cleaned BGProp[] out

:)
This commit is contained in:
damdoum 2007-01-11 10:14:42 +00:00
parent e5918ccbc6
commit cf4d99a320
2 changed files with 31 additions and 24 deletions

View File

@ -213,7 +213,7 @@ void GPU_setVideoProp(GPU * gpu, u32 p)
{ {
if(gpu->nbBGActif) if(gpu->nbBGActif)
{ {
if(BGCNT_PRIORITY(gpu->BGProp[2]) > BGCNT_PRIORITY(gpu->BGProp[3])) if(gpu->bgCnt[2].bitfield.Priority > gpu->bgCnt[3].bitfield.Priority)
{ {
gpu->ordre[0] = 2; gpu->ordre[0] = 2;
gpu->BGIndex[2] = 1; gpu->BGIndex[2] = 1;
@ -249,9 +249,11 @@ void GPU_setVideoProp(GPU * gpu, u32 p)
} }
else else
{ {
u8 i = 0; u8 i;
s8 j; s8 j;
for(; (i < gpu->nbBGActif) && (BGCNT_PRIORITY(gpu->BGProp[gpu->ordre[i]]) >= BGCNT_PRIORITY(gpu->BGProp[1])); ++i); for(i=0; i < gpu->nbBGActif; i++)
if (gpu->bgCnt[gpu->ordre[i]].bitfield.Priority >= gpu->bgCnt[1].bitfield.Priority) break;
for(j = gpu->nbBGActif-1; j >= i; --j) for(j = gpu->nbBGActif-1; j >= i; --j)
{ {
gpu->ordre[j+1] = gpu->ordre[j]; gpu->ordre[j+1] = gpu->ordre[j];
@ -278,7 +280,9 @@ void GPU_setVideoProp(GPU * gpu, u32 p)
{ {
u8 i = 0; u8 i = 0;
s8 j; s8 j;
for(; (i < gpu->nbBGActif) && (BGCNT_PRIORITY(gpu->BGProp[gpu->ordre[i]]) >= BGCNT_PRIORITY(gpu->BGProp[0])); ++i); for(; (i < gpu->nbBGActif); i++)
if (gpu->bgCnt[gpu->ordre[i]].bitfield.Priority >= gpu->bgCnt[0].bitfield.Priority) break;
for(j = gpu->nbBGActif-1; j >= i; --j) for(j = gpu->nbBGActif-1; j >= i; --j)
{ {
gpu->ordre[j+1] = gpu->ordre[j]; gpu->ordre[j+1] = gpu->ordre[j];
@ -299,7 +303,7 @@ void GPU_setVideoProp(GPU * gpu, u32 p)
log::ajouter("------------------"); log::ajouter("------------------");
for(u8 i = 0; i < gpu->nbBGActif; ++i) for(u8 i = 0; i < gpu->nbBGActif; ++i)
{ {
sprintf(logbuf, "bg %d prio %d", gpu->ordre[i], gpu->BGProp[gpu->ordre[i]]&3); sprintf(logbuf, "bg %d prio %d", gpu->ordre[i], gpu->bgCnt[gpu->ordre[i]].bitfield.Priority);
log::ajouter(logbuf); log::ajouter(logbuf);
} }
log::ajouter("_________________"); log::ajouter("_________________");
@ -365,7 +369,6 @@ void GPU_setBGProp(GPU * gpu, u16 num, u16 p)
} }
gpu->bgCnt[num].integer = p; gpu->bgCnt[num].integer = 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_tile_ram[num] = ((u8 *)ARM9Mem.ARM9_BBG);
@ -429,8 +432,10 @@ void GPU_addBack(GPU * gpu, u8 num)
{ {
u8 i = 0; u8 i = 0;
s8 j; s8 j;
u8 p = gpu->BGProp[num]&3; u8 p = gpu->bgCnt[num].bitfield.Priority;
for(; (i<gpu->nbBGActif) && (((gpu->BGProp[gpu->ordre[i]]&3)>p) || (((gpu->BGProp[gpu->ordre[i]]&3)==p)&&(gpu->ordre[i]>num))); ++i); for(; i<gpu->nbBGActif; ++i)
if ((gpu->bgCnt[gpu->ordre[i]].bitfield.Priority >=p)&&(gpu->ordre[i]>num)) break;
for(j = gpu->nbBGActif-1; j >= i; --j) for(j = gpu->nbBGActif-1; j >= i; --j)
{ {
gpu->ordre[j+1] = gpu->ordre[j]; gpu->ordre[j+1] = gpu->ordre[j];
@ -900,7 +905,7 @@ INLINE void renderline_setFinalColor(GPU *gpu,u32 passing,u8 bgnum,u8 *dst,u16 c
/* render a text background to the combined pixelbuffer */ /* render a text background to the combined pixelbuffer */
INLINE void renderline_textBG(GPU * gpu, u8 num, u8 * DST, u16 X, u16 Y, u16 LG) INLINE void renderline_textBG(GPU * gpu, u8 num, u8 * DST, u16 X, u16 Y, u16 LG)
{ {
u32 bgprop = gpu->BGProp[num]; struct _BGxCNT bgCnt = gpu->bgCnt[num].bitfield;
u16 lg = gpu->BGSize[num][0]; u16 lg = gpu->BGSize[num][0];
u16 ht = gpu->BGSize[num][1]; u16 ht = gpu->BGSize[num][1];
u16 tmp = ((Y&(ht-1))>>3); u16 tmp = ((Y&(ht-1))>>3);
@ -914,17 +919,19 @@ INLINE void renderline_textBG(GPU * gpu, u8 num, u8 * DST, u16 X, u16 Y, u16 LG)
if(tmp>31) if(tmp>31)
{ {
map+= ADDRESS_STEP_512B << BGCNT_SCREENSIZE(bgprop) ; map+= ADDRESS_STEP_512B << bgCnt.ScreenSize ;
} }
tile = (u8*) gpu->BG_tile_ram[num]; tile = (u8*) gpu->BG_tile_ram[num];
if((!tile) || (!gpu->BG_map_ram[num])) return; /* no tiles or no map*/ if((!tile) || (!gpu->BG_map_ram[num])) return; /* no tiles or no map*/
xoff = X; xoff = X;
if(!BGCNT_256COL(bgprop)) /* color: 16 palette entries */ if(!bgCnt.Palette_256) /* color: 16 palette entries */
{ {
if (bgprop & 0x0400){ /* CHECKME: mosaic mode: see @ http://nocash.emubase.de/gbatek.htm#lcdiobgcontrol */ if (bgCnt.Mosaic_Enable){
/* test NDS: #2 of http://desmume.sourceforge.net/forums/index.php?action=vthread&forum=2&topic=50&page=0#msg192 */ /* test NDS: #2 of
http://desmume.sourceforge.net/forums/index.php?action=vthread&forum=2&topic=50&page=0#msg192 */
u8 mw = (gpu->MOSAIC & 0xF) +1 ; /* horizontal granularity of the mosaic */ u8 mw = (gpu->MOSAIC & 0xF) +1 ; /* horizontal granularity of the mosaic */
u8 mh = ((gpu->MOSAIC>>4) & 0xF) +1 ; /* vertical granularity of the mosaic */ u8 mh = ((gpu->MOSAIC>>4) & 0xF) +1 ; /* vertical granularity of the mosaic */
Y = (Y / mh) * mh ; /* align y by vertical granularity */ Y = (Y / mh) * mh ; /* align y by vertical granularity */
@ -1142,7 +1149,7 @@ INLINE void renderline_textBG(GPU * gpu, u8 num, u8 * DST, u16 X, u16 Y, u16 LG)
INLINE void rotBG2(GPU * gpu, u8 num, u8 * DST, u16 H, s32 X, s32 Y, s16 PA, s16 PB, s16 PC, s16 PD, u16 LG) INLINE void rotBG2(GPU * gpu, u8 num, u8 * DST, u16 H, s32 X, s32 Y, s16 PA, s16 PB, s16 PC, s16 PD, u16 LG)
{ {
u32 bgprop = gpu->BGProp[num]; struct _BGxCNT bgCnt = gpu->bgCnt[num].bitfield;
s32 x = X + (s32)PB*(s32)H; s32 x = X + (s32)PB*(s32)H;
s32 y = Y + (s32)PD*(s32)H; s32 y = Y + (s32)PD*(s32)H;
@ -1174,7 +1181,7 @@ INLINE void rotBG2(GPU * gpu, u8 num, u8 * DST, u16 H, s32 X, s32 Y, s16 PA, s16
auxX = x>>8; auxX = x>>8;
auxY = y>>8; auxY = y>>8;
if(bgprop&(1<<13)) if(bgCnt.PaletteSet_Wrap)
{ {
auxX &= (lg-1); auxX &= (lg-1);
auxY &= (ht-1); auxY &= (ht-1);
@ -1195,7 +1202,7 @@ INLINE void rotBG2(GPU * gpu, u8 num, u8 * DST, u16 H, s32 X, s32 Y, s16 PA, s16
INLINE void extRotBG2(GPU * gpu, u8 num, u8 * DST, u16 H, s32 X, s32 Y, s16 PA, s16 PB, s16 PC, s16 PD, s16 LG) INLINE void extRotBG2(GPU * gpu, u8 num, u8 * DST, u16 H, s32 X, s32 Y, s16 PA, s16 PB, s16 PC, s16 PD, s16 LG)
{ {
u32 bgprop = gpu->BGProp[num]; struct _BGxCNT bgCnt = gpu->bgCnt[num].bitfield;
s32 x = X + (s32)PB*(s32)H; s32 x = X + (s32)PB*(s32)H;
s32 y = Y + (s32)PD*(s32)H; s32 y = Y + (s32)PD*(s32)H;
@ -1216,7 +1223,8 @@ INLINE void extRotBG2(GPU * gpu, u8 num, u8 * DST, u16 H, s32 X, s32 Y, s16 PA,
u16 mapinfo, i; u16 mapinfo, i;
u8 coul; u8 coul;
switch(((bgprop>>2)&1)|((bgprop>>6)&2)) // damdoum : I just replaced here but I dont understand it yet
switch((bgCnt.CharacBase_Block&1)|(bgCnt.Mosaic_Enable << 1))
{ {
case 0 : case 0 :
case 1 : case 1 :
@ -1227,7 +1235,7 @@ INLINE void extRotBG2(GPU * gpu, u8 num, u8 * DST, u16 H, s32 X, s32 Y, s16 PA,
#define LOOP(c) \ #define LOOP(c) \
for(i = 0; i < LG; ++i) { \ for(i = 0; i < LG; ++i) { \
auxX = x>>8; auxY = y>>8; \ auxX = x>>8; auxY = y>>8; \
if(bgprop&(1<<13)) { \ if(bgCnt.PaletteSet_Wrap) { \
auxX &= (lg-1); auxY &= (ht-1); \ auxX &= (lg-1); auxY &= (ht-1); \
} \ } \
if ((auxX >= 0) && (auxX < lg) && (auxY >= 0) && (auxY < ht)) c \ if ((auxX >= 0) && (auxX < lg) && (auxY >= 0) && (auxY < ht)) c \

View File

@ -169,7 +169,7 @@ struct _BGxCNT
// BG1 extended palette set 0=set1, 1=set3 // BG1 extended palette set 0=set1, 1=set3
// BG2 overflow area wraparound 0=off, 1=wrap // BG2 overflow area wraparound 0=off, 1=wrap
// BG3 overflow area wraparound 0=off, 1=wrap // BG3 overflow area wraparound 0=off, 1=wrap
/*14*/ unsigned ScreenSize:1; // text : 256x256 512x256 256x512 512x512 /*14*/ unsigned ScreenSize:2; // text : 256x256 512x256 256x512 512x512
// x/rot/s : 128x128 256x256 512x512 1024x1024 // x/rot/s : 128x128 256x256 512x512 1024x1024
// bmp : 128x128 256x256 512x256 512x512 // bmp : 128x128 256x256 512x256 512x512
// large : 512x1024 1024x512 - - // large : 512x1024 1024x512 - -
@ -299,9 +299,7 @@ struct _GPU
{ {
DISPCNT dispCnt; DISPCNT dispCnt;
BGxCNT bgCnt[4]; BGxCNT bgCnt[4];
u16 BGProp[4];
#define BGBmpBB BG_bmp_ram #define BGBmpBB BG_bmp_ram
#define BGChBB BG_tile_ram #define BGChBB BG_tile_ram
@ -451,7 +449,8 @@ static INLINE void GPU_ligne(Screen * screen, u16 l)
if (gpu->sprEnable) if (gpu->sprEnable)
{ {
gpu->spriteRender(gpu, l, spr, sprPrio); gpu->spriteRender(gpu, l, spr, sprPrio);
if((gpu->BGProp[gpu->ordre[0]]&3)!=3)
if(gpu->bgCnt[gpu->ordre[0]].bitfield.Priority !=3)
{ {
for(i16 = 0; i16 < 128; ++i16) { for(i16 = 0; i16 < 128; ++i16) {
T2WriteLong(dst, i16 << 2, T2ReadLong(spr, i16 << 2)); T2WriteLong(dst, i16 << 2, T2ReadLong(spr, i16 << 2));
@ -462,7 +461,7 @@ static INLINE void GPU_ligne(Screen * screen, u16 l)
for(i8 = 0; i8 < gpu->nbBGActif; ++i8) for(i8 = 0; i8 < gpu->nbBGActif; ++i8)
{ {
modeRender[gpu->dispCnt.bitfield.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; bgprio = gpu->bgCnt[gpu->ordre[i8]].bitfield.Priority;
if (gpu->sprEnable) if (gpu->sprEnable)
{ {
for(i16 = 0; i16 < 256; ++i16) for(i16 = 0; i16 < 256; ++i16)