📄 systree.asm
字号:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; SYSTREE BROWSER
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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
; 0x80000 pre-read area
; 0x20000 return area
; 0x10000 work area
diry equ 66
dirys equ 223
locy equ 47
START: ; start of execution
call pre_read_directory
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
shr eax , 8
; Menu quit
cmp eax , 504
jne no_menu_quit
mov eax , -1
int 0x40
no_menu_quit:
; Other menu selections
cmp eax , 500
jb no_menu
cmp eax , 520
ja no_menu
jmp still
no_menu:
; Scroll
cmp eax , 1000
jb noscroll
cmp eax , 9999
ja noscroll
mov [scrollv],eax
call draw_scroll
mov eax,[scrollv]
sub eax , 1000-1
mov [readblock],eax
call read_directory
call drawbuttons
jmp still
noscroll:
cmp eax,1 ; button id=1 ?
jnz noclose
mov eax,0xffffffff ; close this program
int 0x40
noclose:
shl eax , 8
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], word 'FD'
jne no_ramdisk_start
mov eax,19
mov ecx,0
int 0x40
no_ramdisk_start:
cmp [location+1], word 'HD'
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 pre_read_directory
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,100*65536+407 ; [x start] *65536 + [x size]
mov ecx,100*65536+306 ; [y start] *65536 + [y size]
mov edx,0x04ffffff ; color of work area RRGGBB
mov esi,window_label ; color of grab bar RRGGBB,8->co
mov edi,menu_struct ; color of frames RRGGBB
int 0x40
; Frames for files
mov eax , 38
mov ebx , 19 * 65536 + 387
mov ecx , (diry-1) * 65536 + (diry-1)
mov edx , 0x000000
int 0x40
mov ecx , (diry+dirys) * 65536 + (diry+dirys)
int 0x40
mov ebx , 19 * 65536 + 19
mov ecx , (diry-1) * 65536 + (diry+dirys)
int 0x40
call draw_scroll
call drawbuttons
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
ret
draw_scroll:
mov eax , 113
mov ebx , 1 shl 16 + 375
mov ecx , diry shl 16 + dirys
mov edx , 1000
mov esi , [scrollsize]
mov edi , [scrollv]
int 0x40
ret
scrollsize: dd 100
scrollv: dd 1000
zeroentry: db 0
drawbuttons:
; Draw directory
pusha
mov eax , 13
mov ebx , 19 * 65536 + 369
mov ecx , locy * 65536 + 11
mov edx , 0xe0e0e0
int 0x40
popa
pusha
mov eax , 4
mov ebx , 21 * 65536 + (locy+2)
mov ecx , 0x000000
mov edx , root+12
mov edi , [loclen]
inc edi
newdirchar:
cmp [edx],byte ' '
jbe skipchar
mov esi , 1
int 0x40
add ebx , 6*65536
skipchar:
inc edx
dec edi
jnz newdirchar
popa
; Draw files
pusha
mov ebx,20*65536+354
mov ecx,diry*65536+12
mov edx,21
mov esi,0x003344aa;0x6677cc
newb:
push edx
mov eax,8
add edx,0x80000000
int 0x40
pop edx
push edx
add edx,0x40000000
int 0x40
pop edx
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
mov ecx,0x000000
; int 0x40
no_dir_text:
popa
pusha
sub edx,21
mov eax,edx
xor edx,edx
mov ebx,62
mul ebx
add eax,fileinfo
mov ebx,25*65536
shr ecx,16
mov bx,cx
add ebx,5*65536+3
mov ecx,0xffffff
cmp [eax+21],word 'SM'
jnz noasm
mov ecx,0x88ffff
noasm:
cmp [eax+7],word 'OL'
jnz nofolt
mov ecx,0xffff00
nofolt:
cmp [eax+7],word 'EL'
jnz nodelt
mov ecx,0x99aaee
nodelt:
mov edx,eax
mov esi,49
mov eax,4
mov ecx,0x000000
pusha
mov eax , 13
mov ecx , ebx
shl ecx , 16
mov bx , 346
sub ebx , 6*65536
mov cx , 8
mov edx , 0xffffff
int 0x40
popa
sub ebx , 3 * 65536
add esi , 5+3
int 0x40
popa
add ecx,(11*65536)
inc edx
cmp edx,37+4
jnz newb
popa
ret
fileinfoblock:
dd 0x0 ; read
dd 0x0 ; first block
dd 0x1 ; number of blocks to read
dd 0x20000 ; ret
dd 0x10000 ; work
filedir:
times 12*10 db 32
pre_read_directory:
mov edi , 0x80000
mov ecx , 0x70000
mov eax , 0
cld
rep stosb
mov esi,location
mov edi,filedir
mov ecx,12*8
cld
rep movsb
mov eax,[loclen]
mov [filedir+eax],byte 0
mov ecx , 0
prdl1:
mov [fileinfoblock+4],ecx
push ecx
imul ecx , 512
add ecx , 0x80000
mov [fileinfoblock+12],ecx ; dword 0x80000
pop ecx
mov eax,58
mov ebx,fileinfoblock
int 0x40
cmp [loclen],dword 20
jb read_error
cmp eax,0
jne read_error
inc ecx
cmp ecx , 100
ja read_error
jmp prdl1
read_error:
inc ecx
imul ecx , 16
add ecx , 32
mov [scrollsize],ecx
cmp [loclen],dword 5
jb nodotadd
cmp [0x80000],dword '.. '
je nodotadd
cmp [0x80000+32],dword '.. '
je nodotadd
mov esi , 0x80000 + 0x70000
mov edi , 0x80000+32 + 0x70000
mov ecx , 0x70000+32
std
rep movsb
mov [0x80000],dword '.. '
mov [0x80000+11],byte 0x10
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -