1 | /*
|
---|
2 | =============================================================================
|
---|
3 | vobjfns.c -- VSDD object functions
|
---|
4 | Version 23 -- 1988-01-29 -- D.N. Lynx Crowe
|
---|
5 | (c) Copyright 1987,1988 -- D.N. Lynx Crowe
|
---|
6 |
|
---|
7 | SelObj(obj)
|
---|
8 | int obj;
|
---|
9 |
|
---|
10 | Select 'obj' as the current working object.
|
---|
11 |
|
---|
12 | SetPri(obj, pri)
|
---|
13 | int obj, pri;
|
---|
14 |
|
---|
15 | Display object 'obj' with priority 'pri'.
|
---|
16 |
|
---|
17 | SetObj(obj, type, bank, base, xpix, ypix, x0, y0, flags, pri)
|
---|
18 | int obj, type, bank, xpix, ypix, x0, y0, flags, pri;
|
---|
19 | unsigned int *base;
|
---|
20 |
|
---|
21 | Setup object 'obj' of type 'type' at 'base' in bank 'bank'
|
---|
22 | with height 'ypix' and width 'xpix' at initial location
|
---|
23 | 'x0','y0', with flags 'flags'. Assumes HRS EQ 1.
|
---|
24 | If 'pri' >= 0, display the object at priority level 'pri'.
|
---|
25 | Define a bitmap object if 'type' EQ 0, or a character object
|
---|
26 | if 'type' NE 0.
|
---|
27 |
|
---|
28 | CpyObj(from, to, w, h, sw)
|
---|
29 | unsigned int *from, *to;
|
---|
30 | int w, h, sw;
|
---|
31 |
|
---|
32 | Copy a 'w'-word by 'h'-line object from 'from' to 'to' with
|
---|
33 | a destination width of 'sw' words.
|
---|
34 | */
|
---|
35 |
|
---|
36 | /* |
---|
37 |
|
---|
38 | */
|
---|
39 |
|
---|
40 | /*
|
---|
41 | VIint() is located in viint.s but is mentioned here for completeness
|
---|
42 |
|
---|
43 | VIint()
|
---|
44 |
|
---|
45 | Vertical Interrupt handler. Enables display of any object
|
---|
46 | whose bit is set in vi_ctl. Bit 0 = object 0, etc.
|
---|
47 |
|
---|
48 | SetPri() uses BIOS(B_SETV, 25, VIint) to set the interrupt
|
---|
49 | vector and lets VIint() enable the object. If vi_dis
|
---|
50 | is set, SetPri() won't enable the interrupt or set the vector
|
---|
51 | so that several objects can be started up at once.
|
---|
52 | =============================================================================
|
---|
53 | */
|
---|
54 |
|
---|
55 | #include "biosdefs.h"
|
---|
56 | #include "graphdef.h"
|
---|
57 | #include "hwdefs.h"
|
---|
58 | #include "stddefs.h"
|
---|
59 | #include "vsdd.h"
|
---|
60 | #include "vsddvars.h"
|
---|
61 |
|
---|
62 | extern void vbank(uint16_t b);
|
---|
63 | extern void objon(uint16_t obj, uint16_t line, uint16_t num);
|
---|
64 | extern void VIint(void);
|
---|
65 |
|
---|
66 | extern uint16_t setipl(uint16_t arg);
|
---|
67 |
|
---|
68 | int16_t wsize; /* object width calculated by SetObj() */
|
---|
69 | int16_t vi_dis; /* disable use of VIint */
|
---|
70 |
|
---|
71 | uint16_t vi_ctl; /* object unblank control bits */
|
---|
72 |
|
---|
73 | /* |
---|
74 |
|
---|
75 | */
|
---|
76 |
|
---|
77 | /*
|
---|
78 | =============================================================================
|
---|
79 | SelObj(obj) -- Select 'obj' as the current working object.
|
---|
80 | =============================================================================
|
---|
81 | */
|
---|
82 |
|
---|
83 | void SelObj(int16_t obj)
|
---|
84 | {
|
---|
85 | register struct octent *op;
|
---|
86 | register uint16_t newbank;
|
---|
87 |
|
---|
88 | op = &v_obtab[obj];
|
---|
89 |
|
---|
90 | newbank = ((op->obank & 0x0001) << 8) | ((op->obank & 0x0002) << 6);
|
---|
91 |
|
---|
92 | v_nobj = obj;
|
---|
93 | v_curob = op;
|
---|
94 | v_obpri = op->opri;
|
---|
95 |
|
---|
96 | if ((v_regs[5] & 0x0180) NE newbank)
|
---|
97 | vbank(op->obank & 3);
|
---|
98 | }
|
---|
99 |
|
---|
100 | /* |
---|
101 |
|
---|
102 | */
|
---|
103 |
|
---|
104 | /*
|
---|
105 | =============================================================================
|
---|
106 | SetPri(obj, pri) -- Display object 'obj' with priority 'pri'.
|
---|
107 |
|
---|
108 | Blanks the object first, then sets the access table
|
---|
109 | and unblanks the object via VIint().
|
---|
110 | =============================================================================
|
---|
111 | */
|
---|
112 |
|
---|
113 | void SetPri(int16_t obj, int16_t pri)
|
---|
114 | {
|
---|
115 | register struct octent *op;
|
---|
116 |
|
---|
117 | if (v_regs[5] & 0x0180) /* point at the control bank */
|
---|
118 | vbank(0);
|
---|
119 |
|
---|
120 | op = &v_obtab[obj]; /* point at the object table */
|
---|
121 | op->opri = pri; /* set the priority */
|
---|
122 |
|
---|
123 | v_odtab[pri][0] = op->odtw0 | V_BLA; /* start object as blanked */
|
---|
124 | v_odtab[pri][1] = op->odtw1;
|
---|
125 | v_odtab[pri][2] = ((int32_t)op->obase >> 1) & 0xFFFF;
|
---|
126 |
|
---|
127 | objon(pri, op->objy, op->ysize); /* enable access table bits */
|
---|
128 |
|
---|
129 | if (vi_dis) /* don't unblank if vi_dis set */
|
---|
130 | return;
|
---|
131 |
|
---|
132 | setipl(7); /* disable interrupts */
|
---|
133 |
|
---|
134 | vi_ctl |= (1 << pri); /* set unblank bit */
|
---|
135 |
|
---|
136 | if (*((int32_t *)0x000064) NE &VIint) /* make sure VI vector is set */
|
---|
137 | BIOS(B_SETV, 25, VIint);
|
---|
138 |
|
---|
139 | setipl(0); /* enable VI interrupt */
|
---|
140 | }
|
---|
141 |
|
---|
142 | /* |
---|
143 |
|
---|
144 | */
|
---|
145 |
|
---|
146 | /*
|
---|
147 | =============================================================================
|
---|
148 | SetObj(obj, type, bank, base, xpix, ypix, x0, y0, flags, pri)
|
---|
149 | Setup an object, and optionally display it. Assumes HRS EQ 1.
|
---|
150 | =============================================================================
|
---|
151 | */
|
---|
152 |
|
---|
153 | void SetObj(int16_t obj, int16_t type, int16_t bank, int16_t xpix, int16_t ypix, int16_t x0, int16_t y0, int16_t flags, int16_t pri, uint16_t *base)
|
---|
154 | {
|
---|
155 | register struct octent *op;
|
---|
156 |
|
---|
157 | if (v_regs[5] & 0x0180) /* point at the control bank */
|
---|
158 | vbank(0);
|
---|
159 |
|
---|
160 | op = &v_obtab[obj];
|
---|
161 |
|
---|
162 | v_curob = op;
|
---|
163 | v_nobj = obj;
|
---|
164 | v_obpri = pri;
|
---|
165 |
|
---|
166 | op->ysize = ypix;
|
---|
167 | op->xsize = xpix;
|
---|
168 | op->objx = x0;
|
---|
169 | op->objy = y0;
|
---|
170 | op->obase = base;
|
---|
171 | op->opri = pri;
|
---|
172 | op->obank = bank & 3;
|
---|
173 |
|
---|
174 | /* |
---|
175 |
|
---|
176 | */
|
---|
177 | if (type) { /* character objects */
|
---|
178 |
|
---|
179 | op->odtw0 = (flags & 0xF9FF) | V_CTYPE;
|
---|
180 |
|
---|
181 | switch (V_RES3 & op->odtw0) {
|
---|
182 |
|
---|
183 | case V_RES0:
|
---|
184 |
|
---|
185 | wsize = xpix / 128;
|
---|
186 | break;
|
---|
187 |
|
---|
188 | case V_RES1:
|
---|
189 |
|
---|
190 | wsize = xpix / 48;
|
---|
191 | break;
|
---|
192 |
|
---|
193 | case V_RES2:
|
---|
194 |
|
---|
195 | wsize = xpix / 64;
|
---|
196 | break;
|
---|
197 |
|
---|
198 | case V_RES3:
|
---|
199 |
|
---|
200 | wsize = xpix / 96;
|
---|
201 | break;
|
---|
202 | }
|
---|
203 |
|
---|
204 | if (V_FAD & op->odtw0)
|
---|
205 | wsize = wsize + (wsize << 1);
|
---|
206 |
|
---|
207 | /* |
---|
208 |
|
---|
209 | */
|
---|
210 | } else { /* bitmap objects */
|
---|
211 |
|
---|
212 | op->odtw0 = (flags & 0x0E37) | (V_BTYPE | ((bank & 3) << 6));
|
---|
213 |
|
---|
214 | switch (V_RES3 & op->odtw0) {
|
---|
215 |
|
---|
216 | case V_RES0:
|
---|
217 | case V_RES1:
|
---|
218 |
|
---|
219 | wsize = 0;
|
---|
220 | break;
|
---|
221 |
|
---|
222 | case V_RES2:
|
---|
223 |
|
---|
224 | wsize = xpix / 32;
|
---|
225 | break;
|
---|
226 |
|
---|
227 | case V_RES3:
|
---|
228 |
|
---|
229 | wsize = xpix / 16;
|
---|
230 | break;
|
---|
231 | }
|
---|
232 | }
|
---|
233 |
|
---|
234 | op->odtw1 = ((x0 >> 1) & 0x03FF) | (0xFC00 & (wsize << 10));
|
---|
235 |
|
---|
236 | if (pri < 0)
|
---|
237 | return;
|
---|
238 |
|
---|
239 | SetPri(obj, pri);
|
---|
240 | }
|
---|
241 |
|
---|
242 | /* |
---|
243 |
|
---|
244 | */
|
---|
245 |
|
---|
246 | /*
|
---|
247 | =============================================================================
|
---|
248 | CpyObj(from, to, w, h, sw)
|
---|
249 |
|
---|
250 | Copy a 'w'-word by 'h'-line object from 'from' to 'to' with
|
---|
251 | a destination width of 'sw' words. Assumes we're pointing at
|
---|
252 | the correct bank.
|
---|
253 | =============================================================================
|
---|
254 | */
|
---|
255 |
|
---|
256 | void CpyObj(uint16_t *from, uint16_t *to, uint16_t w, uint16_t h, uint16_t sw)
|
---|
257 | {
|
---|
258 | register uint16_t *tp;
|
---|
259 | register uint16_t i, j;
|
---|
260 |
|
---|
261 | for (i = h; i--; ) {
|
---|
262 |
|
---|
263 | tp = to;
|
---|
264 |
|
---|
265 | for (j = w; j--; )
|
---|
266 | *tp++ = *from++;
|
---|
267 |
|
---|
268 | to += sw;
|
---|
269 | }
|
---|
270 | }
|
---|