mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-28 06:29:37 +00:00
Merge pull request #420 from TomHarte/DSKDos33
Corrects handling of Apple II DSK files.
This commit is contained in:
commit
65ba9ee6e7
@ -53,12 +53,12 @@ std::shared_ptr<Track> AppleDSK::get_track_at_position(Track::Address address) {
|
||||
// In either case below, the code aims for exactly 50,000 bits per track.
|
||||
if(sectors_per_track_ == 16) {
|
||||
// Write the sectors.
|
||||
uint8_t sector_number_ = 0;
|
||||
for(std::size_t c = 0; c < 16; ++c) {
|
||||
std::size_t sector_number_ = 0;
|
||||
for(uint8_t c = 0; c < 16; ++c) {
|
||||
segment += Encodings::AppleGCR::six_and_two_sync(10);
|
||||
segment += Encodings::AppleGCR::header(0, track, sector_number_);
|
||||
segment += Encodings::AppleGCR::header(0, track, c);
|
||||
segment += Encodings::AppleGCR::six_and_two_sync(10);
|
||||
segment += Encodings::AppleGCR::six_and_two_data(&track_data[c * 256]);
|
||||
segment += Encodings::AppleGCR::six_and_two_data(&track_data[sector_number_ * 256]);
|
||||
|
||||
// DOS and Pro DOS interleave sectors on disk, and they're represented in a disk
|
||||
// image in physical order rather than logical. So that skew needs to be applied here.
|
||||
|
@ -205,9 +205,14 @@ void Drive::setup_track() {
|
||||
assert(track_time_now >= Time(0) && current_event_.length <= Time(1));
|
||||
|
||||
Time time_found = track_->seek_to(track_time_now);
|
||||
assert(time_found >= Time(0) && time_found < Time(1) && time_found <= track_time_now);
|
||||
|
||||
offset = track_time_now - time_found;
|
||||
// time_found can be greater than track_time_now if limited precision caused rounding
|
||||
if(time_found <= track_time_now) {
|
||||
offset = track_time_now - time_found;
|
||||
} else {
|
||||
offset.set_zero();
|
||||
}
|
||||
|
||||
get_next_event(offset);
|
||||
}
|
||||
|
||||
|
@ -156,13 +156,26 @@ Storage::Disk::PCMSegment AppleGCR::six_and_two_data(const uint8_t *source) {
|
||||
// six bits.
|
||||
const uint8_t bit_shuffle[] = {0, 2, 1, 3};
|
||||
for(std::size_t c = 0; c < 84; ++c) {
|
||||
segment.data[3 + c] = bit_shuffle[source[c]&3];
|
||||
if(c + 86 < 256) segment.data[3 + c] |= bit_shuffle[source[c + 86]&3] << 2;
|
||||
if(c + 172 < 256) segment.data[3 + c] |= bit_shuffle[source[c + 172]&3] << 4;
|
||||
segment.data[3 + c] =
|
||||
static_cast<uint8_t>(
|
||||
bit_shuffle[source[c]&3] |
|
||||
(bit_shuffle[source[c + 86]&3] << 2) |
|
||||
(bit_shuffle[source[c + 172]&3] << 4)
|
||||
);
|
||||
}
|
||||
segment.data[87] =
|
||||
static_cast<uint8_t>(
|
||||
(bit_shuffle[source[84]&3] << 0) |
|
||||
(bit_shuffle[source[170]&3] << 2)
|
||||
);
|
||||
segment.data[88] =
|
||||
static_cast<uint8_t>(
|
||||
(bit_shuffle[source[85]&3] << 0) |
|
||||
(bit_shuffle[source[171]&3] << 2)
|
||||
);
|
||||
|
||||
for(std::size_t c = 0; c < 256; ++c) {
|
||||
segment.data[3 + 85 + 1 + c] = source[c] >> 2;
|
||||
segment.data[3 + 86 + c] = source[c] >> 2;
|
||||
}
|
||||
|
||||
// Exclusive OR each byte with the one before it.
|
||||
|
Loading…
x
Reference in New Issue
Block a user