From 1c9a744b019ba1dcef947a96de4433c73d00fa79 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 6 Aug 2017 18:06:20 -0400 Subject: [PATCH] Made an effort to start inspecting ID fields, at least. Discovered that my emulation has somehow stopped proceeding beyond sense interrupt status though. Fix one in that area: adjust ST0 just in time for the sense interrupt status response, as that'll need to specify the drive number properly. --- Components/8272/i8272.cpp | 23 ++++++++++++++++++++++- Components/8272/i8272.hpp | 3 +++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Components/8272/i8272.cpp b/Components/8272/i8272.cpp index 6d5917cf4..e19a62011 100644 --- a/Components/8272/i8272.cpp +++ b/Components/8272/i8272.cpp @@ -56,7 +56,7 @@ void i8272::run_for(Cycles cycles) { (drives_[c].target_head_position == (int)drives_[c].head_position) || (drives_[c].drive.get_is_track_zero() && drives_[c].target_head_position == -1)) { drives_[c].phase = Drive::CompletedSeeking; - status_[0] = (uint8_t)c | 0x20; + if(drives_[c].target_head_position == -1) drives_[c].head_position = 0; main_status_ &= ~(1 << c); } else { int direction = (drives_[c].target_head_position < drives_[c].head_position) ? -1 : 1; @@ -105,6 +105,24 @@ void i8272::set_disk(std::shared_ptr disk, int drive) { #define WAIT_FOR_EVENT(mask) resume_point_ = __LINE__; interesting_event_mask_ = (int)mask; return; case __LINE__: +#define FIND_HEADER() \ + { \ + find_header: WAIT_FOR_EVENT(Event::Token); \ + if(get_latest_token().type != Token::ID) goto find_header; \ + } + +#define READ_HEADER() \ + distance_into_header_ = 0; \ + set_data_mode(Reading); \ + { \ + read_header: WAIT_FOR_EVENT(Event::Token); \ + header_[distance_into_header_] = get_latest_token().byte_value; \ + distance_into_header_++; \ + if(distance_into_header_ != 7) goto read_header; \ + } \ + set_data_mode(Scanning); + + void i8272::posit_event(int type) { if(!(interesting_event_mask_ & type)) return; interesting_event_mask_ &= ~type; @@ -185,6 +203,8 @@ void i8272::posit_event(int type) { } read_data: + FIND_HEADER(); + READ_HEADER(); printf("Read data unimplemented!!\n"); goto wait_for_command; @@ -248,6 +268,7 @@ void i8272::posit_event(int type) { if(found_drive != -1) { drives_[found_drive].phase = Drive::NotSeeking; result_.push_back(drives_[found_drive].head_position); + status_[0] = (uint8_t)found_drive | 0x20; result_.push_back(status_[0]); } else { result_.push_back(0x80); diff --git a/Components/8272/i8272.hpp b/Components/8272/i8272.hpp index ad6e12e34..db97de013 100644 --- a/Components/8272/i8272.hpp +++ b/Components/8272/i8272.hpp @@ -67,6 +67,9 @@ class i8272: public Storage::Disk::MFMController { Drive() : head_position(0), phase(NotSeeking) {}; } drives_[4]; + + uint8_t header_[6]; + int distance_into_header_; }; }