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

Last change on this file since 410 was 376, checked in by gregli@…, 13 years ago

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 5.5 KB
Line 
1; Project name : Assembly Library
2; Description : Functions for splitting menu lines during character output.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12;
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
20
21; Section containing code
22SECTION .text
23
24;--------------------------------------------------------------------
25; CharOutLineSplitter_PrepareForPrintingTextLines
26; Parameters:
27; SS:BP: Ptr to MENU
28; Returns:
29; Nothing
30; Corrupts registers:
31; AX, DX, DI
32;--------------------------------------------------------------------
33ALIGN MENU_JUMP_ALIGN
34CharOutLineSplitter_PrepareForPrintingTextLines:
35 ; Get first text line column offset to DX
36 call CharOutLineSplitter_GetFirstBorderLineColumnOffsetToAX
37 add al, MENU_TEXT_COLUMN_OFFSET<<1
38 xchg dx, ax
39
40 ; Get last text line column offset to AX
41 call MenuLocation_GetMaxTextLineLengthToAX
42 shl ax, 1 ; Characters to BYTEs
43 add ax, dx
44
45 xchg ax, dx ; AL = First text line column offset
46 mov ah, dl ; AH = Last text line column offset
47 CALL_DISPLAY_LIBRARY SetCharacterOutputParameterFromAX
48 ret
49
50
51;--------------------------------------------------------------------
52; CharOutLineSplitter_GetFirstBorderLineColumnOffsetToAX
53; Parameters:
54; SS:BP: Ptr to MENU
55; Returns:
56; AX: Offset to end of text line (first border area character)
57; Corrupts registers:
58; Nothing
59;--------------------------------------------------------------------
60ALIGN MENU_JUMP_ALIGN
61CharOutLineSplitter_GetFirstBorderLineColumnOffsetToAX:
62 call MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
63 xor ah, ah
64 shl ax, 1
65 ret
66
67
68;--------------------------------------------------------------------
69; CharOutLineSplitter_IsCursorAtTheEndOfTextLine
70; Parameters:
71; DS: BDA segment (zero)
72; ES:DI: Ptr to cursor location in video memory
73; Returns:
74; CF: Set if end of text line
75; Clear if more characters fit on current text line
76; Corrupts registers:
77; DX
78;--------------------------------------------------------------------
79ALIGN MENU_JUMP_ALIGN
80CharOutLineSplitter_IsCursorAtTheEndOfTextLine:
81 push ax
82
83 mov dl, [VIDEO_BDA.wColumns]
84 shl dl, 1 ; DX = bytes per row
85 mov ax, di
86 div dl ; AL = row index, AH = column index
87 cmp [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam+1], ah
88
89 pop ax
90 ret
91
92
93;--------------------------------------------------------------------
94; CharOutLineSplitter_MovePartialWordToNewTextLine
95; Parameters:
96; AL: Character to output
97; AH: Attribute to output
98; DS: BDA segment (zero)
99; ES:DI: Ptr to end of text line in video memory
100; Returns:
101; DI: Updated to next character for new text line
102; Corrupts registers:
103; AX, DX
104;--------------------------------------------------------------------
105ALIGN MENU_JUMP_ALIGN
106CharOutLineSplitter_MovePartialWordToNewTextLine:
107 push si
108 push cx
109 push ax
110 ; Fall to .GetOffsetToPartialWordToSIandSizeToCX
111
112;--------------------------------------------------------------------
113; .GetOffsetToPartialWordToSIandSizeToCX
114; Parameters:
115; ES:DI: Ptr to space before border character
116; Returns:
117; CX: Number of bytes that needs to be moved
118; ES:SI: Ptr to beginning of partial word that needs to be moved to new line
119; Corrupts registers:
120; Nothing
121;--------------------------------------------------------------------
122.GetOffsetToPartialWordToSIandSizeToCX:
123 mov cx, di
124 mov si, di
125ALIGN MENU_JUMP_ALIGN
126.ScanNextCharacter: ; Space will always be found since one comes after border
127 dec si
128 dec si
129 cmp BYTE [es:si], ' '
130 jne SHORT .ScanNextCharacter
131 inc si
132 inc si ; SI now points one past space
133 sub cx, si
134 ; Fall to .ChangeLine
135
136;--------------------------------------------------------------------
137; .ChangeLine
138; Parameters:
139; Nothing
140; Returns:
141; Nothing
142; Corrupts registers:
143; AX, DX
144;--------------------------------------------------------------------
145.ChangeLine:
146 call MenuCharOut_PrintLFCRandAdjustOffsetForStartOfLine
147 jcxz .ReturnFromMovePartialWordToNewTextLine
148 ; Fall to .MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX
149
150;--------------------------------------------------------------------
151; .MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX
152; Parameters:
153; CX: Number of BYTEs in partial word
154; DS: BDA segment (zero)
155; ES:SI: Ptr to partial word on previous line
156; ES:DI: Ptr to new empty line
157; Returns:
158; ES:DI: Ptr where to store next character
159; Corrupts registers:
160; AX, CX, DX, SI
161;--------------------------------------------------------------------
162.MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX:
163 push si
164 push cx
165 WAIT_RETRACE_IF_NECESSARY_THEN rep movsb
166 pop cx
167 pop si
168
169 xchg di, si
170 shr cx, 1 ; Bytes to characters
171 mov al, ' '
172 call DisplayPrint_RepeatCharacterFromALwithCountInCX
173 mov di, si
174
175.ReturnFromMovePartialWordToNewTextLine:
176 pop ax
177 pop cx
178 pop si
179 ret
Note: See TracBrowser for help on using the repository browser.