]> Shamusworld >> Repos - thunder/blobdiff - src/thunder.cpp
Added missing files... D'oh!
[thunder] / src / thunder.cpp
index 17ea566f26774da6ad315789ed1df2f5584a855e..8ee60f525a32c1fe713f3f9ce2fe5d3ac2710caf 100755 (executable)
@@ -9,9 +9,10 @@
 // WHO  WHEN        WHAT
 // ---  ----------  ------------------------------------------------------------
 // JLH  07/23/2009  Added changelog ;-)
+// JLH  08/12/2009  Stabilized emulation so that it works
 //
 
-#define THUNDER_VERSION       "0.9.9"
+#define THUNDER_VERSION                "0.9.9"
 
 #include <iostream>
 #include <iomanip>
 //#include <conio.h>                   // For getch()
 #include <curses.h>                    // For getch()
 #include <time.h>
-#include "SDL.h"                                                                               // Get yer SDL out...!
+#include "SDL.h"                                                               // Get yer SDL out...!
 #include "types.h"
 #include "v6809.h"
 #include "screen.h"
 #include "gui.h"
 #include "log.h"
 
-using namespace std;                                                                   // Yes!
+using namespace std;                                                   // Yes!
 
 #if 0
 #define ROM1  "RT3-1B.ROM"
@@ -102,17 +103,17 @@ uint8 chr_rom[0x60000];                                                   // Character ROM pointer
 
 V6809REGS cpu1, cpu2;
 
-bool trace1 = false;                 // ditto...
-bool looking_at_rom = true;         // true = R1, false = R2
-uint32 banksw1, banksw2;             // Bank switch addresses
-uint16 game_over_switch;              // Game over delay
-uint16 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 refresh_ = 0;                // Crappy global screen stuff...
+bool trace1 = false;                                                   // ditto...
+bool looking_at_rom = true;                                            // true = R1, false = R2
+uint32 banksw1, banksw2;                                               // Bank switch addresses
+uint16 game_over_switch;                                               // Game over delay
+uint16 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 refresh_ = 0;                                                   // Crappy global screen stuff...
 bool refresh2 = true;
 
 uint32 psg_lens[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
@@ -124,7 +125,7 @@ uint32 fm_lens[14] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 uint8 * fm_adrs[14];
 
 fstream tr;    // Tracelog hook
-uint16    pcx;   // Where we at?
+uint16 pcx;   // Where we at?
 
 static uint8 * keys;                                                   // SDL raw keyboard matrix
 
@@ -324,7 +325,7 @@ void WrMem(uint16 addr, uint8 b)
     //}
     tr << endl;
   }//*/
-#if 1
+#if 0
        if (addr == 0x4182)
        {
                WriteLog("\nWriteMem: CPU #1 writing $%02X to $4182!\n\n", b);
@@ -358,16 +359,13 @@ void WrMem(uint16 addr, uint8 b)
                        BlitChar(screen, chr_rom, gram1);
                        refresh_ = (refresh2 ? 1 : 0);                          // 60/30 Hz...
                }
-//Seems they're more regular than this...
-//             irqGoA = true; // Will this work??? no...
-//             cpu1.cpuFlags |= V6809_ASSERT_LINE_IRQ;//wil wok???
+
                // IRQ Ack (may also be frame go...
-//             cpu1.cpuFlags &= ~V6809_ASSERT_LINE_IRQ;
+               ClearLineOfCurrentV6809(V6809_ASSERT_LINE_IRQ);
 #if 1
        if (disasm)
                WriteLog("WriteMem: CPU #1 Acknowledging IRQ...\n", b);
 #endif
-               ClearLineOfCurrentV6809(V6809_ASSERT_LINE_IRQ);
        }
 }
 
@@ -420,17 +418,13 @@ void WrMemB(uint16 addr, uint8 b)
     //}
     tr << endl;
   }//*/
-#if 1
+#if 0
        if (addr == 0x0182)
        {
                WriteLog("\nWriteMem: CPU #2 writing $%02X to $0182 ($4182)!\n\n", b);
        }
 #endif
 
-// Bah. Dunno if this is accurate or not!
-//     if (addr == 0x8800)
-//             irqGoB = true;                                                                  // Will it work??? no...
-//             cpu2.cpuFlags |= V6809_ASSERT_LINE_IRQ;//wil wok???
        if (addr == 0x6000)
                SpawnSound(GAMESOUND, gram1[0x6200], 0);                // Do voice chan 1
        if (addr == 0x6400)
@@ -457,12 +451,11 @@ void WrMemB(uint16 addr, uint8 b)
        if (addr == 0x8800)
        {
                // IRQ Ack (may also be frame go...)
-//             cpu2.cpuFlags &= ~V6809_ASSERT_LINE_IRQ;
+               ClearLineOfCurrentV6809(V6809_ASSERT_LINE_IRQ);
 #if 1
        if (disasm)
                WriteLog("WriteMem: CPU #2 Acknowledging IRQ...\n", b);
 #endif
-               ClearLineOfCurrentV6809(V6809_ASSERT_LINE_IRQ);
        }
 }
 
@@ -893,7 +886,6 @@ void LoadPSGs(void)
                if (fp)
                {
                        len = GetWAVLength(fp);                                         // Get WAV data length...
-
                        psg_adrs[i] = new uint8[len];                           // Attempt to allocate space...
 
                        if (psg_adrs[i] != NULL)
@@ -935,7 +927,6 @@ void LoadFMs(void)
                if (fp)
                {
                        len = GetWAVLength(fp);                                         // Get WAV length...
-
                        fm_adrs[i] = new uint8[len];                                    // Attempt to allocate space...
 
                        if (fm_adrs[i] != NULL)
@@ -1554,7 +1545,7 @@ WriteLog("About to enter main loop...\n");
 //          refresh_ = (refresh2 ? 1 : 0);    // 60/30 Hz...
 //        }
 
-#if 1
+#if 0
 //temp, for testing...
 BlitChar(screen, chr_rom, gram1);
 #endif
@@ -1687,6 +1678,10 @@ BlitChar(screen, chr_rom, gram1);
 }
 
 #if 0
+Hitachi uC runs at 6.144 MHz
+YM2151 runs at 3.579580 MHz
+
+
 Rolling Thunder Memory map
 --------------------------
 Most of the decoding is done by custom chips (CUS47 and CUS41), so the memory