From: <for...@pr...> - 2004-01-28 18:01:03
|
Update of /cvsroot/vba/VisualBoyAdvance/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17373 Modified Files: debugger.cpp GBA.cpp SDL.cpp System.h Log Message: Use structure for emulation functions Index: debugger.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/debugger.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** debugger.cpp 21 Jan 2004 03:40:10 -0000 1.5 --- debugger.cpp 28 Jan 2004 17:59:28 -0000 1.6 *************** *** 30,35 **** extern int emulating; ! extern void (*emuUpdateCPSR)(); ! extern void (*emuMain)(int); #define debuggerReadMemory(addr) \ --- 30,34 ---- extern int emulating; ! extern struct EmulatedSystem emulator; #define debuggerReadMemory(addr) \ *************** *** 732,736 **** debuggerEnableBreakpoints(false); } else ! emuMain(1); } debuggerDisableBreakpoints(); --- 731,735 ---- debuggerEnableBreakpoints(false); } else ! emulator.emuMain(1); } debuggerDisableBreakpoints(); *************** *** 1096,1100 **** printf("Continuing after breakpoint\n"); debuggerEnableBreakpoints(true); ! emuMain(1); debuggerAtBreakpoint = false; } --- 1095,1099 ---- printf("Continuing after breakpoint\n"); debuggerEnableBreakpoints(true); ! emulator.emuMain(1); debuggerAtBreakpoint = false; } *************** *** 1422,1426 **** int commandCount = 0; ! emuUpdateCPSR(); debuggerRegisters(0, NULL); --- 1421,1426 ---- int commandCount = 0; ! if(emulator.emuUpdateCPSR) ! emulator.emuUpdateCPSR(); debuggerRegisters(0, NULL); Index: GBA.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/GBA.cpp,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** GBA.cpp 28 Jan 2004 17:44:50 -0000 1.49 --- GBA.cpp 28 Jan 2004 17:59:29 -0000 1.50 *************** *** 3918,3921 **** --- 3918,3925 ---- // emuWriteBMP CPUWriteBMPFile, + // emuUpdateCPSR + CPUUpdateCPSR, + // emuHasDebugger + true, // emuCount #ifdef FINAL_VERSION Index: SDL.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/SDL.cpp,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** SDL.cpp 21 Nov 2003 21:53:41 -0000 1.49 --- SDL.cpp 28 Jan 2004 17:59:29 -0000 1.50 *************** *** 118,135 **** #endif ! bool (*emuWriteState)(const char *) = NULL; ! bool (*emuWriteMemState)(char *, int) = NULL; ! bool (*emuReadState)(const char *) = NULL; ! bool (*emuReadMemState)(char *, int) = NULL; ! bool (*emuWriteBattery)(const char *) = NULL; ! bool (*emuReadBattery)(const char *) = NULL; ! void (*emuReset)() = NULL; ! void (*emuCleanUp)() = NULL; ! bool (*emuWritePNG)(const char *) = NULL; ! bool (*emuWriteBMP)(const char *) = NULL; ! void (*emuMain)(int) = NULL; ! void (*emuUpdateCPSR)() = NULL; ! int emuCount = 0; ! bool emuHasDebugger = false; static u8 COPYRIGHT[] = { --- 118,137 ---- #endif ! struct EmulatedSystem emulator = { ! NULL, ! NULL, ! NULL, ! NULL, ! NULL, ! NULL, ! NULL, ! NULL, ! NULL, ! NULL, ! NULL, ! NULL, ! false, ! 0 ! }; static u8 COPYRIGHT[] = { *************** *** 1362,1367 **** else sprintf(stateName,"%s%d.sgm", filename, num+1); ! if(emuWriteState) ! emuWriteState(stateName); sprintf(stateName, "Wrote state %d", num+1); systemScreenMessage(stateName); --- 1364,1369 ---- else sprintf(stateName,"%s%d.sgm", filename, num+1); ! if(emulator.emuWriteState) ! emulator.emuWriteState(stateName); sprintf(stateName, "Wrote state %d", num+1); systemScreenMessage(stateName); *************** *** 1378,1383 **** sprintf(stateName,"%s%d.sgm", filename, num+1); ! if(emuReadState) ! emuReadState(stateName); sprintf(stateName, "Loaded state %d", num+1); --- 1380,1385 ---- sprintf(stateName,"%s%d.sgm", filename, num+1); ! if(emulator.emuReadState) ! emulator.emuReadState(stateName); sprintf(stateName, "Loaded state %d", num+1); *************** *** 1394,1398 **** sprintf(buffer, "%s.sav", filename); ! emuWriteBattery(buffer); systemScreenMessage("Wrote battery"); --- 1396,1400 ---- sprintf(buffer, "%s.sav", filename); ! emulator.emuWriteBattery(buffer); systemScreenMessage("Wrote battery"); *************** *** 1410,1414 **** bool res = false; ! res = emuReadBattery(buffer); if(res) --- 1412,1416 ---- bool res = false; ! res = emulator.emuReadBattery(buffer); if(res) *************** *** 1715,1719 **** (event.key.keysym.mod & KMOD_CTRL)) { if(emulating) { ! emuReset(); systemScreenMessage("Reset"); --- 1717,1721 ---- (event.key.keysym.mod & KMOD_CTRL)) { if(emulating) { ! emulator.emuReset(); systemScreenMessage("Reset"); *************** *** 1724,1730 **** if(!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) { ! if(emulating && emuReadMemState && rewindMemory && rewindCount) { rewindPos = --rewindPos & 7; ! emuReadMemState(&rewindMemory[REWIND_SIZE*rewindPos], REWIND_SIZE); rewindCount--; rewindCounter = 0; --- 1726,1734 ---- if(!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) { ! if(emulating && emulator.emuReadMemState && rewindMemory ! && rewindCount) { rewindPos = --rewindPos & 7; ! emulator.emuReadMemState(&rewindMemory[REWIND_SIZE*rewindPos], ! REWIND_SIZE); rewindCount--; rewindCounter = 0; *************** *** 2205,2222 **** if(!failed) { cartridgeType = 1; ! emuWriteState = gbWriteSaveState; ! emuWriteMemState = gbWriteMemSaveState; ! emuReadState = gbReadSaveState; ! emuReadMemState = gbReadMemSaveState; ! emuWriteBattery = gbWriteBatteryFile; ! emuReadBattery = gbReadBatteryFile; ! emuReset = gbReset; ! emuCleanUp = gbCleanUp; ! emuWritePNG = gbWritePNGFile; ! emuWriteBMP = gbWriteBMPFile; ! emuMain = gbEmulate; ! emuUpdateCPSR = NULL; ! emuHasDebugger = false; ! emuCount = 70000/4; if(sdlAutoIPS) { int size = gbRomSize; --- 2209,2213 ---- if(!failed) { cartridgeType = 1; ! emulator = GBSystem; if(sdlAutoIPS) { int size = gbRomSize; *************** *** 2240,2257 **** cartridgeType = 0; ! emuWriteState = CPUWriteState; ! emuWriteMemState = CPUWriteMemState; ! emuReadState = CPUReadState; ! emuReadMemState = CPUReadMemState; ! emuWriteBattery = CPUWriteBatteryFile; ! emuReadBattery = CPUReadBatteryFile; ! emuReset = CPUReset; ! emuCleanUp = CPUCleanUp; ! emuWritePNG = CPUWritePNGFile; ! emuWriteBMP = CPUWriteBMPFile; ! emuMain = CPULoop; ! emuUpdateCPSR = CPUUpdateCPSR; ! emuHasDebugger = true; ! emuCount = 50000; if(removeIntros && rom != NULL) { --- 2231,2235 ---- cartridgeType = 0; ! emulator = GBASystem; if(removeIntros && rom != NULL) { *************** *** 2269,2294 **** } } - #ifdef GP_EMULATION - } else if(GPIsGPImage(szFile) || cartridgeType == 2) { - failed = !GPLoadRom(szFile); - if(!failed) { - cartridgeType = 2; - emuWriteState = GPWriteState; - emuReadState = GPReadState; - emuWriteBattery = GPWriteBatteryFile; - emuReadBattery = GPReadBatteryFile; - emuReset = GPReset; - emuCleanUp = GPCleanUp; - emuWritePNG = GPWritePNGFile; - emuWriteBMP = GPWriteBMPFile; - emuMain = GPLoop; - emuUpdateCPSR = GPUpdateCPSR; - emuHasDebugger = true; - emuCount = 50000; - - GPInit(); - GPReset(); - } - #endif } --- 2247,2250 ---- *************** *** 2310,2325 **** ioMem = (u8 *)calloc(1, 0x400); ! emuWriteState = CPUWriteState; ! emuReadState = CPUReadState; ! emuWriteBattery = CPUWriteBatteryFile; ! emuReadBattery = CPUReadBatteryFile; ! emuReset = CPUReset; ! emuCleanUp = CPUCleanUp; ! emuWritePNG = CPUWritePNGFile; ! emuWriteBMP = CPUWriteBMPFile; ! emuMain = CPULoop; ! emuUpdateCPSR = CPUUpdateCPSR; ! emuHasDebugger = true; ! emuCount = 50000; CPUInit(biosFileName, useBios); --- 2266,2270 ---- ioMem = (u8 *)calloc(1, 0x400); ! emulator = GBASystem; CPUInit(biosFileName, useBios); *************** *** 2613,2627 **** while(emulating) { if(!paused && active) { ! if(debugger && emuHasDebugger) dbgMain(); else { ! emuMain(emuCount); ! if(rewindSaveNeeded && rewindMemory && emuWriteMemState) { rewindCount++; if(rewindCount > 8) rewindCount = 8; ! if(emuWriteMemState && ! emuWriteMemState(&rewindMemory[rewindPos*REWIND_SIZE], ! REWIND_SIZE)) { rewindPos = ++rewindPos & 7; if(rewindCount == 8) --- 2558,2572 ---- while(emulating) { if(!paused && active) { ! if(debugger && emulator.emuHasDebugger) dbgMain(); else { ! emulator.emuMain(emulator.emuCount); ! if(rewindSaveNeeded && rewindMemory && emulator.emuWriteMemState) { rewindCount++; if(rewindCount > 8) rewindCount = 8; ! if(emulator.emuWriteMemState && ! emulator.emuWriteMemState(&rewindMemory[rewindPos*REWIND_SIZE], ! REWIND_SIZE)) { rewindPos = ++rewindPos & 7; if(rewindCount == 8) *************** *** 2650,2654 **** if(gbRom != NULL || rom != NULL) { sdlWriteBattery(); ! emuCleanUp(); } --- 2595,2599 ---- if(gbRom != NULL || rom != NULL) { sdlWriteBattery(); ! emulator.emuCleanUp(); } *************** *** 2949,2953 **** sprintf(buffer, "%s%02d.bmp", filename, a); ! emuWriteBMP(buffer); } else { if(captureDir[0]) --- 2894,2898 ---- sprintf(buffer, "%s%02d.bmp", filename, a); ! emulator.emuWriteBMP(buffer); } else { if(captureDir[0]) *************** *** 2955,2959 **** else sprintf(buffer, "%s%02d.png", filename, a); ! emuWritePNG(buffer); } --- 2900,2904 ---- else sprintf(buffer, "%s%02d.png", filename, a); ! emulator.emuWritePNG(buffer); } Index: System.h =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/System.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** System.h 28 Jan 2004 17:44:50 -0000 1.10 --- System.h 28 Jan 2004 17:59:31 -0000 1.11 *************** *** 69,72 **** --- 69,76 ---- // write BMP file bool (*emuWriteBMP)(const char *); + // emulator update CPSR (ARM only) + void (*emuUpdateCPSR)(); + // emulator has debugger + bool emuHasDebugger; // clock ticks to emulate int emuCount; |