From b5e17ec13a758bf4aaa660dae72b02614f2528b1 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Thu, 22 Dec 2016 19:51:25 -0800 Subject: Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful. --- render_sdl.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'render_sdl.c') diff --git a/render_sdl.c b/render_sdl.c index 492c433..bffc12d 100755 --- a/render_sdl.c +++ b/render_sdl.c @@ -44,6 +44,7 @@ static SDL_cond * audio_ready; static SDL_cond * psg_cond; static SDL_cond * ym_cond; static uint8_t quitting = 0; +static uint8_t ym_enabled = 1; static void audio_callback(void * userdata, uint8_t *byte_stream, int len) { @@ -61,26 +62,45 @@ static void audio_callback(void * userdata, uint8_t *byte_stream, int len) current_psg = NULL; SDL_CondSignal(psg_cond); } - if (!ym_buf) { + if (ym_enabled && !ym_buf) { ym_buf = current_ym; current_ym = NULL; SDL_CondSignal(ym_cond); } - if (!quitting && (!psg_buf || !ym_buf)) { + if (!quitting && (!psg_buf || (ym_enabled && !ym_buf))) { SDL_CondWait(audio_ready, audio_mutex); } - } while(!quitting && (!psg_buf || !ym_buf)); + } while(!quitting && (!psg_buf || (ym_enabled && !ym_buf))); local_quit = quitting; SDL_UnlockMutex(audio_mutex); if (!local_quit) { - for (int i = 0; i < samples; i++) { - *(stream++) = psg_buf[i] + *(ym_buf++); - *(stream++) = psg_buf[i] + *(ym_buf++); + if (ym_enabled) { + for (int i = 0; i < samples; i++) + { + *(stream++) = psg_buf[i] + *(ym_buf++); + *(stream++) = psg_buf[i] + *(ym_buf++); + } + } else { + for (int i = 0; i < samples; i++) + { + *(stream++) = psg_buf[i]; + *(stream++) = psg_buf[i]; + } } } } +void render_disable_ym() +{ + ym_enabled = 0; +} + +void render_enable_ym() +{ + ym_enabled = 1; +} + static void render_close_audio() { SDL_LockMutex(audio_mutex); -- cgit v1.2.3