# HG changeset patch # User Michael Pavone # Date 1503990575 25200 # Node ID a094815b11687afada1417338a730e9d3fea9189 # Parent adb62000d296b40df4253b90d3266ea191d1d2dd Save and restore YM2612 timer control and keyon/off state in native save states diff -r adb62000d296 -r a094815b1168 ym2612.c --- 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);