From 91b0e491c5d7867b0faf2b8f4a73a3673f9c6816 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Wed, 19 Jun 2019 22:44:54 +0300 Subject: [PATCH] Increase the minimum required cycles for a sync, fix SGB jingle audio --- Core/sgb.c | 2 +- Core/timing.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/sgb.c b/Core/sgb.c index 323e10f..89218ab 100644 --- a/Core/sgb.c +++ b/Core/sgb.c @@ -466,7 +466,7 @@ static void render_jingle(GB_gameboy_t *gb, size_t count); void GB_sgb_render(GB_gameboy_t *gb) { if (gb->apu_output.sample_rate) { - render_jingle(gb, gb->apu_output.sample_rate / (GB_get_clock_rate(gb) / LCDC_PERIOD)); + render_jingle(gb, gb->apu_output.sample_rate / (GB_get_clock_rate(gb) / (double)LCDC_PERIOD)); } if (gb->sgb->intro_animation < INTRO_ANIMATION_LENGTH) gb->sgb->intro_animation++; diff --git a/Core/timing.c b/Core/timing.c index 5bc369b..138819f 100644 --- a/Core/timing.c +++ b/Core/timing.c @@ -59,7 +59,7 @@ void GB_timing_sync(GB_gameboy_t *gb) return; } /* Prevent syncing if not enough time has passed.*/ - if (gb->cycles_since_last_sync < LCDC_PERIOD / 4) return; + if (gb->cycles_since_last_sync < LCDC_PERIOD / 3) return; uint64_t target_nanoseconds = gb->cycles_since_last_sync * 1000000000LL / 2 / GB_get_clock_rate(gb); /* / 2 because we use 8MHz units */ int64_t nanoseconds = get_nanoseconds();