From 012fbca2d80952421b4ef683be0c453071022716 Mon Sep 17 00:00:00 2001 From: negative Date: Mon, 6 Mar 2023 14:03:09 +0800 Subject: [PATCH] Move mapper 205 to mapper 361/366, add proper mapper 205 - Current mapper 205 implementation moved to describe mappers 361 and 366 instead. - Then add mapper new mapper 205. These mapper changes should now reflect what is described in mapper's wiki article --- src/boards/mmc3.cpp | 77 +++++++++++++++++++++++++++++++++++---------- src/ines.cpp | 4 ++- src/ines.h | 1 + src/unif.cpp | 1 + 4 files changed, 66 insertions(+), 17 deletions(-) diff --git a/src/boards/mmc3.cpp b/src/boards/mmc3.cpp index 17d9509b..49cc7ecb 100644 --- a/src/boards/mmc3.cpp +++ b/src/boards/mmc3.cpp @@ -1136,20 +1136,65 @@ void Mapper198_Init(CartInfo *info) { info->Power = M195Power; } -// ---------------------------- Mapper 205 ------------------------------ -// GN-45 BOARD +/* ---------------------------- Mapper 205 ------------------------------ */ +/* UNIF boardname BMC-JC-016-2 +https://wiki.nesdev.com/w/index.php/INES_Mapper_205 */ + +/* 2023-02 : Update reg write logic and add solder pad */ static void M205PW(uint32 A, uint8 V) { -// GN-30A - начальная маска должна быть 1F + аппаратный переключатель на шине адреса - setprg8(A, (V & 0x0f) | EXPREGS[0]); + uint8 bank = V & ((EXPREGS[0] & 0x02) ? 0x0F : 0x1F); + setprg8(A, EXPREGS[0] << 4 | bank); } static void M205CW(uint32 A, uint8 V) { -// GN-30A - начальная маска должна быть FF + uint8 bank = V & ((EXPREGS[0] & 0x02) ? 0x7F : 0xFF); + setchr1(A, (EXPREGS[0] << 7) | bank); +} + +static DECLFW(M205Write) { + EXPREGS[0] = V & 3; + if (V & 1) { + EXPREGS[0] |= EXPREGS[1]; + } + CartBW(A, V); + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); +} + +static void M205Reset(void) { + EXPREGS[0] = 0; + EXPREGS[1] ^= 2; /* solder pad */ + MMC3RegReset(); +} + +static void M205Power(void) { + EXPREGS[0] = EXPREGS[1] = 0; + GenMMC3Power(); + SetWriteHandler(0x6000, 0x7FFF, M205Write); +} + +void Mapper205_Init(CartInfo *info) { + GenMMC3_Init(info, 256, 128, 8, 0); + pwrap = M205PW; + cwrap = M205CW; + info->Power = M205Power; + info->Reset = M205Reset; + AddExState(EXPREGS, 2, 0, "EXPR"); +} + +/* --------------------------- GN-45 BOARD ------------------------------ */ + +/* Mapper 361 and 366, previously assigned as Mapper 205 */ +static void GN45PW(uint32 A, uint8 V) { + setprg8(A, (V & 0x0f) | EXPREGS[0]); +} + +static void GN45CW(uint32 A, uint8 V) { setchr1(A, (V & 0x7F) | (EXPREGS[0] << 3)); } -static DECLFW(M205Write0) { +static DECLFW(GN45Write0) { if (EXPREGS[2] == 0) { EXPREGS[0] = A & 0x30; EXPREGS[2] = A & 0x80; @@ -1159,7 +1204,7 @@ static DECLFW(M205Write0) { CartBW(A, V); } -static DECLFW(M205Write1) { +static DECLFW(GN45Write1) { if (EXPREGS[2] == 0) { EXPREGS[0] = V & 0x30; FixMMC3PRG(MMC3_cmd); @@ -1168,23 +1213,23 @@ static DECLFW(M205Write1) { CartBW(A, V); } -static void M205Reset(void) { +static void GN45Reset(void) { EXPREGS[0] = EXPREGS[2] = 0; MMC3RegReset(); } -static void M205Power(void) { +static void GN45Power(void) { GenMMC3Power(); - SetWriteHandler(0x6000, 0x6fff, M205Write0); - SetWriteHandler(0x7000, 0x7fff, M205Write1); // OK-411 boards, the same logic, but data latched, 2-in-1 frankenstein + SetWriteHandler(0x6000, 0x6fff, GN45Write0); + SetWriteHandler(0x7000, 0x7fff, GN45Write1); /* OK-411 boards, the same logic, but data latched, 2-in-1 frankenstein */ } -void Mapper205_Init(CartInfo *info) { +void GN45_Init(CartInfo *info) { GenMMC3_Init(info, 128, 128, 8, 0); - pwrap = M205PW; - cwrap = M205CW; - info->Power = M205Power; - info->Reset = M205Reset; + pwrap = GN45PW; + cwrap = GN45CW; + info->Power = GN45Power; + info->Reset = GN45Reset; AddExState(EXPREGS, 1, 0, "EXPR"); } diff --git a/src/ines.cpp b/src/ines.cpp index 6873bdc5..9bf183f5 100644 --- a/src/ines.cpp +++ b/src/ines.cpp @@ -720,7 +720,7 @@ BMAPPINGLocal bmap[] = { {"", 202, Mapper202_Init}, {"", 203, Mapper203_Init}, {"", 204, Mapper204_Init}, - {"", 205, Mapper205_Init}, + {"JC-016-2", 205, Mapper205_Init}, {"NAMCOT 108 Rev. C", 206, Mapper206_Init}, // Deprecated, Used to be "DEIROM" whatever it means, but actually simple version of MMC3 {"TAITO X1-005 Rev. B", 207, Mapper207_Init}, {"", 208, Mapper208_Init}, @@ -788,6 +788,8 @@ BMAPPINGLocal bmap[] = { {"HP10xx/H20xx Boards", 260, BMCHPxx_Init}, {"810544-CA-1", 261, BMC810544CA1_Init}, {"AA6023/AA6023B", 268, AA6023_Init}, + {"OK-411", 361, GN45_Init}, + {"GN-45", 366, GN45_Init}, {"COOLGIRL", 342, COOLGIRL_Init }, {"FAM250/81-01-39-C/SCHI-24", 354, Mapper354_Init }, diff --git a/src/ines.h b/src/ines.h index 04e723d7..6c95863a 100644 --- a/src/ines.h +++ b/src/ines.h @@ -280,6 +280,7 @@ void Mapper354_Init(CartInfo *); void Mapper406_Init(CartInfo *); void INX_007T_Init(CartInfo* info); +void GN45_Init(CartInfo *info); /* previously mapper 205 */ typedef struct { const char *name; diff --git a/src/unif.cpp b/src/unif.cpp index 9bcc44f7..7b6c73a8 100644 --- a/src/unif.cpp +++ b/src/unif.cpp @@ -476,6 +476,7 @@ static BMAPPING bmap[] = { { "BS-400R", BS400R_Init, 0 }, { "BS-4040R", BS4040R_Init, 0 }, { "COOLGIRL", COOLGIRL_Init, 0 }, + { "JC-016-2", Mapper205_Init, 0 }, { 0, 0, 0 } };