changing gpu->BGProp[] to gpu->bgCnt[]
please use the latter from now on
This commit is contained in:
parent
87de52a0f8
commit
c21a0372e9
|
@ -293,29 +293,23 @@ void GPU_setVideoProp(GPU * gpu, u32 p)
|
||||||
void GPU_setBGProp(GPU * gpu, u16 num, u16 p)
|
void GPU_setBGProp(GPU * gpu, u16 num, u16 p)
|
||||||
{
|
{
|
||||||
u8 index = gpu->BGIndex[num];
|
u8 index = gpu->BGIndex[num];
|
||||||
|
struct _BGxCNT * cnt = &(gpu->bgCnt[num].bitfield), *cnt2;
|
||||||
|
int lastPriority = cnt->Priority;
|
||||||
|
gpu->bgCnt[num].integer = p;
|
||||||
|
|
||||||
if((gpu->nbBGActif != 0) && (index != 0))
|
if((gpu->nbBGActif != 0) && (index != 0))
|
||||||
{
|
{
|
||||||
index--;
|
index--;
|
||||||
if(BGCNT_PRIORITY(gpu->BGProp[num]) < BGCNT_PRIORITY(p))
|
// do we have to re-order the layers ?
|
||||||
|
if(lastPriority < cnt->Priority)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_TRI
|
// check layers before
|
||||||
sprintf(logbuf, "INF NEW bg %d prio %d %d", num, p&3, index);
|
u8 i, ordre;
|
||||||
log::ajouter(logbuf);
|
for( i= 0; i<index; i++) {
|
||||||
for(u8 i = 0; i < gpu->nbBGActif; ++i)
|
ordre = gpu->ordre[i];
|
||||||
{
|
cnt2 = &(gpu->bgCnt[ordre].bitfield);
|
||||||
sprintf(logbuf, "bg %d prio %d", gpu->ordre[i], gpu->BGProp[gpu->ordre[i]]&3);
|
if ((cnt2->Priority >= cnt->Priority) || (ordre > num)) break;
|
||||||
log::ajouter(logbuf);
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
u8 i = 0;
|
|
||||||
for(; (i < index) && (((BGCNT_PRIORITY(gpu->BGProp[gpu->ordre[i]]))>(BGCNT_PRIORITY(p))) || (((BGCNT_PRIORITY(gpu->BGProp[gpu->ordre[i]]))==(BGCNT_PRIORITY(p)))&&(gpu->ordre[i]>num))); ++i); /* TODO: commenting and understanding */
|
|
||||||
|
|
||||||
#ifdef DEBUG_TRI
|
|
||||||
|
|
||||||
sprintf(logbuf, "new i %d old %d", i, index);
|
|
||||||
log::ajouter(logbuf);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(i != index)
|
if(i != index)
|
||||||
{
|
{
|
||||||
|
@ -328,35 +322,16 @@ void GPU_setBGProp(GPU * gpu, u16 num, u16 p)
|
||||||
gpu->ordre[i] = num;
|
gpu->ordre[i] = num;
|
||||||
gpu->BGIndex[num] = i + 1;
|
gpu->BGIndex[num] = i + 1;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_TRI
|
} else if(lastPriority > cnt->Priority) {
|
||||||
log::ajouter("");
|
|
||||||
for(u8 i = 0; i < gpu->nbBGActif; ++i)
|
// check layers after
|
||||||
{
|
u8 i, ordre;
|
||||||
sprintf(logbuf, "bg %d prio %d", gpu->ordre[i], gpu->BGProp[gpu->ordre[i]]&3);
|
for( i= gpu->nbBGActif-1; i>index; i--) {
|
||||||
log::ajouter(logbuf);
|
ordre = gpu->ordre[i];
|
||||||
|
cnt2 = &(gpu->bgCnt[ordre].bitfield);
|
||||||
|
if ((cnt2->Priority >= cnt->Priority) && (ordre < num)) break;
|
||||||
}
|
}
|
||||||
log::ajouter("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(BGCNT_PRIORITY(gpu->BGProp[num])>BGCNT_PRIORITY(p))
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_TRI
|
|
||||||
sprintf(logbuf, "SUP NEW bg %d prio %d", num, p&3);
|
|
||||||
log::ajouter(logbuf);
|
|
||||||
for(u8 i = 0; i < gpu->nbBGActif; ++i)
|
|
||||||
{
|
|
||||||
sprintf(logbuf, "bg %d prio %d", gpu->ordre[i], gpu->BGProp[gpu->ordre[i]]&3);
|
|
||||||
log::ajouter(logbuf);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
u8 i = gpu->nbBGActif-1;
|
|
||||||
for(; (i>index) && ((BGCNT_PRIORITY(gpu->BGProp[gpu->ordre[i]])<BGCNT_PRIORITY(p)) || ((BGCNT_PRIORITY(gpu->BGProp[gpu->ordre[i]])==BGCNT_PRIORITY(p))&&(gpu->ordre[i]<num))); --i);
|
|
||||||
#ifdef DEBUG_TRI
|
|
||||||
sprintf(logbuf, "new i %d old %d", i, index);
|
|
||||||
log::ajouter(logbuf);
|
|
||||||
#endif
|
|
||||||
if(i!=index)
|
if(i!=index)
|
||||||
{
|
{
|
||||||
s8 j;
|
s8 j;
|
||||||
|
@ -368,42 +343,26 @@ void GPU_setBGProp(GPU * gpu, u16 num, u16 p)
|
||||||
gpu->ordre[i] = num;
|
gpu->ordre[i] = num;
|
||||||
gpu->BGIndex[num] = i + 1;
|
gpu->BGIndex[num] = i + 1;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_TRI
|
|
||||||
log::ajouter("");
|
|
||||||
for(u8 i = 0; i < gpu->nbBGActif; ++i)
|
|
||||||
{
|
|
||||||
sprintf(logbuf, "bg %d prio %d", gpu->ordre[i], gpu->BGProp[gpu->ordre[i]]&3);
|
|
||||||
log::ajouter(logbuf);
|
|
||||||
}
|
|
||||||
log::ajouter("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpu->bgCnt[num].integer = p;
|
||||||
gpu->BGProp[num] = p;
|
gpu->BGProp[num] = p;
|
||||||
|
|
||||||
if(gpu->core == GPU_SUB)
|
if(gpu->core == GPU_SUB) {
|
||||||
{
|
gpu->BG_tile_ram[num] = ((u8 *)ARM9Mem.ARM9_BBG);
|
||||||
gpu->BG_bmp_ram[num] = ((u8 *)ARM9Mem.ARM9_BBG) + BGCNT_SCREENBASEBLOCK(p) * ADDRESS_STEP_16KB;
|
gpu->BG_bmp_ram[num] = ((u8 *)ARM9Mem.ARM9_BBG);
|
||||||
gpu->BG_tile_ram[num] = ((u8 *)ARM9Mem.ARM9_BBG) + BGCNT_CHARBASEBLOCK(p) * ADDRESS_STEP_16KB;
|
gpu->BG_map_ram[num] = ARM9Mem.ARM9_BBG;
|
||||||
gpu->BG_map_ram[num] = ARM9Mem.ARM9_BBG + BGCNT_SCREENBASEBLOCK(p) * ADDRESS_STEP_2KB;
|
} else {
|
||||||
}
|
gpu->BG_tile_ram[num] = ((u8 *)ARM9Mem.ARM9_ABG) + gpu->dispCnt.bitfield.CharacBase_Block * ADDRESS_STEP_64kB ;
|
||||||
else
|
gpu->BG_bmp_ram[num] = ((u8 *)ARM9Mem.ARM9_ABG);
|
||||||
{
|
gpu->BG_map_ram[num] = ARM9Mem.ARM9_ABG + gpu->dispCnt.bitfield.ScreenBase_Block * ADDRESS_STEP_64kB;
|
||||||
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.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;
|
|
||||||
}
|
}
|
||||||
|
gpu->BG_tile_ram[num] += (cnt->CharacBase_Block * ADDRESS_STEP_16KB);
|
||||||
|
gpu->BG_bmp_ram[num] += (cnt->ScreenBase_Block * ADDRESS_STEP_16KB);
|
||||||
|
gpu->BG_map_ram[num] += (cnt->ScreenBase_Block * ADDRESS_STEP_2KB);
|
||||||
|
|
||||||
/*if(!(p&(1<<7)))
|
gpu->BGExtPalSlot[num] = cnt->PaletteSet_Wrap * 2 + num ;
|
||||||
BGExtPalSlot[num] = 0;
|
|
||||||
else
|
|
||||||
if(!(prop&(1<<30)))
|
|
||||||
BGExtPalSlot[num] = 0;
|
|
||||||
else*/
|
|
||||||
|
|
||||||
gpu->BGExtPalSlot[num] = BGCNT_EXTPALSLOT(p) * 2 + num ;
|
|
||||||
|
|
||||||
/*if(!(prop&(3<<16)))
|
/*if(!(prop&(3<<16)))
|
||||||
{
|
{
|
||||||
|
@ -412,11 +371,9 @@ void GPU_setBGProp(GPU * gpu, u16 num, u16 p)
|
||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/* we got a naming problem here, dispMode actual is _DISPCNT_.ExMode */
|
int mode = mode2type[gpu->dispCnt.bitfield.BG_Mode][num];
|
||||||
// gpu->BGSize[num][0] = sizeTab[mode2type[gpu->dispMode][num]][BGCNT_SCREENSIZE(p)][0];
|
gpu->BGSize[num][0] = sizeTab[mode][cnt->ScreenSize][0];
|
||||||
// gpu->BGSize[num][1] = sizeTab[mode2type[gpu->dispMode][num]][BGCNT_SCREENSIZE(p)][1];
|
gpu->BGSize[num][1] = sizeTab[mode][cnt->ScreenSize][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];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,10 +86,32 @@ typedef union
|
||||||
struct _DISPCNT bitfield;
|
struct _DISPCNT bitfield;
|
||||||
u32 integer;
|
u32 integer;
|
||||||
} DISPCNT;
|
} DISPCNT;
|
||||||
|
|
||||||
#define BGxENABLED(cnt,num) ((num<8)? ((cnt.integer>>8) & num):0)
|
#define BGxENABLED(cnt,num) ((num<8)? ((cnt.integer>>8) & num):0)
|
||||||
|
|
||||||
|
|
||||||
|
struct _BGxCNT
|
||||||
|
{
|
||||||
|
/*0*/ unsigned Priority:2; // 0..3=high..low
|
||||||
|
/*2*/ unsigned CharacBase_Block:4; // individual character base offset (n*16KB)
|
||||||
|
/*6*/ unsigned Mosaic_Enable:1; // 0=disable, 1=Enable mosaic
|
||||||
|
/*7*/ unsigned Palette_256:1; // 0=16x16, 1=1*256 palette
|
||||||
|
/*8*/ unsigned ScreenBase_Block:5; // individual screen base offset (text n*2KB, BMP n*16KB)
|
||||||
|
/*13*/ unsigned PaletteSet_Wrap:1; // BG0 extended palette set 0=set0, 1=set2
|
||||||
|
// BG1 extended palette set 0=set1, 1=set3
|
||||||
|
// BG2 overflow area wraparound 0=off, 1=wrap
|
||||||
|
// BG3 overflow area wraparound 0=off, 1=wrap
|
||||||
|
/*14*/ unsigned ScreenSize:1; // text : 256x256 512x256 256x512 512x512
|
||||||
|
// x/rot/s : 128x128 256x256 512x512 1024x1024
|
||||||
|
// bmp : 128x128 256x256 512x256 512x512
|
||||||
|
// large : 512x1024 1024x512 - -
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct _BGxCNT bitfield;
|
||||||
|
u16 integer;
|
||||||
|
} BGxCNT;
|
||||||
|
|
||||||
#define BGCNT_PRIORITY(val) ((val) & 3)
|
#define BGCNT_PRIORITY(val) ((val) & 3)
|
||||||
#define BGCNT_CHARBASEBLOCK(val) (((val) >> 2) & 0x0F)
|
#define BGCNT_CHARBASEBLOCK(val) (((val) >> 2) & 0x0F)
|
||||||
#define BGCNT_256COL(val) (((val) >> 7) & 0x1)
|
#define BGCNT_256COL(val) (((val) >> 7) & 0x1)
|
||||||
|
@ -162,7 +184,7 @@ typedef struct _GPU GPU;
|
||||||
struct _GPU
|
struct _GPU
|
||||||
{
|
{
|
||||||
DISPCNT dispCnt;
|
DISPCNT dispCnt;
|
||||||
int bgXenabled;
|
BGxCNT bgCnt[4];
|
||||||
|
|
||||||
u16 BGProp[4];
|
u16 BGProp[4];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue