mirror of https://github.com/stella-emu/stella.git
Add considering addresses for current bank. This is important for types where the 4K ROM address space is segmented into smaller slices, so there can be more than one bank at a time.
This addresses #536.
This commit is contained in:
parent
2f24bcbb4f
commit
3ff6a95314
|
@ -47,7 +47,7 @@ bool BankRomCheat::enable()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool BankRomCheat::disable()
|
||||
{
|
||||
int oldBank = myOSystem.console().cartridge().getBank();
|
||||
int oldBank = myOSystem.console().cartridge().getBank(address);
|
||||
myOSystem.console().cartridge().bank(bank);
|
||||
|
||||
for(int i = 0; i < count; ++i)
|
||||
|
@ -63,7 +63,7 @@ void BankRomCheat::evaluate()
|
|||
{
|
||||
if(!myEnabled)
|
||||
{
|
||||
int oldBank = myOSystem.console().cartridge().getBank();
|
||||
int oldBank = myOSystem.console().cartridge().getBank(address);
|
||||
myOSystem.console().cartridge().bank(bank);
|
||||
|
||||
for(int i = 0; i < count; ++i)
|
||||
|
|
|
@ -244,7 +244,7 @@ bool CartDebug::disassemble(bool force)
|
|||
if(changed)
|
||||
{
|
||||
// Are we disassembling from ROM or ZP RAM?
|
||||
BankInfo& info = (PC & 0x1000) ? myBankInfo[getBank()] :
|
||||
BankInfo& info = (PC & 0x1000) ? myBankInfo[getBank(PC)] :
|
||||
myBankInfo[myBankInfo.size()-1];
|
||||
|
||||
// If the offset has changed, all old addresses must be 'converted'
|
||||
|
@ -384,7 +384,8 @@ bool CartDebug::addDirective(CartDebug::DisasmType type,
|
|||
return false;
|
||||
|
||||
if(bank < 0) // Do we want the current bank or ZP RAM?
|
||||
bank = (myDebugger.cpuDebug().pc() & 0x1000) ? getBank() : int(myBankInfo.size())-1;
|
||||
bank = (myDebugger.cpuDebug().pc() & 0x1000) ?
|
||||
getBank(myDebugger.cpuDebug().pc()) : int(myBankInfo.size())-1;
|
||||
|
||||
bank = std::min(bank, bankCount());
|
||||
BankInfo& info = myBankInfo[bank];
|
||||
|
@ -506,9 +507,15 @@ bool CartDebug::addDirective(CartDebug::DisasmType type,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
int CartDebug::getBank()
|
||||
int CartDebug::getBank(uInt16 addr)
|
||||
{
|
||||
return myConsole.cartridge().getBank();
|
||||
return myConsole.cartridge().getBank(addr);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
int CartDebug::getPCBank()
|
||||
{
|
||||
return myConsole.cartridge().getBank(myDebugger.cpuDebug().pc());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -173,7 +173,10 @@ class CartDebug : public DebuggerSystem
|
|||
Get the current bank in use by the cartridge
|
||||
(non-const because of use in YaccParser)
|
||||
*/
|
||||
int getBank();
|
||||
int getBank(uInt16 addr);
|
||||
|
||||
|
||||
int getPCBank();
|
||||
|
||||
/**
|
||||
Get the total number of banks supported by the cartridge.
|
||||
|
|
|
@ -331,7 +331,7 @@ int Debugger::trace()
|
|||
int targetPC = myCpuDebug->pc() + 3; // return address
|
||||
|
||||
// set temporary breakpoint at target PC (if not existing already)
|
||||
Int8 bank = myCartDebug->getBank();
|
||||
Int8 bank = myCartDebug->getBank(targetPC);
|
||||
if(!checkBreakPoint(targetPC, bank))
|
||||
{
|
||||
// add temporary breakpoint and remove later
|
||||
|
|
|
@ -738,7 +738,7 @@ void DebuggerParser::executeBreak()
|
|||
addr = args[0];
|
||||
|
||||
if(argCount < 2)
|
||||
bank = debugger.cartDebug().getBank();
|
||||
bank = debugger.cartDebug().getBank(addr);
|
||||
else
|
||||
{
|
||||
bank = args[1];
|
||||
|
|
|
@ -65,7 +65,7 @@ void Cartridge3FWidget::loadConfig()
|
|||
const CartState& state = static_cast<const CartState&>(cart.getState());
|
||||
const CartState& oldstate = static_cast<const CartState&>(cart.getOldState());
|
||||
|
||||
myBank->setSelectedIndex(myCart.getBank(), state.bank != oldstate.bank);
|
||||
myBank->setSelectedIndex(myCart.getBank(0), state.bank != oldstate.bank);
|
||||
|
||||
CartDebugWidget::loadConfig();
|
||||
}
|
||||
|
|
|
@ -492,7 +492,8 @@ void RomListWidget::drawWidget(bool hilite)
|
|||
|
||||
// Draw checkboxes for correct lines (takes scrolling into account)
|
||||
myCheckList[i]->setState(instance().debugger().
|
||||
checkBreakPoint(dlist[pos].address, instance().debugger().cartDebug().getBank()));
|
||||
checkBreakPoint(dlist[pos].address,
|
||||
instance().debugger().cartDebug().getBank(dlist[pos].address)));
|
||||
|
||||
myCheckList[i]->setDirty();
|
||||
myCheckList[i]->draw();
|
||||
|
|
|
@ -171,7 +171,7 @@ void RomWidget::toggleBreak(int disasm_line)
|
|||
|
||||
if(list[disasm_line].address != 0 && list[disasm_line].bytes != "")
|
||||
instance().debugger().toggleBreakPoint(list[disasm_line].address,
|
||||
instance().debugger().cartDebug().getBank());
|
||||
instance().debugger().cartDebug().getBank(list[disasm_line].address));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -146,6 +146,13 @@ class Cartridge : public Device
|
|||
*/
|
||||
virtual uInt16 getBank() const { return 0; }
|
||||
|
||||
/**
|
||||
Get the current bank for the provided address.
|
||||
|
||||
@param address The address to get the bank for
|
||||
*/
|
||||
virtual uInt16 getBank(uInt16 addr) const { return getBank(); }
|
||||
|
||||
/**
|
||||
Query the number of 'banks' supported by the cartridge. Note that
|
||||
this information is cart-specific, where each cart basically defines
|
||||
|
|
|
@ -185,9 +185,12 @@ bool Cartridge3E::bank(uInt16 bank)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 Cartridge3E::getBank() const
|
||||
uInt16 Cartridge3E::getBank(uInt16 addr) const
|
||||
{
|
||||
return myCurrentBank;
|
||||
if(addr & 0x800)
|
||||
return (mySize >> 11) - 1; // 2K slices, fixed bank
|
||||
else
|
||||
return 255; // 256 - 1
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -102,7 +102,7 @@ class Cartridge3E : public Cartridge
|
|||
/**
|
||||
Get the current bank.
|
||||
*/
|
||||
uInt16 getBank() const override;
|
||||
uInt16 getBank(uInt16 addr) const override;
|
||||
|
||||
/**
|
||||
Query the number of banks supported by the cartridge.
|
||||
|
|
|
@ -78,6 +78,19 @@ void Cartridge3EPlus::install(System& system)
|
|||
bankROM((3 << BANK_BITS) | 0);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 Cartridge3EPlus::getBank(uInt16 addr) const
|
||||
{
|
||||
return bankInUse[(addr & 0xFFF) >> 10]; // 1K slices
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 Cartridge3EPlus::bankCount() const
|
||||
{
|
||||
return mySize >> 10; // 1K slices
|
||||
}
|
||||
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt8 Cartridge3EPlus::peek(uInt16 address)
|
||||
{
|
||||
|
|
|
@ -70,6 +70,16 @@ class Cartridge3EPlus: public Cartridge
|
|||
*/
|
||||
void install(System& system) override;
|
||||
|
||||
/**
|
||||
Get the current bank.
|
||||
*/
|
||||
uInt16 getBank(uInt16 addr) const override;
|
||||
|
||||
/**
|
||||
Query the number of banks supported by the cartridge.
|
||||
*/
|
||||
uInt16 bankCount() const override;
|
||||
|
||||
/**
|
||||
Patch the cartridge ROM.
|
||||
|
||||
|
|
|
@ -125,15 +125,18 @@ bool Cartridge3F::bank(uInt16 bank)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 Cartridge3F::getBank() const
|
||||
uInt16 Cartridge3F::getBank(uInt16 addr) const
|
||||
{
|
||||
if (addr & 0x800)
|
||||
return (mySize >> 11) - 1; // 2K slices, fixed bank
|
||||
else
|
||||
return myCurrentBank;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 Cartridge3F::bankCount() const
|
||||
{
|
||||
return mySize >> 11;
|
||||
return mySize >> 11; // 2K slices
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -79,7 +79,7 @@ class Cartridge3F : public Cartridge
|
|||
/**
|
||||
Get the current bank.
|
||||
*/
|
||||
uInt16 getBank() const override;
|
||||
uInt16 getBank(uInt16 addr) const override;
|
||||
|
||||
/**
|
||||
Query the number of banks supported by the cartridge.
|
||||
|
|
|
@ -74,6 +74,18 @@ void CartridgeE0::install(System& system)
|
|||
mySystem->setPageAccess(addr, access);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 CartridgeE0::getBank(uInt16 addr) const
|
||||
{
|
||||
return myCurrentSlice[(addr & 0xFFF) >> 10]; // 1K slices
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 CartridgeE0::bankCount() const
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt8 CartridgeE0::peek(uInt16 address)
|
||||
{
|
||||
|
|
|
@ -72,6 +72,17 @@ class CartridgeE0 : public Cartridge
|
|||
*/
|
||||
void install(System& system) override;
|
||||
|
||||
|
||||
/**
|
||||
Get the current bank.
|
||||
*/
|
||||
uInt16 getBank(uInt16 addr) const override;
|
||||
|
||||
/**
|
||||
Query the number of banks supported by the cartridge.
|
||||
*/
|
||||
uInt16 bankCount() const override;
|
||||
|
||||
/**
|
||||
Patch the cartridge ROM.
|
||||
|
||||
|
|
|
@ -196,9 +196,9 @@ bool CartridgeMNetwork::bank(uInt16 slice)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 CartridgeMNetwork::getBank() const
|
||||
uInt16 CartridgeMNetwork::getBank(uInt16 addr) const
|
||||
{
|
||||
return myCurrentSlice[0];
|
||||
return myCurrentSlice[(addr & 0xFFF) >> 11]; // 2K slices
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -101,7 +101,7 @@ class CartridgeMNetwork : public Cartridge
|
|||
/**
|
||||
Get the current bank.
|
||||
*/
|
||||
uInt16 getBank() const override;
|
||||
uInt16 getBank(uInt16 addr) const override;
|
||||
|
||||
/**
|
||||
Query the number of banks supported by the cartridge.
|
||||
|
|
|
@ -281,7 +281,7 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result)
|
|||
|
||||
if(myBreakPoints.isInitialized())
|
||||
{
|
||||
uInt8 bank = mySystem->cart().getBank();
|
||||
uInt8 bank = mySystem->cart().getBank(PC);
|
||||
|
||||
if(myBreakPoints.check(PC, bank))
|
||||
{
|
||||
|
|
|
@ -180,7 +180,7 @@ int const_to_int(char* ch)
|
|||
CartMethod getCartSpecial(char* ch)
|
||||
{
|
||||
if(BSPF::equalsIgnoreCase(ch, "_bank"))
|
||||
return &CartDebug::getBank;
|
||||
return &CartDebug::getPCBank;
|
||||
else if(BSPF::equalsIgnoreCase(ch, "__lastread"))
|
||||
return &CartDebug::lastReadBaseAddress;
|
||||
else if(BSPF::equalsIgnoreCase(ch, "__lastwrite"))
|
||||
|
|
Loading…
Reference in New Issue