This commit is contained in:
Denis Molony 2017-06-12 19:09:19 +10:00
parent 77cb5336e0
commit f782427d74
8 changed files with 69 additions and 40 deletions

View File

@ -139,12 +139,22 @@ public class BasicProgram extends AbstractFile
// (see SEA BATTLE on DISK283.DSK) // (see SEA BATTLE on DISK283.DSK)
if (subline.is (TOKEN_REM) && lineText.length () > wrapRemAt + 4) if (subline.is (TOKEN_REM) && lineText.length () > wrapRemAt + 4)
{ {
// System.out.println (lineText.length ());
String copy = lineText.substring (4); String copy = lineText.substring (4);
text.append ("REM "); text.append ("REM ");
int inset = text.length (); int inset = text.length () + 1;
List<String> remarks = splitRemark (copy, wrapRemAt); List<String> remarks = splitRemark (copy, wrapRemAt);
boolean first = true;
for (String remark : remarks) for (String remark : remarks)
text.append (" ".substring (0, inset) + remark); {
if (first)
{
first = false;
text.append (remark);
}
else
text.append ("\n ".substring (0, inset) + remark);
}
} }
else else
text.append (lineText); text.append (lineText);
@ -268,14 +278,12 @@ public class BasicProgram extends AbstractFile
int max = Math.min (wrapLength, remark.length () - 1); int max = Math.min (wrapLength, remark.length () - 1);
while (max > 0 && remark.charAt (max) != ' ') while (max > 0 && remark.charAt (max) != ' ')
--max; --max;
// System.out.println (remark.substring (0, max));
remarks.add (remark.substring (0, max) + "\n");
if (max == 0) if (max == 0)
break; break;
remark = remark.substring (max + 1); remarks.add (remark.substring (0, max));
remark = remark.substring (max);
} }
remarks.add (remark); remarks.add (remark);
// System.out.println (remark);
return remarks; return remarks;
} }

View File

@ -7,11 +7,6 @@ public class OriginalHiResImage extends HiResImage
{ {
private static final int WHITE = 0xFFFFFF; private static final int WHITE = 0xFFFFFF;
private static final int BLACK = 0x000000; private static final int BLACK = 0x000000;
// private static final int RED = 0xFF0000;
// private static final int GREEN = 0x00CC00;
// private static final int BLUE = 0x0000FF;
// private static final int VIOLET = 0xBB66FF;
// private static final int[][] palette = { { VIOLET, GREEN }, { BLUE, RED } };
private static final int[][] paletteTable = { { 9, 6 }, { 12, 3 } }; private static final int[][] paletteTable = { { 9, 6 }, { 12, 3 } };
private static boolean matchColourBits = false; private static boolean matchColourBits = false;
@ -42,6 +37,9 @@ public class OriginalHiResImage extends HiResImage
// createImage (); // createImage ();
} }
// https://github.com/Michaelangel007/apple2_hgr_font_tutorial
// hgr[ y ] = 0x2000 + (y/64)*0x28 + (y%8)*0x400 + ((y/8)&7)*0x80;
@Override @Override
protected void createMonochromeImage () protected void createMonochromeImage ()
{ {

View File

@ -83,31 +83,30 @@ public abstract class AbstractSector implements DataSource
return panel; return panel;
} }
protected void addText (StringBuilder text, byte[] b, int offset, int size, String desc) protected void addText (StringBuilder text, byte[] buffer, int offset, int size,
String desc)
{ {
if ((offset + size - 1) > b.length) if ((offset + size - 1) > buffer.length)
{
// System.out.printf ("Offset : %d, Size : %d, Buffer : %d%n", offset, size, buffer.length);
return; return;
}
switch (size) switch (size)
{ {
case 1: case 1:
text.append ( text.append (String.format ("%03X %02X %s%n", offset,
String.format ("%03X %02X %s%n", offset, b[offset], desc)); buffer[offset], desc));
break; break;
case 2: case 2:
text.append (String.format ("%03X-%03X %02X %02X %s%n", offset, text.append (String.format ("%03X-%03X %02X %02X %s%n", offset,
offset + 1, b[offset], b[offset + 1], desc)); offset + 1, buffer[offset], buffer[offset + 1], desc));
break; break;
case 3: case 3:
text.append (String.format ("%03X-%03X %02X %02X %02X %s%n", offset, text.append (String.format ("%03X-%03X %02X %02X %02X %s%n", offset,
offset + 2, b[offset], b[offset + 1], b[offset + 2], desc)); offset + 2, buffer[offset], buffer[offset + 1], buffer[offset + 2], desc));
break; break;
case 4: case 4:
text.append (String.format ("%03X-%03X %02X %02X %02X %02X %s%n", offset, text.append (String.format ("%03X-%03X %02X %02X %02X %02X %s%n", offset,
offset + 3, b[offset], b[offset + 1], b[offset + 2], b[offset + 3], desc)); offset + 3, buffer[offset], buffer[offset + 1], buffer[offset + 2],
buffer[offset + 3], desc));
break; break;
default: default:
System.out.println ("Invalid length : " + size); System.out.println ("Invalid length : " + size);

View File

@ -533,13 +533,14 @@ public class DiskFactory
private static FormattedDisk check2mgDisk (File file) private static FormattedDisk check2mgDisk (File file)
{ {
if (debug) if (debug)
System.out.println ("Checking Prodos 2mg disk"); System.out.println ("Checking 2mg disk");
try try
{ {
AppleDisk disk = new AppleDisk (file, 0, 0); AppleDisk disk = new AppleDisk (file, 0, 0);
if (disk.getTotalBlocks () > 0 && ProdosDisk.isCorrectFormat (disk)) if (disk.getTotalBlocks () > 0 && ProdosDisk.isCorrectFormat (disk))
return new ProdosDisk (disk); return new ProdosDisk (disk);
// should check for DOS, but AppleDisk assumes 2mg has 512 byte blocks
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -45,6 +45,14 @@ class DosVTOCSector extends AbstractSector
addText (text, buffer, 3, 1, "DOS release number"); addText (text, buffer, 3, 1, "DOS release number");
addText (text, buffer, 4, 2, "Not used"); addText (text, buffer, 4, 2, "Not used");
addTextAndDecimal (text, buffer, 6, 1, "Diskette volume"); addTextAndDecimal (text, buffer, 6, 1, "Diskette volume");
addText (text, buffer, 7, 4, "Not used");
addText (text, buffer, 11, 4, "Not used");
addText (text, buffer, 15, 4, "Not used");
addText (text, buffer, 19, 4, "Not used");
addText (text, buffer, 23, 4, "Not used");
addText (text, buffer, 27, 4, "Not used");
addText (text, buffer, 31, 4, "Not used");
addText (text, buffer, 35, 4, "Not used");
addTextAndDecimal (text, buffer, 39, 1, "Maximum TS pairs"); addTextAndDecimal (text, buffer, 39, 1, "Maximum TS pairs");
addText (text, buffer, 40, 4, "Not used"); addText (text, buffer, 40, 4, "Not used");
addText (text, buffer, 44, 4, "Not used"); addText (text, buffer, 44, 4, "Not used");

View File

@ -18,7 +18,7 @@ import com.bytezone.diskbrowser.gui.DiskLayoutPanel.LayoutDetails;
class DiskLegendPanel extends JPanel class DiskLegendPanel extends JPanel
{ {
private static final int LEFT = 10; private static final int LEFT = 3;
private static final int TOP = 10; private static final int TOP = 10;
private FormattedDisk disk; private FormattedDisk disk;
@ -69,7 +69,7 @@ class DiskLegendPanel extends JPanel
for (SectorType type : disk.getSectorTypeList ()) for (SectorType type : disk.getSectorTypeList ())
{ {
int x = LEFT + (count % 2 == 0 ? 0 : 145); int x = LEFT + (count % 2 == 0 ? 0 : 155);
int y = TOP + count++ / 2 * lineHeight; int y = TOP + count++ / 2 * lineHeight;
// draw border // draw border

View File

@ -128,6 +128,9 @@ public class PascalDisk extends AbstractFormattedDisk
public static boolean isCorrectFormat (AppleDisk disk, boolean debug) public static boolean isCorrectFormat (AppleDisk disk, boolean debug)
{ {
disk.setInterleave (1); // should only ever be Prodos disk.setInterleave (1); // should only ever be Prodos
if (checkFormat (disk, debug))
return true;
disk.setInterleave (0); // SANE Disk 2.po
if (checkFormat (disk, debug)) if (checkFormat (disk, debug))
return true; return true;
return false; return false;

View File

@ -74,20 +74,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
break; break;
case GSOS_EXTENDED_FILE: case GSOS_EXTENDED_FILE:
parentDisk.setSectorType (keyPtr, parentDisk.extendedKeySector); readForks ();
indexBlocks.add (disk.getDiskAddress (keyPtr));
byte[] buffer2 = disk.readSector (keyPtr); // data fork and resource fork
// read 2 mini entries (data fork / resource fork)
for (int i = 0; i < 512; i += 256)
{
int storageType = buffer2[i] & 0x0F;
int keyBlock = HexFormatter.unsignedShort (buffer2, i + 1);
int eof =
HexFormatter.intValue (buffer2[i + 3], buffer2[i + 4], buffer2[i + 5]);
addDataBlocks (storageType, keyBlock);
}
break; break;
case SUBDIRECTORY: case SUBDIRECTORY:
@ -102,6 +89,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
case PASCAL_ON_PROFILE: case PASCAL_ON_PROFILE:
indexBlocks.add (disk.getDiskAddress (keyPtr)); indexBlocks.add (disk.getDiskAddress (keyPtr));
System.out.println ("PASCAL on PROFILE: " + name);
// are these blocks guaranteed to be contiguous?
break; break;
default: default:
@ -109,6 +98,23 @@ class FileEntry extends CatalogEntry implements ProdosConstants
} }
} }
private void readForks ()
{
parentDisk.setSectorType (keyPtr, parentDisk.extendedKeySector);
indexBlocks.add (disk.getDiskAddress (keyPtr));
byte[] buffer2 = disk.readSector (keyPtr); // data fork and resource fork
// read 2 mini entries (data fork / resource fork)
for (int i = 0; i < 512; i += 256)
{
int storageType = buffer2[i] & 0x0F;
int keyBlock = HexFormatter.unsignedShort (buffer2, i + 1);
int eof = HexFormatter.intValue (buffer2[i + 3], buffer2[i + 4], buffer2[i + 5]);
addDataBlocks (storageType, keyBlock);
}
}
private void addDataBlocks (int storageType, int keyPtr) private void addDataBlocks (int storageType, int keyPtr)
{ {
DiskAddress emptyDiskAddress = disk.getDiskAddress (0); DiskAddress emptyDiskAddress = disk.getDiskAddress (0);
@ -188,7 +194,10 @@ class FileEntry extends CatalogEntry implements ProdosConstants
// should be removed // should be removed
private boolean isGSOSFile () private boolean isGSOSFile ()
{ {
return ((fileType & 0xF0) == 0x80); // return ((fileType & 0xF0) == 0x80);
if ((fileType & 0xF0) == 0x80)
System.out.println ("GS/OS file: " + name);
return false;
} }
// should be removed // should be removed
@ -508,6 +517,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
} }
} }
// should be removed
private byte[] getGEOSBuffer () private byte[] getGEOSBuffer ()
{ {
switch (storageType) switch (storageType)
@ -525,6 +535,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
} }
} }
// should be removed
private byte[] getMasterIndexFile (int keyPtr) private byte[] getMasterIndexFile (int keyPtr)
{ {
byte[] buffer = disk.readSector (keyPtr); byte[] buffer = disk.readSector (keyPtr);
@ -545,6 +556,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
return fileBuffer; return fileBuffer;
} }
// should be removed
private byte[] getIndexFile (int keyPtr) private byte[] getIndexFile (int keyPtr)
{ {
byte[] buffer = disk.readSector (keyPtr); byte[] buffer = disk.readSector (keyPtr);