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

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

Changes to Assembly Library:

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