Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 474 → Rev 470

/programs/network/smtps/trunk/smtps.asm
8,7 → 8,7
;; Compile with FASM for Menuet ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
include 'lang.inc'
version equ '0.1'
 
use32
23,23 → 23,27
dd 0xffff0
dd 0,0
 
include 'macros.inc'
 
save_file:
 
; cmp [file_start],0x100000+10
; jbe nosub
; sub [file_start],8
; nosub:
pusha
 
cmp [file_start],0x100000+10
jbe nosub
sub [file_start],8
nosub:
 
mov edi,[file_start]
 
mov eax,[file_start]
sub eax,0x100000
mov [files+8],eax
 
mov eax,58
mov ebx,files
mov [ebx+12],eax
 
mov eax,70
int 0x40
 
popa
 
ret
 
 
47,15 → 51,12
 
mov [file_start],0x100000
 
mov eax,70
mov eax,58
mov ebx,filel
int 0x40
 
test eax,eax
jz @f
cmp eax,6
jnz notfound
@@:
cmp eax,0
jne notfound
add [file_start],ebx
notfound:
 
62,7 → 63,7
 
mov edi,I_END
mov ecx,60*120
mov al,32
mov eax,32
cld
rep stosb
 
629,10 → 630,19
mov eax,0 ; draw window
mov ebx,5*65536+400
mov ecx,5*65536+200
mov edx,0x13ffffff
mov edi,labelt
mov edx,[wcolor]
add edx,0x03ffffff
mov esi,0x80555599
mov edi,0x00ffffff
int 0x40
 
mov eax,4 ; label
mov ebx,9*65536+8
mov ecx,0x10ffffff
mov edx,labelt
mov esi,labellen-labelt
int 0x40
 
mov eax,8 ; button: open socket
mov ebx,23*65536+22
mov ecx,169*65536+10
736,7 → 746,7
db ' '
db ' Open SMTP server port 25 Close SMTP '
 
db 'x' ; <- END MARKER, DONT DELETE
db 'x <- END MARKER, DONT DELETE '
 
 
irc_server_ip db 192,168,1,1
744,10 → 754,10
file_start dd 0x100000
 
files:
dd 2,0,0,?,0x100000
dd 1,0,0,0x100000,0xd0000
db '/rd/1/smtps.txt',0
filel:
dd 0,0,0,0x100000,0x100000
dd 0,0,10000/512,0x100000,0xd0000
db '/rd/1/smtps.txt',0
 
 
830,6 → 840,10
 
numtext db ' '
 
labelt db 'Tiny SMTP email server v ',version,0
wcolor dd 0x000000
 
labelt db 'Tiny SMTP email server v ',version
labellen:
 
 
I_END:
/programs/fs/kfar/trunk/filetool.inc
File deleted
/programs/fs/kfar/trunk/kfar.asm
5,62 → 5,20
dd i_end
memsize dd mem
dd stacktop
dd 0, app_path
dd 0, 0
 
include 'lang.inc'
include 'font.inc'
include 'sort.inc'
include 'kglobals.inc'
include 'memalloc.inc'
include 'dialogs.inc'
include 'viewer.inc'
include 'tools.inc'
include 'filetool.inc'
 
start:
mov edi, tolower_table
push 'A'
pop ecx
xor eax, eax
@@:
stosb
inc eax
loop @b
add al, 0x20
mov cl, 'Z'-'A'+1
@@:
stosb
inc eax
loop @b
sub al, 0x20
mov cl, '€'-'Z'-1
@@:
stosb
inc eax
loop @b
add al, 0x20
mov cl, ''-'€'
@@:
stosb
inc eax
loop @b
add al, 0x30
mov cl, 'Ÿ'-''+1
@@:
stosb
inc eax
loop @b
sub al, 0x50
mov cl, 256-'Ÿ'-1
@@:
stosb
inc eax
loop @b
mov byte [edi-256+'ð'], 'ñ'
push 68
pop eax
push 11
pop ebx
int 0x40
mov eax, mem
call mf_init
call init_console
call draw_window
push 66
69,13 → 27,29
pop ebx
mov ecx, ebx
int 40h ; set keyboard mode to scancodes
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, 200
mov [panel1_nfa], eax
mov [panel2_nfa], eax
mov ecx, 200*4 + 32 + 200*304
call pgalloc
mov eax, 200*4 + 32 + 200*304
push eax
call mf_alloc
mov [panel1_files], eax
call pgalloc
pop eax
call mf_alloc
mov [panel2_files], eax
test eax, eax
jz exit
83,13 → 57,9
jz exit
mov [panel1_sortmode], 0 ; sort by name
mov [panel2_sortmode], 0
push 2 ; "á।­¨©" ä®à¬ â
pop eax
mov [panel1_colmode], eax
mov [panel2_colmode], eax
mov [num_screens], 1
mov ecx, 0x1000
call pgalloc
mov eax, 8
call mf_alloc
mov [screens], eax
test eax, eax
jz exit
96,154 → 66,14
mov ecx, panels_vtable
mov [eax], ecx
mov [active_screen_vtable], ecx
; load libini.obj and kfar.ini
mov eax, libini_name
mov esi, ini_import
push 2
pop ebp ; we use version 2 of libini
call load_dll_and_import
test eax, eax
jnz .noini
mov edi, app_path
or ecx, -1
repnz scasb
mov dword [edi-1], '.ini'
mov byte [edi+3], 0
push 1
push dword aConfirmDelete
push dword aConfirmations
push dword app_path
call [ini.get_int]
mov [bConfirmDelete], al
push 0
push dword aConfirmDeleteIncomplete
push dword aConfirmations
push dword app_path
call [ini.get_int]
mov [bConfirmDeleteIncomplete], al
mov ecx, 0x1000
call xpgalloc
test eax, eax
jz .skip_assoc
@@:
mov edx, eax
push edx ecx
push ecx
push edx
push dword aAssociations
push dword app_path
call [ini.query_sec]
pop ecx edx
cmp eax, ecx
jbe @f
add ecx, ecx
call xpgrealloc
test eax, eax
jz .skip_assoc
jmp @b
@@:
cmp ecx, 0x1000
jbe @f
mov ecx, eax
call xpgrealloc ; must succeed, because we decrease size
mov edx, eax
@@:
mov [associations], edx
xor ebp, ebp
xor esi, esi
.skip_assoc:
mov edi, saved_file_name
push dword nullstr
push 512
push edi
push dword aShortcut
push dword aFolderShortcuts
push dword app_path
call [ini.get_str]
cmp byte [edi], 0
jz .shortcut_cont
or ecx, -1
xor eax, eax
repnz scasb
not ecx
cmp ecx, 2
jz @f
cmp byte [edi-2], '/'
jnz @f
mov byte [edi-2], 0
dec ecx
@@:
mov al, [aShortcut.d]
push esi
inc esi
mov [FolderShortcuts+(eax-'0')*4], esi
lea esi, [esi+ecx-1]
push esi
and esi, 0xFFF
cmp esi, ecx
pop esi
ja .norealloc
mov edx, ebp
mov ecx, esi
call xpgrealloc
test eax, eax
jnz @f
mov edi, FolderShortcuts
mov ecx, 10
rep stosd
jmp .skip_shortcuts
@@:
mov ebp, eax
.norealloc:
pop edi
add edi, ebp
mov ecx, saved_file_name
@@:
mov al, [ecx]
inc ecx
stosb
test al, al
jnz @b
.shortcut_cont:
inc [aShortcut.d]
cmp [aShortcut.d], '9'
jbe .skip_assoc
mov esi, FolderShortcuts
mov ecx, 10
dec ebp
.l3:
lodsd
test eax, eax
jz @f
add [esi-4], ebp
@@:
loop .l3
.skip_shortcuts:
.noini:
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
call draw_keybar
call draw_cmdbar
mov [prev_dir], 0
mov ebp, panel1_data
call calc_colwidths
call read_folder
call draw_panel
mov [bSilentFolderMode], 1
mov ebp, panel2_data
call calc_colwidths
call read_folder
call draw_panel
event:
366,9 → 196,6
add esi, 5-1
int 40h
.resize_draw:
mov ecx, [MemForImage]
call pgfree
and [MemForImage], 0
call init_console
; call draw_window
call draw_keybar
587,37 → 414,28
ret
 
new_screen:
; in: ecx=sizeof(screen data), edx->vtable
; out: ebp=pointer or NULL, eax!=0 if successful
; destroys ebx,ecx
call xpgalloc
call xmalloc
test eax, eax
jnz @f
ret
@@:
mov ebp, eax
mov ebx, [num_screens]
inc ebx
shl ebx, 3
mov eax, [screens]
mov ecx, [num_screens]
inc ecx
shl ecx, 3
test ecx, 0xFFF
jnz .norealloc
push edx
mov edx, eax
call xpgrealloc
pop edx
call xrealloc
test eax, eax
jnz @f
mov ecx, ebp
call pgfree
mov eax, ebp
call mf_free
xor eax, eax
ret
@@:
mov [screens], eax
.norealloc:
inc [num_screens]
mov [eax+ecx-8], edx
mov [eax+ecx-4], ebp
mov [eax+ebx-8], edx
mov [eax+ebx-4], ebp
mov eax, [num_screens]
dec eax
mov [active_screen], eax
647,16 → 465,12
add ecx, ecx
rep movsd
dec [num_screens]
mov ecx, [num_screens]
shl ecx, 3
test ecx, 0xFFF
jnz .norealloc
mov edx, [screens]
call pgrealloc ; must succeed, because we decrease size
mov [screens], eax
.norealloc:
pop ecx
call pgfree
mov ebx, [num_screens]
shl ebx, 3
mov eax, [screens]
call mf_realloc ; must succeed, because we decrease size
pop eax
call mf_free
and [active_screen], 0
 
change_screen:
677,8 → 491,7
add eax, 8
mov esi, eax
mul [num_screens]
mov ecx, eax
call xpgalloc
call xmalloc
test eax, eax
jnz @f
ret
740,7 → 553,7
mul esi
add eax, ebx
push 1
push dword aScreens
push aScreens
push eax
call menu
cmp eax, -1
749,8 → 562,8
div esi
mov [active_screen], eax
@@:
mov ecx, ebx
call pgfree
mov eax, ebx
call mf_free
jmp change_screen
 
panels_OnKey:
774,38 → 587,10
; call draw_panel
; ret
jmp draw_panel
.insert:
lea eax, [ecx*4]
add eax, [ebp + panel1_files - panel1_data]
mov eax, [eax]
cmp word [eax+40], '..'
jnz @f
cmp byte [eax+42], 0
jz .insert.down
@@:
xor byte [eax+303], 1
mov edx, [eax+32]
test byte [eax+303], 1
mov eax, [eax+36]
jnz .insert.increase
sub dword [ebp + panel1_selected_size - panel1_data], edx
sbb dword [ebp + panel1_selected_size+4 - panel1_data], eax
dec [ebp + panel1_selected_num - panel1_data]
jmp .insert.down
.insert.increase:
add dword [ebp + panel1_selected_size - panel1_data], edx
adc dword [ebp + panel1_selected_size+4 - panel1_data], eax
inc [ebp + panel1_selected_num - panel1_data]
.insert.down:
inc ecx
cmp ecx, [ebp + panel1_numfiles - panel1_data]
jae .done_redraw
jmp @f
.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
814,45 → 599,22
mov [ebp + panel1_start - panel1_data], ecx
jmp .done_redraw
.left:
test ecx, ecx
jnz @f
ret
@@:
mov eax, [ebp + panel1_colsz - panel1_data]
sub ecx, eax
jecxz .ret
sub ecx, [ebp + panel1_colsz - panel1_data]
jae @f
xor ecx, ecx
@@:
mov [ebp + panel1_index - panel1_data], ecx
.finalize_left:
cmp ecx, edx
jae .done_redraw
sub edx, eax
sub edx, [ebp + panel1_colsz - panel1_data]
jae @f
xor edx, edx
@@:
mov [ebp + panel1_start - panel1_data], edx
jmp .done_redraw
.pgup:
mov eax, [ebp + panel1_colst - panel1_data]
dec eax
jnz @f
inc eax
@@:
test ecx, ecx
jnz @f
ret
@@:
sub ecx, eax
jae @f
xor ecx, ecx
@@:
mov [ebp + panel1_index - panel1_data], ecx
dec ecx
jmp .finalize_left
.right:
mov eax, [ebp + panel1_colsz - panel1_data]
add ecx, eax
add ecx, [ebp + panel1_colsz - panel1_data]
cmp ecx, [ebp + panel1_numfiles - panel1_data]
jb @f
mov ecx, [ebp + panel1_numfiles - panel1_data]
859,10 → 621,9
dec ecx
@@:
mov [ebp + panel1_index - panel1_data], ecx
.finalize_right:
cmp ecx, ebx
jb .done_redraw
add ebx, eax
add ebx, [ebp + panel1_colsz - panel1_data]
cmp ebx, [ebp + panel1_numfiles - panel1_data]
jbe @f
mov ebx, [ebp + panel1_numfiles - panel1_data]
873,21 → 634,6
@@:
mov [ebp + panel1_start - panel1_data], ebx
jmp .done_redraw
.pgdn:
mov eax, [ebp + panel1_colst - panel1_data]
dec eax
jnz @f
inc eax
@@:
add ecx, eax
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
inc ecx
jmp .finalize_right
.tab:
xor [active_panel], panel1_data xor panel2_data
call draw_cmdbar
915,28 → 661,12
jnz .enter_folder
call find_extension
jc .run_app
jnz .run_app
.run_association:
cmp byte [edi], 0
jz .l1
cmp byte [edi], ';'
jnz @f
.l1:
ret
@@:
mov esi, edi
@@:
lodsb
test al, al
jz @f
cmp al, ';'
jnz @b
dec esi
mov byte [esi], 0
mov [restore_semicolon], esi
@@:
mov eax, [edi+4]
.run_association2:
mov [execparams], execdata
mov [execptr], edi
mov [execptr], eax
jmp .dorun
.run_app:
mov [execptr], execdata
969,14 → 699,7
xor edx, edx
cmp [execparams], edx
jz .nofasm
mov esi, [execptr]
@@:
lodsb
test al, al
jnz @b
mov eax, [esi-5]
or eax, 0x20202020
cmp eax, 'fasm'
cmp [execptr], fasm
jnz .nofasm
cmp edi, execdata+(execdataend-execdata)/2
ja .bigfilename
1026,19 → 749,13
push 70
pop eax
int 40h
xor esi, esi
xchg esi, [restore_semicolon]
test esi, esi
jz @f
mov byte [esi], ';'
@@:
neg eax
js @f
push dword aContinue
push aContinue
mov esi, esp
call get_error_msg
push eax
push dword aRunError
push aRunError
mov eax, esp
push esi
push 1
1046,7 → 763,7
push 2
push -1
push -1
push dword aError
push aError
call SayErr
add esp, 3*4
ret
1067,14 → 784,8
pop esi
.bigfilename:
mov eax, aFileNameTooBig
.l2:
xor esi, esi
xchg esi, [restore_semicolon]
test esi, esi
jz @f
mov byte [esi], ';'
@@:
push dword aContinue
push aContinue
mov esi, esp
push eax
mov eax, esp
1084,21 → 795,21
push 1
push -1
push -1
push dword aError
push aError
call SayErr
add esp, 2*4
ret
.bigcmdline:
mov eax, aCmdLineTooBig
jmp .l2
jmp @b
.bigfoldername2:
mov byte [ecx], 0
.bigfoldername:
mov eax, aFolderNameTooBig
jmp .l2
jmp @b
.copytoself:
mov eax, aCannotCopyToSelf
jmp .l2
jmp @b
.enter_folder:
lea esi, [ecx+40]
cmp word [esi], '..'
1229,7 → 940,6
mov [ebx+dirinfo.dirdata-dirinfo], driveinfo
mov [ebx+dirinfo.name-dirinfo], tmpname
mov byte [tmpname], '/'
xor edx, edx
xor ecx, ecx
.drive_loop_e:
mov byte [tmpname+1], 0
1255,20 → 965,17
mov ebx, dirinfo
test eax, eax
jnz .drive_loop_i_done
add ecx, 32+8
push ecx
and ecx, 0xFFF
cmp ecx, 32+8
pop ecx
ja @f
call xpgrealloc
mov edx, eax
mov eax, 32+8
call xmalloc
test eax, eax
jnz @f
pop eax
ret
jz .drive_loop_i_done
jecxz @f
mov [ecx], eax
@@:
lea edi, [edx+ecx-32]
and dword [eax], 0
mov [eax+4], ecx
mov ecx, eax
lea edi, [eax+8]
mov esi, tmpname
@@:
lodsb
1293,20 → 1000,6
jmp .drive_loop_e
.drive_loop_e_done:
and [ebx+dirinfo.first-dirinfo], 0
mov edi, edx
xor esi, esi
add ecx, edx
@@:
and dword [edi], 0
mov dword [edi+4], esi
mov esi, edi
add edi, 32+8
cmp edi, ecx
jae @f
mov [esi], edi
jmp @b
@@:
mov ecx, edx
lea edi, [ebp + panel1_dir - panel1_data]
.find_cur_drive_loop:
push edi
1320,13 → 1013,12
inc edi
jmp @b
@@:
cmp dword [ecx], 0
cmp dword [ecx+4], 0
jz @f
pop edi
mov ecx, [ecx]
mov ecx, [ecx+4]
jmp .find_cur_drive_loop
@@:
mov ecx, edx
.cur_drive_found:
pop edi
push 1
1357,8 → 1049,17
stosb
test al, al
jnz @b
mov ecx, edx
call pgfree
@@:
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
.shift_f5:
1616,17 → 1317,17
cmp eax, 6
jz .copyreadok
push esi
push dword aCannotReadFile
push aCannotReadFile
call get_error_msg
push eax
mov eax, esp
push dword RetryOrCancelBtn
push RetryOrCancelBtn
push 2
push eax
push 3
push -1
push -1
push dword aError
push aError
call SayErr
add esp, 3*4
test eax, eax
1646,17 → 1347,17
test eax, eax
jz .copywriteok
push edi
push dword aCannotWriteFile
push aCannotWriteFile
call get_error_msg
push eax
mov eax, esp
push dword RetryOrCancelBtn
push RetryOrCancelBtn
push 2
push eax
push 3
push -1
push -1
push dword aError
push aError
call SayErr
add esp, 3*4
test eax, eax
1680,15 → 1381,15
jz @f
cmp [writeinfo.code], 2
jz .copydone
push dword aIncompleteFile
push aIncompleteFile
mov eax, esp
push dword DeleteOrKeepBtn
push DeleteOrKeepBtn
push 2
push eax
push 1
push -1
push -1
push dword aCopyCaption
push aCopyCaption
call SayErr
add esp, 4
test eax, eax
1708,83 → 1409,13
call view_file
.ret2:
ret
.f8_has_selected:
mov edi, saved_file_name+511
mov byte [edi], 0
mov eax, [ebp + panel1_selected_num - panel1_data]
if lang eq ru
cmp eax, 1
jz @f
dec edi
mov byte [edi], ' '
cmp eax, 4
jbe @f
dec edi
mov word [edi], '®¢'
@@:
mov dword [edi-4], '¬¥­â'
mov dword [edi-8], ' í«¥'
sub edi, 8
else
cmp eax, 1
jz @f
dec edi
mov byte [edi], 's'
@@:
mov dword [edi-4], 'item'
mov byte [edi-5], ' '
sub edi, 5
end if
xor edx, edx
push 10
pop ecx
@@:
div ecx
add dl, '0'
dec edi
mov [edi], dl
xor edx, edx
test eax, eax
jnz @b
push edi
push aConfirmDeleteText
mov eax, esp
push DeleteOrCancelBtn
push 2
push eax
push 2
push -1
push -1
push aDeleteCaption
call Message
add esp, 8
test eax, eax
jnz .ret2
mov [del_bSkipAll], 0
mov ecx, [ebp + panel1_numfiles - panel1_data]
jecxz .ret2
mov esi, [ebp + panel1_files - panel1_data]
.f8_loop:
lodsd
test byte [eax+303], 1
jz @f
call delete_file
ja .f8_multiple_cancel
@@:
loop .f8_loop
.f8_multiple_cancel:
jmp .ctrl_r
.f8:
cmp [ebp + panel1_selected_num - panel1_data], 0
jnz .f8_has_selected
call get_curfile_folder_entry
cmp [bConfirmDelete], 0
jz .f8_allowed
lea eax, [ecx+40]
push eax
mov ebx, f8_confirm_dlgdata
mov esi, aConfirmDeleteText
mov edi, aConfirmDeleteTextBuf
push edi
@@:
lodsb
stosb
1800,23 → 1431,93
stosb
test al, al
jnz @b
lea esi, [ecx+40]
mov [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.name], esi
or eax, -1
@@:
inc eax
cmp byte [eax+esi], 0
jnz @b
sub edi, aConfirmDeleteTextBuf+1
cmp eax, edi
jae @f
mov eax, edi
@@:
inc eax
inc eax
mov edx, [cur_width]
sub edx, 8
cmp eax, edx
jbe @f
mov eax, edx
@@:
mov [ebx + dlgtemplate.width], eax
dec eax
dec eax
mov [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.width2], eax
mov [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.width3], eax
shr eax, 1
mov [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.del_x2], eax
sub eax, aDeleteLength-1
mov [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.del_x1], eax
add eax, aDeleteLength
mov [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.cnl_x1], eax
add eax, aCancelLength - 1
mov [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.cnl_x2], eax
or byte [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.flags1], 4
and byte [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.flags2], not 4
push ebx
call DialogBox
cmp eax, f8_confirm_dlgdata.del_btn
jnz .ret2
.f8_allowed:
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
cmp edi, execdataend
jae .bigfilename
stosb
test al, al
jnz @b
.retrydel:
push 70
pop eax
mov ebx, delinfo
int 0x40
test eax, eax
jz .ctrl_r
push execdata
push aCannotDeleteFolder
call get_curfile_folder_entry
test byte [ecx], 10h
jnz @f
mov dword [esp], aCannotDeleteFile
@@:
call get_error_msg
push eax
mov eax, esp
push DeleteOrCancelBtn
push RetryOrCancelBtn
push 2
push eax
push 2
push 3
push -1
push -1
push aDeleteCaption
call Message
add esp, 8
push aError
call SayErr
add esp, 3*4
test eax, eax
jz .f8_allowed
ret
.f8_allowed:
mov [del_bSkipAll], 0
mov eax, ecx
call delete_file
jz .retrydel
.ctrl_r:
; Rescan panel
; call read_folder
1888,25 → 1589,11
@@:
call find_extension
jc .menuret
jnz .menuret
; known extension
@@:
cmp byte [edi], 0
mov ebx, [edi+8]
test ebx, ebx
jz .menuret
cmp byte [edi], ';'
jz @f
inc edi
jmp @b
@@:
inc edi
@@:
inc edi
cmp byte [edi-1], ' '
jz @b
cmp byte [edi-1], 9
jz @b
dec edi
cmp byte [edi], 0
jz .menuret
mov ecx, esi
@@:
inc ecx
1918,91 → 1605,34
mov cl, 15
@@:
xor edx, edx
xor ebp, ebp
push edx
.menucreateloop:
mov eax, edi
xor ebx, ebx
mov eax, [ebx]
test eax, eax
jz .menucreated
@@:
cmp byte [edi], ','
jz @f
cmp byte [edi], bl
jz @f
inc edi
jmp @b
@@:
xchg bl, [edi]
pushad
push nullstr
push 1024
push saved_file_name
push eax
push aMenu
push app_path
call [ini.get_str]
popad
mov [edi], bl
mov eax, saved_file_name
@@:
cmp byte [eax], 0
jz .menucreatecont
cmp byte [eax], ','
jz @f
inc eax
jmp @b
@@:
mov byte [eax], 0
push eax
sub eax, saved_file_name-1
cmp byte [eax-1], 0
jnz @b
sub eax, [ebx]
cmp eax, ecx
ja @f
mov eax, ecx
@@:
xchg eax, [esp]
inc eax
push eax
@@:
inc eax
cmp byte [eax-1], 0
jnz @b
sub eax, [esp]
add [esp+4], eax
pop eax eax
add eax, 8
add ebp, eax
push ebp
and ebp, 0xFFF
cmp ebp, eax
pop ebp
ja @f
push eax
xchg edx, [esp+4]
push ecx
mov ecx, ebp
call xpgrealloc
pop ecx
pop edx
xchg edx, [esp]
add eax, 12
call xmalloc
test eax, eax
xchg eax, [esp]
jz .menucreated
@@:
neg eax
add eax, ebp
add eax, [esp]
and dword [eax], 0
and dword [eax+4], 0
add eax, 4
test edx, edx
jz @f
sub eax, [esp]
mov [edx], eax
add eax, [esp]
sub edx, [esp]
@@:
mov [eax+4], edx
@@:
mov edx, eax
push esi edi
mov esi, saved_file_name
push esi
mov esi, [ebx+4]
mov [eax-4], esi
mov esi, [ebx]
lea edi, [eax+8]
@@:
lodsb
2009,8 → 1639,7
stosb
test al, al
jnz @b
push esi
sub esi, saved_file_name
sub esi, [ebx]
sub esi, ecx
jae .menunoadd
neg esi
2021,50 → 1650,36
jnz @b
.menunoadd:
pop esi
@@:
lodsb
stosb
test al, al
jnz @b
pop edi esi
.menucreatecont:
inc edi
cmp byte [edi-1], ','
jz .menucreateloop
add ebx, 8
jmp .menucreateloop
.menucreated:
test edx, edx
jz .menuret_free
jz .menuret
and dword [edx], 0
pop edx
mov ecx, edx
add [ecx], edx
@@:
mov ecx, [ecx]
cmp dword [ecx], 0
cmp dword [edx+4], 0
jz @f
add [ecx], edx
add [ecx+4], edx
mov edx, [edx+4]
jmp @b
@@:
add [ecx+4], edx
push edx
push 1
push esi
push edx
call menu
cmp eax, -1
jz .menuret_free
lea edi, [eax+8]
jz .menuret
push dword [eax-4]
@@:
inc edi
cmp byte [edi-1], 0
jnz @b
mov ebp, [active_panel]
test edx, edx
jz @f
lea eax, [edx-4]
mov edx, [edx]
call mf_free
jmp @b
@@:
pop eax
call get_curfile_folder_entry
call .run_association2
.menuret_free:
pop ecx
jmp pgfree
jmp .run_association2
.f7:
mov dword [CopyDestEditBuf], CopyDestEditBuf.length
and dword [CopyDestEditBuf+4], 0
2143,18 → 1758,18
int 0x40
test eax, eax
jz @f
push dword CopyDestEditBuf+12
push dword aCannotMakeFolder
push CopyDestEditBuf+12
push aCannotMakeFolder
call get_error_msg
push eax
mov eax, esp
push dword RetryOrCancelBtn
push RetryOrCancelBtn
push 2
push eax
push 3
push -1
push -1
push dword aError
push aError
call SayErr
add esp, 3*4
test eax, eax
2161,143 → 1776,24
jz .mkdir_retry
@@:
jmp .copydone
.change_mode:
dec eax
mov [ebp + panel1_colmode - panel1_data], eax
call calc_colwidths
jmp draw_panel
.quick_jump:
dec eax
cmp al, 10
jnz @f
xor eax, eax
@@:
mov eax, [FolderShortcuts+eax*4]
test eax, eax
jnz @f
ret
@@:
lea esi, [ebp + panel1_dir - panel1_data]
push eax esi
mov edi, prev_dir
@@:
lodsb
stosb
test al, al
jnz @b
pop edi esi
@@:
lodsb
stosb
test al, al
jnz @b
jmp .reread
.greyplus:
push 0
mov ecx, aSelect
jmp @f
.greyminus:
push 1
mov ecx, aDeselect
@@:
mov eax, mark_dlgdata
mov [eax+mark_dlgdata.title-mark_dlgdata], ecx
mov [eax+mark_dlgdata.flags-mark_dlgdata], 0xC
mov edi, enter_string_buf+12
mov dword [edi-12], 512
mov dword [edi-8], 1
and dword [edi-4], 0
mov word [edi], '*'
push eax
call DialogBox
inc eax
jnz @f
.noselect:
pop eax
ret
@@:
xor eax, eax
mov esi, edi
@@:
lodsb
mov al, [tolower_table+eax]
mov [esi-1], al
test al, al
jnz @b
@@:
mov ecx, [ebp + panel1_numfiles - panel1_data]
mov ebx, [ebp + panel1_files - panel1_data]
jecxz .noselect
mov eax, [ebx]
cmp word [eax+40], '..'
jnz .selectloop
cmp byte [eax+42], 0
jnz .selectloop
dec ecx
jz .noselect
add ebx, 4
.selectloop:
xor eax, eax
mov esi, [ebx]
add esi, 40
mov edx, lower_file_name-1
@@:
lodsb
inc edx
mov al, [tolower_table+eax]
mov [edx], al
test al, al
jnz @b
mov esi, lower_file_name
call match_mask_rev_lowercase
jc @f
mov esi, [ebx]
mov eax, [esi+32]
cmp byte [esp], 0
jz .doselect
test byte [esi+303], 1
jz @f
and byte [esi+303], not 1
sub dword [ebp + panel1_selected_size - panel1_data], eax
mov eax, [esi+36]
sbb dword [ebp + panel1_selected_size+4 - panel1_data], eax
dec dword [ebp + panel1_selected_num - panel1_data]
jmp @f
.doselect:
test byte [esi+303], 1
jnz @f
or byte [esi+303], 1
add dword [ebp + panel1_selected_size - panel1_data], eax
mov eax, [esi+36]
adc dword [ebp + panel1_selected_size+4 - panel1_data], eax
inc dword [ebp + panel1_selected_num - panel1_data]
@@:
add ebx, 4
dec ecx
jnz .selectloop
pop eax
jmp .done_redraw
 
panels_OnRedraw:
call draw_cmdbar
mov ebp, panel1_data
call calc_colwidths
call draw_panel
mov ebp, panel2_data
call calc_colwidths
call draw_panel
ret
 
init_console:
mov ecx, [console_data_ptr]
call pgfree
mov eax, [console_data_ptr]
call mf_free
mov eax, [cur_width]
mul [cur_height]
mov ecx, eax
push ecx
shl ecx, 2
call pgalloc
pop ecx
add eax, eax
add eax, eax
call mf_alloc
test eax, eax
jz exit
mov [console_data_ptr], eax
2467,6 → 1963,7
@@:
cmp [fill_height], 0
jz @f
mov al, 13
xor edx, edx
mov ebx, 50000h
mov bx, word [wnd_width]
2480,21 → 1977,15
@@:
; xor ecx, ecx
; call draw_image
mov al, 65
mov ebx, [MemForImage]
test ebx, ebx
jz @f
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
mov esi, 8
mov edi, console_colors
xor ebp, ebp
int 0x40
@@:
and [min_x], 0
and [min_y], 0
mov eax, [cur_width]
dec eax
mov [max_x], eax
mov eax, [cur_height]
dec eax
mov [max_y], eax
call draw_image.force
mov al, 12
push 2
pop ebx
2521,121 → 2012,159
ret
 
draw_image:
mov [bMemForImageValidData], byte 1
cmp [MemForImage], 0
jnz .allocated
; allocate memory for image
mov ecx, [cur_width]
imul ecx, [cur_height]
imul ecx, font_width*font_height
call pgalloc
test eax, eax
jz draw_image.nomem
mov [MemForImage], eax
mov [bMemForImageValidData], byte 0
.allocated:
; determine draw rectangle
and [max_x], 0
or [min_x], -1
and [max_y], 0
or [min_y], -1
mov eax, [cursor_y]
mul [cur_width]
add eax, [cursor_x]
add eax, eax
add eax, [console_data_ptr]
xchg [cur_cursor_pos], eax
mov [old_cursor_pos], eax
mov edi, [MemForImage]
mov esi, [console_data_ptr]
mov ecx, [cur_height]
.lh:
push ecx
xor eax, eax
xor edx, edx
mov ecx, [cur_width]
.lw:
push ecx
mov eax, [cur_width]
imul eax, [cur_height]
mov ebx, [esi]
cmp [bMemForImageValidData], 0
jz @f
cmp esi, [cur_cursor_pos]
jz @f
cmp esi, [old_cursor_pos]
jz @f
cmp bx, [eax*2+esi]
jnz @f
inc esi
inc esi
jmp .skip_symbol
imul ecx, [cur_height]
.m1:
mov bx, [esi]
cmp bx, [esi+ecx*2]
jz .m2
cmp eax, [min_x]
ja @f
mov [min_x], eax
@@:
mov [eax*2+esi], bx
cmp ecx, [min_x]
cmp eax, [max_x]
jb @f
mov [max_x], eax
@@:
cmp edx, [min_y]
jae @f
mov [min_y], edx
@@:
mov [max_y], edx
.m2:
add esi, 2
inc eax
cmp eax, [cur_width]
jb .m1
xor eax, eax
inc edx
cmp edx, [cur_height]
jb .m1
mov eax, [cursor_x]
cmp eax, -1
jz .m3
cmp eax, [min_x]
ja @f
mov [min_x], ecx
mov [min_x], eax
@@:
cmp ecx, [max_x]
cmp eax, [max_x]
jb @f
mov [max_x], ecx
mov [max_x], eax
@@:
mov eax, [esp+4]
mov [min_y], eax
cmp eax, [max_y]
mov edx, [cursor_y]
cmp edx, [min_y]
ja @f
mov [min_y], edx
@@:
cmp edx, [max_y]
jb @f
mov [max_y], eax
mov [max_y], edx
@@:
.m3:
xchg eax, [old_cursor_x]
xchg edx, [old_cursor_y]
cmp eax, -1
jz .m4
cmp eax, [min_x]
ja @f
mov [min_x], eax
@@:
cmp eax, [max_x]
jb @f
mov [max_x], eax
@@:
cmp edx, [min_y]
ja @f
mov [min_y], edx
@@:
cmp edx, [max_y]
jb @f
mov [max_y], edx
@@:
.m4:
cmp [min_y], -1
jz .nodraw
.force:
; allocate memory for image
mov ecx, [max_x]
sub ecx, [min_x]
inc ecx
mov [used_width], ecx
mov edx, [max_y]
sub edx, [min_y]
inc edx
mov [used_height], edx
imul ecx, edx
imul ecx, font_width*font_height
add ecx, [heapend]
push 64
pop eax
push 1
pop ebx
int 0x40
test eax, eax
jnz draw_image.nomem
mov edi, [heapend]
mov esi, [console_data_ptr]
mov eax, [min_y]
imul eax, [cur_width]
add eax, [min_x]
lea esi, [esi+eax*2]
mov ecx, [used_height]
.lh:
push ecx esi
mov ecx, [used_width]
.lw:
push ecx
mov ebx, [esi]
mov eax, [cur_width]
imul eax, [cur_height]
mov [eax*2+esi], bx
movzx eax, bl
push edi
xor eax, eax
mov al, [esi+1]
and al, 0xF
mov ebx, eax
mov al, [esi+1]
shr al, 4
mov ebp, eax
movzx ebx, bh
mov ebp, ebx
shr ebp, 4
and ebx, 0xF
sub ebx, ebp
lodsb
inc esi
add esi, 2
if font_width > 8
lea edx, [eax+eax+font]
else
lea edx, [eax+font]
end if
mov ecx, font_height
.sh:
mov ecx, [edx]
repeat font_width
shr ecx, 1
push ecx edx edi
xor ecx, ecx
mov edx, [edx]
.sw:
shr edx, 1
sbb eax, eax
and eax, ebx
add eax, ebp
mov [edi+%-1], al
end repeat
mov eax, [cur_width]
; imul eax, font_width
; add edi, eax
if font_width = 6
lea eax, [eax*2+eax]
lea edi, [edi+eax*2]
else if font_width = 7
lea edi, [edi+eax*8]
sub edi, eax
else if font_width = 8
lea edi, [edi+eax*8]
else if font_width = 9
lea edi, [edi+eax*8]
mov [edi], al
add ecx, 1
add edi, 1
cmp ecx, font_width
jb .sw
pop edi edx ecx
mov eax, [used_width]
imul eax, font_width
add edi, eax
else if font_width = 10
lea eax, [eax*4+eax]
lea edi, [edi+eax*2]
else
Unknown font_width value!
end if
if font_width > 8
add edx, 256*2
cmp edx, font+256*2*font_height
else
add edx, 256
cmp edx, font+256*font_height
end if
jb .sh
loop .sh
pop edi
.skip_symbol:
pop ecx
2642,10 → 2171,12
add edi, font_width
dec ecx
jnz .lw
mov eax, [cur_width]
mov eax, [used_width]
imul eax, (font_height-1)*font_width
add edi, eax
pop ecx
pop esi ecx
add esi, [cur_width]
add esi, [cur_width]
dec ecx
jnz .lh
; cursor
2652,14 → 2183,16
mov eax, [cursor_y]
inc eax
jz .nocursor
mul [cur_width]
sub eax, [min_y]
mul [used_width]
imul eax, font_height*font_width
mov edx, [cursor_x]
sub edx, [min_x]
inc edx
imul edx, font_width
add eax, edx
add eax, [MemForImage]
mov edx, [cur_width]
add eax, [heapend]
mov edx, [used_width]
imul edx, font_width
neg edx
mov ecx, (font_height*15+50)/100
2677,44 → 2210,31
pop ecx
loop .cursor_loop
.nocursor:
cmp [min_y], -1
jz .nodraw
mov ecx, [cur_width]
mov ebx, [cur_height]
mov eax, ebx
sub ebx, [max_y]
sub eax, [min_y]
sub eax, ebx
inc eax
imul ebp, eax, font_height
mov edx, ecx
sub edx, [max_x]
mov ecx, [used_width]
imul ecx, font_width*65536
mov cx, word [used_height]
imul cx, font_height
mov edx, [min_x]
imul edx, font_width
mov eax, edx
add edx, 5
shl edx, 16
imul dx, bx, font_height
imul ebx, [cur_width]
mov ecx, [max_x]
sub ecx, [min_x]
inc ecx
imul ecx, font_width*10000h
add ecx, ebp
imul ebx, font_width*font_height
add ebx, [MemForImage]
add ebx, eax
mov dx, word [min_y]
imul dx, font_height
add edx, [skinh]
add edx, 5*10000h
imul esi, [cur_width], font_width
mov ebp, ecx
shr ebp, 16
sub esi, ebp
mov ebp, esi
push 65
pop eax
mov edi, console_colors
mov ebx, [heapend]
push 8
pop esi
int 40h
mov edi, console_colors
xor ebp, ebp
int 0x40
push 64
pop eax
push 1
pop ebx
mov ecx, [heapend]
int 0x40
.nodraw:
ret
 
2899,60 → 2419,6
stosw
ret
 
calc_colwidths:
; in: ebp->panel data
imul esi, [ebp + panel1_colmode - panel1_data], PanelMode.size
add esi, colmodes
lodsd
mov ecx, eax
lea edx, [ecx-1]
xor ebx, ebx
add esi, PanelMode.ColumnWidths-4
push ecx esi
xor eax, eax
.loop:
lodsb
add edx, eax
cmp al, 1
adc ebx, 0
loop .loop
pop esi ecx
lea edi, [ebp + panel1_colwidths - panel1_data]
test ebx, ebx
jz .loop2
mov eax, [ebp + panel1_width - panel1_data]
dec eax
dec eax
sub eax, edx
jae @f
xor eax, eax
@@:
xor edx, edx
div ebx
test eax, eax
jnz @f
xor edx, edx
inc eax
@@:
push eax
.loop2:
movzx eax, byte [esi]
inc esi
test eax, eax
jnz @f
pop eax
push eax
dec ebx
cmp ebx, edx
jae @f
inc eax
@@:
stosd
loop .loop2
pop eax
and dword [edi], 0
ret
 
draw_panel:
mov eax, [ebp + panel1_left - panel1_data]
mov edx, [ebp + panel1_top - panel1_data]
2976,43 → 2442,27
rep stosw
mov al, 0xB6
stosw
 
imul esi, [ebp + panel1_colmode - panel1_data], PanelMode.size
add esi, colmodes
lodsd
mov ecx, eax ; number of columns
lea ebx, [ebp + panel1_colwidths - panel1_data]
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
mov eax, [ebp + panel1_top - panel1_data]
inc eax
mov [column_top], eax
mov eax, [ebp + panel1_height - panel1_data]
sub eax, 4
mov [column_height], eax
dec eax
mov [ebp + panel1_colsz - panel1_data], eax
and [ebp + panel1_colst - panel1_data], 0
mov eax, [ebp + panel1_start - panel1_data]
mov [column_index], eax
mov [last_column_index], eax
.columns_loop:
push ecx
mov eax, [ebx]
add ebx, 4
mov [column_width], eax
cmp ecx, 1
jz .skip_right_border
add eax, [column_left]
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_header_color]
mov ah, [panel_border_color]
mov al, 0xD1
mov [edi], ax
add edi, [cur_width]
add edi, [cur_width]
mov ecx, [column_height]
mov ecx, [ebp + panel1_height - panel1_data]
sub ecx, 4
mov [column_height], ecx
mov al, 0xB3
@@:
mov [edi], ax
3021,60 → 2471,22
loop @b
mov al, 0xC1
stosw
.skip_right_border:
mov eax, [column_left]
mov edx, [column_top]
call get_console_ptr
; § £®«®¢®ª á⮫¡æ 
push edi
mov edx, [esi]
and edx, 0xF
mov edx, [column_headers+edx*4]
movzx ecx, byte [edx]
inc edx
cmp ecx, [column_width]
jb @f
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]
@@:
push ecx
sub ecx, [column_width]
neg ecx
shr ecx, 1
mov al, ' '
mov ah, [column_header_color]
rep stosw
pop ecx
jecxz .skipcopyhdr
push ecx
@@:
mov al, [edx]
inc edx
stosw
loop @b
pop ecx
.skipcopyhdr:
sub ecx, [column_width]
neg ecx
sub eax, ecx
mov [column_width], eax
inc ecx
shr ecx, 1
mov al, ' '
rep stosw
pop edi
add edi, [cur_width]
add edi, [cur_width]
; á ¬ á⮫¡¥æ
mov eax, [esi]
and eax, 0xF
push ebx esi
call dword [draw_column_proc+eax*4]
pop esi ebx
inc esi
mov eax, [column_width]
inc eax
add [column_left], eax
pop ecx
dec ecx
jnz .columns_loop
add [column_left], ecx
call draw_column
; ‡ £®«®¢®ª ¯ ­¥«¨ (⥪ãé ï ¯ ¯ª )
lea esi, [ebp + panel1_dir - panel1_data]
mov edi, cur_header
3143,68 → 2555,9
movzx eax, [ebp + panel1_sortmode - panel1_data]
mov al, [compare_names+eax]
stosb
mov eax, [ebp + panel1_selected_num - panel1_data]
test eax, eax
jz .skip_selected_info
; ˆ­ä®à¬ æ¨ï ® ¢ë¤¥«¥­­ëå ä ©« å
push dword [ebp + panel1_selected_size+4 - panel1_data]
push dword [ebp + panel1_selected_size - panel1_data]
call fill_total_info
mov eax, [ebp + panel1_width - panel1_data]
sub eax, 2
cmp ecx, eax
jbe @f
mov ecx, eax
mov edi, saved_file_name+512
sub edi, eax
mov byte [edi], '.'
mov word [edi+1], '..'
@@:
mov esi, edi
sub eax, ecx
shr eax, 1
inc eax
add 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
mov ah, [panel_numselected_color]
@@:
lodsb
stosw
loop @b
.skip_selected_info:
; ˆ­ä®à¬ æ¨ï ®¡ ®¡é¥¬ ç¨á«¥ ¨ à §¬¥à¥ ä ©«®¢ ¯ ­¥«¨
mov eax, [ebp + panel1_total_num - panel1_data]
push dword [ebp + panel1_total_size+4 - panel1_data]
push dword [ebp + panel1_total_size - panel1_data]
call fill_total_info
mov eax, [ebp + panel1_width - panel1_data]
sub eax, 2
cmp ecx, eax
jbe @f
mov ecx, eax
mov byte [edi+ecx-3], '.'
mov word [edi+ecx-2], '..'
@@:
sub eax, ecx
shr eax, 1
inc eax
add eax, [ebp + panel1_left - panel1_data]
add edx, [ebp + panel1_top - panel1_data]
add edx, [ebp + panel1_height - panel1_data]
dec edx
mov esi, edi
call get_console_ptr
mov ah, [panel_number_color]
@@:
lodsb
stosw
loop @b
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]
3219,8 → 2572,6
mov ecx, [ebp + panel1_width - panel1_data]
dec ecx
dec ecx
cmp [ebp + panel1_colmode - panel1_data], 3
jz .show_curname
; ‚à¥¬ï ¬®¤¨ä¨ª æ¨¨
sub edi, 5*2
sub ecx, 6
3351,7 → 2702,6
jnz .size_num
.size_done:
cld
.show_curname:
; ˆ¬ï
sub edi, ecx
sub edi, ecx
3385,115 → 2735,52
call draw_image
ret
 
fill_total_info:
mov edi, saved_file_name+511
mov byte [edi], ' '
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
mov byte [edi-1], '¥'
dec edi
cmp eax, 1
jz @f
mov word [edi-1], ' å'
dec edi
@@:
mov dword [edi-4], 'ä ©«'
mov byte [edi-5], ' '
sub edi, 5
sub ecx, 3
else
cmp eax, 1
jz @f
dec edi
mov byte [edi], 's'
@@:
mov dword [edi-4], 'file'
mov byte [edi-5], ' '
sub edi, 5
sub ecx, 4
end if
xor edx, edx
push 10
pop ecx
@@:
div ecx
dec edi
add dl, '0'
mov [edi], dl
xor edx, edx
test eax, eax
jnz @b
shr ecx, 1
rep stosw
if lang eq ru
mov dword [edi-4], 'â ¢ '
mov dword [edi-8], ' ¡ ©'
sub edi, 8
mov al, 'ˆ'
stosw
mov al, '¬'
stosw
mov al, 'ï'
stosw
else
mov dword [edi-4], ' in '
mov dword [edi-8], 'ytes'
mov word [edi-10], ' b'
sub edi, 10
mov al, 'N'
stosw
mov al, 'a'
stosw
mov al, 'm'
stosw
mov al, 'e'
stosw
end if
lea esi, [edi-3]
mov edx, [esp+8]
mov eax, [esp+4]
.selsizel:
push edx
mov ebx, edx
xor edx, edx
add ebx, ebx
adc edx, edx
push ebx
push edx
add ebx, ebx
adc edx, edx
add ebx, [esp+4]
adc edx, [esp]
add esp, 8
add eax, ebx
adc edx, 0
div ecx
dec edi
cmp edi, esi
jae @f
mov byte [edi], ','
dec edi
sub esi, 4
@@:
pop ebx
add dl, '0'
mov byte [edi], dl
xchg eax, ebx
mul [muldiv10]
add eax, ebx
adc edx, 0
mov ebx, eax
or ebx, edx
jnz .selsizel
dec edi
mov byte [edi], ' '
mov ecx, saved_file_name+512
sub ecx, edi
ret 8
 
get_file_color:
mov ah, [esi + 6]
cmp ebp, [active_panel]
jnz @f
cmp ecx, [ebp + panel1_index - panel1_data]
jnz @f
mov ah, [esi + 7]
@@:
test byte [esi + 303], 1
jnz @f
mov ah, [esi + 4]
cmp ebp, [active_panel]
jnz @f
cmp ecx, [ebp + panel1_index - panel1_data]
jnz @f
mov ah, [esi + 5]
@@:
ret
 
draw_name_column:
mov eax, [column_index]
mov [last_column_index], eax
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
3501,12 → 2788,18
cmp [column_index], edx
jae .ret
push ecx
mov esi, [column_index]
mov ecx, [ebp + panel1_files - panel1_data]
mov esi, [ecx+esi*4]
add esi, 40
mov ah, [esi - 40 + 5]
cmp ebp, [active_panel]
jnz @f
mov ecx, [column_index]
mov esi, [ebp + panel1_files - panel1_data]
mov esi, [esi+ecx*4]
mov ebx, [esi]
call get_file_color
add esi, 40
cmp ecx, [ebp + panel1_index - panel1_data]
jnz @f
mov ah, [esi - 40 + 6]
@@:
mov ecx, [column_width]
push edi
@@:
3515,68 → 2808,12
jz @f
stosw
loop @b
lodsb
test al, al
cmp byte [esi], 0
jz @f
mov byte [edi], '}'
jmp .continue
@@:
test bl, 10h
jnz .noalignext
mov ebx, [ebp + panel1_colmode - panel1_data]
; sizeof(PanelMode) = 40
lea ebx, [ebx+ebx*4]
cmp [colmodes+ebx*8+PanelMode.bAlignExtensions], 0
jz .noalignext
push ecx
sub ecx, [column_width]
neg ecx
jz .noalignext2
dec esi
@@:
dec esi
cmp byte [esi], '.'
loopnz @b
jnz .noalignext2
inc esi
sub ecx, [column_width]
neg ecx
sub ecx, [esp]
sub edi, ecx
sub edi, ecx
dec ecx
mov ebx, [esp+4]
cmp ecx, 3
ja @f
mov cl, 3
@@:
sub ecx, [column_width]
sub ebx, edi
sar ebx, 1
sub ebx, ecx
pop ecx
inc ecx
push 0
cmp ecx, ebx
jbe @f
sub ecx, ebx
mov [esp], ecx
mov ecx, ebx
@@:
mov al, ' '
rep stosw
@@:
lodsb
test al, al
jz .noalignext2
stosw
jmp @b
.noalignext2:
pop ecx
.noalignext:
mov al, ' '
rep stosw
.continue:
pop edi
add edi, [cur_width]
add edi, [cur_width]
3585,8 → 2822,6
dec ecx
jnz .l
.ret:
mov eax, [ebp + panel1_colsz - panel1_data]
add [ebp + panel1_colst - panel1_data], eax
cmp ebp, panel1_data
jnz .ret2
; —¨á«® íªà ­®¢
3620,269 → 2855,8
mov ah, [panel_nscreens_color]
stosw
.ret2:
draw_empty_column:
ret
 
draw_size_column:
add edi, [column_width]
add edi, [column_width]
dec edi
dec edi
std
mov ecx, [column_height]
dec ecx
push [last_column_index]
.l:
mov edx, [ebp + panel1_numfiles - panel1_data]
cmp [last_column_index], edx
jae .ret
push ecx
push edi
mov ecx, [last_column_index]
mov esi, [ebp + panel1_files - panel1_data]
mov esi, [esi+ecx*4]
call get_file_color
mov ecx, [column_width]
@@:
mov ebx, eax
cmp word [esi+40], '..'
jnz .nodotdot
cmp byte [esi+42], 0
jnz .nodotdot
if lang eq ru
mov al, 'å'
stosw
mov al, 'à'
stosw
mov al, '¥'
stosw
mov al, '¢'
stosw
mov al, '‚'
stosw
sub ecx, 5
else
mov al, ' '
stosw
stosw
mov al, 'p'
stosw
mov al, 'U'
stosw
sub ecx, 4
end if
jmp .size_written
.nodotdot:
test byte [esi], 10h
jz .nofolder
if lang eq ru
mov al, ' '
stosw
mov al, 'ª'
stosw
mov al, '¯'
stosw
mov al, ' '
stosw
mov al, ''
stosw
sub ecx, 5
else
mov al, 'r'
stosw
mov al, 'e'
stosw
mov al, 'd'
stosw
mov al, 'l'
stosw
mov al, 'o'
stosw
mov al, 'F'
stosw
sub ecx, 6
end if
jmp .size_written
.nofolder:
mov eax, [esi+32]
mov edx, [esi+36]
test edx, edx
jz .less_4G
cmp edx, 10000/4*1024
jb .giga
mov al, 'T'
shr edx, 10
jmp .write_letter
.giga:
mov al, 'G'
shl edx, 2
jmp .write_letter
.less_4G:
mov edx, eax
cmp eax, 1000000
jb .byte
cmp eax, 10000*1024
jb .kilo
mov al, 'M'
shr edx, 20
jmp .write_letter
.kilo:
mov al, 'K'
shr edx, 10
.write_letter:
mov ah, bh
stosw
mov al, ' '
stosw
dec ecx
dec ecx
.byte:
xchg eax, edx
xor edx, edx
div [_10d]
xchg eax, edx
add al, '0'
mov ah, bh
stosw
dec ecx
test edx, edx
jnz .byte
.size_written:
mov eax, ebx
test ecx, ecx
jle @f
mov al, ' '
rep stosw
@@:
mov byte [edi+1], ah
pop edi
add edi, [cur_width]
add edi, [cur_width]
inc [last_column_index]
pop ecx
dec ecx
jnz .l
.ret:
pop [last_column_index]
cld
ret
 
draw_date_column:
mov ecx, [column_height]
dec ecx
push [last_column_index]
.l:
mov edx, [ebp + panel1_numfiles - panel1_data]
cmp [last_column_index], edx
jae .ret
push ecx
push edi
mov ecx, [last_column_index]
mov esi, [ebp + panel1_files - panel1_data]
mov esi, [esi+ecx*4]
call get_file_color
mov bh, ah
mov byte [edi-1], bh
mov al, [esi+28]
aam
add eax, '00'
push eax
mov al, ah
mov ah, bh
stosw
pop eax
mov ah, bh
stosw
mov al, '.'
stosw
mov al, [esi+29]
aam
add eax, '00'
push eax
mov al, ah
mov ah, bh
stosw
pop eax
mov ah, bh
stosw
mov al, '.'
stosw
movzx eax, word [esi+30]
xor edx, edx
div [_10d]
xchg eax, edx
add al, '0'
mov ah, bh
mov [edi+2], ax
xchg eax, edx
xor edx, edx
div [_10d]
xchg eax, edx
add al, '0'
mov ah, bh
stosw
pop edi
add edi, [cur_width]
add edi, [cur_width]
inc [last_column_index]
pop ecx
dec ecx
jnz .l
.ret:
pop [last_column_index]
cld
ret
 
draw_time_column:
mov ecx, [column_height]
dec ecx
push [last_column_index]
.l:
mov edx, [ebp + panel1_numfiles - panel1_data]
cmp [last_column_index], edx
jae .ret
push ecx
push edi
mov ecx, [last_column_index]
mov esi, [ebp + panel1_files - panel1_data]
mov esi, [esi+ecx*4]
call get_file_color
mov bh, ah
mov byte [edi-1], bh
mov al, [esi+26]
aam
add eax, '00'
push eax
mov al, ah
mov ah, bh
stosw
pop eax
mov ah, bh
stosw
mov al, ':'
stosw
mov al, [esi+25]
aam
add eax, '00'
push eax
mov al, ah
mov ah, bh
stosw
pop eax
mov ah, bh
stosw
pop edi
add edi, [cur_width]
add edi, [cur_width]
inc [last_column_index]
pop ecx
dec ecx
jnz .l
.ret:
pop [last_column_index]
cld
ret
 
;insert_last_dot:
; push eax esi
; mov ah, 0
3925,13 → 2899,6
mov [dirinfo.dirdata], eax
lea eax, [ebp + panel1_dir - panel1_data]
mov [dirinfo.name], eax
xor eax, eax
mov [ebp + panel1_total_num - panel1_data], eax
mov dword [ebp + panel1_total_size - panel1_data], eax
mov dword [ebp + panel1_total_size+4 - panel1_data], eax
mov [ebp + panel1_selected_num - panel1_data], eax
mov dword [ebp + panel1_selected_size - panel1_data], eax
mov dword [ebp + panel1_selected_size+4 - panel1_data], eax
.retry:
push 70
pop eax
3944,12 → 2911,12
; Failed to read folder, notify user
cmp [bSilentFolderMode], 0
jnz .dont_notify
push dword aContinue
push dword aRetry
push aContinue
push aRetry
mov edx, esp
call get_error_msg
push [dirinfo.name]
push dword aCannotReadFolder
push aCannotReadFolder
push eax
mov eax, esp
push edx
3958,7 → 2925,7
push 3
push -1
push -1
push dword aError
push aError
call SayErr
add esp, 5*4
test eax, eax
4017,16 → 2984,17
mov eax, [dirinfo.dirdata]
cmp [eax+8], ebx
jz .readdone
push dword [eax+8]
mov ecx, [ebp + panel1_files - panel1_data]
call pgfree
pop ecx
add ecx, 0xF
and ecx, not 0xF
push ecx
imul ecx, 4+304
add ecx, 32
call xpgalloc
push eax
mov eax, [ebp + panel1_files - panel1_data]
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 xmalloc
test eax, eax
jnz .succ1
pop eax
4053,7 → 3021,6
jz .loopcont
test byte [eax], 8
jnz .loopcont
mov byte [eax+303], 0
test edx, edx
jnz .nodotdot
cmp word [eax+40], '..'
4076,14 → 3043,6
jmp .dotdot
.nodotdot:
stosd
xor ebx, ebx
test byte [eax], 10h
setz bl
add [ebp + panel1_total_num - panel1_data], ebx
mov ebx, dword [eax+32]
add dword [ebp + panel1_total_size - panel1_data], ebx
mov ebx, dword [eax+36]
adc dword [ebp + panel1_total_size+4 - panel1_data], ebx
.dotdot:
; ¯®¤á¢¥âª 
; call insert_last_dot
4092,10 → 3051,9
lea esi, [ebp+40]
mov edi, lower_file_name
mov edx, edi
xor eax, eax
@@:
lodsb
mov al, [tolower_table+eax]
call tolower
stosb
test al, al
jnz @b
4117,25 → 3075,13
jnz @f
mov ah, [panel_normal_color]
@@:
mov [ebp+4], ah
mov [ebp+5], ah
mov ah, [ebx + highlight.CursorColor]
test ah, ah
jnz @f
mov ah, [panel_cursor_color]
@@:
mov [ebp+5], ah
mov ah, [ebx + highlight.SelectedColor]
test ah, ah
jnz @f
mov ah, [panel_selected_color]
@@:
mov [ebp+6], ah
mov ah, [ebx + highlight.SelectedCursorColor]
test ah, ah
jnz @f
mov ah, [panel_selected_cursor_color]
@@:
mov [ebp+7], ah
jmp .doname
.highlight_test_failed:
inc ecx
4143,13 → 3089,9
jb .highlight_test_loop
.nohighlight:
mov ah, [panel_normal_color]
mov [ebp+4], ah
mov [ebp+5], ah
mov ah, [panel_cursor_color]
mov [ebp+5], ah
mov ah, [panel_selected_color]
mov [ebp+6], ah
mov ah, [panel_selected_cursor_color]
mov [ebp+7], ah
.doname:
; call delete_last_dot
popad
4170,9 → 3112,9
mov ecx, [ebp + panel1_numfiles - panel1_data]
jecxz .skip
mov eax, [edx]
cmp word [eax+40], '..'
cmp word [eax], '..'
jnz .nodotdot
cmp byte [eax+42], 0
cmp byte [eax+2], 0
jnz .nodotdot
dec ecx
add edx, 4
4927,22 → 3869,24
jmp .done_succ
end if
 
;tolower:
; push ecx
; movzx ecx, al
; mov al, [tolower_table+ecx]
; pop ecx
; ret
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 ecx
movzx ecx, al
mov al, [tolower_table+ecx]
movzx ecx, byte [edi]
cmp al, [tolower_table+ecx]
pop ecx eax
push eax
call tolower
mov ah, [edi]
xchg al, ah
call tolower
cmp ah, al
pop eax
ret
 
match_mask_rev_lowercase:
4959,8 → 3903,6
jz @f
cmp al, ','
jz @f
cmp al, ';'
jz @f
cmp al, '|'
jnz @b
@@:
4972,8 → 3914,6
jnc .found
cmp al, ','
jz .main_cycle
cmp al, ';'
jz .main_cycle
.done_fail:
stc
popa
4996,8 → 3936,6
test al, al
jz @f
cmp al, ','
jz @f
cmp al, ';'
jnz @b
@@:
dec esi
5141,31 → 4079,23
ret
.found_ext:
inc esi
mov edi, [associations]
.find_loop:
mov edi, associations
@@:
push esi edi
mov edi, [edi]
call strcmpi
pop edi esi
pushf
@@:
jz @f
add edi, 12
cmp edi, associations_end
jb @b
; unknown extension
inc edi
cmp byte [edi-1], 0
jnz @b
popf
jz .found
@@:
inc edi
cmp byte [edi-1], 0
jnz @b
cmp byte [edi], 0
jnz .find_loop
; unknown extension
stc
.found:
pop esi
ret
 
header db 'Kolibri Far 0.32',0
header db 'Kolibri Far 0.21',0
 
nomem_draw db 'No memory for redraw.',0
.size = $ - nomem_draw
5191,10 → 4121,8
aScreens db 'Screens',0
end if
 
align 4
_10d dd 10
_100d dd 100
muldiv10 dd 429496729
_10 db 10
_100 db 100
 
5553,13 → 4481,11
 
cursor_x dd -1
cursor_y dd -1
cur_cursor_pos dd -1
old_cursor_pos dd -1
old_cursor_x dd -1
old_cursor_y dd -1
 
active_panel dd panel1_data
 
associations dd 0
 
console_colors dd 0x000000, 0x000080, 0x008000, 0x008080
dd 0x800000, 0x800080, 0x808000, 0xC0C0C0
dd 0x808080, 0x0000FF, 0x00FF00, 0x00FFFF
5629,14 → 4555,10
encodings:
.cp866 = 0
.cp1251 = 1
.koi8r = 2
.unicode = 3
 
.names:
db 'cp866 '
db 'cp1251 '
db 'koi8-r '
db 'Unicode '
 
.tables:
; cp866 - trivial map
5648,50 → 4570,7
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
; koi8-r
db 0xC4,0xB3,0xDA,0xBF,0xC0,0xD9,0xC3,0xB4,0xC2,0xC1,0xC5,0xDF,0xDC,0xDB,0xDD,0xDE
db 0xB0,0xB1,0xB2,0xF4,0xFE,0xF9,0xFB,0xF7,0xF3,0xF2,0xFF,0xF5,0xF8,0xFD,0xFA,0xF6
db 0xCD,0xBA,0xD5,0xF1,0xD6,0xC9,0xB8,0xB7,0xBB,0xD4,0xD3,0xC8,0xBE,0xBD,0xBC,0xC6
db 0xC7,0xCC,0xB5,0xF0,0xB6,0xB9,0xD1,0xD2,0xCB,0xCF,0xD0,0xCA,0xD8,0xD7,0xCE,0xFC
db 0xEE,0xA0,0xA1,0xE6,0xA4,0xA5,0xE4,0xA3,0xE5,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE
db 0xAF,0xEF,0xE0,0xE1,0xE2,0xE3,0xA6,0xA2,0xEC,0xEB,0xA7,0xE8,0xED,0xE9,0xE7,0xEA
db 0x9E,0x80,0x81,0x96,0x84,0x85,0x94,0x83,0x95,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E
db 0x8F,0x9F,0x90,0x91,0x92,0x93,0x86,0x82,0x9C,0x9B,0x87,0x98,0x9D,0x99,0x97,0x9A
 
.menu:
db .cp866
.menu.1:
dd .menu.2
dd 0
if lang eq ru
db '&DOS ⥪áâ (cp866)',0
else
db '&DOS text (cp866)',0
end if
db .cp1251
.menu.2:
dd .menu.3
dd .menu.1
if lang eq ru
db '&Windows ⥪áâ (cp1251)',0
else
db '&Windows text (cp1251)',0
end if
db .koi8r
.menu.3:
dd .menu.4
dd .menu.2
if lang eq ru
db '&Linux ⥪áâ (koi8-r)',0
else
db '&Linux text (koi8-r)',0
end if
db .unicode
.menu.4:
dd 0
dd .menu.3
db '&Unicode',0
 
active_screen dd 0
tabsize dd 8
 
5729,10 → 4608,6
dd panels_OnKey.left
dw 0x4D, 0
dd panels_OnKey.right
dw 0x51, 0
dd panels_OnKey.pgdn
dw 0x49, 0
dd panels_OnKey.pgup
dw 0xF, 0
dd panels_OnKey.tab
dw 0x47, 0
5769,24 → 4644,6
dd F12
dw 0x13, 0x10
dd panels_OnKey.ctrl_r
dw 2, 0x30
dd panels_OnKey.change_mode
dw 3, 0x30
dd panels_OnKey.change_mode
dw 4, 0x30
dd panels_OnKey.change_mode
dw 5, 0x30
dd panels_OnKey.change_mode
repeat 10
dw %+1, 0x40
dd panels_OnKey.quick_jump
end repeat
dw 0x52, 0
dd panels_OnKey.insert
dw 0x4E, 0
dd panels_OnKey.greyplus
dw 0x4A, 0
dd panels_OnKey.greyminus
db 0
 
viewer_ctrlkeys:
5822,8 → 4679,6
dd viewer_OnKey.f4
dw 0x42, 0
dd viewer_OnKey.f8
dw 0x42, 1
dd viewer_OnKey.shift_f8
dw 0x44, 0
dd viewer_OnKey.exit
dw 0x47, 0
5898,15 → 4753,11
 
;  ­¥«ì
panel_normal_color db 1Bh
panel_selected_color db 1Eh
panel_border_color db 1Bh
panel_cursor_color db 30h
panel_selected_cursor_color db 3Eh
panel_header_color db 1Bh
panel_active_header_color db 30h
column_header_color db 1Eh
panel_number_color db 1Bh
panel_numselected_color db 3Eh
panel_nscreens_color db 0Bh
; „¨ «®£¨
dialog_colors:
5963,71 → 4814,151
; ”®à¬ â ®¯¨á ­¨ï £àã¯¯ë ¯®¤á¢¥âª¨:
virtual at 0
highlight:
.IncludeAttributes db ?
.NormalColor db ?
.CursorColor db ?
.SelectedColor db ?
.SelectedCursorColor db ?
.IncludeAttributes db ?
.Mask: ; ASCIIZ-string
end virtual
 
; all highlight masks must be in lowercase!
highlight_group0:
db 13h
db 38h
db 2
db 13h, 38h, 0, 0
db '*',0
highlight_group1:
db 13h
db 38h
db 4
db 13h, 38h, 0, 0
db '*',0
highlight_group2:
db 1Fh
db 3Fh
db 10h
db 1Fh, 3Fh, 0, 0
db '*|..',0
highlight_group3:
db 0
db 0
db 10h
db 0, 0, 0, 0
db '..',0
highlight_group4:
db 1Ah
db 3Ah
db 0
db 1Ah, 3Ah, 0, 0
db '*.exe,*.com,*.bat,*.cmd',0
highlight_group5:
db 1Ah
db 3Ah
db 0
db 1Ah, 3Ah, 0, 0
db '*|*.*',0
highlight_group6:
db 1Dh
db 3Dh
db 0
db 1Dh, 3Dh, 0, 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 16h, 36h, 0, 0
db '*.bak,*.tmp',0
highlight_group8:
db 17h
db 37h
db 0
db 17h, 37h, 0, 0
db '*.asm,*.inc',0
highlight_group9:
db 1Fh
db 3Fh
db 10h
db 1Fh, 3Fh, 0, 0
db '*',0
 
associations:
dd aAsm, tinypad, AsmMenu
dd aInc, tinypad, 0
dd aTxt, tinypad, 0
dd aJpg, jpegview, 0
dd aJpeg, jpegview, 0
dd aGif, gifview, GifMenu
dd aWav, ac97, 0
dd aMp3, ac97, 0
dd aMid, midamp, 0
dd aBmp, mv, BmpMenu
dd aPng, archer, 0
dd aRtf, rtfread, 0
dd a3ds, view3ds, 0
dd aLif, life2, 0
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
ac97 db '/rd/1/AC97SND',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
 
a3ds db '3ds',0
view3ds db '/rd/1/3d/view3ds',0
 
aLif db 'lif',0
life2 db '/rd/1/demos/life2',0
 
AsmMenu:
dd aEdit, tinypad
dd aCompile, fasm
dd 0
BmpMenu:
dd aView, mv
dd aEdit, animage
dd 0
GifMenu:
dd aView, gifview
dd aEdit, animage
dd 0
 
if lang eq en
aView db '&View',0
aCompile db '&Compile',0
aEdit db '&Edit',0
else
aView db '&à®á¬®âà',0
aCompile db '&Š®¬¯¨«¨à®¢ âì',0
aEdit db '&¥¤ ªâ®à',0
end if
 
fasm db '/rd/1/develop/fasm',0
animage db '/rd/1/animage',0
 
bConfirmDelete db 1
bConfirmDeleteIncomplete db 0
 
FolderShortcuts dd 0,0,0,0,0,0,0,0,0,0
 
; ‡¤¥áì § ª ­ç¨¢ îâáï ª®­ä¨£ãà æ¨®­­ë¥ ¤ ­­ë¥
 
bWasE0 db 0
ctrlstate db 0
MemForImage dd 0
restore_semicolon dd 0
bForHex db 0
 
align 4
; ‘®®¡é¥­¨¥ ® ®¡«®¬¥ ¯à¨ ¢ë¤¥«¥­¨¨ ¯ ¬ïâ¨
6055,6 → 4986,54
dd aOk
dd 0xD
 
f8_confirm_dlgdata:
dd 1
.x dd -1
.y dd -1
.width dd ?
.height dd 3
dd 4
dd 2
dd aDeleteCaption
.main_color db ?
.border_color db ?
.header_color db ?
db 0
dd 0
dd 0
dd 4
; áâப  "‚ë å®â¨â¥ 㤠«¨âì ..."
dd 1
dd 1,0
.width2 dd ?
dd 0
dd aConfirmDeleteTextBuf
dd 1
; áâப  á ¨¬¥­¥¬ ä ©« /¯ ¯ª¨
dd 1
dd 1,1
.width3 dd ?
dd 1
.name dd ?
dd 1
; ª­®¯ª  "㤠«¨âì"
.del_btn:
dd 2
.del_x1 dd ?
dd 2
.del_x2 dd ?
dd 2
dd aDelete
.flags1 dd 0xC
; ª­®¯ª  "®â¬¥­¨âì"
dd 2
.cnl_x1 dd ?
dd 2
.cnl_x2 dd ?
dd 2
dd aCancel
.flags2 dd 8
 
; ¤¨ «®£ ª®¯¨à®¢ ­¨ï
copy_dlgdata:
dd 1
6145,22 → 5124,6
dd aCancelB
.flags2 dd 8
 
; ¤¨ «®£ ¢ë¤¥«¥­¨ï/á­ïâ¨ï
mark_dlgdata:
dd 1
dd -1, -1
dd 37, 1
dd 4, 2
.title dd ?
dd ?
dd 0, 0
dd 1
; ¯®«¥ । ªâ¨à®¢ ­¨ï
dd 3
dd 1, 0, 35, 0
dd enter_string_buf
.flags dd ?
 
RetryOrCancelBtn:
dd aRetry
dd a_Cancel
6170,14 → 5133,6
RetryOrIgnoreBtn:
dd aRetry
dd aIgnore
DeleteOrCancelBtn:
dd a_Delete
dd a_Cancel
DeleteErrorBtn:
dd aRetry
dd aSkip
dd aSkipAll
dd a_Cancel
 
if lang eq ru
aDeleteCaption db '“¤ «¥­¨¥',0
6185,6 → 5140,10
aDeleteFolder db ' ¯ ¯ªã',0
aConfirmDeleteTextMax = $ - aConfirmDeleteText - 2
aDeleteFile db ' ä ©«',0
aDelete db ' “¤ «¨âì ',0
aDeleteLength = $ - aDelete - 1
aCancel db ' Žâ¬¥­¨âì ',0
aCancelLength = $ - aCancel - 1
aCancelB db '[ Žâ¬¥­¨âì ]',0
aCancelBLength = $ - aCancelB - 1
aCopyCaption db 'Š®¯¨à®¢ ­¨¥',0
6199,8 → 5158,6
aRetry db '®¢â®à¨âì',0
a_Cancel db 'Žâ¬¥­¨âì',0
a_Delete db '“¤ «¨âì',0
aSkip db 'à®¯ãáâ¨âì',0
aSkipAll db 'à®¯ãáâ¨âì ¢á¥',0
error0msg db '‘âà ­­®... ¥â ®è¨¡ª¨',0
error1msg db '‘âà ­­®... ¥ ®¯à¥¤¥«¥­  ¡ §  ¨/¨«¨ à §¤¥« ¦ñá⪮£® ¤¨áª ',0
error2msg db '”ã­ªæ¨ï ­¥ ¯®¤¤¥à¦¨¢ ¥âáï ¤«ï ¤ ­­®© ä ©«®¢®© á¨á⥬ë',0
6234,18 → 5191,6
aMkDir db '‘®§¤ âì ¯ ¯ªã',0
aMkDirLen = $ - aMkDir - 1
aCannotMakeFolder db '¥ ¬®£ã ᮧ¤ âì ¯ ¯ªã',0
aName db 3,'ˆ¬ï'
aSize db 6,' §¬¥à'
aDate db 4,'„ â '
aTime db 5,'∴•'
aCannotLoadDLL db '¥ ¬®£ã § £à㧨âì DLL',0
aInvalidDLL db '” ©« ­¥ ­ ©¤¥­ ¨«¨ ¨¬¥¥â ­¥¢¥à­ë© ä®à¬ â',0
aMissingExport db '¥®¡å®¤¨¬ ï äã­ªæ¨ï ­¥ ­ ©¤¥­ ',0
aInitFailed db 'Žè¨¡ª  ¯à¨ ¨­¨æ¨ «¨§ æ¨¨',0
aIncompatibleVersion db '¥á®¢¬¥á⨬ ï ¢¥àá¨ï',0
aTables db '’ ¡«¨æë',0
aSelect db '®¬¥â¨âì',0
aDeselect db '‘­ïâì',0
else
aDeleteCaption db 'Delete',0
aConfirmDeleteText db 'Do you wish to delete',0
6270,8 → 5215,6
aRetry db 'Retry',0
a_Cancel db 'Cancel',0
a_Delete db 'Delete',0
aSkip db 'Skip',0
aSkipAll db 'Skip all',0
error0msg db 'Strange... No error',0
error1msg db 'Strange... Hard disk base and/or partition not defined',0
error2msg db 'The file system does not support this function',0
6297,151 → 5240,18
aCannotReadFile db 'Cannot read file',0
aIncompleteFile db 'Incomplete file was retrieved. Delete it?',0
aKeep db 'Keep',0
aCannotWriteFile db 'Cannot write to the file',0
aCannotDeleteFile db 'Cannot delete the file',0
aCannotDeleteFolder db 'Cannot delete the folder',0
aCannotWriteFile db 'Cannot write file',0
aCannotDeleteFile db 'Cannot delete file',0
aCannotDeleteFolder db 'Cannot delete folder',0
aIgnore db 'Ignore',0
aMkDirCaption db 'Make folder',0
aMkDir db 'Create the folder',0
aMkDirLen = $ - aMkDir - 1
aCannotMakeFolder db 'Cannot create folder',0
aName db 4,'Name'
aSize db 4,'Size'
aDate db 4,'Date'
aTime db 4,'Time'
aCannotLoadDLL db 'Cannot load DLL',0
aInvalidDLL db 'File is not found or invalid',0
aMissingExport db 'Required function is not present',0
aInitFailed db 'Initialization failed',0
aIncompatibleVersion db 'Incompatible version',0
aTables db 'Tables',0
aSelect db 'Select',0
aDeselect db 'Deselect',0
end if
 
aOk db 'OK',0
aNoMemory db 'No memory!'
nullstr db 0
standard_dll_path:
libini_name db '/rd/1/dll/'
standard_dll_path_size = $ - standard_dll_path
db 'libini.obj',0
aStart db 'START',0
aLibInit db 'lib_init',0
aVersion db 'version',0
aIniGetInt db 'ini.get_int',0
aIniGetStr db 'ini.get_str',0
aIniQuerySec db 'ini.query_sec',0
aNoMemory db 'No memory!',0
 
aConfirmations db 'Confirmations',0
aConfirmDelete db 'Delete',0
aConfirmDeleteIncomplete db 'DeleteIncomplete',0
 
aAssociations db 'Associations',0
aMenu db 'Menu',0
aFolderShortcuts db 'FolderShortcuts',0
aShortcut db 'Shortcut'
.d db '0',0
 
align 4
ini_import:
ini.get_int dd aIniGetInt
ini.get_str dd aIniGetStr
ini.query_sec dd aIniQuerySec
dd 0
 
virtual at 0
PanelMode:
; up to 16 columns on one panel
.NumColumns dd ?
; available column types:
COLUMN_TYPE_NONE = 0
COLUMN_TYPE_NAME = 1
COLUMN_NAME_MARK = 10h ; (reserved)
COLUMN_NAME_NOPATH = 20h ; (reserved)
COLUMN_NAME_RIGHTALIGN = 40h ; (reserved)
COLUMN_TYPE_SIZE = 2
COLUMN_SIZE_COMMA = 10h ; (reserved)
COLUMN_TYPE_PACKED_SIZE = 3 ; (reserved)
COLUMN_TYPE_DATE = 4
COLUMN_TYPE_TIME = 5
COLUMN_TYPE_DATETIME = 6 ; (reserved)
COLUMN_TYPE_DATETIME_CREATION = 7 ; (reserved)
COLUMN_TYPE_DATETIME_ACCESS = 8 ; (reserved)
COLUMN_TYPE_ATTRIBUTES = 9 ; (reserved)
COLUMN_TYPE_DESCRIPTION = 10 ; (reserved)
COLUMN_TYPE_OWNER = 11 ; (reserved)
COLUMN_TYPE_NUMLINKS = 12 ; (reserved)
COLUMN_TYPE_CUSTOM = 13 ; (reserved)
.ColumnTypes rb 16
 
.ColumnWidths rb 16
.bFullScreen db ? ; (reserved)
.bAlignExtensions db ?
rb 2
.size = $
end virtual
 
align 4
column_headers:
dd nullstr
dd aName
dd aSize
dd nullstr
dd aDate
dd aTime
draw_column_proc:
dd draw_empty_column
dd draw_name_column
dd draw_size_column
dd -1
dd draw_date_column
dd draw_time_column
colmodes:
; ०¨¬ 0 : NM,SC,D
dd 3
db COLUMN_TYPE_NAME+COLUMN_NAME_MARK, COLUMN_TYPE_SIZE+COLUMN_SIZE_COMMA
db COLUMN_TYPE_DATE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 10, 8
times 13 db 0
db 0, 1
times 2 db 0
; ०¨¬ 1 : N,N,N
dd 3
db COLUMN_TYPE_NAME, COLUMN_TYPE_NAME, COLUMN_TYPE_NAME
times 13 db 0
times 16 db 0
db 0, 1
times 2 db 0
; ०¨¬ 2 : N,N
dd 2
db COLUMN_TYPE_NAME, COLUMN_TYPE_NAME
times 14 db 0
times 16 db 0
db 0, 0
times 2 db 0
; ०¨¬ 3 : N,S,D,T
dd 4
db COLUMN_TYPE_NAME, COLUMN_TYPE_SIZE, COLUMN_TYPE_DATE, COLUMN_TYPE_TIME
times 12 db 0
db 0, 6, 8, 5
times 12 db 0
db 0, 1
times 2 db 0
; ०¨¬ 4 : N,S
dd 2
db COLUMN_TYPE_NAME, COLUMN_TYPE_SIZE
times 14 db 0
db 0, 6
times 14 db 0
db 0, 0
times 2 db 0
; ०¨¬ 5 : N,S,P,DM,DC,DA,A
; ०¨¬ 6 : N,Z
; ०¨¬ 7 : N,S,Z
; ०¨¬ 8 : N,S,O
; ०¨¬ 9 : N,S,LN
 
execinfo:
dd 7
dd 0
6476,12 → 5286,6
panel1_nfa dd ?
panel1_numfiles dd ?
panel1_files dd ?
panel1_colmode dd ?
panel1_colwidths rd 16+1
panel1_total_num dd ?
panel1_total_size dq ?
panel1_selected_num dd ?
panel1_selected_size dq ?
panel1_dir rb 1024
 
panel2_data:
6498,12 → 5302,6
panel2_nfa dd ?
panel2_numfiles dd ?
panel2_files dd ?
panel2_colmode dd ?
panel2_colwidths rd 16+1
panel2_total_num dd ?
panel2_total_size dq ?
panel2_selected_num dd ?
panel2_selected_size dq ?
panel2_dir rb 1024
 
;console_data rb max_width*max_height*2
6531,7 → 5329,6
column_width dd ?
column_height dd ?
column_index dd ?
last_column_index dd ?
 
scrpos dq ?
viewer_right_side dq ?
6540,8 → 5337,6
procinfo rb 1024
lower_file_name = procinfo + 512
 
app_path rb 1100
 
error_msg rb 128
 
prev_dir rb 1024
6559,26 → 5354,12
CopyDestEditBuf rb 12+512+1
.length = $ - CopyDestEditBuf - 13
 
enter_string_buf rb 12+512+1
 
bMemForImageValidData db ?
 
align 4
tolower_table rb 256
layout rb 128
 
copy_buffer_size = 32768
copy_buffer rb copy_buffer_size
 
; data for directory delete
; If directory nested level is >1024, then its full name is too big,
; so we see the overflow when creating full name (we check for this!)
del_dir_stack rd 1024
del_dir_stack_ptr dd ?
del_dir_query_size = 32
del_dir_query_area rb 32+304*del_dir_query_size
del_bSkipAll db ?
 
; stack
align 4
rb 512
/programs/fs/kfar/trunk/viewer.inc
10,7 → 10,6
.bEofReached db ?
.flags db ? ; & 1: hex mode
; & 2: unwrap
; & 4: big-endian unicode
rb 1
.filename rb 1024
.buf rb 16384
25,11 → 24,9
ret
.file:
lea esi, [ebp + panel1_dir - panel1_data]
push ecx
mov ecx, viewer_data.size
mov eax, viewer_data.size
mov edx, viewer_vtable
call new_screen
pop ecx
test eax, eax
jnz @f
ret
131,16 → 128,6
jz .attr_retry
jmp delete_active_screen
.readok:
cmp ebx, 2
jb .nounicode
cmp word [ebp+viewer_data.buf], 0xFEFF
jz @f
cmp word [ebp+viewer_data.buf], 0xFFFE
jnz .nounicode
or byte [ebp+viewer_data.flags], 4
@@:
mov [ebp+viewer_data.encoding], encodings.unicode
.nounicode:
call viewer_set_keybar
call viewer_draw_text
ret
147,24 → 134,6
 
viewer_get_next_char:
pusha
cmp [ebp+viewer_data.encoding], encodings.unicode
jnz @f
cmp [bForHex], 0
jnz @f
cmp dword [ebp+viewer_data.buf_start], 0
jnz @f
cmp dword [ebp+viewer_data.buf_start+4], 0
jnz @f
lea eax, [ebp+viewer_data.buf]
cmp eax, [ebp+viewer_data.buf_pos]
jnz @f
cmp word [eax], 0xFFFE
jz .skip
cmp word [eax], 0xFEFF
jnz @f
.skip:
add [ebp+viewer_data.buf_pos], 2
@@:
mov eax, [ebp+viewer_data.buf_pos]
lea ecx, [ebp+viewer_data.buf]
add ecx, [ebp+viewer_data.buf_size]
215,8 → 184,6
popa
ret
.buffered:
cmp [ebp+viewer_data.encoding], encodings.unicode
jz .unicode
mov al, [eax]
.done:
mov [esp+28], al
225,17 → 192,6
popa
ret
 
.unicode:
inc [ebp+viewer_data.buf_pos]
cmp [bForHex], 0
jnz @f
call read_unicode_char
jmp .done
@@:
mov ax, [eax]
mov [esp+29], ah
jmp .done
 
viewer_get_prev_char:
pusha
lea ecx, [ebp+viewer_data.buf]
261,61 → 217,14
.buffered:
mov eax, [ebp+viewer_data.buf_pos]
dec eax
cmp [ebp+viewer_data.encoding], encodings.unicode
jz .unicode
mov [ebp+viewer_data.buf_pos], eax
mov al, [eax]
mov [esp+28], al
.done:
clc
.ret:
popa
ret
 
.unicode:
dec eax
mov [ebp+viewer_data.buf_pos], eax
call read_unicode_char
jmp .done
 
read_unicode_char:
mov ax, [eax]
uni2ansi_char:
test [ebp+viewer_data.flags], 4
jz @f
xchg al, ah
@@:
cmp ax, 0x80
jb .ret
cmp ax, 0x401
jz .yo1
cmp ax, 0x451
jz .yo2
cmp ax, 0x410
jb .unk
cmp ax, 0x440
jb .rus1
cmp ax, 0x450
jb .rus2
.unk:
mov al, ' '
.ret:
ret
.yo1:
mov al, 'ð'
ret
.yo2:
mov al, 'ñ'
ret
.rus1:
; 0x410-0x43F -> 0x80-0xAF
add al, 0x70
ret
.rus2:
; 0x440-0x44F -> 0xE0-0xEF
add al, 0xA0
ret
 
fld_uint64:
fild qword [eax]
test byte [eax+7], 80h
599,8 → 508,6
test al, al
jns @f
movzx esi, [ebp+viewer_data.encoding]
cmp esi, encodings.unicode
jz @f
shl esi, 7
movzx eax, al
mov al, [encodings.tables-80h+esi+eax]
702,15 → 609,12
rep stosw
mov ebx, edi
pop edi
mov [bForHex], 1
call viewer_get_next_char
mov [bForHex], 0
jc .hexdone
push eax
push edi
add edi, 36*2
mov al, 0xB3
mov ah, [view_normal_color]
call .safechar
pop edi
mov eax, dword [ebp+viewer_data.cur_pos]
751,13 → 655,9
pop eax
jmp @f
.hexchar:
mov [bForHex], 1
call viewer_get_next_char
mov [bForHex], 0
jc .hexdone
@@:
cmp [ebp+viewer_data.encoding], encodings.unicode
jz .hexchar_unicode
push eax
shr al, 4
call .hex_digit
798,53 → 698,6
@@:
cmp ecx, 16
jnz .hexchar
jmp .hexchar_nextline
.hexchar_unicode:
push eax
shr eax, 12
call .hex_digit
pop eax
push eax
shr eax, 8
and al, 0xF
call .hex_digit
pop eax
push eax
shr al, 4
call .hex_digit
pop eax
push eax
and al, 0xF
call .hex_digit
mov al, ' '
mov ah, [view_normal_color]
call .safechar
pop eax
push edi
add edi, 38*2
push ecx
shl ecx, 3
sub edi, ecx
pop ecx
cmp ecx, 4
jb @f
sub edi, 4
@@:
call uni2ansi_char
mov ah, [view_normal_color]
call .safechar
pop edi
inc ecx
cmp ecx, 4
jnz @f
mov al, 0xB3
call .safechar
mov al, ' '
call .safechar
@@:
cmp ecx, 8
jnz .hexchar
.hexchar_nextline:
mov edi, ebx
add esi, 3
mov edx, esi
1079,11 → 932,8
viewer_next_newline:
test [ebp+viewer_data.flags], 1
jz .nohex
push 8
push 10h
pop ecx
cmp [ebp+viewer_data.encoding], encodings.unicode
jz @f
add ecx, ecx
@@:
call viewer_get_next_char
jc @f
1128,9 → 978,6
cmp cl, 0xD xor 0xA
jz .2
dec [ebp+viewer_data.buf_pos]
cmp [ebp+viewer_data.encoding], encodings.unicode
jnz .2
dec [ebp+viewer_data.buf_pos]
.2:
.ret:
call viewer_set_curpos
1139,11 → 986,8
viewer_prev_newline:
test [ebp+viewer_data.flags], 1
jz .nohex
push 8
push 10h
pop ecx
cmp [ebp+viewer_data.encoding], encodings.unicode
jz @f
add ecx, ecx
@@:
call viewer_get_prev_char
jc @f
1252,11 → 1096,7
@@:
end if
movzx esi, [ebp+viewer_data.encoding]
dec esi
jz @f
push 1
pop esi
@@:
xor esi, 1
lea esi, [encodings.names+esi*8]
lea edi, [eax+keybar_cp-keybar_viewer]
movsd
1314,13 → 1154,11
ret
.f8:
movzx esi, [ebp+viewer_data.encoding]
dec [ebp+viewer_data.encoding]
jz .done_redraw_keybar
mov [ebp+viewer_data.encoding], 1
jmp .done_redraw_keybar
xor [ebp+viewer_data.encoding], 1
call viewer_set_keybar
jmp .done_redraw
.f2:
xor [ebp+viewer_data.flags], 2
.done_redraw_keybar:
call viewer_set_keybar
jmp .done_redraw
.f4:
1329,13 → 1167,7
call viewer_set_keybar
popf
jnz .tohex
push 1
pop eax
cmp [ebp+viewer_data.encoding], encodings.unicode
jnz @f
add eax, eax
@@:
add dword [ebp+viewer_data.cur_pos], eax
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
1417,29 → 1249,6
mov dword [ebp+viewer_data.col], eax
mov dword [ebp+viewer_data.col+4], edx
jmp .done_redraw
.shift_f8:
mov ecx, encodings.menu.1
mov al, [ebp+viewer_data.encoding]
@@:
cmp byte [ecx-1], al
jz @f
mov ecx, [ecx]
jmp @b
@@:
push 1
push aTables
push ecx
call menu
cmp eax, -1
jz .ret
mov al, [eax-1]
mov [ebp+viewer_data.encoding], al
cmp al, encodings.unicode
jnz .done_redraw_keybar
add dword [ebp+viewer_data.cur_pos], 1
adc dword [ebp+viewer_data.cur_pos+4], 0
and dword [ebp+viewer_data.cur_pos], not 1
jmp .done_redraw_keybar
 
viewer_getname:
if lang eq ru
/programs/fs/kfar/trunk/dialogs.inc
27,8 → 27,6
pushad
mov ebx, [esp+20h+4]
; center window if required
push [ebx+dlgtemplate.x]
push [ebx+dlgtemplate.y]
cmp [ebx+dlgtemplate.x], -1
jnz @f
mov eax, [cur_width]
61,8 → 59,6
cmp [ebx+dlgtemplate.border_size_y], 1
jge .sizeok
.sizeerr:
pop [ebx+dlgtemplate.y]
pop [ebx+dlgtemplate.x]
popad
or eax, -1
ret 8
77,11 → 73,11
jz @f
mov edi, warning_colors
.setcolor:
mov al, [edi + dialog_main_color-dialog_colors]
mov al, [dialog_main_color-dialog_colors+edi]
mov [ebx+dlgtemplate.main_color], al
mov al, [edi + dialog_border_color-dialog_colors]
mov al, [dialog_border_color-dialog_colors+edi]
mov [ebx+dlgtemplate.border_color], al
mov al, [edi + dialog_header_color-dialog_colors]
mov al, [dialog_header_color-dialog_colors+edi]
mov [ebx+dlgtemplate.header_color], al
@@:
; allocate memory for data under dialog
99,12 → 95,10
add edx, [ebx+dlgtemplate.border_size_y]
inc edx
mul edx
lea ecx, [eax*2]
call xpgalloc
add eax, eax
call mf_alloc
test eax, eax
jnz @f
pop [ebx+dlgtemplate.y]
pop [ebx+dlgtemplate.x]
popad
or eax, -1
ret 8
302,7 → 296,7
dec edx
jnz @b
; send redraw message
mov eax, [esp+28h+8]
mov eax, [esp+20h+8]
push ebx ebp
push 0
push 0
353,7 → 347,7
jz .alt_down
cmp al, 0xB8
jz .alt_up
mov ecx, [esp+28h+8]
mov ecx, [esp+20h+8]
push ebx ebp
push 0
push eax
363,7 → 357,7
pop ebp ebx
test eax, eax
jz .event
mov [esp+8+28], eax
mov [esp+28], eax
jmp .exit
.ctrl_down:
test ah, ah
436,11 → 430,9
call draw_keybar
cmp ebx, nomem_dlgdata
jz @f
mov ecx, ebp
call pgfree
mov eax, ebp
call mf_free
@@:
pop [ebx+dlgtemplate.y]
pop [ebx+dlgtemplate.x]
or [cursor_x], -1
or [cursor_y], -1
call draw_image
556,7 → 548,7
; void* variants, const char* title, unsigned flags);
menu_centered_in:
pushad
mov ecx, 56
mov eax, 56
; 36 bytes for dlgtemplate + additional:
; +36: dd cur_variant
; +40: dd num_variants
563,7 → 555,7
; +44: dd begin_variant
; +48: dd end_variant
; +52: dd cur_variant_idx
call xpgalloc
call xmalloc
test eax, eax
jnz @f
.ret_bad:
708,8 → 700,8
push ebx
call GenericBox
mov [esp+28], eax
mov ecx, ebx
call pgfree
mov eax, ebx
call mf_free
popad
ret 28
 
723,33 → 715,6
.draw:
call .dodraw
ret 16
.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 16
.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
.key:
mov al, [esp+12]
cmp al, 0x48
808,6 → 773,33
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 16
.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]
@@:
1091,7 → 1083,6
ret 16
@@:
lea ebx, [ebp+dlgtemplate.size+12]
mov ecx, [ebx-4]
.enter_find:
cmp [ebx+dlgitemtemplate.type], 2
jnz @f
1099,8 → 1090,7
jnz .enter_found
@@:
add ebx, dlgitemtemplate.size
loop .enter_find
jmp .enter_found
jmp .enter_find
.tab:
test [ctrlstate], 3
jnz .shift_tab
1169,14 → 1159,46
cmp al, 0x0E
jz .editor_backspace
cmp al, 0x53
jnz .editor_char
.editor_del:
mov ecx, [edx+4]
lea edi, [ecx+edx+12]
lea esi, [edi+1]
cmp byte [edi], 0
jz .ret_test
jmp .copy_and_ret_test
jz .editor_del
test [ctrlstate], 0x3C
jnz .ret_draw
; query keyboard layout
pushad
push 26
pop eax
push 2
pop ebx
xor ecx, ecx
cmp [ctrlstate], 1
sbb ecx, -2
mov edx, layout
int 0x40
popad
; translate scancode to ASCII
movzx eax, al
movzx eax, byte [layout+eax]
push eax
; insert entered symbol
xor eax, eax
lea edi, [edx+12]
or ecx, -1
repnz scasb
not ecx
pop eax
cmp ecx, [edx]
ja .ret_test ; buffer capacity exceeded
lea edi, [edx+ecx+12-1]
mov esi, [edx+4]
lea esi, [edx+esi+12]
@@:
mov cl, [edi]
mov [edi+1], cl
dec edi
cmp edi, esi
jae @b
mov [esi], al
inc dword [edx+4]
@@: jmp .ret_test
.editor_left:
mov ecx, [edx+4]
jecxz @f
1226,46 → 1248,13
test al, al
jnz @b
jmp .ret_test
.editor_char:
test [ctrlstate], 0x3C
jnz .ret_draw
; query keyboard layout
pushad
push 26
pop eax
push 2
pop ebx
xor ecx, ecx
cmp [ctrlstate], 1
sbb ecx, -2
mov edx, layout
int 0x40
popad
; translate scancode to ASCII
movzx eax, al
movzx eax, byte [layout+eax]
push eax
; insert entered symbol
xor eax, eax
lea edi, [edx+12]
or ecx, -1
repnz scasb
not ecx
pop eax
cmp ecx, [edx]
ja .ret_test ; buffer capacity exceeded
lea edi, [edx+ecx+12-1]
mov esi, [edx+4]
lea esi, [edx+esi+12]
@@:
mov cl, [edi]
mov [edi+1], cl
dec edi
cmp edi, esi
jae @b
mov [esi], al
inc dword [edx+4]
@@: jmp .ret_test
.editor_del:
mov ecx, [edx+4]
lea edi, [ecx+edx+12]
lea esi, [edi+1]
cmp byte [edi], 0
jz .ret_test
jmp .copy_and_ret_test
 
.dodraw:
or [cursor_x], -1
1445,16 → 1434,6
; int num_strings, const char* strings[],
; int num_buttons, const char* buttons[]);
; may be x=-1 and/or y=-1
SayErr:
push 2
jmp @f
 
; int __stdcall Message(const char* title, int x, int y,
; int num_strings, const char* strings[],
; int num_buttons, const char* buttons[]);
Message:
push 1
@@:
; [esp+4] = title
; [esp+8] = x
; [esp+12] = y
1462,22 → 1441,21
; [esp+20] = strings
; [esp+24] = num_buttons
; [esp+28] = buttons
pop eax
pushad
mov ecx, [esp+4+16]
add ecx, [esp+4+24]
imul ecx, dlgitemtemplate.size
add ecx, dlgtemplate.size+12
call xpgalloc
SayErr:
mov eax, [esp+16]
add eax, [esp+24]
imul eax, dlgitemtemplate.size
add eax, dlgtemplate.size+12
call xmalloc
test eax, eax
jnz @f
popad
or eax, -1
ret 28
@@:
pushad
mov ebx, eax
mov edi, eax
mov eax, [esp+28]
mov eax, 2
stosd ; dlgtemplate.flags
mov eax, [esp+32+8]
stosd ; dlgtemplate.x
1614,7 → 1592,7
sub eax, [esp+32+16]
@@:
mov [esp+28], eax
mov ecx, ebx
call pgfree
mov eax, ebx
call mf_free
popad
ret 28
/programs/fs/kfar/trunk/tools.inc
1,43 → 1,7
pgalloc:
; in: ecx=size
xmalloc:
; in: eax=size
; out: eax=pointer or NULL
push ebx
push 68
pop eax
push 12
pop ebx
int 0x40
pop ebx
ret
 
pgfree:
; in: ecx=pointer
; destroys eax
push ebx
push 68
pop eax
push 13
pop ebx
int 0x40
pop ebx
ret
 
pgrealloc:
; in: ecx=size, edx=pointer
; out: eax=pointer
push ebx
push 68
pop eax
push 20
pop ebx
int 0x40
pop ebx
ret
 
xpgalloc:
; in: ecx=size
; out: eax=pointer or NULL
call pgalloc
call mf_alloc
.common:
test eax, eax
jnz @f
46,11 → 10,11
@@:
ret
 
xpgrealloc:
; in: edx=pointer, ecx=new size
xrealloc:
; in: eax=pointer, ebx=new size
; out: eax=pointer or NULL
call pgrealloc
jmp xpgalloc.common
call mf_realloc
jmp xmalloc.common
 
get_error_msg:
; in: eax=error code
103,171 → 67,3
pop ecx edx
stosb
jmp .ret
 
libini_alloc:
push ecx
mov ecx, [esp+8]
call xpgalloc
pop ecx
ret 4
libini_free:
push ecx
mov ecx, [esp+8]
call pgfree
pop ecx
ret 4
libini_realloc:
push ecx edx
mov edx, [esp+8+4]
mov ecx, [esp+8+8]
call xpgrealloc
pop edx ecx
ret 8
 
libini_dllload:
push esi
mov esi, [esp+8]
.lib:
lodsd
test eax, eax
jz .ret
push eax
lodsd
xchg esi, [esp]
xor ebp, ebp ; no version control
call load_dll_and_import
pop esi
test eax, eax
jz .lib
.ret:
pop esi
ret 4
 
load_dll_and_import:
cmp byte [eax], '/'
jz .do
push esi
mov edi, saved_file_name
push edi
mov esi, standard_dll_path
mov ecx, standard_dll_path_size
rep movsb
mov esi, eax
mov ecx, 1024-standard_dll_path_size
@@:
lodsb
stosb
test al, al
loopnz @b
pop eax
pop esi
jz .do
push eax
mov edi, aFileNameTooBig
.sayerr:
push dword aCannotLoadDLL
push edi
mov eax, esp
push dword aOk
push esp
push 1
push eax
push 3
push -1
push -1
push dword aError
call SayErr
add esp, 16
xor eax, eax
inc eax
ret
.do:
push eax
mov ecx, eax
push 68
pop eax
push 19
pop ebx
int 0x40
mov edi, aInvalidDLL
test eax, eax
jz .sayerr
; initialize import
mov edi, aMissingExport
mov edx, eax
.import_loop:
lodsd
test eax, eax
jz .import_done
call .find_exported_function
jc .sayerr
mov [esi-4], eax
jmp .import_loop
.import_done:
; check version
test ebp, ebp
jz .version_ok
mov edi, aIncompatibleVersion
mov eax, aVersion
call .find_exported_function
jc .sayerr
cmp ax, bp
jb .sayerr
shr eax, 16
cmp eax, ebp
ja .sayerr
.version_ok:
; initialize library
mov eax, aStart
call .find_exported_function
jc @f
push 1 ; DLL_ENTRY
call eax
.ret0:
pop eax
xor eax, eax
ret
@@:
mov eax, aLibInit
call .find_exported_function
jc .ret0
mov esi, eax
mov eax, libini_alloc
mov ebx, libini_free
mov ecx, libini_realloc
mov edx, libini_dllload
call esi
mov edi, aInitFailed
test eax, eax
jnz .sayerr
jmp .ret0
 
.find_exported_function:
push edx
.import_loop_i:
mov ebx, [edx]
test ebx, ebx
jz .import_notfound
push eax
@@:
mov cl, [eax]
cmp cl, [ebx]
jnz .import_find_next
test cl, cl
jz .import_found
inc eax
inc ebx
jmp @b
.import_find_next:
pop eax
add edx, 8
jmp .import_loop_i
.import_found:
pop eax
mov eax, [edx+4]
pop edx
ret
.import_notfound:
pop edx
stc
ret
/programs/fs/kfar/trunk/font.inc
22,111 → 22,27
end virtual
 
font:
macro set_name_test a,b
{
if %=a
font_data_#a = b
end if
}
macro set_name b
{
set_name_test 1,b
set_name_test 2,b
set_name_test 3,b
set_name_test 4,b
set_name_test 5,b
set_name_test 6,b
set_name_test 7,b
set_name_test 8,b
set_name_test 9,b
set_name_test 10,b
set_name_test 11,b
set_name_test 12,b
set_name_test 13,b
set_name_test 14,b
set_name_test 15,b
set_name_test 16,b
}
macro db_name_test a
{
if %=a
db font_data_#a
end if
}
macro db_name
{
db_name_test 1
db_name_test 2
db_name_test 3
db_name_test 4
db_name_test 5
db_name_test 6
db_name_test 7
db_name_test 8
db_name_test 9
db_name_test 10
db_name_test 11
db_name_test 12
db_name_test 13
db_name_test 14
db_name_test 15
db_name_test 16
}
macro dw_name_test a
{
if %=a
dw font_data_#a
end if
}
macro dw_name
{
dw_name_test 1
dw_name_test 2
dw_name_test 3
dw_name_test 4
dw_name_test 5
dw_name_test 6
dw_name_test 7
dw_name_test 8
dw_name_test 9
dw_name_test 10
dw_name_test 11
dw_name_test 12
dw_name_test 13
dw_name_test 14
dw_name_test 15
dw_name_test 16
}
repeat font_height
cur_scan = %
repeat 16
repeat 256
virtual at 0
file fontname:3Eh + font_bmp_scanline*(font_height*(17-%)-cur_scan), font_width*2
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
repeat 16
load a1 dword from ((%-1)*font_width) shr 3
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)
set_name a1
end repeat
end virtual
if font_width > 8
repeat 16
dw_name
end repeat
dw a1
else
repeat 16
db_name
end repeat
db a1
end if
end repeat
end repeat
purge set_name_test
purge db_name_test
purge dw_name_test
purge set_name
purge db_name
purge dw_name
/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