From 3c006fd36154e48325c3cf862ed3287b265924c1 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Wed, 24 Jul 2019 02:46:30 +0200 Subject: [PATCH] GPU2D: fill gaps in BG modes * mode6 actually works on the sub GPU, albeit limited to 1/4 the full bitmap size due to having only 128K of VRAM * mode7 draws BG0, BG1 and sprites. no BG2/BG3. --- src/GPU2D.cpp | 38 ++++++++++++++++++++++++++++++-------- src/GPU2D.h | 1 + 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/GPU2D.cpp b/src/GPU2D.cpp index 9d7ab8f3..4bba2354 100644 --- a/src/GPU2D.cpp +++ b/src/GPU2D.cpp @@ -1316,12 +1316,6 @@ void GPU2D::DrawScanlineBGMode(u32 line) void GPU2D::DrawScanlineBGMode6(u32 line) { - if (Num) - { - printf("GPU2D: MODE6 ON SUB GPU???\n"); - return; - } - for (int i = 3; i >= 0; i--) { if ((BGCnt[2] & 0x3) == i) @@ -1335,7 +1329,7 @@ void GPU2D::DrawScanlineBGMode6(u32 line) { if (DispCnt & 0x0100) { - if (DispCnt & 0x8) + if ((!Num) && (DispCnt & 0x8)) DrawBG_3D(); } } @@ -1344,6 +1338,34 @@ void GPU2D::DrawScanlineBGMode6(u32 line) } } +void GPU2D::DrawScanlineBGMode7(u32 line) +{ + // mode 7 only has text-mode BG0 and BG1 + + for (int i = 3; i >= 0; i--) + { + if ((BGCnt[1] & 0x3) == i) + { + if (DispCnt & 0x0200) + { + DrawBG_Text(line, 1); + } + } + if ((BGCnt[0] & 0x3) == i) + { + if (DispCnt & 0x0100) + { + if ((!Num) && (DispCnt & 0x8)) + DrawBG_3D(); + else + DrawBG_Text(line, 0); + } + } + if ((DispCnt & 0x1000) && NumSprites) + InterleaveSprites(0x8000 | (i<<16)); + } +} + void GPU2D::DrawScanline_BGOBJ(u32 line) { // forced blank disables BG/OBJ compositing @@ -1376,7 +1398,6 @@ void GPU2D::DrawScanline_BGOBJ(u32 line) else memset(WindowMask, 0xFF, 256); - // TODO: what happens in mode 7? mode 6 on the sub engine? switch (DispCnt & 0x7) { case 0: DrawScanlineBGMode<0>(line); break; @@ -1386,6 +1407,7 @@ void GPU2D::DrawScanline_BGOBJ(u32 line) case 4: DrawScanlineBGMode<4>(line); break; case 5: DrawScanlineBGMode<5>(line); break; case 6: DrawScanlineBGMode6(line); break; + case 7: DrawScanlineBGMode7(line); break; } // color special effects diff --git a/src/GPU2D.h b/src/GPU2D.h index b9a24224..6ad97830 100644 --- a/src/GPU2D.h +++ b/src/GPU2D.h @@ -135,6 +135,7 @@ private: template void DrawScanlineBGMode(u32 line); void DrawScanlineBGMode6(u32 line); + void DrawScanlineBGMode7(u32 line); void DrawScanline_BGOBJ(u32 line); static void DrawPixel_Normal(u32* dst, u16 color, u32 flag);