From 4feedbc7c1ccbdf1651bbfe666223f7f2f19bbdb Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Sat, 2 Apr 2022 17:48:19 +0200 Subject: [PATCH] Add mapper 310 --- src/boards/310.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + 3 files changed, 90 insertions(+) create mode 100644 src/boards/310.c diff --git a/src/boards/310.c b/src/boards/310.c new file mode 100644 index 0000000..7ebfac4 --- /dev/null +++ b/src/boards/310.c @@ -0,0 +1,88 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2005 CaH4e3 + * + * 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 uint8 regData[2]; +static uint8 regAddr; + +static SFORMAT K1053_state[] = +{ + { regData, 2, "REGD" }, + {®Addr, 1, "REGA" }, + { 0 } +}; + +static void K1053_sync (void) { + int prg =regData[0] &0x3F | regAddr <<4 &~0x3F; + int chrWritable; + switch(regAddr &3) { + case 0: setprg32(0x8000, prg >>1); + chrWritable =0; + break; + case 1: setprg16(0x8000, prg); + setprg16(0xC000, prg |7); + chrWritable =1; + break; + case 2: prg =prg <<1 | regData[0] >>7; + setprg8(0x8000, prg); + setprg8(0xA000, prg); + setprg8(0xC000, prg); + setprg8(0xE000, prg); + chrWritable =1; + break; + case 3: setprg16(0x8000, prg); + setprg16(0xC000, prg); + chrWritable =0; + break; + } + SetupCartCHRMapping(0, CHRptr[0], 0x8000, chrWritable); + setchr8(regData[1]); + setmirror(regData[0] &0x40? MI_H: MI_V); +} + +static void K1053_restore(int version) { + K1053_sync(); +} + +static DECLFW(K1053_write) { + regData[A >>14 &1] =V; + if (A &0x4000) regAddr=A &0xFF; + K1053_sync(); +} + +static void K1053_reset(void) { + regData[0] =regData[1] =regAddr =0; + K1053_sync(); +} + +static void K1053_power(void) { + K1053_reset(); + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x8000, 0xFFFF, K1053_write); +} + +void Mapper310_Init(CartInfo *info) { + info->Power = K1053_power; + info->Reset = K1053_reset; + GameStateRestore = K1053_restore; + AddExState(&K1053_state, ~0, 0, 0); +} diff --git a/src/ines.c b/src/ines.c index f2af9d5..c288b86 100644 --- a/src/ines.c +++ b/src/ines.c @@ -721,6 +721,7 @@ INES_BOARD_BEGIN() INES_BOARD( "KS7037", 307, UNLKS7037_Init ) INES_BOARD( "TH2131-1", 308, UNLTH21311_Init ) INES_BOARD( "LH51", 309, LH51_Init ) + INES_BOARD( "K-1053", 310, Mapper310_Init ) INES_BOARD( "KS7013B", 312, UNLKS7013B_Init ) INES_BOARD( "RESET-TXROM", 313, BMCRESETTXROM_Init ) INES_BOARD( "64in1NoRepeat", 314, BMC64in1nr_Init ) diff --git a/src/ines.h b/src/ines.h index bdb41a6..ef30b65 100644 --- a/src/ines.h +++ b/src/ines.h @@ -263,6 +263,7 @@ void Mapper271_Init(CartInfo *); void Mapper288_Init(CartInfo *); void Mapper293_Init(CartInfo *); void Mapper297_Init(CartInfo *); +void Mapper310_Init(CartInfo *); void Mapper319_Init(CartInfo *); void Mapper326_Init(CartInfo *); void Mapper330_Init(CartInfo *);