diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index 337a2904a..565957761 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -380,7 +380,7 @@ string Cartridge::autodetectType(const uInt8* image, uInt32 size) else type = "F6"; } - else if(size == 24*1024) // 24K + else if(size == 24*1024 || size == 28*1024) // 24K & 28K { type = "FA2"; } diff --git a/src/emucore/CartFA2.cxx b/src/emucore/CartFA2.cxx index 3d65af495..d1a2938b9 100644 --- a/src/emucore/CartFA2.cxx +++ b/src/emucore/CartFA2.cxx @@ -25,22 +25,27 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeFA2::CartridgeFA2(const uInt8* image, uInt32 size, const Settings& settings) - : Cartridge(settings) + : Cartridge(settings), + mySize(size) { + // Allocate array for the ROM image + myImage = new uInt8[mySize]; + // Copy the ROM image into my buffer - memcpy(myImage, image, BSPF_min(24576u, size)); - createCodeAccessBase(24576); + memcpy(myImage, image, mySize); + createCodeAccessBase(mySize); // This cart contains 256 bytes extended RAM @ 0x1000 registerRamArea(0x1000, 256, 0x100, 0x00); // Remember startup bank - myStartBank = 5; + myStartBank = 0; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeFA2::~CartridgeFA2() { + delete[] myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -131,6 +136,12 @@ uInt8 CartridgeFA2::peek(uInt16 address) bank(5); break; + case 0x0FFB: + // Set the current bank to the seventh 4k bank + // This is only available on 28K ROMs + if(mySize == 28*1024) bank(6); + break; + default: break; } @@ -190,6 +201,12 @@ bool CartridgeFA2::poke(uInt16 address, uInt8) bank(5); break; + case 0x0FFB: + // Set the current bank to the seventh 4k bank + // This is only available on 28K ROMs + if(mySize == 28*1024) bank(6); + break; + default: break; } @@ -240,7 +257,7 @@ uInt16 CartridgeFA2::bank() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt16 CartridgeFA2::bankCount() const { - return 6; + return (mySize / 4096); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -264,7 +281,7 @@ bool CartridgeFA2::patch(uInt16 address, uInt8 value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const uInt8* CartridgeFA2::getImage(int& size) const { - size = 24576; + size = mySize; return myImage; } diff --git a/src/emucore/CartFA2.hxx b/src/emucore/CartFA2.hxx index 9c4bd8eae..1ffa5f5b3 100644 --- a/src/emucore/CartFA2.hxx +++ b/src/emucore/CartFA2.hxx @@ -29,7 +29,7 @@ class System; This is an extended version of the CBS RAM Plus bankswitching scheme supported by the Harmony cartridge. - There are six 4K banks and 256 bytes of RAM. + There are six (or seven) 4K banks and 256 bytes of RAM. @author Chris D. Walton @version $Id$ @@ -143,11 +143,14 @@ class CartridgeFA2 : public Cartridge // Indicates which bank is currently active uInt16 myCurrentBank; - // The 24K ROM image of the cartridge - uInt8 myImage[24576]; + // The 24K/28K ROM image of the cartridge + uInt8* myImage; // The 256 bytes of RAM on the cartridge uInt8 myRAM[256]; + + // Size of the ROM image + uInt32 mySize; }; #endif