Mercurial > repos > blastem
annotate gst.c @ 1124:e4deab85f9ac
The function of the HVC Latch enable bit in mode register 1 is different when not in mode 5
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 27 Dec 2016 13:38:58 -0800 |
parents | e9369d6f0101 |
children | 0928b68fef2a |
rev | line source |
---|---|
467
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
451
diff
changeset
|
1 /* |
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
451
diff
changeset
|
2 Copyright 2013 Michael Pavone |
668
5439ae7946ca
Made the Z80 core more contained by refactoring some code in blastem.c into z80_to_x86.c
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
3 This file is part of BlastEm. |
467
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
451
diff
changeset
|
4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text. |
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
451
diff
changeset
|
5 */ |
1103
22e87b739ad6
WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
Michael Pavone <pavone@retrodev.com>
parents:
1077
diff
changeset
|
6 #include "genesis.h" |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 #include "gst.h" |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 #include <string.h> |
1103
22e87b739ad6
WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
Michael Pavone <pavone@retrodev.com>
parents:
1077
diff
changeset
|
9 #include <stdio.h> |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 #define GST_68K_REGS 0x80 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 #define GST_68K_REG_SIZE (0xDA-GST_68K_REGS) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 #define GST_68K_PC_OFFSET (0xC8-GST_68K_REGS) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 #define GST_68K_SR_OFFSET (0xD0-GST_68K_REGS) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 #define GST_68K_USP_OFFSET (0xD2-GST_68K_REGS) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 #define GST_68K_SSP_OFFSET (0xD6-GST_68K_REGS) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 #define GST_68K_RAM 0x2478 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 #define GST_Z80_REGS 0x404 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 #define GST_Z80_REG_SIZE (0x440-GST_Z80_REGS) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 #define GST_Z80_RAM 0x474 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 #define GST_VDP_REGS 0xFA |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 #define GST_VDP_MEM 0x12478 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 #define GST_YM_OFFSET 0x1E4 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 #define GST_YM_SIZE (0x3E4-GST_YM_OFFSET) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 uint32_t read_le_32(uint8_t * data) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 return data[3] << 24 | data[2] << 16 | data[1] << 8 | data[0]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 uint16_t read_le_16(uint8_t * data) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 return data[1] << 8 | data[0]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 uint16_t read_be_16(uint8_t * data) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 return data[0] << 8 | data[1]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 void write_le_32(uint8_t * dst, uint32_t val) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 dst[0] = val; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 dst[1] = val >> 8; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 dst[2] = val >> 16; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 dst[3] = val >> 24; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 void write_le_16(uint8_t * dst, uint16_t val) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 dst[0] = val; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 dst[1] = val >> 8; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 void write_be_32(uint8_t * dst, uint32_t val) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 dst[0] = val >> 24; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 dst[1] = val >> 16; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 dst[2] = val >> 8; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 dst[3] = val; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 void write_be_16(uint8_t * dst, uint16_t val) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 dst[0] = val >> 8; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 dst[1] = val; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 uint32_t m68k_load_gst(m68k_context * context, FILE * gstfile) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 { |
962
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
71 uint8_t buffer[GST_68K_REG_SIZE]; |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 fseek(gstfile, GST_68K_REGS, SEEK_SET); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 if (fread(buffer, 1, GST_68K_REG_SIZE, gstfile) != GST_68K_REG_SIZE) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 fputs("Failed to read 68K registers from savestate\n", stderr); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 uint8_t * curpos = buffer; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 for (int i = 0; i < 8; i++) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 context->dregs[i] = read_le_32(curpos); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 curpos += sizeof(uint32_t); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 for (int i = 0; i < 8; i++) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 context->aregs[i] = read_le_32(curpos); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
84 curpos += sizeof(uint32_t); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
85 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 uint32_t pc = read_le_32(buffer + GST_68K_PC_OFFSET); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 uint16_t sr = read_le_16(buffer + GST_68K_SR_OFFSET); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 context->status = sr >> 8; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 for (int flag = 4; flag >= 0; flag--) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 context->flags[flag] = sr & 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 sr >>= 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 if (context->status & (1 << 5)) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 context->aregs[8] = read_le_32(buffer + GST_68K_USP_OFFSET); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 } else { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 context->aregs[8] = read_le_32(buffer + GST_68K_SSP_OFFSET); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 } |
962
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
98 |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
99 return pc; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
101 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
102 uint8_t m68k_save_gst(m68k_context * context, uint32_t pc, FILE * gstfile) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
103 { |
962
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
104 uint8_t buffer[GST_68K_REG_SIZE]; |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
105 uint8_t * curpos = buffer; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
106 for (int i = 0; i < 8; i++) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 write_le_32(curpos, context->dregs[i]); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 curpos += sizeof(uint32_t); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
109 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
110 for (int i = 0; i < 8; i++) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
111 write_le_32(curpos, context->aregs[i]); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
112 curpos += sizeof(uint32_t); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
113 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
114 write_le_32(buffer + GST_68K_PC_OFFSET, pc); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
115 uint16_t sr = context->status << 3; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
116 for (int flag = 4; flag >= 0; flag--) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
117 sr <<= 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
118 sr |= context->flags[flag]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
119 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
120 write_le_16(buffer + GST_68K_SR_OFFSET, sr); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
121 if (context->status & (1 << 5)) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
122 write_le_32(buffer + GST_68K_USP_OFFSET, context->aregs[8]); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
123 write_le_32(buffer + GST_68K_SSP_OFFSET, context->aregs[7]); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 } else { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
125 write_le_32(buffer + GST_68K_USP_OFFSET, context->aregs[7]); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
126 write_le_32(buffer + GST_68K_SSP_OFFSET, context->aregs[8]); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
127 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
128 fseek(gstfile, GST_68K_REGS, SEEK_SET); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
129 if (fwrite(buffer, 1, GST_68K_REG_SIZE, gstfile) != GST_68K_REG_SIZE) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
130 fputs("Failed to write 68K registers to savestate\n", stderr); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
131 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
132 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
133 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
134 return 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
135 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
136 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
137 uint8_t z80_load_gst(z80_context * context, FILE * gstfile) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
138 { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
139 uint8_t regdata[GST_Z80_REG_SIZE]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
140 fseek(gstfile, GST_Z80_REGS, SEEK_SET); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
141 if (fread(regdata, 1, sizeof(regdata), gstfile) != sizeof(regdata)) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
142 fputs("Failed to read Z80 registers from savestate\n", stderr); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
143 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
144 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
145 uint8_t * curpos = regdata; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
146 uint8_t f = *(curpos++); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
147 context->flags[ZF_C] = f & 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
148 f >>= 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
149 context->flags[ZF_N] = f & 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
150 f >>= 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
151 context->flags[ZF_PV] = f & 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
152 f >>= 2; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
153 context->flags[ZF_H] = f & 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
154 f >>= 2; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
155 context->flags[ZF_Z] = f & 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
156 f >>= 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
157 context->flags[ZF_S] = f; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
158 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
159 context->regs[Z80_A] = *curpos; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
160 curpos += 3; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
161 for (int reg = Z80_C; reg <= Z80_IYH; reg++) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
162 context->regs[reg++] = *(curpos++); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
163 context->regs[reg] = *curpos; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
164 curpos += 3; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
165 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
166 context->pc = read_le_16(curpos); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
167 curpos += 4; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
168 context->sp = read_le_16(curpos); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
169 curpos += 4; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
170 f = *(curpos++); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
171 context->alt_flags[ZF_C] = f & 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
172 f >>= 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
173 context->alt_flags[ZF_N] = f & 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
174 f >>= 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
175 context->alt_flags[ZF_PV] = f & 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
176 f >>= 2; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
177 context->alt_flags[ZF_H] = f & 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
178 f >>= 2; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
179 context->alt_flags[ZF_Z] = f & 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
180 f >>= 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
181 context->alt_flags[ZF_S] = f; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
182 context->alt_regs[Z80_A] = *curpos; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
183 curpos += 3; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
184 for (int reg = Z80_C; reg <= Z80_H; reg++) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
185 context->alt_regs[reg++] = *(curpos++); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
186 context->alt_regs[reg] = *curpos; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
187 curpos += 3; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
188 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
189 context->regs[Z80_I] = *curpos; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
190 curpos += 2; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
191 context->iff1 = context->iff2 = *curpos; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
192 curpos += 2; |
668
5439ae7946ca
Made the Z80 core more contained by refactoring some code in blastem.c into z80_to_x86.c
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
193 context->reset = !*(curpos++); |
5439ae7946ca
Made the Z80 core more contained by refactoring some code in blastem.c into z80_to_x86.c
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
194 context->busreq = *curpos; |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
195 curpos += 3; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
196 uint32_t bank = read_le_32(curpos); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
197 if (bank < 0x400000) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
198 context->mem_pointers[1] = context->mem_pointers[2] + bank; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
199 } else { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
200 context->mem_pointers[1] = NULL; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
201 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
202 context->bank_reg = bank >> 15; |
962
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
203 uint8_t buffer[Z80_RAM_BYTES]; |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
204 fseek(gstfile, GST_Z80_RAM, SEEK_SET); |
962
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
205 if(fread(buffer, 1, sizeof(buffer), gstfile) != (8*1024)) { |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
206 fputs("Failed to read Z80 RAM from savestate\n", stderr); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
207 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
208 } |
962
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
209 for (int i = 0; i < Z80_RAM_BYTES; i++) |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
210 { |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
211 if (context->mem_pointers[0][i] != buffer[i]) { |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
212 context->mem_pointers[0][i] = buffer[i]; |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
213 z80_handle_code_write(i, context); |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
214 } |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
215 } |
1019
e34334e6c682
Fix GST savestate loading to deal with SAT cache to fix sprite corruption on savestate load. Clear out Z80 native_pc so the Z80 state does not get hosed when loading a savestate while the emulator is already running
Michael Pavone <pavone@retrodev.com>
parents:
962
diff
changeset
|
216 context->native_pc = NULL; |
1112
7ab7c8fb34ba
Fix intermittent crash in GST savestate loading
Michael Pavone <pavone@retrodev.com>
parents:
1111
diff
changeset
|
217 context->extra_pc = NULL; |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
218 return 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
219 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
220 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
221 uint8_t vdp_load_gst(vdp_context * context, FILE * state_file) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
222 { |
1019
e34334e6c682
Fix GST savestate loading to deal with SAT cache to fix sprite corruption on savestate load. Clear out Z80 native_pc so the Z80 state does not get hosed when loading a savestate while the emulator is already running
Michael Pavone <pavone@retrodev.com>
parents:
962
diff
changeset
|
223 uint8_t tmp_buf[VRAM_SIZE]; |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
224 fseek(state_file, GST_VDP_REGS, SEEK_SET); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
225 if (fread(context->regs, 1, VDP_REGS, state_file) != VDP_REGS) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
226 fputs("Failed to read VDP registers from savestate\n", stderr); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
227 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
228 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
229 context->double_res = (context->regs[REG_MODE_4] & (BIT_INTERLACE | BIT_DOUBLE_RES)) == (BIT_INTERLACE | BIT_DOUBLE_RES); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
230 latch_mode(context); |
1019
e34334e6c682
Fix GST savestate loading to deal with SAT cache to fix sprite corruption on savestate load. Clear out Z80 native_pc so the Z80 state does not get hosed when loading a savestate while the emulator is already running
Michael Pavone <pavone@retrodev.com>
parents:
962
diff
changeset
|
231 if (fread(tmp_buf, 1, CRAM_SIZE*2, state_file) != CRAM_SIZE*2) { |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
232 fputs("Failed to read CRAM from savestate\n", stderr); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
233 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
234 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
235 for (int i = 0; i < CRAM_SIZE; i++) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
236 uint16_t value; |
1120
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1112
diff
changeset
|
237 write_cram(context, i, (tmp_buf[i*2+1] << 8) | tmp_buf[i*2]); |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
238 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
239 if (fread(tmp_buf, 2, VSRAM_SIZE, state_file) != VSRAM_SIZE) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
240 fputs("Failed to read VSRAM from savestate\n", stderr); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
241 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
242 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
243 for (int i = 0; i < VSRAM_SIZE; i++) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
244 context->vsram[i] = (tmp_buf[i*2+1] << 8) | tmp_buf[i*2]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
245 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
246 fseek(state_file, GST_VDP_MEM, SEEK_SET); |
1019
e34334e6c682
Fix GST savestate loading to deal with SAT cache to fix sprite corruption on savestate load. Clear out Z80 native_pc so the Z80 state does not get hosed when loading a savestate while the emulator is already running
Michael Pavone <pavone@retrodev.com>
parents:
962
diff
changeset
|
247 if (fread(tmp_buf, 1, VRAM_SIZE, state_file) != VRAM_SIZE) { |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
248 fputs("Failed to read VRAM from savestate\n", stderr); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
249 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
250 } |
1019
e34334e6c682
Fix GST savestate loading to deal with SAT cache to fix sprite corruption on savestate load. Clear out Z80 native_pc so the Z80 state does not get hosed when loading a savestate while the emulator is already running
Michael Pavone <pavone@retrodev.com>
parents:
962
diff
changeset
|
251 for (int i = 0; i < VRAM_SIZE; i++) { |
e34334e6c682
Fix GST savestate loading to deal with SAT cache to fix sprite corruption on savestate load. Clear out Z80 native_pc so the Z80 state does not get hosed when loading a savestate while the emulator is already running
Michael Pavone <pavone@retrodev.com>
parents:
962
diff
changeset
|
252 write_vram_byte(context, i, tmp_buf[i]); |
e34334e6c682
Fix GST savestate loading to deal with SAT cache to fix sprite corruption on savestate load. Clear out Z80 native_pc so the Z80 state does not get hosed when loading a savestate while the emulator is already running
Michael Pavone <pavone@retrodev.com>
parents:
962
diff
changeset
|
253 } |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
254 return 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
255 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
256 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
257 uint8_t vdp_save_gst(vdp_context * context, FILE * outfile) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
258 { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
259 uint8_t tmp_buf[CRAM_SIZE*2]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
260 fseek(outfile, GST_VDP_REGS, SEEK_SET); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
261 if(fwrite(context->regs, 1, VDP_REGS, outfile) != VDP_REGS) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
262 fputs("Error writing VDP regs to savestate\n", stderr); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
263 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
264 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
265 for (int i = 0; i < CRAM_SIZE; i++) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
266 { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
267 tmp_buf[i*2] = context->cram[i]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
268 tmp_buf[i*2+1] = context->cram[i] >> 8; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
269 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
270 if (fwrite(tmp_buf, 1, sizeof(tmp_buf), outfile) != sizeof(tmp_buf)) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
271 fputs("Error writing CRAM to savestate\n", stderr); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
272 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
273 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
274 for (int i = 0; i < VSRAM_SIZE; i++) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
275 { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
276 tmp_buf[i*2] = context->vsram[i]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
277 tmp_buf[i*2+1] = context->vsram[i] >> 8; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
278 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
279 if (fwrite(tmp_buf, 2, VSRAM_SIZE, outfile) != VSRAM_SIZE) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
280 fputs("Error writing VSRAM to savestate\n", stderr); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
281 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
282 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
283 fseek(outfile, GST_VDP_MEM, SEEK_SET); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
284 if (fwrite(context->vdpmem, 1, VRAM_SIZE, outfile) != VRAM_SIZE) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
285 fputs("Error writing VRAM to savestate\n", stderr); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
286 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
287 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
288 return 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
289 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
290 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
291 uint8_t z80_save_gst(z80_context * context, FILE * gstfile) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
292 { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
293 uint8_t regdata[GST_Z80_REG_SIZE]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
294 uint8_t * curpos = regdata; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
295 memset(regdata, 0, sizeof(regdata)); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
296 uint8_t f = context->flags[ZF_S]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
297 f <<= 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
298 f |= context->flags[ZF_Z] ; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
299 f <<= 2; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
300 f |= context->flags[ZF_H]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
301 f <<= 2; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
302 f |= context->flags[ZF_PV]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
303 f <<= 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
304 f |= context->flags[ZF_N]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
305 f <<= 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
306 f |= context->flags[ZF_C]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
307 *(curpos++) = f; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
308 *curpos = context->regs[Z80_A]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
309 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
310 curpos += 3; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
311 for (int reg = Z80_C; reg <= Z80_IYH; reg++) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
312 *(curpos++) = context->regs[reg++]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
313 *curpos = context->regs[reg]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
314 curpos += 3; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
315 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
316 write_le_16(curpos, context->pc); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
317 curpos += 4; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
318 write_le_16(curpos, context->sp); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
319 curpos += 4; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
320 f = context->alt_flags[ZF_S]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
321 f <<= 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
322 f |= context->alt_flags[ZF_Z] ; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
323 f <<= 2; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
324 f |= context->alt_flags[ZF_H]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
325 f <<= 2; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
326 f |= context->alt_flags[ZF_PV]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
327 f <<= 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
328 f |= context->alt_flags[ZF_N]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
329 f <<= 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
330 f |= context->alt_flags[ZF_C]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
331 *(curpos++) = f; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
332 *curpos = context->alt_regs[Z80_A]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
333 curpos += 3; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
334 for (int reg = Z80_C; reg <= Z80_H; reg++) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
335 *(curpos++) = context->alt_regs[reg++]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
336 *curpos = context->alt_regs[reg]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
337 curpos += 3; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
338 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
339 *curpos = context->regs[Z80_I]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
340 curpos += 2; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
341 *curpos = context->iff1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
342 curpos += 2; |
668
5439ae7946ca
Made the Z80 core more contained by refactoring some code in blastem.c into z80_to_x86.c
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
343 *(curpos++) = !context->reset; |
5439ae7946ca
Made the Z80 core more contained by refactoring some code in blastem.c into z80_to_x86.c
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
344 *curpos = context->busreq; |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
345 curpos += 3; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
346 uint32_t bank = context->bank_reg << 15; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
347 write_le_32(curpos, bank); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
348 fseek(gstfile, GST_Z80_REGS, SEEK_SET); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
349 if (fwrite(regdata, 1, sizeof(regdata), gstfile) != sizeof(regdata)) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
350 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
351 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
352 fseek(gstfile, GST_Z80_RAM, SEEK_SET); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
353 if(fwrite(context->mem_pointers[0], 1, 8*1024, gstfile) != (8*1024)) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
354 fputs("Failed to write Z80 RAM to savestate\n", stderr); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
355 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
356 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
357 return 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
358 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
359 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
360 uint8_t ym_load_gst(ym2612_context * context, FILE * gstfile) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
361 { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
362 uint8_t regdata[GST_YM_SIZE]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
363 fseek(gstfile, GST_YM_OFFSET, SEEK_SET); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
364 if (fread(regdata, 1, sizeof(regdata), gstfile) != sizeof(regdata)) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
365 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
366 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
367 for (int i = 0; i < sizeof(regdata); i++) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
368 if (i & 0x100) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
369 ym_address_write_part2(context, i & 0xFF); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
370 } else { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
371 ym_address_write_part1(context, i); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
372 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
373 ym_data_write(context, regdata[i]); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
374 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
375 return 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
376 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
377 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
378 uint8_t ym_save_gst(ym2612_context * context, FILE * gstfile) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
379 { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
380 uint8_t regdata[GST_YM_SIZE]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
381 for (int i = 0; i < sizeof(regdata); i++) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
382 if (i & 0x100) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
383 int reg = (i & 0xFF); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
384 if (reg >= YM_PART2_START && reg < YM_REG_END) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
385 regdata[i] = context->part2_regs[reg-YM_PART2_START]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
386 } else { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
387 regdata[i] = 0xFF; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
388 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
389 } else { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
390 if (i >= YM_PART1_START && i < YM_REG_END) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
391 regdata[i] = context->part1_regs[i-YM_PART1_START]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
392 } else { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
393 regdata[i] = 0xFF; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
394 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
395 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
396 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
397 fseek(gstfile, GST_YM_OFFSET, SEEK_SET); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
398 if (fwrite(regdata, 1, sizeof(regdata), gstfile) != sizeof(regdata)) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
399 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
400 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
401 return 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
402 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
403 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
404 uint32_t load_gst(genesis_context * gen, char * fname) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
405 { |
962
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
406 char buffer[4096]; |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
407 FILE * gstfile = fopen(fname, "rb"); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
408 if (!gstfile) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
409 fprintf(stderr, "Could not open file %s for reading\n", fname); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
410 goto error; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
411 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
412 char ident[5]; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
413 if (fread(ident, 1, sizeof(ident), gstfile) != sizeof(ident)) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
414 fprintf(stderr, "Could not read ident code from %s\n", fname); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
415 goto error_close; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
416 } |
708
61faa298af07
Small horizontal interrupt fixes
Michael Pavone <pavone@retrodev.com>
parents:
668
diff
changeset
|
417 if (memcmp(ident, "GST\x40\xE0", 3) != 0) { |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
418 fprintf(stderr, "%s doesn't appear to be a GST savestate. The ident code is %c%c%c\\x%X\\x%X instead of GST\\x40\\xE0.\n", fname, ident[0], ident[1], ident[2], ident[3], ident[4]); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
419 goto error_close; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
420 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
421 uint32_t pc = m68k_load_gst(gen->m68k, gstfile); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
422 if (!pc) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
423 goto error_close; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
424 } |
962
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
425 |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
426 if (!vdp_load_gst(gen->vdp, gstfile)) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
427 goto error_close; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
428 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
429 if (!ym_load_gst(gen->ym, gstfile)) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
430 goto error_close; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
431 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
432 if (!z80_load_gst(gen->z80, gstfile)) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
433 goto error_close; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
434 } |
1111
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
435 gen->io.ports[0].control = 0x40; |
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
436 gen->io.ports[1].control = 0x40; |
962
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
437 |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
438 fseek(gstfile, GST_68K_RAM, SEEK_SET); |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
439 for (int i = 0; i < (32*1024);) { |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
440 if (fread(buffer, 1, sizeof(buffer), gstfile) != sizeof(buffer)) { |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
441 fputs("Failed to read 68K RAM from savestate\n", stderr); |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
442 return 0; |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
443 } |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
444 for(char *curpos = buffer; curpos < (buffer + sizeof(buffer)); curpos += sizeof(uint16_t)) { |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
445 uint16_t word = read_be_16(curpos); |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
446 if (word != gen->work_ram[i]) { |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
447 gen->work_ram[i] = word; |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
448 m68k_handle_code_write(0xFF0000 | (i << 1), gen->m68k); |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
449 } |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
450 i++; |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
451 } |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
452 } |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
453 fclose(gstfile); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
454 return pc; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
455 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
456 error_close: |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
457 fclose(gstfile); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
458 error: |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
459 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
460 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
461 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
462 uint8_t save_gst(genesis_context * gen, char *fname, uint32_t m68k_pc) |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
463 { |
962
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
464 char buffer[4096]; |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
465 FILE * gstfile = fopen(fname, "wb"); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
466 if (!gstfile) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
467 fprintf(stderr, "Could not open %s for writing\n", fname); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
468 goto error; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
469 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
470 if (fwrite("GST\x40\xE0", 1, 5, gstfile) != 5) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
471 fputs("Error writing signature to savestate\n", stderr); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
472 goto error_close; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
473 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
474 if (!m68k_save_gst(gen->m68k, m68k_pc, gstfile)) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
475 goto error_close; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
476 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
477 if (!z80_save_gst(gen->z80, gstfile)) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
478 goto error_close; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
479 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
480 if (!vdp_save_gst(gen->vdp, gstfile)) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
481 goto error_close; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
482 } |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
483 if (!ym_save_gst(gen->ym, gstfile)) { |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
484 goto error_close; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
485 } |
962
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
486 fseek(gstfile, GST_68K_RAM, SEEK_SET); |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
487 for (int i = 0; i < (32*1024);) { |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
488 for(char *curpos = buffer; curpos < (buffer + sizeof(buffer)); curpos += sizeof(uint16_t)) { |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
489 write_be_16(curpos, gen->work_ram[i++]); |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
490 } |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
491 if (fwrite(buffer, 1, sizeof(buffer), gstfile) != sizeof(buffer)) { |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
492 fputs("Failed to write 68K RAM to savestate\n", stderr); |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
493 return 0; |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
494 } |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
961
diff
changeset
|
495 } |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
496 return 1; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
497 |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
498 error_close: |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
499 fclose(gstfile); |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
500 error: |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
501 return 0; |
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
502 } |