From f24ca1f8a2393457e8f135534e9b1a8b2ade9a86 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Thu, 21 Feb 2019 12:42:27 -0600 Subject: [PATCH] APU: Seemingly obvious optimization. --- apu/bapu/smp/core.cpp | 25 ++++++++++++++++++++++--- apu/bapu/smp/smp.hpp | 3 +++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/apu/bapu/smp/core.cpp b/apu/bapu/smp/core.cpp index 3ad4e140..b1b68694 100644 --- a/apu/bapu/smp/core.cpp +++ b/apu/bapu/smp/core.cpp @@ -49,14 +49,33 @@ void SMP::op_write(uint16 addr, uint8 data) { apuram[addr] = data; //all writes go to RAM, even MMIO writes } +uint8 SMP::op_readpc() { + #if defined(CYCLE_ACCURATE) + tick(); + #endif + if (regs.pc >= 0xffc0 && status.iplrom_enable) return iplrom[regs.pc++ & 0x3f]; + return apuram[regs.pc++]; +} + +uint8 SMP::op_readstack() { + #if defined(CYCLE_ACCURATE) + tick(); + #endif + return apuram[0x0100 | ++regs.sp]; +} + +void SMP::op_writestack(uint8 data) { + #if defined(CYCLE_ACCURATE) + tick(); + #endif + apuram[0x0100 | regs.sp--] = data; +} + void SMP::op_step() { - #define op_readpc() op_read(regs.pc++) #define op_readdp(addr) op_read((regs.p.p << 8) + ((addr) & 0xff)) #define op_writedp(addr, data) op_write((regs.p.p << 8) + ((addr) & 0xff), data) #define op_readaddr(addr) op_read(addr) #define op_writeaddr(addr, data) op_write(addr, data) - #define op_readstack() op_read(0x0100 | ++regs.sp) - #define op_writestack(data) op_write(0x0100 | regs.sp--, data) #if defined(CYCLE_ACCURATE) #if defined(PSEUDO_CYCLE) diff --git a/apu/bapu/smp/smp.hpp b/apu/bapu/smp/smp.hpp index e8c77a9a..9a42aef8 100644 --- a/apu/bapu/smp/smp.hpp +++ b/apu/bapu/smp/smp.hpp @@ -102,6 +102,9 @@ public: debugvirtual alwaysinline uint8 op_read(uint16 addr); debugvirtual alwaysinline void op_write(uint16 addr, uint8 data); debugvirtual alwaysinline void op_step(); + alwaysinline uint8 op_readpc(); + alwaysinline uint8 op_readstack(); + alwaysinline void op_writestack(uint8 data); static const unsigned cycle_count_table[256]; uint64 cycle_table_cpu[256]; unsigned cycle_table_dsp[256];