Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Ignore whitespace Rev 179 → Rev 180

/kernel/trunk/docs/sysfuncr.txt
192,8 → 192,8
* ecx = 0xX0RRGGBB, £¤¥
* RR, GG, BB § ¤ îâ 梥â ⥪áâ 
* X=ABnn (¡¨âë):
* nn § ¤ ¥â ¨á¯®«ì§ã¥¬ë© èà¨äâ: 0=á¨á⥬­ë© ¬®­®è¨à¨­­ë©,
1=á¨á⥬­ë© èà¨äâ ¯¥à¥¬¥­­®© è¨à¨­ë
* nn § ¤ ¥â ¨á¯®«ì§ã¥¬ë© èà¨äâ: 1=á¨á⥬­ë© ¬®­®è¨à¨­­ë©,
0=á¨á⥬­ë© èà¨äâ ¯¥à¥¬¥­­®© è¨à¨­ë
* A=0 - ¢ë¢®¤¨âì esi ᨬ¢®«®¢, A=1 - ¢ë¢®¤¨âì ASCIIZ-áâபã
* B=1 - § ªà è¨¢ âì ä®­ 梥⮬ edi
* edx = 㪠§ â¥«ì ­  ­ ç «® áâப¨
/kernel/trunk/docs/sysfuncs.txt
189,8 → 189,8
* ecx = 0xX0RRGGBB, where
* RR, GG, BB specify text color
* X=ABnn (bits):
* nn specifies the used font: 0=system monospaced,
1=system font of variable width
* nn specifies the used font: 1=system monospaced,
0=system font of variable width
* A=0 - output esi characters, A=1 - output ASCIIZ-string
* B=1 - fill background with the color edi
* edx = pointer to the beginning of the string
/programs/demos/trantest/trunk/build_en.bat
1,4 → 1,5
@erase lang.inc
@echo lang fix en >lang.inc
@fasm trantest.asm trantest
@erase lang.inc
@pause
/programs/demos/trantest/trunk/build_ru.bat
1,4 → 1,5
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm trantest.asm trantest
@erase lang.inc
@pause
/programs/demos/trantest/trunk/trantest.asm
12,8 → 12,8
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd 0x2000000 ; memory for app
dd 0x2000000 ; esp
dd 0x100000 ; memory for app
dd 0x100000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
SCREEN_X equ 320 ;800
24,11 → 24,12
include 'ascgl.inc'
 
START:
red:
call draw_window
 
still:
scevent red,key,button
fps 280,8,cl_White,cl_Black
fps 290,8,cl_White,cl_Black
 
main_loop:
random SCREEN_X,eax
63,9 → 64,6
 
count dd 100
 
red:
call draw_window
jmp still
key:
mov eax,2
int 0x40
81,30 → 79,24
 
;Draw window
draw_window:
mov eax,12 ;Start
mov ebx,1
int 0x40
 
mov eax,0 ;Draw window
mov ebx,100*65536+(SCREEN_X+9) ;x start*65536+x size
mov ecx,100*65536+(SCREEN_Y+26) ;y start*65536+y size
mov edx,0x03000000 ;0x03 use skinned window
xor eax,eax ;Draw window
mov ebx,100*65536+(SCREEN_X+19) ;x start*65536+x size
mov ecx,100*65536+(SCREEN_Y+51) ;y start*65536+y size
mov edx,0x33000000 ;0x33 use skinned window
mov edi,header
int 0x40
 
mov eax,4 ;Out Text
mov ebx,8*65536+8 ;x start*65536+y start
mov ecx,0x00ffffff ;color White
mov edx,head_label
mov esi,hl_end-head_label
int 0x40
 
mov eax,12 ;End
mov ebx,2
int 0x40
ret
 
head_label: db "3D TEST SAMPLE FOR MENUETOS"
hl_end:
header db '3D TEST SAMPLE',0
 
outscr:
 
/programs/fs/kfar/trunk/build_en.bat
0,0 → 1,5
@erase lang.inc
@echo lang fix en >lang.inc
@fasm kfar.asm kfar
@erase lang.inc
@pause
/programs/fs/kfar/trunk/build_ru.bat
0,0 → 1,5
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm kfar.asm kfar
@erase lang.inc
@pause
/programs/fs/kfar/trunk/dialogs.inc
0,0 → 1,934
; int __stdcall DialogBox(DLGTEMPLATE* dlg, void* DlgProc);
; int __stdcall DlgProc(int msg, int param1, int param2);
 
virtual at 0
dlgtemplate:
.flags dd ?
.x dd ?
.y dd ?
.width dd ?
.height dd ?
.border_size_x dd ?
.border_size_y dd ?
.title dd ?
.main_color db ?
.border_color db ?
.header_color db ?
db ? ; align
end virtual
 
DialogBox:
pushad
; some checks
mov ebx, [esp+20h+4]
mov eax, [ebx+dlgtemplate.x]
cmp eax, 1
jl .sizeerr
add eax, [ebx+dlgtemplate.width]
cmp eax, [cur_width]
jge .sizeerr
mov eax, [ebx+dlgtemplate.y]
cmp eax, 1
jl .sizeerr
add eax, [ebx+dlgtemplate.height]
cmp eax, [cur_height]
jge .sizeerr
cmp [ebx+dlgtemplate.border_size_x], 1
jl .sizeerr
cmp [ebx+dlgtemplate.border_size_y], 1
jge .sizeok
.sizeerr:
popad
or eax, -1
ret 8
.sizeok:
; allocate memory for data under dialog
mov eax, [ebx+dlgtemplate.width]
add eax, [ebx+dlgtemplate.border_size_x]
add eax, [ebx+dlgtemplate.border_size_x]
inc eax
inc eax
mov edx, [ebx+dlgtemplate.height]
add edx, [ebx+dlgtemplate.border_size_y]
add edx, [ebx+dlgtemplate.border_size_y]
inc edx
mul edx
add eax, eax
call mf_alloc
test eax, eax
jnz @f
; TODO: add error message
popad
or eax, -1
ret 8
@@:
mov ebp, eax
; save data
mov eax, [ebx+dlgtemplate.y]
add eax, [ebx+dlgtemplate.height]
add eax, [ebx+dlgtemplate.border_size_y]
inc eax
push eax
mov eax, [ebx+dlgtemplate.x]
add eax, [ebx+dlgtemplate.width]
add eax, [ebx+dlgtemplate.border_size_x]
inc eax
inc eax
push eax
mov eax, [ebx+dlgtemplate.y]
sub eax, [ebx+dlgtemplate.border_size_y]
push eax
mov eax, [ebx+dlgtemplate.x]
sub eax, [ebx+dlgtemplate.border_size_x]
push eax
call save_console_data
; draw shadow
mov eax, [ebx+dlgtemplate.x]
sub eax, [ebx+dlgtemplate.border_size_x]
ja @f
xor eax, eax
@@:
push eax ; save real window left
inc eax
inc eax
mov edx, [ebx+dlgtemplate.y]
sub edx, [ebx+dlgtemplate.border_size_y]
ja @f
xor edx, edx
@@:
push edx ; save real window top
inc edx
call get_console_ptr
mov ecx, [ebx+dlgtemplate.y]
add ecx, [ebx+dlgtemplate.height]
add ecx, [ebx+dlgtemplate.border_size_y]
inc ecx
cmp ecx, [cur_height]
jb @f
mov ecx, [cur_height]
@@:
sub ecx, edx
mov edx, ecx
mov ecx, [ebx+dlgtemplate.x]
add ecx, [ebx+dlgtemplate.width]
add ecx, [ebx+dlgtemplate.border_size_x]
inc ecx
inc ecx
cmp ecx, [cur_width]
jb @f
mov ecx, [cur_width]
@@:
sub ecx, eax
mov eax, ecx
.shadow_loop:
mov ecx, eax
push edi
.sl1:
inc edi
test byte [edi], 0x0F
jnz @f
or byte [edi], 8
@@:
and byte [edi], 0x0F
inc edi
loop .sl1
pop edi
add edi, [cur_width]
add edi, [cur_width]
dec edx
jnz .shadow_loop
; draw area background
pop edx
pop eax
call get_console_ptr
mov ecx, [ebx+dlgtemplate.x]
add ecx, [ebx+dlgtemplate.width]
add ecx, [ebx+dlgtemplate.border_size_x]
cmp ecx, [cur_width]
jb @f
mov ecx, [cur_width]
@@:
sub ecx, eax
mov esi, ecx
mov ecx, [ebx+dlgtemplate.y]
add ecx, [ebx+dlgtemplate.height]
add ecx, [ebx+dlgtemplate.border_size_y]
cmp ecx, [cur_height]
jb @f
mov ecx, [cur_height]
@@:
sub ecx, edx
mov edx, ecx
mov al, ' '
mov ah, [ebx+dlgtemplate.border_color]
.1:
mov ecx, esi
push edi
rep stosw
pop edi
add edi, [cur_width]
add edi, [cur_width]
dec edx
jnz .1
; draw border
mov eax, [ebx+dlgtemplate.x]
dec eax
mov edx, [ebx+dlgtemplate.y]
dec edx
call get_console_ptr
mov edx, [ebx+dlgtemplate.height]
inc edx
inc edx
mov ah, [ebx+dlgtemplate.border_color]
push ebx
mov ebx, [ebx+dlgtemplate.width]
inc ebx
inc ebx
call draw_border
pop ebx
; draw header
mov esi, [ebx+dlgtemplate.title]
test esi, esi
jz .noheader
cmp byte [esi], 0
jz .noheader
push esi
@@: lodsb
test al, al
jnz @b
mov eax, esi
pop esi
sub eax, esi
inc eax ; eax = äëèíà çàãîëîâêà + 2
mov ecx, [ebx+dlgtemplate.width]
cmp eax, ecx
jbe .fullhea
sub ecx, 5
jb .noheader
xor edx, edx
jmp .drawhea
.fullhea:
mov edx, ecx
sub edx, eax
shr edx, 1
.drawhea:
mov eax, [ebx+dlgtemplate.x]
add eax, edx
mov edx, [ebx+dlgtemplate.y]
dec edx
call get_console_ptr
mov ah, [ebx+dlgtemplate.header_color]
mov al, ' '
stosw
dec ecx
.2:
jecxz .3
lodsb
test al, al
jz .4
stosw
jmp .2
.3:
mov al, '.'
stosw
stosw
stosw
.4:
mov al, ' '
stosw
.noheader:
; draw window background
mov eax, [ebx+dlgtemplate.x]
mov edx, [ebx+dlgtemplate.y]
call get_console_ptr
mov ah, [ebx+dlgtemplate.main_color]
mov al, ' '
mov edx, [ebx+dlgtemplate.height]
@@:
mov ecx, [ebx+dlgtemplate.width]
push edi
rep stosw
pop edi
add edi, [cur_width]
add edi, [cur_width]
dec edx
jnz @b
; send redraw message
mov eax, [esp+20h+8]
push ebx ebp
push 0
push 0
push 1
call eax
call draw_image
pop ebp ebx
; message loop
.event:
push 10
pop eax
int 40h
dec eax
jz .redraw
dec eax
jz .key
or eax, -1
int 40h
.redraw:
push ebx ebp
call draw_window
pop ebp ebx
jmp .event
.key:
mov al, 2
int 40h
shr eax, 8
cmp al, 0xE0
jnz @f
mov [bWasE0], 1
jmp .event
@@:
xchg ah, [bWasE0]
cmp al, 0x1D
jz .ctrl_down
cmp al, 0x9D
jz .ctrl_up
cmp al, 0x2A
jz .lshift_down
cmp al, 0xAA
jz .lshift_up
cmp al, 0x36
jz .rshift_down
cmp al, 0xB6
jz .rshift_up
cmp al, 0x38
jz .alt_down
cmp al, 0xB8
jz .alt_up
mov ecx, [esp+20h+8]
push ebx ebp
push 0
push eax
push 2
call ecx
pop ebp ebx
test eax, eax
jz .event
mov [esp+28], eax
jmp .exit
.ctrl_down:
test ah, ah
jnz .rctrl_down
or [ctrlstate], 4
jmp .event
.rctrl_down:
or [ctrlstate], 8
jmp .event
.ctrl_up:
test ah, ah
jnz .rctrl_up
and [ctrlstate], not 4
jmp .event
.rctrl_up:
and [ctrlstate], not 8
jmp .event
.lshift_down:
test ah, ah
jnz @f
or [ctrlstate], 1
@@: jmp .event
.lshift_up:
test ah, ah
jnz @b
and [ctrlstate], not 1
jmp @b
.rshift_down:
or [ctrlstate], 2
jmp .event
.rshift_up:
and [ctrlstate], not 2
jmp .event
.alt_down:
test ah, ah
jnz .ralt_down
or [ctrlstate], 0x10
jmp .event
.ralt_down:
or [ctrlstate], 0x20
jmp .event
.alt_up:
test ah, ah
jnz .ralt_up
and [ctrlstate], not 0x10
jmp .event
.ralt_up:
and [ctrlstate], not 0x20
jmp .event
.exit:
; restore data
mov eax, [ebx+dlgtemplate.y]
add eax, [ebx+dlgtemplate.height]
add eax, [ebx+dlgtemplate.border_size_y]
inc eax
push eax
mov eax, [ebx+dlgtemplate.x]
add eax, [ebx+dlgtemplate.width]
add eax, [ebx+dlgtemplate.border_size_x]
inc eax
inc eax
push eax
mov eax, [ebx+dlgtemplate.y]
sub eax, [ebx+dlgtemplate.border_size_y]
push eax
mov eax, [ebx+dlgtemplate.x]
sub eax, [ebx+dlgtemplate.border_size_x]
push eax
call restore_console_data
call draw_keybar
mov eax, ebp
call mf_free
call draw_image
popad
ret 8
 
save_console_data:
cmp dword [esp+4], 0
jge @f
and dword [esp+4], 0
@@:
cmp dword [esp+8], 0
jge @f
and dword [esp+8], 0
@@:
mov eax, [esp+12]
cmp eax, [cur_width]
jbe @f
mov eax, [cur_width]
@@:
sub eax, [esp+4]
ja @f
ret 16
@@:
mov [esp+12], eax
mov eax, [esp+16]
cmp eax, [cur_height]
jbe @f
mov eax, [cur_height]
@@:
sub eax, [esp+8]
ja @f
ret 16
@@:
mov [esp+16], eax
mov eax, [esp+4]
mov edx, [esp+8]
call get_console_ptr
mov esi, edi
mov edi, ebp
.l:
mov ecx, [esp+12]
push esi
shr ecx, 1
rep movsd
adc ecx, ecx
rep movsw
pop esi
add esi, [cur_width]
add esi, [cur_width]
dec dword [esp+16]
jnz .l
ret 16
 
restore_console_data:
cmp dword [esp+4], 0
jge @f
and dword [esp+4], 0
@@:
cmp dword [esp+8], 0
jge @f
and dword [esp+8], 0
@@:
mov eax, [esp+12]
cmp eax, [cur_width]
jbe @f
mov eax, [cur_width]
@@:
sub eax, [esp+4]
ja @f
ret 16
@@:
mov [esp+12], eax
mov eax, [esp+16]
cmp eax, [cur_height]
jbe @f
mov eax, [cur_height]
@@:
sub eax, [esp+8]
ja @f
ret 16
@@:
mov [esp+16], eax
mov eax, [esp+4]
mov edx, [esp+8]
call get_console_ptr
mov esi, ebp
.l:
mov ecx, [esp+12]
push edi
shr ecx, 1
rep movsd
adc ecx, ecx
rep movsw
pop edi
add edi, [cur_width]
add edi, [cur_width]
dec dword [esp+16]
jnz .l
ret 16
 
; int __stdcall menu(void* variants, const char* title, unsigned flags);
; variants 㪠§ë¢ ¥â ­  ⥪ã騩 í«¥¬¥­â ¢ ¤¢ãá¢ï§­®¬ «¨­¥©­®¬ ᯨ᪥
menu:
pop eax
push [cur_height]
push [cur_width]
push 0
push 0
push eax
 
; int __stdcall menu_centered_in(unsigned left, unsigned top, unsigned width, unsigned height,
; void* variants, const char* title, unsigned flags);
menu_centered_in:
pushad
mov eax, 56
; 36 bytes for dlgtemplate + additional:
; +36: dd cur_variant
; +40: dd num_variants
; +44: dd begin_variant
; +48: dd end_variant
; +52: dd cur_variant_idx
call mf_alloc
test eax, eax
jnz @f
.ret_bad:
popad
or eax, -1
ret 28
@@:
mov ebx, eax
mov eax, 1
test byte [esp+20h+28], 1
jz @f
mov al, 3
@@:
mov [ebx+dlgtemplate.border_size_x], eax
inc eax
shr eax, 1
mov [ebx+dlgtemplate.border_size_y], eax
;  å®¤¨¬ è¨à¨­ã ¨ ¢ëá®âã ®ª­ 
xor eax, eax
xor ecx, ecx
mov esi, [esp+20h+20]
mov [ebx+36], esi
and dword [ebx+52], 0
@@:
cmp dword [esi+4], 0
jz .find_width
mov esi, [esi+4]
inc dword [ebx+52]
jmp @b
.find_width:
mov [ebx+44], esi
add esi, 8
push esi
xor edx, edx
.fw1:
cmp byte [esi], '&'
jnz @f
mov dl, 1
@@:
inc esi
cmp byte [esi-1], 0
jnz .fw1
sub esi, [esp]
sub esi, edx
dec esi
cmp eax, esi
ja @f
mov eax, esi
@@:
inc ecx
pop esi
mov esi, [esi-8]
test esi, esi
jnz .find_width
add eax, 3
add eax, [ebx+dlgtemplate.border_size_x]
add eax, [ebx+dlgtemplate.border_size_x]
cmp eax, [cur_width]
jb @f
mov eax, [cur_width]
@@:
sub eax, [ebx+dlgtemplate.border_size_x]
sub eax, [ebx+dlgtemplate.border_size_x]
mov [ebx+dlgtemplate.width], eax
mov [ebx+dlgtemplate.height], ecx
mov [ebx+40], ecx
sub eax, [esp+20h+12]
neg eax
sar eax, 1
add eax, [esp+20h+4]
cmp eax, [ebx+dlgtemplate.border_size_x]
jge @f
mov eax, [ebx+dlgtemplate.border_size_x]
@@:
push eax
add eax, [ebx+dlgtemplate.width]
add eax, [ebx+dlgtemplate.border_size_x]
cmp eax, [cur_width]
jbe @f
pop eax
mov eax, [cur_width]
sub eax, [ebx+dlgtemplate.width]
sub eax, [ebx+dlgtemplate.border_size_x]
push eax
@@:
pop [ebx+dlgtemplate.x]
sub ecx, [esp+20h+16]
neg ecx
sar ecx, 1
add ecx, [esp+20h+8]
cmp ecx, [ebx+dlgtemplate.border_size_y]
jge @f
mov ecx, [ebx+dlgtemplate.border_size_y]
@@:
push ecx
add ecx, [ebx+dlgtemplate.height]
add ecx, [ebx+dlgtemplate.border_size_y]
cmp ecx, [cur_height]
jbe @f
pop ecx
mov ecx, [cur_height]
sub ecx, [ebx+dlgtemplate.height]
sub ecx, [ebx+dlgtemplate.border_size_y]
push ecx
@@:
pop [ebx+dlgtemplate.y]
mov eax, [cur_height]
sub eax, 6
cmp [ebx+dlgtemplate.height], eax
jbe .small_height
mov [ebx+dlgtemplate.height], eax
mov [ebx+dlgtemplate.y], 3
.small_height:
mov ecx, [ebx+dlgtemplate.height]
mov eax, [ebx+36]
mov [ebx+44], eax
dec ecx
jz .skip
push ecx
@@:
cmp dword [eax+4], 0
jz @f
mov eax, [eax+4]
loop @b
@@:
mov [ebx+44], eax
pop ecx
.loop:
mov eax, [eax]
loop .loop
.skip:
mov [ebx+48], eax
mov eax, [esp+20h+24]
mov [ebx+dlgtemplate.title], eax
mov al, [menu_normal_color]
mov [ebx+dlgtemplate.main_color], al
mov al, [menu_border_color]
mov [ebx+dlgtemplate.border_color], al
mov al, [menu_header_color]
mov [ebx+dlgtemplate.header_color], al
push MenuDlgProc
push ebx
call DialogBox
mov [esp+28], eax
mov eax, ebx
call mf_free
popad
ret 28
 
MenuDlgProc:
mov eax, [esp+4]
cmp al, 1
jz .draw
cmp al, 2
jz .key
ret 12
.draw:
call .dodraw
ret 12
.key:
mov al, [esp+8]
cmp al, 0x48
jz .prev
cmp al, 0x4B
jz .prev
cmp al, 0x4D
jz .next
cmp al, 0x50
jz .next
cmp al, 0x1C
jz .enter
cmp al, 1
jz .esc
cmp al, 0x47
jz .home
cmp al, 0x4F
jz .end
cmp al, 0x51
jz .pgdn
cmp al, 0x49
jz .pgup
mov edx, [ebx+36]
@@:
cmp dword [edx+4], 0
jz @f
mov edx, [edx+4]
jmp @b
@@:
.l:
lea esi, [edx+7]
@@:
inc esi
cmp byte [esi], 0
jz .n
cmp byte [esi], '&'
jnz @b
movzx ecx, byte [esi+1]
cmp [ascii2scan+ecx], al
jnz .n
mov eax, edx
ret 12
.n:
mov edx, [edx]
test edx, edx
jnz .l
.ret:
xor eax, eax
ret 12
.pgup:
mov eax, [ebx+36]
mov ecx, [ebx+dlgtemplate.height]
.pgupl:
cmp dword [eax+4], 0
jz .posret
call .line_prev
loop .pgupl
jmp .posret
.prev:
mov eax, [ebx+36]
cmp dword [eax+4], 0
jz .end
call .line_prev
.posret:
mov [ebx+36], eax
.redraw:
call .dodraw
call draw_image
xor eax, eax
ret 12
.next:
mov eax, [ebx+36]
cmp dword [eax], 0
jz .home
call .line_next
jmp .posret
.pgdn:
mov eax, [ebx+36]
mov ecx, [ebx+dlgtemplate.height]
.pgdnl:
cmp dword [eax], 0
jz .posret
call .line_next
loop .pgdnl
jmp .posret
.home:
mov eax, [ebx+36]
@@:
cmp dword [eax+4], 0
jz @f
mov eax, [eax+4]
jmp @b
@@:
mov [ebx+44], eax
push eax
mov ecx, [ebx+dlgtemplate.height]
dec ecx
jz .h1
.h2:
mov eax, [eax]
loop .h2
.h1:
mov [ebx+48], eax
pop eax
and dword [ebx+52], 0
jmp .posret
.end:
mov eax, [ebx+36]
@@:
cmp dword [eax], 0
jz @f
mov eax, [eax]
jmp @b
@@:
mov [ebx+48], eax
push eax
mov ecx, [ebx+dlgtemplate.height]
dec ecx
jz .e1
.e2:
mov eax, [eax+4]
loop .e2
.e1:
mov [ebx+44], eax
mov eax, [ebx+40]
dec eax
mov [ebx+52], eax
pop eax
jmp .posret
.esc:
or eax, -1
ret 12
.enter:
mov eax, [ebx+36]
ret 12
 
.line_prev:
cmp eax, [ebx+44]
jnz @f
mov edx, [ebx+44]
mov edx, [edx+4]
mov [ebx+44], edx
mov edx, [ebx+48]
mov edx, [edx+4]
mov [ebx+48], edx
@@:
mov eax, [eax+4]
dec dword [ebx+52]
ret
.line_next:
cmp eax, [ebx+48]
jnz @f
mov edx, [ebx+44]
mov edx, [edx]
mov [ebx+44], edx
mov edx, [ebx+48]
mov edx, [edx]
mov [ebx+48], edx
@@:
mov eax, [eax]
inc dword [ebx+52]
ret
 
.dodraw:
mov eax, [ebx+dlgtemplate.x]
mov edx, [ebx+dlgtemplate.y]
call get_console_ptr
mov esi, [ebx+44]
.0:
xor edx, edx
mov ah, [menu_selected_color]
cmp esi, [ebx+36]
jz @f
mov ah, [menu_normal_color]
@@:
push edi
mov ecx, [ebx+dlgtemplate.width]
mov al, ' '
stosw
dec ecx
stosw
dec ecx
dec ecx
push esi
add esi, 8
@@:
lodsb
test al, al
jz @f
cmp al, '&'
jnz .noamp
test dl, dl
jnz .noamp
mov dl, 1
lodsb
push eax
mov ah, [menu_selected_highlight_color]
push ecx
mov ecx, [esp+8]
cmp ecx, [ebx+36]
pop ecx
jz .amp1
mov ah, [menu_highlight_color]
.amp1:
stosw
pop eax
jmp .amp2
.noamp:
stosw
.amp2:
loop @b
mov al, ' '
cmp byte [esi], 0
jnz .1
lodsb
jmp .1
@@:
mov al, ' '
.1:
stosw
mov al, ' '
rep stosw
pop esi edi
add edi, [cur_width]
add edi, [cur_width]
cmp esi, [ebx+48]
jz @f
mov esi, [esi]
test esi, esi
jnz .0
@@:
; ‹¨­¥©ª  ¯à®ªàã⪨
mov ecx, [ebx+dlgtemplate.height]
cmp ecx, [ebx+40]
jz .noscrollbar
sub ecx, 2
jbe .noscrollbar
mov eax, [ebx+52]
mul ecx
div dword [ebx+40]
push eax
mov eax, [ebx+dlgtemplate.x]
add eax, [ebx+dlgtemplate.width]
mov edx, [ebx+dlgtemplate.y]
call get_console_ptr
pop edx
inc edx
mov al, 0x1E
mov ah, [menu_scrollbar_color]
mov [edi], ax
add edi, [cur_width]
add edi, [cur_width]
.2:
mov al, 0xB2
dec edx
jz @f
mov al, 0xB0
@@:
mov [edi], ax
add edi, [cur_width]
add edi, [cur_width]
loop .2
mov al, 0x1F
stosw
.noscrollbar:
ret
/programs/fs/kfar/trunk/font.inc
0,0 → 1,48
fontname equ 'font8x16.bmp'
virtual at 0
file fontname, 3Eh
; sanity check
load a1 word from 0
load a2 dword from 0xE
if (a1 <> 'BM') | (a2 <> 0x28)
error 'not BMP file!'
end if
load a1 dword from 0x12
load a2 dword from 0x16
if (a1 and 0xF) | (a2 and 0xF) | (a1 > 16*16)
error 'font: invalid width or height'
end if
font_width = a1 shr 4
font_bmp_scanline = (font_width*2 + 3) and not 3
font_height = a2 shr 4
load a1 dword from 0x1A
if a1 <> 0x10001
error 'font: not monochrome bitmap'
end if
end virtual
 
font:
repeat font_height
cur_scan = %
repeat 256
virtual at 0
a2 = (font_width+14) shr 3
if cur_scan=1 & %=0x10
a2 = (font_width+7) shr 3
end if
file fontname:3Eh + font_bmp_scanline*(font_height*(16-((%-1) shr 4))-cur_scan) + ((((%-1) and 0xF)*font_width) shr 3), a2
dd 0
load a1 dword from 0
a1 = ((a1 and 0x55555555) shl 1) or ((a1 and 0xAAAAAAAA) shr 1)
a1 = ((a1 and 0x33333333) shl 2) or ((a1 and 0xCCCCCCCC) shr 2)
a1 = ((a1 and 0x0F0F0F0F) shl 4) or ((a1 and 0xF0F0F0F0) shr 4)
end virtual
a1 = (a1 shr (((%-1)*font_width) and 7)) and ((1 shl font_width) - 1)
a1 = a1 xor ((1 shl font_width) - 1)
if font_width > 8
dw a1
else
db a1
end if
end repeat
end repeat
/programs/fs/kfar/trunk/font10x20.bmp
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/fs/kfar/trunk/font6x9.bmp
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/fs/kfar/trunk/font7x12.bmp
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/fs/kfar/trunk/font8x16.bmp
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/fs/kfar/trunk/font8x9.bmp
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/fs/kfar/trunk/kfar.asm
0,0 → 1,3648
use32
db 'MENUET01'
dd 1
dd start
dd i_end
memsize dd mem
dd stacktop
dd 0, 0
 
include 'lang.inc'
include 'font.inc'
include 'sort.inc'
include 'kglobals.inc'
include 'memalloc.inc'
include 'dialogs.inc'
include 'viewer.inc'
 
start:
mov eax, mem
call mf_init
call draw_window
push 66
pop eax
push 1
pop ebx
mov ecx, ebx
int 40h ; set keyboard mode to scancodes
call init_console
mov esi, def_left_dir
mov edi, panel1_dir
@@:
lodsb
stosb
test al, al
jnz @b
@@:
mov esi, def_right_dir
mov edi, panel2_dir
@@:
lodsb
stosb
test al, al
jnz @b
mov eax, 304
mov [panel1_nfa], eax
mov [panel2_nfa], eax
mov [panel1_files], buf1
mov [panel2_files], buf2
mov [panel1_sortmode], 0 ; sort by name
mov [panel2_sortmode], 0
mov [num_screens], 1
mov eax, 8
call mf_alloc
mov [screens], eax
mov ecx, panels_vtable
mov [eax], ecx
mov [active_screen_vtable], ecx
call draw_keybar
call draw_cmdbar
mov ebp, panel1_data
call read_folder
call draw_panel
mov ebp, panel2_data
call read_folder
call draw_panel
event:
push 10
pop eax
int 40h
dec eax
jz redraw
dec eax
jz key
; button - we have only one button, close
exit:
or eax, -1
int 40h
redraw:
mov al, 9
mov ebx, procinfo
or ecx, -1
int 40h
; test if rolled up
; height of rolled up window is [skinh]+3
mov eax, [ebx+46]
sub eax, [skinh]
cmp eax, 5
ja @f
mov al, 12
push 1
pop ebx
int 0x40
xor eax, eax
; ebx, ecx, edi are ignored by function 0 after first redraw
mov edx, 0x13000000
int 0x40
mov al, 12
inc ebx
int 0x40
jmp event
@@:
xor ecx, ecx
mov eax, [ebx+42]
sub eax, 5*2
jae @f
xor eax, eax
@@:
cdq
mov esi, font_width
div esi
cmp eax, 54
jae @f
mov al, 54
mov ch, 1
@@:
cmp eax, 255
jbe @f
mov eax, 255
mov ch, 1
@@:
cmp eax, [cur_width]
mov [cur_width], eax
setnz cl
or cl, ch
test edx, edx
setnz ch
or cl, ch
mov eax, [ebx+46]
sub eax, [skinh]
sub eax, 5
jns @f
xor eax, eax
@@:
cdq
mov esi, font_height
div esi
cmp eax, 8
jae @f
mov al, 8
mov cl, 1
@@:
cmp eax, 255
jbe @f
mov eax, 255
mov cl, 1
@@:
cmp eax, [cur_height]
mov [cur_height], eax
setnz ch
or cl, ch
test edx, edx
setnz ch
test cx, cx
jz @f
mov eax, [MemForImage]
call mf_free
and [MemForImage], 0
call init_console
push 67
pop eax
or ebx, -1
or ecx, -1
mov edx, [cur_width]
imul edx, font_width
add edx, 5*2
mov esi, [cur_height]
imul esi, font_height
add esi, [skinh]
add esi, 5
int 40h
call draw_window
call draw_keybar
mov ebp, [active_screen_data]
mov eax, [active_screen_vtable]
call dword [eax+screen_vtable.OnRedraw]
jmp event
@@:
call draw_window
jmp event
key:
mov al, 2
int 40h
test al, al
jnz event
xchg al, ah
cmp al, 0xE0
jnz @f
mov [bWasE0], 1
jmp event
@@:
xchg ah, [bWasE0]
mov ebp, [active_screen_data]
mov edx, [active_screen_vtable]
cmp al, 0x1D
jz .ctrl_down
cmp al, 0x9D
jz .ctrl_up
cmp al, 0x2A
jz .lshift_down
cmp al, 0xAA
jz .lshift_up
cmp al, 0x36
jz .rshift_down
cmp al, 0xB6
jz .rshift_up
cmp al, 0x38
jz .alt_down
cmp al, 0xB8
jz .alt_up
call [edx+screen_vtable.OnKey]
jmp event
.ctrl_down:
test ah, ah
jnz .rctrl_down
or [ctrlstate], 4
jmp .keybar
.rctrl_down:
or [ctrlstate], 8
jmp .keybar
.ctrl_up:
test ah, ah
jnz .rctrl_up
and [ctrlstate], not 4
jmp .keybar
.rctrl_up:
and [ctrlstate], not 8
.keybar:
call draw_keybar
call draw_image
@@: jmp event
.lshift_down:
; ignore E0 2A sequence
; e.g. arrow keys with NumLock on generate sequence E0 2A E0 xx / E0 xx+80 E0 AA
; where xx is scancode, so we can safely ignore E0 2A
test ah, ah
jnz @b
or [ctrlstate], 1
jmp .keybar
.lshift_up:
; ignore E0 AA sequence
test ah, ah
jnz @b
and [ctrlstate], not 1
jmp .keybar
.rshift_down:
or [ctrlstate], 2
jmp .keybar
.rshift_up:
and [ctrlstate], not 2
jmp .keybar
.alt_down:
test ah, ah
jnz .ralt_down
or [ctrlstate], 0x10
jmp .keybar
.ralt_down:
or [ctrlstate], 0x20
jmp .keybar
.alt_up:
test ah, ah
jnz .ralt_up
and [ctrlstate], not 0x10
jmp .keybar
.ralt_up:
and [ctrlstate], not 0x20
jmp .keybar
 
process_ctrl_keys:
cmp byte [esi], 0
jz .done
push ecx
cmp al, [esi]
jz .check
.cont:
pop ecx
add esi, 8
jmp process_ctrl_keys
.done:
stc
ret
.check:
mov cl, 0
call .check_ctrlkey
jc .cont
mov cl, 2
call .check_ctrlkey
jc .cont
mov cl, 4
call .check_ctrlkey
jc .cont
pop ecx
call dword [esi+4]
clc
ret
.check_ctrlkey:
push eax edx
movzx edx, [ctrlstate]
shr edx, cl
add cl, cl
movzx eax, word [esi+2]
shr eax, cl
and eax, 15
cmp al, ctrlkey_tests_num
jae .fail
xchg eax, edx
and al, 3
call [ctrlkey_tests + edx*4]
cmp al, 1
pop edx eax
ret
.fail:
stc
pop edx eax
ret
 
ctrlkey_test0:
test al, al
setz al
ret
ctrlkey_test1:
test al, al
setnp al
ret
ctrlkey_test2:
cmp al, 3
setz al
ret
ctrlkey_test3:
cmp al, 1
setz al
ret
ctrlkey_test4:
cmp al, 2
setz al
ret
 
; TODO: add "no memory" error handling
new_screen:
call mf_alloc
test eax, eax
jnz @f
ret
@@:
mov ebp, eax
mov ebx, [num_screens]
inc ebx
shl ebx, 3
mov eax, [screens]
call mf_realloc
test eax, eax
jnz @f
mov eax, ebp
call mf_free
xor eax, eax
ret
@@:
mov [screens], eax
inc [num_screens]
mov [eax+ebx-8], edx
mov [eax+ebx-4], ebp
mov eax, [num_screens]
dec eax
mov [active_screen], eax
mov [active_screen_vtable], edx
mov [active_screen_data], ebp
jmp draw_keybar
 
next_screen:
mov eax, [active_screen]
inc eax
cmp eax, [num_screens]
jnz @f
xor eax, eax
@@: mov [active_screen], eax
jmp change_screen
 
delete_active_screen:
mov edi, [screens]
mov eax, [active_screen]
shl eax, 3
add edi, eax
push dword [edi+4]
lea esi, [edi+8]
mov ecx, [num_screens]
sub ecx, [active_screen]
dec ecx
add ecx, ecx
rep movsd
dec [num_screens]
mov ebx, [num_screens]
shl ebx, 3
mov eax, [screens]
call mf_realloc
pop eax
call mf_free
and [active_screen], 0
 
change_screen:
pusha
mov eax, [active_screen]
mov esi, [screens]
mov ebp, [esi+eax*8+4]
mov eax, [esi+eax*8]
mov [active_screen_vtable], eax
mov [active_screen_data], ebp
call draw_keybar
call [eax+screen_vtable.OnRedraw]
popa
ret
 
F12:
mov eax, [cur_width]
add eax, 8
mov esi, eax
mul [num_screens]
call mf_alloc
test eax, eax
jnz @f
ret
@@:
mov ebx, eax
mov edi, eax
xor ecx, ecx
.next:
xor eax, eax
stosd
inc ecx
cmp ecx, [num_screens]
jz @f
lea eax, [edi+esi-4]
mov dword [edi-4], eax
@@:
xor eax, eax
stosd
dec ecx
jz @f
lea eax, [edi-8]
sub eax, esi
mov dword [edi-4], eax
@@:
mov al, '&'
stosb
cmp ecx, 36
jae .noletter
lea eax, [ecx+'0']
cmp al, '9'
jbe @f
add al, 7
@@:
stosb
mov al, '.'
stosb
jmp .letter_done
.noletter:
mov al, ' '
stosb
stosb
.letter_done:
mov al, ' '
stosb
pushad
mov eax, [screens]
mov ebp, [eax+ecx*8+4]
mov eax, [eax+ecx*8]
mov ecx, [cur_width]
sub ecx, 12
call [eax + screen_vtable.getname]
popad
sub edi, 4
add edi, [cur_width]
inc ecx
cmp ecx, [num_screens]
jb .next
mov eax, [active_screen]
mul esi
add eax, ebx
push 1
push aScreens
push eax
call menu
cmp eax, -1
jz @f
sub eax, ebx
div esi
mov [active_screen], eax
@@:
mov eax, ebx
call mf_free
jmp change_screen
 
panels_OnKey:
mov ebp, [active_panel]
mov ecx, [ebp + panel1_index - panel1_data]
mov edx, [ebp + panel1_start - panel1_data]
mov ebx, [ebp + panel1_colst - panel1_data]
add ebx, edx
mov esi, panels_ctrlkeys
jmp process_ctrl_keys
.ret:
ret
.up:
jecxz .ret
dec ecx
mov [ebp + panel1_index - panel1_data], ecx
cmp ecx, edx
jae .done_redraw
mov [ebp + panel1_start - panel1_data], ecx
.done_redraw:
; call draw_panel
; ret
jmp draw_panel
.down:
inc ecx
cmp ecx, [ebp + panel1_numfiles - panel1_data]
jae .ret
mov [ebp + panel1_index - panel1_data], ecx
cmp ecx, ebx
jb .done_redraw
sub ecx, [ebp + panel1_colst - panel1_data]
inc ecx
mov [ebp + panel1_start - panel1_data], ecx
jmp .done_redraw
.left:
jecxz .ret
sub ecx, [ebp + panel1_colsz - panel1_data]
jae @f
xor ecx, ecx
@@:
mov [ebp + panel1_index - panel1_data], ecx
cmp ecx, edx
jae .done_redraw
sub edx, [ebp + panel1_colsz - panel1_data]
jae @f
xor edx, edx
@@:
mov [ebp + panel1_start - panel1_data], edx
jmp .done_redraw
.right:
add ecx, [ebp + panel1_colsz - panel1_data]
cmp ecx, [ebp + panel1_numfiles - panel1_data]
jb @f
mov ecx, [ebp + panel1_numfiles - panel1_data]
dec ecx
@@:
mov [ebp + panel1_index - panel1_data], ecx
cmp ecx, ebx
jb .done_redraw
add ebx, [ebp + panel1_colsz - panel1_data]
cmp ebx, [ebp + panel1_numfiles - panel1_data]
jbe @f
mov ebx, [ebp + panel1_numfiles - panel1_data]
@@:
sub ebx, [ebp + panel1_colst - panel1_data]
jae @f
xor ebx, ebx
@@:
mov [ebp + panel1_start - panel1_data], ebx
jmp .done_redraw
.tab:
xor [active_panel], panel1_data xor panel2_data
call draw_cmdbar
call draw_panel
mov ebp, [active_panel]
jmp .done_redraw
.home:
and [ebp + panel1_start - panel1_data], 0
and [ebp + panel1_index - panel1_data], 0
jmp .done_redraw
.end:
mov eax, [ebp + panel1_numfiles - panel1_data]
dec eax
mov [ebp + panel1_index - panel1_data], eax
inc eax
sub eax, [ebp + panel1_colst - panel1_data]
jae @f
xor eax, eax
@@:
mov [ebp + panel1_start - panel1_data], eax
jmp .done_redraw
.enter:
mov eax, [ebp + panel1_files - panel1_data]
mov ecx, [eax+ecx*4]
mov eax, [ebp + panel1_nfa - panel1_data]
lea ecx, [ecx+eax*4+32]
add ecx, [ebp + panel1_files - panel1_data]
test byte [ecx], 10h
jnz .enter_folder
; find extension
lea esi, [ecx+40]
push esi
@@:
lodsb
test al, al
jnz @b
@@:
dec esi
cmp byte [esi], '.'
jz .found_ext
cmp esi, [esp]
ja @b
jmp .run_app
.found_ext:
inc esi
mov edi, associations
@@:
push esi edi
mov edi, [edi]
call strcmpi
pop edi esi
jz .run_association
add edi, 8
cmp edi, associations_end
jb @b
jmp .run_app
.run_association:
mov [execparams], execdata
mov eax, [edi+4]
mov [execptr], eax
jmp .dorun
.run_app:
mov [execptr], execdata
and [execparams], 0
.dorun:
pop esi
lea esi, [ebp + panel1_dir - panel1_data]
mov edi, execdata
; TODO: add overflow check
@@:
lodsb
test al, al
jz @f
stosb
jmp @b
@@:
lea esi, [ecx+40]
mov al, '/'
stosb
@@:
lodsb
stosb
test al, al
jnz @b
push 70
pop eax
mov ebx, execinfo
int 40h
ret
.enter_folder:
lea esi, [ecx+40]
cmp word [esi], '..'
jnz @f
cmp byte [esi+2], 0
jz .dotdot
@@:
lea edi, [ebp + panel1_dir - panel1_data]
mov al, 0
or ecx, -1
repnz scasb
dec edi
mov al, '/'
cmp [edi-1], al
jz @f
stosb
@@:
; TODO: add buffer overflow check
@@:
lodsb
stosb
test al, al
jnz @b
.reread:
call read_folder
.done_cmdbar:
call draw_cmdbar
jmp .done_redraw
.dotdot:
lea edi, [ebp + panel1_dir - panel1_data]
mov al, 0
or ecx, -1
repnz scasb
dec edi
mov al, '/'
std
repnz scasb
cld
inc edi
mov byte [edi], 0
inc edi
push edi
call read_folder
pop edi
mov edx, [ebp + panel1_files - panel1_data]
mov ecx, [ebp + panel1_numfiles - panel1_data]
.scanloop:
mov esi, [edx]
mov eax, [ebp + panel1_nfa - panel1_data]
lea esi, [esi+eax*4+32+40]
add esi, [ebp + panel1_files - panel1_data]
push esi edi
@@:
lodsb
call match_symbol
jnz @f
inc edi
test al, al
jnz @b
@@:
pop edi esi
jz .scanfound
add edx, 4
loop .scanloop
jmp .scandone
.scanfound:
sub edx, [ebp + panel1_files - panel1_data]
shr edx, 2
mov [ebp + panel1_index - panel1_data], edx
sub edx, [ebp + panel1_colst - panel1_data]
jb .scandone
inc edx
mov [ebp + panel1_start - panel1_data], edx
.scandone:
jmp .done_cmdbar
.ctrl_f39:
sub al, 0x3D
add al, al
mov ah, [ebp + panel1_sortmode - panel1_data]
and ah, 0xFE
cmp al, ah
jnz @f
and [ebp + panel1_sortmode - panel1_data], 1
or al, [ebp + panel1_sortmode - panel1_data]
xor al, 1
@@:
mov [ebp + panel1_sortmode - panel1_data], al
mov eax, [ebp + panel1_index - panel1_data]
mov ecx, [ebp + panel1_files - panel1_data]
push dword [ecx+eax*4]
push ecx
call sort_files
pop edi
pop eax
or ecx, -1
repnz scasd
not ecx
dec ecx
mov [ebp + panel1_index - panel1_data], ecx
sub ecx, [ebp + panel1_start - panel1_data]
jb .less_start
sub ecx, [ebp + panel1_colst - panel1_data]
jae .gr_end
@@: jmp .done_redraw
.less_start:
add [ebp + panel1_start - panel1_data], ecx
jmp @b
.gr_end:
inc ecx
add [ebp + panel1_start - panel1_data], ecx
jmp @b
.alt_f12:
mov ebp, panel1_data
cmp al, 0x3B
jz @f
mov ebp, panel2_data
@@:
; get drives list
mov ebx, dirinfo
mov [ebx+dirinfo.size-dirinfo], 1
mov [ebx+dirinfo.dirdata-dirinfo], driveinfo
mov [ebx+dirinfo.name-dirinfo], tmpname
mov byte [tmpname], '/'
xor ecx, ecx
.drive_loop_e:
mov byte [tmpname+1], 0
push 70
pop eax
int 40h
mov ebx, dirinfo
test eax, eax
jnz .drive_loop_e_done
mov esi, driveinfo+32+40
mov edi, tmpname+1
@@:
lodsb
stosb
test al, al
jnz @b
push [ebx+dirinfo.first-dirinfo]
and [ebx+dirinfo.first-dirinfo], 0
.drive_loop_i:
push 70
pop eax
int 40h
mov ebx, dirinfo
test eax, eax
jnz .drive_loop_i_done
mov eax, 32+8
call mf_alloc
test eax, eax
jz .drive_loop_i_done
jecxz @f
mov [ecx], eax
@@:
and dword [eax], 0
mov [eax+4], ecx
mov ecx, eax
lea edi, [eax+8]
mov esi, tmpname
@@:
lodsb
test al, al
jz @f
stosb
jmp @b
@@:
mov esi, driveinfo+32+40
mov al, '/'
stosb
@@:
lodsb
stosb
test al, al
jnz @b
inc [ebx+dirinfo.first-dirinfo]
jmp .drive_loop_i
.drive_loop_i_done:
pop [ebx+dirinfo.first-dirinfo]
inc [ebx+dirinfo.first-dirinfo]
jmp .drive_loop_e
.drive_loop_e_done:
and [ebx+dirinfo.first-dirinfo], 0
lea edi, [ebp + panel1_dir - panel1_data]
.find_cur_drive_loop:
push edi
lea esi, [ecx+8]
@@:
lodsb
test al, al
jz .cur_drive_found
call match_symbol
jnz @f
inc edi
jmp @b
@@:
cmp dword [ecx+4], 0
jz @f
pop edi
mov ecx, [ecx+4]
jmp .find_cur_drive_loop
@@:
.cur_drive_found:
pop edi
push 1
push aDrive
push ecx
mov eax, [ebp + panel1_height - panel1_data]
sub eax, 2
jae @f
add eax, 2
@@:
push eax
push [ebp + panel1_width - panel1_data]
push [ebp + panel1_top - panel1_data]
push [ebp + panel1_left - panel1_data]
call menu_centered_in
cmp eax, -1
jz .ret2
lea esi, [eax+8]
lea edi, [ebp + panel1_dir - panel1_data]
@@:
lodsb
stosb
test al, al
jnz @b
@@:
cmp dword [ecx+4], 0
jz @f
mov ecx, [ecx+4]
jmp @b
@@:
mov eax, ecx
mov ecx, [ecx]
call mf_free
test ecx, ecx
jnz @b
call read_folder
jmp .done_redraw
.f3:
call view_file
.ret2:
ret
.f8:
mov eax, [ebp + panel1_files - panel1_data]
mov ecx, [eax+ecx*4]
mov eax, [ebp + panel1_nfa - panel1_data]
lea ecx, [ecx+eax*4+32]
add ecx, [ebp + panel1_files - panel1_data]
lea esi, [ebp + panel1_dir - panel1_data]
mov edi, execdata
@@:
lodsb
test al, al
jz @f
stosb
jmp @b
@@:
lea esi, [ecx+40]
mov al, '/'
stosb
@@:
lodsb
stosb
test al, al
jnz @b
push 70
pop eax
mov ebx, delinfo
int 0x40
.ctrl_r:
; Rescan panel
; call read_folder
; jmp .done_redraw
mov eax, [ebp + panel1_index - panel1_data]
push eax
mov ecx, [ebp + panel1_files - panel1_data]
mov ecx, [ecx+eax*4]
mov eax, [ebp + panel1_nfa - panel1_data]
lea esi, [ecx+eax*4+32+40]
add esi, [ebp + panel1_files - panel1_data]
mov edi, saved_file_name
@@:
lodsb
stosb
test al, al
jnz @b
push [ebp + panel1_start - panel1_data]
call read_folder
pop [ebp + panel1_start - panel1_data]
pop [ebp + panel1_index - panel1_data]
or eax, -1
@@:
inc eax
cmp eax, [ebp + panel1_numfiles - panel1_data]
jae .ctrl_r.notfound
mov esi, [ebp + panel1_nfa - panel1_data]
mov ecx, [ebp + panel1_files - panel1_data]
lea esi, [ecx+esi*4+32+40]
add esi, [ecx+eax*4]
mov edi, saved_file_name
call strcmpi
jnz @b
.ctrl_r.found:
mov [ebp + panel1_index - panel1_data], eax
.ctrl_r.notfound:
mov eax, [ebp + panel1_numfiles - panel1_data]
dec eax
cmp [ebp + panel1_index - panel1_data], eax
jbe @f
mov [ebp + panel1_index - panel1_data], eax
@@:
mov eax, [ebp + panel1_index - panel1_data]
cmp [ebp + panel1_start - panel1_data], eax
jbe @f
mov [ebp + panel1_start - panel1_data], eax
@@:
inc eax
sub eax, [ebp + panel1_colst - panel1_data]
jae @f
xor eax, eax
@@:
cmp [ebp + panel1_start - panel1_data], eax
jae @f
mov [ebp + panel1_start - panel1_data], eax
@@:
mov eax, [ebp + panel1_numfiles - panel1_data]
sub eax, [ebp + panel1_colst - panel1_data]
jbe @f
cmp [ebp + panel1_start - panel1_data], eax
jbe @f
mov [ebp + panel1_start - panel1_data], eax
@@:
jmp .done_redraw
 
panels_OnRedraw:
call draw_cmdbar
mov ebp, panel1_data
call draw_panel
mov ebp, panel2_data
call draw_panel
ret
 
init_console:
mov ax, 0720h
mov ecx, [cur_width]
imul ecx, [cur_height]
mov edi, console_data
rep stosw
and [panel1_left], 0
and [panel1_top], 0
and [panel2_top], 0
mov eax, [cur_width]
inc eax
shr eax, 1
mov [panel1_width], eax
mov [panel2_left], eax
sub eax, [cur_width]
neg eax
mov [panel2_width], eax
mov eax, [cur_height]
dec eax
dec eax
mov [panel1_height], eax
mov [panel2_height], eax
ret
 
panels_getname:
if lang eq ru
mov eax, ' ­¥'
stosd
mov eax, 'Ǭ '
stosd
mov eax, ' '
stosd
stosb
else
mov eax, 'Pane'
stosd
mov eax, 'ls '
stosd
mov eax, ' '
stosd
stosb
end if
sub ecx, 13
mov ebp, [active_panel]
lea esi, [ebp + panel1_dir - panel1_data]
push 3
pop edx
@@:
lodsb
stosb
dec ecx
test al, al
jz @f
cmp al, '/'
jnz @b
dec edx
jnz @b
@@:
test al, al
jnz @f
dec esi
dec edi
@@:
push esi
@@:
lodsb
test al, al
jnz @b
dec esi
mov ebx, esi
sub ebx, [esp]
dec esi
push esi
mov edx, [ebp + panel1_files - panel1_data]
mov esi, [ebp + panel1_index - panel1_data]
mov esi, [edx+esi*4]
add esi, edx
mov edx, [ebp + panel1_nfa - panel1_data]
lea esi, [esi+edx*4+32+40]
push esi
@@:
lodsb
test al, al
jnz @b
add ebx, esi
sub ebx, [esp]
dec esi
cmp ebx, ecx
jbe @f
mov al, '.'
stosb
stosb
stosb
sub ecx, 3
mov ebx, ecx
@@:
add edi, ebx
inc ecx
std
@@:
movsb
dec ecx
jz .nodir
cmp esi, [esp]
jae @b
mov al, '/'
stosb
dec ecx
jz .nodir
mov esi, [esp+4]
@@:
cmp esi, [esp+8]
jb .nodir
movsb
loop @b
.nodir:
cld
pop eax
pop eax
pop eax
ret
 
draw_window:
push 12
pop eax
push 1
pop ebx
int 40h
mov al, 48
mov bl, 4
int 40h
mov [skinh], eax
mov ebx, [cur_width]
imul ebx, font_width
add ebx, 100*65536 + 5*2
mov ecx, [cur_height]
imul ecx, font_height
lea ecx, [eax+ecx+5+100*65536]
xor eax, eax
mov edx, 0x13000000
mov edi, header
int 40h
mov al, 48
push 3
pop ebx
mov ecx, std_colors
push 40
pop edx
int 40h
; mov bl, 7
; int 40h
; xor ax, ax
; shr ebx, 16
; or ebx, eax
; mov ecx, [std_colors+16]
; mov edx, header
; push header.length
; pop esi
; push 4
; pop eax
; int 40h
xor ecx, ecx
call draw_image
push 12
pop eax
push 2
pop ebx
int 40h
ret
 
draw_image.nomem:
mov al, 13
xor edx, edx
mov ebx, [cur_width]
imul ebx, font_width
add ebx, 5*65536
mov ecx, [skinh-2]
mov cx, word [cur_height]
imul cx, font_height
int 40h
mov al, 4
mov ebx, 32*65536+32
mov ecx, 0xFFFFFF
mov edx, nomem_draw
push nomem_draw.size
pop esi
int 40h
ret
 
draw_image:
cmp [MemForImage], 0
jnz .allocated
; allocate memory for image
mov eax, [cur_width]
imul eax, [cur_height]
imul eax, font_width*font_height*3
call mf_alloc
test eax, eax
jz draw_image.nomem
mov [MemForImage], eax
.allocated:
mov edi, [MemForImage]
mov esi, console_data
mov ecx, [cur_height]
.lh:
push ecx
mov ecx, [cur_width]
.lw:
push ecx edi
xor eax, eax
mov al, [esi+1]
and al, 0xF
mov ebx, [console_colors + eax*4] ; 梥â ⥪áâ 
mov al, [esi+1]
shr al, 4
mov ebp, [console_colors + eax*4] ; 梥â ä®­ 
lodsb
inc esi
if font_width > 8
lea edx, [eax+eax+font]
else
lea edx, [eax+font]
end if
mov ecx, font_height
.sh:
push ecx edi
xor ecx, ecx
.sw:
mov eax, ebx
bt [edx], ecx
jc @f
mov eax, ebp
@@:
stosw
shr eax, 16
stosb
inc ecx
cmp ecx, font_width
jb .sw
pop edi ecx
mov eax, [cur_width]
imul eax, font_width*3
add edi, eax
if font_width > 8
add edx, 256*2
else
add edx, 256
end if
loop .sh
pop edi ecx
add edi, font_width*3
loop .lw
mov eax, [cur_width]
imul eax, (font_height-1)*font_width*3
add edi, eax
pop ecx
loop .lh
push 7
pop eax
mov ebx, [MemForImage]
mov ecx, [cur_width]
imul ecx, font_width*10000h
mov cx, word [cur_height]
imul cx, font_height
mov edx, [skinh]
add edx, 5*10000h
int 40h
ret
 
get_console_ptr:
; in: eax=x, edx=y
; out: edi->console data
push edx
imul edx, [cur_width]
add edx, eax
lea edi, [console_data + edx*2]
pop edx
ret
 
draw_keybar:
pushad
xor eax, eax
test [ctrlstate], 3
jz @f
inc eax
@@:
test [ctrlstate], 0xC
jz @f
or al, 2
@@:
test [ctrlstate], 0x30
jz @f
or al, 4
@@:
imul eax, 6*12
mov esi, [active_screen_vtable]
mov esi, [esi+screen_vtable.keybar]
add esi, eax
xor ecx, ecx
inc ecx
xor eax, eax
mov edx, [cur_height]
dec edx
call get_console_ptr
push 6
pop ebx
mov eax, [cur_width]
sub eax, 11+9+3*2+6
cmp eax, 7*11
jl @f
cdq
mov bl, 11
div ebx
mov ebx, eax
@@:
xor edx, edx
.l:
add edx, 7
cmp cl, 10
jb @f
inc edx
@@:
cmp edx, [cur_width]
ja .ret
cmp cl, 10
jae .twodig
lea eax, [ecx+'0']
stosb
mov al, [keybar_number_color]
stosb
jmp .cmn
.twodig:
mov al, cl
cbw
div [_10]
add al, '0'
stosb
mov al, [keybar_number_color]
stosb
xchg al, ah
add al, '0'
stosw
.cmn:
mov ah, [keybar_name_color]
push ecx
mov cl, 6
@@:
lodsb
stosw
loop @b
mov al, ' '
lea ecx, [ebx-6]
cmp byte [esp], 12
jz .ret_pop
add edx, ecx
rep stosw
pop ecx
inc edx
cmp edx, [cur_width]
ja .ret
mov ah, [keybar_bgr_color]
stosw
inc ecx
jmp .l
.ret_pop:
pop ecx
.ret:
cmp byte [edi-2], ' '
jnz @f
dec edi
dec edi
@@:
push edi
mov eax, [cur_width]
mov edx, [cur_height]
call get_console_ptr
mov ecx, edi
pop edi
sub ecx, edi
shr ecx, 1
mov al, ' '
mov ah, [keybar_name_color]
rep stosw
.done:
popad
ret
 
draw_cmdbar:
mov esi, [active_panel]
add esi, panel1_dir - panel1_data
xor eax, eax
mov edx, [cur_height]
dec edx
dec edx
call get_console_ptr
mov ah, [cmdbar_prefix_color]
mov ecx, [cur_width]
dec ecx
@@:
lodsb
test al, al
jz @f
stosw
loop @b
@@:
mov al, '>'
stosw
mov al, ' '
mov ah, [cmdbar_normal_color]
rep stosw
ret
 
draw_border:
push edi
mov al, 0xC9
stosw
mov al, 0xCD
lea ecx, [ebx-2]
rep stosw
mov al, 0xBB
stosw
pop edi
add edi, [cur_width]
add edi, [cur_width]
lea ecx, [edx-2]
.l:
push edi
mov al, 0xBA
stosw
mov al, 0x20
push ecx
lea ecx, [ebx-2]
rep stosw
pop ecx
mov al, 0xBA
stosw
pop edi
add edi, [cur_width]
add edi, [cur_width]
loop .l
mov al, 0xC8
stosw
mov al, 0xCD
lea ecx, [ebx-2]
rep stosw
mov al, 0xBC
stosw
ret
 
draw_panel:
mov eax, [ebp + panel1_left - panel1_data]
mov edx, [ebp + panel1_top - panel1_data]
call get_console_ptr
; draw border
mov ah, [panel_border_color]
mov ebx, [ebp + panel1_width - panel1_data]
mov edx, [ebp + panel1_height - panel1_data]
call draw_border
push eax
mov eax, [ebp + panel1_left - panel1_data]
mov edx, [ebp + panel1_top - panel1_data]
add edx, [ebp + panel1_height - panel1_data]
sub edx, 3
call get_console_ptr
pop eax
mov al, 0xC7
stosw
mov al, 0xC4
lea ecx, [ebx-2]
rep stosw
mov al, 0xB6
stosw
mov eax, [ebp + panel1_width - panel1_data]
sub eax, 3
shr eax, 1
mov [column_width], eax
mov eax, [ebp + panel1_left - panel1_data]
inc eax
mov [column_left], eax
add eax, [column_width]
mov edx, [ebp + panel1_top - panel1_data]
inc edx
mov [column_top], edx
dec edx
call get_console_ptr
mov ah, [panel_border_color]
mov al, 0xD1
mov [edi], ax
add edi, [cur_width]
add edi, [cur_width]
mov ecx, [ebp + panel1_height - panel1_data]
sub ecx, 4
mov [column_height], ecx
mov al, 0xB3
@@:
mov [edi], ax
add edi, [cur_width]
add edi, [cur_width]
loop @b
mov al, 0xC1
stosw
mov eax, [column_height]
dec eax
mov [ebp + panel1_colsz - panel1_data], eax
add eax, eax
mov [ebp + panel1_colst - panel1_data], eax
mov eax, [ebp + panel1_start - panel1_data]
mov [column_index], eax
call draw_column
mov eax, [ebp + panel1_width - panel1_data]
sub eax, 3
mov ecx, [column_width]
sub eax, ecx
mov [column_width], eax
inc ecx
add [column_left], ecx
call draw_column
; ‡ £®«®¢®ª ¯ ­¥«¨ (⥪ãé ï ¯ ¯ª )
lea esi, [ebp + panel1_dir - panel1_data]
mov edi, cur_header
mov ecx, [ebp + panel1_width - panel1_data]
sub ecx, 7
movsb
@@:
lodsb
stosb
dec ecx
test al, al
jz .header_created
cmp al, '/'
jnz @b
mov edx, esi
@@:
lodsb
test al, al
jnz @b
sub esi, edx
dec esi
cmp esi, ecx
jbe @f
mov word [edi], '..'
mov byte [edi+2], '.'
add edi, 3
sub ecx, 3
add edx, esi
sub edx, ecx
@@:
mov esi, edx
@@:
lodsb
stosb
dec ecx
test al, al
jnz @b
.header_created:
mov edx, [ebp + panel1_top - panel1_data]
mov eax, [ebp + panel1_left - panel1_data]
shr ecx, 1
lea eax, [eax+ecx+3]
call get_console_ptr
mov ah, [panel_active_header_color]
cmp ebp, [active_panel]
jz @f
mov ah, [panel_header_color]
@@:
mov al, ' '
stosw
mov esi, cur_header
@@:
lodsb
test al, al
jz @f
stosw
jmp @b
@@:
mov al, ' '
stosw
mov edx, [ebp + panel1_top - panel1_data]
inc edx
mov eax, [ebp + panel1_left - panel1_data]
inc eax
call get_console_ptr
movzx eax, [ebp + panel1_sortmode - panel1_data]
mov al, [compare_names+eax]
stosb
cmp [ebp + panel1_numfiles - panel1_data], 0
jz .skip_curinfo
; ˆ­ä®à¬ æ¨ï ® ¢ë¡à ­­®¬ ä ©«¥
mov ebx, [ebp + panel1_index - panel1_data]
mov eax, [ebp + panel1_files - panel1_data]
mov ebx, [eax+ebx*4]
mov eax, [ebp + panel1_nfa - panel1_data]
lea ebx, [ebx+eax*4+32]
add ebx, [ebp + panel1_files - panel1_data]
mov eax, [ebp + panel1_left - panel1_data]
add eax, [ebp + panel1_width - panel1_data]
dec eax
mov edx, [ebp + panel1_top - panel1_data]
add edx, [ebp + panel1_height - panel1_data]
dec edx
dec edx
call get_console_ptr
mov ecx, [ebp + panel1_width - panel1_data]
dec ecx
dec ecx
; ‚à¥¬ï ¬®¤¨ä¨ª æ¨¨
sub edi, 5*2
sub ecx, 6
mov al, [ebx+24+2]
aam
or ax, 0x3030
mov [edi], ah
mov [edi+2], al
mov [edi+4], byte ':'
mov al, [ebx+24+1]
aam
or ax, 0x3030
mov [edi+6], ah
mov [edi+8], al
mov al, [panel_normal_color]
mov [edi+1], al
mov [edi+3], al
mov [edi+5], al
mov [edi+7], al
mov [edi+9], al
dec edi
mov [edi], al
dec edi
mov byte [edi], ' '
; „ â  ¬®¤¨ä¨ª æ¨¨
sub edi, 8*2
sub ecx, 9
mov al, [ebx+28+0]
aam
or ax, 0x3030
mov [edi], ah
mov [edi+2], al
mov [edi+4], byte '.'
mov al, [ebx+28+1]
aam
or ax, 0x3030
mov [edi+6], ah
mov [edi+8], al
mov [edi+10], byte '.'
mov ax, [ebx+28+2]
div [_100]
mov al, ah
aam
or ax, 0x3030
mov [edi+12], ah
mov [edi+14], al
mov al, [panel_normal_color]
mov [edi+1], al
mov [edi+3], al
mov [edi+5], al
mov [edi+7], al
mov [edi+9], al
mov [edi+11], al
mov [edi+13], al
mov [edi+15], al
dec edi
mov [edi], al
dec edi
mov [edi], byte ' '
;  §¬¥à
std
mov ah, [panel_normal_color]
dec edi
dec edi
dec ecx
test byte [ebx], 0x10
jz .size_file
push ecx
mov esi, aFolder+aFolder.size-1
mov ecx, aFolder.size
cmp word [ebx+40], '..'
jnz @f
cmp byte [ebx+42], 0
jnz @f
mov esi, aUp+aUp.size-1
mov cl, aUp.size
@@:
sub [esp], ecx
@@:
lodsb
stosw
loop @b
pop ecx
jmp .size_done
.size_file:
mov edx, [ebx+36]
test edx, edx
jz .size_less_4g
cmp edx, 10*256
jae .size_tera
; ¢ £¨£ ¡ ©â å
mov al, 'G'
jmp .size_letter
.size_tera:
; ¢ â¥à ¡ ©â å
shr edx, 8
mov al, 'T'
jmp .size_letter
.size_less_4g:
mov edx, [ebx+32]
cmp edx, 10*(1 shl 20)
jae .size_mega
cmp edx, 1 shl 20
jb .size_num
shr edx, 10
mov al, 'K'
jmp .size_letter
.size_mega:
mov al, 'M'
shr edx, 20
.size_letter:
stosw
dec ecx
mov al, ' '
stosw
dec ecx
.size_num:
xchg eax, edx
xor edx, edx
div [_10d]
xchg eax, edx
add al, '0'
mov ah, [panel_normal_color]
stosw
dec ecx
test edx, edx
jnz .size_num
.size_done:
cld
; ˆ¬ï
sub edi, ecx
sub edi, ecx
lea esi, [ebx+40]
@@:
lodsb
test al, al
jnz @b
sub esi, ebx
sub esi, 41
mov ah, [panel_normal_color]
cmp esi, ecx
lea edx, [ebx+40]
jbe @f
mov al, '{'
mov [edi-2], ax
add edx, esi
sub edx, ecx
@@:
mov esi, edx
@@:
lodsb
test al, al
jz @f
stosw
loop @b
@@:
mov al, ' '
rep stosw
.skip_curinfo:
call draw_image
ret
 
draw_column:
mov eax, [column_left]
mov edx, [column_top]
call get_console_ptr
; § £®«®¢®ª á⮫¡æ 
push edi
mov ah, [column_header_color]
mov al, ' '
mov ecx, [column_width]
if lang eq ru
sub ecx, 3
else
sub ecx, 4
end if
shr ecx, 1
rep stosw
if lang eq ru
mov al, 'ˆ'
stosw
mov al, '¬'
stosw
mov al, 'ï'
stosw
else
mov al, 'N'
stosw
mov al, 'a'
stosw
mov al, 'm'
stosw
mov al, 'e'
stosw
end if
mov al, ' '
mov ecx, [column_width]
if lang eq ru
sub ecx, 2
else
sub ecx, 3
end if
shr ecx, 1
rep stosw
pop edi
add edi, [cur_width]
add edi, [cur_width]
; ä ©«ë
mov edx, [ebp + panel1_numfiles - panel1_data]
mov ecx, [column_height]
dec ecx
.l:
cmp [column_index], edx
jae .ret
push ecx
mov esi, [column_index]
mov ecx, [ebp + panel1_files - panel1_data]
mov esi, [ecx+esi*4]
mov ecx, [ebp + panel1_nfa - panel1_data]
lea esi, [esi + ecx*4 + 32 + 40]
add esi, [ebp + panel1_files - panel1_data]
; ¯®¤á¢¥âª 
; call insert_last_dot
xor ecx, ecx
.highlight_test_loop:
mov ebx, [highlight_groups+ecx*4]
mov al, [ebx + highlight.IncludeAttributes]
mov ah, [esi - 40]
and ah, al
cmp ah, al
jnz .highlight_test_failed
push edi
lea edi, [ebx + highlight.Mask]
call match_mask
pop edi
jc .highlight_test_failed
mov ah, [ebx + highlight.NormalColor]
cmp ebp, [active_panel]
jnz @f
mov ecx, [column_index]
cmp ecx, [ebp + panel1_index - panel1_data]
jnz @f
mov ah, [ebx + highlight.CursorColor]
@@:
test ah, ah
jz .nohighlight
jmp .doname
.highlight_test_failed:
inc ecx
cmp ecx, [highlight_num_groups]
jb .highlight_test_loop
.nohighlight:
mov ah, [panel_normal_color]
cmp ebp, [active_panel]
jnz @f
mov ecx, [column_index]
cmp ecx, [ebp + panel1_index - panel1_data]
jnz @f
mov ah, [panel_cursor_color]
@@:
.doname:
; call delete_last_dot
mov ecx, [column_width]
push edi
@@:
lodsb
test al, al
jz @f
stosw
loop @b
cmp byte [esi], 0
jz @f
mov byte [edi], '}'
@@:
mov al, ' '
rep stosw
pop edi
add edi, [cur_width]
add edi, [cur_width]
inc [column_index]
pop ecx
dec ecx
jnz .l
.ret:
cmp ebp, panel1_data
jnz .ret2
; —¨á«® íªà ­®¢
mov eax, [num_screens]
dec eax
jz .ret2
push eax
xor eax, eax
xor edx, edx
call get_console_ptr
mov ah, [panel_nscreens_color]
mov al, '['
stosw
pop eax
push -'0'
@@:
xor edx, edx
div [_10d]
push edx
test eax, eax
jnz @b
@@:
pop eax
add eax, '0'
jz @f
mov ah, [panel_nscreens_color]
stosw
jmp @b
@@:
mov al, ']'
mov ah, [panel_nscreens_color]
stosw
.ret2:
ret
 
;insert_last_dot:
; push eax esi
; mov ah, 0
;.loop:
; lodsb
; test al, al
; jz .done
; cmp al, '.'
; jnz .loop
; mov ah, 1
; jmp .loop
;.done:
; test ah, ah
; jnz @f
; mov byte [esi-1], '.'
; mov byte [esi], 0
;@@:
; pop esi eax
; ret
 
;delete_last_dot:
; push esi
;@@:
; cmp byte [esi], 0
; jz @f
; inc esi
; jmp @b
;@@:
; cmp byte [esi-1], '.'
; jnz @f
; mov byte [esi-1], 0
;@@: pop esi
; ret
 
read_folder:
mov eax, [ebp + panel1_nfa - panel1_data]
mov [dirinfo.size], eax
shl eax, 2
add eax, [ebp + panel1_files - panel1_data]
mov [dirinfo.dirdata], eax
lea eax, [ebp + panel1_dir - panel1_data]
mov [dirinfo.name], eax
push 70
pop eax
mov ebx, dirinfo
int 40h
test eax, eax
jz .ok
cmp eax, 6
jz .ok
; TODO: add error handling
mov [ebp + panel1_numfiles - panel1_data], 2
mov eax, [ebp + panel1_nfa - panel1_data]
shl eax, 2
add eax, [ebp + panel1_files - panel1_data]
add eax, 32+40
mov word [eax], '..'
mov byte [eax+2], 0
add eax, 304
mov dword [eax], 'Read'
mov dword [eax+4], ' err'
mov dword [eax+8], 'or'
mov eax, [ebp + panel1_files - panel1_data]
mov dword [eax], 0
mov dword [eax+4], 304
and dword [ebp + panel1_index - panel1_data], 0
and dword [ebp + panel1_start - panel1_data], 0
ret
.ok:
mov eax, [dirinfo.dirdata]
cmp [eax+8], ebx
jz .readdone
push eax
mov eax, [ebp + panel1_files - panel1_data]
cmp eax, buf1
jz @f
cmp eax, buf2
jz @f
call mf_free
@@:
pop eax
mov eax, [eax+8]
add eax, 0xF
and eax, not 0xF
push eax
imul eax, 4+304
add eax, 32
call mf_alloc
test eax, eax
jnz .succ1
pop eax
; TODO: add error handling
jmp .readdone
.succ1:
mov [ebp + panel1_files - panel1_data], eax
pop [ebp + panel1_nfa - panel1_data]
jmp read_folder
.readdone:
and [ebp + panel1_start - panel1_data], 0
and [ebp + panel1_index - panel1_data], 0
and [ebp + panel1_start - panel1_data], 0
mov edi, [ebp + panel1_files - panel1_data]
mov eax, [ebp + panel1_nfa - panel1_data]
lea esi, [edi + eax*4 + 32]
xor eax, eax
mov ecx, [esi-32+4]
jecxz .loopdone
; ˆ£­®à¨à㥬 ᯥ樠«ì­ë¥ ¢å®¤ë, ᮮ⢥âáâ¢ãî騥 ¯ ¯ª¥ '.' ¨ ¬¥âª¥ ⮬ 
.ptrinit:
cmp word [esi+eax+40], '.'
jz .loopcont
test byte [esi+eax], 8
jnz .loopcont
stosd
.loopcont:
add eax, 304
loop .ptrinit
.loopdone:
sub edi, [ebp + panel1_files - panel1_data]
shr edi, 2
mov [ebp + panel1_numfiles - panel1_data], edi
.done:
; ‘®àâ¨à®¢ª 
sort_files:
movzx eax, [ebp + panel1_sortmode - panel1_data]
mov ebx, [compare_fns + eax*4]
mov edx, [ebp + panel1_files - panel1_data]
mov ecx, [ebp + panel1_numfiles - panel1_data]
call sort
ret
 
compare_name:
push eax
mov eax, [ebp + panel1_nfa - panel1_data]
add esi, [ebp + panel1_files - panel1_data]
add edi, [ebp + panel1_files - panel1_data]
lea esi, [esi+eax*4+0x20]
lea edi, [edi+eax*4+0x20]
pop eax
cmp word [esi+40], '..'
jnz @f
cmp byte [esi+42], 0
jz .less
@@: cmp word [edi+40], '..'
jnz @f
cmp byte [edi+42], 0
jz .greater
@@:
test byte [esi], 10h
jnz .1dir
test byte [edi], 10h
jnz .greater
.eq1:
add esi, 40
add edi, 40
jmp strcmpi
.greater:
test esi, esi
ret
.1dir:
test byte [edi], 10h
jnz .eq1
.less:
xor edi, edi
stc
ret
 
compare_name_rev:
push eax
mov eax, [ebp + panel1_nfa - panel1_data]
add esi, [ebp + panel1_files - panel1_data]
add edi, [ebp + panel1_files - panel1_data]
lea esi, [esi+eax*4+0x20]
lea edi, [edi+eax*4+0x20]
pop eax
cmp word [esi+40], '..'
jnz @f
cmp byte [esi+42], 0
jz .less
@@: cmp word [edi+40], '..'
jnz @f
cmp byte [edi+42], 0
jz .greater
@@:
test byte [esi], 10h
jnz .1dir
test byte [edi], 10h
jnz .greater
.eq1:
add esi, 40
add edi, 40
xchg esi, edi
jmp strcmpi
.greater:
test esi, esi
ret
.1dir:
test byte [edi], 10h
jnz .eq1
.less:
xor edi, edi
stc
ret
 
strcmpi:
push eax
@@:
lodsb
call match_symbol
jnz .ret
inc edi
test al, al
jnz @b
.ret:
pop eax
ret
 
compare_ext:
push eax
mov eax, [ebp + panel1_nfa - panel1_data]
add esi, [ebp + panel1_files - panel1_data]
add edi, [ebp + panel1_files - panel1_data]
lea esi, [esi+eax*4+0x20]
lea edi, [edi+eax*4+0x20]
pop eax
cmp word [esi+40], '..'
jnz @f
cmp byte [esi+42], 0
jz .less
@@: cmp word [edi+40], '..'
jnz @f
cmp byte [edi+42], 0
jz .greater
@@:
test byte [esi], 10h
jnz .1dir
test byte [edi], 10h
jnz .greater
.eq1:
add esi, 40
add edi, 40
push esi edi
call seek_ext
xchg esi, edi
call seek_ext
xchg esi, edi
call strcmpi
jnz .ret
pop edi esi
jmp strcmpi
.ret:
pop edi esi
ret
.greater:
test esi, esi
ret
.1dir:
test byte [edi], 10h
jnz .eq1
.less:
xor edi, edi
stc
ret
 
compare_ext_rev:
push eax
mov eax, [ebp + panel1_nfa - panel1_data]
add esi, [ebp + panel1_files - panel1_data]
add edi, [ebp + panel1_files - panel1_data]
lea esi, [esi+eax*4+0x20]
lea edi, [edi+eax*4+0x20]
pop eax
cmp word [esi+40], '..'
jnz @f
cmp byte [esi+42], 0
jz .less
@@: cmp word [edi+40], '..'
jnz @f
cmp byte [edi+42], 0
jz .greater
@@:
test byte [esi], 10h
jnz .1dir
test byte [edi], 10h
jnz .greater
.eq1:
add esi, 40
add edi, 40
push esi edi
call seek_ext
xchg esi, edi
call seek_ext
call strcmpi
jnz .ret
pop edi esi
xchg esi, edi
jmp strcmpi
.ret:
pop edi esi
ret
.greater:
test esi, esi
ret
.1dir:
test byte [edi], 10h
jnz .eq1
.less:
xor edi, edi
stc
ret
 
seek_ext:
push eax
xor eax, eax
.l:
inc esi
cmp byte [esi-1], '.'
jnz @f
mov eax, esi
@@:
cmp byte [esi-1], 0
jnz .l
test eax, eax
jnz @f
lea eax, [esi-1]
@@:
mov esi, eax
pop eax
ret
 
compare_modified:
push eax
mov eax, [ebp + panel1_nfa - panel1_data]
add esi, [ebp + panel1_files - panel1_data]
add edi, [ebp + panel1_files - panel1_data]
lea esi, [esi+eax*4+0x20]
lea edi, [edi+eax*4+0x20]
pop eax
cmp word [esi+40], '..'
jnz @f
cmp byte [esi+42], 0
jz .less
@@: cmp word [edi+40], '..'
jnz @f
cmp byte [edi+42], 0
jz .greater
@@:
test byte [esi], 10h
jnz .1dir
test byte [edi], 10h
jnz .greater
.eq1:
push edi
mov edi, [edi+28]
cmp edi, [esi+28]
pop edi
jnz @f
push edi
mov edi, [edi+24]
cmp edi, [esi+24]
pop edi
jnz @f
add esi, 40
add edi, 40
jmp strcmpi
@@:
ret
.greater:
test esi, esi
ret
.1dir:
test byte [edi], 10h
jnz .eq1
.less:
xor edi, edi
stc
ret
 
compare_modified_rev:
push eax
mov eax, [ebp + panel1_nfa - panel1_data]
add esi, [ebp + panel1_files - panel1_data]
add edi, [ebp + panel1_files - panel1_data]
lea esi, [esi+eax*4+0x20]
lea edi, [edi+eax*4+0x20]
pop eax
cmp word [esi+40], '..'
jnz @f
cmp byte [esi+42], 0
jz .less
@@: cmp word [edi+40], '..'
jnz @f
cmp byte [edi+42], 0
jz .greater
@@:
test byte [esi], 10h
jnz .1dir
test byte [edi], 10h
jnz .greater
.eq1:
push esi
mov esi, [esi+28]
cmp esi, [edi+28]
pop esi
jnz @f
push esi
mov esi, [esi+24]
cmp esi, [edi+24]
pop esi
jnz @f
add esi, 40
add edi, 40
xchg esi, edi
jmp strcmpi
@@:
ret
.greater:
test esi, esi
ret
.1dir:
test byte [edi], 10h
jnz .eq1
.less:
xor edi, edi
stc
ret
 
compare_size:
push eax
mov eax, [ebp + panel1_nfa - panel1_data]
add esi, [ebp + panel1_files - panel1_data]
add edi, [ebp + panel1_files - panel1_data]
lea esi, [esi+eax*4+0x20]
lea edi, [edi+eax*4+0x20]
pop eax
cmp word [esi+40], '..'
jnz @f
cmp byte [esi+42], 0
jz .less
@@: cmp word [edi+40], '..'
jnz @f
cmp byte [edi+42], 0
jz .greater
@@:
test byte [esi], 10h
jnz .1dir
test byte [edi], 10h
jnz .greater
.eq1:
push edi
mov edi, [edi+36]
cmp edi, [esi+36]
pop edi
jnz @f
push edi
mov edi, [edi+32]
cmp edi, [esi+32]
pop edi
jnz @f
add esi, 40
add edi, 40
jmp strcmpi
@@:
ret
.greater:
test esi, esi
ret
.1dir:
test byte [edi], 10h
jnz .eq1
.less:
xor edi, edi
stc
ret
 
compare_size_rev:
push eax
mov eax, [ebp + panel1_nfa - panel1_data]
add esi, [ebp + panel1_files - panel1_data]
add edi, [ebp + panel1_files - panel1_data]
lea esi, [esi+eax*4+0x20]
lea edi, [edi+eax*4+0x20]
pop eax
cmp word [esi+40], '..'
jnz @f
cmp byte [esi+42], 0
jz .less
@@: cmp word [edi+40], '..'
jnz @f
cmp byte [edi+42], 0
jz .greater
@@:
test byte [esi], 10h
jnz .1dir
test byte [edi], 10h
jnz .greater
.eq1:
push esi
mov esi, [esi+36]
cmp esi, [edi+36]
pop esi
jnz @f
push esi
mov esi, [esi+32]
cmp esi, [edi+32]
pop esi
jnz @f
add esi, 40
add edi, 40
xchg esi, edi
jmp strcmpi
@@:
ret
.greater:
test esi, esi
ret
.1dir:
test byte [edi], 10h
jnz .eq1
.less:
xor edi, edi
stc
ret
 
compare_unordered:
cmp esi, edi
ret
compare_unordered_rev:
push eax
mov eax, [ebp + panel1_nfa - panel1_data]
add esi, [ebp + panel1_files - panel1_data]
add edi, [ebp + panel1_files - panel1_data]
lea esi, [esi+eax*4+0x20]
lea edi, [edi+eax*4+0x20]
pop eax
cmp word [esi+40], '..'
jnz @f
cmp byte [esi+42], 0
jz .less
@@: cmp word [edi+40], '..'
jnz @f
cmp byte [edi+42], 0
jz .greater
@@:
cmp edi, esi
ret
.greater:
test esi, esi
ret
.less:
xor edi, edi
stc
ret
 
compare_created:
push eax
mov eax, [ebp + panel1_nfa - panel1_data]
add esi, [ebp + panel1_files - panel1_data]
add edi, [ebp + panel1_files - panel1_data]
lea esi, [esi+eax*4+0x20]
lea edi, [edi+eax*4+0x20]
pop eax
cmp word [esi+40], '..'
jnz @f
cmp byte [esi+42], 0
jz .less
@@: cmp word [edi+40], '..'
jnz @f
cmp byte [edi+42], 0
jz .greater
@@:
test byte [esi], 10h
jnz .1dir
test byte [edi], 10h
jnz .greater
.eq1:
push edi
mov edi, [edi+12]
cmp edi, [esi+12]
pop edi
jnz @f
push edi
mov edi, [edi+8]
cmp edi, [esi+8]
pop edi
jnz @f
add esi, 40
add edi, 40
jmp strcmpi
@@:
ret
.greater:
test esi, esi
ret
.1dir:
test byte [edi], 10h
jnz .eq1
.less:
xor edi, edi
stc
ret
 
compare_created_rev:
push eax
mov eax, [ebp + panel1_nfa - panel1_data]
add esi, [ebp + panel1_files - panel1_data]
add edi, [ebp + panel1_files - panel1_data]
lea esi, [esi+eax*4+0x20]
lea edi, [edi+eax*4+0x20]
pop eax
cmp word [esi+40], '..'
jnz @f
cmp byte [esi+42], 0
jz .less
@@: cmp word [edi+40], '..'
jnz @f
cmp byte [edi+42], 0
jz .greater
@@:
test byte [esi], 10h
jnz .1dir
test byte [edi], 10h
jnz .greater
.eq1:
push esi
mov esi, [esi+12]
cmp esi, [edi+12]
pop esi
jnz @f
push esi
mov esi, [esi+8]
cmp esi, [edi+8]
pop esi
jnz @f
add esi, 40
add edi, 40
xchg esi, edi
jmp strcmpi
@@:
ret
.greater:
test esi, esi
ret
.1dir:
test byte [edi], 10h
jnz .eq1
.less:
xor edi, edi
stc
ret
 
compare_accessed:
push eax
mov eax, [ebp + panel1_nfa - panel1_data]
add esi, [ebp + panel1_files - panel1_data]
add edi, [ebp + panel1_files - panel1_data]
lea esi, [esi+eax*4+0x20]
lea edi, [edi+eax*4+0x20]
pop eax
cmp word [esi+40], '..'
jnz @f
cmp byte [esi+42], 0
jz .less
@@: cmp word [edi+40], '..'
jnz @f
cmp byte [edi+42], 0
jz .greater
@@:
test byte [esi], 10h
jnz .1dir
test byte [edi], 10h
jnz .greater
.eq1:
push edi
mov edi, [edi+20]
cmp edi, [esi+20]
pop edi
jnz @f
push edi
mov edi, [edi+16]
cmp edi, [esi+16]
pop edi
jnz @f
add esi, 40
add edi, 40
jmp strcmpi
@@:
ret
.greater:
test esi, esi
ret
.1dir:
test byte [edi], 10h
jnz .eq1
.less:
xor edi, edi
stc
ret
 
compare_accessed_rev:
push eax
mov eax, [ebp + panel1_nfa - panel1_data]
add esi, [ebp + panel1_files - panel1_data]
add edi, [ebp + panel1_files - panel1_data]
lea esi, [esi+eax*4+0x20]
lea edi, [edi+eax*4+0x20]
pop eax
cmp word [esi+40], '..'
jnz @f
cmp byte [esi+42], 0
jz .less
@@: cmp word [edi+40], '..'
jnz @f
cmp byte [edi+42], 0
jz .greater
@@:
test byte [esi], 10h
jnz .1dir
test byte [edi], 10h
jnz .greater
.eq1:
push esi
mov esi, [esi+20]
cmp esi, [edi+20]
pop esi
jnz @f
push esi
mov esi, [esi+16]
cmp esi, [edi+16]
pop esi
jnz @f
add esi, 40
add edi, 40
xchg esi, edi
jmp strcmpi
@@:
ret
.greater:
test esi, esi
ret
.1dir:
test byte [edi], 10h
jnz .eq1
.less:
xor edi, edi
stc
ret
 
match_mask:
; in: esi->name, edi->mask
; out: CF clear <=> match
pusha
xchg esi, edi
.main_cycle:
push esi
@@:
lodsb
test al, al
jz @f
cmp al, ','
jz @f
cmp al, '|'
jnz @b
@@:
mov [esi-1], byte 0
xchg esi, [esp]
call match_single_mask
pop esi
mov [esi-1], al
jnc .found
cmp al, ','
jz .main_cycle
.done_fail:
stc
popa
ret
.found:
test al, al
jz .done_succ
cmp al, '|'
jz .test_exclude
lodsb
jmp .found
.done_succ:
clc
popa
ret
.test_exclude:
push esi
@@:
lodsb
test al, al
jz @f
cmp al, ','
jnz @b
@@:
mov byte [esi-1], 0
xchg esi, [esp]
call match_single_mask
pop esi
mov [esi-1], al
jnc .done_fail
test al, al
jz .done_succ
jmp .test_exclude
 
match_single_mask:
; in: esi->mask, edi->name
; out: CF clear <=> match
pusha
.mask_symbol:
lodsb
test al, al
jz .mask_done
cmp al, '*'
jz .asterisk
cmp al, '?'
jz .quest
cmp al, '['
jz .list
call match_symbol
jnz .done_fail
inc edi
jmp .mask_symbol
.done_fail:
stc
popa
ret
.mask_done:
scasb
jnz .done_fail
.done_succ:
clc
popa
ret
.quest:
mov al, 0
scasb
jz .done_fail
jmp .mask_symbol
.list:
lodsb
cmp al, ']'
jz .done_fail
cmp byte [esi+1], '-'
jz .range
call match_symbol
jnz .list
.listok:
inc edi
@@:
lodsb
cmp al, ']'
jnz @b
jmp .mask_symbol
.range:
call match_symbol
ja @f
mov al, [esi+2]
call match_symbol
jae .listok
@@:
inc esi
jmp .list
.asterisk:
push edi
@@:
call match_single_mask
jnc @f
mov al, 0
scasb
jnz @b
pop edi
jmp .done_fail
@@:
pop edi
jmp .done_succ
 
tolower:
cmp al, 'A'
jb @f
cmp al, 'Z'
ja @f
add al, ' '
@@: ret
 
match_symbol:
; in: al,[edi]=symbols
; out: flags as 'cmp al,[edi]'
push eax
call tolower
mov ah, [edi]
xchg al, ah
call tolower
cmp ah, al
pop eax
ret
 
 
header db 'Kolibri Far 0.13'
;.length = $ - header
db 0
 
nomem_draw db 'No memory for redraw.',0
.size = $ - nomem_draw
 
def_left_dir db '/rd/1',0
def_right_dir db '/hd0/1',0
 
if lang eq ru
aFolder db ' ¯ª '
.size = $-aFolder
aUp db '‚¢¥àå'
.size = $-aUp
aDrive db '„¨áª',0
aScreens db 'ªà ­ë',0
else
aFolder db 'Folder'
.size = $-aFolder
aUp db 'Up'
.size = $-aUp
aDrive db 'Drive',0
aScreens db 'Screens',0
end if
 
_10d dd 10
_100d dd 100
_10 db 10
_100 db 100
 
fpu_cw dw 000011100111111b
 
keybar_panels:
if lang eq ru
; ¡¥§ ª« ¢¨è-¬®¤¨ä¨ª â®à®¢
db '®¬®éì'
db '®«ì§Œ'
db 'à®á¬ '
db '¥¤ ªâ'
db 'Š®¯¨à '
db '¥à¥­ '
db ' ¯ª  '
db '“¤ «¥­'
db 'Š®­äŒ­'
db '‚ë室 '
db 'Œ®¤ã«¨'
db 'ªà ­ë'
; Shift
db '„®¡ ¢«'
db ' á¯ ª'
db '€à劮¬'
db '¥¤ ª.'
db 'Š®¯¨à '
db '¥à¥¨¬'
db ' '
db '“¤ «¥­'
db '‘®åà ­'
db '®á«¤­'
db 'ƒà㯯ë'
db '‚ë¡à ­'
; Ctrl
db '‹¥¢ ï '
db 'à ¢ ï'
db 'ˆ¬ï '
db ' áè¨à'
db 'Œ®¤¨ä '
db ' §¬¥à'
db '¥á®àâ'
db '‘®§¤ ­'
db '„®áâã¯'
db 'Ž¯¨á ­'
db '‚« ¤¥«'
db '‘®àâ '
; Ctrl+Shift
db ' '
db ' '
db 'à®á¬ '
db '¥¤ ªâ'
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
; Alt
db '‹¥¢ ï '
db 'à ¢ ï'
db '‘¬®âà.'
db '¥¤ ª.'
db '¥ç âì'
db '‘¢ï§ì '
db 'ˆáª âì'
db 'ˆáâ®à '
db '‚¨¤¥® '
db '„¥à¥¢®'
db 'ˆáâà '
db 'ˆá⏠¯'
; Alt+Shift
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db 'Š®­ä«'
db ' '
db ' '
db ' '
; Alt+Ctrl
times 12 db ' '
; Alt+Ctrl+Shift
times 12 db ' '
else
; No modificators
db 'Help '
db 'UserMn'
db 'View '
db 'Edit '
db 'Copy '
db 'RenMov'
db 'MkFold'
db 'Delete'
db 'ConfMn'
db 'Quit '
db 'Plugin'
db 'Screen'
; Shift
db 'Add '
db 'Extrct'
db 'ArcCmd'
db 'Edit..'
db 'Copy '
db 'Rename'
db ' '
db 'Delete'
db 'Save '
db 'Last '
db 'Group '
db 'SelUp '
; Ctrl
db 'Left '
db 'Right '
db 'Name '
db 'Extens'
db 'Modifn'
db 'Size '
db 'Unsort'
db 'Creatn'
db 'Access'
db 'Descr '
db 'Owner '
db 'Sort '
; Ctrl+Shift
db ' '
db ' '
db 'View '
db 'Edit '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
; Alt
db 'Left '
db 'Right '
db 'View..'
db 'Edit..'
db 'Print '
db 'MkLink'
db 'Find '
db 'Histry'
db 'Video '
db 'Tree '
db 'ViewHs'
db 'FoldHs'
; Alt+Shift
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db 'ConfPl'
db ' '
db ' '
db ' '
; Alt+Ctrl
times 12 db ' '
; Alt+Ctrl+Shift
times 12 db ' '
end if
 
keybar_viewer:
if lang eq ru
; ¡¥§ ª« ¢¨è-¬®¤¨ä¨ª â®à®¢
db '®¬®éì'
db ' §¢¥à'
db '‚ë室 '
db 'Š®¤ '
db ' '
db '¥¤ ªâ'
db '®¨áª '
keybar_cp:
db 'cp1251'
db ' '
db '‚ë室 '
db 'Œ®¤ã«¨'
db 'ªà ­ë'
; Shift
db ' '
db '‘«®¢  '
db ' '
db ' '
db ' '
db ' '
db '„ «ìè¥'
db '’ ¡«¨æ'
db ' '
db ' '
db ' '
db ' '
; Ctrl
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db '®§¨æ '
db ' '
db ' '
; Ctrl+Shift
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
; Alt
db ' '
db ' '
db ' '
db ' '
db '¥ç âì'
db ' '
db ' § ¤ '
db '¥à¥©â'
db '‚¨¤¥® '
db ' '
db 'ˆáâà '
db ' '
; Alt+Shift
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db 'Š®­ä¨£'
db ' '
db ' '
db ' '
; Alt+Ctrl
times 12 db ' '
; Alt+Ctrl+Shift
times 12 db ' '
else
; No modificators
db 'Help '
db 'Unwrap'
db 'Quit '
db 'Hex '
db ' '
db 'Edit '
db 'Search'
keybar_cp:
db 'cp1251'
db ' '
db 'Quit '
db 'Plugin'
db 'Screen'
; Shift
db ' '
db 'WWrap '
db ' '
db ' '
db ' '
db ' '
db 'Next '
db 'Table '
db ' '
db ' '
db ' '
db ' '
; Ctrl
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db 'GoFile'
db ' '
db ' '
; Ctrl+Shift
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
; Alt
db ' '
db ' '
db ' '
db ' '
db 'Print '
db ' '
db 'Prev '
db 'Goto '
db 'Video '
db ' '
db 'ViewHs'
db ' '
; Alt+Shift
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db ' '
db 'Config'
db ' '
db ' '
db ' '
; Alt+Ctrl
times 12 db ' '
; Alt+Ctrl+Shift
times 12 db ' '
end if
 
align 4
cur_width dd 80
cur_height dd 25
max_width = 256
max_height = 256
 
active_panel dd panel1_data
 
console_colors dd 0x000000, 0x000080, 0x008000, 0x008080
dd 0x800000, 0x800080, 0x808000, 0xC0C0C0
dd 0x808080, 0x0000FF, 0x00FF00, 0x00FFFF
dd 0xFF0000, 0xFF00FF, 0xFFFF00, 0xFFFFFF
 
compare_fns dd compare_name
dd compare_name_rev
dd compare_ext
dd compare_ext_rev
dd compare_modified
dd compare_modified_rev
dd compare_size
dd compare_size_rev
dd compare_unordered
dd compare_unordered_rev
dd compare_created
dd compare_created_rev
dd compare_accessed
dd compare_accessed_rev
 
ctrlkey_tests dd ctrlkey_test0
dd ctrlkey_test1
dd ctrlkey_test2
dd ctrlkey_test3
dd ctrlkey_test4
ctrlkey_tests_num = 5
 
virtual at 0
screen_vtable:
.OnRedraw dd ?
.OnKey dd ?
.keybar dd ?
.getname dd ?
end virtual
 
panels_vtable:
dd panels_OnRedraw
dd panels_OnKey
dd keybar_panels
dd panels_getname
 
viewer_vtable:
dd viewer_OnRedraw
dd viewer_OnKey
dd keybar_viewer
dd viewer_getname
 
encodings:
.cp866 = 0
.cp1251 = 1
 
.names:
db 'cp866 '
db 'cp1251 '
 
.tables:
; cp866 - trivial map
times 128 db %+127
; cp1251
db 0x3F,0x3F,0x27,0x3F,0x22,0x3A,0xC5,0xD8,0x3F,0x25,0x3F,0x3C,0x3F,0x3F,0x3F,0x3F
db 0x3F,0x27,0x27,0x22,0x22,0x07,0x2D,0x2D,0x3F,0x54,0x3F,0x3E,0x3F,0x3F,0x3F,0x3F
db 0xFF,0xF6,0xF7,0x3F,0xFD,0x3F,0xB3,0x15,0xF0,0x63,0xF2,0x3C,0xBF,0x2D,0x52,0xF4
db 0xF8,0x2B,0x49,0x69,0x3F,0xE7,0x14,0xFA,0xF1,0xFC,0xF3,0x3E,0x3F,0x3F,0x3F,0xF5
times 0x30 db %-1+0x80
times 0x10 db %-1+0xE0
 
active_screen dd 0
tabsize dd 8
 
ascii2scan:
times 32 db 0
db 0x39,0x02,0x03,0x04,0x05,0x06,0x08,0x28,0x0A,0x0B,0x09,0x0D,0x33,0x0C,0x34,0x35
db 0x0B,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x27,0x27,0x33,0x0D,0x34,0x35
db 0x03,0x1E,0x30,0x2E,0x20,0x12,0x21,0x22,0x23,0x17,0x24,0x25,0x26,0x32,0x31,0x18
db 0x19,0x10,0x13,0x1F,0x14,0x16,0x2F,0x11,0x2D,0x15,0x2C,0x1A,0x2B,0x1B,0x07,0x0C
db 0x29,0x1E,0x30,0x2E,0x20,0x12,0x21,0x22,0x23,0x17,0x24,0x25,0x26,0x32,0x31,0x18
db 0x19,0x10,0x13,0x1F,0x14,0x16,0x2F,0x11,0x2D,0x15,0x2C,0x1A,0x2B,0x1B,0x29,0x00
db 0x21,0x33,0x20,0x16,0x26,0x14,0x27,0x19,0x30,0x10,0x13,0x25,0x2F,0x15,0x24,0x22
db 0x23,0x2E,0x31,0x12,0x1E,0x1A,0x11,0x2D,0x17,0x18,0x1B,0x1F,0x32,0x28,0x34,0x2C
db 0x21,0x33,0x20,0x16,0x26,0x14,0x27,0x19,0x30,0x10,0x13,0x25,0x2F,0x15,0x24,0x22
times 48 db 0
db 0x23,0x2E,0x31,0x12,0x1E,0x1A,0x11,0x2D,0x17,0x18,0x1B,0x1F,0x32,0x28,0x34,0x2C
db 0x29,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
 
; Š« ¢¨è­ë¥ á®ç¥â ­¨ï
; db scancode, reserved
; dw ctrlstate
; dd handler
; ctrlstate: ¬« ¤è¨¥ 4 ¡¨â  - ¤«ï Shift, á«¥¤ãî騥 - ¤«ï Ctrl, á«¥¤ãî騥 - ¤«ï Alt
; 0 = ­¨ ®¤­  ª« ¢¨è  ­¥ ­ ¦ â 
; 1 = ஢­® ®¤­  ­ ¦ â 
; 2 = ®¡¥ ­ ¦ âë
; 3 = «¥¢ ï ­ ¦ â , ¯à ¢ ï ­¥â
; 4 = ¯à ¢ ï ­ ¦ â , «¥¢ ï ­¥â
panels_ctrlkeys:
dw 0x48, 0
dd panels_OnKey.up
dw 0x50, 0
dd panels_OnKey.down
dw 0x4B, 0
dd panels_OnKey.left
dw 0x4D, 0
dd panels_OnKey.right
dw 0xF, 0
dd panels_OnKey.tab
dw 0x47, 0
dd panels_OnKey.home
dw 0x4F, 0
dd panels_OnKey.end
dw 0x1C, 0
dd panels_OnKey.enter
dw 0x3D, 0
dd panels_OnKey.f3
dw 0x42, 0
dd panels_OnKey.f8
dw 0x44, 0
dd exit
repeat 9-3+1
dw 0x3D+%-1, 0x10
dd panels_OnKey.ctrl_f39
end repeat
dw 0x3B, 0x100
dd panels_OnKey.alt_f12
dw 0x3C, 0x100
dd panels_OnKey.alt_f12
dw 0x58, 0
dd F12
dw 0x13, 0x10
dd panels_OnKey.ctrl_r
db 0
 
viewer_ctrlkeys:
dw 1, 0
dd viewer_OnKey.exit
dw 0x51, 0
dd viewer_OnKey.pgdn
dw 0x49, 0
dd viewer_OnKey.pgup
dw 0x50, 0
dd viewer_OnKey.down
dw 0x48, 0
dd viewer_OnKey.up
dw 0x4B, 0
dd viewer_OnKey.left
dw 0x4B, 0x10
dd viewer_OnKey.ctrl_left
dw 0x4B, 0x11
dd viewer_OnKey.ctrl_shift_left
dw 0x4C, 0
dd viewer_OnKey.exit
dw 0x4D, 0
dd viewer_OnKey.right
dw 0x4D, 0x10
dd viewer_OnKey.ctrl_right
dw 0x4D, 0x11
dd viewer_OnKey.ctrl_shift_right
dw 0x3C, 0
dd viewer_OnKey.f2
dw 0x3D, 0
dd viewer_OnKey.exit
dw 0x3E, 0
dd viewer_OnKey.f4
dw 0x42, 0
dd viewer_OnKey.f8
dw 0x44, 0
dd viewer_OnKey.exit
dw 0x47, 0
dd viewer_OnKey.home
dw 0x4F, 0
dd viewer_OnKey.end
dw 0x58, 0
dd F12
db 0
 
dirinfo:
dd 1
.first dd 0
dd 0
.size dd 300
.dirdata dd 0
db 0
.name dd 0
 
readinfo:
dd 0
.first dq 0
.size dd 0
.data dd 0
db 0
.name dd 0
 
attrinfo:
dd 5
dd 0
dd 0
dd 0
dd .attr
db 0
.name dd 0
 
delinfo:
dd 8
dd 0
dd 0
dd 0
dd 0
db 0
dd execdata
 
if lang eq ru
compare_names db '¨ˆà¬Œ €­á‘¤„'
else
compare_names db 'nNxXmMsSuUcCaA'
end if
 
;  ­¥«ì
panel_normal_color db 1Bh
panel_border_color db 1Bh
panel_cursor_color db 30h
panel_header_color db 1Bh
panel_active_header_color db 30h
column_header_color db 1Eh
panel_nscreens_color db 0Bh
; Œ¥­î
menu_normal_color db 3Fh
menu_selected_color db 0Fh
menu_highlight_color db 3Eh
menu_selected_highlight_color db 0Eh
menu_border_color db 3Fh
menu_header_color db 3Fh
menu_scrollbar_color db 3Fh
; ‹¨­¥©ª  ª« ¢¨è
keybar_number_color db 7
keybar_name_color db 30h
keybar_bgr_color db 7
; Š®¬ ­¤­ ï áâப 
cmdbar_normal_color db 7
cmdbar_prefix_color db 7
; à®á¬®âà騪
view_normal_color db 1Bh
view_status_color db 30h
view_arrows_color db 1Eh
 
; ®¤á¢¥âª  ä ©«®¢
highlight_num_groups dd 10
highlight_groups dd highlight_group0
dd highlight_group1
dd highlight_group2
dd highlight_group3
dd highlight_group4
dd highlight_group5
dd highlight_group6
dd highlight_group7
dd highlight_group8
dd highlight_group9
 
; ”®à¬ â ®¯¨á ­¨ï £àã¯¯ë ¯®¤á¢¥âª¨:
virtual at 0
highlight:
.NormalColor db ?
.CursorColor db ?
.IncludeAttributes db ?
.Mask: ; ASCIIZ-string
end virtual
 
highlight_group0:
db 13h
db 38h
db 2
db '*',0
highlight_group1:
db 13h
db 38h
db 4
db '*',0
highlight_group2:
db 1Fh
db 3Fh
db 10h
db '*|..',0
highlight_group3:
db 0
db 0
db 10h
db '..',0
highlight_group4:
db 1Ah
db 3Ah
db 0
db '*.exe,*.com,*.bat,*.cmd',0
highlight_group5:
db 1Ah
db 3Ah
db 0
db '*|*.*',0
highlight_group6:
db 1Dh
db 3Dh
db 0
db '*.rar,*.zip,*.[zj],*.[bg7]z,*.[bg]zip,*.tar,*.t[ag]z,*.ar[cj],*.r[0-9][0-9],'
db '*.a[0-9][0-9],*.bz2,*.cab,*.msi,*.jar,*.lha,*.lzh,*.ha,*.ac[bei],*.pa[ck],'
db '*.rk,*.cpio,*.rpm,*.zoo,*.hqx,*.sit,*.ice,*.uc2,*.ain,*.imp,*.777,*.ufa,*.boa,'
db '*.bs[2a],*.sea,*.hpk,*.ddi,*.x2,*.rkv,*.[lw]sz,*.h[ay]p,*.lim,*.sqz,*.chz',0
highlight_group7:
db 16h
db 36h
db 0
db '*.bak,*.tmp',0
highlight_group8:
db 17h
db 37h
db 0
db '*.asm,*.inc',0
highlight_group9:
db 1Fh
db 3Fh
db 10h
db '*',0
 
bWasE0 db 0
ctrlstate db 0
MemForImage dd 0
 
associations:
dd aAsm, tinypad
dd aInc, tinypad
dd aTxt, tinypad
dd aJpg, jpegview
dd aJpeg, jpegview
dd aGif, gifview
dd aWav, ac97wav
dd aMp3, ac97wav
dd aMid, midamp
dd aBmp, mv
dd aPng, archer
dd aRtf, rtfread
associations_end:
 
aAsm db 'asm',0
aInc db 'inc',0
aTxt db 'txt',0
tinypad db '/rd/1/TinyPad',0
 
aJpg db 'jpg',0
aJpeg db 'jpeg',0
jpegview db '/rd/1/JpegView',0
 
aGif db 'gif',0
gifview db '/rd/1/GIFVIEW',0
 
aWav db 'wav',0
aMp3 db 'mp3',0
ac97wav db '/rd/1/AC97WAV',0
 
aMid db 'mid',0
midamp db '/rd/1/MIDAMP',0
 
aBmp db 'bmp',0
mv db '/rd/1/MV',0
 
aPng db 'png',0
archer db '/rd/1/@rcher',0
 
aRtf db 'rtf',0
rtfread db '/rd/1/RtfRead',0
 
execinfo:
dd 7
dd 0
execparams dd 0
dd 0
dd 0
db 0
execptr dd ?
 
IncludeIGlobals
 
i_end:
 
IncludeUGlobals
 
execdata rb 1024
align 4
attrinfo.attr rb 40
 
panel1_data:
panel1_left dd ?
panel1_top dd ?
panel1_width dd ?
panel1_height dd ?
panel1_index dd ?
panel1_start dd ?
panel1_colsz dd ?
panel1_colst dd ?
panel1_sortmode db ?
rb 3
panel1_nfa dd ?
panel1_numfiles dd ?
panel1_files dd ?
panel1_dir rb 1024
 
panel2_data:
panel2_left dd ?
panel2_top dd ?
panel2_width dd ?
panel2_height dd ?
panel2_index dd ?
panel2_start dd ?
panel2_colsz dd ?
panel2_colst dd ?
panel2_sortmode db ?
rb 3
panel2_nfa dd ?
panel2_numfiles dd ?
panel2_files dd ?
panel2_dir rb 1024
 
console_data rb max_width*max_height*2
 
cur_header rb max_width
tmp dd ?
 
skinh dd ?
std_colors rd 10
 
column_left dd ?
column_top dd ?
column_width dd ?
column_height dd ?
column_index dd ?
 
scrpos dq ?
viewer_right_side dq ?
 
saved_file_name:
procinfo rb 1024
 
driveinfo rb 32+304
tmpname rb 32
 
screens dd ?
num_screens dd ?
active_screen_vtable dd ?
active_screen_data dd ?
 
; stack
align 512
rb 512
stacktop:
; buffers for directory - may be resized dynamically
buf1 rb 4*304 + 32 + 304*304
buf2 rb 4*304 + 32 + 304*304
 
mem:
/programs/fs/kfar/trunk/kglobals.inc
0,0 → 1,50
;------------------------------------------------------------------
; use "iglobal" for inserting initialized global data definitions.
;------------------------------------------------------------------
macro iglobal {
IGlobals equ IGlobals,
macro __IGlobalBlock { }
 
;-------------------------------------------------------------
; use 'uglobal' for inserting uninitialized global definitions.
; even when you define some data values, these variables
; will be stored as uninitialized data.
;-------------------------------------------------------------
macro uglobal {
UGlobals equ UGlobals,
macro __UGlobalBlock { }
 
endg fix } ; Use endg for ending iglobal and uglobal blocks.
 
macro IncludeIGlobals{
macro IGlobals dummy,[n] \{ __IGlobalBlock
purge __IGlobalBlock \}
match I, IGlobals \{ I \} }
 
 
macro IncludeUGlobals{
macro UGlobals dummy,[n] \{
\common
\local begin, size
begin = $
virtual at $
\forward
__UGlobalBlock
purge __UGlobalBlock
\common
size = $ - begin
end virtual
rb size
\}
match U, UGlobals \{ U \} }
 
macro IncludeAllGlobals {
IncludeIGlobals
IncludeUGlobals
}
iglobal
endg
 
uglobal
endg
/programs/fs/kfar/trunk/memalloc.inc
0,0 → 1,517
if ~ used memalloc_inc
memalloc_inc_fix:
memalloc_inc fix memalloc_inc_fix
;kglobals.inc required.
;multithread: ;uncomment this for thread-safe version
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Memory allocator for MenuetOS ;;
;; Halyavin Andrey halyavin@land.ru, 2006 ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; allocated mem block structure ;;
;; +0: bit 0 - used flag ;;
;; bits 31..1 - block size ;;
;; +4: address of prev block ;;
;; +8 .. +(blocksize) - allocated memory ;;
;; +(blocksize) - next block ;;
;; ;;
;; free mem block structure ;;
;; +0: bit 0 - used flag ;;
;; bits 31..1 - block size ;;
;; +4: address of prev block ;;
;; +8: prev free block ;;
;; +12: next free block ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
memblock.size=0
memblock.prevblock=4
memblock.prevfreeblock=8
memblock.nextfreeblock=12
uglobal
heapsmallblocks rd 1
heapstart rd 1
heapend rd 1
heapfreelist rd 1
heapmutex rd 1
heaplastblock rd 1
endg
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; mf_init ;;
;; Initialize memory map for dynamic use ;;
;; input: eax: starting address or 0 ;;
;; output: none ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mf_init:
push ebx
push ecx
test eax,eax
jnz .noautodet
sub esp,1024
mov ebx,esp
mov ecx,-1
mov eax,9
int 0x40
mov eax,[esp+26]
add esp,1024
.noautodet:
add eax,15
and eax,not 15
mov [heapsmallblocks],eax
add eax,2048
mov [heapstart],eax
mov [heapfreelist],eax
mov [heaplastblock],eax
 
mov ecx,eax
if defined heapstartsize
add ecx,heapstartsize
else
add ecx,4096
end if
add ecx,4095
and ecx,not 4095
push eax
mov eax,64
mov ebx,1
int 0x40
pop eax
mov [eax+memblock.prevblock],dword 0
mov [heapend],ecx
mov [eax+memblock.size],ecx
sub [eax+memblock.size],eax
xor ebx,ebx
mov dword [eax+memblock.prevfreeblock],heapfreelist-memblock.nextfreeblock
mov [eax+memblock.nextfreeblock],ebx
mov [heapmutex],ebx
push edi
mov edi,[heapsmallblocks]
mov ecx,512
xor eax,eax
rep stosd
pop edi
pop ecx
pop ebx
ret
 
if defined multithread
heaplock:
push eax
push ebx
mov eax,68
mov ebx,1
.loop:
xchg eax,[heapmutex]
test eax,eax
jz .endloop
int 0x40 ;change task
jmp .loop
.endloop:
pop ebx
pop eax
ret
 
heapunlock:
mov [heapmutex],dword 0
ret
end if
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; heap_split_block ;;
;; Split free block to allocated block and free one. ;;
;; input: ;;
;; eax - size of allocated block ;;
;; ebx - block ;;
;; output: ;;
;; eax - real size of allocated block ;;
;; ebx - pointer to new block ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
heap_split_block:
push ecx
mov ecx,[ebx+memblock.size]
sub ecx,16
cmp ecx,eax
jge .norm
inc dword [ebx+memblock.size]
mov eax,ecx
xor ebx,ebx
pop ecx
ret
.norm:
add ecx,16
mov [ebx+memblock.size],eax
inc dword [ebx+memblock.size]
mov [ebx+eax+memblock.prevblock],ebx
add ebx,eax
sub ecx,eax
mov [ebx+memblock.size],ecx
mov ecx,eax
mov eax,ebx
call heap_fix_right
mov eax,ecx
pop ecx
ret
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; heap_add_free_block ;;
;; Add free block to one of free block lists. ;;
;; input: ;;
;; eax - address of free block ;;
;; output: ;;
;; none ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
heap_add_free_block:
cmp dword [eax+memblock.size],4096
push ebx
jge .bigblock
mov ebx,[eax+memblock.size]
shr ebx,1
add ebx,[heapsmallblocks]
push dword [ebx]
pop dword [eax+memblock.nextfreeblock]
mov [ebx],eax
mov dword [eax+memblock.prevfreeblock],ebx
sub dword [eax+memblock.prevfreeblock],memblock.nextfreeblock
mov ebx,[eax+memblock.nextfreeblock]
test ebx,ebx
jz .no_next_block
mov [ebx+memblock.prevfreeblock],eax
.no_next_block:
pop ebx
ret
.bigblock:
mov ebx,[heapfreelist]
mov [eax+memblock.nextfreeblock],ebx
mov [heapfreelist],eax
mov dword [eax+memblock.prevfreeblock],heapfreelist-memblock.nextfreeblock
; mov ebx,[eax+memblock.nextfreeblock]
test ebx,ebx
jz .no_next_big_block
mov [ebx+memblock.prevfreeblock],eax
.no_next_big_block:
pop ebx
ret
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; heap_remove_block ;;
;; Remove free block from the list of free blocks. ;;
;; input: ;;
;; eax - free block ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
heap_remove_block:
push ebx
push ecx
mov ecx,[eax+memblock.prevfreeblock]
mov ebx,[eax+memblock.nextfreeblock]
mov [ecx+memblock.nextfreeblock],ebx
test ebx,ebx
jz .no_next_block
mov [ebx+memblock.prevfreeblock],ecx
.no_next_block:
pop ecx
pop ebx
ret
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; mf_alloc
;; allocates a block of memory in heap
;; intput: eax: size of block
;; output: eax: address of allocated memory block or 0 if there's no mem.
;; allocator will not create new nodes that contain less that 8b of space,
;; and minimal allocation is actually 16 bytes - 8 for node and 8 for user.
;; allocator will never create non-aligned memory blocks.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mf_alloc:
test eax,eax
jg .not_null ; test that we are not allocating null size block
xor eax,eax
ret
.not_null:
if defined multithread
call heaplock
end if
push edi
; push edx
push ecx
push ebx
add eax,7
and eax,not 7 ; make sure that block size is aligned
 
lea edi,[eax+8] ; desired block size
cmp edi,4096
jge .general_cycle
 
mov ebx,[heapsmallblocks]
xor ecx,ecx
shr edi,1
 
.smallloop:
cmp [ebx+edi],ecx
jnz .smallblockfound
add edi,4
cmp edi,2048
jl .smallloop
lea edi,[eax+8]
jmp .general_cycle
 
.smallblockfound:
lea ecx,[eax+8]
mov eax,[ebx+edi]
call heap_remove_block
mov ebx,eax
xchg eax,ecx
call heap_split_block
test ebx,ebx
jz .perfect_small_block
mov eax,ebx
call heap_add_free_block
.perfect_small_block:
lea eax,[ecx+8]
jmp .ret
 
.general_cycle:
;edi - size needed
mov eax,[heapfreelist]
 
.loop:
test eax,eax
jz .new_mem
cmp [eax+memblock.size],edi
jge .blockfound
mov eax,[eax+memblock.nextfreeblock]
jmp .loop
 
.blockfound:
call heap_remove_block
mov ebx,eax
mov ecx,eax
mov eax,edi
call heap_split_block
test ebx,ebx
jz .perfect_block
mov eax,ebx
call heap_add_free_block
.perfect_block:
lea eax,[ecx+8]
.ret:
if defined multithread
call heapunlock
end if
pop ebx
pop ecx
; pop edx
pop edi
ret
 
.new_mem:
mov eax,edi
add eax,4095
and eax,not 4095
mov ecx,[heapend]
add [heapend],eax
push eax
mov eax,64
push ebx
push ecx
mov ecx,[heapend]
mov ebx,1
int 0x40
pop ecx
pop ebx
pop eax
mov [ecx+memblock.size],eax
mov eax,[heaplastblock]
mov [ecx+memblock.prevblock],eax
mov [heaplastblock],ecx
mov eax,ecx
call heap_add_free_block
jmp .general_cycle
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; heap_fix_right ;;
;; input: ;;
;; eax - pointer to free block ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
heap_fix_right:
push ebx
mov ebx,eax
add ebx,[eax+memblock.size]
cmp ebx,[heapend]
jz .endblock
mov [ebx+memblock.prevblock],eax
pop ebx
ret
.endblock:
mov [heaplastblock],eax
pop ebx
ret
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; heap_merge_left ;;
;; input: ;;
;; eax - pointer to free block ;;
;; output: ;;
;; eax - pointer to merged block ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
heap_merge_left:
push ebx
mov ebx,[eax+memblock.prevblock]
test ebx,ebx
jz .ret
test byte [ebx+memblock.size],1
jnz .ret
xchg eax,ebx
call heap_remove_block
mov ebx,[ebx+memblock.size]
add [eax+memblock.size],ebx
call heap_fix_right
.ret:
pop ebx
ret
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; heap_merge_right ;;
;; input: ;;
;; eax - pointer to free block ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
heap_merge_right:
push ebx
mov ebx,eax
add ebx,[eax+memblock.size]
cmp ebx,[heapend]
jz .ret
test byte [ebx+memblock.size],1
jnz .ret
xchg eax,ebx
call heap_remove_block
xchg eax,ebx
mov ebx,[ebx+memblock.size]
add [eax+memblock.size],ebx
call heap_fix_right
.ret:
pop ebx
ret
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; mf_free ;;
;; input: ;;
;; eax - pointer ;;
;; output: ;;
;; eax=1 - ok ;;
;; eax=0 - failed ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mf_free:
test eax,eax
jnz .no_null
inc eax
ret
.no_null:
if defined multithread
call heaplock
end if
sub eax,8
dec dword [eax+memblock.size]
call heap_merge_left
call heap_merge_right
call heap_add_free_block
.ret:
if defined multithread
call heapunlock
end if
ret
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; heap_try_reloc
;; input:
;; eax - address
;; ebx - new size
;; output:
;; ebx=1 - ok
;; ebx=0 - failed
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
heap_try_reloc:
push eax
sub eax,8
add ebx,15
dec dword [eax+memblock.size]
and ebx,not 7
cmp [eax+memblock.size],ebx
jge .truncate
push ebx
mov ebx,eax
add ebx,[eax+memblock.size]
cmp ebx,[heapend]
jz .fail ;todo: we can allocate new mem here
test [ebx+memblock.size],byte 1
jnz .fail
xchg eax,ebx
call heap_remove_block
mov eax,[eax+memblock.size]
add [ebx+memblock.size],eax
mov eax,ebx
call heap_fix_right
pop ebx
.truncate:
xchg eax,ebx
call heap_split_block
test ebx,ebx
jz .no_last_block
mov eax,ebx
call heap_add_free_block
call heap_merge_right
.no_last_block:
xor ebx,ebx
pop eax
inc ebx
ret
.fail:
pop ebx
xor ebx,ebx
pop eax
inc dword [eax-8+memblock.size]
ret
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; mf_realloc
;; input:
;; eax - pointer
;; ebx - new size
;; output:
;; eax - new pointer
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mf_realloc:
push ebx
if defined multithread
call heaplock
end if
call heap_try_reloc
test ebx,ebx
jnz .ret
;allocate new memory
push eax
mov eax,[esp+4]
call mf_alloc
test eax,eax
jz .fail
push esi
push edi
push ecx
mov edi,eax
mov esi,[esp+12]
mov ecx,[esi-8+memblock.size]
shr ecx,2
rep movsd
pop ecx
pop edi
pop esi
xchg eax,[esp]
call mf_free
.fail:
pop eax
.ret:
if defined multithread
call heapunlock
end if
pop ebx
ret
end if
/programs/fs/kfar/trunk/sort.inc
0,0 → 1,67
; ‘®àâ¨à®¢ª  dword'®¢ ¢ ª®«¨ç¥á⢥ ecx ¯®  ¤à¥áã edx, äã­ªæ¨ï áà ¢­¥­¨ï ¢ ebx
;  §àãè ¥â eax, ecx, esi, edi
sort:
jecxz .done
mov eax, ecx
@@:
push eax
call .restore
pop eax
dec eax
jnz @b
@@:
cmp ecx, 1
jz .done
mov esi, 1
mov edi, ecx
call .exchange
dec ecx
mov eax, 1
call .restore
jmp @b
.done:
ret
 
.exchange:
push eax ecx
mov eax, [edx+esi*4-4]
mov ecx, [edx+edi*4-4]
mov [edx+esi*4-4], ecx
mov [edx+edi*4-4], eax
pop ecx eax
ret
 
.restore:
lea esi, [eax+eax]
cmp esi, ecx
ja .doner
push esi
mov esi, [edx+esi*4-4]
mov edi, [edx+eax*4-4]
call ebx
pop esi
ja .need_xchg
cmp esi, ecx
jae .doner
push esi
mov esi, [edx+esi*4]
mov edi, [edx+eax*4-4]
call ebx
pop esi
jbe .doner
.need_xchg:
cmp esi, ecx
jz .do_xchg
push esi
mov edi, [edx+esi*4-4]
mov esi, [edx+esi*4]
call ebx
pop esi
sbb esi, -1
.do_xchg:
mov edi, eax
call .exchange
mov eax, esi
jmp .restore
.doner:
ret
/programs/fs/kfar/trunk/viewer.inc
0,0 → 1,1216
virtual at 0
viewer_data:
.buf_start dq ?
.cur_pos dq ?
.filesize dq ?
.buf_pos dd ?
.buf_size dd ?
.col dq ?
.encoding db ?
.bEofReached db ?
.flags db ? ; & 1: hex mode
; & 2: unwrap
rb 1
.filename rb 1024
.buf rb 16384
.size = $
end virtual
 
view_file:
mov eax, [ebp + panel1_files - panel1_data]
mov ecx, [eax+ecx*4]
mov eax, [ebp + panel1_nfa - panel1_data]
lea ecx, [ecx+eax*4+32]
add ecx, [ebp + panel1_files - panel1_data]
test byte [ecx], 10h
jz .file
ret
.file:
lea esi, [ebp + panel1_dir - panel1_data]
mov eax, viewer_data.size
mov edx, viewer_vtable
call new_screen
test eax, eax
jnz @f
ret
@@:
mov [ebp+viewer_data.encoding], encodings.cp866
mov [ebp+viewer_data.flags], 0
and dword [ebp+viewer_data.col], 0
and dword [ebp+viewer_data.col+4], 0
lea edi, [ebp+viewer_data.filename]
push edi
@@:
lodsb
test al, al
jz @f
stosb
jmp @b
@@:
lea esi, [ecx+40]
mov al, '/'
stosb
@@:
lodsb
stosb
test al, al
jnz @b
pop eax
push eax
mov ebx, attrinfo
mov [ebx+21], eax
push 70
pop eax
int 40h
; TODO: add error handling
mov eax, dword [attrinfo.attr+32]
mov dword [ebp+viewer_data.filesize], eax
mov eax, dword [attrinfo.attr+36]
mov dword [ebp+viewer_data.filesize+4], eax
mov ebx, readinfo
xor eax, eax
mov dword [ebx+readinfo.first-readinfo], eax
mov dword [ebx+readinfo.first+4-readinfo], eax
mov dword [ebp+viewer_data.buf_start], eax
mov dword [ebp+viewer_data.buf_start+4], eax
mov dword [ebp+viewer_data.cur_pos], eax
mov dword [ebp+viewer_data.cur_pos+4], eax
mov [ebx+readinfo.size-readinfo], 16384
lea eax, [ebp+viewer_data.buf]
mov [readinfo.data], eax
mov [ebp+viewer_data.buf_pos], eax
pop dword [readinfo.name]
push 70
pop eax
int 40h
mov [ebp+viewer_data.buf_size], ebx
; TODO: add error handling
call viewer_set_keybar
call viewer_draw_text
ret
 
viewer_get_next_char:
pusha
mov eax, [ebp+viewer_data.buf_pos]
lea ecx, [ebp+viewer_data.buf]
add ecx, [ebp+viewer_data.buf_size]
cmp eax, ecx
jb .buffered
mov al, ' '
sub ecx, ebp
cmp ecx, viewer_data.buf + 16384
jb .err
mov eax, dword [ebp+viewer_data.buf_start]
add eax, 8192
mov dword [ebp+viewer_data.buf_start], eax
mov edx, dword [ebp+viewer_data.buf_start+4]
adc edx, 0
mov dword [ebp+viewer_data.buf_start+4], edx
add eax, 16384-8192
adc edx, 0
mov dword [readinfo.first], eax
mov dword [readinfo.first+4], edx
mov dword [readinfo.size], 8192
lea edi, [ebp+viewer_data.buf]
lea esi, [edi+8192]
mov ecx, (16384-8192)/4
rep movsd
mov [readinfo.data], edi
lea eax, [ebp+viewer_data.filename]
mov [readinfo.name], eax
mov ebx, readinfo
push 70
pop eax
int 40h
sub [ebp+viewer_data.buf_pos], 8192
add ebx, 16384-8192
mov [ebp+viewer_data.buf_size], ebx
mov eax, [ebp+viewer_data.buf_pos]
cmp ecx, 16384-8192
jnz .buffered
.err:
stc
popa
ret
.buffered:
mov al, [eax]
.done:
mov [esp+28], al
inc [ebp+viewer_data.buf_pos]
clc
popa
ret
 
viewer_get_prev_char:
pusha
lea ecx, [ebp+viewer_data.buf]
cmp [ebp+viewer_data.buf_pos], ecx
ja .buffered
mov eax, dword [ebp+viewer_data.buf_start]
mov edx, dword [ebp+viewer_data.buf_start+4]
test eax, eax
jnz @f
test edx, edx
jnz @f
stc
jmp .ret
@@:
sub eax, 8192
sbb edx, 0
jnc @f
xor eax, eax
xor edx, edx
@@:
call viewer_seek
add [ebp+viewer_data.buf_pos], 8192
.buffered:
mov eax, [ebp+viewer_data.buf_pos]
dec eax
mov [ebp+viewer_data.buf_pos], eax
mov al, [eax]
mov [esp+28], al
clc
.ret:
popa
ret
 
fld_uint64:
fild qword [eax]
test byte [eax+7], 80h
jz .ret
fadd [@f]
.ret:
ret
@@ dq 18446744073709551616.0 ;0x10000000000000000
 
viewer_draw_text:
call viewer_seek_to_current
xor eax, eax
xor edx, edx
call get_console_ptr
mov ah, [view_status_color]
lea esi, [ebp+viewer_data.filename]
mov dl, 3
mov ecx, [cur_width]
sub ecx, 44
cmp ecx, 20
jae .5
mov cl, 20
.5:
lodsb
cmp al, '/'
jnz @f
dec edx
jz .6
@@:
stosw
loop .5
.6:
dec ecx
stosw
push esi
@@:
inc esi
cmp byte [esi-1], 0
jnz @b
sub esi, [esp]
dec esi
cmp ecx, esi
jae .7
mov al, '.'
stosw
stosw
stosw
sub ecx, 3
sub esi, ecx
add [esp], esi
.7:
pop esi
@@:
lodsb
test al, al
jz @f
dec ecx
stosw
jmp @b
@@:
mov al, ' '
add ecx, 8
rep stosw
movzx esi, [ebp+viewer_data.encoding]
lea esi, [encodings.names+esi*8]
mov cl, 8
@@:
lodsb
stosw
loop @b
mov al, ' '
mov cl, 8
rep stosw
std
push edi
mov edx, dword [ebp+viewer_data.filesize+4]
mov eax, dword [ebp+viewer_data.filesize]
mov cl, 10
@@:
push eax
mov eax, edx
xor edx, edx
div ecx
xchg eax, [esp]
div ecx
xchg eax, edx
add al, '0'
mov ah, [view_status_color]
stosw
xchg eax, edx
pop edx
test eax, eax
jnz @b
test edx, edx
jnz @b
mov al, ' '
mov ah, [view_status_color]
stosw
cld
pop edi
inc edi
inc edi
mov al, ' '
mov cl, 5
rep stosw
if lang eq ru
mov al, 'Š'
stosw
mov al, '®'
stosw
mov al, '«'
stosw
else
mov al, 'C'
stosw
mov al, 'o'
stosw
mov al, 'l'
stosw
end if
mov al, ' '
stosw
push edi
mov eax, dword [ebp+viewer_data.col]
mov edx, dword [ebp+viewer_data.col+4]
test edx, edx
jnz .col_big
cmp eax, 100000
jae .col_big
mov cl, 10
push -'0'
@@:
div ecx
push edx
xor edx, edx
test eax, eax
jnz @b
@@:
pop eax
add eax, '0'
jz .col_done
mov ah, [view_status_color]
stosw
jmp @b
.col_big:
push eax
mov al, '.'
mov ah, [view_status_color]
stosw
stosw
stosw
xor eax, eax
xchg eax, edx
mov cl, 100
div ecx
pop eax
div ecx
mov cl, 10
xor eax, eax
xchg eax, edx
div ecx
add al, '0'
mov ah, [view_status_color]
stosw
mov al, dl
add al, '0'
stosw
.col_done:
pop ecx
add ecx, 10*2
sub ecx, edi
shr ecx, 1
mov al, ' '
mov ah, [view_status_color]
rep stosw
finit
fldcw [fpu_cw]
mov [tmp], 100
lea eax, [ebp+viewer_data.filesize]
cmp dword [eax], 0
jnz @f
cmp dword [eax+4], 0
jz .size_zero
@@:
call fld_uint64
lea eax, [ebp+viewer_data.cur_pos]
call fld_uint64
fdivrp
fimul [_100d]
fistp [tmp]
.size_zero:
mov byte [edi-2], '%'
sub edi, 4
mov eax, [tmp]
mov cl, 10
@@:
xor edx, edx
div ecx
xchg eax, edx
add al, '0'
mov [edi], al
sub edi, 2
xchg eax, edx
test eax, eax
jnz @b
xor eax, eax
push 1
pop edx
call get_console_ptr
test [ebp+viewer_data.flags], 1
jnz .DrawHex
push 2
pop edx
xor ecx, ecx
mov dword [scrpos], ecx
mov dword [scrpos+4], ecx
mov dword [viewer_right_side], ecx
mov dword [viewer_right_side+4], ecx
.1:
call viewer_get_next_char
jc .done
.2:
cmp al, 0xD
jz .newline
cmp al, 0xA
jz .newline
cmp ecx, [cur_width]
jb .no_newline
test [ebp+viewer_data.flags], 2
jnz .no_newline
.newline:
push eax
mov ecx, dword [scrpos]
mov eax, dword [scrpos+4]
sub ecx, dword [ebp+viewer_data.col]
sbb eax, dword [ebp+viewer_data.col+4]
ja .line_filled
jb .line_full
cmp ecx, [cur_width]
ja .line_filled
jmp @f
.line_full:
xor ecx, ecx
@@:
test ecx, ecx
jnz @f
mov eax, dword [scrpos]
or eax, dword [scrpos+4]
jz @f
inc ecx
@@:
sub ecx, [cur_width]
neg ecx
mov al, ' '
mov ah, [view_normal_color]
rep stosw
.line_filled:
mov eax, dword [scrpos]
sub eax, dword [viewer_right_side]
mov eax, dword [scrpos+4]
sbb eax, dword [viewer_right_side+4]
jb @f
mov eax, dword [scrpos]
mov dword [viewer_right_side], eax
mov eax, dword [scrpos+4]
mov dword [viewer_right_side+4], eax
@@:
xor ecx, ecx
mov dword [scrpos], ecx
mov dword [scrpos+4], ecx
inc edx
pop eax
cmp edx, [cur_height]
jae .done
.no_newline:
cmp al, 0xD
jz .3
cmp al, 0xA
jz .3
.4:
test al, al
jns @f
movzx esi, [ebp+viewer_data.encoding]
shl esi, 7
movzx eax, al
mov al, [encodings.tables-80h+esi+eax]
@@:
cmp al, 9
jz .tab
call .write_char
inc ecx
jns .1
push edx
mov eax, ecx
xor edx, edx
div [tabsize]
mov ecx, edx
pop edx
jmp .1
.3:
mov bl, al
call viewer_get_next_char
jc .done
xor bl, al
cmp bl, 0xA xor 0xD
jz .1
jmp .2
.tab:
push edx
push ecx
mov eax, ecx
mov ecx, [tabsize]
xor edx, edx
div ecx
pop eax
sub ecx, edx
add eax, ecx
test [ebp+viewer_data.flags], 2
jnz @f
cmp eax, [cur_width]
jbe @f
sub eax, [cur_width]
sub ecx, eax
mov eax, [cur_width]
@@:
push eax
mov al, ' '
@@:
call .write_char
loop @b
pop ecx
pop edx
jmp .1
.done:
setc [ebp+viewer_data.bEofReached]
.done2:
inc edx
cmp edx, [cur_height]
jnc @f
mov eax, dword [ebp+viewer_data.cur_pos]
or eax, dword [ebp+viewer_data.cur_pos+4]
jz @f
call viewer_seek_to_current
call viewer_prev_newline
jmp viewer_draw_text
@@:
push edi
xor eax, eax
mov edx, [cur_height]
dec edx
call get_console_ptr
mov ecx, edi
pop edi
sub ecx, edi
shr ecx, 1
mov al, ' '
mov ah, [view_normal_color]
rep stosw
cmp [ebp+viewer_data.bEofReached], 0
jz @f
xor edx, edx
mov eax, [cur_width]
sub eax, 4
call get_console_ptr
mov ah, [view_status_color]
mov al, '1'
stosw
mov al, '0'
stosw
stosw
@@:
call draw_image
ret
.DrawHex:
xor esi, esi
mov [ebp+viewer_data.bEofReached], 0
.line:
mov al, ' '
mov ah, [view_normal_color]
push edi
mov ecx, [cur_width]
rep stosw
mov ebx, edi
pop edi
call viewer_get_next_char
jc .hexdone
push eax
push edi
add edi, 36*2
mov al, 0xB3
call .safechar
pop edi
mov eax, dword [ebp+viewer_data.cur_pos]
mov edx, dword [ebp+viewer_data.cur_pos+4]
push esi
shl esi, 4
add eax, esi
adc edx, 0
pop esi
push eax
mov al, dl
shr eax, 4
and al, 0xF
call .hex_digit
mov al, dl
and al, 0xF
call .hex_digit
pop eax
push 8
pop ecx
add edi, 7*2
std
@@:
push eax
and al, 0xF
call .hex_digit
pop eax
shr eax, 4
loop @b
cld
add edi, 9*2
mov al, ':'
mov ah, [view_normal_color]
stosw
mov al, ' '
stosw
xor ecx, ecx
pop eax
jmp @f
.hexchar:
call viewer_get_next_char
jc .hexdone
@@:
push eax
shr al, 4
call .hex_digit
pop eax
push eax
and al, 0xF
call .hex_digit
mov al, ' '
call .safechar
pop eax
push edi
add edi, 48*2
push ecx
shl ecx, 2
sub edi, ecx
pop ecx
cmp ecx, 8
jb @f
sub edi, 4
@@:
test al, al
jns @f
movzx edx, [ebp+viewer_data.encoding]
shl edx, 7
movzx eax, al
mov al, [encodings.tables+eax+edx-80h]
mov ah, [view_normal_color]
@@:
call .safechar
pop edi
inc ecx
cmp ecx, 8
jnz @f
mov al, 0xB3
call .safechar
mov al, ' '
call .safechar
@@:
cmp ecx, 16
jnz .hexchar
mov edi, ebx
add esi, 3
mov edx, esi
cmp esi, [cur_height]
jae .done2
dec esi
dec esi
jmp .line
.hexdone:
mov [ebp+viewer_data.bEofReached], 1
mov edi, ebx
lea edx, [esi+2]
jmp .done2
 
.hex_digit:
push eax
cmp al, 10
sbb al, 69h
das
mov ah, [view_normal_color]
call .safechar
pop eax
ret
.safechar:
cmp edi, ebx
jae @f
stosw
@@:
ret
.write_char:
push ecx eax
mov ecx, dword [scrpos]
mov eax, dword [scrpos+4]
sub ecx, dword [ebp+viewer_data.col]
sbb eax, dword [ebp+viewer_data.col+4]
jb .left
ja .skip
test ecx, ecx
jnz @f
mov eax, dword [scrpos]
or eax, dword [scrpos+4]
jnz .skip
@@:
cmp ecx, [cur_width]
ja .skip
jb .do
mov al, '>'
mov [edi-2], al
mov al, [view_arrows_color]
mov [edi-1], al
jmp .skip
.left:
mov eax, dword [scrpos]
or eax, dword [scrpos+4]
jnz .skip
mov al, '<'
mov ah, [view_arrows_color]
stosw
jmp .skip
.do:
mov al, [esp]
mov ah, [view_normal_color]
stosw
.skip:
pop eax ecx
add dword [scrpos], 1
adc dword [scrpos+4], 0
ret
 
viewer_seek_to_current:
mov eax, dword [ebp+viewer_data.cur_pos]
mov edx, dword [ebp+viewer_data.cur_pos+4]
viewer_seek:
push eax edx
sub eax, dword [ebp+viewer_data.buf_start]
sbb edx, dword [ebp+viewer_data.buf_start+4]
jb .prev
ja .next
cmp eax, 16384
jae .next
lea eax, [ebp+viewer_data.buf+eax]
mov [ebp+viewer_data.buf_pos], eax
pop edx eax
ret
.prev:
inc edx
jnz .read_full
and eax, not 511
cmp eax, -16384
jbe .read_full
lea edi, [ebp+viewer_data.buf+16384-4]
lea esi, [edi+eax]
lea ecx, [eax+16384]
push ecx
shr ecx, 2
std
rep movsd
cld
pop ecx
add dword [ebp+viewer_data.buf_start], eax
adc dword [ebp+viewer_data.buf_start+4], -1
neg eax
cmp dword [ebp+viewer_data.buf_size], ecx
jb .doread
mov dword [ebp+viewer_data.buf_size], ecx
jmp .doread
.read_full:
pop edx eax
push eax edx
and eax, not 511
sub eax, 8192-512
sbb edx, 0
jnc @f
xor eax, eax
xor edx, edx
@@:
mov dword [ebp+viewer_data.buf_start], eax
mov dword [ebp+viewer_data.buf_start+4], edx
and dword [ebp+viewer_data.buf_size], 0
mov eax, 16384
.doread:
mov ebx, readinfo
push dword [ebp+viewer_data.buf_start]
pop dword [ebx+4]
push dword [ebp+viewer_data.buf_start+4]
pop dword [ebx+8]
mov [ebx+12], eax
lea eax, [ebp+viewer_data.buf]
mov [ebx+16], eax
lea eax, [ebp+viewer_data.filename]
mov [ebx+21], eax
push 70
pop eax
int 40h
cmp ebx, [readinfo.size]
jnz @f
add ebx, [ebp+viewer_data.buf_size]
@@:
.ret:
mov [ebp+viewer_data.buf_size], ebx
pop edx eax
sub eax, dword [ebp+viewer_data.buf_start]
lea eax, [ebp+eax+viewer_data.buf]
mov [ebp+viewer_data.buf_pos], eax
ret
.next:
or eax, 511
sub eax, 16384-1
sbb edx, 0
jnz .read_full
cmp eax, 16384
jae .read_full
cmp [ebp+viewer_data.buf_size], 16384
jb .read_full
lea edi, [ebp+viewer_data.buf]
lea esi, [edi+eax]
mov ecx, 16384
sub ecx, eax
shr ecx, 2
rep movsd
add dword [ebp+viewer_data.buf_start], eax
adc dword [ebp+viewer_data.buf_start+4], 0
mov ebx, readinfo
mov [ebx+16], edi
sub edi, ebp
sub edi, viewer_data.buf
mov edx, dword [ebp+viewer_data.buf_start]
add edx, edi
mov [ebx+4], edx
mov edx, dword [ebp+viewer_data.buf_start+4]
adc edx, 0
mov [ebx+8], edx
mov [ebx+12], eax
lea eax, [ebp+viewer_data.filename]
mov [ebx+21], eax
push 70
pop eax
int 40h
sub ebx, [readinfo.size]
add ebx, 16384
jmp .ret
 
viewer_set_curpos:
mov eax, [ebp+viewer_data.buf_pos]
sub eax, ebp
sub eax, viewer_data.buf
xor edx, edx
add eax, dword [ebp+viewer_data.buf_start]
adc edx, dword [ebp+viewer_data.buf_start+4]
mov dword [ebp+viewer_data.cur_pos], eax
mov dword [ebp+viewer_data.cur_pos+4], edx
ret
 
viewer_next_newline:
test [ebp+viewer_data.flags], 1
jz .nohex
push 10h
pop ecx
@@:
call viewer_get_next_char
jc @f
loop @b
call viewer_set_curpos
clc
@@: ret
.nohex:
xor ecx, ecx
@@:
call viewer_get_next_char
jc .ret
cmp al, 0xD
jz .1
cmp al, 0xA
jz .1
cmp al, 9
jz .tab
inc ecx
.next:
test [ebp+viewer_data.flags], 2
jnz @b
cmp ecx, [cur_width]
jbe @b
call viewer_get_prev_char
jmp .2
.tab:
push ecx
mov eax, ecx
mov ecx, [tabsize]
xor edx, edx
div ecx
sub ecx, edx
add [esp], ecx
pop ecx
jmp .next
.1:
mov cl, al
call viewer_get_next_char
jc .ret
xor cl, al
cmp cl, 0xD xor 0xA
jz .2
dec [ebp+viewer_data.buf_pos]
.2:
.ret:
call viewer_set_curpos
ret
 
viewer_prev_newline:
test [ebp+viewer_data.flags], 1
jz .nohex
push 10h
pop ecx
@@:
call viewer_get_prev_char
jc @f
loop @b
@@: call viewer_set_curpos
ret
.nohex:
mov eax, 8192
push eax
cdq
div [cur_width]
pop eax
sub eax, edx
mov edx, eax
call viewer_get_prev_char
jc .0
dec edx
cmp al, 0xD
jz .2
cmp al, 0xA
jnz .3
.2:
mov cl, al
call viewer_get_prev_char
jc .0
dec edx
xor cl, al
cmp cl, 0xD xor 0xA
jnz .3
@@:
call viewer_get_prev_char
jc .0
dec edx
jz .0
.3:
cmp al, 0xD
jz .1
cmp al, 0xA
jnz @b
.1:
call viewer_get_next_char
.0:
push dword [ebp+viewer_data.cur_pos+4]
push dword [ebp+viewer_data.cur_pos]
call viewer_set_curpos
@@:
push dword [ebp+viewer_data.cur_pos+4]
push dword [ebp+viewer_data.cur_pos]
call viewer_next_newline
jc .ret3
mov eax, dword [ebp+viewer_data.cur_pos]
mov edx, dword [ebp+viewer_data.cur_pos+4]
sub eax, [esp+8]
sbb edx, [esp+12]
jae .ret3
pop eax
pop eax
jmp @b
.ret3:
pop dword [ebp+viewer_data.cur_pos]
pop dword [ebp+viewer_data.cur_pos+4]
.ret:
pop eax
pop eax
jmp viewer_seek_to_current
 
viewer_set_keybar:
mov eax, keybar_viewer
if lang eq ru
test [ebp+viewer_data.flags], 1
jnz .hex
mov dword [eax+(4-1)*6], 'Š®¤ '
mov word [eax+(4-1)*6+4], ' '
jmp @f
.hex:
mov dword [eax+(4-1)*6], '’¥ªá'
mov word [eax+(4-1)*6+4], 'â '
@@:
test [ebp+viewer_data.flags], 2
jnz .unwrap
mov dword [eax+6], ' §¢'
mov word [eax+6+4], '¥à'
jmp @f
.unwrap:
mov dword [eax+6], '‘¢¥à'
mov word [eax+6+4], '­ '
@@:
else
test [ebp+viewer_data.flags], 1
jnz .hex
mov dword [eax+(4-1)*6], 'Hex '
; mov word [eax+(4-1)*6+4], ' '
jmp @f
.hex:
mov dword [eax+(4-1)*6], 'Text'
; mov word [eax+(4-1)*6+4], ' '
@@:
test [ebp+viewer_data.flags], 2
jnz .unwrap
mov dword [eax+6], 'Unwr'
mov word [eax+6+4], 'ap'
jmp @f
.unwrap:
mov dword [eax+6], 'Wrap'
mov word [eax+6+4], ' '
@@:
end if
movzx esi, [ebp+viewer_data.encoding]
xor esi, 1
lea esi, [encodings.names+esi*8]
lea edi, [eax+keybar_cp-keybar_viewer]
movsd
movsw
jmp draw_keybar
 
viewer_OnRedraw:
call viewer_set_keybar
call viewer_draw_text
ret
 
viewer_OnKey:
mov esi, viewer_ctrlkeys
jmp process_ctrl_keys
.exit:
call delete_active_screen
ret
.down:
cmp [ebp+viewer_data.bEofReached], 0
jnz .ret
call viewer_seek_to_current
call viewer_next_newline
jc .ret
call viewer_draw_text
ret
.pgdn:
cmp [ebp+viewer_data.bEofReached], 0
jnz .ret
call viewer_seek_to_current
mov ebx, [cur_height]
sub ebx, 3
@@:
call viewer_next_newline
jc .ret
dec ebx
jnz @b
call viewer_draw_text
ret
.up:
call viewer_seek_to_current
call viewer_prev_newline
call viewer_draw_text
ret
.pgup:
call viewer_seek_to_current
mov ebx, [cur_height]
sub ebx, 3
@@:
call viewer_prev_newline
dec ebx
jnz @b
.done_redraw:
call viewer_draw_text
.ret:
ret
.f8:
movzx esi, [ebp+viewer_data.encoding]
xor [ebp+viewer_data.encoding], 1
call viewer_set_keybar
jmp .done_redraw
.f2:
xor [ebp+viewer_data.flags], 2
call viewer_set_keybar
jmp .done_redraw
.f4:
xor [ebp+viewer_data.flags], 1
pushf
call viewer_set_keybar
popf
jnz .tohex
add dword [ebp+viewer_data.cur_pos], 1
adc dword [ebp+viewer_data.cur_pos+4], 0
call viewer_seek_to_current
call viewer_prev_newline
jmp .done_redraw
.tohex:
and byte [ebp+viewer_data.cur_pos], 0xF0
jmp .done_redraw
.home:
xor eax, eax
mov dword [ebp+viewer_data.cur_pos], eax
mov dword [ebp+viewer_data.cur_pos+4], eax
mov dword [ebp+viewer_data.col], eax
mov dword [ebp+viewer_data.col+4], eax
jmp .done_redraw
.end:
mov eax, dword [ebp+viewer_data.filesize]
mov edx, dword [ebp+viewer_data.filesize+4]
and al, 0xF0
mov dword [ebp+viewer_data.cur_pos], eax
mov dword [ebp+viewer_data.cur_pos+4], edx
and dword [ebp+viewer_data.col], 0
and dword [ebp+viewer_data.col+4], 0
jmp .done_redraw
.right:
add dword [ebp+viewer_data.col], 1
adc dword [ebp+viewer_data.col+4], 0
jnc .done_redraw
sub dword [ebp+viewer_data.col], 1
sbb dword [ebp+viewer_data.col+4], 0
ret
.left:
sub dword [ebp+viewer_data.col], 1
sbb dword [ebp+viewer_data.col+4], 0
jnc .done_redraw
add dword [ebp+viewer_data.col], 1
adc dword [ebp+viewer_data.col+4], 0
ret
.ctrl_left:
test [ebp+viewer_data.flags], 1
jnz .ctrl_left_hex
sub dword [ebp+viewer_data.col], 20
sbb dword [ebp+viewer_data.col+4], 0
jnc .done_redraw
.ctrl_shift_left:
and dword [ebp+viewer_data.col], 0
and dword [ebp+viewer_data.col+4], 0
jmp .done_redraw
.ctrl_left_hex:
call viewer_seek_to_current
call viewer_get_prev_char
jc @f
call viewer_set_curpos
jmp .done_redraw
.ctrl_right:
test [ebp+viewer_data.flags], 1
jnz .ctrl_right_hex
add dword [ebp+viewer_data.col], 20
adc dword [ebp+viewer_data.col+4], 0
jnc .done_redraw
sub dword [ebp+viewer_data.col], 20
sbb dword [ebp+viewer_data.col+4], 0
@@: ret
.ctrl_right_hex:
call viewer_seek_to_current
call viewer_get_next_char
call viewer_set_curpos
jmp .done_redraw
.ctrl_shift_right:
test [ebp+viewer_data.flags], 1
jnz @b
mov eax, dword [viewer_right_side]
mov edx, dword [viewer_right_side+4]
sub eax, [cur_width]
sbb edx, 0
jnc @f
xor eax, eax
xor edx, edx
@@:
mov dword [ebp+viewer_data.col], eax
mov dword [ebp+viewer_data.col+4], edx
jmp .done_redraw
 
viewer_getname:
if lang eq ru
mov eax, 'à®á'
stosd
mov eax, '¬®âà'
stosd
mov eax, ' '
stosd
stosb
else
mov eax, 'View'
stosd
mov eax, ' '
stosd
stosd
stosb
end if
sub ecx, 13
lea esi, [ebp+viewer_data.filename]
push 3
pop edx
@@:
lodsb
stosb
dec ecx
cmp al, '/'
jnz @b
dec edx
jnz @b
push esi
@@:
lodsb
test al, al
jnz @b
sub esi, [esp]
dec esi
cmp esi, ecx
jbe @f
mov al, '.'
stosb
stosb
stosb
sub ecx, 3
sub esi, ecx
add [esp], esi
@@:
pop esi
@@:
lodsb
stosb
test al, al
jnz @b
ret
/programs/games/chess/trunk/build_en.bat
1,4 → 1,5
@erase lang.inc
@echo lang fix en >lang.inc
@fasm chess.asm chess
@erase lang.inc
@pause
/programs/games/chess/trunk/build_ru.bat
1,4 → 1,5
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm chess.asm chess
@erase lang.inc
@pause
/programs/games/chess/trunk/chess.asm
3,29 → 3,40
;
; Compile with FASM for Menuet
;
 
appname equ 'Chess Client for Chessclub.com '
version equ '0.2'
 
use32
org 0x0
db 'MENUET00' ; 8 byte id
dd 38 ; required os
dd START ; program start
dd I_END ; program image size
dd 0x100000 ; required amount of memory
; esp = 0x7FFF0
dd 0x00000000 ; reserved=no extended header
 
org 0x0
 
db 'MENUET00' ; 8 byte id
dd 38 ; required os
dd START ; program start
dd I_END ; program image size
dd 0x100000 ; required amount of memory
; esp = 0x7FFF0
dd 0x00000000 ; reserved=no extended header
 
include 'lang.inc'
include 'macros.inc'
 
;file_info:
;
; dd 0,0,-1,0x4000,0x20000
; db '/rd/1/chess.bmp',0
 
file_info:
dd 0,0,-1,0x4000,0x20000
db '/rd/1/chess.bmp',0
dd 0
dd 0
dd 0
dd -1
dd 0x4000
db '/rd/1/chess.bmp',0
 
pawn_color:
 
dd 0x000000
dd 0x222222
dd 0x444444
42,28 → 53,30
dd 0xe8e8e8
dd 0x00ff00
dd 0xffffff
 
 
 
texts equ board_old+80*30
 
text equ texts+80*32*4
START: ; start of execution
mov eax,58
 
 
START: ; start of execution
 
; mov eax,58
mov eax,70
; mov ebx,file_info
mov ebx,file_info
int 0x40
 
mov esi,0x4000+22*3+4+24*2
mov edi,0x10000+18*3
 
mov ebx,0
mov ecx,0
 
newp:
 
xor eax,eax
mov al,[esi]
and al,0xf0
71,7 → 84,7
shl eax,2
mov eax,[pawn_color+eax]
mov [edi+0],eax
 
xor eax,eax
mov al,[esi]
and al,0x0f
78,22 → 91,22
shl eax,2
mov eax,[pawn_color+eax]
mov [edi+3],eax
 
add edi,6
add esi,1
 
inc ebx
cmp ebx,23
jbe newp
 
sub edi,12
 
mov ebx,0
 
inc ecx
cmp ecx,279
jb newp
jb newp
 
; Clear the screen memory
mov eax, ' '
mov edi,text
100,46 → 113,46
mov ecx,80*30 /4
cld
rep stosd
 
 
call draw_window
 
still:
 
call check_for_board
 
call board_changed
 
call draw_board
 
; check connection status
mov eax,53
mov ebx,6
mov ecx,[socket]
int 0x40
 
mov ebx, [socket_status]
mov [socket_status], eax
 
cmp eax, ebx
je waitev
je waitev
 
call display_status
 
waitev:
mov eax,23 ; wait here for event
mov eax,23 ; wait here for event
mov ebx,20
int 0x40
cmp eax,1 ; redraw request ?
je red
cmp eax,2 ; key in buffer ?
je key
cmp eax,3 ; button in buffer ?
je button
 
cmp eax,1 ; redraw request ?
je red
cmp eax,2 ; key in buffer ?
je key
cmp eax,3 ; button in buffer ?
je button
 
; any data from the socket?
 
mov eax, 53
mov ebx, 2
mov ecx, [socket]
146,12 → 159,12
int 0x40
cmp eax, 0
jne read_input
 
jmp still
 
 
read_input:
 
push ecx
mov eax, 53
mov ebx, 3
158,9 → 171,9
mov ecx, [socket]
int 0x40
pop ecx
 
call handle_data
 
push ecx
mov eax, 53
mov ebx, 2
168,81 → 181,81
int 0x40
pop ecx
cmp eax, 0
 
 
jne read_input
call draw_text
jmp still
 
 
 
check_for_board:
 
pusha
 
mov esi,text-80
news:
add esi,80
cmp esi,text+80*10
je board_not_found
je board_not_found
cmp [esi+12],dword '----'
je cfb1
je cfb1
jmp news
cfb1:
cmp [esi+16*80+12],dword '----'
je cfb2
je cfb2
jmp news
cfb2:
cmp [esi+2*80+12],dword '+---'
jne news
 
cmp [esi+4*80+12],dword '+---'
jne news
 
board_found:
 
mov edi,chess_board
mov ecx,80*18
cld
rep movsb
 
board_not_found:
 
popa
 
ret
yst dd 150
textx equ 10
ysts equ 410
boardx dd 45
boardy dd 45
 
 
yst dd 150
textx equ 10
ysts equ 410
 
boardx dd 45
boardy dd 45
 
boardxs dd 44
boardys dd 44
conx equ 420
cony equ 118
dconx equ 420
dcony equ 148
 
conx equ 420
cony equ 118
 
dconx equ 420
dcony equ 148
 
statusx equ 420
statusy equ 178
 
 
drsq:
 
push eax ebx
 
mov ecx,ebx
mov ebx,eax
 
mov eax,ebx
add eax,ecx
 
imul ebx,[boardxs]
add ebx,[boardx]
shl ebx,16
249,68 → 262,68
imul ecx,[boardys]
add ecx,[boardy]
shl ecx,16
 
add ebx,[boardxs]
add ecx,[boardys]
 
mov edx,[sq_black]
test eax,1
jnz dbl22
mov edx,[sq_white]
dbl22:
 
mov eax,13
int 0x40
 
pop ebx eax
 
ret
 
 
 
draw_pawn:
 
; edi,0 ; white / black
; esi,0 ; from position 2 , 20 square
; eax,2 ; board x
; ebx,0 ; board y
 
pusha
 
call drsq
 
cmp esi,20
jne no_sqd
 
popa
ret
 
no_sqd:
 
imul eax,[boardxs]
imul ebx,[boardys]
 
add eax,[boardx]
add ebx,[boardy]
 
imul esi,44*45*3
add esi,0x10000+18*3
 
mov ecx,43
 
dp0:
 
pusha
 
mov ecx,44
 
ldp1:
 
pusha
 
mov ecx,ebx
mov ebx,eax
 
mov edx,[esi]
and edx,0xffffff
mov eax,1
323,32 → 336,32
nobl:
int 0x40
nowp:
 
popa
 
add esi,3
add eax,1
 
dec ecx
jnz ldp1
 
popa
 
add ebx,1
add esi,3*44
 
dec ecx
jnz dp0
 
popa
 
ret
 
 
board_changed:
 
pusha
 
mov eax,0
mov esi,chess_board
bcl1:
355,53 → 368,53
add eax,[esi]
add esi,4
cmp esi,chess_board+19*80
jb bcl1
jb bcl1
 
cmp eax,[checksum]
je bcl2
je bcl2
mov [changed],1
bcl2:
mov [checksum],eax
 
popa
 
ret
 
 
 
checksum dd 0
 
changed db 1
 
draw_board:
 
pusha
 
cmp [changed],1
jne no_change_in_board
 
mov [changed],0
 
mov eax,0
mov ebx,0
scan_board:
 
push eax ebx
 
mov esi,ebx
imul esi,2
imul esi,80
add esi,80
 
imul eax,4
add eax,10
 
add esi,eax
 
movzx edx,word [chess_board+esi]
cmp dx,[board_old+esi]
je empty_slot
 
mov ecx,13
newseek2:
mov edi,ecx
410,11 → 423,11
cmp dx,[edi+nappulat]
je foundnappula2
loop newseek2
 
jmp empty_slot
 
foundnappula2:
 
mov esi,[edi+nappulat+4]
mov edi,0
cmp dl,'*'
424,11 → 437,11
mov eax,[esp+4]
mov ebx,[esp]
call draw_pawn
 
empty_slot:
 
pop ebx eax
 
inc eax
cmp eax,8
jb scan_board
436,13 → 449,13
inc ebx
cmp ebx,8
jb scan_board
 
mov esi,chess_board
mov edi,board_old
mov ecx,80*19
cld
rep movsb
 
mov eax,13
mov ebx,[boardx]
sub ebx,14
453,8 → 466,8
add ecx,46*8
mov edx,[wcolor]
int 0x40
mov eax,4 ; numbers at left
 
mov eax,4 ; numbers at left
mov ebx,[boardx]
sub ebx,14
shl ebx,16
469,7 → 482,7
add ebx,[boardxs]
cmp edx,chess_board+80*16
jb db1
 
mov eax,13
mov ebx,[boardx]
shl ebx,16
482,8 → 495,8
add ecx,10
mov edx,[wcolor]
int 0x40
mov eax,4 ; letters at bottom
 
mov eax,4 ; letters at bottom
mov ebx,[boardx]
add ebx,3
shl ebx,16
502,15 → 515,15
add edx,4
cmp edx,chess_board+80*17+8+4*8
jb db3
 
; print player times
 
mov edi,74
cmp [chess_board+80+5],byte '1'
jne nowww2
mov edi,371
nowww2:
 
mov eax,13
mov ebx,(conx)*65536+100
mov ecx,edi
518,7 → 531,7
add ecx,10
mov edx,[wcolor]
int 0x40
 
mov eax,4
mov ebx,(conx)*65536
add ebx,edi
526,13 → 539,13
mov edx,chess_board+80*7+59-1
mov esi,20
int 0x40
 
mov edi,74
cmp [chess_board+80+5],byte '1'
je nowww
mov edi,371
nowww:
 
mov eax,13
mov ebx,(conx)*65536+100
mov ecx,edi
540,7 → 553,7
add ecx,10
mov edx,[wcolor]
int 0x40
 
mov eax,4
mov ebx,(conx)*65536
add ebx,edi
548,15 → 561,15
mov edx,chess_board+80*9+59-1
mov esi,20
int 0x40
 
; move #
 
mov eax,13
mov ebx,conx*65536+120
mov ecx,200*65536+10
mov edx,[wcolor]
int 0x40
 
mov eax,4
mov ebx,conx*65536
add ebx,200
564,28 → 577,28
mov edx,chess_board+80*1+46
mov esi,30
int 0x40
 
no_change_in_board:
 
popa
 
ret
 
 
handle_data:
; Telnet servers will want to negotiate options about our terminal window
; just reject them all.
; Telnet options start with the byte 0xff and are 3 bytes long.
 
mov al, [telnetstate]
cmp al, 0
je state0
je state0
cmp al, 1
je state1
je state1
cmp al, 2
je state2
je state2
jmp hd001
 
state0:
cmp bl, 255
jne hd001
592,17 → 605,17
mov al, 1
mov [telnetstate], al
ret
 
state1:
mov al, 2
mov [telnetstate], al
ret
 
state2:
mov al, 0
mov [telnetstate], al
mov [telnetrep+2], bl
 
mov edx, 3
mov eax,53
mov ebx,7
610,9 → 623,9
mov esi, telnetrep
int 0x40
ret
 
hd001:
cmp bl,13 ; BEGINNING OF LINE
cmp bl,13 ; BEGINNING OF LINE
jne nobol
mov ecx,[pos]
add ecx,1
625,13 → 638,13
cmp edx,0
jne boll1
mov [pos],ecx
 
call check_for_board
 
jmp newdata
nobol:
cmp bl,10 ; LINE DOWN
 
cmp bl,10 ; LINE DOWN
jne nolf
addx1:
add [pos],dword 1
644,14 → 657,14
mov eax,[pos]
jmp cm1
nolf:
cmp bl,9 ; TAB
 
cmp bl,9 ; TAB
jne notab
add [pos],dword 8
jmp newdata
notab:
cmp bl,8 ; BACKSPACE
 
cmp bl,8 ; BACKSPACE
jne nobasp
mov eax,[pos]
dec eax
660,8 → 673,8
mov [eax+text+60*80],byte 0
jmp newdata
nobasp:
cmp bl,15 ; CHARACTER
 
cmp bl,15 ; CHARACTER
jbe newdata
mov eax,[pos]
mov [eax+text],bl
671,7 → 684,7
mov ebx,[scroll+4]
imul ebx,80
cmp eax,ebx
jb noeaxz
jb noeaxz
mov esi,text+80
mov edi,text
mov ecx,ebx
683,22 → 696,22
mov [pos],eax
newdata:
ret
red: ; REDRAW WINDOW
 
 
red: ; REDRAW WINDOW
call draw_window
jmp still
key: ; KEY
mov eax,2 ; send to modem
 
key: ; KEY
mov eax,2 ; send to modem
int 0x40
 
mov ebx, [socket_status]
cmp ebx, 4 ; connection open?
jne still ; no, so ignore key
cmp ebx, 4 ; connection open?
jne still ; no, so ignore key
 
shr eax,8
cmp eax,178 ; ARROW KEYS
cmp eax,178 ; ARROW KEYS
jne noaup
mov al,'A'
call arrow
723,49 → 736,49
jmp still
noaleft:
modem_out:
 
call to_modem
 
jmp still
button: ; BUTTON
 
button: ; BUTTON
mov eax,17
int 0x40
cmp ah,1 ; CLOSE PROGRAM
cmp ah,1 ; CLOSE PROGRAM
jne noclose
 
mov eax,53
mov ebx,8
mov ecx,[socket]
int 0x40
 
mov eax,-1
int 0x40
noclose:
cmp ah, 4 ; connect
 
cmp ah, 4 ; connect
jne notcon
 
mov eax, [socket_status]
cmp eax, 4
je still
je still
call connect
 
jmp still
 
notcon:
cmp ah,5 ; disconnect
cmp ah,5 ; disconnect
jne notdiscon
 
call disconnect
jmp still
 
notdiscon:
 
jmp still
 
arrow:
 
push eax
mov al,27
call to_modem
773,10 → 786,10
call to_modem
pop eax
call to_modem
 
ret
 
 
to_modem:
pusha
push ax
794,27 → 807,27
pop bx
mov al, [echo]
cmp al, 0
je tm_001
je tm_001
 
push bx
call handle_data
pop bx
 
cmp bl, 13
jne tm_002
 
mov bl, 10
call handle_data
 
tm_002:
call draw_text
 
tm_001:
popa
ret
 
 
 
disconnect:
mov eax,53
mov ebx,8
821,24 → 834,24
mov ecx,[socket]
int 0x40
ret
 
 
 
connect:
pusha
mov ecx, 1000 ; local port starting at 1000
 
mov ecx, 1000 ; local port starting at 1000
 
getlp:
inc ecx
inc ecx
push ecx
mov eax, 53
mov ebx, 9
int 0x40
pop ecx
cmp eax, 0 ; is this local port in use?
jz getlp ; yes - so try next
mov eax, 53
mov ebx, 9
int 0x40
pop ecx
cmp eax, 0 ; is this local port in use?
jz getlp ; yes - so try next
 
mov eax,53
mov ebx,5
mov dl, [ip_address + 3]
849,138 → 862,130
shl edx, 8
mov dl, [ip_address]
mov esi, edx
movzx edx, word [port] ; telnet port id
movzx edx, word [port] ; telnet port id
mov edi,1 ; active open
int 0x40
mov [socket], eax
 
popa
 
ret
 
 
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window:
 
pusha
 
mov eax,12
mov ebx,1
int 0x40
 
mov eax,14
int 0x40
 
mov ebx,eax
mov ecx,eax
 
shr ebx,16
and ebx,0xffff
and ecx,0xffff
 
shr ebx,1
shr ecx,1
 
sub ebx,275
sub ecx,235
 
shl ebx,16
shl ecx,16
mov eax,0 ; DRAW WINDOW
 
mov eax,0 ; DRAW WINDOW
mov bx,550
mov cx,470
mov edx,[wcolor]
add edx,0x03000000
mov esi,0x80557799
mov edi,0x00557799
add edx,0x13000000
mov edi,header
int 0x40
mov eax,4 ; WINDOW LABEL
mov ebx,8*65536+8
mov ecx,0x10ffffff
mov edx,labelt
mov esi,labellen-labelt
int 0x40
 
call display_status
mov eax,8 ; BUTTON 4: Connect
 
mov eax,8 ; BUTTON 4: Connect
mov ebx,conx*65536+80
mov ecx,cony*65536+15
mov esi,[wbutton]
mov edx,4
int 0x40
mov eax,4 ; Button text
mov eax,4 ; Button text
mov ebx,(conx+4)*65536+cony+4
mov ecx,0xffffff
mov edx,cont
mov esi,conlen-cont
int 0x40
mov eax,8 ; BUTTON 5: disconnect
 
 
mov eax,8 ; BUTTON 5: disconnect
mov ebx,dconx*65536+80
mov ecx,dcony*65536+15
mov edx,5
mov esi,[wbutton]
int 0x40
mov eax,4 ; Button text
mov eax,4 ; Button text
mov ebx,(dconx+4)*65536+dcony+4
mov ecx,0x00ffffff
mov edx,dist
mov esi,dislen-dist
int 0x40
 
 
xor eax,eax
mov edi,text+80*30
mov ecx,80*30 /4
cld
rep stosd
 
call draw_text
 
mov [changed],1
 
mov edi,board_old
mov ecx,80*19
mov al,0
cld
rep stosb
 
mov eax,4
mov ebx,conx*65536+52
mov ecx,[tcolor]
mov edx,quick_start
mov esi,30
 
prqs:
 
int 0x40
add ebx,10
add edx,30
cmp [edx],byte 'x'
jne prqs
 
mov eax,12
mov ebx,2
int 0x40
 
popa
 
ret
 
 
display_status:
 
pusha
 
; draw status bar
mov eax, 13
mov ebx, statusx*65536+80
987,26 → 992,26
mov ecx, statusy*65536 + 16
mov edx, [wcolor]
int 0x40
mov esi,contlen-contt ; display connected status
 
mov esi,contlen-contt ; display connected status
mov edx, contt
mov eax, [socket_status]
cmp eax, 4 ; 4 is connected
je pcon
cmp eax, 4 ; 4 is connected
je pcon
mov esi,discontlen-discontt
mov edx, discontt
pcon:
mov eax,4 ; status text
mov eax,4 ; status text
mov ebx,statusx*65536+statusy+2
mov ecx,[tcolor]
int 0x40
 
popa
ret
 
 
nappulat:
 
dd '*P ',5
dd '*K ',3
dd '*Q ',4
1013,9 → 1018,9
dd '*R ',0
dd '*N ',1
dd '*B ',2
 
dd ' ',20
 
dd 'P ',5
dd 'K ',3
dd 'Q ',4
1022,85 → 1027,85
dd 'R ',0
dd 'N ',1
dd 'B ',2
 
 
row dd 0x0
col dd 0x0
 
 
 
draw_text:
 
mov esi,text+80*24
mov edi,texts+80*3
 
dtl1:
 
cmp [esi],dword 'logi'
je add_text
je add_text
cmp [esi],dword 'aics'
je add_text
je add_text
cmp [esi],dword 'You '
je add_text
je add_text
cmp [esi],dword 'Your'
je add_text
je add_text
cmp [esi],dword 'Game'
je add_text
je add_text
cmp [esi],dword 'Ille'
je add_text
je add_text
cmp [esi],dword 'No s'
je add_text
je add_text
 
sub esi,80
cmp esi,text
jge dtl1
 
dtl2:
 
mov eax,13
mov ebx,10*65536+532
mov ecx,420*65536+40
mov edx,[wtcom]
int 0x40
 
mov eax,4
mov ebx,10*65536+420
mov ecx,[wtxt]
mov edx,texts
mov esi,80
 
dtl3:
 
int 0x40
add edx,80
add ebx,10
cmp edx,texts+4*80
jb dtl3
jb dtl3
 
ret
 
add_text:
 
pusha
 
cld
mov ecx,80
rep movsb
 
popa
 
 
sub esi,80
sub edi,80
 
cmp edi,texts
jb dtl2
jb dtl2
 
jmp dtl1
 
 
read_string:
 
mov edi,string
mov eax,'_'
mov ecx,[string_length]
1108,7 → 1113,7
cld
rep stosb
call print_text
 
mov edi,string
f11:
mov eax,10
1119,11 → 1124,11
int 0x40
shr eax,8
cmp eax,13
je read_done
je read_done
cmp eax,8
jnz nobsl
cmp edi,string
jz f11
jz f11
sub edi,1
mov [edi],byte '_'
call print_text
1132,29 → 1137,29
cmp eax,dword 31
jbe f11
cmp eax,dword 95
jb keyok
jb keyok
sub eax,32
keyok:
mov [edi],al
call print_text
 
inc edi
mov esi,string
add esi,[string_length]
cmp esi,edi
jnz f11
 
read_done:
 
call print_text
 
ret
 
 
print_text:
 
pusha
 
mov eax,13
mov ebx,[string_x]
shl ebx,16
1165,7 → 1170,7
mov cx,8
mov edx,[wcolor]
int 0x40
 
mov eax,4
mov ebx,[string_x]
shl ebx,16
1174,150 → 1179,150
mov edx,string
mov esi,[string_length]
int 0x40
 
popa
ret
 
 
 
 
; DATA AREA
telnetrep db 0xff,0xfc,0x00
telnetstate db 0
 
telnetrep db 0xff,0xfc,0x00
telnetstate db 0
 
string_length dd 16
string_x dd 200
string_y dd 60
string db '________________'
tx_buff db 0, 10
ip_address db 204,178,125,65
port dw 5051 ; 0,0
echo db 1
socket dd 0x0
socket_status dd 0x0
pos dd 80 * 22
scroll dd 1
dd 24
wbutton dd 0x336688
wtcom dd 0x336688 ; 0x666666
wtxt dd 0xffffff
wcolor dd 0xe0e0e0
tcolor dd 0x000000
sq_black dd 0x336688 ; 666666
sq_white dd 0xffffff
labelt db 'Chess Client for Chessclub.com - v0.1'
labellen:
setipt db ' . . .'
 
string db '________________'
 
tx_buff db 0, 10
ip_address db 204,178,125,65
port dw 5051 ; 0,0
echo db 1
socket dd 0x0
socket_status dd 0x0
pos dd 80 * 22
scroll dd 1
dd 24
 
wbutton dd 0x336688
 
wtcom dd 0x336688 ; 0x666666
wtxt dd 0xffffff
 
wcolor dd 0xe0e0e0
tcolor dd 0x000000
 
sq_black dd 0x336688 ; 666666
sq_white dd 0xffffff
 
header db appname,version,0
 
setipt db ' . . .'
setiplen:
setportt db ' '
setportt db ' '
setportlen:
cont db 'Connect'
cont db 'Connect'
conlen:
dist db 'Disconnect'
dist db 'Disconnect'
dislen:
contt db 'Connected'
contt db 'Connected'
contlen:
discontt db 'Disconnected'
discontt db 'Disconnected'
discontlen:
echot db 'Echo On'
echot db 'Echo On'
echolen:
echoot db 'Echo Off'
echoot db 'Echo Off'
echoolen:
 
quick_start:
db '( OPPONENT ) '
 
db '( OPPONENT ) '
 
times 16 db ' 1'
db 'Quick start: '
db ' '
db '1 Connect '
db '2 login: "guest" '
db '3 aics% "seek 10 0" '
db ' (for a player) '
db ' (wait) '
db '4 Play eg. "e7e5" '
db ' or "d2d4" '
db '5 aics% "resign" '
db ' (quit game) '
db '6 Disconnect '
 
db 'Quick start: '
db ' '
db '1 Connect '
db '2 login: "guest" '
db '3 aics% "seek 10 0" '
db ' (for a player) '
db ' (wait) '
db '4 Play eg. "e7e5" '
db ' or "d2d4" '
db '5 aics% "resign" '
db ' (quit game) '
db '6 Disconnect '
 
times 5 db ' '
db '( YOU ) '
db 'x'
 
db '( YOU ) '
 
db 'x'
 
 
chess_board:
times 80 db 0
 
times 80 db 0
 
db ' 8 *R *N *B *Q *K *B *N *R'
db ' '
times 80 db 0
 
times 80 db 0
 
db ' 7 *P *P *P *P *P *P *P *P'
db ' '
times 80 db 0
 
times 80 db 0
 
db ' 6 '
db ' '
times 80 db 0
 
times 80 db 0
 
db ' 5 '
db ' '
times 80 db 0
 
times 80 db 0
 
db ' 4 '
db ' '
times 80 db 0
 
times 80 db 0
 
db ' 3 '
db ' '
times 80 db 0
 
times 80 db 0
 
db ' 2 P P P P P P P P '
db ' '
times 80 db 0
 
times 80 db 0
 
db ' 1 R N B Q K B N R '
db ' '
times 80 db 0
 
times 80 db 0
 
db ' a b c d e f g h '
db ' '
 
 
times 80*20 db 0
 
board_old:
 
 
I_END:
 
 
 
 
 
 
 
 
 
/programs/games/tetris/trunk/build_en.bat
1,4 → 1,5
@erase lang.inc
@echo lang fix en >lang.inc
@fasm tetris.asm tetris
@erase lang.inc
@pause
/programs/games/tetris/trunk/build_ru.bat
1,4 → 1,5
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm tetris.asm tetris
@erase lang.inc
@pause
/programs/games/tetris/trunk/macros.inc
123,8 → 123,10
end if
}
 
macro __mov reg,a { ; mike.dld
if ~a eq
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
}
144,7 → 146,6
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
/programs/games/tetris/trunk/tetris.asm
42,7 → 42,7
DOWN_KEY equ 129+48
LEFT_KEY equ 128+48
RIGHT_KEY equ 131+48
BACKGROUND equ 03000080h
;BACKGROUND equ 03000080h
 
_MAXBLOCKS_ = 7*4
 
220,7 → 220,7
jmp still
 
end_program:
mov eax,0xffffffff ; close this program
mov eax,-1 ; close this program
int 0x40
 
go_new_game:
241,64 → 241,51
draw_window:
 
 
mov eax,48
mov ebx,3
mov ecx,sc
mov edx,sizeof.system_colors
int 0x40
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
 
; DRAW WINDOW
mov eax,0 ; function 0 : define and draw window
xor eax,eax ; function 0 : define and draw window
mov ebx,320*65536+(LEN_X-BORDER_LEFT-BORDER_RIGHT)*ADOBE_SIZE+X_LOCATION*2
mov ecx,25*65536+ (LEN_Y-BORDER_TOP-BORDER_BOTTOM)*ADOBE_SIZE+Y_LOCATION+30
mov edx,BACKGROUND ; color of work area RRGGBB
mov esi,0x006688ee;99bbff ; color of grab bar RRGGBB,8->col
mov edi,0x007799ff;99bbee ; color of frames RRGGBB
mov edx,[sc.work] ; color of work area RRGGBB
or edx,0x13000000
mov edi,header ; WINDOW LABEL
int 0x40
 
; WINDOW LABEL
mov eax,4 ; function 4 : write text to window
mov ebx,8*65536+8 ; [x start] *65536 + [y start]
mov ecx,0x10ffffff ; color of text RRGGBB
mov edx,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
 
; CLOSE BUTTON
; mov eax,8 ; function 8 : define and draw button
; mov ebx,243*65536+12 ; [x start] *65536 + [x size]
; mov ecx,5*65536+12 ; [y start] *65536 + [y size]
; mov edx,1 ; button id
; mov esi,0x5580cc;22aacc ; button color RRGGBB
; int 0x40
 
mov eax,8
mov ebx,30*65536+102
mov ebx,30*65536+100
mov ecx,378*65536+18
mov edx,2
mov esi,0xA24466;5580cc;22aacc
mov esi,[sc.work_button]
int 0x40
;/////////////////////////////////////////////// Wildwest's 'Pause' button
mov eax,8
;mov eax,8
mov ebx,132*65536+102
mov ecx,378*65536+18
mov edx,3
mov esi,0x0FA0F0;
mov esi,[sc.work_button];
int 0x40
 
mov eax,4 ; function 4 : write text to window
mov ebx,164*65536+384 ; [x start] *65536 + [y start]
mov ecx,0x10ffffff ; color of text RRGGBB
mov edx,labe ; pointer to text beginning
mov esi,labelen-labe ; text length
mov ebx,164*65536+384 ; [x start] *65536 + [y start]
mov ecx,[sc.work_button_text] ; color of text RRGGBB
or ecx,0x90000000
mov edx,labe ; pointer to text
int 0x40
;///////////////////////////////////////////////
mov eax,4
;mov eax,4
mov ebx,49*65536+384
xor ecx,ecx
mov ecx,0x10ffffff
mov edx,game_finished
mov esi,size_of_game_finished-game_finished
int 0x40
 
call draw_table
 
movzx edx,byte [current_block_color]
306,9 → 293,9
 
cld
mov ebx,38*65536+35 ; draw info text with function 4
mov ecx,0x10ffffff ; color
mov ecx,[sc.work_text] ; color
or ecx,0x90000000
mov edx,text
mov esi,7
mov eax,4
int 0x40
 
454,7 → 441,7
; mov ebx,10
; int 0x40
; popa
mov ax,13
mov eax,13
movzx edx,byte [esi]
mov edx,[color_table+edx*4]
int 0x40
655,16 → 642,12
mov eax,[score]
call number_to_str
 
mov ebx,100*65536+100 ;clear box to write new score
mov ecx,35*65536+15
mov edx,BACKGROUND
mov eax,13
int 40h
 
mov ebx,100*65536+35 ; draw info text with function 4
mov ecx,0xffff00 ; color
mov ebx,90*65536+35 ; draw info text with function 4
mov ecx,[sc.work_text] ; color
or ecx,0x50000000
mov edx,number_str
mov esi,[size_of_number_str]
mov edi,[sc.work]
mov eax,4
int 0x40
ret
842,27 → 825,17
 
if lang eq ru
 
labelt:
db '’…’ˆ‘ 1.6 - ‘’…‹Šˆ ˆ Ž…‹'
labellen:
labe:
db '€“‡€'
labelen:
text: db 'Žçª¨: '
game_finished: db ' €—€’œ'
size_of_game_finished:
header db '’…’ˆ‘ 1.61 - ‘’…‹Šˆ ˆ Ž…‹',0
labe db '€“‡€',0
text db 'Žçª¨:',0
game_finished: db 'Ž‚€Ÿ',0
 
else
 
labelt:
db 'TETRIS 1.6 - ARROWS & SPACE'
labellen:
labe:
db 'PAUSE'
labelen:
text: db 'Score: '
game_finished: db 'NEW GAME'
size_of_game_finished:
header db 'TETRIS 1.61 - ARROWS & SPACE',0
labe db 'PAUSE',0
text db 'Score:',0
game_finished: db 'NEW GAME',0
 
end if
 
880,6 → 853,8
end_number_str:
size_of_number_str dd 9
delay: db 40
sc system_colors
table_tetris:
 
I_END:
 
/programs/media/animage/trunk/animage.asm
0,0 → 1,5679
;******************************************************
;***GRAPHICS EDIT ANIMAGE creted by andrew_programmer**
;******************************************************
 
use32
org 0x0
 
db 'MENUET01'
dd 0x1
dd START
dd I_END
dd 0x19000;100 kb
dd 0x19000;
dd 0x0
dd 0x0
include 'giflib.inc'
include 'bmplib.inc'
include 'dialog.inc'
include 'dialog2.inc'
include 'design.inc'
include 'graphlib.inc'
START:
 
;--------------------------------------------------------
;---------------set events mask--------------------------
;--------------------------------------------------------
mov eax,40
mov ebx,1100111b
int 0x40
 
;---------------------------------------------------------
;--------initializate data and params of program----------
;---------------------------------------------------------
mov [Scroll1CoordinatX],8+1
mov [Scroll2CoordinatY],20+15+1+46+3
mov [Window_SizeX],640
mov [Window_SizeY],400
mov [Window_CordinatX],50
mov [Window_CordinatY],50
mov [WorkScreen_SizeX],100
mov [WorkScreen_SizeY],100
mov [MaxWorkScreen_SizeX],100
mov [MaxWorkScreen_SizeY],100
mov [ScreenPointer],0x19000
and [PosX],0
and [PosY],0
mov [Picture_SizeX],640;400
mov [Picture_SizeY],400;280
mov [k],1
mov [PointerToPicture],0x19000+(1200*1000*3)+30*(20*20*3)+500000
mov [PointerToCopyPicture],0x19000+(1200*1000*3)+30*(20*20*3)+500000+(640*400*3)
mov [PointerToCopyPicture2],0x19000+(1200*1000*3)+30*(20*20*3)+500000+(640*400*3)*2
mov [PointerToEditBufer],0x19000+(1200*1000*3)+30*(20*20*3)+500000+(640*400*3)*3
mov [PointerToSpriteBufer],0x19000+(1200*1000*3)+30*(20*20*3)+500000+(640*400*3)*4
mov [PointerToPalette],0x19000+(1200*100*3)+30*(20*20*3)+1
mov [ReserveArray],0x19000+(1200*1000)*3+30*(20*20*3)+8
and [save_flag],0
mov [line_width],1
mov [lastik_is_active],0
and [crossing],0
and [finishing_crossing],0
and [number_undo],0
and [instrument_used],0
and [DrawSprite_flag],0
and [extended_memory],0
 
finit
;----------------------------------------------------------
;--------get memory and draw window of program-------------
;----------------------------------------------------------
call GetMemory
 
call cleare_work_arrea
call load_icons
call drawwin
;----------------------------------------------------------
;---------------------MAIN LOOP----------------------------
;----------------------------------------------------------
main_loop:
still:
 
call event
 
cmp eax,1
jne no_redraw_window
call drawwin
call drawwin
jmp still
no_redraw_window:
cmp eax,3
je buttons
cmp eax,6
je mouse
cmp eax,2
je keys
jmp main_loop
 
;------------------------------------------
;-------------KEYS-------------------------
;------------------------------------------
keys:
 
mov eax,2
int 0x40
shr eax,8
 
cmp eax,176
jne key2
sub [PosX],20
jmp change_screen
key2:
cmp eax,179
jne key3
add [PosX],20
jmp change_screen
key3:
cmp eax,177
jne key4
add [PosY],20
jmp change_screen
key4:
cmp eax,178
jne key5
sub [PosY],20
jmp change_screen
key5:
cmp eax,49
jne key6
mov [k],1
mov [Scroll1CoordinatX],9
mov [Scroll2CoordinatY],85
call drawwin
jmp change_screen
key6:
cmp eax,50
jne key7
mov [k],2
mov [Scroll1CoordinatX],9
mov [Scroll2CoordinatY],85
call drawwin
jmp change_screen
key7:
cmp eax,52
jne key8
mov [k],4
mov [Scroll1CoordinatX],9
mov [Scroll2CoordinatY],85
call drawwin
jmp change_screen
key8:
cmp eax,56
jne key9
mov [k],8
mov [Scroll1CoordinatX],9
mov [Scroll2CoordinatY],85
call drawwin
jmp change_screen
key9:
cmp eax,48
jne key10
mov [k],16
mov [Scroll1CoordinatX],9
mov [Scroll2CoordinatY],85
call drawwin
jmp change_screen
key10:
cmp eax,255
jne key11
call analizing_picture_to_palette
call drawwin
jmp change_screen
key11:
cmp eax,27
jne still
mov eax,-1
int 0x40
jmp still
 
change_screen:
 
call CalculatePositionScreen
call MovePictureToWorkScreen
call draw_scrollers
call PrintMousePos
 
jmp still
;---------------------------------------------
;-----------panel BUTTONS---------------------
;---------------------------------------------
buttons:
 
cmp [Current_instrument],30
jne no_finish_instrument_button
 
cmp [instrument_used],1
jne no_finish_instrument_button
 
cmp [Activate_instrument],0
jne no_finish_instrument_button
 
cmp [crossing],1
jne no_finish_instrument_button
 
mov [finishing_crossing],1
call TakeButtonInstruments
 
no_finish_instrument_button:
 
mov eax,17
int 0x40
 
shr eax,8
 
cmp eax,1
jne no_exit
 
mov eax,-1
int 0x40
 
no_exit:
 
mov [Current_instrument],eax
 
cmp eax,10
jl still
 
cmp eax,15
je still
 
cmp eax,17
je still
 
cmp eax,18
je still
 
cmp eax,19
je still
 
cmp eax,20
je still
 
cmp eax,21
jne no_palette_
 
call TakeButtonInstruments
jmp still
 
no_palette_:
 
cmp eax,23
je still
 
cmp eax,30
jne no_allocation__
 
and [Activate_instrument],0
jmp still
 
no_allocation__:
 
cmp eax,38
jne no_kontur__
 
and [instrument_used],0
jmp still
 
no_kontur__:
 
call TakeButtonInstruments
jmp still
;---------------------------------------------
;-------------interraction MOUSE--------------
;---------------------------------------------
mouse:
 
call GetMouseCoordinats
 
;panel
mov edx,[Window_SizeX]
sub edx,5
 
cmp ebx,20
jle no_panel
 
cmp ebx,20+15
jae no_panel
 
cmp eax,5
jle no_panel
 
cmp eax,edx ;585
jae no_panel
 
call GetMouseCoordinats
 
mov [counter],7
mov edi,panel_text
call panel_interraction
 
jmp still
no_panel:
 
cmp [Panel_flag],0
jz no_redraw_panel
 
mov [counter],7
mov edi,panel_text
call panel_interraction
 
no_redraw_panel:
 
call GetMouseCoordinats
mov eax,[MouseX]
mov ebx,[MouseY]
mov ecx,[WorkScreen_SizeX]
mov edx,[WorkScreen_SizeY]
add ecx,9
add edx,85
 
cmp eax,ecx
jae mouse_scroll
 
cmp ebx,edx
jae mouse_scroll
 
jmp no_scrollers
 
mouse_scroll:
 
mov [exit_from_work_arrea],1 ;mouse situated after work arrea
 
;scrollers
call GetMouseClick
 
cmp eax,1
jne no_click
 
call GetMouseCoordinats
;interraction with horizontal scroller
mov eax,[Scroll1CoordinatX]
mov ebx,[Scroll1CoordinatY]
mov ecx,[MouseX]
mov edx,[MouseY]
mov esi,[Scroll1MaxSizeX]
mov edi,[Scroll1MaxSizeY]
call columnus
 
test eax,eax
jz no_horizontal
 
 
mov eax,9
mov ebx,[Scroll1CoordinatY]
mov ecx,[Scroll1MaxSizeX]
mov edx,14+10
mov esi,7
inc ecx
call draw_volume_rectangle
 
mov eax,[MouseX]
mov ebx,[Scroll1SizeX]
shr ebx,1
sub eax,ebx
mov ecx,[MouseX]
add ecx,ebx
mov edx,8+1
add edx,[Scroll1MaxSizeX]
mov [Scroll1CoordinatX],eax
 
sub eax,9
jns no_min_scroll
 
mov [Scroll1CoordinatX],9
 
no_min_scroll:
 
cmp ecx,edx
jl no_max_scroll
 
sub edx,ebx
sub edx,ebx
mov [Scroll1CoordinatX],edx
 
no_max_scroll:
;
mov eax,[Scroll1CoordinatX]
sub eax,9
mov ebx,[Picture_SizeX]
imul eax,ebx
mov ebx,[Scroll1MaxSizeX]
cdq
idiv ebx
mov [PosX],eax
 
jmp no_vertical
 
no_horizontal:
 
mov eax,[Scroll2CoordinatX]
mov ebx,[Scroll2CoordinatY]
mov ecx,[MouseX]
mov edx,[MouseY]
mov esi,[Scroll2MaxSizeX]
mov edi,[Scroll2MaxSizeY]
call columnus
 
test eax,eax
jz no_vertical
 
mov eax,[Scroll2CoordinatX]
mov ebx,85
mov ecx,14+10
mov edx,[Scroll2MaxSizeY]
mov esi,7
inc edx
call draw_volume_rectangle
 
mov eax,[MouseY]
mov ebx,[Scroll2SizeY]
shr ebx,1
sub eax,ebx
mov ecx,[MouseY]
add ecx,ebx
mov edx,85
add edx,[Scroll2MaxSizeY]
mov [Scroll2CoordinatY],eax
 
sub eax,85
jns no_min_scroll2
 
mov [Scroll2CoordinatY],85
 
no_min_scroll2:
 
cmp ecx,edx
jl no_max_scroll2
 
sub edx,ebx
sub edx,ebx
mov [Scroll2CoordinatY],edx
 
no_max_scroll2:
;
mov eax,[Scroll2CoordinatY]
sub eax,85
mov ebx,[Picture_SizeY]
imul eax,ebx
mov ebx,[Scroll2MaxSizeY]
cdq
idiv ebx
mov [PosY],eax
 
no_vertical:
 
call CalculatePositionScreen
 
call draw_scrollers
call MovePictureToWorkScreen
 
no_click:
 
jmp still
no_scrollers:
 
 
mov eax,[MouseX]
mov ebx,[MouseY]
mov ecx,[Window_SizeX]
mov edx,[Window_SizeY]
sub ecx,36
sub edx,35
 
cmp eax,9
jle not_work_arrea
 
cmp eax,ecx
jae not_work_arrea
 
cmp ebx,20+15+1+46
jle not_work_arrea
 
cmp ebx,edx
jae not_work_arrea
 
jmp mouse_in_work_arrea
 
not_work_arrea:
 
mov [exit_from_work_arrea],1
 
jmp still
 
mouse_in_work_arrea:
 
call GetScreenCordinats
call PrintMousePos
call GetMouseClick
 
test eax,eax
jz no_use_instruments
 
cmp [Activate_instrument],0
 
jnz no_undo___
;------------begin copy for undo-------------
inc [number_undo]
 
cmp [number_undo],1
jne no_one__
 
mov edi,[PointerToCopyPicture]
 
no_one__:
 
cmp [number_undo],2
jne no_two__
 
mov edi,[PointerToCopyPicture2]
 
no_two__:
 
cmp [number_undo],3
jne no_three__
 
;copy bufer number two to bufer number one
mov esi,[PointerToCopyPicture2]
mov edi,[PointerToCopyPicture]
mov ecx,[Picture_SizeX]
imul ecx,[Picture_SizeY]
lea ecx,[ecx+ecx*2]
add ecx,4
shr ecx,2
inc ecx
cld
rep movsd
;end copy
dec [number_undo]
mov edi,[PointerToCopyPicture2]
 
no_three__:
 
mov esi,[PointerToPicture]
mov ecx,[Picture_SizeX]
imul ecx,[Picture_SizeY]
lea ecx,[ecx+ecx*2]
add ecx,4
shr ecx,2
inc ecx
cld
rep movsd
;--------------end copy for undo-------------
no_undo___:
 
call TakeButtonInstruments
no_use_instruments:
 
mov eax,[Current_instrument]
and [Activate_instrument],0
 
jmp still
;-----------------------------------------------
;---------get mouse cordinats-------------------
;-----------------------------------------------
GetMouseCoordinats:
 
mov eax,37
mov ebx,1
int 0x40
 
mov ebx,eax
shr eax,16
and ebx,0xffff
 
mov [MouseX],eax
mov [MouseY],ebx
 
ret
;------------------------------------------------
;-------get mouse attributs----------------------
;------------------------------------------------
GetMouseClick:
mov eax,37
mov ebx,2
int 0x40
 
ret
;-------------------------------------------------
;-----interraction panel with user----------------
;-------------------------------------------------
panel_interraction:
;>>>>>>>>>>>>>>>>>>>>>>>>>>
mov eax,18
mov ebx,14
int 0x40
 
and [Panel_flag],0
;collision with text on panel
next_columnus_text:
 
mov eax,[edi]
mov ebx,[edi+4]
sub eax,10
sub ebx,3
mov [Icon_text_x],eax
mov [Icon_text_y],ebx
mov esi,[edi+8]
add edi,esi
add edi,3*4
mov ecx,[MouseX]
mov edx,[MouseY]
push edi
mov edi,13
mov esi,80
call columnus
 
pop edi
mov esi,7
 
test eax,eax
jz no_columnus_text
 
mov esi,1
mov [Panel_flag],1
call GetMouseClick
 
test eax,eax
jz no_mouse_pressed
 
call print_panel_menu
 
no_mouse_pressed:
 
no_columnus_text:
 
mov eax,[Icon_text_x]
mov ebx,[Icon_text_y]
mov ecx,79
mov edx,13
call draw_volume_rectangle
 
push [counter]
push edi
mov [counter],7
mov edi,panel_text
call print_panel_text
 
pop edi
pop [counter]
dec [counter]
jnz next_columnus_text
 
ret
;---------------------------------------------------------
;-----draw panel menu(main engin of panel)----------------
;---------------------------------------------------------
print_panel_menu:
 
 
push [counter]
;delit icon buttons(some time)
mov [counter],10
next_icon_delit:
mov eax,8
mov edx,[counter]
add edx,11100000000000000000000000000000b
int 0x40
inc [counter]
 
cmp [counter],30
jl next_icon_delit
 
pop [counter]
 
push esi
mov esi,[counter]
dec esi
shl esi,4
 
mov eax,[menu_rectangles+esi]
mov ebx,[menu_rectangles+esi+4]
mov ecx,[menu_rectangles+esi+8]
mov edx,[menu_rectangles+esi+12]
mov esi,1
mov [menu_coordinat_x],eax
mov [menu_size_x],ecx
call draw_volume_rectangle
pop esi
 
calculate_counter_menu:
 
 
;calculate menu counter
mov eax,[counter]
dec eax
shl eax,2
mov ebx,[menu_counters+eax]
mov [counter_menu],ebx
 
call GetMouseCoordinats
 
and [menu_counter],0
push esi
push edi
;ᣫ ¦¨¢ ­¨¥  ­¨¬ æ¨¨ >>>>>>>>>>>>>>>>>>
mov eax,18
mov ebx,14
int 0x40
 
menu_loop:
 
mov eax,[menu_coordinat_x]
mov ebx,36
mov ecx,[MouseX]
mov edx,[MouseY]
mov esi,[menu_size_x]
mov edi,18
add ebx,[menu_counter]
add eax,2
sub esi,3
inc ebx
call columnus
mov esi,7
 
test eax,eax
jz no_columnus_menu_text
 
mov esi,1
 
no_columnus_menu_text:
 
mov eax,[menu_coordinat_x]
mov ebx,36
mov ecx,[menu_size_x]
mov edx,18
add ebx,[menu_counter]
add eax,2
sub ecx,3
inc ebx
call draw_volume_rectangle
add [menu_counter],20
 
 
dec [counter_menu]
jnz menu_loop
 
;print menu text
push [counter]
mov esi,[counter]
dec esi
shl esi,2
mov edi,[menu_text_en+esi]
mov eax,[menu_counters+esi]
mov [counter],eax
call print_panel_text
pop [counter]
pop edi
pop esi
 
 
menu_still:
 
mov eax,10
int 0x40
mov eax,2
int 0x40
mov eax,17
int 0x40
 
call GetMouseClick
 
test eax,eax
jz calculate_counter_menu
 
call GetMouseCoordinats
 
;calculate menu counter
mov eax,[counter]
dec eax
shl eax,2
mov ebx,[menu_counters+eax]
mov [counter_menu],ebx
 
and [menu_counter],0
and [counter_11],0
 
push esi
push edi
 
menu_loop2:
 
 
mov eax,[menu_coordinat_x]
mov ebx,36
mov ecx,[MouseX]
mov edx,[MouseY]
mov esi,[menu_size_x]
mov edi,18
add ebx,[menu_counter]
add eax,2
sub esi,3
inc ebx
call columnus
 
inc [counter_11]
 
test eax,eax
jz no_columnus_menu_text2
 
mov esi,[counter_11]
mov [number_menu],esi
 
no_columnus_menu_text2:
 
add [menu_counter],20
 
dec [counter_menu]
jnz menu_loop2
 
pop edi
pop esi
 
mov eax,5
mov ebx,15
int 0x40
 
push [counter]
pushad
 
call drawwin
 
popad
pop [counter]
 
mov eax,[counter]
mov [number_panel],eax
 
call TakeInstruments
jmp still
 
;---------------------------------------------------------
;------print mouse position on panel----------------------
;---------------------------------------------------------
PrintMousePos:
 
pushad
 
mov eax,385
mov ebx,20+15+6
mov ecx,52
mov edx,18
mov esi,4
call draw_volume_rectangle
 
mov eax,385
mov ebx,20+15+6+18+1
mov ecx,52
mov edx,18
mov esi,4
call draw_volume_rectangle
 
mov eax,390
mov ebx,20+15+6+6
and ecx,0
mov edx,mouse_pos_x
mov esi,2
call print_text
 
mov eax,390
mov ebx,20+15+6+6+18+1
and ecx,0
mov edx,mouse_pos_y
mov esi,2
call print_text
 
mov eax,47
mov ebx,4*65536
mov ecx,[ScreenX]
add ecx,[PosX]
mov edx,405*65536+20+15+6+6
and esi,0
int 0x40
 
mov eax,47
mov ebx,4*65536
mov ecx,[ScreenY]
add ecx,[PosY]
mov edx,405*65536+20+15+6+18+1+6
and esi,0
int 0x40
 
popad
ret
 
;---------------------------------------------------------
;---------- get time in 1/100 secunds---------------------
;---------------------------------------------------------
Clock:
mov eax,26
mov ebx,9
int 0x40
mov [time],eax
ret
;----------------------------------------------------------
;-------------draw window of program-----------------------
;----------------------------------------------------------
drawwin:
 
mov eax,12
mov ebx,1
int 0x40
 
and eax,0
mov ebx,[Window_CordinatX]
mov ecx,[Window_CordinatY]
shl ebx,16
shl ecx,16
add ebx,[Window_SizeX]
add ecx,[Window_SizeY]
mov edx,0x03aabbcc
mov esi,0x805080d0
mov edi,0x005080d0
int 0x40
 
call draw_panel
call PrintMousePos
 
mov [counter],7
mov edi,panel_text
call print_panel_text
 
mov eax,10
mov ebx,5
mov ecx,0xffffff
mov edx,name_of_program
mov esi,34
call print_text
 
mov eax,13
mov ebx,447*65536+35
mov ecx,42*65536+36
mov edx,[Color]
int 0x40
 
mov eax,12
mov ebx,2
int 0x40
 
mov eax,9
mov ebx,IPC_table
or ecx,-1
int 0x40
 
mov eax,[IPC_table+34]
mov ebx,[IPC_table+38]
mov ecx,[IPC_table+42]
mov edx,[IPC_table+46]
mov [Window_CordinatX],eax
mov [Window_CordinatY],ebx
mov [Window_SizeX],ecx
mov [Window_SizeY],edx
 
cmp [Window_SizeX],585
jae no_minimum_size_x
 
mov [Window_SizeX],585
mov ecx,[Window_SizeX]
 
no_minimum_size_x:
 
cmp [Window_SizeY],320
jae no_minimum_size_y
 
mov [Window_SizeY],320
mov edx,[Window_SizeY]
 
no_minimum_size_y:
 
mov [MaxWorkScreen_SizeX],ecx
mov [MaxWorkScreen_SizeY],edx
sub [MaxWorkScreen_SizeX],20+10+5+10
sub [MaxWorkScreen_SizeY],20+10+15+1+45+20+10
 
cmp [MaxWorkScreen_SizeX],0
jns no_znak1
 
mov [MaxWorkScreen_SizeX],ecx
 
no_znak1:
cmp [MaxWorkScreen_SizeY],0
jns no_znak2
 
mov [MaxWorkScreen_SizeY],ecx
 
no_znak2:
 
mov ecx,[k]
 
and [PosX],0
and [PosY],0
call MovePictureToWorkScreen
call draw_scrollers
call draw_icons
 
ret
;----------------------------------------------------------
;---------------draw panel in window of program------------
;----------------------------------------------------------
draw_panel:
 
mov eax,5
mov ebx,20
mov ecx,[Window_SizeX]
mov edx,15
mov esi,6
sub ecx,10
call draw_volume_rectangle
 
mov eax,5
mov ebx,20
mov ecx,[Window_SizeX]
mov edx,15
mov esi,6
sub ecx,10
call draw_volume_rectangle
 
mov eax,5
mov ebx,20+15+1
mov ecx,[Window_SizeX]
mov edx,46
mov esi,1
sub ecx,10
call draw_volume_rectangle
 
mov eax,5
mov ebx,20+15+1+46+1
mov ecx,[Window_SizeX]
mov edx,[Window_SizeY]
mov esi,1
sub ecx,10+20
sub edx,20+15+1+46+1+5+20
call draw_volume_rectangle
 
mov eax,5
mov ebx,[Window_SizeY]
mov ecx,[Window_SizeX]
mov edx,20+10
mov esi,3
sub ecx,30
sub ebx,25+10
call draw_volume_rectangle
 
mov eax,[Window_SizeX]
mov ebx,20+15+1+45+2
mov ecx,20+10
mov edx,[Window_SizeY]
mov esi,3
sub eax,25+10
sub edx,20+15+1+45+5+20
call draw_volume_rectangle
 
mov eax,[Window_SizeX]
mov ebx,[Window_SizeY]
mov ecx,20+10
mov edx,20+10
mov esi,6
sub eax,25+10
sub ebx,25+10
call draw_volume_rectangle
 
mov eax,445
mov ebx,20+15+6
mov ecx,37
mov edx,37
mov esi,4
call draw_volume_rectangle
 
ret
;----------------------------------------------------------
;---------------------system events------------------------
;----------------------------------------------------------
event:
mov eax,10
int 0x40
ret
 
;----------------------------------------------------------
;----------print text on the panel and menu----------------
;----------------------------------------------------------
print_panel_text:
next_panel_text:
 
mov eax,[edi]
mov ebx,[edi+4]
xor ecx,ecx
mov edx,edi
add edx,12
mov esi,[edi+8]
add edi,esi
add edi,3*4
 
push edi
call print_text
pop edi
 
dec [counter]
jnz next_panel_text
ret
;----------------------------------------------------------
;--------Move picture from array to work screeen-----------
;----------------------------------------------------------
MovePictureToWorkScreen:
 
call cleare_screen
 
mov eax,[Picture_SizeX]
mov ebx,[Picture_SizeY]
mov ecx,[MaxWorkScreen_SizeX]
mov edx,[MaxWorkScreen_SizeY]
mov esi,[k]
imul eax,esi
imul ebx,esi
 
cmp eax,ecx
jle lab1
mov eax,[MaxWorkScreen_SizeX]
mov [WorkScreen_SizeX],eax
jmp lab2
lab1:
mov [WorkScreen_SizeX],eax
lab2:
 
cmp ebx,edx
jle lab3
mov ebx,[MaxWorkScreen_SizeY]
mov [WorkScreen_SizeY],ebx
jmp lab4
lab3:
mov [WorkScreen_SizeY],ebx
lab4:
 
mov eax,[WorkScreen_SizeX]
mov ebx,[k]
cdq
idiv ebx
mov [CounterX],eax
mov eax,[WorkScreen_SizeY]
cdq
idiv ebx
mov [CounterY],eax
 
mov eax,[WorkScreen_SizeX]
mov ecx,eax
mov ebx,[k]
cdq
idiv ebx
imul eax,ebx
sub ecx,eax
lea ecx,[ecx+ecx*2]
;
mov eax,[WorkScreen_SizeX]
mov ebx,[k]
dec ebx
imul eax,ebx
lea eax,[eax+eax*2]
add eax,ecx
mov [OffsetYWorkScreen],eax
 
 
mov ebx,[Picture_SizeX]
mov eax,[CounterX]
sub ebx,eax
lea ebx,[ebx+ebx*2]
mov [OffsetYPicture],ebx
 
mov eax,[WorkScreen_SizeX]
mov ebx,[k]
sub eax,ebx
lea eax,[eax+eax*2]
mov [OffsetYBigPixel],eax
 
mov eax,[PosX]
mov ebx,[PosY]
mov ecx,[Picture_SizeX]
imul ecx,ebx
add eax,ecx
lea eax,[eax+eax*2]
add eax,[PointerToPicture]
 
 
mov ebx,[ScreenPointer]
 
mov edi,[CounterY]
 
;if size of picture natural(mastab is 1) than move picture to work screen
cmp [k],1
jne no_zoom_1_
screen_y_1:
mov esi,[CounterX]
screen_x_1:
mov ecx,[eax]
and ecx,0xffffff
mov ebp,ecx
shr ecx,16
mov [ebx],bp
mov [ebx+2],cl
add ebx,3;
add eax,3
dec esi
jnz screen_x_1
add eax,[OffsetYPicture]
add ebx,[OffsetYWorkScreen]
dec edi
jnz screen_y_1
jmp fps
no_zoom_1_:
 
cmp [k],2
jne no_zoom_2
 
screen_y_2:
mov esi,[CounterX]
screen_x_2:
mov ecx,[eax]
and ecx,0xffffff
mov ebp,ecx
shr ecx,16
mov edx,ebx
mov [edx],bp
mov [edx+2],cl
mov [edx+3],bp
mov [edx+3+2],cl
add edx,3*2
add edx,[OffsetYBigPixel]
mov [edx],bp
mov [edx+2],cl
mov [edx+3],bp
mov [edx+3+2],cl
add edx,3*2
add edx,[OffsetYBigPixel]
add ebx,3*2
add eax,3
dec esi
jnz screen_x_2
add eax,[OffsetYPicture]
add ebx,[OffsetYWorkScreen]
dec edi
jnz screen_y_2
jmp fps
no_zoom_2:
 
cmp [k],4
jne no_zoom_4
screen_y_4:
mov esi,[CounterX]
screen_x_4:
mov ecx,[eax]
and ecx,0xffffff
mov ebp,ecx
shr ecx,16
mov edx,ebx
mov [edx],bp
mov [edx+2],cl
mov [edx+3],bp
mov [edx+3+2],cl
mov [edx+6],bp
mov [edx+6+2],cl
mov [edx+9],bp
mov [edx+9+2],cl
add edx,3*4
add edx,[OffsetYBigPixel]
mov [edx],bp
mov [edx+2],cl
mov [edx+3],bp
mov [edx+3+2],cl
mov [edx+6],bp
mov [edx+6+2],cl
mov [edx+9],bp
mov [edx+9+2],cl
add edx,3*4
add edx,[OffsetYBigPixel]
mov [edx],bp
mov [edx+2],cl
mov [edx+3],bp
mov [edx+3+2],cl
mov [edx+6],bp
mov [edx+6+2],cl
mov [edx+9],bp
mov [edx+9+2],cl
add edx,3*4
add edx,[OffsetYBigPixel]
mov [edx],bp
mov [edx+2],cl
mov [edx+3],bp
mov [edx+3+2],cl
mov [edx+6],bp
mov [edx+6+2],cl
mov [edx+9],bp
mov [edx+9+2],cl
add edx,3*4
add edx,[OffsetYBigPixel]
add ebx,4*3
add eax,3
dec esi
jnz screen_x_4
add eax,[OffsetYPicture]
add ebx,[OffsetYWorkScreen]
dec edi
jnz screen_y_4
jmp fps
no_zoom_4:
;if zoom more than 4
screen_y:
mov esi,[CounterX]
screen_x:
mov ecx,[eax]
and ecx,0xffffff
mov ebp,ecx
shr ecx,16
push ebx
push eax
mov edx,[k]
big_pixel_y:
mov eax,[k]
big_pixel_x:
mov [ebx],bp
mov [ebx+2],cl
add ebx,3
dec eax
jnz big_pixel_x
add ebx,[OffsetYBigPixel]
dec edx
jnz big_pixel_y
pop eax
pop ebx
mov edx,[k]
lea edx,[edx+edx*2]
add ebx,edx
add eax,3
dec esi
jnz screen_x
add eax,[OffsetYPicture]
add ebx,[OffsetYWorkScreen]
dec edi
jnz screen_y
 
fps:
mov eax,18
mov ebx,14
int 0x40
 
mov eax,7
mov ebx,[ScreenPointer]
mov ecx,[WorkScreen_SizeX]
mov edx,[WorkScreen_SizeY]
shl ecx,16
add ecx,edx
mov edx,8*65536+20+15+45+5
int 0x40
 
ret
;----------------------------------------------------------
;--------------------clear screen--------------------------
;----------------------------------------------------------
cleare_screen:
 
mov eax,[ScreenPointer]
mov ebx,[WorkScreen_SizeX]
imul ebx,[WorkScreen_SizeY]
lea ebx,[ebx+ebx*2]
shr ebx,3
inc ebx
mov esi,0xffffff
 
clear_screen_loop:
 
mov [eax],esi
mov [eax+3],esi
mov [eax+6],si
add eax,4+4
 
dec ebx
jnz clear_screen_loop
ret
;----------------------------------------------------------
;-------------cleare work arrea(work screen)---------------
;----------------------------------------------------------
cleare_work_arrea:
 
mov eax,[PointerToPicture]
mov ebx,[Picture_SizeX]
imul ebx,[Picture_SizeY]
lea ebx,[ebx+ebx*2]
shr ebx,3
inc ebx
mov esi,0xffffff
 
clear_work_arrea_loop:
 
mov [eax],esi
mov [eax+3],esi
mov [eax+6],si
add eax,4+4
 
dec ebx
jnz clear_work_arrea_loop
ret
;----------------------------------------------------------
;------------draw lines of scoll---------------------------
;----------------------------------------------------------
draw_scrollers:
 
mov edi,[CounterX]
mov eax,[Scroll1CoordinatX]
mov ebx,[Window_SizeY]
sub ebx,22+10
mov ecx,[Window_SizeX]
sub ecx,10+5+20+10+1
mov edx,14+10
mov esi,1
mov [Scroll1CoordinatX],eax
mov [Scroll1CoordinatY],ebx
mov [Scroll1MaxSizeY],edx
mov [Scroll1MaxSizeX],ecx
imul ecx,edi
push eax
push ebx
push edx
mov eax,ecx
mov ebx,[Picture_SizeX]
cdq
idiv ebx
mov ecx,eax
pop edx
pop ebx
pop eax
mov [Scroll1SizeX],ecx
mov edi,[Scroll1MaxSizeX]
sub edi,ecx
mov [Scroll1FreeX],edi
call draw_volume_rectangle
 
mov eax,[Window_SizeX]
sub eax,22+10
mov ebx,[Scroll2CoordinatY]
mov ecx,14+10
mov edx,[Window_SizeY]
sub edx,20+15+1+46+10+20+11
mov esi,1
mov [Scroll2CoordinatX],eax
mov [Scroll2CoordinatY],ebx
mov [Scroll2MaxSizeX],ecx
mov [Scroll2MaxSizeY],edx
 
imul edx,[CounterY]
push eax
push ebx
mov eax,edx
mov ebx,[Picture_SizeY]
cdq
idiv ebx
mov edx,eax
pop ebx
pop eax
mov [Scroll2SizeY],edx
mov edi,[Scroll2MaxSizeY]
sub edi,edx
mov [Scroll2FreeY],edi
 
call draw_volume_rectangle
 
ret
;----------------------------------------------------------
;--------change size of memory which use program-----------
;----------------------------------------------------------
GetMemory:
pushad
mov eax,64
mov ebx,1
mov ecx,[Picture_SizeX]
mov edx,[Picture_SizeY]
imul ecx,edx
lea ecx,[ecx+ecx*2]
lea ecx,[ecx+ecx*4] ;(Picture_SizeX*Picture_SizeY*3)*5
add ecx,[ScreenPointer]
add ecx,(1200*1000)*3+30*(20*20*3)+500000+16000+0x4000
add ecx,[extended_memory]
int 0x40
 
test eax,eax
jz have_new_memory
 
mov esi,sound_havent_memory
call sound
 
jmp still
 
have_new_memory:
popad
ret
;-----------------------------------------------------------
;-----------instruments of menu-----------------------------
;-----------------------------------------------------------
TakeInstruments:
 
;|||||||||||||||||||FILE||||||||||||||||||||||
cmp [number_panel],7
jne no_file
 
;<<<<<NEW>>>>>>>
cmp [number_menu],1
jne no_new
 
mov eax,80
mov ebx,100
mov ecx,150
mov edx,90
mov esi,1
call draw_volume_rectangle
 
mov eax,177
mov ebx,115
mov ecx,40
mov edx,14
mov esi,4
call draw_volume_rectangle
 
mov eax,177
mov ebx,115+24
mov ecx,40
mov edx,14
mov esi,4
call draw_volume_rectangle
 
mov eax,175
mov ebx,170
mov ecx,40
mov edx,15
mov esi,1
call draw_volume_rectangle
 
mov eax,90
mov ebx,118
mov ecx,0xffffff
mov edx,new_text1
mov esi,14
call print_text
 
mov eax,90
mov ebx,118+24
mov ecx,0xffffff
mov edx,new_text2
mov esi,14
call print_text
 
mov eax,185
mov ebx,175
mov ecx,0xffffff
mov edx,ok_text
mov esi,2
call print_text
 
mov eax,8
mov ebx,177*65536+40
mov ecx,115*65536+14
mov edx,1000000000000000000000000000000b
add edx,1000
int 0x40
 
mov eax,8
mov ebx,177*65536+40
mov ecx,139*65536+14
mov edx,1000000000000000000000000000000b
add edx,1001
int 0x40
 
mov eax,8
mov ebx,175*65536+40
mov ecx,170*65536+15
mov edx,1000000000000000000000000000000b
add edx,1002
int 0x40
 
no_activate_space:
 
mov eax,10
int 0x40
 
cmp eax,1
je exit_new
 
cmp eax,3
jne no_activate_space
 
mov eax,17
int 0x40
shr eax,8
 
cmp eax,1000
jl no_activate_space
 
cmp eax,1000
jne no_picture_size_x
 
mov eax,180
mov ebx,119
mov ecx,5
call dialog_line
 
mov eax,string_
mov ebx,13
call find_symvol
 
dec eax
mov [length_number],eax
mov eax,string_
call value
 
mov [Picture_SizeX],eax
 
jmp no_activate_space
 
no_picture_size_x:
 
cmp eax,1001
jne no_picture_size_y
 
mov eax,180
mov ebx,119+24
mov ecx,5
call dialog_line
 
mov eax,string_
mov ebx,13
call find_symvol
 
dec eax
mov [length_number],eax
mov eax,string_
call value
 
mov [Picture_SizeY],eax
 
jmp no_activate_space
 
no_picture_size_y:
 
cmp eax,1002
jne no_activate_space
 
exit_new:
 
mov eax,8
mov ebx,175*65536+40
mov ecx,170*65536+15
mov edx,11100000000000000000000000000000b
add edx,1002
int 0x40
 
mov eax,8
mov ebx,177*65536+40
mov ecx,139*65536+14
mov edx,11100000000000000000000000000000b
add edx,1001
int 0x40
 
mov eax,8
mov ebx,177*65536+40
mov ecx,115*65536+14
mov edx,11100000000000000000000000000000b
add edx,1000
int 0x40
 
;get memory for new picture
mov eax,[Picture_SizeX]
mov ebx,[Picture_SizeY]
 
imul eax,ebx
lea eax,[eax+eax*2]
 
mov ebx,[ScreenPointer]
add ebx,(1200*1000*3)+30*(20*20*3)+500000
 
mov [PointerToPicture],ebx
mov [PointerToCopyPicture],ebx
mov [PointerToCopyPicture2],ebx
mov [PointerToEditBufer],ebx
mov [PointerToSpriteBufer],ebx
 
add [PointerToCopyPicture],eax
 
add [PointerToCopyPicture2],eax
add [PointerToCopyPicture2],eax
 
add [PointerToEditBufer],eax
add [PointerToEditBufer],eax
add [PointerToEditBufer],eax
 
add [PointerToSpriteBufer],eax
add [PointerToSpriteBufer],eax
add [PointerToSpriteBufer],eax
add [PointerToSpriteBufer],eax
 
call GetMemory
 
and [save_flag],0
and [number_panel],0
and [number_menu],0
 
call cleare_work_arrea
call drawwin
 
jmp still
no_new:
 
;<<<<<OPEN>>>>>>>
cmp [number_menu],2
jne no_open
 
opendialog drawwin,open_1,open_2,file_path
open_1:
 
mov eax,40
mov ebx,100111b
int 0x40
 
mov eax,[ScreenPointer]
add eax,0x10000
mov [file_info],dword 0
mov [file_info+8],dword 1
mov [file_info+12],eax
mov eax,58
mov ebx,file_info
int 0x40
 
mov esi,[ScreenPointer]
add esi,0x10000
;-------------is this BMP file ?----------------
xor eax,eax
mov ax,[esi]
mov [type],ax
 
cmp [type],word 'BM'
jne no_bmp_file
 
xor eax,eax
xor ebx,ebx
mov eax,[esi+18]
mov ebx,[esi+22]
mov [Picture_SizeX],eax
mov [Picture_SizeY],ebx
 
jmp exit_type
 
no_bmp_file:
 
;-------------is this GIF file ?----------------
xor eax,eax
mov ax,[esi]
mov [type],ax
 
cmp [type],'GI'
jne no_gif_file
 
add esi,6
xor eax,eax
xor ebx,ebx
mov ax,word[esi]
mov bx,word[esi+2]
mov [Picture_SizeX],eax
mov [Picture_SizeY],ebx
 
jmp exit_type
 
no_gif_file:
 
jmp no_unpakcing_gif_file
 
exit_type:
;----------------------------------------------------------
;Get momory for unpacking picture and for picture's bufers
;----------------------------------------------------------
mov eax,[Picture_SizeX]
mov ebx,[Picture_SizeY]
 
imul eax,ebx
lea eax,[eax+eax*2]
 
mov ebx,[ScreenPointer]
add ebx,(1200*1000*3)+30*(20*20*3)+500000
 
mov [PointerToPicture],ebx
mov [PointerToCopyPicture],ebx
mov [PointerToCopyPicture2],ebx
mov [PointerToEditBufer],ebx
mov [PointerToSpriteBufer],ebx
 
add [PointerToCopyPicture],eax
 
add [PointerToCopyPicture2],eax
add [PointerToCopyPicture2],eax
 
add [PointerToEditBufer],eax
add [PointerToEditBufer],eax
add [PointerToEditBufer],eax
 
add [PointerToSpriteBufer],eax
add [PointerToSpriteBufer],eax
add [PointerToSpriteBufer],eax
add [PointerToSpriteBufer],eax
 
call GetMemory
;----------------------------------------------------------
;--------------------Load file in memory-------------------
;----------------------------------------------------------
 
mov eax,[PointerToCopyPicture]
mov ebx,[ScreenPointer]
add eax,1000
mov [file_info],dword 0
mov [file_info+8],dword 1
mov [file_info+12],dword eax
mov [file_info+16],dword ebx
 
call load_file
 
;----------------------------------------------------------
;-------------------Unpacking picture----------------------
;----------------------------------------------------------
mov esi,[PointerToCopyPicture]
add esi,1000
mov edi,[PointerToPicture]
mov eax,[ScreenPointer]
 
cmp [type],'BM'
jne no_unpakcing_bmp_file
;BMP DECODER
call bmptoimg
 
no_unpakcing_bmp_file:
 
 
cmp [type],'GI'
jne no_unpakcing_gif_file
;GIF DECODER
sub edi,12
call ReadGIF
 
no_unpakcing_gif_file:
 
mov [Scroll1CoordinatX],9
mov [Scroll2CoordinatY],85
call load_icons
call drawwin
and [number_panel],0
and [number_menu],0
mov [save_flag],1
 
open_2:
 
jmp still
 
no_open:
 
;<<<<<<<<<<<SAVE>>>>>>>>>>>>
cmp [number_menu],3
jne no_save_
 
mov al,[save_flag]
 
test al,al
jz no_save_file
 
jmp save_enter
 
no_save_file:
 
and [number_panel],0
and [number_menu],0
 
jmp still
 
no_save_:
 
;<<<<<<<<<SAVE AS>>>>>>>>>>>
cmp [number_menu],4
jne no_save
 
savedialog drawwin,save1,save2,file_path
 
save1:
 
save_enter:
mov eax,40
mov ebx,100111b
int 0x40
 
call analizing_picture_to_palette
;eax => number of colors in picture
mov ebx,[PointerToPicture]
mov ecx,[PointerToEditBufer]
mov edx,[PointerToPalette]
mov esi,[Picture_SizeX]
mov edi,[Picture_SizeY]
 
call coding_bmp
mov edi,[PointerToEditBufer]
mov [file_info],dword 1
mov [file_info+8],dword ebx
mov [file_info+12],edi
 
mov eax,58
mov ebx,file_info
int 0x40
 
mov [save_flag],1
and [number_panel],0
and [number_menu],0
call drawwin
 
jmp still
 
save2:
 
and [number_panel],0
and [number_menu],0
 
jmp still
no_save:
 
;<<<<<<EXIT>>>>>>>
cmp [number_menu],5
jne no_exit_program
 
mov eax,-1
int 0x40
 
no_exit_program:
 
no_file:
 
;|||||||||||||||||||||||||||||EDIT|||||||||||||||||||||||||
 
;<<<<<<<<<<UNDO>>>>>>>>>>
cmp [number_panel],6
jne no_edit
 
cmp [number_menu],1
jne no_undo
 
cmp [number_undo],1
jne no_one____
 
mov esi,[PointerToCopyPicture]
 
no_one____:
 
cmp [number_undo],2
jne no_two____
 
mov esi,[PointerToCopyPicture2]
 
no_two____:
 
mov edi,[PointerToPicture]
mov ecx,[Picture_SizeX]
imul ecx,[Picture_SizeY]
lea ecx,[ecx+ecx*2]
add ecx,4
shr ecx,2
cld
rep movsd
call MovePictureToWorkScreen
 
dec [number_undo]
jnz no_null_undo
 
mov [number_undo],1
 
no_null_undo:
 
and [number_panel],0
and [number_menu],0
jmp still
no_undo:
 
;<<<<<<<<<<COPY>>>>>>>>>>
 
cmp [number_menu],2
jne no_copy
 
cmp [instrument_used],1
jne no_copy
cmp [Activate_instrument],0
jne no_copy
 
mov eax,[OldX]
mov ebx,[OldY]
 
cmp eax,[rectangular_shade_x]
jl no_remove_x_copy
 
mov ecx,[rectangular_shade_x]
mov [OldX],ecx ; OldX <-----> rectangulare_shade_x
mov [rectangular_shade_x],eax
 
no_remove_x_copy:
 
cmp ebx,[rectangular_shade_y]
jl no_remove_y_copy
 
mov ecx,[rectangular_shade_y]
mov [OldY],ecx ; OldY <-----> rectangulare_shade_y
mov [rectangular_shade_y],ebx
 
no_remove_y_copy:
 
mov eax,[OldX]
mov ebx,[OldY]
mov ecx,[rectangular_shade_x]
mov edx,[rectangular_shade_y]
inc eax
inc ebx
dec ecx
dec edx
 
mov [x],eax
mov [y],ebx
mov esi,eax
mov edi,ebx
mov [Dx_],1
mov [Dy_],1
 
sub ecx,eax
jnz no_signum_fill_r_x_copy
 
mov [Dx_],-1
 
no_signum_fill_r_x_copy:
 
sub edx,ebx
jnz no_signum_fill_r_y_copy
 
mov [Dy_],-1
 
no_signum_fill_r_y_copy:
 
mov ebx,[rectangular_shade_y]
sub ebx,edi
 
mov edx,[PointerToEditBufer]
mov [y],edi
loop_fill_rectangle_y_copy:
 
mov [x],esi
loop_fill_rectangle_x_copy:
 
push esi
push edi
 
mov eax,[PointerToPicture]
mov ebx,[Picture_SizeX]
mov esi,[x]
mov edi,[y]
call GetColorOfPixel
 
mov [edx],ax
shr eax,16
mov [edx+2],al
 
pop edi
pop esi
 
add edx,3
 
mov eax,[x]
add eax,[Dx_]
mov [x],eax
 
cmp eax,[rectangular_shade_x]
jl loop_fill_rectangle_x_copy
 
mov eax,[y]
add eax,[Dy_]
mov [y],eax
 
cmp eax,[rectangular_shade_y]
jl loop_fill_rectangle_y_copy
 
call MovePictureToWorkScreen
 
and [number_panel],0
and [number_menu],0
mov [DrawSprite_flag],1
 
jmp still
 
no_copy:
 
;<<<<<<<<<<PASTE>>>>>>>>
cmp [number_menu],3
jne no_paste
 
cmp [instrument_used],1
jne no_paste
 
cmp [Activate_instrument],0
jne no_paste
 
mov eax,[OldX]
mov ebx,[OldY]
 
cmp eax,[rectangular_shade_x]
jl no_remove_x_paste
 
mov ecx,[rectangular_shade_x]
mov [OldX],ecx ; OldX <-----> rectangulare_shade_x
mov [rectangular_shade_x],eax
 
no_remove_x_paste:
 
cmp ebx,[rectangular_shade_y]
jl no_remove_y_paste
 
mov ecx,[rectangular_shade_y]
mov [OldY],ecx ; OldY <-----> rectangulare_shade_y
mov [rectangular_shade_y],ebx
 
no_remove_y_paste:
 
mov eax,[OldX]
mov ebx,[OldY]
mov ecx,[rectangular_shade_x]
mov edx,[rectangular_shade_y]
inc eax
inc ebx
dec ecx
dec edx
 
mov [x],eax
mov [y],ebx
mov esi,eax
mov edi,ebx
mov [Dx_],1
mov [Dy_],1
 
sub ecx,eax
jnz no_signum_fill_r_x_paste
 
mov [Dx_],-1
 
no_signum_fill_r_x_paste:
 
sub edx,ebx
jnz no_signum_fill_r_y_paste
 
mov [Dy_],-1
 
no_signum_fill_r_y_paste:
 
mov edx,[PointerToEditBufer]
mov [y],edi
 
loop_fill_rectangle_y_paste:
 
mov [x],esi
loop_fill_rectangle_x_paste:
 
push esi
push edi
 
mov ecx,[edx]
and ecx,0xffffff ;color
 
mov eax,[PointerToPicture]
mov ebx,[Picture_SizeX]
mov esi,[x]
mov edi,[y]
call PutPixel
 
pop edi
pop esi
 
add edx,3
 
mov eax,[x]
add eax,[Dx_]
mov [x],eax
cmp eax,[rectangular_shade_x]
jl loop_fill_rectangle_x_paste
 
mov eax,[y]
add eax,[Dy_]
mov [y],eax
cmp eax,[rectangular_shade_y]
 
jl loop_fill_rectangle_y_paste
 
call MovePictureToWorkScreen
and [number_panel],0
and [number_menu],0
mov [Paste_flag],1
 
jmp still
 
no_paste:
 
;<<<<<<<<<<CUT>>>>>>>>>>
cmp [number_menu],4
jne no_cut
 
cmp [instrument_used],1
jne no_cut
 
cmp [Activate_instrument],0
jne no_cut
 
mov eax,[OldX]
mov ebx,[OldY]
 
cmp eax,[rectangular_shade_x]
jl no_remove_x_cut
 
mov ecx,[rectangular_shade_x]
mov [OldX],ecx ; OldX <-----> rectangulare_shade_x
mov [rectangular_shade_x],eax
 
no_remove_x_cut:
 
cmp ebx,[rectangular_shade_y]
jl no_remove_y_cut
 
mov ecx,[rectangular_shade_y]
mov [OldY],ecx ; OldY <-----> rectangulare_shade_y
mov [rectangular_shade_y],ebx
 
no_remove_y_cut:
 
mov eax,[OldX]
mov ebx,[OldY]
mov ecx,[rectangular_shade_x]
mov edx,[rectangular_shade_y]
inc eax
inc ebx
dec ecx
dec edx
 
mov [x],eax
mov [y],ebx
mov esi,eax
mov edi,ebx
mov [Dx_],1
mov [Dy_],1
 
sub ecx,eax
jnz no_signum_fill_r_x
 
mov [Dx_],-1
 
no_signum_fill_r_x:
 
sub edx,ebx
jnz no_signum_fill_r_y
 
mov [Dy_],-1
 
no_signum_fill_r_y:
 
mov [y],edi
loop_fill_rectangle_y:
 
mov [x],esi
loop_fill_rectangle_x:
 
push esi
push edi
 
mov eax,[PointerToPicture]
mov ebx,[Picture_SizeX]
mov ecx,dword 0xffffff
mov esi,[x]
mov edi,[y]
call PutPixel
 
pop edi
pop esi
 
mov eax,[x]
add eax,[Dx_]
mov [x],eax
 
cmp eax,[rectangular_shade_x]
jl loop_fill_rectangle_x
 
mov eax,[y]
add eax,[Dy_]
mov [y],eax
 
cmp eax,[rectangular_shade_y]
jl loop_fill_rectangle_y
 
call MovePictureToWorkScreen
 
and [number_panel],0
and [number_menu],0
 
jmp still
no_cut:
 
;<<<<<<CLEARE ALL>>>>>>
cmp [number_menu],5
jne no_cleare_all
 
call cleare_work_arrea
 
call MovePictureToWorkScreen
 
and [number_panel],0
and [number_menu],0
 
jmp still
no_cleare_all:
;<<<<<<TO ALLOCATE ALL>>>>>>
 
cmp [number_menu],6
jne no_to_allocate_all
 
mov [OldX],1
mov [OldY],1
mov eax,[Picture_SizeX]
mov ebx,[Picture_SizeY]
dec eax
dec ebx
mov [rectangular_shade_x],eax
mov [rectangular_shade_y],ebx
mov [instrument_used],1
mov [Activate_instrument],1
mov [Current_instrument],30
mov [crossing],0
and [number_panel],0
and [number_menu],0
;call TakeButtonInstruments
;call MovePictureToWorkScreen
jmp still
 
no_to_allocate_all:
 
no_edit:
 
 
jmp still
 
ret
;-----------------------------------------------------------
;-----instruments of panel(icon's instruments)--------------
;-----------------------------------------------------------
TakeButtonInstruments:
 
mov eax,[Current_instrument]
 
;*************************brush 1***********************
cmp eax,10
jne no_brush1
 
mov [Brush_SizeX],4
mov [Brush_SizeY],4
mov [Number_Brush],0
mov [Current_instrument],18
 
jmp still
no_brush1:
 
;*************************brush 2***********************
cmp eax,11
jne no_brush2
 
mov [Brush_SizeX],6
mov [Brush_SizeY],4
mov [Number_Brush],1
mov [Current_instrument],18
 
jmp still
no_brush2:
 
;*************************brush 3***********************
cmp eax,12
jne no_brush3
 
mov [Brush_SizeX],8
mov [Brush_SizeY],7
mov [Number_Brush],2
mov [Current_instrument],18
 
jmp still
no_brush3:
 
;************************brush 4************************
cmp eax,13
jne no_brush4
 
mov [Brush_SizeX],14
mov [Brush_SizeY],14
mov [Number_Brush],3
mov [Current_instrument],18
 
jmp still
no_brush4:
 
;************************brush 5************************
cmp eax,14
jne no_brush5
 
mov [Brush_SizeX],6
mov [Brush_SizeY],6
mov [Number_Brush],4
mov [Current_instrument],18
 
jmp still
no_brush5:
 
;*************************pensil************************
cmp eax,15
jne no_pensil
 
mov al,[exit_from_work_arrea]
 
test al,al
jz no_exit_from_work_arrea
 
and [Activate_instrument],0
and [exit_from_work_arrea],0
 
no_exit_from_work_arrea:
 
mov al,[Activate_instrument]
 
test al,al
jnz no_activated_later
 
call GetScreenCordinats
mov eax,[ScreenX]
mov ebx,[ScreenY]
add eax,[PosX]
add ebx,[PosY]
mov [OldX],eax
mov [OldY],ebx
 
no_activated_later:
 
mov eax,[MaxWorkScreen_SizeX]
mov ebx,[MaxWorkScreen_SizeY]
 
mov eax,[PointerToPicture]
mov ebx,[ReserveArray]
mov ecx,[Picture_SizeX]
mov edx,[OldX]
shl edx,16
add edx,[OldY]
mov esi,[ScreenX]
mov edi,[ScreenY]
add esi,[PosX]
add edi,[PosY]
call calculate_line
 
mov ecx,eax
mov edx,[Color]
mov esi,[Color]
shr edx,16
xor ebx,ebx
mov eax,[ReserveArray]
 
pensil_next_pixel_draw:
 
mov ebx,[eax]
mov [ebx],si
mov [ebx+2],dl
add eax,4
 
dec ecx
jnz pensil_next_pixel_draw
 
mov eax,[ScreenX]
mov ebx,[ScreenY]
add eax,[PosX]
add ebx,[PosY]
mov [OldX],eax
mov [OldY],ebx
 
call MovePictureToWorkScreen
mov [Activate_instrument],1
jmp still
no_pensil:
 
;**********************pipetka**************************
cmp eax,16
jne no_pipetka
mov eax,[ScreenY]
mov ebx,[Picture_SizeX]
add eax,[PosY]
imul eax,ebx
add eax,[ScreenX]
add eax,[PosX]
lea eax,[eax+eax*2]
add eax,[PointerToPicture]
mov ebx,[eax]
and ebx,0xffffff
mov [Color],ebx
mov eax,13
mov ebx,447*65536+35
mov ecx,42*65536+36
mov edx,[Color]
int 0x40
jmp still
no_pipetka:
 
;**********************draw brush***********************
cmp eax,18
jne no_brush
 
jmp no_lastik_
 
lastik_in:
mov eax,[Color]
mov [SColor],eax
mov [Color],0xffffff
no_lastik_:
 
mov eax,[ScreenX]
mov ebx,[ScreenY]
mov ecx,[Brush_SizeX]
mov edx,[Brush_SizeY]
add eax,[PosX]
add ebx,[PosY]
add eax,ecx
add ebx,edx
 
cmp eax,[Picture_SizeX]
jl no_max_pos_x
mov eax,[Picture_SizeX]
no_max_pos_x:
 
cmp ebx,[Picture_SizeY]
jl no_max_pos_y
mov ebx,[Picture_SizeY]
no_max_pos_y:
 
cmp eax,ecx
ja no_min_pos_x
mov eax,[Brush_SizeX]
no_min_pos_x:
 
cmp ebx,edx
ja no_min_pos_y
mov ebx,[Brush_SizeY]
no_min_pos_y:
 
sub eax,[Brush_SizeX]
sub ebx,[Brush_SizeY]
 
mov [x],eax
mov [y],ebx
 
mov al,[exit_from_work_arrea]
test al,al
jz no_exit_from_work_arrea_brush
and [Activate_instrument],0
and [exit_from_work_arrea],0
no_exit_from_work_arrea_brush:
 
mov al,[Activate_instrument]
test al,al
jnz no_new_brush_xy
mov eax,[x]
mov ebx,[y]
mov [OldX],eax
mov [OldY],ebx
mov [Activate_instrument],1
no_new_brush_xy:
 
mov eax,[PointerToPicture]
mov ebx,[ReserveArray]
add ebx,4
mov ecx,[Picture_SizeX]
mov edx,[OldX]
shl edx,16
add edx,[OldY]
mov esi,[x]
mov edi,[y]
 
call calculate_line
 
mov ebx,[ReserveArray]
mov [ebx],eax
 
;procedure drawing of brush
mov ebx,[ReserveArray]
mov ecx,[ebx]
mov edx,[Color]
mov esi,[Color]
shr edx,16
add ebx,4
mov edi,[Number_Brush]
imul edi,20*20
 
next_pixel_put_brush:
 
mov eax,[ebx]
push eax
push ecx
xor ebp,ebp
and [counter2],0
 
vertical_width_brush:
and [counter],0
 
horizontal_width_brush:
xor ecx,ecx
mov cl,byte[Brush_color+edi+ebp]
test cl,cl
jz no_draw_pixel_brush
mov [eax],si
mov [eax+2],dl
no_draw_pixel_brush:
add eax,3
inc ebp
inc [counter]
cmp [counter],20
jne horizontal_width_brush
 
mov ecx,[Picture_SizeX]
sub ecx,20
lea ecx,[ecx+ecx*2]
add eax,ecx
inc [counter2]
cmp [counter2],20
jne vertical_width_brush
 
pop ecx
pop eax
add ebx,4
dec ecx
jnz next_pixel_put_brush
 
mov eax,[x]
mov ebx,[y]
mov [OldX],eax
mov [OldY],ebx
 
mov al,[lastik_is_active]
test al,al
jz no_lastik_active
 
mov eax,[SColor]
mov [Color],eax
and [lastik_is_active],0
no_lastik_active:
 
call MovePictureToWorkScreen
jmp still
no_brush:
 
;************************Flood Fill*******************
cmp eax,17
jne no_FloodFill
 
mov eax,[PointerToPicture]
mov ebx,[PointerToEditBufer]
 
mov ecx,[Picture_SizeX]
imul ecx,[Picture_SizeY]
lea ecx,[ecx+ecx*2]
shl ecx,1
 
cmp ecx,500000
ja normal_size_of_bufer
 
mov ebx,[ReserveArray]
 
normal_size_of_bufer:
 
add ebx,4
mov ecx,[Picture_SizeX]
mov edx,[ScreenX]
add edx,[PosX]
shl edx,16
add edx,[ScreenY]
add edx,[PosY]
mov esi,[Picture_SizeX]
dec esi
shl esi,16
add esi,[Picture_SizeY]
dec esi
mov edi,[Color]
 
call flood_fill
call MovePictureToWorkScreen
 
jmp still
no_FloodFill:
 
;************************lastik*************************
cmp eax,19
jne no_lastik
 
mov [lastik_is_active],1
jmp lastik_in
 
no_lastik:
 
;******************************************************
cmp eax,20
jne no_spray
 
cmp [Activate_instrument],0
jne no_null_spray
mov [Activate_instrument],1
jmp still
no_null_spray:
 
mov eax,[ScreenX]
mov ebx,[ScreenY]
mov ecx,[Brush_SizeX]
mov edx,[Brush_SizeY]
add eax,[PosX]
add ebx,[PosY]
add eax,ecx
add ebx,edx
 
cmp eax,[Picture_SizeX]
jl no_max_pos_x_spray
mov eax,[Picture_SizeX]
no_max_pos_x_spray:
 
cmp ebx,[Picture_SizeY]
jl no_max_pos_y_spray
mov ebx,[Picture_SizeY]
no_max_pos_y_spray:
 
cmp eax,ecx
ja no_min_pos_x_spray
mov eax,[Brush_SizeX]
no_min_pos_x_spray:
 
cmp ebx,edx
ja no_min_pos_y_spray
mov ebx,[Brush_SizeY]
no_min_pos_y_spray:
 
sub eax,[Brush_SizeX]
sub ebx,[Brush_SizeY]
mov edi,0;[Number_Brush]
imul edi,20*20
 
mov [x],eax
mov [y],ebx
mov ebp,[Picture_SizeX]
xor edx,edx
brush_y_spray:
xor ecx,ecx
brush_x_spray:
;calculate position in array of spray
mov esi,edx
lea esi,[esi+esi*4] ;esi=esi*5
shl esi,2 ;esi=(esi*3)*4
add esi,ecx
add esi,edi
;read byte from array
xor eax,eax
mov al,[Spray_color+esi]
test eax,eax
jz no_color_spray
mov eax,[x]
mov ebx,[y]
add eax,ecx
add ebx,edx
imul ebx,ebp; ebp=[Picture_SizeX]
add eax,ebx
lea eax,[eax+eax*2]
add eax,[PointerToPicture]
mov ebx,[Color]
mov [eax],bx
shr ebx,16
mov [eax+2],bl
no_color_spray:
inc ecx
cmp ecx,20
jl brush_x_spray
inc edx
cmp edx,20
jl brush_y_spray
 
call MovePictureToWorkScreen
jmp still
 
no_spray:
 
;***********************palette*************************
cmp eax,21
jne no_palette
 
mov eax,20
mov ebx,100
mov ecx,32*10+32*5+7
mov edx,8*10+7*10
mov esi,1
call draw_volume_rectangle
mov [x],20+5
mov [y],100+10
mov edi,256
xor esi,esi
next_rectangle:
mov eax,13
mov ebx,[x]
mov ecx,[y]
mov edx,[palitra+esi]
and edx,0xffffff
shl ebx,16
shl ecx,16
add ebx,13
add ecx,13
int 0x40
add [x],15
cmp [x],20+15*32
jl no_new_line
mov [x],20+5
add [y],15
no_new_line:
add esi,4
dec edi
jnz next_rectangle
 
wait_events:
call event
 
cmp eax,1
je still
cmp eax,2
jne no_keys
mov eax,2
int 0x40
no_keys:
cmp eax,3
jne no_buttons
mov eax,17
int 0x40
no_buttons:
cmp eax,6
jne wait_events
 
call GetMouseClick
 
test eax,eax
jz wait_events
call GetMouseCoordinats
mov [x],20+5
mov [y],100+10
mov [counter],0
next_rectangle_column:
mov eax,[x]
mov ebx,[y]
mov ecx,[MouseX]
mov edx,[MouseY]
mov esi,13
mov edi,13
call columnus
test eax,eax
jz no_columnus_color
mov eax,[counter]
shl eax,2
mov ebx,[palitra+eax]
and ebx,0xffffff
mov [Color],ebx
no_columnus_color:
add [x],15
cmp [x],20+15*32
jl no_new_line_column
mov [x],20+5
add [y],15
no_new_line_column:
inc [counter]
cmp [counter],257
jne next_rectangle_column
mov eax,5
mov ebx,10
int 0x40
call drawwin
and [Current_instrument],0
jmp still
no_palette:
 
;************************draw line**********************
cmp eax,22
jne no_line
 
mov al,[Activate_instrument]
test al,al
jnz no_new_line_xy
mov eax,[ScreenX]
mov ebx,[ScreenY]
add eax,[PosX]
add ebx,[PosY]
mov [OldX],eax
mov [OldY],ebx
mov [Activate_instrument],1
mov eax,[ReserveArray]
mov ecx,60000
clear_array_line:
mov [eax],dword 0
add eax,4
dec ecx
jnz clear_array_line
jmp still
no_new_line_xy:
 
;put saved pixels
mov ebx,[ReserveArray]
mov eax,[ebx]
test eax,eax
jz no_put_line_to_screen_line
mov ecx,[ebx]
add ebx,4
xor ebp,ebp
next_color_put_line:
;put saved pixels in ReserveArray
push ecx
and [counter2],0
mov edi,[ebx]
push edi
vertical_width_put:
and [counter],0
 
horizontal_width_put:
mov edx,[ebx+4807*4+ebp]
and edx,0xffffff
mov [edi],dx
shr edx,16
mov [edi+2],dl
 
add edi,3
add ebp,4
inc [counter]
cmp [counter],5
jne horizontal_width_put
 
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add edi,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_put
pop edi
pop ecx
add ebx,4
dec ecx
jnz next_color_put_line
 
no_put_line_to_screen_line:
 
;calculate line
mov ebx,[ReserveArray]
add ebx,4
mov eax,[PointerToPicture]
mov ecx,[Picture_SizeX]
mov edx,[OldX]
shl edx,16
add edx,[OldY]
mov esi,[ScreenX]
mov edi,[ScreenY]
add esi,[PosX]
add edi,[PosY]
 
mov ebp,[Picture_SizeX]
sub ebp,[line_width]
cmp esi,ebp
jl no_minimum_x_line
mov esi,ebp
no_minimum_x_line:
 
mov ebp,[Picture_SizeY]
sub ebp,[line_width]
cmp edi,ebp
jl no_minimum_y_line
mov edi,ebp
no_minimum_y_line:
 
call calculate_line
;call calculate_rectangle
mov [counter],eax
 
;save color pixels in ReserveArray
mov eax,[counter]
mov ebx,[ReserveArray]
mov [ebx],eax
 
mov ecx,[ebx]
add ebx,4
 
xor ebp,ebp
next_color_save_line:
;save color of pixel in ReserveArray
push ecx
and [counter2],0
mov edi,[ebx]
vertical_width_save:
and [counter],0
 
horizontal_width_save:
mov eax,edi
mov edx,[eax]
and edx,0xffffff
mov [ebx+4807*4+ebp],dx
shr edx,16
mov [ebx+4807*4+2+ebp],dl
 
add edi,3
add ebp,4
inc [counter]
cmp [counter],5
jne horizontal_width_save
 
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add edi,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_save
pop ecx
add ebx,4
dec ecx
jnz next_color_save_line
 
;draw calculated pixels on work arrea
mov ebx,[ReserveArray]
mov ecx,[ebx]
mov edx,[Color]
mov esi,[Color]
shr edx,16
add ebx,4
mov edi,[line_width]
dec edi
imul edi,25
next_pixel_put_line:
 
mov eax,[ebx]
push eax
push ecx
xor ebp,ebp
and [counter2],0
 
vertical_width:
and [counter],0
 
horizontal_width:
xor ecx,ecx
mov cl,byte[width_pixels+edi+ebp]
test cl,cl
jz no_draw_pixel_line
mov [eax],si
mov [eax+2],dl
no_draw_pixel_line:
add eax,3
inc ebp
inc [counter]
cmp [counter],5
jne horizontal_width
 
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add eax,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width
 
pop ecx
pop eax
add ebx,4
dec ecx
jnz next_pixel_put_line
 
call MovePictureToWorkScreen
 
jmp still
no_line:
 
;*********************************DRAW RECTANGLE****************************
cmp eax,23
jne no_rectangle
 
mov al,[Activate_instrument]
test al,al
jnz no_new_rectangle_xy
mov eax,[ScreenX]
mov ebx,[ScreenY]
add eax,[PosX]
add ebx,[PosY]
mov [OldX],eax
mov [OldY],ebx
mov [Activate_instrument],1
mov eax,[ReserveArray]
mov ecx,60000
clear_array_rectangle:
mov [eax],dword 0
add eax,4
dec ecx
jnz clear_array_rectangle
jmp still
no_new_rectangle_xy:
 
;put saved pixels
mov ebx,[ReserveArray]
mov eax,[ebx]
test eax,eax
jz no_put_rectangle_to_screen_line
mov ecx,[ebx]
add ebx,4
xor ebp,ebp
next_color_put_rectangle:
;put saved pixels in ReserveArray
push ecx
and [counter2],0
mov edi,[ebx]
push edi
vertical_width_put_rectangle:
and [counter],0
 
horizontal_width_put_rectangle:
mov edx,[ebx+4807*4+ebp]
and edx,0xffffff
mov [edi],dx
shr edx,16
mov [edi+2],dl
 
add edi,3
add ebp,4
inc [counter]
cmp [counter],5
jne horizontal_width_put_rectangle
 
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add edi,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_put_rectangle
pop edi
pop ecx
add ebx,4
dec ecx
jnz next_color_put_rectangle
 
no_put_rectangle_to_screen_line:
 
;calculate line
mov ebx,[ReserveArray]
add ebx,4
mov eax,[PointerToPicture]
mov ecx,[Picture_SizeX]
mov edx,[OldX]
shl edx,16
add edx,[OldY]
mov esi,[ScreenX]
mov edi,[ScreenY]
add esi,[PosX]
add edi,[PosY]
 
mov ebp,[Picture_SizeX]
sub ebp,[line_width]
cmp esi,ebp
jl no_minimum_x_rectangle
mov esi,ebp
no_minimum_x_rectangle:
 
mov ebp,[Picture_SizeY]
sub ebp,[line_width]
cmp edi,ebp
jl no_minimum_y_rectangle
mov edi,ebp
no_minimum_y_rectangle:
 
call calculate_rectangle
mov [counter],eax
 
;save color pixels in ReserveArray
mov eax,[counter]
mov ebx,[ReserveArray]
mov [ebx],eax
 
mov ecx,[ebx]
add ebx,4
 
xor ebp,ebp
next_color_save_rectangle:
;save color of pixel in ReserveArray
push ecx
and [counter2],0
mov edi,[ebx]
vertical_width_save_rectangle:
and [counter],0
 
horizontal_width_save_rectangle:
mov eax,edi
mov edx,[eax]
and edx,0xffffff
mov [ebx+4807*4+ebp],dx
shr edx,16
mov [ebx+4807*4+2+ebp],dl
 
add edi,3
add ebp,4
inc [counter]
cmp [counter],5
jne horizontal_width_save_rectangle
 
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add edi,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_save_rectangle
pop ecx
add ebx,4
dec ecx
jnz next_color_save_rectangle
 
;draw calculated pixels on work arrea
mov ebx,[ReserveArray]
mov ecx,[ebx]
mov edx,[Color]
mov esi,[Color]
shr edx,16
add ebx,4
mov edi,[line_width]
dec edi
imul edi,25
next_pixel_put_rectangle:
 
mov eax,[ebx]
push eax
push ecx
xor ebp,ebp
and [counter2],0
 
vertical_width_rectangle:
and [counter],0
 
horizontal_width_rectangle:
xor ecx,ecx
mov cl,byte[width_pixels_rectangle+edi+ebp]
test cl,cl
jz no_draw_pixel_rectangle
mov [eax],si
mov [eax+2],dl
no_draw_pixel_rectangle:
add eax,3
inc ebp
inc [counter]
cmp [counter],5
jne horizontal_width_rectangle
 
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add eax,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_rectangle
 
pop ecx
pop eax
add ebx,4
dec ecx
jnz next_pixel_put_rectangle
 
call MovePictureToWorkScreen
jmp still
no_rectangle:
 
;*********************************DRAW CIRCLE****************************
cmp eax,24
jne no_circle
 
mov al,[Activate_instrument]
test al,al
jnz no_new_circle_xy
mov eax,[ScreenX]
mov ebx,[ScreenY]
add eax,[PosX]
add ebx,[PosY]
mov [OldX],eax
mov [OldY],ebx
mov [Activate_instrument],1
mov eax,[ReserveArray]
mov ecx,60000
clear_array_circle:
mov [eax],dword 0
add eax,4
dec ecx
jnz clear_array_circle
jmp still
no_new_circle_xy:
 
;put saved pixels
mov ebx,[ReserveArray]
mov eax,[ebx]
test eax,eax
jz no_put_line_to_screen_circle
mov ecx,[ebx]
add ebx,4
xor ebp,ebp
next_color_put_circle:
;put saved pixels in ReserveArray
push ecx
and [counter2],0
mov edi,[ebx]
push edi
vertical_width_put_circle:
and [counter],0
 
horizontal_width_put_circle:
mov edx,[ebx+4807*4+ebp]
and edx,0xffffff
mov [edi],dx
shr edx,16
mov [edi+2],dl
 
add edi,3
add ebp,4
inc [counter]
cmp [counter],5
jne horizontal_width_put_circle
 
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add edi,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_put_circle
pop edi
pop ecx
add ebx,4
dec ecx
jnz next_color_put_circle
 
no_put_line_to_screen_circle:
 
mov esi,[ScreenX]
mov edi,[ScreenY]
add esi,[PosX]
add edi,[PosY]
 
sub esi,[OldX]
jns no_sign_x_circle
neg esi
shr esi,1
neg esi
add esi,[OldX]
jmp no_plus_sign_x_circle
no_sign_x_circle:
 
shr esi,1
add esi,[OldX]
no_plus_sign_x_circle:
 
sub edi,[OldY]
jns no_sign_y_circle
neg edi
shr edi,1
neg edi
add edi,[OldY]
jmp no_plus_sign_y_circle
no_sign_y_circle:
 
shr edi,1
add edi,[OldY]
no_plus_sign_y_circle:
 
mov [x],esi
mov [y],edi
 
mov esi,[ScreenX]
mov edi,[ScreenY]
add esi,[PosX]
add edi,[PosY]
 
sub esi,[OldX]
jns no_sign_x_circle_r
neg esi
no_sign_x_circle_r:
 
sub edi,[OldY]
jns no_sign_y_circle_r
neg edi
no_sign_y_circle_r:
 
mov [Dx_],esi
mov [Dy_],edi
 
;finit
fild [Dx_]
fmul st0,st0
fild [Dy_]
fmul st0,st0
fadd st0,st1
fsqrt
fistp [Radius]
fistp [Icon_X]
mov esi,[Radius]
shr esi,1
cmp esi,0
jne no_null_radius
mov [Radius],1
no_null_radius:
 
mov [Radius],esi
 
mov edi,[x]
mov ebp,[y]
add edi,esi
add ebp,esi
 
mov edx,[Picture_SizeX]
sub edx,[line_width]
cmp edi,edx
jl no_limit_x_circle
sub edi,edx
sub [Radius],edi
no_limit_x_circle:
 
mov edx,[Picture_SizeY]
sub edx,[line_width]
cmp ebp,edx
jl no_limit_y_circle
sub ebp,edx
sub [Radius],ebp
no_limit_y_circle:
 
 
mov edi,[x]
mov ebp,[y]
 
sub edi,[Radius]
jns no_minimum_x_circle
add [Radius],edi
no_minimum_x_circle:
 
sub ebp,[Radius]
jns no_minimum_y_circle
add [Radius],ebp
no_minimum_y_circle:
 
;calculate circle
mov ebx,[ReserveArray]
add ebx,4
mov eax,[PointerToPicture]
mov ecx,[Picture_SizeX]
mov edx,[x]
shl edx,16
add edx,[y]
mov esi,[Radius]
call calculate_circle
 
mov [counter],eax
 
;save color pixels in ReserveArray
mov eax,[counter]
mov ebx,[ReserveArray]
mov [ebx],eax
 
mov ecx,[ebx]
add ebx,4
 
xor ebp,ebp
next_color_save_circle:
;save color of pixel in ReserveArray
push ecx
and [counter2],0
mov edi,[ebx]
vertical_width_save_circle:
and [counter],0
 
horizontal_width_save_circle:
mov eax,edi
mov edx,[eax]
and edx,0xffffff
mov [ebx+4807*4+ebp],dx
shr edx,16
mov [ebx+4807*4+2+ebp],dl
 
add edi,3
add ebp,4
inc [counter]
cmp [counter],5
jne horizontal_width_save_circle
 
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add edi,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_save_circle
pop ecx
add ebx,4
dec ecx
jnz next_color_save_circle
 
;draw calculated pixels on work arrea
mov ebx,[ReserveArray]
mov ecx,[ebx]
mov edx,[Color]
mov esi,[Color]
shr edx,16
add ebx,4
mov edi,[line_width]
dec edi
imul edi,25
next_pixel_put_circle:
 
mov eax,[ebx]
push eax
push ecx
xor ebp,ebp
and [counter2],0
 
vertical_width_circle:
and [counter],0
 
horizontal_width_circle:
xor ecx,ecx
mov cl,byte[width_pixels+edi+ebp]
test cl,cl
jz no_draw_pixel_circle
mov [eax],si
mov [eax+2],dl
no_draw_pixel_circle:
add eax,3
inc ebp
inc [counter]
cmp [counter],5
jne horizontal_width_circle
 
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add eax,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_circle
 
pop ecx
pop eax
add ebx,4
dec ecx
jnz next_pixel_put_circle
 
call MovePictureToWorkScreen
jmp still
no_circle:
 
;************************zoom 1*************************
cmp eax,25
jne no_1_
mov [k],1
mov [Scroll1CoordinatX],9
mov [Scroll2CoordinatY],85
and [Current_instrument],0
call drawwin
jmp still
no_1_:
 
;*************************zoom 2************************
cmp eax,26
jne no_2_
mov [k],2
call drawwin
mov [Scroll1CoordinatX],9
mov [Scroll2CoordinatY],85
and [Current_instrument],0
jmp still
no_2_:
 
;*************************zoom 4************************
cmp eax,27
jne no_4_
mov [k],4
call drawwin
mov [Scroll1CoordinatX],9
mov [Scroll2CoordinatY],85
and [Current_instrument],0
jmp still
no_4_:
 
;************************zoom 8*************************
cmp eax,28
jne no_8_
mov [k],8
call drawwin
mov [Scroll1CoordinatX],9
mov [Scroll2CoordinatY],85
and [Current_instrument],0
jmp still
no_8_:
 
;************************zoom 16************************
cmp eax,29
jne no_16_
mov [k],16
call drawwin
mov [Scroll1CoordinatX],9
mov [Scroll2CoordinatY],85
and [Current_instrument],0
jmp still
no_16_:
 
;***************allocation of a countour*********************
cmp eax,30
jne no_allocation
 
cmp [instrument_used],0
jnz instrument_not_finished_work
 
mov al,[Activate_instrument]
test al,al
jnz no_new_allocation_xy
mov eax,[ScreenX]
mov ebx,[ScreenY]
add eax,[PosX]
add ebx,[PosY]
mov [OldX],eax
mov [OldY],ebx
inc eax
inc ebx
mov [rectangular_shade_x],eax
mov [rectangular_shade_y],ebx
mov [Activate_instrument],1
mov [instrument_used],1
and [crossing],0
and [finishing_crossing],0
mov eax,[ReserveArray]
mov ecx,60000
clear_array_allocation:
mov [eax],dword 0
add eax,4
dec ecx
jnz clear_array_allocation
jmp still
no_new_allocation_xy:
instrument_not_finished_work:
 
mov al,[instrument_used]
test al,al
jz no_change_coordinats
 
cmp [Activate_instrument],0
jnz no_change_coordinats
 
;save coordinates as old if crossing=0
cmp [crossing],0
jnz no_save_coordinate_of_crossing
 
mov eax,[OldX]
mov ebx,[OldY]
 
cmp eax,[rectangular_shade_x]
jl no_remove_x
mov ecx,[rectangular_shade_x]
mov [OldX],ecx ; OldX <-----> rectangulare_shade_x
mov [rectangular_shade_x],eax
no_remove_x:
 
cmp ebx,[rectangular_shade_y]
jl no_remove_y
mov ecx,[rectangular_shade_y]
mov [OldY],ecx ; OldY <-----> rectangulare_shade_y
mov [rectangular_shade_y],ebx
no_remove_y:
 
mov eax,[ScreenX]
mov ebx,[ScreenY]
add eax,[PosX]
add ebx,[PosY]
mov [crossing_old_x],eax
mov [crossing_old_y],ebx
mov [crossing],1
 
 
mov eax,[OldX]
mov ebx,[OldY]
inc eax
inc ebx
mov [SpriteCoordinatX],eax
mov [SpriteCoordinatY],ebx
mov [SpriteOldCoordinatX],eax
mov [SpriteOldCoordinatY],ebx
mov esi,[rectangular_shade_x]
mov edi,[rectangular_shade_y]
 
sub esi,eax
jns no_sign_sprite_size_x
neg esi
no_sign_sprite_size_x:
 
sub edi,ebx
jns no_sign_sprite_size_y
neg edi
no_sign_sprite_size_y:
 
test esi,esi
jnz no_null_sprite_x
mov esi,1
no_null_sprite_x:
 
test edi,edi
jnz no_null_sprite_y
mov edi,1
no_null_sprite_y:
 
mov [SpriteSizeX],esi
mov [SpriteSizeY],edi
 
call SaveFonForSprite
 
no_save_coordinate_of_crossing:
 
cmp [crossing],0
je no_test_crossing_with_work_arrea
;if mouse situatad after allocation than exit
push [ScreenX]
push [ScreenY]
 
call GetScreenCordinats
 
mov eax,[OldX]
mov ebx,[OldY]
mov ecx,[ScreenX]
mov edx,[ScreenY]
mov esi,[SpriteSizeX]
mov edi,[SpriteSizeY]
add ecx,[PosX]
add edx,[PosY]
inc esi;eax
inc edi;ebx
call columnus
 
test eax,eax
jnz crossing_with_work_area
mov [finishing_crossing],1
mov [register],1
crossing_with_work_area:
 
pop [ScreenY]
pop [ScreenX]
 
no_test_crossing_with_work_arrea:
 
mov eax,[ScreenX]
mov ebx,[ScreenY]
add eax,[PosX]
add ebx,[PosY]
mov ecx,eax
mov edx,ebx
sub eax,[crossing_old_x] ;dx=(x-oldx)
sub ebx,[crossing_old_y] ;dy=(y-oldy)
mov [crossing_old_x],ecx
mov [crossing_old_y],edx
 
add [OldX],eax ;x1=x1+dx
add [OldY],ebx ;y1=y1+dy
add [rectangular_shade_x],eax ;x2=x2+dx
add [rectangular_shade_y],ebx ;y2+y2+dy
 
mov eax,[OldX]
mov ebx,[OldY]
inc eax
inc ebx
mov [SpriteCoordinatX],eax
mov [SpriteCoordinatY],ebx
 
cmp [SpriteCoordinatX],0
jns no_null_sprite_coordinat_x
mov [SpriteCoordinatX],1
no_null_sprite_coordinat_x:
 
cmp [SpriteCoordinatY],0
jns no_null_sprite_coordinat_y
mov [SpriteCoordinatY],1
no_null_sprite_coordinat_y:
 
mov esi,[rectangular_shade_x]
mov edi,[rectangular_shade_y]
 
sub esi,[OldX]
jns no_znak_size_of_rectangulare_crossing_x
neg esi
no_znak_size_of_rectangulare_crossing_x:
 
sub edi,[OldY]
jns no_znak_size_of_rectangulare_crossing_y
neg edi
no_znak_size_of_rectangulare_crossing_y:
 
mov ecx,[OldX]
mov edx,[OldY]
 
sub ecx,[PosX]
jns no_minimum_x_crossing
mov ecx,0
add ecx,[PosX]
mov [OldX],ecx
add ecx,esi
mov [rectangular_shade_x],ecx
no_minimum_x_crossing:
 
sub edx,[PosY]
jns no_minimum_y_crossing
mov edx,0
add edx,[PosY]
mov [OldY],edx
add edx,edi
mov [rectangular_shade_y],edx
no_minimum_y_crossing:
 
mov ecx,[Picture_SizeX]
sub ecx,esi
cmp [OldX],ecx
jl no_maximum_x_crossing
dec ecx
mov [OldX],ecx
add ecx,esi
mov [rectangular_shade_x],ecx
no_maximum_x_crossing:
 
mov edx,[Picture_SizeY]
sub edx,edi
cmp [OldY],edx
jl no_maximum_y_crossing
dec edx
mov [OldY],edx
add edx,edi
mov [rectangular_shade_y],edx
no_maximum_y_crossing:
 
mov eax,[rectangular_shade_x]
mov ebx,[rectangular_shade_y]
sub eax,[PosX]
sub ebx,[PosY]
mov [ScreenX],eax
mov [ScreenY],ebx
no_change_coordinats:
 
;put saved pixels
mov ebx,[ReserveArray]
mov eax,[ebx]
test eax,eax
jz no_put_line_to_screen_allocation
mov ecx,[ebx]
add ebx,4
xor ebp,ebp
next_color_put_allocation:
;put saved pixels in ReserveArray
push ecx
and [counter2],0
mov edi,[ebx]
push edi
vertical_width_put_allocation:
and [counter],0
 
horizontal_width_put_allocation:
mov edx,[ebx+4807*4+ebp]
and edx,0xffffff
mov [edi],dx
shr edx,16
mov [edi+2],dl
 
add edi,3
add ebp,4
inc [counter]
cmp [counter],1;5
jne horizontal_width_put_allocation
 
mov ecx,[Picture_SizeX]
sub ecx,1;5
lea ecx,[ecx+ecx*2]
add edi,ecx
inc [counter2]
cmp [counter2],1;5
jne vertical_width_put_allocation
pop edi
pop ecx
add ebx,4
dec ecx
jnz next_color_put_allocation
 
no_put_line_to_screen_allocation:
 
cmp [DrawSprite_flag],1
jne no_activate_put_fon_
 
cmp [Paste_flag],1
je no_put_fon___
call PutFonForSprite
no_put_fon___:
and [Paste_flag],0
no_activate_put_fon_:
 
cmp [finishing_crossing],0
jz not_finish_from_instrument_crossing
and [Activate_instrument],0
and [crossing],0
and [instrument_used],0
and [DrawSprite_flag],0
call MovePictureToWorkScreen
jmp still
not_finish_from_instrument_crossing:
 
;calculate line
mov ebx,[ReserveArray]
add ebx,4
mov eax,[PointerToPicture]
mov ecx,[Picture_SizeX]
mov edx,[OldX]
shl edx,16
add edx,[OldY]
mov esi,[ScreenX]
mov edi,[ScreenY]
add esi,[PosX]
add edi,[PosY]
 
mov ebp,[Picture_SizeX]
dec ebp
cmp esi,ebp
jl no_minimum_x_allocation
mov esi,ebp
no_minimum_x_allocation:
 
mov ebp,[Picture_SizeY]
dec ebp
cmp edi,ebp
jl no_minimum_y_allocation
mov edi,ebp
no_minimum_y_allocation:
 
call calculate_rectangle
mov [counter],eax
 
;save color pixels in ReserveArray
mov eax,[counter]
mov ebx,[ReserveArray]
mov [ebx],eax
 
mov ecx,[ebx]
add ebx,4
 
xor ebp,ebp
next_color_save_allocation:
;save color of pixel in ReserveArray
push ecx
and [counter2],0
mov edi,[ebx]
vertical_width_save_allocation:
and [counter],0
 
horizontal_width_save_allocation:
mov eax,edi
mov edx,[eax]
and edx,0xffffff
mov [ebx+4807*4+ebp],dx
shr edx,16
mov [ebx+4807*4+2+ebp],dl
 
add edi,3
add ebp,4
inc [counter]
cmp [counter],1;5
jne horizontal_width_save_allocation
 
mov ecx,[Picture_SizeX]
sub ecx,1;5
lea ecx,[ecx+ecx*2]
add edi,ecx
inc [counter2]
cmp [counter2],1;5
jne vertical_width_save_allocation
pop ecx
add ebx,4
dec ecx
jnz next_color_save_allocation
 
cmp [DrawSprite_flag],1
jne no_save_fon_for_sprite_
;save current coordinats as old
mov eax,[SpriteCoordinatX]
mov ebx,[SpriteCoordinatY]
mov [SpriteOldCoordinatX],eax
mov [SpriteOldCoordinatY],ebx
 
call SaveFonForSprite
 
no_save_fon_for_sprite_:
 
;draw calculated pixels on work arrea
mov ebx,[ReserveArray]
mov ecx,[ebx]
add ebx,4
next_pixel_put_allocation:
 
mov edx,0x1f3fff
mov esi,edx
shr edx,16
 
mov ebp,ecx
and ebp,8
cmp ebp,8
jne black_color
mov si,0xffff
mov dl,0xff
black_color:
 
mov eax,[ebx]
mov [eax],si
mov [eax+2],dl
 
add ebx,4
dec ecx
jnz next_pixel_put_allocation
 
cmp [DrawSprite_flag],1
jne no_activate_draw_sprite_
 
call DrawSprite
 
no_activate_draw_sprite_:
 
mov al,[instrument_used]
test al,al
jz no_change_coordinats
cmp [Activate_instrument],0
jz no_save_shades
mov eax,[ScreenX]
mov ebx,[ScreenY]
add eax,[PosX]
add ebx,[PosY]
mov [rectangular_shade_x],eax
mov [rectangular_shade_y],ebx
no_save_shades:
 
call MovePictureToWorkScreen
jmp still
no_allocation:
 
;*************reflection from left to right******************
cmp eax,35
jne no_reflection_from_left_to_right
 
mov ebp,[PointerToPicture]
mov edx,[ReserveArray]
mov esi,[Picture_SizeX]
mov ebx,[Picture_SizeX]
lea ebx,[ebx+ebx*2]
shr esi,1
next_line_reflection_x:
;copy vertical line to array
mov ecx,[Picture_SizeX]
shr ecx,1
sub ecx,esi
lea ecx,[ecx+ecx*2]
add ecx,[PointerToPicture]
mov edx,[ReserveArray]
and edi,0
copy_to_array_line_reflection_y:
xor eax,eax
mov eax,[ecx]
mov ebp,edi
lea ebp,[ebp+ebp*2]
mov [edx+ebp],ax
shr eax,16
mov [edx+ebp+2],al
add ecx,ebx
inc edi
cmp edi,[Picture_SizeY]
jne copy_to_array_line_reflection_y
 
mov ecx,[Picture_SizeX]
shr ecx,1
mov ebp,ecx
add ecx,esi
dec ecx
lea ecx,[ecx+ecx*2]
add ecx,[PointerToPicture]
sub ebp,esi
lea ebp,[ebp+ebp*2]
add ebp,[PointerToPicture]
and edi,0
next_line_reflection_y:
mov eax,[ecx]
and eax,0xffffff
mov [ebp],ax
shr eax,16
mov [ebp+2],al
add ebp,ebx
add ecx,ebx
inc edi
cmp edi,[Picture_SizeY]
jnz next_line_reflection_y
 
;copy vertical line from array to screen
mov ecx,[Picture_SizeX]
shr ecx,1
add ecx,esi
dec ecx
lea ecx,[ecx+ecx*2]
add ecx,[PointerToPicture]
mov edx,[ReserveArray]
and edi,0
copy_from_array_to_screen_reflection_y:
mov ebp,edi
lea ebp,[ebp+ebp*2]
xor eax,eax
mov eax,[edx+ebp]
mov [ecx],ax
shr eax,16
mov [ecx+2],al
add ecx,ebx
inc edi
cmp edi,[Picture_SizeY]
jne copy_from_array_to_screen_reflection_y
 
dec esi
jnz next_line_reflection_x
 
call MovePictureToWorkScreen
jmp still
no_reflection_from_left_to_right:
 
;*************reflection from up to down******************
cmp eax,36
jne no_reflection_from_up_to_down
mov esi,[Picture_SizeX]
mov edi,esi
lea esi,[esi+esi*2]
lea edi,[edi+edi*2]
imul edi,[Picture_SizeY]
mov edx,[ReserveArray]
mov ecx,[Picture_SizeY]
shr ecx,1
add edi,[PointerToPicture]
sub edi,esi
mov ebp,[PointerToPicture]
next_lines_reflection:
;copy line
xor ebx,ebx
copy_line_1:
xor eax,eax
mov al,[edi+ebx]
mov [edx+ebx],al
inc ebx
cmp ebx,esi
jne copy_line_1
 
xor ebx,ebx
copy_line_2:
xor eax,eax
mov al,[ebp+ebx]
mov [edi+ebx],al
inc ebx
cmp ebx,esi
jne copy_line_2
 
xor ebx,ebx
copy_line_3:
xor eax,eax
mov al,[edx+ebx]
mov [ebp+ebx],al
inc ebx
cmp ebx,esi
jne copy_line_3
 
add ebp,esi
sub edi,esi
dec ecx
jnz next_lines_reflection
 
call MovePictureToWorkScreen
jmp still
no_reflection_from_up_to_down:
 
;*********************draw hard contour*******************
cmp eax,38
jne no_kontur_
 
mov al,[Activate_instrument]
test al,al
jnz no_new_konture_xy
 
mov al,[instrument_used]
test al,al
jz instrument_not_used
mov eax,[used_OldX]
mov ebx,[used_OldY]
mov [OldX],eax
mov [OldY],ebx
jmp exit_used_instrument
instrument_not_used:
 
mov eax,[ScreenX]
mov ebx,[ScreenY]
add eax,[PosX]
add ebx,[PosY]
mov [OldX],eax
mov [OldY],ebx
exit_used_instrument:
 
mov al,[instrument_used]
test al,al
jnz instrument_used_true
mov [instrument_used],byte 1
instrument_used_true:
 
mov [Activate_instrument],1
mov eax,[ReserveArray]
mov ecx,60000
clear_array_konture:
mov [eax],dword 0
add eax,4
dec ecx
jnz clear_array_line
 
no_new_konture_xy:
 
;put saved pixels
mov ebx,[ReserveArray]
mov eax,[ebx]
test eax,eax
jz no_put_line_to_screen_konture
mov ecx,[ebx]
add ebx,4
xor ebp,ebp
next_color_put_konture:
;put saved pixels in ReserveArray
push ecx
and [counter2],0
mov edi,[ebx]
push edi
vertical_width_put_konture:
and [counter],0
 
horizontal_width_put_konture:
mov edx,[ebx+4807*4+ebp]
and edx,0xffffff
mov [edi],dx
shr edx,16
mov [edi+2],dl
 
add edi,3
add ebp,4
inc [counter]
cmp [counter],5
jne horizontal_width_put_konture
 
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add edi,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_put_konture
pop edi
pop ecx
add ebx,4
dec ecx
jnz next_color_put_konture
 
no_put_line_to_screen_konture:
 
;calculate line
mov ebx,[ReserveArray]
add ebx,4
mov eax,[PointerToPicture]
mov ecx,[Picture_SizeX]
mov edx,[OldX]
shl edx,16
add edx,[OldY]
mov esi,[ScreenX]
mov edi,[ScreenY]
add esi,[PosX]
add edi,[PosY]
 
mov ebp,[Picture_SizeX]
sub ebp,[line_width]
cmp esi,ebp
jl no_minimum_x_konture
mov esi,ebp
no_minimum_x_konture:
 
mov ebp,[Picture_SizeY]
sub ebp,[line_width]
cmp edi,ebp
jl no_minimum_y_konture
mov edi,ebp
no_minimum_y_konture:
 
call calculate_line
;call calculate_rectangle
mov [counter],eax
 
;save color pixels in ReserveArray
mov eax,[counter]
mov ebx,[ReserveArray]
mov [ebx],eax
 
mov ecx,[ebx]
add ebx,4
 
xor ebp,ebp
next_color_save_konture:
;save color of pixel in ReserveArray
push ecx
and [counter2],0
mov edi,[ebx]
vertical_width_save_konture:
and [counter],0
 
horizontal_width_save_konture:
mov eax,edi
mov edx,[eax]
and edx,0xffffff
mov [ebx+4807*4+ebp],dx
shr edx,16
mov [ebx+4807*4+2+ebp],dl
 
add edi,3
add ebp,4
inc [counter]
cmp [counter],5
jne horizontal_width_save_konture
 
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add edi,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_save_konture
pop ecx
add ebx,4
dec ecx
jnz next_color_save_konture
 
;draw calculated pixels on work arrea
mov ebx,[ReserveArray]
mov ecx,[ebx]
mov edx,[Color]
mov esi,[Color]
shr edx,16
add ebx,4
mov edi,[line_width]
dec edi
imul edi,25
next_pixel_put_konture:
 
mov eax,[ebx]
push eax
push ecx
xor ebp,ebp
and [counter2],0
 
vertical_width_konture:
and [counter],0
 
horizontal_width_konture:
xor ecx,ecx
mov cl,byte[width_pixels+edi+ebp]
test cl,cl
jz no_draw_pixel_konture
mov [eax],si
mov [eax+2],dl
no_draw_pixel_konture:
add eax,3
inc ebp
inc [counter]
cmp [counter],5
jne horizontal_width_konture
 
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add eax,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_konture
 
pop ecx
pop eax
add ebx,4
dec ecx
jnz next_pixel_put_konture
 
mov eax,[ScreenX]
mov ebx,[ScreenY]
add eax,[PosX]
add ebx,[PosY]
mov [used_OldX],eax
mov [used_OldY],ebx
 
call MovePictureToWorkScreen
 
jmp still
 
no_kontur_:
;************************Draw ellips***********************
cmp eax,39
jne no_ellips
 
mov al,[Activate_instrument]
test al,al
jnz no_new_ellips_xy
mov eax,[ScreenX]
mov ebx,[ScreenY]
add eax,[PosX]
add ebx,[PosY]
mov [OldX],eax
mov [OldY],ebx
mov [Activate_instrument],1
mov eax,[ReserveArray]
mov ecx,60000
clear_array_ellips:
mov [eax],dword 0
add eax,4
dec ecx
jnz clear_array_ellips
jmp still
no_new_ellips_xy:
 
;put saved pixels
mov ebx,[ReserveArray]
mov eax,[ebx]
test eax,eax
jz no_put_line_to_screen_ellips
mov ecx,[ebx]
add ebx,4
xor ebp,ebp
next_color_put_ellips:
;put saved pixels in ReserveArray
push ecx
and [counter2],0
mov edi,[ebx]
push edi
vertical_width_put_ellips:
and [counter],0
 
horizontal_width_put_ellips:
mov edx,[ebx+4807*4+ebp]
and edx,0xffffff
mov [edi],dx
shr edx,16
mov [edi+2],dl
 
add edi,3
add ebp,4
inc [counter]
cmp [counter],5
jne horizontal_width_put_ellips
 
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add edi,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_put_ellips
pop edi
pop ecx
add ebx,4
dec ecx
jnz next_color_put_ellips
 
no_put_line_to_screen_ellips:
 
mov esi,[ScreenX]
mov edi,[ScreenY]
add esi,[PosX]
add edi,[PosY]
 
sub esi,[OldX]
jns no_sign_x_ellips
neg esi
shr esi,1
neg esi
add esi,[OldX]
jmp no_plus_sign_x_ellips
no_sign_x_ellips:
 
shr esi,1
add esi,[OldX]
no_plus_sign_x_ellips:
 
sub edi,[OldY]
jns no_sign_y_ellips
neg edi
shr edi,1
neg edi
add edi,[OldY]
jmp no_plus_sign_y_ellips
no_sign_y_ellips:
 
shr edi,1
add edi,[OldY]
no_plus_sign_y_ellips:
 
mov [x],esi
mov [y],edi
 
mov esi,[ScreenX]
mov edi,[ScreenY]
add esi,[PosX]
add edi,[PosY]
 
sub esi,[OldX]
jns no_sign_x_ellips_r
neg esi
no_sign_x_ellips_r:
 
sub edi,[OldY]
jns no_sign_y_ellips_r
neg edi
no_sign_y_ellips_r:
 
cmp edi,0
jnz no_null_a_ellips
mov edi,1
no_null_a_ellips:
 
shr esi,1
shr edi,1
mov [a_ellips],esi
mov [b_ellips],edi
 
mov edi,[x]
mov ebp,[y]
add edi,esi
add ebp,esi
 
mov edx,[Picture_SizeX]
sub edx,[line_width]
cmp edi,edx
jl no_limit_x_ellips
sub edi,edx
sub [a_ellips],edi
no_limit_x_ellips:
 
mov edx,[Picture_SizeY]
sub edx,[line_width]
cmp ebp,edx
jl no_limit_y_ellips
sub ebp,edx
sub [b_ellips],ebp
no_limit_y_ellips:
 
 
mov edi,[x]
mov ebp,[y]
 
sub edi,[a_ellips]
jns no_minimum_x_ellips
add [a_ellips],edi
no_minimum_x_ellips:
 
sub ebp,[b_ellips]
jns no_minimum_y_ellips
add [b_ellips],ebp
no_minimum_y_ellips:
 
;calculate circle
mov ebx,[ReserveArray]
add ebx,4
mov eax,[PointerToPicture]
mov ecx,[Picture_SizeX]
mov edx,[x]
shl edx,16
add edx,[y]
mov esi,[a_ellips]
shl esi,16
add esi,[b_ellips]
call calculate_ellips
 
mov [counter],eax
 
;save color pixels in ReserveArray
mov eax,[counter]
mov ebx,[ReserveArray]
mov [ebx],eax
 
mov ecx,[ebx]
add ebx,4
 
xor ebp,ebp
next_color_save_ellips:
;save color of pixel in ReserveArray
push ecx
and [counter2],0
mov edi,[ebx]
vertical_width_save_ellips:
and [counter],0
 
horizontal_width_save_ellips:
mov eax,edi
mov edx,[eax]
and edx,0xffffff
mov [ebx+4807*4+ebp],dx
shr edx,16
mov [ebx+4807*4+2+ebp],dl
 
add edi,3
add ebp,4
inc [counter]
cmp [counter],5
jne horizontal_width_save_ellips
 
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add edi,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_save_ellips
pop ecx
add ebx,4
dec ecx
jnz next_color_save_ellips
 
;draw calculated pixels on work arrea
mov ebx,[ReserveArray]
mov ecx,[ebx]
mov edx,[Color]
mov esi,[Color]
shr edx,16
add ebx,4
mov edi,[line_width]
dec edi
imul edi,25
next_pixel_put_ellips:
 
mov eax,[ebx]
push eax
push ecx
xor ebp,ebp
and [counter2],0
 
vertical_width_ellips:
and [counter],0
 
horizontal_width_ellips:
xor ecx,ecx
mov cl,byte[width_pixels+edi+ebp]
test cl,cl
jz no_draw_pixel_ellips
mov [eax],si
mov [eax+2],dl
no_draw_pixel_ellips:
add eax,3
inc ebp
inc [counter]
cmp [counter],5
jne horizontal_width_ellips
 
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add eax,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_ellips
 
pop ecx
pop eax
add ebx,4
dec ecx
jnz next_pixel_put_ellips
 
call MovePictureToWorkScreen
jmp still
no_ellips:
 
;*************************Line width 1*********************
cmp eax,41
jne no_line_width_1
mov [line_width],1
jmp still
no_line_width_1:
;*************************Line width 2*********************
cmp eax,42
jne no_line_width_2
mov [line_width],2
jmp still
no_line_width_2:
;*************************Line width 3*********************
cmp eax,43
jne no_line_width_3
mov [line_width],3
jmp still
no_line_width_3:
;*************************Line width 4*********************
cmp eax,44
jne no_line_width_4
mov [line_width],4
jmp still
no_line_width_4:
;*************************Line width 5*********************
cmp eax,45
jne no_line_width_5
mov [line_width],5
jmp still
no_line_width_5:
 
jmp still
ret
;-----------------------------------------------------------
;-----------calculate cordinats on work picture--------------
;-----------------------------------------------------------
GetScreenCordinats:
 
mov eax,[MouseX]
mov ebx,[MouseY]
sub eax,9
sub ebx,83
 
mov ecx,[k]
cdq
idiv ecx
mov [ScreenX],eax
mov eax,ebx
cdq
idiv ecx
mov [ScreenY],eax
 
ret
;-----------------------------------------------------------
;------------------SaveFonForSprite-------------------------
;-----------------------------------------------------------
SaveFonForSprite:
 
mov edi,[PointerToSpriteBufer]
mov ecx,[SpriteSizeX]
mov edx,[Picture_SizeX]
sub edx,[SpriteSizeX]
mov esi,[SpriteCoordinatY]
imul esi,[Picture_SizeX]
add esi,[SpriteCoordinatX]
lea edx,[edx+edx*2]
lea esi,[esi+esi*2]
add esi,[PointerToPicture]
mov ebx,[SpriteSizeY]
mov [counter],ecx
 
next_line_sprite_save:
mov ecx,[counter]
 
next_pixel_sprite_save:
mov eax,[esi]
and eax,0xffffff
mov [edi],ax
shr eax,16
mov [edi+2],al
add esi,3
add edi,3
dec ecx
jnz next_pixel_sprite_save
 
add esi,edx
dec ebx
jnz next_line_sprite_save
 
ret
;-----------------------------------------------------------
;-------------------PutFonForSprite-------------------------
;-----------------------------------------------------------
PutFonForSprite:
 
mov esi,[PointerToSpriteBufer]
mov ecx,[SpriteSizeX]
mov edx,[Picture_SizeX]
sub edx,[SpriteSizeX]
mov edi,[SpriteOldCoordinatY]
imul edi,[Picture_SizeX]
add edi,[SpriteOldCoordinatX]
lea edx,[edx+edx*2]
lea edi,[edi+edi*2]
add edi,[PointerToPicture]
mov ebx,[SpriteSizeY]
mov [counter],ecx
 
next_line_sprite_put:
mov ecx,[counter]
 
next_pixel_sprite_put:
mov eax,[esi]
and eax,0xffffff
mov [edi],ax
shr eax,16
mov [edi+2],al
add esi,3
add edi,3
dec ecx
jnz next_pixel_sprite_put
 
add edi,edx
dec ebx
jnz next_line_sprite_put
 
ret
;-----------------------------------------------------------
;------------------DrawFonForSprite-------------------------
;-----------------------------------------------------------
DrawSprite:
 
mov esi,[PointerToEditBufer]
mov ecx,[SpriteSizeX]
mov edx,[Picture_SizeX]
sub edx,[SpriteSizeX]
mov edi,[SpriteCoordinatY]
imul edi,[Picture_SizeX]
add edi,[SpriteCoordinatX]
lea edx,[edx+edx*2]
lea edi,[edi+edi*2]
add edi,[PointerToPicture]
mov ebx,[SpriteSizeY]
mov [counter],ecx
 
next_line_sprite_draw:
mov ecx,[counter]
 
next_pixel_sprite_draw:
mov eax,[esi]
and eax,0xffffff
mov [edi],ax
shr eax,16
mov [edi+2],al
add esi,3
add edi,3
dec ecx
jnz next_pixel_sprite_draw
 
add edi,edx
dec ebx
jnz next_line_sprite_draw
 
ret
;-----------------------------------------------------------
;-------find simvole in string------------------------------
;-----------------------------------------------------------
find_symvol:
;eax,string
;ebx,symvol
mov esi,eax
next_symvol:
xor ecx,ecx
mov cl,[eax]
cmp cl,bl
je symvol_fined
inc eax
jmp next_symvol
 
symvol_fined:
sub eax,esi
ret
;-----------------------------------------------------------
;--------load file in memory--------------------------------
;-----------------------------------------------------------
load_file:
mov eax,58
mov ebx,file_info
int 0x40
test eax,eax
jnz no_open_
mov [length_file],ebx
shr ebx,9
inc ebx
mov [file_info+8],ebx
mov eax,58
mov ebx,file_info
int 0x40
no_open_:
ret
;-----------------------------------------------------------
;---load icons in memory and draw icons on panel-----------
;-----------------------------------------------------------
load_icons:
mov esi,panel_picture
mov edi,[ScreenPointer]
mov eax,edi
add edi,(1200*1000*3)
call ReadGIF
 
ret
 
draw_icons:
mov [Icon_X],10
mov [Icon_Y],20+15+4
and [counter],0
next_icon:
mov eax,8
mov ebx,[Icon_X]
mov ecx,[Icon_Y]
dec ebx
dec ecx
shl ebx,16
shl ecx,16
add ebx,20
add ecx,20
mov edx,[counter]
add edx,10
add edx,1000000000000000000000000000000b
int 0x40
 
 
mov edx,[Icon_X]
shl edx,16
add edx,[Icon_Y]
mov ebx,[counter]
imul ebx,20*20*3
add ebx,[ScreenPointer]
add ebx,(1200*1000*3)+12
mov eax,7
mov ecx,20*65536+20
int 0x40
 
add [Icon_X],25
cmp [Icon_X],10+25*15
jl no_next_line_icons
mov [Icon_X],10
mov [Icon_Y],20+15+4+22
no_next_line_icons:
inc [counter]
cmp [counter],30
jl next_icon
 
and [counter],0
mov [Icon_X],475
mov [Icon_Y],20+15+7
next_button_line:
 
mov eax,8
mov ebx,[Icon_X]
mov ecx,[Icon_Y]
dec ebx
dec ecx
shl ebx,16
shl ecx,16
add ebx,10
add ecx,35
mov edx,[counter]
add edx,40
add edx,1000000000000000000000000000000b
int 0x40
 
mov eax,13
mov ebx,[Icon_X]
mov ecx,[Icon_Y]
add ebx,4
shl ebx,16
shl ecx,16
add ebx,[counter]
add ecx,35
;xor edx,edx
mov edx,0xb1d8ff
int 0x40
 
add [Icon_X],15
inc [counter]
cmp [counter],5
jle next_button_line
ret
;-----------------------------------------------------------
;calculate position work screen on a picture
;-----------------------------------------------------------
CalculatePositionScreen:
 
mov eax,[Picture_SizeX]
mov ebx,[Picture_SizeY]
mov ecx,[CounterX]
mov edx,[CounterY]
sub eax,ecx
sub ebx,edx
 
cmp [PosX],eax
jle no_limit_screen_x
mov [PosX],eax
no_limit_screen_x:
 
cmp [PosY],ebx
jle no_limit_screen_y
mov [PosY],ebx
no_limit_screen_y:
 
cmp [PosX],0
jns no_minimum_screen_x
mov [PosX],0
no_minimum_screen_x:
 
cmp [PosY],0
jns no_minimum_screen_y
mov [PosY],0
no_minimum_screen_y:
 
ret
;-----------------------------------------------------------
;-------analizing picture to palette------------------------
;-----------------------------------------------------------
analizing_picture_to_palette:
 
mov eax,[Picture_SizeX]
mov ebx,[Picture_SizeY]
imul eax,ebx
mov ecx,eax
mov edx,[PointerToPicture]
mov esi,1 ;counter colors in palette
 
;put firs color of picture how one color in palette
mov ebp,[PointerToPalette]
mov eax,[edx]
and eax,0xffffff
mov [ebp],eax
 
analizing_to_palette:
mov eax,[edx]
and eax,0xffffff
 
mov edi,esi
mov ebp,[PointerToPalette]
next_color_in_palette:
mov ebx,[ebp]
and ebx,0xffffff
cmp ebx,eax ;this is color have in palette
je exit_loop_palette
add ebp,4
dec edi
jnz next_color_in_palette
 
inc esi
cmp esi,256 ;256 colors
ja more_than_256_colors
mov ebp,[PointerToPalette]
mov ebx,esi
dec ebx
shl ebx,2
add ebp,ebx
mov [ebp],ax
shr eax,16
mov [ebp+2],al
 
exit_loop_palette:
 
add edx,3
dec ecx
jnz analizing_to_palette
 
 
more_than_256_colors:
mov eax,esi
ret
;---------------------------------------------------------
;---------------SOUND of EVENTS---------------------------
;---------------------------------------------------------
sound:
mov eax,55
mov ebx,eax
int 0x40
ret
;----------------------------------------------------------
;-------------file info structure--------------------------
;----------------------------------------------------------
file_info:
dd 0
dd 0
dd 1
dd 0x19000+0x10000
dd 0x19000
 
file_path:
times 256 db 0
;-----------------------------------------------------------
;------------variables and data of program------------------
;-----------------------------------------------------------
length_file dd 0
 
time dd 0
sound_havent_memory db 150,64,0
PosX dd 0
PosY dd 0
ScreenPointer dd 0
PointerToPicture dd 0
PointerToCopyPicture dd 0
PointerToCopyPicture2 dd 0
PointerToEditBufer dd 0
PointerToSpriteBufer dd 0
PointerToPalette dd 0
Color dd 0
Number_Brush dd 0
Brush_SizeX dd 0
Brush_SizeY dd 0
Current_instrument dd 0
Activate_instrument db 0
SColor dd 0
OldX dd 0
OldY dd 0
 
MouseX dd 0
MouseY dd 0
Window_SizeX dd 0
Window_SizeY dd 0
Window_CordinatX dd 0
Window_CordinatY dd 0
Picture_SizeX dd 0
Picture_SizeY dd 0
ScreenX dd 0
ScreenY dd 0
WorkScreen_SizeX dd 0
WorkScreen_SizeY dd 0
MaxWorkScreen_SizeX dd 0
MaxWorkScreen_SizeY dd 0
k dd 0
IPC_table rd 256
ReserveArray dd 0
register dd 0
CounterX dd 0
CounterY dd 0
OffsetYPicture dd 0
OffsetYWorkScreen dd 0
OffsetYBigPixel dd 0
 
Icon_X dd 0
Icon_Y dd 0
counter dd 0
counter2 dd 0
Icon_text_x dd 0
Icon_text_y dd 0
Panel_flag db 0
counter_menu dd 0
menu_coordinat_x dd 0
menu_size_x dd 0
menu_counter dd 0
counter_11 dd 0
number_panel dd 0
number_menu dd 0
 
Scroll1CoordinatX dd 0
Scroll1CoordinatY dd 0
Scroll1MaxSizeX dd 0
Scroll1MaxSizeY dd 0
Scroll1SizeX dd 0
Scroll1FreeX dd 0
 
Scroll2CoordinatX dd 0
Scroll2CoordinatY dd 0
Scroll2MaxSizeX dd 0
Scroll2MaxSizeY dd 0
Scroll2SizeY dd 0
Scroll2FreeY dd 0
 
extended_memory dd 0
type dw 0
x dd 0
y dd 0
save_flag db 0
exit_from_work_arrea db 0
 
Radius dd 0
Dx_ dd 0
Dy_ dd 0
line_width dd 0
lastik_is_active db 0
a_ellips dd 0
b_ellips dd 0
instrument_used db 0
used_OldX dd 0
used_OldY dd 0
rectangular_shade_x dd 0
rectangular_shade_y dd 0
crossing_old_x dd 0
crossing_old_y dd 0
crossing dd 0
finishing_crossing dd 0
number_undo dd 0
DrawSprite_flag db 0
Paste_flag db 0
SpriteSizeX dd 0
SpriteSizeY dd 0
SpriteCoordinatX dd 0
SpriteCoordinatY dd 0
SpriteOldCoordinatX dd 0
SpriteOldCoordinatY dd 0
;**********************************************************
;------------------TEXT DATA-------------------------------
;**********************************************************
name_of_program db 'Graphics editor <<ANIMAGE>> V1.00 '
mouse_pos_x db 'X='
mouse_pos_y db 'Y='
new_text1 db 'PICTURE SIZE X'
new_text2 db 'PICTURE SIZE Y'
ok_text db 'OK'
 
panel_text dd 15,24,4
db 'FILE'
dd 95,24,4
db 'EDIT'
dd 175,24,11
db 'INSTRUMENTS'
dd 255,24,7
db 'PALETTE'
dd 335,24,7
db 'FILTERS'
dd 415,24,9
db 'ANIMATION'
dd 495,24,4
db 'HELP'
menu_text_en:
dd menu_text7
dd menu_text6
dd menu_text5
dd menu_text4
dd menu_text3
dd menu_text2
dd menu_text1
dd 0,0,0
 
menu_rectangles dd 485,36,100,100
dd 405,36,100,100
dd 325,36,100,100
dd 245,36,100,100
dd 165,36,100,100
dd 85,36,100,100;20
dd 5,36,100,100
 
 
menu_text1:
dd 15,45,3
db 'NEW'
dd 15,65,4
db 'OPEN'
dd 15,85,4
db 'SAVE'
dd 15,105,7
db 'SAVE AS'
dd 15,125,4
db 'EXIT'
 
menu_text2:
dd 95,45,4
db 'UNDO'
dd 95,65,4
db 'COPY'
dd 95,85,5
db 'PASTE'
dd 95,105,3
db 'CUT'
dd 95,125,13
db 'CLEARE SCREEN'
;dd 95,145,12
;db 'ALLOCATE ALL'
menu_text3:
dd 175,45,3
db 0,0,0;'PENCIL'
dd 175,65,3
db 0,0,0;'BRUSHES'
dd 175,85,3
db 0,0,0;'COLORS'
dd 175,105,3
db 0,0,0;'PIPETKA'
menu_text4:
dd 255,45,1
db 0,0,0
menu_text5:
dd 335,45,1
db 0,0,0
menu_text6:
dd 415,45,1
db 0,0,0
menu_text7:
dd 495,45,1
db 0,0,0,0
 
 
menu_counters:
dd 1,1,1,1,1,5,5
 
;----------------------------------------------------------
palitra: ;three bytes for one color
db 0,0,0,0,0,0,128,0
db 0,128,0,0,0,128,128,0
db 128,0,0,0,128,0,128,0
db 128,128,0,0,128,128,128,0
db 192,220,192,0,240,202,166,0
db 170,63,42,0,255,63,42,0
db 0,95,42,0,85,95,42,0
db 170,95,42,0,255,95,42,0
db 0,127,42,0,85,127,42,0
db 170,127,42,0,255,127,42,0
db 0,159,42,0,85,159,42,0
db 170,159,42,0,255,159,42,0
db 0,191,42,0,85,191,42,0
db 170,191,42,0,255,191,42,0
db 0,223,42,0,85,223,42,0
db 170,223,42,0,255,223,42,0
db 0,255,42,0,85,255,42,0
db 170,255,42,0,255,255,42,0
db 0,0,85,0,85,0,85,0
db 170,0,85,0,255,0,85,0
db 0,31,85,0,85,31,85,0
db 170,31,85,0,255,31,85,0
db 0,63,85,0,85,63,85,0
db 170,63,85,0,255,63,85,0
db 0,95,85,0,85,95,85,0
db 170,95,85,0,255,95,85,0
db 0,127,85,0,85,127,85,0
db 170,127,85,0,255,127,85,0
db 0,159,85,0,85,159,85,0
db 170,159,85,0,255,159,85,0
db 0,191,85,0,85,191,85,0
db 170,191,85,0,255,191,85,0
db 0,223,85,0,85,223,85,0
db 170,223,85,0,255,223,85,0
db 0,255,85,0,85,255,85,0
db 170,255,85,0,255,255,85,0
db 0,0,127,0,85,0,127,0
db 170,0,127,0,255,0,127,0
db 0,31,127,0,85,31,127,0
db 170,31,127,0,255,31,127,0
db 0,63,127,0,85,63,127,0
db 170,63,127,0,255,63,127,0
db 0,95,127,0,85,95,127,0
db 170,95,127,0,255,95,127,0
db 0,127,127,0,85,127,127,0
db 170,127,127,0,255,127,127,0
db 0,159,127,0,85,159,127,0
db 170,159,127,0,255,159,127,0
db 0,191,127,0,85,191,127,0
db 170,191,127,0,255,191,127,0
db 0,223,127,0,85,223,127,0
db 170,223,127,0,255,223,127,0
db 0,255,127,0,85,255,127,0
db 170,255,127,0,255,255,127,0
db 0,0,170,0,85,0,170,0
db 170,0,170,0,255,0,170,0
db 0,31,170,0,85,31,170,0
db 170,31,170,0,255,31,170,0
db 0,63,170,0,85,63,170,0
db 170,63,170,0,255,63,170,0
db 0,95,170,0,85,95,170,0
db 170,95,170,0,255,95,170,0
db 0,127,170,0,85,127,170,0
db 170,127,170,0,255,127,170,0
db 0,159,170,0,85,159,170,0
db 170,159,170,0,255,159,170,0
db 0,191,170,0,85,191,170,0
db 170,191,170,0,255,191,170,0
db 0,223,170,0,85,223,170,0
db 170,223,170,0,255,223,170,0
db 0,255,170,0,85,255,170,0
db 170,255,170,0,255,255,170,0
db 0,0,212,0,85,0,212,0
db 170,0,212,0,255,0,212,0
db 0,31,212,0,85,31,212,0
db 170,31,212,0,255,31,212,0
db 0,63,212,0,85,63,212,0
db 170,63,212,0,255,63,212,0
db 0,95,212,0,85,95,212,0
db 170,95,212,0,255,95,212,0
db 0,127,212,0,85,127,212,0
db 170,127,212,0,255,127,212,0
db 0,159,212,0,85,159,212,0
db 170,159,212,0,255,159,212,0
db 0,191,212,0,85,191,212,0
db 170,191,212,0,255,191,212,0
db 0,223,212,0,85,223,212,0
db 170,223,212,0,255,223,212,0
db 0,255,212,0,85,255,212,0
db 170,255,212,0,255,255,212,0
db 85,0,255,0,170,0,255,0
db 0,31,255,0,85,31,255,0
db 170,31,255,0,255,31,255,0
db 0,63,255,0,85,63,255,0
db 170,63,255,0,255,63,255,0
db 0,95,255,0,85,95,255,0
db 170,95,255,0,255,95,255,0
db 0,127,255,0,85,127,255,0
db 170,127,255,0,255,127,255,0
db 0,159,255,0,85,159,255,0
db 170,159,255,0,255,159,255,0
db 0,191,255,0,85,191,255,0
db 170,191,255,0,255,191,255,0
db 0,223,255,0,85,223,255,0
db 170,223,255,0,255,223,255,0
db 85,255,255,0,170,255,255,0
db 255,204,204,0,255,204,255,0
db 255,255,51,0,255,255,102,0
db 255,255,153,0,255,255,204,0
db 0,127,0,0,85,127,0,0
db 170,127,0,0,255,127,0,0
db 0,159,0,0,85,159,0,0
db 170,159,0,0,255,159,0,0
db 0,191,0,0,85,191,0,0
db 170,191,0,0,255,191,0,0
db 0,223,0,0,85,223,0,0
db 170,223,0,0,255,223,0,0
db 85,255,0,0,170,255,0,0
db 0,0,42,0,85,0,42,0
db 170,0,42,0,255,0,42,0
db 0,31,42,0,85,31,42,0
db 170,31,42,0,255,31,42,0
db 0,63,42,0,170,174,160,0
db 240,251,255,0,164,160,160,0
db 128,128,128,0,0,0,255,0
db 0,255,0,0,0,255,255,0
db 255,0,0,0,255,0,255,0
db 255,255,0,0xff,0xff,0xff,0xff
;----------------------------------------------------------
;--------------------COLOR BRUSHES-------------------------
;----------------------------------------------------------
Brush_color:
;
db 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,1,1,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
db 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
db 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
db 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
db 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
db 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
db 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
db 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
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
 
;
db 0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,1,1,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
db 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
db 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
db 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
db 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
db 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
db 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
db 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
 
;
db 0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0
db 0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,1,1,1,1,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
db 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
db 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
db 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
db 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
db 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
db 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
 
;
db 0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0
db 0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0
db 0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0
db 0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0
db 0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0
db 0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0
db 0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0
db 0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,1,1,1,1,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
db 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
db 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
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
 
;
db 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,1,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
db 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
db 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
db 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
db 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
db 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
db 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
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
 
;
db 0
;------------------------------------------
Spray_color:
;
db 0,1,0,0,0,0,0,0,0,1,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
db 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0
db 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,1,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
db 0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,1,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
db 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
db 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
db 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
db 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
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;
db 0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0
db 0,0,0,0,1,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,1,0,0,0,0,0,0,0,0,0
db 0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0
db 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0
db 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0
db 0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0
db 0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0
db 0,0,1,0,0,0,0,1,0,0,0,0,0,1,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
db 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0
db 0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0
db 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0
db 0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,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
db 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,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0
db 0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0
db 0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0
db 0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0
db 0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0
db 0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0
db 0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0
db 0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,1,1,1,1,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
db 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
db 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
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
 
;------------------------------------------
width_pixels:
 
db 1,0,0,0,0
db 0,0,0,0,0
db 0,0,0,0,0
db 0,0,0,0,0
db 0,0,0,0,0
;
db 1,1,0,0,0
db 1,1,0,0,0
db 0,0,0,0,0
db 0,0,0,0,0
db 0,0,0,0,0
;
db 0,1,0,0,0
db 1,1,1,0,0
db 0,1,0,0,0
db 0,0,0,0,0
db 0,0,0,0,0
;
db 0,1,1,0,0
db 1,1,1,1,0
db 1,1,1,1,0
db 0,1,1,0,0
db 0,0,0,0,0
;
db 0,0,1,0,0
db 0,1,1,1,0
db 1,1,1,1,1
db 0,1,1,1,0
db 0,0,1,0,0
;-----------------------------------------
width_pixels_rectangle:
 
db 1,0,0,0,0
db 0,0,0,0,0
db 0,0,0,0,0
db 0,0,0,0,0
db 0,0,0,0,0
;
db 1,1,0,0,0
db 1,1,0,0,0
db 0,0,0,0,0
db 0,0,0,0,0
db 0,0,0,0,0
;
db 1,1,1,0,0
db 1,1,1,0,0
db 1,1,1,0,0
db 0,0,0,0,0
db 0,0,0,0,0
;
db 1,1,1,1,0
db 1,1,1,1,0
db 1,1,1,1,0
db 1,1,1,1,0
db 0,0,0,0,0
;
db 1,1,1,1,1
db 1,1,1,1,1
db 1,1,1,1,1
db 1,1,1,1,1
db 1,1,1,1,1
 
;----------------------------------------------------------
;-------------------ICON"S picture-------------------------
;----------------------------------------------------------
panel_picture:
file 'worktab1.gif'
 
;----------------------------------------------------------
 
I_END:
 
 
/programs/media/animage/trunk/bmplib.inc
0,0 → 1,715
;**************************************************************************
;**********************DECODING BMP FILE(1,4,8,24 bits)*********************
;***************************************************************************
; BMPTOIMG -Convert BMP format TO IMG format
;***************************************************************************
bmptoimg:
 
mov [bmp_load_area],esi
mov [img_dest_area],edi
xor eax,eax
mov ax,word[esi+28]
mov ebx,[esi+14]
mov ecx,[esi+18]
mov edx,[esi+22]
mov [bmp_bits_per_pixel],ax
mov [bmp_first_structure_size],ebx
mov [Bmp_SizeY],edx
mov [Bmp_SizeX],ecx
 
xor eax,eax
mov ax,[esi+28]
mul dword [esi+18]
add eax,31
shr eax,5
mov dword [bmptoimg_data_area_dwps],eax ;dwps-doublewords per string
shl eax,2
mov dword [bmptoimg_data_area_bps],eax ;bps-bytes per string
 
cmp dword [esi+34],0
jne yespicsize ;if picture size is defined
mul dword [esi+22]
mov dword [esi+34],eax
 
yespicsize:
 
mov eax,[bmp_load_area]
add eax, [esi+10] ;how mach bytes to begin bitmap
add eax, [esi+34] ;size of bitmap in BMP file
mov dword [bmptoimg_data_area_eop],eax ;eop-end of picture in file
;calculate bytes per string
mov eax, [esi+18]
lea eax,[eax+2*eax] ;3x pixels in eax
mov [bmp_bytes_per_string],eax
 
mov esi,dword [bmptoimg_data_area_eop]
sub esi,dword [bmptoimg_data_area_bps]
 
mov ebp,[img_dest_area]
mov edi,[img_dest_area]
mov ebx,[bmp_load_area]
add ebx, [bmp_first_structure_size]
add ebx,14 ;in ebx start of color table
 
 
cmp [bmp_bits_per_pixel],24
je convert_to_24bpp
 
cmp [bmp_bits_per_pixel],8
je convert_to_8bpp
 
cmp [bmp_bits_per_pixel],4
je convert_to_4bpp
 
cmp [bmp_bits_per_pixel],1
je convert_to_1bpp
 
jmp end_bmp
 
;--------------------------------------------------
;-----------Decoding 24 bit BMP file---------------
;--------------------------------------------------
convert_to_24bpp:
 
mov ebx,[Bmp_SizeY]
loop_convert_to_24bpp_y:
 
mov edi,ebp
mov ecx,[bmptoimg_data_area_dwps]
 
loop_convert_to_24bpp_x:
 
mov edx,[esi]
mov [edi],edx
add esi,4
add edi,4
 
dec ecx
jnz loop_convert_to_24bpp_x
 
sub esi,[bmptoimg_data_area_bps]
sub esi,[bmptoimg_data_area_bps]
 
add ebp,eax
dec ebx
jnz loop_convert_to_24bpp_y
 
jmp end_bmp
;-----------------------------------------------------
;--------------Decoding 8 bits BMP file---------------
;-----------------------------------------------------
convert_to_8bpp:
 
mov ebp,[Bmp_SizeY]
loop_convert_8bpp_y:
 
mov ecx,[bmptoimg_data_area_bps]
push edi
 
loop_convert_8bpp_x:
 
xor eax,eax
mov al,byte [esi]
call converttable
inc esi
add edi,3
 
dec ecx
jnz loop_convert_8bpp_x
 
pop edi
 
add edi,[bmp_bytes_per_string]
sub esi,[bmptoimg_data_area_bps]
sub esi,[bmptoimg_data_area_bps]
 
dec ebp
jnz loop_convert_8bpp_y
 
jmp end_bmp
;-----------------------------------------------------
;--------------Decoding 4 bits BMP file---------------
;-----------------------------------------------------
convert_to_4bpp:
 
mov ebp,[Bmp_SizeY]
loop_convert_4bpp_y:
 
mov ecx,[bmptoimg_data_area_bps]
push edi
 
loop_convert_4bpp_x:
 
mov [Bmp_save1],ecx
xor eax,eax
mov al,byte [esi]
xor ecx,ecx
mov cl,al
shr al,4 ;first pixel in byte
and cl,0xf ;second pixel in byte
call converttable ;draw first pixel of byte
mov eax,ecx ;move second pixel to register al and draw
add edi,3
call converttable ;draw second pixel of byte
add edi,3
mov ecx,[Bmp_save1]
inc esi
 
dec ecx
jnz loop_convert_4bpp_x
 
pop edi
 
add edi,[bmp_bytes_per_string]
sub esi,[bmptoimg_data_area_bps]
sub esi,[bmptoimg_data_area_bps]
 
dec ebp
jnz loop_convert_4bpp_y
 
jmp end_bmp
;-----------------------------------------------------
;---------------Decoding 1 bit BMP file---------------
;-----------------------------------------------------
convert_to_1bpp:
 
mov ebp,[Bmp_SizeY]
loop_convert_1bpp_y:
 
mov ecx,[bmptoimg_data_area_bps]
push edi
 
loop_convert_1bpp_x:
 
xor eax,eax
mov al,byte [esi]
mov [Bmp_save1],ecx
mov ecx,eax
mov edx,7
nextbit:
xor eax,eax
bt ecx,edx
jnc noaddelem
inc eax
noaddelem:
 
push edx
call converttable
pop edx
 
add edi,3
dec edx
jns nextbit
mov ecx,[Bmp_save1]
inc esi
dec ecx
jnz loop_convert_1bpp_x
 
pop edi
 
add edi,[bmp_bytes_per_string]
sub esi,[bmptoimg_data_area_bps]
sub esi,[bmptoimg_data_area_bps]
 
dec ebp
jnz loop_convert_1bpp_y
 
jmp end_bmp
;-----------------------------------------------------
converttable:
shl eax,2
add eax,ebx
mov edx, dword [eax]
mov [edi],edx
ret
;-----------------------------------------------------
; DATA AREA
bmptoimg_data_area_bps dd 0
bmptoimg_data_area_dwps dd 0
bmptoimg_data_area_eop dd 0
bmp_load_area dd 0
img_dest_area dd 0
bmp_bits_per_pixel dw 0
bmp_first_structure_size dd 0
bmp_bytes_per_string dd 0
 
end_bmp:
 
ret
 
;***************************************************************************
;*******************CODING BMP FILE(1,4,8,24 bits)**************************
;***************************************************************************
 
;-------------------------autor andrew_programmer---------------------------
 
coding_bmp:
 
mov [PointerToImage],ebx
mov [WhereCodingBMP],ecx
mov [BmpPalette],edx
mov [Bmp_SizeX],esi
mov [Bmp_SizeY],edi
;**********************************************
;******************1 bit BMP*******************
;**********************************************
cmp eax,2
ja no_monohrom_colors
mov esi,[BmpPalette]
mov edi,[WhereCodingBMP]
add edi,54
mov eax,[esi] ;first color
mov ebx,[esi+4] ;second color
mov [edi],eax
mov [edi+4],ebx
 
;coding image to bmp 1 bit format
mov esi,[PointerToImage]
mov edx,[WhereCodingBMP]
mov ebx,[Bmp_SizeX]
add ebx,31 ;picture_size_x+31
shr ebx,5 ;((picture_size_x)+31)/32
mov [Bmp_doublewords],ebx ;double words in string
shl ebx,2
mov [Bmp_bytes_per_string],ebx ;bytes per string
mov ecx,[Bmp_SizeY]
dec ecx
imul ebx,ecx
add edx,54+8
add edx,ebx ;in edx pointer to area for coding
 
mov ebp,[Bmp_bytes_per_string]
 
mov ebx,[Bmp_SizeY]
mov esi,[PointerToImage]
mov edi,edx
 
mov edx,[Bmp_SizeX]
lea edx,[edx+edx*2]
 
mov [Bmp_Counter],7
and [Bmp_Counter2],0
copy_lines_1:
 
push esi
mov ecx,[Bmp_bytes_per_string]
shl ecx,3 ;(Bmp_bytes_per_string)*8
 
rep_movsb_1:
 
mov eax,[esi]
and eax,0xffffff
push esi
push ecx
push ebx
mov esi,[BmpPalette]
xor ecx,ecx
find_color_in_palette_1:
mov ebx,[esi]
and ebx,0xffffff
cmp eax,ebx ;color fined ?
je color_fined_1
add esi,4
inc ecx
cmp ecx,256
jl find_color_in_palette_1
color_fined_1:
mov [Bmp_Counter3],ecx ;number color in palette
pop ebx
pop ecx
pop esi
mov eax,[Bmp_Counter3]
 
test eax,eax
jz no_change_bit_in_byte
 
push ecx
mov ecx,[Bmp_Counter]
bts [Bmp_Counter2],ecx
pop ecx
 
no_change_bit_in_byte:
 
dec [Bmp_Counter]
jns no_minus_in_counter
 
push eax
mov eax,[Bmp_Counter2]
mov [edi],al
inc edi
mov [Bmp_Counter],7
and [Bmp_Counter2],0 ;obnulyaem byte
pop eax
 
no_minus_in_counter:
 
add esi,3
dec ecx
jnz rep_movsb_1
pop esi
 
add esi,edx
sub edi,ebp
sub edi,ebp
 
dec ebx
jnz copy_lines_1
 
mov edi,[WhereCodingBMP]
mov ebx,[Bmp_bytes_per_string]
imul ebx,[Bmp_SizeY]
add ebx,(54+8)
 
;crate list of bmp description
mov [edi],word 'BM'
mov [edi+2],ebx
mov [edi+10],dword 54+8 ;where bigin bmp imige
mov [edi+14],dword 40
mov edx,[Bmp_SizeX]
mov ecx,[Bmp_SizeY]
mov [edi+18],edx ;picture size x
mov [edi+22],ecx ;picture size y
mov [edi+26],word 1
mov [edi+28],word 1 ;bits per pixel
mov [edi+30],dword 0
mov edx,[Bmp_bytes_per_string]
imul edx,ecx
mov [edi+34],edx
mov [edi+38],dword 0
mov [edi+42],dword 0
mov [edi+46],dword 0
 
ret
 
no_monohrom_colors:
 
;**********************************************
;*****************4 bits BMP*******************
;**********************************************
cmp eax,16
ja no_16_colors
;copy 16 colors palette
mov esi,[BmpPalette]
mov edi,[WhereCodingBMP]
add edi,54
mov ecx,16
rep movsd
 
;coding image to bmp 4 bits format
mov esi,[PointerToImage]
mov edx,[WhereCodingBMP]
mov ebx,[Bmp_SizeX]
shl ebx,2 ;4*(picture_size_x)
add ebx,31 ;4*(picture_size_x)+31
shr ebx,5 ;(4*(picture_size_x)+31)/32
mov [Bmp_doublewords],ebx ;double words in string
shl ebx,2
mov [Bmp_bytes_per_string],ebx ;bytes per string
mov ecx,[Bmp_SizeY]
dec ecx
imul ebx,ecx
add edx,54+64
add edx,ebx
 
mov ebp,[Bmp_bytes_per_string]
 
mov ebx,[Bmp_SizeY]
mov [Bmp_Counter2],ebx
 
mov edi,edx
 
xor ebx,ebx
copy_lines_4:
 
mov ecx,[Bmp_bytes_per_string]
shl ecx,1
 
and [Bmp_Counter3],0
push esi
 
rep_movsb_4:
mov eax,[esi]
and eax,0xffffff
 
mov [Bmp_save1],esi
mov [Bmp_save2],ecx
mov [Bmp_save3],ebx
mov esi,[BmpPalette]
xor ecx,ecx
find_color_in_palette_:
mov ebx,[esi]
and ebx,0xffffff
cmp eax,ebx ;color fined ?
je color_fined_
add esi,4
inc ecx
cmp ecx,16
jl find_color_in_palette_
color_fined_:
mov [Bmp_Counter],ecx ;number color in palette
mov esi,[Bmp_save1]
mov ecx,[Bmp_save2]
mov ebx,[Bmp_save3]
 
xor eax,eax
mov eax,[Bmp_Counter]
shl bl,4
add bl,al
 
mov eax,[Bmp_Counter3]
and eax,1b
test eax,eax ;next block ready ?
jz no_ready
mov [edi],bl ;4 bit color
inc edi
no_ready:
 
add esi,3
inc [Bmp_Counter3]
 
dec ecx
jnz rep_movsb_4
 
pop esi
 
add esi,[Bmp_SizeX]
add esi,[Bmp_SizeX]
add esi,[Bmp_SizeX]
 
sub edi,ebp
sub edi,ebp
 
dec [Bmp_Counter2]
jnz copy_lines_4
 
;total size of bmp file
mov edi,[WhereCodingBMP]
mov ebx,[Bmp_bytes_per_string]
imul ebx,[Bmp_SizeY]
add ebx,(54+64)
 
;crate list of bmp description
mov [edi],word 'BM'
mov [edi+2],ebx
mov [edi+10],dword 54+64
mov [edi+14],dword 40
mov edx,[Bmp_SizeX]
mov ecx,[Bmp_SizeY]
mov [edi+18],edx
mov [edi+22],ecx
mov [edi+26],word 1
mov [edi+28],word 4
mov [edi+30],dword 0
mov edx,[Bmp_bytes_per_string]
imul edx,ecx
mov [edi+34],edx
mov [edi+38],dword 0
mov [edi+42],dword 0
mov [edi+46],dword 0
 
ret
no_16_colors:
 
;**********************************************
;******************8 bits BMP******************
;**********************************************
 
cmp eax,256
ja no_8_bits_per_pixel
;copy palette
mov esi,[BmpPalette]
mov edi,[WhereCodingBMP]
add edi,54
mov ecx,256
rep movsd
 
;coding image to bmp 8 bits format
mov esi,[PointerToImage]
mov edx,[WhereCodingBMP]
mov ebx,[Bmp_SizeX]
shl ebx,3 ;8*(picture_size_x)
add ebx,31 ;8*(picture_size_x)+31
shr ebx,5 ;(8*(picture_size_x)+31)/32
mov [Bmp_doublewords],ebx ;double words in string
shl ebx,2
mov [Bmp_bytes_per_string],ebx ;bytes per string
 
mov ecx,[Bmp_SizeY]
dec ecx
imul ebx,ecx
add edx,(1024+54)
add edx,ebx ;in edx pointer to copy bitmap arrea
 
mov ebp,[Bmp_bytes_per_string]
shl ebp,1
 
mov ebx,[Bmp_SizeY]
mov edi,edx
 
copy_lines_8:
 
mov ecx,[Bmp_bytes_per_string]
mov [Bmp_save1],esi
rep_movsb_8:
mov eax,[esi]
and eax,0xffffff
push esi
push ecx
push ebx
mov esi,[BmpPalette]
xor ecx,ecx
find_color_in_palette:
mov ebx,[esi]
and ebx,0xffffff
cmp eax,ebx ;color fined ?
je color_fined
add esi,4
inc ecx
cmp ecx,256
jl find_color_in_palette
color_fined:
mov [Bmp_Counter],ecx ;number color in palette
pop ebx
pop ecx
pop esi
mov eax,[Bmp_Counter]
mov [edi],al ;8 bit color
add esi,3
inc edi
 
dec ecx
jnz rep_movsb_8
 
mov esi,[Bmp_save1]
 
add esi,[Bmp_SizeX]
add esi,[Bmp_SizeX]
add esi,[Bmp_SizeX]
 
sub edi,ebp
dec ebx
jnz copy_lines_8
 
;total size of bmp file
mov edi,[WhereCodingBMP]
mov ebx,[Bmp_bytes_per_string]
imul ebx,[Bmp_SizeY]
add ebx,54+1024
 
;crate list of bmp description
mov [edi],word 'BM'
mov [edi+2],ebx
mov [edi+10],dword 54+1024
mov [edi+14],dword 40
mov edx,[Bmp_SizeX]
mov ecx,[Bmp_SizeY]
mov [edi+18],edx
mov [edi+22],ecx
mov [edi+26],word 1
mov [edi+28],word 8
mov [edi+30],dword 0
mov edx,[Bmp_bytes_per_string]
imul edx,ecx
mov [edi+34],edx
mov [edi+38],dword 0
mov [edi+42],dword 0
mov [edi+46],dword 0
 
ret
no_8_bits_per_pixel:
 
;**********************************************
;*******************24 bit BMP*****************
;**********************************************
 
cmp eax,256
jle no_32_bits_per_pixel
;copy picture
mov esi,[PointerToImage]
mov edx,[WhereCodingBMP]
mov ebx,[Bmp_SizeX]
shl ebx,3 ;8*(picture_size_x)
lea ebx,[ebx+ebx*2] ;3*8*(picture_size_x)
add ebx,31 ;3*8*(picture_size_x)+31
shr ebx,5 ;(3*8*(picture_size_x)+31)/32
mov [Bmp_doublewords],ebx ;double words in string
shl ebx,2
mov [Bmp_bytes_per_string],ebx ;bytes per string
mov ecx,[Bmp_SizeY]
dec ecx
imul ebx,ecx
add edx,54
add edx,ebx ;in edx pointer to start of copy bit map
 
mov ebp,[Bmp_bytes_per_string]
shl ebp,1
 
mov ebx,[Bmp_SizeY]
 
mov esi,[PointerToImage]
mov edi,edx
 
mov edx,[Bmp_SizeX]
lea edx,[edx+edx*2]
 
copy_lines_24:
 
push esi
mov ecx,[Bmp_doublewords]
rep_movsb_24:
mov eax,[esi]
mov [edi],eax
add esi,4
add edi,4
dec ecx
jnz rep_movsb_24
pop esi
 
add esi,edx
sub edi,ebp
dec ebx
jnz copy_lines_24
 
;total size of bmp fille
mov edi,[WhereCodingBMP]
mov ebx,[Bmp_bytes_per_string]
imul ebx,[Bmp_SizeY]
add ebx,54
 
;write info to structure of bmp file
mov [edi],word 'BM'
mov [edi+2],ebx
mov [edi+10],dword 54 ;where begin bmp imige
mov [edi+14],dword 40 ;total size of structure number two
mov edx,[Bmp_SizeX]
mov ecx,[Bmp_SizeY]
mov [edi+18],edx
mov [edi+22],ecx
mov [edi+26],word 1
mov [edi+28],word 24 ;bytes per pixel
mov [edi+30],dword 0
mov edx,[Bmp_bytes_per_string]
imul edx,ecx
mov [edi+34],edx ;size of bmp image
mov [edi+38],dword 0
mov [edi+42],dword 0
mov [edi+46],dword 0
ret
no_32_bits_per_pixel:
 
 
ret
 
PointerToImage dd 0
WhereCodingBMP dd 0
BmpPalette dd 0
Bmp_SizeX dd 0
Bmp_SizeY dd 0
Bmp_Counter dd 0
Bmp_Counter2 dd 0
Bmp_Counter3 dd 0
Bmp_save1 dd 0
Bmp_save2 dd 0
Bmp_save3 dd 0
Bmp_bytes_per_string dd 0
Bmp_doublewords dd 0
/programs/media/animage/trunk/build_en.bat
0,0 → 1,3
@fasm animage.asm animage
@mtappack animage
@pause
/programs/media/animage/trunk/design.inc
0,0 → 1,333
;-----------------------------------------------------
draw_volume_rectangle:
 
mov [line_x],eax
mov [line_y],ebx
mov [line_size_x],ecx
mov [line_size_y],edx
 
cmp esi,1
jne no_volume_light_rectangle
 
mov [color_rectangle],9350878
mov [color_line1],5669590
mov [color_line2],12508927
mov [color_line3],9350878
jmp exit_colors
 
no_volume_light_rectangle:
 
cmp esi,2
jne no_pressed_rectangle
 
mov [color_rectangle],9089258
mov [color_line1],5669590
mov [color_line2],9089258
mov [color_line3],9089258
 
jmp exit_colors
 
no_pressed_rectangle:
 
cmp esi,3
jne no_pressed_panel
 
mov [color_rectangle],9350878
mov [color_line1],5669590
mov [color_line2],7000
mov [color_line3],12508927
jmp exit_colors
 
no_pressed_panel:
 
cmp esi,4
jne no_pressed_light_panel
 
mov [color_rectangle],0xffffff
mov [color_line1],5669590
mov [color_line2],7000
mov [color_line3],12508927
jmp exit_colors
 
no_pressed_light_panel:
 
cmp esi,5
jne no_light_pressed_rectangle
 
mov [color_rectangle],9089258
mov [color_line1],5669590
mov [color_line2],9089258
mov [color_line3],9089258
 
jmp exit_colors
 
no_light_pressed_rectangle:
 
cmp esi,6
jne no_work_rectangle
 
mov [color_rectangle],9350878
mov [color_line1],5669590
mov [color_line2],9350878
mov [color_line3],9350878
jmp exit_colors
 
no_work_rectangle:
 
cmp esi,7
jne no_work_rectangle_2
 
mov [color_rectangle],9350878
mov [color_line1],9350878
mov [color_line2],9350878
mov [color_line3],9350878
jmp exit_colors
 
no_work_rectangle_2:
 
exit_colors:
;draw rectangle
mov ebx,[line_x]
mov ecx,[line_y]
shl ebx,16
shl ecx,16
add ebx,[line_size_x]
add ecx,[line_size_y]
mov edx,[color_rectangle]
call draw_rectangle
;line 1
mov edx,[color_line1]
mov ebx,[line_x]
mov ecx,[line_y]
shl ebx,16
shl ecx,16
add ebx,[line_x]
add ecx,[line_y]
add ebx,[line_size_x]
call draw_line
;line 2
mov edx,[color_line1]
mov ebx,[line_x]
mov ecx,[line_y]
shl ebx,16
shl ecx,16
add ebx,[line_x]
add ecx,[line_y]
add ecx,[line_size_y]
call draw_line
;line 3
mov edx,[color_line1]
mov ebx,[line_x]
mov ecx,[line_y]
add ecx,[line_size_y]
shl ebx,16
shl ecx,16
add ebx,[line_x]
add ecx,[line_y]
add ebx,[line_size_x]
add ecx,[line_size_y]
call draw_line
;line 4
mov edx,[color_line1]
mov ebx,[line_x]
mov ecx,[line_y]
add ebx,[line_size_x]
shl ebx,16
shl ecx,16
add ebx,[line_x]
add ecx,[line_y]
add ebx,[line_size_x]
add ecx,[line_size_y]
call draw_line
;light line 1
mov edx,[color_line2]
mov ebx,[line_x]
mov ecx,[line_y]
inc ebx
inc ecx
shl ebx,16
shl ecx,16
add ebx,[line_x]
add ecx,[line_y]
add ebx,[line_size_x]
dec ebx
inc ecx
call draw_line
;light line 2
mov edx,[color_line2]
mov ebx,[line_x]
mov ecx,[line_y]
inc ebx
inc ecx
shl ebx,16
shl ecx,16
add ebx,[line_x]
add ecx,[line_y]
add ecx,[line_size_y]
dec ecx
inc ebx
call draw_line
;light line 3
mov edx,[color_line3]
mov ebx,[line_x]
mov ecx,[line_y]
add ebx,[line_size_x]
dec ebx
inc ecx
shl ebx,16
shl ecx,16
add ebx,[line_x]
add ecx,[line_y]
add ebx,[line_size_x]
add ecx,[line_size_y]
dec ebx
dec ecx
call draw_line
;light line 4
mov edx,[color_line3]
mov ebx,[line_x]
mov ecx,[line_y]
add ecx,[line_size_y]
inc ebx
dec ecx
shl ebx,16
shl ecx,16
add ebx,[line_x]
add ecx,[line_y]
add ecx,[line_size_y]
add ebx,[line_size_x]
dec ecx
dec ebx
call draw_line
 
ret
;----------------------------------------------------------
rectangle:
 
no_light_rectangle:
mov [line_x],eax
mov [line_y],ebx
mov [line_size_x],ecx
mov [line_size_y],edx
mov edx,esi
mov eax,13
mov ebx,[line_x]
mov ecx,[line_y]
shl ebx,16
shl ecx,16
add ebx,[line_size_x]
add ecx,[line_size_y]
int 0x40
ret
;----------------------------------------------------------
draw_conture:
 
mov [line_x],eax
mov [line_y],ebx
mov [line_size_x],ecx
mov [line_size_y],edx
 
mov [color_line1],5669590
 
;line 1
mov edx,[color_line1]
mov ebx,[line_x]
mov ecx,[line_y]
shl ebx,16
shl ecx,16
add ebx,[line_x]
add ecx,[line_y]
add ebx,[line_size_x]
call draw_line
;line 2
mov edx,[color_line1]
mov ebx,[line_x]
mov ecx,[line_y]
shl ebx,16
shl ecx,16
add ebx,[line_x]
add ecx,[line_y]
add ecx,[line_size_y]
call draw_line
;line 3
mov edx,[color_line1]
mov ebx,[line_x]
mov ecx,[line_y]
add ecx,[line_size_y]
shl ebx,16
shl ecx,16
add ebx,[line_x]
add ecx,[line_y]
add ebx,[line_size_x]
add ecx,[line_size_y]
call draw_line
;line 4
mov edx,[color_line1]
mov ebx,[line_x]
mov ecx,[line_y]
add ebx,[line_size_x]
shl ebx,16
shl ecx,16
add ebx,[line_x]
add ecx,[line_y]
add ebx,[line_size_x]
add ecx,[line_size_y]
call draw_line
 
ret
;----------------------------------------------------------
columnus:
 
sub eax,ecx
jns no_columnus
neg eax
cmp eax,esi
ja no_columnus
sub ebx,edx
jns no_columnus
neg ebx
cmp ebx,edi
ja no_columnus
mov eax,1
jmp columnus_true
no_columnus:
xor eax,eax
columnus_true:
ret
;----------------------------------------------------------
print_text:
mov [text_x],eax
mov [text_y],ebx
mov eax,4
mov ebx,[text_x]
shl ebx,16
add ebx,[text_y]
int 0x40
ret
;----------------------------------------------------------
draw_rectangle:
mov eax,13
int 0x40
ret
;------------------------
draw_line:
mov eax,38
int 0x40
ret
;----------------------------------------------------------
;lightlin 12508927
;lines 5669590
;workpan 9350878
;btnpress 9089258
line_x dd 0
line_y dd 0
line_size_x dd 0
line_size_y dd 0
color_line1 dd 0
color_line2 dd 0
color_line3 dd 0
color_rectangle dd 0
;--------------------
text_x dd 0
text_y dd 0
;--------------------
/programs/media/animage/trunk/dialog.inc
0,0 → 1,423
macro opendialog redproc,openoff,erroff,path
{
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
local run_fileinfo, param
local getmesloop, loox, mred, mkey, mbutton, mgetmes
local dlg_is_work, ready, procinfo
;
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
;
 
cld
;; mov esi,path
mov edi,path
mov eax,0
mov ecx,200
rep stosb
 
;mov [get_loops],0
mov [dlg_pid_get],0
 
; Get my PID in dec format 4 bytes
mov eax,9
mov ebx,procinfo
mov ecx,-1
int 0x40
 
; convert eax bin to param dec
mov eax,dword [procinfo+30] ;offset of myPID
mov edi,param+4-1 ;offset to 4 bytes
mov ecx,4
mov ebx,10
cld
new_d:
xor edx,edx
div ebx
add dl,'0'
mov [edi],dl
dec edi
loop new_d
 
; wirite 1 byte space to param
mov [param+4],byte 32 ;Space for next parametr
; and 1 byte type of dialog to param
mov [param+5],byte 'O' ;Get Open dialog (Use 'S' for Save dialog)
 
;
; STEP2 prepare IPC area for get messages
;
 
; prepare IPC area
mov [path],dword 0
mov [path+4],dword 8
 
; define IPC memory
mov eax,60
mov ebx,1 ; define IPC
mov ecx,path ; offset of area
mov edx,150 ; size 150 bytes
int 0x40
 
; change wanted events list 7-bit IPC event
mov eax,40
mov ebx,01000111b
int 0x40
 
;
; STEP 3 run SYSTEM XTREE with parameters
;
 
mov eax,58
mov ebx,run_fileinfo
int 0x40
 
call redproc
 
mov [get_loops],0
getmesloop:
mov eax,23
mov ebx,50 ;0.5 sec
int 0x40
 
cmp eax,1
je mred
cmp eax,2
je mkey
cmp eax,3
je mbutton
cmp eax,7
je mgetmes
 
; Get number of procces
mov ebx,procinfo
mov ecx,-1
mov eax,9
int 0x40
mov ebp,eax
 
loox:
mov eax,9
mov ebx,procinfo
mov ecx,ebp
int 0x40
mov eax,[DLGPID]
cmp [procinfo+30],eax ;IF Dialog find
je dlg_is_work ;jmp to dlg_is_work
dec ebp
jnz loox
 
jmp erroff
 
dlg_is_work:
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
je erroff ;TESTODP2 terminated too
 
cmp [dlg_pid_get],dword 1
je getmesloop
inc [get_loops]
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated
jae erroff
jmp getmesloop
 
mred:
call redproc
jmp getmesloop
mkey:
mov eax,2
int 0x40 ; read (eax=2)
jmp getmesloop
mbutton:
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne getmesloop
mov eax,-1 ; close this program
int 0x40
mgetmes:
 
; If dlg_pid_get then second message get jmp to still
cmp [dlg_pid_get],dword 1
je ready
 
; First message is number of PID SYSXTREE dialog
 
; convert PID dec to PID bin
movzx eax,byte [path+16]
sub eax,48
imul eax,10
movzx ebx,byte [path+16+1]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+2]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+3]
add eax,ebx
sub eax,48
mov [DLGPID],eax
 
; Claear and prepare IPC area for next message
mov [path],dword 0
mov [path+4],dword 8
mov [path+8],dword 0
mov [path+12],dword 0
mov [path+16],dword 0
 
; Set dlg_pid_get for get next message
mov [dlg_pid_get],dword 1
call redproc ;show DLG_PID
jmp getmesloop
 
ready:
;
; The second message get
; Second message is 100 bytes path to SAVE/OPEN file
; shl path string on 16 bytes
;
cld
mov esi,path+16
mov edi,path
mov ecx,200
rep movsb
mov [edi],byte 0
 
jmp openoff
 
 
; DATA AREA
get_loops dd 0
dlg_pid_get dd 0
DLGPID dd 0
 
param:
dd 0 ; My dec PID
dd 0,0 ; Type of dialog
 
run_fileinfo:
dd 16
dd 0
dd param
dd 0
dd procinfo ; 0x10000
;run_filepath
db '/RD/1/SYSXTREE',0
 
procinfo:
times 1024 db 0
}
 
 
macro savedialog redproc,openoff,erroff,path
{
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
local run_fileinfo, run_filepath, param
local getmesloop, loox, mred, mkey, mbutton, mgetmes
local dlg_is_work, ready, procinfo
;
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
;
 
cld
;; mov esi,path
mov edi,path
mov eax,0
mov ecx,200
rep stosb
 
;mov [get_loops],0
mov [dlg_pid_get],0
 
; Get my PID in dec format 4 bytes
mov eax,9
mov ebx,procinfo
mov ecx,-1
int 0x40
 
; convert eax bin to param dec
mov eax,dword [procinfo+30] ;offset of myPID
mov edi,param+4-1 ;offset to 4 bytes
mov ecx,4
mov ebx,10
cld
new_d:
xor edx,edx
div ebx
add dl,'0'
mov [edi],dl
dec edi
loop new_d
 
; wirite 1 byte space to param
mov [param+4],byte 32 ;Space for next parametr
; and 1 byte type of dialog to param
mov [param+5],byte 'S' ;Get Open dialog (Use 'S' for Save dialog)
 
;
; STEP2 prepare IPC area for get messages
;
 
; prepare IPC area
mov [path],dword 0
mov [path+4],dword 8
 
; define IPC memory
mov eax,60
mov ebx,1 ; define IPC
mov ecx,path ; offset of area
mov edx,150 ; size 150 bytes
int 0x40
 
; change wanted events list 7-bit IPC event
mov eax,40
mov ebx,01000111b
int 0x40
 
;
; STEP 3 run SYSTEM XTREE with parameters
;
 
mov eax,58
mov ebx,run_fileinfo
int 0x40
 
call redproc
 
mov [get_loops],0
getmesloop:
mov eax,23
mov ebx,50 ;0.5 sec
int 0x40
 
cmp eax,1
je mred
cmp eax,2
je mkey
cmp eax,3
je mbutton
cmp eax,7
je mgetmes
 
; Get number of procces
mov ebx,procinfo
mov ecx,-1
mov eax,9
int 0x40
mov ebp,eax
 
loox:
mov eax,9
mov ebx,procinfo
mov ecx,ebp
int 0x40
mov eax,[DLGPID]
cmp [procinfo+30],eax ;IF Dialog find
je dlg_is_work ;jmp to dlg_is_work
dec ebp
jnz loox
 
jmp erroff