source: xtideuniversalbios/tags/v2.0.0_beta_3/Assembly_Library/Src/Display/DisplayCursor.asm@ 514

Last change on this file since 514 was 491, checked in by krille_n_@…, 12 years ago

Changes:

  • Added a new define (USE_UNDOC_INTEL) that enables optimizations possible by using undocumented instructions available on all Intel processors and truly compatible clones. AFAIK the only exceptions are the NEC V-series and the Sony CXQ70108 processors so this option should be safe for use on the AT builds.
  • Building BIOSDRVS or the BIOS without MODULE_STRINGS_COMPRESSED would fail due to the recent code exclusions so I changed them a bit. Also fixed the mistaken change to Main.asm
  • Changed the Tandy specific info in Configuration_FullMode.txt so it matches the info in the Wiki.
  • Optimizations and fixes in general.
File size: 6.2 KB
Line 
1; Project name : Assembly Library
2; Description : Functions for managing display cursor.
3
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
20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; DisplayCursor_GetDefaultCursorShapeToAX
25; Parameters:
26; DS: BDA segment (zero)
27; Returns:
28; AX: Default text mode cursor shape
29; Corrupts registers:
30; Nothing
31;--------------------------------------------------------------------
32ALIGN DISPLAY_JUMP_ALIGN
33DisplayCursor_GetDefaultCursorShapeToAX:
34 mov ax, CURSOR_NORMAL_COLOR ; CGA, EGA, VGA cursor
35 cmp BYTE [VIDEO_BDA.bMode], MDA_TEXT_MODE
36 eCMOVE ax, CURSOR_NORMAL_MDA ; MDA cursor
37 ret
38
39
40;--------------------------------------------------------------------
41; DisplayCursor_SetShapeFromAX
42; Parameters:
43; AX: Cursor shape (AH=Start scan line, AL=End scan line)
44; DS: BDA segment (zero)
45; Returns:
46; Nothing
47; Corrupts registers:
48; Nothing
49;--------------------------------------------------------------------
50%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
51 %ifndef MODULE_BOOT_MENU
52 %define EXCLUDE
53 %endif
54%endif
55
56%ifndef EXCLUDE
57ALIGN DISPLAY_JUMP_ALIGN
58DisplayCursor_SetShapeFromAX:
59 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCursorShape], ax
60 ret
61%endif
62%undef EXCLUDE
63
64
65;--------------------------------------------------------------------
66; DisplayCursor_SetCoordinatesFromAX
67; Parameters:
68; AL: Cursor column (X-coordinate)
69; AH: Cursor row (Y-coordinate)
70; DS: BDA segment (zero)
71; Returns:
72; DI: Offset to cursor location in video RAM
73; Corrupts registers:
74; AX, DX
75;--------------------------------------------------------------------
76ALIGN DISPLAY_JUMP_ALIGN
77DisplayCursor_SetCoordinatesFromAX:
78 xchg dx, ax
79 mov ax, [VIDEO_BDA.wColumns] ; Column count, 40 or 80
80 mul dh ; AX = Column count * row index
81 xor dh, dh
82 add ax, dx ; Add column offset
83 eSHL_IM ax, 1 ; Convert to WORD offset
84 add ax, [VIDEO_BDA.wPageOffset] ; AX = Video RAM offset
85 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition], ax
86 xchg di, ax
87 ret
88
89
90;--------------------------------------------------------------------
91; DisplayCursor_GetSoftwareCoordinatesToAX
92; Parameters:
93; AX: Offset to cursor location in selected page
94; DS: BDA segment (zero)
95; Returns:
96; AL: Cursor column (X-coordinate)
97; AH: Cursor row (Y-coordinate)
98; Corrupts registers:
99; Nothing
100;--------------------------------------------------------------------
101ALIGN DISPLAY_JUMP_ALIGN
102DisplayCursor_GetSoftwareCoordinatesToAX:
103 mov ax, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition]
104 sub ax, [VIDEO_BDA.wPageOffset]
105 shr ax, 1 ; WORD offset to character offset
106 div BYTE [VIDEO_BDA.wColumns] ; AL = full rows, AH = column index for last row
107 xchg al, ah
108 ret
109
110
111;--------------------------------------------------------------------
112; DisplayCursor_GetHardwareCoordinatesToAX
113; Parameters:
114; DS: BDA segment (zero)
115; Returns:
116; AL: Hardware cursor column (X-coordinate)
117; AH: Hardware cursor row (Y-coordinate)
118; Corrupts registers:
119; DX
120;--------------------------------------------------------------------
121ALIGN DISPLAY_JUMP_ALIGN
122DisplayCursor_GetHardwareCoordinatesToAX:
123 push cx
124 push bx
125
126 mov ah, GET_CURSOR_POSITION_AND_SIZE
127 mov bh, [VIDEO_BDA.bActivePage]
128 int BIOS_VIDEO_INTERRUPT_10h
129 xchg ax, dx
130
131 pop bx
132 pop cx
133 ret
134
135
136;--------------------------------------------------------------------
137; DisplayCursor_SynchronizeShapeToHardware
138; Parameters:
139; DS: BDA segment (zero)
140; Returns:
141; Nothing
142; Corrupts registers:
143; AX, DX
144;--------------------------------------------------------------------
145ALIGN DISPLAY_JUMP_ALIGN
146DisplayCursor_SynchronizeShapeToHardware:
147 mov dx, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCursorShape]
148 ; Fall to .SetHardwareCursorShapeFromDX
149
150;--------------------------------------------------------------------
151; .SetHardwareCursorShapeFromDX
152; Parameters:
153; DX: Cursor shape
154; DS: BDA segment (zero)
155; Returns:
156; Nothing
157; Corrupts registers:
158; AX
159;--------------------------------------------------------------------
160.SetHardwareCursorShapeFromDX:
161 cmp dx, [VIDEO_BDA.wCursorShape]
162 je SHORT .Return ; Return if no changes
163 push cx
164 mov cx, dx ; BIOS wants cursor shape in CX
165 mov al, [VIDEO_BDA.bMode] ; Load video mode to prevent lock ups on some BIOSes
166 mov ah, SET_TEXT_MODE_CURSOR_SHAPE
167 int BIOS_VIDEO_INTERRUPT_10h
168 pop cx
169.Return:
170 ret
171
172
173;--------------------------------------------------------------------
174; DisplayCursor_SynchronizeCoordinatesToHardware
175; Parameters:
176; DS: BDA segment (zero)
177; Returns:
178; Nothing
179; Corrupts registers:
180; AX, DX
181;--------------------------------------------------------------------
182ALIGN DISPLAY_JUMP_ALIGN
183DisplayCursor_SynchronizeCoordinatesToHardware:
184 call DisplayCursor_GetSoftwareCoordinatesToAX
185 ; Fall to .SetHardwareCursorCoordinatesFromAX
186
187;--------------------------------------------------------------------
188; .SetHardwareCursorCoordinatesFromAX
189; Parameters:
190; AL: Cursor column (X-coordinate)
191; AH: Cursor row (Y-coordinate)
192; DS: BDA segment (zero)
193; Returns:
194; Nothing
195; Corrupts registers:
196; AX, DX
197;--------------------------------------------------------------------
198.SetHardwareCursorCoordinatesFromAX:
199 push bx
200 xchg dx, ax ; BIOS wants coordinates in DX
201 mov ah, SET_CURSOR_POSITION
202 mov bh, [VIDEO_BDA.bActivePage]
203 int BIOS_VIDEO_INTERRUPT_10h
204 pop bx
205 ret
Note: See TracBrowser for help on using the repository browser.