mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-25 01:32:26 +00:00
refactoring getWizLong and getSignedShort
This commit is contained in:
parent
7d4d8c75e6
commit
97fe58d94d
@ -88,8 +88,8 @@ public class QuickDrawFont extends CharacterList
|
||||
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);
|
||||
kernMax = Utility.getSignedShort (buffer, ptr + 8);
|
||||
nDescent = Utility.getSignedShort (buffer, ptr + 10);
|
||||
fRectWidth = Utility.getShort (buffer, ptr + 12);
|
||||
fRectHeight = Utility.getShort (buffer, ptr + 14);
|
||||
|
||||
|
@ -198,7 +198,7 @@ public final class Utility
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int signedShort (byte[] buffer, int ptr)
|
||||
public static int getSignedShort (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
try
|
||||
@ -447,6 +447,17 @@ public final class Utility
|
||||
return LocalDate.of (year, month, day);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int getWizLong (byte[] buffer, int offset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int low = Utility.getShort (buffer, offset);
|
||||
int mid = Utility.getShort (buffer, offset + 2);
|
||||
int high = Utility.getShort (buffer, offset + 4);
|
||||
|
||||
return high * 100000000 + mid * 10000 + low;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int dimension (int chars, int border, int size, int gap)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -95,7 +95,7 @@ public class CharacterV4 extends Character
|
||||
race = Race.values ()[Utility.getShort (buffer, 35)];
|
||||
characterClass = CharacterClass.values ()[Utility.getShort (buffer, 37)];
|
||||
age = 0;
|
||||
armourClass = Utility.signedShort (buffer, 39);
|
||||
armourClass = Utility.getSignedShort (buffer, 39);
|
||||
|
||||
status = CharacterStatus.values ()[Utility.getShort (buffer, 41)];
|
||||
alignment = Alignment.values ()[Utility.getShort (buffer, 43)];
|
||||
@ -156,7 +156,7 @@ public class CharacterV4 extends Character
|
||||
spellAllowance[PRIEST_SPELLS][i] = Utility.getShort (buffer, 161 + i * 2);
|
||||
}
|
||||
|
||||
hpCalCmd = Utility.signedShort (buffer, 175);
|
||||
hpCalCmd = Utility.getSignedShort (buffer, 175);
|
||||
// armourClass = Utility.getSignedShort (buffer, 177); // see offset 39
|
||||
healPts = Utility.getShort (buffer, 179);
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.bytezone.diskbrowser.wizardry;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class Item extends AbstractFile
|
||||
@ -93,15 +92,4 @@ public class Item extends AbstractFile
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
int getWizLong (byte[] buffer, int offset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int low = Utility.getShort (buffer, offset);
|
||||
int mid = Utility.getShort (buffer, offset + 2);
|
||||
int high = Utility.getShort (buffer, offset + 4);
|
||||
|
||||
return high * 100000000 + mid * 10000 + low;
|
||||
}
|
||||
}
|
||||
|
@ -23,20 +23,20 @@ class ItemV1 extends Item // implements Comparable<ItemV1>
|
||||
|
||||
type = ObjectType.values ()[buffer[32]];
|
||||
alignment = Alignment.values ()[buffer[34]];
|
||||
cursed = Utility.signedShort (buffer, 36) == -1;
|
||||
special = Utility.signedShort (buffer, 38);
|
||||
cursed = Utility.getSignedShort (buffer, 36) == -1;
|
||||
special = Utility.getSignedShort (buffer, 38);
|
||||
changeTo = Utility.getShort (buffer, 40); // decay #
|
||||
changeChance = Utility.getShort (buffer, 42);
|
||||
price = getWizLong (buffer, 44);
|
||||
boltac = Utility.signedShort (buffer, 50);
|
||||
price = Utility.getWizLong (buffer, 44);
|
||||
boltac = Utility.getSignedShort (buffer, 50);
|
||||
spellPwr = Utility.getShort (buffer, 52);
|
||||
classUseFlags = Utility.getShort (buffer, 54); // 8 flags
|
||||
|
||||
healPts = Utility.signedShort (buffer, 56);
|
||||
healPts = Utility.getSignedShort (buffer, 56);
|
||||
flags2 = Utility.getShort (buffer, 58); // 16 flags
|
||||
flags3 = Utility.getShort (buffer, 60); // 16 flags
|
||||
armourClass = Utility.signedShort (buffer, 62);
|
||||
wephitmd = Utility.signedShort (buffer, 64);
|
||||
armourClass = Utility.getSignedShort (buffer, 62);
|
||||
wephitmd = Utility.getSignedShort (buffer, 64);
|
||||
wephpdam = new Dice (buffer, 66); // Dice
|
||||
xtraSwing = Utility.getShort (buffer, 72);
|
||||
crithitm = Utility.getShort (buffer, 74) == 1; // boolean
|
||||
|
@ -21,25 +21,25 @@ public class ItemV4 extends Item
|
||||
|
||||
type = ObjectType.values ()[buffer[1]];
|
||||
alignment = Alignment.values ()[buffer[3]];
|
||||
cursed = Utility.signedShort (buffer, 5) == -1;
|
||||
special = Utility.signedShort (buffer, 7);
|
||||
cursed = Utility.getSignedShort (buffer, 5) == -1;
|
||||
special = Utility.getSignedShort (buffer, 7);
|
||||
changeTo = Utility.getShort (buffer, 9); // decay #
|
||||
changeChance = Utility.getShort (buffer, 11);
|
||||
price = getWizLong (buffer, 13);
|
||||
boltac = Utility.signedShort (buffer, 19);
|
||||
price = Utility.getWizLong (buffer, 13);
|
||||
boltac = Utility.getSignedShort (buffer, 19);
|
||||
spellPwr = Utility.getShort (buffer, 21);
|
||||
classUseFlags = Utility.getShort (buffer, 23); // 8 flags
|
||||
classUseFlags = Utility.getShort (buffer, 23); // 8 flags
|
||||
|
||||
healPts = Utility.signedShort (buffer, 25);
|
||||
flags2 = Utility.getShort (buffer, 27); // 16 flags
|
||||
flags3 = Utility.getShort (buffer, 29); // 16 flags
|
||||
armourClass = Utility.signedShort (buffer, 31);
|
||||
wephitmd = Utility.signedShort (buffer, 33);
|
||||
healPts = Utility.getSignedShort (buffer, 25);
|
||||
flags2 = Utility.getShort (buffer, 27); // 16 flags
|
||||
flags3 = Utility.getShort (buffer, 29); // 16 flags
|
||||
armourClass = Utility.getSignedShort (buffer, 31);
|
||||
wephitmd = Utility.getSignedShort (buffer, 33);
|
||||
wephpdam = new Dice (buffer, 35);
|
||||
|
||||
xtraSwing = Utility.getShort (buffer, 41);
|
||||
crithitm = Utility.getShort (buffer, 43) == 1; // boolean
|
||||
flags1 = Utility.getShort (buffer, 45); // 14 flags
|
||||
crithitm = Utility.getShort (buffer, 43) == 1; // boolean
|
||||
flags1 = Utility.getShort (buffer, 45); // 14 flags
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public abstract class Monster extends AbstractFile
|
||||
@ -98,15 +97,4 @@ public abstract class Monster extends AbstractFile
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
int getWizLong (byte[] buffer, int offset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int low = Utility.getShort (buffer, offset);
|
||||
int mid = Utility.getShort (buffer, offset + 2);
|
||||
int high = Utility.getShort (buffer, offset + 4);
|
||||
|
||||
return high * 100000000 + mid * 10000 + low;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.bytezone.diskbrowser.wizardry;
|
||||
import java.util.List;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class MonsterV1 extends Monster
|
||||
@ -70,7 +71,7 @@ class MonsterV1 extends Monster
|
||||
damage.add (new Dice (buffer, ptr));
|
||||
}
|
||||
|
||||
experiencePoints = getWizLong (buffer, 126);
|
||||
experiencePoints = Utility.getWizLong (buffer, 126);
|
||||
levelDrain = buffer[132];
|
||||
healPts = buffer[134];
|
||||
goldReward = rewards.get (buffer[136]);
|
||||
|
@ -21,7 +21,7 @@ public class MonsterV4 extends Monster
|
||||
groupSize = new Dice (buffer, 1);
|
||||
hitPoints = new Dice (buffer, 7);
|
||||
type = Utility.getShort (buffer, 13);
|
||||
armourClass = Utility.signedShort (buffer, 15);
|
||||
armourClass = Utility.getSignedShort (buffer, 15);
|
||||
|
||||
recsn = buffer[17]; // number of dice
|
||||
for (int i = 0, ptr = 19; i < 7; i++, ptr += 6)
|
||||
|
@ -21,7 +21,7 @@ import com.bytezone.diskbrowser.wizardry.Header.ScenarioData;
|
||||
public class Wizardry4BootDisk extends PascalDisk
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
public Header scenarioHeader;
|
||||
private Header scenarioHeader;
|
||||
private Relocator relocator;
|
||||
private MessageBlock messageBlock;
|
||||
private Huffman huffman;
|
||||
@ -31,7 +31,7 @@ public class Wizardry4BootDisk extends PascalDisk
|
||||
private List<CharacterParty> parties = new ArrayList<> ();
|
||||
private List<ItemV4> items = new ArrayList<> ();
|
||||
private List<MonsterV4> monsters = new ArrayList<> ();
|
||||
public List<String> spellNames = new ArrayList<> ();
|
||||
private List<String> spellNames = new ArrayList<> ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public Wizardry4BootDisk (AppleDisk[] dataDisks)
|
||||
|
Loading…
Reference in New Issue
Block a user