# HG changeset patch # User Mike Pavone # Date 1371522887 25200 # Node ID c1bddeadc5666a23bb32d7db9ab37c6f7e97aa9b # Parent a13a83934ba346027c5915af7bb9036ccd155b67 Process events in vgm player so that quitting works diff -r a13a83934ba3 -r c1bddeadc566 render.h --- a/render.h Mon Jun 17 00:54:14 2013 -0700 +++ b/render.h Mon Jun 17 19:34:47 2013 -0700 @@ -15,6 +15,7 @@ uint32_t render_sample_rate(); void render_debug_mode(uint8_t mode); void render_debug_pal(uint8_t pal); +void process_events(); //TODO: Throw an ifdef in here once there's more than one renderer #include diff -r a13a83934ba3 -r c1bddeadc566 render_sdl.c --- a/render_sdl.c Mon Jun 17 00:54:14 2013 -0700 +++ b/render_sdl.c Mon Jun 17 19:34:47 2013 -0700 @@ -366,6 +366,14 @@ return ret; } +void process_events() +{ + SDL_Event event; + while(SDL_PollEvent(&event)) { + handle_event(&event); + } +} + void render_wait_psg(psg_context * context) { SDL_LockMutex(audio_mutex); diff -r a13a83934ba3 -r c1bddeadc566 vgmplay.c --- a/vgmplay.c Mon Jun 17 00:54:14 2013 -0700 +++ b/vgmplay.c Mon Jun 17 19:34:47 2013 -0700 @@ -72,16 +72,19 @@ { } +#define CYCLE_LIMIT MCLKS_NTSC/60 + void wait(ym2612_context * y_context, psg_context * p_context, uint32_t * current_cycle, uint32_t cycles) { *current_cycle += cycles; psg_run(p_context, *current_cycle); ym_run(y_context, *current_cycle); - if (*current_cycle > 0x1FFFFFFF) { - *current_cycle -= 0x1FFFFFFF; - p_context->cycles -= 0x1FFFFFFF; - y_context->current_cycle -= 0x1FFFFFFF; + if (*current_cycle > CYCLE_LIMIT) { + *current_cycle -= CYCLE_LIMIT; + p_context->cycles -= CYCLE_LIMIT; + y_context->current_cycle -= CYCLE_LIMIT; + process_events(); } }