diff --git a/src/boards/162.c b/src/boards/162.c index c2a44e3..676b44f 100644 --- a/src/boards/162.c +++ b/src/boards/162.c @@ -23,7 +23,6 @@ /* Waixing FS304 PCB */ #include "mapinc.h" -#include "../ines.h" static uint8 *WRAM; static uint32 WRAMSIZE; diff --git a/src/boards/163.c b/src/boards/163.c index f8da4ff..9709255 100644 --- a/src/boards/163.c +++ b/src/boards/163.c @@ -23,7 +23,6 @@ /* Nanjing FC-001 PCB */ #include "mapinc.h" -#include "../ines.h" static uint8 *WRAM; static uint32 WRAMSIZE; diff --git a/src/boards/218.c b/src/boards/218.c index 84892d3..88d3e11 100644 --- a/src/boards/218.c +++ b/src/boards/218.c @@ -19,7 +19,6 @@ */ #include "mapinc.h" -#include "../ines.h" static void M218Power(void) { setchr8(0); diff --git a/src/boards/233.c b/src/boards/233.c new file mode 100644 index 0000000..e441772 --- /dev/null +++ b/src/boards/233.c @@ -0,0 +1,87 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2005 CaH4e3 + * Copyright (C) 2009 qeed + * 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 + * + */ + +/* Updated 2019-07-12 + * Mapper 233 - UNIF 42in1ResetSwitch - reset-based switching + */ + +#include "mapinc.h" + +static uint8 latche; +static uint8 reset; + +static SFORMAT StateRegs[] = +{ + { &reset, 1, "RST" }, + { &latche, 1, "LATC" }, + { 0 } +}; + +static void Sync(void) { + uint8 bank = (latche & 0x1f) | (reset << 5); + + if (!(latche & 0x20)) + setprg32(0x8000, bank >> 1); + else { + setprg16(0x8000, bank); + setprg16(0xC000, bank); + } + + switch ((latche >> 6) & 3) { + case 0: setmirror(MI_0); break; + case 1: setmirror(MI_V); break; + case 2: setmirror(MI_H); break; + case 3: setmirror(MI_1); break; + } + + setchr8(0); +} + +static DECLFW(M233Write) { + latche = V; + Sync(); +} + +static void M233Power(void) { + latche = reset = 0; + Sync(); + SetWriteHandler(0x8000, 0xFFFF, M233Write); + SetReadHandler(0x8000, 0xFFFF, CartBR); +} + +static void StateRestore(int version) { + Sync(); +} + +static void M233Reset(void) { + latche = 0; + reset ^= 1; + Sync(); +} + +void Mapper233_Init(CartInfo *info) { + info->Power = M233Power; + info->Reset = M233Reset; + AddExState(&StateRegs, ~0, 0, 0); + GameStateRestore = StateRestore; +} diff --git a/src/boards/235.c b/src/boards/235.c index b823666..f64b138 100644 --- a/src/boards/235.c +++ b/src/boards/235.c @@ -20,7 +20,6 @@ */ #include "mapinc.h" -#include "../ines.h" static uint8 *CHRRAM; static uint32 CHRRAMSIZE; diff --git a/src/boards/267.c b/src/boards/267.c index 1b53e89..2780fd0 100644 --- a/src/boards/267.c +++ b/src/boards/267.c @@ -34,9 +34,11 @@ static void M267PW(uint32 A, uint8 V) { } static DECLFW(M267Write) { - EXPREGS[0] = V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); + if (!(EXPREGS[0] & 0x80)) { + EXPREGS[0] = V; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); + } } static void M267Reset(void) { @@ -47,14 +49,14 @@ static void M267Reset(void) { static void M267Power(void) { EXPREGS[0] = 0; GenMMC3Power(); - SetWriteHandler(0x6000, 0x6FFF, M267Write); + SetWriteHandler(0x6000, 0x7FFF, M267Write); } void Mapper267_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 128, 0, 0); + GenMMC3_Init(info, 256, 128, 0, 0); cwrap = M267CW; pwrap = M267PW; info->Reset = M267Reset; info->Power = M267Power; - AddExState(EXPREGS, 4, 0, "EXPR"); + AddExState(EXPREGS, 1, 0, "EXPR"); } diff --git a/src/boards/283.c b/src/boards/283.c index c3dba2b..7d9eaef 100644 --- a/src/boards/283.c +++ b/src/boards/283.c @@ -19,7 +19,6 @@ */ #include "mapinc.h" -#include "../ines.h" static uint8 reg, mirr; static SFORMAT StateRegs[] = diff --git a/src/boards/334.c b/src/boards/334.c new file mode 100644 index 0000000..8dcfed0 --- /dev/null +++ b/src/boards/334.c @@ -0,0 +1,65 @@ +/* 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 + * + * + */ + +#include "mapinc.h" +#include "mmc3.h" + +static uint8 dipswitch; + +static void M334PW(uint32 A, uint8 V) { + setprg32(0x8000, EXPREGS[0] >> 1); +} + +static DECLFW(M334Write) { + if (!(A & 1)) { + EXPREGS[0] = V; + FixMMC3PRG(MMC3_cmd); + } +} + +static DECLFR(M334Read) { + if (A & 2) + return ((X.DB & 0xFE) | (dipswitch & 1)); + return X.DB; +} + +static void M334Reset(void) { + dipswitch++; + EXPREGS[0] = 0; + MMC3RegReset(); +} + +static void M334Power(void) { + dipswitch = 0; + EXPREGS[0] = 0; + GenMMC3Power(); + SetReadHandler(0x6000, 0x7FFF, M334Read); + SetWriteHandler(0x6000, 0x7FFF, M334Write); +} + +void Mapper334_Init(CartInfo *info) { + GenMMC3_Init(info, 32, 32, 0, 0); + pwrap = M334PW; + info->Power = M334Power; + info->Reset = M334Reset; + AddExState(EXPREGS, 1, 0, "EXPR"); +} diff --git a/src/boards/357.c b/src/boards/357.c index 2c28e9e..a46bdea 100644 --- a/src/boards/357.c +++ b/src/boards/357.c @@ -29,15 +29,16 @@ static uint8 preg[4]; static uint8 dipswitch; -static uint32 IRQCount, IRQa; +static uint8 IRQa; +static uint16 IRQCount; static const uint8 banks[8] = { 4, 3, 5, 3, 6, 3, 7, 3 }; static const uint8 outer_bank[4] = { 0x00, 0x08, 0x10, 0x18 }; static SFORMAT StateRegs[] = { - { &IRQCount, 4 | FCEUSTATE_RLSB, "IRQC" }, - { &IRQa, 4 | FCEUSTATE_RLSB, "IRQA" }, + { &IRQCount, 2 | FCEUSTATE_RLSB, "IRQC" }, + { &IRQa, 1 | FCEUSTATE_RLSB, "IRQA" }, { &dipswitch, 1, "DPSW" }, { &preg, 4, "REG" }, { 0 } diff --git a/src/boards/364.c b/src/boards/364.c new file mode 100644 index 0000000..b082392 --- /dev/null +++ b/src/boards/364.c @@ -0,0 +1,58 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 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 + * + */ + +#include "mapinc.h" +#include "mmc3.h" + +static void M364CW(uint32 A, uint8 V) { + V &= (EXPREGS[0] & 0x20) ? 0x7F : 0xFF; + setchr1(A, V | ((EXPREGS[0] << 4) & 0x100)); +} + +static void M364PW(uint32 A, uint8 V) { + V &= (EXPREGS[0] & 0x20) ? 0x0F : 0x1F; + setprg8(A, V | ((EXPREGS[0] >> 1) & 0x20)); +} + +static DECLFW(M364Write) { + EXPREGS[0] = V; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); +} + +static void M364Power(void) { + EXPREGS[0] = 0; + GenMMC3Power(); + SetWriteHandler(0x7000, 0x7FFF, M364Write); +} + +static void M364Reset(void) { + EXPREGS[0] = 0; + MMC3RegReset(); +} + +void Mapper364_Init(CartInfo *info) { + GenMMC3_Init(info, 512, 512, 8, 0); + pwrap = M364PW; + cwrap = M364CW; + info->Power = M364Power; + AddExState(EXPREGS, 1, 0, "EXPR"); +} diff --git a/src/boards/368.c b/src/boards/368.c new file mode 100644 index 0000000..4ae27fe --- /dev/null +++ b/src/boards/368.c @@ -0,0 +1,112 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 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 357 is used for a 4-in-1 multicart (cartridge ID 4602) from Bit Corp. + * The first game is Bit Corp's hack of the YUNG-08 conversion of Super Mario Brothers 2 (J) named Mr. Mary 2, + * the other three games are UNROM games. + * + * Implementation is modified so reset actually sets the correct dipswitch (or outer banks) for each of the 4 games + */ + +#include "mapinc.h" + +static uint8 preg; +static uint8 latch; +static uint8 IRQa; +static uint16 IRQCount; + +static const uint8 banks[8] = { 4, 3, 5, 3, 6, 3, 7, 3 }; + +static SFORMAT StateRegs[] = +{ + { &IRQCount, 2 | FCEUSTATE_RLSB, "IRQC" }, + { &IRQa, 1, "IRQA" }, + { &latch, 1, "LATC" }, + { &preg, 1, "REG" }, + { 0 } +}; + +static void Sync(void) { + setprg8(0x6000, 2); + setprg8(0x8000, 1); + setprg8(0xa000, 0); + setprg8(0xc000, banks[preg]); + setprg8(0xe000, 8); + setchr8(0); +} + +static DECLFW(M368WritePRG) { + preg = V & 7; + Sync(); +} + +static DECLFW(M368WriteIRQ) { + latch = V & 0x53; + IRQa = V & 1; + if (!IRQa) { + IRQCount = 0; + X6502_IRQEnd(FCEU_IQEXT); + } +} + +static DECLFR(M368Read) { + return (latch | 0xBA); +} + +static void M368Power(void) { + preg = 0; + latch = 0; + IRQa = IRQCount = 0; + Sync(); + SetReadHandler(0x4122, 0x4122, M368Read); + SetReadHandler(0x6000, 0x7FFF, CartBR); + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x4022, 0x4022, M368WritePRG); + SetWriteHandler(0x4120, 0x4120, M368WritePRG); + SetWriteHandler(0x4122, 0x4122, M368WriteIRQ); +} + +static void M368Reset(void) { + IRQa = IRQCount = 0; + Sync(); +} + +static void FP_FASTAPASS(1) M368IRQHook(int a) { + if (IRQa) { + if (IRQCount < 4096) + IRQCount += a; + else { + IRQa = 0; + X6502_IRQBegin(FCEU_IQEXT); + } + } +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper368_Init(CartInfo *info) { + info->Reset = M368Reset; + info->Power = M368Power; + MapIRQHook = M368IRQHook; + GameStateRestore = StateRestore; + AddExState(&StateRegs, ~0, 0, 0); +} diff --git a/src/boards/377.c b/src/boards/377.c new file mode 100644 index 0000000..bece1b2 --- /dev/null +++ b/src/boards/377.c @@ -0,0 +1,64 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 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 377 - NES 2.0 Mapper 377 is used for the + * 1998 Super Game 8-in-1 (JY-111) pirate multicart. It works similarly to Mapper 267 except it has an outer 256KiB PRG-ROM bank. + */ + +#include "mapinc.h" +#include "mmc3.h" + +#define OUTER_BANK (((EXPREGS[0] & 0x20) >> 2) | (EXPREGS[0] & 0x06)) + +static void M377CW(uint32 A, uint8 V) { + setchr1(A, (V & 0x7F) | (OUTER_BANK << 6)); +} + +static void M377PW(uint32 A, uint8 V) { + setprg8(A, (V & 0x0F) | (OUTER_BANK << 3)); +} + +static DECLFW(M377Write) { + if (!(EXPREGS[0] & 0x80)) { + EXPREGS[0] = V; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); + } +} + +static void M377Reset(void) { + EXPREGS[0] = 0; + MMC3RegReset(); +} + +static void M377Power(void) { + EXPREGS[0] = 0; + GenMMC3Power(); + SetWriteHandler(0x6000, 0x7FFF, M377Write); +} + +void Mapper377_Init(CartInfo *info) { + GenMMC3_Init(info, 128, 128, 0, 0); + cwrap = M377CW; + pwrap = M377PW; + info->Reset = M377Reset; + info->Power = M377Power; + AddExState(EXPREGS, 1, 0, "EXPR"); +} diff --git a/src/boards/393.c b/src/boards/393.c new file mode 100644 index 0000000..56eab48 --- /dev/null +++ b/src/boards/393.c @@ -0,0 +1,111 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 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 + * + * + */ + +#include "mapinc.h" +#include "mmc3.h" + +static uint8 *CHRRAM; +static uint32 CHRRAMSIZE; + +static int getPRGBank(int bank) { + if ((~bank & 1) && (MMC3_cmd & 0x40)) bank ^= 2; + return (bank & 2) ? 0xFE | (bank & 1) : DRegBuf[6 | (bank & 1)]; +} + +static void M393CW(uint32 A, uint8 V) { + if (EXPREGS[0] & 8) + setchr8r(0x10, 0); + else + setchr1(A, V & 0xFF | EXPREGS[0] << 8); +} + +static void M393PW(uint32 A, uint8 V) { + switch ((EXPREGS[0] >> 4) & 3) { + case 0: + case 1: + setprg8(A, (V & 0x0F) | (EXPREGS[0] << 4)); + break; + case 2: + setprg32(0x8000, ((getPRGBank(0) >> 2) & 3) | (EXPREGS[0] << 2)); + break; + case 3: + setprg16(0x8000, (EXPREGS[0] << 3) | (EXPREGS[1] &7)); + setprg16(0xC000, (EXPREGS[0] << 3) | 7); + break; + } +} + +static DECLFW(M393Write8) { + switch (A & 0xE000) { + case 0x8000: + case 0xA000: + MMC3_CMDWrite(A, V); + break; + case 0xC000: + case 0xE000: + MMC3_IRQWrite(A, V); + break; + } + + EXPREGS[1] = V; + FixMMC3CHR(MMC3_cmd); + FixMMC3PRG(MMC3_cmd); +} + +static DECLFW(M393Write6) { + EXPREGS[0] = A & 0xFF; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); +} + +static void M393Power(void) { + EXPREGS[0] = EXPREGS[1] = 0; + GenMMC3Power(); + SetWriteHandler(0x6000, 0x7FFF, M393Write6); + SetWriteHandler(0x8000, 0xFFFF, M393Write8); +} + +static void M393Reset(void) { + EXPREGS[0] = EXPREGS[1] = 0; + MMC3RegReset(); +} + +static void M393lose(void) { + GenMMC3Close(); + if (CHRRAM) + FCEU_free(CHRRAM); + CHRRAM = NULL; +} + +void Mapper393_Init(CartInfo *info) { + GenMMC3_Init(info, 1024, 512, 8, 0); + pwrap = M393PW; + cwrap = M393CW; + info->Power = M393Power; + info->Reset = M393Reset; + info->Close = M393lose; + CHRRAMSIZE = 8192; + CHRRAM = (uint8 *)FCEU_gmalloc(CHRRAMSIZE); + SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); + AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); + AddExState(EXPREGS, 2, 0, "EXPR"); +} diff --git a/src/boards/396.c b/src/boards/396.c new file mode 100644 index 0000000..5b58694 --- /dev/null +++ b/src/boards/396.c @@ -0,0 +1,73 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 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 396 - BMC-830752C + * 1995 Super 8-in-1 (JY-050 rev0) + * Super 8-in-1 Gold Card Series (JY-085) + * Super 8-in-1 Gold Card Series (JY-086) + * 2-in-1 (GN-51) + */ + +#include "mapinc.h" + +static uint8 reg[2]; + +static void Sync (void) { + setprg16(0x8000, reg[1] << 3 | reg[0] & 7); + setprg16(0xC000, reg[1] << 3 | 7); + setchr8(0); + setmirror(((reg[0] >> 6) & 1) ^ 1); +} + +static DECLFW(M396WriteInnerBank) { + reg[0] = V; + Sync(); +} + +static DECLFW(M396WriteOuterBank) { + reg[1] = V; + Sync(); +} + +static void M396Reset(void) { + reg[0] = 0x00; + reg[1] = 0x00; + Sync(); +} + +static void StateRestore(void) { + Sync(); +} + +static void M396Power(void) { + reg[0] = 0x00; + reg[1] = 0x00; + Sync(); + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x8000, 0x9FFF, M396WriteInnerBank); + SetWriteHandler(0xA000, 0xBFFF, M396WriteOuterBank); + SetWriteHandler(0xC000, 0xFFFF, M396WriteInnerBank); +} + +void Mapper396_Init(CartInfo *info) { + info->Power = M396Power; + info->Reset = M396Reset; + GameStateRestore = StateRestore; + AddExState(reg, 2, 0, "REGS"); +} diff --git a/src/boards/403.c b/src/boards/403.c index c0299c8..aa04f75 100644 --- a/src/boards/403.c +++ b/src/boards/403.c @@ -64,6 +64,7 @@ static void M403Reset(void) { static void M403Power(void) { reg[0] = reg[1] = reg[2] = 0; Sync(); + SetReadHandler(0x6000, 0x7FFF, CartBR); /* For TetrisA (Tetris Family 19-in-1 NO 1683) */ SetReadHandler(0x8000, 0xFFFF, CartBR); SetWriteHandler(0x4100, 0x4103, M403Write4); SetWriteHandler(0x8000, 0xFFFF, M403Write8); diff --git a/src/boards/410.c b/src/boards/410.c new file mode 100644 index 0000000..2c0bfa3 --- /dev/null +++ b/src/boards/410.c @@ -0,0 +1,89 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 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 410 is a variant of mapper 45 where the + * ASIC's PRG A21/CHR A20 output (set by bit 6 of the third write to $6000) + * selects between regularly-banked CHR-ROM (=0) and 8 KiB of unbanked CHR-RAM (=1). + * It is used solely for the Super 8-in-1 - 98格鬥天王+熱血 (JY-302) multicart. + */ + +#include "mapinc.h" +#include "mmc3.h" + +static uint8 *CHRRAM; + +static void M410CW(uint32 A, uint8 V) { + if (!(EXPREGS[2] & 0x40)) { + uint32 NV = V; + NV &= (1 << ((EXPREGS[2] & 7) + 1)) - 1; + NV |= EXPREGS[0] | ((EXPREGS[2] & 0xF0) << 4); + setchr1(A, NV); + } else + setchr8r(0x10, 0); +} + +static void M410PW(uint32 A, uint8 V) { + uint32 MV = V & ((EXPREGS[3] & 0x3F) ^ 0x3F); + MV |= EXPREGS[1]; + MV |= ((EXPREGS[2] & 0x40) << 2); + setprg8(A, MV); +/* FCEU_printf("1:%02x 2:%02x 3:%02x A=%04x V=%03x\n",EXPREGS[1],EXPREGS[2],EXPREGS[3],A,MV); */ +} + +static DECLFW(M410Write) { + EXPREGS[EXPREGS[4]] = V; + EXPREGS[4] = (EXPREGS[4] + 1) & 3; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); +} + +static void M410Close(void) { + GenMMC3Close(); + if (CHRRAM) + FCEU_free(CHRRAM); + CHRRAM = NULL; +} + +static void M410Reset(void) { + EXPREGS[0] = EXPREGS[1] = EXPREGS[3] = EXPREGS[4] = 0; + EXPREGS[2] = 0x0F; + MMC3RegReset(); +} + +static void M410Power(void) { + GenMMC3Power(); + EXPREGS[0] = EXPREGS[1] = EXPREGS[3] = EXPREGS[4] = 0; + EXPREGS[2] = 0x0F; + SetWriteHandler(0x6000, 0x7FFF, M410Write); +} + +void Mapper410_Init(CartInfo *info) { + GenMMC3_Init(info, 512, 256, 8, info->battery); + cwrap = M410CW; + pwrap = M410PW; + info->Reset = M410Reset; + info->Power = M410Power; + info->Close = M410Close; + AddExState(EXPREGS, 5, 0, "EXPR"); + + CHRRAM = (uint8*)FCEU_gmalloc(8192); + SetupCartCHRMapping(0x10, CHRRAM, 8192, 1); + AddExState(CHRRAM, 8192, 0, "CRAM"); +} \ No newline at end of file diff --git a/src/boards/416.c b/src/boards/416.c new file mode 100644 index 0000000..9489b30 --- /dev/null +++ b/src/boards/416.c @@ -0,0 +1,111 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 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. + */ + + + +#include "mapinc.h" + +static uint8 reg; +static uint8 smb2j_reg; +static uint8 IRQa; +static uint16 IRQCount; + +static void Sync(void) { + if (reg & 8) { + uint8 prg = ((reg >> 5) & 1) | ((reg >> 6) & 2) | ((reg >> 1) & 4); + switch ((reg >> 6) & 3) { + case 0: + setprg8(0x8000, prg << 1); + setprg8(0xA000, prg << 1); + setprg8(0xC000, prg << 1); + setprg8(0xE000, prg << 1); + break; + case 1: + setprg16(0x8000, prg); + setprg16(0xC000, prg); + break; + case 2: + case 3: + setprg32(0x8000, prg >> 1); + break; + } + } else { + setprg8(0x8000, 0x0); + setprg8(0xA000, 0x1); + setprg8(0xC000, smb2j_reg); + setprg8(0xE000, 0x3); + } + setprg8(0x6000, 0x7); + setchr8((reg >> 1) & 3); + setmirror(((reg >> 2) & 1) ^ 1); +} + +static DECLFW(M416Write4) { + switch (A & 0xD160) { + case 0x4120: + IRQa = V & 1; + if (!IRQa) + IRQCount = 0; + X6502_IRQEnd(FCEU_IQEXT); + break; + case 0x4020: + smb2j_reg = ((V & 1) << 2) | ((V & 6) >> 1); + Sync(); + break; + } +} + +static DECLFW(M416Write8) { + reg = V; + Sync(); +} + +static void M416Power(void) { + reg = smb2j_reg = IRQa = IRQCount = 0; + Sync(); + SetReadHandler(0x6000, 0xFFFF, CartBR); + SetWriteHandler(0x4020, 0x5FFF, M416Write4); + SetWriteHandler(0x8000, 0x8000, M416Write8); +} + +static void FP_FASTAPASS(1) M416IRQHook(int a) { + if (IRQa) { + if (IRQCount < 4096) + IRQCount += a; + else { + IRQa = 0; + X6502_IRQBegin(FCEU_IQEXT); + } + } +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper416_Init(CartInfo *info) { + info->Power = M416Power; + MapIRQHook = M416IRQHook; + GameStateRestore = StateRestore; + AddExState(®, 1, 0, "REGS"); + AddExState(&smb2j_reg, 1, 0, "SMBJ"); + AddExState(&IRQa, 1, 0, "IRQa"); + AddExState(&IRQCount, 2, 0, "IRQC"); +} diff --git a/src/boards/417.c b/src/boards/417.c new file mode 100644 index 0000000..bea2e35 --- /dev/null +++ b/src/boards/417.c @@ -0,0 +1,80 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 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 + */ + +#include "mapinc.h" + +static uint8 preg[4]; +static uint8 creg[8]; +static uint8 nt[4]; +static uint8 IRQa; +static uint16 IRQCount; + +static SFORMAT StateRegs[] = { + { preg, 4, "PREG" }, + { creg, 8, "CREG" }, + { nt, 4, "NREG" }, + { &IRQa, 1, "IRQA" }, + { &IRQCount, 2, "IRQC" }, + { 0 } +}; + +static void Sync(void) { + int i; + setprg8(0x8000, preg[0]); + setprg8(0xA000, preg[1]); + setprg8(0xC000, preg[2]); + setprg8(0xE000, ~0); + for (i = 0; i < 8; i++) setchr1(i << 10, creg[i]); + setmirrorw(nt[0] & 1, nt[1] & 1, nt[2] & 1, nt[3] & 1); +} + +static DECLFW(M417Write) { + switch ((A >> 4) & 7) { + case 0: preg[A & 3] = V; Sync(); break; + case 1: creg[0 | (A & 3)] = V; Sync(); break; + case 2: creg[4 | (A & 3)] = V; Sync(); break;break; + case 3: IRQCount = 0; IRQa = 1; break; + case 4: IRQa = 0; X6502_IRQEnd(FCEU_IQEXT); break; + case 5: nt[A & 3] = V; Sync(); break; + } +} + +static void M417Power(void) { + Sync(); + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x8000, 0xFFFF, M417Write); +} + +static void M417IRQHook(int a) { + IRQCount += a; + if (IRQa && IRQCount > 1024) + X6502_IRQBegin(FCEU_IQEXT); +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper417_Init(CartInfo *info) { + info->Power = M417Power; + MapIRQHook = M417IRQHook; + GameStateRestore = StateRestore; + AddExState(&StateRegs, ~0, 0, 0); +} diff --git a/src/boards/432.c b/src/boards/432.c new file mode 100644 index 0000000..777936f --- /dev/null +++ b/src/boards/432.c @@ -0,0 +1,64 @@ +/* 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 + * + * + */ + +#include "mapinc.h" +#include "mmc3.h" + +static void M432CW(uint32 A, uint8 V) { + if (EXPREGS[0] & 4) + setchr1(A, (V & 0x7F) | ((EXPREGS[0] << 7) & 0x80) | ((EXPREGS[0] << 5) & 0x100)); + else + setchr1(A, V | ((EXPREGS[0] << 5) & 0x100)); +} + +static void M432PW(uint32 A, uint8 V) { + if (EXPREGS[0] & 4) + setprg8(A, (V & 0x0F) | ((EXPREGS[0] << 4) & 0x10) | ((EXPREGS[0] << 1) & 0x20)); + else + setprg8(A, (V & 0x1F) | ((EXPREGS[0] << 1) & 0x20)); +} + +static DECLFW(M432Write) { + EXPREGS[0] = V; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); +} + +static void M432Reset(void) { + EXPREGS[0] = 0; + MMC3RegReset(); +} + +static void M432Power(void) { + EXPREGS[0] = 0; + GenMMC3Power(); + SetWriteHandler(0x6000, 0x7FFF, M432Write); +} + +void Mapper432_Init(CartInfo *info) { + GenMMC3_Init(info, 256, 256, 0, 0); + cwrap = M432CW; + pwrap = M432PW; + info->Power = M432Power; + info->Reset = M432Reset; + AddExState(EXPREGS, 1, 0, "EXPR"); +} diff --git a/src/boards/433.c b/src/boards/433.c new file mode 100644 index 0000000..d7c00ca --- /dev/null +++ b/src/boards/433.c @@ -0,0 +1,72 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 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 433 denotes the NC-20MB PCB, used for the 20-in-1 (CA-006) multicart. It is almost identical to INES Mapper 433, except that mirroring is selected just by single bit 6 (1=Horizontal). + */ + +#include "mapinc.h" + +static uint8 latche; + +static SFORMAT StateRegs[] = +{ + { &latche, 1, "LATC" }, + { 0 } +}; + +static void Sync(void) { + if (!(latche & 0x20)) + setprg32(0x8000, (latche & 0x1f) >> 1); + else { + setprg16(0x8000, (latche & 0x1f)); + setprg16(0xC000, (latche & 0x1f)); + } + setmirror(((latche >> 6) & 1) ^ 1); + setchr8(0); +} + +static DECLFW(M433Write) { + latche = V; + Sync(); +} + +static void M433Power(void) { + latche = 0; + Sync(); + SetWriteHandler(0x8000, 0xFFFF, M433Write); + SetReadHandler(0x8000, 0xFFFF, CartBR); +} + +static void StateRestore(int version) { + Sync(); +} + +static void M433Reset(void) { + latche = 0; + Sync(); +} + +void Mapper433_Init(CartInfo *info) { + info->Power = M433Power; + info->Reset = M433Reset; + AddExState(&StateRegs, ~0, 0, 0); + GameStateRestore = StateRestore; +} diff --git a/src/boards/558.c b/src/boards/558.c index c509ba5..9be3ed1 100644 --- a/src/boards/558.c +++ b/src/boards/558.c @@ -24,7 +24,6 @@ #include "mapinc.h" #include "eeprom_93C66.h" -#include "../ines.h" static uint8 *WRAM; static uint32 WRAMSIZE; diff --git a/src/boards/addrlatch.c b/src/boards/addrlatch.c index 10eef4d..9273341 100644 --- a/src/boards/addrlatch.c +++ b/src/boards/addrlatch.c @@ -19,7 +19,6 @@ */ #include "mapinc.h" -#include "../ines.h" static uint16 latche, latcheinit; static uint16 addrreg0, addrreg1; diff --git a/src/boards/bandai.c b/src/boards/bandai.c index 375d2b0..99d04a0 100644 --- a/src/boards/bandai.c +++ b/src/boards/bandai.c @@ -65,116 +65,202 @@ static SFORMAT StateRegs[] = #define X24C0X_READ 3 #define X24C0X_WRITE 4 -static uint8 x24c0x_data[256], x24c0x_state; -static uint8 x24c0x_addr, x24c0x_word, x24c0x_latch, x24c0x_bitcount; -static uint8 x24c0x_sda, x24c0x_scl, x24c0x_out, x24c0x_oe; +static uint8 x24c0x_data[512]; -static SFORMAT x24c0xStateRegs[] = +static uint8 x24c01_state; +static uint8 x24c01_addr, x24c01_word, x24c01_latch, x24c01_bitcount; +static uint8 x24c01_sda, x24c01_scl, x24c01_out; + +static uint8 x24c02_state; +static uint8 x24c02_addr, x24c02_word, x24c02_latch, x24c02_bitcount; +static uint8 x24c02_sda, x24c02_scl, x24c02_out; + +static SFORMAT x24c01StateRegs[] = { - { &x24c0x_addr, 1, "ADDR" }, - { &x24c0x_word, 1, "WORD" }, - { &x24c0x_latch, 1, "LATC" }, - { &x24c0x_bitcount, 1, "BITC" }, - { &x24c0x_sda, 1, "SDA" }, - { &x24c0x_scl, 1, "SCL" }, - { &x24c0x_out, 1, "OUT" }, - { &x24c0x_oe, 1, "OE" }, - { &x24c0x_state, 1, "STAT" }, + { &x24c01_addr, 1, "ADDR" }, + { &x24c01_word, 1, "WORD" }, + { &x24c01_latch, 1, "LATC" }, + { &x24c01_bitcount, 1, "BITC" }, + { &x24c01_sda, 1, "SDA" }, + { &x24c01_scl, 1, "SCL" }, + { &x24c01_out, 1, "OUT" }, + { &x24c01_state, 1, "STAT" }, { 0 } }; -static void x24c0x_init() { - x24c0x_addr = x24c0x_word = x24c0x_latch = x24c0x_bitcount = x24c0x_sda = x24c0x_scl = x24c0x_oe = 0; - x24c0x_state = X24C0X_STANDBY; +static SFORMAT x24c02StateRegs[] = +{ + { &x24c02_addr, 1, "ADDR" }, + { &x24c02_word, 1, "WORD" }, + { &x24c02_latch, 1, "LATC" }, + { &x24c02_bitcount, 1, "BITC" }, + { &x24c02_sda, 1, "SDA" }, + { &x24c02_scl, 1, "SCL" }, + { &x24c02_out, 1, "OUT" }, + { &x24c02_state, 1, "STAT" }, + { 0 } +}; + +static void x24c01_init(void) { + x24c01_addr = x24c01_word = x24c01_latch = x24c01_bitcount = x24c01_sda = x24c01_scl = 0; + x24c01_state = X24C0X_STANDBY; } -static void x24c0x_write(uint8 data) { - uint8 sda = (data >> 6) & 1; - uint8 scl = (data >> 5) & 1; - x24c0x_oe = (data >> 7); +static void x24c02_init(void) { + x24c02_addr = x24c02_word = x24c02_latch = x24c02_bitcount = x24c02_sda = x24c02_scl = 0; + x24c02_state = X24C0X_STANDBY; +} - if(x24c0x_scl && scl) { - if(x24c0x_sda && !sda) { /* START */ - x24c0x_state = X24C0X_ADDRESS; - x24c0x_bitcount = 0; - x24c0x_addr = 0; - } else if(!x24c0x_sda && sda) { /* STOP */ - x24c0x_state = X24C0X_STANDBY; +static void x24c01_write(uint8 data) { + uint8 scl = (data >> 5) & 1; + uint8 sda = (data >> 6) & 1; + + if(x24c01_scl && scl) { + if(x24c01_sda && !sda) { /* START */ + x24c01_state = X24C0X_ADDRESS; + x24c01_bitcount = 0; + x24c01_addr = 0; + } else if(!x24c01_sda && sda) { /* STOP */ + x24c01_state = X24C0X_STANDBY; } - } else if(!x24c0x_scl && scl) { /* RISING EDGE */ - switch(x24c0x_state) { + } else if(!x24c01_scl && scl) { /* RISING EDGE */ + switch(x24c01_state) { case X24C0X_ADDRESS: - if(x24c0x_bitcount < 7) { - x24c0x_addr <<= 1; - x24c0x_addr |= sda; + if(x24c01_bitcount < 7) { + x24c01_addr <<= 1; + x24c01_addr |= sda; } else { - if(!x24c02) /* X24C01 mode */ - x24c0x_word = x24c0x_addr; - if(sda) { /* READ COMMAND */ - x24c0x_state = X24C0X_READ; - } else { /* WRITE COMMAND */ - if(x24c02) /* X24C02 mode */ - x24c0x_state = X24C0X_WORD; - else - x24c0x_state = X24C0X_WRITE; - } + x24c01_word = x24c01_addr; + if(sda) /* READ COMMAND */ + x24c01_state = X24C0X_READ; + else /* WRITE COMMAND */ + x24c01_state = X24C0X_WRITE; } - x24c0x_bitcount++; - break; - case X24C0X_WORD: - if(x24c0x_bitcount == 8) { /* ACK */ - x24c0x_word = 0; - x24c0x_out = 0; - } else { /* WORD ADDRESS INPUT */ - x24c0x_word <<= 1; - x24c0x_word |= sda; - if(x24c0x_bitcount == 16) { /* END OF ADDRESS INPUT */ - x24c0x_bitcount = 7; - x24c0x_state = X24C0X_WRITE; - } - } - x24c0x_bitcount++; + x24c01_bitcount++; break; case X24C0X_READ: - if (x24c0x_bitcount == 8) { /* ACK */ - x24c0x_out = 0; - x24c0x_latch = x24c0x_data[x24c0x_word]; - x24c0x_bitcount = 0; - } else { /* REAL OUTPUT */ - x24c0x_out = x24c0x_latch >> 7; - x24c0x_latch <<= 1; - x24c0x_bitcount++; - if(x24c0x_bitcount == 8) { - x24c0x_word++; - x24c0x_word &= 0xff; + if (x24c01_bitcount == 8) { /* ACK */ + x24c01_out = 0; + x24c01_latch = x24c0x_data[x24c01_word]; + x24c01_bitcount = 0; + } else { /* REAL OUTPUT */ + x24c01_out = x24c01_latch >> 7; + x24c01_latch <<= 1; + x24c01_bitcount++; + if(x24c01_bitcount == 8) { + x24c01_word++; + x24c01_word &= 0xff; } } break; case X24C0X_WRITE: - if (x24c0x_bitcount == 8) { /* ACK */ - x24c0x_out = 0; - x24c0x_latch = 0; - x24c0x_bitcount = 0; - } else { /* REAL INPUT */ - x24c0x_latch <<= 1; - x24c0x_latch |= sda; - x24c0x_bitcount++; - if(x24c0x_bitcount == 8) { - x24c0x_data[x24c0x_word] = x24c0x_latch; - x24c0x_word++; - x24c0x_word &= 0xff; + if (x24c01_bitcount == 8) { /* ACK */ + x24c01_out = 0; + x24c01_latch = 0; + x24c01_bitcount = 0; + } else { /* REAL INPUT */ + x24c01_latch <<= 1; + x24c01_latch |= sda; + x24c01_bitcount++; + if(x24c01_bitcount == 8) { + x24c0x_data[x24c01_word] = x24c01_latch; + x24c01_word++; + x24c01_word &= 0xff; } } break; } } - x24c0x_sda = sda; - x24c0x_scl = scl; + x24c01_sda = sda; + x24c01_scl = scl; } -static uint8 x24c0x_read() { - return x24c0x_out << 4; +static void x24c02_write(uint8 data) { + uint8 scl = (data >> 5) & 1; + uint8 sda = (data >> 6) & 1; + + if (x24c02_scl && scl) { + if (x24c02_sda && !sda) { /* START */ + x24c02_state = X24C0X_ADDRESS; + x24c02_bitcount = 0; + x24c02_addr = 0; + } else if (!x24c02_sda && sda) { /* STOP */ + x24c02_state = X24C0X_STANDBY; + } + } else if (!x24c02_scl && scl) { /* RISING EDGE */ + switch (x24c02_state) { + case X24C0X_ADDRESS: + if (x24c02_bitcount < 7) { + x24c02_addr <<= 1; + x24c02_addr |= sda; + } else { + if (sda) /* READ COMMAND */ + x24c02_state = X24C0X_READ; + else /* WRITE COMMAND */ + x24c02_state = X24C0X_WORD; + } + x24c02_bitcount++; + break; + case X24C0X_WORD: + if (x24c02_bitcount == 8) { /* ACK */ + x24c02_word = 0; + x24c02_out = 0; + } else { /* WORD ADDRESS INPUT */ + x24c02_word <<= 1; + x24c02_word |= sda; + if (x24c02_bitcount == 16) { /* END OF ADDRESS INPUT */ + x24c02_bitcount = 7; + x24c02_state = X24C0X_WRITE; + } + } + x24c02_bitcount++; + break; + case X24C0X_READ: + if (x24c02_bitcount == 8) { /* ACK */ + x24c02_out = 0; + x24c02_latch = x24c0x_data[x24c02_word|0x100]; + x24c02_bitcount = 0; + } else { /* REAL OUTPUT */ + x24c02_out = x24c02_latch >> 7; + x24c02_latch <<= 1; + x24c02_bitcount++; + if (x24c02_bitcount == 8) { + x24c02_word++; + x24c02_word &= 0xff; + } + } + break; + case X24C0X_WRITE: + if (x24c02_bitcount == 8) { /* ACK */ + x24c02_out = 0; + x24c02_latch = 0; + x24c02_bitcount = 0; + } else { /* REAL INPUT */ + x24c02_latch <<= 1; + x24c02_latch |= sda; + x24c02_bitcount++; + if (x24c02_bitcount == 8) { + x24c0x_data[x24c02_word|0x100] = x24c02_latch; + x24c02_word++; + x24c02_word &= 0xff; + } + } + break; + } + } + + x24c02_sda = sda; + x24c02_scl = scl; +} + +static void SyncMirror(void) { + switch (reg[9] & 3) { + case 0: setmirror(MI_V); break; + case 1: setmirror(MI_H); break; + case 2: setmirror(MI_0); break; + case 3: setmirror(MI_1); break; + } } static void Sync(void) { @@ -189,12 +275,7 @@ static void Sync(void) { setprg16(0x8000, reg[8]); setprg16(0xC000, ~0); } - switch (reg[9] & 3) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } + SyncMirror(); } static DECLFW(BandaiWrite) { @@ -207,12 +288,20 @@ static DECLFW(BandaiWrite) { case 0x0A: X6502_IRQEnd(FCEU_IQEXT); IRQa = V & 1; IRQCount = IRQLatch; break; case 0x0B: IRQLatch &= 0xFF00; IRQLatch |= V; break; case 0x0C: IRQLatch &= 0xFF; IRQLatch |= V << 8; break; - case 0x0D: x24c0x_write(V); break; + case 0x0D: + if (x24c02) + x24c02_write(V); + else + x24c01_write(V); + break; } } static DECLFR(BandaiRead) { - return (X.DB & 0xEF) | x24c0x_read(); + if (x24c02) + return (X.DB & 0xEF) | (x24c02_out << 4); + else + return (X.DB & 0xEF) | (x24c01_out << 4); } static void FP_FASTAPASS(1) BandaiIRQHook(int a) { @@ -228,7 +317,10 @@ static void FP_FASTAPASS(1) BandaiIRQHook(int a) { static void BandaiPower(void) { IRQa = 0; - x24c0x_init(); + if (x24c02) + x24c02_init(); + else + x24c01_init(); Sync(); SetReadHandler(0x6000, 0x7FFF, BandaiRead); SetReadHandler(0x8000, 0xFFFF, CartBR); @@ -246,12 +338,12 @@ void Mapper16_Init(CartInfo *info) { MapIRQHook = BandaiIRQHook; info->battery = 1; - info->SaveGame[0] = x24c0x_data; + info->SaveGame[0] = x24c0x_data + 256; info->SaveGameLen[0] = 256; AddExState(x24c0x_data, 256, 0, "DATA"); GameStateRestore = StateRestore; - AddExState(&x24c0xStateRegs, ~0, 0, 0); + AddExState(&x24c02StateRegs, ~0, 0, 0); AddExState(&StateRegs, ~0, 0, 0); } @@ -267,7 +359,7 @@ void Mapper159_Init(CartInfo *info) { AddExState(x24c0x_data, 128, 0, "DATA"); GameStateRestore = StateRestore; - AddExState(&x24c0xStateRegs, ~0, 0, 0); + AddExState(&x24c01StateRegs, ~0, 0, 0); AddExState(&StateRegs, ~0, 0, 0); } @@ -323,7 +415,9 @@ static int BarcodeReadPos; static int BarcodeCycleCount; static uint32 BarcodeOut; -int FCEUI_DatachSet(const uint8 *rcode) { +/* #define INTERL2OF5 */ + +int FCEUI_DatachSet(uint8 *rcode) { int prefix_parity_type[10][6] = { { 0, 0, 0, 0, 0, 0 }, { 0, 0, 1, 0, 1, 1 }, { 0, 0, 1, 1, 0, 1 }, { 0, 0, 1, 1, 1, 0 }, { 0, 1, 0, 0, 1, 1 }, { 0, 1, 1, 0, 0, 1 }, { 0, 1, 1, 1, 0, 0 }, { 0, 1, 0, 1, 0, 1 }, @@ -346,6 +440,7 @@ int FCEUI_DatachSet(const uint8 *rcode) { }; uint8 code[13 + 1]; uint32 tmp_p = 0; + uint32 csum = 0; int i, j; int len; @@ -359,15 +454,45 @@ int FCEUI_DatachSet(const uint8 *rcode) { #define BS(x) BarcodeData[tmp_p] = x; tmp_p++ - for (j = 0; j < 32; j++) { + for (j = 0; j < 32; j++) { /* delay before sending a code */ BS(0x00); } +#ifdef INTERL2OF5 + + BS(1); BS(1); BS(0); BS(0); /* 1 */ + BS(1); BS(1); BS(0); BS(0); /* 1 */ + BS(1); BS(1); BS(0); BS(0); /* 1 */ + BS(1); BS(1); BS(0); BS(0); /* 1 */ + BS(1); BS(1); BS(0); BS(0); /* 1 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 */ + BS(1); BS(0); BS(0); /* 0 cs */ + BS(1); BS(1); BS(0); BS(0); /* 1 */ + +#else /* Left guard bars */ BS(1); BS(0); BS(1); if (len == 13 || len == 12) { - uint32 csum; for (i = 0; i < 6; i++) if (prefix_parity_type[code[0]][i]) { @@ -386,24 +511,25 @@ int FCEUI_DatachSet(const uint8 *rcode) { for (j = 0; j < 7; j++) { BS(data_right[code[i]][j]); } - csum = 0; - for (i = 0; i < 12; i++) csum += code[i] * ((i & 1) ? 3 : 1); - csum = (10 - (csum % 10)) % 10; + /* Calc and write down the control code if not assigned, instead, send code as is + Battle Rush uses modified type of codes with different control code calculation */ + if (len == 12) { + for (i = 0; i < 12; i++) + csum += code[i] * ((i & 1) ? 3 : 1); + csum = (10 - (csum % 10)) % 10; + rcode[12] = csum + 0x30; /* update check code to the input string as well */ + rcode[13] = 0; + code[12] = csum; + } for (j = 0; j < 7; j++) { - BS(data_right[csum][j]); + BS(data_right[code[12]][j]); } } else if (len == 8 || len == 7) { - uint32 csum = 0; - - for (i = 0; i < 7; i++) csum += (i & 1) ? code[i] : (code[i] * 3); - - csum = (10 - (csum % 10)) % 10; - - for (i = 0; i < 4; i++) + for (i = 0; i < 4; i++) { for (j = 0; j < 7; j++) { BS(data_left_odd[code[i]][j]); } - + } /* Center guard bars */ BS(0); BS(1); BS(0); BS(1); BS(0); @@ -412,7 +538,12 @@ int FCEUI_DatachSet(const uint8 *rcode) { for (j = 0; j < 7; j++) { BS(data_right[code[i]][j]); } - + csum = 0; + for (i = 0; i < 7; i++) + csum += (i & 1) ? code[i] : (code[i] * 3); + csum = (10 - (csum % 10)) % 10; + rcode[7] = csum + 0x30; /* update check code to the input string as well */ + rcode[8] = 0; for (j = 0; j < 7; j++) { BS(data_right[csum][j]); } @@ -420,6 +551,7 @@ int FCEUI_DatachSet(const uint8 *rcode) { /* Right guard bars */ BS(1); BS(0); BS(1); +#endif for (j = 0; j < 32; j++) { BS(0x00); @@ -435,6 +567,26 @@ int FCEUI_DatachSet(const uint8 *rcode) { return(1); } +static void BarcodeSync(void) { + setchr8(0); + setprg16(0x8000, (reg[8] & 0x0F)); + setprg16(0xC000, 0x0F); + SyncMirror(); +} + +static DECLFW(BarcodeWrite) { + A &= 0x0F; + switch (A) { + case 0x00: reg[0] = (V & 8) << 2; x24c01_write(reg[0xD] | reg[0]); break; /* extra EEPROM x24C01 used in Battle Rush mini-cart */ + case 0x08: + case 0x09: reg[A] = V; BarcodeSync(); break; + case 0x0A: X6502_IRQEnd(FCEU_IQEXT); IRQa = V & 1; IRQCount = IRQLatch; break; + case 0x0B: IRQLatch &= 0xFF00; IRQLatch |= V; break; + case 0x0C: IRQLatch &= 0xFF; IRQLatch |= V << 8; break; + case 0x0D: reg[0xD] = V & (~0x20); x24c01_write(reg[0xD] | reg[0]); x24c02_write(V); break; + } +} + static void FP_FASTAPASS(1) BarcodeIRQHook(int a) { BandaiIRQHook(a); @@ -452,7 +604,7 @@ static void FP_FASTAPASS(1) BarcodeIRQHook(int a) { } static DECLFR(BarcodeRead) { - return BarcodeOut; + return (X.DB & 0xE7) | ((x24c02_out | x24c01_out) << 4) | BarcodeOut; } static void M157Power(void) { @@ -462,20 +614,27 @@ static void M157Power(void) { BarcodeOut = 0; BarcodeCycleCount = 0; - Sync(); + x24c01_init(); + x24c02_init(); + BarcodeSync(); - SetWriteHandler(0x6000, 0xFFFF, BandaiWrite); SetReadHandler(0x6000, 0x7FFF, BarcodeRead); SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x8000, 0xFFFF, BarcodeWrite); } void Mapper157_Init(CartInfo *info) { - is153 = 1; + x24c02 = 1; info->Power = M157Power; MapIRQHook = BarcodeIRQHook; GameInfo->cspecial = SIS_DATACH; - + info->battery = 1; + info->SaveGame[0] = x24c0x_data; + info->SaveGameLen[0] = 512; GameStateRestore = StateRestore; + AddExState(x24c0x_data, 512, 0, "DATA"); + AddExState(&x24c01StateRegs, ~0, 0, 0); + AddExState(&x24c02StateRegs, ~0, 0, 0); AddExState(&StateRegs, ~0, 0, 0); } diff --git a/src/boards/bmc42in1r.c b/src/boards/bmc42in1r.c index 3ac92b8..8675bbb 100644 --- a/src/boards/bmc42in1r.c +++ b/src/boards/bmc42in1r.c @@ -18,21 +18,16 @@ * 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 - * - * BMC 42-in-1 "reset switch" + "select switch" - * */ /* Updated 2019-07-12 - * Mapper 266 - Updated and combine UNIF Ghostbusters63in1 board (1.5 MB carts), different bank order + * Mapper 226 - Updated and combine UNIF Ghostbusters63in1 board (1.5 MB carts), different bank order * - some 1MB carts can switch game lists using Select - * Mapper 233 - UNIF 42in1ResetSwitch - reset-based switching */ #include "mapinc.h" static uint8 reorder_banks = 0; -static uint8 isresetbased = 0; static uint8 latche[2], reset; static uint8 banks[4] = { 0, 0, 1, 2 }; static SFORMAT StateRegs[] = @@ -46,13 +41,9 @@ static void Sync(void) { uint8 bank = 0; uint8 base = ((latche[0] & 0x80) >> 7) | ((latche[1] & 1) << 1); - if (isresetbased) - bank = (latche[0] & 0x1f) | (reset << 5) | ((latche[1] & 1) << 6); - else { - if (reorder_banks) /* for 1536 KB prg roms */ - base = banks[base]; - bank = (base << 5) | (latche[0] & 0x1f); - } + if (reorder_banks) /* for 1536 KB prg roms */ + base = banks[base]; + bank = (base << 5) | (latche[0] & 0x1f); if (!(latche[0] & 0x20)) setprg32(0x8000, bank >> 1); @@ -70,7 +61,7 @@ static DECLFW(M226Write) { } static void M226Power(void) { - latche[0] = latche[1] = reset = 0; + latche[0] = latche[1] = 0; Sync(); SetWriteHandler(0x8000, 0xFFFF, M226Write); SetReadHandler(0x8000, 0xFFFF, CartBR); @@ -81,12 +72,11 @@ static void StateRestore(int version) { } static void M226Reset(void) { - latche[0] = latche[1] = reset = 0; + latche[0] = latche[1] = 0; Sync(); } void Mapper226_Init(CartInfo *info) { - isresetbased = 0; /* 1536KiB PRG roms have different bank order */ reorder_banks = ((info->PRGRomSize / 1024) == 1536) ? 1 : 0; info->Power = M226Power; @@ -94,18 +84,3 @@ void Mapper226_Init(CartInfo *info) { AddExState(&StateRegs, ~0, 0, 0); GameStateRestore = StateRestore; } - -static void M233Reset(void) { - latche[0] = latche[1] = 0; - reset ^= 1; - Sync(); -} - -void Mapper233_Init(CartInfo *info) { - reorder_banks = 0; - isresetbased = 1; - info->Power = M226Power; - info->Reset = M233Reset; - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore = StateRestore; -} diff --git a/src/boards/bmc80013b.c b/src/boards/bmc80013b.c index a58c77d..6bd8460 100644 --- a/src/boards/bmc80013b.c +++ b/src/boards/bmc80013b.c @@ -24,7 +24,6 @@ /* 2020-03-22 - Update support for Cave Story II, FIXME: Arabian does not work for some reasons... */ #include "mapinc.h" -#include "../ines.h" static uint8 regs[2], mode; diff --git a/src/boards/cheapocabra.c b/src/boards/cheapocabra.c index 7730941..4535986 100644 --- a/src/boards/cheapocabra.c +++ b/src/boards/cheapocabra.c @@ -31,7 +31,6 @@ */ #include "mapinc.h" -#include "../ines.h" static uint8 reg; static uint8 *CHRRAM = NULL; diff --git a/src/boards/datalatch.c b/src/boards/datalatch.c index f547344..c86d585 100644 --- a/src/boards/datalatch.c +++ b/src/boards/datalatch.c @@ -19,7 +19,6 @@ */ #include "mapinc.h" -#include "../ines.h" #include "../fds_apu.h" static uint8 latche, latcheinit, bus_conflict; @@ -587,3 +586,22 @@ void Mapper429_Init(CartInfo *info) { info->Reset = Mapper429_Reset; Latch_Init(info, Mapper429_Sync, 0, 0x8000, 0xFFFF, 0, 0); } + +/*------------------ Mapper 415 ---------------------------*/ + +static void Mapper415_Sync(void) { + setprg8(0x6000, latche & 0x0F); + setprg32(0x8000, ~0); + setchr8(0); + setmirror(((latche >> 4) & 1) ^ 1); +} + +static void M415Power(void) { + LatchPower(); + SetReadHandler(0x6000, 0x7FFF, CartBR); +} + +void Mapper415_Init(CartInfo *info) { + Latch_Init(info, Mapper415_Sync, 0, 0x8000, 0xFFFF, 0, 0); + info->Power = M415Power; +} diff --git a/src/boards/hp10xx_hp20xx.c b/src/boards/hp10xx_hp20xx.c index c18c9d1..496c1e0 100644 --- a/src/boards/hp10xx_hp20xx.c +++ b/src/boards/hp10xx_hp20xx.c @@ -20,7 +20,6 @@ #include "mapinc.h" #include "mmc3.h" -#include "../ines.h" /* added on 2019-5-23 - NES 2.0 Mapper 260 * HP10xx/HP20xx - a simplified version of FK23C mapper with pretty strict and better diff --git a/src/boards/mapinc.h b/src/boards/mapinc.h index 8376a0c..ba3964d 100644 --- a/src/boards/mapinc.h +++ b/src/boards/mapinc.h @@ -8,4 +8,5 @@ #include "../cart.h" #include "../cheat.h" #include "../unif.h" +#include "../ines.h" #include diff --git a/src/boards/mmc1.c b/src/boards/mmc1.c index e30ba53..126364a 100644 --- a/src/boards/mmc1.c +++ b/src/boards/mmc1.c @@ -681,3 +681,47 @@ void Mapper550_Init(CartInfo *info) { AddExState(&latch, 1, 0, "LATC"); AddExState(&outerBank, 1, 0, "BANK"); } + +/* ---------------------------- Mapper 404 -------------------------------- */ + +/* NES 2.0 Mapper 404 - JY012005 + * 1998 Super HiK 8-in-1 (JY-021B)*/ + +static uint8_t outerBank; + +static void M404PRG16(uint32 A, uint8 V) { + uint8 mask = outerBank & 0x40 ? 0x07 : 0x0F; + setprg16(A, (V & mask) | (outerBank << 3) & ~mask); +} + +static void M404CHR4(uint32 A, uint8 V) { + setchr4(A, (V & 0x1F) | outerBank << 5); +} + +static DECLFW(M404Write) { + if (!(outerBank & 0x80)) { + outerBank = V; + MMC1PRG(); + MMC1CHR(); + } +} + +static void M404Reset(void) { + outerBank = 0; + MMC1CMReset(); +} + +static void M404Power(void) { + outerBank = 0; + GenMMC1Power(); + SetWriteHandler(0x6000, 0x7FFF, M404Write); +} + +void Mapper404_Init(CartInfo *info) { + GenMMC1Init(info, 256, 256, 0, 0); + info->Power = M404Power; + info->Reset = M404Reset; + MMC1CHRHook4 = M404CHR4; + MMC1PRGHook16 = M404PRG16; + AddExState(&outerBank, 1, 0, "BANK"); +} \ No newline at end of file diff --git a/src/boards/mmc3.c b/src/boards/mmc3.c index 25e6f51..d2c905d 100644 --- a/src/boards/mmc3.c +++ b/src/boards/mmc3.c @@ -28,20 +28,17 @@ #include "mmc3.h" uint8 MMC3_cmd; -uint8 *WRAM; -uint32 WRAMSIZE; -uint8 *CHRRAM; -uint32 CHRRAMSIZE; +static uint8 *WRAM; +static uint32 WRAMSIZE; +static uint8 *CHRRAM; +static uint32 CHRRAMSIZE; uint8 DRegBuf[8]; uint8 EXPREGS[8]; /* For bootleg games, mostly. */ uint8 A000B, A001B; uint8 mmc3opts = 0; -#undef IRQCount -#undef IRQLatch -#undef IRQa -uint8 IRQCount, IRQLatch, IRQa; -uint8 IRQReload; +static uint8 IRQCount, IRQLatch, IRQa; +static uint8 IRQReload; static SFORMAT MMC3_StateRegs[] = { diff --git a/src/boards/mmc3.h b/src/boards/mmc3.h index 2479f9d..b29a53e 100644 --- a/src/boards/mmc3.h +++ b/src/boards/mmc3.h @@ -8,12 +8,6 @@ extern uint8 A001B; extern uint8 EXPREGS[8]; extern uint8 DRegBuf[8]; -#undef IRQCount -#undef IRQLatch -#undef IRQa -extern uint8 IRQCount, IRQLatch, IRQa; -extern uint8 IRQReload; - extern void (*pwrap)(uint32 A, uint8 V); extern void (*cwrap)(uint32 A, uint8 V); extern void (*mwrap)(uint8 V); diff --git a/src/boards/unrom512.c b/src/boards/unrom512.c index 3a1961f..ca3f63b 100644 --- a/src/boards/unrom512.c +++ b/src/boards/unrom512.c @@ -35,7 +35,6 @@ */ #include "mapinc.h" -#include "../ines.h" /* Workaround for libretro api compatibility */ #define ROM_size_max 32 diff --git a/src/driver.h b/src/driver.h index 7e63d29..9529bc4 100644 --- a/src/driver.h +++ b/src/driver.h @@ -235,7 +235,7 @@ int FCEUI_FDSInsert(int oride); int FCEUI_FDSEject(void); void FCEUI_FDSSelect(void); -int FCEUI_DatachSet(const uint8 *rcode); +int FCEUI_DatachSet(uint8 *rcode); #ifdef __cplusplus } diff --git a/src/ines.c b/src/ines.c index e75a052..c417a7a 100644 --- a/src/ines.c +++ b/src/ines.c @@ -553,7 +553,6 @@ INES_BOARD_BEGIN() /* INES_BOARD( "", 131, Mapper131_Init ) */ INES_BOARD( "TXC/UNL-22211", 132, Mapper132_Init ) INES_BOARD( "SA72008", 133, SA72008_Init ) -/* INES_BOARD( "MMC3 BMC PIRATE", 134, Mapper134_Init ) */ INES_BOARD( "MMC3 BMC PIRATE", 134, Bs5652_Init ) /* INES_BOARD( "", 135, Mapper135_Init ) */ INES_BOARD( "Sachen 3011", 136, Mapper136_Init ) @@ -677,50 +676,7 @@ INES_BOARD_BEGIN() INES_BOARD( "", 254, Mapper254_Init ) INES_BOARD( "", 255, Mapper255_Init ) /* Duplicate of M225? */ - /* NES 2.0 BOARDS THAT DO NOT HAVE UNIF ASSOCIATION */ - - INES_BOARD( "8-in-1 JY-119", 267, Mapper267_Init ) - INES_BOARD( "Games Xplosion 121-in-1", 269, Mapper269_Init ) - INES_BOARD( "YY860417C", 281, Mapper281_Init ) - INES_BOARD( "860224C", 282, Mapper282_Init ) - INES_BOARD( "GKCX1", 288, Mapper288_Init ) - INES_BOARD( "MMC3 BMC PIRATE", 294, Bs5652_Init ) /* nesdev redirects this as mapper 134 */ - INES_BOARD( "TXC 01-22110-000", 297, Mapper297_Init ) - INES_BOARD( "Super Mario Family", 353, Mapper353_Init ) - INES_BOARD( "7-in-1 Rockman (JY-208)", 356, Mapper356_Init ) - INES_BOARD( "Bit Corp 4-in-1", 357, Mapper357_Init ) - INES_BOARD( "SB-5013/GCL8050/841242C", 359, Mapper359_Init ) - INES_BOARD( "Bitcorp 31-in-1", 360, Mapper360_Init ) - INES_BOARD( "OK-411", 361, GN45_Init ) /* OK-411 is emulated together with GN-45 */ - INES_BOARD( "GN-45", 366, GN45_Init ) - INES_BOARD( "Golden Mario Party II - Around the World 6-in-1", 370, Mapper370_Init ) - INES_BOARD( "MMC3 PIRATE SFC-12", 372, Mapper372_Init ) - INES_BOARD( "95/96 Super HiK 4-in-1", 374, Mapper374_Init ) - INES_BOARD( "YY841155C", 376, Mapper376_Init ) - INES_BOARD( "42 to 80,000 (970630C)", 380, Mapper380_Init ) - INES_BOARD( "KN-42", 381, Mapper381_Init ) - INES_BOARD( "830928C", 382, Mapper382_Init ) - INES_BOARD( "YY840708C", 383, Mapper383_Init ) - INES_BOARD( "Caltron 9-in-1", 389, Mapper389_Init ) - INES_BOARD( "Realtec 8031", 390, Mapper390_Init ) - INES_BOARD( "NewStar 12-in-1/7-in-1", 293, Mapper293_Init ) - INES_BOARD( "Realtec 8210", 395, Mapper395_Init ) - INES_BOARD( "BMC Super 19-in-1 (VIP19)", 401, Mapper401_Init ) - INES_BOARD( "89433", 403, Mapper403_Init ) - INES_BOARD( "A88S-1", 411, Mapper411_Init ) - INES_BOARD( "BS-400R/BS-4040", 422, Mapper422_Init ) - INES_BOARD( "Brilliant Com Cocoma Pack", 516, Mapper516_Init ) - INES_BOARD( "Sachen 3014", 533, Mapper533_Init ) - INES_BOARD( "NJ064", 534, Mapper534_Init ) - INES_BOARD( "60-1064-16L (FDS)", 538, Mapper538_Init ) - INES_BOARD( "Kid Ikarus (FDS)", 539, Mapper539_Init ) - INES_BOARD( "82112C", 540, Mapper540_Init ) - INES_BOARD( "LittleCom 160-in-1", 541, Mapper541_Init ) - INES_BOARD( "5-in-1 (CH-501)", 543, Mapper543_Init ) - INES_BOARD( "KS-7010", 554, Mapper554_Init ) - INES_BOARD( "", 550, Mapper550_Init ) - - /* UNIF to NES 2.0 BOARDS */ + /* NES 2.0 MAPPERS */ INES_BOARD( "OneBus", 256, UNLOneBus_Init ) INES_BOARD( "158B", 258, UNL158B_Init ) @@ -732,17 +688,24 @@ INES_BOARD_BEGIN() INES_BOARD( "YOKO", 264, UNLYOKO_Init ) INES_BOARD( "T-262", 265, BMCT262_Init ) INES_BOARD( "CITYFIGHT", 266, UNLCITYFIGHT_Init ) + INES_BOARD( "8-in-1 JY-119", 267, Mapper267_Init ) INES_BOARD( "COOLBOY/MINDKIDS", 268, Mapper268_Init ) /* Submapper distinguishes between COOLBOY and MINDKIDS */ + INES_BOARD( "Games Xplosion 121-in-1", 269, Mapper269_Init ) INES_BOARD( "80013-B", 274, BMC80013B_Init ) + INES_BOARD( "YY860417C", 281, Mapper281_Init ) + INES_BOARD( "860224C", 282, Mapper282_Init ) INES_BOARD( "GS-2004/GS-2013", 283, Mapper283_Init ) INES_BOARD( "A65AS", 285, BMCA65AS_Init ) INES_BOARD( "BS-5", 286, BMCBS5_Init ) - INES_BOARD( "411120-C", 287, BMC411120C_Init ) -/* INES_BOARD( "K-3088", 287, BMCK3088_Init ) */ + INES_BOARD( "411120-C, 811120-C", 287, BMC411120C_Init ) + INES_BOARD( "GKCX1", 288, Mapper288_Init ) INES_BOARD( "60311C", 289, BMC60311C_Init ) INES_BOARD( "NTD-03", 290, BMCNTD03_Init ) INES_BOARD( "DRAGONFIGHTER", 292, UNLBMW8544_Init ) + INES_BOARD( "NewStar 12-in-1/7-in-1", 293, Mapper293_Init ) + INES_BOARD( "MMC3 BMC PIRATE", 294, Bs5652_Init ) /* nesdev redirects this as mapper 134 */ INES_BOARD( "YY860216C", 295, Mapper295_Init ) + INES_BOARD( "TXC 01-22110-000", 297, Mapper297_Init ) INES_BOARD( "TF1201", 298, UNLTF1201_Init ) INES_BOARD( "11160", 299, BMC11160_Init ) INES_BOARD( "190in1", 300, BMC190in1_Init ) @@ -771,6 +734,7 @@ INES_BOARD_BEGIN() INES_BOARD( "12-IN-1", 331, BMC12IN1_Init ) INES_BOARD( "WS", 332, BMCWS_Init ) INES_BOARD( "NEWSTAR-GRM070-8IN1", 333, BMC8IN1_Init ) + INES_BOARD( "5/20-in-1 1993 Copyright", 334, Mapper334_Init ) INES_BOARD( "CTC-09", 335, BMCCTC09_Init ) INES_BOARD( "K-3046", 336, BMCK3046_Init ) INES_BOARD( "CTC-12IN1", 337, BMCCTC12IN1_Init ) @@ -785,18 +749,52 @@ INES_BOARD_BEGIN() INES_BOARD( "830118C", 348, BMC830118C_Init ) INES_BOARD( "G-146", 349, BMCG146_Init ) INES_BOARD( "891227", 350, BMC891227_Init ) + INES_BOARD( "Super Mario Family", 353, Mapper353_Init ) INES_BOARD( "3D-BLOCK", 355, UNL3DBlock_Init ) + INES_BOARD( "7-in-1 Rockman (JY-208)", 356, Mapper356_Init ) + INES_BOARD( "Bit Corp 4-in-1", 357, Mapper357_Init ) INES_BOARD( "YY860606C", 358, Mapper358_Init ) + INES_BOARD( "SB-5013/GCL8050/841242C", 359, Mapper359_Init ) + INES_BOARD( "Bitcorp 31-in-1", 360, Mapper360_Init ) + INES_BOARD( "OK-411", 361, GN45_Init ) /* OK-411 is emulated together with GN-45 */ + INES_BOARD( "JY830832C", 364, Mapper364_Init ) + INES_BOARD( "GN-45", 366, GN45_Init ) + INES_BOARD( "Yung-08", 368, Mapper368_Init ) INES_BOARD( "N49C-300", 369, Mapper369_Init ) + INES_BOARD( "Golden Mario Party II - Around the World 6-in-1", 370, Mapper370_Init ) + INES_BOARD( "MMC3 PIRATE SFC-12", 372, Mapper372_Init ) + INES_BOARD( "95/96 Super HiK 4-in-1", 374, Mapper374_Init ) + INES_BOARD( "YY841155C", 376, Mapper376_Init ) + INES_BOARD( "JY-111/JY-112", 377, Mapper377_Init ) + INES_BOARD( "42 to 80,000 (970630C)", 380, Mapper380_Init ) + INES_BOARD( "KN-42", 381, Mapper381_Init ) + INES_BOARD( "830928C", 382, Mapper382_Init ) + INES_BOARD( "YY840708C", 383, Mapper383_Init ) INES_BOARD( "YY860729C", 386, Mapper386_Init ) INES_BOARD( "YY850735C", 387, Mapper387_Init ) INES_BOARD( "YY850835C", 388, Mapper388_Init ) + INES_BOARD( "Caltron 9-in-1", 389, Mapper389_Init ) + INES_BOARD( "Realtec 8031", 390, Mapper390_Init ) INES_BOARD( "BS-110", 391, Mapper391_Init ) + INES_BOARD( "820720C", 393, Mapper393_Init ) + INES_BOARD( "Realtec 8210", 395, Mapper395_Init ) + INES_BOARD( "YY850437C", 396, Mapper396_Init ) INES_BOARD( "YY850439C", 397, Mapper397_Init ) + INES_BOARD( "BMC Super 19-in-1 (VIP19)", 401, Mapper401_Init ) INES_BOARD( "831019C J-2282", 402, J2282_Init ) + INES_BOARD( "89433", 403, Mapper403_Init ) + INES_BOARD( "JY012005", 404, Mapper404_Init ) + INES_BOARD( "JY-302", 410, Mapper410_Init ) + INES_BOARD( "A88S-1", 411, Mapper411_Init ) + INES_BOARD( "0353", 415, Mapper415_Init ) + INES_BOARD( "4-in-1/N-32", 416, Mapper416_Init ) + INES_BOARD( "", 417, Mapper417_Init ) INES_BOARD( "SC871115C", 421, Mapper421_Init ) + INES_BOARD( "BS-400R/BS-4040", 422, Mapper422_Init ) INES_BOARD( "AB-G1L/WELL-NO-DG450", 428, Mapper428_Init ) INES_BOARD( "LIKO BBG-235-8-1B", 429, Mapper429_Init ) + INES_BOARD( "Realtec 8090", 432, Mapper432_Init ) + INES_BOARD( "NC-20MB", 433, Mapper433_Init ) INES_BOARD( "S-009", 434, Mapper434_Init ) INES_BOARD( "820401/T-217", 436, Mapper436_Init ) INES_BOARD( "NTDEC TH2348", 437, Mapper437_Init ) @@ -806,6 +804,7 @@ INES_BOARD_BEGIN() INES_BOARD( "DS-9-27", 452, Mapper452_Init ) INES_BOARD( "K6C3001A", 456, Mapper456_Init ) INES_BOARD( "SA-9602B", 513, SA9602B_Init ) + INES_BOARD( "Brilliant Com Cocoma Pack", 516, Mapper516_Init ) INES_BOARD( "DANCE2000", 518, UNLD2000_Init ) INES_BOARD( "EH8813A", 519, UNLEH8813A_Init ) INES_BOARD( "DREAMTECH01", 521, DreamTech01_Init ) @@ -817,8 +816,17 @@ INES_BOARD_BEGIN() INES_BOARD( "AX-40G", 527, UNLAX40G_Init ) INES_BOARD( "T-230", 529, UNLT230_Init ) INES_BOARD( "AX5705", 530, UNLAX5705_Init ) + INES_BOARD( "Sachen 3014", 533, Mapper533_Init ) + INES_BOARD( "NJ064", 534, Mapper534_Init ) INES_BOARD( "LH53", 535, LH53_Init ) + INES_BOARD( "60-1064-16L (FDS)", 538, Mapper538_Init ) + INES_BOARD( "Kid Ikarus (FDS)", 539, Mapper539_Init ) + INES_BOARD( "82112C", 540, Mapper540_Init ) + INES_BOARD( "LittleCom 160-in-1", 541, Mapper541_Init ) + INES_BOARD( "5-in-1 (CH-501)", 543, Mapper543_Init ) INES_BOARD( "SACHEN 3013", 553, Mapper553_Init ) + INES_BOARD( "KS-7010", 554, Mapper554_Init ) + INES_BOARD( "", 550, Mapper550_Init ) INES_BOARD( "YC-03-09", 558, Mapper558_Init ) INES_BOARD_END() @@ -1035,7 +1043,9 @@ int iNESLoad(const char *name, FCEUFILE *fp) SetupCartPRGMapping(0, ROM, rom_size_pow2, 0); SetInput(); - CheckHInfo(); + + if (iNESCart.iNES2 < 1) + CheckHInfo(); { int x; diff --git a/src/ines.h b/src/ines.h index 0e95552..90f3fa6 100644 --- a/src/ines.h +++ b/src/ines.h @@ -262,17 +262,21 @@ void Mapper288_Init(CartInfo *); void Mapper293_Init(CartInfo *); void Mapper297_Init(CartInfo *); void Mapper319_Init(CartInfo *); +void Mapper334_Init(CartInfo *); void Mapper353_Init(CartInfo *); void Mapper356_Init(CartInfo *); void Mapper357_Init(CartInfo *); void Mapper358_Init(CartInfo *); void Mapper359_Init(CartInfo *); void Mapper360_Init(CartInfo *); +void Mapper364_Init(CartInfo *); +void Mapper368_Init(CartInfo *); void Mapper369_Init(CartInfo *); void Mapper370_Init(CartInfo *); void Mapper372_Init(CartInfo *); void Mapper374_Init(CartInfo *); void Mapper376_Init(CartInfo *); +void Mapper377_Init(CartInfo *); void Mapper380_Init(CartInfo *); void Mapper381_Init(CartInfo *); void Mapper382_Init(CartInfo *); @@ -283,15 +287,24 @@ void Mapper388_Init(CartInfo *); void Mapper389_Init(CartInfo *); void Mapper390_Init(CartInfo *); void Mapper391_Init(CartInfo *); +void Mapper393_Init(CartInfo *); void Mapper395_Init(CartInfo *); +void Mapper396_Init(CartInfo *); void Mapper397_Init(CartInfo *); void Mapper401_Init(CartInfo *); void Mapper403_Init(CartInfo *); +void Mapper404_Init(CartInfo *); +void Mapper410_Init(CartInfo *); void Mapper411_Init(CartInfo *); +void Mapper415_Init(CartInfo *); +void Mapper416_Init(CartInfo *); +void Mapper417_Init(CartInfo *); void Mapper421_Init(CartInfo *); void Mapper422_Init(CartInfo *); void Mapper428_Init(CartInfo *); void Mapper429_Init(CartInfo *); +void Mapper432_Init(CartInfo *); +void Mapper433_Init(CartInfo *); void Mapper434_Init(CartInfo *); void Mapper436_Init(CartInfo *); void Mapper437_Init(CartInfo *); diff --git a/src/unif.c b/src/unif.c index c6dc25c..5ce0560 100644 --- a/src/unif.c +++ b/src/unif.c @@ -616,6 +616,7 @@ static BMAPPING bmap[] = { { "SB-5013", 359, Mapper359_Init, 0 }, { "82112C", 540, Mapper540_Init, 0 }, { "N49C-300", 369, Mapper369_Init, 0 }, + { "830752C", 396, Mapper396_Init, 0 }, { "BS-400R", 422, Mapper422_Init, 0 }, { "BS-4040R", 422, Mapper422_Init, 0 },