summaryrefslogtreecommitdiff
path: root/mknes_memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'mknes_memory.c')
-rw-r--r--mknes_memory.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/mknes_memory.c b/mknes_memory.c
index 49546b2..57f527e 100644
--- a/mknes_memory.c
+++ b/mknes_memory.c
@@ -1,11 +1,12 @@
__attribute__((hot))
static inline uint8_t memory_read(struct nes_state *state, uint32_t offset) {
+ if(offset >= 0x10000) __builtin_unreachable();
+
state->cpu.cycles++;
apu_tick(state);
ppu_tick(state);
- if(offset >= 0x10000) __builtin_unreachable();
if(offset <= 0x1fff) {
return state->ram[offset & 0x07ff];
@@ -51,13 +52,14 @@ static inline uint8_t memory_read_dummy(struct nes_state *state, uint32_t offset
return result;
}
-__attribute__((hot, optimize("no-jump-tables")))
+__attribute__((hot))
static inline void memory_write(struct nes_state *state, uint32_t offset, uint8_t value) {
+ if(offset >= 0x10000) __builtin_unreachable();
+
state->cpu.cycles++;
apu_tick(state);
ppu_tick(state);
- if(offset >= 0x10000) __builtin_unreachable();
if(offset <= 0x1fff) {
state->ram[offset & 0x07ff] = value;
@@ -109,9 +111,3 @@ static inline void memory_write(struct nes_state *state, uint32_t offset, uint8_
return;
}
}
-
-__attribute__((hot, flatten))
-static inline uint8_t memory_read_dma(struct nes_state *state, uint32_t offset) {
- // NOTE(peter): DO NOT tick CPU/PPU/APU — caller handles timing
- return state->ram[offset & 0x07ff];
-}