12 #include "d64copy_int.h"
24 static const unsigned char s1_drive_prog[] = {
31 static int s1_write_byte_nohs(
CBM_FILE fd,
unsigned char c)
35 SETSTATEDEBUG(DebugBitCount=i);
37 SETSTATEDEBUG((
void)0);
39 SETSTATEDEBUG((
void)0);
41 SETSTATEDEBUG((
void)0);
42 #ifndef USE_CBM_IEC_WAIT
47 SETSTATEDEBUG((
void)0);
49 SETSTATEDEBUG((
void)0);
50 #ifndef USE_CBM_IEC_WAIT
55 SETSTATEDEBUG((
void)0);
57 SETSTATEDEBUG((
void)0);
59 SETSTATEDEBUG((
void)0);
62 SETSTATEDEBUG((
void)0);
64 #ifndef USE_CBM_IEC_WAIT
70 SETSTATEDEBUG((
void)0);
73 static int s1_write_byte(
CBM_FILE fd,
unsigned char c)
75 SETSTATEDEBUG((
void)0);
76 s1_write_byte_nohs(fd, c);
77 SETSTATEDEBUG((
void)0);
78 #ifndef USE_CBM_IEC_WAIT
83 SETSTATEDEBUG(DebugBitCount=-1);
88 static void write_n(
const unsigned char *data,
int size)
99 s1_write_byte(fd_cbm, *data++);
102 static int s1_read_byte(
CBM_FILE fd,
unsigned char *c)
106 for(i=7; i>=0; i--) {
107 SETSTATEDEBUG(DebugBitCount=i);
108 #ifndef USE_CBM_IEC_WAIT
113 SETSTATEDEBUG((
void)0);
115 SETSTATEDEBUG((
void)0);
117 SETSTATEDEBUG((
void)0);
118 *c = (*c >> 1) | (b ? 0x80 : 0);
120 SETSTATEDEBUG((
void)0);
121 #ifndef USE_CBM_IEC_WAIT
126 SETSTATEDEBUG((
void)0);
128 SETSTATEDEBUG((
void)0);
129 #ifndef USE_CBM_IEC_WAIT
134 SETSTATEDEBUG((
void)0);
137 SETSTATEDEBUG(DebugBitCount=-1);
142 static void read_n(
unsigned char *data,
int size)
153 s1_read_byte(fd_cbm, data++);
156 static int read_block(
unsigned char tr,
unsigned char se,
unsigned char *block)
158 unsigned char status;
160 SETSTATEDEBUG((
void)0);
162 SETSTATEDEBUG((
void)0);
164 SETSTATEDEBUG((
void)0);
165 #ifndef USE_CBM_IEC_WAIT
168 SETSTATEDEBUG((
void)0);
170 SETSTATEDEBUG(DebugByteCount=0);
173 SETSTATEDEBUG(DebugByteCount=-1);
175 SETSTATEDEBUG((
void)0);
179 static int write_block(
unsigned char tr,
unsigned char se,
const unsigned char *blk,
int size,
int read_status)
181 unsigned char status;
182 SETSTATEDEBUG((
void)0);
184 SETSTATEDEBUG((
void)0);
186 SETSTATEDEBUG(DebugByteCount=0);
190 SETSTATEDEBUG(DebugByteCount=-1);
191 #ifndef USE_CBM_IEC_WAIT
192 if(size == BLOCKSIZE) {
193 SETSTATEDEBUG((
void)0);
197 SETSTATEDEBUG((
void)0);
199 SETSTATEDEBUG((
void)0);
201 SETSTATEDEBUG((
void)0);
207 const void *arg,
int for_writing,
208 turbo_start start, d64copy_message_cb message_cb)
210 unsigned char d = (
unsigned char)(ULONG_PTR)arg;
213 two_sided = settings->two_sided;
219 SETSTATEDEBUG((
void)0);
220 cbm_upload(fd_cbm, d, 0x700, s1_drive_prog,
sizeof(s1_drive_prog));
221 SETSTATEDEBUG((
void)0);
223 SETSTATEDEBUG((
void)0);
225 SETSTATEDEBUG((
void)0);
229 static void close_disk(
void)
231 SETSTATEDEBUG((
void)0);
232 s1_write_byte(fd_cbm, 0);
233 SETSTATEDEBUG((
void)0);
234 s1_write_byte_nohs(fd_cbm, 0);
235 SETSTATEDEBUG((
void)0);
237 SETSTATEDEBUG(DebugBitCount=-1);
244 static int send_track_map(
unsigned char tr,
const char *trackmap,
unsigned char count)
248 SETSTATEDEBUG((
void)0);
249 size = d64copy_sector_count(two_sided, tr);
250 data = malloc(size+2);
256 for(i = 0; i < size; i++)
257 data[2+i] = !NEED_SECTOR(trackmap[i]);
258 SETSTATEDEBUG((
void)0);
259 write_n(data, size+2);
261 SETSTATEDEBUG((
void)0);
265 static int read_gcr_block(
unsigned char *se,
unsigned char *gcrbuf)
269 SETSTATEDEBUG((
void)0);
271 SETSTATEDEBUG((
void)0);
274 SETSTATEDEBUG((
void)0);
280 SETSTATEDEBUG(DebugByteCount=0);
281 read_n(gcrbuf, GCRBUFSIZE);
282 SETSTATEDEBUG(DebugByteCount=-1);
286 DECLARE_TRANSFER_FUNCS_EX(s1_transfer, 1, 1);
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.
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_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