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

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

More volatile hardware accesses.

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