UNIF: Fix potential crash when accessing non-existing rom banks

- As stated, prevent a potential crash on some certain roms using split rom banks. This is done by counting the number of prg/chr banks loaded and using this as limit count during mapper bank switching.
- Update related boards.
This commit is contained in:
retro-wertz
2019-06-28 19:25:35 +08:00
parent 83b2f99527
commit 634eb688c1
11 changed files with 91 additions and 38 deletions

View File

@@ -20,6 +20,7 @@
#include "mapinc.h"
static uint8 chip;
static uint8 bank, base, lock, mirr, mode;
static SFORMAT StateRegs[] =
{
@@ -34,8 +35,10 @@ static SFORMAT StateRegs[] =
static void Sync(void) {
setchr8(0);
if (PRGptr[1]) {
setprg16r(base >> 3, 0x8000, bank);
setprg16r(base >> 3, 0xC000, (mode ? bank : 7));
chip = base >> 3;
if (chip > PRGchip_max) chip &= PRGchip_max;
setprg16r(chip, 0x8000, bank);
setprg16r(chip, 0xC000, (mode ? bank : 7));
} else {
setprg16(0x8000, base | bank);
setprg16(0xC000, base | (mode ? bank : 7));