static int send_track_map(unsigned char tr, const char *trackmap, unsigned char count) { int i; unsigned char c; pp_write(fd_cbm, tr, count); for(i = 0; i < d64copy_sector_count(two_sided, tr); i++) { c = !NEED_SECTOR(trackmap[i]); pp_write(fd_cbm, c, c); } return 0; }
static int write2byte(CBM_FILE fd, unsigned char c1, unsigned char c2) { int ret; SETSTATEDEBUG(DebugByteCount = -12801); ret = pp_write(fd, c1, c2); SETSTATEDEBUG(DebugByteCount = -1); return ret; }
static void close_disk(void) { pp_write(fd_cbm, 0, 0); arch_usleep(100); cbm_iec_wait(fd_cbm, IEC_DATA, 0); /* make sure the XP1541 portion of the cable is in input mode */ cbm_pp_read(fd_cbm); }
static int write1byte(CBM_FILE fd, unsigned char c1) { int ret; SETSTATEDEBUG(DebugByteCount = -6401); ret = pp_write(fd, c1, 0); SETSTATEDEBUG(DebugByteCount = -1); return ret; }
/* write_n redirects USB writes to the external reader if required */ static void write_n(const unsigned char *data, int size) { int i; if (opencbm_plugin_pp_dc_write_n) { opencbm_plugin_pp_dc_write_n(fd_cbm, data, size); return; } for(i=0;i<size/2;i++,data+=2) pp_write(fd_cbm, data[0], data[1]); }
static int read_block(unsigned char tr, unsigned char se, unsigned char *block) { int i; unsigned char status; pp_write(fd_cbm, tr, se); #ifndef USE_CBM_IEC_WAIT arch_usleep(20000); #endif pp_read(fd_cbm, &status, &status); for(i=0; i<BLOCKSIZE; i+=2) pp_read(fd_cbm, &block[i], &block[i+1]); return status; }
static int write_block(unsigned char tr, unsigned char se, const unsigned char *blk, int size, int read_status) { int i = 0; unsigned char status; pp_write(fd_cbm, tr, se); if(size % 2) { pp_write(fd_cbm, *blk, *blk); i = 1; } for(; i<size; i+=2) pp_write(fd_cbm, blk[i], blk[i+1]); #ifndef USE_CBM_IEC_WAIT if(size == BLOCKSIZE) { arch_usleep(20000); } #endif pp_read(fd_cbm, &status, &status); return status; }
static int writeblock(CBM_FILE fd, unsigned char *p, unsigned int length) { SETSTATEDEBUG(DebugByteCount = 0); for (; length < 0x100; length += 2, p += 2) { SETSTATEDEBUG(DebugByteCount += 2); if (pp_write(fd, p[0], p[1])) { SETSTATEDEBUG(DebugByteCount = -1); return 1; } } SETSTATEDEBUG(DebugByteCount = -1); return 0; }
static void close_disk(void) { SETSTATEDEBUG((void)0); pp_write(fd_cbm, 0, 0); arch_usleep(100); SETSTATEDEBUG((void)0); cbm_iec_wait(fd_cbm, IEC_DATA, 0); /* make sure the XP1541 portion of the cable is in input mode */ SETSTATEDEBUG((void)0); cbm_pp_read(fd_cbm); SETSTATEDEBUG((void)0); opencbm_plugin_pp_dc_read_n = NULL; opencbm_plugin_pp_dc_write_n = NULL; }