From 79dcb510733d72a31e4976f2a0ef57cd749f72b6 Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Sun, 21 Feb 2021 18:32:30 -0500 Subject: [PATCH] Auto Format of Qt code data and trace logger. Fix spaces/tabs code readability. --- src/drivers/Qt/CodeDataLogger.cpp | 470 ++++---- src/drivers/Qt/CodeDataLogger.h | 76 +- src/drivers/Qt/TraceLogger.cpp | 1675 +++++++++++++++-------------- src/drivers/Qt/TraceLogger.h | 277 ++--- 4 files changed, 1275 insertions(+), 1223 deletions(-) diff --git a/src/drivers/Qt/CodeDataLogger.cpp b/src/drivers/Qt/CodeDataLogger.cpp index 4b2b09be..77bccd95 100644 --- a/src/drivers/Qt/CodeDataLogger.cpp +++ b/src/drivers/Qt/CodeDataLogger.cpp @@ -41,15 +41,15 @@ #include "Qt/config.h" #include "Qt/fceuWrapper.h" -static int autoSaveCDL = true; -static int autoLoadCDL = true; -static int autoResumeCDL = false; +static int autoSaveCDL = true; +static int autoLoadCDL = true; +static int autoResumeCDL = false; static char loadedcdfile[512] = {0}; -static int getDefaultCDLFile( char *filepath ); +static int getDefaultCDLFile(char *filepath); //---------------------------------------------------- CodeDataLoggerDialog_t::CodeDataLoggerDialog_t(QWidget *parent) - : QDialog( parent, Qt::Window ) + : QDialog(parent, Qt::Window) { QVBoxLayout *mainLayout, *vbox1, *vbox; QHBoxLayout *hbox; @@ -57,170 +57,170 @@ CodeDataLoggerDialog_t::CodeDataLoggerDialog_t(QWidget *parent) QGroupBox *frame, *subframe; QPushButton *btn; - updateTimer = new QTimer( this ); + updateTimer = new QTimer(this); - connect( updateTimer, &QTimer::timeout, this, &CodeDataLoggerDialog_t::updatePeriodic ); + connect(updateTimer, &QTimer::timeout, this, &CodeDataLoggerDialog_t::updatePeriodic); - setWindowTitle( tr("Code Data Logger") ); + setWindowTitle(tr("Code Data Logger")); - mainLayout = new QVBoxLayout(); - vbox1 = new QVBoxLayout(); - hbox = new QHBoxLayout(); - grid = new QGridLayout(); - statLabel = new QLabel( tr(" Logger is Paused: Press Start to Run ") ); - cdlFileLabel = new QLabel( tr("CDL File:") ); + mainLayout = new QVBoxLayout(); + vbox1 = new QVBoxLayout(); + hbox = new QHBoxLayout(); + grid = new QGridLayout(); + statLabel = new QLabel(tr(" Logger is Paused: Press Start to Run ")); + cdlFileLabel = new QLabel(tr("CDL File:")); - vbox1->addLayout( grid ); - vbox1->addLayout( hbox ); - vbox1->addWidget( cdlFileLabel ); + vbox1->addLayout(grid); + vbox1->addLayout(hbox); + vbox1->addWidget(cdlFileLabel); - hbox->addWidget( statLabel, 0, Qt::AlignHCenter ); + hbox->addWidget(statLabel, 0, Qt::AlignHCenter); frame = new QGroupBox(tr("Code/Data Log Status")); - frame->setLayout( vbox1 ); + frame->setLayout(vbox1); - prgLoggedCodeLabel = new QLabel( tr("0x000000 0.00%") ); - prgLoggedDataLabel = new QLabel( tr("0x000000 0.00%") ); - prgUnloggedLabel = new QLabel( tr("0x000000 0.00%") ); - chrLoggedCodeLabel = new QLabel( tr("0x000000 0.00%") ); - chrLoggedDataLabel = new QLabel( tr("0x000000 0.00%") ); - chrUnloggedLabel = new QLabel( tr("0x000000 0.00%") ); - autoSaveCdlCbox = new QCheckBox( tr("Auto-save .CDL when closing ROMs") ); - autoLoadCdlCbox = new QCheckBox( tr("Auto-load .CDL when opening this window") ); - autoResumeLogCbox = new QCheckBox( tr("Auto-resume logging when loading ROMs") ); + prgLoggedCodeLabel = new QLabel(tr("0x000000 0.00%")); + prgLoggedDataLabel = new QLabel(tr("0x000000 0.00%")); + prgUnloggedLabel = new QLabel(tr("0x000000 0.00%")); + chrLoggedCodeLabel = new QLabel(tr("0x000000 0.00%")); + chrLoggedDataLabel = new QLabel(tr("0x000000 0.00%")); + chrUnloggedLabel = new QLabel(tr("0x000000 0.00%")); + autoSaveCdlCbox = new QCheckBox(tr("Auto-save .CDL when closing ROMs")); + autoLoadCdlCbox = new QCheckBox(tr("Auto-load .CDL when opening this window")); + autoResumeLogCbox = new QCheckBox(tr("Auto-resume logging when loading ROMs")); g_config->getOption("SDL.AutoSaveCDL", &autoSaveCDL); g_config->getOption("SDL.AutoLoadCDL", &autoLoadCDL); g_config->getOption("SDL.AutoResumeCDL", &autoResumeCDL); - autoSaveCdlCbox->setChecked( autoSaveCDL ); - autoLoadCdlCbox->setChecked( autoLoadCDL ); - autoResumeLogCbox->setChecked( autoResumeCDL ); + autoSaveCdlCbox->setChecked(autoSaveCDL); + autoLoadCdlCbox->setChecked(autoLoadCDL); + autoResumeLogCbox->setChecked(autoResumeCDL); - connect(autoSaveCdlCbox , SIGNAL(stateChanged(int)), this, SLOT(autoSaveCdlStateChange(int)) ); - connect(autoLoadCdlCbox , SIGNAL(stateChanged(int)), this, SLOT(autoLoadCdlStateChange(int)) ); - connect(autoResumeLogCbox, SIGNAL(stateChanged(int)), this, SLOT(autoResumeCdlStateChange(int)) ); + connect(autoSaveCdlCbox, SIGNAL(stateChanged(int)), this, SLOT(autoSaveCdlStateChange(int))); + connect(autoLoadCdlCbox, SIGNAL(stateChanged(int)), this, SLOT(autoLoadCdlStateChange(int))); + connect(autoResumeLogCbox, SIGNAL(stateChanged(int)), this, SLOT(autoResumeCdlStateChange(int))); subframe = new QGroupBox(tr("PRG Logged as Code")); - vbox = new QVBoxLayout(); - vbox->addWidget( prgLoggedCodeLabel ); - subframe->setLayout( vbox ); + vbox = new QVBoxLayout(); + vbox->addWidget(prgLoggedCodeLabel); + subframe->setLayout(vbox); - grid->addWidget( subframe, 0, 0, Qt::AlignCenter ); + grid->addWidget(subframe, 0, 0, Qt::AlignCenter); subframe = new QGroupBox(tr("PRG Logged as Data")); - vbox = new QVBoxLayout(); - vbox->addWidget( prgLoggedDataLabel ); - subframe->setLayout( vbox ); + vbox = new QVBoxLayout(); + vbox->addWidget(prgLoggedDataLabel); + subframe->setLayout(vbox); - grid->addWidget( subframe, 0, 1, Qt::AlignCenter ); + grid->addWidget(subframe, 0, 1, Qt::AlignCenter); subframe = new QGroupBox(tr("PRG not Logged")); - vbox = new QVBoxLayout(); - vbox->addWidget( prgUnloggedLabel ); - subframe->setLayout( vbox ); + vbox = new QVBoxLayout(); + vbox->addWidget(prgUnloggedLabel); + subframe->setLayout(vbox); - grid->addWidget( subframe, 0, 2, Qt::AlignCenter ); + grid->addWidget(subframe, 0, 2, Qt::AlignCenter); subframe = new QGroupBox(tr("CHR Logged as Code")); - vbox = new QVBoxLayout(); - vbox->addWidget( chrLoggedCodeLabel ); - subframe->setLayout( vbox ); + vbox = new QVBoxLayout(); + vbox->addWidget(chrLoggedCodeLabel); + subframe->setLayout(vbox); - grid->addWidget( subframe, 1, 0, Qt::AlignCenter ); + grid->addWidget(subframe, 1, 0, Qt::AlignCenter); subframe = new QGroupBox(tr("CHR Logged as Data")); - vbox = new QVBoxLayout(); - vbox->addWidget( chrLoggedDataLabel ); - subframe->setLayout( vbox ); + vbox = new QVBoxLayout(); + vbox->addWidget(chrLoggedDataLabel); + subframe->setLayout(vbox); - grid->addWidget( subframe, 1, 1, Qt::AlignCenter ); + grid->addWidget(subframe, 1, 1, Qt::AlignCenter); subframe = new QGroupBox(tr("CHR not Logged")); - vbox = new QVBoxLayout(); - vbox->addWidget( chrUnloggedLabel ); - subframe->setLayout( vbox ); + vbox = new QVBoxLayout(); + vbox->addWidget(chrUnloggedLabel); + subframe->setLayout(vbox); - grid->addWidget( subframe, 1, 2, Qt::AlignCenter ); + grid->addWidget(subframe, 1, 2, Qt::AlignCenter); grid = new QGridLayout(); - vbox1->addLayout( grid ); - btn = new QPushButton( tr("Reset Log") ); - grid->addWidget( btn, 0, 0, Qt::AlignCenter ); - connect( btn, SIGNAL(clicked(void)), this, SLOT(ResetCDLogClicked(void))); + vbox1->addLayout(grid); + btn = new QPushButton(tr("Reset Log")); + grid->addWidget(btn, 0, 0, Qt::AlignCenter); + connect(btn, SIGNAL(clicked(void)), this, SLOT(ResetCDLogClicked(void))); - startPauseButton = new QPushButton( tr("Start") ); - grid->addWidget( startPauseButton, 0, 1, Qt::AlignCenter ); - connect( startPauseButton, SIGNAL(clicked(void)), this, SLOT(StartPauseCDLogClicked(void))); + startPauseButton = new QPushButton(tr("Start")); + grid->addWidget(startPauseButton, 0, 1, Qt::AlignCenter); + connect(startPauseButton, SIGNAL(clicked(void)), this, SLOT(StartPauseCDLogClicked(void))); - btn = new QPushButton( tr("Save") ); - grid->addWidget( btn, 0, 2, Qt::AlignCenter ); - connect( btn, SIGNAL(clicked(void)), this, SLOT(saveCdlFile(void))); + btn = new QPushButton(tr("Save")); + grid->addWidget(btn, 0, 2, Qt::AlignCenter); + connect(btn, SIGNAL(clicked(void)), this, SLOT(saveCdlFile(void))); - btn = new QPushButton( tr("Load") ); - grid->addWidget( btn, 1, 0, Qt::AlignCenter ); - connect( btn, SIGNAL(clicked(void)), this, SLOT(loadCdlFile(void))); + btn = new QPushButton(tr("Load")); + grid->addWidget(btn, 1, 0, Qt::AlignCenter); + connect(btn, SIGNAL(clicked(void)), this, SLOT(loadCdlFile(void))); - btn = new QPushButton( tr("Save As") ); - grid->addWidget( btn, 1, 2, Qt::AlignCenter ); - connect( btn, SIGNAL(clicked(void)), this, SLOT(saveCdlFileAs(void))); + btn = new QPushButton(tr("Save As")); + grid->addWidget(btn, 1, 2, Qt::AlignCenter); + connect(btn, SIGNAL(clicked(void)), this, SLOT(saveCdlFileAs(void))); hbox = new QHBoxLayout(); - vbox1->addLayout( hbox ); + vbox1->addLayout(hbox); subframe = new QGroupBox(tr("Logging Workflow Options")); - vbox = new QVBoxLayout(); - vbox->addWidget( autoSaveCdlCbox ); - vbox->addWidget( autoLoadCdlCbox ); - vbox->addWidget( autoResumeLogCbox ); - subframe->setLayout( vbox ); - hbox->addWidget( subframe ); + vbox = new QVBoxLayout(); + vbox->addWidget(autoSaveCdlCbox); + vbox->addWidget(autoLoadCdlCbox); + vbox->addWidget(autoResumeLogCbox); + subframe->setLayout(vbox); + hbox->addWidget(subframe); subframe = new QGroupBox(tr("Generate ROM")); - vbox = new QVBoxLayout(); + vbox = new QVBoxLayout(); - btn = new QPushButton( tr("Save Stripped Data") ); - vbox->addWidget( btn ); - connect( btn, SIGNAL(clicked(void)), this, SLOT(SaveStrippedROMClicked(void))); - btn = new QPushButton( tr("Save Unused Data") ); - vbox->addWidget( btn ); - connect( btn, SIGNAL(clicked(void)), this, SLOT(SaveUnusedROMClicked(void))); - subframe->setLayout( vbox ); - hbox->addWidget( subframe ); + btn = new QPushButton(tr("Save Stripped Data")); + vbox->addWidget(btn); + connect(btn, SIGNAL(clicked(void)), this, SLOT(SaveStrippedROMClicked(void))); + btn = new QPushButton(tr("Save Unused Data")); + vbox->addWidget(btn); + connect(btn, SIGNAL(clicked(void)), this, SLOT(SaveUnusedROMClicked(void))); + subframe->setLayout(vbox); + hbox->addWidget(subframe); - mainLayout->addWidget( frame ); + mainLayout->addWidget(frame); - setLayout( mainLayout ); + setLayout(mainLayout); - updateTimer->start( 200 ); // 5hz + updateTimer->start(200); // 5hz if (autoLoadCDL) { char nameo[2048]; - getDefaultCDLFile( nameo ); + getDefaultCDLFile(nameo); LoadCDLog(nameo); } } //---------------------------------------------------- CodeDataLoggerDialog_t::~CodeDataLoggerDialog_t(void) { - updateTimer->stop(); + updateTimer->stop(); printf("Code Data Logger Window Deleted\n"); } //---------------------------------------------------- void CodeDataLoggerDialog_t::closeEvent(QCloseEvent *event) { - printf("Code Data Logger Close Window Event\n"); - done(0); + printf("Code Data Logger Close Window Event\n"); + done(0); deleteLater(); - event->accept(); + event->accept(); } //---------------------------------------------------- void CodeDataLoggerDialog_t::closeWindow(void) { - printf("Code Data Logger Close Window\n"); - done(0); + printf("Code Data Logger Close Window\n"); + done(0); deleteLater(); } //---------------------------------------------------- @@ -257,52 +257,52 @@ void CodeDataLoggerDialog_t::updatePeriodic(void) float fromsize = cdloggerdataSize; float fvromsize = (cdloggerVideoDataSize != 0) ? cdloggerVideoDataSize : 1; - if ( FCEUI_GetLoggingCD() ) + if (FCEUI_GetLoggingCD()) { - startPauseButton->setText( tr("Pause") ); - statLabel->setText( tr(" Logger is Running: Press Pause to Stop ") ); + startPauseButton->setText(tr("Pause")); + statLabel->setText(tr(" Logger is Running: Press Pause to Stop ")); statLabel->setStyleSheet("background-color: green; color: white;"); } else { - startPauseButton->setText( tr("Start") ); - statLabel->setText( tr(" Logger is Paused: Press Start to Run ") ); + startPauseButton->setText(tr("Start")); + statLabel->setText(tr(" Logger is Paused: Press Start to Run ")); statLabel->setStyleSheet("background-color: red; color: white;"); } - if ( cdloggerdataSize > 0 ) + if (cdloggerdataSize > 0) { - sprintf(str,"0x%06x %.2f%%", codecount, (fcodecount / fromsize) * 100); - prgLoggedCodeLabel->setText( tr(str) ); + sprintf(str, "0x%06x %.2f%%", codecount, (fcodecount / fromsize) * 100); + prgLoggedCodeLabel->setText(tr(str)); - sprintf(str,"0x%06x %.2f%%", datacount,(fdatacount / fromsize) * 100); - prgLoggedDataLabel->setText( tr(str) ); + sprintf(str, "0x%06x %.2f%%", datacount, (fdatacount / fromsize) * 100); + prgLoggedDataLabel->setText(tr(str)); - sprintf(str,"0x%06x %.2f%%", undefinedcount, (fundefinedcount / fromsize) * 100); - prgUnloggedLabel->setText( tr(str) ); + sprintf(str, "0x%06x %.2f%%", undefinedcount, (fundefinedcount / fromsize) * 100); + prgUnloggedLabel->setText(tr(str)); - sprintf(str,"0x%06x %.2f%%", rendercount, (frendercount / fvromsize) * 100); - chrLoggedCodeLabel->setText( tr(str) ); + sprintf(str, "0x%06x %.2f%%", rendercount, (frendercount / fvromsize) * 100); + chrLoggedCodeLabel->setText(tr(str)); - sprintf(str,"0x%06x %.2f%%", vromreadcount, (fvromreadcount / fvromsize) * 100); - chrLoggedDataLabel->setText( tr(str) ); + sprintf(str, "0x%06x %.2f%%", vromreadcount, (fvromreadcount / fvromsize) * 100); + chrLoggedDataLabel->setText(tr(str)); - sprintf(str,"0x%06x %.2f%%", undefinedvromcount, (fundefinedvromcount / fvromsize) * 100); - chrUnloggedLabel->setText( tr(str) ); + sprintf(str, "0x%06x %.2f%%", undefinedvromcount, (fundefinedvromcount / fvromsize) * 100); + chrUnloggedLabel->setText(tr(str)); } else { - prgLoggedCodeLabel->setText( tr("------") ); - prgLoggedDataLabel->setText( tr("------") ); - prgUnloggedLabel->setText( tr("------") ); - chrLoggedCodeLabel->setText( tr("------") ); - chrLoggedDataLabel->setText( tr("------") ); - chrUnloggedLabel->setText( tr("------") ); + prgLoggedCodeLabel->setText(tr("------")); + prgLoggedDataLabel->setText(tr("------")); + prgUnloggedLabel->setText(tr("------")); + chrLoggedCodeLabel->setText(tr("------")); + chrLoggedDataLabel->setText(tr("------")); + chrUnloggedLabel->setText(tr("------")); } - sprintf( str, "CDL File: %s", loadedcdfile ); + sprintf(str, "CDL File: %s", loadedcdfile); - cdlFileLabel->setText( tr(str) ); + cdlFileLabel->setText(tr(str)); } //---------------------------------------------------- void CodeDataLoggerDialog_t::ResetCDLogClicked(void) @@ -312,17 +312,17 @@ void CodeDataLoggerDialog_t::ResetCDLogClicked(void) //---------------------------------------------------- void CodeDataLoggerDialog_t::StartPauseCDLogClicked(void) { - if ( FCEUI_GetLoggingCD() ) + if (FCEUI_GetLoggingCD()) { //printf("CD Logging Paused\n"); PauseCDLogging(); - startPauseButton->setText( tr("Start") ); + startPauseButton->setText(tr("Start")); } else { //printf("CD Logging Started\n"); StartCDLogging(); - startPauseButton->setText( tr("Pause") ); + startPauseButton->setText(tr("Pause")); } } //---------------------------------------------------- @@ -336,58 +336,58 @@ void CodeDataLoggerDialog_t::saveCdlFileAs(void) int ret, useNativeFileDialogVal; QString filename; const char *romFile; - QFileDialog dialog(this, tr("Save CDL To File") ); + QFileDialog dialog(this, tr("Save CDL To File")); dialog.setFileMode(QFileDialog::AnyFile); dialog.setNameFilter(tr("CDL Files (*.cdl *.CDL) ;; All files (*)")); dialog.setViewMode(QFileDialog::List); - dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden ); - dialog.setLabelText( QFileDialog::Accept, tr("Save") ); - dialog.setDefaultSuffix( tr(".cdl") ); + dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden); + dialog.setLabelText(QFileDialog::Accept, tr("Save")); + dialog.setDefaultSuffix(tr(".cdl")); romFile = getRomFile(); - if ( romFile != NULL ) + if (romFile != NULL) { char dir[512], base[256]; - parseFilepath( romFile, dir, base ); + parseFilepath(romFile, dir, base); - strcat( base, ".cdl"); + strcat(base, ".cdl"); - dialog.setDirectory( tr(dir) ); + dialog.setDirectory(tr(dir)); - dialog.selectFile( tr(base) ); + dialog.selectFile(tr(base)); } // Check config option to use native file dialog or not - g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal); + g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal); dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal); ret = dialog.exec(); - if ( ret ) + if (ret) { QStringList fileList; fileList = dialog.selectedFiles(); - if ( fileList.size() > 0 ) + if (fileList.size() > 0) { filename = fileList[0]; } } - if ( filename.isNull() ) - { - return; - } + if (filename.isNull()) + { + return; + } //qDebug() << "selected file path : " << filename.toUtf8(); fceuWrapperLock(); - strcpy( loadedcdfile, filename.toStdString().c_str() ); + strcpy(loadedcdfile, filename.toStdString().c_str()); SaveCDLogFile(); fceuWrapperUnLock(); } @@ -398,54 +398,54 @@ void CodeDataLoggerDialog_t::loadCdlFile(void) QString filename; char dir[512]; const char *romFile; - QFileDialog dialog(this, tr("Load CDL File") ); + QFileDialog dialog(this, tr("Load CDL File")); dialog.setFileMode(QFileDialog::ExistingFile); dialog.setNameFilter(tr("CDL files (*.cdl *.CDL) ;; All files (*)")); dialog.setViewMode(QFileDialog::List); - dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden ); - dialog.setLabelText( QFileDialog::Accept, tr("Load") ); + dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden); + dialog.setLabelText(QFileDialog::Accept, tr("Load")); romFile = getRomFile(); - if ( romFile ) + if (romFile) { - getDirFromFile( romFile, dir ); + getDirFromFile(romFile, dir); - dialog.setDirectory( tr(dir) ); + dialog.setDirectory(tr(dir)); } // Check config option to use native file dialog or not - g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal); + g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal); dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal); ret = dialog.exec(); - if ( ret ) + if (ret) { QStringList fileList; fileList = dialog.selectedFiles(); - if ( fileList.size() > 0 ) + if (fileList.size() > 0) { filename = fileList[0]; } } - if ( filename.isNull() ) - { - return; - } + if (filename.isNull()) + { + return; + } //qDebug() << "selected file path : " << filename.toUtf8(); fceuWrapperLock(); - LoadCDLog ( filename.toStdString().c_str() ); + LoadCDLog(filename.toStdString().c_str()); fceuWrapperUnLock(); - return; + return; } //---------------------------------------------------- void CodeDataLoggerDialog_t::SaveStrippedROM(int invert) @@ -457,7 +457,7 @@ void CodeDataLoggerDialog_t::SaveStrippedROM(int invert) if (!GameInfo) return; - if (GameInfo->type==GIT_NSF) + if (GameInfo->type == GIT_NSF) { printf("Sorry, you're not allowed to save optimized NSFs yet. Please don't optimize individual banks, as there are still some issues with several NSFs to be fixed, and it is easier to fix those issues with as much of the bank data intact as possible."); return; @@ -472,67 +472,67 @@ void CodeDataLoggerDialog_t::SaveStrippedROM(int invert) int i, ret, useNativeFileDialogVal; QString filename; const char *romFile; - QFileDialog dialog(this, tr("Save Stripped File As...") ); + QFileDialog dialog(this, tr("Save Stripped File As...")); dialog.setFileMode(QFileDialog::AnyFile); - if (GameInfo->type==GIT_NSF) + if (GameInfo->type == GIT_NSF) { dialog.setNameFilter(tr("NSF Files (*.nsf *.NSF) ;; All files (*)")); - dialog.setDefaultSuffix( tr(".nsf") ); - } + dialog.setDefaultSuffix(tr(".nsf")); + } else - { + { dialog.setNameFilter(tr("NES Files (*.nes *.NES) ;; All files (*)")); - dialog.setDefaultSuffix( tr(".nes") ); + dialog.setDefaultSuffix(tr(".nes")); } dialog.setViewMode(QFileDialog::List); - dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden ); - dialog.setLabelText( QFileDialog::Accept, tr("Save") ); + dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden); + dialog.setLabelText(QFileDialog::Accept, tr("Save")); romFile = getRomFile(); - if ( romFile != NULL ) + if (romFile != NULL) { char dir[512], base[256]; - parseFilepath( romFile, dir, base ); + parseFilepath(romFile, dir, base); - dialog.setDirectory( tr(dir) ); + dialog.setDirectory(tr(dir)); } // Check config option to use native file dialog or not - g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal); + g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal); dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal); ret = dialog.exec(); - if ( ret ) + if (ret) { QStringList fileList; fileList = dialog.selectedFiles(); - if ( fileList.size() > 0 ) + if (fileList.size() > 0) { filename = fileList[0]; } } - if ( filename.isNull() ) - { - return; - } + if (filename.isNull()) + { + return; + } //qDebug() << "selected file path : " << filename.toUtf8(); - FILE *fp = fopen( filename.toStdString().c_str(),"wb"); - if (!fp) + FILE *fp = fopen(filename.toStdString().c_str(), "wb"); + if (!fp) { FCEUD_PrintError("Error opening target stripped rom file!"); return; } - if (GameInfo->type==GIT_NSF) + if (GameInfo->type == GIT_NSF) { uint8 NSFLoadLow; uint8 NSFLoadHigh; @@ -545,26 +545,26 @@ void CodeDataLoggerDialog_t::SaveStrippedROM(int invert) //Simple store/restore for writing a working NSF header NSFLoadLow = NSFHeader.LoadAddressLow; NSFLoadHigh = NSFHeader.LoadAddressHigh; - NSFHeader.LoadAddressLow=0; - NSFHeader.LoadAddressHigh&=0xF0; - fwrite(&NSFHeader,1,0x8,fp); + NSFHeader.LoadAddressLow = 0; + NSFHeader.LoadAddressHigh &= 0xF0; + fwrite(&NSFHeader, 1, 0x8, fp); NSFHeader.LoadAddressLow = NSFLoadLow; NSFHeader.LoadAddressHigh = NSFLoadHigh; - fseek(fp,0x8,SEEK_SET); - for (i = 0;i < ((NSFMaxBank+1)*4096);i++){ + fseek(fp, 0x8, SEEK_SET); + for (i = 0; i < ((NSFMaxBank + 1) * 4096); i++) + { unsigned char pchar; if (cdloggerdata[i] & 3) { - pchar = invert?0:NSFDATA[i]; + pchar = invert ? 0 : NSFDATA[i]; } else { - pchar = invert?NSFDATA[i]:0; + pchar = invert ? NSFDATA[i] : 0; } fputc(pchar, fp); } - } else { @@ -578,17 +578,18 @@ void CodeDataLoggerDialog_t::SaveStrippedROM(int invert) cdlhead.ROM_size = cdloggerdataSize >> 14; cdlhead.VROM_size = cdloggerVideoDataSize >> 13; - fwrite(&cdlhead,1,16,fp); + fwrite(&cdlhead, 1, 16, fp); - for (i = 0; i < (int)cdloggerdataSize; i++){ + for (i = 0; i < (int)cdloggerdataSize; i++) + { unsigned char pchar; if (cdloggerdata[i] & 3) { - pchar = invert?0:PRGptr[0][i]; + pchar = invert ? 0 : PRGptr[0][i]; } else { - pchar = invert?PRGptr[0][i]:0; + pchar = invert ? PRGptr[0][i] : 0; } fputc(pchar, fp); } @@ -596,15 +597,16 @@ void CodeDataLoggerDialog_t::SaveStrippedROM(int invert) if (cdloggerVideoDataSize != 0) { // since the OldPPU at least logs the $2007 read accesses, we should save the data anyway - for (i = 0; i < (int)cdloggerVideoDataSize; i++) { + for (i = 0; i < (int)cdloggerVideoDataSize; i++) + { unsigned char vchar; if (cdloggervdata[i] & 3) { - vchar = invert?0:CHRptr[0][i]; + vchar = invert ? 0 : CHRptr[0][i]; } else { - vchar = invert?CHRptr[0][i]:0; + vchar = invert ? CHRptr[0][i] : 0; } fputc(vchar, fp); } @@ -623,7 +625,7 @@ void CodeDataLoggerDialog_t::SaveUnusedROMClicked(void) SaveStrippedROM(1); } //---------------------------------------------------- -static int getDefaultCDLFile( char *filepath ) +static int getDefaultCDLFile(char *filepath) { const char *romFile; char dir[512], baseFile[256]; @@ -632,20 +634,20 @@ static int getDefaultCDLFile( char *filepath ) romFile = getRomFile(); - if ( romFile == NULL ) + if (romFile == NULL) { return -1; } - parseFilepath( romFile, dir, baseFile ); - - if ( dir[0] == 0 ) + parseFilepath(romFile, dir, baseFile); + + if (dir[0] == 0) { - sprintf( filepath, "%s.cdl", baseFile ); + sprintf(filepath, "%s.cdl", baseFile); } else { - sprintf( filepath, "%s/%s.cdl", dir, baseFile ); + sprintf(filepath, "%s/%s.cdl", dir, baseFile); } //printf("%s\n", filepath ); @@ -675,14 +677,18 @@ void InitCDLog(void) { fceuWrapperLock(); cdloggerdataSize = PRGsize[0]; - cdloggerdata = (unsigned char*)malloc(cdloggerdataSize); - 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 + cdloggerdata = (unsigned char *)malloc(cdloggerdataSize); + 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 { - if (GameInfo->type != GIT_NSF) { + cdloggervdata = (unsigned char *)malloc(cdloggerVideoDataSize); + } + else + { + if (GameInfo->type != GIT_NSF) + { cdloggerVideoDataSize = 0; - cdloggervdata = (unsigned char*)malloc(8192); + cdloggervdata = (unsigned char *)malloc(8192); } } fceuWrapperUnLock(); @@ -690,7 +696,7 @@ void InitCDLog(void) //---------------------------------------------------- void ResetCDLog(void) { - if ( GameInfo == NULL ) + if (GameInfo == NULL) { return; } @@ -699,22 +705,22 @@ void ResetCDLog(void) codecount = datacount = rendercount = vromreadcount = 0; undefinedcount = cdloggerdataSize; - if ( cdloggerdata != NULL ) + if (cdloggerdata != NULL) { memset(cdloggerdata, 0, cdloggerdataSize); } - if (cdloggerVideoDataSize != 0) + if (cdloggerVideoDataSize != 0) { undefinedvromcount = cdloggerVideoDataSize; - if ( cdloggervdata != NULL ) + if (cdloggervdata != NULL) { memset(cdloggervdata, 0, cdloggerVideoDataSize); } } - else - { - if (GameInfo->type != GIT_NSF) + else + { + if (GameInfo->type != GIT_NSF) { undefinedvromcount = 8192; memset(cdloggervdata, 0, 8192); @@ -723,10 +729,10 @@ void ResetCDLog(void) fceuWrapperUnLock(); } //---------------------------------------------------- -bool LoadCDLog(const char* nameo) +bool LoadCDLog(const char *nameo) { FILE *FP; - int i,j; + int i, j; FP = fopen(nameo, "rb"); if (FP == NULL) @@ -734,7 +740,7 @@ bool LoadCDLog(const char* nameo) return false; } - for(i = 0;i < (int)cdloggerdataSize;i++) + for (i = 0; i < (int)cdloggerdataSize; i++) { j = fgetc(FP); if (j == EOF) @@ -748,15 +754,19 @@ bool LoadCDLog(const char* nameo) cdloggerdata[i] |= j; } - if(cdloggerVideoDataSize != 0) + if (cdloggerVideoDataSize != 0) { - for(i = 0;i < (int)cdloggerVideoDataSize;i++) + for (i = 0; i < (int)cdloggerVideoDataSize; 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. + 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; } } @@ -815,7 +825,7 @@ void CDLoggerROMChanged(void) // try to load respective CDL file char nameo[1024]; - getDefaultCDLFile( nameo ); + getDefaultCDLFile(nameo); FILE *FP; FP = fopen(nameo, "rb"); @@ -834,7 +844,7 @@ void CDLoggerROMChanged(void) } } //---------------------------------------------------- -void RenameCDLog(const char* newName) +void RenameCDLog(const char *newName) { strcpy(loadedcdfile, newName); } @@ -844,7 +854,7 @@ void SaveCDLogFile(void) if (loadedcdfile[0] == 0) { char nameo[1024]; - getDefaultCDLFile( nameo ); + getDefaultCDLFile(nameo); RenameCDLog(nameo); } diff --git a/src/drivers/Qt/CodeDataLogger.h b/src/drivers/Qt/CodeDataLogger.h index ff8241b6..19f94dd1 100644 --- a/src/drivers/Qt/CodeDataLogger.h +++ b/src/drivers/Qt/CodeDataLogger.h @@ -18,46 +18,45 @@ class CodeDataLoggerDialog_t : public QDialog { - Q_OBJECT + Q_OBJECT - public: - CodeDataLoggerDialog_t(QWidget *parent = 0); - ~CodeDataLoggerDialog_t(void); +public: + CodeDataLoggerDialog_t(QWidget *parent = 0); + ~CodeDataLoggerDialog_t(void); - protected: - QTimer *updateTimer; - QLabel *prgLoggedCodeLabel; - QLabel *prgLoggedDataLabel; - QLabel *prgUnloggedLabel; - QLabel *chrLoggedCodeLabel; - QLabel *chrLoggedDataLabel; - QLabel *chrUnloggedLabel; - QLabel *cdlFileLabel; - QLabel *statLabel; - QCheckBox *autoSaveCdlCbox; - QCheckBox *autoLoadCdlCbox; - QCheckBox *autoResumeLogCbox; - QPushButton *startPauseButton; - void closeEvent(QCloseEvent *bar); +protected: + QTimer *updateTimer; + QLabel *prgLoggedCodeLabel; + QLabel *prgLoggedDataLabel; + QLabel *prgUnloggedLabel; + QLabel *chrLoggedCodeLabel; + QLabel *chrLoggedDataLabel; + QLabel *chrUnloggedLabel; + QLabel *cdlFileLabel; + QLabel *statLabel; + QCheckBox *autoSaveCdlCbox; + QCheckBox *autoLoadCdlCbox; + QCheckBox *autoResumeLogCbox; + QPushButton *startPauseButton; + void closeEvent(QCloseEvent *bar); - void SaveStrippedROM(int invert); + void SaveStrippedROM(int invert); - private: - - public slots: - void closeWindow(void); - private slots: - void loadCdlFile(void); - void saveCdlFile(void); - void saveCdlFileAs(void); - void updatePeriodic(void); - void ResetCDLogClicked(void); - void StartPauseCDLogClicked(void); - void autoSaveCdlStateChange(int state); - void autoLoadCdlStateChange(int state); - void autoResumeCdlStateChange(int state); - void SaveStrippedROMClicked(void); - void SaveUnusedROMClicked(void); +private: +public slots: + void closeWindow(void); +private slots: + void loadCdlFile(void); + void saveCdlFile(void); + void saveCdlFileAs(void); + void updatePeriodic(void); + void ResetCDLogClicked(void); + void StartPauseCDLogClicked(void); + void autoSaveCdlStateChange(int state); + void autoLoadCdlStateChange(int state); + void autoResumeCdlStateChange(int state); + void SaveStrippedROMClicked(void); + void SaveUnusedROMClicked(void); }; void InitCDLog(void); @@ -65,9 +64,8 @@ void ResetCDLog(void); void FreeCDLog(void); void StartCDLogging(void); bool PauseCDLogging(void); -bool LoadCDLog(const char* nameo); -void RenameCDLog(const char* newName); +bool LoadCDLog(const char *nameo); +void RenameCDLog(const char *newName); void CDLoggerROMClosed(void); void CDLoggerROMChanged(void); void SaveCDLogFile(void); - diff --git a/src/drivers/Qt/TraceLogger.cpp b/src/drivers/Qt/TraceLogger.cpp index 0af3adf4..5e152142 100644 --- a/src/drivers/Qt/TraceLogger.cpp +++ b/src/drivers/Qt/TraceLogger.cpp @@ -53,19 +53,19 @@ #include "Qt/SymbolicDebug.h" #include "Qt/fceuWrapper.h" -#define LOG_REGISTERS 0x00000001 -#define LOG_PROCESSOR_STATUS 0x00000002 -#define LOG_NEW_INSTRUCTIONS 0x00000004 -#define LOG_NEW_DATA 0x00000008 -#define LOG_TO_THE_LEFT 0x00000010 -#define LOG_FRAMES_COUNT 0x00000020 -#define LOG_MESSAGES 0x00000040 -#define LOG_BREAKPOINTS 0x00000080 -#define LOG_SYMBOLIC 0x00000100 -#define LOG_CODE_TABBING 0x00000200 -#define LOG_CYCLES_COUNT 0x00000400 -#define LOG_INSTRUCTIONS_COUNT 0x00000800 -#define LOG_BANK_NUMBER 0x00001000 +#define LOG_REGISTERS 0x00000001 +#define LOG_PROCESSOR_STATUS 0x00000002 +#define LOG_NEW_INSTRUCTIONS 0x00000004 +#define LOG_NEW_DATA 0x00000008 +#define LOG_TO_THE_LEFT 0x00000010 +#define LOG_FRAMES_COUNT 0x00000020 +#define LOG_MESSAGES 0x00000040 +#define LOG_BREAKPOINTS 0x00000080 +#define LOG_SYMBOLIC 0x00000100 +#define LOG_CODE_TABBING 0x00000200 +#define LOG_CYCLES_COUNT 0x00000400 +#define LOG_INSTRUCTIONS_COUNT 0x00000800 +#define LOG_BANK_NUMBER 0x00001000 #define LOG_LINE_MAX_LEN 160 // Frames count - 1+6+1 symbols @@ -92,217 +92,218 @@ static int logging = 0; static int logging_options = LOG_REGISTERS | LOG_PROCESSOR_STATUS | LOG_TO_THE_LEFT | LOG_MESSAGES | LOG_BREAKPOINTS | LOG_CODE_TABBING; static int oldcodecount = 0, olddatacount = 0; -static traceRecord_t *recBuf = NULL; -static int recBufMax = 0; -static int recBufHead = 0; -static int recBufTail = 0; -static FILE *logFile = NULL; -static TraceLoggerDialog_t *traceLogWindow = NULL; -static void pushMsgToLogBuffer( const char *msg ); +static traceRecord_t *recBuf = NULL; +static int recBufMax = 0; +static int recBufHead = 0; +static int recBufTail = 0; +static FILE *logFile = NULL; +static TraceLoggerDialog_t *traceLogWindow = NULL; +static void pushMsgToLogBuffer(const char *msg); //---------------------------------------------------- TraceLoggerDialog_t::TraceLoggerDialog_t(QWidget *parent) - : QDialog( parent, Qt::Window ) + : QDialog(parent, Qt::Window) { QVBoxLayout *mainLayout; QHBoxLayout *hbox; QGridLayout *grid; QGroupBox *frame; - QLabel *lbl; + QLabel *lbl; - if ( recBufMax == 0 ) - { - initTraceLogBuffer( 1000000 ); - } + if (recBufMax == 0) + { + initTraceLogBuffer(1000000); + } - setWindowTitle( tr("Trace Logger") ); + setWindowTitle(tr("Trace Logger")); - mainLayout = new QVBoxLayout(); - grid = new QGridLayout(); - mainLayout->addLayout( grid, 100 ); + mainLayout = new QVBoxLayout(); + grid = new QGridLayout(); + mainLayout->addLayout(grid, 100); traceView = new QTraceLogView(this); - vbar = new QScrollBar( Qt::Vertical, this ); - hbar = new QScrollBar( Qt::Horizontal, this ); + vbar = new QScrollBar(Qt::Vertical, this); + hbar = new QScrollBar(Qt::Horizontal, this); - connect( hbar, SIGNAL(valueChanged(int)), this, SLOT(hbarChanged(int)) ); - connect( vbar, SIGNAL(valueChanged(int)), this, SLOT(vbarChanged(int)) ); + connect(hbar, SIGNAL(valueChanged(int)), this, SLOT(hbarChanged(int))); + connect(vbar, SIGNAL(valueChanged(int)), this, SLOT(vbarChanged(int))); - traceView->setScrollBars( hbar, vbar ); + traceView->setScrollBars(hbar, vbar); hbar->setMinimum(0); hbar->setMaximum(100); vbar->setMinimum(0); vbar->setMaximum(recBufMax); - vbar->setValue(recBufMax); + vbar->setValue(recBufMax); - grid->addWidget( traceView, 0, 0); - grid->addWidget( vbar , 0, 1 ); - grid->addWidget( hbar , 1, 0 ); + grid->addWidget(traceView, 0, 0); + grid->addWidget(vbar, 0, 1); + grid->addWidget(hbar, 1, 0); - grid = new QGridLayout(); - mainLayout->addLayout( grid, 1 ); + grid = new QGridLayout(); + mainLayout->addLayout(grid, 1); - lbl = new QLabel( tr("Lines") ); - logLastCbox = new QCheckBox( tr("Log Last") ); + lbl = new QLabel(tr("Lines")); + logLastCbox = new QCheckBox(tr("Log Last")); logMaxLinesComboBox = new QComboBox(); logLastCbox->setChecked(true); - logMaxLinesComboBox->addItem( tr("3,000,000"), 3000000 ); - logMaxLinesComboBox->addItem( tr("1,000,000"), 1000000 ); - logMaxLinesComboBox->addItem( tr("300,000") , 300000 ); - logMaxLinesComboBox->addItem( tr("100,000") , 100000 ); - logMaxLinesComboBox->addItem( tr("30,000") , 30000 ); - logMaxLinesComboBox->addItem( tr("10,000") , 10000 ); - logMaxLinesComboBox->addItem( tr("3,000") , 3000 ); - logMaxLinesComboBox->addItem( tr("1,000") , 1000 ); + logMaxLinesComboBox->addItem(tr("3,000,000"), 3000000); + logMaxLinesComboBox->addItem(tr("1,000,000"), 1000000); + logMaxLinesComboBox->addItem(tr("300,000"), 300000); + logMaxLinesComboBox->addItem(tr("100,000"), 100000); + logMaxLinesComboBox->addItem(tr("30,000"), 30000); + logMaxLinesComboBox->addItem(tr("10,000"), 10000); + logMaxLinesComboBox->addItem(tr("3,000"), 3000); + logMaxLinesComboBox->addItem(tr("1,000"), 1000); - for (int i=0; icount(); i++) + for (int i = 0; i < logMaxLinesComboBox->count(); i++) { - if ( logMaxLinesComboBox->itemData(i).toInt() == recBufMax ) + if (logMaxLinesComboBox->itemData(i).toInt() == recBufMax) { - logMaxLinesComboBox->setCurrentIndex( i ); + logMaxLinesComboBox->setCurrentIndex(i); } } - connect( logMaxLinesComboBox, SIGNAL(activated(int)), this, SLOT(logMaxLinesChanged(int)) ); + connect(logMaxLinesComboBox, SIGNAL(activated(int)), this, SLOT(logMaxLinesChanged(int))); - logFileCbox = new QCheckBox( tr("Log to File") ); - selLogFileButton = new QPushButton( tr("Browse...") ); - startStopButton = new QPushButton( tr("Start Logging") ); - autoUpdateCbox = new QCheckBox( tr("Automatically update this window while logging") ); + logFileCbox = new QCheckBox(tr("Log to File")); + selLogFileButton = new QPushButton(tr("Browse...")); + startStopButton = new QPushButton(tr("Start Logging")); + autoUpdateCbox = new QCheckBox(tr("Automatically update this window while logging")); autoUpdateCbox->setChecked(true); - if ( logging ) + if (logging) { - startStopButton->setText( tr("Stop Logging") ); + startStopButton->setText(tr("Stop Logging")); } - connect( startStopButton, SIGNAL(clicked(void)), this, SLOT(toggleLoggingOnOff(void)) ); - connect( selLogFileButton, SIGNAL(clicked(void)), this, SLOT(openLogFile(void)) ); + connect(startStopButton, SIGNAL(clicked(void)), this, SLOT(toggleLoggingOnOff(void))); + connect(selLogFileButton, SIGNAL(clicked(void)), this, SLOT(openLogFile(void))); hbox = new QHBoxLayout(); - hbox->addWidget( logLastCbox ); - hbox->addWidget( logMaxLinesComboBox ); - hbox->addWidget( lbl ); + hbox->addWidget(logLastCbox); + hbox->addWidget(logMaxLinesComboBox); + hbox->addWidget(lbl); - grid->addLayout( hbox, 0, 0, Qt::AlignLeft ); - grid->addWidget( startStopButton, 0, 1, Qt::AlignCenter ); + grid->addLayout(hbox, 0, 0, Qt::AlignLeft); + grid->addWidget(startStopButton, 0, 1, Qt::AlignCenter); hbox = new QHBoxLayout(); - hbox->addWidget( logFileCbox ); - hbox->addWidget( selLogFileButton ); + hbox->addWidget(logFileCbox); + hbox->addWidget(selLogFileButton); - grid->addLayout( hbox, 1, 0, Qt::AlignLeft ); - grid->addWidget( autoUpdateCbox, 1, 1, Qt::AlignCenter ); + grid->addLayout(hbox, 1, 0, Qt::AlignLeft); + grid->addWidget(autoUpdateCbox, 1, 1, Qt::AlignCenter); - grid = new QGridLayout(); + grid = new QGridLayout(); frame = new QGroupBox(tr("Log Options")); - frame->setLayout( grid ); + frame->setLayout(grid); - logRegCbox = new QCheckBox( tr("Log State of Registers") ); - logFrameCbox = new QCheckBox( tr("Log Frames Count") ); - logEmuMsgCbox = new QCheckBox( tr("Log Emulator Messages") ); - symTraceEnaCbox = new QCheckBox( tr("Symbolic Trace") ); - logProcStatFlagCbox = new QCheckBox( tr("Log Processor Status Flags") ); - logCyclesCountCbox = new QCheckBox( tr("Log Cycles Count") ); - logBreakpointCbox = new QCheckBox( tr("Log Breakpoint Hits") ); - useStackPointerCbox = new QCheckBox( tr("Use Stack Pointer for Code Tabbing (Nesting Visualization)") ); - toLeftDisassemblyCbox = new QCheckBox( tr("To the Left from Disassembly") ); - logInstrCountCbox = new QCheckBox( tr("Log Instructions Count") ); - logBankNumCbox = new QCheckBox( tr("Log Bank Number") ); + logRegCbox = new QCheckBox(tr("Log State of Registers")); + logFrameCbox = new QCheckBox(tr("Log Frames Count")); + logEmuMsgCbox = new QCheckBox(tr("Log Emulator Messages")); + symTraceEnaCbox = new QCheckBox(tr("Symbolic Trace")); + logProcStatFlagCbox = new QCheckBox(tr("Log Processor Status Flags")); + logCyclesCountCbox = new QCheckBox(tr("Log Cycles Count")); + logBreakpointCbox = new QCheckBox(tr("Log Breakpoint Hits")); + useStackPointerCbox = new QCheckBox(tr("Use Stack Pointer for Code Tabbing (Nesting Visualization)")); + toLeftDisassemblyCbox = new QCheckBox(tr("To the Left from Disassembly")); + logInstrCountCbox = new QCheckBox(tr("Log Instructions Count")); + logBankNumCbox = new QCheckBox(tr("Log Bank Number")); - logRegCbox->setChecked( (logging_options & LOG_REGISTERS) ? true : false ); - logFrameCbox->setChecked( (logging_options & LOG_FRAMES_COUNT) ? true : false ); - logEmuMsgCbox->setChecked( (logging_options & LOG_MESSAGES) ? true : false ); - symTraceEnaCbox->setChecked( (logging_options & LOG_SYMBOLIC) ? true : false ); - logProcStatFlagCbox->setChecked( (logging_options & LOG_PROCESSOR_STATUS) ? true : false ); - logCyclesCountCbox->setChecked( (logging_options & LOG_CYCLES_COUNT) ? true : false ); - logBreakpointCbox->setChecked( (logging_options & LOG_BREAKPOINTS) ? true : false ); - useStackPointerCbox->setChecked( (logging_options & LOG_CODE_TABBING) ? true : false ); - toLeftDisassemblyCbox->setChecked( (logging_options & LOG_TO_THE_LEFT) ? true : false ); - logInstrCountCbox->setChecked( (logging_options & LOG_INSTRUCTIONS_COUNT) ? true : false ); - logBankNumCbox->setChecked( (logging_options & LOG_BANK_NUMBER) ? true : false ); + logRegCbox->setChecked((logging_options & LOG_REGISTERS) ? true : false); + logFrameCbox->setChecked((logging_options & LOG_FRAMES_COUNT) ? true : false); + logEmuMsgCbox->setChecked((logging_options & LOG_MESSAGES) ? true : false); + symTraceEnaCbox->setChecked((logging_options & LOG_SYMBOLIC) ? true : false); + logProcStatFlagCbox->setChecked((logging_options & LOG_PROCESSOR_STATUS) ? true : false); + logCyclesCountCbox->setChecked((logging_options & LOG_CYCLES_COUNT) ? true : false); + logBreakpointCbox->setChecked((logging_options & LOG_BREAKPOINTS) ? true : false); + useStackPointerCbox->setChecked((logging_options & LOG_CODE_TABBING) ? true : false); + toLeftDisassemblyCbox->setChecked((logging_options & LOG_TO_THE_LEFT) ? true : false); + logInstrCountCbox->setChecked((logging_options & LOG_INSTRUCTIONS_COUNT) ? true : false); + logBankNumCbox->setChecked((logging_options & LOG_BANK_NUMBER) ? true : false); - connect( logRegCbox, SIGNAL(stateChanged(int)), this, SLOT(logRegStateChanged(int)) ); - connect( logFrameCbox, SIGNAL(stateChanged(int)), this, SLOT(logFrameStateChanged(int)) ); - connect( logEmuMsgCbox, SIGNAL(stateChanged(int)), this, SLOT(logEmuMsgStateChanged(int)) ); - connect( symTraceEnaCbox, SIGNAL(stateChanged(int)), this, SLOT(symTraceEnaStateChanged(int)) ); - connect( logProcStatFlagCbox, SIGNAL(stateChanged(int)), this, SLOT(logProcStatFlagStateChanged(int)) ); - connect( logCyclesCountCbox, SIGNAL(stateChanged(int)), this, SLOT(logCyclesCountStateChanged(int)) ); - connect( logBreakpointCbox, SIGNAL(stateChanged(int)), this, SLOT(logBreakpointStateChanged(int)) ); - connect( useStackPointerCbox, SIGNAL(stateChanged(int)), this, SLOT(useStackPointerStateChanged(int)) ); - connect( toLeftDisassemblyCbox, SIGNAL(stateChanged(int)), this, SLOT(toLeftDisassemblyStateChanged(int)) ); - connect( logInstrCountCbox, SIGNAL(stateChanged(int)), this, SLOT(logInstrCountStateChanged(int)) ); - connect( logBankNumCbox, SIGNAL(stateChanged(int)), this, SLOT(logBankNumStateChanged(int)) ); + connect(logRegCbox, SIGNAL(stateChanged(int)), this, SLOT(logRegStateChanged(int))); + connect(logFrameCbox, SIGNAL(stateChanged(int)), this, SLOT(logFrameStateChanged(int))); + connect(logEmuMsgCbox, SIGNAL(stateChanged(int)), this, SLOT(logEmuMsgStateChanged(int))); + connect(symTraceEnaCbox, SIGNAL(stateChanged(int)), this, SLOT(symTraceEnaStateChanged(int))); + connect(logProcStatFlagCbox, SIGNAL(stateChanged(int)), this, SLOT(logProcStatFlagStateChanged(int))); + connect(logCyclesCountCbox, SIGNAL(stateChanged(int)), this, SLOT(logCyclesCountStateChanged(int))); + connect(logBreakpointCbox, SIGNAL(stateChanged(int)), this, SLOT(logBreakpointStateChanged(int))); + connect(useStackPointerCbox, SIGNAL(stateChanged(int)), this, SLOT(useStackPointerStateChanged(int))); + connect(toLeftDisassemblyCbox, SIGNAL(stateChanged(int)), this, SLOT(toLeftDisassemblyStateChanged(int))); + connect(logInstrCountCbox, SIGNAL(stateChanged(int)), this, SLOT(logInstrCountStateChanged(int))); + connect(logBankNumCbox, SIGNAL(stateChanged(int)), this, SLOT(logBankNumStateChanged(int))); - grid->addWidget( logRegCbox , 0, 0, Qt::AlignLeft ); - grid->addWidget( logFrameCbox , 1, 0, Qt::AlignLeft ); - grid->addWidget( logEmuMsgCbox , 2, 0, Qt::AlignLeft ); - grid->addWidget( symTraceEnaCbox, 3, 0, Qt::AlignLeft ); - grid->addWidget( logProcStatFlagCbox, 0, 1, Qt::AlignLeft ); - grid->addWidget( logCyclesCountCbox , 1, 1, Qt::AlignLeft ); - grid->addWidget( logBreakpointCbox , 2, 1, Qt::AlignLeft ); - grid->addWidget( useStackPointerCbox, 3, 1, 1, 2, Qt::AlignLeft ); - grid->addWidget( toLeftDisassemblyCbox, 0, 2, Qt::AlignLeft ); - grid->addWidget( logInstrCountCbox , 1, 2, Qt::AlignLeft ); - grid->addWidget( logBankNumCbox , 2, 2, Qt::AlignLeft ); + grid->addWidget(logRegCbox, 0, 0, Qt::AlignLeft); + grid->addWidget(logFrameCbox, 1, 0, Qt::AlignLeft); + grid->addWidget(logEmuMsgCbox, 2, 0, Qt::AlignLeft); + grid->addWidget(symTraceEnaCbox, 3, 0, Qt::AlignLeft); + grid->addWidget(logProcStatFlagCbox, 0, 1, Qt::AlignLeft); + grid->addWidget(logCyclesCountCbox, 1, 1, Qt::AlignLeft); + grid->addWidget(logBreakpointCbox, 2, 1, Qt::AlignLeft); + grid->addWidget(useStackPointerCbox, 3, 1, 1, 2, Qt::AlignLeft); + grid->addWidget(toLeftDisassemblyCbox, 0, 2, Qt::AlignLeft); + grid->addWidget(logInstrCountCbox, 1, 2, Qt::AlignLeft); + grid->addWidget(logBankNumCbox, 2, 2, Qt::AlignLeft); - mainLayout->addWidget( frame, 1 ); + mainLayout->addWidget(frame, 1); - grid = new QGridLayout(); + grid = new QGridLayout(); frame = new QGroupBox(tr("Extra Log Options that work with the Code/Data Logger")); - frame->setLayout( grid ); + frame->setLayout(grid); - logNewMapCodeCbox = new QCheckBox( tr("Only Log Newly Mapped Code") ); - logNewMapDataCbox = new QCheckBox( tr("Only Log that Accesses Newly Mapped Data") ); + logNewMapCodeCbox = new QCheckBox(tr("Only Log Newly Mapped Code")); + logNewMapDataCbox = new QCheckBox(tr("Only Log that Accesses Newly Mapped Data")); - logNewMapCodeCbox->setChecked( (logging_options & LOG_NEW_INSTRUCTIONS) ? true : false ); - logNewMapDataCbox->setChecked( (logging_options & LOG_NEW_DATA) ? true : false ); + logNewMapCodeCbox->setChecked((logging_options & LOG_NEW_INSTRUCTIONS) ? true : false); + logNewMapDataCbox->setChecked((logging_options & LOG_NEW_DATA) ? true : false); - connect( logNewMapCodeCbox, SIGNAL(stateChanged(int)), this, SLOT(logNewMapCodeChanged(int)) ); - connect( logNewMapDataCbox, SIGNAL(stateChanged(int)), this, SLOT(logNewMapDataChanged(int)) ); + connect(logNewMapCodeCbox, SIGNAL(stateChanged(int)), this, SLOT(logNewMapCodeChanged(int))); + connect(logNewMapDataCbox, SIGNAL(stateChanged(int)), this, SLOT(logNewMapDataChanged(int))); - grid->addWidget( logNewMapCodeCbox, 0, 0, Qt::AlignLeft ); - grid->addWidget( logNewMapDataCbox, 0, 1, Qt::AlignLeft ); + grid->addWidget(logNewMapCodeCbox, 0, 0, Qt::AlignLeft); + grid->addWidget(logNewMapDataCbox, 0, 1, Qt::AlignLeft); - mainLayout->addWidget( frame, 1 ); + mainLayout->addWidget(frame, 1); - setLayout( mainLayout ); + setLayout(mainLayout); traceViewCounter = 0; - recbufHeadLp = recBufHead; + recbufHeadLp = recBufHead; - updateTimer = new QTimer( this ); + updateTimer = new QTimer(this); - connect( updateTimer, &QTimer::timeout, this, &TraceLoggerDialog_t::updatePeriodic ); + connect(updateTimer, &QTimer::timeout, this, &TraceLoggerDialog_t::updatePeriodic); - updateTimer->start( 10 ); // 100hz + updateTimer->start(10); // 100hz } //---------------------------------------------------- TraceLoggerDialog_t::~TraceLoggerDialog_t(void) { - updateTimer->stop(); + updateTimer->stop(); traceLogWindow = NULL; logging = 0; - if ( logFile ) + if (logFile) { - fclose( logFile ); logFile = NULL; + fclose(logFile); + logFile = NULL; } printf("Trace Logger Window Deleted\n"); } //---------------------------------------------------- void TraceLoggerDialog_t::closeEvent(QCloseEvent *event) { - printf("Trace Logger Close Window Event\n"); - done(0); + printf("Trace Logger Close Window Event\n"); + done(0); deleteLater(); - event->accept(); + event->accept(); } //---------------------------------------------------- void TraceLoggerDialog_t::closeWindow(void) { - printf("Trace Logger Close Window\n"); - done(0); + printf("Trace Logger Close Window\n"); + done(0); deleteLater(); } //---------------------------------------------------- @@ -310,9 +311,9 @@ void TraceLoggerDialog_t::updatePeriodic(void) { char traceViewDrawEnable; - if ( logLastCbox->isChecked() ) + if (logLastCbox->isChecked()) { - if ( FCEUI_EmulationPaused() ) + if (FCEUI_EmulationPaused()) { traceViewDrawEnable = 1; } @@ -326,15 +327,15 @@ void TraceLoggerDialog_t::updatePeriodic(void) traceViewDrawEnable = 0; } - if ( logFile && logFileCbox->isChecked() ) + if (logFile && logFileCbox->isChecked()) { char line[256]; - while ( recBufHead != recBufTail ) + while (recBufHead != recBufTail) { - recBuf[ recBufTail ].convToText( line ); + recBuf[recBufTail].convToText(line); - fprintf( logFile, "%s\n", line ); + fprintf(logFile, "%s\n", line); recBufTail = (recBufTail + 1) % recBufMax; } @@ -344,17 +345,17 @@ void TraceLoggerDialog_t::updatePeriodic(void) recBufTail = recBufHead; } - if ( traceViewCounter > 20 ) + if (traceViewCounter > 20) { - if ( recBufHead != recbufHeadLp ) + if (recBufHead != recbufHeadLp) { traceView->highlightClear(); } recbufHeadLp = recBufHead; - if ( traceViewDrawEnable ) + if (traceViewDrawEnable) { - traceView->update(); + traceView->update(); } traceViewCounter = 0; } @@ -371,7 +372,7 @@ void TraceLoggerDialog_t::logMaxLinesChanged(int index) msleep(1); - initTraceLogBuffer( maxLines ); + initTraceLogBuffer(maxLines); vbar->setMaximum(recBufMax); vbar->setValue(recBufMax); @@ -381,26 +382,27 @@ void TraceLoggerDialog_t::logMaxLinesChanged(int index) //---------------------------------------------------- void TraceLoggerDialog_t::toggleLoggingOnOff(void) { - if ( logging ) + if (logging) { logging = 0; - msleep( 1 ); + msleep(1); pushMsgToLogBuffer("Logging Finished"); - startStopButton->setText( tr("Start Logging") ); + startStopButton->setText(tr("Start Logging")); - if ( logFile ) + if (logFile) { - fclose( logFile ); logFile = NULL; + fclose(logFile); + logFile = NULL; } } else { - if ( logFileCbox->isChecked() ) + if (logFileCbox->isChecked()) { openLogFile(); } pushMsgToLogBuffer("Log Start"); - startStopButton->setText( tr("Stop Logging") ); + startStopButton->setText(tr("Stop Logging")); logging = 1; } } @@ -410,7 +412,7 @@ void TraceLoggerDialog_t::openLogFile(void) const char *romFile; int ret, useNativeFileDialogVal; QString filename; - QFileDialog dialog(this, tr("Select Log File") ); + QFileDialog dialog(this, tr("Select Log File")); printf("Log File Select\n"); @@ -419,216 +421,217 @@ void TraceLoggerDialog_t::openLogFile(void) dialog.setNameFilter(tr("LOG files (*.log *.LOG) ;; All files (*)")); dialog.setViewMode(QFileDialog::List); - dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden ); - dialog.setLabelText( QFileDialog::Accept, tr("Open") ); - dialog.setDefaultSuffix( tr(".log") ); + dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden); + dialog.setLabelText(QFileDialog::Accept, tr("Open")); + dialog.setDefaultSuffix(tr(".log")); romFile = getRomFile(); - if ( romFile != NULL ) + if (romFile != NULL) { char dir[512]; - getDirFromFile( romFile, dir ); - dialog.setDirectory( tr(dir) ); + getDirFromFile(romFile, dir); + dialog.setDirectory(tr(dir)); } // Check config option to use native file dialog or not - g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal); + g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal); dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal); ret = dialog.exec(); - if ( ret ) + if (ret) { QStringList fileList; fileList = dialog.selectedFiles(); - if ( fileList.size() > 0 ) + if (fileList.size() > 0) { filename = fileList[0]; } } - if ( filename.isNull() ) - { - return; - } + if (filename.isNull()) + { + return; + } //qDebug() << "selected file path : " << filename.toUtf8(); - if ( logFile ) + if (logFile) { - fclose( logFile ); logFile = NULL; + fclose(logFile); + logFile = NULL; } - logFile = fopen( filename.toStdString().c_str(), "w"); + logFile = fopen(filename.toStdString().c_str(), "w"); - return; + return; } //---------------------------------------------------- void TraceLoggerDialog_t::hbarChanged(int val) { - traceView->update(); + traceView->update(); } //---------------------------------------------------- void TraceLoggerDialog_t::vbarChanged(int val) { - traceView->update(); + traceView->update(); } //---------------------------------------------------- void TraceLoggerDialog_t::logRegStateChanged(int state) { - if ( state == Qt::Unchecked ) - { - logging_options &= ~LOG_REGISTERS; - } - else - { - logging_options |= LOG_REGISTERS; - } + if (state == Qt::Unchecked) + { + logging_options &= ~LOG_REGISTERS; + } + else + { + logging_options |= LOG_REGISTERS; + } } //---------------------------------------------------- void TraceLoggerDialog_t::logFrameStateChanged(int state) { - if ( state == Qt::Unchecked ) - { - logging_options &= ~LOG_FRAMES_COUNT; - } - else - { - logging_options |= LOG_FRAMES_COUNT; - } + if (state == Qt::Unchecked) + { + logging_options &= ~LOG_FRAMES_COUNT; + } + else + { + logging_options |= LOG_FRAMES_COUNT; + } } //---------------------------------------------------- void TraceLoggerDialog_t::logEmuMsgStateChanged(int state) { - if ( state == Qt::Unchecked ) - { - logging_options &= ~LOG_MESSAGES; - } - else - { - logging_options |= LOG_MESSAGES; - } + if (state == Qt::Unchecked) + { + logging_options &= ~LOG_MESSAGES; + } + else + { + logging_options |= LOG_MESSAGES; + } } //---------------------------------------------------- void TraceLoggerDialog_t::symTraceEnaStateChanged(int state) { - if ( state == Qt::Unchecked ) - { - logging_options &= ~LOG_SYMBOLIC; - } - else - { - logging_options |= LOG_SYMBOLIC; - } + if (state == Qt::Unchecked) + { + logging_options &= ~LOG_SYMBOLIC; + } + else + { + logging_options |= LOG_SYMBOLIC; + } } //---------------------------------------------------- void TraceLoggerDialog_t::logProcStatFlagStateChanged(int state) { - if ( state == Qt::Unchecked ) - { - logging_options &= ~LOG_PROCESSOR_STATUS; - } - else - { - logging_options |= LOG_PROCESSOR_STATUS; - } + if (state == Qt::Unchecked) + { + logging_options &= ~LOG_PROCESSOR_STATUS; + } + else + { + logging_options |= LOG_PROCESSOR_STATUS; + } } //---------------------------------------------------- void TraceLoggerDialog_t::logCyclesCountStateChanged(int state) { - if ( state == Qt::Unchecked ) - { - logging_options &= ~LOG_CYCLES_COUNT; - } - else - { - logging_options |= LOG_CYCLES_COUNT; - } + if (state == Qt::Unchecked) + { + logging_options &= ~LOG_CYCLES_COUNT; + } + else + { + logging_options |= LOG_CYCLES_COUNT; + } } //---------------------------------------------------- void TraceLoggerDialog_t::logBreakpointStateChanged(int state) { - if ( state == Qt::Unchecked ) - { - logging_options &= ~LOG_BREAKPOINTS; - } - else - { - logging_options |= LOG_BREAKPOINTS; - } + if (state == Qt::Unchecked) + { + logging_options &= ~LOG_BREAKPOINTS; + } + else + { + logging_options |= LOG_BREAKPOINTS; + } } //---------------------------------------------------- void TraceLoggerDialog_t::useStackPointerStateChanged(int state) { - if ( state == Qt::Unchecked ) - { - logging_options &= ~LOG_CODE_TABBING; - } - else - { - logging_options |= LOG_CODE_TABBING; - } + if (state == Qt::Unchecked) + { + logging_options &= ~LOG_CODE_TABBING; + } + else + { + logging_options |= LOG_CODE_TABBING; + } } //---------------------------------------------------- void TraceLoggerDialog_t::toLeftDisassemblyStateChanged(int state) { - if ( state == Qt::Unchecked ) - { - logging_options &= ~LOG_TO_THE_LEFT; - } - else - { - logging_options |= LOG_TO_THE_LEFT; - } + if (state == Qt::Unchecked) + { + logging_options &= ~LOG_TO_THE_LEFT; + } + else + { + logging_options |= LOG_TO_THE_LEFT; + } } //---------------------------------------------------- void TraceLoggerDialog_t::logInstrCountStateChanged(int state) { - if ( state == Qt::Unchecked ) - { - logging_options &= ~LOG_INSTRUCTIONS_COUNT; - } - else - { - logging_options |= LOG_INSTRUCTIONS_COUNT; - } + if (state == Qt::Unchecked) + { + logging_options &= ~LOG_INSTRUCTIONS_COUNT; + } + else + { + logging_options |= LOG_INSTRUCTIONS_COUNT; + } } //---------------------------------------------------- void TraceLoggerDialog_t::logBankNumStateChanged(int state) { - if ( state == Qt::Unchecked ) - { - logging_options &= ~LOG_BANK_NUMBER; - } - else - { - logging_options |= LOG_BANK_NUMBER; - } + if (state == Qt::Unchecked) + { + logging_options &= ~LOG_BANK_NUMBER; + } + else + { + logging_options |= LOG_BANK_NUMBER; + } } //---------------------------------------------------- void TraceLoggerDialog_t::logNewMapCodeChanged(int state) { - if ( state == Qt::Unchecked ) - { - logging_options &= ~LOG_NEW_INSTRUCTIONS; - } - else - { - logging_options |= LOG_NEW_INSTRUCTIONS; - } + if (state == Qt::Unchecked) + { + logging_options &= ~LOG_NEW_INSTRUCTIONS; + } + else + { + logging_options |= LOG_NEW_INSTRUCTIONS; + } } //---------------------------------------------------- void TraceLoggerDialog_t::logNewMapDataChanged(int state) { - if ( state == Qt::Unchecked ) - { - logging_options &= ~LOG_NEW_DATA; - } - else - { - logging_options |= LOG_NEW_DATA; - } + if (state == Qt::Unchecked) + { + logging_options &= ~LOG_NEW_DATA; + } + else + { + logging_options |= LOG_NEW_DATA; + } } //---------------------------------------------------- traceRecord_t::traceRecord_t(void) @@ -657,157 +660,175 @@ traceRecord_t::traceRecord_t(void) skippedLines = 0; } //---------------------------------------------------- -int traceRecord_t::appendAsmText( const char *txt ) +int traceRecord_t::appendAsmText(const char *txt) { - int i=0; + int i = 0; - while ( txt[i] != 0 ) + while (txt[i] != 0) { - asmTxt[ asmTxtSize ] = txt[i]; i++; asmTxtSize++; + asmTxt[asmTxtSize] = txt[i]; + i++; + asmTxtSize++; } - asmTxt[ asmTxtSize ] = 0; + asmTxt[asmTxtSize] = 0; return 0; } //---------------------------------------------------- -static int convToXchar( int i ) +static int convToXchar(int i) { - int c = 0; + int c = 0; - if ( (i >= 0) && (i < 10) ) + if ((i >= 0) && (i < 10)) { - c = i + '0'; + c = i + '0'; } - else if ( i < 16 ) + else if (i < 16) { c = (i - 10) + 'A'; } return c; } //---------------------------------------------------- -int traceRecord_t::convToText( char *txt, int *len ) +int traceRecord_t::convToText(char *txt, int *len) { - int i=0, j=0; - char stmp[128]; - char str_axystate[32], str_procstatus[32]; + int i = 0, j = 0; + char stmp[128]; + char str_axystate[32], str_procstatus[32]; str_axystate[0] = 0; str_procstatus[0] = 0; - txt[0] = 0; - if ( opSize == 0 ) + txt[0] = 0; + if (opSize == 0) { - j=0; - while ( asmTxt[j] != 0 ) - { - txt[i] = asmTxt[j]; i++; j++; - } + j = 0; + while (asmTxt[j] != 0) + { + txt[i] = asmTxt[j]; + i++; + j++; + } txt[i] = 0; return -1; } - if ( skippedLines > 0 ) - { + if (skippedLines > 0) + { sprintf(stmp, "(%d lines skipped) ", skippedLines); - j=0; - while ( stmp[j] != 0 ) - { - txt[i] = stmp[j]; i++; j++; - } - } + j = 0; + while (stmp[j] != 0) + { + txt[i] = stmp[j]; + i++; + j++; + } + } - // Start filling the str_temp line: Frame count, Cycles count, Instructions count, AXYS state, Processor status, Tabs, Address, Data, Disassembly + // Start filling the str_temp line: Frame count, Cycles count, Instructions count, AXYS state, Processor status, Tabs, Address, Data, Disassembly if (logging_options & LOG_FRAMES_COUNT) { sprintf(stmp, "f%-6llu ", (long long unsigned int)frameCount); - j=0; - while ( stmp[j] != 0 ) - { - txt[i] = stmp[j]; i++; j++; - } + j = 0; + while (stmp[j] != 0) + { + txt[i] = stmp[j]; + i++; + j++; + } } - if (logging_options & LOG_CYCLES_COUNT) + if (logging_options & LOG_CYCLES_COUNT) { sprintf(stmp, "c%-11llu ", (long long unsigned int)cycleCount); - j=0; - while ( stmp[j] != 0 ) - { - txt[i] = stmp[j]; i++; j++; - } + j = 0; + while (stmp[j] != 0) + { + txt[i] = stmp[j]; + i++; + j++; + } } if (logging_options & LOG_INSTRUCTIONS_COUNT) { sprintf(stmp, "i%-11llu ", (long long unsigned int)instrCount); - j=0; - while ( stmp[j] != 0 ) - { - txt[i] = stmp[j]; i++; j++; - } + j = 0; + while (stmp[j] != 0) + { + txt[i] = stmp[j]; + i++; + j++; + } } - + if (logging_options & LOG_REGISTERS) { - sprintf(str_axystate,"A:%02X X:%02X Y:%02X S:%02X ",(cpu.A),(cpu.X),(cpu.Y),(cpu.S)); + sprintf(str_axystate, "A:%02X X:%02X Y:%02X S:%02X ", (cpu.A), (cpu.X), (cpu.Y), (cpu.S)); } - if (logging_options & LOG_PROCESSOR_STATUS) + if (logging_options & LOG_PROCESSOR_STATUS) { - int tmp = cpu.P^0xFF; - sprintf(str_procstatus,"P:%c%c%c%c%c%c%c%c ", - 'N'|(tmp&0x80)>>2, - 'V'|(tmp&0x40)>>1, - 'U'|(tmp&0x20), - 'B'|(tmp&0x10)<<1, - 'D'|(tmp&0x08)<<2, - 'I'|(tmp&0x04)<<3, - 'Z'|(tmp&0x02)<<4, - 'C'|(tmp&0x01)<<5 - ); + int tmp = cpu.P ^ 0xFF; + sprintf(str_procstatus, "P:%c%c%c%c%c%c%c%c ", + 'N' | (tmp & 0x80) >> 2, + 'V' | (tmp & 0x40) >> 1, + 'U' | (tmp & 0x20), + 'B' | (tmp & 0x10) << 1, + 'D' | (tmp & 0x08) << 2, + 'I' | (tmp & 0x04) << 3, + 'Z' | (tmp & 0x02) << 4, + 'C' | (tmp & 0x01) << 5); } - if (logging_options & LOG_TO_THE_LEFT) + if (logging_options & LOG_TO_THE_LEFT) { if (logging_options & LOG_REGISTERS) { - j=0; - while ( str_axystate[j] != 0 ) - { - txt[i] = str_axystate[j]; i++; j++; - } + j = 0; + while (str_axystate[j] != 0) + { + txt[i] = str_axystate[j]; + i++; + j++; + } } if (logging_options & LOG_PROCESSOR_STATUS) { - j=0; - while ( str_procstatus[j] != 0 ) - { - txt[i] = str_procstatus[j]; i++; j++; - } + j = 0; + while (str_procstatus[j] != 0) + { + txt[i] = str_procstatus[j]; + i++; + j++; + } } } - if (logging_options & LOG_CODE_TABBING) + if (logging_options & LOG_CODE_TABBING) { // add spaces at the beginning of the line according to stack pointer int spaces = (0xFF - cpu.S) & LOG_TABS_MASK; - while ( spaces > 0 ) + while (spaces > 0) { - txt[i] = ' '; i++; spaces--; + txt[i] = ' '; + i++; + spaces--; } - } + } else if (logging_options & LOG_TO_THE_LEFT) { - txt[i] = ' '; i++; + txt[i] = ' '; + i++; } - if (logging_options & LOG_BANK_NUMBER) + if (logging_options & LOG_BANK_NUMBER) { if (cpu.PC >= 0x8000) { @@ -817,69 +838,85 @@ int traceRecord_t::convToText( char *txt, int *len ) { sprintf(stmp, " $%04X: ", cpu.PC); } - } + } else { sprintf(stmp, "$%04X: ", cpu.PC); } - j=0; - while ( stmp[j] != 0 ) - { - txt[i] = stmp[j]; i++; j++; - } + j = 0; + while (stmp[j] != 0) + { + txt[i] = stmp[j]; + i++; + j++; + } - for (j=0; j> 4) & 0x0F ); i++; - txt[i] = convToXchar( opCode[j] & 0x0F ); i++; - txt[i] = ' '; i++; - } - while ( j < 3 ) - { - txt[i] = ' '; i++; - txt[i] = ' '; i++; - txt[i] = ' '; i++; - j++; - } - j=0; - while ( asmTxt[j] != 0 ) - { - txt[i] = asmTxt[j]; i++; j++; - } - if ( callAddr >= 0 ) - { + for (j = 0; j < opSize; j++) + { + txt[i] = convToXchar((opCode[j] >> 4) & 0x0F); + i++; + txt[i] = convToXchar(opCode[j] & 0x0F); + i++; + txt[i] = ' '; + i++; + } + while (j < 3) + { + txt[i] = ' '; + i++; + txt[i] = ' '; + i++; + txt[i] = ' '; + i++; + j++; + } + j = 0; + while (asmTxt[j] != 0) + { + txt[i] = asmTxt[j]; + i++; + j++; + } + if (callAddr >= 0) + { sprintf(stmp, " (from $%04X)", callAddr); - j=0; - while ( stmp[j] != 0 ) - { - txt[i] = stmp[j]; i++; j++; - } - } - - if (!(logging_options & LOG_TO_THE_LEFT)) - { - if (logging_options & LOG_REGISTERS) + j = 0; + while (stmp[j] != 0) { - j=0; - while ( str_axystate[j] != 0 ) - { - txt[i] = str_axystate[j]; i++; j++; - } - } - if (logging_options & LOG_PROCESSOR_STATUS) - { - j=0; - while ( str_procstatus[j] != 0 ) - { - txt[i] = str_procstatus[j]; i++; j++; - } + txt[i] = stmp[j]; + i++; + j++; } } - txt[i] = 0; + if (!(logging_options & LOG_TO_THE_LEFT)) + { + if (logging_options & LOG_REGISTERS) + { + j = 0; + while (str_axystate[j] != 0) + { + txt[i] = str_axystate[j]; + i++; + j++; + } + } + if (logging_options & LOG_PROCESSOR_STATUS) + { + j = 0; + while (str_procstatus[j] != 0) + { + txt[i] = str_procstatus[j]; + i++; + j++; + } + } + } - if ( len ) + txt[i] = 0; + + if (len) { *len = i; } @@ -887,63 +924,63 @@ int traceRecord_t::convToText( char *txt, int *len ) return 0; } //---------------------------------------------------- -int initTraceLogBuffer( int maxRecs ) +int initTraceLogBuffer(int maxRecs) { - if ( maxRecs != recBufMax ) - { - size_t size; + if (maxRecs != recBufMax) + { + size_t size; - size = maxRecs * sizeof(traceRecord_t); + size = maxRecs * sizeof(traceRecord_t); - recBuf = (traceRecord_t*)malloc( size ); + recBuf = (traceRecord_t *)malloc(size); - if ( recBuf ) - { - memset( (void*)recBuf, 0, size ); - recBufMax = maxRecs; - } - else - { - recBufMax = 0; - } - } - return recBuf == NULL; + if (recBuf) + { + memset((void *)recBuf, 0, size); + recBufMax = maxRecs; + } + else + { + recBufMax = 0; + } + } + return recBuf == NULL; } //---------------------------------------------------- -void openTraceLoggerWindow( QWidget *parent ) +void openTraceLoggerWindow(QWidget *parent) { // Only allow one trace logger window to be open - if ( traceLogWindow != NULL ) + if (traceLogWindow != NULL) { return; } //printf("Open Trace Logger Window\n"); - - traceLogWindow = new TraceLoggerDialog_t(parent); - - traceLogWindow->show(); + + traceLogWindow = new TraceLoggerDialog_t(parent); + + traceLogWindow->show(); } //---------------------------------------------------- -static void pushToLogBuffer( traceRecord_t &rec ) +static void pushToLogBuffer(traceRecord_t &rec) { - recBuf[ recBufHead ] = rec; - recBufHead = (recBufHead + 1) % recBufMax; + recBuf[recBufHead] = rec; + recBufHead = (recBufHead + 1) % recBufMax; - if ( recBufHead == recBufTail ) + if (recBufHead == recBufTail) { printf("Trace Log Overrun!!!\n"); } } //---------------------------------------------------- -static void pushMsgToLogBuffer( const char *msg ) +static void pushMsgToLogBuffer(const char *msg) { traceRecord_t rec; - strncpy( rec.asmTxt, msg, sizeof(rec.asmTxt) ); - - rec.asmTxt[ sizeof(rec.asmTxt)-1 ] = 0; + strncpy(rec.asmTxt, msg, sizeof(rec.asmTxt)); - pushToLogBuffer( rec ); + rec.asmTxt[sizeof(rec.asmTxt) - 1] = 0; + + pushToLogBuffer(rec); } //---------------------------------------------------- //todo: really speed this up @@ -952,7 +989,7 @@ void FCEUD_TraceInstruction(uint8 *opcode, int size) if (!logging) return; - traceRecord_t rec; + traceRecord_t rec; char asmTxt[256]; unsigned int addr = X.PC; @@ -960,32 +997,32 @@ void FCEUD_TraceInstruction(uint8 *opcode, int size) int asmFlags = 0; rec.cpu.PC = X.PC; - rec.cpu.A = X.A; - rec.cpu.X = X.X; - rec.cpu.Y = X.Y; - rec.cpu.S = X.S; - rec.cpu.P = X.P; + rec.cpu.A = X.A; + rec.cpu.X = X.X; + rec.cpu.Y = X.Y; + rec.cpu.S = X.S; + rec.cpu.P = X.P; - for (int i=0; ipalette(); + pal = this->palette(); - // Figure out if we are using a light or dark theme by checking the + // Figure out if we are using a light or dark theme by checking the // default window text grayscale color. If more white, then we will // use white text on black background, else we do the opposite. c = pal.color(QPalette::WindowText); - if ( qGray( c.red(), c.green(), c.blue() ) > 128 ) + if (qGray(c.red(), c.green(), c.blue()) > 128) { useDarkTheme = true; } - if ( useDarkTheme ) + if (useDarkTheme) { - pal.setColor(QPalette::Base , fg ); - pal.setColor(QPalette::Background, fg ); - pal.setColor(QPalette::WindowText, bg ); + pal.setColor(QPalette::Base, fg); + pal.setColor(QPalette::Background, fg); + pal.setColor(QPalette::WindowText, bg); } - else + else { - pal.setColor(QPalette::Base , bg ); - pal.setColor(QPalette::Background, bg ); - pal.setColor(QPalette::WindowText, fg ); + pal.setColor(QPalette::Base, bg); + pal.setColor(QPalette::Background, bg); + pal.setColor(QPalette::WindowText, fg); } this->setPalette(pal); @@ -1134,23 +1171,23 @@ QTraceLogView::QTraceLogView(QWidget *parent) hbar = NULL; wheelPixelCounter = 0; - mouseLeftBtnDown = false; + mouseLeftBtnDown = false; txtHlgtAnchorLine = -1; txtHlgtAnchorChar = -1; - txtHlgtStartChar = -1; - txtHlgtStartLine = -1; - txtHlgtEndChar = -1; - txtHlgtEndLine = -1; + txtHlgtStartChar = -1; + txtHlgtStartLine = -1; + txtHlgtEndChar = -1; + txtHlgtEndLine = -1; captureHighLightText = false; - selAddrIdx = -1; - selAddrLine = -1; - selAddrChar = -1; + selAddrIdx = -1; + selAddrLine = -1; + selAddrChar = -1; selAddrWidth = -1; selAddrValue = -1; - memset( selAddrText, 0, sizeof(selAddrText) ); + memset(selAddrText, 0, sizeof(selAddrText)); - for (int i=0; i<64; i++) + for (int i = 0; i < 64; i++) { lineBufIdx[i] = -1; } @@ -1158,30 +1195,30 @@ QTraceLogView::QTraceLogView(QWidget *parent) //---------------------------------------------------- QTraceLogView::~QTraceLogView(void) { - } //---------------------------------------------------- void QTraceLogView::calcFontData(void) { this->setFont(font); - QFontMetrics metrics(font); + QFontMetrics metrics(font); #if QT_VERSION > QT_VERSION_CHECK(5, 11, 0) - pxCharWidth = metrics.horizontalAdvance(QLatin1Char('2')); + pxCharWidth = metrics.horizontalAdvance(QLatin1Char('2')); #else - pxCharWidth = metrics.width(QLatin1Char('2')); + pxCharWidth = metrics.width(QLatin1Char('2')); #endif - pxCharHeight = metrics.height(); - pxLineSpacing = metrics.lineSpacing() * 1.25; - pxLineLead = pxLineSpacing - pxCharHeight; - pxCursorHeight = pxCharHeight; - pxLineWidth = pxCharWidth * LOG_LINE_MAX_LEN; + pxCharHeight = metrics.height(); + pxLineSpacing = metrics.lineSpacing() * 1.25; + pxLineLead = pxLineSpacing - pxCharHeight; + pxCursorHeight = pxCharHeight; + pxLineWidth = pxCharWidth * LOG_LINE_MAX_LEN; - viewLines = (viewHeight / pxLineSpacing) + 1; + viewLines = (viewHeight / pxLineSpacing) + 1; } //---------------------------------------------------------------------------- -void QTraceLogView::setScrollBars( QScrollBar *h, QScrollBar *v ) +void QTraceLogView::setScrollBars(QScrollBar *h, QScrollBar *v) { - hbar = h; vbar = v; + hbar = h; + vbar = v; } //---------------------------------------------------- void QTraceLogView::highlightClear(void) @@ -1189,19 +1226,19 @@ void QTraceLogView::highlightClear(void) txtHlgtEndLine = txtHlgtStartLine = txtHlgtAnchorLine; txtHlgtEndChar = txtHlgtStartChar = txtHlgtAnchorChar; - selAddrIdx = -1; - selAddrLine = -1; - selAddrChar = -1; + selAddrIdx = -1; + selAddrLine = -1; + selAddrChar = -1; selAddrWidth = -1; selAddrValue = -1; selAddrText[0] = 0; } //---------------------------------------------------- -QPoint QTraceLogView::convPixToCursor( QPoint p ) +QPoint QTraceLogView::convPixToCursor(QPoint p) { - QPoint c(0,0); + QPoint c(0, 0); - if ( p.x() < 0 ) + if (p.x() < 0) { c.setX(0); } @@ -1209,87 +1246,89 @@ QPoint QTraceLogView::convPixToCursor( QPoint p ) { float x = (float)p.x() / pxCharWidth; - c.setX( (int)x ); + c.setX((int)x); } - if ( p.y() < 0 ) + if (p.y() < 0) { - c.setY( 0 ); + c.setY(0); } - else + else { - float ly = ( (float)pxLineLead / (float)pxLineSpacing ); - float py = ( (float)p.y() ) / (float)pxLineSpacing; - float ry = fmod( py, 1.0 ); + float ly = ((float)pxLineLead / (float)pxLineSpacing); + float py = ((float)p.y()) / (float)pxLineSpacing; + float ry = fmod(py, 1.0); - if ( ry < ly ) + if (ry < ly) { - c.setY( ((int)py) - 1 ); + c.setY(((int)py) - 1); } else { - c.setY( (int)py ); + c.setY((int)py); } } return c; } //---------------------------------------------------------------------------- -void QTraceLogView::calcTextSel( int x, int y ) +void QTraceLogView::calcTextSel(int x, int y) { - int i,j; + int i, j; char id[128]; //printf("Line: '%s' Char: %c\n", lineText[y].c_str(), lineText[y][x] ); - selAddrIdx = -1; - selAddrLine = -1; - selAddrChar = -1; - selAddrWidth = -1; - selAddrValue = -1; - selAddrText[0] = 0; + selAddrIdx = -1; + selAddrLine = -1; + selAddrChar = -1; + selAddrWidth = -1; + selAddrValue = -1; + selAddrText[0] = 0; - if ( x < lineText[y].size() ) + if (x < lineText[y].size()) { int ax = x; - if ( isxdigit( lineText[y][ax] ) ) + if (isxdigit(lineText[y][ax])) { - while ( (ax >= 0) && isxdigit(lineText[y][ax]) ) + while ((ax >= 0) && isxdigit(lineText[y][ax])) { ax--; } - if ( (ax >= 0) && ( (lineText[y][ax] == '$') || (lineText[y][ax] == ':') ) ) + if ((ax >= 0) && ((lineText[y][ax] == '$') || (lineText[y][ax] == ':'))) { ax--; if (lineText[y][ax] != '#') { - i=0; ax += 2; j=ax; - while ( isxdigit(lineText[y][j]) ) + i = 0; + ax += 2; + j = ax; + while (isxdigit(lineText[y][j])) { - id[i] = lineText[y][j]; i++; j++; + id[i] = lineText[y][j]; + i++; + j++; } id[i] = 0; - selAddrIdx = lineBufIdx[y]; - selAddrLine = y; - selAddrChar = ax; + selAddrIdx = lineBufIdx[y]; + selAddrLine = y; + selAddrChar = ax; selAddrWidth = i; - selAddrValue = strtol( id, NULL, 16 ); - strcpy( selAddrText, id ); + selAddrValue = strtol(id, NULL, 16); + strcpy(selAddrText, id); //printf("Sel Addr: $%04X \n", selAddrValue ); } } } - } - } //---------------------------------------------------------------------------- bool QTraceLogView::textIsHighlighted(void) { bool set = false; - if ( txtHlgtStartLine == txtHlgtEndLine ) + if (txtHlgtStartLine == txtHlgtEndLine) { set = (txtHlgtStartChar != txtHlgtEndChar); } @@ -1300,56 +1339,56 @@ bool QTraceLogView::textIsHighlighted(void) return set; } //---------------------------------------------------------------------------- -void QTraceLogView::setHighlightEndCoord( int x, int y ) +void QTraceLogView::setHighlightEndCoord(int x, int y) { - if ( txtHlgtAnchorLine < y ) + if (txtHlgtAnchorLine < y) { txtHlgtStartLine = txtHlgtAnchorLine; txtHlgtStartChar = txtHlgtAnchorChar; - txtHlgtEndLine = y; - txtHlgtEndChar = x; + txtHlgtEndLine = y; + txtHlgtEndChar = x; } - else if ( txtHlgtAnchorLine > y ) + else if (txtHlgtAnchorLine > y) { txtHlgtStartLine = y; txtHlgtStartChar = x; - txtHlgtEndLine = txtHlgtAnchorLine; - txtHlgtEndChar = txtHlgtAnchorChar; + txtHlgtEndLine = txtHlgtAnchorLine; + txtHlgtEndChar = txtHlgtAnchorChar; } else { txtHlgtStartLine = txtHlgtAnchorLine; - txtHlgtEndLine = txtHlgtAnchorLine; + txtHlgtEndLine = txtHlgtAnchorLine; - if ( txtHlgtAnchorChar < x ) + if (txtHlgtAnchorChar < x) { txtHlgtStartChar = txtHlgtAnchorChar; - txtHlgtEndChar = x; + txtHlgtEndChar = x; } - else if ( txtHlgtAnchorChar > x ) + else if (txtHlgtAnchorChar > x) { txtHlgtStartChar = x; - txtHlgtEndChar = txtHlgtAnchorChar; + txtHlgtEndChar = txtHlgtAnchorChar; } else { txtHlgtStartChar = txtHlgtAnchorChar; - txtHlgtEndChar = txtHlgtAnchorChar; + txtHlgtEndChar = txtHlgtAnchorChar; } } return; } //---------------------------------------------------------------------------- -void QTraceLogView::loadClipboard( const char *txt ) +void QTraceLogView::loadClipboard(const char *txt) { QClipboard *clipboard = QGuiApplication::clipboard(); - clipboard->setText( tr(txt), QClipboard::Clipboard ); + clipboard->setText(tr(txt), QClipboard::Clipboard); - if ( clipboard->supportsSelection() ) + if (clipboard->supportsSelection()) { - clipboard->setText( tr(txt), QClipboard::Selection ); + clipboard->setText(tr(txt), QClipboard::Selection); } } //---------------------------------------------------- @@ -1357,68 +1396,68 @@ void QTraceLogView::keyPressEvent(QKeyEvent *event) { //printf("Key Press: %i \n", event->key() ); - if ( !textIsHighlighted() ) + if (!textIsHighlighted()) { - if ( selAddrIdx >= 0 ) + if (selAddrIdx >= 0) { - if ( event->key() == Qt::Key_B ) - { + if (event->key() == Qt::Key_B) + { ctxMenuAddBP(); event->accept(); - } - else if ( event->key() == Qt::Key_S ) - { + } + else if (event->key() == Qt::Key_S) + { ctxMenuAddSym(); event->accept(); - } + } } } } //---------------------------------------------------- -void QTraceLogView::mouseMoveEvent(QMouseEvent * event) +void QTraceLogView::mouseMoveEvent(QMouseEvent *event) { - QPoint c = convPixToCursor( event->pos() ); + QPoint c = convPixToCursor(event->pos()); - if ( mouseLeftBtnDown ) + if (mouseLeftBtnDown) { //printf("Left Button Move: (%i,%i)\n", c.x(), c.y() ); - setHighlightEndCoord( c.x(), c.y() ); + setHighlightEndCoord(c.x(), c.y()); } } //---------------------------------------------------- -void QTraceLogView::mouseReleaseEvent(QMouseEvent * event) +void QTraceLogView::mouseReleaseEvent(QMouseEvent *event) { - QPoint c = convPixToCursor( event->pos() ); + QPoint c = convPixToCursor(event->pos()); - if ( event->button() == Qt::LeftButton ) + if (event->button() == Qt::LeftButton) { //printf("Left Button Release: (%i,%i)\n", c.x(), c.y() ); mouseLeftBtnDown = false; - setHighlightEndCoord( c.x(), c.y() ); + setHighlightEndCoord(c.x(), c.y()); captureHighLightText = true; - if ( !textIsHighlighted() ) + if (!textIsHighlighted()) { - calcTextSel( c.x(), c.y() ); + calcTextSel(c.x(), c.y()); } } } //---------------------------------------------------- -void QTraceLogView::mousePressEvent(QMouseEvent * event) +void QTraceLogView::mousePressEvent(QMouseEvent *event) { - QPoint c = convPixToCursor( event->pos() ); + QPoint c = convPixToCursor(event->pos()); //printf("Line: %i,%i\n", c.x(), c.y() ); - if ( event->button() == Qt::LeftButton ) + if (event->button() == Qt::LeftButton) { //printf("Left Button Pressed: (%i,%i)\n", c.x(), c.y() ); mouseLeftBtnDown = true; txtHlgtAnchorChar = c.x(); txtHlgtAnchorLine = c.y(); - setHighlightEndCoord( c.x(), c.y() ); + setHighlightEndCoord(c.x(), c.y()); } } //---------------------------------------------------- @@ -1426,56 +1465,56 @@ void QTraceLogView::wheelEvent(QWheelEvent *event) { int lineOffset; - QPoint numPixels = event->pixelDelta(); + QPoint numPixels = event->pixelDelta(); QPoint numDegrees = event->angleDelta(); lineOffset = vbar->value(); - if (!numPixels.isNull()) + if (!numPixels.isNull()) { wheelPixelCounter -= numPixels.y(); - //printf("numPixels: (%i,%i) \n", numPixels.x(), numPixels.y() ); - } - else if (!numDegrees.isNull()) + //printf("numPixels: (%i,%i) \n", numPixels.x(), numPixels.y() ); + } + else if (!numDegrees.isNull()) { //QPoint numSteps = numDegrees / 15; //printf("numSteps: (%i,%i) \n", numSteps.x(), numSteps.y() ); //printf("numDegrees: (%i,%i) %i\n", numDegrees.x(), numDegrees.y(), pxLineSpacing ); - wheelPixelCounter -= (pxLineSpacing * numDegrees.y()) / (15*8); + wheelPixelCounter -= (pxLineSpacing * numDegrees.y()) / (15 * 8); } //printf("Wheel Event: %i\n", wheelPixelCounter); - if ( wheelPixelCounter >= pxLineSpacing ) + if (wheelPixelCounter >= pxLineSpacing) { lineOffset += (wheelPixelCounter / pxLineSpacing); - if ( lineOffset > recBufMax ) + if (lineOffset > recBufMax) { lineOffset = recBufMax; } - vbar->setValue( lineOffset ); + vbar->setValue(lineOffset); wheelPixelCounter = wheelPixelCounter % pxLineSpacing; } - else if ( wheelPixelCounter <= -pxLineSpacing ) + else if (wheelPixelCounter <= -pxLineSpacing) { lineOffset += (wheelPixelCounter / pxLineSpacing); - if ( lineOffset < 0 ) + if (lineOffset < 0) { lineOffset = 0; } - vbar->setValue( lineOffset ); + vbar->setValue(lineOffset); wheelPixelCounter = wheelPixelCounter % pxLineSpacing; } - event->accept(); + event->accept(); } //---------------------------------------------------- void QTraceLogView::resizeEvent(QResizeEvent *event) { - viewWidth = event->size().width(); + viewWidth = event->size().width(); viewHeight = event->size().height(); //printf("QAsmView Resize: %ix%i\n", viewWidth, viewHeight ); @@ -1484,18 +1523,17 @@ void QTraceLogView::resizeEvent(QResizeEvent *event) //maxLineOffset = 0; // mb.numLines() - viewLines + 1; - if ( viewWidth >= pxLineWidth ) + if (viewWidth >= pxLineWidth) { pxLineXScroll = 0; } else { - pxLineXScroll = (int)(0.010f * (float)hbar->value() * (float)(pxLineWidth - viewWidth) ); + pxLineXScroll = (int)(0.010f * (float)hbar->value() * (float)(pxLineWidth - viewWidth)); } - } //---------------------------------------------------------------------------- -void QTraceLogView::openBpEditWindow( int editIdx, watchpointinfo *wp, traceRecord_t *recp ) +void QTraceLogView::openBpEditWindow(int editIdx, watchpointinfo *wp, traceRecord_t *recp) { int ret; QDialog dialog(this); @@ -1510,230 +1548,230 @@ void QTraceLogView::openBpEditWindow( int editIdx, watchpointinfo *wp, traceReco QPushButton *okButton, *cancelButton; QRadioButton *cpu_radio, *ppu_radio, *sprite_radio; - if ( editIdx >= 0 ) + if (editIdx >= 0) { - dialog.setWindowTitle( tr("Edit Breakpoint") ); + dialog.setWindowTitle(tr("Edit Breakpoint")); } else { - dialog.setWindowTitle( tr("Add Breakpoint") ); + dialog.setWindowTitle(tr("Add Breakpoint")); } - hbox = new QHBoxLayout(); + hbox = new QHBoxLayout(); mainLayout = new QVBoxLayout(); - mainLayout->addLayout( hbox ); + mainLayout->addLayout(hbox); - lbl = new QLabel( tr("Address") ); + lbl = new QLabel(tr("Address")); addr1 = new QLineEdit(); - hbox->addWidget( lbl ); - hbox->addWidget( addr1 ); + hbox->addWidget(lbl); + hbox->addWidget(addr1); - lbl = new QLabel( tr("-") ); + lbl = new QLabel(tr("-")); addr2 = new QLineEdit(); - hbox->addWidget( lbl ); - hbox->addWidget( addr2 ); + hbox->addWidget(lbl); + hbox->addWidget(addr2); - forbidChkBox = new QCheckBox( tr("Forbid") ); - hbox->addWidget( forbidChkBox ); + forbidChkBox = new QCheckBox(tr("Forbid")); + hbox->addWidget(forbidChkBox); frame = new QFrame(); - vbox = new QVBoxLayout(); - hbox = new QHBoxLayout(); - gbox = new QGroupBox(); + vbox = new QVBoxLayout(); + hbox = new QHBoxLayout(); + gbox = new QGroupBox(); - rbp = new QCheckBox( tr("Read") ); - wbp = new QCheckBox( tr("Write") ); - xbp = new QCheckBox( tr("Execute") ); - ebp = new QCheckBox( tr("Enable") ); + rbp = new QCheckBox(tr("Read")); + wbp = new QCheckBox(tr("Write")); + xbp = new QCheckBox(tr("Execute")); + ebp = new QCheckBox(tr("Enable")); - gbox->setTitle( tr("Memory") ); - mainLayout->addWidget( frame ); - frame->setLayout( vbox ); - frame->setFrameShape( QFrame::Box ); - vbox->addLayout( hbox ); - vbox->addWidget( gbox ); + gbox->setTitle(tr("Memory")); + mainLayout->addWidget(frame); + frame->setLayout(vbox); + frame->setFrameShape(QFrame::Box); + vbox->addLayout(hbox); + vbox->addWidget(gbox); - hbox->addWidget( rbp ); - hbox->addWidget( wbp ); - hbox->addWidget( xbp ); - hbox->addWidget( ebp ); - - hbox = new QHBoxLayout(); - cpu_radio = new QRadioButton( tr("CPU Mem") ); - ppu_radio = new QRadioButton( tr("PPU Mem") ); - sprite_radio = new QRadioButton( tr("Sprite Mem") ); + hbox->addWidget(rbp); + hbox->addWidget(wbp); + hbox->addWidget(xbp); + hbox->addWidget(ebp); + + hbox = new QHBoxLayout(); + cpu_radio = new QRadioButton(tr("CPU Mem")); + ppu_radio = new QRadioButton(tr("PPU Mem")); + sprite_radio = new QRadioButton(tr("Sprite Mem")); cpu_radio->setChecked(true); - gbox->setLayout( hbox ); - hbox->addWidget( cpu_radio ); - hbox->addWidget( ppu_radio ); - hbox->addWidget( sprite_radio ); + gbox->setLayout(hbox); + hbox->addWidget(cpu_radio); + hbox->addWidget(ppu_radio); + hbox->addWidget(sprite_radio); - grid = new QGridLayout(); + grid = new QGridLayout(); - mainLayout->addLayout( grid ); - lbl = new QLabel( tr("Condition") ); - cond = new QLineEdit(); + mainLayout->addLayout(grid); + lbl = new QLabel(tr("Condition")); + cond = new QLineEdit(); - grid->addWidget( lbl, 0, 0 ); - grid->addWidget( cond, 0, 1 ); + grid->addWidget(lbl, 0, 0); + grid->addWidget(cond, 0, 1); - lbl = new QLabel( tr("Name") ); - name = new QLineEdit(); + lbl = new QLabel(tr("Name")); + name = new QLineEdit(); - grid->addWidget( lbl, 1, 0 ); - grid->addWidget( name, 1, 1 ); + grid->addWidget(lbl, 1, 0); + grid->addWidget(name, 1, 1); - hbox = new QHBoxLayout(); - okButton = new QPushButton( tr("OK") ); - cancelButton = new QPushButton( tr("Cancel") ); + hbox = new QHBoxLayout(); + okButton = new QPushButton(tr("OK")); + cancelButton = new QPushButton(tr("Cancel")); - mainLayout->addLayout( hbox ); - hbox->addWidget( cancelButton ); - hbox->addWidget( okButton ); + mainLayout->addLayout(hbox); + hbox->addWidget(cancelButton); + hbox->addWidget(okButton); - connect( okButton, SIGNAL(clicked(void)), &dialog, SLOT(accept(void)) ); - connect( cancelButton, SIGNAL(clicked(void)), &dialog, SLOT(reject(void)) ); + connect(okButton, SIGNAL(clicked(void)), &dialog, SLOT(accept(void))); + connect(cancelButton, SIGNAL(clicked(void)), &dialog, SLOT(reject(void))); okButton->setDefault(true); - if ( wp != NULL ) + if (wp != NULL) { char stmp[256]; - if ( wp->flags & BT_P ) + if (wp->flags & BT_P) { ppu_radio->setChecked(true); } - else if ( wp->flags & BT_S ) + else if (wp->flags & BT_S) { sprite_radio->setChecked(true); } - sprintf( stmp, "%04X", wp->address ); + sprintf(stmp, "%04X", wp->address); - addr1->setText( tr(stmp) ); + addr1->setText(tr(stmp)); - if ( wp->endaddress > 0 ) + if (wp->endaddress > 0) { - sprintf( stmp, "%04X", wp->endaddress ); + sprintf(stmp, "%04X", wp->endaddress); - addr2->setText( tr(stmp) ); + addr2->setText(tr(stmp)); } - if ( wp->flags & WP_R ) + if (wp->flags & WP_R) { - rbp->setChecked(true); + rbp->setChecked(true); } - if ( wp->flags & WP_W ) + if (wp->flags & WP_W) { - wbp->setChecked(true); + wbp->setChecked(true); } - if ( wp->flags & WP_X ) + if (wp->flags & WP_X) { - xbp->setChecked(true); + xbp->setChecked(true); } - if ( wp->flags & WP_F ) + if (wp->flags & WP_F) { - forbidChkBox->setChecked(true); + forbidChkBox->setChecked(true); } - if ( wp->flags & WP_E ) + if (wp->flags & WP_E) { - ebp->setChecked(true); + ebp->setChecked(true); } - if ( wp->condText ) + if (wp->condText) { - cond->setText( tr(wp->condText) ); + cond->setText(tr(wp->condText)); } else { - if ( editIdx < 0 ) + if (editIdx < 0) { // If new breakpoint, suggest condition if in ROM Mapping area of memory. - if ( wp->address >= 0x8000 ) + if (wp->address >= 0x8000) { char str[64]; - if ( (wp->address == recp->cpu.PC) && (recp->bank >= 0) ) + if ((wp->address == recp->cpu.PC) && (recp->bank >= 0)) { - sprintf(str, "K==#%02X", recp->bank ); + sprintf(str, "K==#%02X", recp->bank); } else { sprintf(str, "K==#%02X", getBank(wp->address)); } - cond->setText( tr(str) ); + cond->setText(tr(str)); } } } - if ( wp->desc ) + if (wp->desc) { - name->setText( tr(wp->desc) ); + name->setText(tr(wp->desc)); } } - dialog.setLayout( mainLayout ); + dialog.setLayout(mainLayout); ret = dialog.exec(); - if ( ret == QDialog::Accepted ) + if (ret == QDialog::Accepted) { - int start_addr = -1, end_addr = -1, type = 0, enable = 1, slot; + int start_addr = -1, end_addr = -1, type = 0, enable = 1, slot; std::string s; slot = (editIdx < 0) ? numWPs : editIdx; - if ( cpu_radio->isChecked() ) + if (cpu_radio->isChecked()) { type |= BT_C; } - else if ( ppu_radio->isChecked() ) + else if (ppu_radio->isChecked()) { type |= BT_P; } - else if ( sprite_radio->isChecked() ) + else if (sprite_radio->isChecked()) { type |= BT_S; } s = addr1->text().toStdString(); - if ( s.size() > 0 ) + if (s.size() > 0) { - start_addr = offsetStringToInt( type, s.c_str() ); + start_addr = offsetStringToInt(type, s.c_str()); } s = addr2->text().toStdString(); - if ( s.size() > 0 ) + if (s.size() > 0) { - end_addr = offsetStringToInt( type, s.c_str() ); + end_addr = offsetStringToInt(type, s.c_str()); } - if ( rbp->isChecked() ) + if (rbp->isChecked()) { type |= WP_R; } - if ( wbp->isChecked() ) + if (wbp->isChecked()) { type |= WP_W; } - if ( xbp->isChecked() ) + if (xbp->isChecked()) { type |= WP_X; } - if ( forbidChkBox->isChecked() ) + if (forbidChkBox->isChecked()) { type |= WP_F; } enable = ebp->isChecked(); - if ( (start_addr >= 0) && (numWPs < 64) ) + if ((start_addr >= 0) && (numWPs < 64)) { unsigned int retval; std::string nameString, condString; @@ -1741,9 +1779,9 @@ void QTraceLogView::openBpEditWindow( int editIdx, watchpointinfo *wp, traceReco nameString = name->text().toStdString(); condString = cond->text().toStdString(); - retval = NewBreak( nameString.c_str(), start_addr, end_addr, type, condString.c_str(), slot, enable); + retval = NewBreak(nameString.c_str(), start_addr, end_addr, type, condString.c_str(), slot, enable); - if ( (retval == 1) || (retval == 2) ) + if ((retval == 1) || (retval == 2)) { printf("Breakpoint Add Failed\n"); } @@ -1767,38 +1805,37 @@ void QTraceLogView::ctxMenuAddBP(void) wp.address = selAddrValue; wp.endaddress = 0; - wp.flags = WP_X | WP_E; + wp.flags = WP_X | WP_E; wp.condText = 0; wp.desc = NULL; - if ( selAddrLine >= 0 ) + if (selAddrLine >= 0) { recp = &rec[selAddrLine]; } - if ( recp != NULL ) + if (recp != NULL) { - openBpEditWindow( -1, &wp, recp ); + openBpEditWindow(-1, &wp, recp); } - } //---------------------------------------------------------------------------- -void QTraceLogView::openDebugSymbolEditWindow( int addr, int bank ) +void QTraceLogView::openDebugSymbolEditWindow(int addr, int bank) { int ret; debugSymbol_t *sym; SymbolEditWindow win(this); - sym = debugSymbolTable.getSymbolAtBankOffset( bank, addr ); + sym = debugSymbolTable.getSymbolAtBankOffset(bank, addr); - win.setAddr( addr ); - win.setBank( bank ); + win.setAddr(addr); + win.setBank(bank); - win.setSym( sym ); + win.setSym(sym); ret = win.exec(); - if ( ret == QDialog::Accepted ) + if (ret == QDialog::Accepted) { updateAllDebuggerWindows(); } @@ -1811,159 +1848,165 @@ void QTraceLogView::ctxMenuAddSym(void) addr = selAddrValue; - if ( selAddrLine >= 0 ) + if (selAddrLine >= 0) { recp = &rec[selAddrLine]; } - if ( addr < 0x8000 ) + if (addr < 0x8000) { - bank = -1; + bank = -1; } else { - if ( recp != NULL ) + if (recp != NULL) { - if ( (addr == recp->cpu.PC) && (recp->bank >= 0) ) + if ((addr == recp->cpu.PC) && (recp->bank >= 0)) { bank = recp->bank; } else { - bank = getBank( addr ); + bank = getBank(addr); } } else { - bank = getBank( addr ); + bank = getBank(addr); } } - openDebugSymbolEditWindow( addr, bank ); + openDebugSymbolEditWindow(addr, bank); } //---------------------------------------------------------------------------- void QTraceLogView::contextMenuEvent(QContextMenuEvent *event) { QAction *act; QMenu menu(this); - QPoint c = convPixToCursor( event->pos() ); + QPoint c = convPixToCursor(event->pos()); - if ( !textIsHighlighted() ) + if (!textIsHighlighted()) { - calcTextSel( c.x(), c.y() ); + calcTextSel(c.x(), c.y()); - if ( selAddrIdx >= 0 ) + if (selAddrIdx >= 0) { act = new QAction(tr("Add Symbolic Debug Marker"), &menu); - menu.addAction(act); - act->setShortcut( QKeySequence(tr("S"))); - connect( act, SIGNAL(triggered(void)), this, SLOT(ctxMenuAddSym(void)) ); + menu.addAction(act); + act->setShortcut(QKeySequence(tr("S"))); + connect(act, SIGNAL(triggered(void)), this, SLOT(ctxMenuAddSym(void))); act = new QAction(tr("Add Breakpoint"), &menu); menu.addAction(act); - act->setShortcut( QKeySequence(tr("B"))); - connect( act, SIGNAL(triggered(void)), this, SLOT(ctxMenuAddBP(void)) ); + act->setShortcut(QKeySequence(tr("B"))); + connect(act, SIGNAL(triggered(void)), this, SLOT(ctxMenuAddBP(void))); menu.exec(event->globalPos()); } } } //---------------------------------------------------- -void QTraceLogView::drawText( QPainter *painter, int x, int y, const char *txt, int maxChars ) +void QTraceLogView::drawText(QPainter *painter, int x, int y, const char *txt, int maxChars) { - int i=0; + int i = 0; char c[2]; - c[0] = 0; c[1] = 0; + c[0] = 0; + c[1] = 0; - while ( (txt[i] != 0) && (i < maxChars) ) + while ((txt[i] != 0) && (i < maxChars)) { c[0] = txt[i]; - painter->drawText( x, y, tr(c) ); - i++; x += pxCharWidth; + painter->drawText(x, y, tr(c)); + i++; + x += pxCharWidth; } } //---------------------------------------------------- void QTraceLogView::paintEvent(QPaintEvent *event) { - int i,x,y, v, ofs, row, start, end, nrow, lineLen; + int i, x, y, v, ofs, row, start, end, nrow, lineLen; QPainter painter(this); - char line[256]; - //traceRecord_t rec[64]; + char line[256]; + //traceRecord_t rec[64]; QColor hlgtFG("white"), hlgtBG("blue"); painter.setFont(font); - viewWidth = event->rect().width(); + viewWidth = event->rect().width(); viewHeight = event->rect().height(); nrow = (viewHeight / pxLineSpacing); - if (nrow < 1 ) nrow = 1; + if (nrow < 1) + nrow = 1; - viewLines = nrow; + viewLines = nrow; - painter.fillRect( 0, 0, viewWidth, viewHeight, this->palette().color(QPalette::Background) ); + painter.fillRect(0, 0, viewWidth, viewHeight, this->palette().color(QPalette::Background)); - painter.setPen( this->palette().color(QPalette::WindowText)); + painter.setPen(this->palette().color(QPalette::WindowText)); v = vbar->value(); - if ( v < viewLines ) v = viewLines; + if (v < viewLines) + v = viewLines; - ofs = recBufMax - v; + ofs = recBufMax - v; - end = recBufHead - ofs; + end = recBufHead - ofs; - if ( end < 0 ) end += recBufMax; - - start = (end - nrow); + if (end < 0) + end += recBufMax; - if ( start < 0 ) start += recBufMax; + start = (end - nrow); - for (i=0; i<64; i++) + if (start < 0) + start += recBufMax; + + for (i = 0; i < 64; i++) { lineBufIdx[i] = -1; } - row = 0; - while ( start != end ) - { + row = 0; + while (start != end) + { lineBufIdx[row] = start; - rec[row] = recBuf[ start ]; row++; - start = (start + 1) % recBufMax; - } + rec[row] = recBuf[start]; + row++; + start = (start + 1) % recBufMax; + } - - if ( captureHighLightText ) + if (captureHighLightText) { hlgtText.clear(); } - pxLineXScroll = (int)(0.010f * (float)hbar->value() * (float)(pxLineWidth - viewWidth) ); + pxLineXScroll = (int)(0.010f * (float)hbar->value() * (float)(pxLineWidth - viewWidth)); - x = -pxLineXScroll; - y = pxLineSpacing; + x = -pxLineXScroll; + y = pxLineSpacing; - for (row=0; row= txtHlgtStartLine) && (l <= txtHlgtEndLine) ) + if ((l >= txtHlgtStartLine) && (l <= txtHlgtEndLine)) { int ax, hlgtXs, hlgtXe, hlgtXd; - if ( l == txtHlgtStartLine ) + if (l == txtHlgtStartLine) { hlgtXs = txtHlgtStartChar; } @@ -1972,7 +2015,7 @@ void QTraceLogView::paintEvent(QPaintEvent *event) hlgtXs = 0; } - if ( l == txtHlgtEndLine ) + if (l == txtHlgtEndLine) { hlgtXe = txtHlgtEndChar; } @@ -1984,59 +2027,59 @@ void QTraceLogView::paintEvent(QPaintEvent *event) ax = x + (hlgtXs * pxCharWidth); - painter.fillRect( ax, y - pxLineSpacing + pxLineLead, hlgtXd * pxCharWidth, pxLineSpacing, hlgtBG ); + painter.fillRect(ax, y - pxLineSpacing + pxLineLead, hlgtXd * pxCharWidth, pxLineSpacing, hlgtBG); - if ( hlgtXs < lineLen ) + if (hlgtXs < lineLen) { - painter.setPen( hlgtFG ); + painter.setPen(hlgtFG); - drawText( &painter, ax, y, &line[hlgtXs], hlgtXd ); + drawText(&painter, ax, y, &line[hlgtXs], hlgtXd); - painter.setPen( this->palette().color(QPalette::WindowText)); + painter.setPen(this->palette().color(QPalette::WindowText)); - for (int i=0; i= 0) && (selAddrIdx == lineBufIdx[row]) ) + else if ((selAddrIdx >= 0) && (selAddrIdx == lineBufIdx[row])) { - if ( (selAddrChar >= 0) && (selAddrChar < lineLen) ) + if ((selAddrChar >= 0) && (selAddrChar < lineLen)) { - if ( strncmp( &line[selAddrChar], selAddrText, selAddrWidth ) == 0 ) + if (strncmp(&line[selAddrChar], selAddrText, selAddrWidth) == 0) { int ax = x + (selAddrChar * pxCharWidth); - painter.fillRect( ax, y - pxLineSpacing + pxLineLead, selAddrWidth * pxCharWidth, pxLineSpacing, hlgtBG ); + painter.fillRect(ax, y - pxLineSpacing + pxLineLead, selAddrWidth * pxCharWidth, pxLineSpacing, hlgtBG); - painter.setPen( hlgtFG ); + painter.setPen(hlgtFG); - drawText( &painter, ax, y, selAddrText ); + drawText(&painter, ax, y, selAddrText); - painter.setPen( this->palette().color(QPalette::WindowText)); + painter.setPen(this->palette().color(QPalette::WindowText)); } } } - y += pxLineSpacing; - } + y += pxLineSpacing; + } - if ( captureHighLightText ) + if (captureHighLightText) { //printf("Highlighted Text:\n%s\n", hlgtText.c_str() ); - if ( textIsHighlighted() ) + if (textIsHighlighted()) { - loadClipboard( hlgtText.c_str() ); + loadClipboard(hlgtText.c_str()); } captureHighLightText = false; } diff --git a/src/drivers/Qt/TraceLogger.h b/src/drivers/Qt/TraceLogger.h index f43170c2..c4ad7ac7 100644 --- a/src/drivers/Qt/TraceLogger.h +++ b/src/drivers/Qt/TraceLogger.h @@ -25,177 +25,178 @@ struct traceRecord_t { - struct { - uint16_t PC; - uint8_t A; - uint8_t X; - uint8_t Y; - uint8_t S; - uint8_t P; + struct + { + uint16_t PC; + uint8_t A; + uint8_t X; + uint8_t Y; + uint8_t S; + uint8_t P; } cpu; - uint8_t opCode[3]; - uint8_t opSize; - uint8_t asmTxtSize; - char asmTxt[64]; + uint8_t opCode[3]; + uint8_t opSize; + uint8_t asmTxtSize; + char asmTxt[64]; - uint64_t frameCount; - uint64_t cycleCount; - uint64_t instrCount; - uint64_t flags; + uint64_t frameCount; + uint64_t cycleCount; + uint64_t instrCount; + uint64_t flags; - int32_t callAddr; - int32_t romAddr; - int32_t bank; - int32_t skippedLines; + int32_t callAddr; + int32_t romAddr; + int32_t bank; + int32_t skippedLines; traceRecord_t(void); - int appendAsmText( const char *txt ); + int appendAsmText(const char *txt); - int convToText( char *line, int *len = 0 ); + int convToText(char *line, int *len = 0); }; class QTraceLogView : public QWidget { - Q_OBJECT + Q_OBJECT - public: - QTraceLogView(QWidget *parent = 0); - ~QTraceLogView(void); +public: + QTraceLogView(QWidget *parent = 0); + ~QTraceLogView(void); - void setScrollBars( QScrollBar *h, QScrollBar *v ); - void highlightClear(void); - protected: - void paintEvent(QPaintEvent *event); - void resizeEvent(QResizeEvent *event); - void wheelEvent(QWheelEvent *event); - void mousePressEvent(QMouseEvent * event); - void mouseReleaseEvent(QMouseEvent * event); - void mouseMoveEvent(QMouseEvent * event); - void keyPressEvent(QKeyEvent *event); + void setScrollBars(QScrollBar *h, QScrollBar *v); + void highlightClear(void); - void calcFontData(void); - QPoint convPixToCursor( QPoint p ); - bool textIsHighlighted(void); - void setHighlightEndCoord( int x, int y ); - void loadClipboard( const char *txt ); - void contextMenuEvent(QContextMenuEvent *event); - void drawText( QPainter *painter, int x, int y, const char *txt, int maxChars = 256 ); - void calcTextSel( int x, int y ); - void openBpEditWindow( int editIdx, watchpointinfo *wp, traceRecord_t *recp ); - void openDebugSymbolEditWindow( int addr, int bank = -1 ); +protected: + void paintEvent(QPaintEvent *event); + void resizeEvent(QResizeEvent *event); + void wheelEvent(QWheelEvent *event); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void keyPressEvent(QKeyEvent *event); - protected: - QFont font; - QScrollBar *vbar; - QScrollBar *hbar; - traceRecord_t rec[64]; + void calcFontData(void); + QPoint convPixToCursor(QPoint p); + bool textIsHighlighted(void); + void setHighlightEndCoord(int x, int y); + void loadClipboard(const char *txt); + void contextMenuEvent(QContextMenuEvent *event); + void drawText(QPainter *painter, int x, int y, const char *txt, int maxChars = 256); + void calcTextSel(int x, int y); + void openBpEditWindow(int editIdx, watchpointinfo *wp, traceRecord_t *recp); + void openDebugSymbolEditWindow(int addr, int bank = -1); - int pxCharWidth; - int pxCharHeight; - int pxLineSpacing; - int pxLineLead; - int pxCursorHeight; - int pxLineXScroll; - int pxLineWidth; - int viewLines; - int viewWidth; - int viewHeight; - int wheelPixelCounter; - int txtHlgtAnchorChar; - int txtHlgtAnchorLine; - int txtHlgtStartChar; - int txtHlgtStartLine; - int txtHlgtEndChar; - int txtHlgtEndLine; +protected: + QFont font; + QScrollBar *vbar; + QScrollBar *hbar; + traceRecord_t rec[64]; - bool mouseLeftBtnDown; - bool captureHighLightText; + int pxCharWidth; + int pxCharHeight; + int pxLineSpacing; + int pxLineLead; + int pxCursorHeight; + int pxLineXScroll; + int pxLineWidth; + int viewLines; + int viewWidth; + int viewHeight; + int wheelPixelCounter; + int txtHlgtAnchorChar; + int txtHlgtAnchorLine; + int txtHlgtStartChar; + int txtHlgtStartLine; + int txtHlgtEndChar; + int txtHlgtEndLine; - int selAddrIdx; - int selAddrLine; - int selAddrChar; - int selAddrWidth; - int selAddrValue; - char selAddrText[128]; + bool mouseLeftBtnDown; + bool captureHighLightText; - int lineBufIdx[64]; - std::string hlgtText; - std::string lineText[64]; + int selAddrIdx; + int selAddrLine; + int selAddrChar; + int selAddrWidth; + int selAddrValue; + char selAddrText[128]; - private slots: - void ctxMenuAddBP(void); - void ctxMenuAddSym(void); + int lineBufIdx[64]; + std::string hlgtText; + std::string lineText[64]; + +private slots: + void ctxMenuAddBP(void); + void ctxMenuAddSym(void); }; class TraceLoggerDialog_t : public QDialog { - Q_OBJECT + Q_OBJECT - public: - TraceLoggerDialog_t(QWidget *parent = 0); - ~TraceLoggerDialog_t(void); +public: + TraceLoggerDialog_t(QWidget *parent = 0); + ~TraceLoggerDialog_t(void); - protected: - QTimer *updateTimer; - QCheckBox *logLastCbox; - QCheckBox *logFileCbox; - QComboBox *logMaxLinesComboBox; +protected: + QTimer *updateTimer; + QCheckBox *logLastCbox; + QCheckBox *logFileCbox; + QComboBox *logMaxLinesComboBox; - QCheckBox *autoUpdateCbox; - QCheckBox *logRegCbox; - QCheckBox *logFrameCbox; - QCheckBox *logEmuMsgCbox; - QCheckBox *logProcStatFlagCbox; - QCheckBox *logCyclesCountCbox; - QCheckBox *logBreakpointCbox; - QCheckBox *useStackPointerCbox; - QCheckBox *toLeftDisassemblyCbox; - QCheckBox *logInstrCountCbox; - QCheckBox *logBankNumCbox; - QCheckBox *symTraceEnaCbox; - QCheckBox *logNewMapCodeCbox; - QCheckBox *logNewMapDataCbox; + QCheckBox *autoUpdateCbox; + QCheckBox *logRegCbox; + QCheckBox *logFrameCbox; + QCheckBox *logEmuMsgCbox; + QCheckBox *logProcStatFlagCbox; + QCheckBox *logCyclesCountCbox; + QCheckBox *logBreakpointCbox; + QCheckBox *useStackPointerCbox; + QCheckBox *toLeftDisassemblyCbox; + QCheckBox *logInstrCountCbox; + QCheckBox *logBankNumCbox; + QCheckBox *symTraceEnaCbox; + QCheckBox *logNewMapCodeCbox; + QCheckBox *logNewMapDataCbox; - QPushButton *selLogFileButton; - QPushButton *startStopButton; + QPushButton *selLogFileButton; + QPushButton *startStopButton; - QTraceLogView *traceView; - QScrollBar *hbar; - QScrollBar *vbar; + QTraceLogView *traceView; + QScrollBar *hbar; + QScrollBar *vbar; - int traceViewCounter; - int recbufHeadLp; + int traceViewCounter; + int recbufHeadLp; - void closeEvent(QCloseEvent *bar); + void closeEvent(QCloseEvent *bar); - private: - - public slots: - void closeWindow(void); - private slots: - void updatePeriodic(void); - void toggleLoggingOnOff(void); - void logRegStateChanged(int state); - void logFrameStateChanged(int state); - void logEmuMsgStateChanged(int state); - void symTraceEnaStateChanged(int state); - void logProcStatFlagStateChanged(int state); - void logCyclesCountStateChanged(int state); - void logBreakpointStateChanged(int state); - void useStackPointerStateChanged(int state); - void toLeftDisassemblyStateChanged(int state); - void logInstrCountStateChanged(int state); - void logBankNumStateChanged(int state); - void logNewMapCodeChanged(int state); - void logNewMapDataChanged(int state); - void logMaxLinesChanged(int index); - void hbarChanged(int value); - void vbarChanged(int value); - void openLogFile(void); +private: +public slots: + void closeWindow(void); +private slots: + void updatePeriodic(void); + void toggleLoggingOnOff(void); + void logRegStateChanged(int state); + void logFrameStateChanged(int state); + void logEmuMsgStateChanged(int state); + void symTraceEnaStateChanged(int state); + void logProcStatFlagStateChanged(int state); + void logCyclesCountStateChanged(int state); + void logBreakpointStateChanged(int state); + void useStackPointerStateChanged(int state); + void toLeftDisassemblyStateChanged(int state); + void logInstrCountStateChanged(int state); + void logBankNumStateChanged(int state); + void logNewMapCodeChanged(int state); + void logNewMapDataChanged(int state); + void logMaxLinesChanged(int index); + void hbarChanged(int value); + void vbarChanged(int value); + void openLogFile(void); }; -int initTraceLogBuffer( int maxRecs ); +int initTraceLogBuffer(int maxRecs); -void openTraceLoggerWindow( QWidget *parent ); +void openTraceLoggerWindow(QWidget *parent);