diff --git a/src/boards/268.c b/src/boards/268.c index 02de195..be2895e 100644 --- a/src/boards/268.c +++ b/src/boards/268.c @@ -66,6 +66,14 @@ static void Mapper268_PRGWrap(uint32 A, uint8 V) { prgOffset &=ROM_size -1; if (EXPREGS[0] &0x80? !!(EXPREGS[0] &0x08): !!(DRegBuf[0] &0x80)) prgOffset |=ROM_size; break; + case 8: /* 2 MiB regular plus extra latch, CHR-RAM protection */ + prgMaskGNROM =EXPREGS[3] &0x10? (EXPREGS[1] &0x02? 0x03: 0x01): 0x00; + prgOffset =EXPREGS[3] &0x00E + |EXPREGS[0] <<4 &0x070 + |EXPREGS[1] <<3 &0x080 + |EXPREGS[6] <<8 &0x300 + |EXPREGS[6] <<6 &0xC00; + break; } prgOffset &=~(prgMaskMMC3 | prgMaskGNROM); setprg8(A, V &prgMaskMMC3 | prgOffset | A >>13 &prgMaskGNROM); @@ -79,7 +87,7 @@ static void Mapper268_CHRWrap(uint32 A, uint8 V) { chrMaskMMC3 =EXPREGS[3] &0x10? 0x00: EXPREGS[0] &0x80? 0x7F: 0xFF; chrMaskGNROM =EXPREGS[3] &0x10? 0x07: 0x00; - chrOffset =EXPREGS[0] <<4 &0x380 | EXPREGS[2] <<3 &0x078; + chrOffset =EXPREGS[0] <<9 &0xC00 | EXPREGS[0] <<4 &0x380 | EXPREGS[2] <<3 &0x078; chrOffset &=~(chrMaskMMC3 | chrMaskGNROM); setchr1r(CHRRAM && EXPREGS[4] &0x01 && (V &0xFE) ==(EXPREGS[4] &0xFE)? 0x10: 0x00, A, V &chrMaskMMC3 | chrOffset | A >>10 &chrMaskGNROM); @@ -108,21 +116,31 @@ static DECLFW(Mapper268_WriteReg) { if (index ==2) { if (EXPREGS[2] &0x80) V =V &0x0F | EXPREGS[2] &~0x0F; V &=~EXPREGS[2] >>3 &0xE |0xF1; - } - EXPREGS[index] =V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - Mapper268_MirrorWrap(A000B); + } + + if ((submapper &~1) == 8 && index == 1 && V &0x04 && V &0x08) { /* Latch clocking another latch */ + EXPREGS[6] = V; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); + Mapper268_MirrorWrap(A000B); + } + + if (index <= 5) { + EXPREGS[index] =V; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); + Mapper268_MirrorWrap(A000B); + } } } static void Mapper268_Reset(void) { - EXPREGS[0] =EXPREGS[1] =EXPREGS[2] =EXPREGS[3] =EXPREGS[4] =EXPREGS[5] =0; + EXPREGS[0] =EXPREGS[1] =EXPREGS[2] =EXPREGS[3] =EXPREGS[4] =EXPREGS[5] =EXPREGS[6] =0; MMC3RegReset(); } static void Mapper268_Power(void) { - EXPREGS[0] =EXPREGS[1] =EXPREGS[2] =EXPREGS[3] =EXPREGS[4] =EXPREGS[5] =0; + EXPREGS[0] =EXPREGS[1] =EXPREGS[2] =EXPREGS[3] =EXPREGS[4] =EXPREGS[5] =EXPREGS[6] =0; GenMMC3Power(); SetReadHandler(0x6000, 0x7FFF, Mapper268_ReadWRAM); if (submapper &1) { diff --git a/src/boards/596.c b/src/boards/596.c new file mode 100644 index 0000000..d62c447 --- /dev/null +++ b/src/boards/596.c @@ -0,0 +1,63 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2020 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + */ + +#include "mapinc.h" +#include "asic_mmc3.h" +#include "cartram.h" + +static uint8 reg; + +static void sync () { + int prgAND = reg &0x04? 0x1F: 0x0F; + int chrAND = 0x7F; + int prgOR = reg <<4; + int chrOR = reg <<7; + MMC3_syncWRAM(0); + MMC3_syncPRG(prgAND, prgOR &~prgAND); + MMC3_syncCHR(chrAND, chrOR &~chrAND); + MMC3_syncMirror(); +} + +static DECLFW (writeReg) { + if (~reg &0x08) { + reg = V; + sync(); + } +} + +static void reset () { + reg = 0; + MMC3_clear(); +} + +static void power () { + reg = 0; + MMC3_power(); +} + +void Mapper596_Init (CartInfo *info) { + MMC3_init(info, sync, MMC3_TYPE_AX5202P, NULL, NULL, NULL, writeReg); + WRAM_init(info, 8); + info->Power = power; + info->Reset = reset; + AddExState(®, 1, 0, "EXPR"); +} diff --git a/src/ines.c b/src/ines.c index ba9338c..f8ef459 100644 --- a/src/ines.c +++ b/src/ines.c @@ -1017,6 +1017,7 @@ INES_BOARD_BEGIN() INES_BOARD( "8-in-1 1991", 592, Mapper592_Init ) INES_BOARD( "Rinco FSG2", 594, Mapper594_Init ) INES_BOARD( "4MROM-512", 595, Mapper595_Init ) + INES_BOARD( "FC-49", 596, Mapper596_Init ) INES_BOARD_END() static uint32 iNES_get_mapper_id(void) diff --git a/src/ines.h b/src/ines.h index 1c48ffd..d9f9c62 100644 --- a/src/ines.h +++ b/src/ines.h @@ -486,6 +486,7 @@ void Mapper591_Init(CartInfo *); void Mapper592_Init(CartInfo *); void Mapper594_Init(CartInfo *); void Mapper595_Init(CartInfo *); +void Mapper596_Init(CartInfo *); void FFE_Init(CartInfo *);