From cfe52adc62e03b61040afd52df1ce0958648f334 Mon Sep 17 00:00:00 2001 From: stephena Date: Wed, 2 Apr 2008 01:54:31 +0000 Subject: [PATCH] Fixed bug in ROM disassembler in the debugger. Apparently, mixing C strings and C++ strings causes issues in the Visual Studio compiler, but not for Linux. The ROM listing no longer shows squares (which represented null/out of bounds pointers to strings. Updated Visual Studio files with latest AtariVox class. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1455 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/debugger/CpuDebug.cxx | 129 ++++++++++++++++------------- stella/src/debugger/CpuDebug.hxx | 4 +- stella/src/debugger/Debugger.cxx | 45 +++++----- stella/src/debugger/EquateList.cxx | 16 ++-- stella/src/debugger/EquateList.hxx | 6 +- stella/src/emucore/AtariVox.cxx | 4 +- stella/src/win32/Stella.vcproj | 9 ++ stella/src/win32/stella.iss | 111 ++++++++++++++++--------- 8 files changed, 190 insertions(+), 134 deletions(-) diff --git a/stella/src/debugger/CpuDebug.cxx b/stella/src/debugger/CpuDebug.cxx index 9b14054d4..2eb10455b 100644 --- a/stella/src/debugger/CpuDebug.cxx +++ b/stella/src/debugger/CpuDebug.cxx @@ -13,9 +13,11 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CpuDebug.cxx,v 1.9 2008-02-06 13:45:19 stephena Exp $ +// $Id: CpuDebug.cxx,v 1.10 2008-04-02 01:54:31 stephena Exp $ //============================================================================ +#include + #include "Array.hxx" #include "EquateList.hxx" #include "M6502.hxx" @@ -72,91 +74,106 @@ void CpuDebug::saveOldState() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int CpuDebug::disassemble(int address, char* buffer, EquateList* equateList) +int CpuDebug::disassemble(int address, string& result, EquateList* equateList) { - // equateList->dumpAll(); + ostringstream buf; + int count = 0; int opcode = mySystem->peek(address); switch(M6502::ourAddressingModeTable[opcode]) { case M6502::Absolute: - sprintf(buffer, "%s %s ; %d", M6502::ourInstructionMnemonicTable[opcode], - equateList->getFormatted(dpeek(mySystem, address + 1), 4), - M6502::ourInstructionProcessorCycleTable[opcode]); - return 3; + buf << M6502::ourInstructionMnemonicTable[opcode] << " " + << equateList->getFormatted(dpeek(mySystem, address + 1), 4) << " ; " + << M6502::ourInstructionProcessorCycleTable[opcode]; + count = 3; + break; case M6502::AbsoluteX: - sprintf(buffer, "%s %s,x ; %d", M6502::ourInstructionMnemonicTable[opcode], - equateList->getFormatted(dpeek(mySystem, address + 1), 4), - M6502::ourInstructionProcessorCycleTable[opcode]); - return 3; + buf << M6502::ourInstructionMnemonicTable[opcode] << " " + << equateList->getFormatted(dpeek(mySystem, address + 1), 4) << ",x ; " + << M6502::ourInstructionProcessorCycleTable[opcode]; + count = 3; + break; case M6502::AbsoluteY: - sprintf(buffer, "%s %s,y ; %d", M6502::ourInstructionMnemonicTable[opcode], - equateList->getFormatted(dpeek(mySystem, address + 1), 4), - M6502::ourInstructionProcessorCycleTable[opcode]); - return 3; + buf << M6502::ourInstructionMnemonicTable[opcode] << " " + << equateList->getFormatted(dpeek(mySystem, address + 1), 4) << ",y ; " + << M6502::ourInstructionProcessorCycleTable[opcode]; + count = 3; + break; case M6502::Immediate: - sprintf(buffer, "%s #$%02X ; %d", M6502::ourInstructionMnemonicTable[opcode], - mySystem->peek(address + 1), - M6502::ourInstructionProcessorCycleTable[opcode]); - return 2; + buf << M6502::ourInstructionMnemonicTable[opcode] << " #$" + << hex << setw(2) << setfill('0') << (int) mySystem->peek(address + 1) << " ; " + << dec << M6502::ourInstructionProcessorCycleTable[opcode]; + count = 2; + break; case M6502::Implied: - sprintf(buffer, "%s ; %d", M6502::ourInstructionMnemonicTable[opcode], - M6502::ourInstructionProcessorCycleTable[opcode]); - return 1; + buf << M6502::ourInstructionMnemonicTable[opcode] << " ; " + << M6502::ourInstructionProcessorCycleTable[opcode]; + count = 1; + break; case M6502::Indirect: - sprintf(buffer, "%s (%s) ; %d", M6502::ourInstructionMnemonicTable[opcode], - equateList->getFormatted(dpeek(mySystem, address + 1), 4), - M6502::ourInstructionProcessorCycleTable[opcode]); - return 3; + buf << M6502::ourInstructionMnemonicTable[opcode] << " (" + << equateList->getFormatted(dpeek(mySystem, address + 1), 4) << ") ; " + << M6502::ourInstructionProcessorCycleTable[opcode]; + count = 3; + break; case M6502::IndirectX: - sprintf(buffer, "%s (%s,x) ; %d", - M6502::ourInstructionMnemonicTable[opcode], - equateList->getFormatted(mySystem->peek(address + 1), 2), - M6502::ourInstructionProcessorCycleTable[opcode]); - return 2; + buf << M6502::ourInstructionMnemonicTable[opcode] << " (" + << equateList->getFormatted(mySystem->peek(address + 1), 2) << ",x) ; " + << M6502::ourInstructionProcessorCycleTable[opcode]; + count = 2; + break; case M6502::IndirectY: - sprintf(buffer, "%s (%s),y ; %d", - M6502::ourInstructionMnemonicTable[opcode], - equateList->getFormatted(mySystem->peek(address + 1), 2), - M6502::ourInstructionProcessorCycleTable[opcode]); - return 2; + buf << M6502::ourInstructionMnemonicTable[opcode] << " (" + << equateList->getFormatted(mySystem->peek(address + 1), 2) << "),y ; " + << M6502::ourInstructionProcessorCycleTable[opcode]; + count = 2; + break; case M6502::Relative: - sprintf(buffer, "%s %s ; %d", M6502::ourInstructionMnemonicTable[opcode], - equateList->getFormatted(address + 2 + ((Int16)(Int8)mySystem->peek(address + 1)), 4), - M6502::ourInstructionProcessorCycleTable[opcode]); - return 2; + buf << M6502::ourInstructionMnemonicTable[opcode] << " " + << equateList->getFormatted(address + 2 + ((Int16)(Int8)mySystem->peek(address + 1)), 4) + << " ; " << M6502::ourInstructionProcessorCycleTable[opcode]; + count = 2; + break; case M6502::Zero: - sprintf(buffer, "%s %s ; %d", M6502::ourInstructionMnemonicTable[opcode], - equateList->getFormatted(mySystem->peek(address + 1), 2), - M6502::ourInstructionProcessorCycleTable[opcode]); - return 2; + buf << M6502::ourInstructionMnemonicTable[opcode] << " " + << equateList->getFormatted(mySystem->peek(address + 1), 2) << " ; " + << M6502::ourInstructionProcessorCycleTable[opcode]; + count = 2; + break; case M6502::ZeroX: - sprintf(buffer, "%s %s,x ; %d", M6502::ourInstructionMnemonicTable[opcode], - equateList->getFormatted(mySystem->peek(address + 1), 2), - M6502::ourInstructionProcessorCycleTable[opcode]); - return 2; + buf << M6502::ourInstructionMnemonicTable[opcode] << " " + << equateList->getFormatted(mySystem->peek(address + 1), 2) << ",x ; " + << M6502::ourInstructionProcessorCycleTable[opcode]; + count = 2; + break; case M6502::ZeroY: - sprintf(buffer, "%s %s,y ; %d", M6502::ourInstructionMnemonicTable[opcode], - equateList->getFormatted(mySystem->peek(address + 1), 2), - M6502::ourInstructionProcessorCycleTable[opcode]); - return 2; + buf << M6502::ourInstructionMnemonicTable[opcode] << " " + << equateList->getFormatted(mySystem->peek(address + 1), 2) << ",y ; " + << M6502::ourInstructionProcessorCycleTable[opcode]; + count = 2; + break; default: - sprintf(buffer, "dc $%02X ; %d", opcode, - M6502::ourInstructionProcessorCycleTable[opcode]); - return 1; - } + buf << "dc $" << hex << setw(2) << setfill('0') << (int) opcode << " ; " + << dec << M6502::ourInstructionProcessorCycleTable[opcode]; + count = 1; + break; + } + + result = buf.str(); + return count; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/debugger/CpuDebug.hxx b/stella/src/debugger/CpuDebug.hxx index 538c25bf7..bc672b1f7 100644 --- a/stella/src/debugger/CpuDebug.hxx +++ b/stella/src/debugger/CpuDebug.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CpuDebug.hxx,v 1.11 2008-02-06 13:45:19 stephena Exp $ +// $Id: CpuDebug.hxx,v 1.12 2008-04-02 01:54:31 stephena Exp $ //============================================================================ #ifndef CPU_DEBUG_HXX @@ -51,7 +51,7 @@ class CpuDebug : public DebuggerSystem // I know, we ain't supposed to do this... M6502 &m6502() { return mySystem->m6502(); } - int disassemble(int address, char* buffer, EquateList* equateList); + int disassemble(int address, string& result, EquateList* equateList); int dPeek(int address); int getBank(); diff --git a/stella/src/debugger/Debugger.cxx b/stella/src/debugger/Debugger.cxx index c7a31b057..41f42efda 100644 --- a/stella/src/debugger/Debugger.cxx +++ b/stella/src/debugger/Debugger.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Debugger.cxx,v 1.121 2008-03-28 23:29:13 stephena Exp $ +// $Id: Debugger.cxx,v 1.122 2008-04-02 01:54:31 stephena Exp $ //============================================================================ #include "bspf.hxx" @@ -776,31 +776,24 @@ int Debugger::cycles() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const string& Debugger::disassemble(int start, int lines) { - char buf[255], bbuf[255]; static string result; + ostringstream buffer; + string cpubuf; - result = ""; do { - const char *label = myEquateList->getFormatted(start, 4); + buffer << myEquateList->getFormatted(start, 4) << ": "; - result += label; - result += ": "; + int count = myCpuDebug->disassemble(start, cpubuf, myEquateList); + for(int i = 0; i < count; i++) + buffer << hex << setw(2) << setfill('0') << peek(start++) << dec; - int count = myCpuDebug->disassemble(start, buf, myEquateList); + if(count < 3) buffer << " "; + if(count < 2) buffer << " "; - for(int i=0; i 0 && start <= 0xffff); + result = buffer.str(); return result; } @@ -809,25 +802,25 @@ void Debugger::disassemble(IntArray& addr, StringList& addrLabel, StringList& bytes, StringList& data, int start, int lines) { - char buf[255], bbuf[255]; - string tmp; + string cpubuf, tmp; + char buf[255]; do { - tmp = myEquateList->getFormatted(start, 4); - addrLabel.push_back(tmp + ":"); + addrLabel.push_back(myEquateList->getFormatted(start, 4) + ":"); addr.push_back(start); - int count = myCpuDebug->disassemble(start, buf, myEquateList); + cpubuf = ""; + int count = myCpuDebug->disassemble(start, cpubuf, myEquateList); tmp = ""; for(int i=0; i 0 && start <= 0xffff); } diff --git a/stella/src/debugger/EquateList.cxx b/stella/src/debugger/EquateList.cxx index 8b3d0b47f..208270e0d 100644 --- a/stella/src/debugger/EquateList.cxx +++ b/stella/src/debugger/EquateList.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EquateList.cxx,v 1.27 2008-02-24 16:51:52 stephena Exp $ +// $Id: EquateList.cxx,v 1.28 2008-04-02 01:54:31 stephena Exp $ //============================================================================ #include @@ -252,7 +252,7 @@ const string& EquateList::getLabel(int addr, int flags) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // DEPRECATED -const char *EquateList::getFormatted(int addr, int places) +string EquateList::getFormatted(int addr, int places) { return getFormatted(addr, places, EQF_ANY); } @@ -260,15 +260,15 @@ const char *EquateList::getFormatted(int addr, int places) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // returns either the label, or a formatted hex string // if no label found. -const char *EquateList::getFormatted(int addr, int places, int flags) +string EquateList::getFormatted(int addr, int places, int flags) { - static char fmt[10], buf[255]; - string res = getLabel(addr, flags); - if(res != "") - return res.c_str(); + char fmt[10], buf[255]; + const string& label = getLabel(addr, flags); + + if(label != "") + return label; sprintf(fmt, "$%%0%dx", places); - //cerr << addr << ", " << fmt << ", " << places << endl; sprintf(buf, fmt, addr); return buf; diff --git a/stella/src/debugger/EquateList.hxx b/stella/src/debugger/EquateList.hxx index 48eb69352..d955cb27a 100644 --- a/stella/src/debugger/EquateList.hxx +++ b/stella/src/debugger/EquateList.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EquateList.hxx,v 1.17 2008-02-24 16:51:52 stephena Exp $ +// $Id: EquateList.hxx,v 1.18 2008-04-02 01:54:31 stephena Exp $ //============================================================================ #ifndef EQUATELIST_HXX @@ -33,8 +33,8 @@ class EquateList const string& getLabel(int addr); const string& getLabel(int addr, int flags); - const char *getFormatted(int addr, int places); - const char *getFormatted(int addr, int places, int flags); + string getFormatted(int addr, int places); + string getFormatted(int addr, int places, int flags); int getAddress(const string& label); int getAddress(const string& label, const int flags); void addEquate(const string& label, int address); diff --git a/stella/src/emucore/AtariVox.cxx b/stella/src/emucore/AtariVox.cxx index aa4727104..8f62ce1e9 100644 --- a/stella/src/emucore/AtariVox.cxx +++ b/stella/src/emucore/AtariVox.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: AtariVox.cxx,v 1.8 2008-03-31 00:59:30 stephena Exp $ +// $Id: AtariVox.cxx,v 1.9 2008-04-02 01:54:31 stephena Exp $ //============================================================================ #ifdef SPEAKJET_EMULATION @@ -113,7 +113,7 @@ void AtariVox::update() void AtariVox::clockDataIn(bool value) { // bool oldValue = myPinState & 0x01; - myPinState = (myPinState & 0xfe) | value; + myPinState = (myPinState & 0xfe) | (int)value; uInt32 cycle = mySystem->cycles(); if(DEBUG_ATARIVOX) diff --git a/stella/src/win32/Stella.vcproj b/stella/src/win32/Stella.vcproj index 41f9b62f1..55c25f87a 100755 --- a/stella/src/win32/Stella.vcproj +++ b/stella/src/win32/Stella.vcproj @@ -208,6 +208,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/MP" OmitFramePointers="true" + WholeProgramOptimization="false" AdditionalIncludeDirectories="..\yacc;..\emucore\m6502\src\bspf\src;..\emucore\m6502\src;..\emucore;..\common;..\gui;..\debugger\gui;..\debugger;..\win32;..\cheat" PreprocessorDefinitions="BSPF_WIN32;WIN32;ZLIB_WINAPI;NDEBUG;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;DISPLAY_OPENGL;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT" RuntimeLibrary="0" @@ -400,6 +401,10 @@ + + @@ -966,6 +971,10 @@ + + diff --git a/stella/src/win32/stella.iss b/stella/src/win32/stella.iss index dd1de62b2..cba708267 100755 --- a/stella/src/win32/stella.iss +++ b/stella/src/win32/stella.iss @@ -1,37 +1,74 @@ -; Script generated by the Inno Setup Script Wizard. -; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! - -[Setup] -AppName=Stella -AppVerName=Stella 2.5 -AppPublisher=Bradford W. Mott and the Stella team -AppPublisherURL=http://stella.sourceforge.net -AppSupportURL=http://stella.sourceforge.net -AppUpdatesURL=http://stella.sourceforge.net -DefaultDirName={pf}\Stella -DefaultGroupName=Stella -OutputBaseFilename=stella-2.5-win32 -Compression=lzma -SolidCompression=yes - -[Languages] -Name: "eng"; MessagesFile: "compiler:Default.isl" - -[Tasks] -Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked - -[Files] -Source: "H:\windows\src\stella\stella-2.5\stella.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "H:\windows\src\stella\stella-2.5\zlib1.dll"; DestDir: "{app}"; Flags: ignoreversion -Source: "H:\windows\src\stella\stella-2.5\SDL.dll"; DestDir: "{app}"; Flags: ignoreversion -Source: "H:\windows\src\stella\stella-2.5\docs\*"; DestDir: "{app}\docs"; Flags: ignoreversion recursesubdirs createallsubdirs -; NOTE: Don't use "Flags: ignoreversion" on any shared system files - -[Icons] -Name: "{group}\Stella"; Filename: "{app}\stella.exe"; WorkingDir: "{app}" -Name: "{userdesktop}\Stella"; Filename: "{app}\stella.exe"; WorkingDir: "{app}"; Tasks: desktopicon -Name: "{group}\Documentation"; Filename: "{app}\docs\index.html" -Name: "{group}\Uninstall Stella"; Filename: "{uninstallexe}" - -;[Run] -;Filename: "{app}\stella.exe"; Description: "{cm:LaunchProgram,Stella}"; Flags: nowait postinstall skipifsilent +; Script generated by the Inno Setup Script Wizard. + +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + + + +[Setup] + +AppName=Stella + +AppVerName=Stella 2.5 + +AppPublisher=Bradford W. Mott and the Stella team + +AppPublisherURL=http://stella.sourceforge.net + +AppSupportURL=http://stella.sourceforge.net + +AppUpdatesURL=http://stella.sourceforge.net + +DefaultDirName={pf}\Stella + +DefaultGroupName=Stella + +OutputBaseFilename=stella-2.5-win32 + +Compression=lzma + +SolidCompression=yes + + + +[Languages] + +Name: "eng"; MessagesFile: "compiler:Default.isl" + + + +[Tasks] + +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + + + +[Files] + +Source: "C:\Users\stephena\src\stella\stella-2.5\Stella.exe"; DestDir: "{app}"; Flags: ignoreversion + +Source: "C:\Users\stephena\src\stella\stella-2.5\zlibwapi.dll"; DestDir: "{app}"; Flags: ignoreversion + +Source: "C:\Users\stephena\src\stella\stella-2.5\SDL.dll"; DestDir: "{app}"; Flags: ignoreversion + +Source: "C:\Users\stephena\src\stella\stella-2.5\docs\*"; DestDir: "{app}\docs"; Flags: ignoreversion recursesubdirs createallsubdirs + +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + + + +[Icons] + +Name: "{group}\Stella"; Filename: "{app}\stella.exe"; WorkingDir: "{app}" + +Name: "{userdesktop}\Stella"; Filename: "{app}\stella.exe"; WorkingDir: "{app}"; Tasks: desktopicon + +Name: "{group}\Documentation"; Filename: "{app}\docs\index.html" + +Name: "{group}\Uninstall Stella"; Filename: "{uninstallexe}" + + + +;[Run] + +;Filename: "{app}\stella.exe"; Description: "{cm:LaunchProgram,Stella}"; Flags: nowait postinstall skipifsilent +