source: xtideuniversalbios/trunk/Assembly_Library/Src/Menu/CharOutLineSplitter.asm@ 138

Last change on this file since 138 was 104, checked in by Tomi Tilli, 14 years ago

Changes to Assembly Library:

  • Some more optimizations.
  • Moved macros.inc from XTIDE Universal BIOS to Assembly Library.
File size: 4.9 KB
Line 
1; Project name : Assembly Library
2; Description : Functions for splitting menu lines during character output.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; CharOutLineSplitter_PrepareForPrintingTextLines
9; Parameters:
10; SS:BP: Ptr to MENU
11; Returns:
12; Nothing
13; Corrupts registers:
14; AX, DX, DI
15;--------------------------------------------------------------------
16ALIGN JUMP_ALIGN
17CharOutLineSplitter_PrepareForPrintingTextLines:
18 ; Get first text line column offset to DX
19 call CharOutLineSplitter_GetFirstBorderLineColumnOffsetToAX
20 add al, MENU_TEXT_COLUMN_OFFSET<<1
21 xchg dx, ax
22
23 ; Get last text line column offset to AX
24 call MenuLocation_GetMaxTextLineLengthToAX
25 shl ax, 1 ; Characters to BYTEs
26 add ax, dx
27
28 xchg ax, dx ; AL = First text line column offset
29 mov ah, dl ; AH = Last text line column offset
30 CALL_DISPLAY_LIBRARY SetCharacterOutputParameterFromAX
31 ret
32
33
34;--------------------------------------------------------------------
35; CharOutLineSplitter_GetFirstBorderLineColumnOffsetToAX
36; Parameters:
37; SS:BP: Ptr to MENU
38; Returns:
39; AX: Offset to end of text line (first border area character)
40; Corrupts registers:
41; Nothing
42;--------------------------------------------------------------------
43ALIGN JUMP_ALIGN
44CharOutLineSplitter_GetFirstBorderLineColumnOffsetToAX:
45 call MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
46 xor ah, ah
47 shl ax, 1
48 ret
49
50
51;--------------------------------------------------------------------
52; CharOutLineSplitter_IsCursorAtTheEndOfTextLine
53; Parameters:
54; DS: BDA segment (zero)
55; ES:DI: Ptr to cursor location in video memory
56; Returns:
57; CF: Set if end of text line
58; Clear if more characters fit on current text line
59; Corrupts registers:
60; DX
61;--------------------------------------------------------------------
62ALIGN JUMP_ALIGN
63CharOutLineSplitter_IsCursorAtTheEndOfTextLine:
64 push ax
65
66 mov dl, [VIDEO_BDA.wColumns]
67 shl dl, 1 ; DX = bytes per row
68 mov ax, di
69 div dl ; AL = row index, AH = column index
70 cmp [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam+1], ah
71
72 pop ax
73 ret
74
75
76;--------------------------------------------------------------------
77; CharOutLineSplitter_MovePartialWordToNewTextLine
78; Parameters:
79; AL: Character to output
80; AH: Attribute to output
81; DS: BDA segment (zero)
82; ES:DI: Ptr to end of text line in video memory
83; Returns:
84; DI: Updated to next character for new text line
85; Corrupts registers:
86; AX, DX
87;--------------------------------------------------------------------
88ALIGN JUMP_ALIGN
89CharOutLineSplitter_MovePartialWordToNewTextLine:
90 push si
91 push cx
92 push ax
93 ; Fall to .GetOffsetToPartialWordToSIandSizeToCX
94
95;--------------------------------------------------------------------
96; .GetOffsetToPartialWordToSIandSizeToCX
97; Parameters:
98; ES:DI: Ptr to space before border character
99; Returns:
100; CX: Number of bytes that needs to be moved
101; ES:SI: Ptr to beginning of partial word that needs to be moved to new line
102; Corrupts registers:
103; Nothing
104;--------------------------------------------------------------------
105.GetOffsetToPartialWordToSIandSizeToCX:
106 xor cx, cx
107 mov si, di
108ALIGN JUMP_ALIGN
109.ScanNextCharacter: ; Space will always be found since one comes after border
110 dec si
111 dec si
112 cmp BYTE [es:si], ' '
113 je SHORT .PartialWordFound
114 inc cx
115 jmp SHORT .ScanNextCharacter
116ALIGN JUMP_ALIGN
117.PartialWordFound:
118 inc si
119 inc si ; SI now points one past space
120 shl cx, 1 ; Characters to bytes
121 ; Fall to .ChangeLine
122
123;--------------------------------------------------------------------
124; .ChangeLine
125; Parameters:
126; Nothing
127; Returns:
128; Nothing
129; Corrupts registers:
130; AX, DX
131;--------------------------------------------------------------------
132.ChangeLine:
133 call MenuCharOut_PrintLFCRandAdjustOffsetForStartOfLine
134 jcxz .ReturnFromMovePartialWordToNewTextLine
135 ; Fall to .MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX
136
137;--------------------------------------------------------------------
138; .MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX
139; Parameters:
140; CX: Number of BYTEs in partial word
141; DS: BDA segment (zero)
142; ES:SI: Ptr to partial word on previous line
143; ES:DI: Ptr to new empty line
144; Returns:
145; ES:DI: Ptr where to store next character
146; Corrupts registers:
147; AX, CX, DX, SI
148;--------------------------------------------------------------------
149.MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX:
150 push si
151 push cx
152 WAIT_RETRACE_IF_NECESSARY_THEN rep movsb
153 pop cx
154 pop si
155
156 xchg di, si
157 shr cx, 1 ; Bytes to characters
158 mov al, ' '
159 call DisplayPrint_RepeatCharacterFromALwithCountInCX
160 mov di, si
161
162.ReturnFromMovePartialWordToNewTextLine:
163 pop ax
164 pop cx
165 pop si
166 ret
Note: See TracBrowser for help on using the repository browser.