Mapper 226: Updated and remove duplicate mapper
- Updated mapper 226 to support 1.5mb carts, which in turn makes Unif Ghostbusters63n1 a duplicate. - Unif 42in1ResetSwitch switch to mapper 233
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2005 CaH4e3
|
||||
* Copyright (C) 2009 qeed
|
||||
* 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
|
||||
@@ -22,10 +23,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* Updated 2019-07-12
|
||||
* Mapper 266 - Updated and combine UNIF Ghostbusters63in1 board (1.5 MB carts), different bank order
|
||||
* - some 1MB carts can switch game lists using Select
|
||||
* Mapper 233 - UNIF 42in1ResetSwitch - reset-based switching
|
||||
*/
|
||||
|
||||
#include "mapinc.h"
|
||||
|
||||
static uint8 reorder_banks = 0;
|
||||
static uint8 isresetbased = 0;
|
||||
static uint8 latche[2], reset;
|
||||
static uint8 banks[4] = { 0, 0, 1, 2 };
|
||||
static SFORMAT StateRegs[] =
|
||||
{
|
||||
{ &reset, 1, "RST" },
|
||||
@@ -34,11 +43,17 @@ static SFORMAT StateRegs[] =
|
||||
};
|
||||
|
||||
static void Sync(void) {
|
||||
uint8 bank;
|
||||
uint8 bank = 0;
|
||||
uint8 base = ((latche[0] & 0x80) >> 7) | ((latche[1] & 1) << 1);
|
||||
|
||||
if (isresetbased)
|
||||
bank = (latche[0] & 0x1f) | (reset << 5) | ((latche[1] & 1) << 6);
|
||||
else
|
||||
bank = (latche[0] & 0x1f) | ((latche[0] & 0x80) >> 2) | ((latche[1] & 1) << 6);
|
||||
else {
|
||||
if (reorder_banks) /* for 1536 KB prg roms */
|
||||
base = banks[base];
|
||||
bank = (base << 5) | (latche[0] & 0x1f);
|
||||
}
|
||||
|
||||
if (!(latche[0] & 0x20))
|
||||
setprg32(0x8000, bank >> 1);
|
||||
else {
|
||||
@@ -65,19 +80,29 @@ static void StateRestore(int version) {
|
||||
Sync();
|
||||
}
|
||||
|
||||
static void M226Reset(void) {
|
||||
latche[0] = latche[1] = reset = 0;
|
||||
Sync();
|
||||
}
|
||||
|
||||
void Mapper226_Init(CartInfo *info) {
|
||||
isresetbased = 0;
|
||||
/* 1536KiB PRG roms have different bank order */
|
||||
reorder_banks = ((info->prgRom * 16) == 1536) ? 1 : 0;
|
||||
info->Power = M226Power;
|
||||
info->Reset = M226Reset;
|
||||
AddExState(&StateRegs, ~0, 0, 0);
|
||||
GameStateRestore = StateRestore;
|
||||
}
|
||||
|
||||
static void M233Reset(void) {
|
||||
latche[0] = latche[1] = 0;
|
||||
reset ^= 1;
|
||||
Sync();
|
||||
}
|
||||
|
||||
void Mapper233_Init(CartInfo *info) {
|
||||
reorder_banks = 0;
|
||||
isresetbased = 1;
|
||||
info->Power = M226Power;
|
||||
info->Reset = M233Reset;
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2007 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
|
||||
* 63in1 ghostbusters
|
||||
*/
|
||||
|
||||
#include "mapinc.h"
|
||||
|
||||
static uint8 reg[2], bank;
|
||||
static uint8 banks[4] = { 0, 0, 1, 2 };
|
||||
static uint8 *CHRROM = NULL;
|
||||
static uint32 CHRROMSIZE;
|
||||
|
||||
static SFORMAT StateRegs[] =
|
||||
{
|
||||
{ reg, 2, "REGS" },
|
||||
{ &bank, 1, "BANK" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static void Sync(void) {
|
||||
if (reg[0] & 0x20) {
|
||||
setprg16(0x8000, (banks[bank] << 5) | (reg[0] & 0x1F));
|
||||
setprg16(0xC000, (banks[bank] << 5) | (reg[0] & 0x1F));
|
||||
} else
|
||||
setprg32(0x8000, ((banks[bank] << 5) | (reg[0] & 0x1F)) >> 1);
|
||||
if (reg[1] & 2)
|
||||
setchr8r(0x10, 0);
|
||||
else
|
||||
setchr8(0);
|
||||
setmirror((reg[0] & 0x40) >> 6);
|
||||
}
|
||||
|
||||
static DECLFW(BMCGhostbusters63in1Write) {
|
||||
reg[A & 1] = V;
|
||||
bank = ((reg[0] & 0x80) >> 7) | ((reg[1] & 1) << 1);
|
||||
/* FCEU_printf("reg[0]=%02x, reg[1]=%02x, bank=%02x\n",reg[0],reg[1],bank); */
|
||||
Sync();
|
||||
}
|
||||
|
||||
static DECLFR(BMCGhostbusters63in1Read) {
|
||||
if (bank == 1)
|
||||
return X.DB;
|
||||
else
|
||||
return CartBR(A);
|
||||
}
|
||||
|
||||
static void BMCGhostbusters63in1Power(void) {
|
||||
reg[0] = reg[1] = 0;
|
||||
Sync();
|
||||
SetReadHandler(0x8000, 0xFFFF, BMCGhostbusters63in1Read);
|
||||
SetWriteHandler(0x8000, 0xFFFF, BMCGhostbusters63in1Write);
|
||||
}
|
||||
|
||||
static void BMCGhostbusters63in1Reset(void) {
|
||||
reg[0] = reg[1] = 0;
|
||||
}
|
||||
|
||||
static void StateRestore(int version) {
|
||||
Sync();
|
||||
}
|
||||
|
||||
static void BMCGhostbusters63in1Close(void) {
|
||||
if (CHRROM)
|
||||
FCEU_gfree(CHRROM);
|
||||
CHRROM = NULL;
|
||||
}
|
||||
|
||||
void BMCGhostbusters63in1_Init(CartInfo *info) {
|
||||
info->Reset = BMCGhostbusters63in1Reset;
|
||||
info->Power = BMCGhostbusters63in1Power;
|
||||
info->Close = BMCGhostbusters63in1Close;
|
||||
|
||||
CHRROMSIZE = 8192; /* dummy CHRROM, VRAM disable */
|
||||
CHRROM = (uint8*)FCEU_gmalloc(CHRROMSIZE);
|
||||
SetupCartPRGMapping(0x10, CHRROM, CHRROMSIZE, 0);
|
||||
AddExState(CHRROM, CHRROMSIZE, 0, "CROM");
|
||||
|
||||
GameStateRestore = StateRestore;
|
||||
AddExState(&StateRegs, ~0, 0, 0);
|
||||
}
|
||||
Reference in New Issue
Block a user