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

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

No more warnings in vlib.

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