MCPcopy Create free account
hub / github.com/TASEmulators/fceux / LoadCHR

Function LoadCHR

src/unif.cpp:292–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290}
291
292static int LoadCHR(FCEUFILE *fp) {
293 int z, t;
294 z = uchead.ID[3] - '0';
295 if (z < 0 || z > 15)
296 return(0);
297 FCEU_printf(" CHR ROM %d size: %d", z, (int)uchead.info);
298 if (malloced[16 + z])
299 free(malloced[16 + z]);
300 t = FixRomSize(uchead.info, 8192);
301 if (!(malloced[16 + z] = (uint8*)FCEU_malloc(t)))
302 return(0);
303 mallocedsizes[16 + z] = t;
304 memset(malloced[16 + z] + uchead.info, 0xFF, t - uchead.info);
305 if (FCEU_fread(malloced[16 + z], 1, uchead.info, fp) != uchead.info) {
306 FCEU_printf("Read Error!\n");
307 return(0);
308 } else
309 FCEU_printf("\n");
310
311 SetupCartCHRMapping(z, malloced[16 + z], t, 0);
312 return(1);
313}
314
315#define BMCFLAG_FORCE4 0x01
316#define BMCFLAG_16KCHRR 0x02

Callers

nothing calls this directly

Calls 5

FCEU_printfFunction · 0.85
FixRomSizeFunction · 0.85
FCEU_mallocFunction · 0.85
FCEU_freadFunction · 0.85
SetupCartCHRMappingFunction · 0.85

Tested by

no test coverage detected