X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=fceu.git;a=blobdiff_plain;f=state.c;h=5e4308d62670b5884a796aa215e2534d0bd8b4c9;hp=058b30c2f4cb80c9d60fc0de6f38738af95092ba;hb=92e249b10ad9e479eddb18974555366dba725ef3;hpb=5232c20c0fa2c80964fe1d3f597c239bcf93d6fc diff --git a/state.c b/state.c index 058b30c..5e4308d 100644 --- a/state.c +++ b/state.c @@ -24,6 +24,9 @@ #include #include #include +#ifdef GP2X +#include +#endif #include "types.h" #include "x6502.h" @@ -120,7 +123,7 @@ int WriteStateChunk(FILE *st, int type, SFORMAT *sf, int count) int x; fputc(type,st); - + for(x=bsize=0;x=0;z--) + for(z=(sf[x].s&(~RLSB))-1;z>=0;z--) *(uint8*)sf[x].v=fgetc(st); } else @@ -255,7 +258,11 @@ for(;;) if(!read32(&size,st)) break; switch(t) { - case 1:if(!ReadStateChunk(st,SFCPU,SFCPUELEMENTS,size)) ret=0;break; + case 1:if(!ReadStateChunk(st,SFCPU,SFCPUELEMENTS,size)) ret=0; +#ifdef ASM_6502 + asmcpu_unpack(); +#endif + break; case 2:if(!ReadStateChunk(st,SFCPUC,SFCPUCELEMENTS,size)) ret=0; else { @@ -299,17 +306,23 @@ void SaveState(void) header[3]=VERSION_NUMERIC; fwrite(header,1,16,st); +#ifdef ASM_6502 + asmcpu_pack(); +#endif totalsize=WriteStateChunk(st,1,SFCPU,SFCPUELEMENTS); totalsize+=WriteStateChunk(st,2,SFCPUC,SFCPUCELEMENTS); totalsize+=WriteStateChunk(st,3,SFPPU,SFPPUELEMENTS); // totalsize+=WriteStateChunk(st,4,SFCTLR,SFCTLRELEMENTS); totalsize+=WriteStateChunk(st,5,SFSND,SFSNDELEMENTS); totalsize+=WriteStateChunk(st,0x10,SFMDATA,SFEXINDEX); - + fseek(st,4,SEEK_SET); write32(totalsize,st); SaveStateStatus[CurrentState]=1; fclose(st); +#ifdef GP2X + sync(); +#endif FCEU_DispMessage("State %d saved.",CurrentState); } else @@ -337,7 +350,7 @@ void LoadState(void) fread(&header,1,16,st); if(memcmp(header,"FCS",3)) { - fseek(st,0,SEEK_SET); + fseek(st,0,SEEK_SET); if(!LoadStateOld(st)) goto lerror; goto okload; @@ -379,7 +392,7 @@ void CheckStates(void) FILE *st=NULL; int ssel; - if(SaveStateStatus[0]==-1) + if(SaveStateStatus[0]==(char)-1) for(ssel=0;ssel<10;ssel++) { st=fopen(FCEU_MakeFName(FCEUMKF_STATE,ssel,0),"rb"); @@ -484,7 +497,7 @@ static int LoadStateOld(FILE *st) int32 nada; uint8 version; nada=0; - + StateBuffer=FCEU_malloc(59999); if(StateBuffer==NULL) return 0; @@ -523,7 +536,7 @@ static int LoadStateOld(FILE *st) afread(&nada,1,1); afread(&nada,1,1); afread(&nada,1,1); - + for(x=0;x<8;x++) areadupper8of16((int8 *)&CHRBankList[x]); afread(PRGBankList,4,1); @@ -549,7 +562,7 @@ static int LoadStateOld(FILE *st) aread16((int8 *)&scanline); aread16((int8 *)&RefreshAddr); afread(&VRAMBuffer,1,1); - + afread(&IRQa,1,1); aread32((int8 *)&IRQCount); aread32((int8 *)&IRQLatch); @@ -577,16 +590,16 @@ static int LoadStateOld(FILE *st) { nada=0; afread(&nada,1,1); - PPUCHRRAM|=(nada?1:0)<