diff --git a/src/boards/301.c b/src/boards/301.c new file mode 100644 index 0000000..4e73d23 --- /dev/null +++ b/src/boards/301.c @@ -0,0 +1,59 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2025 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 "asic_latch.h" + +static uint8 half; +static uint8 reg; + +static void sync () { + setprg16(0x8000, half <<5 &0x20 | reg <<3 &0x18 | Latch_data &0x07); + setprg16(0xC000, half <<5 &0x20 | reg <<3 &0x18 | 0x07); + setchr8(0); + setmirror(reg &0x04? MI_H: MI_V); +} + +static DECLFW (writeReg) { + reg = V; + sync(); +} + +static void power () { + half = 0; + reg = 0; + Latch_power(); + SetWriteHandler(0x5000, 0x5FFF, writeReg); +} + +static void reset () { + half ^= 1; + reg = 0; + RAM[0x100] =0; + Latch_clear(); +} + +void Mapper301_Init (CartInfo *info) { + Latch_init(info, sync, 0x8000, 0xFFFF, NULL); + info->Power = power; + info->Reset = reset; + AddExState(&half, 1, 0, "HALF"); + AddExState(®, 1, 0, "EXPR"); +} diff --git a/src/boards/8157.c b/src/boards/8157.c deleted file mode 100644 index eb9224f..0000000 --- a/src/boards/8157.c +++ /dev/null @@ -1,81 +0,0 @@ -/* 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 - * - * GG1 boards, similar to T-262, with no Data latch - * - */ - -#include "mapinc.h" - -static uint16 cmdreg; -static uint8 reset; -static SFORMAT StateRegs[] = -{ - { &reset, 1, "REST" }, - { &cmdreg, 2, "CREG" }, - { 0 } -}; - -static void Sync(void) { - uint32 base = ((cmdreg & 0x060) | ((cmdreg & 0x100) >> 1)) >> 2; - uint32 bank = (cmdreg & 0x01C) >> 2; - uint32 lbank = (cmdreg & 0x200) ? 7 : ((cmdreg & 0x80) ? bank : 0); - - setprg16(0x8000, base | bank); - setprg16(0xC000, base | lbank); - setmirror(((cmdreg & 2) >> 1) ^ 1); -} - -static DECLFR(UNL8157Read) { - if ((cmdreg & 0x100) && (PRGsize[0] < (1024 * 1024))) { - A = (A & 0xFFF0) + reset; - } - return CartBR(A); -} - -static DECLFW(UNL8157Write) { - cmdreg = A; - Sync(); -} - -static void UNL8157Power(void) { - setchr8(0); - SetWriteHandler(0x8000, 0xFFFF, UNL8157Write); - SetReadHandler(0x8000, 0xFFFF, UNL8157Read); - cmdreg = reset = 0; - Sync(); -} - -static void UNL8157Reset(void) { - cmdreg = reset = 0; - reset++; - reset &= 0x1F; - Sync(); -} - -static void UNL8157Restore(int version) { - Sync(); -} - -void UNL8157_Init(CartInfo *info) { - info->Power = UNL8157Power; - info->Reset = UNL8157Reset; - GameStateRestore = UNL8157Restore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/src/ines.c b/src/ines.c index 2fde992..c59a7ab 100644 --- a/src/ines.c +++ b/src/ines.c @@ -750,7 +750,7 @@ INES_BOARD_BEGIN() INES_BOARD( "TF1201", 298, UNLTF1201_Init ) INES_BOARD( "11160", 299, BMC11160_Init ) INES_BOARD( "190in1", 300, BMC190in1_Init ) - INES_BOARD( "8157", 301, UNL8157_Init ) + INES_BOARD( "K-3003", 301, Mapper301_Init ) INES_BOARD( "KS7057", 302, UNLKS7057_Init ) INES_BOARD( "KS7017", 303, UNLKS7017_Init ) INES_BOARD( "SMB2J", 304, UNLSMB2J_Init ) diff --git a/src/ines.h b/src/ines.h index 429b8dc..b8f3d6f 100644 --- a/src/ines.h +++ b/src/ines.h @@ -273,6 +273,7 @@ void Mapper288_Init(CartInfo *); void Mapper293_Init(CartInfo *); void Mapper294_Init(CartInfo *); void Mapper297_Init(CartInfo *); +void Mapper301_Init(CartInfo *); void Mapper310_Init(CartInfo *); void Mapper319_Init(CartInfo *); void Mapper321_Init(CartInfo *); diff --git a/src/unif.c b/src/unif.c index 9a91a53..0600839 100644 --- a/src/unif.c +++ b/src/unif.c @@ -430,10 +430,10 @@ static BMAPPING bmap[] = { { "43272", 242, Mapper242_Init, 0 }, { "603-5052", 238, UNL6035052_Init, 0 }, { "64in1NoRepeat", 314, BMC64in1nr_Init, 0 }, - { "70in1", 236, Mapper236_Init, 0 }, + { "70in1", 236, Mapper236_Init, 0 }, { "70in1B", 236, Mapper236_Init, 0 }, { "810544-C-A1", 261, BMC810544CA1_Init, 0 }, - { "8157", 301, UNL8157_Init, 0 }, + { "8157", 242, Mapper242_Init, 0 }, { "8237", 215, UNL8237_Init, 0 }, { "8237A", 215, UNL8237A_Init, 0 }, { "830118C", 348, BMC830118C_Init, 0 },