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

Last change on this file since 363 was 181, checked in by krille_n_@…, 13 years ago

Changes to all parts of the project:

  • Size optimizations.
  • Added a define (EXCLUDE_FROM_XTIDECFG) to exclude unused library code from XTIDECFG.
  • Tried to minimize time spent with interrupts disabled.
  • Some minor attempts to improve speed (reordering instructions etc).
  • Tried to improve readability, did some cleanup and fixed some errors in comments.
File size: 4.8 KB
RevLine 
[52]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:
[104]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
[52]22
[104]23 ; Get last text line column offset to AX
[52]24 call MenuLocation_GetMaxTextLineLengthToAX
[104]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
[52]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
[104]93 ; Fall to .GetOffsetToPartialWordToSIandSizeToCX
[52]94
95;--------------------------------------------------------------------
[104]96; .GetOffsetToPartialWordToSIandSizeToCX
[52]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;--------------------------------------------------------------------
[104]105.GetOffsetToPartialWordToSIandSizeToCX:
[181]106 mov cx, di
[52]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], ' '
[181]113 jne SHORT .ScanNextCharacter
[52]114 inc si
115 inc si ; SI now points one past space
[181]116 sub cx, si
[104]117 ; Fall to .ChangeLine
[52]118
[104]119;--------------------------------------------------------------------
120; .ChangeLine
121; Parameters:
122; Nothing
123; Returns:
124; Nothing
125; Corrupts registers:
126; AX, DX
127;--------------------------------------------------------------------
128.ChangeLine:
129 call MenuCharOut_PrintLFCRandAdjustOffsetForStartOfLine
130 jcxz .ReturnFromMovePartialWordToNewTextLine
131 ; Fall to .MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX
[52]132
133;--------------------------------------------------------------------
[104]134; .MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX
[52]135; Parameters:
136; CX: Number of BYTEs in partial word
137; DS: BDA segment (zero)
138; ES:SI: Ptr to partial word on previous line
139; ES:DI: Ptr to new empty line
140; Returns:
141; ES:DI: Ptr where to store next character
142; Corrupts registers:
143; AX, CX, DX, SI
144;--------------------------------------------------------------------
[104]145.MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX:
[52]146 push si
147 push cx
148 WAIT_RETRACE_IF_NECESSARY_THEN rep movsb
149 pop cx
150 pop si
151
152 xchg di, si
153 shr cx, 1 ; Bytes to characters
154 mov al, ' '
155 call DisplayPrint_RepeatCharacterFromALwithCountInCX
156 mov di, si
[104]157
158.ReturnFromMovePartialWordToNewTextLine:
159 pop ax
160 pop cx
161 pop si
[52]162 ret
Note: See TracBrowser for help on using the repository browser.