Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6608 | pathoswith | 1 | |
2 | align 4 |
||
3 | ReadGIF.globalColor dd ? |
||
4 | ReadGIF.cur_info dd ? ; image table pointer |
||
5 | ReadGIF.codesize dd ? |
||
6 | ReadGIF.compsize dd ? |
||
7 | ReadGIF.bit_count dd ? |
||
8 | ReadGIF.CC dd ? |
||
9 | ReadGIF.EOI dd ? |
||
10 | ReadGIF.Palette dd ? |
||
11 | ReadGIF.block_ofs dd ? |
||
12 | ReadGIF.gif_workarea rb 16*1024 |
||
13 | endg |
||
14 | |||
15 | |||
16 | ReadGIF: |
||
17 | ; in: |
||
18 | ; esi - pointer to GIF file in memory |
||
19 | ; edi - pointer to output image list |
||
20 | ; out: |
||
21 | ; eax=0 -> ok, eax=1 -> invalid signature |
||
22 | ; eax>=8 -> unsupported image attributes |
||
23 | push esi edi |
||
24 | mov [.cur_info],edi |
||
25 | xor eax,eax |
||
26 | mov [.globalColor],eax |
||
27 | inc eax |
||
28 | cmp dword[esi],'GIF8' |
||
29 | jne .ex ; signature |
||
30 | mov ecx,[esi+0xa] |
||
31 | add esi,0xd |
||
32 | mov edi,esi |
||
33 | test cl,cl |
||
34 | jns .nextblock |
||
35 | mov [.globalColor],esi |
||
36 | call .Gif_skipmap |
||
37 | .nextblock: |
||
38 | cmp byte[edi],0x21 |
||
39 | jne .noextblock |
||
40 | inc edi |
||
41 | inc edi |
||
42 | .block_skip: |
||
43 | movzx eax,byte[edi] |
||
44 | lea edi,[edi+eax+1] |
||
45 | test eax,eax |
||
46 | jnz .block_skip |
||
47 | jmp .nextblock |
||
48 | .noextblock: |
||
49 | mov al,8 |
||
50 | cmp byte[edi],0x2c ; image beginning |
||
51 | jne .ex |
||
52 | inc edi |
||
53 | mov esi,[.cur_info] |
||
54 | xchg esi,edi |
||
55 | movzx eax,word[esi+4] |
||
56 | stosd |
||
57 | movzx eax,word[esi+6] |
||
58 | stosd |
||
59 | add esi,8 |
||
60 | push edi |
||
61 | mov ecx,[esi] |
||
62 | inc esi |
||
63 | test cl,cl |
||
64 | js .uselocal |
||
65 | push [.globalColor] |
||
66 | mov edi,esi |
||
67 | jmp .setPal |
||
68 | .uselocal: |
||
69 | call .Gif_skipmap |
||
70 | push esi |
||
71 | .setPal: |
||
72 | movzx ecx,byte[edi] |
||
73 | inc ecx |
||
74 | mov [.codesize],ecx |
||
75 | dec ecx |
||
76 | pop [.Palette] |
||
77 | lea esi,[edi+1] |
||
78 | mov edi,.gif_workarea |
||
79 | xor eax,eax |
||
80 | lodsb ; eax - block_count |
||
81 | add eax,esi |
||
82 | mov [.block_ofs],eax |
||
83 | mov [.bit_count],8 |
||
84 | mov eax,1 |
||
85 | shl eax,cl |
||
86 | mov [.CC],eax |
||
87 | mov ecx,eax |
||
88 | inc eax |
||
89 | mov [.EOI],eax |
||
90 | mov eax, 1000h shl 16 |
||
91 | .filltable: |
||
92 | stosd |
||
93 | inc eax |
||
94 | loop .filltable |
||
95 | pop edi |
||
96 | .reinit: |
||
97 | mov edx,[.EOI] |
||
98 | inc edx |
||
99 | push [.codesize] |
||
100 | pop [.compsize] |
||
101 | call .Gif_get_sym |
||
102 | cmp eax,[.CC] |
||
103 | je .reinit |
||
104 | call .Gif_output |
||
105 | .cycle: |
||
106 | movzx ebx,ax |
||
107 | call .Gif_get_sym |
||
108 | cmp eax,edx |
||
109 | jae .notintable |
||
110 | cmp eax,[.CC] |
||
111 | je .reinit |
||
112 | cmp eax,[.EOI] |
||
113 | je .end |
||
114 | call .Gif_output |
||
115 | .add: |
||
116 | mov dword [.gif_workarea+edx*4],ebx |
||
117 | cmp edx,0xFFF |
||
118 | jae .cycle |
||
119 | inc edx |
||
120 | bsr ebx,edx |
||
121 | cmp ebx,[.compsize] |
||
122 | jne .noinc |
||
123 | inc [.compsize] |
||
124 | .noinc: |
||
125 | jmp .cycle |
||
126 | .notintable: |
||
127 | push eax |
||
128 | mov eax,ebx |
||
129 | call .Gif_output |
||
130 | push ebx |
||
131 | movzx eax,bx |
||
132 | call .Gif_output |
||
133 | pop ebx eax |
||
134 | jmp .add |
||
135 | .end: |
||
136 | xor eax,eax |
||
137 | .ex: |
||
138 | pop edi esi |
||
139 | ret |
||
140 | |||
141 | |||
142 | ; in: ecx - image descriptor, esi - pointer to colormap |
||
143 | ; out: edi - pointer to area after colormap |
||
144 | and ecx,111b |
||
145 | inc ecx ; color map size |
||
146 | mov ebx,1 |
||
147 | shl ebx,cl |
||
148 | lea ebx,[ebx*2+ebx] |
||
149 | lea edi,[esi+ebx] |
||
150 | ret |
||
151 | |||
152 | |||
153 | mov ecx,[.compsize] |
||
154 | push ecx |
||
155 | xor eax,eax |
||
156 | .shift: |
||
157 | ror byte[esi],1 |
||
158 | rcr eax,1 |
||
159 | dec [.bit_count] |
||
160 | jnz .loop1 |
||
161 | inc esi |
||
162 | cmp esi,[.block_ofs] |
||
163 | jb .noblock |
||
164 | push eax |
||
165 | xor eax,eax |
||
166 | lodsb |
||
167 | test eax,eax |
||
168 | jnz .nextbl |
||
169 | mov eax,[.EOI] |
||
170 | sub esi,2 |
||
171 | add esp,8 |
||
172 | jmp .exx |
||
173 | .nextbl: |
||
174 | add eax,esi |
||
175 | mov [.block_ofs],eax |
||
176 | pop eax |
||
177 | .noblock: |
||
178 | mov [.bit_count],8 |
||
179 | .loop1: |
||
180 | loop .shift |
||
181 | pop ecx |
||
182 | rol eax,cl |
||
183 | .exx: |
||
184 | xor ecx,ecx |
||
185 | ret |
||
186 | |||
187 | |||
188 | push esi eax edx |
||
189 | mov edx,.gif_workarea |
||
190 | .next: |
||
191 | push word[edx+eax*4] |
||
192 | mov ax,word[edx+eax*4+2] |
||
193 | inc ecx |
||
194 | cmp ax,1000h |
||
195 | jnz .next |
||
196 | shl ebx,16 |
||
197 | mov bx,[esp] |
||
198 | .loop2: |
||
199 | pop ax |
||
200 | lea esi,[eax+eax*2] |
||
201 | add esi,[.Palette] |
||
202 | mov esi,[esi] |
||
203 | bswap esi |
||
204 | shr esi,8 |
||
205 | mov [edi],esi |
||
206 | add edi,3 |
||
207 | loop .loop2 |
||
208 | pop edx eax esi |
||
209 | ret |
||
210 |