mirror of
https://github.com/markdavidlong/AppleSAWS.git
synced 2025-01-29 16:33:24 +00:00
Added some error checking to TSList class. Various other cleanup.
This commit is contained in:
parent
46f9ceb386
commit
2af907d1b7
@ -5,15 +5,31 @@ CatalogSector::CatalogSector(Sector *data)
|
||||
{
|
||||
m_data = data;
|
||||
|
||||
m_next.track = m_data->rawData()[0x01];
|
||||
m_next.sector = m_data->rawData()[0x02];
|
||||
m_next = TSPair(0,0);
|
||||
|
||||
TSPair next(m_data->rawData()[0x01],m_data->rawData()[0x02]);
|
||||
|
||||
if (next.isValid())
|
||||
{
|
||||
next.dump();
|
||||
qDebug("Next track sector is valid.");
|
||||
m_next = next;
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << "Track sector is invalid! Not adding to catalog.";
|
||||
m_next.dump();
|
||||
}
|
||||
//m_next.setTrack(m_data->rawData()[0x01]);
|
||||
//m_next.setSector(m_data->rawData()[0x02]);
|
||||
|
||||
for (int idx = 0; idx<7; idx++)
|
||||
{
|
||||
FileDescriptiveEntry fde = makeFDE(idx*0x23+0x0B);
|
||||
if (fde.firstTSListSector != TSPair(0,0)) {
|
||||
if (fde.firstTSListSector() != TSPair(0,0)) {
|
||||
m_fdes.append(fde);
|
||||
}
|
||||
else { qWarning("fde.firstTSListSector() is 0,0"); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +37,7 @@ void CatalogSector::dumpFDEs() {
|
||||
for (int idx = 0; idx<7; idx++)
|
||||
{
|
||||
FileDescriptiveEntry fde = m_fdes[idx];
|
||||
if (fde.firstTSListSector != TSPair(0,0)) {
|
||||
if (fde.firstTSListSector() != TSPair(0,0)) {
|
||||
qDebug() << "FDE #"<<idx;
|
||||
fde.dump();
|
||||
}
|
||||
@ -31,8 +47,8 @@ void CatalogSector::dumpFDEs() {
|
||||
FileDescriptiveEntry CatalogSector::makeFDE(int offset)
|
||||
{
|
||||
FileDescriptiveEntry fde;
|
||||
fde.firstTSListSector.track = m_data->rawData()[offset + 0x00];
|
||||
fde.firstTSListSector.sector = m_data->rawData()[offset + 0x01];
|
||||
fde.firstTSListSector().setTrack(m_data->rawData()[offset + 0x00]);
|
||||
fde.firstTSListSector().setSector(m_data->rawData()[offset + 0x01]);
|
||||
fde.fileTypeAndFlags = m_data->rawData()[offset + 0x02];
|
||||
fde.lengthInSectors = makeWord( m_data->rawData()[offset + 0x21],
|
||||
m_data->rawData()[offset + 0x22]);
|
||||
@ -41,15 +57,15 @@ FileDescriptiveEntry CatalogSector::makeFDE(int offset)
|
||||
fde.filename.append(m_data->rawData()[idx+offset]);
|
||||
}
|
||||
|
||||
if (fde.firstTSListSector.track == 0xFF)
|
||||
if (fde.firstTSListSector().track() == 0xFF)
|
||||
{
|
||||
//TODO: Double check this stuff. applevision.dsk is a good example.
|
||||
qDebug() << "File" << fde.filename.printable() << "is deleted";
|
||||
fde.deleted = true;
|
||||
qDebug() << fde.filename;
|
||||
fde.firstTSListSector.track = m_data->rawData()[offset + 0x20];
|
||||
qDebug() << " New track: " << (quint8) fde.firstTSListSector.track;
|
||||
qDebug() << " Sector: " << fde.firstTSListSector.sector;
|
||||
fde.firstTSListSector().setTrack(m_data->rawData()[offset + 0x20]);
|
||||
qDebug() << " New track: " << (quint8) fde.firstTSListSector().track();
|
||||
qDebug() << " Sector: " << fde.firstTSListSector().sector();
|
||||
}
|
||||
|
||||
return fde;
|
||||
|
@ -56,6 +56,7 @@ bool DiskFile::read(QString filename)
|
||||
char buffer[256];
|
||||
if (qds.readRawData(buffer,256) == 256)
|
||||
{
|
||||
qDebug() << "Track " << track << " Sector " << sector;
|
||||
Sector sec;
|
||||
sec.setTrackSector(track,sector);
|
||||
sec.setData(QByteArray(buffer,256));
|
||||
@ -110,7 +111,8 @@ GenericFile *DiskFile::getFile(FileDescriptiveEntry fde)
|
||||
}
|
||||
else
|
||||
{
|
||||
TrackSectorList tsl = getSector(fde.firstTSListSector).promoteToTrackSectorList();
|
||||
TrackSectorList tsl = getSector(fde.firstTSListSector()).promoteToTrackSectorList();
|
||||
|
||||
QByteArray data = getDataFromTrackSectorList(tsl);
|
||||
|
||||
if (fde.fileType() == "A")
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
|
||||
bool read(QString filename);
|
||||
|
||||
Sector &getSector(TSPair ts) { return getSector(ts.track, ts.sector); }
|
||||
Sector &getSector(TSPair ts) { return getSector(ts.track(), ts.sector()); }
|
||||
|
||||
Sector &getSector(int track, int sector) {
|
||||
return m_contents[track][sector];
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "applestring.h"
|
||||
|
||||
struct FileDescriptiveEntry {
|
||||
TSPair firstTSListSector;
|
||||
int fileTypeAndFlags;
|
||||
AppleString filename;
|
||||
quint16 lengthInSectors;
|
||||
@ -36,8 +35,9 @@ struct FileDescriptiveEntry {
|
||||
bool isLocked() { return (fileTypeAndFlags & DOSIsLocked); }
|
||||
|
||||
void dump() {
|
||||
qDebug() << "First TS List Sector: Track: " << QString("%1").arg(firstTSListSector.track,2,16,QChar('0')).toUpper()
|
||||
<< " Sector: " << QString("%1").arg(firstTSListSector.sector,2,16,QChar('0')).toUpper();
|
||||
|
||||
qDebug() << "First TS List Sector: Track: " << QString("%1").arg(firstTSListSector().track(),2,16,QChar('0')).toUpper()
|
||||
<< " Sector: " << QString("%1").arg(firstTSListSector().sector(),2,16,QChar('0')).toUpper();
|
||||
qDebug() << "File Type and Flags: " << QString::number((quint8)fileTypeAndFlags) << "(" << fileType() << "," << (isLocked()?"Locked":"Unlocked") << ")";
|
||||
qDebug() << "Filename: " << filename.printable();
|
||||
qDebug() << "Length in Sectors: " << lengthInSectors;
|
||||
@ -50,6 +50,23 @@ struct FileDescriptiveEntry {
|
||||
.arg(filename.printable().trimmed());
|
||||
qDebug() << output;
|
||||
}
|
||||
|
||||
void setFirstTSListSector(TSPair ts)
|
||||
{
|
||||
if (ts.isValid())
|
||||
{
|
||||
m_firstTSListSector = ts;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_firstTSListSector = TSPair(0,0);
|
||||
}
|
||||
}
|
||||
TSPair &firstTSListSector() { return m_firstTSListSector; }
|
||||
|
||||
private:
|
||||
TSPair m_firstTSListSector;
|
||||
|
||||
};
|
||||
|
||||
#endif // FILEDESCRIPTIVEENTRY_H
|
||||
|
@ -6,11 +6,11 @@ TrackSectorList::TrackSectorList(Sector *data)
|
||||
{
|
||||
m_data = data;
|
||||
|
||||
m_next_tslist.track = m_data->rawData()[0x01];
|
||||
m_next_tslist.sector = m_data->rawData()[0x02];
|
||||
m_next_tslist.setTrack(m_data->rawData()[0x01]);
|
||||
m_next_tslist.setSector(m_data->rawData()[0x02]);
|
||||
|
||||
m_sector_offset.track = m_data->rawData()[0x05];
|
||||
m_sector_offset.sector = m_data->rawData()[0x06];
|
||||
m_sector_offset.setTrack(m_data->rawData()[0x05]);
|
||||
m_sector_offset.setSector(m_data->rawData()[0x06]);
|
||||
|
||||
for (int idx = 0x0C; idx < 0xff; idx+=2)
|
||||
{
|
||||
|
@ -49,8 +49,8 @@ qint16 VTOC::bytesPerSector() {
|
||||
}
|
||||
|
||||
bool VTOC::isSectorInUse(TSPair ts) {
|
||||
quint8 track = ts.track;
|
||||
quint8 sec = ts.sector;
|
||||
quint8 track = ts.track();
|
||||
quint8 sec = ts.sector();
|
||||
quint8 baseaddr = (track * 4) + 0x38;
|
||||
|
||||
//quint16 word = (((quint16) m_data->rawData()[baseaddr]) *256) + (quint8) m_data->rawData()[baseaddr+1];
|
||||
@ -71,8 +71,8 @@ void VTOC::dump()
|
||||
}
|
||||
*/
|
||||
qDebug() << "Dumping VTOC Track " << m_data->track() << "Sector " << m_data->sector() << " ...";
|
||||
qDebug() << " Track number of first catalog sector: " << QString::number(firstCatalogSector().track);
|
||||
qDebug() << " Sector number of first catalog sector: " << QString::number(firstCatalogSector().sector);
|
||||
qDebug() << " Track number of first catalog sector: " << QString::number(firstCatalogSector().track());
|
||||
qDebug() << " Sector number of first catalog sector: " << QString::number(firstCatalogSector().sector());
|
||||
qDebug() << " Release number of DOS used to INIT disk: " << QString::number(dosVersion());
|
||||
qDebug() << " Disk Volume Number: " << QString::number(volumeNumber());
|
||||
qDebug() << " Max track/sector pairs that fit in t/s list sector (122=256): " << QString::number(maxTSPairs());
|
||||
|
@ -303,11 +303,11 @@ void DiskExplorerMapWidget::mapDiskToButtons()
|
||||
|
||||
foreach(FileDescriptiveEntry fde, cs.getFDEs())
|
||||
{
|
||||
Sector *s = &(m_disk->getSector(fde.firstTSListSector));
|
||||
Sector *s = &(m_disk->getSector(fde.firstTSListSector()));
|
||||
TrackSectorList tsl(s);
|
||||
|
||||
int tsltr = fde.firstTSListSector.track;
|
||||
int tslse = fde.firstTSListSector.sector;
|
||||
int tsltr = fde.firstTSListSector().track();
|
||||
int tslse = fde.firstTSListSector().sector();
|
||||
|
||||
int tslcount = 0;
|
||||
while (tsltr != 0)
|
||||
@ -325,8 +325,8 @@ void DiskExplorerMapWidget::mapDiskToButtons()
|
||||
int sectorcount = 0;
|
||||
foreach(TSPair tsp, tsl.getDataTSPairs())
|
||||
{
|
||||
int se = tsp.sector;
|
||||
int tr = tsp.track;
|
||||
int se = tsp.sector();
|
||||
int tr = tsp.track();
|
||||
|
||||
QString description = QString("Sector #%1.%2 of %3")
|
||||
.arg(tslcount)
|
||||
@ -350,8 +350,8 @@ void DiskExplorerMapWidget::mapDiskToButtons()
|
||||
// fde.dump();
|
||||
idx++;
|
||||
}
|
||||
tsltr = tsl.getNextTSList().track;
|
||||
tslse = tsl.getNextTSList().sector;
|
||||
tsltr = tsl.getNextTSList().track();
|
||||
tslse = tsl.getNextTSList().sector();
|
||||
tsl = m_disk->getSector(tsl.getNextTSList()).promoteToTrackSectorList();
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,6 @@ void DisassemblerViewer::setFile(RelocatableFile *file) {
|
||||
setWindowTitle(title);
|
||||
|
||||
quint16 address = file->address() + 6 ; // Handle offset for relocatable metadata
|
||||
|
||||
m_mem.addFile(m_file->data(), address);
|
||||
|
||||
QList<quint16> addresses = m_bfm->entryPoints()->getEntryPointAddresses();
|
||||
@ -154,8 +153,8 @@ QStringList DisassemblerViewer::getDisassemblyStrings() {
|
||||
void DisassemblerViewer::disassemble(QList<quint16> entryPoints) {
|
||||
|
||||
Disassembler dis(m_mem.values());
|
||||
|
||||
int length = m_file->length();
|
||||
qDebug() << "DV: from: << " << m_file->address() << " to " << length;
|
||||
int end = m_file->address()+length;
|
||||
if (end > 0xffff) { end = 0xffff; }
|
||||
|
||||
|
@ -23,7 +23,7 @@ typedef enum {
|
||||
typedef enum {
|
||||
Inverse = 0x00, // 0x00 -- 0x3F
|
||||
Flash = 0x01, // 0x40 -- 0x7F
|
||||
NormalLow = 0x02, // 0x80 -- 0xBF
|
||||
NormalLow = 0x02, // 0x80 -- 0xBF
|
||||
NormalHigh = 0x04 // 0xC0 -- 0xFF
|
||||
} TextAttribute;
|
||||
|
||||
@ -39,13 +39,34 @@ typedef enum {
|
||||
} TextSet;
|
||||
|
||||
struct TSPair {
|
||||
TSPair() { track = sector = 0; }
|
||||
TSPair(quint8 trackval, quint8 secval) { track=trackval; sector = secval; }
|
||||
quint8 track;
|
||||
quint8 sector;
|
||||
TSPair() { m_track = m_sector = 0; }
|
||||
TSPair(quint8 trackval, quint8 secval) { m_track=trackval; m_sector = secval; }
|
||||
|
||||
void setTrack(quint8 tracknum)
|
||||
{
|
||||
// Q_ASSERT(tracknum < 35);
|
||||
if (tracknum > 34 && tracknum != 0xff) { qWarning("Setting a track with value %d (> 34 and not 256).",tracknum); }
|
||||
m_track = tracknum;
|
||||
}
|
||||
|
||||
void setSector(quint8 secnum)
|
||||
{
|
||||
//Q_ASSERT(secnum < 16);
|
||||
if (secnum > 15 && m_track != 0xff) { qWarning("Setting a sector with value %d (> 15) on track %d.",secnum, m_track); }
|
||||
m_sector = secnum;
|
||||
}
|
||||
|
||||
bool isValid()
|
||||
{
|
||||
auto retval= (m_track != 0xff && m_track < 35) && m_sector < 16;
|
||||
// qDebug() << "TSPair " << track() << "," << sector() << " is " << (retval?"":"not ") << "valid";
|
||||
return retval; }
|
||||
|
||||
quint8 track() const { return m_track; }
|
||||
quint8 sector() const { return m_sector; }
|
||||
|
||||
bool operator==(const TSPair &other) {
|
||||
if (other.track == track && other.sector == sector) return true;
|
||||
if (other.track() == track() && other.sector() == sector()) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -53,7 +74,10 @@ struct TSPair {
|
||||
return !(operator==(other));
|
||||
}
|
||||
|
||||
void dump() { qDebug() << "TSPair: track: " << track << " sector: " << sector; }
|
||||
void dump() const { qDebug() << "TSPair: track: " << track() << " sector: " << sector(); }
|
||||
private:
|
||||
quint8 m_track;
|
||||
quint8 m_sector;
|
||||
};
|
||||
|
||||
inline QString uint8ToHex(quint8 val) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user