2008-02-27 14:14:38 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
2016-12-30 00:00:30 +00:00
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
2008-02-27 14:14:38 +00:00
|
|
|
// 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
|
|
|
|
//
|
2021-12-31 19:37:17 +00:00
|
|
|
// Copyright (c) 1995-2022 by Bradford W. Mott, Stephen Anthony
|
2010-04-10 21:37:23 +00:00
|
|
|
// and the Stella Team
|
2008-02-27 14:14:38 +00:00
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
2008-02-27 14:14:38 +00:00
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#include "System.hxx"
|
|
|
|
#include "M6532.hxx"
|
2016-12-10 17:08:28 +00:00
|
|
|
#include "TIA.hxx"
|
2008-02-27 14:14:38 +00:00
|
|
|
#include "CartX07.hxx"
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2019-09-16 23:59:08 +00:00
|
|
|
CartridgeX07::CartridgeX07(const ByteBuffer& image, size_t size,
|
2020-06-10 19:29:27 +00:00
|
|
|
const string& md5, const Settings& settings,
|
|
|
|
size_t bsSize)
|
|
|
|
: CartridgeEnhanced(image, size, md5, settings, bsSize)
|
2008-02-27 14:14:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeX07::install(System& system)
|
|
|
|
{
|
2020-04-09 14:07:38 +00:00
|
|
|
CartridgeEnhanced::install(system);
|
2008-02-27 14:14:38 +00:00
|
|
|
|
|
|
|
// Set the page accessing methods for the hot spots
|
|
|
|
// The hotspots use almost all addresses below 0x1000, so we simply grab them
|
|
|
|
// all and forward the TIA/RIOT calls from the peek and poke methods.
|
2022-03-29 00:30:26 +00:00
|
|
|
const System::PageAccess access(this, System::PageAccessType::READWRITE);
|
2017-09-16 01:58:20 +00:00
|
|
|
for(uInt16 addr = 0x00; addr < 0x1000; addr += System::PAGE_SIZE)
|
|
|
|
mySystem->setPageAccess(addr, access);
|
2008-02-27 14:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2020-04-09 14:07:38 +00:00
|
|
|
bool CartridgeX07::checkSwitchBank(uInt16 address, uInt8)
|
2008-02-27 14:14:38 +00:00
|
|
|
{
|
|
|
|
// Switch banks if necessary
|
2009-05-25 17:51:52 +00:00
|
|
|
if((address & 0x180f) == 0x080d)
|
2020-04-09 14:07:38 +00:00
|
|
|
{
|
2009-05-25 17:51:52 +00:00
|
|
|
bank((address & 0xf0) >> 4);
|
2020-04-09 14:07:38 +00:00
|
|
|
return true;
|
|
|
|
}
|
2008-02-27 14:14:38 +00:00
|
|
|
else if((address & 0x1880) == 0)
|
|
|
|
{
|
2020-04-09 14:07:38 +00:00
|
|
|
if((getBank() & 0xe) == 0xe)
|
|
|
|
{
|
|
|
|
bank(((address & 0x40) >> 6) | 0xe);
|
|
|
|
return true;
|
|
|
|
}
|
2008-02-27 14:14:38 +00:00
|
|
|
}
|
|
|
|
|
2020-04-09 14:07:38 +00:00
|
|
|
return false;
|
2008-02-27 14:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2020-04-09 14:07:38 +00:00
|
|
|
uInt8 CartridgeX07::peek(uInt16 address)
|
2008-02-27 14:14:38 +00:00
|
|
|
{
|
2020-04-09 14:07:38 +00:00
|
|
|
uInt8 value = 0; // JTZ: is this correct?
|
2008-02-27 14:14:38 +00:00
|
|
|
// Check for RAM or TIA mirroring
|
2022-03-29 00:30:26 +00:00
|
|
|
const uInt16 lowAddress = address & 0x3ff;
|
2020-04-09 14:07:38 +00:00
|
|
|
|
2008-02-27 14:14:38 +00:00
|
|
|
if(lowAddress & 0x80)
|
2020-04-09 14:07:38 +00:00
|
|
|
value = mySystem->m6532().peek(address);
|
2008-02-27 14:14:38 +00:00
|
|
|
else if(!(lowAddress & 0x200))
|
2020-04-09 14:07:38 +00:00
|
|
|
value = mySystem->tia().peek(address);
|
2008-02-27 14:14:38 +00:00
|
|
|
|
2022-08-21 22:03:08 +00:00
|
|
|
checkSwitchBank(address, 0);
|
2008-02-27 14:14:38 +00:00
|
|
|
|
2020-04-09 14:07:38 +00:00
|
|
|
return value;
|
2008-02-27 14:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2020-04-09 14:07:38 +00:00
|
|
|
bool CartridgeX07::poke(uInt16 address, uInt8 value)
|
2008-02-27 14:14:38 +00:00
|
|
|
{
|
2020-04-09 14:07:38 +00:00
|
|
|
// Check for RAM or TIA mirroring
|
2022-03-29 00:30:26 +00:00
|
|
|
const uInt16 lowAddress = address & 0x3ff;
|
2008-02-27 14:14:38 +00:00
|
|
|
|
2020-04-09 14:07:38 +00:00
|
|
|
if(lowAddress & 0x80)
|
|
|
|
mySystem->m6532().poke(address, value);
|
|
|
|
else if(!(lowAddress & 0x200))
|
|
|
|
mySystem->tia().poke(address, value);
|
2008-02-27 14:14:38 +00:00
|
|
|
|
2022-08-21 22:03:08 +00:00
|
|
|
checkSwitchBank(address, 0);
|
2008-02-27 14:14:38 +00:00
|
|
|
|
2020-04-09 14:07:38 +00:00
|
|
|
return false;
|
2008-02-27 14:14:38 +00:00
|
|
|
}
|