2018-04-21 21:33:42 +00:00
|
|
|
//
|
|
|
|
// AppleGCR.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 21/04/2018.
|
|
|
|
// Copyright © 2018 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef AppleGCR_hpp
|
|
|
|
#define AppleGCR_hpp
|
|
|
|
|
|
|
|
#include <cstdint>
|
2018-04-24 02:59:03 +00:00
|
|
|
#include "../../Disk/Track/PCMSegment.hpp"
|
2018-04-21 21:33:42 +00:00
|
|
|
|
|
|
|
namespace Storage {
|
|
|
|
namespace Encodings {
|
|
|
|
|
|
|
|
namespace AppleGCR {
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@returns the eight-bit 13-sector GCR encoding for the low five bits of @c value.
|
|
|
|
*/
|
2018-04-28 19:18:48 +00:00
|
|
|
// unsigned int five_and_three_encoding_for_value(int value);
|
2018-04-21 21:33:42 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
@returns the eight-bit 16-sector GCR encoding for the low six bits of @c value.
|
|
|
|
*/
|
2018-04-28 19:18:48 +00:00
|
|
|
// unsigned int six_and_two_encoding_for_value(int value);
|
2018-04-21 21:33:42 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
A block is defined to be five source bytes, which encodes to eight GCR bytes.
|
|
|
|
*/
|
2018-04-28 19:18:48 +00:00
|
|
|
// void encode_five_and_three_block(uint8_t *destination, uint8_t *source);
|
2018-04-21 21:33:42 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
A block is defined to be three source bytes, which encodes to four GCR bytes.
|
|
|
|
*/
|
2018-04-28 19:18:48 +00:00
|
|
|
// void encode_six_and_two_block(uint8_t *destination, uint8_t *source);
|
2018-04-21 21:33:42 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
@returns the four bit nibble for the five-bit GCR @c quintet if a valid GCR value; INT_MAX otherwise.
|
|
|
|
*/
|
|
|
|
// unsigned int decoding_from_quintet(unsigned int quintet);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@returns the byte composed by splitting the dectet into two qintets, decoding each and composing the resulting nibbles.
|
|
|
|
*/
|
|
|
|
// unsigned int decoding_from_dectet(unsigned int dectet);
|
2018-04-24 02:59:03 +00:00
|
|
|
|
|
|
|
/// Describes the standard three-byte prologue that begins a header.
|
|
|
|
const uint8_t header_prologue[3] = {0xd5, 0xaa, 0x96};
|
|
|
|
/// Describes the standard three-byte prologue that begins a data section.
|
|
|
|
const uint8_t data_prologue[3] = {0xd5, 0xaa, 0xad};
|
|
|
|
/// Describes the epilogue that ends both data sections and headers.
|
|
|
|
const uint8_t epilogue[3] = {0xde, 0xaa, 0xeb};
|
|
|
|
|
2018-04-28 19:18:48 +00:00
|
|
|
/*!
|
|
|
|
Produces the Apple-standard '4 and 4' per-sector header. This is the same
|
|
|
|
for both the 13- and 16-sector formats, and is 112 bits long.
|
|
|
|
*/
|
2018-04-24 02:59:03 +00:00
|
|
|
Storage::Disk::PCMSegment header(uint8_t volume, uint8_t track, uint8_t sector);
|
|
|
|
|
2018-04-28 19:18:48 +00:00
|
|
|
Storage::Disk::PCMSegment six_and_two_data(const uint8_t *source);
|
2018-04-24 02:59:03 +00:00
|
|
|
Storage::Disk::PCMSegment six_and_two_sync(int length);
|
|
|
|
|
2018-04-28 19:18:48 +00:00
|
|
|
Storage::Disk::PCMSegment five_and_three_data(const uint8_t *source);
|
2018-04-24 02:59:03 +00:00
|
|
|
Storage::Disk::PCMSegment five_and_three_sync(int length);
|
2018-04-21 21:33:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* AppleGCR_hpp */
|