summaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
authorPeter Fors <peter.fors@mindkiller.com>2025-05-24 15:45:54 +0200
committerPeter Fors <peter.fors@mindkiller.com>2025-05-24 15:45:54 +0200
commita8e0c141b0184d629504b9f0ee8dbc4fefb90934 (patch)
treecff0f7e64ce58dc8f1e4ff4501743d9b94449c94 /memory.c
parente28ad1546509de31b706f0fd300a906e5bc55199 (diff)
3011fps
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c32
1 files changed, 4 insertions, 28 deletions
diff --git a/memory.c b/memory.c
index 6e0c6df..90ae8b6 100644
--- a/memory.c
+++ b/memory.c
@@ -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);