mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-17 10:06:21 +00:00
Factors out repeated hex-size setting.
This commit is contained in:
parent
a9eb0d02c6
commit
5ab4cfee84
@ -114,7 +114,7 @@ void i8272::run_for(Cycles cycles) {
|
|||||||
while(steps--) {
|
while(steps--) {
|
||||||
// Perform a step.
|
// Perform a step.
|
||||||
int direction = (drives_[c].target_head_position < drives_[c].head_position) ? -1 : 1;
|
int direction = (drives_[c].target_head_position < drives_[c].head_position) ? -1 : 1;
|
||||||
LOG("Target " << std::dec << drives_[c].target_head_position << " versus believed " << static_cast<int>(drives_[c].head_position));
|
LOG("Target " << PADDEC(0) << drives_[c].target_head_position << " versus believed " << static_cast<int>(drives_[c].head_position));
|
||||||
select_drive(c);
|
select_drive(c);
|
||||||
get_drive().step(Storage::Disk::HeadPosition(direction));
|
get_drive().step(Storage::Disk::HeadPosition(direction));
|
||||||
if(drives_[c].target_head_position >= 0) drives_[c].head_position += direction;
|
if(drives_[c].target_head_position >= 0) drives_[c].head_position += direction;
|
||||||
@ -385,7 +385,7 @@ void i8272::posit_event(int event_type) {
|
|||||||
// the index hole limit is breached or a sector is found with a cylinder, head, sector and size equal to the
|
// the index hole limit is breached or a sector is found with a cylinder, head, sector and size equal to the
|
||||||
// values in the internal registers.
|
// values in the internal registers.
|
||||||
index_hole_limit_ = 2;
|
index_hole_limit_ = 2;
|
||||||
// LOG("Seeking " << std::dec << cylinder_ << " " << head_ " " << sector_ << " " << size_);
|
// LOG("Seeking " << PADDEC(0) << cylinder_ << " " << head_ " " << sector_ << " " << size_);
|
||||||
find_next_sector:
|
find_next_sector:
|
||||||
FIND_HEADER();
|
FIND_HEADER();
|
||||||
if(!index_hole_limit_) {
|
if(!index_hole_limit_) {
|
||||||
@ -406,7 +406,7 @@ void i8272::posit_event(int event_type) {
|
|||||||
// This implies a CRC error in the header; mark as such but continue.
|
// This implies a CRC error in the header; mark as such but continue.
|
||||||
SetDataError();
|
SetDataError();
|
||||||
}
|
}
|
||||||
// LOG("Considering << std::hex << header_[0] << " " << header_[1] << " " << header_[2] << " " << header_[3] << " [" << get_crc_generator().get_value() << "]");
|
// LOG("Considering << PADHEX(2) << header_[0] << " " << header_[1] << " " << header_[2] << " " << header_[3] << " [" << get_crc_generator().get_value() << "]");
|
||||||
if(header_[0] != cylinder_ || header_[1] != head_ || header_[2] != sector_ || header_[3] != size_) goto find_next_sector;
|
if(header_[0] != cylinder_ || header_[1] != head_ || header_[2] != sector_ || header_[3] != size_) goto find_next_sector;
|
||||||
|
|
||||||
// Branch to whatever is supposed to happen next
|
// Branch to whatever is supposed to happen next
|
||||||
@ -424,8 +424,7 @@ void i8272::posit_event(int event_type) {
|
|||||||
|
|
||||||
// Performs the read data or read deleted data command.
|
// Performs the read data or read deleted data command.
|
||||||
read_data:
|
read_data:
|
||||||
LOGNBR(std::hex << std::setw(2) << std::left << std::setfill('0'));
|
LOG(PADHEX(2) << "Read [deleted] data ["
|
||||||
LOG("Read [deleted] data ["
|
|
||||||
<< static_cast<int>(command_[2]) << " "
|
<< static_cast<int>(command_[2]) << " "
|
||||||
<< static_cast<int>(command_[3]) << " "
|
<< static_cast<int>(command_[3]) << " "
|
||||||
<< static_cast<int>(command_[4]) << " "
|
<< static_cast<int>(command_[4]) << " "
|
||||||
@ -515,8 +514,7 @@ void i8272::posit_event(int event_type) {
|
|||||||
goto post_st012chrn;
|
goto post_st012chrn;
|
||||||
|
|
||||||
write_data:
|
write_data:
|
||||||
LOGNBR(std::hex << std::setw(2) << std::left << std::setfill('0'));
|
LOG(PADHEX(2) << "Write [deleted] data ["
|
||||||
LOG("Write [deleted] data ["
|
|
||||||
<< static_cast<int>(command_[2]) << " "
|
<< static_cast<int>(command_[2]) << " "
|
||||||
<< static_cast<int>(command_[3]) << " "
|
<< static_cast<int>(command_[3]) << " "
|
||||||
<< static_cast<int>(command_[4]) << " "
|
<< static_cast<int>(command_[4]) << " "
|
||||||
@ -557,7 +555,7 @@ void i8272::posit_event(int event_type) {
|
|||||||
goto write_loop;
|
goto write_loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG("Wrote " << std::dec << distance_into_section_ << " bytes");
|
LOG("Wrote " << PADDEC(0) << distance_into_section_ << " bytes");
|
||||||
write_crc();
|
write_crc();
|
||||||
expects_input_ = false;
|
expects_input_ = false;
|
||||||
WAIT_FOR_EVENT(Event::DataWritten);
|
WAIT_FOR_EVENT(Event::DataWritten);
|
||||||
@ -573,8 +571,7 @@ void i8272::posit_event(int event_type) {
|
|||||||
// Performs the read ID command.
|
// Performs the read ID command.
|
||||||
read_id:
|
read_id:
|
||||||
// Establishes the drive and head being addressed, and whether in double density mode.
|
// Establishes the drive and head being addressed, and whether in double density mode.
|
||||||
LOGNBR(std::hex << std::setw(2) << std::left << std::setfill('0'));
|
LOG(PADHEX(2) << "Read ID [" << static_cast<int>(command_[0]) << " " << static_cast<int>(command_[1]) << "]");
|
||||||
LOG("Read ID [" << static_cast<int>(command_[0]) << " " << static_cast<int>(command_[1]) << "]");
|
|
||||||
|
|
||||||
// Sets a maximum index hole limit of 2 then waits either until it finds a header mark or sees too many index holes.
|
// Sets a maximum index hole limit of 2 then waits either until it finds a header mark or sees too many index holes.
|
||||||
// If a header mark is found, reads in the following bytes that produce a header. Otherwise branches to data not found.
|
// If a header mark is found, reads in the following bytes that produce a header. Otherwise branches to data not found.
|
||||||
@ -596,8 +593,7 @@ void i8272::posit_event(int event_type) {
|
|||||||
|
|
||||||
// Performs read track.
|
// Performs read track.
|
||||||
read_track:
|
read_track:
|
||||||
LOGNBR(std::hex << std::setw(2) << std::left << std::setfill('0'));
|
LOG(PADHEX(2) << "Read track ["
|
||||||
LOG("Read track ["
|
|
||||||
<< static_cast<int>(command_[2]) << " "
|
<< static_cast<int>(command_[2]) << " "
|
||||||
<< static_cast<int>(command_[3]) << " "
|
<< static_cast<int>(command_[3]) << " "
|
||||||
<< static_cast<int>(command_[4]) << " "
|
<< static_cast<int>(command_[4]) << " "
|
||||||
@ -686,8 +682,7 @@ void i8272::posit_event(int event_type) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGNBR(std::hex << std::setw(2) << std::left << std::setfill('0'));
|
LOG(PADHEX(2) << "W:"
|
||||||
LOG("W:"
|
|
||||||
<< static_cast<int>(header_[0]) << " "
|
<< static_cast<int>(header_[0]) << " "
|
||||||
<< static_cast<int>(header_[1]) << " "
|
<< static_cast<int>(header_[1]) << " "
|
||||||
<< static_cast<int>(header_[2]) << " "
|
<< static_cast<int>(header_[2]) << " "
|
||||||
@ -763,8 +758,7 @@ void i8272::posit_event(int event_type) {
|
|||||||
// up in run_for understands to mean 'keep going until track 0 is active').
|
// up in run_for understands to mean 'keep going until track 0 is active').
|
||||||
if(command_.size() > 2) {
|
if(command_.size() > 2) {
|
||||||
drives_[drive].target_head_position = command_[2];
|
drives_[drive].target_head_position = command_[2];
|
||||||
LOGNBR(std::hex << std::setw(2) << std::left << std::setfill('0'));
|
LOG(PADHEX(2) << "Seek to " << static_cast<int>(command_[2]));
|
||||||
LOG("Seek to " << static_cast<int>(command_[2]));
|
|
||||||
} else {
|
} else {
|
||||||
drives_[drive].target_head_position = -1;
|
drives_[drive].target_head_position = -1;
|
||||||
drives_[drive].head_position = 0;
|
drives_[drive].head_position = 0;
|
||||||
@ -859,8 +853,7 @@ void i8272::posit_event(int event_type) {
|
|||||||
// Posts whatever is in result_stack_ as a result phase. Be aware that it is a stack, so the
|
// Posts whatever is in result_stack_ as a result phase. Be aware that it is a stack, so the
|
||||||
// last thing in it will be returned first.
|
// last thing in it will be returned first.
|
||||||
post_result:
|
post_result:
|
||||||
LOGNBR(std::hex << std::setw(2) << std::left << std::setfill('0'));
|
LOGNBR(PADHEX(2) << "Result to " << static_cast<int>(command_[0] & 0x1f) << ", main " << static_cast<int>(main_status_));
|
||||||
LOGNBR("Result to " << static_cast<int>(command_[0] & 0x1f) << ", main " << static_cast<int>(main_status_));
|
|
||||||
for(std::size_t c = 0; c < result_stack_.size(); c++) {
|
for(std::size_t c = 0; c < result_stack_.size(); c++) {
|
||||||
LOGNBR(static_cast<int>(result_stack_[result_stack_.size() - 1 - c]));
|
LOGNBR(static_cast<int>(result_stack_[result_stack_.size() - 1 - c]));
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#define LOG(x)
|
#define LOG(x)
|
||||||
#define LOGNBR(x)
|
#define LOGNBR(x)
|
||||||
|
|
||||||
#define ERROR(x)
|
#define ERROR(x)
|
||||||
#define ERRORNBR(x)
|
#define ERRORNBR(x)
|
||||||
|
|
||||||
@ -22,8 +23,12 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <ios>
|
#include <ios>
|
||||||
|
|
||||||
|
#define PADHEX(n) std::hex << std::setw(n) << std::right << std::setfill('0')
|
||||||
|
#define PADDEC(n) std::dec << std::setw(n) << std::right << std::setfill('0')
|
||||||
|
|
||||||
#define LOG(x) std::cout << x << std::endl
|
#define LOG(x) std::cout << x << std::endl
|
||||||
#define LOGNBR(x) std::cout << x
|
#define LOGNBR(x) std::cout << x
|
||||||
|
|
||||||
#define ERROR(x) std::cerr << x << std::endl
|
#define ERROR(x) std::cerr << x << std::endl
|
||||||
#define ERRORNBR(x) std::cerr << x
|
#define ERRORNBR(x) std::cerr << x
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user