diff --git a/trunk/src/boards/43.cpp b/trunk/src/boards/43.cpp
index c7202129..1fcf1a09 100644
--- a/trunk/src/boards/43.cpp
+++ b/trunk/src/boards/43.cpp
@@ -16,13 +16,14 @@
* 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
+ *
+ * FDS Conversion
+ *
*/
-//ccording to nestopia, BTL_SMB2_C, otherwise known as UNL-SMB2J
-
#include "mapinc.h"
-static uint8 reg;
+static uint8 reg, swap;
static uint32 IRQCount, IRQa;
static SFORMAT StateRegs[] =
@@ -30,31 +31,33 @@ static SFORMAT StateRegs[] =
{ &IRQCount, 4, "IRQC" },
{ &IRQa, 4, "IRQA" },
{ ®, 1, "REG" },
+ { &swap, 1, "SWAP" },
{ 0 }
};
static void Sync(void) {
- setprg4(0x5000, 16); // Only YS-612 advdnced version
- setprg8(0x6000, 2);
+ setprg4(0x5000, 16); // Only YS-612 advanced version
+ setprg8(0x6000, swap?0:2);
setprg8(0x8000, 1);
setprg8(0xa000, 0);
setprg8(0xc000, reg);
- setprg8(0xe000, 9);
+ setprg8(0xe000, swap?8:9);
setchr8(0);
}
static DECLFW(M43Write) {
// 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) {
case 0x4022: reg = transo[V & 7]; Sync(); break;
- case 0x8122: // hacked version
- case 0x4122: IRQa = V & 1; X6502_IRQEnd(FCEU_IQEXT); IRQCount = 0; break; // original version
+ case 0x4120: swap = V & 1; Sync(); break;
+ case 0x8122: // hacked version
+ case 0x4122: IRQa = V & 1; X6502_IRQEnd(FCEU_IQEXT); IRQCount = 0; break; // original version
}
}
static void M43Power(void) {
- reg = 0;
+ reg = swap = 0;
Sync();
SetReadHandler(0x5000, 0xffff, CartBR);
SetWriteHandler(0x4020, 0xffff, M43Write);
diff --git a/trunk/src/boards/addrlatch.cpp b/trunk/src/boards/addrlatch.cpp
index ae463002..299f6e46 100644
--- a/trunk/src/boards/addrlatch.cpp
+++ b/trunk/src/boards/addrlatch.cpp
@@ -85,18 +85,6 @@ static void Latch_Init(CartInfo *info, void (*proc)(void), readfunc func, uint16
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 ---------------------------
static void BMCD1038Sync(void) {
@@ -248,7 +236,7 @@ void Mapper200_Init(CartInfo *info) {
//------------------ Map 201 ---------------------------
static void M201Sync(void) {
- if(latche & 8) {
+ if (latche & 8) {
setprg32(0x8000, latche & 3);
setchr8(latche & 3);
} else {
@@ -303,14 +291,14 @@ static DECLFR(M212Read) {
}
static void M212Sync(void) {
- if(latche & 0x4000) {
+ if (latche & 0x4000) {
setprg32(0x8000, (latche >> 1) & 3);
} else {
setprg16(0x8000, latche & 7);
setprg16(0xC000, latche & 7);
}
setchr8(latche & 7);
- setmirror(((latche >> 3) & 1)^1);
+ setmirror(((latche >> 3) & 1) ^ 1);
}
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);
setprg8r(0x10, 0x6000, 0);
}
@@ -398,13 +386,13 @@ void Mapper227_Init(CartInfo *info) {
static void M229Sync(void) {
setchr8(latche);
- if(!(latche & 0x1e))
+ if (!(latche & 0x1e))
setprg32(0x8000, 0);
else {
setprg16(0x8000, latche & 0x1F);
setprg16(0xC000, latche & 0x1F);
}
- setmirror(((latche >> 5) & 1)^1);
+ setmirror(((latche >> 5) & 1) ^ 1);
}
void Mapper229_Init(CartInfo *info) {
@@ -415,13 +403,13 @@ void Mapper229_Init(CartInfo *info) {
static void M231Sync(void) {
setchr8(0);
- if(latche & 0x20)
+ if (latche & 0x20)
setprg32(0x8000, (latche >> 1) & 0x0F);
else {
setprg16(0x8000, latche & 0x1E);
setprg16(0xC000, latche & 0x1E);
}
- setmirror(((latche >> 7) & 1)^1);
+ setmirror(((latche >> 7) & 1) ^ 1);
}
void Mapper231_Init(CartInfo *info) {
@@ -460,7 +448,7 @@ static void BMC810544CA1Sync(void) {
uint32 bank = latche >> 7;
if (latche & 0x40)
setprg32(0x8000, bank);
- else{
+ else {
setprg16(0x8000, (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) {
setchr8(0);
- if (latche & 0x800) { // UNROM mode
+ if (latche & 0x800) { // UNROM mode
setprg16(0x8000, (latche & 0x1F) | (latche & ((latche & 0x40) >> 6)));
setprg16(0xC000, (latche & 0x18) | 7);
} else {
- if (latche & 0x40) { // 16K mode
+ if (latche & 0x40) { // 16K mode
setprg16(0x8000, latche & 0x1F);
setprg16(0xC000, latche & 0x1F);
} else {
diff --git a/trunk/src/boards/datalatch.cpp b/trunk/src/boards/datalatch.cpp
index ddff9e34..cb7a2ab1 100644
--- a/trunk/src/boards/datalatch.cpp
+++ b/trunk/src/boards/datalatch.cpp
@@ -91,7 +91,7 @@ static DECLFW(NROMWrite) {
#endif
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(0xC000, ~0);
setchr8(0);
@@ -127,7 +127,7 @@ static void UNROMSync(void) {
setprg16(0x8000, latche & 0x7);
if (latche & 8) mirror_in_use = 1;
if (mirror_in_use)
- setmirror(((latche >> 3) & 1) ^ 1); // Higway Star Hacked mapper
+ setmirror(((latche >> 3) & 1) ^ 1); // Higway Star Hacked mapper
} else
setprg16(0x8000, latche & 0xf);
setprg16(0xc000, ~0);
@@ -143,7 +143,7 @@ void UNROM_Init(CartInfo *info) {
static void CNROMSync(void) {
setchr8(latche);
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) {
@@ -159,7 +159,7 @@ static void ANROMSync() {
}
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 ---------------------------
@@ -215,7 +215,6 @@ void Mapper38_Init(CartInfo *info) {
//------------------ Map 66 ---------------------------
static void MHROMSync(void) {
-
setprg32(0x8000, latche >> 4);
setchr8(latche & 0xF);
}
@@ -373,7 +372,7 @@ static void M152Sync() {
setprg16(0x8000, (latche >> 4) & 7);
setprg16(0xc000, ~0);
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) {
@@ -435,8 +434,8 @@ void Mapper240_Init(CartInfo *info) {
static void M241Sync(void) {
setchr8(0);
setprg8r(0x10, 0x6000, 0);
- if(latche & 0x80)
- setprg32(0x8000, latche | 8); // no 241 actually, but why not afterall?
+ if (latche & 0x80)
+ setprg32(0x8000, latche | 8); // no 241 actually, but why not afterall?
else
setprg32(0x8000, latche);
}
@@ -455,7 +454,7 @@ void Mapper241_Init(CartInfo *info) {
static void BMCA65ASSync(void) {
if (latche & 0x40)
setprg32(0x8000, (latche >> 1) & 0x0F);
- else{
+ else {
setprg16(0x8000, ((latche & 0x30) >> 1) | (latche & 7));
setprg16(0xC000, ((latche & 0x30) >> 1) | 7);
}
diff --git a/trunk/src/boards/mihunche.cpp b/trunk/src/boards/mihunche.cpp
new file mode 100644
index 00000000..512aa0f2
--- /dev/null
+++ b/trunk/src/boards/mihunche.cpp
@@ -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);
+}
diff --git a/trunk/src/boards/pec-586.cpp b/trunk/src/boards/pec-586.cpp
index 44c504d0..581d1b0f 100644
--- a/trunk/src/boards/pec-586.cpp
+++ b/trunk/src/boards/pec-586.cpp
@@ -20,13 +20,15 @@
#include "mapinc.h"
-static uint8 reg[7];
+static uint8 reg[7], debug = 1;
+static uint32 lastnt = 0;
static uint8 *WRAM = NULL;
static uint32 WRAMSIZE;
static SFORMAT StateRegs[] =
{
{ reg, 2, "REG" },
+ { &lastnt, 4, "LNT" },
{ 0 }
};
@@ -46,9 +48,13 @@ static uint8 br_tbl[16] = {
};
static void Sync(void) {
-// setchr4(0x0000,(reg[0]&0x80) >> 7);
-// setchr4(0x1000,(reg[0]&0x80) >> 7);
- setchr8(0);
+ if (reg[0]&0x80) {
+ setchr4(0x0000, (lastnt >> 9) ^ 0);
+ setchr4(0x1000, (lastnt >> 9) ^ 1);
+ } else {
+ setchr4(0x0000, 1);
+ setchr4(0x1000, 0);
+ }
setprg8r(0x10, 0x6000, 0);
setprg16(0x8000, bs_tbl[reg[0] & 0x7f] >> 4);
setprg16(0xc000, bs_tbl[reg[0] & 0x7f] & 0xf);
@@ -57,17 +63,18 @@ static void Sync(void) {
static DECLFW(UNLPEC586Write) {
reg[(A & 0x700) >> 8] = V;
- FCEU_printf("bs %04x %02x\n", A, V);
+// FCEU_printf("bs %04x %02x\n", A, V);
Sync();
}
static DECLFR(UNLPEC586Read) {
- FCEU_printf("read %04x\n", A);
+// FCEU_printf("read %04x\n", A);
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);
@@ -77,16 +84,21 @@ static void UNLPEC586Power(void) {
SetReadHandler(0x5000, 0x5fff, UNLPEC586Read);
}
-static void UNLPEC586IRQ(void) {
-// if(reg[0]&0x80)
+static void UNLPEC586PPU(uint32 A) {
+ if (reg[0]&0x80)
{
- if (scanline == 128) {
- setchr4(0x0000, 1);
- setchr4(0x1000, 0);
- } else {
- setchr4(0x0000, 0);
- setchr4(0x1000, 1);
+ 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);
}
}
@@ -103,9 +115,11 @@ static void StateRestore(int version) {
void UNLPEC586Init(CartInfo *info) {
info->Power = UNLPEC586Power;
info->Close = UNLPEC586Close;
- GameHBIRQHook = UNLPEC586IRQ;
+ PPU_hook = UNLPEC586PPU;
GameStateRestore = StateRestore;
+ PEC586Hack = 1;
+
WRAMSIZE = 8192;
WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE);
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);
diff --git a/trunk/src/fceu.cpp b/trunk/src/fceu.cpp
index 72d52803..41a3daa1 100644
--- a/trunk/src/fceu.cpp
+++ b/trunk/src/fceu.cpp
@@ -378,6 +378,7 @@ void ResetGameLoaded(void) {
memset(&GameExpSound, 0, sizeof(GameExpSound));
MapIRQHook = NULL;
MMC5Hack = 0;
+ PEC586Hack = 0;
PAL &= 1;
pale = 0;
}
diff --git a/trunk/src/fceu.h b/trunk/src/fceu.h
index fa26ebf0..2e8d6545 100644
--- a/trunk/src/fceu.h
+++ b/trunk/src/fceu.h
@@ -39,7 +39,7 @@ char *FCEUI_GetAboutString();
extern uint64 timestampbase;
extern uint32 MMC5HackVROMMask;
extern uint8 *MMC5HackExNTARAMPtr;
-extern int MMC5Hack;
+extern int MMC5Hack, PEC586Hack;
extern uint8 *MMC5HackVROMPTR;
extern uint8 MMC5HackCHRMode;
extern uint8 MMC5HackSPMode;
diff --git a/trunk/src/ppu.cpp b/trunk/src/ppu.cpp
index 9d891250..672413d0 100644
--- a/trunk/src/ppu.cpp
+++ b/trunk/src/ppu.cpp
@@ -311,7 +311,7 @@ int fceuindbg = 0;
//0xFF shall indicate to use palette[0]
uint8 gNoBGFillColor = 0xFF;
-int MMC5Hack = 0;
+int MMC5Hack = 0, PEC586Hack = 0;;
uint32 MMC5HackVROMMask = 0;
uint8 *MMC5HackExNTARAMPtr = 0;
uint8 *MMC5HackVROMPTR = 0;
@@ -321,7 +321,6 @@ uint8 MMC50x5130 = 0;
uint8 MMC5HackSPScroll = 0;
uint8 MMC5HackSPPage = 0;
-
uint8 VRAMBuffer = 0, PPUGenLatch = 0;
uint8 *vnapage[4];
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
//0x20 are 0 to not break fceu rendering.
-
#define MMC5SPRVRAMADR(V) &MMC5SPRVPage[(V) >> 10][(V)]
#define VRAMADR(V) &VPage[(V) >> 10][(V)]
@@ -725,7 +723,6 @@ static DECLFR(A2007) {
}
} else {
ret = VRAMBuffer;
-
#ifdef FCEUDEF_DEBUGGER
if (!fceuindbg)
#endif
@@ -740,13 +737,13 @@ static DECLFR(A2007) {
VRAMBuffer = vnapage[(tmp >> 10) & 0x3][tmp & 0x3FF];
}
}
+
#ifdef FCEUDEF_DEBUGGER
if (!fceuindbg)
#endif
{
if ((ScreenON || SpriteON) && (scanline < 240)) {
uint32 rad = RefreshAddr;
-
if ((rad & 0x7000) == 0x7000) {
rad ^= 0x7000;
if ((rad & 0x3E0) == 0x3A0)
@@ -766,7 +763,6 @@ static DECLFR(A2007) {
}
if (PPU_hook) PPU_hook(RefreshAddr & 0x3fff);
}
-
return ret;
}
}
@@ -819,8 +815,9 @@ static DECLFW(B2004) {
if (PPUSPL >= 8) {
if (PPU[3] >= 8)
SPRAM[PPU[3]] = V;
- } else
+ } else {
SPRAM[PPUSPL] = V;
+ }
PPU[3]++;
PPUSPL++;
}
@@ -1020,7 +1017,7 @@ static void RefreshLine(int lastpixel) {
// PPU_hook() functions can call
// mirroring/chr bank switching functions,
// which call FCEUPPU_LineUpdate, which call this
- // function. */
+ // function.
if (norecurse) return;
if (sphitx != 0x100 && !(PPU_status & 0x40)) {
@@ -1112,14 +1109,30 @@ static void RefreshLine(int lastpixel) {
else if (PPU_hook) {
norecurse = 1;
#define PPUT_HOOK
- for (X1 = firsttile; X1 < lasttile; X1++) {
- #include "pputile.inc"
+ if (PEC586Hack) {
+ #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
norecurse = 0;
} else {
- for (X1 = firsttile; X1 < lasttile; X1++) {
- #include "pputile.inc"
+ if (PEC586Hack) {
+ #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;
- vofs = (unsigned int)(P0 & 0x8 & (((P0 & 0x20) ^ 0x20) >> 2)) << 9;
+ vofs = (uint32)(P0 & 0x8 & (((P0 & 0x20) ^ 0x20) >> 2)) << 9;
H += (P0 & 0x20) >> 2;
if (!PPU_hook)
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 (n == 63) sb = 1;
@@ -1315,7 +1328,7 @@ static void FetchSpriteData(void) {
SPRB dst;
uint8 *C;
int t;
- unsigned int vadr;
+ uint32 vadr;
t = (int)scanline - (spr->y);
@@ -1337,9 +1350,8 @@ static void FetchSpriteData(void) {
/* Fix this geniestage hack */
if (MMC5Hack && geniestage != 1)
C = MMC5SPRVRAMADR(vadr);
- else {
+ else
C = VRAMADR(vadr);
- }
if (SpriteON)
RENDER_LOG(vadr);
@@ -1361,7 +1373,7 @@ static void FetchSpriteData(void) {
}
else
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 (n == 63) sb = 1;
@@ -1370,7 +1382,7 @@ static void FetchSpriteData(void) {
SPRB dst;
uint8 *C;
int t;
- unsigned int vadr;
+ uint32 vadr;
t = (int)scanline - (spr->y);
@@ -1559,9 +1571,9 @@ static void CopySprites(uint8 *target) {
uint32 t = *(uint32*)(sprlinebuf + n);
if (t != 0x80808080) {
-#ifdef LSB_FIRST
+ #ifdef LSB_FIRST
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];
}
@@ -1579,7 +1591,7 @@ static void CopySprites(uint8 *target) {
if (!(t & 0x40000000) || (P[n + 3] & 0x40)) // Normal sprite || behind bg sprite
P[n + 3] = (sprlinebuf + 3)[n];
}
-#else
+ #else
/* TODO: Simplify */
if (!(t & 0x80000000)) {
if (!(t & 0x40000000)) // Normal sprite
@@ -1608,7 +1620,7 @@ static void CopySprites(uint8 *target) {
else if (P[n + 3] & 64) // behind bg sprite
P[n + 3] = (sprlinebuf + 3)[n];
}
-#endif
+ #endif
}
}
n += 4;
@@ -1668,7 +1680,7 @@ void FCEUPPU_Power(void) {
BWrite[x + 2] = B2002;
ARead[x + 3] = A200x;
BWrite[x + 3] = B2003;
- ARead[x + 4] = A2004; //A2004;
+ ARead[x + 4] = A2004;
BWrite[x + 4] = B2004;
ARead[x + 5] = A200x;
BWrite[x + 5] = B2005;
@@ -1740,14 +1752,14 @@ int FCEUPPU_Loop(int skip) {
}
if (GameInfo->type == GIT_NSF)
X6502_Run((256 + 85) * 240);
-#ifdef FRAMESKIP
+ #ifdef FRAMESKIP
else if (skip) {
int y;
y = SPRAM[0];
y++;
- PPU_status |= 0x20; // Fixes "Bee 52". Does it break anything?
+ PPU_status |= 0x20; // Fixes "Bee 52". Does it break anything?
if (GameHBIRQHook) {
X6502_Run(256);
for (scanline = 0; scanline < 240; scanline++) {
@@ -1763,17 +1775,16 @@ int FCEUPPU_Loop(int skip) {
} else
X6502_Run((256 + 85) * 240);
}
-#endif
+ #endif
else {
int x, max, maxref;
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]++;
DEBUG(FCEUD_UpdatePPUView(scanline, 1));
DoLine();
}
-
if (MMC5Hack && (ScreenON || SpriteON)) MMC5_hb(scanline);
for (x = 1, max = 0, maxref = 0; x < 7; x++) {
if (deempcnt[x] > max) {
@@ -1786,12 +1797,12 @@ int FCEUPPU_Loop(int skip) {
}
} //else... to if(ppudead)
-#ifdef FRAMESKIP
+ #ifdef FRAMESKIP
if (skip) {
FCEU_PutImageDummy();
return(0);
} else
-#endif
+ #endif
{
FCEU_PutImage();
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
struct BGData {
struct Record {
- uint8 nt, at, pt[2];
+ uint8 nt, pecnt, at, pt[2];
INLINE void Read() {
RefreshAddr = ppur.get_ntread();
+ pecnt = (RefreshAddr & 1) << 3;
nt = CALL_PPUREAD(RefreshAddr);
runppu(kFetchTime);
@@ -1906,15 +1918,24 @@ struct BGData {
ppur.par = nt;
RefreshAddr = ppur.get_ptread();
- 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);
+ if (PEC586Hack) {
+ if (ScreenON)
+ RENDER_LOG(RefreshAddr | pecnt);
+ pt[0] = CALL_PPUREAD(RefreshAddr | pecnt);
+ runppu(kFetchTime);
+ pt[1] = CALL_PPUREAD(RefreshAddr | pecnt);
+ runppu(kFetchTime);
+ } else {
+ 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);
+ }
}
};
diff --git a/trunk/src/pputile.inc b/trunk/src/pputile.inc
index 92451742..b935a7ff 100644
--- a/trunk/src/pputile.inc
+++ b/trunk/src/pputile.inc
@@ -1,82 +1,80 @@
-uint8 *C;
+uint8 *C;
register uint8 cc;
uint32 vadr;
-
+
#ifndef PPUT_MMC5SP
- uint8 zz;
+ register uint8 zz;
#else
- uint8 xs,ys;
- xs=X1;
- ys=((scanline>>3)+MMC5HackSPScroll)&0x1F;
- if(ys>=0x1E) ys-=0x1E;
+ uint8 xs, ys;
+ xs = X1;
+ ys = ((scanline >> 3) + MMC5HackSPScroll) & 0x1F;
+ if (ys >= 0x1E) ys -= 0x1E;
#endif
-
-if(X1>=2) {
- uint8 *S=PALRAM;
+
+if (X1 >= 2) {
+ uint8 *S = PALRAM;
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)];
- //printf("%02x ",ppulut3[XOffset|(atlatch<<3)]);
+ pixdata |= ppulut3[XOffset | (atlatch << 3)];
- P[0]=S[pixdata&0xF];
- pixdata>>=4;
- P[1]=S[pixdata&0xF];
- pixdata>>=4;
- P[2]=S[pixdata&0xF];
- pixdata>>=4;
- P[3]=S[pixdata&0xF];
- pixdata>>=4;
- P[4]=S[pixdata&0xF];
- pixdata>>=4;
- P[5]=S[pixdata&0xF];
- pixdata>>=4;
- P[6]=S[pixdata&0xF];
- pixdata>>=4;
- P[7]=S[pixdata&0xF];
- P+=8;
+ P[0] = S[pixdata & 0xF];
+ pixdata >>= 4;
+ P[1] = S[pixdata & 0xF];
+ pixdata >>= 4;
+ P[2] = S[pixdata & 0xF];
+ pixdata >>= 4;
+ P[3] = S[pixdata & 0xF];
+ pixdata >>= 4;
+ P[4] = S[pixdata & 0xF];
+ pixdata >>= 4;
+ P[5] = S[pixdata & 0xF];
+ pixdata >>= 4;
+ P[6] = S[pixdata & 0xF];
+ pixdata >>= 4;
+ P[7] = S[pixdata & 0xF];
+ P += 8;
}
#ifdef PPUT_MMC5SP
- vadr=(MMC5HackExNTARAMPtr[xs|(ys<<5)]<<4)+(vofs&7);
+ vadr = (MMC5HackExNTARAMPtr[xs | (ys << 5)] << 4) + (vofs & 7);
#else
- zz=RefreshAddr&0x1F;
- C=vnapage[(RefreshAddr>>10)&3];
- vadr=(C[RefreshAddr&0x3ff]<<4)+vofs; /* Fetch name table byte. */
+ zz = RefreshAddr & 0x1F;
+ C = vnapage[(RefreshAddr >> 10) & 3];
+ vadr = (C[RefreshAddr & 0x3ff] << 4) + vofs; // Fetch name table byte.
#endif
#ifdef PPUT_HOOK
- PPU_hook(0x2000|(RefreshAddr&0xfff));
+ PPU_hook(0x2000 | (RefreshAddr & 0xfff));
#endif
#ifdef PPUT_MMC5SP
- cc=MMC5HackExNTARAMPtr[0x3c0+(xs>>2)+((ys&0x1C)<<1)];
- cc=((cc >> ((xs&2) + ((ys&0x2)<<1))) &3);
+ cc = MMC5HackExNTARAMPtr[0x3c0 + (xs >> 2) + ((ys & 0x1C) << 1)];
+ cc = ((cc >> ((xs & 2) + ((ys & 0x2) << 1))) & 3);
#else
#ifdef PPUT_MMC5CHR1
- cc=(MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff] & 0xC0)>>6;
+ cc = (MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff] & 0xC0) >> 6;
#else
- cc=C[0x3c0+(zz>>2)+((RefreshAddr&0x380)>>4)]; /* Fetch attribute table byte. */
- cc=((cc >> ((zz&2) + ((RefreshAddr&0x40)>>4))) &3);
+ cc = C[0x3c0 + (zz >> 2) + ((RefreshAddr & 0x380) >> 4)]; // Fetch attribute table byte.
+ cc = ((cc >> ((zz & 2) + ((RefreshAddr & 0x40) >> 4))) & 3);
#endif
#endif
-atlatch>>=2;
-atlatch|=cc<<2;
-
-pshift[0]<<=8;
-pshift[1]<<=8;
+atlatch >>= 2;
+atlatch |= cc << 2;
+
+pshift[0] <<= 8;
+pshift[1] <<= 8;
#ifdef PPUT_MMC5SP
- C = MMC5HackVROMPTR+vadr;
+ C = MMC5HackVROMPTR + vadr;
C += ((MMC5HackSPPage & 0x3f & MMC5HackVROMMask) << 12);
#else
#ifdef PPUT_MMC5CHR1
C = MMC5HackVROMPTR;
- C += (((MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff]) & 0x3f &
- MMC5HackVROMMask) << 12) + (vadr & 0xfff);
- C += (MMC50x5130&0x3)<<18; //11-jun-2009 for kuja_killer
+ C += (((MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff]) & 0x3f & MMC5HackVROMMask) << 12) + (vadr & 0xfff);
+ C += (MMC50x5130 & 0x3) << 18; //11-jun-2009 for kuja_killer
#elif defined(PPUT_MMC5)
C = MMC5BGVRAMADR(vadr);
#else
@@ -88,19 +86,33 @@ pshift[1]<<=8;
PPU_hook(vadr);
#endif
-if(ScreenON)
- RENDER_LOG(vadr);
-pshift[0]|=C[0];
-if(ScreenON)
- RENDER_LOG(vadr + 8);
-pshift[1]|=C[8];
+#ifdef PPU_BGFETCH
+ if (RefreshAddr & 1) {
+ if(ScreenON)
+ RENDER_LOG(vadr + 8);
+ pshift[0] |= 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)
- RefreshAddr^=0x41F;
+if ((RefreshAddr & 0x1f) == 0x1f)
+ RefreshAddr ^= 0x41F;
else
RefreshAddr++;
#ifdef PPUT_HOOK
- PPU_hook(0x2000|(RefreshAddr&0xfff));
+ PPU_hook(0x2000 | (RefreshAddr & 0xfff));
#endif
diff --git a/trunk/vc/vc10_fceux.vcxproj b/trunk/vc/vc10_fceux.vcxproj
index 0e91e566..feef5dbd 100644
--- a/trunk/vc/vc10_fceux.vcxproj
+++ b/trunk/vc/vc10_fceux.vcxproj
@@ -323,6 +323,7 @@
+
diff --git a/trunk/vc/vc10_fceux.vcxproj.filters b/trunk/vc/vc10_fceux.vcxproj.filters
index 4d9b0370..000e3f8b 100644
--- a/trunk/vc/vc10_fceux.vcxproj.filters
+++ b/trunk/vc/vc10_fceux.vcxproj.filters
@@ -1,4 +1,4 @@
-
+
@@ -955,6 +955,9 @@
utils
+
+ boards
+
diff --git a/trunk/vc/vc8_fceux.vcproj b/trunk/vc/vc8_fceux.vcproj
index 8deffb5d..1e22cf4a 100644
--- a/trunk/vc/vc8_fceux.vcproj
+++ b/trunk/vc/vc8_fceux.vcproj
@@ -1082,6 +1082,10 @@
RelativePath="..\src\boards\malee.cpp"
>
+
+
diff --git a/trunk/vc/vc9_fceux.vcproj b/trunk/vc/vc9_fceux.vcproj
index 1a5fc888..d5bad547 100644
--- a/trunk/vc/vc9_fceux.vcproj
+++ b/trunk/vc/vc9_fceux.vcproj
@@ -851,6 +851,10 @@
RelativePath="..\src\boards\lh53.cpp"
>
+
+