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