29 #define DBG_PROGNAME "OPENCBMVDD.DLL"
38 #define NEW_IMPLEMENTATION_WITH_SETRELEASE
44 get_vdm_address(WORD Offset, WORD Length)
48 buffer = VdmMapFlat(getES(), Offset, getMODE());
54 release_vdm_address(WORD Offset, WORD Length, PVOID Buffer)
56 VdmUnmapFlat(getES(), Offset, Buffer, getMODE());
66 #define retAX( _x_ ) setAX((WORD) _x_)
74 #define FUNC_CHECKEDBUFFERACCESS(_offset_, _length_) \
87 #define CHECKEDBUFFERACCESS_PROLOG() \
89 buffer = get_vdm_address(offset, length); \
102 #define CHECKEDBUFFERACCESS_EPILOG() \
103 release_vdm_address(offset, length, buffer); \
107 FUNC_LEAVE_BOOLEAN(error);
113 #define CHECKEDBUFFERACCESS(_func_) \
114 CHECKEDBUFFERACCESS_PROLOG(); \
116 CHECKEDBUFFERACCESS_EPILOG();
144 USHORT translatedhandle;
154 if (translatedhandle == (WORD) -1)
157 translatedhandle = -1;
162 translatedhandle = -1;
165 setBX(translatedhandle);
166 retAX(retValue ? 1 : 0);
222 const char *returned_string;
230 strncpy(buffer, returned_string, length);
997 enum cbm_devicetype_e devicetype;
1004 ret =
cbm_identify(HandleDevice, getDH(), &devicetype, &
string);
1007 strncpy(buffer,
string, length);
1044 enum cbm_devicetype_e devicetype = getDI();
1045 enum cbm_cabletype_e cabletype;
1049 devicetype = getDI();
1051 devicetype >= 0 ? &devicetype : NULL,
1052 &cabletype) ? TRUE : FALSE;
1063 static CBM_FILE VddCbmFileForIoHook;
1065 static BOOLEAN VddIoHookInstalled = FALSE;
1066 static VDD_IO_PORTRANGE VddIoPortRange;
1067 static VDD_IO_HANDLERS VddIoPortHandlers;
1069 static BYTE vdd_iohook_lastwrittencontrolregister = 0xFF;
1073 #define PP_XE_ATN_OUT 0x01
1074 #define PP_XE_CLK_OUT 0x02
1075 #define PP_XE_RESET_OUT 0x04
1076 #define PP_XE_DATA_OUT 0x08
1077 #define PP_XE_OUTEOR 0x00
1080 #define PP_XE_ATN_IN 0x10
1081 #define PP_XE_CLK_IN 0x20
1082 #define PP_XE_RESET_IN 0x40
1083 #define PP_XE_DATA_IN 0x80
1087 #define PP_XM_ATN_OUT PP_XE_ATN_OUT
1088 #define PP_XM_CLK_OUT PP_XE_CLK_OUT
1089 #define PP_XM_DATA_OUT PP_XE_RESET_OUT
1090 #define PP_XM_RESET_OUT PP_XE_DATA_OUT
1091 #define PP_XM_OUTEOR 0x00
1094 #define PP_XM_ATN_IN PP_XE_ATN_IN
1095 #define PP_XM_CLK_IN PP_XE_CLK_IN
1096 #define PP_XM_DATA_IN PP_XE_RESET_IN
1097 #define PP_XM_RESET_IN PP_XE_DATA_IN
1101 #define PP_XA_ATN_OUT PP_XM_ATN_OUT
1102 #define PP_XA_CLK_OUT PP_XM_CLK_OUT
1103 #define PP_XA_DATA_OUT PP_XM_DATA_OUT
1104 #define PP_XA_RESET_OUT PP_XM_RESET_OUT
1105 #define PP_XA_OUTEOR 0x0F
1108 #define PP_XA_ATN_IN PP_XM_ATN_IN
1109 #define PP_XA_CLK_IN PP_XM_CLK_IN
1110 #define PP_XA_DATA_IN PP_XM_DATA_IN
1111 #define PP_XA_RESET_IN PP_XM_RESET_IN
1114 static unsigned char pp_atn_out;
1115 static unsigned char pp_clk_out;
1116 static unsigned char pp_data_out;
1117 static unsigned char pp_reset_out;
1118 static unsigned char pp_outeor;
1120 static unsigned char pp_atn_in;
1121 static unsigned char pp_clk_in;
1122 static unsigned char pp_data_in;
1123 static unsigned char pp_reset_in;
1133 vdd_iohook_inb(WORD iport,BYTE *data)
1135 if (iport == VddIoPortRange.First)
1140 else if (iport == VddIoPortRange.First + 1)
1166 else if (iport == VddIoPortRange.First + 2)
1169 *data = vdd_iohook_lastwrittencontrolregister & 0xDF | 0xC0;
1175 vdd_iohook_outb(WORD iport,BYTE data)
1177 if (iport == VddIoPortRange.First)
1182 else if (iport == VddIoPortRange.First + 1)
1186 else if (iport == VddIoPortRange.First + 2)
1190 #ifdef NEW_IMPLEMENTATION_WITH_SETRELEASE
1195 vdd_iohook_lastwrittencontrolregister = data;
1197 data ^= 0x04 ^ pp_outeor;
1215 #endif // #ifdef TEST_BIDIR
1219 #else // #ifdef NEW_IMPLEMENTATION_WITH_SETRELEASE
1221 BYTE ret = data ^ vdd_iohook_lastwrittencontrolregister;
1223 vdd_iohook_lastwrittencontrolregister = data;
1225 data ^= 0x04 ^ pp_outeor;
1227 if (ret & pp_atn_out)
1231 (VddCbmFileForIoHook,
IEC_ATN);
1233 if (ret & pp_clk_out)
1239 if (ret & pp_data_out)
1245 if (ret & pp_reset_out)
1248 if (data & pp_reset_out)
1254 #endif // #ifdef NEW_IMPLEMENTATION_WITH_SETRELEASE
1298 if (!VddIoHookInstalled)
1300 VddIoPortRange.First = getCX();
1301 VddIoPortRange.Last = VddIoPortRange.First + 2;
1303 RtlZeroMemory(&VddIoPortHandlers,
sizeof(VddIoPortHandlers));
1304 VddIoPortHandlers.inb_handler = vdd_iohook_inb;
1305 VddIoPortHandlers.outb_handler = vdd_iohook_outb;
1307 if (VDDInstallIOHook(
vdd_handle, 1, &VddIoPortRange, &VddIoPortHandlers))
1310 VddIoHookInstalled = TRUE;
1311 setAX(VddIoPortRange.First);
1313 VddCbmFileForIoHook = HandleDevice;
1389 if (VddIoHookInstalled)
1391 VDDDeInstallIOHook(
vdd_handle, 1, &VddIoPortRange);
1393 VddIoHookInstalled = FALSE;
1394 ret = VddIoPortRange.First;
1451 arch_usleep(getCX());
BOOLEAN vdd_listen(CBM_FILE HandleDevice)
Send a LISTEN on the IEC serial bus.
int CBMAPIDECL cbm_identify_xp1541(CBM_FILE HandleDevice, unsigned char DeviceAddress, enum cbm_device_type_e *CbmDeviceType, enum cbm_cable_type_e *CableType)
Identify the cable connected to a specific floppy drive.
int CBMAPIDECL cbm_get_eoi(CBM_FILE HandleDevice)
Get EOI flag after bus read.
#define PP_XM_RESET_IN
The RESET IN bit for XM cables.
BOOLEAN vdd_device_status(CBM_FILE HandleDevice)
Read the drive status from a floppy.
int CBMAPIDECL cbm_talk(CBM_FILE HandleDevice, unsigned char DeviceAddress, unsigned char SecondaryAddress)
Send a TALK on the IEC serial bus.
#define PP_XA_CLK_IN
The CLOCK IN bit for XM cables.
#define PP_XA_ATN_OUT
The ATN OUT bit for XM cables.
BOOLEAN vdd_get_driver_name(VOID)
Get the name of the driver for a specific parallel port.
const char *CBMAPIDECL cbm_get_driver_name(int PortNumber)
Get the name of the driver for a specific parallel port.
int CBMAPIDECL cbm_driver_open(CBM_FILE *HandleDevice, int PortNumber)
Opens the driver.
int CBMAPIDECL cbm_listen(CBM_FILE HandleDevice, unsigned char DeviceAddress, unsigned char SecondaryAddress)
Send a LISTEN on the IEC serial bus.
Define makros for debugging purposes.
BOOLEAN vdd_identify(CBM_FILE HandleDevice)
Identify the connected floppy drive.
BOOLEAN vdd_pp_write(CBM_FILE HandleDevice)
Write a byte to a XP1541/XP1571 cable.
#define PP_XM_CLK_IN
The CLOCK IN bit for XM cables.
unsigned char CBMAPIDECL cbm_pp_read(CBM_FILE HandleDevice)
Read a byte from a XP1541/XP1571 cable.
#define PP_XE_RESET_IN
The RESET IN bit for XE cables.
int CBMAPIDECL cbm_device_status(CBM_FILE HandleDevice, unsigned char DeviceAddress, void *Buffer, size_t BufferLength)
Read the drive status from a floppy.
BOOLEAN vdd_iec_wait(CBM_FILE HandleDevice)
Wait for a line to have a specific state.
#define PP_XM_ATN_OUT
The ATN OUT bit for XM cables.
#define CHECKEDBUFFERACCESS(_func_)
@@@
Definitions for the configuration of the cbm4win driver.
#define PP_XE_ATN_OUT
The ATN OUT bit for XE cables.
int CBMAPIDECL cbm_close(CBM_FILE HandleDevice, unsigned char DeviceAddress, unsigned char SecondaryAddress)
Close a file on the IEC serial bus.
BOOLEAN vdd_iec_get(CBM_FILE HandleDevice)
Get the (logical) state of a line on the IEC serial bus.
BOOLEAN vdd_iec_poll(CBM_FILE HandleDevice)
Read status of all bus lines.
#define PP_XE_CLK_IN
The CLOCK IN bit for XE cables.
#define FUNC_LEAVE_BOOLEAN(_xxx)
BOOLEAN vdd_iec_set(CBM_FILE HandleDevice)
Activate a line on the IEC serial bus.
WORD vdd_cbmfile_store(CBM_FILE cbmfile)
@@@
Function prototypes for the VDD.
#define PP_XM_ATN_IN
The ATN IN bit for XM cables.
BOOLEAN vdd_clear_eoi(CBM_FILE HandleDevice)
Reset the EOI flag.
void CBMAPIDECL cbm_iec_set(CBM_FILE HandleDevice, int Line)
Activate a line on the IEC serial bus.
int CBMAPIDECL cbm_raw_write(CBM_FILE HandleDevice, const void *Buffer, size_t Count)
Write data to the IEC serial bus.
BOOLEAN vdd_iec_release(CBM_FILE HandleDevice)
Deactivate a line on the IEC serial bus.
#define PP_XA_RESET_OUT
The RESET OUT bit for XM cables.
#define PP_XE_OUTEOR
eor mask for output for XE cables
BOOLEAN vdd_open(CBM_FILE HandleDevice)
Open a file on the IEC serial bus.
int CBMAPIDECL cbm_iec_get(CBM_FILE HandleDevice, int Line)
Get the (logical) state of a line on the IEC serial bus.
void CBMAPIDECL cbm_driver_close(CBM_FILE HandleDevice)
Closes the driver.
int CBMAPIDECL cbm_unlisten(CBM_FILE HandleDevice)
Send an UNLISTEN on the IEC serial bus.
BOOLEAN vdd_close(CBM_FILE HandleDevice)
Close a file on the IEC serial bus.
void CBMAPIDECL cbm_iec_release(CBM_FILE HandleDevice, int Line)
Deactivate a line on the IEC serial bus.
BOOLEAN vdd_exec_command(CBM_FILE HandleDevice)
Executes a command in the floppy drive.
BOOLEAN vdd_raw_write(CBM_FILE HandleDevice)
Write data to the IEC serial bus.
int CBMAPIDECL cbm_open(CBM_FILE HandleDevice, unsigned char DeviceAddress, unsigned char SecondaryAddress, const void *Filename, size_t FilenameLength)
Open a file on the IEC serial bus.
BOOLEAN vdd_usleep(VOID)
Sleep some microseconds.
BOOLEAN vdd_upload(CBM_FILE HandleDevice)
Upload a program into a floppy's drive memory.
BOOLEAN vdd_talk(CBM_FILE HandleDevice)
Send a TALK on the IEC serial bus.
int CBMAPIDECL cbm_clear_eoi(CBM_FILE HandleDevice)
Reset the EOI flag.
int CBMAPIDECL cbm_raw_read(CBM_FILE HandleDevice, void *Buffer, size_t Count)
Read data from the IEC serial bus.
BOOLEAN vdd_get_eoi(CBM_FILE HandleDevice)
Get EOI flag after bus read.
#define FUNC_LEAVE_USHORT(_xxx)
#define CHECKEDBUFFERACCESS_PROLOG()
@@@
int CBMAPIDECL cbm_reset(CBM_FILE HandleDevice)
RESET all devices.
#define PP_XA_OUTEOR
eor mask for output for XA cables
int CBMAPIDECL cbm_iec_wait(CBM_FILE HandleDevice, int Line, int State)
Wait for a line to have a specific state.
#define PP_XE_DATA_OUT
The DATA OUT bit for XE cables.
BOOLEAN vdd_iec_setrelease(CBM_FILE HandleDevice)
Activate and deactive a line on the IEC serial bus.
#define PP_XA_DATA_IN
The DATA IN bit for XM cables.
#define PP_XE_ATN_IN
The ATN IN bit for XE cables.
#define PP_XM_DATA_IN
The DATA IN bit for XM cables.
BOOLEAN vdd_raw_read(CBM_FILE HandleDevice)
Read data from the IEC serial bus.
int CBMAPIDECL cbm_exec_command(CBM_FILE HandleDevice, unsigned char DeviceAddress, const void *Command, size_t Size)
Executes a command in the floppy drive.
#define PP_XA_RESET_IN
The RESET IN bit for XM cables.
BOOLEAN vdd_uninstall_iohook(CBM_FILE HandleDevice)
Uninstall the I/O hook.
int CBMAPIDECL cbm_identify(CBM_FILE HandleDevice, unsigned char DeviceAddress, enum cbm_device_type_e *CbmDeviceType, const char **CbmDeviceString)
Identify the connected floppy drive.
USHORT vdd_uninstall_iohook_internal(VOID)
Uninstall the I/O hook.
DLL interface for accessing the driver.
BOOLEAN vdd_driver_close(CBM_FILE HandleDevice)
Closes the driver.
#define PP_XE_DATA_IN
The DATA IN bit for XE cables.
BOOLEAN vdd_identify_xp1541(CBM_FILE HandleDevice)
Identify the cable connected to a specific floppy drive.
int CBMAPIDECL cbm_iec_poll(CBM_FILE HandleDevice)
Read status of all bus lines.
int CBMAPIDECL cbm_untalk(CBM_FILE HandleDevice)
Send an UNTALK on the IEC serial bus.
BOOLEAN vdd_pp_read(CBM_FILE HandleDevice)
Read a byte from a XP1541/XP1571 cable.
BOOLEAN vdd_install_iohook(CBM_FILE HandleDevice)
Install the I/O hook.
#define CHECKEDBUFFERACCESS_EPILOG()
@@@
#define PP_XE_RESET_OUT
The RESET OUT bit for XE cables.
BOOLEAN vdd_unlisten(CBM_FILE HandleDevice)
Send an UNLISTEN on the IEC serial bus.
#define PP_XE_CLK_OUT
The CLOCK OUT bit for XE cables.
Define makros and functions which account for differences between the different architectures.
#define PP_XM_OUTEOR
eor mask for output for XM cables
void CBMAPIDECL cbm_iec_setrelease(CBM_FILE HandleDevice, int Set, int Release)
Activate and deactive a line on the IEC serial bus.
BOOLEAN vdd_untalk(CBM_FILE HandleDevice)
Send an UNTALK on the IEC serial bus.
#define FUNC_CHECKEDBUFFERACCESS(_offset_, _length_)
@@@
BOOLEAN vdd_reset(CBM_FILE HandleDevice)
RESET all devices.
int CBMAPIDECL cbm_upload(CBM_FILE HandleDevice, unsigned char DeviceAddress, int DriveMemAddress, const void *Program, size_t Size)
Upload a program into a floppy's drive memory.
void CBMAPIDECL cbm_pp_write(CBM_FILE HandleDevice, unsigned char Byte)
Write a byte to a XP1541/XP1571 cable.
#define PP_XA_ATN_IN
The ATN IN bit for XM cables.
#define PP_XM_DATA_OUT
The DATA OUT bit for XM cables.
BOOLEAN vdd_driver_open(VOID)
Opens the driver.
#define PP_XA_DATA_OUT
The DATA OUT bit for XM cables.
#define PP_XA_CLK_OUT
The CLOCK OUT bit for XM cables.
#define PP_XM_RESET_OUT
The RESET OUT bit for XM cables.
#define PP_XM_CLK_OUT
The CLOCK OUT bit for XM cables.