diff --git a/src/com/bytezone/diskbrowser/applefile/IconFile.java b/src/com/bytezone/diskbrowser/applefile/IconFile.java index c88112a..22eb76e 100644 --- a/src/com/bytezone/diskbrowser/applefile/IconFile.java +++ b/src/com/bytezone/diskbrowser/applefile/IconFile.java @@ -18,14 +18,14 @@ public class IconFile extends AbstractFile super (name, buffer); iBlkNext = HexFormatter.getLong (buffer, 0); - iBlkID = HexFormatter.getShort (buffer, 4); + iBlkID = HexFormatter.unsignedShort (buffer, 4); iBlkPath = HexFormatter.getLong (buffer, 6); iBlkName = HexFormatter.getHexString (buffer, 10, 16); int ptr = 26; while (true) { - int dataLen = HexFormatter.getShort (buffer, ptr); + int dataLen = HexFormatter.unsignedShort (buffer, ptr); if (dataLen == 0 || (dataLen + ptr) > buffer.length) break; icons.add (new Icon (buffer, ptr)); @@ -66,7 +66,7 @@ public class IconFile extends AbstractFile public Icon (byte[] fullBuffer, int ptr) { - iDataLen = HexFormatter.getShort (fullBuffer, ptr); + iDataLen = HexFormatter.unsignedShort (fullBuffer, ptr); buffer = new byte[iDataLen]; System.arraycopy (fullBuffer, ptr, buffer, 0, buffer.length); @@ -77,8 +77,8 @@ public class IconFile extends AbstractFile len = buffer[66] & 0xFF; dataName = new String (buffer, 67, len); - iDataType = HexFormatter.getShort (buffer, 82); - iDataAux = HexFormatter.getShort (buffer, 84); + iDataType = HexFormatter.unsignedShort (buffer, 82); + iDataAux = HexFormatter.unsignedShort (buffer, 84); largeImage = new Image (buffer, 86); smallImage = new Image (buffer, 86 + largeImage.size ()); @@ -111,10 +111,10 @@ public class IconFile extends AbstractFile public Image (byte[] buffer, int ptr) { - iconType = HexFormatter.getShort (buffer, ptr); - iconSize = HexFormatter.getShort (buffer, ptr + 2); - iconHeight = HexFormatter.getShort (buffer, ptr + 4); - iconWidth = HexFormatter.getShort (buffer, ptr + 6); + iconType = HexFormatter.unsignedShort (buffer, ptr); + iconSize = HexFormatter.unsignedShort (buffer, ptr + 2); + iconHeight = HexFormatter.unsignedShort (buffer, ptr + 4); + iconWidth = HexFormatter.unsignedShort (buffer, ptr + 6); main = new byte[iconSize]; mask = new byte[iconSize]; diff --git a/src/com/bytezone/diskbrowser/applefile/QuickDrawFont.java b/src/com/bytezone/diskbrowser/applefile/QuickDrawFont.java index 1438263..eb00421 100644 --- a/src/com/bytezone/diskbrowser/applefile/QuickDrawFont.java +++ b/src/com/bytezone/diskbrowser/applefile/QuickDrawFont.java @@ -1,10 +1,19 @@ package com.bytezone.diskbrowser.applefile; +import java.awt.AlphaComposite; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.awt.image.DataBuffer; +import java.util.HashMap; +import java.util.Map; + import com.bytezone.diskbrowser.prodos.ProdosConstants; import com.bytezone.diskbrowser.utilities.HexFormatter; public class QuickDrawFont extends AbstractFile { + Map characters = new HashMap (); + private boolean corrupt; private final int fileType; private final int auxType; @@ -19,12 +28,12 @@ public class QuickDrawFont extends AbstractFile private final int fontType; private final int firstChar; private final int lastChar; - private final int maxWidth; - private final int maxKern; - private final int negativeDescent; - private final int rectangleWidth; - private final int rectangleHeight; - private final int offsetToOffsetWidthTable; + private final int widMax; + private final int kernMax; + private final int nDescent; + private final int fRectWidth; + private final int fRectHeight; + private final int owTLoc; private final int ascent; private final int descent; private final int leading; @@ -53,44 +62,44 @@ public class QuickDrawFont extends AbstractFile fontName = HexFormatter.getPascalString (buffer, 0); int nameLength = (buffer[0] & 0xFF); - int ptr = nameLength + 1; + int ptr = nameLength + 1; // start of header record - headerSize = HexFormatter.getShort (buffer, ptr); + headerSize = HexFormatter.unsignedShort (buffer, ptr); fontDefinitionOffset = nameLength + 1 + headerSize * 2; - fontFamily = HexFormatter.getShort (buffer, ptr + 2); - fontStyle = HexFormatter.getShort (buffer, ptr + 4); - fontSize = HexFormatter.getShort (buffer, ptr + 6); + fontFamily = HexFormatter.unsignedShort (buffer, ptr + 2); + fontStyle = HexFormatter.unsignedShort (buffer, ptr + 4); + fontSize = HexFormatter.unsignedShort (buffer, ptr + 6); versionMajor = buffer[ptr + 8] & 0xFF; versionMinor = buffer[ptr + 9] & 0xFF; - extent = HexFormatter.getShort (buffer, ptr + 10); + extent = HexFormatter.unsignedShort (buffer, ptr + 10); ptr = fontDefinitionOffset; - fontType = HexFormatter.getShort (buffer, ptr); - firstChar = HexFormatter.getShort (buffer, ptr + 2); - lastChar = HexFormatter.getShort (buffer, ptr + 4); - maxWidth = HexFormatter.getShort (buffer, ptr + 6); - maxKern = HexFormatter.getShort (buffer, ptr + 8); - negativeDescent = HexFormatter.getShort (buffer, ptr + 10); - rectangleWidth = HexFormatter.getShort (buffer, ptr + 12); - rectangleHeight = HexFormatter.getShort (buffer, ptr + 14); - imageLines = new String[rectangleHeight]; + fontType = HexFormatter.unsignedShort (buffer, ptr); + firstChar = HexFormatter.unsignedShort (buffer, ptr + 2); + lastChar = HexFormatter.unsignedShort (buffer, ptr + 4); + widMax = HexFormatter.unsignedShort (buffer, ptr + 6); + kernMax = HexFormatter.signedShort (buffer, ptr + 8); + nDescent = HexFormatter.signedShort (buffer, ptr + 10); + fRectWidth = HexFormatter.unsignedShort (buffer, ptr + 12); + fRectHeight = HexFormatter.unsignedShort (buffer, ptr + 14); + imageLines = new String[fRectHeight]; - offsetToOffsetWidthTable = HexFormatter.getShort (buffer, ptr + 16); + owTLoc = HexFormatter.unsignedShort (buffer, ptr + 16); - offsetWidthTableOffset = (ptr + 16) + offsetToOffsetWidthTable * 2; + offsetWidthTableOffset = (ptr + 16) + owTLoc * 2; locationTableOffset = offsetWidthTableOffset - (lastChar - firstChar + 3) * 2; bitImageOffset = ptr + 26; - ascent = HexFormatter.getShort (buffer, ptr + 18); - descent = HexFormatter.getShort (buffer, ptr + 20); - leading = HexFormatter.getShort (buffer, ptr + 22); - rowWords = HexFormatter.getShort (buffer, ptr + 24); + ascent = HexFormatter.unsignedShort (buffer, ptr + 18); + descent = HexFormatter.unsignedShort (buffer, ptr + 20); + leading = HexFormatter.unsignedShort (buffer, ptr + 22); + rowWords = HexFormatter.unsignedShort (buffer, ptr + 24); totalCharacters = lastChar - firstChar + 2; // includes missing character - bitImage = new byte[rowWords * 2 * rectangleHeight]; // should use java bits + bitImage = new byte[rowWords * 2 * fRectHeight]; // should use java bits locationTable = new byte[(totalCharacters + 1) * 2]; offsetWidthTable = new byte[(totalCharacters + 1) * 2]; @@ -115,7 +124,7 @@ public class QuickDrawFont extends AbstractFile System.arraycopy (buffer, offsetWidthTableOffset, offsetWidthTable, 0, offsetWidthTable.length); - for (int i = 0; i < rectangleHeight; i++) + for (int i = 0; i < fRectHeight; i++) { int rowOffset = i * rowWords * 2; @@ -128,14 +137,14 @@ public class QuickDrawFont extends AbstractFile // System.out.println ("\n Location table o/w table\n"); for (int i = 0, max = totalCharacters + 1; i < max; i++) { - int location = HexFormatter.getShort (locationTable, i * 2); + int location = HexFormatter.unsignedShort (locationTable, i * 2); int offset = offsetWidthTable[i * 2] & 0xFF; int width = offsetWidthTable[i * 2 + 1] & 0xFF; int j = i + 1; if (j < max) { - int nextLocation = HexFormatter.getShort (locationTable, j * 2); + int nextLocation = HexFormatter.unsignedShort (locationTable, j * 2); int pixelWidth = nextLocation - location; // System.out.printf ("%3d %04X %04X %2d %02X %02X%n", i, location, // nextLocation, pixelWidth, offset, width); @@ -145,9 +154,50 @@ public class QuickDrawFont extends AbstractFile corrupt = true; return; } + + if (pixelWidth > 0) + characters.put (i, new Character (location, pixelWidth)); } - // else - // System.out.printf ("%3d %04X %n", i, location); + } + + if (true) + { + int base = 10; + int spacing = 5; + + int charsWide = (int) Math.sqrt (totalCharacters); + int charsHigh = (totalCharacters - 1) / charsWide + 1; + + image = new BufferedImage (charsWide * (widMax + spacing) + base * 2, + charsHigh * (fRectHeight + leading) + base * 2, BufferedImage.TYPE_BYTE_GRAY); + + Graphics2D g2d = image.createGraphics (); + g2d.setComposite ( + AlphaComposite.getInstance (AlphaComposite.SRC_OVER, (float) 1.0)); + + int x = base; + int y = base; + int count = 0; + + for (int i = 0; i < totalCharacters + 1; i++) + { + Character character; + if (characters.containsKey (i)) + character = characters.get (i); + else + character = characters.get (lastChar + 1); + + if (character != null) + g2d.drawImage (character.image, x, y, null); + + x += widMax + spacing; + if (++count % charsWide == 0) + { + x = base; + y += fRectHeight + leading; + } + } + g2d.dispose (); } } @@ -169,12 +219,12 @@ public class QuickDrawFont extends AbstractFile text.append (String.format ("Font type : %d%n", fontType)); text.append (String.format ("First char : %d%n", firstChar)); text.append (String.format ("Last char : %d%n", lastChar)); - text.append (String.format ("Max width : %d%n", maxWidth)); - text.append (String.format ("Max kern : %d%n", maxKern)); - text.append (String.format ("Neg descent : %d%n", negativeDescent)); - text.append (String.format ("Width : %d%n", rectangleWidth)); - text.append (String.format ("Height : %d%n", rectangleHeight)); - text.append (String.format ("O/W Offset : %d%n", offsetToOffsetWidthTable)); + text.append (String.format ("Max width : %d%n", widMax)); + text.append (String.format ("Max kern : %d%n", kernMax)); + text.append (String.format ("Neg descent : %d%n", nDescent)); + text.append (String.format ("Width : %d%n", fRectWidth)); + text.append (String.format ("Height : %d%n", fRectHeight)); + text.append (String.format ("O/W Offset : %04X%n", owTLoc)); text.append (String.format ("Ascent : %d%n", ascent)); text.append (String.format ("Descent : %d%n", descent)); text.append (String.format ("Leading : %d%n", leading)); @@ -194,17 +244,18 @@ public class QuickDrawFont extends AbstractFile if (offset == 255 && width == 255) continue; - int location = HexFormatter.getShort (locationTable, i * 2); - int nextLocation = HexFormatter.getShort (locationTable, (i + 1) * 2); + int location = HexFormatter.unsignedShort (locationTable, i * 2); + int nextLocation = HexFormatter.unsignedShort (locationTable, (i + 1) * 2); int pixelWidth = nextLocation - location; - text.append (String.format ("Char %3d %,5d %2d %,5d %,5d%n", i, location, - pixelWidth, offset, width)); + text.append (String.format ( + "Char %3d, location %,5d, pixelWidth %2d. offset %,5d, width %,5d%n", i, + location, pixelWidth, offset, width)); if (pixelWidth > 0 && location + pixelWidth < imageLines[0].length ()) - for (int j = 0; j < rectangleHeight; j++) + for (int j = 0; j < fRectHeight; j++) { - for (int w = 0; w < width; w++) + for (int w = 0; w < offset; w++) text.append (' '); text.append (imageLines[j].substring (location, location + pixelWidth)); text.append ("\n"); @@ -214,7 +265,7 @@ public class QuickDrawFont extends AbstractFile if (false) { text.append ("\n\n"); - for (int i = 0; i < rectangleHeight; i++) + for (int i = 0; i < fRectHeight; i++) { text.append (String.format ("Row: %d%n", i)); int rowOffset = i * rowWords * 2; @@ -235,7 +286,7 @@ public class QuickDrawFont extends AbstractFile text.append ("\n\n"); for (int i = 0; i < totalCharacters; i++) { - int location = HexFormatter.getShort (locationTable, i * 2); + int location = HexFormatter.unsignedShort (locationTable, i * 2); text.append (String.format ("%3d %04X %,7d%n", i, location, location)); } @@ -250,4 +301,34 @@ public class QuickDrawFont extends AbstractFile return text.toString (); } + + class Character + { + private final BufferedImage image; + private final int location; + private final int pixelWidth; + + // offset - where to start drawing relative to current pen location + // width - how far to move the current pen location after drawing + // location - index into imageLines[] + // pixelWidth - number of pixels to copy from imageLines[] + + public Character (int location, int pixelWidth) + { + this.location = location; + this.pixelWidth = pixelWidth; + + image = new BufferedImage (pixelWidth, fRectHeight, BufferedImage.TYPE_BYTE_GRAY); + DataBuffer dataBuffer = image.getRaster ().getDataBuffer (); + + if (pixelWidth > 0 && location + pixelWidth < imageLines[0].length ()) + for (int i = 0; i < fRectHeight; i++) + { + int element = i * pixelWidth; // start of row + String row = imageLines[i].substring (location, location + pixelWidth); + for (char c : row.toCharArray ()) + dataBuffer.setElem (element++, c == '.' ? 0 : 255); + } + } + } } \ No newline at end of file diff --git a/src/com/bytezone/diskbrowser/applefile/ShapeTable.java b/src/com/bytezone/diskbrowser/applefile/ShapeTable.java index fbfc2d1..cae6a82 100755 --- a/src/com/bytezone/diskbrowser/applefile/ShapeTable.java +++ b/src/com/bytezone/diskbrowser/applefile/ShapeTable.java @@ -122,7 +122,7 @@ public class ShapeTable extends AbstractFile return false; // check index points inside the file - int offset = HexFormatter.getShort (buffer, ptr); + int offset = HexFormatter.unsignedShort (buffer, ptr); if (offset == 0 || offset >= buffer.length) return false; } @@ -156,7 +156,7 @@ public class ShapeTable extends AbstractFile int row = startRow; int col = startCol; - offset = HexFormatter.getShort (buffer, index * 2 + 2); + offset = HexFormatter.unsignedShort (buffer, index * 2 + 2); int ptr = offset; while (ptr < buffer.length) diff --git a/src/com/bytezone/diskbrowser/appleworks/AppleworksADBFile.java b/src/com/bytezone/diskbrowser/appleworks/AppleworksADBFile.java index 6b82ca0..1619b81 100644 --- a/src/com/bytezone/diskbrowser/appleworks/AppleworksADBFile.java +++ b/src/com/bytezone/diskbrowser/appleworks/AppleworksADBFile.java @@ -48,7 +48,7 @@ public class AppleworksADBFile extends AbstractFile dbMinVersion = buffer[218] & 0xFF; - headerSize = HexFormatter.getShort (buffer, 0); + headerSize = HexFormatter.unsignedShort (buffer, 0); cursorDirectionSRL = buffer[30]; cursorDirectionMRL = (char) buffer[31]; currentDisplay = (char) buffer[34]; @@ -56,7 +56,7 @@ public class AppleworksADBFile extends AbstractFile categoryNames = new String[categories]; totalReports = buffer[38] & 0xFF; - int recs = HexFormatter.getShort (buffer, 36); + int recs = HexFormatter.unsignedShort (buffer, 36); totalRecords = dbMinVersion == 0 ? recs : recs & 0x7FFF; for (int i = 0; i < 30; i++) @@ -75,9 +75,9 @@ public class AppleworksADBFile extends AbstractFile for (int i = 0; i < 3; i++) { - selectionRules[i] = HexFormatter.getShort (buffer, 223 + i * 2); - testTypes[i] = HexFormatter.getShort (buffer, 229 + i * 2); - continuation[i] = HexFormatter.getShort (buffer, 235 + i * 2); + selectionRules[i] = HexFormatter.unsignedShort (buffer, 223 + i * 2); + testTypes[i] = HexFormatter.unsignedShort (buffer, 229 + i * 2); + continuation[i] = HexFormatter.unsignedShort (buffer, 235 + i * 2); comparison[i] = new String (buffer, 241 + i * 20, 20); } @@ -102,7 +102,7 @@ public class AppleworksADBFile extends AbstractFile ptr += 600; } - int length = HexFormatter.getShort (buffer, ptr); + int length = HexFormatter.unsignedShort (buffer, ptr); ptr += 2; if (length == 0) @@ -114,7 +114,7 @@ public class AppleworksADBFile extends AbstractFile for (int recordNo = 0; recordNo < totalRecords; recordNo++) { - length = HexFormatter.getShort (buffer, ptr); + length = HexFormatter.unsignedShort (buffer, ptr); ptr += 2; if (length == 0) break; diff --git a/src/com/bytezone/diskbrowser/appleworks/AppleworksSSFile.java b/src/com/bytezone/diskbrowser/appleworks/AppleworksSSFile.java index 888057b..be56e8e 100644 --- a/src/com/bytezone/diskbrowser/appleworks/AppleworksSSFile.java +++ b/src/com/bytezone/diskbrowser/appleworks/AppleworksSSFile.java @@ -20,7 +20,7 @@ public class AppleworksSSFile extends AbstractFile int ptr = header.ssMinVers == 0 ? 300 : 302; while (ptr < buffer.length) { - int length = HexFormatter.getShort (buffer, ptr); + int length = HexFormatter.unsignedShort (buffer, ptr); if (length == 0xFFFF) break; @@ -92,7 +92,7 @@ public class AppleworksSSFile extends AbstractFile calcOrder = (char) buffer[131]; calcFrequency = (char) buffer[132]; - lastRow = HexFormatter.getShort (buffer, 133); + lastRow = HexFormatter.unsignedShort (buffer, 133); lastColumn = buffer[135] & 0xFF; windowLayout = (char) buffer[136]; windowSynch = buffer[137] != 0; @@ -193,15 +193,15 @@ public class AppleworksSSFile extends AbstractFile r1 = buffer[offset + 3] & 0xFF; c1 = buffer[offset + 4] & 0xFF; - r2 = HexFormatter.getShort (buffer, offset + 5); + r2 = HexFormatter.unsignedShort (buffer, offset + 5); c2 = buffer[offset + 7] & 0xFF; - r3 = HexFormatter.getShort (buffer, offset + 8); + r3 = HexFormatter.unsignedShort (buffer, offset + 8); c3 = buffer[offset + 10] & 0xFF; - r4 = HexFormatter.getShort (buffer, offset + 11); + r4 = HexFormatter.unsignedShort (buffer, offset + 11); c4 = buffer[offset + 13] & 0xFF; r5 = buffer[offset + 14] & 0xFF; c5 = buffer[offset + 15] & 0xFF; - r6 = HexFormatter.getShort (buffer, offset + 16); + r6 = HexFormatter.unsignedShort (buffer, offset + 16); c6 = buffer[offset + 18] & 0xFF; r7 = buffer[offset + 19] & 0xFF; c7 = buffer[offset + 20] & 0xFF; @@ -252,7 +252,7 @@ public class AppleworksSSFile extends AbstractFile public Row (int ptr) { - rowNumber = HexFormatter.getShort (buffer, ptr); + rowNumber = HexFormatter.unsignedShort (buffer, ptr); ptr += 2; // first control byte int column = 0; diff --git a/src/com/bytezone/diskbrowser/appleworks/Report.java b/src/com/bytezone/diskbrowser/appleworks/Report.java index 90db66b..b888917 100644 --- a/src/com/bytezone/diskbrowser/appleworks/Report.java +++ b/src/com/bytezone/diskbrowser/appleworks/Report.java @@ -126,9 +126,9 @@ abstract class Report if (buffer[offset + 480 + fudge] == 0) // test high byte for (int i = 0; i < 3; i++) { - selectionRules[i] = HexFormatter.getShort (buffer, offset + 479 + i * 2 + fudge); - testTypes[i] = HexFormatter.getShort (buffer, offset + 485 + i * 2 + fudge); - continuation[i] = HexFormatter.getShort (buffer, offset + 491 + i * 2 + fudge); + selectionRules[i] = HexFormatter.unsignedShort (buffer, offset + 479 + i * 2 + fudge); + testTypes[i] = HexFormatter.unsignedShort (buffer, offset + 485 + i * 2 + fudge); + continuation[i] = HexFormatter.unsignedShort (buffer, offset + 491 + i * 2 + fudge); comparison[i] = pascalString (buffer, offset + 497 + i * 32 + fudge); } else diff --git a/src/com/bytezone/diskbrowser/prodos/CatalogEntry.java b/src/com/bytezone/diskbrowser/prodos/CatalogEntry.java index 4f97dcc..8e1d387 100755 --- a/src/com/bytezone/diskbrowser/prodos/CatalogEntry.java +++ b/src/com/bytezone/diskbrowser/prodos/CatalogEntry.java @@ -57,4 +57,18 @@ abstract class CatalogEntry implements AppleFileSource return true; return false; } + + @Override + public String toString () + { + StringBuilder text = new StringBuilder (); + + text.append (String.format ("Name .......... %s%n", name)); + text.append (String.format ("Storage type... %02X%n", storageType)); + text.append (String.format ("Created ....... %s%n", + created == null ? "" : parentDisk.df.format (created.getTime ()))); + text.append (String.format ("Version ....... %d%n", version)); + + return text.toString (); + } } \ No newline at end of file diff --git a/src/com/bytezone/diskbrowser/prodos/FileEntry.java b/src/com/bytezone/diskbrowser/prodos/FileEntry.java index d9ab540..6680734 100755 --- a/src/com/bytezone/diskbrowser/prodos/FileEntry.java +++ b/src/com/bytezone/diskbrowser/prodos/FileEntry.java @@ -36,6 +36,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants int parentBlock) { super (fDisk, entryBuffer); + assert parent != null; this.parentDirectory = parent; this.catalogBlock = this.disk.getDiskAddress (parentBlock); @@ -93,8 +94,11 @@ class FileEntry extends CatalogEntry implements ProdosConstants case ProdosConstants.TYPE_SAPLING: traverseIndex (keyBlock); break; + case ProdosConstants.TYPE_TREE: + traverseMasterIndex (keyBlock); + break; default: - System.out.println ("fork not a sapling or seedling!!!"); + System.out.println ("fork not a tree, sapling or seedling!!!"); } } break; @@ -335,9 +339,14 @@ class FileEntry extends CatalogEntry implements ProdosConstants case FILE_TYPE_ASP: file = new AppleworksSSFile (name + " (Appleworks Spreadsheet File)", buffer); break; - case FILE_TYPE_ASM_SOURCE: + case FILE_TYPE_IIGS_SOURCE: // I think this has a resource fork file = new SimpleText (name, exactBuffer); break; + case FILE_TYPE_IIGS_APPLICATION: + // file = + // new DefaultAppleFile (name, buffer, "S16 Apple IIgs Application Program"); + file = new AssemblerProgram (name, buffer, auxType); + break; case FILE_TYPE_ICN: file = new IconFile (name, exactBuffer); break; @@ -352,11 +361,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants break; default: System.out.format ("Unknown file type : %02X%n", fileType); - if (fileType == 0xB3) - file = new DefaultAppleFile (name, exactBuffer, - "S16 Apple IIgs Application Program"); - else - file = new DefaultAppleFile (name, exactBuffer); + file = new DefaultAppleFile (name, exactBuffer); } } catch (Exception e) diff --git a/src/com/bytezone/diskbrowser/prodos/ProdosCatalogSector.java b/src/com/bytezone/diskbrowser/prodos/ProdosCatalogSector.java index 61038a1..9b1caf0 100755 --- a/src/com/bytezone/diskbrowser/prodos/ProdosCatalogSector.java +++ b/src/com/bytezone/diskbrowser/prodos/ProdosCatalogSector.java @@ -81,7 +81,7 @@ class ProdosCatalogSector extends AbstractSector { StringBuilder text = new StringBuilder (); int fileType = buffer[offset + 16] & 0xFF; - int auxType = HexFormatter.getShort (buffer, offset + 31); + int auxType = HexFormatter.unsignedShort (buffer, offset + 31); addText (text, buffer, offset + 16, 1, "File type (" + ProdosConstants.fileTypes[fileType] + ")"); addTextAndDecimal (text, buffer, offset + 17, 2, "Key pointer"); diff --git a/src/com/bytezone/diskbrowser/prodos/ProdosConstants.java b/src/com/bytezone/diskbrowser/prodos/ProdosConstants.java index 6a4be4e..bcf3760 100755 --- a/src/com/bytezone/diskbrowser/prodos/ProdosConstants.java +++ b/src/com/bytezone/diskbrowser/prodos/ProdosConstants.java @@ -10,9 +10,10 @@ public interface ProdosConstants int FILE_TYPE_AWP = 0x1A; int FILE_TYPE_ASP = 0x1B; int FILE_TYPE_GWP = 0x50; - int FILE_TYPE_ASM_SOURCE = 0xB0; - int FILE_TYPE_ASM_OBJECT = 0xB1; - int FILE_TYPE_FORKED_FILE = 0xB3; // S16 + int FILE_TYPE_IIGS_SOURCE = 0xB0; + int FILE_TYPE_IIGS_OBJECT = 0xB1; + // int FILE_TYPE_FORKED_FILE = 0xB3; // S16 + int FILE_TYPE_IIGS_APPLICATION = 0xB3; int FILE_TYPE_PNT = 0xC0; int FILE_TYPE_PIC = 0xC1; int FILE_TYPE_FONT = 0xC8; diff --git a/src/com/bytezone/diskbrowser/utilities/HexFormatter.java b/src/com/bytezone/diskbrowser/utilities/HexFormatter.java index 5534648..1f6aaa4 100755 --- a/src/com/bytezone/diskbrowser/utilities/HexFormatter.java +++ b/src/com/bytezone/diskbrowser/utilities/HexFormatter.java @@ -314,7 +314,7 @@ public class HexFormatter return val; } - public static int getShort (byte[] buffer, int ptr) + public static int unsignedShort (byte[] buffer, int ptr) { int val = 0; for (int i = 1; i >= 0; i--) @@ -325,6 +325,11 @@ public class HexFormatter return val; } + public static int signedShort (byte[] buffer, int ptr) + { + return (short) (((buffer[ptr] & 0xFF) << 8) | (buffer[ptr + 1] & 0xFF)); + } + public static int getShortBigEndian (byte[] buffer, int ptr) { int val = 0; diff --git a/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java b/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java index b0dc961..19737ae 100644 --- a/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java +++ b/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java @@ -286,11 +286,11 @@ public class Wizardry4BootDisk extends PascalDisk { // System.out.println (HexFormatter.format (buffer, 0x08600 + i * 32, 32)); int offset = 0x08600 + i * 32 + 18; - int key = HexFormatter.getShort (buffer, offset); + int key = HexFormatter.unsignedShort (buffer, offset); if (key > 0) text.append (String.format ("%04X %04X * %s%n", offset, key, messageBlock.getMessageText (key))); - key = HexFormatter.getShort (buffer, offset + 8); + key = HexFormatter.unsignedShort (buffer, offset + 8); if (key > 0) text.append (String.format ("%04X %04X %s%n", offset + 8, key, messageBlock.getMessageText (key)));