mirror of
https://github.com/markdavidlong/AppleSAWS.git
synced 2024-12-26 09:29:39 +00:00
Added some debugging and some safeguards for not overrunning boundaries when loading corrupt disk images. Fixed default font size on sector viewer hexdump.
This commit is contained in:
parent
7002fc09ad
commit
659780d425
@ -3,13 +3,14 @@
|
|||||||
|
|
||||||
CatalogSector::CatalogSector(Sector *data)
|
CatalogSector::CatalogSector(Sector *data)
|
||||||
{
|
{
|
||||||
|
qDebug() << "### Start CatalogSector ctor";
|
||||||
m_data = data;
|
m_data = data;
|
||||||
|
|
||||||
m_next = TSPair(0,0);
|
m_next = TSPair(0,0);
|
||||||
|
|
||||||
TSPair next(m_data->rawData()[0x01],m_data->rawData()[0x02]);
|
TSPair next(m_data->rawData()[0x01],m_data->rawData()[0x02]);
|
||||||
|
|
||||||
if (next.isValid())
|
if (next.isValid() && next.track() == 17)
|
||||||
{
|
{
|
||||||
next.dump();
|
next.dump();
|
||||||
qDebug("Next track sector is valid.");
|
qDebug("Next track sector is valid.");
|
||||||
@ -27,10 +28,15 @@ CatalogSector::CatalogSector(Sector *data)
|
|||||||
{
|
{
|
||||||
FileDescriptiveEntry fde = makeFDE(idx*0x23+0x0B);
|
FileDescriptiveEntry fde = makeFDE(idx*0x23+0x0B);
|
||||||
if (fde.firstTSListSector() != TSPair(0,0)) {
|
if (fde.firstTSListSector() != TSPair(0,0)) {
|
||||||
m_fdes.append(fde);
|
if (fde.firstTSListSector().isValid())
|
||||||
|
{
|
||||||
|
m_fdes.append(fde);
|
||||||
|
}
|
||||||
|
else qDebug() << "Not appending invalid TSPair.";
|
||||||
}
|
}
|
||||||
else { qWarning("fde.firstTSListSector() is 0,0"); }
|
else { qWarning("fde.firstTSListSector() is 0,0"); }
|
||||||
}
|
}
|
||||||
|
qDebug() << "### End CatalogSector ctor";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CatalogSector::dumpFDEs() {
|
void CatalogSector::dumpFDEs() {
|
||||||
@ -53,6 +59,11 @@ FileDescriptiveEntry CatalogSector::makeFDE(int offset)
|
|||||||
fde.lengthInSectors = makeWord( m_data->rawData()[offset + 0x21],
|
fde.lengthInSectors = makeWord( m_data->rawData()[offset + 0x21],
|
||||||
m_data->rawData()[offset + 0x22]);
|
m_data->rawData()[offset + 0x22]);
|
||||||
|
|
||||||
|
if (fde.lengthInSectors > 16*35)
|
||||||
|
{
|
||||||
|
fde.lengthInSectors = -1;
|
||||||
|
}
|
||||||
|
|
||||||
for (int idx = 0x03; idx <= 0x20; idx++) {
|
for (int idx = 0x03; idx <= 0x20; idx++) {
|
||||||
fde.filename.append(m_data->rawData()[idx+offset]);
|
fde.filename.append(m_data->rawData()[idx+offset]);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ bool DiskFile::read(QString filename)
|
|||||||
char buffer[256];
|
char buffer[256];
|
||||||
if (qds.readRawData(buffer,256) == 256)
|
if (qds.readRawData(buffer,256) == 256)
|
||||||
{
|
{
|
||||||
qDebug() << "Track " << track << " Sector " << sector;
|
qDebug() << "Track " << track << " Sector " << sector;
|
||||||
Sector sec;
|
Sector sec;
|
||||||
sec.setTrackSector(track,sector);
|
sec.setTrackSector(track,sector);
|
||||||
sec.setData(QByteArray(buffer,256));
|
sec.setData(QByteArray(buffer,256));
|
||||||
@ -88,6 +88,8 @@ VTOC DiskFile::getVTOC()
|
|||||||
|
|
||||||
QList<CatalogSector> DiskFile::getCatalogSectors()
|
QList<CatalogSector> DiskFile::getCatalogSectors()
|
||||||
{
|
{
|
||||||
|
qDebug() << "### Start getCatalogSector";
|
||||||
|
|
||||||
QList<CatalogSector> retval;
|
QList<CatalogSector> retval;
|
||||||
VTOC vtoc = getVTOC();
|
VTOC vtoc = getVTOC();
|
||||||
TSPair ts = vtoc.firstCatalogSector();
|
TSPair ts = vtoc.firstCatalogSector();
|
||||||
@ -99,6 +101,8 @@ QList<CatalogSector> DiskFile::getCatalogSectors()
|
|||||||
cs = getSector(ts).promoteToCatalogSector();
|
cs = getSector(ts).promoteToCatalogSector();
|
||||||
retval.append(cs);
|
retval.append(cs);
|
||||||
}
|
}
|
||||||
|
qDebug() << "### End getCatalogSector";
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,8 +115,19 @@ GenericFile *DiskFile::getFile(FileDescriptiveEntry fde)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TrackSectorList tsl = getSector(fde.firstTSListSector()).promoteToTrackSectorList();
|
|
||||||
|
|
||||||
|
if (!fde.firstTSListSector().isValid())
|
||||||
|
{
|
||||||
|
qWarning(" Not returning a file from invalid TSList!");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
TrackSectorList tsl = getSector(fde.firstTSListSector()).promoteToTrackSectorList();
|
||||||
|
if (!fde.firstTSListSector().isValid())
|
||||||
|
{
|
||||||
|
qWarning(" Not returning a file from invalid TSList!");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
QByteArray data = getDataFromTrackSectorList(tsl);
|
QByteArray data = getDataFromTrackSectorList(tsl);
|
||||||
|
|
||||||
if (fde.fileType() == "A")
|
if (fde.fileType() == "A")
|
||||||
@ -152,11 +167,19 @@ QByteArray DiskFile::getDataFromTrackSectorList(TrackSectorList tsl)
|
|||||||
|
|
||||||
foreach(TSPair pair, tsl.getDataTSPairs())
|
foreach(TSPair pair, tsl.getDataTSPairs())
|
||||||
{
|
{
|
||||||
|
if (pair.isValid())
|
||||||
|
{
|
||||||
Sector sec = getSector(pair);
|
Sector sec = getSector(pair);
|
||||||
retval.append(sec.rawData());
|
retval.append(sec.rawData());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning("Not adding data from invalid TSList");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsl.getNextTSList() != TSPair(0,0)) {
|
auto next = tsl.getNextTSList();
|
||||||
|
if (next.isValid() && next != TSPair(0,0)) {
|
||||||
TrackSectorList nextTsl = getSector(tsl.getNextTSList()).promoteToTrackSectorList();
|
TrackSectorList nextTsl = getSector(tsl.getNextTSList()).promoteToTrackSectorList();
|
||||||
retval.append(getDataFromTrackSectorList(nextTsl));
|
retval.append(getDataFromTrackSectorList(nextTsl));
|
||||||
}
|
}
|
||||||
@ -164,7 +187,9 @@ QByteArray DiskFile::getDataFromTrackSectorList(TrackSectorList tsl)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<FileDescriptiveEntry> DiskFile::getAllFDEs() {
|
QList<FileDescriptiveEntry> DiskFile::getAllFDEs()
|
||||||
|
{
|
||||||
|
qDebug() << "### Start getAllFDEs";
|
||||||
QList<FileDescriptiveEntry> retval;
|
QList<FileDescriptiveEntry> retval;
|
||||||
|
|
||||||
QList<CatalogSector> sectors = getCatalogSectors();
|
QList<CatalogSector> sectors = getCatalogSectors();
|
||||||
@ -174,6 +199,7 @@ QList<FileDescriptiveEntry> DiskFile::getAllFDEs() {
|
|||||||
QList<FileDescriptiveEntry> fdes = cs.getFDEs();
|
QList<FileDescriptiveEntry> fdes = cs.getFDEs();
|
||||||
retval.append(fdes);
|
retval.append(fdes);
|
||||||
}
|
}
|
||||||
|
qDebug() << "### End getAllFDEs";
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ TrackSectorList::TrackSectorList(Sector *data)
|
|||||||
for (int idx = 0x0C; idx < 0xff; idx+=2)
|
for (int idx = 0x0C; idx < 0xff; idx+=2)
|
||||||
{
|
{
|
||||||
TSPair ts(m_data->rawData()[idx],m_data->rawData()[idx+1]);
|
TSPair ts(m_data->rawData()[idx],m_data->rawData()[idx+1]);
|
||||||
if (ts == TSPair(0,0)) {
|
if (ts == TSPair(0,0) && ts.isValid()) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
m_ts_pairs_for_data.append(ts);
|
m_ts_pairs_for_data.append(ts);
|
||||||
|
@ -12,6 +12,7 @@ VTOC::VTOC(Sector *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TSPair VTOC::firstCatalogSector() {
|
TSPair VTOC::firstCatalogSector() {
|
||||||
|
// return TSPair(0x11,0x0f); // Force to look at the normal location
|
||||||
return TSPair(m_data->rawData()[0x01], m_data->rawData()[0x02]);
|
return TSPair(m_data->rawData()[0x01], m_data->rawData()[0x02]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,44 +39,44 @@ void CatalogWidget::prepForNewDisk(QString filename, DiskFile *disk)
|
|||||||
|
|
||||||
QString CatalogWidget::createToolTip(FileDescriptiveEntry &fde) {
|
QString CatalogWidget::createToolTip(FileDescriptiveEntry &fde) {
|
||||||
QString retval;
|
QString retval;
|
||||||
retval += AppleString(fde.filename).printable().trimmed() + "\n";
|
retval += AppleString(fde.filename).printable().trimmed() +
|
||||||
|
(fde.deleted?"(Deleted)":"") + "\n";
|
||||||
retval += QString("Type: %1\n").arg(fde.fileType());
|
retval += QString("Type: %1\n").arg(fde.fileType());
|
||||||
retval += QString("Sectors: %1 (%2 bytes)\n")
|
retval += QString("Sectors: %1 (%2 bytes)\n")
|
||||||
.arg(fde.lengthInSectors)
|
.arg(fde.lengthInSectors)
|
||||||
.arg(fde.lengthInSectors*256);
|
.arg(fde.lengthInSectors*256);
|
||||||
retval += QString("%1\n").arg(fde.isLocked()?"Locked":"Unlocked");
|
retval += QString("%1\n").arg(fde.isLocked()?"Locked":"Unlocked");
|
||||||
|
|
||||||
GenericFile *file = m_disk->getFile(fde);
|
GenericFile *file = m_disk->getFile(fde);
|
||||||
|
if (!file) { return ""; }
|
||||||
quint16 address = file->address();
|
quint16 address = file->address();
|
||||||
retval += QString("Address: $%1 (%2)\n").arg((quint16) (address),4,16,QChar('0'))
|
retval += QString("Address: $%1 (%2)\n").arg((quint16) (address),4,16,QChar('0'))
|
||||||
.arg(address);
|
.arg(address);
|
||||||
|
|
||||||
if (dynamic_cast<BinaryFile*>(file)) {
|
if (dynamic_cast<BinaryFile*>(file)) {
|
||||||
BinaryFile *binfile = dynamic_cast<BinaryFile*>(file);
|
BinaryFile *binfile = dynamic_cast<BinaryFile*>(file);
|
||||||
quint16 length = binfile->length();
|
quint16 length = binfile->length();
|
||||||
|
|
||||||
retval += QString("Length: $%1 (%2)\n").arg((quint16) (length),4,16,QChar('0'))
|
retval += QString("Length: $%1 (%2)\n").arg((quint16) (length),4,16,QChar('0'))
|
||||||
.arg(length);
|
.arg(length);
|
||||||
} else if (dynamic_cast<ApplesoftFile*>(file)) {
|
} else if (dynamic_cast<ApplesoftFile*>(file)) {
|
||||||
ApplesoftFile *asfile = dynamic_cast<ApplesoftFile*>(file);
|
ApplesoftFile *asfile = dynamic_cast<ApplesoftFile*>(file);
|
||||||
quint16 length = asfile->length();
|
quint16 length = asfile->length();
|
||||||
retval += QString("Length: $%1 (%2)\n").arg((quint16) (length),4,16,QChar('0'))
|
retval += QString("Length: $%1 (%2)\n").arg((quint16) (length),4,16,QChar('0'))
|
||||||
.arg(length);
|
.arg(length);
|
||||||
quint16 uabytes = asfile->extraData().length();
|
quint16 uabytes = asfile->extraData().length();
|
||||||
if (uabytes) {
|
if (uabytes) {
|
||||||
retval += QString("Unaccounted Bytes: $%1 (%2)\n").arg((quint16) (uabytes),4,16,QChar('0'))
|
retval += QString("Unaccounted Bytes: $%1 (%2)\n").arg((quint16) (uabytes),4,16,QChar('0'))
|
||||||
.arg(uabytes);
|
.arg(uabytes);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
retval += QString("Data Length: $%1 (%2)\n").arg((quint16) (file->data().length()),4,16,QChar('0'))
|
retval += QString("Data Length: $%1 (%2)\n").arg((quint16) (file->data().length()),4,16,QChar('0'))
|
||||||
.arg(file->data().length());
|
.arg(file->data().length());
|
||||||
}
|
}
|
||||||
|
// delete file;
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CatalogWidget::processNewlyLoadedDisk(QString diskfilename, DiskFile *disk)
|
void CatalogWidget::processNewlyLoadedDisk(QString diskfilename, DiskFile *disk)
|
||||||
{
|
{
|
||||||
|
qDebug() << "### Start processNewlyLoadedDisk";
|
||||||
if (m_disk == disk) {
|
if (m_disk == disk) {
|
||||||
QUrl url = QUrl::fromLocalFile(diskfilename);
|
QUrl url = QUrl::fromLocalFile(diskfilename);
|
||||||
QString shortfilename = url.fileName();
|
QString shortfilename = url.fileName();
|
||||||
@ -85,6 +85,7 @@ void CatalogWidget::processNewlyLoadedDisk(QString diskfilename, DiskFile *disk)
|
|||||||
ui->volume_label->setText(shortfilename);
|
ui->volume_label->setText(shortfilename);
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
foreach(FileDescriptiveEntry fde, m_disk->getAllFDEs()) {
|
foreach(FileDescriptiveEntry fde, m_disk->getAllFDEs()) {
|
||||||
|
qDebug() << " Processing FDE# " << idx;
|
||||||
QString filetype = fde.fileType();
|
QString filetype = fde.fileType();
|
||||||
QString filename = AppleString(fde.filename).printable().trimmed();
|
QString filename = AppleString(fde.filename).printable().trimmed();
|
||||||
quint16 size = fde.lengthInSectors;
|
quint16 size = fde.lengthInSectors;
|
||||||
@ -92,7 +93,6 @@ void CatalogWidget::processNewlyLoadedDisk(QString diskfilename, DiskFile *disk)
|
|||||||
QString sizeStr = QString("%1").arg(size,5,10,QChar(' ')).toUpper();
|
QString sizeStr = QString("%1").arg(size,5,10,QChar(' ')).toUpper();
|
||||||
QString text = QString("%1 %2 %3 %4").arg(locked?"*":" ").arg(sizeStr).arg(filetype).arg(filename);
|
QString text = QString("%1 %2 %3 %4").arg(locked?"*":" ").arg(sizeStr).arg(filetype).arg(filename);
|
||||||
QListWidgetItem *item = new QListWidgetItem(text);
|
QListWidgetItem *item = new QListWidgetItem(text);
|
||||||
|
|
||||||
if (filetype == "A") { item->setForeground(Qt::blue); }
|
if (filetype == "A") { item->setForeground(Qt::blue); }
|
||||||
else if (filetype == "I") { item->setForeground(Qt::darkYellow); }
|
else if (filetype == "I") { item->setForeground(Qt::darkYellow); }
|
||||||
else if (filetype == "B") { item->setForeground(Qt::darkGreen); }
|
else if (filetype == "B") { item->setForeground(Qt::darkGreen); }
|
||||||
@ -102,32 +102,35 @@ void CatalogWidget::processNewlyLoadedDisk(QString diskfilename, DiskFile *disk)
|
|||||||
else if (filetype == "a") { item->setForeground(Qt::darkBlue); }
|
else if (filetype == "a") { item->setForeground(Qt::darkBlue); }
|
||||||
else if (filetype == "b") { item->setForeground(Qt::darkMagenta); }
|
else if (filetype == "b") { item->setForeground(Qt::darkMagenta); }
|
||||||
else { item->setForeground(Qt::black); }
|
else { item->setForeground(Qt::black); }
|
||||||
|
|
||||||
item->setToolTip(createToolTip(fde));
|
item->setToolTip(createToolTip(fde));
|
||||||
item->setData(0x0100,idx);
|
item->setData(0x0100,idx);
|
||||||
ui->catalog_list->addItem(item);
|
|
||||||
|
if (!fde.deleted) ui->catalog_list->addItem(item);
|
||||||
|
|
||||||
QRect rect = fm.boundingRect(text);
|
QRect rect = fm.boundingRect(text);
|
||||||
if (rect.width() > maxrect.width()) {
|
if (rect.width() > maxrect.width()) {
|
||||||
maxrect = rect;
|
maxrect = rect;
|
||||||
}
|
}
|
||||||
idx++;
|
idx++;
|
||||||
|
qDebug() << " Done Processing FDE# " << idx-1;
|
||||||
}
|
}
|
||||||
// QFont italfont = ui->catalog_list->font();
|
// QFont italfont = ui->catalog_list->font();
|
||||||
// italfont.setItalic(true);
|
// italfont.setItalic(true);
|
||||||
// QListWidgetItem *item = new QListWidgetItem("Boot Sector");
|
// QListWidgetItem *item = new QListWidgetItem("Boot Sector");
|
||||||
// item->setForeground(Qt::black);
|
// item->setForeground(Qt::black);
|
||||||
// item->setFont(italfont);
|
// item->setFont(italfont);
|
||||||
// item->setData(0x0100,-1);
|
// item->setData(0x0100,-1);
|
||||||
// ui->catalog_list->addItem(item);
|
// ui->catalog_list->addItem(item);
|
||||||
|
|
||||||
// item = new QListWidgetItem("DOS Image");
|
// item = new QListWidgetItem("DOS Image");
|
||||||
// item->setForeground(Qt::black);
|
// item->setForeground(Qt::black);
|
||||||
// item->setFont(italfont);
|
// item->setFont(italfont);
|
||||||
// item->setData(0x0100,-2);
|
// item->setData(0x0100,-2);
|
||||||
// ui->catalog_list->addItem(item);
|
// ui->catalog_list->addItem(item);
|
||||||
|
|
||||||
ui->catalog_list->resize(maxrect.width(),ui->catalog_list->size().height());
|
ui->catalog_list->resize(maxrect.width(),ui->catalog_list->size().height());
|
||||||
}
|
}
|
||||||
|
qDebug() << "### End processNewlyLoadedDisk";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CatalogWidget::unloadDisk(DiskFile *disk)
|
void CatalogWidget::unloadDisk(DiskFile *disk)
|
||||||
@ -145,7 +148,7 @@ void CatalogWidget::itemDoubleClicked(QListWidgetItem *item)
|
|||||||
if (idx >= 0)
|
if (idx >= 0)
|
||||||
{
|
{
|
||||||
FileDescriptiveEntry fde = m_disk->getAllFDEs()[idx];
|
FileDescriptiveEntry fde = m_disk->getAllFDEs()[idx];
|
||||||
// qDebug() << "Default File " << AppleString(fde.filename).printable().trimmed();
|
// qDebug() << "Default File " << AppleString(fde.filename).printable().trimmed();
|
||||||
emit openWithDefaultViewer(m_disk,fde);
|
emit openWithDefaultViewer(m_disk,fde);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -165,6 +168,6 @@ void CatalogWidget::itemClicked(QListWidgetItem *item)
|
|||||||
{
|
{
|
||||||
int idx = item->data(0x0100).toInt();
|
int idx = item->data(0x0100).toInt();
|
||||||
FileDescriptiveEntry fde = m_disk->getAllFDEs()[idx];
|
FileDescriptiveEntry fde = m_disk->getAllFDEs()[idx];
|
||||||
// qDebug() << "Default File " << AppleString(fde.filename).printable().trimmed();
|
// qDebug() << "Default File " << AppleString(fde.filename).printable().trimmed();
|
||||||
emit newFileSelected(m_disk,fde);
|
emit newFileSelected(m_disk,fde);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,8 @@ void DiskExplorer::initUi()
|
|||||||
m_frame->setMinimumSize(200,200);
|
m_frame->setMinimumSize(200,200);
|
||||||
QGridLayout *frameLayout = new QGridLayout(0);
|
QGridLayout *frameLayout = new QGridLayout(0);
|
||||||
m_frame->setLayout(frameLayout);
|
m_frame->setLayout(frameLayout);
|
||||||
m_hdv = new HexDumpViewer(this);
|
m_hdv = new HexDumpViewer(this, 10);
|
||||||
|
|
||||||
frameLayout->addWidget(m_hdv);
|
frameLayout->addWidget(m_hdv);
|
||||||
|
|
||||||
m_gridLayout->setColumnStretch(0,4);
|
m_gridLayout->setColumnStretch(0,4);
|
||||||
@ -196,7 +197,10 @@ void DiskExplorer::showLoadDialog(bool parentToThis)
|
|||||||
|
|
||||||
void DiskExplorer::handleDiskItemSelectedDefaultOpen(DiskFile *disk, FileDescriptiveEntry fde)
|
void DiskExplorer::handleDiskItemSelectedDefaultOpen(DiskFile *disk, FileDescriptiveEntry fde)
|
||||||
{
|
{
|
||||||
|
if (fde.deleted) { return; }
|
||||||
|
|
||||||
GenericFile *file = disk->getFile(fde);
|
GenericFile *file = disk->getFile(fde);
|
||||||
|
|
||||||
file->setFilename(AppleString(fde.filename).printable().trimmed());
|
file->setFilename(AppleString(fde.filename).printable().trimmed());
|
||||||
|
|
||||||
ViewerBase *vb = new ViewerBase();
|
ViewerBase *vb = new ViewerBase();
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
|
||||||
DiskExplorerMapWidget::DiskExplorerMapWidget(int numtracks, int numsectors, QWidget *parent) : QWidget(parent)
|
DiskExplorerMapWidget::DiskExplorerMapWidget(int numtracks, int numsectors, QWidget *parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
@ -129,9 +130,9 @@ void DiskExplorerMapWidget::handleButtonCheck(int track, int sector, bool checke
|
|||||||
emit showSectorData(data,track,sector,QVariant());
|
emit showSectorData(data,track,sector,QVariant());
|
||||||
m_trackSectorLabel->setText(
|
m_trackSectorLabel->setText(
|
||||||
QString("Track: %1 Sector: %2 (%3)")
|
QString("Track: %1 Sector: %2 (%3)")
|
||||||
.arg(track)
|
.arg(track)
|
||||||
.arg(sector)
|
.arg(sector)
|
||||||
.arg(getSectorDescription(track,sector)));
|
.arg(getSectorDescription(track,sector)));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
emit showSectorData(QByteArray(),-1,-1,QVariant());
|
emit showSectorData(QByteArray(),-1,-1,QVariant());
|
||||||
@ -242,6 +243,7 @@ QGroupBox *DiskExplorerMapWidget::makeKeyWidget()
|
|||||||
|
|
||||||
DEButton *DiskExplorerMapWidget::buttonAt(int track, int sector)
|
DEButton *DiskExplorerMapWidget::buttonAt(int track, int sector)
|
||||||
{
|
{
|
||||||
|
qDebug() << "Button At:" << track << "," << sector;
|
||||||
if (track >= m_numtracks || sector >= m_numsectors)
|
if (track >= m_numtracks || sector >= m_numsectors)
|
||||||
{
|
{
|
||||||
if (track >= m_numtracks) { track = 0; }
|
if (track >= m_numtracks) { track = 0; }
|
||||||
@ -293,6 +295,7 @@ void DiskExplorerMapWidget::mapDiskToButtons()
|
|||||||
int catseccount = 0;
|
int catseccount = 0;
|
||||||
foreach (CatalogSector cs, m_disk->getCatalogSectors())
|
foreach (CatalogSector cs, m_disk->getCatalogSectors())
|
||||||
{
|
{
|
||||||
|
// qDebug() << "LOOP 1";
|
||||||
Sector *sec = cs.getSector();
|
Sector *sec = cs.getSector();
|
||||||
|
|
||||||
QString desc = QString("Catalog Sector #%1").arg(++catseccount);
|
QString desc = QString("Catalog Sector #%1").arg(++catseccount);
|
||||||
@ -303,55 +306,76 @@ void DiskExplorerMapWidget::mapDiskToButtons()
|
|||||||
|
|
||||||
foreach(FileDescriptiveEntry fde, cs.getFDEs())
|
foreach(FileDescriptiveEntry fde, cs.getFDEs())
|
||||||
{
|
{
|
||||||
|
// qDebug() << "LOOP 2";
|
||||||
Sector *s = &(m_disk->getSector(fde.firstTSListSector()));
|
Sector *s = &(m_disk->getSector(fde.firstTSListSector()));
|
||||||
TrackSectorList tsl(s);
|
TrackSectorList tsl(s);
|
||||||
|
|
||||||
int tsltr = fde.firstTSListSector().track();
|
int tsltr = fde.firstTSListSector().track();
|
||||||
int tslse = fde.firstTSListSector().sector();
|
int tslse = fde.firstTSListSector().sector();
|
||||||
|
|
||||||
int tslcount = 0;
|
if (!fde.firstTSListSector().isValid())
|
||||||
while (tsltr != 0)
|
|
||||||
{
|
{
|
||||||
|
qDebug() << "Invalid first tse entry. Skipping TSList.";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tslcount = 0;
|
||||||
|
while (tsltr != 0 /*&& tslcount < 1*/)
|
||||||
|
{
|
||||||
|
qDebug() << "LOOP 3";
|
||||||
tslcount++;
|
tslcount++;
|
||||||
|
|
||||||
buttonAt(tsltr,tslse)->setBgColor(m_tsListColor);
|
buttonAt(tsltr,tslse)->setBgColor(m_tsListColor);
|
||||||
buttonAt(tsltr,tslse)->setText(QString("%1").arg(idx));
|
buttonAt(tsltr,tslse)->setText(QString("%1").arg(idx));
|
||||||
//qDebug() << "Button" << idx << "=" << tsltr << "," << tslse << " " << fde.filename.printable() << "TSL";
|
// qDebug() << "Button" << idx << "=" << tsltr << "," << tslse << " " << fde.filename.printable() << "TSL";
|
||||||
|
|
||||||
QString description = QString("T/S List #%1 for %2").arg(tslcount).arg(fde.filename.printable());
|
QString description = QString("T/S List #%1 for %2").arg(tslcount).arg(fde.filename.printable());
|
||||||
m_sectorDescriptions.insert(DETSPair(tsltr,tslse),description);
|
m_sectorDescriptions.insert(DETSPair(tsltr,tslse),description);
|
||||||
|
|
||||||
idx++;
|
idx++;
|
||||||
|
|
||||||
|
bool valid = true;
|
||||||
|
|
||||||
int sectorcount = 0;
|
int sectorcount = 0;
|
||||||
foreach(TSPair tsp, tsl.getDataTSPairs())
|
auto pairs = tsl.getDataTSPairs();
|
||||||
|
// int jdx = 0;
|
||||||
|
/*if (false) */ foreach(TSPair tsp, pairs)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// qDebug() << "LOOP 4" << jdx++ << "of" << pairs.count() << "pairs";
|
||||||
|
//QCoreApplication::processEvents(QEventLoop::AllEvents);
|
||||||
int se = tsp.sector();
|
int se = tsp.sector();
|
||||||
int tr = tsp.track();
|
int tr = tsp.track();
|
||||||
|
|
||||||
QString description = QString("Sector #%1.%2 of %3")
|
if (valid && tsp.isValid() && (se != 0 && tr != 0)) {
|
||||||
.arg(tslcount)
|
QString description = QString("Sector #%1.%2 of %3")
|
||||||
.arg(++sectorcount)
|
.arg(tslcount)
|
||||||
.arg(fde.filename.printable());
|
.arg(++sectorcount)
|
||||||
m_sectorDescriptions.insert(DETSPair(tr,se),description);
|
.arg(fde.filename.printable());
|
||||||
|
m_sectorDescriptions.insert(DETSPair(tr,se),description);
|
||||||
|
|
||||||
QColor color;
|
QColor color;
|
||||||
if (fde.fileType() == "I") color = m_intBasicFileColor;
|
if (fde.fileType() == "I") color = m_intBasicFileColor;
|
||||||
else if (fde.fileType() == "A") color = m_applesoftFileColor;
|
else if (fde.fileType() == "A") color = m_applesoftFileColor;
|
||||||
else if (fde.fileType() == "R") color = m_reloFileColor;
|
else if (fde.fileType() == "R") color = m_reloFileColor;
|
||||||
else if (fde.fileType() == "B") color = m_binaryFileColor;
|
else if (fde.fileType() == "B") color = m_binaryFileColor;
|
||||||
else if (fde.fileType() == "S") color = m_typeSFileColor;
|
else if (fde.fileType() == "S") color = m_typeSFileColor;
|
||||||
else if (fde.fileType() == "T") color = m_textFileColor;
|
else if (fde.fileType() == "T") color = m_textFileColor;
|
||||||
else if (fde.fileType() == "a") color = m_typeAFileColor;
|
else if (fde.fileType() == "a") color = m_typeAFileColor;
|
||||||
else if (fde.fileType() == "b") color = m_typeBFileColor;
|
else if (fde.fileType() == "b") color = m_typeBFileColor;
|
||||||
else qDebug() << "Unknown file type: " << fde.fileType();
|
else qDebug() << "Unknown file type: " << fde.fileType();
|
||||||
buttonAt(tr,se)->setBgColor(color);
|
buttonAt(tr,se)->setBgColor(color);
|
||||||
setButtonText(tr,se,QString("%1").arg(idx));
|
setButtonText(tr,se,QString("%1").arg(idx));
|
||||||
//qDebug() << "Button" << idx << "=" << tr << "," << se << " " << fde.filename.printable();
|
qDebug() << "Button" << idx << "=" << tr << "," << se << " " << fde.filename.printable();
|
||||||
// fde.dump();
|
fde.dump();
|
||||||
|
}
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
tsltr = tsl.getNextTSList().track();
|
tsltr = tsl.getNextTSList().track();
|
||||||
tslse = tsl.getNextTSList().sector();
|
tslse = tsl.getNextTSList().sector();
|
||||||
|
|
||||||
|
valid = tsl.getNextTSList().isValid();
|
||||||
|
|
||||||
tsl = m_disk->getSector(tsl.getNextTSList()).promoteToTrackSectorList();
|
tsl = m_disk->getSector(tsl.getNextTSList()).promoteToTrackSectorList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ ApplesoftFileViewer::ApplesoftFileViewer(QWidget *parent) :
|
|||||||
m_afdv = Q_NULLPTR;
|
m_afdv = Q_NULLPTR;
|
||||||
|
|
||||||
|
|
||||||
// QFont textAreaFont("PR Number 3");
|
QFont textAreaFont("PR Number 3");
|
||||||
QFont textAreaFont("Print Char 21");
|
// QFont textAreaFont("Print Char 21");
|
||||||
// textAreaFont.setStyleHint(QFont::Monospace);
|
// textAreaFont.setStyleHint(QFont::Monospace);
|
||||||
textAreaFont.setPointSize(12);
|
textAreaFont.setPointSize(12);
|
||||||
|
|
||||||
|
@ -10,18 +10,21 @@
|
|||||||
#include "applestring.h"
|
#include "applestring.h"
|
||||||
#include <QChar>
|
#include <QChar>
|
||||||
|
|
||||||
HexDumpViewer::HexDumpViewer(QWidget *parent) :
|
HexDumpViewer::HexDumpViewer(QWidget *parent, int defaultFontSize) :
|
||||||
FileViewerInterface(parent),
|
FileViewerInterface(parent),
|
||||||
ui(new Ui::HexDumpViewer)
|
ui(new Ui::HexDumpViewer)
|
||||||
{
|
{
|
||||||
|
m_defaultFontSize = defaultFontSize;
|
||||||
QFont textAreaFont;
|
QFont textAreaFont;
|
||||||
textAreaFont.setStyleHint(QFont::Monospace);
|
textAreaFont.setStyleHint(QFont::Monospace);
|
||||||
|
|
||||||
|
if (defaultFontSize > 0) { textAreaFont.setPointSize(10); }
|
||||||
|
|
||||||
m_file = Q_NULLPTR;
|
m_file = Q_NULLPTR;
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
setTextFont(fontFromSettings("HexDumpViewer.textFont", textAreaFont));
|
setTextFont(fontFromSettings("HexDumpViewer.textFont", textAreaFont),
|
||||||
|
defaultFontSize);
|
||||||
m_offset = 0;
|
m_offset = 0;
|
||||||
|
|
||||||
|
|
||||||
@ -184,9 +187,13 @@ bool HexDumpViewer::optionsMenuItems(QMenu *menu)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HexDumpViewer::setTextFont(const QFont &font)
|
void HexDumpViewer::setTextFont(const QFont &font, int forcedFontSize)
|
||||||
{
|
{
|
||||||
ui->textArea->setFont(font);
|
QFont myfont = font;
|
||||||
|
if (forcedFontSize > 0) { myfont.setPointSize(forcedFontSize); }
|
||||||
|
qDebug() << "######################### Setting text font size " << myfont.pointSize();
|
||||||
|
ui->textArea->setFont(myfont);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HexDumpViewer::setData(QByteArray data)
|
void HexDumpViewer::setData(QByteArray data)
|
||||||
|
@ -18,7 +18,7 @@ class HexDumpViewer : public FileViewerInterface
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit HexDumpViewer(QWidget *parent = 0);
|
explicit HexDumpViewer(QWidget *parent = 0, int defaultFontSize = -1);
|
||||||
~HexDumpViewer();
|
~HexDumpViewer();
|
||||||
|
|
||||||
void setFile(GenericFile *file) { setFile(file,0); }
|
void setFile(GenericFile *file) { setFile(file,0); }
|
||||||
@ -36,14 +36,14 @@ public slots:
|
|||||||
void doExport();
|
void doExport();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setTextFont(const QFont &font);
|
void setTextFont(const QFont &font, int forcedFontSize = -1);
|
||||||
private:
|
private:
|
||||||
void setText(QString text);
|
void setText(QString text);
|
||||||
void setData(QByteArray data);
|
void setData(QByteArray data);
|
||||||
QString valToAppleAscii(quint8 val);
|
QString valToAppleAscii(quint8 val);
|
||||||
|
|
||||||
QAction *m_setFontAction;
|
QAction *m_setFontAction;
|
||||||
|
int m_defaultFontSize;
|
||||||
Ui::HexDumpViewer *ui;
|
Ui::HexDumpViewer *ui;
|
||||||
|
|
||||||
quint16 m_offset;
|
quint16 m_offset;
|
||||||
|
@ -24,7 +24,13 @@
|
|||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="0" column="0" colspan="2">
|
||||||
<widget class="QTextBrowser" name="textArea"/>
|
<widget class="QTextBrowser" name="textArea">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -6,10 +6,11 @@ QString AppleString::printable() const
|
|||||||
{
|
{
|
||||||
QString retval;
|
QString retval;
|
||||||
foreach (quint8 ch, *this) {
|
foreach (quint8 ch, *this) {
|
||||||
if (ch > 0x80)
|
retval.append(AppleChar::printable(ch));
|
||||||
retval.append(QChar(ch-0x80));
|
// if (ch > 0x80)
|
||||||
else
|
// retval.append(QChar(ch-0x80));
|
||||||
retval.append(QChar(ch));
|
// else
|
||||||
|
// retval.append(QChar(ch));
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ struct TSPair {
|
|||||||
bool isValid()
|
bool isValid()
|
||||||
{
|
{
|
||||||
auto retval= (m_track != 0xff && m_track < 35) && m_sector < 16;
|
auto retval= (m_track != 0xff && m_track < 35) && m_sector < 16;
|
||||||
// qDebug() << "TSPair " << track() << "," << sector() << " is " << (retval?"":"not ") << "valid";
|
// qDebug() << "TSPair " << track() << "," << sector() << " is " << (retval?"":"not ") << "valid";
|
||||||
return retval; }
|
return retval; }
|
||||||
|
|
||||||
quint8 track() const { return m_track; }
|
quint8 track() const { return m_track; }
|
||||||
|
Loading…
Reference in New Issue
Block a user