Issue #264 fix (mapper 256 support)

This commit is contained in:
Alexey 'Cluster' Avdyukhin 2020-12-20 19:40:36 +03:00
parent 33d7d517db
commit 395af9d283
1 changed files with 12 additions and 3 deletions

View File

@ -1038,14 +1038,23 @@ static int iNES_Init(int num) {
default: CHRRAMSize = 8 * 1024; break;
}
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
{
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 < 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);
UNIFchrrama = VROM;
if(CHRRAMSize == 0)