]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
capslib raw dump support.
authorToni Wilen <twilen@winuae.net>
Tue, 18 Mar 2014 16:34:22 +0000 (18:34 +0200)
committerToni Wilen <twilen@winuae.net>
Tue, 18 Mar 2014 16:34:22 +0000 (18:34 +0200)
od-win32/caps/CapsAPI.h
od-win32/caps/CapsLib.h
od-win32/caps/Comlib.h
od-win32/caps/caps_win32.cpp
od-win32/caps/caps_win32.h

index 3eb08186bd18b3a0f7af7419e4207d90902f5b32..367b646eb0c144d9c0a575750ce442d3373e60df 100644 (file)
@@ -135,15 +135,52 @@ struct CapsTrackInfoT2 {
 
 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,
@@ -157,7 +194,7 @@ enum {
        ciipAtari8
 };
 
-// track type
+// CapsTrackInfo.track type
 enum {
        ctitNA=0,  // invalid type
        ctitNoise, // cells are unformatted (random size)
@@ -165,6 +202,40 @@ enum {
        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,
index dbb13da9ab51baa2cb5b63a2007c0cdb87dd64ec..646bc6130cbd788ead9726a4da73893e85d33c16 100644 (file)
@@ -5,7 +5,7 @@
 #ifdef CAPS_USER
 #define LIB_USER
 #endif
-#include "comlib.h"
+#include "ComLib.h"
 
 ExtSub SDWORD __cdecl CAPSInit();
 ExtSub SDWORD __cdecl CAPSExit();
@@ -16,10 +16,20 @@ ExtSub SDWORD __cdecl CAPSLockImageMemory(SDWORD id, PUBYTE buffer, UDWORD lengt
 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
index 4eb091e33544de2f9cc32be82366dce93a6ce442..cab19ca174990b73466a35ee060e3a8137b80dda 100644 (file)
@@ -15,6 +15,6 @@
 
 #endif
 
-#define ExtSub
-#define ExtVar
+#define ExtSub extern "C" DllSub
+#define ExtVar extern "C" DllVar
 
index 1449f19280f5c9ff998e1d9cf46ee0840648e1fb..39c204f20fad92dfa9be7f9fd8d987b2829aad7e 100644 (file)
@@ -15,6 +15,8 @@
 #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;
@@ -41,6 +43,10 @@ typedef SDWORD (__cdecl* CAPSUNLOCKALLTRACKS)(SDWORD);
 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)
 {
@@ -84,6 +90,9 @@ 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);
@@ -196,7 +205,7 @@ static void mfmcopy (uae_u16 *mfm, uae_u8 *data, int len)
        }
 }
 
-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;
        
@@ -210,17 +219,21 @@ static int load (struct CapsTrackInfoT2 *ci, int drv, int track, bool seed)
        } 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;
@@ -228,18 +241,52 @@ int caps_loadrevolution (uae_u16 *mfmbuf, int drv, int track, int *tracklength)
                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;
@@ -258,10 +305,12 @@ int caps_loadtrack (uae_u16 *mfmbuf, uae_u16 *tracktiming, int drv, int track, i
                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);
index 7d534ebbddb4d8aaa38cd419afad55cc95385464..b8b7a9d0b967e54acccef05485aaddae75044d80 100644 (file)
@@ -1,6 +1,6 @@
 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);