1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-04-09 00:37:27 +00:00

Starts making some space for Macintosh-style GCR encoding.

This commit is contained in:
Thomas Harte 2019-06-04 15:41:15 -04:00
parent 113d022741
commit 1033abd9fe
3 changed files with 51 additions and 4 deletions

View File

@ -81,7 +81,7 @@ std::shared_ptr<Track> AppleDSK::get_track_at_position(Track::Address address) {
for(uint8_t c = 0; c < 16; ++c) {
segment += Encodings::AppleGCR::header(is_prodos_ ? 0x01 : 0xfe, track, c); // Volume number is 0xfe for DOS 3.3, 0x01 for Pro-DOS.
segment += Encodings::AppleGCR::six_and_two_sync(7); // Gap 2: 7 sync words.
segment += Encodings::AppleGCR::six_and_two_data(&track_data[logical_sector_for_physical_sector(c) * 256]);
segment += Encodings::AppleGCR::AppleII::six_and_two_data(&track_data[logical_sector_for_physical_sector(c) * 256]);
segment += Encodings::AppleGCR::six_and_two_sync(20); // Gap 3: 20 sync words.
}
} else {

View File

@ -120,7 +120,9 @@ Storage::Disk::PCMSegment AppleGCR::five_and_three_data(const uint8_t *source) {
return Storage::Disk::PCMSegment(data);
}
Storage::Disk::PCMSegment AppleGCR::six_and_two_data(const uint8_t *source) {
// MARK: - Apple II-specific encoding.
Storage::Disk::PCMSegment AppleGCR::AppleII::six_and_two_data(const uint8_t *source) {
std::vector<uint8_t> data(349);
// Add the prologue and epilogue.
@ -175,3 +177,22 @@ Storage::Disk::PCMSegment AppleGCR::six_and_two_data(const uint8_t *source) {
return Storage::Disk::PCMSegment(data);
}
// MARK: - Macintosh-specific encoding.
AppleGCR::Macintosh::SectorSpan AppleGCR::Macintosh::sectors_in_track(int track) {
// A Macintosh disk has 80 tracks, divided into 5 16-track zones. The outermost
// zone has 12 sectors/track, the next one in has only 11 sectors/track, and
// that arithmetic progression continues.
//
// (... and therefore the elementary sum of an arithmetic progression formula
// is deployed below)
const int zone = track >> 4;
const int prior_sectors = 16 * zone * (12 + (12 - (zone - 1))) / 2;
AppleGCR::Macintosh::SectorSpan result;
result.length = 12 - zone;
result.start = prior_sectors + (track & 15) * result.length;
return result;
}

View File

@ -29,12 +29,38 @@ const uint8_t epilogue[3] = {0xde, 0xaa, 0xeb};
*/
Storage::Disk::PCMSegment header(uint8_t volume, uint8_t track, uint8_t sector);
namespace AppleII {
/*!
Produces the data section of a six-and-two format sector; the segment returned
will be 2,792 bits long, encoding the first 256 bytes from @c source.
Produces the data section of an Apple II-style six-and-two format sector;
the segment returned will be 2,792 bits long, encoding the first 256 bytes
from @c source.
*/
Storage::Disk::PCMSegment six_and_two_data(const uint8_t *source);
}
namespace Macintosh {
/*!
Produces the data section of a Macintosh-style six-and-two format sector;
the segment returned will be x bits long, encoding the first 524 bytes
from @c source.
*/
Storage::Disk::PCMSegment six_and_two_data(const uint8_t *source);
struct SectorSpan {
int start, length;
};
/*!
@returns the span of sectors included on track @c track using the Macintosh's
ordinary CLV variable-speed mechanish.
*/
SectorSpan sectors_in_track(int track);
}
/*!
Produces @c length sync six-and-two format sync bytes. The segment returned
is @c 10*length bits long.