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;
int x;
char *fn;
#ifndef GEKKO
FCEU_fseek(fp,0,SEEK_SET);
#endif
if(!SubLoad(fp))
return(0);

View File

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

View File

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

View File

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