diff --git a/Emulator/Media/Cartridges/CustomCartridges/Reu.cpp b/Emulator/Media/Cartridges/CustomCartridges/Reu.cpp index cec897b7c..302b00ffa 100644 --- a/Emulator/Media/Cartridges/CustomCartridges/Reu.cpp +++ b/Emulator/Media/Cartridges/CustomCartridges/Reu.cpp @@ -303,6 +303,18 @@ Reu::poke(u16 addr, u8 value) } } +u8 +Reu::readFromC64Ram(u16 addr) +{ + return addr <= 2 ? mem.peek(addr, M_RAM) : mem.peek(addr); +} + +void +Reu::writeToC64Ram(u16 addr, u8 value) +{ + addr <= 2 ? mem.poke(addr, value, M_RAM) : mem.poke(addr, value); +} + u8 Reu::readFromReuRam(u32 addr) { @@ -328,7 +340,7 @@ Reu::writeToReuRam(u32 addr, u8 value) } } -void +void Reu::prepareDma() { if (REU_DEBUG) { dump(Category::Dma, std::cout); } @@ -353,7 +365,7 @@ Reu::doDma(EventID id) case EXP_REU_STASH: - c64Val = mem.peek(c64Addr); + c64Val = readFromC64Ram(c64Addr); writeToReuRam(reuAddr, c64Val); // debug(REU_DEBUG,"(%x, %02x) -> %x\n", memAddr, c64Val, reuAddr); @@ -365,7 +377,7 @@ Reu::doDma(EventID id) case EXP_REU_FETCH: reuVal = readFromReuRam(reuAddr); - mem.poke(c64Addr, reuVal); + writeToC64Ram(c64Addr, reuVal); // debug(REU_DEBUG,"%x <- (%x, %02x)\n", memAddr, reuAddr, reuVal); @@ -375,10 +387,10 @@ Reu::doDma(EventID id) case EXP_REU_SWAP: - c64Val = mem.peek(c64Addr); + c64Val = readFromC64Ram(c64Addr); reuVal = readFromReuRam(reuAddr); - mem.poke(c64Addr, reuVal); + writeToC64Ram(c64Addr, reuVal); writeToReuRam(reuAddr, c64Val); if (memStep()) incMemAddr(c64Addr); @@ -387,7 +399,7 @@ Reu::doDma(EventID id) case EXP_REU_VERIFY: - c64Val = mem.peek(c64Addr); + c64Val = readFromC64Ram(c64Addr); reuVal = readFromReuRam(reuAddr); if (c64Val != reuVal) { diff --git a/Emulator/Media/Cartridges/CustomCartridges/Reu.h b/Emulator/Media/Cartridges/CustomCartridges/Reu.h index 2700cfc84..d87b13778 100644 --- a/Emulator/Media/Cartridges/CustomCartridges/Reu.h +++ b/Emulator/Media/Cartridges/CustomCartridges/Reu.h @@ -193,7 +193,7 @@ class Reu final : public Cartridge { // - // Accessing cartridge memory + // Accessing memory // public: @@ -206,6 +206,9 @@ class Reu final : public Cartridge { private: + u8 readFromC64Ram(u16 addr); + void writeToC64Ram(u16 addr, u8 value); + u8 readFromReuRam(u32 addr); void writeToReuRam(u32 addr, u8 value);