used union for better handling of bitfields
This commit is contained in:
parent
f5238bcf92
commit
07a8b0f032
|
@ -126,9 +126,8 @@ void GPU_DeInit(GPU * gpu)
|
|||
/* Sets up LCD control variables for Display Engines A and B for quick reading */
|
||||
void GPU_setVideoProp(GPU * gpu, u32 p)
|
||||
{
|
||||
*((u32*) &gpu->dispCnt) = p;
|
||||
gpu->bgXenabled = (p >> 8); // we want bits BG0_Enable..WinOBJ_Enable
|
||||
_DISPCNT_ * cnt = &gpu->dispCnt;
|
||||
gpu->dispCnt.integer = p;
|
||||
struct _DISPCNT * cnt = &gpu->dispCnt.bitfield;
|
||||
|
||||
// gpu->dispMode = DISPCNT_DISPLAY_MODE(p,gpu->lcd) ;
|
||||
gpu->dispMode = cnt->DisplayMode & ((gpu->lcd)?1:3);
|
||||
|
@ -393,8 +392,8 @@ void GPU_setBGProp(GPU * gpu, u16 num, u16 p)
|
|||
else
|
||||
{
|
||||
gpu->BG_bmp_ram[num] = ((u8 *)ARM9Mem.ARM9_ABG) + BGCNT_SCREENBASEBLOCK(p) * ADDRESS_STEP_16KB;
|
||||
gpu->BG_tile_ram[num] = ((u8 *)ARM9Mem.ARM9_ABG) + BGCNT_CHARBASEBLOCK(p) * ADDRESS_STEP_16KB + (gpu->dispCnt).CharacBase_Block * ADDRESS_STEP_64kB ;
|
||||
gpu->BG_map_ram[num] = ARM9Mem.ARM9_ABG + BGCNT_SCREENBASEBLOCK(p) * ADDRESS_STEP_2KB + (gpu->dispCnt).ScreenBase_Block * ADDRESS_STEP_64kB;
|
||||
gpu->BG_tile_ram[num] = ((u8 *)ARM9Mem.ARM9_ABG) + BGCNT_CHARBASEBLOCK(p) * ADDRESS_STEP_16KB + gpu->dispCnt.bitfield.CharacBase_Block * ADDRESS_STEP_64kB ;
|
||||
gpu->BG_map_ram[num] = ARM9Mem.ARM9_ABG + BGCNT_SCREENBASEBLOCK(p) * ADDRESS_STEP_2KB + gpu->dispCnt.bitfield.ScreenBase_Block * ADDRESS_STEP_64kB;
|
||||
}
|
||||
|
||||
/*if(!(p&(1<<7)))
|
||||
|
@ -416,8 +415,8 @@ void GPU_setBGProp(GPU * gpu, u16 num, u16 p)
|
|||
/* we got a naming problem here, dispMode actual is _DISPCNT_.ExMode */
|
||||
// gpu->BGSize[num][0] = sizeTab[mode2type[gpu->dispMode][num]][BGCNT_SCREENSIZE(p)][0];
|
||||
// gpu->BGSize[num][1] = sizeTab[mode2type[gpu->dispMode][num]][BGCNT_SCREENSIZE(p)][1];
|
||||
gpu->BGSize[num][0] = sizeTab[mode2type[(gpu->dispCnt).BG_Mode][num]][BGCNT_SCREENSIZE(p)][0];
|
||||
gpu->BGSize[num][1] = sizeTab[mode2type[(gpu->dispCnt).BG_Mode][num]][BGCNT_SCREENSIZE(p)][1];
|
||||
gpu->BGSize[num][0] = sizeTab[mode2type[gpu->dispCnt.bitfield.BG_Mode][num]][BGCNT_SCREENSIZE(p)][0];
|
||||
gpu->BGSize[num][1] = sizeTab[mode2type[gpu->dispCnt.bitfield.BG_Mode][num]][BGCNT_SCREENSIZE(p)][1];
|
||||
|
||||
}
|
||||
|
||||
|
@ -442,7 +441,7 @@ void GPU_remove(GPU * gpu, u8 num)
|
|||
|
||||
void GPU_addBack(GPU * gpu, u8 num)
|
||||
{
|
||||
if((!gpu->BGIndex[num])&& BGxENABLED(gpu,num))
|
||||
if((!gpu->BGIndex[num])&& BGxENABLED(gpu->dispCnt,num))
|
||||
{
|
||||
u8 i = 0;
|
||||
s8 j;
|
||||
|
@ -792,7 +791,7 @@ INLINE void renderline_textBG(GPU * gpu, u8 num, u8 * DST, u16 X, u16 Y, u16 LG)
|
|||
}
|
||||
return;
|
||||
}
|
||||
if(!(gpu->dispCnt).ExBGxPalette_Enable) /* color: no extended palette */
|
||||
if(!gpu->dispCnt.bitfield.ExBGxPalette_Enable) /* color: no extended palette */
|
||||
{
|
||||
yoff = ((Y&7)<<3);
|
||||
pal = ARM9Mem.ARM9_VMEM + gpu->core * ADDRESS_STEP_1KB ;
|
||||
|
@ -1179,7 +1178,7 @@ void sprite1D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab)
|
|||
u16 i;
|
||||
src = gpu->sprMem + (spriteInfo->TileIndex<<block) + ((y>>3)*sprSize.x*8) + ((y&0x7)*8);
|
||||
|
||||
if ((gpu->dispCnt).ExOBJPalette_Enable)
|
||||
if (gpu->dispCnt.bitfield.ExOBJPalette_Enable)
|
||||
pal = ARM9Mem.ObjExtPal[gpu->core][0]+(spriteInfo->PaletteIndex*0x200);
|
||||
else
|
||||
pal = ARM9Mem.ARM9_VMEM + 0x200 + gpu->core *0x400;
|
||||
|
|
|
@ -46,7 +46,7 @@ extern "C" {
|
|||
#define ADDRESS_STEP_32KB 0x08000
|
||||
#define ADDRESS_STEP_64kB 0x10000
|
||||
|
||||
typedef struct
|
||||
struct _DISPCNT
|
||||
{
|
||||
/*0*/ unsigned BG_Mode:3; // A+B:
|
||||
/*3*/ unsigned BG0_3D:1; // A : 0=2D, 1=3D
|
||||
|
@ -79,32 +79,23 @@ typedef struct
|
|||
/*27*/ unsigned ScreenBase_Block:3; // A : Screen Base (64K step)
|
||||
/*30*/ unsigned ExBGxPalette_Enable:1; // A+B: 0=disable, 1=Enable BG extended Palette
|
||||
/*31*/ unsigned ExOBJPalette_Enable:1; // A+B: 0=disable, 1=Enable OBJ extended Palette
|
||||
} _DISPCNT_;
|
||||
};
|
||||
|
||||
#define BGxENABLED(gpu,num) ((num<8)? (gpu->bgXenabled & num):0)
|
||||
typedef union
|
||||
{
|
||||
struct _DISPCNT bitfield;
|
||||
u32 integer;
|
||||
} DISPCNT;
|
||||
|
||||
/* these defines no more useful, do we keep them ? */
|
||||
#define DISPCNT_OBJMAPING1D(val) (((val) >> 4) & 1)
|
||||
#define DISPCNT_BG0ENABLED(val) (((val) >> 8) & 1)
|
||||
#define DISPCNT_BG1ENABLED(val) (((val) >> 9) & 1)
|
||||
#define DISPCNT_BG2ENABLED(val) (((val) >> 10) & 1)
|
||||
#define DISPCNT_BG3ENABLED(val) (((val) >> 11) & 1)
|
||||
#define DISPCNT_SPRITEENABLE(val) (((val) >> 12) & 1)
|
||||
#define DISPCNT_MODE(val) ((val) & 7)
|
||||
/* display mode: gpu0: (val>>16) & 3, gpu1: (val>>16) & 1 */
|
||||
#define DISPCNT_DISPLAY_MODE(val,num) (((val) >> 16) & ((num)?1:3))
|
||||
#define DISPCNT_VRAMBLOCK(val) (((val) >> 18) & 3)
|
||||
#define DISPCNT_TILEOBJ1D_BOUNDARY(val) (((val) >> 20) & 3)
|
||||
#define DISPCNT_BMPOBJ1D_BOUNDARY(val) (((val) >> 22) & 1)
|
||||
#define DISPCNT_SCREENBASEBLOCK(val) (((val) >> 27) & 7)
|
||||
#define DISPCNT_USEEXTPAL(val) (((val) >> 30) & 1)
|
||||
#define BGxENABLED(cnt,num) ((num<8)? ((cnt.integer>>8) & num):0)
|
||||
|
||||
#define BGCNT_PRIORITY(val) ((val) & 3)
|
||||
#define BGCNT_CHARBASEBLOCK(val) (((val) >> 2) & 0x0F)
|
||||
#define BGCNT_256COL(val) (((val) >> 7) & 0x1)
|
||||
#define BGCNT_SCREENBASEBLOCK(val) (((val) >> 8) & 0x1F)
|
||||
#define BGCNT_EXTPALSLOT(val) (((val) >> 13) & 0x1)
|
||||
#define BGCNT_SCREENSIZE(val) (((val) >> 14) & 0x3)
|
||||
|
||||
#define BGCNT_PRIORITY(val) ((val) & 3)
|
||||
#define BGCNT_CHARBASEBLOCK(val) (((val) >> 2) & 0x0F)
|
||||
#define BGCNT_256COL(val) (((val) >> 7) & 0x1)
|
||||
#define BGCNT_SCREENBASEBLOCK(val) (((val) >> 8) & 0x1F)
|
||||
#define BGCNT_EXTPALSLOT(val) (((val) >> 13) & 0x1)
|
||||
#define BGCNT_SCREENSIZE(val) (((val) >> 14) & 0x3)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -148,7 +139,7 @@ typedef struct _GPU GPU;
|
|||
|
||||
struct _GPU
|
||||
{
|
||||
_DISPCNT_ dispCnt;
|
||||
DISPCNT dispCnt;
|
||||
int bgXenabled;
|
||||
|
||||
u16 BGProp[4];
|
||||
|
@ -302,7 +293,7 @@ static INLINE void GPU_ligne(Screen * screen, u16 l)
|
|||
|
||||
for(i8 = 0; i8 < gpu->nbBGActif; ++i8)
|
||||
{
|
||||
modeRender[gpu->dispCnt.BG_Mode][gpu->ordre[i8]](gpu, gpu->ordre[i8], l, dst);
|
||||
modeRender[gpu->dispCnt.bitfield.BG_Mode][gpu->ordre[i8]](gpu, gpu->ordre[i8], l, dst);
|
||||
bgprio = gpu->BGProp[gpu->ordre[i8]]&3;
|
||||
if (gpu->sprEnable)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue