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

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

Zero redundant declarations.

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