From e85c0e2d56002fd8f19caf07ff27d63d323a2721 Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Thu, 29 Dec 2022 21:57:02 +0100 Subject: [PATCH] Add mapper 354 --- src/boards/354.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + 3 files changed, 94 insertions(+) create mode 100644 src/boards/354.c diff --git a/src/boards/354.c b/src/boards/354.c new file mode 100644 index 0000000..0b4d731 --- /dev/null +++ b/src/boards/354.c @@ -0,0 +1,92 @@ +/* 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 + */ + +#include "mapinc.h" + +static uint16 latchAddr; +static uint8 latchData; +static uint8 submapper; + +static SFORMAT StateRegs[] = +{ + { &latchAddr, 2, "ADDR" }, + { &latchData, 1, "DATA" }, + { 0 } +}; + +static void Mapper354_Sync(void) +{ + int prg =latchData &0x3F | latchAddr <<2 &0x40 | latchAddr >>5 &0x80; + switch(latchAddr &7) + { + case 0: case 4: + setprg32(0x8000, prg >>1); + break; + case 1: + setprg16(0x8000, prg); + setprg16(0xC000, prg |7); + break; + case 2: case 6: + setprg8(0x8000, prg <<1 | latchData >>7); + setprg8(0xA000, prg <<1 | latchData >>7); + setprg8(0xC000, prg <<1 | latchData >>7); + setprg8(0xE000, prg <<1 | latchData >>7); + break; + case 3: case 7: + setprg16(0x8000, prg); + setprg16(0xC000, prg); + break; + case 5: + setprg8(0x6000, prg <<1 | latchData >>7); + setprg32(0x8000, prg >>1 |3); + break; + } + setchr8(0); + setmirror(latchData &0x40? MI_H: MI_V); +} + +static DECLFW(Mapper354_WriteLatch) +{ + latchData =V; + latchAddr =A &0xFFFF; + Mapper354_Sync(); +} + +static void Mapper354_Reset(void) +{ + latchAddr =latchData =0; + Mapper354_Sync(); +} + +static void Mapper354_Power(void) +{ + latchAddr =latchData =0; + SetReadHandler(0x6000, 0xFFFF, CartBR); + SetWriteHandler(submapper ==1? 0xE000: 0xF000, 0xFFFF, Mapper354_WriteLatch); + Mapper354_Sync(); +} + +void Mapper354_Init(CartInfo *info) +{ + submapper = info->submapper; + info->Power =Mapper354_Power; + info->Reset =Mapper354_Reset; + AddExState(StateRegs, ~0, 0, 0); +} diff --git a/src/ines.c b/src/ines.c index 63755d7..7a791fe 100644 --- a/src/ines.c +++ b/src/ines.c @@ -759,6 +759,7 @@ INES_BOARD_BEGIN() INES_BOARD( "891227", 350, BMC891227_Init ) INES_BOARD( "Techline XB", 351, Mapper351_Init ) INES_BOARD( "Super Mario Family", 353, Mapper353_Init ) + INES_BOARD( "FAM250/81-01-39-C/SCHI-24",354, Mapper354_Init ) INES_BOARD( "3D-BLOCK", 355, UNL3DBlock_Init ) INES_BOARD( "7-in-1 Rockman (JY-208)", 356, Mapper356_Init ) INES_BOARD( "Bit Corp 4-in-1", 357, Mapper357_Init ) diff --git a/src/ines.h b/src/ines.h index 4f7bbdf..ef072a5 100644 --- a/src/ines.h +++ b/src/ines.h @@ -271,6 +271,7 @@ void Mapper330_Init(CartInfo *); void Mapper334_Init(CartInfo *); void Mapper351_Init(CartInfo *); void Mapper353_Init(CartInfo *); +void Mapper354_Init(CartInfo *); void Mapper356_Init(CartInfo *); void Mapper357_Init(CartInfo *); void Mapper358_Init(CartInfo *);