Mercurial > repos > blastem
diff ym2612.c @ 1909:508522f08e4d
Initial stab at VGM logging support
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 27 Mar 2020 00:03:58 -0700 |
parents | 8312e574100a |
children | 00fb99805445 |
line wrap: on
line diff
--- a/ym2612.c Thu Mar 26 23:53:35 2020 -0700 +++ b/ym2612.c Fri Mar 27 00:03:58 2020 -0700 @@ -779,6 +779,19 @@ return inc; } +void ym_vgm_log(ym2612_context *context, uint32_t master_clock, vgm_writer *vgm) +{ + vgm_ym2612_init(vgm, 6 * master_clock / context->clock_inc); + context->vgm = vgm; + for (uint8_t reg = YM_PART1_START; reg < YM_REG_END; reg++) { + vgm_ym2612_part1_write(context->vgm, context->current_cycle, reg, context->part1_regs[reg - YM_PART1_START]); + } + + for (uint8_t reg = YM_PART2_START; reg < YM_REG_END; reg++) { + vgm_ym2612_part2_write(context->vgm, context->current_cycle, reg, context->part2_regs[reg - YM_PART2_START]); + } +} + void ym_data_write(ym2612_context * context, uint8_t value) { context->write_cycle = context->current_cycle; @@ -791,11 +804,17 @@ if (context->selected_reg < YM_PART2_START) { return; } + if (context->vgm) { + vgm_ym2612_part2_write(context->vgm, context->current_cycle, context->selected_reg, value); + } context->part2_regs[context->selected_reg - YM_PART2_START] = value; } else { if (context->selected_reg < YM_PART1_START) { return; } + if (context->vgm) { + vgm_ym2612_part1_write(context->vgm, context->current_cycle, context->selected_reg, value); + } context->part1_regs[context->selected_reg - YM_PART1_START] = value; } dfprintf(debug_file, "write of %X to reg %X in part %d\n", value, context->selected_reg, context->selected_part+1);