From 0637f526ca0ceb0041ddace6a1f0fb258ba69679 Mon Sep 17 00:00:00 2001 From: Denis Molony Date: Fri, 26 Mar 2021 11:11:34 +1000 Subject: [PATCH] Initial MagicWindow support --- .../applefile/MagicWindowText.java | 52 +++++++++++++++++++ .../diskbrowser/dos/AbstractCatalogEntry.java | 3 ++ 2 files changed, 55 insertions(+) create mode 100644 src/com/bytezone/diskbrowser/applefile/MagicWindowText.java diff --git a/src/com/bytezone/diskbrowser/applefile/MagicWindowText.java b/src/com/bytezone/diskbrowser/applefile/MagicWindowText.java new file mode 100644 index 0000000..b03f178 --- /dev/null +++ b/src/com/bytezone/diskbrowser/applefile/MagicWindowText.java @@ -0,0 +1,52 @@ +package com.bytezone.diskbrowser.applefile; + +// -----------------------------------------------------------------------------------// +public class MagicWindowText extends AbstractFile +// -----------------------------------------------------------------------------------// +{ + + // ---------------------------------------------------------------------------------// + public MagicWindowText (String name, byte[] buffer) + // ---------------------------------------------------------------------------------// + { + super (name, buffer); + } + + // ---------------------------------------------------------------------------------// + @Override + public String getText () + // ---------------------------------------------------------------------------------// + { + StringBuilder text = new StringBuilder (); + + text.append ("Name : " + name + "\n"); + text.append (String.format ("End of file : %,8d%n%n", buffer.length)); + + int ptr = 0x100; + while (ptr < buffer.length && buffer[ptr] != 0x00) + { + String line = getLine (ptr); + text.append (line + "\n"); + ptr += line.length () + 1; + if (ptr < buffer.length && buffer[ptr] == 0x0A) + ptr++; + } + + return text.toString (); + } + + // ---------------------------------------------------------------------------------// + private String getLine (int ptr) + // ---------------------------------------------------------------------------------// + { + StringBuilder line = new StringBuilder (); + + // added check for 0x00 eol 17/01/17 + while (ptr < buffer.length && buffer[ptr] != (byte) 0x8D && buffer[ptr] != 0x00) + { + line.append ((char) (buffer[ptr++] & 0x7F)); + } + + return line.toString (); + } +} diff --git a/src/com/bytezone/diskbrowser/dos/AbstractCatalogEntry.java b/src/com/bytezone/diskbrowser/dos/AbstractCatalogEntry.java index f2715e5..072181e 100644 --- a/src/com/bytezone/diskbrowser/dos/AbstractCatalogEntry.java +++ b/src/com/bytezone/diskbrowser/dos/AbstractCatalogEntry.java @@ -14,6 +14,7 @@ import com.bytezone.diskbrowser.applefile.ErrorMessageFile; import com.bytezone.diskbrowser.applefile.FontFile; import com.bytezone.diskbrowser.applefile.HiResImage; import com.bytezone.diskbrowser.applefile.IntegerBasicProgram; +import com.bytezone.diskbrowser.applefile.MagicWindowText; import com.bytezone.diskbrowser.applefile.MerlinSource; import com.bytezone.diskbrowser.applefile.OriginalHiResImage; import com.bytezone.diskbrowser.applefile.PrintShopGraphic; @@ -271,6 +272,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource || name.endsWith (".SET") || name.startsWith ("ASCII.")) && FontFile.isFont (exactBuffer)) appleFile = new FontFile (name, exactBuffer, loadAddress); + else if (name.endsWith (".MW")) + appleFile = new MagicWindowText (name, exactBuffer); else if (ShapeTable.isShapeTable (exactBuffer)) appleFile = new ShapeTable (name, exactBuffer); else if (name.endsWith (".S"))