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

Last change on this file since 293 was 293, checked in by krille_n_@…, 12 years ago

Commit 1/2 (Library, Configurators and Serial Server):

  • Changed Emulate.inc so that making 286 and 386 versions now works. Additionally, only one processor type define is needed in the makefile.
  • Minor optimizations.
  • Fixed spelling and did some cleaning.
File size: 22.2 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, [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    je      SHORT .DoFilter
268    ret
269
270ALIGN JUMP_ALIGN
271.FilterUpDirectoryWhenInRoot:
272    test    dl, dl          ; Set ZF if root directory selected
273    jnz     SHORT .ReturnWithoutFiltering
274    cmp     WORD [si+DTA.szFile], UPDIR_CHARACTERS
275    jne     SHORT .ReturnWithoutFiltering
276.DoFilter:
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
378    ; Add directory contents string length to DI
379    mov     ax, FILE_STRING_LENGTH
380    push    ax
381    mul     cx
382    add     di, ax
383
384    mov     dx, cx
385    pop     cx
386    mov     bx, .FileStringComparator
387    jmp     Sort_ItemsFromDSSIwithCountInDXsizeInCXandComparatorInBX
388
389;--------------------------------------------------------------------
390; .FileStringComparator
391;   Parameters:
392;       CX:     Item size in bytes
393;       DS:SI:  Ptr to first item to compare
394;       ES:DI:  Ptr to second item to compare
395;   Returns:
396;       FLAGS:  Signed comparison between first and second item
397;   Corrupts registers:
398;       Nothing
399;--------------------------------------------------------------------
400ALIGN JUMP_ALIGN
401.FileStringComparator:
402    push    di
403    push    si
404    push    cx
405    push    bx
406
407    mov     bx, FILE_STRING_LENGTH-2            ; Zero BH
408    cmp     WORD [si], UPDIR_CHARACTERS
409    je      SHORT .ForceValueFromDSSItoBeLess
410    mov     bl, [si+bx]
411    cmp     bl, [es:di+FILE_STRING_LENGTH-2]    ; 'B' for files, 'R' for directories
412    jne     SHORT .ForceValueFromDSSItoBeMoreOrLess
413    repe cmpsb                                  ; Two directories or two files
414
415ALIGN JUMP_ALIGN
416.ReturnFromComparison:
417    pop     bx
418    pop     cx
419    pop     si
420    pop     di
421    ret
422ALIGN JUMP_ALIGN
423.ForceValueFromDSSItoBeMoreOrLess:
424    ja      SHORT .ForceValueFromDSSItoBeLess   ; Directory in SI, file in DI
425    xchg    bl, bh
426    ; Fall to ForceValueFromDSSItoBeLess
427ALIGN JUMP_ALIGN
428.ForceValueFromDSSItoBeLess:
429    cmp     bh, bl
430    jmp     SHORT .ReturnFromComparison
431
432
433;--------------------------------------------------------------------
434; RemoveLastLFandTerminateESDIwithNull
435;   Parameters:
436;       ES:DI:  Ptr to end of buffer to terminate
437;   Returns:
438;       Nothing
439;   Corrupts registers:
440;       AX
441;--------------------------------------------------------------------
442ALIGN JUMP_ALIGN
443RemoveLastLFandTerminateESDIwithNull:
444    dec     di
445    xor     ax, ax
446    stosb
447    ret
448
449
450;--------------------------------------------------------------------
451; GetInfoLinesToCXandDialogFlagsToAX
452;   Parameters:
453;       SS:BP:  Ptr to DIALOG
454;   Returns:
455;       AX:     Dialog flags
456;       CX:     Number of info lines to be displayed
457;   Corrupts registers:
458;       SI, DS
459;--------------------------------------------------------------------
460ALIGN JUMP_ALIGN
461GetInfoLinesToCXandDialogFlagsToAX:
462    xor     ax, ax
463    call    GetDialogFlagsToAL
464    jmp     Bit_GetSetCountToCXfromAX
465
466;--------------------------------------------------------------------
467; GetDialogFlagsToAL
468;   Parameters:
469;       SS:BP:  Ptr to DIALOG
470;   Returns:
471;       AL:     Dialog flags
472;   Corrupts registers:
473;       SI, DS
474;--------------------------------------------------------------------
475ALIGN JUMP_ALIGN
476GetDialogFlagsToAL:
477    lds     si, [bp+DIALOG.fpDialogIO]
478    mov     al, [si+FILE_DIALOG_IO.bDialogFlags]
479    ret
480
481
482;--------------------------------------------------------------------
483; ParseSelectionFromItemLineInDSSI
484;   Parameters:
485;       DS:SI:  Ptr to char buffer containing file or directory to be selected
486;       SS:BP:  Ptr to DIALOG
487;   Returns:
488;       Nothing
489;   Corrupts registers:
490;       All, except BP
491;--------------------------------------------------------------------
492ALIGN JUMP_ALIGN
493ParseSelectionFromItemLineInDSSI:
494    mov     ax, [si]
495    cmp     ax, UPDIR_CHARACTERS
496    je      SHORT .ChangeToUpdir
497    call    Char_IsUpperCaseLetterInAL
498    jc      SHORT .ParseAndChangeToSubdirInDSSI
499    call    Char_IsDecimalDigitInAL
500    jc      SHORT .ParseAndChangeToSubdirInDSSI ; Assume subdir and check for errors
501    ; Fall to .ParseAndSelectFileFromDSSI
502
503;--------------------------------------------------------------------
504; .ParseAndSelectFileFromDSSI
505;   Parameters:
506;       DS:SI:  NULL terminated string selected from dialog
507;       SS:BP:  Ptr to DIALOG
508;   Returns:
509;       Nothing (exits dialog)
510;   Corrupts registers:
511;       All, except BP
512;--------------------------------------------------------------------
513.ParseAndSelectFileFromDSSI:
514    les     di, [bp+DIALOG.fpDialogIO]
515    add     di, BYTE FILE_DIALOG_IO.szFile
516    mov     cx, FILENAME_BUFFER_SIZE-1
517    call    Memory_CopyCXbytesFromDSSItoESDI
518    xor     ax, ax
519    stosb                       ; Terminate with NULL
520    jmp     SHORT CloseFileDialogAfterSuccessfulSelection
521
522;--------------------------------------------------------------------
523; .ChangeToUpdir
524;   Parameters:
525;       SS:BP:  Ptr to DIALOG
526;   Returns:
527;       Nothing
528;   Corrupts registers:
529;       All, except BP
530;--------------------------------------------------------------------
531ALIGN JUMP_ALIGN
532.ChangeToUpdir:
533    push    cs
534    pop     ds
535    mov     si, g_szUpdir
536    jmp     SHORT .ChangeDirectoryToDSSI
537
538;--------------------------------------------------------------------
539; .ParseAndChangeToSubdirInDSSI
540;   Parameters:
541;       DS:SI:  NULL terminated string selected from dialog
542;       SS:BP:  Ptr to DIALOG
543;   Returns:
544;       Nothing
545;   Corrupts registers:
546;       All, except BP
547;--------------------------------------------------------------------
548ALIGN JUMP_ALIGN
549.ParseAndChangeToSubdirInDSSI:
550    mov     BYTE [si+12], NULL  ; Terminate with NULL (unnecessary spaces do not matter)
551.ChangeDirectoryToDSSI:
552    call    Directory_ChangeToPathFromDSSI
553    jc      SHORT .ParseAndSelectFileFromDSSI   ; Must have been a file starting with number
554    ; Fall to RefreshFilesToDisplay
555
556;--------------------------------------------------------------------
557; RefreshFilesToDisplay
558;   Parameters:
559;       SS:BP:  Ptr to DIALOG
560;   Returns:
561;       Nothing
562;   Corrupts registers:
563;       All, except BP
564;--------------------------------------------------------------------
565ALIGN JUMP_ALIGN
566RefreshFilesToDisplay:
567    call    ReInitializeMenuinitFromSSBP
568    jmp     MenuInit_RefreshMenuWindow
569
570
571;--------------------------------------------------------------------
572; HandleFunctionKeyFromAH
573;   Parameters:
574;       AH:     Scancode for function key
575;       SS:BP:  Ptr to DIALOG
576;   Returns:
577;       Nothing
578;   Corrupts registers:
579;       AX, SI, DI, BP
580;--------------------------------------------------------------------
581ALIGN JUMP_ALIGN
582HandleFunctionKeyFromAH:
583    call    GetDialogFlagsToAL
584    cmp     ah, KEY_FILEDIALOG_NEW_FILE_OR_DIR
585    je      SHORT HandleFunctionKeyForCreatingNewFileOrDirectory
586    cmp     ah, KEY_FILEDIALOG_SELECT_DIRECTORY
587    je      SHORT HandleFunctionKeyForSelectingDirectoryInsteadOfFile
588    cmp     ah, KEY_FILEDIALOG_CHANGE_DRIVE
589    je      SHORT HandleFunctionKeyForDriveChange
590ReturnWithoutHandlingKeystroke:
591    clc     ; Event not processed
592    ret
593
594
595;--------------------------------------------------------------------
596; HandleFunctionKeyForCreatingNewFileOrDirectory
597;   Parameters:
598;       AL:     File dialog flags
599;       SS:BP:  Ptr to DIALOG
600;   Returns:
601;       Closes file dialog
602;   Corrupts registers:
603;       All, except BP
604;--------------------------------------------------------------------
605ALIGN JUMP_ALIGN
606HandleFunctionKeyForCreatingNewFileOrDirectory:
607    test    al, FLG_FILEDIALOG_NEW
608    jz      SHORT ReturnWithoutHandlingKeystroke
609
610    mov     cx, STRING_DIALOG_IO_size
611    call    Memory_ReserveCXbytesFromStackToDSSI
612    call    .InitializeStringDialogIoInDSSIforInputtingFileName
613
614    CALL_MENU_LIBRARY GetStringWithIoInDSSI
615    mov     al, [si+STRING_DIALOG_IO.bUserCancellation]
616    add     sp, BYTE STRING_DIALOG_IO_size
617    test    al, al      ; User cancellation?
618    jnz     SHORT ReturnWithoutHandlingKeystroke
619    jmp     CloseFileDialogAfterSuccessfulSelection
620
621ALIGN JUMP_ALIGN
622.InitializeStringDialogIoInDSSIforInputtingFileName:
623    call    InitializeNullStringsToDialogInputInDSSI
624    mov     WORD [si+DIALOG_INPUT.fszTitle], g_szEnterNewFileOrDirectory
625    mov     WORD [si+STRING_DIALOG_IO.fnCharFilter], NULL
626    mov     WORD [si+STRING_DIALOG_IO.wBufferSize], FILENAME_BUFFER_SIZE
627    les     ax, [bp+DIALOG.fpDialogIO]
628    add     ax, BYTE FILE_DIALOG_IO.szFile
629    mov     [si+STRING_DIALOG_IO.fpReturnBuffer], ax
630    mov     [si+STRING_DIALOG_IO.fpReturnBuffer+2], es
631    ret
632
633
634;--------------------------------------------------------------------
635; HandleFunctionKeyForSelectingDirectoryInsteadOfFile
636;   Parameters:
637;       AL:     File dialog flags
638;       SS:BP:  Ptr to DIALOG
639;   Returns:
640;       Closes file dialog
641;   Corrupts registers:
642;       All, except BP
643;--------------------------------------------------------------------
644ALIGN JUMP_ALIGN
645HandleFunctionKeyForSelectingDirectoryInsteadOfFile:
646    test    al, FLG_FILEDIALOG_DIRECTORY
647    jz      SHORT ReturnWithoutHandlingKeystroke
648    ; Fall to CloseFileDialogAfterSuccessfulSelection
649
650;--------------------------------------------------------------------
651; CloseFileDialogAfterSuccessfulSelection
652;   Parameters:
653;       SS:BP:  Ptr to DIALOG
654;   Returns:
655;       Nothing (exits dialog)
656;   Corrupts registers:
657;       All, except BP
658;--------------------------------------------------------------------
659ALIGN JUMP_ALIGN
660CloseFileDialogAfterSuccessfulSelection:
661    lds     di, [bp+DIALOG.fpDialogIO]
662    mov     BYTE [di+FILE_DIALOG_IO.bUserCancellation], FALSE
663    jmp     MenuInit_CloseMenuWindow
664
665
666;--------------------------------------------------------------------
667; HandleFunctionKeyForDriveChange
668;   Parameters:
669;       AL:     File dialog flags
670;       SS:BP:  Ptr to DIALOG
671;   Returns:
672;       Nothing
673;   Corrupts registers:
674;       All, except BP
675;--------------------------------------------------------------------
676ALIGN JUMP_ALIGN
677HandleFunctionKeyForDriveChange:
678    test    al, FLG_FILEDIALOG_DRIVES
679    jz      SHORT ReturnWithoutHandlingKeystroke
680
681    call    DisplayLoadingMessageInInformationArea
682    mov     cx, DRIVE_DIALOG_IO_size
683    call    Memory_ReserveCXbytesFromStackToDSSI
684    call    .DisplayDriveSelectionDialogWithIoInDSSI
685    call    .ChangeDriveToUserSelectionFromIoInDSSI
686    add     sp, BYTE DRIVE_DIALOG_IO_size
687    ret
688
689;--------------------------------------------------------------------
690; .DisplayDriveSelectionDialogWithIoInDSSI
691;   Parameters:
692;       DS:SI:  Ptr to uninitialized DRIVE_DIALOG_IO
693;       SS:BP:  Ptr to DIALOG
694;   Returns:
695;       DS:SI:  Ptr to DRIVE_DIALOG_IO
696;   Corrupts registers:
697;       AX, DI
698;--------------------------------------------------------------------
699ALIGN JUMP_ALIGN
700.DisplayDriveSelectionDialogWithIoInDSSI:
701    call    InitializeNullStringsToDialogInputInDSSI
702    mov     WORD [si+DIALOG_INPUT.fszTitle], g_szSelectNewDrive
703    CALL_MENU_LIBRARY GetDriveWithIoInDSSI
704    ret
705
706;--------------------------------------------------------------------
707; .ChangeDriveToUserSelectionFromIoInDSSI
708;   Parameters:
709;       DS:SI:  Ptr to DRIVE_DIALOG_IO
710;       SS:BP:  Ptr to DIALOG
711;   Returns:
712;       Nothing
713;   Corrupts registers:
714;       All, except BP
715;--------------------------------------------------------------------
716ALIGN JUMP_ALIGN
717.ChangeDriveToUserSelectionFromIoInDSSI:
718    cmp     BYTE [si+DRIVE_DIALOG_IO.bUserCancellation], FALSE
719    jne     SHORT .UserCancelledDriveChange
720
721    mov     dl, [si+DRIVE_DIALOG_IO.bReturnDriveNumber]
722    call    Drive_SetDefaultFromDL
723    jmp     RefreshFilesToDisplay
724.UserCancelledDriveChange:
725    ret
726
727
728;--------------------------------------------------------------------
729; DisplayLoadingMessageInInformationArea
730;   Parameters:
731;       SS:BP:      Ptr to DIALOG
732;   Returns:
733;       Nothing
734;   Corrupts registers:
735;       AX, BX, CX, DX, SI, DI
736;--------------------------------------------------------------------
737ALIGN JUMP_ALIGN
738DisplayLoadingMessageInInformationArea:
739    call    MenuText_ClearInformationArea
740    call    MenuText_PrepareToDrawInformationArea
741    mov     si, g_szLoadingPleaseWait
742    CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
743    ret
744
745
746;--------------------------------------------------------------------
747; InitializeNullStringsToDialogInputInDSSI
748;   Parameters:
749;       DS:SI:  Ptr to DIALOG_INPUT
750;       SS:BP:  Ptr to DIALOG
751;   Returns:
752;       Nothing
753;   Corrupts registers:
754;       AX
755;--------------------------------------------------------------------
756ALIGN JUMP_ALIGN
757InitializeNullStringsToDialogInputInDSSI:
758    mov     ax, g_szNull
759    mov     [si+DIALOG_INPUT.fszTitle], ax
760    mov     [si+DIALOG_INPUT.fszTitle+2], cs
761    mov     [si+DIALOG_INPUT.fszItems], ax
762    mov     [si+DIALOG_INPUT.fszItems+2], cs
763    mov     [si+DIALOG_INPUT.fszInfo], ax
764    mov     [si+DIALOG_INPUT.fszInfo+2], cs
765    ret
Note: See TracBrowser for help on using the repository browser.