12 #include "cbmcopy_int.h"
25 static const unsigned char s2r15x1[] = {
29 static const unsigned char s2w15x1[] = {
33 static const unsigned char s2r1581[] = {
34 #include "s2r-1581.inc"
37 static const unsigned char s2w1581[] = {
38 #include "s2w-1581.inc"
41 static struct drive_prog
43 const unsigned char *
prog;
47 { s2r15x1,
sizeof(s2r15x1) },
48 { s2w15x1,
sizeof(s2w15x1) },
49 { s2r1581,
sizeof(s2r1581) },
50 { s2w1581,
sizeof(s2w1581) }
53 static int write_byte(
CBM_FILE,
unsigned char);
54 static unsigned char read_byte(
CBM_FILE);
76 static int write_blk(
CBM_FILE HandleDevice,
const void *Buffer,
unsigned char Count, cbmcopy_message_cb msg_cb)
80 #ifdef LIBCBMCOPY_DEBUG
81 msg_cb( sev_debug,
"send byte count: %d", Count );
83 SETSTATEDEBUG((
void)0);
88 SETSTATEDEBUG((
void)0);
95 #ifdef LIBCBMCOPY_DEBUG
96 msg_cb( sev_debug,
"send block data" );
102 SETSTATEDEBUG((
void)0);
104 return write_block_generic(HandleDevice, Buffer, Count, &write_byte, msg_cb);
127 static int read_blk(
CBM_FILE HandleDevice,
void *Buffer,
size_t Count, cbmcopy_message_cb msg_cb)
134 SETSTATEDEBUG((
void)0);
140 #ifdef LIBCBMCOPY_DEBUG
141 msg_cb( sev_debug,
"received byte count: %d", c );
143 SETSTATEDEBUG((
void)0);
151 if( (Buffer == NULL) || (c > Count) )
159 #ifdef LIBCBMCOPY_DEBUG
160 msg_cb( sev_debug,
"receive block data (%d)", c );
168 return read_block_generic(HandleDevice, Buffer, Count, &read_byte, msg_cb);
172 static int write_byte(
CBM_FILE fd,
unsigned char c)
175 SETSTATEDEBUG((
void)0);
177 SETSTATEDEBUG(DebugBitCount=i*2);
180 SETSTATEDEBUG((
void)0);
182 SETSTATEDEBUG((
void)0);
183 #ifndef USE_CBM_IEC_WAIT
188 SETSTATEDEBUG(DebugBitCount--);
191 SETSTATEDEBUG((
void)0);
193 SETSTATEDEBUG((
void)0);
194 #ifndef USE_CBM_IEC_WAIT
200 SETSTATEDEBUG(DebugBitCount=-1);
202 SETSTATEDEBUG((
void)0);
206 static unsigned char read_byte(
CBM_FILE fd)
210 SETSTATEDEBUG((
void)0);
213 SETSTATEDEBUG(DebugBitCount=i*2);
214 #ifndef USE_CBM_IEC_WAIT
220 SETSTATEDEBUG((
void)0);
222 SETSTATEDEBUG(DebugBitCount--);
223 #ifndef USE_CBM_IEC_WAIT
229 SETSTATEDEBUG((
void)0);
233 SETSTATEDEBUG(DebugBitCount=-1);
237 static int check_error(
CBM_FILE fd,
int write)
241 SETSTATEDEBUG((
void)0);
243 SETSTATEDEBUG((
void)0);
245 SETSTATEDEBUG((
void)0);
249 SETSTATEDEBUG((
void)0);
251 SETSTATEDEBUG((
void)0);
253 SETSTATEDEBUG((
void)0);
257 SETSTATEDEBUG((
void)0);
262 SETSTATEDEBUG((
void)0);
266 static int upload_turbo(
CBM_FILE fd,
unsigned char drive,
269 const struct drive_prog *p;
277 p = &drive_progs[dt * 2 + (write != 0)];
279 SETSTATEDEBUG((
void)0);
280 cbm_upload(fd, drive, 0x680, p->prog, p->size);
281 SETSTATEDEBUG((
void)0);
285 static int start_turbo(
CBM_FILE fd,
int write)
287 SETSTATEDEBUG((
void)0);
289 SETSTATEDEBUG((
void)0);
291 SETSTATEDEBUG((
void)0);
293 SETSTATEDEBUG((
void)0);
295 SETSTATEDEBUG((
void)0);
299 static void exit_turbo(
CBM_FILE fd,
int write)
301 SETSTATEDEBUG((
void)0);
303 SETSTATEDEBUG((
void)0);
305 SETSTATEDEBUG((
void)0);
307 SETSTATEDEBUG((
void)0);
309 SETSTATEDEBUG((
void)0);
311 SETSTATEDEBUG((
void)0);
318 DECLARE_TRANSFER_FUNCS(s2_transfer);
void CBMAPIDECL cbm_iec_set(CBM_FILE HandleDevice, int Line)
Activate a line 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_iec_release(CBM_FILE HandleDevice, int Line)
Deactivate a line on the IEC serial bus.
int CBMAPIDECL opencbm_plugin_s2_read_n_t(CBM_FILE HandleDevice, unsigned char *data, unsigned int size)
read a block of data from the OpenCBM backend with protocol serial-2
int CBMAPIDECL opencbm_plugin_s2_read_n(CBM_FILE HandleDevice, unsigned char *data, unsigned int size)
Read data with serial2 protocol.
int CBMAPIDECL cbm_iec_wait(CBM_FILE HandleDevice, int Line, int State)
Wait for a line to have a specific state.
DLL interface for accessing the driver.
int CBMAPIDECL opencbm_plugin_s2_write_n_t(CBM_FILE HandleDevice, const unsigned char *data, unsigned int size)
write a block of data to the OpenCBM backend with protocol serial-2
Define makros and functions which account for differences between the different architectures.
void *CBMAPIDECL cbm_get_plugin_function_address(const char *Functionname)
Get the function pointer for a function in a plugin.
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.
int CBMAPIDECL opencbm_plugin_s2_write_n(CBM_FILE HandleDevice, const unsigned char *data, unsigned int size)
Write data with serial2 protocol.