Rewrite mapper 340.

This commit is contained in:
NewRisingSun
2025-09-17 20:25:14 +02:00
parent 1ac2f351ee
commit 3969360227
6 changed files with 47 additions and 72 deletions

43
src/boards/340.c Normal file
View File

@@ -0,0 +1,43 @@
/* 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 void sync () {
int prg = Latch_address >>2 &0x20 | Latch_address &0x1F;
if (Latch_address &0x20) {
if (Latch_address &0x01) {
setprg16(0x8000, prg);
setprg16(0xC000, prg);
} else
setprg32(0x8000, prg >>1);
} else {
setprg16(0x8000, prg);
setprg16(0xC000, prg | 7);
}
setchr8(0);
setmirror(Latch_address &0x040 || (Latch_address &0x025) == 0x025 || (Latch_address &0x118) == 0x010? MI_H: MI_V);
}
void Mapper340_Init (CartInfo *info) {
Latch_init(info, sync, 0x8000, 0xFFFF, NULL);
info->Reset = Latch_clear;
}

View File

@@ -1,69 +0,0 @@
/* FCEUmm - NES/Famicom Emulator
*
* Copyright (C) 2019 Libretro Team
*
* 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 regs[2];
static SFORMAT StateRegs[] =
{
{ regs, 2, "REGS" },
{ 0 }
};
static void Sync(void) {
if (regs[0] &0x20) { /* NROM-128 */
setprg16(0x8000, regs[0] >>2 &0x20 | regs[0] &0x1F);
setprg16(0xC000, regs[0] >>2 &0x20 | regs[0] &0x1F);
} else { /* UNROM */
setprg16(0x8000, regs[0] >>2 &0x20 | regs[0] | regs[1] &7);
setprg16(0xC000, regs[0] >>2 &0x20 | regs[0] | 7);
}
setchr8(0);
setmirror((regs[0] &0x40 || regs[0] &0x20 && regs[0] &0x04)? MI_H: MI_V);
}
static DECLFW(M340Write) {
regs[0] = A & 0xFF;
regs[1] = V;
Sync();
}
static void BMCK3036Power(void) {
Sync();
SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x8000, 0xFFFF, M340Write);
}
static void BMCK3036Reset(void) {
regs[0] = regs[1] = 0;
Sync();
}
static void StateRestore(int version) {
Sync();
}
void BMCK3036_Init(CartInfo *info) {
info->Power = BMCK3036Power;
info->Reset = BMCK3036Reset;
GameStateRestore = StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@@ -785,7 +785,7 @@ INES_BOARD_BEGIN()
INES_BOARD( "CTC-12IN1", 337, BMCCTC12IN1_Init )
INES_BOARD( "SA005-A", 338, BMCSA005A_Init )
INES_BOARD( "K-3006", 339, BMCK3006_Init )
INES_BOARD( "K-3036", 340, BMCK3036_Init )
INES_BOARD( "K-3036", 340, Mapper340_Init )
INES_BOARD( "TJ-03", 341, BMCTJ03_Init )
INES_BOARD( "COOLGIRL", 342, COOLGIRL_Init )
INES_BOARD( "GN-26", 344, BMCGN26_Init )

View File

@@ -279,6 +279,7 @@ void Mapper321_Init(CartInfo *);
void Mapper326_Init(CartInfo *);
void Mapper330_Init(CartInfo *);
void Mapper334_Init(CartInfo *);
void Mapper340_Init(CartInfo *);
void Mapper351_Init(CartInfo *);
void Mapper352_Init(CartInfo *);
void Mapper353_Init(CartInfo *);

View File

@@ -595,7 +595,7 @@ static BMAPPING bmap[] = {
{ "K-3046", 336, BMCK3046_Init, 0 },
{ "SA005-A", 338, BMCSA005A_Init, 0 },
{ "K-3006", 339, BMCK3006_Init, 0 },
{ "K-3036", 340, BMCK3036_Init, 0 },
{ "K-3036", 340, Mapper340_Init, 0 },
{ "KS7021A", 525, UNLKS7021A_Init, 0 },
{ "KS106C", NO_INES, BMCKS106C_Init, 0 }, /* split roms */
{ "900218", 524, BTL900218_Init, 0 },

View File

@@ -164,7 +164,7 @@ void BMCCTC09_Init(CartInfo *info); /* m335 */
void BMCK3046_Init(CartInfo *info); /* m336 */
void BMCSA005A_Init(CartInfo *info); /* m338 */
void BMCK3006_Init(CartInfo *info); /* m339 */
void BMCK3036_Init(CartInfo *info); /* m340 */
void Mapper340_Init(CartInfo *info); /* m340 */
void MINDKIDS_Init(CartInfo *info); /* m268 */
void UNLKS7021A_Init(CartInfo *info); /* m525 */
void BTL900218_Init(CartInfo *info); /* m524 */