diff src/sdl/SDL.cpp @ 53:9d0ec2614443

enabled stepping from clojure
author Robert McIntyre <rlm@mit.edu>
date Wed, 07 Mar 2012 02:31:39 -0600
parents 139178c4d843
children 719d910c90f8
line wrap: on
line diff
     1.1 --- a/src/sdl/SDL.cpp	Wed Mar 07 02:12:59 2012 -0600
     1.2 +++ b/src/sdl/SDL.cpp	Wed Mar 07 02:31:39 2012 -0600
     1.3 @@ -2043,6 +2043,60 @@
     1.4    renderedFrames = 0;
     1.5    }
     1.6  
     1.7 +
     1.8 +void shutdown () {
     1.9 +fprintf(stderr,"Shutting down\n");
    1.10 +  remoteCleanUp();
    1.11 +  soundShutdown();
    1.12 +
    1.13 +  if(gbRom != NULL || rom != NULL) {
    1.14 +    sdlWriteBattery();
    1.15 +    theEmulator.emuCleanUp();
    1.16 +  }
    1.17 +
    1.18 +  if(delta) {
    1.19 +    free(delta);
    1.20 +    delta = NULL;
    1.21 +  }
    1.22 +  
    1.23 +  SDL_Quit();
    1.24 +}
    1.25 +
    1.26 +
    1.27 +void step () {
    1.28 +  if(!paused && active) {
    1.29 +    if(debugger && theEmulator.emuHasDebugger)
    1.30 +      dbgMain();
    1.31 +    else {
    1.32 +      //printf("RLM: emulator main\n");
    1.33 +      theEmulator.emuMain(theEmulator.emuCount);
    1.34 +      //printf("RLM: emulator main called\n");
    1.35 +      if(rewindSaveNeeded && rewindMemory && theEmulator.emuWriteMemState) {
    1.36 +	rewindCount++;
    1.37 +	if(rewindCount > 8)
    1.38 +	  rewindCount = 8;
    1.39 +	if(theEmulator.emuWriteMemState &&
    1.40 +	   theEmulator.emuWriteMemState(&rewindMemory[rewindPos*REWIND_SIZE], 
    1.41 +					REWIND_SIZE)) {
    1.42 +	  rewindPos = ++rewindPos & 7;
    1.43 +	  if(rewindCount == 8)
    1.44 +	    rewindTopPos = ++rewindTopPos & 7;
    1.45 +	}
    1.46 +      }
    1.47 +
    1.48 +      rewindSaveNeeded = false;
    1.49 +    }
    1.50 +  } else {
    1.51 +    SDL_Delay(500);
    1.52 +  }
    1.53 +  sdlPollEvents();
    1.54 +  if(mouseCounter) {
    1.55 +    mouseCounter--;
    1.56 +    if(mouseCounter == 0)
    1.57 +      SDL_ShowCursor(SDL_DISABLE);
    1.58 +  }
    1.59 +}
    1.60 +
    1.61  int main(int argc, char **argv)
    1.62  {
    1.63    fprintf(stderr, "VisualBoyAdvance version %s [SDL]\n", PACKAGE_VERSION);
    1.64 @@ -2651,57 +2705,7 @@
    1.65      fprintf (stderr, "I got a filename OMG!\nCalling VBAMovieOpen...\n");
    1.66      VBAMovieOpen(moviefile, true);
    1.67    }
    1.68 -
    1.69 -  while(emulating) {
    1.70 -    if(!paused && active) {
    1.71 -      if(debugger && theEmulator.emuHasDebugger)
    1.72 -        dbgMain();
    1.73 -      else {
    1.74 -	//printf("RLM: emulator main\n");
    1.75 -	theEmulator.emuMain(theEmulator.emuCount);
    1.76 -	//printf("RLM: emulator main called\n");
    1.77 -        if(rewindSaveNeeded && rewindMemory && theEmulator.emuWriteMemState) {
    1.78 -          rewindCount++;
    1.79 -          if(rewindCount > 8)
    1.80 -            rewindCount = 8;
    1.81 -          if(theEmulator.emuWriteMemState &&
    1.82 -             theEmulator.emuWriteMemState(&rewindMemory[rewindPos*REWIND_SIZE], 
    1.83 -                                       REWIND_SIZE)) {
    1.84 -            rewindPos = ++rewindPos & 7;
    1.85 -            if(rewindCount == 8)
    1.86 -              rewindTopPos = ++rewindTopPos & 7;
    1.87 -          }
    1.88 -        }
    1.89 -
    1.90 -        rewindSaveNeeded = false;
    1.91 -      }
    1.92 -    } else {
    1.93 -      SDL_Delay(500);
    1.94 -    }
    1.95 -    sdlPollEvents();
    1.96 -    if(mouseCounter) {
    1.97 -      mouseCounter--;
    1.98 -      if(mouseCounter == 0)
    1.99 -        SDL_ShowCursor(SDL_DISABLE);
   1.100 -    }
   1.101 -  }
   1.102 -  
   1.103 -  emulating = 0;
   1.104 -  fprintf(stderr,"Shutting down\n");
   1.105 -  remoteCleanUp();
   1.106 -  soundShutdown();
   1.107 -
   1.108 -  if(gbRom != NULL || rom != NULL) {
   1.109 -    sdlWriteBattery();
   1.110 -    theEmulator.emuCleanUp();
   1.111 -  }
   1.112 -
   1.113 -  if(delta) {
   1.114 -    free(delta);
   1.115 -    delta = NULL;
   1.116 -  }
   1.117 -  
   1.118 -  SDL_Quit();
   1.119 +  step();
   1.120    return 0;
   1.121  }
   1.122  
   1.123 @@ -2711,6 +2715,11 @@
   1.124  }
   1.125  
   1.126  
   1.127 +
   1.128 +
   1.129 +
   1.130 +
   1.131 +
   1.132  void systemMessage(int num, const char *msg, ...)
   1.133  {
   1.134    char buffer[2048];