Libs-dev: libio, libini, libgfx, libimg

git-svn-id: svn://kolibrios.org@717 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Mihail Semenyako (mike.dld) 2008-02-07 22:45:15 +00:00
parent c3db1855f8
commit 9a8b3fd945
18 changed files with 5450 additions and 0 deletions

View File

@ -0,0 +1,417 @@
use32
org 0x0
db 'MENUET01'
dd 0x01
dd START
dd I_END
dd 0x1000
dd 0x1000
dd 0x0
dd 0x0
FALSE = 0
TRUE = 1
include '../../../../../proc32.inc'
include '../../../../../macros.inc'
include '../../libio/libio.inc'
include '../dll.inc'
yy dd 20
proc draw xx,color,key,val
pushad
mov esi,[key]
mov edi,buf
cld
mov al,"'"
stosb
@@: lodsb
stosb
or al,al
jnz @b
mov word[edi-1],"'"
mov esi,[val]
or esi,esi
je .noval
mov eax," = '"
stosd
@@: lodsb
stosb
or al,al
jnz @b
mov word[edi-1],"'"
.noval:
or [color],0x80000000
mcall 4,<[xx],[yy]>,[color],buf
add [yy],10
popad
ret
endp
proc callb_k f_name,sec_name,key_name,key_val
stdcall draw,224,0x0000FF,[key_name],[key_val]
mov eax,TRUE
ret
endp
proc callb f_name,sec_name
stdcall draw,200,0xFF0000,[sec_name],0
invoke ini.enum_keys,[f_name],[sec_name],callb_k
mov eax,TRUE
ret
endp
;---------------------------------------------------------------------
;--- ÍÀ×ÀËÎ ÏÐÎÃÐÀÌÌÛ ----------------------------------------------
;---------------------------------------------------------------------
s_key1 db "LeftViewMode",0
s_key2 db "RightViewMode",0
s_null db "",0
macro wildcard_test_data label1, label2, label3, [str1, str2, res]
{
common
label label1
forward
local ..lbl
dd ..lbl - $
db str1,0
..lbl:
common
dd 0
label label2
forward
local ..lbl
dd ..lbl - $
db str2,0
..lbl:
common
label label3
forward
if res = "t"
dd 1
else
dd 0
end if
}
wildcard_test_data _str1, _str2, _str3, \
"" ,"" ,"t", "" ,"a" ,"f", \
"a" ,"a" ,"t", "a" ,"b" ,"f", \
"?" ,"b" ,"t", "??" ,"bc" ,"t", \
"?c" ,"bc" ,"t", "b?" ,"bc" ,"t", \
"[a-z]" ,"b" ,"t", "[A-Z]" ,"b" ,"f", \
"*" ,"a" ,"t", "**" ,"a" ,"t", \
"*" ,"" ,"t", "*bc*hij" ,"abcdfghij","t", \
"*b*a*" ,"b" ,"f", "*bc*hik" ,"abcdfghij","f", \
"abc*" ,"abc" ,"t", "abc**" ,"abc" ,"t", \
"[^]]" ,"^" ,"t", "[^]]" ,"]" ,"f", \
"[^abc]" ,"d" ,"t", "[^abc]" ,"b" ,"f", \
"*???" ,"abc" ,"t", "*???" ,"ab" ,"f", \
"*???" ,"abcd" ,"t", "*?*" ,"abcd" ,"t", \
"*bc" ,"abc" ,"t", "*cc" ,"abc" ,"f", \
"[a-c]*" ,"d" ,"f", "*[a-e]" ,"d" ,"t", \
"*a*" ,"de" ,"f", "*[a-c]" ,"d" ,"f", \
"[a-c]" ,"d" ,"f", "[b-d]" ,"a" ,"f", \
"[]abc]" ,"b" ,"t", "[]abc]" ,"d" ,"f", \
"[z-a]" ,"-" ,"t", "[z-a]" ,"b" ,"f", \
"[A-]" ,"-" ,"t", "[A-]" ,"]" ,"f", \
"[-a]" ,"-" ,"t", "[-[]" ,"-" ,"t", \
"[-]" ,"-" ,"t", "[^-b]" ,"a" ,"t", \
"[^-b]" ,"-" ,"f", "[-b]" ,"a" ,"f", \
"[a-g]lorian","florian","t", "[a-g]*rorian","f" ,"f", \
"*???*" ,"123" ,"t"
START:
mcall 68,11
stdcall dll.Load,@IMPORT
or eax,eax
jnz exit
mov esi,_str1 + 4
mov edi,_str2 + 4
mov ecx,_str3
xor ebx,ebx
inc ebx
@@: invoke file.aux.match_wildcard,edi,esi,0
cmp eax,[ecx]
je .ok
mcall -1
.ok: inc ebx
add esi,[esi-4]
add edi,[edi-4]
add ecx,4
cmp dword[esi-4],0
jnz @b
invoke ini.set_int,s_ini,s_sec,s_key1,100
invoke ini.set_int,s_ini,s_sec,s_key2,101
invoke ini.get_int,s_ini,s_sec,s_key1,-1
cmp eax,100
jne exit
invoke ini.get_int,s_ini,s_sec,s_key2,-1
cmp eax,101
jne exit
mov dword[buf],'102'
invoke ini.set_str,s_ini,s_sec,s_key1,buf,3
mov dword[buf],'103'
invoke ini.set_str,s_ini,s_sec,s_key2,buf,3
invoke ini.get_str,s_ini,s_sec,s_key1,buf,1024,s_null
cmp dword[buf],'102'
jne exit
invoke ini.get_str,s_ini,s_sec,s_key2,buf,1024,s_null
cmp dword[buf],'103'
jne exit
invoke ini.enum_sections,s_ini,callb
; invoke file.open,s_ininame,O_WRITE+O_CREATE
; or eax,eax
; jnz @f
; int3
; @@: mov [fh],eax
; invoke file.seek,[fh],SEEK_SET,8192
; invoke file.write,[fh],s_ininame,16
; invoke file.seteof,[fh]
; invoke file.close,[fh]
red:
call draw_window
;---------------------------------------------------------------------
;--- ÖÈÊË ÎÁÐÀÁÎÒÊÈ ÑÎÁÛÒÈÉ ----------------------------------------
;---------------------------------------------------------------------
still:
mcall 10
cmp eax,1
je red
cmp eax,2
je key
cmp eax,3
je button
jmp still
;---------------------------------------------------------------------
key:
mcall 2
jmp still
;---------------------------------------------------------------------
button:
mcall 17
cmp ah,1
jne still
exit:
mcall -1
;---------------------------------------------------------------------
;--- ÎÏÐÅÄÅËÅÍÈÅ È ÎÒÐÈÑÎÂÊÀ ÎÊÍÀ ----------------------------------
;---------------------------------------------------------------------
ctx dd ?
draw_window:
invoke gfx.open,TRUE
mov [ctx],eax
mcall 0,<200,700>,<200,200>,0x33FFFFFF,,s_header
invoke gfx.pen.color,[ctx],0x00FF0000
invoke gfx.line,[ctx],0,0,50,50
invoke gfx.framerect,[ctx],10,10,100,70
invoke gfx.brush.color,[ctx],0x000000FF
invoke gfx.fillrect,[ctx],15,15,95,65
invoke gfx.pen.color,[ctx],0x00008800
invoke gfx.brush.color,[ctx],0x00CCCCFF
invoke gfx.rectangle,[ctx],20,20,90,60
invoke gfx.move.to,[ctx],13,5
invoke gfx.line.to,[ctx],105,5
invoke gfx.line.to,[ctx],105,75
invoke gfx.line.to,[ctx],5,75
invoke gfx.line.to,[ctx],5,13
invoke gfx.line.to,[ctx],13,5
invoke gfx.pen.color,[ctx],0x00888888
invoke gfx.polyline,[ctx],poly_points,11
invoke gfx.close,[ctx]
mov [yy],10
invoke ini.enum_sections,s_ini,callb
invoke file.find_first,_f_path,_f_mask,FA_ANY-FA_FOLDER
cmp eax,0
jle .finished
mov ebp,eax
mov [yy],10
@@: lea edx,[ebp+FileInfo.FileName]
mcall 4,<450,[yy]>,0x80000000
add [yy],10
invoke file.find_next,ebp
cmp eax,0
jg @b
invoke file.find_close,ebp
.finished:
ret
_f_path db '/rd/1/lib',0
_f_mask db '*ini*',0
;-----------------------------------------------------------------------------
proc mem.Alloc size ;/////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx
mov eax,[size]
lea ecx,[eax+4+4095]
and ecx,not 4095
mcall 68,12
add ecx,-4
mov [eax],ecx
add eax,4
pop ecx ebx
ret
endp
;-----------------------------------------------------------------------------
proc mem.ReAlloc mptr,size;///////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx esi edi eax
mov eax,[mptr]
mov ebx,[size]
or eax,eax
jz @f
lea ecx,[ebx+4+4095]
and ecx,not 4095
add ecx,-4
cmp ecx,[eax-4]
je .exit
@@: mov eax,ebx
call mem.Alloc
xchg eax,[esp]
or eax,eax
jz .exit
mov esi,eax
xchg eax,[esp]
mov edi,eax
mov ecx,[esi-4]
cmp ecx,[edi-4]
jbe @f
mov ecx,[edi-4]
@@: add ecx,3
shr ecx,2
cld
rep movsd
xchg eax,[esp]
call mem.Free
.exit:
pop eax edi esi ecx ebx
ret
endp
;-----------------------------------------------------------------------------
proc mem.Free mptr ;//////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
mov eax,[mptr]
or eax,eax
jz @f
push ebx ecx
lea ecx,[eax-4]
mcall 68,13
pop ecx ebx
@@: ret
endp
;---------------------------------------------------------------------
;--- ÄÀÍÍÛÅ ÏÐÎÃÐÀÌÌÛ ----------------------------------------------
;---------------------------------------------------------------------
s_header db 'EXAMPLE APPLICATION',0
s_ini db '/rd/1/test001.ini',0
s_sec db 'Panels',0
s_key db 'param1',0
align 4
poly_points dd \
140, 10, \
150, 10, \
150, 20, \
160, 20, \
160, 30, \
170, 30, \
170, 40, \
180, 40, \
180, 50, \
140, 50, \
140, 10
;---------------------------------------------------------------------
align 16
@IMPORT:
library \
libini,'libini.obj',\
libio ,'libio.obj',\
libgfx,'libgfx.obj'
import libini, \
ini.get_str,'ini.get_str',\
ini.set_str,'ini.set_str',\
ini.get_int,'ini.get_int',\
ini.set_int,'ini.set_int',\
ini.enum_sections,'ini.enum_sections',\
ini.enum_keys,'ini.enum_keys'
import libio, \
file.aux.match_wildcard,'file.aux.match_wildcard',\
file.find_first,'file.find_first',\
file.find_next,'file.find_next',\
file.find_close,'file.find_close',\
file.open,'file.open',\
file.seek,'file.seek',\
file.write,'file.write',\
file.truncate,'file.truncate',\
file.close,'file.close'
import libgfx, \
gfx.open ,'gfx.open',\
gfx.close ,'gfx.close',\
gfx.pen.color ,'gfx.pen.color',\
gfx.brush.color ,'gfx.brush.color',\
gfx.pixel ,'gfx.pixel',\
gfx.move.to ,'gfx.move.to',\
gfx.line.to ,'gfx.line.to',\
gfx.line ,'gfx.line',\
gfx.polyline ,'gfx.polyline',\
gfx.polyline.to ,'gfx.polyline.to',\
gfx.fillrect ,'gfx.fillrect',\
gfx.fillrect.ex ,'gfx.fillrect.ex',\
gfx.framerect ,'gfx.framerect',\
gfx.framerect.ex,'gfx.framerect.ex',\
gfx.rectangle ,'gfx.rectangle',\
gfx.rectangle.ex,'gfx.rectangle.ex'
I_END:
fh dd ?
buf rb 1024

View File

@ -0,0 +1,20 @@
[section 1]
key 11=val 11 11
key 12=val 12
[-s-e-c-t-i-o-n- -#-2-]
-k-e-y- -2-1- = -v-a-l- -2-1-
-k-e-y- -2-2- = -v-a-l- -2-2-
[ section3 ]
key31 = val31
key32 = val32
[ /section/ "#4" (the) <best> ]
/key/ "41" = (val) <41>
/key/ "42" = (val) <42>
[Panels]
LeftViewMode=102
RightViewMode=103
Param=

View File

@ -0,0 +1,196 @@
use32
org 0x0
db 'MENUET01'
dd 0x01, START, I_END, 0x1000, 0x1000, @PARAMS, 0x0
;-----------------------------------------------------------------------------
FALSE = 0
TRUE = 1
include '../../../../../proc32.inc'
include '../../../../../macros.inc'
include '../dll.inc'
include '../../libio/libio.inc'
;-----------------------------------------------------------------------------
START:
mcall 68, 11
stdcall dll.Load, @IMPORT
or eax, eax
jnz exit
invoke file.open, @PARAMS, O_READ
or eax, eax
jz exit
mov [fh], eax
invoke file.size, @PARAMS
mov [img_data_len], ebx
stdcall mem.Alloc, ebx
or eax, eax
jz exit
mov [img_data], eax
invoke file.read, [fh], eax, [img_data_len]
cmp eax, -1
je exit
cmp eax, [img_data_len]
jne exit
invoke file.close, [fh]
inc eax
jz exit
invoke img.is_img, [img_data], [img_data_len]
or eax, eax
jz exit
invoke img.decode, [img_data], [img_data_len]
or eax, eax
jz exit
invoke img.to_rgb, eax
or eax, eax
jz exit
mov [rgb_img], eax
;-----------------------------------------------------------------------------
red:
call draw_window
still:
mcall 10
cmp eax, 1
je red
cmp eax, 2
je key
cmp eax, 3
je button
jmp still
key:
mcall 2
jmp still
button:
mcall 17
cmp ah, 1
jne still
exit:
mcall -1
draw_window:
invoke gfx.open, TRUE
mov [ctx], eax
mov edi, [rgb_img]
mov ebx, 200 * 65536
mov bx, [edi + 0]
add bx, 9
mov ecx, 200 * 65536
mov cx, [edi + 4]
add cx, 5 + 21
mcall 0, , , 0x33FF0000, , s_header
mov ebx, [rgb_img]
mov ecx, [ebx + 0]
shl ecx, 16
mov cx, [ebx + 4]
add ebx, 4 * 2
mcall 7, , , <0, 0>
invoke gfx.close, [ctx]
ret
;-----------------------------------------------------------------------------
proc mem.Alloc, size ;////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx
mov ecx, [size]
add ecx, 4
mcall 68, 12
add ecx, -4
mov [eax], ecx
add eax, 4
pop ecx ebx
ret
endp
;-----------------------------------------------------------------------------
proc mem.ReAlloc, mptr, size ;////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx edx
mov ecx, [size]
or ecx, ecx
jz @f
add ecx, 4
@@: mov edx, [mptr]
or edx, edx
jz @f
add edx, -4
@@: mcall 68, 20
or eax, eax
jz @f
add ecx, -4
mov [eax], ecx
add eax, 4
@@: pop edx ecx ebx
ret
endp
;-----------------------------------------------------------------------------
proc mem.Free, mptr ;/////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx
mov ecx, [mptr]
or ecx, ecx
jz @f
add ecx, -4
@@: mcall 68, 13
pop ecx ebx
ret
endp
;-----------------------------------------------------------------------------
s_header db 'Image Viewer (test app)', 0
;-----------------------------------------------------------------------------
align 16
@IMPORT:
library \
libio , 'libio.obj' , \
libgfx , 'libgfx.obj' , \
libimg , 'libimg.obj'
import libio , \
file.size , 'file.size' , \
file.open , 'file.open' , \
file.read , 'file.read' , \
file.close , 'file.close'
import libgfx , \
gfx.open , 'gfx.open' , \
gfx.close , 'gfx.close'
import libimg , \
img.is_img , 'img.is_img' , \
img.to_rgb , 'img.to_rgb' , \
img.decode , 'img.decode'
;-----------------------------------------------------------------------------
I_END:
img_data dd ?
img_data_len dd ?
fh dd ?
rgb_img dd ?
ctx dd ?
@PARAMS rb 512

View File

@ -0,0 +1,90 @@
proc dll.Load, import_table:dword
mov esi,[import_table]
.next_lib: mov edx,[esi]
or edx,edx
jz .exit
push esi
mov esi,[esi+4]
mov edi,s_libdir.fname
@@: lodsb
stosb
or al,al
jnz @b
mcall 68,19,s_libdir
or eax,eax
jz .fail
stdcall dll.Link,eax,edx
stdcall dll.Init,[eax+4]
pop esi
add esi,8
jmp .next_lib
.exit: xor eax,eax
ret
.fail: add esp,4
xor eax,eax
inc eax
ret
endp
proc dll.Link, exp:dword,imp:dword
push eax
mov esi,[imp]
test esi,esi
jz .done
.next: lodsd
test eax,eax
jz .done
stdcall dll.GetProcAddress,[exp],eax
or eax,eax
jz @f
mov [esi-4],eax
jmp .next
@@: mov dword[esp],0
.done: pop eax
ret
endp
proc dll.Init, dllentry:dword
pushad
mov eax,mem.Alloc
mov ebx,mem.Free
mov ecx,mem.ReAlloc
mov edx,dll.Load
stdcall [dllentry]
popad
ret
endp
proc dll.GetProcAddress, exp:dword,sz_name:dword
mov edx,[exp]
.next: test edx,edx
jz .end
stdcall strcmp,[edx],[sz_name]
test eax,eax
jz .ok
add edx,8
jmp .next
.ok: mov eax,[edx+4]
.end: ret
endp
proc strcmp, str1:dword,str2:dword
push esi edi
mov esi,[str1]
mov edi,[str2]
xor eax,eax
@@: lodsb
scasb
jne .fail
or al,al
jnz @b
jmp .ok
.fail: or eax,-1
.ok: pop edi esi
ret
endp
s_libdir:
db '/sys/lib/'
.fname rb 32

View File

@ -0,0 +1,442 @@
;;================================================================================================;;
;;//// libgfx.asm //// (c) mike.dld, 2006-2008 ///////////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; 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 ;;
;; General Public License as published by the Free Software Foundation, either version 3 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 ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; General Public License for more details. ;;
;; ;;
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
;; see <http://www.gnu.org/licenses/>. ;;
;; ;;
;;================================================================================================;;
format MS COFF
public @EXPORT as 'EXPORTS'
include '../../../../proc32.inc'
include '../../../../macros.inc'
purge section;mov,add,sub
include 'libgfx_p.inc'
section '.flat' code readable align 16
mem.alloc dd ?
mem.free dd ?
mem.realloc dd ?
dll.load dd ?
;;================================================================================================;;
proc lib_init ;///////////////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Library entry point (called after library load) ;;
;;------------------------------------------------------------------------------------------------;;
;> eax = pointer to memory allocation routine ;;
;> ebx = pointer to memory freeing routine ;;
;> ecx = pointer to memory reallocation routine ;;
;> edx = pointer to library loading routine ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 1 (fail) / 0 (ok) (library initialization result) ;;
;;================================================================================================;;
mov [mem.alloc], eax
mov [mem.free], ebx
mov [mem.realloc], ecx
mov [dll.load], edx
xor eax,eax
ret
endp
;;================================================================================================;;
proc gfx.open _open? ;////////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push ebx ecx
xor ecx, ecx
cmp byte[_open?], 0
je .lp1
mov eax, 12
mov ebx, 1
int 0x40
jmp @f
.lp1: or ecx, GFX_FLAG_DONT_CLOSE
@@: invoke mem.alloc, sizeof.AGfxContext
xor ebx,ebx
mov [eax + AGfxContext.Flags], ecx
mov [eax + AGfxContext.NullPoint.X], ebx
mov [eax + AGfxContext.NullPoint.Y], ebx
mov [eax + AGfxContext.Caret.X], ebx
mov [eax + AGfxContext.Caret.Y], ebx
mov [eax + AGfxContext.Pen.Color], ebx
mov [eax + AGfxContext.Brush.Color], 0x00FFFFFF
pop ecx ebx
ret
endp
;;================================================================================================;;
proc gfx.close _ctx ;/////////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push eax ebx
mov ebx, [_ctx]
mov ebx, [ebx + AGfxContext.Flags]
invoke mem.free, [_ctx]
test ebx, GFX_FLAG_DONT_CLOSE
jnz @f
mov eax, 12
mov ebx, 2
int 0x40
@@: pop ebx eax
ret
endp
;;================================================================================================;;
proc gfx.pen.color _ctx, _color ;/////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push eax
mov eax, [_ctx]
push [_color]
pop [eax + AGfxContext.Pen.Color]
pop eax
ret
endp
;;================================================================================================;;
proc gfx.brush.color _ctx, _color ;///////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push eax
mov eax, [_ctx]
push [_color]
pop [eax + AGfxContext.Brush.Color]
pop eax
ret
endp
;;================================================================================================;;
proc gfx.pixel _ctx, _x, _y ;/////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push eax ebx ecx edx
mov eax, 1
mov ebx, [_x]
mov ecx, [_y]
mov edx, [_ctx]
mov edx, [edx + AGfxContext.Pen.Color]
int 0x40
pop edx ecx ebx eax
ret
endp
;;================================================================================================;;
proc gfx.move.to _ctx, _x, _y ;///////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push eax
mov eax, [_ctx]
push [_x] [_y]
pop [eax + AGfxContext.Caret.Y] [eax+AGfxContext.Caret.X]
pop eax
ret
endp
;;================================================================================================;;
proc gfx.line.to _ctx, _x, _y ;///////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push eax
mov eax, [_ctx]
stdcall gfx.line, eax, [eax + AGfxContext.Caret.X], [eax + AGfxContext.Caret.Y], [_x], [_y]
pop eax
stdcall gfx.move.to, [_ctx], [_x], [_y]
ret
endp
;;================================================================================================;;
proc gfx.line _ctx, _x1, _y1, _x2, _y2 ;//////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push eax ebx ecx edx
mov eax, 38
mov ebx, [_x1 - 2]
mov bx, word[_x2]
mov ecx, [_y1 - 2]
mov cx, word[_y2]
mov edx, [_ctx]
mov edx, [edx + AGfxContext.Pen.Color]
int 0x40
pop edx ecx ebx eax
stdcall gfx.move.to, [_ctx], [_x2], [_y2]
ret
endp
;;================================================================================================;;
proc gfx.polyline _ctx, _points, _count ;/////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push eax ecx
mov eax, [_points]
stdcall gfx.move.to, [_ctx], [eax + 0], [eax + 4]
mov ecx, [_count]
dec ecx
add eax, 8
stdcall gfx.polyline.to, [_ctx], eax, ecx
pop ecx eax
ret
endp
;;================================================================================================;;
proc gfx.polyline.to _ctx, _points, _count ;//////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push eax ecx
mov eax, [_points]
mov ecx, [_count]
@@: stdcall gfx.line.to, [_ctx], [eax + 0], [eax + 4]
add eax, 8
loop @b
pop ecx eax
ret
endp
;;================================================================================================;;
proc gfx.fillrect _ctx, _x1, _y1, _x2, _y2 ;//////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push eax ebx ecx edx
mov eax, 13
mov ebx, [_x1 - 2]
mov bx, word[_x2]
sub bx, word[_x1]
inc bx
mov ecx, [_y1 - 2]
mov cx, word[_y2]
sub cx, word[_y1]
inc cx
mov edx, [_ctx]
mov edx, [edx + AGfxContext.Brush.Color]
int 0x40
pop edx ecx ebx eax
ret
endp
;;================================================================================================;;
proc gfx.fillrect.ex _ctx, _rect ;////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push eax
mov eax, [_rect]
stdcall gfx.fillrect, [_ctx], [eax + ARect.Left], [eax + ARect.Top], \
[eax + ARect.Right], [eax + ARect.Bottom]
pop eax
ret
endp
;;================================================================================================;;
proc gfx.framerect _ctx, _x1, _y1, _x2, _y2 ;/////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
stdcall gfx.move.to, [_ctx], [_x1], [_y1]
stdcall gfx.line.to, [_ctx], [_x2], [_y1]
stdcall gfx.line.to, [_ctx], [_x2], [_y2]
stdcall gfx.line.to, [_ctx], [_x1], [_y2]
stdcall gfx.line.to, [_ctx], [_x1], [_y1]
pop edx ecx ebx eax
ret
endp
;;================================================================================================;;
proc gfx.framerect.ex _ctx, _rect ;///////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push eax
mov eax, [_rect]
stdcall gfx.framerect, [_ctx], [eax + ARect.Left], [eax + ARect.Top], \
[eax + ARect.Right], [eax + ARect.Bottom]
pop eax
ret
endp
;;================================================================================================;;
proc gfx.rectangle _ctx, _x1, _y1, _x2, _y2 ;/////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
stdcall gfx.framerect, [_ctx], [_x1], [_y1], [_x2], [_y2]
push [_y2] [_x2] [_y1] [_x1]
inc dword[esp + 0x00]
inc dword[esp + 0x04]
dec dword[esp + 0x08]
dec dword[esp + 0x0C]
stdcall gfx.fillrect, [_ctx]
ret
endp
;;================================================================================================;;
proc gfx.rectangle.ex _ctx, _rect ;///////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push eax
mov eax, [_rect]
stdcall gfx.rectangle, [_ctx], [eax + ARect.Left], [eax + ARect.Top], \
[eax + ARect.Right], [eax + ARect.Bottom]
pop eax
ret
endp
;;================================================================================================;;
proc gfx.text _ctx, _text, _len, _x, _y ;/////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
ret
endp
;;================================================================================================;;
proc gfx.text.width _ctx, _text, _len ;///////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
ret
endp
;;================================================================================================;;
proc gfx.text.height _ctx, _text, _len ;//////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
ret
endp
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
;! Exported functions section ;;
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
align 16
@EXPORT:
export \
lib_init , 'lib_init' , \
0x01000000 , 'version' , \
gfx.open , 'gfx.open' , \
gfx.close , 'gfx.close' , \
gfx.pen.color , 'gfx.pen.color' , \
gfx.brush.color , 'gfx.brush.color' , \
gfx.pixel , 'gfx.pixel' , \
gfx.move.to , 'gfx.move.to' , \
gfx.line.to , 'gfx.line.to' , \
gfx.line , 'gfx.line' , \
gfx.polyline , 'gfx.polyline' , \
gfx.polyline.to , 'gfx.polyline.to' , \
gfx.fillrect , 'gfx.fillrect' , \
gfx.fillrect.ex , 'gfx.fillrect.ex' , \
gfx.framerect , 'gfx.framerect' , \
gfx.framerect.ex , 'gfx.framerect.ex' , \
gfx.rectangle , 'gfx.rectangle' , \
gfx.rectangle.ex , 'gfx.rectangle.ex'

View File

@ -0,0 +1,42 @@
;;================================================================================================;;
;;//// libgfx_p.inc //// (c) mike.dld, 2006-2008 /////////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; 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 ;;
;; General Public License as published by the Free Software Foundation, either version 3 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 ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; General Public License for more details. ;;
;; ;;
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
;; see <http://www.gnu.org/licenses/>. ;;
;; ;;
;;================================================================================================;;
struct APoint
X dd ?
Y dd ?
ends
struct ARect
Left dd ?
Top dd ?
Right dd ?
Bottom dd ?
ends
struct AGfxContext
NullPoint APoint
Caret APoint
Pen.Color dd ?
Brush.Color dd ?
Font.Face dd ?
Flags dd ?
ends
GFX_FLAG_DONT_CLOSE = 00000001b

View File

@ -0,0 +1,719 @@
;;================================================================================================;;
;;//// bmp.asm //// (c) mike.dld, 2007-2008 //////////////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; 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 ;;
;; General Public License as published by the Free Software Foundation, either version 3 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 ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; General Public License for more details. ;;
;; ;;
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
;; see <http://www.gnu.org/licenses/>. ;;
;; ;;
;;================================================================================================;;
;; ;;
;; References: ;;
;; 1. "Microsoft Windows Bitmap File Format Summary" ;;
;; from "Encyclopedia of Graphics File Formats" by O'Reilly ;;
;; http://www.fileformat.info/format/bmp/ ;;
;; ;;
;;================================================================================================;;
include 'bmp.inc'
;;================================================================================================;;
proc img.is.bmp _data, _length ;//////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Determine if raw data could be decoded (is in BMP format) ;;
;;------------------------------------------------------------------------------------------------;;
;> _data = raw data as read from file/stream ;;
;> _length = data length ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = false / true ;;
;;================================================================================================;;
cmp [_length], 2
jb .nope
mov eax, [_data]
cmp word[eax], 'BM'
je .yep
.nope:
xor eax, eax
ret
.yep:
xor eax,eax
inc eax
ret
endp
;;================================================================================================;;
proc img.decode.bmp _data, _length ;//////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Decode data into image if it contains correctly formed raw data in BMP format ;;
;;------------------------------------------------------------------------------------------------;;
;> _data = raw data as read from file/stream ;;
;> _length = data length ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 (error) or pointer to image ;;
;;================================================================================================;;
locals
img dd ?
endl
push ebx
stdcall img.is.bmp, [_data], [_length]
or eax, eax
jz .error
mov ebx, [_data]
; cmp [ebx + bmp.Header.info.Compression], bmp.BI_RGB
; je @f
; mov eax, [ebx + bmp.Header.file.Size]
; cmp eax, [_length]
; jne .error
@@: stdcall img.create, [ebx + bmp.Header.info.Width], [ebx + bmp.Header.info.Height]
or eax, eax
jz .error
mov [img], eax
mov edx, eax
invoke mem.alloc, sizeof.bmp.Image
or eax, eax
jz .error
mov [edx + Image.Extended], eax
mov esi, ebx
add esi, sizeof.bmp.FileHeader
mov edi, eax
mov ecx, sizeof.bmp.InfoHeader
rep movsb
mov eax, [ebx + bmp.Header.info.Compression]
cmp eax, bmp.BI_RGB
jne @f
stdcall ._.rgb
jmp .decoded
@@: cmp eax, bmp.BI_RLE8
jne @f
stdcall ._.rle
jmp .decoded
@@: cmp eax, bmp.BI_RLE4
jne @f
stdcall ._.rle
jmp .decoded
@@: cmp eax, bmp.BI_BITFIELDS
jne @f
stdcall ._.bitfields
jmp .decoded
@@: cmp eax, bmp.BI_JPEG
jne @f
stdcall ._.jpeg
jmp .decoded
@@: cmp eax, bmp.BI_PNG
jne .error
stdcall ._.png
.decoded:
or eax, eax
jz @f
stdcall img.destroy, [img]
jmp .error
@@: stdcall img.flip, [img], FLIP_VERTICAL
mov eax, [img]
ret
.error:
xor eax, eax
pop ebx
ret
endp
;;================================================================================================;;
proc img.encode.bmp _img, _p_length ;/////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Encode image into raw data in BMP format ;;
;;------------------------------------------------------------------------------------------------;;
;> _img = pointer to image ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 (error) or pointer to encoded data ;;
;< _p_length = encoded data length ;;
;;================================================================================================;;
xor eax, eax
ret
endp
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
;! Below are private procs you should never call directly from your code ;;
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
;;================================================================================================;;
proc img.decode.bmp._.rgb ;///////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> ebx = raw image data ;;
;> edx = image data ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
mov ecx, [edx + Image.Extended]
mov [ecx + bmp.Image.info.AlphaMask], 0
mov edi, [edx + Image.Data]
movzx eax, [ebx + bmp.Header.info.BitCount]
cmp eax, 32
je .32bpp
cmp eax, 24
je .24bpp
cmp eax, 16
je .16bpp
cmp eax, 8
je .8bpp
cmp eax, 4
je .4bpp
cmp eax, 1
je .1bpp
jmp .error
;;------------------------------------------------------------------------------------------------;;
img.decode.bmp._.rgb.32bpp:
mov [ecx + bmp.Image.info.RedMask], 00000000111111110000000000000000b ; 8-0-0
mov [ecx + bmp.Image.info.GreenMask], 00000000000000001111111100000000b ; 0-8-0
mov [ecx + bmp.Image.info.BlueMask], 00000000000000000000000011111111b ; 0-0-8
stdcall img.decode.bmp._.bitfields
ret
;;------------------------------------------------------------------------------------------------;;
img.decode.bmp._.rgb.24bpp:
mov esi, ebx
add esi, [ebx + bmp.Header.file.OffBits]
mov ecx, [ebx + bmp.Header.info.Height]
.next_line:
push ecx
mov ecx, [ebx + bmp.Header.info.Width]
xor edx, edx
.next_line_pixel:
movsd
dec esi
inc edx
dec ecx
jnz .next_line_pixel
and edx, 0x03
add esi, edx
pop ecx
dec ecx
jnz .next_line
jmp img.decode.bmp._.rgb.exit
;;------------------------------------------------------------------------------------------------;;
img.decode.bmp._.rgb.16bpp:
mov [ecx + bmp.Image.info.RedMask], 00000000000000000111110000000000b ; 5-0-0
mov [ecx + bmp.Image.info.GreenMask], 00000000000000000000001111100000b ; 0-5-0
mov [ecx + bmp.Image.info.BlueMask], 00000000000000000000000000011111b ; 0-0-5
stdcall img.decode.bmp._.bitfields
ret
;;------------------------------------------------------------------------------------------------;;
img.decode.bmp._.rgb.8bpp:
mov esi, ebx
add esi, [ebx + bmp.Header.file.OffBits]
mov ecx, [ebx + bmp.Header.info.Height]
.next_line:
push ecx
mov ecx, [ebx + bmp.Header.info.Width]
.next_line_dword:
lodsb
and eax, 0x000000FF
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette]
stosd
dec ecx
jnz .next_line_dword
pop ecx
dec ecx
jnz .next_line
jmp img.decode.bmp._.rgb.exit
;;------------------------------------------------------------------------------------------------;;
img.decode.bmp._.rgb.4bpp:
mov esi, ebx
add esi, [ebx + bmp.Header.file.OffBits]
mov ecx, [ebx + bmp.Header.info.Height]
.next_line:
push ecx
mov ecx, [ebx + bmp.Header.info.Width]
.next_line_dword:
push ecx
lodsd
bswap eax
xchg edx, eax
mov ecx, 32 / 4
.next_pixel:
rol edx, 4
mov al, dl
and eax, 0x0000000F
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette]
stosd
dec dword[esp]
jz @f
dec ecx
jnz .next_pixel
@@: pop ecx
or ecx, ecx
jnz .next_line_dword
pop ecx
dec ecx
jnz .next_line
jmp img.decode.bmp._.rgb.exit
;;------------------------------------------------------------------------------------------------;;
img.decode.bmp._.rgb.1bpp:
mov esi, ebx
add esi, [ebx + bmp.Header.file.OffBits]
mov ecx, [ebx + bmp.Header.info.Height]
.next_line:
push ecx
mov ecx, [ebx + bmp.Header.info.Width]
.next_line_dword:
push ecx
lodsd
bswap eax
xchg edx, eax
mov ecx, 32 / 1
.next_pixel:
rol edx, 1
mov al, dl
and eax, 0x00000001
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette]
stosd
dec dword[esp]
jz @f
dec ecx
jnz .next_pixel
@@: pop ecx
or ecx, ecx
jnz .next_line_dword
pop ecx
dec ecx
jnz .next_line
jmp img.decode.bmp._.rgb.exit
;;------------------------------------------------------------------------------------------------;;
img.decode.bmp._.rgb.exit:
xor eax, eax
ret
img.decode.bmp._.rgb.error:
or eax, -1
ret
endp
;;================================================================================================;;
proc img.decode.bmp._.rle ;///////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> ebx = raw image data ;;
;> edx = image data ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
locals
scanline_len dd ?
marker_x dd ?
marker_y dd ?
abs_mode_addr dd ?
enc_mode_addr dd ?
endl
mov edi, [edx + Image.Data]
mov [abs_mode_addr], .absolute_mode.rle8
mov [enc_mode_addr], .encoded_mode.rle8
cmp [ebx + bmp.Header.info.Compression], bmp.BI_RLE4
jne @f
mov [abs_mode_addr], .absolute_mode.rle4
mov [enc_mode_addr], .encoded_mode.rle4
@@: mov esi, ebx
add esi, [ebx + bmp.Header.file.OffBits]
mov eax, [edx + Image.Width]
shl eax, 2
mov [scanline_len], eax
xor eax, eax
mov [marker_x], eax
mov [marker_y], eax
.next_run:
xor eax, eax
lodsb
or al, al
jz .escape_mode
jmp [enc_mode_addr]
.escape_mode:
lodsb
cmp al, 0
je .end_of_scanline
cmp al, 1
je .exit
cmp al, 2
je .offset_marker
jmp [abs_mode_addr]
.end_of_scanline: ; 0
mov eax, [marker_x]
shl eax, 2
neg eax
add eax, [scanline_len]
add edi, eax
mov [marker_x], 0
inc [marker_y]
jmp .next_run
.offset_marker: ; 2: dx, dy
lodsb
mov edx, [marker_x]
add edx, eax
cmp edx, [ebx + bmp.Header.info.Width]
jae .exit
mov [marker_x], edx
shl eax, 2
add edi, eax
lodsb
and eax, 0x0FF
mov edx, [marker_y]
add edx, eax
cmp edx, [ebx + bmp.Header.info.Height]
jae .exit
mov [marker_y], edx
imul eax, [scanline_len]
add edi, eax
jmp .next_run
.encoded_mode.rle8: ; N: b1 * N
mov edx, eax
lodsb
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette]
@@: dec edx
js .fix_marker
stosd
inc [marker_x]
jmp @b
.absolute_mode.rle8: ; N: b1 .. bN
mov edx, eax
push eax
@@: dec edx
js @f
lodsb
and eax, 0x0FF
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette]
stosd
inc [marker_x]
jmp @b
@@: pop eax
test eax, 1
jz .fix_marker
inc esi
jmp .fix_marker
.encoded_mode.rle4: ; N: b1 * N
mov edx, eax
lodsb
mov ecx, eax
shr ecx, 4
mov ecx, [ebx + ecx * 4 + bmp.Header.info.Palette]
and eax, 0x00F
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette]
@@: dec edx
js .fix_marker
test edx, 1
jz .odd
mov [edi], ecx
add edi, 4
inc [marker_x]
jmp @b
.odd:
stosd
inc [marker_x]
jmp @b
.absolute_mode.rle4: ; N: b1 .. bN
mov edx, eax
push eax
@@: dec edx
js @f
lodsb
and eax, 0x0FF
mov ecx, eax
shr eax, 4
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette]
stosd
inc [marker_x]
dec edx
js @f
mov eax, ecx
and eax, 0x00F
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette]
stosd
inc [marker_x]
jmp @b
@@: pop eax
and eax, 0x03
jz .fix_marker
cmp eax, 3
je .fix_marker
inc esi
jmp .fix_marker
.fix_marker:
mov eax, [marker_x]
@@: sub eax, [ebx + bmp.Header.info.Width]
jle .next_run
mov [marker_x], eax
inc [marker_y]
jmp @b
.exit:
xor eax, eax
ret
.error:
or eax, -1
ret
endp
;;================================================================================================;;
proc img.decode.bmp._.bitfields ;/////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> ebx = raw image data ;;
;> edx = image data ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
locals
shift bmp.RgbByteQuad
unshift bmp.RgbByteQuad
mask bmp.RgbQuad
delta dd ?
endl
push esi edi
mov esi, [edx + Image.Extended]
mov ecx, [esi + bmp.Image.info.RedMask]
call .calc_shift
mov [shift.Red], al
mov [mask.Red], ecx
call .calc_unshift
mov [unshift.Red], al
mov ecx, [esi + bmp.Image.info.GreenMask]
call .calc_shift
mov [shift.Green], al
mov [unshift.Green], al
mov [mask.Green], ecx
call .calc_unshift
mov [unshift.Green], al
mov ecx, [esi + bmp.Image.info.BlueMask]
call .calc_shift
mov [shift.Blue], al
mov [unshift.Blue], al
mov [mask.Blue], ecx
call .calc_unshift
mov [unshift.Blue], al
mov ecx, [esi + bmp.Image.info.AlphaMask]
call .calc_shift
mov [shift.Alpha], al
mov [unshift.Alpha], al
mov [mask.Alpha], ecx
call .calc_unshift
mov [unshift.Alpha], al
mov edi, [edx + Image.Data]
mov esi, ebx
add esi, [ebx + bmp.Header.file.OffBits]
mov [delta], 4
movzx eax, [ebx + bmp.Header.info.BitCount]
cmp eax, 32
je @f
cmp eax, 16
jne .error
mov [delta], 2
;;------------------------------------------------------------------------------------------------;;
@@: mov ecx, [edx + Image.Height]
.next_line:
push ecx
mov ecx, [edx + Image.Width]
.next_pixel:
push ecx
mov eax, [esi]
mov cl, [shift.Blue]
shr eax, cl
and eax, [mask.Blue]
mov cl, [unshift.Blue]
shl eax, cl
stosb
mov eax, [esi]
mov cl, [shift.Green]
shr eax, cl
and eax, [mask.Green]
mov cl, [unshift.Green]
shl eax, cl
stosb
mov eax, [esi]
mov cl, [shift.Red]
shr eax, cl
and eax, [mask.Red]
mov cl, [unshift.Red]
shl eax, cl
stosb
mov eax, [esi]
mov cl, [shift.Alpha]
shr eax, cl
and eax, [mask.Alpha]
mov cl, [unshift.Alpha]
shl eax, cl
stosb
add esi, [delta]
pop ecx
dec ecx
jnz .next_pixel
pop ecx
dec ecx
jnz .next_line
;;------------------------------------------------------------------------------------------------;;
.exit:
xor eax, eax
pop edi esi
ret
.error:
or eax, -1
pop edi esi
ret
.calc_shift:
xor eax, eax
or ecx, ecx
jnz @f
retn
@@: test ecx, 1
jnz @f
.zz: shr ecx, 1
inc eax
jmp @b
@@: test ecx, 0100000000b
jnz .zz
retn
.calc_unshift:
xor eax, eax
or ecx, ecx
jnz @f
retn
@@: test ecx, 1
jz @f
shr ecx, 1
inc eax
jmp @b
@@: sub eax, 8
neg eax
retn
endp
;;================================================================================================;;
proc img.decode.bmp._.jpeg ;//////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> ebx = raw image data ;;
;> edx = image data ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
xor eax, eax
ret
endp
;;================================================================================================;;
proc img.decode.bmp._.png ;///////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> ebx = raw image data ;;
;> edx = image data ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
xor eax, eax
ret
endp
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
;! Below is private data you should never use directly from your code ;;
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
;

View File

@ -0,0 +1,97 @@
;;================================================================================================;;
;;//// bmp.inc //// (c) mike.dld, 2007-2008 //////////////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; 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 ;;
;; General Public License as published by the Free Software Foundation, either version 3 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 ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; General Public License for more details. ;;
;; ;;
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
;; see <http://www.gnu.org/licenses/>. ;;
;; ;;
;;================================================================================================;;
struct bmp.FileHeader
Type dw ? ; File type, always 4D42h ("BM")
Size dd ? ; Size of the file in bytes
dw 2 dup(?) ; Reserved; must be set to zero.
OffBits dd ? ; Starting position of image data in bytes
ends
struct bmp.InfoHeader
; v2 (Windows 2.x)
Size dd ? ; Size of this header in bytes
Width dd ? ; Image width in pixels
Height dd ? ; Image height in pixels
Planes dw ? ; Number of color planes
BitCount dw ? ; Number of bits per pixel
; v3 (Windows 3.x)
Compression dd ? ; Compression method used
SizeImage dd ? ; Size of bitmap in bytes
XPelsPerMeter dd ? ; Horizontal resolution in pixels per meter
YPelsPerMeter dd ? ; Vertical resolution in pixels per meter
ClrUsed dd ? ; Number of colors in the image
ClrImportant dd ? ; Minimum number of important colors
union
Palette dd ? ; Image palette if BitCount in [1,4,8]
; v4 (Windows 95)
struct
RedMask dd ? ; Mask identifying bits of red component
GreenMask dd ? ; Mask identifying bits of green component
BlueMask dd ? ; Mask identifying bits of blue component
AlphaMask dd ? ; Mask identifying bits of alpha component
CSType dd ? ; Color space type
RedX dd ? ; X coordinate of red endpoint
RedY dd ? ; Y coordinate of red endpoint
RedZ dd ? ; Z coordinate of red endpoint
GreenX dd ? ; X coordinate of green endpoint
GreenY dd ? ; Y coordinate of green endpoint
GreenZ dd ? ; Z coordinate of green endpoint
BlueX dd ? ; X coordinate of blue endpoint
BlueY dd ? ; Y coordinate of blue endpoint
BlueZ dd ? ; Z coordinate of blue endpoint
GammaRed dd ? ; Gamma red coordinate scale value
GammaGreen dd ? ; Gamma green coordinate scale value
GammaBlue dd ? ; Gamma blue coordinate scale value
ends
ends
ends
define bmp.BI_RGB 0
define bmp.BI_RLE8 1
define bmp.BI_RLE4 2
define bmp.BI_BITFIELDS 3
define bmp.BI_JPEG 4
define bmp.BI_PNG 5
struct bmp.Header
file bmp.FileHeader
info bmp.InfoHeader
ends
struct bmp.RgbByteQuad
Red db ?
Green db ?
Blue db ?
Alpha db ?
ends
struct bmp.RgbQuad
Red dd ?
Green dd ?
Blue dd ?
Alpha dd ?
ends
;;------------------------------------------------------------------------------------------------;;
struct bmp.Image
info bmp.InfoHeader
ends

View File

@ -0,0 +1,25 @@
;;================================================================================================;;
;;//// ico.asm //// (c) mike.dld, 2007-2008 //////////////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; 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 ;;
;; General Public License as published by the Free Software Foundation, either version 3 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 ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; General Public License for more details. ;;
;; ;;
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
;; see <http://www.gnu.org/licenses/>. ;;
;; ;;
;;================================================================================================;;
;; ;;
;; References: ;;
;; 1. "Icons in Win32" ;;
;; by John Hornick, Microsoft Corporation ;;
;; http://msdn2.microsoft.com/en-us/library/ms997538.aspx ;;
;; ;;
;;================================================================================================;;

View File

@ -0,0 +1,564 @@
;;================================================================================================;;
;;//// gif.asm //// (c) mike.dld, 2007-2008 //////////////////////////////////////////////////////;;
;;================================================================================================;;
;;//// Partial (c) by Willow, Diamond and HidnPlayr //////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; 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 ;;
;; General Public License as published by the Free Software Foundation, either version 3 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 ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; General Public License for more details. ;;
;; ;;
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
;; see <http://www.gnu.org/licenses/>. ;;
;; ;;
;;================================================================================================;;
;; ;;
;; References: ;;
;; 1. GIF LITE v3.0 (2004-2007) ;;
;; by Willow and Diamond ;;
;; svn://kolibrios.org/programs/media/gifview/trunk/gif_lite.inc ;;
;; 2. "GIF File Format Summary" ;;
;; from "Encyclopedia of Graphics File Formats" by O'Reilly ;;
;; http://www.fileformat.info/format/gif/ ;;
;; 3. "LZW and GIF explained" (1987) ;;
;; by Steve Blackstock, IEEE ;;
;; http://www.cis.udel.edu/~amer/CISC651/lzw.and.gif.explained.html ;;
;; 4. "Graphics Interchange Format (tm)" (June 15, 1987) ;;
;; by CompuServe Incorporated ;;
;; http://examples.oreilly.de/english_examples/gff/CDROM/GFF/VENDSPEC/GIF/GIF87A.TXT ;;
;; 5. "Graphics Interchange Format (sm)" (July 31, 1990) ;;
;; by CompuServe Incorporated ;;
;; http://examples.oreilly.de/english_examples/gff/CDROM/GFF/VENDSPEC/GIF/GIF89A.TXT ;;
;; ;;
;;================================================================================================;;
include 'gif.inc'
;;================================================================================================;;
proc img.is.gif _data, _length ;//////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Determine if raw data could be decoded (is in GIF format) ;;
;;------------------------------------------------------------------------------------------------;;
;> _data = raw data as read from file/stream ;;
;> _length = data length ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = false / true ;;
;;================================================================================================;;
cmp [_length], 6
jb .nope
mov eax, [_data]
cmp dword[eax], 'GIF8'
jne .nope
cmp word[eax + 4], '7a'
je .yep
cmp word[eax + 4], '9a'
je .yep
.nope:
xor eax, eax
ret
.yep:
xor eax, eax
inc eax
ret
endp
;;================================================================================================;;
proc img.decode.gif _data, _length ;//////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Decode data into image if it contains correctly formed raw data in GIF format ;;
;;------------------------------------------------------------------------------------------------;;
;> _data = raw data as read from file/stream ;;
;> _length = data length ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 (error) or pointer to image ;;
;;================================================================================================;;
locals
img dd ?
global_color_table dd ?
endl
push ebx
stdcall img.is.gif, [_data], [_length]
or eax, eax
jz .error
mov ebx, [_data]
; cmp [ebx + bmp.Header.info.Compression], bmp.BI_RGB
; je @f
; mov eax, [ebx + bmp.Header.file.Size]
; cmp eax, [_length]
; jne .error
test [ebx + gif.Header.lsd.Packed], gif.LSD.Packed.GlobalColorTableFlag
jz @f
lea eax, [ebx + sizeof.gif.Header]
mov [global_color_table], eax
mov cl, [ebx + gif.Header.lsd.Packed]
and cl, gif.LSD.Packed.SizeOfGlobalColorTableMask
shr cl, gif.LSD.Packed.SizeOfGlobalColorTableShift
inc cl
mov eax, 1
shl eax, cl
lea eax, [eax * 3]
add ebx, eax
@@: add ebx, sizeof.gif.Header
mov [img], 0
; @@: cmp byte[ebx + gif.Block.Introducer], gif.Block.Introducer.Extension
; jne .next_image
; cmp byte[ebx + gif.Extension.Label], gif.Extension.Label.Comment
; jne .error
; add ebx, sizeof.gif.Extension
; stdcall ._.skip_data
; mov ebx, eax
; jmp @b
.next_image:
stdcall img._.new
or eax, eax
jz .error
mov edx, [img]
mov [eax + Image.Previous], edx
mov [img], eax
mov edx, eax
mov ecx, sizeof.gif.Image
invoke mem.alloc, ecx
or eax, eax
jz .error
mov [edx + Image.Extended], eax
stdcall ._.process_extensions
cmp byte[ebx + gif.Block.Introducer], gif.Block.Introducer.ImageDescriptor
jne .error
movzx eax, [ebx + gif.ImageDescriptor.Width]
movzx ecx, [ebx + gif.ImageDescriptor.Height]
stdcall img._resize_data, [img], eax, ecx
or eax, eax
jz .error
test [ebx + gif.ImageDescriptor.Packed], gif.ID.Packed.LocalColorTableFlag
jz @f
mov cl, [ebx + gif.ImageDescriptor.Packed]
and cl, gif.ID.Packed.SizeOfLocalColorTableMask
shr cl, gif.ID.Packed.SizeOfLocalColorTableShift
inc cl
mov eax, 1
shl eax, cl
lea ecx, [eax * sizeof.gif.RgbTriplet]
lea eax, [ecx + sizeof.gif.Image]
invoke mem.realloc, [edx + Image.Extended], eax
or eax, eax
jz .error
mov [edx + Image.Extended], eax
lea esi, [ebx + sizeof.gif.ImageDescriptor]
lea edi, [eax + sizeof.gif.Image]
rep movsb
@@: mov eax, [global_color_table]
test [ebx + gif.ImageDescriptor.Packed], gif.ID.Packed.LocalColorTableFlag
jz @f
lea eax, [ebx + sizeof.gif.ImageDescriptor]
@@: mov ebx, esi
stdcall ._.process_image, eax
.decoded:
or eax, eax
jz @f
stdcall img.destroy, [img]
jmp .error
@@: mov eax, [img]
ret
.error:
xor eax, eax
pop ebx
ret
endp
;;================================================================================================;;
proc img.encode.gif _img, _p_length ;/////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Encode image into raw data in GIF format ;;
;;------------------------------------------------------------------------------------------------;;
;> _img = pointer to image ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 (error) or pointer to encoded data ;;
;< _p_length = encoded data length ;;
;;================================================================================================;;
xor eax, eax
ret
endp
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
;! Below are private procs you should never call directly from your code ;;
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
;;================================================================================================;;
proc img.decode.gif._.skip_data ;/////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> ebx = pointer to data blocks array ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = pointer to data right after data blocks array ;;
;;================================================================================================;;
push ecx
xor ecx, ecx
@@: mov cl, [esi]
or cl, cl
jz @f
lea esi, [esi + ecx + 1]
jmp @b
@@: pop ecx
ret
endp
;;================================================================================================;;
proc img.decode.gif._.process_extensions ;////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> ebx = raw image data ;;
;> edx = image data ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push edx
mov esi, ebx
.next_block:
mov al, [esi + gif.Block.Introducer]
cmp al, gif.Block.Introducer.Extension
je .ext_block
; cmp al, gif.Block.Introducer.ImageDescriptor
; je .exit
; cmp al, gif.Block.Introducer.EndOfFile
; je .exit
jmp .exit
.ext_block:
mov al, [esi + gif.Extension.Label]
cmp al, gif.Extension.Label.PlainText
je .plain_text_ext
cmp al, gif.Extension.Label.GraphicsControl
je .graphics_control_ext
cmp al, gif.Extension.Label.Comment
je .comment_ext
cmp al, gif.Extension.Label.Application
je .application_ext
jmp .exit
.plain_text_ext:
add esi, gif.PlainTextExtension.PlainTextData
stdcall img.decode.gif._.skip_data
jmp .next_ext_block
.graphics_control_ext:
push edi
mov edi, [edx + Image.Extended]
add edi, gif.Image.gce
mov ecx, sizeof.gif.GraphicsControlExtension
rep movsb
pop edi
jmp .next_ext_block
.comment_ext:
add esi, gif.CommentExtension.CommentData
stdcall img.decode.gif._.skip_data
jmp .next_ext_block
.application_ext:
add esi, gif.ApplicationExtension.ApplicationData
stdcall img.decode.gif._.skip_data
jmp .next_ext_block
.next_ext_block:
mov al, [ebx + gif.Block.Introducer]
cmp al, gif.Block.Introducer.EndOfData
jne .exit
inc ebx
jmp .next_block
.exit:
mov ebx, esi
pop edx
ret
endp
;;================================================================================================;;
proc img.decode.gif._.process_image _color_table ;////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> ebx = raw image data ;;
;> edx = image data ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
locals
width dd ?
img_start dd ?
img_end dd ?
row_end dd ?
pass dd ?
codesize dd ?
compsize dd ?
workarea dd ?
block_ofs dd ?
bit_count dd ?
CC dd ?
EOI dd ?
endl
invoke mem.alloc, 16 * 1024
mov [workarea], eax
or eax, eax
jz .error
mov ecx, [edx + Image.Width]
mov [width], ecx
mov eax, [edx + Image.Height]
imul eax, ecx
; lea eax, [eax * 3]
shl eax, 2
mov [img_end], eax
inc eax
mov [row_end], eax
and [pass], 0
mov eax, [edx + Image.Extended]
test [eax + gif.Image.info.Packed], gif.ID.Packed.InterleaceFlag
jz @f
; lea ecx, [ecx * 3]
shl ecx, 2
mov [row_end], ecx
@@: mov esi, ebx
mov edi, [edx + Image.Data]
push edi
movzx ecx, byte[esi]
inc esi
mov [codesize], ecx
inc [codesize]
mov edi, [workarea]
xor eax, eax
lodsb ; eax - block_count
add eax, esi
mov [block_ofs], eax
mov [bit_count], 8
mov eax, 1
shl eax, cl
mov [CC], eax
mov ecx, eax
inc eax
mov [EOI], eax
mov eax, gif.Null shl 16
.filltable:
stosd
inc eax
loop .filltable
pop edi
mov [img_start], edi
add [img_end], edi
add [row_end], edi
.reinit:
mov edx, [EOI]
inc edx
push [codesize]
pop [compsize]
call .get_symbol
cmp eax, [CC]
je .reinit
call .output
.cycle:
movzx ebx, ax
call .get_symbol
cmp eax, edx
jae .notintable
cmp eax, [CC]
je .reinit
cmp eax, [EOI]
je .end
call .output
.add:
mov ecx, [workarea]
mov [ecx + edx * 4], ebx
cmp edx, 0x00000FFF
jae .cycle
inc edx
bsr ebx, edx
cmp ebx, [compsize]
jne .noinc
inc [compsize]
.noinc:
jmp .cycle
.notintable:
push eax
mov eax, ebx
call .output
push ebx
movzx eax, bx
call .output
pop ebx eax
jmp .add
.end:
mov edi, [img_end]
xor eax, eax
.exit:
cmp [workarea], 0
je @f
invoke mem.free, [workarea]
@@: xor eax, eax
ret
.error:
cmp [workarea], 0
je @f
invoke mem.free, [workarea]
@@: xor eax, eax
inc eax
ret
;;------------------------------------------------------------------------------------------------;;
img.decode.gif._.process_image.get_symbol:
mov ecx, [compsize]
push ecx
xor eax, eax
.shift:
ror byte[esi], 1
rcr eax,1
dec [bit_count]
jnz .loop1
inc esi
cmp esi, [block_ofs]
jb .noblock
push eax
xor eax, eax
lodsb
test eax, eax
jnz .nextbl
mov eax, [EOI]
sub esi, 2
add esp, 8
jmp .exit
.nextbl:
add eax, esi
mov [block_ofs], eax
pop eax
.noblock:
mov [bit_count], 8
.loop1:
loop .shift
pop ecx
rol eax, cl
.exit:
xor ecx, ecx
retn
;;------------------------------------------------------------------------------------------------;;
img.decode.gif._.process_image.output:
push esi eax edx
mov edx, [workarea]
.next:
pushw [edx + eax * 4]
mov ax, [edx + eax * 4 + 2]
inc ecx
cmp ax, gif.Null
jnz .next
shl ebx, 16
mov bx, [esp]
.loop2:
pop ax
lea esi, [eax * 3]
add esi, [_color_table]
mov esi, [esi]
bswap esi
shr esi, 8
mov [edi], esi
add edi, 4
cmp edi, [row_end]
jb .norowend
mov eax, [width]
; lea eax, [eax * 3]
shl eax, 2
push eax
sub edi, eax
add eax, eax
cmp [pass], 3
je @f
add eax, eax
cmp [pass], 2
je @f
add eax, eax
@@: add edi, eax
pop eax
cmp edi, [img_end]
jb .nextrow
mov edi, [img_start]
inc [pass]
add edi, eax
cmp [pass], 3
je @f
add edi, eax
cmp [pass], 2
je @f
add edi, eax
add edi, eax
@@:
.nextrow:
add eax, edi
mov [row_end], eax
xor eax, eax
.norowend:
loop .loop2
pop edx eax esi
retn
endp
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
;! Below is private data you should never use directly from your code ;;
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
;

View File

@ -0,0 +1,137 @@
;;================================================================================================;;
;;//// gif.inc //// (c) mike.dld, 2007-2008 //////////////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; 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 ;;
;; General Public License as published by the Free Software Foundation, either version 3 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 ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; General Public License for more details. ;;
;; ;;
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
;; see <http://www.gnu.org/licenses/>. ;;
;; ;;
;;================================================================================================;;
struct gif.FileHeader ; GIF87a
Signature db 3 dup(?) ; Header Signature (always "GIF")
Version db 3 dup(?) ; GIF format version("87a" or "89a")
ends
struct gif.LogicalScreenDescriptor ; GIF87a
ScreenWidth dw ? ; Width of Display Screen in Pixels
ScreenHeight dw ? ; Height of Display Screen in Pixels
Packed db ? ; Screen and Color Map Information
BackgroundColor db ? ; Background Color Index
AspectRatio db ? ; Pixel Aspect Ratio
ends
gif.LSD.Packed.SizeOfGlobalColorTableMask = 000000111b
gif.LSD.Packed.SizeOfGlobalColorTableShift = 0
gif.LSD.Packed.ColorTableSortFlag = 000001000b
gif.LSD.Packed.ColorTableSortShift = 3
gif.LSD.Packed.ColorResolutionMask = 001110000b
gif.LSD.Packed.ColorResolutionShift = 4
gif.LSD.Packed.GlobalColorTableFlag = 010000000b
gif.LSD.Packed.GlobalColorTableShift = 7
struct gif.Header
file gif.FileHeader
lsd gif.LogicalScreenDescriptor
ends
struct gif.RgbTriplet ; GIF87a
Red db ? ; Red Color Element
Green db ? ; Green Color Element
Blue db ? ; Blue Color Element
ends
struct gif.Block
Introducer db ?
ends
gif.Block.Introducer.EndOfData = 0x00
gif.Block.Introducer.Extension = 0x21
gif.Block.Introducer.ImageDescriptor = 0x2C
gif.Block.Introducer.EndOfFile = 0x3B
struct gif.ImageDescriptor ; GIF87a
b gif.Block ; Introducer = 2Ch (',')
Left dw ? ; X position of image on the display
Top dw ? ; Y position of image on the display
Width dw ? ; Width of the image in pixels
Height dw ? ; Height of the image in pixels
Packed db ? ; Image and Color Table Data Information
ends
gif.ID.Packed.SizeOfLocalColorTableMask = 000000111b
gif.ID.Packed.SizeOfLocalColorTableShift = 0
gif.ID.Packed.SortFlag = 000100000b
gif.ID.Packed.SortShift = 5
gif.ID.Packed.InterleaceFlag = 001000000b
gif.ID.Packed.InterleaceShift = 6
gif.ID.Packed.LocalColorTableFlag = 010000000b
gif.ID.Packed.LocalColorTableShift = 7
struct gif.Extension
b gif.Block ; Introducer = 21h ('|')
Label db ? ; Extension label
ends
gif.Extension.Label.PlainText = 0x01
gif.Extension.Label.GraphicsControl = 0xF9
gif.Extension.Label.Comment = 0xFE
gif.Extension.Label.Application = 0xFF
struct gif.PlainTextExtension ; GIF89a
e gif.Extension ; Label = 01h
BlockSize db ? ; Size of Extension Block (always 0Ch)
TextGridLeft dw ? ; X position of text grid in pixels
TextGridTop dw ? ; Y position of text grid in pixels
TextGridWidth dw ? ; Width of the text grid in pixels
TextGridHeight dw ? ; Height of the text grid in pixels
CellWidth db ? ; Width of a grid cell in pixels
CellHeight db ? ; Height of a grid cell in pixels
TextFgColorIndex db ? ; Text foreground color index value
TextBgColorIndex db ? ; Text background color index value
PlainTextData db ? ; The Plain Text data (*)
; Terminator db ? ; Block Terminator (always 0)
ends
struct gif.GraphicsControlExtension ; GIF89a
e gif.Extension ; Label = F9h
BlockSize db ? ; Size of remaining fields (always 04h)
Packed db ? ; Method of graphics disposal to use
DelayTime dw ? ; Hundredths of seconds to wait
ColorIndex db ? ; Transparent Color Index
; Terminator db ? ; Block Terminator (always 0)
ends
struct gif.CommentExtension ; GIF89a
e gif.Extension ; Label = FEh
CommentData db ? ; Pointer to Comment Data sub-blocks (*)
; Terminator db ? ; Block Terminator (always 0)
ends
struct gif.ApplicationExtension ; GIF89a
e gif.Extension ; Label = FFh
BlockSize db ? ; Size of Extension Block (always 0Bh)
Identifier db 8 dup(?) ; Application Identifier
AuthentCode db 3 dup(?) ; Application Authentication Code
ApplicationData db ? ; Point to Application Data sub-blocks (*)
; Terminator db ? ; Block Terminator (always 0)
ends
;;------------------------------------------------------------------------------------------------;;
struct gif.Image
gce gif.GraphicsControlExtension
info gif.ImageDescriptor
ends
gif.Null equ 0x1000

View File

@ -0,0 +1,501 @@
;;================================================================================================;;
;;//// libimg.asm //// (c) mike.dld, 2007-2008 ///////////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; 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 ;;
;; General Public License as published by the Free Software Foundation, either version 3 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 ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; General Public License for more details. ;;
;; ;;
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
;; see <http://www.gnu.org/licenses/>. ;;
;; ;;
;;================================================================================================;;
format MS COFF
public @EXPORT as 'EXPORTS'
include '../../../../struct.inc'
include '../../../../proc32.inc'
include '../../../../macros.inc'
purge section,mov;add,sub
include 'libimg.inc'
section '.flat' code readable align 16
include 'bmp/bmp.asm'
include 'gif/gif.asm'
mem.alloc dd ?
mem.free dd ?
mem.realloc dd ?
dll.load dd ?
;;================================================================================================;;
proc lib_init ;///////////////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Library entry point (called after library load) ;;
;;------------------------------------------------------------------------------------------------;;
;> eax = pointer to memory allocation routine ;;
;> ebx = pointer to memory freeing routine ;;
;> ecx = pointer to memory reallocation routine ;;
;> edx = pointer to library loading routine ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 1 (fail) / 0 (ok) (library initialization result) ;;
;;================================================================================================;;
mov [mem.alloc], eax
mov [mem.free], ebx
mov [mem.realloc], ecx
mov [dll.load], edx
.ok: xor eax,eax
ret
endp
;;================================================================================================;;
proc img.is_img _data, _length ;//////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push ebx
mov ebx, img._.formats_table
@@: stdcall [ebx + FormatsTableEntry.Is], [_data], [_length]
or eax, eax
jnz @f
add ebx, sizeof.FormatsTableEntry
cmp dword[ebx], 0
jnz @b
xor eax, eax
@@: pop ebx
ret
endp
;;================================================================================================;;
proc img.info _data, _length ;////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
xor eax, eax
ret
endp
;;================================================================================================;;
proc img.from_file _filename ;////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 / pointer to image ;;
;;================================================================================================;;
xor eax, eax
ret
endp
;;================================================================================================;;
proc img.to_file _img, _filename ;////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = false / true ;;
;;================================================================================================;;
xor eax, eax
ret
endp
;;================================================================================================;;
proc img.from_rgb _rgb_data ;/////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 / pointer to image ;;
;;================================================================================================;;
xor eax, eax
ret
endp
;;================================================================================================;;
proc img.to_rgb _img ;////////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 / pointer to rgb_data (array of [rgb] triplets) ;;
;;================================================================================================;;
push esi edi
stdcall img._.validate, [_img]
or eax, eax
jnz .error
mov esi, [_img]
mov ecx, [esi + Image.Width]
imul ecx, [esi + Image.Height]
lea eax, [ecx * 3 + 4 * 3]
invoke mem.alloc, eax
or eax, eax
jz .error
mov edi, eax
push eax
mov eax, [esi + Image.Width]
stosd
mov eax, [esi + Image.Height]
stosd
mov esi, [esi + Image.Data]
@@: dec ecx
js @f
movsd
dec edi
jmp @b
@@: pop eax
pop edi esi
ret
.error:
xor eax, eax
pop edi esi
ret
endp
;;================================================================================================;;
proc img.decode _data, _length ;//////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 / pointer to image ;;
;;================================================================================================;;
push ebx
mov ebx, img._.formats_table
@@: stdcall [ebx + FormatsTableEntry.Is], [_data], [_length]
or eax, eax
jnz @f
add ebx, sizeof.FormatsTableEntry
cmp dword[ebx], 0
jnz @f
jmp .error
@@: stdcall [ebx + FormatsTableEntry.Decode], [_data], [_length]
.error:
ret
endp
;;================================================================================================;;
proc img.encode _img, _p_length ;/////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 / pointer to encoded data ;;
;< [_p_length] = data length ;;
;;================================================================================================;;
xor eax, eax
ret
endp
;;================================================================================================;;
proc img.create _width, _height ;/////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 / pointer to image ;;
;;================================================================================================;;
push ecx
stdcall img._.new
or eax, eax
jz .error
push eax
stdcall img._resize_data, eax, [_width], [_height]
or eax, eax
jz .error.2
pop eax
ret
.error.2:
; pop eax
stdcall img._.delete; eax
xor eax, eax
.error:
pop ecx
ret
endp
;;================================================================================================;;
proc img.destroy _img ;///////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = false / true ;;
;;================================================================================================;;
;TODO: link Next and Previous
stdcall img._.delete, [_img]
ret
endp
;;================================================================================================;;
proc img._resize_data _img, _width, _height ;/////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push ebx
mov ebx, [_img]
mov eax, [_height]
imul eax, [_width]
shl eax, 2
invoke mem.realloc, [ebx + Image.Data], eax
or eax, eax
jz .error
mov [ebx + Image.Data], eax
push [_width]
pop [ebx + Image.Width]
push [_height]
pop [ebx + Image.Height]
.error:
pop ebx
ret
endp
;;================================================================================================;;
proc img.lock_bits _img, _start_line, _end_line ;/////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 / pointer to bits ;;
;;================================================================================================;;
xor eax, eax
ret
endp
;;================================================================================================;;
proc img.unlock_bits _img, _lock ;////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = false / true ;;
;;================================================================================================;;
xor eax, eax
ret
endp
;;//// image processing //////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
proc img.flip _img, _flip_kind ;//////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = false / true ;;
;;================================================================================================;;
locals
scanline_len dd ?
endl
push esi edi
stdcall img._.validate, [_img]
or eax, eax
jnz .error
mov esi, [_img]
mov ecx, [esi + Image.Height]
mov eax, [esi + Image.Width]
shl eax, 2
mov [scanline_len], eax
test [_flip_kind], FLIP_VERTICAL
jz .dont_flip_vert
imul eax, ecx
sub eax, [scanline_len]
shr ecx, 1
mov esi, [esi + Image.Data]
lea edi, [esi + eax]
.next_line_vert:
push ecx
mov ecx, [scanline_len]
@@: lodsd
xchg eax, [edi]
mov [esi - 4], eax
add edi, 4
add ecx, -4
jnz @b
mov eax, [scanline_len]
shl eax, 1
sub edi, eax
pop ecx
dec ecx
jnz .next_line_vert
.dont_flip_vert:
test [_flip_kind], FLIP_HORIZONTAL
jz .exit
;TODO: horz flip code
.exit:
xor eax, eax
inc eax
pop edi esi
ret
.error:
xor eax, eax
pop edi esi
ret
endp
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
;! Below are private procs you should never call directly from your code ;;
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
;;================================================================================================;;
proc img._.validate, _img ;///////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
xor eax, eax
ret
endp
;;================================================================================================;;
proc img._.new ;//////////////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 / pointer to image ;;
;;================================================================================================;;
invoke mem.alloc, sizeof.Image
ret
endp
;;================================================================================================;;
proc img._.delete _img ;//////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = false / true ;;
;;================================================================================================;;
push edx
mov edx, [_img]
cmp [edx + Image.Data], 0
je @f
invoke mem.free, [edx + Image.Data]
@@: cmp [edx + Image.Extended], 0
je @f
invoke mem.free, [edx + Image.Extended]
@@: invoke mem.free, edx
pop edx
ret
endp
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
;! Below is private data you should never use directly from your code ;;
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
img._.formats_table:
.bmp dd img.is.bmp, img.decode.bmp, img.encode.bmp
; .ico dd img.is.ico, img.decode.ico, img.encode.ico
; .cur dd img.is.cur, img.decode.cur, img.encode.cur
.gif dd img.is.gif, img.decode.gif, img.encode.gif
; .png dd img.is.png, img.decode.png, img.encode.png
; .jpg dd img.is.jpg, img.decode.jpg, img.encode.jpg
dd 0
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
;! Exported functions section ;;
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
align 16
@EXPORT:
export \
lib_init , 'lib_init' , \
0x00010001 , 'version' , \
img.is_img , 'img.is_img' , \
img.info , 'img.info' , \
img.from_file , 'img.from_file' , \
img.to_file , 'img.to_file' , \
img.from_rgb , 'img.from_rgb' , \
img.to_rgb , 'img.to_rgb' , \
img.decode , 'img.decode' , \
img.encode , 'img.encode' , \
img.create , 'img.create' , \
img.destroy , 'img.destroy' , \
img.lock_bits , 'img.lock_bits' , \
img.unlock_bits , 'img.unlock_bits'

View File

@ -0,0 +1,39 @@
;;================================================================================================;;
;;//// libimg.inc //// (c) mike.dld, 2007-2008 ///////////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; 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 ;;
;; General Public License as published by the Free Software Foundation, either version 3 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 ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; General Public License for more details. ;;
;; ;;
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
;; see <http://www.gnu.org/licenses/>. ;;
;; ;;
;;================================================================================================;;
struct FormatsTableEntry
Is dd ?
Decode dd ?
Encode dd ?
ends
struct Image
Checksum dd ? ; ((Width ROL 16) OR Height) XOR Data[0]
Width dd ?
Height dd ?
Next dd ?
Previous dd ?
Data dd ?
Extended dd ?
ends
FLIP_VERTICAL = 0x01
FLIP_HORIZONTAL = 0x02
FLIP_BOTH = FLIP_VERTICAL or FLIP_HORIZONTAL

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
;;================================================================================================;;
;;//// libini_p.inc //// (c) mike.dld, 2007-2008 /////////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; 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 ;;
;; General Public License as published by the Free Software Foundation, either version 3 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 ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; General Public License for more details. ;;
;; ;;
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
;; see <http://www.gnu.org/licenses/>. ;;
;; ;;
;;================================================================================================;;
ini.MAX_NAME_LEN = 1024
ini.MAX_VALUE_LEN = 4096
ini.MEM_SIZE = 4096
ini.BLOCK_SIZE = ini.MEM_SIZE / 2
struct IniFile
fh dd ?
buf dd ?
cnt dd ?
pos dd ?
bsize dd ?
ends

View File

@ -0,0 +1,803 @@
;;================================================================================================;;
;;//// libio.asm //// (c) mike.dld, 2006-2008 ////////////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; 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 ;;
;; General Public License as published by the Free Software Foundation, either version 3 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 ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; General Public License for more details. ;;
;; ;;
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
;; see <http://www.gnu.org/licenses/>. ;;
;; ;;
;;================================================================================================;;
;; ;;
;; 2007-12-10 (mike.dld) ;;
;; changes: ;;
;; - almost fully incompatible with previous version since return values were changed. ;;
;; now they are more C-like ;;
;; notes: ;;
;; - `file.err` is not yet available ;;
;; 2007-09-26 (mike.dld) ;;
;; changes: ;;
;; - modified `file.size` a bit (according to changes in FileInfo struct) ;;
;; - added `file.find_first`, `file.find_next`, `file.find_close` ;;
;; notes: ;;
;; - `file.aux.match_wildcard` is exported only for testing purposes, don't ;;
;; use it since it may be removed or renamed in next versions ;;
;; ;;
;;================================================================================================;;
format MS COFF
public @EXPORT as 'EXPORTS'
include '../../../../proc32.inc'
include '../../../../macros.inc'
purge section;mov,add,sub
include 'libio.inc'
include 'libio_p.inc'
section '.flat' code readable align 16
mem.alloc dd ?
mem.free dd ?
mem.realloc dd ?
dll.load dd ?
;;================================================================================================;;
proc lib_init ;///////////////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Library entry point (called after library load) ;;
;;------------------------------------------------------------------------------------------------;;
;> eax = pointer to memory allocation routine ;;
;> ebx = pointer to memory freeing routine ;;
;> ecx = pointer to memory reallocation routine ;;
;> edx = pointer to library loading routine ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 1 (fail) / 0 (ok) (library initialization result) ;;
;;================================================================================================;;
mov [mem.alloc], eax
mov [mem.free], ebx
mov [mem.realloc], ecx
mov [dll.load], edx
xor eax, eax
ret
endp
;;================================================================================================;;
proc file.aux.match_wildcard _str, _wcard ;///////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Match string against wildcard ;;
;? Based on http://user.cs.tu-berlin.de/~schintke/references/wildcards/ ;;
;? 1997-2001 (c) Florian Schintke ;;
;;------------------------------------------------------------------------------------------------;;
;> _str = pointer to string (filename in most cases) ;;
;> _wcard = pointer to string (mask expressed using wilcards (?, *, [..])) ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = false / true (match result) ;;
;;================================================================================================;;
push ecx edx esi edi
mov dl, 1 ; fit
mov esi, [_wcard]
mov edi, [_str]
.loop_wildcard:
mov al, [esi]
or al, al
jz .loop_wildcard_exit
or dl, dl
jz .loop_wildcard_exit
cmp byte[edi], 0
je .loop_wildcard_exit
cmp al, '['
je .process_set
cmp al, '?'
je .process_question
cmp al, '*'
je .process_asterisk
xor dl, dl
cmp [edi], al
jne @f
inc dl
@@: inc edi
.loop_wildcard_next:
inc esi
jmp .loop_wildcard
.process_set:
inc esi
xor dl, dl ; fit
xor dh, dh ; negation
mov cl, 1 ; at_beginning
cmp byte[esi], '^'
jne .loop_set_wildcard
inc dh
inc esi
.loop_set_wildcard:
mov al, [esi]
cmp al, ']'
jne @f
or cl, cl
jz .loop_set_wildcard_exit
@@: or dl, dl
jnz .loop_set_wildcard_fit
cmp al, '-'
jne .loop_set_wildcard_not_range
mov ch, [esi - 1]
cmp [esi + 1], ch
jbe .loop_set_wildcard_not_range
cmp byte[esi + 1], ']'
je .loop_set_wildcard_not_range
or cl, cl
jnz .loop_set_wildcard_not_range
cmp [edi], ch
jb .loop_set_wildcard_fit
mov ch, [esi + 1]
cmp [edi], ch
ja .loop_set_wildcard_fit
mov dl, 1
inc esi
jmp .loop_set_wildcard_fit
.loop_set_wildcard_not_range:
cmp [edi], al
jne .loop_set_wildcard_fit
mov dl, 1
.loop_set_wildcard_fit:
inc esi
xor cl, cl
jmp .loop_set_wildcard
.loop_set_wildcard_exit:
or dh, dh
jz @f
xor dl, 1
@@: or dl, dl
jz @f
inc edi
@@:
jmp .loop_wildcard_next
.process_question:
inc edi
jmp .loop_wildcard_next
.process_asterisk:
mov dl, 1
inc esi
.loop_asterisk_del_shit:
lodsb
cmp byte[edi], 0
je .loop_asterisk_del_shit_exit
cmp al, '?'
jne @f
inc edi
jmp .loop_asterisk_del_shit
@@: cmp al, '*'
je .loop_asterisk_del_shit
.loop_asterisk_del_shit_exit:
@@: cmp al, '*'
jne @f
lodsb
jmp @b
@@:
dec esi
cmp byte[edi], 0
jne .process_asterisk_skip_exit
xor dl, dl
or al, al
jnz @f
inc dl
@@: dec esi
jmp .loop_wildcard_next
.process_asterisk_skip_exit:
stdcall file.aux.match_wildcard, edi, esi
or eax, eax
jnz .process_asterisk_not_match
.loop_asterisk_match:
inc edi
.loop_asterisk_char_match:
mov al, [esi]
cmp [edi], al
je .loop_asterisk_char_match_exit
cmp byte[esi], '['
je .loop_asterisk_char_match_exit
cmp byte[edi], 0
je .loop_asterisk_char_match_exit
inc edi
jmp .loop_asterisk_char_match
.loop_asterisk_char_match_exit:
cmp byte[edi], 0
je @f
stdcall file.aux.match_wildcard, edi, esi
or eax, eax
jnz .loop_asterisk_match_exit
jmp .loop_asterisk_match
@@:
xor dl, dl
.loop_asterisk_match_exit:
.process_asterisk_not_match:
cmp byte[esi], 0
jne @f
cmp byte[edi], 0
jne @f
mov dl, 1
@@:
dec esi
jmp .loop_wildcard_next
.loop_wildcard_exit:
or dl, dl
jz .exit
@@: cmp byte[esi], '*'
jne .exit
inc esi
jmp @b
.exit:
cmp byte[esi], 0
je @f
xor dl, dl
@@: cmp byte[edi], 0
je @f
xor dl, dl
@@:
movzx eax, dl
pop edi esi edx ecx
ret
endp
;;================================================================================================;;
proc file.aux.find_matching_file _ffb ;///////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Find file with matching attributes (`FindFileBlock.Options.Attributes`) and mask ;;
;? (`FindFileBlock.Options.Mask`) starting from Nth (`FindFileBlock.InfoBlock.Position`) file in ;;
;? directory (`FindFileBlock.InfoBlock.FileName`) ;;
;;------------------------------------------------------------------------------------------------;;
;> _ffb = pointer to FindFileBlock ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 (error) / pointer to `FileInfo` with matched file data ;;
;;================================================================================================;;
push ebx edx
mov edx, [_ffb]
.loop_find:
lea ebx, [edx + FindFileBlock.InfoBlock]
mcall 70
or eax, eax
jnz .loop_find_error
mov eax, [edx + FindFileBlock.Info.Attributes]
and eax, [edx + FindFileBlock.Options.Attributes]
jz .loop_find_next
lea eax, [edx + FindFileBlock.Info.FileName]
stdcall file.aux.match_wildcard, eax, [edx + FindFileBlock.Options.Mask]
or eax, eax
jnz .loop_find_exit
.loop_find_next:
inc [edx + FindFileBlock.InfoBlock.Position]
jmp .loop_find
.loop_find_error:
xor eax, eax
pop edx ebx
ret
.loop_find_exit:
lea eax, [edx + FindFileBlock.Info]
pop edx ebx
ret
endp
;;================================================================================================;;
proc file.find_first _dir, _mask, _attr ;/////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Find first file with matching attributes and mask in specified directory ;;
;;------------------------------------------------------------------------------------------------;;
;> _dir = pointer to string (directory path to search in) ;;
;> _mask = pointer to string (file mask, with use of wildcards) ;;
;> _attr = file attributes mask (combination of FA_* constants) ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 (error) / pointer to `FileInfo` with matched file data (acts as find descriptor) ;;
;;================================================================================================;;
push ebx edx
invoke mem.alloc, sizeof.FindFileBlock
or eax, eax
jz .exit.error
mov edx, eax
mov ebx, [_attr]
mov [edx + FindFileBlock.Options.Attributes], ebx
mov ebx, [_mask]
mov [edx + FindFileBlock.Options.Mask], ebx
lea ebx, [edx + FindFileBlock.InfoBlock]
mov [ebx + FileInfoBlock.Function], F70_READ_D
mov [ebx + FileInfoBlock.Count], 1
lea eax, [edx + FindFileBlock.Header]
mov [ebx + FileInfoBlock.Buffer], eax
mov eax, [_dir]
mov [ebx + FileInfoBlock.FileName], eax
stdcall file.aux.find_matching_file, edx
pop edx ebx
ret
.exit.error:
xor eax, eax
pop edx ebx
ret
endp
;;================================================================================================;;
proc file.find_next _findd ;//////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Find next file matching criteria ;;
;;------------------------------------------------------------------------------------------------;;
;> _findd = find descriptor (see `file.find_first`) ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 (error) / pointer to `FileInfo` with matched file data (acts as find descriptor) ;;
;;================================================================================================;;
mov eax, [_findd]
add eax, -sizeof.FileInfoHeader
inc [eax + FindFileBlock.InfoBlock.Position]
stdcall file.aux.find_matching_file, eax
ret
endp
;;================================================================================================;;
proc file.find_close _findd ;/////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Close find descriptor and free memory ;;
;;------------------------------------------------------------------------------------------------;;
;> _findd = find descriptor (see `file.find_first`) ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = result of memory freeing routine ;;
;;================================================================================================;;
mov eax, [_findd]
add eax, -sizeof.FileInfoHeader
invoke mem.free, eax
ret
endp
;;================================================================================================;;
proc file.size _name ;////////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Get file size ;;
;;------------------------------------------------------------------------------------------------;;
;> _name = path to file (full or relative) ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = -1 (error) / file size (in bytes, up to 2G) ;;
;;------------------------------------------------------------------------------------------------;;
;# call `file.err` to obtain extended error information ;;
;;================================================================================================;;
locals
loc_info FileInfoBlock
endl
lea ebx, [loc_info]
invoke mem.alloc, 40
push eax
mov [ebx + FileInfoBlock.Function], F70_GETATTR_FD
mov [ebx + FileInfoBlock.Buffer], eax
mov byte[ebx + FileInfoBlock.FileName - 1], 0
mov eax, [_name]
mov [ebx + FileInfoBlock.FileName], eax
mcall 70
pop ebx
push eax
mov eax, ebx
mov ebx, [ebx + FileInfo.FileSizeLow]
invoke mem.free, eax
pop eax
ret
endp
;;================================================================================================;;
proc file.open _name, _mode ;/////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Open file ;;
;;------------------------------------------------------------------------------------------------;;
;> _name = path to file (full or relative) ;;
;> _mode = mode to open file in (combination of O_* constants) ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 (error) / file descriptor ;;
;;------------------------------------------------------------------------------------------------;;
;# call `file.err` to obtain extended error information ;;
;;================================================================================================;;
locals
loc_info FileInfoBlock
loc_buf rb 40
endl
push ebx esi edi
xor ebx, ebx
invoke mem.alloc, sizeof.InternalFileInfo
or eax, eax
jz .exit_error
mov ebx, eax
push [_mode]
pop [ebx + InternalFileInfo.Mode]
mov [ebx + InternalFileInfo.Position], 0
lea edi, [ebx + InternalFileInfo.FileName]
mov esi, [_name]
mov ecx, 260 / 4
cld
rep movsd
.get_info:
push ebx
mov [loc_info.Function], F70_GETATTR_FD
lea eax, [loc_buf]
mov [loc_info.Buffer], eax
mov byte[loc_info.FileName - 1], 0
mov eax, [_name]
mov [loc_info.FileName], eax
lea ebx, [loc_info]
mcall 70
pop ebx
or eax, eax
jz @f
cmp eax, 6
jne .exit_error.ex
@@:
mov eax, ebx
pop edi esi ebx
ret
.exit_error.ex:
test [_mode], O_CREATE
jz .exit_error
push ebx
mov [loc_info.Function], F70_CREATE_F
xor eax, eax
mov [loc_info.Position], eax
mov [loc_info.Flags], eax
mov [loc_info.Count], eax
lea ebx, [loc_info]
mcall 70
pop ebx
or eax, eax
jz .get_info
.exit_error:
invoke mem.free, ebx
xor eax, eax
pop edi esi ebx
ret
endp
;;================================================================================================;;
proc file.read _filed, _buf, _buflen ;////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Read data from file ;;
;;------------------------------------------------------------------------------------------------;;
;> _filed = file descriptor (see `file.open`) ;;
;> _buf = pointer to buffer to put read data to ;;
;> _buflen = buffer size (number of bytes to be read from file) ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = -1 (error) / number of bytes read ;;
;;------------------------------------------------------------------------------------------------;;
;# call `file.err` to obtain extended error information ;;
;;================================================================================================;;
locals
loc_info FileInfoBlock
endl
push ebx esi edi
mov ebx, [_filed]
test [ebx + InternalFileInfo.Mode], O_READ
jz .exit_error
xor eax, eax
mov [loc_info.Function], F70_READ_F
mov [loc_info.Flags], eax
mov byte[loc_info.FileName - 1], al
push [ebx+InternalFileInfo.Position] [_buflen] [_buf]
pop [loc_info.Buffer] [loc_info.Count] [loc_info.Position]
lea eax, [ebx + InternalFileInfo.FileName]
mov [loc_info.FileName], eax
lea ebx, [loc_info]
mcall 70
or eax, eax
jz @f
cmp eax, 6
jne .exit_error
@@:
mov eax, ebx
mov ebx, [_filed]
add [ebx + InternalFileInfo.Position], eax
pop edi esi ebx
ret
.exit_error:
or eax, -1
pop edi esi ebx
ret
endp
;;================================================================================================;;
proc file.write _filed, _buf, _buflen ;///////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Write data to file ;;
;;------------------------------------------------------------------------------------------------;;
;> _filed = file descriptor (see `file.open`) ;;
;> _buf = pointer to buffer to get write data from ;;
;> _buflen = buffer size (number of bytes to be written to file) ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = -1 (error) / number of bytes written ;;
;;------------------------------------------------------------------------------------------------;;
;# call `file.err` to obtain extended error information ;;
;;================================================================================================;;
locals
loc_info FileInfoBlock
endl
push ebx esi edi
mov ebx, [_filed]
test [ebx + InternalFileInfo.Mode], O_WRITE
jz .exit_error
stdcall file.eof?, [_filed]
or eax, eax
js .exit_error
jz @f
stdcall file.truncate, [_filed]
@@:
mov [loc_info.Function], F70_WRITE_F
xor eax, eax
mov [loc_info.Flags], eax
mov byte[loc_info.FileName - 1], al
push [ebx + InternalFileInfo.Position] [_buflen] [_buf]
pop [loc_info.Buffer] [loc_info.Count] [loc_info.Position]
lea eax, [ebx + InternalFileInfo.FileName]
mov [loc_info.FileName], eax
lea ebx, [loc_info]
mcall 70
or eax, eax
jnz .exit_error
@@:
mov eax, ebx
mov ebx, [_filed]
add [ebx + InternalFileInfo.Position],eax
pop edi esi ebx
ret
.exit_error:
or eax, -1
pop edi esi ebx
ret
endp
;;================================================================================================;;
proc file.seek _filed, _where, _origin ;//////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Set file pointer position ;;
;;------------------------------------------------------------------------------------------------;;
;> _filed = file descriptor (see `file.open`) ;;
;> _where = position in file (in bytes) counted from specified origin ;;
;> _origin = origin from where to set the position (one of SEEK_* constants) ;;
;> SEEK_SET - from beginning of file ;;
;> SEEK_CUR - from current pointer position ;;
;> SEEK_END - from end of file ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = -1 (error) / 0 ;;
;;------------------------------------------------------------------------------------------------;;
;# call `file.err` to obtain extended error information ;;
;;================================================================================================;;
push ebx ecx edx
mov ecx, [_filed]
lea eax, [ecx + InternalFileInfo.FileName]
stdcall file.size, eax
or eax, eax
jnz .exit_error
mov edx, [_where]
cmp [_origin], SEEK_SET
jne .n_set
mov [ecx + InternalFileInfo.Position], edx
jmp .exit_ok
.n_set:
cmp [_origin], SEEK_CUR
jne .n_cur
add [ecx + InternalFileInfo.Position], edx
jmp .exit_ok
.n_cur:
cmp [_origin], SEEK_END
jne .exit_error
neg edx
add edx, ebx
mov [ecx + InternalFileInfo.Position], edx
.exit_ok:
cmp [ecx + InternalFileInfo.Position], 0
jge @f
mov [ecx + InternalFileInfo.Position], 0
@@:
; cmp ebx, [ecx+InternalFileInfo.Position]
; jae @f
; mov [ecx + InternalFileInfo.Position], ebx
; @@:
xor eax, eax
pop edx ecx ebx
ret
.exit_error:
or eax, -1
pop edx ecx ebx
ret
endp
;;================================================================================================;;
proc file.eof? _filed ;///////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Determine if file pointer is at the end of file ;;
;;------------------------------------------------------------------------------------------------;;
;> _filed = file descriptor (see `file.open`) ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = false / true ;;
;;------------------------------------------------------------------------------------------------;;
;# call `file.err` to obtain extended error information ;;
;;================================================================================================;;
push ebx ecx
mov ecx, [_filed]
lea eax, [ecx + InternalFileInfo.FileName]
stdcall file.size, eax
or eax, eax
jnz .exit_error
xor eax, eax
cmp [ecx + InternalFileInfo.Position], ebx
jb @f
inc eax
@@: pop ecx ebx
ret
.exit_error:
or eax, -1
pop ecx ebx
ret
endp
;;================================================================================================;;
proc file.truncate _filed ;///////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Truncate file size to current file pointer position ;;
;;------------------------------------------------------------------------------------------------;;
;> _filed = file descriptor (see `file.open`) ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = -1 (error) / 0 ;;
;;------------------------------------------------------------------------------------------------;;
;# call `file.err` to obtain extended error information ;;
;;================================================================================================;;
locals
loc_info FileInfoBlock
endl
push ebx esi edi
mov ebx, [_filed]
test [ebx + InternalFileInfo.Mode], O_WRITE
jz .exit_error
mov [loc_info.Function], F70_SETSIZE_F
mov eax, [ebx + InternalFileInfo.Position]
mov [loc_info.Position], eax
xor eax, eax
mov [loc_info.Flags], eax
mov [loc_info.Count], eax
mov [loc_info.Buffer], eax
mov byte[loc_info.FileName - 1], al
lea eax, [ebx + InternalFileInfo.FileName]
mov [loc_info.FileName], eax
lea ebx, [loc_info]
mcall 70
cmp eax, 2
je .exit_error
cmp eax, 8
je .exit_error
@@: xor eax, eax
pop edi esi ebx
ret
.exit_error:
or eax, -1
pop edi esi ebx
ret
endp
file.seteof equ file.truncate
;;================================================================================================;;
proc file.tell _filed ;///////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Get current file pointer position ;;
;;------------------------------------------------------------------------------------------------;;
;> _filed = file descriptor (see `file.open`) ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = -1 (error) / file pointer position ;;
;;------------------------------------------------------------------------------------------------;;
;# call `file.err` to obtain extended error information ;;
;;================================================================================================;;
mov eax, [_filed]
mov eax, [eax + InternalFileInfo.Position]
ret
endp
;;================================================================================================;;
proc file.close _filed ;//////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Close file ;;
;;------------------------------------------------------------------------------------------------;;
;> _filed = file descriptor (see `file.open`) ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = -1 (error) / file pointer position ;;
;;------------------------------------------------------------------------------------------------;;
;# call `file.err` to obtain extended error information ;;
;;================================================================================================;;
mov eax, [_filed]
mov [eax + InternalFileInfo.Mode], 0
mov [eax + InternalFileInfo.FileName], 0
invoke mem.free, eax
xor eax, eax
ret
endp
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
;! Exported functions section ;;
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
align 16
@EXPORT:
export \
lib_init , 'lib_init' , \
0x00030003 , 'version' , \
file.find_first , 'file.find_first' , \
file.find_next , 'file.find_next' , \
file.find_close , 'file.find_close' , \
file.size , 'file.size' , \
file.open , 'file.open' , \
file.read , 'file.read' , \
file.write , 'file.write' , \
file.seek , 'file.seek' , \
file.tell , 'file.tell' , \
file.eof? , 'file.eof?' , \
file.seteof , 'file.seteof' , \
file.truncate , 'file.truncate' , \
file.close , 'file.close'

View File

@ -0,0 +1,112 @@
;;================================================================================================;;
;;//// libio.inc //// (c) mike.dld, 2007-2008 ////////////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; 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 ;;
;; General Public License as published by the Free Software Foundation, either version 3 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 ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; General Public License for more details. ;;
;; ;;
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
;; see <http://www.gnu.org/licenses/>. ;;
;; ;;
;;================================================================================================;;
O_BINARY = 00000000b
O_READ = 00000001b
O_WRITE = 00000010b
O_CREATE = 00000100b
O_SHARE = 00001000b
O_TEXT = 00010000b
SEEK_SET = 0
SEEK_CUR = 1
SEEK_END = 2
struct FileDateTime
union
time dd ?
struct
sec db ?
min db ?
hour db ?
ends
ends
union
date dd ?
struct
day db ?
month db ?
year dw ?
ends
ends
ends
struct FileInfoBlock
Function dd ?
Position dd ?
Flags dd ?
Count dd ?
Buffer dd ?
db ?
FileName dd ?
ends
struct FileInfoHeader
Version dd ?
FilesRead dd ?
FilesCount dd ?
rd 5
ends
struct FileInfoA
Attributes dd ?
Flags dd ?
DateCreate FileDateTime
DateAccess FileDateTime
DateModify FileDateTime
union
FileSize dq ?
struct
FileSizeLow dd ?
FileSizeHigh dd ?
ends
ends
FileName rb 252
ends
struct FileInfoW
Attributes dd ?
Flags dd ?
DateCreate FileDateTime
DateAccess FileDateTime
DateModify FileDateTime
union
FileSize dq ?
struct
FileSizeLow dd ?
FileSizeHigh dd ?
ends
ends
FileName rw 260
ends
virtual at 0
FileInfo FileInfoA
FileInfo fix FileInfoA
sizeof.FileInfo fix sizeof.FileInfoA
end virtual
FA_READONLY = 00000001b
FA_HIDDEN = 00000010b
FA_SYSTEM = 00000100b
FA_LABEL = 00001000b
FA_FOLDER = 00010000b
FA_ARCHIVED = 00100000b
FA_ANY = 00111111b

View File

@ -0,0 +1,63 @@
;;================================================================================================;;
;;//// libio_p.inc //// (c) mike.dld, 2007-2008 //////////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; 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 ;;
;; General Public License as published by the Free Software Foundation, either version 3 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 ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; General Public License for more details. ;;
;; ;;
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
;; see <http://www.gnu.org/licenses/>. ;;
;; ;;
;;================================================================================================;;
F70_READ_F = 0
F70_READ_D = 1
F70_CREATE_F = 2
F70_WRITE_F = 3
F70_SETSIZE_F = 4
F70_GETATTR_FD = 5
F70_SETATTR_FD = 6
F70_START_F = 7
F70_DELETE_FD = 8
F70_CREATE_D = 9
F70_ERR_OK = 0
F70_ERR_INVALID_DRIVE_SPEC = 1
F70_ERR_FUNC_NOT_SUPPORTED = 2
F70_ERR_UNKNOWN_FS = 3
F70_ERR_FILE_NOT_FOUND = 5
F70_ERR_END_OF_FILE = 6
F70_ERR_INVALID_POINTER = 7
F70_ERR_NO_DISK_SPACE = 8
F70_ERR_FAT_CORRUPTED = 9
F70_ERR_ACCESS_DENIED = 10
F70_ERR_DEVICE_ERROR = 11
F70_ERR_NOT_ENOUGH_MEMORY = 30
F70_ERR_NOT_EXECUTABLE = 31
F70_ERR_TOO_MANY_PROCESSES = 32
struct FindOptions
Attributes dd ?
Mask dd ?
ends
struct FindFileBlock
Header FileInfoHeader
Info FileInfo
InfoBlock FileInfoBlock
Options FindOptions
ends
struct InternalFileInfo
Mode dd ?
Position dd ?
FileName rb 260
ends