mirror of https://github.com/stella-emu/stella.git
more E7 refactoring/cleanup
This commit is contained in:
parent
16bc644b00
commit
7fc1c54d4c
|
@ -39,16 +39,3 @@ void CartridgeE7::checkSwitchBank(uInt16 address)
|
|||
bankRAM(address & 0x0003);
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 CartridgeE7::bankCount() const
|
||||
{
|
||||
return BANK_COUNT;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 CartridgeE7::romSize() const
|
||||
{
|
||||
return bankCount() * BANK_SIZE;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,11 +46,6 @@ class CartridgeE7 : public CartridgeMNetwork
|
|||
virtual ~CartridgeE7() = default;
|
||||
|
||||
public:
|
||||
/**
|
||||
Query the number of banks supported by the cartridge.
|
||||
*/
|
||||
uInt16 bankCount() const override;
|
||||
|
||||
/**
|
||||
Get a descriptor for the device name (used in error checking).
|
||||
|
||||
|
@ -71,19 +66,11 @@ class CartridgeE7 : public CartridgeMNetwork
|
|||
#endif
|
||||
|
||||
private:
|
||||
/**
|
||||
Query the size of the BS type.
|
||||
*/
|
||||
uInt32 romSize() const override;
|
||||
|
||||
/**
|
||||
Check hotspots and switch bank if triggered.
|
||||
*/
|
||||
void checkSwitchBank(uInt16 address) override;
|
||||
|
||||
// Number of banks
|
||||
static constexpr uInt32 BANK_COUNT = 8;
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
CartridgeE7() = delete;
|
||||
|
|
|
@ -39,16 +39,3 @@ void CartridgeE78K::checkSwitchBank(uInt16 address)
|
|||
bankRAM(address & 0x0003);
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 CartridgeE78K::bankCount() const
|
||||
{
|
||||
return BANK_COUNT;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 CartridgeE78K::romSize() const
|
||||
{
|
||||
return bankCount() * BANK_SIZE;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,11 +44,6 @@ class CartridgeE78K : public CartridgeMNetwork
|
|||
virtual ~CartridgeE78K() = default;
|
||||
|
||||
public:
|
||||
/**
|
||||
Query the number of banks supported by the cartridge.
|
||||
*/
|
||||
uInt16 bankCount() const override;
|
||||
|
||||
/**
|
||||
Get a descriptor for the device name (used in error checking).
|
||||
|
||||
|
@ -69,19 +64,11 @@ class CartridgeE78K : public CartridgeMNetwork
|
|||
#endif
|
||||
|
||||
private:
|
||||
/**
|
||||
Query the size of the BS type.
|
||||
*/
|
||||
uInt32 romSize() const override;
|
||||
|
||||
/**
|
||||
Check hotspots and switch bank if triggered.
|
||||
*/
|
||||
void checkSwitchBank(uInt16 address) override;
|
||||
|
||||
// Number of banks
|
||||
static constexpr uInt32 BANK_COUNT = 4;
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
CartridgeE78K() = delete;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
CartridgeMNetwork::CartridgeMNetwork(const BytePtr& image, uInt32 size,
|
||||
const Settings& settings)
|
||||
: Cartridge(settings),
|
||||
mySize(size),
|
||||
myCurrentRAM(0)
|
||||
{
|
||||
}
|
||||
|
@ -29,8 +30,11 @@ CartridgeMNetwork::CartridgeMNetwork(const BytePtr& image, uInt32 size,
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeMNetwork::initialize(const BytePtr& image, uInt32 size)
|
||||
{
|
||||
// Allocate array for the ROM image
|
||||
myImage = make_unique<uInt8[]>(size);
|
||||
|
||||
// Copy the ROM image into my buffer
|
||||
memcpy(myImage, image.get(), std::min(romSize(), size));
|
||||
memcpy(myImage.get(), image.get(), std::min(romSize(), size));
|
||||
createCodeAccessBase(romSize() + RAM_SIZE);
|
||||
|
||||
// Remember startup bank
|
||||
|
@ -94,7 +98,7 @@ void CartridgeMNetwork::install(System& system)
|
|||
|
||||
// Setup the second segment to always point to the last ROM slice
|
||||
setAccess(0x1A00, 0x1FE0U & (~System::PAGE_MASK - 0x1A00),
|
||||
myRAMSlice * BANK_SIZE, myImage, myRAMSlice * BANK_SIZE, System::PA_READ, BANK_SIZE - 1);
|
||||
myRAMSlice * BANK_SIZE, myImage.get(), myRAMSlice * BANK_SIZE, System::PA_READ, BANK_SIZE - 1);
|
||||
myCurrentSlice[1] = myRAMSlice;
|
||||
|
||||
// Install some default banks for the RAM and first segment
|
||||
|
@ -187,7 +191,7 @@ bool CartridgeMNetwork::bank(uInt16 slice)
|
|||
uInt16 offset = slice << 11; // * BANK_SIZE (2048)
|
||||
|
||||
// Map ROM image into first segment
|
||||
setAccess(0x1000, BANK_SIZE, offset, myImage, offset, System::PA_READ);
|
||||
setAccess(0x1000, BANK_SIZE, offset, myImage.get(), offset, System::PA_READ);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -239,7 +243,7 @@ bool CartridgeMNetwork::patch(uInt16 address, uInt8 value)
|
|||
const uInt8* CartridgeMNetwork::getImage(uInt32& size) const
|
||||
{
|
||||
size = bankCount() * BANK_SIZE;
|
||||
return myImage;
|
||||
return myImage.get();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -283,3 +287,16 @@ bool CartridgeMNetwork::load(Serializer& in)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 CartridgeMNetwork::bankCount() const
|
||||
{
|
||||
return mySize >> 11;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 CartridgeMNetwork::romSize() const
|
||||
{
|
||||
return bankCount() * BANK_SIZE;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,6 +101,11 @@ class CartridgeMNetwork : public Cartridge
|
|||
*/
|
||||
uInt16 getBank() const override;
|
||||
|
||||
/**
|
||||
Query the number of banks supported by the cartridge.
|
||||
*/
|
||||
uInt16 bankCount() const override;
|
||||
|
||||
/**
|
||||
Patch the cartridge ROM.
|
||||
|
||||
|
@ -176,7 +181,7 @@ class CartridgeMNetwork : public Cartridge
|
|||
/**
|
||||
Query the size of the BS type.
|
||||
*/
|
||||
virtual uInt32 romSize() const = 0;
|
||||
uInt32 romSize() const;
|
||||
|
||||
/**
|
||||
Check hotspots and switch bank if triggered.
|
||||
|
@ -187,8 +192,13 @@ class CartridgeMNetwork : public Cartridge
|
|||
uInt16 codeOffset, System::PageAccessType type, uInt16 addrMask = 0);
|
||||
|
||||
private:
|
||||
// Pointer to a dynamically allocated ROM image of the cartridge
|
||||
BytePtr myImage;
|
||||
// The 16K ROM image of the cartridge (works for E78K too)
|
||||
uInt8 myImage[BANK_SIZE * 8];
|
||||
//uInt8 myImage[BANK_SIZE * 8];
|
||||
|
||||
// Size of the ROM image
|
||||
uInt32 mySize;
|
||||
|
||||
// The 2K of RAM
|
||||
uInt8 myRAM[RAM_SIZE];
|
||||
|
|
Loading…
Reference in New Issue