source: buchla-68k/vlib/vbfill4.c@ f40d52b

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

Compiled full ROM in Hatari.

  • Property mode set to 100644
File size: 4.0 KB
RevLine 
[109c83b]1/*
2 =============================================================================
3 vbfill4.c -- video block fill blitter for 4 bit per pixel objects
4 Version 3 -- 1987-08-04 -- D.N. Lynx Crowe
5
6 Fills an area with a color. Coded for speed, not space.
7 =============================================================================
8*/
9
10static short fm[] = { /* fill masks */
11
12 0x000F,
13 0x00FF,
14 0x0FFF,
15 0xFFFF,
16
17 0x00F0,
18 0x0FF0,
19 0xFFF0,
20
21 0x0F00,
22 0xFF00,
23
24 0xF000
25};
26
27/*
28
29*/
30
31vbfill4(obj, obwidth, xmin, ymin, xmax, ymax, color)
32unsigned *obj;
33short obwidth, xmin, ymin, xmax, ymax;
34register unsigned color;
35{
36 short mw, nl, width;
37
38 register unsigned *fwp, *wp;
39
40 register unsigned lmask, rmask;
41 register short i, j;
42
43 fwp = obj + (long)(xmin >> 2) + ((long)ymin * obwidth);
44 width = xmax - xmin + 1;
45 nl = ymax - ymin + 1;
46 lmask = rmask = 0;
47
48/*
49
50*/
51 switch (xmin & 3) {
52
53 case 0:
54
55 if (width > 4) {
56
57 width -= 5;
58 lmask = fm[3];
59 mw = width >> 2;
60
61 if (mw) {
62
63 rmask = fm[width & 3];
64
65 for (i = 0; i < nl; i++) {
66
67 wp = fwp;
68 fwp += obwidth;
69 *wp++ = (*wp & ~lmask) | (color & lmask);
70
71 for (j = 0; j < mw; j++)
72 *wp++ = color;
73
74 *wp = (*wp & ~rmask) | (color & rmask);
75 }
76
77 } else {
78
79 rmask = fm[width & 3];
80
81 for (i = 0; i < nl; i++) {
82
83 wp = fwp;
84 fwp += obwidth;
85 *wp++ = (*wp & ~lmask) | (color & lmask);
86 *wp = (*wp & ~rmask) | (color & rmask);
87 }
88 }
89
90 } else {
91
92 lmask = fm[width - 1];
93
94 for (i = 0; i < nl; i++) {
95
96 wp = fwp;
97 fwp += obwidth;
98 *wp = (*wp & ~lmask) | (color & lmask);
99 }
100 }
101
102 return;
103
104/*
105
106*/
107 case 1:
108
109 if (width > 3) {
110
111 width -= 4;
112 lmask = fm[6];
113 mw = width >> 2;
114
115 if (mw) {
116
117 rmask = fm[width & 3];
118
119 for (i = 0; i < nl; i++) {
120
121 wp = fwp;
122 fwp += obwidth;
123 *wp++ = (*wp & ~lmask) | (color & lmask);
124
125 for (j = 0; j < mw; j++)
126 *wp++ = color;
127
128 *wp = (*wp & ~rmask) | (color & rmask);
129 }
130
131 } else {
132
133 rmask = fm[width & 3];
134
135 for (i = 0; i < nl; i++) {
136
137 wp = fwp;
138 fwp += obwidth;
139 *wp++ = (*wp & ~lmask) | (color & lmask);
140 *wp = (*wp & ~rmask) | (color & rmask);
141 }
142 }
143
144 } else {
145
146 lmask = fm[width + 3];
147
148 for (i = 0; i < nl; i++) {
149
150 wp = fwp;
151 fwp += obwidth;
152 *wp = (*wp & ~lmask) | (color & lmask);
153 }
154 }
155
156 return;
157
158/*
159
160*/
161 case 2:
162
163 if (width > 2) {
164
165 width -= 3;
166 lmask = fm[8];
167 mw = width >> 2;
168
169 if (mw) {
170
171 rmask = fm[width & 3];
172
173 for (i = 0; i < nl; i++) {
174
175 wp = fwp;
176 fwp += obwidth;
177 *wp++ = (*wp & ~lmask) | (color & lmask);
178
179 for (j = 0; j < mw; j++)
180 *wp++ = color;
181
182 *wp = (*wp & ~rmask) | (color & rmask);
183 }
184
185 } else {
186
187 rmask = fm[width & 3];
188
189 for (i = 0; i < nl; i++) {
190
191 wp = fwp;
192 fwp += obwidth;
193 *wp++ = (*wp & ~lmask) | (color & lmask);
194 *wp = (*wp & ~rmask) | (color & rmask);
195 }
196 }
197
198 } else {
199
200 lmask = fm[width + 6];
201
202 for (i = 0; i < nl; i++) {
203
204 wp = fwp;
205 fwp += obwidth;
206 *wp = (*wp & ~lmask) | (color & lmask);
207 }
208 }
209
210 return;
211
212/*
213
214*/
215 case 3:
216
217 if (width > 1) {
218
219 width -= 2;
220 lmask = fm[9];
221 mw = width >> 2;
222
223 if (mw) {
224
225 rmask = fm[width & 3];
226
227 for (i = 0; i < nl; i++) {
228
229 wp = fwp;
230 fwp += obwidth;
231 *wp++ = (*wp & ~lmask) | (color & lmask);
232
233 for (j = 0; j < mw; j++)
234 *wp++ = color;
235
236 *wp = (*wp &~rmask) | (color & rmask);
237 }
238
239 } else {
240
241 rmask = fm[width & 3];
242
243 for (i = 0; i < nl; i++) {
244
245 wp = fwp;
246 fwp += obwidth;
247 *wp++ = (*wp & ~lmask) | (color & lmask);
248 *wp = (*wp & ~rmask) | (color & rmask);
249 }
250 }
251
252 } else {
253
254 lmask = fm[9];
255
256 for (i = 0; i < nl; i++) {
257
258 wp = fwp;
259 fwp += obwidth;
260 *wp = (*wp & ~lmask) | (color & lmask);
261 }
262 }
263
264 return;
265 }
266}
Note: See TracBrowser for help on using the repository browser.