1 | ; Project name : Assembly Library
|
---|
2 | ; Description : Displays file dialog.
|
---|
3 |
|
---|
4 | ;
|
---|
5 | ; XTIDE Universal BIOS and Associated Tools
|
---|
6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
|
---|
7 | ;
|
---|
8 | ; This program is free software; you can redistribute it and/or modify
|
---|
9 | ; it under the terms of the GNU General Public License as published by
|
---|
10 | ; the Free Software Foundation; either version 2 of the License, or
|
---|
11 | ; (at your option) any later version.
|
---|
12 | ;
|
---|
13 | ; This program is distributed in the hope that it will be useful,
|
---|
14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | ; GNU General Public License for more details.
|
---|
17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
18 | ;
|
---|
19 |
|
---|
20 | CURRENTDIR_CHARACTERS EQU 002Eh
|
---|
21 | UPDIR_CHARACTERS EQU 2E2Eh
|
---|
22 |
|
---|
23 | ; Section containing code
|
---|
24 | SECTION .text
|
---|
25 |
|
---|
26 | ;--------------------------------------------------------------------
|
---|
27 | ; DialogFile_GetFileNameWithIoInDSSI
|
---|
28 | ; Parameters:
|
---|
29 | ; DS:SI: Ptr to FILE_DIALOG_IO
|
---|
30 | ; SS:BP: Ptr to parent MENU
|
---|
31 | ; Returns:
|
---|
32 | ; Nothing
|
---|
33 | ; Corrupts registers:
|
---|
34 | ; AX, BX, CX, DX, SI, DI
|
---|
35 | ;--------------------------------------------------------------------
|
---|
36 | ALIGN JUMP_ALIGN
|
---|
37 | DialogFile_GetFileNameWithIoInDSSI:
|
---|
38 | mov bx, FileEventHandler
|
---|
39 | mov BYTE [si+FILE_DIALOG_IO.bUserCancellation], TRUE
|
---|
40 | jmp Dialog_DisplayWithDialogInputInDSSIandHandlerInBX
|
---|
41 |
|
---|
42 |
|
---|
43 | ;--------------------------------------------------------------------
|
---|
44 | ; FileEventHandler
|
---|
45 | ; Common parameters for all events:
|
---|
46 | ; BX: Menu event (anything from MENUEVENT struct)
|
---|
47 | ; SS:BP: Ptr to DIALOG
|
---|
48 | ; Common return values for all events:
|
---|
49 | ; CF: Set if event processed
|
---|
50 | ; Cleared if event not processed
|
---|
51 | ; Corrupts registers:
|
---|
52 | ; All
|
---|
53 | ;--------------------------------------------------------------------
|
---|
54 | ALIGN JUMP_ALIGN
|
---|
55 | FileEventHandler:
|
---|
56 | jmp [cs:bx+.rgfnEventHandlers]
|
---|
57 |
|
---|
58 |
|
---|
59 | ALIGN JUMP_ALIGN
|
---|
60 | .ItemSelectedFromCX:
|
---|
61 | call LoadItemStringBufferToESDI
|
---|
62 | call Registers_CopyESDItoDSSI
|
---|
63 | call ItemLineSplitter_GetLineToDSSIandLengthToCXfromStringInDSSIwithIndexInCX
|
---|
64 | jmp ParseSelectionFromItemLineInDSSI
|
---|
65 |
|
---|
66 |
|
---|
67 | ALIGN JUMP_ALIGN
|
---|
68 | .RefreshInformation:
|
---|
69 | call GetInfoLinesToCXandDialogFlagsToAX
|
---|
70 | mov si, [cs:.rgszInfoStringLookup]
|
---|
71 | xor bx, bx
|
---|
72 | xchg dx, ax
|
---|
73 | ALIGN JUMP_ALIGN
|
---|
74 | .InfoLineLoop:
|
---|
75 | shr dl, 1
|
---|
76 | jnc SHORT .CheckNextFlag
|
---|
77 | mov si, [cs:bx+.rgszInfoStringLookup]
|
---|
78 | push bx
|
---|
79 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
80 | pop bx
|
---|
81 | ALIGN JUMP_ALIGN
|
---|
82 | .CheckNextFlag:
|
---|
83 | inc bx
|
---|
84 | inc bx
|
---|
85 | loop .InfoLineLoop
|
---|
86 | stc ; Event processed
|
---|
87 | ret
|
---|
88 |
|
---|
89 |
|
---|
90 | ALIGN JUMP_ALIGN
|
---|
91 | .RefreshItemFromCX:
|
---|
92 | call LoadItemStringBufferToESDI
|
---|
93 | mov ax, FILE_STRING_LENGTH
|
---|
94 | xchg ax, cx
|
---|
95 | mul cx
|
---|
96 | add di, ax
|
---|
97 | mov si, di
|
---|
98 | mov bx, es
|
---|
99 | dec cx ; Do not print LF at the end of file string
|
---|
100 | CALL_DISPLAY_LIBRARY PrintCharBufferFromBXSIwithLengthInCX
|
---|
101 | stc
|
---|
102 | ret
|
---|
103 |
|
---|
104 |
|
---|
105 | ALIGN WORD_ALIGN
|
---|
106 | .rgszInfoStringLookup:
|
---|
107 | dw g_szChangeDrive
|
---|
108 | dw g_szSelectDirectory
|
---|
109 | dw g_szCreateNew
|
---|
110 |
|
---|
111 | .rgfnEventHandlers:
|
---|
112 | istruc MENUEVENT
|
---|
113 | at MENUEVENT.InitializeMenuinitFromDSSI, dw InitializeMenuinitFromSSBP
|
---|
114 | at MENUEVENT.ExitMenu, dw Dialog_EventExitMenu
|
---|
115 | at MENUEVENT.IdleProcessing, dw Dialog_EventNotHandled
|
---|
116 | at MENUEVENT.ItemHighlightedFromCX, dw Dialog_EventNotHandled
|
---|
117 | at MENUEVENT.ItemSelectedFromCX, dw .ItemSelectedFromCX
|
---|
118 | at MENUEVENT.KeyStrokeInAX, dw HandleFunctionKeyFromAH
|
---|
119 | at MENUEVENT.RefreshTitle, dw Dialog_EventRefreshTitle
|
---|
120 | at MENUEVENT.RefreshInformation, dw .RefreshInformation
|
---|
121 | at MENUEVENT.RefreshItemFromCX, dw .RefreshItemFromCX
|
---|
122 | iend
|
---|
123 |
|
---|
124 |
|
---|
125 | ;--------------------------------------------------------------------
|
---|
126 | ; ReInitializeMenuinitFromSSBP
|
---|
127 | ; InitializeMenuinitFromSSBP
|
---|
128 | ; Parameters:
|
---|
129 | ; SS:BP: Ptr to DIALOG
|
---|
130 | ; Returns:
|
---|
131 | ; Nothing
|
---|
132 | ; Corrupts registers:
|
---|
133 | ; All, except BP
|
---|
134 | ;--------------------------------------------------------------------
|
---|
135 | ALIGN JUMP_ALIGN
|
---|
136 | ReInitializeMenuinitFromSSBP:
|
---|
137 | call DisplayLoadingMessageInInformationArea
|
---|
138 | InitializeMenuinitFromSSBP:
|
---|
139 | call LoadItemStringBufferToESDI
|
---|
140 | call CreateStringFromCurrentDirectoryContentsToESDI
|
---|
141 | call LoadItemStringBufferToESDI
|
---|
142 | call SortDirectoryContentsStringFromESDIwithCountInCX
|
---|
143 | call RemoveLastLFandTerminateESDIwithNull
|
---|
144 |
|
---|
145 | call Registers_CopySSBPtoDSSI
|
---|
146 | xor ax, ax
|
---|
147 | call Dialog_EventInitializeMenuinitFromDSSIwithHighlightedItemInAX
|
---|
148 | call GetInfoLinesToCXandDialogFlagsToAX
|
---|
149 | mov [bp+MENUINIT.bInfoLines], cl
|
---|
150 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
|
---|
151 | mov [bp+MENUINIT.bHeight], ah ; Always max height
|
---|
152 | mov WORD [bp+MENU.wFirstVisibleItem], 0
|
---|
153 | ret
|
---|
154 |
|
---|
155 |
|
---|
156 | ;--------------------------------------------------------------------
|
---|
157 | ; LoadItemStringBufferToESDI
|
---|
158 | ; Parameters:
|
---|
159 | ; SS:BP: Ptr to DIALOG
|
---|
160 | ; Returns:
|
---|
161 | ; ES:DI: Ptr to item string buffer
|
---|
162 | ; Corrupts registers:
|
---|
163 | ; Nothing
|
---|
164 | ;--------------------------------------------------------------------
|
---|
165 | ALIGN JUMP_ALIGN
|
---|
166 | LoadItemStringBufferToESDI:
|
---|
167 | les di, [bp+DIALOG.fpDialogIO]
|
---|
168 | les di, [es:di+FILE_DIALOG_IO.fszItemBuffer]
|
---|
169 | ret
|
---|
170 |
|
---|
171 |
|
---|
172 | ;--------------------------------------------------------------------
|
---|
173 | ; CreateStringFromCurrentDirectoryContentsToESDI
|
---|
174 | ; Parameters:
|
---|
175 | ; ES:DI: Buffer where to create item string
|
---|
176 | ; SS:BP: Ptr to DIALOG
|
---|
177 | ; Returns:
|
---|
178 | ; CX: Number of files or directories found
|
---|
179 | ; Corrupts registers:
|
---|
180 | ; AX, BX, DX, SI, DI, DS
|
---|
181 | ;--------------------------------------------------------------------
|
---|
182 | ALIGN JUMP_ALIGN
|
---|
183 | CreateStringFromCurrentDirectoryContentsToESDI:
|
---|
184 | mov bx, di
|
---|
185 | CALL_DISPLAY_LIBRARY PushDisplayContext
|
---|
186 | mov cx, -1
|
---|
187 | CALL_DISPLAY_LIBRARY PrepareOffScreenBufferInESBXwithLengthInCX ; ES:DI now points to buffer
|
---|
188 |
|
---|
189 | lds si, [bp+DIALOG.fpDialogIO]
|
---|
190 | eMOVZX cx, [si+FILE_DIALOG_IO.bFileAttributes]
|
---|
191 | lds si, [si+FILE_DIALOG_IO.fpFileFilterString]
|
---|
192 | call Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX
|
---|
193 |
|
---|
194 | call .ClearDLifInRootDirectory
|
---|
195 | call Directory_GetDiskTransferAreaAddressToDSSI
|
---|
196 | xor cx, cx ; Clear file/directory count
|
---|
197 | call .FindMatchingFilesAndPrintThemToOffScreenBuffer
|
---|
198 |
|
---|
199 | JMP_DISPLAY_LIBRARY PopDisplayContext
|
---|
200 |
|
---|
201 | ;--------------------------------------------------------------------
|
---|
202 | ; .ClearDLifInRootDirectory
|
---|
203 | ; Parameters:
|
---|
204 | ; SS:BP: Ptr to DIALOG
|
---|
205 | ; ES:DI: Ptr to destination string buffer
|
---|
206 | ; Returns:
|
---|
207 | ; DL: Cleared if in root directory
|
---|
208 | ; Set if in any other directory
|
---|
209 | ; Corrupts registers:
|
---|
210 | ; AX, SI, DS
|
---|
211 | ;--------------------------------------------------------------------
|
---|
212 | ALIGN JUMP_ALIGN
|
---|
213 | .ClearDLifInRootDirectory:
|
---|
214 | call Registers_CopyESDItoDSSI
|
---|
215 | call Directory_WriteCurrentPathToDSSI
|
---|
216 | mov dl, [si]
|
---|
217 | ret
|
---|
218 |
|
---|
219 | ;--------------------------------------------------------------------
|
---|
220 | ; .FindMatchingFilesAndPrintThemToOffScreenBuffer
|
---|
221 | ; Parameters:
|
---|
222 | ; CX: Initial directory count
|
---|
223 | ; DL: Zero if root directory selected
|
---|
224 | ; DS:SI: Ptr to DTA with first matching file
|
---|
225 | ; Returns:
|
---|
226 | ; CX: Incremented by number of files/directories found
|
---|
227 | ; Corrupts registers:
|
---|
228 | ; AX, BX, DX, DI, DS
|
---|
229 | ;--------------------------------------------------------------------
|
---|
230 | ALIGN JUMP_ALIGN
|
---|
231 | .FindMatchingFilesAndPrintThemToOffScreenBuffer:
|
---|
232 | call AppendFileFromDTAinDSSItoOffScreenBuffer
|
---|
233 | call Directory_UpdateDTAForNextMatchUsingPreviousParameters
|
---|
234 | jnc SHORT .FindMatchingFilesAndPrintThemToOffScreenBuffer
|
---|
235 | ret
|
---|
236 |
|
---|
237 |
|
---|
238 | ;--------------------------------------------------------------------
|
---|
239 | ; AppendFileFromDTAinDSSItoOffScreenBuffer
|
---|
240 | ; Parameters:
|
---|
241 | ; CX: Files/directories found
|
---|
242 | ; DL: Zero if root directory selected
|
---|
243 | ; DS:SI: Ptr to DTA containing file information
|
---|
244 | ; Returns:
|
---|
245 | ; CX: Incremented by number of files/directories found
|
---|
246 | ; Corrupts registers:
|
---|
247 | ; AX, BX
|
---|
248 | ;--------------------------------------------------------------------
|
---|
249 | ALIGN JUMP_ALIGN
|
---|
250 | AppendFileFromDTAinDSSItoOffScreenBuffer:
|
---|
251 | call .FilterCurrentDirectory ; We never want "."
|
---|
252 | call .FilterUpDirectoryWhenInRoot ; No ".." when in root directory
|
---|
253 | inc cx ; Nothing filtered so increment files/directories
|
---|
254 |
|
---|
255 | push bp
|
---|
256 | push si
|
---|
257 | push dx
|
---|
258 | push cx
|
---|
259 | call .FormatFileOrDirectoryToBufferFromDTAinDSSI
|
---|
260 | pop cx
|
---|
261 | pop dx
|
---|
262 | pop si
|
---|
263 | pop bp
|
---|
264 | ret
|
---|
265 |
|
---|
266 | ;--------------------------------------------------------------------
|
---|
267 | ; .FilterCurrentDirectory
|
---|
268 | ; .FilterUpDirectoryWhenInRoot
|
---|
269 | ; Parameters:
|
---|
270 | ; DL: Zero if root directory selected
|
---|
271 | ; DS:SI: Ptr to DTA containing file information
|
---|
272 | ; Returns:
|
---|
273 | ; Nothing
|
---|
274 | ; Returns from AppendFileToBufferInESDIfromDtaInDSSI when filtering
|
---|
275 | ; Corrupts registers:
|
---|
276 | ; AX
|
---|
277 | ;--------------------------------------------------------------------
|
---|
278 | ALIGN JUMP_ALIGN
|
---|
279 | .FilterCurrentDirectory:
|
---|
280 | cmp WORD [si+DTA.szFile], CURRENTDIR_CHARACTERS
|
---|
281 | je SHORT .DoFilter
|
---|
282 | ret
|
---|
283 |
|
---|
284 | ALIGN JUMP_ALIGN
|
---|
285 | .FilterUpDirectoryWhenInRoot:
|
---|
286 | test dl, dl ; Set ZF if root directory selected
|
---|
287 | jnz SHORT .ReturnWithoutFiltering
|
---|
288 | cmp WORD [si+DTA.szFile], UPDIR_CHARACTERS
|
---|
289 | jne SHORT .ReturnWithoutFiltering
|
---|
290 | .DoFilter:
|
---|
291 | add sp, BYTE 2 ; Remove return address from stack
|
---|
292 | ALIGN JUMP_ALIGN, ret
|
---|
293 | .ReturnWithoutFiltering:
|
---|
294 | ret
|
---|
295 |
|
---|
296 | ;--------------------------------------------------------------------
|
---|
297 | ; .FormatFileOrDirectoryToBufferFromDTAinDSSI
|
---|
298 | ; Parameters:
|
---|
299 | ; DS:SI: Ptr to DTA containing file information
|
---|
300 | ; Returns:
|
---|
301 | ; Nothing
|
---|
302 | ; Corrupts registers:
|
---|
303 | ; AX, BX, CX, DX, SI, DI, BP
|
---|
304 | ;--------------------------------------------------------------------
|
---|
305 | ALIGN JUMP_ALIGN
|
---|
306 | .FormatFileOrDirectoryToBufferFromDTAinDSSI:
|
---|
307 | mov bp, sp
|
---|
308 | lea ax, [si+DTA.szFile]
|
---|
309 |
|
---|
310 | test BYTE [si+DTA.bFileAttributes], FLG_FILEATTR_DIRECTORY
|
---|
311 | jnz SHORT .FormatDirectory
|
---|
312 | ; Fall to .FormatFile
|
---|
313 |
|
---|
314 | ;--------------------------------------------------------------------
|
---|
315 | ; .FormatFile
|
---|
316 | ; Parameters:
|
---|
317 | ; BP: SP before pushing formatting parameters
|
---|
318 | ; DS:AX: Far pointer to file name
|
---|
319 | ; DS:SI: Ptr to DTA containing file information
|
---|
320 | ; Returns:
|
---|
321 | ; Nothing
|
---|
322 | ; Corrupts registers:
|
---|
323 | ; AX, BX, CX, DX, SI, DI
|
---|
324 | ;--------------------------------------------------------------------
|
---|
325 | .FormatFile:
|
---|
326 | xchg si, ax
|
---|
327 | call String_ConvertDSSItoLowerCase
|
---|
328 | xchg ax, si
|
---|
329 |
|
---|
330 | ; Push parameters for file name
|
---|
331 | push ax ; Push file name offset
|
---|
332 | push ds ; Push file name segment
|
---|
333 |
|
---|
334 | ; Push parameters for file size
|
---|
335 | mov ax, [si+DTA.dwFileSize]
|
---|
336 | mov dx, [si+DTA.dwFileSize+2]
|
---|
337 | xor bx, bx
|
---|
338 | xor cx, cx
|
---|
339 | call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
|
---|
340 | mov cl, 'i'
|
---|
341 | cmp dl, ' '
|
---|
342 | eCMOVE cl, dl
|
---|
343 | push ax
|
---|
344 | push dx
|
---|
345 | push cx
|
---|
346 |
|
---|
347 | ; Format to buffer
|
---|
348 | mov si, g_szFileFormat
|
---|
349 | jmp SHORT .FormatStringInCSSIandReturn
|
---|
350 |
|
---|
351 | ;--------------------------------------------------------------------
|
---|
352 | ; .FormatDirectory
|
---|
353 | ; Parameters:
|
---|
354 | ; BP: SP before pushing formatting parameters
|
---|
355 | ; DS:AX: Far pointer to directory name
|
---|
356 | ; DS:SI: Ptr to DTA containing file information
|
---|
357 | ; Returns:
|
---|
358 | ; Nothing
|
---|
359 | ; Corrupts registers:
|
---|
360 | ; AX, SI, DI
|
---|
361 | ;--------------------------------------------------------------------
|
---|
362 | ALIGN JUMP_ALIGN
|
---|
363 | .FormatDirectory:
|
---|
364 | push ax ; Push directory name offset
|
---|
365 | push ds ; Push directory name segment
|
---|
366 | mov ax, g_szSub
|
---|
367 | cmp WORD [si+DTA.szFile], UPDIR_CHARACTERS
|
---|
368 | eCMOVE ax, g_szUp
|
---|
369 | push ax
|
---|
370 | mov si, g_szDirectoryFormat
|
---|
371 | ALIGN JUMP_ALIGN
|
---|
372 | .FormatStringInCSSIandReturn:
|
---|
373 | JMP_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
374 |
|
---|
375 |
|
---|
376 | ;--------------------------------------------------------------------
|
---|
377 | ; SortDirectoryContentsStringFromESDIwithCountInCX
|
---|
378 | ; Parameters:
|
---|
379 | ; CX: Number of files and directories
|
---|
380 | ; ES:DI: Buffer containing directory contents string
|
---|
381 | ; SS:BP: Ptr to DIALOG
|
---|
382 | ; Returns:
|
---|
383 | ; ES:DI: Ptr to end of directory contents string
|
---|
384 | ; Corrupts registers:
|
---|
385 | ; AX, BX, CX, DX, SI, DS
|
---|
386 | ;--------------------------------------------------------------------
|
---|
387 | ALIGN JUMP_ALIGN
|
---|
388 | SortDirectoryContentsStringFromESDIwithCountInCX:
|
---|
389 | call Registers_CopyESDItoDSSI
|
---|
390 |
|
---|
391 | ; Add directory contents string length to DI
|
---|
392 | mov ax, FILE_STRING_LENGTH
|
---|
393 | push ax
|
---|
394 | mul cx
|
---|
395 | add di, ax
|
---|
396 |
|
---|
397 | mov dx, cx
|
---|
398 | pop cx
|
---|
399 | mov bx, .FileStringComparator
|
---|
400 | jmp Sort_ItemsFromDSSIwithCountInDXsizeInCXandComparatorInBX
|
---|
401 |
|
---|
402 | ;--------------------------------------------------------------------
|
---|
403 | ; .FileStringComparator
|
---|
404 | ; Parameters:
|
---|
405 | ; CX: Item size in bytes
|
---|
406 | ; DS:SI: Ptr to first item to compare
|
---|
407 | ; ES:DI: Ptr to second item to compare
|
---|
408 | ; Returns:
|
---|
409 | ; FLAGS: Signed comparison between first and second item
|
---|
410 | ; Corrupts registers:
|
---|
411 | ; Nothing
|
---|
412 | ;--------------------------------------------------------------------
|
---|
413 | ALIGN JUMP_ALIGN
|
---|
414 | .FileStringComparator:
|
---|
415 | push di
|
---|
416 | push si
|
---|
417 | push cx
|
---|
418 | push bx
|
---|
419 |
|
---|
420 | mov bx, FILE_STRING_LENGTH-2 ; Zero BH
|
---|
421 | cmp WORD [si], UPDIR_CHARACTERS
|
---|
422 | je SHORT .ForceValueFromDSSItoBeLess
|
---|
423 | mov bl, [si+bx]
|
---|
424 | cmp bl, [es:di+FILE_STRING_LENGTH-2] ; 'B' for files, 'R' for directories
|
---|
425 | jne SHORT .ForceValueFromDSSItoBeMoreOrLess
|
---|
426 | repe cmpsb ; Two directories or two files
|
---|
427 |
|
---|
428 | ALIGN JUMP_ALIGN
|
---|
429 | .ReturnFromComparison:
|
---|
430 | pop bx
|
---|
431 | pop cx
|
---|
432 | pop si
|
---|
433 | pop di
|
---|
434 | ret
|
---|
435 | ALIGN JUMP_ALIGN
|
---|
436 | .ForceValueFromDSSItoBeMoreOrLess:
|
---|
437 | ja SHORT .ForceValueFromDSSItoBeLess ; Directory in SI, file in DI
|
---|
438 | xchg bl, bh
|
---|
439 | ; Fall to ForceValueFromDSSItoBeLess
|
---|
440 | ALIGN JUMP_ALIGN
|
---|
441 | .ForceValueFromDSSItoBeLess:
|
---|
442 | cmp bh, bl
|
---|
443 | jmp SHORT .ReturnFromComparison
|
---|
444 |
|
---|
445 |
|
---|
446 | ;--------------------------------------------------------------------
|
---|
447 | ; RemoveLastLFandTerminateESDIwithNull
|
---|
448 | ; Parameters:
|
---|
449 | ; ES:DI: Ptr to end of buffer to terminate
|
---|
450 | ; Returns:
|
---|
451 | ; Nothing
|
---|
452 | ; Corrupts registers:
|
---|
453 | ; AX
|
---|
454 | ;--------------------------------------------------------------------
|
---|
455 | ALIGN JUMP_ALIGN
|
---|
456 | RemoveLastLFandTerminateESDIwithNull:
|
---|
457 | dec di
|
---|
458 | xor ax, ax
|
---|
459 | stosb
|
---|
460 | ret
|
---|
461 |
|
---|
462 |
|
---|
463 | ;--------------------------------------------------------------------
|
---|
464 | ; GetInfoLinesToCXandDialogFlagsToAX
|
---|
465 | ; Parameters:
|
---|
466 | ; SS:BP: Ptr to DIALOG
|
---|
467 | ; Returns:
|
---|
468 | ; AX: Dialog flags
|
---|
469 | ; CX: Number of info lines to be displayed
|
---|
470 | ; Corrupts registers:
|
---|
471 | ; SI, DS
|
---|
472 | ;--------------------------------------------------------------------
|
---|
473 | ALIGN JUMP_ALIGN
|
---|
474 | GetInfoLinesToCXandDialogFlagsToAX:
|
---|
475 | xor ax, ax
|
---|
476 | call GetDialogFlagsToAL
|
---|
477 | jmp Bit_GetSetCountToCXfromAX
|
---|
478 |
|
---|
479 | ;--------------------------------------------------------------------
|
---|
480 | ; GetDialogFlagsToAL
|
---|
481 | ; Parameters:
|
---|
482 | ; SS:BP: Ptr to DIALOG
|
---|
483 | ; Returns:
|
---|
484 | ; AL: Dialog flags
|
---|
485 | ; Corrupts registers:
|
---|
486 | ; SI, DS
|
---|
487 | ;--------------------------------------------------------------------
|
---|
488 | ALIGN JUMP_ALIGN
|
---|
489 | GetDialogFlagsToAL:
|
---|
490 | lds si, [bp+DIALOG.fpDialogIO]
|
---|
491 | mov al, [si+FILE_DIALOG_IO.bDialogFlags]
|
---|
492 | ret
|
---|
493 |
|
---|
494 |
|
---|
495 | ;--------------------------------------------------------------------
|
---|
496 | ; ParseSelectionFromItemLineInDSSI
|
---|
497 | ; Parameters:
|
---|
498 | ; DS:SI: Ptr to char buffer containing file or directory to be selected
|
---|
499 | ; SS:BP: Ptr to DIALOG
|
---|
500 | ; Returns:
|
---|
501 | ; Nothing
|
---|
502 | ; Corrupts registers:
|
---|
503 | ; All, except BP
|
---|
504 | ;--------------------------------------------------------------------
|
---|
505 | ALIGN JUMP_ALIGN
|
---|
506 | ParseSelectionFromItemLineInDSSI:
|
---|
507 | mov ax, [si]
|
---|
508 | cmp ax, UPDIR_CHARACTERS
|
---|
509 | je SHORT .ChangeToUpdir
|
---|
510 | call Char_IsUpperCaseLetterInAL
|
---|
511 | jc SHORT .ParseAndChangeToSubdirInDSSI
|
---|
512 | call Char_IsDecimalDigitInAL
|
---|
513 | jc SHORT .ParseAndChangeToSubdirInDSSI ; Assume subdir and check for errors
|
---|
514 | ; Fall to .ParseAndSelectFileFromDSSI
|
---|
515 |
|
---|
516 | ;--------------------------------------------------------------------
|
---|
517 | ; .ParseAndSelectFileFromDSSI
|
---|
518 | ; Parameters:
|
---|
519 | ; DS:SI: NULL terminated string selected from dialog
|
---|
520 | ; SS:BP: Ptr to DIALOG
|
---|
521 | ; Returns:
|
---|
522 | ; Nothing (exits dialog)
|
---|
523 | ; Corrupts registers:
|
---|
524 | ; All, except BP
|
---|
525 | ;--------------------------------------------------------------------
|
---|
526 | .ParseAndSelectFileFromDSSI:
|
---|
527 | les di, [bp+DIALOG.fpDialogIO]
|
---|
528 | add di, BYTE FILE_DIALOG_IO.szFile
|
---|
529 | mov cx, FILENAME_BUFFER_SIZE-1
|
---|
530 | call Memory_CopyCXbytesFromDSSItoESDI
|
---|
531 | xor ax, ax
|
---|
532 | stosb ; Terminate with NULL
|
---|
533 | jmp SHORT CloseFileDialogAfterSuccessfulSelection
|
---|
534 |
|
---|
535 | ;--------------------------------------------------------------------
|
---|
536 | ; .ChangeToUpdir
|
---|
537 | ; Parameters:
|
---|
538 | ; SS:BP: Ptr to DIALOG
|
---|
539 | ; Returns:
|
---|
540 | ; Nothing
|
---|
541 | ; Corrupts registers:
|
---|
542 | ; All, except BP
|
---|
543 | ;--------------------------------------------------------------------
|
---|
544 | ALIGN JUMP_ALIGN
|
---|
545 | .ChangeToUpdir:
|
---|
546 | push cs
|
---|
547 | pop ds
|
---|
548 | mov si, g_szUpdir
|
---|
549 | jmp SHORT .ChangeDirectoryToDSSI
|
---|
550 |
|
---|
551 | ;--------------------------------------------------------------------
|
---|
552 | ; .ParseAndChangeToSubdirInDSSI
|
---|
553 | ; Parameters:
|
---|
554 | ; DS:SI: NULL terminated string selected from dialog
|
---|
555 | ; SS:BP: Ptr to DIALOG
|
---|
556 | ; Returns:
|
---|
557 | ; Nothing
|
---|
558 | ; Corrupts registers:
|
---|
559 | ; All, except BP
|
---|
560 | ;--------------------------------------------------------------------
|
---|
561 | ALIGN JUMP_ALIGN
|
---|
562 | .ParseAndChangeToSubdirInDSSI:
|
---|
563 | mov BYTE [si+12], NULL ; Terminate with NULL (unnecessary spaces do not matter)
|
---|
564 | .ChangeDirectoryToDSSI:
|
---|
565 | call Directory_ChangeToPathFromDSSI
|
---|
566 | jc SHORT .ParseAndSelectFileFromDSSI ; Must have been a file starting with number
|
---|
567 | ; Fall to RefreshFilesToDisplay
|
---|
568 |
|
---|
569 | ;--------------------------------------------------------------------
|
---|
570 | ; RefreshFilesToDisplay
|
---|
571 | ; Parameters:
|
---|
572 | ; SS:BP: Ptr to DIALOG
|
---|
573 | ; Returns:
|
---|
574 | ; Nothing
|
---|
575 | ; Corrupts registers:
|
---|
576 | ; All, except BP
|
---|
577 | ;--------------------------------------------------------------------
|
---|
578 | ALIGN JUMP_ALIGN
|
---|
579 | RefreshFilesToDisplay:
|
---|
580 | call ReInitializeMenuinitFromSSBP
|
---|
581 | jmp MenuInit_RefreshMenuWindow
|
---|
582 |
|
---|
583 |
|
---|
584 | ;--------------------------------------------------------------------
|
---|
585 | ; HandleFunctionKeyFromAH
|
---|
586 | ; Parameters:
|
---|
587 | ; AH: Scancode for function key
|
---|
588 | ; SS:BP: Ptr to DIALOG
|
---|
589 | ; Returns:
|
---|
590 | ; Nothing
|
---|
591 | ; Corrupts registers:
|
---|
592 | ; AX, SI, DI, BP
|
---|
593 | ;--------------------------------------------------------------------
|
---|
594 | ALIGN JUMP_ALIGN
|
---|
595 | HandleFunctionKeyFromAH:
|
---|
596 | call GetDialogFlagsToAL
|
---|
597 | cmp ah, KEY_FILEDIALOG_NEW_FILE_OR_DIR
|
---|
598 | je SHORT HandleFunctionKeyForCreatingNewFileOrDirectory
|
---|
599 | cmp ah, KEY_FILEDIALOG_SELECT_DIRECTORY
|
---|
600 | je SHORT HandleFunctionKeyForSelectingDirectoryInsteadOfFile
|
---|
601 | cmp ah, KEY_FILEDIALOG_CHANGE_DRIVE
|
---|
602 | je SHORT HandleFunctionKeyForDriveChange
|
---|
603 | ReturnWithoutHandlingKeystroke:
|
---|
604 | clc ; Event not processed
|
---|
605 | ret
|
---|
606 |
|
---|
607 |
|
---|
608 | ;--------------------------------------------------------------------
|
---|
609 | ; HandleFunctionKeyForCreatingNewFileOrDirectory
|
---|
610 | ; Parameters:
|
---|
611 | ; AL: File dialog flags
|
---|
612 | ; SS:BP: Ptr to DIALOG
|
---|
613 | ; Returns:
|
---|
614 | ; Closes file dialog
|
---|
615 | ; Corrupts registers:
|
---|
616 | ; All, except BP
|
---|
617 | ;--------------------------------------------------------------------
|
---|
618 | ALIGN JUMP_ALIGN
|
---|
619 | HandleFunctionKeyForCreatingNewFileOrDirectory:
|
---|
620 | test al, FLG_FILEDIALOG_NEW
|
---|
621 | jz SHORT ReturnWithoutHandlingKeystroke
|
---|
622 |
|
---|
623 | mov cx, STRING_DIALOG_IO_size
|
---|
624 | call Memory_ReserveCXbytesFromStackToDSSI
|
---|
625 |
|
---|
626 | ;;; InitializeStringDialogIoInDSSIforInputtingFileName
|
---|
627 | call InitializeNullStringsToDialogInputInDSSI
|
---|
628 | mov WORD [si+DIALOG_INPUT.fszTitle], g_szEnterNewFileOrDirectory
|
---|
629 | mov WORD [si+STRING_DIALOG_IO.fnCharFilter], NULL
|
---|
630 | mov WORD [si+STRING_DIALOG_IO.wBufferSize], FILENAME_BUFFER_SIZE
|
---|
631 | les ax, [bp+DIALOG.fpDialogIO]
|
---|
632 | add ax, BYTE FILE_DIALOG_IO.szFile
|
---|
633 | mov [si+STRING_DIALOG_IO.fpReturnBuffer], ax
|
---|
634 | mov [si+STRING_DIALOG_IO.fpReturnBuffer+2], es
|
---|
635 | ;;;
|
---|
636 |
|
---|
637 | CALL_MENU_LIBRARY GetStringWithIoInDSSI
|
---|
638 | mov al, [si+STRING_DIALOG_IO.bUserCancellation]
|
---|
639 | add sp, BYTE STRING_DIALOG_IO_size
|
---|
640 | test al, al ; User cancellation?
|
---|
641 | jnz SHORT ReturnWithoutHandlingKeystroke
|
---|
642 | jmp CloseFileDialogAfterSuccessfulSelection
|
---|
643 |
|
---|
644 |
|
---|
645 | ;--------------------------------------------------------------------
|
---|
646 | ; HandleFunctionKeyForSelectingDirectoryInsteadOfFile
|
---|
647 | ; Parameters:
|
---|
648 | ; AL: File dialog flags
|
---|
649 | ; SS:BP: Ptr to DIALOG
|
---|
650 | ; Returns:
|
---|
651 | ; Closes file dialog
|
---|
652 | ; Corrupts registers:
|
---|
653 | ; All, except BP
|
---|
654 | ;--------------------------------------------------------------------
|
---|
655 | ALIGN JUMP_ALIGN
|
---|
656 | HandleFunctionKeyForSelectingDirectoryInsteadOfFile:
|
---|
657 | test al, FLG_FILEDIALOG_DIRECTORY
|
---|
658 | jz SHORT ReturnWithoutHandlingKeystroke
|
---|
659 | ; Fall to CloseFileDialogAfterSuccessfulSelection
|
---|
660 |
|
---|
661 | ;--------------------------------------------------------------------
|
---|
662 | ; CloseFileDialogAfterSuccessfulSelection
|
---|
663 | ; Parameters:
|
---|
664 | ; SS:BP: Ptr to DIALOG
|
---|
665 | ; Returns:
|
---|
666 | ; Nothing (exits dialog)
|
---|
667 | ; Corrupts registers:
|
---|
668 | ; All, except BP
|
---|
669 | ;--------------------------------------------------------------------
|
---|
670 | ALIGN JUMP_ALIGN
|
---|
671 | CloseFileDialogAfterSuccessfulSelection:
|
---|
672 | lds di, [bp+DIALOG.fpDialogIO]
|
---|
673 | mov BYTE [di+FILE_DIALOG_IO.bUserCancellation], FALSE
|
---|
674 | jmp MenuInit_CloseMenuWindow
|
---|
675 |
|
---|
676 |
|
---|
677 | ;--------------------------------------------------------------------
|
---|
678 | ; HandleFunctionKeyForDriveChange
|
---|
679 | ; Parameters:
|
---|
680 | ; AL: File dialog flags
|
---|
681 | ; SS:BP: Ptr to DIALOG
|
---|
682 | ; Returns:
|
---|
683 | ; Nothing
|
---|
684 | ; Corrupts registers:
|
---|
685 | ; All, except BP
|
---|
686 | ;--------------------------------------------------------------------
|
---|
687 | ALIGN JUMP_ALIGN
|
---|
688 | HandleFunctionKeyForDriveChange:
|
---|
689 | test al, FLG_FILEDIALOG_DRIVES
|
---|
690 | jz SHORT ReturnWithoutHandlingKeystroke
|
---|
691 |
|
---|
692 | call DisplayLoadingMessageInInformationArea
|
---|
693 | mov cx, DRIVE_DIALOG_IO_size
|
---|
694 | call Memory_ReserveCXbytesFromStackToDSSI
|
---|
695 | call .DisplayDriveSelectionDialogWithIoInDSSI
|
---|
696 | call .ChangeDriveToUserSelectionFromIoInDSSI
|
---|
697 | add sp, BYTE DRIVE_DIALOG_IO_size
|
---|
698 | ret
|
---|
699 |
|
---|
700 | ;--------------------------------------------------------------------
|
---|
701 | ; .DisplayDriveSelectionDialogWithIoInDSSI
|
---|
702 | ; Parameters:
|
---|
703 | ; DS:SI: Ptr to uninitialized DRIVE_DIALOG_IO
|
---|
704 | ; SS:BP: Ptr to DIALOG
|
---|
705 | ; Returns:
|
---|
706 | ; DS:SI: Ptr to DRIVE_DIALOG_IO
|
---|
707 | ; Corrupts registers:
|
---|
708 | ; AX, DI
|
---|
709 | ;--------------------------------------------------------------------
|
---|
710 | ALIGN JUMP_ALIGN
|
---|
711 | .DisplayDriveSelectionDialogWithIoInDSSI:
|
---|
712 | call InitializeNullStringsToDialogInputInDSSI
|
---|
713 | mov WORD [si+DIALOG_INPUT.fszTitle], g_szSelectNewDrive
|
---|
714 | JMP_MENU_LIBRARY GetDriveWithIoInDSSI
|
---|
715 |
|
---|
716 | ;--------------------------------------------------------------------
|
---|
717 | ; .ChangeDriveToUserSelectionFromIoInDSSI
|
---|
718 | ; Parameters:
|
---|
719 | ; DS:SI: Ptr to DRIVE_DIALOG_IO
|
---|
720 | ; SS:BP: Ptr to DIALOG
|
---|
721 | ; Returns:
|
---|
722 | ; Nothing
|
---|
723 | ; Corrupts registers:
|
---|
724 | ; All, except BP
|
---|
725 | ;--------------------------------------------------------------------
|
---|
726 | ALIGN JUMP_ALIGN
|
---|
727 | .ChangeDriveToUserSelectionFromIoInDSSI:
|
---|
728 | cmp BYTE [si+DRIVE_DIALOG_IO.bUserCancellation], FALSE
|
---|
729 | jne SHORT .UserCancelledDriveChange
|
---|
730 |
|
---|
731 | mov dl, [si+DRIVE_DIALOG_IO.bReturnDriveNumber]
|
---|
732 | call Drive_SetDefaultFromDL
|
---|
733 | jmp RefreshFilesToDisplay
|
---|
734 | .UserCancelledDriveChange:
|
---|
735 | ret
|
---|
736 |
|
---|
737 |
|
---|
738 | ;--------------------------------------------------------------------
|
---|
739 | ; DisplayLoadingMessageInInformationArea
|
---|
740 | ; Parameters:
|
---|
741 | ; SS:BP: Ptr to DIALOG
|
---|
742 | ; Returns:
|
---|
743 | ; Nothing
|
---|
744 | ; Corrupts registers:
|
---|
745 | ; AX, BX, CX, DX, SI, DI
|
---|
746 | ;--------------------------------------------------------------------
|
---|
747 | ALIGN JUMP_ALIGN
|
---|
748 | DisplayLoadingMessageInInformationArea:
|
---|
749 | call MenuText_ClearInformationArea
|
---|
750 | call MenuText_PrepareToDrawInformationArea
|
---|
751 | mov si, g_szLoadingPleaseWait
|
---|
752 | JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
753 |
|
---|
754 |
|
---|
755 | ;--------------------------------------------------------------------
|
---|
756 | ; InitializeNullStringsToDialogInputInDSSI
|
---|
757 | ; Parameters:
|
---|
758 | ; DS:SI: Ptr to DIALOG_INPUT
|
---|
759 | ; SS:BP: Ptr to DIALOG
|
---|
760 | ; Returns:
|
---|
761 | ; Nothing
|
---|
762 | ; Corrupts registers:
|
---|
763 | ; AX
|
---|
764 | ;--------------------------------------------------------------------
|
---|
765 | ALIGN JUMP_ALIGN
|
---|
766 | InitializeNullStringsToDialogInputInDSSI:
|
---|
767 | mov ax, g_szNull
|
---|
768 | mov [si+DIALOG_INPUT.fszTitle], ax
|
---|
769 | mov [si+DIALOG_INPUT.fszTitle+2], cs
|
---|
770 | mov [si+DIALOG_INPUT.fszItems], ax
|
---|
771 | mov [si+DIALOG_INPUT.fszItems+2], cs
|
---|
772 | mov [si+DIALOG_INPUT.fszInfo], ax
|
---|
773 | mov [si+DIALOG_INPUT.fszInfo+2], cs
|
---|
774 | ret
|
---|