Checking in WIP for Distella integration. Moved the internal text

handling to C++ stringstreams instead of C-style character arrays,
which fixed some segfaults (sprintf is evil).

First pass at tying the number of banks to the disassembly.  The idea
is that the startup bank (which is now identified by the cart) always
starts at address at 0xfffc, while the other banks are defined by the
PC at the first time we enter the debugger.  This is still a WIP,
since there's no actual checking done yet to see if the current PC
is in the current disassembly.

Added 'ctrlcombo' commandline argument, which completely disables
checking for Control-x key combos.  This is useful when playing
2-player games where the 'f', 'r' and 'Control' keys are supposed
to be treated separately.  Previously, pressing Control and 'r' or
'f' processed some other action (change framerate, reload rom, etc).


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1964 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2010-03-05 22:02:12 +00:00
parent 6de4e358e1
commit e0310e8f35
35 changed files with 322 additions and 288 deletions

View File

@ -861,6 +861,15 @@
<td>Stelladaptor 2 emulates specified joystick port.</td>
</tr>
<tr>
<td><pre>-ctrlcombo &lt;1|0&gt;</pre></td>
<td>Use control-x key combos. This is normally enabled, since the
Quit command is tied to 'Control-q'. However, there are times when
a 2-player game is using either the 'f' or 'r' keys for movement,
and pressing Control (for Fire) will perform an unwanted action
associated with Control-r or Control-f.</td>
</tr>
<tr>
<td><pre>-autoslot &lt;1|0&gt;</pre></td>
<td>Automatically switch to the next available save state slot after

View File

@ -20,6 +20,7 @@
#include "Array.hxx"
#include "System.hxx"
#include "DiStella.hxx"
#include "CpuDebug.hxx"
#include "CartDebug.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -34,6 +35,20 @@ CartDebug::CartDebug(Debugger& dbg, Console& console, const RamAreaList& areas)
myRamAreas = areas;
for(RamAreaList::const_iterator i = areas.begin(); i != areas.end(); ++i)
addRamArea(i->start, i->size, i->roffset, i->woffset);
// We need a start address for each potential bank
myStartAddresses = new uInt16[myConsole.cartridge().bankCount()];
for(int i = 0; i < myConsole.cartridge().bankCount(); ++i)
myStartAddresses[i] = 0;
// We know the address for the startup bank right now
myStartAddresses[myConsole.cartridge().startBank()] = myDebugger.dpeek(0xfffc);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartDebug::~CartDebug()
{
delete[] myStartAddresses;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -172,7 +187,6 @@ string CartDebug::toString()
bool CartDebug::disassemble(bool autocode)
{
bool changed = false;
// Test current disassembly; don't re-disassemble if it hasn't changed
// ...
changed = true; // FIXME
@ -182,10 +196,26 @@ bool CartDebug::disassemble(bool autocode)
myDisassembly.clear();
myAddrToLineList.clear();
// TODO - add logic to determine correct start address to use
// it will depend on the current bank and PC
uInt16 start = myDebugger.dpeek(0xfffc);
// We only use the reset vector when we're actually in the startup bank
// Otherwise, we look at previous accesses to this bank to begin
// If no previous address exists, use the current program counter
uInt16 start = myStartAddresses[getBank()];
cerr << "start addresses: ";
for(int i = 0; i < myConsole.cartridge().bankCount(); ++i) cerr << " " << setw(4) << hex << myStartAddresses[i];
cerr << endl;
cerr << "current bank = " << getBank() << ", start bank = " << myConsole.cartridge().startBank() << endl
<< "reset = " << hex << 0xfffc << ", pc = " << hex << myDebugger.cpuDebug().pc() << endl
<< "start = " << hex << start << endl;
if(start == 0)
start = myStartAddresses[getBank()] = myDebugger.cpuDebug().pc();
cerr << "actual start = " << hex << start << endl << endl;
// For now, DiStella can't handle address space below 0x1000
if(!(start & 0x1000))
return true;
autocode = false;
DiStella distella(myDisassembly, start, autocode);
// Parts of the disassembly will be accessed later in different ways

View File

@ -58,6 +58,7 @@ class CartDebug : public DebuggerSystem
public:
CartDebug(Debugger& dbg, Console& console, const RamAreaList& areas);
virtual ~CartDebug();
const DebuggerState& getState();
const DebuggerState& getOldState() { return myOldState; }
@ -187,8 +188,14 @@ class CartDebug : public DebuggerSystem
private:
CartState myState;
CartState myOldState;
RamAreaList myRamAreas;
// A pointer to an array of start addresses for each bank in a cart
// The startup bank will normally be 0xfffc, while the others are
// determined when the debugger is first opened
uInt16* myStartAddresses;
// Used for the disassembly display, and mapping from addresses
// to corresponding lines of text in that display
DisassemblyList myDisassembly;

View File

@ -16,10 +16,6 @@
// $Id$
//============================================================================
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "bspf.hxx"
#include "Debugger.hxx"
#include "DiStella.hxx"
@ -111,11 +107,8 @@ void DiStella::disasm(uInt32 distart, int pass)
uInt32 ad;
short amode;
int bytes=0, labfound=0, addbranch=0;
char linebuff[256],nextline[256], nextlinebytes[256];
strcpy(linebuff,"");
strcpy(nextline,"");
strcpy(nextlinebytes,"");
myBuf.str("");
stringstream nextline, nextlinebytes;
myDisasmBuf.str("");
/* pc=myAppData.start; */
myPC = distart - myOffset;
@ -129,13 +122,13 @@ void DiStella::disasm(uInt32 distart, int pass)
else if (pass == 3)
{
if (check_bit(labels[myPC],REFERENCED))
myBuf << HEX4 << myPC+myOffset << "'L'" << HEX4 << myPC+myOffset << "'";
myDisasmBuf << HEX4 << myPC+myOffset << "'L'" << HEX4 << myPC+myOffset << "'";
else
myBuf << HEX4 << myPC+myOffset << "' '";
myDisasmBuf << HEX4 << myPC+myOffset << "' '";
myBuf << ".byte $" << HEX2 << (int)Debugger::debugger().peek(myPC+myOffset) << " ; ";
myDisasmBuf << ".byte $" << HEX2 << (int)Debugger::debugger().peek(myPC+myOffset) << " ; ";
showgfx(Debugger::debugger().peek(myPC+myOffset));
myBuf << " $" << HEX4 << myPC+myOffset;
myDisasmBuf << " $" << HEX4 << myPC+myOffset;
addEntry();
}
myPC++;
@ -147,7 +140,7 @@ void DiStella::disasm(uInt32 distart, int pass)
if (pass == 3)
{
bytes = 1;
myBuf << HEX4 << myPC+myOffset << "'L" << HEX4 << myPC+myOffset << "'.byte "
myDisasmBuf << HEX4 << myPC+myOffset << "'L" << HEX4 << myPC+myOffset << "'.byte "
<< "$" << HEX2 << (int)Debugger::debugger().peek(myPC+myOffset);
}
myPC++;
@ -161,11 +154,11 @@ void DiStella::disasm(uInt32 distart, int pass)
if (bytes == 17)
{
addEntry();
myBuf << " ' '.byte $" << HEX2 << (int)Debugger::debugger().peek(myPC+myOffset);
myDisasmBuf << " ' '.byte $" << HEX2 << (int)Debugger::debugger().peek(myPC+myOffset);
bytes = 1;
}
else
myBuf << ",$" << HEX2 << (int)Debugger::debugger().peek(myPC+myOffset);
myDisasmBuf << ",$" << HEX2 << (int)Debugger::debugger().peek(myPC+myOffset);
}
myPC++;
}
@ -173,7 +166,7 @@ void DiStella::disasm(uInt32 distart, int pass)
if (pass == 3)
{
addEntry();
myBuf << " ' ' ";
myDisasmBuf << " ' ' ";
addEntry();
}
}
@ -186,9 +179,9 @@ void DiStella::disasm(uInt32 distart, int pass)
else if (pass == 3)
{
if (check_bit(labels[myPC], REFERENCED))
myBuf << HEX4 << myPC+myOffset << "'L" << HEX4 << myPC+myOffset << "'";
myDisasmBuf << HEX4 << myPC+myOffset << "'L" << HEX4 << myPC+myOffset << "'";
else
myBuf << HEX4 << myPC+myOffset << "' '";
myDisasmBuf << HEX4 << myPC+myOffset << "' '";
}
amode = ourLookup[op].addr_mode;
@ -198,10 +191,7 @@ void DiStella::disasm(uInt32 distart, int pass)
{
amode = IMPLIED;
if (pass == 3)
{
sprintf(linebuff,".byte $%.2X ;",op);
strcat(nextline,linebuff);
}
nextline << ".byte $" << HEX2 << (int)op << " ;";
}
if (pass == 1)
@ -217,10 +207,9 @@ void DiStella::disasm(uInt32 distart, int pass)
}
else if (pass == 3)
{
sprintf(linebuff,"%s",ourLookup[op].mnemonic);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X ",op);
strcat(nextlinebytes,linebuff);
nextline << ourLookup[op].mnemonic;
// sprintf(linebuff,"%02X ",op);
nextlinebytes << HEX2 << (int)op << " ";
}
if (myPC >= myAppData.end)
@ -238,18 +227,18 @@ void DiStella::disasm(uInt32 distart, int pass)
{
/* Line information is already printed; append .byte since last instruction will
put recompilable object larger that original binary file */
myBuf << ".byte $" << HEX2 << op;
myDisasmBuf << ".byte $" << HEX2 << (int)op;
addEntry();
if (myPC == myAppData.end)
{
if (check_bit(labels[myPC],REFERENCED))
myBuf << HEX4 << myPC+myOffset << "'L" << HEX4 << myPC+myOffset << "'";
myDisasmBuf << HEX4 << myPC+myOffset << "'L" << HEX4 << myPC+myOffset << "'";
else
myBuf << HEX4 << myPC+myOffset << "' '";
myDisasmBuf << HEX4 << myPC+myOffset << "' '";
op = Debugger::debugger().peek(myPC+myOffset); myPC++;
myBuf << ".byte $" << HEX2 << (int)op;
myDisasmBuf << ".byte $" << HEX2 << (int)op;
addEntry();
}
}
@ -269,14 +258,10 @@ void DiStella::disasm(uInt32 distart, int pass)
{
/* Line information is already printed, but we can remove the
Instruction (i.e. BMI) by simply clearing the buffer to print */
strcpy(nextline,"");
sprintf(linebuff,".byte $%.2X",op);
strcat(nextline,linebuff);
myBuf << nextline;
myDisasmBuf << ".byte $" << HEX2 << (int)op;
addEntry();
strcpy(nextline,"");
strcpy(nextlinebytes,"");
nextline.str("");
nextlinebytes.str("");
}
myPC++;
myPCEnd = myAppData.end + myOffset;
@ -299,7 +284,7 @@ void DiStella::disasm(uInt32 distart, int pass)
if (pass == 3)
{
sprintf(linebuff,"\n");
strcat(nextline,linebuff);
strcat(_nextline,linebuff);
}
break;
}
@ -307,10 +292,7 @@ void DiStella::disasm(uInt32 distart, int pass)
case ACCUMULATOR:
{
if (pass == 3)
{
sprintf(linebuff," A");
strcat(nextline,linebuff);
}
nextline << " A";
break;
}
@ -331,43 +313,30 @@ void DiStella::disasm(uInt32 distart, int pass)
else if (pass == 3)
{
if (ad < 0x100)
{
sprintf(linebuff,".w ");
strcat(nextline,linebuff);
}
nextline << ".w ";
else
{
sprintf(linebuff," ");
strcat(nextline,linebuff);
}
nextline << " ";
if (labfound == 1)
{
sprintf(linebuff,"L%.4X",ad);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X %02X",(ad&0xff),(ad>>8));
strcat(nextlinebytes,linebuff);
nextline << "L" << HEX4 << ad;
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
}
else if (labfound == 3)
{
sprintf(linebuff,"%s",CartDebug::ourIOMnemonic[ad-0x280]);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X %02X",(ad&0xff),(ad>>8));
strcat(nextlinebytes,linebuff);
nextline << CartDebug::ourIOMnemonic[ad-0x280];
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
}
else if (labfound == 4)
{
int tmp = (ad & myAppData.end)+myOffset;
sprintf(linebuff,"L%.4X",tmp);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X %02X",(tmp&0xff),(tmp>>8));
strcat(nextlinebytes,linebuff);
nextline << "L" << HEX4 << tmp;
nextlinebytes << HEX2 << (int)(tmp&0xff) << " " << HEX2 << (int)(tmp>>8);
}
else
{
sprintf(linebuff,"$%.4X",ad);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X %02X",(ad&0xff),(ad>>8));
strcat(nextlinebytes,linebuff);
nextline << "$" << HEX4 << ad;
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
}
}
break;
@ -380,18 +349,12 @@ void DiStella::disasm(uInt32 distart, int pass)
if (pass == 3)
{
if (labfound == 2)
{
sprintf(linebuff," %s", ourLookup[op].rw_mode == READ ?
nextline << " " << (ourLookup[op].rw_mode == READ ?
CartDebug::ourTIAMnemonicR[d1&0x0f] : CartDebug::ourTIAMnemonicW[d1&0x3f]);
strcat(nextline,linebuff);
}
else
{
sprintf(linebuff," $%.2X ",d1);
strcat(nextline,linebuff);
}
sprintf(linebuff,"%02X", d1);
strcat(nextlinebytes,linebuff);
nextline << " $" << HEX2 << (int)d1;
nextlinebytes << HEX2 << (int)d1;
}
break;
}
@ -401,10 +364,8 @@ void DiStella::disasm(uInt32 distart, int pass)
d1 = Debugger::debugger().peek(myPC+myOffset); myPC++;
if (pass == 3)
{
sprintf(linebuff," #$%.2X ",d1);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X",d1);
strcat(nextlinebytes,linebuff);
nextline << " #$" << HEX2 << (int)d1 << " ";
nextlinebytes << HEX2 << (int)d1;
}
break;
}
@ -416,44 +377,30 @@ void DiStella::disasm(uInt32 distart, int pass)
if (pass == 3)
{
if (ad < 0x100)
{
sprintf(linebuff,".wx ");
strcat(nextline,linebuff);
}
nextline << ".wx ";
else
{
sprintf(linebuff," ");
strcat(nextline,linebuff);
}
nextline << " ";
if (labfound == 1)
{
sprintf(linebuff,"L%.4X,X",ad);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X %02X",(ad&0xff),(ad>>8));
strcat(nextlinebytes,linebuff);
nextline << "L" << HEX4 << ad << ",X";
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
}
else if (labfound == 3)
{
sprintf(linebuff,"%s,X",CartDebug::ourIOMnemonic[ad-0x280]);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X %02X",(ad&0xff),(ad>>8));
strcat(nextlinebytes,linebuff);
nextline << CartDebug::ourIOMnemonic[ad-0x280] << ",X";
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
}
else if (labfound == 4)
{
int tmp = (ad & myAppData.end)+myOffset;
sprintf(linebuff,"L%.4X,X",tmp);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X %02X",(tmp&0xff),(tmp>>8));
strcat(nextlinebytes,linebuff);
nextline << "L" << HEX4 << tmp << ",X";
nextlinebytes << HEX2 << (int)(tmp&0xff) << " " << HEX2 << (int)(tmp>>8);
}
else
{
sprintf(linebuff,"$%.4X,X",ad);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X %02X",(ad&0xff),(ad>>8));
strcat(nextlinebytes,linebuff);
nextline << "$" << HEX4 << ad << ",X";
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
}
}
break;
@ -466,43 +413,30 @@ void DiStella::disasm(uInt32 distart, int pass)
if (pass == 3)
{
if (ad < 0x100)
{
sprintf(linebuff,".wy ");
strcat(nextline,linebuff);
}
nextline << ".wy ";
else
{
sprintf(linebuff," ");
strcat(nextline,linebuff);
}
nextline << " ";
if (labfound == 1)
{
sprintf(linebuff,"L%.4X,Y",ad);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X %02X",(ad&0xff),(ad>>8));
strcat(nextlinebytes,linebuff);
nextline << "L" << HEX4 << ad << ",Y";
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
}
else if (labfound == 3)
{
sprintf(linebuff,"%s,Y",CartDebug::ourIOMnemonic[ad-0x280]);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X %02X",(ad&0xff),(ad>>8));
strcat(nextlinebytes,linebuff);
nextline << CartDebug::ourIOMnemonic[ad-0x280] << ",Y";
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
}
else if (labfound == 4)
{
int tmp = (ad & myAppData.end)+myOffset;
sprintf(linebuff,"L%.4X,Y",tmp);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X %02X",(tmp&0xff),(tmp>>8));
strcat(nextlinebytes,linebuff);
nextline << "L" << HEX4 << tmp << ",Y";
nextlinebytes << HEX2 << (int)(tmp&0xff) << " " << HEX2 << (int)(tmp>>8);
}
else
{
sprintf(linebuff,"$%.4X,Y",ad);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X %02X",(ad&0xff),(ad>>8));
strcat(nextlinebytes,linebuff);
nextline << "$" << HEX4 << ad << ",Y";
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
}
}
break;
@ -513,10 +447,8 @@ void DiStella::disasm(uInt32 distart, int pass)
d1 = Debugger::debugger().peek(myPC+myOffset); myPC++;
if (pass == 3)
{
sprintf(linebuff," ($%.2X,X)",d1);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X",d1);
strcat(nextlinebytes,linebuff);
nextline << " ($" << HEX2 << (int)d1 << ",X)";
nextlinebytes << HEX2 << (int)d1;
}
break;
}
@ -526,10 +458,8 @@ void DiStella::disasm(uInt32 distart, int pass)
d1 = Debugger::debugger().peek(myPC+myOffset); myPC++;
if (pass == 3)
{
sprintf(linebuff," ($%.2X),Y",d1);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X",d1);
strcat(nextlinebytes,linebuff);
nextline << " ($" << HEX2 << (int)d1 << "),Y";
nextlinebytes << HEX2 << (int)d1;
}
break;
}
@ -541,19 +471,13 @@ void DiStella::disasm(uInt32 distart, int pass)
if (pass == 3)
{
if (labfound == 2)
{
sprintf(linebuff," %s,X", ourLookup[op].rw_mode == READ ?
CartDebug::ourTIAMnemonicR[d1&0x0f] : CartDebug::ourTIAMnemonicW[d1&0x3f]);
strcat(nextline,linebuff);
}
nextline << " " << (ourLookup[op].rw_mode == READ ?
CartDebug::ourTIAMnemonicR[d1&0x0f] :
CartDebug::ourTIAMnemonicW[d1&0x3f]) << ",X";
else
{
sprintf(linebuff," $%.2X,X",d1);
strcat(nextline,linebuff);
}
nextline << " $" << HEX2 << (int)d1 << ",X";
}
sprintf(linebuff,"%02X",d1);
strcat(nextlinebytes,linebuff);
nextlinebytes << HEX2 << (int)d1;
break;
}
@ -564,19 +488,13 @@ void DiStella::disasm(uInt32 distart, int pass)
if (pass == 3)
{
if (labfound == 2)
{
sprintf(linebuff," %s,Y", ourLookup[op].rw_mode == READ ?
CartDebug::ourTIAMnemonicR[d1&0x0f] : CartDebug::ourTIAMnemonicW[d1&0x3f]);
strcat(nextline,linebuff);
}
nextline << " " << (ourLookup[op].rw_mode == READ ?
CartDebug::ourTIAMnemonicR[d1&0x0f] :
CartDebug::ourTIAMnemonicW[d1&0x3f]) << ",Y";
else
{
sprintf(linebuff," $%.2X,Y",d1);
strcat(nextline,linebuff);
}
nextline << " $" << HEX2 << (int)d1 << ",Y";
}
sprintf(linebuff,"%02X",d1);
strcat(nextlinebytes,linebuff);
nextlinebytes << HEX2 << (int)d1;
break;
}
@ -601,17 +519,11 @@ void DiStella::disasm(uInt32 distart, int pass)
{
int tmp = myPC+ad+myOffset;
if (labfound == 1)
{
sprintf(linebuff," L%.4X",tmp);
strcat(nextline,linebuff);
}
nextline << " L" << HEX4 << tmp;
else
{
sprintf(linebuff," $%.4X",tmp);
strcat(nextline,linebuff);
}
sprintf(linebuff,"%02X %02X",(tmp&0xff),(tmp>>8));
strcat(nextlinebytes,linebuff);
nextline << " $" << HEX4 << tmp;
nextlinebytes << HEX2 << (int)(tmp&0xff) << " " << HEX2 << (int)(tmp>>8);
}
break;
}
@ -623,37 +535,18 @@ void DiStella::disasm(uInt32 distart, int pass)
if (pass == 3)
{
if (ad < 0x100)
{
sprintf(linebuff,".ind ");
strcat(nextline,linebuff);
}
nextline << ".ind ";
else
{
sprintf(linebuff," ");
strcat(nextline,linebuff);
}
nextline << " ";
}
if (labfound == 1)
{
sprintf(linebuff,"(L%04X)",ad);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X %02X",(ad&0xff),(ad>>8));
strcat(nextlinebytes,linebuff);
}
nextline << "(L" << HEX4 << ad << ")";
else if (labfound == 3)
{
sprintf(linebuff,"(%s)",CartDebug::ourIOMnemonic[ad-0x280]);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X %02X",(ad&0xff),(ad>>8));
strcat(nextlinebytes,linebuff);
}
nextline << "(" << CartDebug::ourIOMnemonic[ad-0x280] << ")";
else
{
sprintf(linebuff,"($%04X)",ad);
strcat(nextline,linebuff);
sprintf(linebuff,"%02X %02X",(ad&0xff),(ad>>8));
strcat(nextlinebytes,linebuff);
}
nextline << "($" << HEX4 << ad << ")";
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
break;
}
} // end switch
@ -671,23 +564,24 @@ void DiStella::disasm(uInt32 distart, int pass)
}
else if (pass == 3)
{
myBuf << nextline;
if (strlen(nextline) <= 15)
myDisasmBuf << nextline.str();;
uInt32 nextlinelen = nextline.str().length();
if (nextlinelen <= 15)
{
/* Print spaces to align cycle count data */
for (uInt32 charcnt=0;charcnt<15-strlen(nextline);charcnt++)
myBuf << " ";
for (uInt32 charcnt=0;charcnt<15-nextlinelen;charcnt++)
myDisasmBuf << " ";
}
myBuf << ";" << dec << (int)ourLookup[op].cycles << "'" << nextlinebytes;
myDisasmBuf << ";" << dec << (int)ourLookup[op].cycles << "'" << nextlinebytes.str();
addEntry();
if (op == 0x40 || op == 0x60)
{
myBuf << " ' ' ";
myDisasmBuf << " ' ' ";
addEntry();
}
strcpy(nextline,"");
strcpy(nextlinebytes,"");
nextline.str("");
nextlinebytes.str("");
}
}
} /* while loop */
@ -776,29 +670,29 @@ void DiStella::showgfx(uInt8 c)
{
int i;
myBuf << "|";
myDisasmBuf << "|";
for(i = 0;i < 8; i++)
{
if (c > 127)
myBuf << "X";
myDisasmBuf << "X";
else
myBuf << " ";
myDisasmBuf << " ";
c = c << 1;
}
myBuf << "|";
myDisasmBuf << "|";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DiStella::addEntry()
{
const string& line = myBuf.str();
const string& line = myDisasmBuf.str();
CartDebug::DisassemblyTag tag;
if(line[0] == ' ')
tag.address = 0;
else
myBuf >> setw(4) >> hex >> tag.address;
myDisasmBuf >> setw(4) >> hex >> tag.address;
if(line[5] != ' ')
tag.label = line.substr(5, 5);
@ -818,7 +712,7 @@ void DiStella::addEntry()
}
myList.push_back(tag);
myBuf.str("");
myDisasmBuf.str("");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -81,7 +81,7 @@ class DiStella
private:
CartDebug::DisassemblyList& myList;
stringstream myBuf;
stringstream myDisasmBuf;
queue<uInt16> myAddressQueue;
uInt32 myOffset, myPC, myPCBeg, myPCEnd;

View File

@ -222,8 +222,9 @@ string Cartridge::createFromMultiCart(const uInt8*& image, uInt32& size,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge::Cartridge()
: myStartBank(0),
myBankLocked(false)
{
unlockBank();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -249,6 +250,12 @@ bool Cartridge::save(ofstream& out)
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Cartridge::startBank()
{
return myStartBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge::registerRamArea(uInt16 start, uInt16 size,
uInt16 roffset, uInt16 woffset)

View File

@ -40,6 +40,8 @@ typedef Common::Array<RamArea> RamAreaList;
/**
A cartridge is a device which contains the machine code for a
game and handles any bankswitching performed by the cartridge.
A 'bank' is defined as a 4K block that is visible in the
0x1000-0x2000 area (or its mirrors).
@author Bradford W. Mott
@version $Id$
@ -92,6 +94,15 @@ class Cartridge : public Device
void lockBank() { myBankLocked = true; }
void unlockBank() { myBankLocked = false; }
/**
Get the default startup bank for a cart. This is the bank where
the system will look at address 0xFFFC to determine where to
start running code.
@return The startup bank
*/
uInt16 startBank();
#ifdef DEBUGGER_SUPPORT
const RamAreaList& ramAreas() { return myRamAreaList; }
#endif
@ -114,7 +125,12 @@ class Cartridge : public Device
virtual int bank() = 0;
/**
Query the number of banks supported by the cartridge.
Query the number of banks supported by the cartridge. Note that
we're counting the number of 4K 'blocks' that can be swapped into
the 4K address space in the 2600. As such, it's possible to have
a ROM that is larger than 4K *but* only consists of 1 bank.
Such cases occur when pages of ROM can be swapped in and out,
yet the 4K image is considered the same.
*/
virtual int bankCount() = 0;
@ -282,6 +298,9 @@ class Cartridge : public Device
static bool isProbablyX07(const uInt8* image, uInt32 size);
protected:
// The startup bank to use (where to look for the reset vector address)
uInt16 myStartBank;
// If myBankLocked is true, ignore attempts at bankswitching. This is used
// by the debugger, when disassembling/dumping ROM.
bool myBankLocked;

View File

@ -27,6 +27,9 @@ Cartridge0840::Cartridge0840(const uInt8* image)
{
// Copy the ROM image into my buffer
memcpy(myImage, image, 8192);
// Remember startup bank
myStartBank = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -37,8 +40,8 @@ Cartridge0840::~Cartridge0840()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge0840::reset()
{
// Upon reset we switch to bank 0
bank(0);
// Upon reset we switch to the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -37,6 +37,9 @@ Cartridge3E::Cartridge3E(const uInt8* image, uInt32 size)
// However, it may not be addressable all the time (it may be swapped out)
// so probably most of the time, the area will point to ROM instead
registerRamArea(0x1000, 1024, 0x00, 0x400); // 1024 bytes RAM @ 0x1000
// Remember startup bank
myStartBank = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -52,8 +55,8 @@ void Cartridge3E::reset()
for(uInt32 i = 0; i < 32768; ++i)
myRam[i] = mySystem->randGenerator().next();
// We'll map bank 0 into the first segment upon reset
bank(0);
// We'll map the startup bank into the first segment upon reset
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -88,8 +91,8 @@ void Cartridge3E::install(System& system)
mySystem->setPageAccess(j >> shift, access);
}
// Install pages for bank 0 into the first segment
bank(0);
// Install pages for the startup bank into the first segment
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -226,7 +229,7 @@ int Cartridge3E::bank()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge3E::bankCount()
{
return mySize / 2048;
return mySize >> 11;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -32,6 +32,9 @@ Cartridge3F::Cartridge3F(const uInt8* image, uInt32 size)
// Copy the ROM image into my buffer
memcpy(myImage, image, mySize);
// Remember startup bank
myStartBank = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -43,7 +46,7 @@ Cartridge3F::~Cartridge3F()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge3F::reset()
{
// We'll map bank 0 into the first segment upon reset
// We'll map the startup bank into the first segment upon reset
bank(0);
}

View File

@ -26,6 +26,7 @@
// TODO - properly handle read from write port functionality
// Note: do r/w port restrictions even exist for this scheme??
// Port to new CartDebug/disassembler scheme
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge4A50::Cartridge4A50(const uInt8* image, uInt32 size)

View File

@ -23,6 +23,10 @@
#include "System.hxx"
#include "CartAR.hxx"
// TODO - properly handle read from write port functionality
// Note: do r/w port restrictions even exist for this scheme??
// Port to new CartDebug/disassembler scheme
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeAR::CartridgeAR(const uInt8* image, uInt32 size,
const Settings& settings)
@ -402,6 +406,7 @@ int CartridgeAR::bank()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeAR::bankCount()
{
// TODO - this should depend on ROM size
return 32;
}

View File

@ -25,6 +25,7 @@
// TODO - properly handle read from write port functionality
// Note: do r/w port restrictions even exist for this scheme??
// Port to new CartDebug/disassembler scheme
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeDPC::CartridgeDPC(const uInt8* image, uInt32 size)
@ -52,6 +53,9 @@ CartridgeDPC::CartridgeDPC(const uInt8* image, uInt32 size)
// Initialize the system cycles counter & fractional clock values
mySystemCycles = 0;
myFractionalClocks = 0.0;
// Remember startup bank
myStartBank = 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -66,8 +70,8 @@ void CartridgeDPC::reset()
mySystemCycles = mySystem->cycles();
myFractionalClocks = 0.0;
// Upon reset we switch to bank 1
bank(1);
// Upon reset we switch to the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -22,6 +22,8 @@
#include "System.hxx"
#include "CartE0.hxx"
// TODO - Port to new CartDebug/disassembler scheme
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeE0::CartridgeE0(const uInt8* image)
{

View File

@ -22,6 +22,9 @@
#include "System.hxx"
#include "CartE7.hxx"
// TODO - Port to new CartDebug/disassembler scheme
// I'm not sure patch is working, since it doesn't consider RAM areas
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeE7::CartridgeE7(const uInt8* image)
{
@ -34,6 +37,9 @@ CartridgeE7::CartridgeE7(const uInt8* image)
// so probably most of the time, the area will point to ROM instead
registerRamArea(0x1000, 1024, 0x400, 0x00); // 1024 bytes RAM @ 0x1000
registerRamArea(0x1800, 256, 0x100, 0x00); // 256 bytes RAM @ 0x1800
// Remember startup bank
myStartBank = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -50,7 +56,7 @@ void CartridgeE7::reset()
// Install some default banks for the RAM and first segment
bankRAM(0);
bank(0);
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -86,7 +92,7 @@ void CartridgeE7::install(System& system)
// Install some default banks for the RAM and first segment
bankRAM(0);
bank(0);
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -27,6 +27,9 @@ CartridgeEF::CartridgeEF(const uInt8* image)
{
// Copy the ROM image into my buffer
memcpy(myImage, image, 65536);
// Remember startup bank
myStartBank = 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -37,8 +40,8 @@ CartridgeEF::~CartridgeEF()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeEF::reset()
{
// Upon reset we switch to bank 1
bank(1);
// Upon reset we switch to the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -61,8 +64,8 @@ void CartridgeEF::install(System& system)
mySystem->setPageAccess(i >> shift, access);
}
// Install pages for bank 1
bank(1);
// Install pages for the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -30,6 +30,9 @@ CartridgeEFSC::CartridgeEFSC(const uInt8* image)
// This cart contains 128 bytes extended RAM @ 0x1000
registerRamArea(0x1000, 128, 0x80, 0x00);
// Remember startup bank
myStartBank = 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -44,8 +47,8 @@ void CartridgeEFSC::reset()
for(uInt32 i = 0; i < 128; ++i)
myRAM[i] = mySystem->randGenerator().next();
// Upon reset we switch to bank 1
bank(1);
// Upon reset we switch to the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -86,8 +89,8 @@ void CartridgeEFSC::install(System& system)
mySystem->setPageAccess(k >> shift, access);
}
// Install pages for bank 1
bank(1);
// Install pages for the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -27,6 +27,9 @@ CartridgeF0::CartridgeF0(const uInt8* image)
{
// Copy the ROM image into my buffer
memcpy(myImage, image, 65536);
// Remember startup bank
myStartBank = 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -95,7 +98,7 @@ void CartridgeF0::incbank()
if(myBankLocked) return;
// Remember what bank we're in
myCurrentBank ++;
myCurrentBank++;
myCurrentBank &= 0x0F;
uInt16 offset = myCurrentBank << 12;
uInt16 shift = mySystem->pageShift();

View File

@ -28,6 +28,9 @@ CartridgeF4::CartridgeF4(const uInt8* image)
{
// Copy the ROM image into my buffer
memcpy(myImage, image, 32768);
// Remember startup bank
myStartBank = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -38,8 +41,8 @@ CartridgeF4::~CartridgeF4()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF4::reset()
{
// Upon reset we switch to bank 0
bank(0);
// Upon reset we switch to the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -62,8 +65,8 @@ void CartridgeF4::install(System& system)
mySystem->setPageAccess(i >> shift, access);
}
// Install pages for bank 0
bank(0);
// Install pages for the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -30,6 +30,9 @@ CartridgeF4SC::CartridgeF4SC(const uInt8* image)
// This cart contains 128 bytes extended RAM @ 0x1000
registerRamArea(0x1000, 128, 0x80, 0x00);
// Remember startup bank
myStartBank = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -44,8 +47,8 @@ void CartridgeF4SC::reset()
for(uInt32 i = 0; i < 128; ++i)
myRAM[i] = mySystem->randGenerator().next();
// Upon reset we switch to bank 0
bank(0);
// Upon reset we switch to the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -86,8 +89,8 @@ void CartridgeF4SC::install(System& system)
mySystem->setPageAccess(k >> shift, access);
}
// Install pages for bank 0
bank(0);
// Install pages for the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -27,6 +27,9 @@ CartridgeF6::CartridgeF6(const uInt8* image)
{
// Copy the ROM image into my buffer
memcpy(myImage, image, 16384);
// Remember startup bank
myStartBank = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -37,8 +40,8 @@ CartridgeF6::~CartridgeF6()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF6::reset()
{
// Upon reset we switch to bank 0
bank(0);
// Upon reset we switch to the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -61,8 +64,8 @@ void CartridgeF6::install(System& system)
mySystem->setPageAccess(i >> shift, access);
}
// Upon install we'll setup bank 0
bank(0);
// Upon install we'll setup the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -30,6 +30,9 @@ CartridgeF6SC::CartridgeF6SC(const uInt8* image)
// This cart contains 128 bytes extended RAM @ 0x1000
registerRamArea(0x1000, 128, 0x80, 0x00);
// Remember startup bank
myStartBank = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -44,8 +47,8 @@ void CartridgeF6SC::reset()
for(uInt32 i = 0; i < 128; ++i)
myRAM[i] = mySystem->randGenerator().next();
// Upon reset we switch to bank 0
bank(0);
// Upon reset we switch to the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -86,8 +89,8 @@ void CartridgeF6SC::install(System& system)
mySystem->setPageAccess(k >> shift, access);
}
// Install pages for bank 0
bank(0);
// Install pages for the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -30,7 +30,7 @@ CartridgeF8::CartridgeF8(const uInt8* image, bool startlow)
// Normally bank 1 is the reset bank, unless we're dealing with ROMs
// that have been incorrectly created with banks in the opposite order
myResetBank = startlow ? 0 : 1;
myStartBank = startlow ? 0 : 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -42,7 +42,7 @@ CartridgeF8::~CartridgeF8()
void CartridgeF8::reset()
{
// Upon reset we switch to the reset bank
bank(myResetBank);
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -65,8 +65,8 @@ void CartridgeF8::install(System& system)
mySystem->setPageAccess(i >> shift, access);
}
// Install pages for bank 1
bank(1);
// Install pages for the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -140,9 +140,6 @@ class CartridgeF8 : public Cartridge
// Indicates which bank is currently active
uInt16 myCurrentBank;
// Indicates the bank to use when resetting
uInt16 myResetBank;
// The 8K ROM image of the cartridge
uInt8 myImage[8192];
};

View File

@ -30,6 +30,9 @@ CartridgeF8SC::CartridgeF8SC(const uInt8* image)
// This cart contains 128 bytes extended RAM @ 0x1000
registerRamArea(0x1000, 128, 0x80, 0x00);
// Remember startup bank
myStartBank = 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -44,8 +47,8 @@ void CartridgeF8SC::reset()
for(uInt32 i = 0; i < 128; ++i)
myRAM[i] = mySystem->randGenerator().next();
// Upon reset we switch to bank 1
bank(1);
// Upon reset we switch to the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -86,8 +89,8 @@ void CartridgeF8SC::install(System& system)
mySystem->setPageAccess(k >> shift, access);
}
// Install pages for bank 1
bank(1);
// Install pages for the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -30,6 +30,9 @@ CartridgeFA::CartridgeFA(const uInt8* image)
// This cart contains 256 bytes extended RAM @ 0x1000
registerRamArea(0x1000, 256, 0x100, 0x00);
// Remember startup bank
myStartBank = 2;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -44,8 +47,8 @@ void CartridgeFA::reset()
for(uInt32 i = 0; i < 256; ++i)
myRAM[i] = mySystem->randGenerator().next();
// Upon reset we switch to bank 2
bank(2);
// Upon reset we switch to the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -86,8 +89,8 @@ void CartridgeFA::install(System& system)
mySystem->setPageAccess(k >> shift, access);
}
// Install pages for bank 2
bank(2);
// Install pages for the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -22,6 +22,8 @@
#include "System.hxx"
#include "CartFE.hxx"
// TODO - Port to new CartDebug/disassembler scheme
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeFE::CartridgeFE(const uInt8* image)
{

View File

@ -25,6 +25,7 @@
// TODO - much more testing of this scheme is required
// No test ROMs exist as of 2009-11-08, so we can't be sure how
// accurate the emulation is
// Port to new CartDebug/disassembler scheme
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeMC::CartridgeMC(const uInt8* image, uInt32 size)

View File

@ -24,14 +24,16 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeSB::CartridgeSB(const uInt8* image, uInt32 size)
: mySize(size),
myLastBank((mySize >> 12) - 1)
: mySize(size)
{
// Allocate array for the ROM image
myImage = new uInt8[mySize];
// Copy the ROM image into my buffer
memcpy(myImage, image, mySize);
// Remember startup bank
myStartBank = (mySize >> 12) - 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -43,8 +45,8 @@ CartridgeSB::~CartridgeSB()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeSB::reset()
{
// Upon reset we switch to the last bank
bank(myLastBank);
// Upon reset we switch to the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -79,7 +81,7 @@ void CartridgeSB::install(System& system)
}
// Install pages for startup bank
bank(myLastBank);
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -89,7 +91,7 @@ uInt8 CartridgeSB::peek(uInt16 address)
// Switch banks if necessary
if ((address & 0x1800) == 0x0800)
bank(address & myLastBank);
bank(address & myStartBank);
if(!(address & 0x1000))
{
@ -109,7 +111,7 @@ void CartridgeSB::poke(uInt16 address, uInt8 value)
// Switch banks if necessary
if((address & 0x1800) == 0x0800)
bank(address & myLastBank);
bank(address & myStartBank);
if(!(address & 0x1000))
{

View File

@ -141,9 +141,6 @@ class CartridgeSB : public Cartridge
// Indicates which bank is currently active
uInt16 myCurrentBank;
// Indicates the last bank
uInt16 myLastBank;
// Previous Device's page access
System::PageAccess myHotSpotPageAccess[8];
};

View File

@ -27,6 +27,9 @@ CartridgeUA::CartridgeUA(const uInt8* image)
{
// Copy the ROM image into my buffer
memcpy(myImage, image, 8192);
// Remember startup bank
myStartBank = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -37,8 +40,8 @@ CartridgeUA::~CartridgeUA()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeUA::reset()
{
// Upon reset we switch to bank 0
bank(0);
// Upon reset we switch to the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -63,8 +66,8 @@ void CartridgeUA::install(System& system)
mySystem->setPageAccess(0x0220 >> shift, access);
mySystem->setPageAccess(0x0240 >> shift, access);
// Install pages for bank 0
bank(0);
// Install pages for the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -29,6 +29,9 @@ CartridgeX07::CartridgeX07(const uInt8* image)
{
// Copy the ROM image into my buffer
memcpy(myImage, image, 65536);
// Remember startup bank
myStartBank = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -39,8 +42,8 @@ CartridgeX07::~CartridgeX07()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeX07::reset()
{
// Upon reset we switch to bank 0
bank(0);
// Upon reset we switch to the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -65,8 +68,8 @@ void CartridgeX07::install(System& system)
mySystem->setPageAccess(i >> shift, access);
}
// Install pages for bank 0
bank(0);
// Install pages for the startup bank
bank(myStartBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -150,6 +150,7 @@ void EventHandler::initialize()
setActionMappings(kMenuMode);
myGrabMouseFlag = myOSystem->settings().getBool("grabmouse");
myUseCtrlKeyFlag = myOSystem->settings().getBool("ctrlcombo");
Joystick::setDeadZone(myOSystem->settings().getInt("joydeadzone"));
Paddles::setDigitalSpeed(myOSystem->settings().getInt("pspeed"));
@ -480,7 +481,7 @@ void EventHandler::poll(uInt64 time)
else
handled = false;
}
else if(kbdControl(mod) && state)
else if(kbdControl(mod) && state && myUseCtrlKeyFlag)
{
// These keys work in all states
if(key == SDLK_q)

View File

@ -483,6 +483,12 @@ class EventHandler
// Indicates whether or not we're in frying mode
bool myFryingFlag;
// Indicates whether the key-combos tied to the Control key are
// being used or not (since Ctrl by default is the fire button,
// pressing it with a movement key could inadvertantly activate
// a Ctrl combo when it isn't wanted)
bool myUseCtrlKeyFlag;
// Indicates which paddle the mouse currently emulates
Int8 myPaddleMode;

View File

@ -85,6 +85,7 @@ Settings::Settings(OSystem* osystem)
setInternal("pspeed", "6");
setInternal("sa1", "left");
setInternal("sa2", "right");
setInternal("ctrlcombo", "true");
// Snapshot options
setInternal("ssdir", "");
@ -361,6 +362,7 @@ void Settings::usage()
<< " -pspeed <number> Speed of digital emulated paddle movement (1-15)\n"
<< " -sa1 <left|right> Stelladaptor 1 emulates specified joystick port\n"
<< " -sa2 <left|right> Stelladaptor 2 emulates specified joystick port\n"
<< " -ctrlcombo <1|0> Use key combos involving the Control key (Control-Q for quit may be disabled!)\n"
<< " -autoslot <1|0> Automatically switch to next save slot when state saving\n"
<< " -md5instate <1|0> ROM MD5 information is saved in a state file, tying the state file to the ROM\n"
<< " -audiofirst <1|0> Initial audio before video (required for some ATI video cards)\n"