source: buchla-68k/vlib/vobjfns.c@ 39a696b

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

Added include files for global functions and variables.

  • Property mode set to 100644
File size: 5.5 KB
Line 
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 "all.h"
56
57extern void vbank(uint16_t b);
58extern void objon(uint16_t obj, uint16_t line, uint16_t num);
59extern void VIint(void);
60
61extern uint16_t setipl(uint16_t arg);
62
63int16_t wsize; /* object width calculated by SetObj() */
64int16_t vi_dis; /* disable use of VIint */
65
66uint16_t vi_ctl; /* object unblank control bits */
67
68/*
69
70*/
71
72/*
73 =============================================================================
74 SelObj(obj) -- Select 'obj' as the current working object.
75 =============================================================================
76*/
77
78void SelObj(int16_t obj)
79{
80 register struct octent *op;
81 register uint16_t newbank;
82
83 op = &v_obtab[obj];
84
85 newbank = ((op->obank & 0x0001) << 8) | ((op->obank & 0x0002) << 6);
86
87 v_nobj = obj;
88 v_curob = op;
89 v_obpri = op->opri;
90
91 if ((v_regs[5] & 0x0180) NE newbank)
92 vbank(op->obank & 3);
93}
94
95/*
96
97*/
98
99/*
100 =============================================================================
101 SetPri(obj, pri) -- Display object 'obj' with priority 'pri'.
102
103 Blanks the object first, then sets the access table
104 and unblanks the object via VIint().
105 =============================================================================
106*/
107
108void SetPri(int16_t obj, int16_t pri)
109{
110 register struct octent *op;
111
112 if (v_regs[5] & 0x0180) /* point at the control bank */
113 vbank(0);
114
115 op = &v_obtab[obj]; /* point at the object table */
116 op->opri = pri; /* set the priority */
117
118 v_odtab[pri][0] = op->odtw0 | V_BLA; /* start object as blanked */
119 v_odtab[pri][1] = op->odtw1;
120 v_odtab[pri][2] = ((int32_t)op->obase >> 1) & 0xFFFF;
121
122 objon(pri, op->objy, op->ysize); /* enable access table bits */
123
124 if (vi_dis) /* don't unblank if vi_dis set */
125 return;
126
127 setipl(7); /* disable interrupts */
128
129 vi_ctl |= (1 << pri); /* set unblank bit */
130
131 if (*((int32_t *)0x000064) NE &VIint) /* make sure VI vector is set */
132 BIOS(B_SETV, 25, VIint);
133
134 setipl(0); /* enable VI interrupt */
135}
136
137/*
138
139*/
140
141/*
142 =============================================================================
143 SetObj(obj, type, bank, base, xpix, ypix, x0, y0, flags, pri)
144 Setup an object, and optionally display it. Assumes HRS EQ 1.
145 =============================================================================
146*/
147
148void 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)
149{
150 register struct octent *op;
151
152 if (v_regs[5] & 0x0180) /* point at the control bank */
153 vbank(0);
154
155 op = &v_obtab[obj];
156
157 v_curob = op;
158 v_nobj = obj;
159 v_obpri = pri;
160
161 op->ysize = ypix;
162 op->xsize = xpix;
163 op->objx = x0;
164 op->objy = y0;
165 op->obase = base;
166 op->opri = pri;
167 op->obank = bank & 3;
168
169/*
170
171*/
172 if (type) { /* character objects */
173
174 op->odtw0 = (flags & 0xF9FF) | V_CTYPE;
175
176 switch (V_RES3 & op->odtw0) {
177
178 case V_RES0:
179
180 wsize = xpix / 128;
181 break;
182
183 case V_RES1:
184
185 wsize = xpix / 48;
186 break;
187
188 case V_RES2:
189
190 wsize = xpix / 64;
191 break;
192
193 case V_RES3:
194
195 wsize = xpix / 96;
196 break;
197 }
198
199 if (V_FAD & op->odtw0)
200 wsize = wsize + (wsize << 1);
201
202/*
203
204*/
205 } else { /* bitmap objects */
206
207 op->odtw0 = (flags & 0x0E37) | (V_BTYPE | ((bank & 3) << 6));
208
209 switch (V_RES3 & op->odtw0) {
210
211 case V_RES0:
212 case V_RES1:
213
214 wsize = 0;
215 break;
216
217 case V_RES2:
218
219 wsize = xpix / 32;
220 break;
221
222 case V_RES3:
223
224 wsize = xpix / 16;
225 break;
226 }
227 }
228
229 op->odtw1 = ((x0 >> 1) & 0x03FF) | (0xFC00 & (wsize << 10));
230
231 if (pri < 0)
232 return;
233
234 SetPri(obj, pri);
235}
236
237/*
238
239*/
240
241/*
242 =============================================================================
243 CpyObj(from, to, w, h, sw)
244
245 Copy a 'w'-word by 'h'-line object from 'from' to 'to' with
246 a destination width of 'sw' words. Assumes we're pointing at
247 the correct bank.
248 =============================================================================
249*/
250
251void CpyObj(uint16_t *from, uint16_t *to, uint16_t w, uint16_t h, uint16_t sw)
252{
253 register uint16_t *tp;
254 register uint16_t i, j;
255
256 for (i = h; i--; ) {
257
258 tp = to;
259
260 for (j = w; j--; )
261 *tp++ = *from++;
262
263 to += sw;
264 }
265}
266
Note: See TracBrowser for help on using the repository browser.