diff segacd.c @ 2278:5a21bc0ec583

Implement turbo/slo mo for Sega CD
author Michael Pavone <pavone@retrodev.com>
date Mon, 02 Jan 2023 13:08:49 -0800
parents 54cd40fc0da5
children 9ead0fe69d9b
line wrap: on
line diff
--- a/segacd.c	Mon Jan 02 12:24:22 2023 -0800
+++ b/segacd.c	Mon Jan 02 13:08:49 2023 -0800
@@ -1538,3 +1538,12 @@
 	*num_chunks = sizeof(main_cpu_map) / sizeof(*main_cpu_map);
 	return main_cpu_map;
 }
+
+void segacd_set_speed_percent(segacd_context *cd, uint32_t percent)
+{
+	uint32_t scd_cycle = gen_cycle_to_scd(cd->genesis->ym->current_cycle, cd->genesis);
+	scd_run(cd, scd_cycle);
+	uint32_t new_clock = ((uint64_t)SCD_MCLKS * (uint64_t)percent) / 100;
+	rf5c164_adjust_master_clock(&cd->pcm, new_clock);
+	cdd_fader_set_speed_percent(&cd->fader, percent);
+}