Add mappers 362 and 398
This commit is contained in:
191
src/boards/362.c
Normal file
191
src/boards/362.c
Normal file
@@ -0,0 +1,191 @@
|
||||
/* 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
|
||||
*/
|
||||
|
||||
/* NES 2.0 Mapper 362 - PCB 830506C
|
||||
* 1995 Super HiK 4-in-1 (JY-005)
|
||||
*/
|
||||
|
||||
#include "mapinc.h"
|
||||
|
||||
static uint8 game;
|
||||
static uint8 PPUCHRBus;
|
||||
static uint8 vrc4Prg[2];
|
||||
static uint8 vrc4Mirr;
|
||||
static uint8 vrc4Misc;
|
||||
static uint16 vrc4Chr[8];
|
||||
static uint8 vrc4IRQLatch;
|
||||
static uint8 vrc4IRQa;
|
||||
static uint8 vrc4IRQCount;
|
||||
static int16 vrc4IRQCycles;
|
||||
|
||||
static SFORMAT StateRegs[] = {
|
||||
{ &game, 1, "GAME" },
|
||||
{ &PPUCHRBus, 1, "CHRB" },
|
||||
{ vrc4Prg, 2, "V4PR" },
|
||||
{ &vrc4Mirr, 1, "V4MI" },
|
||||
{ &vrc4Misc, 1, "V4MS" },
|
||||
{ vrc4Chr, 16, "V4CH" },
|
||||
{ &vrc4IRQLatch, 1, "VILA" },
|
||||
{ &vrc4IRQa, 1, "VIMO" },
|
||||
{ &vrc4IRQCount, 1, "VICO" },
|
||||
{ &vrc4IRQCycles, 2, "VICY" },
|
||||
{ 0 },
|
||||
};
|
||||
|
||||
static void Sync(void) {
|
||||
uint32 cbase = (vrc4Misc << 13) & 0x4000;
|
||||
uint32 prgBase = (game == 0) ? ((vrc4Chr[PPUCHRBus] & 0x180) >> 3) : 0x40;
|
||||
uint32 chrBase = (game == 0) ? (vrc4Chr[PPUCHRBus] & 0x180) : 0x200;
|
||||
uint32 chrMask = (game == 0) ? 0x7F : 0x1FF;
|
||||
|
||||
setprg8(0x8000 ^ cbase, prgBase | (vrc4Prg[0] & 0x0F));
|
||||
setprg8(0xA000, prgBase | (vrc4Prg[1] & 0x0F));
|
||||
setprg8(0xC000 ^ cbase, prgBase | ((~1) & 0x0F));
|
||||
setprg8(0xE000, prgBase | ((~0) & 0x0F));
|
||||
|
||||
setchr1(0x0000, chrBase | (vrc4Chr[0] & chrMask));
|
||||
setchr1(0x0400, chrBase | (vrc4Chr[1] & chrMask));
|
||||
setchr1(0x0800, chrBase | (vrc4Chr[2] & chrMask));
|
||||
setchr1(0x0C00, chrBase | (vrc4Chr[3] & chrMask));
|
||||
setchr1(0x1000, chrBase | (vrc4Chr[4] & chrMask));
|
||||
setchr1(0x1400, chrBase | (vrc4Chr[5] & chrMask));
|
||||
setchr1(0x1800, chrBase | (vrc4Chr[6] & chrMask));
|
||||
setchr1(0x1C00, chrBase | (vrc4Chr[7] & chrMask));
|
||||
|
||||
switch (vrc4Mirr & 0x03) {
|
||||
case 0: setmirror(MI_V); break;
|
||||
case 1: setmirror(MI_H); break;
|
||||
case 2: setmirror(MI_0); break;
|
||||
case 3: setmirror(MI_1); break;
|
||||
}
|
||||
}
|
||||
|
||||
static DECLFW(writeVRC4) {
|
||||
uint8 index;
|
||||
A &= 0xF003;
|
||||
switch (A & 0xF000) {
|
||||
case 0x8000:
|
||||
case 0xA000:
|
||||
vrc4Prg[(A >> 13) & 1] = V;
|
||||
Sync();
|
||||
break;
|
||||
case 0x9000:
|
||||
if (~A & 2) {
|
||||
vrc4Mirr = V;
|
||||
} else if (~A & 1) {
|
||||
vrc4Misc = V;
|
||||
}
|
||||
Sync();
|
||||
break;
|
||||
case 0xF000:
|
||||
switch (A & 3) {
|
||||
case 0:
|
||||
vrc4IRQLatch = (vrc4IRQLatch & 0xF0) | (V & 0x0F);
|
||||
break;
|
||||
case 1:
|
||||
vrc4IRQLatch = (vrc4IRQLatch & 0x0F) | (V << 4);
|
||||
break;
|
||||
case 2:
|
||||
vrc4IRQa = V;
|
||||
if (vrc4IRQa & 0x02) {
|
||||
vrc4IRQCount = vrc4IRQLatch;
|
||||
vrc4IRQCycles = 341;
|
||||
}
|
||||
X6502_IRQEnd(FCEU_IQEXT);
|
||||
break;
|
||||
case 3:
|
||||
/* vrc4IRQa = (vrc4IRQa & ~0x02) | ((vrc4IRQa << 1) & 0x02); */
|
||||
X6502_IRQEnd(FCEU_IQEXT);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
index = ((A - 0xB000) >> 11) | ((A >> 1) & 1);
|
||||
if (A & 1) {
|
||||
vrc4Chr[index] = (vrc4Chr[index] & 0x0F) | (V << 4);
|
||||
} else {
|
||||
vrc4Chr[index] = (vrc4Chr[index] & ~0x0F) | (V & 0x0F);
|
||||
}
|
||||
Sync();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) M362CPUHook(int a) {
|
||||
int count = a;
|
||||
while (count--) {
|
||||
if ((vrc4IRQa & 0x02) && ((vrc4IRQa & 0x04) || ((vrc4IRQCycles -= 3) <= 0))) {
|
||||
if (~vrc4IRQa & 0x04) {
|
||||
vrc4IRQCycles += 341;
|
||||
}
|
||||
if (!++vrc4IRQCount) {
|
||||
vrc4IRQCount = vrc4IRQLatch;
|
||||
X6502_IRQBegin(FCEU_IQEXT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) M362PPUHook(uint32 A) {
|
||||
uint8 bank = (A & 0x1FFF) >> 10;
|
||||
if ((game == 0) && (PPUCHRBus != bank) && ((A & 0x3000) != 0x2000)) {
|
||||
PPUCHRBus = bank;
|
||||
Sync();
|
||||
}
|
||||
}
|
||||
|
||||
static void M362Reset(void) {
|
||||
if (PRGsize[0] <= (512 * 1024)) {
|
||||
game = 0;
|
||||
} else {
|
||||
game = (game + 1) & 0x01;
|
||||
}
|
||||
Sync();
|
||||
}
|
||||
|
||||
static void M362Power(void) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
vrc4Prg[i] = 0;
|
||||
}
|
||||
for (i = 0; i < 8; i++) {
|
||||
vrc4Chr[i] = 0;
|
||||
}
|
||||
vrc4Mirr = vrc4Misc = vrc4IRQLatch = vrc4IRQa = vrc4IRQCount = vrc4IRQCycles = 0;
|
||||
PPUCHRBus = game = 0;
|
||||
Sync();
|
||||
|
||||
SetReadHandler(0x8000, 0xFFFF, CartBR);
|
||||
SetWriteHandler(0x8000, 0xFFFF, writeVRC4);
|
||||
}
|
||||
|
||||
static void StateRestore(int version) {
|
||||
Sync();
|
||||
}
|
||||
|
||||
void Mapper362_Init(CartInfo *info) {
|
||||
info->Reset = M362Reset;
|
||||
info->Power = M362Power;
|
||||
MapIRQHook = M362CPUHook;
|
||||
PPU_hook = M362PPUHook;
|
||||
GameStateRestore = StateRestore;
|
||||
AddExState(StateRegs, ~0, 0, 0);
|
||||
}
|
||||
185
src/boards/398.c
Normal file
185
src/boards/398.c
Normal file
@@ -0,0 +1,185 @@
|
||||
/* 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
|
||||
*/
|
||||
|
||||
/* NES 2.0 Mapper 398 - PCB YY840820C
|
||||
* 1995 Super HiK 5-in-1 - 新系列米奇老鼠組合卡 (JY-048)
|
||||
*/
|
||||
|
||||
#include "mapinc.h"
|
||||
|
||||
static uint8 latch;
|
||||
static uint8 PPUCHRBus;
|
||||
static uint8 vrc4Prg[2];
|
||||
static uint8 vrc4Mirr;
|
||||
static uint8 vrc4Misc;
|
||||
static uint16 vrc4Chr[8];
|
||||
static uint8 vrc4IRQLatch;
|
||||
static uint8 vrc4IRQa;
|
||||
static uint8 vrc4IRQCount;
|
||||
static int16 vrc4IRQCycles;
|
||||
|
||||
static SFORMAT StateRegs[] = {
|
||||
{ &latch, 1, "GAME" },
|
||||
{ &PPUCHRBus, 1, "CHRB" },
|
||||
{ vrc4Prg, 2, "V4PR" },
|
||||
{ &vrc4Mirr, 1, "V4MI" },
|
||||
{ &vrc4Misc, 1, "V4MS" },
|
||||
{ vrc4Chr, 16, "V4CH" },
|
||||
{ &vrc4IRQLatch, 1, "VILA" },
|
||||
{ &vrc4IRQa, 1, "VIMO" },
|
||||
{ &vrc4IRQCount, 1, "VICO" },
|
||||
{ &vrc4IRQCycles, 2, "VICY" },
|
||||
{ 0 },
|
||||
};
|
||||
|
||||
static void Sync(void) {
|
||||
if (latch & 0x80) {
|
||||
/* GNROM-like */
|
||||
setprg32(0x8000, ((latch >> 5) & 0x06) | ((vrc4Chr[PPUCHRBus] >> 2) & 0x01));
|
||||
setchr8(0x40 | ((latch >> 3) & 0x08) | (vrc4Chr[PPUCHRBus] & 0x07));
|
||||
} else {
|
||||
uint32 cbase = (vrc4Misc << 13) & 0x4000;
|
||||
|
||||
setprg8(0x8000 ^ cbase, (vrc4Prg[0] & 0x0F));
|
||||
setprg8(0xA000, (vrc4Prg[1] & 0x0F));
|
||||
setprg8(0xC000 ^ cbase, ((~1) & 0x0F));
|
||||
setprg8(0xE000, ((~0) & 0x0F));
|
||||
|
||||
setchr1(0x0000, (vrc4Chr[0] & 0x1FF));
|
||||
setchr1(0x0400, (vrc4Chr[1] & 0x1FF));
|
||||
setchr1(0x0800, (vrc4Chr[2] & 0x1FF));
|
||||
setchr1(0x0C00, (vrc4Chr[3] & 0x1FF));
|
||||
setchr1(0x1000, (vrc4Chr[4] & 0x1FF));
|
||||
setchr1(0x1400, (vrc4Chr[5] & 0x1FF));
|
||||
setchr1(0x1800, (vrc4Chr[6] & 0x1FF));
|
||||
setchr1(0x1C00, (vrc4Chr[7] & 0x1FF));
|
||||
}
|
||||
|
||||
switch (vrc4Mirr & 0x03) {
|
||||
case 0: setmirror(MI_V); break;
|
||||
case 1: setmirror(MI_H); break;
|
||||
case 2: setmirror(MI_0); break;
|
||||
case 3: setmirror(MI_1); break;
|
||||
}
|
||||
}
|
||||
|
||||
static DECLFW(writeVRC4) {
|
||||
uint8 index;
|
||||
latch = A & 0xFF;
|
||||
A &= 0xF003;
|
||||
switch (A & 0xF000) {
|
||||
case 0x8000:
|
||||
case 0xA000:
|
||||
vrc4Prg[(A >> 13) & 1] = V;
|
||||
break;
|
||||
case 0x9000:
|
||||
if (~A & 2) {
|
||||
vrc4Mirr = V;
|
||||
} else if (~A & 1) {
|
||||
vrc4Misc = V;
|
||||
}
|
||||
break;
|
||||
case 0xF000:
|
||||
switch (A & 3) {
|
||||
case 0: vrc4IRQLatch = (vrc4IRQLatch & 0xF0) | (V & 0x0F); break;
|
||||
case 1: vrc4IRQLatch = (vrc4IRQLatch & 0x0F) | (V << 4); break;
|
||||
case 2:
|
||||
vrc4IRQa = V;
|
||||
if (vrc4IRQa & 0x02) {
|
||||
vrc4IRQCount = vrc4IRQLatch;
|
||||
vrc4IRQCycles = 341;
|
||||
}
|
||||
X6502_IRQEnd(FCEU_IQEXT);
|
||||
break;
|
||||
case 3:
|
||||
vrc4IRQa = (vrc4IRQa & ~0x02) | ((vrc4IRQa << 1) & 0x02);
|
||||
X6502_IRQEnd(FCEU_IQEXT);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
index = ((A - 0xB000) >> 11) | ((A >> 1) & 1);
|
||||
if (A & 1) {
|
||||
vrc4Chr[index] = (vrc4Chr[index] & 0x0F) | (V << 4);
|
||||
} else {
|
||||
vrc4Chr[index] = (vrc4Chr[index] & ~0x0F) | (V & 0x0F);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Sync();
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) M398CPUHook(int a) {
|
||||
int count = a;
|
||||
while (count--) {
|
||||
if ((vrc4IRQa & 0x02) && ((vrc4IRQa & 0x04) || ((vrc4IRQCycles -= 3) <= 0))) {
|
||||
if (~vrc4IRQa & 0x04) {
|
||||
vrc4IRQCycles += 341;
|
||||
}
|
||||
if (!++vrc4IRQCount) {
|
||||
vrc4IRQCount = vrc4IRQLatch;
|
||||
X6502_IRQBegin(FCEU_IQEXT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) M398PPUHook(uint32 A) {
|
||||
uint8 bank = (A & 0x1FFF) >> 10;
|
||||
if ((PPUCHRBus != bank) && ((A & 0x3000) != 0x2000)) {
|
||||
PPUCHRBus = bank;
|
||||
Sync();
|
||||
}
|
||||
}
|
||||
|
||||
static void M398Reset(void) {
|
||||
latch = 0xC0;
|
||||
Sync();
|
||||
}
|
||||
|
||||
static void M398Power(void) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
vrc4Prg[i] = 0;
|
||||
for (i = 0; i < 8; i++)
|
||||
vrc4Chr[i] = 0;
|
||||
vrc4Mirr = vrc4Misc = vrc4IRQLatch = vrc4IRQa = vrc4IRQCount = vrc4IRQCycles = 0;
|
||||
PPUCHRBus = 0;
|
||||
latch = 0xC0;
|
||||
Sync();
|
||||
|
||||
SetReadHandler(0x8000, 0xFFFF, CartBR);
|
||||
SetWriteHandler(0x8000, 0xFFFF, writeVRC4);
|
||||
}
|
||||
|
||||
static void StateRestore(int version) {
|
||||
Sync();
|
||||
}
|
||||
|
||||
void Mapper398_Init(CartInfo *info) {
|
||||
info->Reset = M398Reset;
|
||||
info->Power = M398Power;
|
||||
MapIRQHook = M398CPUHook;
|
||||
PPU_hook = M398PPUHook;
|
||||
GameStateRestore = StateRestore;
|
||||
AddExState(StateRegs, ~0, 0, 0);
|
||||
}
|
||||
@@ -769,6 +769,7 @@ INES_BOARD_BEGIN()
|
||||
INES_BOARD( "SB-5013/GCL8050/841242C", 359, Mapper359_Init )
|
||||
INES_BOARD( "Bitcorp 31-in-1", 360, Mapper360_Init )
|
||||
INES_BOARD( "OK-411", 361, GN45_Init ) /* OK-411 is emulated together with GN-45 */
|
||||
INES_BOARD( "830506C", 362, Mapper362_Init )
|
||||
INES_BOARD( "JY830832C", 364, Mapper364_Init )
|
||||
INES_BOARD( "GN-45", 366, GN45_Init )
|
||||
INES_BOARD( "Yung-08", 368, Mapper368_Init )
|
||||
@@ -795,6 +796,7 @@ INES_BOARD_BEGIN()
|
||||
INES_BOARD( "Realtec 8210", 395, Mapper395_Init )
|
||||
INES_BOARD( "YY850437C", 396, Mapper396_Init )
|
||||
INES_BOARD( "YY850439C", 397, Mapper397_Init )
|
||||
INES_BOARD( "YY840820C", 398, Mapper398_Init )
|
||||
INES_BOARD( "BMC Super 19-in-1 (VIP19)",401, Mapper401_Init )
|
||||
INES_BOARD( "831019C J-2282", 402, J2282_Init )
|
||||
INES_BOARD( "89433", 403, Mapper403_Init )
|
||||
|
||||
@@ -281,6 +281,7 @@ void Mapper357_Init(CartInfo *);
|
||||
void Mapper358_Init(CartInfo *);
|
||||
void Mapper359_Init(CartInfo *);
|
||||
void Mapper360_Init(CartInfo *);
|
||||
void Mapper362_Init(CartInfo *);
|
||||
void Mapper364_Init(CartInfo *);
|
||||
void Mapper368_Init(CartInfo *);
|
||||
void Mapper369_Init(CartInfo *);
|
||||
@@ -306,6 +307,7 @@ void Mapper394_Init(CartInfo *);
|
||||
void Mapper395_Init(CartInfo *);
|
||||
void Mapper396_Init(CartInfo *);
|
||||
void Mapper397_Init(CartInfo *);
|
||||
void Mapper398_Init(CartInfo *);
|
||||
void Mapper401_Init(CartInfo *);
|
||||
void Mapper403_Init(CartInfo *);
|
||||
void Mapper404_Init(CartInfo *);
|
||||
|
||||
Reference in New Issue
Block a user