2014-06-02 20:41:19 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
|
|
|
// SSSS tt ee ee ll ll aa
|
|
|
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
|
|
|
// SS SS tt ee ll ll aa aa
|
|
|
|
// SSSS ttt eeeee llll llll aaaaa
|
|
|
|
//
|
|
|
|
// Copyright (c) 1995-2014 by Bradford W. Mott, Stephen Anthony
|
|
|
|
// and the Stella Team
|
|
|
|
//
|
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
#include "System.hxx"
|
|
|
|
#include "TIA.hxx"
|
|
|
|
#include "CartDASH.hxx"
|
|
|
|
|
2014-06-03 13:53:49 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
CartridgeDASH::CartridgeDASH(const uInt8* image, uInt32 size, const Settings& settings) :
|
|
|
|
Cartridge(settings), mySize(size) {
|
2014-06-06 14:52:10 +00:00
|
|
|
|
2014-06-02 20:41:19 +00:00
|
|
|
// Allocate array for the ROM image
|
2014-07-26 20:32:33 +00:00
|
|
|
myImage = new uInt8[mySize];
|
2014-06-02 20:41:19 +00:00
|
|
|
|
|
|
|
// Copy the ROM image into my buffer
|
|
|
|
memcpy(myImage, image, mySize);
|
2014-07-26 20:32:33 +00:00
|
|
|
createCodeAccessBase(mySize + RAM_TOTAL_SIZE);
|
2014-06-02 20:41:19 +00:00
|
|
|
|
|
|
|
// Remember startup bank (0 per spec, rather than last per 3E scheme).
|
|
|
|
// Set this to go to 3rd 1K Bank.
|
2014-07-26 20:32:33 +00:00
|
|
|
myStartBank = 0;
|
2014-06-02 20:41:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2014-06-03 13:53:49 +00:00
|
|
|
CartridgeDASH::~CartridgeDASH() {
|
2014-06-02 20:41:19 +00:00
|
|
|
delete[] myImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2014-06-03 13:53:49 +00:00
|
|
|
void CartridgeDASH::reset() {
|
2014-06-06 14:52:10 +00:00
|
|
|
|
2014-06-02 20:41:19 +00:00
|
|
|
// Initialize RAM
|
|
|
|
if (mySettings.getBool("ramrandom"))
|
|
|
|
for (uInt32 i = 0; i < RAM_TOTAL_SIZE; ++i)
|
|
|
|
myRAM[i] = mySystem->randGenerator().next();
|
|
|
|
else
|
|
|
|
memset(myRAM, 0, RAM_TOTAL_SIZE);
|
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
// Initialise bank values for all ROM/RAM access
|
|
|
|
// This is used to reverse-lookup from address to bank location
|
|
|
|
for (uInt32 b = 0; b < 8; b++)
|
|
|
|
bankInUse[b] = BANK_UNDEFINED; // bank is undefined and inaccessible!
|
|
|
|
initializeBankState();
|
2014-06-02 20:41:19 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
// We'll map the startup banks 0 and 3 from the image into the third 1K bank upon reset
|
|
|
|
bankROM((0 << BANK_BITS) | 0);
|
|
|
|
bankROM((3 << BANK_BITS) | 0);
|
2014-06-02 20:41:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2014-06-03 13:53:49 +00:00
|
|
|
void CartridgeDASH::install(System& system) {
|
2014-06-04 14:29:33 +00:00
|
|
|
|
2014-06-02 20:41:19 +00:00
|
|
|
mySystem = &system;
|
|
|
|
|
|
|
|
uInt16 shift = mySystem->pageShift();
|
|
|
|
uInt16 mask = mySystem->pageMask();
|
|
|
|
|
|
|
|
// Make sure the system we're being installed in has a page size that'll work
|
|
|
|
assert((0x1800 & mask) == 0);
|
|
|
|
|
2014-07-24 16:24:27 +00:00
|
|
|
System::PageAccess access(this, System::PA_READWRITE);
|
2014-06-02 20:41:19 +00:00
|
|
|
|
|
|
|
// Set the page accessing methods for the hot spots (for 100% emulation
|
|
|
|
// we need to chain any accesses below 0x40 to the TIA. Our poke() method
|
|
|
|
// does this via mySystem->tiaPoke(...), at least until we come up with a
|
|
|
|
// cleaner way to do it).
|
|
|
|
for (uInt32 i = 0x00; i < 0x40; i += (1 << shift))
|
|
|
|
mySystem->setPageAccess(i >> shift, access);
|
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
// Initialise bank values for all ROM/RAM access
|
2014-06-02 20:41:19 +00:00
|
|
|
// This is used to reverse-lookup from address to bank location
|
2014-06-04 14:29:33 +00:00
|
|
|
for (uInt32 b = 0; b < 8; b++)
|
2014-06-02 20:41:19 +00:00
|
|
|
bankInUse[b] = BANK_UNDEFINED; // bank is undefined and inaccessible!
|
2014-07-26 20:32:33 +00:00
|
|
|
initializeBankState();
|
2014-06-02 20:41:19 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
// Setup the last segment (of 4, each 1K) to point to the first ROM slice
|
|
|
|
// Actually we DO NOT want "always". It's just on bootup, and can be out switched later
|
|
|
|
bankROM((0 << BANK_BITS) | 0);
|
|
|
|
bankROM((3 << BANK_BITS) | 0);
|
2014-06-02 20:41:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2014-06-03 13:53:49 +00:00
|
|
|
uInt8 CartridgeDASH::peek(uInt16 address) {
|
2014-06-04 14:29:33 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
uInt16 peekAddress = address;
|
2014-07-24 11:41:19 +00:00
|
|
|
address &= 0x0FFF; // restrict to 4K address range
|
|
|
|
|
2014-06-02 20:41:19 +00:00
|
|
|
uInt8 value = 0;
|
2014-07-26 20:32:33 +00:00
|
|
|
uInt32 bank = (address >> (ROM_BANK_TO_POWER - 1)) & 7; // convert to 512 byte bank index (0-7)
|
2014-06-04 14:29:33 +00:00
|
|
|
Int16 imageBank = bankInUse[bank]; // the ROM/RAM bank that's here
|
2014-06-02 20:41:19 +00:00
|
|
|
|
2014-06-03 13:53:49 +00:00
|
|
|
if (imageBank == BANK_UNDEFINED) { // an uninitialised bank?
|
|
|
|
|
2014-06-02 20:41:19 +00:00
|
|
|
// accessing invalid bank, so return should be... random?
|
|
|
|
value = mySystem->randGenerator().next();
|
2014-06-03 13:53:49 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
} else if (imageBank & BITMASK_ROMRAM) { // a RAM bank
|
2014-06-03 13:53:49 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
// Reading from the write port triggers an unwanted write
|
|
|
|
value = mySystem->getDataBusState(0xFF);
|
2014-06-03 13:53:49 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
if(bankLocked())
|
|
|
|
return value;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
triggerReadFromWritePort(peekAddress);
|
2014-06-04 14:29:33 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
Int32 ramBank = imageBank & BIT_BANK_MASK; // discard irrelevant bits
|
|
|
|
Int32 offset = ramBank << RAM_BANK_TO_POWER; // base bank address in RAM
|
|
|
|
offset += (address & BITMASK_RAM_BANK); // + byte offset in RAM bank
|
|
|
|
return myRAM[offset] = value;
|
|
|
|
}
|
2014-06-02 20:41:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2014-06-03 13:53:49 +00:00
|
|
|
bool CartridgeDASH::poke(uInt16 address, uInt8 value) {
|
2014-06-04 14:29:33 +00:00
|
|
|
|
|
|
|
bool myBankChanged = false;
|
|
|
|
|
2014-06-03 12:05:00 +00:00
|
|
|
// Check for write to the bank switch address. RAM/ROM and bank # are encoded in 'value'
|
|
|
|
// There are NO mirrored hotspots.
|
2014-06-02 20:41:19 +00:00
|
|
|
|
2014-06-04 14:29:33 +00:00
|
|
|
if (address == BANK_SWITCH_HOTSPOT_RAM)
|
|
|
|
myBankChanged = bankRAM(value);
|
|
|
|
|
|
|
|
else if (address == BANK_SWITCH_HOTSPOT_ROM)
|
|
|
|
myBankChanged = bankROM(value);
|
2014-06-02 20:41:19 +00:00
|
|
|
|
|
|
|
// Pass the poke through to the TIA. In a real Atari, both the cart and the
|
|
|
|
// TIA see the address lines, and both react accordingly. In Stella, each
|
|
|
|
// 64-byte chunk of address space is "owned" by only one device. If we
|
|
|
|
// don't chain the poke to the TIA, then the TIA can't see it...
|
|
|
|
mySystem->tia().poke(address, value);
|
|
|
|
|
2014-06-04 14:29:33 +00:00
|
|
|
return myBankChanged;
|
2014-06-02 20:41:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2014-06-04 14:29:33 +00:00
|
|
|
bool CartridgeDASH::bankRAM(uInt8 bank) {
|
2014-06-03 21:17:54 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
if (bankLocked()) // debugger can lock RAM
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Each RAM bank uses two slots, separated by 0x800 in memory -- one read, one write.
|
|
|
|
bankRAMSlot(bank | BITMASK_ROMRAM | 0);
|
|
|
|
bankRAMSlot(bank | BITMASK_ROMRAM | BITMASK_LOWERUPPER);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeDASH::bankRAMSlot(uInt16 bank) {
|
2014-06-02 20:41:19 +00:00
|
|
|
|
|
|
|
uInt16 shift = mySystem->pageShift();
|
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
uInt16 bankNumber = (bank >> BANK_BITS) & 3; // which bank # we are switching TO (BITS D6,D7) to 512 byte block
|
|
|
|
uInt16 currentBank = bank & BIT_BANK_MASK; // Wrap around/restrict to valid range
|
|
|
|
bool upper = bank & BITMASK_LOWERUPPER; // is this the read or write port
|
2014-06-02 20:41:19 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
uInt32 startCurrentBank = currentBank << RAM_BANK_TO_POWER; // Effectively * 512 bytes
|
|
|
|
uInt32 blockSize = 1 << shift;
|
2014-06-03 13:53:49 +00:00
|
|
|
|
2014-06-04 14:29:33 +00:00
|
|
|
// Setup the page access methods for the current bank
|
2014-07-24 16:24:27 +00:00
|
|
|
System::PageAccess access(this, System::PA_READ);
|
2014-06-02 20:41:19 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
if (upper) { // We're mapping the write port
|
2014-06-06 14:52:10 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
bankInUse[bankNumber + 4] = (Int16) bank;
|
|
|
|
access.type = System::PA_WRITE;
|
2014-06-02 20:41:19 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
} else { // We're mapping the read port
|
2014-06-04 14:29:33 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
bankInUse[bankNumber] = (Int16) bank;
|
|
|
|
access.type = System::PA_READ;
|
2014-06-06 14:52:10 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uInt32 start = 0x1000 + (bankNumber << RAM_BANK_TO_POWER) + (upper ? RAM_WRITE_OFFSET : 0);
|
|
|
|
uInt32 end = start + RAM_BANK_SIZE - 1;
|
2014-06-04 14:29:33 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
for (uInt32 address = start; address <= end; address += blockSize) {
|
|
|
|
if(upper)
|
|
|
|
access.directPokeBase = &myRAM[startCurrentBank + (address & (RAM_BANK_SIZE - 1))];
|
|
|
|
else
|
|
|
|
access.directPeekBase = &myRAM[startCurrentBank + (address & (RAM_BANK_SIZE - 1))];
|
|
|
|
access.codeAccessBase = &myCodeAccessBase[mySize + startCurrentBank + (address & (RAM_BANK_SIZE - 1))];
|
|
|
|
mySystem->setPageAccess(address >> shift, access);
|
|
|
|
}
|
2014-06-04 14:29:33 +00:00
|
|
|
}
|
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
|
2014-06-04 14:29:33 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
bool CartridgeDASH::bankROM(uInt8 bank) {
|
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
if (bankLocked()) // debugger can lock ROM
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Map ROM bank image into the system into the correct slot
|
|
|
|
// Memory map is 1K slots at 0x1000, 0x1400, 0x1800, 0x1C00
|
|
|
|
// Each ROM uses 2 consecutive 512 byte slots
|
|
|
|
bankROMSlot(bank | 0);
|
|
|
|
bankROMSlot(bank | BITMASK_LOWERUPPER);
|
2014-06-04 14:29:33 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
2014-06-04 14:29:33 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeDASH::bankROMSlot(uInt16 bank) {
|
2014-06-04 14:29:33 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
uInt16 shift = mySystem->pageShift();
|
2014-06-02 20:41:19 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
uInt16 bankNumber = (bank >> BANK_BITS) & 3; // which bank # we are switching TO (BITS D6,D7)
|
|
|
|
uInt16 currentBank = bank & BIT_BANK_MASK; // Wrap around/restrict to valid range
|
|
|
|
bool upper = bank & BITMASK_LOWERUPPER; // is this the lower or upper 512b
|
2014-06-04 14:29:33 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
bankInUse[bankNumber * 2 + (upper ? 1 : 0)] = (Int16) bank; // Record which bank switched in (as ROM)
|
2014-06-02 20:41:19 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
uInt32 startCurrentBank = currentBank << ROM_BANK_TO_POWER; // Effectively *1K
|
2014-06-02 20:41:19 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
// Setup the page access methods for the current bank
|
|
|
|
System::PageAccess access(this, System::PA_READ);
|
2014-06-02 20:41:19 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
uInt32 start = 0x1000 + (bankNumber << ROM_BANK_TO_POWER) + (upper ? ROM_BANK_SIZE / 2 : 0);
|
|
|
|
uInt32 end = start + ROM_BANK_SIZE / 2 - 1;
|
2014-06-04 14:29:33 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
for (uInt32 address = start; address <= end; address += (1 << shift)) {
|
|
|
|
access.directPeekBase = &myImage[startCurrentBank + (address & (ROM_BANK_SIZE - 1))];
|
|
|
|
access.codeAccessBase = &myCodeAccessBase[startCurrentBank + (address & (ROM_BANK_SIZE - 1))];
|
|
|
|
mySystem->setPageAccess(address >> shift, access);
|
2014-06-02 20:41:19 +00:00
|
|
|
}
|
2014-07-26 20:32:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeDASH::initializeBankState() {
|
|
|
|
|
|
|
|
const uInt16& shift = mySystem->pageShift();
|
|
|
|
|
|
|
|
// Switch in each 512b slot
|
|
|
|
for (uInt32 b = 0; b < 8; b++) {
|
|
|
|
if (bankInUse[b] == BANK_UNDEFINED) {
|
|
|
|
|
|
|
|
// Setup the page access methods for the current bank
|
|
|
|
System::PageAccess access(this, System::PA_READ);
|
|
|
|
uInt32 start = 0x1000 + (b << RAM_BANK_TO_POWER);
|
|
|
|
uInt32 end = start + RAM_BANK_SIZE - 1;
|
|
|
|
for (uInt32 address = start; address <= end; address += (1 << shift))
|
|
|
|
mySystem->setPageAccess(address >> shift, access);
|
2014-06-02 20:41:19 +00:00
|
|
|
|
2014-07-26 20:32:33 +00:00
|
|
|
}
|
|
|
|
else if (bankInUse[b] & BITMASK_ROMRAM)
|
|
|
|
bankRAMSlot(bankInUse[b]);
|
|
|
|
else
|
|
|
|
bankROMSlot(bankInUse[b]);
|
|
|
|
}
|
2014-06-04 14:29:33 +00:00
|
|
|
}
|
|
|
|
|
2014-06-02 20:41:19 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2014-06-03 13:53:49 +00:00
|
|
|
bool CartridgeDASH::patch(uInt16 address, uInt8 value) {
|
2014-07-26 20:32:33 +00:00
|
|
|
#if 0
|
2014-06-03 21:17:54 +00:00
|
|
|
// Patch the cartridge ROM (for debugger)
|
2014-06-02 20:41:19 +00:00
|
|
|
|
|
|
|
myBankChanged = true;
|
|
|
|
|
2014-06-04 14:29:33 +00:00
|
|
|
uInt32 bankNumber = (address >> RAM_BANK_TO_POWER) & 7; // now 512 byte bank # (ie: 0-7)
|
|
|
|
Int16 whichBankIsThere = bankInUse[bankNumber]; // ROM or RAM bank reference
|
2014-06-02 20:41:19 +00:00
|
|
|
|
2014-06-03 13:53:49 +00:00
|
|
|
if (whichBankIsThere == BANK_UNDEFINED) {
|
|
|
|
|
2014-06-03 21:17:54 +00:00
|
|
|
// We're trying to access undefined memory (no bank here yet). Fail!
|
2014-06-02 20:41:19 +00:00
|
|
|
myBankChanged = false;
|
2014-06-03 13:53:49 +00:00
|
|
|
|
|
|
|
} else if (whichBankIsThere & BITMASK_ROMRAM) { // patching RAM (512 byte banks)
|
|
|
|
|
|
|
|
uInt32 byteOffset = address & BITMASK_RAM_BANK;
|
|
|
|
uInt32 baseAddress = ((whichBankIsThere & BIT_BANK_MASK) << RAM_BANK_TO_POWER) + byteOffset;
|
|
|
|
myRAM[baseAddress] = value; // write to RAM
|
|
|
|
|
2014-06-04 14:29:33 +00:00
|
|
|
// TODO: Stephen -- should we set 'myBankChanged' true when there's a RAM write?
|
|
|
|
|
2014-06-03 13:53:49 +00:00
|
|
|
} else { // patching ROM (1K banks)
|
|
|
|
|
|
|
|
uInt32 byteOffset = address & BITMASK_ROM_BANK;
|
2014-06-02 20:41:19 +00:00
|
|
|
uInt32 baseAddress = (whichBankIsThere << ROM_BANK_TO_POWER) + byteOffset;
|
|
|
|
myImage[baseAddress] = value; // write to the image
|
|
|
|
}
|
|
|
|
|
|
|
|
return myBankChanged;
|
2014-07-26 20:32:33 +00:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
2014-06-02 20:41:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2014-06-03 13:53:49 +00:00
|
|
|
const uInt8* CartridgeDASH::getImage(int& size) const {
|
2014-06-02 20:41:19 +00:00
|
|
|
size = mySize;
|
|
|
|
return myImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2014-06-03 13:53:49 +00:00
|
|
|
bool CartridgeDASH::save(Serializer& out) const {
|
2014-07-26 20:32:33 +00:00
|
|
|
|
2014-06-03 13:53:49 +00:00
|
|
|
try {
|
2014-06-02 20:41:19 +00:00
|
|
|
out.putString(name());
|
2014-07-26 20:32:33 +00:00
|
|
|
out.putShortArray((uInt16*)bankInUse, 8);
|
2014-06-02 20:41:19 +00:00
|
|
|
out.putByteArray(myRAM, RAM_TOTAL_SIZE);
|
2014-06-03 13:53:49 +00:00
|
|
|
} catch (...) {
|
2014-06-02 20:41:19 +00:00
|
|
|
cerr << "ERROR: CartridgeDASH::save" << endl;
|
2014-06-04 14:29:33 +00:00
|
|
|
return false;
|
2014-06-03 13:53:49 +00:00
|
|
|
}
|
2014-06-04 14:29:33 +00:00
|
|
|
return true;
|
2014-06-02 20:41:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2014-06-03 13:53:49 +00:00
|
|
|
bool CartridgeDASH::load(Serializer& in) {
|
2014-07-26 20:32:33 +00:00
|
|
|
|
2014-06-03 13:53:49 +00:00
|
|
|
try {
|
|
|
|
if (in.getString() != name())
|
2014-06-02 20:41:19 +00:00
|
|
|
return false;
|
2014-07-26 20:32:33 +00:00
|
|
|
in.getShortArray((uInt16*)bankInUse, 8);
|
2014-06-02 20:41:19 +00:00
|
|
|
in.getByteArray(myRAM, RAM_TOTAL_SIZE);
|
2014-06-03 13:53:49 +00:00
|
|
|
} catch (...) {
|
2014-06-02 20:41:19 +00:00
|
|
|
cerr << "ERROR: CartridgeDASH::load" << endl;
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-26 20:32:33 +00:00
|
|
|
|
|
|
|
initializeBankState();
|
2014-06-02 20:41:19 +00:00
|
|
|
return true;
|
|
|
|
}
|