typedef struct CapsTrackInfoT2 *PCAPSTRACKINFOT2;
+// disk sector information block
+struct CapsSectorInfo {
+ UDWORD descdatasize; // data size in bits from IPF descriptor
+ UDWORD descgapsize; // gap size in bits from IPF descriptor
+ UDWORD datasize; // data size in bits from decoder
+ UDWORD gapsize; // gap size in bits from decoder
+ UDWORD datastart; // data start position in bits from decoder
+ UDWORD gapstart; // gap start position in bits from decoder
+ UDWORD gapsizews0; // gap size before write splice
+ UDWORD gapsizews1; // gap size after write splice
+ UDWORD gapws0mode; // gap size mode before write splice
+ UDWORD gapws1mode; // gap size mode after write splice
+ UDWORD celltype; // bitcell type
+ UDWORD enctype; // encoder type
+};
+
+typedef struct CapsSectorInfo *PCAPSSECTORINFO;
+
+// disk data information block
+struct CapsDataInfo {
+ UDWORD type; // data type
+ UDWORD start; // start position
+ UDWORD size; // size in bits
+};
+
+typedef struct CapsDataInfo *PCAPSDATAINFO;
+
+// disk data information block
+struct CapsRevolutionInfo {
+ SDWORD next; // the revolution number used by the next track lock call
+ SDWORD last; // the revolution number used by the lack track lock call
+ SDWORD real; // the real revolution number used by the last track lock call
+ SDWORD max; // the maximum revolution available for the selected track, <0 unlimited/randomized, 0 empty
+};
+
+typedef struct CapsRevolutionInfo *PCAPSREVOLUTIONINFO;
+
#pragma pack(pop)
-// image type
+// CapsImageInfo.image type
enum {
ciitNA=0, // invalid image type
ciitFDD // floppy disk
};
-// platform IDs, not about configuration, but intended use
+// CapsImageInfo.platform IDs, not about configuration, but intended use
enum {
ciipNA=0, // invalid platform (dummy entry)
ciipAmiga,
ciipAtari8
};
-// track type
+// CapsTrackInfo.track type
enum {
ctitNA=0, // invalid type
ctitNoise, // cells are unformatted (random size)
ctitVar // variable density
};
+// CapsSectorInfo.bitcell type
+enum {
+ csicNA=0, // invalid cell type
+ csic2us // 2us cells
+};
+
+// CapsSectorInfo.encoder type
+enum {
+ csieNA=0, // undefined encoder
+ csieMFM, // MFM
+ csieRaw // no encoder used, test data only
+};
+
+// CapsSectorInfo.gap size mode
+enum {
+ csiegmFixed=0, // fixed size, can't be changed
+ csiegmAuto, // size can be changed, resize information calculated automatically
+ csiegmResize // size can be changed, resize information is scripted
+};
+
+// CapsDataInfo.data type
+enum {
+ cditNA=0, // undefined
+ cditWeak // weak bits
+};
+
+// CAPSGetInfo inftype
+enum {
+ cgiitNA=0, // illegal
+ cgiitSector, // CapsSectorInfo
+ cgiitWeak, // CapsDataInfo, weak bits
+ cgiitRevolution // CapsRevolutionInfo
+};
+
// image error status
enum {
imgeOk=0,
#ifdef CAPS_USER
#define LIB_USER
#endif
-#include "comlib.h"
+#include "ComLib.h"
ExtSub SDWORD __cdecl CAPSInit();
ExtSub SDWORD __cdecl CAPSExit();
ExtSub SDWORD __cdecl CAPSUnlockImage(SDWORD id);
ExtSub SDWORD __cdecl CAPSLoadImage(SDWORD id, UDWORD flag);
ExtSub SDWORD __cdecl CAPSGetImageInfo(PCAPSIMAGEINFO pi, SDWORD id);
-ExtSub SDWORD __cdecl CAPSLockTrack(PCAPSTRACKINFO pi, SDWORD id, UDWORD cylinder, UDWORD head, UDWORD flag);
+ExtSub SDWORD __cdecl CAPSLockTrack(PVOID ptrackinfo, SDWORD id, UDWORD cylinder, UDWORD head, UDWORD flag);
ExtSub SDWORD __cdecl CAPSUnlockTrack(SDWORD id, UDWORD cylinder, UDWORD head);
ExtSub SDWORD __cdecl CAPSUnlockAllTracks(SDWORD id);
ExtSub PCHAR __cdecl CAPSGetPlatformName(UDWORD pid);
-ExtSub SDWORD __cdecl CAPSGetVersionInfo(PCAPSVERSIONINFO pi, UDWORD flag);
+ExtSub SDWORD __cdecl CAPSGetVersionInfo(PVOID pversioninfo, UDWORD flag);
+ExtSub UDWORD __cdecl CAPSFdcGetInfo(SDWORD iid, PCAPSFDC pc, SDWORD ext);
+ExtSub SDWORD __cdecl CAPSFdcInit(PCAPSFDC pc);
+ExtSub void __cdecl CAPSFdcReset(PCAPSFDC pc);
+ExtSub void __cdecl CAPSFdcEmulate(PCAPSFDC pc, UDWORD cyclecnt);
+ExtSub UDWORD __cdecl CAPSFdcRead(PCAPSFDC pc, UDWORD address);
+ExtSub void __cdecl CAPSFdcWrite(PCAPSFDC pc, UDWORD address, UDWORD data);
+ExtSub SDWORD __cdecl CAPSFdcInvalidateTrack(PCAPSFDC pc, SDWORD drive);
+ExtSub SDWORD __cdecl CAPSFormatDataToMFM(PVOID pformattrack, UDWORD flag);
+ExtSub SDWORD __cdecl CAPSGetInfo(PVOID pinfo, SDWORD id, UDWORD cylinder, UDWORD head, UDWORD inftype, UDWORD infid);
+ExtSub SDWORD __cdecl CAPSSetRevolution(SDWORD id, UDWORD value);
#endif
#endif
-#define ExtSub
-#define ExtVar
+#define ExtSub extern "C" DllSub
+#define ExtVar extern "C" DllVar
#include "ComType.h"
#include "CapsAPI.h"
+#define CAPS_TRACKTIMING 1
+
static SDWORD caps_cont[4]= {-1, -1, -1, -1};
static int caps_locked[4];
static int caps_flags = DI_LOCK_DENVAR|DI_LOCK_DENNOISE|DI_LOCK_NOISE|DI_LOCK_UPDATEFD|DI_LOCK_TYPE|DI_LOCK_OVLBIT;
static CAPSUNLOCKALLTRACKS pCAPSUnlockAllTracks;
typedef SDWORD (__cdecl* CAPSGETVERSIONINFO)(PCAPSVERSIONINFO,UDWORD);
static CAPSGETVERSIONINFO pCAPSGetVersionInfo;
+typedef SDWORD (__cdecl* CAPSGETINFO)(PVOID pinfo, SDWORD id, UDWORD cylinder, UDWORD head, UDWORD inftype, UDWORD infid);
+static CAPSGETINFO pCAPSGetInfo;
+typedef SDWORD (__cdecl* CAPSSETREVOLUTION)(SDWORD id, UDWORD value);
+static CAPSSETREVOLUTION pCAPSSetRevolution;
int caps_init (void)
{
pCAPSUnlockTrack = (CAPSUNLOCKTRACK)GetProcAddress (h, "CAPSUnlockTrack");
pCAPSUnlockAllTracks = (CAPSUNLOCKALLTRACKS)GetProcAddress (h, "CAPSUnlockAllTracks");
pCAPSGetVersionInfo = (CAPSGETVERSIONINFO)GetProcAddress (h, "CAPSGetVersionInfo");
+ pCAPSGetInfo = (CAPSGETINFO)GetProcAddress (h, "CAPSGetInfo");
+ pCAPSSetRevolution = (CAPSSETREVOLUTION)GetProcAddress (h, "CAPSSetRevolution");
+
init = 1;
cvi.type = 1;
pCAPSGetVersionInfo (&cvi, 0);
}
}
-static int load (struct CapsTrackInfoT2 *ci, int drv, int track, bool seed)
+static int load (struct CapsTrackInfoT2 *ci, int drv, int track, bool seed, bool newtrack)
{
int flags;
} else {
ci->type = 1;
}
+#if 0
+ if (newtrack)
+ flags |= DI_LOCK_NOUPDATE;
+#endif
if (pCAPSLockTrack ((PCAPSTRACKINFO)ci, caps_cont[drv], track / 2, track & 1, flags) != imgeOk)
return 0;
return 1;
}
-int caps_loadrevolution (uae_u16 *mfmbuf, int drv, int track, int *tracklength)
+int caps_loadrevolution (uae_u16 *mfmbuf, uae_u16 *tracktiming, int drv, int track, int *tracklength, int *nextrev)
{
int len;
struct CapsTrackInfoT2 ci;
- if (!load (&ci, drv, track, false))
+ if (!load (&ci, drv, track, false, false))
return 0;
if (oldlib)
len = ci.tracklen * 8;
len = ci.tracklen;
*tracklength = len;
mfmcopy (mfmbuf, ci.trackbuf, len);
+#if CAPS_TRACKTIMING
+ if (ci.timelen > 0 && tracktiming) {
+ for (int i = 0; i < ci.timelen; i++)
+ tracktiming[i] = (uae_u16)ci.timebuf[i];
+ }
+#endif
+ if (nextrev && pCAPSGetInfo) {
+ CapsRevolutionInfo pinfo;
+ *nextrev = 0;
+ pCAPSGetInfo(&pinfo, caps_cont[drv], track / 2, track & 1, cgiitRevolution, 0);
+ //write_log (_T("get next rev = %d\n"), pinfo.next);
+ if (pinfo.max > 0)
+ *nextrev = pinfo.next;
+ }
return 1;
}
-int caps_loadtrack (uae_u16 *mfmbuf, uae_u16 *tracktiming, int drv, int track, int *tracklength, int *multirev, int *gapoffset)
+int caps_loadtrack (uae_u16 *mfmbuf, uae_u16 *tracktiming, int drv, int track, int *tracklength, int *multirev, int *gapoffset, int *nextrev, bool sametrack)
{
int len;
struct CapsTrackInfoT2 ci;
+ CapsRevolutionInfo pinfo;
if (tracktiming)
*tracktiming = 0;
- if (!load (&ci, drv, track, true))
+
+ if (nextrev && pCAPSSetRevolution) {
+ if (sametrack) {
+ pCAPSSetRevolution(caps_cont[drv], *nextrev);
+ //write_log (_T("set rev = %d\n"), *nextrev);
+ } else {
+ pCAPSSetRevolution(caps_cont[drv], 0);
+ }
+ }
+
+ if (!load (&ci, drv, track, true, sametrack != true))
return 0;
+
+ if (nextrev && sametrack && pCAPSGetInfo) {
+ *nextrev = 0;
+ pCAPSGetInfo(&pinfo, caps_cont[drv], track / 2, track & 1, cgiitRevolution, 0);
+ //write_log (_T("get next rev = %d\n"), pinfo.next);
+ if (pinfo.max > 0)
+ *nextrev = pinfo.next;
+ }
+
*multirev = (ci.type & CTIT_FLAG_FLAKEY) ? 1 : 0;
if (oldlib) {
len = ci.tracklen * 8;
fclose (f);
}
#endif
+#if CAPS_TRACKTIMING
if (ci.timelen > 0 && tracktiming) {
for (int i = 0; i < ci.timelen; i++)
tracktiming[i] = (uae_u16)ci.timebuf[i];
}
+#endif
#if 0
write_log (_T("caps: drive:%d track:%d len:%d multi:%d timing:%d type:%d overlap:%d\n"),
drv, track, len, *multirev, ci.timelen, type, ci.overlap);
int caps_init (void);
void caps_unloadimage (int drv);
int caps_loadimage (struct zfile *zf, int drv, int *num_tracks);
-int caps_loadtrack (uae_u16 *mfmbuf, uae_u16 *tracktiming, int drv, int track, int *tracklength, int *multirev, int *gapoffset);
-int caps_loadrevolution (uae_u16 *mfmbuf, int drv, int track, int *tracklength);
+int caps_loadtrack (uae_u16 *mfmbuf, uae_u16 *tracktiming, int drv, int track, int *tracklength, int *multirev, int *gapoffset, int *nextrev, bool setrev);
+int caps_loadrevolution (uae_u16 *mfmbuf, uae_u16 *tracktiming, int drv, int track, int *tracklength, int *nextrev);