t_stat lpt (uint32 op, uint32 pa, uint32 f0, uint32 f1) { int8 lpc; uint8 z, d; t_stat r, sta; sta = SCPE_OK; sim_cancel (&lpt_unit); /* "stall" until */ ind[IN_PRBSY] = 0; /* printer free */ switch (op) { /* decode op */ case OP_K: /* control */ lpt_savctrl = (f0 << 4) | f1; /* form ctrl */ if (lpt_savctrl & K_IMM) /* immediate? */ return lpt_print (); break; case OP_DN: return lpt_num (pa, f1, TRUE); /* dump numeric (tfm: removed len parm ) */ case OP_WN: return lpt_num (pa, f1, FALSE); /* write numeric (tfm: removed len parm ) */ case OP_WA: for ( ; lpt_bptr < LPT_BSIZE; lpt_bptr++) { /* only fill buf */ d = M[pa] & DIGIT; /* get digit */ z = M[pa - 1] & DIGIT; /* get zone */ if ((d & REC_MARK) == REC_MARK) /* 8-2 char? */ break; lpc = alp_to_lpt[(z << 4) | d]; /* translate pair */ if (lpc < 0) { /* bad char? */ ind[IN_WRCHK] = ind[IN_PRCHK] = 1; /* wr chk */ if (io_stop) /* set return status */ sta = STOP_INVCHR; } lpt_buf[lpt_bptr] = lpc & 0x7F; /* fill buffer */ pa = ADDR_A (pa, 2); /* incr mem addr */ } if ((f1 & 1) == 0) { ; /* print now? */ r = lpt_print (); /* print line */ if (r != SCPE_OK) return r; } return sta; default: /* invalid function */ return STOP_INVFNC; } return SCPE_OK; }
t_stat lpt_num (uint32 pa, uint32 f1, t_bool dump) /* tfm: removed len parm and reorganized code */ { uint8 d; int8 lpc; t_stat r, sta; sta = SCPE_OK; for ( ; lpt_bptr < LPT_BSIZE; lpt_bptr++) { /* only fill buf */ d = M[pa]; /* get data char */ if (!dump && /* not dumping? */ ((d & REC_MARK) == REC_MARK)) /* quit on RM or GM */ break; lpc = num_to_lpt[d]; /* translate digit */ if (!dump && /* if not dumping */ ((d & DIGIT) == NUM_BLANK)) /* translate numeric blank */ lpc = ' '; /* to normal space */ if (lpc < 0) { /* bad char? */ ind[IN_WRCHK] = ind[IN_PRCHK] = 1; /* wr chk */ if (io_stop) /* set return status */ sta = STOP_INVCHR; } lpt_buf[lpt_bptr] = lpc & 0x7F; /* put char into buffer (tfm: correct increment)*/ PP (pa); /* incr mem addr */ } if ((f1 & 1) == 0) { /* print now? */ r = lpt_print (); /* print line */ if (r != SCPE_OK) return r; } return sta; }
t_stat lpt_num (uint32 pa, uint32 len, uint32 f1) { uint32 end; uint8 d; int8 lpc; t_stat r, sta; sta = SCPE_OK; end = pa + len; for ( ; lpt_bptr < LPT_BSIZE; lpt_bptr++) { /* only fill buf */ d = M[pa]; /* get digit */ if (len? (pa >= end): /* end reached? */ ((d & REC_MARK) == REC_MARK)) break; lpc = num_to_lpt[d]; /* translate */ if (lpc < 0) { /* bad char? */ ind[IN_WRCHK] = ind[IN_PRCHK] = 1; /* wr chk */ if (io_stop) /* set return status */ sta = STOP_INVCHR; } lpt_buf[lpt_bptr++] = lpc & 0x7F; /* fill buffer */ PP (pa); /* incr mem addr */ } if ((f1 & 1) == 0) { /* print now? */ r = lpt_print (); /* print line */ if (r != SCPE_OK) return r; } return sta; }