summaryrefslogtreecommitdiff
path: root/ym2612.c
diff options
context:
space:
mode:
authorMike Pavone <pavone@retrodev.com>2013-06-29 17:15:08 -0700
committerMike Pavone <pavone@retrodev.com>2013-06-29 17:15:08 -0700
commit48718d1f339e263fb52a35a7a5230d32491b78b8 (patch)
tree16eb423306ce41301c188ffa4ed8193b438e334b /ym2612.c
parent6183aae8b8ff8deb39d5e177896ef62bc72df7c0 (diff)
Add support for loading GST format savestates
Diffstat (limited to 'ym2612.c')
-rw-r--r--ym2612.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/ym2612.c b/ym2612.c
index c2952bd..facba3a 100644
--- a/ym2612.c
+++ b/ym2612.c
@@ -763,3 +763,24 @@ uint8_t ym_read_status(ym2612_context * context)
return context->status;
}
+#define GST_YM_OFFSET 0x1E4
+#define GST_YM_SIZE (0x3E4-GST_YM_OFFSET)
+
+uint8_t ym_load_gst(ym2612_context * context, FILE * gstfile)
+{
+ uint8_t regdata[GST_YM_SIZE];
+ fseek(gstfile, GST_YM_OFFSET, SEEK_SET);
+ if (fread(regdata, 1, sizeof(regdata), gstfile) != sizeof(regdata)) {
+ return 0;
+ }
+ for (int i = 0; i < sizeof(regdata); i++) {
+ if (i & 0x100) {
+ ym_address_write_part2(context, i & 0xFF);
+ } else {
+ ym_address_write_part1(context, i);
+ }
+ ym_data_write(context, regdata[i]);
+ }
+ return 1;
+}
+