Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/fceux.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeromus <zeromus@users.noreply.github.com>2022-08-28 11:32:23 +0300
committerzeromus <zeromus@users.noreply.github.com>2022-08-28 11:32:23 +0300
commit20d03d4434ca2a473dcb33e61ce6a3da4fddcc19 (patch)
tree7a8ce3b8dc2bf3a071f69054b225d2135f7f1b04
parent9d831d8b8b647f0e7a84cd0ebb4baea4ba22f596 (diff)
minimum framework to support loading ips files on top of already loaded roms
-rw-r--r--src/fceu.cpp2
-rw-r--r--src/file.cpp20
-rw-r--r--src/ines.cpp1
-rw-r--r--src/ines.h1
4 files changed, 7 insertions, 17 deletions
diff --git a/src/fceu.cpp b/src/fceu.cpp
index 83b8c223..28396c34 100644
--- a/src/fceu.cpp
+++ b/src/fceu.cpp
@@ -431,7 +431,7 @@ FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode, bool silen
// currently there's only one situation:
// the user clicked cancel form the open from archive dialog
int userCancel = 0;
- fp = FCEU_fopen(name, 0, "rb", 0, -1, romextensions, &userCancel);
+ fp = FCEU_fopen(name, LoadedRomFNamePatchToUse[0] ? LoadedRomFNamePatchToUse : nullptr, "rb", 0, -1, romextensions, &userCancel);
if (!fp)
{
diff --git a/src/file.cpp b/src/file.cpp
index c927be7b..90d024da 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -69,7 +69,7 @@ void ApplyIPS(FILE *ips, FCEUFILE* fp)
if(!ips) return;
- char* buf = (char*)FCEU_dmalloc(fp->size);
+ char* buf = (char*)FCEU_malloc(fp->size);
memcpy(buf,fp->EnsureMemorystream()->buf(),fp->size);
@@ -108,13 +108,7 @@ void ApplyIPS(FILE *ips, FCEUFILE* fp)
if((offset+size)>(uint32)fp->size)
{
// Probably a little slow.
- char *newbuf=(char *)realloc(buf,offset+size);
- if(!newbuf)
- {
- free(buf); buf=NULL;
- FCEU_printf(" Oops. IPS patch %d(type RLE) goes beyond end of file. Could not allocate memory.\n",count);
- goto end;
- }
+ char *newbuf=(char *)FCEU_realloc(buf,offset+size);
buf=newbuf;
memset(buf+fp->size,0,offset+size-fp->size);
fp->size=offset+size;
@@ -133,13 +127,7 @@ void ApplyIPS(FILE *ips, FCEUFILE* fp)
if((offset+size)>(uint32)fp->size)
{
// Probably a little slow.
- char *newbuf=(char *)realloc(buf,offset+size);
- if(!newbuf)
- {
- free(buf); buf=NULL;
- FCEU_printf(" Oops. IPS patch %d(type normal) goes beyond end of file. Could not allocate memory.\n",count);
- goto end;
- }
+ char *newbuf=(char *)FCEU_realloc(buf,offset+size);
buf=newbuf;
memset(buf+fp->size,0,offset+size-fp->size);
}
@@ -495,7 +483,7 @@ void FCEUI_SetDirOverride(int which, char *n)
va_list ap;
int ret;
- if(!(*strp=(char*)FCEU_dmalloc(2048))) //mbg merge 7/17/06 cast to char*
+ if(!(*strp=(char*)FCEU_malloc(2048))) //mbg merge 7/17/06 cast to char*
return(0);
va_start(ap,fmt);
ret=vsnprintf(*strp,2048,fmt,ap);
diff --git a/src/ines.cpp b/src/ines.cpp
index 6766a558..92fa0bdf 100644
--- a/src/ines.cpp
+++ b/src/ines.cpp
@@ -58,6 +58,7 @@ uint8 MirroringAs2bits = 0;
uint32 ROM_size = 0;
uint32 VROM_size = 0;
char LoadedRomFName[2048]; //mbg merge 7/17/06 added
+char LoadedRomFNamePatchToUse[2048];
static int CHRRAMSize = -1;
static int iNES_Init(int num);
diff --git a/src/ines.h b/src/ines.h
index 315e54f0..267ab963 100644
--- a/src/ines.h
+++ b/src/ines.h
@@ -47,6 +47,7 @@ extern uint8 **VPageR;
extern int iNesSave(void); //bbit Edited: line added
extern int iNesSaveAs(const char* name);
extern char LoadedRomFName[2048]; //bbit Edited: line added
+extern char LoadedRomFNamePatchToUse[2048];
extern char *iNesShortFName(void);
extern const TMasterRomInfo* MasterRomInfo;
extern TMasterRomInfoParams MasterRomInfoParams;