Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 109 → Rev 205

/programs/system/run/trunk/build_en.bat
1,4 → 1,5
@erase lang.inc
@echo lang fix en >lang.inc
@fasm run.asm run
@erase lang.inc
@pause
/programs/system/run/trunk/build_ru.bat
1,4 → 1,5
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm run.asm run
@erase lang.inc
@pause
/programs/system/run/trunk/editbox.inc
0,0 → 1,755
; <Lrz> 21.07.2006 ¤®¡ ¢«¥­  äã­ªæ¨ï ª­®¯ª¨ Del, ⥯¥àì ¬®¦­® 㤠«ïâì ᨬ¢®«ë ¯à¨ ¯®¬®é¨ ¤ ­­®© ª®« ¢¨è¨
; €¢â®à: …¢â¨å®¢ Œ ªá¨¬ (Maxxxx32) email: maxxxxm@mail.ru
; „ â  ¯®á«¥¤­¨å ¨§¬¥­¥­¨©: 13.07.06 10:40
;  ¯¨è¨â¥ ¢ ¨á室­®¬ ª®¤¥ ᢮¥© ¯à®£à ¬¬ë use_edit_box,
; íâ® ¢áâ ¢¨â ­¥®¡å®¤¨¬ë¥ ¯à®æ¥¤ãàë ¢ ª®¤ ¢ è¥© ¯à®£à ¬¬ë.
; à®æ¥¤ãàë:
; edit_box.draw - ¯®«­ ï ¯¥à¥à¨á®¢ª ;
; edit_box.key - ®¡à ¡®âª  ª« ¢¨ âãàë;
; edit_box.mouse - ®¡à ¡®âª  ¬ëè¨;
; edit_box.focus - ãáâ ­®¢ª  䮪ãá ;
; edit_box.blur - ¥£® à §¬ë¢ ­¨¥;
; edit_box.get_n - ¯®«ãç¨âì ª®«¨ç¥á⢮ ¯à®à¨á®¢ë¢ ¥¬ëå ᨬ¢®«®¢.
; à¨ ¢ë§®¢¥ «î¡ëå ¨§ íâ¨å ¯à®æ¥¤ãà ¢ ॣ¨áâॠedi á«¥¤ã¥â
; ®áâ ¢¨âì 㪠§ â¥«ì ­  áâàãªâãàã.
; à¨¬¥à áâàãªâãàë:
; some_edit edit_box 100,10,30,0x00ffffff,0,0x00aaaaaa,0,255,some_edit_text
; ¤«¨­ , «¥¢®, ¢¥àå, 梥â ä®­ , 梥â à ¬ª¨, ¥á«¨ ¢ë¡à ­,
; 梥â à ¬ª¨, ¥á«¨ ­¥ ¢ë¡à ­, ¬ ªá¨¬ «ì­®¥ ª®«¨ç¥á⢮ ᨬ¢®«®¢,
; 㪠§ â¥«ì ­  ¡ãä¥à, £¤¥ ¡ã¤ãâ åà ­¨âáï ᨬ¢®«ë. ãä¥à ¤®«¦¥­
; ®ª ­ç¨¢ âìáï ­ã«¥¬, ­ ¯à¨¬¥à ¥á«¨ ¬ ªá¨¬ «ì­®¥ ª®«¨ç¥á⢮ 255:
; some_edit_text:
; rb 256 ;255+1
 
; à¨¬¥à ¢ë§®¢  ¯à®æ¥¤ãàë:
; mov edi,some_edit
; call edit_box.draw
 
; à¨ ¢ë§®¢¥ ¯à®æ¥¤ãàë edit_box.key ª®¤ ª« ¢¨è¨ ¤®«¦¥­
; ­ å®¤¨âáï ¢ ah, â® ¥áâì ¯¥à¥¤ ¢ë§®¢®¬ í⮩ ¯à®æ¥¤ãàë ­ ¤® ¢ë§¢ âì
; 2-ãî á¨á¥¬­ãî äã­ªæ¨î, ­ ¯à¨¬¥à:
; mov eax,2
; int 0x40
; mov edi,some_edit1
; call edit_box.key
; mov edi,some_edit2
; call edit_box.key
; ¥à¥¤ ¢ë§®¢®¬ ®¡à ¡®â稪  ¬ëè¨ á«¥¤ã¥â ¯à®¢¥à¨âì, ï¥âáï «¨ ®ª­®
;  ªâ¨¢­ë¬.
; …᫨ 饫箪 ¬ëè¨ ¡ë« ¯à®©§¢¥¤¥­ §  ¯à¥¤¥« ¬¨ edit box
; 䮪ãá â¥àï¥âáï.
macro use_edit_box
{
edit_box:
ed_width equ [edi]
ed_left equ [edi+2]
ed_top equ [edi+4]
ed_color equ [edi+6]
ed_focus_border_color equ [edi+10]
ed_blur_border_color equ [edi+14]
ed_text_color equ [edi+18]
ed_flags equ [edi+22]
ed_max equ [edi+24]
ed_size equ [edi+26]
ed_pos equ [edi+28]
ed_offset equ [edi+30]
ed_text equ [edi+32]
ed_height=14 ; ¢ëá®â 
;==========================================================
;=== ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ =================================
;==========================================================
.draw:
pusha
;--- à¨á㥬 à ¬ªã ---
call .draw_border
 
.draw_bg_cursor_text:
;--- ¨§¬¥­ï¥¬ ᬥ饭¨¥, ¥á«¨ ­ ¤® ---
call .check_offset
;--- à¨á㥬 ¢­ãâ७­îî ®¡« áâì ---
call .draw_bg
.draw_cursor_text:
;--- à¨á㥬 ªãàá®à ---
;--- ¬®¦¥â ¥£® ­¥ ­ ¤® à¨á®¢ âì ----
bt word ed_flags,1
jnc @f
call .draw_cursor
@@:
call .draw_text
popa
ret
 
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ⥪áâ  --------------------------
;----------------------------------------------------------
.draw_text:
;--- ¢ëç¨á«ï¥¬, ᪮«ìª® ¯®¬¥é ¥âáï ᨬ¢®«®¢ ---
call .get_n
;--- çâ®¡ë ¬ãá®à ­¥ à¨á®¢ âì ---
movsx esi,word ed_size
sub si,ed_offset
cmp ax,si
ja @f
mov si,ax
@@:
 
;--- à¨á㥬 ⥪áâ ---
mov eax,4
mov bx,ed_left
add bx,2
shl ebx,16
mov bx,ed_top
add bx,4
mov ecx,ed_text_color
movsx edx,word ed_offset
add edx,ed_text
int 0x40
ret
 
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ä®­  ----------------------------
;----------------------------------------------------------
.draw_bg_eax:
pusha
movsx ebx,ax
lea ebx,[ebx*2+ebx]
shl bx,1
shl ebx,16
shr eax,16
lea eax,[eax*2+eax]
shl ax,1
add ax,ed_left
add ax,2
mov bx,ax
ror ebx,16
jmp @f
.draw_bg:
pusha
mov bx,ed_left
inc bx
shl ebx,16
mov bx,ed_width
dec bx
 
@@:
mov cx,ed_top
inc cx
shl ecx,16
mov cx,ed_height
dec cx
 
mov edx,ed_color
mov eax,13
int 0x40
popa
ret
 
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ¯®«ã祭¨ï ª®«¨ç¥á⢠ ᨬ¢®«®¢ --------------
;----------------------------------------------------------
.get_n:
xor edx,edx
movsx eax,word ed_width
sub ax,4
mov bx,6
div bx
ret
 
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  à¨á®¢ ­¨ï ªãàá®à  --------------------------
;----------------------------------------------------------
.clear_cursor:
mov edx,ed_color
jmp @f
.draw_cursor:
mov edx,ed_text_color
@@:
movsx ebx,word ed_pos
sub bx,ed_offset
;lea ebx,[ebx*2+ebx]
;shl ebx,1
imul ebx,6
add bx,ed_left
inc bx
push bx
shl ebx,16
pop bx
mov cx,ed_top
add cx,2
push cx
shl ecx,16
pop cx
add cx,ed_height-4
mov eax,38
int 0x40
ret
 
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  à¨á®¢ ­¨ï à ¬ª¨ ----------------------------
;----------------------------------------------------------
.draw_border:
;--- 梥â à ¬ª¨ ---
bt word ed_flags,1
mov edx,ed_focus_border_color
jc @f
mov edx,ed_blur_border_color
@@:
;--- ᢥàåã ---
mov bx,ed_left
push bx
shl ebx,16
pop bx
add bx,ed_width
mov cx,ed_top
push cx
shl ecx,16
pop cx
mov eax,38
int 0x40
 
;--- á­¨§ã ---
push cx
add cx,ed_height
push cx
shl ecx,16
pop cx
int 0x40
 
;--- á«¥¢  ---
pop cx
push bx
sub bx,ed_width
int 0x40
 
;--- á¯à ¢  ---
pop bx
push bx
shl ebx,16
pop bx
int 0x40
ret
 
;----------------------------------------------------------
;--- ¯à®¢¥àª , § è¥« «¨ ªãàá®à §  £à ­¨æë ¨, ¥á«¨ ­ ¤®, ---
;--- ¨§¬¥­ï¥¬ ᬥ饭¨¥ ------------------------------------
;--- eax = 1, ¥á«¨ ­¥ ¨§¬¥­¨«®áì ¨«¨ eax = 0, ¥á«¨
; ¨§¬¥­¨«®áì
;----------------------------------------------------------
.check_offset:
push word ed_offset
call .get_n
;--- ¯à ¢¥¥ ---
mov bx,ed_offset
add bx,ax
cmp bx,ed_pos
ja @f
mov bx,ed_pos
mov cx,ax
shr cx,2
sub bx,cx
mov cx,ax
shr cx,1
sub bx,cx
mov ed_offset,bx
@@:
;--- «¥¢¥¥ ---
mov bx,ed_offset
cmp bx,ed_pos
jb @f
mov bx,ed_pos
mov cx,ax
shr cx,2
sub bx,cx
jnc $+5
xor bx,bx
mov ed_offset,bx
@@:
xor eax,eax
pop bx
cmp bx,ed_offset
jne @f
inc eax
@@:
ret
 
;==========================================================
;=== ®¡à ¡®âª  ª« ¢¨ âãàë =================================
;==========================================================
.key:
pusha
bt word ed_flags,1 ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
jc @f
popa
ret
@@:
 
;----------------------------------------------------------
;--- ¯à®¢¥à塞, çâ® ­ ¦ â® --------------------------------
;----------------------------------------------------------
cmp ah,8
je .backspace
cmp ah,0xb6
je .delete
cmp ah,176
je .left
cmp ah,179
je .right
cmp ah,180
je .home
cmp ah,181
je .end
 
;--- ­ ¦ â  ¤àã£ ï ª« ¢¨è  ---
bt word ed_flags,15 ; ⮫쪮 æ¨äàë ?
jnc @f
cmp ah,'0'
jb .no_figure
cmp ah,'9'
ja .no_figure
jmp @f
.no_figure:
popa
ret
@@:
; ¯à®¢¥à塞, ­ å®¤¨âáï «¨ ªãàá®à ¢ ª®­æ¥
mov bx,ed_max
cmp bx,ed_pos
jne @f ; ¥á«¨ ¤ , ¢ ª®­¥æ ¯à®æ¥¤ãàë
popa
ret
@@:
; ᤢ¨£ ¥¬ ᨬ¢®«ë ¯®á«¥ ªãàá®à  ¢¯à ¢®
mov edx,ed_text
dec edx
xor ecx,ecx
mov cx,ed_size
cmp cx,ed_pos
je @f
.mov_right_next:
mov bh,[edx+ecx]
mov [edx+ecx+1],bh
dec cx
cmp cx,ed_pos
jne .mov_right_next
@@:
 
 
; ¢áâ ¢«ï¥¬ ª®¤ ª« ¢¨è¨ â㤠, £¤¥ ªãàá®à
mov edx,ed_text
movsx ebx,word ed_pos
mov [ebx+edx],ah
 
call .clear_cursor
; 㢥«¨ç¨¢ ¥¬ §­ ç¥­¨¥ à §¬¥à  ¨ ¯®§¨æ¨¨
inc word ed_pos
mov bx,ed_size
cmp bx,ed_max
je .draw_bg_cursor_text;.key_end_draw
inc word ed_size
 
;push word ed_offset
call .check_offset
;pop ax
;cmp ax,ed_offset
;jne .draw_bg_cursor_text
test eax,eax
jz .draw_bg_cursor_text
 
call .get_n
sub ax,ed_pos
add ax,ed_offset
inc ax
shl eax,16
mov ax,ed_pos
sub ax,ed_offset
dec ax
ror eax,16
call .draw_bg_eax
 
jmp .draw_cursor_text
 
;jmp .draw_cursor_text;.key_end_draw
 
.delete:
mov dx,ed_size
mov cx,ed_pos
;inc edx
;add ecx,900
;sub ecx,1
cmp dx,cx
jg @f
popa
ret
 
@@:
mov edx,ed_text
;dec edx
.mov_stop_next:
mov bh,[edx+ecx+1]
mov [edx+ecx],bh
inc cx
mov bx,ed_size
;dec bx
;dec bx
cmp cx,bx
jne .mov_stop_next
 
; 㬥­ìè ¥¬ §­ ç¥­¨¥ ¯®§¨æ¨¨ ¨ à §¬¥à 
;dec word ed_pos
dec word ed_size
;push word ed_offset
call .check_offset
;pop ax
;cmp ax,ed_offset
;jne .draw_bg_cursor_text
test eax,eax
jz .draw_bg_cursor_text
 
call .get_n
sub ax,ed_pos
add ax,ed_offset
shl eax,16
mov ax,ed_pos
sub ax,ed_offset
ror eax,16
call .draw_bg_eax
 
jmp .draw_cursor_text
popa
ret
 
;--- ­ ¦ â  ª« ¢¨è  backspace ---
.backspace:
; ¯à®¢¥à塞, ªãàá®à ã «¥¢®£® ªà ï ?
mov bx,ed_pos
;cmp bx,0
;jne @f; .key_end ; ¥á«¨ ¤ , ¢ ª®­¥æ
test bx,bx
jnz @f
popa
ret
@@:
 
; ᤢ¨£ ¥¬ ᨬ¢®«ë ¯®á«¥ ªãàá®à  ¢«¥¢®
mov edx,ed_text
dec edx
movsx ecx,word ed_pos
 
.mov_left_next:
mov bh,[edx+ecx+1]
mov [edx+ecx],bh
inc cx
mov bx,ed_size
inc bx
cmp cx,bx
jne .mov_left_next
 
; 㬥­ìè ¥¬ §­ ç¥­¨¥ ¯®§¨æ¨¨ ¨ à §¬¥à 
dec word ed_pos
dec word ed_size
 
;push word ed_offset
call .check_offset
;pop ax
;cmp ax,ed_offset
;jne .draw_bg_cursor_text
test eax,eax
jz .draw_bg_cursor_text
 
call .get_n
sub ax,ed_pos
add ax,ed_offset
shl eax,16
mov ax,ed_pos
sub ax,ed_offset
ror eax,16
call .draw_bg_eax
 
jmp .draw_cursor_text
popa
ret
 
;--- ­ ¦ â  ª« ¢¨è  left ---
.left:
mov bx,ed_pos
;cmp bx,0
;je @f
test bx,bx
jz @f
call .clear_cursor
dec word ed_pos
call .check_offset
test eax,eax
jz .draw_bg_cursor_text
call .draw_cursor
@@:
popa
ret
 
;--- ­ ¦ â  ª« ¢¨è  right ---
.right:
mov bx,ed_pos
cmp bx,ed_size
je @f
call .clear_cursor
inc word ed_pos
call .check_offset
test eax,eax
jz .draw_bg_cursor_text
call .draw_cursor
@@:
popa
ret
 
.home:
mov bx,ed_pos
test bx,bx
jz @f
call .clear_cursor
xor eax,eax
mov ed_pos,ax
call .check_offset
test eax,eax
jz .draw_bg_cursor_text
call .draw_cursor
@@:
popa
ret
 
.end:
mov bx,ed_pos
cmp bx,ed_size
je @f
call .clear_cursor
mov ax,ed_size
mov ed_pos,ax
call .check_offset
test eax,eax
jz .draw_bg_cursor_text
call .draw_cursor
@@:
popa
ret
 
 
;==========================================================
;=== ®¡à ¡®âª  ¬ëè¨ =======================================
;==========================================================
.mouse:
pusha
;----------------------------------------------------------
;--- ¯®«ãç ¥¬ á®áâ®ï­¨¥ ª­®¯®ª ¬ëè¨ -----------------------
;----------------------------------------------------------
mov eax,37
mov ebx,2
int 0x40
;----------------------------------------------------------
;--- ¯à®¢¥à塞 á®áâ®ï­¨¥ ----------------------------------
;----------------------------------------------------------
bt eax,0
jc .mouse_left_button
 
bt eax,1
jc @f
btr word ed_flags,2
@@:
 
popa
ret
 
.mouse_left_button:
;----------------------------------------------------------
;--- ¯®«ãç ¥¬ ª®®à¤¨­ âë ¬ëè¨ -----------------------------
;----------------------------------------------------------
bts word ed_flags,2
jc .mouse_pressed
mov eax,37
;mov ebx,1
xor ebx,ebx
inc ebx
int 0x40
;----------------------------------------------------------
;--- ¯à®¢¥à塞, ¯®¯ ¤ ¥â «¨ ªãàá®à ¢ edit box -------------
;----------------------------------------------------------
mov bx,ed_top
cmp ax,bx
jl ._blur;.mouse_end_no_focus
 
add bx,ed_height
cmp ax,bx
jg ._blur;.mouse_end_no_focus
 
shr eax,16
 
mov bx,ed_left
cmp ax,bx
jl ._blur;.mouse_end_no_focus
 
add bx,ed_width
cmp ax,bx
jg ._blur;.mouse_end_no_focus
 
;--- ¨§¬¥­ï¥¬ ¯®§¨æ¨î ªãàá®à  ---
push eax
call .clear_cursor
pop eax
xor dx,dx
sub ax,ed_left
add ax,2
mov bx,6
div bx
add ax,ed_offset
cmp ax,ed_size
jna @f
mov ax,ed_size
@@:
mov ed_pos,ax
call .check_offset
test eax,eax
jz .draw_bg_cursor_text
call .draw_cursor
 
call .focus
 
.mouse_pressed:
popa
ret
 
;.mouse_end_no_focus:
; call .blur
;popa
;ret
 
 
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ãáâ ­®¢ª¨ 䮪ãá  ---------------------------
;----------------------------------------------------------
.blur:
pusha
._blur:
bt word ed_flags,14
jc @f
btr word ed_flags,1
jnc @f
call .clear_cursor
jmp .blur_end
.focus:
pusha
bts word ed_flags,1
jc @f
call .draw_cursor
.blur_end:
call .draw_border
@@:
popa
ret
 
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  à §¬ë¢ ­¨ï 䮪ãá  --------------------------
;----------------------------------------------------------
;.blur:
;pusha
;._blur:
;btr word ed_flags,1
;jnc @f
;call .draw_border
;call .clear_cursor
;@@:
;popa
;ret
}
ed_figure_only=1000000000000000b
ed_always_focus=100000000000000b
ed_focus=10b
ed_struc_size=36
macro draw_edit_boxes start,end
{
mov edi,start
mov ecx,((end-start)/ed_struc_size)
@@:
call edit_box.draw
add edi,ed_struc_size
loop @b
}
 
macro mouse_edit_boxes start,end
{
mov edi,start
mov ecx,((end-start)/ed_struc_size)
@@:
call edit_box.mouse
add edi,ed_struc_size
loop @b
}
 
macro key_edit_boxes start,end
{
mov edi,start
mov ecx,((end-start)/ed_struc_size)
@@:
call edit_box.key
add edi,ed_struc_size
loop @b
}
 
struc edit_box width,left,top,color,focus_border_color,\
blur_border_color,text_color,max,text,flags,size
{
.width dw width
.left dw left
.top dw top
.color dd color
.focus_border_color dd focus_border_color
.blur_border_color dd blur_border_color
.text_color dd text_color
.flags dw flags+0
.max dw max
.size dw size+0
.pos dw 0
.offset dw 0
.text dd text
}
 
macro edit_boxes_set_sys_color start,end,color_table
{
mov edi,start
mov ecx,((end-start)/ed_struc_size)
mov esi,color_table
@@:
mov eax,[esi+36]
mov ebx,[esi+20]
mov ed_focus_border_color,eax
shr bh,1
shr bl,1
shr ah,1
shr al,1
add ah,bh
add al,bl
ror eax,16
ror ebx,16
shr bl,1
shr al,1
add al,bl
ror eax,16
mov ed_blur_border_color,eax
add edi,ed_struc_size
loop @b
}
 
macro draw_edit_box ed_ptr
{
mov edi,ed_ptr
call edit_box.draw
}
 
macro mouse_edit_box ed_ptr
{
mov edi,ed_ptr
call edit_box.mouse
}
 
macro key_edit_box ed_ptr
{
mov edi,ed_ptr
call edit_box.key
}
/programs/system/run/trunk/macros.inc
1,5 → 1,17
; new application structure
macro meos_app_start
;--- ¤à㣨¥ ¬ ªà®áë ---
include 'editbox.inc'
include 'txtbut.inc'
;include 'gp.inc'
;include 'label.inc'
;include 'checkbox.inc'
;include 'file_sys.inc'
;include 'textwork.inc'
;include 'ini.inc'
 
include 'lang.inc'
 
;--- § £®«®¢®ª ---
macro meos_header par_buf,cur_dir_buf
{
use32
org 0x0
6,261 → 18,294
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
dd __app_start
dd __app_end
dd __app_end
dd __app_end
if <par_buf> eq <>
dd 0x0
else
dd par_buf
end if
if <cur_dir_buf> eq <>
dd 0x0
else
dd cur_dir_buf
end if
}
 
dd 0x0
;--- ®¯à¥¤¥«¨âì â®çªã ¢å®¤  ---
macro app_start
{
__app_start:
}
MEOS_APP_START fix meos_app_start
 
macro code
;--- ®¯à¥¤¥«¨âì ª®­¥æ ¯à¨«®¦¥­¨ï ¨ à §¬¥à á⥪  ---
macro app_end stack_size
{
__start:
if <stack_size> eq <>
rb 1024
else
rb stack_size
end if
__app_end:
}
CODE fix code
 
macro data
;--- § ¢¥àè¨âì ⥪ã騩 ¯®â®ª ---
macro app_close
{
__data:
xor eax,eax
dec eax
int 0x40
}
DATA fix data
 
macro udata
;--- ¯®«ãç¨âì ª®¤ ­ ¦ â®© ª« ¢¨è¨ ---
macro get_key
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
mov eax,2
int 0x40
}
UDATA fix udata
 
macro meos_app_end
;--- ¯®«ãç¨âì ª®¤ ­ ¦ â®© ª­®¯ª¨ ---
macro get_pressed_button
{
align 32
rb 2048
__stack:
__memory:
mov eax,17
int 0x40
}
MEOS_APP_END fix meos_app_end
 
;--- á®®¡é¨âì á¨á⥬¥ ® ­ ç «¥ ¯¥à¥à¨á®¢ª¨ ®ª­  ---
macro start_draw_window
{
mov eax,12
xor ebx,ebx
inc ebx
int 0x40
}
 
; macro for defining multiline text data
struc mstr [sstring]
;--- á®®¡é¨âì á¨á⥬¥ ® § ¢¥à襭¨¨ ¯¥à¥à¨á®¢ª¨ ®ª­  ---
macro stop_draw_window
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
mov eax,12
mov ebx,2
int 0x40
}
 
;--- ãáâ ­®¢¨âì ¬ áªã ®¦¨¤ ¥¬ëå ᮡë⨩ ---
macro set_events_mask mask
{
mov eax,40
mov ebx,mask
int 0x40
}
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
;--- ¯®«ãç¨âì ¨­ä®à¬ æ¨î ® ¯à®æ¥áᥠ---
macro get_procinfo proc_inf_buf,slot_num
{
mov eax,9
mov ebx,proc_inf_buf
if <slot_num> eq <>
xor ecx,ecx
dec ecx
else
mov ecx,slot_num
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
int 0x40
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
macro get_sys_colors col_buf
{
mov eax,48
mov ebx,3
mov ecx,col_buf
mov edx,40
int 0x40
}
 
macro get_grab_area
{
mov eax,48
mov ebx,7
int 0x40
}
 
macro get_scin_height
{
mov eax,48
mov ebx,4
int 0x40
}
 
; easy system call macro
macro mpack dest, hsrc, lsrc
macro min_window
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
mov eax,18
mov ebx,10
int 0x40
}
 
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
macro activ_window slot_n
{
mov eax,18
mov ebx,3
if <slot_n> eq <>
else
mov ecx,slot_n
end if
int 0x40
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
macro get_active_window
{
mov eax,18
mov ebx,7
int 0x40
}
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
macro delay time
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
mov eax,5
if <time> eq <>
else
add arg1,arg2
mov ebx,time
end if
else
add arg1,arg2
end if
int 0x40
}
 
macro sub arg1,arg2
;--- ®¦¨¤ âì ᮡëâ¨ï ---
macro wait_event redraw,key,button,mouse,ipc,other
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
mov eax,10
int 0x40
dec ax
if <redraw> eq <>
else
sub arg1,arg2
jz redraw
end if
dec ax
if <key> eq <>
else
sub arg1,arg2
jz key
end if
dec ax
if <button> eq <>
else
jz button
end if
dec ax
dec ax
dec ax
if <mouse> eq <>
else
jz mouse
end if
if <ipc> eq <>
else
dec ax
jz ipc
end if
if <other> eq <>
jmp still
else
jmp other
end if
}
 
macro mov arg1,arg2
;--- ¯®«ãç¨âì à §¬¥àë íªà ­  ---
macro get_screen_size
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
mov eax,14
int 0x40
}
 
macro get_screen_prop struc_ptr
{
mov eax,61
push eax eax
xor ebx,ebx
inc ebx
int 0x40
mov [struc_ptr],eax
pop eax
inc ebx
int 0x40
mov [struc_ptr+4],ax
pop eax
inc ebx
int 0x40
mov [struc_ptr+6],eax
}
 
macro resize_mem mem_size
{
mov eax,64
xor ebx,ebx
inc ebx
if <mem_size> eq <>
else
mov arg1,arg2
mov ecx,mem_size
end if
else
mov arg1,arg2
end if
int 0x40
}
 
evm_redraw equ 1
evm_key equ 10b
evm_button equ 100b
evm_mouse equ 100000b
evm_ipc equ 1000000b
 
macro struct name
struc procinfo
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
.takts_per_second: dd ?
.window_stack_pos: dw ?
.slot_number: dw ?
dw ?
.name: rb 11
.align: db ?
.addres: dd ?
.use_mem: dd ?
.pid: dd ?
.left: dd ?
.top: dd ?
.width: dd ?
.height: dd ?
.slot_state: dw ?
rb (1024-56)
}
 
; structures used in MeOS
struc process_information
struc sys_color_table
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
.frames: dd ? ;+0
.grab: dd ? ;+4
.grab_button: dd ? ;+8
.grab_button_text: dd ? ;+12
.grab_text: dd ? ;+16
.work: dd ? ;+20
.work_button: dd ?;+24
.work_button_text: dd ? ;+28
.work_text: dd ? ;+32
.work_graph: dd ? ;+36
}
struct process_information
 
struc system_colors
struc screen_size
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
.height: dw ?
.width: dw ?
}
struct system_colors
 
struc screen_prop
{
.height: dw ? ;+0
.width: dw ? ;+2
.bitspp: dw ? ;+4
.bytesps: dd ?;+6
}
 
; constants
struc ipc_buffer size
{
.block: dd ?
.in_use: dd ?
.messages: rb size
}
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
;--- æ¢¥â  ---
cl_white=0xffffff
cl_black=0x000000
/programs/system/run/trunk/run.asm
1,198 → 1,261
; <--- description --->
; compiler: FASM 1.54
; name: MenuetOS RUN
; version: 0.02
; last update: 28/09/2004
; written by: Ivan Poddubny
; e-mail: ivan-yar@bk.ru
 
 
; <--- include all MeOS stuff --->
include "lang.inc"
include "macros.inc"
;;;lang fix en
 
 
; <--- start of MenuetOS application --->
MEOS_APP_START
 
;include "DEBUG.INC"
 
; <--- start of code --->
CODE
call draw_window ; at first create and draw the window
 
wait_event: ; main cycle
mcall 10
 
cmp eax, 1 ; if event == 1
je redraw ; jump to redraw handler
cmp eax, 2 ; else if event == 2
je key ; jump to key handler
cmp eax, 3 ; else if event == 3
je button ; jump to button handler
 
jmp wait_event ; else return to the start of main cycle
 
 
redraw: ; redraw event handler
window_y=88
;window_x=320
window_x=450
include 'macros.inc'
meos_header par
use_edit_box
use_txt_button
app_start
cmp [par],byte 0
jne read_par
set_events_mask evm_mouse+evm_button+evm_key+evm_redraw
red:
get_sys_colors sc
set_sys_colors_txt_button run_but,sc
push dword [sc.work_graph]
pop [input_fn.focus_border_color]
call draw_window
jmp wait_event
 
 
key: ; key event handler
mcall 2
 
still:
wait_event red,key,button,mouse,,still
key:
get_key
cmp ah, 13
je _run
cmp ah, 8
je .backspace
je run
key_edit_box input_fn
jmp still
button:
get_pressed_button
dec ah
jz close
dec ah
jz run
jmp still
mouse:
mouse_edit_box input_fn
jmp still
 
mov bl, ah
mov eax, [position]
mov [filename + eax], bl
inc [position]
call draw_string
 
jmp wait_event
 
.backspace:
read_par:
mov esi,par
mov edi,fn
mov ecx,256
rep movsb
run:
xor eax, eax
cmp [position], eax
je wait_event
dec [position]
call draw_string
jmp wait_event
mov edi,file_info.name
mov ecx,512
rep stosb
mov edi,run_par
mov ecx,256
rep stosb
 
mov esi,fn
mov edi,file_info.name
cmp [esi],byte '"'
je copy_fn_with_spaces
copy_fn:
cmp [esi],byte ' '
je .stop
cmp [esi],byte 0
je .stop
mov al,[esi]
mov [edi],al
inc esi
inc edi
jmp copy_fn
.stop:
 
button: ; button event handler
mcall 17
jmp copy_par
 
cmp ah, 10
je _run
copy_fn_with_spaces:
inc esi
@@:
cmp [esi],byte '"'
je .stop
cmp [esi],byte 0
je .stop
mov al,[esi]
mov [edi],al
inc esi
inc edi
jmp @b
.stop:
 
dec ah
jne wait_event ; return if button id != 1
copy_par:
@@:
inc esi
cmp [esi],byte ' '
je @b
mov edi,run_par
@@:
cmp [esi],byte 0
je .stop
mov al,[esi]
mov [edi],al
inc esi
inc edi
jmp @b
.stop:
 
_exit:
or eax, -1 ; exit application
mov eax,70
mov ebx,file_info
int 0x40
 
;cmp eax,0
;jg error
bt eax,31
je error
jmp still
close:
app_close
 
_run:
mcall 58, fileinfo
; dps "58th function returned "
; dpd eax
; newline
jmp _exit
error:
 
macro cmp_err code,text_ptr
{
cmp al,code
jne @f
mov [status],text_ptr
;jmp .draw_status
@@:
}
neg eax
 
draw_window:
mcall 12, 1
;test al,al
;jz close
 
mcall 14
and eax, 0xFFFF
sub eax, 100
shl eax, 16
add eax, 80
mov ecx, eax
cmp_err 3,bad_file_sys
 
mov ebx, 148*65536+400 ; (window_cx)*65536+(window_sx)
mov edx, 0x03DDDDDD ; work area color & window type 3
mcall 0
cmp_err 5,file_not_find
 
mov ebx, 8*65536+8 ; coordinates
mov ecx, 0x10ffffff ; color & font N1
mov edx, header ; address of text
mov esi, header.size ; length of text
mcall 4
cmp_err 9,bad_fat_table
 
mpack ebx, 10, 26
mov ecx, 0
mov edx, message
mov esi, message.size
mcall
cmp_err 10,acces_denyied
 
mpack ebx, 385-(runbtn.size*6), runbtn.size*6+4
mpack ecx, 56, 14
mov edx, 10
mov esi, 0xa0a0a0
mcall 8
cmp_err 11,device_error
 
; mpack ebx, 385-runbtn.size*6-findbtn.size*6-8, findbtn.size*6+4
; inc edx
; mcall 8
cmp_err 30,out_of_memory
 
; mpack ebx, 388-runbtn.size*6-findbtn.size*6-7, 59
; mov ecx, 0
; mov edx, findbtn
; mov esi, findbtn.size
; mcall 4
cmp_err 31,file_not_executable
 
mpack ebx, 388-runbtn.size*6, 59
mov ecx, 0
mov edx, runbtn
mov esi, runbtn.size
mcall 4
cmp_err 32,many_processes
 
call draw_string
.draw_status:
call draw_status
jmp still
 
mcall 12, 2
ret
draw_window:
start_draw_window
get_screen_size
mov cx,ax
sub cx,window_y+20
shl ecx,16
mov cx,window_y
shr eax,16
mov bx,ax
sub bx,window_x
shl ebx,15
mov bx,window_x
mov edx,[sc.work]
or edx,0x03000000
xor eax,eax
xor esi,esi
xor edi,edi
int 0x40
 
get_procinfo app
 
draw_string:
mpack ebx, 10, 380
mpack ecx, 38, 14
mov edx, 0xA0A0A0
mcall 13
mov ax,[app.width]
sub ax,20
mov [input_fn.width],ax
mov [run_but.width],ax
 
mpack ebx, 14, 41
mov ecx, 0
mov edx, filename
mov esi, [position]
mcall 4
ret
mov bx,5
shl ebx,16
mov bx,ax
add bx,15
mov cx,70
push cx
shl ecx,16
pop cx
mov edx,[sc.work_graph]
mov eax,38
int 0x40
 
draw_edit_box input_fn
draw_txt_button run_but
 
call draw_status_text
 
; <--- initialised data --->
DATA
stop_draw_window
ret
 
position dd filename.size
draw_status:
mov ebx,5*65536+(window_x-5-5)
mov ecx,(window_y-16)*65536+12
mov edx,[sc.work]
mov eax,13
int 0x40
draw_status_text:
mov edx,[status]
xor esi,esi
@@:
cmp [edx+esi],byte 0
je @f
inc esi
jmp @b
@@:
mov eax,4
mov ebx,10*65536+(window_y-14)
mov ecx,[sc.work_text]
int 0x40
ret
 
lsz header,\
ru, "‡ ¯ã᪠¯à®£à ¬¬ë",\
en, "Start program"
run_but txt_button 0,10,15,50,2,0,0,run_but_text,
if lang eq ru
run_but_text db '‡€“‘’ˆ’œ',0
else
run_but_text db 'RUN',0
end if
input_fn edit_box 0,10,30,0xffffff,0,0xaaaaaa,0,511,fn,ed_focus+\
ed_always_focus
 
lsz message,\
ru, "‚¢¥¤¨â¥ ¯ãâì ª ä ©«ã:",\
en, "Enter path to file:"
if lang eq ru
hello db '‚¢¥¤¨â¥ ¯®«­ë© ¯ãâì ª ä ©«ã ¨ ­ ¦¬¨â¥ Enter',0
bad_file_sys db '¥¨§¢¥áâ­ ï ä ©«®¢ ï á¨á⥬ ',0 ; 3
file_not_find db '” ©« ­¥ ­ ©¤¥­',0 ; 5
bad_fat_table db '’ ¡«¨æ  FAT à §àã襭 ',0 ; 9
acces_denyied db '„®áâ㯠§ ¯à¥é¥­',0 ; 10
device_error db 'Žè¨¡ª  ãáâனá⢠',0 ; 11
out_of_memory db '¥¤®áâ â®ç­® ¯ ¬ïâ¨',0 ; 30
file_not_executable db '” ©« ­¥ ï¥âáï ¨á¯®«­ï¥¬ë¬',0 ; 31
many_processes db '‘«¨èª®¬ ¬­®£® ¯à®æ¥áᮢ',0 ; 32
else
hello db 'Enter full path to file and press <Enter>',0
bad_file_sys db 'Unknown file system',0 ; 3
file_not_find db 'File not found',0 ; 5
bad_fat_table db 'FAT table corrupted',0 ; 9
acces_denyied db 'Access denied',0 ; 10
device_error db 'Device error',0 ; 11
out_of_memory db 'Out of memory',0 ; 30
file_not_executable db 'File is not executable',0 ; 31
many_processes db 'Too many processes',0 ; 32
end if
 
; lsz findbtn,\
; ru, " ©â¨...",\
; en, "Find..."
status dd hello
 
lsz runbtn,\
ru, "‡ ¯ãáâ¨âì",\
en, "Run"
file_info:
.mode dd 7
.flags dd 0
.par dd run_par
dd 0,0
.name rb 512
 
flags dw ?
 
fileinfo:
.mode dd 16
dd 0
.param dd 0
dd 0
.workarea dd workarea
fn rb 512
 
sz filename, "/rd/1/"
rb 122
 
 
; <--- uninitialised data --->
UDATA
workarea rb 4096
 
 
MEOS_APP_END
; <--- end of MenuetOS application --->
sc sys_color_table
app procinfo
run_par rb 256
par rb 256
app_end
/programs/system/run/trunk/run.txt
0,0 → 1,19
RUN - § ¯ã᪠«ª  ¯à®£à ¬¬ ¢ Š®«¨¡à¨Ž‘ ç¥à¥§ 70-î äã­ªæ¨î.
 
‡ ¯ã᪠¯à®£à ¬¬
‚¢¥¤¨â¥ ¯®«­ë© ¯ãâì ª ¨á¯®«­ï¥¬®¬ã ä ©«ã ¨ ­ ¦¬¨â¥ ª­®¯ªã "‡€“‘’ˆ’œ" ¨«¨
ª« ¢¨èã Enter.
‡ ¯ã᪠¯à®£à ¬¬ á ¯ à ¬¥âà ¬¨
®áâ ¢ì⥠¯à®¡¥« ¯®á«¥ ¯ã⨠ª ä ©«ã ¨ ¢¢®¤¨â¥ ¯ à ¬¥âàë. …᫨ ¢ ¯ã⨠ª ä ©«ã
¥áâì ¯à®¡¥«ë, ¥£® ­¥®¡å®¤¨¬® ¢ë¤¥«¨âì ª ¢ë窠¬¨ (⮣¤  ¯à®¡¥«®¬ à §¤¥«ïâì
­¥®¡ï§ â¥«ì­®).
à¨¬¥àë
/rd/1/tinypad /rd/1/menu.dat
"/hd0/1/long name dir with spaces/tinypad" /rd/1/autorun.dat
 
‚ᥣ® ¬®¦­® ¢¢®¤¨âì ¤® 512 ᨬ¢®«®¢.
ˆ¬ï ä ©«  ¨«¨ ¯ ¯ª¨ ¬®¦¥â ᮤ¥à¦ âì ¤® 260 ᨬ¢®«®¢.
…᫨ ¯à®¨§®è«  ®è¨¡ª , ®­  ®â®¡à §¨âáï ¢­¨§ã.
 
…¢â¨å®¢ Œ ªá¨¬ (Maxxxx32)
mailto:maxxxxm@mail.ru
/programs/system/run/trunk/txtbut.inc
0,0 → 1,127
;--------------------------------------------------------------------
;--- à¨á®¢ ­¨¥ ª­®¯ª¨ á ⥪á⮬ ¢ á¥à¥¤¨­¥ --------------------------
;--------------------------------------------------------------------
macro use_txt_button
{
txt_button:
.draw:
pusha
;--- ¯à®à¨á®¢ª  á ¬®© ª­®¯ª¨ ---
mov eax,8
mov ebx,[edi] ; [but.width]
mov ecx,[edi+4] ;[but.height]
mov edx,[edi+8];[but.id]
mov esi,[edi+12];[but.color]
int 0x40
;--- ⥪áâ ­  ­¥© ---
; áç¨â ¥¬ ª®«¨ç¥á⢮ ᨬ¢®«®¢
mov edx,[edi+20]
xor esi,esi
.check_next_symbol:
cmp [edx+esi],byte 0
je .str_end
inc esi ; ¢ esi ¤«¨­  áâப¨ ¢ ᨬ¢®« å
jmp .check_next_symbol
.str_end:
 
; ¢ëç¨á«ï¥¬ ª®®à¤¨­ âë
lea ebx,[esi*2+esi]
lea ebx,[ebx*2] ; ¢ ebx ¤«¨­  áâப¨ ¢ ¯¨ªá¥«ïå
 
;not ebx
neg ebx
add bx,[edi] ; [but.width]
sar bx,1
inc bx
add bx,[edi+2];[but.left] ; ¢ bx ¯®§¨æ¨ï á«¥¢ 
shl ebx,16
 
 
mov bx,[edi+4];[but.height]
sub bx,8-1
sar bx,1
add bx,[edi+6];[but.top] ; ¢ bx ¯®§¨æ¨ï ᢥàåã
 
; à¨á㥬 áâபã ⥪áâ 
mov ecx,[edi+16] ;[but.text_color]
shr eax,1
int 0x40
popa
ret
}
 
struc txt_button width,left,height,top,id,color,text_color,text_ptr,\
proc_addres
{
.width dw width ;+0
.left dw left ;+2
.height dw height ;+4
.top dw top ;+6
.id dd id ;+8
.color dd color ;+12
.text_color dd text_color ;+16
.text_ptr dd text_ptr ;+20
.proc_addres dd proc_addres+0 ;+24
}
but_struc_size=24+4
macro draw_txt_buttons start,end
{
mov edi,start
mov ecx,((end-start)/but_struc_size)
@@:
call txt_button.draw
add edi,but_struc_size
loop @b
}
 
macro txt_but_set_sys_color start,end,color_table
{
mov edi,start
mov esi,color_table
mov ecx,((end-start)/but_struc_size)
@@:
push dword [esi+24]
pop dword [edi+12]
push dword [esi+28]
pop dword [edi+16]
add edi,but_struc_size
loop @b
}
 
macro txt_but_ev start,end
{
mov edi,start
mov ecx,((end-start)/but_struc_size)
.txt_but_next:
cmp ah,[edi+8]
jne @f
cmp dword [edi+24],0
je @f
pusha
call dword [edi+24]
popa
@@:
add edi,but_struc_size
loop .txt_but_next
}
 
macro draw_txt_button ptr
{
mov edi,ptr
call txt_button.draw
}
 
macro set_sys_colors_txt_button but,sc
{
mov esi,sc
mov edi,but
push dword [esi+24]
pop dword [edi+12]
push dword [esi+28]
pop dword [edi+16]
}
 
macro event_txt_button but,sc
{
 
}