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

Last change on this file since 454 was 445, checked in by krille_n_@…, 12 years ago

Changes:

  • A speed optimization to the eSHL_IM macro for 386 and higher. This change breaks emulation in the sense that the macro will fail when given a memory operand as the first parameter.
  • Memory_SumCXbytesFromESSItoAL now returns with the zero flag set/cleared according to the result.
  • Unrolled all the 8 bit READ transfer loops to do 16 bytes per iteration. Added a new macro (UNROLL_SECTORS_IN_CX_TO_OWORDS) as part of it. Size wise this is expensive but I think it should be worth the ROM space. The WRITE transfer loops were left as is since writes are rare anyway (<10% of all disk I/O IIRC).
  • Minor optimizations and fixes here and there.
File size: 5.5 KB
RevLine 
[52]1; Project name : Assembly Library
2; Description : Functions for splitting menu lines during character output.
3
[376]4;
[445]5; XTIDE Universal BIOS and Associated Tools
[376]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.
[445]12;
[376]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
[445]16; GNU General Public License for more details.
[376]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
[445]20
[52]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;--------------------------------------------------------------------
[369]33ALIGN MENU_JUMP_ALIGN
[52]34CharOutLineSplitter_PrepareForPrintingTextLines:
[104]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
[52]39
[104]40 ; Get last text line column offset to AX
[52]41 call MenuLocation_GetMaxTextLineLengthToAX
[445]42 eSHL_IM ax, 1 ; Characters to BYTEs
[104]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
[52]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;--------------------------------------------------------------------
[369]60ALIGN MENU_JUMP_ALIGN
[52]61CharOutLineSplitter_GetFirstBorderLineColumnOffsetToAX:
62 call MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
63 xor ah, ah
[445]64 eSHL_IM ax, 1
[52]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;--------------------------------------------------------------------
[369]79ALIGN MENU_JUMP_ALIGN
[52]80CharOutLineSplitter_IsCursorAtTheEndOfTextLine:
81 push ax
82
83 mov dl, [VIDEO_BDA.wColumns]
[445]84 eSHL_IM dl, 1 ; DX = bytes per row
[52]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;--------------------------------------------------------------------
[369]105ALIGN MENU_JUMP_ALIGN
[52]106CharOutLineSplitter_MovePartialWordToNewTextLine:
107 push si
108 push cx
109 push ax
[104]110 ; Fall to .GetOffsetToPartialWordToSIandSizeToCX
[52]111
112;--------------------------------------------------------------------
[104]113; .GetOffsetToPartialWordToSIandSizeToCX
[52]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;--------------------------------------------------------------------
[104]122.GetOffsetToPartialWordToSIandSizeToCX:
[181]123 mov cx, di
[52]124 mov si, di
[369]125ALIGN MENU_JUMP_ALIGN
[52]126.ScanNextCharacter: ; Space will always be found since one comes after border
127 dec si
128 dec si
129 cmp BYTE [es:si], ' '
[181]130 jne SHORT .ScanNextCharacter
[52]131 inc si
132 inc si ; SI now points one past space
[181]133 sub cx, si
[104]134 ; Fall to .ChangeLine
[52]135
[104]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
[52]149
150;--------------------------------------------------------------------
[104]151; .MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX
[52]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;--------------------------------------------------------------------
[104]162.MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX:
[52]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
[104]174
175.ReturnFromMovePartialWordToNewTextLine:
176 pop ax
177 pop cx
178 pop si
[52]179 ret
Note: See TracBrowser for help on using the repository browser.