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