📄 filesel.asm
字号:
sub eax,10
jns @@ek0
xor eax,eax
@@ek0: mov _FS_FirstFile,eax
mov _FS_drawstate,4 ;make sure list gets a re-draw.
jmp drawloop
;
;PgUp key was pressed.
;
PgUpKeyed: cmp _FS_FirstFile,0 ;check if we're already at the
jz waitloop ;top of the list.
mov eax,_FS_FirstFile
sub eax,10
js HomeKeyed
mov _FS_FirstFile,eax
mov _FS_drawstate,4 ;make sure list gets a re-draw.
jmp drawloop
;
;PgDn key was pressed.
;
PgDnKeyed: mov eax,_FS_FirstFile ;see if we reached the end of the
add eax,10 ;file list yet.
cmp eax,_FS_TotalFiles
jnc waitloop
add eax,10
cmp eax,_FS_TotalFiles
jnc EndKeyed
sub eax,10
mov _FS_FirstFile,eax
mov _FS_drawstate,4 ;make sure list gets a re-draw.
jmp drawloop
;
;File list UP button pressed so deal with it.
;
fileup: cmp _FS_FirstFile,0 ;check if we're already at the
jz waitloop ;top of the list.
dec _FS_FirstFile ;update list start entry number
mov _FS_drawstate,4 ;and make sure it gets a re-draw.
mov ecx,dFILE_FILEUP
mov esi,offset dFileSelector ;get buttons current state so
call DialogGetState ;we know if it should be re-drawn.
or eax,eax
jnz @@fu1
inc eax ;set button to in position and
call DialogSetState ;force a re-draw.
or _FS_drawstate,32
@@fu1: mov ecx,1 ;wait for a bit so the list doesn't
call Delay ;go past to quickly.
jmp drawloop
;
;File list DOWN button pressed so deal with it.
;
filedown: mov eax,_FS_FirstFile ;see if we reached the end of the
add eax,10 ;file list yet.
cmp eax,_FS_TotalFiles
jnc waitloop
inc _FS_FirstFile ;update start file number and
mov _FS_drawstate,4 ;make sure list gets a re-draw.
inc eax
mov ecx,dFILE_FILEDOWN
mov esi,offset dFileSelector ;get button state so we know if
call DialogGetState ;it needs pushing in.
or eax,eax
jnz @@fd1
inc eax ;put button in the in position
call DialogSetState ;and force a re-draw.
or _FS_drawstate,64
@@fd1: mov ecx,1 ;wait for a bit so the list doesn't
call Delay ;go past to quickly.
jmp drawloop
;
;Type list UP button pressed so deal with it.
;
typeup: cmp _FS_FirstMask,0 ;check we're not already at
jz waitloop ;the top of the list.
dec _FS_FirstMask ;update start position.
mov _FS_drawstate,8 ;make sure type list is updated.
mov ecx,dFILE_TYPEUP
mov esi,offset dFileSelector ;check if button is already in
call DialogGetState ;the in position.
or eax,eax
jnz @@tu1
inc eax ;put button in the in position
call DialogSetState ;and force a re-draw.
or _FS_drawstate,128
@@tu1: mov ecx,1 ;wait for a bit so the list doesn't
call Delay ;go past to quickly.
jmp drawloop
;
;Type list DOWN button pressed so deal with it.
;
typedown: mov eax,_FS_FirstMask ;make sure we're not already at
add eax,10 ;the end of the list.
cmp eax,_FS_TotalMasks
jnc waitloop
inc _FS_FirstMask ;update start position and make
mov _FS_drawstate,8 ;sure list gets a re-draw.
inc eax
mov ecx,dFILE_TYPEDOWN
mov esi,offset dFileSelector ;now see if button is already in
call DialogGetState ;the in position.
or eax,eax
jnz @@td1
inc eax ;put button in the in position and
call DialogSetState ;force a re-draw.
mov _FS_drawstate,8+256
@@td1: mov ecx,2 ;wait for a bit so the list doesn't
call Delay ;go past to quickly.
jmp drawloop
;
;Drive list UP button pressed so deal with it.
;
driveup: cmp _FS_FirstDrive,0 ;check we're not already at the
jz waitloop ;top of the list.
dec _FS_FirstDrive ;update start position and make
mov _FS_drawstate,16 ;sure list gets a re-draw.
mov ecx,dFILE_DRIVEUP
mov esi,offset dFileSelector ;now see if the button is already
call DialogGetState ;in the in position.
or eax,eax
jnz @@du1
inc eax ;put button in the in position and
call DialogSetState ;force a re-draw.
mov _FS_drawstate,16+512
@@du1: mov ecx,2 ;wait for a bit so the list doesn't
call Delay ;go past to quickly.
jmp drawloop
;
;Drive list DOWN button pressed so deal with it.
;
drivedown: mov eax,_FS_FirstDrive ;check if we've already reached
add eax,10 ;the end of the list.
cmp eax,_FS_TotalDrives
jnc waitloop
inc _FS_FirstDrive ;update start position and make
mov _FS_drawstate,16 ;sure the list gets a re-draw.
mov ecx,dFILE_DRIVEDOWN
mov esi,offset dFileSelector ;now see if the button is already
call DialogGetState ;in the in position.
or eax,eax
jnz @@dd1
inc eax ;put button in the in position and
call DialogSetState ;force a re-draw.
mov _FS_drawstate,8+1024
@@dd1: mov ecx,2 ;wait for a bit so the list doesn't
call Delay ;go past to quickly.
jmp drawloop
;
;
; OK button selected so return selected files to caller.
;
;
okexit:
;
;Build a selected file list from either the typed name or the current list.
;
cmp _FS_TypedFocus,0 ;is the typed name the current
jz @@oe0 ;focus?
mov esi,_FS_FileList ;Any file names in the list?
cmp d[esi],0
jnz @@oe1
mov ecx,4+256+14 ;make sure at least one names
call ReMalloc ;worth of space in the list
jc memexit ;buffer.
mov _FS_FileList,esi
inc d[esi] ;update number of entries.
@@oe1: ;
add esi,4+256 ;skip past count and path.
mov edi,esi
mov esi,offset _FS_typedname ;copy typed name into the file
call CopyString ;list buffer.
mov al,[esi+13]
mov [edi+13],al ;copy attributes and make sure
or b[edi+13],128 ;selected bit is set.
@@oe0: ;
mov esi,_FS_FileList ;point to file list.
mov ecx,[esi] ;get number of entries.
add esi,4+256 ;skip count and path.
xor edx,edx ;reset counter.
@@oe2: test b[esi+13],128 ;this a selected entry?
jz @@oe3
inc edx ;update counter.
@@oe3: add esi,14 ;next file name.
dec ecx
jnz @@oe2
;
or edx,edx ;if no file names in the list
jz nofileexit ;then pretend CANCEL pressed.
;
push edx
mov esi,_FS_FileList ;point to file list again.
add esi,4+256 ;skip count and path.
@@oe4: or edx,edx
jz @@oe5
@@oe6: test b[esi+13],128 ;this a selected file?
jnz @@oe7
add esi,14 ;next file.
jmp @@oe6
@@oe7: and b[esi+13],not 128 ;clear selected bit so this entry
mov edi,_FS_FileList ;can be found in search.
add edi,4+256
@@oe8: test b[edi+13],128 ;find an entry that's not selected.
jz @@oe9
add edi,14
jmp @@oe8
@@oe9: call CopyString ;copy current name into new position.
mov al,[esi+13]
or al,128 ;copy attrivutes and make sure
mov [edi+13],al ;selection bit is set.
add esi,14
dec edx
jmp @@oe4
@@oe5: ;
pop ebx ;get number of selected entries
mov eax,14 ;and work out how big the buffer
mul ebx ;needs to be now.
add eax,4+256 ;allow for count and path.
mov ecx,eax
mov esi,_FS_FileList ;current address.
call ReMalloc ;try and re-size it, should be
jc memexit ;shrinking so it's not likely
mov _FS_FileList,esi ;to fail.
mov [esi],ebx ;store new count value.
;
;Show the button down
;
mov ecx,dFILE_OK ;set OK button to the in position
mov esi,offset dFileSelector ;so they know we reacted to the
mov eax,1 ;selection.
call DialogSetState
mov edi,_FS_window ;make sure the button gets a
call DrawDialog ;re-draw.
;
@@oe10: call _FS_ReadInput ;now wait for them to let go of
cmp _FS_mouseb,0 ;the mouse button.
jnz @@oe10
;
;show the button up.
;
mov ecx,dFILE_OK ;set OK button to the out position
mov esi,offset dFileSelector ;to complete the effect of something
xor eax,eax ;happening.
call DialogSetState
mov edi,_FS_window ;make sure the button get a
call DrawDialog ;re-draw.
;
@@oe11: mov ecx,2 ;now wait a while so the button
call Delay ;shows up as being out before
mov eax,_FS_window ;it all disapears.
call WinCloseWindow ;close the window.
;
popad
xor eax,eax
mov ebx,_FS_FirstFile ;file list start position.
mov ecx,_FS_FirstMask ;mask list start position.
mov edx,_FS_CurrentMask ;current mask number.
mov esi,_FS_FirstDrive ;drive list start position.
mov edi,_FS_FileList ;return the file list address.
clc
ret
;
;
; CANCEL selected so don't pass a file name back.
;
;
cancelexit: mov ecx,dFILE_CANCEL ;set CANCEL button to the in
mov esi,offset dFileSelector ;position so they know we
mov eax,1 ;reacted to the action.
call DialogSetState
mov edi,_FS_window ;make sure the button get a
call DrawDialog ;re-draw.
;
@@ce0: call _FS_ReadInput
cmp _FS_mouseb,0
jnz @@ce0
;
mov ecx,dFILE_CANCEL ;set button to the out position
mov esi,offset dFileSelector ;to complete the effect of
xor eax,eax ;something happening.
call DialogSetState
mov edi,_FS_window ;make sure the button get a
call DrawDialog ;re-draw.
;
@@ce1: mov ecx,2 ;brief delay to make sure they
call Delay ;see the button out again.
mov _FS_ErrorCode,1
RealExit: mov eax,_FS_window
call WinCloseWindow ;close the window.
cmp _FS_FileList,0
jz @@ce2
mov esi,_FS_FileList ;release the file list.
call Free
@@ce2: popad
mov eax,_FS_ErrorCode ;return a null pointer.
stc
ret
;
;Not enough memory for file list.
;
memexit: mov _FS_ErrorCode,3
jmp RealExit
;
;No file selected.
;
nofileexit: jmp cancelexit
mov _FS_ErrorCode,2
jmp RealExit
_dlgFileSelector_ endp
;-------------------------------------------------------------------------
;
;Read the keyboard and mouse.
;
_FS_ReadInput proc near
call GetKey ;read the keyboard state.
mov _FS_KeyASCII,al
mov _FS_KeyCode,ah
shr eax,16
mov _FS_KeyFlags,ax
call MouseGet ;read the mouse state.
mov _FS_mouseb,ebx
mov _FS_mousex,ecx
mov _FS_mousey,edx
call WinWhichWindow ;find out which (if any) window
mov _FS_mousewin,eax ;the mouse is currenty in.
mov _FS_mousewinx,ecx
mov _FS_mousewiny,edx
ret
_FS_ReadInput endp
sdata
;
_FS_mousewin dd ?
_FS_mousewinx dd ?
_FS_mousewiny dd ?
_FS_mouseb dd ?
_FS_mousex dd ?
_FS_mousey dd ?
_FS_KeyASCII db ?
_FS_KeyCode db ?
_FS_KeyFlags dw ?
_FS_window dd ?
_FS_mainw dd ?
_FS_maind dd ?
_FS_mainx dd ?
_FS_mainy dd ?
_FS_i dd ?
_FS_j dd ?
_FS_k dd ?
_FS_m dd ?
_FS_p dd ?
_FS_bmptr dd ?
_FS_charptr dd ?
_FS_charptr2 dd ?
_FS_intptr dd ?
_FS_currentpath db 256 dup (?)
_FS_printpath db 128 dup (?)
_FS_filemask db 6 dup (?)
_FS_drivelist db 64 dup (?)
_FS_typedname db 16 dup (?)
_FS_TotalMasks dd ?
_FS_CurrentMask dd ?
_FS_FirstMask dd ?
_FS_TotalFiles dd ?
_FS_FirstFile dd ?
_FS_TotalDrives dd ?
_FS_CurrentDrive dd ?
_FS_FirstDrive dd ?
_FS_FileList dd ?
_FS_drawstate dd ?
_FS_action dd ?
_FS_FirstTyped dd ?
_FS_TypedFocus dd ?
_FS_TypedTotal dd ?
_FS_ALL db "ALL",0
_FS_CenterFile db 14 dup (?)
_FS_ErrorCode dd ?
;
dFILE_TITLE equ 0
dFILE_PATH equ 1
dFILE_FILES equ 2
dFILE_TYPED equ 3
dFILE_FILEUP equ 4
dFILE_FILEDOWN equ 5
dFILE_TYPES equ 6
dFILE_TYPEUP equ 7
dFILE_TYPEDOWN equ 8
dFILE_DRIVES equ 9
dFILE_DRIVEUP equ 10
dFILE_DRIVEDOWN equ 11
dFILE_OK equ 12
dFILE_CANCEL equ 13
;
dFileSelector label byte
DlgMain <22,23, 13,25>
Dlg <0, 0,3, 0,3, 22,17, 1,4, (9*256)+1,0> ; title.
Dlg <2, 0,3, 1,8, 22,17, 1,4, (253*256),0> ; path.
Dlg <2, 0,3, 2,13, 12,4, 10,4, 0,0> ; file list.
Dlg <2, 0,3, 12,18, 12,4, 1,4, 0,0> ; typed name.
Dlg <0, 12,8, 2,13, 2,0, 5,2, (9*256)+1,_FS_Up> ; file list UP
Dlg <0, 12,8, 7,15, 2,0, 5,2, (9*256)+8+1,_FS_Down> ; file list DOWN.
Dlg <2, 14,9, 2,13, 3,4, 10,4, 0,0> ; type list.
Dlg <0, 17,14, 2,13, 2,0, 5,2, (9*256)+1,_FS_Up> ; type list UP
Dlg <0, 17,14, 7,15, 2,0, 5,2, (9*256)+8+1,_FS_Down> ; type list DOWN.
Dlg <2, 19,15, 2,13, 1,4, 10,4, 0,0> ; drive list.
Dlg <0, 20,20, 2,13, 2,0, 5,2, (9*256)+1,_FS_Up> ; drive list UP
Dlg <0, 20,20, 7,15, 2,0, 5,2, (9*256)+8+1,_FS_Down> ; drive list DOWN.
Dlg <0, 12,8, 12,18, 5,6, 1,4, (9*256)+1+8,_FS_Ok> ; OK button.
Dlg <0, 17,14, 12,18, 5,6, 1,4, (9*256)+1+8,_FS_Cancel> ; CANCEL button.
Dlg <-1>
;
_FS_Ok db "OK",0
_FS_Cancel db "CANCEL",0
_FS_Up db 2,3,0
_FS_Down db 4,5,0
;
efile
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -