mirror of
https://github.com/markdavidlong/AppleSAWS.git
synced 2024-12-28 21:30:20 +00:00
Various changes.
This commit is contained in:
parent
42386ea39e
commit
d652dad5c8
@ -12,7 +12,6 @@ public:
|
||||
quint16 address() { return m_address; }
|
||||
quint16 length() { return m_length; }
|
||||
|
||||
QByteArray data() { return m_data; }
|
||||
void dump();
|
||||
|
||||
protected:
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include <QDebug>
|
||||
|
||||
#include "tracksectorlist.h"
|
||||
#include "applesoftfile.h"
|
||||
#include "binaryfile.h"
|
||||
|
||||
DiskFile::DiskFile(QString filename)
|
||||
{
|
||||
@ -14,6 +16,14 @@ DiskFile::DiskFile(QString filename)
|
||||
}
|
||||
}
|
||||
|
||||
DiskFile::~DiskFile()
|
||||
{
|
||||
foreach (GenericFile *file, m_files)
|
||||
{
|
||||
delete file;
|
||||
}
|
||||
}
|
||||
|
||||
bool DiskFile::read(QString filename)
|
||||
{
|
||||
QFile infile(filename);
|
||||
@ -68,11 +78,33 @@ QList<CatalogSector> DiskFile::getCatalogSectors()
|
||||
return retval;
|
||||
}
|
||||
|
||||
QByteArray DiskFile::getFile(FileDescriptiveEntry fde)
|
||||
GenericFile *DiskFile::getFile(FileDescriptiveEntry fde)
|
||||
{
|
||||
QByteArray retval;
|
||||
TrackSectorList tsl = getSector(fde.firstTSListSector).promoteToTrackSectorList();
|
||||
return getDataFromTrackSectorList(tsl);
|
||||
GenericFile *retval = 0;
|
||||
if (m_files.contains(fde))
|
||||
{
|
||||
retval = m_files[fde];
|
||||
}
|
||||
else
|
||||
{
|
||||
TrackSectorList tsl = getSector(fde.firstTSListSector).promoteToTrackSectorList();
|
||||
QByteArray data = getDataFromTrackSectorList(tsl);
|
||||
|
||||
if (fde.fileTypeAndFlags & ApplesoftBasicFile)
|
||||
{
|
||||
retval = new ApplesoftFile(data);
|
||||
}
|
||||
else if (fde.fileTypeAndFlags & RawBinaryFile)
|
||||
{
|
||||
retval = new BinaryFile(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = new GenericFile(data);
|
||||
}
|
||||
m_files[fde] = retval;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,12 +10,13 @@
|
||||
#include "sector.h"
|
||||
#include "vtoc.h"
|
||||
|
||||
|
||||
#include "genericfile.h"
|
||||
|
||||
class DiskFile
|
||||
{
|
||||
public:
|
||||
DiskFile(QString filename = "");
|
||||
~DiskFile();
|
||||
|
||||
bool read(QString filename);
|
||||
|
||||
@ -29,7 +30,7 @@ public:
|
||||
|
||||
QList<CatalogSector> getCatalogSectors();
|
||||
|
||||
QByteArray getFile(FileDescriptiveEntry fde);
|
||||
GenericFile *getFile(FileDescriptiveEntry fde);
|
||||
|
||||
QByteArray getDataFromTrackSectorList(TrackSectorList tsl);
|
||||
|
||||
@ -39,6 +40,7 @@ public:
|
||||
private:
|
||||
|
||||
QMap< int, QMap< int, Sector> > m_contents;
|
||||
QMap<FileDescriptiveEntry,GenericFile *> m_files;
|
||||
|
||||
};
|
||||
|
||||
|
@ -11,6 +11,10 @@ struct FileDescriptiveEntry {
|
||||
AppleString filename;
|
||||
quint16 lengthInSectors;
|
||||
|
||||
bool operator<(const FileDescriptiveEntry& f1) const {
|
||||
return f1.filename < filename;
|
||||
}
|
||||
|
||||
QString fileType() {
|
||||
if (fileTypeAndFlags & IntegerBasicFile) { return "I"; }
|
||||
if (fileTypeAndFlags & ApplesoftBasicFile) { return "A"; }
|
||||
|
@ -7,7 +7,9 @@ class GenericFile
|
||||
{
|
||||
public:
|
||||
GenericFile(QByteArray data = QByteArray());
|
||||
virtual ~GenericFile() { }
|
||||
virtual void setData(QByteArray data);
|
||||
virtual QByteArray data() { return m_data; }
|
||||
|
||||
protected:
|
||||
QByteArray m_data;
|
||||
|
@ -39,8 +39,8 @@ int main(int argc, char** argv)
|
||||
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
// w.loadDiskFile("/home/mlong/Desktop/missing_ring_good.dsk");
|
||||
w.loadDiskFile("/home/mlong/Desktop/dos.3.3.system.master.dsk");
|
||||
w.loadDiskFile("/home/mlong/Desktop/missing_ring_good.dsk");
|
||||
// w.loadDiskFile("/home/mlong/Desktop/dos.3.3.system.master.dsk");
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
|
@ -3,7 +3,11 @@
|
||||
|
||||
#include <QFileDialog>
|
||||
#include "hiresviewwidget.h"
|
||||
#include "applesoftfileviewer.h"
|
||||
#include <QMdiSubWindow>
|
||||
#include "binaryfile.h"
|
||||
#include "applesoftfile.h"
|
||||
#include <QTextDocument>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
@ -18,7 +22,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
connect(ui->action_Load_Disk_Image, SIGNAL(triggered()), SLOT(showLoadDialog()));
|
||||
connect(ui->action_Unload_Disk_Image, SIGNAL(triggered()), SLOT(unloadDiskFile()));
|
||||
connect(ui->catalogWidget,SIGNAL(itemSelected(DiskFile*,FileDescriptiveEntry)),
|
||||
SLOT(handleDiskItemSelected(DiskFile*,FileDescriptiveEntry)));
|
||||
SLOT(handleDiskItemSelectedDefaultOpen(DiskFile*,FileDescriptiveEntry)));
|
||||
|
||||
|
||||
connect(this, SIGNAL(diskFileLoading(QString, DiskFile*)),
|
||||
@ -73,15 +77,54 @@ void MainWindow::showLoadDialog()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::handleDiskItemSelected(DiskFile *disk, FileDescriptiveEntry fde)
|
||||
void MainWindow::handleDiskItemSelectedDefaultOpen(DiskFile *disk, FileDescriptiveEntry fde)
|
||||
{
|
||||
HiresViewWidget *hvwma = new HiresViewWidget(0);
|
||||
hvwma->resize(280,192);
|
||||
QString title = QString("Image: %1").arg(AppleString(fde.filename).printable().trimmed());
|
||||
hvwma->setWindowTitle(title);
|
||||
hvwma->show();
|
||||
GenericFile *file = disk->getFile(fde);
|
||||
|
||||
if (dynamic_cast<BinaryFile*>(file)) {
|
||||
if (fde.lengthInSectors == 34)
|
||||
{
|
||||
HiresViewWidget *hvwma = new HiresViewWidget(0);
|
||||
hvwma->resize(280,192);
|
||||
QString title = QString("Image: %1").arg(AppleString(fde.filename).printable().trimmed());
|
||||
hvwma->setWindowTitle(title);
|
||||
hvwma->show();
|
||||
hvwma->setData(file->data());
|
||||
}
|
||||
}
|
||||
else if (dynamic_cast<ApplesoftFile *>(file))
|
||||
{
|
||||
ApplesoftFile *abf = dynamic_cast<ApplesoftFile *>(file);
|
||||
ApplesoftFileViewer *afv = new ApplesoftFileViewer(0);
|
||||
QString title = QString("AppleSoft Viewer: %1").arg(AppleString(fde.filename).printable().trimmed());
|
||||
afv->setWindowTitle(title);
|
||||
QStringList strings;
|
||||
foreach (ApplesoftLine line, abf->detokenized())
|
||||
{
|
||||
QString linestring = QString("%1 %2").arg(line.linenum,5,10,QChar(' ')).arg(line.detokenized_line);
|
||||
strings.append(linestring);
|
||||
}
|
||||
QString fulltext = Qt::convertFromPlainText(strings.join("\n"));
|
||||
fulltext.replace("POKE","<font color=\"purple\">POKE</font>");
|
||||
fulltext.replace("PEEK","<font color=\"purple\">PEEK</font>");
|
||||
fulltext.replace("CALL","<font color=\"blue\">CALL</font>");
|
||||
fulltext.replace("GOTO","<b><font color=\"green\">GOTO</font></b>");
|
||||
fulltext.replace("GOSUB","<b><font color=\"green\">GOSUB</font></b>");
|
||||
// fulltext.replace("0","<font color=\"orange\">0</font>");
|
||||
// fulltext.replace("1","<font color=\"orange\">1</font>");
|
||||
// fulltext.replace("2","<font color=\"orange\">2</font>");
|
||||
// fulltext.replace("3","<font color=\"orange\">3</font>");
|
||||
// fulltext.replace("4","<font color=\"orange\">4</font>");
|
||||
// fulltext.replace("5","<font color=\"orange\">5</font>");
|
||||
// fulltext.replace("6","<font color=\"orange\">6</font>");
|
||||
// fulltext.replace("7","<font color=\"orange\">7</font>");
|
||||
// fulltext.replace("8","<font color=\"orange\">8</font>");
|
||||
// fulltext.replace("9","<font color=\"orange\">9</font>");
|
||||
fulltext.replace("RETURN","RETURN<p>");
|
||||
|
||||
afv->setText(fulltext);
|
||||
afv->show();
|
||||
}
|
||||
|
||||
QByteArray data = disk->getFile(fde).mid(4);
|
||||
hvwma->setData(data);
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public slots:
|
||||
void showLoadDialog();
|
||||
|
||||
private slots:
|
||||
void handleDiskItemSelected(DiskFile *disk, FileDescriptiveEntry fde);
|
||||
void handleDiskItemSelectedDefaultOpen(DiskFile *disk, FileDescriptiveEntry fde);
|
||||
|
||||
signals:
|
||||
void diskFileLoading(QString filename, DiskFile *file);
|
||||
|
Loading…
Reference in New Issue
Block a user