2013-05-13 19:27:34 +00:00
|
|
|
uint8 *C;
|
2008-08-08 09:45:34 +00:00
|
|
|
register uint8 cc;
|
|
|
|
uint32 vadr;
|
2019-06-30 11:00:59 +00:00
|
|
|
#ifdef PPU_VRC5FETCH
|
|
|
|
uint8 tmpd;
|
|
|
|
#endif
|
2013-05-13 19:27:34 +00:00
|
|
|
|
2008-08-08 09:45:34 +00:00
|
|
|
#ifndef PPUT_MMC5SP
|
2013-05-13 19:27:34 +00:00
|
|
|
register uint8 zz;
|
2008-08-08 09:45:34 +00:00
|
|
|
#else
|
2013-05-13 19:27:34 +00:00
|
|
|
uint8 xs, ys;
|
|
|
|
xs = X1;
|
|
|
|
ys = ((scanline >> 3) + MMC5HackSPScroll) & 0x1F;
|
|
|
|
if (ys >= 0x1E) ys -= 0x1E;
|
2008-08-08 09:45:34 +00:00
|
|
|
#endif
|
2013-05-13 19:27:34 +00:00
|
|
|
|
|
|
|
if (X1 >= 2) {
|
|
|
|
uint8 *S = PALRAM;
|
2008-08-08 09:45:34 +00:00
|
|
|
uint32 pixdata;
|
|
|
|
|
2013-05-13 19:27:34 +00:00
|
|
|
pixdata = ppulut1[(pshift[0] >> (8 - XOffset)) & 0xFF] | ppulut2[(pshift[1] >> (8 - XOffset)) & 0xFF];
|
|
|
|
|
|
|
|
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;
|
2008-08-08 09:45:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PPUT_MMC5SP
|
2013-05-13 19:27:34 +00:00
|
|
|
vadr = (MMC5HackExNTARAMPtr[xs | (ys << 5)] << 4) + (vofs & 7);
|
2008-08-08 09:45:34 +00:00
|
|
|
#else
|
2013-05-13 19:27:34 +00:00
|
|
|
zz = RefreshAddr & 0x1F;
|
|
|
|
C = vnapage[(RefreshAddr >> 10) & 3];
|
2019-06-30 11:00:59 +00:00
|
|
|
#ifdef PPU_VRC5FETCH
|
|
|
|
tmpd = QTAINTRAM[((((RefreshAddr >> 10) & 3) >> ((qtaintramreg >> 1)) & 1) << 10) | (RefreshAddr & 0x3FF)];
|
|
|
|
vofs = ((tmpd & 0x3F) << 12) | ((RefreshAddr >> 12) & 7); // recalculate VROM offset
|
|
|
|
#endif
|
|
|
|
vadr = (C[RefreshAddr & 0x3ff] << 4) + vofs; // Fetch name table byte.
|
2008-08-08 09:45:34 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PPUT_HOOK
|
2013-05-13 19:27:34 +00:00
|
|
|
PPU_hook(0x2000 | (RefreshAddr & 0xfff));
|
2008-08-08 09:45:34 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PPUT_MMC5SP
|
2013-05-13 19:27:34 +00:00
|
|
|
cc = MMC5HackExNTARAMPtr[0x3c0 + (xs >> 2) + ((ys & 0x1C) << 1)];
|
|
|
|
cc = ((cc >> ((xs & 2) + ((ys & 0x2) << 1))) & 3);
|
2008-08-08 09:45:34 +00:00
|
|
|
#else
|
|
|
|
#ifdef PPUT_MMC5CHR1
|
2013-05-13 19:27:34 +00:00
|
|
|
cc = (MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff] & 0xC0) >> 6;
|
2008-08-08 09:45:34 +00:00
|
|
|
#else
|
2013-05-13 19:27:34 +00:00
|
|
|
cc = C[0x3c0 + (zz >> 2) + ((RefreshAddr & 0x380) >> 4)]; // Fetch attribute table byte.
|
|
|
|
cc = ((cc >> ((zz & 2) + ((RefreshAddr & 0x40) >> 4))) & 3);
|
2008-08-08 09:45:34 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2013-05-13 19:27:34 +00:00
|
|
|
atlatch >>= 2;
|
|
|
|
atlatch |= cc << 2;
|
|
|
|
|
|
|
|
pshift[0] <<= 8;
|
|
|
|
pshift[1] <<= 8;
|
2008-08-08 09:45:34 +00:00
|
|
|
|
|
|
|
#ifdef PPUT_MMC5SP
|
2013-05-13 19:27:34 +00:00
|
|
|
C = MMC5HackVROMPTR + vadr;
|
2008-08-08 09:45:34 +00:00
|
|
|
C += ((MMC5HackSPPage & 0x3f & MMC5HackVROMMask) << 12);
|
|
|
|
#else
|
|
|
|
#ifdef PPUT_MMC5CHR1
|
|
|
|
C = MMC5HackVROMPTR;
|
2013-05-13 19:27:34 +00:00
|
|
|
C += (((MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff]) & 0x3f & MMC5HackVROMMask) << 12) + (vadr & 0xfff);
|
|
|
|
C += (MMC50x5130 & 0x3) << 18; //11-jun-2009 for kuja_killer
|
2008-08-08 09:45:34 +00:00
|
|
|
#elif defined(PPUT_MMC5)
|
2013-03-10 14:41:50 +00:00
|
|
|
C = MMC5BGVRAMADR(vadr);
|
2008-08-08 09:45:34 +00:00
|
|
|
#else
|
2019-06-30 11:00:59 +00:00
|
|
|
|
|
|
|
#ifdef PPU_VRC5FETCH
|
|
|
|
if(tmpd & 0x40)
|
|
|
|
C = CHRptr[0] + vadr;
|
|
|
|
else
|
2008-08-08 09:45:34 +00:00
|
|
|
C = VRAMADR(vadr);
|
2019-06-30 11:00:59 +00:00
|
|
|
#else
|
|
|
|
C = VRAMADR(vadr);
|
|
|
|
#endif
|
|
|
|
|
2008-08-08 09:45:34 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PPUT_HOOK
|
|
|
|
PPU_hook(vadr);
|
|
|
|
#endif
|
|
|
|
|
2013-05-13 19:27:34 +00:00
|
|
|
#ifdef PPU_BGFETCH
|
|
|
|
if (RefreshAddr & 1) {
|
|
|
|
if(ScreenON)
|
2018-02-11 15:24:54 +00:00
|
|
|
RENDER_LOGP(C + 8);
|
2013-05-13 19:27:34 +00:00
|
|
|
pshift[0] |= C[8];
|
|
|
|
pshift[1] |= C[8];
|
|
|
|
} else {
|
|
|
|
if(ScreenON)
|
2018-02-11 15:24:54 +00:00
|
|
|
RENDER_LOGP(C);
|
2013-05-13 19:27:34 +00:00
|
|
|
pshift[0] |= C[0];
|
|
|
|
pshift[1] |= C[0];
|
|
|
|
}
|
|
|
|
#else
|
2019-08-06 22:17:57 +00:00
|
|
|
#ifdef PPU_VRC5FETCH
|
|
|
|
pshift[0] |= C[0];
|
|
|
|
if(tmpd & 0x40)
|
|
|
|
pshift[1] |= (tmpd & 0x80) ? 0xFF : 0x00;
|
|
|
|
else
|
|
|
|
pshift[1] |= C[8];
|
|
|
|
#else
|
2013-05-13 19:27:34 +00:00
|
|
|
if(ScreenON)
|
2018-02-11 15:24:54 +00:00
|
|
|
RENDER_LOGP(C);
|
2013-05-13 19:27:34 +00:00
|
|
|
pshift[0] |= C[0];
|
|
|
|
if(ScreenON)
|
2018-02-11 15:24:54 +00:00
|
|
|
RENDER_LOGP(C + 8);
|
2013-05-13 19:27:34 +00:00
|
|
|
pshift[1] |= C[8];
|
2019-08-06 22:17:57 +00:00
|
|
|
#endif
|
2013-05-13 19:27:34 +00:00
|
|
|
#endif
|
2008-08-08 09:45:34 +00:00
|
|
|
|
2013-05-13 19:27:34 +00:00
|
|
|
if ((RefreshAddr & 0x1f) == 0x1f)
|
|
|
|
RefreshAddr ^= 0x41F;
|
2008-08-08 09:45:34 +00:00
|
|
|
else
|
|
|
|
RefreshAddr++;
|
|
|
|
|
|
|
|
#ifdef PPUT_HOOK
|
2013-05-13 19:27:34 +00:00
|
|
|
PPU_hook(0x2000 | (RefreshAddr & 0xfff));
|
2008-08-08 09:45:34 +00:00
|
|
|
#endif
|
|
|
|
|