mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2025-02-26 11:28:56 +00:00
Changed readSector in an attempt to handle wrapping within a
track appropriately. Prior to this change, if the sector wrapped to the beginning of the track, it would throw an exception.
This commit is contained in:
parent
119297dfa1
commit
e41de0c2fd
@ -19,10 +19,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.webcodepro.applecommander.storage.physical;
|
package com.webcodepro.applecommander.storage.physical;
|
||||||
|
|
||||||
import com.webcodepro.applecommander.util.AppleUtil;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import com.webcodepro.applecommander.util.AppleUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supports disk images stored in nibbilized DOS physical order.
|
* Supports disk images stored in nibbilized DOS physical order.
|
||||||
* <p>
|
* <p>
|
||||||
@ -101,16 +101,14 @@ public class NibbleOrder extends DosOrder {
|
|||||||
int offset = 0;
|
int offset = 0;
|
||||||
byte[] addressField = new byte[14];
|
byte[] addressField = new byte[14];
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
while (!found && offset < trackData.length) {
|
int attempts = getSectorsPerTrack();
|
||||||
|
while (!found && attempts >= 0) {
|
||||||
int nextOffset = locateField(0xd5, 0xaa, 0x96, trackData, addressField, offset);
|
int nextOffset = locateField(0xd5, 0xaa, 0x96, trackData, addressField, offset);
|
||||||
if (nextOffset < offset) { // we wrapped!
|
attempts--;
|
||||||
throw new IllegalArgumentException("Unable to locate physical sector "
|
|
||||||
+ sector + " on track " + track);
|
|
||||||
}
|
|
||||||
offset = nextOffset;
|
offset = nextOffset;
|
||||||
int t = decodeOddEven(addressField, 5);
|
int t = decodeOddEven(addressField, 5);
|
||||||
int s = decodeOddEven(addressField, 7);
|
int s = decodeOddEven(addressField, 7);
|
||||||
found = (t == track && s == sector);
|
found = (t == track && s == sector);
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
throw new IllegalArgumentException("Unable to locate physical sector "
|
throw new IllegalArgumentException("Unable to locate physical sector "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user