12 #include "d64copy_int.h"
24 static const unsigned char s2_drive_prog[] = {
31 static int s2_read_byte(
CBM_FILE fd,
unsigned char *c)
36 SETSTATEDEBUG(DebugBitCount=i*2);
37 #ifndef USE_CBM_IEC_WAIT
39 SETSTATEDEBUG((
void)0);
44 SETSTATEDEBUG((
void)0);
46 SETSTATEDEBUG(DebugBitCount--);
47 #ifndef USE_CBM_IEC_WAIT
49 SETSTATEDEBUG((
void)0);
54 SETSTATEDEBUG((
void)0);
57 SETSTATEDEBUG(DebugBitCount=-1);
61 static int s2_write_byte_nohs(
CBM_FILE fd,
unsigned char c)
65 SETSTATEDEBUG(DebugBitCount=i*2);
68 SETSTATEDEBUG((
void)0);
70 #ifndef USE_CBM_IEC_WAIT
75 SETSTATEDEBUG(DebugBitCount--);
78 SETSTATEDEBUG((
void)0);
83 SETSTATEDEBUG((
void)0);
84 #ifndef USE_CBM_IEC_WAIT
93 static void read_n(
unsigned char *data,
int size)
104 s2_read_byte(fd_cbm, data++);
107 static int s2_write_byte(
CBM_FILE fd,
unsigned char c)
109 SETSTATEDEBUG((
void)0);
110 s2_write_byte_nohs(fd, c);
111 SETSTATEDEBUG((
void)0);
112 #ifndef USE_CBM_IEC_WAIT
117 SETSTATEDEBUG(DebugBitCount=-1);
119 SETSTATEDEBUG((
void)0);
124 static void write_n(
const unsigned char *data,
int size)
135 s2_write_byte(fd_cbm, *data++);
138 static int read_block(
unsigned char tr,
unsigned char se,
unsigned char *block)
140 unsigned char status;
142 SETSTATEDEBUG((
void)0);
144 SETSTATEDEBUG((
void)0);
146 #ifndef USE_CBM_IEC_WAIT
149 SETSTATEDEBUG((
void)0);
151 SETSTATEDEBUG(DebugByteCount=0);
152 read_n(block, BLOCKSIZE);
153 SETSTATEDEBUG(DebugByteCount=-1);
158 static int write_block(
unsigned char tr,
unsigned char se,
const unsigned char *blk,
int size,
int read_status)
160 unsigned char status;
161 SETSTATEDEBUG((
void)0);
163 SETSTATEDEBUG((
void)0);
165 SETSTATEDEBUG(DebugByteCount=0);
167 SETSTATEDEBUG(DebugByteCount=-1);
168 #ifndef USE_CBM_IEC_WAIT
169 if(size == BLOCKSIZE) {
173 SETSTATEDEBUG((
void)0);
175 SETSTATEDEBUG((
void)0);
180 const void *arg,
int for_writing,
181 turbo_start start, d64copy_message_cb message_cb)
183 unsigned char d = (
unsigned char)(ULONG_PTR)arg;
186 two_sided = settings->two_sided;
192 SETSTATEDEBUG((
void)0);
193 cbm_upload(fd_cbm, d, 0x700, s2_drive_prog,
sizeof(s2_drive_prog));
194 SETSTATEDEBUG((
void)0);
196 SETSTATEDEBUG((
void)0);
198 SETSTATEDEBUG((
void)0);
200 SETSTATEDEBUG((
void)0);
204 SETSTATEDEBUG((
void)0);
208 static void close_disk(
void)
210 SETSTATEDEBUG((
void)0);
211 s2_write_byte(fd_cbm, 0);
212 SETSTATEDEBUG((
void)0);
213 s2_write_byte_nohs(fd_cbm, 0);
215 SETSTATEDEBUG(DebugBitCount=-1);
217 SETSTATEDEBUG((
void)0);
219 SETSTATEDEBUG((
void)0);
221 SETSTATEDEBUG((
void)0);
228 static int send_track_map(
unsigned char tr,
const char *trackmap,
unsigned char count)
234 SETSTATEDEBUG((
void)0);
235 size = d64copy_sector_count(two_sided, tr);
236 data = malloc(2+size);
242 for(i = 0; i < size; i++)
243 data[2+i] = !NEED_SECTOR(trackmap[i]);
245 write_n(data, size+2);
247 SETSTATEDEBUG((
void)0);
251 static int read_gcr_block(
unsigned char *se,
unsigned char *gcrbuf)
255 SETSTATEDEBUG((
void)0);
258 SETSTATEDEBUG((
void)0);
264 SETSTATEDEBUG(DebugByteCount=0);
265 read_n(gcrbuf, GCRBUFSIZE);
266 SETSTATEDEBUG(DebugByteCount=-1);
270 DECLARE_TRANSFER_FUNCS_EX(s2_transfer, 1, 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 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.