MCPcopy Create free account
hub / github.com/dborth/fceugx / LoadPatch

Function LoadPatch

source/patch.cpp:228–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228int LoadPatch(int size)
229{
230 int newsize = size;
231 int patchsize = 0;
232 int patchtype;
233 char patchpath[2][512];
234
235 AllocSaveBuffer ();
236
237 memset(patchpath, 0, sizeof(patchpath));
238 sprintf(patchpath[0], "%s%s.ips", browser.dir, romFilename);
239 sprintf(patchpath[1], "%s%s.ups", browser.dir, romFilename);
240
241 for(patchtype=0; patchtype<2; patchtype++)
242 {
243 patchsize = LoadFile(patchpath[patchtype], SILENT);
244
245 if(patchsize)
246 break;
247 }
248
249 if(patchsize > 0)
250 {
251 // create memory file
252 MFILE * mf = memfopen((char *)savebuffer, patchsize);
253
254 if(patchtype == 0)
255 patchApplyIPS(mf, &nesrom, &newsize);
256 else
257 patchApplyUPS(mf, &nesrom, &newsize);
258
259 memfclose(mf); // close memory file
260 }
261
262 FreeSaveBuffer ();
263 return newsize;
264}

Callers 1

BrowserLoadFileFunction · 0.85

Calls 7

AllocSaveBufferFunction · 0.85
LoadFileFunction · 0.85
memfopenFunction · 0.85
patchApplyIPSFunction · 0.85
patchApplyUPSFunction · 0.85
memfcloseFunction · 0.85
FreeSaveBufferFunction · 0.85

Tested by

no test coverage detected