📄 systree.asm
字号:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; SYSTEM TREE BROWSER ;
; ;
; Compile with FASM for MenuetOS ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; program start
dd I_END ; program image size
dd 0x100000 ; required amount of memory
dd 0x7f000 ; stack
dd 0x0,0x0 ; param,icon
START: ; start of execution
call read_directory
call draw_window ; at first, draw the window
still:
mov eax,10 ; wait here for event
int 0x40
cmp eax,1 ; redraw request ?
jz red
cmp eax,2 ; key in buffer ?
jz key
cmp eax,3 ; button in buffer ?
jz button
jmp still
red: ; redraw
call draw_window
jmp still
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
jmp still
button: ; button
mov eax,17
int 0x40
cmp ah,1 ; button id=1 ?
jnz noclose
mov eax,0xffffffff ; close this program
int 0x40
noclose:
pusha ; clear info text area
mov eax,13
mov ebx,70*65536+300
mov ecx,265*65536+8
mov edx,0xffffff
int 0x40
popa
cmp ah,41 ; button id=12 -> directory
jb noreadhd
shr eax,8
sub eax,41
imul eax,12
cmp eax,[loclen]
jge still
mov [loclen],eax
mov [readblock],1
call read_directory
call drawbuttons
jmp still
noreadhd:
cmp ah,13 ; button id=13 ?
jnz noreadhd2
mov eax,[readblock]
cmp eax,1
jz nozer1
sub eax,1
mov [readblock],eax
call read_directory
call drawbuttons
nozer1:
jmp still
noreadhd2:
cmp ah,14 ; button id=14 ?
jnz noreadhd3
mov eax,[readblock]
add eax,1
mov [readblock],eax
call read_directory
call drawbuttons
nozer2:
jmp still
noreadhd3:
cmp ah,21
jge yesnewdir
jmp nonewdir
yesnewdir:
pusha
mov al,ah
and eax,255
sub eax,21
xor edx,edx
mov ebx,62
mul ebx
mov esi,eax
add esi,fileinfo+7
cmp [esi],word 'OL'
jz folok
cmp [esi+14],word 'XT' ; show txt and asm files
je yeseditor
cmp [esi+14],word 'SM'
je yeseditor
jmp noeditor
yeseditor:
popa
shr eax,8
sub eax,21
imul eax,32
add eax,data_area+1024
mov esi,eax
mov edi,param
mov ecx,11
cld
rep movsb
mov eax,19
mov ebx,editor
mov ecx,param
int 0x40
jmp still
noeditor:
; start application
popa
pusha
mov al,ah
and eax,255
sub eax,21
xor edx,edx
mov ebx,32
mul ebx
mov ebx,eax
add ebx,data_area+1024
cmp [location+1],dword 'RAMD'
jne no_ramdisk_start
mov eax,19
mov ecx,0
int 0x40
no_ramdisk_start:
cmp [location+1],dword 'HARD'
jne no_harddisk_start
mov esi,ebx
mov edi,location+1
add edi,[loclen]
mov ecx,11
cld
rep movsb
mov eax,31
mov ebx,location+24
mov ecx,[loclen]
sub ecx,12
mov edx,0x10000
int 0x40
no_harddisk_start:
popa
jmp still
folok:
popa
mov al,ah
and eax,255
sub eax,21
xor edx,edx
mov ebx,32
mul ebx
mov esi,eax
mov edi,[loclen]
add edi,1
add esi,data_area+1024
cmp [esi],word '..' ; if '..'
jnz chdir1
mov eax,[loclen]
sub eax,12
mov [loclen],eax
mov [readblock],dword 1
jmp readhd
chdir1:
cmp [esi],byte '.' ; if '.'
jnz chdir2
jmp still
chdir2:
add edi,location
mov ecx,11
cld
rep movsb
mov eax,[loclen]
add eax,12
mov [loclen],eax
mov [readblock],dword 1
readhd:
call read_directory
call drawbuttons
jmp still
nonewdir:
jmp still
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
draw_window:
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
; DRAW WINDOW
mov eax,0 ; function 0 : define and draw window
mov ebx,50*65536+480 ; [x start] *65536 + [x size]
mov ecx,50*65536+290 ; [y start] *65536 + [y size]
mov edx,0x03ffffff ; color of work area RRGGBB
mov esi,0x808899ff ; color of grab bar RRGGBB,8->color g
mov edi,0x008899ff ; color of frames RRGGBB
int 0x40
; WINDOW LABEL
mov eax,4 ; function 4 : write text to window
mov ebx,8*65536+8 ; [x start] *65536 + [y start]
mov ecx,0x10ffffff ; color of text RRGGBB
mov edx,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
; UP
mov eax,8 ; function 8 : define and draw button
mov ebx,415*65536+22 ; [x start] *65536 + [x size]
mov ecx,37*65536+12 ; [y start] *65536 + [y size]
mov edx,13 ; button id
mov esi,[b_color] ; button color RRGGBB
int 0x40
mov ebx,424*65536+40 ; draw info text with function 4
mov ecx,0xffffff
mov edx,up
mov esi,1
mov eax,4
int 0x40
; DOWN
mov eax,8 ; function 8 : define and draw button
mov ebx,438*65536+22 ; [x start] *65536 + [x size]
mov ecx,37*65536+12 ; [y start] *65536 + [y size]
mov edx,14 ; button id
mov esi,[b_color] ; button color RRGGBB
int 0x40
mov ebx,447*65536+40 ; draw info text with function 4
mov ecx,0xffffff
mov edx,down
mov esi,1
mov eax,4
int 0x40
call drawbuttons
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
ret
drawbuttons:
pusha
mov ebx,150*65536+310
mov ecx,50*65536+12
mov edx,21
mov esi,0x3344aa;0x6677cc
newb:
push edx
mov eax,8
add edx,0x80000000
int 0x40
pop edx
int 0x40
pusha
sub ebx,130*65536
mov bx,120
add edx,20
push edx
add edx,0x80000000
int 0x40
pop edx
int 0x40
popa
pusha
sub edx,21
mov esi,edx
imul edx,12
cmp edx,[loclen]
jg no_dir_text
mov eax,4
sub ebx,125*65536
shr ecx,16
mov bx,cx
add bx,3
shl esi,2+16
add ebx,esi
mov ecx,0xffffff
add edx,root
cmp edx,root
jne no_yellow
mov ecx,0xffff00
no_yellow:
mov esi,11
int 0x40
no_dir_text:
popa
pusha
sub edx,21
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -