applied namechanges of GPU.h into the .c (bitfield=>bits), fixed BG0_3D corrupting 2D background

This commit is contained in:
mightymax 2007-01-11 14:42:00 +00:00
parent 66a6a53327
commit ec21670868
2 changed files with 32 additions and 30 deletions

View File

@ -126,22 +126,22 @@ void GPU_DeInit(GPU * gpu)
void GPU_resortBGs(GPU *gpu)
{
BOOL LayersEnable[5];
u16 WinBG=0;
BOOL LayersEnable[5];
u16 WinBG=0;
int i,q ;
struct _DISPCNT * cnt = &gpu->dispCnt.bits;
if (cnt->Win0_Enable || cnt->Win1_Enable)
{
WinBG = (gpu->WINDOW_INCNT.val | gpu->WINDOW_OUTCNT.val);
WinBG = WinBG | (WinBG >> 8);
WinBG = (gpu->WINDOW_INCNT.val | gpu->WINDOW_OUTCNT.val);
WinBG = WinBG | (WinBG >> 8);
}
// Let's prepare the field for WINDOWS implementation
LayersEnable[0] = gpu->dispBG[0] && (cnt->BG0_Enable || (WinBG & 0x1));
LayersEnable[1] = gpu->dispBG[1] && (cnt->BG1_Enable || (WinBG & 0x2));
LayersEnable[2] = gpu->dispBG[2] && (cnt->BG2_Enable || (WinBG & 0x4));
LayersEnable[3] = gpu->dispBG[3] && (cnt->BG3_Enable || (WinBG & 0x8));
LayersEnable[0] = gpu->dispBG[0] && (cnt->BG0_Enable || (WinBG & 0x1)) && !gpu->dispCnt.bits.BG0_3D ;
LayersEnable[1] = gpu->dispBG[1] && (cnt->BG1_Enable || (WinBG & 0x2)) ;
LayersEnable[2] = gpu->dispBG[2] && (cnt->BG2_Enable || (WinBG & 0x4)) ;
LayersEnable[3] = gpu->dispBG[3] && (cnt->BG3_Enable || (WinBG & 0x8)) ;
LayersEnable[4] = (cnt->OBJ_Enable || (WinBG & 0x10));
/* first: place them all unsorted, just as they are */
@ -154,30 +154,29 @@ u16 WinBG=0;
/* selection sort*/
for (i=0;i<4;i++)
{
/* weighted priorities: first drawn/not drawm, then set priority bits,
then the num the higher the value the lower the priority */
/* weighted priorities: first drawn/not drawm, then set priority bits, then the num */
/* the higher the value the lower the priority */
u8 curPrio = gpu->bgCnt[gpu->ordre[i]].bits.Priority*4 + (LayersEnable[gpu->ordre[i]]?16:0) + gpu->ordre[i] ;
for (q=i+1;q<4;q++)
{
u8 lookingPrio = gpu->bgCnt[gpu->ordre[q]].bits.Priority*4 + (LayersEnable[gpu->ordre[q]]?16:0) + gpu->ordre[q] ;
/* if the one we are looking for is of higher priority then the
current selected, swap them
note: higher value = lower priority */
/* if the one we are looking for is of higher priority then the current selected, swap them */
/* note: higher value = lower priority */
if (lookingPrio > curPrio)
{
/* swap the order */
u8 savedIndex = gpu->ordre[i] ;
gpu->ordre[i] = gpu->ordre[q] ;
gpu->ordre[q] = savedIndex ;
gpu->ordre[i] = gpu->ordre[q] ;
gpu->ordre[q] = savedIndex ;
/* update the current info */
curPrio = lookingPrio ;
curPrio = lookingPrio ;
} ;
}
}
/* once we are done ordering, create the inverse table */
for (i=0;i<4;i++)
{
gpu->BGIndex[gpu->ordre[i]] = i ;
gpu->BGIndex[gpu->ordre[i]] = i ;
/* and remember the processed highest enabled BG */
if (LayersEnable[gpu->ordre[i]]) gpu->nbBGActif = i+1 ;
}
@ -188,6 +187,7 @@ void GPU_setVideoProp(GPU * gpu, u32 p)
{
BOOL LayersEnable[5];
u16 WinBG=0;
int i ;
struct _DISPCNT * cnt = &gpu->dispCnt.bits;
gpu->dispCnt.val = p;
@ -238,20 +238,21 @@ void GPU_setVideoProp(GPU * gpu, u32 p)
}
gpu->sprEnable = cnt->OBJ_Enable;
GPU_setBGProp(gpu, 3, T1ReadWord(ARM9Mem.ARM9_REG, gpu->core * ADDRESS_STEP_4KB + 14));
GPU_setBGProp(gpu, 2, T1ReadWord(ARM9Mem.ARM9_REG, gpu->core * ADDRESS_STEP_4KB + 12));
GPU_setBGProp(gpu, 1, T1ReadWord(ARM9Mem.ARM9_REG, gpu->core * ADDRESS_STEP_4KB + 10));
GPU_setBGProp(gpu, 0, T1ReadWord(ARM9Mem.ARM9_REG, gpu->core * ADDRESS_STEP_4KB + 8));
GPU_resortBGs(gpu) ; /* is allready done in GPU_setBGProb */
GPU_resortBGs(gpu) ; /* is allready done in GPU_setBGProb */
/* FIXME: this debug won't work, obviously ... */
#ifdef DEBUG_TRI
log::ajouter("------------------");
for(u8 i = 0; i < gpu->nbBGActif; ++i)
{
sprintf(logbuf, "bg %d prio %d", gpu->ordre[i], gpu->bgCnt[gpu->ordre[i]].bits.Priority);
sprintf(logbuf, "bg %d prio %d", gpu->ordre[i], gpu->bgCnt[gpu->ordre[i]].bitfield.Priority);
log::ajouter(logbuf);
}
log::ajouter("_________________");
@ -266,9 +267,9 @@ void GPU_setBGProp(GPU * gpu, u16 num, u16 p)
struct _BGxCNT * cnt = &(gpu->bgCnt[num].bits), *cnt2;
int lastPriority = cnt->Priority, mode;
gpu->bgCnt[num].val = p;
GPU_resortBGs(gpu) ; /* is allready done in GPU_setBGProb */
GPU_resortBGs(gpu) ;
if(gpu->core == GPU_SUB) {
gpu->BG_tile_ram[num] = ((u8 *)ARM9Mem.ARM9_BBG);
gpu->BG_bmp_ram[num] = ((u8 *)ARM9Mem.ARM9_BBG);
@ -524,7 +525,7 @@ INLINE BOOL renderline_checkWindowInside(GPU *gpu, u8 bgnum, u16 x, u16 y, BOOL
if (gpu->dispCnt.bits.Win0_Enable) /* highest priority */
{
if (((gpu->WINDOW_XDIM[0].val) && (gpu->WINDOW_YDIM[0].val)) &&
((((x >= gpu->WINDOW_XDIM[0].bits.start) && (x < gpu->WINDOW_XDIM[0].bits.end)) /* || (gpu->WINDOW_XDIM[1].bits.end==0)*/)
((((x >= gpu->WINDOW_XDIM[0].bits.start) && (x < gpu->WINDOW_XDIM[0].bits.end)) /* || (gpu->WINDOW_XDIM[1].bitfield.end==0)*/)
&&(y >= gpu->WINDOW_YDIM[0].bits.start) && (y < gpu->WINDOW_YDIM[0].bits.end)))
{
switch (bgnum) {
@ -566,7 +567,7 @@ INLINE BOOL renderline_checkWindowInside(GPU *gpu, u8 bgnum, u16 x, u16 y, BOOL
if (gpu->dispCnt.bits.Win1_Enable) /* mid priority */
{
if (((gpu->WINDOW_XDIM[1].val) && (gpu->WINDOW_YDIM[1].val)) &&
((((x >= gpu->WINDOW_XDIM[1].bits.start) && (x < gpu->WINDOW_XDIM[1].bits.end)) /* || (gpu->WINDOW_XDIM[1].bits.end==0)*/)
((((x >= gpu->WINDOW_XDIM[1].bits.start) && (x < gpu->WINDOW_XDIM[1].bits.end)) /* || (gpu->WINDOW_XDIM[1].bitfield.end==0)*/)
&&(y >= gpu->WINDOW_YDIM[1].bits.start) && (y < gpu->WINDOW_YDIM[1].bits.end)))
{
switch (bgnum) {
@ -620,7 +621,7 @@ INLINE BOOL renderline_checkWindowOutside(GPU *gpu, u8 bgnum, u16 x, u16 y, BOOL
if (gpu->dispCnt.bits.Win0_Enable) /* highest priority */
{
if (((gpu->WINDOW_XDIM[0].val) && (gpu->WINDOW_YDIM[0].val)) &&
((((x >= gpu->WINDOW_XDIM[0].bits.start) && (x < gpu->WINDOW_XDIM[0].bits.end)) /* || (gpu->WINDOW_XDIM[1].bits.end==0)*/)
((((x >= gpu->WINDOW_XDIM[0].bits.start) && (x < gpu->WINDOW_XDIM[0].bits.end)) /* || (gpu->WINDOW_XDIM[1].bitfield.end==0)*/)
&&(y >= gpu->WINDOW_YDIM[0].bits.start) && (y < gpu->WINDOW_YDIM[0].bits.end)))
{
} else
@ -664,7 +665,7 @@ INLINE BOOL renderline_checkWindowOutside(GPU *gpu, u8 bgnum, u16 x, u16 y, BOOL
if (gpu->dispCnt.bits.Win1_Enable) /* mid priority */
{
if (((gpu->WINDOW_XDIM[1].val) && (gpu->WINDOW_YDIM[1].val)) &&
((((x >= gpu->WINDOW_XDIM[1].bits.start) && (x < gpu->WINDOW_XDIM[1].bits.end)) /* || (gpu->WINDOW_XDIM[1].bits.end==0)*/)
((((x >= gpu->WINDOW_XDIM[1].bits.start) && (x < gpu->WINDOW_XDIM[1].bits.end)) /* || (gpu->WINDOW_XDIM[1].bitfield.end==0)*/)
&&(y >= gpu->WINDOW_YDIM[1].bits.start) && (y < gpu->WINDOW_YDIM[1].bits.end)))
{
} else
@ -1122,9 +1123,9 @@ INLINE void extRotBG2(GPU * gpu, u8 num, u8 * DST, u16 H, s32 X, s32 Y, s16 PA,
u16 mapinfo, i;
u8 coul;
u8 affineModeSelection ;
/* see: http://nocash.emubase.de/gbatek.htm#dsvideobgmodescontrol */
affineModeSelection = (bgCnt.Palette_256) | ((bgCnt.CharacBase_Block & 1) << 1) ;
affineModeSelection = (bgCnt.Palette_256) | ((bgCnt.CharacBase_Block & 1) << 1) ;
switch(affineModeSelection)
{
case 0 :

View File

@ -482,7 +482,8 @@ static INLINE void GPU_ligne(Screen * screen, u16 l)
for(i8 = 0; i8 < gpu->nbBGActif; ++i8)
{
modeRender[gpu->dispCnt.bits.BG_Mode][gpu->ordre[i8]](gpu, gpu->ordre[i8], l, dst);
if (! ((gpu->ordre[i8]==0) && (gpu->dispCnt.bits.BG0_3D)) )
modeRender[gpu->dispCnt.bits.BG_Mode][gpu->ordre[i8]](gpu, gpu->ordre[i8], l, dst);
bgprio = gpu->bgCnt[gpu->ordre[i8]].bits.Priority;
if (gpu->sprEnable)
{