From 8aeb65d4b764e30109f61ac84ad4d92f6998cfca Mon Sep 17 00:00:00 2001 From: urchlay Date: Mon, 27 Jun 2005 23:40:36 +0000 Subject: [PATCH] patch() methods for various Cart classes. Still a work in progress, but we can now change ROM from the debugger on a good chunk of the games out there. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@571 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/emucore/Cart2K.cxx | 9 ++++++++- stella/src/emucore/Cart2K.hxx | 6 ++++-- stella/src/emucore/Cart3F.cxx | 17 ++++++++++++++++- stella/src/emucore/Cart3F.hxx | 6 ++++-- stella/src/emucore/CartAR.cxx | 9 ++++++++- stella/src/emucore/CartAR.hxx | 6 ++++-- stella/src/emucore/CartCV.cxx | 9 ++++++++- stella/src/emucore/CartCV.hxx | 6 ++++-- stella/src/emucore/CartF6.cxx | 10 +++++++++- stella/src/emucore/CartF6.hxx | 6 ++++-- stella/src/emucore/CartF8.cxx | 9 ++++++++- stella/src/emucore/CartF8.hxx | 6 ++++-- 12 files changed, 81 insertions(+), 18 deletions(-) diff --git a/stella/src/emucore/Cart2K.cxx b/stella/src/emucore/Cart2K.cxx index bf98ec1d4..ce9463810 100644 --- a/stella/src/emucore/Cart2K.cxx +++ b/stella/src/emucore/Cart2K.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Cart2K.cxx,v 1.4 2005-06-16 00:55:57 stephena Exp $ +// $Id: Cart2K.cxx,v 1.5 2005-06-27 23:40:35 urchlay Exp $ //============================================================================ #include @@ -83,6 +83,13 @@ void Cartridge2K::poke(uInt16, uInt8) // This is ROM so poking has no effect :-) } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge2K::patch(uInt16 address, uInt8 value) +{ + myImage[address & 0x07FF] = value; + return true; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Cartridge2K::save(Serializer& out) { diff --git a/stella/src/emucore/Cart2K.hxx b/stella/src/emucore/Cart2K.hxx index 8d7c0244a..67b9ec250 100644 --- a/stella/src/emucore/Cart2K.hxx +++ b/stella/src/emucore/Cart2K.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Cart2K.hxx,v 1.4 2005-06-16 00:55:57 stephena Exp $ +// $Id: Cart2K.hxx,v 1.5 2005-06-27 23:40:35 urchlay Exp $ //============================================================================ #ifndef CARTRIDGE2K_HXX @@ -33,7 +33,7 @@ class Deserializer; 2600's 4K cartridge addressing space. @author Bradford W. Mott - @version $Id: Cart2K.hxx,v 1.4 2005-06-16 00:55:57 stephena Exp $ + @version $Id: Cart2K.hxx,v 1.5 2005-06-27 23:40:35 urchlay Exp $ */ class Cartridge2K : public Cartridge { @@ -103,6 +103,8 @@ class Cartridge2K : public Cartridge */ virtual void poke(uInt16 address, uInt8 value); + bool patch(uInt16 address, uInt8 value); + private: // The 2k ROM image for the cartridge uInt8 myImage[2048]; diff --git a/stella/src/emucore/Cart3F.cxx b/stella/src/emucore/Cart3F.cxx index 308c22bca..1f6338980 100644 --- a/stella/src/emucore/Cart3F.cxx +++ b/stella/src/emucore/Cart3F.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Cart3F.cxx,v 1.6 2005-06-27 12:43:48 urchlay Exp $ +// $Id: Cart3F.cxx,v 1.7 2005-06-27 23:40:35 urchlay Exp $ //============================================================================ #include @@ -118,6 +118,21 @@ void Cartridge3F::poke(uInt16 address, uInt8 value) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge3F::patch(uInt16 address, uInt8 value) +{ + address = address & 0x0FFF; + if(address < 0x0800) + { + myImage[(address & 0x07FF) + myCurrentBank * 2048] = value; + } + else + { + myImage[(address & 0x07FF) + mySize - 2048] = value; + } + return true; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Cartridge3F::bank(uInt16 bank) { diff --git a/stella/src/emucore/Cart3F.hxx b/stella/src/emucore/Cart3F.hxx index a09f86f96..9c8caff10 100644 --- a/stella/src/emucore/Cart3F.hxx +++ b/stella/src/emucore/Cart3F.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Cart3F.hxx,v 1.5 2005-06-27 12:43:48 urchlay Exp $ +// $Id: Cart3F.hxx,v 1.6 2005-06-27 23:40:35 urchlay Exp $ //============================================================================ #ifndef CARTRIDGE3F_HXX @@ -37,7 +37,7 @@ class Deserializer; only used 8K this bankswitching scheme supports up to 512K. @author Bradford W. Mott - @version $Id: Cart3F.hxx,v 1.5 2005-06-27 12:43:48 urchlay Exp $ + @version $Id: Cart3F.hxx,v 1.6 2005-06-27 23:40:35 urchlay Exp $ */ class Cartridge3F : public Cartridge { @@ -108,6 +108,8 @@ class Cartridge3F : public Cartridge */ virtual void poke(uInt16 address, uInt8 value); + bool patch(uInt16 address, uInt8 value); + /** Map the specified bank into the first segment diff --git a/stella/src/emucore/CartAR.cxx b/stella/src/emucore/CartAR.cxx index beaeeea45..f247e3f24 100644 --- a/stella/src/emucore/CartAR.cxx +++ b/stella/src/emucore/CartAR.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartAR.cxx,v 1.8 2005-06-27 12:43:48 urchlay Exp $ +// $Id: CartAR.cxx,v 1.9 2005-06-27 23:40:35 urchlay Exp $ //============================================================================ #include @@ -197,6 +197,13 @@ void CartridgeAR::poke(uInt16 addr, uInt8) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeAR::patch(uInt16 address, uInt8 value) +{ + // myImage[address & 0x0FFF] = value; + return false; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeAR::bankConfiguration(uInt8 configuration) { diff --git a/stella/src/emucore/CartAR.hxx b/stella/src/emucore/CartAR.hxx index 68a24acc7..1e9c5cce8 100644 --- a/stella/src/emucore/CartAR.hxx +++ b/stella/src/emucore/CartAR.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartAR.hxx,v 1.6 2005-06-27 12:43:49 urchlay Exp $ +// $Id: CartAR.hxx,v 1.7 2005-06-27 23:40:35 urchlay Exp $ //============================================================================ #ifndef CARTRIDGEAR_HXX @@ -37,7 +37,7 @@ class Deserializer; and one bank of ROM. All 6K of the RAM can be read and written. @author Bradford W. Mott - @version $Id: CartAR.hxx,v 1.6 2005-06-27 12:43:49 urchlay Exp $ + @version $Id: CartAR.hxx,v 1.7 2005-06-27 23:40:35 urchlay Exp $ */ class CartridgeAR : public Cartridge { @@ -115,6 +115,8 @@ class CartridgeAR : public Cartridge */ virtual void poke(uInt16 address, uInt8 value); + bool patch(uInt16 address, uInt8 value); + /** Install pages for the specified bank in the system diff --git a/stella/src/emucore/CartCV.cxx b/stella/src/emucore/CartCV.cxx index fd7775ac5..bfe82e742 100644 --- a/stella/src/emucore/CartCV.cxx +++ b/stella/src/emucore/CartCV.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartCV.cxx,v 1.6 2005-06-16 00:55:57 stephena Exp $ +// $Id: CartCV.cxx,v 1.7 2005-06-27 23:40:35 urchlay Exp $ //============================================================================ #include @@ -131,6 +131,13 @@ void CartridgeCV::poke(uInt16, uInt8) // This is ROM so poking has no effect :-) } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeCV::patch(uInt16 address, uInt8 value) +{ + myImage[address & 0x07FF] = value; + return true; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeCV::save(Serializer& out) { diff --git a/stella/src/emucore/CartCV.hxx b/stella/src/emucore/CartCV.hxx index 75c8ae930..30e0b875e 100644 --- a/stella/src/emucore/CartCV.hxx +++ b/stella/src/emucore/CartCV.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartCV.hxx,v 1.4 2005-06-16 00:55:57 stephena Exp $ +// $Id: CartCV.hxx,v 1.5 2005-06-27 23:40:36 urchlay Exp $ //============================================================================ #ifndef CARTRIDGECV_HXX @@ -35,7 +35,7 @@ class Deserializer; $F800-$FFFF ROM @author Eckhard Stolberg - @version $Id: CartCV.hxx,v 1.4 2005-06-16 00:55:57 stephena Exp $ + @version $Id: CartCV.hxx,v 1.5 2005-06-27 23:40:36 urchlay Exp $ */ class CartridgeCV : public Cartridge { @@ -105,6 +105,8 @@ class CartridgeCV : public Cartridge */ virtual void poke(uInt16 address, uInt8 value); + bool patch(uInt16 address, uInt8 value); + private: // The 2k ROM image for the cartridge uInt8 myImage[2048]; diff --git a/stella/src/emucore/CartF6.cxx b/stella/src/emucore/CartF6.cxx index 74a368804..6b544847f 100644 --- a/stella/src/emucore/CartF6.cxx +++ b/stella/src/emucore/CartF6.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartF6.cxx,v 1.5 2005-06-16 00:55:57 stephena Exp $ +// $Id: CartF6.cxx,v 1.6 2005-06-27 23:40:36 urchlay Exp $ //============================================================================ #include @@ -143,6 +143,14 @@ void CartridgeF6::poke(uInt16 address, uInt8) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeF6::patch(uInt16 address, uInt8 value) +{ + address = address & 0x0FFF; + myImage[myCurrentBank * 4096 + address] = value; + return true; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeF6::bank(uInt16 bank) { diff --git a/stella/src/emucore/CartF6.hxx b/stella/src/emucore/CartF6.hxx index 2d1db59f6..dd99ad85a 100644 --- a/stella/src/emucore/CartF6.hxx +++ b/stella/src/emucore/CartF6.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartF6.hxx,v 1.4 2005-06-16 00:55:57 stephena Exp $ +// $Id: CartF6.hxx,v 1.5 2005-06-27 23:40:36 urchlay Exp $ //============================================================================ #ifndef CARTRIDGEF6_HXX @@ -31,7 +31,7 @@ class Deserializer; are four 4K banks. @author Bradford W. Mott - @version $Id: CartF6.hxx,v 1.4 2005-06-16 00:55:57 stephena Exp $ + @version $Id: CartF6.hxx,v 1.5 2005-06-27 23:40:36 urchlay Exp $ */ class CartridgeF6 : public Cartridge { @@ -101,6 +101,8 @@ class CartridgeF6 : public Cartridge */ virtual void poke(uInt16 address, uInt8 value); + bool patch(uInt16 address, uInt8 value); + private: /** Install pages for the specified bank in the system diff --git a/stella/src/emucore/CartF8.cxx b/stella/src/emucore/CartF8.cxx index 2659bcd4c..d212978d6 100644 --- a/stella/src/emucore/CartF8.cxx +++ b/stella/src/emucore/CartF8.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartF8.cxx,v 1.5 2005-06-27 04:45:52 urchlay Exp $ +// $Id: CartF8.cxx,v 1.6 2005-06-27 23:40:36 urchlay Exp $ //============================================================================ #include @@ -123,6 +123,13 @@ void CartridgeF8::poke(uInt16 address, uInt8) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeF8::patch(uInt16 address, uInt8 value) +{ + myImage[myCurrentBank * 4096 + address] = value; + return true; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeF8::bank(uInt16 bank) { diff --git a/stella/src/emucore/CartF8.hxx b/stella/src/emucore/CartF8.hxx index c56228824..1ddcf83d8 100644 --- a/stella/src/emucore/CartF8.hxx +++ b/stella/src/emucore/CartF8.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartF8.hxx,v 1.4 2005-06-27 04:45:52 urchlay Exp $ +// $Id: CartF8.hxx,v 1.5 2005-06-27 23:40:36 urchlay Exp $ //============================================================================ #ifndef CARTRIDGEF8_HXX @@ -31,7 +31,7 @@ class Deserializer; are two 4K banks. @author Bradford W. Mott - @version $Id: CartF8.hxx,v 1.4 2005-06-27 04:45:52 urchlay Exp $ + @version $Id: CartF8.hxx,v 1.5 2005-06-27 23:40:36 urchlay Exp $ */ class CartridgeF8 : public Cartridge { @@ -101,6 +101,8 @@ class CartridgeF8 : public Cartridge */ virtual void poke(uInt16 address, uInt8 value); + bool patch(uInt16 address, uInt8 value); + /** Install pages for the specified bank in the system