]> Shamusworld >> Repos - thunder/commitdiff
Added DIP switch fungibility, misc. code cleanups.
authorShamus Hammons <jlhamm@acm.org>
Thu, 1 May 2014 16:53:55 +0000 (11:53 -0500)
committerShamus Hammons <jlhamm@acm.org>
Thu, 1 May 2014 16:53:55 +0000 (11:53 -0500)
src/gui.cpp
src/screen.cpp
src/screen.h
src/thunder.cpp
src/video.cpp
src/video.h

index 9eae58bc33d04252ec9826785359d1d5f1bd11c9..a3379721e10d3b242038f6d602e79e7632431643 100644 (file)
@@ -2,7 +2,7 @@
 // Thunder Graphic User Interface
 //
 // by James Hammons
-// (c) 2004, 2014 Underground Software
+// (C) 2004, 2014 Underground Software
 //
 // JLH = James Hammons <jlhamm@acm.org>
 //
@@ -14,7 +14,6 @@
 #include "gui.h"
 
 #include <string>
-#include <fstream>       // Needed for tracelog
 #include "screen.h"
 #include "sound.h"
 #include "resource.h"    // Thunder graphics & sounds
@@ -23,14 +22,8 @@ using namespace std;
 
 // External shit
 
-extern SDL_Surface * screen;
-
 extern uint8_t my_scr[0x14000];                // Screen buffer...
 extern uint8_t gram1[];                                // Game RAM (do here??)
-extern uint8_t hScrollOffset;          // Horizontal scroll offset
-extern uint8_t vScrollOffset;          // Vertical scroll offset
-extern uint32_t voffsets[8];
-extern fstream tr;                                     // Tracelog
 
 // Global shit
 
@@ -238,7 +231,7 @@ uint8_t bnF[] = {
   };
 
 
-  //
+//
 // Initialize GUI
 //
 void InitGUI(void)
@@ -351,7 +344,7 @@ void DrawSmallIcons(uint16_t icon_not_to_draw)
                xl = xlens[iconidx[idx]];
                yl = ylens[iconidx[idx]];
 
-               uint32_t scadr = hScrollOffset + voffsets[vScrollOffset];
+               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;
@@ -379,7 +372,7 @@ void DrawSmallIcons(uint16_t icon_not_to_draw)
                xl = xlens[iconidx[idx]];
                yl = ylens[iconidx[idx]];
 
-               uint32_t scadr = hScrollOffset + voffsets[vScrollOffset];
+               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;
@@ -446,7 +439,7 @@ void DrawLargeIcon(uint16_t icon)
                yl = ylens[6];
        }
 
-       uint32_t scadr = hScrollOffset + voffsets[vScrollOffset];
+       uint32_t scadr;// = hScrollOffset + voffsets[vScrollOffset];
        scadr += 320 * ((224 - yl) / 2);                // Center vertically
        scadr += (288 - xl) / 2;                      // Center horizontally
        uint16_t bmpptr = 0;
@@ -516,7 +509,7 @@ void DrawDipswitch(void)
        uint32_t scadr, bmpptr;
        //dsx = //26x65
 
-       uint32_t dbase = hScrollOffset + voffsets[vScrollOffset];
+       uint32_t dbase;// = hScrollOffset + voffsets[vScrollOffset];
        dbase += (288 - 26) / 2;                 // Center horizontally
        dbase += 320 * ((224 - ((65 * 2) + 8)) / 2);   // Center vertically
 
index dda0f6e665eb42f349723213b4b688e370e8384c..d3f5672c214db805ef7779b2e120f6a7c34e933e 100644 (file)
@@ -1,12 +1,9 @@
 //
 // Screen Handler
 //
-// This sets screen to VESA 320x240 LFB so we can use the WHOLE laptop screen
-// Now with VESA2 support!
-// Also, support routines for video hardware emulation are included
+// This emulates the NAMCO tile/sprite hardware
 //
 // by James Hammons
-//
 // (C) 2003 Underground Software
 //
 // JLH = James Hammons <jlhamm@acm.org>
 
 void DrawSprites(uint8_t priority);
 int FindPCXName(void);
-//static void DrawChar(uint8_t * chr, uint8_t * ram, uint8_t sx, uint8_t sy, uint16_t scp, uint32_t baseAddr, uint32_t scrollOffset, bool transparent = true);
-static void DrawChar(uint8_t * chr, uint8_t * ram, uint8_t sx, uint8_t sy, uint16_t scp, uint32_t baseAddr, uint32_t xScroll = 0, uint32_t yScroll = 0, bool transparent = true);
+static inline void DrawScreen(uint16_t ramBlock, uint16_t xAddress, uint16_t yAddress, uint32_t baseAddr, bool transparent = true);
+static void DrawChar(uint8_t sx, uint8_t sy, uint16_t scp, uint32_t baseAddr, uint32_t xScroll, uint32_t yScroll, bool transparent = true);
 void Sprite(uint32_t sprnum, uint16_t x, uint16_t y, uint8_t flip, uint8_t horiz_bl, uint8_t vert_bl);
 
 // Private global variables
 
-uint8_t my_scr[0x14000];                       // Screen buffer...
-//uint8_t palette[768];                                // Screen palette
-uint32_t palette[256];                         // Screen palette
-uint8_t ccolor[256][8];                                // Character colors
-uint8_t scolor[128][16];                       // Sprite colors
-bool charbase;                                         // Character base pointer...
-uint8_t hScrollOffset;                         // Horizontal scroll offset
-uint8_t vScrollOffset;                         // Vertical scroll offset
-uint8_t spr_color_index;                       // Sprite color index
-//uint32_t hoffsets[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };// Scroll offsets...
-//uint32_t voffsets[8] = { 0, 320, 640, 960, 1280, 1600, 1920, 2240 };
-uint32_t voffsets[8] = { 288*0, 288*1, 288*2, 288*3, 288*4, 288*5, 288*6, 288*7 };
+uint8_t my_scr[0x14000];               // Screen buffer...
+uint32_t palette[256];                 // Screen palette
+uint8_t ccolor[256][8];                        // Character colors
+uint8_t scolor[128][16];               // Sprite colors
+bool charBankSwitch;                   // Character bank switch
+uint8_t spr_color_index;               // Sprite color index
 
-extern bool show_text;                         // Whether or not to show text
-extern bool show_scr;                          // Whether or not to show screen
+extern bool show_text;                 // Whether or not to show text
 
 
 //
 // Render the NAMCO screen
 //
-void BlitChar(SDL_Surface * scr, uint8_t * chr, uint8_t * ram)
+void BlitChar(uint8_t * chr, uint8_t * ram)
 {
        // Screen structure:
+       //
+       // Each screen RAM is 4K in size, from lowest to highest priority:
+       // $0000-$0FFF, $1000-$1FFF, $2000-$2FFF, $3000-$3FFF
+       //
        // Screen is 288 x 224 pixels, with character and independent sprites.
-       // Tiles are 36 x 28. There are four tile planes, three of them affected by
-       // the h/vscroll values, the last one is a static display (also has highest
-       // priority). Screens are 128 bytes wide by 32 bytes high.
-
-       if (show_scr)
-       {
-               uint32_t sc_base = ((ram[0x9000] << 8) | ram[0x9001]) + 4;      // Adjust hscroll val
-               hScrollOffset = sc_base & 0x07;         // Horiz. fine scroll offset
-               sc_base = (sc_base & 0xFFF8) >> 2;      // Skip odds..
-               uint8_t vsc_base = ((ram[0x9002] + 1) & 0xF8) >> 3;// Vertical scroll addr adjust
-               vScrollOffset = ((ram[0x9002] + 1) & 0x07);     // Vertical fine scroll amount
-
-               uint32_t scp0 = 0x0180 | ((sc_base + 0x04) & 0x7F);     /*0x0188;*/
-               uint32_t scp1 = 0x1180 | ((sc_base + 0x04) & 0x7F);     /*0x1188;*/
-               uint32_t scp2 = 0x2180 | ((sc_base + 0x04) & 0x7F);     /*0x2188;*/
-               uint32_t scp3 = 0x3208;
-
-               scp0 += vsc_base * 0x80;
-               scp0 &= 0x0FFF;                                         // Set vertical scroll addr
-               scp1 += vsc_base * 0x80;
-               scp1 = 0x1000 | (scp1 & 0x0FFF);        // Set vertical scroll addr
-               scp2 += vsc_base * 0x80;
-               scp2 = 0x2000 | (scp2 & 0x0FFF);        // Set vertical scroll addr
-
-               // Layer 0 (bottom layer)
-               for(uint8_t sy=0; sy<29; sy++)
-               {
-                       for(uint8_t sx=0; sx<37; sx++)
-                               DrawChar(chr, ram, sx, sy, scp0, (charbase ? 0x20000 : 0x00000), hScrollOffset, vScrollOffset, false);
-
-                       scp0 += 0x80;
-                       scp0 = 0x0000 | (scp0 & 0x0FFF);
-               }
-
-               // Draw sprites at lowest layer...
-               DrawSprites(0x40);
-
-               // Layer 1
-               for(uint8_t sy=0; sy<29; sy++)
-               {
-                       for(uint8_t sx=0; sx<37; sx++)
-                               DrawChar(chr, ram, sx, sy, scp1, (charbase ? 0x30000 : 0x10000), hScrollOffset, vScrollOffset);
-
-                       scp1 += 0x80;
-                       scp1 = 0x1000 | (scp1 & 0x0FFF);
-               }
-
-               // Draw sprites under layer #2...
-               DrawSprites(0x80);
-
-               // Layer 2
-               for(uint8_t sy=0; sy<29; sy++)
-               {
-                       for(uint8_t sx=0; sx<37; sx++)
-                               DrawChar(chr, ram, sx, sy, scp2, 0x40000, hScrollOffset, vScrollOffset);
-
-                       scp2 += 0x80;
-                       scp2 = 0x2000 | (scp2 & 0x0FFF);
-               }
-
-               // Draw highest priority sprites...
-               DrawSprites(0xC0);
-
-               // Layer 3 (top layer)
-               for(uint8_t sy=0; sy<28; sy++)
-               {
-                       for(uint8_t sx=0; sx<36; sx++)
-                               DrawChar(chr, ram, sx, sy, scp3, 0x50000);
-
-                       scp3 += 0x80;
-               }
-       }
+       // Tiles are 36 x 28. There are four tile planes, all of them affected by
+       // their own h/vscroll values. Screens are 128 bytes wide by 32 bytes high.
+       //
+       // Also note that tiles are 16-bits wide, meaning the screen is really
+       // only 64 characters wide!
+
+       // Base address is $9000-1 (top 13 bits) + $9002 >> 3 << 7 (top 5 bits)
+/*
+$9000-2: $02 $0C $FF  0000 0010  0000 1100  1111 1111
+$9004-6: $06 $0E $FF  0000 0110  0000 1110  1111 1111
+$9400-2: $0A $0B $FF  0000 1010  0000 1011  1111 1111
+$9404-6: $0E $0D $07  0000 1110  0000 1101  0000 0111
+                      ---- PP?H  HHHH Hhhh  VVVV Vvvv
+? = refresh layer bit?
+PP = which 4K block to write to?
+*/
+       uint16_t screenX0 = (((ram[0x9000] << 8) | ram[0x9001]) + 20) & 0x1FF;
+       uint16_t screenX1 = (((ram[0x9004] << 8) | ram[0x9005]) + 18) & 0x1FF;
+       uint16_t screenX2 = (((ram[0x9400] << 8) | ram[0x9401]) + 21) & 0x1FF;
+       uint16_t screenX3 = (((ram[0x9404] << 8) | ram[0x9405]) + 19) & 0x1FF;
+
+       uint16_t screenY0 = ram[0x9002] + 25;
+       uint16_t screenY1 = ram[0x9006] + 25;
+       uint16_t screenY2 = ram[0x9402] + 25;
+       uint16_t screenY3 = ram[0x9406] + 25;
+
+       uint16_t ramBlock0 = (ram[0x9000] >> 2) & 0x03;
+       uint16_t ramBlock1 = (ram[0x9004] >> 2) & 0x03;
+       uint16_t ramBlock2 = (ram[0x9400] >> 2) & 0x03;
+       uint16_t ramBlock3 = (ram[0x9404] >> 2) & 0x03;
+
+       DrawScreen(ramBlock0, screenX0, screenY0, (charBankSwitch ? 2 : 0), false);
+       DrawSprites(0x40);
+       DrawScreen(ramBlock1, screenX1, screenY1, (charBankSwitch ? 3 : 1));
+       DrawSprites(0x80);
+       DrawScreen(ramBlock2, screenX2, screenY2, 4);
+       DrawSprites(0xC0);
+       DrawScreen(ramBlock3, screenX3, screenY3, 5);
 
        // Draw a msg if needed...
        if (show_text)
@@ -143,34 +103,49 @@ void BlitChar(SDL_Surface * scr, uint8_t * chr, uint8_t * ram)
        // Rolling Thunder screen size is 288 x 224. Virtual is this, real may not
        // be... (and we don't have to care about that, the OpenGL backend takes
        // care of it.)
+       for(uint32_t i=0; i<VIRTUAL_SCREEN_WIDTH*VIRTUAL_SCREEN_HEIGHT; i++)
+               scrBuffer[i] = palette[my_scr[i]];
+
+       RenderScreenBuffer();
+}
+
 
-       uint32_t src = 0;
+//
+// Render tilemap
+//
+static inline void DrawScreen(uint16_t ramBlock, uint16_t xAddress, uint16_t yAddress, uint32_t tileBase, bool transparent/*= true*/)
+{
+       uint16_t ramBase = (ramBlock << 12) | ((yAddress << 4) & 0xF80)
+               | ((xAddress >> 2) & 0x7E);
 
-       for(int i=0; i<VIRTUAL_SCREEN_HEIGHT; i++)
+       for(uint8_t sy=0; sy<29; sy++)
        {
-               for (int j=0; j<VIRTUAL_SCREEN_WIDTH; j++)
+               for(uint8_t sx=0; sx<37; sx++)
                {
-                       scrBuffer[src] = palette[my_scr[src]];
-                       src++;
+
+                       DrawChar(sx, sy, ramBase, tileBase << 16, xAddress & 0x07, yAddress & 0x07, transparent);
                }
        }
-
-       RenderScreenBuffer();
 }
 
 
 //
 // Draw character on screen
 //
-//static inline void DrawChar(uint8_t * chr, uint8_t * ram, uint8_t sx, uint8_t sy, uint16_t scp, uint32_t baseAddr, uint32_t scrollOffset, bool transparent/*= true*/)
-static inline void DrawChar(uint8_t * chr, uint8_t * ram, uint8_t sx, uint8_t sy, uint16_t scp, uint32_t baseAddr, uint32_t xScroll/*= 0*/, uint32_t yScroll/*= 0*/, bool transparent/*= true*/)
+static inline void DrawChar(uint8_t sx, uint8_t sy, uint16_t ramBase, uint32_t tileBase, uint32_t xScroll, uint32_t yScroll, bool transparent/*= true*/)
 {
-       uint8_t scp_lo = (scp + (sx << 1)) & 0x7F;// Let LO byte wrap only...
-       uint16_t sp2 = (scp & 0xFF80) | scp_lo;
-       uint8_t tile  = ram[sp2++];
-       uint8_t index = ram[sp2] & 0x03;
-       uint8_t color = ram[sp2];
-       uint32_t chind = baseAddr + (((index << 8) + tile) * 64);
+       extern uint8_t charROM[];
+       extern uint8_t gram1[];
+
+       // Calculate address in RAM of tile to draw
+       uint16_t addr = (ramBase & 0xF000) | ((ramBase + (sy << 7)) & 0x0F80)
+               | ((ramBase + (sx << 1)) & 0x7F);
+       uint16_t tile  = ((gram1[addr + 1] << 8) | gram1[addr]) & 0x03FF;
+       // Yes, it really requires all 8 bits... even though the bottom 3 are used
+       // as a tile address!
+       uint8_t color = gram1[addr + 1];
+       uint32_t chind = tileBase + (tile << 6);
+
        int xStart = (int)(sx * 8) - xScroll;
        int yStart = (int)(sy * 8) - yScroll;
        int32_t sc_addr = xStart + (yStart * 288);
@@ -179,6 +154,7 @@ static inline void DrawChar(uint8_t * chr, uint8_t * ram, uint8_t sx, uint8_t sy
        {
                for(int x=0; x<8; x++)
                {
+                       // Clipping...
                        if (((xStart + x) < 0) || ((xStart + x) >= 288)
                                || ((yStart + y) < 0) || ((yStart + y) >= 224))
                        {
@@ -187,13 +163,8 @@ static inline void DrawChar(uint8_t * chr, uint8_t * ram, uint8_t sx, uint8_t sy
                                continue;
                        }
 
-                       if (transparent)
-                       {
-                               if (chr[chind] != 7)
-                                       my_scr[sc_addr] = ccolor[color][chr[chind]];
-                       }
-                       else
-                               my_scr[sc_addr] = ccolor[color][chr[chind]];
+                       if (!(transparent && (charROM[chind] == 7)))
+                               my_scr[sc_addr] = ccolor[color][charROM[chind]];
 
                        sc_addr++;
                        chind++;
@@ -204,6 +175,24 @@ static inline void DrawChar(uint8_t * chr, uint8_t * ram, uint8_t sx, uint8_t sy
 }
 
 
+//
+// Copy sprites in sprite RAM from positions 4-9 to 10-15
+// (N.B.: This still doesn't solve the shifting signs on the walls problem...)
+//
+void CopySprites(void)
+{
+       extern uint8_t gram1[];
+
+       for(uint16_t i=0x5800; i<0x6000; i+=0x10)
+       {
+               for(uint16_t j=4; j<=9; j++)
+               {
+                       gram1[i + j + 6] = gram1[i + j];
+               }
+       }
+}
+
+
 //
 // Draw sprites at priority level (new code)
 //
@@ -227,23 +216,23 @@ void DrawSprites(uint8_t priority)
 
        for(uint16_t i=0x5800; i<0x6000; i+=0x10)
        {
-               if ((gram1[i + 8] & 0xC0) == priority)          // Check for correct layer...
+               if ((gram1[i + 8 + 6] & 0xC0) == priority)              // Check for correct layer...
                {
-                       spr_color_index = gram1[i + 6] >> 1;    // Set color...
-                       uint16_t x = ((gram1[i + 6] & 0x01) << 8) | gram1[i + 7];
+                       spr_color_index = gram1[i + 6 + 6] >> 1;        // Set color...
+                       uint16_t x = ((gram1[i + 6 + 6] & 0x01) << 8) | gram1[i + 7 + 6];
 
                        if (x > 512 - 32)
                                x -= 512;                                                       // Handle neg x values
 
-                       uint16_t y = 192 - gram1[i + 9];
-                       uint8_t flip = gram1[i + 4] & 0x20;             // Horizontal flip
-                       uint32_t spr_num = ((gram1[i + 4] & 0x07) << 9)
-                               | ((gram1[i + 5] & 0x7F) << 2)
-                               | ((gram1[i + 4] & 0x10) >> 4)
-                               | ((gram1[i + 8] & 0x10) >> 3);
+                       uint16_t y = 192 - gram1[i + 9 + 6];
+                       uint8_t flip = gram1[i + 4 + 6] & 0x20;         // Horizontal flip
+                       uint32_t spr_num = ((gram1[i + 4 + 6] & 0x07) << 9)
+                               | ((gram1[i + 5 + 6] & 0x7F) << 2)
+                               | ((gram1[i + 4 + 6] & 0x10) >> 4)
+                               | ((gram1[i + 8 + 6] & 0x10) >> 3);
 
                        // Draw sprite...
-                       Sprite(spr_num, x, y, flip, gram1[i + 4] & 0x80, gram1[i + 8] & 0x04);
+                       Sprite(spr_num, x, y, flip, gram1[i + 4 + 6] & 0x80, gram1[i + 8 + 6] & 0x04);
                }
        }
 }
index 6ea06f4818bacc461dbaf2b2f90a0c10272ca9bc..bc1e2ec53763e03899e7a92d3697b5a18aab10de 100644 (file)
 #include <SDL2/SDL.h>
 #include <stdint.h>
 
-void BlitChar(SDL_Surface *, uint8_t *, uint8_t *);
+void BlitChar(uint8_t *, uint8_t *);
+void CopySprites(void);
 void SavePCXSnapshot(void);
 
+// Exported vars
+extern uint32_t palette[256];  // Screen physical palette
+extern uint8_t ccolor[256][8]; // Character color PROM values
+extern uint8_t scolor[128][16];        // Sprite color PROM values
+extern bool charBankSwitch;
+
 #endif // __SCREEN_H__
 
index ace26f29716faf7b51b9f8a977d4b8abf637e077..bd0cc855ab903cfa0409ce278aaccd06c5f3a747 100644 (file)
 // JLH  04/17/2014  Removed a metric fuck-tonne of cruft, added YM2151 & MCU
 //
 
-#define THUNDER_VERSION                "1.1.0"
+#define THUNDER_VERSION                "1.2.0"
 
 #include <SDL2/SDL.h>
-#include <iostream>
-#include <iomanip>
-#include <fstream>
 #include <string>
-#include <new>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -37,9 +33,6 @@
 #include "ym2151.h"
 
 
-using namespace std;
-
-
 #define ROM1   "rt3-1b.9c"
 #define ROM2   "rt3-2b.12c"
 #define ROM3   "rt3-3.12d"
@@ -72,39 +65,21 @@ using namespace std;
 
 // Global defines
 
-SDL_Surface * screen;
-
-uint8_t * gram, * grom;                        // Allocate RAM & ROM pointers
-// Actual memory
-uint8_t gram1[0x10000], gram2[0x10000], grom1[0x10000], grom2[0x10000];
+uint8_t gram1[0x10000], grom1[0x10000], grom2[0x10000];
 uint8_t grom3[0x8000], data_rom[0x40000], spr_rom[0x80000], voice_rom[0x20000];
-uint8_t chr_rom[0x60000];              // Character ROM pointer
+uint8_t charROM[0x60000];              // Character ROM
 uint8_t mcuMem[0x10000];               // 64K for MCU
 
-V6809REGS cpu1, cpu2;                  // CPU execution contexts
+// CPU execution contexts
+V6809REGS cpu1, cpu2;
 V63701REGS mcu;
 
-bool trace1 = false;                   // ditto...
-bool looking_at_rom = true;            // true = R1, false = R2
-uint32_t banksw1, banksw2;             // Bank switch addresses
-uint16_t game_over_switch;             // Game over delay
-uint16_t dpc;                                  // Debug pc reg...
-bool show_scr = true;                  // Whether or not to show background
-bool enable_cpu = true;                        // Whether or not to enable CPUs
-bool irqGoA = true;                            // IRQ switch for CPU #1
-bool irqGoB = true;                            // IRQ switch for CPU #2
-
-uint16_t refresh_ = 0;                 // Crappy global screen stuff...
-bool refresh2 = true;
-
-uint32_t psg_lens[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-uint8_t * psg_adrs[16];
+// Bank switch addresses
+uint32_t banksw1, banksw2;
 
+// MCU inputs
 Byte input1, input2, input3, input4, input5;
 
-fstream tr;                                                    // Tracelog hook
-uint16_t pcx;                                          // Where we at?
-
 // Function prototypes
 uint8_t MCUReadMemory(uint16_t address);
 void MCUWriteMemory(uint16_t address, uint8_t data);
@@ -113,7 +88,7 @@ void MCUWriteMemory(uint16_t address, uint8_t data);
 //
 // Read a byte from memory
 //
-uint8_t RdMem(uint16_t addr)
+uint8_t MainReadMemory(uint16_t addr)
 {
        uint8_t b;
 
@@ -122,15 +97,11 @@ uint8_t RdMem(uint16_t addr)
                // Memory shared with MCU (CPU #1 only! CPU #2 does not)
                if ((addr >= 0x4000) && (addr <= 0x43FF))
                        return mcuMem[addr - 0x3000];
-//             if ((addr >= 0x4000) && (addr <= 0x41FF))
-//                     return MCUReadMemory(addr - 0x3000);
-//             if ((addr >= 0x4200) && (addr <= 0x43FF))
-//                     return mcuMem[addr - 0x3000];
 
                if (addr >= 0x6000)
                        return data_rom[banksw1 + (addr - 0x6000)];     // Get char data
-               else
-                       return gram1[addr];
+
+               return gram1[addr];
        }
 
        return grom1[addr];
@@ -140,59 +111,34 @@ uint8_t RdMem(uint16_t addr)
 //
 // Write a byte to memory
 //
-void WrMem(uint16_t address, uint8_t data)
+void MainWriteMemory(uint16_t address, uint8_t data)
 {
        extern bool disasm;
-       extern bool charbase;   // Needed for screen. Extern it in it??
-#if 0
-       if (address == 0x4182)
-       {
-               WriteLog("\nWriteMem: CPU #1 writing $%02X to $4182!\n\n", b);
-       }
-#endif
-#if 0
-if (((address >= 0x4180) && (address <= 0x4191)) || (address == 0x4380))
-       printf("WriteMem: CPU #1 writing $%02X to $%04X...\n", b, address);
-#endif
 
        if (address == 0x6000)
-{
-//printf("Spawning VOICE channel #1: $6000=$%02X, $6200=$%02X\n", b, gram1[0x6200]);
                SpawnSound(GAMESOUND, gram1[0x6200], 0);        // Do voice chan 1
-}
        if (address == 0x6400)
-{
-//printf("Spawning VOICE channel #2: $6400=$%02X, $6600=$%02X\n", b, gram1[0x6600]);
                SpawnSound(GAMESOUND, gram1[0x6600], 1);        // Do voice chan 2
-}
        if (address == 0x6800)
                banksw1 = (uint32_t)data << 13;                         // Set char data bankswitch base address
-       if (address > 0x4284 && address < 0x42A5 && data)
-               SpawnSound(PSGSOUND, address - 0x4285);         // Do PSG sound on chans 2, 3
 
-//if ((address >= 0x4284) && (address < 0x42A5))
-//{
-//     printf("WrMem: Wrote $%02X to PSG address $%04X...\n", data, address);
-//}
        // Memory shared with MCU (CPU #1 only! CPU #2 does not)
        if ((address >= 0x4000) && (address <= 0x43FF))
                mcuMem[address - 0x3000] = data;
-//     if ((address >= 0x4000) && (address <= 0x41FF))
-//             MCUWriteMemory(address - 0x3000, data);
-//     if ((address >= 0x4200) && (address <= 0x43FF))
-//             mcuMem[address - 0x3000] = data;
        else
                gram1[address] = data;
 
+       if (address == 0x5FF2)
+               CopySprites();
        if (address == 0x8800)
-               charbase = false;                                                       // Char banksw1
+               charBankSwitch = false;         // Char banksw1
        if (address == 0x8C00)
-               charbase = true;                                                        // Char banksw2
-       if (address == 0x8400)                                                          // Frame go strobe? VBlank acknowledge?
+               charBankSwitch = true;          // Char banksw2
+       if (address == 0x8400)          // Frame go strobe? VBlank acknowledge?
        {
-               BlitChar(screen, chr_rom, gram1);
+//             BlitChar(charROM, gram1);
 
-               // IRQ Ack (may also be frame go...
+               // IRQ Ack (may also be frame go...)
                ClearLineOfCurrentV6809(V6809_ASSERT_LINE_IRQ);
 #if 1
        if (disasm)
@@ -205,7 +151,7 @@ if (((address >= 0x4180) && (address <= 0x4191)) || (address == 0x4380))
 //
 // Read a byte from memory (2nd processor)
 //
-uint8_t RdMemB(uint16_t address)
+uint8_t SubReadMemory(uint16_t address)
 {
        if (address < 0x8000)
        {
@@ -224,10 +170,9 @@ uint8_t RdMemB(uint16_t address)
 //
 // Write a byte to memory (2nd processor)
 //
-void WrMemB(uint16_t address, uint8_t data)
+void SubWriteMemory(uint16_t address, uint8_t data)
 {
        extern bool disasm;
-       extern bool charbase;
 
        // Set sprite data bank switch
        if (address == 0xD803)
@@ -239,6 +184,9 @@ void WrMemB(uint16_t address, uint8_t data)
        if ((address >= 0x2000) && (address < 0x6000))
                gram1[address - 0x2000] = data;
 
+       if (address == 0x1FF2)
+               CopySprites();
+
        if (address == 0x8800)
        {
                // IRQ Ack (may also be frame go...)
@@ -256,7 +204,6 @@ uint8_t MCUReadMemory(uint16_t address)
        if (address < 0x20)
                return InternalRegisterRead(address);
        else if ((address >= 0x1000) && (address <= 0x113F))
-//     else if ((address >= 0x1000) && (address <= 0x11FF))
                return ReadPSG(address - 0x1000);
        else if ((address >= 0x2000) && (address <= 0x2001))
                return YMReadReg(0);
@@ -288,7 +235,6 @@ void MCUWriteMemory(uint16_t address, uint8_t data)
                || (address >= 0xF000))
                return;
        else if ((address >= 0x1000) && (address <= 0x113F))
-//     else if ((address >= 0x1000) && (address <= 0x11FF))
        {
                WritePSG(address - 0x1000, data);
                return;
@@ -364,75 +310,60 @@ bool LoadImg(const char * filename, uint8_t * mem, uint32_t address, uint32_t le
 //
 bool ReadColorPROMs(void)
 {
-       fstream ff1, ff2;
-       //  uint8_t ch;
-       char ch;
-       extern uint32_t palette[256];     // Screen physical palette
-       extern uint8_t ccolor[256][8];   // Character color PROM values
-       extern uint8_t scolor[128][16];  // Sprite color PROM values
-
-       ff1.open("./ROMs/"PROM3, ios::binary | ios::in);
+       FILE * file1 = fopen("./ROMs/"PROM3, "rb");
 
-       if (ff1)
+       if (file1)
        {
                for(int i=0; i<256; i++) // Load char pallete with PROM values
-               {
                        for(int j=0; j<8; j++)
-                       {
-                               ff1.get(ch);
-                               ccolor[i][j] = (uint8_t)ch;
-                       }
-               }
+                               ccolor[i][j] = (uint8_t)fgetc(file1);
 
-               ff1.close();
+               fclose(file1);
        }
 
-       ff1.open("./ROMs/"PROM4, ios::binary | ios::in);
+       file1 = fopen("./ROMs/"PROM4, "rb");
 
-       if (ff1)
+       if (file1)
        {
                for(int i=0; i<128; i++) // Load sprite pallete with PROM values
-               {
                        for(int j=0; j<16; j++)
-                       {
-                               ff1.get(ch);
-                               scolor[i][j] = (uint8_t)ch;
-                       }
-               }
+                               scolor[i][j] = (uint8_t)fgetc(file1);
 
-               ff1.close();
+               fclose(file1);
        }
 
-       ff1.open("./ROMs/"PROM1, ios::binary | ios::in);
-       ff2.open("./ROMs/"PROM2, ios::binary | ios::in);
+       file1 = fopen("./ROMs/"PROM1, "rb");
+       FILE * file2 = fopen("./ROMs/"PROM2, "rb");
 
        // If open was successful...
-       if (ff1 && ff2)
+       if (file1 && file2)
        {
                // Palette is 12-bit RGB, we stretch it to 24-bit
                for(int i=0; i<256; i++)
                {
-                       char c1, c2;
-                       ff1.get(c1);
-                       ff2.get(c2);
+                       uint8_t c1 = fgetc(file1);
+                       uint8_t c2 = fgetc(file2);
                        uint8_t r = (uint8_t)c1 & 0x0F;
                        uint8_t g = (uint8_t)c1 >> 4;
                        uint8_t b = (uint8_t)c2;
                        palette[i] = 0xFF000000 | (b << 20) | (b << 16) | (g << 12) | (g << 8) | (r << 4) | r;
                }
 
-               ff1.close();
-               ff2.close();
+               fclose(file1);
+               fclose(file2);
        }
 
        // PROM5 has the following in it (tile address decoder):
        // 00:  00 20 40 60  02 22 42 62  04 24 44 64  06 26 46 66
        // 10:  88 A8 C8 E8  8A AA CA EA  8C AC CC EC  8E AE CE EE 
 
-       if (!ff1)
+       if (!file1)
+       {
                printf("Could not open PROM files!\n");
+               return false;
+       }
 
-       return ff1;
+       return true;
 }
 
 
@@ -441,58 +372,66 @@ bool ReadColorPROMs(void)
 //
 bool UnpackFonts(void)
 {
-//  uint8_t b1, b2, b3;
-       char b1, b2, b3;
-       fstream f1, f2;
-       //0x4000 $800 chars
-       f1.open("./ROMs/"ROM7, ios::binary | ios::in);
-       f2.open("./ROMs/"ROM8, ios::binary | ios::in);
+       // 0x4000 $800 chars
+       FILE * file1 = fopen("./ROMs/"ROM7, "rb");
+       FILE * file2 = fopen("./ROMs/"ROM8, "rb");
 
-       if ((!f1) || (!f2))
-               return false;  // Return if not found...
+       if (!file1 || !file2)
+       {
+               printf("Could not open either "ROM7" or "ROM8"!\n");
+               return false;
+       }
 
        for(long i=0; i<0x40000; i+=64)
        {
                for(int j=0; j<64; j+=8)
                {
-                       f1.get(b1);  f1.get(b2);  f2.get(b3);
-                       b3 ^= 0xFF; // Invert top data...
-                       chr_rom[i+j] = ((b3 & 0x80) >> 5) | ((b1 & 0x80) >> 6) | ((b1 & 0x08) >> 3);
-                       chr_rom[i+j+1] = ((b3 & 0x40) >> 4) | ((b1 & 0x40) >> 5) | ((b1 & 0x04) >> 2);
-                       chr_rom[i+j+2] = ((b3 & 0x20) >> 3) | ((b1 & 0x20) >> 4) | ((b1 & 0x02) >> 1);
-                       chr_rom[i+j+3] = ((b3 & 0x10) >> 2) | ((b1 & 0x10) >> 3) | (b1 & 0x01);
-                       chr_rom[i+j+4] = ((b3 & 0x08) >> 1) | ((b2 & 0x80) >> 6) | ((b2 & 0x08) >> 3);
-                       chr_rom[i+j+5] = (b3 & 0x04)        | ((b2 & 0x40) >> 5) | ((b2 & 0x04) >> 2);
-                       chr_rom[i+j+6] = ((b3 & 0x02) << 1) | ((b2 & 0x20) >> 4) | ((b2 & 0x02) >> 1);
-                       chr_rom[i+j+7] = ((b3 & 0x01) << 2) | ((b2 & 0x10) >> 3) | (b2 & 0x01);
+                       uint8_t b1 = (uint8_t)fgetc(file1);
+                       uint8_t b2 = (uint8_t)fgetc(file1);
+                       uint8_t b3 = (uint8_t)fgetc(file2) ^ 0xFF;
+                       charROM[i + j + 0] = ((b3 & 0x80) >> 5) | ((b1 & 0x80) >> 6) | ((b1 & 0x08) >> 3);
+                       charROM[i + j + 1] = ((b3 & 0x40) >> 4) | ((b1 & 0x40) >> 5) | ((b1 & 0x04) >> 2);
+                       charROM[i + j + 2] = ((b3 & 0x20) >> 3) | ((b1 & 0x20) >> 4) | ((b1 & 0x02) >> 1);
+                       charROM[i + j + 3] = ((b3 & 0x10) >> 2) | ((b1 & 0x10) >> 3) | (b1 & 0x01);
+                       charROM[i + j + 4] = ((b3 & 0x08) >> 1) | ((b2 & 0x80) >> 6) | ((b2 & 0x08) >> 3);
+                       charROM[i + j + 5] = (b3 & 0x04)        | ((b2 & 0x40) >> 5) | ((b2 & 0x04) >> 2);
+                       charROM[i + j + 6] = ((b3 & 0x02) << 1) | ((b2 & 0x20) >> 4) | ((b2 & 0x02) >> 1);
+                       charROM[i + j + 7] = ((b3 & 0x01) << 2) | ((b2 & 0x10) >> 3) | (b2 & 0x01);
                }
        }
 
-       f1.close();
-       f2.close();
+       fclose(file1);
+       fclose(file2);
+
+       file1 = fopen("./ROMs/"ROM5, "rb");
+       file2 = fopen("./ROMs/"ROM6, "rb");
 
-       f1.open("./ROMs/"ROM5, ios::binary | ios::in);
-       f2.open("./ROMs/"ROM6, ios::binary | ios::in);
+       if (!file1 || !file2)
+       {
+               printf("Could not open either "ROM5" or "ROM6"!\n");
+               return false;
+       }
 
        for(long i=0x40000; i<0x60000; i+=64)
        {
                for(int j=0; j<64; j+=8)
                {
-                       f1.get(b1);  f1.get(b2);  f2.get(b3);
-                       b3 ^= 0xFF;                             // Invert top data
-                       chr_rom[i+j] = ((b3 & 0x80) >> 5) | ((b1 & 0x80) >> 6) | ((b1 & 0x08) >> 3);
-                       chr_rom[i+j+1] = ((b3 & 0x40) >> 4) | ((b1 & 0x40) >> 5) | ((b1 & 0x04) >> 2);
-                       chr_rom[i+j+2] = ((b3 & 0x20) >> 3) | ((b1 & 0x20) >> 4) | ((b1 & 0x02) >> 1);
-                       chr_rom[i+j+3] = ((b3 & 0x10) >> 2) | ((b1 & 0x10) >> 3) | (b1 & 0x01);
-                       chr_rom[i+j+4] = ((b3 & 0x08) >> 1) | ((b2 & 0x80) >> 6) | ((b2 & 0x08) >> 3);
-                       chr_rom[i+j+5] = (b3 & 0x04)        | ((b2 & 0x40) >> 5) | ((b2 & 0x04) >> 2);
-                       chr_rom[i+j+6] = ((b3 & 0x02) << 1) | ((b2 & 0x20) >> 4) | ((b2 & 0x02) >> 1);
-                       chr_rom[i+j+7] = ((b3 & 0x01) << 2) | ((b2 & 0x10) >> 3) | (b2 & 0x01);
+                       uint8_t b1 = (uint8_t)fgetc(file1);
+                       uint8_t b2 = (uint8_t)fgetc(file1);
+                       uint8_t b3 = (uint8_t)fgetc(file2) ^ 0xFF;
+                       charROM[i + j + 0] = ((b3 & 0x80) >> 5) | ((b1 & 0x80) >> 6) | ((b1 & 0x08) >> 3);
+                       charROM[i + j + 1] = ((b3 & 0x40) >> 4) | ((b1 & 0x40) >> 5) | ((b1 & 0x04) >> 2);
+                       charROM[i + j + 2] = ((b3 & 0x20) >> 3) | ((b1 & 0x20) >> 4) | ((b1 & 0x02) >> 1);
+                       charROM[i + j + 3] = ((b3 & 0x10) >> 2) | ((b1 & 0x10) >> 3) | (b1 & 0x01);
+                       charROM[i + j + 4] = ((b3 & 0x08) >> 1) | ((b2 & 0x80) >> 6) | ((b2 & 0x08) >> 3);
+                       charROM[i + j + 5] = (b3 & 0x04)        | ((b2 & 0x40) >> 5) | ((b2 & 0x04) >> 2);
+                       charROM[i + j + 6] = ((b3 & 0x02) << 1) | ((b2 & 0x20) >> 4) | ((b2 & 0x02) >> 1);
+                       charROM[i + j + 7] = ((b3 & 0x01) << 2) | ((b2 & 0x10) >> 3) | (b2 & 0x01);
                }
        }
 
-       f1.close();
-       f2.close();
+       fclose(file1);
+       fclose(file2);
 
        return true;
 }
@@ -506,13 +445,11 @@ int main(int argc, char * argv[])
        InitLog("thunder.log");
 
        extern bool disasm;                             // From 'V6809.CPP'
-       extern bool charbase;                   // From 'SCREEN.CPP'
-       charbase = false;
 
        bool running;                                   // CPU running state flag...
        SDL_Event event;                                // SDL "event"
-       extern uint8_t palette[768];    // Screen physical palette
        uint32_t ticks, oldTicks;
+       uint8_t frameTickCount = 0;
 
        printf("THUNDER v"THUNDER_VERSION" by James Hammons\n");
        printf("Serial #20149417 / Prerelease\n");
@@ -521,15 +458,8 @@ int main(int argc, char * argv[])
 
 //     SDL_WM_SetCaption("Thunder v"THUNDER_VERSION" ", "Thunder");
 
-       // Needed only for debugger
-       gram = gram1;  grom = grom1;
-
-       memset(gram, 0, 0x10000);
-       memset(grom, 0, 0x10000);
-       memset(gram2, 0, 0x10000);
-       memset(grom2, 0, 0x10000);
+       printf("Loading ROMs...\n");
 
-       cout << "Loading ROMs..." << endl;
        if (!ReadColorPROMs())
                return -1;
 
@@ -589,10 +519,7 @@ int main(int argc, char * argv[])
 
        // Load 5, 6, 7, 8th ROMs
        if (!UnpackFonts())
-       {
-               cout << "Could not open font files!" << endl;
                return -1;
-       }
 
        // Load MCU program + data
        if (!LoadImg(MCUROM, mcuMem, 0xF000, 0x1000))
@@ -602,15 +529,14 @@ int main(int argc, char * argv[])
                return -1;
 
        // Set up V6809, V63701 execution contexts
-
        memset(&cpu1, 0, sizeof(V6809REGS));
-       cpu1.RdMem = RdMem;
-       cpu1.WrMem = WrMem;
+       cpu1.RdMem = MainReadMemory;
+       cpu1.WrMem = MainWriteMemory;
        cpu1.cpuFlags |= V6809_ASSERT_LINE_RESET;
 
        memset(&cpu2, 0, sizeof(V6809REGS));
-       cpu2.RdMem = RdMemB;
-       cpu2.WrMem = WrMemB;
+       cpu2.RdMem = SubReadMemory;
+       cpu2.WrMem = SubWriteMemory;
        cpu2.cpuFlags |= V6809_ASSERT_LINE_RESET;
 
        memset(&mcu, 0, sizeof(V63701REGS));
@@ -618,14 +544,33 @@ int main(int argc, char * argv[])
        mcu.WrMem = MCUWriteMemory;
        mcu.cpuFlags |= V63701_ASSERT_LINE_RESET;
 
-       running = true;                                                         // Set running status...
+       running = true;
 
        // Set all inputs to inactive...
-       input1.byte = input2.byte = input3.byte = input4.byte = input5.byte = 0xFF;
-       banksw1 = 0;                   // Will this work?
+       input1.byte = input2.byte = input3.byte = 0xFF;
+       banksw1 = 0;
        banksw2 = 0;
        InitGUI();                 // Reset # of coins
 
+       // Set up DIP switches...
+       input4.bit.b0 = 1;              // DSW B-0: Contiues (1 = 6, 0 = 3)
+       input4.bit.b1 = 1;              // DSW B-2: ???
+       input4.bit.b2 = 1;              // DSW B-4: Difficulty (1 = normal, 0 = easy)
+       input4.bit.b3 = 1;              // DSW B-6: Bonus lives (70K/200K = 1, 100K/300K = 0)
+       input4.bit.b4 = 1;              // DSW A-0: Coin #2 credit
+       input4.bit.b5 = 1;              // DSW A-2: Freeze mode (0 = freeze)
+       input4.bit.b6 = 1;              // DSW A-4: Attract mode sound (1 = on)
+       input4.bit.b7 = 1;              // DSW A-6: Coin #1 credit
+
+       input5.bit.b0 = 1;              // DSW B-1: Cabinet type (1 = A, 0 = B)
+       input5.bit.b1 = 0;              // DSW B-3: Level select (0 = on)
+       input5.bit.b2 = 0;              // DSW B-5: Time (1 = 120, 0 = 150)
+       input5.bit.b3 = 0;              // DSW B-7: Lives (1 = 3, 0 = 5)
+       input5.bit.b4 = 1;              // DSW A-1: Coin #2 credit
+       input5.bit.b5 = 1;              // DSW A-3: Invulnerability (0 = on)
+       input5.bit.b6 = 1;              // DSW A-5: Coin #1 credit
+       input5.bit.b7 = 1;              // DSW A-7: Service mode
+
 WriteLog("About to set up screen...\n");
        InitVideo();
 
@@ -634,13 +579,13 @@ WriteLog("About to set up screen...\n");
 WriteLog("About to set up audio...\n");
        InitSound();
 
-memset(scrBuffer, 0xFF, VIRTUAL_SCREEN_WIDTH*VIRTUAL_SCREEN_HEIGHT*sizeof(uint32_t));
-RenderScreenBuffer();
+//memset(scrBuffer, 0xFF, VIRTUAL_SCREEN_WIDTH*VIRTUAL_SCREEN_HEIGHT*sizeof(uint32_t));
+//RenderScreenBuffer();
 
 WriteLog("About to enter main loop...\n");
        while (running)
        {
-               HandleGUIDebounce();                                    // Debounce GUI keys
+//             HandleGUIDebounce();                                    // Debounce GUI keys
 
 // Dipswitches are presented to the main CPUs as 0 or 1 at locations
 // $423D - $425B by the MCU
@@ -672,18 +617,41 @@ WriteLog("About to enter main loop...\n");
                                        input1.bit.b5 = 0;
                                else if (event.key.keysym.sym == SDLK_1)
                                        input1.bit.b6 = 0;
-                               else if (event.key.keysym.sym == SDLK_RIGHT)
+                               else if (event.key.keysym.sym == SDLK_2)
+                                       input2.bit.b6 = 0;
+                               else if (event.key.keysym.sym == SDLK_c)        // Left
                                        input3.bit.b5 = 0;
-                               else if (event.key.keysym.sym == SDLK_LEFT)
+                               else if (event.key.keysym.sym == SDLK_z)        // Right
                                        input3.bit.b4 = 0;
-                               else if (event.key.keysym.sym == SDLK_UP)
+                               else if (event.key.keysym.sym == SDLK_s)        // Up
                                        input2.bit.b2 = 0;
-                               else if (event.key.keysym.sym == SDLK_DOWN)
+                               else if (event.key.keysym.sym == SDLK_x)        // Down
                                        input1.bit.b2 = 0;
-                               else if (event.key.keysym.sym == SDLK_q)        // (Q)  Jump
+                               else if (event.key.keysym.sym == SDLK_k)        // Jump
                                        input1.bit.b1 = 0;
-                               else if (event.key.keysym.sym == SDLK_e)        // (E) Fire
+                               else if (event.key.keysym.sym == SDLK_l)        // Fire
                                        input3.bit.b3 = 0;
+
+                               else if (event.key.keysym.sym == SDLK_F1)       // Service mode
+                                       input5.bit.b7 = !input5.bit.b7;
+
+                               else if (event.key.keysym.sym == SDLK_q)
+                                       input4.bit.b7 = !input4.bit.b7;
+                               else if (event.key.keysym.sym == SDLK_w)
+                                       input5.bit.b6 = !input5.bit.b6;
+                               else if (event.key.keysym.sym == SDLK_e)
+                                       input5.bit.b5 = !input5.bit.b5;
+                               else if (event.key.keysym.sym == SDLK_r)
+                                       input5.bit.b4 = !input5.bit.b4;
+                               else if (event.key.keysym.sym == SDLK_t)
+                                       input5.bit.b3 = !input5.bit.b3;
+                               else if (event.key.keysym.sym == SDLK_y)
+                                       input5.bit.b2 = !input5.bit.b2;
+                               else if (event.key.keysym.sym == SDLK_u)
+                                       input5.bit.b1 = !input5.bit.b1;
+                               else if (event.key.keysym.sym == SDLK_i)
+                                       input5.bit.b0 = !input5.bit.b0;
+
 #else
                                else if (event.key.keysym.sym == SDLK_1)
                                        input1.bit.b0 = 0;
@@ -738,17 +706,19 @@ WriteLog("About to enter main loop...\n");
                                        input1.bit.b5 = 1;
                                else if (event.key.keysym.sym == SDLK_1)
                                        input1.bit.b6 = 1;
-                               else if (event.key.keysym.sym == SDLK_RIGHT)
+                               else if (event.key.keysym.sym == SDLK_2)
+                                       input2.bit.b6 = 1;
+                               else if (event.key.keysym.sym == SDLK_c)
                                        input3.bit.b5 = 1;
-                               else if (event.key.keysym.sym == SDLK_LEFT)
+                               else if (event.key.keysym.sym == SDLK_z)
                                        input3.bit.b4 = 1;
-                               else if (event.key.keysym.sym == SDLK_UP)
+                               else if (event.key.keysym.sym == SDLK_s)
                                        input2.bit.b2 = 1;
-                               else if (event.key.keysym.sym == SDLK_DOWN)
+                               else if (event.key.keysym.sym == SDLK_x)
                                        input1.bit.b2 = 1;
-                               else if (event.key.keysym.sym == SDLK_q)        // (Q)  Jump
+                               else if (event.key.keysym.sym == SDLK_k)        // (Q)  Jump
                                        input1.bit.b1 = 1;
-                               else if (event.key.keysym.sym == SDLK_e)        // (E) Fire
+                               else if (event.key.keysym.sym == SDLK_l)        // (E) Fire
                                        input3.bit.b3 = 1;
 #else
                                if (event.key.keysym.sym == SDLK_1)
@@ -1002,9 +972,16 @@ WriteLog("About to enter main loop...\n");
                        Execute63701(&mcu, 40);
                }
 
+               BlitChar(charROM, gram1);
+
+               frameTickCount++;
+
+               if (frameTickCount == 3)
+                       frameTickCount = 0;
+
                // Speed throttling happens here...
-               // Actually, it's 16.66... Need to account for that somehow
-               while (SDL_GetTicks() - oldTicks < 16)
+               // Actually, it's 16.66... Need to account for that somehow [DONE]
+               while (SDL_GetTicks() - oldTicks < (16 + (frameTickCount == 2 ? 1 : 0)))
                        SDL_Delay(1);                           // Release our timeslice...
 
                oldTicks = SDL_GetTicks();
index 787dbb00c9aa6b2cc8b4a8939c3354b8b6c8e5fe..9ca749090bb2594715c2755cfdbaf1f4785aa091 100644 (file)
@@ -22,6 +22,7 @@
 
 // Exported global variables (actually, these are LOCAL global variables, EXPORTED...)
 
+//SDL_Surface * screen;
 static SDL_Window * sdlWindow = NULL;
 SDL_Renderer * sdlRenderer = NULL;
 static SDL_Texture * sdlTexture = NULL;
@@ -32,6 +33,7 @@ struct
        bool fullscreen;
 } settings;
 
+
 //
 // Prime SDL and create surfaces
 //
index cdae6647245c9d9a7ce051273459a73eead67bdd..8e59dfbee804b97988be5fc6c190c83aa468339c 100644 (file)
@@ -20,6 +20,8 @@ void ToggleFullScreen(void);
 
 extern SDL_Renderer * sdlRenderer;
 extern uint32_t scrBuffer[];
+//SDL_Surface * screen;
+
 //extern uint32_t mainScrBuffer[];
 
 #endif // __VIDEO_H__