Rev 552 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | lang equ ru |
2 | |||
3 | ; |
||
4 | ; Assembler |
||
5 | ; SMALL |
||
6 | ; CODE |
||
7 | ; Graphics |
||
8 | ; Libary |
||
9 | ; |
||
9241 | leency | 10 | ; Ver 0.18 |
11 | ; |
||
31 | halyavin | 12 | |
9241 | leency | 13 | ; draw image into image with alpha color mask |
14 | ; image_draw_acimage dest, source, x, y, alpha_color |
||
15 | ; |
||
16 | macro image_draw_acimage dest, source, x, y, alpha_color |
||
17 | { |
||
18 | local next_pix,next_line,skip_pix,no_skip |
||
19 | push dest |
||
20 | push source |
||
21 | push x |
||
22 | push y |
||
23 | push alpha_color |
||
24 | pop ebp ; alpha color |
||
25 | pop eax ; y |
||
26 | pop ebx ; x |
||
27 | pop esi ; src |
||
28 | pop edi ; dest |
||
29 | call image_draw_acimage_proc |
||
31 | halyavin | 30 | |
9241 | leency | 31 | if ~ defined image_draw_acimage_used |
32 | image_draw_acimage_used equ 1 |
||
33 | |||
34 | jmp end_image_draw_acimage_proc |
||
35 | image_draw_acimage_proc: |
||
36 | mov ecx,dword [edi] ; ecx = canvas width |
||
37 | mul ecx ; edx:eax = ypos * canvas width |
||
38 | add eax,ebx ; eax = (ypos * canvas width) + xpos |
||
39 | lea eax,[eax+eax*2+8] ; eax=(y*xsize+x)*3+8 (8=skip xy size dwords) |
||
40 | |||
41 | mov edx,[esi] ; edx = img width |
||
42 | sub ecx,edx ; ecx = canvas width - img width |
||
43 | lea ebx,[ecx*2+ecx] ; ebx = how many pixels skip for new line |
||
44 | mov ecx,[esi+4] ; ecx = img height |
||
45 | add esi,8 ; esi + 8 for skip xy size dwords |
||
46 | add edi,eax ; edi = dest position |
||
47 | shl ebp,8 ; for fast compare with alpha color |
||
48 | cld ; set movs direction flag |
||
49 | next_line: |
||
50 | push edx |
||
51 | next_pix: |
||
52 | mov eax,[esi] |
||
53 | shl eax,8 |
||
54 | cmp eax,ebp |
||
55 | je skip_pix |
||
56 | movsw |
||
57 | movsb |
||
58 | jmp no_skip |
||
59 | skip_pix: |
||
60 | add esi,3 |
||
61 | add edi,3 |
||
62 | no_skip: |
||
63 | dec edx |
||
64 | jnz next_pix |
||
65 | pop edx |
||
66 | add edi,ebx |
||
67 | dec ecx |
||
68 | jnz next_line |
||
69 | ret |
||
70 | end_image_draw_acimage_proc : |
||
71 | end if |
||
72 | |||
73 | } |
||
74 | |||
75 | macro image_set_size image,width,height |
||
76 | { |
||
77 | mov dword [image],width |
||
78 | mov dword [image+4],height |
||
79 | } |
||
80 | |||
81 | ; label - draw label on window |
||
82 | ; example: |
||
83 | ; label 10,12,'Hello World!',cl_Green+font_size_x4+utf16 |
||
84 | |||
85 | macro image_draw_label image,x,y,text,color |
||
86 | { |
||
87 | local label_text |
||
88 | draw_to_buffer equ 00001000b shl 24 |
||
89 | jmp @f |
||
90 | label_text db text |
||
91 | @@: |
||
92 | words2reg ebx,x,y ; ebx - position |
||
93 | dword2reg ecx,color+draw_to_buffer ; ecx - color |
||
94 | mov edi,image |
||
95 | mov edx,label_text ; edx - address of label text |
||
96 | mov esi,@b-label_text ; esi - size of libel in bytes |
||
97 | mov eax,4 |
||
98 | mcall |
||
99 | } |
||
100 | |||
101 | ; draw_frect - draw filled rect |
||
102 | macro draw_frect x,y,xs,ys,color |
||
103 | { |
||
104 | wordstoreg ebx,x,xs ;x*65536+xs |
||
105 | wordstoreg ecx,y,ys ;y*65536+ys |
||
106 | mov edx,color |
||
107 | mov eax,13 |
||
108 | mcall |
||
109 | } |
||
110 | |||
111 | ; draw_label - Draw label in window |
||
112 | ; example: |
||
113 | ; draw_label 10,12,'Hello World!',cl_Green+font_size_x4+utf16 |
||
114 | |||
115 | macro draw_label x,y,text,color |
||
116 | { |
||
117 | local label_text |
||
118 | words2reg ebx,x,y ; ebx - position |
||
119 | if text eqtype 123 | text eqtype eax |
||
120 | movt edx,text |
||
121 | mov ecx,color+(1 shl 31) ; ecx - color |
||
122 | else |
||
123 | mov edx,label_text ; edx - address of label text |
||
124 | jmp @f |
||
125 | label_text db text |
||
126 | @@: |
||
127 | mov esi,@b-label_text ; esi - size of libel in bytes |
||
128 | movt ecx,color ; ecx - color |
||
129 | end if |
||
130 | mov eax,4 |
||
131 | mcall |
||
132 | } |
||
133 | |||
134 | hide_zeros equ (1 shl 31) |
||
135 | use_bg_color equ (1 shl 30) |
||
136 | use_big_font equ (1 shl 28) |
||
137 | |||
138 | macro draw_number data, x, y, color, numtype, bg_color |
||
139 | { |
||
140 | movt ecx,data |
||
141 | movt ebx,numtype |
||
142 | mov bl,0 ; if bl = 0, ecx is contain number |
||
143 | words2reg edx,x,y |
||
144 | if bg_color eq |
||
145 | movt esi,color |
||
146 | else |
||
147 | movt esi,color+use_bg_color |
||
148 | movt edi,bg_color |
||
149 | end if |
||
150 | mov eax,47 |
||
151 | mcall |
||
152 | } |
||
153 | |||
154 | ; draw_image - macro for draw image on window area |
||
155 | macro draw_image x, y, image |
||
156 | { |
||
157 | mov ecx,[image-2] ; -2 for except shl ecx,16 |
||
158 | mov cx,[image+4] ; ecx = xsize*65536+ysize |
||
159 | wordstoreg edx, x, y ; edx = x*65536+y |
||
160 | lea ebx,[image+8] ; ebx = image data address |
||
161 | mov eax,7 ; eax = 7 is draw image function |
||
162 | mcall |
||
163 | } |
||
164 | |||
31 | halyavin | 165 | aframetoimg_use_count=0 |
166 | macro aframetoimg img, x, y, canvas,acol |
||
167 | { |
||
168 | local loo,loo2,acolor |
||
169 | aframetoimg_use_count=aframetoimg_use_count+1 |
||
170 | if aframetoimg_use_count = 1 |
||
171 | |||
9241 | leency | 172 | jmp end_aframetoimg_proc |
31 | halyavin | 173 | |
174 | acolor dd 0 |
||
175 | aframetoimg_proc: |
||
176 | ;getout coord |
||
9241 | leency | 177 | mov [acolor],ebp |
31 | halyavin | 178 | |
9241 | leency | 179 | mov edx,ebx ;img ;xsize |
180 | movzx eax,word [edx] |
||
181 | add eax,esi ;y cor |
||
31 | halyavin | 182 | |
183 | ; mov eax,esi ;y cor |
||
9241 | leency | 184 | mul dword [ecx] ;canvas xsize |
185 | add eax,edi ;x cor |
||
31 | halyavin | 186 | |
9241 | leency | 187 | mov ebp,ebx ;img ;xsize |
188 | movzx edx,word [ebp] |
||
189 | add eax,edx |
||
31 | halyavin | 190 | |
9241 | leency | 191 | mov ebp,eax |
192 | shl eax,1 |
||
193 | add ebp,eax |
||
194 | add ebp,ecx ;canvas+8;start |
||
195 | add ebp,8 |
||
31 | halyavin | 196 | ;get img size |
9241 | leency | 197 | add ebx,4 |
198 | mov eax,ebx ;img ;xsize |
||
199 | movzx esi,word [eax] |
||
200 | movzx edi,word [eax+2] |
||
201 | add ebx,4 |
||
202 | mov edx,ebx ;img+8 |
||
31 | halyavin | 203 | loo2: |
204 | push esi |
||
205 | loo: |
||
206 | ;test on alpha color |
||
9241 | leency | 207 | mov eax,[edx] |
208 | shl eax,8 |
||
209 | shr eax,8 |
||
210 | cmp eax,[acolor] |
||
211 | jne yx |
||
212 | add edx,3 |
||
213 | add ebp,3 |
||
214 | jmp nx |
||
31 | halyavin | 215 | yx: |
9241 | leency | 216 | mov al,byte [edx] |
217 | mov byte [ebp],al |
||
218 | inc ebp |
||
219 | inc edx |
||
220 | mov al,byte [edx] |
||
221 | mov byte [ebp],al |
||
222 | inc ebp |
||
223 | inc edx |
||
224 | mov al,byte [edx] |
||
225 | mov byte [ebp],al |
||
226 | inc ebp |
||
227 | inc edx |
||
31 | halyavin | 228 | nx: |
9241 | leency | 229 | dec esi |
230 | jnz loo |
||
31 | halyavin | 231 | pop esi |
9241 | leency | 232 | sub ebp,3 |
233 | mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3) |
||
234 | sub eax,esi |
||
235 | add ebp,eax |
||
236 | shl eax,1 |
||
237 | add ebp,eax |
||
31 | halyavin | 238 | |
9241 | leency | 239 | add ebp,3 |
31 | halyavin | 240 | |
9241 | leency | 241 | dec edi |
242 | jnz loo2 |
||
243 | ret |
||
31 | halyavin | 244 | end_aframetoimg_proc: |
245 | end if |
||
9241 | leency | 246 | push img |
247 | push canvas |
||
248 | push x |
||
249 | push y |
||
250 | push acol |
||
251 | pop ebp |
||
252 | pop esi |
||
253 | pop edi |
||
254 | pop ecx |
||
255 | pop ebx |
||
256 | call aframetoimg_proc |
||
31 | halyavin | 257 | } |
258 | |||
259 | frametoimg_use_count=0 |
||
260 | macro frametoimg img, x, y, canvas |
||
261 | { |
||
262 | local loo,loo2 |
||
263 | frametoimg_use_count=frametoimg_use_count+1 |
||
264 | if frametoimg_use_count = 1 |
||
265 | |||
9241 | leency | 266 | jmp end_frametoimg_proc |
31 | halyavin | 267 | |
268 | frametoimg_proc: |
||
269 | ;getout coord |
||
9241 | leency | 270 | mov edx,ebx ;img ;xsize |
271 | movzx eax,word [edx] |
||
272 | add eax,esi ;y cor |
||
31 | halyavin | 273 | |
274 | ; mov eax,esi ;y cor |
||
9241 | leency | 275 | mul dword [ecx] ;canvas xsize |
276 | add eax,edi ;x cor |
||
31 | halyavin | 277 | |
9241 | leency | 278 | mov ebp,ebx ;img ;xsize |
279 | movzx edx,word [ebp] |
||
280 | add eax,edx |
||
31 | halyavin | 281 | |
9241 | leency | 282 | mov ebp,eax |
283 | shl eax,1 |
||
284 | add ebp,eax |
||
285 | add ebp,ecx ;canvas+8;start |
||
286 | add ebp,8 |
||
31 | halyavin | 287 | ;get img size |
9241 | leency | 288 | add ebx,4 |
289 | mov eax,ebx ;img ;xsize |
||
290 | movzx esi,word [eax] |
||
291 | movzx edi,word [eax+2] |
||
292 | add ebx,4 |
||
293 | mov edx,ebx ;img+8 |
||
31 | halyavin | 294 | loo2: |
295 | push esi |
||
296 | loo: |
||
9241 | leency | 297 | mov al,byte [edx] |
298 | mov byte [ebp],al |
||
299 | inc ebp |
||
300 | inc edx |
||
301 | mov al,byte [edx] |
||
302 | mov byte [ebp],al |
||
303 | inc ebp |
||
304 | inc edx |
||
305 | mov al,byte [edx] |
||
306 | mov byte [ebp],al |
||
307 | inc ebp |
||
308 | inc edx |
||
31 | halyavin | 309 | |
9241 | leency | 310 | dec esi |
311 | jnz loo |
||
31 | halyavin | 312 | pop esi |
9241 | leency | 313 | sub ebp,3 |
314 | mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3) |
||
315 | sub eax,esi |
||
316 | add ebp,eax |
||
317 | shl eax,1 |
||
318 | add ebp,eax |
||
31 | halyavin | 319 | |
9241 | leency | 320 | add ebp,3 |
31 | halyavin | 321 | |
9241 | leency | 322 | dec edi |
323 | jnz loo2 |
||
324 | ret |
||
31 | halyavin | 325 | end_frametoimg_proc: |
326 | end if |
||
9241 | leency | 327 | push img |
328 | push canvas |
||
329 | push x |
||
330 | push y |
||
331 | pop esi |
||
332 | pop edi |
||
333 | pop ecx |
||
334 | pop ebx |
||
335 | call frametoimg_proc |
||
31 | halyavin | 336 | } |
337 | |||
338 | |||
339 | imgtoimg_use_count=0 |
||
340 | macro imgtoimg img, x, y, canvas |
||
341 | { |
||
342 | local loo,loo2 |
||
343 | imgtoimg_use_count=imgtoimg_use_count+1 |
||
344 | if imgtoimg_use_count = 1 |
||
345 | |||
9241 | leency | 346 | jmp end_imgtoimg_proc |
31 | halyavin | 347 | imgtoimg_proc: |
348 | ;getout coord |
||
9241 | leency | 349 | mov eax,esi ;y cor |
350 | mul dword [ecx] ;canvas xsize |
||
351 | add eax,edi ;x cor |
||
352 | mov ebp,eax |
||
353 | shl eax,1 |
||
354 | add ebp,eax |
||
355 | add ebp,ecx ;canvas+8;start |
||
356 | add ebp,8 |
||
31 | halyavin | 357 | ;get img size |
9241 | leency | 358 | mov eax,ebx ;img ;xsize |
359 | mov esi,[eax] |
||
360 | add ebx,4 |
||
361 | mov eax,ebx ; img+4 ;ysize |
||
362 | mov edi,[eax] |
||
363 | add ebx,4 |
||
364 | mov edx,ebx ;img+8 |
||
31 | halyavin | 365 | loo2: |
366 | push esi |
||
367 | loo: |
||
9241 | leency | 368 | mov al,byte [edx] |
369 | mov byte [ebp],al |
||
370 | inc ebp |
||
371 | inc edx |
||
372 | mov al,byte [edx] |
||
373 | mov byte [ebp],al |
||
374 | inc ebp |
||
375 | inc edx |
||
376 | mov al,byte [edx] |
||
377 | mov byte [ebp],al |
||
378 | inc ebp |
||
379 | inc edx |
||
380 | dec esi |
||
381 | jnz loo |
||
31 | halyavin | 382 | pop esi |
9241 | leency | 383 | sub ebp,3 |
384 | mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3) |
||
385 | sub eax,esi |
||
386 | add ebp,eax |
||
387 | shl eax,1 |
||
388 | add ebp,eax |
||
389 | add ebp,3 |
||
390 | dec edi |
||
391 | jnz loo2 |
||
392 | ret |
||
31 | halyavin | 393 | end_imgtoimg_proc: |
394 | end if |
||
9241 | leency | 395 | push img |
396 | push canvas |
||
397 | push x |
||
398 | push y |
||
399 | pop esi |
||
400 | pop edi |
||
401 | pop ecx |
||
402 | pop ebx |
||
403 | call imgtoimg_proc |
||
31 | halyavin | 404 | } |
405 | |||
406 | ; FPS - Set Frame Per Second Display |
||
407 | fps_show_frequency=40 |
||
408 | macro fps x,y,color,delcolor |
||
409 | { |
||
410 | local spdat,savetime,new_time,fps,fps_cntr,out_fps,new_time,ttt |
||
411 | local no_out_fps |
||
9241 | leency | 412 | jmp spdat |
31 | halyavin | 413 | savetime dd 0 |
414 | fps_cntr dd 0 |
||
415 | fps dd 0 |
||
416 | ttt dd 0 |
||
417 | spdat: |
||
418 | get_time: |
||
9241 | leency | 419 | mov eax,3 |
420 | mcall |
||
421 | cmp eax,[savetime] |
||
422 | jne new_time |
||
423 | inc [fps_cntr] |
||
424 | cmp dword [ttt],0 |
||
425 | je out_fps |
||
426 | dec dword [ttt] |
||
427 | jmp no_out_fps |
||
31 | halyavin | 428 | new_time: |
9241 | leency | 429 | mov [savetime],eax |
430 | mov ebx,[fps_cntr] |
||
431 | mov [fps],ebx |
||
432 | mov [fps_cntr],0 |
||
31 | halyavin | 433 | out_fps: |
434 | if ~(delcolor eq ) |
||
9241 | leency | 435 | mov ebx,x*65536+30 |
436 | mov ecx,y*65536+7 |
||
437 | mov edx,delcolor |
||
438 | mov eax,13 |
||
439 | mcall |
||
31 | halyavin | 440 | end if |
9241 | leency | 441 | mov dword [ttt],fps_show_frequency |
442 | mov eax,47 |
||
443 | mov ebx,5*65536 |
||
444 | ; mov bl,0 |
||
445 | mov edx,x*65536+y |
||
446 | mov esi,color |
||
447 | mov ecx,[fps] |
||
448 | mcall |
||
31 | halyavin | 449 | no_out_fps: |
450 | } |
||
451 | |||
452 | macro rgbtobgr image |
||
453 | { |
||
9241 | leency | 454 | mov eax,[image] |
455 | mul dword [image+4] |
||
456 | mov ecx,eax |
||
457 | mov esi,image+8 |
||
458 | @@: |
||
31 | halyavin | 459 | mov al,[esi] |
460 | mov bl,[esi+2] |
||
461 | mov [esi],bl |
||
462 | mov [esi+2],al |
||
463 | add esi,3 |
||
464 | dec ecx |
||
9241 | leency | 465 | jnz @b |
31 | halyavin | 466 | } |
467 | |||
468 | macro setframe x , y ,arg3 |
||
469 | { |
||
9241 | leency | 470 | mov eax,7 |
471 | mov ebx,arg3 |
||
472 | add ebx,8 |
||
473 | wordstoreg edx, x , y ;arg1*65536+arg2 |
||
474 | add edx,dword [arg3] |
||
475 | mov ecx,dword [arg3+4] |
||
476 | mcall |
||
31 | halyavin | 477 | } |
478 | |||
479 | |||
480 | macro getimg imgsrc,x,y,xs,ys,imgdest |
||
481 | { |
||
9241 | leency | 482 | local next_pixel,next_line |
483 | ; store image size |
||
484 | if xs eqtype 0 | xs eqtype eax |
||
485 | mov dword [imgdest],xs |
||
31 | halyavin | 486 | else |
9241 | leency | 487 | mov eax,xs |
488 | mov dword [imgdest],eax |
||
31 | halyavin | 489 | end if |
9241 | leency | 490 | if ys eqtype 0 | ys eqtype eax |
491 | mov dword [imgdest+4],ys |
||
31 | halyavin | 492 | else |
9241 | leency | 493 | ;push ys |
494 | ;pop dword [imgdest+4] |
||
495 | mov eax,ys |
||
496 | mov dword [imgdest+4],eax |
||
31 | halyavin | 497 | end if |
498 | |||
9241 | leency | 499 | lea edi,[8+imgdest] ; edi = destinaton address |
500 | mov eax,dword [imgsrc] ; eax = xsize of source image in pixels |
||
501 | push eax ; store eax before mul operation |
||
502 | mov edx,y |
||
503 | mul edx ; edx:eax = eax*edx |
||
504 | add eax,x |
||
505 | lea esi,[imgsrc+8+eax+2*eax] ; esi = start offset on img src |
||
506 | pop eax ; restore eax |
||
507 | sub eax,xs ; eax = src image xsize - crop fragment xsize |
||
508 | lea eax,[eax+eax*2] ; eax = eax * 3 (bytes per pixel) |
||
31 | halyavin | 509 | |
9241 | leency | 510 | ; this loop used esi,edi,ecx,edx,eax registers |
511 | mov edx,ys ; edx = ysize in pixels |
||
512 | cld ; set direction |
||
513 | next_line: |
||
514 | mov ecx,xs ; ecx = xsize in pixels |
||
515 | next_pixel: |
||
516 | movsw |
||
517 | movsb ; write 3 bytes pixel |
||
518 | dec ecx |
||
519 | jnz next_pixel |
||
520 | add esi,eax |
||
521 | dec edx |
||
522 | jnz next_line |
||
31 | halyavin | 523 | } |
524 | |||
525 | macro copyimg img2_off,img1_off |
||
526 | { |
||
9241 | leency | 527 | mov eax,dword [img1_off] |
528 | mov ebx,dword [img1_off+4] |
||
529 | mul ebx |
||
530 | lea ecx,[eax+2*eax] |
||
531 | lea esi,[img1_off+8] |
||
532 | lea edi,[img2_off+8] |
||
533 | cld |
||
534 | rep movsb |
||
31 | halyavin | 535 | } |
536 | |||
537 | macro fullimg img_off,xs,ys,color |
||
538 | { |
||
539 | local cop |
||
9241 | leency | 540 | mov eax,xs |
541 | mov ebx,ys |
||
542 | mov dword [img_off],eax |
||
543 | mov dword [img_off+4],ebx |
||
544 | mul ebx |
||
545 | lea ebp,[eax+2*eax] |
||
546 | mov esi,color |
||
31 | halyavin | 547 | if color eqtype 0 |
9241 | leency | 548 | mov ecx,color/65536 |
31 | halyavin | 549 | else |
9241 | leency | 550 | mov ecx,esi |
551 | shr ecx,16 |
||
31 | halyavin | 552 | end if |
9241 | leency | 553 | xor edi,edi |
31 | halyavin | 554 | cop: |
9241 | leency | 555 | mov word [img_off+8+edi],si |
556 | add edi,2 |
||
557 | mov byte [img_off+8+edi],cl |
||
558 | inc edi |
||
559 | cmp edi,ebp |
||
560 | jne cop |
||
31 | halyavin | 561 | } |
562 | |||
9241 | leency | 563 | ; number of frame in ecx |
564 | ; callculatin offset of raw data |
||
31 | halyavin | 565 | |
566 | macro getframeoff num_of_frame,offset_of_animation,offset_of_frame |
||
567 | { |
||
568 | local loo,setpic |
||
569 | mov ebp,num_of_frame ;ecx |
||
570 | mov esi,offset_of_animation;Image |
||
571 | loo: |
||
572 | cmp ebp,0 |
||
573 | je setpic |
||
574 | movzx eax,word [esi+4] |
||
575 | movzx ebx,word [esi+6] |
||
576 | mul ebx ;dword [esi+4] |
||
577 | mov ebx,3 |
||
578 | mul ebx |
||
579 | add eax,8 |
||
580 | add esi,eax |
||
581 | dec ebp |
||
582 | jmp loo |
||
583 | setpic: |
||
584 | mov dword offset_of_frame,esi |
||
585 | } |
||
586 | |||
587 | ; BMPTOIMG -Convert BMP format TO IMG format |
||
588 | ; (SYNTAX) BMPTOIMG BMP_source_offset,IMG_dest_ofset |
||
589 | ; (SAMPLE) View BMPLS.ASM sample. |
||
9241 | leency | 590 | ; ( NOTE ) This is macro is not brake bmp structure! Tested in 32,8,4 bits |
31 | halyavin | 591 | |
592 | bmptoimg_data_area_count=0 |
||
593 | macro bmptoimg bmp_load_area,img_dest_area |
||
594 | { |
||
595 | local fileinfo,string,end_bmp,nodix |
||
596 | local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2 |
||
597 | local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize |
||
598 | ;local qwe,bmpfn |
||
599 | |||
600 | ; convert: |
||
9241 | leency | 601 | movzx eax,word [bmp_load_area+28] |
602 | mul dword [bmp_load_area+18] |
||
603 | add eax,31 |
||
604 | shr eax,5 |
||
605 | mov dword [bmptoimg_data_area_dwps],eax ;dwps-doublewords per string |
||
606 | shl eax,2 |
||
607 | mov dword [bmptoimg_data_area_bps],eax ;bps-bytes per string |
||
31 | halyavin | 608 | |
9241 | leency | 609 | cmp dword [bmp_load_area+34],0 |
610 | jne yespicsize ;if picture size is defined |
||
611 | mul dword [bmp_load_area+22] |
||
612 | mov dword [bmp_load_area+34],eax |
||
31 | halyavin | 613 | |
9241 | leency | 614 | yespicsize: |
615 | mov ebp,img_dest_area+8 |
||
31 | halyavin | 616 | |
9241 | leency | 617 | mov eax,bmp_load_area |
618 | mov ebx,eax |
||
619 | add ebx, [bmp_load_area+2];file size |
||
620 | inc ebx |
||
621 | mov dword [bmptoimg_soi],ebx ;soi-start of image area for drawing |
||
31 | halyavin | 622 | |
9241 | leency | 623 | add eax, [bmp_load_area+10] |
624 | mov dword [bmptoimg_data_area_sop],eax ;sop-start of picture in file |
||
625 | add eax, [bmp_load_area+34] |
||
626 | mov dword [bmptoimg_data_area_eop],eax ;eop-end of picture in file |
||
627 | mov eax, [bmp_load_area+18] |
||
628 | lea eax,[eax+2*eax] ;3x pixels in eax |
||
31 | halyavin | 629 | |
9241 | leency | 630 | mov edi,dword [bmptoimg_soi] ;initializing |
631 | mov esi,dword [bmptoimg_data_area_eop] |
||
632 | sub esi,dword [bmptoimg_data_area_bps] |
||
31 | halyavin | 633 | |
634 | |||
9241 | leency | 635 | nextstring: |
636 | push edi |
||
637 | push ebp |
||
638 | cmp word [bmp_load_area+28],24 |
||
639 | jne convertno32 |
||
31 | halyavin | 640 | |
9241 | leency | 641 | mov edi,ebp |
642 | mov ecx,[bmptoimg_data_area_dwps] |
||
643 | cld |
||
644 | rep movsd |
||
31 | halyavin | 645 | |
9241 | leency | 646 | convert1: |
647 | pop ebp |
||
648 | pop edi |
||
649 | sub esi,dword [bmptoimg_data_area_bps] |
||
650 | sub esi,dword [bmptoimg_data_area_bps] |
||
651 | cmp esi,dword [bmptoimg_data_area_sop] |
||
652 | jb end_bmp |
||
653 | add edi,eax |
||
654 | add ebp,eax |
||
655 | jmp nextstring |
||
31 | halyavin | 656 | |
9241 | leency | 657 | convertno32: |
658 | mov ebx,bmp_load_area |
||
659 | add ebx, [bmp_load_area+14] |
||
660 | add ebx,14 ;start of color table |
||
661 | push esi |
||
662 | add esi,dword [bmptoimg_data_area_bps] |
||
663 | mov dword [bmptoimg_data_area_eos],esi |
||
664 | pop esi |
||
665 | nextelem: |
||
666 | push eax |
||
667 | movzx eax,byte [esi] |
||
668 | cmp word [bmp_load_area+28],4 |
||
669 | je convert4bpp |
||
670 | cmp word [bmp_load_area+28],1 |
||
671 | je convert1bpp |
||
672 | call converttable |
||
31 | halyavin | 673 | |
9241 | leency | 674 | convert2: |
675 | pop eax |
||
676 | inc esi |
||
677 | cmp esi,dword [bmptoimg_data_area_eos] |
||
678 | jae convert1 |
||
679 | add edi,3 |
||
680 | add ebp,3 |
||
681 | jmp nextelem |
||
31 | halyavin | 682 | |
9241 | leency | 683 | convert4bpp: |
684 | shl ax,4 |
||
685 | shr al,4 |
||
686 | push ax |
||
687 | movzx eax,ah |
||
688 | call converttable |
||
689 | add edi,3 |
||
690 | add ebp,3 |
||
691 | pop ax |
||
692 | movzx eax,al |
||
693 | call converttable |
||
694 | jmp convert2 |
||
31 | halyavin | 695 | |
9241 | leency | 696 | convert1bpp: |
697 | mov ecx,eax |
||
698 | mov edx,7 |
||
699 | nextbit: |
||
700 | xor eax,eax |
||
701 | bt ecx,edx |
||
702 | jnc noaddelem |
||
703 | inc eax |
||
704 | noaddelem: |
||
705 | push edx |
||
706 | call converttable |
||
707 | pop edx |
||
708 | dec edx |
||
709 | js convert2 |
||
710 | add edi,3 |
||
711 | add ebp,3 |
||
712 | jmp nextbit |
||
713 | converttable: |
||
714 | shl eax,2 |
||
715 | add eax,ebx |
||
716 | mov edx, dword [eax] |
||
717 | ; mov dword [edi],edx |
||
718 | mov [ebp],edx |
||
719 | ret |
||
31 | halyavin | 720 | |
721 | bmptoimg_data_area_count=bmptoimg_data_area_count+1 |
||
722 | if bmptoimg_data_area_count = 1 |
||
723 | ; DATA AREA |
||
724 | bmptoimg_soi dd 0 |
||
725 | bmptoimg_data_area_bps dd 0 |
||
726 | bmptoimg_data_area_dwps dd 0 |
||
727 | bmptoimg_data_area_sop dd 0 |
||
728 | bmptoimg_data_area_eop dd 0 |
||
729 | bmptoimg_data_area_eos dd 0 |
||
730 | end if |
||
731 | |||
732 | end_bmp: |
||
9241 | leency | 733 | mov eax,dword [bmp_load_area+18] |
734 | mov ebx,dword [bmp_load_area+22] |
||
735 | mov dword [img_dest_area],eax |
||
736 | mov dword [img_dest_area+4],ebx |
||
31 | halyavin | 737 | } |
738 | |||
552 | diamond | 739 | if used ReadGIF |
31 | halyavin | 740 | ; For convert RGB to BGR |
741 | COLOR_ORDER equ MENUETOS |
||
552 | diamond | 742 | include 'gif_lite.inc' |
743 | end if |
||
31 | halyavin | 744 | |
745 | macro giftoani gifsrc,imgsrc,num_of_frames |
||
746 | { |
||
552 | diamond | 747 | gif_img_count = num_of_frames |
9241 | leency | 748 | mov esi, gifsrc |
749 | mov edi, imgsrc |
||
750 | call ReadGIF |
||
31 | halyavin | 751 | } |
752 | |||
753 | macro giftoimg gifsrc,imgsrc |
||
754 | { |
||
552 | diamond | 755 | if defined gif_img_count |
756 | error 'giftoimg cannot be used in GIF multiple images mode. Use giftoani instead.' |
||
757 | end if |
||
9241 | leency | 758 | mov esi, gifsrc |
759 | mov edi, imgsrc |
||
760 | call ReadGIF |
||
31 | halyavin | 761 | } |