diff options
Diffstat (limited to 'cpu.c')
-rw-r--r-- | cpu.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -5,10 +5,11 @@ #include <stdlib.h> #include <string.h> +#include "apu.h" #include "cpu.h" #include "opcodes.h" -#include "rom.h" #include "ppu.h" +#include "rom.h" #define MAX(a, b) ((a > b) ? a : b) @@ -53,9 +54,10 @@ peek(uint16_t addr) return rom.prg_rom[addr - 0x8000]; else fprintf(stderr, "PRG ROG size is not 0x4000 nor 0x8000\n"), exit(1); - } else { + } else if ((addr >= 0x4000 && addr <= 0x4013) || addr == 0x4015 || addr == 0x4017) + return apu_read(addr); + else return memory[addr]; - } } static uint16_t @@ -68,6 +70,11 @@ peek16(uint16_t addr) static void memwrite(uint16_t addr, uint8_t byte) { + if (addr >= 0x4000 && addr <= 0x4017) { + apu_write(addr, byte); + return; + } + MEMORY_MIRROR(addr); memory[addr] = byte; |