comparison 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
comparison
equal deleted inserted replaced
1908:c3d49c338224 1909:508522f08e4d
777 } 777 }
778 //printf("phase_inc for operator %d: %d, block: %d, fnum: %d, detune: %d, multiple: %d\n", op, inc, channel->block, channel->fnum, detune, operator->multiple); 778 //printf("phase_inc for operator %d: %d, block: %d, fnum: %d, detune: %d, multiple: %d\n", op, inc, channel->block, channel->fnum, detune, operator->multiple);
779 return inc; 779 return inc;
780 } 780 }
781 781
782 void ym_vgm_log(ym2612_context *context, uint32_t master_clock, vgm_writer *vgm)
783 {
784 vgm_ym2612_init(vgm, 6 * master_clock / context->clock_inc);
785 context->vgm = vgm;
786 for (uint8_t reg = YM_PART1_START; reg < YM_REG_END; reg++) {
787 vgm_ym2612_part1_write(context->vgm, context->current_cycle, reg, context->part1_regs[reg - YM_PART1_START]);
788 }
789
790 for (uint8_t reg = YM_PART2_START; reg < YM_REG_END; reg++) {
791 vgm_ym2612_part2_write(context->vgm, context->current_cycle, reg, context->part2_regs[reg - YM_PART2_START]);
792 }
793 }
794
782 void ym_data_write(ym2612_context * context, uint8_t value) 795 void ym_data_write(ym2612_context * context, uint8_t value)
783 { 796 {
784 context->write_cycle = context->current_cycle; 797 context->write_cycle = context->current_cycle;
785 context->busy_start = context->current_cycle + context->clock_inc; 798 context->busy_start = context->current_cycle + context->clock_inc;
786 799
789 } 802 }
790 if (context->selected_part) { 803 if (context->selected_part) {
791 if (context->selected_reg < YM_PART2_START) { 804 if (context->selected_reg < YM_PART2_START) {
792 return; 805 return;
793 } 806 }
807 if (context->vgm) {
808 vgm_ym2612_part2_write(context->vgm, context->current_cycle, context->selected_reg, value);
809 }
794 context->part2_regs[context->selected_reg - YM_PART2_START] = value; 810 context->part2_regs[context->selected_reg - YM_PART2_START] = value;
795 } else { 811 } else {
796 if (context->selected_reg < YM_PART1_START) { 812 if (context->selected_reg < YM_PART1_START) {
797 return; 813 return;
814 }
815 if (context->vgm) {
816 vgm_ym2612_part1_write(context->vgm, context->current_cycle, context->selected_reg, value);
798 } 817 }
799 context->part1_regs[context->selected_reg - YM_PART1_START] = value; 818 context->part1_regs[context->selected_reg - YM_PART1_START] = value;
800 } 819 }
801 dfprintf(debug_file, "write of %X to reg %X in part %d\n", value, context->selected_reg, context->selected_part+1); 820 dfprintf(debug_file, "write of %X to reg %X in part %d\n", value, context->selected_reg, context->selected_part+1);
802 if (context->selected_reg < 0x30) { 821 if (context->selected_reg < 0x30) {