improved text preferences

This commit is contained in:
Denis Molony 2020-12-01 21:02:01 +10:00
parent 145bcb38de
commit 13a45cd9bf
6 changed files with 63 additions and 33 deletions

View File

@ -543,7 +543,7 @@ public class ApplesoftBasicProgram extends BasicProgram
int linePtr; int linePtr;
int length; int length;
public SourceLine (int ptr) SourceLine (int ptr)
{ {
linePtr = ptr; linePtr = ptr;
// lineNumber = Utility.intValue (buffer[ptr + 2], buffer[ptr + 3]); // lineNumber = Utility.intValue (buffer[ptr + 2], buffer[ptr + 3]);
@ -630,7 +630,7 @@ public class ApplesoftBasicProgram extends BasicProgram
// used for aligning the equals sign // used for aligning the equals sign
int assignEqualPos; int assignEqualPos;
public SubLine (SourceLine parent, int startPtr, int length) SubLine (SourceLine parent, int startPtr, int length)
{ {
this.parent = parent; this.parent = parent;
this.startPtr = startPtr; this.startPtr = startPtr;
@ -738,22 +738,22 @@ public class ApplesoftBasicProgram extends BasicProgram
return is (TOKEN_REM) && !isFirst (); return is (TOKEN_REM) && !isFirst ();
} }
public boolean isFirst () boolean isFirst ()
{ {
return (parent.linePtr + 4) == startPtr; return (parent.linePtr + 4) == startPtr;
} }
public boolean is (byte token) boolean is (byte token)
{ {
return buffer[startPtr] == token; return buffer[startPtr] == token;
} }
public boolean isEmpty () boolean isEmpty ()
{ {
return length == 1 && buffer[startPtr] == 0; return length == 1 && buffer[startPtr] == 0;
} }
public boolean containsToken () boolean containsToken ()
{ {
// ignore first byte, check the rest for tokens // ignore first byte, check the rest for tokens
for (int p = startPtr + 1, max = startPtr + length; p < max; p++) for (int p = startPtr + 1, max = startPtr + length; p < max; p++)
@ -763,7 +763,7 @@ public class ApplesoftBasicProgram extends BasicProgram
return false; return false;
} }
public boolean containsControlChars () boolean containsControlChars ()
{ {
for (int p = startPtr + 1, max = startPtr + length; p < max; p++) for (int p = startPtr + 1, max = startPtr + length; p < max; p++)
{ {
@ -778,7 +778,7 @@ public class ApplesoftBasicProgram extends BasicProgram
return false; return false;
} }
public void addFormattedRem (StringBuilder text) void addFormattedRem (StringBuilder text)
{ {
int ptr = startPtr + 1; int ptr = startPtr + 1;
int max = startPtr + length - 2; int max = startPtr + length - 2;

View File

@ -92,9 +92,17 @@ public class BasicTextFile extends TextFile
if (recordLength == 0) if (recordLength == 0)
return unknownLength (text); return unknownLength (text);
text.append ("Offset Record# Text values\n"); if (textPreferences.showTextOffsets)
text.append ( {
"------ ------- -------------------------------------------------------\n"); text.append (" Offset Record# Text values\n");
text.append (
"---------- ------- -------------------------------------------------------\n");
}
else
{
text.append ("Text values\n");
text.append ("-------------------------------------------------------\n");
}
return knownLength (text, 0).toString (); return knownLength (text, 0).toString ();
} }
@ -102,9 +110,17 @@ public class BasicTextFile extends TextFile
private String treeFileText (StringBuilder text) private String treeFileText (StringBuilder text)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
text.append (" Offset Record# Text values\n"); if (textPreferences.showTextOffsets)
text.append ( {
"---------- ------- -------------------------------------------------------\n"); text.append (" Offset Record# Text values\n");
text.append (
"---------- ------- -------------------------------------------------------\n");
}
else
{
text.append ("Text values\n");
text.append ("-------------------------------------------------------\n");
}
for (TextBuffer tb : buffers) for (TextBuffer tb : buffers)
{ {
buffer = tb.buffer; buffer = tb.buffer;
@ -135,9 +151,19 @@ public class BasicTextFile extends TextFile
bytes--; bytes--;
String line = HexFormatter.getString (buffer, ptr, bytes); String line = HexFormatter.getString (buffer, ptr, bytes);
line = line.replaceAll ("\\n", "\n ");
text.append ( if (textPreferences.showTextOffsets)
String.format ("%,10d %,8d %s%n", recNo * recordLength, recNo++, line)); {
line = line.replaceAll ("\\n", "\n ");
text.append (
String.format ("%,10d %,8d %s%n", recNo * recordLength, recNo++, line));
}
else
{
line = line.replaceAll ("\\n", "\n ");
text.append (String.format ("%s%n", line));
recNo++;
}
} }
return text; return text;

View File

@ -30,7 +30,6 @@ public class DosMasterFile extends AbstractFile
public static boolean isDos33 (ProdosDisk parentDisk, byte[] buffer) public static boolean isDos33 (ProdosDisk parentDisk, byte[] buffer)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
// System.out.println (HexFormatter.format (buffer, 0x38, 0x30, 0x38));
System.out.printf ("%nHighest Block: %04X (%<,d)%n", System.out.printf ("%nHighest Block: %04X (%<,d)%n",
parentDisk.getDisk ().getTotalBlocks () - 1); parentDisk.getDisk ().getTotalBlocks () - 1);
@ -106,9 +105,6 @@ public class DosMasterFile extends AbstractFile
daList.add (disk.getDiskAddress (block)); daList.add (disk.getDiskAddress (block));
byte[] diskBuffer = disk.readBlocks (daList); byte[] diskBuffer = disk.readBlocks (daList);
// System.out.println (HexFormatter.format (diskBuffer));
// System.out.printf ("Buffer: %,d%n", diskBuffer.length);
// System.out.printf ("Blocks: %,d x 2 = %,d%n", daList.size (), daList.size () * 2);
if (false) if (false)
createDisk (String.format ("%sVol%03d.dsk", base, volNo), diskBuffer); createDisk (String.format ("%sVol%03d.dsk", base, volNo), diskBuffer);

View File

@ -478,12 +478,25 @@ public class DiskFactory
disk2 = checkProdos (appleDisk512); disk2 = checkProdos (appleDisk512);
if (disk2 != null) if (disk2 != null)
{
disk = new DualDosDisk (disk, disk2); disk = new DualDosDisk (disk, disk2);
return disk;
}
AppleDisk appleDisk = new AppleDisk (file, 35, 16); AppleDisk appleDisk = new AppleDisk (file, 35, 16);
disk2 = checkCPMDisk (appleDisk); disk2 = checkCPMDisk (appleDisk);
if (disk2 != null) if (disk2 != null)
{
disk = new DualDosDisk (disk, disk2); disk = new DualDosDisk (disk, disk2);
return disk;
}
disk2 = checkPascalDisk (appleDisk512);
if (disk2 != null)
{
disk = new DualDosDisk (disk, disk2);
return disk;
}
} }
} }
else if (suffix.equals ("po")) else if (suffix.equals ("po"))

View File

@ -7,6 +7,7 @@ import java.util.List;
import com.bytezone.diskbrowser.applefile.ApplesoftBasicProgram; import com.bytezone.diskbrowser.applefile.ApplesoftBasicProgram;
import com.bytezone.diskbrowser.applefile.AssemblerProgram; import com.bytezone.diskbrowser.applefile.AssemblerProgram;
import com.bytezone.diskbrowser.applefile.BasicProgramGS; import com.bytezone.diskbrowser.applefile.BasicProgramGS;
import com.bytezone.diskbrowser.applefile.BasicTextFile;
import com.bytezone.diskbrowser.applefile.CharacterRom; import com.bytezone.diskbrowser.applefile.CharacterRom;
import com.bytezone.diskbrowser.applefile.DefaultAppleFile; import com.bytezone.diskbrowser.applefile.DefaultAppleFile;
import com.bytezone.diskbrowser.applefile.DeviceDriver; import com.bytezone.diskbrowser.applefile.DeviceDriver;
@ -35,7 +36,6 @@ import com.bytezone.diskbrowser.applefile.ShapeTable;
import com.bytezone.diskbrowser.applefile.SimpleText; import com.bytezone.diskbrowser.applefile.SimpleText;
import com.bytezone.diskbrowser.applefile.StoredVariables; import com.bytezone.diskbrowser.applefile.StoredVariables;
import com.bytezone.diskbrowser.applefile.TextBuffer; import com.bytezone.diskbrowser.applefile.TextBuffer;
import com.bytezone.diskbrowser.applefile.BasicTextFile;
import com.bytezone.diskbrowser.appleworks.AppleworksADBFile; import com.bytezone.diskbrowser.appleworks.AppleworksADBFile;
import com.bytezone.diskbrowser.appleworks.AppleworksSSFile; import com.bytezone.diskbrowser.appleworks.AppleworksSSFile;
import com.bytezone.diskbrowser.appleworks.AppleworksWPFile; import com.bytezone.diskbrowser.appleworks.AppleworksWPFile;
@ -222,7 +222,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
parentDisk.setSectorType (keyPtr, parentDisk.masterIndexSector); parentDisk.setSectorType (keyPtr, parentDisk.masterIndexSector);
indexBlocks.add (disk.getDiskAddress (keyPtr)); indexBlocks.add (disk.getDiskAddress (keyPtr));
byte[] buffer = disk.readBlock (keyPtr); // master index byte[] buffer = disk.readBlock (keyPtr); // master index
int highest = 0x80; int highest = 0x80;
while (highest-- > 0) // decrement after test while (highest-- > 0) // decrement after test
@ -272,6 +272,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
byte[] buffer = getBuffer (); byte[] buffer = getBuffer ();
byte[] exactBuffer = getExactBuffer (buffer); byte[] exactBuffer = getExactBuffer (buffer);
// System.out.printf ("Name: %s, EOF: %04X%n", name, endOfFile);
try try
{ {

View File

@ -44,7 +44,6 @@ class VolumeDirectoryHeader extends DirectoryHeader
} while (block > 0); } while (block > 0);
// convert the Free Sector Table // convert the Free Sector Table
// int bitMapBytes = totalBlocks / 8; // one bit per block
int bitMapBytes = (totalBlocks - 1) / 8 + 1; // one bit per block int bitMapBytes = (totalBlocks - 1) / 8 + 1; // one bit per block
byte[] buffer = new byte[bitMapBytes]; byte[] buffer = new byte[bitMapBytes];
int bitMapBlocks = (bitMapBytes - 1) / disk.getBlocksPerTrack () + 1; int bitMapBlocks = (bitMapBytes - 1) / disk.getBlocksPerTrack () + 1;
@ -77,19 +76,14 @@ class VolumeDirectoryHeader extends DirectoryHeader
byte b = buffer[i]; byte b = buffer[i];
for (int j = 0; j < 8; j++) for (int j = 0; j < 8; j++)
{ {
if ((b & 0x80) == 0x80) boolean free = (b & 0x80) != 0;
{ if (free)
freeBlocks++; freeBlocks++;
parentDisk.setSectorFree (block++, true); parentDisk.setSectorFree (block++, free);
}
else
{
usedBlocks++;
parentDisk.setSectorFree (block++, false);
}
b <<= 1; b <<= 1;
} }
} }
usedBlocks = totalBlocks - freeBlocks; // totalBlocks may not be a multiple of 8
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//