method header lines

This commit is contained in:
Denis Molony 2020-02-08 09:21:13 +10:00
parent 080976fc48
commit 32de2aa69d
4 changed files with 139 additions and 33 deletions

View File

@ -1,32 +1,42 @@
package com.bytezone.diskbrowser.applefile; package com.bytezone.diskbrowser.applefile;
public class DefaultAppleFile extends AbstractFile // -----------------------------------------------------------------------------------//
{ public class DefaultAppleFile extends AbstractFile
String text; // -----------------------------------------------------------------------------------//
{
public DefaultAppleFile (String name, byte[] buffer) String text;
{
super (name, buffer); // ---------------------------------------------------------------------------------//
} public DefaultAppleFile (String name, byte[] buffer)
// ---------------------------------------------------------------------------------//
public DefaultAppleFile (String name, byte[] buffer, String text) {
{ super (name, buffer);
super (name, buffer); }
this.text = "Name : " + name + "\n\n" + text;
} // ---------------------------------------------------------------------------------//
public DefaultAppleFile (String name, byte[] buffer, String text)
public void setText (String text) // ---------------------------------------------------------------------------------//
{ {
this.text = text; super (name, buffer);
} this.text = "Name : " + name + "\n\n" + text;
}
@Override
public String getText () // ---------------------------------------------------------------------------------//
{ public void setText (String text)
if (text != null) // ---------------------------------------------------------------------------------//
return text; {
if (buffer == null) this.text = text;
return "Invalid file : " + name; }
return super.getText ();
} // ---------------------------------------------------------------------------------//
@Override
public String getText ()
// ---------------------------------------------------------------------------------//
{
if (text != null)
return text;
if (buffer == null)
return "Invalid file : " + name;
return super.getText ();
}
} }

View File

@ -1,13 +1,17 @@
package com.bytezone.diskbrowser.applefile; package com.bytezone.diskbrowser.applefile;
// -----------------------------------------------------------------------------------//
public class DeviceDriver extends AbstractFile public class DeviceDriver extends AbstractFile
// -----------------------------------------------------------------------------------//
{ {
private final int auxType; private final int auxType;
private final int classifications; private final int classifications;
private final int driverClass; private final int driverClass;
private final boolean inactive; private final boolean inactive;
// ---------------------------------------------------------------------------------//
public DeviceDriver (String name, byte[] buffer, int auxType) public DeviceDriver (String name, byte[] buffer, int auxType)
// ---------------------------------------------------------------------------------//
{ {
super (name, buffer); super (name, buffer);
this.auxType = auxType; this.auxType = auxType;
@ -17,8 +21,10 @@ public class DeviceDriver extends AbstractFile
inactive = (auxType & 0x8000) != 0; inactive = (auxType & 0x8000) != 0;
} }
// ---------------------------------------------------------------------------------//
@Override @Override
public String getText () public String getText ()
// ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder ("Name : " + name + "\n\n"); StringBuilder text = new StringBuilder ("Name : " + name + "\n\n");

View File

@ -5,7 +5,9 @@ import java.awt.image.DataBuffer;
import com.bytezone.diskbrowser.utilities.HexFormatter; import com.bytezone.diskbrowser.utilities.HexFormatter;
// -----------------------------------------------------------------------------------//
public class DoubleHiResImage extends HiResImage public class DoubleHiResImage extends HiResImage
// -----------------------------------------------------------------------------------//
{ {
private static int[] swap = { 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 }; private static int[] swap = { 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 };
@ -13,7 +15,9 @@ public class DoubleHiResImage extends HiResImage
private DoubleScrunch doubleScrunch; private DoubleScrunch doubleScrunch;
byte[] packedBuffer; byte[] packedBuffer;
// ---------------------------------------------------------------------------------//
public DoubleHiResImage (String name, byte[] buffer, byte[] auxBuffer) public DoubleHiResImage (String name, byte[] buffer, byte[] auxBuffer)
// ---------------------------------------------------------------------------------//
{ {
super (name, buffer); super (name, buffer);
@ -21,7 +25,9 @@ public class DoubleHiResImage extends HiResImage
createImage (); createImage ();
} }
// ---------------------------------------------------------------------------------//
public DoubleHiResImage (String name, byte[] buffer) public DoubleHiResImage (String name, byte[] buffer)
// ---------------------------------------------------------------------------------//
{ {
super (name, buffer); super (name, buffer);
@ -30,8 +36,8 @@ public class DoubleHiResImage extends HiResImage
if (name.endsWith (".PAC")) if (name.endsWith (".PAC"))
{ {
packedBuffer = buffer; packedBuffer = buffer;
doubleScrunch = new DoubleScrunch (); doubleScrunch = new DoubleScrunch (buffer);
doubleScrunch.unscrunch (buffer); // doubleScrunch.unscrunch (buffer);
auxBuffer = doubleScrunch.memory[0]; auxBuffer = doubleScrunch.memory[0];
this.buffer = doubleScrunch.memory[1]; this.buffer = doubleScrunch.memory[1];
} }
@ -50,8 +56,10 @@ public class DoubleHiResImage extends HiResImage
createImage (); createImage ();
} }
// ---------------------------------------------------------------------------------//
@Override @Override
protected void createMonochromeImage () protected void createMonochromeImage ()
// ---------------------------------------------------------------------------------//
{ {
// image will be doubled vertically // image will be doubled vertically
image = new BufferedImage (560, 192 * 2, BufferedImage.TYPE_BYTE_GRAY); image = new BufferedImage (560, 192 * 2, BufferedImage.TYPE_BYTE_GRAY);
@ -81,8 +89,10 @@ public class DoubleHiResImage extends HiResImage
} }
} }
// ---------------------------------------------------------------------------------//
@Override @Override
protected void createColourImage () protected void createColourImage ()
// ---------------------------------------------------------------------------------//
{ {
paletteIndex = paletteFactory.getCurrentPaletteIndex (); paletteIndex = paletteFactory.getCurrentPaletteIndex ();
Palette palette = paletteFactory.getCurrentPalette (); Palette palette = paletteFactory.getCurrentPalette ();
@ -115,8 +125,10 @@ public class DoubleHiResImage extends HiResImage
} }
} }
// ---------------------------------------------------------------------------------//
@Override @Override
public String getHexDump () public String getHexDump ()
// ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();

View File

@ -1,6 +1,8 @@
package com.bytezone.diskbrowser.utilities; package com.bytezone.diskbrowser.utilities;
// -----------------------------------------------------------------------------------//
public abstract class CPU public abstract class CPU
// -----------------------------------------------------------------------------------//
{ {
// registers // registers
private byte xReg; private byte xReg;
@ -22,12 +24,16 @@ public abstract class CPU
private boolean debug = false; private boolean debug = false;
// ---------------------------------------------------------------------------------//
protected void setDebug (boolean value) protected void setDebug (boolean value)
// ---------------------------------------------------------------------------------//
{ {
debug = value; debug = value;
} }
// ---------------------------------------------------------------------------------//
protected void and (byte mask) // AND protected void and (byte mask) // AND
// ---------------------------------------------------------------------------------//
{ {
aReg &= mask; aReg &= mask;
zero = aReg == 0; zero = aReg == 0;
@ -35,7 +41,9 @@ public abstract class CPU
debug ("AND"); debug ("AND");
} }
// ---------------------------------------------------------------------------------//
protected void asl () // ASL protected void asl () // ASL
// ---------------------------------------------------------------------------------//
{ {
carry = (aReg & 0x80) != 0; // move bit 7 into the carry flag carry = (aReg & 0x80) != 0; // move bit 7 into the carry flag
aReg = (byte) (aReg << 1); // shift left aReg = (byte) (aReg << 1); // shift left
@ -45,7 +53,9 @@ public abstract class CPU
} }
// unfinished // unfinished
// ---------------------------------------------------------------------------------//
protected void bit (byte value) // BIT protected void bit (byte value) // BIT
// ---------------------------------------------------------------------------------//
{ {
byte b = (byte) (aReg & value); byte b = (byte) (aReg & value);
zero = b == 0; zero = b == 0;
@ -54,25 +64,33 @@ public abstract class CPU
debug ("BIT"); debug ("BIT");
} }
// ---------------------------------------------------------------------------------//
protected void clc () // CLC protected void clc () // CLC
// ---------------------------------------------------------------------------------//
{ {
carry = false; carry = false;
debug ("CLC"); debug ("CLC");
} }
// ---------------------------------------------------------------------------------//
protected void cli () // CLI protected void cli () // CLI
// ---------------------------------------------------------------------------------//
{ {
interrupt = false; interrupt = false;
debug ("CLI"); debug ("CLI");
} }
// ---------------------------------------------------------------------------------//
protected void clv () // CLV protected void clv () // CLV
// ---------------------------------------------------------------------------------//
{ {
overflow = false; overflow = false;
debug ("CLV"); debug ("CLV");
} }
// ---------------------------------------------------------------------------------//
protected void cmp (byte value) // CMP protected void cmp (byte value) // CMP
// ---------------------------------------------------------------------------------//
{ {
int tmp = (aReg & 0xFF) - (value & 0xFF); int tmp = (aReg & 0xFF) - (value & 0xFF);
zero = tmp == 0; zero = tmp == 0;
@ -81,7 +99,9 @@ public abstract class CPU
debug ("CMP"); debug ("CMP");
} }
// ---------------------------------------------------------------------------------//
protected void cpx (byte value) // CPX protected void cpx (byte value) // CPX
// ---------------------------------------------------------------------------------//
{ {
int tmp = (xReg & 0xFF) - (value & 0xFF); int tmp = (xReg & 0xFF) - (value & 0xFF);
zero = tmp == 0; zero = tmp == 0;
@ -90,7 +110,9 @@ public abstract class CPU
debug ("CPX"); debug ("CPX");
} }
// ---------------------------------------------------------------------------------//
protected void cpy (byte value) // CPY protected void cpy (byte value) // CPY
// ---------------------------------------------------------------------------------//
{ {
int tmp = (yReg & 0xFF) - (value & 0xFF); int tmp = (yReg & 0xFF) - (value & 0xFF);
zero = tmp == 0; zero = tmp == 0;
@ -99,7 +121,9 @@ public abstract class CPU
debug ("CPY"); debug ("CPY");
} }
// ---------------------------------------------------------------------------------//
protected byte dec (byte value) // DEC protected byte dec (byte value) // DEC
// ---------------------------------------------------------------------------------//
{ {
value = (byte) ((value & 0xFF) - 1); value = (byte) ((value & 0xFF) - 1);
zero = value == 0; zero = value == 0;
@ -108,7 +132,9 @@ public abstract class CPU
return value; return value;
} }
// ---------------------------------------------------------------------------------//
protected byte inc (byte value) // INC protected byte inc (byte value) // INC
// ---------------------------------------------------------------------------------//
{ {
value = (byte) ((value & 0xFF) + 1); value = (byte) ((value & 0xFF) + 1);
zero = value == 0; zero = value == 0;
@ -117,7 +143,9 @@ public abstract class CPU
return value; return value;
} }
// ---------------------------------------------------------------------------------//
protected void inx () // INX protected void inx () // INX
// ---------------------------------------------------------------------------------//
{ {
xReg = (byte) ((xReg & 0xFF) + 1); xReg = (byte) ((xReg & 0xFF) + 1);
xReg &= 0xFF; xReg &= 0xFF;
@ -126,7 +154,9 @@ public abstract class CPU
debug ("INX"); debug ("INX");
} }
// ---------------------------------------------------------------------------------//
protected void lda (byte value) // LDA protected void lda (byte value) // LDA
// ---------------------------------------------------------------------------------//
{ {
aReg = value; aReg = value;
zero = aReg == 0; zero = aReg == 0;
@ -134,7 +164,9 @@ public abstract class CPU
debug ("LDA"); debug ("LDA");
} }
// ---------------------------------------------------------------------------------//
protected void lda (byte[] buffer, int offset) // LDA protected void lda (byte[] buffer, int offset) // LDA
// ---------------------------------------------------------------------------------//
{ {
aReg = buffer[offset]; aReg = buffer[offset];
zero = aReg == 0; zero = aReg == 0;
@ -142,7 +174,9 @@ public abstract class CPU
debug ("LDA"); debug ("LDA");
} }
// ---------------------------------------------------------------------------------//
protected void ldx (byte value) // LDX protected void ldx (byte value) // LDX
// ---------------------------------------------------------------------------------//
{ {
xReg = value; xReg = value;
zero = xReg == 0; zero = xReg == 0;
@ -150,7 +184,9 @@ public abstract class CPU
debug ("LDX"); debug ("LDX");
} }
// ---------------------------------------------------------------------------------//
protected void ldy (byte value) // LDY protected void ldy (byte value) // LDY
// ---------------------------------------------------------------------------------//
{ {
yReg = value; yReg = value;
zero = yReg == 0; zero = yReg == 0;
@ -158,7 +194,9 @@ public abstract class CPU
debug ("LDY"); debug ("LDY");
} }
// ---------------------------------------------------------------------------------//
protected void lsr () // LSR protected void lsr () // LSR
// ---------------------------------------------------------------------------------//
{ {
negative = false; negative = false;
carry = (aReg & 0x01) != 0; carry = (aReg & 0x01) != 0;
@ -167,7 +205,9 @@ public abstract class CPU
debug ("LSR"); debug ("LSR");
} }
// ---------------------------------------------------------------------------------//
protected void ora (byte mask) // ORA protected void ora (byte mask) // ORA
// ---------------------------------------------------------------------------------//
{ {
aReg |= mask; aReg |= mask;
zero = aReg == 0; zero = aReg == 0;
@ -175,7 +215,9 @@ public abstract class CPU
debug ("ORA"); debug ("ORA");
} }
// ---------------------------------------------------------------------------------//
protected void php () // PHP protected void php () // PHP
// ---------------------------------------------------------------------------------//
{ {
byte flags = 0; byte flags = 0;
if (negative) if (negative)
@ -196,7 +238,9 @@ public abstract class CPU
debug ("PHP"); debug ("PHP");
} }
// ---------------------------------------------------------------------------------//
protected void plp () // PLP protected void plp () // PLP
// ---------------------------------------------------------------------------------//
{ {
byte flags = stack[sp++]; byte flags = stack[sp++];
negative = (flags & 0x80) != 0; negative = (flags & 0x80) != 0;
@ -209,13 +253,17 @@ public abstract class CPU
debug ("PLP"); debug ("PLP");
} }
// ---------------------------------------------------------------------------------//
protected void pha () // PHA protected void pha () // PHA
// ---------------------------------------------------------------------------------//
{ {
stack[--sp] = aReg; stack[--sp] = aReg;
debug ("PHA"); debug ("PHA");
} }
// ---------------------------------------------------------------------------------//
protected void pla () // PLA protected void pla () // PLA
// ---------------------------------------------------------------------------------//
{ {
aReg = stack[sp++]; aReg = stack[sp++];
zero = aReg == 0; zero = aReg == 0;
@ -223,7 +271,9 @@ public abstract class CPU
debug ("PLA"); debug ("PLA");
} }
// ---------------------------------------------------------------------------------//
protected void rol () // ROL protected void rol () // ROL
// ---------------------------------------------------------------------------------//
{ {
boolean tempCarry = carry; boolean tempCarry = carry;
carry = (aReg & 0x80) != 0; // move bit 7 into the carry flag carry = (aReg & 0x80) != 0; // move bit 7 into the carry flag
@ -235,7 +285,9 @@ public abstract class CPU
debug ("ROL"); debug ("ROL");
} }
// ---------------------------------------------------------------------------------//
protected byte rol (byte value) // ROL protected byte rol (byte value) // ROL
// ---------------------------------------------------------------------------------//
{ {
boolean tempCarry = carry; boolean tempCarry = carry;
carry = (value & 0x80) != 0; // move bit 7 into the carry flag carry = (value & 0x80) != 0; // move bit 7 into the carry flag
@ -249,7 +301,9 @@ public abstract class CPU
return value; return value;
} }
// ---------------------------------------------------------------------------------//
protected byte ror (byte value) // ROR protected byte ror (byte value) // ROR
// ---------------------------------------------------------------------------------//
{ {
boolean tempCarry = carry; boolean tempCarry = carry;
carry = (value & 0x01) != 0; // move bit 0 into the carry flag carry = (value & 0x01) != 0; // move bit 0 into the carry flag
@ -263,13 +317,17 @@ public abstract class CPU
return value; return value;
} }
// ---------------------------------------------------------------------------------//
protected byte sta () // STA protected byte sta () // STA
// ---------------------------------------------------------------------------------//
{ {
debug ("STA"); debug ("STA");
return aReg; return aReg;
} }
// ---------------------------------------------------------------------------------//
protected void sta (byte[] buffer, int offset) // STA protected void sta (byte[] buffer, int offset) // STA
// ---------------------------------------------------------------------------------//
{ {
buffer[offset] = aReg; buffer[offset] = aReg;
zero = aReg == 0; zero = aReg == 0;
@ -277,19 +335,25 @@ public abstract class CPU
debug ("STA"); debug ("STA");
} }
// ---------------------------------------------------------------------------------//
protected byte stx () // STX protected byte stx () // STX
// ---------------------------------------------------------------------------------//
{ {
debug ("STX"); debug ("STX");
return xReg; return xReg;
} }
// ---------------------------------------------------------------------------------//
protected byte sty () // STY protected byte sty () // STY
// ---------------------------------------------------------------------------------//
{ {
debug ("STY"); debug ("STY");
return yReg; return yReg;
} }
// ---------------------------------------------------------------------------------//
protected void txa () // TXA protected void txa () // TXA
// ---------------------------------------------------------------------------------//
{ {
aReg = xReg; aReg = xReg;
zero = aReg == 0; zero = aReg == 0;
@ -297,7 +361,9 @@ public abstract class CPU
debug ("TXA"); debug ("TXA");
} }
// ---------------------------------------------------------------------------------//
protected void tya () // TYA protected void tya () // TYA
// ---------------------------------------------------------------------------------//
{ {
aReg = yReg; aReg = yReg;
zero = aReg == 0; zero = aReg == 0;
@ -305,7 +371,9 @@ public abstract class CPU
debug ("TYA"); debug ("TYA");
} }
// ---------------------------------------------------------------------------------//
protected void tax () // TAX protected void tax () // TAX
// ---------------------------------------------------------------------------------//
{ {
xReg = aReg; xReg = aReg;
zero = xReg == 0; zero = xReg == 0;
@ -313,7 +381,9 @@ public abstract class CPU
debug ("TAX"); debug ("TAX");
} }
// ---------------------------------------------------------------------------------//
protected void tay () // TAY protected void tay () // TAY
// ---------------------------------------------------------------------------------//
{ {
yReg = aReg; yReg = aReg;
zero = yReg == 0; zero = yReg == 0;
@ -321,18 +391,24 @@ public abstract class CPU
debug ("TAY"); debug ("TAY");
} }
// ---------------------------------------------------------------------------------//
protected void sei () // SEI protected void sei () // SEI
// ---------------------------------------------------------------------------------//
{ {
interrupt = true; interrupt = true;
debug ("SEI"); debug ("SEI");
} }
// ---------------------------------------------------------------------------------//
protected String debugString () protected String debugString ()
// ---------------------------------------------------------------------------------//
{ {
return ""; return "";
} }
// ---------------------------------------------------------------------------------//
protected void debug (String cmd) protected void debug (String cmd)
// ---------------------------------------------------------------------------------//
{ {
if (debug) if (debug)
{ {
@ -344,7 +420,9 @@ public abstract class CPU
} }
} }
// ---------------------------------------------------------------------------------//
protected int indirectY (int base, byte offset, byte page) protected int indirectY (int base, byte offset, byte page)
// ---------------------------------------------------------------------------------//
{ {
if (debug) if (debug)
System.out.printf ("base: %,6d, page: %02X, offset: %02X, yReg: %02X%n", base, page, System.out.printf ("base: %,6d, page: %02X, offset: %02X, yReg: %02X%n", base, page,