New updates

This commit is contained in:
Mark Long 2016-06-29 19:37:09 -05:00
parent bf8b4cece3
commit b5558818e2
10 changed files with 211 additions and 21 deletions

View File

@ -47,7 +47,8 @@ SOURCES += \
src/ui/viewers/disassemblerviewer.cpp \
src/ui/viewers/hexdumpviewer.cpp \
src/ui/viewers/texthexdumpviewer.cpp \
src/relocatablefile/relocatablefile.cxx
src/relocatablefile/relocatablefile.cxx \
src/ui/viewers/mazeviewer.cpp
HEADERS += \
src/diskfiles/dos33/diskfile.h \
@ -74,7 +75,8 @@ HEADERS += \
src/ui/viewers/disassemblerviewer.h \
src/ui/viewers/hexdumpviewer.h \
src/ui/viewers/texthexdumpviewer.h \
src/relocatablefile/relocatablefile.h
src/relocatablefile/relocatablefile.h \
src/ui/viewers/mazeviewer.h
FORMS += \
src/ui/catalogwidget.ui \

Binary file not shown.

View File

@ -11,6 +11,7 @@ public:
QByteArray &values() { return m_memory; }
quint8 at(quint16 addr) { return m_memory.at(addr); }
private:
QByteArray m_memory;

View File

@ -1,4 +1,6 @@
#include <QApplication>
#include <QSettings>
#include <QString>
#include "mainwindow.h"
#include "binaryfile.h"
@ -10,10 +12,16 @@
int main(int argc, char** argv)
{
QApplication a(argc, argv);
QCoreApplication::setOrganizationName("AppleSAWS");
QCoreApplication::setOrganizationDomain("ml.com");
QCoreApplication::setApplicationName("AppleSAWS");
MainWindow w;
w.loadDiskFile("~/AppleSAWS/images/missing_ring_good.dsk");
// w.loadDiskFile("~/AppleSAWS/images/dos.3.3.system.master.dsk");
// w.loadDiskFile("~/AppleSAWS/images//montezuma_etc.dsk");
QSettings settings;
QString lastOpened = settings.value("lastOpened").toString();
if (!lastOpened.isEmpty())
{
w.loadDiskFile(lastOpened);
}
w.show();
return a.exec();

View File

@ -38,6 +38,8 @@ void CatalogWidget::showContextMenuForWidget(const QPoint &point) {
[=](){ this->toggleHexView(selectedItem); hexViewAction->deleteLater();});
contextMenu.addAction(hexViewAction);
// QAction *viewWithAction = new QAction("View With...",this);
// connect(viewWithAction, &QAction::triggered,
// [=](){ this->itemClicked(selectedItem); viewWithAction->deleteLater();});
@ -153,3 +155,4 @@ void CatalogWidget::toggleHexView(QListWidgetItem *item)
}

View File

@ -9,12 +9,15 @@
#include "disassembler.h"
#include "disassemblerviewer.h"
#include "hexdumpviewer.h"
#include "mazeviewer.h"
#include "texthexdumpviewer.h"
#include "relocatablefile.h"
#include <QFileDialog>
#include <QTextDocument>
#include <QSettings>
#include <QString>
MainWindow::MainWindow(QWidget *parent) :
@ -58,6 +61,8 @@ void MainWindow::loadDiskFile(QString filename)
emit diskFileLoading(filename,m_disk);
if (m_disk->read(filename)) {
ui->action_Unload_Disk_Image->setEnabled(true);
QSettings settings;
settings.setValue("lastOpened",filename);
emit diskFileLoaded(filename,m_disk);
} else {
emit diskFileLoadFailed(filename,m_disk);
@ -101,6 +106,14 @@ void MainWindow::openInDisassemblerViewer(BinaryFile *file) {
hvwma->setFile(file);
}
void MainWindow::openInMazeViewer(BinaryFile *file) {
MazeViewer *hvwma = new MazeViewer(0);
int cellw = 70;
hvwma->resize(cellw*8,cellw*10);
hvwma->show();
hvwma->setFile(file);
}
void MainWindow::openInApplesoftFileViewer(ApplesoftFile *file) {
ApplesoftFileViewer *afv = new ApplesoftFileViewer(0);
@ -119,6 +132,7 @@ void MainWindow::handleDiskItemSelectedHexViewOpen(DiskFile *disk, FileDescripti
}
void MainWindow::handleDiskItemSelectedDefaultOpen(DiskFile *disk, FileDescriptiveEntry fde)
{
GenericFile *file = disk->getFile(fde);
@ -133,10 +147,13 @@ void MainWindow::handleDiskItemSelectedDefaultOpen(DiskFile *disk, FileDescripti
{
openInHiresViewWidget(binfile, AppleString(fde.filename).printable().trimmed());
}
else if (file->filename().contains("maze",Qt::CaseInsensitive))
{
openInMazeViewer(binfile);
}
else
{
openInDisassemblerViewer(binfile);
}
}
else if (dynamic_cast<ApplesoftFile *>(file))

View File

@ -42,6 +42,7 @@ protected:
void openInApplesoftFileViewer(ApplesoftFile *file);
void openInHiresViewWidget(BinaryFile *file, QString filename);
void openInDisassemblerViewer(BinaryFile *file);
void openInMazeViewer(BinaryFile *file);
private:
Ui::MainWindow *ui;

View File

@ -1,6 +1,8 @@
#include "hexdumpviewer.h"
#include "ui_hexdumpviewer.h"
#include <QScrollBar>
HexDumpViewer::HexDumpViewer(QWidget *parent) :
QWidget(parent),
ui(new Ui::HexDumpViewer)
@ -8,6 +10,14 @@ HexDumpViewer::HexDumpViewer(QWidget *parent) :
ui->setupUi(this);
m_offset = 0;
QButtonGroup *bg = new QButtonGroup(this);
bg->addButton(ui->hexButton);
bg->addButton(ui->textButton);
ui->hexButton->setChecked(true);
connect(ui->hexButton, SIGNAL(clicked(bool)), SLOT(showHexValues()));
connect(ui->textButton, SIGNAL(clicked(bool)), SLOT(showAsciiValues()));
QString title = QString("Hex Viewer");
setWindowTitle(title);
}
@ -17,26 +27,21 @@ HexDumpViewer::~HexDumpViewer()
delete ui;
}
void HexDumpViewer::setFile(GenericFile *file, quint16 offset)
void HexDumpViewer::showHexValues()
{
QString title = QString("Hex Viewer: %1").arg(file->filename());
setWindowTitle(title);
m_offset = offset;
int offset = ui->textArea->verticalScrollBar()->value();
QStringList lines;
QByteArray data = file->data();
//TODO: Align text from x00 to xFF. Currently it will start with whatever the offset is.
quint16 addr = m_offset;
for (int idx = 0; idx <= data.count()/16; idx++) {
for (int idx = 0; idx <= m_data.count()/16; idx++) {
QString line = QString("%1: ").arg(m_offset+(idx*16),4,16,QChar('0'));
for (int jdx = (idx*16); jdx < (idx*16)+16; jdx++) {
addr++;
if (jdx < data.count()) {
line += QString(" %1").arg((quint8) data[jdx],2,16,QChar('0'));
if (jdx < m_data.count()) {
line += QString(" %1").arg((quint8) m_data[jdx],2,16,QChar('0'));
if ((addr % 16) == 0) { line += " "; }
}
}
@ -44,12 +49,89 @@ void HexDumpViewer::setFile(GenericFile *file, quint16 offset)
lines.append(line);
}
}
setData(qPrintable(lines.join("\n").toUpper()));
setText(qPrintable(lines.join("<br>").toUpper()));
ui->textArea->verticalScrollBar()->setValue(offset);
}
QString HexDumpViewer::valToAppleAscii(quint8 val)
{
typedef enum {
Inverse,
Flash,
Normal,
AltUC
} Zone;
Zone zone;
QString charval;
if (val <= 0x1F) { val += 0x40; charval = QString("%1").arg(QChar(val)); zone = Inverse; } //INV UC
else if (val <= 0x3F) { val = val; charval = QString("%1").arg(QChar(val)); zone = Inverse; } // INV SP
else if (val <= 0x5F) { val = val; charval = QString("%1").arg(QChar(val)); zone = Flash; } // FL UC
else if (val <= 0x7F) { val -= 0x40; charval = QString("%1").arg(QChar(val)); zone = Flash; } // FL SP
else if (val <= 0x9F) { val -= 0x40; charval = QString("%1").arg(QChar(val)); zone = AltUC; } // NORMx UC
else if (val <= 0xBF) { val -= 0x40; charval = QString("%1").arg(QChar(val)); zone = Normal; } // NORM SP
else if (val <= 0xDF) { val -= 0x80; charval = QString("%1").arg(QChar(val)); zone = Normal; } // NORM UC
else if (val < 0xFF) { val -= 0x80; charval = QString("%1").arg(QChar(val)); zone = Normal; } // NORM LC
else if (val == 0xFF) { val = val; charval = QString("\u25a0"); zone = Normal; }
QString htmlstr = charval.toHtmlEscaped();
QString retval;
if (zone == Inverse) { retval = QString("<b>%1</b>").arg(htmlstr); }
else if (zone == Flash) { retval = QString("<i>%1</i>").arg(htmlstr);}
else if (zone == AltUC) { retval = QString("%1").arg(htmlstr);}
else /* zone == Normal */ { retval = QString("%1").arg(htmlstr);}
return retval;
}
void HexDumpViewer::showAsciiValues()
{
int offset = ui->textArea->verticalScrollBar()->value();
QStringList lines;
//TODO: Align text from x00 to xFF. Currently it will start with whatever the offset is.
quint16 addr = m_offset;
for (int idx = 0; idx <= m_data.count()/16; idx++) {
QString line = QString("%1: ").arg(m_offset+(idx*16),4,16,QChar('0'));
for (int jdx = (idx*16); jdx < (idx*16)+16; jdx++) {
addr++;
if (jdx < m_data.count()) {
//line += QString(" %1").arg((quint8) m_data[jdx],2,16,QChar('0'));
line += valToAppleAscii(m_data[jdx]);
// if ((addr % 16) == 0) { line += " "; }
}
}
if (line.length() > 6) {
lines.append(line);
}
}
setText(qPrintable(lines.join("<br>")));
ui->textArea->verticalScrollBar()->setValue(offset);
}
void HexDumpViewer::setFile(GenericFile *file, quint16 offset)
{
QString title = QString("Hex Viewer: %1").arg(file->filename());
setWindowTitle(title);
m_offset = offset;
m_data = file->data();
showHexValues();
}
void HexDumpViewer::setData(QByteArray data)
{
ui->textArea->setText(data);
ui->textArea->setHtml(data);
}
void HexDumpViewer::setText(QString text)

View File

@ -21,13 +21,20 @@ public:
~HexDumpViewer();
void setFile(GenericFile *file, quint16 offset = 0);
void setData(QByteArray data);
void setText(QString text);
public slots:
void showHexValues();
void showAsciiValues();
private:
void setText(QString text);
void setData(QByteArray data);
QString valToAppleAscii(quint8 val);
Ui::HexDumpViewer *ui;
quint16 m_offset;
QByteArray m_data;
};
#endif // HEXDUMPVIEWER_H

View File

@ -13,8 +13,77 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="gridLayout_2">
<property name="topMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<property name="verticalSpacing">
<number>1</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<property name="spacing">
<number>1</number>
</property>
<item row="0" column="0">
<widget class="QToolButton" name="hexButton">
<property name="text">
<string>Hex</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="textButton">
<property name="text">
<string>Text</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>728</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2">
<widget class="QTextBrowser" name="textArea">
<property name="font">
<font>