/* DolphinDOS XZ command */ void save_dolphin(void) { buffer_t *buf; uint8_t eoi; /* find the already open file */ buf = find_buffer(1); if (!buf) return; /* reset buffer position */ buf->position = 2; buf->lastused = 2; /* experimental delay to avoid hangs */ delay_us(100); /* handshaking */ parallel_set_dir(PARALLEL_DIR_IN); set_data(0); parallel_clear_rxflag(); parallel_send_handshake(); uart_flush(); /* receive data */ do { /* flush buffer if full */ if (buf->mustflush) if (buf->refill(buf)) return; // FIXME: check error handling in Dolphin while (!parallel_rxflag) ; buf->data[buf->position] = parallel_read(); mark_buffer_dirty(buf); if (buf->lastused < buf->position) buf->lastused = buf->position; buf->position++; /* mark for flushing on wrap */ if (buf->position == 0) buf->mustflush = 1; eoi = !!IEC_CLOCK; parallel_clear_rxflag(); parallel_send_handshake(); } while (!eoi); /* the file will be closed with ATN+0xe1 by DolphinDOS */ }
void f77_parallel_read(char *filename, int *fnamelen, long *size, long long *offset, void *buffer) { #elif defined ADD2US void f77_parallel_read__(char *filename, int *fnamelen, long *size, long long *offset, void *buffer) { #else void f77_parallel_read_(char *filename, int *fnamelen, long *size, long long *offset, void *buffer) { #endif int stat; filename[*fnamelen]='\0'; stat = parallel_read(filename,*size,*offset,buffer); if (stat !=0) fprintf(stderr,"Failure to read with parallel_read\n"); }
/** * _dolphin_getc - receive one byte from the parallel port (DD A816) * * This function tries to receive one byte via parallel and returns * it if successful. Returns -1 instead if the device state has * changed. */ static int16_t _dolphin_getc(void) { /* wait until CLOCK is high */ while (!IEC_CLOCK) // A818 if (iec_check_atn()) return -1; set_data(1); // A81F /* start EOI timeout */ start_timeout(86); /* wait until CLOCK is low or 86 microseconds passed */ uint8_t tmp; do { if (iec_check_atn()) return -1; tmp = has_timed_out(); } while (!tmp && IEC_CLOCK); if (tmp) { // A835 /* acknowledge EOI */ set_data(0); delay_us(57); set_data(1); uart_putc('E'); iec_data.iecflags |= EOI_RECVD; /* wait until CLOCK is low - A849 */ while (IEC_CLOCK) if (iec_check_atn()) return -1; } /* read byte */ uint8_t b = parallel_read(); parallel_send_handshake(); set_data(0); return b; }