From c9ab10952499cb80f85087751e80491b86c683e1 Mon Sep 17 00:00:00 2001
From: stephena <stephena@8b62c5a3-ac7e-4cc8-8f21-d9a121418aba>
Date: Thu, 11 Nov 2010 16:46:41 +0000
Subject: [PATCH] Converted several 'toString' methods to use stringstreams
 instead of multiple concatentation of strings.  This should be faster, or at
 least lead to less string constructor calls.

Output of 'ROW' directives in the disassembly now shows only 8 items per
line, instead of 16.  This allows to see all the bytes without having a
'...' in between.  A future release may customize this to the size of the
output area.

Fixed output from debugger 'disasm' command to properly align different
directive types and show GFX and PGFX output.

Bumped state file version to 3.3 final, since there are no further
changes to the code that will break the file format.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2183 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
---
 src/debugger/CartDebug.cxx        |  41 ++--
 src/debugger/CpuDebug.cxx         |   1 +
 src/debugger/DiStella.cxx         |   4 +-
 src/debugger/RiotDebug.cxx        |  83 ++++---
 src/debugger/TIADebug.cxx         | 297 ++++++++---------------
 src/debugger/gui/PromptWidget.cxx |   3 +-
 src/emucore/StateManager.cxx      |   4 +-
 src/gui/ConsoleFont.hxx           | 388 +++++++++++++++---------------
 8 files changed, 366 insertions(+), 455 deletions(-)

diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx
index 4b4ab396f..eb83eaaa1 100644
--- a/src/debugger/CartDebug.cxx
+++ b/src/debugger/CartDebug.cxx
@@ -155,8 +155,7 @@ int CartDebug::readFromWritePort()
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 string CartDebug::toString()
 {
-  string result;
-  char buf[128];
+  ostringstream buf;
   uInt32 bytesPerLine;
 
   switch(myDebugger.parser().base())
@@ -186,27 +185,26 @@ string CartDebug::toString()
     // bytes have been previously output
     if(state.rport[i] - curraddr > bytesPerLine || bytesSoFar >= 256)
     {
-      sprintf(buf, "%04x: (rport = %04x, wport = %04x)\n",
+      char port[50];
+      sprintf(port, "%04x: (rport = %04x, wport = %04x)\n",
               state.rport[i], state.rport[i], state.wport[i]);
-      buf[2] = buf[3] = 'x';
-      result += DebuggerParser::red(buf);
+      port[2] = port[3] = 'x';
+      buf << DebuggerParser::red(port);
       bytesSoFar = 0;
     }
     curraddr = state.rport[i];
-    sprintf(buf, "%.2x: ", curraddr & 0x00ff);
-    result += buf;
+    buf << HEX2 << (curraddr & 0x00ff) << ": ";
 
     for(uInt8 j = 0; j < bytesPerLine; ++j)
     {
-      result += myDebugger.invIfChanged(state.ram[i+j], oldstate.ram[i+j]);
-      result += " ";
+      buf << myDebugger.invIfChanged(state.ram[i+j], oldstate.ram[i+j]) << " ";
 
-      if(j == 0x07) result += " ";
+      if(j == 0x07) buf << " ";
     }
-    result += "\n";
+    buf << endl;
   }
 
-  return result;
+  return buf.str();
 }
 
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -317,9 +315,10 @@ string CartDebug::disassemble(uInt16 start, uInt16 lines) const
 {
   Disassembly disasm;
   BankInfo info;
+  uInt8 labels[0x1000], directives[0x1000];
   info.addressList.push_back(start);
-  DiStella distella(*this, disasm.list, info, (uInt8*)myDisLabels,
-                    (uInt8*)myDisDirectives, false);
+  DiStella distella(*this, disasm.list, info, (uInt8*)labels,
+                    (uInt8*)directives, false);
 
   // Fill the string with disassembled data
   start &= 0xFFF;
@@ -334,7 +333,8 @@ string CartDebug::disassemble(uInt16 start, uInt16 lines) const
     if((tag.address & 0xfff) >= start)
     {
       if(begin == list_size) begin = end;
-      length = BSPF_max(length, (uInt32)tag.disasm.length());
+      if(tag.type != CartDebug::ROW)
+        length = BSPF_max(length, (uInt32)tag.disasm.length());
 
       --lines;
     }
@@ -344,8 +344,15 @@ string CartDebug::disassemble(uInt16 start, uInt16 lines) const
   for(uInt32 i = begin; i < end; ++i)
   {
     const CartDebug::DisassemblyTag& tag = disasm.list[i];
-    buffer << uppercase << hex << setw(4) << setfill('0') << tag.address
-           << ":  " << tag.disasm << setw(length - tag.disasm.length() + 1)
+    if(tag.type == CartDebug::NONE)
+      continue;
+    else if(tag.address)
+      buffer << uppercase << hex << setw(4) << setfill('0') << tag.address
+           << ":  ";
+    else
+      buffer << "       ";
+
+    buffer << tag.disasm << setw(length - tag.disasm.length() + 1)
            << setfill(' ') << " "
            << tag.ccount << "   " << tag.bytes << endl;
   }
diff --git a/src/debugger/CpuDebug.cxx b/src/debugger/CpuDebug.cxx
index cf3e79b61..3f56ce6bd 100644
--- a/src/debugger/CpuDebug.cxx
+++ b/src/debugger/CpuDebug.cxx
@@ -75,6 +75,7 @@ void CpuDebug::saveOldState()
 string CpuDebug::toString()
 {
   // TODO - this doesn't seem to be used anywhere ??
+  //        if it's ever used, convert to C++ stringstream
   string result;
   char buf[255];
 
diff --git a/src/debugger/DiStella.cxx b/src/debugger/DiStella.cxx
index 40c7cf16c..f39f4593b 100644
--- a/src/debugger/DiStella.cxx
+++ b/src/debugger/DiStella.cxx
@@ -224,7 +224,7 @@ void DiStella::disasm(uInt32 distart, int pass)
           myDisasmBuf << HEX4 << myPC+myOffset << "'     '";
 
         bool isPGfx = check_bit(myPC, CartDebug::PGFX);
-        const string& bit_string = isPGfx ? "\x80" : "\x7f";
+        const string& bit_string = isPGfx ? "\x1f" : "\x1e";
         uInt8 byte = Debugger::debugger().peek(myPC+myOffset);
         myDisasmBuf << ".byte $" << HEX2 << (int)byte << "  |";
         for(uInt8 i = 0, c = byte; i < 8; ++i, c <<= 1)
@@ -275,7 +275,7 @@ void DiStella::disasm(uInt32 distart, int pass)
              && pass == 3 && myPC <= myAppData.end)
       {
         bytes++;
-        if (bytes == 17)
+        if (bytes == 9) // TODO - perhaps make this configurable to size of output area
         {
           addEntry(CartDebug::ROW);
           myDisasmBuf << "    '     '.byte $" << HEX2 << (int)Debugger::debugger().peek(myPC+myOffset);
diff --git a/src/debugger/RiotDebug.cxx b/src/debugger/RiotDebug.cxx
index 739edebfa..ae16954fb 100644
--- a/src/debugger/RiotDebug.cxx
+++ b/src/debugger/RiotDebug.cxx
@@ -315,55 +315,54 @@ string RiotDebug::switchesString()
 string RiotDebug::toString()
 {
   // TODO: keyboard controllers?
+  ostringstream buf;
 
   const RiotState& state    = (RiotState&) getState();
   const RiotState& oldstate = (RiotState&) getOldState();
-  string ret;
 
-  ret += myDebugger.valueToString(0x280) + "/SWCHA(R)=" +
-         myDebugger.invIfChanged(state.SWCHA_R, oldstate.SWCHA_R) + " ";
-  ret += myDebugger.valueToString(0x280) + "/SWCHA(W)=" +
-         myDebugger.invIfChanged(state.SWCHA_W, oldstate.SWCHA_W) + " ";
-  ret += myDebugger.valueToString(0x281) + "/SWACNT=" +
-         myDebugger.invIfChanged(state.SWACNT, oldstate.SWACNT) + " ";
-  ret += myDebugger.valueToString(0x282) + "/SWCHB=" +
-         myDebugger.invIfChanged(state.SWCHB, oldstate.SWCHB) + " ";
-  ret += "\n";
+  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="
+      << myDebugger.invIfChanged(state.SWCHB, oldstate.SWCHB) << " "
+      << endl
 
-  // These are squirrely: some symbol files will define these as
-  // 0x284-0x287. Doesn't actually matter, these registers repeat
-  // every 16 bytes.
-  ret += myDebugger.valueToString(0x294) + "/TIM1T=" +
-         myDebugger.invIfChanged(state.TIM1T, oldstate.TIM1T) + " ";
-  ret += myDebugger.valueToString(0x295) + "/TIM8T=" +
-         myDebugger.invIfChanged(state.TIM8T, oldstate.TIM8T) + " ";
-  ret += myDebugger.valueToString(0x296) + "/TIM64T=" +
-         myDebugger.invIfChanged(state.TIM64T, oldstate.TIM64T) + " ";
-  ret += myDebugger.valueToString(0x297) + "/TIM1024T=" +
-         myDebugger.invIfChanged(state.TIM1024T, oldstate.TIM1024T) + " ";
-  ret += "\n";
+      // 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) << " "
+      << endl
 
-  ret += myDebugger.valueToString(0x284) + "/INTIM=" +
-         myDebugger.invIfChanged(state.INTIM, oldstate.INTIM) + " ";
-  ret += myDebugger.valueToString(0x285) + "/TIMINT=" +
-         myDebugger.invIfChanged(state.TIMINT, oldstate.TIMINT) + " ";
-  ret += "Timer_Clocks=" +
-         myDebugger.invIfChanged(state.TIMCLKS, oldstate.TIMCLKS) + " ";
-  ret += "\n";
+      << 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) << " "
+      << endl
 
-  ret += "Left/P0diff: " + diffP0String() + "   Right/P1diff: " + diffP0String();
-  ret += "\n";
+      << "Left/P0diff: " << diffP0String() << "   Right/P1diff: " << diffP0String()
+      << endl
+      << "TVType: " << tvTypeString() << "   Switches: " << switchesString()
+      << endl
 
-  ret += "TVType: " + tvTypeString() + "   Switches: " + switchesString();
-  ret += "\n";
+      // Yes, the fire buttons are in the TIA, but we might as well
+      // show them here for convenience.
+      << "Left/P0 stick:  " << dirP0String()
+      << ((mySystem.peek(0x03c) & 0x80) ? "" : "(button) ")
+      << endl
+      << "Right/P1 stick: " << dirP1String()
+      << ((mySystem.peek(0x03d) & 0x80) ? "" : "(button) ");
 
-  // Yes, the fire buttons are in the TIA, but we might as well
-  // show them here for convenience.
-  ret += "Left/P0 stick:  " + dirP0String();
-  ret += (mySystem.peek(0x03c) & 0x80) ? "" : "(button) ";
-  ret += "\n";
-  ret += "Right/P1 stick: " + dirP1String();
-  ret += (mySystem.peek(0x03d) & 0x80) ? "" : "(button) ";
-
-  return ret;
+  return buf.str();
 }
diff --git a/src/debugger/TIADebug.cxx b/src/debugger/TIADebug.cxx
index 16c30345e..8beb3d0a1 100644
--- a/src/debugger/TIADebug.cxx
+++ b/src/debugger/TIADebug.cxx
@@ -735,20 +735,15 @@ string TIADebug::booleanWithLabel(string label, bool value)
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 string TIADebug::toString()
 {
-  string ret;
-  char buf[128];
+  ostringstream buf;
 
-  sprintf(buf, "%.2x: ", 0);
-  ret += buf;
+  buf << "00: ";
   for (uInt8 j = 0; j < 0x010; j++)
   {
-    sprintf(buf, "%.2x ", mySystem.peek(j));
-    ret += buf;
-
-    if(j == 0x07) ret += "- ";
+    buf << HEX2 << (int)mySystem.peek(j) << " ";
+    if(j == 0x07) buf << "- ";
   }
-
-  ret += "\n";
+  buf << endl;
 
   // TODO: inverse video for changed regs. Core needs to track this.
   // TODO: strobes? WSYNC RSYNC RESP0/1 RESM0/1 RESBL HMOVE HMCLR CXCLR
@@ -757,190 +752,100 @@ string TIADebug::toString()
 //  const TiaState& oldstate = (TiaState&) getOldState();
 
   // build up output, then return it.
-  ret += "scanline ";
-
-  ret += myDebugger.valueToString(myTIA.scanlines());
-  ret += " ";
-
-  ret += booleanWithLabel("vsync", vsync());
-  ret += " ";
-
-  ret += booleanWithLabel("vblank", vblank());
-  ret += "\n";
-
-  ret += booleanWithLabel("inpt0", myTIA.peek(0x08) & 0x80);
-  ret += " ";
-  ret += booleanWithLabel("inpt1", myTIA.peek(0x09) & 0x80);
-  ret += " ";
-  ret += booleanWithLabel("inpt2", myTIA.peek(0x0a) & 0x80);
-  ret += " ";
-  ret += booleanWithLabel("inpt3", myTIA.peek(0x0b) & 0x80);
-  ret += " ";
-  ret += booleanWithLabel("inpt4", myTIA.peek(0x0c) & 0x80);
-  ret += " ";
-  ret += booleanWithLabel("inpt5", myTIA.peek(0x0d) & 0x80);
-  ret += " ";
-  ret += booleanWithLabel("dump_gnd_0123", myTIA.myDumpEnabled);
-  ret += "\n";
-
-  ret += "COLUP0: ";
-  ret += myDebugger.valueToString(state.coluRegs[0]);
-  ret += "/";
-  ret += colorSwatch(state.coluRegs[0]);
-
-  ret += "COLUP1: ";
-  ret += myDebugger.valueToString(state.coluRegs[1]);
-  ret += "/";
-  ret += colorSwatch(state.coluRegs[1]);
-
-  ret += "COLUPF: ";
-  ret += myDebugger.valueToString(state.coluRegs[2]);
-  ret += "/";
-  ret += colorSwatch(state.coluRegs[2]);
-
-  ret += "COLUBK: ";
-  ret += myDebugger.valueToString(state.coluRegs[3]);
-  ret += "/";
-  ret += colorSwatch(state.coluRegs[3]);
-
-  ret += "\n";
-
-  ret += "P0: GR=";
-  ret += Debugger::to_bin_8(state.gr[P0]);
-  ret += "/";
-  ret += myDebugger.valueToString(state.gr[P0]);
-  ret += " pos=";
-  ret += myDebugger.valueToString(state.pos[P0]);
-  ret += " HM=";
-  ret += myDebugger.valueToString(state.hm[P0]);
-  ret += " ";
-  ret += nusizP0String();
-  ret += " ";
-  ret += booleanWithLabel("reflect", refP0());
-  ret += " ";
-  ret += booleanWithLabel("delay", vdelP0());
-  ret += "\n";
-
-  ret += "P1: GR=";
-  ret += Debugger::to_bin_8(state.gr[P1]);
-  ret += "/";
-  ret += myDebugger.valueToString(state.gr[P1]);
-  ret += " pos=";
-  ret += myDebugger.valueToString(state.pos[P1]);
-  ret += " HM=";
-  ret += myDebugger.valueToString(state.hm[P1]);
-  ret += " ";
-  ret += nusizP1String();
-  ret += " ";
-  ret += booleanWithLabel("reflect", refP1());
-  ret += " ";
-  ret += booleanWithLabel("delay", vdelP1());
-  ret += "\n";
-
-  ret += "M0: ";
-  ret += (myTIA.myENAM0 ? " ENABLED" : "disabled");
-  ret += " pos=";
-  ret += myDebugger.valueToString(state.pos[M0]);
-  ret += " HM=";
-  ret += myDebugger.valueToString(state.hm[M0]);
-  ret += " size=";
-  ret += myDebugger.valueToString(state.size[M0]);
-  ret += " ";
-  ret += booleanWithLabel("reset", resMP0());
-  ret += "\n";
-
-  ret += "M1: ";
-  ret += (myTIA.myENAM1 ? " ENABLED" : "disabled");
-  ret += " pos=";
-  ret += myDebugger.valueToString(state.pos[M1]);
-  ret += " HM=";
-  ret += myDebugger.valueToString(state.hm[M1]);
-  ret += " size=";
-  ret += myDebugger.valueToString(state.size[M1]);
-  ret += " ";
-  ret += booleanWithLabel("reset", resMP1());
-  ret += "\n";
-
-  ret += "BL: ";
-  ret += (myTIA.myENABL ? " ENABLED" : "disabled");
-  ret += " pos=";
-  ret += myDebugger.valueToString(state.pos[BL]);
-  ret += " HM=";
-  ret += myDebugger.valueToString(state.hm[BL]);
-  ret += " size=";
-  ret += myDebugger.valueToString(state.size[BL]);
-  ret += " ";
-  ret += booleanWithLabel("delay", vdelBL());
-  ret += "\n";
-
-  ret += "PF0: ";
-  ret += Debugger::to_bin_8(state.pf[0]);
-  ret += "/";
-  ret += myDebugger.valueToString(state.pf[0]);
-  ret += " PF1: ";
-  ret += Debugger::to_bin_8(state.pf[1]);
-  ret += "/";
-  ret += myDebugger.valueToString(state.pf[1]);
-  ret += " PF2: ";
-  ret += Debugger::to_bin_8(state.pf[2]);
-  ret += "/";
-  ret += myDebugger.valueToString(state.pf[2]);
-  ret += "\n     ";
-  ret += booleanWithLabel("reflect",  refPF());
-  ret += " ";
-  ret += booleanWithLabel("score",    scorePF());
-  ret += " ";
-  ret += booleanWithLabel("priority", priorityPF());
-  ret += "\n";
-
-  ret += "Collisions: ";
-  ret += booleanWithLabel("m0_p1 ", collM0_P1());
-  ret += booleanWithLabel("m0_p0 ", collM0_P0());
-  ret += booleanWithLabel("m1_p0 ", collM1_P0());
-  ret += booleanWithLabel("m1_p1 ", collM1_P1());
-  ret += booleanWithLabel("p0_pf ", collP0_PF());
-  ret += booleanWithLabel("p0_bl ", collP0_BL());
-  ret += booleanWithLabel("p1_pf ", collP1_PF());
-  ret += "\n            ";
-  ret += booleanWithLabel("p1_bl ", collP1_BL());
-  ret += booleanWithLabel("m0_pf ", collM0_PF());
-  ret += booleanWithLabel("m0_bl ", collM0_BL());
-  ret += booleanWithLabel("m1_pf ", collM1_PF());
-  ret += booleanWithLabel("m1_bl ", collM1_BL());
-  ret += booleanWithLabel("bl_pf ", collBL_PF());
-  ret += booleanWithLabel("p0_p1 ", collP0_P1());
-  ret += booleanWithLabel("m0_m1 ", collM0_M1());
-  ret += "\n";
-
-  ret += "AUDF0: ";
-  ret += myDebugger.valueToString(myTIA.myAUDF0);
-  ret += "/";
-  ret += audFreq(myTIA.myAUDF0);
-  ret += " ";
-
-  ret += "AUDC0: ";
-  ret += myDebugger.valueToString(myTIA.myAUDC0);
-  ret += " ";
-
-  ret += "AUDV0: ";
-  ret += myDebugger.valueToString(myTIA.myAUDV0);
-  ret += "\n";
-
-  ret += "AUDF1: ";
-  ret += myDebugger.valueToString(myTIA.myAUDF1);
-  ret += "/";
-  ret += audFreq(myTIA.myAUDF1);
-  ret += " ";
-
-  ret += "AUDC1: ";
-  ret += myDebugger.valueToString(myTIA.myAUDC1);
-  ret += " ";
-
-  ret += "AUDV1: ";
-  ret += myDebugger.valueToString(myTIA.myAUDV1);
-  //ret += "\n";
-
-  // note: last "ret +=" line should not contain \n, caller will add.
-
-  return ret;
+  buf << "scanline " << myDebugger.valueToString(myTIA.scanlines()) << " "
+      << booleanWithLabel("vsync", vsync()) << " "
+      << booleanWithLabel("vblank", vblank())
+      << endl
+      << booleanWithLabel("inpt0", myTIA.peek(0x08) & 0x80) << " "
+      << booleanWithLabel("inpt1", myTIA.peek(0x09) & 0x80) << " "
+      << booleanWithLabel("inpt2", myTIA.peek(0x0a) & 0x80) << " "
+      << booleanWithLabel("inpt3", myTIA.peek(0x0b) & 0x80) << " "
+      << booleanWithLabel("inpt4", myTIA.peek(0x0c) & 0x80) << " "
+      << booleanWithLabel("inpt5", myTIA.peek(0x0d) & 0x80) << " "
+      << booleanWithLabel("dump_gnd_0123", myTIA.myDumpEnabled)
+      << endl
+      << "COLUxx: "
+      << "P0=" << myDebugger.valueToString(state.coluRegs[0]) << "/"
+      << colorSwatch(state.coluRegs[0])
+      << "P1=" << myDebugger.valueToString(state.coluRegs[1]) << "/"
+      << colorSwatch(state.coluRegs[1])
+      << "PF=" << myDebugger.valueToString(state.coluRegs[2]) << "/"
+      << colorSwatch(state.coluRegs[2])
+      << "BK=" << myDebugger.valueToString(state.coluRegs[3]) << "/"
+      << colorSwatch(state.coluRegs[3])
+      << endl
+      << "P0: GR=" << string(Debugger::to_bin_8(state.gr[P0]))
+      << " pos=" << myDebugger.valueToString(state.pos[P0])
+      << " HM=" << myDebugger.valueToString(state.hm[P0]) << " "
+      << nusizP0String() << " "
+      << booleanWithLabel("refl", refP0()) << " "
+      << booleanWithLabel("delay", vdelP0())
+      << endl
+      << "P1: GR=" << string(Debugger::to_bin_8(state.gr[P1]))
+      << " pos=" << myDebugger.valueToString(state.pos[P1])
+      << " HM=" << myDebugger.valueToString(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]) << " "
+      << 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]) << " "
+      << 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]) << " "
+      << booleanWithLabel("delay", vdelBL())
+      << endl
+      << "PF0: " << string(Debugger::to_bin_8(state.pf[0])) << "/"
+      << myDebugger.valueToString(state.pf[0])
+      << " PF1: " << string(Debugger::to_bin_8(state.pf[1])) << "/"
+      << myDebugger.valueToString(state.pf[1])
+      << " PF2: " << string(Debugger::to_bin_8(state.pf[2])) << "/"
+      << myDebugger.valueToString(state.pf[2])
+      << endl << "     "
+      << booleanWithLabel("reflect",  refPF()) << " "
+      << booleanWithLabel("score",    scorePF()) << " "
+      << booleanWithLabel("priority", priorityPF())
+      << endl
+      << "Collisions: "
+      << booleanWithLabel("m0_p1 ", collM0_P1())
+      << booleanWithLabel("m0_p0 ", collM0_P0())
+      << booleanWithLabel("m1_p0 ", collM1_P0())
+      << booleanWithLabel("m1_p1 ", collM1_P1())
+      << booleanWithLabel("p0_pf ", collP0_PF())
+      << booleanWithLabel("p0_bl ", collP0_BL())
+      << booleanWithLabel("p1_pf ", collP1_PF())
+      << endl << "            "
+      << booleanWithLabel("p1_bl ", collP1_BL())
+      << booleanWithLabel("m0_pf ", collM0_PF())
+      << booleanWithLabel("m0_bl ", collM0_BL())
+      << booleanWithLabel("m1_pf ", collM1_PF())
+      << booleanWithLabel("m1_bl ", collM1_BL())
+      << booleanWithLabel("bl_pf ", collBL_PF())
+      << booleanWithLabel("p0_p1 ", collP0_P1())
+      << endl << "            "
+      << booleanWithLabel("m0_m1 ", collM0_M1())
+      << endl
+      << "AUDF0: " << myDebugger.valueToString(myTIA.myAUDF0)
+      << "/" << audFreq(myTIA.myAUDF0) << " "
+      << "AUDC0: " << myDebugger.valueToString(myTIA.myAUDC0) << " "
+      << "AUDV0: " << myDebugger.valueToString(myTIA.myAUDV0)
+      << endl
+      << "AUDF1: " << myDebugger.valueToString(myTIA.myAUDF1)
+      << "/" << audFreq(myTIA.myAUDF1) << " "
+      << "AUDC1: " << myDebugger.valueToString(myTIA.myAUDC1) << " "
+      << "AUDV1: " << myDebugger.valueToString(myTIA.myAUDV1)
+      ;
+  // note: last line should not contain \n, caller will add.
+  return buf.str();
 }
diff --git a/src/debugger/gui/PromptWidget.cxx b/src/debugger/gui/PromptWidget.cxx
index a585525f3..3d98fb95d 100644
--- a/src/debugger/gui/PromptWidget.cxx
+++ b/src/debugger/gui/PromptWidget.cxx
@@ -789,7 +789,8 @@ void PromptWidget::putcharIntern(int c)
                       // OverlayColor contains 256 of them
     _textcolor = (c & 0x7f) << 1;
   }
-  else if(c < ' ') { // More colors (the regular GUI ones)
+  else if(c < 0x1e) { // first actual character is large dash
+    // More colors (the regular GUI ones)
     _textcolor = c + 0x100;
   }
   else if(c == 0x7f) { // toggle inverse video (DEL char)
diff --git a/src/emucore/StateManager.cxx b/src/emucore/StateManager.cxx
index dc2b56a05..ca671b0c9 100644
--- a/src/emucore/StateManager.cxx
+++ b/src/emucore/StateManager.cxx
@@ -30,8 +30,8 @@
 
 #include "StateManager.hxx"
 
-#define STATE_HEADER "03031100state"
-#define MOVIE_HEADER "03031100movie"
+#define STATE_HEADER "03030000state"
+#define MOVIE_HEADER "03030000movie"
 
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 StateManager::StateManager(OSystem* osystem)
diff --git a/src/gui/ConsoleFont.hxx b/src/gui/ConsoleFont.hxx
index 24b2462aa..4442001be 100644
--- a/src/gui/ConsoleFont.hxx
+++ b/src/gui/ConsoleFont.hxx
@@ -34,7 +34,7 @@ namespace GUI {
    ascent: 11
    descent: 2
    first char: 0 (0x00)
-   last char: 128 (0x80)
+   last char: 126 (0x7e)
    default char: 0 (0x00)
    proportional: no
    Public domain font.  Share and enjoy.
@@ -75,6 +75,70 @@ static const uInt16 _console_font_bits[] = {
 0x0000,
 0x0000,
 
+/* Character 30 (0x1e): large centered rounded rectangle
+   width 8
+   +--------+
+   |  ****  |
+   | ****** |
+   | ****** |
+   | ****** |
+   | ****** |
+   | ****** |
+   | ****** |
+   | ****** |
+   | ****** |
+   | ****** |
+   | ****** |
+   | ****** |
+   |  ****  |
+   +--------+
+*/
+0x3c00,
+0x7e00,
+0x7e00,
+0x7e00,
+0x7e00,
+0x7e00,
+0x7e00,
+0x7e00,
+0x7e00,
+0x7e00,
+0x7e00,
+0x7e00,
+0x3c00,
+
+/* Character 31 (0x1f): large centered circle
+   width 8
+   +--------+
+   |        |
+   |        |
+   |        |
+   |        |
+   |        |
+   |  ****  |
+   | ****** |
+   | ****** |
+   |  ****  |
+   |        |
+   |        |
+   |        |
+   |        |
+   +--------+
+*/
+0x0000,
+0x0000,
+0x0000,
+0x0000,
+0x0000,
+0x3c00,
+0x7e00,
+0x7e00,
+0x3c00,
+0x0000,
+0x0000,
+0x0000,
+0x0000,
+
 /* Character 32 (0x20):
    width 8
    +--------+
@@ -3113,204 +3177,138 @@ static const uInt16 _console_font_bits[] = {
 0x0000,
 0x0000,
 0x0000,
-0x0000,
-
-/* Character 127 (0x7f): large centered rounded rectangle
-   width 8
-   +--------+
-   |  ****  |
-   | ****** |
-   | ****** |
-   | ****** |
-   | ****** |
-   | ****** |
-   | ****** |
-   | ****** |
-   | ****** |
-   | ****** |
-   | ****** |
-   | ****** |
-   |  ****  |
-   +--------+
-*/
-0x3c00,
-0x7e00,
-0x7e00,
-0x7e00,
-0x7e00,
-0x7e00,
-0x7e00,
-0x7e00,
-0x7e00,
-0x7e00,
-0x7e00,
-0x7e00,
-0x3c00,
-
-/* Character 128 (0x80): large centered circle
-   width 8
-   +--------+
-   |        |
-   |        |
-   |        |
-   |        |
-   |        |
-   |  ****  |
-   | ****** |
-   | ****** |
-   |  ****  |
-   |        |
-   |        |
-   |        |
-   |        |
-   +--------+
-*/
-0x0000,
-0x0000,
-0x0000,
-0x0000,
-0x0000,
-0x3c00,
-0x7e00,
-0x7e00,
-0x3c00,
-0x0000,
-0x0000,
-0x0000,
 0x0000
 };
 
 /* Character->glyph mapping. */
 static const uInt32 _console_sysfont_offset[] = {
-	13, /* (0x00) */
-	0,	/* (0x01) */
-	0,	/* (0x02) */
-	0,	/* (0x03) */
-	0,	/* (0x04) */
-	0,	/* (0x05) */
-	0,	/* (0x06) */
-	0,	/* (0x07) */
-	0,	/* (0x08) */
-	0,	/* (0x09) */
-	0,	/* (0x0a) */
-	0,	/* (0x0b) */
-	0,	/* (0x0c) */
-	0,	/* (0x0d) */
-	0,	/* (0x0e) */
-	0,	/* (0x0f) */
-	0,	/* (0x10) */
-	0,	/* (0x11) */
-	0,	/* (0x12) */
-	0,	/* (0x13) */
-	0,	/* (0x14) */
-	0,	/* (0x15) */
-	0,	/* (0x16) */
-	0,	/* (0x17) */
-	0,	/* (0x18) */
-	0,	/* (0x19) */
-	0,	/* (0x1a) */
-	0,	/* (0x1b) */
-	0,	/* (0x1c) */
-	0,	/* (0x1d) */
-	0,	/* (0x1e) */
-	0,	/* (0x1f) */
-	13,	/* (0x20) */
-	26,	/* (0x21) */
-	39,	/* (0x22) */
-	52,	/* (0x23) */
-	65,	/* (0x24) */
-	78,	/* (0x25) */
-	91,	/* (0x26) */
-	104,	/* (0x27) */
-	117,	/* (0x28) */
-	130,	/* (0x29) */
-	143,	/* (0x2a) */
-	156,	/* (0x2b) */
-	169,	/* (0x2c) */
-	182,	/* (0x2d) */
-	195,	/* (0x2e) */
-	208,	/* (0x2f) */
-	221,	/* (0x30) */
-	234,	/* (0x31) */
-	247,	/* (0x32) */
-	260,	/* (0x33) */
-	273,	/* (0x34) */
-	286,	/* (0x35) */
-	299,	/* (0x36) */
-	312,	/* (0x37) */
-	325,	/* (0x38) */
-	338,	/* (0x39) */
-	351,	/* (0x3a) */
-	364,	/* (0x3b) */
-	377,	/* (0x3c) */
-	390,	/* (0x3d) */
-	403,	/* (0x3e) */
-	416,	/* (0x3f) */
-	429,	/* (0x40) */
-	442,	/* (0x41) */
-	455,	/* (0x42) */
-	468,	/* (0x43) */
-	481,	/* (0x44) */
-	494,	/* (0x45) */
-	507,	/* (0x46) */
-	520,	/* (0x47) */
-	533,	/* (0x48) */
-	546,	/* (0x49) */
-	559,	/* (0x4a) */
-	572,	/* (0x4b) */
-	585,	/* (0x4c) */
-	598,	/* (0x4d) */
-	611,	/* (0x4e) */
-	624,	/* (0x4f) */
-	637,	/* (0x50) */
-	650,	/* (0x51) */
-	663,	/* (0x52) */
-	676,	/* (0x53) */
-	689,	/* (0x54) */
-	702,	/* (0x55) */
-	715,	/* (0x56) */
-	728,	/* (0x57) */
-	741,	/* (0x58) */
-	754,	/* (0x59) */
-	767,	/* (0x5a) */
-	780,	/* (0x5b) */
-	793,	/* (0x5c) */
-	806,	/* (0x5d) */
-	819,	/* (0x5e) */
-	832,	/* (0x5f) */
-	845,	/* (0x60) */
-	858,	/* (0x61) */
-	871,	/* (0x62) */
-	884,	/* (0x63) */
-	897,	/* (0x64) */
-	910,	/* (0x65) */
-	923,	/* (0x66) */
-	936,	/* (0x67) */
-	949,	/* (0x68) */
-	962,	/* (0x69) */
-	975,	/* (0x6a) */
-	988,	/* (0x6b) */
-	1001,	/* (0x6c) */
-	1014,	/* (0x6d) */
-	1027,	/* (0x6e) */
-	1040,	/* (0x6f) */
-	1053,	/* (0x70) */
-	1066,	/* (0x71) */
-	1079,	/* (0x72) */
-	1092,	/* (0x73) */
-	1105,	/* (0x74) */
-	1118,	/* (0x75) */
-	1131,	/* (0x76) */
-	1144,	/* (0x77) */
-	1157,	/* (0x78) */
-	1170,	/* (0x79) */
-	1183,	/* (0x7a) */
-	1196,	/* (0x7b) */
-	1209,	/* (0x7c) */
-	1222,	/* (0x7d) */
-	1235,	/* (0x7e) */
-	1248,	/* (0x7f) */
-	1261,	/* (0x80) */
+  39,   /* (0x00) */
+  0,    /* (0x01) */
+  0,    /* (0x02) */
+  0,    /* (0x03) */
+  0,    /* (0x04) */
+  0,    /* (0x05) */
+  0,    /* (0x06) */
+  0,    /* (0x07) */
+  0,    /* (0x08) */
+  0,    /* (0x09) */
+  0,    /* (0x0a) */
+  0,    /* (0x0b) */
+  0,    /* (0x0c) */
+  0,    /* (0x0d) */
+  0,    /* (0x0e) */
+  0,    /* (0x0f) */
+  0,    /* (0x10) */
+  0,    /* (0x11) */
+  0,    /* (0x12) */
+  0,    /* (0x13) */
+  0,    /* (0x14) */
+  0,    /* (0x15) */
+  0,    /* (0x16) */
+  0,    /* (0x17) */
+  0,    /* (0x18) */
+  0,    /* (0x19) */
+  0,    /* (0x1a) */
+  0,    /* (0x1b) */
+  0,    /* (0x1c) */
+  0,    /* (0x1d) */
+  13,   /* (0x1e) */
+  26,   /* (0x1f) */
+  39,   /* (0x20) */
+  52,   /* (0x21) */
+  65,   /* (0x22) */
+  78,   /* (0x23) */
+  91,   /* (0x24) */
+  104,  /* (0x25) */
+  117,  /* (0x26) */
+  130,  /* (0x27) */
+  143,  /* (0x28) */
+  156,  /* (0x29) */
+  169,  /* (0x2a) */
+  182,  /* (0x2b) */
+  195,  /* (0x2c) */
+  208,  /* (0x2d) */
+  221,  /* (0x2e) */
+  234,  /* (0x2f) */
+  247,  /* (0x30) */
+  260,  /* (0x31) */
+  273,  /* (0x32) */
+  286,  /* (0x33) */
+  299,  /* (0x34) */
+  312,  /* (0x35) */
+  325,  /* (0x36) */
+  338,  /* (0x37) */
+  351,  /* (0x38) */
+  364,  /* (0x39) */
+  377,  /* (0x3a) */
+  390,  /* (0x3b) */
+  403,  /* (0x3c) */
+  416,  /* (0x3d) */
+  429,  /* (0x3e) */
+  442,  /* (0x3f) */
+  455,  /* (0x40) */
+  468,  /* (0x41) */
+  481,  /* (0x42) */
+  494,  /* (0x43) */
+  507,  /* (0x44) */
+  520,  /* (0x45) */
+  533,  /* (0x46) */
+  546,  /* (0x47) */
+  559,  /* (0x48) */
+  572,  /* (0x49) */
+  585,  /* (0x4a) */
+  598,  /* (0x4b) */
+  611,  /* (0x4c) */
+  624,  /* (0x4d) */
+  637,  /* (0x4e) */
+  650,  /* (0x4f) */
+  663,  /* (0x50) */
+  676,  /* (0x51) */
+  689,  /* (0x52) */
+  702,  /* (0x53) */
+  715,  /* (0x54) */
+  728,  /* (0x55) */
+  741,  /* (0x56) */
+  754,  /* (0x57) */
+  767,  /* (0x58) */
+  780,  /* (0x59) */
+  793,  /* (0x5a) */
+  806,  /* (0x5b) */
+  819,  /* (0x5c) */
+  832,  /* (0x5d) */
+  845,  /* (0x5e) */
+  858,  /* (0x5f) */
+  871,  /* (0x60) */
+  884,  /* (0x61) */
+  897,  /* (0x62) */
+  910,  /* (0x63) */
+  923,  /* (0x64) */
+  936,  /* (0x65) */
+  949,  /* (0x66) */
+  962,  /* (0x67) */
+  975,  /* (0x68) */
+  988,  /* (0x69) */
+  1001, /* (0x6a) */
+  1014, /* (0x6b) */
+  1027, /* (0x6c) */
+  1040, /* (0x6d) */
+  1053, /* (0x6e) */
+  1066, /* (0x6f) */
+  1079, /* (0x70) */
+  1092, /* (0x71) */
+  1105, /* (0x72) */
+  1118, /* (0x73) */
+  1131, /* (0x74) */
+  1144, /* (0x75) */
+  1157, /* (0x76) */
+  1170, /* (0x77) */
+  1183, /* (0x78) */
+  1196, /* (0x79) */
+  1209, /* (0x7a) */
+  1222, /* (0x7b) */
+  1235, /* (0x7c) */
+  1248, /* (0x7d) */
+  1261  /* (0x7e) */
 };
 
 static const FontDesc consoleDesc = {
@@ -3320,7 +3318,7 @@ static const FontDesc consoleDesc = {
 	8, 13, 0, -1,             /* max bounding box */
 	11,                       /* ascent (baseline) height */
 	0,                        /* first character in bitmap */
-	129,                      /* font size in glyphs */
+	127,                      /* font size in glyphs */
 	_console_font_bits,       /* 16-bit right-padded bitmap data */
 	_console_sysfont_offset,  /* offsets into bitmap data*/
 	0,  /* fixed width*/      /* character widths or NULL if fixed */