Skip to content

Commit

Permalink
allow woz format pascal disks
Browse files Browse the repository at this point in the history
  • Loading branch information
dmolony committed Mar 28, 2022
1 parent c1deee5 commit db49536
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 86 deletions.
4 changes: 2 additions & 2 deletions src/com/bytezone/diskbrowser/applefile/SegmentDictionary.java
Expand Up @@ -33,8 +33,8 @@ public SegmentDictionary (String name, byte[] buffer)
ptr += 8;
}

for (int seg = 0; seg < 16; seg++)
System.out.printf ("%04X %04X %s%n", codeAddress[seg], codeLength[seg], segName[seg]);
// for (int seg = 0; seg < 16; seg++)
// System.out.printf ("%04X %04X %s%n", codeAddress[seg], codeLength[seg], segName[seg]);
}

// ---------------------------------------------------------------------------------//
Expand Down
11 changes: 6 additions & 5 deletions src/com/bytezone/diskbrowser/disk/DiskFactory.java
Expand Up @@ -356,6 +356,8 @@ else if ("bsq".equals (suffix))
disk = checkDos (appleDisk256);
if (disk == null)
disk = checkProdos (new AppleDisk (wozFile, 35, 8));
if (disk == null)
disk = checkPascalDisk (new AppleDisk (wozFile, 35, 8));
if (disk == null)
disk = new DataDisk (appleDisk256);
}
Expand Down Expand Up @@ -409,8 +411,7 @@ else if ("bsq".equals (suffix))

if (length != DISK_143K) // 16 sector floppy disk
{
System.out.printf ("%s: invalid file length : %,d%n", file.getName (),
file.length ());
System.out.printf ("%s: invalid file length : %,d%n", file.getName (), file.length ());
return null;
}

Expand Down Expand Up @@ -570,8 +571,8 @@ else if (suffix.equals ("po"))
disk = new DataDisk (appleDisk256);

if (debug)
System.out.println (
"Factory creating disk : " + disk.getDisk ().getFile ().getAbsolutePath ());
System.out
.println ("Factory creating disk : " + disk.getDisk ().getFile ().getAbsolutePath ());

if (disk != null && compressed)
disk.setOriginalPath (originalPath);
Expand All @@ -583,7 +584,7 @@ else if (suffix.equals ("po"))
private static FormattedDisk check (FormattedDisk disk)
// ---------------------------------------------------------------------------------//
{
if (disk.getDisk ()instanceof AppleDisk appleDisk)
if (disk.getDisk () instanceof AppleDisk appleDisk)
{
if (nuFX != null)
appleDisk.setNuFX (nuFX);
Expand Down
5 changes: 3 additions & 2 deletions src/com/bytezone/diskbrowser/pascal/CatalogEntry.java
Expand Up @@ -52,6 +52,7 @@ public boolean contains (DiskAddress da)
for (DiskAddress sector : blocks)
if (sector.matches (da))
return true;

return false;
}

Expand Down Expand Up @@ -85,8 +86,8 @@ public String toString ()
// ---------------------------------------------------------------------------------//
{
int size = lastBlock - firstBlock;
String fileTypeText = fileType < 0 || fileType >= parent.fileTypes.length ? "????"
: parent.fileTypes[fileType];
String fileTypeText =
fileType < 0 || fileType >= parent.fileTypes.length ? "????" : parent.fileTypes[fileType];
return String.format ("%03d %s %-15s", size, fileTypeText, name);
}
}
1 change: 1 addition & 0 deletions src/com/bytezone/diskbrowser/pascal/PascalCodeObject.java
Expand Up @@ -66,6 +66,7 @@ public boolean contains (DiskAddress da)
for (DiskAddress sector : blocks)
if (sector.matches (da))
return true;

return false;
}

Expand Down
34 changes: 16 additions & 18 deletions src/com/bytezone/diskbrowser/pascal/PascalDisk.java
Expand Up @@ -47,8 +47,8 @@ public class PascalDisk extends AbstractFormattedDisk
SectorType fotoSector = new SectorType ("Foto", Color.gray);
SectorType badSector = new SectorType ("Bad", Color.darkGray);

SectorType[] sectors = { catalogSector, badSector, codeSector, textSector, infoSector,
dataSector, grafSector, fotoSector };
SectorType[] sectors = { catalogSector, badSector, codeSector, textSector, infoSector, dataSector,
grafSector, fotoSector };

// ---------------------------------------------------------------------------------//
public PascalDisk (Disk disk)
Expand Down Expand Up @@ -99,8 +99,7 @@ public PascalDisk (Disk disk)
freeBlocks.set (i, false);
}

diskCatalogSector =
new PascalCatalogSector (disk, disk.readBlocks (sectors), sectors);
diskCatalogSector = new PascalCatalogSector (disk, disk.readBlocks (sectors), sectors);

// read the catalog
List<DiskAddress> addresses = new ArrayList<> ();
Expand Down Expand Up @@ -143,14 +142,16 @@ public static boolean isCorrectFormat (AppleDisk disk, boolean debug)
disk.setInterleave (1); // should only ever be Prodos
if (checkFormat (disk, debug))
return true;

disk.setInterleave (0); // see SANE Disk 2.po
if (checkFormat (disk, debug))
return true;

return false;
}

// ---------------------------------------------------------------------------------//
public static boolean checkFormat (AppleDisk disk, boolean debug)
private static boolean checkFormat (AppleDisk disk, boolean debug)
// ---------------------------------------------------------------------------------//
{
byte[] buffer = disk.readBlock (2);
Expand Down Expand Up @@ -277,16 +278,14 @@ public AppleFileSource getCatalog ()
{
String newLine = String.format ("%n");
String newLine2 = newLine + newLine;
String line = "---- --------------- ---- -------- ------- ---- ---- ----"
+ newLine;
String date =
volumeEntry.date == null ? "--" : df.format (volumeEntry.date.getTime ());
String line =
"---- --------------- ---- -------- ------- ---- ---- ----" + newLine;
String date = volumeEntry.date == null ? "--" : df.format (volumeEntry.date.getTime ());
StringBuilder text = new StringBuilder ();
text.append ("File : " + getDisplayPath () + newLine2);
text.append ("Volume : " + volumeEntry.name + newLine);
text.append ("Date : " + date + newLine2);
text.append (
"Blks Name Type Date Length Frst Last Blks\n");
text.append ("Blks Name Type Date Length Frst Last Blks\n");
text.append (line);

int usedBlocks = 6;
Expand All @@ -297,15 +296,14 @@ public AppleFileSource getCatalog ()
usedBlocks += size;
date = ce.date == null ? "--" : df.format (ce.date.getTime ());
int bytes = (size - 1) * 512 + ce.bytesUsedInLastBlock;
String fileType = ce.fileType < 0 || ce.fileType >= fileTypes.length ? "????"
: fileTypes[ce.fileType];
text.append (String.format ("%4d %-15s %s %8s %,8d $%03X $%03X $%03X%n",
size, ce.name, fileType, date, bytes, ce.firstBlock, ce.lastBlock, size));
String fileType =
ce.fileType < 0 || ce.fileType >= fileTypes.length ? "????" : fileTypes[ce.fileType];
text.append (String.format ("%4d %-15s %s %8s %,8d $%03X $%03X $%03X%n", size,
ce.name, fileType, date, bytes, ce.firstBlock, ce.lastBlock, size));
}
text.append (line);
text.append (
String.format ("Blocks free : %3d Blocks used : %3d Total blocks : %3d%n",
(volumeEntry.totalBlocks - usedBlocks), usedBlocks, volumeEntry.totalBlocks));
text.append (String.format ("Blocks free : %3d Blocks used : %3d Total blocks : %3d%n",
(volumeEntry.totalBlocks - usedBlocks), usedBlocks, volumeEntry.totalBlocks));
return new DefaultAppleFileSource (volumeEntry.name, text.toString (), this);
}
}

0 comments on commit db49536

Please sign in to comment.