kiv and libimg.asm: Follow asm style guide, no semantic changes.
git-svn-id: svn://kolibrios.org@8497 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -1,21 +1,25 @@
|
|||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
;;//// libimg.asm //// (c) mike.dld, 2007-2008, (c) diamond, 2009, (c) dunkaist, 2011-2013 ///////;;
|
;;//// libimg.asm //// (c) mike.dld, 2007-2008 ;;
|
||||||
;;================================================================================================;;
|
;; //// (c) diamond, 2009, ;;
|
||||||
|
;; //// (c) dunkaist, 2011-2020 ;;
|
||||||
|
;;============================================================================;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; This file is part of Common development libraries (Libs-Dev). ;;
|
;; This file is part of Common development libraries (Libs-Dev). ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
|
;; Libs-Dev is free software: you can redistribute it and/or modify it under ;;
|
||||||
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
|
;; the terms of the GNU Lesser General Public License as published by the ;;
|
||||||
;; of the License, or (at your option) any later version. ;;
|
;; Free Software Foundation, either version 2.1 of the License, or (at your ;;
|
||||||
|
;; option) any later version. ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
|
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ;;
|
||||||
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
|
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ;;
|
||||||
;; Lesser General Public License for more details. ;;
|
;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public ;;
|
||||||
|
;; License for more details. ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
|
;; You should have received a copy of the GNU Lesser General Public License ;;
|
||||||
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
;; along with Libs-Dev. If not, see <http://www.gnu.org/licenses/>. ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
|
|
||||||
|
|
||||||
format MS COFF
|
format MS COFF
|
||||||
@@ -58,18 +62,18 @@ COMPOSITE_MODE equ MMX
|
|||||||
; SSE | a bit faster, but may be unsupported by some CPUs
|
; SSE | a bit faster, but may be unsupported by some CPUs
|
||||||
include 'blend.asm'
|
include 'blend.asm'
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc lib_init ;///////////////////////////////////////////////////////////////////////////////////;;
|
proc lib_init ;///////////////////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? Library entry point (called after library load) ;;
|
;? Library entry point (called after library load) ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> eax = pointer to memory allocation routine ;;
|
;> eax = pointer to memory allocation routine ;;
|
||||||
;> ebx = pointer to memory freeing routine ;;
|
;> ebx = pointer to memory freeing routine ;;
|
||||||
;> ecx = pointer to memory reallocation routine ;;
|
;> ecx = pointer to memory reallocation routine ;;
|
||||||
;> edx = pointer to library loading routine ;;
|
;> edx = pointer to library loading routine ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = 1 (fail) / 0 (ok) (library initialization result) ;;
|
;< eax = 1 (fail) / 0 (ok) (library initialization result) ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
mov [mem.alloc], eax
|
mov [mem.alloc], eax
|
||||||
mov [mem.free], ebx
|
mov [mem.free], ebx
|
||||||
mov [mem.realloc], ecx
|
mov [mem.realloc], ecx
|
||||||
@@ -90,54 +94,57 @@ proc lib_init ;/////////////////////////////////////////////////////////////////
|
|||||||
mov dword [img._.do_rgb.handlers + (Image.bpp16-1)*4], img._.do_rgb.bpp16.intel
|
mov dword [img._.do_rgb.handlers + (Image.bpp16-1)*4], img._.do_rgb.bpp16.intel
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
.ok: xor eax,eax
|
.ok:
|
||||||
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.is_img _data, _length ;//////////////////////////////////////////////////////////////////;;
|
proc img.is_img _data, _length ;//////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? --- TBD --- ;;
|
;? --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> --- TBD --- ;;
|
;> --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< --- TBD --- ;;
|
;< --- TBD --- ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
push ebx
|
push ebx
|
||||||
mov ebx, img.formats_table
|
mov ebx, img.formats_table
|
||||||
@@: stdcall [ebx + FormatsTableEntry.Is], [_data], [_length]
|
@@:
|
||||||
|
stdcall [ebx + FormatsTableEntry.Is], [_data], [_length]
|
||||||
or eax, eax
|
or eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
add ebx, sizeof.FormatsTableEntry
|
add ebx, sizeof.FormatsTableEntry
|
||||||
cmp dword[ebx], 0
|
cmp dword[ebx], 0
|
||||||
jnz @b
|
jnz @b
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
@@: pop ebx
|
@@:
|
||||||
|
pop ebx
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.info _data, _length ;////////////////////////////////////////////////////////////////////;;
|
proc img.info _data, _length ;////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? --- TBD --- ;;
|
;? --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> --- TBD --- ;;
|
;> --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< --- TBD --- ;;
|
;< --- TBD --- ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.from_file _filename ;////////////////////////////////////////////////////////////////////;;
|
proc img.from_file _filename ;////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? load file from disk and decode it ;;
|
;? load file from disk and decode it ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> [_filename] = file name as passed to libio ;;
|
;> [_filename] = file name as passed to libio ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = 0 / pointer to image ;;
|
;< eax = 0 / pointer to image ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
locals
|
locals
|
||||||
fd dd ?
|
fd dd ?
|
||||||
img_data_len dd ?
|
img_data_len dd ?
|
||||||
@@ -177,42 +184,42 @@ endl
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.to_file _img, _filename ;////////////////////////////////////////////////////////////////;;
|
proc img.to_file _img, _filename ;////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? --- TBD --- ;;
|
;? --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> --- TBD --- ;;
|
;> --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = false / true ;;
|
;< eax = false / true ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.from_rgb _rgb_data ;/////////////////////////////////////////////////////////////////////;;
|
proc img.from_rgb _rgb_data ;/////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? --- TBD --- ;;
|
;? --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> --- TBD --- ;;
|
;> --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = 0 / pointer to image ;;
|
;< eax = 0 / pointer to image ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.to_rgb2 _img, _out ;/////////////////////////////////////////////////////////////////////;;
|
proc img.to_rgb2 _img, _out ;/////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? decodes image data into RGB triplets and stores them where [_out] points to;;
|
;? decodes image data into RGB triplets and stores them where [_out] points to;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> [_img] = pointer to source image ;;
|
;> [_img] = pointer to source image ;;
|
||||||
;> [_out] = where to store RGB triplets ;;
|
;> [_out] = where to store RGB triplets ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< none ;;
|
;< none ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
push esi edi
|
push esi edi
|
||||||
mov esi, [_img]
|
mov esi, [_img]
|
||||||
stdcall img._.validate, esi
|
stdcall img._.validate, esi
|
||||||
@@ -225,18 +232,19 @@ proc img.to_rgb2 _img, _out ;///////////////////////////////////////////////////
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.to_rgb _img ;////////////////////////////////////////////////////////////////////////////;;
|
proc img.to_rgb _img ;////////////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? decodes image data into RGB triplets and returns pointer to memory area of following structure:;;
|
;? decodes image data into RGB triplets and returns pointer to memory area of ;;
|
||||||
|
;? following structure: ;;
|
||||||
;? width dd ? ;;
|
;? width dd ? ;;
|
||||||
;? height dd ? ;;
|
;? height dd ? ;;
|
||||||
;? rgb triplets ;;
|
;? rgb triplets ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> [_img] = pointer to source image ;;
|
;> [_img] = pointer to source image ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = 0 / pointer to rgb_data (array of [rgb] triplets) ;;
|
;< eax = 0 / pointer to rgb_data (array of [rgb] triplets) ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
push esi edi
|
push esi edi
|
||||||
mov esi, [_img]
|
mov esi, [_img]
|
||||||
stdcall img._.validate, esi
|
stdcall img._.validate, esi
|
||||||
@@ -268,16 +276,16 @@ proc img.to_rgb _img ;//////////////////////////////////////////////////////////
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img._.do_rgb ;///////////////////////////////////////////////////////////////////////////////;;
|
proc img._.do_rgb ;///////////////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? decodes [esi + Image.Data] data into RGB triplets and stores them at [edi] ;;
|
;? decodes [esi + Image.Data] data into RGB triplets and stores them at [edi] ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> esi = pointer to source image ;;
|
;> esi = pointer to source image ;;
|
||||||
;> edi = pointer to memory to store RGB triplets ;;
|
;> edi = pointer to memory to store RGB triplets ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< none ;;
|
;< none ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
mov ecx, [esi + Image.Width]
|
mov ecx, [esi + Image.Width]
|
||||||
imul ecx, [esi + Image.Height]
|
imul ecx, [esi + Image.Height]
|
||||||
mov eax, [esi + Image.Type]
|
mov eax, [esi + Image.Type]
|
||||||
@@ -708,23 +716,24 @@ align 16
|
|||||||
|
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.decode _data, _length, _options ;////////////////////////////////////////////////////////;;
|
proc img.decode _data, _length, _options ;////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? decodes loaded into memory graphic file ;;
|
;? decodes loaded into memory graphic file ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> [_data] = pointer to file in memory ;;
|
;> [_data] = pointer to file in memory ;;
|
||||||
;> [_length] = size in bytes of memory area pointed to by [_data] ;;
|
;> [_length] = size in bytes of memory area pointed to by [_data] ;;
|
||||||
;> [_options] = 0 / pointer to the structure of additional options ;;
|
;> [_options] = 0 / pointer to the structure of additional options ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = 0 / pointer to image ;;
|
;< eax = 0 / pointer to image ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
push ebx
|
push ebx
|
||||||
mov ebx, [_length]
|
mov ebx, [_length]
|
||||||
or ebx, ebx
|
or ebx, ebx
|
||||||
jz .fail
|
jz .fail
|
||||||
mov ebx, img.formats_table
|
mov ebx, img.formats_table
|
||||||
@@: stdcall [ebx + FormatsTableEntry.Is], [_data], [_length]
|
@@:
|
||||||
|
stdcall [ebx + FormatsTableEntry.Is], [_data], [_length]
|
||||||
or eax, eax
|
or eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
add ebx, sizeof.FormatsTableEntry
|
add ebx, sizeof.FormatsTableEntry
|
||||||
@@ -734,41 +743,47 @@ proc img.decode _data, _length, _options ;//////////////////////////////////////
|
|||||||
xor eax, eax
|
xor eax, eax
|
||||||
pop ebx
|
pop ebx
|
||||||
ret
|
ret
|
||||||
@@: mov eax, [ebx + FormatsTableEntry.Decode]
|
@@:
|
||||||
|
mov eax, [ebx + FormatsTableEntry.Decode]
|
||||||
pop ebx
|
pop ebx
|
||||||
leave
|
leave
|
||||||
jmp eax
|
jmp eax
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.encode uses ebx, _img, _common, _specific ;////////////////////////////////////////////////////////;;
|
proc img.encode uses ebx, _img, _common, _specific ;//////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? encode image to some format ;;
|
;? encode image to some format ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> [_img] = pointer to input image ;;
|
;> [_img] = pointer to input image ;;
|
||||||
;> [_common] = some most important/common options ;;
|
;> [_common] = some most important/common options ;;
|
||||||
; 0x00 : byte : format id (defined in libimg.inc) ;;
|
; 0x00 : byte : format id (defined in libimg.inc) ;;
|
||||||
; 0x01 : byte : fast encoding (0) / best compression ratio (255) ;;
|
; 0x01 : byte : fast encoding (0) / best compression ratio (255) ;;
|
||||||
; 0 : store uncompressed data (if supported both by the format and libimg) ;;
|
; 0 : store uncompressed data (if supported both by the ;;
|
||||||
|
; format and libimg) ;;
|
||||||
; 1 - 255 : use compression, if supported ;;
|
; 1 - 255 : use compression, if supported ;;
|
||||||
; this option may be ignored if any format specific options are defined ;;
|
; this option may be ignored if any format specific ;;
|
||||||
; i.e. 0 here will be ignored if particular compression algorithm is specified ;;
|
; options are defined, i.e. 0 here will be ignored if ;;
|
||||||
|
; particular compression algorithm is specified ;;
|
||||||
; 0x02 : byte : flags (bitfield) ;;
|
; 0x02 : byte : flags (bitfield) ;;
|
||||||
; 0x01 : return an error if format specific conditions cannot be met ;;
|
; 0x01 : return an error if format specific conditions ;;
|
||||||
; 0x02 : preserve current bit depth. means 8bpp/16bpp/24bpp and so on ;;
|
; cannot be met ;;
|
||||||
|
; 0x02 : preserve current bit depth. means 8bpp/16bpp/ ;;
|
||||||
|
; 24bpp and so on ;;
|
||||||
; 0x04 : delete alpha channel, if any ;;
|
; 0x04 : delete alpha channel, if any ;;
|
||||||
; 0x08 : flush alpha channel with 0xff, if any; add it if none ;;
|
; 0x08 : flush alpha channel with 0xff, if any; add it if ;;
|
||||||
|
; none ;;
|
||||||
; 0x03 : byte : reserved, must be 0 ;;
|
; 0x03 : byte : reserved, must be 0 ;;
|
||||||
;> [_specific] = 0 / pointer to the structure of format specific options ;;
|
;> [_specific] = 0 / pointer to the structure of format specific options ;;
|
||||||
; see <format_name>.inc for description ;;
|
; see <format_name>.inc for description ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = 0 / pointer to encoded data ;;
|
;< eax = 0 / pointer to encoded data ;;
|
||||||
;< ecx = error code / the size of encoded data ;;
|
;< ecx = error code / the size of encoded data ;;
|
||||||
; 1 : out of memory ;;
|
; 1 : out of memory ;;
|
||||||
; 2 : format is not supported ;;
|
; 2 : format is not supported ;;
|
||||||
; 3 : specific conditions cannot be satisfied ;;
|
; 3 : specific conditions cannot be satisfied ;;
|
||||||
; 4 : bit depth cannot be preserved ;;
|
; 4 : bit depth cannot be preserved ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
mov ebx, [_img]
|
mov ebx, [_img]
|
||||||
|
|
||||||
movzx eax, byte[_common]
|
movzx eax, byte[_common]
|
||||||
@@ -830,17 +845,17 @@ proc img.encode uses ebx, _img, _common, _specific ;////////////////////////////
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.create _width, _height, _type ;//////////////////////////////////////////////////////////;;
|
proc img.create _width, _height, _type ;//////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? creates an Image structure and initializes some its fields ;;
|
;? creates an Image structure and initializes some its fields ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> [_width] = width of an image in pixels ;;
|
;> [_width] = width of an image in pixels ;;
|
||||||
;> [_height] = height of an image in pixels ;;
|
;> [_height] = height of an image in pixels ;;
|
||||||
;> [_type] = one of the Image.bppN constants from libimg.inc ;;
|
;> [_type] = one of the Image.bppN constants from libimg.inc ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = 0 / pointer to image ;;
|
;< eax = 0 / pointer to image ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
push ecx
|
push ecx
|
||||||
|
|
||||||
stdcall img._.new
|
stdcall img._.new
|
||||||
@@ -870,16 +885,17 @@ proc img.create _width, _height, _type ;////////////////////////////////////////
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.destroy.layer _img ;/////////////////////////////////////////////////////////////////////;;
|
proc img.destroy.layer _img ;/////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? frees memory occupied by an image and all the memory regions its fields point to ;;
|
;? Frees memory occupied by an image and all the memory regions its fields ;;
|
||||||
;? for image sequences deletes only one frame and fixes Previous/Next pointers ;;
|
;? point to. For image sequences deletes only one frame and fixes Previous/ ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;? Next pointers. ;;
|
||||||
|
;;----------------------------------------------------------------------------;;
|
||||||
;> [_img] = pointer to image ;;
|
;> [_img] = pointer to image ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = 0 (fail) / 1 (success) ;;
|
;< eax = 0 (fail) / 1 (success) ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
mov eax, [_img]
|
mov eax, [_img]
|
||||||
mov edx, [eax + Image.Previous]
|
mov edx, [eax + Image.Previous]
|
||||||
test edx, edx
|
test edx, edx
|
||||||
@@ -897,16 +913,17 @@ proc img.destroy.layer _img ;///////////////////////////////////////////////////
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.destroy _img ;///////////////////////////////////////////////////////////////////////////;;
|
proc img.destroy _img ;///////////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? frees memory occupied by an image and all the memory regions its fields point to ;;
|
;? Frees memory occupied by an image and all the memory regions its fields ;;
|
||||||
;? follows Previous/Next pointers and deletes all the images in sequence ;;
|
;? point to. Follows Previous/Next pointers and deletes all the images in ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;? sequence. ;;
|
||||||
|
;;----------------------------------------------------------------------------;;
|
||||||
;> [_img] = pointer to image ;;
|
;> [_img] = pointer to image ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = 0 (fail) / 1 (success) ;;
|
;< eax = 0 (fail) / 1 (success) ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
push 1
|
push 1
|
||||||
mov eax, [_img]
|
mov eax, [_img]
|
||||||
mov eax, [eax + Image.Previous]
|
mov eax, [eax + Image.Previous]
|
||||||
@@ -937,29 +954,32 @@ proc img.destroy _img ;/////////////////////////////////////////////////////////
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.count _img ;/////////////////////////////////////////////////////////////////////////////;;
|
proc img.count _img ;/////////////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? Get number of images in the list (e.g. in animated GIF file) ;;
|
;? Get number of images in the list (e.g. in animated GIF file) ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> _img = pointer to image ;;
|
;> _img = pointer to image ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = -1 (fail) / >0 (ok) ;;
|
;< eax = -1 (fail) / >0 (ok) ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
push ecx edx
|
push ecx edx
|
||||||
mov edx, [_img]
|
mov edx, [_img]
|
||||||
stdcall img._.validate, edx
|
stdcall img._.validate, edx
|
||||||
or eax, eax
|
or eax, eax
|
||||||
jnz .error
|
jnz .error
|
||||||
|
|
||||||
@@: mov eax, [edx + Image.Previous]
|
@@:
|
||||||
|
mov eax, [edx + Image.Previous]
|
||||||
or eax, eax
|
or eax, eax
|
||||||
jz @f
|
jz @f
|
||||||
mov edx, eax
|
mov edx, eax
|
||||||
jmp @b
|
jmp @b
|
||||||
|
|
||||||
@@: xor ecx, ecx
|
@@:
|
||||||
@@: inc ecx
|
xor ecx, ecx
|
||||||
|
@@:
|
||||||
|
inc ecx
|
||||||
mov eax, [edx + Image.Next]
|
mov eax, [edx + Image.Next]
|
||||||
or eax, eax
|
or eax, eax
|
||||||
jz .exit
|
jz .exit
|
||||||
@@ -977,44 +997,44 @@ proc img.count _img ;///////////////////////////////////////////////////////////
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;//// image processing //////////////////////////////////////////////////////////////////////////;;
|
;;//// image processing //////////////////////////////////////////////////////;;
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.lock_bits _img, _start_line, _end_line ;/////////////////////////////////////////////////;;
|
proc img.lock_bits _img, _start_line, _end_line ;/////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? --- TBD --- ;;
|
;? --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> --- TBD --- ;;
|
;> --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = 0 / pointer to bits ;;
|
;< eax = 0 / pointer to bits ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.unlock_bits _img, _lock ;////////////////////////////////////////////////////////////////;;
|
proc img.unlock_bits _img, _lock ;////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? --- TBD --- ;;
|
;? --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> --- TBD --- ;;
|
;> --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = false / true ;;
|
;< eax = false / true ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.flip.layer _img, _flip_kind ;////////////////////////////////////////////////////////////;;
|
proc img.flip.layer _img, _flip_kind ;////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? Flip image layer ;;
|
;? Flip image layer ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> _img = pointer to image ;;
|
;> _img = pointer to image ;;
|
||||||
;> _flip_kind = one of FLIP_* constants ;;
|
;> _flip_kind = one of FLIP_* constants ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = false / true ;;
|
;< eax = false / true ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
locals
|
locals
|
||||||
scanline_len dd ?
|
scanline_len dd ?
|
||||||
endl
|
endl
|
||||||
@@ -1096,7 +1116,8 @@ endl
|
|||||||
|
|
||||||
mov ecx, [scanline_len]
|
mov ecx, [scanline_len]
|
||||||
shr ecx, 3
|
shr ecx, 3
|
||||||
@@: mov eax, [esi]
|
@@:
|
||||||
|
mov eax, [esi]
|
||||||
xchg eax, [edi]
|
xchg eax, [edi]
|
||||||
mov [esi], eax
|
mov [esi], eax
|
||||||
add esi, 4
|
add esi, 4
|
||||||
@@ -1117,7 +1138,8 @@ endl
|
|||||||
push ecx esi edi
|
push ecx esi edi
|
||||||
|
|
||||||
mov ecx, [ebx + Image.Width]
|
mov ecx, [ebx + Image.Width]
|
||||||
@@: mov ax, [esi]
|
@@:
|
||||||
|
mov ax, [esi]
|
||||||
mov dx, [edi]
|
mov dx, [edi]
|
||||||
mov [edi], ax
|
mov [edi], ax
|
||||||
mov [esi], dx
|
mov [esi], dx
|
||||||
@@ -1140,7 +1162,8 @@ endl
|
|||||||
|
|
||||||
mov ecx, [scanline_len]
|
mov ecx, [scanline_len]
|
||||||
shr ecx, 1
|
shr ecx, 1
|
||||||
@@: mov al, [esi]
|
@@:
|
||||||
|
mov al, [esi]
|
||||||
mov dl, [edi]
|
mov dl, [edi]
|
||||||
mov [edi], al
|
mov [edi], al
|
||||||
mov [esi], dl
|
mov [esi], dl
|
||||||
@@ -1380,16 +1403,16 @@ endl
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.flip _img, _flip_kind ;//////////////////////////////////////////////////////////////////;;
|
proc img.flip _img, _flip_kind ;//////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? Flip all layers of image ;;
|
;? Flip all layers of image ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> _img = pointer to image ;;
|
;> _img = pointer to image ;;
|
||||||
;> _flip_kind = one of FLIP_* constants ;;
|
;> _flip_kind = one of FLIP_* constants ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = false / true ;;
|
;< eax = false / true ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
push 1
|
push 1
|
||||||
mov ebx, [_img]
|
mov ebx, [_img]
|
||||||
@@:
|
@@:
|
||||||
@@ -1411,16 +1434,16 @@ proc img.flip _img, _flip_kind ;////////////////////////////////////////////////
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.rotate.layer _img, _rotate_kind ;////////////////////////////////////////////////////////;;
|
proc img.rotate.layer _img, _rotate_kind ;////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? Rotate image layer ;;
|
;? Rotate image layer ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> _img = pointer to image ;;
|
;> _img = pointer to image ;;
|
||||||
;> _rotate_kind = one of ROTATE_* constants ;;
|
;> _rotate_kind = one of ROTATE_* constants ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = false / true ;;
|
;< eax = false / true ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
locals
|
locals
|
||||||
scanline_len_old dd ?
|
scanline_len_old dd ?
|
||||||
scanline_len_new dd ?
|
scanline_len_new dd ?
|
||||||
@@ -1492,7 +1515,8 @@ endl
|
|||||||
mov ecx, [scanline_pixels_new]
|
mov ecx, [scanline_pixels_new]
|
||||||
mov esi, [ebx + Image.Data]
|
mov esi, [ebx + Image.Data]
|
||||||
mov edi, [line_buffer]
|
mov edi, [line_buffer]
|
||||||
@@: mov ax, [esi]
|
@@:
|
||||||
|
mov ax, [esi]
|
||||||
mov [edi], ax
|
mov [edi], ax
|
||||||
add esi, edx
|
add esi, edx
|
||||||
add edi, 2
|
add edi, 2
|
||||||
@@ -1503,7 +1527,8 @@ endl
|
|||||||
mov edi, [ebx + Image.Data]
|
mov edi, [ebx + Image.Data]
|
||||||
lea esi, [edi + 2]
|
lea esi, [edi + 2]
|
||||||
mov edx, [scanline_len_old]
|
mov edx, [scanline_len_old]
|
||||||
@@: mov ecx, edx
|
@@:
|
||||||
|
mov ecx, edx
|
||||||
shr ecx, 2
|
shr ecx, 2
|
||||||
rep movsd
|
rep movsd
|
||||||
mov ecx, edx
|
mov ecx, edx
|
||||||
@@ -1540,7 +1565,8 @@ endl
|
|||||||
mov ecx, [scanline_pixels_new]
|
mov ecx, [scanline_pixels_new]
|
||||||
mov esi, [ebx + Image.Data]
|
mov esi, [ebx + Image.Data]
|
||||||
mov edi, [line_buffer]
|
mov edi, [line_buffer]
|
||||||
@@: mov eax, [esi]
|
@@:
|
||||||
|
mov eax, [esi]
|
||||||
stosd
|
stosd
|
||||||
add esi, edx
|
add esi, edx
|
||||||
dec ecx
|
dec ecx
|
||||||
@@ -1551,7 +1577,8 @@ endl
|
|||||||
lea esi, [edi + 4]
|
lea esi, [edi + 4]
|
||||||
mov edx, [scanline_len_old]
|
mov edx, [scanline_len_old]
|
||||||
shr edx, 2
|
shr edx, 2
|
||||||
@@: mov ecx, edx
|
@@:
|
||||||
|
mov ecx, edx
|
||||||
rep movsd
|
rep movsd
|
||||||
add esi, 4
|
add esi, 4
|
||||||
dec eax
|
dec eax
|
||||||
@@ -1579,7 +1606,8 @@ endl
|
|||||||
mov ecx, [scanline_pixels_new]
|
mov ecx, [scanline_pixels_new]
|
||||||
mov esi, [ebx + Image.Data]
|
mov esi, [ebx + Image.Data]
|
||||||
mov edi, [line_buffer]
|
mov edi, [line_buffer]
|
||||||
@@: mov al, [esi]
|
@@:
|
||||||
|
mov al, [esi]
|
||||||
mov [edi], al
|
mov [edi], al
|
||||||
add esi, edx
|
add esi, edx
|
||||||
add edi, 1
|
add edi, 1
|
||||||
@@ -1590,7 +1618,8 @@ endl
|
|||||||
mov edi, [ebx + Image.Data]
|
mov edi, [ebx + Image.Data]
|
||||||
lea esi, [edi + 1]
|
lea esi, [edi + 1]
|
||||||
mov edx, [scanline_len_old]
|
mov edx, [scanline_len_old]
|
||||||
@@: mov ecx, edx
|
@@:
|
||||||
|
mov ecx, edx
|
||||||
shr ecx, 2
|
shr ecx, 2
|
||||||
rep movsd
|
rep movsd
|
||||||
mov ecx, edx
|
mov ecx, edx
|
||||||
@@ -1627,7 +1656,8 @@ endl
|
|||||||
mov ecx, [scanline_pixels_new]
|
mov ecx, [scanline_pixels_new]
|
||||||
mov esi, [ebx + Image.Data]
|
mov esi, [ebx + Image.Data]
|
||||||
mov edi, [line_buffer]
|
mov edi, [line_buffer]
|
||||||
@@: mov al, [esi]
|
@@:
|
||||||
|
mov al, [esi]
|
||||||
mov [edi], al
|
mov [edi], al
|
||||||
mov al, [esi+1]
|
mov al, [esi+1]
|
||||||
mov [edi+1], al
|
mov [edi+1], al
|
||||||
@@ -1642,7 +1672,8 @@ endl
|
|||||||
mov edi, [ebx + Image.Data]
|
mov edi, [ebx + Image.Data]
|
||||||
lea esi, [edi + 3]
|
lea esi, [edi + 3]
|
||||||
mov edx, [scanline_len_old]
|
mov edx, [scanline_len_old]
|
||||||
@@: mov ecx, edx
|
@@:
|
||||||
|
mov ecx, edx
|
||||||
shr ecx, 2
|
shr ecx, 2
|
||||||
rep movsd
|
rep movsd
|
||||||
mov ecx, edx
|
mov ecx, edx
|
||||||
@@ -1942,7 +1973,8 @@ endl
|
|||||||
mov esi, [pixels_ptr]
|
mov esi, [pixels_ptr]
|
||||||
add esi, -2
|
add esi, -2
|
||||||
mov edi, [line_buffer]
|
mov edi, [line_buffer]
|
||||||
@@: mov ax, [esi]
|
@@:
|
||||||
|
mov ax, [esi]
|
||||||
mov [edi], ax
|
mov [edi], ax
|
||||||
sub esi, edx
|
sub esi, edx
|
||||||
add edi, 2
|
add edi, 2
|
||||||
@@ -1955,7 +1987,8 @@ endl
|
|||||||
add edi, [scanline_len_old]
|
add edi, [scanline_len_old]
|
||||||
lea esi, [edi + 2]
|
lea esi, [edi + 2]
|
||||||
mov edx, [scanline_len_old]
|
mov edx, [scanline_len_old]
|
||||||
@@: mov ecx, edx
|
@@:
|
||||||
|
mov ecx, edx
|
||||||
shr ecx, 2
|
shr ecx, 2
|
||||||
rep movsd
|
rep movsd
|
||||||
mov ecx, edx
|
mov ecx, edx
|
||||||
@@ -1992,7 +2025,8 @@ endl
|
|||||||
mov esi, [pixels_ptr]
|
mov esi, [pixels_ptr]
|
||||||
add esi, -4
|
add esi, -4
|
||||||
mov edi, [line_buffer]
|
mov edi, [line_buffer]
|
||||||
@@: mov eax, [esi]
|
@@:
|
||||||
|
mov eax, [esi]
|
||||||
stosd
|
stosd
|
||||||
sub esi, edx
|
sub esi, edx
|
||||||
dec ecx
|
dec ecx
|
||||||
@@ -2005,7 +2039,8 @@ endl
|
|||||||
lea esi, [edi + 4]
|
lea esi, [edi + 4]
|
||||||
mov edx, [scanline_len_old]
|
mov edx, [scanline_len_old]
|
||||||
shr edx, 2
|
shr edx, 2
|
||||||
@@: mov ecx, edx
|
@@:
|
||||||
|
mov ecx, edx
|
||||||
rep movsd
|
rep movsd
|
||||||
add esi, 4
|
add esi, 4
|
||||||
dec eax
|
dec eax
|
||||||
@@ -2034,7 +2069,8 @@ endl
|
|||||||
mov esi, [pixels_ptr]
|
mov esi, [pixels_ptr]
|
||||||
add esi, -1
|
add esi, -1
|
||||||
mov edi, [line_buffer]
|
mov edi, [line_buffer]
|
||||||
@@: mov al, [esi]
|
@@:
|
||||||
|
mov al, [esi]
|
||||||
mov [edi], al
|
mov [edi], al
|
||||||
sub esi, edx
|
sub esi, edx
|
||||||
add edi, 1
|
add edi, 1
|
||||||
@@ -2047,7 +2083,8 @@ endl
|
|||||||
add edi, [scanline_len_old]
|
add edi, [scanline_len_old]
|
||||||
lea esi, [edi + 1]
|
lea esi, [edi + 1]
|
||||||
mov edx, [scanline_len_old]
|
mov edx, [scanline_len_old]
|
||||||
@@: mov ecx, edx
|
@@:
|
||||||
|
mov ecx, edx
|
||||||
shr ecx, 2
|
shr ecx, 2
|
||||||
rep movsd
|
rep movsd
|
||||||
mov ecx, edx
|
mov ecx, edx
|
||||||
@@ -2084,7 +2121,8 @@ endl
|
|||||||
mov esi, [pixels_ptr]
|
mov esi, [pixels_ptr]
|
||||||
add esi, -3
|
add esi, -3
|
||||||
mov edi, [line_buffer]
|
mov edi, [line_buffer]
|
||||||
@@: mov al, [esi]
|
@@:
|
||||||
|
mov al, [esi]
|
||||||
mov [edi], al
|
mov [edi], al
|
||||||
mov al, [esi+1]
|
mov al, [esi+1]
|
||||||
mov [edi+1], al
|
mov [edi+1], al
|
||||||
@@ -2101,7 +2139,8 @@ endl
|
|||||||
add edi, [scanline_len_old]
|
add edi, [scanline_len_old]
|
||||||
lea esi, [edi + 3]
|
lea esi, [edi + 3]
|
||||||
mov edx, [scanline_len_old]
|
mov edx, [scanline_len_old]
|
||||||
@@: mov ecx, edx
|
@@:
|
||||||
|
mov ecx, edx
|
||||||
shr ecx, 2
|
shr ecx, 2
|
||||||
rep movsd
|
rep movsd
|
||||||
mov ecx, edx
|
mov ecx, edx
|
||||||
@@ -2374,16 +2413,16 @@ endl
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.rotate _img, _rotate_kind ;//////////////////////////////////////////////////////////////;;
|
proc img.rotate _img, _rotate_kind ;//////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? Rotate all layers of image ;;
|
;? Rotate all layers of image ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> _img = pointer to image ;;
|
;> _img = pointer to image ;;
|
||||||
;> _rotate_kind = one of ROTATE_* constants ;;
|
;> _rotate_kind = one of ROTATE_* constants ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = false / true ;;
|
;< eax = false / true ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
push 1
|
push 1
|
||||||
mov ebx, [_img]
|
mov ebx, [_img]
|
||||||
@@:
|
@@:
|
||||||
@@ -2405,11 +2444,11 @@ proc img.rotate _img, _rotate_kind ;////////////////////////////////////////////
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.draw _img, _x, _y, _width, _height, _xpos, _ypos ;///////////////////////////////////////;;
|
proc img.draw _img, _x, _y, _width, _height, _xpos, _ypos ;///////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? Draw image in the window ;;
|
;? Draw image in the window ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> _img = pointer to image ;;
|
;> _img = pointer to image ;;
|
||||||
;>_x = x-coordinate in the window ;;
|
;>_x = x-coordinate in the window ;;
|
||||||
;>_y = y-coordinate in the window ;;
|
;>_y = y-coordinate in the window ;;
|
||||||
@@ -2417,9 +2456,9 @@ proc img.draw _img, _x, _y, _width, _height, _xpos, _ypos ;/////////////////////
|
|||||||
;>_height = maximum height to draw ;;
|
;>_height = maximum height to draw ;;
|
||||||
;>_xpos = offset in image by x-axis ;;
|
;>_xpos = offset in image by x-axis ;;
|
||||||
;>_ypos = offset in image by y-axis ;;
|
;>_ypos = offset in image by y-axis ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< no return value ;;
|
;< no return value ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
push ebx esi edi
|
push ebx esi edi
|
||||||
mov ebx, [_img]
|
mov ebx, [_img]
|
||||||
stdcall img._.validate, ebx
|
stdcall img._.validate, ebx
|
||||||
@@ -2487,37 +2526,37 @@ img.formats_table:
|
|||||||
.z80 dd LIBIMG_FORMAT_Z80, img.is.z80, img.decode.z80, img.encode.z80, 0 ;this must be the last entry as there are no signatures in z80 screens at all
|
.z80 dd LIBIMG_FORMAT_Z80, img.is.z80, img.decode.z80, img.encode.z80, 0 ;this must be the last entry as there are no signatures in z80 screens at all
|
||||||
dd 0
|
dd 0
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
;;////////////////////////////////////////////////////////////////////////////;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
;! Below are private procs you should never call directly from your code ;;
|
;! Below are private procs you should never call directly from your code ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
;;////////////////////////////////////////////////////////////////////////////;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
|
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img._.validate, _img ;///////////////////////////////////////////////////////////////////////;;
|
proc img._.validate, _img ;///////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? --- TBD --- ;;
|
;? --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> --- TBD --- ;;
|
;> --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< --- TBD --- ;;
|
;< --- TBD --- ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img._.new ;//////////////////////////////////////////////////////////////////////////////////;;
|
proc img._.new ;//////////////////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? --- TBD --- ;;
|
;? --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> --- TBD --- ;;
|
;> --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = 0 / pointer to image ;;
|
;< eax = 0 / pointer to image ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
invoke mem.alloc, sizeof.Image
|
invoke mem.alloc, sizeof.Image
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz @f
|
jz @f
|
||||||
@@ -2534,41 +2573,44 @@ proc img._.new ;////////////////////////////////////////////////////////////////
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img._.delete _img ;//////////////////////////////////////////////////////////////////////////;;
|
proc img._.delete _img ;//////////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? --- TBD --- ;;
|
;? --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> --- TBD --- ;;
|
;> --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = false / true ;;
|
;< eax = false / true ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
push edx
|
push edx
|
||||||
mov edx, [_img]
|
mov edx, [_img]
|
||||||
cmp [edx + Image.Data], 0
|
cmp [edx + Image.Data], 0
|
||||||
je @f
|
je @f
|
||||||
invoke mem.free, [edx + Image.Data]
|
invoke mem.free, [edx + Image.Data]
|
||||||
@@: cmp [edx + Image.Extended], 0
|
@@:
|
||||||
|
cmp [edx + Image.Extended], 0
|
||||||
je @f
|
je @f
|
||||||
invoke mem.free, [edx + Image.Extended]
|
invoke mem.free, [edx + Image.Extended]
|
||||||
@@: invoke mem.free, edx
|
@@:
|
||||||
|
invoke mem.free, edx
|
||||||
pop edx
|
pop edx
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
proc img.resize_data _img, _width, _height ;//////////////////////////////////////////////////////;;
|
proc img.resize_data _img, _width, _height ;//////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? Resize data block of image. New size is calculated from _width and _height params and internal ;;
|
;? Resize data block of image. New size is calculated from _width and _height ;;
|
||||||
;? Image.Type value. All the internal fields are updated iff succeeded. ;;
|
;? params and internal Image.Type value. All the internal fields are updated ;;
|
||||||
;? This function does not scale images, use img.scale if you need to. ;;
|
;? iff succeeded. This function does not scale images, use img.scale if you ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;? need to. ;;
|
||||||
|
;;----------------------------------------------------------------------------;;
|
||||||
;> _img = pointer to image ;;
|
;> _img = pointer to image ;;
|
||||||
;> _width = new width ;;
|
;> _width = new width ;;
|
||||||
;> _height = new height ;;
|
;> _height = new height ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = 0 (fail) / pointer to the new pixels data ;;
|
;< eax = 0 (fail) / pointer to the new pixels data ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
push ebx esi
|
push ebx esi
|
||||||
mov ebx, [_img]
|
mov ebx, [_img]
|
||||||
mov eax, [_height]
|
mov eax, [_height]
|
||||||
@@ -2698,16 +2740,16 @@ proc img.resize_data _img, _width, _height ;////////////////////////////////////
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
img._.get_scanline_len: ;/////////////////////////////////////////////////////////////////////////;;
|
img._.get_scanline_len: ;/////////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;? Get scanline length of image in bytes ;;
|
;? Get scanline length of image in bytes ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;> eax = width of image in pixels ;;
|
;> eax = width of image in pixels ;;
|
||||||
;> ebx = image ;;
|
;> ebx = image ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;----------------------------------------------------------------------------;;
|
||||||
;< eax = scanline length in bytes ;;
|
;< eax = scanline length in bytes ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
cmp [ebx + Image.Type], Image.bpp1
|
cmp [ebx + Image.Type], Image.bpp1
|
||||||
jz .bpp1.1
|
jz .bpp1.1
|
||||||
cmp [ebx + Image.Type], Image.bpp2i
|
cmp [ebx + Image.Type], Image.bpp2i
|
||||||
@@ -2749,13 +2791,13 @@ img._.get_scanline_len: ;///////////////////////////////////////////////////////
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
;;////////////////////////////////////////////////////////////////////////////;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
;! Below is private data you should never use directly from your code ;;
|
;! Below is private data you should never use directly from your code ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
;;////////////////////////////////////////////////////////////////////////////;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
|
|
||||||
section '.data' data readable writable align 16
|
section '.data' data readable writable align 16
|
||||||
;include_debug_strings
|
;include_debug_strings
|
||||||
@@ -2784,13 +2826,13 @@ img.flip.layer.handlers_horz:
|
|||||||
dd img.flip.layer.bpp2i_horz
|
dd img.flip.layer.bpp2i_horz
|
||||||
dd img.flip.layer.bpp4i_horz
|
dd img.flip.layer.bpp4i_horz
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
;;////////////////////////////////////////////////////////////////////////////;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
;! Exported functions section ;;
|
;! Exported functions section ;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
;;////////////////////////////////////////////////////////////////////////////;;
|
||||||
;;================================================================================================;;
|
;;============================================================================;;
|
||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
|
@@ -37,7 +37,8 @@ START:
|
|||||||
mcall SF_SYSTEM, SSF_MOUSE_SETTINGS, SSSF_SET_SPEEDUP, 5
|
mcall SF_SYSTEM, SSF_MOUSE_SETTINGS, SSSF_SET_SPEEDUP, 5
|
||||||
mcall SF_SYS_MISC, SSF_HEAP_INIT
|
mcall SF_SYS_MISC, SSF_HEAP_INIT
|
||||||
mcall SF_KEYBOARD, SSF_SET_INPUT_MODE, 1 ; set kbd mode to scancodes
|
mcall SF_KEYBOARD, SSF_SET_INPUT_MODE, 1 ; set kbd mode to scancodes
|
||||||
mcall SF_SET_EVENTS_MASK, EVM_REDRAW or EVM_KEY or EVM_BUTTON or EVM_MOUSE or EVM_MOUSE_FILTER
|
mcall SF_SET_EVENTS_MASK, EVM_REDRAW or EVM_KEY or EVM_BUTTON or \
|
||||||
|
EVM_MOUSE or EVM_MOUSE_FILTER
|
||||||
|
|
||||||
stdcall dll.Load, @IMPORT
|
stdcall dll.Load, @IMPORT
|
||||||
or eax, eax
|
or eax, eax
|
||||||
@@ -1062,7 +1063,7 @@ proc draw_window
|
|||||||
cmp [window.width], 0
|
cmp [window.width], 0
|
||||||
jne @f
|
jne @f
|
||||||
mcall SF_GET_SCREEN_SIZE
|
mcall SF_GET_SCREEN_SIZE
|
||||||
mov ebx,eax ;
|
mov ebx, eax
|
||||||
shr ebx, 16 ; ebx = width
|
shr ebx, 16 ; ebx = width
|
||||||
movzx esi, ax ; esi = height
|
movzx esi, ax ; esi = height
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user