source: trunk/src/ddraw/new/fillfunc.cpp

Last change on this file was 3345, checked in by mike, 25 years ago

Experimental fullscreen DDraw

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