1 | ; File name : DialogFile.asm
|
---|
2 | ; Project name : Assembly Library
|
---|
3 | ; Created date : 6.9.2010
|
---|
4 | ; Last update : 16.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, 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, 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
|
---|
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
|
---|
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 ax, BUFFER_OUTPUT_WITH_CHAR_ONLY
|
---|
256 | CALL_DISPLAY_LIBRARY SetCharacterOutputFunctionFromAX
|
---|
257 |
|
---|
258 | call .FormatFileOrDirectoryToBufferFromDTAinDSSI
|
---|
259 |
|
---|
260 | CALL_DISPLAY_LIBRARY GetCharacterPointerToBXAX
|
---|
261 | mov es, bx
|
---|
262 | xchg cx, ax
|
---|
263 | CALL_DISPLAY_LIBRARY PopDisplayContext
|
---|
264 | mov di, cx
|
---|
265 | pop si
|
---|
266 | pop bp
|
---|
267 | ret
|
---|
268 |
|
---|
269 | ;--------------------------------------------------------------------
|
---|
270 | ; .FormatFileOrDirectoryToBufferFromDTAinDSSI
|
---|
271 | ; Parameters:
|
---|
272 | ; DS:SI: Ptr to DTA containing file information
|
---|
273 | ; Returns:
|
---|
274 | ; Nothing
|
---|
275 | ; Corrupts registers:
|
---|
276 | ; AX, BX, CX, DX, SI, DI, BP
|
---|
277 | ;--------------------------------------------------------------------
|
---|
278 | ALIGN JUMP_ALIGN
|
---|
279 | .FormatFileOrDirectoryToBufferFromDTAinDSSI:
|
---|
280 | mov bp, sp
|
---|
281 | lea ax, [si+DTA.szFile]
|
---|
282 | push ax
|
---|
283 | push ds
|
---|
284 |
|
---|
285 | test BYTE [si+DTA.bFileAttributes], FLG_FILEATTR_DIRECTORY
|
---|
286 | jnz SHORT .FormatDirectory
|
---|
287 |
|
---|
288 | mov ax, [si+DTA.dwFileSize]
|
---|
289 | mov dx, [si+DTA.dwFileSize+2]
|
---|
290 | xor bx, bx
|
---|
291 | xor cx, cx
|
---|
292 | call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
|
---|
293 | mov cl, 'i'
|
---|
294 | cmp dl, ' '
|
---|
295 | eCMOVE cl, dl
|
---|
296 | push ax
|
---|
297 | push dx
|
---|
298 | push cx
|
---|
299 | mov si, g_szFileFormat
|
---|
300 | jmp SHORT .FormatStringInCSSIandReturn
|
---|
301 |
|
---|
302 | ALIGN JUMP_ALIGN
|
---|
303 | .FormatDirectory:
|
---|
304 | mov ax, g_szSub
|
---|
305 | cmp WORD [si+DTA.szFile], UPDIR_CHARACTERS
|
---|
306 | eCMOVE ax, g_szUp
|
---|
307 | push ax
|
---|
308 | mov si, g_szDirectoryFormat
|
---|
309 | ALIGN JUMP_ALIGN
|
---|
310 | .FormatStringInCSSIandReturn:
|
---|
311 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
312 | ret
|
---|
313 |
|
---|
314 | ;--------------------------------------------------------------------
|
---|
315 | ; .FilterCurrentDirectory
|
---|
316 | ; .FilterUpDirectoryWhenInRoot
|
---|
317 | ; Parameters:
|
---|
318 | ; DL: Zero if root directory selected
|
---|
319 | ; DS:SI: Ptr to DTA containing file information
|
---|
320 | ; Returns:
|
---|
321 | ; Nothing
|
---|
322 | ; Returns from AppendFileToBufferInESDIfromDtaInDSSI when filtering
|
---|
323 | ; Corrupts registers:
|
---|
324 | ; AX
|
---|
325 | ;--------------------------------------------------------------------
|
---|
326 | ALIGN JUMP_ALIGN
|
---|
327 | .FilterCurrentDirectory:
|
---|
328 | cmp WORD [si+DTA.szFile], CURRENTDIR_CHARACTERS
|
---|
329 | jne SHORT .ReturnWithoutFiltering
|
---|
330 | add sp, BYTE 2 ; Remove return address from stack
|
---|
331 | ret
|
---|
332 |
|
---|
333 | ALIGN JUMP_ALIGN
|
---|
334 | .FilterUpDirectoryWhenInRoot:
|
---|
335 | test dl, dl ; Set ZF if root directory selected
|
---|
336 | jnz SHORT .ReturnWithoutFiltering
|
---|
337 | cmp WORD [si+DTA.szFile], UPDIR_CHARACTERS
|
---|
338 | jne SHORT .ReturnWithoutFiltering
|
---|
339 | add sp, BYTE 2 ; Remove return address from stack
|
---|
340 | ALIGN JUMP_ALIGN, ret
|
---|
341 | .ReturnWithoutFiltering:
|
---|
342 | ret
|
---|
343 |
|
---|
344 |
|
---|
345 | ;--------------------------------------------------------------------
|
---|
346 | ; GetInfoLinesToCXandDialogFlagsToAX
|
---|
347 | ; Parameters:
|
---|
348 | ; SS:BP: Ptr to DIALOG
|
---|
349 | ; Returns:
|
---|
350 | ; AX: Dialog flags
|
---|
351 | ; CX: Number of info lines to be displayed
|
---|
352 | ; Corrupts registers:
|
---|
353 | ; SI, DS
|
---|
354 | ;--------------------------------------------------------------------
|
---|
355 | ALIGN JUMP_ALIGN
|
---|
356 | GetInfoLinesToCXandDialogFlagsToAX:
|
---|
357 | xor ax, ax
|
---|
358 | call GetDialogFlagsToAL
|
---|
359 | jmp Bit_GetSetCountToCXfromAX
|
---|
360 |
|
---|
361 | ;--------------------------------------------------------------------
|
---|
362 | ; GetDialogFlagsToAL
|
---|
363 | ; Parameters:
|
---|
364 | ; SS:BP: Ptr to DIALOG
|
---|
365 | ; Returns:
|
---|
366 | ; AL: Dialog flags
|
---|
367 | ; Corrupts registers:
|
---|
368 | ; SI, DS
|
---|
369 | ;--------------------------------------------------------------------
|
---|
370 | ALIGN JUMP_ALIGN
|
---|
371 | GetDialogFlagsToAL:
|
---|
372 | lds si, [bp+DIALOG.fpDialogIO]
|
---|
373 | mov al, [si+FILE_DIALOG_IO.bDialogFlags]
|
---|
374 | ret
|
---|
375 |
|
---|
376 |
|
---|
377 | ;--------------------------------------------------------------------
|
---|
378 | ; ParseSelectionFromItemLineInDSSI
|
---|
379 | ; Parameters:
|
---|
380 | ; DS:SI: Ptr to char buffer containing file or directory to be selected
|
---|
381 | ; SS:BP: Ptr to DIALOG
|
---|
382 | ; Returns:
|
---|
383 | ; Nothing
|
---|
384 | ; Corrupts registers:
|
---|
385 | ; All, except BP
|
---|
386 | ;--------------------------------------------------------------------
|
---|
387 | ALIGN JUMP_ALIGN
|
---|
388 | ParseSelectionFromItemLineInDSSI:
|
---|
389 | cmp BYTE [si], '['
|
---|
390 | je SHORT .ChangeToSubdirInDSSI
|
---|
391 | ; Fall to .SelectFileFromDSSI
|
---|
392 |
|
---|
393 | ;--------------------------------------------------------------------
|
---|
394 | ; .SelectFileFromDSSI
|
---|
395 | ; Parameters:
|
---|
396 | ; DS:SI: Ptr to char buffer containing file name to be selected
|
---|
397 | ; SS:BP: Ptr to DIALOG
|
---|
398 | ; Returns:
|
---|
399 | ; Nothing (exits dialog)
|
---|
400 | ; Corrupts registers:
|
---|
401 | ; All, except BP
|
---|
402 | ;--------------------------------------------------------------------
|
---|
403 | ;ALIGN JUMP_ALIGN
|
---|
404 | .SelectFileFromDSSI:
|
---|
405 | les di, [bp+DIALOG.fpDialogIO]
|
---|
406 | add di, BYTE FILE_DIALOG_IO.szFile
|
---|
407 | mov cx, FILENAME_BUFFER_SIZE-1
|
---|
408 | cld
|
---|
409 | rep movsb
|
---|
410 | xor ax, ax
|
---|
411 | stosb ; Terminate with NULL
|
---|
412 | jmp CloseFileDialogAfterSuccessfullSelection
|
---|
413 |
|
---|
414 | ;--------------------------------------------------------------------
|
---|
415 | ; ChangeToSubdirInDSSI
|
---|
416 | ; Parameters:
|
---|
417 | ; DS:SI: NULL terminated string containing new subdir in []
|
---|
418 | ; SS:BP: Ptr to DIALOG
|
---|
419 | ; Returns:
|
---|
420 | ; Nothing
|
---|
421 | ; Corrupts registers:
|
---|
422 | ; All, except BP
|
---|
423 | ;--------------------------------------------------------------------
|
---|
424 | ALIGN JUMP_ALIGN
|
---|
425 | .ChangeToSubdirInDSSI:
|
---|
426 | inc si ; Skip '['
|
---|
427 | mov BYTE [si+12], NULL ; Replace ']' with NULL
|
---|
428 | cmp WORD [si], UPDIR_CHARACTERS
|
---|
429 | eCMOVE si, g_szUpdir ; Real DOS do not accept spaces after ".."
|
---|
430 | call Directory_ChangeToPathFromDSSI
|
---|
431 | ; Fall to RefreshFilesToDisplay
|
---|
432 |
|
---|
433 | ;--------------------------------------------------------------------
|
---|
434 | ; RefreshFilesToDisplay
|
---|
435 | ; Parameters:
|
---|
436 | ; SS:BP: Ptr to DIALOG
|
---|
437 | ; Returns:
|
---|
438 | ; Nothing
|
---|
439 | ; Corrupts registers:
|
---|
440 | ; All, except BP
|
---|
441 | ;--------------------------------------------------------------------
|
---|
442 | ALIGN JUMP_ALIGN
|
---|
443 | RefreshFilesToDisplay:
|
---|
444 | call InitializeMenuinitFromSSBP
|
---|
445 | jmp MenuInit_RefreshMenuWindow
|
---|
446 |
|
---|
447 |
|
---|
448 | ;--------------------------------------------------------------------
|
---|
449 | ; HandleFunctionKeyFromAH
|
---|
450 | ; Parameters:
|
---|
451 | ; AH: Scancode for function key
|
---|
452 | ; SS:BP: Ptr to DIALOG
|
---|
453 | ; Returns:
|
---|
454 | ; Nothing
|
---|
455 | ; Corrupts registers:
|
---|
456 | ; AX, SI, DI, BP
|
---|
457 | ;--------------------------------------------------------------------
|
---|
458 | ALIGN JUMP_ALIGN
|
---|
459 | HandleFunctionKeyFromAH:
|
---|
460 | call GetDialogFlagsToAL
|
---|
461 | cmp ah, KEY_FILEDIALOG_NEW_FILE_OR_DIR
|
---|
462 | je SHORT HandleFunctionKeyForCreatingNewFileOrDirectory
|
---|
463 | cmp ah, KEY_FILEDIALOG_SELECT_DIRECTORY
|
---|
464 | je SHORT HandleFunctionKeyForSelectingDirectoryInsteadOfFile
|
---|
465 | cmp ah, KEY_FILEDIALOG_CHANGE_DRIVE
|
---|
466 | je SHORT HandleFunctionKeyForDriveChange
|
---|
467 | ReturnWithoutHandlingKeystroke:
|
---|
468 | clc ; Event not processed
|
---|
469 | ret
|
---|
470 |
|
---|
471 |
|
---|
472 | ;--------------------------------------------------------------------
|
---|
473 | ; HandleFunctionKeyForCreatingNewFileOrDirectory
|
---|
474 | ; Parameters:
|
---|
475 | ; AL: File dialog flags
|
---|
476 | ; SS:BP: Ptr to DIALOG
|
---|
477 | ; Returns:
|
---|
478 | ; Closes file dialog
|
---|
479 | ; Corrupts registers:
|
---|
480 | ; All, except BP
|
---|
481 | ;--------------------------------------------------------------------
|
---|
482 | ALIGN JUMP_ALIGN
|
---|
483 | HandleFunctionKeyForCreatingNewFileOrDirectory:
|
---|
484 | test al, FLG_FILEDIALOG_NEW
|
---|
485 | jz SHORT ReturnWithoutHandlingKeystroke
|
---|
486 |
|
---|
487 | mov cx, STRING_DIALOG_IO_size
|
---|
488 | call Memory_ReserveCXbytesFromStackToDSSI
|
---|
489 | call .InitializeStringDialogIoInDSSIforInputtingFileName
|
---|
490 |
|
---|
491 | CALL_MENU_LIBRARY GetStringWithIoInDSSI
|
---|
492 | mov al, [si+STRING_DIALOG_IO.bUserCancellation]
|
---|
493 | add sp, BYTE STRING_DIALOG_IO_size
|
---|
494 | test al, al ; User cancellation?
|
---|
495 | jnz SHORT ReturnWithoutHandlingKeystroke
|
---|
496 | jmp CloseFileDialogAfterSuccessfullSelection
|
---|
497 |
|
---|
498 | ALIGN JUMP_ALIGN
|
---|
499 | .InitializeStringDialogIoInDSSIforInputtingFileName:
|
---|
500 | call InitializeNullStringsToDialogInputInDSSI
|
---|
501 | mov WORD [si+DIALOG_INPUT.fszTitle], g_szEnterNewFileOrDirectory
|
---|
502 | mov WORD [si+STRING_DIALOG_IO.fnCharFilter], NULL
|
---|
503 | mov WORD [si+STRING_DIALOG_IO.wBufferSize], FILENAME_BUFFER_SIZE
|
---|
504 | les ax, [bp+DIALOG.fpDialogIO]
|
---|
505 | add ax, BYTE FILE_DIALOG_IO.szFile
|
---|
506 | mov [si+STRING_DIALOG_IO.fpReturnBuffer], ax
|
---|
507 | mov [si+STRING_DIALOG_IO.fpReturnBuffer+2], es
|
---|
508 | ret
|
---|
509 |
|
---|
510 |
|
---|
511 | ;--------------------------------------------------------------------
|
---|
512 | ; HandleFunctionKeyForSelectingDirectoryInsteadOfFile
|
---|
513 | ; Parameters:
|
---|
514 | ; AL: File dialog flags
|
---|
515 | ; SS:BP: Ptr to DIALOG
|
---|
516 | ; Returns:
|
---|
517 | ; Closes file dialog
|
---|
518 | ; Corrupts registers:
|
---|
519 | ; All, except BP
|
---|
520 | ;--------------------------------------------------------------------
|
---|
521 | ALIGN JUMP_ALIGN
|
---|
522 | HandleFunctionKeyForSelectingDirectoryInsteadOfFile:
|
---|
523 | test al, FLG_FILEDIALOG_DIRECTORY
|
---|
524 | jz SHORT ReturnWithoutHandlingKeystroke
|
---|
525 | ; Fall to CloseFileDialogAfterSuccessfullSelection
|
---|
526 |
|
---|
527 | ;--------------------------------------------------------------------
|
---|
528 | ; CloseFileDialogAfterSuccessfullSelection
|
---|
529 | ; Parameters:
|
---|
530 | ; SS:BP: Ptr to DIALOG
|
---|
531 | ; Returns:
|
---|
532 | ; Nothing (exits dialog)
|
---|
533 | ; Corrupts registers:
|
---|
534 | ; All, except BP
|
---|
535 | ;--------------------------------------------------------------------
|
---|
536 | ALIGN JUMP_ALIGN
|
---|
537 | CloseFileDialogAfterSuccessfullSelection:
|
---|
538 | lds di, [bp+DIALOG.fpDialogIO]
|
---|
539 | mov BYTE [di+FILE_DIALOG_IO.bUserCancellation], FALSE
|
---|
540 | jmp MenuInit_CloseMenuWindow
|
---|
541 |
|
---|
542 |
|
---|
543 | ;--------------------------------------------------------------------
|
---|
544 | ; HandleFunctionKeyForDriveChange
|
---|
545 | ; Parameters:
|
---|
546 | ; AL: File dialog flags
|
---|
547 | ; SS:BP: Ptr to DIALOG
|
---|
548 | ; Returns:
|
---|
549 | ; Nothing
|
---|
550 | ; Corrupts registers:
|
---|
551 | ; All, except BP
|
---|
552 | ;--------------------------------------------------------------------
|
---|
553 | ALIGN JUMP_ALIGN
|
---|
554 | HandleFunctionKeyForDriveChange:
|
---|
555 | test al, FLG_FILEDIALOG_DRIVES
|
---|
556 | jz SHORT ReturnWithoutHandlingKeystroke
|
---|
557 |
|
---|
558 | call .ShowDriveSelectionDialogAndGetDriveNumberToDL
|
---|
559 | jnc SHORT RefreshFilesToDisplay
|
---|
560 | call Drive_SetDefaultFromDL
|
---|
561 | jmp SHORT RefreshFilesToDisplay
|
---|
562 |
|
---|
563 | ;--------------------------------------------------------------------
|
---|
564 | ; .ShowDriveSelectionDialogAndGetDriveNumberToDL
|
---|
565 | ; Parameters:
|
---|
566 | ; SS:BP: Ptr to DIALOG
|
---|
567 | ; Returns:
|
---|
568 | ; DL: Drive selected by user
|
---|
569 | ; CF: Set if new drive selected
|
---|
570 | ; Cleared if selection cancelled by user
|
---|
571 | ; Corrupts registers:
|
---|
572 | ; All, except BP
|
---|
573 | ;--------------------------------------------------------------------
|
---|
574 | ALIGN JUMP_ALIGN
|
---|
575 | .ShowDriveSelectionDialogAndGetDriveNumberToDL:
|
---|
576 | mov cx, DIALOG_INPUT_size
|
---|
577 | call Memory_ReserveCXbytesFromStackToDSSI
|
---|
578 | call .InitializeDialogInputInDSSIforDriveSelection
|
---|
579 | call DialogSelection_GetSelectionToAXwithInputInDSSI
|
---|
580 | add sp, BYTE DIALOG_INPUT_size
|
---|
581 | cmp ax, BYTE NO_ITEM_SELECTED ; Clear CF if equal
|
---|
582 | jne SHORT .ConvertDriveNumberToDLfromItemIndexInAX
|
---|
583 | ret
|
---|
584 |
|
---|
585 | ALIGN JUMP_ALIGN
|
---|
586 | .InitializeDialogInputInDSSIforDriveSelection:
|
---|
587 | call InitializeNullStringsToDialogInputInDSSI
|
---|
588 | call LoadItemStringBufferToESDI
|
---|
589 | mov WORD [si+DIALOG_INPUT.fszTitle], g_szSelectNewDrive
|
---|
590 | mov [si+DIALOG_INPUT.fszItems], di
|
---|
591 | mov [si+DIALOG_INPUT.fszItems+2], es
|
---|
592 | call Drive_GetFlagsForAvailableDrivesToDXAX
|
---|
593 | ; Fall to .GenerateDriveSelectionStringToESDIfromDriveFlagsInDXAX
|
---|
594 |
|
---|
595 | ;--------------------------------------------------------------------
|
---|
596 | ; .GenerateDriveSelectionStringToESDIfromDriveFlagsInDXAX
|
---|
597 | ; Parameters:
|
---|
598 | ; DX:AX: Drive letter flags
|
---|
599 | ; ES:DI: Ptr to item string buffer
|
---|
600 | ; SS:BP: Ptr to DIALOG
|
---|
601 | ; Returns:
|
---|
602 | ; Nothing
|
---|
603 | ; Corrupts registers:
|
---|
604 | ; AX, BX, CX, DX, DI, ES
|
---|
605 | ;--------------------------------------------------------------------
|
---|
606 | ;ALIGN JUMP_ALIGN
|
---|
607 | .GenerateDriveSelectionStringToESDIfromDriveFlagsInDXAX:
|
---|
608 | cld
|
---|
609 | xchg cx, ax
|
---|
610 | mov ax, 3A41h ; A:
|
---|
611 | ALIGN JUMP_ALIGN
|
---|
612 | .BitShiftLoop:
|
---|
613 | shr dx, 1
|
---|
614 | rcr cx, 1
|
---|
615 | jnc SHORT .CheckIfMoreDrivesLeft
|
---|
616 | stosw
|
---|
617 | mov BYTE [es:di], LF
|
---|
618 | inc di
|
---|
619 | ALIGN JUMP_ALIGN
|
---|
620 | .CheckIfMoreDrivesLeft:
|
---|
621 | inc ax ; Next drive letter
|
---|
622 | mov bx, dx
|
---|
623 | or bx, cx
|
---|
624 | jnz SHORT .BitShiftLoop
|
---|
625 | jmp RemoveLastLFandTerminateESDIwithNull
|
---|
626 |
|
---|
627 | ;--------------------------------------------------------------------
|
---|
628 | ; .ConvertDriveNumberToDLfromItemIndexInAX
|
---|
629 | ; Parameters:
|
---|
630 | ; AX: Selected drive item
|
---|
631 | ; Returns:
|
---|
632 | ; DL: Drive number
|
---|
633 | ; CF: Set since drive selected
|
---|
634 | ; Corrupts registers:
|
---|
635 | ; AX, CX, DH
|
---|
636 | ;--------------------------------------------------------------------
|
---|
637 | ALIGN JUMP_ALIGN
|
---|
638 | .ConvertDriveNumberToDLfromItemIndexInAX:
|
---|
639 | mov ah, -1
|
---|
640 | xchg cx, ax
|
---|
641 | call Drive_GetFlagsForAvailableDrivesToDXAX
|
---|
642 | ALIGN JUMP_ALIGN
|
---|
643 | .BitScanLoop:
|
---|
644 | shr dx, 1
|
---|
645 | rcr ax, 1
|
---|
646 | inc ch ; Increment drive number
|
---|
647 | sbb cl, 0 ; Decrement selection index
|
---|
648 | jnc SHORT .BitScanLoop
|
---|
649 | mov dl, ch
|
---|
650 | stc ; Drive selected by user
|
---|
651 | ret
|
---|
652 |
|
---|
653 |
|
---|
654 | ;--------------------------------------------------------------------
|
---|
655 | ; InitializeNullStringsToDialogInputInDSSI
|
---|
656 | ; Parameters:
|
---|
657 | ; DS:SI: Ptr to DIALOG_INPUT
|
---|
658 | ; SS:BP: Ptr to DIALOG
|
---|
659 | ; Returns:
|
---|
660 | ; Nothing
|
---|
661 | ; Corrupts registers:
|
---|
662 | ; AX
|
---|
663 | ;--------------------------------------------------------------------
|
---|
664 | ALIGN JUMP_ALIGN
|
---|
665 | InitializeNullStringsToDialogInputInDSSI:
|
---|
666 | mov ax, g_szNull
|
---|
667 | mov [si+DIALOG_INPUT.fszTitle], ax
|
---|
668 | mov [si+DIALOG_INPUT.fszTitle+2], cs
|
---|
669 | mov [si+DIALOG_INPUT.fszItems], ax
|
---|
670 | mov [si+DIALOG_INPUT.fszItems+2], cs
|
---|
671 | mov [si+DIALOG_INPUT.fszInfo], ax
|
---|
672 | mov [si+DIALOG_INPUT.fszInfo+2], cs
|
---|
673 | ret
|
---|