mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-06-12 15:29:28 +00:00
tidying
This commit is contained in:
parent
cf0cfd278b
commit
b1ed1a74ba
|
@ -48,8 +48,8 @@ public class AppleDisk implements Disk
|
||||||
|
|
||||||
private int interleave = 0;
|
private int interleave = 0;
|
||||||
private static int[][] interleaveSector = //
|
private static int[][] interleaveSector = //
|
||||||
{ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
|
{ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, //
|
||||||
22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }, // None
|
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }, // None
|
||||||
{ 0, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15 }, // Prodos/Pascal
|
{ 0, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15 }, // Prodos/Pascal
|
||||||
{ 0, 13, 11, 9, 7, 5, 3, 1, 14, 12, 10, 8, 6, 4, 2, 15 }, // Infocom
|
{ 0, 13, 11, 9, 7, 5, 3, 1, 14, 12, 10, 8, 6, 4, 2, 15 }, // Infocom
|
||||||
{ 0, 6, 12, 3, 9, 15, 14, 5, 11, 2, 8, 7, 13, 4, 10, 1 } }; // CPM
|
{ 0, 6, 12, 3, 9, 15, 14, 5, 11, 2, 8, 7, 13, 4, 10, 1 } }; // CPM
|
||||||
|
@ -101,8 +101,7 @@ public class AppleDisk implements Disk
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public AppleDisk (File file, int tracks, int sectors, int skip)
|
public AppleDisk (File file, int tracks, int sectors, int skip) throws FileFormatException
|
||||||
throws FileFormatException
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert (file.exists ()) : "No such path :" + file.getAbsolutePath ();
|
assert (file.exists ()) : "No such path :" + file.getAbsolutePath ();
|
||||||
|
@ -158,8 +157,7 @@ public class AppleDisk implements Disk
|
||||||
tracks = blocks / 8; // change parameter!
|
tracks = blocks / 8; // change parameter!
|
||||||
sectors = 8; // change parameter!
|
sectors = 8; // change parameter!
|
||||||
}
|
}
|
||||||
else if (suffix.equalsIgnoreCase ("HDV")
|
else if (suffix.equalsIgnoreCase ("HDV") || (suffix.equalsIgnoreCase ("po") && tracks > 50)) // ULTIMATE APPLE1 CFFA 3.5.po
|
||||||
|| (suffix.equalsIgnoreCase ("po") && tracks > 50)) // ULTIMATE APPLE1 CFFA 3.5.po
|
|
||||||
{
|
{
|
||||||
//this.blocks = (int) file.length () / 4096 * 8; // reduce blocks to a multiple of 8
|
//this.blocks = (int) file.length () / 4096 * 8; // reduce blocks to a multiple of 8
|
||||||
this.blocks = tracks * sectors;
|
this.blocks = tracks * sectors;
|
||||||
|
@ -557,8 +555,7 @@ public class AppleDisk implements Disk
|
||||||
{
|
{
|
||||||
if (!isValidAddress (block))
|
if (!isValidAddress (block))
|
||||||
{
|
{
|
||||||
System.out.printf ("getDiskAddress: Invalid block : %d of %d%n", block,
|
System.out.printf ("getDiskAddress: Invalid block : %d of %d%n", block, this.blocks);
|
||||||
this.blocks);
|
|
||||||
return null;
|
return null;
|
||||||
// return new AppleDiskAddress (this, 0); // this was looping 26/07/2016
|
// return new AppleDiskAddress (this, 0); // this was looping 26/07/2016
|
||||||
}
|
}
|
||||||
|
@ -624,10 +621,9 @@ public class AppleDisk implements Disk
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert da.getDisk () == this : "Disk address not applicable to this disk";
|
assert da.getDisk () == this : "Disk address not applicable to this disk";
|
||||||
assert sectorSize == SECTOR_SIZE
|
assert sectorSize == SECTOR_SIZE || sectorSize == BLOCK_SIZE : "Invalid sector size : "
|
||||||
|| sectorSize == BLOCK_SIZE : "Invalid sector size : " + sectorSize;
|
+ sectorSize;
|
||||||
assert interleave >= 0 && interleave <= MAX_INTERLEAVE : "Invalid interleave : "
|
assert interleave >= 0 && interleave <= MAX_INTERLEAVE : "Invalid interleave : " + interleave;
|
||||||
+ interleave;
|
|
||||||
|
|
||||||
if (sectorSize == SECTOR_SIZE)
|
if (sectorSize == SECTOR_SIZE)
|
||||||
{
|
{
|
||||||
|
@ -640,8 +636,7 @@ public class AppleDisk implements Disk
|
||||||
System.arraycopy (diskBuffer, diskOffset, buffer, bufferOffset, SECTOR_SIZE);
|
System.arraycopy (diskBuffer, diskOffset, buffer, bufferOffset, SECTOR_SIZE);
|
||||||
|
|
||||||
diskOffset = getBufferOffset (da, 1);
|
diskOffset = getBufferOffset (da, 1);
|
||||||
System.arraycopy (diskBuffer, diskOffset, buffer, bufferOffset + SECTOR_SIZE,
|
System.arraycopy (diskBuffer, diskOffset, buffer, bufferOffset + SECTOR_SIZE, SECTOR_SIZE);
|
||||||
SECTOR_SIZE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,10 +645,9 @@ public class AppleDisk implements Disk
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert da.getDisk () == this : "Disk address not applicable to this disk";
|
assert da.getDisk () == this : "Disk address not applicable to this disk";
|
||||||
assert sectorSize == SECTOR_SIZE
|
assert sectorSize == SECTOR_SIZE || sectorSize == BLOCK_SIZE : "Invalid sector size : "
|
||||||
|| sectorSize == BLOCK_SIZE : "Invalid sector size : " + sectorSize;
|
+ sectorSize;
|
||||||
assert interleave >= 0 && interleave <= MAX_INTERLEAVE : "Invalid interleave : "
|
assert interleave >= 0 && interleave <= MAX_INTERLEAVE : "Invalid interleave : " + interleave;
|
||||||
+ interleave;
|
|
||||||
|
|
||||||
if (sectorSize == SECTOR_SIZE)
|
if (sectorSize == SECTOR_SIZE)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,6 +32,8 @@ class ExperienceLevel extends AbstractFile
|
||||||
long getExperiencePoints (int level)
|
long getExperiencePoints (int level)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
if (level == 0)
|
||||||
|
return expLevels[0];
|
||||||
return level < 13 ? expLevels[level - 1] : (level - 13) * expLevels[0] + expLevels[12];
|
return level < 13 ? expLevels[level - 1] : (level - 13) * expLevels[0] + expLevels[12];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ public class MazeLevel extends AbstractFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert buffer[ptr] == 0;
|
// assert buffer[ptr] == 0;
|
||||||
ptr++; // skip last byte
|
ptr++; // skip last byte
|
||||||
text.append ("\n");
|
text.append ("\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,9 +43,8 @@ class Monster extends AbstractFile
|
||||||
static int[] weight1 = { 0, 1, 2, 4, 8, 16, 32, 64, 253, 506, 0 };
|
static int[] weight1 = { 0, 1, 2, 4, 8, 16, 32, 64, 253, 506, 0 };
|
||||||
static int[] weight2 = { 0, 60, 120, 180, 300, 540, 1020, 0 };
|
static int[] weight2 = { 0, 60, 120, 180, 300, 540, 1020, 0 };
|
||||||
|
|
||||||
public static String[] monsterClass =
|
public static String[] monsterClass = { "Fighter", "Mage", "Priest", "Thief", "Midget", "Giant",
|
||||||
{ "Fighter", "Mage", "Priest", "Thief", "Midget", "Giant", "Mythical", "Dragon",
|
"Mythical", "Dragon", "Animal", "Were", "Undead", "Demon", "Insect", "Enchanted" };
|
||||||
"Animal", "Were", "Undead", "Demon", "Insect", "Enchanted" };
|
|
||||||
|
|
||||||
private static int[] experience = { //
|
private static int[] experience = { //
|
||||||
55, 235, 415, 230, 380, 620, 840, 520, 550, 350, // 00-09
|
55, 235, 415, 230, 380, 620, 840, 520, 550, 350, // 00-09
|
||||||
|
@ -111,7 +110,7 @@ class Monster extends AbstractFile
|
||||||
|
|
||||||
// these values definitely affect the damage a monster does (when breathing?)
|
// these values definitely affect the damage a monster does (when breathing?)
|
||||||
int exp2 = ((buffer[72] & 0xFF) * (buffer[74] & 0xFF) - 1) * 20;
|
int exp2 = ((buffer[72] & 0xFF) * (buffer[74] & 0xFF) - 1) * 20;
|
||||||
int exp3 = weight2[speed]; // 1-6
|
int exp3 = weight2[speed]; // 1-6
|
||||||
int exp4 = (10 - armourClass) * 40;
|
int exp4 = (10 - armourClass) * 40;
|
||||||
int exp5 = getBonus (35, mageSpellLevel);
|
int exp5 = getBonus (35, mageSpellLevel);
|
||||||
int exp6 = getBonus (35, priestSpellLevel);
|
int exp6 = getBonus (35, priestSpellLevel);
|
||||||
|
@ -175,8 +174,8 @@ class Monster extends AbstractFile
|
||||||
if (debug)
|
if (debug)
|
||||||
text.append (" " + exp9);
|
text.append (" " + exp9);
|
||||||
|
|
||||||
text.append ("\n\nExperience ...... " + (exp2 + exp3 + exp4 + exp5 + exp6 + exp7
|
text.append ("\n\nExperience ...... "
|
||||||
+ exp8 + exp9 + exp10 + exp11 + exp12));
|
+ (exp2 + exp3 + exp4 + exp5 + exp6 + exp7 + exp8 + exp9 + exp10 + exp11 + exp12));
|
||||||
|
|
||||||
text.append ("\n\n===== Gold reward ======");
|
text.append ("\n\n===== Gold reward ======");
|
||||||
// text.append ("\nTable ........... " + rewardTable1);
|
// text.append ("\nTable ........... " + rewardTable1);
|
||||||
|
@ -255,8 +254,7 @@ class Monster extends AbstractFile
|
||||||
public String getDump (int block)
|
public String getDump (int block)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder line =
|
StringBuilder line = new StringBuilder (String.format ("%3d %-16s", monsterID, realName));
|
||||||
new StringBuilder (String.format ("%3d %-16s", monsterID, realName));
|
|
||||||
int lo = block == 0 ? 64 : block == 1 ? 88 : block == 2 ? 112 : 136;
|
int lo = block == 0 ? 64 : block == 1 ? 88 : block == 2 ? 112 : 136;
|
||||||
int hi = lo + 24;
|
int hi = lo + 24;
|
||||||
if (hi > buffer.length)
|
if (hi > buffer.length)
|
||||||
|
|
|
@ -140,9 +140,9 @@ class Reward extends AbstractFile
|
||||||
String lineTitle = title ? "Items ..........." : "";
|
String lineTitle = title ? "Items ..........." : "";
|
||||||
title = false;
|
title = false;
|
||||||
for (int j = 0; j < lineItem.length; j++)
|
for (int j = 0; j < lineItem.length; j++)
|
||||||
lineItem[j] = i + j <= max ? items.get (i + j).getName () : "";
|
lineItem[j] = i + j < items.size () ? items.get (i + j).getName () : "";
|
||||||
text.append (String.format ("%-17s %-16s %-16s %-16s %-16s%n", lineTitle,
|
text.append (String.format ("%-17s %-16s %-16s %-16s %-16s%n", lineTitle, lineItem[0],
|
||||||
lineItem[0], lineItem[1], lineItem[2], lineItem[3]));
|
lineItem[1], lineItem[2], lineItem[3]));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -466,7 +466,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||||
{
|
{
|
||||||
int sequence = buffer[ptr + recordLength - 2];
|
int sequence = buffer[ptr + recordLength - 2];
|
||||||
++totalLines;
|
++totalLines;
|
||||||
if (sequence == 1) // end of message
|
if (sequence == 1) // end of message
|
||||||
{
|
{
|
||||||
int totalBytes = totalLines * recordLength;
|
int totalBytes = totalLines * recordLength;
|
||||||
byte[] newBuffer = new byte[totalBytes];
|
byte[] newBuffer = new byte[totalBytes];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user