Skip to content

Commit

Permalink
Fix support for mapper 547
Browse files Browse the repository at this point in the history
  • Loading branch information
negativeExponent authored and LibretroAdmin committed Sep 20, 2024
1 parent ebbd29e commit f1d7589
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/ppu.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,12 @@ static DECLFW(B2007) {
if (PPUCHRRAM & (1 << (tmp >> 10)))
VPage[tmp >> 10][tmp] = V;
} else if (tmp < 0x3F00) {
if (PPUNTARAM & (1 << ((tmp & 0xF00) >> 10)))
vnapage[((tmp & 0xF00) >> 10)][tmp & 0x3FF] = V;
if (QTAIHack && (qtaintramreg & 1)) {
QTAINTRAM[((((tmp & 0xF00) >> 10) >> ((qtaintramreg >> 1)) & 1) << 10) | (tmp & 0x3FF)] = V;
} else {
if (PPUNTARAM & (1 << ((tmp & 0xF00) >> 10)))
vnapage[((tmp & 0xF00) >> 10)][tmp & 0x3FF] = V;
}
} else {
if (!(tmp & 3)) {
if (!(tmp & 0xC))
Expand Down Expand Up @@ -571,6 +575,12 @@ static void FASTAPASS(1) RefreshLine(int lastpixel) {
#include "pputile.h"
}
#undef PPU_BGFETCH
} else if (QTAIHack) {
#define PPU_VRC5FETCH
for (X1 = firsttile; X1 < lasttile; X1++) {
#include "pputile.h"
}
#undef PPU_VRC5FETCH
} else {
for (X1 = firsttile; X1 < lasttile; X1++) {
#include "pputile.h"
Expand Down
28 changes: 28 additions & 0 deletions src/pputile.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
uint8 *C;
uint8 cc;
uint32 vadr;
#ifdef PPU_VRC5FETCH
uint8 tmpd;
#endif

#ifndef PPUT_MMC5SP
uint8 zz;
Expand Down Expand Up @@ -42,6 +45,10 @@ if (X1 >= 2) {
#else
zz = RefreshAddr & 0x1F;
C = vnapage[(RefreshAddr >> 10) & 3];
#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. */
#endif

Expand Down Expand Up @@ -77,9 +84,22 @@ pshift[1] <<= 8;
C += (MMC50x5130 & 0x3) << 18;
#elif defined(PPUT_MMC5)
C = MMC5BGVRAMADR(vadr);
#else
#ifdef PPU_VRC5FETCH
extern uint8 *VROM;
extern uint32 VROM_size;
if (tmpd & 0x40) {
if ((VROM_size * 8) == 128) {
vadr = ((vadr & 0x07) << 1) | ((vadr & 0x10) >> 4) | ((vadr & 0x3FFE0) >> 1);
}
C = VROM + vadr;
} else {
C = VRAMADR(vadr);
}
#else
C = VRAMADR(vadr);
#endif
#endif
#endif

#ifdef PPUT_HOOK
Expand All @@ -95,8 +115,16 @@ pshift[1] <<= 8;
pshift[1] |= C[0];
}
#else
#ifdef PPU_VRC5FETCH
pshift[0] |= C[0];
if (tmpd & 0x40)
pshift[1] |= (tmpd & 0x80) ? 0xFF : 0x00;
else
pshift[1] |= C[8];
#else
pshift[0] |= C[0];
pshift[1] |= C[8];
#endif
#endif

if ((RefreshAddr & 0x1f) == 0x1f)
Expand Down

0 comments on commit f1d7589

Please sign in to comment.