comparison vdp.c @ 56:a28b1dfe1af2

Fix CRAM and possibly VSRAM writes
author Mike Pavone <pavone@retrodev.com>
date Tue, 18 Dec 2012 19:51:33 -0800
parents 3b79cbcf6846
children a6a19c45d358
comparison
equal deleted inserted replaced
55:8317f174d916 56:a28b1dfe1af2
201 return; 201 return;
202 } 202 }
203 break; 203 break;
204 case CRAM_WRITE: 204 case CRAM_WRITE:
205 printf("CRAM Write: %X to %X\n", start->value, context->address); 205 printf("CRAM Write: %X to %X\n", start->value, context->address);
206 context->cram[context->address & (CRAM_SIZE-1)] = start->value; 206 context->cram[(context->address/2) & (CRAM_SIZE-1)] = start->value;
207 break; 207 break;
208 case VSRAM_WRITE: 208 case VSRAM_WRITE:
209 if ((context->address & 63) < VSRAM_SIZE) { 209 if (((context->address/2) & 63) < VSRAM_SIZE) {
210 printf("VSRAM Write: %X to %X\n", start->value, context->address); 210 printf("VSRAM Write: %X to %X\n", start->value, context->address);
211 context->vsram[context->address & 63] = start->value; 211 context->vsram[(context->address/2) & 63] = start->value;
212 } 212 }
213 break; 213 break;
214 } 214 }
215 context->address += context->regs[REG_AUTOINC]; 215 context->address += context->regs[REG_AUTOINC];
216 fifo_entry * cur = start+1; 216 fifo_entry * cur = start+1;
992 } 992 }
993 fseek(state_file, GST_VDP_MEM, SEEK_SET); 993 fseek(state_file, GST_VDP_MEM, SEEK_SET);
994 fread(context->vdpmem, 1, VRAM_SIZE, state_file); 994 fread(context->vdpmem, 1, VRAM_SIZE, state_file);
995 } 995 }
996 996
997 void vdp_save_state(vdp_context * context, FILE * outfile)
998 {
999 uint8_t tmp_buf[CRAM_SIZE*2];
1000 fseek(outfile, GST_VDP_REGS, SEEK_SET);
1001 fwrite(context->regs, 1, VDP_REGS, outfile);
1002 for (int i = 0; i < CRAM_SIZE; i++) {
1003 tmp_buf[i*2] = context->cram[i];
1004 tmp_buf[i*2+1] = context->cram[i] >> 8;
1005 }
1006 fwrite(tmp_buf, 1, sizeof(tmp_buf), outfile);
1007 for (int i = 0; i < VSRAM_SIZE; i++) {
1008 tmp_buf[i*2] = context->vsram[i];
1009 tmp_buf[i*2+1] = context->vsram[i] >> 8;
1010 }
1011 fwrite(tmp_buf, 2, VSRAM_SIZE, outfile);
1012 fseek(outfile, GST_VDP_MEM, SEEK_SET);
1013 fwrite(context->vdpmem, 1, VRAM_SIZE, outfile);
1014 }
1015