From c50535a398fda2560e09594b2936ab10b7fa6655 Mon Sep 17 00:00:00 2001 From: CaH4e3 Date: Sun, 20 Dec 2015 16:22:46 +0000 Subject: [PATCH] implemented visual CHR data usage logging for VRAM-only games (mapper 2, etc). no cdl log save available, just display current used/unused tiles in ppu tile viewer. reset tile usage flags if rewritten by the program. --- trunk/src/boards/datalatch.cpp | 2 +- trunk/src/drivers/win/cdlogger.cpp | 10 +++++++--- trunk/src/drivers/win/ppuview.cpp | 6 +++--- trunk/src/ppu.cpp | 10 +++++++++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/trunk/src/boards/datalatch.cpp b/trunk/src/boards/datalatch.cpp index ec9a73ed..342ef5bd 100644 --- a/trunk/src/boards/datalatch.cpp +++ b/trunk/src/boards/datalatch.cpp @@ -93,7 +93,7 @@ static DECLFW(NROMWrite) { static void NROMPower(void) { setprg8r(0x10, 0x6000, 0); // Famili BASIC (v3.0) need it (uses only 4KB), FP-BASIC uses 8KB - setprg16(0x8000, 0); + setprg16(0x8000, ~1); setprg16(0xC000, ~0); setchr8(0); diff --git a/trunk/src/drivers/win/cdlogger.cpp b/trunk/src/drivers/win/cdlogger.cpp index cff4a75e..4529e676 100644 --- a/trunk/src/drivers/win/cdlogger.cpp +++ b/trunk/src/drivers/win/cdlogger.cpp @@ -572,8 +572,10 @@ void InitCDLog() if(!CHRram[0] || (CHRptr[0] == PRGptr[0])) { // Some kind of workaround for my OneBus VRAM hack, will remove it if I find another solution for that cdloggerVideoDataSize = CHRsize[0]; cdloggervdata = (unsigned char*)malloc(cdloggerVideoDataSize); - } else + } else { cdloggerVideoDataSize = 0; + cdloggervdata = (unsigned char*)malloc(8192); + } } void ResetCDLog() @@ -581,10 +583,12 @@ void ResetCDLog() codecount = datacount = rendercount = vromreadcount = 0; undefinedcount = cdloggerdataSize; ZeroMemory(cdloggerdata, cdloggerdataSize); - if(cdloggerVideoDataSize != 0) - { + if(cdloggerVideoDataSize != 0) { undefinedvromcount = cdloggerVideoDataSize; ZeroMemory(cdloggervdata, cdloggerVideoDataSize); + } else { + undefinedvromcount = 8192; + ZeroMemory(cdloggervdata, 8192); } } diff --git a/trunk/src/drivers/win/ppuview.cpp b/trunk/src/drivers/win/ppuview.cpp index ed308e70..8d220ad5 100644 --- a/trunk/src/drivers/win/ppuview.cpp +++ b/trunk/src/drivers/win/ppuview.cpp @@ -117,7 +117,7 @@ void DrawPatternTable(uint8 *bitmap, uint8 *table, uint8 *log, uint8 pal) chr1 = table[index + 8]; logs = log[index] & log[index + 8]; tmp = 7; - shift=(PPUView_maskUnusedGraphics && cdloggerVideoDataSize && (((logs & 3) != 0) == PPUView_invertTheMask))?3:0; + shift=(PPUView_maskUnusedGraphics /*&& cdloggerVideoDataSize*/ && (((logs & 3) != 0) == PPUView_invertTheMask))?3:0; for (x = 0; x < 8; x++) { p = (chr0 >> tmp) & 1; @@ -168,8 +168,8 @@ void FCEUD_UpdatePPUView(int scanline, int refreshchr) logcache1[i] = cdloggervdata[addr]; } else { - logcache0[i] = 0; - logcache1[i] = 0; + logcache0[i] = cdloggervdata[i]; + logcache1[i] = cdloggervdata[x]; } } } diff --git a/trunk/src/ppu.cpp b/trunk/src/ppu.cpp index a615ce7d..6522f8d3 100644 --- a/trunk/src/ppu.cpp +++ b/trunk/src/ppu.cpp @@ -431,7 +431,8 @@ int GetCHRAddress(int A) { int result = &VPage[A >> 10][A] - CHRptr[0]; if ((result >= 0) && (result < (int)cdloggerVideoDataSize)) return result; - } + } else + if(A < 0x2000) return A; return -1; } @@ -886,6 +887,13 @@ static DECLFW(B2006) { static DECLFW(B2007) { uint32 tmp = RefreshAddr & 0x3FFF; + if (debug_loggingCD) { + if(tmp < 0x2000) { + cdloggervdata[tmp] = 0; + undefinedvromcount++; + } + } + if (newppu) { PPUGenLatch = V; RefreshAddr = ppur.get_2007access() & 0x3FFF;