summaryrefslogtreecommitdiff
path: root/vdp.c
diff options
context:
space:
mode:
authorMike Pavone <pavone@retrodev.com>2012-12-18 19:51:33 -0800
committerMike Pavone <pavone@retrodev.com>2012-12-18 19:51:33 -0800
commite88632e2aee3bb60d5ddf197d5b0fd1c24a0c059 (patch)
treea628cd270ae67237ce312312b018c082100bcdde /vdp.c
parent23f50516176c33b4faedc9486031d32320a46217 (diff)
Fix CRAM and possibly VSRAM writes
Diffstat (limited to 'vdp.c')
-rw-r--r--vdp.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/vdp.c b/vdp.c
index edb3332..daa4f54 100644
--- a/vdp.c
+++ b/vdp.c
@@ -203,12 +203,12 @@ void external_slot(vdp_context * context)
break;
case CRAM_WRITE:
printf("CRAM Write: %X to %X\n", start->value, context->address);
- context->cram[context->address & (CRAM_SIZE-1)] = start->value;
+ context->cram[(context->address/2) & (CRAM_SIZE-1)] = start->value;
break;
case VSRAM_WRITE:
- if ((context->address & 63) < VSRAM_SIZE) {
+ if (((context->address/2) & 63) < VSRAM_SIZE) {
printf("VSRAM Write: %X to %X\n", start->value, context->address);
- context->vsram[context->address & 63] = start->value;
+ context->vsram[(context->address/2) & 63] = start->value;
}
break;
}
@@ -994,3 +994,22 @@ void vdp_load_savestate(vdp_context * context, FILE * state_file)
fread(context->vdpmem, 1, VRAM_SIZE, state_file);
}
+void vdp_save_state(vdp_context * context, FILE * outfile)
+{
+ uint8_t tmp_buf[CRAM_SIZE*2];
+ fseek(outfile, GST_VDP_REGS, SEEK_SET);
+ fwrite(context->regs, 1, VDP_REGS, outfile);
+ for (int i = 0; i < CRAM_SIZE; i++) {
+ tmp_buf[i*2] = context->cram[i];
+ tmp_buf[i*2+1] = context->cram[i] >> 8;
+ }
+ fwrite(tmp_buf, 1, sizeof(tmp_buf), outfile);
+ for (int i = 0; i < VSRAM_SIZE; i++) {
+ tmp_buf[i*2] = context->vsram[i];
+ tmp_buf[i*2+1] = context->vsram[i] >> 8;
+ }
+ fwrite(tmp_buf, 2, VSRAM_SIZE, outfile);
+ fseek(outfile, GST_VDP_MEM, SEEK_SET);
+ fwrite(context->vdpmem, 1, VRAM_SIZE, outfile);
+}
+