mirror of
https://github.com/dborth/fceugx.git
synced 2024-11-01 06:55:05 +01:00
fix for file loading errors
This commit is contained in:
parent
0e901eca08
commit
a2ca3ac04a
@ -99,7 +99,7 @@ FCEUGI::~FCEUGI()
|
||||
if(archiveFilename) delete archiveFilename;
|
||||
}
|
||||
|
||||
static void CloseGame(void)
|
||||
static void FCEU_CloseGame(void)
|
||||
{
|
||||
if(GameInfo)
|
||||
{
|
||||
@ -360,7 +360,7 @@ static DECLFR(ARAMH)
|
||||
|
||||
void ResetGameLoaded(void)
|
||||
{
|
||||
if(GameInfo) CloseGame();
|
||||
if(GameInfo) FCEU_CloseGame();
|
||||
EmulationPaused = 0; //mbg 5/8/08 - loading games while paused was bad news. maybe this fixes it
|
||||
GameStateRestore=0;
|
||||
PPU_hook=0;
|
||||
@ -421,7 +421,7 @@ FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode)
|
||||
for (AutosaveIndex=0; AutosaveIndex<AutosaveQty; ++AutosaveIndex)
|
||||
AutosaveStatus[AutosaveIndex] = 0;
|
||||
|
||||
CloseGame();
|
||||
FCEU_CloseGame();
|
||||
GameInfo = new FCEUGI();
|
||||
memset(GameInfo, 0, sizeof(FCEUGI));
|
||||
|
||||
@ -714,7 +714,7 @@ void FCEUI_CloseGame(void)
|
||||
if(!FCEU_IsValidUI(FCEUI_CLOSEGAME))
|
||||
return;
|
||||
|
||||
CloseGame();
|
||||
FCEU_CloseGame();
|
||||
}
|
||||
|
||||
void ResetNES(void)
|
||||
|
@ -776,9 +776,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);
|
||||
|
||||
|
@ -424,8 +424,10 @@ int FCEU_fseek(FCEUFILE *fp, long offset, int whence)
|
||||
//else
|
||||
// return fseek((FILE *)fp->fp,offset,whence);
|
||||
|
||||
fp->stream->seekg(offset,(std::ios_base::seekdir)whence);
|
||||
fp->stream->seekp(offset,(std::ios_base::seekdir)whence);
|
||||
if(fp->mode == FCEUFILE::READ || fp->mode == FCEUFILE::READWRITE)
|
||||
fp->stream->seekg(offset,(std::ios_base::seekdir)whence);
|
||||
if(fp->mode == FCEUFILE::WRITE || fp->mode == FCEUFILE::READWRITE)
|
||||
fp->stream->seekp(offset,(std::ios_base::seekdir)whence);
|
||||
|
||||
return FCEU_ftell(fp);
|
||||
}
|
||||
|
@ -167,9 +167,8 @@ static INLINE void BANKSET(uint32 A, uint32 bank)
|
||||
int NSFLoad(const char *name, 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;
|
||||
|
@ -117,6 +117,10 @@ typedef uint32_t uint32;
|
||||
#define PSS ":"
|
||||
#define PS ':'
|
||||
|
||||
#else
|
||||
|
||||
#error PSS_STYLE undefined or invalid; see "types.h" for possible values, and add as compile-time option.
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -556,9 +556,7 @@ 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;
|
||||
|
@ -184,11 +184,7 @@ private:
|
||||
if(!myBuf && !usevec)
|
||||
throw new std::runtime_error("memory_streambuf is not expandable");
|
||||
|
||||
size_t newcapacity;
|
||||
if(upto == 0)
|
||||
newcapacity = capacity + capacity/2 + 2;
|
||||
else
|
||||
newcapacity = std::max(upto,capacity);
|
||||
size_t newcapacity = std::max(upto,capacity);
|
||||
|
||||
if(newcapacity == capacity) return;
|
||||
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "file.h"
|
||||
|
||||
#include "fceugx.h"
|
||||
#include "gcaudio.h"
|
||||
#include "fceusupport.h"
|
||||
@ -61,28 +63,19 @@ int GCMemROM(int size)
|
||||
FCEUFILE * fceufp = new FCEUFILE();
|
||||
fceufp->size = size;
|
||||
fceufp->filename = romFilename;
|
||||
memorystream * fceumem;
|
||||
|
||||
romLoaded = false;
|
||||
|
||||
// for some reason FCEU_fseek(fp,0,SEEK_SET); fails, so we will do this
|
||||
fceumem = new memorystream((char *) nesrom, size);
|
||||
fceufp->mode = FCEUFILE::READ; // read only
|
||||
memorystream * 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(romFilename, fceufp);
|
||||
}
|
||||
|
||||
@ -118,11 +111,6 @@ int GCMemROM(int size)
|
||||
}
|
||||
if (FDSBIOS[1] != 0)
|
||||
{
|
||||
// load game
|
||||
delete fceumem;
|
||||
fceumem = new memorystream((char *) nesrom, size);
|
||||
fceufp->stream = fceumem;
|
||||
|
||||
romLoaded = FDSLoad(romFilename, fceufp);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user