1 | ; File name : DialogFile.asm
|
---|
2 | ; Project name : Assembly Library
|
---|
3 | ; Created date : 6.9.2010
|
---|
4 | ; Last update : 9.10.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 | call LoadItemStringBufferToESDI
|
---|
115 | call SortDirectoryContentsStringFromESDIwithCountInCX
|
---|
116 | call Memory_CopySSBPtoDSSI
|
---|
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 | xor ax, ax
|
---|
123 | mov [bp+MENU.wHighlightedItem], ax
|
---|
124 | mov [bp+MENU.wFirstVisibleItem], ax
|
---|
125 | ret
|
---|
126 |
|
---|
127 |
|
---|
128 | ;--------------------------------------------------------------------
|
---|
129 | ; LoadItemStringBufferToESDI
|
---|
130 | ; Parameters:
|
---|
131 | ; SS:BP: Ptr to DIALOG
|
---|
132 | ; Returns:
|
---|
133 | ; ES:DI: Ptr to item string buffer
|
---|
134 | ; Corrupts registers:
|
---|
135 | ; Nothing
|
---|
136 | ;--------------------------------------------------------------------
|
---|
137 | ALIGN JUMP_ALIGN
|
---|
138 | LoadItemStringBufferToESDI:
|
---|
139 | les di, [bp+DIALOG.fpDialogIO]
|
---|
140 | les di, [es:di+FILE_DIALOG_IO.fszItemBuffer]
|
---|
141 | ret
|
---|
142 |
|
---|
143 |
|
---|
144 | ;--------------------------------------------------------------------
|
---|
145 | ; CreateStringFromCurrentDirectoryContentsToESDI
|
---|
146 | ; Parameters:
|
---|
147 | ; ES:DI: Buffer where to create item string
|
---|
148 | ; SS:BP: Ptr to DIALOG
|
---|
149 | ; Returns:
|
---|
150 | ; CX: Number of files or directories found
|
---|
151 | ; Corrupts registers:
|
---|
152 | ; AX, DX, SI, DI, DS, ES
|
---|
153 | ;--------------------------------------------------------------------
|
---|
154 | ALIGN JUMP_ALIGN
|
---|
155 | CreateStringFromCurrentDirectoryContentsToESDI:
|
---|
156 | lds si, [bp+DIALOG.fpDialogIO]
|
---|
157 | eMOVZX cx, BYTE [si+FILE_DIALOG_IO.bFileAttributes]
|
---|
158 | lds si, [si+FILE_DIALOG_IO.fpFileFilterString]
|
---|
159 | call Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX
|
---|
160 | rcr cx, 1 ; Store CF
|
---|
161 | call .ClearDLifInRootDirectory
|
---|
162 | call Directory_GetDiskTransferAreaAddressToDSSI
|
---|
163 | rcl cx, 1 ; Restore CF
|
---|
164 | xor cx, cx ; Clear file/directory count
|
---|
165 | ; Fall to .FindMatchingFilesAndWriteThemToESDI
|
---|
166 |
|
---|
167 | ;--------------------------------------------------------------------
|
---|
168 | ; .FindMatchingFilesAndWriteThemToESDI
|
---|
169 | ; Parameters:
|
---|
170 | ; CX: Initial directory count
|
---|
171 | ; DL: Zero if root directory selected
|
---|
172 | ; DS:SI: Ptr to DTA with first matching file
|
---|
173 | ; ES:DI: Ptr to destination string buffer
|
---|
174 | ; Returns:
|
---|
175 | ; CX: Incremented by number of files/directories found
|
---|
176 | ; Corrupts registers:
|
---|
177 | ; AX, DX, DI
|
---|
178 | ;--------------------------------------------------------------------
|
---|
179 | ;ALIGN JUMP_ALIGN
|
---|
180 | .FindMatchingFilesAndWriteThemToESDI:
|
---|
181 | jc SHORT TerminateESDIwithNull
|
---|
182 | call AppendFileToBufferInESDIfromDtaInDSSI
|
---|
183 | call Directory_UpdateDTAForNextMatchUsingPreviousParameters
|
---|
184 | jmp SHORT .FindMatchingFilesAndWriteThemToESDI
|
---|
185 |
|
---|
186 | ;--------------------------------------------------------------------
|
---|
187 | ; .ClearDLifInRootDirectory
|
---|
188 | ; Parameters:
|
---|
189 | ; SS:BP: Ptr to DIALOG
|
---|
190 | ; ES:DI: Ptr to destination string buffer
|
---|
191 | ; Returns:
|
---|
192 | ; DL: Cleared if in root directory
|
---|
193 | ; Set if in any other directory
|
---|
194 | ; Corrupts registers:
|
---|
195 | ; AX, SI, DS
|
---|
196 | ;--------------------------------------------------------------------
|
---|
197 | ALIGN JUMP_ALIGN
|
---|
198 | .ClearDLifInRootDirectory:
|
---|
199 | call Memory_CopyESDItoDSSI
|
---|
200 | call Directory_WriteCurrentPathToDSSI
|
---|
201 | mov dl, [si]
|
---|
202 | ret
|
---|
203 |
|
---|
204 |
|
---|
205 | ;--------------------------------------------------------------------
|
---|
206 | ; TerminateESDIwithNull
|
---|
207 | ; Parameters:
|
---|
208 | ; ES:DI: Ptr to destination string buffer
|
---|
209 | ; Returns:
|
---|
210 | ; Nothing
|
---|
211 | ; Corrupts registers:
|
---|
212 | ; AX
|
---|
213 | ;--------------------------------------------------------------------
|
---|
214 | ALIGN JUMP_ALIGN
|
---|
215 | TerminateESDIwithNull:
|
---|
216 | xor ax, ax
|
---|
217 | stosb
|
---|
218 | ret
|
---|
219 |
|
---|
220 |
|
---|
221 | ;--------------------------------------------------------------------
|
---|
222 | ; AppendFileToBufferInESDIfromDtaInDSSI
|
---|
223 | ; Parameters:
|
---|
224 | ; CX: Files/directores found
|
---|
225 | ; DL: Zero if root directory selected
|
---|
226 | ; DS:SI: Ptr to DTA containing file information
|
---|
227 | ; ES:DI: Ptr to destination string buffer
|
---|
228 | ; Returns:
|
---|
229 | ; CX: Incremented by number of files/directories found
|
---|
230 | ; DI: Updated for next file
|
---|
231 | ; Corrupts registers:
|
---|
232 | ; AX, BX, DX
|
---|
233 | ;--------------------------------------------------------------------
|
---|
234 | ALIGN JUMP_ALIGN
|
---|
235 | AppendFileToBufferInESDIfromDtaInDSSI:
|
---|
236 | call .FilterCurrentDirectory ; We never want "."
|
---|
237 | call .FilterUpDirectoryWhenInRoot ; No ".." when in root directory
|
---|
238 | inc cx ; Nothing filtered so increment files/directories
|
---|
239 | ; Fall to .PrepareBufferFormattingAndFormatFromDTAinDSSI
|
---|
240 |
|
---|
241 | ;--------------------------------------------------------------------
|
---|
242 | ; .PrepareBufferFormattingAndFormatFromDTAinDSSI
|
---|
243 | ; Parameters:
|
---|
244 | ; DS:SI: Ptr to DTA containing file information
|
---|
245 | ; ES:DI: Ptr to destination string buffer
|
---|
246 | ; Returns:
|
---|
247 | ; DI: Updated for next file
|
---|
248 | ; Corrupts registers:
|
---|
249 | ; AX, BX, DX
|
---|
250 | ;--------------------------------------------------------------------
|
---|
251 | ;ALIGN JUMP_ALIGN
|
---|
252 | .PrepareBufferFormattingAndFormatFromDTAinDSSI:
|
---|
253 | push bp
|
---|
254 | push si
|
---|
255 | push cx
|
---|
256 | mov bx, di
|
---|
257 | CALL_DISPLAY_LIBRARY PushDisplayContext
|
---|
258 | CALL_DISPLAY_LIBRARY PrepareOffScreenBufferInESBXtoESDI
|
---|
259 |
|
---|
260 | call .FormatFileOrDirectoryToBufferFromDTAinDSSI
|
---|
261 |
|
---|
262 | CALL_DISPLAY_LIBRARY GetCharacterPointerToBXAX
|
---|
263 | xchg bx, ax
|
---|
264 | CALL_DISPLAY_LIBRARY PopDisplayContext
|
---|
265 | mov di, bx
|
---|
266 | pop cx
|
---|
267 | pop si
|
---|
268 | pop bp
|
---|
269 | ret
|
---|
270 |
|
---|
271 | ;--------------------------------------------------------------------
|
---|
272 | ; .FormatFileOrDirectoryToBufferFromDTAinDSSI
|
---|
273 | ; Parameters:
|
---|
274 | ; DS:SI: Ptr to DTA containing file information
|
---|
275 | ; Returns:
|
---|
276 | ; Nothing
|
---|
277 | ; Corrupts registers:
|
---|
278 | ; AX, BX, CX, DX, SI, DI, BP
|
---|
279 | ;--------------------------------------------------------------------
|
---|
280 | ALIGN JUMP_ALIGN
|
---|
281 | .FormatFileOrDirectoryToBufferFromDTAinDSSI:
|
---|
282 | mov bp, sp
|
---|
283 | lea ax, [si+DTA.szFile]
|
---|
284 |
|
---|
285 | test BYTE [si+DTA.bFileAttributes], FLG_FILEATTR_DIRECTORY
|
---|
286 | jnz SHORT .FormatDirectory
|
---|
287 | ; Fall to .FormatFile
|
---|
288 |
|
---|
289 | ;--------------------------------------------------------------------
|
---|
290 | ; .FormatFile
|
---|
291 | ; Parameters:
|
---|
292 | ; BP: SP before pushing formatting parameters
|
---|
293 | ; DS:AX: Far pointer to file name
|
---|
294 | ; DS:SI: Ptr to DTA containing file information
|
---|
295 | ; Returns:
|
---|
296 | ; Nothing
|
---|
297 | ; Corrupts registers:
|
---|
298 | ; AX, BX, CX, DX, SI, DI, BP
|
---|
299 | ;--------------------------------------------------------------------
|
---|
300 | .FormatFile:
|
---|
301 | ; Push parameters for file name
|
---|
302 | xchg si, ax
|
---|
303 | call String_ConvertDSSItoLowerCase
|
---|
304 | xchg ax, si
|
---|
305 | push ax ; Push directory name offset
|
---|
306 | push ds ; Push directory name segment
|
---|
307 |
|
---|
308 | ; Push parameters for file size
|
---|
309 | mov ax, [si+DTA.dwFileSize]
|
---|
310 | mov dx, [si+DTA.dwFileSize+2]
|
---|
311 | xor bx, bx
|
---|
312 | xor cx, cx
|
---|
313 | call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
|
---|
314 | mov cl, 'i'
|
---|
315 | cmp dl, ' '
|
---|
316 | eCMOVE cl, dl
|
---|
317 | push ax
|
---|
318 | push dx
|
---|
319 | push cx
|
---|
320 |
|
---|
321 | ; Format to buffer
|
---|
322 | mov si, g_szFileFormat
|
---|
323 | jmp SHORT .FormatStringInCSSIandReturn
|
---|
324 |
|
---|
325 | ;--------------------------------------------------------------------
|
---|
326 | ; .FormatDirectory
|
---|
327 | ; Parameters:
|
---|
328 | ; BP: SP before pushing formatting parameters
|
---|
329 | ; DS:AX: Far pointer to directory name
|
---|
330 | ; DS:SI: Ptr to DTA containing file information
|
---|
331 | ; Returns:
|
---|
332 | ; Nothing
|
---|
333 | ; Corrupts registers:
|
---|
334 | ; AX, BX, CX, DX, SI, DI, BP
|
---|
335 | ;--------------------------------------------------------------------
|
---|
336 | ALIGN JUMP_ALIGN
|
---|
337 | .FormatDirectory:
|
---|
338 | push ax ; Push directory name offset
|
---|
339 | push ds ; Push directory name segment
|
---|
340 | mov ax, g_szSub
|
---|
341 | cmp WORD [si+DTA.szFile], UPDIR_CHARACTERS
|
---|
342 | eCMOVE ax, g_szUp
|
---|
343 | push ax
|
---|
344 | mov si, g_szDirectoryFormat
|
---|
345 | ALIGN JUMP_ALIGN
|
---|
346 | .FormatStringInCSSIandReturn:
|
---|
347 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
348 | ret
|
---|
349 |
|
---|
350 | ;--------------------------------------------------------------------
|
---|
351 | ; .FilterCurrentDirectory
|
---|
352 | ; .FilterUpDirectoryWhenInRoot
|
---|
353 | ; Parameters:
|
---|
354 | ; DL: Zero if root directory selected
|
---|
355 | ; DS:SI: Ptr to DTA containing file information
|
---|
356 | ; Returns:
|
---|
357 | ; Nothing
|
---|
358 | ; Returns from AppendFileToBufferInESDIfromDtaInDSSI when filtering
|
---|
359 | ; Corrupts registers:
|
---|
360 | ; AX
|
---|
361 | ;--------------------------------------------------------------------
|
---|
362 | ALIGN JUMP_ALIGN
|
---|
363 | .FilterCurrentDirectory:
|
---|
364 | cmp WORD [si+DTA.szFile], CURRENTDIR_CHARACTERS
|
---|
365 | jne SHORT .ReturnWithoutFiltering
|
---|
366 | add sp, BYTE 2 ; Remove return address from stack
|
---|
367 | ret
|
---|
368 |
|
---|
369 | ALIGN JUMP_ALIGN
|
---|
370 | .FilterUpDirectoryWhenInRoot:
|
---|
371 | test dl, dl ; Set ZF if root directory selected
|
---|
372 | jnz SHORT .ReturnWithoutFiltering
|
---|
373 | cmp WORD [si+DTA.szFile], UPDIR_CHARACTERS
|
---|
374 | jne SHORT .ReturnWithoutFiltering
|
---|
375 | add sp, BYTE 2 ; Remove return address from stack
|
---|
376 | ALIGN JUMP_ALIGN, ret
|
---|
377 | .ReturnWithoutFiltering:
|
---|
378 | ret
|
---|
379 |
|
---|
380 |
|
---|
381 | ;--------------------------------------------------------------------
|
---|
382 | ; SortDirectoryContentsStringFromESDIwithCountInCX
|
---|
383 | ; Parameters:
|
---|
384 | ; CX: Number of files and directories
|
---|
385 | ; ES:DI: Buffer containing directory contents string
|
---|
386 | ; SS:BP: Ptr to DIALOG
|
---|
387 | ; Returns:
|
---|
388 | ; Nothing
|
---|
389 | ; Corrupts registers:
|
---|
390 | ; AX, BX, CX, DX, SI, DI, DS, ES
|
---|
391 | ;--------------------------------------------------------------------
|
---|
392 | ALIGN JUMP_ALIGN
|
---|
393 | SortDirectoryContentsStringFromESDIwithCountInCX:
|
---|
394 | call Memory_ExchangeDSSIwithESDI
|
---|
395 | mov bx, .FileStringComparator
|
---|
396 | xchg dx, cx
|
---|
397 | mov cx, FILE_STRING_LENGTH
|
---|
398 | jmp Sort_ItemsFromDSSIwithCountInDXsizeInCXandComparatorInBX
|
---|
399 |
|
---|
400 | ;--------------------------------------------------------------------
|
---|
401 | ; .FileStringComparator
|
---|
402 | ; Parameters:
|
---|
403 | ; CX: Item size in bytes
|
---|
404 | ; DS:SI: Ptr to first item to compare
|
---|
405 | ; ES:DI: Ptr to second item to compare
|
---|
406 | ; Returns:
|
---|
407 | ; FLAGS: Signed comparition between first and second item
|
---|
408 | ; Corrupts registers:
|
---|
409 | ; Nothing
|
---|
410 | ;--------------------------------------------------------------------
|
---|
411 | ALIGN JUMP_ALIGN
|
---|
412 | .FileStringComparator:
|
---|
413 | push di
|
---|
414 | push si
|
---|
415 | push cx
|
---|
416 | push bx
|
---|
417 |
|
---|
418 | mov bx, FILE_STRING_LENGTH-2 ; Zero BH
|
---|
419 | cmp WORD [si], UPDIR_CHARACTERS
|
---|
420 | je SHORT .ForceValueFromDSSItoBeLess
|
---|
421 | mov bl, [si+bx]
|
---|
422 | cmp bl, [es:di+FILE_STRING_LENGTH-2] ; 'B' for files, 'R' for directories
|
---|
423 | jne SHORT .ForceValueFromDSSItoBeMoreOrLess
|
---|
424 | repe cmpsb ; Two directories or two files
|
---|
425 |
|
---|
426 | ALIGN JUMP_ALIGN
|
---|
427 | .ReturnFromComparison:
|
---|
428 | pop bx
|
---|
429 | pop cx
|
---|
430 | pop si
|
---|
431 | pop di
|
---|
432 | ret
|
---|
433 | ALIGN JUMP_ALIGN
|
---|
434 | .ForceValueFromDSSItoBeMoreOrLess:
|
---|
435 | ja SHORT .ForceValueFromDSSItoBeLess ; Directory in SI, file in DI
|
---|
436 | xchg bl, bh
|
---|
437 | ; Fall to ForceValueFromDSSItoBeLess
|
---|
438 | ALIGN JUMP_ALIGN
|
---|
439 | .ForceValueFromDSSItoBeLess:
|
---|
440 | cmp bh, bl
|
---|
441 | jmp SHORT .ReturnFromComparison
|
---|
442 |
|
---|
443 |
|
---|
444 | ;--------------------------------------------------------------------
|
---|
445 | ; GetInfoLinesToCXandDialogFlagsToAX
|
---|
446 | ; Parameters:
|
---|
447 | ; SS:BP: Ptr to DIALOG
|
---|
448 | ; Returns:
|
---|
449 | ; AX: Dialog flags
|
---|
450 | ; CX: Number of info lines to be displayed
|
---|
451 | ; Corrupts registers:
|
---|
452 | ; SI, DS
|
---|
453 | ;--------------------------------------------------------------------
|
---|
454 | ALIGN JUMP_ALIGN
|
---|
455 | GetInfoLinesToCXandDialogFlagsToAX:
|
---|
456 | xor ax, ax
|
---|
457 | call GetDialogFlagsToAL
|
---|
458 | jmp Bit_GetSetCountToCXfromAX
|
---|
459 |
|
---|
460 | ;--------------------------------------------------------------------
|
---|
461 | ; GetDialogFlagsToAL
|
---|
462 | ; Parameters:
|
---|
463 | ; SS:BP: Ptr to DIALOG
|
---|
464 | ; Returns:
|
---|
465 | ; AL: Dialog flags
|
---|
466 | ; Corrupts registers:
|
---|
467 | ; SI, DS
|
---|
468 | ;--------------------------------------------------------------------
|
---|
469 | ALIGN JUMP_ALIGN
|
---|
470 | GetDialogFlagsToAL:
|
---|
471 | lds si, [bp+DIALOG.fpDialogIO]
|
---|
472 | mov al, [si+FILE_DIALOG_IO.bDialogFlags]
|
---|
473 | ret
|
---|
474 |
|
---|
475 |
|
---|
476 | ;--------------------------------------------------------------------
|
---|
477 | ; ParseSelectionFromItemLineInDSSI
|
---|
478 | ; Parameters:
|
---|
479 | ; DS:SI: Ptr to char buffer containing file or directory to be selected
|
---|
480 | ; SS:BP: Ptr to DIALOG
|
---|
481 | ; Returns:
|
---|
482 | ; Nothing
|
---|
483 | ; Corrupts registers:
|
---|
484 | ; All, except BP
|
---|
485 | ;--------------------------------------------------------------------
|
---|
486 | ALIGN JUMP_ALIGN
|
---|
487 | ParseSelectionFromItemLineInDSSI:
|
---|
488 | mov ax, [si]
|
---|
489 | cmp ax, UPDIR_CHARACTERS
|
---|
490 | je SHORT .ChangeToUpdir
|
---|
491 | call Char_IsUpperCaseLetterInAL
|
---|
492 | jc SHORT .ParseAndChangeToSubdirInDSSI
|
---|
493 | ; Fall to .ParseAndSelectFileFromDSSI
|
---|
494 |
|
---|
495 | ;--------------------------------------------------------------------
|
---|
496 | ; .ParseAndSelectFileFromDSSI
|
---|
497 | ; Parameters:
|
---|
498 | ; DS:SI: NULL terminated string selected from dialog
|
---|
499 | ; SS:BP: Ptr to DIALOG
|
---|
500 | ; Returns:
|
---|
501 | ; Nothing (exits dialog)
|
---|
502 | ; Corrupts registers:
|
---|
503 | ; All, except BP
|
---|
504 | ;--------------------------------------------------------------------
|
---|
505 | .ParseAndSelectFileFromDSSI:
|
---|
506 | les di, [bp+DIALOG.fpDialogIO]
|
---|
507 | add di, BYTE FILE_DIALOG_IO.szFile
|
---|
508 | mov cx, FILENAME_BUFFER_SIZE-1
|
---|
509 | call Memory_CopyCXbytesFromDSSItoESDI
|
---|
510 | xor ax, ax
|
---|
511 | stosb ; Terminate with NULL
|
---|
512 | jmp SHORT CloseFileDialogAfterSuccessfullSelection
|
---|
513 |
|
---|
514 | ;--------------------------------------------------------------------
|
---|
515 | ; .ChangeToUpdir
|
---|
516 | ; Parameters:
|
---|
517 | ; SS:BP: Ptr to DIALOG
|
---|
518 | ; Returns:
|
---|
519 | ; Nothing
|
---|
520 | ; Corrupts registers:
|
---|
521 | ; All, except BP
|
---|
522 | ;--------------------------------------------------------------------
|
---|
523 | ALIGN JUMP_ALIGN
|
---|
524 | .ChangeToUpdir:
|
---|
525 | mov si, g_szUpdir
|
---|
526 | jmp SHORT .ChangeDirectoryToDSSI
|
---|
527 |
|
---|
528 | ;--------------------------------------------------------------------
|
---|
529 | ; .ParseAndChangeToSubdirInDSSI
|
---|
530 | ; Parameters:
|
---|
531 | ; DS:SI: NULL terminated string selected from dialog
|
---|
532 | ; SS:BP: Ptr to DIALOG
|
---|
533 | ; Returns:
|
---|
534 | ; Nothing
|
---|
535 | ; Corrupts registers:
|
---|
536 | ; All, except BP
|
---|
537 | ;--------------------------------------------------------------------
|
---|
538 | ALIGN JUMP_ALIGN
|
---|
539 | .ParseAndChangeToSubdirInDSSI:
|
---|
540 | mov BYTE [si+12], NULL ; Terminate with NULL (unnecessary spaces do not matter)
|
---|
541 | .ChangeDirectoryToDSSI:
|
---|
542 | call Directory_ChangeToPathFromDSSI
|
---|
543 | ; Fall to RefreshFilesToDisplay
|
---|
544 |
|
---|
545 | ;--------------------------------------------------------------------
|
---|
546 | ; RefreshFilesToDisplay
|
---|
547 | ; Parameters:
|
---|
548 | ; SS:BP: Ptr to DIALOG
|
---|
549 | ; Returns:
|
---|
550 | ; Nothing
|
---|
551 | ; Corrupts registers:
|
---|
552 | ; All, except BP
|
---|
553 | ;--------------------------------------------------------------------
|
---|
554 | ALIGN JUMP_ALIGN
|
---|
555 | RefreshFilesToDisplay:
|
---|
556 | call InitializeMenuinitFromSSBP
|
---|
557 | jmp MenuInit_RefreshMenuWindow
|
---|
558 |
|
---|
559 |
|
---|
560 | ;--------------------------------------------------------------------
|
---|
561 | ; HandleFunctionKeyFromAH
|
---|
562 | ; Parameters:
|
---|
563 | ; AH: Scancode for function key
|
---|
564 | ; SS:BP: Ptr to DIALOG
|
---|
565 | ; Returns:
|
---|
566 | ; Nothing
|
---|
567 | ; Corrupts registers:
|
---|
568 | ; AX, SI, DI, BP
|
---|
569 | ;--------------------------------------------------------------------
|
---|
570 | ALIGN JUMP_ALIGN
|
---|
571 | HandleFunctionKeyFromAH:
|
---|
572 | call GetDialogFlagsToAL
|
---|
573 | cmp ah, KEY_FILEDIALOG_NEW_FILE_OR_DIR
|
---|
574 | je SHORT HandleFunctionKeyForCreatingNewFileOrDirectory
|
---|
575 | cmp ah, KEY_FILEDIALOG_SELECT_DIRECTORY
|
---|
576 | je SHORT HandleFunctionKeyForSelectingDirectoryInsteadOfFile
|
---|
577 | cmp ah, KEY_FILEDIALOG_CHANGE_DRIVE
|
---|
578 | je SHORT HandleFunctionKeyForDriveChange
|
---|
579 | ReturnWithoutHandlingKeystroke:
|
---|
580 | clc ; Event not processed
|
---|
581 | ret
|
---|
582 |
|
---|
583 |
|
---|
584 | ;--------------------------------------------------------------------
|
---|
585 | ; HandleFunctionKeyForCreatingNewFileOrDirectory
|
---|
586 | ; Parameters:
|
---|
587 | ; AL: File dialog flags
|
---|
588 | ; SS:BP: Ptr to DIALOG
|
---|
589 | ; Returns:
|
---|
590 | ; Closes file dialog
|
---|
591 | ; Corrupts registers:
|
---|
592 | ; All, except BP
|
---|
593 | ;--------------------------------------------------------------------
|
---|
594 | ALIGN JUMP_ALIGN
|
---|
595 | HandleFunctionKeyForCreatingNewFileOrDirectory:
|
---|
596 | test al, FLG_FILEDIALOG_NEW
|
---|
597 | jz SHORT ReturnWithoutHandlingKeystroke
|
---|
598 |
|
---|
599 | mov cx, STRING_DIALOG_IO_size
|
---|
600 | call Memory_ReserveCXbytesFromStackToDSSI
|
---|
601 | call .InitializeStringDialogIoInDSSIforInputtingFileName
|
---|
602 |
|
---|
603 | CALL_MENU_LIBRARY GetStringWithIoInDSSI
|
---|
604 | mov al, [si+STRING_DIALOG_IO.bUserCancellation]
|
---|
605 | add sp, BYTE STRING_DIALOG_IO_size
|
---|
606 | test al, al ; User cancellation?
|
---|
607 | jnz SHORT ReturnWithoutHandlingKeystroke
|
---|
608 | jmp CloseFileDialogAfterSuccessfullSelection
|
---|
609 |
|
---|
610 | ALIGN JUMP_ALIGN
|
---|
611 | .InitializeStringDialogIoInDSSIforInputtingFileName:
|
---|
612 | call InitializeNullStringsToDialogInputInDSSI
|
---|
613 | mov WORD [si+DIALOG_INPUT.fszTitle], g_szEnterNewFileOrDirectory
|
---|
614 | mov WORD [si+STRING_DIALOG_IO.fnCharFilter], NULL
|
---|
615 | mov WORD [si+STRING_DIALOG_IO.wBufferSize], FILENAME_BUFFER_SIZE
|
---|
616 | les ax, [bp+DIALOG.fpDialogIO]
|
---|
617 | add ax, BYTE FILE_DIALOG_IO.szFile
|
---|
618 | mov [si+STRING_DIALOG_IO.fpReturnBuffer], ax
|
---|
619 | mov [si+STRING_DIALOG_IO.fpReturnBuffer+2], es
|
---|
620 | ret
|
---|
621 |
|
---|
622 |
|
---|
623 | ;--------------------------------------------------------------------
|
---|
624 | ; HandleFunctionKeyForSelectingDirectoryInsteadOfFile
|
---|
625 | ; Parameters:
|
---|
626 | ; AL: File dialog flags
|
---|
627 | ; SS:BP: Ptr to DIALOG
|
---|
628 | ; Returns:
|
---|
629 | ; Closes file dialog
|
---|
630 | ; Corrupts registers:
|
---|
631 | ; All, except BP
|
---|
632 | ;--------------------------------------------------------------------
|
---|
633 | ALIGN JUMP_ALIGN
|
---|
634 | HandleFunctionKeyForSelectingDirectoryInsteadOfFile:
|
---|
635 | test al, FLG_FILEDIALOG_DIRECTORY
|
---|
636 | jz SHORT ReturnWithoutHandlingKeystroke
|
---|
637 | ; Fall to CloseFileDialogAfterSuccessfullSelection
|
---|
638 |
|
---|
639 | ;--------------------------------------------------------------------
|
---|
640 | ; CloseFileDialogAfterSuccessfullSelection
|
---|
641 | ; Parameters:
|
---|
642 | ; SS:BP: Ptr to DIALOG
|
---|
643 | ; Returns:
|
---|
644 | ; Nothing (exits dialog)
|
---|
645 | ; Corrupts registers:
|
---|
646 | ; All, except BP
|
---|
647 | ;--------------------------------------------------------------------
|
---|
648 | ALIGN JUMP_ALIGN
|
---|
649 | CloseFileDialogAfterSuccessfullSelection:
|
---|
650 | lds di, [bp+DIALOG.fpDialogIO]
|
---|
651 | mov BYTE [di+FILE_DIALOG_IO.bUserCancellation], FALSE
|
---|
652 | jmp MenuInit_CloseMenuWindow
|
---|
653 |
|
---|
654 |
|
---|
655 | ;--------------------------------------------------------------------
|
---|
656 | ; HandleFunctionKeyForDriveChange
|
---|
657 | ; Parameters:
|
---|
658 | ; AL: File dialog flags
|
---|
659 | ; SS:BP: Ptr to DIALOG
|
---|
660 | ; Returns:
|
---|
661 | ; Nothing
|
---|
662 | ; Corrupts registers:
|
---|
663 | ; All, except BP
|
---|
664 | ;--------------------------------------------------------------------
|
---|
665 | ALIGN JUMP_ALIGN
|
---|
666 | HandleFunctionKeyForDriveChange:
|
---|
667 | test al, FLG_FILEDIALOG_DRIVES
|
---|
668 | jz SHORT ReturnWithoutHandlingKeystroke
|
---|
669 |
|
---|
670 | call .ShowDriveSelectionDialogAndGetDriveNumberToDL
|
---|
671 | jnc SHORT RefreshFilesToDisplay
|
---|
672 | call Drive_SetDefaultFromDL
|
---|
673 | jmp SHORT RefreshFilesToDisplay
|
---|
674 |
|
---|
675 | ;--------------------------------------------------------------------
|
---|
676 | ; .ShowDriveSelectionDialogAndGetDriveNumberToDL
|
---|
677 | ; Parameters:
|
---|
678 | ; SS:BP: Ptr to DIALOG
|
---|
679 | ; Returns:
|
---|
680 | ; DL: Drive selected by user
|
---|
681 | ; CF: Set if new drive selected
|
---|
682 | ; Cleared if selection cancelled by user
|
---|
683 | ; Corrupts registers:
|
---|
684 | ; All, except BP
|
---|
685 | ;--------------------------------------------------------------------
|
---|
686 | ALIGN JUMP_ALIGN
|
---|
687 | .ShowDriveSelectionDialogAndGetDriveNumberToDL:
|
---|
688 | mov cx, DIALOG_INPUT_size
|
---|
689 | call Memory_ReserveCXbytesFromStackToDSSI
|
---|
690 | call .InitializeDialogInputInDSSIforDriveSelection
|
---|
691 | call DialogSelection_GetSelectionToAXwithInputInDSSI
|
---|
692 | add sp, BYTE DIALOG_INPUT_size
|
---|
693 | cmp ax, BYTE NO_ITEM_SELECTED ; Clear CF if equal
|
---|
694 | jne SHORT .ConvertDriveNumberToDLfromItemIndexInAX
|
---|
695 | ret
|
---|
696 |
|
---|
697 | ALIGN JUMP_ALIGN
|
---|
698 | .InitializeDialogInputInDSSIforDriveSelection:
|
---|
699 | call InitializeNullStringsToDialogInputInDSSI
|
---|
700 | call LoadItemStringBufferToESDI
|
---|
701 | mov WORD [si+DIALOG_INPUT.fszTitle], g_szSelectNewDrive
|
---|
702 | mov [si+DIALOG_INPUT.fszItems], di
|
---|
703 | mov [si+DIALOG_INPUT.fszItems+2], es
|
---|
704 | call Drive_GetFlagsForAvailableDrivesToDXAX
|
---|
705 | ; Fall to .GenerateDriveSelectionStringToESDIfromDriveFlagsInDXAX
|
---|
706 |
|
---|
707 | ;--------------------------------------------------------------------
|
---|
708 | ; .GenerateDriveSelectionStringToESDIfromDriveFlagsInDXAX
|
---|
709 | ; Parameters:
|
---|
710 | ; DX:AX: Drive letter flags
|
---|
711 | ; ES:DI: Ptr to item string buffer
|
---|
712 | ; SS:BP: Ptr to DIALOG
|
---|
713 | ; Returns:
|
---|
714 | ; Nothing
|
---|
715 | ; Corrupts registers:
|
---|
716 | ; AX, BX, CX, DX, DI, ES
|
---|
717 | ;--------------------------------------------------------------------
|
---|
718 | ;ALIGN JUMP_ALIGN
|
---|
719 | .GenerateDriveSelectionStringToESDIfromDriveFlagsInDXAX:
|
---|
720 | cld
|
---|
721 | xchg cx, ax
|
---|
722 | mov ax, 3A41h ; A:
|
---|
723 | ALIGN JUMP_ALIGN
|
---|
724 | .BitShiftLoop:
|
---|
725 | shr dx, 1
|
---|
726 | rcr cx, 1
|
---|
727 | jnc SHORT .CheckIfMoreDrivesLeft
|
---|
728 | stosw
|
---|
729 | mov BYTE [es:di], LF
|
---|
730 | inc di
|
---|
731 | ALIGN JUMP_ALIGN
|
---|
732 | .CheckIfMoreDrivesLeft:
|
---|
733 | inc ax ; Next drive letter
|
---|
734 | mov bx, dx
|
---|
735 | or bx, cx
|
---|
736 | jnz SHORT .BitShiftLoop
|
---|
737 | jmp TerminateESDIwithNull
|
---|
738 |
|
---|
739 | ;--------------------------------------------------------------------
|
---|
740 | ; .ConvertDriveNumberToDLfromItemIndexInAX
|
---|
741 | ; Parameters:
|
---|
742 | ; AX: Selected drive item
|
---|
743 | ; Returns:
|
---|
744 | ; DL: Drive number
|
---|
745 | ; CF: Set since drive selected
|
---|
746 | ; Corrupts registers:
|
---|
747 | ; AX, CX, DH
|
---|
748 | ;--------------------------------------------------------------------
|
---|
749 | ALIGN JUMP_ALIGN
|
---|
750 | .ConvertDriveNumberToDLfromItemIndexInAX:
|
---|
751 | mov ah, -1
|
---|
752 | xchg cx, ax
|
---|
753 | call Drive_GetFlagsForAvailableDrivesToDXAX
|
---|
754 | ALIGN JUMP_ALIGN
|
---|
755 | .BitScanLoop:
|
---|
756 | shr dx, 1
|
---|
757 | rcr ax, 1
|
---|
758 | inc ch ; Increment drive number
|
---|
759 | sbb cl, 0 ; Decrement selection index
|
---|
760 | jnc SHORT .BitScanLoop
|
---|
761 | mov dl, ch
|
---|
762 | stc ; Drive selected by user
|
---|
763 | ret
|
---|
764 |
|
---|
765 |
|
---|
766 | ;--------------------------------------------------------------------
|
---|
767 | ; InitializeNullStringsToDialogInputInDSSI
|
---|
768 | ; Parameters:
|
---|
769 | ; DS:SI: Ptr to DIALOG_INPUT
|
---|
770 | ; SS:BP: Ptr to DIALOG
|
---|
771 | ; Returns:
|
---|
772 | ; Nothing
|
---|
773 | ; Corrupts registers:
|
---|
774 | ; AX
|
---|
775 | ;--------------------------------------------------------------------
|
---|
776 | ALIGN JUMP_ALIGN
|
---|
777 | InitializeNullStringsToDialogInputInDSSI:
|
---|
778 | mov ax, g_szNull
|
---|
779 | mov [si+DIALOG_INPUT.fszTitle], ax
|
---|
780 | mov [si+DIALOG_INPUT.fszTitle+2], cs
|
---|
781 | mov [si+DIALOG_INPUT.fszItems], ax
|
---|
782 | mov [si+DIALOG_INPUT.fszItems+2], cs
|
---|
783 | mov [si+DIALOG_INPUT.fszInfo], ax
|
---|
784 | mov [si+DIALOG_INPUT.fszInfo+2], cs
|
---|
785 | ret
|
---|