mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-18 05:30:29 +00:00
created HeaderFormatter
This commit is contained in:
parent
34c8c16aba
commit
a290327a3e
@ -16,6 +16,7 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
|
||||
private AppleBasicFormatter appleBasicFormatter;
|
||||
private DebugBasicFormatter debugBasicFormatter;
|
||||
private XrefFormatter xrefFormatter;
|
||||
private HeaderFormatter headerFormatter;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public ApplesoftBasicProgram (String name, byte[] buffer)
|
||||
@ -38,6 +39,7 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
|
||||
appleBasicFormatter = new AppleBasicFormatter (this, basicPreferences);
|
||||
debugBasicFormatter = new DebugBasicFormatter (this, basicPreferences);
|
||||
xrefFormatter = new XrefFormatter (this, basicPreferences);
|
||||
headerFormatter = new HeaderFormatter (this, basicPreferences);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -48,7 +50,7 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
if (basicPreferences.showHeader)
|
||||
addHeader (text);
|
||||
headerFormatter.format (text);
|
||||
|
||||
if (showDebugText)
|
||||
{
|
||||
@ -93,14 +95,4 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
|
||||
{
|
||||
return endPtr;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void addHeader (StringBuilder pgm)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
pgm.append ("Name : " + name + "\n");
|
||||
pgm.append (String.format ("Length : $%04X (%<,d)%n", buffer.length));
|
||||
pgm.append (String.format ("Load at : $%04X (%<,d)%n%n",
|
||||
BasicFormatter.getLoadAddress (buffer)));
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@ public abstract class BasicFormatter implements ApplesoftConstants
|
||||
BasicPreferences basicPreferences;
|
||||
byte[] buffer;
|
||||
List<SourceLine> sourceLines;
|
||||
int endPtr;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public BasicFormatter (ApplesoftBasicProgram program, BasicPreferences basicPreferences)
|
||||
@ -26,7 +25,6 @@ public abstract class BasicFormatter implements ApplesoftConstants
|
||||
this.basicPreferences = basicPreferences;
|
||||
this.buffer = program.getBuffer ();
|
||||
this.sourceLines = program.getSourceLines ();
|
||||
this.endPtr = program.getEndPtr ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -37,20 +35,11 @@ public abstract class BasicFormatter implements ApplesoftConstants
|
||||
int getLoadAddress ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
// return program.getLoadAddress ();
|
||||
return getLoadAddress (buffer);
|
||||
return (buffer.length > 1) ? unsignedShort (buffer, 0) - getLineLength (0) : 0;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
static int getLoadAddress (byte[] buffer)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return (buffer.length > 1) ? unsignedShort (buffer, 0) - getLineLength (buffer, 0)
|
||||
: 0;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private static int getLineLength (byte[] buffer, int ptr)
|
||||
private int getLineLength (int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int linkField = unsignedShort (buffer, ptr);
|
||||
|
@ -11,12 +11,16 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
public class DebugBasicFormatter extends BasicFormatter
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
int endPtr;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public DebugBasicFormatter (ApplesoftBasicProgram program,
|
||||
BasicPreferences basicPreferences)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (program, basicPreferences);
|
||||
|
||||
endPtr = program.getEndPtr ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
26
src/com/bytezone/diskbrowser/applefile/HeaderFormatter.java
Normal file
26
src/com/bytezone/diskbrowser/applefile/HeaderFormatter.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
import com.bytezone.diskbrowser.gui.BasicPreferences;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class HeaderFormatter extends BasicFormatter
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public HeaderFormatter (ApplesoftBasicProgram program,
|
||||
BasicPreferences basicPreferences)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (program, basicPreferences);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void format (StringBuilder fullText)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
fullText.append ("Name : " + program.name + "\n");
|
||||
fullText.append (String.format ("Length : $%04X (%<,d)%n", buffer.length));
|
||||
fullText.append (String.format ("Load at : $%04X (%<,d)%n%n", getLoadAddress ()));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user