X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fjaguar.cpp;h=b92b2215e4cdd650b9c48dfedf8a340041a492a7;hb=25646c0a48be1832e20fd4fcdd2d40ba2174bfa3;hp=72802f518ce117b6895c2e9db4e2c0ff364083d3;hpb=10d7ab1fb217c01030a0b637f9a571c1faf61ede;p=virtualjaguar diff --git a/src/jaguar.cpp b/src/jaguar.cpp index 72802f5..b92b221 100644 --- a/src/jaguar.cpp +++ b/src/jaguar.cpp @@ -16,6 +16,7 @@ #include "jaguar.h" +#include #include #include "SDL_opengl.h" #include "blitter.h" @@ -24,6 +25,7 @@ #include "dsp.h" #include "eeprom.h" #include "event.h" +#include "foooked.h" #include "gpu.h" #include "jerry.h" #include "joystick.h" @@ -78,6 +80,22 @@ uint32_t returnAddr[4000], raPtr = 0xFFFFFFFF; #endif uint32_t pcQueue[0x400]; +uint32_t a0Queue[0x400]; +uint32_t a1Queue[0x400]; +uint32_t a2Queue[0x400]; +uint32_t a3Queue[0x400]; +uint32_t a4Queue[0x400]; +uint32_t a5Queue[0x400]; +uint32_t a6Queue[0x400]; +uint32_t a7Queue[0x400]; +uint32_t d0Queue[0x400]; +uint32_t d1Queue[0x400]; +uint32_t d2Queue[0x400]; +uint32_t d3Queue[0x400]; +uint32_t d4Queue[0x400]; +uint32_t d5Queue[0x400]; +uint32_t d6Queue[0x400]; +uint32_t d7Queue[0x400]; uint32_t pcQPtr = 0; bool startM68KTracing = false; @@ -136,7 +154,24 @@ if (inRoutine) // For tracebacks... // Ideally, we'd save all the registers as well... - pcQueue[pcQPtr++] = m68kPC; + pcQueue[pcQPtr] = m68kPC; + a0Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_A0); + a1Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_A1); + a2Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_A2); + a3Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_A3); + a4Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_A4); + a5Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_A5); + a6Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_A6); + a7Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_A7); + d0Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_D0); + d1Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_D1); + d2Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_D2); + d3Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_D3); + d4Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_D4); + d5Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_D5); + d6Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_D6); + d7Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_D7); + pcQPtr++; pcQPtr &= 0x3FF; if (m68kPC & 0x01) // Oops! We're fetching an odd address! @@ -146,6 +181,8 @@ 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]); + WriteLog("[A0=%08X, A1=%08X, A2=%08X, A3=%08X, A4=%08X, A5=%08X, A6=%08X, A7=%08X, D0=%08X, D1=%08X, D2=%08X, D3=%08X, D4=%08X, D5=%08X, D6=%08X, D7=%08X]\n", a0Queue[(pcQPtr + i) & 0x3FF], a1Queue[(pcQPtr + i) & 0x3FF], a2Queue[(pcQPtr + i) & 0x3FF], a3Queue[(pcQPtr + i) & 0x3FF], a4Queue[(pcQPtr + i) & 0x3FF], a5Queue[(pcQPtr + i) & 0x3FF], a6Queue[(pcQPtr + i) & 0x3FF], a7Queue[(pcQPtr + i) & 0x3FF], d0Queue[(pcQPtr + i) & 0x3FF], d1Queue[(pcQPtr + i) & 0x3FF], d2Queue[(pcQPtr + i) & 0x3FF], d3Queue[(pcQPtr + i) & 0x3FF], d4Queue[(pcQPtr + i) & 0x3FF], d5Queue[(pcQPtr + i) & 0x3FF], d6Queue[(pcQPtr + i) & 0x3FF], d7Queue[(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 +1795,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 +1827,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 +1865,7 @@ void JaguarReset(void) SetCallbackTime(HalflineCallback, (vjs.hardwareTypeNTSC ? 31.777777777 : 32.0)); } + void JaguarDone(void) { #ifdef CPU_DEBUG_MEMORY @@ -1913,12 +1963,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 +2021,7 @@ void DumpMainMemory(void) if (fp == NULL) return; - fwrite(jaguarMainRAM, 1, 0x400000, fp); + fwrite(jaguarMainRAM, 1, 0x200000, fp); fclose(fp); }