1 | ; File name : DialogFile.asm
|
---|
2 | ; Project name : Assembly Library
|
---|
3 | ; Created date : 6.9.2010
|
---|
4 | ; Last update : 28.9.2010
|
---|
5 | ; Author : Tomi Tilli
|
---|
6 | ; Description : Displays file dialog.
|
---|
7 |
|
---|
8 |
|
---|
9 | CURRENTDIR_CHARACTERS EQU 002Eh
|
---|
10 | UPDIR_CHARACTERS EQU 2E2Eh
|
---|
11 |
|
---|
12 | ; Section containing code
|
---|
13 | SECTION .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 | ;--------------------------------------------------------------------
|
---|
25 | ALIGN JUMP_ALIGN
|
---|
26 | DialogFile_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 | ;--------------------------------------------------------------------
|
---|
43 | ALIGN JUMP_ALIGN
|
---|
44 | FileEventHandler:
|
---|
45 | jmp [cs:bx+.rgfnEventHandlers]
|
---|
46 |
|
---|
47 |
|
---|
48 | ALIGN JUMP_ALIGN
|
---|
49 | .ItemSelectedFromCX:
|
---|
50 | call LoadItemStringBufferToESDI
|
---|
51 | call LineSplitter_GetOffsetToSIforLineCXfromStringInESDI
|
---|
52 | push es
|
---|
53 | pop ds
|
---|
54 | jmp ParseSelectionFromItemLineInDSSI
|
---|
55 |
|
---|
56 |
|
---|
57 | ALIGN JUMP_ALIGN
|
---|
58 | .RefreshInformation:
|
---|
59 | call GetInfoLinesToCXandDialogFlagsToAX
|
---|
60 | mov si, [cs:.rgszInfoStringLookup]
|
---|
61 | xor bx, bx
|
---|
62 | xchg dx, ax
|
---|
63 | ALIGN JUMP_ALIGN
|
---|
64 | .InfoLineLoop:
|
---|
65 | shr dl, 1
|
---|
66 | jnc SHORT .CheckNextFlag
|
---|
67 | mov si, [cs:bx+.rgszInfoStringLookup]
|
---|
68 | push bx
|
---|
69 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
70 | pop bx
|
---|
71 | ALIGN JUMP_ALIGN
|
---|
72 | .CheckNextFlag:
|
---|
73 | inc bx
|
---|
74 | inc bx
|
---|
75 | loop .InfoLineLoop
|
---|
76 | stc ; Event processed
|
---|
77 | ret
|
---|
78 |
|
---|
79 |
|
---|
80 | ALIGN WORD_ALIGN
|
---|
81 | .rgszInfoStringLookup:
|
---|
82 | dw g_szChangeDrive
|
---|
83 | dw g_szSelectDirectory
|
---|
84 | dw g_szCreateNew
|
---|
85 |
|
---|
86 | .rgfnEventHandlers:
|
---|
87 | istruc MENUEVENT
|
---|
88 | at MENUEVENT.InitializeMenuinitFromDSSI, dw InitializeMenuinitFromSSBP
|
---|
89 | at MENUEVENT.ExitMenu, dw Dialog_EventNotHandled
|
---|
90 | at MENUEVENT.IdleProcessing, dw Dialog_EventNotHandled
|
---|
91 | at MENUEVENT.ItemHighlightedFromCX, dw Dialog_EventNotHandled
|
---|
92 | at MENUEVENT.ItemSelectedFromCX, dw .ItemSelectedFromCX
|
---|
93 | at MENUEVENT.KeyStrokeInAX, dw HandleFunctionKeyFromAH
|
---|
94 | at MENUEVENT.RefreshTitle, dw Dialog_EventRefreshTitle
|
---|
95 | at MENUEVENT.RefreshInformation, dw .RefreshInformation
|
---|
96 | at MENUEVENT.RefreshItemFromCX, dw Dialog_EventRefreshItemFromCX
|
---|
97 | iend
|
---|
98 |
|
---|
99 |
|
---|
100 | ;--------------------------------------------------------------------
|
---|
101 | ; InitializeMenuinitFromSSBP
|
---|
102 | ; Parameters:
|
---|
103 | ; DS:SI: Ptr to MENUINIT to initialize (also points to DIALOG)
|
---|
104 | ; SS:BP: Ptr to DIALOG
|
---|
105 | ; Returns:
|
---|
106 | ; Nothing
|
---|
107 | ; Corrupts registers:
|
---|
108 | ; All, except BP
|
---|
109 | ;--------------------------------------------------------------------
|
---|
110 | ALIGN JUMP_ALIGN
|
---|
111 | InitializeMenuinitFromSSBP:
|
---|
112 | call LoadItemStringBufferToESDI
|
---|
113 | call CreateStringFromCurrentDirectoryContentsToESDI
|
---|
114 | push ss
|
---|
115 | pop ds
|
---|
116 | mov si, bp
|
---|
117 | call Dialog_EventInitializeMenuinitFromDSSI
|
---|
118 | call GetInfoLinesToCXandDialogFlagsToAX
|
---|
119 | mov [bp+MENUINIT.bInfoLines], cl
|
---|
120 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
|
---|
121 | mov [bp+MENUINIT.bHeight], ah ; Always max height
|
---|
122 | mov WORD [bp+MENU.wHighlightedItem], 0
|
---|
123 | ret
|
---|
124 |
|
---|
125 |
|
---|
126 | ;--------------------------------------------------------------------
|
---|
127 | ; LoadItemStringBufferToESDI
|
---|
128 | ; Parameters:
|
---|
129 | ; SS:BP: Ptr to DIALOG
|
---|
130 | ; Returns:
|
---|
131 | ; ES:DI: Ptr to item string buffer
|
---|
132 | ; Corrupts registers:
|
---|
133 | ; Nothing
|
---|
134 | ;--------------------------------------------------------------------
|
---|
135 | ALIGN JUMP_ALIGN
|
---|
136 | LoadItemStringBufferToESDI:
|
---|
137 | les di, [bp+DIALOG.fpDialogIO]
|
---|
138 | les di, [es:di+FILE_DIALOG_IO.fszItemBuffer]
|
---|
139 | ret
|
---|
140 |
|
---|
141 |
|
---|
142 | ;--------------------------------------------------------------------
|
---|
143 | ; CreateStringFromCurrentDirectoryContentsToESDI
|
---|
144 | ; Parameters:
|
---|
145 | ; ES:DI: Buffer where to create item string
|
---|
146 | ; SS:BP: Ptr to DIALOG
|
---|
147 | ; Returns:
|
---|
148 | ; Nothing
|
---|
149 | ; Corrupts registers:
|
---|
150 | ; AX, CX, DX, SI, DI, DS, ES
|
---|
151 | ;--------------------------------------------------------------------
|
---|
152 | ALIGN JUMP_ALIGN
|
---|
153 | CreateStringFromCurrentDirectoryContentsToESDI:
|
---|
154 | lds si, [bp+DIALOG.fpDialogIO]
|
---|
155 | eMOVZX cx, BYTE [si+FILE_DIALOG_IO.bFileAttributes]
|
---|
156 | lds si, [si+FILE_DIALOG_IO.fpFileFilterString]
|
---|
157 | call Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX
|
---|
158 | rcr cx, 1 ; Store CF
|
---|
159 | call .ClearDLifInRootDirectory
|
---|
160 | call Directory_GetDiskTransferAreaAddressToDSSI
|
---|
161 | rcl cx, 1 ; Restore CF
|
---|
162 | ; Fall to .FindMatchingFilesAndWriteThemToESDI
|
---|
163 |
|
---|
164 | ;--------------------------------------------------------------------
|
---|
165 | ; .FindMatchingFilesAndWriteThemToESDI
|
---|
166 | ; Parameters:
|
---|
167 | ; DL: Zero if root directory selected
|
---|
168 | ; DS:SI: Ptr to DTA with first matching file
|
---|
169 | ; ES:DI: Ptr to destination string buffer
|
---|
170 | ; Returns:
|
---|
171 | ; Nothing
|
---|
172 | ; Corrupts registers:
|
---|
173 | ; AX, CX, DX, DI
|
---|
174 | ;--------------------------------------------------------------------
|
---|
175 | ;ALIGN JUMP_ALIGN
|
---|
176 | .FindMatchingFilesAndWriteThemToESDI:
|
---|
177 | jc SHORT RemoveLastLFandTerminateESDIwithNull
|
---|
178 | call AppendFileToBufferInESDIfromDtaInDSSI
|
---|
179 | call Directory_UpdateDTAForNextMatchUsingPreviousParameters
|
---|
180 | jmp SHORT .FindMatchingFilesAndWriteThemToESDI
|
---|
181 |
|
---|
182 | ;--------------------------------------------------------------------
|
---|
183 | ; .ClearDLifInRootDirectory
|
---|
184 | ; Parameters:
|
---|
185 | ; SS:BP: Ptr to DIALOG
|
---|
186 | ; ES:DI: Ptr to destination string buffer
|
---|
187 | ; Returns:
|
---|
188 | ; DL: Cleared if in root directory
|
---|
189 | ; Set if in any other directory
|
---|
190 | ; Corrupts registers:
|
---|
191 | ; AX, SI, DS
|
---|
192 | ;--------------------------------------------------------------------
|
---|
193 | ALIGN JUMP_ALIGN
|
---|
194 | .ClearDLifInRootDirectory:
|
---|
195 | push es
|
---|
196 | pop ds
|
---|
197 | mov si, di
|
---|
198 | call Directory_WriteCurrentPathToDSSI
|
---|
199 | mov dl, [si]
|
---|
200 | ret
|
---|
201 |
|
---|
202 | ;--------------------------------------------------------------------
|
---|
203 | ; RemoveLastLFandTerminateESDIwithNull
|
---|
204 | ; Parameters:
|
---|
205 | ; ES:DI: Ptr to destination string buffer
|
---|
206 | ; Returns:
|
---|
207 | ; Nothing
|
---|
208 | ; Corrupts registers:
|
---|
209 | ; AX
|
---|
210 | ;--------------------------------------------------------------------
|
---|
211 | ALIGN JUMP_ALIGN
|
---|
212 | RemoveLastLFandTerminateESDIwithNull:
|
---|
213 | xor ax, ax
|
---|
214 | dec di ; Remove last LF
|
---|
215 | stosb
|
---|
216 | ret
|
---|
217 |
|
---|
218 | ;--------------------------------------------------------------------
|
---|
219 | ; AppendFileToBufferInESDIfromDtaInDSSI
|
---|
220 | ; Parameters:
|
---|
221 | ; DL: Zero if root directory selected
|
---|
222 | ; DS:SI: Ptr to DTA containing file information
|
---|
223 | ; ES:DI: Ptr to destination string buffer
|
---|
224 | ; Returns:
|
---|
225 | ; DI: Updated for next file
|
---|
226 | ; Corrupts registers:
|
---|
227 | ; AX, BX, CX, DX
|
---|
228 | ;--------------------------------------------------------------------
|
---|
229 | ALIGN JUMP_ALIGN
|
---|
230 | AppendFileToBufferInESDIfromDtaInDSSI:
|
---|
231 | call .FilterCurrentDirectory ; We never want "."
|
---|
232 | call .FilterUpDirectoryWhenInRoot ; No ".." when in root directory
|
---|
233 | ; Fall to .PrepareBufferFormattingAndFormatFromDTAinDSSI
|
---|
234 |
|
---|
235 | ;--------------------------------------------------------------------
|
---|
236 | ; .PrepareBufferFormattingAndFormatFromDTAinDSSI
|
---|
237 | ; Parameters:
|
---|
238 | ; DS:SI: Ptr to DTA containing file information
|
---|
239 | ; ES:DI: Ptr to destination string buffer
|
---|
240 | ; Returns:
|
---|
241 | ; DI: Updated for next file
|
---|
242 | ; Corrupts registers:
|
---|
243 | ; AX, BX, CX, DX
|
---|
244 | ;--------------------------------------------------------------------
|
---|
245 | ;ALIGN JUMP_ALIGN
|
---|
246 | .PrepareBufferFormattingAndFormatFromDTAinDSSI:
|
---|
247 | push bp
|
---|
248 | push si
|
---|
249 | mov cx, di
|
---|
250 | CALL_DISPLAY_LIBRARY PushDisplayContext
|
---|
251 |
|
---|
252 | mov bx, es
|
---|
253 | xchg ax, cx
|
---|
254 | CALL_DISPLAY_LIBRARY SetCharacterPointerFromBXAX
|
---|
255 | mov bl, ATTRIBUTES_NOT_USED
|
---|
256 | mov ax, BUFFER_OUTPUT_WITH_CHAR_ONLY
|
---|
257 | CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
|
---|
258 |
|
---|
259 | call .FormatFileOrDirectoryToBufferFromDTAinDSSI
|
---|
260 |
|
---|
261 | CALL_DISPLAY_LIBRARY GetCharacterPointerToBXAX
|
---|
262 | mov es, bx
|
---|
263 | xchg cx, ax
|
---|
264 | CALL_DISPLAY_LIBRARY PopDisplayContext
|
---|
265 | mov di, cx
|
---|
266 | pop si
|
---|
267 | pop bp
|
---|
268 | ret
|
---|
269 |
|
---|
270 | ;--------------------------------------------------------------------
|
---|
271 | ; .FormatFileOrDirectoryToBufferFromDTAinDSSI
|
---|
272 | ; Parameters:
|
---|
273 | ; DS:SI: Ptr to DTA containing file information
|
---|
274 | ; Returns:
|
---|
275 | ; Nothing
|
---|
276 | ; Corrupts registers:
|
---|
277 | ; AX, BX, CX, DX, SI, DI, BP
|
---|
278 | ;--------------------------------------------------------------------
|
---|
279 | ALIGN JUMP_ALIGN
|
---|
280 | .FormatFileOrDirectoryToBufferFromDTAinDSSI:
|
---|
281 | mov bp, sp
|
---|
282 | lea ax, [si+DTA.szFile]
|
---|
283 | push ax
|
---|
284 | push ds
|
---|
285 |
|
---|
286 | test BYTE [si+DTA.bFileAttributes], FLG_FILEATTR_DIRECTORY
|
---|
287 | jnz SHORT .FormatDirectory
|
---|
288 |
|
---|
289 | mov ax, [si+DTA.dwFileSize]
|
---|
290 | mov dx, [si+DTA.dwFileSize+2]
|
---|
291 | xor bx, bx
|
---|
292 | xor cx, cx
|
---|
293 | call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
|
---|
294 | mov cl, 'i'
|
---|
295 | cmp dl, ' '
|
---|
296 | eCMOVE cl, dl
|
---|
297 | push ax
|
---|
298 | push dx
|
---|
299 | push cx
|
---|
300 | mov si, g_szFileFormat
|
---|
301 | jmp SHORT .FormatStringInCSSIandReturn
|
---|
302 |
|
---|
303 | ALIGN JUMP_ALIGN
|
---|
304 | .FormatDirectory:
|
---|
305 | mov ax, g_szSub
|
---|
306 | cmp WORD [si+DTA.szFile], UPDIR_CHARACTERS
|
---|
307 | eCMOVE ax, g_szUp
|
---|
308 | push ax
|
---|
309 | mov si, g_szDirectoryFormat
|
---|
310 | ALIGN JUMP_ALIGN
|
---|
311 | .FormatStringInCSSIandReturn:
|
---|
312 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
313 | ret
|
---|
314 |
|
---|
315 | ;--------------------------------------------------------------------
|
---|
316 | ; .FilterCurrentDirectory
|
---|
317 | ; .FilterUpDirectoryWhenInRoot
|
---|
318 | ; Parameters:
|
---|
319 | ; DL: Zero if root directory selected
|
---|
320 | ; DS:SI: Ptr to DTA containing file information
|
---|
321 | ; Returns:
|
---|
322 | ; Nothing
|
---|
323 | ; Returns from AppendFileToBufferInESDIfromDtaInDSSI when filtering
|
---|
324 | ; Corrupts registers:
|
---|
325 | ; AX
|
---|
326 | ;--------------------------------------------------------------------
|
---|
327 | ALIGN JUMP_ALIGN
|
---|
328 | .FilterCurrentDirectory:
|
---|
329 | cmp WORD [si+DTA.szFile], CURRENTDIR_CHARACTERS
|
---|
330 | jne SHORT .ReturnWithoutFiltering
|
---|
331 | add sp, BYTE 2 ; Remove return address from stack
|
---|
332 | ret
|
---|
333 |
|
---|
334 | ALIGN JUMP_ALIGN
|
---|
335 | .FilterUpDirectoryWhenInRoot:
|
---|
336 | test dl, dl ; Set ZF if root directory selected
|
---|
337 | jnz SHORT .ReturnWithoutFiltering
|
---|
338 | cmp WORD [si+DTA.szFile], UPDIR_CHARACTERS
|
---|
339 | jne SHORT .ReturnWithoutFiltering
|
---|
340 | add sp, BYTE 2 ; Remove return address from stack
|
---|
341 | ALIGN JUMP_ALIGN, ret
|
---|
342 | .ReturnWithoutFiltering:
|
---|
343 | ret
|
---|
344 |
|
---|
345 |
|
---|
346 | ;--------------------------------------------------------------------
|
---|
347 | ; GetInfoLinesToCXandDialogFlagsToAX
|
---|
348 | ; Parameters:
|
---|
349 | ; SS:BP: Ptr to DIALOG
|
---|
350 | ; Returns:
|
---|
351 | ; AX: Dialog flags
|
---|
352 | ; CX: Number of info lines to be displayed
|
---|
353 | ; Corrupts registers:
|
---|
354 | ; SI, DS
|
---|
355 | ;--------------------------------------------------------------------
|
---|
356 | ALIGN JUMP_ALIGN
|
---|
357 | GetInfoLinesToCXandDialogFlagsToAX:
|
---|
358 | xor ax, ax
|
---|
359 | call GetDialogFlagsToAL
|
---|
360 | jmp Bit_GetSetCountToCXfromAX
|
---|
361 |
|
---|
362 | ;--------------------------------------------------------------------
|
---|
363 | ; GetDialogFlagsToAL
|
---|
364 | ; Parameters:
|
---|
365 | ; SS:BP: Ptr to DIALOG
|
---|
366 | ; Returns:
|
---|
367 | ; AL: Dialog flags
|
---|
368 | ; Corrupts registers:
|
---|
369 | ; SI, DS
|
---|
370 | ;--------------------------------------------------------------------
|
---|
371 | ALIGN JUMP_ALIGN
|
---|
372 | GetDialogFlagsToAL:
|
---|
373 | lds si, [bp+DIALOG.fpDialogIO]
|
---|
374 | mov al, [si+FILE_DIALOG_IO.bDialogFlags]
|
---|
375 | ret
|
---|
376 |
|
---|
377 |
|
---|
378 | ;--------------------------------------------------------------------
|
---|
379 | ; ParseSelectionFromItemLineInDSSI
|
---|
380 | ; Parameters:
|
---|
381 | ; DS:SI: Ptr to char buffer containing file or directory to be selected
|
---|
382 | ; SS:BP: Ptr to DIALOG
|
---|
383 | ; Returns:
|
---|
384 | ; Nothing
|
---|
385 | ; Corrupts registers:
|
---|
386 | ; All, except BP
|
---|
387 | ;--------------------------------------------------------------------
|
---|
388 | ALIGN JUMP_ALIGN
|
---|
389 | ParseSelectionFromItemLineInDSSI:
|
---|
390 | cmp BYTE [si], '['
|
---|
391 | je SHORT .ChangeToSubdirInDSSI
|
---|
392 | ; Fall to .SelectFileFromDSSI
|
---|
393 |
|
---|
394 | ;--------------------------------------------------------------------
|
---|
395 | ; .SelectFileFromDSSI
|
---|
396 | ; Parameters:
|
---|
397 | ; DS:SI: Ptr to char buffer containing file name to be selected
|
---|
398 | ; SS:BP: Ptr to DIALOG
|
---|
399 | ; Returns:
|
---|
400 | ; Nothing (exits dialog)
|
---|
401 | ; Corrupts registers:
|
---|
402 | ; All, except BP
|
---|
403 | ;--------------------------------------------------------------------
|
---|
404 | ;ALIGN JUMP_ALIGN
|
---|
405 | .SelectFileFromDSSI:
|
---|
406 | les di, [bp+DIALOG.fpDialogIO]
|
---|
407 | add di, BYTE FILE_DIALOG_IO.szFile
|
---|
408 | mov cx, FILENAME_BUFFER_SIZE-1
|
---|
409 | cld
|
---|
410 | rep movsb
|
---|
411 | xor ax, ax
|
---|
412 | stosb ; Terminate with NULL
|
---|
413 | jmp CloseFileDialogAfterSuccessfullSelection
|
---|
414 |
|
---|
415 | ;--------------------------------------------------------------------
|
---|
416 | ; ChangeToSubdirInDSSI
|
---|
417 | ; Parameters:
|
---|
418 | ; DS:SI: NULL terminated string containing new subdir in []
|
---|
419 | ; SS:BP: Ptr to DIALOG
|
---|
420 | ; Returns:
|
---|
421 | ; Nothing
|
---|
422 | ; Corrupts registers:
|
---|
423 | ; All, except BP
|
---|
424 | ;--------------------------------------------------------------------
|
---|
425 | ALIGN JUMP_ALIGN
|
---|
426 | .ChangeToSubdirInDSSI:
|
---|
427 | inc si ; Skip '['
|
---|
428 | mov BYTE [si+12], NULL ; Replace ']' with NULL
|
---|
429 | cmp WORD [si], UPDIR_CHARACTERS
|
---|
430 | eCMOVE si, g_szUpdir ; Real DOS do not accept spaces after ".."
|
---|
431 | call Directory_ChangeToPathFromDSSI
|
---|
432 | ; Fall to RefreshFilesToDisplay
|
---|
433 |
|
---|
434 | ;--------------------------------------------------------------------
|
---|
435 | ; RefreshFilesToDisplay
|
---|
436 | ; Parameters:
|
---|
437 | ; SS:BP: Ptr to DIALOG
|
---|
438 | ; Returns:
|
---|
439 | ; Nothing
|
---|
440 | ; Corrupts registers:
|
---|
441 | ; All, except BP
|
---|
442 | ;--------------------------------------------------------------------
|
---|
443 | ALIGN JUMP_ALIGN
|
---|
444 | RefreshFilesToDisplay:
|
---|
445 | call InitializeMenuinitFromSSBP
|
---|
446 | jmp MenuInit_RefreshMenuWindow
|
---|
447 |
|
---|
448 |
|
---|
449 | ;--------------------------------------------------------------------
|
---|
450 | ; HandleFunctionKeyFromAH
|
---|
451 | ; Parameters:
|
---|
452 | ; AH: Scancode for function key
|
---|
453 | ; SS:BP: Ptr to DIALOG
|
---|
454 | ; Returns:
|
---|
455 | ; Nothing
|
---|
456 | ; Corrupts registers:
|
---|
457 | ; AX, SI, DI, BP
|
---|
458 | ;--------------------------------------------------------------------
|
---|
459 | ALIGN JUMP_ALIGN
|
---|
460 | HandleFunctionKeyFromAH:
|
---|
461 | call GetDialogFlagsToAL
|
---|
462 | cmp ah, KEY_FILEDIALOG_NEW_FILE_OR_DIR
|
---|
463 | je SHORT HandleFunctionKeyForCreatingNewFileOrDirectory
|
---|
464 | cmp ah, KEY_FILEDIALOG_SELECT_DIRECTORY
|
---|
465 | je SHORT HandleFunctionKeyForSelectingDirectoryInsteadOfFile
|
---|
466 | cmp ah, KEY_FILEDIALOG_CHANGE_DRIVE
|
---|
467 | je SHORT HandleFunctionKeyForDriveChange
|
---|
468 | ReturnWithoutHandlingKeystroke:
|
---|
469 | clc ; Event not processed
|
---|
470 | ret
|
---|
471 |
|
---|
472 |
|
---|
473 | ;--------------------------------------------------------------------
|
---|
474 | ; HandleFunctionKeyForCreatingNewFileOrDirectory
|
---|
475 | ; Parameters:
|
---|
476 | ; AL: File dialog flags
|
---|
477 | ; SS:BP: Ptr to DIALOG
|
---|
478 | ; Returns:
|
---|
479 | ; Closes file dialog
|
---|
480 | ; Corrupts registers:
|
---|
481 | ; All, except BP
|
---|
482 | ;--------------------------------------------------------------------
|
---|
483 | ALIGN JUMP_ALIGN
|
---|
484 | HandleFunctionKeyForCreatingNewFileOrDirectory:
|
---|
485 | test al, FLG_FILEDIALOG_NEW
|
---|
486 | jz SHORT ReturnWithoutHandlingKeystroke
|
---|
487 |
|
---|
488 | mov cx, STRING_DIALOG_IO_size
|
---|
489 | call Memory_ReserveCXbytesFromStackToDSSI
|
---|
490 | call .InitializeStringDialogIoInDSSIforInputtingFileName
|
---|
491 |
|
---|
492 | CALL_MENU_LIBRARY GetStringWithIoInDSSI
|
---|
493 | mov al, [si+STRING_DIALOG_IO.bUserCancellation]
|
---|
494 | add sp, BYTE STRING_DIALOG_IO_size
|
---|
495 | test al, al ; User cancellation?
|
---|
496 | jnz SHORT ReturnWithoutHandlingKeystroke
|
---|
497 | jmp CloseFileDialogAfterSuccessfullSelection
|
---|
498 |
|
---|
499 | ALIGN JUMP_ALIGN
|
---|
500 | .InitializeStringDialogIoInDSSIforInputtingFileName:
|
---|
501 | call InitializeNullStringsToDialogInputInDSSI
|
---|
502 | mov WORD [si+DIALOG_INPUT.fszTitle], g_szEnterNewFileOrDirectory
|
---|
503 | mov WORD [si+STRING_DIALOG_IO.fnCharFilter], NULL
|
---|
504 | mov WORD [si+STRING_DIALOG_IO.wBufferSize], FILENAME_BUFFER_SIZE
|
---|
505 | les ax, [bp+DIALOG.fpDialogIO]
|
---|
506 | add ax, BYTE FILE_DIALOG_IO.szFile
|
---|
507 | mov [si+STRING_DIALOG_IO.fpReturnBuffer], ax
|
---|
508 | mov [si+STRING_DIALOG_IO.fpReturnBuffer+2], es
|
---|
509 | ret
|
---|
510 |
|
---|
511 |
|
---|
512 | ;--------------------------------------------------------------------
|
---|
513 | ; HandleFunctionKeyForSelectingDirectoryInsteadOfFile
|
---|
514 | ; Parameters:
|
---|
515 | ; AL: File dialog flags
|
---|
516 | ; SS:BP: Ptr to DIALOG
|
---|
517 | ; Returns:
|
---|
518 | ; Closes file dialog
|
---|
519 | ; Corrupts registers:
|
---|
520 | ; All, except BP
|
---|
521 | ;--------------------------------------------------------------------
|
---|
522 | ALIGN JUMP_ALIGN
|
---|
523 | HandleFunctionKeyForSelectingDirectoryInsteadOfFile:
|
---|
524 | test al, FLG_FILEDIALOG_DIRECTORY
|
---|
525 | jz SHORT ReturnWithoutHandlingKeystroke
|
---|
526 | ; Fall to CloseFileDialogAfterSuccessfullSelection
|
---|
527 |
|
---|
528 | ;--------------------------------------------------------------------
|
---|
529 | ; CloseFileDialogAfterSuccessfullSelection
|
---|
530 | ; Parameters:
|
---|
531 | ; SS:BP: Ptr to DIALOG
|
---|
532 | ; Returns:
|
---|
533 | ; Nothing (exits dialog)
|
---|
534 | ; Corrupts registers:
|
---|
535 | ; All, except BP
|
---|
536 | ;--------------------------------------------------------------------
|
---|
537 | ALIGN JUMP_ALIGN
|
---|
538 | CloseFileDialogAfterSuccessfullSelection:
|
---|
539 | lds di, [bp+DIALOG.fpDialogIO]
|
---|
540 | mov BYTE [di+FILE_DIALOG_IO.bUserCancellation], FALSE
|
---|
541 | jmp MenuInit_CloseMenuWindow
|
---|
542 |
|
---|
543 |
|
---|
544 | ;--------------------------------------------------------------------
|
---|
545 | ; HandleFunctionKeyForDriveChange
|
---|
546 | ; Parameters:
|
---|
547 | ; AL: File dialog flags
|
---|
548 | ; SS:BP: Ptr to DIALOG
|
---|
549 | ; Returns:
|
---|
550 | ; Nothing
|
---|
551 | ; Corrupts registers:
|
---|
552 | ; All, except BP
|
---|
553 | ;--------------------------------------------------------------------
|
---|
554 | ALIGN JUMP_ALIGN
|
---|
555 | HandleFunctionKeyForDriveChange:
|
---|
556 | test al, FLG_FILEDIALOG_DRIVES
|
---|
557 | jz SHORT ReturnWithoutHandlingKeystroke
|
---|
558 |
|
---|
559 | call .ShowDriveSelectionDialogAndGetDriveNumberToDL
|
---|
560 | jnc SHORT RefreshFilesToDisplay
|
---|
561 | call Drive_SetDefaultFromDL
|
---|
562 | jmp SHORT RefreshFilesToDisplay
|
---|
563 |
|
---|
564 | ;--------------------------------------------------------------------
|
---|
565 | ; .ShowDriveSelectionDialogAndGetDriveNumberToDL
|
---|
566 | ; Parameters:
|
---|
567 | ; SS:BP: Ptr to DIALOG
|
---|
568 | ; Returns:
|
---|
569 | ; DL: Drive selected by user
|
---|
570 | ; CF: Set if new drive selected
|
---|
571 | ; Cleared if selection cancelled by user
|
---|
572 | ; Corrupts registers:
|
---|
573 | ; All, except BP
|
---|
574 | ;--------------------------------------------------------------------
|
---|
575 | ALIGN JUMP_ALIGN
|
---|
576 | .ShowDriveSelectionDialogAndGetDriveNumberToDL:
|
---|
577 | mov cx, DIALOG_INPUT_size
|
---|
578 | call Memory_ReserveCXbytesFromStackToDSSI
|
---|
579 | call .InitializeDialogInputInDSSIforDriveSelection
|
---|
580 | call DialogSelection_GetSelectionToAXwithInputInDSSI
|
---|
581 | add sp, BYTE DIALOG_INPUT_size
|
---|
582 | cmp ax, BYTE NO_ITEM_SELECTED ; Clear CF if equal
|
---|
583 | jne SHORT .ConvertDriveNumberToDLfromItemIndexInAX
|
---|
584 | ret
|
---|
585 |
|
---|
586 | ALIGN JUMP_ALIGN
|
---|
587 | .InitializeDialogInputInDSSIforDriveSelection:
|
---|
588 | call InitializeNullStringsToDialogInputInDSSI
|
---|
589 | call LoadItemStringBufferToESDI
|
---|
590 | mov WORD [si+DIALOG_INPUT.fszTitle], g_szSelectNewDrive
|
---|
591 | mov [si+DIALOG_INPUT.fszItems], di
|
---|
592 | mov [si+DIALOG_INPUT.fszItems+2], es
|
---|
593 | call Drive_GetFlagsForAvailableDrivesToDXAX
|
---|
594 | ; Fall to .GenerateDriveSelectionStringToESDIfromDriveFlagsInDXAX
|
---|
595 |
|
---|
596 | ;--------------------------------------------------------------------
|
---|
597 | ; .GenerateDriveSelectionStringToESDIfromDriveFlagsInDXAX
|
---|
598 | ; Parameters:
|
---|
599 | ; DX:AX: Drive letter flags
|
---|
600 | ; ES:DI: Ptr to item string buffer
|
---|
601 | ; SS:BP: Ptr to DIALOG
|
---|
602 | ; Returns:
|
---|
603 | ; Nothing
|
---|
604 | ; Corrupts registers:
|
---|
605 | ; AX, BX, CX, DX, DI, ES
|
---|
606 | ;--------------------------------------------------------------------
|
---|
607 | ;ALIGN JUMP_ALIGN
|
---|
608 | .GenerateDriveSelectionStringToESDIfromDriveFlagsInDXAX:
|
---|
609 | cld
|
---|
610 | xchg cx, ax
|
---|
611 | mov ax, 3A41h ; A:
|
---|
612 | ALIGN JUMP_ALIGN
|
---|
613 | .BitShiftLoop:
|
---|
614 | shr dx, 1
|
---|
615 | rcr cx, 1
|
---|
616 | jnc SHORT .CheckIfMoreDrivesLeft
|
---|
617 | stosw
|
---|
618 | mov BYTE [es:di], LF
|
---|
619 | inc di
|
---|
620 | ALIGN JUMP_ALIGN
|
---|
621 | .CheckIfMoreDrivesLeft:
|
---|
622 | inc ax ; Next drive letter
|
---|
623 | mov bx, dx
|
---|
624 | or bx, cx
|
---|
625 | jnz SHORT .BitShiftLoop
|
---|
626 | jmp RemoveLastLFandTerminateESDIwithNull
|
---|
627 |
|
---|
628 | ;--------------------------------------------------------------------
|
---|
629 | ; .ConvertDriveNumberToDLfromItemIndexInAX
|
---|
630 | ; Parameters:
|
---|
631 | ; AX: Selected drive item
|
---|
632 | ; Returns:
|
---|
633 | ; DL: Drive number
|
---|
634 | ; CF: Set since drive selected
|
---|
635 | ; Corrupts registers:
|
---|
636 | ; AX, CX, DH
|
---|
637 | ;--------------------------------------------------------------------
|
---|
638 | ALIGN JUMP_ALIGN
|
---|
639 | .ConvertDriveNumberToDLfromItemIndexInAX:
|
---|
640 | mov ah, -1
|
---|
641 | xchg cx, ax
|
---|
642 | call Drive_GetFlagsForAvailableDrivesToDXAX
|
---|
643 | ALIGN JUMP_ALIGN
|
---|
644 | .BitScanLoop:
|
---|
645 | shr dx, 1
|
---|
646 | rcr ax, 1
|
---|
647 | inc ch ; Increment drive number
|
---|
648 | sbb cl, 0 ; Decrement selection index
|
---|
649 | jnc SHORT .BitScanLoop
|
---|
650 | mov dl, ch
|
---|
651 | stc ; Drive selected by user
|
---|
652 | ret
|
---|
653 |
|
---|
654 |
|
---|
655 | ;--------------------------------------------------------------------
|
---|
656 | ; InitializeNullStringsToDialogInputInDSSI
|
---|
657 | ; Parameters:
|
---|
658 | ; DS:SI: Ptr to DIALOG_INPUT
|
---|
659 | ; SS:BP: Ptr to DIALOG
|
---|
660 | ; Returns:
|
---|
661 | ; Nothing
|
---|
662 | ; Corrupts registers:
|
---|
663 | ; AX
|
---|
664 | ;--------------------------------------------------------------------
|
---|
665 | ALIGN JUMP_ALIGN
|
---|
666 | InitializeNullStringsToDialogInputInDSSI:
|
---|
667 | mov ax, g_szNull
|
---|
668 | mov [si+DIALOG_INPUT.fszTitle], ax
|
---|
669 | mov [si+DIALOG_INPUT.fszTitle+2], cs
|
---|
670 | mov [si+DIALOG_INPUT.fszItems], ax
|
---|
671 | mov [si+DIALOG_INPUT.fszItems+2], cs
|
---|
672 | mov [si+DIALOG_INPUT.fszInfo], ax
|
---|
673 | mov [si+DIALOG_INPUT.fszInfo+2], cs
|
---|
674 | ret
|
---|