Browse Source

Fix backdrop override quirk

master
Nathaniel Walizer 10 months ago
parent
commit
7b981c89d4
2 changed files with 8 additions and 1 deletions
  1. +7
    -0
      src/ppu.c
  2. +1
    -1
      src/sdl_render.c

+ 7
- 0
src/ppu.c View File

@@ -89,6 +89,10 @@ static inline void nes_ppu_internal_copy_y(nes_ppu* ppu) {
((ppu->t & 0x7000U) >> 12); ((ppu->t & 0x7000U) >> 12);
} }


static inline void nes_ppu_internal_copy_v(nes_ppu* ppu) {
ppu->addr = ppu->t;
}

void nes_ppu_write(nes_ppu* ppu, uint16_t addr, uint8_t val) { void nes_ppu_write(nes_ppu* ppu, uint16_t addr, uint8_t val) {
PPU_LOG("PPU: W-> $%04x %02x\n", addr, val); PPU_LOG("PPU: W-> $%04x %02x\n", addr, val);


@@ -236,6 +240,9 @@ nes_ppu_Result nes_ppu_run(nes_ppu* ppu, int cycles) {
if (ppu->scanline == 0) { if (ppu->scanline == 0) {
nes_ppu_internal_copy_y(ppu); nes_ppu_internal_copy_y(ppu);
} }
if (ppu->mask & (ppu_Mask_Sprite | ppu_Mask_Back)) {
nes_ppu_internal_copy_v(ppu);
}
} }


if ( NULL != ppu->mapper->scanline && if ( NULL != ppu->mapper->scanline &&


+ 1
- 1
src/sdl_render.c View File

@@ -560,7 +560,7 @@ static void render_scanline(nes_ppu* ppu, int line,


if (line >= 0) { if (line >= 0) {
// Emulate the happy part of the backdrop override quirk // Emulate the happy part of the backdrop override quirk
int pal_idx = (ppu->addr >= nes_ppu_mem_pal_start) ?
int pal_idx = ((ppu->addr & 0x3FFFU) >= nes_ppu_mem_pal_start) ?
(ppu->addr & (nes_ppu_mem_pal_size - 1)) : 0; (ppu->addr & (nes_ppu_mem_pal_size - 1)) : 0;
SDL_Color ext = nes_palette[ppu->palette[pal_idx]]; SDL_Color ext = nes_palette[ppu->palette[pal_idx]];
SDL_FillRect(data->target, &dst_rect, ((int)ext.r << 16) | SDL_FillRect(data->target, &dst_rect, ((int)ext.r << 16) |


Loading…
Cancel
Save