74 lines
1.9 KiB
C++
Raw Normal View History

2009-07-17 17:27:04 +00:00
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2006 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 17:18:20 +00:00
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2009-07-17 17:27:04 +00:00
*/
#include "mapinc.h"
2016-09-17 20:43:24 -07:00
static uint8 bank, base, lock, mirr, mode;
2012-12-14 17:43:51 +00:00
static SFORMAT StateRegs[] =
2009-07-17 17:27:04 +00:00
{
2012-12-14 17:43:51 +00:00
{ &bank, 1, "BANK" },
{ &base, 1, "BASE" },
{ &lock, 1, "LOCK" },
{ &mirr, 1, "MIRR" },
2016-09-17 20:43:24 -07:00
{ &mode, 1, "MODE" },
2012-12-14 17:43:51 +00:00
{ 0 }
2009-07-17 17:27:04 +00:00
};
2012-12-14 17:43:51 +00:00
static void Sync(void) {
setchr8(0);
setprg16(0x8000, base | bank);
2016-09-17 20:43:24 -07:00
setprg16(0xC000, base | (mode ? bank : 7));
2012-12-14 17:43:51 +00:00
setmirror(mirr);
2009-07-17 17:27:04 +00:00
}
2012-12-14 17:43:51 +00:00
static DECLFW(BMCT262Write) {
if (!lock) {
base = ((A & 0x60) >> 2) | ((A & 0x100) >> 3);
2016-09-17 20:43:24 -07:00
mode = A & 0x80;
2012-12-14 17:43:51 +00:00
mirr = ((A & 2) >> 1) ^ 1;
lock = (A & 0x2000) >> 13;
}
bank = V & 7;
Sync();
2009-07-17 17:27:04 +00:00
}
2012-12-14 17:43:51 +00:00
static void BMCT262Power(void) {
2016-09-17 20:43:24 -07:00
lock = bank = base = mode = 0;
2012-12-14 17:43:51 +00:00
Sync();
SetWriteHandler(0x8000, 0xFFFF, BMCT262Write);
SetReadHandler(0x8000, 0xFFFF, CartBR);
2009-07-17 17:27:04 +00:00
}
2012-12-14 17:43:51 +00:00
static void BMCT262Reset(void) {
2016-09-17 20:43:24 -07:00
lock = bank = base = mode = 0;
2012-12-14 17:43:51 +00:00
Sync();
2009-07-17 17:27:04 +00:00
}
2012-12-14 17:43:51 +00:00
static void BMCT262Restore(int version) {
Sync();
2009-07-17 17:27:04 +00:00
}
2012-12-14 17:43:51 +00:00
void BMCT262_Init(CartInfo *info) {
info->Power = BMCT262Power;
info->Reset = BMCT262Reset;
GameStateRestore = BMCT262Restore;
AddExState(&StateRegs, ~0, 0, 0);
2009-07-17 17:27:04 +00:00
}