mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-27 14:49:25 +00:00
FontFile
This commit is contained in:
parent
f025c72d1e
commit
343d460679
@ -98,73 +98,73 @@ public class AssemblerProgram extends AbstractFile
|
||||
return pgm.append (getStringBuilder2 ()).toString ();
|
||||
}
|
||||
|
||||
private StringBuilder getStringBuilder ()
|
||||
{
|
||||
if (true)
|
||||
return getStringBuilder2 ();
|
||||
|
||||
StringBuilder pgm = new StringBuilder ();
|
||||
|
||||
int ptr = executeOffset;
|
||||
int address = loadAddress + executeOffset;
|
||||
|
||||
// if the assembly doesn't start at the beginning, just dump the bytes that
|
||||
// are skipped
|
||||
for (int i = 0; i < executeOffset; i++)
|
||||
pgm.append (String.format ("%04X: %02X%n", (loadAddress + i), buffer[i]));
|
||||
|
||||
while (ptr < buffer.length)
|
||||
{
|
||||
StringBuilder line = new StringBuilder ();
|
||||
|
||||
AssemblerStatement cmd = new AssemblerStatement (buffer[ptr]);
|
||||
|
||||
if (cmd.size == 2 && ptr < buffer.length - 1)
|
||||
cmd.addData (buffer[ptr + 1]);
|
||||
else if (cmd.size == 3 && ptr < buffer.length - 2)
|
||||
cmd.addData (buffer[ptr + 1], buffer[ptr + 2]);
|
||||
else
|
||||
cmd.size = 1;
|
||||
|
||||
line.append (String.format ("%04X: ", address));
|
||||
for (int i = 0; i < cmd.size; i++)
|
||||
line.append (String.format ("%02X ", buffer[ptr + i]));
|
||||
while (line.length () < 20)
|
||||
line.append (" ");
|
||||
line.append (cmd.mnemonic + " " + cmd.operand);
|
||||
if (cmd.offset != 0)
|
||||
{
|
||||
int branch = address + cmd.offset + 2;
|
||||
line.append (String.format ("$%04X", branch < 0 ? branch += 0xFFFF : branch));
|
||||
}
|
||||
|
||||
if (cmd.target > 0
|
||||
&& (cmd.target < loadAddress - 1 || cmd.target > (loadAddress + buffer.length)))
|
||||
{
|
||||
while (line.length () < 40)
|
||||
line.append (" ");
|
||||
|
||||
String text = equates.get (cmd.target);
|
||||
if (text != null)
|
||||
line.append ("; " + text);
|
||||
else
|
||||
for (int i = 0, max = ApplesoftConstants.tokenAddresses.length; i < max; i++)
|
||||
if (cmd.target == ApplesoftConstants.tokenAddresses[i])
|
||||
{
|
||||
line.append ("; Applesoft - " + ApplesoftConstants.tokens[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
pgm.append (line.toString () + "\n");
|
||||
address += cmd.size;
|
||||
ptr += cmd.size;
|
||||
}
|
||||
|
||||
if (pgm.length () > 0)
|
||||
pgm.deleteCharAt (pgm.length () - 1);
|
||||
|
||||
return pgm;
|
||||
}
|
||||
// private StringBuilder getStringBuilder ()
|
||||
// {
|
||||
// if (true)
|
||||
// return getStringBuilder2 ();
|
||||
//
|
||||
// StringBuilder pgm = new StringBuilder ();
|
||||
//
|
||||
// int ptr = executeOffset;
|
||||
// int address = loadAddress + executeOffset;
|
||||
//
|
||||
// // if the assembly doesn't start at the beginning, just dump the bytes that
|
||||
// // are skipped
|
||||
// for (int i = 0; i < executeOffset; i++)
|
||||
// pgm.append (String.format ("%04X: %02X%n", (loadAddress + i), buffer[i]));
|
||||
//
|
||||
// while (ptr < buffer.length)
|
||||
// {
|
||||
// StringBuilder line = new StringBuilder ();
|
||||
//
|
||||
// AssemblerStatement cmd = new AssemblerStatement (buffer[ptr]);
|
||||
//
|
||||
// if (cmd.size == 2 && ptr < buffer.length - 1)
|
||||
// cmd.addData (buffer[ptr + 1]);
|
||||
// else if (cmd.size == 3 && ptr < buffer.length - 2)
|
||||
// cmd.addData (buffer[ptr + 1], buffer[ptr + 2]);
|
||||
// else
|
||||
// cmd.size = 1;
|
||||
//
|
||||
// line.append (String.format ("%04X: ", address));
|
||||
// for (int i = 0; i < cmd.size; i++)
|
||||
// line.append (String.format ("%02X ", buffer[ptr + i]));
|
||||
// while (line.length () < 20)
|
||||
// line.append (" ");
|
||||
// line.append (cmd.mnemonic + " " + cmd.operand);
|
||||
// if (cmd.offset != 0)
|
||||
// {
|
||||
// int branch = address + cmd.offset + 2;
|
||||
// line.append (String.format ("$%04X", branch < 0 ? branch += 0xFFFF : branch));
|
||||
// }
|
||||
//
|
||||
// if (cmd.target > 0
|
||||
// && (cmd.target < loadAddress - 1 || cmd.target > (loadAddress + buffer.length)))
|
||||
// {
|
||||
// while (line.length () < 40)
|
||||
// line.append (" ");
|
||||
//
|
||||
// String text = equates.get (cmd.target);
|
||||
// if (text != null)
|
||||
// line.append ("; " + text);
|
||||
// else
|
||||
// for (int i = 0, max = ApplesoftConstants.tokenAddresses.length; i < max; i++)
|
||||
// if (cmd.target == ApplesoftConstants.tokenAddresses[i])
|
||||
// {
|
||||
// line.append ("; Applesoft - " + ApplesoftConstants.tokens[i]);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// pgm.append (line.toString () + "\n");
|
||||
// address += cmd.size;
|
||||
// ptr += cmd.size;
|
||||
// }
|
||||
//
|
||||
// if (pgm.length () > 0)
|
||||
// pgm.deleteCharAt (pgm.length () - 1);
|
||||
//
|
||||
// return pgm;
|
||||
// }
|
||||
|
||||
private StringBuilder getStringBuilder2 ()
|
||||
{
|
||||
@ -197,8 +197,7 @@ public class AssemblerProgram extends AbstractFile
|
||||
int branch = cmd.address + cmd.offset + 2;
|
||||
line.append (String.format ("$%04X", branch < 0 ? branch += 0xFFFF : branch));
|
||||
}
|
||||
|
||||
if (cmd.target > 0
|
||||
else if (cmd.target > 0
|
||||
&& (cmd.target < loadAddress - 1 || cmd.target > (loadAddress + buffer.length)))
|
||||
{
|
||||
while (line.length () < 40)
|
||||
|
78
src/com/bytezone/diskbrowser/applefile/FontFile.java
Normal file
78
src/com/bytezone/diskbrowser/applefile/FontFile.java
Normal file
@ -0,0 +1,78 @@
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FontFile extends AbstractFile
|
||||
{
|
||||
List<Character> characters = new ArrayList<Character> ();
|
||||
|
||||
public FontFile (String name, byte[] buffer)
|
||||
{
|
||||
super (name, buffer);
|
||||
|
||||
int ptr = 0;
|
||||
while (ptr < buffer.length)
|
||||
{
|
||||
Character c = new Character (buffer, ptr);
|
||||
ptr += 8;
|
||||
characters.add (c);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ("Name : " + name + "\n\n");
|
||||
|
||||
for (int i = 0; i < characters.size (); i += 8)
|
||||
{
|
||||
StringBuilder line = new StringBuilder ();
|
||||
for (int j = 0; j < 8; j++)
|
||||
{
|
||||
for (int k = 0; k < 8; k++)
|
||||
{
|
||||
line.append (characters.get (i + k).lines[j]);
|
||||
line.append (" ");
|
||||
}
|
||||
line.append ("\n");
|
||||
}
|
||||
|
||||
text.append (line.toString ());
|
||||
text.append ("\n");
|
||||
}
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
class Character
|
||||
{
|
||||
String[] lines = new String[8];
|
||||
|
||||
public Character (byte[] buffer, int ptr)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int b = buffer[ptr + i] & 0xFF;
|
||||
String s = "0000000" + Integer.toString (b, 2);
|
||||
s = s.substring (s.length () - 7);
|
||||
s = s.replace ('0', ' ');
|
||||
s = s.replace ('1', 'O');
|
||||
s = new StringBuilder (s).reverse ().toString ();
|
||||
lines[i] = s;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
for (String s : lines)
|
||||
text.append (s + "\n");
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
}
|
||||
}
|
@ -33,10 +33,15 @@ public class HiResImage extends AbstractFile
|
||||
private byte[] unpackedBuffer;
|
||||
|
||||
public HiResImage (String name, byte[] buffer)
|
||||
{
|
||||
this (name, buffer, false);
|
||||
}
|
||||
|
||||
public HiResImage (String name, byte[] buffer, boolean scrunched)
|
||||
{
|
||||
super (name, buffer);
|
||||
|
||||
if (name.equals ("FLY LOGO") || name.equals ("BIGBAT.PAC"))
|
||||
if (scrunched)
|
||||
this.buffer = unscrunch (buffer);
|
||||
|
||||
draw ();
|
||||
|
@ -1,5 +1,10 @@
|
||||
* Zero page
|
||||
|
||||
0018 First data track
|
||||
0019 First data sector
|
||||
001A Shape pointer LO
|
||||
001B Shape pointer HI
|
||||
001C Last color used
|
||||
0020 WNDLFT
|
||||
0021 WNDWDTH
|
||||
0022 WNDTOP
|
||||
@ -10,7 +15,9 @@
|
||||
0027 GBAS-HI
|
||||
0028 BAS-LO
|
||||
0029 BAS-HI
|
||||
002B Boot slot * 16
|
||||
0032 INVFLG
|
||||
0033 Prompt character
|
||||
0035 YSAV1
|
||||
0036 CSWL
|
||||
0037 CSHW
|
||||
@ -18,6 +25,12 @@
|
||||
004E RND-LO
|
||||
004F RND-HI
|
||||
0050 LINNUM
|
||||
0067 Basic program address LO
|
||||
0068 Basic program address HI
|
||||
0069 Basic variables address LO
|
||||
006A Basic variables address HI
|
||||
006B Basic arrays address LO
|
||||
006C Basic arrays address HI
|
||||
0073 HIMEM
|
||||
009D FAC
|
||||
009E FAC mantissa hi order
|
||||
@ -26,6 +39,12 @@
|
||||
00B7 CHRGOT
|
||||
00B8 TXTPTR
|
||||
|
||||
00E4 HCOLOR
|
||||
00E8 Shape table address LO
|
||||
00E9 Shape table address HI
|
||||
00EA Collision counter
|
||||
00F9 ROT
|
||||
|
||||
0200 Input buffer
|
||||
|
||||
03D0 Applesoft warm start
|
||||
|
@ -80,12 +80,12 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
||||
if (c > 127)
|
||||
c -= c < 160 ? 64 : 128;
|
||||
if (c < 32)
|
||||
text.append ("^" + (char) (c + 64)); // non-printable ascii
|
||||
text.append ("^" + (char) (c + 64)); // non-printable ascii
|
||||
else
|
||||
text.append ((char) c); // standard ascii
|
||||
text.append ((char) c); // standard ascii
|
||||
}
|
||||
while (text.length () > 0 && text.charAt (text.length () - 1) == ' ')
|
||||
text.deleteCharAt (text.length () - 1); // rtrim()
|
||||
text.deleteCharAt (text.length () - 1); // rtrim()
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
@ -196,7 +196,9 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
||||
|
||||
System.arraycopy (buffer, 4, exactBuffer, 0, exactBuffer.length);
|
||||
|
||||
if (ShapeTable.isShapeTable (exactBuffer))
|
||||
if (name.endsWith (".FONT"))
|
||||
appleFile = new FontFile (name, exactBuffer);
|
||||
else if (ShapeTable.isShapeTable (exactBuffer))
|
||||
appleFile = new ShapeTable (name, exactBuffer);
|
||||
else if (name.endsWith (".S"))
|
||||
appleFile = new MerlinSource (name, exactBuffer);
|
||||
@ -204,11 +206,10 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
||||
appleFile = new HiResImage (name, exactBuffer);
|
||||
else if (loadAddress == 0x2000 || loadAddress == 0x4000)
|
||||
{
|
||||
if ((reportedLength > 0x1F00 && reportedLength <= 0x4000)
|
||||
|| ((name.equals ("FLY LOGO") && reportedLength == 0x14FA)))
|
||||
if (reportedLength > 0x1F00 && reportedLength <= 0x4000)
|
||||
appleFile = new HiResImage (name, exactBuffer);
|
||||
// else if
|
||||
// appleFile = new HiResImage (name, unscrunch (exactBuffer));
|
||||
else if (isScrunched (reportedLength))
|
||||
appleFile = new HiResImage (name, exactBuffer, true);
|
||||
else
|
||||
appleFile = new AssemblerProgram (name, exactBuffer, loadAddress);
|
||||
}
|
||||
@ -219,7 +220,6 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
||||
((AssemblerProgram) appleFile).setExtraBuffer (buffer,
|
||||
exactBuffer.length + 4, buffer.length - (exactBuffer.length + 4));
|
||||
}
|
||||
// }
|
||||
break;
|
||||
|
||||
case SS: // what is this?
|
||||
@ -254,6 +254,18 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
||||
return appleFile;
|
||||
}
|
||||
|
||||
private boolean isScrunched (int reportedLength)
|
||||
{
|
||||
if ((name.equals ("FLY LOGO") || name.equals ("FLY LOGO SCRUNCHED"))
|
||||
&& reportedLength == 0x14FA)
|
||||
return true;
|
||||
|
||||
if (name.equals ("BBROS LOGO SCRUNCHED") && reportedLength == 0x0FED)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains (DiskAddress da)
|
||||
{
|
||||
|
@ -25,8 +25,9 @@ class CatalogEntry extends AbstractCatalogEntry
|
||||
dosDisk.sectorTypes[da.getBlock ()] = dosDisk.tsListSector;
|
||||
else
|
||||
{
|
||||
System.out.printf ("Attempt to assign TS sector to occupied sector "
|
||||
+ ": %s from %s%n", da, name);
|
||||
System.out.printf (
|
||||
"Attempt to assign TS sector to occupied sector " + ": %s from %s%n", da,
|
||||
name);
|
||||
// break;
|
||||
}
|
||||
tsSectors.add (da);
|
||||
@ -50,7 +51,7 @@ class CatalogEntry extends AbstractCatalogEntry
|
||||
{
|
||||
System.out.print ("T/S list in sector " + i);
|
||||
System.out.printf (" contains an invalid address : %02X, %02X (file %s)%n",
|
||||
sectorBuffer[i], sectorBuffer[i + 1], name.trim ());
|
||||
sectorBuffer[i], sectorBuffer[i + 1], name.trim ());
|
||||
break loop;
|
||||
}
|
||||
if (da.getBlock () == 0)
|
||||
@ -79,7 +80,7 @@ class CatalogEntry extends AbstractCatalogEntry
|
||||
{
|
||||
System.out.print ("Next T/S list in sector " + thisDA);
|
||||
System.out.printf (" is invalid : %02X, %02X%n", sectorBuffer[1],
|
||||
sectorBuffer[2]);
|
||||
sectorBuffer[2]);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -136,9 +137,13 @@ class CatalogEntry extends AbstractCatalogEntry
|
||||
message += "Bad size (" + reportedSize + ") ";
|
||||
if (dataSectors.size () == 0)
|
||||
message += "No data ";
|
||||
return String.format ("%1s %1s %03d %-30.30s %-5s " + "%-13s %2d %3d %s",
|
||||
lockedFlag, getFileType (), actualSize, name, addressText,
|
||||
lengthText, tsSectors.size (),
|
||||
(dataSectors.size () - textFileGaps), message.trim ());
|
||||
|
||||
String text =
|
||||
String.format ("%1s %1s %03d %-30.30s %-5s " + "%-13s %2d %3d %s",
|
||||
lockedFlag, getFileType (), actualSize, name, addressText, lengthText,
|
||||
tsSectors.size (), (dataSectors.size () - textFileGaps), message.trim ());
|
||||
if (actualSize == 0)
|
||||
text = text.substring (0, 50);
|
||||
return text;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user