mirror of https://github.com/stella-emu/stella.git
Some cleanup of CartAR class, in preparation for moving some code from System class.
This commit is contained in:
parent
72227788b1
commit
55e3874097
|
@ -15,11 +15,20 @@
|
|||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//============================================================================
|
||||
|
||||
#include <numeric>
|
||||
|
||||
#include "M6502.hxx"
|
||||
#include "System.hxx"
|
||||
#include "Settings.hxx"
|
||||
#include "CartAR.hxx"
|
||||
|
||||
namespace {
|
||||
// Compute the sum of the array of bytes
|
||||
uInt8 checksum(const uInt8* s, uInt16 length) {
|
||||
return static_cast<uInt8>(std::accumulate(s, s + length, 0));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CartridgeAR::CartridgeAR(const ByteBuffer& image, size_t size,
|
||||
string_view md5, const Settings& settings)
|
||||
|
@ -509,39 +518,3 @@ std::array<uInt8, 294> CartridgeAR::ourDummyROMCode = {
|
|||
0xa9, 0x9a, 0xa2, 0xff, 0xa0, 0x00, 0x9a, 0x4c,
|
||||
0xfa, 0x00, 0xcd, 0xf8, 0xff, 0x4c
|
||||
};
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const std::array<uInt8, 256> CartridgeAR::ourDefaultHeader = {
|
||||
0xac, 0xfa, 0x0f, 0x18, 0x62, 0x00, 0x24, 0x02,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c,
|
||||
0x01, 0x05, 0x09, 0x0d, 0x11, 0x15, 0x19, 0x1d,
|
||||
0x02, 0x06, 0x0a, 0x0e, 0x12, 0x16, 0x1a, 0x1e,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00
|
||||
};
|
||||
|
|
|
@ -173,7 +173,7 @@ class CartridgeAR : public Cartridge
|
|||
|
||||
@param address The address to query
|
||||
*/
|
||||
Device::AccessFlags getAccessFlags(uInt16 address) const override;
|
||||
Device::AccessFlags getAccessFlags(uInt16 address) const override;
|
||||
/**
|
||||
Change the given address to use the given access flags.
|
||||
|
||||
|
@ -186,15 +186,6 @@ class CartridgeAR : public Cartridge
|
|||
// Handle a change to the bank configuration
|
||||
bool bankConfiguration(uInt8 configuration);
|
||||
|
||||
// Compute the sum of the array of bytes
|
||||
static uInt8 checksum(const uInt8* s, uInt16 length) {
|
||||
uInt8 sum = 0;
|
||||
for(uInt32 i = 0; i < length; ++i)
|
||||
sum += s[i];
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
// Load the specified load into SC RAM
|
||||
void loadIntoRAM(uInt8 load);
|
||||
|
||||
|
@ -239,11 +230,45 @@ class CartridgeAR : public Cartridge
|
|||
uInt16 myCurrentBank{0};
|
||||
|
||||
// Fake SC-BIOS code to simulate the Supercharger load bars
|
||||
// This is not marked 'constexpr', since it's patched at runtime
|
||||
static std::array<uInt8, 294> ourDummyROMCode;
|
||||
|
||||
// Default 256-byte header to use if one isn't included in the ROM
|
||||
// This data comes from z26
|
||||
static const std::array<uInt8, 256> ourDefaultHeader;
|
||||
static constexpr std::array<uInt8, 256> ourDefaultHeader = {
|
||||
0xac, 0xfa, 0x0f, 0x18, 0x62, 0x00, 0x24, 0x02,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c,
|
||||
0x01, 0x05, 0x09, 0x0d, 0x11, 0x15, 0x19, 0x1d,
|
||||
0x02, 0x06, 0x0a, 0x0e, 0x12, 0x16, 0x1a, 0x1e,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00
|
||||
};
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
|
|
|
@ -83,7 +83,8 @@ void M6502::reset()
|
|||
// Load PC from the reset vector
|
||||
PC = static_cast<uInt16>(mySystem->peek(0xfffc)) | (static_cast<uInt16>(mySystem->peek(0xfffd)) << 8);
|
||||
|
||||
myLastAddress = myLastPeekAddress = myLastPokeAddress = myLastPeekBaseAddress = myLastPokeBaseAddress;
|
||||
myLastAddress = myLastPeekAddress = myLastPokeAddress =
|
||||
myLastPeekBaseAddress = myLastPokeBaseAddress = 0;
|
||||
myLastSrcAddressS = myLastSrcAddressA =
|
||||
myLastSrcAddressX = myLastSrcAddressY = -1;
|
||||
myDataAddressForPoke = 0;
|
||||
|
@ -489,7 +490,7 @@ bool M6502::save(Serializer& out) const
|
|||
|
||||
// Indicates the number of distinct memory accesses
|
||||
out.putInt(myNumberOfDistinctAccesses);
|
||||
// Indicates the last address(es) which was accessed
|
||||
// Indicates the last addresses which were accessed
|
||||
out.putShort(myLastAddress);
|
||||
out.putShort(myLastPeekAddress);
|
||||
out.putShort(myLastPokeAddress);
|
||||
|
@ -536,7 +537,7 @@ bool M6502::load(Serializer& in)
|
|||
|
||||
// Indicates the number of distinct memory accesses
|
||||
myNumberOfDistinctAccesses = in.getInt();
|
||||
// Indicates the last address(es) which was accessed
|
||||
// Indicates the last addresses which were accessed
|
||||
myLastAddress = in.getShort();
|
||||
myLastPeekAddress = in.getShort();
|
||||
myLastPokeAddress = in.getShort();
|
||||
|
|
Loading…
Reference in New Issue