1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-04-26 03:29:40 +00:00

Made a first attempt at D64 support. Made an error somewhere but this should be 90% of it.

This commit is contained in:
Thomas Harte
2016-08-01 08:41:16 -04:00
parent 58297f1baf
commit a00f9adba3
6 changed files with 163 additions and 3 deletions
+16
View File
@@ -49,3 +49,19 @@ unsigned int Storage::Encodings::CommodoreGCR::encoding_for_byte(uint8_t byte)
{
return encoding_for_nibble(byte) | (encoding_for_nibble(byte >> 4) << 5);
}
void Storage::Encodings::CommodoreGCR::encode_block(uint8_t *destination, uint8_t *source)
{
unsigned int encoded_bytes[4] = {
encoding_for_byte(source[0]),
encoding_for_byte(source[1]),
encoding_for_byte(source[2]),
encoding_for_byte(source[3]),
};
destination[0] = (uint8_t)(encoded_bytes[0] >> 2);
destination[1] = (uint8_t)((encoded_bytes[0] << 6) | (encoded_bytes[1] >> 4));
destination[2] = (uint8_t)((encoded_bytes[1] << 4) | (encoded_bytes[2] >> 6));
destination[3] = (uint8_t)((encoded_bytes[2] << 2) | (encoded_bytes[3] >> 8));
destination[4] = (uint8_t)(encoded_bytes[3]);
}