12 #include "d64copy_int.h"
32 static const unsigned char pp1541_drive_prog[] = {
36 static const unsigned char pp1571_drive_prog[] = {
40 static void pp_check_direction(
enum pp_direction_e dir)
42 static enum pp_direction_e direction = PP_READ;
50 static int pp_write(
CBM_FILE fd,
char c1,
char c2)
52 SETSTATEDEBUG((
void)0);
53 pp_check_direction(PP_WRITE);
54 SETSTATEDEBUG((
void)0);
55 #ifndef USE_CBM_IEC_WAIT
60 SETSTATEDEBUG((
void)0);
62 SETSTATEDEBUG((
void)0);
65 SETSTATEDEBUG((
void)0);
66 #ifndef USE_CBM_IEC_WAIT
71 SETSTATEDEBUG((
void)0);
73 SETSTATEDEBUG((
void)0);
76 SETSTATEDEBUG((
void)0);
81 static void write_n(
const unsigned char *data,
int size)
91 for(i=0;i<size/2;i++,data+=2)
92 pp_write(fd_cbm, data[0], data[1]);
95 static int pp_read(
CBM_FILE fd,
unsigned char *c1,
unsigned char *c2)
97 SETSTATEDEBUG((
void)0);
98 pp_check_direction(PP_READ);
99 SETSTATEDEBUG((
void)0);
100 #ifndef USE_CBM_IEC_WAIT
105 SETSTATEDEBUG((
void)0);
107 SETSTATEDEBUG((
void)0);
110 SETSTATEDEBUG((
void)0);
111 #ifndef USE_CBM_IEC_WAIT
116 SETSTATEDEBUG((
void)0);
118 SETSTATEDEBUG((
void)0);
121 SETSTATEDEBUG((
void)0);
126 static void read_n(
unsigned char *data,
int size)
136 for(i=0;i<size/2;i++,data+=2)
137 pp_read(fd_cbm, data, data+1);
140 static int read_block(
unsigned char tr,
unsigned char se,
unsigned char *block)
142 unsigned char status[2];
143 SETSTATEDEBUG((
void)0);
145 status[0] = tr; status[1] = se;
148 #ifndef USE_CBM_IEC_WAIT
151 SETSTATEDEBUG((
void)0);
154 SETSTATEDEBUG(DebugByteCount=0);
155 read_n(block, BLOCKSIZE);
156 SETSTATEDEBUG(DebugByteCount=-1);
158 SETSTATEDEBUG((
void)0);
162 static int write_block(
unsigned char tr,
unsigned char se,
const unsigned char *blk,
int size,
int read_status)
165 unsigned char status[2];
167 SETSTATEDEBUG((
void)0);
168 status[0] = tr; status[1] = se;
171 SETSTATEDEBUG((
void)0);
177 SETSTATEDEBUG(DebugByteCount=0);
178 write_n(blk+i, size-i);
180 SETSTATEDEBUG(DebugByteCount=-1);
181 #ifndef USE_CBM_IEC_WAIT
182 if(size == BLOCKSIZE) {
187 SETSTATEDEBUG((
void)0);
190 SETSTATEDEBUG((
void)0);
195 const void *arg,
int for_writing,
196 turbo_start start, d64copy_message_cb message_cb)
198 unsigned char d = (
unsigned char)(ULONG_PTR)arg;
199 const unsigned char *drive_prog;
203 two_sided = settings->two_sided;
211 drive_prog = pp1571_drive_prog;
212 prog_size =
sizeof(pp1571_drive_prog);
216 drive_prog = pp1541_drive_prog;
217 prog_size =
sizeof(pp1541_drive_prog);
220 SETSTATEDEBUG((
void)0);
224 SETSTATEDEBUG((
void)0);
225 cbm_upload(fd_cbm, d, 0x700, drive_prog, prog_size);
226 SETSTATEDEBUG((
void)0);
228 SETSTATEDEBUG((
void)0);
229 pp_check_direction(PP_READ);
230 SETSTATEDEBUG((
void)0);
232 SETSTATEDEBUG((
void)0);
234 SETSTATEDEBUG((
void)0);
238 static void close_disk(
void)
240 SETSTATEDEBUG((
void)0);
241 pp_write(fd_cbm, 0, 0);
243 SETSTATEDEBUG((
void)0);
247 SETSTATEDEBUG((
void)0);
249 SETSTATEDEBUG((
void)0);
256 static int send_track_map(
unsigned char tr,
const char *trackmap,
unsigned char count)
261 size = d64copy_sector_count(two_sided, tr);
262 data = malloc(2+2*size);
268 for(i = 0; i < size; i++)
269 data[2+2*i] = data[2+2*i+1] = !NEED_SECTOR(trackmap[i]);
271 write_n(data, 2*size+2);
273 SETSTATEDEBUG((
void)0);
277 static int read_gcr_block(
unsigned char *se,
unsigned char *gcrbuf)
280 SETSTATEDEBUG((
void)0);
283 SETSTATEDEBUG((
void)0);
289 SETSTATEDEBUG(DebugByteCount=0);
290 read_n(gcrbuf, GCRBUFSIZE);
291 SETSTATEDEBUG(DebugByteCount=-1);
293 SETSTATEDEBUG((
void)0);
297 DECLARE_TRANSFER_FUNCS_EX(pp_transfer, 1, 1);
int CBMAPIDECL opencbm_plugin_pp_dc_read_n_t(CBM_FILE HandleDevice, unsigned char *data, unsigned int size)
read a block of data from the OpenCBM backend with protocol parallel/d64copy
unsigned char CBMAPIDECL cbm_pp_read(CBM_FILE HandleDevice)
Read a byte from a XP1541/XP1571 cable.
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_pp_dc_read_n(CBM_FILE HandleDevice, unsigned char *data, unsigned int size)
Read data with parallel protocol (d64copy)
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.
int CBMAPIDECL opencbm_plugin_pp_dc_write_n(CBM_FILE HandleDevice, const unsigned char *data, unsigned int size)
Write data with parallel protocol (d64copy)
int CBMAPIDECL opencbm_plugin_pp_dc_write_n_t(CBM_FILE HandleDevice, const unsigned char *data, unsigned int size)
write a block of data to the OpenCBM backend with protocol parallel/d64copy
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.
void CBMAPIDECL cbm_pp_write(CBM_FILE HandleDevice, unsigned char Byte)
Write a byte to a XP1541/XP1571 cable.