moved some functions from HexFormatter to Utility
This commit is contained in:
parent
2c37c365d6
commit
489f7b1791
|
@ -7,6 +7,7 @@ import java.util.Set;
|
|||
import java.util.Stack;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
public class ApplesoftBasicProgram extends BasicProgram
|
||||
{
|
||||
|
@ -37,7 +38,7 @@ public class ApplesoftBasicProgram extends BasicProgram
|
|||
int max = buffer.length - 4; // need at least 4 bytes to make a SourceLine
|
||||
while (ptr < max)
|
||||
{
|
||||
int offset = HexFormatter.unsignedShort (buffer, ptr);
|
||||
int offset = Utility.unsignedShort (buffer, ptr);
|
||||
if (offset <= prevOffset)
|
||||
break;
|
||||
|
||||
|
@ -214,7 +215,7 @@ public class ApplesoftBasicProgram extends BasicProgram
|
|||
int ptr = endPtr + 2;
|
||||
if (ptr < buffer.length - 1) // sometimes there's an extra byte on the end
|
||||
{
|
||||
int offset = HexFormatter.unsignedShort (buffer, 0);
|
||||
int offset = Utility.unsignedShort (buffer, 0);
|
||||
int programLoadAddress = offset - getLineLength (0);
|
||||
fullText.append ("\nExtra data:\n\n");
|
||||
fullText.append (HexFormatter.formatNoHeader (buffer, ptr, buffer.length - ptr,
|
||||
|
@ -379,7 +380,7 @@ public class ApplesoftBasicProgram extends BasicProgram
|
|||
addHeader (pgm);
|
||||
|
||||
int ptr = 0;
|
||||
int offset = HexFormatter.unsignedShort (buffer, 0);
|
||||
int offset = Utility.unsignedShort (buffer, 0);
|
||||
int programLoadAddress = offset - getLineLength (0);
|
||||
|
||||
while (ptr <= endPtr) // stop at the same place as the source listing
|
||||
|
@ -423,7 +424,7 @@ public class ApplesoftBasicProgram extends BasicProgram
|
|||
int programLoadAddress = 0;
|
||||
if (buffer.length > 1)
|
||||
{
|
||||
int offset = HexFormatter.intValue (buffer[0], buffer[1]);
|
||||
int offset = Utility.intValue (buffer[0], buffer[1]);
|
||||
programLoadAddress = offset - getLineLength (0);
|
||||
}
|
||||
return programLoadAddress;
|
||||
|
@ -431,7 +432,7 @@ public class ApplesoftBasicProgram extends BasicProgram
|
|||
|
||||
private int getLineLength (int ptr)
|
||||
{
|
||||
int offset = HexFormatter.unsignedShort (buffer, ptr);
|
||||
int offset = Utility.unsignedShort (buffer, ptr);
|
||||
if (offset == 0)
|
||||
return 0;
|
||||
ptr += 4; // skip offset and line number
|
||||
|
@ -478,7 +479,7 @@ public class ApplesoftBasicProgram extends BasicProgram
|
|||
public SourceLine (int ptr)
|
||||
{
|
||||
linePtr = ptr;
|
||||
lineNumber = HexFormatter.intValue (buffer[ptr + 2], buffer[ptr + 3]);
|
||||
lineNumber = Utility.intValue (buffer[ptr + 2], buffer[ptr + 3]);
|
||||
|
||||
int startPtr = ptr += 4;
|
||||
boolean inString = false; // can toggle
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Arrays;
|
|||
import java.util.Comparator;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
public class AssemblerStatement
|
||||
{
|
||||
|
@ -312,7 +313,7 @@ public class AssemblerStatement
|
|||
case 0xEE: // INC
|
||||
operand = address;
|
||||
mode = 3; // absolute
|
||||
this.target = HexFormatter.intValue (b1, b2);
|
||||
this.target = Utility.intValue (b1, b2);
|
||||
break;
|
||||
|
||||
case 0x1D: // ORA
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.bytezone.diskbrowser.applefile;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class BasicProgramGS extends BasicProgram
|
||||
|
@ -134,7 +134,7 @@ public class BasicProgramGS extends BasicProgram
|
|||
ptr += labelLength;
|
||||
|
||||
int lineLength = buffer[ptr] & 0xFF;
|
||||
lineNumber = HexFormatter.intValue (buffer[ptr + 1], buffer[ptr + 2]);
|
||||
lineNumber = Utility.intValue (buffer[ptr + 1], buffer[ptr + 2]);
|
||||
length = labelLength + lineLength;
|
||||
|
||||
if (lineNumber == 0)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// pack::: ~/exomizer-3.0.2/src/exomizer mem -q -P23 -lnone LODE148@0x4000 -o LODE148c
|
||||
|
@ -38,15 +37,15 @@ public class ExoBuffer
|
|||
this.inBuffer = inBuffer;
|
||||
Utility.reverse (inBuffer);
|
||||
|
||||
switch (inBuffer[0])
|
||||
switch (Utility.getShortBigEndian (inBuffer, 0))
|
||||
{
|
||||
case 0x60:
|
||||
case 0x6000:
|
||||
outBuffer = new byte[0x2000]; // HGR
|
||||
break;
|
||||
case (byte) 0x80:
|
||||
case 0x8000:
|
||||
outBuffer = new byte[0x4000]; // DHGR
|
||||
break;
|
||||
case (byte) 0xA0:
|
||||
case 0xA000:
|
||||
outBuffer = new byte[0x8000]; // SHR
|
||||
break;
|
||||
}
|
||||
|
@ -69,7 +68,7 @@ public class ExoBuffer
|
|||
if (auxType != 0x1FF8 && auxType != 0x3FF8)
|
||||
return false;
|
||||
|
||||
int address = HexFormatter.unsignedShort (buffer, buffer.length - 2);
|
||||
int address = Utility.unsignedShort (buffer, buffer.length - 2);
|
||||
|
||||
if (address != 0x6000 && address != 0x8000 && address != 0xA000)
|
||||
return false;
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
public class FileTypeDescriptorTable extends AbstractFile
|
||||
{
|
||||
|
@ -23,11 +24,11 @@ public class FileTypeDescriptorTable extends AbstractFile
|
|||
|
||||
versionMajor = buffer[0] & 0xFF;
|
||||
versionMinor = buffer[1] & 0xFF;
|
||||
flags = HexFormatter.unsignedShort (buffer, 2);
|
||||
numEntries = HexFormatter.unsignedShort (buffer, 4);
|
||||
spareWord = HexFormatter.unsignedShort (buffer, 6);
|
||||
indexRecordSize = HexFormatter.unsignedShort (buffer, 8);
|
||||
offsetToIdx = HexFormatter.unsignedShort (buffer, 10);
|
||||
flags = Utility.unsignedShort (buffer, 2);
|
||||
numEntries = Utility.unsignedShort (buffer, 4);
|
||||
spareWord = Utility.unsignedShort (buffer, 6);
|
||||
indexRecordSize = Utility.unsignedShort (buffer, 8);
|
||||
offsetToIdx = Utility.unsignedShort (buffer, 10);
|
||||
|
||||
int ptr = offsetToIdx;
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
|
@ -71,10 +72,10 @@ public class FileTypeDescriptorTable extends AbstractFile
|
|||
|
||||
public IndexRecord (byte[] buffer, int offset)
|
||||
{
|
||||
fileType = HexFormatter.unsignedShort (buffer, offset);
|
||||
auxType = HexFormatter.unsignedLong (buffer, offset + 2);
|
||||
flags = HexFormatter.unsignedShort (buffer, offset + 6);
|
||||
this.offset = HexFormatter.unsignedShort (buffer, offset + 8);
|
||||
fileType = Utility.unsignedShort (buffer, offset);
|
||||
auxType = Utility.unsignedLong (buffer, offset + 2);
|
||||
flags = Utility.unsignedShort (buffer, offset + 6);
|
||||
this.offset = Utility.unsignedShort (buffer, offset + 8);
|
||||
string = HexFormatter.getPascalString (buffer, this.offset);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import javax.imageio.ImageIO;
|
|||
|
||||
import com.bytezone.diskbrowser.prodos.ProdosConstants;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public abstract class HiResImage extends AbstractFile
|
||||
|
@ -629,15 +630,15 @@ public abstract class HiResImage extends AbstractFile
|
|||
return false;
|
||||
|
||||
String text = new String (buffer, 0, 2);
|
||||
int size = HexFormatter.unsignedLong (buffer, 2);
|
||||
int size = Utility.unsignedLong (buffer, 2);
|
||||
|
||||
if (false)
|
||||
{
|
||||
int empty = HexFormatter.unsignedLong (buffer, 6);
|
||||
int offset = HexFormatter.unsignedLong (buffer, 10);
|
||||
int header = HexFormatter.unsignedLong (buffer, 14);
|
||||
int width = HexFormatter.unsignedLong (buffer, 18);
|
||||
int height = HexFormatter.unsignedLong (buffer, 22);
|
||||
int empty = Utility.unsignedLong (buffer, 6);
|
||||
int offset = Utility.unsignedLong (buffer, 10);
|
||||
int header = Utility.unsignedLong (buffer, 14);
|
||||
int width = Utility.unsignedLong (buffer, 18);
|
||||
int height = Utility.unsignedLong (buffer, 22);
|
||||
|
||||
System.out.println (buffer.length);
|
||||
System.out.println (size);
|
||||
|
@ -809,7 +810,7 @@ public abstract class HiResImage extends AbstractFile
|
|||
public ColorEntry (byte[] data, int offset)
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
value = HexFormatter.unsignedShort (data, offset);
|
||||
value = Utility.unsignedShort (data, offset);
|
||||
|
||||
int red = ((value >> 8) & 0x0f) * 17;
|
||||
int green = ((value >> 4) & 0x0f) * 17;
|
||||
|
@ -838,8 +839,8 @@ public abstract class HiResImage extends AbstractFile
|
|||
public DirEntry (byte[] data, int offset)
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
numBytes = HexFormatter.unsignedShort (data, offset);
|
||||
mode = HexFormatter.unsignedShort (data, offset + 2);
|
||||
numBytes = Utility.unsignedShort (data, offset);
|
||||
mode = Utility.unsignedShort (data, offset + 2);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------//
|
||||
|
|
|
@ -29,16 +29,16 @@ public class IconFile extends AbstractFile implements ProdosConstants
|
|||
{
|
||||
super (name, buffer);
|
||||
|
||||
iBlkNext = HexFormatter.unsignedLong (buffer, 0);
|
||||
iBlkID = HexFormatter.unsignedShort (buffer, 4);
|
||||
iBlkPath = HexFormatter.unsignedLong (buffer, 6);
|
||||
iBlkNext = Utility.unsignedLong (buffer, 0);
|
||||
iBlkID = Utility.unsignedShort (buffer, 4);
|
||||
iBlkPath = Utility.unsignedLong (buffer, 6);
|
||||
iBlkName = HexFormatter.getHexString (buffer, 10, 16);
|
||||
|
||||
int ptr = 26;
|
||||
|
||||
while (true)
|
||||
{
|
||||
int dataLen = HexFormatter.unsignedShort (buffer, ptr);
|
||||
int dataLen = Utility.unsignedShort (buffer, ptr);
|
||||
if (dataLen == 0 || (dataLen + ptr) > buffer.length)
|
||||
break;
|
||||
|
||||
|
@ -131,7 +131,7 @@ public class IconFile extends AbstractFile implements ProdosConstants
|
|||
public Icon (byte[] fullBuffer, int ptr)
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
iDataLen = HexFormatter.unsignedShort (fullBuffer, ptr);
|
||||
iDataLen = Utility.unsignedShort (fullBuffer, ptr);
|
||||
|
||||
buffer = new byte[iDataLen];
|
||||
System.arraycopy (fullBuffer, ptr, buffer, 0, buffer.length);
|
||||
|
@ -142,8 +142,8 @@ public class IconFile extends AbstractFile implements ProdosConstants
|
|||
len = buffer[66] & 0xFF;
|
||||
dataName = new String (buffer, 67, len);
|
||||
|
||||
iDataType = HexFormatter.unsignedShort (buffer, 82);
|
||||
iDataAux = HexFormatter.unsignedShort (buffer, 84);
|
||||
iDataType = Utility.unsignedShort (buffer, 82);
|
||||
iDataAux = Utility.unsignedShort (buffer, 84);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
|
@ -200,10 +200,10 @@ public class IconFile extends AbstractFile implements ProdosConstants
|
|||
public Image (byte[] buffer, int ptr) throws InvalidImageException
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
iconType = HexFormatter.unsignedShort (buffer, ptr);
|
||||
iconSize = HexFormatter.unsignedShort (buffer, ptr + 2);
|
||||
iconHeight = HexFormatter.unsignedShort (buffer, ptr + 4);
|
||||
iconWidth = HexFormatter.unsignedShort (buffer, ptr + 6);
|
||||
iconType = Utility.unsignedShort (buffer, ptr);
|
||||
iconSize = Utility.unsignedShort (buffer, ptr + 2);
|
||||
iconHeight = Utility.unsignedShort (buffer, ptr + 4);
|
||||
iconWidth = Utility.unsignedShort (buffer, ptr + 6);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
public class IntegerBasicProgram extends BasicProgram
|
||||
{
|
||||
|
@ -64,7 +65,7 @@ public class IntegerBasicProgram extends BasicProgram
|
|||
|
||||
if ((ptr + 4) < buffer.length)
|
||||
{
|
||||
int address = HexFormatter.intValue (buffer[ptr + 2], buffer[ptr + 3]);
|
||||
int address = Utility.intValue (buffer[ptr + 2], buffer[ptr + 3]);
|
||||
int remainingBytes = buffer.length - ptr - 5;
|
||||
byte[] newBuffer = new byte[remainingBytes];
|
||||
System.arraycopy (buffer, ptr + 4, newBuffer, 0, remainingBytes);
|
||||
|
@ -157,7 +158,7 @@ public class IntegerBasicProgram extends BasicProgram
|
|||
|
||||
private void appendInteger (StringBuilder text, int ptr, int lineLength)
|
||||
{
|
||||
int lineNumber = HexFormatter.intValue (buffer[ptr + 1], buffer[ptr + 2]);
|
||||
int lineNumber = Utility.intValue (buffer[ptr + 1], buffer[ptr + 2]);
|
||||
|
||||
boolean inString = false;
|
||||
boolean inRemark = false;
|
||||
|
@ -181,7 +182,7 @@ public class IntegerBasicProgram extends BasicProgram
|
|||
&& (buffer[p - 1] & 0x80) == 0 // not a variable name
|
||||
&& !inString && !inRemark)
|
||||
{
|
||||
text.append (HexFormatter.intValue (buffer[p + 1], buffer[p + 2]));
|
||||
text.append (Utility.intValue (buffer[p + 1], buffer[p + 2]));
|
||||
p += 2;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class PascalArea extends AbstractFile
|
||||
|
@ -21,13 +22,13 @@ public class PascalArea extends AbstractFile
|
|||
{
|
||||
super (name, buffer);
|
||||
|
||||
size = HexFormatter.unsignedShort (buffer, 0);
|
||||
volumes = HexFormatter.unsignedShort (buffer, 2);
|
||||
size = Utility.unsignedShort (buffer, 0);
|
||||
volumes = Utility.unsignedShort (buffer, 2);
|
||||
ppmName = HexFormatter.getPascalString (buffer, 4);
|
||||
start = HexFormatter.unsignedShort (buffer, 8);
|
||||
length = HexFormatter.unsignedShort (buffer, 11);
|
||||
start = Utility.unsignedShort (buffer, 8);
|
||||
length = Utility.unsignedShort (buffer, 11);
|
||||
defaultUnit = buffer[13] & 0xFF;
|
||||
oldDriver = HexFormatter.unsignedShort (buffer, 14);
|
||||
oldDriver = Utility.unsignedShort (buffer, 14);
|
||||
// writeProtected = buffer[12] != 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
|
||||
import com.bytezone.diskbrowser.utilities.FileFormatException;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public class PascalCode extends AbstractFile
|
||||
|
@ -46,7 +47,7 @@ public class PascalCode extends AbstractFile
|
|||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
String codeName = HexFormatter.getString (buffer, 0x40 + i * 8, 8).trim ();
|
||||
int size = HexFormatter.intValue (buffer[i * 4 + 2], buffer[i * 4 + 3]);
|
||||
int size = Utility.intValue (buffer[i * 4 + 2], buffer[i * 4 + 3]);
|
||||
if (codeName.length () == 0 && size > 0)
|
||||
codeName = "<NULL" + ++nonameCounter + ">";
|
||||
if (size > 0)
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class PascalCodeStatement implements PascalConstants
|
||||
|
@ -79,8 +80,8 @@ public class PascalCodeStatement implements PascalConstants
|
|||
int max = min + (p2 - p1) * 2;
|
||||
for (int i = min; i <= max; i += 2)
|
||||
{
|
||||
jumps.add (new Jump (i,
|
||||
i - HexFormatter.intValue (buffer[i], buffer[i + 1]), v++));
|
||||
jumps.add (
|
||||
new Jump (i, i - Utility.intValue (buffer[i], buffer[i + 1]), v++));
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import com.bytezone.diskbrowser.applefile.PascalCodeStatement.Jump;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class PascalProcedure
|
||||
|
@ -35,7 +36,7 @@ public class PascalProcedure
|
|||
this.buffer = buffer;
|
||||
this.slot = slot;
|
||||
int p = buffer.length - 2 - slot * 2;
|
||||
offset = HexFormatter.intValue (buffer[p], buffer[p + 1]);
|
||||
offset = Utility.intValue (buffer[p], buffer[p + 1]);
|
||||
procOffset = p - offset;
|
||||
valid = procOffset > 0;
|
||||
|
||||
|
@ -43,10 +44,10 @@ public class PascalProcedure
|
|||
{
|
||||
procedureNo = buffer[procOffset] & 0xFF;
|
||||
procLevel = buffer[procOffset + 1] & 0xFF;
|
||||
codeStart = HexFormatter.intValue (buffer[procOffset - 2], buffer[procOffset - 1]);
|
||||
codeEnd = HexFormatter.intValue (buffer[procOffset - 4], buffer[procOffset - 3]);
|
||||
parmSize = HexFormatter.intValue (buffer[procOffset - 6], buffer[procOffset - 5]);
|
||||
dataSize = HexFormatter.intValue (buffer[procOffset - 8], buffer[procOffset - 7]);
|
||||
codeStart = Utility.intValue (buffer[procOffset - 2], buffer[procOffset - 1]);
|
||||
codeEnd = Utility.intValue (buffer[procOffset - 4], buffer[procOffset - 3]);
|
||||
parmSize = Utility.intValue (buffer[procOffset - 6], buffer[procOffset - 5]);
|
||||
dataSize = Utility.intValue (buffer[procOffset - 8], buffer[procOffset - 7]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import com.bytezone.diskbrowser.utilities.FileFormatException;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class PascalSegment extends AbstractFile implements PascalConstants
|
||||
|
@ -42,14 +43,14 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
|||
// this.blockOffset = blockOffset;
|
||||
// this.relocator = relocator;
|
||||
|
||||
this.blockNo = HexFormatter.intValue (fullBuffer[seq * 4], fullBuffer[seq * 4 + 1]);
|
||||
this.size = HexFormatter.intValue (fullBuffer[seq * 4 + 2], fullBuffer[seq * 4 + 3]);
|
||||
this.blockNo = Utility.intValue (fullBuffer[seq * 4], fullBuffer[seq * 4 + 1]);
|
||||
this.size = Utility.intValue (fullBuffer[seq * 4 + 2], fullBuffer[seq * 4 + 3]);
|
||||
|
||||
segKind = HexFormatter.intValue (fullBuffer[0xC0 + seq * 2],
|
||||
fullBuffer[0xC0 + seq * 2 + 1]);
|
||||
segKind =
|
||||
Utility.intValue (fullBuffer[0xC0 + seq * 2], fullBuffer[0xC0 + seq * 2 + 1]);
|
||||
|
||||
textAddress = HexFormatter.intValue (fullBuffer[0xE0 + seq * 2],
|
||||
fullBuffer[0xE0 + seq * 2 + 1]);
|
||||
textAddress =
|
||||
Utility.intValue (fullBuffer[0xE0 + seq * 2], fullBuffer[0xE0 + seq * 2 + 1]);
|
||||
|
||||
// segment 1 is the main segment, 2-6 are used by the system, and 7
|
||||
// onwards is for the program
|
||||
|
@ -64,9 +65,9 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
|||
|
||||
version = (flags & 0xD0) >> 5;
|
||||
|
||||
intrinsSegs1 = HexFormatter.intValue (fullBuffer[0x120 + seq * 4],
|
||||
fullBuffer[0x120 + seq * 4 + 1]);
|
||||
intrinsSegs2 = HexFormatter.intValue (fullBuffer[0x120 + seq * 4 + 2],
|
||||
intrinsSegs1 =
|
||||
Utility.intValue (fullBuffer[0x120 + seq * 4], fullBuffer[0x120 + seq * 4 + 1]);
|
||||
intrinsSegs2 = Utility.intValue (fullBuffer[0x120 + seq * 4 + 2],
|
||||
fullBuffer[0x120 + seq * 4 + 3]);
|
||||
|
||||
int offset = blockNo * 512;
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Map;
|
|||
|
||||
import com.bytezone.diskbrowser.prodos.ProdosConstants;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// see IIGS System 6.0.1 - Disk 5 Fonts.po
|
||||
// -----------------------------------------------------------------------------------//
|
||||
|
@ -71,37 +72,37 @@ public class QuickDrawFont extends CharacterList
|
|||
|
||||
int ptr = nameLength + 1; // start of header record
|
||||
|
||||
headerSize = HexFormatter.unsignedShort (buffer, ptr);
|
||||
headerSize = Utility.unsignedShort (buffer, ptr);
|
||||
fontDefinitionOffset = nameLength + 1 + headerSize * 2;
|
||||
|
||||
fontFamily = HexFormatter.unsignedShort (buffer, ptr + 2);
|
||||
fontStyle = HexFormatter.unsignedShort (buffer, ptr + 4);
|
||||
fontSize = HexFormatter.unsignedShort (buffer, ptr + 6);
|
||||
fontFamily = Utility.unsignedShort (buffer, ptr + 2);
|
||||
fontStyle = Utility.unsignedShort (buffer, ptr + 4);
|
||||
fontSize = Utility.unsignedShort (buffer, ptr + 6);
|
||||
versionMajor = buffer[ptr + 8] & 0xFF;
|
||||
versionMinor = buffer[ptr + 9] & 0xFF;
|
||||
extent = HexFormatter.unsignedShort (buffer, ptr + 10);
|
||||
extent = Utility.unsignedShort (buffer, ptr + 10);
|
||||
|
||||
ptr = fontDefinitionOffset;
|
||||
|
||||
fontType = HexFormatter.unsignedShort (buffer, ptr);
|
||||
firstChar = HexFormatter.unsignedShort (buffer, ptr + 2);
|
||||
lastChar = HexFormatter.unsignedShort (buffer, ptr + 4);
|
||||
widMax = HexFormatter.unsignedShort (buffer, ptr + 6);
|
||||
kernMax = HexFormatter.signedShort (buffer, ptr + 8);
|
||||
nDescent = HexFormatter.signedShort (buffer, ptr + 10);
|
||||
fRectWidth = HexFormatter.unsignedShort (buffer, ptr + 12);
|
||||
fRectHeight = HexFormatter.unsignedShort (buffer, ptr + 14);
|
||||
fontType = Utility.unsignedShort (buffer, ptr);
|
||||
firstChar = Utility.unsignedShort (buffer, ptr + 2);
|
||||
lastChar = Utility.unsignedShort (buffer, ptr + 4);
|
||||
widMax = Utility.unsignedShort (buffer, ptr + 6);
|
||||
kernMax = Utility.signedShort (buffer, ptr + 8);
|
||||
nDescent = Utility.signedShort (buffer, ptr + 10);
|
||||
fRectWidth = Utility.unsignedShort (buffer, ptr + 12);
|
||||
fRectHeight = Utility.unsignedShort (buffer, ptr + 14);
|
||||
|
||||
owTLoc = HexFormatter.unsignedShort (buffer, ptr + 16);
|
||||
owTLoc = Utility.unsignedShort (buffer, ptr + 16);
|
||||
|
||||
offsetWidthTableOffset = (ptr + 16) + owTLoc * 2;
|
||||
locationTableOffset = offsetWidthTableOffset - (lastChar - firstChar + 3) * 2;
|
||||
bitImageOffset = ptr + 26;
|
||||
|
||||
ascent = HexFormatter.unsignedShort (buffer, ptr + 18);
|
||||
descent = HexFormatter.unsignedShort (buffer, ptr + 20);
|
||||
leading = HexFormatter.unsignedShort (buffer, ptr + 22);
|
||||
rowWords = HexFormatter.unsignedShort (buffer, ptr + 24);
|
||||
ascent = Utility.unsignedShort (buffer, ptr + 18);
|
||||
descent = Utility.unsignedShort (buffer, ptr + 20);
|
||||
leading = Utility.unsignedShort (buffer, ptr + 22);
|
||||
rowWords = Utility.unsignedShort (buffer, ptr + 24);
|
||||
|
||||
totalCharacters = lastChar - firstChar + 2; // includes 'missing' character
|
||||
|
||||
|
@ -150,13 +151,12 @@ public class QuickDrawFont extends CharacterList
|
|||
for (int i = 0, max = totalCharacters + 1; i < max; i++)
|
||||
{
|
||||
// index into the strike
|
||||
int location = HexFormatter.unsignedShort (buffer, locationTableOffset + i * 2);
|
||||
int location = Utility.unsignedShort (buffer, locationTableOffset + i * 2);
|
||||
|
||||
int j = i + 1; // next character
|
||||
if (j < max)
|
||||
{
|
||||
int nextLocation =
|
||||
HexFormatter.unsignedShort (buffer, locationTableOffset + j * 2);
|
||||
int nextLocation = Utility.unsignedShort (buffer, locationTableOffset + j * 2);
|
||||
int pixelWidth = nextLocation - location;
|
||||
|
||||
if (pixelWidth > 0)
|
||||
|
@ -259,9 +259,9 @@ public class QuickDrawFont extends CharacterList
|
|||
if (offset == 255 && width == 255)
|
||||
continue;
|
||||
|
||||
int location = HexFormatter.unsignedShort (buffer, locationTableOffset + i * 2);
|
||||
int location = Utility.unsignedShort (buffer, locationTableOffset + i * 2);
|
||||
int nextLocation =
|
||||
HexFormatter.unsignedShort (buffer, locationTableOffset + (i + 1) * 2);
|
||||
Utility.unsignedShort (buffer, locationTableOffset + (i + 1) * 2);
|
||||
int pixelWidth = nextLocation - location;
|
||||
|
||||
text.append (String.format (
|
||||
|
|
|
@ -5,8 +5,8 @@ import java.awt.image.DataBuffer;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.bytezone.common.Utility;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class SHRPictureFile1 extends HiResImage
|
||||
|
@ -27,7 +27,7 @@ public class SHRPictureFile1 extends HiResImage
|
|||
int ptr = 0;
|
||||
while (ptr < buffer.length)
|
||||
{
|
||||
int len = HexFormatter.unsignedLong (buffer, ptr);
|
||||
int len = Utility.unsignedLong (buffer, ptr);
|
||||
if (len == 0 || len > buffer.length)
|
||||
{
|
||||
System.out.printf ("Block length: %d%n", len);
|
||||
|
@ -232,7 +232,7 @@ public class SHRPictureFile1 extends HiResImage
|
|||
super (kind, data);
|
||||
|
||||
int ptr = 5 + kind.length ();
|
||||
numColorTables = HexFormatter.unsignedShort (data, ptr);
|
||||
numColorTables = Utility.unsignedShort (data, ptr);
|
||||
|
||||
ptr += 2;
|
||||
colorTables = new ColorTable[numColorTables];
|
||||
|
@ -286,9 +286,9 @@ public class SHRPictureFile1 extends HiResImage
|
|||
super (kind, data);
|
||||
|
||||
int ptr = 5 + kind.length ();
|
||||
masterMode = HexFormatter.unsignedShort (data, ptr);
|
||||
pixelsPerScanLine = HexFormatter.unsignedShort (data, ptr + 2);
|
||||
numColorTables = HexFormatter.unsignedShort (data, ptr + 4);
|
||||
masterMode = Utility.unsignedShort (data, ptr);
|
||||
pixelsPerScanLine = Utility.unsignedShort (data, ptr + 2);
|
||||
numColorTables = Utility.unsignedShort (data, ptr + 4);
|
||||
mode640 = (masterMode & 0x80) != 0;
|
||||
|
||||
ptr += 6;
|
||||
|
@ -299,7 +299,7 @@ public class SHRPictureFile1 extends HiResImage
|
|||
ptr += 32;
|
||||
}
|
||||
|
||||
numScanLines = HexFormatter.unsignedShort (data, ptr);
|
||||
numScanLines = Utility.unsignedShort (data, ptr);
|
||||
ptr += 2;
|
||||
|
||||
scanLineDirectory = new DirEntry[numScanLines];
|
||||
|
@ -465,7 +465,7 @@ public class SHRPictureFile1 extends HiResImage
|
|||
int ptr = 5 + kind.length ();
|
||||
while (ptr < data.length)
|
||||
{
|
||||
text.append (Utility.toHex (data, ptr, 4) + "\n");
|
||||
text.append (HexFormatter.format (data, ptr, 4) + "\n");
|
||||
ptr += 4;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.List;
|
|||
|
||||
import com.bytezone.diskbrowser.prodos.ProdosConstants;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class SHRPictureFile2 extends HiResImage
|
||||
|
@ -98,10 +99,10 @@ public class SHRPictureFile2 extends HiResImage
|
|||
unpack (buffer, 0, buffer.length, newBuffer, 0);
|
||||
buffer = newBuffer;
|
||||
|
||||
int mode = HexFormatter.unsignedShort (this.buffer, 0);
|
||||
int rect1 = HexFormatter.unsignedLong (this.buffer, 2);
|
||||
int rect2 = HexFormatter.unsignedLong (this.buffer, 6);
|
||||
int version = HexFormatter.unsignedShort (this.buffer, 10); // $8211
|
||||
int mode = Utility.unsignedShort (this.buffer, 0);
|
||||
int rect1 = Utility.unsignedLong (this.buffer, 2);
|
||||
int rect2 = Utility.unsignedLong (this.buffer, 6);
|
||||
int version = Utility.unsignedShort (this.buffer, 10); // $8211
|
||||
|
||||
break;
|
||||
|
||||
|
@ -154,7 +155,7 @@ public class SHRPictureFile2 extends HiResImage
|
|||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
// int len = HexFormatter.unsignedLong (buffer, 0x8000);
|
||||
delay = HexFormatter.unsignedLong (buffer, 0x8004);
|
||||
delay = Utility.unsignedLong (buffer, 0x8004);
|
||||
if (delay > 60)
|
||||
delay = 10;
|
||||
delay = delay * 1000 / 60;
|
||||
|
@ -172,7 +173,7 @@ public class SHRPictureFile2 extends HiResImage
|
|||
int start = ptr;
|
||||
while (ptr < buffer.length)
|
||||
{
|
||||
int off = HexFormatter.unsignedShort (buffer, ptr);
|
||||
int off = Utility.unsignedShort (buffer, ptr);
|
||||
|
||||
ptr += 4;
|
||||
if (off == 0)
|
||||
|
@ -298,7 +299,7 @@ public class SHRPictureFile2 extends HiResImage
|
|||
|
||||
while (true)
|
||||
{
|
||||
int offset = HexFormatter.unsignedShort (buffer, ptr);
|
||||
int offset = Utility.unsignedShort (buffer, ptr);
|
||||
if (offset == 0)
|
||||
break;
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
/*-
|
||||
* Offset Meaning
|
||||
|
@ -130,7 +131,7 @@ public class ShapeTable extends AbstractFile
|
|||
return false;
|
||||
|
||||
// check index points inside the file
|
||||
int offset = HexFormatter.unsignedShort (buffer, ptr);
|
||||
int offset = Utility.unsignedShort (buffer, ptr);
|
||||
if (offset == 0 || offset >= buffer.length)
|
||||
return false;
|
||||
|
||||
|
@ -169,7 +170,7 @@ public class ShapeTable extends AbstractFile
|
|||
int row = startRow;
|
||||
int col = startCol;
|
||||
|
||||
offset = HexFormatter.unsignedShort (buffer, index * 2 + 2);
|
||||
offset = Utility.unsignedShort (buffer, index * 2 + 2);
|
||||
|
||||
int ptr = offset;
|
||||
while (ptr < buffer.length)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class StoredVariables extends AbstractFile
|
||||
|
@ -25,10 +26,10 @@ public class StoredVariables extends AbstractFile
|
|||
int strPtr = buffer.length;
|
||||
|
||||
text.append ("File length : " + HexFormatter.format4 (buffer.length));
|
||||
int totalLength = HexFormatter.intValue (buffer[0], buffer[1]);
|
||||
int totalLength = Utility.intValue (buffer[0], buffer[1]);
|
||||
text.append ("\nTotal length : " + HexFormatter.format4 (totalLength));
|
||||
|
||||
int varLength = HexFormatter.intValue (buffer[2], buffer[3]);
|
||||
int varLength = Utility.intValue (buffer[2], buffer[3]);
|
||||
text.append ("\nVar length : " + HexFormatter.format4 (varLength));
|
||||
text.append ("\n\n");
|
||||
|
||||
|
@ -50,7 +51,7 @@ public class StoredVariables extends AbstractFile
|
|||
}
|
||||
else if (suffix == '%')
|
||||
{
|
||||
intValue = HexFormatter.intValue (buffer[ptr + 3], buffer[ptr + 2]);
|
||||
intValue = Utility.intValue (buffer[ptr + 3], buffer[ptr + 2]);
|
||||
if ((buffer[ptr + 2] & 0x80) > 0)
|
||||
intValue -= 65536;
|
||||
text.append (" = " + intValue);
|
||||
|
@ -132,14 +133,14 @@ 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 offset = Utility.intValue (buffer[ptr + 2], buffer[ptr + 3]);
|
||||
int dimensions = buffer[ptr + 4] & 0xFF;
|
||||
int[] dimensionSizes = new int[dimensions];
|
||||
int totalElements = 0;
|
||||
for (int i = 0; i < dimensions; i++)
|
||||
{
|
||||
int p = i * 2 + 5 + ptr;
|
||||
int elements = HexFormatter.intValue (buffer[p + 1], buffer[p]);
|
||||
int elements = Utility.intValue (buffer[p + 1], buffer[p]);
|
||||
dimensionSizes[dimensions - i - 1] = elements - 1;
|
||||
if (totalElements == 0)
|
||||
totalElements = elements;
|
||||
|
@ -159,7 +160,7 @@ public class StoredVariables extends AbstractFile
|
|||
text.append (variableName + " " + getDimensionText (values) + " = ");
|
||||
if (elementSize == 2)
|
||||
{
|
||||
int intValue = HexFormatter.intValue (buffer[p + 1], buffer[p]);
|
||||
int intValue = Utility.intValue (buffer[p + 1], buffer[p]);
|
||||
if ((buffer[p] & 0x80) > 0)
|
||||
intValue -= 65536;
|
||||
text.append (intValue + "\n");
|
||||
|
@ -211,10 +212,10 @@ public class StoredVariables extends AbstractFile
|
|||
StringBuffer text = new StringBuffer ();
|
||||
|
||||
text.append ("File length : " + HexFormatter.format4 (buffer.length));
|
||||
int totalLength = HexFormatter.intValue (buffer[0], buffer[1]);
|
||||
int totalLength = Utility.intValue (buffer[0], buffer[1]);
|
||||
text.append ("\nTotal length : " + HexFormatter.format4 (totalLength));
|
||||
|
||||
int varLength = HexFormatter.intValue (buffer[2], buffer[3]);
|
||||
int varLength = Utility.intValue (buffer[2], buffer[3]);
|
||||
text.append ("\nVar length : " + HexFormatter.format4 (varLength));
|
||||
|
||||
int unknown = buffer[4] & 0xFF;
|
||||
|
@ -231,14 +232,14 @@ public class StoredVariables extends AbstractFile
|
|||
text.append ("\nArrays : \n\n");
|
||||
while (ptr < totalLength + 5)
|
||||
{
|
||||
int offset = HexFormatter.intValue (buffer[ptr + 2], buffer[ptr + 3]);
|
||||
int offset = Utility.intValue (buffer[ptr + 2], buffer[ptr + 3]);
|
||||
int dimensions = buffer[ptr + 4] & 0xFF;
|
||||
int[] dimensionSizes = new int[dimensions];
|
||||
int totalElements = 0;
|
||||
for (int i = 0; i < dimensions; i++)
|
||||
{
|
||||
int p = i * 2 + 5 + ptr;
|
||||
int elements = HexFormatter.intValue (buffer[p + 1], buffer[p]);
|
||||
int elements = Utility.intValue (buffer[p + 1], buffer[p]);
|
||||
dimensionSizes[dimensions - i - 1] = elements;
|
||||
if (totalElements == 0)
|
||||
totalElements = elements;
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class AppleworksADBFile extends AbstractFile
|
||||
|
@ -52,7 +52,7 @@ public class AppleworksADBFile extends AbstractFile
|
|||
|
||||
dbMinVersion = buffer[218] & 0xFF;
|
||||
|
||||
headerSize = HexFormatter.unsignedShort (buffer, 0);
|
||||
headerSize = Utility.unsignedShort (buffer, 0);
|
||||
cursorDirectionSRL = buffer[30];
|
||||
cursorDirectionMRL = (char) buffer[31];
|
||||
currentDisplay = (char) buffer[34];
|
||||
|
@ -60,7 +60,7 @@ public class AppleworksADBFile extends AbstractFile
|
|||
categoryNames = new String[categories];
|
||||
|
||||
totalReports = buffer[38] & 0xFF;
|
||||
int recs = HexFormatter.unsignedShort (buffer, 36);
|
||||
int recs = Utility.unsignedShort (buffer, 36);
|
||||
totalRecords = dbMinVersion == 0 ? recs : recs & 0x7FFF;
|
||||
|
||||
for (int i = 0; i < 30; i++)
|
||||
|
@ -79,9 +79,9 @@ public class AppleworksADBFile extends AbstractFile
|
|||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
selectionRules[i] = HexFormatter.unsignedShort (buffer, 223 + i * 2);
|
||||
testTypes[i] = HexFormatter.unsignedShort (buffer, 229 + i * 2);
|
||||
continuation[i] = HexFormatter.unsignedShort (buffer, 235 + i * 2);
|
||||
selectionRules[i] = Utility.unsignedShort (buffer, 223 + i * 2);
|
||||
testTypes[i] = Utility.unsignedShort (buffer, 229 + i * 2);
|
||||
continuation[i] = Utility.unsignedShort (buffer, 235 + i * 2);
|
||||
comparison[i] = new String (buffer, 241 + i * 20, 20);
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ public class AppleworksADBFile extends AbstractFile
|
|||
ptr += 600;
|
||||
}
|
||||
|
||||
int length = HexFormatter.unsignedShort (buffer, ptr);
|
||||
int length = Utility.unsignedShort (buffer, ptr);
|
||||
ptr += 2;
|
||||
|
||||
if (length == 0)
|
||||
|
@ -118,7 +118,7 @@ public class AppleworksADBFile extends AbstractFile
|
|||
|
||||
for (int recordNo = 0; recordNo < totalRecords; recordNo++)
|
||||
{
|
||||
length = HexFormatter.unsignedShort (buffer, ptr);
|
||||
length = Utility.unsignedShort (buffer, ptr);
|
||||
ptr += 2;
|
||||
if (length == 0)
|
||||
break;
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class AppleworksSSFile extends AbstractFile
|
||||
|
@ -24,7 +25,7 @@ public class AppleworksSSFile extends AbstractFile
|
|||
int ptr = header.ssMinVers == 0 ? 300 : 302;
|
||||
while (ptr < buffer.length)
|
||||
{
|
||||
int length = HexFormatter.unsignedShort (buffer, ptr);
|
||||
int length = Utility.unsignedShort (buffer, ptr);
|
||||
|
||||
if (length == 0xFFFF)
|
||||
break;
|
||||
|
@ -102,7 +103,7 @@ public class AppleworksSSFile extends AbstractFile
|
|||
|
||||
calcOrder = (char) buffer[131];
|
||||
calcFrequency = (char) buffer[132];
|
||||
lastRow = HexFormatter.unsignedShort (buffer, 133);
|
||||
lastRow = Utility.unsignedShort (buffer, 133);
|
||||
lastColumn = buffer[135] & 0xFF;
|
||||
windowLayout = (char) buffer[136];
|
||||
windowSynch = buffer[137] != 0;
|
||||
|
@ -203,15 +204,15 @@ public class AppleworksSSFile extends AbstractFile
|
|||
|
||||
r1 = buffer[offset + 3] & 0xFF;
|
||||
c1 = buffer[offset + 4] & 0xFF;
|
||||
r2 = HexFormatter.unsignedShort (buffer, offset + 5);
|
||||
r2 = Utility.unsignedShort (buffer, offset + 5);
|
||||
c2 = buffer[offset + 7] & 0xFF;
|
||||
r3 = HexFormatter.unsignedShort (buffer, offset + 8);
|
||||
r3 = Utility.unsignedShort (buffer, offset + 8);
|
||||
c3 = buffer[offset + 10] & 0xFF;
|
||||
r4 = HexFormatter.unsignedShort (buffer, offset + 11);
|
||||
r4 = Utility.unsignedShort (buffer, offset + 11);
|
||||
c4 = buffer[offset + 13] & 0xFF;
|
||||
r5 = buffer[offset + 14] & 0xFF;
|
||||
c5 = buffer[offset + 15] & 0xFF;
|
||||
r6 = HexFormatter.unsignedShort (buffer, offset + 16);
|
||||
r6 = Utility.unsignedShort (buffer, offset + 16);
|
||||
c6 = buffer[offset + 18] & 0xFF;
|
||||
r7 = buffer[offset + 19] & 0xFF;
|
||||
c7 = buffer[offset + 20] & 0xFF;
|
||||
|
@ -264,7 +265,7 @@ public class AppleworksSSFile extends AbstractFile
|
|||
|
||||
public Row (int ptr)
|
||||
{
|
||||
rowNumber = HexFormatter.unsignedShort (buffer, ptr);
|
||||
rowNumber = Utility.unsignedShort (buffer, ptr);
|
||||
ptr += 2; // first control byte
|
||||
|
||||
int column = 0;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.bytezone.diskbrowser.appleworks;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class CellAddress
|
||||
|
@ -14,7 +14,7 @@ class CellAddress
|
|||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
colRef = buffer[offset];
|
||||
rowRef = HexFormatter.intValue (buffer[offset + 1], buffer[offset + 2]);
|
||||
rowRef = Utility.intValue (buffer[offset + 1], buffer[offset + 2]);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.bytezone.diskbrowser.appleworks;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class CellFormula
|
||||
|
@ -33,7 +33,7 @@ class CellFormula
|
|||
}
|
||||
else if (value == 0xFD)
|
||||
{
|
||||
double d = HexFormatter.getSANEDouble (buffer, offset + i + 1);
|
||||
double d = Utility.getSANEDouble (buffer, offset + i + 1);
|
||||
String num = String.format ("%f", d).trim ();
|
||||
while (num.endsWith ("0"))
|
||||
num = num.substring (0, num.length () - 1);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.bytezone.diskbrowser.appleworks;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class CellValue extends Cell
|
||||
|
@ -31,7 +31,7 @@ class CellValue extends Cell
|
|||
int b1 = buffer[offset + 1] & 0xFF;
|
||||
lastEvalNA = (b1 & 0x40) != 0;
|
||||
lastEvalError = (b1 & 0x20) != 0;
|
||||
saneDouble = HexFormatter.getSANEDouble (buffer, offset + 2);
|
||||
saneDouble = Utility.getSANEDouble (buffer, offset + 2);
|
||||
value = String.format (format.mask (), saneDouble).trim ();
|
||||
formula = new CellFormula (this, buffer, offset + 10, length - 10);
|
||||
value = String.format ("%-15s %s", value, formula.value);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.bytezone.diskbrowser.appleworks;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
abstract class Report
|
||||
|
@ -130,11 +131,9 @@ abstract class Report
|
|||
if (buffer[offset + 480 + fudge] == 0) // test high byte
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
selectionRules[i] =
|
||||
HexFormatter.unsignedShort (buffer, offset + 479 + i * 2 + fudge);
|
||||
testTypes[i] = HexFormatter.unsignedShort (buffer, offset + 485 + i * 2 + fudge);
|
||||
continuation[i] =
|
||||
HexFormatter.unsignedShort (buffer, offset + 491 + i * 2 + fudge);
|
||||
selectionRules[i] = Utility.unsignedShort (buffer, offset + 479 + i * 2 + fudge);
|
||||
testTypes[i] = Utility.unsignedShort (buffer, offset + 485 + i * 2 + fudge);
|
||||
continuation[i] = Utility.unsignedShort (buffer, offset + 491 + i * 2 + fudge);
|
||||
comparison[i] = pascalString (buffer, offset + 497 + i * 32 + fudge);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.bytezone.diskbrowser.disk;
|
||||
|
||||
import com.bytezone.common.Utility;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// http://apple2.org.za/gswv/a2zine/Docs/DiskImage_2MG_Info.txt
|
||||
// -----------------------------------------------------------------------------------//
|
||||
|
@ -27,7 +26,7 @@ public class Prefix2mg
|
|||
format = buffer[12];
|
||||
|
||||
diskData = Utility.getLong (buffer, 28);
|
||||
blocks = HexFormatter.intValue (buffer[20], buffer[21]); // 1600
|
||||
blocks = Utility.intValue (buffer[20], buffer[21]); // 1600
|
||||
|
||||
// see /Asimov disks/images/gs/os/prodos16/ProDOS 16v1_3.2mg
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import com.bytezone.diskbrowser.disk.DiskAddress;
|
|||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
import com.bytezone.diskbrowser.dos.DosDisk.FileType;
|
||||
import com.bytezone.diskbrowser.gui.DataSource;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
|
@ -58,7 +57,7 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
this.catalogSectorDA = catalogSector;
|
||||
|
||||
name = getName ("", entryBuffer);
|
||||
reportedSize = HexFormatter.unsignedShort (entryBuffer, 33);
|
||||
reportedSize = Utility.unsignedShort (entryBuffer, 33);
|
||||
// if (reportedSize == 0)
|
||||
// System.out.printf ("%s size 0%n", name);
|
||||
|
||||
|
@ -195,14 +194,14 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
break;
|
||||
|
||||
case IntegerBasic:
|
||||
reportedLength = HexFormatter.unsignedShort (buffer, 0);
|
||||
reportedLength = Utility.unsignedShort (buffer, 0);
|
||||
exactBuffer = new byte[reportedLength];
|
||||
System.arraycopy (buffer, 2, exactBuffer, 0, reportedLength);
|
||||
appleFile = new IntegerBasicProgram (name, exactBuffer);
|
||||
break;
|
||||
|
||||
case ApplesoftBasic:
|
||||
reportedLength = HexFormatter.unsignedShort (buffer, 0);
|
||||
reportedLength = Utility.unsignedShort (buffer, 0);
|
||||
exactBuffer = new byte[reportedLength];
|
||||
if (reportedLength > buffer.length)
|
||||
reportedLength = buffer.length - 2;
|
||||
|
@ -212,8 +211,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
|
||||
case Binary: // binary file
|
||||
case Relocatable: // relocatable binary file
|
||||
int loadAddress = HexFormatter.unsignedShort (buffer, 0);
|
||||
reportedLength = HexFormatter.unsignedShort (buffer, 2);
|
||||
int loadAddress = Utility.unsignedShort (buffer, 0);
|
||||
reportedLength = Utility.unsignedShort (buffer, 2);
|
||||
if (reportedLength == 0)
|
||||
{
|
||||
System.out.println (name.trim () + " reported length : 0 - reverting to "
|
||||
|
@ -293,8 +292,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
break;
|
||||
|
||||
case BB: // Lisa
|
||||
loadAddress = HexFormatter.intValue (buffer[0], buffer[1]);
|
||||
reportedLength = HexFormatter.intValue (buffer[2], buffer[3]);
|
||||
loadAddress = Utility.intValue (buffer[0], buffer[1]);
|
||||
reportedLength = Utility.intValue (buffer[2], buffer[3]);
|
||||
exactBuffer = new byte[reportedLength];
|
||||
System.arraycopy (buffer, 4, exactBuffer, 0, reportedLength);
|
||||
appleFile = new SimpleText2 (name, exactBuffer, loadAddress);
|
||||
|
@ -320,7 +319,7 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
{
|
||||
byte[] exactBuffer;
|
||||
|
||||
int reportedLength = HexFormatter.unsignedShort (buffer, 2);
|
||||
int reportedLength = Utility.unsignedShort (buffer, 2);
|
||||
if (reportedLength == 0)
|
||||
{
|
||||
System.out.println (
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.bytezone.diskbrowser.dos;
|
|||
import com.bytezone.diskbrowser.disk.AppleDiskAddress;
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.dos.DosDisk.FileType;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class CatalogEntry extends AbstractCatalogEntry
|
||||
|
@ -131,12 +131,12 @@ class CatalogEntry extends AbstractCatalogEntry
|
|||
{
|
||||
case IntegerBasic:
|
||||
case ApplesoftBasic:
|
||||
length = HexFormatter.intValue (buffer[0], buffer[1]);
|
||||
length = Utility.intValue (buffer[0], buffer[1]);
|
||||
break;
|
||||
|
||||
default:
|
||||
address = HexFormatter.intValue (buffer[0], buffer[1]);
|
||||
length = HexFormatter.intValue (buffer[2], buffer[3]);
|
||||
address = Utility.intValue (buffer[0], buffer[1]);
|
||||
length = Utility.intValue (buffer[2], buffer[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.bytezone.diskbrowser.dos;
|
|||
import com.bytezone.diskbrowser.disk.AbstractSector;
|
||||
import com.bytezone.diskbrowser.disk.Disk;
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class DosTSListSector extends AbstractSector
|
||||
|
@ -82,7 +82,7 @@ class DosTSListSector extends AbstractSector
|
|||
addText (text, buffer, 7, 4, "Not used");
|
||||
addText (text, buffer, 11, 1, "Not used");
|
||||
|
||||
int sectorBase = HexFormatter.intValue (buffer[5], buffer[6]);
|
||||
int sectorBase = Utility.intValue (buffer[5], buffer[6]);
|
||||
|
||||
for (int i = 12; i <= 255; i += 2)
|
||||
{
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.bytezone.diskbrowser.dos;
|
|||
import com.bytezone.diskbrowser.disk.AbstractSector;
|
||||
import com.bytezone.diskbrowser.disk.Disk;
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
|
@ -36,7 +35,7 @@ class DosVTOCSector extends AbstractSector
|
|||
direction = buffer[49];
|
||||
maxTracks = buffer[52] & 0xFF;
|
||||
maxSectors = buffer[53] & 0xFF;
|
||||
sectorSize = HexFormatter.intValue (buffer[54], buffer[55]);
|
||||
sectorSize = Utility.intValue (buffer[54], buffer[55]);
|
||||
|
||||
flagSectors ();
|
||||
}
|
||||
|
@ -168,7 +167,7 @@ class DosVTOCSector extends AbstractSector
|
|||
private String getBitmap (byte[] buffer, int offset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int value = HexFormatter.getLongBigEndian (buffer, offset);
|
||||
int value = Utility.getLongBigEndian (buffer, offset);
|
||||
|
||||
String bits = "0000000000000000000000000000000" + Integer.toBinaryString (value);
|
||||
bits = bits.substring (bits.length () - 32);
|
||||
|
|
|
@ -18,7 +18,7 @@ import com.bytezone.diskbrowser.disk.Disk;
|
|||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.disk.SectorType;
|
||||
import com.bytezone.diskbrowser.gui.DataSource;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// https://mud.co.uk/richard/htflpism.htm
|
||||
// https://inform-fiction.org/zmachine/standards/
|
||||
|
@ -250,14 +250,14 @@ public class InfocomDisk extends AbstractFormattedDisk
|
|||
byte[] buffer = disk.readBlock (3, 0);
|
||||
|
||||
int version = buffer[0] & 0xFF;
|
||||
int highMemory = HexFormatter.intValue (buffer[5], buffer[4]);
|
||||
int programCounter = HexFormatter.intValue (buffer[7], buffer[6]);
|
||||
int dictionary = HexFormatter.intValue (buffer[9], buffer[8]);
|
||||
int objectTable = HexFormatter.intValue (buffer[11], buffer[10]);
|
||||
int globals = HexFormatter.intValue (buffer[13], buffer[12]);
|
||||
int staticMemory = HexFormatter.intValue (buffer[15], buffer[14]);
|
||||
int abbreviationsTable = HexFormatter.intValue (buffer[25], buffer[24]);
|
||||
int fileLength = HexFormatter.intValue (buffer[27], buffer[26]);
|
||||
int highMemory = Utility.intValue (buffer[5], buffer[4]);
|
||||
int programCounter = Utility.intValue (buffer[7], buffer[6]);
|
||||
int dictionary = Utility.intValue (buffer[9], buffer[8]);
|
||||
int objectTable = Utility.intValue (buffer[11], buffer[10]);
|
||||
int globals = Utility.intValue (buffer[13], buffer[12]);
|
||||
int staticMemory = Utility.intValue (buffer[15], buffer[14]);
|
||||
int abbreviationsTable = Utility.intValue (buffer[25], buffer[24]);
|
||||
int fileLength = Utility.intValue (buffer[27], buffer[26]);
|
||||
|
||||
if (false)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.io.FileInputStream;
|
|||
import java.io.IOException;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
/*
|
||||
* from Gerard Putter's email:
|
||||
|
@ -60,9 +61,9 @@ public class V2dFile
|
|||
BufferedInputStream in = new BufferedInputStream (new FileInputStream (file));
|
||||
in.read (header);
|
||||
|
||||
int diskLength = HexFormatter.getLongBigEndian (header, 0); // 4 bytes
|
||||
String id = HexFormatter.getString (header, 4, 4); // 4 bytes
|
||||
tracks = HexFormatter.getShortBigEndian (header, 8); // 2 bytes
|
||||
int diskLength = Utility.getLongBigEndian (header, 0); // 4 bytes
|
||||
String id = HexFormatter.getString (header, 4, 4); // 4 bytes
|
||||
tracks = Utility.getShortBigEndian (header, 8); // 2 bytes
|
||||
|
||||
assert diskLength + 8 == file.length ();
|
||||
assert "D5NI".equals (id);
|
||||
|
@ -73,8 +74,8 @@ public class V2dFile
|
|||
for (int i = 0; i < tracks; i++)
|
||||
{
|
||||
in.read (trackHeader);
|
||||
int trackNumber = HexFormatter.getShortBigEndian (trackHeader, 0);
|
||||
int trackLength = HexFormatter.getShortBigEndian (trackHeader, 2); // 6304
|
||||
int trackNumber = Utility.getShortBigEndian (trackHeader, 0);
|
||||
int trackLength = Utility.getShortBigEndian (trackHeader, 2); // 6304
|
||||
|
||||
assert trackLength == TRACK_LENGTH;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.bytezone.diskbrowser.disk.Disk;
|
|||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
abstract class CatalogEntry implements AppleFileSource
|
||||
|
@ -31,11 +32,11 @@ abstract class CatalogEntry implements AppleFileSource
|
|||
{
|
||||
this.parent = parent;
|
||||
|
||||
firstBlock = HexFormatter.intValue (buffer[0], buffer[1]);
|
||||
lastBlock = HexFormatter.intValue (buffer[2], buffer[3]);
|
||||
firstBlock = Utility.intValue (buffer[0], buffer[1]);
|
||||
lastBlock = Utility.intValue (buffer[2], buffer[3]);
|
||||
fileType = buffer[4] & 0xFF;
|
||||
name = HexFormatter.getPascalString (buffer, 6);
|
||||
bytesUsedInLastBlock = HexFormatter.intValue (buffer[16], buffer[17]);
|
||||
bytesUsedInLastBlock = Utility.intValue (buffer[16], buffer[17]);
|
||||
|
||||
Disk disk = parent.getDisk ();
|
||||
int max = Math.min (lastBlock, disk.getTotalBlocks ());
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.bytezone.diskbrowser.applefile.PascalSegment;
|
|||
import com.bytezone.diskbrowser.applefile.PascalText;
|
||||
import com.bytezone.diskbrowser.utilities.FileFormatException;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class FileEntry extends CatalogEntry
|
||||
|
@ -25,7 +26,7 @@ public class FileEntry extends CatalogEntry
|
|||
{
|
||||
super (parent, buffer);
|
||||
|
||||
bytesUsedInLastBlock = HexFormatter.intValue (buffer[22], buffer[23]);
|
||||
bytesUsedInLastBlock = Utility.intValue (buffer[22], buffer[23]);
|
||||
date = HexFormatter.getPascalDate (buffer, 24);
|
||||
|
||||
int max = Math.min (lastBlock, parent.getDisk ().getTotalBlocks ());
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.bytezone.diskbrowser.disk.AbstractSector;
|
|||
import com.bytezone.diskbrowser.disk.Disk;
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class PascalCatalogSector extends AbstractSector
|
||||
|
@ -49,7 +50,7 @@ class PascalCatalogSector extends AbstractSector
|
|||
addTextAndDecimal (text, buffer, 22, 4, "Reserved");
|
||||
|
||||
int ptr = PascalDisk.CATALOG_ENTRY_SIZE;
|
||||
int totalFiles = HexFormatter.intValue (buffer[16], buffer[17]);
|
||||
int totalFiles = Utility.intValue (buffer[16], buffer[17]);
|
||||
|
||||
while (ptr < buffer.length && totalFiles > 0)
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.bytezone.diskbrowser.disk.DiskAddress;
|
|||
import com.bytezone.diskbrowser.disk.SectorType;
|
||||
import com.bytezone.diskbrowser.gui.DataSource;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
import com.bytezone.diskbrowser.wizardry.Relocator;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
|
@ -167,8 +168,8 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
System.out.println ("Name ok : " + name);
|
||||
}
|
||||
|
||||
int from = HexFormatter.intValue (buffer[0], buffer[1]);
|
||||
int to = HexFormatter.intValue (buffer[2], buffer[3]);
|
||||
int from = Utility.intValue (buffer[0], buffer[1]);
|
||||
int to = Utility.intValue (buffer[2], buffer[3]);
|
||||
if (from != 0 || to != 6)
|
||||
{
|
||||
if (debug)
|
||||
|
@ -176,7 +177,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
return false; // will only work for floppies!
|
||||
}
|
||||
|
||||
int blocks = HexFormatter.intValue (buffer[14], buffer[15]);
|
||||
int blocks = Utility.intValue (buffer[14], buffer[15]);
|
||||
if (blocks > 280)
|
||||
{
|
||||
if (debug)
|
||||
|
@ -189,7 +190,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
addresses.add (disk.getDiskAddress (i));
|
||||
buffer = disk.readBlocks (addresses);
|
||||
|
||||
int files = HexFormatter.intValue (buffer[16], buffer[17]);
|
||||
int files = Utility.intValue (buffer[16], buffer[17]);
|
||||
if (files < 0 || files > 77)
|
||||
{
|
||||
if (debug)
|
||||
|
@ -203,9 +204,9 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
for (int i = 1; i <= files; i++)
|
||||
{
|
||||
int ptr = i * 26;
|
||||
int firstBlock = HexFormatter.intValue (buffer[ptr], buffer[ptr + 1]);
|
||||
int lastBlock = HexFormatter.intValue (buffer[ptr + 2], buffer[ptr + 3]);
|
||||
int kind = HexFormatter.intValue (buffer[ptr + 4], buffer[ptr + 5]);
|
||||
int firstBlock = Utility.intValue (buffer[ptr], buffer[ptr + 1]);
|
||||
int lastBlock = Utility.intValue (buffer[ptr + 2], buffer[ptr + 3]);
|
||||
int kind = Utility.intValue (buffer[ptr + 4], buffer[ptr + 5]);
|
||||
if (lastBlock < firstBlock)
|
||||
return false;
|
||||
if (kind == 0)
|
||||
|
@ -213,7 +214,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
nameLength = buffer[ptr + 6] & 0xFF;
|
||||
if (nameLength < 1 || nameLength > 15)
|
||||
return false;
|
||||
int lastByte = HexFormatter.intValue (buffer[ptr + 22], buffer[ptr + 23]);
|
||||
int lastByte = Utility.intValue (buffer[ptr + 22], buffer[ptr + 23]);
|
||||
GregorianCalendar date = HexFormatter.getPascalDate (buffer, 24);
|
||||
if (debug)
|
||||
System.out.printf ("%4d %4d %d %-15s %d %s%n", firstBlock, lastBlock, kind,
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.bytezone.diskbrowser.pascal;
|
|||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.applefile.DefaultAppleFile;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class VolumeEntry extends CatalogEntry
|
||||
|
@ -17,8 +18,8 @@ class VolumeEntry extends CatalogEntry
|
|||
{
|
||||
super (parent, buffer);
|
||||
|
||||
totalBlocks = HexFormatter.intValue (buffer[14], buffer[15]); // 280
|
||||
totalFiles = HexFormatter.intValue (buffer[16], buffer[17]);
|
||||
totalBlocks = Utility.intValue (buffer[14], buffer[15]); // 280
|
||||
totalFiles = Utility.intValue (buffer[16], buffer[17]);
|
||||
date = HexFormatter.getPascalDate (buffer, 20); // 2 bytes
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.bytezone.diskbrowser.prodos;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
abstract class DirectoryHeader extends CatalogEntry
|
||||
|
@ -18,6 +18,6 @@ abstract class DirectoryHeader extends CatalogEntry
|
|||
|
||||
entryLength = entryBuffer[31] & 0xFF;
|
||||
entriesPerBlock = entryBuffer[32] & 0xFF;
|
||||
fileCount = HexFormatter.intValue (entryBuffer[33], entryBuffer[34]);
|
||||
fileCount = Utility.intValue (entryBuffer[33], entryBuffer[34]);
|
||||
}
|
||||
}
|
|
@ -40,6 +40,7 @@ import com.bytezone.diskbrowser.appleworks.AppleworksWPFile;
|
|||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.gui.DataSource;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// - Set sector types for each used sector
|
||||
// - Populate dataBlocks, indexBlocks, catalogBlock and masterIndexBlock
|
||||
|
@ -77,13 +78,13 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
this.catalogBlock = this.disk.getDiskAddress (parentBlock);
|
||||
|
||||
fileType = entryBuffer[0x10] & 0xFF;
|
||||
keyPtr = HexFormatter.unsignedShort (entryBuffer, 0x11);
|
||||
blocksUsed = HexFormatter.unsignedShort (entryBuffer, 0x13);
|
||||
endOfFile = HexFormatter.intValue (entryBuffer[21], entryBuffer[22], entryBuffer[23]);
|
||||
keyPtr = Utility.unsignedShort (entryBuffer, 0x11);
|
||||
blocksUsed = Utility.unsignedShort (entryBuffer, 0x13);
|
||||
endOfFile = Utility.intValue (entryBuffer[21], entryBuffer[22], entryBuffer[23]);
|
||||
|
||||
auxType = HexFormatter.unsignedShort (entryBuffer, 0x1F);
|
||||
auxType = Utility.unsignedShort (entryBuffer, 0x1F);
|
||||
modified = HexFormatter.getAppleDate (entryBuffer, 0x21);
|
||||
headerPointer = HexFormatter.unsignedShort (entryBuffer, 0x25);
|
||||
headerPointer = Utility.unsignedShort (entryBuffer, 0x25);
|
||||
|
||||
switch (storageType)
|
||||
{
|
||||
|
@ -106,7 +107,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
break;
|
||||
dataBlocks.add (diskAddress);
|
||||
byte[] buffer = disk.readBlock (block);
|
||||
block = HexFormatter.unsignedShort (buffer, 2);
|
||||
block = Utility.unsignedShort (buffer, 2);
|
||||
} while (block > 0);
|
||||
break;
|
||||
|
||||
|
@ -137,8 +138,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
for (int i = 0; i < 512; i += 256)
|
||||
{
|
||||
int storageType = buffer2[i] & 0x0F;
|
||||
int keyBlock = HexFormatter.unsignedShort (buffer2, i + 1);
|
||||
int eof = HexFormatter.intValue (buffer2[i + 3], buffer2[i + 4], buffer2[i + 5]);
|
||||
int keyBlock = Utility.unsignedShort (buffer2, i + 1);
|
||||
int eof = Utility.intValue (buffer2[i + 3], buffer2[i + 4], buffer2[i + 5]);
|
||||
addDataBlocks (storageType, keyBlock);
|
||||
}
|
||||
}
|
||||
|
@ -582,8 +583,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
byte[] mainIndexBuffer = disk.readBlock (keyPtr);
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
int indexBlock =
|
||||
HexFormatter.intValue (mainIndexBuffer[i], mainIndexBuffer[i + 256]);
|
||||
int indexBlock = Utility.intValue (mainIndexBuffer[i], mainIndexBuffer[i + 256]);
|
||||
if (indexBlock > 0)
|
||||
logicalBlock = readIndexBlock (indexBlock, addresses, buffers, logicalBlock);
|
||||
else
|
||||
|
@ -699,7 +699,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
byte[] indexBuffer = disk.readBlock (indexBlock);
|
||||
for (int j = 0; j < 256; j++)
|
||||
{
|
||||
int block = HexFormatter.intValue (indexBuffer[j], indexBuffer[j + 256]);
|
||||
int block = Utility.intValue (indexBuffer[j], indexBuffer[j + 256]);
|
||||
if (block > 0)
|
||||
addresses.add (disk.getDiskAddress (block));
|
||||
else if (addresses.size () > 0)
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.bytezone.diskbrowser.disk.AbstractSector;
|
|||
import com.bytezone.diskbrowser.disk.Disk;
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class ProdosCatalogSector extends AbstractSector
|
||||
|
@ -98,7 +99,7 @@ class ProdosCatalogSector extends AbstractSector
|
|||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
int fileType = buffer[offset + 16] & 0xFF;
|
||||
int auxType = HexFormatter.unsignedShort (buffer, offset + 31);
|
||||
int auxType = Utility.unsignedShort (buffer, offset + 31);
|
||||
addText (text, buffer, offset + 16, 1,
|
||||
"File type (" + ProdosConstants.fileTypes[fileType] + ")");
|
||||
addTextAndDecimal (text, buffer, offset + 17, 2, "Key pointer");
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.GregorianCalendar;
|
|||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class ProdosDirectory extends AbstractFile implements ProdosConstants
|
||||
|
@ -70,7 +71,7 @@ class ProdosDirectory extends AbstractFile implements ProdosConstants
|
|||
case ProdosConstants.GSOS_EXTENDED_FILE:
|
||||
case ProdosConstants.SUBDIRECTORY:
|
||||
int type = buffer[i + 16] & 0xFF;
|
||||
int blocks = HexFormatter.intValue (buffer[i + 19], buffer[i + 20]);
|
||||
int blocks = Utility.intValue (buffer[i + 19], buffer[i + 20]);
|
||||
|
||||
GregorianCalendar created = HexFormatter.getAppleDate (buffer, i + 24);
|
||||
String dateC = created == null ? NO_DATE
|
||||
|
@ -80,15 +81,14 @@ class ProdosDirectory extends AbstractFile implements ProdosConstants
|
|||
String dateM = modified == null ? NO_DATE
|
||||
: sdf.format (modified.getTime ()).toUpperCase ().replace (".", "");
|
||||
String timeM = modified == null ? "" : stf.format (modified.getTime ());
|
||||
int eof =
|
||||
HexFormatter.intValue (buffer[i + 21], buffer[i + 22], buffer[i + 23]);
|
||||
int eof = Utility.intValue (buffer[i + 21], buffer[i + 22], buffer[i + 23]);
|
||||
int fileType = buffer[i + 16] & 0xFF;
|
||||
locked = (buffer[i + 30] & 0xE0) == 0xE0 ? " " : "*";
|
||||
|
||||
switch (fileType)
|
||||
{
|
||||
case FILE_TYPE_TEXT:
|
||||
int aux = HexFormatter.intValue (buffer[i + 31], buffer[i + 32]);
|
||||
int aux = Utility.intValue (buffer[i + 31], buffer[i + 32]);
|
||||
subType = String.format ("R=%5d", aux);
|
||||
break;
|
||||
|
||||
|
@ -96,12 +96,12 @@ class ProdosDirectory extends AbstractFile implements ProdosConstants
|
|||
case FILE_TYPE_PNT:
|
||||
case FILE_TYPE_PIC:
|
||||
case FILE_TYPE_FOT:
|
||||
aux = HexFormatter.intValue (buffer[i + 31], buffer[i + 32]);
|
||||
aux = Utility.intValue (buffer[i + 31], buffer[i + 32]);
|
||||
subType = String.format ("A=$%4X", aux);
|
||||
break;
|
||||
|
||||
case FILE_TYPE_AWP:
|
||||
aux = HexFormatter.intValue (buffer[i + 32], buffer[i + 31]); // backwards!
|
||||
aux = Utility.intValue (buffer[i + 32], buffer[i + 31]); // backwards!
|
||||
if (aux != 0)
|
||||
filename = convert (filename, aux);
|
||||
break;
|
||||
|
|
|
@ -22,6 +22,7 @@ import com.bytezone.diskbrowser.disk.SectorType;
|
|||
import com.bytezone.diskbrowser.gui.DataSource;
|
||||
import com.bytezone.diskbrowser.gui.ProdosPreferences;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class ProdosDisk extends AbstractFormattedDisk
|
||||
|
@ -177,7 +178,7 @@ public class ProdosDisk extends AbstractFormattedDisk
|
|||
System.out.println (HexFormatter.format (entry, 0, entry.length));
|
||||
}
|
||||
}
|
||||
block = HexFormatter.intValue (sectorBuffer[2], sectorBuffer[3]);
|
||||
block = Utility.intValue (sectorBuffer[2], sectorBuffer[3]);
|
||||
} while (block > 0);
|
||||
|
||||
// link double hi-res files
|
||||
|
@ -234,7 +235,7 @@ public class ProdosDisk extends AbstractFormattedDisk
|
|||
if (buffer[0x23] != 0x27 || buffer[0x24] != 0x0D)
|
||||
return false;
|
||||
|
||||
int bitMapBlock = HexFormatter.intValue (buffer[0x27], buffer[0x28]);
|
||||
int bitMapBlock = Utility.intValue (buffer[0x27], buffer[0x28]);
|
||||
if (bitMapBlock < 3 || bitMapBlock > 10)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.bytezone.diskbrowser.prodos;
|
|||
import com.bytezone.diskbrowser.disk.AbstractSector;
|
||||
import com.bytezone.diskbrowser.disk.Disk;
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class ProdosIndexSector extends AbstractSector
|
||||
|
@ -32,7 +32,7 @@ class ProdosIndexSector extends AbstractSector
|
|||
String.format ("%02X %02X %02X", i, buffer[i], buffer[i + 256]));
|
||||
if (buffer[i] != 0 || buffer[i + 256] != 0)
|
||||
{
|
||||
int blockNo = HexFormatter.intValue (buffer[i], buffer[i + 256]);
|
||||
int blockNo = Utility.intValue (buffer[i], buffer[i + 256]);
|
||||
String valid = disk.isValidAddress (blockNo) ? "" : " *** invalid ***";
|
||||
text.append (String.format (" %s%s%n", "block " + blockNo, valid));
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.List;
|
|||
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.gui.DataSource;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class SubDirectoryHeader extends DirectoryHeader
|
||||
|
@ -21,7 +21,7 @@ class SubDirectoryHeader extends DirectoryHeader
|
|||
super (parentDisk, entryBuffer);
|
||||
this.parentDirectory = parent.parentDirectory;
|
||||
|
||||
parentPointer = HexFormatter.intValue (entryBuffer[35], entryBuffer[36]);
|
||||
parentPointer = Utility.intValue (entryBuffer[35], entryBuffer[36]);
|
||||
parentSequence = entryBuffer[37] & 0xFF;
|
||||
parentSize = entryBuffer[38] & 0xFF;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.List;
|
|||
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.gui.DataSource;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
/*
|
||||
* There is only one of these - it is always the first entry in the first block.
|
||||
|
@ -27,8 +27,8 @@ class VolumeDirectoryHeader extends DirectoryHeader
|
|||
{
|
||||
super (parentDisk, entryBuffer);
|
||||
|
||||
bitMapBlock = HexFormatter.unsignedShort (entryBuffer, 35);
|
||||
totalBlocks = HexFormatter.unsignedShort (entryBuffer, 37);
|
||||
bitMapBlock = Utility.unsignedShort (entryBuffer, 35);
|
||||
totalBlocks = Utility.unsignedShort (entryBuffer, 37);
|
||||
|
||||
// if (totalBlocks == 0xFFFF || totalBlocks == 0x7FFF)
|
||||
// totalBlocks = (int) disk.getFile ().length () / 4096 * 8;// ignore extra bytes
|
||||
|
@ -40,7 +40,7 @@ class VolumeDirectoryHeader extends DirectoryHeader
|
|||
{
|
||||
dataBlocks.add (disk.getDiskAddress (block));
|
||||
byte[] buffer = disk.readBlock (block);
|
||||
block = HexFormatter.unsignedShort (buffer, 2);
|
||||
block = Utility.unsignedShort (buffer, 2);
|
||||
} while (block > 0);
|
||||
|
||||
// convert the Free Sector Table
|
||||
|
@ -103,7 +103,7 @@ class VolumeDirectoryHeader extends DirectoryHeader
|
|||
{
|
||||
byte[] buf = disk.readBlock (block);
|
||||
blockList.add (buf);
|
||||
block = HexFormatter.intValue (buf[2], buf[3]); // next block
|
||||
block = Utility.intValue (buf[2], buf[3]); // next block
|
||||
} while (block > 0);
|
||||
|
||||
byte[] fullBuffer = new byte[blockList.size () * 507];
|
||||
|
|
|
@ -333,97 +333,6 @@ public class HexFormatter
|
|||
return text;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int intValue (byte b1, byte b2)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return (b1 & 0xFF) | ((b2 & 0xFF) << 8);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int intValue (byte b1, byte b2, byte b3)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return (b1 & 0xFF) | ((b2 & 0xFF) << 8) | ((b3 & 0xFF) << 16);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int unsignedLong (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int val = 0;
|
||||
for (int i = 3; i >= 0; i--)
|
||||
{
|
||||
val <<= 8;
|
||||
val += buffer[ptr + i] & 0xFF;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int getLongBigEndian (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int val = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
val <<= 8;
|
||||
val += buffer[ptr + i] & 0xFF;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int unsignedShort (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (ptr >= buffer.length)
|
||||
{
|
||||
System.out.println ("Index out of range (unsigned short): " + ptr);
|
||||
return 0;
|
||||
}
|
||||
return (buffer[ptr] & 0xFF) | ((buffer[ptr + 1] & 0xFF) << 8);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int signedShort (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (ptr >= buffer.length)
|
||||
{
|
||||
System.out.println ("Index out of range (signed short): " + ptr);
|
||||
return 0;
|
||||
}
|
||||
return (short) ((buffer[ptr] & 0xFF) | ((buffer[ptr + 1] & 0xFF) << 8));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int getShortBigEndian (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int val = 0;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
val <<= 8;
|
||||
val |= buffer[ptr + i] & 0xFF;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static double getSANEDouble (byte[] buffer, int offset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
long bits = 0;
|
||||
for (int i = 7; i >= 0; i--)
|
||||
{
|
||||
bits <<= 8;
|
||||
bits |= buffer[offset + i] & 0xFF;
|
||||
}
|
||||
|
||||
return Double.longBitsToDouble (bits);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static double floatValueOld (byte[] buffer, int offset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -477,7 +386,7 @@ public class HexFormatter
|
|||
public static GregorianCalendar getAppleDate (byte[] buffer, int offset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int date = HexFormatter.intValue (buffer[offset], buffer[offset + 1]);
|
||||
int date = Utility.intValue (buffer[offset], buffer[offset + 1]);
|
||||
if (date > 0)
|
||||
{
|
||||
int year = (date & 0xFE00) >> 9;
|
||||
|
|
|
@ -31,14 +31,14 @@ public class Utility
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
static int getLong (byte[] buffer, int ptr)
|
||||
public static int getLong (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return getWord (buffer, ptr) + getWord (buffer, ptr + 2) * 0x10000;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
static int getWord (byte[] buffer, int ptr)
|
||||
public static int getWord (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int a = (buffer[ptr + 1] & 0xFF) << 8;
|
||||
|
@ -46,6 +46,97 @@ public class Utility
|
|||
return a + b;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int intValue (byte b1, byte b2)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return (b1 & 0xFF) | ((b2 & 0xFF) << 8);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int intValue (byte b1, byte b2, byte b3)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return (b1 & 0xFF) | ((b2 & 0xFF) << 8) | ((b3 & 0xFF) << 16);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int unsignedLong (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int val = 0;
|
||||
for (int i = 3; i >= 0; i--)
|
||||
{
|
||||
val <<= 8;
|
||||
val += buffer[ptr + i] & 0xFF;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int getLongBigEndian (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int val = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
val <<= 8;
|
||||
val += buffer[ptr + i] & 0xFF;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int unsignedShort (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (ptr >= buffer.length)
|
||||
{
|
||||
System.out.println ("Index out of range (unsigned short): " + ptr);
|
||||
return 0;
|
||||
}
|
||||
return (buffer[ptr] & 0xFF) | ((buffer[ptr + 1] & 0xFF) << 8);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int signedShort (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (ptr >= buffer.length)
|
||||
{
|
||||
System.out.println ("Index out of range (signed short): " + ptr);
|
||||
return 0;
|
||||
}
|
||||
return (short) ((buffer[ptr] & 0xFF) | ((buffer[ptr + 1] & 0xFF) << 8));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int getShortBigEndian (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int val = 0;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
val <<= 8;
|
||||
val |= buffer[ptr + i] & 0xFF;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static double getSANEDouble (byte[] buffer, int offset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
long bits = 0;
|
||||
for (int i = 7; i >= 0; i--)
|
||||
{
|
||||
bits <<= 8;
|
||||
bits |= buffer[offset + i] & 0xFF;
|
||||
}
|
||||
|
||||
return Double.longBitsToDouble (bits);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int dimension (int chars, int border, int size, int gap)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class Character extends AbstractFile
|
||||
|
@ -39,19 +39,19 @@ class Character extends AbstractFile
|
|||
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.ageInWeeks = Utility.intValue (buffer[38], buffer[39]);
|
||||
stats.statusValue = buffer[40];
|
||||
stats.status = statuses[stats.statusValue];
|
||||
stats.alignment = alignments[buffer[42] & 0xFF];
|
||||
|
||||
stats.gold = HexFormatter.intValue (buffer[52], buffer[53])
|
||||
+ HexFormatter.intValue (buffer[54], buffer[55]) * 10000;
|
||||
stats.experience = HexFormatter.intValue (buffer[124], buffer[125])
|
||||
+ HexFormatter.intValue (buffer[126], buffer[127]) * 10000;
|
||||
stats.level = HexFormatter.intValue (buffer[132], buffer[133]);
|
||||
stats.gold = Utility.intValue (buffer[52], buffer[53])
|
||||
+ Utility.intValue (buffer[54], buffer[55]) * 10000;
|
||||
stats.experience = Utility.intValue (buffer[124], buffer[125])
|
||||
+ Utility.intValue (buffer[126], buffer[127]) * 10000;
|
||||
stats.level = Utility.intValue (buffer[132], buffer[133]);
|
||||
|
||||
stats.hitsLeft = HexFormatter.intValue (buffer[134], buffer[135]);
|
||||
stats.hitsMax = HexFormatter.intValue (buffer[136], buffer[137]);
|
||||
stats.hitsLeft = Utility.intValue (buffer[134], buffer[135]);
|
||||
stats.hitsMax = Utility.intValue (buffer[136], buffer[137]);
|
||||
stats.armourClass = buffer[176];
|
||||
|
||||
attributes.strength = (buffer[44] & 0xFF) % 16;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.bytezone.diskbrowser.wizardry;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class ExperienceLevel extends AbstractFile
|
||||
|
@ -22,9 +22,9 @@ class ExperienceLevel extends AbstractFile
|
|||
if (buffer[ptr] == 0)
|
||||
break;
|
||||
|
||||
long points = HexFormatter.intValue (buffer[ptr], buffer[ptr + 1])
|
||||
+ HexFormatter.intValue (buffer[ptr + 2], buffer[ptr + 3]) * 10000
|
||||
+ HexFormatter.intValue (buffer[ptr + 4], buffer[ptr + 5]) * 100000000L;
|
||||
long points = Utility.intValue (buffer[ptr], buffer[ptr + 1])
|
||||
+ Utility.intValue (buffer[ptr + 2], buffer[ptr + 3]) * 10000
|
||||
+ Utility.intValue (buffer[ptr + 4], buffer[ptr + 5]) * 100000000L;
|
||||
expLevels[seq++] = points;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.bytezone.diskbrowser.disk.DefaultAppleFileSource;
|
|||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class Header
|
||||
|
@ -122,7 +123,7 @@ class Header
|
|||
text.append ("\n");
|
||||
while (ptr < 512)
|
||||
{
|
||||
int value = HexFormatter.intValue (buffer[ptr], buffer[ptr + 1]);
|
||||
int value = Utility.intValue (buffer[ptr], buffer[ptr + 1]);
|
||||
text.append (String.format ("%04X %,6d%n", value, value));
|
||||
ptr += 2;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.bytezone.diskbrowser.wizardry;
|
|||
|
||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class Item extends AbstractFile implements Comparable<Item>
|
||||
|
@ -24,9 +25,9 @@ class Item extends AbstractFile implements Comparable<Item>
|
|||
super (name, buffer);
|
||||
itemID = counter++;
|
||||
type = buffer[32];
|
||||
cost = HexFormatter.intValue (buffer[44], buffer[45])
|
||||
+ HexFormatter.intValue (buffer[46], buffer[47]) * 10000
|
||||
+ HexFormatter.intValue (buffer[48], buffer[49]) * 100000000L;
|
||||
cost = Utility.intValue (buffer[44], buffer[45])
|
||||
+ Utility.intValue (buffer[46], buffer[47]) * 10000
|
||||
+ Utility.intValue (buffer[48], buffer[49]) * 100000000L;
|
||||
genericName = HexFormatter.getPascalString (buffer, 16);
|
||||
damage = new Dice (buffer, 66);
|
||||
armourClass = buffer[62];
|
||||
|
@ -95,7 +96,7 @@ class Item extends AbstractFile implements Comparable<Item>
|
|||
if (buffer[50] == -1 && buffer[51] == -1)
|
||||
return -1;
|
||||
|
||||
return HexFormatter.intValue (buffer[50], buffer[51]);
|
||||
return Utility.intValue (buffer[50], buffer[51]);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
|||
|
||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class MazeLevel extends AbstractFile
|
||||
|
@ -438,9 +439,9 @@ class MazeLevel extends AbstractFile
|
|||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int x = b * 2;
|
||||
return new MazeAddress (HexFormatter.intValue (buffer[768 + x], buffer[769 + x]),
|
||||
HexFormatter.intValue (buffer[800 + x], buffer[801 + x]),
|
||||
HexFormatter.intValue (buffer[832 + x], buffer[833 + x]));
|
||||
return new MazeAddress (Utility.intValue (buffer[768 + x], buffer[769 + x]),
|
||||
Utility.intValue (buffer[800 + x], buffer[801 + x]),
|
||||
Utility.intValue (buffer[832 + x], buffer[833 + x]));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.bytezone.diskbrowser.applefile.AbstractFile;
|
|||
import com.bytezone.diskbrowser.disk.AppleDisk;
|
||||
import com.bytezone.diskbrowser.disk.Disk;
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class Relocator extends AbstractFile
|
||||
|
@ -25,7 +25,7 @@ public class Relocator extends AbstractFile
|
|||
{
|
||||
super (name, buffer);
|
||||
|
||||
checkByte = HexFormatter.intValue (buffer[0], buffer[1]);
|
||||
checkByte = Utility.intValue (buffer[0], buffer[1]);
|
||||
|
||||
int ptr = 2; // skip checkByte
|
||||
|
||||
|
@ -169,8 +169,8 @@ public class Relocator extends AbstractFile
|
|||
|
||||
public DiskRecord (byte[] buffer, int ptr)
|
||||
{
|
||||
diskNumber = HexFormatter.intValue (buffer[ptr], buffer[ptr + 1]);
|
||||
totDiskSegments = HexFormatter.intValue (buffer[ptr + 2], buffer[ptr + 4]);
|
||||
diskNumber = Utility.intValue (buffer[ptr], buffer[ptr + 1]);
|
||||
totDiskSegments = Utility.intValue (buffer[ptr + 2], buffer[ptr + 4]);
|
||||
|
||||
ptr += 4;
|
||||
for (int i = 0; i < totDiskSegments; i++)
|
||||
|
@ -224,9 +224,9 @@ public class Relocator extends AbstractFile
|
|||
|
||||
public DiskSegment (byte[] buffer, int ptr)
|
||||
{
|
||||
logicalBlock = HexFormatter.intValue (buffer[ptr], buffer[ptr + 1]);
|
||||
physicalBlock = HexFormatter.intValue (buffer[ptr + 2], buffer[ptr + 3]);
|
||||
segmentLength = HexFormatter.intValue (buffer[ptr + 4], buffer[ptr + 5]);
|
||||
logicalBlock = Utility.intValue (buffer[ptr], buffer[ptr + 1]);
|
||||
physicalBlock = Utility.intValue (buffer[ptr + 2], buffer[ptr + 3]);
|
||||
segmentLength = Utility.intValue (buffer[ptr + 4], buffer[ptr + 5]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -304,11 +304,11 @@ public class Wizardry4BootDisk extends PascalDisk
|
|||
{
|
||||
// System.out.println (HexFormatter.format (buffer, 0x08600 + i * 32, 32));
|
||||
int offset = 0x08600 + i * 32 + 18;
|
||||
int key = HexFormatter.unsignedShort (buffer, offset);
|
||||
int key = Utility.unsignedShort (buffer, offset);
|
||||
if (key > 0)
|
||||
text.append (String.format ("%04X %04X * %s%n", offset, key,
|
||||
messageBlock.getMessageText (key)));
|
||||
key = HexFormatter.unsignedShort (buffer, offset + 8);
|
||||
key = Utility.unsignedShort (buffer, offset + 8);
|
||||
if (key > 0)
|
||||
text.append (String.format ("%04X %04X %s%n", offset + 8, key,
|
||||
messageBlock.getMessageText (key)));
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.bytezone.diskbrowser.disk.SectorType;
|
|||
import com.bytezone.diskbrowser.gui.DataSource;
|
||||
import com.bytezone.diskbrowser.pascal.PascalDisk;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
import com.bytezone.diskbrowser.wizardry.Character.Attributes;
|
||||
import com.bytezone.diskbrowser.wizardry.Character.Statistics;
|
||||
import com.bytezone.diskbrowser.wizardry.Header.ScenarioData;
|
||||
|
@ -136,7 +137,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
byte[] buffer = disk.readBlock (2);
|
||||
int totalFiles = HexFormatter.intValue (buffer[16], buffer[17]);
|
||||
int totalFiles = Utility.intValue (buffer[16], buffer[17]);
|
||||
if (totalFiles != 3)
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue