This commit is contained in:
Denis Molony 2022-09-16 06:26:52 +10:00
parent 23b95675cf
commit 668ed719fa
2 changed files with 30 additions and 22 deletions

View File

@ -10,7 +10,7 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
// -----------------------------------------------------------------------------------//
{
private final List<SourceLine> sourceLines = new ArrayList<> ();
private int ptr; // end-of-program marker
private int ptr = 0; // end-of-program marker
private final UserBasicFormatter userBasicFormatter;
private final AppleBasicFormatter appleBasicFormatter;

View File

@ -89,8 +89,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
lastModified = Utility.getDateTime (entryBuffer, 0x1B);
// CATALOG command only formats the LO byte - see Beneath Apple DOS pp4-6
String base = String.format ("%s%s %03d ", locked ? "*" : " ", getFileType (),
reportedSize & 0xFF);
String base =
String.format ("%s%s %03d ", locked ? "*" : " ", getFileType (), reportedSize & 0xFF);
catalogName = getName (base, entryBuffer);
displayName = getDisplayName (entryBuffer);
}
@ -235,18 +235,28 @@ abstract class AbstractCatalogEntry implements AppleFileSource
case IntegerBasic:
reportedLength = Utility.getShort (buffer, 0);
exactBuffer = new byte[reportedLength];
System.arraycopy (buffer, 2, exactBuffer, 0, reportedLength);
appleFile = new IntegerBasicProgram (name, exactBuffer);
if (reportedLength > 0)
{
exactBuffer = new byte[reportedLength];
System.arraycopy (buffer, 2, exactBuffer, 0, reportedLength);
appleFile = new IntegerBasicProgram (name, exactBuffer);
}
else
appleFile = new DefaultAppleFile (name, buffer);
break;
case ApplesoftBasic:
reportedLength = Utility.getShort (buffer, 0);
exactBuffer = new byte[reportedLength];
if (reportedLength > buffer.length)
reportedLength = buffer.length - 2;
System.arraycopy (buffer, 2, exactBuffer, 0, reportedLength);
appleFile = new ApplesoftBasicProgram (name, exactBuffer);
if (reportedLength > 0)
{
exactBuffer = new byte[reportedLength];
if (reportedLength > buffer.length)
reportedLength = buffer.length - 2;
System.arraycopy (buffer, 2, exactBuffer, 0, reportedLength);
appleFile = new ApplesoftBasicProgram (name, exactBuffer);
}
else
appleFile = new DefaultAppleFile (name, buffer);
break;
case Binary: // binary file
@ -256,8 +266,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
reportedLength = Utility.getShort (buffer, 2);
if (reportedLength == 0)
{
System.out.println (name.trim () + " reported length : 0 - reverting to "
+ (buffer.length - 4));
System.out.println (
name.trim () + " reported length : 0 - reverting to " + (buffer.length - 4));
reportedLength = buffer.length - 4;
}
@ -268,9 +278,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
exactBuffer = new byte[buffer.length - 4]; // reported length is too long
System.arraycopy (buffer, 4, exactBuffer, 0, exactBuffer.length);
if ((name.endsWith (".FONT") || name.endsWith (" FONT")
|| name.endsWith (".SET") || name.startsWith ("ASCII."))
&& FontFile.isFont (exactBuffer))
if ((name.endsWith (".FONT") || name.endsWith (" FONT") || 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);
@ -305,8 +314,7 @@ abstract class AbstractCatalogEntry implements AppleFileSource
appleFile = new AssemblerProgram (name, exactBuffer, loadAddress);
}
else if (reportedLength == 0x240 //
&& (loadAddress == 0x5800 || loadAddress == 0x6000
|| loadAddress == 0x7800))
&& (loadAddress == 0x5800 || loadAddress == 0x6000 || loadAddress == 0x7800))
appleFile = new PrintShopGraphic (name, exactBuffer);
else if (isRunCommand (exactBuffer))
{
@ -319,8 +327,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
{
appleFile = new AssemblerProgram (name, exactBuffer, loadAddress);
if ((exactBuffer.length + 4) < buffer.length)
((AssemblerProgram) appleFile).setExtraBuffer (buffer,
exactBuffer.length + 4, buffer.length - (exactBuffer.length + 4));
((AssemblerProgram) appleFile).setExtraBuffer (buffer, exactBuffer.length + 4,
buffer.length - (exactBuffer.length + 4));
}
break;
@ -362,8 +370,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
int reportedLength = Utility.getShort (buffer, 2);
if (reportedLength == 0)
{
System.out.println (
name.trim () + " reported length : 0 - reverting to " + (buffer.length - 4));
System.out
.println (name.trim () + " reported length : 0 - reverting to " + (buffer.length - 4));
reportedLength = buffer.length - 4;
}