fceugx/source/fceultra/boards/bs-5.cpp

85 lines
2.1 KiB
C++
Raw Normal View History

2009-07-17 19:27:04 +02:00
/* 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
2012-12-14 18:18:20 +01:00
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2009-07-17 19:27:04 +02:00
*/
#include "mapinc.h"
static uint8 reg_prg[4];
static uint8 reg_chr[4];
static uint8 dip_switch;
2012-12-14 18:43:51 +01:00
static SFORMAT StateRegs[] =
2009-07-17 19:27:04 +02:00
{
2012-12-14 18:43:51 +01:00
{ reg_prg, 4, "PREG" },
{ reg_chr, 4, "CREG" },
{ 0 }
2009-07-17 19:27:04 +02:00
};
2012-12-14 18:43:51 +01:00
static void Sync(void) {
setprg8(0x8000, reg_prg[0]);
setprg8(0xa000, reg_prg[1]);
setprg8(0xc000, reg_prg[2]);
setprg8(0xe000, reg_prg[3]);
setchr2(0x0000, reg_chr[0]);
setchr2(0x0800, reg_chr[1]);
setchr2(0x1000, reg_chr[2]);
setchr2(0x1800, reg_chr[3]);
setmirror(MI_V);
2009-07-17 19:27:04 +02:00
}
2012-12-14 18:43:51 +01:00
static DECLFW(MBS5Write) {
int bank_sel = (A & 0xC00) >> 10;
switch (A & 0xF000) {
case 0x8000:
reg_chr[bank_sel] = A & 0x1F;
break;
case 0xA000:
if (A & (1 << (dip_switch + 4)))
reg_prg[bank_sel] = A & 0x0F;
break;
}
Sync();
2009-07-17 19:27:04 +02:00
}
2012-12-14 18:43:51 +01:00
static void MBS5Reset(void) {
dip_switch++;
dip_switch &= 3;
reg_prg[0] = reg_prg[1] = reg_prg[2] = reg_prg[3] = ~0;
Sync();
2009-07-17 19:27:04 +02:00
}
2012-12-14 18:43:51 +01:00
static void MBS5Power(void) {
dip_switch = 0;
reg_prg[0] = reg_prg[1] = reg_prg[2] = reg_prg[3] = ~0;
Sync();
SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x8000, 0xFFFF, MBS5Write);
2009-07-17 19:27:04 +02:00
}
2012-12-14 18:43:51 +01:00
static void StateRestore(int version) {
Sync();
2009-07-17 19:27:04 +02:00
}
2012-12-14 18:43:51 +01:00
void BMCBS5_Init(CartInfo *info) {
info->Power = MBS5Power;
info->Reset = MBS5Reset;
GameStateRestore = StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
2009-07-17 19:27:04 +02:00
}