void txdb_func (int32 data) { int32 sel = TXDB_GETSEL (data); /* get selection */ if (sel == TXDB_MISC) { /* misc function? */ switch (data & MISC_MASK) { /* case on function */ case MISC_SWDN: ABORT (STOP_SWDN); break; case MISC_BOOT: con_halt (0, 0); /* set up reboot */ break; case MISC_LEDS0: case MISC_LEDS1: case MISC_LEDS2: case MISC_LEDS3: case MISC_LEDS4: case MISC_LEDS5: case MISC_LEDS6: case MISC_LEDS7: tto_leds = 0x7 & (~((data & MISC_MASK)-MISC_LEDS0)); sim_putchar ('.'); sim_putchar ('0' + tto_leds); sim_putchar ('.'); break; } } else if (sel != 0) RSVD_OPND_FAULT; }
void tto_echo (int32 c) { uint32 cnt; cnt = 1; if (c == '\r') tto_pos = 0; else if (c == '\n') { tto_pos = 0; sim_putchar ('\r'); tt_unit[TTO].pos = tt_unit[TTO].pos + 1; } else if (c == '\t') { c = ' '; cnt = 8 - (tto_pos % 8); } else c = sim_tt_outcvt (c, TT_GET_MODE (tt_unit[TTO].flags)); if (c >= 0) { while (cnt-- > 0) { sim_putchar (c); tto_pos++; tt_unit[TTO].pos = tt_unit[TTO].pos + 1; } } return; }
t_stat cdr_read_cons (char *buf, int32 sz) { int32 i, t; inq_puts ("[Enter card]\r\n"); for (i = 0; i < sz; ) { while (((t = sim_poll_kbd ()) == SCPE_OK) || /* wait for char */ (t & SCPE_BREAK)) { if (stop_cpu) /* stop? */ return t; } if (t < SCPE_KFLAG) /* error? */ return t; t = t & 0177; if ((t == '\r') || (t == '\n')) /* eol? */ break; if (t == 0177) { /* rubout? */ if (i != 0) { /* anything? */ buf[--i] = 0; sim_putchar ('\\'); } } else { sim_putchar (t); buf[i++] = t; } } inq_puts ("\r\n"); return SCPE_OK; }
t_stat inq_io (int32 flag, int32 mod) { int32 i, t, wm_seen = 0; 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 */ puts_tty ("[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) return SCPE_STOP; } /* interrupt? */ if (t < SCPE_KFLAG) return t; /* if not char, err */ t = t & 0177; if ((t == '\r') || (t == '\n')) break; if (t == inq_char) { /* cancel? */ ind[IN_INC] = 1; /* set indicator */ puts_tty ("\r\n[Canceled]\r\n"); return SCPE_OK; } if (i && ((i % INQ_WIDTH) == 0)) puts_tty ("\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 | ascii_to_bcd[t]; wm_seen = 0; } } else M[BS] = (M[BS] & WM) | ascii_to_bcd[t]; if (!wm_seen) BS++; if (ADDR_ERR (BS)) { BS = BA | (BS % MAXMEMSIZE); return STOP_NXM; } } puts_tty ("\r\n"); M[BS++] = BCD_GRPMRK + WM; return SCPE_OK; 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)) puts_tty ("\r\n"); sim_putchar ('~'); } if (i && ((i % INQ_WIDTH) == 0)) puts_tty ("\r\n"); sim_putchar (bcd_to_ascii[t & CHAR]); if (ADDR_ERR (BS)) { BS = BA | (BS % MAXMEMSIZE); return STOP_NXM; } } puts_tty ("\r\n"); return SCPE_OK; default: return STOP_INVM; } /* invalid mod */ }
t_stat tto_svc (UNIT *uptr) { int32 c; t_stat r; if (tty_buf == FIODEC_UC) /* upper case? */ tty_uc = UC; else if (tty_buf == FIODEC_LC) /* lower case? */ tty_uc = 0; else { c = fiodec_to_ascii[tty_buf | tty_uc]; /* translate */ if (c && ((r = sim_putchar_s (c)) != SCPE_OK)) { /* output; error? */ sim_activate (uptr, uptr->wait); /* retry */ return ((r == SCPE_STALL)? SCPE_OK: r); } } if (cpls & CPLS_TTO) { /* completion pulse? */ ios = 1; /* restart */ cpls = cpls & ~CPLS_TTO; } iosta = iosta | IOS_TTO; /* set flag */ dev_req_int (tto_sbs); /* req interrupt */ uptr->pos = uptr->pos + 1; if (c == '\r') { /* cr? add lf */ sim_putchar ('\n'); uptr->pos = uptr->pos + 1; } return SCPE_OK; }
t_stat ttpi_svc (UNIT *uptr) { int32 c, out; sim_activate (uptr, KBD_WAIT (uptr->wait, lfc_poll)); /* continue poll */ ttp_sta = ttp_sta & ~STA_FR; /* clear break */ if ((c = sim_poll_kbd ()) < SCPE_KFLAG) /* no char or error? */ return c; ttp_sta = ttp_sta & ~STA_PF; /* clear parity err */ if (ttp_kchp) /* overrun? */ ttp_sta = ttp_sta | STA_OVR; if (ttp_karm) SET_INT (v_TTP); if (c & SCPE_BREAK) { /* break? */ ttp_sta = ttp_sta | STA_FR; /* framing error */ uptr->buf = 0; /* no character */ } else { out = c & 0x7F; /* echo is 7b */ c = sim_tt_inpcvt (c, TT_GET_MODE (uptr->flags)); if (TT_GET_MODE (uptr->flags) != TT_MODE_8B) /* not 8b mode? */ c = pas_par (ttp_cmd, c); /* apply parity */ uptr->buf = c; /* save char */ uptr->pos = uptr->pos + 1; /* incr count */ ttp_kchp = 1; /* char pending */ if (ttp_cmd & CMD_ECHO) { out = sim_tt_outcvt (out, TT_GET_MODE (uptr->flags)); if (c >= 0) sim_putchar (out); ttp_unit[TTO].pos = ttp_unit[TTO].pos + 1; } } return SCPE_OK; }
void inq_puts (char *cptr) { if (cptr == NULL) return; while (*cptr != 0) sim_putchar (*cptr++); return; }
void tto_puts (const char *cptr) { int32 c; while ((c = *cptr++) != 0) sim_putchar (c); return; }
t_stat lpt_end_line (UNIT *uptr) { uint32 i, col, row, bufw, colbin; const char *pch; char bcd, lpt_cbuf[LPT_CHRLNT + 1]; t_uint64 dat; pch = pch_table[GET_PCHAIN (lpt_unit.flags)]; /* get print chain */ for (col = 0; col < (LPT_CHRLNT + 1); col++) /* clear ascii buf */ lpt_cbuf[col] = ' '; for (col = 0; col < 72; col++) { /* proc 72 columns */ colbin = 0; dat = bit_masks[35 - (col % 36)]; /* mask for column */ for (row = 0; row < 12; row++) { /* proc 12 rows */ bufw = (row * 2) + (col / 36); /* index to buffer */ if (lpt_bbuf[bufw] & dat) colbin |= col_masks[row]; } bcd = colbin_to_bcd (colbin); /* column bin -> BCD */ lpt_cbuf[col] = pch[bcd]; /* -> ASCII */ } for (i = LPT_CHRLNT; (i > 0) && (lpt_cbuf[i - 1] == ' '); --i) ; /* trim spaces */ lpt_cbuf[i] = 0; /* append nul */ if (uptr->flags & UNIT_ATT) { /* file? */ fputs (lpt_cbuf, uptr->fileref); /* write line */ fputc ('\n', uptr->fileref); /* append nl */ uptr->pos = ftell (uptr->fileref); /* update position */ if (ferror (uptr->fileref)) { /* error? */ sim_perror ("LPT I/O error"); clearerr (uptr->fileref); return SCPE_IOERR; } } else if (uptr->flags & UNIT_CONS) { /* print to console? */ for (i = 0; lpt_cbuf[i] != 0; i++) sim_putchar (lpt_cbuf[i]); sim_putchar ('\r'); sim_putchar ('\n'); } else return SCPE_UNATT; /* otherwise error */ lpt_sta = LPS_END; /* end line state */ sim_cancel (uptr); /* cancel current */ sim_activate (uptr, lpt_tstop); /* long timer */ return SCPE_OK; }
t_stat tto_svc (UNIT *uptr) { int32 temp; tto_csr = tto_csr | CSR_DONE; if (tto_csr & CSR_IE) int_req = int_req | INT_TTO; if ((temp = sim_putchar (tto_unit.buf & 0177)) != SCPE_OK) return temp; tto_unit.pos = tto_unit.pos + 1; return SCPE_OK; }
/* channel B data */ int32 i8274Bd(int32 io, int32 data) { if (io == 0) { /* read data port */ i8274_unit.u3 &= 0xFD; return (i8274_unit.buf); } else { /* write data port */ sim_putchar(data); } return 0; }
int32 putseq(char *seq) { int i, len, temp; len = strlen(seq); for (i = 0; i < len; i++) { if ((temp = sim_putchar(seq[i])) != SCPE_OK) return temp; tto_unit.pos += 1; } return SCPE_OK; }
t_stat tti_svc (UNIT *uptr) { int32 temp; sim_activate (&tti_unit, tti_unit.wait); /* continue poll */ if ((temp = sim_poll_kbd ()) < SCPE_KFLAG) /* no char or error? */ return temp; if (temp & SCPE_BREAK) /* ignore break */ return SCPE_OK; temp = temp & 0177; tti_unit.pos = tti_unit.pos + 1; if (ascii_to_sds[temp] >= 0) { tti_unit.buf = ascii_to_sds[temp]; /* internal rep */ sim_putchar (temp); /* echo */ if (temp == '\r') /* lf after cr */ sim_putchar ('\n'); xfr_req = xfr_req | XFR_TTI; /* set xfr flag */ } else sim_putchar (007); /* ding! */ return SCPE_OK; }
uint8 i8251d(t_bool io, uint8 data) { uint8 devnum; if ((devnum = i8272_get_dn()) != 0xFF) { if (io == 0) { /* read data port */ i8272_unit[devnum].u3 &= ~RXR; return (i8272_unit[devnum].buf); } else { /* write data port */ sim_putchar(data); } } return 0; }
t_stat tti_svc (UNIT *uptr) { int32 in, temp; sim_activate (uptr, uptr->wait); /* continue poll */ if (tti_hold & CW) { /* char waiting? */ tty_buf = tti_hold & TT_WIDTH; /* return char */ tti_hold = 0; /* not waiting */ } else { if ((temp = sim_poll_kbd ()) < SCPE_KFLAG) return temp; if (temp & SCPE_BREAK) /* ignore break */ return SCPE_OK; temp = temp & 0177; if (temp == 0177) /* rubout? bs */ temp = '\b'; sim_putchar (temp); /* echo */ if (temp == '\r') /* cr? add nl */ sim_putchar ('\n'); in = ascii_to_fiodec[temp]; /* translate char */ if (in == 0) /* no xlation? */ return SCPE_OK; if ((in & BOTH) || ((in & UC) == (tty_uc & UC))) tty_buf = in & TT_WIDTH; else { /* must shift */ tty_uc = in & UC; /* new case */ tty_buf = tty_uc? FIODEC_UC: FIODEC_LC; tti_hold = in | CW; /* set 2nd waiting */ } } iosta = iosta | IOS_TTI; /* set flag */ dev_req_int (tti_sbs); /* req interrupt */ PF = PF | PF_SS_1; /* set prog flag 1 */ uptr->pos = uptr->pos + 1; return SCPE_OK; }
t_stat tto_svc (UNIT *uptr) { int32 c, temp; dev_busy = dev_busy & ~INT_TTO; /* clear busy */ dev_done = dev_done | INT_TTO; /* set done */ int_req = (int_req & ~INT_DEV) | (dev_done & ~dev_disable); c = tto_unit.buf & 0177; /* --- BEGIN MODIFIED CODE --- */ if (tto_unit.flags & UNIT_DASHER) { if ((temp = translate_out(c)) != SCPE_OK) return temp; } else { if ((temp = sim_putchar (c)) != SCPE_OK) return temp; tto_unit.pos = tto_unit.pos + 1; } /* --- END MODIFIED CODE --- */ return SCPE_OK; }
t_stat tto_svc (UNIT *uptr) { int32 asc; t_stat r; if (uptr->buf == TT_CR) /* control chars? */ asc = '\r'; else if (uptr->buf == TT_BS) asc = '\b'; else if (uptr->buf == TT_TB) asc = '\t'; else asc = sds_to_ascii[uptr->buf]; /* translate */ if ((r = sim_putchar_s (asc)) != SCPE_OK) { /* output; error? */ sim_activate (uptr, uptr->wait); /* retry */ return ((r == SCPE_STALL)? SCPE_OK: r); /* !stall? report */ } uptr->pos = uptr->pos + 1; /* inc position */ chan_set_ordy (tto_dib.chan); /* tto rdy */ if (asc == '\r') { /* CR? */ sim_putchar ('\n'); /* add lf */ uptr->pos = uptr->pos + 1; /* inc position */ } return SCPE_OK; }
int32 sio0d(int32 io, int32 data) { UNIT *uptr; if (io == 0) { // data register read if (ptr_flag) { // RDR enabled? if ((ptr_unit.flags & UNIT_ATT) == 0) // attached? return 0; // no, done // printf("ptr_unit.u3=%02X\n", ptr_unit.u3); if ((ptr_unit.u3 & 0x01) == 0) { // yes, more data? // printf("Returning old %02X\n", odata); // no, return previous byte return (odata & 0xFF); } uptr = ptr_dev.units; // get data byte if ((odata = getc(uptr -> fileref)) == EOF) { // end of file? // printf("Got EOF\n"); ptr_unit.u3 &= 0xFE; // clear RXF flag return (odata = 0); // no data } // printf("Returning new %02X\n", odata); ptr_unit.pos++; // step character count ptr_unit.u3 &= 0xFE; // clear RXF flag return (odata & 0xFF); // return character } else { sio_unit.u3 &= 0xFE; // clear RXF flag return (odata = sio_unit.buf); // return next char } } else { // data register write if (isprint(data) || data == '\r' || data == '\n') { // printable? sim_putchar(data); // print character on console if (ptp_flag && ptp_unit.flags & UNIT_ATT) { // PTP enabled & attached? uptr = ptp_dev.units; // punch character to file putc(data, uptr -> fileref); ptp_unit.pos++; // step character counter } } else { // DC1-DC4 control Reader/Punch switch (data) { case 0x11: // RDR on ptr_flag = 1; ptr_flg1 = 0; ptr_unit.u3 |= 0x01; // printf("Reader on\r\n"); break; case 0x12: // PTP on ptp_flag = 1; ptp_unit.u3 |= 0x02; // printf("Punch on\r\n"); break; case 0x13: // RDR off ptr_flag = 0; // printf("Reader off-%d bytes read\r\n", ptr_unit.pos); break; case 0x14: // PTP off ptp_flag = 0; // printf("Punch off-%d bytes written\r\n", ptp_unit.pos); break; default: // ignore all other characters break; } } } return (odata = 0); }
int32 translate_out(int32 c) { int32 temp; char outstr[32]; if (spec200 == 1) { /* Special terminal control seq */ spec200 = 0; switch (c) { case 'C': /* read model ID */ return SCPE_OK; case 'E': /* Reverse video off */ return SCPE_OK; case 'D': /* Reverse video on */ return SCPE_OK; default: return SCPE_OK; } } if (curpos == 1) { /* 2nd char of cursor position */ col = c & 0x7f; curpos++; return (SCPE_OK); } if (curpos == 2) { /* 3rd char of cursor position */ row = c & 0x7f; curpos = 0; sprintf(outstr, "\033[%d;%dH", row+1, col+1); if ((temp = putseq(outstr)) != SCPE_OK) return temp; return (SCPE_OK); } switch (c) { /* Single-char command or data */ case 003: /* Blink enable */ break; case 004: /* Blink disable */ break; case 005: /* Read cursor address */ break; case 010: /* Cursor home */ sprintf(outstr, "\033[1;1H"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; row = col = 0; return (SCPE_OK); case 012: /* Newline */ if ((temp = sim_putchar('\r')) != SCPE_OK) return temp; tto_unit.pos += 1; if ((temp = sim_putchar(c)) != SCPE_OK) return temp; tto_unit.pos += 1; col = 1; row++; if (row > 24) row = 1; return (SCPE_OK); case 013: /* Erase EOL */ sprintf(outstr, "\033[K"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; return (SCPE_OK); case 014: /* Erase screen */ sprintf(outstr, "\033[1;1H\033[2J"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; row = col = 0; return (SCPE_OK); case 015: /* CR */ if ((temp = sim_putchar(c)) != SCPE_OK) return temp; tto_unit.pos += 1; col = 1; return (SCPE_OK); case 016: /* Blink On */ sprintf(outstr, "\033[5m"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; return (SCPE_OK); case 017: /* Blink off */ sprintf(outstr, "\033[25m"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; return (SCPE_OK); case 020: /* Write cursor address */ curpos = 1; return SCPE_OK; case 024: /* underscore on */ sprintf(outstr, "\033[4m"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; return (SCPE_OK); case 025: /* underscore off */ sprintf(outstr, "\033[24m"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; return (SCPE_OK); break; case 027: /* cursor up */ sprintf(outstr, "\033[A"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; row--; if (row < 1) row = 24; return (SCPE_OK); case 030: /* cursor right */ sprintf(outstr, "\033[C"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; col++; if (col > 80) { col = 1; row++; if (row > 24) row = 1; } return (SCPE_OK); case 031: /* Cursor left */ sprintf(outstr, "\033[D"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; tto_unit.pos += 1; col--; if (col < 1) { col = 80; row--; if (row < 1) row = 24; } return (SCPE_OK); case 032: /* Cursor down */ sprintf(outstr, "\033[B"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; row++; if (row > 24) row = 1; return (SCPE_OK); case 034: /* Dim on */ sprintf(outstr, "\033[22m"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; return (SCPE_OK); case 035: /* Dim off */ sprintf(outstr, "\033[1m"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; return (SCPE_OK); case 036: /* Special sequence */ spec200 = 1; return SCPE_OK; default: /* ..A character of data */ if ((temp = sim_putchar(c)) != SCPE_OK) return temp; tto_unit.pos += 1; col++; if (col > 80) { col = 1; row++; if (row > 24) row = 24; } return (SCPE_OK); } return SCPE_OK; }
t_stat tto_svc (UNIT *uptr) { int32 c = uptr->buf; #ifdef CYR_CTLN_CTLO c &= 0177; if (c == ('N' & 037)) { tto_charconv = 1; c = -1; } else if (c == ('O' & 037)) { tto_charconv = 0; c = -1; } else if (tto_charconv && c >= '@') { #ifdef _WIN32 static uint8 tab[0100] = { #if 0 /* Codepage 1251 */ 0376, 0340, 0341, 0366, 0344, 0345, 0364, 0343, /* @ABCDEFG */ 0365, 0350, 0351, 0352, 0353, 0354, 0355, 0356, /* HIJKLMNO */ 0357, 0377, 0360, 0361, 0362, 0363, 0346, 0342, /* PQRSTUVW */ 0374, 0373, 0347, 0370, 0375, 0371, 0367, 0372, /* XYZ[\]^_ */ 0336, 0300, 0301, 0326, 0304, 0305, 0324, 0303, /* `abcdefg */ 0325, 0310, 0311, 0312, 0313, 0314, 0315, 0316, /* hijklmno */ 0317, 0337, 0320, 0321, 0322, 0323, 0306, 0302, /* pqrstuvw */ 0334, 0333, 0307, 0330, 0335, 0331, 0327, 0332, /* xyz{|}~ */ #else /* Codepage 866 */ 0356, 0240, 0241, 0346, 0244, 0245, 0344, 0243, /* @ABCDEFG */ 0345, 0250, 0251, 0252, 0253, 0254, 0255, 0256, /* HIJKLMNO */ 0257, 0357, 0340, 0341, 0342, 0343, 0246, 0242, /* PQRSTUVW */ 0354, 0353, 0247, 0350, 0355, 0351, 0347, 0352, /* XYZ[\]^_ */ 0236, 0200, 0201, 0226, 0204, 0205, 0224, 0203, /* `abcdefg */ 0225, 0210, 0211, 0212, 0213, 0214, 0215, 0216, /* hijklmno */ 0217, 0237, 0220, 0221, 0222, 0223, 0206, 0202, /* pqrstuvw */ 0234, 0233, 0207, 0230, 0235, 0231, 0227, 0232, /* xyz{|}~ */ #endif }; c = tab [c - '@']; #else /* _WIN32 */ /* UTF-8 */ static const char *tab[0100] = { "ю", "а", "б", "ц", "д", "е", "ф", "г", /* @ABCDEFG */ "х", "и", "й", "к", "л", "м", "н", "о", /* HIJKLMNO */ "п", "я", "р", "с", "т", "у", "ж", "в", /* PQRSTUVW */ "ь", "ы", "з", "ш", "э", "щ", "ч", "ъ", /* XYZ[\]^_ */ "Ю", "А", "Б", "Ц", "Д", "Е", "Ф", "Г", /* `abcdefg */ "Х", "И", "Й", "К", "Л", "М", "Н", "О", /* hijklmno */ "П", "Я", "Р", "С", "Т", "У", "Ж", "В", /* pqrstuvw */ "Ь", "Ы", "З", "Ш", "Э", "Щ", "Ч", "Ъ", /* xyz{|}~ */ }; const char *str = tab[c-'@']; t_stat r = sim_putchar_s (str[0]); if (r != SCPE_OK) { /* output; error? */ sim_activate (uptr, uptr->wait); /* try again */ return ((r == SCPE_STALL)? SCPE_OK: r); /* !stall? report */ } for (c=1; str[c]; c++) sim_putchar (str[c]); c = -1; #endif /* _WIN32 */ } #else /* CYR_CTLN_CTLO */ c = sim_tt_outcvt (c, TT_GET_MODE (uptr->flags)); #endif /* CYR_CTLN_CTLO */ if (c >= 0) { t_stat r = sim_putchar_s (c); if (r != SCPE_OK) { /* output; error? */ sim_activate (uptr, uptr->wait); /* try again */ return ((r == SCPE_STALL)? SCPE_OK: r); /* !stall? report */ } } tto_csr = tto_csr | CSR_DONE; if (tto_csr & CSR_IE) SET_INT (TTO); uptr->pos = uptr->pos + 1; return SCPE_OK; }
int32 pkb (int32 op, int32 m, int32 n, int32 data) { int32 iodata= 0, ec, ac; switch (op) { case 0: /* SIO 5471 */ if (n != 0) return STOP_INVDEV; /*printf("%04X SIO %d,%d,%02X\n\r", IAR[level]-4, m, n, data);*/ if (m == 0) { /* Keyboard */ pkb_unit.u3 &= 0xFC1; pkb_unit.u3 |= data; if (data & 0x01) { pkb_unit.u3 &= ~KBD_INTREQ; pkb_unit.u3 &= ~KBD_INTKEY; pkb_unit.u3 &= ~KBD_INTEND; return RESET_INTERRUPT; } } else { /* Printer */ if (data & 0x80) { /* start print bit */ if (debug_reg & 0x80) return STOP_IBKPT; ec = pkb_unit.u4 & 0xff; ac = ebcdic_to_ascii[ec]; sim_putchar(ac); pkb_unit.u3 |= PRT_INTREQ; } if (data & 0x40) { /* Carr. Return */ sim_putchar('\n'); sim_putchar('\r'); pkb_unit.u3 |= PRT_INTREQ; } pkb_unit.u3 &= 0xFFe; if (data & 0x04) /* Print interrupt flag */ pkb_unit.u3 |= PRT_PRTINT; if (data & 0x01) { /* Reset Interrupt */ if (level < 8) { if (!(data & 0x80)) pkb_unit.u3 &= ~PRT_INTREQ; return RESET_INTERRUPT; } } } return SCPE_OK; case 1: /* LIO 5471 */ if (n != 0) return STOP_INVDEV; if (m != 1) return STOP_INVDEV; pkb_unit.u4 = (data >> 8) & 0xff; return SCPE_OK; break; case 2: /* TIO 5471 */ return STOP_INVDEV; case 3: /* SNS 5471 */ if (n != 1 && n != 3) return (STOP_INVDEV << 16); if (m == 0) { /* Keyboard data */ if (n == 1) { /* Sense bytes 0 & 1 */ iodata = (pkb_unit.buf << 8) & 0xff00; if (pkb_unit.u3 & KBD_INTREQ) iodata |= 0x80; if (pkb_unit.u3 & KBD_INTEND) iodata |= 0x40; if (pkb_unit.u3 & KBD_INTKEY) iodata |= 0x08; if (pkb_unit.buf == 0x12) /* Return key */ iodata |= 0x04; if (pkb_unit.buf == 0x03) /* Cancel key */ iodata |= 0x20; if (pkb_unit.buf == 0x0d) /* End key */ iodata |= 0x10; iodata |= ((SCPE_OK << 16) & 0xffff0000); } else { /* Sense bytes 2 & 3 */ iodata = 0; /* Manual says CE use only */ } } else { /* Printer Data */ if (n == 1) { /* Sense bytes 0 & 1 */ iodata = 0; if (pkb_unit.u3 & PRT_INTREQ) iodata |= 0x80; } else { iodata = 0; /* CE use only */ } } iodata |= ((SCPE_OK << 16) & 0xffff0000); return (iodata); case 4: /* APL 5471 */ return STOP_INVDEV; default: break; } printf (">>PKB non-existent function %d\n", op); return SCPE_OK; }