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

Last change on this file since 592 was 592, checked in by krille_n_, 6 years ago

Changes:

  • The problem with NASM in the previous revision (r591) has been fixed.
  • The colors used by the boot menu and hotkey bar can now be customized by selecting one of a number of pre-defined color themes. Suggestions for additional themes are more than welcome!
  • Large builds are now 10 KB. Small builds are still 8 KB with the exception of the Tiny build which is now 4 KB. In other words, builds are now as small as possible to make it easier to combine them with other BIOSes.
  • Added code to the library to improve drive error handling. XTIDECFG can now handle "Drive Not Ready" errors.
  • Fixed a couple of potential bugs in AtaID.asm (AtaID_GetMaxPioModeToAXandMinCycleTimeToCX); 1) ATA1.bPioMode was treated as a WORD variable. 2) ATA2.bPIOSupp was assumed to be non-zero which would result in PIO mode 3 being returned if the assumption was wrong.
  • Made the same changes in the equivalent function used by BIOSDRVS (DisplayPioModeInformationUsingAtaInfoFromDSBX in AtaInfo.asm).
  • Fixed a bug from r587 in PDC20x30.asm in PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX.
  • Fixed a bug from r523 in XTIDECFG where Auto Configure would only set the IRQ on one IDE interface on AT-builds.
  • XTIDECFG will now restore the default settings for the "Serial port virtual device" when reselecting it in the list of device types. This makes it behave consistently for all device types.
  • The eAAM macro is now used regardless if USE_UNDOC_INTEL is defined or not because it is apparently supported on all processors including the NEC V20/V30 CPUs.
  • Renamed the EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS define to EXCLUDE_FROM_XUB.
  • Added a define to exclude unused library code from BIOSDRVS (EXCLUDE_FROM_BIOSDRVS). This makes it a lot smaller than in previous revisions.
  • All unnecessary CLD-instructions are now under a new define 'CLD_NEEDED' which is only enabled for the BIOS. It is disabled for XTIDECFG and BIOSDRVS but can be enabled if needed by adding this define to the respective makefile. This change was made because these unnecessary instructions are wasteful and should never be needed. In fact, they only serve to hide bugs (in other peoples code) which I strongly believe should be avoided. I recommend people making their own BIOSes from source to not use this define as it's extremely unlikely to be needed.
  • Updated the copyright info in SerDrive and changed an URL to point to the new site.
  • Updated the copyright info and version number in BIOSDRVS.
  • Updated the copyright info in XTIDECFG.
  • Optimizations 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-2013 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_XUB
51    %ifndef MODULE_BOOT_MENU
52        %define EXCLUDE
53    %endif
54%endif
55
56%ifndef EXCLUDE OR EXCLUDE_FROM_BIOSDRVS
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.