diff options
author | Mike Pavone <pavone@retrodev.com> | 2013-05-15 22:37:25 -0700 |
---|---|---|
committer | Mike Pavone <pavone@retrodev.com> | 2013-05-15 22:37:25 -0700 |
commit | f0460d04b948942c369592baf0160de5d9bf621e (patch) | |
tree | d65bff414fe2b95efe428fc7650d9e0bf2700a24 | |
parent | 3e9473a73d17bb3b71551c8eb053e8288eceb713 (diff) |
Re-enable frame limit, but add a command line flag to disable it
-rw-r--r-- | blastem.c | 10 | ||||
-rw-r--r-- | render.h | 2 | ||||
-rw-r--r-- | render_sdl.c | 26 |
3 files changed, 22 insertions, 16 deletions
@@ -27,6 +27,7 @@ io_port gamepad_2; int headless = 0; int z80_enabled = 1; +int frame_limit = 1; #ifndef MIN #define MIN(a,b) ((a) < (b) ? (a) : (b)) @@ -197,7 +198,7 @@ m68k_context * sync_components(m68k_context * context, uint32_t address) //printf("reached frame end | 68K Cycles: %d, MCLK Cycles: %d\n", context->current_cycle, mclks); vdp_run_context(v_context, MCLKS_PER_FRAME); if (!headless) { - break_on_sync |= wait_render_frame(v_context); + break_on_sync |= wait_render_frame(v_context, frame_limit); } frame++; mclks -= MCLKS_PER_FRAME; @@ -242,7 +243,7 @@ m68k_context * vdp_port_write(uint32_t vdp_port, m68k_context * context, uint16_ vdp_run_dma_done(v_context, MCLKS_PER_FRAME); if (v_context->cycles >= MCLKS_PER_FRAME) { if (!headless) { - wait_render_frame(v_context); + wait_render_frame(v_context, frame_limit); } vdp_adjust_cycles(v_context, MCLKS_PER_FRAME); io_adjust_cycles(&gamepad_1, v_context->cycles/MCLKS_PER_68K, MCLKS_PER_FRAME/MCLKS_PER_68K); @@ -259,7 +260,7 @@ m68k_context * vdp_port_write(uint32_t vdp_port, m68k_context * context, uint16_ vdp_run_dma_done(v_context, MCLKS_PER_FRAME); if (v_context->cycles >= MCLKS_PER_FRAME) { if (!headless) { - wait_render_frame(v_context); + wait_render_frame(v_context, frame_limit); } vdp_adjust_cycles(v_context, MCLKS_PER_FRAME); io_adjust_cycles(&gamepad_1, v_context->cycles/MCLKS_PER_68K, MCLKS_PER_FRAME/MCLKS_PER_68K); @@ -1042,6 +1043,9 @@ int main(int argc, char ** argv) case 'd': debug = 1; break; + case 'f': + frame_limit = 0; + break; case 'l': address_log = fopen("address.log", "w"); break; @@ -5,7 +5,7 @@ void render_init(int width, int height); void render_context(vdp_context * context); void render_wait_quit(vdp_context * context); -int wait_render_frame(vdp_context * context); +int wait_render_frame(vdp_context * context, int frame_limit); #endif //RENDER_SDL_H_ diff --git a/render_sdl.c b/render_sdl.c index a40887f..f71b929 100644 --- a/render_sdl.c +++ b/render_sdl.c @@ -232,7 +232,7 @@ void render_wait_quit(vdp_context * context) #define MIN_DELAY 5 uint32_t frame_counter = 0; uint32_t start = 0; -int wait_render_frame(vdp_context * context) +int wait_render_frame(vdp_context * context, int frame_limit) { FILE * outfile; SDL_Event event; @@ -358,18 +358,20 @@ int wait_render_frame(vdp_context * context) exit(0); } } - //TODO: Adjust frame delay so we actually get 60 FPS rather than 62.5 FPS - /*uint32_t current = SDL_GetTicks(); - uint32_t desired = last_frame + FRAME_DELAY; - if (current < desired) { - uint32_t delay = last_frame + FRAME_DELAY - current; - //TODO: Calculate MIN_DELAY at runtime - if (delay > MIN_DELAY) { - SDL_Delay((delay/MIN_DELAY)*MIN_DELAY); - } - while ((desired) >= SDL_GetTicks()) { + if (frame_limit) { + //TODO: Adjust frame delay so we actually get 60 FPS rather than 62.5 FPS + uint32_t current = SDL_GetTicks(); + uint32_t desired = last_frame + FRAME_DELAY; + if (current < desired) { + uint32_t delay = last_frame + FRAME_DELAY - current; + //TODO: Calculate MIN_DELAY at runtime + if (delay > MIN_DELAY) { + SDL_Delay((delay/MIN_DELAY)*MIN_DELAY); + } + while ((desired) >= SDL_GetTicks()) { + } } - }*/ + } render_context(context); |