Consolidated the code for converting integers to strings in various

bases into a Common::Base class.  Previously, this functionality was
spread across several classes, and used different approaches to formatting.
While the code still mixes C++ streams and C-style sprintf's, at least
it will now be easier to modify it all in one place.

Related to the above, added ability to use upper or lower case
characters for HEX output in the debugger.  This is toggled by the
new debugger prompt command 'uhex', which is also tied to a new
commandline argument, 'dbg.uhex'.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2770 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2013-07-27 22:28:41 +00:00
parent 33bcec92be
commit 95fe213f3a
56 changed files with 676 additions and 513 deletions

View File

@ -35,7 +35,11 @@
- Added 'cpurandom' commandline argument, and associated UI item
to the 'I/O' tab. This works similar to 'ramrandom', and
randomizes the contents on the CPU registers on ROM startup.
randomizes the contents of the CPU registers on ROM startup.
- Added 'uhex' debugger prompt command, which toggles all
hexadecimal display between upper/lower case. This setting is
also saved in the settings file as argument 'dbg.uhex'.
* For the Linux/UNIX port:
- Fixed bug whereby a maximize button was always present in the

115
src/common/Base.cxx Normal file
View File

@ -0,0 +1,115 @@
//============================================================================
//
// 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-2013 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 "Base.hxx"
namespace Common {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Base::setHexUppercase(bool enable)
{
if(enable)
{
myHexflags |= std::ios_base::uppercase;
myFmt = Base::myUpperFmt;
}
else
{
myHexflags &= ~std::ios_base::uppercase;
myFmt = Base::myLowerFmt;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Base::toString(int value, Common::Base::Format outputBase)
{
static char vToS_buf[32];
if(outputBase == Base::F_DEFAULT)
outputBase = myDefaultBase;
switch(outputBase)
{
case Base::F_2: // base 2: 8 or 16 bits (depending on value)
case Base::F_2_8: // base 2: 1 byte (8 bits) wide
case Base::F_2_16: // base 2: 2 bytes (16 bits) wide
{
int places = (outputBase == Base::F_2_8 ||
(outputBase == Base::F_2 && value < 0x100)) ? 8 : 16;
vToS_buf[places] = '\0';
int bit = 1;
while(--places >= 0) {
if(value & bit) vToS_buf[places] = '1';
else vToS_buf[places] = '0';
bit <<= 1;
}
break;
}
case Base::F_10: // base 10: 3 or 5 bytes (depending on value)
if(value < 0x100)
BSPF_snprintf(vToS_buf, 4, "%3d", value);
else
BSPF_snprintf(vToS_buf, 6, "%5d", value);
break;
case Base::F_16_1: // base 16: 1 byte wide
BSPF_snprintf(vToS_buf, 2, myFmt[0], value);
break;
case Base::F_16_2: // base 16: 2 bytes wide
BSPF_snprintf(vToS_buf, 3, myFmt[1], value);
break;
case Base::F_16_4: // base 16: 4 bytes wide
BSPF_snprintf(vToS_buf, 5, myFmt[2], value);
break;
case Base::F_16_8: // base 16: 8 bytes wide
BSPF_snprintf(vToS_buf, 9, myFmt[3], value);
break;
case Base::F_16: // base 16: 2, 4, 8 bytes (depending on value)
default:
if(value < 0x100)
BSPF_snprintf(vToS_buf, 3, myFmt[1], value);
else if(value < 0x10000)
BSPF_snprintf(vToS_buf, 5, myFmt[2], value);
else
BSPF_snprintf(vToS_buf, 9, myFmt[3], value);
break;
}
return string(vToS_buf);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Base::Format Base::myDefaultBase = Base::F_16;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
std::ios_base::fmtflags Base::myHexflags =
std::ios_base::hex | std::ios_base::left;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* Base::myLowerFmt[4] = {
"%1x", "%02x", "%04x", "%08x"
};
const char* Base::myUpperFmt[4] = {
"%1X", "%02X", "%04X", "%08X"
};
const char** Base::myFmt = Base::myLowerFmt;
} // Namespace Common

102
src/common/Base.hxx Normal file
View File

@ -0,0 +1,102 @@
//============================================================================
//
// 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-2013 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$
//============================================================================
#ifndef BASE_HXX
#define BASE_HXX
#include <iostream>
#include <iomanip>
#include "bspf.hxx"
namespace Common {
/**
This class implements several functions for converting integer data
into strings in multiple bases, with different formats (# of characters,
upper/lower-case, etc).
@author Stephen Anthony
*/
class Base
{
public:
// The base to use for conversion from integers to strings
// Note that the actual number of places will be determined by
// the magnitude of the value itself in the general case
enum Format {
F_16, // base 16: 2, 4, 8 bytes (depending on value)
F_16_1, // base 16: 1 byte wide
F_16_2, // base 16: 2 bytes wide
F_16_4, // base 16: 4 bytes wide
F_16_8, // base 16: 8 bytes wide
F_10, // base 10: 3 or 5 bytes (depending on value)
F_2, // base 2: 8 or 16 bits (depending on value)
F_2_8, // base 2: 1 byte (8 bits) wide
F_2_16, // base 2: 2 bytes (16 bits) wide
F_DEFAULT
};
public:
/** Get/set the number base when parsing numeric values */
static void setFormat(Base::Format base) { myDefaultBase = base; }
static Base::Format format() { return myDefaultBase; }
/** Get/set HEX output to be upper/lower case */
static void setHexUppercase(bool enable);
static bool hexUppercase() { return myHexflags & std::ios_base::uppercase; }
/** Output HEX digits in 1/2/4 byte format */
static inline std::ostream& HEX2(std::ostream& os) {
os.flags(myHexflags);
return os << std::setw(2) << std::setfill('0');
}
static inline std::ostream& HEX4(std::ostream& os) {
os.flags(myHexflags);
return os << std::setw(4) << std::setfill('0');
}
static inline std::ostream& HEX8(std::ostream& os) {
os.flags(myHexflags);
return os << std::setw(8) << std::setfill('0');
}
/** Convert integer to a string in the given base format */
static string toString(int value,
Common::Base::Format outputBase = Common::Base::F_DEFAULT);
private: // Make sure this class is never instantiated
Base() { }
private:
// Default format to use when none is specified
static Format myDefaultBase;
// Upper or lower case for HEX digits
static std::ios_base::fmtflags myHexflags;
// Format specifiers to use for sprintf (eventually we may convert
// to C++ streams
static const char* myLowerFmt[4];
static const char* myUpperFmt[4];
static const char** myFmt;
};
} // Namespace Common
#endif

View File

@ -70,6 +70,7 @@
#include <sstream>
#include <cstring>
#include <cctype>
#include <cstdio>
using namespace std;
// Defines to help with path handling
@ -112,11 +113,6 @@ using namespace std;
#define BSPF_ARCH "NOARCH"
#endif
// Used for stringstreams
#define HEX8 uppercase << hex << setw(8) << setfill('0')
#define HEX4 uppercase << hex << setw(4) << setfill('0')
#define HEX2 uppercase << hex << setw(2) << setfill('0')
// Some convenience functions
template<typename T> inline void BSPF_swap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
template<typename T> inline T BSPF_abs (T x) { return (x>=0) ? x : -x; }

View File

@ -2,6 +2,7 @@ MODULE := src/common
MODULE_OBJS := \
src/common/mainSDL.o \
src/common/Base.o \
src/common/SoundSDL.o \
src/common/FrameBufferSoft.o \
src/common/FrameBufferGL.o \

View File

@ -31,6 +31,7 @@
#include "Version.hxx"
#include "CartDebug.hxx"
#include "CartDebugWidget.hxx"
using namespace Common;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartDebug::CartDebug(Debugger& dbg, Console& console, const OSystem& osystem)
@ -97,7 +98,7 @@ CartDebug::CartDebug(Debugger& dbg, Console& console, const OSystem& osystem)
// Add settings for Distella
DiStella::settings.gfx_format =
myOSystem.settings().getInt("dis.gfxformat") == 16 ? kBASE_16 : kBASE_2;
myOSystem.settings().getInt("dis.gfxformat") == 16 ? Base::F_16 : Base::F_2;
DiStella::settings.resolve_code =
myOSystem.settings().getBool("dis.resolve");
DiStella::settings.show_addresses =
@ -201,18 +202,18 @@ string CartDebug::toString()
ostringstream buf;
uInt32 bytesPerLine;
switch(myDebugger.parser().base())
switch(Base::format())
{
case kBASE_16:
case kBASE_10:
case Base::F_16:
case Base::F_10:
bytesPerLine = 0x10;
break;
case kBASE_2:
case Base::F_2:
bytesPerLine = 0x04;
break;
case kBASE_DEFAULT:
case Base::F_DEFAULT:
default:
return DebuggerParser::red("invalid base, this is a BUG");
}
@ -236,7 +237,7 @@ string CartDebug::toString()
bytesSoFar = 0;
}
curraddr = state.rport[i];
buf << HEX2 << (curraddr & 0x00ff) << ": ";
buf << Base::HEX2 << (curraddr & 0x00ff) << ": ";
for(uInt8 j = 0; j < bytesPerLine; ++j)
{
@ -611,10 +612,10 @@ bool CartDebug::getLabel(ostream& buf, uInt16 addr, bool isRead, int places) con
{
buf << ourTIAMnemonicR[a];
if(offset > 0)
buf << "|$" << HEX2 << offset;
buf << "|$" << Base::HEX2 << offset;
}
else
buf << "$" << HEX2 << addr;
buf << "$" << Base::HEX2 << addr;
}
else
{
@ -623,10 +624,10 @@ bool CartDebug::getLabel(ostream& buf, uInt16 addr, bool isRead, int places) con
{
buf << ourTIAMnemonicW[a];
if(offset > 0)
buf << "|$" << HEX2 << offset;
buf << "|$" << Base::HEX2 << offset;
}
else
buf << "$" << HEX2 << addr;
buf << "$" << Base::HEX2 << addr;
}
return true;
}
@ -640,13 +641,13 @@ bool CartDebug::getLabel(ostream& buf, uInt16 addr, bool isRead, int places) con
{
buf << ourIOMnemonic[a - 0x80];
if(offset > 0)
buf << "|$" << HEX2 << offset;
buf << "|$" << Base::HEX2 << offset;
}
else
buf << "$" << HEX2 << addr;
buf << "$" << Base::HEX2 << addr;
}
else
buf << "$" << HEX2 << addr;
buf << "$" << Base::HEX2 << addr;
return true;
}
@ -668,7 +669,7 @@ bool CartDebug::getLabel(ostream& buf, uInt16 addr, bool isRead, int places) con
else
buf << ourZPMnemonic[a - 0x80];
if(offset > 0)
buf << "|$" << HEX2 << offset;
buf << "|$" << Base::HEX2 << offset;
}
return true;
@ -977,7 +978,7 @@ string CartDebug::saveDisassembly()
myDisLabels, myDisDirectives, myReserved);
buf << " SEG CODE\n"
<< " ORG $" << HEX4 << info.offset << "\n\n";
<< " ORG $" << Base::HEX4 << info.offset << "\n\n";
// Format in 'distella' style
for(uInt32 i = 0; i < disasm.list.size(); ++i)
@ -1008,25 +1009,25 @@ string CartDebug::saveDisassembly()
}
case CartDebug::GFX:
{
buf << ".byte " << (settings.gfx_format == kBASE_2 ? "%" : "$")
buf << ".byte " << (settings.gfx_format == Base::F_2 ? "%" : "$")
<< tag.bytes << " ; |";
for(int i = 12; i < 20; ++i)
buf << ((tag.disasm[i] == '\x1e') ? "#" : " ");
buf << "| $" << HEX4 << tag.address << " (G)\n";
buf << "| $" << Base::HEX4 << tag.address << " (G)\n";
break;
}
case CartDebug::PGFX:
{
buf << ".byte " << (settings.gfx_format == kBASE_2 ? "%" : "$")
buf << ".byte " << (settings.gfx_format == Base::F_2 ? "%" : "$")
<< tag.bytes << " ; |";
for(int i = 12; i < 20; ++i)
buf << ((tag.disasm[i] == '\x1f') ? "*" : " ");
buf << "| $" << HEX4 << tag.address << " (P)\n";
buf << "| $" << Base::HEX4 << tag.address << " (P)\n";
break;
}
case CartDebug::DATA:
{
buf << tag.disasm.substr(0, 9) << " ; $" << HEX4 << tag.address << " (D)\n";
buf << tag.disasm.substr(0, 9) << " ; $" << Base::HEX4 << tag.address << " (D)\n";
break;
}
default:
@ -1068,15 +1069,15 @@ string CartDebug::saveDisassembly()
for(uInt16 addr = 0x00; addr <= 0x0F; ++addr)
if(myReserved.TIARead[addr] && ourTIAMnemonicR[addr])
out << ALIGN(6) << ourTIAMnemonicR[addr] << " = $"
<< HEX2 << right << addr << " ; (R)\n";
<< Base::HEX2 << right << addr << " ; (R)\n";
for(uInt16 addr = 0x00; addr <= 0x3F; ++addr)
if(myReserved.TIAWrite[addr] && ourTIAMnemonicW[addr])
out << ALIGN(6) << ourTIAMnemonicW[addr] << " = $"
<< HEX2 << right << addr << " ; (W)\n";
<< Base::HEX2 << right << addr << " ; (W)\n";
for(uInt16 addr = 0x00; addr <= 0x17; ++addr)
if(myReserved.IOReadWrite[addr] && ourIOMnemonic[addr])
out << ALIGN(6) << ourIOMnemonic[addr] << " = $"
<< HEX4 << right << (addr+0x280) << "\n";
<< Base::HEX4 << right << (addr+0x280) << "\n";
}
addrUsed = false;
@ -1093,7 +1094,7 @@ string CartDebug::saveDisassembly()
myUserLabels.find(addr) == myUserLabels.end())
{
out << ALIGN(6) << ourZPMnemonic[addr-0x80] << " = $"
<< HEX2 << right << (addr) << "\n";
<< Base::HEX2 << right << (addr) << "\n";
}
}
}
@ -1168,7 +1169,7 @@ string CartDebug::listConfig(int bank)
{
buf << "(*) ";
disasmTypeAsString(buf, i->type);
buf << " " << HEX4 << i->start << " " << HEX4 << i->end << endl;
buf << " " << Base::HEX4 << i->start << " " << Base::HEX4 << i->end << endl;
}
}
getBankDirectives(buf, info);
@ -1260,7 +1261,7 @@ CartDebug::AddrType CartDebug::addressType(uInt16 addr) const
void CartDebug::getBankDirectives(ostream& buf, BankInfo& info) const
{
// Start with the offset for this bank
buf << "ORG " << HEX4 << info.offset << endl;
buf << "ORG " << Base::HEX4 << info.offset << endl;
// Now consider each byte
uInt32 prev = info.offset, addr = prev + 1;
@ -1273,7 +1274,7 @@ void CartDebug::getBankDirectives(ostream& buf, BankInfo& info) const
if(currType != prevType)
{
disasmTypeAsString(buf, prevType);
buf << " " << HEX4 << prev << " " << HEX4 << (addr-1) << endl;
buf << " " << Base::HEX4 << prev << " " << Base::HEX4 << (addr-1) << endl;
prev = addr;
prevType = currType;
@ -1284,7 +1285,7 @@ void CartDebug::getBankDirectives(ostream& buf, BankInfo& info) const
if(prev != addr)
{
disasmTypeAsString(buf, prevType);
buf << " " << HEX4 << prev << " " << HEX4 << (addr-1) << endl;
buf << " " << Base::HEX4 << prev << " " << Base::HEX4 << (addr-1) << endl;
}
}
@ -1301,11 +1302,11 @@ void CartDebug::addressTypeAsString(ostream& buf, uInt16 addr) const
debugger = myDebugger.getAccessFlags(addr) & 0xFC,
label = myDisLabels[addr & 0xFFF];
buf << endl << "directive: " << myDebugger.valueToString(directive, kBASE_2_8) << " ";
buf << endl << "directive: " << Base::toString(directive, Base::F_2_8) << " ";
disasmTypeAsString(buf, directive);
buf << endl << "emulation: " << myDebugger.valueToString(debugger, kBASE_2_8) << " ";
buf << endl << "emulation: " << Base::toString(debugger, Base::F_2_8) << " ";
disasmTypeAsString(buf, debugger);
buf << endl << "tentative: " << myDebugger.valueToString(label, kBASE_2_8) << " ";
buf << endl << "tentative: " << Base::toString(label, Base::F_2_8) << " ";
disasmTypeAsString(buf, label);
buf << endl;
}

View File

@ -127,7 +127,7 @@ Debugger::Debugger(OSystem& osystem, Console& console)
myRewindManager(NULL)
{
// Init parser
myParser = new DebuggerParser(*this);
myParser = new DebuggerParser(*this, osystem.settings());
// Create debugger subsystems
myCpuDebug = new CpuDebug(*this, myConsole);
@ -203,7 +203,7 @@ bool Debugger::start(const string& message, int address)
ostringstream buf;
buf << message;
if(address > -1)
buf << valueToString(address);
buf << Common::Base::HEX4 << address;
myDialog->message().setText(buf.str());
return true;
@ -265,66 +265,6 @@ const string Debugger::run(const string& command)
return myParser->run(command);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Debugger::valueToString(int value, BaseFormat outputBase) const
{
static char vToS_buf[32];
if(outputBase == kBASE_DEFAULT)
outputBase = myParser->base();
switch(outputBase)
{
case kBASE_2: // base 2: 8 or 16 bits (depending on value)
case kBASE_2_8: // base 2: 1 byte (8 bits) wide
case kBASE_2_16: // base 2: 2 bytes (16 bits) wide
{
int places = (outputBase == kBASE_2_8 ||
(outputBase == kBASE_2 && value < 0x100)) ? 8 : 16;
vToS_buf[places] = '\0';
int bit = 1;
while(--places >= 0) {
if(value & bit) vToS_buf[places] = '1';
else vToS_buf[places] = '0';
bit <<= 1;
}
break;
}
case kBASE_10: // base 10: 3 or 5 bytes (depending on value)
if(value < 0x100)
BSPF_snprintf(vToS_buf, 4, "%3d", value);
else
BSPF_snprintf(vToS_buf, 6, "%5d", value);
break;
case kBASE_16_1: // base 16: 1 byte wide
BSPF_snprintf(vToS_buf, 2, "%1X", value);
break;
case kBASE_16_2: // base 16: 2 bytes wide
BSPF_snprintf(vToS_buf, 3, "%02X", value);
break;
case kBASE_16_4: // base 16: 4 bytes wide
BSPF_snprintf(vToS_buf, 5, "%04X", value);
break;
case kBASE_16_8: // base 16: 8 bytes wide
BSPF_snprintf(vToS_buf, 9, "%08X", value);
break;
case kBASE_16: // base 16: 2, 4, 8 bytes (depending on value)
default:
if(value < 0x100)
BSPF_snprintf(vToS_buf, 3, "%02X", value);
else if(value < 0x10000)
BSPF_snprintf(vToS_buf, 5, "%04X", value);
else
BSPF_snprintf(vToS_buf, 9, "%08X", value);
break;
}
return string(vToS_buf);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string Debugger::invIfChanged(int reg, int oldReg)
{
@ -332,7 +272,7 @@ const string Debugger::invIfChanged(int reg, int oldReg)
bool changed = reg != oldReg;
if(changed) ret += "\177";
ret += valueToString(reg);
ret += Common::Base::toString(reg, Common::Base::F_16_2);
if(changed) ret += "\177";
return ret;

View File

@ -41,6 +41,7 @@ class ButtonWidget;
#include <map>
#include "Array.hxx"
#include "Base.hxx"
#include "DialogContainer.hxx"
#include "DebuggerDialog.hxx"
#include "DebuggerParser.hxx"
@ -183,7 +184,6 @@ class Debugger : public DialogContainer
*/
int stringToValue(const string& stringval)
{ return myParser->decipher_arg(stringval); }
string valueToString(int value, BaseFormat outputBase = kBASE_DEFAULT) const;
/* Convenience methods to get/set bit(s) in an 8-bit register */
static uInt8 set_bit(uInt8 input, uInt8 bit, bool on)

View File

@ -36,6 +36,9 @@
#include "ProgressDialog.hxx"
#include "PackedBitArray.hxx"
#include "Base.hxx"
using namespace Common;
#ifdef CHEATCODE_SUPPORT
#include "Cheat.hxx"
#include "CheatManager.hxx"
@ -50,9 +53,9 @@
// TODO - use C++ streams instead of nasty C-strings and pointers
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DebuggerParser::DebuggerParser(Debugger& d)
DebuggerParser::DebuggerParser(Debugger& d, Settings& s)
: debugger(d),
defaultBase(kBASE_16)
settings(s)
{
}
@ -148,7 +151,7 @@ string DebuggerParser::exec(const FilesystemNode& file)
run(command);
count++;
}
buf << "Executed " << debugger.valueToString(count) << " commands from \""
buf << "Executed " << count << " commands from \""
<< file.getShortPath() << "\"";
return buf.str();
@ -181,9 +184,11 @@ int DebuggerParser::decipher_arg(const string& str)
int result;
string arg = str;
if(defaultBase == kBASE_2) {
Base::Format defaultBase = Base::format();
if(defaultBase == Base::F_2) {
bin=true; dec=false;
} else if(defaultBase == kBASE_10) {
} else if(defaultBase == Base::F_10) {
bin=false; dec=true;
} else {
bin=false; dec=false;
@ -543,11 +548,11 @@ string DebuggerParser::eval()
buf << wlabel << "(W): ";
if(args[i] < 0x100)
buf << "$" << debugger.valueToString(args[i], kBASE_16_2)
<< " %" << debugger.valueToString(args[i], kBASE_2_8);
buf << "$" << Base::toString(args[i], Base::F_16_2)
<< " %" << Base::toString(args[i], Base::F_2_8);
else
buf << "$" << debugger.valueToString(args[i], kBASE_16_4)
<< " %" << debugger.valueToString(args[i], kBASE_2_16);
buf << "$" << Base::toString(args[i], Base::F_16_4)
<< " %" << Base::toString(args[i], Base::F_2_16);
buf << " #" << (int) args[i];
if(i != argCount - 1)
@ -561,7 +566,7 @@ string DebuggerParser::eval()
string DebuggerParser::trapStatus(int addr)
{
string result;
result += debugger.valueToString(addr);
result += Base::toString(addr);
result += ": ";
bool r = debugger.readTrap(addr);
bool w = debugger.writeTrap(addr);
@ -649,8 +654,8 @@ void DebuggerParser::executeBank()
commandResult << red("bankswitching not supported by this cartridge");
else
{
commandResult << "current = " << debugger.valueToString(debugger.cartDebug().getBank())
<< " out of " << debugger.valueToString(banks) << " banks";
commandResult << "current = " << debugger.cartDebug().getBank()
<< " out of " << banks << " banks";
}
}
else
@ -659,7 +664,7 @@ void DebuggerParser::executeBank()
commandResult << red("bankswitching not supported by this cartridge");
else if(args[0] >= banks)
commandResult << red("invalid bank number (must be 0 to ")
<< debugger.valueToString(banks - 1) << ")";
<< (banks - 1) << ")";
else if(debugger.setBank(args[0]))
commandResult << "switched bank OK";
else
@ -672,23 +677,23 @@ void DebuggerParser::executeBank()
void DebuggerParser::executeBase()
{
if(args[0] == 2 || argStrings[0] == "bin")
setBase(kBASE_2);
Base::setFormat(Base::F_2);
else if(args[0] == 10 || argStrings[0] == "dec")
setBase(kBASE_10);
Base::setFormat(Base::F_10);
else if(args[0] == 16 || argStrings[0] == "hex")
setBase(kBASE_16);
Base::setFormat(Base::F_16);
commandResult << "default base set to ";
switch(defaultBase) {
case kBASE_2:
switch(Base::format()) {
case Base::F_2:
commandResult << "#2/bin";
break;
case kBASE_10:
case Base::F_10:
commandResult << "#10/dec";
break;
case kBASE_16:
case Base::F_16:
commandResult << "#16/hex";
break;
@ -715,7 +720,7 @@ void DebuggerParser::executeBreak()
else
commandResult << "Cleared";
commandResult << " breakpoint at " << debugger.valueToString(bp);
commandResult << " breakpoint at " << Base::toString(bp);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -727,7 +732,7 @@ void DebuggerParser::executeBreakif()
{
uInt32 ret = debugger.cpuDebug().m6502().addCondBreak(
YaccParser::getResult(), argStrings[0] );
commandResult << "Added breakif " << debugger.valueToString(ret);
commandResult << "Added breakif " << Base::toString(ret);
}
else
commandResult << red("invalid expression");
@ -943,10 +948,10 @@ void DebuggerParser::executeDump()
for(int i=0; i<8; i++)
{
int start = args[0] + i*16;
commandResult << debugger.valueToString(start) << ": ";
for(int j=0; j<16; j++)
commandResult << Base::toString(start) << ": ";
for(int j = 0; j < 16; j++)
{
commandResult << debugger.valueToString(debugger.peek(start+j)) << " ";
commandResult << Base::toString(debugger.peek(start+j)) << " ";
if(j == 7) commandResult << "- ";
}
if(i != 7) commandResult << endl;
@ -975,8 +980,7 @@ void DebuggerParser::executeFrame()
int count = 1;
if(argCount != 0) count = args[0];
debugger.nextFrame(count);
commandResult << "advanced " << debugger.valueToString(count) << " frame";
if(count != 1) commandResult << "s";
commandResult << "advanced " << dec << count << " frame(s)";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1057,10 +1061,10 @@ void DebuggerParser::executeJump()
if(line >= 0 && address >= 0)
{
debugger.rom().scrollTo(line);
commandResult << "disassembly scrolled to address $" << HEX4 << address;
commandResult << "disassembly scrolled to address $" << Base::HEX4 << address;
}
else
commandResult << "address $" << HEX4 << args[0] << " doesn't exist";
commandResult << "address $" << Base::HEX4 << args[0] << " doesn't exist";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1092,9 +1096,9 @@ void DebuggerParser::executeListbreaks()
if(conds.size() > 0)
{
commandResult << "\nbreakifs:\n";
for(unsigned int i=0; i<conds.size(); i++)
for(unsigned int i = 0; i < conds.size(); i++)
{
commandResult << debugger.valueToString(i) << ": " << conds[i];
commandResult << i << ": " << conds[i];
if(i != (conds.size() - 1)) commandResult << endl;
}
}
@ -1278,8 +1282,7 @@ void DebuggerParser::executeRom()
// method ...
debugger.rom().invalidate();
commandResult << "changed " << debugger.valueToString( args.size() - 1 )
<< " location(s)";
commandResult << "changed " << (args.size() - 1) << " location(s)";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1349,13 +1352,11 @@ void DebuggerParser::executeRunTo()
if(done)
commandResult
<< "found " << argStrings[0] << " in "
<< debugger.valueToString(count, kBASE_10)
<< "found " << argStrings[0] << " in " << dec << count
<< " disassembled instructions";
else
commandResult
<< argStrings[0] << " not found in "
<< debugger.valueToString(count, kBASE_10)
<< argStrings[0] << " not found in " << dec << count
<< " disassembled instructions";
}
@ -1379,14 +1380,12 @@ void DebuggerParser::executeRunToPc()
if(done)
commandResult
<< "set PC to " << hex << args[0] << " in "
<< debugger.valueToString(count, kBASE_10)
<< " disassembled instructions";
<< "set PC to " << Base::HEX4 << args[0] << " in "
<< dec << count << " disassembled instructions";
else
commandResult
<< "PC " << hex << args[0] << " not reached or found in "
<< debugger.valueToString(count, kBASE_10)
<< " disassembled instructions";
<< "PC " << Base::HEX4 << args[0] << " not reached or found in "
<< dec << count << " disassembled instructions";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1454,8 +1453,7 @@ void DebuggerParser::executeScanline()
int count = 1;
if(argCount != 0) count = args[0];
debugger.nextScanline(count);
commandResult << "advanced " << debugger.valueToString(count) << " scanline";
if(count != 1) commandResult << "s";
commandResult << "advanced " << dec << count << " scanline(s)";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1463,7 +1461,7 @@ void DebuggerParser::executeScanline()
void DebuggerParser::executeStep()
{
commandResult
<< "executed " << debugger.valueToString(debugger.step()) << " cycles";
<< "executed " << dec << debugger.step() << " cycles";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1477,8 +1475,7 @@ void DebuggerParser::executeTia()
// "trace"
void DebuggerParser::executeTrace()
{
commandResult
<< "executed " << debugger.valueToString(debugger.trace()) << " cycles";
commandResult << "executed " << dec << debugger.trace() << " cycles";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1537,12 +1534,24 @@ void DebuggerParser::executeType()
for(uInt32 i = beg; i <= end; ++i)
{
commandResult << HEX4 << i << ": ";
commandResult << Base::HEX4 << i << ": ";
debugger.cartDebug().addressTypeAsString(commandResult, i);
commandResult << endl;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "uhex"
void DebuggerParser::executeUHex()
{
bool enable = !Base::hexUppercase();
Base::setHexUppercase(enable);
settings.setValue("dbg.uhex", enable);
commandResult << "uppercase HEX " << (enable ? "enabled" : "disabled");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "undef"
void DebuggerParser::executeUndef()
@ -2178,6 +2187,14 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
&DebuggerParser::executeType
},
{
"uhex",
"Toggle upper/lowercase HEX display",
false,
true,
{ kARG_END_ARGS },
&DebuggerParser::executeUHex
},
{
"undef",

View File

@ -29,27 +29,12 @@ struct Command;
#include "bspf.hxx"
#include "Array.hxx"
#include "FrameBuffer.hxx"
// The base to use for conversion from integers to strings
// Note that the actual number of places will be determined by
// the magnitude of the value itself in the general case
typedef enum {
kBASE_16, // base 16: 2, 4, 8 bytes (depending on value)
kBASE_16_1, // base 16: 1 byte wide
kBASE_16_2, // base 16: 2 bytes wide
kBASE_16_4, // base 16: 4 bytes wide
kBASE_16_8, // base 16: 8 bytes wide
kBASE_10, // base 10: 3 or 5 bytes (depending on value)
kBASE_2, // base 2: 8 or 16 bits (depending on value)
kBASE_2_8, // base 2: 1 byte (8 bits) wide
kBASE_2_16, // base 2: 2 bytes (16 bits) wide
kBASE_DEFAULT
} BaseFormat;
#include "Settings.hxx"
class DebuggerParser
{
public:
DebuggerParser(Debugger& debugger);
DebuggerParser(Debugger& debugger, Settings& settings);
~DebuggerParser();
/** Run the given command, and return the result */
@ -68,10 +53,6 @@ class DebuggerParser
/** String representation of all watches currently defined */
string showWatches();
/** Get/set the number base when parsing numeric values */
void setBase(BaseFormat base) { defaultBase = base; }
BaseFormat base() const { return defaultBase; }
static inline string red(const string& msg = "")
{
return char(kDbgChangedColor) + msg;
@ -91,7 +72,7 @@ class DebuggerParser
private:
enum {
kNumCommands = 70,
kNumCommands = 71,
kMAX_ARG_TYPES = 10
};
@ -130,6 +111,9 @@ class DebuggerParser
// Reference to our debugger object
Debugger& debugger;
// Reference to settings object (required for saving certain options)
Settings& settings;
// The results of the currently running command
ostringstream commandResult;
@ -138,7 +122,6 @@ class DebuggerParser
StringList argStrings;
int argCount;
BaseFormat defaultBase;
StringList watches;
// List of available command methods
@ -206,6 +189,7 @@ class DebuggerParser
void executeTrapread();
void executeTrapwrite();
void executeType();
void executeUHex();
void executeUndef();
void executeV();
void executeWatch();

View File

@ -20,6 +20,7 @@
#include "bspf.hxx"
#include "Debugger.hxx"
#include "DiStella.hxx"
using namespace Common;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list,
@ -210,7 +211,7 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list,
if(myDbg.addressType(k+myOffset) == CartDebug::ADDR_ROM)
{
reservedLabel.str("");
reservedLabel << "L" << HEX4 << (k+myOffset);
reservedLabel << "L" << Base::HEX4 << (k+myOffset);
myReserved.Label.insert(make_pair(k+myOffset, reservedLabel.str()));
}
}
@ -249,21 +250,21 @@ void DiStella::disasm(uInt32 distart, int pass)
if (pass == 3)
{
if (check_bit(myPC, CartDebug::REFERENCED))
myDisasmBuf << HEX4 << myPC+myOffset << "'L" << HEX4 << myPC+myOffset << "'";
myDisasmBuf << Base::HEX4 << myPC+myOffset << "'L" << Base::HEX4 << myPC+myOffset << "'";
else
myDisasmBuf << HEX4 << myPC+myOffset << "' '";
myDisasmBuf << Base::HEX4 << myPC+myOffset << "' '";
bool isPGfx = check_bit(myPC, CartDebug::PGFX);
const string& bit_string = isPGfx ? "\x1f" : "\x1e";
uInt8 byte = Debugger::debugger().peek(myPC+myOffset);
myDisasmBuf << ".byte $" << HEX2 << (int)byte << " |";
myDisasmBuf << ".byte $" << Base::HEX2 << (int)byte << " |";
for(uInt8 i = 0, c = byte; i < 8; ++i, c <<= 1)
myDisasmBuf << ((c > 127) ? bit_string : " ");
myDisasmBuf << "| $" << HEX4 << myPC+myOffset << "'";
if(mySettings.gfx_format == kBASE_2)
myDisasmBuf << Debugger::debugger().valueToString(byte, kBASE_2_8);
myDisasmBuf << "| $" << Base::HEX4 << myPC+myOffset << "'";
if(mySettings.gfx_format == Base::F_2)
myDisasmBuf << Base::toString(byte, Base::F_2_8);
else
myDisasmBuf << HEX2 << (int)byte;
myDisasmBuf << Base::HEX2 << (int)byte;
addEntry(isPGfx ? CartDebug::PGFX : CartDebug::GFX);
}
myPC++;
@ -276,14 +277,14 @@ void DiStella::disasm(uInt32 distart, int pass)
else if (pass == 3)
{
if (check_bit(myPC, CartDebug::REFERENCED))
myDisasmBuf << HEX4 << myPC+myOffset << "'L" << HEX4 << myPC+myOffset << "'";
myDisasmBuf << Base::HEX4 << myPC+myOffset << "'L" << Base::HEX4 << myPC+myOffset << "'";
else
myDisasmBuf << HEX4 << myPC+myOffset << "' '";
myDisasmBuf << Base::HEX4 << myPC+myOffset << "' '";
uInt8 byte = Debugger::debugger().peek(myPC+myOffset);
myDisasmBuf << ".byte $" << HEX2 << (int)byte << " $"
<< HEX4 << myPC+myOffset << "'"
<< HEX2 << (int)byte;
myDisasmBuf << ".byte $" << Base::HEX2 << (int)byte << " $"
<< Base::HEX4 << myPC+myOffset << "'"
<< Base::HEX2 << (int)byte;
addEntry(CartDebug::DATA);
}
myPC++;
@ -310,8 +311,8 @@ void DiStella::disasm(uInt32 distart, int pass)
addEntry(CartDebug::ROW);
line_empty = true;
}
myDisasmBuf << HEX4 << myPC+myOffset << "'L" << HEX4
<< myPC+myOffset << "'.byte " << "$" << HEX2
myDisasmBuf << Base::HEX4 << myPC+myOffset << "'L" << Base::HEX4
<< myPC+myOffset << "'.byte " << "$" << Base::HEX2
<< (int)Debugger::debugger().peek(myPC+myOffset);
myPC++;
bytes = 1;
@ -319,7 +320,7 @@ void DiStella::disasm(uInt32 distart, int pass)
}
else if(line_empty) // start a new line without a label
{
myDisasmBuf << " ' '.byte $" << HEX2 << (int)Debugger::debugger().peek(myPC+myOffset);
myDisasmBuf << " ' '.byte $" << Base::HEX2 << (int)Debugger::debugger().peek(myPC+myOffset);
myPC++;
bytes = 1;
line_empty = false;
@ -332,7 +333,7 @@ void DiStella::disasm(uInt32 distart, int pass)
}
else
{
myDisasmBuf << ",$" << HEX2 << (int)Debugger::debugger().peek(myPC+myOffset);
myDisasmBuf << ",$" << Base::HEX2 << (int)Debugger::debugger().peek(myPC+myOffset);
myPC++;
}
@ -360,9 +361,9 @@ void DiStella::disasm(uInt32 distart, int pass)
else if (pass == 3)
{
if (check_bit(myPC, CartDebug::REFERENCED))
myDisasmBuf << HEX4 << myPC+myOffset << "'L" << HEX4 << myPC+myOffset << "'";
myDisasmBuf << Base::HEX4 << myPC+myOffset << "'L" << Base::HEX4 << myPC+myOffset << "'";
else
myDisasmBuf << HEX4 << myPC+myOffset << "' '";
myDisasmBuf << Base::HEX4 << myPC+myOffset << "' '";
}
// Add opcode mneumonic
@ -376,7 +377,7 @@ void DiStella::disasm(uInt32 distart, int pass)
{
addr_mode = IMPLIED;
if (pass == 3)
nextline << ".byte $" << HEX2 << (int)op << " ;";
nextline << ".byte $" << Base::HEX2 << (int)op << " ;";
}
if (pass == 1)
@ -399,7 +400,7 @@ void DiStella::disasm(uInt32 distart, int pass)
else if (pass == 3)
{
nextline << ourLookup[op].mnemonic;
nextlinebytes << HEX2 << (int)op << " ";
nextlinebytes << Base::HEX2 << (int)op << " ";
}
// Add operand(s) for PC values outside the app data range
@ -420,22 +421,22 @@ 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 */
myDisasmBuf << ".byte $" << HEX2 << (int)op << " $"
<< HEX4 << myPC+myOffset << "'"
<< HEX2 << (int)op;
myDisasmBuf << ".byte $" << Base::HEX2 << (int)op << " $"
<< Base::HEX4 << myPC+myOffset << "'"
<< Base::HEX2 << (int)op;
addEntry(CartDebug::DATA);
if (myPC == myAppData.end)
{
if (check_bit(myPC, CartDebug::REFERENCED))
myDisasmBuf << HEX4 << myPC+myOffset << "'L" << HEX4 << myPC+myOffset << "'";
myDisasmBuf << Base::HEX4 << myPC+myOffset << "'L" << Base::HEX4 << myPC+myOffset << "'";
else
myDisasmBuf << HEX4 << myPC+myOffset << "' '";
myDisasmBuf << Base::HEX4 << myPC+myOffset << "' '";
op = Debugger::debugger().peek(myPC+myOffset); myPC++;
myDisasmBuf << ".byte $" << HEX2 << (int)op << " $"
<< HEX4 << myPC+myOffset << "'"
<< HEX2 << (int)op;
myDisasmBuf << ".byte $" << Base::HEX2 << (int)op << " $"
<< Base::HEX4 << myPC+myOffset << "'"
<< Base::HEX2 << (int)op;
addEntry(CartDebug::DATA);
}
}
@ -455,7 +456,7 @@ 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 */
myDisasmBuf << ".byte $" << HEX2 << (int)op;
myDisasmBuf << ".byte $" << Base::HEX2 << (int)op;
addEntry(CartDebug::ROW);
nextline.str("");
nextlinebytes.str("");
@ -523,7 +524,7 @@ void DiStella::disasm(uInt32 distart, int pass)
if (labfound == 1)
{
LABEL_A12_HIGH(ad);
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
nextlinebytes << Base::HEX2 << (int)(ad&0xff) << " " << Base::HEX2 << (int)(ad>>8);
}
else if (labfound == 4)
{
@ -531,18 +532,18 @@ void DiStella::disasm(uInt32 distart, int pass)
{
int tmp = (ad & myAppData.end)+myOffset;
LABEL_A12_HIGH(tmp);
nextlinebytes << HEX2 << (int)(tmp&0xff) << " " << HEX2 << (int)(tmp>>8);
nextlinebytes << Base::HEX2 << (int)(tmp&0xff) << " " << Base::HEX2 << (int)(tmp>>8);
}
else
{
nextline << "$" << HEX4 << ad;
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
nextline << "$" << Base::HEX4 << ad;
nextlinebytes << Base::HEX2 << (int)(ad&0xff) << " " << Base::HEX2 << (int)(ad>>8);
}
}
else
{
LABEL_A12_LOW(ad);
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
nextlinebytes << Base::HEX2 << (int)(ad&0xff) << " " << Base::HEX2 << (int)(ad>>8);
}
}
break;
@ -556,7 +557,7 @@ void DiStella::disasm(uInt32 distart, int pass)
{
nextline << " ";
LABEL_A12_LOW((int)d1);
nextlinebytes << HEX2 << (int)d1;
nextlinebytes << Base::HEX2 << (int)d1;
}
break;
}
@ -566,8 +567,8 @@ void DiStella::disasm(uInt32 distart, int pass)
d1 = Debugger::debugger().peek(myPC+myOffset); myPC++;
if (pass == 3)
{
nextline << " #$" << HEX2 << (int)d1 << " ";
nextlinebytes << HEX2 << (int)d1;
nextline << " #$" << Base::HEX2 << (int)d1 << " ";
nextlinebytes << Base::HEX2 << (int)d1;
}
break;
}
@ -595,7 +596,7 @@ void DiStella::disasm(uInt32 distart, int pass)
{
LABEL_A12_HIGH(ad);
nextline << ",X";
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
nextlinebytes << Base::HEX2 << (int)(ad&0xff) << " " << Base::HEX2 << (int)(ad>>8);
}
else if (labfound == 4)
{
@ -604,19 +605,19 @@ void DiStella::disasm(uInt32 distart, int pass)
int tmp = (ad & myAppData.end)+myOffset;
LABEL_A12_HIGH(tmp);
nextline << ",X";
nextlinebytes << HEX2 << (int)(tmp&0xff) << " " << HEX2 << (int)(tmp>>8);
nextlinebytes << Base::HEX2 << (int)(tmp&0xff) << " " << Base::HEX2 << (int)(tmp>>8);
}
else
{
nextline << "$" << HEX4 << ad << ",X";
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
nextline << "$" << Base::HEX4 << ad << ",X";
nextlinebytes << Base::HEX2 << (int)(ad&0xff) << " " << Base::HEX2 << (int)(ad>>8);
}
}
else
{
LABEL_A12_LOW(ad);
nextline << ",X";
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
nextlinebytes << Base::HEX2 << (int)(ad&0xff) << " " << Base::HEX2 << (int)(ad>>8);
}
}
break;
@ -645,7 +646,7 @@ void DiStella::disasm(uInt32 distart, int pass)
{
LABEL_A12_HIGH(ad);
nextline << ",Y";
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
nextlinebytes << Base::HEX2 << (int)(ad&0xff) << " " << Base::HEX2 << (int)(ad>>8);
}
else if (labfound == 4)
{
@ -654,19 +655,19 @@ void DiStella::disasm(uInt32 distart, int pass)
int tmp = (ad & myAppData.end)+myOffset;
LABEL_A12_HIGH(tmp);
nextline << ",Y";
nextlinebytes << HEX2 << (int)(tmp&0xff) << " " << HEX2 << (int)(tmp>>8);
nextlinebytes << Base::HEX2 << (int)(tmp&0xff) << " " << Base::HEX2 << (int)(tmp>>8);
}
else
{
nextline << "$" << HEX4 << ad << ",Y";
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
nextline << "$" << Base::HEX4 << ad << ",Y";
nextlinebytes << Base::HEX2 << (int)(ad&0xff) << " " << Base::HEX2 << (int)(ad>>8);
}
}
else
{
LABEL_A12_LOW(ad);
nextline << ",Y";
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
nextlinebytes << Base::HEX2 << (int)(ad&0xff) << " " << Base::HEX2 << (int)(ad>>8);
}
}
break;
@ -681,7 +682,7 @@ void DiStella::disasm(uInt32 distart, int pass)
nextline << " (";
LABEL_A12_LOW(d1);
nextline << ",X)";
nextlinebytes << HEX2 << (int)d1;
nextlinebytes << Base::HEX2 << (int)d1;
}
break;
}
@ -695,7 +696,7 @@ void DiStella::disasm(uInt32 distart, int pass)
nextline << " (";
LABEL_A12_LOW(d1);
nextline << "),Y";
nextlinebytes << HEX2 << (int)d1;
nextlinebytes << Base::HEX2 << (int)d1;
}
break;
}
@ -710,7 +711,7 @@ void DiStella::disasm(uInt32 distart, int pass)
LABEL_A12_LOW(d1);
nextline << ",X";
}
nextlinebytes << HEX2 << (int)d1;
nextlinebytes << Base::HEX2 << (int)d1;
break;
}
@ -724,7 +725,7 @@ void DiStella::disasm(uInt32 distart, int pass)
LABEL_A12_LOW(d1);
nextline << ",Y";
}
nextlinebytes << HEX2 << (int)d1;
nextlinebytes << Base::HEX2 << (int)d1;
break;
}
@ -753,9 +754,9 @@ void DiStella::disasm(uInt32 distart, int pass)
LABEL_A12_HIGH(ad);
}
else
nextline << " $" << HEX4 << ad;
nextline << " $" << Base::HEX4 << ad;
nextlinebytes << HEX2 << (int)d1;
nextlinebytes << Base::HEX2 << (int)d1;
}
break;
}
@ -793,7 +794,7 @@ void DiStella::disasm(uInt32 distart, int pass)
nextline << ")";
}
nextlinebytes << HEX2 << (int)(ad&0xff) << " " << HEX2 << (int)(ad>>8);
nextlinebytes << Base::HEX2 << (int)(ad&0xff) << " " << Base::HEX2 << (int)(ad>>8);
break;
}
@ -997,9 +998,7 @@ void DiStella::addEntry(CartDebug::DisasmType type)
else if(mySettings.show_addresses && tag.type == CartDebug::CODE)
{
// Have addresses indented, to differentiate from actual labels
char address[7];
BSPF_snprintf(address, 6, " %4X", tag.address);
tag.label = address;
tag.label = " " + Base::toString(tag.address, Base::F_16_4);
tag.hllabel = false;
}
}
@ -1066,13 +1065,13 @@ void DiStella::processDirectives(const CartDebug::DirectiveList& directives)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DiStella::Settings DiStella::settings = {
kBASE_2, // gfx_format
true, // resolve_code (opposite of -d in Distella)
true, // show_addresses (not used externally; always off)
false, // aflag (-a in Distella)
true, // fflag (-f in Distella)
false, // rflag (-r in Distella)
9 // number of bytes to use with .byte directive
Base::F_2, // gfx_format
true, // resolve_code (opposite of -d in Distella)
true, // show_addresses (not used externally; always off)
false, // aflag (-a in Distella)
true, // fflag (-f in Distella)
false, // rflag (-r in Distella)
9 // number of bytes to use with .byte directive
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -24,9 +24,9 @@
#include <sstream>
#include "Array.hxx"
#include "bspf.hxx"
#include "Base.hxx"
#include "CartDebug.hxx"
#include "DebuggerParser.hxx"
#include "bspf.hxx"
/**
This class is a wrapper around the Distella code. Much of the code remains
@ -45,7 +45,7 @@ class DiStella
// This will eventually grow to include all options supported by
// standalone Distella
typedef struct {
BaseFormat gfx_format;
Common::Base::Format gfx_format;
bool resolve_code; // Attempt to detect code vs. data sections
bool show_addresses; // Show PC addresses (always off for external output)
bool aflag; // Turns 'A' off in accumulator instructions (-a in Distella)
@ -94,7 +94,7 @@ class DiStella
inline void labelA12High(stringstream& buf, uInt8 op, uInt16 addr, int labfound)
{
if(!myDbg.getLabel(buf, addr, true))
buf << "L" << HEX4 << addr;
buf << "L" << Common::Base::HEX4 << addr;
}
inline void labelA12Low(stringstream& buf, uInt8 op, uInt16 addr, int labfound)
{

View File

@ -61,7 +61,7 @@ const DebuggerState& RiotDebug::getState()
myState.TIM1T = tim1T();
myState.TIM8T = tim8T();
myState.TIM64T = tim64T();
myState.TIM1024T = tim1024T();
myState.T1024T = tim1024T();
myState.INTIM = intim();
myState.TIMINT = timint();
myState.TIMCLKS = timClocks();
@ -99,7 +99,7 @@ void RiotDebug::saveOldState()
myOldState.TIM1T = tim1T();
myOldState.TIM8T = tim8T();
myOldState.TIM64T = tim64T();
myOldState.TIM1024T = tim1024T();
myOldState.T1024T = tim1024T();
myOldState.INTIM = intim();
myOldState.TIMINT = timint();
myOldState.TIMCLKS = timClocks();
@ -313,41 +313,28 @@ string RiotDebug::toString()
const RiotState& oldstate = (RiotState&) getOldState();
ostringstream buf;
buf << myDebugger.valueToString(0x280) + "/SWCHA(R)="
<< myDebugger.invIfChanged(state.SWCHA_R, oldstate.SWCHA_R) << " "
<< myDebugger.valueToString(0x280) + "/SWCHA(W)="
<< myDebugger.invIfChanged(state.SWCHA_W, oldstate.SWCHA_W) << " "
<< myDebugger.valueToString(0x281) + "/SWACNT="
<< myDebugger.invIfChanged(state.SWACNT, oldstate.SWACNT) << " "
<< myDebugger.valueToString(0x282) + "/SWCHB(R)="
<< myDebugger.invIfChanged(state.SWCHB_R, oldstate.SWCHB_R) << " "
<< myDebugger.valueToString(0x282) + "/SWCHB(W)="
<< myDebugger.invIfChanged(state.SWCHB_W, oldstate.SWCHB_W) << " "
<< myDebugger.valueToString(0x283) + "/SWBCNT="
<< myDebugger.invIfChanged(state.SWBCNT, oldstate.SWBCNT) << " "
buf << "280/SWCHA(R)=" << myDebugger.invIfChanged(state.SWCHA_R, oldstate.SWCHA_R)
<< " 280/SWCHA(W)=" << myDebugger.invIfChanged(state.SWCHA_W, oldstate.SWCHA_W)
<< " 281/SWACNT=" << myDebugger.invIfChanged(state.SWACNT, oldstate.SWACNT)
<< endl
<< "282/SWCHB(R)=" << myDebugger.invIfChanged(state.SWCHB_R, oldstate.SWCHB_R)
<< " 282/SWCHB(W)=" << myDebugger.invIfChanged(state.SWCHB_W, oldstate.SWCHB_W)
<< " 283/SWBCNT=" << myDebugger.invIfChanged(state.SWBCNT, oldstate.SWBCNT)
<< endl
// These are squirrely: some symbol files will define these as
// 0x284-0x287. Doesn't actually matter, these registers repeat
// every 16 bytes.
<< myDebugger.valueToString(0x294) + "/TIM1T="
<< myDebugger.invIfChanged(state.TIM1T, oldstate.TIM1T) << " "
<< myDebugger.valueToString(0x295) + "/TIM8T="
<< myDebugger.invIfChanged(state.TIM8T, oldstate.TIM8T) << " "
<< myDebugger.valueToString(0x296) + "/TIM64T="
<< myDebugger.invIfChanged(state.TIM64T, oldstate.TIM64T) << " "
<< myDebugger.valueToString(0x297) + "/TIM1024T="
<< myDebugger.invIfChanged(state.TIM1024T, oldstate.TIM1024T) << " "
<< "294/TIM1T=" << myDebugger.invIfChanged(state.TIM1T, oldstate.TIM1T)
<< " 295/TIM8T=" << myDebugger.invIfChanged(state.TIM8T, oldstate.TIM8T)
<< " 296/TIM64T=" << myDebugger.invIfChanged(state.TIM64T, oldstate.TIM64T)
<< " 297/T1024T=" << myDebugger.invIfChanged(state.T1024T, oldstate.T1024T)
<< endl
<< myDebugger.valueToString(0x284) + "/INTIM="
<< myDebugger.invIfChanged(state.INTIM, oldstate.INTIM) << " "
<< myDebugger.valueToString(0x285) + "/TIMINT="
<< myDebugger.invIfChanged(state.TIMINT, oldstate.TIMINT) << " "
<< "Timer_Clocks="
<< myDebugger.invIfChanged(state.TIMCLKS, oldstate.TIMCLKS) << " "
<< "INTIM_Clocks="
<< myDebugger.invIfChanged(state.INTIMCLKS, oldstate.INTIMCLKS) << " "
<< "0x284/INTIM=" << myDebugger.invIfChanged(state.INTIM, oldstate.INTIM)
<< " 285/TIMINT=" << myDebugger.invIfChanged(state.TIMINT, oldstate.TIMINT)
<< " Timer_Clocks=" << myDebugger.invIfChanged(state.TIMCLKS, oldstate.TIMCLKS)
<< " INTIM_Clocks=" << myDebugger.invIfChanged(state.INTIMCLKS, oldstate.INTIMCLKS)
<< endl
<< "Left/P0diff: " << diffP0String() << " Right/P1diff: " << diffP0String()

View File

@ -38,7 +38,7 @@ class RiotState : public DebuggerState
BoolArray swchbWriteBits;
BoolArray swbcntBits;
uInt8 TIM1T, TIM8T, TIM64T, TIM1024T, INTIM, TIMINT;
uInt8 TIM1T, TIM8T, TIM64T, T1024T, INTIM, TIMINT;
Int32 TIMCLKS, INTIMCLKS;
// These are actually from the TIA, but are I/O related

View File

@ -17,6 +17,7 @@
// $Id$
//============================================================================
#include "Base.hxx"
#include "System.hxx"
#include "Debugger.hxx"
#include "TIA.hxx"
@ -740,7 +741,7 @@ string TIADebug::toString()
buf << "00: ";
for (uInt8 j = 0; j < 0x010; j++)
{
buf << HEX2 << (int)mySystem.peek(j) << " ";
buf << Common::Base::HEX2 << (int)mySystem.peek(j) << " ";
if(j == 0x07) buf << "- ";
}
buf << endl;
@ -752,7 +753,7 @@ string TIADebug::toString()
// const TiaState& oldstate = (TiaState&) getOldState();
// build up output, then return it.
buf << "scanline " << myDebugger.valueToString(myTIA.scanlines()) << " "
buf << "scanline " << dec << myTIA.scanlines() << " "
<< booleanWithLabel("vsync", vsync()) << " "
<< booleanWithLabel("vblank", vblank())
<< endl
@ -765,53 +766,53 @@ string TIADebug::toString()
<< booleanWithLabel("dump_gnd_0123", myTIA.myDumpEnabled)
<< endl
<< "COLUxx: "
<< "P0=" << myDebugger.valueToString(state.coluRegs[0]) << "/"
<< "P0=$" << Common::Base::HEX2 << state.coluRegs[0] << "/"
<< colorSwatch(state.coluRegs[0])
<< "P1=" << myDebugger.valueToString(state.coluRegs[1]) << "/"
<< "P1=$" << Common::Base::HEX2 << state.coluRegs[1] << "/"
<< colorSwatch(state.coluRegs[1])
<< "PF=" << myDebugger.valueToString(state.coluRegs[2]) << "/"
<< "PF=$" << Common::Base::HEX2 << state.coluRegs[2] << "/"
<< colorSwatch(state.coluRegs[2])
<< "BK=" << myDebugger.valueToString(state.coluRegs[3]) << "/"
<< "BK=$" << Common::Base::HEX2 << state.coluRegs[3] << "/"
<< colorSwatch(state.coluRegs[3])
<< endl
<< "P0: GR=" << myDebugger.valueToString(state.gr[P0], kBASE_2_8)
<< " pos=" << myDebugger.valueToString(state.pos[P0])
<< " HM=" << myDebugger.valueToString(state.hm[P0]) << " "
<< "P0: GR=%" << Common::Base::toString(state.gr[P0], Common::Base::F_2_8)
<< " pos=#" << dec << state.pos[P0]
<< " HM=$" << Common::Base::HEX2 << state.hm[P0] << " "
<< nusizP0String() << " "
<< booleanWithLabel("refl", refP0()) << " "
<< booleanWithLabel("delay", vdelP0())
<< endl
<< "P1: GR=" << myDebugger.valueToString(state.gr[P1], kBASE_2_8)
<< " pos=" << myDebugger.valueToString(state.pos[P1])
<< " HM=" << myDebugger.valueToString(state.hm[P1]) << " "
<< "P1: GR=%" << Common::Base::toString(state.gr[P1], Common::Base::F_2_8)
<< " pos=#" << dec << state.pos[P1]
<< " HM=$" << Common::Base::HEX2 << state.hm[P1] << " "
<< nusizP1String() << " "
<< booleanWithLabel("refl", refP1()) << " "
<< booleanWithLabel("delay", vdelP1())
<< endl
<< "M0: " << (myTIA.myENAM0 ? " ENABLED" : "disabled")
<< " pos=" << myDebugger.valueToString(state.pos[M0])
<< " HM=" << myDebugger.valueToString(state.hm[M0])
<< " size=" << myDebugger.valueToString(state.size[M0]) << " "
<< " pos=#" << dec << state.pos[M0]
<< " HM=$" << Common::Base::HEX2 << state.hm[M0]
<< " size=" << dec << state.size[M0] << " "
<< booleanWithLabel("reset", resMP0())
<< endl
<< "M1: " << (myTIA.myENAM1 ? " ENABLED" : "disabled")
<< " pos=" << myDebugger.valueToString(state.pos[M1])
<< " HM=" << myDebugger.valueToString(state.hm[M1])
<< " size=" << myDebugger.valueToString(state.size[M1]) << " "
<< " pos=#" << dec << state.pos[M1]
<< " HM=$" << Common::Base::HEX2 << state.hm[M1]
<< " size=" << dec << state.size[M1] << " "
<< booleanWithLabel("reset", resMP0())
<< endl
<< "BL: " << (myTIA.myENABL ? " ENABLED" : "disabled")
<< " pos=" << myDebugger.valueToString(state.pos[BL])
<< " HM=" << myDebugger.valueToString(state.hm[BL])
<< " size=" << myDebugger.valueToString(state.size[BL]) << " "
<< " pos=#" << dec << state.pos[BL]
<< " HM=$" << Common::Base::HEX2 << state.hm[BL]
<< " size=" << dec << state.size[BL] << " "
<< booleanWithLabel("delay", vdelBL())
<< endl
<< "PF0: " << myDebugger.valueToString(state.pf[0], kBASE_2_8) << "/"
<< myDebugger.valueToString(state.pf[0])
<< " PF1: " << myDebugger.valueToString(state.pf[1], kBASE_2_8) << "/"
<< myDebugger.valueToString(state.pf[1])
<< " PF2: " << myDebugger.valueToString(state.pf[2], kBASE_2_8) << "/"
<< myDebugger.valueToString(state.pf[2])
<< "PF0: %" << Common::Base::toString(state.pf[0], Common::Base::F_2_8) << "/$"
<< Common::Base::HEX2 << state.pf[0]
<< " PF1: %" << Common::Base::toString(state.pf[1], Common::Base::F_2_8) << "/$"
<< Common::Base::HEX2 << state.pf[1]
<< " PF2: %" << Common::Base::toString(state.pf[2], Common::Base::F_2_8) << "/$"
<< Common::Base::HEX2 << state.pf[2]
<< endl << " "
<< booleanWithLabel("reflect", refPF()) << " "
<< booleanWithLabel("score", scorePF()) << " "
@ -836,15 +837,15 @@ string TIADebug::toString()
<< endl << " "
<< booleanWithLabel("m0_m1 ", collM0_M1())
<< endl
<< "AUDF0: " << myDebugger.valueToString(myTIA.myAUDF0)
<< "AUDF0: $" << Common::Base::HEX2 << (int)myTIA.myAUDF0
<< "/" << audFreq(myTIA.myAUDF0) << " "
<< "AUDC0: " << myDebugger.valueToString(myTIA.myAUDC0) << " "
<< "AUDV0: " << myDebugger.valueToString(myTIA.myAUDV0)
<< "AUDC0: $" << Common::Base::HEX2 << (int)myTIA.myAUDC0 << " "
<< "AUDV0: $" << Common::Base::HEX2 << (int)myTIA.myAUDV0
<< endl
<< "AUDF1: " << myDebugger.valueToString(myTIA.myAUDF1)
<< "AUDF1: $" << Common::Base::HEX2 << (int)myTIA.myAUDF1
<< "/" << audFreq(myTIA.myAUDF1) << " "
<< "AUDC1: " << myDebugger.valueToString(myTIA.myAUDC1) << " "
<< "AUDV1: " << myDebugger.valueToString(myTIA.myAUDV1)
<< "AUDC1: $" << Common::Base::HEX2 << (int)myTIA.myAUDC1 << " "
<< "AUDV1: $" << Common::Base::HEX2 << (int)myTIA.myAUDV1
;
// note: last line should not contain \n, caller will add.
return buf.str();

View File

@ -45,7 +45,7 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& font,
"AUDF:", kTextAlignLeft);
xpos += lwidth;
myAudF = new DataGridWidget(boss, font, xpos, ypos,
2, 1, 2, 5, kBASE_16);
2, 1, 2, 5, Common::Base::F_16);
myAudF->setTarget(this);
myAudF->setID(kAUDFID);
myAudF->setEditable(false);
@ -55,7 +55,7 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& font,
{
new StaticTextWidget(boss, font, xpos + col*myAudF->colWidth() + 7,
ypos - lineHeight, fontWidth, fontHeight,
instance().debugger().valueToString(col, kBASE_16_1),
Common::Base::toString(col, Common::Base::F_16_1),
kTextAlignLeft);
}
@ -65,7 +65,7 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& font,
"AUDC:", kTextAlignLeft);
xpos += lwidth;
myAudC = new DataGridWidget(boss, font, xpos, ypos,
2, 1, 2, 4, kBASE_16);
2, 1, 2, 4, Common::Base::F_16);
myAudC->setTarget(this);
myAudC->setID(kAUDCID);
myAudC->setEditable(false);
@ -77,7 +77,7 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& font,
"AUDV:", kTextAlignLeft);
xpos += lwidth;
myAudV = new DataGridWidget(boss, font, xpos, ypos,
2, 1, 2, 4, kBASE_16);
2, 1, 2, 4, Common::Base::F_16);
myAudV->setTarget(this);
myAudV->setID(kAUDVID);
myAudV->setEditable(false);

View File

@ -40,7 +40,7 @@ Cartridge0840Widget::Cartridge0840Widget(
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << i << " @ $" << HEX4 << start << " - "
info << "Bank " << i << " @ $" << Common::Base::HEX4 << start << " - "
<< "$" << (start + 0xFFF) << " (hotspot = $" << spot << ")\n";
}

View File

@ -33,6 +33,6 @@ Cartridge2KWidget::Cartridge2KWidget(
ostringstream info;
info << "Standard 2K cartridge, non-bankswitched\n"
<< "Accessible @ $" << HEX4 << start << " - " << "$" << (start + size - 1);
<< "Accessible @ $" << Common::Base::HEX4 << start << " - " << "$" << (start + size - 1);
addBaseInformation(size, "Atari", info.str());
}

View File

@ -47,7 +47,7 @@ Cartridge3EWidget::Cartridge3EWidget(
// Eventually, we should query this from the debugger/disassembler
uInt16 start = (cart.myImage[size-3] << 8) | cart.myImage[size-4];
start -= start % 0x1000;
info << "Bank RORG" << " = $" << HEX4 << start << "\n";
info << "Bank RORG" << " = $" << Common::Base::HEX4 << start << "\n";
int xpos = 10,
ypos = addBaseInformation(size, "TigerVision", info.str()) + myLineHeight;
@ -63,7 +63,8 @@ Cartridge3EWidget::Cartridge3EWidget(
ramitems.push_back("Inactive", "");
ostringstream label;
label << "Set bank ($" << HEX4 << start << " - $" << (start+0x7FF) << "): ";
label << "Set bank ($" << Common::Base::HEX4 << start << " - $"
<< (start+0x7FF) << "): ";
new StaticTextWidget(_boss, _font, xpos, ypos, font.getStringWidth(label.str()),
myFontHeight, label.str(), kTextAlignLeft);

View File

@ -39,7 +39,7 @@ Cartridge3FWidget::Cartridge3FWidget(
// Eventually, we should query this from the debugger/disassembler
uInt16 start = (cart.myImage[size-3] << 8) | cart.myImage[size-4];
start -= start % 0x1000;
info << "Bank RORG" << " = $" << HEX4 << start << "\n";
info << "Bank RORG" << " = $" << Common::Base::HEX4 << start << "\n";
int xpos = 10,
ypos = addBaseInformation(size, "TigerVision", info.str()) + myLineHeight;
@ -51,7 +51,8 @@ Cartridge3FWidget::Cartridge3FWidget(
items.push_back(b + " ($3F)");
}
ostringstream label;
label << "Set bank ($" << HEX4 << start << " - $" << (start+0x7FF) << "): ";
label << "Set bank ($" << Common::Base::HEX4 << start << " - $" <<
(start+0x7FF) << "): ";
myBank =
new PopUpWidget(boss, font, xpos, ypos-2, font.getStringWidth("0 ($3F) "),
myLineHeight, items, label.str(),

View File

@ -32,6 +32,7 @@ Cartridge4KWidget::Cartridge4KWidget(
ostringstream info;
info << "Standard 4K cartridge, non-bankswitched\n"
<< "Accessible @ $" << HEX4 << start << " - " << "$" << (start + 0xFFF);
<< "Accessible @ $" << Common::Base::HEX4 << start << " - "
<< "$" << (start + 0xFFF);
addBaseInformation(4096, "Atari", info.str());
}

View File

@ -73,7 +73,7 @@ CartridgeCMWidget::CartridgeCMWidget(
myFontHeight, "Current column: ", kTextAlignLeft);
xpos += lwidth;
myColumn = new DataGridWidget(boss, font, xpos, ypos-2, 1, 1, 2, 8, kBASE_16);
myColumn = new DataGridWidget(boss, font, xpos, ypos-2, 1, 1, 2, 8, Common::Base::F_16);
myColumn->setTarget(this);
myColumn->setEditable(false);

View File

@ -35,7 +35,7 @@ CartridgeCVWidget::CartridgeCVWidget(
info << "CV 2K ROM + 1K RAM , non-bankswitched\n"
<< "1024 bytes RAM @ $F000 - $F7FF\n"
<< " $F000 - $F3FF (R), $F400 - $F7FF (W)\n"
<< "ROM accessible @ $" << HEX4 << start << " - "
<< "ROM accessible @ $" << Common::Base::HEX4 << start << " - "
<< "$" << (start + size - 1);
addBaseInformation(cart.mySize, "CommaVid", info.str());

View File

@ -75,7 +75,7 @@ CartridgeDPCPlusWidget::CartridgeDPCPlusWidget(
myFontHeight, "Top Registers: ", kTextAlignLeft);
xpos += lwidth;
myTops = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 2, 8, kBASE_16);
myTops = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 2, 8, Common::Base::F_16);
myTops->setTarget(this);
myTops->setEditable(false);
@ -85,7 +85,7 @@ CartridgeDPCPlusWidget::CartridgeDPCPlusWidget(
myFontHeight, "Bottom Registers: ", kTextAlignLeft);
xpos += lwidth;
myBottoms = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 2, 8, kBASE_16);
myBottoms = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 2, 8, Common::Base::F_16);
myBottoms->setTarget(this);
myBottoms->setEditable(false);
@ -95,7 +95,7 @@ CartridgeDPCPlusWidget::CartridgeDPCPlusWidget(
myFontHeight, "Counter Registers: ", kTextAlignLeft);
xpos += lwidth;
myCounters = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 4, 16, kBASE_16_4);
myCounters = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 4, 16, Common::Base::F_16_4);
myCounters->setTarget(this);
myCounters->setEditable(false);
@ -105,7 +105,7 @@ CartridgeDPCPlusWidget::CartridgeDPCPlusWidget(
myFontHeight, "Frac Counters: ", kTextAlignLeft);
xpos += lwidth;
myFracCounters = new DataGridWidget(boss, font, xpos, ypos-2, 4, 2, 8, 32, kBASE_16_8);
myFracCounters = new DataGridWidget(boss, font, xpos, ypos-2, 4, 2, 8, 32, Common::Base::F_16_8);
myFracCounters->setTarget(this);
myFracCounters->setEditable(false);
@ -115,7 +115,7 @@ CartridgeDPCPlusWidget::CartridgeDPCPlusWidget(
myFontHeight, "Frac Increments: ", kTextAlignLeft);
xpos += lwidth;
myFracIncrements = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 2, 8, kBASE_16);
myFracIncrements = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 2, 8, Common::Base::F_16);
myFracIncrements->setTarget(this);
myFracIncrements->setEditable(false);
@ -125,7 +125,7 @@ CartridgeDPCPlusWidget::CartridgeDPCPlusWidget(
myFontHeight, "Function Params: ", kTextAlignLeft);
xpos += lwidth;
myParameter = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 2, 8, kBASE_16);
myParameter = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 2, 8, Common::Base::F_16);
myParameter->setTarget(this);
myParameter->setEditable(false);
@ -135,7 +135,7 @@ CartridgeDPCPlusWidget::CartridgeDPCPlusWidget(
myFontHeight, "Music Counters: ", kTextAlignLeft);
xpos += lwidth;
myMusicCounters = new DataGridWidget(boss, font, xpos, ypos-2, 3, 1, 8, 32, kBASE_16_8);
myMusicCounters = new DataGridWidget(boss, font, xpos, ypos-2, 3, 1, 8, 32, Common::Base::F_16_8);
myMusicCounters->setTarget(this);
myMusicCounters->setEditable(false);
@ -145,7 +145,7 @@ CartridgeDPCPlusWidget::CartridgeDPCPlusWidget(
myFontHeight, "Music Frequencies: ", kTextAlignLeft);
xpos += lwidth;
myMusicFrequencies = new DataGridWidget(boss, font, xpos, ypos-2, 3, 1, 8, 32, kBASE_16_8);
myMusicFrequencies = new DataGridWidget(boss, font, xpos, ypos-2, 3, 1, 8, 32, Common::Base::F_16_8);
myMusicFrequencies->setTarget(this);
myMusicFrequencies->setEditable(false);
@ -155,7 +155,7 @@ CartridgeDPCPlusWidget::CartridgeDPCPlusWidget(
myFontHeight, "Music Waveforms: ", kTextAlignLeft);
xpos += lwidth;
myMusicWaveforms = new DataGridWidget(boss, font, xpos, ypos-2, 3, 1, 4, 16, kBASE_16_4);
myMusicWaveforms = new DataGridWidget(boss, font, xpos, ypos-2, 3, 1, 4, 16, Common::Base::F_16_4);
myMusicWaveforms->setTarget(this);
myMusicWaveforms->setEditable(false);
@ -166,7 +166,7 @@ CartridgeDPCPlusWidget::CartridgeDPCPlusWidget(
myFontHeight, "Current random number: ", kTextAlignLeft);
xpos += lwidth;
myRandom = new DataGridWidget(boss, font, xpos, ypos-2, 1, 1, 8, 32, kBASE_16_8);
myRandom = new DataGridWidget(boss, font, xpos, ypos-2, 1, 1, 8, 32, Common::Base::F_16_8);
myRandom->setTarget(this);
myRandom->setEditable(false);

View File

@ -43,7 +43,7 @@ CartridgeDPCWidget::CartridgeDPCWidget(
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << i << " @ $" << HEX4 << (start + 0x80) << " - "
info << "Bank " << i << " @ $" << Common::Base::HEX4 << (start + 0x80) << " - "
<< "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n";
}
@ -74,7 +74,7 @@ CartridgeDPCWidget::CartridgeDPCWidget(
myFontHeight, "Top Registers: ", kTextAlignLeft);
xpos += lwidth;
myTops = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 2, 8, kBASE_16);
myTops = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 2, 8, Common::Base::F_16);
myTops->setTarget(this);
myTops->setEditable(false);
@ -84,7 +84,7 @@ CartridgeDPCWidget::CartridgeDPCWidget(
myFontHeight, "Bottom Registers: ", kTextAlignLeft);
xpos += lwidth;
myBottoms = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 2, 8, kBASE_16);
myBottoms = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 2, 8, Common::Base::F_16);
myBottoms->setTarget(this);
myBottoms->setEditable(false);
@ -94,7 +94,7 @@ CartridgeDPCWidget::CartridgeDPCWidget(
myFontHeight, "Counter Registers: ", kTextAlignLeft);
xpos += lwidth;
myCounters = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 4, 16, kBASE_16_4);
myCounters = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 4, 16, Common::Base::F_16_4);
myCounters->setTarget(this);
myCounters->setEditable(false);
@ -104,7 +104,7 @@ CartridgeDPCWidget::CartridgeDPCWidget(
myFontHeight, "Flag Registers: ", kTextAlignLeft);
xpos += lwidth;
myFlags = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 2, 8, kBASE_16);
myFlags = new DataGridWidget(boss, font, xpos, ypos-2, 8, 1, 2, 8, Common::Base::F_16);
myFlags->setTarget(this);
myFlags->setEditable(false);
@ -115,7 +115,7 @@ CartridgeDPCWidget::CartridgeDPCWidget(
myFontHeight, "Music mode (DF5/DF6/DF7): ", kTextAlignLeft);
xpos += lwidth;
myMusicMode = new DataGridWidget(boss, font, xpos, ypos-2, 3, 1, 2, 8, kBASE_16);
myMusicMode = new DataGridWidget(boss, font, xpos, ypos-2, 3, 1, 2, 8, Common::Base::F_16);
myMusicMode->setTarget(this);
myMusicMode->setEditable(false);
@ -125,7 +125,7 @@ CartridgeDPCWidget::CartridgeDPCWidget(
myFontHeight, "Current random number: ", kTextAlignLeft);
xpos += lwidth;
myRandom = new DataGridWidget(boss, font, xpos, ypos-2, 1, 1, 2, 8, kBASE_16);
myRandom = new DataGridWidget(boss, font, xpos, ypos-2, 1, 1, 2, 8, Common::Base::F_16);
myRandom->setTarget(this);
myRandom->setEditable(false);
}

View File

@ -23,6 +23,7 @@
class GuiObject;
class ButtonWidget;
#include "Base.hxx"
#include "Font.hxx"
#include "Command.hxx"
#include "Debugger.hxx"

View File

@ -41,8 +41,8 @@ CartridgeEFSCWidget::CartridgeEFSCWidget(
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << dec << i << " @ $" << HEX4 << (start + 0x100) << " - "
<< "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n";
info << "Bank " << dec << i << " @ $" << Common::Base::HEX4 << (start + 0x100)
<< " - " << "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n";
}
int xpos = 10,

View File

@ -39,7 +39,7 @@ CartridgeEFWidget::CartridgeEFWidget(
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << dec << i << " @ $" << HEX4 << start << " - "
info << "Bank " << dec << i << " @ $" << Common::Base::HEX4 << start << " - "
<< "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n";
}

View File

@ -40,7 +40,7 @@ CartridgeF0Widget::CartridgeF0Widget(
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << dec << i << " @ $" << HEX4 << start << " - "
info << "Bank " << dec << i << " @ $" << Common::Base::HEX4 << start << " - "
<< "$" << (start + 0xFFF) << "\n";
}

View File

@ -41,7 +41,7 @@ CartridgeF4SCWidget::CartridgeF4SCWidget(
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << i << " @ $" << HEX4 << (start + 0x100) << " - "
info << "Bank " << i << " @ $" << Common::Base::HEX4 << (start + 0x100) << " - "
<< "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n";
}

View File

@ -39,7 +39,7 @@ CartridgeF4Widget::CartridgeF4Widget(
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << i << " @ $" << HEX4 << start << " - "
info << "Bank " << i << " @ $" << Common::Base::HEX4 << start << " - "
<< "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n";
}

View File

@ -41,7 +41,7 @@ CartridgeF6SCWidget::CartridgeF6SCWidget(
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << i << " @ $" << HEX4 << (start + 0x100) << " - "
info << "Bank " << i << " @ $" << Common::Base::HEX4 << (start + 0x100) << " - "
<< "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n";
}

View File

@ -39,7 +39,7 @@ CartridgeF6Widget::CartridgeF6Widget(
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << i << " @ $" << HEX4 << start << " - "
info << "Bank " << i << " @ $" << Common::Base::HEX4 << start << " - "
<< "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n";
}

View File

@ -41,7 +41,7 @@ CartridgeF8SCWidget::CartridgeF8SCWidget(
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << i << " @ $" << HEX4 << (start + 0x100) << " - "
info << "Bank " << i << " @ $" << Common::Base::HEX4 << (start + 0x100) << " - "
<< "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n";
}

View File

@ -39,7 +39,7 @@ CartridgeF8Widget::CartridgeF8Widget(
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << i << " @ $" << HEX4 << start << " - "
info << "Bank " << i << " @ $" << Common::Base::HEX4 << start << " - "
<< "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n";
}

View File

@ -43,7 +43,7 @@ CartridgeFA2Widget::CartridgeFA2Widget(
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << i << " @ $" << HEX4 << (start + 0x200) << " - "
info << "Bank " << i << " @ $" << Common::Base::HEX4 << (start + 0x200) << " - "
<< "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n";
}

View File

@ -41,7 +41,7 @@ CartridgeFAWidget::CartridgeFAWidget(
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << i << " @ $" << HEX4 << (start + 0x200) << " - "
info << "Bank " << i << " @ $" << Common::Base::HEX4 << (start + 0x200) << " - "
<< "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n";
}

View File

@ -34,7 +34,7 @@ CartridgeSBWidget::CartridgeSBWidget(
ostringstream info, bank;
info << "SB SUPERbanking, 32 or 64 4K banks\n"
<< "Hotspots are from $800 to $"
<< HEX2 << (0x800 + myCart.bankCount() - 1) << ", including\n"
<< Common::Base::HEX2 << (0x800 + myCart.bankCount() - 1) << ", including\n"
<< "mirrors ($900, $A00, $B00, ...)\n"
<< "Startup bank = " << dec << cart.myStartBank << "\n";
@ -44,10 +44,11 @@ CartridgeSBWidget::CartridgeSBWidget(
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << dec << i << " @ $" << HEX4 << start << " - "
info << "Bank " << dec << i << " @ $" << Common::Base::HEX4 << start << " - "
<< "$" << (start + 0xFFF) << " (hotspot = $" << spot << ")\n";
bank << dec << setw(2) << setfill(' ') << i << " ($" << HEX2 << spot << ")";
bank << dec << setw(2) << setfill(' ') << i << " ($" << Common::Base::HEX2
<< spot << ")";
items.push_back(bank.str());
bank.str("");
}
@ -90,7 +91,7 @@ string CartridgeSBWidget::bankState()
ostringstream& buf = buffer();
buf << "Bank = " << myCart.myCurrentBank
<< ", hotspot = $" << HEX2 << (myCart.myCurrentBank + 0x800);
<< ", hotspot = $" << Common::Base::HEX2 << (myCart.myCurrentBank + 0x800);
return buf.str();
}

View File

@ -40,7 +40,7 @@ CartridgeUAWidget::CartridgeUAWidget(
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << i << " @ $" << HEX4 << start << " - "
info << "Bank " << i << " @ $" << Common::Base::HEX4 << start << " - "
<< "$" << (start + 0xFFF) << " (hotspot = $" << spot << ")\n";
}

View File

@ -41,8 +41,8 @@ CartridgeX07Widget::CartridgeX07Widget(
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << dec << i << " @ $" << HEX4 << start << " - "
<< "$" << (start + 0xFFF) << "\n";
info << "Bank " << dec << i << " @ $" << Common::Base::HEX4 << start
<< " - " << "$" << (start + 0xFFF) << "\n";
}
int xpos = 10,

View File

@ -48,7 +48,7 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
new StaticTextWidget(boss, font, xpos, ypos+2, lwidth-2, fontHeight,
"PC:", kTextAlignLeft);
myPCGrid =
new DataGridWidget(boss, font, xpos + lwidth, ypos, 1, 1, 4, 16, kBASE_16);
new DataGridWidget(boss, font, xpos + lwidth, ypos, 1, 1, 4, 16, Common::Base::F_16);
myPCGrid->setTarget(this);
myPCGrid->setID(kPCRegID);
addFocusWidget(myPCGrid);
@ -62,7 +62,7 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
// Create a 1x4 grid with labels for the other CPU registers
xpos = x + lwidth; ypos += myPCGrid->getHeight() + 1;
myCpuGrid =
new DataGridWidget(boss, font, xpos, ypos, 1, 4, 2, 8, kBASE_16);
new DataGridWidget(boss, font, xpos, ypos, 1, 4, 2, 8, Common::Base::F_16);
myCpuGrid->setTarget(this);
myCpuGrid->setID(kCpuRegID);
addFocusWidget(myCpuGrid);
@ -70,17 +70,17 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
// Create a 1x4 grid with decimal and binary values for the other CPU registers
xpos = x + lwidth + myPCGrid->getWidth() + 10;
myCpuGridDecValue =
new DataGridWidget(boss, font, xpos, ypos, 1, 4, 3, 8, kBASE_10);
new DataGridWidget(boss, font, xpos, ypos, 1, 4, 3, 8, Common::Base::F_10);
myCpuGridDecValue->setEditable(false);
xpos += myCpuGridDecValue->getWidth() + 5;
myCpuGridBinValue =
new DataGridWidget(boss, font, xpos, ypos, 1, 4, 8, 8, kBASE_2);
new DataGridWidget(boss, font, xpos, ypos, 1, 4, 8, 8, Common::Base::F_2);
myCpuGridBinValue->setEditable(false);
// Create a label and 1x3 grid showing the source of data for A/X/Y registers
xpos += myCpuGridBinValue->getWidth() + 20;
myCpuDataSrcGrid =
new DataGridWidget(boss, font, xpos, ypos, 1, 4, 4, 16, kBASE_16);
new DataGridWidget(boss, font, xpos, ypos, 1, 4, 4, 16, Common::Base::F_16);
myCpuDataSrcGrid->setEditable(false);
new StaticTextWidget(boss, font, xpos-font.getMaxCharWidth(),
ypos+myCpuDataSrcGrid->getHeight() + 4,

View File

@ -30,7 +30,8 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DataGridWidget::DataGridWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int cols, int rows,
int colchars, int bits, BaseFormat base,
int colchars, int bits,
Common::Base::Format base,
bool useScrollbar)
: EditableWidget(boss, font, x, y,
cols*(colchars * font.getMaxCharWidth() + 8) + 1,
@ -114,10 +115,7 @@ cerr << "alist.size() = " << alist.size()
// An efficiency thing
string temp;
for(int i = 0; i < size; ++i)
{
temp = instance().debugger().valueToString(_valueList[i], _base);
_valueStringList.push_back(temp);
}
_valueStringList.push_back(Common::Base::toString(_valueList[i], _base));
/*
cerr << "_addrList.size() = " << _addrList.size()
@ -196,7 +194,7 @@ void DataGridWidget::setValue(int position, int value, bool changed)
if(position >= 0 && uInt32(position) < _valueList.size())
{
// Correctly format the data for viewing
_editString = instance().debugger().valueToString(value, _base);
_editString = Common::Base::toString(value, _base);
_valueStringList[position] = _editString;
_changedList[position] = changed;
@ -658,22 +656,22 @@ void DataGridWidget::endEditMode()
{
switch(_base)
{
case kBASE_16:
case kBASE_16_1:
case kBASE_16_2:
case kBASE_16_4:
case kBASE_16_8:
case Common::Base::F_16:
case Common::Base::F_16_1:
case Common::Base::F_16_2:
case Common::Base::F_16_4:
case Common::Base::F_16_8:
_editString.insert(0, 1, '$');
break;
case kBASE_2:
case kBASE_2_8:
case kBASE_2_16:
case Common::Base::F_2:
case Common::Base::F_2_8:
case Common::Base::F_2_16:
_editString.insert(0, 1, '\\');
break;
case kBASE_10:
case Common::Base::F_10:
_editString.insert(0, 1, '#');
break;
case kBASE_DEFAULT:
case Common::Base::F_DEFAULT:
break;
}
}

View File

@ -28,6 +28,7 @@ class ScrollBarWidget;
#include "Debugger.hxx"
#include "EditableWidget.hxx"
#include "Array.hxx"
#include "Base.hxx"
#include "Rect.hxx"
/* DataGridWidget */
@ -45,7 +46,8 @@ class DataGridWidget : public EditableWidget
public:
DataGridWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int cols, int rows,
int colchars, int bits, BaseFormat format = kBASE_DEFAULT,
int colchars, int bits,
Common::Base::Format format = Common::Base::F_DEFAULT,
bool useScrollbar = false);
virtual ~DataGridWidget();
@ -114,7 +116,7 @@ class DataGridWidget : public EditableWidget
int _lowerBound;
int _upperBound;
BaseFormat _base;
Common::Base::Format _base;
IntArray _addrList;
IntArray _valueList;

View File

@ -50,7 +50,7 @@ DrivingWidget::DrivingWidget(GuiObject* boss, const GUI::Font& font,
xpos += myGreyDown->getWidth() + 10; ypos -= 10;
myGreyValue = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 2, 8, kBASE_16);
1, 1, 2, 8, Common::Base::F_16);
myGreyValue->setTarget(this);
myGreyValue->setEditable(false);
@ -104,4 +104,4 @@ void DrivingWidget::handleCommand(
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 DrivingWidget::ourGreyTable[4] = { 0x03, 0x01, 0x00, 0x02 };
uInt8 DrivingWidget::ourGreyTable[4] = { 0x03, 0x01, 0x00, 0x02 };

View File

@ -51,7 +51,7 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
// Add a scrollbar, since there may be more than 128 bytes of RAM available
xpos = x; ypos = y + lineHeight; lwidth = 4 * fontWidth;
myRamGrid = new DataGridWidget(boss, font, xpos + lwidth, ypos,
16, 8, 2, 8, kBASE_16, true);
16, 8, 2, 8, Common::Base::F_16, true);
myRamGrid->setTarget(this);
addFocusWidget(myRamGrid);
@ -93,7 +93,7 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
new StaticTextWidget(boss, font, xpos + col*myRamGrid->colWidth() + lwidth + 8,
ypos - lineHeight,
fontWidth, fontHeight,
instance().debugger().valueToString(col, kBASE_16_1),
Common::Base::toString(col, Common::Base::F_16_1),
kTextAlignLeft);
}
for(int row = 0; row < 8; ++row)
@ -179,8 +179,8 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
myUndoAddress = addr;
myUndoValue = oldval;
myDecValue->setText(instance().debugger().valueToString(value, kBASE_10));
myBinValue->setText(instance().debugger().valueToString(value, kBASE_2));
myDecValue->setText(Common::Base::toString(value, Common::Base::F_10));
myBinValue->setText(Common::Base::toString(value, Common::Base::F_2));
myRevertButton->setEnabled(true);
myUndoButton->setEnabled(true);
break;
@ -192,8 +192,8 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
value = myRamGrid->getSelectedValue();
myLabel->setText(dbg.getLabel(state.rport[addr], true));
myDecValue->setText(instance().debugger().valueToString(value, kBASE_10));
myBinValue->setText(instance().debugger().valueToString(value, kBASE_2));
myDecValue->setText(Common::Base::toString(value, Common::Base::F_10));
myBinValue->setText(Common::Base::toString(value, Common::Base::F_2));
break;
}

View File

@ -98,7 +98,7 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& font,
CREATE_IO_REGS("SWCHB(R):", mySWCHBReadBits, 0, false);
// Timer registers (R/W)
const char* writeNames[] = { "TIM1T:", "TIM8T:", "TIM64T:", "TIM1024T:" };
const char* writeNames[] = { "TIM1T:", "TIM8T:", "TIM64T:", "T1024T:" };
xpos = 10; ypos += 2*lineHeight;
for(int row = 0; row < 4; ++row)
{
@ -106,7 +106,7 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& font,
9*fontWidth, fontHeight, writeNames[row], kTextAlignLeft);
}
xpos += 9*fontWidth + 5;
myTimWrite = new DataGridWidget(boss, font, xpos, ypos, 1, 4, 2, 8, kBASE_16);
myTimWrite = new DataGridWidget(boss, font, xpos, ypos, 1, 4, 2, 8, Common::Base::F_16);
myTimWrite->setTarget(this);
myTimWrite->setID(kTimWriteID);
addFocusWidget(myTimWrite);
@ -120,7 +120,7 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& font,
11*fontWidth, fontHeight, readNames[row], kTextAlignLeft);
}
xpos += t->getWidth() + 5;
myTimRead = new DataGridWidget(boss, font, xpos, ypos, 1, 4, 8, 32, kBASE_16);
myTimRead = new DataGridWidget(boss, font, xpos, ypos, 1, 4, 8, 32, Common::Base::F_16);
myTimRead->setTarget(this);
myTimRead->setEditable(false);
@ -142,7 +142,7 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& font,
6*fontWidth, fontHeight, contLeftReadNames[row], kTextAlignLeft);
}
xpos += 6*fontWidth + 5;
myLeftINPT = new DataGridWidget(boss, font, xpos, ypos, 1, 3, 2, 8, kBASE_16);
myLeftINPT = new DataGridWidget(boss, font, xpos, ypos, 1, 3, 2, 8, Common::Base::F_16);
myLeftINPT->setTarget(this);
myLeftINPT->setEditable(false);
@ -155,7 +155,7 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& font,
6*fontWidth, fontHeight, contRightReadNames[row], kTextAlignLeft);
}
xpos += 6*fontWidth + 5;
myRightINPT = new DataGridWidget(boss, font, xpos, ypos, 1, 3, 2, 8, kBASE_16);
myRightINPT = new DataGridWidget(boss, font, xpos, ypos, 1, 3, 2, 8, Common::Base::F_16);
myRightINPT->setTarget(this);
myRightINPT->setEditable(false);
@ -307,8 +307,8 @@ void RiotWidget::loadConfig()
changed.push_back(state.TIM8T != oldstate.TIM8T);
alist.push_back(kTim64TID); vlist.push_back(state.TIM64T);
changed.push_back(state.TIM64T != oldstate.TIM64T);
alist.push_back(kTim1024TID); vlist.push_back(state.TIM1024T);
changed.push_back(state.TIM1024T != oldstate.TIM1024T);
alist.push_back(kTim1024TID); vlist.push_back(state.T1024T);
changed.push_back(state.T1024T != oldstate.T1024T);
myTimWrite->setList(alist, vlist, changed);
// Update timer read registers

View File

@ -557,23 +557,23 @@ bool RomListWidget::tryInsertChar(char c, int pos)
c = tolower(c);
switch(_base)
{
case kBASE_16:
case kBASE_16_1:
case kBASE_16_2:
case kBASE_16_4:
case kBASE_16_8:
case Common::Base::F_16:
case Common::Base::F_16_1:
case Common::Base::F_16_2:
case Common::Base::F_16_4:
case Common::Base::F_16_8:
insert = (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || c == ' ';
break;
case kBASE_2:
case kBASE_2_8:
case kBASE_2_16:
case Common::Base::F_2:
case Common::Base::F_2_8:
case Common::Base::F_2_16:
insert = c == '0' || c == '1' || c == ' ';
break;
case kBASE_10:
case Common::Base::F_10:
if((c >= '0' && c <= '9') || c == ' ')
insert = true;
break;
case kBASE_DEFAULT:
case Common::Base::F_DEFAULT:
break;
}
@ -600,7 +600,7 @@ void RomListWidget::startEditMode()
_base = DiStella::settings.gfx_format;
break;
default:
_base = instance().debugger().parser().base();
_base = Common::Base::format();
}
// Widget gets raw data while editing

View File

@ -26,8 +26,8 @@ class PackedBitArray;
class CheckListWidget;
#include "Array.hxx"
#include "Base.hxx"
#include "CartDebug.hxx"
#include "DebuggerParser.hxx"
#include "EditableWidget.hxx"
/** RomListWidget */
@ -38,7 +38,7 @@ class RomListWidget : public EditableWidget
kBPointChangedCmd = 'RLbp', // 'data' will be disassembly line number,
// 'id' will be the checkbox state
kRomChangedCmd = 'RLpr', // 'data' will be disassembly line number
// 'id' will be the BaseFormat of the data
// 'id' will be the Base::Format of the data
kSetPCCmd = 'STpc', // 'data' will be disassembly line number
kRuntoPCCmd = 'RTpc', // 'data' will be disassembly line number
kDisassembleCmd = 'REds',
@ -102,8 +102,8 @@ class RomListWidget : public EditableWidget
int _selectedItem;
int _highlightedItem;
bool _editMode;
BaseFormat _base; // base used during editing
StellaKey _currentKeyDown;
Common::Base::Format _base; // base used during editing
const CartDebug::Disassembly* myDisasm;
const PackedBitArray* myBPState;

View File

@ -112,7 +112,7 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
case RomListWidget::kRomChangedCmd:
// 'data' is the line in the disassemblylist to be accessed
// 'id' is the base to use for the data to be changed
patchROM(data, myRomList->getText(), (BaseFormat)id);
patchROM(data, myRomList->getText(), (Common::Base::Format)id);
break;
case RomListWidget::kSetPCCmd:
@ -151,12 +151,12 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
// 'data' is the boolean value
if(data)
{
DiStella::settings.gfx_format = kBASE_2;
DiStella::settings.gfx_format = Common::Base::F_2;
instance().settings().setValue("dis.gfxformat", "2");
}
else
{
DiStella::settings.gfx_format = kBASE_16;
DiStella::settings.gfx_format = Common::Base::F_16;
instance().settings().setValue("dis.gfxformat", "16");
}
invalidate();
@ -214,7 +214,8 @@ void RomWidget::runtoPC(int disasm_line)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomWidget::patchROM(int disasm_line, const string& bytes, BaseFormat base)
void RomWidget::patchROM(int disasm_line, const string& bytes,
Common::Base::Format base)
{
const CartDebug::DisassemblyList& list =
instance().debugger().cartDebug().disassembly().list;
@ -226,13 +227,13 @@ void RomWidget::patchROM(int disasm_line, const string& bytes, BaseFormat base)
// Temporarily set to correct base, so we don't have to prefix each byte
// with the type of data
BaseFormat oldbase = instance().debugger().parser().base();
Common::Base::Format oldbase = Common::Base::format();
instance().debugger().parser().setBase(base);
Common::Base::setFormat(base);
command << "rom #" << list[disasm_line].address << " " << bytes;
instance().debugger().run(command.str());
// Restore previous base
instance().debugger().parser().setBase(oldbase);
Common::Base::setFormat(oldbase);
}
}

View File

@ -23,8 +23,8 @@
class GuiObject;
class EditTextWidget;
#include "Base.hxx"
#include "Command.hxx"
#include "DebuggerParser.hxx"
#include "RomListWidget.hxx"
class RomWidget : public Widget, public CommandSender
@ -50,7 +50,8 @@ class RomWidget : public Widget, public CommandSender
void setBreak(int disasm_line, bool state);
void setPC(int disasm_line);
void runtoPC(int disasm_line);
void patchROM(int disasm_line, const string& bytes, BaseFormat base);
void patchROM(int disasm_line, const string& bytes,
Common::Base::Format base);
private:
RomListWidget* myRomList;

View File

@ -17,6 +17,7 @@
// $Id$
//============================================================================
#include "Base.hxx"
#include "OSystem.hxx"
#include "FrameBuffer.hxx"
#include "Debugger.hxx"
@ -122,15 +123,15 @@ void TiaInfoWidget::loadConfig()
Debugger& dbg = instance().debugger();
TIADebug& tia = dbg.tiaDebug();
myFrameCount->setText(dbg.valueToString(tia.frameCount(), kBASE_10));
myFrameCycles->setText(dbg.valueToString(dbg.cycles(), kBASE_10));
myFrameCount->setText(Common::Base::toString(tia.frameCount(), Common::Base::F_10));
myFrameCycles->setText(Common::Base::toString(dbg.cycles(), Common::Base::F_10));
myVSync->setState(tia.vsync());
myVBlank->setState(tia.vblank());
int clk = tia.clocksThisLine();
myScanlineCount->setText(dbg.valueToString(tia.scanlines(), kBASE_10));
myScanlineCycles->setText(dbg.valueToString(clk/3, kBASE_10));
myPixelPosition->setText(dbg.valueToString(clk-68, kBASE_10));
myColorClocks->setText(dbg.valueToString(clk, kBASE_10));
myScanlineCount->setText(Common::Base::toString(tia.scanlines(), Common::Base::F_10));
myScanlineCycles->setText(Common::Base::toString(clk/3, Common::Base::F_10));
myPixelPosition->setText(Common::Base::toString(clk-68, Common::Base::F_10));
myColorClocks->setText(Common::Base::toString(clk, Common::Base::F_10));
}

View File

@ -57,7 +57,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& font,
}
xpos += 7*fontWidth + 5;
myColorRegs = new DataGridWidget(boss, font, xpos, ypos,
1, 4, 2, 8, kBASE_16);
1, 4, 2, 8, Common::Base::F_16);
myColorRegs->setTarget(this);
myColorRegs->setID(kColorRegsID);
addFocusWidget(myColorRegs);
@ -200,7 +200,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& font,
"Pos: #", kTextAlignLeft);
xpos += t->getWidth() + 2;
myPosP0 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 3, 8, kBASE_10);
1, 1, 3, 8, Common::Base::F_10);
myPosP0->setTarget(this);
myPosP0->setID(kPosP0ID);
myPosP0->setRange(0, 160);
@ -213,7 +213,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& font,
"HM:", kTextAlignLeft);
xpos += 3*fontWidth + 5;
myHMP0 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 1, 4, kBASE_16_1);
1, 1, 1, 4, Common::Base::F_16_1);
myHMP0->setTarget(this);
myHMP0->setID(kHMP0ID);
addFocusWidget(myHMP0);
@ -240,7 +240,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& font,
"NusizP0:", kTextAlignLeft);
xpos += 8*fontWidth + 5;
myNusizP0 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 1, 3, kBASE_16_1);
1, 1, 1, 3, Common::Base::F_16_1);
myNusizP0->setTarget(this);
myNusizP0->setID(kNusizP0ID);
addFocusWidget(myNusizP0);
@ -269,7 +269,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& font,
"Pos: #", kTextAlignLeft);
xpos += t->getWidth() + 2;
myPosP1 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 3, 8, kBASE_10);
1, 1, 3, 8, Common::Base::F_10);
myPosP1->setTarget(this);
myPosP1->setID(kPosP1ID);
myPosP1->setRange(0, 160);
@ -281,7 +281,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& font,
"HM:", kTextAlignLeft);
xpos += 3*fontWidth + 5;
myHMP1 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 1, 4, kBASE_16_1);
1, 1, 1, 4, Common::Base::F_16_1);
myHMP1->setTarget(this);
myHMP1->setID(kHMP1ID);
addFocusWidget(myHMP1);
@ -307,7 +307,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& font,
"NusizP1:", kTextAlignLeft);
xpos += 8*fontWidth + 5;
myNusizP1 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 1, 3, kBASE_16_1);
1, 1, 1, 3, Common::Base::F_16_1);
myNusizP1->setTarget(this);
myNusizP1->setID(kNusizP1ID);
addFocusWidget(myNusizP1);
@ -337,7 +337,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& font,
"Pos: #", kTextAlignLeft);
xpos += t->getWidth() + 2;
myPosM0 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 3, 8, kBASE_10);
1, 1, 3, 8, Common::Base::F_10);
myPosM0->setTarget(this);
myPosM0->setID(kPosM0ID);
myPosM0->setRange(0, 160);
@ -349,7 +349,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& font,
"HM:", kTextAlignLeft);
xpos += 3*fontWidth + 5;
myHMM0 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 1, 4, kBASE_16_1);
1, 1, 1, 4, Common::Base::F_16_1);
myHMM0->setTarget(this);
myHMM0->setID(kHMM0ID);
addFocusWidget(myHMM0);
@ -360,7 +360,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& font,
"Size:", kTextAlignLeft);
xpos += 5*fontWidth + 5;
myNusizM0 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 1, 2, kBASE_16_1);
1, 1, 1, 2, Common::Base::F_16_1);
myNusizM0->setTarget(this);
myNusizM0->setID(kNusizM0ID);
addFocusWidget(myNusizM0);
@ -393,7 +393,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& font,
"Pos: #", kTextAlignLeft);
xpos += t->getWidth() + 2;
myPosM1 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 3, 8, kBASE_10);
1, 1, 3, 8, Common::Base::F_10);
myPosM1->setTarget(this);
myPosM1->setID(kPosM1ID);
myPosM1->setRange(0, 160);
@ -405,7 +405,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& font,
"HM:", kTextAlignLeft);
xpos += 3*fontWidth + 5;
myHMM1 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 1, 4, kBASE_16_1);
1, 1, 1, 4, Common::Base::F_16_1);
myHMM1->setTarget(this);
myHMM1->setID(kHMM1ID);
addFocusWidget(myHMM1);
@ -416,7 +416,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& font,
"Size:", kTextAlignLeft);
xpos += 5*fontWidth + 5;
myNusizM1 = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 1, 2, kBASE_16_1);
1, 1, 1, 2, Common::Base::F_16_1);
myNusizM1->setTarget(this);
myNusizM1->setID(kNusizM1ID);
addFocusWidget(myNusizM1);
@ -449,7 +449,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& font,
"Pos: #", kTextAlignLeft);
xpos += t->getWidth() + 2;
myPosBL = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 3, 8, kBASE_10);
1, 1, 3, 8, Common::Base::F_10);
myPosBL->setTarget(this);
myPosBL->setID(kPosBLID);
myPosBL->setRange(0, 160);
@ -461,7 +461,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& font,
"HM:", kTextAlignLeft);
xpos += 3*fontWidth + 5;
myHMBL = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 1, 4, kBASE_16_1);
1, 1, 1, 4, Common::Base::F_16_1);
myHMBL->setTarget(this);
myHMBL->setID(kHMBLID);
addFocusWidget(myHMBL);
@ -472,7 +472,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& font,
"Size:", kTextAlignLeft);
xpos += 5*fontWidth + 5;
mySizeBL = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 1, 2, kBASE_16_1);
1, 1, 1, 2, Common::Base::F_16_1);
mySizeBL->setTarget(this);
mySizeBL->setID(kSizeBLID);
addFocusWidget(mySizeBL);

View File

@ -24,6 +24,7 @@
#include "bspf.hxx"
#include "Base.hxx"
#include "CommandMenu.hxx"
#include "Console.hxx"
#include "DialogContainer.hxx"
@ -117,6 +118,9 @@ void EventHandler::initialize()
// Set number of lines a mousewheel will scroll
ScrollBarWidget::setWheelLines(myOSystem->settings().getInt("mwheel"));
// Integer to string conversions (for HEX) use upper or lower-case
Common::Base::setHexUppercase(myOSystem->settings().getBool("dbg.uhex"));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1780,7 +1784,7 @@ void EventHandler::saveComboMapping()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline bool EventHandler::eventIsAnalog(Event::Type event) const
{
switch((int)event)
switch(event)
{
case Event::PaddleZeroAnalog:
case Event::PaddleOneAnalog:

View File

@ -137,7 +137,8 @@ Settings::Settings(OSystem* osystem)
setExternal("romloadcount", "0");
setExternal("maxres", "");
// Debugger disassembly options
// Debugger/disassembly options
setInternal("dbg.uhex", "true");
setInternal("dis.resolve", "true");
setInternal("dis.gfxformat", "2");
setInternal("dis.showaddr", "true");

View File

@ -27,7 +27,9 @@
#ifdef THUMB_SUPPORT
#include "bspf.hxx"
#include "Base.hxx"
#include "Thumbulator.hxx"
using namespace Common;
// Uncomment the following to enable specific functionality
// WARNING!!! This slows the runtime to a crawl
@ -79,7 +81,7 @@ string Thumbulator::run( void )
inline int Thumbulator::fatalError(const char* opcode, uInt32 v1, const char* msg)
{
statusMsg << "Thumb ARM emulation fatal error: " << endl
<< opcode << "(" << HEX8 << v1 << "), " << msg << endl;
<< opcode << "(" << Base::HEX8 << v1 << "), " << msg << endl;
dump_regs();
if(trapOnFatal)
throw statusMsg.str();
@ -91,7 +93,7 @@ inline int Thumbulator::fatalError(const char* opcode, uInt32 v1, uInt32 v2,
const char* msg)
{
statusMsg << "Thumb ARM emulation fatal error: " << endl
<< opcode << "(" << HEX8 << v1 << "," << v2 << "), " << msg << endl;
<< opcode << "(" << Base::HEX8 << v1 << "," << v2 << "), " << msg << endl;
dump_regs();
if(trapOnFatal)
throw statusMsg.str();
@ -114,13 +116,13 @@ void Thumbulator::dump_regs( void )
{
for (int cnt = 1; cnt < 14; cnt++)
{
statusMsg << "R" << cnt << " = " << HEX8 << reg_sys[cnt-1] << " ";
statusMsg << "R" << cnt << " = " << Base::HEX8 << reg_sys[cnt-1] << " ";
if(cnt % 4 == 0) statusMsg << endl;
}
statusMsg << endl
<< "SP = " << HEX8 << reg_svc[13] << " "
<< "LR = " << HEX8 << reg_svc[14] << " "
<< "PC = " << HEX8 << reg_sys[15] << " "
<< "SP = " << Base::HEX8 << reg_svc[13] << " "
<< "LR = " << Base::HEX8 << reg_svc[14] << " "
<< "PC = " << Base::HEX8 << reg_sys[15] << " "
<< endl;
}
@ -143,7 +145,7 @@ uInt32 Thumbulator::fetch16 ( uInt32 addr )
#else
data=rom[addr];
#endif
DO_DBUG(statusMsg << "fetch16(" << HEX8 << addr << ")=" << HEX4 << data << endl);
DO_DBUG(statusMsg << "fetch16(" << Base::HEX8 << addr << ")=" << Base::HEX4 << data << endl);
return(data);
case 0x40000000: //RAM
@ -154,7 +156,7 @@ uInt32 Thumbulator::fetch16 ( uInt32 addr )
#else
data=ram[addr];
#endif
DO_DBUG(statusMsg << "fetch16(" << HEX8 << addr << ")=" << HEX4 << data << endl);
DO_DBUG(statusMsg << "fetch16(" << Base::HEX8 << addr << ")=" << Base::HEX4 << data << endl);
return(data);
}
return fatalError("fetch16", addr, "abort");
@ -170,7 +172,7 @@ uInt32 Thumbulator::fetch32 ( uInt32 addr )
if(addr<0x50)
{
data=read32(addr);
DO_DBUG(statusMsg << "fetch32(" << HEX8 << addr << ")=" << HEX8 << data << endl);
DO_DBUG(statusMsg << "fetch32(" << Base::HEX8 << addr << ")=" << Base::HEX8 << data << endl);
if(addr==0x00000000) return(data);
if(addr==0x00000004) return(data);
fatalError("fetch32", addr, "abort");
@ -180,7 +182,7 @@ uInt32 Thumbulator::fetch32 ( uInt32 addr )
data =fetch16(addr+2);
data<<=16;
data|=fetch16(addr+0);
DO_DBUG(statusMsg << "fetch32(" << HEX8 << addr << ")=" << HEX8 << data << endl);
DO_DBUG(statusMsg << "fetch32(" << Base::HEX8 << addr << ")=" << Base::HEX8 << data << endl);
return(data);
}
return fatalError("fetch32", addr, "abort");
@ -198,7 +200,7 @@ void Thumbulator::write16 ( uInt32 addr, uInt32 data )
writes++;
DO_DBUG(statusMsg << "write16(" << HEX8 << addr << "," << HEX8 << data << ")" << endl);
DO_DBUG(statusMsg << "write16(" << Base::HEX8 << addr << "," << Base::HEX8 << data << ")" << endl);
switch(addr&0xF0000000)
{
@ -215,7 +217,7 @@ void Thumbulator::write16 ( uInt32 addr, uInt32 data )
case 0xE0000000: //MAMCR
if(addr == 0xE01FC000)
{
DO_DBUG(statusMsg << "write16(" << HEX8 << "MAMCR" << "," << HEX8 << data << ") *" << endl);
DO_DBUG(statusMsg << "write16(" << Base::HEX8 << "MAMCR" << "," << Base::HEX8 << data << ") *" << endl);
mamcr = data;
return;
}
@ -229,7 +231,7 @@ void Thumbulator::write32 ( uInt32 addr, uInt32 data )
if(addr&3)
fatalError("write32", addr, "abort - misaligned");
DO_DBUG(statusMsg << "write32(" << HEX8 << addr << "," << HEX8 << data << ")" << endl);
DO_DBUG(statusMsg << "write32(" << Base::HEX8 << addr << "," << Base::HEX8 << data << ")" << endl);
switch(addr&0xF0000000)
{
@ -247,7 +249,7 @@ void Thumbulator::write32 ( uInt32 addr, uInt32 data )
return;
case 0xD0000000: //debug
statusMsg << "[" << HEX8 << read_register(14) << "]["
statusMsg << "[" << Base::HEX8 << read_register(14) << "]["
<< addr << "] " << data << endl;
return;
@ -283,7 +285,7 @@ uInt32 Thumbulator::read16 ( uInt32 addr )
#else
data=rom[addr];
#endif
DO_DBUG(statusMsg << "read16(" << HEX8 << addr << ")=" << HEX4 << data << endl);
DO_DBUG(statusMsg << "read16(" << Base::HEX8 << addr << ")=" << Base::HEX4 << data << endl);
return(data);
case 0x40000000: //RAM
@ -294,7 +296,7 @@ uInt32 Thumbulator::read16 ( uInt32 addr )
#else
data=ram[addr];
#endif
DO_DBUG(statusMsg << "read16(" << HEX8 << addr << ")=" << HEX4 << data << endl);
DO_DBUG(statusMsg << "read16(" << Base::HEX8 << addr << ")=" << Base::HEX4 << data << endl);
return(data);
case 0xE0000000: //MAMCR
@ -321,7 +323,7 @@ uInt32 Thumbulator::read32 ( uInt32 addr )
data =read16(addr+2);
data<<=16;
data|=read16(addr+0);
DO_DBUG(statusMsg << "read32(" << HEX8 << addr << ")=" << HEX8 << data << endl);
DO_DBUG(statusMsg << "read32(" << Base::HEX8 << addr << ")=" << Base::HEX8 << data << endl);
return(data);
}
return fatalError("read32", addr, "abort");
@ -341,7 +343,7 @@ uInt32 Thumbulator::read_register ( uInt32 reg )
default: data=reg_sys[reg]; break;
case 13: case 14: data=reg_svc[reg]; break;
}
DO_DBUG(statusMsg << "read_register(" << dec << reg << ")=" << HEX8 << data << endl);
DO_DBUG(statusMsg << "read_register(" << dec << reg << ")=" << Base::HEX8 << data << endl);
return(data);
}
return fatalError("read_register", cpsr, "invalid cpsr mode");
@ -352,7 +354,7 @@ uInt32 Thumbulator::write_register ( uInt32 reg, uInt32 data )
{
reg&=0xF;
DO_DBUG(statusMsg << "write_register(" << dec << reg << "," << HEX8 << data << ")" << endl);
DO_DBUG(statusMsg << "write_register(" << dec << reg << "," << Base::HEX8 << data << ")" << endl);
switch(cpsr&0x1F)
{
case MODE_SVC:
@ -446,7 +448,7 @@ int Thumbulator::execute ( void )
inst=fetch16(pc-2);
pc+=2;
write_register(15,pc);
DO_DISS(statusMsg << HEX8 << (pc-5) << ": " << HEX4 << inst << " ");
DO_DISS(statusMsg << Base::HEX8 << (pc-5) << ": " << Base::HEX4 << inst << " ");
instructions++;
@ -479,7 +481,7 @@ int Thumbulator::execute ( void )
if(rb)
{
DO_DISS(statusMsg << "adds r" << dec << rd << ",r" << dec << rn << ","
<< "#0x" << HEX2 << rb << endl);
<< "#0x" << Base::HEX2 << rb << endl);
ra=read_register(rn);
rc=ra+rb;
//fprintf(stderr,"0x%08X = 0x%08X + 0x%08X\n",rc,ra,rb);
@ -501,7 +503,7 @@ int Thumbulator::execute ( void )
{
rb=(inst>>0)&0xFF;
rd=(inst>>8)&0x7;
DO_DISS(statusMsg << "adds r" << dec << rd << ",#0x" << HEX2 << rb << endl);
DO_DISS(statusMsg << "adds r" << dec << rd << ",#0x" << Base::HEX2 << rb << endl);
ra=read_register(rd);
rc=ra+rb;
write_register(rd,rc);
@ -555,7 +557,7 @@ int Thumbulator::execute ( void )
rb=(inst>>0)&0xFF;
rd=(inst>>8)&0x7;
rb<<=2;
DO_DISS(statusMsg << "add r" << dec << rd << ",PC,#0x" << HEX2 << rb << endl);
DO_DISS(statusMsg << "add r" << dec << rd << ",PC,#0x" << Base::HEX2 << rb << endl);
ra=read_register(15);
rc=(ra&(~3))+rb;
write_register(rd,rc);
@ -568,7 +570,7 @@ int Thumbulator::execute ( void )
rb=(inst>>0)&0xFF;
rd=(inst>>8)&0x7;
rb<<=2;
DO_DISS(statusMsg << "add r" << dec << rd << ",SP,#0x" << HEX2 << rb << endl);
DO_DISS(statusMsg << "add r" << dec << rd << ",SP,#0x" << Base::HEX2 << rb << endl);
ra=read_register(13);
rc=ra+rb;
write_register(rd,rc);
@ -580,7 +582,7 @@ int Thumbulator::execute ( void )
{
rb=(inst>>0)&0x7F;
rb<<=2;
DO_DISS(statusMsg << "add SP,#0x" << HEX2 << rb << endl);
DO_DISS(statusMsg << "add SP,#0x" << Base::HEX2 << rb << endl);
ra=read_register(13);
rc=ra+rb;
write_register(13,rc);
@ -608,7 +610,7 @@ int Thumbulator::execute ( void )
rd=(inst>>0)&0x07;
rm=(inst>>3)&0x07;
rb=(inst>>6)&0x1F;
DO_DISS(statusMsg << "asrs r" << dec << rd << ",r" << dec << rm << ",#0x" << HEX2 << rb << endl);
DO_DISS(statusMsg << "asrs r" << dec << rd << ",r" << dec << rm << ",#0x" << Base::HEX2 << rb << endl);
rc=read_register(rm);
if(rb==0)
{
@ -693,7 +695,7 @@ int Thumbulator::execute ( void )
switch(op)
{
case 0x0: //b eq z set
DO_DISS(statusMsg << "beq 0x" << HEX8 << (rb-3) << endl);
DO_DISS(statusMsg << "beq 0x" << Base::HEX8 << (rb-3) << endl);
if(cpsr&CPSR_Z)
{
write_register(15,rb);
@ -701,7 +703,7 @@ int Thumbulator::execute ( void )
return(0);
case 0x1: //b ne z clear
DO_DISS(statusMsg << "bne 0x" << HEX8 << (rb-3) << endl);
DO_DISS(statusMsg << "bne 0x" << Base::HEX8 << (rb-3) << endl);
if(!(cpsr&CPSR_Z))
{
write_register(15,rb);
@ -709,7 +711,7 @@ int Thumbulator::execute ( void )
return(0);
case 0x2: //b cs c set
DO_DISS(statusMsg << "bcs 0x" << HEX8 << (rb-3) << endl);
DO_DISS(statusMsg << "bcs 0x" << Base::HEX8 << (rb-3) << endl);
if(cpsr&CPSR_C)
{
write_register(15,rb);
@ -717,7 +719,7 @@ int Thumbulator::execute ( void )
return(0);
case 0x3: //b cc c clear
DO_DISS(statusMsg << "bcc 0x" << HEX8 << (rb-3) << endl);
DO_DISS(statusMsg << "bcc 0x" << Base::HEX8 << (rb-3) << endl);
if(!(cpsr&CPSR_C))
{
write_register(15,rb);
@ -725,7 +727,7 @@ int Thumbulator::execute ( void )
return(0);
case 0x4: //b mi n set
DO_DISS(statusMsg << "bmi 0x" << HEX8 << (rb-3) << endl);
DO_DISS(statusMsg << "bmi 0x" << Base::HEX8 << (rb-3) << endl);
if(cpsr&CPSR_N)
{
write_register(15,rb);
@ -733,7 +735,7 @@ int Thumbulator::execute ( void )
return(0);
case 0x5: //b pl n clear
DO_DISS(statusMsg << "bpl 0x" << HEX8 << (rb-3) << endl);
DO_DISS(statusMsg << "bpl 0x" << Base::HEX8 << (rb-3) << endl);
if(!(cpsr&CPSR_N))
{
write_register(15,rb);
@ -741,7 +743,7 @@ int Thumbulator::execute ( void )
return(0);
case 0x6: //b vs v set
DO_DISS(statusMsg << "bvs 0x" << HEX8 << (rb-3) << endl);
DO_DISS(statusMsg << "bvs 0x" << Base::HEX8 << (rb-3) << endl);
if(cpsr&CPSR_V)
{
write_register(15,rb);
@ -749,7 +751,7 @@ int Thumbulator::execute ( void )
return(0);
case 0x7: //b vc v clear
DO_DISS(statusMsg << "bvc 0x" << HEX8 << (rb-3) << endl);
DO_DISS(statusMsg << "bvc 0x" << Base::HEX8 << (rb-3) << endl);
if(!(cpsr&CPSR_V))
{
write_register(15,rb);
@ -757,7 +759,7 @@ int Thumbulator::execute ( void )
return(0);
case 0x8: //b hi c set z clear
DO_DISS(statusMsg << "bhi 0x" << HEX8 << (rb-3) << endl);
DO_DISS(statusMsg << "bhi 0x" << Base::HEX8 << (rb-3) << endl);
if((cpsr&CPSR_C)&&(!(cpsr&CPSR_Z)))
{
write_register(15,rb);
@ -765,7 +767,7 @@ int Thumbulator::execute ( void )
return(0);
case 0x9: //b ls c clear or z set
DO_DISS(statusMsg << "bls 0x" << HEX8 << (rb-3) << endl);
DO_DISS(statusMsg << "bls 0x" << Base::HEX8 << (rb-3) << endl);
if((cpsr&CPSR_Z)||(!(cpsr&CPSR_C)))
{
write_register(15,rb);
@ -773,7 +775,7 @@ int Thumbulator::execute ( void )
return(0);
case 0xA: //b ge N == V
DO_DISS(statusMsg << "bge 0x" << HEX8 << (rb-3) << endl);
DO_DISS(statusMsg << "bge 0x" << Base::HEX8 << (rb-3) << endl);
ra=0;
if( (cpsr&CPSR_N) && (cpsr&CPSR_V) ) ra++;
if((!(cpsr&CPSR_N))&&(!(cpsr&CPSR_V))) ra++;
@ -784,7 +786,7 @@ int Thumbulator::execute ( void )
return(0);
case 0xB: //b lt N != V
DO_DISS(statusMsg << "blt 0x" << HEX8 << (rb-3) << endl);
DO_DISS(statusMsg << "blt 0x" << Base::HEX8 << (rb-3) << endl);
ra=0;
if((!(cpsr&CPSR_N))&&(cpsr&CPSR_V)) ra++;
if((!(cpsr&CPSR_V))&&(cpsr&CPSR_N)) ra++;
@ -795,7 +797,7 @@ int Thumbulator::execute ( void )
return(0);
case 0xC: //b gt Z==0 and N == V
DO_DISS(statusMsg << "bgt 0x" << HEX8 << (rb-3) << endl);
DO_DISS(statusMsg << "bgt 0x" << Base::HEX8 << (rb-3) << endl);
ra=0;
if( (cpsr&CPSR_N) && (cpsr&CPSR_V) ) ra++;
if((!(cpsr&CPSR_N))&&(!(cpsr&CPSR_V))) ra++;
@ -807,7 +809,7 @@ int Thumbulator::execute ( void )
return(0);
case 0xD: //b le Z==1 or N != V
DO_DISS(statusMsg << "ble 0x" << HEX8 << (rb-3) << endl);
DO_DISS(statusMsg << "ble 0x" << Base::HEX8 << (rb-3) << endl);
ra=0;
if((!(cpsr&CPSR_N))&&(cpsr&CPSR_V)) ra++;
if((!(cpsr&CPSR_V))&&(cpsr&CPSR_N)) ra++;
@ -837,7 +839,7 @@ int Thumbulator::execute ( void )
rb<<=1;
rb+=pc;
rb+=2;
DO_DISS(statusMsg << "B 0x" << HEX8 << (rb-3) << endl);
DO_DISS(statusMsg << "B 0x" << Base::HEX8 << (rb-3) << endl);
write_register(15,rb);
return(0);
}
@ -861,7 +863,7 @@ int Thumbulator::execute ( void )
if((inst&0xFF00)==0xBE00)
{
rb=(inst>>0)&0xFF;
statusMsg << "bkpt 0x" << HEX2 << rb << endl;
statusMsg << "bkpt 0x" << Base::HEX2 << rb << endl;
return(1);
}
@ -884,7 +886,7 @@ int Thumbulator::execute ( void )
rb|=inst&((1<<11)-1);
rb<<=1;
rb+=pc;
DO_DISS(statusMsg << "bl 0x" << HEX8 << (rb-3) << endl);
DO_DISS(statusMsg << "bl 0x" << Base::HEX8 << (rb-3) << endl);
write_register(14,pc-2);
write_register(15,rb);
return(0);
@ -961,7 +963,7 @@ int Thumbulator::execute ( void )
{
rb=(inst>>0)&0xFF;
rn=(inst>>8)&0x07;
DO_DISS(statusMsg << "cmp r" << dec << rn << ",#0x" << HEX2 << rb << endl);
DO_DISS(statusMsg << "cmp r" << dec << rn << ",#0x" << Base::HEX2 << rb << endl);
ra=read_register(rn);
rc=ra-rb;
//fprintf(stderr,"0x%08X 0x%08X\n",ra,rb);
@ -1017,7 +1019,7 @@ int Thumbulator::execute ( void )
if(cpsr&CPSR_Z) statusMsg << "Z"; else statusMsg << "z";
if(cpsr&CPSR_C) statusMsg << "C"; else statusMsg << "c";
if(cpsr&CPSR_V) statusMsg << "V"; else statusMsg << "v";
statusMsg << " -- 0x" << HEX8 << ra << " 0x" << HEX8 << rb << endl;
statusMsg << " -- 0x" << Base::HEX8 << ra << " 0x" << Base::HEX8 << rb << endl;
#endif
return(0);
}
@ -1094,7 +1096,7 @@ int Thumbulator::execute ( void )
rn=(inst>>3)&0x07;
rb=(inst>>6)&0x1F;
rb<<=2;
DO_DISS(statusMsg << "ldr r" << dec << rd << ",[r" << dec << rn << ",#0x" << HEX2 << rb << "]" << endl);
DO_DISS(statusMsg << "ldr r" << dec << rd << ",[r" << dec << rn << ",#0x" << Base::HEX2 << rb << "]" << endl);
rb=read_register(rn)+rb;
rc=read32(rb);
write_register(rd,rc);
@ -1120,11 +1122,11 @@ int Thumbulator::execute ( void )
rb=(inst>>0)&0xFF;
rd=(inst>>8)&0x07;
rb<<=2;
DO_DISS(statusMsg << "ldr r" << dec << rd << ",[PC+#0x" << HEX2 << rb << "] ");
DO_DISS(statusMsg << "ldr r" << dec << rd << ",[PC+#0x" << Base::HEX2 << rb << "] ");
ra=read_register(15);
ra&=~3;
rb+=ra;
DO_DISS(statusMsg << ";@ 0x" << HEX2 << rb << endl);
DO_DISS(statusMsg << ";@ 0x" << Base::HEX2 << rb << endl);
rc=read32(rb);
write_register(rd,rc);
return(0);
@ -1136,7 +1138,7 @@ int Thumbulator::execute ( void )
rb=(inst>>0)&0xFF;
rd=(inst>>8)&0x07;
rb<<=2;
DO_DISS(statusMsg << "ldr r" << dec << rd << ",[SP+#0x" << HEX2 << rb << "]" << endl);
DO_DISS(statusMsg << "ldr r" << dec << rd << ",[SP+#0x" << Base::HEX2 << rb << "]" << endl);
ra=read_register(13);
//ra&=~3;
rb+=ra;
@ -1151,7 +1153,7 @@ int Thumbulator::execute ( void )
rd=(inst>>0)&0x07;
rn=(inst>>3)&0x07;
rb=(inst>>6)&0x1F;
DO_DISS(statusMsg << "ldrb r" << dec << rd << ",[r" << dec << rn << ",#0x" << HEX2 << rb << "]" << endl);
DO_DISS(statusMsg << "ldrb r" << dec << rd << ",[r" << dec << rn << ",#0x" << Base::HEX2 << rb << "]" << endl);
rb=read_register(rn)+rb;
rc=read16(rb&(~1));
if(rb&1)
@ -1192,7 +1194,7 @@ int Thumbulator::execute ( void )
rn=(inst>>3)&0x07;
rb=(inst>>6)&0x1F;
rb<<=1;
DO_DISS(statusMsg << "ldrh r" << dec << rd << ",[r" << dec << rn << ",#0x" << HEX2 << rb << "]" << endl);
DO_DISS(statusMsg << "ldrh r" << dec << rd << ",[r" << dec << rn << ",#0x" << Base::HEX2 << rb << "]" << endl);
rb=read_register(rn)+rb;
rc=read16(rb);
write_register(rd,rc&0xFFFF);
@ -1255,7 +1257,7 @@ int Thumbulator::execute ( void )
rd=(inst>>0)&0x07;
rm=(inst>>3)&0x07;
rb=(inst>>6)&0x1F;
DO_DISS(statusMsg << "lsls r" << dec << rd << ",r" << dec << rm << ",#0x" << HEX2 << rb << endl);
DO_DISS(statusMsg << "lsls r" << dec << rd << ",r" << dec << rm << ",#0x" << Base::HEX2 << rb << endl);
rc=read_register(rm);
if(rb==0)
{
@ -1314,7 +1316,7 @@ int Thumbulator::execute ( void )
rd=(inst>>0)&0x07;
rm=(inst>>3)&0x07;
rb=(inst>>6)&0x1F;
DO_DISS(statusMsg << "lsrs r" << dec << rd << ",r" << dec << rm << ",#0x" << HEX2 << rb << endl);
DO_DISS(statusMsg << "lsrs r" << dec << rd << ",r" << dec << rm << ",#0x" << Base::HEX2 << rb << endl);
rc=read_register(rm);
if(rb==0)
{
@ -1370,7 +1372,7 @@ int Thumbulator::execute ( void )
{
rb=(inst>>0)&0xFF;
rd=(inst>>8)&0x07;
DO_DISS(statusMsg << "movs r" << dec << rd << ",#0x" << HEX2 << rb << endl);
DO_DISS(statusMsg << "movs r" << dec << rd << ",#0x" << Base::HEX2 << rb << endl);
write_register(rd,rb);
do_nflag(rb);
do_zflag(rb);
@ -1700,7 +1702,7 @@ int Thumbulator::execute ( void )
rn=(inst>>3)&0x07;
rb=(inst>>6)&0x1F;
rb<<=2;
DO_DISS(statusMsg << "str r" << dec << rd << ",[r" << dec << rn << ",#0x" << HEX2 << rb << "]" << endl);
DO_DISS(statusMsg << "str r" << dec << rd << ",[r" << dec << rn << ",#0x" << Base::HEX2 << rb << "]" << endl);
rb=read_register(rn)+rb;
rc=read_register(rd);
write32(rb,rc);
@ -1726,7 +1728,7 @@ int Thumbulator::execute ( void )
rb=(inst>>0)&0xFF;
rd=(inst>>8)&0x07;
rb<<=2;
DO_DISS(statusMsg << "str r" << dec << rd << ",[SP,#0x" << HEX2 << rb << "]" << endl);
DO_DISS(statusMsg << "str r" << dec << rd << ",[SP,#0x" << Base::HEX2 << rb << "]" << endl);
rb=read_register(13)+rb;
//fprintf(stderr,"0x%08X\n",rb);
rc=read_register(rd);
@ -1740,7 +1742,7 @@ int Thumbulator::execute ( void )
rd=(inst>>0)&0x07;
rn=(inst>>3)&0x07;
rb=(inst>>6)&0x1F;
DO_DISS(statusMsg << "strb r" << dec << rd << ",[r" << dec << rn << ",#0x" << HEX8 << rb << "]" << endl);
DO_DISS(statusMsg << "strb r" << dec << rd << ",[r" << dec << rn << ",#0x" << Base::HEX8 << rb << "]" << endl);
rb=read_register(rn)+rb;
rc=read_register(rd);
ra=read16(rb&(~1));
@ -1789,7 +1791,7 @@ int Thumbulator::execute ( void )
rn=(inst>>3)&0x07;
rb=(inst>>6)&0x1F;
rb<<=1;
DO_DISS(statusMsg << "strh r" << dec << rd << ",[r" << dec << rn << ",#0x" << HEX2 << rb << "]" << endl);
DO_DISS(statusMsg << "strh r" << dec << rd << ",[r" << dec << rn << ",#0x" << Base::HEX2 << rb << "]" << endl);
rb=read_register(rn)+rb;
rc=read_register(rd);
write16(rb,rc&0xFFFF);
@ -1815,7 +1817,7 @@ int Thumbulator::execute ( void )
rd=(inst>>0)&7;
rn=(inst>>3)&7;
rb=(inst>>6)&7;
DO_DISS(statusMsg << "subs r" << dec << rd << ",r" << dec << rn << ",#0x" << HEX2 << rb << endl);
DO_DISS(statusMsg << "subs r" << dec << rd << ",r" << dec << rn << ",#0x" << Base::HEX2 << rb << endl);
ra=read_register(rn);
rc=ra-rb;
write_register(rd,rc);
@ -1831,7 +1833,7 @@ int Thumbulator::execute ( void )
{
rb=(inst>>0)&0xFF;
rd=(inst>>8)&0x07;
DO_DISS(statusMsg << "subs r" << dec << rd << ",#0x" << HEX2 << rb << endl);
DO_DISS(statusMsg << "subs r" << dec << rd << ",#0x" << Base::HEX2 << rb << endl);
ra=read_register(rd);
rc=ra-rb;
write_register(rd,rc);
@ -1865,7 +1867,7 @@ int Thumbulator::execute ( void )
{
rb=inst&0x7F;
rb<<=2;
DO_DISS(statusMsg << "sub SP,#0x" << HEX2 << rb << endl);
DO_DISS(statusMsg << "sub SP,#0x" << Base::HEX2 << rb << endl);
ra=read_register(13);
ra-=rb;
write_register(13,ra);
@ -1876,8 +1878,8 @@ int Thumbulator::execute ( void )
if((inst&0xFF00)==0xDF00)
{
rb=inst&0xFF;
DO_DISS(statusMsg << "swi 0x" << HEX2 << rb << endl);
statusMsg << endl << endl << "swi 0x" << HEX2 << rb << endl;
DO_DISS(statusMsg << "swi 0x" << Base::HEX2 << rb << endl);
statusMsg << endl << endl << "swi 0x" << Base::HEX2 << rb << endl;
return(1);
}
@ -1945,7 +1947,7 @@ int Thumbulator::execute ( void )
return(0);
}
statusMsg << "invalid instruction " << HEX8 << pc << " " << HEX4 << inst << endl;
statusMsg << "invalid instruction " << Base::HEX8 << pc << " " << Base::HEX4 << inst << endl;
return(1);
}

View File

@ -23,6 +23,7 @@
//extern "C" {
//#endif
#include "Base.hxx"
#include "Expression.hxx"
#include "CartDebug.hxx"
#include "CpuDebug.hxx"
@ -107,21 +108,21 @@ inline bool is_operator(char x)
// responsibility, not the lexer's
int const_to_int(char *c) {
// what base is the input in?
BaseFormat base = Debugger::debugger().parser().base();
Common::Base::Format format = Common::Base::format();
switch(*c) {
case '\\':
base = kBASE_2;
format = Common::Base::F_2;
c++;
break;
case '#':
base = kBASE_10;
format = Common::Base::F_10;
c++;
break;
case '$':
base = kBASE_16;
format = Common::Base::F_16;
c++;
break;
@ -130,8 +131,8 @@ int const_to_int(char *c) {
}
int ret = 0;
switch(base) {
case kBASE_2:
switch(format) {
case Common::Base::F_2:
while(*c) {
if(*c != '0' && *c != '1')
return -1;
@ -141,7 +142,7 @@ int const_to_int(char *c) {
}
return ret;
case kBASE_10:
case Common::Base::F_10:
while(*c) {
if(!isdigit(*c))
return -1;
@ -151,7 +152,7 @@ int const_to_int(char *c) {
}
return ret;
case kBASE_16:
case Common::Base::F_16:
while(*c) { // FIXME: error check!
if(!isxdigit(*c))
return -1;