I1620: Input processing cleanup - backspace, tabs, WRU
- Fixed keyboard interrupt problem for Linux - Added input backspace for Model II - Revised tab calculation algorithm
This commit is contained in:
parent
ec9c746ca7
commit
d72ab3ce51
1 changed files with 64 additions and 29 deletions
|
@ -25,6 +25,9 @@
|
||||||
|
|
||||||
tty console typewriter
|
tty console typewriter
|
||||||
|
|
||||||
|
18-May-17 RMS Fixed keyboard interrupt problem for Linux
|
||||||
|
Added input backspace for Model II
|
||||||
|
04-May-17 DW Revised tab calculation algorithm
|
||||||
13-Mar-17 RMS Fixed tab stop array overrun at right margin (COVERITY)
|
13-Mar-17 RMS Fixed tab stop array overrun at right margin (COVERITY)
|
||||||
21-Feb-15 TFM Option to provide single digit numeric output
|
21-Feb-15 TFM Option to provide single digit numeric output
|
||||||
05-Feb-15 TFM Changes to translate tables and valid input char.
|
05-Feb-15 TFM Changes to translate tables and valid input char.
|
||||||
|
@ -36,14 +39,16 @@
|
||||||
|
|
||||||
#include "i1620_defs.h"
|
#include "i1620_defs.h"
|
||||||
|
|
||||||
#define NUM_1_DIGIT TRUE /* Indicate numeric output will use single digit format (tfm) */
|
#define NUM_1_DIGIT TRUE /* indicate numeric output will use single digit format (tfm) */
|
||||||
|
|
||||||
|
/* Maximum number of characters per line, or one-based column number of last char cell */
|
||||||
|
|
||||||
#define TTO_COLMAX 80
|
#define TTO_COLMAX 80
|
||||||
#define UF_V_1DIG (UNIT_V_UF)
|
#define UF_V_1DIG (UNIT_V_UF)
|
||||||
#define UF_1DIG (1 << UF_V_1DIG)
|
#define UF_1DIG (1 << UF_V_1DIG)
|
||||||
|
|
||||||
int32 tto_col = 0;
|
int32 tto_col = 1; /* One-based, char cell we will print to next */
|
||||||
uint8 tto_tabs[TTO_COLMAX + 1] = {
|
uint8 tto_tabs[TTO_COLMAX + 1] = { /* Zero-based access, one-based UI */
|
||||||
0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,
|
||||||
1,0,0,0,0,0,0,0,
|
1,0,0,0,0,0,0,0,
|
||||||
1,0,0,0,0,0,0,0,
|
1,0,0,0,0,0,0,0,
|
||||||
|
@ -61,6 +66,7 @@ extern uint8 M[MAXMEMSIZE];
|
||||||
extern uint8 ind[NUM_IND];
|
extern uint8 ind[NUM_IND];
|
||||||
extern UNIT cpu_unit;
|
extern UNIT cpu_unit;
|
||||||
extern uint32 io_stop;
|
extern uint32 io_stop;
|
||||||
|
extern volatile int32 stop_cpu;
|
||||||
|
|
||||||
void tti_unlock (void);
|
void tti_unlock (void);
|
||||||
t_stat tti_rnum (int8 *c);
|
t_stat tti_rnum (int8 *c);
|
||||||
|
@ -275,8 +281,13 @@ switch (op) { /* case on op */
|
||||||
return r;
|
return r;
|
||||||
if (ttc == 0x7F) /* end record? */
|
if (ttc == 0x7F) /* end record? */
|
||||||
return SCPE_OK;
|
return SCPE_OK;
|
||||||
M[pa] = ttc & (FLAG | DIGIT); /* store char */
|
if (ttc == 0x7E) { /* backspace? */
|
||||||
PP (pa); /* incr mem addr */
|
MM (pa); /* decr mem addr */
|
||||||
|
}
|
||||||
|
else { /* normal char */
|
||||||
|
M[pa] = ttc & (FLAG | DIGIT); /* store char */
|
||||||
|
PP (pa); /* incr mem addr */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -288,9 +299,14 @@ switch (op) { /* case on op */
|
||||||
return r;
|
return r;
|
||||||
if (ttc == 0x7F) /* end record? */
|
if (ttc == 0x7F) /* end record? */
|
||||||
return SCPE_OK;
|
return SCPE_OK;
|
||||||
M[pa] = (M[pa] & FLAG) | (ttc & DIGIT); /* store 2 digits */
|
if (ttc == 0x7E) { /* backspace? */
|
||||||
M[pa - 1] = (M[pa - 1] & FLAG) | ((ttc >> 4) & DIGIT);
|
pa = ADDR_A (pa, -2); /* decr mem addr*/
|
||||||
pa = ADDR_A (pa, 2); /* incr mem addr */
|
}
|
||||||
|
else { /* normal char */
|
||||||
|
M[pa] = (M[pa] & FLAG) | (ttc & DIGIT); /* store 2 digits */
|
||||||
|
M[pa - 1] = (M[pa - 1] & FLAG) | ((ttc >> 4) & DIGIT);
|
||||||
|
pa = ADDR_A (pa, 2); /* incr mem addr */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -339,6 +355,11 @@ do {
|
||||||
return r;
|
return r;
|
||||||
if (raw == '\r') /* return? mark */
|
if (raw == '\r') /* return? mark */
|
||||||
*c = 0x7F;
|
*c = 0x7F;
|
||||||
|
else if (((raw == '\b') || (raw == 0x7F)) && /* backspace or del? */
|
||||||
|
((cpu_unit.flags & IF_MII) != 0)) { /* on model 2? */
|
||||||
|
*c = 0x7E; /* mark */
|
||||||
|
raw = '-'; /* print minus */
|
||||||
|
}
|
||||||
else if ((raw == '~') || (raw == '`')) /* flag? mark */
|
else if ((raw == '~') || (raw == '`')) /* flag? mark */
|
||||||
flg = FLAG;
|
flg = FLAG;
|
||||||
else if ((cp = strchr (tti_to_num, raw)) != 0) /* legal? */
|
else if ((cp = strchr (tti_to_num, raw)) != 0) /* legal? */
|
||||||
|
@ -363,6 +384,11 @@ do {
|
||||||
return r;
|
return r;
|
||||||
if (raw == '\r') /* return? mark */
|
if (raw == '\r') /* return? mark */
|
||||||
*c = 0x7F;
|
*c = 0x7F;
|
||||||
|
else if (((raw == '\b') || (raw == 0x7F)) && /* backspace or del? */
|
||||||
|
((cpu_unit.flags & IF_MII) != 0)) { /* on model 2? */
|
||||||
|
*c = 0x7E; /* mark */
|
||||||
|
raw = '-'; /* print minus */
|
||||||
|
}
|
||||||
else if (tti_to_alp[raw] >= 0) /* legal char? */
|
else if (tti_to_alp[raw] >= 0) /* legal char? */
|
||||||
*c = tti_to_alp[raw]; /* xlate */
|
*c = tti_to_alp[raw]; /* xlate */
|
||||||
else raw = 007; /* beep! */
|
else raw = 007; /* beep! */
|
||||||
|
@ -378,6 +404,8 @@ t_stat tti_read (int8 *c)
|
||||||
int32 t;
|
int32 t;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
if (stop_cpu != 0) /* stop? */
|
||||||
|
return SCPE_STOP;
|
||||||
t = sim_poll_kbd (); /* get character */
|
t = sim_poll_kbd (); /* get character */
|
||||||
} while ((t == SCPE_OK) || (t & SCPE_BREAK)); /* ignore break */
|
} while ((t == SCPE_OK) || (t & SCPE_BREAK)); /* ignore break */
|
||||||
if (t < SCPE_KFLAG) /* error? */
|
if (t < SCPE_KFLAG) /* error? */
|
||||||
|
@ -413,39 +441,47 @@ for (i = 0; i < MEMSIZE; i++) { /* (stop runaway) */
|
||||||
return STOP_RWRAP;
|
return STOP_RWRAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Wrap line, if needed, prior to character output */
|
||||||
|
|
||||||
|
void tto_wrap(void)
|
||||||
|
{
|
||||||
|
if (tto_col > TTO_COLMAX) { /* line wrap? */
|
||||||
|
sim_putchar('\r');
|
||||||
|
sim_putchar('\n');
|
||||||
|
tto_col = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Write, maintaining position */
|
/* Write, maintaining position */
|
||||||
|
|
||||||
t_stat tto_write (uint32 c)
|
t_stat tto_write (uint32 c)
|
||||||
{
|
{
|
||||||
int32 rpt;
|
|
||||||
|
|
||||||
if (c == '\t') { /* tab? */
|
if (c == '\t') { /* tab? */
|
||||||
for (rpt = tto_col + 1; /* find tab stop */
|
tto_wrap();
|
||||||
(rpt <= TTO_COLMAX) && (tto_tabs[rpt] == 0);
|
do {
|
||||||
rpt++) ;
|
sim_putchar(' '); /* use spaces */
|
||||||
for ( ; tto_col < rpt; tto_col++)
|
tto_col++;
|
||||||
sim_putchar (' '); /* use spaces */
|
} while (!(tto_col > TTO_COLMAX || tto_tabs[tto_col-1] == 1));
|
||||||
}
|
}
|
||||||
else if (c == '\r') { /* return? */
|
else if (c == '\r') { /* return? */
|
||||||
sim_putchar ('\r'); /* crlf */
|
sim_putchar ('\r'); /* crlf */
|
||||||
sim_putchar ('\n');
|
sim_putchar ('\n');
|
||||||
tto_col = 0; /* clear colcnt */
|
tto_col = 1; /* back to LMargin */
|
||||||
return SCPE_OK;
|
|
||||||
}
|
}
|
||||||
else if ((c == '\n') || (c == 007)) { /* non-spacing? */
|
else if ((c == '\n') || (c == 007)) { /* non-spacing? */
|
||||||
sim_putchar (c);
|
sim_putchar (c);
|
||||||
return SCPE_OK;
|
|
||||||
}
|
}
|
||||||
else if (c == '\b') /* backspace? */
|
else if (c == '\b') { /* backspace? */
|
||||||
tto_col = tto_col? tto_col - 1: 0;
|
if (tto_col > 1) {
|
||||||
else tto_col++; /* normal */
|
sim_putchar(c);
|
||||||
if (tto_col > TTO_COLMAX) { /* line wrap? */
|
tto_col--;
|
||||||
sim_putchar ('\r');
|
}
|
||||||
sim_putchar ('\n');
|
}
|
||||||
tto_col = 0;
|
else { /* normal */
|
||||||
|
tto_wrap();
|
||||||
|
sim_putchar(c);
|
||||||
|
tto_col++;
|
||||||
}
|
}
|
||||||
if (c != '\t')
|
|
||||||
sim_putchar (c);
|
|
||||||
return SCPE_OK;
|
return SCPE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,8 +502,7 @@ return SCPE_OK;
|
||||||
t_stat tty_reset (DEVICE *dptr)
|
t_stat tty_reset (DEVICE *dptr)
|
||||||
{
|
{
|
||||||
sim_activate (&tty_unit, tty_unit.wait); /* activate poll */
|
sim_activate (&tty_unit, tty_unit.wait); /* activate poll */
|
||||||
tto_col = 0;
|
tto_col = 1;
|
||||||
tto_tabs[TTO_COLMAX] = 1; /* tab stop at limit */
|
|
||||||
return SCPE_OK;
|
return SCPE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue