From b4a3a5ddefeec4bd71944d0a896542828b41f6ed Mon Sep 17 00:00:00 2001 From: luigi__ Date: Mon, 19 Jan 2009 19:04:10 +0000 Subject: [PATCH] Better determination if BG0 has the highest prio. --- desmume/src/GPU.cpp | 22 +++++++++++++++++++--- desmume/src/GPU.h | 2 ++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/desmume/src/GPU.cpp b/desmume/src/GPU.cpp index b01aeac16..345af400d 100644 --- a/desmume/src/GPU.cpp +++ b/desmume/src/GPU.cpp @@ -288,6 +288,8 @@ void GPU_Reset(GPU *g, u8 l) g->bgPrio[4] = 0xFF; + g->bg0HasHighestPrio = TRUE; + if(g->core == GPU_SUB) { g->oam = (OAM *)(ARM9Mem.ARM9_OAM + ADDRESS_STEP_1KB); @@ -357,6 +359,20 @@ static void GPU_resortBGs(GPU *gpu) item->BGs[item->nbBGs]=i; item->nbBGs++; } + + int bg0Prio = gpu->dispx_st->dispx_BGxCNT[0].bits.Priority; + gpu->bg0HasHighestPrio = TRUE; + for(i = 1; i < 4; i++) + { + if(gpu->LayersEnable[i]) + { + if(gpu->dispx_st->dispx_BGxCNT[i].bits.Priority < bg0Prio) + { + gpu->bg0HasHighestPrio = FALSE; + break; + } + } + } #if 0 //debug @@ -1213,7 +1229,7 @@ static BOOL setFinal3DColorSpecialBlend(GPU *gpu, u32 passing, u8 *dst, u16 colo { /* We can blend if the 3D layer is selected as 1st target, */ /* but also if the 3D layer has the highest prio. */ - if((gpu->BLDCNT & 0x1) || (gpu->dispx_st->dispx_BGxCNT[0].bits.Priority == 0)) + if((gpu->BLDCNT & 0x1) || gpu->bg0HasHighestPrio) { int bg_under = gpu->bgPixels[x]; u16 final = color; @@ -1324,7 +1340,7 @@ static BOOL setFinal3DColorSpecialBlendWnd(GPU *gpu, u32 passing, u8 *dst, u16 c { /* We can blend if the 3D layer is selected as 1st target, */ /* but also if the 3D layer has the highest prio. */ - if(((gpu->BLDCNT & 0x1) && windowEffect) || (gpu->dispx_st->dispx_BGxCNT[0].bits.Priority == 0)) + if(((gpu->BLDCNT & 0x1) && windowEffect) || gpu->bg0HasHighestPrio) { int bg_under = gpu->bgPixels[x]; u16 final = color; @@ -1473,7 +1489,7 @@ INLINE void renderline_textBG(GPU * gpu, u8 num, u8 * dst, u32 Y, u16 XBG, u16 Y if(!bgCnt->Palette_256) // color: 16 palette entries { - if (bgCnt->Mosaic_Enable){ + if (bgCnt->Mosaic_Enable && 0){ //test NDS: #2 of http://desmume.sourceforge.net/forums/index.php?action=vthread&forum=2&topic=50&page=0#msg192 u8 mw = (mosaic & 0xF) +1 ; // horizontal granularity of the mosaic diff --git a/desmume/src/GPU.h b/desmume/src/GPU.h index 369dc8fa8..31adcd1d4 100644 --- a/desmume/src/GPU.h +++ b/desmume/src/GPU.h @@ -624,6 +624,8 @@ struct _GPU u8 bgPrio[5]; + BOOL bg0HasHighestPrio; + OAM * oam; u32 sprMem; u8 sprBoundary;