Merge pull request #329 from negativeExponent/updates_and_fixes

mapper updates and fixes
This commit is contained in:
Twinaphex
2020-02-29 19:06:15 +01:00
committed by GitHub
24 changed files with 416 additions and 516 deletions

View File

@@ -27,34 +27,42 @@ static uint8 *WRAM = NULL;
static uint32 WRAMSIZE;
static SFORMAT StateRegs[] =
{
{ &latchea, 2, "AREG" },
{ &latchea, 2 | FCEUSTATE_RLSB, "AREG" },
{ &latched, 1, "DREG" },
{ 0 }
};
static void Sync(void) {
int i;
uint32 preg[4];
uint32 bank = (latched & 0x3F) << 1;
switch (latchea & 0x03) {
case 0:
preg[0] = bank + 0;
preg[1] = bank + 1;
preg[2] = bank + 2;
preg[3] = bank + 3;
break;
case 2:
bank = bank | (latched >> 7);
preg[0] = bank;
preg[1] = bank;
preg[2] = bank;
preg[3] = bank;
break;
case 1:
case 3:
preg[0] = bank + 0;
preg[1] = bank + 1;
preg[2] = (((latchea & 0x02) == 0) ? (bank | 0xE) : bank) + 0;
preg[3] = (((latchea & 0x02) == 0) ? (bank | 0xE) : bank) + 1;
break;
}
setprg8(0x8000, preg[0]);
setprg8(0xA000, preg[1]);
setprg8(0xC000, preg[2]);
setprg8(0xE000, preg[3]);
setmirror(((latched >> 6) & 1) ^ 1);
switch (latchea) {
case 0x8000:
for (i = 0; i < 4; i++)
setprg8(0x8000 + (i << 13), (((latched & 0x7F) << 1) + i) ^ (latched >> 7));
break;
case 0x8002:
for (i = 0; i < 4; i++)
setprg8(0x8000 + (i << 13), ((latched & 0x7F) << 1) + (latched >> 7));
break;
case 0x8001:
case 0x8003:
for (i = 0; i < 4; i++) {
unsigned int b;
b = latched & 0x7F;
if (i >= 2 && !(latchea & 0x2))
b = 0x7F;
setprg8(0x8000 + (i << 13), (i & 1) + ((b << 1) ^ (latched >> 7)));
}
break;
}
}
static DECLFW(M15Write) {

View File

@@ -21,9 +21,6 @@
#include "mapinc.h"
#include "../ines.h"
static uint8 mirror;
static uint8 mask;
static void M218Power(void) {
setchr8(0);
setprg32(0x8000, 0);

View File

@@ -2,6 +2,8 @@
*
* Copyright notice for this file:
* Copyright (C) 2011 CaH4e3
* Copyright (C) 2019 Libretro Team
* Copyright (C) 2020 negativeExponent
*
* 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
@@ -19,15 +21,20 @@
*
* PCB-018 board, discrete multigame cart 110-in-1
*
* Mapper 225
* Mapper 255
*
*/
/* 2020-2-20 - merge mapper 255, re-implement extra RAM */
#include "mapinc.h"
static uint8 prot[4], prg, mode, chr, mirr;
static uint8 extraRAM[4], prg, mode, chr, mirr;
static SFORMAT StateRegs[] =
{
{ prot, 4, "PROT" },
{ extraRAM, 4, "PROT" },
{ &prg, 1, "PRG" },
{ &chr, 1, "CHR" },
{ &mode, 1, "MODE" },
@@ -55,10 +62,13 @@ static DECLFW(M225Write) {
}
static DECLFW(M225LoWrite) {
/* e.g. 115-in-1 [p1][!] CRC32 0xb39d30b4 */
if (A & 0x800) extraRAM[A & 3] = V & 0x0F;
}
static DECLFR(M225LoRead) {
return 0;
if (A & 0x800) return extraRAM[A & 3];
return X.DB;
}
static void M225Power(void) {
@@ -87,3 +97,7 @@ void Mapper225_Init(CartInfo *info) {
GameStateRestore = StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}
void Mapper255_Init(CartInfo *info) {
Mapper225_Init(info);
}

View File

@@ -2,6 +2,7 @@
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
* Copyright (C) 2020 negativeExponent
*
* 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
@@ -19,35 +20,76 @@
*/
#include "mapinc.h"
#include "../ines.h"
static uint8 *CHRRAM;
static uint32 CHRRAMSIZE;
static uint16 cmdreg;
static uint8 unrom, reg, type, openbus;
static SFORMAT StateRegs[] =
{
{ &cmdreg, 2, "CREG" },
{ &cmdreg, 2 | FCEUSTATE_RLSB, "CREG" },
{ &unrom, 1, "UNRM" },
{ &reg, 1, "UNRG" },
{ &type, 1, "TYPE" },
{ &openbus, 1, "OPNB" },
{ 0 }
};
static void Sync(void) {
if (type && unrom) {
setprg16(0x8000, 0x80 | reg & 7);
setprg16(0xC000, 0x80 | 7);
setchr8(0);
setmirror(MI_V);
} else {
uint8 bank = ((cmdreg & 0x300) >> 3) | (cmdreg & 0x1F);
if (cmdreg & 0x400)
setmirror(MI_0);
else
setmirror(((cmdreg >> 13) & 1) ^ 1);
if (cmdreg & 0x800) {
setprg16(0x8000, ((cmdreg & 0x300) >> 3) | ((cmdreg & 0x1F) << 1) | ((cmdreg >> 12) & 1));
setprg16(0xC000, ((cmdreg & 0x300) >> 3) | ((cmdreg & 0x1F) << 1) | ((cmdreg >> 12) & 1));
if (bank >= PRGsize[0] / 32768)
openbus = 1;
else if (cmdreg & 0x800) {
setprg16(0x8000, (bank << 1) | ((cmdreg >> 12) & 1));
setprg16(0xC000, (bank << 1) | ((cmdreg >> 12) & 1));
} else
setprg32(0x8000, ((cmdreg & 0x300) >> 4) | (cmdreg & 0x1F));
setprg32(0x8000, bank);
setchr8(0);
}
}
static DECLFR(M235Read) {
if (openbus) {
openbus = 0;
return X.DB;
}
return CartBR(A);
}
static DECLFW(M235Write) {
cmdreg = A;
reg = V;
Sync();
}
static void M235Close(void) {
if (CHRRAM)
FCEU_free(CHRRAM);
CHRRAM = NULL;
}
static void M235Reset(void) {
cmdreg = 0;
unrom = (unrom + type) & 1;
Sync();
}
static void M235Power(void) {
setchr8(0);
SetWriteHandler(0x8000, 0xFFFF, M235Write);
SetReadHandler(0x8000, 0xFFFF, CartBR);
SetReadHandler(0x8000, 0xFFFF, M235Read);
cmdreg = 0;
Sync();
}
@@ -57,7 +99,24 @@ static void M235Restore(int version) {
}
void Mapper235_Init(CartInfo *info) {
info->Reset = M235Reset;
info->Power = M235Power;
info->Close = M235Close;
GameStateRestore = M235Restore;
AddExState(&StateRegs, ~0, 0, 0);
/* some nes 2.0 header do can have no chr-ram.
* one such cart is 210-in-1 and Contra 4-in-1 (212-in-1,212 Hong Kong,Reset Based)(Unl).nes (0x745A6791)
*/
if (CHRsize[0] == 0) {
CHRRAMSIZE = 8192;
CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE);
SetupCartCHRMapping(0, CHRRAM, CHRRAMSIZE, 1);
AddExState(CHRRAM, CHRRAMSIZE, 0, "CRAM");
}
type = 0;
/* carts with unrom game, reset-based */
if ((info->CRC32) == 0x745A6791) /* 210-in-1 and Contra 4-in-1 (212-in-1,212 Hong Kong,Reset Based)(Unl).nes */
type = 1;
}

View File

@@ -1,79 +0,0 @@
/* FCEUmm - NES/Famicom Emulator
*
* Copyright (C) 2019 Libretro Team
*
* 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
*/
/* added 2019-5-23
* Mapper 255
* https://wiki.nesdev.com/w/index.php/INES_Mapper_225
* 115-in-1 [p1][!] CRC32 0xb39d30b4
* Seems to handle up to last game in the multicarts than m225 but causes
* graphics garbage past it, else games works fine */
#include "mapinc.h"
static uint8 preg, creg, mode, mirr;
static SFORMAT StateRegs[] =
{
{ &preg, 1, "PRG0" },
{ &creg, 1, "CHR0" },
{ &mode, 1, "MODE" },
{ &mirr, 1, "MIRR" },
{ 0 }
};
static void Sync(void) {
setprg16(0x8000, preg & ~mode);
setprg16(0xC000, preg | mode);
setchr8(creg);
setmirror(mirr ^ 1);
}
static DECLFW(M255Write) {
uint32 bank = (A >> 8 & 0x40);
preg = bank | ((A >> 6) & 0x3F);
creg = bank | (A & 0x3F);
mirr = (A >> 13) & 1;
mode = ((~A) >> 12 & 1);
Sync();
}
static void M255Power(void) {
preg = 0;
mode = 1;
Sync();
SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x8000, 0xFFFF, M255Write);
}
static void M255Reset(void) {
preg = 0;
mode = 1;
Sync();
}
static void StateRestore(int version) {
Sync();
}
void Mapper255_Init(CartInfo *info) {
info->Reset = M255Reset;
info->Power = M255Power;
GameStateRestore = StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@@ -54,6 +54,12 @@ static DECLFW(M269Write5) {
}
}
static void M269Close(void) {
if (CHRROM)
FCEU_free(CHRROM);
CHRROM = NULL;
}
static void M269Reset(void) {
EXPREGS[0] = EXPREGS[1] = EXPREGS[3] = EXPREGS[4] = 0;
EXPREGS[2] = 0x0F;
@@ -85,5 +91,6 @@ void Mapper269_Init(CartInfo *info) {
pwrap = M269PW;
info->Power = M269Power;
info->Reset = M269Reset;
info->Close = M269Close;
AddExState(EXPREGS, 5, 0, "EXPR");
}

View File

@@ -78,8 +78,6 @@ static void M534Reset(void) {
FCEU_printf("dipswitch = %d\n", EXPREGS[4]);
MMC3RegReset();
}
static void M534Close(void) {
}
void Mapper534_Init(CartInfo *info) {
GenMMC3_Init(info, 512, 512, 0, 0);
@@ -87,6 +85,5 @@ void Mapper534_Init(CartInfo *info) {
cwrap = M534CW;
info->Power = M534Power;
info->Reset = M534Reset;
info->Close = M534Close;
AddExState(EXPREGS, 5, 0, "EXPR");
}

View File

@@ -153,13 +153,7 @@ static void CNROMSync(void) {
}
void CNROM_Init(CartInfo *info) {
unsigned _no_busc, _busc;
_busc = 1; /* by default, CNROM is set to emulate bus conflicts to all games */
_no_busc = 0;
if (GameInfo->cspecial == 1)
_no_busc = 1;
uint8 CNROM_busc = 1; /* by default, CNROM is set to emulate bus conflicts to all games */
/* TODO: move these to extended database when implemented. */
switch (info->CRC32) {
@@ -171,12 +165,10 @@ void CNROM_Init(CartInfo *info) {
case 0xe41b440f: /* Sidewinder (Joy Van) */
case 0xb0c871c5: /* Wei Lai Xiao Zi (Joy Van) */
case 0xb3be2f71: /* Yanshan Chess (Unl) */
_no_busc = 1;
CNROM_busc = 0;
break;
}
if (_no_busc == 1) _busc = 0;
Latch_Init(info, CNROMSync, 0, 0x8000, 0xFFFF, 1, _busc);
Latch_Init(info, CNROMSync, 0, 0x8000, 0xFFFF, 1, CNROM_busc);
}
/*------------------ Map 7 ---------------------------*/

View File

@@ -36,105 +36,6 @@ static void S74LS374MSync(uint8 mirr) {
}
}
/* old mapper 150 and 243 */
/* static void S74LS374NSynco(void) {
setprg32(0x8000, latch[0]);
setchr8(latch[1] | latch[3] | latch[4]);
S74LS374MSync(latch[2]);
}
static DECLFW(S74LS374NWrite) {
A &= 0x4101;
if (A == 0x4100)
cmd = V & 7;
else {
switch (cmd) {
case 2: latch[0] = V & 1; latch[3] = (V & 1) << 3; break;
case 4: latch[4] = (V & 1) << 2; break;
case 5: latch[0] = V & 7; break;
case 6: latch[1] = V & 3; break;
case 7: latch[2] = V >> 1; break;
}
S74LS374NSynco();
}
}
static DECLFR(S74LS374NRead) {
uint8 ret;
if ((A & 0x4100) == 0x4100)
// ret=(X.DB&0xC0)|((~cmd)&0x3F);
ret = ((~cmd) & 0x3F) ^ dip;
else
ret = X.DB;
return ret;
}
static void S74LS374NPower(void) {
dip = 0;
latch[0] = latch[1] = latch[2] = latch[3] = latch[4] = 0;
S74LS374NSynco();
SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x4100, 0x7FFF, S74LS374NWrite);
SetReadHandler(0x4100, 0x5fff, S74LS374NRead);
}
static void S74LS374NReset(void) {
dip ^= 1;
latch[0] = latch[1] = latch[2] = latch[3] = latch[4] = 0;
S74LS374NSynco();
}
static void S74LS374NRestore(int version) {
S74LS374NSynco();
}
void S74LS374N_Init(CartInfo *info) {
info->Power = S74LS374NPower;
info->Reset = S74LS374NReset;
GameStateRestore = S74LS374NRestore;
AddExState(latch, 5, 0, "LATC");
AddExState(&cmd, 1, 0, "CMD");
AddExState(&dip, 1, 0, "DIP");
}
static void S74LS374NASynco(void) {
setprg32(0x8000, latch[0]);
setchr8(latch[1]);
S74LS374MSync(latch[2]);
}
static DECLFW(S74LS374NAWrite) {
A &= 0x4101;
if (A == 0x4100)
cmd = V & 7;
else {
switch (cmd) {
case 0: latch[0] = 0; latch[1] = 3; break;
case 2: latch[3] = (V & 1) << 3; break;
case 4: latch[1] = (latch[1] & 6) | (V & 3); break;
case 5: latch[0] = V & 1; break;
case 6: latch[1] = (latch[1] & 1) | latch[3] | ((V & 3) << 1); break;
case 7: latch[2] = V & 1; break;
}
S74LS374NASynco();
}
}
static void S74LS374NAPower(void) {
latch[0] = latch[2] = latch[3] = latch[4] = 0;
latch[1] = 3;
S74LS374NASynco();
SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x4100, 0x7FFF, S74LS374NAWrite);
}
void S74LS374NA_Init(CartInfo *info) {
info->Power = S74LS374NAPower;
GameStateRestore = S74LS374NRestore;
AddExState(latch, 5, 0, "LATC");
AddExState(&cmd, 1, 0, "CMD");
}*/
static int type;
static void S8259Synco(void) {
int x;

View File

@@ -316,6 +316,11 @@
{0xd09f778d, 217, -1}, /* 9999999-in-1 (Static Splash, Alt Mapper)[p1][!] */
{0x62ef6c79, 232, 8}, /* Quattro Sports -Aladdin */
{0x2705eaeb, 234, -1}, /* Maxi 15 */
{0x80CBCACB, 235, -1}, /* 100-in-1 (Unl).nes */
{0x6175B9A0, 235, -1}, /* 150_in_1_199x-ASp */
{0x745A6791, 235, -1}, /* 210-in-1 and Contra 4-in-1 (212-in-1,212 Hong Kong,Reset Based)(Unl).nes */
{0xDF81364D, 235, -1}, /* 260-in-1 [p1][!].nes */
{0xA38F2F1D, 235, -1}, /* 1500-in-1.nes */
{0x6f12afc5, 235, -1}, /* Golden Game 150-in-1 */
{0x2537b3e6, 241, -1}, /* Dance Xtreme - Prima (Unl) */
{0x11611e89, 241, -1}, /* Darkseed (Unl) [p1] */

View File

@@ -630,7 +630,7 @@ static BMAPPINGLocal bmap[] = {
{(uint8_t*)"BMC QUATTRO", 232, Mapper232_Init},
{(uint8_t*)"BMC 22+20-in-1 RST", 233, Mapper233_Init},
{(uint8_t*)"BMC MAXI", 234, Mapper234_Init},
{(uint8_t*)"", 235, Mapper235_Init},
{(uint8_t*)"Golden Game", 235, Mapper235_Init},
/* {(uint8_t*)"", 236, Mapper236_Init}, */
{(uint8_t*)"Teletubbies / Y2K", 237, Mapper237_Init},
{(uint8_t*)"UNL6035052", 238, UNL6035052_Init},

View File

@@ -360,7 +360,6 @@ struct _unif_db {
static struct _unif_db unif_db[] = {
{ 0x8ebad077d08e6c78ULL, "A65AS", 1, -1 }, /* 3-in-1 (N080) [p1][U][!], not a real submapper */
{ 0x117181328eb1ad23ULL, "CNROM", 0, MI_H, NO_BUSC }, /* 75 Bingo (Sachen-English) [U] */
{ 0x616851e56946893bULL, "RESETNROM-XIN1", 0, MI_V }, /* Sheng Tian 2-in-1(Unl,ResetBase)[p1].unf */
{ 0x4cd729b5ae23a3cfULL, "RESETNROM-XIN1", 0, MI_H }, /* Sheng Tian 2-in-1(Unl,ResetBase)[p2].unf */