mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-17 14:30:52 +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;
|
||||
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)
|
||||
{
|
||||
this.value = opcode;
|
||||
this.opcode = HexFormatter.intValue (opcode);
|
||||
this.opcode = opcode & 0xFF;
|
||||
this.mnemonic = AssemblerConstants.mnemonics[this.opcode];
|
||||
this.size = AssemblerConstants.sizes2[this.opcode];
|
||||
this.operand = "";
|
||||
@ -173,7 +174,7 @@ public class AssemblerStatement
|
||||
case 0xE4: // CPX
|
||||
case 0xE5: // SBC
|
||||
case 0xE6: // INC
|
||||
target = HexFormatter.intValue (b);
|
||||
target = b & 0xFF;
|
||||
operand = address;
|
||||
mode = 8; // Zero page
|
||||
break;
|
||||
@ -253,7 +254,7 @@ public class AssemblerStatement
|
||||
case 0xF0: // BEQ
|
||||
offset = b;
|
||||
mode = 14; // relative
|
||||
this.target = HexFormatter.intValue (b);
|
||||
this.target = b & 0xFF;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -358,6 +359,7 @@ public class AssemblerStatement
|
||||
{
|
||||
if (offset == 0)
|
||||
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,7 +1,5 @@
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
public class Charset extends AbstractFile
|
||||
{
|
||||
public Charset (String name, byte[] buffer)
|
||||
@ -9,6 +7,7 @@ public class Charset extends AbstractFile
|
||||
super (name, buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
@ -16,7 +15,7 @@ public class Charset extends AbstractFile
|
||||
{
|
||||
for (int line = 7; line >= 0; line--)
|
||||
{
|
||||
int value = HexFormatter.intValue (buffer[i + line]);
|
||||
int value = buffer[i + line] & 0xFF;
|
||||
for (int bit = 0; bit < 8; bit++)
|
||||
{
|
||||
text.append ((value & 0x01) == 1 ? "X" : ".");
|
||||
|
@ -5,17 +5,18 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
public class IntegerBasicProgram extends AbstractFile
|
||||
{
|
||||
private static String[] tokens =
|
||||
{ "?", "?", "?", " : ", "?", "?", "?", "?", "?", "?", "?", "?", "CLR", "?", "?", "?",
|
||||
"HIMEM: ", "LOMEM: ", " + ", " - ", " * ", " / ", " = ", " # ", " >= ", " > ",
|
||||
" <= ", " <> ", " < ", " AND ", " OR ", " MOD ", "^", "+", "(", ",", " THEN ",
|
||||
" THEN ", ",", ",", "\"", "\"", "(", "!", "!", "(", "PEEK ", "RND ", "SGN", "ABS",
|
||||
"PDL", "RNDX", "(", "+", "-", "NOT ", "(", "=", "#", "LEN(", "ASC(", "SCRN(", ",",
|
||||
"(", "$", "$", "(", ", ", ",", ";", ";", ";", ",", ",", ",", "TEXT", "GR ", "CALL ",
|
||||
"DIM ", "DIM ", "TAB ", "END", "INPUT ", "INPUT ", "INPUT ", "FOR ", " = ", " TO ",
|
||||
" STEP ", "NEXT ", ",", "RETURN", "GOSUB ", "REM ", "LET ", "GOTO ", "IF ", "PRINT ",
|
||||
"PRINT ", "PRINT", "POKE ", ",", "COLOR=", "PLOT", ",", "HLIN", ",", " AT ", "VLIN ",
|
||||
",", " AT ", "VTAB ", " = ", " = ", ")", ")", "LIST ", ",", "LIST ", "POP ",
|
||||
"NODSP ", "NODSP ", "NOTRACE ", "DSP ", "DSP ", "TRACE ", "PR#", "IN#", };
|
||||
{ "?", "?", "?", " : ", "?", "?", "?", "?", "?", "?", "?", "?", "CLR", "?", "?",
|
||||
"?", "HIMEM: ", "LOMEM: ", " + ", " - ", " * ", " / ", " = ", " # ", " >= ",
|
||||
" > ", " <= ", " <> ", " < ", " AND ", " OR ", " MOD ", "^", "+", "(", ",",
|
||||
" THEN ", " THEN ", ",", ",", "\"", "\"", "(", "!", "!", "(", "PEEK ", "RND ",
|
||||
"SGN", "ABS", "PDL", "RNDX", "(", "+", "-", "NOT ", "(", "=", "#", "LEN(", "ASC(",
|
||||
"SCRN(", ",", "(", "$", "$", "(", ", ", ",", ";", ";", ";", ",", ",", ",", "TEXT",
|
||||
"GR ", "CALL ", "DIM ", "DIM ", "TAB ", "END", "INPUT ", "INPUT ", "INPUT ",
|
||||
"FOR ", " = ", " TO ", " STEP ", "NEXT ", ",", "RETURN", "GOSUB ", "REM ", "LET ",
|
||||
"GOTO ", "IF ", "PRINT ", "PRINT ", "PRINT", "POKE ", ",", "COLOR=", "PLOT", ",",
|
||||
"HLIN", ",", " AT ", "VLIN ", ",", " AT ", "VTAB ", " = ", " = ", ")", ")",
|
||||
"LIST ", ",", "LIST ", "POP ", "NODSP ", "NODSP ", "NOTRACE ", "DSP ", "DSP ",
|
||||
"TRACE ", "PR#", "IN#", };
|
||||
|
||||
public IntegerBasicProgram (String name, byte[] buffer)
|
||||
{
|
||||
@ -27,8 +28,8 @@ public class IntegerBasicProgram extends AbstractFile
|
||||
{
|
||||
StringBuilder pgm = new StringBuilder ();
|
||||
pgm.append ("Name : " + name + "\n");
|
||||
pgm.append ("Length : $" + HexFormatter.format4 (buffer.length) + " (" + buffer.length
|
||||
+ ")\n\n");
|
||||
pgm.append ("Length : $" + HexFormatter.format4 (buffer.length) + " ("
|
||||
+ buffer.length + ")\n\n");
|
||||
int ptr = 0;
|
||||
|
||||
boolean looksLikeAssembler = checkForAssembler (); // this can probably go
|
||||
@ -36,7 +37,7 @@ public class IntegerBasicProgram extends AbstractFile
|
||||
|
||||
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
|
||||
* lines ending in 01 are Integer Basic programs.
|
||||
@ -86,7 +87,7 @@ public class IntegerBasicProgram extends AbstractFile
|
||||
pgm.append (' ');
|
||||
continue;
|
||||
}
|
||||
int b = HexFormatter.intValue (buffer[i]);
|
||||
int b = buffer[i] & 0xFF;
|
||||
pgm.append ((char) b);
|
||||
}
|
||||
}
|
||||
@ -97,7 +98,7 @@ public class IntegerBasicProgram extends AbstractFile
|
||||
|
||||
while (ptr < buffer.length)
|
||||
{
|
||||
int lineLength = HexFormatter.intValue (buffer[ptr]);
|
||||
int lineLength = buffer[ptr] & 0xFF;
|
||||
if (lineLength == 255)
|
||||
System.out.printf ("Line length %d%n", lineLength);
|
||||
int p2 = ptr + lineLength - 1;
|
||||
@ -122,7 +123,7 @@ public class IntegerBasicProgram extends AbstractFile
|
||||
System.out.println ("Empty buffer array");
|
||||
return false;
|
||||
}
|
||||
int lineLength = HexFormatter.intValue (buffer[0]);
|
||||
int lineLength = buffer[0] & 0xFF;
|
||||
if (lineLength <= 0)
|
||||
return false;
|
||||
return buffer[lineLength - 1] == 0;
|
||||
@ -130,8 +131,7 @@ public class IntegerBasicProgram extends AbstractFile
|
||||
|
||||
private void appendSCAssembler (StringBuilder pgm, int ptr, int lineLength)
|
||||
{
|
||||
int lineNumber = HexFormatter.intValue (buffer[ptr + 2]) * 256
|
||||
+ HexFormatter.intValue (buffer[ptr + 1]);
|
||||
int lineNumber = (buffer[ptr + 2] & 0xFF) * 256 + (buffer[ptr + 1] & 0xFF);
|
||||
pgm.append (String.format ("%4d: ", lineNumber));
|
||||
int p2 = ptr + 3;
|
||||
while (buffer[p2] != 0)
|
||||
@ -168,7 +168,7 @@ public class IntegerBasicProgram extends AbstractFile
|
||||
|
||||
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 (:)
|
||||
&& !inString && !inRemark && buffer[p + 1] != 1) // not end of line
|
||||
@ -223,7 +223,7 @@ public class IntegerBasicProgram extends AbstractFile
|
||||
|
||||
while (ptr < buffer.length)
|
||||
{
|
||||
int lineLength = HexFormatter.intValue (buffer[ptr]);
|
||||
int lineLength = buffer[ptr] & 0xFF;
|
||||
int p2 = ptr + lineLength - 1;
|
||||
if (p2 < 0 || p2 >= buffer.length || buffer[p2] > 1)
|
||||
{
|
||||
|
@ -5,6 +5,18 @@ import java.util.List;
|
||||
|
||||
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
|
||||
{
|
||||
private static final int SIZE = 400;
|
||||
@ -23,7 +35,7 @@ public class ShapeTable extends AbstractFile
|
||||
|
||||
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 row = startPos;
|
||||
int col = row;
|
||||
@ -147,7 +159,7 @@ public class ShapeTable extends AbstractFile
|
||||
return false;
|
||||
|
||||
// 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)
|
||||
return false;
|
||||
|
||||
|
@ -9,6 +9,7 @@ public class StoredVariables extends AbstractFile
|
||||
super (name, buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
@ -36,7 +37,7 @@ public class StoredVariables extends AbstractFile
|
||||
char suffix = variableName.charAt (variableName.length () - 1);
|
||||
if (suffix == '$')
|
||||
{
|
||||
int strLength = HexFormatter.intValue (buffer[ptr + 2]);
|
||||
int strLength = buffer[ptr + 2] & 0xFF;
|
||||
strPtr -= strLength;
|
||||
strValue = HexFormatter.getString (buffer, strPtr, strLength);
|
||||
text.append (" = " + strValue);
|
||||
@ -120,7 +121,7 @@ public class StoredVariables extends AbstractFile
|
||||
String variableName = getVariableName (buffer[ptr], buffer[ptr + 1]);
|
||||
text.append ("\n");
|
||||
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 totalElements = 0;
|
||||
for (int i = 0; i < dimensions; i++)
|
||||
@ -153,7 +154,7 @@ public class StoredVariables extends AbstractFile
|
||||
}
|
||||
else if (elementSize == 3)
|
||||
{
|
||||
int strLength = HexFormatter.intValue (buffer[p]);
|
||||
int strLength = buffer[p] & 0xFF;
|
||||
if (strLength > 0)
|
||||
{
|
||||
strPtr -= strLength;
|
||||
@ -188,6 +189,7 @@ public class StoredVariables extends AbstractFile
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHexDump ()
|
||||
{
|
||||
StringBuffer text = new StringBuffer ();
|
||||
@ -199,7 +201,7 @@ public class StoredVariables extends AbstractFile
|
||||
int varLength = HexFormatter.intValue (buffer[2], buffer[3]);
|
||||
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 ("\n\n");
|
||||
|
||||
@ -214,7 +216,7 @@ public class StoredVariables extends AbstractFile
|
||||
while (ptr < totalLength + 5)
|
||||
{
|
||||
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 totalElements = 0;
|
||||
for (int i = 0; i < dimensions; i++)
|
||||
@ -229,7 +231,8 @@ public class StoredVariables extends AbstractFile
|
||||
}
|
||||
int headerSize = 5 + dimensions * 2;
|
||||
text.append (HexFormatter.format (buffer, ptr, headerSize, false, 0) + "\n\n");
|
||||
text.append (HexFormatter.format (buffer, ptr + headerSize, offset - headerSize, false, 0)
|
||||
text.append (
|
||||
HexFormatter.format (buffer, ptr + headerSize, offset - headerSize, false, 0)
|
||||
+ "\n\n");
|
||||
ptr += offset;
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
public class WizardryTitle extends AbstractFile
|
||||
{
|
||||
public WizardryTitle (String name, byte[] buffer)
|
||||
@ -21,7 +19,7 @@ public class WizardryTitle extends AbstractFile
|
||||
int p = i + line;
|
||||
if (p >= buffer.length)
|
||||
break;
|
||||
int value = HexFormatter.intValue (buffer[p]);
|
||||
int value = buffer[p] & 0xFF;
|
||||
text = decode2 (value, text);
|
||||
}
|
||||
text.append ("\n");
|
||||
|
@ -73,7 +73,7 @@ class DosCatalogSector extends AbstractSector
|
||||
int max = buffer[offset] == (byte) 0xFF ? 32 : 33;
|
||||
for (int i = 3; i < max; i++)
|
||||
{
|
||||
int c = HexFormatter.intValue (buffer[i + offset]);
|
||||
int c = buffer[i + offset] & 0xFF;
|
||||
if (c == 136)
|
||||
{
|
||||
if (text.length () > 0)
|
||||
|
@ -26,7 +26,7 @@ class DosVTOCSector extends AbstractSector
|
||||
|
||||
this.parentDisk = parentDisk;
|
||||
DOSVersion = buffer[3];
|
||||
volume = HexFormatter.intValue (buffer[6]);
|
||||
volume = buffer[6] & 0xFF;
|
||||
maxTSPairs = buffer[39];
|
||||
lastAllocTrack = buffer[48];
|
||||
direction = buffer[49];
|
||||
@ -64,8 +64,7 @@ class DosVTOCSector extends AbstractSector
|
||||
extra = "(VTOC and Catalog)";
|
||||
else
|
||||
extra = "";
|
||||
addText (text, buffer, i, 4,
|
||||
String.format ("Track %02X %s %s", (i - 56) / 4,
|
||||
addText (text, buffer, i, 4, String.format ("Track %02X %s %s", (i - 56) / 4,
|
||||
getBitmap (buffer[i], buffer[i + 1]), extra));
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
||||
public static boolean checkFormat (AppleDisk disk, boolean debug)
|
||||
{
|
||||
byte[] buffer = disk.readSector (2);
|
||||
int nameLength = HexFormatter.intValue (buffer[6]);
|
||||
int nameLength = buffer[6] & 0xFF;
|
||||
if (nameLength < 1 || nameLength > 7)
|
||||
{
|
||||
if (debug)
|
||||
@ -188,7 +188,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
||||
return false;
|
||||
if (kind == 0)
|
||||
return false;
|
||||
nameLength = HexFormatter.intValue (buffer[ptr + 6]);
|
||||
nameLength = buffer[ptr + 6] & 0xFF;
|
||||
if (nameLength < 1 || nameLength > 15)
|
||||
return false;
|
||||
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);
|
||||
storageType = (entryBuffer[0] & 0xF0) >> 4;
|
||||
created = HexFormatter.getAppleDate (entryBuffer, 24);
|
||||
version = HexFormatter.intValue (entryBuffer[28]);
|
||||
minVersion = HexFormatter.intValue (entryBuffer[29]);
|
||||
access = HexFormatter.intValue (entryBuffer[30]);
|
||||
version = entryBuffer[28] & 0xFF;
|
||||
minVersion = entryBuffer[29] & 0xFF;
|
||||
access = entryBuffer[30] & 0xFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,8 +12,8 @@ abstract class DirectoryHeader extends CatalogEntry
|
||||
{
|
||||
super (parentDisk, entryBuffer);
|
||||
|
||||
entryLength = HexFormatter.intValue (entryBuffer[31]);
|
||||
entriesPerBlock = HexFormatter.intValue (entryBuffer[32]);
|
||||
entryLength = entryBuffer[31] & 0xFF;
|
||||
entriesPerBlock = entryBuffer[32] & 0xFF;
|
||||
fileCount = HexFormatter.intValue (entryBuffer[33], entryBuffer[34]);
|
||||
}
|
||||
}
|
@ -80,7 +80,7 @@ class ProdosCatalogSector extends AbstractSector
|
||||
private String doFileDescription (int offset)
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
int fileType = HexFormatter.intValue (buffer[offset + 16]);
|
||||
int fileType = buffer[offset + 16] & 0xFF;
|
||||
addText (text, buffer, offset + 16, 1,
|
||||
"File type (" + ProdosConstants.fileTypes[fileType] + ")");
|
||||
addTextAndDecimal (text, buffer, offset + 17, 2, "Key pointer");
|
||||
@ -191,7 +191,7 @@ class ProdosCatalogSector extends AbstractSector
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
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 ();
|
||||
}
|
||||
}
|
@ -60,7 +60,7 @@ class ProdosDirectory extends AbstractFile
|
||||
case ProdosConstants.TYPE_PASCAL_ON_PROFILE:
|
||||
case ProdosConstants.TYPE_GSOS_EXTENDED_FILE:
|
||||
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]);
|
||||
|
||||
GregorianCalendar created = HexFormatter.getAppleDate (buffer, i + 24);
|
||||
@ -74,7 +74,7 @@ class ProdosDirectory extends AbstractFile
|
||||
modified == null ? "" : parentFD.stf.format (modified.getTime ());
|
||||
int eof =
|
||||
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 ? " " : "*";
|
||||
|
||||
switch (fileType)
|
||||
@ -97,16 +97,16 @@ class ProdosDirectory extends AbstractFile
|
||||
}
|
||||
|
||||
text.append (String.format ("%s%-15s %3s %5d %9s %5s %9s %5s %8d %7s%n",
|
||||
locked, filename, ProdosConstants.fileTypes[type],
|
||||
blocks, dateM, timeM, dateC, timeC, eof, subType));
|
||||
locked, filename, ProdosConstants.fileTypes[type], blocks, dateM, timeM,
|
||||
dateC, timeC, eof, subType));
|
||||
break;
|
||||
|
||||
default:
|
||||
text.append (" <Unknown strage type : " + storageType + newLine);
|
||||
}
|
||||
}
|
||||
text.append (String.format (
|
||||
"%nBLOCKS FREE:%5d BLOCKS USED:%5d TOTAL BLOCKS:%5d%n",
|
||||
text.append (
|
||||
String.format ("%nBLOCKS FREE:%5d BLOCKS USED:%5d TOTAL BLOCKS:%5d%n",
|
||||
freeBlocks, usedBlocks, totalBlocks));
|
||||
return text.toString ();
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ class SubDirectoryHeader extends DirectoryHeader
|
||||
this.parentDirectory = parent.parentDirectory;
|
||||
|
||||
parentPointer = HexFormatter.intValue (entryBuffer[35], entryBuffer[36]);
|
||||
parentSequence = HexFormatter.intValue (entryBuffer[37]);
|
||||
parentSize = HexFormatter.intValue (entryBuffer[38]);
|
||||
parentSequence = entryBuffer[37] & 0xFF;
|
||||
parentSize = entryBuffer[38] & 0xFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -151,7 +151,7 @@ public class HexFormatter
|
||||
|
||||
for (int i = offset; i < offset + length; i++)
|
||||
{
|
||||
int c = intValue (buffer[i]);
|
||||
int c = buffer[i] & 0xFF;
|
||||
if (c > 127)
|
||||
{
|
||||
if (c < 160)
|
||||
@ -176,7 +176,7 @@ public class HexFormatter
|
||||
|
||||
for (int i = offset; i < offset + length; i++)
|
||||
{
|
||||
int c = intValue (buffer[i]);
|
||||
int c = buffer[i] & 0xFF;
|
||||
if (c == 136 && text.length () > 0)
|
||||
{
|
||||
System.out.println (text.toString ());
|
||||
@ -241,7 +241,7 @@ public class HexFormatter
|
||||
|
||||
public static char byteValue (byte b)
|
||||
{
|
||||
int c = intValue (b);
|
||||
int c = b & 0xFF;
|
||||
if (c > 127)
|
||||
c -= 128;
|
||||
if (c > 95)
|
||||
@ -288,24 +288,19 @@ public class HexFormatter
|
||||
return text;
|
||||
}
|
||||
|
||||
public static int intValue (byte b1)
|
||||
{
|
||||
// int i1 = b1;
|
||||
// if (i1 < 0)
|
||||
// i1 += 256;
|
||||
|
||||
// return i1;
|
||||
return b1 & 0xFF;
|
||||
}
|
||||
// public static int intValue (byte b1)
|
||||
// {
|
||||
// return b1 & 0xFF;
|
||||
// }
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
@ -330,6 +325,17 @@ public class HexFormatter
|
||||
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)
|
||||
{
|
||||
int val = 0;
|
||||
@ -379,11 +385,11 @@ public class HexFormatter
|
||||
{
|
||||
double val = 0;
|
||||
|
||||
int exponent = HexFormatter.intValue (buffer[offset]) - 0x80;
|
||||
int exponent = (buffer[offset] & 0xFF) - 0x80;
|
||||
|
||||
int mantissa =
|
||||
(buffer[offset + 1] & 0x7F) * 0x1000000 + intValue (buffer[offset + 2]) * 0x10000
|
||||
+ intValue (buffer[offset + 3]) * 0x100 + intValue (buffer[offset + 4]);
|
||||
(buffer[offset + 1] & 0x7F) * 0x1000000 + (buffer[offset + 2] & 0xFF) * 0x10000
|
||||
+ (buffer[offset + 3] & 0xFF) * 0x100 + (buffer[offset + 4] & 0xFF);
|
||||
|
||||
int weight1 = 1;
|
||||
long weight2 = 2147483648L;
|
||||
@ -428,8 +434,8 @@ public class HexFormatter
|
||||
int year = (date & 0xFE00) >> 9;
|
||||
int month = (date & 0x01E0) >> 5;
|
||||
int day = date & 0x001F;
|
||||
int hour = HexFormatter.intValue (buffer[offset + 3]) & 0x1F;
|
||||
int minute = HexFormatter.intValue (buffer[offset + 2]) & 0x3F;
|
||||
int hour = buffer[offset + 3] & 0x1F;
|
||||
int minute = buffer[offset + 2] & 0x3F;
|
||||
if (year < 70)
|
||||
year += 2000;
|
||||
else
|
||||
@ -441,7 +447,7 @@ public class HexFormatter
|
||||
|
||||
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 month = buffer[offset] & 0x0F;
|
||||
if (day == 0 || month == 0)
|
||||
@ -458,7 +464,7 @@ public class HexFormatter
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -32,13 +32,13 @@ class Character extends AbstractFile
|
||||
attributes = new Attributes ();
|
||||
stats = new Statistics ();
|
||||
|
||||
stats.race = races[HexFormatter.intValue (buffer[34])];
|
||||
stats.typeInt = HexFormatter.intValue (buffer[36]);
|
||||
stats.race = races[buffer[34] & 0xFF];
|
||||
stats.typeInt = buffer[36] & 0xFF;
|
||||
stats.type = types[stats.typeInt];
|
||||
stats.ageInWeeks = HexFormatter.intValue (buffer[38], buffer[39]);
|
||||
stats.statusValue = buffer[40];
|
||||
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])
|
||||
+ HexFormatter.intValue (buffer[54], buffer[55]) * 10000;
|
||||
@ -50,30 +50,30 @@ class Character extends AbstractFile
|
||||
stats.hitsMax = HexFormatter.intValue (buffer[136], buffer[137]);
|
||||
stats.armourClass = buffer[176];
|
||||
|
||||
attributes.strength = HexFormatter.intValue (buffer[44]) % 16;
|
||||
attributes.strength = (buffer[44] & 0xFF) % 16;
|
||||
if (attributes.strength < 3)
|
||||
attributes.strength += 16;
|
||||
attributes.array[0] = attributes.strength;
|
||||
|
||||
int i1 = HexFormatter.intValue (buffer[44]) / 16;
|
||||
int i2 = HexFormatter.intValue (buffer[45]) % 4;
|
||||
int i1 = (buffer[44] & 0xFF) / 16;
|
||||
int i2 = (buffer[45] & 0xFF) % 4;
|
||||
attributes.intelligence = i1 / 2 + i2 * 8;
|
||||
attributes.array[1] = attributes.intelligence;
|
||||
|
||||
attributes.piety = HexFormatter.intValue (buffer[45]) / 4;
|
||||
attributes.piety = (buffer[45] & 0xFF) / 4;
|
||||
attributes.array[2] = attributes.piety;
|
||||
|
||||
attributes.vitality = HexFormatter.intValue (buffer[46]) % 16;
|
||||
attributes.vitality = (buffer[46] & 0xFF) % 16;
|
||||
if (attributes.vitality < 3)
|
||||
attributes.vitality += 16;
|
||||
attributes.array[3] = attributes.vitality;
|
||||
|
||||
int a1 = HexFormatter.intValue (buffer[46]) / 16;
|
||||
int a2 = HexFormatter.intValue (buffer[47]) % 4;
|
||||
int a1 = (buffer[46] & 0xFF) / 16;
|
||||
int a2 = (buffer[47] & 0xFF) % 4;
|
||||
attributes.agility = a1 / 2 + a2 * 8;
|
||||
attributes.array[4] = attributes.agility;
|
||||
|
||||
attributes.luck = HexFormatter.intValue (buffer[47]) / 4;
|
||||
attributes.luck = (buffer[47] & 0xFF) / 4;
|
||||
attributes.array[5] = attributes.luck;
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ class Character extends AbstractFile
|
||||
|
||||
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)
|
||||
itemID = (itemID + 24) % 256;
|
||||
if (itemID >= 0 && itemID < itemList.size ())
|
||||
|
@ -14,7 +14,7 @@ class CodedMessage extends Message
|
||||
@Override
|
||||
protected String getLine (int offset)
|
||||
{
|
||||
int length = HexFormatter.intValue (buffer[offset]);
|
||||
int length = buffer[offset] & 0xFF;
|
||||
byte[] translation = new byte[length];
|
||||
codeOffset--;
|
||||
for (int j = 0; j < length; j++)
|
||||
|
@ -186,7 +186,7 @@ class Header
|
||||
{
|
||||
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++)
|
||||
{
|
||||
if ((value & 0x01) == 1)
|
||||
@ -217,10 +217,10 @@ class Header
|
||||
public ScenarioData (byte[] buffer, int seq, List<DiskAddress> sectors)
|
||||
{
|
||||
int offset = 42 + seq * 2;
|
||||
dunno = HexFormatter.intValue (buffer[offset]);
|
||||
total = HexFormatter.intValue (buffer[offset + 16]);
|
||||
totalBlocks = HexFormatter.intValue (buffer[offset + 32]);
|
||||
dataOffset = HexFormatter.intValue (buffer[offset + 48]);
|
||||
dunno = buffer[offset] & 0xFF;
|
||||
total = buffer[offset + 16] & 0xFF;
|
||||
totalBlocks = buffer[offset + 32] & 0xFF;
|
||||
dataOffset = buffer[offset + 48] & 0xFF;
|
||||
type = seq;
|
||||
|
||||
this.sectors = new ArrayList<DiskAddress> (totalBlocks);
|
||||
|
@ -20,8 +20,7 @@ class Item extends AbstractFile implements Comparable<Item>
|
||||
super (name, buffer);
|
||||
itemID = counter++;
|
||||
type = buffer[32];
|
||||
cost =
|
||||
HexFormatter.intValue (buffer[44], buffer[45])
|
||||
cost = HexFormatter.intValue (buffer[44], buffer[45])
|
||||
+ HexFormatter.intValue (buffer[46], buffer[47]) * 10000
|
||||
+ HexFormatter.intValue (buffer[48], buffer[49]) * 100000000L;
|
||||
genericName = HexFormatter.getPascalString (buffer, 16);
|
||||
@ -87,7 +86,7 @@ class Item extends AbstractFile implements Comparable<Item>
|
||||
|
||||
public boolean canUse (int type2)
|
||||
{
|
||||
int users = HexFormatter.intValue (buffer[54]);
|
||||
int users = buffer[54] & 0xFF;
|
||||
return ((users >>> type2) & 1) == 1;
|
||||
}
|
||||
|
||||
@ -133,6 +132,7 @@ class Item extends AbstractFile implements Comparable<Item>
|
||||
return line.toString ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo (Item otherItem)
|
||||
{
|
||||
Item item = otherItem;
|
||||
|
@ -88,13 +88,13 @@ public class MazeGridV5 extends AbstractFile
|
||||
int offset = gridNo * 16 + column * 2 + row / 4;
|
||||
int value;
|
||||
|
||||
value = HexFormatter.intValue (buffer[offset + 0]);
|
||||
value = buffer[offset + 0] & 0xFF;
|
||||
value >>>= (row % 4) * 2;
|
||||
cell.eastWall = ((value & 1) == 1);
|
||||
value >>>= 1;
|
||||
cell.eastDoor = ((value & 1) == 1);
|
||||
|
||||
value = HexFormatter.intValue (buffer[offset + 256]);
|
||||
value = buffer[offset + 256] & 0xFF;
|
||||
value >>>= (row % 4) * 2;
|
||||
cell.northWall = ((value & 1) == 1);
|
||||
value >>>= 1;
|
||||
|
@ -105,9 +105,7 @@ class Monster extends AbstractFile implements Comparable<Monster>
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
// these values definitely affect the damage a monster does (when breathing?)
|
||||
int exp2 =
|
||||
(HexFormatter.intValue (buffer[72]) * HexFormatter.intValue (buffer[74]) - 1)
|
||||
* 20;
|
||||
int exp2 = ((buffer[72] & 0xFF) * (buffer[74] & 0xFF) - 1) * 20;
|
||||
int exp3 = weight2[speed]; // 1-6
|
||||
int exp4 = (10 - armourClass) * 40;
|
||||
int exp5 = getBonus (35, mageSpellLevel);
|
||||
@ -191,9 +189,7 @@ class Monster extends AbstractFile implements Comparable<Monster>
|
||||
public int getExperience ()
|
||||
{
|
||||
// these values definitely affect the damage a monster does (when breathing?)
|
||||
int exp2 =
|
||||
(HexFormatter.intValue (buffer[72]) * HexFormatter.intValue (buffer[74]) - 1)
|
||||
* 20;
|
||||
int exp2 = ((buffer[72] & 0xFF) * (buffer[74] & 0xFF) - 1) * 20;
|
||||
int exp3 = weight2[speed];
|
||||
int exp4 = (10 - armourClass) * 40;
|
||||
int exp5 = getBonus (35, mageSpellLevel);
|
||||
|
@ -12,7 +12,7 @@ class PlainMessage extends Message
|
||||
@Override
|
||||
protected String getLine (int offset)
|
||||
{
|
||||
int length = HexFormatter.intValue (buffer[offset]);
|
||||
int length = buffer[offset] & 0xFF;
|
||||
return HexFormatter.getString (buffer, offset + 1, length);
|
||||
}
|
||||
}
|
@ -255,7 +255,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||
int recLen = 208;
|
||||
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)
|
||||
continue;
|
||||
String name = HexFormatter.getString (buffer, ptr + 1, nameLength);
|
||||
@ -308,7 +308,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||
int recLen = 158;
|
||||
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)
|
||||
break;
|
||||
String itemName = HexFormatter.getString (buffer, ptr + 33, nameLength);
|
||||
|
Loading…
x
Reference in New Issue
Block a user