source: xtideuniversalbios/trunk/Assembly_Library/Src/Display/DisplayCursor.asm@ 231

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

Changes to Assembly Library:

  • Some minor size optimizations to Display Library.
File size: 4.8 KB
RevLine 
[41]1; Project name : Assembly Library
2; Description : Functions for managing display cursor.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; DisplayCursor_SetShapeFromAX
9; Parameters:
10; AX: Cursor shape (AH=Start scan line, AL=End scan line)
11; DS: BDA segment (zero)
12; Returns:
13; Nothing
14; Corrupts registers:
15; Nothing
16;--------------------------------------------------------------------
17ALIGN JUMP_ALIGN
18DisplayCursor_SetShapeFromAX:
19 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCursorShape], ax
20 ret
21
22
23;--------------------------------------------------------------------
24; DisplayCursor_SetCoordinatesFromAX
25; Parameters:
26; AL: Cursor column (X-coordinate)
27; AH: Cursor row (Y-coordinate)
28; DS: BDA segment (zero)
29; Returns:
30; DI: Offset to cursor location in video RAM
31; Corrupts registers:
32; AX, DX
33;--------------------------------------------------------------------
34ALIGN JUMP_ALIGN
35DisplayCursor_SetCoordinatesFromAX:
36 xchg dx, ax
37 mov ax, [VIDEO_BDA.wColumns] ; Column count, 40 or 80
38 mul dh ; AX = Column count * row index
[101]39 xor dh, dh
40 add ax, dx ; Add column offset
[41]41 shl ax, 1 ; Convert to WORD offset
[101]42 add ax, [VIDEO_BDA.wPageOffset] ; AX = Video RAM offset
43 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition], ax
44 xchg di, ax
[41]45 ret
46
47
48;--------------------------------------------------------------------
49; DisplayCursor_GetSoftwareCoordinatesToAX
50; Parameters:
51; AX: Offset to cursor location in selected page
52; DS: BDA segment (zero)
53; Returns:
54; AL: Cursor column (X-coordinate)
55; AH: Cursor row (Y-coordinate)
56; Corrupts registers:
57; Nothing
58;--------------------------------------------------------------------
59ALIGN JUMP_ALIGN
60DisplayCursor_GetSoftwareCoordinatesToAX:
61 mov ax, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition]
62 sub ax, [VIDEO_BDA.wPageOffset]
63 shr ax, 1 ; WORD offset to character offset
64 div BYTE [VIDEO_BDA.wColumns] ; AL = full rows, AH = column index for last row
65 xchg al, ah
66 ret
67
68
69;--------------------------------------------------------------------
70; DisplayCursor_GetHardwareCoordinatesToAX
71; Parameters:
72; DS: BDA segment (zero)
73; Returns:
74; AL: Hardware cursor column (X-coordinate)
75; AH: Hardware cursor row (Y-coordinate)
76; Corrupts registers:
77; DX
78;--------------------------------------------------------------------
79ALIGN JUMP_ALIGN
80DisplayCursor_GetHardwareCoordinatesToAX:
81 push cx
82 push bx
83
84 mov ah, GET_CURSOR_POSITION_AND_SIZE
85 mov bh, [VIDEO_BDA.bActivePage]
86 int BIOS_VIDEO_INTERRUPT_10h
87 xchg ax, dx
88
89 pop bx
90 pop cx
91 ret
92
93
94;--------------------------------------------------------------------
95; DisplayCursor_SynchronizeShapeToHardware
96; Parameters:
97; DS: BDA segment (zero)
98; Returns:
99; Nothing
100; Corrupts registers:
101; AX, DX
102;--------------------------------------------------------------------
103ALIGN JUMP_ALIGN
104DisplayCursor_SynchronizeShapeToHardware:
105 mov dx, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCursorShape]
106 ; Fall to .SetHardwareCursorShapeFromDX
107
108;--------------------------------------------------------------------
109; .SetHardwareCursorShapeFromDX
110; Parameters:
111; DX: Cursor shape
112; DS: BDA segment (zero)
113; Returns:
114; Nothing
115; Corrupts registers:
116; AX
117;--------------------------------------------------------------------
118.SetHardwareCursorShapeFromDX:
119 cmp dx, [VIDEO_BDA.wCursorShape]
120 je SHORT .Return ; Return if no changes
121 push cx
122 mov cx, dx ; BIOS wants cursor shape in CX
123 mov al, [VIDEO_BDA.bMode] ; Load video mode to prevent lock ups on some BIOSes
124 mov ah, SET_TEXT_MODE_CURSOR_SHAPE
125 int BIOS_VIDEO_INTERRUPT_10h
126 pop cx
127.Return:
128 ret
129
130
131;--------------------------------------------------------------------
132; DisplayCursor_SynchronizeCoordinatesToHardware
133; Parameters:
134; DS: BDA segment (zero)
135; Returns:
136; Nothing
137; Corrupts registers:
138; AX, DX
139;--------------------------------------------------------------------
140ALIGN JUMP_ALIGN
141DisplayCursor_SynchronizeCoordinatesToHardware:
142 call DisplayCursor_GetSoftwareCoordinatesToAX
143 ; Fall to .SetHardwareCursorCoordinatesFromAX
144
145;--------------------------------------------------------------------
146; .SetHardwareCursorCoordinatesFromAX
147; Parameters:
148; AL: Cursor column (X-coordinate)
149; AH: Cursor row (Y-coordinate)
150; DS: BDA segment (zero)
151; Returns:
152; Nothing
153; Corrupts registers:
154; AX, DX
155;--------------------------------------------------------------------
156.SetHardwareCursorCoordinatesFromAX:
157 push bx
158 xchg dx, ax ; BIOS wants coordinates in DX
159 mov ah, SET_CURSOR_POSITION
160 mov bh, [VIDEO_BDA.bActivePage]
161 int BIOS_VIDEO_INTERRUPT_10h
162 pop bx
163 ret
Note: See TracBrowser for help on using the repository browser.