From f0ddb8caa8a26d9845b313f9132bc4bb2adb7af3 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Thu, 12 Sep 2019 11:08:26 +0200 Subject: [PATCH] partial fix for issue #537 (RAM writes to read port) --- src/emucore/Cart3E.cxx | 17 +++++++++++++++-- src/emucore/Cart4KSC.cxx | 15 +++++++++++++-- src/emucore/CartBFSC.cxx | 15 +++++++++++++-- src/emucore/CartEFSC.cxx | 15 +++++++++++++-- src/emucore/CartF4SC.cxx | 15 +++++++++++++-- src/emucore/CartF6SC.cxx | 15 +++++++++++++-- src/emucore/CartF8SC.cxx | 15 +++++++++++++-- 7 files changed, 93 insertions(+), 14 deletions(-) diff --git a/src/emucore/Cart3E.cxx b/src/emucore/Cart3E.cxx index e8e1c77cd..67f9572c5 100644 --- a/src/emucore/Cart3E.cxx +++ b/src/emucore/Cart3E.cxx @@ -113,9 +113,22 @@ bool Cartridge3E::poke(uInt16 address, uInt8 value) return mySystem->tia().poke(address, value); } else - pokeRAM(myRAM[(address & 0x03FF) + ((myCurrentBank - 256) << 10)], pokeAddress, value); + { + if(address & 0x0400) + { + pokeRAM(myRAM[(address & 0x03FF) + ((myCurrentBank - 256) << 10)], pokeAddress, value); + return true; + } + else + { + // Writing to the read port should be ignored, but (TODO) trigger a break if option enabled + uInt8 dummy; - return true; + pokeRAM(dummy, pokeAddress, value); + return false; + + } + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Cart4KSC.cxx b/src/emucore/Cart4KSC.cxx index 330c7dcdb..bf7c2c1bd 100644 --- a/src/emucore/Cart4KSC.cxx +++ b/src/emucore/Cart4KSC.cxx @@ -83,8 +83,19 @@ uInt8 Cartridge4KSC::peek(uInt16 address) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Cartridge4KSC::poke(uInt16 address, uInt8 value) { - pokeRAM(myRAM[address & 0x007F], address, value); - return true; + if(address & 0x080) + { + pokeRAM(myRAM[address & 0x007F], address, value); + return true; + } + else + { + // Writing to the read port should be ignored, but (TODO) trigger a break if option enabled + uInt8 dummy; + + pokeRAM(dummy, address, value); + return false; + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartBFSC.cxx b/src/emucore/CartBFSC.cxx index d7edea29b..d41c290ce 100644 --- a/src/emucore/CartBFSC.cxx +++ b/src/emucore/CartBFSC.cxx @@ -98,8 +98,19 @@ bool CartridgeBFSC::poke(uInt16 address, uInt8 value) return false; } - pokeRAM(myRAM[address & 0x007F], pokeAddress, value); - return true; + if(address & 0x080) + { + pokeRAM(myRAM[address & 0x007F], pokeAddress, value); + return true; + } + else + { + // Writing to the read port should be ignored, but (TODO) trigger a break if option enabled + uInt8 dummy; + + pokeRAM(dummy, pokeAddress, value); + return false; + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartEFSC.cxx b/src/emucore/CartEFSC.cxx index 86c10a4af..0a5069489 100644 --- a/src/emucore/CartEFSC.cxx +++ b/src/emucore/CartEFSC.cxx @@ -98,8 +98,19 @@ bool CartridgeEFSC::poke(uInt16 address, uInt8 value) return false; } - pokeRAM(myRAM[address & 0x007F], pokeAddress, value); - return true; + if(address & 0x080) + { + pokeRAM(myRAM[address & 0x007F], pokeAddress, value); + return true; + } + else + { + // Writing to the read port should be ignored, but (TODO) trigger a break if option enabled + uInt8 dummy; + + pokeRAM(dummy, pokeAddress, value); + return false; + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartF4SC.cxx b/src/emucore/CartF4SC.cxx index 148d61d7d..9d468d28c 100644 --- a/src/emucore/CartF4SC.cxx +++ b/src/emucore/CartF4SC.cxx @@ -98,8 +98,19 @@ bool CartridgeF4SC::poke(uInt16 address, uInt8 value) return false; } - pokeRAM(myRAM[address & 0x007F], pokeAddress, value); - return true; + if(address & 0x080) + { + pokeRAM(myRAM[address & 0x007F], pokeAddress, value); + return true; + } + else + { + // Writing to the read port should be ignored, but (TODO) trigger a break if option enabled + uInt8 dummy; + + pokeRAM(dummy, pokeAddress, value); + return false; + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartF6SC.cxx b/src/emucore/CartF6SC.cxx index 3ad8ad790..b9f47ae89 100644 --- a/src/emucore/CartF6SC.cxx +++ b/src/emucore/CartF6SC.cxx @@ -138,8 +138,19 @@ bool CartridgeF6SC::poke(uInt16 address, uInt8 value) break; } - pokeRAM(myRAM[address & 0x007F], address, value); - return true; + if(address & 0x080) + { + pokeRAM(myRAM[address & 0x007F], address, value); + return true; + } + else + { + // Writing to the read port should be ignored, but (TODO) trigger a break if option enabled + uInt8 dummy; + + pokeRAM(dummy, address, value); + return false; + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartF8SC.cxx b/src/emucore/CartF8SC.cxx index 41da41178..5c4c8a523 100644 --- a/src/emucore/CartF8SC.cxx +++ b/src/emucore/CartF8SC.cxx @@ -118,8 +118,19 @@ bool CartridgeF8SC::poke(uInt16 address, uInt8 value) break; } - pokeRAM(myRAM[address & 0x007F], address, value); - return true; + if(address & 0x080) + { + pokeRAM(myRAM[address & 0x007F], address, value); + return true; + } + else + { + // Writing to the read port should be ignored, but (TODO) trigger a break if option enabled + uInt8 dummy; + + pokeRAM(dummy, address, value); + return false; + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -