source: xtideuniversalbios/trunk/Assembly_Library/Src/Menu/MenuLocation.asm

Last change on this file 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: 4.5 KB
Line 
1; Project name  :   Assembly Library
2; Description   :   Functions for calculation menu window dimensions.
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
21; Section containing code
22SECTION .text
23
24;--------------------------------------------------------------------
25; MenuLocation_GetTextCoordinatesToAXforItemInAX
26;   Parameters
27;       AX:     Item index
28;       SS:BP:  Ptr to MENU
29;   Returns:
30;       AL:     Column (X)
31;       AH:     Row (Y)
32;   Corrupts registers:
33;       Nothing
34;--------------------------------------------------------------------
35ALIGN MENU_JUMP_ALIGN
36MenuLocation_GetTextCoordinatesToAXforItemInAX:
37    sub     ax, [bp+MENU.wFirstVisibleItem]     ; Item to line
38    xchg    al, ah                              ; Line to AH, clear AL
39    add     ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
40    SKIP2B  f   ; cmp ax, <next instruction>
41    ; Fall to MenuLocation_GetItemBordersTopLeftCoordinatesToAX
42
43;--------------------------------------------------------------------
44; MenuLocation_GetItemBordersTopLeftCoordinatesToAX
45; MenuLocation_GetTitleTextTopLeftCoordinatesToAX
46; MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
47; MenuLocation_GetInformationTextTopLeftCoordinatesToAX
48; MenuLocation_GetBottomBordersTopLeftCoordinatesToAX
49;   Parameters
50;       SS:BP:  Ptr to MENU
51;   Returns:
52;       AL:     Column (X)
53;       AH:     Row (Y)
54;   Corrupts registers:
55;       Nothing
56;--------------------------------------------------------------------
57%ifndef EXCLUDE_FROM_XUB
58MenuLocation_GetItemBordersTopLeftCoordinatesToAX:
59%endif
60    xor     ax, ax
61    jmp     SHORT AddItemBordersTopLeftCoordinatesToAX
62
63ALIGN MENU_JUMP_ALIGN
64MenuLocation_GetTitleTextTopLeftCoordinatesToAX:
65    mov     ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
66    SKIP2B  f   ; cmp ax, <next instruction>
67MenuLocation_GetTitleBordersTopLeftCoordinatesToAX:
68    xor     ax, ax
69    jmp     SHORT MenuLocation_AddTitleBordersTopLeftCoordinatesToAX
70
71ALIGN MENU_JUMP_ALIGN
72MenuLocation_GetInformationTextTopLeftCoordinatesToAX:
73    mov     ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
74    jmp     SHORT AddInformationBordersTopLeftCoordinatesToAX
75
76ALIGN MENU_JUMP_ALIGN
77MenuLocation_GetBottomBordersTopLeftCoordinatesToAX:
78    xor     ax, ax
79    ; Fall to .AddBottomBordersTopLeftCoordinatesToAX
80
81;--------------------------------------------------------------------
82; .AddBottomBordersTopLeftCoordinatesToAX
83; AddInformationBordersTopLeftCoordinatesToAX
84; AddItemBordersTopLeftCoordinatesToAX
85; MenuLocation_AddTitleBordersTopLeftCoordinatesToAX
86;   Parameters
87;       AX:     Zero of offset
88;       SS:BP:  Ptr to MENU
89;   Returns:
90;       AL:     Column (X)
91;       AH:     Row (Y)
92;   Corrupts registers:
93;       Nothing
94;--------------------------------------------------------------------
95.AddBottomBordersTopLeftCoordinatesToAX:
96    stc                         ; Compensate for Information top border
97    adc     ah, [bp+MENUINIT.bInfoLines]
98ALIGN MENU_JUMP_ALIGN
99AddInformationBordersTopLeftCoordinatesToAX:
100    push    cx
101    call    MenuScrollbars_GetMaxVisibleItemsOnPageToCX
102    inc     cx                  ; Compensate for Items top border
103    add     ah, cl
104    pop     cx
105ALIGN MENU_JUMP_ALIGN
106AddItemBordersTopLeftCoordinatesToAX:
107    stc                         ; Compensate for Title top border
108    adc     ah, [bp+MENUINIT.bTitleLines]
109ALIGN MENU_JUMP_ALIGN
110MenuLocation_AddTitleBordersTopLeftCoordinatesToAX:
111    push    di
112    push    ax
113    CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
114    sub     al, [bp+MENUINIT.bWidth]
115    sub     ah, [bp+MENUINIT.bHeight]
116    shr     al, 1
117    shr     ah, 1
118    pop     di                  ; Old AX to DI
119    add     ax, di              ; Add old AX to menu top left coordinates
120    pop     di
121    ret
122
123
124;--------------------------------------------------------------------
125; MenuLocation_GetMaxTextLineLengthToAX
126;   Parameters
127;       SS:BP:  Ptr to MENU
128;   Returns:
129;       AX:     Maximum text line length in characters
130;   Corrupts registers:
131;       Nothing
132;--------------------------------------------------------------------
133ALIGN MENU_JUMP_ALIGN
134MenuLocation_GetMaxTextLineLengthToAX:
135    mov     ax, -(MENU_HORIZONTAL_BORDER_LINES + MENU_TEXT_COLUMN_OFFSET) & 0FFh
136    add     al, [bp+MENUINIT.bWidth]
137    ret
Note: See TracBrowser for help on using the repository browser.