diff --git a/src/boards/bmck3088.c b/src/boards/bmck3088.c new file mode 100644 index 0000000..e59c38c --- /dev/null +++ b/src/boards/bmck3088.c @@ -0,0 +1,72 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2019 Libretro Team + * + * 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 + */ + +/* NES 2.0 Mapper 287 + * similar to BMC-411120-C but without jumper or dipswitch */ + +#include "mapinc.h" +#include "mmc3.h" + +static void BMCK3088CW(uint32 A, uint8 V) { + if (CHRptr[EXPREGS[0] & 7]) + setchr1r(EXPREGS[0] & 7, A, V); + else + setchr1(A, V | ((EXPREGS[0] & 3) << 7)); +} + +static void BMCK3088PW(uint32 A, uint8 V) { + if (PRGptr[EXPREGS[0] & 7]) { + uint8 chip = EXPREGS[0] & 7; + if (EXPREGS[0] & 8) + setprg32r(chip, 0x8000, ((EXPREGS[0] >> 4) & 3)); + else + setprg8r(chip, A, (V & 0x0F)); + } else { + if (EXPREGS[0] & 8) + setprg32(0x8000, ((EXPREGS[0] >> 4) & 3) | (0x0C)); + else + setprg8(A, (V & 0x0F) | ((EXPREGS[0] & 3) << 4)); + } +} + +static DECLFW(BMCK3088LoWrite) { + EXPREGS[0] = A; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); +} + +static void BMCK3088Reset(void) { + EXPREGS[0] = 0; + MMC3RegReset(); +} + +static void BMCK3088Power(void) { + GenMMC3Power(); + SetWriteHandler(0x6000, 0x7FFF, BMCK3088LoWrite); +} + +void BMCK3088_Init(CartInfo *info) { + GenMMC3_Init(info, 128, 128, 8, 0); + pwrap = BMCK3088PW; + cwrap = BMCK3088CW; + info->Power = BMCK3088Power; + info->Reset = BMCK3088Reset; + AddExState(EXPREGS, 1, 0, "EXPR"); +} diff --git a/src/unif.c b/src/unif.c index ebd60fa..9e8cc07 100644 --- a/src/unif.c +++ b/src/unif.c @@ -479,7 +479,7 @@ static BMAPPING bmap[] = { { "RESETNROM-XIN1", BMCRESETNROMXIN1_Init, 0 }, { " BMC-RESET-TXROM", BMCRESETTXROM_Init, 0 }, { "RESET-TXROM", BMCRESETTXROM_Init, 0 }, - { "K-3088", BMC411120C_Init, 0 }, + { "K-3088", BMCK3088_Init, 0 }, { "FARID_SLROM_8-IN-1", FARIDSLROM8IN1_Init, 0 }, { "830425C-4391T", BMC830425C4391T_Init, 0 }, { "TJ-03", BMCTJ03_Init, 0 }, diff --git a/src/unif.h b/src/unif.h index 6181f3b..2c9f269 100644 --- a/src/unif.h +++ b/src/unif.h @@ -180,6 +180,7 @@ void MINDKIDS_Init(CartInfo *info); /* m268 */ void UNLKS7021A_Init(CartInfo *info); /* m525 */ void BTL900218_Init(CartInfo *info); /* m524 */ void UNLAX40G_Init(CartInfo *info); /* m527 */ +void BMCK3088_Init(CartInfo *info); /* m287 */ #ifdef COPYFAMI void MapperCopyFamiMMC3_Init(CartInfo *info);