FASM - checking for "rolled up" window

git-svn-id: svn://kolibrios.org@2059 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Marat Zakiyanov (Mario79) 2011-08-18 15:20:00 +00:00
parent 8e1566eec3
commit 9934173476
3 changed files with 433 additions and 450 deletions

View File

@ -1,8 +1,6 @@
@fasm.exe -m 16384 ..\..\..\develop\libraries\box_lib\trunk\box_lib.asm box_lib.obj
@kpack box_lib.obj
@erase lang.inc
@echo lang fix en >lang.inc
@fasm fasm.asm fasm
@fasm -m 16384 fasm.asm fasm
@erase lang.inc
@kpack fasm
@pause

View File

@ -1,8 +1,6 @@
@fasm.exe -m 16384 ..\..\..\develop\libraries\box_lib\trunk\box_lib.asm box_lib.obj
@kpack box_lib.obj
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm fasm.asm fasm
@fasm -m 16384 fasm.asm fasm
@erase lang.inc
@kpack fasm
@pause

View File

@ -4,6 +4,7 @@
;; Copyright (c) 1999-2006, Tomasz Grysztar ;;
;; All rights reserved. ;;
;; ;;
;; KolibriOS port by KolibriOS Team ;;
;; Menuet port by VT ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -19,9 +20,8 @@ APP_MEMORY = 0x00800000
;; Menuet header
appname equ "flat assembler "
use32
;---------------------------------------------------------------------
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
@ -30,7 +30,7 @@ use32
dd stacktop ; required amount of memory
dd stacktop ; stack
dd params,cur_dir_path ; parameters,icon
;---------------------------------------------------------------------
include 'lang.inc'
include '../../../macros.inc'
purge add,sub ; macros.inc does incorrect substitution
@ -40,10 +40,8 @@ include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
include '../../../develop/libraries/box_lib/load_lib.mac'
@use_library
center fix true
;---------------------------------------------------------------------
START: ; Start of execution
mov edi, fileinfos
mov ecx, (fileinfos_end-fileinfos)/4
@ -89,11 +87,10 @@ START: ; Start of execution
cmp [esi], dword ',run'
jne @f
mov [_run_outfile],1
@@:
@@:
mov [_mode],CONSOLE_MODE
jmp start
;---------------------------------------------------------------------
start_1:
;sys_
load_libraries l_libs_start,load_lib_end
@ -101,17 +98,17 @@ load_libraries l_libs_start,load_lib_end
cmp eax,-1
jne @f
mcall -1 ;exit if not open box_lib.obj
@@:
@@:
mcall 40,0x27 ;¬ áª  á¨á⥬­ëå ᮡë⨩
get_sys_colors 1,0
edit_boxes_set_sys_color edit1,editboxes_end,sc
check_boxes_set_sys_color ch1_dbg,ch1_dbg+ch_struc_size,sc
; OpenDialog initialisation
;---------------------------------------------------------------------
get_sys_colors 1,0
edit_boxes_set_sys_color edit1,editboxes_end,sc
check_boxes_set_sys_color ch1_dbg,ch1_dbg+ch_struc_size,sc
;---------------------------------------------------------------------
; OpenDialog initialisation
push dword OpenDialog_data
call dword [OpenDialog_Init]
;---------------------------------------------------------------------
red: ; Redraw
call draw_window
@ -125,7 +122,6 @@ still:
je red ; Redraw request
dec eax
jne button ; Button in buffer
key: ; Key
mov al,2 ; Read it and ignore
mcall
@ -136,15 +132,13 @@ key: ; Key
call [edit_box_key]
push dword edit3
call [edit_box_key]
jmp still
;---------------------------------------------------------------------
call_mouse:
call mouse
jmp still
;---------------------------------------------------------------------
button: ; Button in Window
mov al,17
mcall
@ -152,12 +146,12 @@ button: ; Button in Window
jne noclose
or eax,-1
mcall
;---------------------------------------------------------------------
noclose:
cmp ah,5 ;press button for OpenDialog
jne @f
call fun_opn_dlg
@@:
@@:
cmp ah,2 ; Start compiling
je start
cmp ah,3 ; Start compiled file
@ -168,7 +162,8 @@ noclose:
mcall 70,file_info_start
; xor ecx,ecx
jmp still
norunout:
;---------------------------------------------------------------------
norunout:
cmp ah,4
jnz norundebug
@ -176,12 +171,10 @@ noclose:
call make_fullpaths
mcall 70,file_info_debug
jmp still
norundebug:
;---------------------------------------------------------------------
norundebug:
jmp still
;---------------------------------------------------------------------
mouse:
push dword edit1
call [edit_box_mouse]
@ -192,14 +185,11 @@ mouse:
push dword ch1_dbg
call [check_box_mouse]
ret
;---------------------------------------------------------------------
draw_window:
pusha
mcall 12,1 ; Start of draw
;get_sys_colors 1,0
;get_sys_colors 1,0
xor eax,eax
mov ebx,100*65536+280
mov ecx,90*65536+260
@ -210,15 +200,17 @@ draw_window:
mcall 9,PROCESSINFO,-1
mov eax,[PROCESSINFO+70] ;status of window
test eax,100b
jne .end
cmp dword[pinfo.box.width],230 ; ïðîâåðÿåì øèðèíó îêíà
jge @f
mov dword[pinfo.box.width],230 ; åñëè îêíî î÷åíü óçêîå, óâåëè÷èâàåì øèðèíó äëÿ èçáåæàíèÿ ãëþêîâ
@@:
@@:
mpack ecx,1,1
mov ebx,[pinfo.box.width]
sub ebx,10
mov eax,8
mov edx,0x4000000B
mpack ebx,[pinfo.box.width],MAGIC1
@ -230,8 +222,7 @@ draw_window:
mcall ,,,0x00000003
madd ecx, (14*3+16)/3+1,0
mcall ,,,4
;button for OpenDialog [..]
;button for OpenDialog [..]
mov ebx, 5*65536+47
mov ecx, 33*65536+14
mcall ,,,5
@ -242,11 +233,12 @@ draw_window:
mov edx,text
mov esi,text.line_size
mov eax,4
mcall ;InFile
add ebx, 16 ;14
add edx,text.line_size
mcall ;OutFile
mov ecx,[sc.work_button_text]
add ebx, 16 ;14
add edx,text.line_size
@ -272,7 +264,8 @@ draw_window:
cmp al,MAX_PATH
jbe @f
mov al,MAX_PATH
@@: movzx esi,al
@@:
movzx esi,al
call draw_messages
@ -290,12 +283,11 @@ draw_window:
call [edit_box_draw]
push dword ch1_dbg
call [check_box_draw]
.end:
mcall 12,2 ; End of Draw
popa
ret
;---------------------------------------------------------------------
bottom_right dd ?
align 4
@ -312,12 +304,12 @@ fun_opn_dlg: ;
cmp byte[edi-2],'/'
jne @f
mov byte[edi-2],0 ;¥á«¨ ¢ ª®­æ¥ ¯ã⨠¥áâì á«¥è, â® ¯ãâì 㪮à ç¨¢ ¥¬ ­  1 ᨬ¢®«
@@:
@@:
push dword OpenDialog_data
call dword [OpenDialog_Start]
cmp [OpenDialog_data.status],2
je @f
xor al,al
mov edi,dword[edit3.text]
mov ebx,edi ;copy text pointer
@ -326,8 +318,9 @@ fun_opn_dlg: ;
repne scasb
cmp byte[edi-2],'/'
jne .no_slash
dec edi ;¥á«¨ ¢ ª®­æ¥ ¯ã⨠¥áâì á«¥è, â® ¯ãâì 㪮à ç¨¢ ¥¬ ­  1 ᨬ¢®«
.no_slash:
.no_slash:
mov byte[edi-1],'/' ;áâ ¢¨¬ ¢ ª®­æ¥ ¯ã⨠᫥è
mov byte[edi],0 ;®â१ ¥¬ ¨¬ï ­ ©¤¥­­®£® ä ©« 
sub edi,ebx ;edi = strlen(edit3.text)
@ -345,28 +338,30 @@ fun_opn_dlg: ;
mov esi,[edit2.text]
xor eax,eax
cld
.cycle:
.cycle:
lodsb
test eax,eax
jnz .cycle
sub esi,4
cmp esi,[edit2.text]
jle .short_fn
mov byte[esi],0
sub dword [edit2.size],4
sub dword [edit2.pos],4
.short_fn:
.short_fn:
push dword edit1
call dword [edit_box_draw]
push dword edit2
call dword [edit_box_draw]
push dword edit3
call dword [edit_box_draw]
@@:
@@:
popad
ret
;---------------------------------------------------------------------
draw_messages:
mov eax,13 ; clear work area
mpack ebx,7-2,[pinfo.box.width]
@ -409,10 +404,9 @@ _sx = 6
mcall
pop ecx ebx
ret
;---------------------------------------------------------------------
; DATA
;---------------------------------------------------------------------
if lang eq ru
text:
db ' ‚å” ©«:'
@ -461,40 +455,39 @@ end if
system_dir1 db '/sys/lib/'
lib1_name db 'proc_lib.obj',0
;---------------------------------------------------------------------
align 4
import_box_lib:
edit_box_draw dd aEdit_box_draw
edit_box_key dd aEdit_box_key
edit_box_mouse dd aEdit_box_mouse
edit_box_set_text dd aEdit_box_set_text
;version_ed dd aVersion_ed
edit_box_draw dd aEdit_box_draw
edit_box_key dd aEdit_box_key
edit_box_mouse dd aEdit_box_mouse
edit_box_set_text dd aEdit_box_set_text
;version_ed dd aVersion_ed
check_box_draw dd aCheck_box_draw
check_box_mouse dd aCheck_box_mouse
;version_ch dd aVersion_ch
check_box_draw dd aCheck_box_draw
check_box_mouse dd aCheck_box_mouse
;version_ch dd aVersion_ch
dd 0,0
aEdit_box_draw db 'edit_box',0
aEdit_box_key db 'edit_box_key',0
aEdit_box_mouse db 'edit_box_mouse',0
aEdit_box_set_text db 'edit_box_set_text',0
;aVersion_ed db 'version_ed',0
aCheck_box_draw db 'check_box_draw',0
aCheck_box_mouse db 'check_box_mouse',0
;aVersion_ch db 'version_ch',0
aEdit_box_draw db 'edit_box',0
aEdit_box_key db 'edit_box_key',0
aEdit_box_mouse db 'edit_box_mouse',0
aEdit_box_set_text db 'edit_box_set_text',0
;aVersion_ed db 'version_ed',0
aCheck_box_draw db 'check_box_draw',0
aCheck_box_mouse db 'check_box_mouse',0
;aVersion_ch db 'version_ch',0
;---------------------------------------------------------------------
align 4
import_proc_lib:
OpenDialog_Init dd aOpenDialog_Init
OpenDialog_Start dd aOpenDialog_Start
dd 0,0
aOpenDialog_Init db 'OpenDialog_init',0
aOpenDialog_Start db 'OpenDialog_start',0
OpenDialog_Init dd aOpenDialog_Init
OpenDialog_Start dd aOpenDialog_Start
dd 0,0
aOpenDialog_Init db 'OpenDialog_init',0
aOpenDialog_Start db 'OpenDialog_start',0
;---------------------------------------------------------------------
;library structures
l_libs_start:
lib0 l_libs lib0_name, cur_dir_path, library_path, system_dir0, err_message_found_lib0, head_f_l, import_box_lib, err_message_import0, head_f_i
@ -506,7 +499,6 @@ edit2 edit_box 153, 56, 17, 0xffffff, 0xff, 0x80ff, 0, 0x8000,(path-outfile-1),
edit3 edit_box 153, 56, 33, 0xffffff, 0xff, 0x80ff, 0, 0x8000,(path_end-path-1), path, mouse_dd, 0, 6,6
editboxes_end:
ch1_dbg check_box 5, 49, 6, 12, 0xffffff, 0x80ff, 0, s_dbgdescr,(s_dbgdescr_end-s_dbgdescr)
;---------------------------------------------------------------------
align 4
OpenDialog_data:
@ -544,9 +536,9 @@ dd Filter.end - Filter
db 'ASM',0
.end:
db 0
;---------------------------------------------------------------------
mouse_dd dd 0 ;íóæíî äëÿ Shift-à â editbox
;---------------------------------------------------------------------
infile db 'example.asm'
times MAX_PATH-$+infile db 0
outfile db 'example'
@ -555,8 +547,7 @@ path db '/rd/1//' ;OpenDialog
times MAX_PATH-$+path db 0
path_end:
lf db 13,10,0
;---------------------------------------------------------------------
mov_param_str:
cld
@@:
@ -570,9 +561,7 @@ mov_param_str:
xor al,al
stosb
ret
;---------------------------------------------------------------------
start:
cmp [_mode],NORMAL_MODE
jne @f
@ -582,10 +571,9 @@ start:
mov esi,_logo
call display_string
;
; Fasm native code
;
;---------------------------------------------------------------------
; Fasm native code
;---------------------------------------------------------------------
mov [input_file],infile
mov [output_file],outfile
@ -627,7 +615,7 @@ start:
call display_number
mov esi,_seconds_suffix
call display_string
display_bytes_count:
display_bytes_count:
mov eax,[written_size]
call display_number
mov esi,_bytes_suffix
@ -644,8 +632,7 @@ start:
mcall
@@:
jmp exit_program
;---------------------------------------------------------------------
include 'system.inc'
include 'version.inc'
include 'errors.inc'
@ -658,7 +645,7 @@ include 'x86_64.inc'
include 'tables.inc'
include 'symbdump.inc'
include 'messages.inc'
;---------------------------------------------------------------------
title db appname,VERSION_STRING,0
_logo db 'flat assembler version ',VERSION_STRING,13,10,0