diff options
Diffstat (limited to 'memory.c')
| -rw-r--r-- | memory.c | 32 |
1 files changed, 4 insertions, 28 deletions
@@ -2,7 +2,7 @@ __attribute__((hot)) -static uint8_t memory_read(struct nes_state *restrict state, uint32_t offset) { +static inline uint8_t memory_read(struct nes_state *state, uint32_t offset) { state->cpu.cycles++; ppu_tick(state); // apu_tick(state); @@ -23,33 +23,11 @@ static uint8_t memory_read(struct nes_state *restrict state, uint32_t offset) { return value | 0x40; // Bit 6 open bus high, bit 7 low } -#if 0 - if(LIKELY(offset < 0x2000)) { // SECOND - return state->ram[offset & 0x07ff]; - - } else if(offset < 0x4000) { // THIRD - return ppu_read(state, offset); - - } else if(offset == 0x4016 || offset == 0x4017) { - uint32_t index = offset & 1; - uint8_t value = (state->ppu.input_latch[index] >> state->ppu.input_bit[index]) & 1; - state->ppu.input_bit[index]++; - return value | 0x40; // Bit 6 open bus high, bit 7 low - - // } else if(offset == 4015) { - // static uint32_t apuread = 0; - // // printf("%.5d apu\n", apuread++); - - } else if(LIKELY(offset >= 0x6000)) { // MOST - return state->mapper.prg_read(state, offset); - - } -#endif return 0; } __attribute__((hot)) -static void memory_write(struct nes_state *restrict state, uint32_t offset, uint8_t value) { +static inline void memory_write(struct nes_state *state, uint32_t offset, uint8_t value) { state->cpu.cycles++; ppu_tick(state); // apu_tick(state); @@ -93,8 +71,7 @@ static void memory_write(struct nes_state *restrict state, uint32_t offset, uint } } -__attribute__((hot)) -static uint8_t memory_read_dma(struct nes_state *restrict state, uint32_t offset) { +static inline uint8_t memory_read_dma(struct nes_state *state, uint32_t offset) { // Do not tick CPU/PPU/APU — caller handles timing if(LIKELY(offset < 0x2000)) { return state->ram[offset & 0x07ff]; @@ -106,8 +83,7 @@ static uint8_t memory_read_dma(struct nes_state *restrict state, uint32_t offset return 0; } -__attribute__((hot)) -static uint8_t memory_read_dummy(struct nes_state *restrict state, uint32_t offset) { +static inline uint8_t memory_read_dummy(struct nes_state *state, uint32_t offset) { state->cpu.cycles++; ppu_tick(state); // apu_tick(state); |
