diff --git a/src/boards/586.c b/src/boards/586.c new file mode 100644 index 0000000..2cf2bfc --- /dev/null +++ b/src/boards/586.c @@ -0,0 +1,37 @@ +/* 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 void sync () { + if (Latch_address &0x08) { + setprg16(0x8000, Latch_address); + setprg16(0xC000, Latch_address); + } else + setprg32(0x8000, Latch_address >>1); + setchr8(Latch_address); + setmirror(Latch_address &0x08? MI_V: MI_H); +} + +void Mapper586_Init (CartInfo *info) { + Latch_init(info, sync, 0x8000, 0xFFFF, NULL); + info->Reset = Latch_power; +} diff --git a/src/boards/asic_latch.c b/src/boards/asic_latch.c index 03df1d2..4eebcfd 100644 --- a/src/boards/asic_latch.c +++ b/src/boards/asic_latch.c @@ -36,7 +36,7 @@ static SFORMAT Latch_state[] = { DECLFW(Latch_write) { uint16 newAddress = A &0xFFFF; if (Latch_cbWrite) Latch_cbWrite(&newAddress, &V, CartBR(A)); - Latch_address = A; + Latch_address = newAddress; Latch_data = V; Latch_cbSync(); } @@ -48,6 +48,7 @@ static void Latch_clear () { } static void Latch_setHandlers() { + SetReadHandler(0x8000, 0xFFFF, CartBR); SetWriteHandler(Latch_from, Latch_to, Latch_write); } diff --git a/src/ines.c b/src/ines.c index f6e9c3e..547adc5 100644 --- a/src/ines.c +++ b/src/ines.c @@ -948,6 +948,7 @@ INES_BOARD_BEGIN() INES_BOARD( "Bung Super Game Doctor", 561, Mapper561_562_Init ) INES_BOARD( "Venus Turbo Game Doctor", 562, Mapper561_562_Init ) INES_BOARD( "J-2020", 563, Mapper563_Init ) + INES_BOARD( "HN-02", 586, Mapper586_Init ) INES_BOARD_END() static uint32 iNES_get_mapper_id(void) diff --git a/src/ines.h b/src/ines.h index 832438b..0991fed 100644 --- a/src/ines.h +++ b/src/ines.h @@ -413,6 +413,7 @@ void Mapper558_Init(CartInfo *); void Mapper559_Init(CartInfo *); void Mapper561_562_Init(CartInfo *); void Mapper563_Init(CartInfo *); +void Mapper586_Init(CartInfo *); void FFE_Init(CartInfo *);