2016-11-25 18:19:45 +03:00
|
|
|
; Run with OpenDialog ;
org 0
use32
STACK_SIZE equ 256
REDRAW_EVENT equ 1
KEY_EVENT equ 2
BUTTON_EVENT equ 3
MOUSE_EVENT equ 6
BUTTON_RUN equ 10
BUTTON_BROWSE equ 20
MENUET01 db 'MENUET01'
version dd 1
program.start dd start_
program.end dd data_
program.memory dd end_ + STACK_SIZE
program.stack dd end_ + STACK_SIZE
program.params dd 0
program.path dd 0
include 'lang.inc'
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
; ======================================================================= ;
start_:
mov byte [file_info], 7
; set.event
mov eax, 40
mov ebx, 39
int 64
push sz_box_lib
call load.library
mov [box_lib], eax
push dword[box_lib]
push sz_edit_box
call getprocaddress
mov [edit_box_draw], eax
push dword[box_lib]
push sz_edit_box_key
call getprocaddress
mov [edit_box_key], eax
push dword[box_lib]
push sz_edit_box_mouse
call getprocaddress
mov [edit_box_mouse], eax
push dword[box_lib]
push sz_edit_box_set_text
call getprocaddress
mov [edit_box_set_text], eax
push sz_proc_lib
call load.library
mov [proc_lib], eax
push dword[proc_lib]
push sz_OpenDialog_init
call getprocaddress
mov [opendialog_init], eax
push dword[proc_lib]
push sz_OpenDialog_start
call getprocaddress
mov [opendialog_start], eax
; memory.allocate:
mov eax, 68
mov ebx, 12
mov ecx, 4096 + 4096 + 4096
int 64
mov [od.procinfo], eax
add eax, 1024
mov [od.filename_area], eax
add eax, 4096 - 1024
mov [od.opendir_path], eax
add eax, 4096
mov [od.openfile_path], eax
push od
call [opendialog_init]
; get.screen.size
mov eax, 61
mov ebx, 1
int 64
mov [screen], eax
movzx eax, word[screen.width]
shr eax, 3
lea eax, [eax*2 + eax]
add eax, 90
mov [window.width], eax
; skin.height
mov eax, 48
mov ebx, 4
int 64
add eax, 100
mov [window.height], eax
movzx eax, word[screen.width]
sub eax, [window.width]
shr eax, 1
mov [window.left], eax
movzx eax, word[screen.height]
sub eax, [window.height]
sub eax, 100
mov [window.top], eax
mov eax, [window.width]
sub eax, 80
mov [edit1.width], eax
mov eax, [od.openfile_path]
mov [edit1.text], eax
call on_redraw
; ----------------------- ;
.loop:
; wait.event
mov eax, 10
int 64
cmp eax, REDRAW_EVENT
jne .check_key
call on_redraw
jmp .loop
; ----------------------- ;
.check_key:
cmp eax, KEY_EVENT
jne .check_button
mov eax, 2
int 64
cmp ah, 13
jne .no_key_enter
call on_button_run
jmp .loop
; ----------------------- ;
.no_key_enter:
cmp ah, 185
jne .no_key_insert
call on_button_browse
jmp .loop
.no_key_insert:
push edit1
call [edit_box_key]
jmp .loop
; ----------------------- ;
.check_button:
cmp eax, BUTTON_EVENT
jne .check_mouse
; get.button.number
mov eax, 17
int 64
cmp ah, 1
jne .check_button_run
; program.terminate
or eax, -1
int 64
; ----------------------- ;
.check_button_run:
cmp ah, BUTTON_RUN
jne .check_button_browse
call on_button_run
jmp .loop
; ----------------------- ;
.check_button_browse:
cmp ah, BUTTON_BROWSE
jne .loop
call on_button_browse
jmp .loop
; ----------------------- ;
.check_mouse:
cmp eax, MOUSE_EVENT
jne .loop
push edit1
call [edit_box_mouse]
jmp .loop
; ======================================================================= ;
on_button_run:
push dword[edit1.text]
call extractrunpathandparams
;file.run:
mov eax, 70
mov ebx, file_info
int 64
mov dl, byte[lastendpath]
mov ecx, [ptrlastendpath]
mov [ecx], dl
test eax, eax
jnge .error
mov [runresult], dword sz_Program_run_successfully
jmp .exit
.error:
; ----------------------- ;
.5:
cmp al, -5
jne .31
mov [runresult], dword sz_File_not_found
jmp .exit
; ----------------------- ;
.31:
cmp al, -31
jne .32
mov [runresult], dword sz_File_is_not_executable
jmp .exit
; ----------------------- ;
.32:
cmp al, -32
jne .10
mov [runresult], dword sz_Too_many_processes
jmp .exit
; ----------------------- ;
.10:
cmp al, -10
jne .30
mov [runresult], dword sz_Access_denied
jmp .exit
; ----------------------- ;
|