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