Rev 1921 | Rev 2733 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1921 | Rev 2388 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;================================================================================================;; |
1 | ;;================================================================================================;; |
2 | ;;//// xcf.asm //// (c) dunkaist, 2011 ///////////////////////////////////////////////////////////;; |
2 | ;;//// xcf.asm //// (c) dunkaist, 2011-2012 //////////////////////////////////////////////////////;; |
3 | ;;================================================================================================;; |
3 | ;;================================================================================================;; |
4 | ;; ;; |
4 | ;; ;; |
5 | ;; This file is part of Common development libraries (Libs-Dev). ;; |
5 | ;; This file is part of Common development libraries (Libs-Dev). ;; |
6 | ;; ;; |
6 | ;; ;; |
7 | ;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; |
7 | ;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; |
Line 25... | Line 25... | ||
25 | ;; from docs.gimp.org ;; |
25 | ;; from docs.gimp.org ;; |
26 | ;; http://docs.gimp.org/en/gimp-concepts-layer-modes.html ;; |
26 | ;; http://docs.gimp.org/en/gimp-concepts-layer-modes.html ;; |
27 | ;; ;; |
27 | ;; ;; |
28 | ;;================================================================================================;; |
28 | ;;================================================================================================;; |
29 | include 'xcf.inc' |
29 | include 'xcf.inc' |
30 | ;include '../../../../system/board/trunk/debug.inc' |
30 | ;include '../../../../../system/board/trunk/debug.inc' |
Line 31... | Line 31... | ||
31 | 31 | ||
- | 32 | COMPOSITE_MODE equ MMX |
|
- | 33 | ; MMX | pretty fast and compatible |
|
Line 32... | Line 34... | ||
32 | COMPOSITE_MODE equ MMX |
34 | ; SSE | a bit faster, but may be unsupported by some CPUs |
33 | - | ||
34 | MAX_LAYERS equ 255 |
- | |
35 | - | ||
Line 36... | Line 35... | ||
36 | DEBUG_STANDARD equ TRUE |
35 | |
37 | DEBUG_FBOUNDS equ FALSE |
36 | MAX_LAYERS = 255 |
38 | 37 | ||
39 | ;;================================================================================================;; |
38 | ;;================================================================================================;; |
Line 73... | Line 72... | ||
73 | inc eax |
72 | inc eax |
Line 74... | Line 73... | ||
74 | 73 | ||
75 | .is_not_xcf: |
74 | .is_not_xcf: |
76 | pop edi |
75 | pop edi |
77 | ret |
- | |
78 | 76 | ret |
|
Line -... | Line 77... | ||
- | 77 | endp |
|
79 | endp |
78 | |
80 | 79 | ||
81 | ;;================================================================================================;; |
80 | ;;================================================================================================;; |
82 | proc img.decode.xcf _data, _length, _options ;////////////////////////////////////////////////////;; |
81 | proc img.decode.xcf _data, _length, _options ;////////////////////////////////////////////////////;; |
83 | ;;------------------------------------------------------------------------------------------------;; |
82 | ;;------------------------------------------------------------------------------------------------;; |
Line 87... | Line 86... | ||
87 | ;> _length = data length ;; |
86 | ;> _length = data length ;; |
88 | ;;------------------------------------------------------------------------------------------------;; |
87 | ;;------------------------------------------------------------------------------------------------;; |
89 | ;< eax = 0 (error) or pointer to image ;; |
88 | ;< eax = 0 (error) or pointer to image ;; |
90 | ;;================================================================================================;; |
89 | ;;================================================================================================;; |
91 | locals |
90 | locals |
92 | count rd 1 |
91 | layer_count rd 1 |
93 | retvalue rd 1 ; 0 (error) or pointer to image |
92 | retvalue rd 1 |
94 | endl |
93 | endl |
Line 95... | Line 94... | ||
95 | 94 | ||
Line 96... | Line 95... | ||
96 | push ebx esi edi |
95 | push ebx esi edi |
Line 147... | Line 146... | ||
147 | mov [ebx + Image.Data], eax |
146 | mov [ebx + Image.Data], eax |
148 | add [ebx + Image.Palette], eax |
147 | add [ebx + Image.Palette], eax |
Line 149... | Line 148... | ||
149 | 148 | ||
150 | mov edi, [ebx+Image.Palette] |
149 | mov edi, [ebx + Image.Palette] |
- | 150 | mov eax, 0xff000000 |
|
151 | mov eax, 0xff000000 |
151 | @@: |
152 | @@: stosd |
152 | stosd |
153 | add eax, 0x00010101 |
153 | add eax, 0x00010101 |
Line 154... | Line 154... | ||
154 | jnc @b |
154 | jnc @b |
Line 186... | Line 186... | ||
186 | jz .error |
186 | jz .error |
187 | mov [ebx+Image.Extended], eax |
187 | mov [ebx + Image.Extended], eax |
188 | mov [eax+xcf_ext.opacity], 0xffffffff |
188 | mov [eax + xcf_ext.opacity], 0xffffffff |
189 | mov [eax+xcf_ext.type], edx |
189 | mov [eax + xcf_ext.type], edx |
Line 190... | Line 190... | ||
190 | 190 | ||
Line 191... | Line 191... | ||
191 | stdcall parse_properties, ebx |
191 | stdcall xcf._.parse_properties, ebx |
192 | 192 | ||
193 | mov edi, esi |
193 | mov edi, esi |
194 | mov eax, 0 |
194 | xor eax, eax |
195 | mov ecx, MAX_LAYERS |
195 | mov ecx, MAX_LAYERS |
196 | mov [count], MAX_LAYERS-1 |
196 | mov [layer_count], MAX_LAYERS-1 |
197 | repne scasd |
197 | repne scasd |
198 | sub [count], ecx |
198 | sub [layer_count], ecx |
Line -... | Line 199... | ||
- | 199 | mov esi, edi |
|
199 | mov esi, edi |
200 | xor ecx, ecx |
200 | mov ecx, 0 |
201 | |
201 | 202 | .still: |
|
Line 202... | Line 203... | ||
202 | .still: sub esi, 8 |
203 | sub esi, 8 |
203 | lodsd |
204 | lodsd |
204 | bswap eax |
205 | bswap eax |
205 | 206 | ||
206 | push ecx |
207 | push ecx |
207 | stdcall decode_layer, eax, [_data] |
208 | stdcall xcf._.decode_layer, eax, [_data] |
208 | pop ecx |
209 | pop ecx |
209 | test eax, eax |
210 | test eax, eax |
210 | jz @f |
211 | jz @f |
- | 212 | push ecx |
|
211 | push ecx |
213 | stdcall xcf._.merge_down, eax, [retvalue], ecx |
212 | stdcall merge_down, eax, [retvalue], ecx |
214 | pop ecx |
213 | pop ecx |
- | |
214 | add ecx, 1 |
- | |
Line 215... | Line 215... | ||
215 | @@: dec [count] |
215 | add ecx, 1 |
216 | jnz .still |
216 | @@: |
217 | ; jmp .quit |
217 | dec [layer_count] |
218 | 218 | jnz .still |
|
Line -... | Line 219... | ||
- | 219 | ||
219 | 220 | cmp [ebx + Image.Type], Image.bpp8 |
|
- | 221 | jne .quit |
|
220 | cmp [ebx+Image.Type], Image.bpp8 |
222 | stdcall xcf._.pack_8a, ebx |
221 | jne .quit |
223 | jmp .quit |
222 | stdcall pack_8a, ebx |
224 | |
223 | jmp .quit |
225 | .error: |
Line 224... | Line -... | ||
224 | - | ||
225 | .error: mov [retvalue], 0 |
226 | mov [retvalue], 0 |
226 | .quit: pop edi esi ebx |
227 | .quit: |
227 | mov eax, [retvalue] |
228 | pop edi esi ebx |
228 | ret |
229 | mov eax, [retvalue] |
229 | endp |
230 | ret |
Line 250... | Line 251... | ||
250 | ;;================================================================================================;; |
251 | ;;================================================================================================;; |
251 | ;! Below are private procs you should never call directly from your code ;; |
252 | ;! Below are private procs you should never call directly from your code ;; |
252 | ;;================================================================================================;; |
253 | ;;================================================================================================;; |
253 | ;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
254 | ;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
254 | ;;================================================================================================;; |
255 | ;;================================================================================================;; |
255 | proc parse_properties _img |
256 | proc xcf._.parse_properties _img |
Line 256... | Line 257... | ||
256 | 257 | ||
257 | mov ebx, [_img] |
258 | mov ebx, [_img] |
258 | .begin: |
259 | .begin: |
259 | lodsd |
260 | lodsd |
Line 260... | Line 261... | ||
260 | bswap eax |
261 | bswap eax |
261 | 262 | ||
Line 262... | Line 263... | ||
262 | mov ecx, (xcf_prop_table_end-xcf_prop_table_begin)/8 |
263 | mov ecx, (xcf._.prop_table_end - xcf._.prop_table_begin)/8 |
263 | mov edi, xcf_prop_table_begin |
264 | mov edi, xcf._.prop_table_begin |
264 | 265 | ||
265 | .still: |
266 | .still: |
266 | cmp eax, [edi] |
267 | cmp eax, [edi] |
267 | jne @f |
268 | jne @f |
268 | jmp dword[edi+4] |
269 | jmp dword[edi + 4] |
269 | @@: |
270 | @@: |
270 | add edi, 8 |
271 | add edi, 8 |
271 | dec ecx |
272 | dec ecx |
272 | jnz .still |
273 | jnz .still |
273 | lodsd ; skip |
274 | lodsd |
Line 274... | Line 275... | ||
274 | bswap eax ; uninteresting |
275 | bswap eax |
275 | add esi, eax ; property |
276 | add esi, eax |
276 | jmp .begin |
277 | jmp .begin |
Line 277... | Line 278... | ||
277 | 278 | ||
278 | parse_prop_00: ; PROP_END |
279 | .00: ; PROP_END |
279 | lodsd |
280 | lodsd |
280 | ret |
281 | ret |
281 | 282 | ||
282 | parse_prop_01: ; PROP_COLORMAP |
283 | .01: ; PROP_COLORMAP |
283 | lodsd |
284 | lodsd |
284 | mov ecx, [ebx+Image.Extended] |
285 | mov ecx, [ebx + Image.Extended] |
285 | cmp [ecx+xcf_ext.type], XCF_BASETYPE_INDEXED |
286 | cmp [ecx + xcf_ext.type], XCF_BASETYPE_INDEXED |
286 | je @f |
287 | je @f |
287 | bswap eax |
288 | bswap eax |
288 | add esi, eax |
289 | add esi, eax |
289 | jmp parse_properties.begin |
290 | jmp xcf._.parse_properties.begin |
Line -... | Line 291... | ||
- | 291 | @@: |
|
290 | @@: |
292 | lodsd |
291 | lodsd |
293 | bswap eax |
292 | bswap eax |
294 | mov ecx, eax |
293 | mov ecx, eax |
295 | mov edi, [ebx + Image.Palette] |
294 | mov edi, [ebx+Image.Palette] |
296 | |
295 | 297 | @@: |
|
296 | @@: lodsd |
298 | lodsd |
297 | sub esi, 1 |
299 | sub esi, 1 |
298 | bswap eax |
300 | bswap eax |
Line 299... | Line 301... | ||
299 | shr eax, 8 |
301 | shr eax, 8 |
300 | or eax, 0xff000000 |
302 | or eax, 0xff000000 |
301 | stosd |
303 | stosd |
302 | dec ecx |
304 | dec ecx |
303 | jnz @b |
305 | jnz @b |
304 | jmp parse_properties.begin |
306 | jmp xcf._.parse_properties.begin |
305 | 307 | ||
Line 306... | Line 308... | ||
306 | parse_prop_06: ; PROP_OPACITY |
308 | .06: ; PROP_OPACITY |
307 | lodsd |
309 | lodsd |
308 | lodsd |
310 | lodsd |
309 | bswap eax |
311 | bswap eax |
310 | mov ecx, [ebx+Image.Extended] |
312 | mov ecx, [ebx + Image.Extended] |
311 | mov [ecx+xcf_ext.opacity], eax |
313 | mov [ecx + xcf_ext.opacity], eax |
312 | jmp parse_properties.begin |
314 | jmp xcf._.parse_properties.begin |
Line 313... | Line 315... | ||
313 | 315 | ||
314 | parse_prop_07: ; PROP_MODE |
316 | .07: ; PROP_MODE |
315 | lodsd |
317 | lodsd |
316 | lodsd |
318 | lodsd |
317 | bswap eax |
319 | bswap eax |
318 | mov ecx, [ebx+Image.Extended] |
320 | mov ecx, [ebx + Image.Extended] |
319 | mov [ecx+xcf_ext.layer_mode], eax |
321 | mov [ecx + xcf_ext.layer_mode], eax |
Line 320... | Line 322... | ||
320 | jmp parse_properties.begin |
322 | jmp xcf._.parse_properties.begin |
321 | 323 | ||
322 | parse_prop_08: ; PROP_VISIBLE |
324 | .08: ; PROP_VISIBLE |
323 | lodsd |
325 | lodsd |
324 | lodsd |
326 | lodsd |
325 | bswap eax |
327 | bswap eax |
326 | mov ecx, [ebx+Image.Extended] |
328 | mov ecx, [ebx + Image.Extended] |
Line 327... | Line 329... | ||
327 | mov [ecx+xcf_ext.visible], eax |
329 | mov [ecx + xcf_ext.visible], eax |
328 | jmp parse_properties.begin |
330 | jmp xcf._.parse_properties.begin |
329 | 331 | ||
330 | parse_prop_11: ; PROP_APPLY_MASK |
332 | .11: ; PROP_APPLY_MASK |
331 | lodsd |
333 | lodsd |
332 | lodsd |
334 | lodsd |
333 | bswap eax |
335 | bswap eax |
334 | mov ecx, [ebx+Image.Extended] |
336 | mov ecx, [ebx + Image.Extended] |
335 | mov [ecx+xcf_ext.apply_mask], eax |
337 | mov [ecx + xcf_ext.apply_mask], eax |
336 | jmp parse_properties.begin |
338 | jmp xcf._.parse_properties.begin |
337 | 339 | ||
Line 338... | Line 340... | ||
338 | parse_prop_15: ; PROP_OFFSETS |
340 | .15: ; PROP_OFFSETS |
339 | lodsd |
341 | lodsd |
340 | lodsd |
342 | lodsd |
341 | mov ecx, [ebx+Image.Extended] |
343 | mov ecx, [ebx + Image.Extended] |
342 | bswap eax |
344 | bswap eax |
343 | mov [ecx+xcf_ext.offset_x], eax |
345 | mov [ecx + xcf_ext.offset_x], eax |
Line 377... | Line 379... | ||
377 | invoke mem.alloc, sizeof.xcf_ext |
379 | invoke mem.alloc, sizeof.xcf_ext |
378 | or eax, eax |
380 | or eax, eax |
379 | jz .error |
381 | jz .error |
380 | mov [ebx+Image.Extended], eax |
382 | mov [ebx + Image.Extended], eax |
Line 381... | Line 383... | ||
381 | 383 | ||
Line 382... | Line 384... | ||
382 | stdcall parse_properties, ebx |
384 | stdcall xcf._.parse_properties, ebx |
383 | 385 | ||
384 | lodsd |
386 | lodsd |
385 | bswap eax |
387 | bswap eax |
Line 397... | Line 399... | ||
397 | lodsd |
399 | lodsd |
398 | lodsd |
400 | lodsd |
Line 399... | Line 401... | ||
399 | 401 | ||
400 | mov edi, [ebx+Image.Data] |
402 | mov edi, [ebx + Image.Data] |
- | 403 | mov ecx, 0 |
|
401 | mov ecx, 0 |
404 | @@: |
402 | @@: lodsd |
405 | lodsd |
403 | test eax, eax |
406 | test eax, eax |
404 | jz .quit |
407 | jz .quit |
405 | bswap eax |
408 | bswap eax |
406 | add eax, [_data] |
409 | add eax, [_data] |
407 | stdcall decode_tile, eax, [channel_width], [channel_height], [total_bpl], [planes_todo], 1 |
410 | stdcall xcf._.decode_tile, eax, [channel_width], [channel_height], [total_bpl], [planes_todo], 1 |
408 | add ecx, 1 |
411 | add ecx, 1 |
Line -... | Line 412... | ||
- | 412 | jmp @b |
|
409 | jmp @b |
413 | |
410 | 414 | .error: |
|
- | 415 | stdcall img.destroy, ebx |
|
411 | .error: stdcall img.destroy, ebx |
416 | mov ebx, 0 |
412 | mov ebx, 0 |
417 | .quit: |
413 | .quit: mov eax, ebx |
418 | mov eax, ebx |
414 | pop edi esi ebx |
419 | pop edi esi ebx |
Line 415... | Line 420... | ||
415 | ret |
420 | ret |
416 | endp |
421 | endp |
417 | 422 | ||
418 | 423 | ||
419 | proc decode_layer _layer_begin, _data |
424 | proc xcf._.decode_layer _layer_begin, _data |
420 | locals |
425 | locals |
Line 443... | Line 448... | ||
443 | cmp eax, 2 |
448 | cmp eax, 2 |
444 | jge @f |
449 | jge @f |
445 | mov [color_step], 3 |
450 | mov [color_step], 3 |
446 | mov edx, Image.bpp32 |
451 | mov edx, Image.bpp32 |
447 | shl [total_bpl], 1 |
452 | shl [total_bpl], 1 |
- | 453 | @@: |
|
448 | @@: stdcall img.create, [layer_width], [layer_height], edx |
454 | stdcall img.create, [layer_width], [layer_height], edx |
449 | mov ebx, eax |
455 | mov ebx, eax |
450 | test ebx, ebx |
456 | test ebx, ebx |
451 | jz .quit |
457 | jz .quit |
452 | invoke mem.alloc, sizeof.xcf_ext |
458 | invoke mem.alloc, sizeof.xcf_ext |
453 | or eax, eax |
459 | or eax, eax |
Line 455... | Line 461... | ||
455 | mov [ebx+Image.Extended], eax |
461 | mov [ebx + Image.Extended], eax |
Line 456... | Line 462... | ||
456 | 462 | ||
457 | lodsd |
463 | lodsd |
458 | bswap eax |
464 | bswap eax |
459 | add esi, eax |
465 | add esi, eax |
460 | stdcall parse_properties, ebx |
466 | stdcall xcf._.parse_properties, ebx |
461 | mov edx, [ebx+Image.Extended] |
467 | mov edx, [ebx + Image.Extended] |
462 | or [edx+xcf_ext.visible], 0 |
468 | or [edx + xcf_ext.visible], 0 |
Line 463... | Line 469... | ||
463 | jz .unvisible |
469 | jz .unvisible |
Line 481... | Line 487... | ||
481 | lodsd |
487 | lodsd |
482 | lodsd |
488 | lodsd |
Line 483... | Line 489... | ||
483 | 489 | ||
484 | mov edi, [ebx+Image.Data] |
490 | mov edi, [ebx + Image.Data] |
- | 491 | mov ecx, 0 |
|
485 | mov ecx, 0 |
492 | @@: |
486 | @@: lodsd |
493 | lodsd |
487 | test eax, eax |
494 | test eax, eax |
488 | jz @f |
495 | jz @f |
489 | bswap eax |
496 | bswap eax |
490 | add eax, [_data] |
497 | add eax, [_data] |
491 | stdcall decode_tile, eax, [layer_width], [layer_height], [total_bpl], [planes_todo], 0 |
498 | stdcall xcf._.decode_tile, eax, [layer_width], [layer_height], [total_bpl], [planes_todo], 0 |
492 | add ecx, 1 |
499 | add ecx, 1 |
493 | jmp @b |
500 | jmp @b |
Line 494... | Line 501... | ||
494 | @@: |
501 | @@: |
Line 495... | Line 502... | ||
495 | 502 | ||
496 | stdcall apply_opacity, ebx, [color_step] |
503 | stdcall xcf._.apply_opacity, ebx, [color_step] |
497 | 504 | ||
498 | pop esi |
505 | pop esi |
499 | lodsd |
506 | lodsd |
Line 500... | Line 507... | ||
500 | bswap eax |
507 | bswap eax |
501 | test eax, eax |
508 | test eax, eax |
502 | jz .quit |
509 | jz .quit |
Line 503... | Line 510... | ||
503 | 510 | ||
504 | stdcall decode_channel, eax, [_data] |
511 | stdcall xcf._.decode_channel, eax, [_data] |
505 | test eax, eax |
512 | test eax, eax |
Line 506... | Line 513... | ||
506 | jz .error |
513 | jz .error |
507 | 514 | ||
Line 508... | Line 515... | ||
508 | mov edx, [ebx+Image.Extended] |
515 | mov edx, [ebx + Image.Extended] |
- | 516 | cmp [edx + xcf_ext.apply_mask], 0 |
|
509 | cmp [edx+xcf_ext.apply_mask], 0 |
517 | je .quit |
510 | je .quit |
518 | |
- | 519 | stdcall xcf._.apply_alpha_mask, ebx, eax, [color_step] |
|
511 | 520 | jmp .quit |
|
512 | stdcall apply_alpha_mask, ebx, eax, [color_step] |
521 | |
513 | jmp .quit |
522 | .unvisible: |
514 | 523 | .error: |
|
Line 515... | Line 524... | ||
515 | .unvisible: |
524 | stdcall img.destroy, ebx |
516 | .error: stdcall img.destroy, ebx |
525 | mov ebx, 0 |
517 | mov ebx, 0 |
526 | .quit: |
518 | .quit: mov eax, ebx |
527 | mov eax, ebx |
519 | pop edi esi ebx |
528 | pop edi esi ebx |
520 | ret |
529 | ret |
Line 593... | Line 602... | ||
593 | imul eax, [_bytes_pp] |
602 | imul eax, [_bytes_pp] |
594 | add edi, eax |
603 | add edi, eax |
Line 595... | Line 604... | ||
595 | 604 | ||
596 | cmp [_is_channel], 1 |
605 | cmp [_is_channel], 1 |
597 | jne @f |
606 | jne @f |
598 | stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
607 | stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
599 | jmp .quit |
608 | jmp .quit |
600 | @@: |
609 | @@: |
601 | mov eax, [planes_todo] |
610 | mov eax, [planes_todo] |
602 | dec eax |
611 | dec eax |
Line 605... | Line 614... | ||
605 | jz .p2 |
614 | jz .p2 |
606 | dec eax |
615 | dec eax |
607 | jz .p3 |
616 | jz .p3 |
608 | jmp .p4 |
617 | jmp .p4 |
609 | .p1: |
618 | .p1: |
610 | stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
619 | stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
611 | add edi, 1 |
620 | add edi, 1 |
612 | stdcall fill_color, [tile_width], [tile_height], [_total_bpl], [_bytes_pp], [color_step] |
621 | stdcall xcf._.fill_color, [tile_width], [tile_height], [_total_bpl], [_bytes_pp], [color_step] |
613 | jmp .quit |
622 | jmp .quit |
614 | .p2: |
623 | .p2: |
615 | stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
624 | stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
616 | add edi, 1 |
625 | add edi, 1 |
617 | stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
626 | stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
618 | jmp .quit |
627 | jmp .quit |
619 | .p3: |
628 | .p3: |
620 | add edi, 2 |
629 | add edi, 2 |
621 | stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
630 | stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
622 | sub edi, 1 |
631 | sub edi, 1 |
623 | stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
632 | stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
624 | sub edi, 1 |
633 | sub edi, 1 |
625 | stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
634 | stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
626 | add edi, 3 |
635 | add edi, 3 |
627 | stdcall fill_color, [tile_width], [tile_height], [_total_bpl], [_bytes_pp], [color_step] |
636 | stdcall xcf._.fill_color, [tile_width], [tile_height], [_total_bpl], [_bytes_pp], [color_step] |
628 | jmp .quit |
637 | jmp .quit |
629 | .p4: |
638 | .p4: |
630 | add edi, 2 |
639 | add edi, 2 |
631 | stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
640 | stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
632 | sub edi, 1 |
641 | sub edi, 1 |
633 | stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
642 | stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
634 | sub edi, 1 |
643 | sub edi, 1 |
635 | stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
644 | stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
636 | add edi, 3 |
645 | add edi, 3 |
637 | stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
646 | stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
638 | ; jmp .quit |
647 | ; jmp .quit |
Line -... | Line 648... | ||
- | 648 | ||
639 | 649 | .quit: |
|
640 | .quit: pop edi esi edx ecx ebx |
650 | pop edi esi edx ecx ebx |
641 | ret |
651 | ret |
Line 642... | Line 652... | ||
642 | endp |
652 | endp |
643 | 653 | ||
644 | 654 | ||
645 | proc fill_color _tile_width, _tile_height, _total_bpl, _bytes_pp, _color_step |
655 | proc xcf._.fill_color _tile_width, _tile_height, _total_bpl, _bytes_pp, _color_step |
646 | push ebx |
656 | push ebx |
647 | mov edx, [_color_step] |
657 | mov edx, [_color_step] |
648 | mov ebx, [_total_bpl] |
658 | mov ebx, [_total_bpl] |
Line 649... | Line 659... | ||
649 | mov eax, [_bytes_pp] |
659 | mov eax, [_bytes_pp] |
650 | mul byte[_tile_width] |
660 | mul byte[_tile_width] |
- | 661 | sub ebx, eax |
|
651 | sub ebx, eax |
662 | |
- | 663 | mov ch, byte[_tile_height] |
|
652 | 664 | mov al, 0xff |
|
653 | mov ch, byte[_tile_height] |
665 | .line: |
654 | mov al, 0xff |
666 | mov cl, byte[_tile_width] |
655 | .still: mov cl, byte[_tile_width] |
667 | @@: |
656 | @@: stosb |
668 | stosb |
657 | add edi, edx |
669 | add edi, edx |
658 | dec cl |
670 | dec cl |
659 | jnz @b |
671 | jnz @b |
660 | add edi, ebx |
672 | add edi, ebx |
661 | dec ch |
673 | dec ch |
Line 662... | Line 674... | ||
662 | jnz .still |
674 | jnz .line |
663 | pop ebx |
675 | pop ebx |
664 | ret |
676 | ret |
665 | endp |
677 | endp |
666 | 678 | ||
667 | 679 | ||
Line 680... | Line 692... | ||
680 | sub ebx, eax |
692 | sub ebx, eax |
681 | mov [line_step], ebx |
693 | mov [line_step], ebx |
682 | mov ebx, [_tile_height] |
694 | mov ebx, [_tile_height] |
683 | mov edx, [_tile_width] |
695 | mov edx, [_tile_width] |
Line 684... | Line 696... | ||
684 | 696 | ||
- | 697 | .decode: |
|
685 | .decode:lodsb |
698 | lodsb |
686 | cmp al, 127 |
699 | cmp al, 127 |
687 | je .long_identical |
700 | je .long_identical |
688 | jb .short_identical |
701 | jb .short_identical |
689 | test al, 0x7f |
702 | test al, 0x7f |
Line 699... | Line 712... | ||
699 | mov ecx, 0 |
712 | mov ecx, 0 |
700 | lodsw |
713 | lodsw |
701 | mov cx, ax |
714 | mov cx, ax |
702 | xchg cl, ch |
715 | xchg cl, ch |
703 | lodsb |
716 | lodsb |
- | 717 | .step1: |
|
704 | .step1: cmp cx, dx |
718 | cmp cx, dx |
705 | je .step2 |
719 | je .step2 |
706 | jl .step3 |
720 | jl .step3 |
707 | xchg cx, dx |
721 | xchg cx, dx |
708 | sub dx, cx |
722 | sub dx, cx |
709 | sub bx, 1 |
723 | sub bx, 1 |
- | 724 | @@: |
|
710 | @@: stosb |
725 | stosb |
711 | add edi, [_color_step] |
726 | add edi, [_color_step] |
712 | loop @b |
727 | loop @b |
713 | mov cx, dx |
728 | mov cx, dx |
714 | mov edx, [_tile_width] |
729 | mov edx, [_tile_width] |
715 | add edi, [line_step] |
730 | add edi, [line_step] |
716 | jmp .step1 |
731 | jmp .step1 |
Line 717... | Line 732... | ||
717 | 732 | ||
- | 733 | .step2: |
|
718 | .step2: |
734 | @@: |
719 | @@: stosb |
735 | stosb |
720 | add edi, [_color_step] |
736 | add edi, [_color_step] |
721 | loop @b |
737 | loop @b |
722 | mov edx, [_tile_width] |
738 | mov edx, [_tile_width] |
723 | add edi, [line_step] |
739 | add edi, [line_step] |
724 | dec bx |
740 | dec bx |
725 | jz .quit |
741 | jz .quit |
- | 742 | jmp .decode |
|
726 | jmp .decode |
743 | .step3: |
- | 744 | sub dx, cx |
|
727 | .step3: sub dx, cx |
745 | @@: |
728 | @@: stosb |
746 | stosb |
729 | add edi, [_color_step] |
747 | add edi, [_color_step] |
730 | loop @b |
748 | loop @b |
Line 740... | Line 758... | ||
740 | mov ecx, 0 |
758 | mov ecx, 0 |
741 | lodsb |
759 | lodsb |
742 | mov ch, al |
760 | mov ch, al |
743 | lodsb |
761 | lodsb |
744 | mov cl, al |
762 | mov cl, al |
- | 763 | .step4: |
|
745 | .step4: cmp cx, dx |
764 | cmp cx, dx |
746 | je .step5 |
765 | je .step5 |
747 | jl .step6 |
766 | jl .step6 |
748 | xchg cx, dx |
767 | xchg cx, dx |
749 | sub dx, cx |
768 | sub dx, cx |
750 | sub bx, 1 |
769 | sub bx, 1 |
- | 770 | @@: |
|
751 | @@: movsb |
771 | movsb |
752 | add edi, [_color_step] |
772 | add edi, [_color_step] |
753 | loop @b |
773 | loop @b |
754 | mov cx, dx |
774 | mov cx, dx |
755 | mov edx, [_tile_width] |
775 | mov edx, [_tile_width] |
756 | add edi, [line_step] |
776 | add edi, [line_step] |
757 | jmp .step4 |
777 | jmp .step4 |
Line 758... | Line 778... | ||
758 | 778 | ||
- | 779 | .step5: |
|
759 | .step5: |
780 | @@: |
760 | @@: movsb |
781 | movsb |
761 | add edi, [_color_step] |
782 | add edi, [_color_step] |
762 | loop @b |
783 | loop @b |
763 | mov edx, [_tile_width] |
784 | mov edx, [_tile_width] |
764 | add edi, [line_step] |
785 | add edi, [line_step] |
765 | dec bx |
786 | dec bx |
766 | jz .quit |
787 | jz .quit |
Line -... | Line 788... | ||
- | 788 | jmp .decode |
|
767 | jmp .decode |
789 | |
- | 790 | .step6: |
|
768 | 791 | sub dx, cx |
|
769 | .step6: sub dx, cx |
792 | @@: |
770 | @@: movsb |
793 | movsb |
771 | add edi, [_color_step] |
794 | add edi, [_color_step] |
Line -... | Line 795... | ||
- | 795 | loop @b |
|
772 | loop @b |
796 | jmp .decode |
773 | jmp .decode |
797 | |
774 | 798 | .quit: |
|
Line 775... | Line 799... | ||
775 | .quit: pop edi |
799 | pop edi |
776 | ret |
800 | ret |
777 | endp |
801 | endp |
778 | 802 | ||
779 | 803 | ||
780 | proc merge_down _img, _bottom, _layer_number |
804 | proc xcf._.merge_down _img, _bottom, _layer_number |
Line 876... | Line 900... | ||
876 | add eax, [img_x1] |
900 | add eax, [img_x1] |
877 | shl eax, 1 |
901 | shl eax, 1 |
878 | cmp [edx+Image.Width], Image.bpp16 |
902 | cmp [edx + Image.Width], Image.bpp16 |
879 | je @f |
903 | je @f |
880 | shl eax, 1 |
904 | shl eax, 1 |
- | 905 | @@: |
|
881 | @@: add esi, eax |
906 | add esi, eax |
Line 882... | Line 907... | ||
882 | 907 | ||
883 | mov eax, [ebx+Image.Width] |
908 | mov eax, [ebx + Image.Width] |
884 | imul eax, [bottom_y1] |
909 | imul eax, [bottom_y1] |
885 | add eax, [bottom_x1] |
910 | add eax, [bottom_x1] |
886 | shl eax, 1 |
911 | shl eax, 1 |
887 | cmp [ebx+Image.Width], Image.bpp8 |
912 | cmp [ebx + Image.Width], Image.bpp8 |
888 | je @f |
913 | je @f |
- | 914 | shl eax, 1 |
|
889 | shl eax, 1 |
915 | @@: |
Line 890... | Line 916... | ||
890 | @@: add edi, eax |
916 | add edi, eax |
891 | 917 | ||
892 | 918 | ||
893 | mov eax, [edx+Image.Width] |
919 | mov eax, [edx + Image.Width] |
894 | sub eax, [copy_width] |
920 | sub eax, [copy_width] |
895 | shl eax, 1 |
921 | shl eax, 1 |
- | 922 | cmp [edx + Image.Width], Image.bpp16 |
|
896 | cmp [edx+Image.Width], Image.bpp16 |
923 | je @f |
Line 897... | Line 924... | ||
897 | je @f |
924 | shl eax, 1 |
898 | shl eax, 1 |
925 | @@: |
899 | @@: mov [img_total_bpl], eax |
926 | mov [img_total_bpl], eax |
900 | 927 | ||
901 | mov eax, [ebx+Image.Width] |
928 | mov eax, [ebx + Image.Width] |
902 | sub eax, [copy_width] |
929 | sub eax, [copy_width] |
- | 930 | shl eax, 1 |
|
903 | shl eax, 1 |
931 | cmp [ebx + Image.Width], Image.bpp8 |
Line 904... | Line 932... | ||
904 | cmp [ebx+Image.Width], Image.bpp8 |
932 | je @f |
905 | je @f |
933 | shl eax, 1 |
906 | shl eax, 1 |
934 | @@: |
907 | @@: mov [bottom_total_bpl], eax |
935 | mov [bottom_total_bpl], eax |
908 | 936 | ||
909 | cmp [_layer_number], 0 |
937 | cmp [_layer_number], 0 |
- | 938 | jne .not_first |
|
910 | jne .not_first |
939 | mov ecx, [copy_width] |
911 | mov ecx, [copy_width] |
940 | imul ecx, [copy_height] |
- | 941 | cmp [ebx + Image.Type], Image.bpp8 |
|
912 | imul ecx, [copy_height] |
942 | je .bpp8a |
913 | cmp [ebx+Image.Type], Image.bpp8 |
943 | .bpp32: |
914 | je .bpp8 |
944 | rep movsd |
Line 915... | Line 945... | ||
915 | .bpp32: rep movsd |
945 | jmp .done |
916 | jmp .done |
946 | .bpp8a: |
Line 935... | Line 965... | ||
935 | mov edx, 8 |
965 | mov edx, 8 |
936 | jmp .type_defined |
966 | jmp .type_defined |
937 | @@: |
967 | @@: |
938 | mov edx, 12 |
968 | mov edx, 12 |
939 | .type_defined: |
969 | .type_defined: |
940 | mov ecx, (composite_table_end-composite_table_begin)/8 |
970 | mov ecx, (xcf._.composite_table.end - xcf._.composite_table.begin) / 8 |
941 | mov edi, composite_table_begin |
971 | mov edi, xcf._.composite_table.begin |
Line 942... | Line 972... | ||
942 | 972 | ||
943 | .still: |
973 | .still: |
944 | cmp eax, [edi] |
974 | cmp eax, [edi] |
945 | jne @f |
975 | jne @f |
Line 967... | Line 997... | ||
967 | @@: |
997 | @@: |
Line 968... | Line 998... | ||
968 | 998 | ||
969 | 999 | ||
970 | cmp [ebx+Image.Type], Image.bpp8 |
1000 | cmp [ebx + Image.Type], Image.bpp8 |
971 | jne @f |
1001 | jne @f |
- | 1002 | stdcall xcf._.merge_8a, [copy_width], [copy_height], [img_total_bpl], [bottom_total_bpl] |
|
972 | stdcall merge_8a, [copy_width], [copy_height], [img_total_bpl], [bottom_total_bpl] |
1003 | jmp .done |
973 | jmp .done |
1004 | @@: |
974 | @@: stdcall merge_32, [copy_width], [copy_height], [img_total_bpl], [bottom_total_bpl] |
1005 | stdcall xcf._.merge_32, [copy_width], [copy_height], [img_total_bpl], [bottom_total_bpl] |
975 | ; jmp .done |
1006 | ; jmp .done |
976 | .done: |
1007 | .done: |
977 | stdcall img.destroy, [_img] |
1008 | stdcall img.destroy, [_img] |
978 | pop edi esi ebx |
1009 | pop edi esi ebx |
Line 979... | Line 1010... | ||
979 | ret |
1010 | ret |
980 | endp |
1011 | endp |
981 | 1012 | ||
982 | 1013 | ||
983 | proc pack_8a _img |
1014 | proc xcf._.pack_8a _img |
984 | mov ebx, [_img] |
1015 | mov ebx, [_img] |
985 | mov esi, [ebx+Image.Data] |
1016 | mov esi, [ebx + Image.Data] |
986 | mov edi, [ebx+Image.Data] |
1017 | mov edi, esi |
987 | mov ecx, [ebx+Image.Width] |
1018 | mov ecx, [ebx + Image.Width] |
988 | mov edx, [ebx+Image.Height] |
1019 | imul ecx, [ebx + Image.Height] |
989 | imul ecx, edx |
1020 | @@: |
990 | @@: lodsw |
1021 | lodsw |
991 | stosb |
1022 | stosb |
Line 992... | Line 1023... | ||
992 | dec ecx |
1023 | dec ecx |
Line 993... | Line 1024... | ||
993 | jnz @b |
1024 | jnz @b |
Line 994... | Line 1025... | ||
994 | ret |
1025 | ret |
995 | endp |
1026 | endp |
Line 1008... | Line 1039... | ||
1008 | imul ecx, [ebx+Image.Height] |
1039 | imul ecx, [ebx + Image.Height] |
1009 | mov esi, [ebx+Image.Data] |
1040 | mov esi, [ebx + Image.Data] |
1010 | mov ebx, [_color_step] |
1041 | mov ebx, [_color_step] |
1011 | add esi, ebx |
1042 | add esi, ebx |
1012 | mov edi, esi |
1043 | mov edi, esi |
- | 1044 | @@: |
|
1013 | @@: lodsb |
1045 | lodsb |
1014 | mul dl |
1046 | mul dl |
1015 | shr ax, 8 |
1047 | shr ax, 8 |
1016 | stosb |
1048 | stosb |
1017 | add esi, ebx |
1049 | add esi, ebx |
1018 | add edi, ebx |
1050 | add edi, ebx |
1019 | dec ecx |
1051 | dec ecx |
1020 | jnz @b |
1052 | jnz @b |
Line -... | Line 1053... | ||
- | 1053 | ||
1021 | 1054 | .quit: |
|
1022 | .quit: pop ebx |
1055 | pop ebx |
1023 | ret |
1056 | ret |
Line 1024... | Line 1057... | ||
1024 | endp |
1057 | endp |
Line 1025... | Line 1058... | ||
1025 | 1058 | ||
Line 1026... | Line 1059... | ||
1026 | 1059 | ||
1027 | proc apply_alpha_mask _img, _mask, _color_step |
1060 | proc xcf._.apply_alpha_mask _img, _mask, _color_step |
Line 1049... | Line 1082... | ||
1049 | pop ebx |
1082 | pop ebx |
1050 | ret |
1083 | ret |
1051 | endp |
1084 | endp |
Line -... | Line 1085... | ||
- | 1085 | ||
1052 | 1086 | ||
- | 1087 | ;;================================================================================================;; |
|
- | 1088 | proc xcf._.rgb2hsv ;///////////////////////////////////////////////////////////////////////////;; |
|
- | 1089 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 1090 | ;? convert color from RGB to HSV space ;; |
|
- | 1091 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 1092 | ;> eax = color (0xAARRGGBB) ;; |
|
- | 1093 | ;;------------------------------------------------------------------------------------------------;; |
|
1053 | 1094 | ;< eax = color (0xAAHHSSVV) ;; |
|
1054 | proc pixel_rgb2hsv |
1095 | ;;================================================================================================;; |
1055 | locals |
1096 | locals |
1056 | vsha rd 1 |
1097 | vsha rd 1 |
1057 | max rd 1 |
1098 | max rd 1 |
Line 1072... | Line 1113... | ||
1072 | ror eax, 8 |
1113 | ror eax, 8 |
1073 | mov ax, 0 |
1114 | mov ax, 0 |
1074 | rol eax, 8 |
1115 | rol eax, 8 |
1075 | jmp .quit |
1116 | jmp .quit |
Line -... | Line 1117... | ||
- | 1117 | ||
1076 | 1118 | @@: |
|
1077 | @@: cmp dl, cl |
1119 | cmp dl, cl |
1078 | ja @f |
1120 | ja @f |
1079 | cmp dl, al |
1121 | cmp dl, al |
1080 | ja @f |
1122 | ja @f |
1081 | mov byte[min], dl |
1123 | mov byte[min], dl |
- | 1124 | jmp .min_found |
|
1082 | jmp .min_found |
1125 | @@: |
1083 | @@: cmp cl, al |
1126 | cmp cl, al |
1084 | ja @f |
1127 | ja @f |
1085 | cmp cl, dl |
1128 | cmp cl, dl |
1086 | ja @f |
1129 | ja @f |
1087 | mov byte[min], cl |
1130 | mov byte[min], cl |
- | 1131 | jmp .min_found |
|
1088 | jmp .min_found |
1132 | @@: |
1089 | @@: mov byte[min], al |
1133 | mov byte[min], al |
1090 | ; jmp .min_found |
1134 | ; jmp .min_found |
Line 1091... | Line 1135... | ||
1091 | .min_found: |
1135 | .min_found: |
1092 | 1136 | ||
Line 1097... | Line 1141... | ||
1097 | mov byte[max], dl |
1141 | mov byte[max], dl |
1098 | sub cx, ax |
1142 | sub cx, ax |
1099 | mov dx, cx |
1143 | mov dx, cx |
1100 | mov cx, 0 |
1144 | mov cx, 0 |
1101 | jmp .max_found |
1145 | jmp .max_found |
- | 1146 | @@: |
|
1102 | @@: cmp cl, al |
1147 | cmp cl, al |
1103 | jb @f |
1148 | jb @f |
1104 | cmp cl, dl |
1149 | cmp cl, dl |
1105 | jb @f |
1150 | jb @f |
1106 | mov byte[max], cl |
1151 | mov byte[max], cl |
1107 | sub ax, dx |
1152 | sub ax, dx |
1108 | mov dx, ax |
1153 | mov dx, ax |
1109 | mov cx, 85 |
1154 | mov cx, 85 |
1110 | jmp .max_found |
1155 | jmp .max_found |
- | 1156 | @@: |
|
1111 | @@: mov byte[max], al |
1157 | mov byte[max], al |
1112 | sub dx, cx |
1158 | sub dx, cx |
1113 | mov cx, 171 |
1159 | mov cx, 171 |
1114 | ; jmp .max_found |
1160 | ; jmp .max_found |
1115 | .max_found: |
1161 | .max_found: |
Line 1143... | Line 1189... | ||
1143 | div byte[max] |
1189 | div byte[max] |
1144 | mov byte[vsha+1], al |
1190 | mov byte[vsha + 1], al |
1145 | @@: |
1191 | @@: |
1146 | mov eax, [vsha] |
1192 | mov eax, [vsha] |
Line -... | Line 1193... | ||
- | 1193 | ||
1147 | 1194 | .quit: |
|
1148 | .quit: pop edx ecx ebx |
1195 | pop edx ecx ebx |
1149 | ret |
1196 | ret |
Line -... | Line 1197... | ||
- | 1197 | endp |
|
1150 | endp |
1198 | |
- | 1199 | ||
- | 1200 | ;;================================================================================================;; |
|
- | 1201 | proc xcf._.hsv2rgb ;///////////////////////////////////////////////////////////////////////////;; |
|
- | 1202 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 1203 | ;? convert color from HSV to RGB space ;; |
|
- | 1204 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 1205 | ;> eax = color (0xAAHHSSVV) ;; |
|
1151 | 1206 | ;;------------------------------------------------------------------------------------------------;; |
|
1152 | 1207 | ;< eax = color (0xAARRGGBB) ;; |
|
1153 | proc pixel_hsv2rgb |
1208 | ;;================================================================================================;; |
1154 | locals |
1209 | locals |
1155 | vsha rd 1 |
1210 | vsha rd 1 |
Line 1176... | Line 1231... | ||
1176 | sub eax, ebx |
1231 | sub eax, ebx |
1177 | shr ebx, 1 |
1232 | shr ebx, 1 |
1178 | sub eax, ebx |
1233 | sub eax, ebx |
1179 | jmp .ok |
1234 | jmp .ok |
Line -... | Line 1235... | ||
- | 1235 | ||
1180 | 1236 | @@: |
|
1181 | @@: cmp eax, 86 |
1237 | cmp eax, 86 |
1182 | ja @f |
1238 | ja @f |
1183 | sub eax, 44 |
1239 | sub eax, 44 |
1184 | lea eax, [eax*3] |
1240 | lea eax, [eax*3] |
1185 | shl eax, 1 |
1241 | shl eax, 1 |
1186 | neg al |
1242 | neg al |
1187 | add al, 0xff |
1243 | add al, 0xff |
Line -... | Line 1244... | ||
- | 1244 | jmp .ok |
|
1188 | jmp .ok |
1245 | |
1189 | 1246 | @@: |
|
1190 | @@: cmp eax, 129 |
1247 | cmp eax, 129 |
1191 | ja @f |
1248 | ja @f |
1192 | sub eax, 87 |
1249 | sub eax, 87 |
1193 | lea eax, [eax*3] |
1250 | lea eax, [eax*3] |
Line -... | Line 1251... | ||
- | 1251 | shl eax, 1 |
|
1194 | shl eax, 1 |
1252 | jmp .ok |
1195 | jmp .ok |
1253 | |
1196 | 1254 | @@: |
|
1197 | @@: cmp eax, 171 |
1255 | cmp eax, 171 |
1198 | ja @f |
1256 | ja @f |
1199 | sub eax, 130 |
1257 | sub eax, 130 |
1200 | lea eax, [eax*3] |
1258 | lea eax, [eax*3] |
1201 | shl eax, 1 |
1259 | shl eax, 1 |
Line -... | Line 1260... | ||
- | 1260 | neg al |
|
1202 | neg al |
1261 | add al, 0xff |
1203 | add al, 0xff |
1262 | jmp .ok |
1204 | jmp .ok |
1263 | |
1205 | 1264 | @@: |
|
1206 | @@: cmp eax, 214 |
1265 | cmp eax, 214 |
1207 | ja @f |
1266 | ja @f |
Line 1237... | Line 1296... | ||
1237 | shl eax, 8 |
1296 | shl eax, 8 |
1238 | mov ah, byte[x] |
1297 | mov ah, byte[x] |
1239 | mov al, 0 |
1298 | mov al, 0 |
1240 | jmp .done |
1299 | jmp .done |
Line -... | Line 1300... | ||
- | 1300 | ||
1241 | 1301 | @@: |
|
1242 | @@: cmp al, 86 |
1302 | cmp al, 86 |
1243 | jae @f |
1303 | jae @f |
1244 | mov eax, [vsha] |
1304 | mov eax, [vsha] |
1245 | shr eax, 8 |
1305 | shr eax, 8 |
1246 | mov ah, byte[x] |
1306 | mov ah, byte[x] |
1247 | shl eax, 8 |
1307 | shl eax, 8 |
1248 | mov ah, byte[c] |
1308 | mov ah, byte[c] |
1249 | mov al, 0 |
1309 | mov al, 0 |
Line -... | Line 1310... | ||
- | 1310 | jmp .done |
|
1250 | jmp .done |
1311 | |
1251 | 1312 | @@: |
|
1252 | @@: cmp al, 129 |
1313 | cmp al, 129 |
1253 | jae @f |
1314 | jae @f |
1254 | mov eax, [vsha] |
1315 | mov eax, [vsha] |
1255 | shr eax, 8 |
1316 | shr eax, 8 |
1256 | mov ah, 0 |
1317 | mov ah, 0 |
1257 | shl eax, 8 |
1318 | shl eax, 8 |
1258 | mov ah, byte[c] |
1319 | mov ah, byte[c] |
Line -... | Line 1320... | ||
- | 1320 | mov al, byte[x] |
|
1259 | mov al, byte[x] |
1321 | jmp .done |
1260 | jmp .done |
1322 | |
1261 | 1323 | @@: |
|
1262 | @@: cmp al, 171 |
1324 | cmp al, 171 |
1263 | jae @f |
1325 | jae @f |
1264 | mov eax, [vsha] |
1326 | mov eax, [vsha] |
1265 | shr eax, 8 |
1327 | shr eax, 8 |
1266 | mov ah, 0 |
1328 | mov ah, 0 |
1267 | shl eax, 8 |
1329 | shl eax, 8 |
Line -... | Line 1330... | ||
- | 1330 | mov ah, byte[x] |
|
1268 | mov ah, byte[x] |
1331 | mov al, byte[c] |
1269 | mov al, byte[c] |
1332 | jmp .done |
1270 | jmp .done |
1333 | |
1271 | 1334 | @@: |
|
1272 | @@: cmp al, 214 |
1335 | cmp al, 214 |
1273 | jae @f |
1336 | jae @f |
1274 | mov eax, [vsha] |
1337 | mov eax, [vsha] |
1275 | shr eax, 8 |
1338 | shr eax, 8 |
1276 | mov ah, byte[x] |
1339 | mov ah, byte[x] |
Line -... | Line 1340... | ||
- | 1340 | shl eax, 8 |
|
1277 | shl eax, 8 |
1341 | mov ah, 0 |
1278 | mov ah, 0 |
1342 | mov al, byte[c] |
1279 | mov al, byte[c] |
1343 | jmp .done |
1280 | jmp .done |
1344 | |
1281 | 1345 | @@: |
|
1282 | @@: mov eax, [vsha] |
1346 | mov eax, [vsha] |
Line 1294... | Line 1358... | ||
1294 | add ah, bl |
1358 | add ah, bl |
1295 | rol eax, 8 |
1359 | rol eax, 8 |
1296 | add ah, bl |
1360 | add ah, bl |
1297 | add al, bl |
1361 | add al, bl |
Line -... | Line 1362... | ||
- | 1362 | ||
1298 | 1363 | .quit: |
|
1299 | .quit: pop edx ecx ebx |
1364 | pop edx ecx ebx |
1300 | ret |
1365 | ret |
Line -... | Line 1366... | ||
- | 1366 | endp |
|
1301 | endp |
1367 | |
- | 1368 | ||
- | 1369 | ;;================================================================================================;; |
|
- | 1370 | proc xcf._.rgb2hsl ;///////////////////////////////////////////////////////////////////////////;; |
|
- | 1371 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 1372 | ;? convert color from RGB to HSL space ;; |
|
- | 1373 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 1374 | ;> eax = color (0xAARRGGBB) ;; |
|
1302 | 1375 | ;;------------------------------------------------------------------------------------------------;; |
|
1303 | 1376 | ;< eax = color (0xAAHHSSLL) ;; |
|
1304 | proc pixel_rgb2hsl |
1377 | ;;================================================================================================;; |
1305 | ; http://www.asmcommunity.net/board/index.php?topic=7425 |
1378 | ; http://www.asmcommunity.net/board/index.php?topic=7425 |
1306 | ; iblis: "I don't know what X-Filez is, but yes you may use it however you wish. That's why I made this post, to share." |
1379 | ; iblis: "I don't know what X-Filez is, but yes you may use it however you wish. That's why I made this post, to share." |
Line 1337... | Line 1410... | ||
1337 | cmp esi, edi |
1410 | cmp esi, edi |
1338 | ja .cmp1 |
1411 | ja .cmp1 |
1339 | xchg esi, edi |
1412 | xchg esi, edi |
1340 | neg cl |
1413 | neg cl |
1341 | shl cl, 1 |
1414 | shl cl, 1 |
- | 1415 | .cmp1: |
|
1342 | .cmp1: cmp edi, ebx |
1416 | cmp edi, ebx |
1343 | jb .cmp2 |
1417 | jb .cmp2 |
1344 | xchg edi, ebx |
1418 | xchg edi, ebx |
1345 | neg cl |
1419 | neg cl |
- | 1420 | .cmp2: |
|
1346 | .cmp2: cmp esi, ebx |
1421 | cmp esi, ebx |
1347 | ja .cmp3 |
1422 | ja .cmp3 |
1348 | xchg esi, ebx |
1423 | xchg esi, ebx |
1349 | not cl |
1424 | not cl |
- | 1425 | .cmp3: |
|
1350 | .cmp3: neg ebx |
1426 | neg ebx |
1351 | add ebx, esi |
1427 | add ebx, esi |
1352 | mov eax, edi |
1428 | mov eax, edi |
1353 | add edi, esi |
1429 | add edi, esi |
1354 | jz .done |
1430 | jz .done |
1355 | sub esi, eax |
1431 | sub esi, eax |
Line 1360... | Line 1436... | ||
1360 | push edi |
1436 | push edi |
1361 | cmp edi, 0xff |
1437 | cmp edi, 0xff |
1362 | jbe .csat |
1438 | jbe .csat |
1363 | neg edi |
1439 | neg edi |
1364 | add edi, 510 |
1440 | add edi, 510 |
- | 1441 | .csat: |
|
1365 | .csat: xor edx, edx |
1442 | xor edx, edx |
1366 | div edi |
1443 | div edi |
1367 | pop edi |
1444 | pop edi |
1368 | shr edi, 1 |
1445 | shr edi, 1 |
1369 | shl eax, 8 |
1446 | shl eax, 8 |
1370 | or edi, eax |
1447 | or edi, eax |
1371 | add cl, 3 |
1448 | add cl, 3 |
1372 | jnc .noneg |
1449 | jnc .noneg |
1373 | neg ebx |
1450 | neg ebx |
- | 1451 | .noneg: |
|
1374 | .noneg: shl cl, 2 |
1452 | shl cl, 2 |
1375 | mov eax, 0x13135db9 |
1453 | mov eax, 0x13135db9 |
1376 | shr eax, cl |
1454 | shr eax, cl |
1377 | and eax, 7 |
1455 | and eax, 7 |
1378 | mul esi |
1456 | mul esi |
1379 | add eax, ebx |
1457 | add eax, ebx |
Line 1385... | Line 1463... | ||
1385 | lea ebx, [ebx*4+esi] |
1463 | lea ebx, [ebx*4 + esi] |
1386 | xor edx, edx |
1464 | xor edx, edx |
1387 | div ebx |
1465 | div ebx |
1388 | shl eax, 16 |
1466 | shl eax, 16 |
1389 | or eax, edi |
1467 | or eax, edi |
- | 1468 | .done: |
|
1390 | .done: bswap eax |
1469 | bswap eax |
1391 | shr eax, 8 |
1470 | shr eax, 8 |
Line 1392... | Line 1471... | ||
1392 | 1471 | ||
1393 | mov bl, byte[bgra+3] |
1472 | mov bl, byte[bgra + 3] |
1394 | bswap eax |
1473 | bswap eax |
Line 1399... | Line 1478... | ||
1399 | pop edi esi ebx |
1478 | pop edi esi ebx |
1400 | ret |
1479 | ret |
1401 | endp |
1480 | endp |
Line -... | Line 1481... | ||
- | 1481 | ||
1402 | 1482 | ||
- | 1483 | ;;================================================================================================;; |
|
- | 1484 | proc xcf._.hsl2rgb ;///////////////////////////////////////////////////////////////////////////;; |
|
- | 1485 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 1486 | ;? convert color from HSL to RGB space ;; |
|
- | 1487 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 1488 | ;> eax = color (0xAAHHSSLL) ;; |
|
- | 1489 | ;;------------------------------------------------------------------------------------------------;; |
|
1403 | 1490 | ;< eax = color (0xAARRGGBB) ;; |
|
1404 | proc pixel_hsl2rgb |
1491 | ;;================================================================================================;; |
1405 | ; http://www.asmcommunity.net/board/index.php?topic=7425 |
1492 | ; http://www.asmcommunity.net/board/index.php?topic=7425 |
1406 | ; iblis: "I don't know what X-Filez is, but yes you may use it however you wish. That's why I made this post, to share." |
1493 | ; iblis: "I don't know what X-Filez is, but yes you may use it however you wish. That's why I made this post, to share." |
1407 | ; so pixel_hsl2rgb procedure is based on code by Greg Hoyer (iblis). thanks! |
1494 | ; so pixel_hsl2rgb procedure is based on code by Greg Hoyer (iblis). thanks! |
Line 1437... | Line 1524... | ||
1437 | mov cl, 1 |
1524 | mov cl, 1 |
1438 | cmp bl, 0x7f |
1525 | cmp bl, 0x7f |
1439 | ja .lcase |
1526 | ja .lcase |
1440 | dec al |
1527 | dec al |
1441 | xor ecx, ecx |
1528 | xor ecx, ecx |
- | 1529 | .lcase: |
|
1442 | .lcase: add eax, edi |
1530 | add eax, edi |
1443 | mul ebx |
1531 | mul ebx |
1444 | or ecx, ecx |
1532 | or ecx, ecx |
1445 | jz .scase |
1533 | jz .scase |
1446 | neg eax |
1534 | neg eax |
1447 | mov ecx, ebx |
1535 | mov ecx, ebx |
1448 | add ecx, edi |
1536 | add ecx, edi |
1449 | mov edx, ecx |
1537 | mov edx, ecx |
1450 | shl ecx, 8 |
1538 | shl ecx, 8 |
1451 | sub ecx, edx |
1539 | sub ecx, edx |
1452 | add eax, ecx |
1540 | add eax, ecx |
- | 1541 | .scase: |
|
1453 | .scase: xor edx, edx |
1542 | xor edx, edx |
1454 | xor ecx, ecx |
1543 | xor ecx, ecx |
1455 | dec cl |
1544 | dec cl |
1456 | mov edi, ecx |
1545 | mov edi, ecx |
1457 | div ecx |
1546 | div ecx |
1458 | jz .done |
1547 | jz .done |
Line 1511... | Line 1600... | ||
1511 | xchg ah, al |
1600 | xchg ah, al |
1512 | dec ecx |
1601 | dec ecx |
1513 | jz .done |
1602 | jz .done |
1514 | ror eax, 8 |
1603 | ror eax, 8 |
1515 | xchg ah, al |
1604 | xchg ah, al |
- | 1605 | .done: |
|
1516 | .done: and eax, 0x00ffffff |
1606 | and eax, 0x00ffffff |
Line 1517... | Line 1607... | ||
1517 | 1607 | ||
1518 | mov bl, byte[lsha+3] |
1608 | mov bl, byte[lsha + 3] |
1519 | bswap eax |
1609 | bswap eax |
1520 | mov al, bl |
1610 | mov al, bl |
Line 1521... | Line 1611... | ||
1521 | ror eax, 8 |
1611 | ror eax, 8 |
- | 1612 | ||
- | 1613 | pop edi esi ebx |
|
1522 | 1614 | ||
1523 | pop edi esi ebx |
1615 | |
Line 1524... | Line 1616... | ||
1524 | ret |
1616 | ret |
- | 1617 | endp |
|
- | 1618 | ||
1525 | endp |
1619 | |
1526 | 1620 | match =MMX, COMPOSITE_MODE{include 'composite_mmx.asm'} |
|
1527 | 1621 | match =SSE, COMPOSITE_MODE{include 'composite_sse.asm'} |
|
1528 | match =MMX,COMPOSITE_MODE{include 'composite_mmx.inc'} |
1622 | |
1529 | ;;================================================================================================;; |
1623 | ;;================================================================================================;; |
1530 | ;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
1624 | ;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
1531 | ;;================================================================================================;; |
1625 | ;;================================================================================================;; |
1532 | ;! Below is private data you should never use directly from your code ;; |
- | |
1533 | ;;================================================================================================;; |
- | |
1534 | ;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
- | |
1535 | ;;================================================================================================;; |
- | |
1536 | xcf_prop_table_begin: |
- | |
1537 | dd 00, parse_prop_00 |
- | |
1538 | dd 01, parse_prop_01 |
- | |
1539 | dd 06, parse_prop_06 |
- | |
1540 | dd 07, parse_prop_07 |
- | |
1541 | dd 08, parse_prop_08 |
- | |
1542 | dd 11, parse_prop_11 |
- | |
1543 | dd 15, parse_prop_15 |
- | |
1544 | xcf_prop_table_end: |
- | |
1545 | - | ||
1546 | composite_table_begin: |
- | |
1547 | .p00 dd 00, composite_rgb_00, composite_gray_00, composite_indexed_00 ; Normal |
- | |
1548 | .p01 dd 01, composite_rgb_01, composite_gray_01, composite_gray_01 ; Dissolve : random dithering to discrete alpha |
- | |
1549 | ;.p02 dd 02, composite_rgb_02, 0, composite_indexed_02 ; Behind : not selectable in the GIMP UI. not implemented |
- | |
1550 | .p03 dd 03, composite_rgb_03, composite_rgb_03, composite_indexed_00 ; Multiply |
- | |
1551 | .p04 dd 04, composite_rgb_04, composite_rgb_04, composite_indexed_00 ; Screen |
- | |
1552 | .p05 dd 05, composite_rgb_05, composite_rgb_05, composite_indexed_00 ; Overlay |
- | |
1553 | .p06 dd 06, composite_rgb_06, composite_rgb_06, composite_indexed_00 ; Difference |
- | |
1554 | .p07 dd 07, composite_rgb_07, composite_rgb_07, composite_indexed_00 ; Addition |
- | |
1555 | .p08 dd 08, composite_rgb_08, composite_rgb_08, composite_indexed_00 ; Subtract |
- | |
1556 | .p09 dd 09, composite_rgb_09, composite_rgb_09, composite_indexed_00 ; Darken Only |
- | |
1557 | .p10 dd 10, composite_rgb_10, composite_rgb_10, composite_indexed_00 ; Lighten Only |
- | |
1558 | .p11 dd 11, composite_rgb_11, composite_gray_00, composite_indexed_00 ; Hue (H of HSV) |
- | |
1559 | .p12 dd 12, composite_rgb_12, composite_gray_00, composite_indexed_00 ; Saturation (S of HSV) |
- | |
1560 | .p13 dd 13, composite_rgb_13, composite_gray_00, composite_indexed_00 ; Color (H and S of HSL) |
- | |
1561 | .p14 dd 14, composite_rgb_14, composite_gray_00, composite_indexed_00 ; Value (V of HSV) |
- | |
1562 | .p15 dd 15, composite_rgb_15, composite_rgb_15, composite_indexed_00 ; Divide |
- | |
1563 | .p16 dd 16, composite_rgb_16, composite_rgb_16, composite_indexed_00 ; Dodge |
- | |
1564 | .p17 dd 17, composite_rgb_17, composite_rgb_17, composite_indexed_00 ; Burn |
- | |
1565 | .p18 dd 18, composite_rgb_18, composite_rgb_18, composite_indexed_00 ; Hard Light |
- | |
1566 | .p19 dd 19, composite_rgb_05, composite_rgb_05, composite_indexed_00 ; Soft Light : XCF version >= 2 only ('soft light' == 'overlay') |
- | |
1567 | .p20 dd 20, composite_rgb_20, composite_rgb_20, composite_indexed_00 ; Grain Extract : XCF version >= 2 only |
- | |
1568 | .p21 dd 21, composite_rgb_21, composite_rgb_21, composite_indexed_00 ; Grain Merge : XCF version >= 2 only |
- | |
1569 | composite_table_end: |
- | |
1570 | 1626 | ;! Below is private data you should never use directly from your code ;; |
|
- | 1627 | ;;================================================================================================;; |
|
- | 1628 | ;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
|
- | 1629 | ;;================================================================================================;; |
|
- | 1630 | xcf._.prop_table_begin: |
|
- | 1631 | dd 00, xcf._.parse_properties.00 |
|
- | 1632 | dd 01, xcf._.parse_properties.01 |
|
- | 1633 | dd 06, xcf._.parse_properties.06 |
|
- | 1634 | dd 07, xcf._.parse_properties.07 |
|
- | 1635 | dd 08, xcf._.parse_properties.08 |
|
- | 1636 | dd 11, xcf._.parse_properties.11 |
|
- | 1637 | dd 15, xcf._.parse_properties.15 |
|
- | 1638 | xcf._.prop_table_end: |
|
- | 1639 | ||
- | 1640 | xcf._.composite_table.begin: |
|
- | 1641 | .p00 dd 00, xcf._.composite_rgb_00, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Normal |
|
- | 1642 | .p01 dd 01, xcf._.composite_rgb_01, xcf._.composite_gray_01, xcf._.composite_gray_01 ; Dissolve : random dithering to discrete alpha |
|
- | 1643 | ; .p02 dd 02, xcf._.composite_rgb_02, 0, xcf._.composite_indexed_02 ; Behind : not selectable in the GIMP UI. not implemented |
|
- | 1644 | .p03 dd 03, xcf._.composite_rgb_03, xcf._.composite_rgb_03, xcf._.composite_indexed_00 ; Multiply |
|
- | 1645 | .p04 dd 04, xcf._.composite_rgb_04, xcf._.composite_rgb_04, xcf._.composite_indexed_00 ; Screen |
|
- | 1646 | .p05 dd 05, xcf._.composite_rgb_05, xcf._.composite_rgb_05, xcf._.composite_indexed_00 ; Overlay |
|
- | 1647 | .p06 dd 06, xcf._.composite_rgb_06, xcf._.composite_rgb_06, xcf._.composite_indexed_00 ; Difference |
|
- | 1648 | .p07 dd 07, xcf._.composite_rgb_07, xcf._.composite_rgb_07, xcf._.composite_indexed_00 ; Addition |
|
- | 1649 | .p08 dd 08, xcf._.composite_rgb_08, xcf._.composite_rgb_08, xcf._.composite_indexed_00 ; Subtract |
|
- | 1650 | .p09 dd 09, xcf._.composite_rgb_09, xcf._.composite_rgb_09, xcf._.composite_indexed_00 ; Darken Only |
|
- | 1651 | .p10 dd 10, xcf._.composite_rgb_10, xcf._.composite_rgb_10, xcf._.composite_indexed_00 ; Lighten Only |
|
- | 1652 | .p11 dd 11, xcf._.composite_rgb_11, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Hue (H of HSV) |
|
- | 1653 | .p12 dd 12, xcf._.composite_rgb_12, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Saturation (S of HSV) |
|
- | 1654 | .p13 dd 13, xcf._.composite_rgb_13, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Color (H and S of HSL) |
|
- | 1655 | .p14 dd 14, xcf._.composite_rgb_14, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Value (V of HSV) |
|
- | 1656 | .p15 dd 15, xcf._.composite_rgb_15, xcf._.composite_rgb_15, xcf._.composite_indexed_00 ; Divide |
|
- | 1657 | .p16 dd 16, xcf._.composite_rgb_16, xcf._.composite_rgb_16, xcf._.composite_indexed_00 ; Dodge |
|
- | 1658 | .p17 dd 17, xcf._.composite_rgb_17, xcf._.composite_rgb_17, xcf._.composite_indexed_00 ; Burn |
|
- | 1659 | .p18 dd 18, xcf._.composite_rgb_18, xcf._.composite_rgb_18, xcf._.composite_indexed_00 ; Hard Light |
|
- | 1660 | .p19 dd 19, xcf._.composite_rgb_05, xcf._.composite_rgb_05, xcf._.composite_indexed_00 ; Soft Light : XCF >= 2 only ('soft light' == 'overlay') |