* Fix missing GameStateRestore

* Add mapper 403

Co-authored-by: negativeExponent <negativeExponent@users.noreply.github.com>
This commit is contained in:
negativeExponent
2022-01-24 22:53:53 +08:00
committed by GitHub
parent 758a51eacb
commit 03c42f32b3
8 changed files with 108 additions and 0 deletions

81
src/boards/403.c Normal file
View File

@@ -0,0 +1,81 @@
/* FCEUmm - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2022 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 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.
*/
/* NES 2.0 Mapper 403 denotes the 89433 circuit board with up to 1 MiB PRG-ROM and 32 KiB of CHR-RAM, bankable with 8 KiB granularity.
*
* Tetris Family - 玩家 19-in-1 智瑟實典 (NO-1683)
* Sachen Superpack (versions A-C)
*/
#include "mapinc.h"
static uint8 reg[3];
static void Sync(void) {
uint8 prg = reg[0];
uint8 chr = reg[1];
uint8 mode = reg[2];
/* NROM-128 */
if (mode & 1) {
setprg16(0x8000, prg >> 1);
setprg16(0xC000, prg >> 1);
/* NROM-256 */
} else
setprg32(0x8000, prg >> 2);
setchr8(chr);
setmirror(((mode >> 4) & 1) ^ 1);
}
static DECLFW(M403Write4) {
reg[A & 3] = V;
Sync();
}
static DECLFW(M403Write8) {
if (reg[2] & 4) {
reg[1] = V;
Sync();
}
}
static void M403Reset(void) {
reg[0] = reg[1] = reg[2] = 0;
Sync();
}
static void M403Power(void) {
reg[0] = reg[1] = reg[2] = 0;
Sync();
SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x4100, 0x4103, M403Write4);
SetWriteHandler(0x8000, 0xFFFF, M403Write8);
}
static void StateRestore(void) {
Sync();
}
void Mapper403_Init(CartInfo *info) {
info->Reset = M403Reset;
info->Power = M403Power;
GameStateRestore = StateRestore;
AddExState(&reg, 3, 0, "REGS");
}