예제 #1
0
파일: id_lp.c 프로젝트: ST3ALth/simh
t_stat lpt_svc (UNIT *uptr)
{
int32 t;
t_stat r = SCPE_OK;

lpt_sta = 0;                                            /* clear busy */
if (lpt_arm)                                            /* armed? intr */
    SET_INT (v_LPT);
if ((uptr->flags & UNIT_ATT) == 0)                      /* attached? */
    return IORETURN (lpt_stopioe, SCPE_UNATT);
t = uptr->buf;                                          /* get character */
if (lpt_spnd || ((t >= LF) && (t < CR))) {              /* spc pend or spc op? */
    lpt_spnd = 0;
    if (lpt_bufout (uptr) != SCPE_OK)                   /* print */
        return SCPE_IOERR;
    if ((t == 1) || (t == LF))                          /* single space */
        lpt_spc (uptr, 1);
    else if (t == VT)                                   /* VT->VFU */
        r = lpt_vfu (uptr, VT_VFU - 1);
    else if (t == 0xC)                                  /* FF->VFU */
        r = lpt_vfu (uptr, FF_VFU - 1);
    else if ((t >= SPC_BASE) && (t < VFU_BASE))
        lpt_spc (uptr, t - SPC_BASE);                   /* space */
    else if ((t >= VFU_BASE) && (t < VFU_BASE + VFU_WIDTH))
        r = lpt_vfu (uptr, t - VFU_BASE);               /* VFU */
    else fputs ("\r", uptr->fileref);                   /* overprint */
    uptr->pos = ftell (uptr->fileref);                  /* update position */
    if (ferror (lpt_unit.fileref)) {
        sim_perror ("LPT I/O error");
        clearerr (uptr->fileref);
        return SCPE_IOERR;
        }
    }
else if (t == CR) {                                     /* CR? */
    lpt_spnd = 1;                                       /* set spc pend */
    return lpt_bufout (uptr);                           /* print line */
    }
else if (t >= 0x20) {                                   /* printable? */
    if ((uptr->flags & UNIT_UC) && islower (t))         /* UC only? */
        t = toupper (t);
    if (lpt_bptr < LPT_WIDTH)
        lpxb[lpt_bptr++] = t;
    }
return r;
}
예제 #2
0
파일: sds_lp.c 프로젝트: markemmer/simh
t_stat lpt_svc (UNIT *uptr)
{
t_stat r = SCPE_OK;

if (lpt_sta & SET_XFR)                                  /* need lpt xfr? */
    chan_set_ordy (lpt_dib.chan);
if (lpt_sta & SET_EOR) {                                /* printing? */
    chan_set_flag (lpt_dib.chan, CHF_EOR);              /* set eor flg */
    r = lpt_bufout (uptr);                              /* output buf */
    }
if (lpt_sta & SET_SPC) {                                /* spacing? */
    if (uptr->flags & UNIT_ATT) {                       /* attached? */
        int32 ln = LPT_GETLN (lpt_spc);                 /* get lines, ch */
        if (lpt_spc & 0200)                             /* n lines? */
            lpt_space (uptr, ln);                       /* upspace */
        else lpt_crctl (uptr, ln);                      /* carriage ctl */
        }
    r = lpt_status (uptr);                              /* update status */
    }
lpt_sta = 0;                                            /* clear state */
return r;
}
예제 #3
0
파일: sds_lp.c 프로젝트: markemmer/simh
t_stat lpt (uint32 fnc, uint32 inst, uint32 *dat)
{
int32 i, t, new_ch;
char asc;

switch (fnc) {                                          /* case function */

    case IO_CONN:                                       /* connect */
        new_ch = I_GETEOCH (inst);                      /* get new chan */
        if (new_ch != lpt_dib.chan)                     /* wrong chan? */
            return SCPE_IERR;
        for (i = 0; i < LPT_WIDTH; i++)                 /* clr buffer */
            lpt_buf[i] = 0;
        lpt_bptr = 0;                                   /* clr buf ptr */
        lpt_err = 0;                                    /* err = 0 */
        xfr_req = xfr_req & ~XFR_LPT;                   /* clr xfr flag */
        lpt_sta = lpt_sta | SET_XFR;                    /* need xfr */
        sim_activate (&lpt_unit, lpt_ctime);            /* start timer */
        break;

    case IO_EOM1:                                       /* EOM mode 1 */
        new_ch = I_GETEOCH (inst);                      /* get new chan */
        if (new_ch != lpt_dib.chan)                     /* wrong chan? */
            CRETIOP;
        if (inst & 0400) {                              /* space? */
            lpt_spc = inst;                             /* save instr */
            lpt_sta = lpt_sta | SET_SPC;                /* need space */
            sim_cancel (&lpt_unit);                     /* cancel timer */
            sim_activate (&lpt_unit, lpt_stime);        /* start timer */
            }
        break;

    case IO_DISC:                                       /* disconnect */
        lpt_end_op (0);                                 /* normal term */
        return lpt_bufout (&lpt_unit);                  /* dump output */

    case IO_WREOR:                                      /* write eor */
        lpt_sta = (lpt_sta | SET_EOR) & ~SET_XFR;       /* need eor */
        sim_activate (&lpt_unit, lpt_ptime);            /* start timer */
        break;

    case IO_SKS:                                        /* SKS */
        new_ch = I_GETSKCH (inst);                      /* sks chan */
        if (new_ch != lpt_dib.chan)                     /* wrong chan? */
            return SCPE_IERR;
        t = I_GETSKCND (inst);                          /* sks cond */
        if (((t == 020) && (!CHP (7, lpt_cct[lpt_ccp]))) || /* 14062: !ch 7 */
            ((t == 010) && (lpt_unit.flags & UNIT_ATT)) ||  /* 12062: !online */
            ((t == 004) && !lpt_err))                   /* 11062: !err */
            *dat = 1;
        break;

    case IO_WRITE:                                      /* write */
        asc = sds_to_ascii(*dat);                       /* convert data */
        xfr_req = xfr_req & ~XFR_LPT;                   /* clr xfr flag */
        if (lpt_bptr < LPT_WIDTH)                       /* store data */
            lpt_buf[lpt_bptr++] = asc;
        lpt_sta = lpt_sta | SET_XFR;                    /* need xfr */
        sim_activate (&lpt_unit, lpt_ctime);            /* start ch timer */
        break;

    default:
        CRETINS;
        }

return SCPE_OK;
}