mapper 43 - new dumps needed

UNIF mihunche - new source for the old board/mapper
UNIF PEC-586 - new mapper almost complete
This commit is contained in:
CaH4e3 2013-05-13 19:27:34 +00:00
parent dad4e753f6
commit d5e6d7f891
13 changed files with 275 additions and 157 deletions

View File

@ -16,13 +16,14 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* FDS Conversion
*
*/ */
//ccording to nestopia, BTL_SMB2_C, otherwise known as UNL-SMB2J
#include "mapinc.h" #include "mapinc.h"
static uint8 reg; static uint8 reg, swap;
static uint32 IRQCount, IRQa; static uint32 IRQCount, IRQa;
static SFORMAT StateRegs[] = static SFORMAT StateRegs[] =
@ -30,31 +31,33 @@ static SFORMAT StateRegs[] =
{ &IRQCount, 4, "IRQC" }, { &IRQCount, 4, "IRQC" },
{ &IRQa, 4, "IRQA" }, { &IRQa, 4, "IRQA" },
{ &reg, 1, "REG" }, { &reg, 1, "REG" },
{ &swap, 1, "SWAP" },
{ 0 } { 0 }
}; };
static void Sync(void) { static void Sync(void) {
setprg4(0x5000, 16); // Only YS-612 advdnced version setprg4(0x5000, 16); // Only YS-612 advanced version
setprg8(0x6000, 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, 9); setprg8(0xe000, swap?8:9);
setchr8(0); setchr8(0);
} }
static DECLFW(M43Write) { static DECLFW(M43Write) {
// int transo[8]={4,3,4,4,4,7,5,6}; // int transo[8]={4,3,4,4,4,7,5,6};
int transo[8] = { 4, 3, 5, 3, 6, 3, 7, 3 }; // According to hardware tests int transo[8] = { 4, 3, 5, 3, 6, 3, 7, 3 }; // According to hardware tests
switch (A & 0xf1ff) { switch (A & 0xf1ff) {
case 0x4022: reg = transo[V & 7]; Sync(); break; case 0x4022: reg = transo[V & 7]; Sync(); break;
case 0x8122: // hacked version case 0x4120: swap = V & 1; Sync(); break;
case 0x4122: IRQa = V & 1; X6502_IRQEnd(FCEU_IQEXT); IRQCount = 0; break; // original version case 0x8122: // hacked version
case 0x4122: IRQa = V & 1; X6502_IRQEnd(FCEU_IQEXT); IRQCount = 0; break; // original version
} }
} }
static void M43Power(void) { static void M43Power(void) {
reg = 0; reg = swap = 0;
Sync(); Sync();
SetReadHandler(0x5000, 0xffff, CartBR); SetReadHandler(0x5000, 0xffff, CartBR);
SetWriteHandler(0x4020, 0xffff, M43Write); SetWriteHandler(0x4020, 0xffff, M43Write);

View File

@ -85,18 +85,6 @@ static void Latch_Init(CartInfo *info, void (*proc)(void), readfunc func, uint16
AddExState(&latche, 2, 0, "LATC"); AddExState(&latche, 2, 0, "LATC");
} }
//------------------ UNLCC21 ---------------------------
static void UNLCC21Sync(void) {
setprg32(0x8000, 0);
setchr8(latche & 1);
setmirror(MI_0 + ((latche & 2) >> 1));
}
void UNLCC21_Init(CartInfo *info) {
Latch_Init(info, UNLCC21Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0);
}
//------------------ BMCD1038 --------------------------- //------------------ BMCD1038 ---------------------------
static void BMCD1038Sync(void) { static void BMCD1038Sync(void) {
@ -248,7 +236,7 @@ void Mapper200_Init(CartInfo *info) {
//------------------ Map 201 --------------------------- //------------------ Map 201 ---------------------------
static void M201Sync(void) { static void M201Sync(void) {
if(latche & 8) { if (latche & 8) {
setprg32(0x8000, latche & 3); setprg32(0x8000, latche & 3);
setchr8(latche & 3); setchr8(latche & 3);
} else { } else {
@ -303,14 +291,14 @@ static DECLFR(M212Read) {
} }
static void M212Sync(void) { static void M212Sync(void) {
if(latche & 0x4000) { if (latche & 0x4000) {
setprg32(0x8000, (latche >> 1) & 3); setprg32(0x8000, (latche >> 1) & 3);
} else { } else {
setprg16(0x8000, latche & 7); setprg16(0x8000, latche & 7);
setprg16(0xC000, latche & 7); setprg16(0xC000, latche & 7);
} }
setchr8(latche & 7); setchr8(latche & 7);
setmirror(((latche >> 3) & 1)^1); setmirror(((latche >> 3) & 1) ^ 1);
} }
void Mapper212_Init(CartInfo *info) { void Mapper212_Init(CartInfo *info) {
@ -385,7 +373,7 @@ static void M227Sync(void) {
} }
} }
setmirror(((latche >> 1) & 1)^1); setmirror(((latche >> 1) & 1) ^ 1);
setchr8(0); setchr8(0);
setprg8r(0x10, 0x6000, 0); setprg8r(0x10, 0x6000, 0);
} }
@ -398,13 +386,13 @@ void Mapper227_Init(CartInfo *info) {
static void M229Sync(void) { static void M229Sync(void) {
setchr8(latche); setchr8(latche);
if(!(latche & 0x1e)) if (!(latche & 0x1e))
setprg32(0x8000, 0); setprg32(0x8000, 0);
else { else {
setprg16(0x8000, latche & 0x1F); setprg16(0x8000, latche & 0x1F);
setprg16(0xC000, latche & 0x1F); setprg16(0xC000, latche & 0x1F);
} }
setmirror(((latche >> 5) & 1)^1); setmirror(((latche >> 5) & 1) ^ 1);
} }
void Mapper229_Init(CartInfo *info) { void Mapper229_Init(CartInfo *info) {
@ -415,13 +403,13 @@ void Mapper229_Init(CartInfo *info) {
static void M231Sync(void) { static void M231Sync(void) {
setchr8(0); setchr8(0);
if(latche & 0x20) if (latche & 0x20)
setprg32(0x8000, (latche >> 1) & 0x0F); setprg32(0x8000, (latche >> 1) & 0x0F);
else { else {
setprg16(0x8000, latche & 0x1E); setprg16(0x8000, latche & 0x1E);
setprg16(0xC000, latche & 0x1E); setprg16(0xC000, latche & 0x1E);
} }
setmirror(((latche >> 7) & 1)^1); setmirror(((latche >> 7) & 1) ^ 1);
} }
void Mapper231_Init(CartInfo *info) { void Mapper231_Init(CartInfo *info) {
@ -460,7 +448,7 @@ static void BMC810544CA1Sync(void) {
uint32 bank = latche >> 7; uint32 bank = latche >> 7;
if (latche & 0x40) if (latche & 0x40)
setprg32(0x8000, bank); setprg32(0x8000, bank);
else{ else {
setprg16(0x8000, (bank << 1) | ((latche >> 5) & 1)); setprg16(0x8000, (bank << 1) | ((latche >> 5) & 1));
setprg16(0xC000, (bank << 1) | ((latche >> 5) & 1)); setprg16(0xC000, (bank << 1) | ((latche >> 5) & 1));
} }
@ -498,11 +486,11 @@ void BMCNTD03_Init(CartInfo *info) {
static void BMCG146Sync(void) { static void BMCG146Sync(void) {
setchr8(0); setchr8(0);
if (latche & 0x800) { // UNROM mode if (latche & 0x800) { // UNROM mode
setprg16(0x8000, (latche & 0x1F) | (latche & ((latche & 0x40) >> 6))); setprg16(0x8000, (latche & 0x1F) | (latche & ((latche & 0x40) >> 6)));
setprg16(0xC000, (latche & 0x18) | 7); setprg16(0xC000, (latche & 0x18) | 7);
} else { } else {
if (latche & 0x40) { // 16K mode if (latche & 0x40) { // 16K mode
setprg16(0x8000, latche & 0x1F); setprg16(0x8000, latche & 0x1F);
setprg16(0xC000, latche & 0x1F); setprg16(0xC000, latche & 0x1F);
} else { } else {

View File

@ -91,7 +91,7 @@ static DECLFW(NROMWrite) {
#endif #endif
static void NROMPower(void) { static void NROMPower(void) {
setprg8r(0x10, 0x6000, 0); // Famili BASIC (v3.0) need it (uses only 4KB), FP-BASIC uses 8KB setprg8r(0x10, 0x6000, 0); // Famili BASIC (v3.0) need it (uses only 4KB), FP-BASIC uses 8KB
setprg16(0x8000, 0); setprg16(0x8000, 0);
setprg16(0xC000, ~0); setprg16(0xC000, ~0);
setchr8(0); setchr8(0);
@ -127,7 +127,7 @@ static void UNROMSync(void) {
setprg16(0x8000, latche & 0x7); setprg16(0x8000, latche & 0x7);
if (latche & 8) mirror_in_use = 1; if (latche & 8) mirror_in_use = 1;
if (mirror_in_use) if (mirror_in_use)
setmirror(((latche >> 3) & 1) ^ 1); // Higway Star Hacked mapper setmirror(((latche >> 3) & 1) ^ 1); // Higway Star Hacked mapper
} else } else
setprg16(0x8000, latche & 0xf); setprg16(0x8000, latche & 0xf);
setprg16(0xc000, ~0); setprg16(0xc000, ~0);
@ -143,7 +143,7 @@ void UNROM_Init(CartInfo *info) {
static void CNROMSync(void) { static void CNROMSync(void) {
setchr8(latche); setchr8(latche);
setprg32(0x8000, 0); setprg32(0x8000, 0);
setprg8r(0x10, 0x6000, 0); // Hayauchy IGO uses 2Kb or RAM setprg8r(0x10, 0x6000, 0); // Hayauchy IGO uses 2Kb or RAM
} }
void CNROM_Init(CartInfo *info) { void CNROM_Init(CartInfo *info) {
@ -159,7 +159,7 @@ static void ANROMSync() {
} }
void ANROM_Init(CartInfo *info) { void ANROM_Init(CartInfo *info) {
Latch_Init(info, ANROMSync, 0, 0x8000, 0xFFFF, 0, 0); Latch_Init(info, ANROMSync, 0, 0x4020, 0xFFFF, 0, 0);
} }
//------------------ Map 8 --------------------------- //------------------ Map 8 ---------------------------
@ -215,7 +215,6 @@ void Mapper38_Init(CartInfo *info) {
//------------------ Map 66 --------------------------- //------------------ Map 66 ---------------------------
static void MHROMSync(void) { static void MHROMSync(void) {
setprg32(0x8000, latche >> 4); setprg32(0x8000, latche >> 4);
setchr8(latche & 0xF); setchr8(latche & 0xF);
} }
@ -373,7 +372,7 @@ static void M152Sync() {
setprg16(0x8000, (latche >> 4) & 7); setprg16(0x8000, (latche >> 4) & 7);
setprg16(0xc000, ~0); setprg16(0xc000, ~0);
setchr8(latche & 0xf); setchr8(latche & 0xf);
setmirror(MI_0 + ((latche >> 7) & 1)); /* Saint Seiya...hmm. */ setmirror(MI_0 + ((latche >> 7) & 1)); /* Saint Seiya...hmm. */
} }
void Mapper152_Init(CartInfo *info) { void Mapper152_Init(CartInfo *info) {
@ -435,8 +434,8 @@ void Mapper240_Init(CartInfo *info) {
static void M241Sync(void) { static void M241Sync(void) {
setchr8(0); setchr8(0);
setprg8r(0x10, 0x6000, 0); setprg8r(0x10, 0x6000, 0);
if(latche & 0x80) if (latche & 0x80)
setprg32(0x8000, latche | 8); // no 241 actually, but why not afterall? setprg32(0x8000, latche | 8); // no 241 actually, but why not afterall?
else else
setprg32(0x8000, latche); setprg32(0x8000, latche);
} }
@ -455,7 +454,7 @@ void Mapper241_Init(CartInfo *info) {
static void BMCA65ASSync(void) { static void BMCA65ASSync(void) {
if (latche & 0x40) if (latche & 0x40)
setprg32(0x8000, (latche >> 1) & 0x0F); setprg32(0x8000, (latche >> 1) & 0x0F);
else{ else {
setprg16(0x8000, ((latche & 0x30) >> 1) | (latche & 7)); setprg16(0x8000, ((latche & 0x30) >> 1) | (latche & 7));
setprg16(0xC000, ((latche & 0x30) >> 1) | 7); setprg16(0xC000, ((latche & 0x30) >> 1) | 7);
} }

View File

@ -0,0 +1,68 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2013 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
*/
#include "mapinc.h"
static uint16 latche;
static SFORMAT StateRegs[] =
{
{ &latche, 2, "LATC" },
{ 0 }
};
static void Sync(void) {
setprg32(0x8000, 0);
if(CHRsize[0] == 8192) {
setchr4(0x0000, latche & 1);
setchr4(0x1000, latche & 1);
} else {
setchr8(latche & 1); // actually, my bad, overdumped roms, the real CHR size if 8K
}
setmirror(MI_0 + (latche & 1));
}
static DECLFW(UNLCC21Write1) {
latche = A;
Sync();
}
static DECLFW(UNLCC21Write2) {
latche = V;
Sync();
}
static void UNLCC21Power(void) {
latche = 0;
Sync();
SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x8001, 0xFFFF, UNLCC21Write1);
SetWriteHandler(0x8000, 0x8000, UNLCC21Write2); // another one many-in-1 mapper, there is a lot of similar carts with little different wirings
}
static void StateRestore(int version) {
Sync();
}
void UNLCC21_Init(CartInfo *info) {
info->Power = UNLCC21Power;
GameStateRestore = StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -20,13 +20,15 @@
#include "mapinc.h" #include "mapinc.h"
static uint8 reg[7]; static uint8 reg[7], debug = 1;
static uint32 lastnt = 0;
static uint8 *WRAM = NULL; static uint8 *WRAM = NULL;
static uint32 WRAMSIZE; static uint32 WRAMSIZE;
static SFORMAT StateRegs[] = static SFORMAT StateRegs[] =
{ {
{ reg, 2, "REG" }, { reg, 2, "REG" },
{ &lastnt, 4, "LNT" },
{ 0 } { 0 }
}; };
@ -46,9 +48,13 @@ static uint8 br_tbl[16] = {
}; };
static void Sync(void) { static void Sync(void) {
// setchr4(0x0000,(reg[0]&0x80) >> 7); if (reg[0]&0x80) {
// setchr4(0x1000,(reg[0]&0x80) >> 7); setchr4(0x0000, (lastnt >> 9) ^ 0);
setchr8(0); setchr4(0x1000, (lastnt >> 9) ^ 1);
} else {
setchr4(0x0000, 1);
setchr4(0x1000, 0);
}
setprg8r(0x10, 0x6000, 0); setprg8r(0x10, 0x6000, 0);
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);
@ -57,17 +63,18 @@ static void Sync(void) {
static DECLFW(UNLPEC586Write) { static DECLFW(UNLPEC586Write) {
reg[(A & 0x700) >> 8] = V; reg[(A & 0x700) >> 8] = V;
FCEU_printf("bs %04x %02x\n", A, V); // FCEU_printf("bs %04x %02x\n", A, V);
Sync(); Sync();
} }
static DECLFR(UNLPEC586Read) { static DECLFR(UNLPEC586Read) {
FCEU_printf("read %04x\n", A); // FCEU_printf("read %04x\n", A);
return (X.DB & 0xD8) | br_tbl[reg[4] >> 4]; return (X.DB & 0xD8) | br_tbl[reg[4] >> 4];
} }
static void UNLPEC586Power(void) { static void UNLPEC586Power(void) {
reg[0] = 0x0E; reg[0] = 0x0E;
debug ^= 1;
Sync(); Sync();
setchr8(0); setchr8(0);
SetReadHandler(0x6000, 0x7FFF, CartBR); SetReadHandler(0x6000, 0x7FFF, CartBR);
@ -77,16 +84,21 @@ static void UNLPEC586Power(void) {
SetReadHandler(0x5000, 0x5fff, UNLPEC586Read); SetReadHandler(0x5000, 0x5fff, UNLPEC586Read);
} }
static void UNLPEC586IRQ(void) { static void UNLPEC586PPU(uint32 A) {
// if(reg[0]&0x80) if (reg[0]&0x80)
{ {
if (scanline == 128) { if (((A & 0x3FFF) > 0x2000) && ((A & 0x3FFF) < 0x23C0)) {
setchr4(0x0000, 1); uint32 curnt = A & 0x200;
setchr4(0x1000, 0); if (curnt != lastnt) {
} else { setchr4(0x0000, (curnt >> 9) ^ 0);
setchr4(0x0000, 0); setchr4(0x1000, (curnt >> 9) ^ 1);
setchr4(0x1000, 1); lastnt = curnt;
}
} }
} else {
lastnt = 0;
setchr4(0x0000, 1);
setchr4(0x1000, 0);
} }
} }
@ -103,9 +115,11 @@ 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;
GameHBIRQHook = UNLPEC586IRQ; 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

@ -378,6 +378,7 @@ void ResetGameLoaded(void) {
memset(&GameExpSound, 0, sizeof(GameExpSound)); memset(&GameExpSound, 0, sizeof(GameExpSound));
MapIRQHook = NULL; MapIRQHook = NULL;
MMC5Hack = 0; MMC5Hack = 0;
PEC586Hack = 0;
PAL &= 1; PAL &= 1;
pale = 0; pale = 0;
} }

View File

@ -39,7 +39,7 @@ char *FCEUI_GetAboutString();
extern uint64 timestampbase; extern uint64 timestampbase;
extern uint32 MMC5HackVROMMask; extern uint32 MMC5HackVROMMask;
extern uint8 *MMC5HackExNTARAMPtr; extern uint8 *MMC5HackExNTARAMPtr;
extern int MMC5Hack; extern int MMC5Hack, PEC586Hack;
extern uint8 *MMC5HackVROMPTR; extern uint8 *MMC5HackVROMPTR;
extern uint8 MMC5HackCHRMode; extern uint8 MMC5HackCHRMode;
extern uint8 MMC5HackSPMode; extern uint8 MMC5HackSPMode;

View File

@ -311,7 +311,7 @@ int fceuindbg = 0;
//0xFF shall indicate to use palette[0] //0xFF shall indicate to use palette[0]
uint8 gNoBGFillColor = 0xFF; uint8 gNoBGFillColor = 0xFF;
int MMC5Hack = 0; int MMC5Hack = 0, PEC586Hack = 0;;
uint32 MMC5HackVROMMask = 0; uint32 MMC5HackVROMMask = 0;
uint8 *MMC5HackExNTARAMPtr = 0; uint8 *MMC5HackExNTARAMPtr = 0;
uint8 *MMC5HackVROMPTR = 0; uint8 *MMC5HackVROMPTR = 0;
@ -321,7 +321,6 @@ uint8 MMC50x5130 = 0;
uint8 MMC5HackSPScroll = 0; uint8 MMC5HackSPScroll = 0;
uint8 MMC5HackSPPage = 0; uint8 MMC5HackSPPage = 0;
uint8 VRAMBuffer = 0, PPUGenLatch = 0; uint8 VRAMBuffer = 0, PPUGenLatch = 0;
uint8 *vnapage[4]; uint8 *vnapage[4];
uint8 PPUNTARAM = 0; uint8 PPUNTARAM = 0;
@ -352,7 +351,6 @@ uint8 NTARAM[0x800], PALRAM[0x20], SPRAM[0x100], SPRBUF[0x100];
uint8 UPALRAM[0x03];//for 0x4/0x8/0xC addresses in palette, the ones in uint8 UPALRAM[0x03];//for 0x4/0x8/0xC addresses in palette, the ones in
//0x20 are 0 to not break fceu rendering. //0x20 are 0 to not break fceu rendering.
#define MMC5SPRVRAMADR(V) &MMC5SPRVPage[(V) >> 10][(V)] #define MMC5SPRVRAMADR(V) &MMC5SPRVPage[(V) >> 10][(V)]
#define VRAMADR(V) &VPage[(V) >> 10][(V)] #define VRAMADR(V) &VPage[(V) >> 10][(V)]
@ -725,7 +723,6 @@ static DECLFR(A2007) {
} }
} else { } else {
ret = VRAMBuffer; ret = VRAMBuffer;
#ifdef FCEUDEF_DEBUGGER #ifdef FCEUDEF_DEBUGGER
if (!fceuindbg) if (!fceuindbg)
#endif #endif
@ -740,13 +737,13 @@ static DECLFR(A2007) {
VRAMBuffer = vnapage[(tmp >> 10) & 0x3][tmp & 0x3FF]; VRAMBuffer = vnapage[(tmp >> 10) & 0x3][tmp & 0x3FF];
} }
} }
#ifdef FCEUDEF_DEBUGGER #ifdef FCEUDEF_DEBUGGER
if (!fceuindbg) if (!fceuindbg)
#endif #endif
{ {
if ((ScreenON || SpriteON) && (scanline < 240)) { if ((ScreenON || SpriteON) && (scanline < 240)) {
uint32 rad = RefreshAddr; uint32 rad = RefreshAddr;
if ((rad & 0x7000) == 0x7000) { if ((rad & 0x7000) == 0x7000) {
rad ^= 0x7000; rad ^= 0x7000;
if ((rad & 0x3E0) == 0x3A0) if ((rad & 0x3E0) == 0x3A0)
@ -766,7 +763,6 @@ static DECLFR(A2007) {
} }
if (PPU_hook) PPU_hook(RefreshAddr & 0x3fff); if (PPU_hook) PPU_hook(RefreshAddr & 0x3fff);
} }
return ret; return ret;
} }
} }
@ -819,8 +815,9 @@ static DECLFW(B2004) {
if (PPUSPL >= 8) { if (PPUSPL >= 8) {
if (PPU[3] >= 8) if (PPU[3] >= 8)
SPRAM[PPU[3]] = V; SPRAM[PPU[3]] = V;
} else } else {
SPRAM[PPUSPL] = V; SPRAM[PPUSPL] = V;
}
PPU[3]++; PPU[3]++;
PPUSPL++; PPUSPL++;
} }
@ -1020,7 +1017,7 @@ static void RefreshLine(int lastpixel) {
// PPU_hook() functions can call // PPU_hook() functions can call
// mirroring/chr bank switching functions, // mirroring/chr bank switching functions,
// which call FCEUPPU_LineUpdate, which call this // which call FCEUPPU_LineUpdate, which call this
// function. */ // function.
if (norecurse) return; if (norecurse) return;
if (sphitx != 0x100 && !(PPU_status & 0x40)) { if (sphitx != 0x100 && !(PPU_status & 0x40)) {
@ -1112,14 +1109,30 @@ static void RefreshLine(int lastpixel) {
else if (PPU_hook) { else if (PPU_hook) {
norecurse = 1; norecurse = 1;
#define PPUT_HOOK #define PPUT_HOOK
for (X1 = firsttile; X1 < lasttile; X1++) { if (PEC586Hack) {
#include "pputile.inc" #define PPU_BGFETCH
for (X1 = firsttile; X1 < lasttile; X1++) {
#include "pputile.inc"
}
#undef PPU_BGFETCH
} else {
for (X1 = firsttile; X1 < lasttile; X1++) {
#include "pputile.inc"
}
} }
#undef PPUT_HOOK #undef PPUT_HOOK
norecurse = 0; norecurse = 0;
} else { } else {
for (X1 = firsttile; X1 < lasttile; X1++) { if (PEC586Hack) {
#include "pputile.inc" #define PPU_BGFETCH
for (X1 = firsttile; X1 < lasttile; X1++) {
#include "pputile.inc"
}
#undef PPU_BGFETCH
} else {
for (X1 = firsttile; X1 < lasttile; X1++) {
#include "pputile.inc"
}
} }
} }
@ -1302,12 +1315,12 @@ static void FetchSpriteData(void) {
ns = sb = 0; ns = sb = 0;
vofs = (unsigned int)(P0 & 0x8 & (((P0 & 0x20) ^ 0x20) >> 2)) << 9; vofs = (uint32)(P0 & 0x8 & (((P0 & 0x20) ^ 0x20) >> 2)) << 9;
H += (P0 & 0x20) >> 2; H += (P0 & 0x20) >> 2;
if (!PPU_hook) if (!PPU_hook)
for (n = 63; n >= 0; n--, spr++) { for (n = 63; n >= 0; n--, spr++) {
if ((unsigned int)(scanline - spr->y) >= H) continue; if ((uint32)(scanline - spr->y) >= H) continue;
if (ns < maxsprites) { if (ns < maxsprites) {
if (n == 63) sb = 1; if (n == 63) sb = 1;
@ -1315,7 +1328,7 @@ static void FetchSpriteData(void) {
SPRB dst; SPRB dst;
uint8 *C; uint8 *C;
int t; int t;
unsigned int vadr; uint32 vadr;
t = (int)scanline - (spr->y); t = (int)scanline - (spr->y);
@ -1337,9 +1350,8 @@ static void FetchSpriteData(void) {
/* Fix this geniestage hack */ /* Fix this geniestage hack */
if (MMC5Hack && geniestage != 1) if (MMC5Hack && geniestage != 1)
C = MMC5SPRVRAMADR(vadr); C = MMC5SPRVRAMADR(vadr);
else { else
C = VRAMADR(vadr); C = VRAMADR(vadr);
}
if (SpriteON) if (SpriteON)
RENDER_LOG(vadr); RENDER_LOG(vadr);
@ -1361,7 +1373,7 @@ static void FetchSpriteData(void) {
} }
else else
for (n = 63; n >= 0; n--, spr++) { for (n = 63; n >= 0; n--, spr++) {
if ((unsigned int)(scanline - spr->y) >= H) continue; if ((uint32)(scanline - spr->y) >= H) continue;
if (ns < maxsprites) { if (ns < maxsprites) {
if (n == 63) sb = 1; if (n == 63) sb = 1;
@ -1370,7 +1382,7 @@ static void FetchSpriteData(void) {
SPRB dst; SPRB dst;
uint8 *C; uint8 *C;
int t; int t;
unsigned int vadr; uint32 vadr;
t = (int)scanline - (spr->y); t = (int)scanline - (spr->y);
@ -1559,9 +1571,9 @@ static void CopySprites(uint8 *target) {
uint32 t = *(uint32*)(sprlinebuf + n); uint32 t = *(uint32*)(sprlinebuf + n);
if (t != 0x80808080) { if (t != 0x80808080) {
#ifdef LSB_FIRST #ifdef LSB_FIRST
if (!(t & 0x80)) { if (!(t & 0x80)) {
if (!(t & 0x40) || (P[n] & 0x40)) // Normal sprite || behind bg sprite if (!(t & 0x40) || (P[n] & 0x40)) // Normal sprite || behind bg sprite
P[n] = sprlinebuf[n]; P[n] = sprlinebuf[n];
} }
@ -1579,7 +1591,7 @@ static void CopySprites(uint8 *target) {
if (!(t & 0x40000000) || (P[n + 3] & 0x40)) // Normal sprite || behind bg sprite if (!(t & 0x40000000) || (P[n + 3] & 0x40)) // Normal sprite || behind bg sprite
P[n + 3] = (sprlinebuf + 3)[n]; P[n + 3] = (sprlinebuf + 3)[n];
} }
#else #else
/* TODO: Simplify */ /* TODO: Simplify */
if (!(t & 0x80000000)) { if (!(t & 0x80000000)) {
if (!(t & 0x40000000)) // Normal sprite if (!(t & 0x40000000)) // Normal sprite
@ -1608,7 +1620,7 @@ static void CopySprites(uint8 *target) {
else if (P[n + 3] & 64) // behind bg sprite else if (P[n + 3] & 64) // behind bg sprite
P[n + 3] = (sprlinebuf + 3)[n]; P[n + 3] = (sprlinebuf + 3)[n];
} }
#endif #endif
} }
} }
n += 4; n += 4;
@ -1668,7 +1680,7 @@ void FCEUPPU_Power(void) {
BWrite[x + 2] = B2002; BWrite[x + 2] = B2002;
ARead[x + 3] = A200x; ARead[x + 3] = A200x;
BWrite[x + 3] = B2003; BWrite[x + 3] = B2003;
ARead[x + 4] = A2004; //A2004; ARead[x + 4] = A2004;
BWrite[x + 4] = B2004; BWrite[x + 4] = B2004;
ARead[x + 5] = A200x; ARead[x + 5] = A200x;
BWrite[x + 5] = B2005; BWrite[x + 5] = B2005;
@ -1740,14 +1752,14 @@ int FCEUPPU_Loop(int skip) {
} }
if (GameInfo->type == GIT_NSF) if (GameInfo->type == GIT_NSF)
X6502_Run((256 + 85) * 240); X6502_Run((256 + 85) * 240);
#ifdef FRAMESKIP #ifdef FRAMESKIP
else if (skip) { else if (skip) {
int y; int y;
y = SPRAM[0]; y = SPRAM[0];
y++; y++;
PPU_status |= 0x20; // Fixes "Bee 52". Does it break anything? PPU_status |= 0x20; // Fixes "Bee 52". Does it break anything?
if (GameHBIRQHook) { if (GameHBIRQHook) {
X6502_Run(256); X6502_Run(256);
for (scanline = 0; scanline < 240; scanline++) { for (scanline = 0; scanline < 240; scanline++) {
@ -1763,17 +1775,16 @@ int FCEUPPU_Loop(int skip) {
} else } else
X6502_Run((256 + 85) * 240); X6502_Run((256 + 85) * 240);
} }
#endif #endif
else { else {
int x, max, maxref; int x, max, maxref;
deemp = PPU[1] >> 5; deemp = PPU[1] >> 5;
for (scanline = 0; scanline < 240; ) { //scanline is incremented in DoLine. Evil. :/ for (scanline = 0; scanline < 240; ) { //scanline is incremented in DoLine. Evil. :/
deempcnt[deemp]++; deempcnt[deemp]++;
DEBUG(FCEUD_UpdatePPUView(scanline, 1)); DEBUG(FCEUD_UpdatePPUView(scanline, 1));
DoLine(); DoLine();
} }
if (MMC5Hack && (ScreenON || SpriteON)) MMC5_hb(scanline); if (MMC5Hack && (ScreenON || SpriteON)) MMC5_hb(scanline);
for (x = 1, max = 0, maxref = 0; x < 7; x++) { for (x = 1, max = 0, maxref = 0; x < 7; x++) {
if (deempcnt[x] > max) { if (deempcnt[x] > max) {
@ -1786,12 +1797,12 @@ int FCEUPPU_Loop(int skip) {
} }
} //else... to if(ppudead) } //else... to if(ppudead)
#ifdef FRAMESKIP #ifdef FRAMESKIP
if (skip) { if (skip) {
FCEU_PutImageDummy(); FCEU_PutImageDummy();
return(0); return(0);
} else } else
#endif #endif
{ {
FCEU_PutImage(); FCEU_PutImage();
return(1); return(1);
@ -1879,10 +1890,11 @@ void runppu(int x) {
//todo - consider making this a 3 or 4 slot fifo to keep from touching so much memory //todo - consider making this a 3 or 4 slot fifo to keep from touching so much memory
struct BGData { struct BGData {
struct Record { struct Record {
uint8 nt, at, pt[2]; uint8 nt, pecnt, at, pt[2];
INLINE void Read() { INLINE void Read() {
RefreshAddr = ppur.get_ntread(); RefreshAddr = ppur.get_ntread();
pecnt = (RefreshAddr & 1) << 3;
nt = CALL_PPUREAD(RefreshAddr); nt = CALL_PPUREAD(RefreshAddr);
runppu(kFetchTime); runppu(kFetchTime);
@ -1906,15 +1918,24 @@ struct BGData {
ppur.par = nt; ppur.par = nt;
RefreshAddr = ppur.get_ptread(); RefreshAddr = ppur.get_ptread();
if (ScreenON) if (PEC586Hack) {
RENDER_LOG(RefreshAddr); if (ScreenON)
pt[0] = CALL_PPUREAD(RefreshAddr); RENDER_LOG(RefreshAddr | pecnt);
runppu(kFetchTime); pt[0] = CALL_PPUREAD(RefreshAddr | pecnt);
RefreshAddr |= 8; runppu(kFetchTime);
if (ScreenON) pt[1] = CALL_PPUREAD(RefreshAddr | pecnt);
RENDER_LOG(RefreshAddr); runppu(kFetchTime);
pt[1] = CALL_PPUREAD(RefreshAddr); } else {
runppu(kFetchTime); if (ScreenON)
RENDER_LOG(RefreshAddr);
pt[0] = CALL_PPUREAD(RefreshAddr);
runppu(kFetchTime);
RefreshAddr |= 8;
if (ScreenON)
RENDER_LOG(RefreshAddr);
pt[1] = CALL_PPUREAD(RefreshAddr);
runppu(kFetchTime);
}
} }
}; };

View File

@ -1,82 +1,80 @@
uint8 *C; uint8 *C;
register uint8 cc; register uint8 cc;
uint32 vadr; uint32 vadr;
#ifndef PPUT_MMC5SP #ifndef PPUT_MMC5SP
uint8 zz; register uint8 zz;
#else #else
uint8 xs,ys; uint8 xs, ys;
xs=X1; xs = X1;
ys=((scanline>>3)+MMC5HackSPScroll)&0x1F; ys = ((scanline >> 3) + MMC5HackSPScroll) & 0x1F;
if(ys>=0x1E) ys-=0x1E; if (ys >= 0x1E) ys -= 0x1E;
#endif #endif
if(X1>=2) { if (X1 >= 2) {
uint8 *S=PALRAM; uint8 *S = PALRAM;
uint32 pixdata; uint32 pixdata;
pixdata=ppulut1[(pshift[0]>>(8-XOffset))&0xFF]|ppulut2[(pshift[1]>>(8-XOffset))&0xFF]; pixdata = ppulut1[(pshift[0] >> (8 - XOffset)) & 0xFF] | ppulut2[(pshift[1] >> (8 - XOffset)) & 0xFF];
pixdata|=ppulut3[XOffset|(atlatch<<3)]; pixdata |= ppulut3[XOffset | (atlatch << 3)];
//printf("%02x ",ppulut3[XOffset|(atlatch<<3)]);
P[0]=S[pixdata&0xF]; P[0] = S[pixdata & 0xF];
pixdata>>=4; pixdata >>= 4;
P[1]=S[pixdata&0xF]; P[1] = S[pixdata & 0xF];
pixdata>>=4; pixdata >>= 4;
P[2]=S[pixdata&0xF]; P[2] = S[pixdata & 0xF];
pixdata>>=4; pixdata >>= 4;
P[3]=S[pixdata&0xF]; P[3] = S[pixdata & 0xF];
pixdata>>=4; pixdata >>= 4;
P[4]=S[pixdata&0xF]; P[4] = S[pixdata & 0xF];
pixdata>>=4; pixdata >>= 4;
P[5]=S[pixdata&0xF]; P[5] = S[pixdata & 0xF];
pixdata>>=4; pixdata >>= 4;
P[6]=S[pixdata&0xF]; P[6] = S[pixdata & 0xF];
pixdata>>=4; pixdata >>= 4;
P[7]=S[pixdata&0xF]; P[7] = S[pixdata & 0xF];
P+=8; P += 8;
} }
#ifdef PPUT_MMC5SP #ifdef PPUT_MMC5SP
vadr=(MMC5HackExNTARAMPtr[xs|(ys<<5)]<<4)+(vofs&7); vadr = (MMC5HackExNTARAMPtr[xs | (ys << 5)] << 4) + (vofs & 7);
#else #else
zz=RefreshAddr&0x1F; zz = RefreshAddr & 0x1F;
C=vnapage[(RefreshAddr>>10)&3]; C = vnapage[(RefreshAddr >> 10) & 3];
vadr=(C[RefreshAddr&0x3ff]<<4)+vofs; /* Fetch name table byte. */ vadr = (C[RefreshAddr & 0x3ff] << 4) + vofs; // Fetch name table byte.
#endif #endif
#ifdef PPUT_HOOK #ifdef PPUT_HOOK
PPU_hook(0x2000|(RefreshAddr&0xfff)); PPU_hook(0x2000 | (RefreshAddr & 0xfff));
#endif #endif
#ifdef PPUT_MMC5SP #ifdef PPUT_MMC5SP
cc=MMC5HackExNTARAMPtr[0x3c0+(xs>>2)+((ys&0x1C)<<1)]; cc = MMC5HackExNTARAMPtr[0x3c0 + (xs >> 2) + ((ys & 0x1C) << 1)];
cc=((cc >> ((xs&2) + ((ys&0x2)<<1))) &3); cc = ((cc >> ((xs & 2) + ((ys & 0x2) << 1))) & 3);
#else #else
#ifdef PPUT_MMC5CHR1 #ifdef PPUT_MMC5CHR1
cc=(MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff] & 0xC0)>>6; cc = (MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff] & 0xC0) >> 6;
#else #else
cc=C[0x3c0+(zz>>2)+((RefreshAddr&0x380)>>4)]; /* Fetch attribute table byte. */ cc = C[0x3c0 + (zz >> 2) + ((RefreshAddr & 0x380) >> 4)]; // Fetch attribute table byte.
cc=((cc >> ((zz&2) + ((RefreshAddr&0x40)>>4))) &3); cc = ((cc >> ((zz & 2) + ((RefreshAddr & 0x40) >> 4))) & 3);
#endif #endif
#endif #endif
atlatch>>=2; atlatch >>= 2;
atlatch|=cc<<2; atlatch |= cc << 2;
pshift[0]<<=8; pshift[0] <<= 8;
pshift[1]<<=8; pshift[1] <<= 8;
#ifdef PPUT_MMC5SP #ifdef PPUT_MMC5SP
C = MMC5HackVROMPTR+vadr; C = MMC5HackVROMPTR + vadr;
C += ((MMC5HackSPPage & 0x3f & MMC5HackVROMMask) << 12); C += ((MMC5HackSPPage & 0x3f & MMC5HackVROMMask) << 12);
#else #else
#ifdef PPUT_MMC5CHR1 #ifdef PPUT_MMC5CHR1
C = MMC5HackVROMPTR; C = MMC5HackVROMPTR;
C += (((MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff]) & 0x3f & C += (((MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff]) & 0x3f & MMC5HackVROMMask) << 12) + (vadr & 0xfff);
MMC5HackVROMMask) << 12) + (vadr & 0xfff); C += (MMC50x5130 & 0x3) << 18; //11-jun-2009 for kuja_killer
C += (MMC50x5130&0x3)<<18; //11-jun-2009 for kuja_killer
#elif defined(PPUT_MMC5) #elif defined(PPUT_MMC5)
C = MMC5BGVRAMADR(vadr); C = MMC5BGVRAMADR(vadr);
#else #else
@ -88,19 +86,33 @@ pshift[1]<<=8;
PPU_hook(vadr); PPU_hook(vadr);
#endif #endif
if(ScreenON) #ifdef PPU_BGFETCH
RENDER_LOG(vadr); if (RefreshAddr & 1) {
pshift[0]|=C[0]; if(ScreenON)
if(ScreenON) RENDER_LOG(vadr + 8);
RENDER_LOG(vadr + 8); pshift[0] |= C[8];
pshift[1]|=C[8]; pshift[1] |= C[8];
} else {
if(ScreenON)
RENDER_LOG(vadr);
pshift[0] |= C[0];
pshift[1] |= C[0];
}
#else
if(ScreenON)
RENDER_LOG(vadr);
pshift[0] |= C[0];
if(ScreenON)
RENDER_LOG(vadr + 8);
pshift[1] |= C[8];
#endif
if((RefreshAddr&0x1f)==0x1f) if ((RefreshAddr & 0x1f) == 0x1f)
RefreshAddr^=0x41F; RefreshAddr ^= 0x41F;
else else
RefreshAddr++; RefreshAddr++;
#ifdef PPUT_HOOK #ifdef PPUT_HOOK
PPU_hook(0x2000|(RefreshAddr&0xfff)); PPU_hook(0x2000 | (RefreshAddr & 0xfff));
#endif #endif

View File

@ -323,6 +323,7 @@
<ClCompile Include="..\src\boards\le05.cpp" /> <ClCompile Include="..\src\boards\le05.cpp" />
<ClCompile Include="..\src\boards\lh32.cpp" /> <ClCompile Include="..\src\boards\lh32.cpp" />
<ClCompile Include="..\src\boards\lh53.cpp" /> <ClCompile Include="..\src\boards\lh53.cpp" />
<ClCompile Include="..\src\boards\mihunche.cpp" />
<ClCompile Include="..\src\boards\mmc2and4.cpp" /> <ClCompile Include="..\src\boards\mmc2and4.cpp" />
<ClCompile Include="..\src\boards\onebus.cpp" /> <ClCompile Include="..\src\boards\onebus.cpp" />
<ClCompile Include="..\src\boards\pec-586.cpp" /> <ClCompile Include="..\src\boards\pec-586.cpp" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup> <ItemGroup>
<Filter Include="boards"> <Filter Include="boards">
@ -955,6 +955,9 @@
<ClCompile Include="..\src\utils\ioapi.cpp"> <ClCompile Include="..\src\utils\ioapi.cpp">
<Filter>utils</Filter> <Filter>utils</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\src\boards\mihunche.cpp">
<Filter>boards</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\src\drivers\common\args.h"> <ClInclude Include="..\src\drivers\common\args.h">

View File

@ -1082,6 +1082,10 @@
RelativePath="..\src\boards\malee.cpp" RelativePath="..\src\boards\malee.cpp"
> >
</File> </File>
<File
RelativePath="..\src\boards\mihunche.cpp"
>
</File>
<File <File
RelativePath="..\src\boards\mmc1.cpp" RelativePath="..\src\boards\mmc1.cpp"
> >

View File

@ -851,6 +851,10 @@
RelativePath="..\src\boards\lh53.cpp" RelativePath="..\src\boards\lh53.cpp"
> >
</File> </File>
<File
RelativePath="..\src\boards\mihunche.cpp"
>
</File>
<File <File
RelativePath="..\src\boards\malee.cpp" RelativePath="..\src\boards\malee.cpp"
> >