Mercurial > repos > blastem
comparison ym2612.c @ 451:b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 26 Jul 2013 19:55:04 -0700 |
parents | e85a107e6ec0 |
children | 140af5509ce7 |
comparison
equal
deleted
inserted
replaced
448:e85a107e6ec0 | 451:b7c3b2d22858 |
---|---|
580 operator->phase_inc = inc; | 580 operator->phase_inc = inc; |
581 } | 581 } |
582 | 582 |
583 void ym_data_write(ym2612_context * context, uint8_t value) | 583 void ym_data_write(ym2612_context * context, uint8_t value) |
584 { | 584 { |
585 if (context->selected_reg < 0x21 || context->selected_reg > 0xB6 || (context->selected_reg < 0x30 && context->selected_part)) { | 585 if (context->selected_reg >= YM_REG_END) { |
586 return; | 586 return; |
587 } | |
588 if (context->selected_part) { | |
589 if (context->selected_reg < YM_PART2_START) { | |
590 return; | |
591 } | |
592 context->part2_regs[context->selected_reg - YM_PART2_START] = value; | |
593 } else { | |
594 if (context->selected_reg < YM_PART1_START) { | |
595 return; | |
596 } | |
597 context->part1_regs[context->selected_reg - YM_PART1_START] = value; | |
587 } | 598 } |
588 dfprintf(debug_file, "write of %X to reg %X in part %d\n", value, context->selected_reg, context->selected_part+1); | 599 dfprintf(debug_file, "write of %X to reg %X in part %d\n", value, context->selected_reg, context->selected_part+1); |
589 if (context->selected_reg < 0x30) { | 600 if (context->selected_reg < 0x30) { |
590 //Shared regs | 601 //Shared regs |
591 switch (context->selected_reg) | 602 switch (context->selected_reg) |
763 uint8_t ym_read_status(ym2612_context * context) | 774 uint8_t ym_read_status(ym2612_context * context) |
764 { | 775 { |
765 return context->status; | 776 return context->status; |
766 } | 777 } |
767 | 778 |
768 #define GST_YM_OFFSET 0x1E4 | |
769 #define GST_YM_SIZE (0x3E4-GST_YM_OFFSET) | |
770 | |
771 uint8_t ym_load_gst(ym2612_context * context, FILE * gstfile) | |
772 { | |
773 uint8_t regdata[GST_YM_SIZE]; | |
774 fseek(gstfile, GST_YM_OFFSET, SEEK_SET); | |
775 if (fread(regdata, 1, sizeof(regdata), gstfile) != sizeof(regdata)) { | |
776 return 0; | |
777 } | |
778 for (int i = 0; i < sizeof(regdata); i++) { | |
779 if (i & 0x100) { | |
780 ym_address_write_part2(context, i & 0xFF); | |
781 } else { | |
782 ym_address_write_part1(context, i); | |
783 } | |
784 ym_data_write(context, regdata[i]); | |
785 } | |
786 return 1; | |
787 } | |
788 |