From 91509603264ca2f39b8c6cfd217272996b3a04e3 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sat, 1 Feb 2020 09:33:44 +0800 Subject: [PATCH] Add mappers 360, 533 --- src/boards/360.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ src/boards/533.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++ src/ines.c | 2 ++ src/ines.h | 2 ++ 4 files changed, 137 insertions(+) create mode 100644 src/boards/360.c create mode 100644 src/boards/533.c diff --git a/src/boards/360.c b/src/boards/360.c new file mode 100644 index 0000000..2c6609c --- /dev/null +++ b/src/boards/360.c @@ -0,0 +1,67 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2020 negativeExponent + * + * 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 360 - Bit Corp's 31-in-1 multicart (3150) */ + +#include "mapinc.h" + +static uint8 dipswitch; + +static SFORMAT StateRegs[] = +{ + { &dipswitch, 1, "DPSW" }, + { 0 } +}; + +static void Sync(void) { + /* dip 0 and 1 is the same game SMB) */ + if (dipswitch < 2) + setprg32(0x8000, dipswitch >> 1); + else { + setprg16(0x8000, dipswitch); + setprg16(0xC000, dipswitch); + } + setchr8(dipswitch); + setmirror(((dipswitch & 0x10) >> 4) ^ 1); +} + +static void M360Power(void) { + dipswitch = 0; + Sync(); + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x8000, 0XFFFF, CartBW); +} + +static void M360Reset(void) { + dipswitch = (dipswitch + 1) & 31; + Sync(); + FCEU_printf("dipswitch = %d\n", dipswitch); +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper360_Init(CartInfo *info) { + info->Reset = M360Reset; + info->Power = M360Power; + GameStateRestore = StateRestore; + AddExState(&StateRegs, ~0, 0, 0); +} diff --git a/src/boards/533.c b/src/boards/533.c new file mode 100644 index 0000000..664b547 --- /dev/null +++ b/src/boards/533.c @@ -0,0 +1,66 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2020 negativeExponent + * + * 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 533 is used for the Sachen 3014 board, used for the game + * 動動腦 II: 國中英文(一) (Dòngdòngnǎo II: Guózhōng Yīngwén (I), + * also known as Middle School English II, SA-003). + * It's a CNROM-like board with the added ability to read back + * the latch content for protection purposes. + */ + +#include "mapinc.h" + +static uint8 latche; + +static SFORMAT StateRegs[] = { + { &latche, 1, "LATC" }, + { 0 } +}; + +static void Sync(void) { + setprg32(0x8000, 0); + setchr8((latche >> 4) & 1); +} + +static DECLFR(M533Read) { + return ((PRGptr[0][A] & 0xF0) | (latche >> 4)); +} + +static DECLFW(M533Write) { + latche = (V & CartBR(A)); + Sync(); +} + +static void M533Power(void) { + Sync(); + SetReadHandler(0x8000, 0xFFFF, CartBROB); + SetReadHandler(0xE000, 0xEFFF, M533Read); + SetWriteHandler(0x8000, 0xFFFF, M533Write); +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper533_Init(CartInfo* info) { + info->Power = M533Power; + GameStateRestore = StateRestore; + AddExState(&StateRegs, ~0, 0, 0); +} diff --git a/src/ines.c b/src/ines.c index d3d9ae7..3917ba5 100644 --- a/src/ines.c +++ b/src/ines.c @@ -671,6 +671,8 @@ static BMAPPINGLocal bmap[] = { {(uint8_t*)"8-in-1 JY-119", 267, Mapper267_Init }, {(uint8_t*)"MMC3 BMC PIRATE", 294, Bs5652_Init}, /* nesdev redirects this as mapper 134 */ {(uint8_t*)"TXC 01-22110-000", 297, Mapper297_Init}, + {(uint8_t*)"Bitcorp 31-in-1", 360, Mapper360_Init}, + {(uint8_t*)"Sachen 3014", 533, Mapper533_Init}, /* UNIF to NES 2.0 BOARDS */ diff --git a/src/ines.h b/src/ines.h index 871216d..a9c5942 100644 --- a/src/ines.h +++ b/src/ines.h @@ -247,10 +247,12 @@ void Mapper267_Init(CartInfo *); void Mapper288_Init(CartInfo *); void Mapper297_Init(CartInfo *); void Mapper357_Init(CartInfo *); +void Mapper360_Init(CartInfo *); void Mapper372_Init(CartInfo *); void Mapper374_Init(CartInfo *); void Mapper381_Init(CartInfo *); void Mapper390_Init(CartInfo *); +void Mapper533_Init(CartInfo *); void Mapper538_Init(CartInfo *); void Mapper541_Init(CartInfo *);