comparison src/sdl/SDL.cpp @ 33:44974c3e093b

found source of problem for video recording
author Robert McIntyre <rlm@mit.edu>
date Mon, 05 Mar 2012 01:25:11 -0600
parents 48369c6aeaa0
children 3e36553d0cbf
comparison
equal deleted inserted replaced
32:0dc331ec7f27 33:44974c3e093b
1964 1964
1965 static char *szFile; 1965 static char *szFile;
1966 1966
1967 void file_run() 1967 void file_run()
1968 { 1968 {
1969 printf("RLM: file_run\n");
1969 utilGetBaseName(szFile, filename); 1970 utilGetBaseName(szFile, filename);
1970 char *p = strrchr(filename, '.'); 1971 char *p = strrchr(filename, '.');
1971 1972
1972 if(p) 1973 if(p)
1973 *p = 0; 1974 *p = 0;
1987 1988
1988 if(type == IMAGE_GB) { 1989 if(type == IMAGE_GB) {
1989 failed = !gbLoadRom(szFile); 1990 failed = !gbLoadRom(szFile);
1990 if(!failed) { 1991 if(!failed) {
1991 systemCartridgeType = 1; 1992 systemCartridgeType = 1;
1992 theEmulator = GBSystem; 1993 printf("RLM: choosing GBSystem\n");
1994 theEmulator = GBSystem;
1993 if(sdlAutoIPS) { 1995 if(sdlAutoIPS) {
1994 int size = gbRomSize; 1996 int size = gbRomSize;
1995 utilApplyIPS(ipsname, &gbRom, &size); 1997 utilApplyIPS(ipsname, &gbRom, &size);
1996 if(size != gbRomSize) { 1998 if(size != gbRomSize) {
1997 extern bool gbUpdateSizes(); 1999 extern bool gbUpdateSizes();
2005 failed = (size == 0); 2007 failed = (size == 0);
2006 if(!failed) { 2008 if(!failed) {
2007 // if(cpuEnhancedDetection && cpuSaveType == 0) { 2009 // if(cpuEnhancedDetection && cpuSaveType == 0) {
2008 // utilGBAFindSave(rom, size); 2010 // utilGBAFindSave(rom, size);
2009 // } 2011 // }
2010 2012
2011 sdlApplyPerImagePreferences(); 2013 sdlApplyPerImagePreferences();
2012 2014
2013 systemCartridgeType = 0; 2015 systemCartridgeType = 0;
2014 theEmulator = GBASystem; 2016 theEmulator = GBASystem;
2015 2017
2181 } 2183 }
2182 break; 2184 break;
2183 2185
2184 case 'r': 2186 case 'r':
2185 if(optarg == NULL) { 2187 if(optarg == NULL) {
2186 fprintf(stderr, "ERROR: --recordMovie ('r') needs movie filename as option\n"); 2188 fprintf(stderr, "ERROR: --recordmovie ('r') needs movie filename as option\n");
2187 exit(-1); 2189 exit(-1);
2188 } 2190 }
2189 strcpy(movieFileName, optarg); 2191 strcpy(movieFileName, optarg);
2190 useMovie = 1; 2192 useMovie = 1;
2191 break; 2193 break;
2192 case 'p': // play without read-only (editable) 2194 case 'p': // play without read-only (editable)
2193 fprintf (stderr, "-p got called!\n"); 2195 fprintf (stderr, "-p got called!\n");
2194 if(optarg == NULL) { 2196 if(optarg == NULL) {
2195 fprintf(stderr, "ERROR: --playMovie ('p') needs movie filename as option\n"); 2197 fprintf(stderr, "ERROR: --playmovie ('p') needs movie filename as option\n");
2196 exit(-1); 2198 exit(-1);
2197 } 2199 }
2198 strcpy(movieFileName, optarg); 2200 strcpy(movieFileName, optarg);
2199 useMovie = 2; 2201 useMovie = 2;
2200 break; 2202 break;
2201 case 'w': // play with read-only 2203 case 'w': // play with read-only
2202 fprintf (stderr, "-w got called!\n"); 2204 fprintf (stderr, "-w got called!\n");
2203 if(optarg == NULL) { 2205 if(optarg == NULL) {
2204 fprintf(stderr, "ERROR: --watchMovie ('w') needs movie filename as option\n"); 2206 fprintf(stderr, "ERROR: --watchmovie ('w') needs movie filename as option\n");
2205 exit(-1); 2207 exit(-1);
2206 } 2208 }
2207 strcpy(movieFileName, optarg); 2209 strcpy(movieFileName, optarg);
2208 useMovie = 3; 2210 useMovie = 3;
2209 break; 2211 break;
2269 sdlPrintUsage = 1; 2271 sdlPrintUsage = 1;
2270 break; 2272 break;
2271 } 2273 }
2272 } 2274 }
2273 2275
2276 printf("RLM: derpy loves you!\n");
2277 printf("RLM: useMovie: %d (1 is record)\n", useMovie);
2274 if(sdlPrintUsage) { 2278 if(sdlPrintUsage) {
2275 usage(argv[0]); 2279 usage(argv[0]);
2276 exit(-1); 2280 exit(-1);
2277 } 2281 }
2278 2282
2315 2319
2316 if(optind < argc) 2320 if(optind < argc)
2317 { 2321 {
2318 szFile = argv[optind]; 2322 szFile = argv[optind];
2319 file_run(); 2323 file_run();
2324 printf("RLM: file_run() done\n");
2320 } 2325 }
2321 else 2326 else
2322 { 2327 {
2323 systemCartridgeType = 0; 2328 systemCartridgeType = 0;
2324 strcpy(filename, "gnu_stub"); 2329 strcpy(filename, "gnu_stub");
2334 2339
2335 theEmulator = GBASystem; 2340 theEmulator = GBASystem;
2336 2341
2337 //CPUInit(biosFileName, useBios); 2342 //CPUInit(biosFileName, useBios);
2338 CPUInit(); 2343 CPUInit();
2339 CPUReset(); 2344 CPUReset();
2340 } 2345 }
2341 2346
2342 if(debuggerStub) 2347 if(debuggerStub)
2343 remoteInit(); 2348 remoteInit();
2344 2349
2613 2618
2614 if(!soundOffFlag) 2619 if(!soundOffFlag)
2615 soundInit(); 2620 soundInit();
2616 2621
2617 autoFrameSkipLastTime = throttleLastTime = systemGetClock(); 2622 autoFrameSkipLastTime = throttleLastTime = systemGetClock();
2623 printf("RLM: and now for the movie part!\n");
2618 2624
2619 switch(useMovie) 2625 switch(useMovie)
2620 { 2626 {
2621 case 1: // --recordMovie 2627 case 1: // --recordMovie
2622 VBAMovieCreate(movieFileName, 2628 VBAMovieCreate(movieFileName,
2633 break; 2639 break;
2634 default: 2640 default:
2635 sdlReadBattery(); 2641 sdlReadBattery();
2636 break; 2642 break;
2637 } 2643 }
2644 printf("RLM: still alive after movie switch\n");
2638 SDL_WM_SetCaption("VisualBoyAdvance", NULL); 2645 SDL_WM_SetCaption("VisualBoyAdvance", NULL);
2639 2646
2640 char *moviefile = getenv("AUTODEMO"); 2647 char *moviefile = getenv("AUTODEMO");
2641 // fprintf (stderr, "Checking for AUTODEMO...\n"); 2648 fprintf (stderr, "Checking for AUTODEMO...\n");
2642 if (moviefile) 2649 if (moviefile)
2643 { 2650 {
2644 // fprintf (stderr, "I got a filename OMG!\nCalling VBAMovieOpen...\n"); 2651 fprintf (stderr, "I got a filename OMG!\nCalling VBAMovieOpen...\n");
2645 VBAMovieOpen(moviefile, true); 2652 VBAMovieOpen(moviefile, true);
2646 } 2653 }
2647 2654
2648 while(emulating) { 2655 while(emulating) {
2649 if(!paused && active) { 2656 if(!paused && active) {
2650 if(debugger && theEmulator.emuHasDebugger) 2657 if(debugger && theEmulator.emuHasDebugger)
2651 dbgMain(); 2658 dbgMain();
2652 else { 2659 else {
2653 theEmulator.emuMain(theEmulator.emuCount); 2660 printf("RLM: emulator main\n");
2661 theEmulator.emuMain(theEmulator.emuCount);
2662 printf("RLM: emulator main called\n");
2654 if(rewindSaveNeeded && rewindMemory && theEmulator.emuWriteMemState) { 2663 if(rewindSaveNeeded && rewindMemory && theEmulator.emuWriteMemState) {
2655 rewindCount++; 2664 rewindCount++;
2656 if(rewindCount > 8) 2665 if(rewindCount > 8)
2657 rewindCount = 8; 2666 rewindCount = 8;
2658 if(theEmulator.emuWriteMemState && 2667 if(theEmulator.emuWriteMemState &&
3603 true //laggedLast 3612 true //laggedLast
3604 }; 3613 };
3605 3614
3606 void VBAOnEnteringFrameBoundary() 3615 void VBAOnEnteringFrameBoundary()
3607 { 3616 {
3608 CallRegisteredLuaFunctions(LUACALL_AFTEREMULATION); 3617 printf("RLM: Entering Frame Boundary\n");
3609 3618 CallRegisteredLuaFunctions(LUACALL_AFTEREMULATION);
3610 if (VBALuaRunning()) 3619
3611 { 3620 if (VBALuaRunning())
3612 VBALuaFrameBoundary(); 3621 {
3613 } 3622 VBALuaFrameBoundary();
3614 3623 }
3615 VBAMovieUpdateState(); 3624
3625 printf("RLM: Movie state update pending\n");
3626 VBAMovieUpdateState();
3627 printf("RLM: Movie state updated\n");
3616 } 3628 }
3617 3629
3618 void VBAOnExitingFrameBoundary() 3630 void VBAOnExitingFrameBoundary()
3619 { 3631 {
3620 ; 3632 ;