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

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

Removed align directives for initalization code and added define for align in boot-time calls to the assembly library (defaulting to 1), resulting in a significant savings for the AT and 386 builds. Fixed a bug with switch command line handling in the serial server. Put in CR characters in licesnse.txt, so that it properly displays on Windows. In the configurator, added default values for user supplied CHS and LBA values, defaulting to values within range when those features are enabled. Updated the copyright message in the configurator as the literal word Copyright is important.

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;--------------------------------------------------------------------
[369]17ALIGN DISPLAY_JUMP_ALIGN
[41]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;--------------------------------------------------------------------
[369]34ALIGN DISPLAY_JUMP_ALIGN
[41]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;--------------------------------------------------------------------
[369]59ALIGN DISPLAY_JUMP_ALIGN
[41]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;--------------------------------------------------------------------
[369]79ALIGN DISPLAY_JUMP_ALIGN
[41]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;--------------------------------------------------------------------
[369]103ALIGN DISPLAY_JUMP_ALIGN
[41]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;--------------------------------------------------------------------
[369]140ALIGN DISPLAY_JUMP_ALIGN
[41]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.