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

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

Changes to Assembly Library:

  • Some inlining in Size.asm.
  • File Dialog can now enter in subdirectories starting with number.
File size: 22.4 KB
Line 
1; Project name : Assembly Library
2; Description : Displays file dialog.
3
4
5CURRENTDIR_CHARACTERS EQU 002Eh
6UPDIR_CHARACTERS EQU 2E2Eh
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; DialogFile_GetFileNameWithIoInDSSI
13; Parameters:
14; DS:SI: Ptr to FILE_DIALOG_IO
15; SS:BP: Ptr to parent MENU
16; Returns:
17; Nothing
18; Corrupts registers:
19; AX, BX, CX, DX, SI, DI
20;--------------------------------------------------------------------
21ALIGN JUMP_ALIGN
22DialogFile_GetFileNameWithIoInDSSI:
23 mov bx, FileEventHandler
24 mov BYTE [si+FILE_DIALOG_IO.bUserCancellation], TRUE
25 jmp Dialog_DisplayWithDialogInputInDSSIandHandlerInBX
26
27
28;--------------------------------------------------------------------
29; FileEventHandler
30; Common parameters for all events:
31; BX: Menu event (anything from MENUEVENT struct)
32; SS:BP: Ptr to DIALOG
33; Common return values for all events:
34; CF: Set if event processed
35; Cleared if event not processed
36; Corrupts registers:
37; All
38;--------------------------------------------------------------------
39ALIGN JUMP_ALIGN
40FileEventHandler:
41 jmp [cs:bx+.rgfnEventHandlers]
42
43
44ALIGN JUMP_ALIGN
45.ItemSelectedFromCX:
46 call LoadItemStringBufferToESDI
47 call Registers_CopyESDItoDSSI
48 call ItemLineSplitter_GetLineToDSSIandLengthToCXfromStringInDSSIwithIndexInCX
49 jmp ParseSelectionFromItemLineInDSSI
50
51
52ALIGN JUMP_ALIGN
53.RefreshInformation:
54 call GetInfoLinesToCXandDialogFlagsToAX
55 mov si, [cs:.rgszInfoStringLookup]
56 xor bx, bx
57 xchg dx, ax
58ALIGN JUMP_ALIGN
59.InfoLineLoop:
60 shr dl, 1
61 jnc SHORT .CheckNextFlag
62 mov si, [cs:bx+.rgszInfoStringLookup]
63 push bx
64 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
65 pop bx
66ALIGN JUMP_ALIGN
67.CheckNextFlag:
68 inc bx
69 inc bx
70 loop .InfoLineLoop
71 stc ; Event processed
72 ret
73
74
75ALIGN JUMP_ALIGN
76.RefreshItemFromCX:
77 call LoadItemStringBufferToESDI
78 mov ax, FILE_STRING_LENGTH
79 xchg ax, cx
80 mul cx
81 add di, ax
82 mov si, di
83 mov bx, es
84 dec cx ; Do not print LF at the end of file string
85 CALL_DISPLAY_LIBRARY PrintCharBufferFromBXSIwithLengthInCX
86 stc
87 ret
88
89
90ALIGN WORD_ALIGN
91.rgszInfoStringLookup:
92 dw g_szChangeDrive
93 dw g_szSelectDirectory
94 dw g_szCreateNew
95
96.rgfnEventHandlers:
97istruc MENUEVENT
98 at MENUEVENT.InitializeMenuinitFromDSSI, dw InitializeMenuinitFromSSBP
99 at MENUEVENT.ExitMenu, dw Dialog_EventExitMenu
100 at MENUEVENT.IdleProcessing, dw Dialog_EventNotHandled
101 at MENUEVENT.ItemHighlightedFromCX, dw Dialog_EventNotHandled
102 at MENUEVENT.ItemSelectedFromCX, dw .ItemSelectedFromCX
103 at MENUEVENT.KeyStrokeInAX, dw HandleFunctionKeyFromAH
104 at MENUEVENT.RefreshTitle, dw Dialog_EventRefreshTitle
105 at MENUEVENT.RefreshInformation, dw .RefreshInformation
106 at MENUEVENT.RefreshItemFromCX, dw .RefreshItemFromCX
107iend
108
109
110;--------------------------------------------------------------------
111; ReInitializeMenuinitFromSSBP
112; InitializeMenuinitFromSSBP
113; Parameters:
114; SS:BP: Ptr to DIALOG
115; Returns:
116; Nothing
117; Corrupts registers:
118; All, except BP
119;--------------------------------------------------------------------
120ALIGN JUMP_ALIGN
121ReInitializeMenuinitFromSSBP:
122 call DisplayLoadingMessageInInformationArea
123InitializeMenuinitFromSSBP:
124 call LoadItemStringBufferToESDI
125 call CreateStringFromCurrentDirectoryContentsToESDI
126 call LoadItemStringBufferToESDI
127 call SortDirectoryContentsStringFromESDIwithCountInCX
128 call RemoveLastLFandTerminateESDIwithNull
129
130 call Registers_CopySSBPtoDSSI
131 xor ax, ax
132 call Dialog_EventInitializeMenuinitFromDSSIwithHighlightedItemInAX
133 call GetInfoLinesToCXandDialogFlagsToAX
134 mov [bp+MENUINIT.bInfoLines], cl
135 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
136 mov [bp+MENUINIT.bHeight], ah ; Always max height
137 mov WORD [bp+MENU.wFirstVisibleItem], 0
138 ret
139
140
141;--------------------------------------------------------------------
142; LoadItemStringBufferToESDI
143; Parameters:
144; SS:BP: Ptr to DIALOG
145; Returns:
146; ES:DI: Ptr to item string buffer
147; Corrupts registers:
148; Nothing
149;--------------------------------------------------------------------
150ALIGN JUMP_ALIGN
151LoadItemStringBufferToESDI:
152 les di, [bp+DIALOG.fpDialogIO]
153 les di, [es:di+FILE_DIALOG_IO.fszItemBuffer]
154 ret
155
156
157;--------------------------------------------------------------------
158; CreateStringFromCurrentDirectoryContentsToESDI
159; Parameters:
160; ES:DI: Buffer where to create item string
161; SS:BP: Ptr to DIALOG
162; Returns:
163; CX: Number of files or directories found
164; Corrupts registers:
165; AX, BX, DX, SI, DI, DS
166;--------------------------------------------------------------------
167ALIGN JUMP_ALIGN
168CreateStringFromCurrentDirectoryContentsToESDI:
169 mov bx, di
170 CALL_DISPLAY_LIBRARY PushDisplayContext
171 mov cx, -1
172 CALL_DISPLAY_LIBRARY PrepareOffScreenBufferInESBXwithLengthInCX ; ES:DI now points to buffer
173
174 lds si, [bp+DIALOG.fpDialogIO]
175 eMOVZX cx, BYTE [si+FILE_DIALOG_IO.bFileAttributes]
176 lds si, [si+FILE_DIALOG_IO.fpFileFilterString]
177 call Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX
178
179 call .ClearDLifInRootDirectory
180 call Directory_GetDiskTransferAreaAddressToDSSI
181 xor cx, cx ; Clear file/directory count
182 call .FindMatchingFilesAndPrintThemToOffScreenBuffer
183
184 CALL_DISPLAY_LIBRARY PopDisplayContext
185 ret
186
187;--------------------------------------------------------------------
188; .ClearDLifInRootDirectory
189; Parameters:
190; SS:BP: Ptr to DIALOG
191; ES:DI: Ptr to destination string buffer
192; Returns:
193; DL: Cleared if in root directory
194; Set if in any other directory
195; Corrupts registers:
196; AX, SI, DS
197;--------------------------------------------------------------------
198ALIGN JUMP_ALIGN
199.ClearDLifInRootDirectory:
200 call Registers_CopyESDItoDSSI
201 call Directory_WriteCurrentPathToDSSI
202 mov dl, [si]
203 ret
204
205;--------------------------------------------------------------------
206; .FindMatchingFilesAndPrintThemToOffScreenBuffer
207; Parameters:
208; CX: Initial directory count
209; DL: Zero if root directory selected
210; DS:SI: Ptr to DTA with first matching file
211; Returns:
212; CX: Incremented by number of files/directories found
213; Corrupts registers:
214; AX, BX, DX, DI, DS
215;--------------------------------------------------------------------
216ALIGN JUMP_ALIGN
217.FindMatchingFilesAndPrintThemToOffScreenBuffer:
218 call AppendFileFromDTAinDSSItoOffScreenBuffer
219 call Directory_UpdateDTAForNextMatchUsingPreviousParameters
220 jnc SHORT .FindMatchingFilesAndPrintThemToOffScreenBuffer
221 ret
222
223
224;--------------------------------------------------------------------
225; AppendFileFromDTAinDSSItoOffScreenBuffer
226; Parameters:
227; CX: Files/directores found
228; DL: Zero if root directory selected
229; DS:SI: Ptr to DTA containing file information
230; Returns:
231; CX: Incremented by number of files/directories found
232; Corrupts registers:
233; AX, BX
234;--------------------------------------------------------------------
235ALIGN JUMP_ALIGN
236AppendFileFromDTAinDSSItoOffScreenBuffer:
237 call .FilterCurrentDirectory ; We never want "."
238 call .FilterUpDirectoryWhenInRoot ; No ".." when in root directory
239 inc cx ; Nothing filtered so increment files/directories
240
241 push bp
242 push si
243 push dx
244 push cx
245 call .FormatFileOrDirectoryToBufferFromDTAinDSSI
246 pop cx
247 pop dx
248 pop si
249 pop bp
250 ret
251
252;--------------------------------------------------------------------
253; .FilterCurrentDirectory
254; .FilterUpDirectoryWhenInRoot
255; Parameters:
256; DL: Zero if root directory selected
257; DS:SI: Ptr to DTA containing file information
258; Returns:
259; Nothing
260; Returns from AppendFileToBufferInESDIfromDtaInDSSI when filtering
261; Corrupts registers:
262; AX
263;--------------------------------------------------------------------
264ALIGN JUMP_ALIGN
265.FilterCurrentDirectory:
266 cmp WORD [si+DTA.szFile], CURRENTDIR_CHARACTERS
267 jne SHORT .ReturnWithoutFiltering
268 add sp, BYTE 2 ; Remove return address from stack
269 ret
270
271ALIGN JUMP_ALIGN
272.FilterUpDirectoryWhenInRoot:
273 test dl, dl ; Set ZF if root directory selected
274 jnz SHORT .ReturnWithoutFiltering
275 cmp WORD [si+DTA.szFile], UPDIR_CHARACTERS
276 jne SHORT .ReturnWithoutFiltering
277 add sp, BYTE 2 ; Remove return address from stack
278ALIGN JUMP_ALIGN, ret
279.ReturnWithoutFiltering:
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
310;--------------------------------------------------------------------
311.FormatFile:
312 xchg si, ax
313 call String_ConvertDSSItoLowerCase
314 xchg ax, si
315
316 ; Push parameters for file name
317 push ax ; Push file name offset
318 push ds ; Push file name segment
319
320 ; Push parameters for file size
321 mov ax, [si+DTA.dwFileSize]
322 mov dx, [si+DTA.dwFileSize+2]
323 xor bx, bx
324 xor cx, cx
325 call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
326 mov cl, 'i'
327 cmp dl, ' '
328 eCMOVE cl, dl
329 push ax
330 push dx
331 push cx
332
333 ; Format to buffer
334 mov si, g_szFileFormat
335 jmp SHORT .FormatStringInCSSIandReturn
336
337;--------------------------------------------------------------------
338; .FormatDirectory
339; Parameters:
340; BP: SP before pushing formatting parameters
341; DS:AX: Far pointer to directory name
342; DS:SI: Ptr to DTA containing file information
343; Returns:
344; Nothing
345; Corrupts registers:
346; AX, SI, DI
347;--------------------------------------------------------------------
348ALIGN JUMP_ALIGN
349.FormatDirectory:
350 push ax ; Push directory name offset
351 push ds ; Push directory name segment
352 mov ax, g_szSub
353 cmp WORD [si+DTA.szFile], UPDIR_CHARACTERS
354 eCMOVE ax, g_szUp
355 push ax
356 mov si, g_szDirectoryFormat
357ALIGN JUMP_ALIGN
358.FormatStringInCSSIandReturn:
359 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
360 ret
361
362
363;--------------------------------------------------------------------
364; SortDirectoryContentsStringFromESDIwithCountInCX
365; Parameters:
366; CX: Number of files and directories
367; ES:DI: Buffer containing directory contents string
368; SS:BP: Ptr to DIALOG
369; Returns:
370; ES:DI: Ptr to end of directory contents string
371; Corrupts registers:
372; AX, BX, CX, DX, SI, DS
373;--------------------------------------------------------------------
374ALIGN JUMP_ALIGN
375SortDirectoryContentsStringFromESDIwithCountInCX:
376 call Registers_CopyESDItoDSSI
377 call .AddDirectoryContentsStringLengthToDI
378 mov bx, .FileStringComparator
379 xchg dx, cx
380 mov cx, FILE_STRING_LENGTH
381 jmp Sort_ItemsFromDSSIwithCountInDXsizeInCXandComparatorInBX
382
383ALIGN JUMP_ALIGN
384.AddDirectoryContentsStringLengthToDI:
385 mov ax, FILE_STRING_LENGTH
386 mul cx
387 add di, ax
388 ret
389
390;--------------------------------------------------------------------
391; .FileStringComparator
392; Parameters:
393; CX: Item size in bytes
394; DS:SI: Ptr to first item to compare
395; ES:DI: Ptr to second item to compare
396; Returns:
397; FLAGS: Signed comparition between first and second item
398; Corrupts registers:
399; Nothing
400;--------------------------------------------------------------------
401ALIGN JUMP_ALIGN
402.FileStringComparator:
403 push di
404 push si
405 push cx
406 push bx
407
408 mov bx, FILE_STRING_LENGTH-2 ; Zero BH
409 cmp WORD [si], UPDIR_CHARACTERS
410 je SHORT .ForceValueFromDSSItoBeLess
411 mov bl, [si+bx]
412 cmp bl, [es:di+FILE_STRING_LENGTH-2] ; 'B' for files, 'R' for directories
413 jne SHORT .ForceValueFromDSSItoBeMoreOrLess
414 repe cmpsb ; Two directories or two files
415
416ALIGN JUMP_ALIGN
417.ReturnFromComparison:
418 pop bx
419 pop cx
420 pop si
421 pop di
422 ret
423ALIGN JUMP_ALIGN
424.ForceValueFromDSSItoBeMoreOrLess:
425 ja SHORT .ForceValueFromDSSItoBeLess ; Directory in SI, file in DI
426 xchg bl, bh
427 ; Fall to ForceValueFromDSSItoBeLess
428ALIGN JUMP_ALIGN
429.ForceValueFromDSSItoBeLess:
430 cmp bh, bl
431 jmp SHORT .ReturnFromComparison
432
433
434;--------------------------------------------------------------------
435; RemoveLastLFandTerminateESDIwithNull
436; Parameters:
437; ES:DI: Ptr to end of buffer to terminate
438; Returns:
439; Nothing
440; Corrupts registers:
441; AX
442;--------------------------------------------------------------------
443ALIGN JUMP_ALIGN
444RemoveLastLFandTerminateESDIwithNull:
445 dec di
446 xor ax, ax
447 stosb
448 ret
449
450
451;--------------------------------------------------------------------
452; GetInfoLinesToCXandDialogFlagsToAX
453; Parameters:
454; SS:BP: Ptr to DIALOG
455; Returns:
456; AX: Dialog flags
457; CX: Number of info lines to be displayed
458; Corrupts registers:
459; SI, DS
460;--------------------------------------------------------------------
461ALIGN JUMP_ALIGN
462GetInfoLinesToCXandDialogFlagsToAX:
463 xor ax, ax
464 call GetDialogFlagsToAL
465 jmp Bit_GetSetCountToCXfromAX
466
467;--------------------------------------------------------------------
468; GetDialogFlagsToAL
469; Parameters:
470; SS:BP: Ptr to DIALOG
471; Returns:
472; AL: Dialog flags
473; Corrupts registers:
474; SI, DS
475;--------------------------------------------------------------------
476ALIGN JUMP_ALIGN
477GetDialogFlagsToAL:
478 lds si, [bp+DIALOG.fpDialogIO]
479 mov al, [si+FILE_DIALOG_IO.bDialogFlags]
480 ret
481
482
483;--------------------------------------------------------------------
484; ParseSelectionFromItemLineInDSSI
485; Parameters:
486; DS:SI: Ptr to char buffer containing file or directory to be selected
487; SS:BP: Ptr to DIALOG
488; Returns:
489; Nothing
490; Corrupts registers:
491; All, except BP
492;--------------------------------------------------------------------
493ALIGN JUMP_ALIGN
494ParseSelectionFromItemLineInDSSI:
495 mov ax, [si]
496 cmp ax, UPDIR_CHARACTERS
497 je SHORT .ChangeToUpdir
498 call Char_IsUpperCaseLetterInAL
499 jc SHORT .ParseAndChangeToSubdirInDSSI
500 call Char_IsDecimalDigitInAL
501 jc SHORT .ParseAndChangeToSubdirInDSSI ; Assume subdir and check for errors
502 ; Fall to .ParseAndSelectFileFromDSSI
503
504;--------------------------------------------------------------------
505; .ParseAndSelectFileFromDSSI
506; Parameters:
507; DS:SI: NULL terminated string selected from dialog
508; SS:BP: Ptr to DIALOG
509; Returns:
510; Nothing (exits dialog)
511; Corrupts registers:
512; All, except BP
513;--------------------------------------------------------------------
514.ParseAndSelectFileFromDSSI:
515 les di, [bp+DIALOG.fpDialogIO]
516 add di, BYTE FILE_DIALOG_IO.szFile
517 mov cx, FILENAME_BUFFER_SIZE-1
518 call Memory_CopyCXbytesFromDSSItoESDI
519 xor ax, ax
520 stosb ; Terminate with NULL
521 jmp SHORT CloseFileDialogAfterSuccessfullSelection
522
523;--------------------------------------------------------------------
524; .ChangeToUpdir
525; Parameters:
526; SS:BP: Ptr to DIALOG
527; Returns:
528; Nothing
529; Corrupts registers:
530; All, except BP
531;--------------------------------------------------------------------
532ALIGN JUMP_ALIGN
533.ChangeToUpdir:
534 push cs
535 pop ds
536 mov si, g_szUpdir
537 jmp SHORT .ChangeDirectoryToDSSI
538
539;--------------------------------------------------------------------
540; .ParseAndChangeToSubdirInDSSI
541; Parameters:
542; DS:SI: NULL terminated string selected from dialog
543; SS:BP: Ptr to DIALOG
544; Returns:
545; Nothing
546; Corrupts registers:
547; All, except BP
548;--------------------------------------------------------------------
549ALIGN JUMP_ALIGN
550.ParseAndChangeToSubdirInDSSI:
551 mov BYTE [si+12], NULL ; Terminate with NULL (unnecessary spaces do not matter)
552.ChangeDirectoryToDSSI:
553 call Directory_ChangeToPathFromDSSI
554 jc SHORT .ParseAndSelectFileFromDSSI ; Must have been a file starting with number
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 ReInitializeMenuinitFromSSBP
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 DisplayLoadingMessageInInformationArea
683 mov cx, DRIVE_DIALOG_IO_size
684 call Memory_ReserveCXbytesFromStackToDSSI
685 call .DisplayDriveSelectionDialogWithIoInDSSI
686 call .ChangeDriveToUserSelectionFromIoInDSSI
687 add sp, BYTE DRIVE_DIALOG_IO_size
688 ret
689
690;--------------------------------------------------------------------
691; .DisplayDriveSelectionDialogWithIoInDSSI
692; Parameters:
693; DS:SI: Ptr to uninitialized DRIVE_DIALOG_IO
694; SS:BP: Ptr to DIALOG
695; Returns:
696; DS:SI: Ptr to DRIVE_DIALOG_IO
697; Corrupts registers:
698; AX, DI
699;--------------------------------------------------------------------
700ALIGN JUMP_ALIGN
701.DisplayDriveSelectionDialogWithIoInDSSI:
702 call InitializeNullStringsToDialogInputInDSSI
703 mov WORD [si+DIALOG_INPUT.fszTitle], g_szSelectNewDrive
704 CALL_MENU_LIBRARY GetDriveWithIoInDSSI
705 ret
706
707;--------------------------------------------------------------------
708; .ChangeDriveToUserSelectionFromIoInDSSI
709; Parameters:
710; DS:SI: Ptr to DRIVE_DIALOG_IO
711; SS:BP: Ptr to DIALOG
712; Returns:
713; Nothing
714; Corrupts registers:
715; All, except BP
716;--------------------------------------------------------------------
717ALIGN JUMP_ALIGN
718.ChangeDriveToUserSelectionFromIoInDSSI:
719 cmp BYTE [si+DRIVE_DIALOG_IO.bUserCancellation], FALSE
720 jne SHORT .UserCancelledDriveChange
721
722 mov dl, [si+DRIVE_DIALOG_IO.bReturnDriveNumber]
723 call Drive_SetDefaultFromDL
724 jmp RefreshFilesToDisplay
725.UserCancelledDriveChange:
726 ret
727
728
729;--------------------------------------------------------------------
730; DisplayLoadingMessageInInformationArea
731; Parameters:
732; SS:BP: Ptr to DIALOG
733; Returns:
734; Nothing
735; Corrupts registers:
736; AX, BX, CX, DX, SI, DI
737;--------------------------------------------------------------------
738ALIGN JUMP_ALIGN
739DisplayLoadingMessageInInformationArea:
740 call MenuText_ClearInformationArea
741 call MenuText_PrepareToDrawInformationArea
742 mov si, g_szLoadingPleaseWait
743 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
744 ret
745
746
747;--------------------------------------------------------------------
748; InitializeNullStringsToDialogInputInDSSI
749; Parameters:
750; DS:SI: Ptr to DIALOG_INPUT
751; SS:BP: Ptr to DIALOG
752; Returns:
753; Nothing
754; Corrupts registers:
755; AX
756;--------------------------------------------------------------------
757ALIGN JUMP_ALIGN
758InitializeNullStringsToDialogInputInDSSI:
759 mov ax, g_szNull
760 mov [si+DIALOG_INPUT.fszTitle], ax
761 mov [si+DIALOG_INPUT.fszTitle+2], cs
762 mov [si+DIALOG_INPUT.fszItems], ax
763 mov [si+DIALOG_INPUT.fszItems+2], cs
764 mov [si+DIALOG_INPUT.fszInfo], ax
765 mov [si+DIALOG_INPUT.fszInfo+2], cs
766 ret
Note: See TracBrowser for help on using the repository browser.