# HG changeset patch # User Michael Pavone # Date 1670912816 28800 # Node ID 74112041b2c7283703280b284c176ebbabed5ad8 # Parent 8b88d57d1218422f6dbeb4f1a01678f7a246ff56 Proper calculation of sample rate for YM2612/PSG oscilloscope view diff -r 8b88d57d1218 -r 74112041b2c7 genesis.c --- a/genesis.c Mon Dec 12 21:49:51 2022 -0800 +++ b/genesis.c Mon Dec 12 22:26:56 2022 -0800 @@ -1733,8 +1733,8 @@ scope_close(scope); } else { oscilloscope *scope = create_oscilloscope(); - ym_enable_scope(gen->ym, scope); - psg_enable_scope(gen->psg, scope); + ym_enable_scope(gen->ym, scope, gen->normal_clock); + psg_enable_scope(gen->psg, scope, gen->normal_clock); if (gen->expansion) { segacd_context *cd = gen->expansion; rf5c164_enable_scope(&cd->pcm, scope); diff -r 8b88d57d1218 -r 74112041b2c7 psg.c --- a/psg.c Mon Dec 12 21:49:51 2022 -0800 +++ b/psg.c Mon Dec 12 22:26:56 2022 -0800 @@ -21,7 +21,7 @@ context->pan = 0xFF; } -void psg_enable_scope(psg_context *context, oscilloscope *scope) +void psg_enable_scope(psg_context *context, oscilloscope *scope, uint32_t master_clock) { context->scope = scope; static const char *names[] = { @@ -32,7 +32,7 @@ }; for (int i = 0; i < 4; i++) { - context->scope_channel[i] = scope_add_channel(scope, names[i], 53693175 / context->clock_inc); + context->scope_channel[i] = scope_add_channel(scope, names[i], master_clock / context->clock_inc); } } diff -r 8b88d57d1218 -r 74112041b2c7 psg.h --- a/psg.h Mon Dec 12 21:49:51 2022 -0800 +++ b/psg.h Mon Dec 12 22:26:56 2022 -0800 @@ -33,7 +33,7 @@ void psg_init(psg_context * context, uint32_t master_clock, uint32_t clock_div); -void psg_enable_scope(psg_context *context, oscilloscope *scope); +void psg_enable_scope(psg_context *context, oscilloscope *scope, uint32_t master_clock); void psg_free(psg_context *context); void psg_adjust_master_clock(psg_context * context, uint32_t master_clock); void psg_write(psg_context * context, uint8_t value); diff -r 8b88d57d1218 -r 74112041b2c7 ym2612.c --- a/ym2612.c Mon Dec 12 21:49:51 2022 -0800 +++ b/ym2612.c Mon Dec 12 22:26:56 2022 -0800 @@ -1397,7 +1397,7 @@ } } -void ym_enable_scope(ym2612_context *context, oscilloscope *scope) +void ym_enable_scope(ym2612_context *context, oscilloscope *scope, uint32_t master_clock) { static const char *names[] = { "YM2612 #1", @@ -1410,7 +1410,6 @@ context->scope = scope; for (int i = 0; i < NUM_CHANNELS; i++) { - //TODO: calculate actual sample rate based on current clock settings - context->channels[i].scope_channel = scope_add_channel(scope, names[i], 53267); + context->channels[i].scope_channel = scope_add_channel(scope, names[i], master_clock / (context->clock_inc * NUM_OPERATORS)); } } diff -r 8b88d57d1218 -r 74112041b2c7 ym2612.h --- a/ym2612.h Mon Dec 12 21:49:51 2022 -0800 +++ b/ym2612.h Mon Dec 12 22:26:56 2022 -0800 @@ -159,7 +159,7 @@ void ym_print_timer_info(ym2612_context *context); void ym_serialize(ym2612_context *context, serialize_buffer *buf); void ym_deserialize(deserialize_buffer *buf, void *vcontext); -void ym_enable_scope(ym2612_context *context, oscilloscope *scope); +void ym_enable_scope(ym2612_context *context, oscilloscope *scope, uint32_t master_clock); #endif //YM2612_H_