comparison ym2612.c @ 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 4e5797b3935a
children 08bc099a622f
comparison
equal deleted inserted replaced
1446:adb62000d296 1447:a094815b1168
1076 save_int16(buf, context->channels[i].op1_old); 1076 save_int16(buf, context->channels[i].op1_old);
1077 //Due to the latching behavior, these need to be saved 1077 //Due to the latching behavior, these need to be saved
1078 //even though duplicate info is probably in the regs array 1078 //even though duplicate info is probably in the regs array
1079 save_int8(buf, context->channels[i].block); 1079 save_int8(buf, context->channels[i].block);
1080 save_int8(buf, context->channels[i].fnum); 1080 save_int8(buf, context->channels[i].fnum);
1081 save_int8(buf, context->channels[i].keyon);
1081 } 1082 }
1082 for (int i = 0; i < 3; i++) 1083 for (int i = 0; i < 3; i++)
1083 { 1084 {
1084 //Due to the latching behavior, these need to be saved 1085 //Due to the latching behavior, these need to be saved
1085 //even though duplicate info is probably in the regs array 1086 //even though duplicate info is probably in the regs array
1086 save_int8(buf, context->ch3_supp[i].block); 1087 save_int8(buf, context->ch3_supp[i].block);
1087 save_int8(buf, context->ch3_supp[i].fnum); 1088 save_int8(buf, context->ch3_supp[i].fnum);
1088 } 1089 }
1090 save_int8(buf, context->timer_control);
1089 save_int16(buf, context->timer_a); 1091 save_int16(buf, context->timer_a);
1090 save_int8(buf, context->timer_b); 1092 save_int8(buf, context->timer_b);
1091 save_int8(buf, context->sub_timer_b); 1093 save_int8(buf, context->sub_timer_b);
1092 save_int16(buf, context->env_counter); 1094 save_int16(buf, context->env_counter);
1093 save_int8(buf, context->current_op); 1095 save_int8(buf, context->current_op);
1109 load_buffer8(buf, temp_regs, YM_PART1_REGS); 1111 load_buffer8(buf, temp_regs, YM_PART1_REGS);
1110 context->selected_part = 0; 1112 context->selected_part = 0;
1111 for (int i = 0; i < YM_PART1_REGS; i++) 1113 for (int i = 0; i < YM_PART1_REGS; i++)
1112 { 1114 {
1113 uint8_t reg = YM_PART1_START + i; 1115 uint8_t reg = YM_PART1_START + i;
1114 if (reg != REG_FNUM_LOW && reg != REG_KEY_ONOFF && reg != REG_TIME_CTRL) { 1116 if (reg == REG_TIME_CTRL) {
1117 context->ch3_mode = temp_regs[i] & 0xC0;
1118 } else if (reg != REG_FNUM_LOW && reg != REG_KEY_ONOFF) {
1115 context->selected_reg = reg; 1119 context->selected_reg = reg;
1116 ym_data_write(context, temp_regs[i]); 1120 ym_data_write(context, temp_regs[i]);
1117 } 1121 }
1118 } 1122 }
1119 load_buffer8(buf, temp_regs, YM_PART2_REGS); 1123 load_buffer8(buf, temp_regs, YM_PART2_REGS);
1142 context->channels[i].output = load_int16(buf); 1146 context->channels[i].output = load_int16(buf);
1143 context->channels[i].op1_old = load_int16(buf); 1147 context->channels[i].op1_old = load_int16(buf);
1144 context->channels[i].block = load_int8(buf); 1148 context->channels[i].block = load_int8(buf);
1145 context->channels[i].fnum = load_int8(buf); 1149 context->channels[i].fnum = load_int8(buf);
1146 context->channels[i].keycode = context->channels[i].block << 2 | fnum_to_keycode[context->channels[i].fnum >> 7]; 1150 context->channels[i].keycode = context->channels[i].block << 2 | fnum_to_keycode[context->channels[i].fnum >> 7];
1151 context->channels[i].keyon = load_int8(buf);
1147 } 1152 }
1148 for (int i = 0; i < 3; i++) 1153 for (int i = 0; i < 3; i++)
1149 { 1154 {
1150 context->ch3_supp[i].block = load_int8(buf); 1155 context->ch3_supp[i].block = load_int8(buf);
1151 context->ch3_supp[i].fnum = load_int8(buf); 1156 context->ch3_supp[i].fnum = load_int8(buf);
1152 context->ch3_supp[i].keycode = context->ch3_supp[i].block << 2 | fnum_to_keycode[context->ch3_supp[i].fnum >> 7]; 1157 context->ch3_supp[i].keycode = context->ch3_supp[i].block << 2 | fnum_to_keycode[context->ch3_supp[i].fnum >> 7];
1153 } 1158 }
1159 context->timer_control = load_int8(buf);
1154 context->timer_a = load_int16(buf); 1160 context->timer_a = load_int16(buf);
1155 context->timer_b = load_int8(buf); 1161 context->timer_b = load_int8(buf);
1156 context->sub_timer_b = load_int8(buf); 1162 context->sub_timer_b = load_int8(buf);
1157 context->env_counter = load_int16(buf); 1163 context->env_counter = load_int16(buf);
1158 context->current_op = load_int8(buf); 1164 context->current_op = load_int8(buf);