Removed duplicate code

This commit is contained in:
Denis Molony 2016-12-18 09:14:55 +11:00
parent 5ed0d0d16a
commit 0557c2340e
6 changed files with 56 additions and 53 deletions

View File

@ -18,14 +18,14 @@ public class IconFile extends AbstractFile
super (name, buffer);
iBlkNext = HexFormatter.getLong (buffer, 0);
iBlkID = HexFormatter.getWord (buffer, 4);
iBlkID = HexFormatter.getShort (buffer, 4);
iBlkPath = HexFormatter.getLong (buffer, 6);
iBlkName = HexFormatter.getHexString (buffer, 10, 16);
int ptr = 26;
while (true)
{
int dataLen = HexFormatter.getWord (buffer, ptr);
int dataLen = HexFormatter.getShort (buffer, ptr);
if (dataLen == 0 || (dataLen + ptr) > buffer.length)
break;
icons.add (new Icon (buffer, ptr));
@ -66,7 +66,7 @@ public class IconFile extends AbstractFile
public Icon (byte[] fullBuffer, int ptr)
{
iDataLen = HexFormatter.getWord (fullBuffer, ptr);
iDataLen = HexFormatter.getShort (fullBuffer, ptr);
buffer = new byte[iDataLen];
System.arraycopy (fullBuffer, ptr, buffer, 0, buffer.length);
@ -77,8 +77,8 @@ public class IconFile extends AbstractFile
len = buffer[66] & 0xFF;
dataName = new String (buffer, 67, len);
iDataType = HexFormatter.getWord (buffer, 82);
iDataAux = HexFormatter.getWord (buffer, 84);
iDataType = HexFormatter.getShort (buffer, 82);
iDataAux = HexFormatter.getShort (buffer, 84);
largeImage = new Image (buffer, 86);
smallImage = new Image (buffer, 86 + largeImage.size ());
@ -111,10 +111,10 @@ public class IconFile extends AbstractFile
public Image (byte[] buffer, int ptr)
{
iconType = HexFormatter.getWord (buffer, ptr);
iconSize = HexFormatter.getWord (buffer, ptr + 2);
iconHeight = HexFormatter.getWord (buffer, ptr + 4);
iconWidth = HexFormatter.getWord (buffer, ptr + 6);
iconType = HexFormatter.getShort (buffer, ptr);
iconSize = HexFormatter.getShort (buffer, ptr + 2);
iconHeight = HexFormatter.getShort (buffer, ptr + 4);
iconWidth = HexFormatter.getShort (buffer, ptr + 6);
main = new byte[iconSize];
mask = new byte[iconSize];

View File

@ -9,7 +9,7 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
public class AppleworksADBFile extends AbstractFile
{
static final String line = "-------------------------------------------------------"
+ "-----------------------------------\n";
+ "-----------------------------------\n";
private final int headerSize;
private final int cursorDirectionSRL;
@ -48,7 +48,7 @@ public class AppleworksADBFile extends AbstractFile
dbMinVersion = buffer[218] & 0xFF;
headerSize = HexFormatter.getWord (buffer, 0);
headerSize = HexFormatter.getShort (buffer, 0);
cursorDirectionSRL = buffer[30];
cursorDirectionMRL = (char) buffer[31];
currentDisplay = (char) buffer[34];
@ -56,7 +56,7 @@ public class AppleworksADBFile extends AbstractFile
categoryNames = new String[categories];
totalReports = buffer[38] & 0xFF;
int recs = HexFormatter.getWord (buffer, 36);
int recs = HexFormatter.getShort (buffer, 36);
totalRecords = dbMinVersion == 0 ? recs : recs & 0x7FFF;
for (int i = 0; i < 30; i++)
@ -75,9 +75,9 @@ public class AppleworksADBFile extends AbstractFile
for (int i = 0; i < 3; i++)
{
selectionRules[i] = HexFormatter.getWord (buffer, 223 + i * 2);
testTypes[i] = HexFormatter.getWord (buffer, 229 + i * 2);
continuation[i] = HexFormatter.getWord (buffer, 235 + i * 2);
selectionRules[i] = HexFormatter.getShort (buffer, 223 + i * 2);
testTypes[i] = HexFormatter.getShort (buffer, 229 + i * 2);
continuation[i] = HexFormatter.getShort (buffer, 235 + i * 2);
comparison[i] = new String (buffer, 241 + i * 20, 20);
}
@ -102,7 +102,7 @@ public class AppleworksADBFile extends AbstractFile
ptr += 600;
}
int length = HexFormatter.getWord (buffer, ptr);
int length = HexFormatter.getShort (buffer, ptr);
ptr += 2;
if (length == 0)
@ -114,7 +114,7 @@ public class AppleworksADBFile extends AbstractFile
for (int recordNo = 0; recordNo < totalRecords; recordNo++)
{
length = HexFormatter.getWord (buffer, ptr);
length = HexFormatter.getShort (buffer, ptr);
ptr += 2;
if (length == 0)
break;
@ -131,12 +131,13 @@ public class AppleworksADBFile extends AbstractFile
StringBuilder text = new StringBuilder ();
text.append (String.format ("Header size ........ %d%n", headerSize));
text.append (String
.format ("SRL cursor ......... %d (1=default, 2=left->right, top->bottom)%n",
cursorDirectionSRL));
text.append (String.format (
"SRL cursor ......... %d (1=default, 2=left->right, top->bottom)%n",
cursorDirectionSRL));
text.append (String.format ("MRL cursor ......... %s (D=down, R=right)%n",
cursorDirectionMRL));
text.append (String.format ("Display ............ %s (R=SRL, /=MRL)%n", currentDisplay));
cursorDirectionMRL));
text.append (
String.format ("Display ............ %s (R=SRL, /=MRL)%n", currentDisplay));
text.append (String.format ("Categories ......... %d%n", categories));
text.append (String.format ("Reports ............ %d%n", totalReports));
text.append (String.format ("Records ............ %d%n", totalRecords));

View File

@ -20,7 +20,7 @@ public class AppleworksSSFile extends AbstractFile
int ptr = header.ssMinVers == 0 ? 300 : 302;
while (ptr < buffer.length)
{
int length = HexFormatter.getWord (buffer, ptr);
int length = HexFormatter.getShort (buffer, ptr);
if (length == 0xFFFF)
break;
@ -92,7 +92,7 @@ public class AppleworksSSFile extends AbstractFile
calcOrder = (char) buffer[131];
calcFrequency = (char) buffer[132];
lastRow = HexFormatter.getWord (buffer, 133);
lastRow = HexFormatter.getShort (buffer, 133);
lastColumn = buffer[135] & 0xFF;
windowLayout = (char) buffer[136];
windowSynch = buffer[137] != 0;
@ -193,15 +193,15 @@ public class AppleworksSSFile extends AbstractFile
r1 = buffer[offset + 3] & 0xFF;
c1 = buffer[offset + 4] & 0xFF;
r2 = HexFormatter.getWord (buffer, offset + 5);
r2 = HexFormatter.getShort (buffer, offset + 5);
c2 = buffer[offset + 7] & 0xFF;
r3 = HexFormatter.getWord (buffer, offset + 8);
r3 = HexFormatter.getShort (buffer, offset + 8);
c3 = buffer[offset + 10] & 0xFF;
r4 = HexFormatter.getWord (buffer, offset + 11);
r4 = HexFormatter.getShort (buffer, offset + 11);
c4 = buffer[offset + 13] & 0xFF;
r5 = buffer[offset + 14] & 0xFF;
c5 = buffer[offset + 15] & 0xFF;
r6 = HexFormatter.getWord (buffer, offset + 16);
r6 = HexFormatter.getShort (buffer, offset + 16);
c6 = buffer[offset + 18] & 0xFF;
r7 = buffer[offset + 19] & 0xFF;
c7 = buffer[offset + 20] & 0xFF;
@ -252,7 +252,7 @@ public class AppleworksSSFile extends AbstractFile
public Row (int ptr)
{
rowNumber = HexFormatter.getWord (buffer, ptr);
rowNumber = HexFormatter.getShort (buffer, ptr);
ptr += 2; // first control byte
int column = 0;

View File

@ -5,11 +5,11 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
abstract class Report
{
static final String line = "-------------------------------------------------------"
+ "-----------------------------------\n";
+ "-----------------------------------\n";
static final String gap = " "
+ " ";
static final String[] testText = { "", "=", ">", "<", "?4", "?5", "<>", "?7", "?8", "?9",
"?10", "?11", "?12", "?13" };
+ " ";
static final String[] testText = { "", "=", ">", "<", "?4", "?5", "<>", "?7", "?8",
"?9", "?10", "?11", "?12", "?13" };
static final String[] continuationText = { "", "And", "Or", "Through" };
protected final AppleworksADBFile parent;
@ -87,7 +87,8 @@ abstract class Report
if (false)
{
System.out.println ("==============================================================");
System.out
.println ("==============================================================");
System.out.println ("Header");
System.out.println (HexFormatter.formatNoHeader (buffer, offset + 213, 7));
System.out.println ();
@ -125,9 +126,9 @@ abstract class Report
if (buffer[offset + 480 + fudge] == 0) // test high byte
for (int i = 0; i < 3; i++)
{
selectionRules[i] = HexFormatter.getWord (buffer, offset + 479 + i * 2 + fudge);
testTypes[i] = HexFormatter.getWord (buffer, offset + 485 + i * 2 + fudge);
continuation[i] = HexFormatter.getWord (buffer, offset + 491 + i * 2 + fudge);
selectionRules[i] = HexFormatter.getShort (buffer, offset + 479 + i * 2 + fudge);
testTypes[i] = HexFormatter.getShort (buffer, offset + 485 + i * 2 + fudge);
continuation[i] = HexFormatter.getShort (buffer, offset + 491 + i * 2 + fudge);
comparison[i] = pascalString (buffer, offset + 497 + i * 32 + fudge);
}
else
@ -148,11 +149,12 @@ abstract class Report
text.append (String.format ("Report name ........ %s%n", name));
text.append (String.format ("Report type ........ %s%n", reportFormat));
text.append (String.format ("Spacing ............ %s (Single/Double/Triple)%n", spacing));
text.append (
String.format ("Spacing ............ %s (Single/Double/Triple)%n", spacing));
text.append (String.format ("Print header ....... %s%n", printHeader));
text.append (String.format ("Title .............. %s%n", titleLine));
text.append (String.format ("L/R/T/B margin ..... %d/%d/%d/%d%n", leftMargin, rightMargin,
topMargin, bottomMargin));
text.append (String.format ("L/R/T/B margin ..... %d/%d/%d/%d%n", leftMargin,
rightMargin, topMargin, bottomMargin));
text.append (String.format ("Categories ......... %s%n", categoriesOnThisReport));
text.append (String.format ("Platen width ....... %d%n", platenWidth));
text.append (String.format ("Chars per inch ..... %d%n", charsPerInch));
@ -170,7 +172,7 @@ abstract class Report
int test = testTypes[i];
int cont = continuation[i];
text.append (String.format ("[%s] %s [%s] %s ", parent.categoryNames[category],
testText[test], comparison[i], continuationText[cont]));
testText[test], comparison[i], continuationText[cont]));
}
text.append ("\n");

View File

@ -359,16 +359,16 @@ public class HexFormatter
return Double.longBitsToDouble (bits);
}
public static int getWord (byte[] buffer, int ptr)
{
int val = 0;
for (int i = 1; i >= 0; i--)
{
val <<= 8;
val += buffer[ptr + i] & 0xFF;
}
return val;
}
// public static int getWord (byte[] buffer, int ptr)
// {
// int val = 0;
// for (int i = 1; i >= 0; i--)
// {
// val <<= 8;
// val += buffer[ptr + i] & 0xFF;
// }
// return val;
// }
public static int getSignedWord (byte b1, byte b2)
{

View File

@ -286,11 +286,11 @@ public class Wizardry4BootDisk extends PascalDisk
{
// System.out.println (HexFormatter.format (buffer, 0x08600 + i * 32, 32));
int offset = 0x08600 + i * 32 + 18;
int key = HexFormatter.getWord (buffer, offset);
int key = HexFormatter.getShort (buffer, offset);
if (key > 0)
text.append (String.format ("%04X %04X * %s%n", offset, key,
messageBlock.getMessageText (key)));
key = HexFormatter.getWord (buffer, offset + 8);
key = HexFormatter.getShort (buffer, offset + 8);
if (key > 0)
text.append (String.format ("%04X %04X %s%n", offset + 8, key,
messageBlock.getMessageText (key)));