Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 2474 → Rev 2475

/programs/system/icon/trunk/icon.asm
5,12 → 5,36
;* Compile with flat assembler *
;* *
;********************************
; 22.02.05 was modified for work with new multi-thread ICON.
; 8.03.07 ïåðåõîä íà 70 ôóíêöèþ by SPraid
;---------------------------------------------------------------------
; version: 2.1
; last update: 17/03/2012
; changed by: Marat Zakiyanov aka Mario79, aka Mario
; changes: Global optimization! The program uses
; only 161 KB of memory instead of 603 kb is now.
;---------------------------------------------------------------------
; version: 2.02
; last update: 15/03/2012
; changed by: Marat Zakiyanov aka Mario79, aka Mario
; changes: some optimisations and code refactoring
;---------------------------------------------------------------------
; version: 2.01
; last update: 27/09/2011
; changed by: Marat Zakiyanov aka Mario79, aka Mario
; changes: deactivate the window after click
; (working to kernel r.2244 and above)
;---------------------------------------------------------------------
; Many fix's and changes created by:
; Halyavin, Diamond, Heavyiron,
; SPraid, Dunkaist
;---------------------------------------------------------------------
; version: 2.00
; last update: 22|02|2005
; changed by: Willow and Mario79
; changes: modified for work with new multi-thread ICON.
;******************************************************************************
RAW_SIZE equ 350000
ICON_SIZE equ 32*32*3
GIF_SIZE equ 45000
RAW_SIZE equ ICON_SIZE*32 ;350000
GIF_SIZE equ 12*1024 ;45000
REC_SIZE equ 80
ICONS_DAT equ '/sys/ICONS.DAT'
ICON_APP equ '/sys/ICON'
21,10 → 45,11
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd icon_data+0x30000 ; memory for app
dd IM_END ; size of image
dd I_END ; memory for app
dd stack_area ; esp
dd I_Param , 0x0 ; I_Param , I_Icon
dd I_Param ; boot parameters
dd 0x0 ; path
;------------------------------------------------------------------------------
include '../../../macros.inc'
include 'lang.inc'
64,7 → 89,7
jz key
;------------------------------------------------------------------------------
align 4
button: ; button
button:
mcall 17 ; get id
shr eax,8
 
162,7 → 187,7
mcall 70
; (2) terminate all icons
or ecx,-1
mcall 9,I_END
mcall 9,process_table
mov edi,[ebx+30]
;--------------------------------------
align 4
173,14 → 198,14
newread:
inc esi
mov ecx,esi
mcall 9,I_END
mcall 9,process_table
cmp edi,[ebx+30]
je newread
 
cmp esi,eax
jg all_terminated
jg apply_changes
 
mov eax,[ebx+10] ;[I_END+10]
mov eax,[ebx+10]
and eax,not 20202020h
cmp eax,'@ICO'
jz @f
190,10 → 215,10
align 4
@@:
mov eax,51
cmp eax,[ebx+42] ;[I_END+42]
cmp eax,[ebx+42]
jne newread
 
cmp eax,[ebx+46] ;[I_END+46]
cmp eax,[ebx+46]
jne newread
 
mov ecx,esi
222,8 → 247,7
rb 31-($-.path)
;------------------------------------------------------------------------------
align 4
all_terminated:
;apply_changes:
apply_changes:
mov ebx, finfo_start
mov dword [ebx+8], boot_str+6
mov esi, iconname
253,7 → 277,6
xor edx,edx ; bcd -> 10
mov ebx,16
div ebx
; imul eax,10
; multiply x10
shl eax,1 ; multiply x2
lea eax,[eax+eax*4] ; multiply x5
309,13 → 332,12
mcall 17
shr eax,8
cmp eax,40
jb red;no_f;ound
jb red
sub eax,40
xor edx,edx
mov ebx,16
div ebx
; imul eax,10
; multiply x10
shl eax,1 ; multiply x2
lea eax,[eax+eax*4] ; multiply x5
569,7 → 591,7
ret
;------------------------------------------------------------------------------
align 4
key: ; key
key:
mcall 2 ; just read it and ignore
jmp still
;------------------------------------------------------------------------------
910,7 → 932,7
apply_changes2:
mov edi,[icons]
mov esi,icon_data
mov ebp,0x5000 ; threads stack starting point
mov ebp,thread_stack+0x100 ;0x5000 ; threads stack starting point
;--------------------------------------
align 4
start_new:
923,12 → 945,13
mcall 51,1,thread
add ebp,0x100
 
mov eax,5
; change to next thread if mutex is blocked
mov eax,68
mov ebx,1
;--------------------------------------
align 4
wait_thread_start: ;wait until thread draw itself first time
cmp [create_thread_event],bl
cmp [create_thread_event],bl ;mutex
jz wait_thread_end
mcall
jmp wait_thread_start
945,12 → 968,20
or eax,-1
mcall
;------------------------------------------------------------------------------
; esp-28 = start of thread stack
; esp-24 = ???
; esp-20 = 'AA-F' or...
; esp-16 = ??? SHL greedy maniac mode on!
; esp-12 = ebp+0 = X
; esp-8 = ebp+4 = Y
; esp-4 = ebp+8 = adress of icon_data
;------------------------------------------------------------------------------
align 4
thread:
; pop ebp ;ebp - address of our icon
sub esp,12
mov ebp,esp
sub esp,16
call shape_window
call draw_window2
mov [create_thread_event],1
mcall 40,010101b
965,9 → 996,7
je button2
call get_bg_info
mov eax,5
mov ebx,1
call draw_icon2
call draw_icon2_1
jmp still2
;------------------------------------------------------------------------------
982,11 → 1011,11
add ebp,+12
call calc_icon_pos
add ebp,-12
mcall 9,I_END,-1
mov eax,[I_END+process_information.box.left]
mcall 9,process_table,-1
mov eax,[process_table+process_information.box.left]
cmp eax,[ebp+0]
jne @f
mov eax,[I_END+process_information.box.top]
mov eax,[process_table+process_information.box.top]
cmp eax,[ebp+4]
je .lp1
;--------------------------------------
1006,7 → 1035,7
cmp ah, 2
jnz still2
 
mcall 9,I_END,-1
mcall 9,process_table,-1
mov ecx,[ebx+30] ; PID
mcall 18,21
mov edx,eax ; SLOT
1114,7 → 1143,8
;------------------------------------------------------------------------------
align 4
draw_picture:
mov [image],0x3000
mov [image],image_area
 
mov edi,[ebp+8]
lea esi,[edi+12]
call atoi
1127,7 → 1157,7
lea edi,[eax+strip_file+8]
xor ebx,ebx
xor ecx,ecx
mov esi,edi;strip_file+8+(32*3*32)*2
mov esi,edi
 
mov [pixpos],0
;--------------------------------------
1148,8 → 1178,6
mov esi,edi
add esi,[pixpos]
;--------------------------------------
align 4
no_correction_pixpos:
add [pixpos],3
mov eax,[esi]
and eax,0xffffff
1218,21 → 1246,26
 
mov edx,eax
mov eax,[image]
mov [eax],edx
 
mov [eax],dl
inc eax
ror edx,8
mov [eax],dl
inc eax
ror edx,8
mov [eax],dl
inc eax
mov [image],eax
inc ebx
mov eax,[yw]
inc eax
cmp ebx,eax
jnz newb
jb newb
xor ebx,ebx
 
inc ecx
1253,7 → 1286,7
align 4
toponly:
xor edx,edx
mcall 7,0x3000,<52,52>
mcall 7,image_area,<52,52>
;--------------------------------------
align 4
.ex:
1266,9 → 1299,6
add esi,3
push edi
mov edi,title
; mov ecx,8
; cld
; rep movsb
mov ecx,8/4
cld
rep movsd
1339,19 → 1369,22
xor eax,eax ; function 0 : define and draw window
mov ebx,[ebp+0-2]
mov ecx,[ebp+4-2]
add ebx,[yw] ; [x start] *65536 + [x size]
add ecx,51 ; [y start] *65536 + [y size]
mov bx,[yw] ; [x start] *65536 + [x size]
mov cx,51 ; [y start] *65536 + [y size]
mov edx,0x41000000 ; color of work area RRGGBB,8->color gl
mcall
mcall 8,51,50,0x40000002 ; button
mov eax,5
;--------------------------------------
align 4
draw_icon2_1:
; change to next thread if mutex is blocked
mov eax,68
mov ebx,1
;--------------------------------------
align 4
draw_icon2:
xchg [load_pic],bl
xchg [load_pic],bl ;mutex
test bl,bl
je draw_icon_end
mcall
1359,12 → 1392,13
;--------------------------------------
align 4
draw_icon_end:
mov eax,5
; change to next thread if mutex is blocked
mov eax,68
mov ebx,1
;--------------------------------------
align 4
draw_icon_2:
xchg [draw_pic],bl
xchg [draw_pic],bl ;mutex
test bl,bl
je draw_icon_end_2
mcall
1372,14 → 1406,81
;--------------------------------------
align 4
draw_icon_end_2:
mcall 9,process_table,-1
call draw_picture
call draw_text
mcall 12,2
ret
;------------------------------------------------------------------------------
shape_window:
; give the shape reference area
mcall 50,0,shape_reference
; give the shape scale 32 x 32 -> 128 x 128 ecx = 2
; you dont have to give this, scale is 1:1 by default
; mcall 50,1,2
ret
;------------------------------------------------------------------------------
shape_reference: ; 32 x 32 ( window_size_X + 1 ) * ( window_size_Y + 1 )
 
db 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1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,0,0,0,0,0,0,0,0,0,0,0,0,0
 
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;------------------------------------------------------------------------------
tl dd 8
yw dd 51
yw: dd 51
ya dd 0
cur_btn dd 40
 
1387,19 → 1488,16
load_pic db 0
create_thread_event db 0
 
image dd 0x3000
image dd image_area
 
I_Param:
icon_data = I_END+0x1400
stack_area = I_END+0x3400-4
process_table = I_END+0x3400
IncludeUGlobals
;------------------------------------------------------------------------------
IM_END:
;------------------------------------------------------------------------------
align 4
bgrx dd ?
bgry dd ?
param_str rb 31
 
;//////////////////////////
 
bgrxy dd ?
warea:
.by_x:
1419,10 → 1517,42
cur_band dd ?
sel_icon1 rd 1
icon_count rd 1
;------------------------------------------------------------------------------
align 4
param_str rb 31
;------------------------------------------------------------------------------
align 4
gif_file rb GIF_SIZE
;------------------------------------------------------------------------------
align 4
strip_file rb RAW_SIZE
 
IncludeUGlobals
 
;------------------------------------------------------------------------------
align 4
process_table:
rb 0x400
;------------------------------------------------------------------------------
align 4
icon_data:
rb 0x1000
;------------------------------------------------------------------------------
align 4
rb 0x1000
stack_area:
;------------------------------------------------------------------------------
align 4
I_Param:
rb 0x100 ; max 256
;------------------------------------------------------------------------------
align 4
thread_stack:
rb 0x100*48 ; max 48 icons
;------------------------------------------------------------------------------
align 4
image_area:
rb 52*52*3
;------------------------------------------------------------------------------
;align 4
;shape_reference_0:
; rb 52*52 ; ( window_size_X + 1 ) * ( window_size_Y + 1 )
;------------------------------------------------------------------------------
I_END:
;------------------------------------------------------------------------------