diff options
| author | vin <git@vineetk.net> | 2024-08-31 22:24:33 -0400 |
|---|---|---|
| committer | vin <git@vineetk.net> | 2024-09-01 01:49:37 -0400 |
| commit | 279478f16f8ea4fcc3c8765ff964954368664106 (patch) | |
| tree | a3c3c1bb28d26f9040a3afec7f519c92fc7ac5a0 /cpu.c | |
| parent | c0679b404d3bd9c20133a1868113f200eae2cf9f (diff) | |
add preliminary apu register support
Diffstat (limited to 'cpu.c')
| -rw-r--r-- | cpu.c | 13 |
1 files changed, 10 insertions, 3 deletions
| @@ -5,10 +5,11 @@ | |||
| 5 | #include <stdlib.h> | 5 | #include <stdlib.h> |
| 6 | #include <string.h> | 6 | #include <string.h> |
| 7 | 7 | ||
| 8 | #include "apu.h" | ||
| 8 | #include "cpu.h" | 9 | #include "cpu.h" |
| 9 | #include "opcodes.h" | 10 | #include "opcodes.h" |
| 10 | #include "rom.h" | ||
| 11 | #include "ppu.h" | 11 | #include "ppu.h" |
| 12 | #include "rom.h" | ||
| 12 | 13 | ||
| 13 | #define MAX(a, b) ((a > b) ? a : b) | 14 | #define MAX(a, b) ((a > b) ? a : b) |
| 14 | 15 | ||
| @@ -53,9 +54,10 @@ peek(uint16_t addr) | |||
| 53 | return rom.prg_rom[addr - 0x8000]; | 54 | return rom.prg_rom[addr - 0x8000]; |
| 54 | else | 55 | else |
| 55 | fprintf(stderr, "PRG ROG size is not 0x4000 nor 0x8000\n"), exit(1); | 56 | fprintf(stderr, "PRG ROG size is not 0x4000 nor 0x8000\n"), exit(1); |
| 56 | } else { | 57 | } else if ((addr >= 0x4000 && addr <= 0x4013) || addr == 0x4015 || addr == 0x4017) |
| 58 | return apu_read(addr); | ||
| 59 | else | ||
| 57 | return memory[addr]; | 60 | return memory[addr]; |
| 58 | } | ||
| 59 | } | 61 | } |
| 60 | 62 | ||
| 61 | static uint16_t | 63 | static uint16_t |
| @@ -68,6 +70,11 @@ peek16(uint16_t addr) | |||
| 68 | static void | 70 | static void |
| 69 | memwrite(uint16_t addr, uint8_t byte) | 71 | memwrite(uint16_t addr, uint8_t byte) |
| 70 | { | 72 | { |
| 73 | if (addr >= 0x4000 && addr <= 0x4017) { | ||
| 74 | apu_write(addr, byte); | ||
| 75 | return; | ||
| 76 | } | ||
| 77 | |||
| 71 | MEMORY_MIRROR(addr); | 78 | MEMORY_MIRROR(addr); |
| 72 | 79 | ||
| 73 | memory[addr] = byte; | 80 | memory[addr] = byte; |
