From f56be8ce5e5c379c0ae12d64107744aee769592a Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Fri, 12 Sep 2025 01:25:50 +0200 Subject: [PATCH] Add mapper 548. --- src/boards/548.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + 3 files changed, 109 insertions(+) create mode 100644 src/boards/548.c diff --git a/src/boards/548.c b/src/boards/548.c new file mode 100644 index 0000000..0ca04ca --- /dev/null +++ b/src/boards/548.c @@ -0,0 +1,107 @@ +/* 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 + * + * + */ + +/* The UNIF dump of "(JY-103) 3-in-1" (JY4M4 MAPR) has a strange bank order and will not run with this emulation. */ + +#include "mapinc.h" +#include "wram.h" +#include "../fds_apu.h" + +static uint8 reg; +static uint8 latch; +static uint8 counting; +static uint16 counter; + +static SFORMAT stateRegs[] ={ + { ®, 1, "REGM" }, + { &latch, 1, "LATC" }, + { &counting, 1, "IRQA" }, + { &counter, 2, "IRQC" }, + { 0 } +}; + +static void sync () { + setprg8r(0x10, 0x6000, 0); + setprg16(0x8000, reg); + setprg16(0xC000, 3); + setchr8(0); +} + +static DECLFW (writeLatch) { + latch = A >>2 &0x03 | A >>3 &0x04; + if (A &4) { + counting = 0; + counter = 0; + X6502_IRQEnd(FCEU_IQEXT); + } else + counting = 1; +} + +static DECLFW (writeReg) { + reg = latch ^0x05; + sync(); +} + +static void FP_FASTAPASS(1) cpuCycle (int a) { + while (a--) { + if (counting) { + if (counter == 23680) + X6502_IRQBegin(FCEU_IQEXT); + else + if (counter == 24320) + X6502_IRQEnd(FCEU_IQEXT); + counter++; + } + } +} + +static void reset() { + FDSSoundReset(); + X6502_IRQEnd(FCEU_IQEXT); + latch = 0x07; + reg = latch ^0x05; + counting = 0; + counter = 0; + sync(); +} + +static void power() { + FDSSoundPower(); + SetReadHandler(0x6000, 0xFFFF, CartBR); + SetWriteHandler(0x4800, 0x4FFF, writeLatch); + SetWriteHandler(0x5000, 0x57FF, writeReg); + SetWriteHandler(0x6000, 0x7FFF, CartBW); + reset(); +} + +static void stateRestore(int version) { + sync(); +} + +void Mapper548_Init (CartInfo *info) { + WRAM_init(info, 8); + info->Power = power; + info->Reset = reset; + MapIRQHook = cpuCycle; + GameStateRestore = stateRestore; + AddExState(stateRegs, ~0, 0, 0); +} diff --git a/src/ines.c b/src/ines.c index 51df3dd..ae50efc 100644 --- a/src/ines.c +++ b/src/ines.c @@ -971,6 +971,7 @@ INES_BOARD_BEGIN() INES_BOARD( "WAIXING FS306", 544, Mapper544_Init ) INES_BOARD( "ST-80", 545, Mapper545_Init ) INES_BOARD( "03-101", 546, Mapper546_Init ) + INES_BOARD( "CTC-15", 548, Mapper548_Init ) INES_BOARD( "Kaiser KS-7016B", 549, Mapper549_Init ) INES_BOARD( "", 550, Mapper550_Init ) INES_BOARD( "", 551, Mapper178_Init ) diff --git a/src/ines.h b/src/ines.h index a7b1b53..a56fd6b 100644 --- a/src/ines.h +++ b/src/ines.h @@ -439,6 +439,7 @@ void Mapper543_Init(CartInfo *); void Mapper544_Init(CartInfo *); void Mapper545_Init(CartInfo *); void Mapper546_Init(CartInfo *); +void Mapper548_Init(CartInfo *); void Mapper549_Init(CartInfo *); void Mapper550_Init(CartInfo *); void Mapper552_Init(CartInfo *);