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

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

Changes:

  • A speed optimization to the eSHL_IM macro for 386 and higher. This change breaks emulation in the sense that the macro will fail when given a memory operand as the first parameter.
  • Memory_SumCXbytesFromESSItoAL now returns with the zero flag set/cleared according to the result.
  • Unrolled all the 8 bit READ transfer loops to do 16 bytes per iteration. Added a new macro (UNROLL_SECTORS_IN_CX_TO_OWORDS) as part of it. Size wise this is expensive but I think it should be worth the ROM space. The WRITE transfer loops were left as is since writes are rare anyway (<10% of all disk I/O IIRC).
  • Minor optimizations and fixes here and there.
File size: 6.0 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;--------------------------------------------------------------------
50ALIGN DISPLAY_JUMP_ALIGN
51DisplayCursor_SetShapeFromAX:
52 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCursorShape], ax
53 ret
54
55
56;--------------------------------------------------------------------
57; DisplayCursor_SetCoordinatesFromAX
58; Parameters:
59; AL: Cursor column (X-coordinate)
60; AH: Cursor row (Y-coordinate)
61; DS: BDA segment (zero)
62; Returns:
63; DI: Offset to cursor location in video RAM
64; Corrupts registers:
65; AX, DX
66;--------------------------------------------------------------------
67ALIGN DISPLAY_JUMP_ALIGN
68DisplayCursor_SetCoordinatesFromAX:
69 xchg dx, ax
70 mov ax, [VIDEO_BDA.wColumns] ; Column count, 40 or 80
71 mul dh ; AX = Column count * row index
72 xor dh, dh
73 add ax, dx ; Add column offset
74 eSHL_IM ax, 1 ; Convert to WORD offset
75 add ax, [VIDEO_BDA.wPageOffset] ; AX = Video RAM offset
76 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition], ax
77 xchg di, ax
78 ret
79
80
81;--------------------------------------------------------------------
82; DisplayCursor_GetSoftwareCoordinatesToAX
83; Parameters:
84; AX: Offset to cursor location in selected page
85; DS: BDA segment (zero)
86; Returns:
87; AL: Cursor column (X-coordinate)
88; AH: Cursor row (Y-coordinate)
89; Corrupts registers:
90; Nothing
91;--------------------------------------------------------------------
92ALIGN DISPLAY_JUMP_ALIGN
93DisplayCursor_GetSoftwareCoordinatesToAX:
94 mov ax, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition]
95 sub ax, [VIDEO_BDA.wPageOffset]
96 shr ax, 1 ; WORD offset to character offset
97 div BYTE [VIDEO_BDA.wColumns] ; AL = full rows, AH = column index for last row
98 xchg al, ah
99 ret
100
101
102;--------------------------------------------------------------------
103; DisplayCursor_GetHardwareCoordinatesToAX
104; Parameters:
105; DS: BDA segment (zero)
106; Returns:
107; AL: Hardware cursor column (X-coordinate)
108; AH: Hardware cursor row (Y-coordinate)
109; Corrupts registers:
110; DX
111;--------------------------------------------------------------------
112ALIGN DISPLAY_JUMP_ALIGN
113DisplayCursor_GetHardwareCoordinatesToAX:
114 push cx
115 push bx
116
117 mov ah, GET_CURSOR_POSITION_AND_SIZE
118 mov bh, [VIDEO_BDA.bActivePage]
119 int BIOS_VIDEO_INTERRUPT_10h
120 xchg ax, dx
121
122 pop bx
123 pop cx
124 ret
125
126
127;--------------------------------------------------------------------
128; DisplayCursor_SynchronizeShapeToHardware
129; Parameters:
130; DS: BDA segment (zero)
131; Returns:
132; Nothing
133; Corrupts registers:
134; AX, DX
135;--------------------------------------------------------------------
136ALIGN DISPLAY_JUMP_ALIGN
137DisplayCursor_SynchronizeShapeToHardware:
138 mov dx, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCursorShape]
139 ; Fall to .SetHardwareCursorShapeFromDX
140
141;--------------------------------------------------------------------
142; .SetHardwareCursorShapeFromDX
143; Parameters:
144; DX: Cursor shape
145; DS: BDA segment (zero)
146; Returns:
147; Nothing
148; Corrupts registers:
149; AX
150;--------------------------------------------------------------------
151.SetHardwareCursorShapeFromDX:
152 cmp dx, [VIDEO_BDA.wCursorShape]
153 je SHORT .Return ; Return if no changes
154 push cx
155 mov cx, dx ; BIOS wants cursor shape in CX
156 mov al, [VIDEO_BDA.bMode] ; Load video mode to prevent lock ups on some BIOSes
157 mov ah, SET_TEXT_MODE_CURSOR_SHAPE
158 int BIOS_VIDEO_INTERRUPT_10h
159 pop cx
160.Return:
161 ret
162
163
164;--------------------------------------------------------------------
165; DisplayCursor_SynchronizeCoordinatesToHardware
166; Parameters:
167; DS: BDA segment (zero)
168; Returns:
169; Nothing
170; Corrupts registers:
171; AX, DX
172;--------------------------------------------------------------------
173ALIGN DISPLAY_JUMP_ALIGN
174DisplayCursor_SynchronizeCoordinatesToHardware:
175 call DisplayCursor_GetSoftwareCoordinatesToAX
176 ; Fall to .SetHardwareCursorCoordinatesFromAX
177
178;--------------------------------------------------------------------
179; .SetHardwareCursorCoordinatesFromAX
180; Parameters:
181; AL: Cursor column (X-coordinate)
182; AH: Cursor row (Y-coordinate)
183; DS: BDA segment (zero)
184; Returns:
185; Nothing
186; Corrupts registers:
187; AX, DX
188;--------------------------------------------------------------------
189.SetHardwareCursorCoordinatesFromAX:
190 push bx
191 xchg dx, ax ; BIOS wants coordinates in DX
192 mov ah, SET_CURSOR_POSITION
193 mov bh, [VIDEO_BDA.bActivePage]
194 int BIOS_VIDEO_INTERRUPT_10h
195 pop bx
196 ret
Note: See TracBrowser for help on using the repository browser.