mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-23 03:29:04 +00:00
Ensures full 8272 instance state initialisation.
This commit is contained in:
parent
3944e734d3
commit
91b867a7b3
@ -79,14 +79,7 @@ namespace {
|
|||||||
|
|
||||||
i8272::i8272(BusHandler &bus_handler, Cycles clock_rate) :
|
i8272::i8272(BusHandler &bus_handler, Cycles clock_rate) :
|
||||||
Storage::Disk::MFMController(clock_rate),
|
Storage::Disk::MFMController(clock_rate),
|
||||||
bus_handler_(bus_handler),
|
bus_handler_(bus_handler) {
|
||||||
main_status_(0),
|
|
||||||
interesting_event_mask_((int)Event8272::CommandByte),
|
|
||||||
resume_point_(0),
|
|
||||||
delay_time_(0),
|
|
||||||
head_timers_running_(0),
|
|
||||||
expects_input_(false),
|
|
||||||
drives_seeking_(0) {
|
|
||||||
posit_event((int)Event8272::CommandByte);
|
posit_event((int)Event8272::CommandByte);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,15 +50,15 @@ class i8272: public Storage::Disk::MFMController {
|
|||||||
std::unique_ptr<BusHandler> allocated_bus_handler_;
|
std::unique_ptr<BusHandler> allocated_bus_handler_;
|
||||||
|
|
||||||
// Status registers.
|
// Status registers.
|
||||||
uint8_t main_status_;
|
uint8_t main_status_ = 0;
|
||||||
uint8_t status_[3];
|
uint8_t status_[3] = {0, 0, 0};
|
||||||
|
|
||||||
// A buffer for accumulating the incoming command, and one for accumulating the result.
|
// A buffer for accumulating the incoming command, and one for accumulating the result.
|
||||||
std::vector<uint8_t> command_;
|
std::vector<uint8_t> command_;
|
||||||
std::vector<uint8_t> result_stack_;
|
std::vector<uint8_t> result_stack_;
|
||||||
uint8_t input_;
|
uint8_t input_ = 0;
|
||||||
bool has_input_;
|
bool has_input_ = false;
|
||||||
bool expects_input_;
|
bool expects_input_ = false;
|
||||||
|
|
||||||
// Event stream: the 8272-specific events, plus the current event state.
|
// Event stream: the 8272-specific events, plus the current event state.
|
||||||
enum class Event8272: int {
|
enum class Event8272: int {
|
||||||
@ -68,41 +68,37 @@ class i8272: public Storage::Disk::MFMController {
|
|||||||
NoLongerReady = (1 << 6)
|
NoLongerReady = (1 << 6)
|
||||||
};
|
};
|
||||||
void posit_event(int type);
|
void posit_event(int type);
|
||||||
int interesting_event_mask_;
|
int interesting_event_mask_ = (int)Event8272::CommandByte;
|
||||||
int resume_point_;
|
int resume_point_ = 0;
|
||||||
bool is_access_command_;
|
bool is_access_command_ = false;
|
||||||
|
|
||||||
// The counter used for ::Timer events.
|
// The counter used for ::Timer events.
|
||||||
int delay_time_;
|
int delay_time_ = 0;
|
||||||
|
|
||||||
// The connected drives.
|
// The connected drives.
|
||||||
struct Drive {
|
struct Drive {
|
||||||
uint8_t head_position;
|
uint8_t head_position = 0;
|
||||||
|
|
||||||
// Seeking: persistent state.
|
// Seeking: persistent state.
|
||||||
enum Phase {
|
enum Phase {
|
||||||
NotSeeking,
|
NotSeeking,
|
||||||
Seeking,
|
Seeking,
|
||||||
CompletedSeeking
|
CompletedSeeking
|
||||||
} phase;
|
} phase = NotSeeking;
|
||||||
bool did_seek;
|
bool did_seek = false;
|
||||||
bool seek_failed;
|
bool seek_failed = false;
|
||||||
|
|
||||||
// Seeking: transient state.
|
// Seeking: transient state.
|
||||||
int step_rate_counter;
|
int step_rate_counter = 0;
|
||||||
int steps_taken;
|
int steps_taken = 0;
|
||||||
int target_head_position; // either an actual number, or -1 to indicate to step until track zero
|
int target_head_position = 0; // either an actual number, or -1 to indicate to step until track zero
|
||||||
|
|
||||||
// Head state.
|
// Head state.
|
||||||
int head_unload_delay[2];
|
int head_unload_delay[2] = {0, 0};
|
||||||
bool head_is_loaded[2];
|
bool head_is_loaded[2] = {false, false};
|
||||||
|
|
||||||
Drive() :
|
|
||||||
head_position(0), phase(NotSeeking),
|
|
||||||
head_is_loaded{false, false},
|
|
||||||
head_unload_delay{0, 0} {};
|
|
||||||
} drives_[4];
|
} drives_[4];
|
||||||
int drives_seeking_;
|
int drives_seeking_ = 0;
|
||||||
|
|
||||||
/// @returns @c true if the selected drive, which is number @c drive, can stop seeking.
|
/// @returns @c true if the selected drive, which is number @c drive, can stop seeking.
|
||||||
bool seek_is_satisfied(int drive);
|
bool seek_is_satisfied(int drive);
|
||||||
@ -115,22 +111,22 @@ class i8272: public Storage::Disk::MFMController {
|
|||||||
bool is_executing_ = false;
|
bool is_executing_ = false;
|
||||||
|
|
||||||
// A count of head unload timers currently running.
|
// A count of head unload timers currently running.
|
||||||
int head_timers_running_;
|
int head_timers_running_ = 0;
|
||||||
|
|
||||||
// Transient storage and counters used while reading the disk.
|
// Transient storage and counters used while reading the disk.
|
||||||
uint8_t header_[6];
|
uint8_t header_[6] = {0, 0, 0, 0, 0, 0};
|
||||||
int distance_into_section_;
|
int distance_into_section_ = 0;
|
||||||
int index_hole_count_, index_hole_limit_;
|
int index_hole_count_ = 0, index_hole_limit_ = 0;
|
||||||
|
|
||||||
// Keeps track of the drive and head in use during commands.
|
// Keeps track of the drive and head in use during commands.
|
||||||
int active_drive_;
|
int active_drive_ = 0;
|
||||||
int active_head_;
|
int active_head_ = 0;
|
||||||
|
|
||||||
// Internal registers.
|
// Internal registers.
|
||||||
uint8_t cylinder_, head_, sector_, size_;
|
uint8_t cylinder_ = 0, head_ = 0, sector_ = 0, size_ = 0;
|
||||||
|
|
||||||
// Master switch on not performing any work.
|
// Master switch on not performing any work.
|
||||||
bool is_sleeping_;
|
bool is_sleeping_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user