changeset 1447:a094815b1168

Save and restore YM2612 timer control and keyon/off state in native save states
author Michael Pavone <pavone@retrodev.com>
date Tue, 29 Aug 2017 00:09:35 -0700
parents adb62000d296
children 9327c1dc3791
files ym2612.c
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ym2612.c	Mon Aug 28 22:41:02 2017 -0700
+++ b/ym2612.c	Tue Aug 29 00:09:35 2017 -0700
@@ -1078,6 +1078,7 @@
 		//even though duplicate info is probably in the regs array
 		save_int8(buf, context->channels[i].block);
 		save_int8(buf, context->channels[i].fnum);
+		save_int8(buf, context->channels[i].keyon);
 	}
 	for (int i = 0; i < 3; i++)
 	{
@@ -1086,6 +1087,7 @@
 		save_int8(buf, context->ch3_supp[i].block);
 		save_int8(buf, context->ch3_supp[i].fnum);
 	}
+	save_int8(buf, context->timer_control);
 	save_int16(buf, context->timer_a);
 	save_int8(buf, context->timer_b);
 	save_int8(buf, context->sub_timer_b);
@@ -1111,7 +1113,9 @@
 	for (int i = 0; i < YM_PART1_REGS; i++)
 	{
 		uint8_t reg = YM_PART1_START + i;
-		if (reg != REG_FNUM_LOW && reg != REG_KEY_ONOFF && reg != REG_TIME_CTRL) {
+		if (reg == REG_TIME_CTRL) {
+			context->ch3_mode = temp_regs[i] & 0xC0;
+		} else if (reg != REG_FNUM_LOW && reg != REG_KEY_ONOFF) {
 			context->selected_reg = reg;
 			ym_data_write(context, temp_regs[i]);
 		}
@@ -1144,6 +1148,7 @@
 		context->channels[i].block = load_int8(buf);
 		context->channels[i].fnum = load_int8(buf);
 		context->channels[i].keycode = context->channels[i].block << 2 | fnum_to_keycode[context->channels[i].fnum >> 7];
+		context->channels[i].keyon = load_int8(buf);
 	}
 	for (int i = 0; i < 3; i++)
 	{
@@ -1151,6 +1156,7 @@
 		context->ch3_supp[i].fnum = load_int8(buf);
 		context->ch3_supp[i].keycode = context->ch3_supp[i].block << 2 | fnum_to_keycode[context->ch3_supp[i].fnum >> 7];
 	}
+	context->timer_control = load_int8(buf);
 	context->timer_a = load_int16(buf);
 	context->timer_b = load_int8(buf);
 	context->sub_timer_b = load_int8(buf);