Index: trunk/Assembly_Library/Inc/AssemblyLibrary.inc
===================================================================
--- trunk/Assembly_Library/Inc/AssemblyLibrary.inc	(revision 47)
+++ trunk/Assembly_Library/Inc/AssemblyLibrary.inc	(revision 48)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	2.7.2010
-; Last update	:	16.9.2010
+; Last update	:	8.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Common defines for all library functions.
@@ -12,4 +12,5 @@
 %include "BiosData.inc"
 %include "BiosFunctions.inc"
+%include "CgaSnow.inc"
 %include "Debug.inc"
 %include "DosFunctions.inc"
Index: trunk/Assembly_Library/Inc/CgaSnow.inc
===================================================================
--- trunk/Assembly_Library/Inc/CgaSnow.inc	(revision 48)
+++ trunk/Assembly_Library/Inc/CgaSnow.inc	(revision 48)
@@ -0,0 +1,69 @@
+; File name		:	CgaSnow.inc
+; Project name	:	AssemblyLibrary
+; Created date	:	8.10.2010
+; Last update	:	8.10.2010
+; Author		:	Tomi Tilli
+; Description	:	Macros for preventing CGA snow.
+%ifndef CGASNOW_INC
+%define CGASNOW_INC
+
+;--------------------------------------------------------------------
+; WAIT_RETRACE_IF_NECESSARY_THEN
+;	Parameters:
+;		%1:		Instruction that accessed CGA memory
+;		AL:		Character to output
+;		AH:		Attribute to output (stosw only)
+;		DS:		BDA segment (zero)
+;		ES:SI:	Ptr to video memory where to read from (if %1 reads)
+;		ES:DI:	Ptr to video memory where to output (if %1 writes)
+;	Returns:
+;		SI, DI:	Updated according to instruction
+;	Corrupts registers:
+;		AX, DX
+;--------------------------------------------------------------------
+%macro WAIT_RETRACE_IF_NECESSARY_THEN 1
+%ifdef ELIMINATE_CGA_SNOW
+	%ifidn %1, stosb
+		call	CgaSnow_StosbWithoutCgaSnow
+	%elifidn %1, stosw
+		call	CgaSnow_StoswWithoutCgaSnow
+	%elifidn %1, scasb
+		call	CgaSnow_ScasbWithoutCgaSnow
+	%elifidn %1, rep movsb
+		call	CgaSnow_RepMovsbWithoutCgaSnow
+	%else
+		%error	"Invalid instruction passed to WAIT_RETRACE_IF_NECESSARY_THEN"
+	%endif
+%else	; No CGA snow prevention
+	%ifidn %1, rep movsb
+		eSEG_STR rep, es, movsb
+	%else
+		%1	; Single instruction
+	%endif
+%endif
+%endmacro
+
+
+;--------------------------------------------------------------------
+; WAIT_UNTIL_SAFE_CGA_WRITE
+;	Parameters:
+;		DX:		CGA Status Register Address (3DAh)
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AL
+;--------------------------------------------------------------------
+%macro WAIT_UNTIL_SAFE_CGA_WRITE 0
+%%WaitUntilNotInRetrace:
+	in		al, dx
+	shr		al, 1	; 1 = Bit 0: A 1 indicates that regen-buffer memory access can be
+					; made without interfering with the display. (H or V retrace)
+	jc		SHORT %%WaitUntilNotInRetrace
+%%WaitUntilNextRetraceStarts:
+	in		al, dx
+	shr		al, 1
+	jnc		SHORT %%WaitUntilNextRetraceStarts
+%endmacro
+
+
+%endif ; CGASNOW_INC
Index: trunk/Assembly_Library/Inc/Display.inc
===================================================================
--- trunk/Assembly_Library/Inc/Display.inc	(revision 47)
+++ trunk/Assembly_Library/Inc/Display.inc	(revision 48)
@@ -2,5 +2,5 @@
 ; Project name	:	AssemblyLibrary
 ; Created date	:	25.6.2010
-; Last update	:	28.9.2010
+; Last update	:	6.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Defines for display library.
@@ -26,4 +26,6 @@
 	%elifidn %1, PopDisplayContext
 		call	DisplayContext_Pop
+	%elifidn %1, PrepareOffScreenBufferInESBXtoESDI
+		call	DisplayContext_PrepareOffScreenBufferInESBXtoESDI
 	%else
 		mov		di, DISPLAY_LIB.%1
@@ -37,4 +39,5 @@
 	.PushDisplayContext:
 	.PopDisplayContext:
+	.PrepareOffScreenBufferInESBXtoESDI:
 	.InitializeDisplayContext						resb	2
 
@@ -181,4 +184,7 @@
 COLOR_TEXT_SEGMENT			EQU		0B800h	; Text modes 0...3 (CGA+)
 MONO_TEXT_SEGMENT			EQU		0B000h	; Text mode 7 (MDA, Hercules)
+
+OFFSET_TO_CGA_STATUS_REGISTER	EQU		6	; Base port 3D4h + 6 = 3DAh
+CGA_STATUS_REGISTER				EQU		3DAh
 
 
Index: trunk/Assembly_Library/Inc/Menu.inc
===================================================================
--- trunk/Assembly_Library/Inc/Menu.inc	(revision 47)
+++ trunk/Assembly_Library/Inc/Menu.inc	(revision 48)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	13.7.2010
-; Last update	:	15.9.2010
+; Last update	:	5.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Defines for Menu library.
@@ -35,4 +35,7 @@
 		call	MenuInit_SetTitleHeightFromAL
 
+	%elifidn %1, GetHighlightedItemToAX
+		call	MenuInit_GetHighlightedItemToAX
+
 	%elifidn %1, SetTotalItemsFromAX
 		call	MenuInit_SetTotalItemsFromAX
@@ -60,6 +63,8 @@
 
 	.SetTitleHeightFromAL:
+	.ClearTitleArea								resb	2
 	.RefreshTitle								resb	2
 
+	.GetHighlightedItemToAX:
 	.HighlightItemFromAX						resb	2
 	.SetTotalItemsFromAX:
@@ -67,4 +72,5 @@
 
 	.SetInformationHeightFromAL:
+	.ClearInformationArea						resb	2
 	.RefreshInformation							resb	2
 
@@ -130,4 +136,5 @@
 NO_ITEM_SELECTED					EQU		-1
 NO_ITEM_HIGHLIGHTED					EQU		-1
+NO_TIMEOUT_USED						EQU		0
 
 
Index: trunk/Assembly_Library/Inc/MenuEvents.inc
===================================================================
--- trunk/Assembly_Library/Inc/MenuEvents.inc	(revision 47)
+++ trunk/Assembly_Library/Inc/MenuEvents.inc	(revision 48)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	13.7.2010
-; Last update	:	11.8.2010
+; Last update	:	5.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Defines for Menu events send to the user.
@@ -49,5 +49,6 @@
 
 	; Parameters:
-	;	None but cursor has been positioned to the beginning of first line
+	;	CX:			Index of highlighted item
+	;	Cursor has been positioned to the beginning of first line
 	.RefreshTitle					resb	2
 	.RefreshInformation				resb	2
Index: trunk/Assembly_Library/Src/AssemblyLibrary.asm
===================================================================
--- trunk/Assembly_Library/Src/AssemblyLibrary.asm	(revision 47)
+++ trunk/Assembly_Library/Src/AssemblyLibrary.asm	(revision 48)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	15.9.2010
-; Last update	:	29.9.2010
+; Last update	:	8.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Assembly Library main file. This is the only file that
@@ -11,4 +11,5 @@
 
 %ifdef INCLUDE_DISPLAY_LIBRARY
+	%include "CgaSnow.asm"
 	%include "Display.asm"
 	%include "DisplayCharOut.asm"
Index: trunk/Assembly_Library/Src/Display/CgaSnow.asm
===================================================================
--- trunk/Assembly_Library/Src/Display/CgaSnow.asm	(revision 48)
+++ trunk/Assembly_Library/Src/Display/CgaSnow.asm	(revision 48)
@@ -0,0 +1,146 @@
+; File name		:	CgaSnow.asm
+; Project name	:	Assembly Library
+; Created date	:	8.10.2010
+; Last update	:	8.10.2010
+; Author		:	Tomi Tilli
+; Description	:	Functions for preventing CGA snow.
+
+; Section containing code
+SECTION .text
+
+
+; CGA snow preventing must be kept optional so unnecerrasy overhead
+; can be prevented when building program ment for non-CGA systems.
+%ifdef ELIMINATE_CGA_SNOW
+
+;--------------------------------------------------------------------
+; CgaSnow_StosbWithoutCgaSnow
+; CgaSnow_StoswWithoutCgaSnow
+;	Parameters:
+;		AL:		Character to output
+;		AH:		Attribute to output (CgaSnow_StoswWithoutCgaSnow only)
+;		DS:		BDA segment (zero)
+;		ES:DI:	Ptr to video memory where to output
+;	Returns:
+;		DI:		Incremented for next character
+;	Corrupts registers:
+;		AX, DX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+CgaSnow_StosbWithoutCgaSnow:
+	call	LoadAndVerifyStatusRegisterFromBDA
+	jne		SHORT .StosbWithoutWaitSinceUnknownPort
+
+	mov		ah, al
+	cli				; Interrupt request would mess up timing
+	WAIT_UNTIL_SAFE_CGA_WRITE
+	mov		al, ah
+.StosbWithoutWaitSinceUnknownPort:
+	stosb
+	sti
+	ret
+
+ALIGN JUMP_ALIGN
+CgaSnow_StoswWithoutCgaSnow:
+	push	bx
+	call	LoadAndVerifyStatusRegisterFromBDA
+	jne		SHORT .StoswWithoutWaitSinceUnknownPort
+
+	xchg	bx, ax
+	cli				; Interrupt request would mess up timing
+	WAIT_UNTIL_SAFE_CGA_WRITE
+	xchg	ax, bx
+.StoswWithoutWaitSinceUnknownPort:
+	stosw
+	pop		bx
+	sti
+	ret
+
+
+;--------------------------------------------------------------------
+; CgaSnow_ScasbWithoutCgaSnow
+;	Parameters:
+;		AL:		Byte for comparison
+;		DS:		BDA segment (zero)
+;		ES:DI:	Ptr to video memory where to output
+;	Returns:
+;		DI:		Incremented for next character
+;	Corrupts registers:
+;		AX, DX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+CgaSnow_ScasbWithoutCgaSnow:
+	call	LoadAndVerifyStatusRegisterFromBDA
+	jne		SHORT .ScasbWithoutWaitSinceUnknownPort
+
+	mov		ah, al
+	cli				; Interrupt request would mess up timing
+	WAIT_UNTIL_SAFE_CGA_WRITE
+.ScasbWithoutWaitSinceUnknownPort:
+	mov		al, ah
+	scasb
+	sti
+	ret
+
+
+;--------------------------------------------------------------------
+; CgaSnow_RepMovsbWithoutCgaSnow
+;	Parameters:
+;		CX:		Number of characters to copy
+;		DS:		BDA segment (zero)
+;		ES:SI:	Ptr to video memory where to read from
+;		ES:DI:	Ptr to video memory where to write to
+;	Returns:
+;		SI, DI:	Updated for next character
+;	Corrupts registers:
+;		AX, CX, DX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+CgaSnow_RepMovsbWithoutCgaSnow:
+	call	LoadAndVerifyStatusRegisterFromBDA
+	jne		SHORT .RepMovsbWithoutWaitSinceUnknownPort
+
+.MovsbNextByte:
+	cli				; Interrupt request would mess up timing
+	WAIT_UNTIL_SAFE_CGA_WRITE
+	eSEG	es
+	movsb
+	sti
+	loop	.MovsbNextByte
+	ret
+.RepMovsbWithoutWaitSinceUnknownPort:
+	eSEG_STR rep, es, movsb
+	ret
+
+
+;--------------------------------------------------------------------
+; LoadAndVerifyStatusRegisterFromBDA
+;	Parameters:
+;		DS:		BDA segment (zero)
+;	Returns:
+;		DX:		CGA Status Register Address
+;		ZF:		Set if CGA Base Port found in BDA
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+LoadAndVerifyStatusRegisterFromBDA:
+	mov		dx, [BDA.wVidPort]
+	add		dl, OFFSET_TO_CGA_STATUS_REGISTER
+	cmp		dx, CGA_STATUS_REGISTER
+	je		SHORT .CheckIfEgaOrLater
+	ret
+
+ALIGN JUMP_ALIGN
+.CheckIfEgaOrLater:
+	push	ax
+	call	DisplayPage_GetColumnsToALandRowsToAH
+	cmp		ah, [BDA.bVidRows]		; Video rows stored only by EGA and later
+	lahf
+	xor		ah, 1<<6				; Invert ZF
+	sahf
+	pop		ax
+	ret
+
+
+%endif ; ELIMINATE_CGA_SNOW
Index: trunk/Assembly_Library/Src/Display/DisplayCharOut.asm
===================================================================
--- trunk/Assembly_Library/Src/Display/DisplayCharOut.asm	(revision 47)
+++ trunk/Assembly_Library/Src/Display/DisplayCharOut.asm	(revision 48)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	26.6.2010
-; Last update	:	4.10.2010
+; Last update	:	8.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Functions for outputting characters to video memory.
@@ -11,29 +11,4 @@
 ; Section containing code
 SECTION .text
-
-;--------------------------------------------------------------------
-; WAIT_RETRACE_IF_NECESSARY_THEN
-;	Parameters:
-;		AL:		Character to output
-;		AH:		Attribute to output (stosw only)
-;		DS:		BDA segment (zero)
-;		ES:DI:	Ptr to video memory where to output
-;	Returns:
-;		DI:		Incremented for next character
-;	Corrupts registers:
-;		AX, DX
-;--------------------------------------------------------------------
-%macro WAIT_RETRACE_IF_NECESSARY_THEN 1
-%ifdef ELIMINATE_CGA_SNOW
-	%ifidn %1, stosb
-		call	StosbWithoutCgaSnow
-	%else
-		call	StoswWithoutCgaSnow
-	%endif
-%else
-	%1			; STOSB or STOSW
-%endif
-%endmacro
-
 
 ;--------------------------------------------------------------------
@@ -155,94 +130,2 @@
 .BufferFull:
 	ret
-
-
-; STOSB and STOSW replacement functions to prevent CGA snow. These will slow
-; drawing a lot so use them only if it is necessary to eliminate CGA snow.
-%ifdef ELIMINATE_CGA_SNOW
-
-OFFSET_TO_CGA_STATUS_REGISTER	EQU		6		; Base port 3D4h + 6 = 3DAh
-CGA_STATUS_REGISTER				EQU		3DAh
-
-;--------------------------------------------------------------------
-; WAIT_UNTIL_SAFE_CGA_WRITE
-;	Parameters:
-;		DX:		CGA Status Register Address (3DAh)
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AL
-;--------------------------------------------------------------------
-%macro WAIT_UNTIL_SAFE_CGA_WRITE 0
-%%WaitUntilNotInRetrace:
-	in		al, dx
-	shr		al, 1	; 1 = Bit 0: A 1 indicates that regen-buffer memory access can be
-					; made without interfering with the display. (H or V retrace)
-	jc		SHORT %%WaitUntilNotInRetrace
-%%WaitUntilNextRetraceStarts:
-	in		al, dx
-	shr		al, 1
-	jnc		SHORT %%WaitUntilNextRetraceStarts
-%endmacro
-
-;--------------------------------------------------------------------
-; StosbWithoutCgaSnow
-; StoswWithoutCgaSnow
-;	Parameters:
-;		AL:		Character to output
-;		AH:		Attribute to output (StoswWithoutCgaSnow only)
-;		DS:		BDA segment (zero)
-;		ES:DI:	Ptr to video memory where to output
-;	Returns:
-;		DI:		Incremented for next character
-;	Corrupts registers:
-;		AX, DX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-StosbWithoutCgaSnow:
-	call	DisplayCharOut_LoadAndVerifyStatusRegisterFromBDA
-	jne		SHORT .StosbWithoutWaitSinceUnknownPort
-
-	mov		ah, al
-	cli				; Interrupt request would mess up timing
-	WAIT_UNTIL_SAFE_CGA_WRITE
-	mov		al, ah
-.StosbWithoutWaitSinceUnknownPort:
-	stosb
-	sti
-	ret
-
-ALIGN JUMP_ALIGN
-StoswWithoutCgaSnow:
-	push	bx
-	call	DisplayCharOut_LoadAndVerifyStatusRegisterFromBDA
-	jne		SHORT .StoswWithoutWaitSinceUnknownPort
-
-	xchg	bx, ax
-	cli				; Interrupt request would mess up timing
-	WAIT_UNTIL_SAFE_CGA_WRITE
-	xchg	ax, bx
-.StoswWithoutWaitSinceUnknownPort:
-	stosw
-	pop		bx
-	sti
-	ret
-
-
-;--------------------------------------------------------------------
-; DisplayCharOut_LoadAndVerifyStatusRegisterFromBDA
-;	Parameters:
-;		DS:		BDA segment (zero)
-;	Returns:
-;		DX:		CGA Status Register Address
-;		ZF:		Set if CGA Base Port found in BDA
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-DisplayCharOut_LoadAndVerifyStatusRegisterFromBDA:
-	mov		dx, [BDA.wVidPort]
-	add		dl, OFFSET_TO_CGA_STATUS_REGISTER
-	cmp		dx, CGA_STATUS_REGISTER
-	ret
-
-%endif ; ELIMINATE_CGA_SNOW
Index: trunk/Assembly_Library/Src/Display/DisplayContext.asm
===================================================================
--- trunk/Assembly_Library/Src/Display/DisplayContext.asm	(revision 47)
+++ trunk/Assembly_Library/Src/Display/DisplayContext.asm	(revision 48)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	25.6.2010
-; Last update	:	28.9.2010
+; Last update	:	5.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Functions for managing display context.
@@ -102,4 +102,31 @@
 
 ;--------------------------------------------------------------------
+; DisplayContext_PrepareOffScreenBufferInESBXtoESDI
+;	Parameters:
+;		BX:AX:	Ptr to off screen buffer
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+DisplayContext_PrepareOffScreenBufferInESBXtoESDI:
+	push	ds
+
+	LOAD_BDA_SEGMENT_TO	ds, di
+	xchg	ax, bx
+	mov		bx, es
+	call	DisplayContext_SetCharacterPointerFromBXAX	; ES:DI now has the pointer
+
+	mov		bl, ATTRIBUTES_NOT_USED
+	mov		ax, BUFFER_OUTPUT_WITH_CHAR_ONLY
+	call	DisplayContext_SetCharOutputFunctionFromAXwithAttribFlagInBL
+
+	mov		bx, di
+	pop		ds
+	ret
+
+
+;--------------------------------------------------------------------
 ; DisplayContext_SynchronizeToHardware
 ;	Parameters:
@@ -123,5 +150,5 @@
 ;		DS:		BDA segment (zero)
 ;	Returns:
-;		ES:DI:	Pointer that was in DX:AX
+;		ES:DI:	Pointer that was in BX:AX
 ;	Corrupts registers:
 ;		AX
Index: trunk/Assembly_Library/Src/Display/DisplayFormat.asm
===================================================================
--- trunk/Assembly_Library/Src/Display/DisplayFormat.asm	(revision 47)
+++ trunk/Assembly_Library/Src/Display/DisplayFormat.asm	(revision 48)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	29.6.2010
-; Last update	:	4.10.2010
+; Last update	:	8.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Functions for displaying formatted strings.
@@ -220,5 +220,5 @@
 	dec		di					; DI = Offset where to move last byte formatted
 	xchg	bx, ax				; BX = BYTEs to prepend
-	call	.ReverseMoveCXbytesFromESSItoESDI
+	call	.ReverseCopyCXbytesFromESSItoESDI
 	xchg	ax, bx
 	call	.ReversePrintAXspacesStartingFromESDI
@@ -231,53 +231,26 @@
 
 ;--------------------------------------------------------------------
-; .ReverseMoveCXbytesFromESSItoESDI
-;	Parameters:
-;		CX:		Number of bytes to move
-;		DS:		BDA segment (zero)
-;		ES:SI:	Ptr to source in video RAM
-;		ES:DI:	Ptr to destination in video RAM
-;	Returns:
-;		DI:		Offset to character preceeding string just moved
+; .ReverseCopyCXbytesFromESSItoESDI
+;	Parameters:
+;		CX:		Number of bytes to copy
+;		DS:		BDA segment (zero)
+;		ES:SI:	Ptr to old location
+;		ES:DI:	Ptr to new location
+;	Returns:
+;		DI:		Updated to before last character copied
 ;	Corrupts registers:
 ;		AX, CX, DX, SI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-.ReverseMoveCXbytesFromESSItoESDI:
-%ifdef ELIMINATE_CGA_SNOW
-	call	DisplayCharOut_LoadAndVerifyStatusRegisterFromBDA
-	je		SHORT .WaitUntilReadyToMoveNextByte
-%endif
-
+.ReverseCopyCXbytesFromESSItoESDI:
+	test	BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], FLG_CONTEXT_ATTRIBUTES
+	jz		SHORT .CopyWithoutDisplayProcessing
+
+	WAIT_RETRACE_IF_NECESSARY_THEN rep movsb
+	dec		di					; Point to preceeding character instead of attribute
+	ret
+ALIGN JUMP_ALIGN
+.CopyWithoutDisplayProcessing:
 	eSEG_STR rep, es, movsb
-
-%ifdef ELIMINATE_CGA_SNOW
-	jmp		SHORT .AlignDIforFirstPreceedingSpace
-.WaitUntilReadyToMoveNextByte:
-	cli				; Interrupt request would mess up timing
-	WAIT_UNTIL_SAFE_CGA_WRITE
-.MovsbWithoutWaitSinceUnknownPort:
-	eSEG	es
-	movsb
-	sti
-	loop	.WaitUntilReadyToMoveNextByte
-%endif
-	; Fall to .AlignDIforFirstPreceedingSpace
-
-;--------------------------------------------------------------------
-; .AlignDIforFirstPreceedingSpace
-;	Parameters:
-;		DS:		BDA segment (zero)
-;		ES:DI:	Byte offset before last byte moved
-;	Returns:
-;		DI:		Offset to space preceeding moved string
-;	Corrupts registers:
-;		AX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.AlignDIforFirstPreceedingSpace:
-	mov		al, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags]
-	and		ax, BYTE FLG_CONTEXT_ATTRIBUTES
-	not		ax
-	and		di, ax
 	ret
 
Index: trunk/Assembly_Library/Src/Display/DisplayPrint.asm
===================================================================
--- trunk/Assembly_Library/Src/Display/DisplayPrint.asm	(revision 47)
+++ trunk/Assembly_Library/Src/Display/DisplayPrint.asm	(revision 48)
@@ -25,4 +25,8 @@
 ;	minimum number of characters. For example %8d would append spaces
 ;	after integer so that at least 8 characters would be printed.
+;
+;	When placing '-' after number, then spaces will be used for prepending.
+;	For example %8-d would prepend integer with spaces so that at least
+;	8 characters would be printed.
 ; 
 ; DisplayPrint_FormattedNullTerminatedStringFromCSSI
Index: trunk/Assembly_Library/Src/Keyboard/Keyboard.asm
===================================================================
--- trunk/Assembly_Library/Src/Keyboard/Keyboard.asm	(revision 47)
+++ trunk/Assembly_Library/Src/Keyboard/Keyboard.asm	(revision 48)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	5.7.2010
-; Last update	:	12.8.2010
+; Last update	:	7.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Functions for managing keyboard.
@@ -97,4 +97,6 @@
 	loop	.GetCharacterFromUser
 .PlayBellForRejectedCharacter:
+	cmp		al, BS								; No bell for backspace
+	je		SHORT .GetCharacterFromUser
 	call	Keyboard_PlayBellForUnwantedKeystroke
 	jmp		SHORT .GetCharacterFromUser
@@ -169,4 +171,5 @@
 	dec		di
 	call	Keyboard_PrintBackspace
+	mov		al, BS								; Restore character
 .RejectCharacter:
 	test	al, al								; Clear ZF...
@@ -227,5 +230,5 @@
 	push	di
 	CALL_DISPLAY_LIBRARY PrintCharacterFromAL
-	CALL_DISPLAY_LIBRARY SynchronizeDisplayContextToHardware
+	CALL_DISPLAY_LIBRARY SynchronizeDisplayContextToHardware	; Hardware cursor
 	pop		di
 	ret
Index: trunk/Assembly_Library/Src/LibraryTests.asm
===================================================================
--- trunk/Assembly_Library/Src/LibraryTests.asm	(revision 47)
+++ trunk/Assembly_Library/Src/LibraryTests.asm	(revision 48)
@@ -83,6 +83,5 @@
 	ret
 .szMenuTitle:
-	db		"First line for menu title.",CR,LF,
-	db		"This is the second line.",NULL
+	db		"Simple test program for Assembly Library. Can be used to find bugs.",NULL
 
 ALIGN JUMP_ALIGN
@@ -97,6 +96,6 @@
 .szInfoTitle:
 	db		"Information line 1,",CR,LF,
-	db		"Information line 2,",CR,LF,
-	db		"This is the last information line.",NULL
+	db		"Information line 2. ",
+	db		"This comes (12) right after Information line 2.",NULL
 
 ALIGN JUMP_ALIGN
Index: trunk/Assembly_Library/Src/Menu/Dialog/Dialog.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/Dialog/Dialog.asm	(revision 47)
+++ trunk/Assembly_Library/Src/Menu/Dialog/Dialog.asm	(revision 48)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	6.8.2010
-; Last update	:	1.10.2010
+; Last update	:	7.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Common functions for many dialogs.
@@ -291,8 +291,9 @@
 ALIGN JUMP_ALIGN
 .RedrawDialogAreaAndWholeParentWindow:
+	push	si
+	call	MenuBorders_AdjustDisplayContextForDrawingBorders
+	pop		si
 	mov		al, SCREEN_BACKGROUND_ATTRIBUTE
 	CALL_DISPLAY_LIBRARY SetCharacterAttributeFromAL
-	call	MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
-	CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
 	mov		ax, [bp+MENUINIT.wWidthAndHeight]
 	CALL_DISPLAY_LIBRARY ClearAreaWithHeightInAHandWidthInAL
Index: trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm	(revision 47)
+++ trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm	(revision 48)
@@ -260,16 +260,9 @@
 	mov		bx, di
 	CALL_DISPLAY_LIBRARY PushDisplayContext
-
-	xchg	ax, bx
-	mov		bx, es
-	CALL_DISPLAY_LIBRARY SetCharacterPointerFromBXAX
-	mov		bl, ATTRIBUTES_NOT_USED
-	mov		ax, BUFFER_OUTPUT_WITH_CHAR_ONLY
-	CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
+	CALL_DISPLAY_LIBRARY PrepareOffScreenBufferInESBXtoESDI
 
 	call	.FormatFileOrDirectoryToBufferFromDTAinDSSI
 
 	CALL_DISPLAY_LIBRARY GetCharacterPointerToBXAX
-	mov		es, bx
 	xchg	bx, ax
 	CALL_DISPLAY_LIBRARY PopDisplayContext
Index: trunk/Assembly_Library/Src/Menu/Dialog/DialogProgress.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/Dialog/DialogProgress.asm	(revision 47)
+++ trunk/Assembly_Library/Src/Menu/Dialog/DialogProgress.asm	(revision 48)
@@ -33,5 +33,5 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, BX, DX, SI, DI
+;		AX, BX, CX, DX, SI, DI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
Index: trunk/Assembly_Library/Src/Menu/Menu.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/Menu.asm	(revision 47)
+++ trunk/Assembly_Library/Src/Menu/Menu.asm	(revision 48)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	3.8.2010
-; Last update	:	15.9.2010
+; Last update	:	7.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Menu Library functions for CALL_MENU_LIBRARY macro
@@ -46,4 +46,5 @@
 
 	;at	MENU_LIB.SetTitleHeightFromAL,			dw	MenuInit_SetTitleHeightFromAL			; Special case in CALL_MENU_LIBRARY
+	at	MENU_LIB.ClearTitleArea,				dw	MenuText_ClearTitleArea
 	at	MENU_LIB.RefreshTitle,					dw	MenuText_RefreshTitle
 
@@ -53,4 +54,5 @@
 
 	;at	MENU_LIB.SetInformationHeightFromAL,	dw	MenuInit_SetInformationHeightFromAL		; Special case in CALL_MENU_LIBRARY
+	at	MENU_LIB.ClearInformationArea,			dw	MenuText_ClearInformationArea
 	at	MENU_LIB.RefreshInformation,			dw	MenuText_RefreshInformation
 
Index: trunk/Assembly_Library/Src/Menu/MenuCharOut.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/MenuCharOut.asm	(revision 47)
+++ trunk/Assembly_Library/Src/Menu/MenuCharOut.asm	(revision 48)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	15.7.2010
-; Last update	:	4.8.2010
+; Last update	:	8.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Character out function for printing withing menu window.
@@ -29,5 +29,5 @@
 ALIGN JUMP_ALIGN
 .PrintCRandAdjustColumnToMenuBorders:
-	call	DisplayCharOut_TeletypeOutputWithAttribute
+	call	DisplayCharOut_BiosTeletypeOutput
 	xor		ax, ax					; No offset, cursor to start of border
 	jmp		SHORT SetCursorToNextMenuLine
@@ -35,4 +35,5 @@
 
 ;--------------------------------------------------------------------
+; MenuCharOut_MenuTextTeletypeOutputWithAttributeAndAutomaticLineChange
 ; MenuCharOut_MenuTextTeletypeOutputWithAttribute
 ;	Parameters:
@@ -47,12 +48,139 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
+MenuCharOut_MenuTextTeletypeOutputWithAttributeAndAutomaticLineChange:
+	push	di
+	push	ax
+	mov		al, DOUBLE_VERTICAL
+	add		di, BYTE MENU_TEXT_COLUMN_OFFSET	; Border char comes after space
+	WAIT_RETRACE_IF_NECESSARY_THEN scasb
+	pop		ax
+	pop		di
+	je		SHORT MovePartialWordToNewTextLineAndPrintCharacterFromAX
+	; Fall to MenuCharOut_MenuTextTeletypeOutputWithAttribute
+
+ALIGN JUMP_ALIGN
 MenuCharOut_MenuTextTeletypeOutputWithAttribute:
 	cmp		al, CR						; Carriage return?
-	je		SHORT .PrintCRandAdjustColumnToMenuText
+	je		SHORT PrintCRfromALandAdjustColumnToMenuText
 	jmp		DisplayCharOut_TeletypeOutputWithAttribute
 
-ALIGN JUMP_ALIGN
-.PrintCRandAdjustColumnToMenuText:
-	call	DisplayCharOut_TeletypeOutputWithAttribute
+
+;--------------------------------------------------------------------
+; MovePartialWordToNewTextLineAndPrintCharacterFromAX
+;	Parameters:
+;		AL:		Character to output
+;		AH:		Attribute to output
+;		DS:		BDA segment (zero)
+;		ES:DI:	Ptr to end of text line in video memory
+;	Returns:
+;		DI:		Incremented for next character
+;	Corrupts registers:
+;		AX, DX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+MovePartialWordToNewTextLineAndPrintCharacterFromAX:
+	cmp		al, ' '
+	je		SHORT .MoveCursorInDItoBeginningOfNextLine
+	push	si
+	push	cx
+	push	ax
+
+	call	.GetOffsetToPartialWordToSIandSizeToCX
+	call	.MoveCursorInDItoBeginningOfNextLine
+	jcxz	.NothingToMove
+	call	.MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX
+.NothingToMove:
+	pop		ax
+	pop		cx
+	pop		si
+	jmp		DisplayCharOut_TeletypeOutputWithAttribute
+
+;--------------------------------------------------------------------
+; .GetOffsetToPartialWordToSIandSizeToCX
+;	Parameters:
+;		ES:DI:	Ptr to space before border character
+;	Returns:
+;		CX:		Number of bytes that needs to be moved
+;		ES:SI:	Ptr to beginning of partial word that needs to be moved to new line
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.GetOffsetToPartialWordToSIandSizeToCX:
+	xor		cx, cx
+	mov		si, di
+ALIGN JUMP_ALIGN
+.ScanNextCharacter:		; Space will always be found since one comes after border
+	dec		si
+	dec		si
+	cmp		BYTE [es:si], ' '
+	je		SHORT .PartialWordFound
+	inc		cx
+	jmp		SHORT .ScanNextCharacter
+ALIGN JUMP_ALIGN
+.PartialWordFound:
+	inc		si
+	inc		si			; SI now points one past space
+	shl		cx, 1		; Characters to bytes
+	ret
+
+;--------------------------------------------------------------------
+; .MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX
+;	Parameters:
+;		CX:		Number of bytes in partial word
+;		DS:		BDA segment (zero)
+;		ES:SI:	Ptr to partial word on previous line
+;		ES:DI:	Ptr to new empty line
+;	Returns:
+;		ES:DI:	Ptr where to store next character
+;	Corrupts registers:
+;		AX, CX, DX, SI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX:
+	push	si
+	push	cx
+	WAIT_RETRACE_IF_NECESSARY_THEN rep movsb
+	pop		cx
+	pop		si
+	xchg	di, si
+	shr		cx, 1		; Bytes to characters
+	mov		al, ' '
+	call	DisplayPrint_RepeatCharacterFromALwithCountInCX
+	mov		di, si
+	ret
+
+;--------------------------------------------------------------------
+; .MoveCursorInDItoBeginningOfNextLine
+;	Parameters:
+;		DS:		BDA segment (zero)
+;		ES:DI:	Ptr to cursor location
+;	Returns:
+;		ES:DI:	Ptr to beginning of new line
+;	Corrupts registers:
+;		AX, DX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.MoveCursorInDItoBeginningOfNextLine:
+	mov		al, LF
+	call	DisplayCharOut_BiosTeletypeOutput
+	mov		al, CR
+	; Fall to PrintCRfromALandAdjustColumnToMenuText
+
+
+;--------------------------------------------------------------------
+; PrintCRfromALandAdjustColumnToMenuText
+;	Parameters:
+;		AL:		Character to output (CR)
+;		DS:		BDA segment (zero)
+;		ES:DI:	Ptr to video memory where to output
+;	Returns:
+;		DI:		Incremented for next text line
+;	Corrupts registers:
+;		AX, DX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+PrintCRfromALandAdjustColumnToMenuText:
+	call	DisplayCharOut_BiosTeletypeOutput
 	mov		al, MENU_TEXT_COLUMN_OFFSET	; Offset to start of text
 	; Fall to SetCursorToNextMenuLine
Index: trunk/Assembly_Library/Src/Menu/MenuEvent.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/MenuEvent.asm	(revision 47)
+++ trunk/Assembly_Library/Src/Menu/MenuEvent.asm	(revision 48)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	13.7.2010
-; Last update	:	11.8.2010
+; Last update	:	5.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Functions for initializing menu system.
@@ -65,4 +65,5 @@
 ; MenuEvent_RefreshInformation
 ;	Parameters
+;		SS:BP:	Ptr to MENU
 ;		Cursor will be positioned to beginning of window
 ;	Returns:
@@ -70,13 +71,16 @@
 ;				Cleared if event not processed
 ;	Corrupts registers:
-;		AX, BX, DX
+;		AX, CX, BX, DX
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 MenuEvent_RefreshTitle:
 	mov		bx, MENUEVENT.RefreshTitle
-	jmp		SHORT MenuEvent_SendFromBX
+	jmp		SHORT LoadHighlightedItemToCXandSendMessageFromBX
+
 ALIGN JUMP_ALIGN
 MenuEvent_RefreshInformation:
 	mov		bx, MENUEVENT.RefreshInformation
+LoadHighlightedItemToCXandSendMessageFromBX:
+	mov		cx, [bp+MENU.wHighlightedItem]
 	jmp		SHORT MenuEvent_SendFromBX
 
@@ -86,4 +90,5 @@
 ;	Parameters
 ;		CX:		Index of item to refresh
+;		SS:BP:	Ptr to MENU
 ;		Cursor has been positioned to the beginning of item line
 ;	Returns:
@@ -103,4 +108,5 @@
 ;	Parameters
 ;		CX:		Index of item to highlight
+;		SS:BP:	Ptr to MENU
 ;	Returns:
 ;		Nothing
@@ -128,4 +134,5 @@
 ;		AL:		ASCII character for the key
 ;		AH:		Keyboard library scan code for the key
+;		SS:BP:	Ptr to MENU
 ;	Returns:
 ;		CF:		Set if event processed
@@ -144,4 +151,5 @@
 ;	Parameters
 ;		CX:		Index of selected item
+;		SS:BP:	Ptr to MENU
 ;	Returns:
 ;		CF:		Set if event processed
Index: trunk/Assembly_Library/Src/Menu/MenuInit.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/MenuInit.asm	(revision 47)
+++ trunk/Assembly_Library/Src/Menu/MenuInit.asm	(revision 48)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	13.7.2010
-; Last update	:	1.10.2010
+; Last update	:	5.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Functions for initializing menu system.
@@ -113,4 +113,18 @@
 	jmp		MenuScrollbars_MoveHighlightedItemByAX
 
+;--------------------------------------------------------------------
+; MenuInit_GetHighlightedItemToAX
+;	Parameters
+;		SS:BP:	Ptr to MENU
+;	Returns:
+;		AX:		Index of highlighted item or NO_ITEM_HIGHLIGHTED
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+MenuInit_GetHighlightedItemToAX:
+	mov		ax, [bp+MENU.wHighlightedItem]
+	ret
+
 
 ;--------------------------------------------------------------------
Index: trunk/Assembly_Library/Src/Menu/MenuText.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/MenuText.asm	(revision 47)
+++ trunk/Assembly_Library/Src/Menu/MenuText.asm	(revision 48)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	21.7.2010
-; Last update	:	28.9.2010
+; Last update	:	7.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Functions for drawing menu texts by the user.
@@ -10,4 +10,34 @@
 
 ;--------------------------------------------------------------------
+; MenuText_ClearTitleArea
+; MenuText_ClearInformationArea
+;	Parameters
+;		SS:BP:	Ptr to MENU
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, CX, DX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+MenuText_ClearTitleArea:
+	call	PrepareToDrawTitleArea
+	mov		cl, [bp+MENUINIT.bTitleLines]
+	jmp		SHORT ClearCLlinesOfText
+
+ALIGN JUMP_ALIGN
+MenuText_ClearInformationArea:
+	call	PrepareToDrawInformationArea
+	mov		cl, [bp+MENUINIT.bInfoLines]
+ClearCLlinesOfText:
+	mov		al, [bp+MENUINIT.bWidth]
+	sub		al, MENU_HORIZONTAL_BORDER_LINES+MENU_TEXT_COLUMN_OFFSET
+	mul		cl
+	xchg	cx, ax
+	mov		al, ' '
+	CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
+	ret
+
+
+;--------------------------------------------------------------------
 ; MenuText_RefreshTitle
 ; MenuText_RefreshInformation
@@ -17,5 +47,5 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, BX, DX, SI, DI
+;		AX, BX, CX, DX, SI, DI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -23,9 +53,5 @@
 	cmp		BYTE [bp+MENUINIT.bTitleLines], 0
 	jz		SHORT NothingToRefresh
-
-	mov		si, ATTRIBUTE_CHARS.cTitle
-	call	AdjustDisplayContextForDrawingTexts
-	call	MenuLocation_GetTitleTextTopLeftCoordinatesToAX
-	CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
+	call	PrepareToDrawTitleArea
 	jmp		MenuEvent_RefreshTitle
 
@@ -34,10 +60,34 @@
 	cmp		BYTE [bp+MENUINIT.bInfoLines], 0
 	jz		SHORT NothingToRefresh
-
+	call	PrepareToDrawInformationArea
+	jmp		MenuEvent_RefreshInformation
+
+;--------------------------------------------------------------------
+; PrepareToDrawTitleArea
+; PrepareToDrawInformationArea
+;	Parameters
+;		SS:BP:	Ptr to MENU
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, DX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+PrepareToDrawTitleArea:
+	mov		si, ATTRIBUTE_CHARS.cTitle
+	mov		ax, MenuCharOut_MenuTextTeletypeOutputWithAttributeAndAutomaticLineChange
+	call	AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX
+	call	MenuLocation_GetTitleTextTopLeftCoordinatesToAX
+	CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
+	ret
+
+ALIGN JUMP_ALIGN
+PrepareToDrawInformationArea:
 	mov		si, ATTRIBUTE_CHARS.cInformation
-	call	AdjustDisplayContextForDrawingTexts
+	mov		ax, MenuCharOut_MenuTextTeletypeOutputWithAttributeAndAutomaticLineChange
+	call	AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX
 	call	MenuLocation_GetInformationTextTopLeftCoordinatesToAX
 	CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
-	jmp		MenuEvent_RefreshInformation
+	ret
 
 
@@ -109,5 +159,6 @@
 	CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
 	call	.GetItemTextAttributeTypeToSIforItemInCX
-	jmp		SHORT AdjustDisplayContextForDrawingTexts
+	mov		ax, MenuCharOut_MenuTextTeletypeOutputWithAttribute
+	jmp		SHORT AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX
 
 ;--------------------------------------------------------------------
@@ -142,5 +193,5 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, DX, SI, DI
+;		AX, BX, DX, SI, DI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -188,5 +239,5 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, DX, SI, DI
+;		AX, BX, DX, SI, DI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -194,6 +245,5 @@
 	push	cx
 
-	mov		si, ATTRIBUTE_CHARS.cBordersAndBackground
-	call	MenuAttribute_SetToDisplayContextFromTypeInSI
+	call	MenuBorders_AdjustDisplayContextForDrawingBorders
 
 	mov		ax, cx
@@ -211,6 +261,7 @@
 
 ;--------------------------------------------------------------------
-; AdjustDisplayContextForDrawingTexts
-;	Parameters
+; AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX
+;	Parameters
+;		AX:		Character output function
 ;		SI:		Attribute type (from ATTRIBUTE_CHARS)
 ;		SS:BP:	Ptr to MENU
@@ -221,7 +272,6 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-AdjustDisplayContextForDrawingTexts:
+AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX:
 	mov		bl, ATTRIBUTES_ARE_USED
-	mov		ax, MenuCharOut_MenuTextTeletypeOutputWithAttribute
 	CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
 
