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

Last change on this file since 399 was 376, checked in by gregli@…, 13 years ago

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

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