java.lang.Object
com.webcodepro.applecommander.storage.physical.NibbleCodec

public class NibbleCodec extends Object
  • Field Details

    • DOS32_ADDRESS_PROLOGUE

      public static final int[] DOS32_ADDRESS_PROLOGUE
    • DOS32_DATA_PROLOGUE

      public static final int[] DOS32_DATA_PROLOGUE
    • DOS33_ADDRESS_PROLOGUE

      public static final int[] DOS33_ADDRESS_PROLOGUE
    • DOS33_DATA_PROLOGUE

      public static final int[] DOS33_DATA_PROLOGUE
  • Constructor Details

    • NibbleCodec

      public NibbleCodec()
  • Method Details

    • decodeOddEven

      public static int decodeOddEven(byte[] buffer, int offset)
      Decode odd-even bytes as stored on disk. The format will be in two bytes. They are stored as such:
           XX = 1d1d1d1d (odd data bits)
           YY = 1d1d1d1d (even data bits)
       
      XX is then shifted by a bit and ANDed with YY to get the data byte. See page 3-12 in Beneath Apple DOS for more information.
    • encodeOddEven

      public static void encodeOddEven(byte[] buffer, int offset, int value)
      Encode odd-even bytes to be stored on disk. See decodeOddEven for the format.
      See Also:
    • identifySectorsPerTrack

      public static int identifySectorsPerTrack(byte[] trackData)
      Identify if this is a 13-sector or 16-sector disk. Note that it is "guaranteed" to return 13, 16, or an exception.
    • readSectorFromTrack62

      public static byte[] readSectorFromTrack62(byte[] trackData, int track, int physicalSector, int sectorsPerTrack)
      Locate physical sector in the given track data. Decodes 6+2 encoding.
    • readSectorFromTrack53

      public static byte[] readSectorFromTrack53(byte[] trackData, int track, int physicalSector, int sectorsPerTrack)
      Locate physical sector in the given track data. Decodes 5+3 encoding.
    • locateField

      public static int locateField(int[] prologue, byte[] trackData, byte[] fieldData, int startingOffset)
      Locate a field on the track. These are identified by a 3 byte unique signature. Because of the way in which disk bytes are captured, we need to wrap around the track to ensure all sequences of bytes are accounted for.

      This method fills fieldData as well as returning the last position referenced in the track buffer.

    • writeSectorToTrack

      public static void writeSectorToTrack(byte[] trackData, byte[] sectorData, int track, int physicalSector, int sectorsPerTrack)