From 3f20020b9620aef6b094725af927cf428c7590e8 Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Wed, 9 Mar 2022 14:36:00 +0100 Subject: [PATCH 01/11] Mapper 49: Correct AND mask in NROM mode. --- src/boards/mmc3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/boards/mmc3.c b/src/boards/mmc3.c index 00f770c..633f0b5 100644 --- a/src/boards/mmc3.c +++ b/src/boards/mmc3.c @@ -597,7 +597,7 @@ static void M49PW(uint32 A, uint8 V) { V |= (EXPREGS[0] & 0xC0) >> 2; setprg8(A, V); } else - setprg32(0x8000, (EXPREGS[0] >> 4) & 3); + setprg32(0x8000, (EXPREGS[0] >> 4) & 15); } static void M49CW(uint32 A, uint8 V) { From c01250c28d3bb751a131419ea4c308046dc82963 Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Mon, 21 Mar 2022 15:31:21 +0100 Subject: [PATCH 02/11] Mapper 340: Add support for 1 MiB variant --- src/boards/bmck3036.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/src/boards/bmck3036.c b/src/boards/bmck3036.c index bd72ca3..73e03eb 100644 --- a/src/boards/bmck3036.c +++ b/src/boards/bmck3036.c @@ -18,41 +18,31 @@ * */ -/* NES 2.0 mapper 340 is used for a 35-in-1 multicart. - * Its UNIF board name is BMC-K-3036. - * http://wiki.nesdev.com/w/index.php/NES_2.0_Mapper_340 - * TODO: Some games are not working... - */ - #include "mapinc.h" -static uint8 regs[2], mirr, mode; +static uint8 regs[2]; static SFORMAT StateRegs[] = { { regs, 2, "REGS" }, - { &mode, 1, "MODE" }, - { &mirr, 1, "MIRR" }, { 0 } }; static void Sync(void) { - if (mode) { /* NROM-128 */ - setprg16(0x8000, regs[0]); - setprg16(0xC000, regs[0]); - } else { /* UNROM */ - setprg16(0x8000, regs[0] | regs[1]); - setprg16(0xC000, regs[0] | 0x07); + if (regs[0] &0x20) { /* NROM-128 */ + setprg16(0x8000, regs[0] >>2 &0x20 | regs[0] &0x1F); + setprg16(0xC000, regs[0] >>2 &0x20 | regs[0] &0x1F); + } else { /* UNROM */ + setprg16(0x8000, regs[0] >>2 &0x20 | regs[0] | regs[1] &7); + setprg16(0xC000, regs[0] >>2 &0x20 | regs[0] | 7); } setchr8(0); - setmirror(mirr); + setmirror((regs[0] &0x40 || regs[0] &0x20 && regs[0] &0x04)? MI_H: MI_V); } static DECLFW(M340Write) { - regs[0] = A & 0x1F; - regs[1] = V & 0x07; - mode = A & 0x20; - mirr = ((A & 0x25) == 0x25) ? 0 : 1; + regs[0] = A & 0xFF; + regs[1] = V; Sync(); } @@ -63,7 +53,7 @@ static void BMCK3036Power(void) { } static void BMCK3036Reset(void) { - regs[0] = regs[1] = mode = mirr = 0; + regs[0] = regs[1] = 0; Sync(); } From dc1d14f3cd29f3ba1bf4e2d0f798b0c2d79c24cf Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Mon, 21 Mar 2022 15:53:24 +0100 Subject: [PATCH 03/11] Mapper 351: Add CHR-RAM mode plus the ability to map CHR data into CPU address space --- src/boards/351.c | 61 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 16 deletions(-) diff --git a/src/boards/351.c b/src/boards/351.c index 1492204..62fe0fa 100644 --- a/src/boards/351.c +++ b/src/boards/351.c @@ -31,6 +31,8 @@ static uint8 VRCIRQ_latch; static uint8 VRCIRQ_mode; static uint8 VRCIRQ_count; static signed short int VRCIRQ_cycles; +static uint8 *CHRRAM =NULL; +static uint8 *PRGCHR =NULL; static SFORMAT stateRegs[] = { { reg, 4, "REGS" }, @@ -63,34 +65,36 @@ static void sync () { int chrOR; int prgAND =reg[2] &0x04? 0x0F: 0x1F; int prgOR =reg[1] >>1; - if (reg[2] &0x80) { /* NROM mode */ + int chip =reg[2] &0x01 && CHRRAM? 0x10: 0x00; + + if (reg[2] &0x10) { /* NROM mode */ if (reg[2] &0x04) { /* NROM-128 */ - setprg16(0x8000, prgOR >>1); - setprg16(0xC000, prgOR >>1); + setprg16r(chip, 0x8000, prgOR >>1); + setprg16r(chip, 0xC000, prgOR >>1); } else /* NROM-256 */ - setprg32(0x8000, prgOR >>2); + setprg32r(chip, 0x8000, prgOR >>2); } else if (~reg[0] &0x02) { /* MMC3 mode */ - setprg8(0x8000 ^(MMC3_index <<8 &0x4000), MMC3_reg[6] &prgAND | prgOR &~prgAND); - setprg8(0xA000, MMC3_reg[7] &prgAND | prgOR &~prgAND); - setprg8(0xC000 ^(MMC3_index <<8 &0x4000), 0xFE &prgAND | prgOR &~prgAND); - setprg8(0xE000, 0xFF &prgAND | prgOR &~prgAND); + setprg8r(chip, 0x8000 ^(MMC3_index <<8 &0x4000), MMC3_reg[6] &prgAND | prgOR &~prgAND); + setprg8r(chip, 0xA000, MMC3_reg[7] &prgAND | prgOR &~prgAND); + setprg8r(chip, 0xC000 ^(MMC3_index <<8 &0x4000), 0xFE &prgAND | prgOR &~prgAND); + setprg8r(chip, 0xE000, 0xFF &prgAND | prgOR &~prgAND); } else if (reg[0] &0x01) { /* VRC4 mode */ - setprg8(0x8000 ^(VRC4_misc <<13 &0x4000), VRC4_prg[0] &prgAND | prgOR &~prgAND); - setprg8(0xA000, VRC4_prg[1] &prgAND | prgOR &~prgAND); - setprg8(0xC000 ^(VRC4_misc <<13 &0x4000), 0xFE &prgAND | prgOR &~prgAND); - setprg8(0xE000, 0xFF &prgAND | prgOR &~prgAND); + setprg8r(chip, 0x8000 ^(VRC4_misc <<13 &0x4000), VRC4_prg[0] &prgAND | prgOR &~prgAND); + setprg8r(chip, 0xA000, VRC4_prg[1] &prgAND | prgOR &~prgAND); + setprg8r(chip, 0xC000 ^(VRC4_misc <<13 &0x4000), 0xFE &prgAND | prgOR &~prgAND); + setprg8r(chip, 0xE000, 0xFF &prgAND | prgOR &~prgAND); } else { /* MMC1 mode */ prgAND >>=1; prgOR >>=1; if (MMC1_reg[0] &0x8) { /* 16 KiB mode */ if (MMC1_reg[0] &0x04) { /* OR logic */ - setprg16(0x8000, MMC1_reg[3] &prgAND | prgOR &~prgAND); - setprg16(0xC000, 0xFF &prgAND | prgOR &~prgAND); + setprg16r(chip, 0x8000, MMC1_reg[3] &prgAND | prgOR &~prgAND); + setprg16r(chip, 0xC000, 0xFF &prgAND | prgOR &~prgAND); } else { /* AND logic */ - setprg16(0x8000, 0x00 &prgAND | prgOR &~prgAND); - setprg16(0xC000, MMC1_reg[3] &prgAND | prgOR &~prgAND); + setprg16r(chip, 0x8000, 0x00 &prgAND | prgOR &~prgAND); + setprg16r(chip, 0xC000, MMC1_reg[3] &prgAND | prgOR &~prgAND); } } else setprg32(0x8000, (MMC1_reg[3] &prgAND | prgOR &~prgAND) >>1); @@ -98,6 +102,9 @@ static void sync () { chrAND =reg[2] &0x10? 0x1F: reg[2] &0x20? 0x7F: 0xFF; chrOR =reg[0] <<1; + if (reg[2] &0x01) /* CHR RAM mode */ + setchr8r(0x10, 0); + else if (reg[2] &0x40) /* CNROM mode */ setchr8(chrOR >>3); else @@ -286,12 +293,34 @@ static void Mapper351_reset (void) { sync(); } +static void Mapper351_close(void) { + if (CHRRAM) FCEU_gfree(CHRRAM); + if (PRGCHR) FCEU_gfree(PRGCHR); + CHRRAM =NULL; + PRGCHR =NULL; +} + void Mapper351_Init (CartInfo *info) { + int CHRRAMSIZE =info->CHRRamSize + info->CHRRamSaveSize; + info->Reset = Mapper351_reset; info->Power = Mapper351_power; + info->Close = Mapper351_close; MapIRQHook = cpuCycle; GameHBIRQHook = horizontalBlanking; GameStateRestore = Mapper351_restore; AddExState(stateRegs, ~0, 0, 0); + + if (CHRRAMSIZE) { + CHRRAM =(uint8 *)FCEU_gmalloc(CHRRAMSIZE); + SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); + AddExState(CHRRAM, CHRRAMSIZE, 0, "CRAM"); + + /* This crazy thing can map CHR-ROM into CPU address space. Allocate a combined PRG+CHR address space and treat it a second "chip". */ + PRGCHR =(uint8 *)FCEU_gmalloc(PRGsize[0] +CHRsize[0]); + memcpy(PRGCHR, PRGptr[0], PRGsize[0]); + memcpy(PRGCHR +PRGsize[0], CHRptr[0], CHRsize[0]); + SetupCartPRGMapping(0x10, PRGCHR, PRGsize[0] +CHRsize[0], 0); + } } From d03005689fcc1e131740ade40d94c72fefa56c6b Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Mon, 21 Mar 2022 16:10:51 +0100 Subject: [PATCH 04/11] Mapper 341: correct mirroring --- src/boards/addrlatch.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/boards/addrlatch.c b/src/boards/addrlatch.c index e9bf8b4..dda64dd 100644 --- a/src/boards/addrlatch.c +++ b/src/boards/addrlatch.c @@ -658,13 +658,12 @@ void BMCG146_Init(CartInfo *info) { /* NES 2.0 mapper 341 is used for a simple 4-in-1 multicart */ static void BMCTJ03Sync(void) { - uint8 mirr = ((latche >> 1) & 1) ^ 1; - uint8 bank = (latche >> 8) & 7; + uint8 mirr = latche &(PRGsize[0] &0x40000? 0x800: 0x200)? MI_H: MI_V; + uint8 bank = latche >> 8; setprg32(0x8000, bank); setchr8(bank); - if (bank == 3) mirr ^= 1; /* Twin Bee has incorrect mirroring */ setmirror(mirr); } From 5ea4d73e6f341aac320107f8f2aac89e6b7bcf0c Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Wed, 23 Mar 2022 17:47:58 +0100 Subject: [PATCH 05/11] Mapper 444: Add NC-8000M as submapper bit 2 --- src/boards/444.c | 5 +++-- src/ines.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/boards/444.c b/src/boards/444.c index e6a61b4..3872f56 100644 --- a/src/boards/444.c +++ b/src/boards/444.c @@ -18,7 +18,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* NC7000M PCB, with incorrect UNIF MAPR BS-110 due to a mix-up. Submappers denote the setting of two solder pads that configure CHR banking. */ +/* NC7000M PCB, with incorrect UNIF MAPR BS-110 due to a mix-up. Submapper bits 0 and 1. denote the setting of two solder pads that configure CHR banking. */ +/* NC8000M PCB, indicated by submapper bit 2. */ #include "mapinc.h" #include "mmc3.h" @@ -27,7 +28,7 @@ static uint8 pads; static uint8 dip; static void Mapper444_PRGWrap(uint32 A, uint8 V) { - int prgAND =0x0F; + int prgAND =pads &4 && EXPREGS[0] &0x02? 0x1F: 0x0F; int prgOR =EXPREGS[0] <<4; if (EXPREGS[0] &0x04) { if (~A &0x4000) { diff --git a/src/ines.c b/src/ines.c index 4e9baa5..ac867b1 100644 --- a/src/ines.c +++ b/src/ines.c @@ -813,7 +813,7 @@ INES_BOARD_BEGIN() INES_BOARD( "NTDEC TH2348", 437, Mapper437_Init ) INES_BOARD( "K-3071", 438, Mapper438_Init ) INES_BOARD( "NC-3000M", 443, Mapper443_Init ) - INES_BOARD( "NC-7000M", 444, Mapper444_Init ) + INES_BOARD( "NC-7000M/NC-8000M", 444, Mapper444_Init ) INES_BOARD( "DS-9-27", 452, Mapper452_Init ) INES_BOARD( "K6C3001A", 456, Mapper456_Init ) INES_BOARD( "SA-9602B", 513, SA9602B_Init ) From a13e82d631dfe8920ee75baa2184ad73b4e79f12 Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Fri, 1 Apr 2022 13:06:58 +0200 Subject: [PATCH 06/11] Mapper 258: Is actually a duplicate of 215 that uses different features. Correct a few mapper 114, 215 and 258 iNES correction database entries. --- src/boards/158B.c | 71 ---------------------------------------------- src/boards/8237.c | 31 ++++++++++++++++++-- src/ines-correct.h | 14 +++++---- src/ines.c | 2 +- src/unif.c | 2 +- src/unif.h | 1 - 6 files changed, 38 insertions(+), 83 deletions(-) delete mode 100644 src/boards/158B.c diff --git a/src/boards/158B.c b/src/boards/158B.c deleted file mode 100644 index 8bd0f5d..0000000 --- a/src/boards/158B.c +++ /dev/null @@ -1,71 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2015 CaH4e3 - * - * 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 - * - * "Blood Of Jurassic" protected MMC3 based board (GD-98 Cart ID, 158B PCB ID) - * - */ - -#include "mapinc.h" -#include "mmc3.h" - -static uint8 lut[8] = { 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x0F, 0x00 }; - -static void UNL158BPW(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x80) { - uint32 bank = EXPREGS[0] & 7; - if(EXPREGS[0] & 0x20) { /* 32Kb mode */ - setprg32(0x8000, bank >> 1); - } else { /* 16Kb mode */ - setprg16(0x8000, bank); - setprg16(0xC000, bank); - } - } else { - setprg8(A, V & 0xF); - } -} - -static DECLFW(UNL158BProtWrite) { - EXPREGS[A & 7] = V; - switch(A & 7) { - case 0: - FixMMC3PRG(MMC3_cmd); - break; - case 7: - FCEU_printf("UNK PROT WRITE\n"); - break; - } - -} - -static DECLFR(UNL158BProtRead) { - return X.DB | lut[A & 7]; -} - -static void UNL158BPower(void) { - GenMMC3Power(); - SetWriteHandler(0x5000, 0x5FFF, UNL158BProtWrite); - SetReadHandler(0x5000, 0x5FFF, UNL158BProtRead); -} - -void UNL158B_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 128, 0, 0); - pwrap = UNL158BPW; - info->Power = UNL158BPower; - AddExState(EXPREGS, 8, 0, "EXPR"); -} diff --git a/src/boards/8237.c b/src/boards/8237.c index 4c5b869..c72d969 100644 --- a/src/boards/8237.c +++ b/src/boards/8237.c @@ -63,6 +63,17 @@ static uint8 adrperm[8][8] = { 0, 1, 2, 3, 4, 5, 6, 7 }, /* empty */ }; +static uint8 protarray[8][8] = { + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* 0 Super Hang-On */ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00 }, /* 1 Monkey King */ + { 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x00, 0x00 }, /* 2 Super Hang-On/Monkey King */ + { 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x05, 0x00 }, /* 3 Super Hang-On/Monkey King */ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* 4 */ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* 5 */ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* 6 */ + { 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x0F, 0x00 } /* 7 (default) Blood of Jurassic */ +}; + static void UNL8237CW(uint32 A, uint8 V) { uint16 outer_bank; @@ -109,6 +120,10 @@ static void UNL8237PW(uint32 A, uint8 V) { } } +static DECLFR(UNL8237ProtRead) { + return protarray[EXPREGS[3]][A &7] &0x0F | 0x50; +} + static DECLFW(UNL8237Write) { uint8 dat = V; uint8 adr = adrperm[EXPREGS[2]][((A >> 12) & 6) | (A & 1)]; @@ -125,6 +140,7 @@ static DECLFW(UNL8237ExWrite) { switch (A & 0xF007) { case 0x5000: EXPREGS[0] = V; FixMMC3PRG(MMC3_cmd); FixMMC3CHR(MMC3_cmd); break; case 0x5001: EXPREGS[1] = V; FixMMC3PRG(MMC3_cmd); FixMMC3CHR(MMC3_cmd); break; + case 0x5002: EXPREGS[3] = V; break; case 0x5007: EXPREGS[2] = V; break; } } @@ -132,9 +148,18 @@ static DECLFW(UNL8237ExWrite) { static void UNL8237Power(void) { EXPREGS[0] = EXPREGS[2] = 0; EXPREGS[1] = 0x0F; + EXPREGS[3] = 7; GenMMC3Power(); SetWriteHandler(0x8000, 0xFFFF, UNL8237Write); - SetWriteHandler(0x5000, 0x7FFF, UNL8237ExWrite); + SetReadHandler (0x5000, 0x5FFF, UNL8237ProtRead); + SetWriteHandler(0x5000, 0x5FFF, UNL8237ExWrite); +} + +static void UNL8237Reset(void) { + EXPREGS[0] = EXPREGS[2] = 0; + EXPREGS[1] = 0x0F; + EXPREGS[3] = 7; + MMC3RegReset(); } void UNL8237_Init(CartInfo *info) { @@ -142,8 +167,8 @@ void UNL8237_Init(CartInfo *info) { cwrap = UNL8237CW; pwrap = UNL8237PW; info->Power = UNL8237Power; - AddExState(EXPREGS, 3, 0, "EXPR"); - AddExState(&submapper, 1, 0, "SUBM"); + info->Reset = UNL8237Reset; + AddExState(EXPREGS, 4, 0, "EXPR"); if (info->iNES2) submapper = info->submapper; } diff --git a/src/ines-correct.h b/src/ines-correct.h index fb80e15..18f251d 100644 --- a/src/ines-correct.h +++ b/src/ines-correct.h @@ -913,12 +913,14 @@ { 0x6e149729, 189, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Master Fighter II (Unl) [a1].nes */ { 0x60bfeb0c, 90, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Mortal Kombat 2 (Unl) [!].nes */ { 0x247cc73d, 150, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Poker II (Asia) (Ja) (Unl).nes */ - { 0x1f1326d4, 121, DEFAULT, MI_H, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Super Sonic 5 (1997) (Unl) [!].nes */ - { 0x99748230, 215, DEFAULT, MI_H, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* EarthWorm Jim 2 (SuperGame).nes */ - { 0x37876ac7, 215, DEFAULT, MI_H, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Golden Card 6-in-1 (Unl) [!].nes */ - { 0x1a3320a3, 215, DEFAULT, MI_H, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Mortal Kombat 3 (SuperGame).nes */ - { 0x80eb1839, 114, DEFAULT, MI_H, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Boogerman (Sugar Softec) (Unl) [!].nes */ - { 0x071e4ee8, 114, DEFAULT, MI_H, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* ?? m114,submapper 1 test rom */ + { 0x1f1326d4, 121, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Super Sonic 5 (1997) (Unl) [!].nes */ + { 0x99748230, 215, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* EarthWorm Jim 2 (SuperGame).nes */ + { 0x37876ac7, 215, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Golden Card 6-in-1 (Unl) [!].nes */ + { 0x1a3320a3, 215, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Mortal Kombat 3 (SuperGame).nes */ + { 0xec70f8d8, 258, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* 1997 留念: 港-京 - Super Hang-On (protected version, CHR doubled) */ + { 0x224989d9, 258, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* 1997 留念: 港-京 - Super Hang-On (protected version) */ + { 0x80eb1839, 114, 1, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Boogerman (Sugar Softec) (Unl) [!].nes */ + { 0x071e4ee8, 114, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* ?? m114,submapper 1 test rom */ { 0xfe3e03a1, 197, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Mortal Kombat III Special (YY-030) (Ch) [!].nes */ { 0x9151d311, 197, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Mortal Kombat III 28 Peoples (NT-328) (Ch) [!].nes */ { 0x272709b9, 237, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Teletubbies Y2K (420-in-1).nes */ diff --git a/src/ines.c b/src/ines.c index ac867b1..f2af9d5 100644 --- a/src/ines.c +++ b/src/ines.c @@ -679,7 +679,7 @@ INES_BOARD_BEGIN() /* NES 2.0 MAPPERS */ INES_BOARD( "OneBus", 256, UNLOneBus_Init ) - INES_BOARD( "158B", 258, UNL158B_Init ) + INES_BOARD( "158B", 258, UNL8237_Init ) INES_BOARD( "F-15", 259, BMCF15_Init ) INES_BOARD( "HPxx / HP2018-A", 260, BMCHPxx_Init ) INES_BOARD( "810544-C-A1", 261, BMC810544CA1_Init ) diff --git a/src/unif.c b/src/unif.c index 44f065b..7ee2e29 100644 --- a/src/unif.c +++ b/src/unif.c @@ -565,7 +565,7 @@ static BMAPPING bmap[] = { { "YOKO", 264, UNLYOKO_Init, 0 }, { "COOLBOY", 268, COOLBOY_Init, BMCFLAG_256KCHRR }, { "MINDKIDS", 268, MINDKIDS_Init, BMCFLAG_256KCHRR }, - { "158B", 258, UNL158B_Init, 0 }, + { "158B", 258, UNL8237_Init, 0 }, { "DRAGONFIGHTER", 292, UNLBMW8544_Init, 0 }, { "EH8813A", 519, UNLEH8813A_Init, 0 }, { "HP898F", 319, BMCHP898F_Init, 0 }, diff --git a/src/unif.h b/src/unif.h index a0826ff..351765c 100644 --- a/src/unif.h +++ b/src/unif.h @@ -139,7 +139,6 @@ void UNLYOKO_Init(CartInfo *info); void UNROM_Init(CartInfo *info); void UNROM512_Init(CartInfo *info); void COOLBOY_Init(CartInfo *info); -void UNL158B_Init(CartInfo *info); void UNLBMW8544_Init(CartInfo *info); void UNLEH8813A_Init(CartInfo *info); void BMCHP898F_Init(CartInfo *info); From 4feedbc7c1ccbdf1651bbfe666223f7f2f19bbdb Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Sat, 2 Apr 2022 17:48:19 +0200 Subject: [PATCH 07/11] Add mapper 310 --- src/boards/310.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + 3 files changed, 90 insertions(+) create mode 100644 src/boards/310.c diff --git a/src/boards/310.c b/src/boards/310.c new file mode 100644 index 0000000..7ebfac4 --- /dev/null +++ b/src/boards/310.c @@ -0,0 +1,88 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2005 CaH4e3 + * + * 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 regData[2]; +static uint8 regAddr; + +static SFORMAT K1053_state[] = +{ + { regData, 2, "REGD" }, + {®Addr, 1, "REGA" }, + { 0 } +}; + +static void K1053_sync (void) { + int prg =regData[0] &0x3F | regAddr <<4 &~0x3F; + int chrWritable; + switch(regAddr &3) { + case 0: setprg32(0x8000, prg >>1); + chrWritable =0; + break; + case 1: setprg16(0x8000, prg); + setprg16(0xC000, prg |7); + chrWritable =1; + break; + case 2: prg =prg <<1 | regData[0] >>7; + setprg8(0x8000, prg); + setprg8(0xA000, prg); + setprg8(0xC000, prg); + setprg8(0xE000, prg); + chrWritable =1; + break; + case 3: setprg16(0x8000, prg); + setprg16(0xC000, prg); + chrWritable =0; + break; + } + SetupCartCHRMapping(0, CHRptr[0], 0x8000, chrWritable); + setchr8(regData[1]); + setmirror(regData[0] &0x40? MI_H: MI_V); +} + +static void K1053_restore(int version) { + K1053_sync(); +} + +static DECLFW(K1053_write) { + regData[A >>14 &1] =V; + if (A &0x4000) regAddr=A &0xFF; + K1053_sync(); +} + +static void K1053_reset(void) { + regData[0] =regData[1] =regAddr =0; + K1053_sync(); +} + +static void K1053_power(void) { + K1053_reset(); + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x8000, 0xFFFF, K1053_write); +} + +void Mapper310_Init(CartInfo *info) { + info->Power = K1053_power; + info->Reset = K1053_reset; + GameStateRestore = K1053_restore; + AddExState(&K1053_state, ~0, 0, 0); +} diff --git a/src/ines.c b/src/ines.c index f2af9d5..c288b86 100644 --- a/src/ines.c +++ b/src/ines.c @@ -721,6 +721,7 @@ INES_BOARD_BEGIN() INES_BOARD( "KS7037", 307, UNLKS7037_Init ) INES_BOARD( "TH2131-1", 308, UNLTH21311_Init ) INES_BOARD( "LH51", 309, LH51_Init ) + INES_BOARD( "K-1053", 310, Mapper310_Init ) INES_BOARD( "KS7013B", 312, UNLKS7013B_Init ) INES_BOARD( "RESET-TXROM", 313, BMCRESETTXROM_Init ) INES_BOARD( "64in1NoRepeat", 314, BMC64in1nr_Init ) diff --git a/src/ines.h b/src/ines.h index bdb41a6..ef30b65 100644 --- a/src/ines.h +++ b/src/ines.h @@ -263,6 +263,7 @@ void Mapper271_Init(CartInfo *); void Mapper288_Init(CartInfo *); void Mapper293_Init(CartInfo *); void Mapper297_Init(CartInfo *); +void Mapper310_Init(CartInfo *); void Mapper319_Init(CartInfo *); void Mapper326_Init(CartInfo *); void Mapper330_Init(CartInfo *); From a3f2054aa6b6981e91209ff4dcd84fa51a9f3a4e Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Sat, 2 Apr 2022 17:49:05 +0200 Subject: [PATCH 08/11] Correct 310.c copyright notice --- src/boards/310.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/boards/310.c b/src/boards/310.c index 7ebfac4..929af1b 100644 --- a/src/boards/310.c +++ b/src/boards/310.c @@ -1,7 +1,7 @@ /* FCE Ultra - NES/Famicom Emulator * * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 + * Copyright (C) 2022 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 From 12157b4f8251d9a588f7f1499e5ca6e2b9852b4d Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Sat, 2 Apr 2022 20:25:09 +0200 Subject: [PATCH 09/11] Add mapper 294 --- src/boards/294.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ines.c | 2 +- src/ines.h | 1 + 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/boards/294.c diff --git a/src/boards/294.c b/src/boards/294.c new file mode 100644 index 0000000..db4956c --- /dev/null +++ b/src/boards/294.c @@ -0,0 +1,61 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 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" + +static uint8 latch; + +static void Mapper294_sync (void) { + setprg16(0x8000, latch); + setprg16(0xC000, latch |7); + setchr8(0); + setmirror(latch &0x80? MI_H: MI_V); +} + +static DECLFW(Mapper294_writeInnerBank) { + latch =latch &~7 | V&7; + Mapper294_sync(); +} + +static DECLFW(Mapper294_writeOuterBank) { + if (A &0x100) { + latch =latch &7 | V <<3; + Mapper294_sync(); + } +} + +static void Mapper294_reset(void) { + latch =0; + Mapper294_sync(); +} + +static void Mapper294_power(void) { + Mapper294_reset(); + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x8000, 0xFFFF, Mapper294_writeInnerBank); + SetWriteHandler(0x4020, 0x7FFF, Mapper294_writeOuterBank); +} + +void Mapper294_Init(CartInfo *info) { + info->Power = Mapper294_power; + info->Reset = Mapper294_reset; + AddExState(&latch, 1, 0, "LATC"); +} diff --git a/src/ines.c b/src/ines.c index c288b86..9ddcef0 100644 --- a/src/ines.c +++ b/src/ines.c @@ -706,7 +706,7 @@ INES_BOARD_BEGIN() INES_BOARD( "Kasheng 2-in-1 ", 291, Mapper291_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, Mapper134_Init ) /* nesdev redirects this as mapper 134 */ + INES_BOARD( "63-1601 ", 294, Mapper294_Init ) INES_BOARD( "YY860216C", 295, Mapper295_Init ) INES_BOARD( "TXC 01-22110-000", 297, Mapper297_Init ) INES_BOARD( "TF1201", 298, UNLTF1201_Init ) diff --git a/src/ines.h b/src/ines.h index ef30b65..aefc891 100644 --- a/src/ines.h +++ b/src/ines.h @@ -262,6 +262,7 @@ void Mapper269_Init(CartInfo *); void Mapper271_Init(CartInfo *); void Mapper288_Init(CartInfo *); void Mapper293_Init(CartInfo *); +void Mapper294_Init(CartInfo *); void Mapper297_Init(CartInfo *); void Mapper310_Init(CartInfo *); void Mapper319_Init(CartInfo *); From cfbe777f6183759d7a6ce4e83c9319826d9a8b5d Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Sat, 2 Apr 2022 22:03:41 +0200 Subject: [PATCH 10/11] Added mapper 467 --- src/boards/467.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + 3 files changed, 76 insertions(+) create mode 100644 src/boards/467.c diff --git a/src/boards/467.c b/src/boards/467.c new file mode 100644 index 0000000..3ec24d5 --- /dev/null +++ b/src/boards/467.c @@ -0,0 +1,74 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 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 "mmc3.h" + +static void Mapper467_PRGWrap(uint32 A, uint8 V) { + if (EXPREGS[0] &0x20) { + int prgAND =EXPREGS[0] &0x40? 0x0F: 0x03; + int prgOR =EXPREGS[0] <<1 &0x3C | 0x40; + setprg8(A, V &prgAND | prgOR &~prgAND); + } else + if (~A &0x2000) + setprg16(A, EXPREGS[0] &0x1F); +} + +static void Mapper467_CHRWrap(uint32 A, uint8 V) { + if (~A &0x0800) { + A =A &~0x400 | A <<1 &0x800; + if (EXPREGS[0] &0x40) + setchr2(A, V |0x100); + else + setchr2(A, V &~3 | A >>11 &3); + } +} + +static DECLFW(Mapper467_WriteExtra) { + EXPREGS[0] =V; + FixMMC3PRG(MMC3_cmd &0x3F); + FixMMC3CHR(MMC3_cmd &0x3F); + setmirror(EXPREGS[0] &0x80? MI_H: MI_V); +} + +static DECLFW(Mapper467_WriteMMC3) { + if (~A &1) V &=0x3F; + MMC3_CMDWrite(A, V); +} + +static void Mapper467_Reset(void) { + EXPREGS[0] =0; + MMC3RegReset(); +} + +static void Mapper467_Power(void) { + EXPREGS[0] =0; + GenMMC3Power(); + SetWriteHandler(0x8000, 0x8FFF, Mapper467_WriteMMC3); + SetWriteHandler(0x9000, 0x9FFF, Mapper467_WriteExtra); +} + +void Mapper467_Init(CartInfo *info) { + GenMMC3_Init(info, 256, 256, 0, 0); + cwrap = Mapper467_CHRWrap; + pwrap = Mapper467_PRGWrap; + info->Power = Mapper467_Power; + info->Reset = Mapper467_Reset; + AddExState(EXPREGS, 1, 0, "EXPR"); +} diff --git a/src/ines.c b/src/ines.c index 9ddcef0..a025647 100644 --- a/src/ines.c +++ b/src/ines.c @@ -817,6 +817,7 @@ INES_BOARD_BEGIN() INES_BOARD( "NC-7000M/NC-8000M", 444, Mapper444_Init ) INES_BOARD( "DS-9-27", 452, Mapper452_Init ) INES_BOARD( "K6C3001A", 456, Mapper456_Init ) + INES_BOARD( "47-2", 467, Mapper467_Init ) INES_BOARD( "SA-9602B", 513, SA9602B_Init ) INES_BOARD( "Brilliant Com Cocoma Pack", 516, Mapper516_Init ) INES_BOARD( "DANCE2000", 518, UNLD2000_Init ) diff --git a/src/ines.h b/src/ines.h index aefc891..92ad140 100644 --- a/src/ines.h +++ b/src/ines.h @@ -327,6 +327,7 @@ void Mapper443_Init(CartInfo *); void Mapper444_Init(CartInfo *); void Mapper452_Init(CartInfo *); void Mapper456_Init(CartInfo *); +void Mapper467_Init(CartInfo *); void Mapper516_Init(CartInfo *); void Mapper523_Init(CartInfo *); void Mapper533_Init(CartInfo *); From bc3767e37489692586137e2a55de555e5eadc1e1 Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Sat, 2 Apr 2022 22:50:13 +0200 Subject: [PATCH 11/11] Mapper 467: Remove unnecessary AND mask --- src/boards/467.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/boards/467.c b/src/boards/467.c index 3ec24d5..268a1a6 100644 --- a/src/boards/467.c +++ b/src/boards/467.c @@ -42,8 +42,8 @@ static void Mapper467_CHRWrap(uint32 A, uint8 V) { static DECLFW(Mapper467_WriteExtra) { EXPREGS[0] =V; - FixMMC3PRG(MMC3_cmd &0x3F); - FixMMC3CHR(MMC3_cmd &0x3F); + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); setmirror(EXPREGS[0] &0x80? MI_H: MI_V); }