]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/jaguar.cpp
Changed DSP default to on. It's time. :-)
[virtualjaguar] / src / jaguar.cpp
index 72802f518ce117b6895c2e9db4e2c0ff364083d3..f9a4185b6999f4eb2a8873719137dd7222e4e35b 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "jaguar.h"
 
+#include <time.h>
 #include <SDL.h>
 #include "SDL_opengl.h"
 #include "blitter.h"
@@ -78,6 +79,8 @@ uint32_t returnAddr[4000], raPtr = 0xFFFFFFFF;
 #endif
 
 uint32_t pcQueue[0x400];
+uint32_t a2Queue[0x400];
+uint32_t d0Queue[0x400];
 uint32_t pcQPtr = 0;
 bool startM68KTracing = false;
 
@@ -136,7 +139,10 @@ if (inRoutine)
 
 // For tracebacks...
 // Ideally, we'd save all the registers as well...
-       pcQueue[pcQPtr++] = m68kPC;
+       pcQueue[pcQPtr] = m68kPC;
+       a2Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_A2);
+       d0Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_D0);
+       pcQPtr++;
        pcQPtr &= 0x3FF;
 
        if (m68kPC & 0x01)              // Oops! We're fetching an odd address!
@@ -146,6 +152,7 @@ if (inRoutine)
                static char buffer[2048];
                for(int i=0; i<0x400; i++)
                {
+                       WriteLog("[A2=%08X, D0=%08X]\n", a2Queue[(pcQPtr + i) & 0x3FF], d0Queue[(pcQPtr + i) & 0x3FF]);
                        m68k_disassemble(buffer, pcQueue[(pcQPtr + i) & 0x3FF], 0);//M68K_CPU_TYPE_68000);
                        WriteLog("\t%08X: %s\n", pcQueue[(pcQPtr + i) & 0x3FF], buffer);
                }
@@ -1758,24 +1765,30 @@ void JaguarSetScreenPitch(uint32_t pitch)
 //
 void JaguarInit(void)
 {
+       // For randomizing RAM
+       srand(time(NULL));
+
+       // Contents of local RAM are quasi-stable; we simulate this by randomizing RAM contents
+       for(uint32_t i=0; i<0x200000; i+=4)
+               *((uint32_t *)(&jaguarMainRAM[i])) = rand();
+
 #ifdef CPU_DEBUG_MEMORY
        memset(readMem, 0x00, 0x400000);
        memset(writeMemMin, 0xFF, 0x400000);
        memset(writeMemMax, 0x00, 0x400000);
 #endif
-       memset(jaguarMainRAM, 0x00, 0x200000);
+//     memset(jaguarMainRAM, 0x00, 0x200000);
 //     memset(jaguar_mainRom, 0xFF, 0x200000); // & set it to all Fs...
 //     memset(jaguar_mainRom, 0x00, 0x200000); // & set it to all 0s...
 //NOTE: This *doesn't* fix FlipOut...
 //Or does it? Hmm...
 //Seems to want $01010101... Dunno why. Investigate!
-       memset(jaguarMainROM, 0x01, 0x600000);  // & set it to all 01s...
+//     memset(jaguarMainROM, 0x01, 0x600000);  // & set it to all 01s...
 //     memset(jaguar_mainRom, 0xFF, 0x600000); // & set it to all Fs...
        lowerField = false;                                                     // Reset the lower field flag
 //temp, for crappy crap that sux
 memset(jaguarMainRAM + 0x804, 0xFF, 4);
 
-//     m68k_set_cpu_type(M68K_CPU_TYPE_68000);
        m68k_pulse_reset();                                                     // Need to do this so UAE disasm doesn't segfault on exit
        GPUInit();
        DSPInit();
@@ -1784,11 +1797,17 @@ memset(jaguarMainRAM + 0x804, 0xFF, 4);
        CDROMInit();
 }
 
+
 //New timer based code stuffola...
 void HalflineCallback(void);
 void RenderCallback(void);
 void JaguarReset(void)
 {
+       // Only problem with this approach: It wipes out RAM loaded files...!
+       // Contents of local RAM are quasi-stable; we simulate this by randomizing RAM contents
+       for(uint32_t i=8; i<0x200000; i+=4)
+               *((uint32_t *)(&jaguarMainRAM[i])) = rand();
+
        // New timer base code stuffola...
        InitializeEventList();
 //Need to change this so it uses the single RAM space and load the BIOS
@@ -1816,6 +1835,7 @@ void JaguarReset(void)
        SetCallbackTime(HalflineCallback, (vjs.hardwareTypeNTSC ? 31.777777777 : 32.0));
 }
 
+
 void JaguarDone(void)
 {
 #ifdef CPU_DEBUG_MEMORY
@@ -1913,12 +1933,6 @@ void JaguarDone(void)
        M68K_show_context();
 //#endif
 
-#if 0  // This is drawn already...
-       WriteLog("Jaguar: 68K AutoVector table:\n", JaguarReadWord(0x3004));
-       for(uint32_t i=0x64; i<=0x7C; i+=4)
-               WriteLog("  #%u: %08X\n", (i-0x64)/4, JaguarReadLong(i));
-#endif
-
        CDROMDone();
        GPUDone();
        DSPDone();
@@ -1977,7 +1991,7 @@ void DumpMainMemory(void)
        if (fp == NULL)
                return;
 
-       fwrite(jaguarMainRAM, 1, 0x400000, fp);
+       fwrite(jaguarMainRAM, 1, 0x200000, fp);
        fclose(fp);
 }