added missing PlusROM support for E7 bankswitching (fixes #965)

This commit is contained in:
thrust26 2023-04-09 15:18:24 +02:00
parent 1cc58b9d02
commit 76bd7f493f
4 changed files with 49 additions and 1 deletions

View File

@ -30,6 +30,8 @@
* Enhanced Kid Vid support to play tape audio.
* Added missing PlusROM support for E7 bankswitching.
* Acclerated emulation up to ~15% (ARM).
* Added BUS bankswitching support for some older demos.

View File

@ -41,6 +41,11 @@ void CartridgeE7::initialize(const ByteBuffer& image, size_t size)
myCurrentBank.fill(0);
myRAMBank = romBankCount() - 1; // NOLINT
myPlusROM = make_unique<PlusROM>(mySettings, *this);
// Determine whether we have a PlusROM cart
myPlusROM->initialize(myImage, mySize);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -57,6 +62,9 @@ void CartridgeE7::reset()
bank(startBank());
myBankChanged = true;
if (myPlusROM->isValid())
myPlusROM->reset();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -142,6 +150,15 @@ void CartridgeE7::checkSwitchBank(uInt16 address)
uInt8 CartridgeE7::peek(uInt16 address)
{
const uInt16 peekAddress = address;
// Is this a PlusROM?
if (myPlusROM->isValid())
{
uInt8 value = 0;
if (myPlusROM->peekHotspot(address, value))
return value;
}
address &= 0x0FFF;
// Switch banks if necessary
@ -164,6 +181,10 @@ uInt8 CartridgeE7::peek(uInt16 address)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeE7::poke(uInt16 address, uInt8 value)
{
// Is this a PlusROM?
if (myPlusROM->isValid() && myPlusROM->pokeHotspot(address, value))
return true;
const uInt16 pokeAddress = address;
address &= 0x0FFF;
@ -309,6 +330,8 @@ bool CartridgeE7::save(Serializer& out) const
out.putShortArray(myCurrentBank.data(), myCurrentBank.size());
out.putShort(myCurrentRAM);
out.putByteArray(myRAM.data(), myRAM.size());
if (myPlusROM->isValid() && !myPlusROM->save(out))
return false;
}
catch(...)
{
@ -327,6 +350,8 @@ bool CartridgeE7::load(Serializer& in)
in.getShortArray(myCurrentBank.data(), myCurrentBank.size());
myCurrentRAM = in.getShort();
in.getByteArray(myRAM.data(), myRAM.size());
if (myPlusROM->isValid() && !myPlusROM->load(in))
return false;
}
catch(...)
{

View File

@ -22,6 +22,7 @@
#include "System.hxx"
#include "bspf.hxx"
#include "Cart.hxx"
#include "PlusROM.hxx"
#ifdef DEBUGGER_SUPPORT
#include "CartE7Widget.hxx"
#endif
@ -177,6 +178,24 @@ class CartridgeE7 : public Cartridge
*/
string name() const override { return "CartridgeE7"; }
/**
Answer whether this is a PlusROM cart. Note that until the
initialize method has been called, this will always return false.
@return Whether this is actually a PlusROM cart
*/
bool isPlusROM() const override { return myPlusROM->isValid(); }
/**
Set the callback for displaying messages
*/
void setMessageCallback(const messageCallback& callback) override
{
Cartridge::setMessageCallback(callback);
if (myPlusROM->isValid())
myPlusROM->setMessageCallback(myMsgCallback);
}
#ifdef DEBUGGER_SUPPORT
/**
Get debugger widget responsible for accessing the inner workings
@ -244,6 +263,9 @@ class CartridgeE7 : public Cartridge
// The number of the RAM bank (== bankCount() - 1)
uInt32 myRAMBank{0};
// Handle PlusROM functionality, if available
unique_ptr<PlusROM> myPlusROM;
private:
// Following constructors and assignment operators not supported
CartridgeE7() = delete;

View File

@ -394,7 +394,6 @@ bool CartridgeEnhanced::save(Serializer& out) const
if(myPlusROM->isValid() && !myPlusROM->save(out))
return false;
}
catch(...)
{