From 395af9d283baaf7eec808918a4d6b1c2299cae6e Mon Sep 17 00:00:00 2001 From: Alexey 'Cluster' Avdyukhin Date: Sun, 20 Dec 2020 19:40:36 +0300 Subject: [PATCH] Issue #264 fix (mapper 256 support) --- src/ines.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/ines.cpp b/src/ines.cpp index b6ef2473..9860b24c 100644 --- a/src/ines.cpp +++ b/src/ines.cpp @@ -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)