From 988be84742eeac6b82891759bb4edcd489cd185e Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Wed, 27 Jul 2022 11:07:25 +0200 Subject: [PATCH] Add mapper 441 --- src/boards/441.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + 3 files changed, 70 insertions(+) create mode 100644 src/boards/441.c diff --git a/src/boards/441.c b/src/boards/441.c new file mode 100644 index 0000000..a2ef809 --- /dev/null +++ b/src/boards/441.c @@ -0,0 +1,68 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 + * + * 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 + */ + +/* 850335C PCB */ + +#include "mapinc.h" +#include "mmc3.h" + +static void Mapper441_PRGWrap(uint32 A, uint8 V) { + int prgAND =EXPREGS[0] &0x08? 0x0F: 0x1F; + int prgOR =EXPREGS[0] <<4 &0x30; + if (EXPREGS[0] &0x04) { + if (~A &0x4000) { + setprg8(A, ~2 &V &prgAND | prgOR &~prgAND); + setprg8(A |0x4000, 2 |V &prgAND | prgOR &~prgAND); + } + } else + setprg8(A, V &prgAND | prgOR &~prgAND); +} + +static void Mapper441_CHRWrap(uint32 A, uint8 V) { + int chrAND =EXPREGS[0] &0x40? 0x7F: 0xFF; + int chrOR =EXPREGS[0] <<3 &0x180; + setchr1(A, V &chrAND | chrOR &~chrAND); +} + +static DECLFW(Mapper441_Write) { + if (~EXPREGS[0] &0x80) EXPREGS[0] =V; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); +} + +static void Mapper441_Reset(void) { + EXPREGS[0] =0; + MMC3RegReset(); +} + +static void Mapper441_Power(void) { + EXPREGS[0] =0; + GenMMC3Power(); + SetWriteHandler(0x6000, 0x7FFF, Mapper441_Write); +} + +void Mapper441_Init(CartInfo *info) { + GenMMC3_Init(info, 256, 256, 0, 0); + cwrap = Mapper441_CHRWrap; + pwrap = Mapper441_PRGWrap; + info->Power = Mapper441_Power; + info->Reset = Mapper441_Reset; + AddExState(EXPREGS, 1, 0, "EXPR"); +} diff --git a/src/ines.c b/src/ines.c index 71070ff..2fb19e3 100644 --- a/src/ines.c +++ b/src/ines.c @@ -815,6 +815,7 @@ INES_BOARD_BEGIN() INES_BOARD( "820401/T-217", 436, Mapper436_Init ) INES_BOARD( "NTDEC TH2348", 437, Mapper437_Init ) INES_BOARD( "K-3071", 438, Mapper438_Init ) + INES_BOARD( "850335C", 441, Mapper441_Init ) INES_BOARD( "NC-3000M", 443, Mapper443_Init ) INES_BOARD( "NC-7000M/NC-8000M", 444, Mapper444_Init ) INES_BOARD( "DS-9-27", 452, Mapper452_Init ) diff --git a/src/ines.h b/src/ines.h index 92ad140..4d0a91b 100644 --- a/src/ines.h +++ b/src/ines.h @@ -323,6 +323,7 @@ void Mapper435_Init(CartInfo *); void Mapper436_Init(CartInfo *); void Mapper437_Init(CartInfo *); void Mapper438_Init(CartInfo *); +void Mapper441_Init(CartInfo *); void Mapper443_Init(CartInfo *); void Mapper444_Init(CartInfo *); void Mapper452_Init(CartInfo *);