summaryrefslogtreecommitdiff
path: root/render_sdl.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2016-12-22 19:51:25 -0800
committerMichael Pavone <pavone@retrodev.com>2016-12-22 19:51:25 -0800
commitb5e17ec13a758bf4aaa660dae72b02614f2528b1 (patch)
tree3e6f1052eb5ef26e1af6d90bc35e9b0ff140dee4 /render_sdl.c
parent0ce85adad77df67b6637d2160fdeccefbfd4790d (diff)
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Diffstat (limited to 'render_sdl.c')
-rwxr-xr-xrender_sdl.c32
1 files changed, 26 insertions, 6 deletions
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);