Skip to content

Commit

Permalink
[#65] Greaseweazle boards (Part 18: Physical range of tracks is a dri…
Browse files Browse the repository at this point in the history
…ve's property to be saved for next session)
  • Loading branch information
tomas-nestorovic committed Nov 15, 2023
1 parent 37f4930 commit 9ac538b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
18 changes: 5 additions & 13 deletions Main/src/CapsBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
, lastSuccessfullCodec(Codec::MFM) {
::ZeroMemory( &capsImageInfo, sizeof(capsImageInfo) );
::ZeroMemory( internalTracks, sizeof(internalTracks) );
params.fortyTrackDrive&=properties->IsRealDevice();
}

CCapsBase::~CCapsBase(){
Expand Down Expand Up @@ -1193,6 +1194,7 @@
#define INI_FLUX_DECODER _T("decod")
#define INI_FLUX_DECODER_RESET _T("drst")
#define INI_PRECISION _T("prec2")
#define INI_40_TRACK_DRIVE _T("sd40")
#define INI_CALIBRATE_SECTOR_ERROR _T("clberr")
#define INI_CALIBRATE_SECTOR_ERROR_KNOWN _T("clbknw")
#define INI_CALIBRATE_FORMATTING _T("clbfmt")
Expand All @@ -1205,14 +1207,14 @@
, precision( (TPrecision)app.GetProfileInt(iniSectionName,INI_PRECISION,TPrecision::BASIC) )
, fluxDecoder( (TFluxDecoder)app.GetProfileInt(iniSectionName,INI_FLUX_DECODER,TFluxDecoder::KEIR_FRASER) )
, resetFluxDecoderOnIndex( (TFluxDecoder)app.GetProfileInt(iniSectionName,INI_FLUX_DECODER_RESET,true)!=0 )
, fortyTrackDrive( app.GetProfileInt(iniSectionName,INI_40_TRACK_DRIVE,0)!=0 )
, calibrationAfterError( (TCalibrationAfterError)app.GetProfileInt(iniSectionName,INI_CALIBRATE_SECTOR_ERROR,TCalibrationAfterError::ONCE_PER_CYLINDER) )
, calibrationAfterErrorOnlyForKnownSectors( app.GetProfileInt(iniSectionName,INI_CALIBRATE_SECTOR_ERROR_KNOWN,0)!=0 )
, calibrationStepDuringFormatting( app.GetProfileInt(iniSectionName,INI_CALIBRATE_FORMATTING,0) )
, corrections( iniSectionName )
, verifyWrittenTracks( app.GetProfileInt(iniSectionName,INI_VERIFY_WRITTEN_TRACKS,true)!=0 )
// - volatile (current session only)
, flippyDisk(false) , userForcedFlippyDisk(false)
, fortyTrackDrive(false) , userForcedFortyTrackDrive(false)
, doubleTrackStep(false) , userForcedDoubleTrackStep(false) { // True once the ID_40D80 button in Settings dialog is pressed
}

Expand All @@ -1221,6 +1223,7 @@
app.WriteProfileInt( iniSectionName, INI_PRECISION, precision );
app.WriteProfileInt( iniSectionName, INI_FLUX_DECODER, fluxDecoder );
app.WriteProfileInt( iniSectionName, INI_FLUX_DECODER_RESET, resetFluxDecoderOnIndex );
app.WriteProfileInt( iniSectionName, INI_40_TRACK_DRIVE, fortyTrackDrive );
app.WriteProfileInt( iniSectionName, INI_CALIBRATE_SECTOR_ERROR, calibrationAfterError );
app.WriteProfileInt( iniSectionName, INI_CALIBRATE_SECTOR_ERROR_KNOWN, calibrationAfterErrorOnlyForKnownSectors );
app.WriteProfileInt( iniSectionName, INI_CALIBRATE_FORMATTING, calibrationStepDuringFormatting );
Expand Down Expand Up @@ -1251,18 +1254,13 @@
const bool initialEditing;
CCapsBase &rcb;
CPrecompensation tmpPrecomp;
TCHAR flippyDiskTextOrg[40],fortyTrackDriveTextOrg[80],doubleTrackDistanceTextOrg[80];
TCHAR flippyDiskTextOrg[40],doubleTrackDistanceTextOrg[80];

bool IsFlippyDiskForcedByUser() const{
// True <=> user has manually overrode FlippyDisk setting, otherwise False
return ::lstrlen(flippyDiskTextOrg)!=GetDlgItemTextLength(ID_SIDE);
}

bool IsShugartDriveForcedByUser() const{
// True <=> user has manually overrode ShugartDrive setting, otherwise False
return ::lstrlen(fortyTrackDriveTextOrg)!=GetDlgItemTextLength(ID_DRIVE);
}

bool IsDoubleTrackDistanceForcedByUser() const{
// True <=> user has manually overrode DoubleTrackDistance setting, otherwise False
return ::lstrlen(doubleTrackDistanceTextOrg)!=GetDlgItemTextLength(ID_40D80);
Expand Down Expand Up @@ -1375,9 +1373,6 @@
GetDlgItemText( ID_40D80, doubleTrackDistanceTextOrg, ARRAYSIZE(doubleTrackDistanceTextOrg) );
if (rcb.params.userForcedDoubleTrackStep)
SendMessage( WM_COMMAND, ID_40D80 );
GetDlgItemText( ID_DRIVE, fortyTrackDriveTextOrg, ARRAYSIZE(fortyTrackDriveTextOrg) );
if (rcb.params.userForcedFortyTrackDrive)
SendMessage( WM_COMMAND, ID_DRIVE );
CheckAndEnableDlgItem( ID_40D80,
rcb.params.doubleTrackStep,
!CheckDlgItem( ID_DRIVE, rcb.params.fortyTrackDrive )
Expand Down Expand Up @@ -1487,7 +1482,6 @@
if (initialEditing){ // if no Tracks are yet formatted, then resetting the flag that user has overridden these settings
CheckDlgItem( ID_DRIVE, CheckDlgItem(ID_SIDE,false) );
SetDlgItemText( ID_SIDE, flippyDiskTextOrg );
SetDlgItemText( ID_DRIVE, fortyTrackDriveTextOrg );
SetDlgItemText( ID_40D80, doubleTrackDistanceTextOrg );
}
RefreshMediumInformation();
Expand All @@ -1498,7 +1492,6 @@
break;
case ID_DRIVE:
// drive physical track range changed manually
SetDlgItemFormattedText( ID_DRIVE, _T("%s (user forced)"), fortyTrackDriveTextOrg );
CheckAndEnableDlgItem( ID_40D80, false, !IsDlgItemChecked(ID_DRIVE) );
//fallthrough
case ID_40D80:
Expand All @@ -1524,7 +1517,6 @@
params.flippyDisk=IsDlgItemChecked(ID_SIDE);
params.userForcedFlippyDisk=IsFlippyDiskForcedByUser();
params.fortyTrackDrive=IsDlgItemChecked(ID_DRIVE);
params.userForcedFortyTrackDrive=IsShugartDriveForcedByUser();
params.doubleTrackStep=IsDlgItemChecked(ID_40D80);
params.userForcedDoubleTrackStep=IsDoubleTrackDistanceForcedByUser();
break;
Expand Down
2 changes: 1 addition & 1 deletion Main/src/CapsBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
MARK_OGDEN
} fluxDecoder;
bool resetFluxDecoderOnIndex;
bool fortyTrackDrive;
enum TCalibrationAfterError{
NONE =0,
ONCE_PER_CYLINDER =1,
Expand All @@ -159,7 +160,6 @@
bool verifyWrittenTracks;
// volatile (current session only)
bool flippyDisk, userForcedFlippyDisk;
bool fortyTrackDrive, userForcedFortyTrackDrive;
bool doubleTrackStep, userForcedDoubleTrackStep;

TParams(LPCTSTR iniSectionName);
Expand Down
2 changes: 1 addition & 1 deletion Main/src/Greaseweazle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
if (!ReadTrack(0,0))
continue; // must be able to turn motor on, seek to a Cylinder and read a Track
UnscanTrack(0,0);
params.fortyTrackDrive=busType==BUS_SHUGART;
params.fortyTrackDrive|=busType==BUS_SHUGART;
break;
}
// - evaluating connection
Expand Down

0 comments on commit 9ac538b

Please sign in to comment.