comparison gst.c @ 1181:0928b68fef2a

Update gst loader to deal with VDP changes
author Michael Pavone <pavone@retrodev.com>
date Tue, 17 Jan 2017 19:01:13 -0800
parents e9369d6f0101
children 58bfbed6cdb5
comparison
equal deleted inserted replaced
1180:e2b81a0f8fd8 1181:0928b68fef2a
220 220
221 uint8_t vdp_load_gst(vdp_context * context, FILE * state_file) 221 uint8_t vdp_load_gst(vdp_context * context, FILE * state_file)
222 { 222 {
223 uint8_t tmp_buf[VRAM_SIZE]; 223 uint8_t tmp_buf[VRAM_SIZE];
224 fseek(state_file, GST_VDP_REGS, SEEK_SET); 224 fseek(state_file, GST_VDP_REGS, SEEK_SET);
225 if (fread(context->regs, 1, VDP_REGS, state_file) != VDP_REGS) { 225 if (fread(tmp_buf, 1, VDP_REGS, state_file) != VDP_REGS) {
226 fputs("Failed to read VDP registers from savestate\n", stderr); 226 fputs("Failed to read VDP registers from savestate\n", stderr);
227 return 0; 227 return 0;
228 } 228 }
229 context->double_res = (context->regs[REG_MODE_4] & (BIT_INTERLACE | BIT_DOUBLE_RES)) == (BIT_INTERLACE | BIT_DOUBLE_RES); 229 for (uint16_t i = 0; i < VDP_REGS; i++)
230 {
231 vdp_control_port_write(context, 0x8000 | (i << 8) | tmp_buf[i]);
232 }
230 latch_mode(context); 233 latch_mode(context);
231 if (fread(tmp_buf, 1, CRAM_SIZE*2, state_file) != CRAM_SIZE*2) { 234 if (fread(tmp_buf, 1, CRAM_SIZE*2, state_file) != CRAM_SIZE*2) {
232 fputs("Failed to read CRAM from savestate\n", stderr); 235 fputs("Failed to read CRAM from savestate\n", stderr);
233 return 0; 236 return 0;
234 } 237 }
235 for (int i = 0; i < CRAM_SIZE; i++) { 238 for (int i = 0; i < CRAM_SIZE; i++) {
236 uint16_t value; 239 uint16_t value;
237 write_cram(context, i, (tmp_buf[i*2+1] << 8) | tmp_buf[i*2]); 240 write_cram(context, i*2, (tmp_buf[i*2+1] << 8) | tmp_buf[i*2]);
238 } 241 }
239 if (fread(tmp_buf, 2, VSRAM_SIZE, state_file) != VSRAM_SIZE) { 242 if (fread(tmp_buf, 2, VSRAM_SIZE, state_file) != VSRAM_SIZE) {
240 fputs("Failed to read VSRAM from savestate\n", stderr); 243 fputs("Failed to read VSRAM from savestate\n", stderr);
241 return 0; 244 return 0;
242 } 245 }