source: buchla-68k/ram/vtyper.c@ 0170798

Last change on this file since 0170798 was 0170798, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Added last missing function pointer prototypes.

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