all repos — mgba @ 11ccbca4ffd33e82e5595ce0f959d4d17a6d0cb9

mGBA Game Boy Advance Emulator

GBA Video: Add missing parts of 256-color mode 0 mosaic (fixes #1701)
Vicki Pfau vi@endrift.com
Mon, 25 May 2020 15:07:54 -0700
commit

11ccbca4ffd33e82e5595ce0f959d4d17a6d0cb9

parent

ff1033b80150e37e3772f2c08f5e1ac35e25745d

2 files changed, 51 insertions(+), 2 deletions(-)

jump to
M CHANGESCHANGES

@@ -24,6 +24,7 @@ - GBA Video: Latch scanline at end of Hblank (fixes mgba.io/i/1319)

- GBA Video: Fix Hblank timing - GBA Video: Fix mosaic objects drawing past the end (fixes mgba.io/i/1702) - GBA Video: Fix disabling OBJWIN in GL renderer (fixes mgba.io/i/1759) + - GBA Video: Add missing parts of 256-color mode 0 mosaic (fixes mgba.io/1701) Other fixes: - All: Improve export headers (fixes mgba.io/i/1738) - ARM Debugger: Clear low bit on breakpoint addresses (fixes mgba.io/i/1764)
M src/gba/renderers/software-mode0.csrc/gba/renderers/software-mode0.c

@@ -329,8 +329,56 @@ } \

} #define DRAW_BACKGROUND_MODE_0_MOSAIC_256(BLEND, OBJWIN) \ + x = inX & 7; \ + if (mosaicWait) { \ + int baseX = x - (mosaicH - mosaicWait); \ + if (baseX < 0) { \ + int disturbX = (16 + baseX) >> 3; \ + inX -= disturbX << 3; \ + localX = tileX * 8 + inX; \ + BACKGROUND_TEXT_SELECT_CHARACTER; \ + localY = inY & 0x7; \ + if (GBA_TEXT_MAP_VFLIP(mapData)) { \ + localY = 7 - localY; \ + } \ + baseX -= disturbX << 3; \ + inX += disturbX << 3; \ + } else { \ + localX = tileX * 8 + inX; \ + BACKGROUND_TEXT_SELECT_CHARACTER; \ + localY = inY & 0x7; \ + if (GBA_TEXT_MAP_VFLIP(mapData)) { \ + localY = 7 - localY; \ + } \ + } \ + charBase = (background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) + (localY << 3); \ + if (UNLIKELY(charBase >= 0x10000)) { \ + carryData = 0; \ + } else { \ + LOAD_32(tileData, charBase, vram); \ + if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ + if (x >= 4) { \ + LOAD_32(tileData, charBase + 4, vram); \ + tileData >>= (x - 4) * 8; \ + } else { \ + LOAD_32(tileData, charBase, vram); \ + tileData >>= x * 8; \ + } \ + } else { \ + if (x >= 4) { \ + LOAD_32(tileData, charBase, vram); \ + tileData >>= (7 - x) * 8; \ + } else { \ + LOAD_32(tileData, charBase + 4, vram); \ + tileData >>= (3 - x) * 8; \ + } \ + } \ + tileData &= 0xFF; \ + carryData = tileData; \ + } \ + } \ localX = tileX * 8 + inX; \ - for (; tileX < tileEnd; ++tileX) { \ + for (; length; ++tileX) { \ mapData = background->mapCache[(localX >> 3) & 0x3F]; \ localX += 8; \ localY = inY & 0x7; \

@@ -339,7 +387,7 @@ localY = 7 - localY; \

} \ charBase = (background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) + (localY << 3); \ tileData = carryData; \ - for (x = 0; x < 8; ++x) { \ + for (x = 0; x < 8 && length; ++x, --length) { \ if (!mosaicWait) { \ if (UNLIKELY(charBase >= 0x10000)) { \ carryData = 0; \