mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-06-03 01:29:32 +00:00
Removed stupid HexFormatter call
This commit is contained in:
parent
871fb79913
commit
5ed0d0d16a
|
@ -61,14 +61,15 @@ public class AssemblerStatement
|
||||||
lastMnemonic = as.mnemonic;
|
lastMnemonic = as.mnemonic;
|
||||||
System.out.println ();
|
System.out.println ();
|
||||||
}
|
}
|
||||||
System.out.printf ("%3s %-15s %s%n", as.mnemonic, AssemblerConstants.mode[as.mode], as);
|
System.out.printf ("%3s %-15s %s%n", as.mnemonic,
|
||||||
|
AssemblerConstants.mode[as.mode], as);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AssemblerStatement (byte opcode)
|
public AssemblerStatement (byte opcode)
|
||||||
{
|
{
|
||||||
this.value = opcode;
|
this.value = opcode;
|
||||||
this.opcode = HexFormatter.intValue (opcode);
|
this.opcode = opcode & 0xFF;
|
||||||
this.mnemonic = AssemblerConstants.mnemonics[this.opcode];
|
this.mnemonic = AssemblerConstants.mnemonics[this.opcode];
|
||||||
this.size = AssemblerConstants.sizes2[this.opcode];
|
this.size = AssemblerConstants.sizes2[this.opcode];
|
||||||
this.operand = "";
|
this.operand = "";
|
||||||
|
@ -128,8 +129,8 @@ public class AssemblerStatement
|
||||||
{
|
{
|
||||||
operand1 = b;
|
operand1 = b;
|
||||||
String address = "$" + HexFormatter.format2 (b);
|
String address = "$" + HexFormatter.format2 (b);
|
||||||
// if (this.mnemonic.equals ("JSR"))
|
// if (this.mnemonic.equals ("JSR"))
|
||||||
// this.target = HexFormatter.intValue (b);
|
// this.target = HexFormatter.intValue (b);
|
||||||
|
|
||||||
switch (this.opcode)
|
switch (this.opcode)
|
||||||
{
|
{
|
||||||
|
@ -173,7 +174,7 @@ public class AssemblerStatement
|
||||||
case 0xE4: // CPX
|
case 0xE4: // CPX
|
||||||
case 0xE5: // SBC
|
case 0xE5: // SBC
|
||||||
case 0xE6: // INC
|
case 0xE6: // INC
|
||||||
target = HexFormatter.intValue (b);
|
target = b & 0xFF;
|
||||||
operand = address;
|
operand = address;
|
||||||
mode = 8; // Zero page
|
mode = 8; // Zero page
|
||||||
break;
|
break;
|
||||||
|
@ -253,7 +254,7 @@ public class AssemblerStatement
|
||||||
case 0xF0: // BEQ
|
case 0xF0: // BEQ
|
||||||
offset = b;
|
offset = b;
|
||||||
mode = 14; // relative
|
mode = 14; // relative
|
||||||
this.target = HexFormatter.intValue (b);
|
this.target = b & 0xFF;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -266,10 +267,10 @@ public class AssemblerStatement
|
||||||
operand1 = b1;
|
operand1 = b1;
|
||||||
operand2 = b2;
|
operand2 = b2;
|
||||||
String address = "$" + HexFormatter.format2 (b2) + HexFormatter.format2 (b1);
|
String address = "$" + HexFormatter.format2 (b2) + HexFormatter.format2 (b1);
|
||||||
// if (this.mnemonic.equals ("JSR") || this.mnemonic.equals ("JMP")
|
// if (this.mnemonic.equals ("JSR") || this.mnemonic.equals ("JMP")
|
||||||
// || this.mnemonic.equals ("BIT") || this.mnemonic.equals ("STA")
|
// || this.mnemonic.equals ("BIT") || this.mnemonic.equals ("STA")
|
||||||
// || this.mnemonic.equals ("LDA"))
|
// || this.mnemonic.equals ("LDA"))
|
||||||
// this.target = HexFormatter.intValue (b1, b2);
|
// this.target = HexFormatter.intValue (b1, b2);
|
||||||
|
|
||||||
switch (this.opcode)
|
switch (this.opcode)
|
||||||
{
|
{
|
||||||
|
@ -358,6 +359,7 @@ public class AssemblerStatement
|
||||||
{
|
{
|
||||||
if (offset == 0)
|
if (offset == 0)
|
||||||
return String.format ("%d %3s %-10s %02X", size, mnemonic, operand, value);
|
return String.format ("%d %3s %-10s %02X", size, mnemonic, operand, value);
|
||||||
return String.format ("%d %3s %-10s %02X", size, mnemonic, operand + "+" + offset, value);
|
return String.format ("%d %3s %-10s %02X", size, mnemonic, operand + "+" + offset,
|
||||||
|
value);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,31 +1,30 @@
|
||||||
package com.bytezone.diskbrowser.applefile;
|
package com.bytezone.diskbrowser.applefile;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
|
||||||
|
|
||||||
public class Charset extends AbstractFile
|
public class Charset extends AbstractFile
|
||||||
{
|
{
|
||||||
public Charset (String name, byte[] buffer)
|
public Charset (String name, byte[] buffer)
|
||||||
{
|
{
|
||||||
super (name, buffer);
|
super (name, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getText ()
|
@Override
|
||||||
{
|
public String getText ()
|
||||||
StringBuilder text = new StringBuilder ();
|
{
|
||||||
for (int i = 0; i < buffer.length; i += 8)
|
StringBuilder text = new StringBuilder ();
|
||||||
{
|
for (int i = 0; i < buffer.length; i += 8)
|
||||||
for (int line = 7; line >= 0; line--)
|
{
|
||||||
{
|
for (int line = 7; line >= 0; line--)
|
||||||
int value = HexFormatter.intValue (buffer[i + line]);
|
{
|
||||||
for (int bit = 0; bit < 8; bit++)
|
int value = buffer[i + line] & 0xFF;
|
||||||
{
|
for (int bit = 0; bit < 8; bit++)
|
||||||
text.append ((value & 0x01) == 1 ? "X" : ".");
|
{
|
||||||
value >>= 1;
|
text.append ((value & 0x01) == 1 ? "X" : ".");
|
||||||
}
|
value >>= 1;
|
||||||
text.append ("\n");
|
}
|
||||||
}
|
text.append ("\n");
|
||||||
text.append ("\n");
|
}
|
||||||
}
|
text.append ("\n");
|
||||||
return text.toString ();
|
}
|
||||||
}
|
return text.toString ();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -5,17 +5,18 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
public class IntegerBasicProgram extends AbstractFile
|
public class IntegerBasicProgram extends AbstractFile
|
||||||
{
|
{
|
||||||
private static String[] tokens =
|
private static String[] tokens =
|
||||||
{ "?", "?", "?", " : ", "?", "?", "?", "?", "?", "?", "?", "?", "CLR", "?", "?", "?",
|
{ "?", "?", "?", " : ", "?", "?", "?", "?", "?", "?", "?", "?", "CLR", "?", "?",
|
||||||
"HIMEM: ", "LOMEM: ", " + ", " - ", " * ", " / ", " = ", " # ", " >= ", " > ",
|
"?", "HIMEM: ", "LOMEM: ", " + ", " - ", " * ", " / ", " = ", " # ", " >= ",
|
||||||
" <= ", " <> ", " < ", " AND ", " OR ", " MOD ", "^", "+", "(", ",", " THEN ",
|
" > ", " <= ", " <> ", " < ", " AND ", " OR ", " MOD ", "^", "+", "(", ",",
|
||||||
" THEN ", ",", ",", "\"", "\"", "(", "!", "!", "(", "PEEK ", "RND ", "SGN", "ABS",
|
" THEN ", " THEN ", ",", ",", "\"", "\"", "(", "!", "!", "(", "PEEK ", "RND ",
|
||||||
"PDL", "RNDX", "(", "+", "-", "NOT ", "(", "=", "#", "LEN(", "ASC(", "SCRN(", ",",
|
"SGN", "ABS", "PDL", "RNDX", "(", "+", "-", "NOT ", "(", "=", "#", "LEN(", "ASC(",
|
||||||
"(", "$", "$", "(", ", ", ",", ";", ";", ";", ",", ",", ",", "TEXT", "GR ", "CALL ",
|
"SCRN(", ",", "(", "$", "$", "(", ", ", ",", ";", ";", ";", ",", ",", ",", "TEXT",
|
||||||
"DIM ", "DIM ", "TAB ", "END", "INPUT ", "INPUT ", "INPUT ", "FOR ", " = ", " TO ",
|
"GR ", "CALL ", "DIM ", "DIM ", "TAB ", "END", "INPUT ", "INPUT ", "INPUT ",
|
||||||
" STEP ", "NEXT ", ",", "RETURN", "GOSUB ", "REM ", "LET ", "GOTO ", "IF ", "PRINT ",
|
"FOR ", " = ", " TO ", " STEP ", "NEXT ", ",", "RETURN", "GOSUB ", "REM ", "LET ",
|
||||||
"PRINT ", "PRINT", "POKE ", ",", "COLOR=", "PLOT", ",", "HLIN", ",", " AT ", "VLIN ",
|
"GOTO ", "IF ", "PRINT ", "PRINT ", "PRINT", "POKE ", ",", "COLOR=", "PLOT", ",",
|
||||||
",", " AT ", "VTAB ", " = ", " = ", ")", ")", "LIST ", ",", "LIST ", "POP ",
|
"HLIN", ",", " AT ", "VLIN ", ",", " AT ", "VTAB ", " = ", " = ", ")", ")",
|
||||||
"NODSP ", "NODSP ", "NOTRACE ", "DSP ", "DSP ", "TRACE ", "PR#", "IN#", };
|
"LIST ", ",", "LIST ", "POP ", "NODSP ", "NODSP ", "NOTRACE ", "DSP ", "DSP ",
|
||||||
|
"TRACE ", "PR#", "IN#", };
|
||||||
|
|
||||||
public IntegerBasicProgram (String name, byte[] buffer)
|
public IntegerBasicProgram (String name, byte[] buffer)
|
||||||
{
|
{
|
||||||
|
@ -27,8 +28,8 @@ public class IntegerBasicProgram extends AbstractFile
|
||||||
{
|
{
|
||||||
StringBuilder pgm = new StringBuilder ();
|
StringBuilder pgm = new StringBuilder ();
|
||||||
pgm.append ("Name : " + name + "\n");
|
pgm.append ("Name : " + name + "\n");
|
||||||
pgm.append ("Length : $" + HexFormatter.format4 (buffer.length) + " (" + buffer.length
|
pgm.append ("Length : $" + HexFormatter.format4 (buffer.length) + " ("
|
||||||
+ ")\n\n");
|
+ buffer.length + ")\n\n");
|
||||||
int ptr = 0;
|
int ptr = 0;
|
||||||
|
|
||||||
boolean looksLikeAssembler = checkForAssembler (); // this can probably go
|
boolean looksLikeAssembler = checkForAssembler (); // this can probably go
|
||||||
|
@ -36,7 +37,7 @@ public class IntegerBasicProgram extends AbstractFile
|
||||||
|
|
||||||
while (ptr < buffer.length)
|
while (ptr < buffer.length)
|
||||||
{
|
{
|
||||||
int lineLength = HexFormatter.intValue (buffer[ptr]);
|
int lineLength = buffer[ptr] & 0xFF;
|
||||||
/*
|
/*
|
||||||
* It appears that lines ending in 00 are S-C Assembler programs, and
|
* It appears that lines ending in 00 are S-C Assembler programs, and
|
||||||
* lines ending in 01 are Integer Basic programs.
|
* lines ending in 01 are Integer Basic programs.
|
||||||
|
@ -86,7 +87,7 @@ public class IntegerBasicProgram extends AbstractFile
|
||||||
pgm.append (' ');
|
pgm.append (' ');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int b = HexFormatter.intValue (buffer[i]);
|
int b = buffer[i] & 0xFF;
|
||||||
pgm.append ((char) b);
|
pgm.append ((char) b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +98,7 @@ public class IntegerBasicProgram extends AbstractFile
|
||||||
|
|
||||||
while (ptr < buffer.length)
|
while (ptr < buffer.length)
|
||||||
{
|
{
|
||||||
int lineLength = HexFormatter.intValue (buffer[ptr]);
|
int lineLength = buffer[ptr] & 0xFF;
|
||||||
if (lineLength == 255)
|
if (lineLength == 255)
|
||||||
System.out.printf ("Line length %d%n", lineLength);
|
System.out.printf ("Line length %d%n", lineLength);
|
||||||
int p2 = ptr + lineLength - 1;
|
int p2 = ptr + lineLength - 1;
|
||||||
|
@ -122,7 +123,7 @@ public class IntegerBasicProgram extends AbstractFile
|
||||||
System.out.println ("Empty buffer array");
|
System.out.println ("Empty buffer array");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int lineLength = HexFormatter.intValue (buffer[0]);
|
int lineLength = buffer[0] & 0xFF;
|
||||||
if (lineLength <= 0)
|
if (lineLength <= 0)
|
||||||
return false;
|
return false;
|
||||||
return buffer[lineLength - 1] == 0;
|
return buffer[lineLength - 1] == 0;
|
||||||
|
@ -130,8 +131,7 @@ public class IntegerBasicProgram extends AbstractFile
|
||||||
|
|
||||||
private void appendSCAssembler (StringBuilder pgm, int ptr, int lineLength)
|
private void appendSCAssembler (StringBuilder pgm, int ptr, int lineLength)
|
||||||
{
|
{
|
||||||
int lineNumber = HexFormatter.intValue (buffer[ptr + 2]) * 256
|
int lineNumber = (buffer[ptr + 2] & 0xFF) * 256 + (buffer[ptr + 1] & 0xFF);
|
||||||
+ HexFormatter.intValue (buffer[ptr + 1]);
|
|
||||||
pgm.append (String.format ("%4d: ", lineNumber));
|
pgm.append (String.format ("%4d: ", lineNumber));
|
||||||
int p2 = ptr + 3;
|
int p2 = ptr + 3;
|
||||||
while (buffer[p2] != 0)
|
while (buffer[p2] != 0)
|
||||||
|
@ -168,18 +168,18 @@ public class IntegerBasicProgram extends AbstractFile
|
||||||
|
|
||||||
for (int p = ptr + 3; p < ptr + lineLength - 1; p++)
|
for (int p = ptr + 3; p < ptr + lineLength - 1; p++)
|
||||||
{
|
{
|
||||||
int b = HexFormatter.intValue (buffer[p]);
|
int b = buffer[p] & 0xFF;
|
||||||
|
|
||||||
if (b == 0x03 // token for colon (:)
|
if (b == 0x03 // token for colon (:)
|
||||||
&& !inString && !inRemark && buffer[p + 1] != 1) // not end of line
|
&& !inString && !inRemark && buffer[p + 1] != 1) // not end of line
|
||||||
{
|
{
|
||||||
pgm.append (":\n" + " ".substring (0, lineTab));
|
pgm.append (":\n" + " ".substring (0, lineTab));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b >= 0xB0 && b <= 0xB9 // numeric literal
|
if (b >= 0xB0 && b <= 0xB9 // numeric literal
|
||||||
&& (buffer[p - 1] & 0x80) == 0 // not a variable name
|
&& (buffer[p - 1] & 0x80) == 0 // not a variable name
|
||||||
&& !inString && !inRemark)
|
&& !inString && !inRemark)
|
||||||
{
|
{
|
||||||
pgm.append (HexFormatter.intValue (buffer[p + 1], buffer[p + 2]));
|
pgm.append (HexFormatter.intValue (buffer[p + 1], buffer[p + 2]));
|
||||||
p += 2;
|
p += 2;
|
||||||
|
@ -217,13 +217,13 @@ public class IntegerBasicProgram extends AbstractFile
|
||||||
|
|
||||||
pgm.append ("Name : " + name + "\n");
|
pgm.append ("Name : " + name + "\n");
|
||||||
pgm.append ("Length : $" + HexFormatter.format4 (buffer.length) + " (" + buffer.length
|
pgm.append ("Length : $" + HexFormatter.format4 (buffer.length) + " (" + buffer.length
|
||||||
+ ")\n\n");
|
+ ")\n\n");
|
||||||
|
|
||||||
int ptr = 0;
|
int ptr = 0;
|
||||||
|
|
||||||
while (ptr < buffer.length)
|
while (ptr < buffer.length)
|
||||||
{
|
{
|
||||||
int lineLength = HexFormatter.intValue (buffer[ptr]);
|
int lineLength = buffer[ptr] & 0xFF;
|
||||||
int p2 = ptr + lineLength - 1;
|
int p2 = ptr + lineLength - 1;
|
||||||
if (p2 < 0 || p2 >= buffer.length || buffer[p2] > 1)
|
if (p2 < 0 || p2 >= buffer.length || buffer[p2] > 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,18 @@ import java.util.List;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Offset Meaning
|
||||||
|
* 0 # of shapes
|
||||||
|
* 1 unused
|
||||||
|
* 2-3 offset to shape #1 (S1)
|
||||||
|
* 3-4 offset to shape #2 (S2)
|
||||||
|
* S1-S1+1 shape definition #1
|
||||||
|
* S1+n last byte = 0
|
||||||
|
* S2-S2+1 shape definition #1
|
||||||
|
* S2+n last byte = 0
|
||||||
|
*/
|
||||||
|
|
||||||
public class ShapeTable extends AbstractFile
|
public class ShapeTable extends AbstractFile
|
||||||
{
|
{
|
||||||
private static final int SIZE = 400;
|
private static final int SIZE = 400;
|
||||||
|
@ -23,7 +35,7 @@ public class ShapeTable extends AbstractFile
|
||||||
|
|
||||||
for (int i = 0; i < totalShapes; i++)
|
for (int i = 0; i < totalShapes; i++)
|
||||||
{
|
{
|
||||||
int offset = HexFormatter.intValue (buffer[i * 2 + 2], buffer[i * 2 + 3]);
|
int offset = HexFormatter.getShort (buffer, i * 2 + 2);
|
||||||
int[][] grid = new int[SIZE][SIZE];
|
int[][] grid = new int[SIZE][SIZE];
|
||||||
int row = startPos;
|
int row = startPos;
|
||||||
int col = row;
|
int col = row;
|
||||||
|
@ -147,7 +159,7 @@ public class ShapeTable extends AbstractFile
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// check index points inside the file
|
// check index points inside the file
|
||||||
int offset = HexFormatter.intValue (buffer[ptr], buffer[ptr + 1]);
|
int offset = HexFormatter.getShort (buffer, ptr);
|
||||||
if (offset == 0 || offset >= buffer.length)
|
if (offset == 0 || offset >= buffer.length)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -4,239 +4,242 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
|
|
||||||
public class StoredVariables extends AbstractFile
|
public class StoredVariables extends AbstractFile
|
||||||
{
|
{
|
||||||
public StoredVariables (String name, byte[] buffer)
|
public StoredVariables (String name, byte[] buffer)
|
||||||
{
|
{
|
||||||
super (name, buffer);
|
super (name, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getText ()
|
@Override
|
||||||
{
|
public String getText ()
|
||||||
StringBuilder text = new StringBuilder ();
|
{
|
||||||
String strValue = null;
|
StringBuilder text = new StringBuilder ();
|
||||||
int intValue = 0;
|
String strValue = null;
|
||||||
// double doubleValue = 0.0;
|
int intValue = 0;
|
||||||
int strPtr = buffer.length;
|
// double doubleValue = 0.0;
|
||||||
|
int strPtr = buffer.length;
|
||||||
|
|
||||||
text.append ("File length : " + HexFormatter.format4 (buffer.length));
|
text.append ("File length : " + HexFormatter.format4 (buffer.length));
|
||||||
int totalLength = HexFormatter.intValue (buffer[0], buffer[1]);
|
int totalLength = HexFormatter.intValue (buffer[0], buffer[1]);
|
||||||
text.append ("\nTotal length : " + HexFormatter.format4 (totalLength));
|
text.append ("\nTotal length : " + HexFormatter.format4 (totalLength));
|
||||||
|
|
||||||
int varLength = HexFormatter.intValue (buffer[2], buffer[3]);
|
int varLength = HexFormatter.intValue (buffer[2], buffer[3]);
|
||||||
text.append ("\nVar length : " + HexFormatter.format4 (varLength));
|
text.append ("\nVar length : " + HexFormatter.format4 (varLength));
|
||||||
text.append ("\n\n");
|
text.append ("\n\n");
|
||||||
|
|
||||||
// list simple variables
|
// list simple variables
|
||||||
|
|
||||||
int ptr = 5;
|
int ptr = 5;
|
||||||
while (ptr < varLength + 5)
|
while (ptr < varLength + 5)
|
||||||
{
|
{
|
||||||
String variableName = getVariableName (buffer[ptr], buffer[ptr + 1]);
|
String variableName = getVariableName (buffer[ptr], buffer[ptr + 1]);
|
||||||
text.append (variableName);
|
text.append (variableName);
|
||||||
|
|
||||||
char suffix = variableName.charAt (variableName.length () - 1);
|
char suffix = variableName.charAt (variableName.length () - 1);
|
||||||
if (suffix == '$')
|
if (suffix == '$')
|
||||||
{
|
{
|
||||||
int strLength = HexFormatter.intValue (buffer[ptr + 2]);
|
int strLength = buffer[ptr + 2] & 0xFF;
|
||||||
strPtr -= strLength;
|
strPtr -= strLength;
|
||||||
strValue = HexFormatter.getString (buffer, strPtr, strLength);
|
strValue = HexFormatter.getString (buffer, strPtr, strLength);
|
||||||
text.append (" = " + strValue);
|
text.append (" = " + strValue);
|
||||||
}
|
}
|
||||||
else if (suffix == '%')
|
else if (suffix == '%')
|
||||||
{
|
{
|
||||||
intValue = HexFormatter.intValue (buffer[ptr + 3], buffer[ptr + 2]);
|
intValue = HexFormatter.intValue (buffer[ptr + 3], buffer[ptr + 2]);
|
||||||
if ((buffer[ptr + 2] & 0x80) > 0)
|
if ((buffer[ptr + 2] & 0x80) > 0)
|
||||||
intValue -= 65536;
|
intValue -= 65536;
|
||||||
text.append (" = " + intValue);
|
text.append (" = " + intValue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (hasValue (ptr + 2))
|
if (hasValue (ptr + 2))
|
||||||
{
|
{
|
||||||
String value = HexFormatter.floatValue (buffer, ptr + 2) + "";
|
String value = HexFormatter.floatValue (buffer, ptr + 2) + "";
|
||||||
if (value.endsWith (".0"))
|
if (value.endsWith (".0"))
|
||||||
text.append (" = " + value.substring (0, value.length () - 2));
|
text.append (" = " + value.substring (0, value.length () - 2));
|
||||||
else
|
else
|
||||||
text.append (" = " + value);
|
text.append (" = " + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
text.append ("\n");
|
text.append ("\n");
|
||||||
ptr += 7;
|
ptr += 7;
|
||||||
}
|
}
|
||||||
listArrays (text, ptr, totalLength, strPtr);
|
listArrays (text, ptr, totalLength, strPtr);
|
||||||
|
|
||||||
return text.toString ();
|
return text.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getVariableName (byte b1, byte b2)
|
private String getVariableName (byte b1, byte b2)
|
||||||
{
|
{
|
||||||
char c1, c2, suffix;
|
char c1, c2, suffix;
|
||||||
|
|
||||||
if ((b1 & 0x80) > 0) // integer
|
if ((b1 & 0x80) > 0) // integer
|
||||||
{
|
{
|
||||||
c1 = (char) (b1 & 0x7F);
|
c1 = (char) (b1 & 0x7F);
|
||||||
c2 = (char) (b2 & 0x7F);
|
c2 = (char) (b2 & 0x7F);
|
||||||
suffix = '%';
|
suffix = '%';
|
||||||
}
|
}
|
||||||
else if ((b2 & 0x80) > 0) // string
|
else if ((b2 & 0x80) > 0) // string
|
||||||
{
|
{
|
||||||
c1 = (char) b1;
|
c1 = (char) b1;
|
||||||
c2 = (char) (b2 & 0x7F);
|
c2 = (char) (b2 & 0x7F);
|
||||||
suffix = '$';
|
suffix = '$';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
c1 = (char) b1;
|
c1 = (char) b1;
|
||||||
c2 = (char) b2;
|
c2 = (char) b2;
|
||||||
suffix = ' ';
|
suffix = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuffer variableName = new StringBuffer ();
|
StringBuffer variableName = new StringBuffer ();
|
||||||
variableName.append (c1);
|
variableName.append (c1);
|
||||||
if (c2 > 32)
|
if (c2 > 32)
|
||||||
variableName.append (c2);
|
variableName.append (c2);
|
||||||
if (suffix != ' ')
|
if (suffix != ' ')
|
||||||
variableName.append (suffix);
|
variableName.append (suffix);
|
||||||
|
|
||||||
return variableName.toString ();
|
return variableName.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDimensionText (int[] values)
|
private String getDimensionText (int[] values)
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ("(");
|
StringBuilder text = new StringBuilder ("(");
|
||||||
for (int i = 0; i < values.length; i++)
|
for (int i = 0; i < values.length; i++)
|
||||||
{
|
{
|
||||||
text.append (values[i]);
|
text.append (values[i]);
|
||||||
if (i < values.length - 1)
|
if (i < values.length - 1)
|
||||||
text.append (',');
|
text.append (',');
|
||||||
}
|
}
|
||||||
return text.append (')').toString ();
|
return text.append (')').toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void listArrays (StringBuilder text, int ptr, int totalLength, int strPtr)
|
private void listArrays (StringBuilder text, int ptr, int totalLength, int strPtr)
|
||||||
{
|
{
|
||||||
while (ptr < totalLength + 5)
|
while (ptr < totalLength + 5)
|
||||||
{
|
{
|
||||||
String variableName = getVariableName (buffer[ptr], buffer[ptr + 1]);
|
String variableName = getVariableName (buffer[ptr], buffer[ptr + 1]);
|
||||||
text.append ("\n");
|
text.append ("\n");
|
||||||
int offset = HexFormatter.intValue (buffer[ptr + 2], buffer[ptr + 3]);
|
int offset = HexFormatter.intValue (buffer[ptr + 2], buffer[ptr + 3]);
|
||||||
int dimensions = HexFormatter.intValue (buffer[ptr + 4]);
|
int dimensions = buffer[ptr + 4] & 0xFF;
|
||||||
int[] dimensionSizes = new int[dimensions];
|
int[] dimensionSizes = new int[dimensions];
|
||||||
int totalElements = 0;
|
int totalElements = 0;
|
||||||
for (int i = 0; i < dimensions; i++)
|
for (int i = 0; i < dimensions; i++)
|
||||||
{
|
{
|
||||||
int p = i * 2 + 5 + ptr;
|
int p = i * 2 + 5 + ptr;
|
||||||
int elements = HexFormatter.intValue (buffer[p + 1], buffer[p]);
|
int elements = HexFormatter.intValue (buffer[p + 1], buffer[p]);
|
||||||
dimensionSizes[dimensions - i - 1] = elements - 1;
|
dimensionSizes[dimensions - i - 1] = elements - 1;
|
||||||
if (totalElements == 0)
|
if (totalElements == 0)
|
||||||
totalElements = elements;
|
totalElements = elements;
|
||||||
else
|
else
|
||||||
totalElements *= elements;
|
totalElements *= elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
int headerSize = 5 + dimensions * 2;
|
int headerSize = 5 + dimensions * 2;
|
||||||
int elementSize = (offset - headerSize) / totalElements;
|
int elementSize = (offset - headerSize) / totalElements;
|
||||||
|
|
||||||
int p = ptr + headerSize;
|
int p = ptr + headerSize;
|
||||||
int[] values = new int[dimensions];
|
int[] values = new int[dimensions];
|
||||||
for (int i = 0; i < values.length; i++)
|
for (int i = 0; i < values.length; i++)
|
||||||
values[i] = 0;
|
values[i] = 0;
|
||||||
out: while (true)
|
out: while (true)
|
||||||
{
|
{
|
||||||
text.append (variableName + " " + getDimensionText (values) + " = ");
|
text.append (variableName + " " + getDimensionText (values) + " = ");
|
||||||
if (elementSize == 2)
|
if (elementSize == 2)
|
||||||
{
|
{
|
||||||
int intValue = HexFormatter.intValue (buffer[p + 1], buffer[p]);
|
int intValue = HexFormatter.intValue (buffer[p + 1], buffer[p]);
|
||||||
if ((buffer[p] & 0x80) > 0)
|
if ((buffer[p] & 0x80) > 0)
|
||||||
intValue -= 65536;
|
intValue -= 65536;
|
||||||
text.append (intValue + "\n");
|
text.append (intValue + "\n");
|
||||||
}
|
}
|
||||||
else if (elementSize == 3)
|
else if (elementSize == 3)
|
||||||
{
|
{
|
||||||
int strLength = HexFormatter.intValue (buffer[p]);
|
int strLength = buffer[p] & 0xFF;
|
||||||
if (strLength > 0)
|
if (strLength > 0)
|
||||||
{
|
{
|
||||||
strPtr -= strLength;
|
strPtr -= strLength;
|
||||||
text.append (HexFormatter.getString (buffer, strPtr, strLength));
|
text.append (HexFormatter.getString (buffer, strPtr, strLength));
|
||||||
}
|
}
|
||||||
text.append ("\n");
|
text.append ("\n");
|
||||||
}
|
}
|
||||||
else if (elementSize == 5)
|
else if (elementSize == 5)
|
||||||
{
|
{
|
||||||
if (hasValue (p))
|
if (hasValue (p))
|
||||||
text.append (HexFormatter.floatValue (buffer, p));
|
text.append (HexFormatter.floatValue (buffer, p));
|
||||||
text.append ("\n");
|
text.append ("\n");
|
||||||
}
|
}
|
||||||
p += elementSize;
|
p += elementSize;
|
||||||
int cp = 0;
|
int cp = 0;
|
||||||
while (++values[cp] > dimensionSizes[cp])
|
while (++values[cp] > dimensionSizes[cp])
|
||||||
{
|
{
|
||||||
values[cp++] = 0;
|
values[cp++] = 0;
|
||||||
if (cp >= values.length)
|
if (cp >= values.length)
|
||||||
break out;
|
break out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ptr += offset;
|
ptr += offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasValue (int p)
|
private boolean hasValue (int p)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
if (buffer[p + i] != 0)
|
if (buffer[p + i] != 0)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHexDump ()
|
@Override
|
||||||
{
|
public String getHexDump ()
|
||||||
StringBuffer text = new StringBuffer ();
|
{
|
||||||
|
StringBuffer text = new StringBuffer ();
|
||||||
|
|
||||||
text.append ("File length : " + HexFormatter.format4 (buffer.length));
|
text.append ("File length : " + HexFormatter.format4 (buffer.length));
|
||||||
int totalLength = HexFormatter.intValue (buffer[0], buffer[1]);
|
int totalLength = HexFormatter.intValue (buffer[0], buffer[1]);
|
||||||
text.append ("\nTotal length : " + HexFormatter.format4 (totalLength));
|
text.append ("\nTotal length : " + HexFormatter.format4 (totalLength));
|
||||||
|
|
||||||
int varLength = HexFormatter.intValue (buffer[2], buffer[3]);
|
int varLength = HexFormatter.intValue (buffer[2], buffer[3]);
|
||||||
text.append ("\nVar length : " + HexFormatter.format4 (varLength));
|
text.append ("\nVar length : " + HexFormatter.format4 (varLength));
|
||||||
|
|
||||||
int unknown = HexFormatter.intValue (buffer[4]);
|
int unknown = buffer[4] & 0xFF;
|
||||||
text.append ("\nUnknown : " + HexFormatter.format2 (unknown));
|
text.append ("\nUnknown : " + HexFormatter.format2 (unknown));
|
||||||
text.append ("\n\n");
|
text.append ("\n\n");
|
||||||
|
|
||||||
int ptr = 5;
|
int ptr = 5;
|
||||||
text.append ("Simple variables : \n\n");
|
text.append ("Simple variables : \n\n");
|
||||||
while (ptr < varLength + 5)
|
while (ptr < varLength + 5)
|
||||||
{
|
{
|
||||||
text.append (HexFormatter.format (buffer, ptr, 7, false, 0) + "\n");
|
text.append (HexFormatter.format (buffer, ptr, 7, false, 0) + "\n");
|
||||||
ptr += 7;
|
ptr += 7;
|
||||||
}
|
}
|
||||||
text.append ("\nArrays : \n\n");
|
text.append ("\nArrays : \n\n");
|
||||||
while (ptr < totalLength + 5)
|
while (ptr < totalLength + 5)
|
||||||
{
|
{
|
||||||
int offset = HexFormatter.intValue (buffer[ptr + 2], buffer[ptr + 3]);
|
int offset = HexFormatter.intValue (buffer[ptr + 2], buffer[ptr + 3]);
|
||||||
int dimensions = HexFormatter.intValue (buffer[ptr + 4]);
|
int dimensions = buffer[ptr + 4] & 0xFF;
|
||||||
int[] dimensionSizes = new int[dimensions];
|
int[] dimensionSizes = new int[dimensions];
|
||||||
int totalElements = 0;
|
int totalElements = 0;
|
||||||
for (int i = 0; i < dimensions; i++)
|
for (int i = 0; i < dimensions; i++)
|
||||||
{
|
{
|
||||||
int p = i * 2 + 5 + ptr;
|
int p = i * 2 + 5 + ptr;
|
||||||
int elements = HexFormatter.intValue (buffer[p + 1], buffer[p]);
|
int elements = HexFormatter.intValue (buffer[p + 1], buffer[p]);
|
||||||
dimensionSizes[dimensions - i - 1] = elements;
|
dimensionSizes[dimensions - i - 1] = elements;
|
||||||
if (totalElements == 0)
|
if (totalElements == 0)
|
||||||
totalElements = elements;
|
totalElements = elements;
|
||||||
else
|
else
|
||||||
totalElements *= elements;
|
totalElements *= elements;
|
||||||
}
|
}
|
||||||
int headerSize = 5 + dimensions * 2;
|
int headerSize = 5 + dimensions * 2;
|
||||||
text.append (HexFormatter.format (buffer, ptr, headerSize, false, 0) + "\n\n");
|
text.append (HexFormatter.format (buffer, ptr, headerSize, false, 0) + "\n\n");
|
||||||
text.append (HexFormatter.format (buffer, ptr + headerSize, offset - headerSize, false, 0)
|
text.append (
|
||||||
+ "\n\n");
|
HexFormatter.format (buffer, ptr + headerSize, offset - headerSize, false, 0)
|
||||||
ptr += offset;
|
+ "\n\n");
|
||||||
}
|
ptr += offset;
|
||||||
text.append ("Strings : \n\n");
|
}
|
||||||
int length = buffer.length - ptr;
|
text.append ("Strings : \n\n");
|
||||||
text.append (HexFormatter.format (buffer, ptr, length, false, 0) + "\n\n");
|
int length = buffer.length - ptr;
|
||||||
|
text.append (HexFormatter.format (buffer, ptr, length, false, 0) + "\n\n");
|
||||||
|
|
||||||
return text.toString ();
|
return text.toString ();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,51 +1,49 @@
|
||||||
package com.bytezone.diskbrowser.applefile;
|
package com.bytezone.diskbrowser.applefile;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
|
||||||
|
|
||||||
public class WizardryTitle extends AbstractFile
|
public class WizardryTitle extends AbstractFile
|
||||||
{
|
{
|
||||||
public WizardryTitle (String name, byte[] buffer)
|
public WizardryTitle (String name, byte[] buffer)
|
||||||
{
|
{
|
||||||
super (name, buffer);
|
super (name, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText ()
|
public String getText ()
|
||||||
{
|
{
|
||||||
int size = 20;
|
int size = 20;
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
for (int i = 0; i < buffer.length; i += size)
|
for (int i = 0; i < buffer.length; i += size)
|
||||||
{
|
{
|
||||||
for (int line = 0; line < size; line++)
|
for (int line = 0; line < size; line++)
|
||||||
{
|
{
|
||||||
int p = i + line;
|
int p = i + line;
|
||||||
if (p >= buffer.length)
|
if (p >= buffer.length)
|
||||||
break;
|
break;
|
||||||
int value = HexFormatter.intValue (buffer[p]);
|
int value = buffer[p] & 0xFF;
|
||||||
text = decode2 (value, text);
|
text = decode2 (value, text);
|
||||||
}
|
}
|
||||||
text.append ("\n");
|
text.append ("\n");
|
||||||
}
|
}
|
||||||
return text.toString ();
|
return text.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private StringBuilder decode (int value, StringBuilder text)
|
private StringBuilder decode (int value, StringBuilder text)
|
||||||
{
|
{
|
||||||
for (int bit = 0; bit < 8; bit++)
|
for (int bit = 0; bit < 8; bit++)
|
||||||
{
|
{
|
||||||
text.append ((value & 0x01) == 1 ? "X" : " ");
|
text.append ((value & 0x01) == 1 ? "X" : " ");
|
||||||
value >>= 1;
|
value >>= 1;
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
private StringBuilder decode2 (int value, StringBuilder text)
|
private StringBuilder decode2 (int value, StringBuilder text)
|
||||||
{
|
{
|
||||||
for (int bit = 7; bit >= 0; bit--)
|
for (int bit = 7; bit >= 0; bit--)
|
||||||
{
|
{
|
||||||
text.append ((value & 0x01) == 1 ? "X" : " ");
|
text.append ((value & 0x01) == 1 ? "X" : " ");
|
||||||
value >>= 1;
|
value >>= 1;
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,8 +34,8 @@ class DosCatalogSector extends AbstractSector
|
||||||
if (buffer[i] == (byte) 0xFF)
|
if (buffer[i] == (byte) 0xFF)
|
||||||
{
|
{
|
||||||
addText (text, buffer, i + 0, 2,
|
addText (text, buffer, i + 0, 2,
|
||||||
"DEL: file @ " + HexFormatter.format2 (buffer[i + 32]) + " "
|
"DEL: file @ " + HexFormatter.format2 (buffer[i + 32]) + " "
|
||||||
+ HexFormatter.format2 (buffer[i + 1]));
|
+ HexFormatter.format2 (buffer[i + 1]));
|
||||||
addText (text, buffer, i + 2, 1, "DEL: File type " + getType (buffer[i + 2]));
|
addText (text, buffer, i + 2, 1, "DEL: File type " + getType (buffer[i + 2]));
|
||||||
if (buffer[i + 3] == 0)
|
if (buffer[i + 3] == 0)
|
||||||
addText (text, buffer, i + 3, 4, "");
|
addText (text, buffer, i + 3, 4, "");
|
||||||
|
@ -73,7 +73,7 @@ class DosCatalogSector extends AbstractSector
|
||||||
int max = buffer[offset] == (byte) 0xFF ? 32 : 33;
|
int max = buffer[offset] == (byte) 0xFF ? 32 : 33;
|
||||||
for (int i = 3; i < max; i++)
|
for (int i = 3; i < max; i++)
|
||||||
{
|
{
|
||||||
int c = HexFormatter.intValue (buffer[i + offset]);
|
int c = buffer[i + offset] & 0xFF;
|
||||||
if (c == 136)
|
if (c == 136)
|
||||||
{
|
{
|
||||||
if (text.length () > 0)
|
if (text.length () > 0)
|
||||||
|
|
|
@ -26,7 +26,7 @@ class DosVTOCSector extends AbstractSector
|
||||||
|
|
||||||
this.parentDisk = parentDisk;
|
this.parentDisk = parentDisk;
|
||||||
DOSVersion = buffer[3];
|
DOSVersion = buffer[3];
|
||||||
volume = HexFormatter.intValue (buffer[6]);
|
volume = buffer[6] & 0xFF;
|
||||||
maxTSPairs = buffer[39];
|
maxTSPairs = buffer[39];
|
||||||
lastAllocTrack = buffer[48];
|
lastAllocTrack = buffer[48];
|
||||||
direction = buffer[49];
|
direction = buffer[49];
|
||||||
|
@ -64,9 +64,8 @@ class DosVTOCSector extends AbstractSector
|
||||||
extra = "(VTOC and Catalog)";
|
extra = "(VTOC and Catalog)";
|
||||||
else
|
else
|
||||||
extra = "";
|
extra = "";
|
||||||
addText (text, buffer, i, 4,
|
addText (text, buffer, i, 4, String.format ("Track %02X %s %s", (i - 56) / 4,
|
||||||
String.format ("Track %02X %s %s", (i - 56) / 4,
|
getBitmap (buffer[i], buffer[i + 1]), extra));
|
||||||
getBitmap (buffer[i], buffer[i + 1]), extra));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
text.deleteCharAt (text.length () - 1);
|
text.deleteCharAt (text.length () - 1);
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
||||||
public static boolean checkFormat (AppleDisk disk, boolean debug)
|
public static boolean checkFormat (AppleDisk disk, boolean debug)
|
||||||
{
|
{
|
||||||
byte[] buffer = disk.readSector (2);
|
byte[] buffer = disk.readSector (2);
|
||||||
int nameLength = HexFormatter.intValue (buffer[6]);
|
int nameLength = buffer[6] & 0xFF;
|
||||||
if (nameLength < 1 || nameLength > 7)
|
if (nameLength < 1 || nameLength > 7)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
|
@ -188,7 +188,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
||||||
return false;
|
return false;
|
||||||
if (kind == 0)
|
if (kind == 0)
|
||||||
return false;
|
return false;
|
||||||
nameLength = HexFormatter.intValue (buffer[ptr + 6]);
|
nameLength = buffer[ptr + 6] & 0xFF;
|
||||||
if (nameLength < 1 || nameLength > 15)
|
if (nameLength < 1 || nameLength > 15)
|
||||||
return false;
|
return false;
|
||||||
int lastByte = HexFormatter.intValue (buffer[ptr + 22], buffer[ptr + 23]);
|
int lastByte = HexFormatter.intValue (buffer[ptr + 22], buffer[ptr + 23]);
|
||||||
|
|
|
@ -30,9 +30,9 @@ abstract class CatalogEntry implements AppleFileSource
|
||||||
name = HexFormatter.getString (entryBuffer, 1, entryBuffer[0] & 0x0F);
|
name = HexFormatter.getString (entryBuffer, 1, entryBuffer[0] & 0x0F);
|
||||||
storageType = (entryBuffer[0] & 0xF0) >> 4;
|
storageType = (entryBuffer[0] & 0xF0) >> 4;
|
||||||
created = HexFormatter.getAppleDate (entryBuffer, 24);
|
created = HexFormatter.getAppleDate (entryBuffer, 24);
|
||||||
version = HexFormatter.intValue (entryBuffer[28]);
|
version = entryBuffer[28] & 0xFF;
|
||||||
minVersion = HexFormatter.intValue (entryBuffer[29]);
|
minVersion = entryBuffer[29] & 0xFF;
|
||||||
access = HexFormatter.intValue (entryBuffer[30]);
|
access = entryBuffer[30] & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,8 +12,8 @@ abstract class DirectoryHeader extends CatalogEntry
|
||||||
{
|
{
|
||||||
super (parentDisk, entryBuffer);
|
super (parentDisk, entryBuffer);
|
||||||
|
|
||||||
entryLength = HexFormatter.intValue (entryBuffer[31]);
|
entryLength = entryBuffer[31] & 0xFF;
|
||||||
entriesPerBlock = HexFormatter.intValue (entryBuffer[32]);
|
entriesPerBlock = entryBuffer[32] & 0xFF;
|
||||||
fileCount = HexFormatter.intValue (entryBuffer[33], entryBuffer[34]);
|
fileCount = HexFormatter.intValue (entryBuffer[33], entryBuffer[34]);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -49,7 +49,7 @@ class ProdosCatalogSector extends AbstractSector
|
||||||
addText (text, buffer, i, 1, typeText + ", " + hex2 + " = Name length");
|
addText (text, buffer, i, 1, typeText + ", " + hex2 + " = Name length");
|
||||||
|
|
||||||
addText (text, buffer, i + 1, 4,
|
addText (text, buffer, i + 1, 4,
|
||||||
HexFormatter.getString (buffer, i + 1, nameLength));
|
HexFormatter.getString (buffer, i + 1, nameLength));
|
||||||
|
|
||||||
switch (fileType)
|
switch (fileType)
|
||||||
{
|
{
|
||||||
|
@ -80,9 +80,9 @@ class ProdosCatalogSector extends AbstractSector
|
||||||
private String doFileDescription (int offset)
|
private String doFileDescription (int offset)
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
int fileType = HexFormatter.intValue (buffer[offset + 16]);
|
int fileType = buffer[offset + 16] & 0xFF;
|
||||||
addText (text, buffer, offset + 16, 1,
|
addText (text, buffer, offset + 16, 1,
|
||||||
"File type (" + ProdosConstants.fileTypes[fileType] + ")");
|
"File type (" + ProdosConstants.fileTypes[fileType] + ")");
|
||||||
addTextAndDecimal (text, buffer, offset + 17, 2, "Key pointer");
|
addTextAndDecimal (text, buffer, offset + 17, 2, "Key pointer");
|
||||||
addTextAndDecimal (text, buffer, offset + 19, 2, "Blocks used");
|
addTextAndDecimal (text, buffer, offset + 19, 2, "Blocks used");
|
||||||
addTextAndDecimal (text, buffer, offset + 21, 3, "EOF");
|
addTextAndDecimal (text, buffer, offset + 21, 3, "EOF");
|
||||||
|
@ -93,7 +93,7 @@ class ProdosCatalogSector extends AbstractSector
|
||||||
addText (text, buffer, offset + 29, 1, "Minimum version");
|
addText (text, buffer, offset + 29, 1, "Minimum version");
|
||||||
addText (text, buffer, offset + 30, 1, "Access");
|
addText (text, buffer, offset + 30, 1, "Access");
|
||||||
addTextAndDecimal (text, buffer, offset + 31, 2,
|
addTextAndDecimal (text, buffer, offset + 31, 2,
|
||||||
"Auxilliary type - " + getAuxilliaryText (fileType));
|
"Auxilliary type - " + getAuxilliaryText (fileType));
|
||||||
GregorianCalendar modified = HexFormatter.getAppleDate (buffer, offset + 33);
|
GregorianCalendar modified = HexFormatter.getAppleDate (buffer, offset + 33);
|
||||||
String dateM = modified == null ? "" : parent.df.format (modified.getTime ());
|
String dateM = modified == null ? "" : parent.df.format (modified.getTime ());
|
||||||
addText (text, buffer, offset + 33, 4, "Modification date : " + dateM);
|
addText (text, buffer, offset + 33, 4, "Modification date : " + dateM);
|
||||||
|
@ -191,7 +191,7 @@ class ProdosCatalogSector extends AbstractSector
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
for (int i = offset, max = offset + 15; i < max && buffer[i] != 0; i++)
|
for (int i = offset, max = offset + 15; i < max && buffer[i] != 0; i++)
|
||||||
text.append ((char) HexFormatter.intValue (buffer[i]));
|
text.append ((char) buffer[i] & 0xFF);
|
||||||
return text.toString ();
|
return text.toString ();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -60,7 +60,7 @@ class ProdosDirectory extends AbstractFile
|
||||||
case ProdosConstants.TYPE_PASCAL_ON_PROFILE:
|
case ProdosConstants.TYPE_PASCAL_ON_PROFILE:
|
||||||
case ProdosConstants.TYPE_GSOS_EXTENDED_FILE:
|
case ProdosConstants.TYPE_GSOS_EXTENDED_FILE:
|
||||||
case ProdosConstants.TYPE_SUBDIRECTORY:
|
case ProdosConstants.TYPE_SUBDIRECTORY:
|
||||||
int type = HexFormatter.intValue (buffer[i + 16]);
|
int type = buffer[i + 16] & 0xFF;
|
||||||
int blocks = HexFormatter.intValue (buffer[i + 19], buffer[i + 20]);
|
int blocks = HexFormatter.intValue (buffer[i + 19], buffer[i + 20]);
|
||||||
|
|
||||||
GregorianCalendar created = HexFormatter.getAppleDate (buffer, i + 24);
|
GregorianCalendar created = HexFormatter.getAppleDate (buffer, i + 24);
|
||||||
|
@ -74,7 +74,7 @@ class ProdosDirectory extends AbstractFile
|
||||||
modified == null ? "" : parentFD.stf.format (modified.getTime ());
|
modified == null ? "" : parentFD.stf.format (modified.getTime ());
|
||||||
int eof =
|
int eof =
|
||||||
HexFormatter.intValue (buffer[i + 21], buffer[i + 22], buffer[i + 23]);
|
HexFormatter.intValue (buffer[i + 21], buffer[i + 22], buffer[i + 23]);
|
||||||
int fileType = HexFormatter.intValue (buffer[i + 16]);
|
int fileType = buffer[i + 16] & 0xFF;
|
||||||
locked = (buffer[i + 30] & 0xE0) == 0xE0 ? " " : "*";
|
locked = (buffer[i + 30] & 0xE0) == 0xE0 ? " " : "*";
|
||||||
|
|
||||||
switch (fileType)
|
switch (fileType)
|
||||||
|
@ -97,17 +97,17 @@ class ProdosDirectory extends AbstractFile
|
||||||
}
|
}
|
||||||
|
|
||||||
text.append (String.format ("%s%-15s %3s %5d %9s %5s %9s %5s %8d %7s%n",
|
text.append (String.format ("%s%-15s %3s %5d %9s %5s %9s %5s %8d %7s%n",
|
||||||
locked, filename, ProdosConstants.fileTypes[type],
|
locked, filename, ProdosConstants.fileTypes[type], blocks, dateM, timeM,
|
||||||
blocks, dateM, timeM, dateC, timeC, eof, subType));
|
dateC, timeC, eof, subType));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
text.append (" <Unknown strage type : " + storageType + newLine);
|
text.append (" <Unknown strage type : " + storageType + newLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
text.append (String.format (
|
text.append (
|
||||||
"%nBLOCKS FREE:%5d BLOCKS USED:%5d TOTAL BLOCKS:%5d%n",
|
String.format ("%nBLOCKS FREE:%5d BLOCKS USED:%5d TOTAL BLOCKS:%5d%n",
|
||||||
freeBlocks, usedBlocks, totalBlocks));
|
freeBlocks, usedBlocks, totalBlocks));
|
||||||
return text.toString ();
|
return text.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ class SubDirectoryHeader extends DirectoryHeader
|
||||||
this.parentDirectory = parent.parentDirectory;
|
this.parentDirectory = parent.parentDirectory;
|
||||||
|
|
||||||
parentPointer = HexFormatter.intValue (entryBuffer[35], entryBuffer[36]);
|
parentPointer = HexFormatter.intValue (entryBuffer[35], entryBuffer[36]);
|
||||||
parentSequence = HexFormatter.intValue (entryBuffer[37]);
|
parentSequence = entryBuffer[37] & 0xFF;
|
||||||
parentSize = HexFormatter.intValue (entryBuffer[38]);
|
parentSize = entryBuffer[38] & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,7 +27,7 @@ class SubDirectoryHeader extends DirectoryHeader
|
||||||
{
|
{
|
||||||
String locked = (access == 0x01) ? "*" : " ";
|
String locked = (access == 0x01) ? "*" : " ";
|
||||||
return String.format (" %s%-40s %15s", locked, "/" + name,
|
return String.format (" %s%-40s %15s", locked, "/" + name,
|
||||||
parentDisk.df.format (created.getTime ()));
|
parentDisk.df.format (created.getTime ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -151,7 +151,7 @@ public class HexFormatter
|
||||||
|
|
||||||
for (int i = offset; i < offset + length; i++)
|
for (int i = offset; i < offset + length; i++)
|
||||||
{
|
{
|
||||||
int c = intValue (buffer[i]);
|
int c = buffer[i] & 0xFF;
|
||||||
if (c > 127)
|
if (c > 127)
|
||||||
{
|
{
|
||||||
if (c < 160)
|
if (c < 160)
|
||||||
|
@ -176,7 +176,7 @@ public class HexFormatter
|
||||||
|
|
||||||
for (int i = offset; i < offset + length; i++)
|
for (int i = offset; i < offset + length; i++)
|
||||||
{
|
{
|
||||||
int c = intValue (buffer[i]);
|
int c = buffer[i] & 0xFF;
|
||||||
if (c == 136 && text.length () > 0)
|
if (c == 136 && text.length () > 0)
|
||||||
{
|
{
|
||||||
System.out.println (text.toString ());
|
System.out.println (text.toString ());
|
||||||
|
@ -241,7 +241,7 @@ public class HexFormatter
|
||||||
|
|
||||||
public static char byteValue (byte b)
|
public static char byteValue (byte b)
|
||||||
{
|
{
|
||||||
int c = intValue (b);
|
int c = b & 0xFF;
|
||||||
if (c > 127)
|
if (c > 127)
|
||||||
c -= 128;
|
c -= 128;
|
||||||
if (c > 95)
|
if (c > 95)
|
||||||
|
@ -288,24 +288,19 @@ public class HexFormatter
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int intValue (byte b1)
|
// public static int intValue (byte b1)
|
||||||
{
|
// {
|
||||||
// int i1 = b1;
|
// return b1 & 0xFF;
|
||||||
// if (i1 < 0)
|
// }
|
||||||
// i1 += 256;
|
|
||||||
|
|
||||||
// return i1;
|
|
||||||
return b1 & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int intValue (byte b1, byte b2)
|
public static int intValue (byte b1, byte b2)
|
||||||
{
|
{
|
||||||
return intValue (b1) + intValue (b2) * 256;
|
return (b1 & 0xFF) + (b2 & 0xFF) * 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int intValue (byte b1, byte b2, byte b3)
|
public static int intValue (byte b1, byte b2, byte b3)
|
||||||
{
|
{
|
||||||
return intValue (b1) + intValue (b2) * 256 + intValue (b3) * 65536;
|
return (b1 & 0xFF) + (b2 & 0xFF) * 256 + (b3 & 0xFF) * 65536;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getLong (byte[] buffer, int ptr)
|
public static int getLong (byte[] buffer, int ptr)
|
||||||
|
@ -330,6 +325,17 @@ public class HexFormatter
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getShort (byte[] buffer, int ptr)
|
||||||
|
{
|
||||||
|
int val = 0;
|
||||||
|
for (int i = 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
val <<= 8;
|
||||||
|
val += buffer[ptr + i] & 0xFF;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
public static int getShortBigEndian (byte[] buffer, int ptr)
|
public static int getShortBigEndian (byte[] buffer, int ptr)
|
||||||
{
|
{
|
||||||
int val = 0;
|
int val = 0;
|
||||||
|
@ -379,11 +385,11 @@ public class HexFormatter
|
||||||
{
|
{
|
||||||
double val = 0;
|
double val = 0;
|
||||||
|
|
||||||
int exponent = HexFormatter.intValue (buffer[offset]) - 0x80;
|
int exponent = (buffer[offset] & 0xFF) - 0x80;
|
||||||
|
|
||||||
int mantissa =
|
int mantissa =
|
||||||
(buffer[offset + 1] & 0x7F) * 0x1000000 + intValue (buffer[offset + 2]) * 0x10000
|
(buffer[offset + 1] & 0x7F) * 0x1000000 + (buffer[offset + 2] & 0xFF) * 0x10000
|
||||||
+ intValue (buffer[offset + 3]) * 0x100 + intValue (buffer[offset + 4]);
|
+ (buffer[offset + 3] & 0xFF) * 0x100 + (buffer[offset + 4] & 0xFF);
|
||||||
|
|
||||||
int weight1 = 1;
|
int weight1 = 1;
|
||||||
long weight2 = 2147483648L;
|
long weight2 = 2147483648L;
|
||||||
|
@ -428,8 +434,8 @@ public class HexFormatter
|
||||||
int year = (date & 0xFE00) >> 9;
|
int year = (date & 0xFE00) >> 9;
|
||||||
int month = (date & 0x01E0) >> 5;
|
int month = (date & 0x01E0) >> 5;
|
||||||
int day = date & 0x001F;
|
int day = date & 0x001F;
|
||||||
int hour = HexFormatter.intValue (buffer[offset + 3]) & 0x1F;
|
int hour = buffer[offset + 3] & 0x1F;
|
||||||
int minute = HexFormatter.intValue (buffer[offset + 2]) & 0x3F;
|
int minute = buffer[offset + 2] & 0x3F;
|
||||||
if (year < 70)
|
if (year < 70)
|
||||||
year += 2000;
|
year += 2000;
|
||||||
else
|
else
|
||||||
|
@ -441,7 +447,7 @@ public class HexFormatter
|
||||||
|
|
||||||
public static GregorianCalendar getPascalDate (byte[] buffer, int offset)
|
public static GregorianCalendar getPascalDate (byte[] buffer, int offset)
|
||||||
{
|
{
|
||||||
int year = intValue (buffer[offset + 1]);
|
int year = (buffer[offset + 1] & 0xFF);
|
||||||
int day = (buffer[offset] & 0xF0) >> 4;
|
int day = (buffer[offset] & 0xF0) >> 4;
|
||||||
int month = buffer[offset] & 0x0F;
|
int month = buffer[offset] & 0x0F;
|
||||||
if (day == 0 || month == 0)
|
if (day == 0 || month == 0)
|
||||||
|
@ -458,7 +464,7 @@ public class HexFormatter
|
||||||
|
|
||||||
public static String getPascalString (byte[] buffer, int offset)
|
public static String getPascalString (byte[] buffer, int offset)
|
||||||
{
|
{
|
||||||
int length = HexFormatter.intValue (buffer[offset]);
|
int length = buffer[offset] & 0xFF;
|
||||||
return HexFormatter.getString (buffer, offset + 1, length);
|
return HexFormatter.getString (buffer, offset + 1, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,13 +32,13 @@ class Character extends AbstractFile
|
||||||
attributes = new Attributes ();
|
attributes = new Attributes ();
|
||||||
stats = new Statistics ();
|
stats = new Statistics ();
|
||||||
|
|
||||||
stats.race = races[HexFormatter.intValue (buffer[34])];
|
stats.race = races[buffer[34] & 0xFF];
|
||||||
stats.typeInt = HexFormatter.intValue (buffer[36]);
|
stats.typeInt = buffer[36] & 0xFF;
|
||||||
stats.type = types[stats.typeInt];
|
stats.type = types[stats.typeInt];
|
||||||
stats.ageInWeeks = HexFormatter.intValue (buffer[38], buffer[39]);
|
stats.ageInWeeks = HexFormatter.intValue (buffer[38], buffer[39]);
|
||||||
stats.statusValue = buffer[40];
|
stats.statusValue = buffer[40];
|
||||||
stats.status = statuses[stats.statusValue];
|
stats.status = statuses[stats.statusValue];
|
||||||
stats.alignment = alignments[HexFormatter.intValue (buffer[42])];
|
stats.alignment = alignments[buffer[42] & 0xFF];
|
||||||
|
|
||||||
stats.gold = HexFormatter.intValue (buffer[52], buffer[53])
|
stats.gold = HexFormatter.intValue (buffer[52], buffer[53])
|
||||||
+ HexFormatter.intValue (buffer[54], buffer[55]) * 10000;
|
+ HexFormatter.intValue (buffer[54], buffer[55]) * 10000;
|
||||||
|
@ -50,30 +50,30 @@ class Character extends AbstractFile
|
||||||
stats.hitsMax = HexFormatter.intValue (buffer[136], buffer[137]);
|
stats.hitsMax = HexFormatter.intValue (buffer[136], buffer[137]);
|
||||||
stats.armourClass = buffer[176];
|
stats.armourClass = buffer[176];
|
||||||
|
|
||||||
attributes.strength = HexFormatter.intValue (buffer[44]) % 16;
|
attributes.strength = (buffer[44] & 0xFF) % 16;
|
||||||
if (attributes.strength < 3)
|
if (attributes.strength < 3)
|
||||||
attributes.strength += 16;
|
attributes.strength += 16;
|
||||||
attributes.array[0] = attributes.strength;
|
attributes.array[0] = attributes.strength;
|
||||||
|
|
||||||
int i1 = HexFormatter.intValue (buffer[44]) / 16;
|
int i1 = (buffer[44] & 0xFF) / 16;
|
||||||
int i2 = HexFormatter.intValue (buffer[45]) % 4;
|
int i2 = (buffer[45] & 0xFF) % 4;
|
||||||
attributes.intelligence = i1 / 2 + i2 * 8;
|
attributes.intelligence = i1 / 2 + i2 * 8;
|
||||||
attributes.array[1] = attributes.intelligence;
|
attributes.array[1] = attributes.intelligence;
|
||||||
|
|
||||||
attributes.piety = HexFormatter.intValue (buffer[45]) / 4;
|
attributes.piety = (buffer[45] & 0xFF) / 4;
|
||||||
attributes.array[2] = attributes.piety;
|
attributes.array[2] = attributes.piety;
|
||||||
|
|
||||||
attributes.vitality = HexFormatter.intValue (buffer[46]) % 16;
|
attributes.vitality = (buffer[46] & 0xFF) % 16;
|
||||||
if (attributes.vitality < 3)
|
if (attributes.vitality < 3)
|
||||||
attributes.vitality += 16;
|
attributes.vitality += 16;
|
||||||
attributes.array[3] = attributes.vitality;
|
attributes.array[3] = attributes.vitality;
|
||||||
|
|
||||||
int a1 = HexFormatter.intValue (buffer[46]) / 16;
|
int a1 = (buffer[46] & 0xFF) / 16;
|
||||||
int a2 = HexFormatter.intValue (buffer[47]) % 4;
|
int a2 = (buffer[47] & 0xFF) % 4;
|
||||||
attributes.agility = a1 / 2 + a2 * 8;
|
attributes.agility = a1 / 2 + a2 * 8;
|
||||||
attributes.array[4] = attributes.agility;
|
attributes.array[4] = attributes.agility;
|
||||||
|
|
||||||
attributes.luck = HexFormatter.intValue (buffer[47]) / 4;
|
attributes.luck = (buffer[47] & 0xFF) / 4;
|
||||||
attributes.array[5] = attributes.luck;
|
attributes.array[5] = attributes.luck;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ class Character extends AbstractFile
|
||||||
|
|
||||||
for (int ptr = 60; totItems > 0; ptr += 8, totItems--)
|
for (int ptr = 60; totItems > 0; ptr += 8, totItems--)
|
||||||
{
|
{
|
||||||
int itemID = HexFormatter.intValue (buffer[ptr + 6]);
|
int itemID = buffer[ptr + 6] & 0xFF;
|
||||||
if (scenario == 3)
|
if (scenario == 3)
|
||||||
itemID = (itemID + 24) % 256;
|
itemID = (itemID + 24) % 256;
|
||||||
if (itemID >= 0 && itemID < itemList.size ())
|
if (itemID >= 0 && itemID < itemList.size ())
|
||||||
|
|
|
@ -4,24 +4,24 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
|
|
||||||
class CodedMessage extends Message
|
class CodedMessage extends Message
|
||||||
{
|
{
|
||||||
public static int codeOffset = 185;
|
public static int codeOffset = 185;
|
||||||
|
|
||||||
public CodedMessage (byte[] buffer)
|
public CodedMessage (byte[] buffer)
|
||||||
{
|
{
|
||||||
super (buffer);
|
super (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getLine (int offset)
|
protected String getLine (int offset)
|
||||||
{
|
{
|
||||||
int length = HexFormatter.intValue (buffer[offset]);
|
int length = buffer[offset] & 0xFF;
|
||||||
byte[] translation = new byte[length];
|
byte[] translation = new byte[length];
|
||||||
codeOffset--;
|
codeOffset--;
|
||||||
for (int j = 0; j < length; j++)
|
for (int j = 0; j < length; j++)
|
||||||
{
|
{
|
||||||
translation[j] = buffer[offset + 1 + j];
|
translation[j] = buffer[offset + 1 + j];
|
||||||
translation[j] -= codeOffset - j * 3;
|
translation[j] -= codeOffset - j * 3;
|
||||||
}
|
}
|
||||||
return HexFormatter.getString (translation, 0, length);
|
return HexFormatter.getString (translation, 0, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -186,7 +186,7 @@ class Header
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 8; j++)
|
for (int j = 0; j < 8; j++)
|
||||||
{
|
{
|
||||||
int value = HexFormatter.intValue (buffer[i + line + j * 8]);
|
int value = buffer[i + line + j * 8] & 0xFF;
|
||||||
for (int bit = 0; bit < 7; bit++)
|
for (int bit = 0; bit < 7; bit++)
|
||||||
{
|
{
|
||||||
if ((value & 0x01) == 1)
|
if ((value & 0x01) == 1)
|
||||||
|
@ -217,10 +217,10 @@ class Header
|
||||||
public ScenarioData (byte[] buffer, int seq, List<DiskAddress> sectors)
|
public ScenarioData (byte[] buffer, int seq, List<DiskAddress> sectors)
|
||||||
{
|
{
|
||||||
int offset = 42 + seq * 2;
|
int offset = 42 + seq * 2;
|
||||||
dunno = HexFormatter.intValue (buffer[offset]);
|
dunno = buffer[offset] & 0xFF;
|
||||||
total = HexFormatter.intValue (buffer[offset + 16]);
|
total = buffer[offset + 16] & 0xFF;
|
||||||
totalBlocks = HexFormatter.intValue (buffer[offset + 32]);
|
totalBlocks = buffer[offset + 32] & 0xFF;
|
||||||
dataOffset = HexFormatter.intValue (buffer[offset + 48]);
|
dataOffset = buffer[offset + 48] & 0xFF;
|
||||||
type = seq;
|
type = seq;
|
||||||
|
|
||||||
this.sectors = new ArrayList<DiskAddress> (totalBlocks);
|
this.sectors = new ArrayList<DiskAddress> (totalBlocks);
|
||||||
|
|
|
@ -5,137 +5,137 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
|
|
||||||
class Item extends AbstractFile implements Comparable<Item>
|
class Item extends AbstractFile implements Comparable<Item>
|
||||||
{
|
{
|
||||||
public final int itemID;
|
public final int itemID;
|
||||||
private final int type;
|
private final int type;
|
||||||
private final long cost;
|
private final long cost;
|
||||||
public int partyOwns;
|
public int partyOwns;
|
||||||
String genericName;
|
String genericName;
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
public final Dice damage;
|
public final Dice damage;
|
||||||
public final int armourClass;
|
public final int armourClass;
|
||||||
public final int speed;
|
public final int speed;
|
||||||
|
|
||||||
public Item (String name, byte[] buffer)
|
public Item (String name, byte[] buffer)
|
||||||
{
|
{
|
||||||
super (name, buffer);
|
super (name, buffer);
|
||||||
itemID = counter++;
|
itemID = counter++;
|
||||||
type = buffer[32];
|
type = buffer[32];
|
||||||
cost =
|
cost = HexFormatter.intValue (buffer[44], buffer[45])
|
||||||
HexFormatter.intValue (buffer[44], buffer[45])
|
+ HexFormatter.intValue (buffer[46], buffer[47]) * 10000
|
||||||
+ HexFormatter.intValue (buffer[46], buffer[47]) * 10000
|
+ HexFormatter.intValue (buffer[48], buffer[49]) * 100000000L;
|
||||||
+ HexFormatter.intValue (buffer[48], buffer[49]) * 100000000L;
|
genericName = HexFormatter.getPascalString (buffer, 16);
|
||||||
genericName = HexFormatter.getPascalString (buffer, 16);
|
damage = new Dice (buffer, 66);
|
||||||
damage = new Dice (buffer, 66);
|
armourClass = buffer[62];
|
||||||
armourClass = buffer[62];
|
speed = buffer[72];
|
||||||
speed = buffer[72];
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText ()
|
public String getText ()
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
text.append ("Name ......... : " + name);
|
text.append ("Name ......... : " + name);
|
||||||
// int length = HexFormatter.intValue (buffer[16]);
|
// int length = HexFormatter.intValue (buffer[16]);
|
||||||
text.append ("\nGeneric name . : " + genericName);
|
text.append ("\nGeneric name . : " + genericName);
|
||||||
text.append ("\nType ......... : " + type);
|
text.append ("\nType ......... : " + type);
|
||||||
text.append ("\nCost ......... : " + cost);
|
text.append ("\nCost ......... : " + cost);
|
||||||
text.append ("\nArmour class . : " + armourClass);
|
text.append ("\nArmour class . : " + armourClass);
|
||||||
text.append ("\nDamage ....... : " + damage);
|
text.append ("\nDamage ....... : " + damage);
|
||||||
text.append ("\nSpeed ........ : " + speed);
|
text.append ("\nSpeed ........ : " + speed);
|
||||||
text.append ("\nCursed? ...... : " + isCursed ());
|
text.append ("\nCursed? ...... : " + isCursed ());
|
||||||
int stock = getStockOnHand ();
|
int stock = getStockOnHand ();
|
||||||
text.append ("\nStock on hand : " + stock);
|
text.append ("\nStock on hand : " + stock);
|
||||||
if (stock < 0)
|
if (stock < 0)
|
||||||
text.append (" (always in stock)");
|
text.append (" (always in stock)");
|
||||||
|
|
||||||
return text.toString ();
|
return text.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getType ()
|
public int getType ()
|
||||||
{
|
{
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public int getArmourClass ()
|
// public int getArmourClass ()
|
||||||
// {
|
// {
|
||||||
// return buffer[62];
|
// return buffer[62];
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// public int getSpeed ()
|
// public int getSpeed ()
|
||||||
// {
|
// {
|
||||||
// return HexFormatter.intValue (buffer[72]);
|
// return HexFormatter.intValue (buffer[72]);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public long getCost ()
|
public long getCost ()
|
||||||
{
|
{
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCursed ()
|
public boolean isCursed ()
|
||||||
{
|
{
|
||||||
return buffer[36] != 0;
|
return buffer[36] != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStockOnHand ()
|
public int getStockOnHand ()
|
||||||
{
|
{
|
||||||
if (buffer[50] == -1 && buffer[51] == -1)
|
if (buffer[50] == -1 && buffer[51] == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return HexFormatter.intValue (buffer[50], buffer[51]);
|
return HexFormatter.intValue (buffer[50], buffer[51]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUse (int type2)
|
public boolean canUse (int type2)
|
||||||
{
|
{
|
||||||
int users = HexFormatter.intValue (buffer[54]);
|
int users = buffer[54] & 0xFF;
|
||||||
return ((users >>> type2) & 1) == 1;
|
return ((users >>> type2) & 1) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
{
|
{
|
||||||
StringBuilder line = new StringBuilder ();
|
StringBuilder line = new StringBuilder ();
|
||||||
line.append (String.format ("%-16s", name));
|
line.append (String.format ("%-16s", name));
|
||||||
if (buffer[36] == -1)
|
if (buffer[36] == -1)
|
||||||
line.append ("(c) ");
|
line.append ("(c) ");
|
||||||
else
|
else
|
||||||
line.append (" ");
|
line.append (" ");
|
||||||
line.append (String.format ("%02X ", buffer[62]));
|
line.append (String.format ("%02X ", buffer[62]));
|
||||||
line.append (String.format ("%02X ", buffer[34]));
|
line.append (String.format ("%02X ", buffer[34]));
|
||||||
line.append (String.format ("%02X %02X", buffer[50], buffer[51]));
|
line.append (String.format ("%02X %02X", buffer[50], buffer[51]));
|
||||||
|
|
||||||
// if (buffer[50] == -1 && buffer[51] == -1)
|
// if (buffer[50] == -1 && buffer[51] == -1)
|
||||||
// line.append ("* ");
|
// line.append ("* ");
|
||||||
// else
|
// else
|
||||||
// line.append (HexFormatter.intValue (buffer[50], buffer[51]) + " ");
|
// line.append (HexFormatter.intValue (buffer[50], buffer[51]) + " ");
|
||||||
|
|
||||||
for (int i = 38; i < 44; i++)
|
for (int i = 38; i < 44; i++)
|
||||||
line.append (HexFormatter.format2 (buffer[i]) + " ");
|
line.append (HexFormatter.format2 (buffer[i]) + " ");
|
||||||
for (int i = 48; i < 50; i++)
|
for (int i = 48; i < 50; i++)
|
||||||
line.append (HexFormatter.format2 (buffer[i]) + " ");
|
line.append (HexFormatter.format2 (buffer[i]) + " ");
|
||||||
for (int i = 52; i < 62; i++)
|
for (int i = 52; i < 62; i++)
|
||||||
line.append (HexFormatter.format2 (buffer[i]) + " ");
|
line.append (HexFormatter.format2 (buffer[i]) + " ");
|
||||||
// for (int i = 64; i < 78; i++)
|
// for (int i = 64; i < 78; i++)
|
||||||
// line.append (HexFormatter.format2 (buffer[i]) + " ");
|
// line.append (HexFormatter.format2 (buffer[i]) + " ");
|
||||||
|
|
||||||
return line.toString ();
|
return line.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDump (int block)
|
public String getDump (int block)
|
||||||
{
|
{
|
||||||
StringBuilder line = new StringBuilder (String.format ("%3d %-16s", itemID, name));
|
StringBuilder line = new StringBuilder (String.format ("%3d %-16s", itemID, name));
|
||||||
int lo = block == 0 ? 32 : block == 1 ? 46 : 70;
|
int lo = block == 0 ? 32 : block == 1 ? 46 : 70;
|
||||||
int hi = lo + 24;
|
int hi = lo + 24;
|
||||||
if (hi > buffer.length)
|
if (hi > buffer.length)
|
||||||
hi = buffer.length;
|
hi = buffer.length;
|
||||||
for (int i = lo; i < hi; i++)
|
for (int i = lo; i < hi; i++)
|
||||||
line.append (String.format ("%02X ", buffer[i]));
|
line.append (String.format ("%02X ", buffer[i]));
|
||||||
return line.toString ();
|
return line.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo (Item otherItem)
|
@Override
|
||||||
{
|
public int compareTo (Item otherItem)
|
||||||
Item item = otherItem;
|
{
|
||||||
return this.type - item.type;
|
Item item = otherItem;
|
||||||
}
|
return this.type - item.type;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -88,13 +88,13 @@ public class MazeGridV5 extends AbstractFile
|
||||||
int offset = gridNo * 16 + column * 2 + row / 4;
|
int offset = gridNo * 16 + column * 2 + row / 4;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
value = HexFormatter.intValue (buffer[offset + 0]);
|
value = buffer[offset + 0] & 0xFF;
|
||||||
value >>>= (row % 4) * 2;
|
value >>>= (row % 4) * 2;
|
||||||
cell.eastWall = ((value & 1) == 1);
|
cell.eastWall = ((value & 1) == 1);
|
||||||
value >>>= 1;
|
value >>>= 1;
|
||||||
cell.eastDoor = ((value & 1) == 1);
|
cell.eastDoor = ((value & 1) == 1);
|
||||||
|
|
||||||
value = HexFormatter.intValue (buffer[offset + 256]);
|
value = buffer[offset + 256] & 0xFF;
|
||||||
value >>>= (row % 4) * 2;
|
value >>>= (row % 4) * 2;
|
||||||
cell.northWall = ((value & 1) == 1);
|
cell.northWall = ((value & 1) == 1);
|
||||||
value >>>= 1;
|
value >>>= 1;
|
||||||
|
|
|
@ -105,9 +105,7 @@ class Monster extends AbstractFile implements Comparable<Monster>
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
// these values definitely affect the damage a monster does (when breathing?)
|
// these values definitely affect the damage a monster does (when breathing?)
|
||||||
int exp2 =
|
int exp2 = ((buffer[72] & 0xFF) * (buffer[74] & 0xFF) - 1) * 20;
|
||||||
(HexFormatter.intValue (buffer[72]) * HexFormatter.intValue (buffer[74]) - 1)
|
|
||||||
* 20;
|
|
||||||
int exp3 = weight2[speed]; // 1-6
|
int exp3 = weight2[speed]; // 1-6
|
||||||
int exp4 = (10 - armourClass) * 40;
|
int exp4 = (10 - armourClass) * 40;
|
||||||
int exp5 = getBonus (35, mageSpellLevel);
|
int exp5 = getBonus (35, mageSpellLevel);
|
||||||
|
@ -191,9 +189,7 @@ class Monster extends AbstractFile implements Comparable<Monster>
|
||||||
public int getExperience ()
|
public int getExperience ()
|
||||||
{
|
{
|
||||||
// these values definitely affect the damage a monster does (when breathing?)
|
// these values definitely affect the damage a monster does (when breathing?)
|
||||||
int exp2 =
|
int exp2 = ((buffer[72] & 0xFF) * (buffer[74] & 0xFF) - 1) * 20;
|
||||||
(HexFormatter.intValue (buffer[72]) * HexFormatter.intValue (buffer[74]) - 1)
|
|
||||||
* 20;
|
|
||||||
int exp3 = weight2[speed];
|
int exp3 = weight2[speed];
|
||||||
int exp4 = (10 - armourClass) * 40;
|
int exp4 = (10 - armourClass) * 40;
|
||||||
int exp5 = getBonus (35, mageSpellLevel);
|
int exp5 = getBonus (35, mageSpellLevel);
|
||||||
|
|
|
@ -4,15 +4,15 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
|
|
||||||
class PlainMessage extends Message
|
class PlainMessage extends Message
|
||||||
{
|
{
|
||||||
public PlainMessage (byte[] buffer)
|
public PlainMessage (byte[] buffer)
|
||||||
{
|
{
|
||||||
super (buffer);
|
super (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getLine (int offset)
|
protected String getLine (int offset)
|
||||||
{
|
{
|
||||||
int length = HexFormatter.intValue (buffer[offset]);
|
int length = buffer[offset] & 0xFF;
|
||||||
return HexFormatter.getString (buffer, offset + 1, length);
|
return HexFormatter.getString (buffer, offset + 1, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -255,7 +255,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||||
int recLen = 208;
|
int recLen = 208;
|
||||||
for (int ptr = 0; ptr < 832; ptr += recLen)
|
for (int ptr = 0; ptr < 832; ptr += recLen)
|
||||||
{
|
{
|
||||||
int nameLength = HexFormatter.intValue (buffer[ptr]);
|
int nameLength = buffer[ptr] & 0xFF;
|
||||||
if (nameLength == 0xC3 || buffer[ptr + 40] == 0x07)
|
if (nameLength == 0xC3 || buffer[ptr + 40] == 0x07)
|
||||||
continue;
|
continue;
|
||||||
String name = HexFormatter.getString (buffer, ptr + 1, nameLength);
|
String name = HexFormatter.getString (buffer, ptr + 1, nameLength);
|
||||||
|
@ -308,7 +308,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||||
int recLen = 158;
|
int recLen = 158;
|
||||||
for (int ptr = 0; ptr < 948; ptr += recLen)
|
for (int ptr = 0; ptr < 948; ptr += recLen)
|
||||||
{
|
{
|
||||||
int nameLength = HexFormatter.intValue (buffer[ptr + 32]);
|
int nameLength = buffer[ptr + 32] & 0xFF;
|
||||||
if (nameLength == 0 || nameLength == 255)
|
if (nameLength == 0 || nameLength == 255)
|
||||||
break;
|
break;
|
||||||
String itemName = HexFormatter.getString (buffer, ptr + 33, nameLength);
|
String itemName = HexFormatter.getString (buffer, ptr + 33, nameLength);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user