mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-11 07:30:39 +00:00
consolidated some of the getWord() type routines in Utility, also allow
user to save the current file buffer to the local file system.
This commit is contained in:
parent
ddadfd3198
commit
62c09af14f
@ -6,6 +6,7 @@ import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import com.bytezone.diskbrowser.gui.DataSource;
|
||||
import com.bytezone.diskbrowser.prodos.ResourceFork;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
@ -19,6 +20,7 @@ public abstract class AbstractFile implements DataSource
|
||||
protected AssemblerProgram assembler;
|
||||
protected BufferedImage image;
|
||||
protected int loadAddress;
|
||||
ResourceFork resourceFork;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public AbstractFile (String name, byte[] buffer)
|
||||
@ -36,6 +38,14 @@ public abstract class AbstractFile implements DataSource
|
||||
return "Name : " + name + "\n\nNo text description";
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public byte[] getBuffer ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static void setDefaultDebug (boolean value)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -43,6 +53,13 @@ public abstract class AbstractFile implements DataSource
|
||||
showDebugText = value;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void setResourceFork (ResourceFork resourceFork)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
this.resourceFork = resourceFork;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static void setDebug (boolean value)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -4,8 +4,8 @@ import static com.bytezone.diskbrowser.utilities.Utility.ASCII_BACKSPACE;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.ASCII_CR;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.ASCII_LF;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.getIndent;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.getShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.isHighBitSet;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.unsignedShort;
|
||||
|
||||
import com.bytezone.diskbrowser.gui.BasicPreferences;
|
||||
|
||||
@ -37,9 +37,9 @@ public class AppleBasicFormatter extends BasicFormatter
|
||||
LineFormatter formatter =
|
||||
basicPreferences.appleLineWrap ? wrapFormatter : flatFormatter;
|
||||
|
||||
while ((linkField = unsignedShort (buffer, ptr)) != 0)
|
||||
while ((linkField = getShort (buffer, ptr)) != 0)
|
||||
{
|
||||
int lineNumber = unsignedShort (buffer, ptr + 2);
|
||||
int lineNumber = getShort (buffer, ptr + 2);
|
||||
currentLine.append (String.format (" %d ", lineNumber));
|
||||
ptr += 4;
|
||||
|
||||
|
@ -79,11 +79,11 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
byte[] getBuffer ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
// byte[] getBuffer ()
|
||||
// // ---------------------------------------------------------------------------------//
|
||||
// {
|
||||
// return buffer;
|
||||
// }
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
int getEndPtr ()
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.unsignedShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.getShort;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -35,14 +35,14 @@ public abstract class BasicFormatter implements ApplesoftConstants
|
||||
int getLoadAddress ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return (buffer.length > 3) ? unsignedShort (buffer, 0) - getFirstLineLength () : 0;
|
||||
return (buffer.length > 3) ? getShort (buffer, 0) - getFirstLineLength () : 0;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private int getFirstLineLength ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int linkField = unsignedShort (buffer, 0);
|
||||
int linkField = getShort (buffer, 0);
|
||||
if (linkField == 0)
|
||||
return 2;
|
||||
|
||||
|
@ -136,7 +136,7 @@ public class BasicProgramGS extends BasicProgram
|
||||
ptr += labelLength;
|
||||
|
||||
int lineLength = buffer[ptr] & 0xFF;
|
||||
lineNumber = Utility.unsignedShort (buffer, ptr + 1);
|
||||
lineNumber = Utility.getShort (buffer, ptr + 1);
|
||||
length = labelLength + lineLength;
|
||||
|
||||
if (lineNumber == 0)
|
||||
|
@ -44,22 +44,22 @@ public class DosMasterFile extends AbstractFile
|
||||
System.out.print ("\nFirst Block : ");
|
||||
for (int i = 0; i < 16; i += 2)
|
||||
{
|
||||
System.out.printf ("%04X ", Utility.unsignedShort (buffer, 0x40 + i));
|
||||
System.out.printf ("%04X ", Utility.getShort (buffer, 0x40 + i));
|
||||
if (i % 4 == 2)
|
||||
System.out.print (": ");
|
||||
}
|
||||
|
||||
System.out.print ("\nLast Block : ");
|
||||
for (int i = 0; i < 8; i += 2)
|
||||
System.out.printf ("%04X : ", Utility.unsignedShort (buffer, 0x50 + i));
|
||||
System.out.printf ("%04X : ", Utility.getShort (buffer, 0x50 + i));
|
||||
|
||||
System.out.print ("\nImage Size : ");
|
||||
for (int i = 0; i < 8; i += 2)
|
||||
System.out.printf ("%04X : ", Utility.unsignedShort (buffer, 0x58 + i));
|
||||
System.out.printf ("%04X : ", Utility.getShort (buffer, 0x58 + i));
|
||||
|
||||
System.out.print ("\nAddress : ");
|
||||
for (int i = 0; i < 8; i += 2)
|
||||
System.out.printf ("%04X : ", Utility.unsignedShort (buffer, 0x60 + i));
|
||||
System.out.printf ("%04X : ", Utility.getShort (buffer, 0x60 + i));
|
||||
|
||||
System.out.println ();
|
||||
System.out.println ();
|
||||
@ -75,12 +75,12 @@ public class DosMasterFile extends AbstractFile
|
||||
|
||||
int slot = (slotDrive & 0x70) >>> 4;
|
||||
int drive = ((slotDrive & 0x80) >>> 7) + 1;
|
||||
int firstBlock = Utility.unsignedShort (buffer, 0x40 + i * 2); // of first volume
|
||||
int firstBlock = Utility.getShort (buffer, 0x40 + i * 2); // of first volume
|
||||
|
||||
int skip = i / 2 * 2; // 0, 0, 2, 2, 4, 4, 6, 6 - same for both drives
|
||||
|
||||
int lastBlock = Utility.unsignedShort (buffer, 0x50 + skip); // of last volume
|
||||
int volSize = Utility.unsignedShort (buffer, 0x58 + skip);
|
||||
int lastBlock = Utility.getShort (buffer, 0x50 + skip); // of last volume
|
||||
int volSize = Utility.getShort (buffer, 0x58 + skip);
|
||||
|
||||
int originalFirstBlock = firstBlock;
|
||||
if (firstBlock > lastBlock) // WTF?
|
||||
@ -176,9 +176,9 @@ public class DosMasterFile extends AbstractFile
|
||||
text.append (String.format ("Slot %d, Drive %d has", s / 16, dr + 1));
|
||||
|
||||
int ptr = v0 + 2 * d0 + 2 * dr;
|
||||
int st = Utility.unsignedShort (buffer, ptr); // start block of first volume
|
||||
int v = Utility.unsignedShort (buffer, size + d0); // end block of last volume
|
||||
int sz = Utility.unsignedShort (buffer, vsiz + d0); // blocks per volume
|
||||
int st = Utility.getShort (buffer, ptr); // start block of first volume
|
||||
int v = Utility.getShort (buffer, size + d0); // end block of last volume
|
||||
int sz = Utility.getShort (buffer, vsiz + d0); // blocks per volume
|
||||
|
||||
if (st > v)
|
||||
st -= 16 * 4096;
|
||||
|
@ -84,7 +84,7 @@ public class ExoBuffer
|
||||
return false;
|
||||
}
|
||||
|
||||
int address = Utility.unsignedShort (buffer, buffer.length - 2);
|
||||
int address = Utility.getShort (buffer, buffer.length - 2);
|
||||
|
||||
if (address != 0x6000 && address != 0x8000 && address != 0xA000)
|
||||
{
|
||||
|
@ -28,11 +28,11 @@ public class FileTypeDescriptorTable extends AbstractFile
|
||||
|
||||
versionMajor = buffer[0] & 0xFF;
|
||||
versionMinor = buffer[1] & 0xFF;
|
||||
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);
|
||||
flags = Utility.getShort (buffer, 2);
|
||||
numEntries = Utility.getShort (buffer, 4);
|
||||
spareWord = Utility.getShort (buffer, 6);
|
||||
indexRecordSize = Utility.getShort (buffer, 8);
|
||||
offsetToIdx = Utility.getShort (buffer, 10);
|
||||
|
||||
int ptr = offsetToIdx;
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
@ -80,10 +80,10 @@ public class FileTypeDescriptorTable extends AbstractFile
|
||||
|
||||
public IndexRecord (byte[] buffer, int offset)
|
||||
{
|
||||
fileType = Utility.unsignedShort (buffer, offset);
|
||||
auxType = Utility.unsignedLong (buffer, offset + 2);
|
||||
flags = Utility.unsignedShort (buffer, offset + 6);
|
||||
this.offset = Utility.unsignedShort (buffer, offset + 8);
|
||||
fileType = Utility.getShort (buffer, offset);
|
||||
auxType = Utility.getLong (buffer, offset + 2);
|
||||
flags = Utility.getShort (buffer, offset + 6);
|
||||
this.offset = Utility.getShort (buffer, offset + 8);
|
||||
string = HexFormatter.getPascalString (buffer, this.offset);
|
||||
}
|
||||
|
||||
|
@ -620,15 +620,15 @@ public abstract class HiResImage extends AbstractFile
|
||||
return false;
|
||||
|
||||
String text = new String (buffer, 0, 2);
|
||||
int size = Utility.unsignedLong (buffer, 2);
|
||||
int size = Utility.getLong (buffer, 2);
|
||||
|
||||
if (false)
|
||||
{
|
||||
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);
|
||||
int empty = Utility.getLong (buffer, 6);
|
||||
int offset = Utility.getLong (buffer, 10);
|
||||
int header = Utility.getLong (buffer, 14);
|
||||
int width = Utility.getLong (buffer, 18);
|
||||
int height = Utility.getLong (buffer, 22);
|
||||
|
||||
System.out.println (buffer.length);
|
||||
System.out.println (size);
|
||||
@ -800,7 +800,7 @@ public abstract class HiResImage extends AbstractFile
|
||||
public ColorEntry (byte[] data, int offset)
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
value = Utility.unsignedShort (data, offset);
|
||||
value = Utility.getShort (data, offset);
|
||||
|
||||
int red = ((value >> 8) & 0x0f) * 17;
|
||||
int green = ((value >> 4) & 0x0f) * 17;
|
||||
@ -829,8 +829,8 @@ public abstract class HiResImage extends AbstractFile
|
||||
public DirEntry (byte[] data, int offset)
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
numBytes = Utility.unsignedShort (data, offset);
|
||||
mode = Utility.unsignedShort (data, offset + 2);
|
||||
numBytes = Utility.getShort (data, offset);
|
||||
mode = Utility.getShort (data, offset + 2);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------//
|
||||
|
@ -29,16 +29,16 @@ public class IconFile extends AbstractFile implements ProdosConstants
|
||||
{
|
||||
super (name, buffer);
|
||||
|
||||
iBlkNext = Utility.unsignedLong (buffer, 0);
|
||||
iBlkID = Utility.unsignedShort (buffer, 4);
|
||||
iBlkPath = Utility.unsignedLong (buffer, 6);
|
||||
iBlkNext = Utility.getLong (buffer, 0);
|
||||
iBlkID = Utility.getShort (buffer, 4);
|
||||
iBlkPath = Utility.getLong (buffer, 6);
|
||||
iBlkName = HexFormatter.getHexString (buffer, 10, 16);
|
||||
|
||||
int ptr = 26;
|
||||
|
||||
while (true)
|
||||
{
|
||||
int dataLen = Utility.unsignedShort (buffer, ptr);
|
||||
int dataLen = Utility.getShort (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 = Utility.unsignedShort (fullBuffer, ptr);
|
||||
iDataLen = Utility.getShort (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 = Utility.unsignedShort (buffer, 82);
|
||||
iDataAux = Utility.unsignedShort (buffer, 84);
|
||||
iDataType = Utility.getShort (buffer, 82);
|
||||
iDataAux = Utility.getShort (buffer, 84);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
@ -200,10 +200,10 @@ public class IconFile extends AbstractFile implements ProdosConstants
|
||||
public Image (byte[] buffer, int ptr) throws InvalidImageException
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
iconType = Utility.unsignedShort (buffer, ptr);
|
||||
iconSize = Utility.unsignedShort (buffer, ptr + 2);
|
||||
iconHeight = Utility.unsignedShort (buffer, ptr + 4);
|
||||
iconWidth = Utility.unsignedShort (buffer, ptr + 6);
|
||||
iconType = Utility.getShort (buffer, ptr);
|
||||
iconSize = Utility.getShort (buffer, ptr + 2);
|
||||
iconHeight = Utility.getShort (buffer, ptr + 4);
|
||||
iconWidth = Utility.getShort (buffer, ptr + 6);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
|
@ -22,13 +22,13 @@ public class PascalArea extends AbstractFile
|
||||
{
|
||||
super (name, buffer);
|
||||
|
||||
size = Utility.unsignedShort (buffer, 0);
|
||||
volumes = Utility.unsignedShort (buffer, 2);
|
||||
size = Utility.getShort (buffer, 0);
|
||||
volumes = Utility.getShort (buffer, 2);
|
||||
ppmName = HexFormatter.getPascalString (buffer, 4);
|
||||
start = Utility.unsignedShort (buffer, 8);
|
||||
length = Utility.unsignedShort (buffer, 11);
|
||||
start = Utility.getShort (buffer, 8);
|
||||
length = Utility.getShort (buffer, 11);
|
||||
defaultUnit = buffer[13] & 0xFF;
|
||||
oldDriver = Utility.unsignedShort (buffer, 14);
|
||||
oldDriver = Utility.getShort (buffer, 14);
|
||||
// writeProtected = buffer[12] != 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.unsignedShort (buffer, i * 4 + 2);
|
||||
int size = Utility.getShort (buffer, i * 4 + 2);
|
||||
if (codeName.length () == 0 && size > 0)
|
||||
codeName = "<NULL" + ++nonameCounter + ">";
|
||||
if (size > 0)
|
||||
|
@ -79,7 +79,7 @@ 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.unsignedShort (buffer, i), v++));
|
||||
jumps.add (new Jump (i, i - Utility.getShort (buffer, i), v++));
|
||||
|
||||
break;
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class PascalProcedure
|
||||
this.buffer = buffer;
|
||||
this.slot = slot;
|
||||
int p = buffer.length - 2 - slot * 2;
|
||||
offset = Utility.unsignedShort (buffer, p);
|
||||
offset = Utility.getShort (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.unsignedShort (buffer, procOffset - 2);
|
||||
codeEnd = Utility.unsignedShort (buffer, procOffset - 4);
|
||||
parmSize = Utility.unsignedShort (buffer, procOffset - 6);
|
||||
dataSize = Utility.unsignedShort (buffer, procOffset - 8);
|
||||
codeStart = Utility.getShort (buffer, procOffset - 2);
|
||||
codeEnd = Utility.getShort (buffer, procOffset - 4);
|
||||
parmSize = Utility.getShort (buffer, procOffset - 6);
|
||||
dataSize = Utility.getShort (buffer, procOffset - 8);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,12 +43,12 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
||||
// this.blockOffset = blockOffset;
|
||||
// this.relocator = relocator;
|
||||
|
||||
this.blockNo = Utility.unsignedShort (fullBuffer, seq * 4);
|
||||
this.size = Utility.unsignedShort (fullBuffer, seq * 4 + 2);
|
||||
this.blockNo = Utility.getShort (fullBuffer, seq * 4);
|
||||
this.size = Utility.getShort (fullBuffer, seq * 4 + 2);
|
||||
|
||||
segKind = Utility.unsignedShort (fullBuffer, 0xC0 + seq * 2);
|
||||
segKind = Utility.getShort (fullBuffer, 0xC0 + seq * 2);
|
||||
|
||||
textAddress = Utility.unsignedShort (fullBuffer, 0xE0 + seq * 2);
|
||||
textAddress = Utility.getShort (fullBuffer, 0xE0 + seq * 2);
|
||||
|
||||
// segment 1 is the main segment, 2-6 are used by the system, and 7
|
||||
// onwards is for the program
|
||||
@ -63,8 +63,8 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
||||
|
||||
version = (flags & 0xD0) >> 5;
|
||||
|
||||
intrinsSegs1 = Utility.unsignedShort (fullBuffer, 0x120 + seq * 4);
|
||||
intrinsSegs2 = Utility.unsignedShort (fullBuffer, 0x120 + seq * 4 + 2);
|
||||
intrinsSegs1 = Utility.getShort (fullBuffer, 0x120 + seq * 4);
|
||||
intrinsSegs2 = Utility.getShort (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.unsignedShort (buffer, i + 19);
|
||||
int blocks = Utility.getShort (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.unsignedShort (buffer, i + 31);
|
||||
int aux = Utility.getShort (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.unsignedShort (buffer, i + 31);
|
||||
aux = Utility.getShort (buffer, i + 31);
|
||||
subType = String.format ("A=$%4X", aux);
|
||||
break;
|
||||
|
||||
|
@ -72,37 +72,37 @@ public class QuickDrawFont extends CharacterList
|
||||
|
||||
int ptr = nameLength + 1; // start of header record
|
||||
|
||||
headerSize = Utility.unsignedShort (buffer, ptr);
|
||||
headerSize = Utility.getShort (buffer, ptr);
|
||||
fontDefinitionOffset = nameLength + 1 + headerSize * 2;
|
||||
|
||||
fontFamily = Utility.unsignedShort (buffer, ptr + 2);
|
||||
fontStyle = Utility.unsignedShort (buffer, ptr + 4);
|
||||
fontSize = Utility.unsignedShort (buffer, ptr + 6);
|
||||
fontFamily = Utility.getShort (buffer, ptr + 2);
|
||||
fontStyle = Utility.getShort (buffer, ptr + 4);
|
||||
fontSize = Utility.getShort (buffer, ptr + 6);
|
||||
versionMajor = buffer[ptr + 8] & 0xFF;
|
||||
versionMinor = buffer[ptr + 9] & 0xFF;
|
||||
extent = Utility.unsignedShort (buffer, ptr + 10);
|
||||
extent = Utility.getShort (buffer, ptr + 10);
|
||||
|
||||
ptr = fontDefinitionOffset;
|
||||
|
||||
fontType = Utility.unsignedShort (buffer, ptr);
|
||||
firstChar = Utility.unsignedShort (buffer, ptr + 2);
|
||||
lastChar = Utility.unsignedShort (buffer, ptr + 4);
|
||||
widMax = Utility.unsignedShort (buffer, ptr + 6);
|
||||
fontType = Utility.getShort (buffer, ptr);
|
||||
firstChar = Utility.getShort (buffer, ptr + 2);
|
||||
lastChar = Utility.getShort (buffer, ptr + 4);
|
||||
widMax = Utility.getShort (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);
|
||||
fRectWidth = Utility.getShort (buffer, ptr + 12);
|
||||
fRectHeight = Utility.getShort (buffer, ptr + 14);
|
||||
|
||||
owTLoc = Utility.unsignedShort (buffer, ptr + 16);
|
||||
owTLoc = Utility.getShort (buffer, ptr + 16);
|
||||
|
||||
offsetWidthTableOffset = (ptr + 16) + owTLoc * 2;
|
||||
locationTableOffset = offsetWidthTableOffset - (lastChar - firstChar + 3) * 2;
|
||||
bitImageOffset = ptr + 26;
|
||||
|
||||
ascent = Utility.unsignedShort (buffer, ptr + 18);
|
||||
descent = Utility.unsignedShort (buffer, ptr + 20);
|
||||
leading = Utility.unsignedShort (buffer, ptr + 22);
|
||||
rowWords = Utility.unsignedShort (buffer, ptr + 24);
|
||||
ascent = Utility.getShort (buffer, ptr + 18);
|
||||
descent = Utility.getShort (buffer, ptr + 20);
|
||||
leading = Utility.getShort (buffer, ptr + 22);
|
||||
rowWords = Utility.getShort (buffer, ptr + 24);
|
||||
|
||||
totalCharacters = lastChar - firstChar + 2; // includes 'missing' character
|
||||
|
||||
@ -151,12 +151,12 @@ public class QuickDrawFont extends CharacterList
|
||||
for (int i = 0, max = totalCharacters + 1; i < max; i++)
|
||||
{
|
||||
// index into the strike
|
||||
int location = Utility.unsignedShort (buffer, locationTableOffset + i * 2);
|
||||
int location = Utility.getShort (buffer, locationTableOffset + i * 2);
|
||||
|
||||
int j = i + 1; // next character
|
||||
if (j < max)
|
||||
{
|
||||
int nextLocation = Utility.unsignedShort (buffer, locationTableOffset + j * 2);
|
||||
int nextLocation = Utility.getShort (buffer, locationTableOffset + j * 2);
|
||||
int pixelWidth = nextLocation - location;
|
||||
|
||||
if (pixelWidth > 0)
|
||||
@ -259,9 +259,8 @@ public class QuickDrawFont extends CharacterList
|
||||
if (offset == 255 && width == 255)
|
||||
continue;
|
||||
|
||||
int location = Utility.unsignedShort (buffer, locationTableOffset + i * 2);
|
||||
int nextLocation =
|
||||
Utility.unsignedShort (buffer, locationTableOffset + (i + 1) * 2);
|
||||
int location = Utility.getShort (buffer, locationTableOffset + i * 2);
|
||||
int nextLocation = Utility.getShort (buffer, locationTableOffset + (i + 1) * 2);
|
||||
int pixelWidth = nextLocation - location;
|
||||
|
||||
text.append (String.format (
|
||||
|
@ -27,7 +27,7 @@ public class SHRPictureFile1 extends HiResImage
|
||||
int ptr = 0;
|
||||
while (ptr < buffer.length)
|
||||
{
|
||||
int len = Utility.unsignedLong (buffer, ptr);
|
||||
int len = Utility.getLong (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 = Utility.unsignedShort (data, ptr);
|
||||
numColorTables = Utility.getShort (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 = Utility.unsignedShort (data, ptr);
|
||||
pixelsPerScanLine = Utility.unsignedShort (data, ptr + 2);
|
||||
numColorTables = Utility.unsignedShort (data, ptr + 4);
|
||||
masterMode = Utility.getShort (data, ptr);
|
||||
pixelsPerScanLine = Utility.getShort (data, ptr + 2);
|
||||
numColorTables = Utility.getShort (data, ptr + 4);
|
||||
mode640 = (masterMode & 0x80) != 0;
|
||||
|
||||
ptr += 6;
|
||||
@ -299,7 +299,7 @@ public class SHRPictureFile1 extends HiResImage
|
||||
ptr += 32;
|
||||
}
|
||||
|
||||
numScanLines = Utility.unsignedShort (data, ptr);
|
||||
numScanLines = Utility.getShort (data, ptr);
|
||||
ptr += 2;
|
||||
|
||||
scanLineDirectory = new DirEntry[numScanLines];
|
||||
|
@ -99,10 +99,10 @@ public class SHRPictureFile2 extends HiResImage
|
||||
unpack (buffer, 0, buffer.length, newBuffer, 0);
|
||||
buffer = newBuffer;
|
||||
|
||||
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
|
||||
int mode = Utility.getShort (this.buffer, 0);
|
||||
int rect1 = Utility.getLong (this.buffer, 2);
|
||||
int rect2 = Utility.getLong (this.buffer, 6);
|
||||
int version = Utility.getShort (this.buffer, 10); // $8211
|
||||
|
||||
break;
|
||||
|
||||
@ -154,13 +154,13 @@ public class SHRPictureFile2 extends HiResImage
|
||||
private void doAnimation ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
// int len = HexFormatter.unsignedLong (buffer, 0x8000);
|
||||
delay = Utility.unsignedLong (buffer, 0x8004);
|
||||
// int len = HexFormatter.getLong (buffer, 0x8000);
|
||||
delay = Utility.getLong (buffer, 0x8004);
|
||||
if (delay > 60)
|
||||
delay = 10;
|
||||
delay = delay * 1000 / 60;
|
||||
|
||||
// int offset = HexFormatter.unsignedLong (buffer, 0x8008);
|
||||
// int offset = HexFormatter.getLong (buffer, 0x8008);
|
||||
// int blockLen = eof - 0x8008;
|
||||
|
||||
// System.out.printf ("Delay: %,d%n", delay);
|
||||
@ -173,7 +173,7 @@ public class SHRPictureFile2 extends HiResImage
|
||||
int start = ptr;
|
||||
while (ptr < buffer.length)
|
||||
{
|
||||
int off = Utility.unsignedShort (buffer, ptr);
|
||||
int off = Utility.getShort (buffer, ptr);
|
||||
|
||||
ptr += 4;
|
||||
if (off == 0)
|
||||
@ -299,7 +299,7 @@ public class SHRPictureFile2 extends HiResImage
|
||||
|
||||
while (true)
|
||||
{
|
||||
int offset = Utility.unsignedShort (buffer, ptr);
|
||||
int offset = Utility.getShort (buffer, ptr);
|
||||
if (offset == 0)
|
||||
break;
|
||||
|
||||
|
@ -54,20 +54,20 @@ public class SegmentHeader
|
||||
version = buffer[offset + 15] & 0xFF;
|
||||
|
||||
banksize = Utility.getLong (buffer, offset + 16);
|
||||
kind2 = Utility.getWord (buffer, offset + 20);
|
||||
unused = Utility.getWord (buffer, offset + 22);
|
||||
kind2 = Utility.getShort (buffer, offset + 20);
|
||||
unused = Utility.getShort (buffer, offset + 22);
|
||||
org = Utility.getLong (buffer, offset + 24);
|
||||
align = Utility.getLong (buffer, offset + 28);
|
||||
|
||||
numsex = buffer[offset + 32] & 0xFF;
|
||||
lcbank = buffer[offset + 33] & 0xFF;
|
||||
|
||||
segnum = Utility.getWord (buffer, offset + 34);
|
||||
segnum = Utility.getShort (buffer, offset + 34);
|
||||
|
||||
entry = Utility.getLong (buffer, offset + 36);
|
||||
|
||||
dispname = Utility.getWord (buffer, offset + 40);
|
||||
dispdata = Utility.getWord (buffer, offset + 42);
|
||||
dispname = Utility.getShort (buffer, offset + 40);
|
||||
dispdata = Utility.getShort (buffer, offset + 42);
|
||||
|
||||
decodeKind ();
|
||||
|
||||
@ -136,8 +136,8 @@ public class SegmentHeader
|
||||
int count1 = buffer[ptr + 1] & 0xFF;
|
||||
int count2 = buffer[ptr + 2] & 0xFF;
|
||||
int operandOffset = Utility.getLong (buffer, ptr + 3);
|
||||
int fileNo = Utility.getWord (buffer, ptr + 7);
|
||||
int segNo = Utility.getWord (buffer, ptr + 9);
|
||||
int fileNo = Utility.getShort (buffer, ptr + 7);
|
||||
int segNo = Utility.getShort (buffer, ptr + 9);
|
||||
int subroutineOffset = Utility.getLong (buffer, ptr + 11);
|
||||
if (debug)
|
||||
System.out.printf ("INTERSEG: %02X %02X %08X %04X %04X %08X%n", count1,
|
||||
@ -226,8 +226,8 @@ public class SegmentHeader
|
||||
case 0xF5: // cRELOC
|
||||
int cBytesRelocated = buffer[ptr + 1] & 0xFF;
|
||||
int cBitShift = buffer[ptr + 2] & 0xFF;
|
||||
int cSegmentOffset = Utility.getWord (buffer, ptr + 3);
|
||||
int cValue = Utility.getWord (buffer, ptr + 5);
|
||||
int cSegmentOffset = Utility.getShort (buffer, ptr + 3);
|
||||
int cValue = Utility.getShort (buffer, ptr + 5);
|
||||
if (debug)
|
||||
System.out.printf ("cRELOC: %02X %02X %08X %08X%n", cBytesRelocated,
|
||||
cBitShift, cSegmentOffset, cValue);
|
||||
@ -237,9 +237,9 @@ public class SegmentHeader
|
||||
case 0xF6: // cINTERSEG
|
||||
int cCount1 = buffer[ptr + 1] & 0xFF;
|
||||
int cCount2 = buffer[ptr + 2] & 0xFF;
|
||||
int cOperandOffset = Utility.getWord (buffer, ptr + 3);
|
||||
int cOperandOffset = Utility.getShort (buffer, ptr + 3);
|
||||
int cSegNo = buffer[ptr + 5] & 0xFF;
|
||||
int cSubroutineOffset = Utility.getWord (buffer, ptr + 6);
|
||||
int cSubroutineOffset = Utility.getShort (buffer, ptr + 6);
|
||||
if (debug)
|
||||
System.out.printf ("cINTERSEG: %02X %02X %04X %02X %04X%n", cCount1, cCount2,
|
||||
cOperandOffset, cSegNo, cSubroutineOffset);
|
||||
|
@ -39,7 +39,7 @@ class Shape
|
||||
int row = startRow;
|
||||
int col = startCol;
|
||||
|
||||
offset = Utility.unsignedShort (buffer, index * 2 + 2);
|
||||
offset = Utility.getShort (buffer, index * 2 + 2);
|
||||
|
||||
int ptr = offset;
|
||||
while (ptr < buffer.length)
|
||||
|
@ -128,7 +128,7 @@ public class ShapeTable extends AbstractFile
|
||||
return false;
|
||||
|
||||
// check index points inside the file
|
||||
int offset = Utility.unsignedShort (buffer, ptr);
|
||||
int offset = Utility.getShort (buffer, ptr);
|
||||
if (offset == 0 || offset >= buffer.length)
|
||||
return false;
|
||||
|
||||
|
@ -32,6 +32,13 @@ public class SimpleText extends AbstractFile
|
||||
if (ptr < buffer.length && buffer[ptr] == 0x0A)
|
||||
ptr++;
|
||||
}
|
||||
|
||||
if (resourceFork != null)
|
||||
{
|
||||
text.append ("\n\nResource Fork\n=============\n");
|
||||
text.append (resourceFork);
|
||||
}
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.ASCII_COLON;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.ASCII_QUOTE;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.unsignedShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.getShort;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -30,8 +30,8 @@ public class SourceLine implements ApplesoftConstants
|
||||
this.buffer = buffer;
|
||||
|
||||
linePtr = ptr;
|
||||
linkField = unsignedShort (buffer, ptr);
|
||||
lineNumber = unsignedShort (buffer, ptr + 2);
|
||||
linkField = getShort (buffer, ptr);
|
||||
lineNumber = getShort (buffer, ptr + 2);
|
||||
|
||||
int startPtr = ptr += 4; // skip link field and lineNumber
|
||||
boolean inString = false; // can toggle
|
||||
|
@ -26,10 +26,10 @@ public class StoredVariables extends AbstractFile
|
||||
int strPtr = buffer.length;
|
||||
|
||||
text.append ("File length : " + HexFormatter.format4 (buffer.length));
|
||||
int totalLength = Utility.unsignedShort (buffer, 0);
|
||||
int totalLength = Utility.getShort (buffer, 0);
|
||||
text.append ("\nTotal length : " + HexFormatter.format4 (totalLength));
|
||||
|
||||
int varLength = Utility.unsignedShort (buffer, 2);
|
||||
int varLength = Utility.getShort (buffer, 2);
|
||||
text.append ("\nVar length : " + HexFormatter.format4 (varLength));
|
||||
text.append ("\n\n");
|
||||
|
||||
@ -133,7 +133,7 @@ public class StoredVariables extends AbstractFile
|
||||
{
|
||||
String variableName = getVariableName (buffer[ptr], buffer[ptr + 1]);
|
||||
text.append ("\n");
|
||||
int offset = Utility.unsignedShort (buffer, ptr + 2);
|
||||
int offset = Utility.getShort (buffer, ptr + 2);
|
||||
int dimensions = buffer[ptr + 4] & 0xFF;
|
||||
int[] dimensionSizes = new int[dimensions];
|
||||
int totalElements = 0;
|
||||
@ -212,10 +212,10 @@ public class StoredVariables extends AbstractFile
|
||||
StringBuffer text = new StringBuffer ();
|
||||
|
||||
text.append ("File length : " + HexFormatter.format4 (buffer.length));
|
||||
int totalLength = Utility.unsignedShort (buffer, 0);
|
||||
int totalLength = Utility.getShort (buffer, 0);
|
||||
text.append ("\nTotal length : " + HexFormatter.format4 (totalLength));
|
||||
|
||||
int varLength = Utility.unsignedShort (buffer, 2);
|
||||
int varLength = Utility.getShort (buffer, 2);
|
||||
text.append ("\nVar length : " + HexFormatter.format4 (varLength));
|
||||
|
||||
int unknown = buffer[4] & 0xFF;
|
||||
@ -232,7 +232,7 @@ public class StoredVariables extends AbstractFile
|
||||
text.append ("\nArrays : \n\n");
|
||||
while (ptr < totalLength + 5)
|
||||
{
|
||||
int offset = Utility.unsignedShort (buffer, ptr + 2);
|
||||
int offset = Utility.getShort (buffer, ptr + 2);
|
||||
int dimensions = buffer[ptr + 4] & 0xFF;
|
||||
int[] dimensionSizes = new int[dimensions];
|
||||
int totalElements = 0;
|
||||
|
@ -52,7 +52,7 @@ public class AppleworksADBFile extends AbstractFile
|
||||
|
||||
dbMinVersion = buffer[218] & 0xFF;
|
||||
|
||||
headerSize = Utility.unsignedShort (buffer, 0);
|
||||
headerSize = Utility.getShort (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 = Utility.unsignedShort (buffer, 36);
|
||||
int recs = Utility.getShort (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] = Utility.unsignedShort (buffer, 223 + i * 2);
|
||||
testTypes[i] = Utility.unsignedShort (buffer, 229 + i * 2);
|
||||
continuation[i] = Utility.unsignedShort (buffer, 235 + i * 2);
|
||||
selectionRules[i] = Utility.getShort (buffer, 223 + i * 2);
|
||||
testTypes[i] = Utility.getShort (buffer, 229 + i * 2);
|
||||
continuation[i] = Utility.getShort (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 = Utility.unsignedShort (buffer, ptr);
|
||||
int length = Utility.getShort (buffer, ptr);
|
||||
ptr += 2;
|
||||
|
||||
if (length == 0)
|
||||
@ -118,7 +118,7 @@ public class AppleworksADBFile extends AbstractFile
|
||||
|
||||
for (int recordNo = 0; recordNo < totalRecords; recordNo++)
|
||||
{
|
||||
length = Utility.unsignedShort (buffer, ptr);
|
||||
length = Utility.getShort (buffer, ptr);
|
||||
ptr += 2;
|
||||
if (length == 0)
|
||||
break;
|
||||
|
@ -25,7 +25,7 @@ public class AppleworksSSFile extends AbstractFile
|
||||
int ptr = header.ssMinVers == 0 ? 300 : 302;
|
||||
while (ptr < buffer.length)
|
||||
{
|
||||
int length = Utility.unsignedShort (buffer, ptr);
|
||||
int length = Utility.getShort (buffer, ptr);
|
||||
|
||||
if (length == 0xFFFF)
|
||||
break;
|
||||
@ -103,7 +103,7 @@ public class AppleworksSSFile extends AbstractFile
|
||||
|
||||
calcOrder = (char) buffer[131];
|
||||
calcFrequency = (char) buffer[132];
|
||||
lastRow = Utility.unsignedShort (buffer, 133);
|
||||
lastRow = Utility.getShort (buffer, 133);
|
||||
lastColumn = buffer[135] & 0xFF;
|
||||
windowLayout = (char) buffer[136];
|
||||
windowSynch = buffer[137] != 0;
|
||||
@ -204,15 +204,15 @@ public class AppleworksSSFile extends AbstractFile
|
||||
|
||||
r1 = buffer[offset + 3] & 0xFF;
|
||||
c1 = buffer[offset + 4] & 0xFF;
|
||||
r2 = Utility.unsignedShort (buffer, offset + 5);
|
||||
r2 = Utility.getShort (buffer, offset + 5);
|
||||
c2 = buffer[offset + 7] & 0xFF;
|
||||
r3 = Utility.unsignedShort (buffer, offset + 8);
|
||||
r3 = Utility.getShort (buffer, offset + 8);
|
||||
c3 = buffer[offset + 10] & 0xFF;
|
||||
r4 = Utility.unsignedShort (buffer, offset + 11);
|
||||
r4 = Utility.getShort (buffer, offset + 11);
|
||||
c4 = buffer[offset + 13] & 0xFF;
|
||||
r5 = buffer[offset + 14] & 0xFF;
|
||||
c5 = buffer[offset + 15] & 0xFF;
|
||||
r6 = Utility.unsignedShort (buffer, offset + 16);
|
||||
r6 = Utility.getShort (buffer, offset + 16);
|
||||
c6 = buffer[offset + 18] & 0xFF;
|
||||
r7 = buffer[offset + 19] & 0xFF;
|
||||
c7 = buffer[offset + 20] & 0xFF;
|
||||
@ -265,7 +265,7 @@ public class AppleworksSSFile extends AbstractFile
|
||||
|
||||
public Row (int ptr)
|
||||
{
|
||||
rowNumber = Utility.unsignedShort (buffer, ptr);
|
||||
rowNumber = Utility.getShort (buffer, ptr);
|
||||
ptr += 2; // first control byte
|
||||
|
||||
int column = 0;
|
||||
|
@ -14,7 +14,7 @@ class CellAddress
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
colRef = buffer[offset];
|
||||
rowRef = Utility.unsignedShort (buffer, offset + 1);
|
||||
rowRef = Utility.getShort (buffer, offset + 1);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -131,9 +131,9 @@ abstract class Report
|
||||
if (buffer[offset + 480 + fudge] == 0) // test high byte
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
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);
|
||||
selectionRules[i] = Utility.getShort (buffer, offset + 479 + i * 2 + fudge);
|
||||
testTypes[i] = Utility.getShort (buffer, offset + 485 + i * 2 + fudge);
|
||||
continuation[i] = Utility.getShort (buffer, offset + 491 + i * 2 + fudge);
|
||||
comparison[i] = pascalString (buffer, offset + 497 + i * 32 + fudge);
|
||||
}
|
||||
else
|
||||
|
@ -56,6 +56,14 @@ public abstract class AbstractSector implements DataSource
|
||||
return HexFormatter.format (buffer, 0, buffer.length);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public byte[] getBuffer ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public BufferedImage getImage ()
|
||||
|
@ -48,6 +48,14 @@ public class DefaultDataSource implements DataSource
|
||||
return null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public byte[] getBuffer ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public BufferedImage getImage ()
|
||||
|
@ -59,6 +59,9 @@ public class DiskFactory
|
||||
if (debug)
|
||||
System.out.println ("\nFactory : " + pathName);
|
||||
|
||||
nuFX = null;
|
||||
binary2 = null;
|
||||
|
||||
File file = new File (pathName);
|
||||
if (!file.exists ())
|
||||
return null;
|
||||
@ -168,9 +171,12 @@ public class DiskFactory
|
||||
catch (Exception e)
|
||||
{
|
||||
// e.printStackTrace ();
|
||||
System.out.println (e.getMessage ());
|
||||
if (e.getMessage () == null)
|
||||
System.out.println (e);
|
||||
else
|
||||
System.out.println (e.getMessage ());
|
||||
System.out.printf ("Error unpacking: %s%n", file.getAbsolutePath ());
|
||||
System.out.println (nuFX);
|
||||
// System.out.println (nuFX);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -198,7 +204,7 @@ public class DiskFactory
|
||||
// e.printStackTrace ();
|
||||
System.out.println (e.getMessage ());
|
||||
System.out.printf ("Error unpacking: %s%n", file.getAbsolutePath ());
|
||||
System.out.println (binary2);
|
||||
// System.out.println (binary2);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -705,6 +711,7 @@ public class DiskFactory
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println (e);
|
||||
e.printStackTrace ();
|
||||
System.out.println ("Prodos hard disk had error");
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,8 @@ public class Prefix2mg
|
||||
{
|
||||
prefix = new String (buffer, 0, 4);
|
||||
creator = new String (buffer, 4, 4);
|
||||
headerSize = Utility.getWord (buffer, 0x08);
|
||||
version = Utility.getWord (buffer, 0x0A);
|
||||
headerSize = Utility.getShort (buffer, 0x08);
|
||||
version = Utility.getShort (buffer, 0x0A);
|
||||
format = Utility.getLong (buffer, 0x0C);
|
||||
flags = Utility.getLong (buffer, 0x10);
|
||||
blocks = Utility.getLong (buffer, 0x14); // 1600
|
||||
|
@ -67,7 +67,7 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
||||
this.catalogSectorDA = catalogSector;
|
||||
|
||||
name = getName ("", entryBuffer);
|
||||
reportedSize = Utility.unsignedShort (entryBuffer, 33);
|
||||
reportedSize = Utility.getShort (entryBuffer, 33);
|
||||
|
||||
int type = entryBuffer[2] & 0x7F;
|
||||
locked = (entryBuffer[2] & 0x80) != 0;
|
||||
@ -234,14 +234,14 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
||||
break;
|
||||
|
||||
case IntegerBasic:
|
||||
reportedLength = Utility.unsignedShort (buffer, 0);
|
||||
reportedLength = Utility.getShort (buffer, 0);
|
||||
exactBuffer = new byte[reportedLength];
|
||||
System.arraycopy (buffer, 2, exactBuffer, 0, reportedLength);
|
||||
appleFile = new IntegerBasicProgram (name, exactBuffer);
|
||||
break;
|
||||
|
||||
case ApplesoftBasic:
|
||||
reportedLength = Utility.unsignedShort (buffer, 0);
|
||||
reportedLength = Utility.getShort (buffer, 0);
|
||||
exactBuffer = new byte[reportedLength];
|
||||
if (reportedLength > buffer.length)
|
||||
reportedLength = buffer.length - 2;
|
||||
@ -252,8 +252,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
||||
case Binary: // binary file
|
||||
case Relocatable: // relocatable binary file
|
||||
case BB:
|
||||
int loadAddress = Utility.unsignedShort (buffer, 0);
|
||||
reportedLength = Utility.unsignedShort (buffer, 2);
|
||||
int loadAddress = Utility.getShort (buffer, 0);
|
||||
reportedLength = Utility.getShort (buffer, 2);
|
||||
if (reportedLength == 0)
|
||||
{
|
||||
System.out.println (name.trim () + " reported length : 0 - reverting to "
|
||||
@ -359,7 +359,7 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
||||
{
|
||||
byte[] exactBuffer;
|
||||
|
||||
int reportedLength = Utility.unsignedShort (buffer, 2);
|
||||
int reportedLength = Utility.getShort (buffer, 2);
|
||||
if (reportedLength == 0)
|
||||
{
|
||||
System.out.println (
|
||||
|
@ -131,12 +131,12 @@ class CatalogEntry extends AbstractCatalogEntry
|
||||
{
|
||||
case IntegerBasic:
|
||||
case ApplesoftBasic:
|
||||
length = Utility.unsignedShort (buffer, 0);
|
||||
length = Utility.getShort (buffer, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
address = Utility.unsignedShort (buffer, 0);
|
||||
length = Utility.unsignedShort (buffer, 2);
|
||||
address = Utility.getShort (buffer, 0);
|
||||
length = Utility.getShort (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.unsignedShort (buffer, 5);
|
||||
int sectorBase = Utility.getShort (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.unsignedShort (buffer, 54);
|
||||
sectorSize = Utility.getShort (buffer, 54);
|
||||
|
||||
flagSectors ();
|
||||
}
|
||||
|
@ -17,4 +17,6 @@ public interface DataSource
|
||||
public BufferedImage getImage ();
|
||||
|
||||
public JComponent getComponent ();
|
||||
|
||||
public byte[] getBuffer ();
|
||||
}
|
@ -79,6 +79,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||
|
||||
FormattedDisk currentDisk;
|
||||
private final SaveTempFileAction saveTempFileAction = new SaveTempFileAction ();
|
||||
private final SaveSingleFileAction saveSingleFileAction = new SaveSingleFileAction ();
|
||||
final SaveSectorsAction saveSectorsAction = new SaveSectorsAction ();
|
||||
|
||||
private final BasicPreferences basicPreferences = new BasicPreferences ();
|
||||
@ -115,6 +116,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||
final JMenuItem refreshTreeItem = new JMenuItem ("Refresh current tree");
|
||||
final JMenuItem executeDiskItem = new JMenuItem ();
|
||||
final JMenuItem saveDiskItem = new JMenuItem ("Save converted disk as...");
|
||||
final JMenuItem saveFileItem = new JMenuItem ("Save file...");
|
||||
final JMenuItem saveSectorsItem = new JMenuItem ("Save sectors as...");
|
||||
final JMenuItem printItem = new JMenuItem ("Print output panel...");
|
||||
final JMenuItem closeTabItem = new JMenuItem ();
|
||||
@ -162,7 +164,8 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||
final JMenuItem blankAfterReturnItem =
|
||||
new JCheckBoxMenuItem ("Blank line after RETURN");
|
||||
final JMenuItem formatRemItem = new JCheckBoxMenuItem ("Allow formatted REM");
|
||||
// final JMenuItem deleteExtraRemSpace = new JCheckBoxMenuItem ("Delete extra REM space");
|
||||
// final JMenuItem deleteExtraRemSpace =
|
||||
// new JCheckBoxMenuItem ("Delete extra REM space");
|
||||
final JMenuItem deleteExtraDataSpace =
|
||||
new JCheckBoxMenuItem ("Delete extra DATA space");
|
||||
|
||||
@ -207,6 +210,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||
fileMenu.addSeparator ();
|
||||
fileMenu.add (refreshTreeItem);
|
||||
fileMenu.add (saveDiskItem);
|
||||
fileMenu.add (saveFileItem);
|
||||
fileMenu.add (saveSectorsItem);
|
||||
|
||||
addLauncherMenu ();
|
||||
@ -384,6 +388,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||
scaleGroup.add (scale3Item);
|
||||
|
||||
saveDiskItem.setAction (saveTempFileAction);
|
||||
saveFileItem.setAction (saveSingleFileAction);
|
||||
saveSectorsItem.setAction (saveSectorsAction);
|
||||
|
||||
KeyStroke keyStroke1 = KeyStroke.getKeyStroke (KeyEvent.VK_S, KeyEvent.ALT_DOWN_MASK);
|
||||
@ -717,6 +722,8 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||
currentDisk = event.appleFileSource.getFormattedDisk ();
|
||||
adjustMenus (currentDisk);
|
||||
}
|
||||
|
||||
saveSingleFileAction.setFile (event.appleFileSource);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -766,6 +773,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||
|
||||
saveDiskItem.setEnabled (disk.isTempDisk ());
|
||||
saveTempFileAction.setDisk (disk);
|
||||
// saveSingleFileAction.setDisk (disk);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -21,7 +21,7 @@ class SaveSectorsAction extends DefaultAction implements SectorSelectionListener
|
||||
SaveSectorsAction ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Save sectors...", "Save sectors");
|
||||
super ("Save sectors...", "Save currently selected sectors");
|
||||
this.setEnabled (false);
|
||||
}
|
||||
|
||||
|
65
src/com/bytezone/diskbrowser/gui/SaveSingleFileAction.java
Normal file
65
src/com/bytezone/diskbrowser/gui/SaveSingleFileAction.java
Normal file
@ -0,0 +1,65 @@
|
||||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
||||
import com.bytezone.diskbrowser.utilities.DefaultAction;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class SaveSingleFileAction extends DefaultAction
|
||||
//-----------------------------------------------------------------------------------//
|
||||
{
|
||||
AppleFileSource appleFileSource;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
SaveSingleFileAction ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Save file...", "Save currently selected file");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent evt)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (appleFileSource == null)
|
||||
{
|
||||
System.out.println ("No data source");
|
||||
return;
|
||||
}
|
||||
|
||||
JFileChooser fileChooser = new JFileChooser ();
|
||||
fileChooser.setDialogTitle ("Save File");
|
||||
fileChooser.setSelectedFile (new File (appleFileSource.getUniqueName () + ".bin"));
|
||||
|
||||
if (fileChooser.showSaveDialog (null) == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
File file = fileChooser.getSelectedFile ();
|
||||
try
|
||||
{
|
||||
Files.write (file.toPath (), appleFileSource.getDataSource ().getBuffer (),
|
||||
StandardOpenOption.CREATE_NEW);
|
||||
JOptionPane.showMessageDialog (null, "File saved");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void setFile (AppleFileSource dataSource)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
this.appleFileSource = dataSource;
|
||||
}
|
||||
}
|
@ -108,7 +108,7 @@ class TreeBuilder
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class FileNode implements DataSource // why does it implement DataSource?
|
||||
class FileNode implements DataSource
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
private static final int MAX_NAME_LENGTH = 36;
|
||||
@ -253,6 +253,14 @@ class TreeBuilder
|
||||
return null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public byte[] getBuffer ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public JComponent getComponent ()
|
||||
|
@ -32,11 +32,11 @@ abstract class CatalogEntry implements AppleFileSource
|
||||
{
|
||||
this.parent = parent;
|
||||
|
||||
firstBlock = Utility.unsignedShort (buffer, 0);
|
||||
lastBlock = Utility.unsignedShort (buffer, 2);
|
||||
firstBlock = Utility.getShort (buffer, 0);
|
||||
lastBlock = Utility.getShort (buffer, 2);
|
||||
fileType = buffer[4] & 0xFF;
|
||||
name = HexFormatter.getPascalString (buffer, 6);
|
||||
bytesUsedInLastBlock = Utility.unsignedShort (buffer, 16);
|
||||
bytesUsedInLastBlock = Utility.getShort (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.unsignedShort (buffer, 22);
|
||||
bytesUsedInLastBlock = Utility.getShort (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.unsignedShort (buffer, 16);
|
||||
int totalFiles = Utility.getShort (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.unsignedShort (buffer, 0);
|
||||
int to = Utility.unsignedShort (buffer, 2);
|
||||
int from = Utility.getShort (buffer, 0);
|
||||
int to = Utility.getShort (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.unsignedShort (buffer, 14);
|
||||
int blocks = Utility.getShort (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.unsignedShort (buffer, 16);
|
||||
int files = Utility.getShort (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.unsignedShort (buffer, ptr);
|
||||
int lastBlock = Utility.unsignedShort (buffer, ptr + 2);
|
||||
int kind = Utility.unsignedShort (buffer, ptr + 4);
|
||||
int firstBlock = Utility.getShort (buffer, ptr);
|
||||
int lastBlock = Utility.getShort (buffer, ptr + 2);
|
||||
int kind = Utility.getShort (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.unsignedShort (buffer, ptr + 22);
|
||||
int lastByte = Utility.getShort (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.unsignedShort (buffer, 14); // 280
|
||||
totalFiles = Utility.unsignedShort (buffer, 16);
|
||||
totalBlocks = Utility.getShort (buffer, 14); // 280
|
||||
totalFiles = Utility.getShort (buffer, 16);
|
||||
date = HexFormatter.getPascalDate (buffer, 20); // 2 bytes
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ public abstract class DirectoryHeader extends CatalogEntry implements ProdosCons
|
||||
|
||||
entryLength = entryBuffer[31] & 0xFF;
|
||||
entriesPerBlock = entryBuffer[32] & 0xFF;
|
||||
fileCount = Utility.unsignedShort (entryBuffer, 33);
|
||||
fileCount = Utility.getShort (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.unsignedShort (buffer, ptr + 0x13);
|
||||
int blocksUsed = Utility.getShort (buffer, ptr + 0x13);
|
||||
int fileType = buffer[ptr + 0x10] & 0xFF;
|
||||
int keyPointer = Utility.unsignedShort (buffer, ptr + 0x11);
|
||||
int headerPointer = Utility.unsignedShort (buffer, ptr + 0x25);
|
||||
int keyPointer = Utility.getShort (buffer, ptr + 0x11);
|
||||
int headerPointer = Utility.getShort (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.unsignedShort (buffer, 2);
|
||||
blockNo = Utility.getShort (buffer, 2);
|
||||
} while (blockNo != 0);
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.applefile.ApplesoftBasicProgram;
|
||||
import com.bytezone.diskbrowser.applefile.AssemblerProgram;
|
||||
import com.bytezone.diskbrowser.applefile.BasicProgramGS;
|
||||
@ -30,7 +31,6 @@ import com.bytezone.diskbrowser.applefile.OriginalHiResImage;
|
||||
import com.bytezone.diskbrowser.applefile.PascalArea;
|
||||
import com.bytezone.diskbrowser.applefile.ProdosDirectory;
|
||||
import com.bytezone.diskbrowser.applefile.QuickDrawFont;
|
||||
import com.bytezone.diskbrowser.applefile.ResourceFork;
|
||||
import com.bytezone.diskbrowser.applefile.SHRPictureFile1;
|
||||
import com.bytezone.diskbrowser.applefile.SHRPictureFile2;
|
||||
import com.bytezone.diskbrowser.applefile.Selector;
|
||||
@ -62,6 +62,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
private final int headerPointer;
|
||||
private DataSource file;
|
||||
private final DiskAddress catalogBlock;
|
||||
private ResourceFork resourceFork;
|
||||
|
||||
private DiskAddress masterIndexBlock;
|
||||
private final List<DiskAddress> indexBlocks = new ArrayList<> ();
|
||||
@ -81,13 +82,13 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
this.catalogBlock = this.disk.getDiskAddress (parentBlock);
|
||||
|
||||
fileType = entryBuffer[0x10] & 0xFF;
|
||||
keyPtr = Utility.unsignedShort (entryBuffer, 0x11);
|
||||
blocksUsed = Utility.unsignedShort (entryBuffer, 0x13);
|
||||
keyPtr = Utility.getShort (entryBuffer, 0x11);
|
||||
blocksUsed = Utility.getShort (entryBuffer, 0x13);
|
||||
endOfFile = Utility.intValue (entryBuffer[21], entryBuffer[22], entryBuffer[23]);
|
||||
|
||||
auxType = Utility.unsignedShort (entryBuffer, 0x1F);
|
||||
auxType = Utility.getShort (entryBuffer, 0x1F);
|
||||
modified = Utility.getAppleDate (entryBuffer, 0x21);
|
||||
headerPointer = Utility.unsignedShort (entryBuffer, 0x25);
|
||||
headerPointer = Utility.getShort (entryBuffer, 0x25);
|
||||
|
||||
switch (storageType)
|
||||
{
|
||||
@ -110,7 +111,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
break;
|
||||
dataBlocks.add (diskAddress);
|
||||
byte[] buffer = disk.readBlock (block);
|
||||
block = Utility.unsignedShort (buffer, 2);
|
||||
block = Utility.getShort (buffer, 2);
|
||||
} while (block > 0);
|
||||
break;
|
||||
|
||||
@ -140,7 +141,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
for (int i = 0; i < 512; i += 256)
|
||||
{
|
||||
int storageType = buffer2[i] & 0x0F;
|
||||
int keyBlock = Utility.unsignedShort (buffer2, i + 1);
|
||||
int keyBlock = Utility.getShort (buffer2, i + 1);
|
||||
int eof = Utility.readTriple (buffer2, i + 3);
|
||||
|
||||
if (i < 256)
|
||||
@ -149,7 +150,10 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
addDataBlocks (storageType, keyBlock, resourceBlocks);
|
||||
}
|
||||
|
||||
ResourceFork fork = new ResourceFork (disk.readBlocks (resourceBlocks));
|
||||
resourceFork = new ResourceFork (disk.readBlocks (resourceBlocks));
|
||||
|
||||
if (!resourceFork.isValid ())
|
||||
System.out.printf ("Invalid Resource Fork: %s%n", name);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -554,6 +558,9 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
e.printStackTrace ();
|
||||
}
|
||||
|
||||
if (resourceFork != null)
|
||||
((AbstractFile) file).setResourceFork (resourceFork);
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ class ProdosCatalogSector extends AbstractSector
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
int fileType = buffer[offset + 16] & 0xFF;
|
||||
int auxType = Utility.unsignedShort (buffer, offset + 31);
|
||||
int auxType = Utility.getShort (buffer, offset + 31);
|
||||
addText (text, buffer, offset + 16, 1,
|
||||
"File type (" + ProdosConstants.fileTypes[fileType] + ")");
|
||||
addTextAndDecimal (text, buffer, offset + 17, 2, "Key pointer");
|
||||
|
@ -180,7 +180,7 @@ public class ProdosDisk extends AbstractFormattedDisk
|
||||
System.out.println (HexFormatter.format (entry, 0, entry.length));
|
||||
}
|
||||
}
|
||||
block = Utility.unsignedShort (sectorBuffer, 2);
|
||||
block = Utility.getShort (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.unsignedShort (buffer, 0x27);
|
||||
int bitMapBlock = Utility.getShort (buffer, 0x27);
|
||||
if (bitMapBlock < 3 || bitMapBlock > 10)
|
||||
return false;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
package com.bytezone.diskbrowser.prodos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -10,6 +10,14 @@ import com.bytezone.diskbrowser.utilities.Utility;
|
||||
public class ResourceFork
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static String[] resourceTypes =
|
||||
{ "", "rIcon", "rPicture", "rControlList", "rControlTemplate", "rC1InputString",
|
||||
"rPString", "rStringList", "rMenuBar", "rMenu", "rMenuItem", "rTextForLETextBox2",
|
||||
"", "rCt1lColorTbl", "rWindParaml", "rWindParam2", "rWindColor", "rTextBlock",
|
||||
"rStyleBlock", "rToolStartup", "rResName", "rAlertString", "rText", "", "", "",
|
||||
"rTwoRects", "", "rListRef", "rcString", "", "", "rErrorString", "rKTransTable",
|
||||
"", "rCloutputString", "", "rTERuler", "", "", "", "", "" };
|
||||
|
||||
byte[] buffer;
|
||||
ResourceFileHeader resourceFileHeader;
|
||||
|
||||
@ -20,7 +28,19 @@ public class ResourceFork
|
||||
this.buffer = buffer;
|
||||
|
||||
resourceFileHeader = new ResourceFileHeader (buffer);
|
||||
System.out.println (resourceFileHeader);
|
||||
}
|
||||
|
||||
public boolean isValid ()
|
||||
{
|
||||
return resourceFileHeader.resourceMap != null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return resourceFileHeader.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -40,7 +60,8 @@ public class ResourceFork
|
||||
fileToMap = Utility.getLong (buffer, 4);
|
||||
fileMapSize = Utility.getLong (buffer, 8);
|
||||
|
||||
resourceMap = new ResourceMap (buffer, fileToMap, fileMapSize);
|
||||
if (fileVersion == 0)
|
||||
resourceMap = new ResourceMap (buffer, fileToMap, fileMapSize);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------//
|
||||
@ -83,17 +104,23 @@ public class ResourceFork
|
||||
{
|
||||
int offset = ptr;
|
||||
|
||||
if (ptr > buffer.length)
|
||||
{
|
||||
System.out.println ("bad");
|
||||
return;
|
||||
}
|
||||
|
||||
mapNext = Utility.getLong (buffer, ptr);
|
||||
mapFlags = Utility.getWord (buffer, ptr + 4);
|
||||
mapFlags = Utility.getShort (buffer, ptr + 4);
|
||||
mapOffset = Utility.getLong (buffer, ptr + 6);
|
||||
mapSize = Utility.getLong (buffer, ptr + 10);
|
||||
mapToIndex = Utility.getWord (buffer, ptr + 14);
|
||||
mapFileNum = Utility.getWord (buffer, ptr + 16);
|
||||
mapId = Utility.getWord (buffer, ptr + 18);
|
||||
mapToIndex = Utility.getShort (buffer, ptr + 14);
|
||||
mapFileNum = Utility.getShort (buffer, ptr + 16);
|
||||
mapId = Utility.getShort (buffer, ptr + 18);
|
||||
mapIndexSize = Utility.getLong (buffer, ptr + 20);
|
||||
mapIndexUsed = Utility.getLong (buffer, ptr + 24);
|
||||
mapFreeListSize = Utility.getWord (buffer, ptr + 28);
|
||||
mapFreeListUsed = Utility.getWord (buffer, ptr + 30);
|
||||
mapFreeListSize = Utility.getShort (buffer, ptr + 28);
|
||||
mapFreeListUsed = Utility.getShort (buffer, ptr + 30);
|
||||
|
||||
ptr = offset + 32;
|
||||
for (int i = 0; i < mapFreeListUsed; i++)
|
||||
@ -188,10 +215,10 @@ public class ResourceFork
|
||||
public ResourceReferenceRecord (byte[] buffer, int ptr)
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
resType = Utility.getWord (buffer, ptr);
|
||||
resType = Utility.getShort (buffer, ptr);
|
||||
resId = Utility.getLong (buffer, ptr + 2);
|
||||
resOffset = Utility.getLong (buffer, ptr + 6);
|
||||
resAttr = Utility.getWord (buffer, ptr + 10);
|
||||
resAttr = Utility.getShort (buffer, ptr + 10);
|
||||
resSize = Utility.getLong (buffer, ptr + 12);
|
||||
resHandle = Utility.getLong (buffer, ptr + 16);
|
||||
|
||||
@ -206,7 +233,13 @@ public class ResourceFork
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
text.append (String.format ("Type .......... %04X%n", resType));
|
||||
String resourceTypeText = "";
|
||||
int index = resType & 0xFF;
|
||||
if (resType > 0x8000 && index < resourceTypes.length)
|
||||
resourceTypeText = resourceTypes[index];
|
||||
|
||||
text.append (
|
||||
String.format ("Type .......... %04X %s%n", resType, resourceTypeText));
|
||||
text.append (String.format ("ID ............ %04X %<d%n", resId));
|
||||
text.append (String.format ("Offset ........ %04X %<d%n", resOffset));
|
||||
text.append (String.format ("Attr .......... %04X %<d%n", resAttr));
|
@ -26,7 +26,7 @@ public class SubDirectoryHeader extends DirectoryHeader
|
||||
this.parentDirectory = parent.parentDirectory;
|
||||
this.blockNo = blockNo;
|
||||
|
||||
parentPointer = Utility.unsignedShort (entryBuffer, 35);
|
||||
parentPointer = Utility.getShort (entryBuffer, 35);
|
||||
parentSequence = entryBuffer[37] & 0xFF;
|
||||
parentSize = entryBuffer[38] & 0xFF;
|
||||
|
||||
|
@ -24,8 +24,8 @@ public class VolumeDirectoryHeader extends DirectoryHeader
|
||||
{
|
||||
super (parentDisk, entryBuffer, 2, 1);
|
||||
|
||||
bitMapBlock = Utility.unsignedShort (entryBuffer, 35);
|
||||
totalBlocks = Utility.unsignedShort (entryBuffer, 37);
|
||||
bitMapBlock = Utility.getShort (entryBuffer, 35);
|
||||
totalBlocks = Utility.getShort (entryBuffer, 37);
|
||||
|
||||
totalBitMapBlocks = (totalBlocks - 1) / BLOCK_SIZE + 1;
|
||||
|
||||
@ -34,7 +34,7 @@ public class VolumeDirectoryHeader extends DirectoryHeader
|
||||
{
|
||||
dataBlocks.add (disk.getDiskAddress (block));
|
||||
byte[] buffer = disk.readBlock (block);
|
||||
block = Utility.unsignedShort (buffer, 2);
|
||||
block = Utility.getShort (buffer, 2);
|
||||
} while (block > 0);
|
||||
|
||||
// convert the Free Sector Table
|
||||
@ -88,7 +88,7 @@ public class VolumeDirectoryHeader extends DirectoryHeader
|
||||
{
|
||||
byte[] buf = disk.readBlock (block);
|
||||
blockList.add (buf);
|
||||
block = Utility.unsignedShort (buf, 2); // next block
|
||||
block = Utility.getShort (buf, 2); // next block
|
||||
} while (block > 0);
|
||||
|
||||
byte[] fullBuffer = new byte[blockList.size () * 507];
|
||||
|
@ -4,8 +4,8 @@ import static com.bytezone.diskbrowser.prodos.ProdosConstants.BLOCK_SIZE;
|
||||
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.getShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.putAppleDate;
|
||||
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 = unsignedShort (buffer, ptr + 0x21);
|
||||
fileCount = getShort (buffer, ptr + 0x21);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -98,7 +98,7 @@ public class DirectoryHeader
|
||||
|
||||
ptr += ENTRY_SIZE;
|
||||
}
|
||||
blockNo = unsignedShort (buffer, offset + 2);
|
||||
blockNo = getShort (buffer, offset + 2);
|
||||
} while (blockNo > 0);
|
||||
System.out.println ();
|
||||
}
|
||||
|
@ -105,8 +105,8 @@ public class ExtendedKeyBlock
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
storageType = buffer[ptr];
|
||||
keyBlock = Utility.unsignedShort (buffer, ptr + 1);
|
||||
blocksUsed = Utility.unsignedShort (buffer, ptr + 3);
|
||||
keyBlock = Utility.getShort (buffer, ptr + 1);
|
||||
blocksUsed = Utility.getShort (buffer, ptr + 3);
|
||||
eof = Utility.readTriple (buffer, ptr + 5);
|
||||
}
|
||||
|
||||
|
@ -4,9 +4,9 @@ import static com.bytezone.diskbrowser.prodos.ProdosConstants.BLOCK_SIZE;
|
||||
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.getShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.putAppleDate;
|
||||
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 = unsignedShort (buffer, ptr + 0x11);
|
||||
blocksUsed = unsignedShort (buffer, ptr + 0x13);
|
||||
keyPointer = getShort (buffer, ptr + 0x11);
|
||||
blocksUsed = getShort (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 = unsignedShort (buffer, ptr + 0x1F);
|
||||
auxType = getShort (buffer, ptr + 0x1F);
|
||||
modifiedDate = getAppleDate (buffer, ptr + 0x21);
|
||||
headerPointer = unsignedShort (buffer, ptr + 0x25);
|
||||
headerPointer = getShort (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.unsignedShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.getShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.writeShort;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
@ -370,7 +370,7 @@ public class ProdosDisk
|
||||
|
||||
ptr += ENTRY_SIZE;
|
||||
}
|
||||
blockNo = unsignedShort (buffer, offset + 2);
|
||||
blockNo = getShort (buffer, offset + 2);
|
||||
} while (blockNo > 0);
|
||||
|
||||
return Optional.empty ();
|
||||
@ -477,7 +477,7 @@ public class ProdosDisk
|
||||
}
|
||||
|
||||
lastBlockNo = blockNo;
|
||||
blockNo = unsignedShort (buffer, offset + 2); // next block
|
||||
blockNo = getShort (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.unsignedShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.getShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.writeShort;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@ -63,7 +63,7 @@ public class SubdirectoryHeader extends DirectoryHeader
|
||||
{
|
||||
super.read ();
|
||||
|
||||
parentPointer = unsignedShort (buffer, ptr + 0x23);
|
||||
parentPointer = getShort (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.unsignedShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.getShort;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.writeShort;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
@ -26,8 +26,8 @@ public class VolumeDirectoryHeader extends DirectoryHeader
|
||||
{
|
||||
super.read ();
|
||||
|
||||
bitMapPointer = unsignedShort (buffer, ptr + 0x23);
|
||||
totalBlocks = unsignedShort (buffer, ptr + 0x25);
|
||||
bitMapPointer = getShort (buffer, ptr + 0x23);
|
||||
totalBlocks = getShort (buffer, ptr + 0x25);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -57,9 +57,9 @@ public class Binary2Header
|
||||
|
||||
accessCode = buffer[ptr + 3] & 0xFF;
|
||||
fileType = buffer[ptr + 4];
|
||||
auxType = Utility.unsignedShort (buffer, ptr + 5);
|
||||
auxType = Utility.getShort (buffer, ptr + 5);
|
||||
storageType = buffer[ptr + 7] & 0xFF;
|
||||
totalBlocks = Utility.unsignedShort (buffer, ptr + 8);
|
||||
totalBlocks = Utility.getShort (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.unsignedShort (buffer, ptr + 114);
|
||||
prodos16totalBlocks = Utility.getShort (buffer, ptr + 114);
|
||||
prodos16eof = buffer[ptr + 116] & 0xFF;
|
||||
diskSpaceRequired = Utility.getLong (buffer, ptr + 117);
|
||||
osType = buffer[ptr + 121] & 0xFF;
|
||||
nativeFileType = Utility.unsignedShort (buffer, ptr + 122);
|
||||
nativeFileType = Utility.getShort (buffer, ptr + 122);
|
||||
phantomFileFlag = buffer[ptr + 124] & 0xFF;
|
||||
dataFlags = buffer[ptr + 125] & 0xFF;
|
||||
version = buffer[ptr + 126] & 0xFF;
|
||||
|
@ -17,7 +17,7 @@ class LZW1 extends LZW
|
||||
void unpack ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
crc = Utility.getWord (buffer, 0);
|
||||
crc = Utility.getShort (buffer, 0);
|
||||
crcBase = 0;
|
||||
|
||||
volume = buffer[2] & 0xFF;
|
||||
@ -26,7 +26,7 @@ class LZW1 extends LZW
|
||||
|
||||
while (ptr < buffer.length - 2)
|
||||
{
|
||||
int rleLength = Utility.getWord (buffer, ptr);
|
||||
int rleLength = Utility.getShort (buffer, ptr);
|
||||
boolean lzwPerformed = (buffer[ptr + 2] & 0xFF) != 0;
|
||||
ptr += 3;
|
||||
|
||||
|
@ -32,7 +32,7 @@ class LZW2 extends LZW
|
||||
|
||||
while (ptr < buffer.length - 1)
|
||||
{
|
||||
int rleLength = Utility.getWord (buffer, ptr);
|
||||
int rleLength = Utility.getShort (buffer, ptr);
|
||||
boolean lzwPerformed = (rleLength & 0x8000) != 0;
|
||||
ptr += 2;
|
||||
|
||||
@ -42,7 +42,7 @@ class LZW2 extends LZW
|
||||
if (rleLength == 0)
|
||||
rleLength = TRACK_LENGTH;
|
||||
|
||||
int chunkLength = Utility.getWord (buffer, ptr);
|
||||
int chunkLength = Utility.getShort (buffer, ptr);
|
||||
ptr += 2;
|
||||
|
||||
setBuffer (ptr); // prepare to read n-bit integers
|
||||
|
@ -38,6 +38,7 @@ class MasterHeader
|
||||
// bin2 = true;
|
||||
// break;
|
||||
// }
|
||||
|
||||
if (isBin2 (buffer, ptr))
|
||||
{
|
||||
binary2Header = new Binary2Header (buffer, 0);
|
||||
@ -56,15 +57,16 @@ class MasterHeader
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println (HexFormatter.format (buffer, 0, 256));
|
||||
throw new FileFormatException ("NuFile not found");
|
||||
}
|
||||
|
||||
crc = Utility.getWord (buffer, ptr + 6);
|
||||
crc = Utility.getShort (buffer, ptr + 6);
|
||||
totalRecords = Utility.getLong (buffer, ptr + 8);
|
||||
created = new DateTime (buffer, ptr + 12);
|
||||
modified = new DateTime (buffer, ptr + 20);
|
||||
version = Utility.getWord (buffer, ptr + 28);
|
||||
reserved = Utility.getWord (buffer, ptr + 30);
|
||||
version = Utility.getShort (buffer, ptr + 28);
|
||||
reserved = Utility.getShort (buffer, ptr + 30);
|
||||
eof = Utility.getLong (buffer, ptr + 38);
|
||||
|
||||
// assert reserved == 0;
|
||||
|
@ -80,8 +80,6 @@ public class NuFX
|
||||
if (record.hasDisk ())
|
||||
++totalDisks;
|
||||
}
|
||||
|
||||
// listFiles ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -49,21 +49,21 @@ class Record
|
||||
if (!Utility.isMagic (buffer, dataPtr, NuFX))
|
||||
throw new FileFormatException ("NuFX not found");
|
||||
|
||||
crc = Utility.getWord (buffer, dataPtr + 4);
|
||||
attributes = Utility.getWord (buffer, dataPtr + 6);
|
||||
version = Utility.getWord (buffer, dataPtr + 8);
|
||||
crc = Utility.getShort (buffer, dataPtr + 4);
|
||||
attributes = Utility.getShort (buffer, dataPtr + 6);
|
||||
version = Utility.getShort (buffer, dataPtr + 8);
|
||||
totThreads = Utility.getLong (buffer, dataPtr + 10);
|
||||
fileSystemID = Utility.getWord (buffer, dataPtr + 14);
|
||||
fileSystemID = Utility.getShort (buffer, dataPtr + 14);
|
||||
separator = (char) (buffer[dataPtr + 16] & 0x00FF);
|
||||
access = Utility.getLong (buffer, dataPtr + 18);
|
||||
fileType = Utility.getLong (buffer, dataPtr + 22);
|
||||
auxType = Utility.getLong (buffer, dataPtr + 26);
|
||||
storType = Utility.getWord (buffer, dataPtr + 30);
|
||||
storType = Utility.getShort (buffer, dataPtr + 30);
|
||||
created = new DateTime (buffer, dataPtr + 32);
|
||||
modified = new DateTime (buffer, dataPtr + 40);
|
||||
archived = new DateTime (buffer, dataPtr + 48);
|
||||
optionSize = Utility.getWord (buffer, dataPtr + 56);
|
||||
fileNameLength = Utility.getWord (buffer, dataPtr + attributes - 2);
|
||||
optionSize = Utility.getShort (buffer, dataPtr + 56);
|
||||
fileNameLength = Utility.getShort (buffer, dataPtr + attributes - 2);
|
||||
|
||||
int len = attributes + fileNameLength - 6;
|
||||
byte[] crcBuffer = new byte[len + totThreads * 16];
|
||||
|
@ -40,11 +40,11 @@ class Thread
|
||||
public Thread (byte[] buffer, int offset, int dataOffset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
threadClass = Utility.getWord (buffer, offset);
|
||||
threadFormat = Utility.getWord (buffer, offset + 2);
|
||||
threadKind = Utility.getWord (buffer, offset + 4);
|
||||
threadClass = Utility.getShort (buffer, offset);
|
||||
threadFormat = Utility.getShort (buffer, offset + 2);
|
||||
threadKind = Utility.getShort (buffer, offset + 4);
|
||||
|
||||
threadCrc = Utility.getWord (buffer, offset + 6);
|
||||
threadCrc = Utility.getShort (buffer, offset + 6);
|
||||
uncompressedEOF = Utility.getLong (buffer, offset + 8);
|
||||
compressedEOF = Utility.getLong (buffer, offset + 12);
|
||||
|
||||
|
@ -97,20 +97,20 @@ public final class Utility
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int getLong (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return getWord (buffer, ptr) + getWord (buffer, ptr + 2) * 0x10000;
|
||||
}
|
||||
// public static int getLong (byte[] buffer, int ptr)
|
||||
// // ---------------------------------------------------------------------------------//
|
||||
// {
|
||||
// return getWord (buffer, ptr) + getWord (buffer, ptr + 2) * 0x10000;
|
||||
// }
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int getWord (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int a = (buffer[ptr + 1] & 0xFF) << 8;
|
||||
int b = buffer[ptr] & 0xFF;
|
||||
return a + b;
|
||||
}
|
||||
// public static int getWord (byte[] buffer, int ptr)
|
||||
// // ---------------------------------------------------------------------------------//
|
||||
// {
|
||||
// int a = (buffer[ptr + 1] & 0xFF) << 8;
|
||||
// int b = buffer[ptr] & 0xFF;
|
||||
// return a + b;
|
||||
// }
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int intValue (byte b1, byte b2)
|
||||
@ -127,9 +127,15 @@ public final class Utility
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int unsignedLong (byte[] buffer, int ptr)
|
||||
public static int getLong (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (ptr >= buffer.length)
|
||||
{
|
||||
System.out.printf ("Index out of range (getLong): %08X%n", ptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int val = 0;
|
||||
for (int i = 3; i >= 0; i--)
|
||||
{
|
||||
@ -166,14 +172,15 @@ public final class Utility
|
||||
// }
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int unsignedShort (byte[] buffer, int ptr)
|
||||
public static int getShort (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (ptr >= buffer.length)
|
||||
{
|
||||
System.out.println ("Index out of range (unsigned short): " + ptr);
|
||||
System.out.printf ("Index out of range (getShort): %04X%n", ptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (buffer[ptr] & 0xFF) | ((buffer[ptr + 1] & 0xFF) << 8);
|
||||
}
|
||||
|
||||
@ -207,7 +214,7 @@ public final class Utility
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
// int yymmdd = readShort (buffer, offset);
|
||||
int yymmdd = unsignedShort (buffer, offset);
|
||||
int yymmdd = getShort (buffer, offset);
|
||||
if (yymmdd != 0)
|
||||
{
|
||||
int year = (yymmdd & 0xFE00) >> 9;
|
||||
|
@ -39,19 +39,18 @@ class Character extends AbstractFile
|
||||
stats.race = races[buffer[34] & 0xFF];
|
||||
stats.typeInt = buffer[36] & 0xFF;
|
||||
stats.type = types[stats.typeInt];
|
||||
stats.ageInWeeks = Utility.unsignedShort (buffer, 38);
|
||||
stats.ageInWeeks = Utility.getShort (buffer, 38);
|
||||
stats.statusValue = buffer[40];
|
||||
stats.status = statuses[stats.statusValue];
|
||||
stats.alignment = alignments[buffer[42] & 0xFF];
|
||||
|
||||
stats.gold =
|
||||
Utility.unsignedShort (buffer, 52) + Utility.unsignedShort (buffer, 54) * 10000;
|
||||
stats.gold = Utility.getShort (buffer, 52) + Utility.getShort (buffer, 54) * 10000;
|
||||
stats.experience =
|
||||
Utility.unsignedShort (buffer, 124) + Utility.unsignedShort (buffer, 126) * 10000;
|
||||
stats.level = Utility.unsignedShort (buffer, 132);
|
||||
Utility.getShort (buffer, 124) + Utility.getShort (buffer, 126) * 10000;
|
||||
stats.level = Utility.getShort (buffer, 132);
|
||||
|
||||
stats.hitsLeft = Utility.unsignedShort (buffer, 134);
|
||||
stats.hitsMax = Utility.unsignedShort (buffer, 136);
|
||||
stats.hitsLeft = Utility.getShort (buffer, 134);
|
||||
stats.hitsMax = Utility.getShort (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.unsignedShort (buffer, ptr)
|
||||
+ Utility.unsignedShort (buffer, ptr + 2) * 10000
|
||||
+ Utility.unsignedShort (buffer, ptr + 4) * 100000000L;
|
||||
long points =
|
||||
Utility.getShort (buffer, ptr) + Utility.getShort (buffer, ptr + 2) * 10000
|
||||
+ Utility.getShort (buffer, ptr + 4) * 100000000L;
|
||||
expLevels[seq++] = points;
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ class Header
|
||||
text.append ("\n");
|
||||
while (ptr < 512)
|
||||
{
|
||||
int value = Utility.unsignedShort (buffer, ptr);
|
||||
int value = Utility.getShort (buffer, ptr);
|
||||
text.append (String.format ("%04X %,6d%n", value, value));
|
||||
ptr += 2;
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ class Item extends AbstractFile implements Comparable<Item>
|
||||
super (name, buffer);
|
||||
itemID = counter++;
|
||||
type = buffer[32];
|
||||
cost = Utility.unsignedShort (buffer, 44) + Utility.unsignedShort (buffer, 46) * 10000
|
||||
+ Utility.unsignedShort (buffer, 48) * 100000000L;
|
||||
cost = Utility.getShort (buffer, 44) + Utility.getShort (buffer, 46) * 10000
|
||||
+ Utility.getShort (buffer, 48) * 100000000L;
|
||||
genericName = HexFormatter.getPascalString (buffer, 16);
|
||||
damage = new Dice (buffer, 66);
|
||||
armourClass = buffer[62];
|
||||
@ -95,7 +95,7 @@ class Item extends AbstractFile implements Comparable<Item>
|
||||
if (buffer[50] == -1 && buffer[51] == -1)
|
||||
return -1;
|
||||
|
||||
return Utility.unsignedShort (buffer, 50);
|
||||
return Utility.getShort (buffer, 50);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -152,7 +152,7 @@ class MazeGridV5 extends AbstractFile
|
||||
text.append ("\n");
|
||||
for (int i = 0; i < 176; i += 2)
|
||||
{
|
||||
int msg = Utility.getWord (buffer, 0x540 + i);
|
||||
int msg = Utility.getShort (buffer, 0x540 + i);
|
||||
text.append (String.format ("%05X %04X %04X", 0x540 + i, i / 2, msg));
|
||||
if (msg >= 700)
|
||||
{
|
||||
@ -178,7 +178,7 @@ class MazeGridV5 extends AbstractFile
|
||||
{
|
||||
for (int i = 0; i < 176; i += 2)
|
||||
{
|
||||
int msg = Utility.getWord (buffer, 0x540 + i);
|
||||
int msg = Utility.getShort (buffer, 0x540 + i);
|
||||
if (msg >= 15000)
|
||||
{
|
||||
List<String> messages = messageBlock.getMessageLines (msg);
|
||||
|
@ -439,8 +439,8 @@ class MazeLevel extends AbstractFile
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int x = b * 2;
|
||||
return new MazeAddress (Utility.unsignedShort (buffer, 768 + x),
|
||||
Utility.unsignedShort (buffer, 800 + x), Utility.unsignedShort (buffer, 832 + x));
|
||||
return new MazeAddress (Utility.getShort (buffer, 768 + x),
|
||||
Utility.getShort (buffer, 800 + x), Utility.getShort (buffer, 832 + x));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -23,14 +23,14 @@ class MessageBlock extends AbstractFile implements Iterable<MessageDataBlock>
|
||||
{
|
||||
super ("bollocks", buffer);
|
||||
|
||||
indexOffset = Utility.getWord (buffer, 0);
|
||||
indexLength = Utility.getWord (buffer, 2);
|
||||
indexOffset = Utility.getShort (buffer, 0);
|
||||
indexLength = Utility.getShort (buffer, 2);
|
||||
|
||||
int ptr = indexOffset * 512;
|
||||
|
||||
for (int i = 0, max = indexLength / 2; i < max; i++)
|
||||
{
|
||||
int firstMessageNo = Utility.getWord (buffer, ptr + i * 2);
|
||||
int firstMessageNo = Utility.getShort (buffer, ptr + i * 2);
|
||||
byte[] data = new byte[512];
|
||||
System.arraycopy (buffer, i * 512, data, 0, data.length);
|
||||
MessageDataBlock messageDataBlock = new MessageDataBlock (
|
||||
|
@ -25,7 +25,7 @@ public class Relocator extends AbstractFile
|
||||
{
|
||||
super (name, buffer);
|
||||
|
||||
checkByte = Utility.unsignedShort (buffer, 0);
|
||||
checkByte = Utility.getShort (buffer, 0);
|
||||
|
||||
int ptr = 2; // skip checkByte
|
||||
|
||||
@ -169,7 +169,7 @@ public class Relocator extends AbstractFile
|
||||
|
||||
public DiskRecord (byte[] buffer, int ptr)
|
||||
{
|
||||
diskNumber = Utility.unsignedShort (buffer, ptr);
|
||||
diskNumber = Utility.getShort (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.unsignedShort (buffer, ptr);
|
||||
physicalBlock = Utility.unsignedShort (buffer, ptr + 2);
|
||||
segmentLength = Utility.unsignedShort (buffer, ptr + 4);
|
||||
logicalBlock = Utility.getShort (buffer, ptr);
|
||||
physicalBlock = Utility.getShort (buffer, ptr + 2);
|
||||
segmentLength = Utility.getShort (buffer, ptr + 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,7 +23,7 @@ class Wiz5Monsters extends AbstractFile implements Iterable<Wiz5Monsters.Monster
|
||||
|
||||
int p = 0;
|
||||
int nextBlock = buffer[p] & 0xFF;
|
||||
int nextOffset = Utility.getWord (buffer, 256);
|
||||
int nextOffset = Utility.getShort (buffer, 256);
|
||||
|
||||
Monster monster = new Monster (p + 1);
|
||||
monsters.add (monster);
|
||||
@ -39,12 +39,12 @@ class Wiz5Monsters extends AbstractFile implements Iterable<Wiz5Monsters.Monster
|
||||
if (buffer[ndx] != (byte) 0)
|
||||
{
|
||||
nextBlock = buffer[ndx] & 0xFF;
|
||||
nextOffset = Utility.getWord (buffer, ndx + 1);
|
||||
nextOffset = Utility.getShort (buffer, ndx + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
nextBlock = buffer[++p] & 0xFF;
|
||||
nextOffset = Utility.getWord (buffer, p * 2 + 256);
|
||||
nextOffset = Utility.getShort (buffer, p * 2 + 256);
|
||||
createMonster = true;
|
||||
}
|
||||
|
||||
|
@ -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 = Utility.unsignedShort (buffer, offset);
|
||||
int key = Utility.getShort (buffer, offset);
|
||||
if (key > 0)
|
||||
text.append (String.format ("%04X %04X * %s%n", offset, key,
|
||||
messageBlock.getMessageText (key)));
|
||||
key = Utility.unsignedShort (buffer, offset + 8);
|
||||
key = Utility.getShort (buffer, offset + 8);
|
||||
if (key > 0)
|
||||
text.append (String.format ("%04X %04X %s%n", offset + 8, key,
|
||||
messageBlock.getMessageText (key)));
|
||||
|
@ -137,7 +137,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
byte[] buffer = disk.readBlock (2);
|
||||
int totalFiles = Utility.unsignedShort (buffer, 16);
|
||||
int totalFiles = Utility.getShort (buffer, 16);
|
||||
if (totalFiles != 3)
|
||||
return false;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user