source: trunk/src/ddraw/asmutil.asm@ 4

Last change on this file since 4 was 4, checked in by ktk, 26 years ago

Import

File size: 2.2 KB
Line 
1; $Id: asmutil.asm,v 1.1 1999-05-24 20:19:37 ktk Exp $
2
3; asmutil.asm Color key bit blitting for DirectDraw
4;
5; Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
6; *
7; * Project Odin Software License can be found in LICENSE.TXT
8; *
9;
10
11.386p
12 NAME asmutil
13
14CODE32 SEGMENT DWORD PUBLIC USE32 'CODE'
15 ASSUME CS:FLAT ,DS:FLAT,SS:FLAT
16
17 PUBLIC _BlitColorKey8
18
19; endpos = destbuf + blitlinesize;
20; while(destbuf < endpos) {
21; if(*srcbuf == colorkey) {
22; destbuf++;
23; }
24; else *destbuf++ = *srcbuf;
25; srcbuf++;
26; }
27; destbuf += (destscanlinesize-blitlinesize);
28; srcbuf += (srcscanlinesize-blitlinesize);
29;void BlitColorKey8(char *dest, char *src, ULONG key, ULONG linesize)
30_BlitColorKey8 PROC NEAR
31 push ebp
32 mov ebp, esp
33 push edi
34 push esi
35 push eax
36 push ebx
37 push ecx
38 push edx
39
40 mov edi, dword ptr [ebp+8] ;dest
41 mov esi, dword ptr [ebp+12] ;src
42 mov ecx, dword ptr [ebp+20] ;linesize
43 mov edx, dword ptr [ebp+16] ;colorkey
44
45 and ecx, 3
46 push ecx ;do the remaining bytes afterwards
47 mov ecx, dword ptr [ebp+20] ;linesize
48 shr ecx, 2 ;linesize in dwords
49
50 ALIGN 16
51
52blitloop:
53 mov ebx, dword ptr [esi]
54 mov eax, dword ptr [edi]
55 cmp bl, dl
56 je skipbyte1
57 mov al, bl
58
59skipbyte1:
60 cmp bh, dl
61 je skipbyte2
62 mov ah, bh
63skipbyte2:
64 ror eax, 16
65 ror ebx, 16
66 cmp bl, dl
67 je skipbyte3
68 mov al, bl
69skipbyte3:
70 cmp bh, dl
71 je skipbyte4
72 mov ah, bh
73skipbyte4:
74 ror eax, 16
75 dec ecx
76 mov dword ptr [edi], eax
77 add esi, 4
78 add edi, 4
79
80 cmp ecx, 0
81 jne blitloop
82
83 pop ecx
84 cmp ecx, 0
85 je endofblit
86
87blitperbyte:
88 mov al, byte ptr [esi]
89 dec ecx
90 cmp al, dl
91 je skipsinglebyte
92 mov byte ptr [edi], al
93skipsinglebyte:
94 inc esi
95 inc edi
96 cmp ecx, 0
97 jne blitperbyte
98
99endofblit:
100 pop edx
101 pop ecx
102 pop ebx
103 pop eax
104 pop esi
105 pop edi
106 pop ebp
107 ret
108_BlitColorKey8 ENDP
109
110CODE32 ENDS
111
112 END
Note: See TracBrowser for help on using the repository browser.