From 86d3ef51710dc333d2299da1f46a4dbe1380eb44 Mon Sep 17 00:00:00 2001 From: Oggom Date: Thu, 18 Jun 2015 16:41:53 +0200 Subject: [PATCH 1/4] Backport r167 and r168 - mapper 35 fixes --- src/boards/sc-127.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/boards/sc-127.c b/src/boards/sc-127.c index c092510..2d2d968 100644 --- a/src/boards/sc-127.c +++ b/src/boards/sc-127.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * Wario Land II (Kirby hack) VRC4 + * Wario Land II (Kirby hack) */ #include "mapinc.h" @@ -31,16 +31,18 @@ static SFORMAT StateRegs[] = { { reg, 8, "REGS" }, { chr, 8, "CHRS" }, - { &IRQCount, 16, "IRQc" }, - { &IRQa, 16, "IRQa" }, + { &IRQCount, 2, "IRQc" }, + { &IRQa, 2, "IRQa" }, { 0 } }; static void Sync(void) { int i; + setprg8r(0x10, 0x6000, 0); setprg8(0x8000, reg[0]); setprg8(0xA000, reg[1]); setprg8(0xC000, reg[2]); + setprg8(0xE000, ~0); for (i = 0; i < 8; i++) setchr1(i << 10, chr[i]); setmirror(reg[3] ^ 1); @@ -67,20 +69,26 @@ static DECLFW(UNLSC127Write) { Sync(); } +static DECLFR(UNLSC127ProtRead) { + return 0x20; +} + static void UNLSC127Power(void) { + IRQCount = IRQa = 0; Sync(); - setprg8r(0x10, 0x6000, 0); - setprg8(0xE000, ~0); + SetReadHandler(0x5800, 0x5800, UNLSC127ProtRead); SetReadHandler(0x6000, 0x7fff, CartBR); SetWriteHandler(0x6000, 0x7fff, CartBW); SetReadHandler(0x8000, 0xFFFF, CartBR); SetWriteHandler(0x8000, 0xFFFF, UNLSC127Write); + FCEU_CheatAddRAM(WRAMSIZE >> 10, 0x6000, WRAM); } static void UNLSC127IRQ(void) { if (IRQa) { - IRQCount--; - if (IRQCount == 0) { + if(IRQCount > 0) + IRQCount--; + if (!IRQCount) { X6502_IRQBegin(FCEU_IQEXT); IRQa = 0; } @@ -88,6 +96,7 @@ static void UNLSC127IRQ(void) { } static void UNLSC127Reset(void) { + IRQCount = IRQa = 0; } static void UNLSC127Close(void) { From 4cf16b188715ef74287cb6fd06bb438ef8d871e6 Mon Sep 17 00:00:00 2001 From: Oggom Date: Thu, 18 Jun 2015 16:43:13 +0200 Subject: [PATCH 2/4] Backport r171 - UNIF 158B - new board for "Blood of Jurassic" dump --- Fceuwin.dev | 6 ++-- src/boards/158B.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++ src/boards/mmc1.c | 4 +++ src/unif.c | 1 + src/unif.h | 1 + 5 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 src/boards/158B.c diff --git a/Fceuwin.dev b/Fceuwin.dev index add2902..d968e62 100644 --- a/Fceuwin.dev +++ b/Fceuwin.dev @@ -1,7 +1,7 @@ [Project] FileName=Fceuwin.dev Name=Fceu -UnitCount=295 +UnitCount=297 Type=0 Ver=1 ObjFiles= @@ -2648,9 +2648,9 @@ OverrideBuildCmd=0 BuildCmd= [Unit297] -FileName=src\boards\246.c +FileName=src\boards\158B.c CompileCpp=0 -Folder=boards +Folder=boards/mmc3 based Compile=1 Link=1 Priority=1000 diff --git a/src/boards/158B.c b/src/boards/158B.c new file mode 100644 index 0000000..e7fd684 --- /dev/null +++ b/src/boards/158B.c @@ -0,0 +1,71 @@ +/* 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, 6, 0, "EXPR"); +} diff --git a/src/boards/mmc1.c b/src/boards/mmc1.c index 41877fe..0115ad9 100644 --- a/src/boards/mmc1.c +++ b/src/boards/mmc1.c @@ -191,6 +191,10 @@ static int DetectMMC1WRAMSize(uint32 crc32) { FCEU_printf(" >8KB external WRAM present. Use UNIF if you hack the ROM image.\n"); return(16); break; + case 0xd1e50064: /* Dezaemon */ + FCEU_printf(" >8KB external WRAM present. Use UNIF if you hack the ROM image.\n"); + return(32); + break; default: return(8); } } diff --git a/src/unif.c b/src/unif.c index 0c98e8a..8808a2e 100644 --- a/src/unif.c +++ b/src/unif.c @@ -450,6 +450,7 @@ static BMAPPING bmap[] = { { "VRC7", UNLVRC7_Init, 0 }, { "YOKO", UNLYOKO_Init, 0 }, { "COOLBOY", COOLBOY_Init, BMCFLAG_256KCHRR }, + { "158B", UNL158B_Init, 0 }, #ifdef COPYFAMI { "COPYFAMI_MMC3", MapperCopyFamiMMC3_Init, 0 }, diff --git a/src/unif.h b/src/unif.h index 8cce071..7821507 100644 --- a/src/unif.h +++ b/src/unif.h @@ -146,6 +146,7 @@ void UNLVRC7_Init(CartInfo *info); void UNLYOKO_Init(CartInfo *info); void UNROM_Init(CartInfo *info); void COOLBOY_Init(CartInfo *info); +void UNL158B_Init(CartInfo *info); #ifdef COPYFAMI void MapperCopyFamiMMC3_Init(CartInfo *info); From 561848064eb0f2507895a82fd14fdccf68dec0d8 Mon Sep 17 00:00:00 2001 From: Oggom Date: Thu, 18 Jun 2015 16:50:20 +0200 Subject: [PATCH 3/4] Sync unif.c and Fceuwin.dev with upstream --- Fceuwin.dev | 10 ++++++++++ src/unif.c | 15 +++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Fceuwin.dev b/Fceuwin.dev index d968e62..3f76e3c 100644 --- a/Fceuwin.dev +++ b/Fceuwin.dev @@ -3167,3 +3167,13 @@ Priority=1000 OverrideBuildCmd=0 BuildCmd= +[Unit296] +FileName=src\boards\coolboy.c +CompileCpp=0 +Folder=boards/mmc3 based +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/src/unif.c b/src/unif.c index 8808a2e..4420d2c 100644 --- a/src/unif.c +++ b/src/unif.c @@ -353,7 +353,7 @@ static BMAPPING bmap[] = { { "ELROM", ELROM_Init, 0 }, { "ETROM", ETROM_Init, 0 }, { "EWROM", EWROM_Init, 0 }, - { "FK23C", BMCFK23C_Init, BMCFLAG_256KCHRR }, + { "FK23C", BMCFK23C_Init, BMCFLAG_256KCHRR }, { "FK23CA", BMCFK23CA_Init, BMCFLAG_256KCHRR }, { "FS304", UNLFS304_Init, 0 }, { "G-146", BMCG146_Init, 0 }, @@ -449,7 +449,7 @@ static BMAPPING bmap[] = { { "UOROM", UNROM_Init, 0 }, { "VRC7", UNLVRC7_Init, 0 }, { "YOKO", UNLYOKO_Init, 0 }, - { "COOLBOY", COOLBOY_Init, BMCFLAG_256KCHRR }, + { "COOLBOY", COOLBOY_Init, BMCFLAG_256KCHRR }, { "158B", UNL158B_Init, 0 }, #ifdef COPYFAMI @@ -511,13 +511,16 @@ static int InitializeBoard(void) { if (!strcmp((char*)sboardname, (char*)bmap[x].name)) { if (!malloced[16]) { if (bmap[x].flags & BMCFLAG_16KCHRR) - CHRRAMSize = 16384; + CHRRAMSize = 16; else if (bmap[x].flags & BMCFLAG_32KCHRR) - CHRRAMSize = 32768; + CHRRAMSize = 32; + else if (bmap[x].flags & BMCFLAG_128KCHRR) + CHRRAMSize = 128; else if (bmap[x].flags & BMCFLAG_256KCHRR) - CHRRAMSize = 256 * 1024; + CHRRAMSize = 256; else - CHRRAMSize = 8192; + CHRRAMSize = 8; + CHRRAMSize <<= 10; if ((UNIFchrrama = (uint8*)FCEU_malloc(CHRRAMSize))) { SetupCartCHRMapping(0, UNIFchrrama, CHRRAMSize, 1); AddExState(UNIFchrrama, CHRRAMSize, 0, "CHRR"); From de7985a278388659c11ff9cb05b2471712060d52 Mon Sep 17 00:00:00 2001 From: Oggom Date: Thu, 18 Jun 2015 17:14:40 +0200 Subject: [PATCH 4/4] Sync libretro/fceu/unif.c with mainline --- src/drivers/libretro/fceu/unif.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/drivers/libretro/fceu/unif.c b/src/drivers/libretro/fceu/unif.c index 3b40c28..26f79a3 100644 --- a/src/drivers/libretro/fceu/unif.c +++ b/src/drivers/libretro/fceu/unif.c @@ -309,11 +309,11 @@ static int LoadCHR(FCEUFILE *fp) { return(1); } -#define BMCFLAG_FORCE4 1 -#define BMCFLAG_16KCHRR 2 -#define BMCFLAG_32KCHRR 4 -#define BMCFLAG_128KCHRR 8 -#define BMCFLAG_EXPCHRR 10 +#define BMCFLAG_FORCE4 0x01 +#define BMCFLAG_16KCHRR 0x02 +#define BMCFLAG_32KCHRR 0x04 +#define BMCFLAG_128KCHRR 0x08 +#define BMCFLAG_256KCHRR 0x10 static BMAPPING bmap[] = { { "11160", BMC11160_Init, 0 }, @@ -353,8 +353,8 @@ static BMAPPING bmap[] = { { "ELROM", ELROM_Init, 0 }, { "ETROM", ETROM_Init, 0 }, { "EWROM", EWROM_Init, 0 }, - { "FK23C", BMCFK23C_Init, BMCFLAG_EXPCHRR }, - { "FK23CA", BMCFK23CA_Init, BMCFLAG_EXPCHRR }, + { "FK23C", BMCFK23C_Init, BMCFLAG_256KCHRR }, + { "FK23CA", BMCFK23CA_Init, BMCFLAG_256KCHRR }, { "FS304", UNLFS304_Init, 0 }, { "G-146", BMCG146_Init, 0 }, { "GK-192", BMCGK192_Init, 0 }, @@ -449,7 +449,8 @@ static BMAPPING bmap[] = { { "UOROM", UNROM_Init, 0 }, { "VRC7", UNLVRC7_Init, 0 }, { "YOKO", UNLYOKO_Init, 0 }, - { "COOLBOY", COOLBOY_Init, BMCFLAG_128KCHRR }, + { "COOLBOY", COOLBOY_Init, BMCFLAG_256KCHRR }, + { "158B", UNL158B_Init, 0 }, #ifdef COPYFAMI { "COPYFAMI_MMC3", MapperCopyFamiMMC3_Init, 0 }, @@ -514,12 +515,12 @@ static int InitializeBoard(void) { else if (bmap[x].flags & BMCFLAG_32KCHRR) CHRRAMSize = 32; else if (bmap[x].flags & BMCFLAG_128KCHRR) - CHRRAMSize = 128; - else if (bmap[x].flags & BMCFLAG_EXPCHRR) + CHRRAMSize = 128; + else if (bmap[x].flags & BMCFLAG_256KCHRR) CHRRAMSize = 256; else CHRRAMSize = 8; - CHRRAMSize <<= 10; + CHRRAMSize <<= 10; if ((UNIFchrrama = (uint8*)FCEU_malloc(CHRRAMSize))) { SetupCartCHRMapping(0, UNIFchrrama, CHRRAMSize, 1); AddExState(UNIFchrrama, CHRRAMSize, 0, "CHRR");