comparison 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
comparison
equal deleted inserted replaced
52:ee70875e0d3e 53:9d0ec2614443
2041 2041
2042 emulating = 1; 2042 emulating = 1;
2043 renderedFrames = 0; 2043 renderedFrames = 0;
2044 } 2044 }
2045 2045
2046
2047 void shutdown () {
2048 fprintf(stderr,"Shutting down\n");
2049 remoteCleanUp();
2050 soundShutdown();
2051
2052 if(gbRom != NULL || rom != NULL) {
2053 sdlWriteBattery();
2054 theEmulator.emuCleanUp();
2055 }
2056
2057 if(delta) {
2058 free(delta);
2059 delta = NULL;
2060 }
2061
2062 SDL_Quit();
2063 }
2064
2065
2066 void step () {
2067 if(!paused && active) {
2068 if(debugger && theEmulator.emuHasDebugger)
2069 dbgMain();
2070 else {
2071 //printf("RLM: emulator main\n");
2072 theEmulator.emuMain(theEmulator.emuCount);
2073 //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 {
2090 SDL_Delay(500);
2091 }
2092 sdlPollEvents();
2093 if(mouseCounter) {
2094 mouseCounter--;
2095 if(mouseCounter == 0)
2096 SDL_ShowCursor(SDL_DISABLE);
2097 }
2098 }
2099
2046 int main(int argc, char **argv) 2100 int main(int argc, char **argv)
2047 { 2101 {
2048 fprintf(stderr, "VisualBoyAdvance version %s [SDL]\n", PACKAGE_VERSION); 2102 fprintf(stderr, "VisualBoyAdvance version %s [SDL]\n", PACKAGE_VERSION);
2049 2103
2050 arg0 = argv[0]; 2104 arg0 = argv[0];
2649 if (moviefile) 2703 if (moviefile)
2650 { 2704 {
2651 fprintf (stderr, "I got a filename OMG!\nCalling VBAMovieOpen...\n"); 2705 fprintf (stderr, "I got a filename OMG!\nCalling VBAMovieOpen...\n");
2652 VBAMovieOpen(moviefile, true); 2706 VBAMovieOpen(moviefile, true);
2653 } 2707 }
2654 2708 step();
2655 while(emulating) {
2656 if(!paused && active) {
2657 if(debugger && theEmulator.emuHasDebugger)
2658 dbgMain();
2659 else {
2660 //printf("RLM: emulator main\n");
2661 theEmulator.emuMain(theEmulator.emuCount);
2662 //printf("RLM: emulator main called\n");
2663 if(rewindSaveNeeded && rewindMemory && theEmulator.emuWriteMemState) {
2664 rewindCount++;
2665 if(rewindCount > 8)
2666 rewindCount = 8;
2667 if(theEmulator.emuWriteMemState &&
2668 theEmulator.emuWriteMemState(&rewindMemory[rewindPos*REWIND_SIZE],
2669 REWIND_SIZE)) {
2670 rewindPos = ++rewindPos & 7;
2671 if(rewindCount == 8)
2672 rewindTopPos = ++rewindTopPos & 7;
2673 }
2674 }
2675
2676 rewindSaveNeeded = false;
2677 }
2678 } else {
2679 SDL_Delay(500);
2680 }
2681 sdlPollEvents();
2682 if(mouseCounter) {
2683 mouseCounter--;
2684 if(mouseCounter == 0)
2685 SDL_ShowCursor(SDL_DISABLE);
2686 }
2687 }
2688
2689 emulating = 0;
2690 fprintf(stderr,"Shutting down\n");
2691 remoteCleanUp();
2692 soundShutdown();
2693
2694 if(gbRom != NULL || rom != NULL) {
2695 sdlWriteBattery();
2696 theEmulator.emuCleanUp();
2697 }
2698
2699 if(delta) {
2700 free(delta);
2701 delta = NULL;
2702 }
2703
2704 SDL_Quit();
2705 return 0; 2709 return 0;
2706 } 2710 }
2707 2711
2708 // RLM 2712 // RLM
2709 int runVBA(int argc, char **argv){ 2713 int runVBA(int argc, char **argv){
2710 return main(argc, argv); 2714 return main(argc, argv);
2711 } 2715 }
2716
2717
2718
2719
2720
2712 2721
2713 2722
2714 void systemMessage(int num, const char *msg, ...) 2723 void systemMessage(int num, const char *msg, ...)
2715 { 2724 {
2716 char buffer[2048]; 2725 char buffer[2048];