Added 'palette' debugger prompt command, which shows a colour swatch

of the currently active TIA palette.
This commit is contained in:
Stephen Anthony 2017-04-06 17:54:41 -02:30
parent 435608422b
commit 9736bdd3e8
6 changed files with 51 additions and 8 deletions

View File

@ -35,6 +35,8 @@
- The 'help' command now accepts other commands, and gives extra - The 'help' command now accepts other commands, and gives extra
information about the command (ie, 'help breakif' prints extended information about the command (ie, 'help breakif' prints extended
information about the breakif command) information about the breakif command)
- Added 'palette' command, which shows a color swatch of the
currently active TIA palette
- The previous trap'm' commands now work when setting TIA read - The previous trap'm' commands now work when setting TIA read
addresses; previously they only worked for write addresses addresses; previously they only worked for write addresses
- Command completion now works with internal functions and pseudo-ops - Command completion now works with internal functions and pseudo-ops

View File

@ -62,7 +62,11 @@ class Base
static void setHexUppercase(bool enable); static void setHexUppercase(bool enable);
static bool hexUppercase() { return myHexflags & std::ios_base::uppercase; } static bool hexUppercase() { return myHexflags & std::ios_base::uppercase; }
/** Output HEX digits in 1/2/4 byte format */ /** Output HEX digits in 0.5/1/2/4 byte format */
static inline std::ostream& HEX1(std::ostream& os) {
os.flags(myHexflags);
return os << std::setw(1);
}
static inline std::ostream& HEX2(std::ostream& os) { static inline std::ostream& HEX2(std::ostream& os) {
os.flags(myHexflags); os.flags(myHexflags);
return os << std::setw(2) << std::setfill('0'); return os << std::setw(2) << std::setfill('0');

View File

@ -1150,6 +1150,13 @@ void DebuggerParser::executeN()
debugger.cpuDebug().setN(args[0]); debugger.cpuDebug().setN(args[0]);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "palette"
void DebuggerParser::executePalette()
{
commandResult << debugger.tiaDebug().palette();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "pc" // "pc"
void DebuggerParser::executePc() void DebuggerParser::executePc()
@ -2033,6 +2040,16 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
std::mem_fn(&DebuggerParser::executeN) std::mem_fn(&DebuggerParser::executeN)
}, },
{
"palette",
"Show current TIA palette",
"Example: palette (no parameters)",
false,
false,
{ kARG_END_ARGS },
std::mem_fn(&DebuggerParser::executePalette)
},
{ {
"pc", "pc",
"Set Program Counter to address xx", "Set Program Counter to address xx",

View File

@ -68,7 +68,7 @@ class DebuggerParser
bool saveScriptFile(string file); bool saveScriptFile(string file);
private: private:
enum { kNumCommands = 70 }; enum { kNumCommands = 71 };
// Constants for argument processing // Constants for argument processing
enum { enum {
@ -152,6 +152,7 @@ class DebuggerParser
void executeLoadconfig(); void executeLoadconfig();
void executeLoadstate(); void executeLoadstate();
void executeN(); void executeN();
void executePalette();
void executePc(); void executePc();
void executePGfx(); void executePGfx();
void executePrint(); void executePrint();

View File

@ -695,7 +695,7 @@ shared_ptr<DelayQueueIterator> TIADebug::delayQueueIterator() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::colorSwatch(uInt8 c) string TIADebug::colorSwatch(uInt8 c) const
{ {
string ret; string ret;
@ -742,6 +742,24 @@ string TIADebug::booleanWithLabel(string label, bool value)
return "-" + label; return "-" + label;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::palette() const
{
ostringstream buf;
buf << " 0 2 4 6 8 A C E\n";
uInt8 c = 0;
for(uInt16 row = 0; row < 16; ++row)
{
buf << " " << Common::Base::HEX1 << row << " ";
for(uInt16 col = 0; col < 8; ++col, c += 2)
buf << colorSwatch(c);
buf << endl;
}
return buf.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::toString() string TIADebug::toString()
{ {
@ -776,11 +794,11 @@ string TIADebug::toString()
<< "COLUxx: " << "COLUxx: "
<< "P0=$" << Common::Base::HEX2 << state.coluRegs[0] << "/" << "P0=$" << Common::Base::HEX2 << state.coluRegs[0] << "/"
<< colorSwatch(state.coluRegs[0]) << colorSwatch(state.coluRegs[0])
<< "P1=$" << Common::Base::HEX2 << state.coluRegs[1] << "/" << " P1=$" << Common::Base::HEX2 << state.coluRegs[1] << "/"
<< colorSwatch(state.coluRegs[1]) << colorSwatch(state.coluRegs[1])
<< "PF=$" << Common::Base::HEX2 << state.coluRegs[2] << "/" << " PF=$" << Common::Base::HEX2 << state.coluRegs[2] << "/"
<< colorSwatch(state.coluRegs[2]) << colorSwatch(state.coluRegs[2])
<< "BK=$" << Common::Base::HEX2 << state.coluRegs[3] << "/" << " BK=$" << Common::Base::HEX2 << state.coluRegs[3] << "/"
<< colorSwatch(state.coluRegs[3]) << colorSwatch(state.coluRegs[3])
<< endl << endl
<< "P0: GR=%" << Common::Base::toString(state.gr[P0], Common::Base::F_2_8) << "P0: GR=%" << Common::Base::toString(state.gr[P0], Common::Base::F_2_8)

View File

@ -59,6 +59,7 @@ class TIADebug : public DebuggerSystem
void saveOldState() override; void saveOldState() override;
string toString() override; string toString() override;
string palette() const;
// TIA byte (or part of a byte) registers // TIA byte (or part of a byte) registers
uInt8 nusiz0(int newVal = -1); uInt8 nusiz0(int newVal = -1);
@ -139,7 +140,7 @@ class TIADebug : public DebuggerSystem
// TIA strobe registers // TIA strobe registers
void strobeWsync() { mySystem.poke(WSYNC, 0); } void strobeWsync() { mySystem.poke(WSYNC, 0); }
void strobeRsync() { mySystem.poke(RSYNC, 0); } // not emulated! void strobeRsync() { mySystem.poke(RSYNC, 0); }
void strobeResP0() { mySystem.poke(RESP0, 0); } void strobeResP0() { mySystem.poke(RESP0, 0); }
void strobeResP1() { mySystem.poke(RESP1, 0); } void strobeResP1() { mySystem.poke(RESP1, 0); }
void strobeResM0() { mySystem.poke(RESM0, 0); } void strobeResM0() { mySystem.poke(RESM0, 0); }
@ -162,7 +163,7 @@ class TIADebug : public DebuggerSystem
private: private:
/** Display a color patch for color at given index in the palette */ /** Display a color patch for color at given index in the palette */
string colorSwatch(uInt8 c); string colorSwatch(uInt8 c) const;
/** Get specific bits in the collision register (used by collXX_XX) */ /** Get specific bits in the collision register (used by collXX_XX) */
bool collision(CollisionBit id) const; bool collision(CollisionBit id) const;