Add solder-pad-based menu selection to mapper 285. Make Latch_clear public and use it to reset multicarts to menu instead of Latch_power.

This commit is contained in:
NewRisingSun
2025-09-09 13:44:14 +02:00
parent ee20cce026
commit b2de421d4d
20 changed files with 155 additions and 63 deletions

78
src/boards/285.c Normal file
View File

@@ -0,0 +1,78 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2025 NewRisingSun
*
* 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
*/
#include "mapinc.h"
#include "asic_latch.h"
static uint8 pad;
static void sync_submapper0 () {
if (Latch_data &0x40)
setprg32(0x8000, Latch_data >>1);
else {
setprg16(0x8000, Latch_data);
setprg16(0xC000, Latch_data |7);
}
setchr8(0);
if (Latch_data &0x80)
setmirror(Latch_data &0x20? MI_1: MI_0);
else
setmirror(Latch_data &0x20? MI_H: MI_V);
}
static void sync_submapper1 () {
if (Latch_data &0x40)
setprg32(0x8000, Latch_data >>1 &0x03 | Latch_data >>2 &~0x03);
else {
setprg16(0x8000, Latch_data >>1 &~0x07 | Latch_data &0x07);
setprg16(0xC000, Latch_data >>1 | 0x07);
}
setchr8(0);
if (Latch_data &0x80)
setmirror(Latch_data &0x20? MI_1: MI_0);
else
setmirror(Latch_data &0x08? MI_H: MI_V);
}
static DECLFR (readPad) {
if (A &0x80) return pad >= 20? (4 | pad % 20): 0; else
if (A &0x40) return pad >= 16? (4 | pad % 16): 0; else
if (A &0x20) return pad >= 12? (4 | pad % 12): 0; else
if (A &0x10) return pad >= 8? (4 | pad % 8): 0; else
return pad >= 8? 0: pad &7;
}
static void power() {
pad = 0;
Latch_power();
SetReadHandler(0x5000, 0x5FFF, readPad);
}
static void reset() {
pad = ++pad %24;
Latch_clear();
}
void Mapper285_Init (CartInfo *info) {
Latch_init(info, info->submapper ==1? sync_submapper1: sync_submapper0, 0x8000, 0xFFFF, NULL);
info->Power = power;
info->Reset = reset;
AddExState(&pad, 1, 0, "DIPS");
}

View File

@@ -44,5 +44,5 @@ static void trapLatchWrite (uint16 *newAddress, uint8 *newValue, uint8 romValue)
void Mapper573_Init (CartInfo *info) {
Latch_init(info, sync, 0x8000, 0xFFFF, trapLatchWrite);
info->Reset = Latch_power;
info->Reset = Latch_clear;
}

View File

@@ -45,5 +45,5 @@ static void trapLatchWrite (uint16 *newAddress, uint8 *newValue, uint8 romValue)
void Mapper579_Init (CartInfo *info) {
Latch_init(info, sync, 0x8000, 0xFFFF, trapLatchWrite);
info->Reset = Latch_power;
info->Reset = Latch_clear;
}

View File

@@ -35,5 +35,5 @@ static void sync () {
void Mapper580_Init (CartInfo *info) {
Latch_init(info, sync, 0x8000, 0xFFFF, NULL);
info->Reset = Latch_power;
info->Reset = Latch_clear;
}

View File

@@ -44,5 +44,5 @@ static void trapLatchWrite (uint16 *newAddress, uint8 *newValue, uint8 romValue)
void Mapper581_Init (CartInfo *info) {
Latch_init(info, sync, 0x8000, 0xFFFF, trapLatchWrite);
info->Reset = Latch_power;
info->Reset = Latch_clear;
}

View File

@@ -46,5 +46,5 @@ static void trapLatchWrite (uint16 *newAddress, uint8 *newValue, uint8 romValue)
void Mapper583_Init (CartInfo *info) {
Latch_init(info, sync, 0x8000, 0xFFFF, trapLatchWrite);
info->Reset = Latch_power;
info->Reset = Latch_clear;
}

59
src/boards/584.c Normal file
View File

@@ -0,0 +1,59 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2025 NewRisingSun
*
* 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
*/
#include "mapinc.h"
static uint8 reg[2];
static void sync () {
if (reg[0] &0x20)
setprg32(0x8000, reg[0] >>1);
else {
setprg16(0x8000, reg[0]);
setprg16(0xC000, reg[0]);
}
setchr8(reg[1]);
setmirror(reg[1] &0x20? MI_V: MI_H);
}
static DECLFW(writeReg) {
if (A &0x100) {
reg[A >>13 &1] = V;
sync();
}
}
static void power() {
SetReadHandler(0x6000, 0xFFFF, CartBR);
SetWriteHandler(0x4020, 0x7FFF, writeReg);
reg[0] = reg[1] = 0;
sync();
}
static void stateRestore(int version) {
sync();
}
void Mapper584_Init (CartInfo *info) {
info->Reset = power;
info->Power = power;
GameStateRestore = stateRestore;
AddExState(reg, 2, 0, "REGS");
}

View File

@@ -46,8 +46,7 @@ static void power() {
static void reset() {
pad += 0x20;
Latch_address = 0;
sync();
Latch_clear();
}
void Mapper585_Init (CartInfo *info) {

View File

@@ -33,5 +33,5 @@ static void sync () {
void Mapper586_Init (CartInfo *info) {
Latch_init(info, sync, 0x8000, 0xFFFF, NULL);
info->Reset = Latch_power;
info->Reset = Latch_clear;
}

View File

@@ -39,5 +39,5 @@ static void trapLatchWrite (uint16 *newAddress, uint8 *newValue, uint8 romValue)
void Mapper589_Init (CartInfo *info) {
Latch_init(info, sync, 0x8000, 0xFFFF, trapLatchWrite);
info->Reset = Latch_power;
info->Reset = Latch_clear;
}

View File

@@ -33,5 +33,5 @@ static void sync () {
void Mapper590_Init (CartInfo *info) {
Latch_init(info, sync, 0x8000, 0xFFFF, NULL);
info->Reset = Latch_power;
info->Reset = Latch_clear;
}

View File

@@ -34,5 +34,5 @@ static void sync () {
void Mapper591_Init (CartInfo *info) {
Latch_init(info, sync, 0x8000, 0xFFFF, NULL);
info->Reset = Latch_power;
info->Reset = Latch_clear;
}

View File

@@ -30,5 +30,5 @@ static void sync () {
void Mapper592_Init (CartInfo *info) {
Latch_init(info, sync, 0x8000, 0xFFFF, NULL);
info->Reset = Latch_power;
info->Reset = Latch_clear;
}

View File

@@ -41,7 +41,7 @@ DECLFW(Latch_write) {
Latch_cbSync();
}
static void Latch_clear () {
void Latch_clear () {
Latch_address = 0;
Latch_data = 0;
Latch_cbSync();

View File

@@ -27,6 +27,7 @@ extern uint8 Latch_data;
DECLFW (Latch_write);
void Latch_addExState ();
void Latch_restore (int);
void Latch_clear ();
void Latch_power ();
void Latch_activate (uint8, void (*)(), uint16, uint16, void (*)(uint16*, uint8*, uint8));
void Latch6_activate (uint8, void (*)(), uint16, uint16, void (*)(uint16*, uint8*, uint8));

View File

@@ -507,53 +507,6 @@ void Mapper538_Init(CartInfo *info) {
info->Power = M538Power;
}
/* ------------------ A65AS --------------------------- */
/* actually, there is two cart in one... First have extra mirroring
* mode (one screen) and 32K bankswitching, second one have only
* 16 bankswitching mode and normal mirroring... But there is no any
* correlations between modes and they can be used in one mapper code.
*
* Submapper 0 - 3-in-1 (N068)
* Submapper 0 - 3-in-1 (N080)
* Submapper 1 - 4-in-1 (JY-066)
*/
static int A65ASsubmapper;
static void BMCA65ASSync(void) {
if (latche & 0x40)
setprg32(0x8000, (latche >> 1) & 0x0F);
else {
if (A65ASsubmapper == 1) {
setprg16(0x8000, ((latche & 0x30) >> 1) | (latche & 7));
setprg16(0xC000, ((latche & 0x30) >> 1) | 7);
} else {
setprg16(0x8000, latche & 0x0F);
setprg16(0xC000, latche & 0x0F | 7);
}
}
setchr8(0);
if (latche & 0x80)
setmirror(MI_0 + (((latche >> 5) & 1)));
else {
if (A65ASsubmapper == 1)
setmirror(latche &0x08? MI_H: MI_V);
else
setmirror(latche &0x20? MI_H: MI_V);
}
}
void BMCA65AS_Reset() {
latche =0;
BMCA65ASSync();
}
void BMCA65AS_Init(CartInfo *info) {
A65ASsubmapper = info->submapper;
info->Reset = BMCA65AS_Reset;
Latch_Init(info, BMCA65ASSync, 0, 0x8000, 0xFFFF, 0, 0);
}
/*------------------ BMC-11160 ---------------------------*/
/* Simple BMC discrete mapper by TXC */

View File

@@ -734,7 +734,7 @@ INES_BOARD_BEGIN()
INES_BOARD( "YY860417C", 281, Mapper281_Init )
INES_BOARD( "860224C", 282, Mapper282_Init )
INES_BOARD( "GS-2004/GS-2013", 283, Mapper283_Init )
INES_BOARD( "A65AS", 285, BMCA65AS_Init )
INES_BOARD( "A65AS", 285, Mapper285_Init )
INES_BOARD( "BS-5", 286, BMCBS5_Init )
INES_BOARD( "411120-C, 811120-C", 287, BMC411120C_Init )
INES_BOARD( "GKCX1", 288, Mapper288_Init )
@@ -960,6 +960,7 @@ INES_BOARD_BEGIN()
INES_BOARD( "ET-156", 580, Mapper580_Init )
INES_BOARD( "ET-82", 581, Mapper581_Init )
INES_BOARD( "8203", 583, Mapper583_Init )
INES_BOARD( "ST-32", 584, Mapper584_Init )
INES_BOARD( "FE-01-1", 585, Mapper585_Init )
INES_BOARD( "HN-02", 586, Mapper586_Init )
INES_BOARD( "3355", 587, Mapper587_Init )

View File

@@ -425,6 +425,7 @@ void Mapper579_Init(CartInfo *);
void Mapper580_Init(CartInfo *);
void Mapper581_Init(CartInfo *);
void Mapper583_Init(CartInfo *);
void Mapper584_Init(CartInfo *);
void Mapper585_Init(CartInfo *);
void Mapper586_Init(CartInfo *);
void Mapper587_Init(CartInfo *);

View File

@@ -437,7 +437,7 @@ static BMAPPING bmap[] = {
{ "8237", 215, UNL8237_Init, 0 },
{ "8237A", 215, UNL8237A_Init, 0 },
{ "830118C", 348, BMC830118C_Init, 0 },
{ "A65AS", 285, BMCA65AS_Init, 0 },
{ "A65AS", 285, Mapper285_Init, 0 },
{ "AB-G1L", 428, Mapper428_Init, 0 },
{ "WELL-NO-DG450", 428, Mapper428_Init, 0 },
{ "TF2740", 428, Mapper428_Init, 0 },

View File

@@ -30,7 +30,7 @@ void BMC411120C_Init(CartInfo *info);
void BMC64in1nr_Init(CartInfo *info);
void BMC810544CA1_Init(CartInfo *info);
void BMC830118C_Init(CartInfo *info);
void BMCA65AS_Init(CartInfo *info);
void Mapper285_Init(CartInfo *info);
void BMCBS5_Init(CartInfo *info);
void BMCD1038_Init(CartInfo *info);
void BMCFK23CA_Init(CartInfo *info);