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

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

Prefer signed integers in vlib.

  • Property mode set to 100644
File size: 5.3 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 VIint() is located in viint.s but is mentioned here for completeness
38
39 VIint()
40
41 Vertical Interrupt handler. Enables display of any object
42 whose bit is set in vi_ctl. Bit 0 = object 0, etc.
43
44 SetPri() uses BIOS(B_SETV, 25, VIint) to set the interrupt
45 vector and lets VIint() enable the object. If vi_dis
46 is set, SetPri() won't enable the interrupt or set the vector
47 so that several objects can be started up at once.
48 =============================================================================
49*/
50
51#include "ram.h"
52
53int16_t wsize; /* object width calculated by SetObj() */
54int16_t vi_dis; /* disable use of VIint */
55
56uint16_t vi_ctl; /* object unblank control bits */
57
58/*
59 =============================================================================
60 SelObj(obj) -- Select 'obj' as the current working object.
61 =============================================================================
62*/
63
64void SelObj(int16_t obj)
65{
66 register struct octent *op;
67 register uint16_t newbank;
68
69 op = &v_obtab[obj];
70
71 newbank = ((op->obank & 0x0001u) << 8) | ((op->obank & 0x0002u) << 6);
72
73 v_nobj = obj;
74 v_curob = op;
75 v_obpri = op->opri;
76
77 if ((v_regs[5] & 0x0180) NE newbank)
78 vbank(op->obank & 3);
79}
80
81/*
82 =============================================================================
83 SetPri(obj, pri) -- Display object 'obj' with priority 'pri'.
84
85 Blanks the object first, then sets the access table
86 and unblanks the object via VIint().
87 =============================================================================
88*/
89
90void SetPri(int16_t obj, int16_t pri)
91{
92 register struct octent *op;
93
94 if (v_regs[5] & 0x0180) /* point at the control bank */
95 vbank(0);
96
97 op = &v_obtab[obj]; /* point at the object table */
98 op->opri = pri; /* set the priority */
99
100 v_odtab[pri][0] = op->odtw0 | V_BLA; /* start object as blanked */
101 v_odtab[pri][1] = op->odtw1;
102 v_odtab[pri][2] = ((int32_t)op->obase >> 1) & 0xFFFF;
103
104 objon(pri, op->objy, op->ysize); /* enable access table bits */
105
106 if (vi_dis) /* don't unblank if vi_dis set */
107 return;
108
109 setipl(7); /* disable interrupts */
110
111 vi_ctl |= (1u << pri); /* set unblank bit */
112
113 if (*((int32_t *)0x000064) NE &VIint) /* make sure VI vector is set */
114 BIOS(B_SETV, 25, VIint);
115
116 setipl(0); /* enable VI interrupt */
117}
118
119/*
120 =============================================================================
121 SetObj(obj, type, bank, base, xpix, ypix, x0, y0, flags, pri)
122 Setup an object, and optionally display it. Assumes HRS EQ 1.
123 =============================================================================
124*/
125
126void SetObj(int16_t obj, int16_t type, int16_t bank, uint16_t *base, int16_t xpix, int16_t ypix, int16_t x0, int16_t y0, uint16_t flags, int16_t pri)
127{
128 register struct octent *op;
129
130 if (v_regs[5] & 0x0180) /* point at the control bank */
131 vbank(0);
132
133 op = &v_obtab[obj];
134
135 v_curob = op;
136 v_nobj = obj;
137 v_obpri = pri;
138
139 op->ysize = ypix;
140 op->xsize = xpix;
141 op->objx = x0;
142 op->objy = y0;
143 op->obase = base;
144 op->opri = pri;
145 op->obank = bank & 3;
146
147
148 if (type) { /* character objects */
149
150 op->odtw0 = (flags & 0xF9FFu) | V_CTYPE;
151
152 switch (V_RES3 & op->odtw0) {
153
154 case V_RES0:
155
156 wsize = xpix / 128;
157 break;
158
159 case V_RES1:
160
161 wsize = xpix / 48;
162 break;
163
164 case V_RES2:
165
166 wsize = xpix / 64;
167 break;
168
169 case V_RES3:
170
171 wsize = xpix / 96;
172 break;
173 }
174
175 if (V_FAD & op->odtw0)
176 wsize = wsize + (wsize << 1);
177
178
179 } else { /* bitmap objects */
180
181 op->odtw0 = (flags & 0x0E37u) | (V_BTYPE | (((uint16_t)bank & 3u) << 6));
182
183 switch (V_RES3 & op->odtw0) {
184
185 case V_RES0:
186 case V_RES1:
187
188 wsize = 0;
189 break;
190
191 case V_RES2:
192
193 wsize = xpix / 32;
194 break;
195
196 case V_RES3:
197
198 wsize = xpix / 16;
199 break;
200 }
201 }
202
203 op->odtw1 = (((uint16_t)x0 >> 1) & 0x03FFu) | (0xFC00u & ((uint16_t)wsize << 10));
204
205 if (pri < 0)
206 return;
207
208 SetPri(obj, pri);
209}
210
211/*
212 =============================================================================
213 CpyObj(from, to, w, h, sw)
214
215 Copy a 'w'-word by 'h'-line object from 'from' to 'to' with
216 a destination width of 'sw' words. Assumes we're pointing at
217 the correct bank.
218 =============================================================================
219*/
220
221void CpyObj(uint16_t *from, uint16_t *to, int16_t w, int16_t h, int16_t sw)
222{
223 register uint16_t *tp;
224 register int16_t i, j;
225
226 for (i = h; i--; ) {
227
228 tp = to;
229
230 for (j = w; j--; )
231 *tp++ = *from++;
232
233 to += sw;
234 }
235}
236
Note: See TracBrowser for help on using the repository browser.