This commit is contained in:
Denis Molony 2022-03-26 18:07:17 +10:00
parent cf0cfd278b
commit b1ed1a74ba
6 changed files with 25 additions and 31 deletions

View File

@ -48,8 +48,8 @@ public class AppleDisk implements Disk
private int interleave = 0;
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,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }, // None
{ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, //
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, 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
@ -101,8 +101,7 @@ public class AppleDisk implements Disk
}
// ---------------------------------------------------------------------------------//
public AppleDisk (File file, int tracks, int sectors, int skip)
throws FileFormatException
public AppleDisk (File file, int tracks, int sectors, int skip) throws FileFormatException
// ---------------------------------------------------------------------------------//
{
assert (file.exists ()) : "No such path :" + file.getAbsolutePath ();
@ -158,8 +157,7 @@ public class AppleDisk implements Disk
tracks = blocks / 8; // change parameter!
sectors = 8; // change parameter!
}
else if (suffix.equalsIgnoreCase ("HDV")
|| (suffix.equalsIgnoreCase ("po") && tracks > 50)) // ULTIMATE APPLE1 CFFA 3.5.po
else if (suffix.equalsIgnoreCase ("HDV") || (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 = tracks * sectors;
@ -557,8 +555,7 @@ public class AppleDisk implements Disk
{
if (!isValidAddress (block))
{
System.out.printf ("getDiskAddress: Invalid block : %d of %d%n", block,
this.blocks);
System.out.printf ("getDiskAddress: Invalid block : %d of %d%n", block, this.blocks);
return null;
// 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 sectorSize == SECTOR_SIZE
|| sectorSize == BLOCK_SIZE : "Invalid sector size : " + sectorSize;
assert interleave >= 0 && interleave <= MAX_INTERLEAVE : "Invalid interleave : "
+ interleave;
assert sectorSize == SECTOR_SIZE || sectorSize == BLOCK_SIZE : "Invalid sector size : "
+ sectorSize;
assert interleave >= 0 && interleave <= MAX_INTERLEAVE : "Invalid interleave : " + interleave;
if (sectorSize == SECTOR_SIZE)
{
@ -640,8 +636,7 @@ public class AppleDisk implements Disk
System.arraycopy (diskBuffer, diskOffset, buffer, bufferOffset, SECTOR_SIZE);
diskOffset = getBufferOffset (da, 1);
System.arraycopy (diskBuffer, diskOffset, buffer, bufferOffset + SECTOR_SIZE,
SECTOR_SIZE);
System.arraycopy (diskBuffer, diskOffset, buffer, bufferOffset + 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 sectorSize == SECTOR_SIZE
|| sectorSize == BLOCK_SIZE : "Invalid sector size : " + sectorSize;
assert interleave >= 0 && interleave <= MAX_INTERLEAVE : "Invalid interleave : "
+ interleave;
assert sectorSize == SECTOR_SIZE || sectorSize == BLOCK_SIZE : "Invalid sector size : "
+ sectorSize;
assert interleave >= 0 && interleave <= MAX_INTERLEAVE : "Invalid interleave : " + interleave;
if (sectorSize == SECTOR_SIZE)
{

View File

@ -32,6 +32,8 @@ class ExperienceLevel extends AbstractFile
long getExperiencePoints (int level)
// ---------------------------------------------------------------------------------//
{
if (level == 0)
return expLevels[0];
return level < 13 ? expLevels[level - 1] : (level - 13) * expLevels[0] + expLevels[12];
}

View File

@ -139,7 +139,7 @@ public class MazeLevel extends AbstractFile
}
}
assert buffer[ptr] == 0;
// assert buffer[ptr] == 0;
ptr++; // skip last byte
text.append ("\n");
}

View File

@ -43,9 +43,8 @@ class Monster extends AbstractFile
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 };
public static String[] monsterClass =
{ "Fighter", "Mage", "Priest", "Thief", "Midget", "Giant", "Mythical", "Dragon",
"Animal", "Were", "Undead", "Demon", "Insect", "Enchanted" };
public static String[] monsterClass = { "Fighter", "Mage", "Priest", "Thief", "Midget", "Giant",
"Mythical", "Dragon", "Animal", "Were", "Undead", "Demon", "Insect", "Enchanted" };
private static int[] experience = { //
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?)
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 exp5 = getBonus (35, mageSpellLevel);
int exp6 = getBonus (35, priestSpellLevel);
@ -175,8 +174,8 @@ class Monster extends AbstractFile
if (debug)
text.append (" " + exp9);
text.append ("\n\nExperience ...... " + (exp2 + exp3 + exp4 + exp5 + exp6 + exp7
+ exp8 + exp9 + exp10 + exp11 + exp12));
text.append ("\n\nExperience ...... "
+ (exp2 + exp3 + exp4 + exp5 + exp6 + exp7 + exp8 + exp9 + exp10 + exp11 + exp12));
text.append ("\n\n===== Gold reward ======");
// text.append ("\nTable ........... " + rewardTable1);
@ -255,8 +254,7 @@ class Monster extends AbstractFile
public String getDump (int block)
// ---------------------------------------------------------------------------------//
{
StringBuilder line =
new StringBuilder (String.format ("%3d %-16s", monsterID, realName));
StringBuilder line = new StringBuilder (String.format ("%3d %-16s", monsterID, realName));
int lo = block == 0 ? 64 : block == 1 ? 88 : block == 2 ? 112 : 136;
int hi = lo + 24;
if (hi > buffer.length)

View File

@ -140,9 +140,9 @@ class Reward extends AbstractFile
String lineTitle = title ? "Items ..........." : "";
title = false;
for (int j = 0; j < lineItem.length; j++)
lineItem[j] = i + j <= max ? items.get (i + j).getName () : "";
text.append (String.format ("%-17s %-16s %-16s %-16s %-16s%n", lineTitle,
lineItem[0], lineItem[1], lineItem[2], lineItem[3]));
lineItem[j] = i + j < items.size () ? items.get (i + j).getName () : "";
text.append (String.format ("%-17s %-16s %-16s %-16s %-16s%n", lineTitle, lineItem[0],
lineItem[1], lineItem[2], lineItem[3]));
}
break;
default:

View File

@ -466,7 +466,7 @@ public class WizardryScenarioDisk extends PascalDisk
{
int sequence = buffer[ptr + recordLength - 2];
++totalLines;
if (sequence == 1) // end of message
if (sequence == 1) // end of message
{
int totalBytes = totalLines * recordLength;
byte[] newBuffer = new byte[totalBytes];