FDS / UNIF / NSF work now

This commit is contained in:
dborth 2009-07-20 08:05:44 +00:00
parent 0f16f3b191
commit 6f609f6943
4 changed files with 52 additions and 33 deletions

View File

@ -761,9 +761,9 @@ int FDSLoad(const char *name, FCEUFILE *fp)
FILE *zp; FILE *zp;
int x; int x;
char *fn; char *fn;
#ifndef GEKKO
FCEU_fseek(fp,0,SEEK_SET); FCEU_fseek(fp,0,SEEK_SET);
#endif
if(!SubLoad(fp)) if(!SubLoad(fp))
return(0); return(0);

View File

@ -163,8 +163,9 @@ static INLINE void BANKSET(uint32 A, uint32 bank)
int NSFLoad(FCEUFILE *fp) int NSFLoad(FCEUFILE *fp)
{ {
int x; int x;
#ifndef GEKKO
FCEU_fseek(fp,0,SEEK_SET); FCEU_fseek(fp,0,SEEK_SET);
#endif
FCEU_fread(&NSFHeader,1,0x80,fp); FCEU_fread(&NSFHeader,1,0x80,fp);
if(memcmp(NSFHeader.ID,"NESM\x1a",5)) if(memcmp(NSFHeader.ID,"NESM\x1a",5))
return 0; return 0;

View File

@ -557,7 +557,9 @@ static void UNIFGI(GI h)
int UNIFLoad(const char *name, FCEUFILE *fp) int UNIFLoad(const char *name, FCEUFILE *fp)
{ {
#ifndef GEKKO
FCEU_fseek(fp,0,SEEK_SET); FCEU_fseek(fp,0,SEEK_SET);
#endif
FCEU_fread(&unhead,1,4,fp); FCEU_fread(&unhead,1,4,fp);
if(memcmp(&unhead,"UNIF",4)) if(memcmp(&unhead,"UNIF",4))
return 0; return 0;

View File

@ -55,22 +55,35 @@ int GCMemROM(int method, int size)
FCEUI_SetSoundVolume(100); // 0-100 FCEUI_SetSoundVolume(100); // 0-100
FCEUI_SetLowPass(0); FCEUI_SetLowPass(0);
memorystream * fceumem = new memorystream((char *) nesrom, size);
FCEUFILE * fceufp = new FCEUFILE(); FCEUFILE * fceufp = new FCEUFILE();
fceufp->size = size; fceufp->size = size;
fceufp->stream = fceumem;
fceufp->filename = romFilename; fceufp->filename = romFilename;
memorystream * fceumem;
romLoaded = false; romLoaded = false;
if (iNESLoad(romFilename, fceufp, 1)) // for some reason FCEU_fseek(fp,0,SEEK_SET); fails, so we will do this
romLoaded = true; fceumem = new memorystream((char *) nesrom, size);
else if (UNIFLoad(romFilename, fceufp)) fceufp->stream = fceumem;
romLoaded = true; romLoaded = iNESLoad(romFilename, fceufp, 1);
else if (NSFLoad(fceufp))
romLoaded = true; if(!romLoaded)
else {
delete fceumem;
fceumem = new memorystream((char *) nesrom, size);
fceufp->stream = fceumem;
romLoaded = UNIFLoad(romFilename, fceufp);
}
if(!romLoaded)
{
delete fceumem;
fceumem = new memorystream((char *) nesrom, size);
fceufp->stream = fceumem;
romLoaded = NSFLoad(fceufp);
}
if(!romLoaded)
{ {
// read FDS BIOS into FDSBIOS - should be 8192 bytes // read FDS BIOS into FDSBIOS - should be 8192 bytes
if (FDSBIOS[1] == 0) if (FDSBIOS[1] == 0)
@ -101,8 +114,11 @@ int GCMemROM(int method, int size)
if (FDSBIOS[1] != 0) if (FDSBIOS[1] != 0)
{ {
// load game // load game
if (FDSLoad(romFilename, fceufp)) delete fceumem;
romLoaded = true; fceumem = new memorystream((char *) nesrom, size);
fceufp->stream = fceumem;
romLoaded = FDSLoad(romFilename, fceufp);
} }
} }