source: xtideuniversalbios/trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm@ 47

Last change on this file since 47 was 46, checked in by Tomi Tilli, 14 years ago

Changes to Assembly Library:
Sorting now works (pivot item is copied for comparison and index comparisons are now signed instead of unsigned).
Menu shadow now looks better on black and white modes.
Sorting is now implemented for File Fialog: directories are displayed before files.
File Dialog now displays directories with upper case letters and files with lower case letters.
Line splitter now removes all empty lines from the end.

File size: 23.3 KB
Line 
1; File name : DialogFile.asm
2; Project name : Assembly Library
3; Created date : 6.9.2010
4; Last update : 4.10.2010
5; Author : Tomi Tilli
6; Description : Displays file dialog.
7
8
9CURRENTDIR_CHARACTERS EQU 002Eh
10UPDIR_CHARACTERS EQU 2E2Eh
11
12; Section containing code
13SECTION .text
14
15;--------------------------------------------------------------------
16; DialogFile_GetFileNameWithIoInDSSI
17; Parameters:
18; DS:SI: Ptr to FILE_DIALOG_IO
19; SS:BP: Ptr to parent MENU
20; Returns:
21; Nothing
22; Corrupts registers:
23; AX, BX, CX, DX, SI, DI
24;--------------------------------------------------------------------
25ALIGN JUMP_ALIGN
26DialogFile_GetFileNameWithIoInDSSI:
27 mov bx, FileEventHandler
28 mov BYTE [si+FILE_DIALOG_IO.bUserCancellation], TRUE
29 jmp Dialog_DisplayWithDialogInputInDSSIandHandlerInBX
30
31
32;--------------------------------------------------------------------
33; FileEventHandler
34; Common parameters for all events:
35; BX: Menu event (anything from MENUEVENT struct)
36; SS:BP: Ptr to DIALOG
37; Common return values for all events:
38; CF: Set if event processed
39; Cleared if event not processed
40; Corrupts registers:
41; All
42;--------------------------------------------------------------------
43ALIGN JUMP_ALIGN
44FileEventHandler:
45 jmp [cs:bx+.rgfnEventHandlers]
46
47
48ALIGN JUMP_ALIGN
49.ItemSelectedFromCX:
50 call LoadItemStringBufferToESDI
51 call LineSplitter_GetOffsetToSIforLineCXfromStringInESDI
52 push es
53 pop ds
54 jmp ParseSelectionFromItemLineInDSSI
55
56
57ALIGN JUMP_ALIGN
58.RefreshInformation:
59 call GetInfoLinesToCXandDialogFlagsToAX
60 mov si, [cs:.rgszInfoStringLookup]
61 xor bx, bx
62 xchg dx, ax
63ALIGN JUMP_ALIGN
64.InfoLineLoop:
65 shr dl, 1
66 jnc SHORT .CheckNextFlag
67 mov si, [cs:bx+.rgszInfoStringLookup]
68 push bx
69 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
70 pop bx
71ALIGN JUMP_ALIGN
72.CheckNextFlag:
73 inc bx
74 inc bx
75 loop .InfoLineLoop
76 stc ; Event processed
77 ret
78
79
80ALIGN WORD_ALIGN
81.rgszInfoStringLookup:
82 dw g_szChangeDrive
83 dw g_szSelectDirectory
84 dw g_szCreateNew
85
86.rgfnEventHandlers:
87istruc MENUEVENT
88 at MENUEVENT.InitializeMenuinitFromDSSI, dw InitializeMenuinitFromSSBP
89 at MENUEVENT.ExitMenu, dw Dialog_EventNotHandled
90 at MENUEVENT.IdleProcessing, dw Dialog_EventNotHandled
91 at MENUEVENT.ItemHighlightedFromCX, dw Dialog_EventNotHandled
92 at MENUEVENT.ItemSelectedFromCX, dw .ItemSelectedFromCX
93 at MENUEVENT.KeyStrokeInAX, dw HandleFunctionKeyFromAH
94 at MENUEVENT.RefreshTitle, dw Dialog_EventRefreshTitle
95 at MENUEVENT.RefreshInformation, dw .RefreshInformation
96 at MENUEVENT.RefreshItemFromCX, dw Dialog_EventRefreshItemFromCX
97iend
98
99
100;--------------------------------------------------------------------
101; InitializeMenuinitFromSSBP
102; Parameters:
103; DS:SI: Ptr to MENUINIT to initialize (also points to DIALOG)
104; SS:BP: Ptr to DIALOG
105; Returns:
106; Nothing
107; Corrupts registers:
108; All, except BP
109;--------------------------------------------------------------------
110ALIGN JUMP_ALIGN
111InitializeMenuinitFromSSBP:
112 call LoadItemStringBufferToESDI
113 call CreateStringFromCurrentDirectoryContentsToESDI
114 call LoadItemStringBufferToESDI
115 call SortDirectoryContentsStringFromESDIwithCountInCX
116 push ss
117 pop ds
118 mov si, bp
119 call Dialog_EventInitializeMenuinitFromDSSI
120 call GetInfoLinesToCXandDialogFlagsToAX
121 mov [bp+MENUINIT.bInfoLines], cl
122 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
123 mov [bp+MENUINIT.bHeight], ah ; Always max height
124 xor ax, ax
125 mov [bp+MENU.wHighlightedItem], ax
126 mov [bp+MENU.wFirstVisibleItem], ax
127 ret
128
129
130;--------------------------------------------------------------------
131; LoadItemStringBufferToESDI
132; Parameters:
133; SS:BP: Ptr to DIALOG
134; Returns:
135; ES:DI: Ptr to item string buffer
136; Corrupts registers:
137; Nothing
138;--------------------------------------------------------------------
139ALIGN JUMP_ALIGN
140LoadItemStringBufferToESDI:
141 les di, [bp+DIALOG.fpDialogIO]
142 les di, [es:di+FILE_DIALOG_IO.fszItemBuffer]
143 ret
144
145
146;--------------------------------------------------------------------
147; CreateStringFromCurrentDirectoryContentsToESDI
148; Parameters:
149; ES:DI: Buffer where to create item string
150; SS:BP: Ptr to DIALOG
151; Returns:
152; CX: Number of files or directories found
153; Corrupts registers:
154; AX, DX, SI, DI, DS, ES
155;--------------------------------------------------------------------
156ALIGN JUMP_ALIGN
157CreateStringFromCurrentDirectoryContentsToESDI:
158 lds si, [bp+DIALOG.fpDialogIO]
159 eMOVZX cx, BYTE [si+FILE_DIALOG_IO.bFileAttributes]
160 lds si, [si+FILE_DIALOG_IO.fpFileFilterString]
161 call Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX
162 rcr cx, 1 ; Store CF
163 call .ClearDLifInRootDirectory
164 call Directory_GetDiskTransferAreaAddressToDSSI
165 rcl cx, 1 ; Restore CF
166 xor cx, cx ; Clear file/directory count
167 ; Fall to .FindMatchingFilesAndWriteThemToESDI
168
169;--------------------------------------------------------------------
170; .FindMatchingFilesAndWriteThemToESDI
171; Parameters:
172; CX: Initial directory count
173; DL: Zero if root directory selected
174; DS:SI: Ptr to DTA with first matching file
175; ES:DI: Ptr to destination string buffer
176; Returns:
177; CX: Incremented by number of files/directories found
178; Corrupts registers:
179; AX, DX, DI
180;--------------------------------------------------------------------
181;ALIGN JUMP_ALIGN
182.FindMatchingFilesAndWriteThemToESDI:
183 jc SHORT TerminateESDIwithNull
184 call AppendFileToBufferInESDIfromDtaInDSSI
185 call Directory_UpdateDTAForNextMatchUsingPreviousParameters
186 jmp SHORT .FindMatchingFilesAndWriteThemToESDI
187
188;--------------------------------------------------------------------
189; .ClearDLifInRootDirectory
190; Parameters:
191; SS:BP: Ptr to DIALOG
192; ES:DI: Ptr to destination string buffer
193; Returns:
194; DL: Cleared if in root directory
195; Set if in any other directory
196; Corrupts registers:
197; AX, SI, DS
198;--------------------------------------------------------------------
199ALIGN JUMP_ALIGN
200.ClearDLifInRootDirectory:
201 push es
202 pop ds
203 mov si, di
204 call Directory_WriteCurrentPathToDSSI
205 mov dl, [si]
206 ret
207
208
209;--------------------------------------------------------------------
210; TerminateESDIwithNull
211; Parameters:
212; ES:DI: Ptr to destination string buffer
213; Returns:
214; Nothing
215; Corrupts registers:
216; AX
217;--------------------------------------------------------------------
218ALIGN JUMP_ALIGN
219TerminateESDIwithNull:
220 xor ax, ax
221 stosb
222 ret
223
224
225;--------------------------------------------------------------------
226; AppendFileToBufferInESDIfromDtaInDSSI
227; Parameters:
228; CX: Files/directores found
229; DL: Zero if root directory selected
230; DS:SI: Ptr to DTA containing file information
231; ES:DI: Ptr to destination string buffer
232; Returns:
233; CX: Incremented by number of files/directories found
234; DI: Updated for next file
235; Corrupts registers:
236; AX, BX, DX
237;--------------------------------------------------------------------
238ALIGN JUMP_ALIGN
239AppendFileToBufferInESDIfromDtaInDSSI:
240 call .FilterCurrentDirectory ; We never want "."
241 call .FilterUpDirectoryWhenInRoot ; No ".." when in root directory
242 inc cx ; Nothing filtered so increment files/directories
243 ; Fall to .PrepareBufferFormattingAndFormatFromDTAinDSSI
244
245;--------------------------------------------------------------------
246; .PrepareBufferFormattingAndFormatFromDTAinDSSI
247; Parameters:
248; DS:SI: Ptr to DTA containing file information
249; ES:DI: Ptr to destination string buffer
250; Returns:
251; DI: Updated for next file
252; Corrupts registers:
253; AX, BX, DX
254;--------------------------------------------------------------------
255;ALIGN JUMP_ALIGN
256.PrepareBufferFormattingAndFormatFromDTAinDSSI:
257 push bp
258 push si
259 push cx
260 mov bx, di
261 CALL_DISPLAY_LIBRARY PushDisplayContext
262
263 xchg ax, bx
264 mov bx, es
265 CALL_DISPLAY_LIBRARY SetCharacterPointerFromBXAX
266 mov bl, ATTRIBUTES_NOT_USED
267 mov ax, BUFFER_OUTPUT_WITH_CHAR_ONLY
268 CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
269
270 call .FormatFileOrDirectoryToBufferFromDTAinDSSI
271
272 CALL_DISPLAY_LIBRARY GetCharacterPointerToBXAX
273 mov es, bx
274 xchg bx, ax
275 CALL_DISPLAY_LIBRARY PopDisplayContext
276 mov di, bx
277 pop cx
278 pop si
279 pop bp
280 ret
281
282;--------------------------------------------------------------------
283; .FormatFileOrDirectoryToBufferFromDTAinDSSI
284; Parameters:
285; DS:SI: Ptr to DTA containing file information
286; Returns:
287; Nothing
288; Corrupts registers:
289; AX, BX, CX, DX, SI, DI, BP
290;--------------------------------------------------------------------
291ALIGN JUMP_ALIGN
292.FormatFileOrDirectoryToBufferFromDTAinDSSI:
293 mov bp, sp
294 lea ax, [si+DTA.szFile]
295
296 test BYTE [si+DTA.bFileAttributes], FLG_FILEATTR_DIRECTORY
297 jnz SHORT .FormatDirectory
298 ; Fall to .FormatFile
299
300;--------------------------------------------------------------------
301; .FormatFile
302; Parameters:
303; BP: SP before pushing formatting parameters
304; DS:AX: Far pointer to file name
305; DS:SI: Ptr to DTA containing file information
306; Returns:
307; Nothing
308; Corrupts registers:
309; AX, BX, CX, DX, SI, DI, BP
310;--------------------------------------------------------------------
311.FormatFile:
312 ; Push parameters for file name
313 xchg si, ax
314 call String_ConvertDSSItoLowerCase
315 xchg ax, si
316 push ax ; Push directory name offset
317 push ds ; Push directory name segment
318
319 ; Push parameters for file size
320 mov ax, [si+DTA.dwFileSize]
321 mov dx, [si+DTA.dwFileSize+2]
322 xor bx, bx
323 xor cx, cx
324 call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
325 mov cl, 'i'
326 cmp dl, ' '
327 eCMOVE cl, dl
328 push ax
329 push dx
330 push cx
331
332 ; Format to buffer
333 mov si, g_szFileFormat
334 jmp SHORT .FormatStringInCSSIandReturn
335
336;--------------------------------------------------------------------
337; .FormatDirectory
338; Parameters:
339; BP: SP before pushing formatting parameters
340; DS:AX: Far pointer to directory name
341; DS:SI: Ptr to DTA containing file information
342; Returns:
343; Nothing
344; Corrupts registers:
345; AX, BX, CX, DX, SI, DI, BP
346;--------------------------------------------------------------------
347ALIGN JUMP_ALIGN
348.FormatDirectory:
349 push ax ; Push directory name offset
350 push ds ; Push directory name segment
351 mov ax, g_szSub
352 cmp WORD [si+DTA.szFile], UPDIR_CHARACTERS
353 eCMOVE ax, g_szUp
354 push ax
355 mov si, g_szDirectoryFormat
356ALIGN JUMP_ALIGN
357.FormatStringInCSSIandReturn:
358 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
359 ret
360
361;--------------------------------------------------------------------
362; .FilterCurrentDirectory
363; .FilterUpDirectoryWhenInRoot
364; Parameters:
365; DL: Zero if root directory selected
366; DS:SI: Ptr to DTA containing file information
367; Returns:
368; Nothing
369; Returns from AppendFileToBufferInESDIfromDtaInDSSI when filtering
370; Corrupts registers:
371; AX
372;--------------------------------------------------------------------
373ALIGN JUMP_ALIGN
374.FilterCurrentDirectory:
375 cmp WORD [si+DTA.szFile], CURRENTDIR_CHARACTERS
376 jne SHORT .ReturnWithoutFiltering
377 add sp, BYTE 2 ; Remove return address from stack
378 ret
379
380ALIGN JUMP_ALIGN
381.FilterUpDirectoryWhenInRoot:
382 test dl, dl ; Set ZF if root directory selected
383 jnz SHORT .ReturnWithoutFiltering
384 cmp WORD [si+DTA.szFile], UPDIR_CHARACTERS
385 jne SHORT .ReturnWithoutFiltering
386 add sp, BYTE 2 ; Remove return address from stack
387ALIGN JUMP_ALIGN, ret
388.ReturnWithoutFiltering:
389 ret
390
391
392;--------------------------------------------------------------------
393; SortDirectoryContentsStringFromESDIwithCountInCX
394; Parameters:
395; CX: Number of files and directories
396; ES:DI: Buffer containing directory contents string
397; SS:BP: Ptr to DIALOG
398; Returns:
399; Nothing
400; Corrupts registers:
401; AX, BX, CX, DX, SI, DI, DS, ES
402;--------------------------------------------------------------------
403ALIGN JUMP_ALIGN
404SortDirectoryContentsStringFromESDIwithCountInCX:
405 call Memory_ExchangeDSSIwithESDI
406 mov bx, .FileStringComparator
407 xchg dx, cx
408 mov cx, FILE_STRING_LENGTH
409 jmp Sort_ItemsFromDSSIwithCountInDXsizeInCXandComparatorInBX
410
411;--------------------------------------------------------------------
412; .FileStringComparator
413; Parameters:
414; CX: Item size in bytes
415; DS:SI: Ptr to first item to compare
416; ES:DI: Ptr to second item to compare
417; Returns:
418; FLAGS: Signed comparition between first and second item
419; Corrupts registers:
420; Nothing
421;--------------------------------------------------------------------
422ALIGN JUMP_ALIGN
423.FileStringComparator:
424 push di
425 push si
426 push cx
427 push bx
428
429 mov bx, FILE_STRING_LENGTH-2 ; Zero BH
430 cmp WORD [si], UPDIR_CHARACTERS
431 je SHORT .ForceValueFromDSSItoBeLess
432 mov bl, [si+bx]
433 cmp bl, [es:di+FILE_STRING_LENGTH-2] ; 'B' for files, 'R' for directories
434 jne SHORT .ForceValueFromDSSItoBeMoreOrLess
435 repe cmpsb ; Two directories or two files
436
437ALIGN JUMP_ALIGN
438.ReturnFromComparison:
439 pop bx
440 pop cx
441 pop si
442 pop di
443 ret
444ALIGN JUMP_ALIGN
445.ForceValueFromDSSItoBeMoreOrLess:
446 ja SHORT .ForceValueFromDSSItoBeLess ; Directory in SI, file in DI
447 xchg bl, bh
448 ; Fall to ForceValueFromDSSItoBeLess
449ALIGN JUMP_ALIGN
450.ForceValueFromDSSItoBeLess:
451 cmp bh, bl
452 jmp SHORT .ReturnFromComparison
453
454
455;--------------------------------------------------------------------
456; GetInfoLinesToCXandDialogFlagsToAX
457; Parameters:
458; SS:BP: Ptr to DIALOG
459; Returns:
460; AX: Dialog flags
461; CX: Number of info lines to be displayed
462; Corrupts registers:
463; SI, DS
464;--------------------------------------------------------------------
465ALIGN JUMP_ALIGN
466GetInfoLinesToCXandDialogFlagsToAX:
467 xor ax, ax
468 call GetDialogFlagsToAL
469 jmp Bit_GetSetCountToCXfromAX
470
471;--------------------------------------------------------------------
472; GetDialogFlagsToAL
473; Parameters:
474; SS:BP: Ptr to DIALOG
475; Returns:
476; AL: Dialog flags
477; Corrupts registers:
478; SI, DS
479;--------------------------------------------------------------------
480ALIGN JUMP_ALIGN
481GetDialogFlagsToAL:
482 lds si, [bp+DIALOG.fpDialogIO]
483 mov al, [si+FILE_DIALOG_IO.bDialogFlags]
484 ret
485
486
487;--------------------------------------------------------------------
488; ParseSelectionFromItemLineInDSSI
489; Parameters:
490; DS:SI: Ptr to char buffer containing file or directory to be selected
491; SS:BP: Ptr to DIALOG
492; Returns:
493; Nothing
494; Corrupts registers:
495; All, except BP
496;--------------------------------------------------------------------
497ALIGN JUMP_ALIGN
498ParseSelectionFromItemLineInDSSI:
499 mov ax, [si]
500 cmp ax, UPDIR_CHARACTERS
501 je SHORT .ChangeToUpdir
502 call Char_IsUpperCaseLetterInAL
503 jc SHORT .ParseAndChangeToSubdirInDSSI
504 ; Fall to .ParseAndSelectFileFromDSSI
505
506;--------------------------------------------------------------------
507; .ParseAndSelectFileFromDSSI
508; Parameters:
509; DS:SI: NULL terminated string selected from dialog
510; SS:BP: Ptr to DIALOG
511; Returns:
512; Nothing (exits dialog)
513; Corrupts registers:
514; All, except BP
515;--------------------------------------------------------------------
516.ParseAndSelectFileFromDSSI:
517 les di, [bp+DIALOG.fpDialogIO]
518 add di, BYTE FILE_DIALOG_IO.szFile
519 mov cx, FILENAME_BUFFER_SIZE-1
520 cld
521 rep movsb
522 xor ax, ax
523 stosb ; Terminate with NULL
524 jmp CloseFileDialogAfterSuccessfullSelection
525
526;--------------------------------------------------------------------
527; .ChangeToUpdir
528; Parameters:
529; SS:BP: Ptr to DIALOG
530; Returns:
531; Nothing
532; Corrupts registers:
533; All, except BP
534;--------------------------------------------------------------------
535ALIGN JUMP_ALIGN
536.ChangeToUpdir:
537 mov si, g_szUpdir
538 jmp SHORT .ChangeDirectoryToDSSI
539
540;--------------------------------------------------------------------
541; .ParseAndChangeToSubdirInDSSI
542; Parameters:
543; DS:SI: NULL terminated string selected from dialog
544; SS:BP: Ptr to DIALOG
545; Returns:
546; Nothing
547; Corrupts registers:
548; All, except BP
549;--------------------------------------------------------------------
550ALIGN JUMP_ALIGN
551.ParseAndChangeToSubdirInDSSI:
552 mov BYTE [si+12], NULL ; Terminate with NULL (unnecessary spaces do not matter)
553.ChangeDirectoryToDSSI:
554 call Directory_ChangeToPathFromDSSI
555 ; Fall to RefreshFilesToDisplay
556
557;--------------------------------------------------------------------
558; RefreshFilesToDisplay
559; Parameters:
560; SS:BP: Ptr to DIALOG
561; Returns:
562; Nothing
563; Corrupts registers:
564; All, except BP
565;--------------------------------------------------------------------
566ALIGN JUMP_ALIGN
567RefreshFilesToDisplay:
568 call InitializeMenuinitFromSSBP
569 jmp MenuInit_RefreshMenuWindow
570
571
572;--------------------------------------------------------------------
573; HandleFunctionKeyFromAH
574; Parameters:
575; AH: Scancode for function key
576; SS:BP: Ptr to DIALOG
577; Returns:
578; Nothing
579; Corrupts registers:
580; AX, SI, DI, BP
581;--------------------------------------------------------------------
582ALIGN JUMP_ALIGN
583HandleFunctionKeyFromAH:
584 call GetDialogFlagsToAL
585 cmp ah, KEY_FILEDIALOG_NEW_FILE_OR_DIR
586 je SHORT HandleFunctionKeyForCreatingNewFileOrDirectory
587 cmp ah, KEY_FILEDIALOG_SELECT_DIRECTORY
588 je SHORT HandleFunctionKeyForSelectingDirectoryInsteadOfFile
589 cmp ah, KEY_FILEDIALOG_CHANGE_DRIVE
590 je SHORT HandleFunctionKeyForDriveChange
591ReturnWithoutHandlingKeystroke:
592 clc ; Event not processed
593 ret
594
595
596;--------------------------------------------------------------------
597; HandleFunctionKeyForCreatingNewFileOrDirectory
598; Parameters:
599; AL: File dialog flags
600; SS:BP: Ptr to DIALOG
601; Returns:
602; Closes file dialog
603; Corrupts registers:
604; All, except BP
605;--------------------------------------------------------------------
606ALIGN JUMP_ALIGN
607HandleFunctionKeyForCreatingNewFileOrDirectory:
608 test al, FLG_FILEDIALOG_NEW
609 jz SHORT ReturnWithoutHandlingKeystroke
610
611 mov cx, STRING_DIALOG_IO_size
612 call Memory_ReserveCXbytesFromStackToDSSI
613 call .InitializeStringDialogIoInDSSIforInputtingFileName
614
615 CALL_MENU_LIBRARY GetStringWithIoInDSSI
616 mov al, [si+STRING_DIALOG_IO.bUserCancellation]
617 add sp, BYTE STRING_DIALOG_IO_size
618 test al, al ; User cancellation?
619 jnz SHORT ReturnWithoutHandlingKeystroke
620 jmp CloseFileDialogAfterSuccessfullSelection
621
622ALIGN JUMP_ALIGN
623.InitializeStringDialogIoInDSSIforInputtingFileName:
624 call InitializeNullStringsToDialogInputInDSSI
625 mov WORD [si+DIALOG_INPUT.fszTitle], g_szEnterNewFileOrDirectory
626 mov WORD [si+STRING_DIALOG_IO.fnCharFilter], NULL
627 mov WORD [si+STRING_DIALOG_IO.wBufferSize], FILENAME_BUFFER_SIZE
628 les ax, [bp+DIALOG.fpDialogIO]
629 add ax, BYTE FILE_DIALOG_IO.szFile
630 mov [si+STRING_DIALOG_IO.fpReturnBuffer], ax
631 mov [si+STRING_DIALOG_IO.fpReturnBuffer+2], es
632 ret
633
634
635;--------------------------------------------------------------------
636; HandleFunctionKeyForSelectingDirectoryInsteadOfFile
637; Parameters:
638; AL: File dialog flags
639; SS:BP: Ptr to DIALOG
640; Returns:
641; Closes file dialog
642; Corrupts registers:
643; All, except BP
644;--------------------------------------------------------------------
645ALIGN JUMP_ALIGN
646HandleFunctionKeyForSelectingDirectoryInsteadOfFile:
647 test al, FLG_FILEDIALOG_DIRECTORY
648 jz SHORT ReturnWithoutHandlingKeystroke
649 ; Fall to CloseFileDialogAfterSuccessfullSelection
650
651;--------------------------------------------------------------------
652; CloseFileDialogAfterSuccessfullSelection
653; Parameters:
654; SS:BP: Ptr to DIALOG
655; Returns:
656; Nothing (exits dialog)
657; Corrupts registers:
658; All, except BP
659;--------------------------------------------------------------------
660ALIGN JUMP_ALIGN
661CloseFileDialogAfterSuccessfullSelection:
662 lds di, [bp+DIALOG.fpDialogIO]
663 mov BYTE [di+FILE_DIALOG_IO.bUserCancellation], FALSE
664 jmp MenuInit_CloseMenuWindow
665
666
667;--------------------------------------------------------------------
668; HandleFunctionKeyForDriveChange
669; Parameters:
670; AL: File dialog flags
671; SS:BP: Ptr to DIALOG
672; Returns:
673; Nothing
674; Corrupts registers:
675; All, except BP
676;--------------------------------------------------------------------
677ALIGN JUMP_ALIGN
678HandleFunctionKeyForDriveChange:
679 test al, FLG_FILEDIALOG_DRIVES
680 jz SHORT ReturnWithoutHandlingKeystroke
681
682 call .ShowDriveSelectionDialogAndGetDriveNumberToDL
683 jnc SHORT RefreshFilesToDisplay
684 call Drive_SetDefaultFromDL
685 jmp SHORT RefreshFilesToDisplay
686
687;--------------------------------------------------------------------
688; .ShowDriveSelectionDialogAndGetDriveNumberToDL
689; Parameters:
690; SS:BP: Ptr to DIALOG
691; Returns:
692; DL: Drive selected by user
693; CF: Set if new drive selected
694; Cleared if selection cancelled by user
695; Corrupts registers:
696; All, except BP
697;--------------------------------------------------------------------
698ALIGN JUMP_ALIGN
699.ShowDriveSelectionDialogAndGetDriveNumberToDL:
700 mov cx, DIALOG_INPUT_size
701 call Memory_ReserveCXbytesFromStackToDSSI
702 call .InitializeDialogInputInDSSIforDriveSelection
703 call DialogSelection_GetSelectionToAXwithInputInDSSI
704 add sp, BYTE DIALOG_INPUT_size
705 cmp ax, BYTE NO_ITEM_SELECTED ; Clear CF if equal
706 jne SHORT .ConvertDriveNumberToDLfromItemIndexInAX
707 ret
708
709ALIGN JUMP_ALIGN
710.InitializeDialogInputInDSSIforDriveSelection:
711 call InitializeNullStringsToDialogInputInDSSI
712 call LoadItemStringBufferToESDI
713 mov WORD [si+DIALOG_INPUT.fszTitle], g_szSelectNewDrive
714 mov [si+DIALOG_INPUT.fszItems], di
715 mov [si+DIALOG_INPUT.fszItems+2], es
716 call Drive_GetFlagsForAvailableDrivesToDXAX
717 ; Fall to .GenerateDriveSelectionStringToESDIfromDriveFlagsInDXAX
718
719;--------------------------------------------------------------------
720; .GenerateDriveSelectionStringToESDIfromDriveFlagsInDXAX
721; Parameters:
722; DX:AX: Drive letter flags
723; ES:DI: Ptr to item string buffer
724; SS:BP: Ptr to DIALOG
725; Returns:
726; Nothing
727; Corrupts registers:
728; AX, BX, CX, DX, DI, ES
729;--------------------------------------------------------------------
730;ALIGN JUMP_ALIGN
731.GenerateDriveSelectionStringToESDIfromDriveFlagsInDXAX:
732 cld
733 xchg cx, ax
734 mov ax, 3A41h ; A:
735ALIGN JUMP_ALIGN
736.BitShiftLoop:
737 shr dx, 1
738 rcr cx, 1
739 jnc SHORT .CheckIfMoreDrivesLeft
740 stosw
741 mov BYTE [es:di], LF
742 inc di
743ALIGN JUMP_ALIGN
744.CheckIfMoreDrivesLeft:
745 inc ax ; Next drive letter
746 mov bx, dx
747 or bx, cx
748 jnz SHORT .BitShiftLoop
749 jmp TerminateESDIwithNull
750
751;--------------------------------------------------------------------
752; .ConvertDriveNumberToDLfromItemIndexInAX
753; Parameters:
754; AX: Selected drive item
755; Returns:
756; DL: Drive number
757; CF: Set since drive selected
758; Corrupts registers:
759; AX, CX, DH
760;--------------------------------------------------------------------
761ALIGN JUMP_ALIGN
762.ConvertDriveNumberToDLfromItemIndexInAX:
763 mov ah, -1
764 xchg cx, ax
765 call Drive_GetFlagsForAvailableDrivesToDXAX
766ALIGN JUMP_ALIGN
767.BitScanLoop:
768 shr dx, 1
769 rcr ax, 1
770 inc ch ; Increment drive number
771 sbb cl, 0 ; Decrement selection index
772 jnc SHORT .BitScanLoop
773 mov dl, ch
774 stc ; Drive selected by user
775 ret
776
777
778;--------------------------------------------------------------------
779; InitializeNullStringsToDialogInputInDSSI
780; Parameters:
781; DS:SI: Ptr to DIALOG_INPUT
782; SS:BP: Ptr to DIALOG
783; Returns:
784; Nothing
785; Corrupts registers:
786; AX
787;--------------------------------------------------------------------
788ALIGN JUMP_ALIGN
789InitializeNullStringsToDialogInputInDSSI:
790 mov ax, g_szNull
791 mov [si+DIALOG_INPUT.fszTitle], ax
792 mov [si+DIALOG_INPUT.fszTitle+2], cs
793 mov [si+DIALOG_INPUT.fszItems], ax
794 mov [si+DIALOG_INPUT.fszItems+2], cs
795 mov [si+DIALOG_INPUT.fszInfo], ax
796 mov [si+DIALOG_INPUT.fszInfo+2], cs
797 ret
Note: See TracBrowser for help on using the repository browser.