From 988be84742eeac6b82891759bb4edcd489cd185e Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Wed, 27 Jul 2022 11:07:25 +0200 Subject: [PATCH 01/12] Add mapper 441 --- src/boards/441.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + 3 files changed, 70 insertions(+) create mode 100644 src/boards/441.c diff --git a/src/boards/441.c b/src/boards/441.c new file mode 100644 index 0000000..a2ef809 --- /dev/null +++ b/src/boards/441.c @@ -0,0 +1,68 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 + * + * 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 + */ + +/* 850335C PCB */ + +#include "mapinc.h" +#include "mmc3.h" + +static void Mapper441_PRGWrap(uint32 A, uint8 V) { + int prgAND =EXPREGS[0] &0x08? 0x0F: 0x1F; + int prgOR =EXPREGS[0] <<4 &0x30; + if (EXPREGS[0] &0x04) { + if (~A &0x4000) { + setprg8(A, ~2 &V &prgAND | prgOR &~prgAND); + setprg8(A |0x4000, 2 |V &prgAND | prgOR &~prgAND); + } + } else + setprg8(A, V &prgAND | prgOR &~prgAND); +} + +static void Mapper441_CHRWrap(uint32 A, uint8 V) { + int chrAND =EXPREGS[0] &0x40? 0x7F: 0xFF; + int chrOR =EXPREGS[0] <<3 &0x180; + setchr1(A, V &chrAND | chrOR &~chrAND); +} + +static DECLFW(Mapper441_Write) { + if (~EXPREGS[0] &0x80) EXPREGS[0] =V; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); +} + +static void Mapper441_Reset(void) { + EXPREGS[0] =0; + MMC3RegReset(); +} + +static void Mapper441_Power(void) { + EXPREGS[0] =0; + GenMMC3Power(); + SetWriteHandler(0x6000, 0x7FFF, Mapper441_Write); +} + +void Mapper441_Init(CartInfo *info) { + GenMMC3_Init(info, 256, 256, 0, 0); + cwrap = Mapper441_CHRWrap; + pwrap = Mapper441_PRGWrap; + info->Power = Mapper441_Power; + info->Reset = Mapper441_Reset; + AddExState(EXPREGS, 1, 0, "EXPR"); +} diff --git a/src/ines.c b/src/ines.c index 71070ff..2fb19e3 100644 --- a/src/ines.c +++ b/src/ines.c @@ -815,6 +815,7 @@ INES_BOARD_BEGIN() INES_BOARD( "820401/T-217", 436, Mapper436_Init ) INES_BOARD( "NTDEC TH2348", 437, Mapper437_Init ) INES_BOARD( "K-3071", 438, Mapper438_Init ) + INES_BOARD( "850335C", 441, Mapper441_Init ) INES_BOARD( "NC-3000M", 443, Mapper443_Init ) INES_BOARD( "NC-7000M/NC-8000M", 444, Mapper444_Init ) INES_BOARD( "DS-9-27", 452, Mapper452_Init ) diff --git a/src/ines.h b/src/ines.h index 92ad140..4d0a91b 100644 --- a/src/ines.h +++ b/src/ines.h @@ -323,6 +323,7 @@ void Mapper435_Init(CartInfo *); void Mapper436_Init(CartInfo *); void Mapper437_Init(CartInfo *); void Mapper438_Init(CartInfo *); +void Mapper441_Init(CartInfo *); void Mapper443_Init(CartInfo *); void Mapper444_Init(CartInfo *); void Mapper452_Init(CartInfo *); From 95f06256045019cc36b63b5df86c7f161305642b Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Wed, 27 Jul 2022 11:27:59 +0200 Subject: [PATCH 02/12] Add mapper 463 --- src/boards/463.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + 3 files changed, 79 insertions(+) create mode 100644 src/boards/463.c diff --git a/src/boards/463.c b/src/boards/463.c new file mode 100644 index 0000000..3c70244 --- /dev/null +++ b/src/boards/463.c @@ -0,0 +1,77 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 + * + * 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 regs[4] = { 0 }; +static uint8 dipswitch = 0; + +static SFORMAT StateRegs[] = { + { regs, 4, "EXPR" }, + { &dipswitch, 1, "DPSW" }, + { 0 } +}; + +static void Mapper463_Sync(void) +{ + if (regs[0] &4) + { + setprg16(0x8000, regs[1]); + setprg16(0xC000, regs[1]); + } + else + { + setprg32(0x8000, regs[1] >>1); + } + setchr8(regs[2]); + setmirror(regs[0] &1? MI_H: MI_V); +} + +static DECLFW(Mapper463_Write5000) +{ + if (A &(0x10 << dipswitch)) + { + regs[A &3] =V; + Mapper463_Sync(); + } +} + +static void Mapper463_Reset(void) +{ + dipswitch =(dipswitch +1) &7; + regs[0] =regs[1] =regs[2] =regs[3] =0; + Mapper463_Sync(); +} + +static void Mapper463_Power(void) +{ + dipswitch =0; + regs[0] =regs[1] =regs[2] =regs[3] =0; + Mapper463_Sync(); + SetWriteHandler(0x5000, 0x5FFF, Mapper463_Write5000); + SetReadHandler(0x6000, 0xFFFF, CartBR); +} + +void Mapper463_Init(CartInfo *info) +{ + info->Power = Mapper463_Power; + info->Reset = Mapper463_Reset; + AddExState(StateRegs, ~0, 0, 0); +} \ No newline at end of file diff --git a/src/ines.c b/src/ines.c index 2fb19e3..aee8aad 100644 --- a/src/ines.c +++ b/src/ines.c @@ -820,6 +820,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( "YH810X1", 463, Mapper463_Init ) INES_BOARD( "47-2", 467, Mapper467_Init ) INES_BOARD( "SA-9602B", 513, SA9602B_Init ) INES_BOARD( "Brilliant Com Cocoma Pack", 516, Mapper516_Init ) diff --git a/src/ines.h b/src/ines.h index 4d0a91b..6da5dd1 100644 --- a/src/ines.h +++ b/src/ines.h @@ -328,6 +328,7 @@ void Mapper443_Init(CartInfo *); void Mapper444_Init(CartInfo *); void Mapper452_Init(CartInfo *); void Mapper456_Init(CartInfo *); +void Mapper463_Init(CartInfo *); void Mapper467_Init(CartInfo *); void Mapper516_Init(CartInfo *); void Mapper523_Init(CartInfo *); From 16c10d63c92cb73c01f192963f74d745567a3cce Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Wed, 27 Jul 2022 11:39:58 +0200 Subject: [PATCH 03/12] Add mapper 466 --- src/boards/466.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + 3 files changed, 102 insertions(+) create mode 100644 src/boards/466.c diff --git a/src/boards/466.c b/src/boards/466.c new file mode 100644 index 0000000..a8ad361 --- /dev/null +++ b/src/boards/466.c @@ -0,0 +1,100 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 + * + * 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 regs[3]; + +static SFORMAT StateRegs[] = +{ + { regs, 3, "EXPR" }, + { 0 } +}; + +static DECLFR(Mapper466_ReadOB) +{ + return X.DB; +} + +static void Mapper466_Sync(void) +{ + int prg =regs[1] <<5 | regs[0] <<1 &0x1E | regs[0] >>5 &1; + + /* Return open bus when selecting unpopulated PRG chip */ + if (prg &0x20 && PRGsize[0] <1024*1024) + SetReadHandler(0x8000, 0xFFFF, Mapper466_ReadOB); + else + SetReadHandler(0x8000, 0xFFFF, CartBR); + + if (regs[0] &0x40) + { + if (regs[0] &0x10) + { + setprg16(0x8000, prg); + setprg16(0xC000, prg); + } + else + { + setprg32(0x8000, prg >>1); + } + } + else + { + setprg16(0x8000, prg &~7 | regs[2] &7); + setprg16(0xC000, prg &~7 | 7); + } + setprg8r(0x10, 0x6000, 0); + setchr8(0); + setmirror(regs[0] &0x80? MI_H: MI_V); +} + +static DECLFW(Mapper466_Write5000) +{ + regs[A >>11 &1] =A &0xFF; + Mapper466_Sync(); +} + +static DECLFW(Mapper466_WriteLatch) +{ + regs[2] =V; + Mapper466_Sync(); +} + +static void Mapper466_Reset(void) +{ + regs[0] =regs[1] =0; + Mapper466_Sync(); +} + +static void Mapper466_Power(void) +{ + regs[0] =regs[1] =0; + Mapper466_Sync(); + SetWriteHandler(0x5000, 0x5FFF, Mapper466_Write5000); + SetWriteHandler(0x8000, 0xFFFF, Mapper466_WriteLatch); + SetReadHandler(0x6000, 0xFFFF, CartBR); +} + +void Mapper466_Init(CartInfo *info) +{ + info->Power = Mapper466_Power; + info->Reset = Mapper466_Reset; + AddExState(StateRegs, ~0, 0, 0); +} \ No newline at end of file diff --git a/src/ines.c b/src/ines.c index aee8aad..1d7f0b2 100644 --- a/src/ines.c +++ b/src/ines.c @@ -821,6 +821,7 @@ INES_BOARD_BEGIN() INES_BOARD( "DS-9-27", 452, Mapper452_Init ) INES_BOARD( "K6C3001A", 456, Mapper456_Init ) INES_BOARD( "YH810X1", 463, Mapper463_Init ) + INES_BOARD( "Keybyte Computer", 466, Mapper466_Init ) INES_BOARD( "47-2", 467, Mapper467_Init ) INES_BOARD( "SA-9602B", 513, SA9602B_Init ) INES_BOARD( "Brilliant Com Cocoma Pack", 516, Mapper516_Init ) diff --git a/src/ines.h b/src/ines.h index 6da5dd1..8a6d505 100644 --- a/src/ines.h +++ b/src/ines.h @@ -329,6 +329,7 @@ void Mapper444_Init(CartInfo *); void Mapper452_Init(CartInfo *); void Mapper456_Init(CartInfo *); void Mapper463_Init(CartInfo *); +void Mapper466_Init(CartInfo *); void Mapper467_Init(CartInfo *); void Mapper516_Init(CartInfo *); void Mapper523_Init(CartInfo *); From 868edfb32dc5db1d3771e062e60362c05f9dd79d Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Wed, 27 Jul 2022 11:51:30 +0200 Subject: [PATCH 04/12] Add mapper 464 --- src/boards/addrlatch.c | 18 ++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + 3 files changed, 20 insertions(+) diff --git a/src/boards/addrlatch.c b/src/boards/addrlatch.c index dda64dd..836e7a8 100644 --- a/src/boards/addrlatch.c +++ b/src/boards/addrlatch.c @@ -757,3 +757,21 @@ static void M435Sync(void) { void Mapper435_Init(CartInfo *info) { Latch_Init(info, M435Sync, NULL, 0x0000, 0x8000, 0xFFFF, 1); } + +/*------------------ Map 464 ---------------------------*/ +static void M464Sync(void) { + int p =latche >>7; + int c =latche &0x1F; + if (latche &0x40) { + setprg32(0x8000, p >> 1); + } else { + setprg16(0x8000, p); + setprg16(0xC000, p); + } + setchr8(c); + setmirror(latche &0x20? MI_H: MI_V); +} + +void Mapper464_Init(CartInfo *info) { + Latch_Init(info, M464Sync, NULL, 0x0000, 0x8000, 0xFFFF, 1); +} diff --git a/src/ines.c b/src/ines.c index 1d7f0b2..ce3791e 100644 --- a/src/ines.c +++ b/src/ines.c @@ -821,6 +821,7 @@ INES_BOARD_BEGIN() INES_BOARD( "DS-9-27", 452, Mapper452_Init ) INES_BOARD( "K6C3001A", 456, Mapper456_Init ) INES_BOARD( "YH810X1", 463, Mapper463_Init ) + INES_BOARD( "NTDEC 9012", 464, Mapper464_Init ) INES_BOARD( "Keybyte Computer", 466, Mapper466_Init ) INES_BOARD( "47-2", 467, Mapper467_Init ) INES_BOARD( "SA-9602B", 513, SA9602B_Init ) diff --git a/src/ines.h b/src/ines.h index 8a6d505..2a489cf 100644 --- a/src/ines.h +++ b/src/ines.h @@ -329,6 +329,7 @@ void Mapper444_Init(CartInfo *); void Mapper452_Init(CartInfo *); void Mapper456_Init(CartInfo *); void Mapper463_Init(CartInfo *); +void Mapper464_Init(CartInfo *); void Mapper466_Init(CartInfo *); void Mapper467_Init(CartInfo *); void Mapper516_Init(CartInfo *); From c80d2b129768755e1bb959df3a2df6f04b8ed115 Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Wed, 27 Jul 2022 11:56:35 +0200 Subject: [PATCH 05/12] Add mapper 459 --- src/boards/addrlatch.c | 18 ++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + 3 files changed, 20 insertions(+) diff --git a/src/boards/addrlatch.c b/src/boards/addrlatch.c index 836e7a8..14dba25 100644 --- a/src/boards/addrlatch.c +++ b/src/boards/addrlatch.c @@ -758,6 +758,24 @@ void Mapper435_Init(CartInfo *info) { Latch_Init(info, M435Sync, NULL, 0x0000, 0x8000, 0xFFFF, 1); } +/*------------------ Map 459 ---------------------------*/ +static void M459Sync(void) { + int p =latche >>5; + int c =latche &0x03 | latche >>2 &0x04 | latche >>4 &0x08; + if (latche &0x04) { + setprg32(0x8000, p); + } else { + setprg16(0x8000, p <<1); + setprg16(0xC000, p <<1 |7); + } + setchr8(c &(latche &0x08? 0x0F: 0x08)); + setmirror(latche &0x100? MI_H: MI_V); +} + +void Mapper459_Init(CartInfo *info) { + Latch_Init(info, M459Sync, NULL, 0x0000, 0x8000, 0xFFFF, 1); +} + /*------------------ Map 464 ---------------------------*/ static void M464Sync(void) { int p =latche >>7; diff --git a/src/ines.c b/src/ines.c index ce3791e..2350f51 100644 --- a/src/ines.c +++ b/src/ines.c @@ -820,6 +820,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( "8-in-1", 459, Mapper459_Init ) INES_BOARD( "YH810X1", 463, Mapper463_Init ) INES_BOARD( "NTDEC 9012", 464, Mapper464_Init ) INES_BOARD( "Keybyte Computer", 466, Mapper466_Init ) diff --git a/src/ines.h b/src/ines.h index 2a489cf..4afc8c8 100644 --- a/src/ines.h +++ b/src/ines.h @@ -328,6 +328,7 @@ void Mapper443_Init(CartInfo *); void Mapper444_Init(CartInfo *); void Mapper452_Init(CartInfo *); void Mapper456_Init(CartInfo *); +void Mapper459_Init(CartInfo *); void Mapper463_Init(CartInfo *); void Mapper464_Init(CartInfo *); void Mapper466_Init(CartInfo *); From 3999c571c91c014c5acd324d0966ce546d7f10a2 Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Wed, 27 Jul 2022 12:44:40 +0200 Subject: [PATCH 06/12] Add mapper 465 --- src/boards/465.c | 89 ++++++++++++++++++++++++++++++++++++++++++ src/boards/addrlatch.c | 2 +- src/ines.c | 1 + src/ines.h | 1 + 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 src/boards/465.c diff --git a/src/boards/465.c b/src/boards/465.c new file mode 100644 index 0000000..e847a9b --- /dev/null +++ b/src/boards/465.c @@ -0,0 +1,89 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 + * + * 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 uint16 latchAddr; +static uint8 latchData; + +static SFORMAT StateRegs[] = +{ + { &latchAddr, 2, "ADDR" }, + { &latchData, 1, "DATA" }, + { 0 } +}; + +static void Mapper465_Sync(void) +{ + int prg =latchAddr >>2 &0x1F | latchAddr >>5 &0x20; + if (latchAddr &0x200) + { + setprg16(0x8000, prg &~7 | latchData &7); + setprg16(0xC000, prg | 7); + } + else + { + if (latchAddr &0x001) + { + setprg32(0x8000, prg >>1); + } + else + { + setprg16(0x8000, prg); + setprg16(0xC000, prg); + } + } + setchr8(0); + setmirror(latchAddr &0x002? MI_H: MI_V); +} + +static DECLFW(Mapper465_WriteLatch) +{ + if (latchAddr &0x200) + { + latchData =V; + } + else + { + latchAddr =A &0xFFFF; + } + Mapper465_Sync(); +} + +static void Mapper465_Reset(void) +{ + latchAddr =latchData =0; + Mapper465_Sync(); +} + +static void Mapper465_Power(void) +{ + latchAddr =latchData =0; + Mapper465_Sync(); + SetWriteHandler(0x8000, 0xFFFF, Mapper465_WriteLatch); + SetReadHandler(0x6000, 0xFFFF, CartBR); +} + +void Mapper465_Init(CartInfo *info) +{ + info->Power = Mapper465_Power; + info->Reset = Mapper465_Reset; + AddExState(StateRegs, ~0, 0, 0); +} \ No newline at end of file diff --git a/src/boards/addrlatch.c b/src/boards/addrlatch.c index 14dba25..a221fb1 100644 --- a/src/boards/addrlatch.c +++ b/src/boards/addrlatch.c @@ -792,4 +792,4 @@ static void M464Sync(void) { void Mapper464_Init(CartInfo *info) { Latch_Init(info, M464Sync, NULL, 0x0000, 0x8000, 0xFFFF, 1); -} +} \ No newline at end of file diff --git a/src/ines.c b/src/ines.c index 2350f51..891182a 100644 --- a/src/ines.c +++ b/src/ines.c @@ -823,6 +823,7 @@ INES_BOARD_BEGIN() INES_BOARD( "8-in-1", 459, Mapper459_Init ) INES_BOARD( "YH810X1", 463, Mapper463_Init ) INES_BOARD( "NTDEC 9012", 464, Mapper464_Init ) + INES_BOARD( "ET-120", 465, Mapper465_Init ) INES_BOARD( "Keybyte Computer", 466, Mapper466_Init ) INES_BOARD( "47-2", 467, Mapper467_Init ) INES_BOARD( "SA-9602B", 513, SA9602B_Init ) diff --git a/src/ines.h b/src/ines.h index 4afc8c8..6e50bee 100644 --- a/src/ines.h +++ b/src/ines.h @@ -331,6 +331,7 @@ void Mapper456_Init(CartInfo *); void Mapper459_Init(CartInfo *); void Mapper463_Init(CartInfo *); void Mapper464_Init(CartInfo *); +void Mapper465_Init(CartInfo *); void Mapper466_Init(CartInfo *); void Mapper467_Init(CartInfo *); void Mapper516_Init(CartInfo *); From 707853d234d023bd61b974333b001498257f44c7 Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Wed, 27 Jul 2022 12:48:05 +0200 Subject: [PATCH 07/12] Add mapper 461 --- src/boards/addrlatch.c | 18 ++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + 3 files changed, 20 insertions(+) diff --git a/src/boards/addrlatch.c b/src/boards/addrlatch.c index a221fb1..dd67b51 100644 --- a/src/boards/addrlatch.c +++ b/src/boards/addrlatch.c @@ -776,6 +776,24 @@ void Mapper459_Init(CartInfo *info) { Latch_Init(info, M459Sync, NULL, 0x0000, 0x8000, 0xFFFF, 1); } +/*------------------ Map 461 ---------------------------*/ +static void M461Sync(void) { + int p =latche <<1 | latche >>5 &1; + int c =latche >>8; + if (latche &0x10) { + setprg16(0x8000, p); + setprg16(0xC000, p); + } else { + setprg32(0x8000, p >>1); + } + setchr8(c); + setmirror(latche &0x80? MI_H: MI_V); +} + +void Mapper461_Init(CartInfo *info) { + Latch_Init(info, M461Sync, NULL, 0x0000, 0x8000, 0xFFFF, 1); +} + /*------------------ Map 464 ---------------------------*/ static void M464Sync(void) { int p =latche >>7; diff --git a/src/ines.c b/src/ines.c index 891182a..c0100cd 100644 --- a/src/ines.c +++ b/src/ines.c @@ -821,6 +821,7 @@ INES_BOARD_BEGIN() INES_BOARD( "DS-9-27", 452, Mapper452_Init ) INES_BOARD( "K6C3001A", 456, Mapper456_Init ) INES_BOARD( "8-in-1", 459, Mapper459_Init ) + INES_BOARD( "0324", 461, Mapper461_Init ) INES_BOARD( "YH810X1", 463, Mapper463_Init ) INES_BOARD( "NTDEC 9012", 464, Mapper464_Init ) INES_BOARD( "ET-120", 465, Mapper465_Init ) diff --git a/src/ines.h b/src/ines.h index 6e50bee..61a77be 100644 --- a/src/ines.h +++ b/src/ines.h @@ -329,6 +329,7 @@ void Mapper444_Init(CartInfo *); void Mapper452_Init(CartInfo *); void Mapper456_Init(CartInfo *); void Mapper459_Init(CartInfo *); +void Mapper461_Init(CartInfo *); void Mapper463_Init(CartInfo *); void Mapper464_Init(CartInfo *); void Mapper465_Init(CartInfo *); From 718047a24185199256b38d5ccdfe78d977602548 Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Wed, 27 Jul 2022 13:24:30 +0200 Subject: [PATCH 08/12] Add mapper 460 --- src/boards/460.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + 3 files changed, 96 insertions(+) create mode 100644 src/boards/460.c diff --git a/src/boards/460.c b/src/boards/460.c new file mode 100644 index 0000000..7cbd782 --- /dev/null +++ b/src/boards/460.c @@ -0,0 +1,94 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 + * + * 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 =NULL; + +static DECLFR(Mapper460_ReadOB) +{ + return X.DB; +} + +static void Mapper460_PRGWrap(uint32 A, uint8 V) { + int prgAND =0x0F; + int prgOR =EXPREGS[0] <<4; + if (EXPREGS[0] &0x20) { + if (~A &0x4000) { + setprg8(A, (EXPREGS[0] &0x10? ~2: ~0) &V &prgAND | prgOR &~prgAND); + setprg8(A |0x4000, (EXPREGS[0] &0x10? 2: 0) |V &prgAND | prgOR &~prgAND); + } + } else + setprg8(A, V &prgAND | prgOR &~prgAND); + + /* Menu selection by selectively connecting reg's D7 to PRG /CE or not */ + if (EXPREGS[0] &0x80 && EXPREGS[1] &1) + SetReadHandler(0x8000, 0xFFFF, Mapper460_ReadOB); + else + SetReadHandler(0x8000, 0xFFFF, CartBR); +} + +static void Mapper460_CHRWrap(uint32 A, uint8 V) { + if (EXPREGS[0] &0x04) { + setchr2(0x0000, DRegBuf[0] &0xFE); + setchr2(0x0800, DRegBuf[0] |0x01); + setchr2(0x1000, DRegBuf[2]); + setchr2(0x1800, DRegBuf[5]); + } else + setchr8r(0x10, 0); +} + +static DECLFW(Mapper460_WriteExtra) { + if (A001B &0x80 && ~A001B &0x40) EXPREGS[0] =A &0xFF; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); +} + +static void Mapper460_Reset(void) { + EXPREGS[0] =0; + EXPREGS[1]++; + MMC3RegReset(); +} + +static void Mapper460_Power(void) { + EXPREGS[0] =0; + EXPREGS[1] =0; + GenMMC3Power(); + SetWriteHandler(0x6000, 0x7FFF, Mapper460_WriteExtra); +} + +static void Mapper460_close(void) { + if (CHRRAM) FCEU_gfree(CHRRAM); + CHRRAM =NULL; +} + +void Mapper460_Init(CartInfo *info) { + GenMMC3_Init(info, 128, 512, 0, 0); + cwrap = Mapper460_CHRWrap; + pwrap = Mapper460_PRGWrap; + info->Power = Mapper460_Power; + info->Reset = Mapper460_Reset; + info->Close = Mapper460_close; + AddExState(EXPREGS, 2, 0, "EXPR"); + + CHRRAM =(uint8 *)FCEU_gmalloc(8192); + SetupCartCHRMapping(0x10, CHRRAM, 8192, 1); + AddExState(CHRRAM, 8192, 0, "CRAM"); +} diff --git a/src/ines.c b/src/ines.c index c0100cd..c69eea0 100644 --- a/src/ines.c +++ b/src/ines.c @@ -821,6 +821,7 @@ INES_BOARD_BEGIN() INES_BOARD( "DS-9-27", 452, Mapper452_Init ) INES_BOARD( "K6C3001A", 456, Mapper456_Init ) INES_BOARD( "8-in-1", 459, Mapper459_Init ) + INES_BOARD( "FC-29-40/K-3101", 460, Mapper460_Init ) INES_BOARD( "0324", 461, Mapper461_Init ) INES_BOARD( "YH810X1", 463, Mapper463_Init ) INES_BOARD( "NTDEC 9012", 464, Mapper464_Init ) diff --git a/src/ines.h b/src/ines.h index 61a77be..988851e 100644 --- a/src/ines.h +++ b/src/ines.h @@ -329,6 +329,7 @@ void Mapper444_Init(CartInfo *); void Mapper452_Init(CartInfo *); void Mapper456_Init(CartInfo *); void Mapper459_Init(CartInfo *); +void Mapper460_Init(CartInfo *); void Mapper461_Init(CartInfo *); void Mapper463_Init(CartInfo *); void Mapper464_Init(CartInfo *); From 43e54d0e4314de6edc201ca9393b10f15a3f733a Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Wed, 27 Jul 2022 13:28:57 +0200 Subject: [PATCH 09/12] Mapper 429: Allow more than 32 KiB CHR --- src/boards/datalatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/boards/datalatch.c b/src/boards/datalatch.c index 7b1007c..d51dd3f 100644 --- a/src/boards/datalatch.c +++ b/src/boards/datalatch.c @@ -587,7 +587,7 @@ void BMCK3046_Init(CartInfo *info) { static void Mapper429_Sync(void) { setprg32(0x8000, latche >>2); - setchr8(latche &3); + setchr8(latche); } static void Mapper429_Reset(void) { From d37d644d17ad4f5dd929d3c64c4edd05aa2b4da4 Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Wed, 27 Jul 2022 13:35:33 +0200 Subject: [PATCH 10/12] Add mapper 449 --- src/boards/449.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + 3 files changed, 85 insertions(+) create mode 100644 src/boards/449.c diff --git a/src/boards/449.c b/src/boards/449.c new file mode 100644 index 0000000..bcb17d9 --- /dev/null +++ b/src/boards/449.c @@ -0,0 +1,83 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 + * + * 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 uint16 latchAddr; +static uint8 latchData; + +static SFORMAT StateRegs[] = +{ + { &latchAddr, 2, "ADDR" }, + { &latchData, 1, "DATA" }, + { 0 } +}; + +static void Mapper449_Sync(void) +{ + int prg =latchAddr >>2 &0x1F | latchAddr >>3 &0x20; + if (~latchAddr &0x080) + { + setprg16(0x8000, prg); + setprg16(0xC000, prg |7); + } + else + { + if (latchAddr &0x001) + { + setprg32(0x8000, prg >>1); + } + else + { + setprg16(0x8000, prg); + setprg16(0xC000, prg); + } + } + setchr8(latchData); + setmirror(latchAddr &0x002? MI_H: MI_V); +} + +static DECLFW(Mapper449_WriteLatch) +{ + latchData =V; + latchAddr =A &0xFFFF; + Mapper449_Sync(); +} + +static void Mapper449_Reset(void) +{ + latchAddr =latchData =0; + Mapper449_Sync(); +} + +static void Mapper449_Power(void) +{ + latchAddr =latchData =0; + Mapper449_Sync(); + SetWriteHandler(0x8000, 0xFFFF, Mapper449_WriteLatch); + SetReadHandler(0x6000, 0xFFFF, CartBR); +} + +void Mapper449_Init(CartInfo *info) +{ + info->Power = Mapper449_Power; + info->Reset = Mapper449_Reset; + AddExState(StateRegs, ~0, 0, 0); +} \ No newline at end of file diff --git a/src/ines.c b/src/ines.c index c69eea0..7755137 100644 --- a/src/ines.c +++ b/src/ines.c @@ -818,6 +818,7 @@ INES_BOARD_BEGIN() INES_BOARD( "850335C", 441, Mapper441_Init ) INES_BOARD( "NC-3000M", 443, Mapper443_Init ) INES_BOARD( "NC-7000M/NC-8000M", 444, Mapper444_Init ) + INES_BOARD( "22-in-1 King Series", 449, Mapper449_Init ) INES_BOARD( "DS-9-27", 452, Mapper452_Init ) INES_BOARD( "K6C3001A", 456, Mapper456_Init ) INES_BOARD( "8-in-1", 459, Mapper459_Init ) diff --git a/src/ines.h b/src/ines.h index 988851e..ac5cc1c 100644 --- a/src/ines.h +++ b/src/ines.h @@ -326,6 +326,7 @@ void Mapper438_Init(CartInfo *); void Mapper441_Init(CartInfo *); void Mapper443_Init(CartInfo *); void Mapper444_Init(CartInfo *); +void Mapper449_Init(CartInfo *); void Mapper452_Init(CartInfo *); void Mapper456_Init(CartInfo *); void Mapper459_Init(CartInfo *); From 94a6359a9d3370eb1f14f6d56b44895324f45aa9 Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Wed, 27 Jul 2022 13:47:23 +0200 Subject: [PATCH 11/12] Add mapper 455 --- src/boards/455.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + 3 files changed, 79 insertions(+) create mode 100644 src/boards/455.c diff --git a/src/boards/455.c b/src/boards/455.c new file mode 100644 index 0000000..55c8bdf --- /dev/null +++ b/src/boards/455.c @@ -0,0 +1,77 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 + * + * 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 + */ + +/* N625836 PCB */ + +#include "mapinc.h" +#include "mmc3.h" + +static void Mapper455_PRGWrap(uint32 A, uint8 V) { + int prgAND =EXPREGS[1] &0x01? 0x1F: 0x0F; + int prgOR =EXPREGS[0] >>2 &0x07 | EXPREGS[1] <<1 &0x08 | EXPREGS[0] >>2 &0x10; + if (EXPREGS[0] &0x01) { + if (EXPREGS[0] &0x02) { + setprg32(0x8000, prgOR >>1); + } else { + setprg16(0x8000, prgOR); + setprg16(0xC000, prgOR); + } + } else { + prgOR <<=1; + setprg8(A, V &prgAND | prgOR &~prgAND); + } +} + +static void Mapper455_CHRWrap(uint32 A, uint8 V) { + int chrAND =EXPREGS[1] &0x02? 0xFF: 0x7F; + int chrOR =(EXPREGS[0] >>2 &0x07 | EXPREGS[1] <<1 &0x08 | EXPREGS[0] >>2 &0x10) <<4; + setchr1(A, V &chrAND | chrOR &~chrAND); +} + +static DECLFW(Mapper455_Write) { + if (A &0x100) { + EXPREGS[0] =V; + EXPREGS[1] =A &0xFF; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); + } +} + +static void Mapper455_Reset(void) { + EXPREGS[0] =1; + EXPREGS[1] =0; + MMC3RegReset(); +} + +static void Mapper455_Power(void) { + EXPREGS[0] =1; + EXPREGS[1] =0; + GenMMC3Power(); + SetWriteHandler(0x4100, 0x5FFF, Mapper455_Write); +} + +void Mapper455_Init(CartInfo *info) { + GenMMC3_Init(info, 256, 256, 0, 0); + cwrap = Mapper455_CHRWrap; + pwrap = Mapper455_PRGWrap; + info->Power = Mapper455_Power; + info->Reset = Mapper455_Reset; + AddExState(EXPREGS, 2, 0, "EXPR"); +} diff --git a/src/ines.c b/src/ines.c index 7755137..63755d7 100644 --- a/src/ines.c +++ b/src/ines.c @@ -820,6 +820,7 @@ INES_BOARD_BEGIN() INES_BOARD( "NC-7000M/NC-8000M", 444, Mapper444_Init ) INES_BOARD( "22-in-1 King Series", 449, Mapper449_Init ) INES_BOARD( "DS-9-27", 452, Mapper452_Init ) + INES_BOARD( "N625836", 455, Mapper455_Init ) INES_BOARD( "K6C3001A", 456, Mapper456_Init ) INES_BOARD( "8-in-1", 459, Mapper459_Init ) INES_BOARD( "FC-29-40/K-3101", 460, Mapper460_Init ) diff --git a/src/ines.h b/src/ines.h index ac5cc1c..4f7bbdf 100644 --- a/src/ines.h +++ b/src/ines.h @@ -328,6 +328,7 @@ void Mapper443_Init(CartInfo *); void Mapper444_Init(CartInfo *); void Mapper449_Init(CartInfo *); void Mapper452_Init(CartInfo *); +void Mapper455_Init(CartInfo *); void Mapper456_Init(CartInfo *); void Mapper459_Init(CartInfo *); void Mapper460_Init(CartInfo *); From 2fd8f6c233ca97388049b513b29ea9f40349005a Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Wed, 27 Jul 2022 22:01:05 +0200 Subject: [PATCH 12/12] Mapper 351: Correct CHR mask, add FDS-like mirroring control --- src/boards/351.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/boards/351.c b/src/boards/351.c index 62fe0fa..6ef4b59 100644 --- a/src/boards/351.c +++ b/src/boards/351.c @@ -100,7 +100,7 @@ static void sync () { setprg32(0x8000, (MMC1_reg[3] &prgAND | prgOR &~prgAND) >>1); } - chrAND =reg[2] &0x10? 0x1F: reg[2] &0x20? 0x7F: 0xFF; + chrAND =reg[2] &0x10 && ~reg[2] &0x20? 0x1F: reg[2] &0x20? 0x7F: 0xFF; chrOR =reg[0] <<1; if (reg[2] &0x01) /* CHR RAM mode */ setchr8r(0x10, 0); @@ -265,6 +265,11 @@ static DECLFW(writeReg) { sync(); } +static DECLFW(writeFDSMirroring) { + MMC3_mirroring =V >>3 &1; + sync(); +} + static void Mapper351_power(void) { int i; for (i =0; i <4; i++) reg[i] =0; @@ -281,6 +286,7 @@ static void Mapper351_power(void) { SetReadHandler(0x6000, 0xFFFF, CartBR); SetReadHandler(0x5000, 0x5FFF, readDIP); SetWriteHandler(0x5000, 0x5FFF, writeReg); + SetWriteHandler(0x4025, 0x4025, writeFDSMirroring); applyMode(); sync(); }