Mercurial > repos > blastem
comparison ym2612.c @ 1427:4e5797b3935a
WIP - New savestate format
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 06 Aug 2017 00:06:36 -0700 |
parents | 4d16c09210fd |
children | a094815b1168 |
comparison
equal
deleted
inserted
replaced
1426:957325c990d5 | 1427:4e5797b3935a |
---|---|
1056 context->timer_b_load, | 1056 context->timer_b_load, |
1057 context->status & BIT_STATUS_TIMERB ? "yes" : "no", | 1057 context->status & BIT_STATUS_TIMERB ? "yes" : "no", |
1058 context->timer_control & BIT_TIMERB_ENABLE ? "yes" : "no"); | 1058 context->timer_control & BIT_TIMERB_ENABLE ? "yes" : "no"); |
1059 } | 1059 } |
1060 | 1060 |
1061 void ym_serialize(ym2612_context *context, serialize_buffer *buf) | |
1062 { | |
1063 save_buffer8(buf, context->part1_regs, YM_PART1_REGS); | |
1064 save_buffer8(buf, context->part2_regs, YM_PART2_REGS); | |
1065 for (int i = 0; i < NUM_OPERATORS; i++) | |
1066 { | |
1067 save_int32(buf, context->operators[i].phase_counter); | |
1068 save_int16(buf, context->operators[i].envelope); | |
1069 save_int16(buf, context->operators[i].output); | |
1070 save_int8(buf, context->operators[i].env_phase); | |
1071 save_int8(buf, context->operators[i].inverted); | |
1072 } | |
1073 for (int i = 0; i < NUM_CHANNELS; i++) | |
1074 { | |
1075 save_int16(buf, context->channels[i].output); | |
1076 save_int16(buf, context->channels[i].op1_old); | |
1077 //Due to the latching behavior, these need to be saved | |
1078 //even though duplicate info is probably in the regs array | |
1079 save_int8(buf, context->channels[i].block); | |
1080 save_int8(buf, context->channels[i].fnum); | |
1081 } | |
1082 for (int i = 0; i < 3; i++) | |
1083 { | |
1084 //Due to the latching behavior, these need to be saved | |
1085 //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].fnum); | |
1088 } | |
1089 save_int16(buf, context->timer_a); | |
1090 save_int8(buf, context->timer_b); | |
1091 save_int8(buf, context->sub_timer_b); | |
1092 save_int16(buf, context->env_counter); | |
1093 save_int8(buf, context->current_op); | |
1094 save_int8(buf, context->current_env_op); | |
1095 save_int8(buf, context->lfo_counter); | |
1096 save_int8(buf, context->csm_keyon); | |
1097 save_int8(buf, context->status); | |
1098 save_int8(buf, context->selected_reg); | |
1099 save_int8(buf, context->selected_part); | |
1100 save_int32(buf, context->current_cycle); | |
1101 save_int32(buf, context->write_cycle); | |
1102 save_int32(buf, context->busy_cycles); | |
1103 } | |
1104 | |
1105 void ym_deserialize(deserialize_buffer *buf, void *vcontext) | |
1106 { | |
1107 ym2612_context *context = vcontext; | |
1108 uint8_t temp_regs[YM_PART1_REGS]; | |
1109 load_buffer8(buf, temp_regs, YM_PART1_REGS); | |
1110 context->selected_part = 0; | |
1111 for (int i = 0; i < YM_PART1_REGS; i++) | |
1112 { | |
1113 uint8_t reg = YM_PART1_START + i; | |
1114 if (reg != REG_FNUM_LOW && reg != REG_KEY_ONOFF && reg != REG_TIME_CTRL) { | |
1115 context->selected_reg = reg; | |
1116 ym_data_write(context, temp_regs[i]); | |
1117 } | |
1118 } | |
1119 load_buffer8(buf, temp_regs, YM_PART2_REGS); | |
1120 context->selected_part = 1; | |
1121 for (int i = 0; i < YM_PART2_REGS; i++) | |
1122 { | |
1123 uint8_t reg = YM_PART2_START + i; | |
1124 if (reg != REG_FNUM_LOW) { | |
1125 context->selected_reg = reg; | |
1126 ym_data_write(context, temp_regs[i]); | |
1127 } | |
1128 } | |
1129 for (int i = 0; i < NUM_OPERATORS; i++) | |
1130 { | |
1131 context->operators[i].phase_counter = load_int32(buf); | |
1132 context->operators[i].envelope = load_int16(buf); | |
1133 context->operators[i].output = load_int16(buf); | |
1134 context->operators[i].env_phase = load_int8(buf); | |
1135 if (context->operators[i].env_phase > PHASE_RELEASE) { | |
1136 context->operators[i].env_phase = PHASE_RELEASE; | |
1137 } | |
1138 context->operators[i].inverted = load_int8(buf) != 0; | |
1139 } | |
1140 for (int i = 0; i < NUM_CHANNELS; i++) | |
1141 { | |
1142 context->channels[i].output = load_int16(buf); | |
1143 context->channels[i].op1_old = load_int16(buf); | |
1144 context->channels[i].block = load_int8(buf); | |
1145 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]; | |
1147 } | |
1148 for (int i = 0; i < 3; i++) | |
1149 { | |
1150 context->ch3_supp[i].block = load_int8(buf); | |
1151 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]; | |
1153 } | |
1154 context->timer_a = load_int16(buf); | |
1155 context->timer_b = load_int8(buf); | |
1156 context->sub_timer_b = load_int8(buf); | |
1157 context->env_counter = load_int16(buf); | |
1158 context->current_op = load_int8(buf); | |
1159 if (context->current_op >= NUM_OPERATORS) { | |
1160 context->current_op = 0; | |
1161 } | |
1162 context->current_env_op = load_int8(buf); | |
1163 if (context->current_env_op >= NUM_OPERATORS) { | |
1164 context->current_env_op = 0; | |
1165 } | |
1166 context->lfo_counter = load_int8(buf); | |
1167 context->csm_keyon = load_int8(buf); | |
1168 context->status = load_int8(buf); | |
1169 context->selected_reg = load_int8(buf); | |
1170 context->selected_part = load_int8(buf); | |
1171 context->current_cycle = load_int32(buf); | |
1172 context->write_cycle = load_int32(buf); | |
1173 context->busy_cycles = load_int32(buf); | |
1174 } |