1 | ; Project name : Assembly Library
|
---|
2 | ; Description : Functions for splitting menu lines during character output.
|
---|
3 |
|
---|
4 | ; Section containing code
|
---|
5 | SECTION .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 | ;--------------------------------------------------------------------
|
---|
16 | ALIGN MENU_JUMP_ALIGN
|
---|
17 | CharOutLineSplitter_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 | ;--------------------------------------------------------------------
|
---|
43 | ALIGN MENU_JUMP_ALIGN
|
---|
44 | CharOutLineSplitter_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 | ;--------------------------------------------------------------------
|
---|
62 | ALIGN MENU_JUMP_ALIGN
|
---|
63 | CharOutLineSplitter_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 | ;--------------------------------------------------------------------
|
---|
88 | ALIGN MENU_JUMP_ALIGN
|
---|
89 | CharOutLineSplitter_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 | mov cx, di
|
---|
107 | mov si, di
|
---|
108 | ALIGN MENU_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 | jne SHORT .ScanNextCharacter
|
---|
114 | inc si
|
---|
115 | inc si ; SI now points one past space
|
---|
116 | sub cx, si
|
---|
117 | ; Fall to .ChangeLine
|
---|
118 |
|
---|
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
|
---|
132 |
|
---|
133 | ;--------------------------------------------------------------------
|
---|
134 | ; .MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX
|
---|
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 | ;--------------------------------------------------------------------
|
---|
145 | .MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX:
|
---|
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
|
---|
157 |
|
---|
158 | .ReturnFromMovePartialWordToNewTextLine:
|
---|
159 | pop ax
|
---|
160 | pop cx
|
---|
161 | pop si
|
---|
162 | ret
|
---|