mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-20 04:29:02 +00:00
tidying
This commit is contained in:
parent
e216a805ad
commit
466633bb4f
@ -4,7 +4,8 @@ package com.bytezone.diskbrowser.nib;
|
|||||||
abstract class DiskReader
|
abstract class DiskReader
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
static final int BLOCK_SIZE = 256;
|
static final int SECTOR_SIZE = 256;
|
||||||
|
static final int BLOCK_SIZE = 512;
|
||||||
static final byte[] dataPrologue = { (byte) 0xD5, (byte) 0xAA, (byte) 0xAD };
|
static final byte[] dataPrologue = { (byte) 0xD5, (byte) 0xAA, (byte) 0xAD };
|
||||||
|
|
||||||
static DiskReader reader13;
|
static DiskReader reader13;
|
||||||
@ -60,6 +61,4 @@ abstract class DiskReader
|
|||||||
abstract byte[] decodeSector (byte[] buffer, int offset) throws DiskNibbleException;
|
abstract byte[] decodeSector (byte[] buffer, int offset) throws DiskNibbleException;
|
||||||
|
|
||||||
abstract byte[] encodeSector (byte[] buffer);
|
abstract byte[] encodeSector (byte[] buffer);
|
||||||
|
|
||||||
abstract int expectedDataSize ();
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class DiskReader13Sector extends DiskReader
|
|||||||
byte[] decodeSector (byte[] buffer, int offset) throws DiskNibbleException
|
byte[] decodeSector (byte[] buffer, int offset) throws DiskNibbleException
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
byte[] decodedBuffer = new byte[BLOCK_SIZE];
|
byte[] decodedBuffer = new byte[SECTOR_SIZE];
|
||||||
|
|
||||||
// convert legal disk values to actual 5 bit values
|
// convert legal disk values to actual 5 bit values
|
||||||
for (int i = 0; i < BUFFER_WITH_CHECKSUM_SIZE; i++) // 411 bytes
|
for (int i = 0; i < BUFFER_WITH_CHECKSUM_SIZE; i++) // 411 bytes
|
||||||
@ -82,12 +82,4 @@ class DiskReader13Sector extends DiskReader
|
|||||||
System.out.println ("encodeSector() not written");
|
System.out.println ("encodeSector() not written");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
@Override
|
|
||||||
int expectedDataSize ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
return BUFFER_WITH_CHECKSUM_SIZE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class DiskReader16Sector extends DiskReader
|
|||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
// rearrange 342 bytes into 256
|
// rearrange 342 bytes into 256
|
||||||
byte[] decodedBuffer = new byte[BLOCK_SIZE]; // 256 bytes
|
byte[] decodedBuffer = new byte[SECTOR_SIZE]; // 256 bytes
|
||||||
|
|
||||||
// convert legal disk values to actual 6 bit values
|
// convert legal disk values to actual 6 bit values
|
||||||
for (int i = 0; i < BUFFER_WITH_CHECKSUM_SIZE; i++) // 343 bytes
|
for (int i = 0; i < BUFFER_WITH_CHECKSUM_SIZE; i++) // 343 bytes
|
||||||
@ -42,7 +42,7 @@ class DiskReader16Sector extends DiskReader
|
|||||||
throw new DiskNibbleException ("Checksum failed");
|
throw new DiskNibbleException ("Checksum failed");
|
||||||
|
|
||||||
// move 6 bits into place
|
// move 6 bits into place
|
||||||
for (int i = 0; i < BLOCK_SIZE; i++)
|
for (int i = 0; i < SECTOR_SIZE; i++)
|
||||||
decodedBuffer[i] = decodeB[i + 86];
|
decodedBuffer[i] = decodeB[i + 86];
|
||||||
|
|
||||||
// reattach each byte's last 2 bits
|
// reattach each byte's last 2 bits
|
||||||
@ -53,7 +53,7 @@ class DiskReader16Sector extends DiskReader
|
|||||||
decodedBuffer[i] |= reverse ((val & 0x0C) >> 2);
|
decodedBuffer[i] |= reverse ((val & 0x0C) >> 2);
|
||||||
decodedBuffer[j] |= reverse ((val & 0x30) >> 4);
|
decodedBuffer[j] |= reverse ((val & 0x30) >> 4);
|
||||||
|
|
||||||
if (k < BLOCK_SIZE)
|
if (k < SECTOR_SIZE)
|
||||||
decodedBuffer[k] |= reverse ((val & 0xC0) >> 6);
|
decodedBuffer[k] |= reverse ((val & 0xC0) >> 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ class DiskReader16Sector extends DiskReader
|
|||||||
byte[] encodedBuffer = new byte[BUFFER_WITH_CHECKSUM_SIZE];
|
byte[] encodedBuffer = new byte[BUFFER_WITH_CHECKSUM_SIZE];
|
||||||
|
|
||||||
// move data buffer down to make room for the 86 extra bytes
|
// move data buffer down to make room for the 86 extra bytes
|
||||||
for (int i = 0; i < BLOCK_SIZE; i++)
|
for (int i = 0; i < SECTOR_SIZE; i++)
|
||||||
encodeA[i + 86] = buffer[i];
|
encodeA[i + 86] = buffer[i];
|
||||||
|
|
||||||
// build extra 86 bytes from the bits stripped from the data bytes
|
// build extra 86 bytes from the bits stripped from the data bytes
|
||||||
@ -111,12 +111,4 @@ class DiskReader16Sector extends DiskReader
|
|||||||
{
|
{
|
||||||
return bits == 1 ? 2 : bits == 2 ? 1 : bits;
|
return bits == 1 ? 2 : bits == 2 ? 1 : bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
@Override
|
|
||||||
int expectedDataSize ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
return BUFFER_WITH_CHECKSUM_SIZE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ package com.bytezone.diskbrowser.nib;
|
|||||||
public class DiskReaderGCR extends DiskReader
|
public class DiskReaderGCR extends DiskReader
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
static final int TAG_SIZE = 12;
|
||||||
private final ByteTranslator byteTranslator = new ByteTranslator6and2 ();
|
private final ByteTranslator byteTranslator = new ByteTranslator6and2 ();
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
@ -18,7 +19,7 @@ public class DiskReaderGCR extends DiskReader
|
|||||||
byte[] decodeSector (byte[] inBuffer, int inPtr) throws DiskNibbleException
|
byte[] decodeSector (byte[] inBuffer, int inPtr) throws DiskNibbleException
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
byte[] outBuffer = new byte[BLOCK_SIZE * 2 + 12]; // 524 bytes
|
byte[] outBuffer = new byte[BLOCK_SIZE + TAG_SIZE]; // 524 bytes
|
||||||
int outPtr = 0;
|
int outPtr = 0;
|
||||||
int[] checksums = new int[3];
|
int[] checksums = new int[3];
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ public class DiskReaderGCR extends DiskReader
|
|||||||
outBuffer[outPtr++] = checksum (b2, checksums, 1, 0); // checksum
|
outBuffer[outPtr++] = checksum (b2, checksums, 1, 0); // checksum
|
||||||
}
|
}
|
||||||
|
|
||||||
// decode four disk bytes into three data bytes
|
// decode four disk bytes into three checksum bytes
|
||||||
byte d3 = byteTranslator.decode (inBuffer[inPtr++]); // composite byte
|
byte d3 = byteTranslator.decode (inBuffer[inPtr++]); // composite byte
|
||||||
byte d0 = byteTranslator.decode (inBuffer[inPtr++]);
|
byte d0 = byteTranslator.decode (inBuffer[inPtr++]);
|
||||||
byte d1 = byteTranslator.decode (inBuffer[inPtr++]);
|
byte d1 = byteTranslator.decode (inBuffer[inPtr++]);
|
||||||
@ -92,15 +93,7 @@ public class DiskReaderGCR extends DiskReader
|
|||||||
byte[] encodeSector (byte[] buffer)
|
byte[] encodeSector (byte[] buffer)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
System.out.println ("encodeSector() not written");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
@Override
|
|
||||||
int expectedDataSize ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
assert false;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user