From a1342afe34a953833979f6d790f8e7a0d24a66a6 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Sun, 27 Jan 2019 13:13:08 -0330 Subject: [PATCH] Fixed bug in peek handling for 2K and 4K ROMs. This fixes cheatcode handling for those schemes. --- src/emucore/Cart2K.hxx | 7 +++++++ src/emucore/Cart4K.hxx | 7 +++++++ src/emucore/Device.hxx | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/emucore/Cart2K.hxx b/src/emucore/Cart2K.hxx index 13aed2608..ddca38048 100644 --- a/src/emucore/Cart2K.hxx +++ b/src/emucore/Cart2K.hxx @@ -118,6 +118,13 @@ class Cartridge2K : public Cartridge } #endif + /** + Get the byte at the specified address. + + @return The byte at the specified address + */ + uInt8 peek(uInt16 address) override { return myImage[address & myMask]; } + private: // Pointer to a dynamically allocated ROM image of the cartridge BytePtr myImage; diff --git a/src/emucore/Cart4K.hxx b/src/emucore/Cart4K.hxx index cc361feba..f8ad3c6fa 100644 --- a/src/emucore/Cart4K.hxx +++ b/src/emucore/Cart4K.hxx @@ -115,6 +115,13 @@ class Cartridge4K : public Cartridge } #endif + /** + Get the byte at the specified address. + + @return The byte at the specified address + */ + uInt8 peek(uInt16 address) override { return myImage[address & 0x0FFF]; } + private: // The 4K ROM image for the cartridge uInt8 myImage[4096]; diff --git a/src/emucore/Device.hxx b/src/emucore/Device.hxx index 73dd90f93..7ab55597e 100644 --- a/src/emucore/Device.hxx +++ b/src/emucore/Device.hxx @@ -85,7 +85,7 @@ class Device : public Serializable @return The byte at the specified address */ - virtual uInt8 peek(uInt16 address) { return 0; } + virtual uInt8 peek(uInt16 address) = 0; /** Change the byte at the specified address to the given value