kolibrios-gitea/programs/media/log_el/trunk/log_el.asm
IgorA 49b4b54d25 add new program 'log_el' (modeling logik elements)
git-svn-id: svn://kolibrios.org@2462 a494cfbc-eb01-0410-851d-a64ba20cac60
2012-03-15 09:43:33 +00:00

2141 lines
46 KiB
NASM
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use32
org 0x0
db 'MENUET01' ;¨¤¥­â¨ä. ¨á¯®«­ï¥¬®£® ä ©«  ¢á¥£¤  8 ¡ ©â
dd 0x1
dd start
dd i_end ;à §¬¥à ¯à¨«®¦¥­¨ï
dd mem
dd stacktop
dd 0
dd sys_path
color_border equ 0xff0000
color_s0 equ 0xff ;ᨣ­ « 0
color_s1 equ 0xffffff ;ᨣ­ « 1
color_s2 equ 0xff00 ;â®çª  ¡¥§ ¯¥à¥á¥ç¥­¨ï
color_s3 equ 0xff0000 ;¢à¥¬¥­­®¥ §­ ç¥­¨¥ ¤«ï á®åà ­¥­¨ï
color_caption equ 0x808080
;­®¬ à  ¨ª®­®ª:
el_icon_group equ 0 ;£à㯯®¢ ï
el_icon_points equ 1 ;â®çª¨
el_icon_sub_points equ 2 ;¨§®«ï樨
el_icon_elems equ 3 ;í«¥¬¥­â 
el_icon_captions equ 4 ;¯®¤¯¨á¨
size_el_opt equ 34 ;à §¬¥à áâàãªâãàë á ®¯æ¨ï¬¨ í«¥¬¥­â 
el_offs_nam equ 0 ;ᬥ饭¨¥ ¤«ï ­ ç «  ¨¬¥­¨ í«¥¬¥­â 
el_offs_col equ 16 ;梥â í«¥¬¥­â 
el_offs_box_x equ 20 ;è¨à¨­  ª®à®¡ª¨ í«¥¬¥­â 
el_offs_box_y equ 21 ;¢ëá®â  ª®à®¡ª¨ í«¥¬¥­â 
el_offs_table equ 22 ;㪠§ â¥«ì ­  â ¡«¨æã à ¡®âë í«¥¬¥­â 
el_offs_legs_inp equ 26 ;ᬥ饭¨¥ ­  ®¯¨á ­¨¥ ¢å®¤­ëå ­®£
el_offs_legs_out equ 30 ;ᬥ饭¨¥ ­  ®¯¨á ­¨¥ ¢ë室­ëå ­®£
sp_offs_el_type equ 9 ;ᬥ饭¨¥ ¤«ï ⨯  í«¥¬¥­â  ¢ ᯨ᪥
points_max equ 1000
capt_offs equ 10 ;ᬥ饭¨¥ ¤«ï ­ ç «  ¯®¤¯¨á¨ ¢ «¨á⥠tree1
include '../../../macros.inc'
include '../../../proc32.inc'
include '../../../develop/libraries/box_lib/load_lib.mac'
include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
include 'mem.inc'
include 'dll.inc'
include 'le_pole.inc'
include 'le_signal.inc'
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
caption db '‹®£¨ç¥áª¨¥ í«¥¬¥­âë 15.03.12',0 ;¯®¤¯¨áì ®ª­ 
panel_0_coord_top equ 5 ;¢¥àå­ïï ª®®à¤¨­ â  0-£® à鸞 ¯ ­¥«¨ ¨­áâà㬥­â®¢
panel_1_coord_top equ 35
panel_2_coord_top equ 60
panel_3_coord_top equ 85
align 4
proc move_rotate_x_n90 uses ecx edi, d_x:dword, angle:dword
mov edi,[angle] ;㣮« ¯®¢®à®â  / 90 (®â 0-3)
and edi,3
shl edi,4 ;edi*=16
add edi,mcs
mov ecx,[d_x]
imul ecx,dword[edi]
add eax,ecx
mov ecx,[d_x]
imul ecx,dword[edi+8]
add ebx,ecx
ret
endp
struct FileInfoBlock
Function dd ?
Position dd ?
Flags dd ?
Count dd ?
Buffer dd ?
db ?
FileName dd ?
ends
macro elOpt nam,col,box_x,box_y,table, il0, il1, il2, ol0, ol1, ol2
{
@@: db nam
rb @b+16-$
dd col
db box_x
db box_y
dd table+0 ;+el_offs_table
;+26
db il0+0 ;0-ï ¢å®¤­ ï ­®£ 
db il1+0 ;1-ï ¢å®¤­ ï ­®£ 
db il2+0
db 0
;+30
db ol0+0
db ol1+0
db ol2+0
db 0
}
align 4
el_opt_beg:
elOpt 'or[2]', 0xff00ff,5,5,tbl_or, 1,2,, 2
elOpt 'or[3]', 0xff00ff,5,7,tbl_or, 1,2,2, 3
elOpt 'and[2]',0xffff00,5,5,tbl_and.2, 1,2,, 2
elOpt 'and[3]',0xffff00,5,7,tbl_and.3, 1,2,2, 3
elOpt 'not', 0xffff,3,3,tbl_not, 1,,, 1
elOpt 'xor', 0x8000ff,5,5,tbl_xor, 1,2,, 2
elOpt 'sm[1]', 0x8080ff,7,7,tbl_sm, 1,2,2, 1,4
.end:
elOpt '???', 0x808080,3,3,tbl_and.3, 1,,, 1 ;­¥ ®¯®§­ ­­ë© í«¥¬¥­â
;â ¡«¨æë ¯® ª®â®àë¬ § ¤ îâáï ¯à ¢¨«  à ¡®âë í«¥¬¥­â®¢
align 4
tbl_or db 0,1,1,1, 1,1,1,1 ;or2, or3
tbl_and:
.3: db 0,0,0,0
.2: db 0,0,0,1
tbl_xor db 0,1,1,0
tbl_sm db 0,2,2,1, 2,1,1,3
tbl_not db 1,0 ;not
time dd 0
tim_ch db 0
pen_mode dd 0 ;०¨¬ à¨á®¢ ­¨ï ¯à®¢®¤ 
txt_set_0 db '0',0
txt_set_1 db '1',0
txt_mov_l db 27,0 ;<-
txt_mov_r db 26,0 ;->
txt_size db 'size',0
txt_elements db 'elements',0
txt_points db 'points',0
txt_sub_points db 'subpoints',0
txt_captions db 'captions',0
;¬ âà¨æ  ª®á¨­ãᮢ ¨ ᨭãᮢ, ¨á¯®«ì§ã¥¬ ï ¤«ï ¯®¢®à®â®¢ ᨣ­ «®¢ ¨ í«¥¬¥­â®¢
align 4
mcs dd 1, 0, 0, 1,\
0, 1,-1, 0,\
-1, 0, 0,-1,\
0,-1, 1, 0
run_file_70 FileInfoBlock
image_data dd 0 ;㪠§ â¥«ì ­  ¢à¥¬¥­­ãî ¯ ¬ïâì. ¤«ï ­ã¦¥­ ¯à¥®¡à §®¢ ­¨ï ¨§®¡à ¦¥­¨ï
IMAGE_TOOLBAR_ICON_SIZE equ 16*16*3
IMAGE_TOOLBAR_SIZE equ IMAGE_TOOLBAR_ICON_SIZE*15
image_data_toolbar dd 0
TREE_ICON_SYS16_BMP_SIZE equ IMAGE_TOOLBAR_ICON_SIZE*11+54 ;à §¬¥à bmp ä ©«  á á¨á⥬­ë¬¨ ¨ª®­ª ¬¨
icon_tl_sys dd 0 ;㪠§ â¥«ì ­  ¯ ¬ïâì ¤«ï åà ­¥­¨ï á¨á⥬­ëå ¨ª®­®ª
TOOLBAR_ICON_BMP_SIZE equ IMAGE_TOOLBAR_ICON_SIZE*5+54 ;à §¬¥à bmp ä ©«  á ¨ª®­ª ¬¨ ®¡ê¥ªâ®¢
icon_toolbar dd 0 ;㪠§ â¥«ì ­  ¯ ¬ïâì ¤«ï åà ­¥­¨ï ¨ª®­®ª ®¡ê¥ªâ®¢
IMAGE_FONT_SIZE equ 128*144*3
image_data_gray dd 0 ;¯ ¬ïâì á ¢à¥¬¥­­ë¬¨ á¥à묨 ¨§®¡à ¦¥­¨ï¬¨ ¢ ä®à¬ â¥ 24-bit, ¨§ ª®â®àëå ¡ã¤ãâ ᮧ¤ ¢ âìáï âà ä à¥âë
macro load_image_file path,buf,size { ;¬ ªà®á ¤«ï § £à㧪¨ ¨§®¡à ¦¥­¨©
;path - ¬®¦¥â ¡ëâì ¯¥à¥¬¥­­®© ¨«¨ áâப®¢ë¬ ¯ à ¬¥â஬
if path eqtype '' ;¯à®¢¥à塞 § ¤ ­ «¨ áâப®© ¯ à ¬¥âà path
jmp @f
local .path_str
.path_str db path ;ä®à¬¨à㥬 «®ª «ì­ãî ¯¥à¥¬¥­­ãî
db 0
@@:
;32 - áâ ­¤ àâ­ë©  ¤à¥á ¯® ª®â®à®¬ã ¤®«¦¥­ ¡ëâì ¡ãä¥à á á¨á⥬­ë¬ ¯ã⥬
copy_path .path_str,[32],file_name,0x0
else
copy_path path,[32],file_name,0x0 ;ä®à¬¨à㥬 ¯®«­ë© ¯ãâì ª ä ©«ã ¨§®¡à ¦¥­¨ï, ¯®¤à §ã¬¥¢ ¥¬ çâ® ®­ ¢ ®¤­®© ¯ ¯ª¥ á ¯à®£à ¬¬®©
end if
stdcall mem.Alloc, dword size ;¢ë¤¥«ï¥¬ ¯ ¬ïâì ¤«ï ¨§®¡à ¦¥­¨ï
mov [buf],eax
mov eax,70 ;70-ï äã­ªæ¨ï à ¡®â  á ä ©« ¬¨
mov [run_file_70.Function], 0
mov [run_file_70.Position], 0
mov [run_file_70.Flags], 0
mov [run_file_70.Count], dword size
m2m [run_file_70.Buffer], [buf]
mov byte[run_file_70+20], 0
mov [run_file_70.FileName], file_name
mov ebx,run_file_70
int 0x40 ;§ £à㦠¥¬ ä ©« ¨§®¡à ¦¥­¨ï
cmp ebx,0xffffffff
je @f
;®¯à¥¤¥«ï¥¬ ¢¨¤ ¨§®¡à ¦¥­¨ï ¨ ¯¥à¥¢®¤¨¬ ¥£® ¢® ¢à¥¬¥­­ë© ¡ãä¥à image_data
stdcall dword[img_decode], dword[buf],ebx,0
mov dword[image_data],eax
;¯à¥®¡à §ã¥¬ ¨§®¡à ¦¥­¨¥ ª ä®à¬ âã rgb
stdcall dword[img_to_rgb2], dword[image_data],dword[buf]
;㤠«ï¥¬ ¢à¥¬¥­­ë© ¡ãä¥à image_data
stdcall dword[img_destroy], dword[image_data]
@@:
}
align 4
start:
load_libraries l_libs_start,l_libs_end
;¯à®¢¥àª  ­  ᪮«ìª® 㤠筮 § £ã§¨« áì ¡¨¡«¨®â¥ª 
mov ebp,lib_7
cmp dword [ebp+ll_struc_size-4],0
jz @f
mcall -1 ;exit not correct
@@:
mcall 48,3,sc,sizeof.system_colors
mcall 40,0x27
stdcall [OpenDialog_Init],OpenDialog_data ;¯®¤£®â®¢ª  ¤¨ «®£ 
stdcall [buf2d_create], buf_0 ;ᮧ¤ ­¨¥ ¡ãä¥à 
load_image_file 'toolbar.png', image_data_toolbar,IMAGE_TOOLBAR_SIZE
stdcall pole_init, pole
stdcall dword[tl_data_init], tree1
;á¨á⥬­ë¥ ¨ª®­ª¨ 16*16 ¤«ï tree_list
load_image_file 'tl_sys_16.png', icon_tl_sys,TREE_ICON_SYS16_BMP_SIZE
;¥á«¨ ¨§®¡à ¦¥­¨¥ ­¥ ®âªàë«®áì, â® ¢ icon_tl_sys ¡ã¤ãâ
;­¥ ¨­¨æ¨ «¨§¨à®¢ ­­ë¥ ¤ ­­ë¥, ­® ®è¨¡ª¨ ­¥ ¡ã¤¥â, â. ª. ¡ãä¥à ­ã¦­®£® à §¬¥à 
mov eax,dword[icon_tl_sys]
mov dword[tree1.data_img_sys],eax
load_image_file 'objects.png', icon_toolbar,TOOLBAR_ICON_BMP_SIZE
mov eax,dword[icon_toolbar]
mov dword[tree1.data_img],eax
load_image_file 'font6x9.bmp', image_data_gray,IMAGE_FONT_SIZE
stdcall [buf2d_create_f_img], buf_font,[image_data_gray] ;ᮧ¤ ¥¬ ¡ãä¥à
stdcall mem.Free,[image_data_gray] ;®á¢®¡®¦¤ ¥¬ ¯ ¬ïâì
stdcall [buf2d_conv_24_to_8], buf_font,1 ;¤¥« ¥¬ ¡ãä¥à ¯à®§à ç­®á⨠8 ¡¨â
stdcall [buf2d_convert_text_matrix], buf_font
stdcall sign_init, 3000
mcall 26,9
mov [last_time],eax
align 4
red_win:
call draw_window
align 4
still:
mcall 26,9
mov ebx,[last_time]
add ebx,10 ;§ ¤¥à¦ª 
cmp ebx,eax
jge @f
mov ebx,eax
@@:
sub ebx,eax
;cmp ebx,10 ;§ ¤¥à¦ª 
;ja timer_funct
;test ebx,ebx
;jz timer_funct
mcall 23
cmp eax,0
je timer_funct
cmp al,1
jz red_win
cmp al,EV_KEY
jz key
cmp al,3
jz button
cmp al,EV_MOUSE
jne @f
call mouse
@@:
jmp still
align 4
timer_funct:
pushad
mcall 26,9
mov [last_time],eax
cmp byte[tim_ch],0
je @f
inc dword[time]
call sign_move
mov eax,[time]
and eax,11b ;ªà â­®áâì 4-¬
jnz @f
call sign_from_elems
call sign_from_captions
@@:
popad
jmp still
align 4
mouse:
stdcall [tl_mouse], tree1
push eax ebx ecx edx
mcall 37,2 ;­ ¦ âë¥ ª­®¯ª¨ ¬ëè¨
bt eax,0 ;«¥¢ ï ª­®¯ª  ­ ¦ â ?
jnc .end_buf_wnd
mcall 37,1 ;eax = (x shl 16) + y
cmp ax,word[buf_0.t]
jl .end_buf_wnd ;­¥ ¯®¯ «¨ ¢ ®ª­® ¡ãä¥à  ¯® ®á¨ y
mov ebx,eax
shr ebx,16
cmp bx,word[buf_0.l]
jl .end_buf_wnd ;­¥ ¯®¯ «¨ ¢ ®ª­® ¡ãä¥à  ¯® ®á¨ x
and eax,0xffff ;®áâ ¢«ï¥¬ ª®®à¤¨­ âã y
sub ax,word[buf_0.t]
sub bx,word[buf_0.l]
;*** ¤¥«¥­¨¥ ­  zoom
movzx ecx,byte[zoom]
xor edx,edx
div ecx
xchg eax,ebx ;ebx ¤¥«¨¬ ­  ecx
xor edx,edx
div ecx
sub eax,[Cor_x]
sub ebx,[Cor_y]
;*** ¯à®¢¥àª  ­  ¯®¯ ¤¥­¨¥ ¢ á奬ã
bt eax,31
jc .end_buf_wnd
bt ebx,31
jc .end_buf_wnd
cmp eax,[shem_w]
jge .end_buf_wnd
cmp ebx,[shem_h]
jge .end_buf_wnd
cmp byte[pen_mode],1
jne @f
;०¨¬ à¨á®¢ ­¨ï ¯à®¢®¤ 
stdcall pole_cell_creat, pole,eax,ebx,0
;­¨ç¥£® ­¥ ã¡à «®áì redraw_pole ­¥ ¯®¤å®¤¨â, â. ª. ç¨áâ¨âì ¯®«¥ ­¥ ­ã¦­®
stdcall pole_paint, pole
stdcall [buf2d_draw], buf_0
;stdcall but_test_pole, pole
jmp .end_buf_wnd
@@:
cmp byte[pen_mode],2
jne @f
;०¨¬ à¨á®¢ ­¨ï ¨§®«ï樨 ¤«ï ¯à®¢®¤ 
stdcall pole_cell_creat, pole,eax,ebx,2
stdcall pole_paint, pole
stdcall [buf2d_draw], buf_0
;stdcall but_test_pole, pole
jmp .end_buf_wnd
@@:
cmp byte[pen_mode],3
jne @f
;०¨¬ áâ¨à ­¨ï ¯à®¢®¤ 
stdcall pole_cell_delete, pole,eax,ebx
call redraw_pole
;stdcall but_test_pole, pole
jmp .end_buf_wnd
@@:
.end_buf_wnd:
pop edx ecx ebx eax
ret
align 4
draw_window:
pushad
mcall 12,1
; *** à¨á®¢ ­¨¥ £« ¢­®£® ®ª­  (¢ë¯®«­ï¥âáï 1 à § ¯à¨ § ¯ã᪥) ***
xor eax,eax
mov ebx,(20 shl 16)+520
mov ecx,(20 shl 16)+415
mov edx,[sc.work]
or edx,(3 shl 24)+0x10000000+0x20000000
mov edi,caption
int 0x40
; *** ᮧ¤ ­¨¥ ª­®¯®ª ­  ¯ ­¥«ì ***
mov eax,8
mov ebx,(5 shl 16)+20
mov ecx,(panel_0_coord_top shl 16)+20
mov edx,3
mov esi,[sc.work_button]
int 0x40
mov ebx,(30 shl 16)+20
mov edx,4
int 0x40
mov ebx,(55 shl 16)+20
mov edx,5
int 0x40
mov ebx,(85 shl 16)+20
mov edx,6
int 0x40
mov ebx,(110 shl 16)+20
mov edx,7
int 0x40
mov ebx,(135 shl 16)+20
mov edx,8
int 0x40
mov ebx,(160 shl 16)+20
mov edx,9
int 0x40
mov ebx,(185 shl 16)+20
mov edx,10
int 0x40
mov ebx,(210 shl 16)+20
mov edx,11
int 0x40
mov ebx,(235 shl 16)+20
mov edx,12
int 0x40
mov ebx,(265 shl 16)+20
mov edx,13
int 0x40
; *** à¨á®¢ ­¨¥ ¨ª®­®ª ­  ª­®¯ª å ***
mov eax,7
mov ebx,[image_data_toolbar]
mov ecx,(16 shl 16)+16
mov edx,(7 shl 16)+panel_0_coord_top+2 ;icon new
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;icon open
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;icon save
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(30 shl 16) ;+
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;-
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;m
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;m
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;m
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;m
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(30 shl 16) ;center
int 0x40
; *** à¨á®¢ ­¨¥ ¡ãä¥à  ***
stdcall [buf2d_draw], buf_0
mov dword[wScrObj.all_redraw],1
stdcall [tl_draw], tree1
stdcall pole_draw_pok, pole
; *** ᮧ¤ ­¨¥ ª­®¯®ª ãáâ ­®¢ª¨ ᨣ­ «®¢ set_0 ¨ set_1 ***
mov eax,8
mov ebx,(5 shl 16)+20
mov ecx,(panel_1_coord_top shl 16)+20
mov edx,20
mov esi,[sc.work_button]
int 0x40
add ebx,25 shl 16
mov edx,21
int 0x40
add ebx,30 shl 16
mov edx,22
int 0x40
add ebx,25 shl 16
mov edx,23
int 0x40
add ebx,25 shl 16
mov edx,24
int 0x40
add ebx,25 shl 16
mov edx,25
int 0x40
mov eax,4 ;à¨á®¢ ­¨¥ ⥪áâ 
mov ebx,(10 shl 16)+panel_1_coord_top+5
mov ecx,[sc.work_text]
or ecx,0x80000000 ;or (1 shl 30)
mov edx,txt_set_0
;mov edi,[sc.work]
int 0x40
add ebx,25 shl 16
mov edx,txt_set_1
int 0x40
add ebx,35 shl 16
mov edx,txt_mov_l
int 0x40
add ebx,25 shl 16
mov edx,txt_mov_r
int 0x40
; *** ᮧ¤ ­¨¥ ª­®¯®ª à¨á®¢ ­¨ï ¯à®¢®¤  ***
mov eax,8
mov ebx,(5 shl 16)+20
mov ecx,(panel_2_coord_top shl 16)+20
mov edx,30
mov esi,[sc.work_button]
int 0x40
add ebx,25 shl 16
mov edx,31
int 0x40
add ebx,25 shl 16
mov edx,32
int 0x40
add ebx,25 shl 16
mov edx,33
int 0x40
; *** à¨á®¢ ­¨¥ ¨ª®­®ª ­  ª­®¯ª å ***
mov eax,7
mov ebx,[image_data_toolbar]
mov ecx,(16 shl 16)+16
mov edx,(7 shl 16)+panel_2_coord_top+2 ;¨ª®­ª  áâ५ 
add ebx,IMAGE_TOOLBAR_ICON_SIZE*11
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;icon pen 1
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;icon pen 2
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;icon pen 3
int 0x40
mcall 12,2
popad
ret
align 4
key:
mcall 2
stdcall [tl_key], dword tree1
jmp still
align 4
button:
mcall 17
cmp ah,3
jne @f
call but_new_file
@@:
cmp ah,4
jne @f
call but_open_file
@@:
cmp ah,5
jne @f
call but_save_file
@@:
cmp ah,6
jne @f
call but_run_stop
@@:
cmp ah,7
jne @f
call but_zoom_p
@@:
cmp ah,8
jne @f
call but_zoom_m
@@:
cmp ah,9
jne @f
call but_pole_left
@@:
cmp ah,10
jne @f
call but_pole_right
@@:
cmp ah,11
jne @f
call but_pole_up
@@:
cmp ah,12
jne @f
call but_pole_dn
@@:
cmp ah,13
jne @f
call but_center
@@:
cmp ah,20
jne @f
call but_set_0
@@:
cmp ah,21
jne @f
call but_set_1
@@:
cmp ah,22
jne @f
call but_mov_l
@@:
cmp ah,23
jne @f
call but_mov_r
@@:
cmp ah,24
jne @f
call but_mov_u
@@:
cmp ah,25
jne @f
call but_mov_d
@@:
cmp ah,30
jne @f
call but_set_none
@@:
cmp ah,31
jne @f
call but_set_pen_1
@@:
cmp ah,32
jne @f
call but_set_pen_2
@@:
cmp ah,33
jne @f
call but_set_pen_3
@@:
cmp ah,1
jne still
.exit:
stdcall [buf2d_delete],buf_0
stdcall [buf2d_delete],buf_font
stdcall mem.Free,[image_data_toolbar]
stdcall pole_delete, pole
call sign_delete
stdcall [tl_data_clear], tree1
mcall -1
align 4
but_new_file:
stdcall pole_clear, pole
call redraw_pole
ret
align 4
f_size dd 0 ;à §¬¥à ®âªà뢠¥¬®£® ä ©« 
shem_w dd 192 ;è¨à¨­  á奬ë
shem_h dd 128 ;¢ëá®â  á奬ë
shem_points dd 0 ;ª®««¨ç¥á⢮ 㧫®¢ ­  á奬¥
shem_sub_points dd 0 ;ª®««¨ç¥á⢮ ¨§®«¨à®¢ ­­ëå 㧫®¢ ­  á奬¥
shem_elems dd 0 ;ª®««¨ç¥á⢮ í«¥¬¥­â®¢ ­  á奬¥
shem_captions dd 0
shem_colors:
dd color_s0, color_s1, color_s2, color_s3
align 4
open_file_lif:
rb 2*4096 ;®¡« áâì ¤«ï ®âªàëâ¨ï ä ©«®¢
.end:
align 4
but_open_file:
pushad
copy_path open_dialog_name,communication_area_default_path,file_name,0
mov [OpenDialog_data.type],0
stdcall [OpenDialog_Start],OpenDialog_data
cmp [OpenDialog_data.status],2
je .end_open_file
;ª®¤ ¯à¨ 㤠筮¬ ®âªàë⨨ ¤¨ «®£ 
mov eax,70 ;70-ï äã­ªæ¨ï à ¡®â  á ä ©« ¬¨
mov [run_file_70.Function], 0
mov [run_file_70.Position], 0
mov [run_file_70.Flags], 0
mov dword[run_file_70.Count], open_file_lif.end-open_file_lif
m2m [run_file_70.Buffer], open_file_lif
mov byte[run_file_70+20], 0
mov dword[run_file_70.FileName], openfile_path
mov ebx,run_file_70
int 0x40 ;§ £à㦠¥¬ ä ©«
cmp ebx,0xffffffff
je .end_open_file
mov dword[f_size],ebx
add ebx,open_file_lif
mov byte[ebx],0 ;­  á«ãç © ¥á«¨ à ­¥¥ ¡ë« ®âªàëâ ä ©« ¡®«ì襣® à §¬¥à  ç¨á⨬ ª®­¥æ ¡ãä¥à  á ä ©«®¬
mcall 71,1,openfile_path
;---
;§ ¤ ¥¬ ¬¨­¨¬ «ì­ë¥ §­ ç¥­¨ï, ­  á«ãç © ¥á«¨ ¢ ä ©«¥ ¡ã¤ãâ ­¥ª®à¥ªâ­ë¥ à §¬¥àë
mov dword[shem_w],5
mov dword[shem_h],5
mov esi,txt_size
call str_analiz_r
cmp edi,0
je @f
stdcall str_len,esi
add edi,eax
stdcall conv_str_to_int,edi
cmp eax,5
jl @f ;®è¨¡ª  ¢ ä ©«¥ (­  .end_open_file ­¥ ¯¥à¥å®¤¨¬, ¯ëâ ¥¬áï ¯à®ç¨â âì ¤àã£ãî ¨­ä®à¬ æ¨î)
mov dword[shem_w],eax
call str_next_val
stdcall conv_str_to_int,edi
cmp eax,5
jl @f ;®è¨¡ª  ¢ ä ©«¥
mov dword[shem_h],eax
@@:
stdcall [tl_info_clear],tree1
;*** ¤®¡ ¢«¥­¨¥ ¢ ᯨ᮪ «®£¨ç¥áª¨å í«¥¬¥­â®¢ ***
stdcall [tl_node_add], txt_elements-capt_offs,(el_icon_group shl 16), tree1
stdcall [tl_cur_next], tree1
mov esi,txt_elements
call str_analiz_r
cmp edi,0
je .end_elems
stdcall str_len,esi
add edi,eax
stdcall conv_str_to_int,edi
cmp eax,0
jle .end_elems ;¥á«¨ ç¨á«® í«¥¬¥­â®¢ = 0
mov [shem_elems],eax
mov ecx,eax
.cycle_elem:
call str_next_val
stdcall conv_str_to_int,edi
mov dword[txt_buf],eax ;ª®®à¤¨­ â  x
call str_next_val
stdcall conv_str_to_int,edi
mov dword[txt_buf+4],eax ;ª®®à¤¨­ â  y
call str_next_val
stdcall conv_str_to_int,edi
mov byte[txt_buf+8],al ;­ ¯à ¢«¥­¨¥
call str_next_val
;¯®  ¤à¥áã edi ­ §¢ ­¨¥ í«¥¬¥­â 
stdcall el_get_name, edi
mov byte[txt_buf+sp_offs_el_type],al ;⨯ í«¥¬¥­â 
stdcall make_list_capts,txt_buf,edi
stdcall [tl_node_add], txt_buf,(el_icon_elems shl 16)+1, tree1
stdcall [tl_cur_next], tree1
dec ecx
jnz .cycle_elem
.end_elems:
;*** ¤®¡ ¢«¥­¨¥ ¢ ᯨ᮪ ⥪á⮢ëå ¯®¤¯¨á¥© ***
stdcall [tl_node_add], txt_captions-capt_offs,(el_icon_group shl 16), tree1
stdcall [tl_cur_next], tree1
mov esi,txt_captions
call str_analiz_r
cmp edi,0
je .end_captions
stdcall str_len,esi
add edi,eax
stdcall conv_str_to_int,edi
cmp eax,0
jle .end_captions ;¥á«¨ ç¨á«® ¯®¤¯¨á¥© = 0
mov [shem_captions],eax
mov ecx,eax
.cycle_captions:
call str_next_val
stdcall conv_str_to_int,edi
mov dword[txt_buf],eax ;ª®®à¤¨­ â  x
call str_next_val
stdcall conv_str_to_int,edi
mov dword[txt_buf+4],eax ;ª®®à¤¨­ â  y
call str_next_val
mov al,byte[edi]
mov byte[txt_buf+8],al ;¢¨¤ ¯®¤¯¨á¨ ('z' - ᨣ­ « á 0, 'o' - ᨣ­ « á 1, 'n' - ­¥â ᨣ­ « )
call str_next_val
stdcall make_list_capts,txt_buf,edi
stdcall [tl_node_add], txt_buf,(el_icon_captions shl 16)+1, tree1
stdcall [tl_cur_next], tree1
dec ecx
jnz .cycle_captions
.end_captions:
mov byte[txt_buf+capt_offs],0 ;®¡­ã«¥­¨¥ ¯®¤¯¨á¥©
;*** ¤®¡ ¢«¥­¨¥ ¢ ᯨ᮪ ª«î祢ëå â®ç¥ª ***
stdcall [tl_node_add], txt_points-capt_offs,(el_icon_group shl 16), tree1
stdcall [tl_cur_next], tree1
mov dword[shem_points],0
mov esi,txt_points
call str_analiz_r
cmp edi,0
je .end_points ;¥á«¨ ®¯¨á ­¨ï â®ç¥ª ­¥â ¢ ä ©«¥
stdcall str_len,esi
add edi,eax
stdcall conv_str_to_int,edi
cmp eax,0
jle .end_points ;¥á«¨ ç¨á«® â®ç¥ª = 0
mov [shem_points],eax
mov ecx,eax
.cycle_poi:
call str_next_val
stdcall conv_str_to_int,edi
mov dword[txt_buf],eax ;ª®®à¤¨­ â  x
call str_next_val
stdcall conv_str_to_int,edi
mov dword[txt_buf+4],eax ;ª®®à¤¨­ â  y
call str_next_val
stdcall conv_str_to_int,edi
mov byte[txt_buf+8],al ;­ ¯à ¢«¥­¨ï
; stdcall make_list_capts,txt_buf,0
stdcall [tl_node_add], txt_buf,(el_icon_points shl 16)+1, tree1
stdcall [tl_cur_next], tree1
dec ecx
jnz .cycle_poi
.end_points:
stdcall [tl_cur_beg], tree1
;*** ¤®¡ ¢«¥­¨¥ â®ç¥ç­ëå ®¡ê¥ªâ®¢ ***
stdcall pole_clear, pole
stdcall dword[tl_node_poi_get_info],0,tree1
pop esi
@@:
cmp esi,0
je @f
cmp word[esi],el_icon_points ;¯®«ã祭¨¥ ç¥à¥§ esi ⨯ ¨ª®­ª¨, ¨ ¯à®¯ã᪠­¥ â®ç¥ç­ëå ®¡ê¥ªâ®¢
jne .end_add_p0
stdcall [tl_node_poi_get_data], esi, tree1
pop eax
stdcall pole_cell_creat, pole,dword[eax],dword[eax+4],0
.end_add_p0:
stdcall dword[tl_node_poi_get_next_info],esi,tree1
pop esi ;¯¥à¥å®¤¨¬ ª á«¥¤ã饬ã 㧫ã
jmp @b
@@:
stdcall pole_sort, pole
;*** ¤®¡ ¢«¥­¨¥ â®ç¥ç­ëå ®¡ê¥ªâ®¢ (­  ®á­®¢¥ «®£¨ç¥áª¨å í«¥¬¥­â®¢) ***
stdcall dword[tl_node_poi_get_info],0,tree1
pop esi
@@:
cmp esi,0
je @f
cmp word[esi],el_icon_elems ;¯®«ã祭¨¥ ç¥à¥§ esi ⨯ ¨ª®­ª¨
jne .end_add_p3
stdcall [tl_node_poi_get_data], esi, tree1
pop ecx
xor edx,edx ;edx - ­®¬¥à ¢å®¤­®© ­®£¨
.add_p1:
stdcall el_get_leg_coords, ecx,edx
test eax,eax
jnz .add_beg1
test ebx,ebx
jnz .add_beg1
jmp .end_add_p1 ;¥á«¨ ª®®à¤¨­ âë ­¥ ¢§ï«¨áì (eax=0 && ebx=0), ¢ë室 ¨§ 横« 
.add_beg1:
stdcall pole_cell_creat, pole,eax,ebx,0
inc edx
jmp .add_p1
.end_add_p1:
mov edx,(1 shl 16) ;edx - ­®¬¥à ¢ë室­®© ­®£¨
.add_p2:
stdcall el_get_leg_coords, ecx,edx
test eax,eax
jnz .add_beg2
test ebx,ebx
jnz .add_beg2
jmp .end_add_p2 ;¥á«¨ ª®®à¤¨­ âë ­¥ ¢§ï«¨áì (eax=0 && ebx=0), ¢ë室 ¨§ 横« 
.add_beg2:
stdcall pole_cell_creat, pole,eax,ebx,0
inc edx
jmp .add_p2
.end_add_p2:
.end_add_p3:
stdcall dword[tl_node_poi_get_next_info],esi,tree1
pop esi ;¯¥à¥å®¤¨¬ ª á«¥¤ã饬ã 㧫ã
jmp @b
@@:
stdcall pole_sort, pole
;*** ¤®¡ ¢«¥­¨¥ â®ç¥ç­ëå ®¡ê¥ªâ®¢ (­  ®á­®¢¥ ¯®¤¯¨á¥©) ***
stdcall dword[tl_node_poi_get_info],0,tree1
pop esi
@@:
cmp esi,0
je @f
cmp word[esi],el_icon_captions ;¯®«ã祭¨¥ ç¥à¥§ esi ⨯ ¨ª®­ª¨
jne .end_add_p6
stdcall [tl_node_poi_get_data], esi, tree1
pop ecx
cmp byte[ecx+8],'n'
je .end_add_p6
stdcall pole_cell_creat, pole,[ecx],[ecx+4],0
.end_add_p6:
stdcall dword[tl_node_poi_get_next_info],esi,tree1
pop esi ;¯¥à¥å®¤¨¬ ª á«¥¤ã饬ã 㧫ã
jmp @b
@@:
stdcall pole_sort, pole
;*** à¨á®¢ ­¨¥ ¯à®¢®¤®¢ (­  ®á­®¢¥ â®ç¥ç­ëå ®¡ê¥ªâ®¢) ***
stdcall dword[tl_node_poi_get_info],0,tree1
pop esi
xor ecx,ecx
@@:
cmp esi,0
je @f
cmp word[esi],el_icon_points ;¯®«ã祭¨¥ ç¥à¥§ esi ⨯ ¨ª®­ª¨, ¨ ¯à®¯ã᪠­¥ â®ç¥ç­ëå ®¡ê¥ªâ®¢
jne .end_add_p4
stdcall [tl_node_poi_get_data], esi, tree1
pop eax
movzx ebx,byte[eax+8]
stdcall shem_create_line, dword[eax],dword[eax+4],ebx
add ecx,edx
.end_add_p4:
stdcall dword[tl_node_poi_get_next_info],esi,tree1
pop esi ;¯¥à¥å®¤¨¬ ª á«¥¤ã饬ã 㧫ã
cmp ecx,250 ;ecx - ç¨á«® ¤®¡ ¢«¥­­ëå â®ç¥ª
jl @b
xor ecx,ecx
stdcall pole_sort, pole ;á®àâ¨à㥬 ¤«ï ®¯â¨¬¨§ æ¨¨ ¡ëáâத¥©á⢨ï
jmp @b
@@:
stdcall pole_sort, pole
stdcall pole_reset_cells, pole ;ç¨á⪠ ¯à®¢®¤®¢
;*** ¤®¡ ¢«¥­¨¥ ¨§®«ï樮­­ëå ®¡ê¥ªâ®¢ (¯àאַ ¨§ ä ©« , ¬¨­ãï § ¯¨áì ¢ ᯨ᮪) ***
mov dword[shem_sub_points],0
mov esi,txt_sub_points
call str_analiz_r
cmp edi,0
je .end_sub_points ;¥á«¨ ®¯¨á ­¨ï â®ç¥ª ­¥â ¢ ä ©«¥
stdcall str_len,esi
add edi,eax
stdcall conv_str_to_int,edi
cmp eax,0
jle .end_sub_points ;¥á«¨ ç¨á«® â®ç¥ª = 0
mov [shem_sub_points],eax
mov ecx,eax
.cycle_sub_poi:
call str_next_val
stdcall conv_str_to_int,edi
mov ebx,eax ;ª®®à¤¨­ â  x
call str_next_val
stdcall conv_str_to_int,edi ;ª®®à¤¨­ â  y
stdcall pole_cell_creat, pole,ebx,eax,2
dec ecx
jnz .cycle_sub_poi
.end_sub_points:
stdcall pole_sort, pole
;*** 㤠«¥­¨¥ ª«î祢ëå â®ç¥ª ᮠᯨ᪠ ***
mov ecx,[shem_points]
inc ecx
cld
@@:
stdcall [tl_info_undo],tree1
loop @b
;*** ä®à¬¨à®¢ ­¨¥ ¯®¤¯¨á¥© ® ¯ à ¬¥âà å á奬ë ***
mov dword[txt_info.size],0
mov eax,dword[shem_w]
mov edi,txt_info.size
call convert_int_to_str
stdcall str_cat, edi,txt_mull
mov eax,dword[shem_h]
mov edi,txt_buf
call convert_int_to_str
stdcall str_cat, txt_info.size,edi
stdcall str_cat, txt_info.size,txt_space ;§ ¢¥àè î騩 ¯à®¡¥«
;---
call but_center ;業â஢ª  á奬ë á ãç¥â®¬ shem_w ¨ shem_h
.end_open_file:
popad
ret
align 4
proc but_save_file
locals
napr dd ?
endl
pushad
;*** ¢ë§®¢ ¤¨ «®£®¢®£® ®ª­  ¤«ï á®åà ­¥­¨ï ä ©« 
copy_path open_dialog_name,communication_area_default_path,file_name,0
mov [OpenDialog_data.type],1
stdcall [OpenDialog_Start],OpenDialog_data
cmp [OpenDialog_data.status],1 ;if status==1 then save
jne .end_save_file
;*** ¯à®¢¥àª  ¥áâì «¨ ¯à®¢®¤  ­  á奬¥
mov edi,pole
mov esi,pole_index
cmp dword[esi],0
je .cycle1_beg ;.end_save_file ;¥á«¨ ­¥â ï祥ª (¯à®¢®¤®¢) â® ¢ë室
;*** ãáâ ­ ¢«¨¢ ¥¬ ¬¥âª¨ ­  ª«îç¥¢ë¥ â®çª¨, ª®â®àë¥ ¡ã¤ãâ á®åà ­¥­ë ¢ ä ©«
mov dword[shem_points],0 ;¤«ï ¯¥à¥®¯à¥¤¥«¥­¨ï â®ç¥ª
mov dword[shem_sub_points],0
mov ecx,dword[esi]
.cycle0: ;横« ¯® ¢á¥¬ â®çª ¬
add esi,4
mov ebx,[esi]
imul ebx,sizeof.Cell
add ebx,pole_data
cmp byte[ebx+offs_cell_liv],2
jne @f
inc dword[shem_sub_points]
jmp .cycle0_next
@@:
mov dword[napr],0
mov edx,[ebx+offs_cell_y]
push edx
mov edx,[ebx+offs_cell_x]
inc edx
push edx
stdcall pole_cell_find, edi
cmp eax,0
je @f
or dword[napr],1
@@:
mov edx,[ebx+offs_cell_y]
inc edx
push edx
mov edx,[ebx+offs_cell_x]
push edx
stdcall pole_cell_find, edi
cmp eax,0
je @f
or dword[napr],2
@@:
mov edx,[ebx+offs_cell_y]
push edx
mov edx,[ebx+offs_cell_x]
dec edx
push edx
stdcall pole_cell_find, edi
cmp eax,0
je @f
or dword[napr],4
@@:
mov edx,[ebx+offs_cell_y]
dec edx
push edx
mov edx,[ebx+offs_cell_x]
push edx
stdcall pole_cell_find, edi
cmp eax,0
je @f
or dword[napr],8
@@:
cmp dword[napr],5
je @f
cmp dword[napr],10
je @f
cmp dword[napr],15
je @f
mov eax,dword[napr]
mov byte[ebx+offs_cell_liv],3 ;ãáâ ­®¢ª  ¬¥âª¨
mov byte[ebx+offs_cell_napr],al ;ãáâ ­®¢ª  ­ ¯à ¢«¥­¨©
inc dword[shem_points]
@@:
.cycle0_next:
dec ecx
jnz .cycle0
;*** á­ï⨥ ¬¥âª¨ á â®ç¥ª, ª®â®àë¥ ­ å®¤ïâáï ­  ¢å®¤­ëå ­®£ å «®£¨ç¥áª¨å í«¥¬¥­â®¢
.cycle1_beg:
mov dword[shem_elems],0 ;¤«ï ¯¥¯¥®¯à¥¤¥«¥­¨ï ç¨á«  í«¥¬¥­â®¢
stdcall dword[tl_node_poi_get_info],0,tree1
pop esi
.cycle1:
cmp esi,0
je .cycle1_end
cmp word[esi],el_icon_elems ;¯®«ã祭¨¥ ç¥à¥§ esi ⨯ ¨ª®­ª¨
jne .end_add_p1
stdcall [tl_node_poi_get_data], esi, tree1
pop ecx
inc dword[shem_elems]
xor edx,edx ;edx - ­®¬¥à ¢å®¤­®© ­®£¨
@@:
stdcall el_get_leg_coords, ecx,edx
test eax,eax
jz @f ;¥á«¨ ª®®à¤¨­ âë ­¥ ¢§ï«¨áì (eax=0 && ebx=0)
test ebx,ebx
jz @f ;¥á«¨ ª®®à¤¨­ âë ­¥ ¢§ï«¨áì (eax=0 && ebx=0)
stdcall pole_cell_find, edi,eax,ebx
test eax,eax
jz .no_erase
get_cell_offset ebx,eax
mov byte[ebx+offs_cell_liv],0 ;á­ï⨥ ¬¥âª¨
dec dword[shem_points]
.no_erase:
inc edx
jmp @b
@@:
;mov edx,(1 shl 16) ;edx - ­®¬¥à ¢ë室­®© ­®£¨
.end_add_p1:
stdcall dword[tl_node_poi_get_next_info],esi,tree1
pop esi ;¯¥à¥å®¤¨¬ ª á«¥¤ã饬ã 㧫ã
jmp .cycle1
.cycle1_end:
;*** ᮧ¤ ­¨¥ ¨­ä®à¬ æ¨¨ ¤«ï § ¯¨á¨ ¢ ä ©« ***
mov edi,open_file_lif
stdcall mem_copy,edi,txt_size,5
stdcall str_cat,edi,txt_space
mov eax,dword[shem_w]
add edi,5
stdcall convert_int_to_str
stdcall str_cat,edi,txt_space
stdcall str_len,edi
add edi,eax
mov eax,[shem_h]
stdcall convert_int_to_str
stdcall str_cat,edi,txt_nl
;*** á®åà ­¥­¨¥ «®£¨ç¥áª¨å í«¥¬¥­â®¢ ***
stdcall str_cat,edi,txt_elements
stdcall str_cat,edi,txt_space
stdcall str_len,edi
add edi,eax
mov eax,[shem_elems]
stdcall convert_int_to_str
stdcall str_cat,edi,txt_nl
cmp eax,1
jl .cycle2_end
stdcall dword[tl_node_poi_get_info],0,tree1
pop esi
.cycle2:
cmp esi,0
je .cycle2_end
cmp word[esi],el_icon_elems ;¯®«ã祭¨¥ ç¥à¥§ esi ⨯ ¨ª®­ª¨
jne .end_add_p2
stdcall [tl_node_poi_get_data], esi, tree1
pop ecx
stdcall str_len,edi
add edi,eax
mov eax,[ecx] ;coord x
stdcall convert_int_to_str
stdcall str_cat,edi,txt_space
stdcall str_len,edi
add edi,eax
mov eax,[ecx+4] ;coord y
stdcall convert_int_to_str
stdcall str_cat,edi,txt_space
stdcall str_len,edi
add edi,eax
movzx eax,byte[ecx+8] ;angle
stdcall convert_int_to_str
stdcall str_cat,edi,txt_space
;¨¬ï í«¥¬¥­â 
movzx eax,byte[ecx+sp_offs_el_type]
imul eax,size_el_opt
add eax,el_opt_beg+el_offs_nam
stdcall str_cat,edi,eax
stdcall str_cat,edi,txt_nl
.end_add_p2:
stdcall dword[tl_node_poi_get_next_info],esi,tree1
pop esi ;¯¥à¥å®¤¨¬ ª á«¥¤ã饬ã 㧫ã
jmp .cycle2
.cycle2_end:
;*** á®åà ­¥­¨¥ ¯®¤¯¨á¥© ***
stdcall str_cat,edi,txt_captions
stdcall str_cat,edi,txt_space
stdcall str_len,edi
add edi,eax
mov eax,[shem_captions]
stdcall convert_int_to_str
stdcall str_cat,edi,txt_nl
cmp eax,1
jl .cycle3_end
stdcall dword[tl_node_poi_get_info],0,tree1
pop esi
.cycle3:
cmp esi,0
je .cycle3_end
cmp word[esi],el_icon_captions ;¯®«ã祭¨¥ ç¥à¥§ esi ⨯ ¨ª®­ª¨
jne .end_add_p3
stdcall [tl_node_poi_get_data], esi, tree1
pop ecx
stdcall str_len,edi
add edi,eax
mov eax,[ecx] ;coord x
stdcall convert_int_to_str
stdcall str_cat,edi,txt_space
stdcall str_len,edi
add edi,eax
mov eax,[ecx+4] ;coord y
stdcall convert_int_to_str
stdcall str_cat,edi,txt_space
stdcall str_len,edi
add edi,eax
movzx eax,byte[ecx+8] ;n,z,o
mov ah,' ' ;¯à®¡¥« ¯®á«¥ ¡ãª¢ë, çâ® ¡ë ­¥ ¤®¡ ¢«ïâì txt_space
mov dword[edi],eax ;al
;¨¬ï í«¥¬¥­â 
mov ebx,edi
mov edi,ecx
add edi,capt_offs
call str_next_val
call str_next_val
;call str_next_val
xchg ebx,edi
stdcall str_cat,edi,ebx
stdcall str_cat,edi,txt_nl
.end_add_p3:
stdcall dword[tl_node_poi_get_next_info],esi,tree1
pop esi ;¯¥à¥å®¤¨¬ ª á«¥¤ã饬ã 㧫ã
jmp .cycle3
.cycle3_end:
;*** á®åà ­¥­¨¥ ª«î祢ëå â®ç¥ª ***
stdcall str_cat,edi,txt_points
stdcall str_cat,edi,txt_space
stdcall str_len,edi
add edi,eax
mov eax,[shem_points]
stdcall convert_int_to_str
stdcall str_cat,edi,txt_nl
mov eax,edi
mov edi,pole
mov esi,pole_index
cmp dword[esi],0
je .no_points ;¥á«¨ ­¥â ï祥ª (¯à®¢®¤®¢) â® ¯à®¯ãáª
mov ebx,pole_data
mov dword[napr],ebx
mov edi,eax
mov ecx,dword[esi]
.cycle4: ;横« ¯® ¢á¥¬ â®çª ¬
add esi,4
mov ebx,[esi]
imul ebx,sizeof.Cell
add ebx,dword[napr] ;pole_data
movzx edx,word[ebx+offs_cell_liv] ;also use offs_cell_napr
cmp dl,3
jne @f
stdcall str_len,edi
add edi,eax
mov eax,dword[ebx+offs_cell_x]
stdcall convert_int_to_str
stdcall str_cat,edi,txt_space
stdcall str_len,edi
add edi,eax
mov eax,dword[ebx+offs_cell_y]
stdcall convert_int_to_str
stdcall str_cat,edi,txt_space
stdcall str_len,edi
add edi,eax
movzx eax,dh
stdcall convert_int_to_str
stdcall str_cat,edi,txt_space
;stdcall str_cat,edi,txt_nl
@@:
dec ecx
jnz .cycle4
stdcall str_cat,edi,txt_nl
;*** á®åà ­¥­¨¥ ¨§®«ï樮­­ëå â®ç¥ª ***
stdcall str_cat,edi,txt_sub_points
stdcall str_cat,edi,txt_space
stdcall str_len,edi
add edi,eax
mov eax,[shem_sub_points]
stdcall convert_int_to_str
stdcall str_cat,edi,txt_nl
mov eax,edi
mov edi,pole
mov esi,pole_index
;cmp dword[esi],0
;je .no_points ;¥á«¨ ­¥â ï祥ª (¯à®¢®¤®¢) â® ¯à®¯ãáª
;mov ebx,pole_data
;mov dword[napr],ebx
mov edi,eax
mov ecx,dword[esi]
.cycle5: ;横« ¯® ¢á¥¬ â®çª ¬
add esi,4
mov ebx,[esi]
imul ebx,sizeof.Cell
add ebx,dword[napr] ;pole_data
movzx edx,byte[ebx+offs_cell_liv]
cmp dl,2
jne @f
stdcall str_len,edi
add edi,eax
mov eax,dword[ebx+offs_cell_x]
stdcall convert_int_to_str
stdcall str_cat,edi,txt_space
stdcall str_len,edi
add edi,eax
mov eax,dword[ebx+offs_cell_y]
stdcall convert_int_to_str
stdcall str_cat,edi,txt_space
;stdcall str_cat,edi,txt_nl
@@:
dec ecx
jnz .cycle5
stdcall str_cat,edi,txt_nl
.no_points:
;*** ®¯à¥¤¥«¥­¨¥ ¯ à ¬¥â஢ ä ©« 
mov edi,open_file_lif
stdcall str_len,edi
mov ecx,eax
;*** § ¯¨áì ä ©« 
mov eax,70
mov [run_file_70.Function], 2
mov [run_file_70.Position], 0
mov [run_file_70.Flags], 0
mov dword[run_file_70.Count], ecx
mov [run_file_70.Buffer], edi
mov byte[run_file_70+20], 0
mov dword[run_file_70.FileName], openfile_path
mov ebx,run_file_70
int 0x40 ;á®å࠭塞 ä ©«
call redraw_pole
.end_save_file:
popad
ret
endp
;ä®à¬¨à®¢ ­¨¥ ¯®¤¯¨á¨ ¤«ï ᯨ᪠
align 4
proc make_list_capts uses eax ebx ecx edi, buf:dword, txt:dword
mov ebx,dword[buf]
mov edi,ebx
add edi,capt_offs
mov dword[edi],' ' ;¯à®¡¥«ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¬ «¥­ìª¨å ç¨á¥«
mov eax,dword[ebx] ;+0 - offset coord x
cmp eax,100
jge @f
inc edi
@@:
cmp eax,10
jge @f
inc edi
@@:
call convert_int_to_str ;ª®®à¤¨­ â  x (¤«ï ¯®¤¯¨á¨)
stdcall str_cat,edi,txt_space
stdcall str_len,edi
add edi,eax
mov eax,dword[ebx+4] ;+4 - offset coord y
call convert_int_to_str ;ª®®à¤¨­ â  y (¤«ï ¯®¤¯¨á¨)
stdcall str_cat,edi,txt_space
mov edi,dword[txt]
cmp edi,0
je .end_f
stdcall str_len,edi ;eax = strlen([edi])
mov ecx,edi
call str_next_spaces
sub edi,ecx ;®¯à¥¤¥«ï¥¬ ¤«¨­­ã ¯®¤¯¨á¨
cmp edi,eax
jle @f
mov edi,eax ;¥á«¨ áâப  § ª®­ç¨« áì ­¥ ¯à®¡¥«®¬
@@:
;cmp edi,1
;jge @f
; mov edi,1 ;¬¨­¨¬ã¬ 1 ᨬ¢®«
;@@:
add ebx,capt_offs
stdcall str_n_cat, ebx,ecx,edi
.end_f:
ret
endp
;output:
; eax - ⨯ í«¥¬¥­â 
align 4
proc el_get_name uses ecx edi esi, str:dword
mov edi,[str]
mov esi,el_opt_beg+el_offs_nam
xor ecx,ecx
@@:
stdcall str_instr, edi,esi
cmp eax,0
je @f
add esi,size_el_opt
cmp esi,el_opt_beg.end
jge @f
inc ecx
jmp @b
@@:
mov eax,ecx
ret
endp
;input:
; el_data - 㪠§ â¥«ì ­  ¤ ­­ë¥ í«¥¬¥­â 
; l_opt - ­®¬¥à ­®£¨, ¤«ï ª®â®à®© ¨éãâáï ª®®à¤¨­ âë, ¢å®¤­ ï/¢ë室­ ï ­®£ 
;output:
; eax - coord x (if not found eax=0)
; ebx - coord y (if not found ebx=0)
align 4
proc el_get_leg_coords uses ecx edx edi esi, el_data:dword, l_opt:dword
mov edi,[el_data] ;¤ ­­ë¥ í«¥¬¥­â 
movzx esi,byte[edi+sp_offs_el_type] ;⨯ í«¥¬¥­â 
imul esi,size_el_opt
add esi,el_opt_beg
;esi+el_offs_legs_inp - 㪠§ â¥«ì ­  ¯ à ¬¥âàë 0-© ¢å®¤­®© ­®£¨
mov eax,[edi+0]
mov ebx,[edi+4]
mov edx,[l_opt]
movzx edi,byte[edi+8] ;㣮« ¯®¢®à®â  / 90 (®â 0-3)
btr edx,16 ;¢å®¤­ ï/¢ë室­ ï ­®£ 
jc .output_leg
;¥á«¨ ­®£  ¢å®¤­ ï
inc edx ;­®¬¥à æ¨ï ­®£ ­ ç¨­ ¥âáï á ­ã«ï, ¯®â®¬ã ¤®¡ ¢«ï¥¬ 1
stdcall move_rotate_x_n90, -2,edi
add esi,el_offs_legs_inp
@@:
movzx ecx,byte[esi]
cmp ecx,0
je .not_found ;­®£¨ ª®­ç¨«¨áì à ­ìè¥, 祬 ®¦¨¤ «®áì
stdcall move_rotate_n90, 0,ecx,edi
inc esi
dec edx
jnz @b
jmp .end_f
;¥á«¨ ­®£  ¢ë室­ ï
.output_leg:
inc edx ;­®¬¥à æ¨ï ­®£ ­ ç¨­ ¥âáï á ­ã«ï, ¯®â®¬ã ¤®¡ ¢«ï¥¬ 1
movzx ecx,byte[esi+el_offs_box_x]
add ecx,2
stdcall move_rotate_x_n90, ecx,edi
add esi,el_offs_legs_out
@@:
movzx ecx,byte[esi]
cmp ecx,0
je .not_found ;­®£¨ ª®­ç¨«¨áì à ­ìè¥, 祬 ®¦¨¤ «®áì
stdcall move_rotate_n90, 0,ecx,edi
inc esi
dec edx
jnz @b
jmp .end_f
.not_found:
xor eax,eax
xor ebx,ebx
.end_f:
ret
endp
align 4
proc move_rotate_n90 uses ecx edi, d_x:dword, d_y:dword, angle:dword
mov edi,[angle] ;㣮« ¯®¢®à®â  / 90 (®â 0-3)
and edi,3
shl edi,4 ;edi*=16
add edi,mcs
mov ecx,[d_x]
imul ecx,dword[edi]
add eax,ecx
mov ecx,[d_y]
imul ecx,dword[edi+4]
add eax,ecx
mov ecx,[d_x]
imul ecx,dword[edi+8]
add ebx,ecx
mov ecx,[d_y]
imul ecx,dword[edi+12]
add ebx,ecx
ret
endp
align 4
proc mem_copy, destination:dword, source:dword, len:dword
push ecx esi edi
cld
mov esi, dword[source]
mov edi, dword[destination]
mov ecx, dword[len]
rep movsb
pop edi esi ecx
ret
endp
;description:
; ”ã­ªæ¨ï ¯à®¯ã᪠¥â ®¤­® á«®¢® (¨«¨ ç¨á«®) á ãç¥â®¬ à §¤¥«¨â¥«ì­ëå ᨬ¢®«®¢:
; ¯à®¡¥« , â ¡ã«ï樨, ­®¢®© áâப¨. <20>㦭  ¤«ï ¯®á«¥¤®¢ â¥«ì­®£® áç¨â뢠­¨ ç¨á¥« ¨§ áâப¨
;input:
; edi - 㪠§ â¥«ì ­  ¯à®¡¥« ¨«¨ á«®¢®
;output:
; edi - 㪠§ â¥«ì ­  á«¥¤ãî饥 á«®¢®
align 4
str_next_val:
call str_skip_spaces
@@:
cmp byte[edi],0
je @f
cmp byte[edi],' '
je @f
cmp byte[edi],9
je @f
cmp byte[edi],10
je @f
cmp byte[edi],13
je @f
inc edi
jmp @b
@@:
call str_skip_spaces
ret
align 4
str_skip_spaces:
dec edi
@@:
inc edi
cmp byte[edi],' '
je @b
cmp byte[edi],9
je @b
cmp byte[edi],10
je @b
cmp byte[edi],13
je @b
ret
align 4
str_next_spaces:
dec edi
@@:
inc edi
cmp byte[edi],0
je @f
cmp byte[edi],' '
je @f
cmp byte[edi],9
je @f
cmp byte[edi],10
je @f
cmp byte[edi],13
je @f
jmp @b
@@:
ret
;input:
; esi - 㪠§ â¥«ì ­  ¨áª®¬®¥ á«®¢®
;output:
; edi - 㪠§ â¥«ì ­  ¯®§¨æ¨î ¢ ª®â®à®© á«®¢® ­ ©¤¥­®, ¥á«¨ á«®¢® ­¥ ­ ©¤¥­® â® edi=0
;¯®àâïâáï ॣ¨áâàë:
; eax ecx
align 4
str_analiz_r:
mov edi,open_file_lif
mov ecx,dword[f_size]
@@:
mov al,byte[esi] ;ãáâ ­ ¢«¨¢ ¥¬ ¯¥à¢ë© ᨬ¢®« ¤«ï ¯®¨áª 
cld
repnz scasb
cmp ecx,0
je @f ;¥á«¨ § ª®­ç¨«áï ¢¥áì ⥪áâ, â® ¢ë室 ¨§ ä㭪樨
;¯¥à¢ë© ᨬ¢®« ¯®  ¤à¥áã edi-1 ¤®«¦¥­ ¡ëâì ¨§ áâப¨ esi
dec edi
stdcall str_instr, edi,esi ;¯à®¢¥à塞 á«®¢® ­  ᮢ¯ ¤¥­¨¥
inc edi
cmp al,0
jne @b ;¥á«¨ á«®¢® ­¥ ᮢ¯ «®, ¨é¥¬ ¢ áâப¥ á«¥¤ãî騩 ¯¥à¢ë© ᨬ¢®« ¤«ï áà ¢­¥­¨ï
;á ¯®¯ ¤ ¥¬ ¥á«¨ ­ è«¨ á«®¢® esi ¯®  ¤à¥áã edi
jmp .exit_f
@@:
;á ¯®¯ ¤ ¥¬ ¥á«¨ ­¥ ­ è«¨ á«®¢® esi ¯®  ¤à¥áã edi
xor edi,edi
.exit_f:
ret
;description:
; ¯à®¢¥àï¥â ᮤ¥à¦¨âáï «¨ áâப  str1 ¢ áâப¥ str0
; ¯à®¢¥àª  ¤¥« ¥âáï ⮫쪮 ­ ç¨­ ï á ¯¥à¢ëå ᨬ¢®«®¢, 㪠§ ­­ëå ¢ str0 ¨ str1
; ¯à¨¬¥à 1: ¥á«¨ str0='aaabbbccc', str1='bbb' ᮢ¯ ¤¥­¨ï ­¥ ¡ã¤¥â
; ¯à¨¬¥à 2: ¥á«¨ str0='aaabbbccc', str1='aaa' ᮢ¯ ¤¥­¨¥ ¡ã¤¥â
;output:
; al = 0 ¥á«¨ áâப  str1 ᮤ¥à¦¨âáï ¢ str0
; al != 0 ¥á«¨ áâப  str1 ­¥ ᮤ¥à¦¨âáï ¢ str0
align 4
proc str_instr uses edi esi, str0:dword, str1:dword
;xor eax,eax
mov edi,[str0]
mov esi,[str1]
cld
@@:
mov al,[esi]
cmp al,0
je .e1
inc esi
scasb ;áà ¢­¨¢ ¥¬ ᨬ¢®«ë
jz @b ;¥á«¨ ᮢ¯ «¨, â® ¯¥à¥å®¤¨¬ ª áà ¢­¥­¨î á«¥¤ãîé¨å
;á ¯®¯ ¤ ¥¬ ¥á«¨ áâப¨ ­¥ ᮢ¯ «¨
sub al,[edi-1]
.e1: ;á ¯®¯ ¤ ¥¬ ¥á«¨ áâப  str1 (esi) § ª®­ç¨« áì
ret
endp
align 4
proc but_run_stop
xor byte[tim_ch],1
cmp byte[tim_ch],0
jne @f
;®áâ ­®¢ª  á奬ë
stdcall pole_reset_cells, pole ;ç¨á⪠ ¯à®¢®¤®¢
call redraw_pole
jmp .end_f
@@:
;¯®¤£®â®¢ª  áå¥¬ë ª § ¯ãáªã
call sign_clear
.end_f:
ret
endp
align 4
proc but_set_0 uses eax
stdcall [tl_node_get_data], tree1
pop eax
test eax,eax
jz .end_f
;el_icon_captions
; cmp byte[eax+8],'n'
; je .end_f
cmp byte[eax+8],'o' ;¢à¥¬¥­­®¥ ®âá¥ç¥­¨¥, ¯®ª  ­¥â ¯à®¢¥àª¨ ⨯  ⥪ã饩 ¨ª®­ª¨
jne .end_f
mov byte[eax+8],'z'
.end_f:
ret
endp
align 4
proc but_set_1 uses eax
stdcall [tl_node_get_data], tree1
pop eax
test eax,eax
jz .end_f
;el_icon_captions
; cmp byte[eax+8],'n'
; je .end_f
cmp byte[eax+8],'z' ;¢à¥¬¥­­®¥ ®âá¥ç¥­¨¥, ¯®ª  ­¥â ¯à®¢¥àª¨ ⨯  ⥪ã饩 ¨ª®­ª¨
jne .end_f
mov byte[eax+8],'o'
.end_f:
ret
endp
;ᤢ¨£ ®¡ê¥ªâ  ¢«¥¢®
align 4
proc but_mov_l uses eax edi
cmp byte[tim_ch],0
jne .end_f
stdcall [tl_node_get_data], tree1
pop eax
test eax,eax
jz .end_f
cmp dword[eax],1
jle .end_f
dec dword[eax]
mov edi,eax
stdcall mem_copy,txt_buf,eax,capt_offs
add edi,capt_offs
call str_next_val
call str_next_val
stdcall make_list_capts,txt_buf,edi
stdcall mem_copy,eax,txt_buf,32 ;capt_offs
call redraw_pole
stdcall [tl_draw],tree1
.end_f:
ret
endp
;ᤢ¨£ ®¡ê¥ªâ  ¢¯à ¢®
align 4
proc but_mov_r uses eax edi
cmp byte[tim_ch],0
jne .end_f
stdcall [tl_node_get_data], tree1
pop eax
test eax,eax
jz .end_f
inc dword[eax]
mov edi,eax
stdcall mem_copy,txt_buf,eax,capt_offs
add edi,capt_offs
call str_next_val
call str_next_val
stdcall make_list_capts,txt_buf,edi
stdcall mem_copy,eax,txt_buf,32 ;capt_offs
call redraw_pole
stdcall [tl_draw],tree1
.end_f:
ret
endp
align 4
proc but_mov_u uses eax edi
cmp byte[tim_ch],0
jne .end_f
stdcall [tl_node_get_data], tree1
pop eax
test eax,eax
jz .end_f
cmp dword[eax+4],1
jle .end_f
dec dword[eax+4]
mov edi,eax
stdcall mem_copy,txt_buf,eax,capt_offs
add edi,capt_offs
call str_next_val
call str_next_val
stdcall make_list_capts,txt_buf,edi
stdcall mem_copy,eax,txt_buf,32 ;capt_offs
call redraw_pole
stdcall [tl_draw],tree1
.end_f:
ret
endp
align 4
proc but_mov_d uses eax edi
cmp byte[tim_ch],0
jne .end_f
stdcall [tl_node_get_data], tree1
pop eax
test eax,eax
jz .end_f
inc dword[eax+4]
mov edi,eax
stdcall mem_copy,txt_buf,eax,capt_offs
add edi,capt_offs
call str_next_val
call str_next_val
stdcall make_list_capts,txt_buf,edi
stdcall mem_copy,eax,txt_buf,32 ;capt_offs
call redraw_pole
stdcall [tl_draw],tree1
.end_f:
ret
endp
;ãáâ ­®¢ª  ®¡ëç­®£® ०¨¬ , ¡¥§ à¨á®¢ ­¨ï
align 4
proc but_set_none
mov byte[pen_mode],0
ret
endp
;ãáâ ­®¢ª  ०¨¬  à¨á®¢ ­¨ï ¯à®¢®¤ 
align 4
proc but_set_pen_1
mov byte[pen_mode],1
ret
endp
;
align 4
proc but_set_pen_2
mov byte[pen_mode],2
ret
endp
;ãáâ ­®¢ª  ०¨¬  áâ¨à ­¨ï ¯à®¢®¤ 
align 4
proc but_set_pen_3
mov byte[pen_mode],3
ret
endp
;¤ ­­ë¥ ¤«ï ¤¨ «®£  ®âªàëâ¨ï ä ©«®¢
align 4
OpenDialog_data:
.type dd 0 ;0 - ®âªàëâì, 1 - á®åà ­¨âì, 2 - ¢ë¡à âì ¤â४â®à¨î
.procinfo dd procinfo ;+4
.com_area_name dd communication_area_name ;+8
.com_area dd 0 ;+12
.opendir_path dd plugin_path ;+16
.dir_default_path dd default_dir ;+20
.start_path dd file_name ;+24 ¯ãâì ª ¤¨ «®£ã ®âªàëâ¨ï ä ©«®¢
.draw_window dd draw_window ;+28
.status dd 0 ;+32
.openfile_path dd openfile_path ;+36 ¯ãâì ª ®âªà뢠¥¬®¬ã ä ©«ã
.filename_area dd filename_area ;+40
.filter_area dd Filter
.x:
.x_size dw 420 ;+48 ; Window X size
.x_start dw 10 ;+50 ; Window X position
.y:
.y_size dw 320 ;+52 ; Window y size
.y_start dw 10 ;+54 ; Window Y position
default_dir db '/rd/1',0
communication_area_name:
db 'FFFFFFFF_open_dialog',0
open_dialog_name:
db 'opendial',0
communication_area_default_path:
db '/rd/1/File managers/',0
Filter:
dd Filter.end - Filter ;.1
.1:
db 'TXT',0
db 'ASM',0
.end:
db 0
include 'le_libs.inc'
mouse_dd dd 0x0
sc system_colors
last_time dd 0
align 16
procinfo process_information
align 4
buf_0: dd 0 ;
.l: dw 170 ;+4 left
.t: dw panel_1_coord_top ;+6 top
.w: dd 335 ;+8 w
.h: dd 340 ;+12 h
.color: dd 0 ;+16 color
db 24 ;+20 bit in pixel
align 4
buf_font: ;¡ãä¥à á® èà¨ä⮬
dd 0 ;㪠§ â¥«ì ­  ¡ãä¥à ¨§®¡à ¦¥­¨ï
dw 25 ;+4 left
dw 25 ;+6 top
dd 96 ;+8 w
dd 144 ;+12 h
dd 0 ;+16 color
db 24 ;+20 bit in pixel
el_focus dd 0
tree1 tree_list 32,points_max+2, tl_key_no_edit, 16,16,\
0x8080ff,0x0000ff,0xffffff, 5,panel_3_coord_top,145,250, 0,capt_offs,0,\
el_focus, wScrObj,0
align 4
wScrObj:
.x:
.size_x dw 16 ;+0
.start_x dw 0 ;+2
.y:
.size_y dw 150 ;+4
.start_y dw 0 ;+6
.btn_high dd 15 ;+8
.type dd 1 ;+12
.max_area dd 100 ;+16
.cur_area dd 30 ;+20
.position dd 0 ;+24
.bckg_col dd 0xeeeeee ;+28
.frnt_col dd 0xbbddff ;+32
.line_col dd 0 ;+36
.redraw dd 0 ;+40
.delta dw 0 ;+44
.delta2 dw 0 ;+46
.run_x:
.r_size_x dw 0 ;+48
.r_start_x dw 0 ;+50
.run_y:
.r_size_y dw 0 ;+52
.r_start_y dw 0 ;+54
.m_pos dd 0 ;+56
.m_pos_2 dd 0 ;+60
.m_keys dd 0 ;+64
.run_size dd 0 ;+68
.position2 dd 0 ;+72
.work_size dd 0 ;+76
.all_redraw dd 0 ;+80
.ar_offset dd 1 ;+84
align 4
proc str_n_cat uses eax ecx edi esi, str1:dword, str2:dword, n:dword
mov esi,dword[str2]
mov ecx,dword[n]
mov edi,dword[str1]
stdcall str_len,edi
add edi,eax
cld
repne movsb
mov byte[edi],0
ret
endp
align 4
proc str_cat uses eax ecx edi esi, str1:dword, str2:dword
mov esi,dword[str2]
stdcall str_len,esi
mov ecx,eax
inc ecx
mov edi,dword[str1]
stdcall str_len,edi
add edi,eax
cld
repne movsb
ret
endp
;output:
; eax = strlen
align 4
proc str_len, str1:dword
mov eax,[str1]
@@:
cmp byte[eax],0
je @f
inc eax
jmp @b
@@:
sub eax,[str1]
ret
endp
;input:
; buf - 㪠§ â¥«ì ­  áâபã, ç¨á«® ¤®«¦­® ¡ëâì ¢ 10 ¨«¨ 16 à¨ç­®¬ ¢¨¤¥
;output:
; eax - ç¨á«®
align 4
proc conv_str_to_int, buf:dword
xor eax,eax
push ebx ecx esi
xor ebx,ebx
mov esi,[buf]
;­  á«ãç © ¥á«¨ ¯¥à¥¤ ç¨á«®¬ ­ å®¤ïâáï ¯à®¡¥«ë
@@:
cmp byte[esi],' '
jne @f
inc esi
jmp @b
@@:
;®¯à¥¤¥«¥­¨¥ ®âà¨æ â¥«ì­ëå ç¨á¥«
xor ecx,ecx
inc ecx
cmp byte[esi],'-'
jne @f
dec ecx
inc esi
@@:
cmp word[esi],'0x'
je .load_digit_16
.load_digit_10: ;áç¨â뢠­¨¥ 10-â¨ç­ëå æ¨äà
mov bl,byte[esi]
cmp bl,'0'
jl @f
cmp bl,'9'
jg @f
sub bl,'0'
imul eax,10
add eax,ebx
inc esi
jmp .load_digit_10
jmp @f
.load_digit_16: ;áç¨â뢠­¨¥ 16-à¨ç­ëå æ¨äà
add esi,2
.cycle_16:
mov bl,byte[esi]
cmp bl,'0'
jl @f
cmp bl,'f'
jg @f
cmp bl,'9'
jle .us1
cmp bl,'A'
jl @f ;®âᥨ¢ ¥¬ ᨬ¢®«ë >'9' ¨ <'A'
.us1: ;á®áâ ¢­®¥ ãá«®¢¨¥
cmp bl,'F'
jle .us2
cmp bl,'a'
jl @f ;®âᥨ¢ ¥¬ ᨬ¢®«ë >'F' ¨ <'a'
sub bl,32 ;¯¥à¥¢®¤¨¬ ᨬ¢®«ë ¢ ¢¥àå­¨© ॣ¨áâà, ¤«ï ã¯à®é¥­¨ï ¨å ¯®á«¥¤ã饩 ®¡à ¡®âª¨
.us2: ;á®áâ ¢­®¥ ãá«®¢¨¥
sub bl,'0'
cmp bl,9
jle .cor1
sub bl,7 ;convert 'A' to '10'
.cor1:
shl eax,4
add eax,ebx
inc esi
jmp .cycle_16
@@:
cmp ecx,0 ;¥á«¨ ç¨á«® ®âà¨æ â¥«ì­®¥
jne @f
sub ecx,eax
mov eax,ecx
@@:
pop esi ecx ebx
ret
endp
;íâ®â ª®¤ ­¥ ¬®©, ®­ ¯à¥®¡à §ã¥â ç¨á«® ¢ áâபã
;input:
; eax = value
; edi = string buffer
;output:
align 4
convert_int_to_str:
pushad
mov dword[edi+1],0;0x20202020
call .str
popad
ret
align 4
.str:
mov ecx,0x0a ;§ ¤ ¥âáï á¨á⥬  áç¨á«¥­¨ï ¨§¬¥­ïîâáï ॣ¨áâàë ebx,eax,ecx,edx ¢å®¤­ë¥ ¯ à ¬¥âàë eax - ç¨á«®
;¯à¥à¥¢®¤ ç¨á«  ¢ ASCII áâப㠢§®¤­ë¥ ¤ ­­ë¥ ecx=á¨á⥬  áç¨á«¥­ï edi  ¤à¥á ªã¤  § ¯¨á뢠âì, ¡ã¤¥¬ áâபã, ¯à¨ç¥¬ ª®­¥æ ¯¥à¥¬¥­­®©
cmp eax,ecx ;áà ¢­¨âì ¥á«¨ ¢ eax ¬¥­ìè¥ ç¥¬ ¢ ecx â® ¯¥à¥©â¨ ­  @@-1 â.¥. ­  pop eax
jb @f
xor edx,edx ;®ç¨áâ¨âì edx
div ecx ;à §¤¥«¨âì - ®áâ â®ª ¢ edx
push edx ;¯®«®¦¨âì ¢ á⥪
;dec edi ;ᬥ饭¨¥ ­¥®¡å®¤¨¬®¥ ¤«ï § ¯¨á¨ á ª®­æ  áâப¨
call .str ;¯¥à¥©â¨ ­  á ¬ã ᥡï â.¥. ¢ë§¢ âì á ¬ã á¥¡ï ¨ â ª ¤® ⮣® ¬®¬¥­â  ¯®ª  ¢ eax ­¥ áâ ­¥â ¬¥­ìè¥ ç¥¬ ¢ ecx
pop eax
@@: ;cmp al,10 ;¯à®¢¥à¨âì ­¥ ¬¥­ìè¥ «¨ §­ ç¥­¨¥ ¢ al 祬 10 (¤«ï á¨á⥬ë áç¨á«¥­ï 10 ¤ ­­ ï ª®¬ ­¤  - «¨è­ ï))
or al,0x30 ;¤ ­­ ï ª®¬ ­¤  ª®à®ç¥ 祬 ¤¢¥ ¢ëè¥
stosb ;§ ¯¨á âì í«¥¬¥­â ¨§ ॣ¨áâà  al ¢ ï祪㠯 ¬ï⨠es:edi
ret ;¢¥à­ãâìáï ç¥­ì ¨­â¥à¥á­ë© 室 â.ª. ¯®ª  ¢ á⥪¥ åà ­¨âìáï ª®«-¢® ¢ë§®¢®¢ â® á⮫쪮 à § ¬ë ¨ ¡ã¤¥¬ ¢ë§ë¢ âìáï
i_end:
rb 1024
stacktop:
sys_path rb 1024
file_name:
rb 1024 ;4096
library_path rb 1024
plugin_path rb 4096
openfile_path rb 4096
filename_area rb 256
mem: