Mercurial > repos > blastem
comparison psg.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 | 9c65819afec3 |
comparison
equal
deleted
inserted
replaced
1426:957325c990d5 | 1427:4e5797b3935a |
---|---|
149 } | 149 } |
150 context->cycles += context->clock_inc; | 150 context->cycles += context->clock_inc; |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 void psg_serialize(psg_context *context, serialize_buffer *buf) | |
155 { | |
156 save_int16(buf, context->lsfr); | |
157 save_buffer16(buf, context->counter_load, 4); | |
158 save_buffer16(buf, context->counters, 4); | |
159 save_buffer8(buf, context->volume, 4); | |
160 uint8_t output_state = context->output_state[0] << 3 | context->output_state[1] << 2 | |
161 | context->output_state[2] << 1 | context->output_state[3] | |
162 | context->noise_use_tone << 4; | |
163 save_int8(buf, output_state); | |
164 save_int8(buf, context->noise_type); | |
165 save_int8(buf, context->latch); | |
166 save_int32(buf, context->cycles); | |
167 } | |
168 | |
169 void psg_deserialize(deserialize_buffer *buf, void *vcontext) | |
170 { | |
171 psg_context *context = vcontext; | |
172 context->lsfr = load_int16(buf); | |
173 load_buffer16(buf, context->counter_load, 4); | |
174 load_buffer16(buf, context->counters, 4); | |
175 load_buffer8(buf, context->volume, 4); | |
176 uint8_t output_state = load_int8(buf); | |
177 context->output_state[0] = output_state & 8 >> 3; | |
178 context->output_state[1] = output_state & 4 >> 2; | |
179 context->output_state[2] = output_state & 2 >> 1; | |
180 context->output_state[3] = output_state & 1; | |
181 context->noise_use_tone = output_state & 0x10 >> 4; | |
182 context->noise_type = load_int8(buf); | |
183 context->latch = load_int8(buf); | |
184 context->cycles = load_int32(buf); | |
185 } |