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

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

Prefer signed integers in vlib.

  • Property mode set to 100644
File size: 3.8 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 uint16_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 wp++;
64
65 for (j = 0; j < mw; j++)
66 *wp++ = color;
67
68 *wp = (*wp & ~rmask) | (color & rmask);
69 }
70
71 } else {
72
73 rmask = fm[width & 3];
74
75 for (i = 0; i < nl; i++) {
76
77 wp = fwp;
78 fwp += obwidth;
79 *wp = (*wp & ~lmask) | (color & lmask);
80 wp++;
81 *wp = (*wp & ~rmask) | (color & rmask);
82 }
83 }
84
85 } else {
86
87 lmask = fm[width - 1];
88
89 for (i = 0; i < nl; i++) {
90
91 wp = fwp;
92 fwp += obwidth;
93 *wp = (*wp & ~lmask) | (color & lmask);
94 }
95 }
96
97 return;
98
99
100 case 1:
101
102 if (width > 3) {
103
104 width -= 4;
105 lmask = fm[6];
106 mw = width >> 2;
107
108 if (mw) {
109
110 rmask = fm[width & 3];
111
112 for (i = 0; i < nl; i++) {
113
114 wp = fwp;
115 fwp += obwidth;
116 *wp = (*wp & ~lmask) | (color & lmask);
117 wp++;
118
119 for (j = 0; j < mw; j++)
120 *wp++ = color;
121
122 *wp = (*wp & ~rmask) | (color & rmask);
123 }
124
125 } else {
126
127 rmask = fm[width & 3];
128
129 for (i = 0; i < nl; i++) {
130
131 wp = fwp;
132 fwp += obwidth;
133 *wp = (*wp & ~lmask) | (color & lmask);
134 wp++;
135 *wp = (*wp & ~rmask) | (color & rmask);
136 }
137 }
138
139 } else {
140
141 lmask = fm[width + 3];
142
143 for (i = 0; i < nl; i++) {
144
145 wp = fwp;
146 fwp += obwidth;
147 *wp = (*wp & ~lmask) | (color & lmask);
148 }
149 }
150
151 return;
152
153
154 case 2:
155
156 if (width > 2) {
157
158 width -= 3;
159 lmask = fm[8];
160 mw = width >> 2;
161
162 if (mw) {
163
164 rmask = fm[width & 3];
165
166 for (i = 0; i < nl; i++) {
167
168 wp = fwp;
169 fwp += obwidth;
170 *wp = (*wp & ~lmask) | (color & lmask);
171 wp++;
172
173 for (j = 0; j < mw; j++)
174 *wp++ = color;
175
176 *wp = (*wp & ~rmask) | (color & rmask);
177 }
178
179 } else {
180
181 rmask = fm[width & 3];
182
183 for (i = 0; i < nl; i++) {
184
185 wp = fwp;
186 fwp += obwidth;
187 *wp = (*wp & ~lmask) | (color & lmask);
188 wp++;
189 *wp = (*wp & ~rmask) | (color & rmask);
190 }
191 }
192
193 } else {
194
195 lmask = fm[width + 6];
196
197 for (i = 0; i < nl; i++) {
198
199 wp = fwp;
200 fwp += obwidth;
201 *wp = (*wp & ~lmask) | (color & lmask);
202 }
203 }
204
205 return;
206
207
208 case 3:
209
210 if (width > 1) {
211
212 width -= 2;
213 lmask = fm[9];
214 mw = width >> 2;
215
216 if (mw) {
217
218 rmask = fm[width & 3];
219
220 for (i = 0; i < nl; i++) {
221
222 wp = fwp;
223 fwp += obwidth;
224 *wp = (*wp & ~lmask) | (color & lmask);
225 wp++;
226
227 for (j = 0; j < mw; j++)
228 *wp++ = color;
229
230 *wp = (*wp &~rmask) | (color & rmask);
231 }
232
233 } else {
234
235 rmask = fm[width & 3];
236
237 for (i = 0; i < nl; i++) {
238
239 wp = fwp;
240 fwp += obwidth;
241 *wp = (*wp & ~lmask) | (color & lmask);
242 wp++;
243 *wp = (*wp & ~rmask) | (color & rmask);
244 }
245 }
246
247 } else {
248
249 lmask = fm[9];
250
251 for (i = 0; i < nl; i++) {
252
253 wp = fwp;
254 fwp += obwidth;
255 *wp = (*wp & ~lmask) | (color & lmask);
256 }
257 }
258
259 return;
260 }
261}
Note: See TracBrowser for help on using the repository browser.