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

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

Removed form-feed comments.

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