[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | vtyper.c -- virtual typewriter support functions
|
---|
| 4 | Version 8 -- 1989-11-14 -- D.N. Lynx Crowe
|
---|
| 5 | =============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #include "stddefs.h"
|
---|
| 9 | #include "fields.h"
|
---|
| 10 | #include "hwdefs.h"
|
---|
| 11 | #include "vsdd.h"
|
---|
| 12 | #include "graphdef.h"
|
---|
| 13 |
|
---|
| 14 | #include "midas.h"
|
---|
| 15 |
|
---|
| 16 | extern unsigned exp_c();
|
---|
| 17 |
|
---|
| 18 | extern short cxrate; /* data entry cursor x (col) update increment */
|
---|
| 19 | extern short cyrate; /* data entry cursor y (row) update increment */
|
---|
| 20 | extern short stccol; /* data entry text cursor column */
|
---|
| 21 | extern short stcrow; /* data entry text cursor row */
|
---|
| 22 | extern short vtccol; /* vtyper cursor column */
|
---|
| 23 | extern short vtcrow; /* vtyper cursor row */
|
---|
| 24 | extern short vtdecol; /* vtyper data entry column */
|
---|
| 25 | extern short vtxval; /* vtyper cursor x value */
|
---|
| 26 | extern short vtyval; /* vtyper cursor y value */
|
---|
| 27 |
|
---|
| 28 | extern char *vtdeptr; /* vtyper data entry pointer */
|
---|
| 29 |
|
---|
| 30 | extern char vtdechr; /* vtyper data entry character */
|
---|
| 31 |
|
---|
| 32 | extern char bfs[]; /* display string buffer */
|
---|
| 33 |
|
---|
| 34 | extern short vtwrow; /* vtyper window top row */
|
---|
| 35 | extern short vtwcol; /* vtyper window left column */
|
---|
| 36 |
|
---|
| 37 | extern short (*vt_adv)(); /* vtyper data cursor advance function */
|
---|
| 38 | extern short (*vt_bsp)(); /* vtyper data cursor backspace function */
|
---|
| 39 | extern short (*vt_cdn)(); /* vtyper data cursor down function */
|
---|
| 40 | extern short (*vt_cup)(); /* vtyper data cursor up function */
|
---|
| 41 | extern short (*vt_stop)(); /* vtyper exit function */
|
---|
| 42 | extern short (*vt_dsp)(); /* vtyper display function */
|
---|
| 43 |
|
---|
| 44 | extern unsigned *vtobj; /* vtyper display object pointer */
|
---|
| 45 | extern unsigned vtfgval; /* vtyper data foreground color */
|
---|
| 46 | extern unsigned vtbgval; /* vtyper data background color */
|
---|
| 47 |
|
---|
| 48 | /* virtual typewriter display line constants */
|
---|
| 49 |
|
---|
| 50 | /* "123456789012345678901234567890" */
|
---|
| 51 | char vtlin1[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ | "; /* top */
|
---|
| 52 | char vtlin2[] = "abcdefghijklmnopqrstuvwxyz -*-"; /* center */
|
---|
| 53 | char vtlin3[] = " 0123456789+-/#().,:;!?&<> | "; /* bottom */
|
---|
| 54 |
|
---|
| 55 | /* |
---|
| 56 |
|
---|
| 57 | */
|
---|
| 58 |
|
---|
| 59 | /*
|
---|
| 60 | =============================================================================
|
---|
| 61 | vtsetup() -- setup the virtual typewriter for data entry
|
---|
| 62 |
|
---|
| 63 | This sets up the parameters for the virtual typewriter:
|
---|
| 64 |
|
---|
| 65 | obj VSDD display object pointer
|
---|
| 66 | dsp character display function
|
---|
| 67 | col data entry area -- leftmost column on the screen
|
---|
| 68 | ptr data string base pointer
|
---|
| 69 | tr typewriter window topmost row
|
---|
| 70 | tc typewriter window leftmost column
|
---|
| 71 | adv data entry cursor advance function
|
---|
| 72 | bsp data entry cursor backspace function
|
---|
| 73 | cup data entry cursor up function
|
---|
| 74 | cdn data entry cursor down function
|
---|
| 75 | stop virtual typewriter end function
|
---|
| 76 | fg data entry text foreground color
|
---|
| 77 | bg data entry text background color
|
---|
| 78 | =============================================================================
|
---|
| 79 | */
|
---|
| 80 |
|
---|
| 81 | vtsetup(obj, dsp, col, ptr, tr, tc, adv, bsp, cup, cdn, stop, fg, bg)
|
---|
| 82 | unsigned *obj;
|
---|
| 83 | short (*dsp)();
|
---|
| 84 | short col;
|
---|
| 85 | char *ptr;
|
---|
| 86 | short tr, tc;
|
---|
| 87 | short (*adv)(), (*bsp)(), (*cup)(), (*cdn)(), (*stop)();
|
---|
| 88 | unsigned fg, bg;
|
---|
| 89 | {
|
---|
| 90 | vtobj = obj; /* setup object pointer */
|
---|
| 91 | vt_adv = adv; /* setup cursor advance function pointer */
|
---|
| 92 | vt_bsp = bsp; /* setup cursor backspace function pointer */
|
---|
| 93 | vt_cup = cup; /* setup cursor up function pointer */
|
---|
| 94 | vt_cdn = cdn; /* setup cursor down function pointer */
|
---|
| 95 | vt_dsp = dsp; /* setup display function pointer */
|
---|
| 96 | vt_stop = stop; /* setup exit typewriter function pointer */
|
---|
| 97 | vtwrow = tr; /* setup typewriter window row */
|
---|
| 98 | vtwcol = tc; /* setup typewriter window column */
|
---|
| 99 | vtdecol = col; /* setup data entry base column */
|
---|
| 100 | vtdeptr = ptr; /* setup data entry area base address */
|
---|
| 101 | vtfgval = exp_c(fg); /* setup foreground color value */
|
---|
| 102 | vtbgval = exp_c(bg); /* setup background color value */
|
---|
| 103 | SetPri(TTCURS, TTCPRI); /* turn on the typewriter cursor */
|
---|
| 104 | vtxval = CTOX(tc); /* setup vt x value */
|
---|
| 105 | vtyval = YTOR(tr); /* setup vt y value */
|
---|
| 106 | ttcpos(tr, tc); /* position the typewriter cusor */
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | /* |
---|
| 110 |
|
---|
| 111 | */
|
---|
| 112 |
|
---|
| 113 | /*
|
---|
| 114 | =============================================================================
|
---|
| 115 | vtcxupd() -- update virtual typewriter cursor x value
|
---|
| 116 |
|
---|
| 117 | Standard cursor x update for use when the typewriter is displayed.
|
---|
| 118 |
|
---|
| 119 | Reference this in the cursor x update for the particular display
|
---|
| 120 | when the virtual typewriter is displayed.
|
---|
| 121 | =============================================================================
|
---|
| 122 | */
|
---|
| 123 |
|
---|
| 124 | vtcxupd()
|
---|
| 125 | {
|
---|
| 126 | vtccol = XTOC(vtxval += cxrate);
|
---|
| 127 |
|
---|
| 128 | if (vtccol > (vtwcol + 29))
|
---|
| 129 | vtxval = CTOX(vtccol = vtwcol + 29);
|
---|
| 130 | else if (vtccol < vtwcol)
|
---|
| 131 | vtxval = CTOX(vtccol = vtwcol);
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | /*
|
---|
| 135 | =============================================================================
|
---|
| 136 | vtcyupd() -- update virtual typewriter cursor y value
|
---|
| 137 |
|
---|
| 138 | Standard cursor y update for use when the typewriter is displayed.
|
---|
| 139 |
|
---|
| 140 | Reference this in the cursor y update for the particular display
|
---|
| 141 | when the virtual typewriter is displayed.
|
---|
| 142 | =============================================================================
|
---|
| 143 | */
|
---|
| 144 |
|
---|
| 145 | vtcyupd()
|
---|
| 146 | {
|
---|
| 147 | vtcrow = YTOR(vtyval += cyrate);
|
---|
| 148 |
|
---|
| 149 | if (vtcrow > (vtwrow + 2))
|
---|
| 150 | vtyval = RTOY(vtcrow = vtwrow + 2);
|
---|
| 151 | else if (vtcrow < vtwrow)
|
---|
| 152 | vtyval = RTOY(vtcrow = vtwrow);
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | /* |
---|
| 156 |
|
---|
| 157 | */
|
---|
| 158 |
|
---|
| 159 | /*
|
---|
| 160 | =============================================================================
|
---|
| 161 | vtdisp() -- virtual typewriter data entry display (4 bit graphics)
|
---|
| 162 |
|
---|
| 163 | Standard function for virtual typewriter output to a graphic screen.
|
---|
| 164 | Assumes that the graphic object is a 4 bit per pixel object in bank 0.
|
---|
| 165 | =============================================================================
|
---|
| 166 | */
|
---|
| 167 |
|
---|
| 168 | vtdisp(obj, fg, bg, row, col, buf)
|
---|
| 169 | unsigned *obj;
|
---|
| 170 | unsigned fg, bg;
|
---|
| 171 | short row, col;
|
---|
| 172 | char *buf;
|
---|
| 173 | {
|
---|
| 174 |
|
---|
| 175 | if (v_regs[5] & 0x0180)
|
---|
| 176 | vbank(0);
|
---|
| 177 |
|
---|
| 178 | vcputsv(obj, 64, fg, bg, row, col, buf, 14);
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | /* |
---|
| 182 |
|
---|
| 183 | */
|
---|
| 184 |
|
---|
| 185 | /*
|
---|
| 186 | =============================================================================
|
---|
| 187 | vtyper() -- do data entry with the virtual typewriter
|
---|
| 188 |
|
---|
| 189 | Called when enter is hit to do data entry from the select function
|
---|
| 190 | for the display. Returns TRUE if data entry occurred, FALSE otherwise.
|
---|
| 191 | =============================================================================
|
---|
| 192 | */
|
---|
| 193 |
|
---|
| 194 | vtyper()
|
---|
| 195 | {
|
---|
| 196 | /* check for data entry */
|
---|
| 197 |
|
---|
| 198 | if (vtccol < (vtwcol + 26)) { /* enter data */
|
---|
| 199 |
|
---|
| 200 | /* convert (vtcrow, vtccol) to data entry character */
|
---|
| 201 |
|
---|
| 202 | if (vtcrow EQ vtwrow)
|
---|
| 203 | vtdechr = vtlin1[vtccol - vtwcol];
|
---|
| 204 | else if (vtcrow EQ (vtwrow + 1))
|
---|
| 205 | vtdechr = vtlin2[vtccol - vtwcol];
|
---|
| 206 | else if (vtcrow EQ (vtwrow + 2))
|
---|
| 207 | vtdechr = vtlin3[vtccol - vtwcol];
|
---|
| 208 | else {
|
---|
| 209 |
|
---|
| 210 | vtdechr = '*'; /* error -- bad row */
|
---|
| 211 | return(FALSE);
|
---|
| 212 | }
|
---|
| 213 |
|
---|
| 214 | vtdeptr[stccol - vtdecol] = vtdechr; /* update data area */
|
---|
| 215 |
|
---|
| 216 | /* update the screen */
|
---|
| 217 |
|
---|
| 218 | bfs[0] = vtdechr;
|
---|
| 219 | bfs[1] = '\0';
|
---|
| 220 |
|
---|
| 221 | (*vt_dsp)(vtobj, vtfgval, vtbgval, stcrow, stccol, bfs);
|
---|
| 222 |
|
---|
| 223 | (*vt_adv)(); /* advance cursor */
|
---|
| 224 | return(TRUE);
|
---|
| 225 | /* |
---|
| 226 |
|
---|
| 227 | */
|
---|
| 228 | /* check for exit or cursor controls */
|
---|
| 229 |
|
---|
| 230 | } else if ((vtcrow EQ (vtwrow + 1))
|
---|
| 231 | AND (vtccol EQ (vtwcol + 28))) { /* exit */
|
---|
| 232 |
|
---|
| 233 | objclr(TTCPRI); /* turn off typewriter cursor */
|
---|
| 234 | (*vt_stop)(); /* refresh typewriter window */
|
---|
| 235 | return(FALSE);
|
---|
| 236 |
|
---|
| 237 | } else if ((vtcrow EQ vtwrow)
|
---|
| 238 | AND (vtccol EQ (vtwcol + 28))) { /* cursor up */
|
---|
| 239 |
|
---|
| 240 | (*vt_cup)(); /* move cursor up a row */
|
---|
| 241 | return(FALSE);
|
---|
| 242 |
|
---|
| 243 | } else if ((vtcrow EQ (vtwrow + 2))
|
---|
| 244 | AND (vtccol EQ (vtwcol + 28))) { /* cursor down */
|
---|
| 245 |
|
---|
| 246 | (*vt_cdn)(); /* move cursor down a row */
|
---|
| 247 | return(FALSE);
|
---|
| 248 |
|
---|
| 249 | } else if ((vtcrow EQ (vtwrow + 1))
|
---|
| 250 | AND (vtccol EQ (vtwcol + 27))) { /* cursor lft */
|
---|
| 251 |
|
---|
| 252 | (*vt_bsp)(); /* move cursor left a column */
|
---|
| 253 | return(FALSE);
|
---|
| 254 |
|
---|
| 255 | } else if ((vtcrow EQ (vtwrow + 1))
|
---|
| 256 | AND (vtccol EQ (vtwcol + 29))) { /* cursor rgt */
|
---|
| 257 |
|
---|
| 258 | (*vt_adv)(); /* move cursor right a column */
|
---|
| 259 | return(FALSE);
|
---|
| 260 | }
|
---|
| 261 | }
|
---|
| 262 |
|
---|