From 8b1c405d95df1b831de73b1c71c238eddadfa720 Mon Sep 17 00:00:00 2001 From: g0me3 Date: Tue, 1 Oct 2019 22:01:30 +0300 Subject: [PATCH 1/3] mapper 15 chr protection implemented --- src/boards/15.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/boards/15.cpp b/src/boards/15.cpp index 8ea05bf2..13ca2d7a 100644 --- a/src/boards/15.cpp +++ b/src/boards/15.cpp @@ -35,17 +35,17 @@ static SFORMAT StateRegs[] = static void Sync(void) { int i; setmirror(((latched >> 6) & 1) ^ 1); - switch (latchea) { - case 0x8000: + switch (latchea & 3) { + case 0: for (i = 0; i < 4; i++) setprg8(0x8000 + (i << 13), (((latched & 0x7F) << 1) + i) ^ (latched >> 7)); break; - case 0x8002: + case 2: for (i = 0; i < 4; i++) setprg8(0x8000 + (i << 13), ((latched & 0x7F) << 1) + (latched >> 7)); break; - case 0x8001: - case 0x8003: + case 1: + case 3: for (i = 0; i < 4; i++) { unsigned int b; b = latched & 0x7F; @@ -60,6 +60,18 @@ static void Sync(void) { static DECLFW(M15Write) { latchea = A; latched = V; + switch (latchea & 3) { + case 0: + case 3: + SetupCartCHRMapping(0, CHRptr[0], 0x2000, 0); + setchr8(0); + break; + case 1: + case 2: + SetupCartCHRMapping(0, CHRptr[0], 0x2000, 1); + setchr8(0); + break; + } Sync(); } @@ -70,7 +82,6 @@ static void StateRestore(int version) { static void M15Power(void) { latchea = 0x8000; latched = 0; - setchr8(0); setprg8r(0x10, 0x6000, 0); SetReadHandler(0x6000, 0x7FFF, CartBR); SetWriteHandler(0x6000, 0x7FFF, CartBW); From 5ca7f608f7f173afefa586e25b3e3a174ba09ca3 Mon Sep 17 00:00:00 2001 From: norill Date: Wed, 2 Oct 2019 18:30:36 +0200 Subject: [PATCH 2/3] Update 15.cpp changes in accordance to the reverse-engineered mapper schematics: - changed bank mode 1 mapping CPU $C000-$DFFF from "fixed to last bank" to "B OR 7" to support multiple 128KiB UNROM games in one cart - latch D.7 bit ignored outside bank mode 2 - fixed latch D.6 bit interpreted as bank number bit --- src/boards/15.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/boards/15.cpp b/src/boards/15.cpp index 13ca2d7a..5465a381 100644 --- a/src/boards/15.cpp +++ b/src/boards/15.cpp @@ -38,20 +38,20 @@ static void Sync(void) { switch (latchea & 3) { case 0: for (i = 0; i < 4; i++) - setprg8(0x8000 + (i << 13), (((latched & 0x7F) << 1) + i) ^ (latched >> 7)); + setprg8(0x8000 + (i << 13), ((latched & 0x3F) << 1) + i); break; case 2: for (i = 0; i < 4; i++) - setprg8(0x8000 + (i << 13), ((latched & 0x7F) << 1) + (latched >> 7)); + setprg8(0x8000 + (i << 13), ((latched & 0x3F) << 1) + (latched >> 7)); break; case 1: case 3: for (i = 0; i < 4; i++) { unsigned int b; - b = latched & 0x7F; + b = latched & 0x3F; if (i >= 2 && !(latchea & 0x2)) - b = 0x7F; - setprg8(0x8000 + (i << 13), (i & 1) + ((b << 1) ^ (latched >> 7))); + b = b | 0x07; + setprg8(0x8000 + (i << 13), (i & 1) + (b << 1)); } break; } From 0fc18be6b8ef6b6ac73df93ade1172ae7d3e8df8 Mon Sep 17 00:00:00 2001 From: g0me3 Date: Wed, 2 Oct 2019 20:03:38 +0300 Subject: [PATCH 3/3] mapper 15 - fixed regression by previous fixes (waising / subors does not work properly with CHR write protection on mode 0) --- src/boards/15.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/boards/15.cpp b/src/boards/15.cpp index 5465a381..01f55cd5 100644 --- a/src/boards/15.cpp +++ b/src/boards/15.cpp @@ -55,23 +55,19 @@ static void Sync(void) { } break; } + setchr8(0); } static DECLFW(M15Write) { latchea = A; latched = V; - switch (latchea & 3) { - case 0: - case 3: + // cah4e3 02.10.19 once again, there may be either two similar mapper 15 exist. the one for 110in1 or 168in1 carts with complex multi game features. + // and another implified version for subor/waixing chinese originals and hacks with no different modes, working only in mode 0 and which does not + // expect there is any CHR write protection. protecting CHR writes only for mode 3 fixes the problem, all roms may be run on the same source again. + if((latchea & 3) == 3) SetupCartCHRMapping(0, CHRptr[0], 0x2000, 0); - setchr8(0); - break; - case 1: - case 2: + else SetupCartCHRMapping(0, CHRptr[0], 0x2000, 1); - setchr8(0); - break; - } Sync(); }