source: trunk/src/ddraw/fillfunc.cpp@ 6496

Last change on this file since 6496 was 5472, checked in by sandervl, 24 years ago

compile fix

File size: 14.7 KB
Line 
1/* $Id: fillfunc.cpp,v 1.4 2001-04-04 09:02:15 sandervl Exp $ */
2
3/*
4 * ColorFill functions
5 *
6 * Copyright 1999 Markus Montkowski
7 *
8 * Project Odin Software License can be found in LICENSE.TXT
9 *
10 */
11
12#define INCL_BASE
13#include <os2wrap.h>
14#include <win32type.h>
15#include <memory.h>
16#include <misc.h>
17#include "fillfunc.h"
18
19//
20// Blt Functions
21//
22
23#ifndef USE_ASM
24void __cdecl Fill8( char* pDst,
25 DWORD dwWidth,
26 DWORD dwHeight,
27 DWORD dwPitch,
28 DWORD dwColor)
29{
30 DWORD *pColor;
31 char *pFillPos;
32 int i;
33 dprintf(("DDRAW:Fill8 with %08X\n",dwColor));
34
35 // First Fill First row with the color
36
37 for( i=0,pColor = (DWORD*)pDst;i<(dwWidth/4);i++)
38 pColor[i] = dwColor;
39
40 if(dwWidth % 4)
41 {
42 pFillPos = (char*) (&pColor[i-1]);
43 for(i=0;i<dwWidth % 4;i++)
44 pFillPos[i] = (UCHAR) dwColor;
45 }
46
47 dwHeight--;
48
49 if(dwWidth == dwPitch)
50 {
51 // Width = Pitch => fill buffer so no need to take care of lines
52 memcpy(pDst+dwPitch, pDst, dwWidth*dwHeight);
53 }
54 else
55 {
56 pFillPos = pDst+dwPitch;
57 while(dwHeight)
58 {
59 memcpy(pFillPos,pDst,dwWidth);
60 pFillPos += dwPitch;
61 dwHeight--;
62 }
63 }
64}
65void __cdecl Fill16( char* pDst,
66 DWORD dwWidth,
67 DWORD dwHeight,
68 DWORD dwPitch,
69 DWORD dwColor)
70{
71 DWORD *pColor;
72 char *pFillPos;
73 int i;
74 dprintf(("DDRAW:Fill16 with %08X \n",dwColor));
75
76 // First Fill First row with the color
77
78 for( i=0,pColor = (DWORD*)pDst;i<(dwWidth/2);i++)
79 pColor[i] = dwColor;
80
81 if(dwWidth % 2)
82 {
83 pFillPos = (char*)(&pColor[i-1]);
84 *((USHORT*)pFillPos) = (USHORT)dwColor;
85 }
86
87 dwWidth *=2;
88 dwHeight--;
89
90 if(dwWidth == dwPitch)
91 {
92 // Width = Pitch => fill buffer so no need to take care of lines
93 memcpy(pDst+dwPitch, pDst, dwWidth*dwHeight);
94 }
95 else
96 {
97 pFillPos = pDst+dwPitch;
98 while(dwHeight)
99 {
100 memcpy(pFillPos,pDst,dwWidth);
101 pFillPos += dwPitch;
102 dwHeight--;
103 }
104 }
105}
106void __cdecl Fill24( char* pDst,
107 DWORD dwWidth,
108 DWORD dwHeight,
109 DWORD dwPitch,
110 DWORD dwColor)
111{
112 DWORD *pColor;
113 char *pFillPos;
114 int i;
115 dprintf(("DDRAW:Fill24 with %08X \n",dwColor));
116
117 // First Fill First row with the color
118
119 for(i=0 ; i<dwWidth ; i++)
120 {
121 pColor = (DWORD*)(pDst+(i*3));
122 *pColor = dwColor;
123 }
124 dwWidth *=3;
125 dwHeight--;
126
127 if(dwWidth == dwPitch)
128 {
129 // Width = Pitch => fill buffer so no need to take care of lines
130 memcpy(pDst+dwPitch, pDst, dwWidth*dwHeight);
131 }
132 else
133 {
134 pFillPos = pDst+dwPitch;
135 while(dwHeight)
136 {
137 memcpy(pFillPos,pDst,dwWidth);
138 pFillPos += dwPitch;
139 dwHeight--;
140 }
141 }
142}
143
144void __cdecl Fill32( char* pDst,
145 DWORD dwWidth,
146 DWORD dwHeight,
147 DWORD dwPitch,
148 DWORD dwColor)
149{
150 DWORD *pColor;
151 char *pFillPos;
152 int i;
153 dprintf(("DDRAW:Fill24 with %08X \n",dwColor));
154
155 // First Fill First row with the color
156
157 for(i=0 ; i<dwWidth ; i++)
158 {
159 pColor[i] = dwColor;
160 }
161 dwWidth *=4;
162 dwHeight--;
163
164 if(dwWidth == dwPitch)
165 {
166 // Width = Pitch => fill buffer so no need to take care of lines
167 memcpy(pDst+dwPitch, pDst, dwWidth*dwHeight);
168 }
169 else
170 {
171 pFillPos = pDst+dwPitch;
172 while(dwHeight)
173 {
174 memcpy(pFillPos,pDst,dwWidth);
175 pFillPos += dwPitch;
176 dwHeight--;
177 }
178 }
179}
180#else
181 #define Fill8 Fill8ASM
182 #define Fill16 Fill16ASM
183 #define Fill24 Fill24ASM
184 #define Fill32 Fill32ASM
185#endif
186
187
188
189// without ColorConversion
190 void __cdecl Fill8on8( char *pDB,
191 char *pFB,
192 DWORD dwTop,
193 DWORD dwLeft,
194 DWORD dwWidth,
195 DWORD dwHeight,
196 DWORD dwPitchDB,
197 DWORD dwPitchFB,
198 DWORD dwColor,
199 VOID *pPalette
200 )
201{
202 dprintf(("Fill8on8\n"));
203 dwColor = (dwColor&0xFF)+(dwColor&0xFF<<8);
204 dwColor += (dwColor<<16);
205
206 Fill8( pDB+(dwTop*dwPitchDB)+dwLeft,
207 dwWidth,
208 dwHeight,
209 dwPitchDB,
210 dwColor);
211}
212 void __cdecl Fill16on16( char *pDB,
213 char *pFB,
214 DWORD dwTop,
215 DWORD dwLeft,
216 DWORD dwWidth,
217 DWORD dwHeight,
218 DWORD dwPitchDB,
219 DWORD dwPitchFB,
220 DWORD dwColor,
221 VOID *pPalette
222 )
223{
224 dprintf(("Fill16on16\n"));
225 dwColor = (dwColor&0xFFFF)+((dwColor&0xFFFF)<<16);
226
227 Fill16( pDB+(dwTop*dwPitchDB)+(dwLeft*2),
228 dwWidth,
229 dwHeight,
230 dwPitchDB,
231 dwColor);
232}
233 void __cdecl Fill24on24( char *pDB,
234 char *pFB,
235 DWORD dwTop,
236 DWORD dwLeft,
237 DWORD dwWidth,
238 DWORD dwHeight,
239 DWORD dwPitchDB,
240 DWORD dwPitchFB,
241 DWORD dwColor,
242 VOID *pPalette
243 )
244{
245 dprintf(("Fill24on24\n"));
246 dwColor <<= 8;
247
248 Fill24( pDB+(dwTop*dwPitchDB)+(dwLeft*3),
249 dwWidth,
250 dwHeight,
251 dwPitchDB,
252 dwColor);
253
254}
255 void __cdecl Fill32on32( char *pDB,
256 char *pFB,
257 DWORD dwTop,
258 DWORD dwLeft,
259 DWORD dwWidth,
260 DWORD dwHeight,
261 DWORD dwPitchDB,
262 DWORD dwPitchFB,
263 DWORD dwColor,
264 VOID *pPalette
265 )
266{
267 dprintf(("Fill32on32\n"));
268 Fill32( pDB+(dwTop*dwPitchDB)+(dwLeft*4),
269 dwWidth,
270 dwHeight,
271 dwPitchDB,
272 dwColor);
273}
274
275 void __cdecl Fill8on16( char *pDB,
276 char *pFB,
277 DWORD dwTop,
278 DWORD dwLeft,
279 DWORD dwWidth,
280 DWORD dwHeight,
281 DWORD dwPitchDB,
282 DWORD dwPitchFB,
283 DWORD dwColor,
284 VOID *pPalette
285 )
286{
287 DWORD dwCol;
288 dprintf(("Fill8on16\n"));
289 dwCol = (dwColor&0xFF)+(dwColor&0xFF<<8);
290 dwCol += (dwCol<<16);
291
292 Fill8( pFB+(dwTop*dwPitchFB)+dwLeft,
293 dwWidth,
294 dwHeight,
295 dwPitchFB,
296 dwCol);
297
298 dwCol = ((WORD*)pPalette)[dwColor];
299 dwCol += (dwCol<<16);
300 Fill16( pDB+(dwTop*dwPitchDB)+(dwLeft*2),
301 dwWidth,
302 dwHeight,
303 dwPitchDB,
304 dwCol);
305}
306
307 void __cdecl Fill8on24( char *pDB,
308 char *pFB,
309 DWORD dwTop,
310 DWORD dwLeft,
311 DWORD dwWidth,
312 DWORD dwHeight,
313 DWORD dwPitchDB,
314 DWORD dwPitchFB,
315 DWORD dwColor,
316 VOID *pPalette
317 )
318{
319 DWORD dwCol;
320 dprintf(("Fill8on24\n"));
321 dwCol = (dwColor&0xFF)+(dwColor&0xFF<<8);
322 dwCol += (dwCol<<16);
323
324 Fill8( pFB+(dwTop*dwPitchFB)+dwLeft,
325 dwWidth,
326 dwHeight,
327 dwPitchFB,
328 dwCol);
329
330 dwCol = ((DWORD*)pPalette)[dwColor];
331 //dwCol <<= 8;
332 Fill24( pDB+(dwTop*dwPitchDB)+(dwLeft*3),
333 dwWidth,
334 dwHeight,
335 dwPitchDB,
336 dwCol);
337}
338 void __cdecl Fill8on32( char *pDB,
339 char *pFB,
340 DWORD dwTop,
341 DWORD dwLeft,
342 DWORD dwWidth,
343 DWORD dwHeight,
344 DWORD dwPitchDB,
345 DWORD dwPitchFB,
346 DWORD dwColor,
347 VOID *pPalette
348 )
349{
350 DWORD dwCol;
351 dprintf(("Fill8on32\n"));
352 dwCol = (dwColor&0xFF)+(dwColor&0xFF<<8);
353 dwCol += (dwCol<<16);
354
355 Fill8( pFB+(dwTop*dwPitchFB)+dwLeft,
356 dwWidth,
357 dwHeight,
358 dwPitchFB,
359 dwCol);
360
361 dwCol = ((DWORD*)pPalette)[dwColor];
362 Fill32( pDB+(dwTop*dwPitchDB)+(dwLeft*4),
363 dwWidth,
364 dwHeight,
365 dwPitchDB,
366 dwCol);
367}
368 void __cdecl Fill16on8( char *pDB,
369 char *pFB,
370 DWORD dwTop,
371 DWORD dwLeft,
372 DWORD dwWidth,
373 DWORD dwHeight,
374 DWORD dwPitchDB,
375 DWORD dwPitchFB,
376 DWORD dwColor,
377 VOID *pPalette
378 )
379{
380 dprintf(("Fill16on8 NOT Implemented \n"));
381}
382 void __cdecl Fill16on24( char *pDB,
383 char *pFB,
384 DWORD dwTop,
385 DWORD dwLeft,
386 DWORD dwWidth,
387 DWORD dwHeight,
388 DWORD dwPitchDB,
389 DWORD dwPitchFB,
390 DWORD dwColor,
391 VOID *pPalette
392 )
393{
394 DWORD dwCol;
395 dprintf(("Fill16on24\n"));
396 dwCol = dwColor + (dwColor<<16);
397
398 Fill16( pFB+(dwTop*dwPitchFB)+(dwLeft*2),
399 dwWidth,
400 dwHeight,
401 dwPitchFB,
402 dwCol);
403
404 dwCol = ((dwColor & 0xF800)<< 16) +
405 ((dwColor & 0x07E0)<< 13) +
406 ((dwColor & 0x001F)<< 11);
407 Fill24( pDB+(dwTop*dwPitchDB)+(dwLeft*2),
408 dwWidth,
409 dwHeight,
410 dwPitchDB,
411 dwCol);
412}
413 void __cdecl Fill16on32( char *pDB,
414 char *pFB,
415 DWORD dwTop,
416 DWORD dwLeft,
417 DWORD dwWidth,
418 DWORD dwHeight,
419 DWORD dwPitchDB,
420 DWORD dwPitchFB,
421 DWORD dwColor,
422 VOID *pPalette
423 )
424{
425 DWORD dwCol;
426 dprintf(("Fill16on32\n"));
427 dwCol = dwColor + (dwColor<<16);
428
429 Fill16( pFB+(dwTop*dwPitchFB)+(dwLeft*2),
430 dwWidth,
431 dwHeight,
432 dwPitchFB,
433 dwCol);
434
435 dwCol = ((dwColor & 0xF800)<< 16) +
436 ((dwColor & 0x07E0)<< 13) +
437 ((dwColor & 0x001F)<< 11);
438 Fill32( pDB+(dwTop*dwPitchDB)+(dwLeft*4),
439 dwWidth,
440 dwHeight,
441 dwPitchDB,
442 dwCol);
443}
444
445 void __cdecl Fill24on8( char *pDB,
446 char *pFB,
447 DWORD dwTop,
448 DWORD dwLeft,
449 DWORD dwWidth,
450 DWORD dwHeight,
451 DWORD dwPitchDB,
452 DWORD dwPitchFB,
453 DWORD dwColor,
454 VOID *pPalette
455 )
456{
457 dprintf(("Fill24on8 NOT implemented\n"));
458}
459 void __cdecl Fill24on16( char *pDB,
460 char *pFB,
461 DWORD dwTop,
462 DWORD dwLeft,
463 DWORD dwWidth,
464 DWORD dwHeight,
465 DWORD dwPitchDB,
466 DWORD dwPitchFB,
467 DWORD dwColor,
468 VOID *pPalette
469 )
470{
471 DWORD dwCol;
472 dprintf(("Fill24on16\n"));
473 //dwColor <<=8;
474
475 Fill24( pFB+(dwTop*dwPitchFB)+(dwLeft*3),
476 dwWidth,
477 dwHeight,
478 dwPitchFB,
479 dwColor);
480
481 dwCol = ((dwColor & 0xF8000000) >>16) +
482 ((dwColor & 0x00FE0000)>> 13) +
483 ((dwColor & 0x0000F800)>> 11);
484
485 dwCol = dwCol + (dwCol<<16);
486 Fill16( pDB+(dwTop*dwPitchDB)+(dwLeft*2),
487 dwWidth,
488 dwHeight,
489 dwPitchDB,
490 dwCol);
491}
492 void __cdecl Fill24on32( char *pDB,
493 char *pFB,
494 DWORD dwTop,
495 DWORD dwLeft,
496 DWORD dwWidth,
497 DWORD dwHeight,
498 DWORD dwPitchDB,
499 DWORD dwPitchFB,
500 DWORD dwColor,
501 VOID *pPalette
502 )
503{
504 dprintf(("Fill24on32\n"));
505 //dwColor <<=8;
506
507 Fill24( pFB+(dwTop*dwPitchFB)+(dwLeft*3),
508 dwWidth,
509 dwHeight,
510 dwPitchFB,
511 dwColor);
512 Fill32( pDB+(dwTop*dwPitchDB)+(dwLeft*4),
513 dwWidth,
514 dwHeight,
515 dwPitchDB,
516 dwColor);
517}
518 void __cdecl Fill32on8( char *pDB,
519 char *pFB,
520 DWORD dwTop,
521 DWORD dwLeft,
522 DWORD dwWidth,
523 DWORD dwHeight,
524 DWORD dwPitchDB,
525 DWORD dwPitchFB,
526 DWORD dwColor,
527 VOID *pPalette
528 )
529{
530 dprintf(("Fill32on8 NOT implemented\n"));
531}
532 void __cdecl Fill32on16( char *pDB,
533 char *pFB,
534 DWORD dwTop,
535 DWORD dwLeft,
536 DWORD dwWidth,
537 DWORD dwHeight,
538 DWORD dwPitchDB,
539 DWORD dwPitchFB,
540 DWORD dwColor,
541 VOID *pPalette
542 )
543{
544 DWORD dwCol;
545 dprintf(("Fill32on16\n"));
546
547 Fill32( pFB+(dwTop*dwPitchFB)+(dwLeft*4),
548 dwWidth,
549 dwHeight,
550 dwPitchFB,
551 dwColor);
552
553 dwCol = ((dwColor & 0xF8000000) >>16) +
554 ((dwColor & 0x00FE0000)>> 13) +
555 ((dwColor & 0x0000F800)>> 11);
556
557 dwCol = dwCol + (dwCol<<16);
558 Fill16( pDB+(dwTop*dwPitchDB)+(dwLeft*2),
559 dwWidth,
560 dwHeight,
561 dwPitchDB,
562 dwCol);
563}
564 void __cdecl Fill32on24( char *pDB,
565 char *pFB,
566 DWORD dwTop,
567 DWORD dwLeft,
568 DWORD dwWidth,
569 DWORD dwHeight,
570 DWORD dwPitchDB,
571 DWORD dwPitchFB,
572 DWORD dwColor,
573 VOID *pPalette
574 )
575{
576 dprintf(("Fill32on24\n"));
577 Fill32( pFB+(dwTop*dwPitchFB)+(dwLeft*4),
578 dwWidth,
579 dwHeight,
580 dwPitchFB,
581 dwColor);
582
583 Fill24( pDB+(dwTop*dwPitchDB)+(dwLeft*3),
584 dwWidth,
585 dwHeight,
586 dwPitchDB,
587 dwColor);
588}
589
Note: See TracBrowser for help on using the repository browser.