Add mapper 174
This commit is contained in:
37
src/boards/174.c
Normal file
37
src/boards/174.c
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/* FCE Ultra - NES/Famicom Emulator
|
||||||
|
*
|
||||||
|
* Copyright notice for this file:
|
||||||
|
* Copyright (C) 2023
|
||||||
|
*
|
||||||
|
* 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 "latch.h"
|
||||||
|
|
||||||
|
static void Sync(void) {
|
||||||
|
if (latch.addr & 0x80) {
|
||||||
|
setprg32(0x8000, (latch.addr >> 5) & 3);
|
||||||
|
} else {
|
||||||
|
setprg16(0x8000, (latch.addr >> 4) & 7);
|
||||||
|
setprg16(0xC000, (latch.addr >> 4) & 7);
|
||||||
|
}
|
||||||
|
setchr8((latch.addr >> 1) & 7);
|
||||||
|
setmirror((latch.addr & 1) ^ 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mapper174_Init(CartInfo *info) {
|
||||||
|
Latch_Init(info, Sync, NULL, 0, 0);
|
||||||
|
}
|
||||||
98
src/boards/latch.c
Normal file
98
src/boards/latch.c
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
/* FCE Ultra - NES/Famicom Emulator
|
||||||
|
*
|
||||||
|
* Copyright notice for this file:
|
||||||
|
* Copyright (C) 2023
|
||||||
|
*
|
||||||
|
* 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 "latch.h"
|
||||||
|
|
||||||
|
static uint8 bus_conflict;
|
||||||
|
static uint8 *WRAM = NULL;
|
||||||
|
static uint32 WRAMSIZE;
|
||||||
|
static void (*WSync)(void);
|
||||||
|
static readfunc defread;
|
||||||
|
|
||||||
|
LATCH latch;
|
||||||
|
|
||||||
|
DECLFW(LatchWrite) {
|
||||||
|
/* FCEU_printf("bs %04x %02x\n",A,V); */
|
||||||
|
if (bus_conflict)
|
||||||
|
V &= CartBR(A);
|
||||||
|
latch.addr = A;
|
||||||
|
latch.data = V;
|
||||||
|
WSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LatchHardReset() {
|
||||||
|
latch.addr = 0;
|
||||||
|
latch.data = 0;
|
||||||
|
WSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LatchPower(void) {
|
||||||
|
LatchHardReset();
|
||||||
|
WSync();
|
||||||
|
if (WRAM) {
|
||||||
|
SetReadHandler(0x6000, 0xFFFF, CartBR);
|
||||||
|
SetWriteHandler(0x6000, 0x7FFF, CartBW);
|
||||||
|
FCEU_CheatAddRAM(WRAMSIZE >> 10, 0x6000, WRAM);
|
||||||
|
} else {
|
||||||
|
SetReadHandler(0x8000, 0xFFFF, defread);
|
||||||
|
}
|
||||||
|
SetWriteHandler(0x8000, 0xFFFF, LatchWrite);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LatchClose(void) {
|
||||||
|
if (WRAM)
|
||||||
|
FCEU_gfree(WRAM);
|
||||||
|
WRAM = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void LatchReset(void) {
|
||||||
|
WSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void StateRestore(int version) {
|
||||||
|
WSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Latch_Init(CartInfo *info, void (*proc)(void), readfunc func,
|
||||||
|
uint8 wram, uint8 busc) {
|
||||||
|
bus_conflict = busc;
|
||||||
|
WSync = proc;
|
||||||
|
if (func != NULL)
|
||||||
|
defread = func;
|
||||||
|
else
|
||||||
|
defread = CartBROB;
|
||||||
|
info->Power = LatchPower;
|
||||||
|
info->Close = LatchClose;
|
||||||
|
info->Reset = LatchReset;
|
||||||
|
GameStateRestore = StateRestore;
|
||||||
|
if (wram) {
|
||||||
|
WRAMSIZE = 8192;
|
||||||
|
WRAM = (uint8 *)FCEU_gmalloc(WRAMSIZE);
|
||||||
|
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);
|
||||||
|
if (info->battery) {
|
||||||
|
info->SaveGame[0] = WRAM;
|
||||||
|
info->SaveGameLen[0] = WRAMSIZE;
|
||||||
|
}
|
||||||
|
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
|
||||||
|
}
|
||||||
|
AddExState(&latch.addr, 2, 0, "ADDR");
|
||||||
|
AddExState(&latch.data, 1, 0, "DATA");
|
||||||
|
}
|
||||||
17
src/boards/latch.h
Normal file
17
src/boards/latch.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#ifndef _FCEU_LATCH_H
|
||||||
|
#define _FCEU_LATCH_H
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16 addr;
|
||||||
|
uint8 data;
|
||||||
|
} LATCH;
|
||||||
|
|
||||||
|
extern LATCH latch;
|
||||||
|
|
||||||
|
void Latch_Init(CartInfo *info, void (*proc)(void), readfunc func, uint8 wram, uint8 busc);
|
||||||
|
void LatchPower(void);
|
||||||
|
void LatchClose(void);
|
||||||
|
void LatchWrite(uint32 A, uint8 V);
|
||||||
|
void LatchHardReset();
|
||||||
|
|
||||||
|
#endif /* _FCEU_LATCH_H */
|
||||||
@@ -595,7 +595,7 @@ INES_BOARD_BEGIN()
|
|||||||
INES_BOARD( "", 171, Mapper171_Init )
|
INES_BOARD( "", 171, Mapper171_Init )
|
||||||
INES_BOARD( "Super Mega P-4070", 172, Mapper172_Init )
|
INES_BOARD( "Super Mega P-4070", 172, Mapper172_Init )
|
||||||
INES_BOARD( "Idea-Tek ET.xx", 173, Mapper173_Init )
|
INES_BOARD( "Idea-Tek ET.xx", 173, Mapper173_Init )
|
||||||
/* INES_BOARD( "", 174, Mapper174_Init ) */
|
INES_BOARD( "", 174, Mapper174_Init )
|
||||||
INES_BOARD( "", 175, Mapper175_Init )
|
INES_BOARD( "", 175, Mapper175_Init )
|
||||||
INES_BOARD( "BMCFK23C", 176, Mapper176_Init )
|
INES_BOARD( "BMCFK23C", 176, Mapper176_Init )
|
||||||
INES_BOARD( "", 177, Mapper177_Init )
|
INES_BOARD( "", 177, Mapper177_Init )
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ void Mapper170_Init(CartInfo *);
|
|||||||
void Mapper171_Init(CartInfo *);
|
void Mapper171_Init(CartInfo *);
|
||||||
void Mapper172_Init(CartInfo *);
|
void Mapper172_Init(CartInfo *);
|
||||||
void Mapper173_Init(CartInfo *);
|
void Mapper173_Init(CartInfo *);
|
||||||
|
void Mapper174_Init(CartInfo *);
|
||||||
void Mapper175_Init(CartInfo *);
|
void Mapper175_Init(CartInfo *);
|
||||||
void Mapper176_Init(CartInfo *);
|
void Mapper176_Init(CartInfo *);
|
||||||
void Mapper177_Init(CartInfo *);
|
void Mapper177_Init(CartInfo *);
|
||||||
|
|||||||
Reference in New Issue
Block a user