1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-26 09:29:45 +00:00

Sought to correct my interpretation of 'gap 3'.

This commit is contained in:
Thomas Harte 2017-08-13 21:52:48 -04:00
parent 9ace6e1f71
commit 1011143dbe
2 changed files with 30 additions and 16 deletions

View File

@ -92,6 +92,7 @@ void i8272::run_for(Cycles cycles) {
// Check for completion.
if(drives_[c].seek_is_satisfied()) {
drives_[c].phase = Drive::CompletedSeeking;
main_status_ &= ~(1 << c);
if(drives_[c].target_head_position == -1) drives_[c].head_position = 0;
break;
}
@ -438,17 +439,29 @@ void i8272::posit_event(int event_type) {
write_data_found_header:
begin_writing();
// Write out the requested gap between ID and data.
for(int c = 0; c < command_[7]; c++) {
write_byte(0x4e);
if(get_is_double_density()) {
for(int c = 0; c < 50; c++) {
write_byte(0x4e);
}
for(int c = 0; c < 12; c++) {
write_byte(0x00);
}
} else {
for(int c = 0; c < 11; c++) {
write_byte(0xff);
}
for(int c = 0; c < 6; c++) {
write_byte(0x00);
}
}
WAIT_FOR_EVENT(Event::DataWritten);
{
bool is_deleted = (command_[0] & 0x1f) == 0x09;
if(get_is_double_density()) {
get_crc_generator().set_value(Storage::Encodings::MFM::MFMPostSyncCRCValue);
write_raw_short(Storage::Encodings::MFM::MFMSync);
for(int c = 0; c < 3; c++) write_raw_short(Storage::Encodings::MFM::MFMSync);
write_byte(is_deleted ? Storage::Encodings::MFM::DeletedDataAddressByte : Storage::Encodings::MFM::DataAddressByte);
} else {
get_crc_generator().reset();
@ -644,6 +657,7 @@ void i8272::posit_event(int event_type) {
drives_[drive].target_head_position = (command_.size() > 2) ? command_[2] : -1;
drives_[drive].step_rate_counter = 0;
drives_[drive].seek_failed = false;
printf("Accepted seek to %d\n", drives_[drive].target_head_position);
// Check whether any steps are even needed.
if(drives_[drive].seek_is_satisfied()) {
@ -651,6 +665,8 @@ void i8272::posit_event(int event_type) {
} else {
main_status_ |= 1 << (command_[1]&3);
}
} else {
printf("Rejected seek to %d\n", (command_.size() > 2) ? command_[2] : -1);
}
goto wait_for_command;
@ -672,7 +688,6 @@ void i8272::posit_event(int event_type) {
drives_[found_drive].phase = Drive::NotSeeking;
status_[0] = (uint8_t)found_drive;
SetSeekEnd();
main_status_ &= ~(1 << found_drive);
result_stack_.push_back(drives_[found_drive].head_position);
result_stack_.push_back(status_[0]);

View File

@ -120,8 +120,8 @@ template<class T> std::shared_ptr<Storage::Disk::Track>
size_t post_index_address_mark_bytes, uint8_t post_index_address_mark_value,
size_t pre_address_mark_bytes,
size_t post_address_mark_bytes, uint8_t post_address_mark_value,
size_t pre_data_mark_bytes, size_t post_data_bytes,
size_t inter_sector_gap,
size_t pre_data_mark_bytes,
size_t post_data_bytes, uint8_t post_data_value,
size_t expected_track_bytes) {
Storage::Disk::PCMSegment segment;
segment.data.reserve(expected_track_bytes);
@ -169,8 +169,7 @@ template<class T> std::shared_ptr<Storage::Disk::Track>
}
// gap
for(size_t c = 0; c < post_data_bytes; c++) shifter.add_byte(0x00);
for(size_t c = 0; c < inter_sector_gap; c++) shifter.add_byte(0x4e);
for(size_t c = 0; c < post_data_bytes; c++) shifter.add_byte(post_data_value);
}
while(segment.data.size() < expected_track_bytes) shifter.add_byte(0x00);
@ -199,11 +198,11 @@ const size_t Storage::Encodings::MFM::DefaultSectorGapLength = (size_t)~0;
std::shared_ptr<Storage::Disk::Track> Storage::Encodings::MFM::GetFMTrackWithSectors(const std::vector<Sector> &sectors, size_t sector_gap_length, uint8_t sector_gap_filler_byte) {
return GetTrackWithSectors<FMEncoder>(
sectors,
16, 0x00,
26, 0xff,
6,
(sector_gap_length != DefaultSectorGapLength) ? sector_gap_length : 0, sector_gap_filler_byte,
(sector_gap_length != DefaultSectorGapLength) ? 0 : 17, 14,
0,
11, 0xff,
6,
(sector_gap_length != DefaultSectorGapLength) ? sector_gap_length : 27, 0xff,
6250); // i.e. 250kbps (including clocks) * 60 = 15000kpm, at 300 rpm => 50 kbits/rotation => 6250 bytes/rotation
}
@ -212,9 +211,9 @@ std::shared_ptr<Storage::Disk::Track> Storage::Encodings::MFM::GetMFMTrackWithSe
sectors,
50, 0x4e,
12,
(sector_gap_length != DefaultSectorGapLength) ? sector_gap_length : 22, sector_gap_filler_byte,
(sector_gap_length != DefaultSectorGapLength) ? 0 : 12, 18,
32,
22, 0x4e,
12,
(sector_gap_length != DefaultSectorGapLength) ? sector_gap_length : 54, 0xff,
12500); // unintelligently: double the single-density bytes/rotation (or: 500kps @ 300 rpm)
}