]> Shamusworld >> Repos - virtualjaguar/commitdiff
Added preliminary M68K disassembly browser.
authorShamus Hammons <jlhamm@acm.org>
Mon, 3 Dec 2012 02:59:39 +0000 (20:59 -0600)
committerShamus Hammons <jlhamm@acm.org>
Mon, 3 Dec 2012 02:59:39 +0000 (20:59 -0600)
src/gui/about.cpp
src/gui/debug/m68kdasmbrowser.cpp [new file with mode: 0644]
src/gui/debug/m68kdasmbrowser.h [new file with mode: 0644]
src/gui/mainwin.cpp
src/gui/mainwin.h
virtualjaguar.pro

index 5cf1ade6d9d49f25fc01e70eafad89a22741d522..14ccfd801395f6a0a388c19374e494cdaa90b6fd 100644 (file)
@@ -28,13 +28,9 @@ AboutWindow::AboutWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog)
        layout->setSizeConstraint(QLayout::SetFixedSize);
        setLayout(layout);
 
-       image = new QLabel();
-       image->setAlignment(Qt::AlignRight);
-       image->setPixmap(QPixmap(":/res/vj_title_small.png"));
-       layout->addWidget(image);
-
        QString s;
        s.append(tr(
+               "<img src=':/res/vj_title_small.png' style='float: right'>"
                "<table>"
                "<tr><td align='right'><b>Version: </b></td><td>"
                VJ_RELEASE_VERSION " (" VJ_RELEASE_SUBVERSION ")"
diff --git a/src/gui/debug/m68kdasmbrowser.cpp b/src/gui/debug/m68kdasmbrowser.cpp
new file mode 100644 (file)
index 0000000..5c52cf0
--- /dev/null
@@ -0,0 +1,127 @@
+//
+// m68kdasmbrowser.cpp - Jaguar M68K disassembly browser
+//
+// by James Hammons
+// (C) 2012 Underground Software
+//
+// JLH = James Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -------------------------------------------------------------
+// JLH  12/01/2012  Created this file
+//
+
+// STILL TO DO:
+//
+
+#include "m68kdasmbrowser.h"
+//#include "memory.h"
+#include "m68000/m68kinterface.h"
+#include "dsp.h"
+#include "gpu.h"
+
+
+M68KDasmBrowserWindow::M68KDasmBrowserWindow(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(0x4000)
+{
+       setWindowTitle(tr("M68K Disassembly 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 M68KDasmBrowserWindow::RefreshContents(void)
+{
+       char string[1024];//, buf[64];
+       QString s;
+
+       char buffer[2048];
+       int pc = memBase, oldpc;
+
+       for(uint32_t i=0; i<32; i++)
+       {
+               oldpc = pc;
+               pc += m68k_disassemble(buffer, pc, 0);
+//             WriteLog("%06X: %s\n", oldpc, buffer);
+               sprintf(string, "%06X: %s<br>", oldpc, buffer);
+
+               buffer[0] = 0;  // Clear string
+               char singleCharString[2] = { 0, 0 };
+
+               for(int j=0; j<strlen(string); j++)
+               {
+                       if (string[j] == 32)
+                               strcat(buffer, "&nbsp;");
+                       else
+                       {
+                               singleCharString[0] = string[j];
+                               strcat(buffer, singleCharString);
+                       }
+               }
+
+//             s += QString(string);
+               s += QString(buffer);
+       }
+
+       text->clear();
+       text->setText(s);
+}
+
+
+void M68KDasmBrowserWindow::keyPressEvent(QKeyEvent * e)
+{
+       if (e->key() == Qt::Key_Escape || e->key() == Qt::Key_Return)
+               hide();
+#if 1
+       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();
+       }
+#endif
+}
diff --git a/src/gui/debug/m68kdasmbrowser.h b/src/gui/debug/m68kdasmbrowser.h
new file mode 100644 (file)
index 0000000..77550ee
--- /dev/null
@@ -0,0 +1,38 @@
+//
+// m68kdasmbrowser.h: Jaguar 68K disassembly browser
+//
+// by James Hammons
+// (C) 2012 Underground Software
+//
+
+#ifndef __M68KDASMBROWSER_H__
+#define __M68KDASMBROWSER_H__
+
+#include <QtGui>
+#include <stdint.h>
+
+class M68KDasmBrowserWindow: public QWidget
+{
+       Q_OBJECT
+
+       public:
+               M68KDasmBrowserWindow(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 // __M68KDASMBROWSER_H__
index 72869fb7515723f7751715621b0c400c4137ac61..5eb4f6f13d6deeb62a89e31e29b8dfa3e64eb45c 100644 (file)
@@ -43,8 +43,9 @@
 #include "configdialog.h"
 #include "generaltab.h"
 #include "version.h"
-#include "debug/memorybrowser.h"
 #include "debug/cpubrowser.h"
+#include "debug/m68kdasmbrowser.h"
+#include "debug/memorybrowser.h"
 #include "debug/opbrowser.h"
 
 #include "dac.h"
@@ -102,6 +103,7 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false),
        memBrowseWin = new MemoryBrowserWindow(this);
        cpuBrowseWin = new CPUBrowserWindow(this);
        opBrowseWin = new OPBrowserWindow(this);
+       m68kDasmBrowseWin = new M68KDasmBrowserWindow(this);
 
     videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -223,6 +225,11 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false),
 //     memBrowseAct->setCheckable(true);
        connect(opBrowseAct, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
 
+       m68kDasmBrowseAct = new QAction(QIcon(":/res/generic.png"), tr("68K Listing Browser"), this);
+       m68kDasmBrowseAct->setStatusTip(tr("Shows the 68K disassembly browser window"));
+//     memBrowseAct->setCheckable(true);
+       connect(m68kDasmBrowseAct, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
+
        // Misc. connections...
        connect(filePickWin, SIGNAL(RequestLoad(QString)), this, SLOT(LoadSoftware(QString)));
        connect(filePickWin, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
@@ -244,6 +251,7 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false),
                debugMenu->addAction(memBrowseAct);
                debugMenu->addAction(cpuBrowseAct);
                debugMenu->addAction(opBrowseAct);
+               debugMenu->addAction(m68kDasmBrowseAct);
        }
 
        helpMenu = menuBar()->addMenu(tr("&Help"));
@@ -272,6 +280,7 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false),
                debugbar->addAction(memBrowseAct);
                debugbar->addAction(cpuBrowseAct);
                debugbar->addAction(opBrowseAct);
+               debugbar->addAction(m68kDasmBrowseAct);
        }
 
        //      Create status bar
@@ -888,6 +897,13 @@ void MainWin::ShowOPBrowserWin(void)
 }
 
 
+void MainWin::ShowM68KDasmBrowserWin(void)
+{
+       m68kDasmBrowseWin->show();
+       m68kDasmBrowseWin->RefreshContents();
+}
+
+
 void MainWin::ResizeMainWindow(void)
 {
 //     videoWidget->setFixedSize(zoomLevel * 320, zoomLevel * (vjs.hardwareTypeNTSC ? 240 : 256));
index b1fb71db106cdc1d92db116ab326541e1706d0f5..27c99ce13b997838909dcef6e05de35267b27ed7 100644 (file)
@@ -19,6 +19,7 @@ class FilePickerWindow;
 class MemoryBrowserWindow;
 class CPUBrowserWindow;
 class OPBrowserWindow;
+class M68KDasmBrowserWindow;
 
 class MainWin: public QMainWindow
 {
@@ -60,6 +61,7 @@ class MainWin: public QMainWindow
                void ShowMemoryBrowserWin(void);
                void ShowCPUBrowserWin(void);
                void ShowOPBrowserWin(void);
+               void ShowM68KDasmBrowserWin(void);
 
        private:
                void HandleKeys(QKeyEvent *, bool);
@@ -77,6 +79,7 @@ class MainWin: public QMainWindow
                MemoryBrowserWindow * memBrowseWin;
                CPUBrowserWindow * cpuBrowseWin;
                OPBrowserWindow * opBrowseWin;
+               M68KDasmBrowserWindow * m68kDasmBrowseWin;
                QTimer * timer;
                bool running;
                int zoomLevel;
@@ -124,6 +127,7 @@ class MainWin: public QMainWindow
                QAction * memBrowseAct;
                QAction * cpuBrowseAct;
                QAction * opBrowseAct;
+               QAction * m68kDasmBrowseAct;
 
                QIcon powerGreen;
                QIcon powerRed;
index 7d1164e11b8758fe27fb29c99b27f2fb511096a7..0c42810a1fa81e82f96f0f97b31a8dd5f55d059d 100644 (file)
@@ -74,6 +74,7 @@ HEADERS = \
        src/gui/keygrabber.h \
        src/gui/mainwin.h \
        src/gui/debug/cpubrowser.h \
+       src/gui/debug/m68kdasmbrowser.h \
        src/gui/debug/memorybrowser.h \
        src/gui/debug/opbrowser.h \
 #      src/gui/sdljoystick.h
@@ -95,6 +96,7 @@ SOURCES = \
        src/gui/keygrabber.cpp \
        src/gui/mainwin.cpp \
        src/gui/debug/cpubrowser.cpp \
+       src/gui/debug/m68kdasmbrowser.cpp \
        src/gui/debug/memorybrowser.cpp \
        src/gui/debug/opbrowser.cpp \
 #      src/gui/sdljoystick.cpp