uint32 *dest;
int y,x;
- dest=(uint32 *)(XBuf+272*12+164);
- for(y=24;y;y--,dest+=(272-72)>>2)
+ dest=(uint32 *)(XBuf+320*12+164);
+ for(y=24;y;y--,dest+=(320-72)>>2)
{
for(x=72>>2;x;x--,dest++)
*dest=0x80808080;
}
- dest=(uint32 *)(XBuf+272*(12+4)+164+6 );
- for(y=16;y;y--,dest+=(272>>2)-16)
+ dest=(uint32 *)(XBuf+320*(12+4)+164+6 );
+ for(y=16;y;y--,dest+=(320>>2)-16)
for(x=8;x;x--)
{
*dest=0x81818181;
dest+=2;
}
- dest=(uint32 *)(XBuf+272*(12+4)+164+6 );
+ dest=(uint32 *)(XBuf+320*(12+4)+164+6 );
for(x=0;x<8;x++,dest+=2)
{
- uint32 *da=dest+(272>>2);
+ uint32 *da=dest+(320>>2);
if(!((vsdip>>x)&1))
- da+=(272>>2)*10;
+ da+=(320>>2)*10;
- for(y=4;y;y--,da+=272>>2)
+ for(y=4;y;y--,da+=320>>2)
*da=0x80808080;
}
uint8 *XBaf;
int x,y,z;
- XBaf=XBuf+4+(FSettings.LastSLine-44)*272;
+ XBaf=XBuf+4+(FSettings.LastSLine-44)*320;
if(XBaf>=XBuf)
for(z=1;z<11;z++)
{
for(y=0;y<13;y++)
for(x=0;x<21;x++)
- XBaf[y*272+x+z*21+z]=sstat[y*21+x+(z-1)*21*12];
+ XBaf[y*320+x+z*21+z]=sstat[y*21+x+(z-1)*21*12];
} else {
for(y=0;y<13;y++)
for(x=0;x<21;x++)
if(sstat[y*21+x+(z-1)*21*12]!=0x83)
- XBaf[y*272+x+z*21+z]=sstat[y*21+x+(z-1)*21*12];
+ XBaf[y*320+x+z*21+z]=sstat[y*21+x+(z-1)*21*12];
}
if(CurrentState==z%10)
{
XBaf[x+z*21+z*1]=132;
for(x=1;x<12;x++)
{
- XBaf[272*x+z*21+z*1]=
- XBaf[272*x+z*21+z*1+20]=132;
+ XBaf[320*x+z*21+z*1]=
+ XBaf[320*x+z*21+z*1+20]=132;
}
for(x=0;x<21;x++)
XBaf[3264+x+z*21+z*1]=132;
if(controlselect==1)
{
- DrawTextTrans(XBuf+128-12+180*272, 272, (uint8 *)"Hue", 0x85);
+ DrawTextTrans(XBuf+128-12+180*320, 320, (uint8 *)"Hue", 0x85);
which=ntschue<<1;
}
else if(controlselect==2)
{
- DrawTextTrans(XBuf+128-16+180*272, 272, (uint8 *)"Tint", 0x85);
+ DrawTextTrans(XBuf+128-16+180*320, 320, (uint8 *)"Tint", 0x85);
which=ntsctint<<1;
}
- XBaf=XBuf+200*272;
+ XBaf=XBuf+200*320;
for(x=0;x<which;x+=2)
{
for(x2=6;x2>=-6;x2--)
{
- XBaf[x-272*x2]=0x85;
+ XBaf[x-320*x2]=0x85;
}
}
for(;x<256;x+=2)
{
for(x2=2;x2>=-2;x2--)
- XBaf[x-272*x2]=0x85;
+ XBaf[x-320*x2]=0x85;
}
}
#include "svga.h"
#include "input.h"
+#include "state.h"
#include "movie.h"
#include "dprintf.h"
extern INPUTCFC *FCEU_InitSpaceShadow(void);
extern INPUTCFC *FCEU_InitFKB(void);
static uint8 joy_readbit[2];
-static uint16 joy[4]={0,0,0,0};
+static uint8 joy[4]={0,0,0,0};
+static uint8 LastStrobe;
extern int coinon;
if(JPorts[1]->Write)
JPorts[1]->Write(V&1);
- if((PSG[0x16]&1) && (!(V&1)))
+ if((LastStrobe&1) && (!(V&1)))
{
/* This strobe code is just for convenience. If it were
with the code in input / *.c, it would more accurately represent
if(FCExp->Strobe)
FCExp->Strobe();
}
- PSG[0x16]=V;
+ LastStrobe=V&1;
}
static void FP_FASTAPASS(1) StrobeGP(int w)
{
memset(joy_readbit,0,sizeof(joy_readbit));
memset(joy,0,sizeof(joy));
+ LastStrobe=0;
if(FCEUGameInfo.type==GIT_VSUNI)
{
InputDataPtrFC=ptr;
SetInputStuffFC();
}
+
+// quick paste
+#define FCEUNPCMD_RESET 0x01
+#define FCEUNPCMD_POWER 0x02
+
+#define FCEUNPCMD_VSUNICOIN 0x07
+#define FCEUNPCMD_VSUNIDIP0 0x08
+#define FCEUNPCMD_FDSINSERT 0x18
+#define FCEUNPCMD_FDSSELECT 0x1A
+
+
+void FCEU_DoSimpleCommand(int cmd)
+{
+ switch(cmd)
+ {
+// case FCEUNPCMD_FDSINSERT: FCEU_FDSInsert();break;
+// case FCEUNPCMD_FDSSELECT: FCEU_FDSSelect();break;
+// case FCEUNPCMD_FDSEJECT: FCEU_FDSEject();break;
+// case FCEUNPCMD_VSUNICOIN: FCEU_VSUniCoin(); break;
+// case FCEUNPCMD_VSUNIDIP0 ... (FCEUNPCMD_VSUNIDIP0 + 7): FCEU_VSUniToggleDIP(cmd - FCEUNPCMD_VSUNIDIP0);break;
+ case FCEUNPCMD_POWER: PowerNES();break;
+ case FCEUNPCMD_RESET: ResetNES();break;
+ default: printf("FCEU_DoSimpleCommand: can't handle cmd %i\n", cmd); break;
+ }
+}
+
+
+SFORMAT FCEUCTRL_STATEINFO[]={
+ { joy_readbit, 2, "JYRB"},
+ { joy, 4, "JOYS"},
+ { &LastStrobe, 1, "LSTS"},
+ { 0 }
+};
+
+
static int SFEXINDEX;
static int stateversion;
-#define RLSB 0x80000000
+extern SFORMAT FCEUPPU_STATEINFO[]; // 3
+extern SFORMAT FCEUCTRL_STATEINFO[]; // 4
-#define SFCPUELEMENTS 7
-
-SFORMAT SFCPU[SFCPUELEMENTS]={
+SFORMAT SFCPU[]={ // 1
{ &X.PC, 2|RLSB, "PC\0"},
{ &X.A, 1, "A\0\0"},
{ &X.P, 1, "P\0\0"},
{ &X.X, 1, "X\0\0"},
{ &X.Y, 1, "Y\0\0"},
{ &X.S, 1, "S\0\0"},
- { RAM, 0x800, "RAM"}
+ { RAM, 0x800, "RAM"},
+ { 0, }
};
-#define SFCPUCELEMENTS 6
-SFORMAT SFCPUC[SFCPUCELEMENTS]={
+SFORMAT SFCPUC[]={ // 2
{ &X.jammed, 1, "JAMM"},
{ &X.IRQlow, 1, "IRQL"},
{ &X.tcount, 4|RLSB, "ICoa"},
{ &X.count, 4|RLSB, "ICou"},
{ ×tamp, 4|RLSB, "TIME"},
- { ×tampbase, 8|RLSB, "TMEB"}
+ { ×tampbase, 8|RLSB, "TMEB"},
+ // from 0.98.15
+ { ×tampbase, sizeof(timestampbase) | RLSB, "TSBS"}, // size seems to match?
+ { &X.mooPI, 1, "MooP"}, // alternative to the "quick and dirty hack"
+ // TODO: IQLB?
+ { 0, }
};
-static uint16 TempAddrT,RefreshAddrT;
-
-#define SFPPUELEMENTS 10
-SFORMAT SFPPU[SFPPUELEMENTS]={
- { NTARAM, 0x800, "NTAR"},
- { PALRAM, 0x20, "PRAM"},
- { SPRAM, 0x100, "SPRA"},
- { PPU, 0x4, "PPUR"},
- { &XOffset, 1, "XOFF"},
- { &vtoggle, 1, "VTOG"},
- { &RefreshAddrT, 2|RLSB, "RADD"},
- { &TempAddrT, 2|RLSB, "TADD"},
- { &VRAMBuffer, 1, "VBUF"},
- { &PPUGenLatch, 1, "PGEN"},
-};
+extern uint16 TempAddrT,RefreshAddrT;
-// Is this chunk necessary? I'll fix it later.
-//#define SFCTLRELEMENTS 2
-//SFORMAT SFCTLR[SFCTLRELEMENTS]={
-// { &joy_readbit, 1, "J1RB"},
-// { &joy2_readbit, 1, "J2RB"}
-//};
-#define SFSNDELEMENTS 18
-SFORMAT SFSND[SFSNDELEMENTS]={
+SFORMAT SFSND[]={
{ &fhcnt, 4|RLSB,"FHCN"},
{ &fcnt, 1, "FCNT"},
{ PSG, 14, "PSG"},
{ DecCountTo1, 3,"DCT1"},
{ &PCMBitIndex, 1,"PBIN"},
{ &PCMAddressIndex, 4|RLSB, "PAIN"},
- { &PCMSizeIndex, 4|RLSB, "PSIN"}
+ { &PCMSizeIndex, 4|RLSB, "PSIN"},
+ { 0, }
};
-int WriteStateChunk(FILE *st, int type, SFORMAT *sf, int count)
+
+int WriteStateChunk(FILE *st, int type, SFORMAT *sf)
{
- int bsize;
+ int bsize, count;
int x;
+ count = x = 0;
+ while (sf[x++].v) count++;
+
fputc(type,st);
for(x=bsize=0;x<count;x++)
return (bsize+5);
}
-int ReadStateChunk(FILE *st, SFORMAT *sf, int count, int size)
+int ReadStateChunk(FILE *st, SFORMAT *sf, int size)
{
uint8 tmpyo[16];
- int bsize;
+ int bsize, count;
int x;
+ // recalculate count ourselves
+ count = x = 0;
+ while (sf[x++].v) count++;
+
for(x=bsize=0;x<count;x++)
bsize+=sf[x].s&(~RLSB);
if(stateversion>=53)
if(!memcmp(toa,sf[x].desc,4))
{
if(tsize!=(sf[x].s&(~RLSB)))
+ {
+ printf("ReadStateChunk: sect \"%c%c%c%c\" has wrong size\n", toa[0], toa[1], toa[2], toa[3]);
goto nkayo;
+ }
#ifndef LSB_FIRST
if(sf[x].s&RLSB)
{
goto bloo;
}
}
+ printf("ReadStateChunk: sect \"%c%c%c%c\" not handled\n", toa[0], toa[1], toa[2], toa[3]);
nkayo:
fseek(st,tsize,SEEK_CUR);
bloo:;
return 1;
}
-int ReadStateChunks(FILE *st)
+static int ReadStateChunks(FILE *st)
{
int t;
uint32 size;
t=fgetc(st);
if(t==EOF) break;
if(!read32(&size,st)) break;
+
+ // printf("ReadStateChunks: chunk %i\n", t);
switch(t)
{
- case 1:if(!ReadStateChunk(st,SFCPU,SFCPUELEMENTS,size)) ret=0;
+ case 1:if(!ReadStateChunk(st,SFCPU,size)) ret=0;
#ifdef ASM_6502
asmcpu_unpack();
#endif
break;
- case 2:if(!ReadStateChunk(st,SFCPUC,SFCPUCELEMENTS,size)) ret=0;
+ case 2:if(!ReadStateChunk(st,SFCPUC,size)) ret=0;
else
{
X.mooPI=X.P; // Quick and dirty hack.
}
break;
- case 3:if(!ReadStateChunk(st,SFPPU,SFPPUELEMENTS,size)) ret=0;break;
-// case 4:if(!ReadStateChunk(st,SFCTLR,SFCTLRELEMENTS,size)) ret=0;break;
- case 5:if(!ReadStateChunk(st,SFSND,SFSNDELEMENTS,size)) ret=0;break;
- case 0x10:if(!ReadStateChunk(st,SFMDATA,SFEXINDEX,size)) ret=0;break;
- default: if(fseek(st,size,SEEK_CUR)<0) goto endo;break;
+ case 3:if(!ReadStateChunk(st,FCEUPPU_STATEINFO,size)) ret=0;break;
+ case 4:if(!ReadStateChunk(st,FCEUCTRL_STATEINFO,size)) ret=0;break;
+ case 5:if(!ReadStateChunk(st,SFSND,size)) ret=0;break;
+ case 0x10:if(!ReadStateChunk(st,SFMDATA,size)) ret=0;break;
+ default:printf("ReadStateChunks: unknown chunk: %i\n", t);
+ if(fseek(st,size,SEEK_CUR)<0) goto endo;break;
}
}
endo:
#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);
+ totalsize=WriteStateChunk(st,1,SFCPU);
+ totalsize+=WriteStateChunk(st,2,SFCPUC);
+ totalsize+=WriteStateChunk(st,3,FCEUPPU_STATEINFO);
+ totalsize+=WriteStateChunk(st,4,FCEUCTRL_STATEINFO);
+ totalsize+=WriteStateChunk(st,5,SFSND);
+ totalsize+=WriteStateChunk(st,0x10,SFMDATA);
fseek(st,4,SEEK_SET);
write32(totalsize,st);
uint8 version;
nada=0;
+ printf("LoadStateOld\n");
+
StateBuffer=FCEU_malloc(59999);
if(StateBuffer==NULL)
return 0;