diff genesis.c @ 2486:e8eba0cd5444

Implement turbo/slow for Pico and Copera
author Michael Pavone <pavone@retrodev.com>
date Sun, 14 Apr 2024 12:30:32 -0700
parents 59a299610662
children bfd09d3367ba
line wrap: on
line diff
--- a/genesis.c	Sun Apr 14 11:46:34 2024 -0700
+++ b/genesis.c	Sun Apr 14 12:30:32 2024 -0700
@@ -1876,14 +1876,24 @@
 	genesis_context *context = (genesis_context *)system;
 	uint32_t old_clock = context->master_clock;
 	context->master_clock = ((uint64_t)context->normal_clock * (uint64_t)percent) / 100;
-	while (context->ym->current_cycle != context->psg->cycles) {
-		sync_sound(context, context->psg->cycles + MCLKS_PER_PSG);
+	if (context->header.type != SYSTEM_PICO && context->header.type != SYSTEM_COPERA) {
+		while (context->ym->current_cycle != context->psg->cycles) {
+			sync_sound(context, context->psg->cycles + MCLKS_PER_PSG);
+		}
+		if (context->expansion) {
+			segacd_context *cd = context->expansion;
+			segacd_set_speed_percent(cd, percent);
+		}
+		ym_adjust_master_clock(context->ym, context->master_clock);
+	} else {
+		while (context->adpcm->cycle != context->psg->cycles) {
+			sync_sound_pico(context, context->psg->cycles + MCLKS_PER_PSG);
+		}
+		if (context->ymz) {
+			ymz263b_adjust_master_clock(context->ymz, context->master_clock);
+		}
+		pico_pcm_adjust_master_clock(context->adpcm, context->master_clock);
 	}
-	if (context->expansion) {
-		segacd_context *cd = context->expansion;
-		segacd_set_speed_percent(cd, percent);
-	}
-	ym_adjust_master_clock(context->ym, context->master_clock);
 	psg_adjust_master_clock(context->psg, context->master_clock);
 }
 
@@ -2211,7 +2221,7 @@
 		pico_pcm_free(gen->adpcm);
 		free(gen->adpcm);
 		if (gen->ymz) {
-			//TODO: call cleanup function once it exists
+			ymz263b_free(gen->ymz);
 			free(gen->ymz);
 		}
 	} else {