Skip to content

Commit

Permalink
[#40] Track Map: General improvements and bugfixes (Part 32: Added co…
Browse files Browse the repository at this point in the history
…ntext menu command to rescan selected track)
  • Loading branch information
tomas-nestorovic committed Jun 24, 2023
1 parent 7738058 commit 260c7d4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Main/res/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ BEGIN
MENUITEM "Show track low-level", ID_HEAD, GRAYED
MENUITEM SEPARATOR
MENUITEM "Show sector hexa", ID_SECTOR, GRAYED
MENUITEM SEPARATOR
MENUITEM "Rescan", ID_ACCURACY, GRAYED
END
END

Expand Down
23 changes: 23 additions & 0 deletions Main/src/ViewTrackMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,15 @@
mnu.EnableMenuItem( ID_TRACK, MF_BYCOMMAND|MF_ENABLED );
if (IMAGE->ReadTrack( chs.cylinder, chs.head )) // CANNOT alternatively call WriteTrack with Invalid data for some containers (e.g. *.IPF) don't allow for writing!
mnu.EnableMenuItem( ID_HEAD, MF_BYCOMMAND|MF_ENABLED );
if (!IMAGE->properties->IsRealDevice() // possible only for real Devices
||
IMAGE->UnscanTrack( TPhysicalAddress::Invalid.cylinder, TPhysicalAddress::Invalid.head )==ERROR_NOT_SUPPORTED
||
DOS->properties!=&CUnknownDos::Properties // "unscanning" a Track is safe only when no other operations with the disk are possible
)
mnu.ModifyMenu( ID_ACCURACY, MF_BYCOMMAND|MF_GRAYED, 0, _T("Can't rescan any track") );
else if (IMAGE->IsTrackScanned( chs.cylinder, chs.head ))
mnu.EnableMenuItem( ID_ACCURACY, MF_BYCOMMAND|MF_ENABLED );
break;
default:
return;
Expand Down Expand Up @@ -643,6 +652,20 @@
if (const auto tr=IMAGE->ReadTrack( chs.cylinder, chs.head ))
tr.ShowModal( _T("Track %d (Cyl=%d, Head=%d)"), chs.GetTrackNumber(scanner.params.nHeads), chs.cylinder, chs.head );
break;
case ID_ACCURACY:
// rescan Track
if (const TStdWinError err=IMAGE->UnscanTrack( chs.cylinder, chs.head ))
Utils::Information( _T("Can't rescan"), err );
else{
RECT rcTrack;
GetClientRect(&rcTrack);
rcTrack.top= TRACK0_Y + (chs.cylinder*scanner.params.nHeads+chs.head)*TRACK_HEIGHT;
rcTrack.bottom=rcTrack.top+TRACK_HEIGHT;
Utils::ScaleLogicalUnit( (PINT)&rcTrack, 4 ); static_assert( sizeof(int)==sizeof(LONG), "" );
::OffsetRect( &rcTrack, 0, -GetScrollPos(SB_VERT) );
::InvalidateRect( *this, &rcTrack, TRUE );
}
break;
}
}

Expand Down

0 comments on commit 260c7d4

Please sign in to comment.