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

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

Use standard integer types.

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