/programs/media/animage/trunk/giflib.inc |
---|
File deleted |
/programs/media/animage/trunk/animage.asm |
---|
22,7 → 22,8 |
include '..\..\..\macros.inc' |
include 'giflib.inc' |
COLOR_ORDER equ MENUETOS |
include 'gif_lite.inc' |
include 'bmplib.inc' |
include 'dialog.inc' |
include 'dialog2.inc' |
274,4 → 275,4 |
I_END: |
IncludeUGlobals |
/programs/media/animage/trunk/gif_lite.inc |
---|
0,0 → 1,485 |
; GIF LITE v3.0 by Willow |
; Written in pure assembler by Ivushkin Andrey aka Willow |
; Modified by Diamond |
; |
; This include file will contain functions to handle GIF image format |
; |
; Created: August 15, 2004 |
; Last changed: June 24, 2007 |
; Requires kglobals.inc (iglobal/uglobal macro) |
; (program must 'include "kglobals.inc"' and say 'IncludeUGlobal' |
; somewhere in uninitialized data area). |
; Configuration: [changed from program which includes this file] |
; 1. The constant COLOR_ORDER: must be one of |
; PALETTE - for 8-bit image with palette (sysfunction 65) |
; MENUETOS - for MenuetOS and KolibriOS color order (sysfunction 7) |
; OTHER - for standard color order |
; 2. Define constant GIF_SUPPORT_INTERLACED if you want to support interlaced |
; GIFs. |
; 3. Single image mode vs multiple image mode: |
; if the program defines the variable 'gif_img_count' of type dword |
; somewhere, ReadGIF will enter multiple image mode: gif_img_count |
; will be initialized with image count, output format is GIF_list, |
; the function GetGIFinfo retrieves Nth image info. Otherwise, ReadGIF |
; uses single image mode: exit after end of first image, output is |
; <dd width,height, times width*height[*3] db image> |
if ~ (COLOR_ORDER in <PALETTE,MENUETOS,OTHER>) |
; This message may not appear under MenuetOS, so watch... |
display 'Please define COLOR_ORDER: PALETTE, MENUETOS or OTHER',13,10 |
end if |
if defined gif_img_count |
; virtual structure, used internally |
struct GIF_list |
NextImg rd 1 |
Left rw 1 |
Top rw 1 |
Width rw 1 |
Height rw 1 |
Delay rd 1 |
Displacement rd 1 ; 0 = not specified |
; 1 = do not dispose |
; 2 = restore to background color |
; 3 = restore to previous |
if COLOR_ORDER eq PALETTE |
Image rd 1 |
end if |
ends |
struct GIF_info |
Left rw 1 |
Top rw 1 |
Width rw 1 |
Height rw 1 |
Delay rd 1 |
Displacement rd 1 |
if COLOR_ORDER eq PALETTE |
Palette rd 1 |
end if |
ends |
; **************************************** |
; FUNCTION GetGIFinfo - retrieve Nth image info |
; **************************************** |
; in: |
; esi - pointer to image list header |
; ecx - image_index (0...img_count-1) |
; edi - pointer to GIF_info structure to be filled |
; out: |
; eax - pointer to RAW data, or 0, if error |
GetGIFinfo: |
push esi ecx edi |
xor eax,eax |
jecxz .eloop |
.lp: |
mov esi,[esi] |
test esi,esi |
jz .error |
loop .lp |
.eloop: |
lodsd |
movsd |
movsd |
movsd |
movsd |
if COLOR_ORDER eq PALETTE |
lodsd |
mov [edi],esi |
else |
mov eax,esi |
end if |
.error: |
pop edi ecx esi |
ret |
end if |
_null fix 0x1000 |
; **************************************** |
; FUNCTION ReadGIF - unpacks GIF image |
; **************************************** |
; in: |
; esi - pointer to GIF file in memory |
; edi - pointer to output image list |
; out: |
; eax - 0, all OK; |
; eax - 1, invalid signature; |
; eax >=8, unsupported image attributes |
; |
ReadGIF: |
push esi edi |
mov [.cur_info],edi |
xor eax,eax |
mov [.globalColor],eax |
if defined gif_img_count |
mov [gif_img_count],eax |
mov [.anim_delay],eax |
mov [.anim_disp],eax |
end if |
inc eax |
cmp dword[esi],'GIF8' |
jne .ex ; signature |
mov ecx,[esi+0xa] |
add esi,0xd |
mov edi,esi |
test cl,cl |
jns .nextblock |
mov [.globalColor],esi |
call .Gif_skipmap |
.nextblock: |
cmp byte[edi],0x21 |
jne .noextblock |
inc edi |
if defined gif_img_count |
cmp byte[edi],0xf9 ; Graphic Control Ext |
jne .no_gc |
movzx eax,word [edi+3] |
mov [.anim_delay],eax |
mov al,[edi+2] |
shr al,2 |
and eax,7 |
mov [.anim_disp],eax |
add edi,7 |
jmp .nextblock |
.no_gc: |
end if |
inc edi |
.block_skip: |
movzx eax,byte[edi] |
lea edi,[edi+eax+1] |
test eax,eax |
jnz .block_skip |
jmp .nextblock |
.noextblock: |
mov al,8 |
cmp byte[edi],0x2c ; image beginning |
jne .ex |
if defined gif_img_count |
inc [gif_img_count] |
end if |
inc edi |
mov esi,[.cur_info] |
if defined gif_img_count |
add esi,4 |
end if |
xchg esi,edi |
if defined GIF_SUPPORT_INTERLACED |
movzx ecx,word[esi+4] |
mov [.width],ecx |
movzx eax,word[esi+6] |
imul eax,ecx |
if ~(COLOR_ORDER eq PALETTE) |
lea eax,[eax*3] |
end if |
mov [.img_end],eax |
inc eax |
mov [.row_end],eax |
and [.pass],0 |
test byte[esi+8],40h |
jz @f |
if ~(COLOR_ORDER eq PALETTE) |
lea ecx,[ecx*3] |
end if |
mov [.row_end],ecx |
@@: |
end if |
if defined gif_img_count |
movsd |
movsd |
mov eax,[.anim_delay] |
stosd |
mov eax,[.anim_disp] |
stosd |
else |
movzx eax,word[esi+4] |
stosd |
movzx eax,word[esi+6] |
stosd |
add esi,8 |
end if |
push edi |
mov ecx,[esi] |
inc esi |
test cl,cl |
js .uselocal |
push [.globalColor] |
mov edi,esi |
jmp .setPal |
.uselocal: |
call .Gif_skipmap |
push esi |
.setPal: |
movzx ecx,byte[edi] |
inc ecx |
mov [.codesize],ecx |
dec ecx |
if ~(COLOR_ORDER eq PALETTE) |
pop [.Palette] |
end if |
lea esi,[edi+1] |
mov edi,.gif_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, _null shl 16 |
.filltable: |
stosd |
inc eax |
loop .filltable |
if COLOR_ORDER eq PALETTE |
pop eax |
pop edi |
push edi |
scasd |
push esi |
mov esi,eax |
mov ecx,[.CC] |
@@: |
lodsd |
dec esi |
bswap eax |
shr eax,8 |
stosd |
loop @b |
pop esi |
pop eax |
mov [eax],edi |
else |
pop edi |
end if |
if defined GIF_SUPPORT_INTERLACED |
mov [.img_start],edi |
add [.img_end],edi |
add [.row_end],edi |
end if |
.reinit: |
mov edx,[.EOI] |
inc edx |
push [.codesize] |
pop [.compsize] |
call .Gif_get_sym |
cmp eax,[.CC] |
je .reinit |
call .Gif_output |
.cycle: |
movzx ebx,ax |
call .Gif_get_sym |
cmp eax,edx |
jae .notintable |
cmp eax,[.CC] |
je .reinit |
cmp eax,[.EOI] |
je .end |
call .Gif_output |
.add: |
mov dword [.gif_workarea+edx*4],ebx |
cmp edx,0xFFF |
jae .cycle |
inc edx |
bsr ebx,edx |
cmp ebx,[.compsize] |
jne .noinc |
inc [.compsize] |
.noinc: |
jmp .cycle |
.notintable: |
push eax |
mov eax,ebx |
call .Gif_output |
push ebx |
movzx eax,bx |
call .Gif_output |
pop ebx eax |
jmp .add |
.end: |
if defined GIF_SUPPORT_INTERLACED |
mov edi,[.img_end] |
end if |
if defined gif_img_count |
mov eax,[.cur_info] |
mov [eax],edi |
mov [.cur_info],edi |
add esi,2 |
xchg esi,edi |
.nxt: |
cmp byte[edi],0 |
jnz .continue |
inc edi |
jmp .nxt |
.continue: |
cmp byte[edi],0x3b |
jne .nextblock |
xchg esi,edi |
and dword [eax],0 |
end if |
xor eax,eax |
.ex: |
pop edi esi |
ret |
.Gif_skipmap: |
; in: ecx - image descriptor, esi - pointer to colormap |
; out: edi - pointer to area after colormap |
and ecx,111b |
inc ecx ; color map size |
mov ebx,1 |
shl ebx,cl |
lea ebx,[ebx*2+ebx] |
lea edi,[esi+ebx] |
ret |
.Gif_get_sym: |
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 .exx |
.nextbl: |
add eax,esi |
mov [.block_ofs],eax |
pop eax |
.noblock: |
mov [.bit_count],8 |
.loop1: |
loop .shift |
pop ecx |
rol eax,cl |
.exx: |
xor ecx,ecx |
ret |
.Gif_output: |
push esi eax edx |
mov edx,.gif_workarea |
.next: |
push word[edx+eax*4] |
mov ax,word[edx+eax*4+2] |
inc ecx |
cmp ax,_null |
jnz .next |
shl ebx,16 |
mov bx,[esp] |
.loop2: |
pop ax |
if COLOR_ORDER eq PALETTE |
stosb |
else |
lea esi,[eax+eax*2] |
add esi,[.Palette] |
if COLOR_ORDER eq MENUETOS |
mov esi,[esi] |
bswap esi |
shr esi,8 |
mov [edi],esi |
add edi,3 |
else |
movsb |
movsb |
movsb |
end if |
end if |
if defined GIF_SUPPORT_INTERLACED |
cmp edi,[.row_end] |
jb .norowend |
mov eax,[.width] |
if ~(COLOR_ORDER eq PALETTE) |
lea eax,[eax*3] |
end if |
push eax |
sub edi,eax |
add eax,eax |
cmp [.pass],3 |
jz @f |
add eax,eax |
cmp [.pass],2 |
jz @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 |
jz @f |
add edi,eax |
cmp [.pass],2 |
jz @f |
add edi,eax |
add edi,eax |
@@: |
.nextrow: |
add eax,edi |
mov [.row_end],eax |
xor eax,eax |
.norowend: |
end if |
loop .loop2 |
pop edx eax esi |
ret |
uglobal |
align 4 |
ReadGIF.globalColor rd 1 |
ReadGIF.cur_info rd 1 ; image table pointer |
ReadGIF.codesize rd 1 |
ReadGIF.compsize rd 1 |
ReadGIF.bit_count rd 1 |
ReadGIF.CC rd 1 |
ReadGIF.EOI rd 1 |
if ~(COLOR_ORDER eq PALETTE) |
ReadGIF.Palette rd 1 |
end if |
ReadGIF.block_ofs rd 1 |
if defined GIF_SUPPORT_INTERLACED |
ReadGIF.row_end rd 1 |
ReadGIF.img_end rd 1 |
ReadGIF.img_start rd 1 |
ReadGIF.pass rd 1 |
ReadGIF.width rd 1 |
end if |
if defined gif_img_count |
ReadGIF.anim_delay rd 1 |
ReadGIF.anim_disp rd 1 |
end if |
ReadGIF.gif_workarea rb 16*1024 |
endg |
/programs/media/animage/trunk/icons.inc |
---|
4,7 → 4,6 |
load_icons: |
mov esi,panel_picture |
mov edi,[ScreenPointer] |
mov eax,edi |
add edi,(1200*1000*3) |
;mov edi,[PointerToIcons] |
call ReadGIF |
21,7 → 20,7 |
shl edx,16 |
add edx,[Icon_Y] |
mov ebx,[ScreenPointer] |
add ebx,(1200*1000*3)+12 |
add ebx,(1200*1000*3)+8 |
mov eax,7 |
mov ecx,417*65536+46 |
mcall |
/programs/media/animage/trunk/load_from_parameters.inc |
---|
142,7 → 142,7 |
cmp [type],'GI' |
jne no_unpakcing_file_1 |
;GIF DECODER |
sub edi,12 |
sub edi,8 |
call ReadGIF |
mov [save_flag],1 |
no_unpakcing_file_1: |
/programs/media/animage/trunk/menu_instruments.inc |
---|
337,7 → 337,7 |
cmp [type],'GI' |
jne no_unpakcing_file |
;GIF DECODER |
sub edi,12 |
sub edi,8 |
call ReadGIF |
mov [save_flag],1 |
no_unpakcing_file: |
/programs/media/gifview/trunk/gif_lite.inc |
---|
1,40 → 1,67 |
; GIF LITE v2.0 by Willow |
; GIF LITE v3.0 by Willow |
; Written in pure assembler by Ivushkin Andrey aka Willow |
; Modified by Diamond |
; |
; This include file will contain functions to handle GIF image format |
; |
; Created: August 15, 2004 |
; Last changed: August 25, 2006 |
; Last changed: June 24, 2007 |
; Change COLOR_ORDER in your program |
; if colors are displayed improperly |
; Requires kglobals.inc (iglobal/uglobal macro) |
; (program must 'include "kglobals.inc"' and say 'IncludeUGlobal' |
; somewhere in uninitialized data area). |
if ~ (COLOR_ORDER in <MENUETOS,OTHER>) |
; Configuration: [changed from program which includes this file] |
; 1. The constant COLOR_ORDER: must be one of |
; PALETTE - for 8-bit image with palette (sysfunction 65) |
; MENUETOS - for MenuetOS and KolibriOS color order (sysfunction 7) |
; OTHER - for standard color order |
; 2. Define constant GIF_SUPPORT_INTERLACED if you want to support interlaced |
; GIFs. |
; 3. Single image mode vs multiple image mode: |
; if the program defines the variable 'gif_img_count' of type dword |
; somewhere, ReadGIF will enter multiple image mode: gif_img_count |
; will be initialized with image count, output format is GIF_list, |
; the function GetGIFinfo retrieves Nth image info. Otherwise, ReadGIF |
; uses single image mode: exit after end of first image, output is |
; <dd width,height, times width*height[*3] db image> |
if ~ (COLOR_ORDER in <PALETTE,MENUETOS,OTHER>) |
; This message may not appear under MenuetOS, so watch... |
display 'Please define COLOR_ORDER: MENUETOS or OTHER',13,10 |
display 'Please define COLOR_ORDER: PALETTE, MENUETOS or OTHER',13,10 |
end if |
if defined gif_img_count |
; virtual structure, used internally |
struc GIF_list |
{ |
.NextImg rd 1 |
.Left rw 1 |
.Top rw 1 |
.Width rw 1 |
.Height rw 1 |
} |
struct GIF_list |
NextImg rd 1 |
Left rw 1 |
Top rw 1 |
Width rw 1 |
Height rw 1 |
Delay rd 1 |
Displacement rd 1 ; 0 = not specified |
; 1 = do not dispose |
; 2 = restore to background color |
; 3 = restore to previous |
if COLOR_ORDER eq PALETTE |
Image rd 1 |
end if |
ends |
struc GIF_info |
{ |
.Left rw 1 |
.Top rw 1 |
.Width rw 1 |
.Height rw 1 |
} |
struct GIF_info |
Left rw 1 |
Top rw 1 |
Width rw 1 |
Height rw 1 |
Delay rd 1 |
Displacement rd 1 |
if COLOR_ORDER eq PALETTE |
Palette rd 1 |
end if |
ends |
_null fix 0x1000 |
; **************************************** |
; FUNCTION GetGIFinfo - retrieve Nth image info |
; **************************************** |
56,14 → 83,25 |
jz .error |
loop .lp |
.eloop: |
add esi,4 |
lodsd |
movsd |
movsd |
movsd |
movsd |
if COLOR_ORDER eq PALETTE |
lodsd |
mov [edi],esi |
else |
mov eax,esi |
end if |
.error: |
pop edi ecx esi |
ret |
end if |
_null fix 0x1000 |
; **************************************** |
; FUNCTION ReadGIF - unpacks GIF image |
; **************************************** |
70,7 → 108,6 |
; in: |
; esi - pointer to GIF file in memory |
; edi - pointer to output image list |
; eax - pointer to work area (MIN 16 KB!) |
; out: |
; eax - 0, all OK; |
77,24 → 114,25 |
; eax - 1, invalid signature; |
; eax >=8, unsupported image attributes |
; |
; ecx - number of images |
ReadGIF: |
push esi edi |
mov [.table_ptr],eax |
mov [.cur_info],edi |
xor eax,eax |
mov [.globalColor],eax |
mov [.img_count],eax |
if defined gif_img_count |
mov [gif_img_count],eax |
mov [.anim_delay],eax |
mov [.anim_disp],eax |
end if |
inc eax |
cmp dword[esi],'GIF8' |
jne .ex ; signature |
mov ecx,[esi+0xa] |
inc eax |
add esi,0xd |
mov edi,esi |
bt ecx,7 |
jnc .nextblock |
test cl,cl |
jns .nextblock |
mov [.globalColor],esi |
call .Gif_skipmap |
.nextblock: |
101,41 → 139,78 |
cmp byte[edi],0x21 |
jne .noextblock |
inc edi |
if defined gif_img_count |
cmp byte[edi],0xf9 ; Graphic Control Ext |
jne .no_gc |
movzx eax,word [edi+3] |
mov [.anim_delay],eax |
mov al,[edi+2] |
shr al,2 |
and eax,7 |
mov [.anim_disp],eax |
add edi,7 |
jmp .nextblock |
.no_gc: |
cmp byte[edi],0xfe ; Comment Ext |
jne .no_comm |
end if |
inc edi |
.block_skip: |
movzx eax,byte[edi] |
lea edi,[edi+eax+1] |
cmp byte[edi],0 |
test eax,eax |
jnz .block_skip |
inc edi |
jmp .nextblock |
.no_comm: |
cmp byte[edi],0xff ; Application Ext |
jne .nextblock |
add edi,13 |
jmp .block_skip |
.noextblock: |
mov al,8 |
cmp byte[edi],0x2c ; image beginning |
jne .ex |
inc [.img_count] |
if defined gif_img_count |
inc [gif_img_count] |
end if |
inc edi |
mov esi,[.cur_info] |
if defined gif_img_count |
add esi,4 |
end if |
xchg esi,edi |
if defined GIF_SUPPORT_INTERLACED |
movzx ecx,word[esi+4] |
mov [.width],ecx |
movzx eax,word[esi+6] |
imul eax,ecx |
if ~(COLOR_ORDER eq PALETTE) |
lea eax,[eax*3] |
end if |
mov [.img_end],eax |
inc eax |
mov [.row_end],eax |
and [.pass],0 |
test byte[esi+8],40h |
jz @f |
if ~(COLOR_ORDER eq PALETTE) |
lea ecx,[ecx*3] |
end if |
mov [.row_end],ecx |
@@: |
end if |
if defined gif_img_count |
movsd |
movsd |
mov eax,[.anim_delay] |
stosd |
mov eax,[.anim_disp] |
stosd |
else |
movzx eax,word[esi+4] |
stosd |
movzx eax,word[esi+6] |
stosd |
add esi,8 |
end if |
push edi |
movzx ecx,word[esi] |
mov ecx,[esi] |
inc esi |
bt ecx,7 |
jc .uselocal |
test cl,cl |
js .uselocal |
push [.globalColor] |
mov edi,esi |
jmp .setPal |
147,11 → 222,12 |
inc ecx |
mov [.codesize],ecx |
dec ecx |
if ~(COLOR_ORDER eq PALETTE) |
pop [.Palette] |
end if |
lea esi,[edi+1] |
mov edi,[.table_ptr] |
mov edi,.gif_workarea |
xor eax,eax |
cld |
lodsb ; eax - block_count |
add eax,esi |
mov [.block_ofs],eax |
159,16 → 235,40 |
mov eax,1 |
shl eax,cl |
mov [.CC],eax |
mov ecx,eax |
inc eax |
mov [.EOI],eax |
lea ecx,[eax-1] |
mov eax, _null shl 16 |
.filltable: |
stosd |
inc eax |
loop .filltable |
if COLOR_ORDER eq PALETTE |
pop eax |
pop edi |
push edi |
scasd |
push esi |
mov esi,eax |
mov ecx,[.CC] |
@@: |
lodsd |
dec esi |
bswap eax |
shr eax,8 |
stosd |
loop @b |
pop esi |
pop eax |
mov [eax],edi |
else |
pop edi |
end if |
if defined GIF_SUPPORT_INTERLACED |
mov [.img_start],edi |
add [.img_end],edi |
add [.row_end],edi |
end if |
.reinit: |
mov edx,[.EOI] |
inc edx |
189,10 → 289,7 |
je .end |
call .Gif_output |
.add: |
push eax |
mov eax,[.table_ptr] |
mov [eax+edx*4],ebx |
pop eax |
mov dword [.gif_workarea+edx*4],ebx |
cmp edx,0xFFF |
jae .cycle |
inc edx |
212,6 → 309,10 |
pop ebx eax |
jmp .add |
.end: |
if defined GIF_SUPPORT_INTERLACED |
mov edi,[.img_end] |
end if |
if defined gif_img_count |
mov eax,[.cur_info] |
mov [eax],edi |
mov [.cur_info],edi |
225,9 → 326,10 |
.continue: |
cmp byte[edi],0x3b |
jne .nextblock |
xchg esi,edi |
and dword [eax],0 |
end if |
xor eax,eax |
stosd |
mov ecx,[.img_count] |
.ex: |
pop edi esi |
ret |
281,7 → 383,7 |
.Gif_output: |
push esi eax edx |
mov edx,[.table_ptr] |
mov edx,.gif_workarea |
.next: |
push word[edx+eax*4] |
mov ax,word[edx+eax*4+2] |
293,6 → 395,9 |
.loop2: |
pop ax |
if COLOR_ORDER eq PALETTE |
stosb |
else |
lea esi,[eax+eax*2] |
add esi,[.Palette] |
303,23 → 408,78 |
mov [edi],esi |
add edi,3 |
else |
movsw |
movsb |
movsb |
movsb |
end if |
end if |
if defined GIF_SUPPORT_INTERLACED |
cmp edi,[.row_end] |
jb .norowend |
mov eax,[.width] |
if ~(COLOR_ORDER eq PALETTE) |
lea eax,[eax*3] |
end if |
push eax |
sub edi,eax |
add eax,eax |
cmp [.pass],3 |
jz @f |
add eax,eax |
cmp [.pass],2 |
jz @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 |
jz @f |
add edi,eax |
cmp [.pass],2 |
jz @f |
add edi,eax |
add edi,eax |
@@: |
.nextrow: |
add eax,edi |
mov [.row_end],eax |
xor eax,eax |
.norowend: |
end if |
loop .loop2 |
pop edx eax esi |
ret |
.globalColor rd 1 |
.img_count rd 1 |
.cur_info rd 1 ; image table pointer |
.img_start rd 1 |
.codesize rd 1 |
.compsize rd 1 |
.bit_count rd 1 |
.CC rd 1 |
.EOI rd 1 |
.Palette rd 1 |
.block_ofs rd 1 |
.table_ptr rd 1 |
uglobal |
align 4 |
ReadGIF.globalColor rd 1 |
ReadGIF.cur_info rd 1 ; image table pointer |
ReadGIF.codesize rd 1 |
ReadGIF.compsize rd 1 |
ReadGIF.bit_count rd 1 |
ReadGIF.CC rd 1 |
ReadGIF.EOI rd 1 |
if ~(COLOR_ORDER eq PALETTE) |
ReadGIF.Palette rd 1 |
end if |
ReadGIF.block_ofs rd 1 |
if defined GIF_SUPPORT_INTERLACED |
ReadGIF.row_end rd 1 |
ReadGIF.img_end rd 1 |
ReadGIF.img_start rd 1 |
ReadGIF.pass rd 1 |
ReadGIF.width rd 1 |
end if |
if defined gif_img_count |
ReadGIF.anim_delay rd 1 |
ReadGIF.anim_disp rd 1 |
end if |
ReadGIF.gif_workarea rb 16*1024 |
endg |
/programs/media/gifview/trunk/gifview.asm |
---|
23,19 → 23,16 |
dd 0x01 |
dd START |
dd I_END |
dd 0x300000 |
dd 0x27fff0 |
dd 0x400000 |
dd 0x400000 |
dd filename ;0x0 |
dd 0x0 |
include 'lang.inc' |
include '..\..\..\macros.inc' ; decrease code size (optional) |
include 'debug.inc' |
COLOR_ORDER equ MENUETOS |
DELAY equ 20 ; animation speed |
;include '/hd/1/gif/gif_lite.inc' |
COLOR_ORDER equ PALETTE |
GIF_SUPPORT_INTERLACED = 1 |
include 'gif_lite.inc' |
START: |
43,9 → 40,9 |
jne openfile2 |
; jmp openfile2 |
openfile: |
and [entered],0 |
xor eax,eax |
mov [imgcount],eax |
mov [entered], eax |
mov [gif_img_count],eax |
mov esi,fn_input |
mov edi,filename |
mov ecx,[inp_pos] |
52,8 → 49,8 |
rep movsb |
stosb |
openfile2: |
mov ebx,file_info |
mov eax,70 |
mov ebx,file_info |
mcall |
cmp eax,6 |
je temp |
63,9 → 60,8 |
; cmp ebx,64 |
; jbe ok2 |
and [entered],0 |
xor eax,eax |
mov [imgcount],eax |
mov [entered], eax |
mov esi,filename |
mov edi,fn_input |
mov ecx,256/4 ;[filename_len] |
73,12 → 69,9 |
mov edi,fn_input |
mov ecx,256 |
xor eax,eax |
repne scasb |
sub edi,fn_input |
dec edi |
mov [inp_pos],edi |
inc [inp_pos] |
; test eax,eax |
; jnz .ok2 |
86,36 → 79,67 |
; jbe .ok2 |
mov esi,workarea |
mov edi,Image |
mov eax,hashtable |
call ReadGIF |
test eax,eax |
jz .ok |
xor ecx,ecx |
and [gif_img_count], 0 |
.ok: |
mov [imgcount],ecx |
ok2: |
and dword[img_index],0 |
mov eax,48 |
mov ebx,3 |
mov ecx,sc |
mov edx,sizeof.system_colors |
mov eax,48 |
mcall |
red: |
call draw_window |
; ********************************************* |
; ******* ******* |
; ********************************************* |
draw_window: |
mov ebx,1 |
mov eax,12 |
mcall |
xor eax,eax |
mov ebx,50*65536+700 |
mov ecx,50*65536+500 |
mov edx,[sc.work] |
or edx,0x33000000 |
mov edi,title |
mcall |
call draw_input |
xor ecx,ecx |
call draw_subimage |
cmp [gif_img_count],1 |
jz @f |
mov ecx,[img_index] |
call draw_subimage |
@@: |
mov ebx,2 |
mov eax,12 |
mcall |
still: |
cmp [imgcount], 1 |
jnz .delay |
mov eax, 10 |
int 0x40 |
jmp @f |
.delay: |
mov ebx,DELAY |
cmp [gif_img_count], 1 |
jbe .infinite |
mov ebx, [cur_anim_delay] |
test ebx, ebx |
jz .infinite |
mov eax,23 |
mcall |
jmp @f |
.infinite: |
mov eax, 10 |
mcall |
@@: |
dec eax |
jz red |
123,7 → 147,7 |
jz key |
dec eax |
jz button |
mov eax,[imgcount] |
mov eax,[gif_img_count] |
cmp eax,1 |
je still |
inc [img_index] |
143,16 → 167,14 |
jmp still |
button: |
mov eax,17 |
mcall |
mcall 17 |
cmp ah,1 |
jnz wait_input |
cmp ah,1 |
jne noclose |
_close: |
or eax,-1 |
mcall |
noclose: |
is_input: ; simple input line with backspace feature |
inc [entered] ; sorry - no cursor |
wait_input: |
159,17 → 181,17 |
call draw_input |
mov eax,10 |
mcall |
cmp eax,2 |
cmp al,2 |
jne still |
mov edi,[inp_pos] |
mov eax,2 |
; mov eax,2 |
mcall |
shr eax,8 |
cmp eax,27 |
cmp al,27 |
je still |
cmp eax,13 |
cmp al,13 |
je openfile |
cmp eax,8 |
cmp al,8 |
je backsp |
mov [fn_input+edi],al |
inc [inp_pos] |
185,63 → 207,26 |
;******* DRAW CONTENTS OF INPUT LINE **** |
;**************************************** |
draw_input: |
push edi |
mov esi,0xe0e0e0 |
cmp [entered],0 |
jne highlight |
mov esi,0x00aabbcc |
jmp di_draw |
highlight: |
mov esi,0xe0e0e0 |
di_draw: |
mov eax,8 |
mov ebx,INP_X |
mov ecx,INP_Y |
mov edx,2 |
mov ebx,INP_X |
mov eax,8 |
mcall |
mov eax,4 |
mov ecx,0x00107a30 |
mov ebx,INP_XY |
mov edx,fn_input |
mov esi,[inp_pos] |
mov ebx,INP_XY |
mov eax,4 |
mcall |
pop edi |
ret |
; ********************************************* |
; ******* ******* |
; ********************************************* |
draw_window: |
mov eax,12 |
mov ebx,1 |
mcall |
mov eax,0 |
mov ebx,50*65536+700 |
mov ecx,50*65536+500 |
mov edx,[sc.work] |
or edx,0x33000000 |
mov edi,title |
mcall |
call draw_input |
xor ecx,ecx |
call draw_subimage |
cmp [imgcount],1 |
je .enddraw |
mov ecx,[img_index] |
call draw_subimage |
.enddraw: |
mov eax,12 |
mov ebx,2 |
mcall |
ret |
draw_subimage: |
cmp [imgcount],0 |
cmp [gif_img_count],0 |
jz .enddraw |
mov esi,Image |
mov edi,gif_inf |
248,17 → 233,18 |
call GetGIFinfo |
test eax,eax |
jz .enddraw |
movzx ebx,[gif_inf.Width] |
shl ebx,16 |
movzx ecx,[gif_inf.Height] |
add ecx,ebx |
mov ecx, dword [edi+GIF_info.Width-2] |
mov cx, [edi+GIF_info.Height] |
mov ebx,eax |
movzx eax,[gif_inf.Top] |
movzx edx,[gif_inf.Left] |
shl edx,16 |
add edx,eax |
mov eax, [edi+GIF_info.Delay] |
mov [cur_anim_delay],eax |
mov edx, dword [edi+GIF_info.Left-2] |
mov dx, [edi+GIF_info.Top] |
add edx,5 shl 16 +25 |
mov eax,7 |
mov esi, 8 |
mov edi, [edi+GIF_info.Palette] |
xor ebp, ebp |
mov eax, 65 |
mcall |
.enddraw: |
ret |
291,14 → 277,17 |
; db '/hd/1/gif/meos.gif',0 |
rb 257 |
;filename_len dd 0 |
entered rd 1 |
sc system_colors |
imgcount rd 1 |
gif_img_count rd 1 |
cur_anim_delay rd 1 |
img_index rd 1 |
gif_inf GIF_info |
hashtable rd 4096 |
IncludeUGlobals |
workarea rb 0x100000 |
Image: |
/programs/media/midamp/trunk/MIDAMP.ASM |
---|
83,15 → 83,12 |
mcall 40,1000111b |
mov esi,btns |
mov edi,btn_raw |
mov eax,hash_table |
call ReadGIF |
mov esi,hdrimg |
mov edi,hdr_raw |
mov eax,hash_table |
call ReadGIF |
mov esi,bottom |
mov edi,bottom_raw |
mov eax,hash_table |
call ReadGIF |
call respawn |
mcall 9,prcinfo,-1 |
385,12 → 382,11 |
ipcmsg db ? |
fnbuf: |
rb 1024 |
btn_raw rb 222*17*3+12 |
hdr_raw rb 275*29*3+12 |
bottom_raw rb 25*378*3+12 |
btn_raw rb 222*17*3+8 |
hdr_raw rb 275*29*3+8 |
bottom_raw rb 25*378*3+8 |
rb 4 |
playlist rb 256*LISTITEMS |
hash_table: |
rd 4096 |
IncludeUGlobals |
dir_table rb 32+304 |
workarea: |
/programs/media/midamp/trunk/draw.inc |
---|
49,7 → 49,7 |
xor eax,eax |
mov ebx,100*65536+275 |
mov ecx,200*65536+WND_HEIGHT |
mov edi,hdr_raw+12 |
mov edi,hdr_raw+8 |
mov ebp,[coo] |
test [flag],FL_HIDDEN |
jz .nohide1 |
126,7 → 126,7 |
test [flag],FL_HIDDEN |
jnz .nohide2 |
mov eax,7 |
mov ebx,btn_raw+12 |
mov ebx,btn_raw+8 |
mov ecx,BTNS_SIZE |
mov edx,BTNS_XY |
mcall |
254,7 → 254,7 |
mov ecx,5 |
mov esi,bot_btn |
push esi |
mov ebx,bottom_raw+12 |
mov ebx,bottom_raw+8 |
xor eax,eax |
.nxt: |
push ecx |
323,7 → 323,7 |
push edx |
.noadj3: |
imul ebx,eax,BOTT_S |
add ebx,bottom_raw+12 |
add ebx,bottom_raw+8 |
push ecx |
.nxt: |
push ecx |
/programs/media/midamp/trunk/gif_lite.inc |
---|
1,40 → 1,67 |
; GIF LITE v2.0 by Willow |
; GIF LITE v3.0 by Willow |
; Written in pure assembler by Ivushkin Andrey aka Willow |
; Modified by Diamond |
; |
; This include file will contain functions to handle GIF image format |
; |
; Created: August 15, 2004 |
; Last changed: September 9, 2004 |
; Last changed: June 24, 2007 |
; Change COLOR_ORDER in your program |
; if colors are displayed improperly |
; Requires kglobals.inc (iglobal/uglobal macro) |
; (program must 'include "kglobals.inc"' and say 'IncludeUGlobal' |
; somewhere in uninitialized data area). |
if ~ (COLOR_ORDER in <MENUETOS,OTHER>) |
; Configuration: [changed from program which includes this file] |
; 1. The constant COLOR_ORDER: must be one of |
; PALETTE - for 8-bit image with palette (sysfunction 65) |
; MENUETOS - for MenuetOS and KolibriOS color order (sysfunction 7) |
; OTHER - for standard color order |
; 2. Define constant GIF_SUPPORT_INTERLACED if you want to support interlaced |
; GIFs. |
; 3. Single image mode vs multiple image mode: |
; if the program defines the variable 'gif_img_count' of type dword |
; somewhere, ReadGIF will enter multiple image mode: gif_img_count |
; will be initialized with image count, output format is GIF_list, |
; the function GetGIFinfo retrieves Nth image info. Otherwise, ReadGIF |
; uses single image mode: exit after end of first image, output is |
; <dd width,height, times width*height[*3] db image> |
if ~ (COLOR_ORDER in <PALETTE,MENUETOS,OTHER>) |
; This message may not appear under MenuetOS, so watch... |
display 'Please define COLOR_ORDER: MENUETOS or OTHER',13,10 |
display 'Please define COLOR_ORDER: PALETTE, MENUETOS or OTHER',13,10 |
end if |
if defined gif_img_count |
; virtual structure, used internally |
struc GIF_list |
{ |
.NextImg rd 1 |
.Left rw 1 |
.Top rw 1 |
.Width rw 1 |
.Height rw 1 |
} |
struct GIF_list |
NextImg rd 1 |
Left rw 1 |
Top rw 1 |
Width rw 1 |
Height rw 1 |
Delay rd 1 |
Displacement rd 1 ; 0 = not specified |
; 1 = do not dispose |
; 2 = restore to background color |
; 3 = restore to previous |
if COLOR_ORDER eq PALETTE |
Image rd 1 |
end if |
ends |
struc GIF_info |
{ |
.Left rw 1 |
.Top rw 1 |
.Width rw 1 |
.Height rw 1 |
} |
struct GIF_info |
Left rw 1 |
Top rw 1 |
Width rw 1 |
Height rw 1 |
Delay rd 1 |
Displacement rd 1 |
if COLOR_ORDER eq PALETTE |
Palette rd 1 |
end if |
ends |
_null fix 0x1000 |
; **************************************** |
; FUNCTION GetGIFinfo - retrieve Nth image info |
; **************************************** |
56,14 → 83,25 |
jz .error |
loop .lp |
.eloop: |
add esi,4 |
lodsd |
movsd |
movsd |
movsd |
movsd |
if COLOR_ORDER eq PALETTE |
lodsd |
mov [edi],esi |
else |
mov eax,esi |
end if |
.error: |
pop edi ecx esi |
ret |
end if |
_null fix 0x1000 |
; **************************************** |
; FUNCTION ReadGIF - unpacks GIF image |
; **************************************** |
70,7 → 108,6 |
; in: |
; esi - pointer to GIF file in memory |
; edi - pointer to output image list |
; eax - pointer to work area (MIN 16 KB!) |
; out: |
; eax - 0, all OK; |
77,24 → 114,25 |
; eax - 1, invalid signature; |
; eax >=8, unsupported image attributes |
; |
; ecx - number of images |
ReadGIF: |
push esi edi |
mov [.table_ptr],eax |
mov [.cur_info],edi |
xor eax,eax |
mov [.globalColor],eax |
mov [.img_count],eax |
if defined gif_img_count |
mov [gif_img_count],eax |
mov [.anim_delay],eax |
mov [.anim_disp],eax |
end if |
inc eax |
cmp dword[esi],'GIF8' |
jne .ex ; signature |
mov ecx,[esi+0xa] |
inc eax |
add esi,0xd |
mov edi,esi |
bt ecx,7 |
jnc .nextblock |
test cl,cl |
jns .nextblock |
mov [.globalColor],esi |
call .Gif_skipmap |
.nextblock: |
101,41 → 139,78 |
cmp byte[edi],0x21 |
jne .noextblock |
inc edi |
if defined gif_img_count |
cmp byte[edi],0xf9 ; Graphic Control Ext |
jne .no_gc |
movzx eax,word [edi+3] |
mov [.anim_delay],eax |
mov al,[edi+2] |
shr al,2 |
and eax,7 |
mov [.anim_disp],eax |
add edi,7 |
jmp .nextblock |
.no_gc: |
cmp byte[edi],0xfe ; Comment Ext |
jne .no_comm |
end if |
inc edi |
.block_skip: |
movzx eax,byte[edi] |
lea edi,[edi+eax+1] |
cmp byte[edi],0 |
test eax,eax |
jnz .block_skip |
inc edi |
jmp .nextblock |
.no_comm: |
cmp byte[edi],0xff ; Application Ext |
jne .nextblock |
add edi,13 |
jmp .block_skip |
.noextblock: |
mov al,8 |
cmp byte[edi],0x2c ; image beginning |
jne .ex |
inc [.img_count] |
if defined gif_img_count |
inc [gif_img_count] |
end if |
inc edi |
mov esi,[.cur_info] |
if defined gif_img_count |
add esi,4 |
end if |
xchg esi,edi |
if defined GIF_SUPPORT_INTERLACED |
movzx ecx,word[esi+4] |
mov [.width],ecx |
movzx eax,word[esi+6] |
imul eax,ecx |
if ~(COLOR_ORDER eq PALETTE) |
lea eax,[eax*3] |
end if |
mov [.img_end],eax |
inc eax |
mov [.row_end],eax |
and [.pass],0 |
test byte[esi+8],40h |
jz @f |
if ~(COLOR_ORDER eq PALETTE) |
lea ecx,[ecx*3] |
end if |
mov [.row_end],ecx |
@@: |
end if |
if defined gif_img_count |
movsd |
movsd |
mov eax,[.anim_delay] |
stosd |
mov eax,[.anim_disp] |
stosd |
else |
movzx eax,word[esi+4] |
stosd |
movzx eax,word[esi+6] |
stosd |
add esi,8 |
end if |
push edi |
movzx ecx,word[esi] |
mov ecx,[esi] |
inc esi |
bt ecx,7 |
jc .uselocal |
test cl,cl |
js .uselocal |
push [.globalColor] |
mov edi,esi |
jmp .setPal |
147,11 → 222,12 |
inc ecx |
mov [.codesize],ecx |
dec ecx |
if ~(COLOR_ORDER eq PALETTE) |
pop [.Palette] |
end if |
lea esi,[edi+1] |
mov edi,[.table_ptr] |
mov edi,.gif_workarea |
xor eax,eax |
cld |
lodsb ; eax - block_count |
add eax,esi |
mov [.block_ofs],eax |
159,16 → 235,40 |
mov eax,1 |
shl eax,cl |
mov [.CC],eax |
mov ecx,eax |
inc eax |
mov [.EOI],eax |
lea ecx,[eax-1] |
mov eax, _null shl 16 |
.filltable: |
stosd |
inc eax |
loop .filltable |
if COLOR_ORDER eq PALETTE |
pop eax |
pop edi |
push edi |
scasd |
push esi |
mov esi,eax |
mov ecx,[.CC] |
@@: |
lodsd |
dec esi |
bswap eax |
shr eax,8 |
stosd |
loop @b |
pop esi |
pop eax |
mov [eax],edi |
else |
pop edi |
end if |
if defined GIF_SUPPORT_INTERLACED |
mov [.img_start],edi |
add [.img_end],edi |
add [.row_end],edi |
end if |
.reinit: |
mov edx,[.EOI] |
inc edx |
189,10 → 289,7 |
je .end |
call .Gif_output |
.add: |
push eax |
mov eax,[.table_ptr] |
mov [eax+edx*4],ebx |
pop eax |
mov dword [.gif_workarea+edx*4],ebx |
cmp edx,0xFFF |
jae .cycle |
inc edx |
212,6 → 309,10 |
pop ebx eax |
jmp .add |
.end: |
if defined GIF_SUPPORT_INTERLACED |
mov edi,[.img_end] |
end if |
if defined gif_img_count |
mov eax,[.cur_info] |
mov [eax],edi |
mov [.cur_info],edi |
225,8 → 326,10 |
.continue: |
cmp byte[edi],0x3b |
jne .nextblock |
xchg esi,edi |
and dword [eax],0 |
end if |
xor eax,eax |
mov ecx,[.img_count] |
.ex: |
pop edi esi |
ret |
280,7 → 383,7 |
.Gif_output: |
push esi eax edx |
mov edx,[.table_ptr] |
mov edx,.gif_workarea |
.next: |
push word[edx+eax*4] |
mov ax,word[edx+eax*4+2] |
292,6 → 395,9 |
.loop2: |
pop ax |
if COLOR_ORDER eq PALETTE |
stosb |
else |
lea esi,[eax+eax*2] |
add esi,[.Palette] |
302,23 → 408,78 |
mov [edi],esi |
add edi,3 |
else |
movsw |
movsb |
movsb |
movsb |
end if |
end if |
if defined GIF_SUPPORT_INTERLACED |
cmp edi,[.row_end] |
jb .norowend |
mov eax,[.width] |
if ~(COLOR_ORDER eq PALETTE) |
lea eax,[eax*3] |
end if |
push eax |
sub edi,eax |
add eax,eax |
cmp [.pass],3 |
jz @f |
add eax,eax |
cmp [.pass],2 |
jz @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 |
jz @f |
add edi,eax |
cmp [.pass],2 |
jz @f |
add edi,eax |
add edi,eax |
@@: |
.nextrow: |
add eax,edi |
mov [.row_end],eax |
xor eax,eax |
.norowend: |
end if |
loop .loop2 |
pop edx eax esi |
ret |
.globalColor rd 1 |
.img_count rd 1 |
.cur_info rd 1 ; image table pointer |
.img_start rd 1 |
.codesize rd 1 |
.compsize rd 1 |
.bit_count rd 1 |
.CC rd 1 |
.EOI rd 1 |
.Palette rd 1 |
.block_ofs rd 1 |
.table_ptr rd 1 |
uglobal |
align 4 |
ReadGIF.globalColor rd 1 |
ReadGIF.cur_info rd 1 ; image table pointer |
ReadGIF.codesize rd 1 |
ReadGIF.compsize rd 1 |
ReadGIF.bit_count rd 1 |
ReadGIF.CC rd 1 |
ReadGIF.EOI rd 1 |
if ~(COLOR_ORDER eq PALETTE) |
ReadGIF.Palette rd 1 |
end if |
ReadGIF.block_ofs rd 1 |
if defined GIF_SUPPORT_INTERLACED |
ReadGIF.row_end rd 1 |
ReadGIF.img_end rd 1 |
ReadGIF.img_start rd 1 |
ReadGIF.pass rd 1 |
ReadGIF.width rd 1 |
end if |
if defined gif_img_count |
ReadGIF.anim_delay rd 1 |
ReadGIF.anim_disp rd 1 |
end if |
ReadGIF.gif_workarea rb 16*1024 |
endg |
/programs/media/midamp/trunk/playlist.inc |
---|
75,7 → 75,7 |
test [flag],FL_BOTTRED |
jz .nobott |
pusha |
mcall 7,hdr_raw+12+275*16*3,<275,12>,<10,(WND_HEIGHT-20)> |
mcall 7,hdr_raw+8+275*16*3,<275,12>,<10,(WND_HEIGHT-20)> |
mov ebp,main_coo2 |
mov esi,10 shl 16 |
mov edi,(WND_HEIGHT-22)shl 16 |