Minor refactoring, unreachable code removed
This commit is contained in:
parent
395af9d283
commit
ed4d1a7217
38
src/ines.cpp
38
src/ines.cpp
|
@ -906,9 +906,6 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) {
|
||||||
case 2:
|
case 2:
|
||||||
FCEU_PrintError("Unable to allocate CHR-RAM.");
|
FCEU_PrintError("Unable to allocate CHR-RAM.");
|
||||||
break;
|
break;
|
||||||
case 3:
|
|
||||||
FCEU_PrintError("CHR-RAM size < 1k is not supported.");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (ROM) free(ROM);
|
if (ROM) free(ROM);
|
||||||
if (VROM) free(VROM);
|
if (VROM) free(VROM);
|
||||||
|
@ -1023,7 +1020,8 @@ static int iNES_Init(int num) {
|
||||||
|
|
||||||
while (tmp->init) {
|
while (tmp->init) {
|
||||||
if (num == tmp->number) {
|
if (num == tmp->number) {
|
||||||
UNIFchrrama = 0; // need here for compatibility with UNIF mapper code
|
// is this code used by the UNIF loader in any way?
|
||||||
|
UNIFchrrama = NULL; // need here for compatibility with UNIF mapper code
|
||||||
if (!VROM_size) {
|
if (!VROM_size) {
|
||||||
if(!iNESCart.ines2)
|
if(!iNESCart.ines2)
|
||||||
{
|
{
|
||||||
|
@ -1038,37 +1036,25 @@ static int iNES_Init(int num) {
|
||||||
default: CHRRAMSize = 8 * 1024; break;
|
default: CHRRAMSize = 8 * 1024; break;
|
||||||
}
|
}
|
||||||
iNESCart.vram_size = CHRRAMSize;
|
iNESCart.vram_size = CHRRAMSize;
|
||||||
if (CHRRAMSize < 1024) return 3; // unsupported size, VPage only goes down to 1k banks, NES program can corrupt memory if used
|
|
||||||
if ((VROM = (uint8*)FCEU_dmalloc(CHRRAMSize)) == NULL) return 2;
|
|
||||||
FCEU_MemoryRand(VROM, CHRRAMSize);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CHRRAMSize = iNESCart.battery_vram_size + iNESCart.vram_size;
|
CHRRAMSize = iNESCart.battery_vram_size + iNESCart.vram_size;
|
||||||
if (CHRRAMSize > 0)
|
|
||||||
{
|
|
||||||
if ((VROM = (uint8*)FCEU_dmalloc(CHRRAMSize)) == NULL) return 2;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// mapper 256 (OneBus) has not CHR-RAM _and_ has not CHR-ROM region in iNES file
|
|
||||||
// so zero-sized CHR should be supported at least for this mapper
|
|
||||||
VROM = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (CHRRAMSize > 0)
|
||||||
UNIFchrrama = VROM;
|
|
||||||
if(CHRRAMSize == 0)
|
|
||||||
{
|
|
||||||
//probably a mistake.
|
|
||||||
//but (for chrram): "Use of $00 with no CHR ROM implies that the game is wired to map nametable memory in CHR space. The value $00 MUST NOT be used if a mapper isn't defined to allow this. "
|
|
||||||
//well, i'm not going to do that now. we'll save it for when it's needed
|
|
||||||
//"it's only mapper 218 and no other mappers"
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
// again. seems like this code never executed for UNIF files
|
||||||
|
// so why we need to set UNIFchrrama here?
|
||||||
|
if ((UNIFchrrama = VROM = (uint8*)FCEU_dmalloc(CHRRAMSize)) == NULL) return 2;
|
||||||
|
FCEU_MemoryRand(VROM, CHRRAMSize);
|
||||||
SetupCartCHRMapping(0, VROM, CHRRAMSize, 1);
|
SetupCartCHRMapping(0, VROM, CHRRAMSize, 1);
|
||||||
AddExState(VROM, CHRRAMSize, 0, "CHRR");
|
AddExState(VROM, CHRRAMSize, 0, "CHRR");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// mapper 256 (OneBus) has not CHR-RAM _and_ has not CHR-ROM region in iNES file
|
||||||
|
// so zero-sized CHR should be supported at least for this mapper
|
||||||
|
VROM = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (head.ROM_type & 8)
|
if (head.ROM_type & 8)
|
||||||
AddExState(ExtraNTARAM, 2048, 0, "EXNR");
|
AddExState(ExtraNTARAM, 2048, 0, "EXNR");
|
||||||
|
|
Loading…
Reference in New Issue