mirror of
https://github.com/jfdelnero/HxCFloppyEmulator.git
synced 2026-07-27 19:56:23 +00:00
WIP : Attempt to fix v5.2 CAPSLib support.
This commit is contained in:
@@ -1 +1 @@
|
|||||||
int init_caps_lib(HXCFE* hxcfe);
|
|
||||||
|
|||||||
@@ -60,6 +60,8 @@
|
|||||||
|
|
||||||
#include "libhxcadaptor.h"
|
#include "libhxcadaptor.h"
|
||||||
|
|
||||||
|
#include "../../tracks/std_crc32.h"
|
||||||
|
|
||||||
#define BYTE int8_t
|
#define BYTE int8_t
|
||||||
#define WORD int16_t
|
#define WORD int16_t
|
||||||
#define DWORD int32_t
|
#define DWORD int32_t
|
||||||
@@ -67,37 +69,14 @@
|
|||||||
#define LIB_USER 1
|
#define LIB_USER 1
|
||||||
#include "./thirdpartylibs/capslib/Comtype.h"
|
#include "./thirdpartylibs/capslib/Comtype.h"
|
||||||
#include "./thirdpartylibs/capslib/CapsAPI.h"
|
#include "./thirdpartylibs/capslib/CapsAPI.h"
|
||||||
|
#include "./thirdpartylibs/capslib/CapsAPI.h"
|
||||||
|
|
||||||
#include "capslibloader.h"
|
#include "../../misc/capslib_loader/capslibloader.h"
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#define __cdecl
|
#define __cdecl
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef SDWORD (__cdecl* CAPSINIT)(void);
|
|
||||||
typedef SDWORD (__cdecl* CAPSADDIMAGE)(void);
|
|
||||||
typedef SDWORD (__cdecl* CAPSLOCKIMAGEMEMORY)(SDWORD,PUBYTE,UDWORD,UDWORD);
|
|
||||||
typedef SDWORD (__cdecl* CAPSUNLOCKIMAGE)(SDWORD);
|
|
||||||
typedef SDWORD (__cdecl* CAPSLOADIMAGE)(SDWORD,UDWORD);
|
|
||||||
typedef SDWORD (__cdecl* CAPSGETIMAGEINFO)(PCAPSIMAGEINFO,SDWORD);
|
|
||||||
typedef SDWORD (__cdecl* CAPSLOCKTRACK)(PCAPSTRACKINFO,SDWORD,UDWORD,UDWORD,UDWORD);
|
|
||||||
typedef SDWORD (__cdecl* CAPSUNLOCKTRACK)(SDWORD id, UDWORD cylinder, UDWORD head);
|
|
||||||
typedef SDWORD (__cdecl* CAPSUNLOCKALLTRACKS)(SDWORD);
|
|
||||||
typedef SDWORD (__cdecl* CAPSGETVERSIONINFO)(PCAPSVERSIONINFO,UDWORD);
|
|
||||||
typedef SDWORD (__cdecl* CAPSREMIMAGE)(SDWORD id);
|
|
||||||
|
|
||||||
extern CAPSINIT pCAPSInit;
|
|
||||||
extern CAPSADDIMAGE pCAPSAddImage;
|
|
||||||
extern CAPSLOCKIMAGEMEMORY pCAPSLockImageMemory;
|
|
||||||
extern CAPSUNLOCKIMAGE pCAPSUnlockImage;
|
|
||||||
extern CAPSLOADIMAGE pCAPSLoadImage;
|
|
||||||
extern CAPSGETIMAGEINFO pCAPSGetImageInfo;
|
|
||||||
extern CAPSLOCKTRACK pCAPSLockTrack;
|
|
||||||
extern CAPSUNLOCKTRACK pCAPSUnlockTrack;
|
|
||||||
extern CAPSUNLOCKALLTRACKS pCAPSUnlockAllTracks;
|
|
||||||
extern CAPSGETVERSIONINFO pCAPSGetVersionInfo;
|
|
||||||
extern CAPSREMIMAGE pCAPSRemImage;
|
|
||||||
|
|
||||||
#define INDEX_POSITION 0
|
#define INDEX_POSITION 0
|
||||||
#define INDEX_DURATION 2000
|
#define INDEX_DURATION 2000
|
||||||
|
|
||||||
@@ -213,6 +192,7 @@ int IPF_libLoad_DiskFile(HXCFE_IMGLDR * imgldr_ctx,HXCFE_FLOPPY * floppydisk,cha
|
|||||||
FILE * f;
|
FILE * f;
|
||||||
int img;
|
int img;
|
||||||
int ret;
|
int ret;
|
||||||
|
int block_sz;
|
||||||
int progresscnt;
|
int progresscnt;
|
||||||
int overlap;
|
int overlap;
|
||||||
int intrackflakeybit;
|
int intrackflakeybit;
|
||||||
@@ -230,6 +210,13 @@ int IPF_libLoad_DiskFile(HXCFE_IMGLDR * imgldr_ctx,HXCFE_FLOPPY * floppydisk,cha
|
|||||||
temptrack = NULL;
|
temptrack = NULL;
|
||||||
progresscnt = 0;
|
progresscnt = 0;
|
||||||
|
|
||||||
|
ret = pCAPSInit();
|
||||||
|
if( ret != 0 )
|
||||||
|
{
|
||||||
|
imgldr_ctx->hxcfe->hxc_printf(MSG_ERROR,"CAPSInit failure ! (Code %d) ",ret);
|
||||||
|
return HXCFE_INTERNALERROR;
|
||||||
|
}
|
||||||
|
|
||||||
f = hxc_fopen(imgfile,"rb");
|
f = hxc_fopen(imgfile,"rb");
|
||||||
if( f == NULL )
|
if( f == NULL )
|
||||||
{
|
{
|
||||||
@@ -241,17 +228,35 @@ int IPF_libLoad_DiskFile(HXCFE_IMGLDR * imgldr_ctx,HXCFE_FLOPPY * floppydisk,cha
|
|||||||
|
|
||||||
if( filesize )
|
if( filesize )
|
||||||
{
|
{
|
||||||
fileimg = (unsigned char*)malloc(filesize);
|
fileimg = (unsigned char*)calloc(1,filesize);
|
||||||
|
|
||||||
if(fileimg!=NULL)
|
if(fileimg!=NULL)
|
||||||
{
|
{
|
||||||
i=0;
|
#define LOAD_BLOCKSIZE 8192
|
||||||
do
|
unsigned char *fileimg_ptr = fileimg;
|
||||||
{
|
|
||||||
hxc_fread(fileimg+(i*1024),1024,f);
|
|
||||||
i++;
|
|
||||||
}while(i<((filesize/1024)+1));
|
|
||||||
|
|
||||||
|
ret = 1;
|
||||||
|
while( fileimg_ptr < (fileimg + filesize) && ret > 0 )
|
||||||
|
{
|
||||||
|
if( filesize - (fileimg_ptr - fileimg) >= LOAD_BLOCKSIZE)
|
||||||
|
block_sz = LOAD_BLOCKSIZE;
|
||||||
|
else
|
||||||
|
block_sz = filesize - (fileimg_ptr - fileimg);
|
||||||
|
|
||||||
|
ret = hxc_fread(fileimg_ptr,block_sz,f);
|
||||||
|
|
||||||
|
fileimg_ptr += block_sz;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( fileimg_ptr != (fileimg + filesize) )
|
||||||
|
{
|
||||||
|
imgldr_ctx->hxcfe->hxc_printf(MSG_ERROR,"Error while loading %s !", imgfile);
|
||||||
|
hxc_fclose(f);
|
||||||
|
return HXCFE_ACCESSERROR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imgldr_ctx->hxcfe->hxc_printf(MSG_INFO_1,"IPF File loaded (%d bytes, CRC32: 0x%.8X)", filesize, std_crc32(0x00000000, fileimg, filesize) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -294,10 +299,19 @@ int IPF_libLoad_DiskFile(HXCFE_IMGLDR * imgldr_ctx,HXCFE_FLOPPY * floppydisk,cha
|
|||||||
|
|
||||||
img = pCAPSAddImage();
|
img = pCAPSAddImage();
|
||||||
|
|
||||||
if(img != -1)
|
if(img >= 0 )
|
||||||
{
|
{
|
||||||
if(pCAPSLockImageMemory(img, fileimg,filesize,0)!=imgeUnsupported )
|
ret = pCAPSGetImageTypeMemory(fileimg,filesize);
|
||||||
|
|
||||||
|
imgldr_ctx->hxcfe->hxc_printf(MSG_DEBUG,"pCAPSGetImageTypeMemory return code : %d",ret);
|
||||||
|
|
||||||
|
ret = pCAPSLockImageMemory(img, fileimg,filesize,DI_LOCK_MEMREF);
|
||||||
|
|
||||||
|
imgldr_ctx->hxcfe->hxc_printf(MSG_DEBUG,"pCAPSLockImageMemory return code : %d",ret);
|
||||||
|
|
||||||
|
if(ret != imgeUnsupported )
|
||||||
{
|
{
|
||||||
|
|
||||||
pCAPSLoadImage(img, flag);
|
pCAPSLoadImage(img, flag);
|
||||||
pCAPSGetImageInfo(&ci2, img);
|
pCAPSGetImageInfo(&ci2, img);
|
||||||
|
|
||||||
@@ -627,18 +641,26 @@ int IPF_libLoad_DiskFile(HXCFE_IMGLDR * imgldr_ctx,HXCFE_FLOPPY * floppydisk,cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
pCAPSUnlockAllTracks(img);
|
pCAPSUnlockAllTracks(img);
|
||||||
|
|
||||||
|
imgldr_ctx->hxcfe->hxc_printf(MSG_INFO_1,"IPF Loader : tracks file successfully loaded and encoded!");
|
||||||
|
|
||||||
|
ret = HXCFE_NOERROR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imgldr_ctx->hxcfe->hxc_printf(MSG_ERROR,"IPF Loader : CAPSLib has rejected the image !");
|
||||||
|
|
||||||
|
ret = HXCFE_BADFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
pCAPSUnlockImage(img);
|
pCAPSUnlockImage(img);
|
||||||
|
|
||||||
|
|
||||||
pCAPSRemImage(img);
|
pCAPSRemImage(img);
|
||||||
|
|
||||||
free(fileimg);
|
free(fileimg);
|
||||||
fileimg = NULL;
|
fileimg = NULL;
|
||||||
|
|
||||||
imgldr_ctx->hxcfe->hxc_printf(MSG_INFO_1,"IPF Loader : tracks file successfully loaded and encoded!");
|
return ret;
|
||||||
return HXCFE_NOERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return HXCFE_INTERNALERROR;
|
return HXCFE_INTERNALERROR;
|
||||||
|
|||||||
@@ -65,20 +65,12 @@ typedef void* HMODULE;
|
|||||||
#include "thirdpartylibs/capslib/Comtype.h"
|
#include "thirdpartylibs/capslib/Comtype.h"
|
||||||
#include "thirdpartylibs/capslib/CapsAPI.h"
|
#include "thirdpartylibs/capslib/CapsAPI.h"
|
||||||
|
|
||||||
typedef SDWORD (* CAPSINIT)(void);
|
#include "capslibloader.h"
|
||||||
typedef SDWORD (* CAPSADDIMAGE)(void);
|
|
||||||
typedef SDWORD (* CAPSLOCKIMAGEMEMORY)(SDWORD,PUBYTE,UDWORD,UDWORD);
|
|
||||||
typedef SDWORD (* CAPSUNLOCKIMAGE)(SDWORD);
|
|
||||||
typedef SDWORD (* CAPSLOADIMAGE)(SDWORD,UDWORD);
|
|
||||||
typedef SDWORD (* CAPSGETIMAGEINFO)(PCAPSIMAGEINFO,SDWORD);
|
|
||||||
typedef SDWORD (* CAPSLOCKTRACK)(PCAPSTRACKINFO,SDWORD,UDWORD,UDWORD,UDWORD);
|
|
||||||
typedef SDWORD (* CAPSUNLOCKTRACK)(SDWORD id, UDWORD cylinder, UDWORD head);
|
|
||||||
typedef SDWORD (* CAPSUNLOCKALLTRACKS)(SDWORD);
|
|
||||||
typedef SDWORD (* CAPSGETVERSIONINFO)(PCAPSVERSIONINFO,UDWORD);
|
|
||||||
typedef SDWORD (* CAPSREMIMAGE)(SDWORD id);
|
|
||||||
|
|
||||||
CAPSINIT pCAPSInit = 0;
|
CAPSINIT pCAPSInit = 0;
|
||||||
CAPSADDIMAGE pCAPSAddImage = 0;
|
CAPSADDIMAGE pCAPSAddImage = 0;
|
||||||
|
CAPSLOCKIMAGE pCAPSLockImage = 0;
|
||||||
|
CAPSGETIMAGETYPEMEMORY pCAPSGetImageTypeMemory = 0;
|
||||||
CAPSLOCKIMAGEMEMORY pCAPSLockImageMemory = 0;
|
CAPSLOCKIMAGEMEMORY pCAPSLockImageMemory = 0;
|
||||||
CAPSUNLOCKIMAGE pCAPSUnlockImage = 0;
|
CAPSUNLOCKIMAGE pCAPSUnlockImage = 0;
|
||||||
CAPSLOADIMAGE pCAPSLoadImage = 0;
|
CAPSLOADIMAGE pCAPSLoadImage = 0;
|
||||||
@@ -99,17 +91,19 @@ typedef struct _lib_funcs_def
|
|||||||
|
|
||||||
lib_funcs_def capslib_lib_funcs_def[]=
|
lib_funcs_def capslib_lib_funcs_def[]=
|
||||||
{
|
{
|
||||||
{"CAPSInit", (func_ptr *)&pCAPSInit},
|
{"CAPSInit", (func_ptr *)&pCAPSInit},
|
||||||
{"CAPSAddImage", (func_ptr *)&pCAPSAddImage},
|
{"CAPSAddImage", (func_ptr *)&pCAPSAddImage},
|
||||||
{"CAPSLockImageMemory", (func_ptr *)&pCAPSLockImageMemory},
|
{"CAPSLockImage", (func_ptr *)&pCAPSLockImage},
|
||||||
{"CAPSUnlockImage", (func_ptr *)&pCAPSUnlockImage},
|
{"CAPSLockImageMemory", (func_ptr *)&pCAPSLockImageMemory},
|
||||||
{"CAPSLoadImage", (func_ptr *)&pCAPSLoadImage},
|
{"CAPSGetImageTypeMemory", (func_ptr *)&pCAPSGetImageTypeMemory},
|
||||||
{"CAPSGetImageInfo", (func_ptr *)&pCAPSGetImageInfo},
|
{"CAPSUnlockImage", (func_ptr *)&pCAPSUnlockImage},
|
||||||
{"CAPSLockTrack", (func_ptr *)&pCAPSLockTrack},
|
{"CAPSLoadImage", (func_ptr *)&pCAPSLoadImage},
|
||||||
{"CAPSUnlockTrack", (func_ptr *)&pCAPSUnlockTrack},
|
{"CAPSGetImageInfo", (func_ptr *)&pCAPSGetImageInfo},
|
||||||
{"CAPSUnlockAllTracks", (func_ptr *)&pCAPSUnlockAllTracks},
|
{"CAPSLockTrack", (func_ptr *)&pCAPSLockTrack},
|
||||||
{"CAPSGetVersionInfo", (func_ptr *)&pCAPSGetVersionInfo},
|
{"CAPSUnlockTrack", (func_ptr *)&pCAPSUnlockTrack},
|
||||||
{"CAPSRemImage", (func_ptr *)&pCAPSRemImage},
|
{"CAPSUnlockAllTracks", (func_ptr *)&pCAPSUnlockAllTracks},
|
||||||
|
{"CAPSGetVersionInfo", (func_ptr *)&pCAPSGetVersionInfo},
|
||||||
|
{"CAPSRemImage", (func_ptr *)&pCAPSRemImage},
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
int init_caps_lib(HXCFE* hxcfe);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#define CALLCONV __cdecl
|
||||||
|
#else
|
||||||
|
#define CALLCONV
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef SDWORD (CALLCONV* CAPSINIT)(void);
|
||||||
|
typedef SDWORD (CALLCONV* CAPSADDIMAGE)(void);
|
||||||
|
typedef SDWORD (CALLCONV* CAPSLOCKIMAGE)(SDWORD,PUBYTE);
|
||||||
|
typedef SDWORD (CALLCONV* CAPSLOCKIMAGEMEMORY)(SDWORD,PUBYTE,UDWORD,UDWORD);
|
||||||
|
typedef SDWORD (CALLCONV* CAPSGETIMAGETYPEMEMORY)(PUBYTE,UDWORD);
|
||||||
|
typedef SDWORD (CALLCONV* CAPSUNLOCKIMAGE)(SDWORD);
|
||||||
|
typedef SDWORD (CALLCONV* CAPSLOADIMAGE)(SDWORD,UDWORD);
|
||||||
|
typedef SDWORD (CALLCONV* CAPSGETIMAGEINFO)(PCAPSIMAGEINFO,SDWORD);
|
||||||
|
typedef SDWORD (CALLCONV* CAPSLOCKTRACK)(PCAPSTRACKINFO,SDWORD,UDWORD,UDWORD,UDWORD);
|
||||||
|
typedef SDWORD (CALLCONV* CAPSUNLOCKTRACK)(SDWORD id, UDWORD cylinder, UDWORD head);
|
||||||
|
typedef SDWORD (CALLCONV* CAPSUNLOCKALLTRACKS)(SDWORD);
|
||||||
|
typedef SDWORD (CALLCONV* CAPSGETVERSIONINFO)(PCAPSVERSIONINFO,UDWORD);
|
||||||
|
typedef SDWORD (CALLCONV* CAPSREMIMAGE)(SDWORD id);
|
||||||
|
|
||||||
|
extern CAPSINIT pCAPSInit;
|
||||||
|
extern CAPSADDIMAGE pCAPSAddImage;
|
||||||
|
extern CAPSLOCKIMAGE pCAPSLockImage;
|
||||||
|
extern CAPSGETIMAGETYPEMEMORY pCAPSGetImageTypeMemory;
|
||||||
|
extern CAPSLOCKIMAGEMEMORY pCAPSLockImageMemory;
|
||||||
|
extern CAPSUNLOCKIMAGE pCAPSUnlockImage;
|
||||||
|
extern CAPSLOADIMAGE pCAPSLoadImage;
|
||||||
|
extern CAPSGETIMAGEINFO pCAPSGetImageInfo;
|
||||||
|
extern CAPSLOCKTRACK pCAPSLockTrack;
|
||||||
|
extern CAPSUNLOCKTRACK pCAPSUnlockTrack;
|
||||||
|
extern CAPSUNLOCKALLTRACKS pCAPSUnlockAllTracks;
|
||||||
|
extern CAPSGETVERSIONINFO pCAPSGetVersionInfo;
|
||||||
|
extern CAPSREMIMAGE pCAPSRemImage;
|
||||||
|
|||||||
Reference in New Issue
Block a user