Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 30 → Rev 31

/programs/icon/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm icon.asm icon
@pause
/programs/icon/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm icon.asm icon
@pause
/programs/icon/trunk/icon.asm
0,0 → 1,534
;
; ICON APPLICATION
;
; Compile with FASM for Menuet
;
; 22.02.05 Mario79
; 1) multi-threading
; 2)dinamic load BMP files
; 3)type on desktop with function 7
; 4)Image in memory only 8000h (32Kb) for all 48 icons.
; Old version ICON 5000h*48(decimal)=960Kb.
;
 
use32
 
org 0x0
 
db 'MENUET01'
dd 0x01
dd START
dd I_END
dd 0x8000
dd 0x8000
dd I_Param , 0x0
 
include 'lang.inc'
include 'macros.inc'
 
get_bg_info:
mov eax,39
mov ebx,4
int 0x40
mov [bgrdrawtype],eax
 
mov eax,39 ; get background size
mov ebx,1
int 0x40
mov [bgrxy],eax
 
mov ebx,eax
shr eax,16
and ebx,0xffff
mov [bgrx],eax
mov [bgry],ebx
ret
 
START:
load_icon_list:
mov eax,6
mov ebx,icon_lst
xor ecx,ecx
mov edx,-1
mov esi,icon_data
int 0x40
 
add eax,10
xor edx,edx
mov ebx,52
div ebx
mov [icons],eax
 
call get_bg_info
 
mov eax,14
int 0x40
add eax,0x00010001
mov [scrxy],eax
 
apply_changes:
 
mov edi,[icons]
mov esi,icon_data
mov ebp,0x5000 ; threads stack starting point
 
start_new:
movzx eax,byte [esi] ; x position
sub eax,'A' ;eax - number of letter
cmp eax,4
jg no_left
shl eax,6 ;imul eax,64
add eax,24
jmp x_done
no_left:
sub eax,9
shl eax,6 ;imul eax,64
sub eax,24+32-1
movzx ebx,word [scrxy+2]
add eax,ebx
x_done:
; mov [xpos],eax
mov [ebp-12],eax
 
movzx eax,byte [esi+1] ; y position
sub eax,'A' ; eax - number of letter
cmp eax,4
jg no_up
lea eax,[eax+4*eax]
shl eax,4 ;imul eax,80
add eax,34
jmp y_done
no_up:
sub eax,9
lea eax,[eax+4*eax]
shl eax,4 ;imul eax,80
movzx ebx,word [scrxy]
sub eax,32-1
add eax,ebx
y_done:
; mov [ypos],eax
mov [ebp-8],eax
 
mov eax,51
mov ebx,1
mov ecx,thread
; mov edx,[thread_stack]
mov edx,ebp
; sub edx,4
; mov [edx],esi
mov [ebp-4],esi
int 0x40
; add [thread_stack],0x100
add ebp,0x100
 
mov eax,5
mov ebx,1
wait_thread_start: ;wait until thread draw itself first time
cmp [create_thread_event],bl
jz wait_thread_end
int 0x40
jmp wait_thread_start
wait_thread_end:
dec [create_thread_event] ;reset event
 
 
add esi,50+2
dec edi
jnz start_new
or eax,-1
int 0x40
 
thread:
; pop ebp ;ebp - address of our icon
sub esp,12
mov ebp,esp
call draw_window
mov [create_thread_event],1
mov eax,40
mov ebx,010101b
int 0x40
jmp still
red:
call draw_window
 
still:
 
mov eax,10
int 0x40
 
cmp eax,1
je red
cmp eax,3
je button
cmp eax,5
jne still
 
call get_bg_info
mov eax,5
mov ebx,1
call draw_icon
 
jmp still
 
key:
mov eax,2
int 0x40
 
jmp still
 
button:
mov eax,17
int 0x40
 
; mcall 55,eax, , ,klick_music
 
mov ebx,[ebp+8]
add ebx,19
; lea ebx,[ebp+19]
mov eax,19
xor ecx,ecx
int 0x40
mcall 55,eax, , ,klick_music
jmp still
 
klick_music db 0x85,0x60,0x85,0x70,0x85,0x65,0
 
draw_picture:
mov [image],0x3000
xor ebx,ebx
xor ecx,ecx
mov esi,data_from_file+54+32*3*33-96
mov [pixpos],0
mov [pixpos2],32
newb:
push ebx
push ecx
 
cmp ebx,10
jb yesbpix
cmp ebx,42
jge yesbpix
cmp ecx,32
jg yesbpix
 
push esi
mov esi,data_from_file+54+32*3*33-96
sub esi,[pixpos]
 
dec [pixpos2]
cmp [pixpos2],0
jne no_correction_pixpos
add [pixpos],192
mov [pixpos2],32
no_correction_pixpos:
sub [pixpos],3
mov eax,[esi]
and eax,0xffffff
 
pop esi
 
cmp eax,0
je yesbpix
cmp eax,0xf5f5f5
je yesbpix
jmp nobpix
 
yesbpix:
 
stretch:
cmp [bgrdrawtype],dword 2
jne nostretch
; mov eax,[ypos]
mov eax,[ebp+4]
add eax,ecx
imul eax,[bgry]
cdq
movzx ebx,word [scrxy]
div ebx
imul eax,[bgrx]
push eax
; mov eax,[xpos]
mov eax,[ebp+0]
add eax,[esp+8]
imul eax,[bgrx]
cdq
movzx ebx,word [scrxy+2]
div ebx
add eax,[esp]
add esp,4
 
jmp notiled
 
nostretch:
 
cmp [bgrdrawtype],dword 1
jne notiled
; mov eax,[ypos]
mov eax,[ebp+4]
add eax,ecx
cdq
movzx ebx,word [bgrxy]
div ebx
mov eax,edx
imul eax,[bgrx]
push eax
; mov eax,[xpos]
mov eax,[ebp+0]
add eax,[esp+8]
movzx ebx,word [bgrxy+2]
cdq
div ebx
mov eax,edx
add eax,[esp]
add esp,4
 
notiled:
 
lea ecx,[eax+eax*2]
mov eax,39
mov ebx,2
int 0x40
 
nobpix:
 
pop ecx
pop ebx
 
mov edx,eax
mov eax,[image]
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
xor ebx,ebx
 
inc ecx
 
mov eax,[ya]
add [pixpos],eax
 
cmp [top],1
jne notop
cmp ecx,38
je toponly
 
notop:
 
cmp ecx,52
jnz newb
 
toponly:
 
mov eax,7
mov ebx,0x3000
mov ecx,52 shl 16 + 52
xor edx,edx
int 0x40
mov [load_pic],0
ret
 
draw_text:
 
mov esi,[ebp+8]
add esi,33
; lea esi,[ebp+33]
push edi
mov edi,labelt
mov ecx,8
cld
rep movsb
pop edi
mov eax,labelt
news:
cmp [eax],byte 33
jb founde
inc eax
cmp eax,labelt+11
jb news
founde:
sub eax,labelt
mov [tl],eax
 
mov eax,[tl]
lea eax,[eax+eax*2] ; eax *= char_width/2
shl eax,16
 
mov ebx,27*65536+42
sub ebx,eax
 
mov eax,4
xor ecx,ecx ; black shade of text
mov edx,labelt
mov esi,[tl]
add ebx,1 shl 16 ;*65536+1
int 0x40
inc ebx
int 0x40
add ebx,1 shl 16
int 0x40
inc ebx
int 0x40
sub ebx,1 shl 16
int 0x40
dec ebx
sub ebx,1 shl 16
int 0x40
sub ebx,1 shl 16
dec ebx
int 0x40
dec ebx
add ebx,1 shl 16
int 0x40
inc ebx
mov ecx,0xffffff
 
int 0x40
mov [draw_pic],0
ret
 
load_icon_file:
mov ebx,[ebp+8]
add ebx,5
; lea ebx,[ebp+5]
 
mov eax,6
xor ecx,ecx
mov edx,-1
mov esi,data_from_file
int 0x40
 
ret
 
; for y = 32 to 0
; for x = 0 to 32
; if (pix[y][x]==0) then
; pix[y][x]=background(x,y);
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window:
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
 
; DRAW WINDOW
xor eax,eax ; function 0 : define and draw window
; mov ebx,[xpos-2]
mov ebx,[ebp+0-2]
; mov ecx,[ypos-2]
mov ecx,[ebp+4-2]
add ebx,[yw] ; [x start] *65536 + [x size]
add ecx,51 ; [y start] *65536 + [y size]
mov edx,0x01000000 ; color of work area RRGGBB,8->color gl
int 0x40
 
mov eax,8 ; button
mov ebx,51
mov ecx,50
mov edx,1+20000000 ; or 0x40000000
int 0x40
 
mov eax,5
mov ebx,1
draw_icon:
xchg [load_pic],bl
test bl,bl
je draw_icon_end
int 0x40
jmp draw_icon
draw_icon_end:
 
call load_icon_file
 
mov eax,5
mov ebx,1
draw_icon_2:
xchg [draw_pic],bl
test bl,bl
je draw_icon_end_2
int 0x40
jmp draw_icon_2
draw_icon_end_2:
 
mov eax,9
mov ebx,process_table
mov ecx,-1
int 0x40
; mov eax,process_table
; add eax,34
; mov ebx,[eax]
; mov [xpos],ebx
; add eax,4
; mov ebx,[eax]
; mov [ypos],ebx
 
call draw_picture
call draw_text
 
mov eax,12
mov ebx,2
int 0x40
 
ret
 
 
 
icon_lst db 'ICON LST'
 
tl dd 8
yw dd 51
ya dd 0
 
;xpos dd 15
;ypos dd 185
draw_pic db 0
load_pic db 0
create_thread_event db 0
 
labelt:
db 'SETUP '
labellen:
 
bgrxy dd 0x0
scrxy dd 0x0
bgrdrawtype dd 0x0
 
pixpos dd 0
pixpos2 db 0
 
top dd 0
 
image dd 0x3000
;thread_stack dd 0x5000
 
icons dd 0
 
 
I_Param:
 
icon_data = I_END+0x1400
process_table = I_END+0x2400
 
I_END:
 
bgrx dd ?
bgry dd ?
data_from_file:
rb 54 ;header
raw_data:
rb 32*32
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/icon/trunk/macros.inc
0,0 → 1,267
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property