CDLOGGER: CHR logging for the new PPU engine, TODO: doc update

This commit is contained in:
CaH4e3 2012-09-23 14:07:43 +00:00
parent e30c685c5e
commit a3e21f76cd
7 changed files with 133 additions and 45 deletions

View File

@ -364,7 +364,6 @@ int condition(watchpointinfo* wp)
volatile int codecount, datacount, undefinedcount;
unsigned char *cdloggerdata;
char *cdlogfilename;
static int indirectnext;
int debug_loggingCD;

View File

@ -43,6 +43,11 @@ void SaveStrippedRom(int invert);
extern iNES_HEADER head; //defined in ines.c
extern uint8 *trainerpoo;
//---------CDLogger VROM
extern volatile int rendercount, vromreadcount, undefinedvromcount;
extern unsigned char *cdloggervdata;
extern int newppu;
int CDLogger_wndx=0, CDLogger_wndy=0;
//extern uint8 *ROM;
@ -110,10 +115,13 @@ BOOL CALLBACK CDLoggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
if (CDLogger_wndy==-32000) CDLogger_wndy=0;
SetWindowPos(hwndDlg,0,CDLogger_wndx,CDLogger_wndy,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER);
hCDLogger = hwndDlg;
codecount = datacount = 0;
codecount = datacount = rendercount = vromreadcount = 0;
undefinedcount = PRGsize[0];
undefinedvromcount = CHRsize[0];
cdloggerdata = (unsigned char*)malloc(PRGsize[0]); //mbg merge 7/18/06 added cast
cdloggervdata = (unsigned char*)malloc(CHRsize[0]);
ZeroMemory(cdloggerdata,PRGsize[0]);
ZeroMemory(cdloggervdata,CHRsize[0]);
break;
case WM_CLOSE:
case WM_QUIT:
@ -126,7 +134,9 @@ MB_OK);
}
FCEUI_SetLoggingCD(0);
free(cdloggerdata);
free(cdloggervdata);
cdloggerdata=0;
cdloggervdata=0;
hCDLogger = 0;
EndDialog(hwndDlg,0);
break;
@ -135,9 +145,11 @@ MB_OK);
case BN_CLICKED:
switch(LOWORD(wParam)) {
case BTN_CDLOGGER_RESET:
codecount = datacount = 0;
codecount = datacount = rendercount = vromreadcount = 0;
undefinedcount = PRGsize[0];
undefinedvromcount = CHRsize[0];
ZeroMemory(cdloggerdata,PRGsize[0]);
ZeroMemory(cdloggervdata,CHRsize[0]);
UpdateCDLogger();
break;
case BTN_CDLOGGER_LOAD:
@ -157,6 +169,16 @@ MB_OK);
SetDlgItemText(hCDLogger, BTN_CDLOGGER_START_PAUSE, "Start");
}
else{
if(!newppu)
{
if(MessageBox(hCDLogger,
"In order for CHR data logging to take effect, the New PPU engine logger must also be enabled.\
Would you like to enable new PPU engine now?","Enable new PPU engine?",
MB_YESNO) == IDYES)
{
FCEU_TogglePPU();
}
}
FCEUI_SetLoggingCD(1);
EnableTracerMenuItems();
SetDlgItemText(hCDLogger, BTN_CDLOGGER_START_PAUSE, "Pause");
@ -190,14 +212,6 @@ void LoadCDLog (const char* nameo)
int i,j;
strcpy(loadedcdfile,nameo);
//FCEUD_PrintError(loadedcdfile);
//fseek(FP,0,SEEK_SET);
//codecount = datacount = 0;
//undefinedcount = PRGsize[0];
//cdloggerdata = malloc(PRGsize[0]);
FP = fopen(loadedcdfile,"rb");
if(FP == NULL){
@ -205,9 +219,6 @@ void LoadCDLog (const char* nameo)
return;
}
//codecount = datacount = 0;
//undefinedcount = PRGsize[0];
for(i = 0;i < (int)PRGsize[0];i++){
j = fgetc(FP);
if(j == EOF)break;
@ -216,6 +227,16 @@ void LoadCDLog (const char* nameo)
if((j & 3) && !(cdloggerdata[i] & 3))undefinedcount--; //the appropriate counter.
cdloggerdata[i] |= j;
}
for(i = 0;i < (int)CHRsize[0];i++){
j = fgetc(FP);
if(j == EOF)break;
if((j & 1) && !(cdloggervdata[i] & 1))rendercount++; //if the new byte has something logged and
if((j & 2) && !(cdloggervdata[i] & 2))vromreadcount++; //if the new byte has something logged and
if((j & 3) && !(cdloggervdata[i] & 3))undefinedvromcount--; //the appropriate counter.
cdloggervdata[i] |= j;
}
fclose(FP);
UpdateCDLogger();
return;
@ -285,6 +306,7 @@ void SaveCDLogFile(){ //todo make this button work before you've saved as
return;
}
fwrite(cdloggerdata,PRGsize[0],1,FP);
fwrite(cdloggervdata,CHRsize[0],1,FP);
fclose(FP);
return;
}
@ -315,8 +337,14 @@ void UpdateCDLogger(){
if(!hCDLogger)return;
char str[50];
float fcodecount = codecount, fdatacount = datacount,
fundefinedcount = undefinedcount, fromsize = PRGsize[0];
float fcodecount = codecount;
float fdatacount = datacount;
float frendercount = rendercount;
float fvromreadcount = vromreadcount;
float fundefinedcount = undefinedcount;
float fundefinedvromcount = undefinedvromcount;
float fromsize = PRGsize[0];
float fvromsize = CHRsize[0];
sprintf(str,"0x%06x %.2f%%",codecount,fcodecount/fromsize*100);
SetDlgItemText(hCDLogger,LBL_CDLOGGER_CODECOUNT,str);
@ -324,6 +352,13 @@ void UpdateCDLogger(){
SetDlgItemText(hCDLogger,LBL_CDLOGGER_DATACOUNT,str);
sprintf(str,"0x%06x %.2f%%",undefinedcount,fundefinedcount/fromsize*100);
SetDlgItemText(hCDLogger,LBL_CDLOGGER_UNDEFCOUNT,str);
sprintf(str,"0x%06x %.2f%%",rendercount,frendercount/fvromsize*100);
SetDlgItemText(hCDLogger,LBL_CDLOGGER_RENDERCOUNT,str);
sprintf(str,"0x%06x %.2f%%",vromreadcount,fvromreadcount/fvromsize*100);
SetDlgItemText(hCDLogger,LBL_CDLOGGER_VROMREADCOUNT,str);
sprintf(str,"0x%06x %.2f%%",undefinedvromcount,fundefinedvromcount/fvromsize*100);
SetDlgItemText(hCDLogger,LBL_CDLOGGER_UNDEFVROMCOUNT,str);
return;
}
@ -414,9 +449,15 @@ void SaveStrippedRom(int invert){ //this is based off of iNesSave()
pchar = invert?ROM[i]:0;
fputc(pchar, fp);
}
//fwrite(ROM,0x4000,head.ROM_size,fp);
if(head.VROM_size)fwrite(VROM,0x2000,head.VROM_size,fp);
for(i = 0;i < head.VROM_size*0x2000;i++){
unsigned char vchar;
if(cdloggervdata[i] & 1)
vchar = invert?0:VROM[i];
else
vchar = invert?VROM[i]:0;
fputc(vchar, fp);
}
}
fclose(fp);
}

View File

@ -12,7 +12,7 @@
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Íåéòðàëüíûé resources
// Neutral resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
@ -1563,31 +1563,37 @@ BEGIN
DEFPUSHBUTTON "&OK",IDOK,67,52,50,14
END
CDLOGGER DIALOGEX 0, 0, 315, 218
CDLOGGER DIALOGEX 0, 0, 315, 264
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Code Data Logger"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Load...",BTN_CDLOGGER_LOAD,7,81,50,14
PUSHBUTTON "Save",BTN_CDLOGGER_SAVE,257,81,50,14
GROUPBOX "Code Data Log Status",-1,3,4,308,131,BS_CENTER
PUSHBUTTON "Start",BTN_CDLOGGER_START_PAUSE,129,81,50,14
GROUPBOX "Address Label Logger",65534,3,136,308,79,BS_CENTER
DEFPUSHBUTTON "Load...",BTN_CDLOGGER_LOAD,7,105,50,14
PUSHBUTTON "Save",BTN_CDLOGGER_SAVE,257,105,50,14
GROUPBOX "Code/Data Log Status",-1,3,4,308,173,BS_CENTER
PUSHBUTTON "Start",BTN_CDLOGGER_START_PAUSE,129,105,50,14
GROUPBOX "Address Label Logger",65534,2,180,308,79,BS_CENTER
PUSHBUTTON "Load...",111,7,190,50,14,WS_DISABLED
PUSHBUTTON "Start",112,127,189,50,14,WS_DISABLED
PUSHBUTTON "Save...",113,256,189,50,14,WS_DISABLED
LTEXT "4067 - 29.5%",LBL_CDLOGGER_CODECOUNT,38,31,68,11
GROUPBOX "Bytes Logged As Code",65533,29,20,84,27
GROUPBOX "Bytes Logged as data",65532,117,20,84,27
GROUPBOX "PRG Logged as Code",65533,29,20,84,27
GROUPBOX "PRG Logged as Data",65532,117,20,84,27
LTEXT "7092 - 37.2%",LBL_CDLOGGER_DATACOUNT,128,31,65,9
GROUPBOX "Bytes Not Logged",65531,205,20,79,27
GROUPBOX "PRG not Logged",65531,205,20,79,27
LTEXT "6072 - 32.7%",LBL_CDLOGGER_UNDEFCOUNT,210,31,60,8
LTEXT "Itsa me the Code Data Logger! Press Start to play!",65530,69,56,172,12
PUSHBUTTON "Reset Log",BTN_CDLOGGER_RESET,7,66,50,14
PUSHBUTTON "Save as...",BTN_CDLOGGER_SAVE_AS,257,66,50,14
PUSHBUTTON "Save Stripped iNes Rom...",BTN_CDLOGGER_SAVE_STRIPPED,208,102,99,14
PUSHBUTTON "Save Unused Data...",BTN_CDLOGGER_SAVE_UNUSED,208,117,99,14
LTEXT "Itsa me the Code/Data Logger! Press Start to play!",65530,69,80,172,12
PUSHBUTTON "Reset Log",BTN_CDLOGGER_RESET,7,90,50,14
PUSHBUTTON "Save as...",BTN_CDLOGGER_SAVE_AS,257,90,50,14
PUSHBUTTON "Save Stripped iNes Rom...",BTN_CDLOGGER_SAVE_STRIPPED,208,126,99,14
PUSHBUTTON "Save Unused Data...",BTN_CDLOGGER_SAVE_UNUSED,208,141,99,14
LTEXT "4067 - 29.5%",LBL_CDLOGGER_RENDERCOUNT,37,60,68,11
GROUPBOX "CHR Rendered",-1,29,50,84,27
GROUPBOX "CHR Logged as Data",-1,117,50,84,27
LTEXT "7092 - 37.2%",LBL_CDLOGGER_VROMREADCOUNT,127,60,65,9
GROUPBOX "CHR not Logged",-1,205,50,79,27
LTEXT "6072 - 32.7%",LBL_CDLOGGER_UNDEFVROMCOUNT,209,60,60,8
END
PPUVIEW DIALOGEX 44, 38, 355, 246
@ -2073,7 +2079,7 @@ BEGIN
"CDLOGGER", DIALOG
BEGIN
BOTTOMMARGIN, 213
BOTTOMMARGIN, 259
END
"PPUVIEW", DIALOG
@ -2118,12 +2124,12 @@ BEGIN
END
#endif // APSTUDIO_INVOKED
#endif // Íåéòðàëüíûé resources
#endif // Neutral resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Àíãëèéñêèé (ÑØÀ) resources
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
@ -2357,7 +2363,7 @@ IDB_BITMAP_SELECTED17 BITMAP "res\\te_17_selected.bmp"
IDB_BITMAP_SELECTED18 BITMAP "res\\te_18_selected.bmp"
IDB_BITMAP_SELECTED19 BITMAP "res\\te_19_selected.bmp"
IDB_BRANCH_SPRITESHEET BITMAP "res\\branch_spritesheet.bmp"
#endif // Àíãëèéñêèé (ÑØÀ) resources
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////

View File

@ -119,6 +119,7 @@
#define IDC_CHECK_LOG_REGISTERS 110
#define IDC_DEBUGGER_BREAK_ON_BAD_OP 110
#define IDC_ROMPATCHER_BTN_APPLY 110
#define LBL_CDLOGGER_RENDERCOUNT 110
#define MENU_LOAD_STATE 111
#define CB_DISABLE_SCREEN_SAVER 111
#define BTN_FAM 111
@ -133,11 +134,13 @@
#define IDC_CHECK_LOG_NEW_INSTRUCTIONS 114
#define IDD_DIALOG1 114
#define IDC_DEBUGGER_RUN_LINE 114
#define LBL_CDLOGGER_VROMREADCOUNT 114
#define LBL_AUTO_HOLD 115
#define IDC_CHECK_LOG_NEW_DATA 115
#define IDD_DIALOG2 115
#define IDC_DEBUGGER_STEP_OUT3 115
#define IDC_DEBUGGER_RUN_FRAME2 115
#define LBL_CDLOGGER_UNDEFVROMCOUNT 115
#define LBL_CLEAR_AH 116
#define IDC_CHECK_LOG_UPDATE_WINDOW 116
#define IDC_DEBUGGER_RESET_CYCLES_COUNTER 116

View File

@ -343,7 +343,7 @@ void (*PPU_hook)(uint32 A);
uint8 vtoggle=0;
uint8 XOffset=0;
uint32 TempAddr=0,RefreshAddr=0;
uint32 TempAddr=0,RefreshAddr=0,DummyRead=0;
static int maxsprites=8;
@ -435,6 +435,17 @@ inline void FFCEUX_PPUWrite_Default(uint32 A, uint8 V) {
}
}
volatile int rendercount, vromreadcount, undefinedvromcount, LogAddress = -1;
unsigned char *cdloggervdata;
int GetCHRAddress(int A){
int result;
if((A > 0x1fff))return -1;
result = &VPage[A>>10][A]-CHRptr[0];
if((result > (int)CHRsize[0]) || (result < 0))return -1;
else return result;
}
uint8 FASTCALL FFCEUX_PPURead_Default(uint32 A) {
uint32 tmp = A;
@ -442,6 +453,19 @@ uint8 FASTCALL FFCEUX_PPURead_Default(uint32 A) {
if(tmp<0x2000)
{
if(debug_loggingCD)
{
int addr = GetCHRAddress(tmp);
if(addr != -1)
{
if(!(cdloggervdata[addr] & 1))
{
cdloggervdata[addr] |= 1;
if(!(cdloggervdata[addr] & 2))undefinedvromcount--;
rendercount++;
}
}
}
return VPage[tmp>>10][tmp];
}
else if (tmp < 0x3F00)
@ -743,6 +767,21 @@ static DECLFR(A2007)
uint8 ret;
uint32 tmp=RefreshAddr&0x3FFF;
if(debug_loggingCD)
{
if(!DummyRead && (LogAddress != -1))
{
if(!(cdloggervdata[LogAddress] & 2))
{
cdloggervdata[LogAddress] |= 2;
if(!(cdloggervdata[LogAddress] & 1))undefinedvromcount--;
vromreadcount++;
}
}
else
DummyRead = 0;
}
if(newppu) {
ret = VRAMBuffer;
RefreshAddr = ppur.get_2007access() & 0x3FFF;
@ -766,8 +805,11 @@ static DECLFR(A2007)
ret &= 0x30;
VRAMBuffer = CALL_PPUREAD(RefreshAddr - 0x1000);
}
else
else {
if(debug_loggingCD)
LogAddress = GetCHRAddress(RefreshAddr);
VRAMBuffer = CALL_PPUREAD(RefreshAddr);
}
ppur.increment2007(INC32!=0);
RefreshAddr = ppur.get_2007access();
return ret;
@ -784,6 +826,8 @@ static DECLFR(A2007)
PPUGenLatch=VRAMBuffer;
if(tmp<0x2000)
{
if(debug_loggingCD)
LogAddress = GetCHRAddress(tmp);
VRAMBuffer=VPage[tmp>>10][tmp];
}
else if (tmp < 0x3F00)
@ -949,6 +993,7 @@ static DECLFW(B2006)
TempAddr|=V;
RefreshAddr=TempAddr;
DummyRead=1;
if(PPU_hook)
PPU_hook(RefreshAddr);
//printf("%d, %04x\n",scanline,RefreshAddr);

View File

@ -3,11 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fceux", "vc10_fceux.vcxproj", "{6893EF44-FEA3-46DF-B236-C4C200F54294}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F8647A59-ED57-4975-B40C-054BA8588E4E}"
ProjectSection(SolutionItems) = preProject
Performance1.psess = Performance1.psess
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32

View File

@ -1001,7 +1001,6 @@
<None Include="..\src\drivers\win\res\te_piano_9_lostpos.bmp" />
<None Include="..\src\drivers\win\res\te_piano_9_playback.bmp" />
<None Include="..\src\pputile.inc" />
<None Include="ClassDiagram1.cd" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">