diff --git a/source/CPU/cpu65d02.h b/source/CPU/cpu65d02.h index d9ea6595..60a239df 100644 --- a/source/CPU/cpu65d02.h +++ b/source/CPU/cpu65d02.h @@ -41,11 +41,23 @@ inline u8 DecClamp8( u8 x ) // 1 B Exec // 2 G Read // 3 R Write -// RGBA r= write, g = read, b = pc -int g_aMemoryAccess[ 65536 ]; // TODO: Change to int32_t -u8 *g_pRead = 0; -u8 *g_pWrite = 0; -u8 *g_pExec = 0; +// RGBA r = write, g = read, b = Program Counter +const int HEATMAP_W_MASK = 0x00FF0000; // Red Store +const int HEATMAP_R_MASK = 0x0000FF00; // Green Load +const int HEATMAP_X_MASK = 0x000000FF; // Blue Exec + + +// This is a memory heatmap +// FF = accessed on this clock cycle +// FE = accessed 1 clock cycles ago +// FD = accessed 2 clock cycles ago +// etc. +// Displayed as 256x256 64K memory access +int g_aMemoryHeatmap[ 65536 ]; // TODO: Change to int32_t + +#define HEATMAP_W(addr) g_aMemoryHeatmap[ addr ] |= HEATMAP_W_MASK +#define HEATMAP_R(addr) g_aMemoryHeatmap[ addr ] |= HEATMAP_R_MASK +#define HEATMAP_X(addr) g_aMemoryHeatmap[ addr ] |= HEATMAP_X_MASK #undef READ #define READ ReadByte( addr, uExecutedCycles ) @@ -53,8 +65,7 @@ u8 *g_pExec = 0; inline u8 ReadByte( u16 addr, int uExecutedCycles ) { // TODO: We should have a single g_bDebuggerActive so we can have a single implementation across ][+ //e - (u8*) g_pRead = ((u8*)g_aMemoryAccess) + (addr * 4) + 3; - *g_pRead = IncClamp8( *g_pRead ); + HEATMAP_R(addr); return ( \ @@ -66,8 +77,7 @@ inline u8 ReadByte( u16 addr, int uExecutedCycles ) #undef WRITE #define WRITE(a) \ - (u8*) g_pWrite = ((u8*)g_aMemoryAccess) + (addr * 4) + 0; \ - *g_pWrite = DecClamp8( *g_pWrite ); \ + HEATMAP_W(addr); \ { \ memdirty[addr >> 8] = 0xFF; \ LPBYTE page = memwrite[addr >> 8]; \ @@ -112,6 +122,8 @@ static DWORD Cpu65D02 (DWORD uTotalCycles) } else + HEATMAP_X( regs.pc ); + if (!Fetch(iOpcode, uExecutedCycles)) break;