2016-07-29 15:03:09 +00:00
|
|
|
//
|
|
|
|
// CommodoreGCR.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 29/07/2016.
|
|
|
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2016-09-18 17:35:54 +00:00
|
|
|
#ifndef Storage_Disk_Encodings_CommodoreGCR_hpp
|
|
|
|
#define Storage_Disk_Encodings_CommodoreGCR_hpp
|
2016-07-29 15:03:09 +00:00
|
|
|
|
|
|
|
#include "../../Storage.hpp"
|
2016-08-01 10:04:55 +00:00
|
|
|
#include <cstdint>
|
2016-07-29 15:03:09 +00:00
|
|
|
|
|
|
|
namespace Storage {
|
|
|
|
namespace Encodings {
|
2016-08-01 10:04:55 +00:00
|
|
|
|
2016-07-29 15:03:09 +00:00
|
|
|
namespace CommodoreGCR {
|
2016-08-01 10:04:55 +00:00
|
|
|
/*!
|
|
|
|
@returns the proportion of a second that each bit of data within the specified @c time_zone
|
|
|
|
should idiomatically occupy.
|
|
|
|
*/
|
2016-07-29 15:03:09 +00:00
|
|
|
Time length_of_a_bit_in_time_zone(unsigned int time_zone);
|
2016-08-01 10:04:55 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
@returns the five-bit GCR encoding for the low four bits of @c nibble.
|
|
|
|
*/
|
|
|
|
unsigned int encoding_for_nibble(uint8_t nibble);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@returns the ten-bit GCR encoding for @c byte.
|
|
|
|
*/
|
|
|
|
unsigned int encoding_for_byte(uint8_t byte);
|
2016-08-01 12:41:16 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
A block is defined to be four source bytes, which encodes to five GCR bytes.
|
|
|
|
*/
|
|
|
|
void encode_block(uint8_t *destination, uint8_t *source);
|
2016-09-14 01:53:36 +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 composted of the low five bit five-bit GCR
|
|
|
|
*/
|
|
|
|
unsigned int decoding_from_dectet(unsigned int dectet);
|
2016-07-29 15:03:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CommodoreGCR_hpp */
|