Skip to content

Commit

Permalink
[core] ppu: Handle odd tile numbers in 256-color OBJs correctly (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fleroviux committed May 27, 2020
1 parent 65c857a commit 6e91162
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions source/emulator/core/hw/ppu/render/oam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 6e91162

Please sign in to comment.