Skip to content

Commit

Permalink
[#57] Support for KryoFlux and associated images (Part 68: Added prec…
Browse files Browse the repository at this point in the history
…ompensation determination "Method 1")
  • Loading branch information
tomas-nestorovic committed Feb 1, 2021
1 parent 0a27a07 commit 9d55bce
Show file tree
Hide file tree
Showing 19 changed files with 469 additions and 38 deletions.
1 change: 1 addition & 0 deletions Main/Main.vcxproj
Expand Up @@ -247,6 +247,7 @@
<ClCompile Include="src\BSDOS_FAT.cpp" />
<ClCompile Include="src\BSDOS_FileManager.cpp" />
<ClCompile Include="src\CapsBase.cpp" />
<ClCompile Include="src\CapsBase_Precomp.cpp" />
<ClCompile Include="src\CtRaw.cpp" />
<ClCompile Include="src\Debug.cpp" />
<ClCompile Include="src\DialogRealDeviceSelection.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions Main/Main.vcxproj.filters
Expand Up @@ -446,6 +446,9 @@
<ClCompile Include="src\OptionalLibAPIs.cpp">
<Filter>Source Files\Utils</Filter>
</ClCompile>
<ClCompile Include="src\CapsBase_Precomp.cpp">
<Filter>Source Files\Image</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\resource.rc">
Expand Down
3 changes: 2 additions & 1 deletion Main/res/resource.h
Expand Up @@ -55,6 +55,7 @@
#define IDR_KRYOFLUX_ACCESS 220
#define IDR_CAPS 221
#define IDR_TRACK_EDITOR 222
#define IDR_CAPS_PRECOMPENSATION 224
#define ID_HIDDEN 1018
#define ID_SYSTEM 1019
#define ID_CONNECTED 1020
Expand Down Expand Up @@ -262,7 +263,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 223
#define _APS_NEXT_RESOURCE_VALUE 225
#define _APS_NEXT_COMMAND_VALUE 40291
#define _APS_NEXT_CONTROL_VALUE 1185
#define _APS_NEXT_SYMED_VALUE 103
Expand Down
56 changes: 41 additions & 15 deletions Main/res/resource.rc
Expand Up @@ -1582,13 +1582,13 @@ BEGIN
LTEXT "Error",ID_ERROR,15,73,47,15,WS_BORDER | NOT WS_GROUP
END

IDR_KRYOFLUX_ACCESS DIALOG DISCARDABLE 0, 0, 225, 236
IDR_KRYOFLUX_ACCESS DIALOG DISCARDABLE 0, 0, 225, 258
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
CAPTION "KryoFlux access options"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,115,215,50,14
PUSHBUTTON "Cancel",IDCANCEL,168,215,50,14
DEFPUSHBUTTON "OK",IDOK,115,237,50,14
PUSHBUTTON "Cancel",IDCANCEL,168,237,50,14
LTEXT "Firmware:",IDC_STATIC,7,8,31,8,NOT WS_GROUP
LTEXT "Static",ID_SYSTEM,71,8,147,8,NOT WS_GROUP
LTEXT "&Precision:",IDC_STATIC,7,24,32,8
Expand All @@ -1605,28 +1605,30 @@ BEGIN
PUSHBUTTON "Refresh",ID_RECOVER,170,70,48,13
CONTROL "Double track distance",ID_40D80,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,71,87,147,10
LTEXT "Calibrate head:",IDC_STATIC,7,102,48,8,NOT WS_GROUP
LTEXT "Pre-compensation:",IDC_STATIC,7,102,60,8
CONTROL "",ID_ALIGN,"SysLink",WS_TABSTOP,71,102,147,16
LTEXT "Calibrate head:",IDC_STATIC,7,124,48,8,NOT WS_GROUP
CONTROL "Never",ID_NONE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,
71,102,74,10
71,124,74,10
CONTROL "O&nce per cylinder",ID_CYLINDER,"Button",
BS_AUTORADIOBUTTON,71,113,71,10
BS_AUTORADIOBUTTON,71,135,71,10
CONTROL "For each &sector",ID_SECTOR,"Button",BS_AUTORADIOBUTTON,
71,124,65,10
71,146,65,10
CONTROL "Never",ID_ZERO,"Button",BS_AUTORADIOBUTTON |
WS_DISABLED | WS_GROUP,71,140,74,10
WS_DISABLED | WS_GROUP,71,162,74,10
CONTROL "&Each",ID_CYLINDER_N,"Button",BS_AUTORADIOBUTTON |
WS_DISABLED,71,151,31,10
EDITTEXT ID_NUMBER,103,152,16,12,ES_RIGHT | ES_AUTOHSCROLL |
WS_DISABLED,71,173,31,10
EDITTEXT ID_NUMBER,103,174,16,12,ES_RIGHT | ES_AUTOHSCROLL |
ES_NUMBER | WS_DISABLED | NOT WS_BORDER
LTEXT "-th cyl.",IDC_STATIC,119,152,22,8,NOT WS_GROUP
LTEXT "-th cyl.",IDC_STATIC,119,174,22,8,NOT WS_GROUP
CONTROL "&Verify formatted tracks before writing any data (recommended)",
ID_VERIFY_TRACK,"Button",BS_AUTOCHECKBOX | WS_DISABLED |
WS_TABSTOP,7,179,211,10
WS_TABSTOP,7,201,211,10
CONTROL "Verify &written data (including requested data errors, if any)",
ID_VERIFY_SECTOR,"Button",BS_AUTOCHECKBOX | WS_DISABLED |
WS_TABSTOP,7,190,195,10
WS_TABSTOP,7,212,195,10
CONTROL "Normalize read tracks (timing correction)",ID_TRACK,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,168,141,10
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,190,141,10
END

IDR_CAPS DIALOGEX 0, 0, 186, 127
Expand Down Expand Up @@ -1665,6 +1667,22 @@ BEGIN
TBS_NOTICKS | WS_BORDER,0,117,149,17
END

IDR_CAPS_PRECOMPENSATION DIALOG DISCARDABLE 0, 0, 186, 159
STYLE WS_POPUP | WS_CAPTION
CAPTION "Precompensation"
FONT 8, "MS Sans Serif"
BEGIN
PUSHBUTTON "Close",IDCANCEL,129,138,50,14
EDITTEXT ID_INFORMATION,7,24,172,102,ES_MULTILINE |
ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY |
WS_VSCROLL
LTEXT "Floppy type:",IDC_STATIC,7,8,39,8,NOT WS_GROUP
COMBOBOX ID_MEDIUM,58,7,121,65,CBS_DROPDOWNLIST | WS_VSCROLL |
WS_TABSTOP
PUSHBUTTON "",IDRETRY,29,138,95,14
END


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
Expand Down Expand Up @@ -1935,7 +1953,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 218
TOPMARGIN, 7
BOTTOMMARGIN, 229
BOTTOMMARGIN, 251
END

IDR_CAPS, DIALOG
Expand All @@ -1950,6 +1968,14 @@ BEGIN
BEGIN
BOTTOMMARGIN, 142
END

IDR_CAPS_PRECOMPENSATION, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 152
END
END
#endif // APSTUDIO_INVOKED

Expand Down
4 changes: 3 additions & 1 deletion Main/src/CapsBase.cpp
Expand Up @@ -15,7 +15,7 @@
return ERROR_SUCCESS;
}

CCapsBase::CCapsBase(PCProperties properties,bool hasEditableSettings)
CCapsBase::CCapsBase(PCProperties properties,char realDriveLetter,bool hasEditableSettings)
// ctor
// - base
: CFloppyImage(properties,hasEditableSettings)
Expand All @@ -24,6 +24,7 @@
// - creating a CAPS device
, capsDeviceHandle( capsLibLoadingError ? -1 : CAPS::AddImage() )
// - initialization
, precompensation(realDriveLetter)
, forcedMediumType( Medium::FLOPPY_ANY )
, lastSuccessfullCodec(Codec::MFM) {
::ZeroMemory( &capsImageInfo, sizeof(capsImageInfo) );
Expand Down Expand Up @@ -685,6 +686,7 @@ returnData: *outFdcStatuses++=currRev->fdcStatus;
auto &rit=internalTracks[cyl][head];
delete rit, rit=nullptr; // ... disposing it and letting DOS later read it once again
}
precompensation.Load( pFormat->mediumType );
return ERROR_SUCCESS;
}
}
Expand Down
28 changes: 27 additions & 1 deletion Main/src/CapsBase.h
Expand Up @@ -76,6 +76,32 @@
} *PInternalTrack;
typedef const CInternalTrack *PCInternalTrack;

class CPrecompensation sealed{
Medium::TType floppyType;

static UINT AFX_CDECL PrecompensationDetermination_thread(PVOID pCancelableAction);
public:
const char driveLetter;
enum TMethodVersion:BYTE{
None,
MethodVersion1,
MethodLatest = MethodVersion1
} methodVersion;
union{
struct{
double coeffs[2][5]; // coefficients for even (0) and odd (1) fluxes
} v1;
};

CPrecompensation(char driveLetter);

void Load(Medium::TType floppyType);
void Save() const;
TStdWinError DetermineUsingLatestMethod(const CCapsBase &cb,BYTE nTrials=4);
void ShowOrDetermineModal(const CCapsBase &cb);
bool ApplyTo(CTrackReaderWriter trw) const;
} precompensation;

const TStdWinError capsLibLoadingError;
const SDWORD capsDeviceHandle;
CapsVersionInfo capsVersionInfo;
Expand All @@ -84,7 +110,7 @@

mutable Codec::TType lastSuccessfullCodec;

CCapsBase(PCProperties properties,bool hasEditableSettings);
CCapsBase(PCProperties properties,char realDriveLetter,bool hasEditableSettings);

void DestroyAllTracks();
public:
Expand Down

0 comments on commit 9d55bce

Please sign in to comment.