mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-06-12 15:29:28 +00:00
removing calls to intValue()
This commit is contained in:
parent
a72bdff81d
commit
3bd836a828
|
@ -136,7 +136,7 @@ public class BasicProgramGS extends BasicProgram
|
|||
ptr += labelLength;
|
||||
|
||||
int lineLength = buffer[ptr] & 0xFF;
|
||||
lineNumber = Utility.intValue (buffer[ptr + 1], buffer[ptr + 2]);
|
||||
lineNumber = Utility.unsignedShort (buffer, ptr + 1);
|
||||
length = labelLength + lineLength;
|
||||
|
||||
if (lineNumber == 0)
|
||||
|
|
|
@ -47,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 = Utility.intValue (buffer[i * 4 + 2], buffer[i * 4 + 3]);
|
||||
int size = Utility.unsignedShort (buffer, i * 4 + 2);
|
||||
if (codeName.length () == 0 && size > 0)
|
||||
codeName = "<NULL" + ++nonameCounter + ">";
|
||||
if (size > 0)
|
||||
|
|
|
@ -79,10 +79,8 @@ public class PascalCodeStatement implements PascalConstants
|
|||
int min = ptr + padding + 7;
|
||||
int max = min + (p2 - p1) * 2;
|
||||
for (int i = min; i <= max; i += 2)
|
||||
{
|
||||
jumps.add (
|
||||
new Jump (i, i - Utility.intValue (buffer[i], buffer[i + 1]), v++));
|
||||
}
|
||||
jumps.add (new Jump (i, i - Utility.unsignedShort (buffer, i), v++));
|
||||
|
||||
break;
|
||||
|
||||
// UB, <block> - word aligned
|
||||
|
|
|
@ -36,7 +36,7 @@ public class PascalProcedure
|
|||
this.buffer = buffer;
|
||||
this.slot = slot;
|
||||
int p = buffer.length - 2 - slot * 2;
|
||||
offset = Utility.intValue (buffer[p], buffer[p + 1]);
|
||||
offset = Utility.unsignedShort (buffer, p);
|
||||
procOffset = p - offset;
|
||||
valid = procOffset > 0;
|
||||
|
||||
|
@ -44,10 +44,10 @@ public class PascalProcedure
|
|||
{
|
||||
procedureNo = buffer[procOffset] & 0xFF;
|
||||
procLevel = buffer[procOffset + 1] & 0xFF;
|
||||
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]);
|
||||
codeStart = Utility.unsignedShort (buffer, procOffset - 2);
|
||||
codeEnd = Utility.unsignedShort (buffer, procOffset - 4);
|
||||
parmSize = Utility.unsignedShort (buffer, procOffset - 6);
|
||||
dataSize = Utility.unsignedShort (buffer, procOffset - 8);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,14 +43,12 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
|||
// this.blockOffset = blockOffset;
|
||||
// this.relocator = relocator;
|
||||
|
||||
this.blockNo = Utility.intValue (fullBuffer[seq * 4], fullBuffer[seq * 4 + 1]);
|
||||
this.size = Utility.intValue (fullBuffer[seq * 4 + 2], fullBuffer[seq * 4 + 3]);
|
||||
this.blockNo = Utility.unsignedShort (fullBuffer, seq * 4);
|
||||
this.size = Utility.unsignedShort (fullBuffer, seq * 4 + 2);
|
||||
|
||||
segKind =
|
||||
Utility.intValue (fullBuffer[0xC0 + seq * 2], fullBuffer[0xC0 + seq * 2 + 1]);
|
||||
segKind = Utility.unsignedShort (fullBuffer, 0xC0 + seq * 2);
|
||||
|
||||
textAddress =
|
||||
Utility.intValue (fullBuffer[0xE0 + seq * 2], fullBuffer[0xE0 + seq * 2 + 1]);
|
||||
textAddress = Utility.unsignedShort (fullBuffer, 0xE0 + seq * 2);
|
||||
|
||||
// segment 1 is the main segment, 2-6 are used by the system, and 7
|
||||
// onwards is for the program
|
||||
|
@ -65,10 +63,8 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
|||
|
||||
version = (flags & 0xD0) >> 5;
|
||||
|
||||
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]);
|
||||
intrinsSegs1 = Utility.unsignedShort (fullBuffer, 0x120 + seq * 4);
|
||||
intrinsSegs2 = Utility.unsignedShort (fullBuffer, 0x120 + seq * 4 + 2);
|
||||
|
||||
int offset = blockNo * 512;
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
|
|||
case GSOS_EXTENDED_FILE:
|
||||
case SUBDIRECTORY:
|
||||
int type = buffer[i + 16] & 0xFF;
|
||||
int blocks = Utility.intValue (buffer[i + 19], buffer[i + 20]);
|
||||
int blocks = Utility.unsignedShort (buffer, i + 19);
|
||||
|
||||
LocalDateTime createdDate = Utility.getAppleDate (buffer, i + 24);
|
||||
LocalDateTime modifiedDate = Utility.getAppleDate (buffer, i + 33);
|
||||
|
@ -126,7 +126,7 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
|
|||
switch (fileType)
|
||||
{
|
||||
case FILE_TYPE_TEXT:
|
||||
int aux = Utility.intValue (buffer[i + 31], buffer[i + 32]);
|
||||
int aux = Utility.unsignedShort (buffer, i + 31);
|
||||
subType = String.format ("R=%5d", aux);
|
||||
break;
|
||||
|
||||
|
@ -134,7 +134,7 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
|
|||
case FILE_TYPE_PNT:
|
||||
case FILE_TYPE_PIC:
|
||||
case FILE_TYPE_FOT:
|
||||
aux = Utility.intValue (buffer[i + 31], buffer[i + 32]);
|
||||
aux = Utility.unsignedShort (buffer, i + 31);
|
||||
subType = String.format ("A=$%4X", aux);
|
||||
break;
|
||||
|
||||
|
|
|
@ -26,10 +26,10 @@ public class StoredVariables extends AbstractFile
|
|||
int strPtr = buffer.length;
|
||||
|
||||
text.append ("File length : " + HexFormatter.format4 (buffer.length));
|
||||
int totalLength = Utility.intValue (buffer[0], buffer[1]);
|
||||
int totalLength = Utility.unsignedShort (buffer, 0);
|
||||
text.append ("\nTotal length : " + HexFormatter.format4 (totalLength));
|
||||
|
||||
int varLength = Utility.intValue (buffer[2], buffer[3]);
|
||||
int varLength = Utility.unsignedShort (buffer, 2);
|
||||
text.append ("\nVar length : " + HexFormatter.format4 (varLength));
|
||||
text.append ("\n\n");
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class StoredVariables extends AbstractFile
|
|||
}
|
||||
else if (suffix == '%')
|
||||
{
|
||||
intValue = Utility.intValue (buffer[ptr + 3], buffer[ptr + 2]);
|
||||
intValue = Utility.intValue (buffer[ptr + 3], buffer[ptr + 2]); // backwards!
|
||||
if ((buffer[ptr + 2] & 0x80) > 0)
|
||||
intValue -= 65536;
|
||||
text.append (" = " + intValue);
|
||||
|
@ -133,14 +133,14 @@ public class StoredVariables extends AbstractFile
|
|||
{
|
||||
String variableName = getVariableName (buffer[ptr], buffer[ptr + 1]);
|
||||
text.append ("\n");
|
||||
int offset = Utility.intValue (buffer[ptr + 2], buffer[ptr + 3]);
|
||||
int offset = Utility.unsignedShort (buffer, ptr + 2);
|
||||
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 = Utility.intValue (buffer[p + 1], buffer[p]);
|
||||
int elements = Utility.intValue (buffer[p + 1], buffer[p]); // backwards!
|
||||
dimensionSizes[dimensions - i - 1] = elements - 1;
|
||||
if (totalElements == 0)
|
||||
totalElements = elements;
|
||||
|
@ -160,7 +160,7 @@ public class StoredVariables extends AbstractFile
|
|||
text.append (variableName + " " + getDimensionText (values) + " = ");
|
||||
if (elementSize == 2)
|
||||
{
|
||||
int intValue = Utility.intValue (buffer[p + 1], buffer[p]);
|
||||
int intValue = Utility.intValue (buffer[p + 1], buffer[p]); // backwards
|
||||
if ((buffer[p] & 0x80) > 0)
|
||||
intValue -= 65536;
|
||||
text.append (intValue + "\n");
|
||||
|
@ -212,10 +212,10 @@ public class StoredVariables extends AbstractFile
|
|||
StringBuffer text = new StringBuffer ();
|
||||
|
||||
text.append ("File length : " + HexFormatter.format4 (buffer.length));
|
||||
int totalLength = Utility.intValue (buffer[0], buffer[1]);
|
||||
int totalLength = Utility.unsignedShort (buffer, 0);
|
||||
text.append ("\nTotal length : " + HexFormatter.format4 (totalLength));
|
||||
|
||||
int varLength = Utility.intValue (buffer[2], buffer[3]);
|
||||
int varLength = Utility.unsignedShort (buffer, 2);
|
||||
text.append ("\nVar length : " + HexFormatter.format4 (varLength));
|
||||
|
||||
int unknown = buffer[4] & 0xFF;
|
||||
|
@ -232,14 +232,14 @@ public class StoredVariables extends AbstractFile
|
|||
text.append ("\nArrays : \n\n");
|
||||
while (ptr < totalLength + 5)
|
||||
{
|
||||
int offset = Utility.intValue (buffer[ptr + 2], buffer[ptr + 3]);
|
||||
int offset = Utility.unsignedShort (buffer, ptr + 2);
|
||||
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 = Utility.intValue (buffer[p + 1], buffer[p]);
|
||||
int elements = Utility.intValue (buffer[p + 1], buffer[p]); // backwards!
|
||||
dimensionSizes[dimensions - i - 1] = elements;
|
||||
if (totalElements == 0)
|
||||
totalElements = elements;
|
||||
|
|
|
@ -14,7 +14,7 @@ class CellAddress
|
|||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
colRef = buffer[offset];
|
||||
rowRef = Utility.intValue (buffer[offset + 1], buffer[offset + 2]);
|
||||
rowRef = Utility.unsignedShort (buffer, offset + 1);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -131,12 +131,12 @@ class CatalogEntry extends AbstractCatalogEntry
|
|||
{
|
||||
case IntegerBasic:
|
||||
case ApplesoftBasic:
|
||||
length = Utility.intValue (buffer[0], buffer[1]);
|
||||
length = Utility.unsignedShort (buffer, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
address = Utility.intValue (buffer[0], buffer[1]);
|
||||
length = Utility.intValue (buffer[2], buffer[3]);
|
||||
address = Utility.unsignedShort (buffer, 0);
|
||||
length = Utility.unsignedShort (buffer, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ class DosTSListSector extends AbstractSector
|
|||
addText (text, buffer, 7, 4, "Not used");
|
||||
addText (text, buffer, 11, 1, "Not used");
|
||||
|
||||
int sectorBase = Utility.intValue (buffer[5], buffer[6]);
|
||||
int sectorBase = Utility.unsignedShort (buffer, 5);
|
||||
|
||||
for (int i = 12; i <= 255; i += 2)
|
||||
{
|
||||
|
|
|
@ -35,7 +35,7 @@ class DosVTOCSector extends AbstractSector
|
|||
direction = buffer[49];
|
||||
maxTracks = buffer[52] & 0xFF;
|
||||
maxSectors = buffer[53] & 0xFF;
|
||||
sectorSize = Utility.intValue (buffer[54], buffer[55]);
|
||||
sectorSize = Utility.unsignedShort (buffer, 54);
|
||||
|
||||
flagSectors ();
|
||||
}
|
||||
|
|
|
@ -250,14 +250,14 @@ public class InfocomDisk extends AbstractFormattedDisk
|
|||
byte[] buffer = disk.readBlock (3, 0);
|
||||
|
||||
int version = buffer[0] & 0xFF;
|
||||
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]);
|
||||
int highMemory = Utility.getShortBigEndian (buffer, 4);
|
||||
int programCounter = Utility.getShortBigEndian (buffer, 6);
|
||||
int dictionary = Utility.getShortBigEndian (buffer, 8);
|
||||
int objectTable = Utility.getShortBigEndian (buffer, 10);
|
||||
int globals = Utility.getShortBigEndian (buffer, 12);
|
||||
int staticMemory = Utility.getShortBigEndian (buffer, 14);
|
||||
int abbreviationsTable = Utility.getShortBigEndian (buffer, 24);
|
||||
int fileLength = Utility.getShortBigEndian (buffer, 26);
|
||||
|
||||
if (false)
|
||||
{
|
||||
|
|
|
@ -32,11 +32,11 @@ abstract class CatalogEntry implements AppleFileSource
|
|||
{
|
||||
this.parent = parent;
|
||||
|
||||
firstBlock = Utility.intValue (buffer[0], buffer[1]);
|
||||
lastBlock = Utility.intValue (buffer[2], buffer[3]);
|
||||
firstBlock = Utility.unsignedShort (buffer, 0);
|
||||
lastBlock = Utility.unsignedShort (buffer, 2);
|
||||
fileType = buffer[4] & 0xFF;
|
||||
name = HexFormatter.getPascalString (buffer, 6);
|
||||
bytesUsedInLastBlock = Utility.intValue (buffer[16], buffer[17]);
|
||||
bytesUsedInLastBlock = Utility.unsignedShort (buffer, 16);
|
||||
|
||||
Disk disk = parent.getDisk ();
|
||||
int max = Math.min (lastBlock, disk.getTotalBlocks ());
|
||||
|
|
|
@ -26,7 +26,7 @@ public class FileEntry extends CatalogEntry
|
|||
{
|
||||
super (parent, buffer);
|
||||
|
||||
bytesUsedInLastBlock = Utility.intValue (buffer[22], buffer[23]);
|
||||
bytesUsedInLastBlock = Utility.unsignedShort (buffer, 22);
|
||||
date = HexFormatter.getPascalDate (buffer, 24);
|
||||
|
||||
int max = Math.min (lastBlock, parent.getDisk ().getTotalBlocks ());
|
||||
|
|
|
@ -50,7 +50,7 @@ class PascalCatalogSector extends AbstractSector
|
|||
addTextAndDecimal (text, buffer, 22, 4, "Reserved");
|
||||
|
||||
int ptr = PascalDisk.CATALOG_ENTRY_SIZE;
|
||||
int totalFiles = Utility.intValue (buffer[16], buffer[17]);
|
||||
int totalFiles = Utility.unsignedShort (buffer, 16);
|
||||
|
||||
while (ptr < buffer.length && totalFiles > 0)
|
||||
{
|
||||
|
|
|
@ -168,8 +168,8 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
System.out.println ("Name ok : " + name);
|
||||
}
|
||||
|
||||
int from = Utility.intValue (buffer[0], buffer[1]);
|
||||
int to = Utility.intValue (buffer[2], buffer[3]);
|
||||
int from = Utility.unsignedShort (buffer, 0);
|
||||
int to = Utility.unsignedShort (buffer, 2);
|
||||
if (from != 0 || to != 6)
|
||||
{
|
||||
if (debug)
|
||||
|
@ -177,7 +177,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
return false; // will only work for floppies!
|
||||
}
|
||||
|
||||
int blocks = Utility.intValue (buffer[14], buffer[15]);
|
||||
int blocks = Utility.unsignedShort (buffer, 14);
|
||||
if (blocks != 280 && blocks != 1600)
|
||||
{
|
||||
if (debug)
|
||||
|
@ -190,7 +190,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
addresses.add (disk.getDiskAddress (i));
|
||||
buffer = disk.readBlocks (addresses);
|
||||
|
||||
int files = Utility.intValue (buffer[16], buffer[17]);
|
||||
int files = Utility.unsignedShort (buffer, 16);
|
||||
if (files < 0 || files > 77)
|
||||
{
|
||||
if (debug)
|
||||
|
@ -204,9 +204,9 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
for (int i = 1; i <= files; i++)
|
||||
{
|
||||
int ptr = i * 26;
|
||||
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]);
|
||||
int firstBlock = Utility.unsignedShort (buffer, ptr);
|
||||
int lastBlock = Utility.unsignedShort (buffer, ptr + 2);
|
||||
int kind = Utility.unsignedShort (buffer, ptr + 4);
|
||||
if (lastBlock < firstBlock)
|
||||
return false;
|
||||
if (kind == 0)
|
||||
|
@ -214,7 +214,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
nameLength = buffer[ptr + 6] & 0xFF;
|
||||
if (nameLength < 1 || nameLength > 15)
|
||||
return false;
|
||||
int lastByte = Utility.intValue (buffer[ptr + 22], buffer[ptr + 23]);
|
||||
int lastByte = Utility.unsignedShort (buffer, ptr + 22);
|
||||
GregorianCalendar date = HexFormatter.getPascalDate (buffer, 24);
|
||||
if (debug)
|
||||
System.out.printf ("%4d %4d %d %-15s %d %s%n", firstBlock, lastBlock, kind,
|
||||
|
|
|
@ -18,8 +18,8 @@ class VolumeEntry extends CatalogEntry
|
|||
{
|
||||
super (parent, buffer);
|
||||
|
||||
totalBlocks = Utility.intValue (buffer[14], buffer[15]); // 280
|
||||
totalFiles = Utility.intValue (buffer[16], buffer[17]);
|
||||
totalBlocks = Utility.unsignedShort (buffer, 14); // 280
|
||||
totalFiles = Utility.unsignedShort (buffer, 16);
|
||||
date = HexFormatter.getPascalDate (buffer, 20); // 2 bytes
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@ abstract class CatalogEntry implements AppleFileSource
|
|||
int access;
|
||||
|
||||
List<DiskAddress> dataBlocks = new ArrayList<> ();
|
||||
List<DiskAddress> resourceBlocks = new ArrayList<> ();
|
||||
|
||||
DirectoryHeader parentDirectory;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -93,6 +95,11 @@ abstract class CatalogEntry implements AppleFileSource
|
|||
for (DiskAddress diskAddress : dataBlocks)
|
||||
if (diskAddress.matches (da))
|
||||
return true;
|
||||
|
||||
for (DiskAddress diskAddress : resourceBlocks)
|
||||
if (diskAddress.matches (da))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ public abstract class DirectoryHeader extends CatalogEntry implements ProdosCons
|
|||
|
||||
entryLength = entryBuffer[31] & 0xFF;
|
||||
entriesPerBlock = entryBuffer[32] & 0xFF;
|
||||
fileCount = Utility.intValue (entryBuffer[33], entryBuffer[34]);
|
||||
fileCount = Utility.unsignedShort (entryBuffer, 33);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -47,10 +47,10 @@ public abstract class DirectoryHeader extends CatalogEntry implements ProdosCons
|
|||
if (nameLength > 0 && storageType < 0x0E)
|
||||
{
|
||||
String name = new String (buffer, ptr + 1, nameLength);
|
||||
int blocksUsed = Utility.intValue (buffer[ptr + 0x13], buffer[ptr + 0x14]);
|
||||
int blocksUsed = Utility.unsignedShort (buffer, ptr + 0x13);
|
||||
int fileType = buffer[ptr + 0x10] & 0xFF;
|
||||
int keyPointer = Utility.intValue (buffer[ptr + 0x11], buffer[ptr + 0x12]);
|
||||
int headerPointer = Utility.intValue (buffer[ptr + 0x25], buffer[ptr + 0x26]);
|
||||
int keyPointer = Utility.unsignedShort (buffer, ptr + 0x11);
|
||||
int headerPointer = Utility.unsignedShort (buffer, ptr + 0x25);
|
||||
text.append (String.format ("%04X:%02X %-15s %s %04X %s %04X %04X%n",
|
||||
blockNo, entryNo, name, storageTypes[storageType], blocksUsed,
|
||||
fileTypes[fileType], keyPointer, headerPointer));
|
||||
|
@ -59,7 +59,7 @@ public abstract class DirectoryHeader extends CatalogEntry implements ProdosCons
|
|||
++entryNo;
|
||||
}
|
||||
|
||||
blockNo = Utility.intValue (buffer[2], buffer[3]);
|
||||
blockNo = Utility.unsignedShort (buffer, 2);
|
||||
} while (blockNo != 0);
|
||||
}
|
||||
}
|
|
@ -93,7 +93,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
case SEEDLING:
|
||||
case SAPLING:
|
||||
case TREE:
|
||||
addDataBlocks (storageType, keyPtr);
|
||||
addDataBlocks (storageType, keyPtr, dataBlocks);
|
||||
break;
|
||||
|
||||
case GSOS_EXTENDED_FILE:
|
||||
|
@ -119,7 +119,6 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
dataBlocks.add (disk.getDiskAddress (i));
|
||||
parentDisk.setSectorType (i, parentDisk.dataSector);
|
||||
}
|
||||
// System.out.println ("PASCAL on PROFILE: " + name); // PDUCSD12.PO
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -141,13 +140,17 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
{
|
||||
int storageType = buffer2[i] & 0x0F;
|
||||
int keyBlock = Utility.unsignedShort (buffer2, i + 1);
|
||||
int eof = Utility.intValue (buffer2[i + 3], buffer2[i + 4], buffer2[i + 5]);
|
||||
addDataBlocks (storageType, keyBlock);
|
||||
int eof = Utility.readTriple (buffer2, i + 3);
|
||||
|
||||
if (i < 256)
|
||||
addDataBlocks (storageType, keyBlock, dataBlocks);
|
||||
else
|
||||
addDataBlocks (storageType, keyBlock, resourceBlocks);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void addDataBlocks (int storageType, int keyPtr)
|
||||
private void addDataBlocks (int storageType, int keyPtr, List<DiskAddress> dataBlocks)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
DiskAddress emptyDiskAddress = disk.getDiskAddress (0);
|
||||
|
@ -272,7 +275,6 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
|
||||
byte[] buffer = getBuffer ();
|
||||
byte[] exactBuffer = getExactBuffer (buffer);
|
||||
// System.out.printf ("Name: %s, EOF: %04X%n", name, endOfFile);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -735,8 +737,10 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
sectors.add (catalogBlock);
|
||||
if (masterIndexBlock != null)
|
||||
sectors.add (masterIndexBlock);
|
||||
|
||||
sectors.addAll (indexBlocks);
|
||||
sectors.addAll (dataBlocks);
|
||||
sectors.addAll (resourceBlocks);
|
||||
|
||||
return sectors;
|
||||
}
|
||||
|
@ -748,15 +752,22 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||
{
|
||||
if (da == null)
|
||||
return false;
|
||||
|
||||
if (da.equals (masterIndexBlock))
|
||||
return true;
|
||||
|
||||
for (DiskAddress block : indexBlocks)
|
||||
if (da.matches (block))
|
||||
return true;
|
||||
|
||||
for (DiskAddress block : dataBlocks)
|
||||
if (da.matches (block))
|
||||
return true;
|
||||
|
||||
for (DiskAddress block : resourceBlocks)
|
||||
if (da.matches (block))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ public class ProdosDisk extends AbstractFormattedDisk
|
|||
System.out.println (HexFormatter.format (entry, 0, entry.length));
|
||||
}
|
||||
}
|
||||
block = Utility.intValue (sectorBuffer[2], sectorBuffer[3]);
|
||||
block = Utility.unsignedShort (sectorBuffer, 2);
|
||||
} while (block > 0);
|
||||
|
||||
// link double hi-res files
|
||||
|
@ -230,7 +230,7 @@ public class ProdosDisk extends AbstractFormattedDisk
|
|||
if (buffer[0x23] != 0x27 || buffer[0x24] != 0x0D)
|
||||
return false;
|
||||
|
||||
int bitMapBlock = Utility.intValue (buffer[0x27], buffer[0x28]);
|
||||
int bitMapBlock = Utility.unsignedShort (buffer, 0x27);
|
||||
if (bitMapBlock < 3 || bitMapBlock > 10)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ public class SubDirectoryHeader extends DirectoryHeader
|
|||
this.parentDirectory = parent.parentDirectory;
|
||||
this.blockNo = blockNo;
|
||||
|
||||
parentPointer = Utility.intValue (entryBuffer[35], entryBuffer[36]);
|
||||
parentPointer = Utility.unsignedShort (entryBuffer, 35);
|
||||
parentSequence = entryBuffer[37] & 0xFF;
|
||||
parentSize = entryBuffer[38] & 0xFF;
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.bytezone.diskbrowser.prodos;
|
||||
|
||||
import static com.bytezone.diskbrowser.prodos.ProdosConstants.BLOCK_SIZE;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -90,7 +88,7 @@ public class VolumeDirectoryHeader extends DirectoryHeader
|
|||
{
|
||||
byte[] buf = disk.readBlock (block);
|
||||
blockList.add (buf);
|
||||
block = Utility.intValue (buf[2], buf[3]); // next block
|
||||
block = Utility.unsignedShort (buf, 2); // next block
|
||||
} while (block > 0);
|
||||
|
||||
byte[] fullBuffer = new byte[blockList.size () * 507];
|
||||
|
|
|
@ -5,7 +5,7 @@ import static com.bytezone.diskbrowser.prodos.ProdosConstants.ENTRIES_PER_BLOCK;
|
|||
import static com.bytezone.diskbrowser.prodos.ProdosConstants.ENTRY_SIZE;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.getAppleDate;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.putAppleDate;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.readShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.unsignedShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.writeShort;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -52,7 +52,7 @@ public class DirectoryHeader
|
|||
access = buffer[ptr + 0x1E];
|
||||
entryLength = buffer[ptr + 0x1F];
|
||||
entriesPerBlock = buffer[ptr + 0x20];
|
||||
fileCount = readShort (buffer, ptr + 0x21);
|
||||
fileCount = unsignedShort (buffer, ptr + 0x21);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -98,7 +98,7 @@ public class DirectoryHeader
|
|||
|
||||
ptr += ENTRY_SIZE;
|
||||
}
|
||||
blockNo = readShort (buffer, offset + 2);
|
||||
blockNo = unsignedShort (buffer, offset + 2);
|
||||
} while (blockNo > 0);
|
||||
System.out.println ();
|
||||
}
|
||||
|
|
|
@ -105,8 +105,8 @@ public class ExtendedKeyBlock
|
|||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
storageType = buffer[ptr];
|
||||
keyBlock = Utility.readShort (buffer, ptr + 1);
|
||||
blocksUsed = Utility.readShort (buffer, ptr + 3);
|
||||
keyBlock = Utility.unsignedShort (buffer, ptr + 1);
|
||||
blocksUsed = Utility.unsignedShort (buffer, ptr + 3);
|
||||
eof = Utility.readTriple (buffer, ptr + 5);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import static com.bytezone.diskbrowser.prodos.ProdosConstants.ENTRY_SIZE;
|
|||
import static com.bytezone.diskbrowser.prodos.write.ProdosDisk.UNDERLINE;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.getAppleDate;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.putAppleDate;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.readShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.readTriple;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.unsignedShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.writeShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.writeTriple;
|
||||
|
||||
|
@ -70,8 +70,8 @@ public class FileEntry
|
|||
fileName = "";
|
||||
|
||||
fileType = buffer[ptr + 0x10];
|
||||
keyPointer = readShort (buffer, ptr + 0x11);
|
||||
blocksUsed = readShort (buffer, ptr + 0x13);
|
||||
keyPointer = unsignedShort (buffer, ptr + 0x11);
|
||||
blocksUsed = unsignedShort (buffer, ptr + 0x13);
|
||||
eof = readTriple (buffer, ptr + 0x15);
|
||||
creationDate = getAppleDate (buffer, ptr + 0x18);
|
||||
|
||||
|
@ -79,9 +79,9 @@ public class FileEntry
|
|||
minVersion = buffer[ptr + 0x1D];
|
||||
access = buffer[ptr + 0x1E];
|
||||
|
||||
auxType = readShort (buffer, ptr + 0x1F);
|
||||
auxType = unsignedShort (buffer, ptr + 0x1F);
|
||||
modifiedDate = getAppleDate (buffer, ptr + 0x21);
|
||||
headerPointer = readShort (buffer, ptr + 0x25);
|
||||
headerPointer = unsignedShort (buffer, ptr + 0x25);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -6,7 +6,7 @@ import static com.bytezone.diskbrowser.prodos.ProdosConstants.ENTRY_SIZE;
|
|||
import static com.bytezone.diskbrowser.prodos.ProdosConstants.FILE_TYPE_DIRECTORY;
|
||||
import static com.bytezone.diskbrowser.prodos.ProdosConstants.SUBDIRECTORY;
|
||||
import static com.bytezone.diskbrowser.prodos.ProdosConstants.SUBDIRECTORY_HEADER;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.readShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.unsignedShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.writeShort;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
|
@ -370,7 +370,7 @@ public class ProdosDisk
|
|||
|
||||
ptr += ENTRY_SIZE;
|
||||
}
|
||||
blockNo = readShort (buffer, offset + 2);
|
||||
blockNo = unsignedShort (buffer, offset + 2);
|
||||
} while (blockNo > 0);
|
||||
|
||||
return Optional.empty ();
|
||||
|
@ -477,7 +477,7 @@ public class ProdosDisk
|
|||
}
|
||||
|
||||
lastBlockNo = blockNo;
|
||||
blockNo = readShort (buffer, offset + 2); // next block
|
||||
blockNo = unsignedShort (buffer, offset + 2); // next block
|
||||
} while (blockNo > 0);
|
||||
|
||||
if (subdirectoryHeader == null) // this should be impossible
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.bytezone.diskbrowser.prodos.write;
|
|||
|
||||
import static com.bytezone.diskbrowser.prodos.ProdosConstants.BLOCK_SIZE;
|
||||
import static com.bytezone.diskbrowser.prodos.ProdosConstants.ENTRY_SIZE;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.readShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.unsignedShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.writeShort;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -63,7 +63,7 @@ public class SubdirectoryHeader extends DirectoryHeader
|
|||
{
|
||||
super.read ();
|
||||
|
||||
parentPointer = readShort (buffer, ptr + 0x23);
|
||||
parentPointer = unsignedShort (buffer, ptr + 0x23);
|
||||
parentEntry = buffer[ptr + 0x25];
|
||||
parentEntryLength = buffer[ptr + 0x26];
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.bytezone.diskbrowser.prodos.write;
|
||||
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.readShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.unsignedShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.writeShort;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
|
@ -26,8 +26,8 @@ public class VolumeDirectoryHeader extends DirectoryHeader
|
|||
{
|
||||
super.read ();
|
||||
|
||||
bitMapPointer = readShort (buffer, ptr + 0x23);
|
||||
totalBlocks = readShort (buffer, ptr + 0x25);
|
||||
bitMapPointer = unsignedShort (buffer, ptr + 0x23);
|
||||
totalBlocks = unsignedShort (buffer, ptr + 0x25);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -57,9 +57,9 @@ public class Binary2Header
|
|||
|
||||
accessCode = buffer[ptr + 3] & 0xFF;
|
||||
fileType = buffer[ptr + 4];
|
||||
auxType = Utility.readShort (buffer, ptr + 5);
|
||||
auxType = Utility.unsignedShort (buffer, ptr + 5);
|
||||
storageType = buffer[ptr + 7] & 0xFF;
|
||||
totalBlocks = Utility.readShort (buffer, ptr + 8);
|
||||
totalBlocks = Utility.unsignedShort (buffer, ptr + 8);
|
||||
modified = Utility.getAppleDate (buffer, ptr + 10);
|
||||
created = Utility.getAppleDate (buffer, ptr + 14);
|
||||
id = buffer[ptr + 18] & 0xFF;
|
||||
|
@ -68,11 +68,11 @@ public class Binary2Header
|
|||
prodos16accessCode = buffer[ptr + 111] & 0xFF;
|
||||
prodos16fileType = buffer[ptr + 112] & 0xFF;
|
||||
prodos16storageType = buffer[113] & 0xFF;
|
||||
prodos16totalBlocks = Utility.readShort (buffer, ptr + 114);
|
||||
prodos16totalBlocks = Utility.unsignedShort (buffer, ptr + 114);
|
||||
prodos16eof = buffer[ptr + 116] & 0xFF;
|
||||
diskSpaceRequired = Utility.getLong (buffer, ptr + 117);
|
||||
osType = buffer[ptr + 121] & 0xFF;
|
||||
nativeFileType = Utility.readShort (buffer, ptr + 122);
|
||||
nativeFileType = Utility.unsignedShort (buffer, ptr + 122);
|
||||
phantomFileFlag = buffer[ptr + 124] & 0xFF;
|
||||
dataFlags = buffer[ptr + 125] & 0xFF;
|
||||
version = buffer[ptr + 126] & 0xFF;
|
||||
|
|
|
@ -119,108 +119,106 @@ public class NuFX
|
|||
return thread.getData ();
|
||||
}
|
||||
|
||||
if (totalFiles > 0)
|
||||
if (totalFiles == 0)
|
||||
return null;
|
||||
|
||||
if (debug)
|
||||
System.out.println ("Reading files");
|
||||
|
||||
calculateTotalBlocks ();
|
||||
int[] diskSizes = { 280, 800, 1600, 3200, 6400, 65536 };
|
||||
for (int diskSize : diskSizes) // in case we choose a size that is too small
|
||||
{
|
||||
if (debug)
|
||||
System.out.println ("Reading files");
|
||||
if (diskSize < (totalBlocks + 10))
|
||||
continue;
|
||||
|
||||
calculateTotalBlocks ();
|
||||
int[] diskSizes = { 280, 800, 1600, 3200, 6400, 65536 };
|
||||
for (int diskSize : diskSizes) // in case we choose a size that is too small
|
||||
try
|
||||
{
|
||||
if (diskSize < (totalBlocks + 10))
|
||||
continue;
|
||||
ProdosDisk disk = new ProdosDisk (diskSize, volumeName.getVolumeName ());
|
||||
int count = 0;
|
||||
|
||||
try
|
||||
for (Record record : records)
|
||||
{
|
||||
ProdosDisk disk = new ProdosDisk (diskSize, volumeName.getVolumeName ());
|
||||
int count = 0;
|
||||
|
||||
for (Record record : records)
|
||||
if (record.hasFile ())
|
||||
{
|
||||
if (record.hasFile ())
|
||||
String fileName = volumeName.convert (record.getFileName ());
|
||||
|
||||
if (!record.isValidFileSystem ())
|
||||
{
|
||||
String fileName = volumeName.convert (record.getFileName ());
|
||||
System.out.printf ("File %s is file system %s%n", fileName,
|
||||
record.getFileSystemName ());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!record.isValidFileSystem ())
|
||||
{
|
||||
System.out.printf ("File %s is file system %s%n", fileName,
|
||||
record.getFileSystemName ());
|
||||
continue;
|
||||
}
|
||||
// int fileSize = record.getFileSize ();
|
||||
byte fileType = (byte) record.getFileType ();
|
||||
int eof = record.getUncompressedSize ();
|
||||
int auxType = record.getAuxType ();
|
||||
LocalDateTime created = record.getCreated ();
|
||||
LocalDateTime modified = record.getModified ();
|
||||
byte[] buffer;
|
||||
try
|
||||
{
|
||||
buffer = record.getData ();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println (e.getMessage ());
|
||||
System.out.printf ("Failed to unpack: %s%n", fileName);
|
||||
continue;
|
||||
}
|
||||
|
||||
// int fileSize = record.getFileSize ();
|
||||
byte fileType = (byte) record.getFileType ();
|
||||
int eof = record.getUncompressedSize ();
|
||||
int auxType = record.getAuxType ();
|
||||
LocalDateTime created = record.getCreated ();
|
||||
LocalDateTime modified = record.getModified ();
|
||||
byte[] buffer;
|
||||
if (debug)
|
||||
System.out.printf ("%3d %-35s %02X %,7d %,7d %,7d %s %s%n", ++count,
|
||||
fileName, fileType, auxType, eof, buffer.length, created, modified);
|
||||
|
||||
FileEntry fileEntry;
|
||||
try
|
||||
{
|
||||
fileEntry = disk.addFile (fileName, fileType, auxType, created, modified,
|
||||
buffer, eof);
|
||||
}
|
||||
catch (FileAlreadyExistsException e)
|
||||
{
|
||||
System.out.printf ("File %s not added%n", fileName);
|
||||
break;
|
||||
}
|
||||
|
||||
if (record.hasResource ())
|
||||
{
|
||||
try
|
||||
{
|
||||
buffer = record.getData ();
|
||||
buffer = record.getResourceData ();
|
||||
disk.addResourceFork (fileEntry, buffer, buffer.length);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println (e.getMessage ());
|
||||
System.out.printf ("Failed to unpack: %s%n", fileName);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
System.out.printf ("%3d %-35s %02X %,7d %,7d %,7d %s %s%n", ++count,
|
||||
fileName, fileType, auxType, eof, buffer.length, created, modified);
|
||||
|
||||
FileEntry fileEntry;
|
||||
try
|
||||
{
|
||||
fileEntry = disk.addFile (fileName, fileType, auxType, created, modified,
|
||||
buffer, eof);
|
||||
}
|
||||
catch (FileAlreadyExistsException e)
|
||||
{
|
||||
System.out.printf ("File %s not added%n", fileName);
|
||||
break;
|
||||
}
|
||||
|
||||
if (record.hasResource ())
|
||||
{
|
||||
try
|
||||
{
|
||||
buffer = record.getResourceData ();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println (e.getMessage ());
|
||||
System.out.printf ("Failed to unpack resource fork: %s%n", fileName);
|
||||
continue;
|
||||
}
|
||||
disk.addResourceFork (fileEntry, buffer, buffer.length);
|
||||
System.out.printf ("Failed to unpack resource fork: %s%n", fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
disk.close ();
|
||||
disk.close ();
|
||||
|
||||
return disk.getBuffer ();
|
||||
}
|
||||
catch (DiskFullException e)
|
||||
{
|
||||
System.out.println ("disk full: " + diskSize); // go round again
|
||||
}
|
||||
catch (VolumeCatalogFullException e)
|
||||
{
|
||||
e.printStackTrace ();
|
||||
return null;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace ();
|
||||
return null;
|
||||
}
|
||||
return disk.getBuffer ();
|
||||
}
|
||||
catch (DiskFullException e)
|
||||
{
|
||||
System.out.println ("disk full: " + diskSize); // go round again
|
||||
}
|
||||
catch (VolumeCatalogFullException e)
|
||||
{
|
||||
e.printStackTrace ();
|
||||
return null;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace ();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -245,22 +243,6 @@ public class NuFX
|
|||
return totalBlocks;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void listFiles ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int count = 0;
|
||||
for (Record record : records)
|
||||
{
|
||||
if (record.hasFile ())
|
||||
{
|
||||
System.out.printf ("%3d %-35s %,7d %02X %,7d%n", count, record.getFileName (),
|
||||
record.getFileSize (), record.getFileType (), record.getUncompressedSize ());
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
|
|
|
@ -206,7 +206,8 @@ public final class Utility
|
|||
public static LocalDateTime getAppleDate (byte[] buffer, int offset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int yymmdd = readShort (buffer, offset);
|
||||
// int yymmdd = readShort (buffer, offset);
|
||||
int yymmdd = unsignedShort (buffer, offset);
|
||||
if (yymmdd != 0)
|
||||
{
|
||||
int year = (yymmdd & 0xFE00) >> 9;
|
||||
|
@ -277,11 +278,11 @@ public final class Utility
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int readShort (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return (buffer[ptr] & 0xFF) | (buffer[ptr + 1] & 0xFF) << 8;
|
||||
}
|
||||
// public static int readShort (byte[] buffer, int ptr)
|
||||
// // ---------------------------------------------------------------------------------//
|
||||
// {
|
||||
// return (buffer[ptr] & 0xFF) | (buffer[ptr + 1] & 0xFF) << 8;
|
||||
// }
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int readTriple (byte[] buffer, int ptr)
|
||||
|
|
|
@ -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 = Utility.intValue (buffer[38], buffer[39]);
|
||||
stats.ageInWeeks = Utility.unsignedShort (buffer, 38);
|
||||
stats.statusValue = buffer[40];
|
||||
stats.status = statuses[stats.statusValue];
|
||||
stats.alignment = alignments[buffer[42] & 0xFF];
|
||||
|
||||
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.gold =
|
||||
Utility.unsignedShort (buffer, 52) + Utility.unsignedShort (buffer, 54) * 10000;
|
||||
stats.experience =
|
||||
Utility.unsignedShort (buffer, 124) + Utility.unsignedShort (buffer, 126) * 10000;
|
||||
stats.level = Utility.unsignedShort (buffer, 132);
|
||||
|
||||
stats.hitsLeft = Utility.intValue (buffer[134], buffer[135]);
|
||||
stats.hitsMax = Utility.intValue (buffer[136], buffer[137]);
|
||||
stats.hitsLeft = Utility.unsignedShort (buffer, 134);
|
||||
stats.hitsMax = Utility.unsignedShort (buffer, 136);
|
||||
stats.armourClass = buffer[176];
|
||||
|
||||
attributes.strength = (buffer[44] & 0xFF) % 16;
|
||||
|
|
|
@ -22,9 +22,9 @@ class ExperienceLevel extends AbstractFile
|
|||
if (buffer[ptr] == 0)
|
||||
break;
|
||||
|
||||
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;
|
||||
long points = Utility.unsignedShort (buffer, ptr)
|
||||
+ Utility.unsignedShort (buffer, ptr + 2) * 10000
|
||||
+ Utility.unsignedShort (buffer, ptr + 4) * 100000000L;
|
||||
expLevels[seq++] = points;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ class Header
|
|||
text.append ("\n");
|
||||
while (ptr < 512)
|
||||
{
|
||||
int value = Utility.intValue (buffer[ptr], buffer[ptr + 1]);
|
||||
int value = Utility.unsignedShort (buffer, ptr);
|
||||
text.append (String.format ("%04X %,6d%n", value, value));
|
||||
ptr += 2;
|
||||
}
|
||||
|
|
|
@ -25,9 +25,8 @@ class Item extends AbstractFile implements Comparable<Item>
|
|||
super (name, buffer);
|
||||
itemID = counter++;
|
||||
type = buffer[32];
|
||||
cost = Utility.intValue (buffer[44], buffer[45])
|
||||
+ Utility.intValue (buffer[46], buffer[47]) * 10000
|
||||
+ Utility.intValue (buffer[48], buffer[49]) * 100000000L;
|
||||
cost = Utility.unsignedShort (buffer, 44) + Utility.unsignedShort (buffer, 46) * 10000
|
||||
+ Utility.unsignedShort (buffer, 48) * 100000000L;
|
||||
genericName = HexFormatter.getPascalString (buffer, 16);
|
||||
damage = new Dice (buffer, 66);
|
||||
armourClass = buffer[62];
|
||||
|
@ -96,7 +95,7 @@ class Item extends AbstractFile implements Comparable<Item>
|
|||
if (buffer[50] == -1 && buffer[51] == -1)
|
||||
return -1;
|
||||
|
||||
return Utility.intValue (buffer[50], buffer[51]);
|
||||
return Utility.unsignedShort (buffer, 50);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -439,9 +439,8 @@ class MazeLevel extends AbstractFile
|
|||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int x = b * 2;
|
||||
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]));
|
||||
return new MazeAddress (Utility.unsignedShort (buffer, 768 + x),
|
||||
Utility.unsignedShort (buffer, 800 + x), Utility.unsignedShort (buffer, 832 + x));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -25,7 +25,7 @@ public class Relocator extends AbstractFile
|
|||
{
|
||||
super (name, buffer);
|
||||
|
||||
checkByte = Utility.intValue (buffer[0], buffer[1]);
|
||||
checkByte = Utility.unsignedShort (buffer, 0);
|
||||
|
||||
int ptr = 2; // skip checkByte
|
||||
|
||||
|
@ -169,7 +169,7 @@ public class Relocator extends AbstractFile
|
|||
|
||||
public DiskRecord (byte[] buffer, int ptr)
|
||||
{
|
||||
diskNumber = Utility.intValue (buffer[ptr], buffer[ptr + 1]);
|
||||
diskNumber = Utility.unsignedShort (buffer, ptr);
|
||||
totDiskSegments = Utility.intValue (buffer[ptr + 2], buffer[ptr + 4]);
|
||||
|
||||
ptr += 4;
|
||||
|
@ -224,9 +224,9 @@ public class Relocator extends AbstractFile
|
|||
|
||||
public DiskSegment (byte[] buffer, int ptr)
|
||||
{
|
||||
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]);
|
||||
logicalBlock = Utility.unsignedShort (buffer, ptr);
|
||||
physicalBlock = Utility.unsignedShort (buffer, ptr + 2);
|
||||
segmentLength = Utility.unsignedShort (buffer, ptr + 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -137,7 +137,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
byte[] buffer = disk.readBlock (2);
|
||||
int totalFiles = Utility.intValue (buffer[16], buffer[17]);
|
||||
int totalFiles = Utility.unsignedShort (buffer, 16);
|
||||
if (totalFiles != 3)
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user