diff options
Diffstat (limited to 'ppu.c')
| -rw-r--r-- | ppu.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -219,12 +219,14 @@ static void ppu_tick(struct nes_state *state) { uint32_t nt_addr = 0x2000 | (ppu->vram_addr & 0x0fff); ppu->bg_next_tile_id = state->mapper.ciram_read(state, nt_addr); } break; + case 3: { uint32_t attr_addr = 0x23c0 | (ppu->vram_addr & 0x0c00) | ((ppu->vram_addr >> 4) & 0x38) | ((ppu->vram_addr >> 2) & 0x07); uint8_t attr = state->mapper.ciram_read(state, attr_addr & 0x0fff); uint8_t shift = ((ppu->vram_addr >> 4) & 4) | (ppu->vram_addr & 2); ppu->bg_next_tile_attrib = (attr >> shift) & 3; } break; + case 5: { uint32_t base = (ppu->reg_ctrl & 0x10) ? 0x1000 : 0x0000; uint32_t tile = ppu->bg_next_tile_id; @@ -232,6 +234,7 @@ static void ppu_tick(struct nes_state *state) { uint32_t addr_lsb = (base + tile * 16 + fine_y) & 0x1fff; ppu->bg_next_tile_lsb = state->mapper.chr_read(state, addr_lsb); } break; + case 7: { uint32_t base = (ppu->reg_ctrl & 0x10) ? 0x1000 : 0x0000; uint32_t tile = ppu->bg_next_tile_id; @@ -239,6 +242,7 @@ static void ppu_tick(struct nes_state *state) { uint32_t addr_msb = (base + tile * 16 + fine_y + 8) & 0x1fff; ppu->bg_next_tile_msb = state->mapper.chr_read(state, addr_msb); } break; + case 0: { ppu->bg_shift_pattern_low = (ppu->bg_shift_pattern_low & 0xff00) | ppu->bg_next_tile_lsb; ppu->bg_shift_pattern_high = (ppu->bg_shift_pattern_high & 0xff00) | ppu->bg_next_tile_msb; @@ -339,12 +343,12 @@ static void ppu_tick(struct nes_state *state) { } break; case 0: { - ppu->bg_shift_pattern_low = (ppu->bg_shift_pattern_low & 0xff00) | ppu->bg_next_tile_lsb; - ppu->bg_shift_pattern_high = (ppu->bg_shift_pattern_high & 0xff00) | ppu->bg_next_tile_msb; + ppu->bg_shift_pattern_low = (ppu->bg_shift_pattern_low & 0xff00) | ppu->bg_next_tile_lsb; + ppu->bg_shift_pattern_high = (ppu->bg_shift_pattern_high & 0xff00) | ppu->bg_next_tile_msb; uint8_t a = ppu->bg_next_tile_attrib; - ppu->bg_shift_attrib_low = (ppu->bg_shift_attrib_low & 0xff00) | ((a & 1) ? 0xff : 0x00); - ppu->bg_shift_attrib_high = (ppu->bg_shift_attrib_high & 0xff00) | ((a & 2) ? 0xff : 0x00); + ppu->bg_shift_attrib_low = (ppu->bg_shift_attrib_low & 0xff00) | ((a & 1) ? 0xff : 0x00); + ppu->bg_shift_attrib_high = (ppu->bg_shift_attrib_high & 0xff00) | ((a & 2) ? 0xff : 0x00); if((ppu->vram_addr & 0x001f) == 31) { ppu->vram_addr &= ~0x001f; |
