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

Last change on this file since 468 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
RevLine 
[41]1; Project name : Assembly Library
2; Description : Functions for calculation menu window dimensions.
3
[376]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
[41]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;--------------------------------------------------------------------
[369]35ALIGN MENU_JUMP_ALIGN
[41]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
[181]40 SKIP2B f ; cmp ax, <next instruction>
41 ; Fall to MenuLocation_GetItemBordersTopLeftCoordinatesToAX
[41]42
43;--------------------------------------------------------------------
[181]44; MenuLocation_GetItemBordersTopLeftCoordinatesToAX
45; MenuLocation_GetTitleTextTopLeftCoordinatesToAX
[41]46; MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
[181]47; MenuLocation_GetInformationTextTopLeftCoordinatesToAX
[41]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;--------------------------------------------------------------------
[181]57MenuLocation_GetItemBordersTopLeftCoordinatesToAX:
58 xor ax, ax
59 jmp SHORT AddItemBordersTopLeftCoordinatesToAX
60
[369]61ALIGN MENU_JUMP_ALIGN
[181]62MenuLocation_GetTitleTextTopLeftCoordinatesToAX:
63 mov ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
64 SKIP2B f ; cmp ax, <next instruction>
[41]65MenuLocation_GetTitleBordersTopLeftCoordinatesToAX:
66 xor ax, ax
67 jmp SHORT MenuLocation_AddTitleBordersTopLeftCoordinatesToAX
68
[369]69ALIGN MENU_JUMP_ALIGN
[181]70MenuLocation_GetInformationTextTopLeftCoordinatesToAX:
71 mov ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
72 jmp SHORT AddInformationBordersTopLeftCoordinatesToAX
[41]73
[369]74ALIGN MENU_JUMP_ALIGN
[41]75MenuLocation_GetBottomBordersTopLeftCoordinatesToAX:
76 xor ax, ax
[104]77 ; Fall to .AddBottomBordersTopLeftCoordinatesToAX
[41]78
79;--------------------------------------------------------------------
[104]80; .AddBottomBordersTopLeftCoordinatesToAX
[41]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;--------------------------------------------------------------------
[104]93.AddBottomBordersTopLeftCoordinatesToAX:
[41]94 stc ; Compensate for Information top border
95 adc ah, [bp+MENUINIT.bInfoLines]
[369]96ALIGN MENU_JUMP_ALIGN
[41]97AddInformationBordersTopLeftCoordinatesToAX:
98 push cx
99 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
100 inc cx ; Compensate for Items top border
101 add ah, cl
102 pop cx
[369]103ALIGN MENU_JUMP_ALIGN
[41]104AddItemBordersTopLeftCoordinatesToAX:
105 stc ; Compensate for Title top border
106 adc ah, [bp+MENUINIT.bTitleLines]
[369]107ALIGN MENU_JUMP_ALIGN
[41]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;--------------------------------------------------------------------
[369]131ALIGN MENU_JUMP_ALIGN
[41]132MenuLocation_GetMaxTextLineLengthToAX:
[293]133 eMOVZX ax, [bp+MENUINIT.bWidth]
[41]134 sub ax, BYTE MENU_HORIZONTAL_BORDER_LINES + MENU_TEXT_COLUMN_OFFSET
135 ret
Note: See TracBrowser for help on using the repository browser.