]> Shamusworld >> Repos - thunder/blobdiff - src/gui.cpp
Added DIP switch fungibility, misc. code cleanups.
[thunder] / src / gui.cpp
old mode 100755 (executable)
new mode 100644 (file)
index df8275c..a337972
@@ -1,86 +1,53 @@
 //
 // Thunder Graphic User Interface
 //
-// by James L. Hammons
-// (c) 2004, 2009 Underground Software
+// by James Hammons
+// (C) 2004, 2014 Underground Software
 //
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
 //
 // WHO  WHEN        WHAT
-// ---  ----------  ------------------------------------------------------------
+// ---  ----------  -----------------------------------------------------------
 // JLH  07/23/2009  Added changelog ;-)
 //
 
 #include "gui.h"
 
 #include <string>
-#include <fstream>       // Needed for tracelog
-//#include "SDL.h"         // Needed for screen.h
 #include "screen.h"
+#include "sound.h"
 #include "resource.h"    // Thunder graphics & sounds
 
-using namespace std;                                   // Yes!
+using namespace std;
 
 // External shit
 
-extern SDL_Surface * screen;
-
-extern uint8 my_scr[0x14000];                                                  // Screen buffer...
-extern uint8 gram1[];                                                                  // Game RAM (do here??)
-extern uint8 hScrollOffset;                                                            // Horizontal scroll offset
-extern uint8 vScrollOffset;                                                            // Vertical scroll offset
-extern uint32 voffsets[8];
-extern uint8 voice_rom[];                                                              // PCM data pointer
-extern fstream tr;                                                                             // Tracelog
+extern uint8_t my_scr[0x14000];                // Screen buffer...
+extern uint8_t gram1[];                                // Game RAM (do here??)
 
 // Global shit
 
-uint16 text_life;          // How long text is visible
-bool show_text;          // Whether or not to show text
-uint16 show_which_msg;     // Which message to show
-bool show_gui;           // Whether or not to show GUI
-uint16 selection;          // Which GUI item currently selected
-uint16 snd_num;
-uint16 gui_debounce;       // GUI key debounce value
-uint16 num_coins;          // Number of coins dropped
-uint16 blink = 0;          // Used to blink player 1 & 2 start buttons
-uint16 flash = 23;         // Used to flash GUI lights
-uint16 iline = 0;          // Used to roll line
-uint16 dcurcol = 179;      // dipswitch cursor color
-int  dcurdir = 1;        // Initially going up...
+uint16_t text_life;                            // How long text is visible
+bool show_text;                                        // Whether or not to show text
+uint16_t show_which_msg;               // Which message to show
+bool show_gui;                                 // Whether or not to show GUI
+uint16_t selection;                            // Which GUI item currently selected
+uint16_t gui_debounce;                 // GUI key debounce value
+uint16_t num_coins;                            // Number of coins dropped
+uint16_t blink = 0;                            // Used to blink player 1 & 2 start buttons
+uint16_t flash = 23;                   // Used to flash GUI lights
+uint16_t iline = 0;                            // Used to roll line
+uint16_t dcurcol = 179;                        // dipswitch cursor color
+int  dcurdir = 1;                              // Initially going up...
 bool blink_on = false;
-bool game_refresh;       // Refresh rate user set
-bool do_decrement;       // Flag to handle decrement...
-bool user_selected_something;  // Flag for well, you know...
-uint16 dswitch;            // Which dipswitch is selected...
-
-// The following are global for the sound routines...
-
-const float sampleBase = 22050.0/6000.0;  // Btwn 5512.5 and 6000
-bool snd_go = false;
-bool chan1_go = false, chan2_go = false, chan3_go = false;
-bool chan4_go = false, chan5_go = false, chan6_go = false;
-uint8 * sndp1, * sndp2, * sndp3, * sndp4, * sndp5, * sndp6;
-uint32 rom_pos, end_pos;
-uint32 spos1, end_pos1;
-uint32 spos2, end_pos2;
-uint32 spos3, end_pos3;
-uint32 spos4, end_pos4;
-uint32 spos5, end_pos5;
-uint32 spos6, end_pos6;
-float sample1;
-uint8 prevSamp1;
-int8 delta_x1;
-float sample2;
-uint8 prevSamp2;
-int8 delta_x2;
-
-uint8 * snd_array[3] = { sunknown, scya, scamera }; // From RESOURCE.H
-uint32 snd_lens[3]   = { sunknownlen, scyalen, scameralen };
+bool game_refresh;                             // Refresh rate user set
+bool do_decrement;                             // Flag to handle decrement...
+bool user_selected_something;  // Flag for well, you know...
+uint16_t dswitch;                              // Which dipswitch is selected...
 
 // Bitmaps
 
-uint8 bmp1[] = {
+uint8_t bmp1[] = {
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
   0,0,1,1,0,0,0,1,1,0,0,1,0,0,1,0,0,0,0,0,0,
   0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,0,1,1,1,1,0,
@@ -89,7 +56,7 @@ uint8 bmp1[] = {
   0,0,1,1,0,0,0,1,1,0,0,1,0,0,1,0,1,1,1,1,0,
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
   };
-uint8 bmp2[] = {
+uint8_t bmp2[] = {
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
   0,1,1,1,0,0,0,1,1,0,0,1,0,0,1,0,0,0,0,0,0,
   0,0,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,1,1,1,0,
@@ -98,7 +65,7 @@ uint8 bmp2[] = {
   0,1,1,1,0,0,0,1,1,0,0,1,0,0,1,0,1,1,1,1,0,
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
   };
-uint8 bmp3[] = {
+uint8_t bmp3[] = {
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
   0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
   0,1,0,0,0,0,1,1,1,0,0,0,1,1,0,0,1,1,1,0,0,
@@ -107,7 +74,7 @@ uint8 bmp3[] = {
   0,1,1,1,0,0,1,0,0,1,0,0,1,1,1,0,1,1,1,0,0,
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0
   };
-uint8 boptions[] = { // 35x9
+uint8_t boptions[] = { // 35x9
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
   0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
   0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -118,7 +85,7 @@ uint8 boptions[] = { // 35x9
   0,0,1,1,0,0,1,1,1,0,0,0,0,1,1,0,1,1,1,0,0,1,1,0,0,1,0,0,1,0,0,1,1,0,0,
   0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
   };
-uint8 bn0[] = {
+uint8_t bn0[] = {
   0,0,0,0,0,0,
   0,0,1,1,0,0,
   0,1,0,0,1,0,
@@ -127,7 +94,7 @@ uint8 bn0[] = {
   0,0,1,1,0,0,
   0,0,0,0,0,0
   };
-uint8 bn1[] = {
+uint8_t bn1[] = {
   0,0,0,0,0,0,
   0,0,1,0,0,0,
   0,1,1,0,0,0,
@@ -136,7 +103,7 @@ uint8 bn1[] = {
   0,1,1,1,0,0,
   0,0,0,0,0,0
   };
-uint8 bn2[] = {
+uint8_t bn2[] = {
   0,0,0,0,0,0,
   0,1,1,1,0,0,
   0,0,0,0,1,0,
@@ -145,7 +112,7 @@ uint8 bn2[] = {
   0,1,1,1,1,0,
   0,0,0,0,0,0
   };
-uint8 bn3[] = {
+uint8_t bn3[] = {
   0,0,0,0,0,0,
   0,1,1,1,0,0,
   0,0,0,0,1,0,
@@ -154,7 +121,7 @@ uint8 bn3[] = {
   0,1,1,1,0,0,
   0,0,0,0,0,0
   };
-uint8 bn4[] = {
+uint8_t bn4[] = {
   0,0,0,0,0,0,
   0,0,0,1,0,0,
   0,1,0,1,0,0,
@@ -163,7 +130,7 @@ uint8 bn4[] = {
   0,0,0,1,0,0,
   0,0,0,0,0,0
   };
-uint8 bn5[] = {
+uint8_t bn5[] = {
   0,0,0,0,0,0,
   0,1,1,1,1,0,
   0,1,0,0,0,0,
@@ -172,7 +139,7 @@ uint8 bn5[] = {
   0,1,1,1,0,0,
   0,0,0,0,0,0
   };
-uint8 bn6[] = {
+uint8_t bn6[] = {
   0,0,0,0,0,0,
   0,0,1,1,0,0,
   0,1,0,0,0,0,
@@ -181,7 +148,7 @@ uint8 bn6[] = {
   0,0,1,1,0,0,
   0,0,0,0,0,0
   };
-uint8 bn7[] = {
+uint8_t bn7[] = {
   0,0,0,0,0,0,
   0,1,1,1,1,0,
   0,0,0,0,1,0,
@@ -190,7 +157,7 @@ uint8 bn7[] = {
   0,0,1,0,0,0,
   0,0,0,0,0,0
   };
-uint8 bn8[] = {
+uint8_t bn8[] = {
   0,0,0,0,0,0,
   0,0,1,1,0,0,
   0,1,0,0,1,0,
@@ -199,7 +166,7 @@ uint8 bn8[] = {
   0,0,1,1,0,0,
   0,0,0,0,0,0
   };
-uint8 bn9[] = {
+uint8_t bn9[] = {
   0,0,0,0,0,0,
   0,0,1,1,0,0,
   0,1,0,0,1,0,
@@ -208,7 +175,7 @@ uint8 bn9[] = {
   0,0,1,1,0,0,
   0,0,0,0,0,0
   };
-uint8 bnA[] = {
+uint8_t bnA[] = {
   0,0,0,0,0,0,
   0,0,1,1,0,0,
   0,1,0,0,1,0,
@@ -217,7 +184,7 @@ uint8 bnA[] = {
   0,1,0,0,1,0,
   0,0,0,0,0,0
   };
-uint8 bnB[] = {
+uint8_t bnB[] = {
   0,0,0,0,0,0,
   0,1,1,1,0,0,
   0,1,0,0,1,0,
@@ -226,7 +193,7 @@ uint8 bnB[] = {
   0,1,1,1,0,0,
   0,0,0,0,0,0
   };
-uint8 bnC[] = {
+uint8_t bnC[] = {
   0,0,0,0,0,0,
   0,0,1,1,0,0,
   0,1,0,0,1,0,
@@ -235,7 +202,7 @@ uint8 bnC[] = {
   0,0,1,1,0,0,
   0,0,0,0,0,0
   };
-uint8 bnD[] = {
+uint8_t bnD[] = {
   0,0,0,0,0,0,
   0,1,1,1,0,0,
   0,1,0,0,1,0,
@@ -244,7 +211,7 @@ uint8 bnD[] = {
   0,1,1,1,0,0,
   0,0,0,0,0,0
   };
-uint8 bnE[] = {
+uint8_t bnE[] = {
   0,0,0,0,0,0,
   0,1,1,1,1,0,
   0,1,0,0,0,0,
@@ -253,7 +220,7 @@ uint8 bnE[] = {
   0,1,1,1,1,0,
   0,0,0,0,0,0
   };
-uint8 bnF[] = {
+uint8_t bnF[] = {
   0,0,0,0,0,0,
   0,1,1,1,1,0,
   0,1,0,0,0,0,
@@ -263,6 +230,7 @@ uint8 bnF[] = {
   0,0,0,0,0,0
   };
 
+
 //
 // Initialize GUI
 //
@@ -273,558 +241,714 @@ void InitGUI(void)
        user_selected_something = false;
 }
 
+
 //
 // Handle key debounce
 //
 void HandleGUIDebounce(void)
 {
-  if (gui_debounce)  gui_debounce--;   // Debounce GUI keys...
-  do_decrement = !do_decrement;        // Called at 60Hz, so skip decrementing blink
-  if (do_decrement)
-  {
-    if (blink)  blink--;  // Handle blinking stuff (Should prb go in DrawGUI)
-
-    flash-=2;  // Handle flashing stuff (Should prb go in DrawGUI)
-    if (flash == 0xFFFF)  flash = 23;
-
-    iline++;
-    if (iline > 30)  iline = 0;  // 30 pixels high, going past by 1
-
-    dcurcol += dcurdir;
-    if (dcurcol == 186)  dcurdir = -1;
-    if (dcurcol == 179)  dcurdir = 1;
-  }
+       if (gui_debounce)
+               gui_debounce--;   // Debounce GUI keys...
+
+       do_decrement = !do_decrement;        // Called at 60Hz, so skip decrementing blink
+
+       if (do_decrement)
+       {
+               if (blink)
+                       blink--;  // Handle blinking stuff (Should prb go in DrawGUI)
+
+               flash -= 2;  // Handle flashing stuff (Should prb go in DrawGUI)
+
+               if (flash == 0xFFFF)
+                       flash = 23;
+
+               iline++;
+
+               if (iline > 30)
+                       iline = 0;  // 30 pixels high, going past by 1
+
+               dcurcol += dcurdir;
+
+               if (dcurcol == 186)
+                       dcurdir = -1;
+
+               if (dcurcol == 179)
+                       dcurdir = 1;
+       }
 }
 
+
 //
 // Set the refresh rate (30/60 Hz)
 //
 void SetRefreshRate(bool refresh)
 {
-  game_refresh = refresh;
+       game_refresh = refresh;
 }
 
+
 //
 // Whether or not GUI is showing
 //
-bool ShowGUI(void)  { return show_gui; }
+bool ShowGUI(void)
+{
+       return show_gui;
+}
+
 
 //
 // Turn the GUI on
 //
-void ActivateGUI(void)  { show_gui = true; }
+void ActivateGUI(void)
+{
+       show_gui = true;
+}
+
 
 //
 // Turn the GUI off
 //
-void DeactivateGUI(void)  { show_gui = false; }
+void DeactivateGUI(void)
+{
+       show_gui = false;
+}
+
 
 //
 // Draw the small icons...
 //
-void DrawSmallIcons(uint16 icon_not_to_draw)
+void DrawSmallIcons(uint16_t icon_not_to_draw)
 {
-  uint8 * iconmem;
-  uint8 xl, yl;
-  uint8 * sIcons[12] = { inoguis, icoinus, ipl1sts, ipl2sts, ii30hzs, ii60hzs,
-                        idipsws, ichecks, ikeycns, isnapss, iresets, ibyebys };
-  uint8 xlens[12] = { 31, 18, 32, 35, 37, 37, 29, 23, 28, 32, 19, 19 };
-  uint8 ylens[12] = { 31, 18, 19, 19, 21, 21, 23, 20, 16, 17, 20, 23 };
-  uint8 xpos[11] = { 33, 48, 63, 78, 104, 0, 184, 210, 225, 240, 255 };
-  uint8 iconidx[11] = { 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 6 };
-
-  if (game_refresh)  iconidx[9] = 5;       // 60 Hz...
-
-  // Draw small icons 1 to 5 on left, then 11 to 7 on right.
-
-  for(int i=0; i<5; i++)
-  {
-    uint16 idx = i + icon_not_to_draw;          // Get correct start pos.
-    if (idx > 10)  idx -= 11;
-
-    iconmem = sIcons[iconidx[idx]];
-    xl = xlens[iconidx[idx]];  yl = ylens[iconidx[idx]];
-
-    uint32 scadr = hScrollOffset + voffsets[vScrollOffset];
-    scadr += 320*((224-yl)/2);                // Center vertically
-    scadr += xpos[i] - (xl/2);                // Center around horiz. pos.
-    uint16 bmpptr = 0;
-
-    for(int yy=0; yy<yl; yy++)
-    {
-      for(int xx=0; xx<xl; xx++)
-      {
-        uint8 b = iconmem[bmpptr++];
-        if (b)  my_scr[scadr+xx+yy*320] = b;
-      }
-    }
-  }
-  for(int i=10; i>5; i--)
-  {
-    uint16 idx = i + icon_not_to_draw;          // Get correct start pos.
-    if (idx > 10)  idx -= 11;
-
-    iconmem = sIcons[iconidx[idx]];
-    xl = xlens[iconidx[idx]];  yl = ylens[iconidx[idx]];
-
-    uint32 scadr = hScrollOffset + voffsets[vScrollOffset];
-    scadr += 320*((224-yl)/2);                // Center vertically
-    scadr += xpos[i] - (xl/2);     // Center around horiz. pos.
-    uint16 bmpptr = 0;
-
-    for(int yy=0; yy<yl; yy++)
-    {
-      for(int xx=0; xx<xl; xx++)
-      {
-        uint8 b = iconmem[bmpptr++];
-        if (b)  my_scr[scadr+xx+yy*320] = b;
-      }
-    }
-  }
+       uint8_t * iconmem;
+       uint8_t xl, yl;
+       uint8_t * sIcons[12] = { inoguis, icoinus, ipl1sts, ipl2sts, ii30hzs,
+               ii60hzs, idipsws, ichecks, ikeycns, isnapss, iresets, ibyebys };
+       uint8_t xlens[12] = { 31, 18, 32, 35, 37, 37, 29, 23, 28, 32, 19, 19 };
+       uint8_t ylens[12] = { 31, 18, 19, 19, 21, 21, 23, 20, 16, 17, 20, 23 };
+       uint8_t xpos[11] = { 33, 48, 63, 78, 104, 0, 184, 210, 225, 240, 255 };
+       uint8_t iconidx[11] = { 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 6 };
+
+       if (game_refresh)
+               iconidx[9] = 5;       // 60 Hz...
+
+       // Draw small icons 1 to 5 on left, then 11 to 7 on right.
+
+       for(int i=0; i<5; i++)
+       {
+               uint16_t idx = i + icon_not_to_draw;    // Get correct start pos.
+
+               if (idx > 10)
+                       idx -= 11;
+
+               iconmem = sIcons[iconidx[idx]];
+               xl = xlens[iconidx[idx]];
+               yl = ylens[iconidx[idx]];
+
+               uint32_t scadr;// = hScrollOffset + voffsets[vScrollOffset];
+               scadr += 320 * ((224 - yl) / 2);                // Center vertically
+               scadr += xpos[i] - (xl / 2);                    // Center around horiz. pos.
+               uint16_t bmpptr = 0;
+
+               for(int yy=0; yy<yl; yy++)
+               {
+                       for(int xx=0; xx<xl; xx++)
+                       {
+                               uint8_t b = iconmem[bmpptr++];
+
+                               if (b)
+                                       my_scr[scadr + xx + yy * 320] = b;
+                       }
+               }
+       }
+
+       for(int i=10; i>5; i--)
+       {
+               uint16_t idx = i + icon_not_to_draw;    // Get correct start pos.
+
+               if (idx > 10)
+                       idx -= 11;
+
+               iconmem = sIcons[iconidx[idx]];
+               xl = xlens[iconidx[idx]];
+               yl = ylens[iconidx[idx]];
+
+               uint32_t scadr;// = hScrollOffset + voffsets[vScrollOffset];
+               scadr += 320 * ((224 - yl) / 2);                // Center vertically
+               scadr += xpos[i] - (xl / 2);                    // Center around horiz. pos.
+               uint16_t bmpptr = 0;
+
+               for(int yy=0; yy<yl; yy++)
+               {
+                       for(int xx=0; xx<xl; xx++)
+                       {
+                               uint8_t b = iconmem[bmpptr++];
+
+                               if (b)
+                                       my_scr[scadr + xx + yy * 320] = b;
+                       }
+               }
+       }
 }
 
+
 //
 // Draw the large (selected) icon
 //
-void DrawLargeIcon(uint16 icon)
+void DrawLargeIcon(uint16_t icon)
 {
-  uint8 * iconmem;
-  uint8 xl, yl;
-  uint8 * lIcons[11] = { inoguib, icoinub, ipl1stb, ipl2stb, ii30hzb, ii60hzb,
-                        idipswb, ikeycnb, isnapsb, iresetb, ibyebyb };
-  uint8 xlens[11] = { 44, 45, 50, 52, 59, 59, 42, 45, 48, 58, 42 };
-  uint8 ylens[11] = { 44, 40, 33, 29, 52, 52, 34, 45, 37, 40, 50 };
-
-  uint8 gsubs1[24] = { 21, 21, 20, 19, 168, 168, 31, 155, 68, 68, 67, 66,
-                      36, 36, 35, 34, 188, 188, 183, 181, 81, 81, 85, 80 },
-       gsubs2[24] = { 20, 20, 19, 19, 31,  31,  155, 155, 67, 67, 66, 66,
-                      35, 35, 34, 34, 183, 183, 181, 181, 85, 85, 80, 80 },
-       gsubs3[24] = { 35, 34, 188, 188, 183, 181, 81, 81, 85, 80, 21, 21,
-                      20, 19, 168, 168, 31, 155, 68, 68, 67, 66, 36, 36 },
-       gsubs4[24] = { 34, 34, 183, 183, 181, 181, 85, 85, 80, 80, 20, 20,
-                      19, 19, 31,  31,  155, 155, 67, 67, 66, 66, 35, 35 },
-       gsubs5[24] = { 20, 20, 183, 183, 31, 31, 85, 85, 67, 67, 20, 20,
-                      35, 35, 31, 31, 183, 183, 67, 67, 85, 85, 35, 35 };
-
-  iconmem = lIcons[icon];
-  xl = xlens[icon];  yl = ylens[icon];
-  if (icon == OPTIONS)
-  {
-    iconmem = boptions;
-    xl = 35;  yl = 9;
-  }
-  if ((icon == REFRESH) && game_refresh)
-  {
-    iconmem = lIcons[5];
-    xl = xlens[5];  yl = ylens[5];
-  }
-  if (icon == DIPSWITCH)
-  {
-    iconmem = lIcons[6];
-    xl = xlens[6];  yl = ylens[6];
-  }
-
-  uint32 scadr = hScrollOffset + voffsets[vScrollOffset];
-  scadr += 320*((224-yl)/2);                // Center vertically
-  scadr += (288-xl)/2;                      // Center horizontally
-  uint16 bmpptr = 0;
-
-  for(int yy=0; yy<yl; yy++)
-  {
-    for(int xx=0; xx<xl; xx++)
-    {
-      uint8 b = iconmem[bmpptr++];
-      if (b)
-      {
-        if ((icon == PL1START) && (b == 235) && (num_coins) && !blink_on)
-          b = 125;                        // Light ON color
-/*noguib: 44x44 [Green (hi/lo): 36/235 Orange: 168/31 Neutral:12]
-   Rainbow (ROYGBP, hi/med/lo): 21,20,19; 168, 31,155; 68,67,66;
-                                36,35,34; 188,183,181; 81,85,80 */
-        if (icon == NOGUI)
-        {
-          uint8 fln = (23 - flash) + 1; // Want to go forward (maybe fix it?)
-          switch (b)
-          {
-            case 36:   { b = gsubs1[fln];  break; }
-            case 235:  { b = gsubs2[fln];  break; }
-            case 168:  { b = gsubs3[fln];  break; }
-            case 31:   { b = gsubs4[fln];  break; }
-            case 12:   { b = gsubs5[fln];  break; }
-          }
-        }
-        if ((icon == REFRESH) && (iline == yy) && (b == 50))  b = 188;
-        my_scr[scadr+xx+yy*320] = b;
-      }
-    }
-  }
-  if (!blink)    // Should go here???
-  {
-    blink_on = !blink_on;        // Switch blink state
-    if (blink_on)  blink = 12;
-    else           blink = 6;
-  }
+       uint8_t * iconmem;
+       uint8_t xl, yl;
+       uint8_t * lIcons[11] = { inoguib, icoinub, ipl1stb, ipl2stb, ii30hzb,
+               ii60hzb, idipswb, ikeycnb, isnapsb, iresetb, ibyebyb };
+       uint8_t xlens[11] = { 44, 45, 50, 52, 59, 59, 42, 45, 48, 58, 42 };
+       uint8_t ylens[11] = { 44, 40, 33, 29, 52, 52, 34, 45, 37, 40, 50 };
+
+       uint8_t gsubs1[24] = { 21, 21, 20, 19, 168, 168, 31, 155, 68, 68, 67, 66,
+                                               36, 36, 35, 34, 188, 188, 183, 181, 81, 81, 85, 80 },
+               gsubs2[24] = { 20, 20, 19, 19, 31,  31,  155, 155, 67, 67, 66, 66,
+                                               35, 35, 34, 34, 183, 183, 181, 181, 85, 85, 80, 80 },
+               gsubs3[24] = { 35, 34, 188, 188, 183, 181, 81, 81, 85, 80, 21, 21,
+                                               20, 19, 168, 168, 31, 155, 68, 68, 67, 66, 36, 36 },
+               gsubs4[24] = { 34, 34, 183, 183, 181, 181, 85, 85, 80, 80, 20, 20,
+                                               19, 19, 31,  31,  155, 155, 67, 67, 66, 66, 35, 35 },
+               gsubs5[24] = { 20, 20, 183, 183, 31, 31, 85, 85, 67, 67, 20, 20,
+                                               35, 35, 31, 31, 183, 183, 67, 67, 85, 85, 35, 35 };
+
+       iconmem = lIcons[icon];
+       xl = xlens[icon];
+       yl = ylens[icon];
+
+       if (icon == OPTIONS)
+       {
+               iconmem = boptions;
+               xl = 35;
+               yl = 9;
+       }
+
+       if ((icon == REFRESH) && game_refresh)
+       {
+               iconmem = lIcons[5];
+               xl = xlens[5];
+               yl = ylens[5];
+       }
+
+       if (icon == DIPSWITCH)
+       {
+               iconmem = lIcons[6];
+               xl = xlens[6];
+               yl = ylens[6];
+       }
+
+       uint32_t scadr;// = hScrollOffset + voffsets[vScrollOffset];
+       scadr += 320 * ((224 - yl) / 2);                // Center vertically
+       scadr += (288 - xl) / 2;                      // Center horizontally
+       uint16_t bmpptr = 0;
+
+       for(int yy=0; yy<yl; yy++)
+       {
+               for(int xx=0; xx<xl; xx++)
+               {
+                       uint8_t b = iconmem[bmpptr++];
+
+                       if (b)
+                       {
+                               if ((icon == PL1START) && (b == 235) && (num_coins) && !blink_on)
+                               b = 125;                        // Light ON color
+               /*noguib: 44x44 [Green (hi/lo): 36/235 Orange: 168/31 Neutral:12]
+               Rainbow (ROYGBP, hi/med/lo): 21,20,19; 168, 31,155; 68,67,66;
+                                                                               36,35,34; 188,183,181; 81,85,80 */
+                               if (icon == NOGUI)
+                               {
+                                       uint8_t fln = (23 - flash) + 1; // Want to go forward (maybe fix it?)
+                                       switch (b)
+                                       {
+                                               case 36:   { b = gsubs1[fln];  break; }
+                                               case 235:  { b = gsubs2[fln];  break; }
+                                               case 168:  { b = gsubs3[fln];  break; }
+                                               case 31:   { b = gsubs4[fln];  break; }
+                                               case 12:   { b = gsubs5[fln];  break; }
+                                       }
+                               }
+
+                               if ((icon == REFRESH) && (iline == yy) && (b == 50))
+                                       b = 188;
+
+                               my_scr[scadr+xx+yy*320] = b;
+                       }
+               }
+       }
+
+       if (!blink)    // Should go here???
+       {
+               blink_on = !blink_on;        // Switch blink state
+
+               if (blink_on)
+                       blink = 12;
+               else
+                       blink = 6;
+       }
   //if (flash == 1)  flash = 23;       // Reset flash value
 }
 
+
 //
 // Draw the dipswitch portion of the GUI
 //
 void DrawDipswitch(void)
 {
-  uint8 dseloff[16] = { 0, 1, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 11, 11, 12 };
-  uint8 * dtxt[13] = { idstext1, idstext2, idstext3, idstext4, idstext5,
-                      idstext2, idstext6, idstext7, idstext8, idstext9,
-                      idstext10, idstext11, idstext12 };
-
-  uint8 dtx[13] = { 48, 80, 96, 82, 60, 80, 76, 57, 33, 50, 62, 65, 63 },
-       dty[13] = { 7, 9, 7, 9, 7, 9, 7, 7, 7, 9, 7, 9, 7 };
-  uint32 dtxtoff[13] = { 4*320+24, 14*320-78, 25*320+24, 32*320-80,
-                        39*320+24, 49*320-78,
-                        4*320+24, 11*320-55, 18*320+24, 25*320-48,
-                        32*320+24, 42*320-63, 53*320+24 };
-  uint32 scadr, bmpptr;
-  //dsx = //26x65
-
-  uint32 dbase = hScrollOffset + voffsets[vScrollOffset];
-  dbase += (288-26)/2;                 // Center horizontally
-  dbase += 320*((224-((65*2)+8))/2);   // Center vertically
-
-  scadr = dbase;   // Reset screen address
-  bmpptr = 0;
-  for(int yy=0; yy<65; yy++)
-  {
-    for(int xx=0; xx<26; xx++)
-    {
-      uint8 b = idswitch[bmpptr++];
-      if (b)  my_scr[scadr+xx+yy*320] = b;
-    }
-  }
-  scadr = dbase + (320*73);   // Reset screen address
-  bmpptr = 0;
-  for(int yy=0; yy<65; yy++)
-  {
-    for(int xx=0; xx<26; xx++)
-    {
-      uint8 b = idswitch[bmpptr++];
-      if (b)  my_scr[scadr+xx+yy*320] = b;
-    }
-  }
-  for(int i=0; i<16; i++)
-  {
-    scadr = dbase + (5*320+5) + i*7*320;
-    if (i>7)  scadr += 17*320;   // Adjust for DSW #2
-    bmpptr = 0;
-    if (gram1[0x423D+(i<<1)])  scadr += 12; // Adjust position if ON
-    for(int yy=0; yy<5; yy++)
-    {
-      for(int xx=0; xx<5; xx++)
-      {
-        my_scr[scadr++] = idsbutton[bmpptr++];
-      }
-      scadr += 315; // Adjust position...
-    }
-  }
-  uint8 dselected_text = dseloff[dswitch];
-  for(int i=0; i<13; i++)
-  {
-    if (dselected_text != i)
-    {
-      scadr = dbase + dtxtoff[i];
-      if (i>5)  scadr += (73*320);
-      bmpptr = 0;
-      for(int yy=0; yy<dty[i]; yy++)
-      {
-        for(int xx=0; xx<dtx[i]; xx++)
-        {
-          uint8 b = dtxt[i][bmpptr++];
-          if (b)  my_scr[scadr] = b;
-          scadr++;
-        }
-        scadr += (320-dtx[i]); // Adjust position...
-      }
-    }
-  }
-  scadr = dbase + dtxtoff[dselected_text];
-  if (dselected_text>5)  scadr += (73*320);
-  bmpptr = 0;
-  for(int yy=0; yy<dty[dselected_text]; yy++)
-  {
-    for(int xx=0; xx<dtx[dselected_text]; xx++)
-    {
-      uint8 b = dtxt[dselected_text][bmpptr++];
-      if (b)  my_scr[scadr] = 125;
-      scadr++;
-    }
-    scadr += (320-dtx[dselected_text]); // Adjust position...
-  }
-  if (dswitch != 16)                   // Draw cursor
-  {
-    scadr = dbase + (4*320+4) + dswitch*7*320;
-    if (dswitch>7)  scadr += 17*320;   // Adjust for DSW #2
-    for(int xx=0; xx<19; xx++)  my_scr[scadr++] = dcurcol;
-    scadr += 301;
-    for(int xx=0; xx<5; xx++)
-    {
-      my_scr[scadr] = dcurcol;  scadr += 18;
-      my_scr[scadr] = dcurcol;  scadr += 302;
-    }
-    for(int xx=0; xx<19; xx++)  my_scr[scadr++] = dcurcol;
-  }
+       uint8_t dseloff[16] = { 0, 1, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 11, 11, 12 };
+       uint8_t * dtxt[13] = { idstext1, idstext2, idstext3, idstext4, idstext5,
+               idstext2, idstext6, idstext7, idstext8, idstext9, idstext10, idstext11,
+               idstext12 };
+
+       uint8_t dtx[13] = { 48, 80, 96, 82, 60, 80, 76, 57, 33, 50, 62, 65, 63 },
+               dty[13] = { 7, 9, 7, 9, 7, 9, 7, 7, 7, 9, 7, 9, 7 };
+       uint32_t dtxtoff[13] = { 4*320+24, 14*320-78, 25*320+24, 32*320-80,
+               39*320+24, 49*320-78,  4*320+24, 11*320-55, 18*320+24, 25*320-48,
+               32*320+24, 42*320-63, 53*320+24 };
+       uint32_t scadr, bmpptr;
+       //dsx = //26x65
+
+       uint32_t dbase;// = hScrollOffset + voffsets[vScrollOffset];
+       dbase += (288 - 26) / 2;                 // Center horizontally
+       dbase += 320 * ((224 - ((65 * 2) + 8)) / 2);   // Center vertically
+
+       scadr = dbase;   // Reset screen address
+       bmpptr = 0;
+
+       for(int yy=0; yy<65; yy++)
+       {
+               for(int xx=0; xx<26; xx++)
+               {
+                       uint8_t b = idswitch[bmpptr++];
+
+                       if (b)
+                               my_scr[scadr + xx + yy * 320] = b;
+               }
+       }
+
+       scadr = dbase + (320*73);   // Reset screen address
+       bmpptr = 0;
+
+       for(int yy=0; yy<65; yy++)
+       {
+               for(int xx=0; xx<26; xx++)
+               {
+                       uint8_t b = idswitch[bmpptr++];
+
+                       if (b)
+                               my_scr[scadr + xx + yy * 320] = b;
+               }
+       }
+
+       for(int i=0; i<16; i++)
+       {
+               scadr = dbase + (5 * 320 + 5) + i * 7 * 320;
+
+               if (i > 7)
+                       scadr += 17*320;   // Adjust for DSW #2
+
+               bmpptr = 0;
+
+               if (gram1[0x423D + (i << 1)])
+                       scadr += 12; // Adjust position if ON
+
+               for(int yy=0; yy<5; yy++)
+               {
+                       for(int xx=0; xx<5; xx++)
+                       {
+                               my_scr[scadr++] = idsbutton[bmpptr++];
+                       }
+
+                       scadr += 315; // Adjust position...
+               }
+       }
+
+       uint8_t dselected_text = dseloff[dswitch];
+
+       for(int i=0; i<13; i++)
+       {
+               if (dselected_text != i)
+               {
+                       scadr = dbase + dtxtoff[i];
+
+                       if (i > 5)
+                               scadr += (73 * 320);
+
+                       bmpptr = 0;
+
+                       for(int yy=0; yy<dty[i]; yy++)
+                       {
+                               for(int xx=0; xx<dtx[i]; xx++)
+                               {
+                                       uint8_t b = dtxt[i][bmpptr++];
+
+                                       if (b)
+                                               my_scr[scadr] = b;
+
+                                       scadr++;
+                               }
+
+                               scadr += (320 - dtx[i]); // Adjust position...
+                       }
+               }
+       }
+
+       scadr = dbase + dtxtoff[dselected_text];
+
+       if (dselected_text>5)
+               scadr += (73 * 320);
+
+       bmpptr = 0;
+
+       for(int yy=0; yy<dty[dselected_text]; yy++)
+       {
+               for(int xx=0; xx<dtx[dselected_text]; xx++)
+               {
+                       uint8_t b = dtxt[dselected_text][bmpptr++];
+
+                       if (b)
+                               my_scr[scadr] = 125;
+
+                       scadr++;
+               }
+
+               scadr += (320 - dtx[dselected_text]); // Adjust position...
+       }
+
+       if (dswitch != 16)                   // Draw cursor
+       {
+               scadr = dbase + (4 * 320 + 4) + dswitch * 7 * 320;
+
+               if (dswitch>7)
+                       scadr += 17 * 320;   // Adjust for DSW #2
+
+               for(int xx=0; xx<19; xx++)
+                       my_scr[scadr++] = dcurcol;
+
+               scadr += 301;
+
+               for(int xx=0; xx<5; xx++)
+               {
+                       my_scr[scadr] = dcurcol;
+                       scadr += 18;
+                       my_scr[scadr] = dcurcol;
+                       scadr += 302;
+               }
+
+               for(int xx=0; xx<19; xx++)
+                       my_scr[scadr++] = dcurcol;
+       }
 }
 
+
 //
 // The actual GUI display routine
 //
 void DrawGUI(void)
 {
-  if (!user_selected_something)  // i.e. we're not inside a selection...
-  {
-    DrawSmallIcons(selection);  // 'selection' is icon *not* to draw
-    DrawLargeIcon(selection);
-  }
-  else
-  {
-    if (selection == DIPSWITCH)  DrawDipswitch();
-  }
+       if (!user_selected_something)  // i.e. we're not inside a selection...
+       {
+               DrawSmallIcons(selection);  // 'selection' is icon *not* to draw
+               DrawLargeIcon(selection);
+       }
+       else
+       {
+               if (selection == DIPSWITCH)
+                       DrawDipswitch();
+       }
 }
 
+
 //
 // User pressed left arrow handler
 //
 void SelectLeft(void)
 {
-  if (!gui_debounce)
-  {
-    gui_debounce = 6;
-    if (!user_selected_something)
-    {
-      selection++;
-      if (selection > 10)  selection = 0;
-    }
-    else
-    {
-      if (gram1[0x423D+(dswitch<<1)])       // It's switchable...
-      {}  //SpawnSound(USERSOUND, SCLICK);
-      else
-      {}  //SpawnSound(USERSOUND, SUNGH);
-      gram1[0x423D+(dswitch<<1)] = 0;       // & turn it off
-    }
-  }
+       if (!gui_debounce)
+       {
+               gui_debounce = 6;
+
+               if (!user_selected_something)
+               {
+                       selection++;
+
+                       if (selection > 10)
+                               selection = 0;
+               }
+               else
+               {
+                       if (gram1[0x423D + (dswitch << 1)])       // It's switchable...
+                       {}  //SpawnSound(USERSOUND, SCLICK);
+                       else
+                       {}  //SpawnSound(USERSOUND, SUNGH);
+
+                       gram1[0x423D + (dswitch << 1)] = 0;       // & turn it off
+               }
+       }
 }
 
+
 //
 // User pressed right arrow handler
 //
 void SelectRight(void)
 {
-  if (!gui_debounce)
-  {
-    gui_debounce = 6;
-    if (!user_selected_something)
-    {
-      selection--;
-      if (selection > 10)  selection = 10;  // Unsigned compare
-    }
-    else
-    {
-      if (!gram1[0x423D+(dswitch<<1)])       // It's switchable...
-      {}  //SpawnSound(USERSOUND, SCLICK);
-      else
-      {}  //SpawnSound(USERSOUND, SUNGH);
-      gram1[0x423D+(dswitch<<1)] = 1;       // & turn it on
-    }
-  }
+       if (!gui_debounce)
+       {
+               gui_debounce = 6;
+
+               if (!user_selected_something)
+               {
+                       selection--;
+
+                       if (selection > 10)
+                               selection = 10;  // Unsigned compare
+               }
+               else
+               {
+                       if (!gram1[0x423D + (dswitch << 1)])       // It's switchable...
+                       {}  //SpawnSound(USERSOUND, SCLICK);
+                       else
+                       {}  //SpawnSound(USERSOUND, SUNGH);
+
+                       gram1[0x423D+(dswitch<<1)] = 1;       // & turn it on
+               }
+       }
 }
 
+
 //
 // User pressed Up arrow handler
 //
 void SelectUp(void)
 {
-  if (!gui_debounce)
-  {
-    gui_debounce = 6;
-    if (user_selected_something)
-    {
-      if (selection == DIPSWITCH)
-      {
-        dswitch--;
-        if (dswitch > 16)  dswitch = 16;  // Wrap non-int
-        //snd_num = dswitch;  SpawnMsg(MSHOWNUMS); // Temp...
-      }
-    }
-  }
+       if (!gui_debounce)
+       {
+               gui_debounce = 6;
+
+               if (user_selected_something)
+               {
+                       if (selection == DIPSWITCH)
+                       {
+                               dswitch--;
+
+                               if (dswitch > 16)
+                                       dswitch = 16;  // Wrap non-int
+                               //snd_num = dswitch;  SpawnMsg(MSHOWNUMS); // Temp...
+                       }
+               }
+       }
 }
 
+
 //
 // User pressed down arrow handler
 //
 void SelectDown(void)
 {
-  if (!gui_debounce)
-  {
-    gui_debounce = 6;
-    if (user_selected_something)
-    {
-      if (selection == DIPSWITCH)
-      {
-        dswitch++;
-        if (dswitch > 16)  dswitch = 0;
-        //snd_num = dswitch;  SpawnMsg(MSHOWNUMS); // Temp...
-      }
-    }
-  }
+       if (!gui_debounce)
+       {
+               gui_debounce = 6;
+
+               if (user_selected_something)
+               {
+                       if (selection == DIPSWITCH)
+                       {
+                               dswitch++;
+
+                               if (dswitch > 16)
+                                       dswitch = 0;
+                               //snd_num = dswitch;  SpawnMsg(MSHOWNUMS); // Temp...
+                       }
+               }
+       }
 }
 
+
 //
 // User selected something! Handle it!
 //
-uint8 UserSelectedSomething(void)
+uint8_t UserSelectedSomething(void)
 {
-  //extern uint8 * gram1;
-
-  if (!gui_debounce)
-  {
-    gui_debounce = 6;
-    if (!user_selected_something)  // Inside a selection? no...
-    {
-      if (selection == NOGUI)     // Turn off GUI
-      {
-        show_gui = false;
-      }
-      if (selection == COINUP)    // Coin up machine
-      {
-        gram1[0x41A5]++;          // Add one coin... (prob. need sep. counter)
-        num_coins++;
-        gram1[0x4189] = num_coins/10; // Should be in THUNDER.CPP?
-        gram1[0x418A] = num_coins - (gram1[0x4189]*10);
-      }
-      if (selection == PL1START)  // 1 Player start
-      {
-        if (num_coins)
-        {
-          num_coins--;
-          show_gui = false;       // Shut off GUI only if coined up
-        }
-        gram1[0x418C] = 1;        // Strobe start location
-      }
-      if (selection == PL2START)  // 2 Player start
-      {
-        if (num_coins > 1)
-        {
-          num_coins -= 2;
-          show_gui = false;
-        }
-      }
-      if (selection == REFRESH)   // Toggle refresh rate
-      {
-        //SpawnSound(USERSOUND, SCLICK);
-      }
-      if (selection == DIPSWITCH) // Edit game settings
-      {
-        //SpawnSound(USERSOUND, SBLAH);
-        user_selected_something = true;
-        dswitch = 0;              // Set at first dipswitch
-      }
-      if (selection == OPTIONS)   // Edit emulator settings
-      {
-      }
-      if (selection == KEYCONFIG) // Edit game keys
-      {
-      }
-      if (selection == SNAPSHOT)  // Snapshot
-      {
-        SpawnSound(USERSOUND, SCAMERA);
-        SnapPCX(screen);
-      }
-      if (selection == RESET)     // Reset machine
-      {
-        //SpawnSound(USERSOUND, SRESET);
-      }
-      if (selection == EXIT)
-      {
-        SpawnSound(USERSOUND, SCYA);
-      }
-      return selection;
-    }
-    else           // Selected something inside selection...
-    {
-      if (selection == DIPSWITCH)
-      {
-        if (dswitch == 16)  // Selected 'back to GUI'
-        {
-          //SpawnSound(USERSOUND, SBLAH2);
-          user_selected_something = false;
-        }
-        else
-        {
-          //SpawnSound(USERSOUND, SCLICK);
-          gram1[0x423D + (dswitch<<1)] = !gram1[0x423D + (dswitch<<1)];
-        }
-      }
-      return 0xFF;  // Nothing for main to do...
-    }
-  }
-  else  return 0xFF;  // Wasn't debounced, so return invalid
+       //extern uint8_t * gram1;
+
+       if (!gui_debounce)
+       {
+               gui_debounce = 6;
+
+               if (!user_selected_something)  // Inside a selection? no...
+               {
+
+                       if (selection == NOGUI)     // Turn off GUI
+                       {
+                               show_gui = false;
+                       }
+
+                       if (selection == COINUP)    // Coin up machine
+                       {
+                               gram1[0x41A5]++;          // Add one coin... (prob. need sep. counter)
+                               num_coins++;
+                               gram1[0x4189] = num_coins / 10; // Should be in THUNDER.CPP?
+                               gram1[0x418A] = num_coins - (gram1[0x4189] * 10);
+                       }
+
+                       if (selection == PL1START)  // 1 Player start
+                       {
+                               if (num_coins)
+                               {
+                                       num_coins--;
+                                       show_gui = false;       // Shut off GUI only if coined up
+                               }
+
+                               gram1[0x418C] = 1;        // Strobe start location
+                       }
+
+                       if (selection == PL2START)  // 2 Player start
+                       {
+                               if (num_coins > 1)
+                               {
+                                       num_coins -= 2;
+                                       show_gui = false;
+                               }
+                       }
+
+                       if (selection == REFRESH)   // Toggle refresh rate
+                       {
+                               //SpawnSound(USERSOUND, SCLICK);
+                       }
+
+                       if (selection == DIPSWITCH) // Edit game settings
+                       {
+                               //SpawnSound(USERSOUND, SBLAH);
+                               user_selected_something = true;
+                               dswitch = 0;              // Set at first dipswitch
+                       }
+
+                       if (selection == OPTIONS)   // Edit emulator settings
+                       {
+                       }
+
+                       if (selection == KEYCONFIG) // Edit game keys
+                       {
+                       }
+
+                       if (selection == SNAPSHOT)  // Snapshot
+                       {
+                               SpawnSound(USERSOUND, SCAMERA);
+                               SavePCXSnapshot();
+                       }
+
+                       if (selection == RESET)     // Reset machine
+                       {
+                               //SpawnSound(USERSOUND, SRESET);
+                       }
+
+                       if (selection == EXIT)
+                       {
+                               SpawnSound(USERSOUND, SCYA);
+                       }
+
+                       return selection;
+               }
+               else           // Selected something inside selection...
+               {
+                       if (selection == DIPSWITCH)
+                       {
+                               if (dswitch == 16)  // Selected 'back to GUI'
+                               {
+                                       //SpawnSound(USERSOUND, SBLAH2);
+                                       user_selected_something = false;
+                               }
+                               else
+                               {
+                                       //SpawnSound(USERSOUND, SCLICK);
+                                       gram1[0x423D + (dswitch << 1)] = !gram1[0x423D + (dswitch << 1)];
+                               }
+                       }
+
+                       return 0xFF;  // Nothing for main to do...
+               }
+       }
+       else
+               return 0xFF;  // Wasn't debounced, so return invalid
 }
 
+
 //
 // Show byte passed to it
 //
 void ShowNumbers(int number)
 {
-  uint8 * bnarray[16] = { bn0, bn1, bn2, bn3, bn4, bn5, bn6, bn7, bn8, bn9,
-    bnA, bnB, bnC, bnD, bnE, bnF };
-  uint32 scadr = hScrollOffset + voffsets[vScrollOffset] + 642 + 2560;
-  uint16 bmpptr = 0;
-
-  uint8 first_dig = number>>4, second_dig = number&0x0F;
-  for(int y=0; y<7; y++)
-  {
-    for(int x=0; x<6; x++)
-    {
-      if (bnarray[first_dig][bmpptr++] == 1)  my_scr[scadr+x+y*320] = 7;
-      else                                    my_scr[scadr+x+y*320] = 0;
-    }
-  }
-  bmpptr = 0;  scadr += 6;
-  for(int y=0; y<7; y++)
-  {
-    for(int x=0; x<6; x++)
-    {
-      if (bnarray[second_dig][bmpptr++] == 1)  my_scr[scadr+x+y*320] = 7;
-      else                                     my_scr[scadr+x+y*320] = 0;
-    }
-  }
+       uint8_t * bnarray[16] = { bn0, bn1, bn2, bn3, bn4, bn5, bn6, bn7, bn8, bn9,
+               bnA, bnB, bnC, bnD, bnE, bnF };
+//     uint32_t scadr = hScrollOffset + voffsets[vScrollOffset] + 642 + 2560;
+       uint32_t scadr = ((2 * 288) + 2) + (8 * 288);
+       uint16_t bmpptr = 0;
+
+       uint8_t first_dig = number >> 4, second_dig = number & 0x0F;
+
+       for(int y=0; y<7; y++)
+       {
+               for(int x=0; x<6; x++)
+               {
+                       if (bnarray[first_dig][bmpptr++] == 1)
+//                             my_scr[scadr + x + y * 320] = 7;
+                               my_scr[scadr + x + y * 288] = 7;
+                       else
+//                             my_scr[scadr + x + y * 320] = 0;
+                               my_scr[scadr + x + y * 288] = 0;
+               }
+       }
+
+       bmpptr = 0;
+       scadr += 6;
+
+       for(int y=0; y<7; y++)
+       {
+               for(int x=0; x<6; x++)
+               {
+                       if (bnarray[second_dig][bmpptr++] == 1)
+//                             my_scr[scadr + x + y * 320] = 7;
+                               my_scr[scadr + x + y * 288] = 7;
+                       else
+//                             my_scr[scadr + x + y * 320] = 0;
+                               my_scr[scadr + x + y * 288] = 0;
+               }
+       }
 }
 
+
 //
 // Spawn a message
 //
-void SpawnMsg(uint8 msg)
+void SpawnMsg(uint8_t msg)
 {
-       text_life = 60;                                                                         // 1 second...
-       show_text = true;                                                                       // Show the damn thing...
-       show_which_msg = msg;                                                           // And tell it which message to show...
+       text_life = 60;                 // 1 second...
+       show_text = true;               // Show the damn thing...
+       show_which_msg = msg;   // And tell it which message to show...
 }
 
+
 //
 // Draw text message
 //
 void DrawText(void)
 {
-       if (!text_life)                                                                         // Kill text if it's time
+       // Kill text if it's time
+       if (!text_life)
        {
                show_text = false;
                return;
        }
 
-       text_life--;                                                                            // Your life force is running out...
+       // Your life force is running out...
+       text_life--;
 
        // Draw the message here...
-       uint32 scadr = hScrollOffset + voffsets[vScrollOffset] + 642;
-       uint16 bmpptr = 0;
+//     uint32_t scadr = hScrollOffset + voffsets[vScrollOffset] + 642;
+       uint32_t scadr = (288 * 2) + 2;
+       uint16_t bmpptr = 0;
 
        for(int y=0; y<7; y++)
        {
@@ -833,23 +957,29 @@ void DrawText(void)
                        if (show_which_msg == M60FPS)
                        {
                                if (bmp1[bmpptr++] == 1)
-                                       my_scr[scadr + x + y * 320] = 7;
+//                                     my_scr[scadr + x + y * 320] = 7;
+                                       my_scr[scadr + x + y * 288] = 7;
                                else
-                                       my_scr[scadr + x + y * 320] = 0;
+//                                     my_scr[scadr + x + y * 320] = 0;
+                                       my_scr[scadr + x + y * 288] = 0;
                        }
                        else if (show_which_msg == M30FPS)
                        {
                                if (bmp2[bmpptr++] == 1)
-                                       my_scr[scadr + x + y * 320] = 7;
+//                                     my_scr[scadr + x + y * 320] = 7;
+                                       my_scr[scadr + x + y * 288] = 7;
                                else
-                                       my_scr[scadr + x + y * 320] = 0;
+//                                     my_scr[scadr + x + y * 320] = 0;
+                                       my_scr[scadr + x + y * 288] = 0;
                        }
                        else if (show_which_msg == MSNAPSHOT)
                        {
                                if (bmp3[bmpptr++] == 1)
-                                       my_scr[scadr + x + y * 320] = 7;
+//                                     my_scr[scadr + x + y * 320] = 7;
+                                       my_scr[scadr + x + y * 288] = 7;
                                else
-                                       my_scr[scadr + x + y * 320] = 0;
+//                                     my_scr[scadr + x + y * 320] = 0;
+                                       my_scr[scadr + x + y * 288] = 0;
                        }
                }
        }
@@ -858,211 +988,3 @@ void DrawText(void)
                ShowNumbers(snd_num);
 }
 
-//
-// Sound stuff (Will go elsewhere??? Perhaps in sound.cpp?)
-//
-void SpawnSound(int type, int snd, int channel/* = 0*/)
-{
-       extern uint32 psg_lens[16];
-       extern uint8 * psg_adrs[16];
-       extern uint32 voc_lens[32];
-       extern uint8 * voc_adrs[32];
-       extern uint32 fm_lens[14];
-       extern uint8 * fm_adrs[14];
-
-       snd_num = snd;
-       SpawnMsg(MSHOWNUMS);
-
-       if (type == GAMESOUND)
-       {
-               snd--;                                                                                  // Will that do it???  Yes!!!
-
-               if (channel == 0)
-               {
-                       // 00 nn ss (nn # of repeats of sample ss)
-                       uint32 st = 0;
-
-                       if (snd & 0x40)
-                       {
-                               st = 0x10000;
-                               snd &= 0x0F;
-                       }
-
-                       spos1 = (voice_rom[st + (snd << 1)] << 8) | voice_rom[st + (snd << 1) + 1];
-                       spos1 += st;                                                            // Need to add start somewhere...
-                       prevSamp1 = 128;
-                       sample1 = 0;
-                       chan1_go = true;
-               }
-               else
-               {
-                       uint32 st = 0;
-
-                       if (snd & 0x40)
-                       {
-                               st = 0x10000;
-                               snd &= 0x0F;
-                       }
-
-                       spos2 = (voice_rom[st + (snd << 1)] << 8) | voice_rom[st + (snd << 1) + 1];
-                       spos2 += st;                                                            // Need to add start somewhere...
-                       prevSamp2 = 128;
-                       sample2 = 0;
-                       chan2_go = true;
-               }
-       }
-       else if (type == PSGSOUND)
-       {
-               if (snd_num & 0x10)                                                             // Second channel?
-               {
-                       spos3 = 0;
-                       end_pos3 = psg_lens[snd_num & 0x0F];
-                       sndp3 = psg_adrs[snd_num & 0x0F];
-                       chan3_go = true;
-
-                       if (spos3 == end_pos3)
-                               chan3_go = false;                                               // No sound loaded, so don't do it!
-               }
-               else                                                                                    // First channel
-               {
-                       spos4 = 0;
-                       end_pos4 = psg_lens[snd_num & 0x0F];
-                       sndp4 = psg_adrs[snd_num & 0x0F];
-                       chan4_go = true;
-
-                       if (spos4 == end_pos4)
-                               chan4_go = false;                                               // No sound loaded, so don't do it!
-               }
-       }
-       else if (type == FMSOUND)
-       {
-               spos5 = 0;
-               end_pos5 = fm_lens[snd_num];
-               sndp5 = fm_adrs[snd_num];
-               chan5_go = true;
-
-               if (spos5 == end_pos5)
-                       chan5_go = false;                                                       // No sound loaded, so don't do it!
-       }
-       else if (type == USERSOUND)
-       {
-               spos6 = 0;
-               end_pos6 = snd_lens[snd_num];                                   // User sound
-               sndp6 = snd_array[snd_num];                                             // Load pointer
-               chan6_go = true;
-       }
-}
-
-//
-// Sound card IRQ handler
-//
-void SoundFunc(void * userdata, Uint8 * buff, int num)
-{
-       uint16 cnt = 0, sample;                                                         // 0-22 different sounds...
-       uint8 start_samp1, end_samp1, start_samp2, end_samp2;
-       uint8 samp1 = 128, samp2 = 128, samp3 = 128,
-               samp4 = 128, samp5 = 128, samp6 = 128;                  // Zero samples...
-
-       memset(buff, 128, num);                                                         // Kill sound...
-
-       if (chan1_go || chan2_go || chan3_go || chan4_go || chan5_go || chan6_go)
-       {
-               while (cnt != num)
-               {
-                       if (chan1_go)
-                       {
-                               if (sample1 < 1)
-                               {
-                                       samp1 = voice_rom[spos1++];
-
-                                       if (samp1 == 0xFF)
-                                       {
-                                               chan1_go = false;
-                                               samp1 = 128;                                    // Kill channel 1 if done...
-                                       }
-                                       else if (samp1 == 0x00)                         // RLE compression...
-                                       {
-                                               sample1 += (float)voice_rom[spos1++] * sampleBase;      // # of repeats
-                                               samp1   = prevSamp1;                    // Get last good sample
-                                       }
-                                       else
-                                               sample1 += sampleBase;                  // Keep fractional part intact
-                               }
-
-                               prevSamp1 = samp1;                                              // Save last sample value
-                               sample1 -= 1.0;                                                 // Decrement repeat counter
-                       }
-
-// Stretching 5KHz samples to 22KHz:
-//   numRepeats = 4;
-//            6KHz -> 22KHz:  22/6 repeats...
-                       if (chan2_go)
-                       {
-                               if (sample2 < 1)
-                               {
-                                       samp2 = voice_rom[spos2++];
-
-                                       if (samp2 == 0xFF)
-                                       {
-                                               chan2_go = false;
-                                               samp2 = 128;                                    // Kill channel 2 if done...
-                                       }
-                                       else if (samp2 == 0x00)                         // RLE compression...
-                                       {
-                                               sample2 += (float)voice_rom[spos2++] * sampleBase;      // # of repeats
-                                               samp2   = prevSamp2;
-                                       }
-                                       else
-                                               sample2 += sampleBase;
-                               }
-
-// Delta-X values were making the samples sound like crap...
-//                             start_samp2 += delta_x2;
-                               prevSamp2 = samp2;
-                               sample2 -= 1.0;
-                       }
-
-      if (chan3_go)
-      {
-        samp3 = sndp3[spos3++];
-        if (spos3 == end_pos3)
-        {
-          chan3_go = false;  samp3 = 128; // Kill channel 3 if done...
-        }
-      }
-
-      if (chan4_go)
-      {
-        samp4 = sndp4[spos4++];
-        if (spos4 == end_pos4)
-        {
-          chan4_go = false;  samp4 = 128; // Kill channel 4 if done...
-        }
-      }
-
-      if (chan5_go)
-      {
-        samp5 = sndp5[spos5++];
-        if (spos5 == end_pos5)
-        {
-          chan5_go = false;  samp5 = 128; // Kill channel 5 if done...
-        }
-      }
-
-                       if (chan6_go)
-                       {
-                               samp6 = sndp6[spos6++];
-
-                               if (spos6 == end_pos6)
-                                       chan6_go = false, samp6 = 128;          // Kill channel 6...
-                       }
-
-                       sample = samp1 + samp2 + samp3 + samp4 + samp5 + samp6 - 640;   // Mix 'em...
-
-                       if (sample & 0xFF00)                                            // i.e., it overflowed
-                               sample = (sample&0x8000 ? 0x00 : 0xFF); // Clip it
-
-                       buff[cnt++] = sample;                                           // & store it...
-               }
-       }
-}