diff options
| author | Peter Fors <peter.fors@mindkiller.com> | 2025-11-02 09:16:03 +0100 |
|---|---|---|
| committer | Peter Fors <peter.fors@mindkiller.com> | 2025-11-02 09:16:03 +0100 |
| commit | ed41715142f419021ed8fef5522ea1f363f16441 (patch) | |
| tree | 9cf0049db6ac5b0da5552bba9e0376b82eaeb2b4 /mknes_mapper.c | |
| parent | e137c881d835703d1030746cd7262899de7169c6 (diff) | |
fix multiple mappers
Diffstat (limited to 'mknes_mapper.c')
| -rw-r--r-- | mknes_mapper.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/mknes_mapper.c b/mknes_mapper.c index 4202769..a05707e 100644 --- a/mknes_mapper.c +++ b/mknes_mapper.c @@ -7,19 +7,16 @@ static uint8_t mapper_default_ciram_read(struct nes_state *state, uint32_t addr) { - if(state->ines.mirroring == MIRROR_HORIZONTAL) { // Horizontal: NT0↔NT1, NT2↔NT3 - addr = ((addr >> 1) & 0x400) | (addr & 0x3ff); - } else { // Vertical (default fallback): NT0↔NT2, NT1↔NT3 - addr = addr & 0x7ff; + if(state->ines.mirroring == MIRROR_HORIZONTAL) { + return state->ciram[((addr >> 1) & 0x400) | (addr & 0x3ff)]; } - - return state->ciram[addr]; + return state->ciram[addr & 0x7ff]; } static void mapper_default_ciram_write(struct nes_state *state, uint32_t addr, uint8_t value) { - if(state->ines.mirroring == MIRROR_HORIZONTAL) { // Horizontal: NT0↔NT1, NT2↔NT3 + if(state->ines.mirroring == MIRROR_HORIZONTAL) { // Horizontal: NT0+NT1, NT2+NT3 addr = ((addr >> 1) & 0x400) | (addr & 0x3ff); - } else { // Vertical (default fallback): NT0↔NT2, NT1↔NT3 + } else { // Vertical (default fallback): NT0+NT2, NT1+NT3 addr = addr & 0x7ff; } state->ciram[addr] = value; |
