From 178d7f01b40cf8367cfe5b71219e6d20f60f92d4 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Wed, 15 Aug 2012 16:29:42 -0500 Subject: [PATCH] Added preliminary CPU browser window & GUI hooks. --- src/gui/debug/cpubrowser.cpp | 128 +++++++++++++++++++++++++++++++++++ src/gui/debug/cpubrowser.h | 38 +++++++++++ src/gui/mainwin.cpp | 16 +++++ src/gui/mainwin.h | 4 ++ virtualjaguar.pro | 2 + 5 files changed, 188 insertions(+) create mode 100644 src/gui/debug/cpubrowser.cpp create mode 100644 src/gui/debug/cpubrowser.h diff --git a/src/gui/debug/cpubrowser.cpp b/src/gui/debug/cpubrowser.cpp new file mode 100644 index 0000000..067755e --- /dev/null +++ b/src/gui/debug/cpubrowser.cpp @@ -0,0 +1,128 @@ +// +// cpubrowser.cpp - Jaguar CPU browser +// +// by James Hammons +// (C) 2012 Underground Software +// +// JLH = James Hammons +// +// Who When What +// --- ---------- ------------------------------------------------------------- +// JLH 08/14/2012 Created this file +// + +// STILL TO DO: +// + +#include "cpubrowser.h" +//#include "memory.h" +#include "m68000/m68kinterface.h" + + +CPUBrowserWindow::CPUBrowserWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog), +// layout(new QVBoxLayout), text(new QTextBrowser), + layout(new QVBoxLayout), text(new QLabel), + refresh(new QPushButton(tr("Refresh"))), + memBase(0) +{ + setWindowTitle(tr("CPU Browser")); + + // Need to set the size as well... +// resize(560, 480); + + QFont fixedFont("Lucida Console", 10, QFont::Normal); + text->setFont(fixedFont); +//// layout->setSizeConstraint(QLayout::SetFixedSize); + setLayout(layout); + + layout->addWidget(text); + layout->addWidget(refresh); + + connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents())); +} + + +void CPUBrowserWindow::RefreshContents(void) +{ + char string[1024], buf[64]; + QString s; + + uint32_t m68kPC = m68k_get_reg(NULL, M68K_REG_PC); + uint32_t m68kSR = m68k_get_reg(NULL, M68K_REG_SR); + sprintf(string, "PC: %06X  SR: %04X

", m68kPC, m68kSR); + s += QString(string); + + uint32_t m68kA0 = m68k_get_reg(NULL, M68K_REG_A0); + uint32_t m68kA1 = m68k_get_reg(NULL, M68K_REG_A1); + uint32_t m68kA2 = m68k_get_reg(NULL, M68K_REG_A2); + uint32_t m68kA3 = m68k_get_reg(NULL, M68K_REG_A3); + sprintf(string, "A0: %08X  A1: %08X  A2: %08X  A3: %08X
", m68kA0, m68kA1, m68kA2, m68kA3); + s += QString(string); + + uint32_t m68kA4 = m68k_get_reg(NULL, M68K_REG_A4); + uint32_t m68kA5 = m68k_get_reg(NULL, M68K_REG_A5); + uint32_t m68kA6 = m68k_get_reg(NULL, M68K_REG_A6); + uint32_t m68kA7 = m68k_get_reg(NULL, M68K_REG_A7); + sprintf(string, "A4: %08X  A5: %08X  A6: %08X  A7: %08X

", m68kA4, m68kA5, m68kA6, m68kA7); + s += QString(string); + + uint32_t m68kD0 = m68k_get_reg(NULL, M68K_REG_D0); + uint32_t m68kD1 = m68k_get_reg(NULL, M68K_REG_D1); + uint32_t m68kD2 = m68k_get_reg(NULL, M68K_REG_D2); + uint32_t m68kD3 = m68k_get_reg(NULL, M68K_REG_D3); + sprintf(string, "D0: %08X  D1: %08X  D2: %08X  D3: %08X
", m68kD0, m68kD1, m68kD2, m68kD3); + s += QString(string); + + uint32_t m68kD4 = m68k_get_reg(NULL, M68K_REG_D4); + uint32_t m68kD5 = m68k_get_reg(NULL, M68K_REG_D5); + uint32_t m68kD6 = m68k_get_reg(NULL, M68K_REG_D6); + uint32_t m68kD7 = m68k_get_reg(NULL, M68K_REG_D7); + sprintf(string, "D4: %08X  D5: %08X  D6: %08X  D7: %08X", m68kD4, m68kD5, m68kD6, m68kD7); + s += QString(string); + + text->clear(); + text->setText(s); +} + + +void CPUBrowserWindow::keyPressEvent(QKeyEvent * e) +{ + if (e->key() == Qt::Key_Escape || e->key() == Qt::Key_Return) + hide(); + else if (e->key() == Qt::Key_PageUp) + { + memBase -= 480; + + if (memBase < 0) + memBase = 0; + + RefreshContents(); + } + else if (e->key() == Qt::Key_PageDown) + { + memBase += 480; + + if (memBase > (0x200000 - 480)) + memBase = 0x200000 - 480; + + RefreshContents(); + } + else if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Minus) + { + memBase -= 16; + + if (memBase < 0) + memBase = 0; + + RefreshContents(); + } + else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Equal) + { + memBase += 16; + + if (memBase > (0x200000 - 480)) + memBase = 0x200000 - 480; + + RefreshContents(); + } +} diff --git a/src/gui/debug/cpubrowser.h b/src/gui/debug/cpubrowser.h new file mode 100644 index 0000000..0ea0cda --- /dev/null +++ b/src/gui/debug/cpubrowser.h @@ -0,0 +1,38 @@ +// +// cpubrowser.h: Jaguar CPU browser +// +// by James Hammons +// (C) 2012 Underground Software +// + +#ifndef __CPUBROWSER_H__ +#define __CPUBROWSER_H__ + +#include +#include + +class CPUBrowserWindow: public QWidget +{ + Q_OBJECT + + public: + CPUBrowserWindow(QWidget * parent = 0); + + + public slots: +// void DefineAllKeys(void); + void RefreshContents(void); + + protected: + void keyPressEvent(QKeyEvent *); + + private: + QVBoxLayout * layout; +// QTextBrowser * text; + QLabel * text; + QPushButton * refresh; + + int32_t memBase; +}; + +#endif // __CPUBROWSER_H__ diff --git a/src/gui/mainwin.cpp b/src/gui/mainwin.cpp index b9c0724..ac017ce 100644 --- a/src/gui/mainwin.cpp +++ b/src/gui/mainwin.cpp @@ -44,6 +44,7 @@ #include "generaltab.h" #include "version.h" #include "debug/memorybrowser.h" +#include "debug/cpubrowser.h" #include "dac.h" #include "jaguar.h" @@ -98,6 +99,7 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false), helpWin = new HelpWindow(this); filePickWin = new FilePickerWindow(this); memBrowseWin = new MemoryBrowserWindow(this); + cpuBrowseWin = new CPUBrowserWindow(this); videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -205,6 +207,11 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false), // memBrowseAct->setCheckable(true); connect(memBrowseAct, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin())); + cpuBrowseAct = new QAction(QIcon(":/res/generic.png"), tr("CPU Browser"), this); + cpuBrowseAct->setStatusTip(tr("Shows the Jaguar CPU browser window")); +// memBrowseAct->setCheckable(true); + connect(cpuBrowseAct, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin())); + // Misc. connections... connect(filePickWin, SIGNAL(RequestLoad(QString)), this, SLOT(LoadSoftware(QString))); connect(filePickWin, SIGNAL(FilePickerHiding()), this, SLOT(Unpause())); @@ -224,6 +231,7 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false), { debugMenu = menuBar()->addMenu(tr("&Debug")); debugMenu->addAction(memBrowseAct); + debugMenu->addAction(cpuBrowseAct); } helpMenu = menuBar()->addMenu(tr("&Help")); @@ -249,6 +257,7 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false), { debugbar = addToolBar(tr("&Debug")); debugbar->addAction(memBrowseAct); + debugbar->addAction(cpuBrowseAct); } // Create status bar @@ -786,6 +795,13 @@ void MainWin::ShowMemoryBrowserWin(void) } +void MainWin::ShowCPUBrowserWin(void) +{ + cpuBrowseWin->show(); + cpuBrowseWin->RefreshContents(); +} + + void MainWin::ResizeMainWindow(void) { videoWidget->setFixedSize(zoomLevel * 320, zoomLevel * (vjs.hardwareTypeNTSC ? 240 : 256)); diff --git a/src/gui/mainwin.h b/src/gui/mainwin.h index fd6aef1..a5d0f76 100644 --- a/src/gui/mainwin.h +++ b/src/gui/mainwin.h @@ -17,6 +17,7 @@ class AboutWindow; class HelpWindow; class FilePickerWindow; class MemoryBrowserWindow; +class CPUBrowserWindow; class MainWin: public QMainWindow { @@ -55,6 +56,7 @@ class MainWin: public QMainWindow void FrameAdvance(void); void ShowMemoryBrowserWin(void); + void ShowCPUBrowserWin(void); private: void HandleKeys(QKeyEvent *, bool); @@ -69,6 +71,7 @@ class MainWin: public QMainWindow HelpWindow * helpWin; FilePickerWindow * filePickWin; MemoryBrowserWindow * memBrowseWin; + CPUBrowserWindow * cpuBrowseWin; QTimer * timer; bool running; int zoomLevel; @@ -110,6 +113,7 @@ class MainWin: public QMainWindow QAction * frameAdvanceAct; QAction * memBrowseAct; + QAction * cpuBrowseAct; QIcon powerGreen; QIcon powerRed; diff --git a/virtualjaguar.pro b/virtualjaguar.pro index f16d7ce..7a6992e 100644 --- a/virtualjaguar.pro +++ b/virtualjaguar.pro @@ -73,6 +73,7 @@ HEADERS = \ src/gui/imagedelegate.h \ src/gui/keygrabber.h \ src/gui/mainwin.h \ + src/gui/debug/cpubrowser.h \ src/gui/debug/memorybrowser.h \ # src/gui/sdljoystick.h @@ -92,5 +93,6 @@ SOURCES = \ src/gui/imagedelegate.cpp \ src/gui/keygrabber.cpp \ src/gui/mainwin.cpp \ + src/gui/debug/cpubrowser.cpp \ src/gui/debug/memorybrowser.cpp \ # src/gui/sdljoystick.cpp -- 2.37.2