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) { 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(0x6000, swap?0:2);
setprg8(0x8000, 1); setprg8(0x8000, 1);
setprg8(0xa000, 0); setprg8(0xa000, 0);
setprg8(0xc000, reg); 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); setchr8(0);
} }

View File

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

View File

@ -307,7 +307,7 @@ void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery) {
if (info->CRC32 == 0x5104833e) // Kick Master if (info->CRC32 == 0x5104833e) // Kick Master
GameHBIRQHook = MMC3_hb_KickMasterHack; 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; 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; GameHBIRQHook = MMC3_hb_PALStarWarsHack;
@ -353,10 +353,22 @@ static DECLFW(M12Write) {
EXPREGS[1] = (V & 0x10) >> 4; EXPREGS[1] = (V & 0x10) >> 4;
} }
static DECLFR(M12Read) {
return EXPREGS[2];
}
static void M12Power(void) { static void M12Power(void) {
EXPREGS[0] = EXPREGS[1] = 0; EXPREGS[0] = EXPREGS[1] = 0;
EXPREGS[2] = 1; // chinese is default
GenMMC3Power(); GenMMC3Power();
SetWriteHandler(0x4100, 0x5FFF, M12Write); 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) { void Mapper12_Init(CartInfo *info) {
@ -365,6 +377,7 @@ void Mapper12_Init(CartInfo *info) {
isRevB = 0; isRevB = 0;
info->Power = M12Power; info->Power = M12Power;
info->Reset = M12Reset;
AddExState(EXPREGS, 2, 0, "EXPR"); AddExState(EXPREGS, 2, 0, "EXPR");
} }
@ -1028,7 +1041,7 @@ void Mapper196_Init(CartInfo *info) {
// all data bits merged, because it's using one of them as 8000 reg... // all data bits merged, because it's using one of them as 8000 reg...
static void UNLMaliSBPW(uint32 A, uint8 V) { 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) { static void UNLMaliSBCW(uint32 A, uint8 V) {
@ -1172,7 +1185,7 @@ static void M249PW(uint32 A, uint8 V) {
if (EXPREGS[0] & 0x2) { if (EXPREGS[0] & 0x2) {
if (V < 0x20) if (V < 0x20)
V = (V & 1) | ((V >> 3) & 2) | ((V >> 1) & 4) | ((V << 2) & 8) | ((V << 2) & 0x10); V = (V & 1) | ((V >> 3) & 2) | ((V >> 1) & 4) | ((V << 2) & 8) | ((V << 2) & 0x10);
else{ else {
V -= 0x20; V -= 0x20;
V = (V & 3) | ((V >> 1) & 4) | ((V >> 4) & 8) | ((V >> 2) & 0x10) | ((V << 3) & 0x20) | ((V << 2) & 0xC0); 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" #include "mapinc.h"
static uint8 reg[7], debug = 1; static uint8 reg[8];
static uint32 lastnt = 0; static uint32 lastnt = 0;
static uint8 *WRAM = NULL; static uint8 *WRAM = NULL;
static uint32 WRAMSIZE; static uint32 WRAMSIZE;
@ -33,14 +33,14 @@ static SFORMAT StateRegs[] =
}; };
static uint8 bs_tbl[128] = { static uint8 bs_tbl[128] = {
0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 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, 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, 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, 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, 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, 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, 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, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, // 70
}; };
static uint8 br_tbl[16] = { static uint8 br_tbl[16] = {
@ -48,21 +48,29 @@ static uint8 br_tbl[16] = {
}; };
static void Sync(void) { static void Sync(void) {
if (reg[0]&0x80) { setchr8(0);
setchr4(0x0000, (lastnt >> 9) ^ 0);
setchr4(0x1000, (lastnt >> 9) ^ 1);
} else {
setchr4(0x0000, 1);
setchr4(0x1000, 0);
}
setprg8r(0x10, 0x6000, 0); setprg8r(0x10, 0x6000, 0);
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(0x8000, bs_tbl[reg[0] & 0x7f] >> 4);
setprg16(0xc000, bs_tbl[reg[0] & 0x7f] & 0xf); setprg16(0xc000, bs_tbl[reg[0] & 0x7f] & 0xf);
setmirror(MI_V); setmirror(MI_V);
}
} }
static DECLFW(UNLPEC586Write) { static DECLFW(UNLPEC586Write) {
reg[(A & 0x700) >> 8] = V; reg[(A & 0x700) >> 8] = V;
PEC586Hack = (reg[0] & 0x80) >> 7;
// FCEU_printf("bs %04x %02x\n", A, V); // FCEU_printf("bs %04x %02x\n", A, V);
Sync(); Sync();
} }
@ -72,36 +80,29 @@ static DECLFR(UNLPEC586Read) {
return (X.DB & 0xD8) | br_tbl[reg[4] >> 4]; return (X.DB & 0xD8) | br_tbl[reg[4] >> 4];
} }
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 UNLPEC586Power(void) { static void UNLPEC586Power(void) {
if(PRGsize[0] == 512 * 1024)
reg[0] = 0x00;
else
reg[0] = 0x0E; reg[0] = 0x0E;
debug ^= 1;
Sync(); Sync();
setchr8(0);
SetReadHandler(0x6000, 0x7FFF, CartBR); SetReadHandler(0x6000, 0x7FFF, CartBR);
SetWriteHandler(0x6000, 0x7FFF, CartBW); SetWriteHandler(0x6000, 0x7FFF, CartBW);
if(PRGsize[0] == 512 * 1024)
SetReadHandler(0x8000, 0xFFFF, UNLPEC586ReadHi);
else
SetReadHandler(0x8000, 0xFFFF, CartBR); SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x5000, 0x5fff, UNLPEC586Write); SetWriteHandler(0x5000, 0x5fff, UNLPEC586Write);
SetReadHandler(0x5000, 0x5fff, UNLPEC586Read); SetReadHandler(0x5000, 0x5fff, UNLPEC586Read);
} }
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 UNLPEC586Close(void) { static void UNLPEC586Close(void) {
if (WRAM) if (WRAM)
FCEU_gfree(WRAM); FCEU_gfree(WRAM);
@ -115,11 +116,8 @@ static void StateRestore(int version) {
void UNLPEC586Init(CartInfo *info) { void UNLPEC586Init(CartInfo *info) {
info->Power = UNLPEC586Power; info->Power = UNLPEC586Power;
info->Close = UNLPEC586Close; info->Close = UNLPEC586Close;
PPU_hook = UNLPEC586PPU;
GameStateRestore = StateRestore; GameStateRestore = StateRestore;
PEC586Hack = 1;
WRAMSIZE = 8192; WRAMSIZE = 8192;
WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE);
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);

View File

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

View File

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