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

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

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

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-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
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;--------------------------------------------------------------------
57MenuLocation_GetItemBordersTopLeftCoordinatesToAX:
58 xor ax, ax
59 jmp SHORT AddItemBordersTopLeftCoordinatesToAX
60
61ALIGN MENU_JUMP_ALIGN
62MenuLocation_GetTitleTextTopLeftCoordinatesToAX:
63 mov ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
64 SKIP2B f ; cmp ax, <next instruction>
65MenuLocation_GetTitleBordersTopLeftCoordinatesToAX:
66 xor ax, ax
67 jmp SHORT MenuLocation_AddTitleBordersTopLeftCoordinatesToAX
68
69ALIGN MENU_JUMP_ALIGN
70MenuLocation_GetInformationTextTopLeftCoordinatesToAX:
71 mov ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
72 jmp SHORT AddInformationBordersTopLeftCoordinatesToAX
73
74ALIGN MENU_JUMP_ALIGN
75MenuLocation_GetBottomBordersTopLeftCoordinatesToAX:
76 xor ax, ax
77 ; Fall to .AddBottomBordersTopLeftCoordinatesToAX
78
79;--------------------------------------------------------------------
80; .AddBottomBordersTopLeftCoordinatesToAX
81; AddInformationBordersTopLeftCoordinatesToAX
82; AddItemBordersTopLeftCoordinatesToAX
83; MenuLocation_AddTitleBordersTopLeftCoordinatesToAX
84; Parameters
85; AX: Zero of offset
86; SS:BP: Ptr to MENU
87; Returns:
88; AL: Column (X)
89; AH: Row (Y)
90; Corrupts registers:
91; Nothing
92;--------------------------------------------------------------------
93.AddBottomBordersTopLeftCoordinatesToAX:
94 stc ; Compensate for Information top border
95 adc ah, [bp+MENUINIT.bInfoLines]
96ALIGN MENU_JUMP_ALIGN
97AddInformationBordersTopLeftCoordinatesToAX:
98 push cx
99 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
100 inc cx ; Compensate for Items top border
101 add ah, cl
102 pop cx
103ALIGN MENU_JUMP_ALIGN
104AddItemBordersTopLeftCoordinatesToAX:
105 stc ; Compensate for Title top border
106 adc ah, [bp+MENUINIT.bTitleLines]
107ALIGN MENU_JUMP_ALIGN
108MenuLocation_AddTitleBordersTopLeftCoordinatesToAX:
109 push di
110 push ax
111 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
112 sub al, [bp+MENUINIT.bWidth]
113 sub ah, [bp+MENUINIT.bHeight]
114 shr al, 1
115 shr ah, 1
116 pop di ; Old AX to DI
117 add ax, di ; Add old AX to menu top left coordinates
118 pop di
119 ret
120
121
122;--------------------------------------------------------------------
123; MenuLocation_GetMaxTextLineLengthToAX
124; Parameters
125; SS:BP: Ptr to MENU
126; Returns:
127; AX: Maximum text line length in characters
128; Corrupts registers:
129; Nothing
130;--------------------------------------------------------------------
131ALIGN MENU_JUMP_ALIGN
132MenuLocation_GetMaxTextLineLengthToAX:
133 eMOVZX ax, [bp+MENUINIT.bWidth]
134 sub ax, BYTE MENU_HORIZONTAL_BORDER_LINES + MENU_TEXT_COLUMN_OFFSET
135 ret
Note: See TracBrowser for help on using the repository browser.