]> Shamusworld >> Repos - thunder/blobdiff - src/thunder.cpp
Replaced old v6809 core with new updated one. :-)
[thunder] / src / thunder.cpp
index 3a9d8ae3ae84a67965ffd918b0552425e3c32164..ffbfed9574a7ec070ea679c79c0f2668ace9e130 100755 (executable)
@@ -99,18 +99,6 @@ uint8 * gram, * grom;                                                        // Allocate RAM & ROM pointers
 uint8 gram1[0x10000], gram2[0x10000], grom1[0x10000], grom2[0x10000];  // Actual memory
 uint8 grom3[0x8000], grom4[0x8000], data_rom[0x40000], spr_rom[0x80000], voice_rom[0x20000];
 uint8 chr_rom[0x60000];                                                        // Character ROM pointer
-/*
-  gram1 = new uint8[0x10000];
-  grom1 = new uint8[0x10000];
-  gram2 = new uint8[0x10000];
-  grom2 = new uint8[0x10000];
-  chr_rom = new uint8[0x60000];
-  grom3 = new uint8[0x8000];
-  grom4 = new uint8[0x8000];
-  data_rom = new uint8[0x40000];
-  spr_rom = new uint8[0x80000];
-  voice_rom = new uint8[0x20000];
-*/
 
 V6809REGS cpu1, cpu2;
 
@@ -451,25 +439,25 @@ void DisplayBytes(uint16 src, unsigned long dst)
   uint8 cnt;
   unsigned long i;
 
-  printf("%04X: ", src);
+  WriteLog("%04X: ", src);
   cnt = 0;                               // Init counter...
   if (src > dst)  dst += 0x10000;        // That should fix the FFFF bug...
   for(i=src; i<dst; i++)
   {
-    printf("%02X ", (uint8)(looking_at_rom ? RdMem(i) : RdMemB(i)));
+    WriteLog("%02X ", (uint8)(looking_at_rom ? RdMem(i) : RdMemB(i)));
     cnt++;                               // Bump counter...
   }
   for(i=cnt; i<5; i++)                   // Pad the leftover spaces...
   {
-    cout << "   ";
+    WriteLog("   ");
   }
 }
 
 // temp crap...
-uint8 Fetch(void) { return 0; }
-uint16 FetchW(void) { return 0; }
-uint8 FetchB(void) { return 0; }
-uint16 FetchWB(void) { return 0; }
+uint8 Fetch(void) { return RdMem(dpc); }
+uint16 FetchW(void) { return (uint16)((RdMem(dpc) << 8) | RdMem(dpc+1)); }
+uint8 FetchB(void) { return RdMemB(dpc); }
+uint16 FetchWB(void) { return (uint16)((RdMemB(dpc) << 8) | RdMemB(dpc+1)); }
 
 //
 // Decode a 6809 instruction at 'addr'
@@ -626,7 +614,7 @@ void Decode_6809()
       break; }
   }
   DisplayBytes(dpc, (looking_at_rom ? pcr : pcrB));  // Show bytes
-  cout << outbuf << endl;     // display opcode & addressing, etc
+  WriteLog(outbuf); WriteLog("\n");     // display opcode & addressing, etc
   dpc = (looking_at_rom ? pcr : pcrB);  // Advance debug PC
   pcr = pc_save;  pcrB = pcB_save;  // Restore PCs
 }
@@ -1229,26 +1217,30 @@ WriteLog("Executing secondary 'run' command...\n");
 //        iclock = 0;                // Reset instr clock #1...
                                InitGUI();                 // Reset # of coins
 
-/*        cpu1.pc = ((grom1[0xFFFE]<<8) | grom1[0xFFFF]); // Reset 6809 #1
-        if (lbuff[1] != 0)
-        {
-          lbuff[0] = 32;  cpu1.pc = htod(lbuff);
-        }
-        else  cpu1.cc = 0xFF;                         // Set CC register
+#if 0
+                               cpu1.pc = ((grom1[0xFFFE]<<8) | grom1[0xFFFF]); // Reset 6809 #1
+                               if (lbuff[1] != 0)
+                               {
+                               lbuff[0] = 32;  cpu1.pc = htod(lbuff);
+                               }
+                               else  cpu1.cc = 0xFF;                         // Set CC register
 
-        cpu2.pc = ((grom2[0xFFFE]<<8) | grom2[0xFFFF]); // Reset 6809 #2
-        cpu2.cc = 0xFF;                              // Set CC register
-        while(iclock < 8000)  // was 17000, 20000, 5000
-        {
-          Execute6809(&cpu1, 1);  Execute6809(&cpu2, 1);
-        }*/
+                               cpu2.pc = ((grom2[0xFFFE]<<8) | grom2[0xFFFF]); // Reset 6809 #2
+                               cpu2.cc = 0xFF;                              // Set CC register
+                               while(iclock < 8000)  // was 17000, 20000, 5000
+                               {
+                               Execute6809(&cpu1, 1);  Execute6809(&cpu2, 1);
+                               }
+#endif
+#if 0
 WriteLog("--> CPU clock #1: %u\n", cpu1.clock);
-                               // Will *this* help video sync?
+                               // Will *this* help video sync? NO
                                while (cpu1.clock < 8000)                               // was 17000, 20000, 5000
                                {
                                        Execute6809(&cpu1, 1);
                                        Execute6809(&cpu2, 1);
                                }
+#endif
                        }
 
 WriteLog("About to set up screen...\n");
@@ -1270,7 +1262,7 @@ WriteLog("About to set up screen...\n");
                        }
                        SDL_SetPalette(screen, SDL_LOGPAL | SDL_PHYSPAL, colors, 0, 256);
 
-#if 1
+#if 0
        // This confirms that we're getting video to the screen...
        SDL_LockSurface(screen);
 
@@ -1497,6 +1489,12 @@ WriteLog("About to enter main loop...\n");
                                        Execute6809(&cpu2, 10);
                                }
 //                     }
+//F12 is used above, but the values are ignored. So we'll do it here too.
+                               if (keys[SDLK_F12])
+                               {
+                                       cpu1.cpuFlags |= V6809_ASSERT_LINE_RESET;
+                                       cpu2.cpuFlags |= V6809_ASSERT_LINE_RESET;
+                               }
 
 //                             if (enable_cpu)
                                if (true)
@@ -1525,8 +1523,8 @@ WriteLog("About to enter main loop...\n");
                                                Execute6809(&cpu2, 100);
                                        }
 
-                                       cpu1.clock -= 25000;                            // Remove 25K ticks from clock (in case it overflowed)
-                                       cpu2.clock -= 25000;                            // Remove 25K ticks from clock (in case it overflowed)//*/
+//                                     cpu1.clock -= 25000;                            // Remove 25K ticks from clock (in case it overflowed)
+//                                     cpu2.clock -= 25000;                            // Remove 25K ticks from clock (in case it overflowed)//*/
 #endif
                                } // END: enable_cpu