comparison src/sdl/SDL.cpp @ 92:1ff2c546f5ad

added tick(), which allows one to step through each opcode of gameboy
author Robert McIntyre <rlm@mit.edu>
date Sun, 11 Mar 2012 19:07:31 -0500
parents ff6f1acae59e
children 95b2758dd517
comparison
equal deleted inserted replaced
91:613353b7e012 92:1ff2c546f5ad
2060 } 2060 }
2061 2061
2062 SDL_Quit(); 2062 SDL_Quit();
2063 } 2063 }
2064 2064
2065 int tick () {
2066 return theEmulator.emuMain(theEmulator.emuCount);
2067 }
2065 2068
2066 void step () { 2069 void step () {
2067 if(!paused && active) { 2070 if(!paused && active) {
2068 if(debugger && theEmulator.emuHasDebugger) 2071 //printf("RLM: emulator main\n");
2069 dbgMain(); 2072 int frameComplete = 0;
2070 else { 2073 while (!(frameComplete)){
2071 //printf("RLM: emulator main\n"); 2074 frameComplete = theEmulator.emuMain(theEmulator.emuCount);
2072 theEmulator.emuMain(theEmulator.emuCount); 2075 }
2073 //printf("RLM: emulator main called\n"); 2076 //printf("RLM: emulator main called\n");
2074 if(rewindSaveNeeded && rewindMemory && theEmulator.emuWriteMemState) {
2075 rewindCount++;
2076 if(rewindCount > 8)
2077 rewindCount = 8;
2078 if(theEmulator.emuWriteMemState &&
2079 theEmulator.emuWriteMemState(&rewindMemory[rewindPos*REWIND_SIZE],
2080 REWIND_SIZE)) {
2081 rewindPos = ++rewindPos & 7;
2082 if(rewindCount == 8)
2083 rewindTopPos = ++rewindTopPos & 7;
2084 }
2085 }
2086
2087 rewindSaveNeeded = false;
2088 }
2089 } else { 2077 } else {
2090 SDL_Delay(500); 2078 SDL_Delay(500);
2091 } 2079 }
2092 sdlPollEvents(); 2080 sdlPollEvents();
2093 SDL_ShowCursor(SDL_DISABLE); 2081 SDL_ShowCursor(SDL_DISABLE);