From 6e9116257b32c43a7ae04a66b35b8cec0d71cfc0 Mon Sep 17 00:00:00 2001 From: Frederic Meyer Date: Wed, 27 May 2020 02:28:09 +0200 Subject: [PATCH] [core] ppu: Handle odd tile numbers in 256-color OBJs correctly (fixes #106). --- source/emulator/core/hw/ppu/render/oam.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/emulator/core/hw/ppu/render/oam.cpp b/source/emulator/core/hw/ppu/render/oam.cpp index 74503db29..a6da9672a 100644 --- a/source/emulator/core/hw/ppu/render/oam.cpp +++ b/source/emulator/core/hw/ppu/render/oam.cpp @@ -46,7 +46,6 @@ void PPU::RenderLayerOAM(bool bitmap_mode) { int tile_num; std::uint16_t pixel; - std::uint32_t tile_base = 0x10000; std::int32_t offset = 127 * 8; line_contains_alpha_obj = false; @@ -148,12 +147,18 @@ void PPU::RenderLayerOAM(bool bitmap_mode) { int flip_v = !affine && (attr1 & (1 << 13)); int is_256 = (attr0 >> 13) & 1; - if (is_256) number /= 2; + std::uint32_t tile_base = 0x10000; + + if (is_256) { + if ((number & 1) && mmio.dispcnt.oam_mapping_1d) { + tile_base = 0x10020; + } + number /= 2; + } int mosaic_x = 0; if (mosaic) { - /* TODO: optimize this operation. */ mosaic_x = (x - half_width) % mmio.mosaic.obj.size_x; local_y -= mmio.mosaic.obj._counter_y; }