[41] | 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
|
---|
[106] | 47 | call Registers_CopyESDItoDSSI
|
---|
[52] | 48 | call ItemLineSplitter_GetLineToDSSIandLengthToCXfromStringInDSSIwithIndexInCX
|
---|
[41] | 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 |
|
---|
[53] | 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 |
|
---|
[41] | 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
|
---|
[58] | 99 | at MENUEVENT.ExitMenu, dw Dialog_EventExitMenu
|
---|
[41] | 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
|
---|
[53] | 106 | at MENUEVENT.RefreshItemFromCX, dw .RefreshItemFromCX
|
---|
[41] | 107 | iend
|
---|
| 108 |
|
---|
| 109 |
|
---|
| 110 | ;--------------------------------------------------------------------
|
---|
[54] | 111 | ; ReInitializeMenuinitFromSSBP
|
---|
[41] | 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
|
---|
[54] | 121 | ReInitializeMenuinitFromSSBP:
|
---|
| 122 | call DisplayLoadingMessageInInformationArea
|
---|
[41] | 123 | InitializeMenuinitFromSSBP:
|
---|
| 124 | call LoadItemStringBufferToESDI
|
---|
| 125 | call CreateStringFromCurrentDirectoryContentsToESDI
|
---|
[46] | 126 | call LoadItemStringBufferToESDI
|
---|
| 127 | call SortDirectoryContentsStringFromESDIwithCountInCX
|
---|
[53] | 128 | call RemoveLastLFandTerminateESDIwithNull
|
---|
[54] | 129 |
|
---|
[106] | 130 | call Registers_CopySSBPtoDSSI
|
---|
[52] | 131 | xor ax, ax
|
---|
| 132 | call Dialog_EventInitializeMenuinitFromDSSIwithHighlightedItemInAX
|
---|
[41] | 133 | call GetInfoLinesToCXandDialogFlagsToAX
|
---|
| 134 | mov [bp+MENUINIT.bInfoLines], cl
|
---|
| 135 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
|
---|
| 136 | mov [bp+MENUINIT.bHeight], ah ; Always max height
|
---|
[52] | 137 | mov WORD [bp+MENU.wFirstVisibleItem], 0
|
---|
[41] | 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:
|
---|
[46] | 163 | ; CX: Number of files or directories found
|
---|
[41] | 164 | ; Corrupts registers:
|
---|
[53] | 165 | ; AX, BX, DX, SI, DI, DS
|
---|
[41] | 166 | ;--------------------------------------------------------------------
|
---|
| 167 | ALIGN JUMP_ALIGN
|
---|
| 168 | CreateStringFromCurrentDirectoryContentsToESDI:
|
---|
[53] | 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 |
|
---|
[41] | 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
|
---|
[53] | 178 |
|
---|
[41] | 179 | call .ClearDLifInRootDirectory
|
---|
| 180 | call Directory_GetDiskTransferAreaAddressToDSSI
|
---|
[46] | 181 | xor cx, cx ; Clear file/directory count
|
---|
[53] | 182 | call .FindMatchingFilesAndPrintThemToOffScreenBuffer
|
---|
[41] | 183 |
|
---|
[53] | 184 | CALL_DISPLAY_LIBRARY PopDisplayContext
|
---|
| 185 | ret
|
---|
[41] | 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:
|
---|
[106] | 200 | call Registers_CopyESDItoDSSI
|
---|
[41] | 201 | call Directory_WriteCurrentPathToDSSI
|
---|
| 202 | mov dl, [si]
|
---|
| 203 | ret
|
---|
| 204 |
|
---|
| 205 | ;--------------------------------------------------------------------
|
---|
[53] | 206 | ; .FindMatchingFilesAndPrintThemToOffScreenBuffer
|
---|
[41] | 207 | ; Parameters:
|
---|
[53] | 208 | ; CX: Initial directory count
|
---|
| 209 | ; DL: Zero if root directory selected
|
---|
| 210 | ; DS:SI: Ptr to DTA with first matching file
|
---|
[41] | 211 | ; Returns:
|
---|
[53] | 212 | ; CX: Incremented by number of files/directories found
|
---|
[41] | 213 | ; Corrupts registers:
|
---|
[53] | 214 | ; AX, BX, DX, DI, DS
|
---|
[41] | 215 | ;--------------------------------------------------------------------
|
---|
| 216 | ALIGN JUMP_ALIGN
|
---|
[53] | 217 | .FindMatchingFilesAndPrintThemToOffScreenBuffer:
|
---|
| 218 | call AppendFileFromDTAinDSSItoOffScreenBuffer
|
---|
| 219 | call Directory_UpdateDTAForNextMatchUsingPreviousParameters
|
---|
| 220 | jnc SHORT .FindMatchingFilesAndPrintThemToOffScreenBuffer
|
---|
[41] | 221 | ret
|
---|
| 222 |
|
---|
[46] | 223 |
|
---|
[41] | 224 | ;--------------------------------------------------------------------
|
---|
[53] | 225 | ; AppendFileFromDTAinDSSItoOffScreenBuffer
|
---|
[41] | 226 | ; Parameters:
|
---|
[46] | 227 | ; CX: Files/directores found
|
---|
[41] | 228 | ; DL: Zero if root directory selected
|
---|
| 229 | ; DS:SI: Ptr to DTA containing file information
|
---|
| 230 | ; Returns:
|
---|
[46] | 231 | ; CX: Incremented by number of files/directories found
|
---|
[41] | 232 | ; Corrupts registers:
|
---|
[53] | 233 | ; AX, BX
|
---|
[41] | 234 | ;--------------------------------------------------------------------
|
---|
| 235 | ALIGN JUMP_ALIGN
|
---|
[53] | 236 | AppendFileFromDTAinDSSItoOffScreenBuffer:
|
---|
[41] | 237 | call .FilterCurrentDirectory ; We never want "."
|
---|
| 238 | call .FilterUpDirectoryWhenInRoot ; No ".." when in root directory
|
---|
[46] | 239 | inc cx ; Nothing filtered so increment files/directories
|
---|
[41] | 240 |
|
---|
| 241 | push bp
|
---|
| 242 | push si
|
---|
[53] | 243 | push dx
|
---|
[46] | 244 | push cx
|
---|
[41] | 245 | call .FormatFileOrDirectoryToBufferFromDTAinDSSI
|
---|
[46] | 246 | pop cx
|
---|
[53] | 247 | pop dx
|
---|
[41] | 248 | pop si
|
---|
| 249 | pop bp
|
---|
| 250 | ret
|
---|
| 251 |
|
---|
| 252 | ;--------------------------------------------------------------------
|
---|
[53] | 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
|
---|
[170] | 267 | je SHORT .ReturnWithFiltering
|
---|
[53] | 268 | ret
|
---|
| 269 |
|
---|
| 270 | ALIGN JUMP_ALIGN
|
---|
| 271 | .FilterUpDirectoryWhenInRoot:
|
---|
| 272 | test dl, dl ; Set ZF if root directory selected
|
---|
| 273 | jnz SHORT .ReturnWithoutFiltering
|
---|
| 274 | cmp WORD [si+DTA.szFile], UPDIR_CHARACTERS
|
---|
| 275 | jne SHORT .ReturnWithoutFiltering
|
---|
[170] | 276 | .ReturnWithFiltering:
|
---|
[53] | 277 | add sp, BYTE 2 ; Remove return address from stack
|
---|
| 278 | ALIGN JUMP_ALIGN, ret
|
---|
| 279 | .ReturnWithoutFiltering:
|
---|
| 280 | ret
|
---|
| 281 |
|
---|
| 282 | ;--------------------------------------------------------------------
|
---|
[41] | 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
|
---|
[46] | 298 | ; Fall to .FormatFile
|
---|
[41] | 299 |
|
---|
[46] | 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:
|
---|
[53] | 309 | ; AX, BX, CX, DX, SI, DI
|
---|
[46] | 310 | ;--------------------------------------------------------------------
|
---|
| 311 | .FormatFile:
|
---|
| 312 | xchg si, ax
|
---|
[53] | 313 | call String_ConvertDSSItoLowerCase
|
---|
[46] | 314 | xchg ax, si
|
---|
[52] | 315 |
|
---|
| 316 | ; Push parameters for file name
|
---|
[53] | 317 | push ax ; Push file name offset
|
---|
| 318 | push ds ; Push file name segment
|
---|
[46] | 319 |
|
---|
| 320 | ; Push parameters for file size
|
---|
[41] | 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
|
---|
[46] | 332 |
|
---|
| 333 | ; Format to buffer
|
---|
[41] | 334 | mov si, g_szFileFormat
|
---|
| 335 | jmp SHORT .FormatStringInCSSIandReturn
|
---|
| 336 |
|
---|
[46] | 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:
|
---|
[53] | 346 | ; AX, SI, DI
|
---|
[46] | 347 | ;--------------------------------------------------------------------
|
---|
[41] | 348 | ALIGN JUMP_ALIGN
|
---|
| 349 | .FormatDirectory:
|
---|
[46] | 350 | push ax ; Push directory name offset
|
---|
| 351 | push ds ; Push directory name segment
|
---|
[41] | 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 | ;--------------------------------------------------------------------
|
---|
[46] | 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:
|
---|
[53] | 370 | ; ES:DI: Ptr to end of directory contents string
|
---|
[46] | 371 | ; Corrupts registers:
|
---|
[53] | 372 | ; AX, BX, CX, DX, SI, DS
|
---|
[46] | 373 | ;--------------------------------------------------------------------
|
---|
| 374 | ALIGN JUMP_ALIGN
|
---|
| 375 | SortDirectoryContentsStringFromESDIwithCountInCX:
|
---|
[106] | 376 | call Registers_CopyESDItoDSSI
|
---|
[53] | 377 | call .AddDirectoryContentsStringLengthToDI
|
---|
[46] | 378 | mov bx, .FileStringComparator
|
---|
| 379 | xchg dx, cx
|
---|
| 380 | mov cx, FILE_STRING_LENGTH
|
---|
| 381 | jmp Sort_ItemsFromDSSIwithCountInDXsizeInCXandComparatorInBX
|
---|
| 382 |
|
---|
[53] | 383 | ALIGN JUMP_ALIGN
|
---|
| 384 | .AddDirectoryContentsStringLengthToDI:
|
---|
| 385 | mov ax, FILE_STRING_LENGTH
|
---|
| 386 | mul cx
|
---|
| 387 | add di, ax
|
---|
| 388 | ret
|
---|
| 389 |
|
---|
[46] | 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 | ;--------------------------------------------------------------------
|
---|
[54] | 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 | ;--------------------------------------------------------------------
|
---|
[41] | 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:
|
---|
[46] | 495 | mov ax, [si]
|
---|
| 496 | cmp ax, UPDIR_CHARACTERS
|
---|
| 497 | je SHORT .ChangeToUpdir
|
---|
| 498 | call Char_IsUpperCaseLetterInAL
|
---|
| 499 | jc SHORT .ParseAndChangeToSubdirInDSSI
|
---|
[141] | 500 | call Char_IsDecimalDigitInAL
|
---|
| 501 | jc SHORT .ParseAndChangeToSubdirInDSSI ; Assume subdir and check for errors
|
---|
[46] | 502 | ; Fall to .ParseAndSelectFileFromDSSI
|
---|
[41] | 503 |
|
---|
| 504 | ;--------------------------------------------------------------------
|
---|
[46] | 505 | ; .ParseAndSelectFileFromDSSI
|
---|
[41] | 506 | ; Parameters:
|
---|
[46] | 507 | ; DS:SI: NULL terminated string selected from dialog
|
---|
[41] | 508 | ; SS:BP: Ptr to DIALOG
|
---|
| 509 | ; Returns:
|
---|
| 510 | ; Nothing (exits dialog)
|
---|
| 511 | ; Corrupts registers:
|
---|
| 512 | ; All, except BP
|
---|
| 513 | ;--------------------------------------------------------------------
|
---|
[46] | 514 | .ParseAndSelectFileFromDSSI:
|
---|
[41] | 515 | les di, [bp+DIALOG.fpDialogIO]
|
---|
| 516 | add di, BYTE FILE_DIALOG_IO.szFile
|
---|
| 517 | mov cx, FILENAME_BUFFER_SIZE-1
|
---|
[50] | 518 | call Memory_CopyCXbytesFromDSSItoESDI
|
---|
[41] | 519 | xor ax, ax
|
---|
| 520 | stosb ; Terminate with NULL
|
---|
[50] | 521 | jmp SHORT CloseFileDialogAfterSuccessfullSelection
|
---|
[41] | 522 |
|
---|
| 523 | ;--------------------------------------------------------------------
|
---|
[46] | 524 | ; .ChangeToUpdir
|
---|
[41] | 525 | ; Parameters:
|
---|
| 526 | ; SS:BP: Ptr to DIALOG
|
---|
| 527 | ; Returns:
|
---|
| 528 | ; Nothing
|
---|
| 529 | ; Corrupts registers:
|
---|
| 530 | ; All, except BP
|
---|
| 531 | ;--------------------------------------------------------------------
|
---|
| 532 | ALIGN JUMP_ALIGN
|
---|
[46] | 533 | .ChangeToUpdir:
|
---|
[51] | 534 | push cs
|
---|
| 535 | pop ds
|
---|
[46] | 536 | mov si, g_szUpdir
|
---|
| 537 | jmp SHORT .ChangeDirectoryToDSSI
|
---|
| 538 |
|
---|
| 539 | ;--------------------------------------------------------------------
|
---|
| 540 | ; .ParseAndChangeToSubdirInDSSI
|
---|
| 541 | ; Parameters:
|
---|
| 542 | ; DS:SI: NULL terminated string selected from dialog
|
---|
| 543 | ; SS:BP: Ptr to DIALOG
|
---|
| 544 | ; Returns:
|
---|
| 545 | ; Nothing
|
---|
| 546 | ; Corrupts registers:
|
---|
| 547 | ; All, except BP
|
---|
| 548 | ;--------------------------------------------------------------------
|
---|
| 549 | ALIGN JUMP_ALIGN
|
---|
| 550 | .ParseAndChangeToSubdirInDSSI:
|
---|
| 551 | mov BYTE [si+12], NULL ; Terminate with NULL (unnecessary spaces do not matter)
|
---|
| 552 | .ChangeDirectoryToDSSI:
|
---|
[41] | 553 | call Directory_ChangeToPathFromDSSI
|
---|
[141] | 554 | jc SHORT .ParseAndSelectFileFromDSSI ; Must have been a file starting with number
|
---|
[41] | 555 | ; Fall to RefreshFilesToDisplay
|
---|
| 556 |
|
---|
| 557 | ;--------------------------------------------------------------------
|
---|
| 558 | ; RefreshFilesToDisplay
|
---|
| 559 | ; Parameters:
|
---|
| 560 | ; SS:BP: Ptr to DIALOG
|
---|
| 561 | ; Returns:
|
---|
| 562 | ; Nothing
|
---|
| 563 | ; Corrupts registers:
|
---|
| 564 | ; All, except BP
|
---|
| 565 | ;--------------------------------------------------------------------
|
---|
| 566 | ALIGN JUMP_ALIGN
|
---|
| 567 | RefreshFilesToDisplay:
|
---|
[54] | 568 | call ReInitializeMenuinitFromSSBP
|
---|
[41] | 569 | jmp MenuInit_RefreshMenuWindow
|
---|
| 570 |
|
---|
| 571 |
|
---|
| 572 | ;--------------------------------------------------------------------
|
---|
| 573 | ; HandleFunctionKeyFromAH
|
---|
| 574 | ; Parameters:
|
---|
| 575 | ; AH: Scancode for function key
|
---|
| 576 | ; SS:BP: Ptr to DIALOG
|
---|
| 577 | ; Returns:
|
---|
| 578 | ; Nothing
|
---|
| 579 | ; Corrupts registers:
|
---|
| 580 | ; AX, SI, DI, BP
|
---|
| 581 | ;--------------------------------------------------------------------
|
---|
| 582 | ALIGN JUMP_ALIGN
|
---|
| 583 | HandleFunctionKeyFromAH:
|
---|
| 584 | call GetDialogFlagsToAL
|
---|
| 585 | cmp ah, KEY_FILEDIALOG_NEW_FILE_OR_DIR
|
---|
| 586 | je SHORT HandleFunctionKeyForCreatingNewFileOrDirectory
|
---|
| 587 | cmp ah, KEY_FILEDIALOG_SELECT_DIRECTORY
|
---|
| 588 | je SHORT HandleFunctionKeyForSelectingDirectoryInsteadOfFile
|
---|
| 589 | cmp ah, KEY_FILEDIALOG_CHANGE_DRIVE
|
---|
| 590 | je SHORT HandleFunctionKeyForDriveChange
|
---|
| 591 | ReturnWithoutHandlingKeystroke:
|
---|
| 592 | clc ; Event not processed
|
---|
| 593 | ret
|
---|
| 594 |
|
---|
| 595 |
|
---|
| 596 | ;--------------------------------------------------------------------
|
---|
| 597 | ; HandleFunctionKeyForCreatingNewFileOrDirectory
|
---|
| 598 | ; Parameters:
|
---|
| 599 | ; AL: File dialog flags
|
---|
| 600 | ; SS:BP: Ptr to DIALOG
|
---|
| 601 | ; Returns:
|
---|
| 602 | ; Closes file dialog
|
---|
| 603 | ; Corrupts registers:
|
---|
| 604 | ; All, except BP
|
---|
| 605 | ;--------------------------------------------------------------------
|
---|
| 606 | ALIGN JUMP_ALIGN
|
---|
| 607 | HandleFunctionKeyForCreatingNewFileOrDirectory:
|
---|
| 608 | test al, FLG_FILEDIALOG_NEW
|
---|
| 609 | jz SHORT ReturnWithoutHandlingKeystroke
|
---|
| 610 |
|
---|
| 611 | mov cx, STRING_DIALOG_IO_size
|
---|
| 612 | call Memory_ReserveCXbytesFromStackToDSSI
|
---|
| 613 | call .InitializeStringDialogIoInDSSIforInputtingFileName
|
---|
| 614 |
|
---|
| 615 | CALL_MENU_LIBRARY GetStringWithIoInDSSI
|
---|
| 616 | mov al, [si+STRING_DIALOG_IO.bUserCancellation]
|
---|
| 617 | add sp, BYTE STRING_DIALOG_IO_size
|
---|
| 618 | test al, al ; User cancellation?
|
---|
| 619 | jnz SHORT ReturnWithoutHandlingKeystroke
|
---|
| 620 | jmp CloseFileDialogAfterSuccessfullSelection
|
---|
| 621 |
|
---|
| 622 | ALIGN JUMP_ALIGN
|
---|
| 623 | .InitializeStringDialogIoInDSSIforInputtingFileName:
|
---|
| 624 | call InitializeNullStringsToDialogInputInDSSI
|
---|
| 625 | mov WORD [si+DIALOG_INPUT.fszTitle], g_szEnterNewFileOrDirectory
|
---|
| 626 | mov WORD [si+STRING_DIALOG_IO.fnCharFilter], NULL
|
---|
| 627 | mov WORD [si+STRING_DIALOG_IO.wBufferSize], FILENAME_BUFFER_SIZE
|
---|
| 628 | les ax, [bp+DIALOG.fpDialogIO]
|
---|
| 629 | add ax, BYTE FILE_DIALOG_IO.szFile
|
---|
| 630 | mov [si+STRING_DIALOG_IO.fpReturnBuffer], ax
|
---|
| 631 | mov [si+STRING_DIALOG_IO.fpReturnBuffer+2], es
|
---|
| 632 | ret
|
---|
| 633 |
|
---|
| 634 |
|
---|
| 635 | ;--------------------------------------------------------------------
|
---|
| 636 | ; HandleFunctionKeyForSelectingDirectoryInsteadOfFile
|
---|
| 637 | ; Parameters:
|
---|
| 638 | ; AL: File dialog flags
|
---|
| 639 | ; SS:BP: Ptr to DIALOG
|
---|
| 640 | ; Returns:
|
---|
| 641 | ; Closes file dialog
|
---|
| 642 | ; Corrupts registers:
|
---|
| 643 | ; All, except BP
|
---|
| 644 | ;--------------------------------------------------------------------
|
---|
| 645 | ALIGN JUMP_ALIGN
|
---|
| 646 | HandleFunctionKeyForSelectingDirectoryInsteadOfFile:
|
---|
| 647 | test al, FLG_FILEDIALOG_DIRECTORY
|
---|
| 648 | jz SHORT ReturnWithoutHandlingKeystroke
|
---|
| 649 | ; Fall to CloseFileDialogAfterSuccessfullSelection
|
---|
| 650 |
|
---|
| 651 | ;--------------------------------------------------------------------
|
---|
| 652 | ; CloseFileDialogAfterSuccessfullSelection
|
---|
| 653 | ; Parameters:
|
---|
| 654 | ; SS:BP: Ptr to DIALOG
|
---|
| 655 | ; Returns:
|
---|
| 656 | ; Nothing (exits dialog)
|
---|
| 657 | ; Corrupts registers:
|
---|
| 658 | ; All, except BP
|
---|
| 659 | ;--------------------------------------------------------------------
|
---|
| 660 | ALIGN JUMP_ALIGN
|
---|
| 661 | CloseFileDialogAfterSuccessfullSelection:
|
---|
| 662 | lds di, [bp+DIALOG.fpDialogIO]
|
---|
| 663 | mov BYTE [di+FILE_DIALOG_IO.bUserCancellation], FALSE
|
---|
| 664 | jmp MenuInit_CloseMenuWindow
|
---|
| 665 |
|
---|
| 666 |
|
---|
| 667 | ;--------------------------------------------------------------------
|
---|
| 668 | ; HandleFunctionKeyForDriveChange
|
---|
| 669 | ; Parameters:
|
---|
| 670 | ; AL: File dialog flags
|
---|
| 671 | ; SS:BP: Ptr to DIALOG
|
---|
| 672 | ; Returns:
|
---|
| 673 | ; Nothing
|
---|
| 674 | ; Corrupts registers:
|
---|
| 675 | ; All, except BP
|
---|
| 676 | ;--------------------------------------------------------------------
|
---|
| 677 | ALIGN JUMP_ALIGN
|
---|
| 678 | HandleFunctionKeyForDriveChange:
|
---|
| 679 | test al, FLG_FILEDIALOG_DRIVES
|
---|
| 680 | jz SHORT ReturnWithoutHandlingKeystroke
|
---|
| 681 |
|
---|
[54] | 682 | call DisplayLoadingMessageInInformationArea
|
---|
| 683 | mov cx, DRIVE_DIALOG_IO_size
|
---|
| 684 | call Memory_ReserveCXbytesFromStackToDSSI
|
---|
| 685 | call .DisplayDriveSelectionDialogWithIoInDSSI
|
---|
| 686 | call .ChangeDriveToUserSelectionFromIoInDSSI
|
---|
| 687 | add sp, BYTE DRIVE_DIALOG_IO_size
|
---|
| 688 | ret
|
---|
[41] | 689 |
|
---|
| 690 | ;--------------------------------------------------------------------
|
---|
[54] | 691 | ; .DisplayDriveSelectionDialogWithIoInDSSI
|
---|
[41] | 692 | ; Parameters:
|
---|
[54] | 693 | ; DS:SI: Ptr to uninitialized DRIVE_DIALOG_IO
|
---|
[41] | 694 | ; SS:BP: Ptr to DIALOG
|
---|
| 695 | ; Returns:
|
---|
[54] | 696 | ; DS:SI: Ptr to DRIVE_DIALOG_IO
|
---|
[41] | 697 | ; Corrupts registers:
|
---|
[54] | 698 | ; AX, DI
|
---|
[41] | 699 | ;--------------------------------------------------------------------
|
---|
| 700 | ALIGN JUMP_ALIGN
|
---|
[54] | 701 | .DisplayDriveSelectionDialogWithIoInDSSI:
|
---|
[41] | 702 | call InitializeNullStringsToDialogInputInDSSI
|
---|
| 703 | mov WORD [si+DIALOG_INPUT.fszTitle], g_szSelectNewDrive
|
---|
[54] | 704 | CALL_MENU_LIBRARY GetDriveWithIoInDSSI
|
---|
| 705 | ret
|
---|
[41] | 706 |
|
---|
| 707 | ;--------------------------------------------------------------------
|
---|
[54] | 708 | ; .ChangeDriveToUserSelectionFromIoInDSSI
|
---|
[41] | 709 | ; Parameters:
|
---|
[54] | 710 | ; DS:SI: Ptr to DRIVE_DIALOG_IO
|
---|
[41] | 711 | ; SS:BP: Ptr to DIALOG
|
---|
| 712 | ; Returns:
|
---|
| 713 | ; Nothing
|
---|
| 714 | ; Corrupts registers:
|
---|
[54] | 715 | ; All, except BP
|
---|
[41] | 716 | ;--------------------------------------------------------------------
|
---|
| 717 | ALIGN JUMP_ALIGN
|
---|
[54] | 718 | .ChangeDriveToUserSelectionFromIoInDSSI:
|
---|
| 719 | cmp BYTE [si+DRIVE_DIALOG_IO.bUserCancellation], FALSE
|
---|
| 720 | jne SHORT .UserCancelledDriveChange
|
---|
[41] | 721 |
|
---|
[54] | 722 | mov dl, [si+DRIVE_DIALOG_IO.bReturnDriveNumber]
|
---|
| 723 | call Drive_SetDefaultFromDL
|
---|
| 724 | jmp RefreshFilesToDisplay
|
---|
| 725 | .UserCancelledDriveChange:
|
---|
[41] | 726 | ret
|
---|
| 727 |
|
---|
| 728 |
|
---|
| 729 | ;--------------------------------------------------------------------
|
---|
[54] | 730 | ; DisplayLoadingMessageInInformationArea
|
---|
[53] | 731 | ; Parameters:
|
---|
[54] | 732 | ; SS:BP: Ptr to DIALOG
|
---|
[53] | 733 | ; Returns:
|
---|
| 734 | ; Nothing
|
---|
| 735 | ; Corrupts registers:
|
---|
[54] | 736 | ; AX, BX, CX, DX, SI, DI
|
---|
[53] | 737 | ;--------------------------------------------------------------------
|
---|
| 738 | ALIGN JUMP_ALIGN
|
---|
[54] | 739 | DisplayLoadingMessageInInformationArea:
|
---|
| 740 | call MenuText_ClearInformationArea
|
---|
| 741 | call MenuText_PrepareToDrawInformationArea
|
---|
| 742 | mov si, g_szLoadingPleaseWait
|
---|
| 743 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
[53] | 744 | ret
|
---|
| 745 |
|
---|
| 746 |
|
---|
| 747 | ;--------------------------------------------------------------------
|
---|
[41] | 748 | ; InitializeNullStringsToDialogInputInDSSI
|
---|
| 749 | ; Parameters:
|
---|
| 750 | ; DS:SI: Ptr to DIALOG_INPUT
|
---|
| 751 | ; SS:BP: Ptr to DIALOG
|
---|
| 752 | ; Returns:
|
---|
| 753 | ; Nothing
|
---|
| 754 | ; Corrupts registers:
|
---|
| 755 | ; AX
|
---|
| 756 | ;--------------------------------------------------------------------
|
---|
| 757 | ALIGN JUMP_ALIGN
|
---|
| 758 | InitializeNullStringsToDialogInputInDSSI:
|
---|
| 759 | mov ax, g_szNull
|
---|
| 760 | mov [si+DIALOG_INPUT.fszTitle], ax
|
---|
| 761 | mov [si+DIALOG_INPUT.fszTitle+2], cs
|
---|
| 762 | mov [si+DIALOG_INPUT.fszItems], ax
|
---|
| 763 | mov [si+DIALOG_INPUT.fszItems+2], cs
|
---|
| 764 | mov [si+DIALOG_INPUT.fszInfo], ax
|
---|
| 765 | mov [si+DIALOG_INPUT.fszInfo+2], cs
|
---|
| 766 | ret
|
---|