From cfbe777f6183759d7a6ce4e83c9319826d9a8b5d Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Sat, 2 Apr 2022 22:03:41 +0200 Subject: [PATCH] Added mapper 467 --- src/boards/467.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + 3 files changed, 76 insertions(+) create mode 100644 src/boards/467.c diff --git a/src/boards/467.c b/src/boards/467.c new file mode 100644 index 0000000..3ec24d5 --- /dev/null +++ b/src/boards/467.c @@ -0,0 +1,74 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 NewRisingSun + * + * 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 "mmc3.h" + +static void Mapper467_PRGWrap(uint32 A, uint8 V) { + if (EXPREGS[0] &0x20) { + int prgAND =EXPREGS[0] &0x40? 0x0F: 0x03; + int prgOR =EXPREGS[0] <<1 &0x3C | 0x40; + setprg8(A, V &prgAND | prgOR &~prgAND); + } else + if (~A &0x2000) + setprg16(A, EXPREGS[0] &0x1F); +} + +static void Mapper467_CHRWrap(uint32 A, uint8 V) { + if (~A &0x0800) { + A =A &~0x400 | A <<1 &0x800; + if (EXPREGS[0] &0x40) + setchr2(A, V |0x100); + else + setchr2(A, V &~3 | A >>11 &3); + } +} + +static DECLFW(Mapper467_WriteExtra) { + EXPREGS[0] =V; + FixMMC3PRG(MMC3_cmd &0x3F); + FixMMC3CHR(MMC3_cmd &0x3F); + setmirror(EXPREGS[0] &0x80? MI_H: MI_V); +} + +static DECLFW(Mapper467_WriteMMC3) { + if (~A &1) V &=0x3F; + MMC3_CMDWrite(A, V); +} + +static void Mapper467_Reset(void) { + EXPREGS[0] =0; + MMC3RegReset(); +} + +static void Mapper467_Power(void) { + EXPREGS[0] =0; + GenMMC3Power(); + SetWriteHandler(0x8000, 0x8FFF, Mapper467_WriteMMC3); + SetWriteHandler(0x9000, 0x9FFF, Mapper467_WriteExtra); +} + +void Mapper467_Init(CartInfo *info) { + GenMMC3_Init(info, 256, 256, 0, 0); + cwrap = Mapper467_CHRWrap; + pwrap = Mapper467_PRGWrap; + info->Power = Mapper467_Power; + info->Reset = Mapper467_Reset; + AddExState(EXPREGS, 1, 0, "EXPR"); +} diff --git a/src/ines.c b/src/ines.c index 9ddcef0..a025647 100644 --- a/src/ines.c +++ b/src/ines.c @@ -817,6 +817,7 @@ INES_BOARD_BEGIN() INES_BOARD( "NC-7000M/NC-8000M", 444, Mapper444_Init ) INES_BOARD( "DS-9-27", 452, Mapper452_Init ) INES_BOARD( "K6C3001A", 456, Mapper456_Init ) + INES_BOARD( "47-2", 467, Mapper467_Init ) INES_BOARD( "SA-9602B", 513, SA9602B_Init ) INES_BOARD( "Brilliant Com Cocoma Pack", 516, Mapper516_Init ) INES_BOARD( "DANCE2000", 518, UNLD2000_Init ) diff --git a/src/ines.h b/src/ines.h index aefc891..92ad140 100644 --- a/src/ines.h +++ b/src/ines.h @@ -327,6 +327,7 @@ void Mapper443_Init(CartInfo *); void Mapper444_Init(CartInfo *); void Mapper452_Init(CartInfo *); void Mapper456_Init(CartInfo *); +void Mapper467_Init(CartInfo *); void Mapper516_Init(CartInfo *); void Mapper523_Init(CartInfo *); void Mapper533_Init(CartInfo *);