Adding software-selectable mirroring to mapper 166/167. Rewrite mapper 518.
This commit is contained in:
95
src/boards/518.c
Normal file
95
src/boards/518.c
Normal file
@@ -0,0 +1,95 @@
|
||||
/* 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 "cartram.h"
|
||||
|
||||
static uint8 reg[2];
|
||||
static uint8 chr;
|
||||
|
||||
static void sync () {
|
||||
setprg8r(0x10, 0x6000, 0);
|
||||
if (reg[1] &0x04)
|
||||
setprg32(0x8000, reg[0]);
|
||||
else {
|
||||
setprg16(0x8000, reg[0]);
|
||||
setprg16(0xC000, 0);
|
||||
}
|
||||
setchr4(0x0000, reg[1] &0x02? chr: 0);
|
||||
setchr4(0x1000, 1);
|
||||
setmirror(reg[1] &0x01? MI_H: MI_V);
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) trapPPUAddressChange (uint32 A) {
|
||||
if (A &0x2000 && (A &0x23C0) < 0x23C0) {
|
||||
chr = A >>(10 +(reg[1] &0x01? 1: 0)) &1;
|
||||
setchr4(0x0000, reg[1] &0x02? chr: 0);
|
||||
}
|
||||
}
|
||||
|
||||
static DECLFR (readReg) {
|
||||
switch(A >>8 &7) {
|
||||
case 3: /* LPC state */
|
||||
return 0x8F;
|
||||
case 6: /* FDC */
|
||||
return 0x00;
|
||||
default:
|
||||
return X.DB;
|
||||
}
|
||||
}
|
||||
|
||||
static DECLFW (writeReg) {
|
||||
switch(A >>8 &7) {
|
||||
case 0: case 2:
|
||||
reg[A >>9 &1] = V;
|
||||
sync();
|
||||
break;
|
||||
case 3: /* LPC data */
|
||||
break;
|
||||
case 5: /* FDC */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void reset () {
|
||||
reg[0] = reg[1] = chr = 0;
|
||||
sync();
|
||||
}
|
||||
|
||||
static void power () {
|
||||
SetReadHandler(0x5000, 0x5FFF, readReg);
|
||||
SetReadHandler(0x6000, 0xFFFF, CartBR);
|
||||
SetWriteHandler(0x5000, 0x5FFF, writeReg);
|
||||
SetWriteHandler(0x6000, 0xFFFF, CartBW);
|
||||
reset();
|
||||
}
|
||||
|
||||
static void restore (int version) {
|
||||
sync();
|
||||
}
|
||||
|
||||
void Mapper518_Init (CartInfo *info) {
|
||||
WRAM_init(info, 8);
|
||||
info->Power = power;
|
||||
info->Reset = reset;
|
||||
GameStateRestore = restore;
|
||||
PPU_hook = trapPPUAddressChange;
|
||||
AddExState(&chr, 1, 0, "CHRB");
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2007 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
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Dance 2000 12-in-1
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mapinc.h"
|
||||
|
||||
static uint8 prg, mode;
|
||||
static uint8 *WRAM = NULL;
|
||||
static uint32 WRAMSIZE;
|
||||
static uint32 lastnt = 0;
|
||||
|
||||
static SFORMAT StateRegs[] =
|
||||
{
|
||||
{ &prg, 1, "REGS" },
|
||||
{ &mode, 1, "MODE" },
|
||||
{ &lastnt, 4, "LSNT" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static void Sync(void) {
|
||||
setmirror((mode ^ 1) & 1);
|
||||
setprg8r(0x10, 0x6000, 0);
|
||||
setchr4(0x0000, lastnt);
|
||||
setchr4(0x1000, 1);
|
||||
if (mode & 4)
|
||||
setprg32(0x8000, prg & 7);
|
||||
else {
|
||||
setprg16(0x8000, prg & 0x0f);
|
||||
setprg16(0xC000, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static DECLFW(UNLD2000Write) {
|
||||
switch (A) {
|
||||
case 0x5000: prg = V; Sync(); break;
|
||||
case 0x5200: mode = V; if (mode & 4) Sync(); break;
|
||||
}
|
||||
}
|
||||
|
||||
static DECLFR(UNLD2000Read) {
|
||||
if (prg & 0x40)
|
||||
return X.DB;
|
||||
else
|
||||
return CartBR(A);
|
||||
}
|
||||
|
||||
static void UNLD2000Power(void) {
|
||||
prg = mode = 0;
|
||||
Sync();
|
||||
SetReadHandler(0x6000, 0x7FFF, CartBR);
|
||||
SetWriteHandler(0x6000, 0x7FFF, CartBW);
|
||||
SetReadHandler(0x8000, 0xFFFF, UNLD2000Read);
|
||||
SetWriteHandler(0x5000, 0x5FFF, UNLD2000Write);
|
||||
FCEU_CheatAddRAM(WRAMSIZE >> 10, 0x6000, WRAM);
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) UNL2000Hook(uint32 A) {
|
||||
if (mode & 2) {
|
||||
if ((A & 0x3000) == 0x2000) {
|
||||
uint32 curnt = A & 0x800;
|
||||
if (curnt != lastnt) {
|
||||
setchr4(0x0000, curnt >> 11);
|
||||
lastnt = curnt;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lastnt = 0;
|
||||
setchr4(0x0000, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void UNLD2000Close(void) {
|
||||
if (WRAM)
|
||||
FCEU_gfree(WRAM);
|
||||
WRAM = NULL;
|
||||
}
|
||||
|
||||
static void StateRestore(int version) {
|
||||
Sync();
|
||||
}
|
||||
|
||||
void UNLD2000_Init(CartInfo *info) {
|
||||
info->Power = UNLD2000Power;
|
||||
info->Close = UNLD2000Close;
|
||||
PPU_hook = UNL2000Hook;
|
||||
GameStateRestore = StateRestore;
|
||||
|
||||
WRAMSIZE = 8192;
|
||||
WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE);
|
||||
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);
|
||||
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
|
||||
|
||||
AddExState(&StateRegs, ~0, 0, 0);
|
||||
}
|
||||
@@ -55,6 +55,7 @@ static void Sync(void) {
|
||||
}
|
||||
}
|
||||
setchr8(0);
|
||||
setmirror(regs[0] & 0x01? MI_H: MI_V);
|
||||
}
|
||||
|
||||
static DECLFW(M166Write) {
|
||||
|
||||
@@ -944,7 +944,7 @@ INES_BOARD_BEGIN()
|
||||
INES_BOARD( "Subor Karaoke", 514, Mapper514_Init )
|
||||
INES_BOARD( "Brilliant Com Cocoma Pack",516, Mapper516_Init )
|
||||
INES_BOARD( "Kkachi-wa Nolae Chingu", 517, UNROM_Init ) /* Microphone input currently not emulated */
|
||||
INES_BOARD( "DANCE2000", 518, UNLD2000_Init )
|
||||
INES_BOARD( "Subor SB96", 518, Mapper518_Init )
|
||||
INES_BOARD( "EH8813A", 519, UNLEH8813A_Init )
|
||||
INES_BOARD( "YuYuHakusho+DBZ", 520, Mapper520_Init )
|
||||
INES_BOARD( "DREAMTECH01", 521, DreamTech01_Init )
|
||||
|
||||
@@ -424,6 +424,7 @@ void Mapper511_Init(CartInfo *);
|
||||
void Mapper512_Init(CartInfo *);
|
||||
void Mapper514_Init(CartInfo *);
|
||||
void Mapper516_Init(CartInfo *);
|
||||
void Mapper518_Init(CartInfo *);
|
||||
void Mapper520_Init(CartInfo *);
|
||||
void Mapper523_Init(CartInfo *);
|
||||
void Mapper528_Init(CartInfo *);
|
||||
|
||||
@@ -456,7 +456,7 @@ static BMAPPING bmap[] = {
|
||||
{ "D1038", 59, BMCD1038_Init, 0 },
|
||||
{ "T3H53", 59, BMCD1038_Init, 0 },
|
||||
{ "DANCE", 256, UNLOneBus_Init, 0 },
|
||||
{ "DANCE2000", 518, UNLD2000_Init, 0 },
|
||||
{ "DANCE2000", 518, Mapper518_Init, 0 },
|
||||
{ "DREAMTECH01", 521, DreamTech01_Init, 0 },
|
||||
{ "EDU2000", 329, UNLEDU2000_Init, 0 },
|
||||
{ "EKROM", 5, EKROM_Init, 0 },
|
||||
|
||||
Reference in New Issue
Block a user