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

Function LoadCHR

source/fceultra/unif.cpp:296–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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