Esempio n. 1
0
t_stat carriage_control (int32 mod)
{
int32 i, action;

action = (mod & ZONE) >> V_ZONE;                        /* get mod type */
mod = mod & DIGIT;                                      /* isolate value */

switch (action) {

    case 0:                                             /* to channel now */
        if ((mod == 0) || (mod > 12) || CHP (mod, cct[cctptr]))
            return SCPE_OK;
        for (i = 1; i < cctlnt + 1; i++) {              /* sweep thru cct */
            if (CHP (mod, cct[(cctptr + i) % cctlnt]))
                return space (i, TRUE);
            }
        return STOP_CCT;                                /* runaway channel */

    case 1:                                             /* space after */
        if (mod <= 3) {
            lines = mod;                                /* save # lines */
            lflag = FALSE;                              /* flag spacing */
            ind[IN_CC9] = ind[IN_CC12] = 0;
            }
        return SCPE_OK;

    case 2:                                             /* space now */
        if (mod <= 3)
            return space (mod, FALSE);
        return SCPE_OK;

    case 3:                                             /* to channel after */
        if ((mod == 0) || (mod > 12))                   /* check channel */
            return SCPE_OK;
        ind[IN_CC9] = ind[IN_CC12] = 0;
        for (i = 1; i < cctlnt + 1; i++) {              /* sweep thru cct */
            if (CHP (mod, cct[(cctptr + i) % cctlnt])) {
                lines = i;                              /* save # lines */
                lflag = TRUE;                           /* flag skipping */
                return SCPE_OK;
                }
            }
        return STOP_CCT;                                /* runaway channel */
        }

return SCPE_OK;
}
Esempio n. 2
0
t_stat space (int32 count, int32 sflag)
{
int32 i;

if ((lpt_unit.flags & UNIT_ATT) == 0)
    return SCPE_UNATT;
cctptr = (cctptr + count) % cctlnt;                     /* adv cct, mod lnt */
if (sflag && CHP (0, cct[cctptr]))                      /* skip, top of form? */
    fputs ("\n\f", lpt_unit.fileref);                   /* nl, ff */
else {
    for (i = 0; i < count; i++)
        fputc ('\n', lpt_unit.fileref);
    }
lpt_unit.pos = ftell (lpt_unit.fileref);                /* update position */
ind[IN_CC9] = CHP (9, cct[cctptr]) != 0;                /* set indicators */
ind[IN_CC12] = CHP (12, cct[cctptr]) != 0;
return SCPE_OK;
}
Esempio n. 3
0
t_stat lpt_crctl (UNIT *uptr, int32 ch)
{
int32 i, j;

if ((ch == 1) && CHP (ch, lpt_cct[0])) {                /* top of form? */
    fputs ("\f\n", uptr->fileref);                      /* ff + nl */
    lpt_ccp = 0;                                        /* top of page */
    return SCPE_OK;
    }
for (i = 1; i < lpt_ccl + 1; i++) {                     /* sweep thru cct */
    lpt_ccp = (lpt_ccp + 1) % lpt_ccl;                  /* adv pointer */
    if (CHP (ch, lpt_cct[lpt_ccp])) {                   /* chan punched? */
        for (j = 0; j < i; j++)
            fputc ('\n', uptr->fileref);
        return SCPE_OK;
        }
    }
return STOP_CCT;                                        /* runaway channel */
}
Esempio n. 4
0
uint32 lp_skip (UNIT *uptr, uint32 ch)
{
uint32 i;

for (i = 1; i < (lp_cctl + 1); i++) {                   /* sweep thru CCT */
    if (CHP (ch, lp_cct[(lp_cctp + i) % lp_cctl]))      /* channel punched? */
        return lp_space (uptr, i, TRUE);                /* space to chan */
    }
lp_run = LPDV_RUN;                                      /* runaway CCT */
return lp_space (uptr, lp_cctl, TRUE);                  /* space max */
}
Esempio n. 5
0
t_stat lpt_space (int32 count, int32 sflag)
{
int32 i;

cct_ptr = (cct_ptr + count) % cct_lnt;                  /* adv cct, mod lnt */
if (sflag && CHP (0, cct[cct_ptr]))                     /* skip, top of form? */
    fputs ("\n\f", lpt_unit.fileref);                   /* nl, ff */
else {
    for (i = 0; i < count; i++)                         /* count lines */
        fputc ('\n', lpt_unit.fileref);
    }
lpt_unit.pos = ftell (lpt_unit.fileref);                /* update position */
ind[IN_PRCH9] = CHP (9, cct[cct_ptr]) != 0;             /* set indicators */
ind[IN_PRCH12] = CHP (12, cct[cct_ptr]) != 0;
if (ferror (lpt_unit.fileref)) {                        /* error? */
    ind[IN_PRCHK] = ind[IN_WRCHK] = 1;                  /* wr, pri check */
    sim_perror ("LPT I/O error");
    clearerr (lpt_unit.fileref);
    return SCPE_IOERR;
    }
return SCPE_OK;
}
Esempio n. 6
0
/*
 * Returns only if there is an I/O error while communicating with the server
 */
static void di_mux(void)
{
   struct intercept_s   *ip = &dgram_intercept_state ;
   fd_set                     socket_mask ;
   int                        mask_max ;

   FD_ZERO( &socket_mask ) ;
   FD_SET( INT_REMOTE( ip ), &socket_mask ) ;
   mask_max = INT_REMOTE( ip ) ;

   for ( ;; )
   {
      unsigned u ;
      channel_s *chp ;
      fd_set read_mask ;
      int n_ready ;

      read_mask = socket_mask ;
      n_ready = int_select( mask_max+1, &read_mask ) ;

      if ( n_ready == -1 )
         return ;
      
      if ( FD_ISSET( INT_REMOTE( ip ), &read_mask ) )
      {
         udp_remote_to_local( ip, &chp ) ;
         if ( chp != NULL )
         {
            FD_SET( chp->ch_local_socket, &socket_mask ) ;
            if ( chp->ch_local_socket > mask_max )
               mask_max = chp->ch_local_socket ;
         }
         if ( --n_ready == 0 )
            continue ;
      }

      for ( u = 0 ; u < pset_count( INT_CONNECTIONS( ip ) ) ; u++ )
      {
         chp = CHP( pset_pointer( INT_CONNECTIONS( ip ), u ) ) ;

         if ( FD_ISSET( chp->ch_local_socket, &read_mask ) )
         {
            if ( udp_local_to_remote( chp ) == FAILED )
               return ;
            if ( --n_ready == 0 )
               break ;
         }
      }
   }
}
Esempio n. 7
0
t_stat lpt_print (void)
{
int32 i, chan, ctrl = lpt_savctrl;

if ((lpt_unit.flags & UNIT_ATT) == 0) {                 /* not attached? */
    ind[IN_PRCHK] = ind[IN_WRCHK] = 1;                  /* wr, pri check */
    return SCPE_UNATT;
    }

ind[IN_PRBSY] = 1;                                      /* print busy */
sim_activate (&lpt_unit, lpt_unit.wait);                /* start timer */

for (i = LPT_WIDTH; i <= LPT_BSIZE; i++)                /* clear unprintable */
    lpt_buf[i] = ' ';
while ((lpt_bptr > 0) && (lpt_buf[lpt_bptr - 1] == ' '))
    lpt_buf[--lpt_bptr] = 0;                            /* trim buffer */
if (lpt_bptr) {                                         /* any line? */
    fputs (lpt_buf, lpt_unit.fileref);                  /* print */
    lpt_unit.pos = ftell (lpt_unit.fileref);            /* update pos */
    lpt_buf_init ();                                    /* reinit buf */
    if (ferror (lpt_unit.fileref)) {                    /* error? */
        ind[IN_PRCHK] = ind[IN_WRCHK] = 1;              /* wr, pri check */
        sim_perror ("LPT I/O error");
        clearerr (lpt_unit.fileref);
        return SCPE_IOERR;
        }
    }

lpt_savctrl = 0x61;                                     /* reset ctrl */
if ((ctrl & K_LIN) == ((ctrl & K_IMM)? 0: K_LIN))       /* space lines? */
    return lpt_space (ctrl & K_LCNT, FALSE);
chan = lpt_savctrl & K_CHAN;                            /* basic chan */
if ((lpt_savctrl & K_CH10) == 0) {                      /* chan 10-12? */
    if (chan == 0)
        chan = 10;
    else if (chan == 3)
        chan = 11;
    else if (chan == 4)
        chan = 12;
    else chan = 0;
    }
if ((chan == 0) || (chan > 12))
    return STOP_INVFNC;
for (i = 1; i < cct_lnt + 1; i++) {                     /* sweep thru cct */
    if (CHP (chan, cct[(cct_ptr + i) % cct_lnt]))
        return lpt_space (i, TRUE);
    }
return STOP_CCT;                                        /* runaway channel */
}
Esempio n. 8
0
uint32 lp_space (UNIT *uptr, uint32 cnt, t_bool skp)
{
uint32 i;

lp_cctp = (lp_cctp + cnt) % lp_cctl;                    /* adv cct, mod lnt */
if (skp && CHP (CH_TOF, lp_cct[lp_cctp]))               /* skip, TOF? */
        fputs ("\f", uptr->fileref);                    /* ff */
    else {                                              /* space */
        for (i = 0; i < cnt; i++)
            fputc ('\n', uptr->fileref);
        }
uptr->pos = ftell (uptr->fileref);                      /* update position */
if (ferror (uptr->fileref)) {                           /* error? */
    sim_perror ("Line printer I/O error");
    clearerr (uptr->fileref);
    chan_set_chf (lp_dib.dva, CHF_XMDE);
    return SCPE_IOERR;
    }
return 0;
}
Esempio n. 9
0
uint32 lp_fmt (UNIT *uptr)
{
uint32 c, i;
uint32 st;

st = chan_RdMemB (lp_dib.dva, &c);                      /* get char */
if (CHS_IFERR (st))                                     /* channel error? */
    return st;                                          /* caller handles */
if (lp_pass)                                            /* only on pass 1 */
    return 0;
if ((c & 0x7F) == FMT_INH)                              /* inhibit? */
    lp_inh = 1;
else if ((c & ~(((lp_model == LP_7450)? 0x20: 0) | SPC_MASK)) == FMT_SPC) {
    c = c & SPC_MASK;                                   /* space? */
    for (i = 1; i <= c; i++) {                          /* look for BOF */
        if (CHP (CH_BOF, lp_cct[(lp_cctp + i) % lp_cctl]))
            return lp_skip (uptr, CH_TOF);              /* found, TOF */
        }        
    return lp_space (uptr, c, FALSE);                   /* space */
    }
else if ((c & ~CCH_MASK) == FMT_SKP)                    /* skip? */
    return lp_skip (uptr, c & CCH_MASK);                /* skip to chan */
return 0;
}
Esempio n. 10
0
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;
}