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

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

Changes:

  • Update of the copyright notices to include the year 2013.
File size: 4.6 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_XTIDE_UNIVERSAL_BIOS
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 eMOVZX ax, [bp+MENUINIT.bWidth]
136 sub ax, BYTE MENU_HORIZONTAL_BORDER_LINES + MENU_TEXT_COLUMN_OFFSET
137 ret
Note: See TracBrowser for help on using the repository browser.