Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 53 additions & 59 deletions lib/pbkit/pbkit.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@
#define ADDR_FBMEM 2
#define ADDR_AGPMEM 3

#define DMA_CLASS_2 2
#define DMA_CLASS_3 3
#define DMA_CLASS_3D 0x3D

#define GR_CLASS_30 0x30
#define GR_CLASS_39 0x39
#define GR_CLASS_62 0x62
#define GR_CLASS_97 0x97
#define GR_CLASS_9F 0x9F

#define GPU_IRQ 3

#define XTAL_16MHZ 16.6667f
Expand Down Expand Up @@ -1128,11 +1118,11 @@ static void pb_prepare_tiles(void)



static void pb_create_dma_ctx( DWORD ChannelID,
DWORD Class,
DWORD Base,
DWORD Limit,
struct s_CtxDma *pDmaObject )
void pb_create_dma_ctx(DWORD ChannelID,
DWORD Class,
DWORD Base,
DWORD Limit,
struct s_CtxDma *pDmaObject)
{
DWORD Addr;
DWORD AddrSpace;
Expand Down Expand Up @@ -1177,7 +1167,7 @@ static void pb_create_dma_ctx( DWORD ChannelID,



static void pb_bind_channel(struct s_CtxDma *pCtxDmaObject)
void pb_bind_channel(struct s_CtxDma *pCtxDmaObject)
{
DWORD entry;
DWORD *p;
Expand Down Expand Up @@ -1408,70 +1398,73 @@ static void pb_3D_init(void)
#endif
}

static inline void pb_create_gr_instance(int ChannelID,
int Class,
DWORD instance,
DWORD flags,
DWORD flags3D,
struct s_CtxDma *pGrObject)
{
DWORD offset = instance << 4;
VIDEOREG(NV_PRAMIN + offset + 0x00) = flags;
VIDEOREG(NV_PRAMIN + offset + 0x04) = flags3D;
VIDEOREG(NV_PRAMIN + offset + 0x08) = 0;
VIDEOREG(NV_PRAMIN + offset + 0x0C) = 0;

memset(pGrObject,0,sizeof(struct s_CtxDma));

pGrObject->ChannelID = ChannelID;
pGrObject->Class = Class;
pGrObject->isGr = 1;
pGrObject->Inst = instance;
}


static void pb_create_gr_ctx( int ChannelID,
int Class,
struct s_CtxDma *pGrObject )
void pb_create_gr_ctx(int ChannelID,
int Class,
struct s_CtxDma *pGrObject)
{
DWORD flags;
DWORD flags3D;

int size;

int size;
DWORD Inst;

flags=Class&0x000000FF;
flags3D=0;

if ( (Class!=GR_CLASS_30)&&
(Class!=GR_CLASS_39)&&
(Class!=GR_CLASS_62)&&
(Class!=GR_CLASS_97)&&
(Class!=GR_CLASS_9F) )
switch (Class)
{
case GR_CLASS_97:
size=0x330; //816 bytes
flags3D=0x00000A00;
break;
case GR_CLASS_39:
size=16; //16 bytes
flags|=0x01000000;
break;
case GR_CLASS_12:
case GR_CLASS_19:
case GR_CLASS_30:
case GR_CLASS_62:
case GR_CLASS_72:
case GR_CLASS_9F:
size=16; //16 bytes
break;
default:
//"CreateGrObject invalid class number"
size=Class;
}
else
{
size=16; //16 bytes
if (Class==GR_CLASS_97)
{
size=0x330; //816 bytes
flags3D=1;
}
break;
}

Inst=pb_FreeInst; pb_FreeInst+=(size>>4);
Inst=pb_FreeInst;
pb_FreeInst+=(size>>4);

if (flags3D)
{
pb_3DGrCtxInst[pb_FifoChannelID]=Inst;
pb_3D_init();
}


flags=Class&0x000000FF;
flags3D=0x00000000;

if (Class==GR_CLASS_39) flags|=0x01000000;

if (Class==GR_CLASS_97) flags3D=0x00000A00;

VIDEOREG(NV_PRAMIN+(Inst<<4)+0x00)=flags;
VIDEOREG(NV_PRAMIN+(Inst<<4)+0x04)=flags3D;
VIDEOREG(NV_PRAMIN+(Inst<<4)+0x08)=0;
VIDEOREG(NV_PRAMIN+(Inst<<4)+0x0C)=0;


memset(pGrObject,0,sizeof(struct s_CtxDma));

pGrObject->ChannelID=ChannelID;
pGrObject->Class=Class;
pGrObject->isGr=1;
pGrObject->Inst=Inst;
pb_create_gr_instance(ChannelID, Class, Inst, flags, flags3D, pGrObject);
}


Expand Down Expand Up @@ -2181,7 +2174,8 @@ void pb_kill(void)
}


void pb_set_color_format(unsigned int fmt, bool swizzled) {
void pb_set_color_format(unsigned int fmt, bool swizzled)
{
pb_ColorFmt = fmt;
assert(swizzled == false);
}
Expand Down
19 changes: 16 additions & 3 deletions lib/pbkit/pbkit_dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,26 @@ struct s_CtxDma
};

// Points an existing DMA context object at a new address.
void pb_set_dma_address (const struct s_CtxDma *context, const void *address, uint32_t limit);
void pb_set_dma_address(const struct s_CtxDma *context, const void *address, uint32_t limit);

// Binds a subchannel to the given context.
void pb_bind_subchannel (uint32_t subchannel, const struct s_CtxDma *context);
void pb_bind_subchannel(uint32_t subchannel, const struct s_CtxDma *context);

// Returns an AGP version of the given nv2a tiled memory address.
void *pb_agp_access (void *fb_memory_pointer);
void *pb_agp_access(void *fb_memory_pointer);

// Creates a DMA context for the given channel, class, and address space.
void pb_create_dma_ctx(DWORD ChannelID,
DWORD Class,
DWORD Base,
DWORD Limit,
struct s_CtxDma *pDmaObject);

// Binds the given DMA context.
void pb_bind_channel(struct s_CtxDma *pCtxDmaObject);

// Creates the context object for the given DMA object.
void pb_create_gr_ctx(int ChannelID, int Class, struct s_CtxDma *pCtxDmaObject);

#ifdef __cplusplus
}
Expand Down
Loading