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

Last change on this file since 4b63bf3 was 8c8b4e5, checked in by Thomas Lopatic <thomas@…>, 7 years ago

More volatile hardware accesses.

  • Property mode set to 100644
File size: 3.8 KB
RevLine 
[f40a309]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
[b28a12e]10#include "ram.h"
[6262b5c]11
[09d1345]12static uint16_t fm[] = { /* fill masks */
[f40a309]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
[8c8b4e5]29void vbfill4(volatile uint16_t *obj, int16_t obwidth, int16_t xmin, int16_t ymin, int16_t xmax, int16_t ymax, uint16_t color)
[f40a309]30{
[7258c6a]31 int16_t mw, nl, width;
[f40a309]32
[8c8b4e5]33 volatile uint16_t *fwp, *wp;
[f40a309]34
[8c8b4e5]35 uint16_t lmask, rmask;
36 int16_t i, j;
[f40a309]37
[7258c6a]38 fwp = obj + (int32_t)(xmin >> 2) + ((int32_t)ymin * obwidth);
[f40a309]39 width = xmax - xmin + 1;
40 nl = ymax - ymin + 1;
41 lmask = rmask = 0;
42
[fa38804]43
[f40a309]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;
[09d1345]62 *wp = (*wp & ~lmask) | (color & lmask);
63 wp++;
[f40a309]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;
[09d1345]79 *wp = (*wp & ~lmask) | (color & lmask);
80 wp++;
[f40a309]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
[fa38804]99
[f40a309]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;
[09d1345]116 *wp = (*wp & ~lmask) | (color & lmask);
117 wp++;
[f40a309]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;
[09d1345]133 *wp = (*wp & ~lmask) | (color & lmask);
134 wp++;
[f40a309]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
[fa38804]153
[f40a309]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;
[09d1345]170 *wp = (*wp & ~lmask) | (color & lmask);
171 wp++;
[f40a309]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;
[09d1345]187 *wp = (*wp & ~lmask) | (color & lmask);
188 wp++;
[f40a309]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
[fa38804]207
[f40a309]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;
[09d1345]224 *wp = (*wp & ~lmask) | (color & lmask);
225 wp++;
[f40a309]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;
[09d1345]241 *wp = (*wp & ~lmask) | (color & lmask);
242 wp++;
[f40a309]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.