Пример #1
0
t_stat read_card (int32 ilnt, int32 mod)
{
int32 i, cbn, c1, c2;
t_stat r;

if (sim_is_active (&cdr_unit)) {                        /* busy? */
    sim_cancel (&cdr_unit);                             /* cancel */
    if (r = cdr_svc (&cdr_unit))                        /* process */
        return r;
    }
if ((cdr_unit.flags & UNIT_ATT) == 0)                   /* attached? */
    return SCPE_UNATT;
ind[IN_READ] = ind[IN_LST] = s1sel = s2sel = 0;         /* default stacker */
cbn = ((ilnt == 2) || (ilnt == 5)) && (mod == BCD_C);   /* col binary? */
for (i = 0; i < 2 * CBUFSIZE; i++)                      /* clear extended buf */
    rbuf[i] = 0;
fgets (rbuf, (cbn)? 2 * CBUFSIZE: CBUFSIZE,             /* rd bin/char card */
     cdr_unit.fileref);
if (feof (cdr_unit.fileref))                            /* eof? */
    return STOP_NOCD;
if (ferror (cdr_unit.fileref)) {                        /* error? */
    ind[IN_READ] = 1;  
    perror ("Card reader I/O error");
    clearerr (cdr_unit.fileref);
    if (iochk)
        return SCPE_IOERR;
    return SCPE_OK;
    }
cdr_unit.pos = ftell (cdr_unit.fileref);                /* update position */
if (ssa) {                                              /* if last cd on */
    getc (cdr_unit.fileref);                            /* see if more */
    if (feof (cdr_unit.fileref))                        /* eof? set flag */
        ind[IN_LST] = 1;
    fseek (cdr_unit.fileref, cdr_unit.pos, SEEK_SET);
    }
if (cbn) {                                              /* column binary */
    for (i = 0; i < CDR_WIDTH; i++) {
        if (conv_old) {
            c1 = ascii2bcd (rbuf[i]);
            c2 = ascii2bcd (rbuf[CDR_WIDTH + i]);
            }
        else {
            c1 = ascii2bcd (rbuf[2 * i]);
            c2 = ascii2bcd (rbuf[(2 * i) + 1]);
            }
        M[CD_CBUF1 + i] = (M[CD_CBUF1 + i] & WM) | c1;
        M[CD_CBUF2 + i] = (M[CD_CBUF2 + i] & WM) | c2;
        M[CDR_BUF + i] = colbin_to_bcd ((c1 << 6) | c2);
        }                                               /* end for i */
    }                                                   /* end if col bin */
else {                                                  /* normal read */
    for (i = 0; i < CDR_WIDTH; i++) {                   /* cvt to BCD */
        rbuf[i] = ascii2bcd (rbuf[i]);
        M[CDR_BUF + i] = (M[CDR_BUF + i] & WM) | rbuf[i];
        }
    }
M[CDR_BUF - 1] = 060;                                   /* mem mark */
sim_activate (&cdr_unit, cdr_unit.wait);                /* activate */
return SCPE_OK;
}
Пример #2
0
t_stat read_card (int32 ilnt, int32 mod)
{
int32 i, cbn, c1, c2, cbufsz;
t_stat r;

if (sim_is_active (&cdr_unit)) {                        /* busy? */
    sim_cancel (&cdr_unit);                             /* cancel */
    if ((r = cdr_svc (&cdr_unit)))                      /* process */
        return r;
    }
ind[IN_READ] = ind[IN_LST] = s1sel = s2sel = 0;         /* default stacker */
cbn = ((ilnt == 2) || (ilnt == 5)) && (mod == BCD_C);   /* col binary? */
cbufsz = (cbn)? 2 * CBUFSIZE: CBUFSIZE;                 /* buffer size */
for (i = 0; i < (2 * CBUFSIZE) + 1; i++)                /* clear extended buf */
    cdr_buf[i] = 0;
if ((cdr_unit.flags & UNIT_ATT) != 0)                   /* attached? */
    r = cdr_read_file (cdr_buf, cbufsz);                /* read from file */
else if ((cdr_unit.flags & UNIT_CONS) != 0)             /* default to console? */
    r = cdr_read_cons (cdr_buf, cbufsz);                /* read from console */
else return SCPE_UNATT;                                 /* else can't read */
if (r != SCPE_OK)                                       /* read error? */
    return r;                                           /* can't read */
if (cbn) {                                              /* column binary? */
    for (i = 0; i < CDR_WIDTH; i++) {
        if (conv_old) {
            c1 = ascii2bcd (cdr_buf[i]);
            c2 = ascii2bcd (cdr_buf[CDR_WIDTH + i]);
            }
        else {
            c1 = ascii2bcd (cdr_buf[2 * i]);
            c2 = ascii2bcd (cdr_buf[(2 * i) + 1]);
            }
        M[CD_CBUF1 + i] = (M[CD_CBUF1 + i] & WM) | c1;
        M[CD_CBUF2 + i] = (M[CD_CBUF2 + i] & WM) | c2;
        M[CDR_BUF + i] = colbin_to_bcd ((c1 << 6) | c2);
        }
    }                                                   /* end if col bin */
else {                                                  /* normal read */
    for (i = 0; i < CDR_WIDTH; i++) {                   /* cvt to BCD */
        c1 = ascii2bcd (cdr_buf[i]);
        M[CDR_BUF + i] = (M[CDR_BUF + i] & WM) | c1;
        }
    }
M[CDR_BUF - 1] = 060;                                   /* mem mark */
sim_activate (&cdr_unit, cdr_unit.wait);                /* activate */
return SCPE_OK;
}
Пример #3
0
t_stat inq_io (int32 flag, int32 mod)
{
int32 i, t, wm_seen = 0;
t_bool use_h = inq_unit.flags & UNIT_PCH;

ind[IN_INC] = 0;                                        /* clear inq clear */
switch (mod) {                                          /* case on mod */

    case BCD_R:                                         /* input */
/*      if (ind[IN_INR] == 0)                         */
/*          return SCPE_OK;                           *//* return if no req */
        ind[IN_INR] = 0;                                /* clear req */
        inq_puts ("[Enter]\r\n");                       /* prompt */
        for (i = 0; M[BS] != (BCD_GRPMRK + WM); i++) {  /* until GM + WM */
            while (((t = sim_poll_kbd ()) == SCPE_OK) ||
                    (t & SCPE_BREAK)) {
                if (stop_cpu)                           /* interrupt? */
                    return SCPE_STOP;
                }
            if (t < SCPE_KFLAG)                         /* if not char, err */
                return t;
            t = t & 0177;
            if ((t == '\r') || (t == '\n'))
                break;
            if (t == inq_char) {                        /* cancel? */
                ind[IN_INC] = 1;                        /* set indicator */
                inq_puts ("\r\n[Canceled]\r\n");
                return SCPE_OK;
                }
            if (i && ((i % INQ_WIDTH) == 0))
                inq_puts ("\r\n");
            sim_putchar (t);                            /* echo */
            if (flag == MD_WM) {                        /* word mark mode? */
                if ((t == '~') && (wm_seen == 0))
                    wm_seen = WM;
                else {
                    M[BS] = wm_seen | ascii2bcd (t);
                    wm_seen = 0;
                    }
                }
            else M[BS] = (M[BS] & WM) | ascii2bcd (t);
            if (!wm_seen)
                BS++;
            if (ADDR_ERR (BS)) {
                BS = BA | (BS % MAXMEMSIZE);
                return STOP_NXM;
                }
            }
        inq_puts ("\r\n");
        M[BS++] = BCD_GRPMRK + WM;
        break;

    case BCD_W:                                         /* output */
        for (i = 0; (t = M[BS++]) != (BCD_GRPMRK + WM); i++) {
            if ((flag == MD_WM) && (t & WM)) {
                if (i && ((i % INQ_WIDTH) == 0))
                    inq_puts ("\r\n");
                if (conv_old)
                    sim_putchar ('~');
                else sim_putchar ('`');
                }
            if (i && ((i % INQ_WIDTH) == 0))
                inq_puts ("\r\n");
            sim_putchar (bcd2ascii (t & CHAR, use_h));
            if (ADDR_ERR (BS)) {
                BS = BA | (BS % MAXMEMSIZE);
                return STOP_NXM;
                }
            }
        inq_puts ("\r\n");
        break;

    default:                                            /* invalid mod */
        return STOP_INVM;
        }

return SCPE_OK;
}