From 9736bdd3e854ec9f1333f2abfddf36a2257cc991 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Thu, 6 Apr 2017 17:54:41 -0230 Subject: [PATCH] Added 'palette' debugger prompt command, which shows a colour swatch of the currently active TIA palette. --- Changes.txt | 2 ++ src/common/Base.hxx | 6 +++++- src/debugger/DebuggerParser.cxx | 17 +++++++++++++++++ src/debugger/DebuggerParser.hxx | 3 ++- src/debugger/TIADebug.cxx | 26 ++++++++++++++++++++++---- src/debugger/TIADebug.hxx | 5 +++-- 6 files changed, 51 insertions(+), 8 deletions(-) diff --git a/Changes.txt b/Changes.txt index 85ba25b7e..94dfdb579 100644 --- a/Changes.txt +++ b/Changes.txt @@ -35,6 +35,8 @@ - The 'help' command now accepts other commands, and gives extra information about the command (ie, 'help breakif' prints extended 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 addresses; previously they only worked for write addresses - Command completion now works with internal functions and pseudo-ops diff --git a/src/common/Base.hxx b/src/common/Base.hxx index 6dbdfbd3c..eceb68db6 100644 --- a/src/common/Base.hxx +++ b/src/common/Base.hxx @@ -62,7 +62,11 @@ class Base static void setHexUppercase(bool enable); 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) { os.flags(myHexflags); return os << std::setw(2) << std::setfill('0'); diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 6b52115e8..2a857011d 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -1150,6 +1150,13 @@ void DebuggerParser::executeN() debugger.cpuDebug().setN(args[0]); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "palette" +void DebuggerParser::executePalette() +{ + commandResult << debugger.tiaDebug().palette(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // "pc" void DebuggerParser::executePc() @@ -2033,6 +2040,16 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = { 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", "Set Program Counter to address xx", diff --git a/src/debugger/DebuggerParser.hxx b/src/debugger/DebuggerParser.hxx index 1320f82fb..6e36df4e0 100644 --- a/src/debugger/DebuggerParser.hxx +++ b/src/debugger/DebuggerParser.hxx @@ -68,7 +68,7 @@ class DebuggerParser bool saveScriptFile(string file); private: - enum { kNumCommands = 70 }; + enum { kNumCommands = 71 }; // Constants for argument processing enum { @@ -152,6 +152,7 @@ class DebuggerParser void executeLoadconfig(); void executeLoadstate(); void executeN(); + void executePalette(); void executePc(); void executePGfx(); void executePrint(); diff --git a/src/debugger/TIADebug.cxx b/src/debugger/TIADebug.cxx index 5cc23cac1..44608c359 100644 --- a/src/debugger/TIADebug.cxx +++ b/src/debugger/TIADebug.cxx @@ -695,7 +695,7 @@ shared_ptr TIADebug::delayQueueIterator() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string TIADebug::colorSwatch(uInt8 c) +string TIADebug::colorSwatch(uInt8 c) const { string ret; @@ -742,6 +742,24 @@ string TIADebug::booleanWithLabel(string label, bool value) 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() { @@ -776,11 +794,11 @@ string TIADebug::toString() << "COLUxx: " << "P0=$" << Common::Base::HEX2 << 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]) - << "PF=$" << Common::Base::HEX2 << state.coluRegs[2] << "/" + << " PF=$" << Common::Base::HEX2 << 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]) << endl << "P0: GR=%" << Common::Base::toString(state.gr[P0], Common::Base::F_2_8) diff --git a/src/debugger/TIADebug.hxx b/src/debugger/TIADebug.hxx index 0885601d2..bf0f2ed36 100644 --- a/src/debugger/TIADebug.hxx +++ b/src/debugger/TIADebug.hxx @@ -59,6 +59,7 @@ class TIADebug : public DebuggerSystem void saveOldState() override; string toString() override; + string palette() const; // TIA byte (or part of a byte) registers uInt8 nusiz0(int newVal = -1); @@ -139,7 +140,7 @@ class TIADebug : public DebuggerSystem // TIA strobe registers 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 strobeResP1() { mySystem.poke(RESP1, 0); } void strobeResM0() { mySystem.poke(RESM0, 0); } @@ -162,7 +163,7 @@ class TIADebug : public DebuggerSystem private: /** 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) */ bool collision(CollisionBit id) const;