Skip to content

Commit

Permalink
Merge pull request #22 from captainys/Analyzer_Message_Fix
Browse files Browse the repository at this point in the history
Corrected disk_analyzer message when sector index is out of range.
  • Loading branch information
yas-sim authored Oct 24, 2023
2 parents 8f20216 + 2ffdbbc commit 37d76bf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions disk_analyzer/analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,15 @@ void cmd_read_sector(size_t cyl, size_t rcd, bool pulse_vis) {
track_stream = disk_img->get_track_data(cyl);
fdc->set_track_data(track_stream);
fdc->set_pos(0);
if(rcd >= 1000) { // read by sector index #
if(999==rcd) {
std::cout << "Index needs to be between 1 and the number of sectors in the track." << std::endl;
return;
}
else if(rcd >= 1000) { // read by sector index #
std::vector<fdc_bitstream::id_field> id_list = fdc->read_all_idam(); // get the list of all IDs
size_t sct_idx = rcd - 1000;
if (sct_idx >= id_list.size()) {
std::cout << "Index exceeded (the number of sectors)-1 in the track. (" << sct_idx << ">" << id_list.size()-1 << ")." << std::endl;
std::cout << "Index exceeded the number of sectors in the track. (" << sct_idx << ">" << id_list.size() << ")." << std::endl;
return;
}
fdc_bitstream::id_field sct_id = id_list[sct_idx];
Expand Down

0 comments on commit 37d76bf

Please sign in to comment.