From f9e8e9c862a5ff8d0af433c1252a8a052e1525d8 Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 23 Nov 2009 00:53:46 +0000 Subject: [PATCH] gpu: clean up use of scroll registers to make sure that the correct &0x1FF is done everywhere --- desmume/src/GPU.cpp | 16 +++++----------- desmume/src/GPU.h | 3 +++ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/desmume/src/GPU.cpp b/desmume/src/GPU.cpp index 181d62c80..823f0ef03 100644 --- a/desmume/src/GPU.cpp +++ b/desmume/src/GPU.cpp @@ -868,10 +868,9 @@ template void lineLarge8bpp(GPU * gpu) return; } - BGxOFS * ofs = &gpu->dispx_st->dispx_BGxOFS[gpu->currBgNum]; u8 num = gpu->currBgNum; - u16 XBG = T1ReadWord((u8 *)&ofs->BGxHOFS, 0); - u16 YBG = gpu->currLine + T1ReadWord((u8 *)&ofs->BGxVOFS, 0); + u16 XBG = gpu->getHOFS(gpu->currBgNum); + u16 YBG = gpu->currLine + gpu->getVOFS(gpu->currBgNum); u16 lg = gpu->BGSize[num][0]; u16 ht = gpu->BGSize[num][1]; u16 wmask = (lg-1); @@ -1214,10 +1213,6 @@ static void lineNull(GPU * gpu) template void lineText(GPU * gpu) { - BGxOFS * ofs = &gpu->dispx_st->dispx_BGxOFS[gpu->currBgNum]; - - - if(gpu->debug) { const s32 wh = gpu->BGSize[gpu->currBgNum][0]; @@ -1225,8 +1220,8 @@ template void lineText(GPU * gpu) } else { - const u16 vofs = T1ReadWord((u8 *)&ofs->BGxVOFS,0); - const u16 hofs = T1ReadWord((u8 *)&ofs->BGxHOFS,0); + const u16 vofs = gpu->getVOFS(gpu->currBgNum); + const u16 hofs = gpu->getHOFS(gpu->currBgNum); renderline_textBG(gpu, hofs, gpu->currLine + vofs, 256); } } @@ -2115,8 +2110,7 @@ static void GPU_RenderLine_layer(NDS_Screen * screen, u16 l) { gpu->currBgNum = 0; - BGxOFS *bgofs = &gpu->dispx_st->dispx_BGxOFS[i16]; - u16 hofs = (T1ReadWord((u8*)&bgofs->BGxHOFS, 0) & 0x1FF); + const u16 hofs = gpu->getHOFS(i16); gfx3d_GetLineData(l, &gpu->_3dColorLine); u8* colorLine = gpu->_3dColorLine; diff --git a/desmume/src/GPU.h b/desmume/src/GPU.h index 98a87b819..018661464 100644 --- a/desmume/src/GPU.h +++ b/desmume/src/GPU.h @@ -844,6 +844,9 @@ struct GPU updateBLDALPHA(); } + u32 getHOFS(int bg) { return T1ReadWord(&dispx_st->dispx_BGxOFS[bg].BGxHOFS,0) & 0x1FF; } + u32 getVOFS(int bg) { return T1ReadWord(&dispx_st->dispx_BGxOFS[bg].BGxVOFS,0) & 0x1FF; } + typedef u8 TBlendTable[32][32]; TBlendTable *blendTable;