source: xtideuniversalbios/trunk/Assembly_Library/Src/Display/DisplayContext.asm@ 42

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

Initial commit for Assembly Library.

File size: 6.2 KB
Line 
1; File name : DisplayContext.asm
2; Project name : Assembly Library
3; Created date : 25.6.2010
4; Last update : 13.8.2010
5; Author : Tomi Tilli
6; Description : Functions for managing display context.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; DisplayContext_Initialize
13; Parameters:
14; DS: BDA segment (zero)
15; Returns:
16; Nothing
17; Corrupts registers:
18; AX, DX, DI
19;--------------------------------------------------------------------
20ALIGN JUMP_ALIGN
21DisplayContext_Initialize:
22 call .DetectAndSetDisplaySegment
23 mov WORD [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut], DEFAULT_CHARACTER_OUTPUT
24 mov WORD [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCursorShape], CURSOR_NORMAL
25 mov BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute], MONO_NORMAL
26
27 xor ax, ax
28 call DisplayCursor_SetCoordinatesFromAX
29 jmp SHORT DisplayContext_SynchronizeToHardware
30
31;--------------------------------------------------------------------
32; .DetectAndSetDisplaySegment
33; Parameters:
34; DS: BDA segment (zero)
35; Returns:
36; Nothing
37; Corrupts registers:
38; Nothing
39;--------------------------------------------------------------------
40.DetectAndSetDisplaySegment:
41 mov WORD [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2], COLOR_TEXT_SEGMENT
42 cmp BYTE [VIDEO_BDA.bMode], MDA_TEXT_MODE
43 jne SHORT .Return
44 sub WORD [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2], COLOR_TEXT_SEGMENT - MONO_TEXT_SEGMENT
45.Return:
46 ret
47
48
49;--------------------------------------------------------------------
50; DisplayContext_Push
51; Parameters:
52; Nothing
53; Returns:
54; Nothing
55; Corrupts registers:
56; AX, DI
57;--------------------------------------------------------------------
58ALIGN JUMP_ALIGN
59DisplayContext_Push:
60 mov di, ds ; Backup DS
61 LOAD_BDA_SEGMENT_TO ds, ax
62 pop ax ; Pop return address
63
64 %assign i 0
65 %rep DISPLAY_CONTEXT_size / 2
66 push WORD [VIDEO_BDA.displayContext + i]
67 %assign i i+2
68 %endrep
69
70 mov ds, di ; Restore DS
71 jmp ax
72
73;--------------------------------------------------------------------
74; DisplayContext_Pop
75; Parameters:
76; Nothing
77; Returns:
78; Nothing
79; Corrupts registers:
80; AX, DI
81;--------------------------------------------------------------------
82ALIGN JUMP_ALIGN
83DisplayContext_Pop:
84 mov di, ds ; Backup DS
85 LOAD_BDA_SEGMENT_TO ds, ax
86 pop ax ; Pop return address
87
88 %assign i DISPLAY_CONTEXT_size-2
89 %rep DISPLAY_CONTEXT_size / 2
90 pop WORD [VIDEO_BDA.displayContext + i]
91 %assign i i-2
92 %endrep
93
94 push ax ; Push return address
95 push dx
96 call DisplayContext_SynchronizeToHardware
97 pop dx
98 mov ds, di ; Restore DS
99 ret
100
101
102;--------------------------------------------------------------------
103; DisplayContext_SynchronizeToHardware
104; Parameters:
105; DS: BDA segment (zero)
106; Returns:
107; Nothing
108; Corrupts registers:
109; AX, DX
110;--------------------------------------------------------------------
111ALIGN JUMP_ALIGN
112DisplayContext_SynchronizeToHardware:
113 call DisplayPage_SynchronizeToHardware
114 call DisplayCursor_SynchronizeShapeToHardware
115 jmp DisplayCursor_SynchronizeCoordinatesToHardware
116
117
118;--------------------------------------------------------------------
119; DisplayContext_SetCharacterPointerFromBXAX
120; Parameters:
121; BX:AX: Ptr to destination for next character to output
122; DS: BDA segment (zero)
123; Returns:
124; ES:DI: Pointer that was in DX:AX
125; Corrupts registers:
126; AX
127;--------------------------------------------------------------------
128ALIGN JUMP_ALIGN
129DisplayContext_SetCharacterPointerFromBXAX:
130 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition], ax
131 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2], bx
132 xchg di, ax
133 mov es, bx
134 ret
135
136
137;--------------------------------------------------------------------
138; DisplayContext_GetCharacterPointerToBXAX
139; Parameters:
140; DS: BDA segment (zero)
141; Returns:
142; BX:AX: Ptr to destination for next character to output
143; Corrupts registers:
144; Nothing
145;--------------------------------------------------------------------
146ALIGN JUMP_ALIGN
147DisplayContext_GetCharacterPointerToBXAX:
148 mov ax, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition]
149 mov bx, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2]
150 ret
151
152
153;--------------------------------------------------------------------
154; DisplayContext_SetCharacterOutputFunctionFromAX
155; Parameters:
156; AX: Offset to character output function
157; DS: BDA segment (zero)
158; Returns:
159; Nothing
160; Corrupts registers:
161; Nothing
162;--------------------------------------------------------------------
163ALIGN JUMP_ALIGN
164DisplayContext_SetCharacterOutputFunctionFromAX:
165 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut], ax
166 ret
167
168
169;--------------------------------------------------------------------
170; DisplayContext_SetCharacterAttributeFromAL
171; Parameters:
172; AL: Character attribute
173; DS: BDA segment (zero)
174; Returns:
175; Nothing
176; Corrupts registers:
177; Nothing
178;--------------------------------------------------------------------
179ALIGN JUMP_ALIGN
180DisplayContext_SetCharacterAttributeFromAL:
181 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute], al
182 ret
183
184
185;--------------------------------------------------------------------
186; DisplayContext_SetCharacterOutputParameterFromAX
187; Parameters:
188; AX: Parameter for Character Output function
189; DS: BDA segment (zero)
190; Returns:
191; Nothing
192; Corrupts registers:
193; Nothing
194;--------------------------------------------------------------------
195ALIGN JUMP_ALIGN
196DisplayContext_SetCharacterOutputParameterFromAX:
197 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam], ax
198 ret
199
200;--------------------------------------------------------------------
201; DisplayContext_GetCharacterOutputParameterToDX
202; Parameters:
203; DS: BDA segment (zero)
204; Returns:
205; DX: User parameter for Character Output function
206; Corrupts registers:
207; Nothing
208;--------------------------------------------------------------------
209ALIGN JUMP_ALIGN
210DisplayContext_GetCharacterOutputParameterToDX:
211 mov dx, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam]
212 ret
Note: See TracBrowser for help on using the repository browser.