t_stat lpt_svc (UNIT *uptr) { int32 i, skip, chan; if ((uptr->flags & UNIT_ATT) == 0) /* attached? */ return IOERROR (lpt_stopioe, SCPE_UNATT); else if (uptr->flags & UNIT_OFFLINE) /* offline? */ return IOERROR (lpt_stopioe, STOP_OFFLINE); else if (uptr->flags & UNIT_POWEROFF) /* powered off? */ return IOERROR (lpt_stopioe, STOP_PWROFF); lptio (&lpt_dib, ioENF, 0); /* set flag */ if (uptr->buf & LPT_CTL) { /* control word? */ if (uptr->buf & LPT_CHAN) { chan = uptr->buf & LPT_CHANM; if (chan == 0) { /* top of form? */ fputc ('\f', uptr->fileref); /* ffeed */ lpt_lcnt = 0; /* reset line cnt */ skip = 0; } else if (chan == 1) skip = LPT_PAGELNT - lpt_lcnt - 1; else skip = lpt_cct[chan] - (lpt_lcnt % lpt_cct[chan]); } else { skip = uptr->buf & LPT_SKIPM; if (skip == 0) fputc ('\r', uptr->fileref); } for (i = 0; i < skip; i++) fputc ('\n', uptr->fileref); lpt_lcnt = (lpt_lcnt + skip) % LPT_PAGELNT; } else fputc (uptr->buf & 0177, uptr->fileref); /* no, just add char */ if (ferror (uptr->fileref)) { perror ("LPT I/O error"); clearerr (uptr->fileref); return SCPE_IOERR; } lpt_unit.pos = ftell (uptr->fileref); /* update pos */ return SCPE_OK; }
t_stat ttp_out (int32 c) { if (tty_mode & TM_PUN) { /* punching? */ if ((tty_unit[TTP].flags & UNIT_ATT) == 0) /* attached? */ return IOERROR (ttp_stopioe, SCPE_UNATT); if (putc (c, tty_unit[TTP].fileref) == EOF) { /* output char */ perror ("TTP I/O error"); clearerr (tty_unit[TTP].fileref); return SCPE_IOERR; } tty_unit[TTP].pos = ftell (tty_unit[TTP].fileref); } return SCPE_OK; }
t_stat ptp_svc (UNIT *uptr) { ptpio (&ptp_dib, ioENF, 0); /* set flag */ if ((ptp_unit.flags & UNIT_ATT) == 0) /* attached? */ return IOERROR (ptp_stopioe, SCPE_UNATT); if (putc (ptp_unit.buf, ptp_unit.fileref) == EOF) { /* output byte */ perror ("PTP I/O error"); clearerr (ptp_unit.fileref); return SCPE_IOERR; } ptp_unit.pos = ftell (ptp_unit.fileref); /* update position */ return SCPE_OK; }
t_stat ptr_svc (UNIT *uptr) { int32 temp; if ((ptr_unit.flags & UNIT_ATT) == 0) /* attached? */ return IOERROR (ptr_stopioe, SCPE_UNATT); while ((temp = getc (ptr_unit.fileref)) == EOF) { /* read byte, error? */ if (feof (ptr_unit.fileref)) { /* end of file? */ if ((ptr_unit.flags & UNIT_DIAG) && (ptr_unit.pos > 0)) { rewind (ptr_unit.fileref); /* rewind if loop mode */ ptr_unit.pos = 0; } else { if (ptr_trlcnt >= ptr_trllim) { /* added all trailer? */ if (ptr_stopioe) { /* stop on error? */ printf ("PTR end of file\n"); return SCPE_IOERR; } else return SCPE_OK; /* no, just hang */ } ptr_trlcnt++; /* count trailer */ temp = 0; /* read a zero */ break; } } else { /* no, real error */ perror ("PTR I/O error"); clearerr (ptr_unit.fileref); return SCPE_IOERR; } } ptrio (&ptr_dib, ioENF, 0); /* set flag */ ptr_unit.buf = temp & 0377; /* put byte in buf */ ptr_unit.pos = ftell (ptr_unit.fileref); if (temp) /* character non-null? */ ptr_trlcnt = 0; /* clear trailing null counter */ return SCPE_OK; }