Mapper 449: Distinguish three circuit boards that differ in their menu selection mechanism via submapper.
This commit is contained in:
129
src/boards/449.c
129
src/boards/449.c
@@ -1,7 +1,7 @@
|
|||||||
/* FCEUmm - NES/Famicom Emulator
|
/* FCE Ultra - NES/Famicom Emulator
|
||||||
*
|
*
|
||||||
* Copyright notice for this file:
|
* Copyright notice for this file:
|
||||||
* Copyright (C) 2022
|
* Copyright (C) 2025 NewRisingSun
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -19,88 +19,71 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mapinc.h"
|
#include "mapinc.h"
|
||||||
|
#include "asic_latch.h"
|
||||||
|
|
||||||
static uint16 latchAddr;
|
uint8 submapper;
|
||||||
static uint8 latchData;
|
uint8 pad;
|
||||||
static uint8 dipswitch;
|
uint8 padSelect;
|
||||||
static uint8 dipselect;
|
|
||||||
|
|
||||||
static SFORMAT StateRegs[] =
|
static DECLFR(readPad_submapper0) {
|
||||||
{
|
return CartBR(A &~0xF | pad &0xF);
|
||||||
{ &latchAddr, 2, "ADDR" },
|
|
||||||
{ &latchData, 1, "DATA" },
|
|
||||||
{ &latchData, 1, "DIPS" },
|
|
||||||
{ &dipselect, 1, "DSEL" },
|
|
||||||
{ 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static void Mapper449_Sync(void)
|
|
||||||
{
|
|
||||||
int prg =latchAddr >>2 &0x1F | latchAddr >>3 &0x20;
|
|
||||||
if (~latchAddr &0x080)
|
|
||||||
{
|
|
||||||
setprg16(0x8000, prg);
|
|
||||||
setprg16(0xC000, prg |7);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (latchAddr &0x001)
|
|
||||||
{
|
|
||||||
setprg32(0x8000, prg >>1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setprg16(0x8000, prg);
|
|
||||||
setprg16(0xC000, prg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setchr8(latchData);
|
|
||||||
setmirror(latchAddr &0x002? MI_H: MI_V);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLFR(Mapper449_Read)
|
static DECLFR(readPad_submapper1) {
|
||||||
{
|
return pad;
|
||||||
if (dipselect)
|
|
||||||
return dipswitch &0x3;
|
|
||||||
else
|
|
||||||
if (latchAddr &0x200)
|
|
||||||
return CartBR(A | dipswitch &0xF);
|
|
||||||
else
|
|
||||||
return CartBR(A);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLFW(Mapper449_WriteDIPSelect)
|
static DECLFR(readPad_submapper2) {
|
||||||
{
|
return CartBR(A &~0x3 | pad &0x3);
|
||||||
dipselect =V &1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLFW(Mapper449_WriteLatch)
|
static void sync () {
|
||||||
{
|
int prg = Latch_address >>2 &0x1F | Latch_address >>3 &0x20 | Latch_address >>4 &0x40;
|
||||||
latchData =V;
|
if (Latch_address &0x080) {
|
||||||
latchAddr =A &0xFFFF;
|
if (Latch_address &0x001)
|
||||||
Mapper449_Sync();
|
setprg32(0x8000, prg >>1);
|
||||||
|
else {
|
||||||
|
setprg16(0x8000, prg);
|
||||||
|
setprg16(0xC000, prg);
|
||||||
|
}
|
||||||
|
setmirror(Latch_data &0x10? MI_1: MI_0);
|
||||||
|
} else {
|
||||||
|
setprg16(0x8000, prg);
|
||||||
|
setprg16(0xC000, prg | 7);
|
||||||
|
}
|
||||||
|
SetupCartCHRMapping(0, CHRptr[0], CHRsize[0], submapper == 0 && Latch_address &0x80? 0: 1);
|
||||||
|
setchr8(Latch_data);
|
||||||
|
setmirror(Latch_address &0x002? MI_H: MI_V);
|
||||||
|
SetReadHandler(0x8000, 0xFFFF, submapper == 0 && Latch_address &0x200? readPad_submapper0: submapper == 2 && padSelect &1? readPad_submapper2: CartBR);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Mapper449_Reset(void)
|
static DECLFW(writePad_submapper2) {
|
||||||
{
|
padSelect = V;
|
||||||
dipswitch++;
|
sync();
|
||||||
latchAddr =latchData =0;
|
|
||||||
Mapper449_Sync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Mapper449_Power(void)
|
static void power () {
|
||||||
{
|
pad = padSelect = 0;
|
||||||
dipselect =dipswitch =latchAddr =latchData =0;
|
Latch_power();
|
||||||
Mapper449_Sync();
|
if (submapper == 1)
|
||||||
SetWriteHandler(0x6000, 0x7FFF, Mapper449_WriteDIPSelect);
|
SetReadHandler(0x5000, 0x5FFF, readPad_submapper1);
|
||||||
SetWriteHandler(0x8000, 0xFFFF, Mapper449_WriteLatch);
|
else
|
||||||
SetReadHandler(0x6000, 0x7FFF, CartBR);
|
if (submapper == 2)
|
||||||
SetReadHandler(0x8000, 0xFFFF, Mapper449_Read);
|
SetWriteHandler(0x6000, 0x7FFF, writePad_submapper2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mapper449_Init(CartInfo *info)
|
static void reset () {
|
||||||
{
|
pad++;
|
||||||
info->Power = Mapper449_Power;
|
padSelect = 0;
|
||||||
info->Reset = Mapper449_Reset;
|
Latch_address = 0;
|
||||||
AddExState(StateRegs, ~0, 0, 0);
|
sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Mapper449_Init (CartInfo *info) {
|
||||||
|
submapper = info->submapper;
|
||||||
|
Latch_init(info, sync, 0x8000, 0xFFFF, NULL);
|
||||||
|
info->Power = power;
|
||||||
|
info->Reset = reset;
|
||||||
|
AddExState(&pad, 1, 0, "DIPS");
|
||||||
|
if (submapper == 2) AddExState(&padSelect, 1, 0, "DIPE");
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user