mirror of
https://github.com/TomHarte/CLK.git
synced 2024-07-26 11:29:09 +00:00
Sought to correct my interpretation of 'gap 3'.
This commit is contained in:
parent
9ace6e1f71
commit
1011143dbe
@ -92,6 +92,7 @@ void i8272::run_for(Cycles cycles) {
|
|||||||
// Check for completion.
|
// Check for completion.
|
||||||
if(drives_[c].seek_is_satisfied()) {
|
if(drives_[c].seek_is_satisfied()) {
|
||||||
drives_[c].phase = Drive::CompletedSeeking;
|
drives_[c].phase = Drive::CompletedSeeking;
|
||||||
|
main_status_ &= ~(1 << c);
|
||||||
if(drives_[c].target_head_position == -1) drives_[c].head_position = 0;
|
if(drives_[c].target_head_position == -1) drives_[c].head_position = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -438,17 +439,29 @@ void i8272::posit_event(int event_type) {
|
|||||||
write_data_found_header:
|
write_data_found_header:
|
||||||
begin_writing();
|
begin_writing();
|
||||||
|
|
||||||
// Write out the requested gap between ID and data.
|
if(get_is_double_density()) {
|
||||||
for(int c = 0; c < command_[7]; c++) {
|
for(int c = 0; c < 50; c++) {
|
||||||
write_byte(0x4e);
|
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);
|
WAIT_FOR_EVENT(Event::DataWritten);
|
||||||
|
|
||||||
{
|
{
|
||||||
bool is_deleted = (command_[0] & 0x1f) == 0x09;
|
bool is_deleted = (command_[0] & 0x1f) == 0x09;
|
||||||
if(get_is_double_density()) {
|
if(get_is_double_density()) {
|
||||||
get_crc_generator().set_value(Storage::Encodings::MFM::MFMPostSyncCRCValue);
|
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);
|
write_byte(is_deleted ? Storage::Encodings::MFM::DeletedDataAddressByte : Storage::Encodings::MFM::DataAddressByte);
|
||||||
} else {
|
} else {
|
||||||
get_crc_generator().reset();
|
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].target_head_position = (command_.size() > 2) ? command_[2] : -1;
|
||||||
drives_[drive].step_rate_counter = 0;
|
drives_[drive].step_rate_counter = 0;
|
||||||
drives_[drive].seek_failed = false;
|
drives_[drive].seek_failed = false;
|
||||||
|
printf("Accepted seek to %d\n", drives_[drive].target_head_position);
|
||||||
|
|
||||||
// Check whether any steps are even needed.
|
// Check whether any steps are even needed.
|
||||||
if(drives_[drive].seek_is_satisfied()) {
|
if(drives_[drive].seek_is_satisfied()) {
|
||||||
@ -651,6 +665,8 @@ void i8272::posit_event(int event_type) {
|
|||||||
} else {
|
} else {
|
||||||
main_status_ |= 1 << (command_[1]&3);
|
main_status_ |= 1 << (command_[1]&3);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
printf("Rejected seek to %d\n", (command_.size() > 2) ? command_[2] : -1);
|
||||||
}
|
}
|
||||||
goto wait_for_command;
|
goto wait_for_command;
|
||||||
|
|
||||||
@ -672,7 +688,6 @@ void i8272::posit_event(int event_type) {
|
|||||||
drives_[found_drive].phase = Drive::NotSeeking;
|
drives_[found_drive].phase = Drive::NotSeeking;
|
||||||
status_[0] = (uint8_t)found_drive;
|
status_[0] = (uint8_t)found_drive;
|
||||||
SetSeekEnd();
|
SetSeekEnd();
|
||||||
main_status_ &= ~(1 << found_drive);
|
|
||||||
|
|
||||||
result_stack_.push_back(drives_[found_drive].head_position);
|
result_stack_.push_back(drives_[found_drive].head_position);
|
||||||
result_stack_.push_back(status_[0]);
|
result_stack_.push_back(status_[0]);
|
||||||
|
@ -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 post_index_address_mark_bytes, uint8_t post_index_address_mark_value,
|
||||||
size_t pre_address_mark_bytes,
|
size_t pre_address_mark_bytes,
|
||||||
size_t post_address_mark_bytes, uint8_t post_address_mark_value,
|
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 pre_data_mark_bytes,
|
||||||
size_t inter_sector_gap,
|
size_t post_data_bytes, uint8_t post_data_value,
|
||||||
size_t expected_track_bytes) {
|
size_t expected_track_bytes) {
|
||||||
Storage::Disk::PCMSegment segment;
|
Storage::Disk::PCMSegment segment;
|
||||||
segment.data.reserve(expected_track_bytes);
|
segment.data.reserve(expected_track_bytes);
|
||||||
@ -169,8 +169,7 @@ template<class T> std::shared_ptr<Storage::Disk::Track>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// gap
|
// gap
|
||||||
for(size_t c = 0; c < post_data_bytes; c++) shifter.add_byte(0x00);
|
for(size_t c = 0; c < post_data_bytes; c++) shifter.add_byte(post_data_value);
|
||||||
for(size_t c = 0; c < inter_sector_gap; c++) shifter.add_byte(0x4e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while(segment.data.size() < expected_track_bytes) shifter.add_byte(0x00);
|
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> §ors, size_t sector_gap_length, uint8_t sector_gap_filler_byte) {
|
std::shared_ptr<Storage::Disk::Track> Storage::Encodings::MFM::GetFMTrackWithSectors(const std::vector<Sector> §ors, size_t sector_gap_length, uint8_t sector_gap_filler_byte) {
|
||||||
return GetTrackWithSectors<FMEncoder>(
|
return GetTrackWithSectors<FMEncoder>(
|
||||||
sectors,
|
sectors,
|
||||||
16, 0x00,
|
26, 0xff,
|
||||||
6,
|
6,
|
||||||
(sector_gap_length != DefaultSectorGapLength) ? sector_gap_length : 0, sector_gap_filler_byte,
|
11, 0xff,
|
||||||
(sector_gap_length != DefaultSectorGapLength) ? 0 : 17, 14,
|
6,
|
||||||
0,
|
(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
|
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,
|
sectors,
|
||||||
50, 0x4e,
|
50, 0x4e,
|
||||||
12,
|
12,
|
||||||
(sector_gap_length != DefaultSectorGapLength) ? sector_gap_length : 22, sector_gap_filler_byte,
|
22, 0x4e,
|
||||||
(sector_gap_length != DefaultSectorGapLength) ? 0 : 12, 18,
|
12,
|
||||||
32,
|
(sector_gap_length != DefaultSectorGapLength) ? sector_gap_length : 54, 0xff,
|
||||||
12500); // unintelligently: double the single-density bytes/rotation (or: 500kps @ 300 rpm)
|
12500); // unintelligently: double the single-density bytes/rotation (or: 500kps @ 300 rpm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user