Index: trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm	(revision 53)
+++ trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm	(revision 54)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	6.9.2010
-; Last update	:	13.10.2010
+; Last update	:	24.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Displays file dialog.
@@ -49,5 +49,5 @@
 .ItemSelectedFromCX:
 	call	LoadItemStringBufferToESDI
-	call	Memory_CopyESDItoDSSI
+	call	Registers_CopyESDItoDSSI
 	call	ItemLineSplitter_GetLineToDSSIandLengthToCXfromStringInDSSIwithIndexInCX
 	jmp		ParseSelectionFromItemLineInDSSI
@@ -113,7 +113,7 @@
 
 ;--------------------------------------------------------------------
+; ReInitializeMenuinitFromSSBP
 ; InitializeMenuinitFromSSBP
 ;	Parameters:
-;		DS:SI:		Ptr to MENUINIT to initialize (also points to DIALOG)
 ;		SS:BP:		Ptr to DIALOG
 ;	Returns:
@@ -123,4 +123,6 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
+ReInitializeMenuinitFromSSBP:
+	call	DisplayLoadingMessageInInformationArea
 InitializeMenuinitFromSSBP:
 	call	LoadItemStringBufferToESDI
@@ -129,5 +131,6 @@
 	call	SortDirectoryContentsStringFromESDIwithCountInCX
 	call	RemoveLastLFandTerminateESDIwithNull
-	call	Memory_CopySSBPtoDSSI
+
+	call	Registers_CopySSBPtoDSSI
 	xor		ax, ax
 	call	Dialog_EventInitializeMenuinitFromDSSIwithHighlightedItemInAX
@@ -199,5 +202,5 @@
 ALIGN JUMP_ALIGN
 .ClearDLifInRootDirectory:
-	call	Memory_CopyESDItoDSSI
+	call	Registers_CopyESDItoDSSI
 	call	Directory_WriteCurrentPathToDSSI
 	mov		dl, [si]
@@ -375,5 +378,5 @@
 ALIGN JUMP_ALIGN
 SortDirectoryContentsStringFromESDIwithCountInCX:
-	call	Memory_CopyESDItoDSSI
+	call	Registers_CopyESDItoDSSI
 	call	.AddDirectoryContentsStringLengthToDI
 	mov		bx, .FileStringComparator
@@ -431,4 +434,21 @@
 	cmp		bh, bl
 	jmp		SHORT .ReturnFromComparison
+
+
+;--------------------------------------------------------------------
+; RemoveLastLFandTerminateESDIwithNull
+;	Parameters:
+;		ES:DI:	Ptr to end of buffer to terminate
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+RemoveLastLFandTerminateESDIwithNull:
+	dec		di
+	xor		ax, ax
+	stosb
+	ret
 
 
@@ -547,5 +567,5 @@
 ALIGN JUMP_ALIGN
 RefreshFilesToDisplay:
-	call	InitializeMenuinitFromSSBP
+	call	ReInitializeMenuinitFromSSBP
 	jmp		MenuInit_RefreshMenuWindow
 
@@ -661,117 +681,66 @@
 	jz		SHORT ReturnWithoutHandlingKeystroke
 
-	call	.ShowDriveSelectionDialogAndGetDriveNumberToDL
-	jnc		SHORT RefreshFilesToDisplay
+	call	DisplayLoadingMessageInInformationArea
+	mov		cx, DRIVE_DIALOG_IO_size
+	call	Memory_ReserveCXbytesFromStackToDSSI
+	call	.DisplayDriveSelectionDialogWithIoInDSSI
+	call	.ChangeDriveToUserSelectionFromIoInDSSI
+	add		sp, BYTE DRIVE_DIALOG_IO_size
+	ret
+
+;--------------------------------------------------------------------
+; .DisplayDriveSelectionDialogWithIoInDSSI
+;	Parameters:
+;		DS:SI:	Ptr to uninitialized DRIVE_DIALOG_IO
+;		SS:BP:	Ptr to DIALOG
+;	Returns:
+;		DS:SI:	Ptr to DRIVE_DIALOG_IO
+;	Corrupts registers:
+;		AX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.DisplayDriveSelectionDialogWithIoInDSSI:
+	call	InitializeNullStringsToDialogInputInDSSI
+	mov		WORD [si+DIALOG_INPUT.fszTitle], g_szSelectNewDrive
+	CALL_MENU_LIBRARY GetDriveWithIoInDSSI
+	ret
+
+;--------------------------------------------------------------------
+; .ChangeDriveToUserSelectionFromIoInDSSI
+;	Parameters:
+;		DS:SI:	Ptr to DRIVE_DIALOG_IO
+;		SS:BP:	Ptr to DIALOG
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		All, except BP
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.ChangeDriveToUserSelectionFromIoInDSSI:
+	cmp		BYTE [si+DRIVE_DIALOG_IO.bUserCancellation], FALSE
+	jne		SHORT .UserCancelledDriveChange
+
+	mov		dl, [si+DRIVE_DIALOG_IO.bReturnDriveNumber]
 	call	Drive_SetDefaultFromDL
-	jmp		SHORT RefreshFilesToDisplay
-
-;--------------------------------------------------------------------
-; .ShowDriveSelectionDialogAndGetDriveNumberToDL
-;	Parameters:
-;		SS:BP:	Ptr to DIALOG
-;	Returns:
-;		DL:		Drive selected by user
-;		CF:		Set if new drive selected
-;				Cleared if selection cancelled by user
-;	Corrupts registers:
-;		All, except BP
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.ShowDriveSelectionDialogAndGetDriveNumberToDL:
-	mov		cx, DIALOG_INPUT_size
-	call	Memory_ReserveCXbytesFromStackToDSSI
-	call	.InitializeDialogInputInDSSIforDriveSelection
-	call	DialogSelection_GetSelectionToAXwithInputInDSSI
-	add		sp, BYTE DIALOG_INPUT_size
-	cmp		ax, BYTE NO_ITEM_SELECTED	; Clear CF if equal
-	jne		SHORT .ConvertDriveNumberToDLfromItemIndexInAX
-	ret
-
-ALIGN JUMP_ALIGN
-.InitializeDialogInputInDSSIforDriveSelection:
-	call	InitializeNullStringsToDialogInputInDSSI
-	call	LoadItemStringBufferToESDI
-	mov		WORD [si+DIALOG_INPUT.fszTitle], g_szSelectNewDrive
-	mov		[si+DIALOG_INPUT.fszItems], di
-	mov		[si+DIALOG_INPUT.fszItems+2], es
-	call	Drive_GetFlagsForAvailableDrivesToDXAX
-	; Fall to .GenerateDriveSelectionStringToESDIfromDriveFlagsInDXAX
-
-;--------------------------------------------------------------------
-; .GenerateDriveSelectionStringToESDIfromDriveFlagsInDXAX
-;	Parameters:
-;		DX:AX:	Drive letter flags
-;		ES:DI:	Ptr to item string buffer
-;		SS:BP:	Ptr to DIALOG
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, BX, CX, DX, DI, ES
-;--------------------------------------------------------------------
-;ALIGN JUMP_ALIGN
-.GenerateDriveSelectionStringToESDIfromDriveFlagsInDXAX:
-	cld
-	xchg	cx, ax
-	mov		ax, 3A41h		; A:
-ALIGN JUMP_ALIGN
-.BitShiftLoop:
-	shr		dx, 1
-	rcr		cx, 1
-	jnc		SHORT .CheckIfMoreDrivesLeft
-	stosw
-	mov		BYTE [es:di], LF
-	inc		di
-ALIGN JUMP_ALIGN
-.CheckIfMoreDrivesLeft:
-	inc		ax				; Next drive letter
-	mov		bx, dx
-	or		bx, cx
-	jnz		SHORT .BitShiftLoop
-	jmp		SHORT TerminateESDIwithNull
-
-;--------------------------------------------------------------------
-; .ConvertDriveNumberToDLfromItemIndexInAX
-;	Parameters:
-;		AX:		Selected drive item	
-;	Returns:
-;		DL:		Drive number
-;		CF:		Set since drive selected
-;	Corrupts registers:
-;		AX, CX, DH
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.ConvertDriveNumberToDLfromItemIndexInAX:
-	mov		ah, -1
-	xchg	cx, ax
-	call	Drive_GetFlagsForAvailableDrivesToDXAX
-ALIGN JUMP_ALIGN
-.BitScanLoop:
-	shr		dx, 1
-	rcr		ax, 1
-	inc		ch				; Increment drive number
-	sbb		cl, 0			; Decrement selection index
-	jnc		SHORT .BitScanLoop
-	mov		dl, ch
-	stc						; Drive selected by user
-	ret
-
-
-;--------------------------------------------------------------------
-; RemoveLastLFandTerminateESDIwithNull
-; TerminateESDIwithNull
-;	Parameters:
-;		ES:DI:	Ptr to end of buffer to terminate
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-RemoveLastLFandTerminateESDIwithNull:
-	dec		di
-ALIGN JUMP_ALIGN
-TerminateESDIwithNull:
-	xor		ax, ax
-	stosb
+	jmp		RefreshFilesToDisplay
+.UserCancelledDriveChange:
+	ret
+
+
+;--------------------------------------------------------------------
+; DisplayLoadingMessageInInformationArea
+;	Parameters:
+;		SS:BP:		Ptr to DIALOG
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, CX, DX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+DisplayLoadingMessageInInformationArea:
+	call	MenuText_ClearInformationArea
+	call	MenuText_PrepareToDrawInformationArea
+	mov		si, g_szLoadingPleaseWait
+	CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
 	ret
 
