Mercurial > repos > blastem
diff sms.c @ 2529:a6687a6fb69d
Merge
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 25 Nov 2024 22:30:32 -0800 |
parents | 90a40be940f7 7e1215d17571 |
children | f4a471730ba4 |
line wrap: on
line diff
--- a/sms.c Mon Nov 25 22:26:45 2024 -0800 +++ b/sms.c Mon Nov 25 22:30:32 2024 -0800 @@ -375,6 +375,9 @@ sms_context *sms = z80->system; psg_run(sms->psg, z80->Z80_CYCLE); sms->psg->pan = value; + if (sms->psg->vgm) { + vgm_gg_pan_write(sms->psg->vgm, sms->psg->cycles, sms->psg->pan); + } return vcontext; } @@ -717,6 +720,9 @@ vdp_adjust_cycles(sms->vdp, adjust); sms->psg->cycles -= adjust; sms->cassette_cycle -= adjust; + if (sms->psg->vgm) { + vgm_adjust_cycles(sms->psg->vgm, adjust); + } target_cycle -= adjust; } } @@ -1011,6 +1017,30 @@ sms->cassette = media; } +static void start_vgm_log(system_header *system, char *filename) +{ + sms_context *sms = (sms_context *)system; + //TODO: 50 Hz support + vgm_writer *vgm = vgm_write_open(filename, 60, sms->normal_clock, sms->z80->Z80_CYCLE); + if (vgm) { + printf("Started logging VGM to %s\n", filename); + psg_run(sms->psg, sms->z80->Z80_CYCLE); + psg_vgm_log(sms->psg, sms->normal_clock, vgm); + sms->header.vgm_logging = 1; + } else { + printf("Failed to start logging to %s\n", filename); + } +} + +static void stop_vgm_log(system_header *system) +{ + puts("Stopped VGM log"); + sms_context *sms = (sms_context *)system; + vgm_close(sms->psg->vgm); + sms->psg->vgm = NULL; + sms->header.vgm_logging = 0; +} + sms_context *alloc_configure_sms(system_media *media, uint32_t opts, uint8_t force_region) { sms_context *sms = calloc(1, sizeof(sms_context)); @@ -1149,6 +1179,8 @@ sms->header.config_updated = config_updated; sms->header.serialize = serialize; sms->header.deserialize = deserialize; + sms->header.start_vgm_log = start_vgm_log; + sms->header.stop_vgm_log = stop_vgm_log; sms->header.toggle_debug_view = toggle_debug_view; sms->header.cassette_action = cassette_action; sms->header.type = SYSTEM_SMS;