12 #include "cbmcopy_int.h"
22 static const unsigned char s1r15x1[] = {
26 static const unsigned char s1w15x1[] = {
30 static const unsigned char s1r1581[] = {
31 #include "s1r-1581.inc"
34 static const unsigned char s1w1581[] = {
35 #include "s1w-1581.inc"
38 static struct drive_prog
40 const unsigned char *
prog;
44 { s1r15x1,
sizeof(s1r15x1) },
45 { s1w15x1,
sizeof(s1w15x1) },
46 { s1r1581,
sizeof(s1r1581) },
47 { s1w1581,
sizeof(s1w1581) }
50 static int write_byte(
CBM_FILE,
unsigned char);
51 static unsigned char read_byte(
CBM_FILE);
73 static int write_blk(
CBM_FILE HandleDevice,
const void *Buffer,
unsigned char Count, cbmcopy_message_cb msg_cb)
77 #ifdef LIBCBMCOPY_DEBUG
78 msg_cb( sev_debug,
"send byte count: %d", Count );
80 SETSTATEDEBUG((
void)0);
85 SETSTATEDEBUG((
void)0);
92 #ifdef LIBCBMCOPY_DEBUG
93 msg_cb( sev_debug,
"send block data" );
99 SETSTATEDEBUG((
void)0);
101 return write_block_generic(HandleDevice, Buffer, Count, &write_byte, msg_cb);
124 static int read_blk(
CBM_FILE HandleDevice,
void *Buffer,
size_t Count, cbmcopy_message_cb msg_cb)
131 SETSTATEDEBUG((
void)0);
137 #ifdef LIBCBMCOPY_DEBUG
138 msg_cb( sev_debug,
"received byte count: %d", c );
140 SETSTATEDEBUG((
void)0);
148 if( (Buffer == NULL) || (c > Count) )
156 #ifdef LIBCBMCOPY_DEBUG
157 msg_cb( sev_debug,
"receive block data (%d)", c );
165 return read_block_generic(HandleDevice, Buffer, Count, &read_byte, msg_cb);
169 static int write_byte(
CBM_FILE fd,
unsigned char c)
172 SETSTATEDEBUG((
void)0);
173 for(i=7; i>=0; i--) {
175 SETSTATEDEBUG(DebugBitCount=i);
177 SETSTATEDEBUG((
void)0);
179 SETSTATEDEBUG((
void)0);
180 #ifndef USE_CBM_IEC_WAIT
185 SETSTATEDEBUG((
void)0);
187 SETSTATEDEBUG((
void)0);
188 #ifndef USE_CBM_IEC_WAIT
193 SETSTATEDEBUG((
void)0);
195 SETSTATEDEBUG((
void)0);
197 SETSTATEDEBUG((
void)0);
198 #ifndef USE_CBM_IEC_WAIT
204 SETSTATEDEBUG(DebugBitCount=-1);
208 static unsigned char read_byte(
CBM_FILE fd)
212 SETSTATEDEBUG((
void)0);
214 for(i=7; i>=0; i--) {
215 SETSTATEDEBUG(DebugBitCount=i);
216 #ifndef USE_CBM_IEC_WAIT
221 SETSTATEDEBUG((
void)0);
223 SETSTATEDEBUG((
void)0);
225 c = (c >> 1) | (b ? 0x80 : 0);
226 SETSTATEDEBUG((
void)0);
228 SETSTATEDEBUG((
void)0);
229 #ifndef USE_CBM_IEC_WAIT
234 SETSTATEDEBUG((
void)0);
236 SETSTATEDEBUG((
void)0);
237 #ifndef USE_CBM_IEC_WAIT
242 SETSTATEDEBUG((
void)0);
245 SETSTATEDEBUG(DebugBitCount=-1);
249 static int check_error(
CBM_FILE fd,
int write)
253 SETSTATEDEBUG((
void)0);
255 SETSTATEDEBUG((
void)0);
257 SETSTATEDEBUG((
void)0);
262 SETSTATEDEBUG((
void)0);
264 SETSTATEDEBUG((
void)0);
266 SETSTATEDEBUG((
void)0);
270 SETSTATEDEBUG((
void)0);
275 SETSTATEDEBUG((
void)0);
277 SETSTATEDEBUG((
void)0);
280 SETSTATEDEBUG((
void)0);
282 SETSTATEDEBUG((
void)0);
286 static int upload_turbo(
CBM_FILE fd,
unsigned char drive,
289 const struct drive_prog *p;
296 p = &drive_progs[dt * 2 + (write != 0)];
298 SETSTATEDEBUG((
void)0);
299 cbm_upload(fd, drive, 0x680, p->prog, p->size);
300 SETSTATEDEBUG((
void)0);
304 static int start_turbo(
CBM_FILE fd,
int write)
308 SETSTATEDEBUG((
void)0);
313 SETSTATEDEBUG((
void)0);
315 SETSTATEDEBUG((
void)0);
317 SETSTATEDEBUG((
void)0);
320 SETSTATEDEBUG((
void)0);
324 static void exit_turbo(
CBM_FILE fd,
int write)
326 SETSTATEDEBUG((
void)0);
328 SETSTATEDEBUG((
void)0);
335 DECLARE_TRANSFER_FUNCS(s1_transfer);
int CBMAPIDECL opencbm_plugin_s1_write_n(CBM_FILE HandleDevice, const unsigned char *data, unsigned int size)
Write data with serial1 protocol.
int CBMAPIDECL opencbm_plugin_s1_read_n_t(CBM_FILE HandleDevice, unsigned char *data, unsigned int size)
read a block of data from the OpenCBM backend with protocol serial-1
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 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.
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_s1_read_n(CBM_FILE HandleDevice, unsigned char *data, unsigned int size)
Read data with serial1 protocol.
int CBMAPIDECL opencbm_plugin_s1_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-1