mapper 002 - workaround for "Top Gun" issue #621, need test if this isn't broke something other

mapper 012 - added hardware dip for language select
UNIF PEC-586 - fixed render finally, added 512K cartridges suppport, TODO: PEC keyboard
This commit is contained in:
CaH4e3 2013-09-15 10:41:42 +00:00
parent a6c62b4b5f
commit 0220dabeb4
6 changed files with 92 additions and 73 deletions

View File

@ -36,12 +36,15 @@ static SFORMAT StateRegs[] =
};
static void Sync(void) {
setprg4(0x5000, 16); // Only YS-612 advanced version
setprg4(0x5000, 8 << 1); // Only YS-612 advanced version
setprg8(0x6000, swap?0:2);
setprg8(0x8000, 1);
setprg8(0xa000, 0);
setprg8(0xc000, reg);
setprg8(0xe000, swap?8:9);
setprg8(0xe000, swap?8:9); // hard dump for mr.Mary is 128K,
// bank 9 is the last 2K ok bank 8 repeated 4 times, then till the end of 128K
// instead used bank A, containing some CHR data, ines rom have unused banks removed,
// and bank A moved to the bank 9 place for compatibility with other crappy dumps
setchr8(0);
}

View File

@ -30,7 +30,7 @@ static void (*WSync)(void);
static DECLFW(LatchWrite) {
// FCEU_printf("bs %04x %02x\n",A,V);
if (bus_conflict)
latche = V & CartBR(A);
latche = (V == CartBR(A)) ? V : 0;
else
latche = V;
WSync();

View File

@ -33,7 +33,7 @@ uint32 WRAMSIZE;
uint8 *CHRRAM;
uint32 CHRRAMSIZE;
uint8 DRegBuf[8];
uint8 EXPREGS[8]; /* For bootleg games, mostly. */
uint8 EXPREGS[8]; /* For bootleg games, mostly. */
uint8 A000B, A001B;
uint8 mmc3opts = 0;
@ -79,7 +79,7 @@ void FixMMC3PRG(int V) {
} else {
pwrap(0x8000, DRegBuf[6]);
pwrap(0xC000, ~1);
}
}
pwrap(0xA000, DRegBuf[7]);
pwrap(0xE000, ~0);
}
@ -216,11 +216,11 @@ void GenMMC3Restore(int version) {
}
static void GENCWRAP(uint32 A, uint8 V) {
setchr1(A, V); // Business Wars NEEDS THIS for 8K CHR-RAM
setchr1(A, V); // Business Wars NEEDS THIS for 8K CHR-RAM
}
static void GENPWRAP(uint32 A, uint8 V) {
setprg8(A, V & 0x7F); // [NJ102] Mo Dao Jie (C) has 1024Mb MMC3 BOARD, maybe something other will be broken
setprg8(A, V & 0x7F); // [NJ102] Mo Dao Jie (C) has 1024Mb MMC3 BOARD, maybe something other will be broken
}
static void GENMWRAP(uint8 V) {
@ -305,11 +305,11 @@ void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery) {
info->Reset = MMC3RegReset;
info->Close = GenMMC3Close;
if (info->CRC32 == 0x5104833e) // Kick Master
if (info->CRC32 == 0x5104833e) // Kick Master
GameHBIRQHook = MMC3_hb_KickMasterHack;
else if (info->CRC32 == 0x5a6860f1 || info->CRC32 == 0xae280e20) // Shougi Meikan '92/'93
else if (info->CRC32 == 0x5a6860f1 || info->CRC32 == 0xae280e20)// Shougi Meikan '92/'93
GameHBIRQHook = MMC3_hb_KickMasterHack;
else if (info->CRC32 == 0xfcd772eb) // PAL Star Wars, similar problem as Kick Master.
else if (info->CRC32 == 0xfcd772eb) // PAL Star Wars, similar problem as Kick Master.
GameHBIRQHook = MMC3_hb_PALStarWarsHack;
else
GameHBIRQHook = MMC3_hb;
@ -322,7 +322,7 @@ void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery) {
// ---------------------------- Mapper 4 --------------------------------
static int hackm4 = 0; /* For Karnov, maybe others. BLAH. Stupid iNES format.*/
static int hackm4 = 0; /* For Karnov, maybe others. BLAH. Stupid iNES format.*/
static void M4Power(void) {
GenMMC3Power();
@ -353,10 +353,22 @@ static DECLFW(M12Write) {
EXPREGS[1] = (V & 0x10) >> 4;
}
static DECLFR(M12Read) {
return EXPREGS[2];
}
static void M12Power(void) {
EXPREGS[0] = EXPREGS[1] = 0;
EXPREGS[2] = 1; // chinese is default
GenMMC3Power();
SetWriteHandler(0x4100, 0x5FFF, M12Write);
SetReadHandler(0x4100, 0x5FFF, M12Read);
}
static void M12Reset(void) {
EXPREGS[0] = EXPREGS[1] = 0;
EXPREGS[2] ^= 1;
MMC3RegReset();
}
void Mapper12_Init(CartInfo *info) {
@ -365,6 +377,7 @@ void Mapper12_Init(CartInfo *info) {
isRevB = 0;
info->Power = M12Power;
info->Reset = M12Reset;
AddExState(EXPREGS, 2, 0, "EXPR");
}
@ -461,7 +474,7 @@ static void M45CW(uint32 A, uint8 V) {
NV &= (1 << ((EXPREGS[2] & 7) + 1)) - 1;
else
if (EXPREGS[2])
NV &= 0; // hack ;( don't know exactly how it should be
NV &= 0; // hack ;( don't know exactly how it should be
NV |= EXPREGS[0] | ((EXPREGS[2] & 0xF0) << 4);
setchr1(A, NV);
}
@ -609,7 +622,7 @@ static void M52PW(uint32 A, uint8 V) {
static void M52CW(uint32 A, uint8 V) {
uint32 mask = 0xFF ^ ((EXPREGS[0] & 0x40) << 1);
// uint32 bank = (((EXPREGS[0]>>3)&4)|((EXPREGS[0]>>1)&2)|((EXPREGS[0]>>6)&(EXPREGS[0]>>4)&1))<<7;
uint32 bank = (((EXPREGS[0] >> 4) & 2) | (EXPREGS[0] & 4) | ((EXPREGS[0] >> 6) & (EXPREGS[0] >> 4) & 1)) << 7; // actually 256K CHR banks index bits is inverted!
uint32 bank = (((EXPREGS[0] >> 4) & 2) | (EXPREGS[0] & 4) | ((EXPREGS[0] >> 6) & (EXPREGS[0] >> 4) & 1)) << 7; // actually 256K CHR banks index bits is inverted!
setchr1(A, bank | (V & mask));
}
@ -659,7 +672,7 @@ void Mapper76_Init(CartInfo *info) {
// ---------------------------- Mapper 74 -------------------------------
static void M74CW(uint32 A, uint8 V) {
if ((V == 8) || (V == 9)) //Di 4 Ci - Ji Qi Ren Dai Zhan (As).nes, Ji Jia Zhan Shi (As).nes
if ((V == 8) || (V == 9)) //Di 4 Ci - Ji Qi Ren Dai Zhan (As).nes, Ji Jia Zhan Shi (As).nes
setchr1r(0x10, A, V);
else
setchr1r(0, A, V);
@ -735,7 +748,7 @@ void Mapper114_Init(CartInfo *info) {
static void M115PW(uint32 A, uint8 V) {
if (EXPREGS[0] & 0x80) {
if (EXPREGS[0] & 0x20)
setprg32(0x8000, (EXPREGS[0] & 0x0F) >> 1); // real hardware tests, info 100% now lol
setprg32(0x8000, (EXPREGS[0] & 0x0F) >> 1); // real hardware tests, info 100% now lol
else {
setprg16(0x8000, (EXPREGS[0] & 0x0F));
setprg16(0xC000, (EXPREGS[0] & 0x0F));
@ -750,7 +763,7 @@ static void M115CW(uint32 A, uint8 V) {
static DECLFW(M115Write) {
if (A == 0x5080)
EXPREGS[2] = V; // Extra prot hardware 2-in-1 mode
EXPREGS[2] = V; // Extra prot hardware 2-in-1 mode
else if (A == 0x6000)
EXPREGS[0] = V;
else if (A == 0x6001)
@ -940,7 +953,7 @@ void Mapper192_Init(CartInfo *info) {
// ---------------------------- Mapper 194 -------------------------------
static void M194CW(uint32 A, uint8 V) {
if (V <= 1) //Dai-2-Ji - Super Robot Taisen (As).nes
if (V <= 1) //Dai-2-Ji - Super Robot Taisen (As).nes
setchr1r(0x10, A, V);
else
setchr1r(0, A, V);
@ -957,7 +970,7 @@ void Mapper194_Init(CartInfo *info) {
// ---------------------------- Mapper 195 -------------------------------
static void M195CW(uint32 A, uint8 V) {
if (V <= 3) // Crystalis (c).nes, Captain Tsubasa Vol 2 - Super Striker (C)
if (V <= 3) // Crystalis (c).nes, Captain Tsubasa Vol 2 - Super Striker (C)
setchr1r(0x10, A, V);
else
setchr1r(0, A, V);
@ -1028,7 +1041,7 @@ void Mapper196_Init(CartInfo *info) {
// all data bits merged, because it's using one of them as 8000 reg...
static void UNLMaliSBPW(uint32 A, uint8 V) {
setprg8(A, (V & 3)|((V & 8) >> 1)|((V & 4) << 1));
setprg8(A, (V & 3) | ((V & 8) >> 1) | ((V & 4) << 1));
}
static void UNLMaliSBCW(uint32 A, uint8 V) {
@ -1076,7 +1089,7 @@ void Mapper197_Init(CartInfo *info) {
// ---------------------------- Mapper 198 -------------------------------
static void M198PW(uint32 A, uint8 V) {
if (V >= 0x50) // Tenchi o Kurau II - Shokatsu Koumei Den (J) (C).nes
if (V >= 0x50) // Tenchi o Kurau II - Shokatsu Koumei Den (J) (C).nes
setprg8(A, V & 0x4F);
else
setprg8(A, V);
@ -1128,7 +1141,7 @@ static void M205Reset(void) {
static void M205Power(void) {
GenMMC3Power();
SetWriteHandler(0x6000, 0x6fff, M205Write0);
SetWriteHandler(0x7000, 0x7fff, M205Write1); // OK-411 boards, the same logic, but data latched, 2-in-1 frankenstein
SetWriteHandler(0x7000, 0x7fff, M205Write1); // OK-411 boards, the same logic, but data latched, 2-in-1 frankenstein
}
void Mapper205_Init(CartInfo *info) {
@ -1143,7 +1156,7 @@ void Mapper205_Init(CartInfo *info) {
// ---------------------------- Mapper 245 ------------------------------
static void M245CW(uint32 A, uint8 V) {
if (!UNIFchrrama) // Yong Zhe Dou E Long - Dragon Quest VI (As).nes NEEDS THIS for RAM cart
if (!UNIFchrrama) // Yong Zhe Dou E Long - Dragon Quest VI (As).nes NEEDS THIS for RAM cart
setchr1(A, V & 7);
EXPREGS[0] = V;
FixMMC3PRG(MMC3_cmd);
@ -1172,7 +1185,7 @@ static void M249PW(uint32 A, uint8 V) {
if (EXPREGS[0] & 0x2) {
if (V < 0x20)
V = (V & 1) | ((V >> 3) & 2) | ((V >> 1) & 4) | ((V << 2) & 8) | ((V << 2) & 0x10);
else{
else {
V -= 0x20;
V = (V & 3) | ((V >> 1) & 4) | ((V >> 4) & 8) | ((V >> 2) & 0x10) | ((V << 3) & 0x20) | ((V << 2) & 0xC0);
}

View File

@ -20,7 +20,7 @@
#include "mapinc.h"
static uint8 reg[7], debug = 1;
static uint8 reg[8];
static uint32 lastnt = 0;
static uint8 *WRAM = NULL;
static uint32 WRAMSIZE;
@ -33,14 +33,14 @@ static SFORMAT StateRegs[] =
};
static uint8 bs_tbl[128] = {
0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33,
0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67,
0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33,
0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67,
0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32,
0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67,
0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x00, 0x10, 0x20, 0x30,
0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67,
0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, // 00
0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, // 10
0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, // 20
0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, // 30
0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, // 40
0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, // 50
0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x00, 0x10, 0x20, 0x30, // 60
0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, // 70
};
static uint8 br_tbl[16] = {
@ -48,21 +48,29 @@ static uint8 br_tbl[16] = {
};
static void Sync(void) {
if (reg[0]&0x80) {
setchr4(0x0000, (lastnt >> 9) ^ 0);
setchr4(0x1000, (lastnt >> 9) ^ 1);
} else {
setchr4(0x0000, 1);
setchr4(0x1000, 0);
}
setchr8(0);
setprg8r(0x10, 0x6000, 0);
setprg16(0x8000, bs_tbl[reg[0] & 0x7f] >> 4);
setprg16(0xc000, bs_tbl[reg[0] & 0x7f] & 0xf);
setmirror(MI_V);
if(PRGsize[0] == 512 * 1024) {
if(reg[0] & 0x010) {
setprg32(0x8000, reg[0] & 7);
} else {
if(reg[0] & 0x40)
setprg8(0x8000, (reg[0] & 0x0F) | 0x20 | ((reg[0] & 0x20) >> 1));
}
if((reg[0] & 0x18) == 0x18)
setmirror(MI_H);
else
setmirror(MI_V);
} else {
setprg16(0x8000, bs_tbl[reg[0] & 0x7f] >> 4);
setprg16(0xc000, bs_tbl[reg[0] & 0x7f] & 0xf);
setmirror(MI_V);
}
}
static DECLFW(UNLPEC586Write) {
reg[(A & 0x700) >> 8] = V;
PEC586Hack = (reg[0] & 0x80) >> 7;
// FCEU_printf("bs %04x %02x\n", A, V);
Sync();
}
@ -72,34 +80,27 @@ static DECLFR(UNLPEC586Read) {
return (X.DB & 0xD8) | br_tbl[reg[4] >> 4];
}
static void UNLPEC586Power(void) {
reg[0] = 0x0E;
debug ^= 1;
Sync();
setchr8(0);
SetReadHandler(0x6000, 0x7FFF, CartBR);
SetWriteHandler(0x6000, 0x7FFF, CartBW);
SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x5000, 0x5fff, UNLPEC586Write);
SetReadHandler(0x5000, 0x5fff, UNLPEC586Read);
static DECLFR(UNLPEC586ReadHi) {
if((reg[0] & 0x10) || ((reg[0] & 0x40) && (A < 0xA000)))
return CartBR(A);
else
return PRGptr[0][((0x0107 | ((A >> 7) & 0x0F8)) << 10) | (A & 0x3FF)];
}
static void UNLPEC586PPU(uint32 A) {
if (reg[0]&0x80)
{
if (((A & 0x3FFF) > 0x2000) && ((A & 0x3FFF) < 0x23C0)) {
uint32 curnt = A & 0x200;
if (curnt != lastnt) {
setchr4(0x0000, (curnt >> 9) ^ 0);
setchr4(0x1000, (curnt >> 9) ^ 1);
lastnt = curnt;
}
}
} else {
lastnt = 0;
setchr4(0x0000, 1);
setchr4(0x1000, 0);
}
static void UNLPEC586Power(void) {
if(PRGsize[0] == 512 * 1024)
reg[0] = 0x00;
else
reg[0] = 0x0E;
Sync();
SetReadHandler(0x6000, 0x7FFF, CartBR);
SetWriteHandler(0x6000, 0x7FFF, CartBW);
if(PRGsize[0] == 512 * 1024)
SetReadHandler(0x8000, 0xFFFF, UNLPEC586ReadHi);
else
SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x5000, 0x5fff, UNLPEC586Write);
SetReadHandler(0x5000, 0x5fff, UNLPEC586Read);
}
static void UNLPEC586Close(void) {
@ -115,11 +116,8 @@ static void StateRestore(int version) {
void UNLPEC586Init(CartInfo *info) {
info->Power = UNLPEC586Power;
info->Close = UNLPEC586Close;
PPU_hook = UNLPEC586PPU;
GameStateRestore = StateRestore;
PEC586Hack = 1;
WRAMSIZE = 8192;
WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE);
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);

View File

@ -1034,7 +1034,10 @@ static void RefreshLine(int lastpixel) {
vofs = 0;
vofs = ((PPU[0] & 0x10) << 8) | ((RefreshAddr >> 12) & 7);
if(PEC586Hack)
vofs = ((RefreshAddr & 0x200) << 3) | ((RefreshAddr >> 12) & 7);
else
vofs = ((PPU[0] & 0x10) << 8) | ((RefreshAddr >> 12) & 7);
if (!ScreenON && !SpriteON) {
uint32 tem;
@ -1894,6 +1897,8 @@ struct BGData {
INLINE void Read() {
RefreshAddr = ppur.get_ntread();
if (PEC586Hack)
ppur.s = (RefreshAddr & 0x200) >> 9;
pecnt = (RefreshAddr & 1) << 3;
nt = CALL_PPUREAD(RefreshAddr);
runppu(kFetchTime);

View File

@ -10,7 +10,7 @@ extern void (*PPU_hook)(uint32 A);
extern void (*GameHBIRQHook)(void), (*GameHBIRQHook2)(void);
/* For cart.c and banksw.h, mostly */
extern uint8 NTARAM[0x800],*vnapage[4];
extern uint8 NTARAM[0x800], *vnapage[4];
extern uint8 PPUNTARAM;
extern uint8 PPUCHRRAM;