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

Last change on this file since 399 was 376, checked in by gregli@…, 13 years ago

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

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