Index: trunk/Assembly_Library/Src/Menu/MenuText.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/MenuText.asm	(revision 48)
+++ trunk/Assembly_Library/Src/Menu/MenuText.asm	(revision 52)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	21.7.2010
-; Last update	:	7.10.2010
+; Last update	:	12.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Functions for drawing menu texts by the user.
@@ -76,18 +76,14 @@
 PrepareToDrawTitleArea:
 	mov		si, ATTRIBUTE_CHARS.cTitle
-	mov		ax, MenuCharOut_MenuTextTeletypeOutputWithAttributeAndAutomaticLineChange
-	call	AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX
 	call	MenuLocation_GetTitleTextTopLeftCoordinatesToAX
-	CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
-	ret
+	jmp		SHORT FinishPreparationsToDrawTitleOrInformationArea
 
 ALIGN JUMP_ALIGN
 PrepareToDrawInformationArea:
 	mov		si, ATTRIBUTE_CHARS.cInformation
-	mov		ax, MenuCharOut_MenuTextTeletypeOutputWithAttributeAndAutomaticLineChange
-	call	AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX
 	call	MenuLocation_GetInformationTextTopLeftCoordinatesToAX
-	CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
-	ret
+FinishPreparationsToDrawTitleOrInformationArea:
+	mov		dx, MenuCharOut_MenuTeletypeOutputWithAutomaticLineChange
+	jmp		SHORT AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
 
 
@@ -134,6 +130,5 @@
 	call	MenuScrollbars_IsItemInCXonVisiblePage
 	jnc		SHORT .InvalidItem
-	mov		ax, cx
-	call	MenuText_AdjustDisplayContextForDrawingItemFromAX
+	call	MenuText_AdjustDisplayContextForDrawingItemFromCX
 	call	MenuEvent_RefreshItemFromCX
 	call	DrawScrollbarIfNecessary
@@ -144,24 +139,47 @@
 
 ;--------------------------------------------------------------------
-; MenuText_AdjustDisplayContextForDrawingItemFromAX
-;	Parameters
-;		AX:		Item to refresh
-;		SS:BP:	Ptr to MENU
-;	Returns:
-;		CX:		Item to refresh
-;	Corrupts registers:
-;		AX, SI, DI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-MenuText_AdjustDisplayContextForDrawingItemFromAX:
-	mov		cx, ax
+; MenuText_AdjustDisplayContextForDrawingItemFromCX
+;	Parameters
+;		CX:		Item to refresh
+;		SS:BP:	Ptr to MENU
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, DX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+MenuText_AdjustDisplayContextForDrawingItemFromCX:
+	mov		ax, cx
+	call	GetItemTextAttributeTypeToSIforItemInCX
 	call	MenuLocation_GetTextCoordinatesToAXforItemInAX
+	mov		dx, MenuCharOut_MenuTeletypeOutput
+	; Fall to AdjustDisplayContextForDrawingTextsAtCoordinatesInAXwithAttributeTypeInSI
+
+;--------------------------------------------------------------------
+; AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
+;	Parameters
+;		AX:		Cursor coordinates to set
+;		DX:		Character output function
+;		SI:		Attribute type (from ATTRIBUTE_CHARS)
+;		SS:BP:	Ptr to MENU
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, DX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX:
 	CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
-	call	.GetItemTextAttributeTypeToSIforItemInCX
-	mov		ax, MenuCharOut_MenuTextTeletypeOutputWithAttribute
-	jmp		SHORT AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX
-
-;--------------------------------------------------------------------
-; .GetItemTextAttributeTypeToSIforItemInCX
+
+	xchg	ax, dx
+	mov		bl, ATTRIBUTES_ARE_USED
+	CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
+
+	call	CharOutLineSplitter_PrepareForPrintingTextLines
+	jmp		MenuAttribute_SetToDisplayContextFromTypeInSI
+
+
+;--------------------------------------------------------------------
+; GetItemTextAttributeTypeToSIforItemInCX
 ;	Parameters
 ;		CX:		Item to refresh
@@ -173,9 +191,10 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-.GetItemTextAttributeTypeToSIforItemInCX:
+GetItemTextAttributeTypeToSIforItemInCX:
 	mov		si, ATTRIBUTE_CHARS.cItem
 	test	BYTE [bp+MENU.bFlags], FLG_MENU_NOHIGHLIGHT
 	jnz		SHORT .ReturnAttributeTypeInSI
-	cmp		cx, [bp+MENU.wHighlightedItem]
+
+	cmp		cx, [bp+MENUINIT.wHighlightedItem]
 	jne		SHORT .ReturnAttributeTypeInSI
 	sub		si, BYTE ATTRIBUTE_CHARS.cItem - ATTRIBUTE_CHARS.cHighlightedItem
@@ -258,24 +277,2 @@
 	pop		cx
 	ret
-
-
-;--------------------------------------------------------------------
-; AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX
-;	Parameters
-;		AX:		Character output function
-;		SI:		Attribute type (from ATTRIBUTE_CHARS)
-;		SS:BP:	Ptr to MENU
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, BX, SI, DI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX:
-	mov		bl, ATTRIBUTES_ARE_USED
-	CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
-
-	mov		ax, bp
-	CALL_DISPLAY_LIBRARY SetCharacterOutputParameterFromAX
-
-	jmp		MenuAttribute_SetToDisplayContextFromTypeInSI
