diff --git a/src/boards/341.c b/src/boards/341.c new file mode 100644 index 0000000..c776544 --- /dev/null +++ b/src/boards/341.c @@ -0,0 +1,40 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2026 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" + +uint8 submapper; + +static void sync () { + setprg32(0x8000, Latch_address >>8); + setchr8(Latch_address >>8); + setmirror(Latch_address &(submapper == 1? 0x800: 0x200)? MI_H: MI_V); +} + +static void trapLatchWrite (uint16 *newAddress, uint8 *newValue, uint8 romValue) { + if (!((*newAddress &0xF0) == 0xA0)) *newAddress = Latch_address; /* Update address only if new A7..A4 = $A */ +} + +void Mapper341_Init (CartInfo *info) { + submapper = info->submapper; + Latch_init(info, sync, 0x8000, 0xFFFF, submapper == 1? trapLatchWrite: NULL); + info->Reset = Latch_clear; +} diff --git a/src/boards/343.c b/src/boards/343.c new file mode 100644 index 0000000..50ec372 --- /dev/null +++ b/src/boards/343.c @@ -0,0 +1,53 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2026 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 reg; + +static void sync () { + setprg32(0x8000, Latch_data); + setchr8(0); + setmirror(reg &0x08? MI_H: MI_V); +} + +static DECLFW (writeReg) { + reg = V; + sync(); +} + +static void reset () { + reg = 0; + Latch_clear(); +} + +static void power () { + reg = 0; + Latch_power(); + SetWriteHandler(0x5000, 0x5FFF, writeReg); +} + +void Mapper343_Init (CartInfo *info) { + Latch_init(info, sync, 0x8000, 0xFFFF, NULL); + info->Power = power; + info->Reset = reset; + AddExState(®, 1, 0, "REGS"); +} diff --git a/src/boards/addrlatch.c b/src/boards/addrlatch.c index bb3fe6c..fe9b9fd 100644 --- a/src/boards/addrlatch.c +++ b/src/boards/addrlatch.c @@ -696,23 +696,6 @@ void BMCG146_Init(CartInfo *info) { Latch_Init(info, BMCG146Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); } -/*-------------- BMC-TJ-03 ------------------------*/ -/* NES 2.0 mapper 341 is used for a simple 4-in-1 multicart */ - -static void BMCTJ03Sync(void) { - uint8 mirr = latche &(PRGsize[0] &0x40000? 0x800: 0x200)? MI_H: MI_V; - uint8 bank = latche >> 8; - - setprg32(0x8000, bank); - setchr8(bank); - - setmirror(mirr); -} - -void BMCTJ03_Init(CartInfo *info) { - Latch_Init(info, BMCTJ03Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - /*-------------- BMC-SA005-A ------------------------*/ /* NES 2.0 mapper 338 is used for a 16-in-1 and a 200/300/600/1000-in-1 multicart. * http://wiki.nesdev.com/w/index.php/NES_2.0_Mapper_338 */ diff --git a/src/ines.c b/src/ines.c index bec4026..212b6c6 100644 --- a/src/ines.c +++ b/src/ines.c @@ -786,8 +786,9 @@ INES_BOARD_BEGIN() INES_BOARD( "SA005-A", 338, BMCSA005A_Init ) INES_BOARD( "K-3006", 339, BMCK3006_Init ) INES_BOARD( "K-3036", 340, Mapper340_Init ) - INES_BOARD( "TJ-03", 341, BMCTJ03_Init ) + INES_BOARD( "TJ-03", 341, Mapper341_Init ) INES_BOARD( "COOLGIRL", 342, COOLGIRL_Init ) + INES_BOARD( "I030", 343, Mapper343_Init ) INES_BOARD( "GN-26", 344, BMCGN26_Init ) INES_BOARD( "L6IN1", 345, BMCL6IN1_Init ) INES_BOARD( "KS7012", 346, UNLKS7012_Init ) diff --git a/src/ines.h b/src/ines.h index d1579df..ed9e299 100644 --- a/src/ines.h +++ b/src/ines.h @@ -281,6 +281,8 @@ void Mapper326_Init(CartInfo *); void Mapper330_Init(CartInfo *); void Mapper334_Init(CartInfo *); void Mapper340_Init(CartInfo *); +void Mapper341_Init(CartInfo *); +void Mapper343_Init(CartInfo *); void Mapper351_Init(CartInfo *); void Mapper352_Init(CartInfo *); void Mapper353_Init(CartInfo *); diff --git a/src/unif.c b/src/unif.c index d60ba50..4d47250 100644 --- a/src/unif.c +++ b/src/unif.c @@ -590,7 +590,7 @@ static BMAPPING bmap[] = { { "K-3088", 287, BMCK3088_Init, 0 }, { "FARID_SLROM_8-IN-1", 323, FARIDSLROM8IN1_Init, 0 }, { "830425C-4391T", 320, BMC830425C4391T_Init, 0 }, - { "TJ-03", 341, BMCTJ03_Init, 0 }, + { "TJ-03", 341, Mapper341_Init, 0 }, { "CTC-09", 335, BMCCTC09_Init, 0 }, { "K-3046", 336, BMCK3046_Init, 0 }, { "SA005-A", 338, BMCSA005A_Init, 0 }, diff --git a/src/unif.h b/src/unif.h index 558d5cc..6c96479 100644 --- a/src/unif.h +++ b/src/unif.h @@ -158,7 +158,6 @@ void LH51_Init(CartInfo *info); /* m309 */ void BMCRESETTXROM_Init(CartInfo *info); /* m313 */ void FARIDSLROM8IN1_Init(CartInfo *info); /* m323 */ void BMC830425C4391T_Init(CartInfo *info); /* m320 */ -void BMCTJ03_Init(CartInfo *info); /* m341 */ void BMCCTC09_Init(CartInfo *info); /* m335 */ void BMCK3046_Init(CartInfo *info); /* m336 */ void BMCSA005A_Init(CartInfo *info); /* m338 */