comparison render_sdl.c @ 338:5c34a9c39394

Re-enable frame limit, but add a command line flag to disable it
author Mike Pavone <pavone@retrodev.com>
date Wed, 15 May 2013 22:37:25 -0700
parents 8e2fa485c0f2
children 80d934369fd5
comparison
equal deleted inserted replaced
337:f8c6f8684cd6 338:5c34a9c39394
230 230
231 #define FRAME_DELAY 16 231 #define FRAME_DELAY 16
232 #define MIN_DELAY 5 232 #define MIN_DELAY 5
233 uint32_t frame_counter = 0; 233 uint32_t frame_counter = 0;
234 uint32_t start = 0; 234 uint32_t start = 0;
235 int wait_render_frame(vdp_context * context) 235 int wait_render_frame(vdp_context * context, int frame_limit)
236 { 236 {
237 FILE * outfile; 237 FILE * outfile;
238 SDL_Event event; 238 SDL_Event event;
239 int ret = 0; 239 int ret = 0;
240 while(SDL_PollEvent(&event)) { 240 while(SDL_PollEvent(&event)) {
356 case SDL_QUIT: 356 case SDL_QUIT:
357 puts(""); 357 puts("");
358 exit(0); 358 exit(0);
359 } 359 }
360 } 360 }
361 //TODO: Adjust frame delay so we actually get 60 FPS rather than 62.5 FPS 361 if (frame_limit) {
362 /*uint32_t current = SDL_GetTicks(); 362 //TODO: Adjust frame delay so we actually get 60 FPS rather than 62.5 FPS
363 uint32_t desired = last_frame + FRAME_DELAY; 363 uint32_t current = SDL_GetTicks();
364 if (current < desired) { 364 uint32_t desired = last_frame + FRAME_DELAY;
365 uint32_t delay = last_frame + FRAME_DELAY - current; 365 if (current < desired) {
366 //TODO: Calculate MIN_DELAY at runtime 366 uint32_t delay = last_frame + FRAME_DELAY - current;
367 if (delay > MIN_DELAY) { 367 //TODO: Calculate MIN_DELAY at runtime
368 SDL_Delay((delay/MIN_DELAY)*MIN_DELAY); 368 if (delay > MIN_DELAY) {
369 } 369 SDL_Delay((delay/MIN_DELAY)*MIN_DELAY);
370 while ((desired) >= SDL_GetTicks()) { 370 }
371 } 371 while ((desired) >= SDL_GetTicks()) {
372 }*/ 372 }
373 }
374 }
373 render_context(context); 375 render_context(context);
374 376
375 377
376 //TODO: Figure out why this causes segfaults 378 //TODO: Figure out why this causes segfaults
377 /*frame_counter++; 379 /*frame_counter++;