mirror of https://github.com/stella-emu/stella.git
fixed odd ROM sizes for 3E+ (fixed #960
This commit is contained in:
parent
93ea39d615
commit
45157e8eb2
|
@ -24,7 +24,7 @@ Cartridge3EPlus::Cartridge3EPlus(const ByteBuffer& image, size_t size,
|
||||||
string_view md5, const Settings& settings,
|
string_view md5, const Settings& settings,
|
||||||
size_t bsSize)
|
size_t bsSize)
|
||||||
: Cartridge3E(image, size, md5, settings,
|
: Cartridge3E(image, size, md5, settings,
|
||||||
bsSize == 0 ? BSPF::nextMultipleOf(size, 1_KB) : bsSize)
|
bsSize == 0 ? std::max(4_KB, BSPF::nextMultipleOf(size, 1_KB)) : bsSize)
|
||||||
{
|
{
|
||||||
myBankShift = BANK_SHIFT;
|
myBankShift = BANK_SHIFT;
|
||||||
myRamSize = RAM_SIZE;
|
myRamSize = RAM_SIZE;
|
||||||
|
|
|
@ -133,6 +133,12 @@ class Cartridge3EPlus: public Cartridge3E
|
||||||
|
|
||||||
bool checkSwitchBank(uInt16 address, uInt8 value) override;
|
bool checkSwitchBank(uInt16 address, uInt8 value) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the number of segments supported by the cartridge.
|
||||||
|
*/
|
||||||
|
uInt16 calcNumSegments() const override { return 4; }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// log(ROM bank segment size) / log(2)
|
// log(ROM bank segment size) / log(2)
|
||||||
static constexpr uInt16 BANK_SHIFT = 10; // = 1K = 0x0400
|
static constexpr uInt16 BANK_SHIFT = 10; // = 1K = 0x0400
|
||||||
|
|
|
@ -213,7 +213,7 @@ class CartridgeE7 : public Cartridge
|
||||||
private:
|
private:
|
||||||
// Size of RAM in the cart
|
// Size of RAM in the cart
|
||||||
static constexpr uInt32 RAM_SIZE = 0x800; // 1K + 4 * 256B = 2K
|
static constexpr uInt32 RAM_SIZE = 0x800; // 1K + 4 * 256B = 2K
|
||||||
// Number of segment within the 4K address space
|
// Number of segments within the 4K address space
|
||||||
static constexpr uInt32 NUM_SEGMENTS = 2;
|
static constexpr uInt32 NUM_SEGMENTS = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -37,11 +37,11 @@ CartridgeEnhanced::CartridgeEnhanced(const ByteBuffer& image, size_t size,
|
||||||
<< "), truncating " << (size - bsSize) << " bytes\n";
|
<< "), truncating " << (size - bsSize) << " bytes\n";
|
||||||
Logger::info(buf.str());
|
Logger::info(buf.str());
|
||||||
}
|
}
|
||||||
else if(size < mySize)
|
else if(size < bsSize)
|
||||||
{
|
{
|
||||||
ostringstream buf;
|
ostringstream buf;
|
||||||
buf << "ROM smaller than expected (" << mySize << " > " << size
|
buf << "ROM smaller than expected (" << bsSize << " > " << size
|
||||||
<< "), appending " << (mySize - size) << " bytes\n";
|
<< "), appending " << (bsSize - size) << " bytes\n";
|
||||||
Logger::info(buf.str());
|
Logger::info(buf.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,10 +72,7 @@ void CartridgeEnhanced::install(System& system)
|
||||||
// calculate bank switching and RAM sizes and masks
|
// calculate bank switching and RAM sizes and masks
|
||||||
myBankSize = 1 << myBankShift; // e.g. = 2 ^ 12 = 4K = 0x1000
|
myBankSize = 1 << myBankShift; // e.g. = 2 ^ 12 = 4K = 0x1000
|
||||||
myBankMask = myBankSize - 1; // e.g. = 0x0FFF
|
myBankMask = myBankSize - 1; // e.g. = 0x0FFF
|
||||||
// Either the bankswitching supports multiple segments
|
myBankSegs = calcNumSegments();
|
||||||
// or the ROM is < 4K (-> 1 segment)
|
|
||||||
myBankSegs = std::min(1 << (MAX_BANK_SHIFT - myBankShift),
|
|
||||||
static_cast<int>(mySize) / myBankSize); // e.g. = 1
|
|
||||||
// ROM has an offset if RAM inside a bank (e.g. for F8SC)
|
// ROM has an offset if RAM inside a bank (e.g. for F8SC)
|
||||||
myRomOffset = myRamBankCount > 0U ? 0U : static_cast<uInt16>(myRamSize * 2);
|
myRomOffset = myRamBankCount > 0U ? 0U : static_cast<uInt16>(myRamSize * 2);
|
||||||
myRamMask = ramSize - 1; // e.g. = 0xFFFF (doesn't matter for RAM size 0)
|
myRamMask = ramSize - 1; // e.g. = 0xFFFF (doesn't matter for RAM size 0)
|
||||||
|
@ -339,6 +336,16 @@ uInt16 CartridgeEnhanced::ramBankCount() const
|
||||||
return myRamBankCount;
|
return myRamBankCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
uInt16 CartridgeEnhanced::calcNumSegments() const
|
||||||
|
{
|
||||||
|
|
||||||
|
// Either the bankswitching supports multiple segments
|
||||||
|
// or the ROM is < 4K (-> 1 segment)
|
||||||
|
return std::min(1 << (MAX_BANK_SHIFT - myBankShift),
|
||||||
|
static_cast<int>(mySize) / myBankSize); // e.g. = 1
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool CartridgeEnhanced::isRamBank(uInt16 address) const
|
bool CartridgeEnhanced::isRamBank(uInt16 address) const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue