CDLogger: MMC5 BG CHR logging fixed.

This commit is contained in:
CaH4e3 2018-02-11 15:24:54 +00:00
parent 2c64456617
commit fbece4b5e8
2 changed files with 54 additions and 13 deletions

View File

@ -433,7 +433,12 @@ unsigned int cdloggerVideoDataSize = 0;
int GetCHRAddress(int A) { int GetCHRAddress(int A) {
if (cdloggerVideoDataSize) { if (cdloggerVideoDataSize) {
int result = &VPage[A >> 10][A] - CHRptr[0]; // int result = &VPage[A >> 10][A] - CHRptr[0];
int result;
if(MMC5Hack)
result = MMC5BGVRAMADR(A) - CHRptr[0];
else
result = &VPage[A >> 10][A] - CHRptr[0];
if ((result >= 0) && (result < (int)cdloggerVideoDataSize)) if ((result >= 0) && (result < (int)cdloggerVideoDataSize))
return result; return result;
} else } else
@ -441,6 +446,18 @@ int GetCHRAddress(int A) {
return -1; return -1;
} }
int GetCHROffset(uint8 *ptr) {
int result = ptr - CHRptr[0];
if (cdloggerVideoDataSize) {
if ((result >= 0) && (result < (int)cdloggerVideoDataSize))
return result;
} else {
if ((result >= 0) && (result < 0x2000))
return result;
}
return -1;
}
#define RENDER_LOG(tmp) { \ #define RENDER_LOG(tmp) { \
if (debug_loggingCD) \ if (debug_loggingCD) \
{ \ { \
@ -459,6 +476,24 @@ int GetCHRAddress(int A) {
} \ } \
} }
#define RENDER_LOGP(tmp) { \
if (debug_loggingCD) \
{ \
int addr = GetCHROffset(tmp); \
if (addr != -1) \
{ \
if (!(cdloggervdata[addr] & 1)) \
{ \
cdloggervdata[addr] |= 1; \
if(cdloggerVideoDataSize) { \
if (!(cdloggervdata[addr] & 2)) undefinedvromcount--; \
rendercount++; \
} \
} \
} \
} \
}
uint8 FASTCALL FFCEUX_PPURead_Default(uint32 A) { uint8 FASTCALL FFCEUX_PPURead_Default(uint32 A) {
uint32 tmp = A; uint32 tmp = A;
@ -741,11 +776,9 @@ static DECLFR(A2007) {
if (debug_loggingCD) if (debug_loggingCD)
LogAddress = GetCHRAddress(tmp); LogAddress = GetCHRAddress(tmp);
if(MMC5Hack) if(MMC5Hack)
{
//probably wrong CD logging in this case...
VRAMBuffer = *MMC5BGVRAMADR(tmp); VRAMBuffer = *MMC5BGVRAMADR(tmp);
} else
else VRAMBuffer = VPage[tmp >> 10][tmp]; VRAMBuffer = VPage[tmp >> 10][tmp];
} else if (tmp < 0x3F00) } else if (tmp < 0x3F00)
VRAMBuffer = vnapage[(tmp >> 10) & 0x3][tmp & 0x3FF]; VRAMBuffer = vnapage[(tmp >> 10) & 0x3][tmp & 0x3FF];
@ -1395,10 +1428,12 @@ static void FetchSpriteData(void) {
C = VRAMADR(vadr); C = VRAMADR(vadr);
if (SpriteON) if (SpriteON)
RENDER_LOG(vadr); // RENDER_LOG(vadr);
RENDER_LOGP(C);
dst.ca[0] = C[0]; dst.ca[0] = C[0];
if (SpriteON) if (SpriteON)
RENDER_LOG(vadr + 8); // RENDER_LOG(vadr + 8);
RENDER_LOGP(C+8);
dst.ca[1] = C[8]; dst.ca[1] = C[8];
dst.x = spr->x; dst.x = spr->x;
dst.atr = spr->atr; dst.atr = spr->atr;
@ -1447,14 +1482,16 @@ static void FetchSpriteData(void) {
else else
C = VRAMADR(vadr); C = VRAMADR(vadr);
if (SpriteON) if (SpriteON)
RENDER_LOG(vadr); // RENDER_LOG(vadr);
RENDER_LOGP(C);
dst.ca[0] = C[0]; dst.ca[0] = C[0];
if (ns < 8) { if (ns < 8) {
PPU_hook(0x2000); PPU_hook(0x2000);
PPU_hook(vadr); PPU_hook(vadr);
} }
if (SpriteON) if (SpriteON)
RENDER_LOG(vadr + 8); // RENDER_LOG(vadr + 8);
RENDER_LOGP(C+8);
dst.ca[1] = C[8]; dst.ca[1] = C[8];
dst.x = spr->x; dst.x = spr->x;
dst.atr = spr->atr; dst.atr = spr->atr;

View File

@ -89,21 +89,25 @@ pshift[1] <<= 8;
#ifdef PPU_BGFETCH #ifdef PPU_BGFETCH
if (RefreshAddr & 1) { if (RefreshAddr & 1) {
if(ScreenON) if(ScreenON)
RENDER_LOG(vadr + 8); // RENDER_LOG(vadr + 8);
RENDER_LOGP(C + 8);
pshift[0] |= C[8]; pshift[0] |= C[8];
pshift[1] |= C[8]; pshift[1] |= C[8];
} else { } else {
if(ScreenON) if(ScreenON)
RENDER_LOG(vadr); // RENDER_LOG(vadr);
RENDER_LOGP(C);
pshift[0] |= C[0]; pshift[0] |= C[0];
pshift[1] |= C[0]; pshift[1] |= C[0];
} }
#else #else
if(ScreenON) if(ScreenON)
RENDER_LOG(vadr); // RENDER_LOG(vadr);
RENDER_LOGP(C);
pshift[0] |= C[0]; pshift[0] |= C[0];
if(ScreenON) if(ScreenON)
RENDER_LOG(vadr + 8); // RENDER_LOG(vadr + 8);
RENDER_LOGP(C + 8);
pshift[1] |= C[8]; pshift[1] |= C[8];
#endif #endif