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

Last change on this file since 53 was 41, checked in by Tomi Tilli, 14 years ago

Initial commit for Assembly Library.

File size: 4.9 KB
RevLine 
[41]1; File name : MenuLocation.asm
2; Project name : Assembly Library
3; Created date : 14.7.2010
4; Last update : 11.8.2010
5; Author : Tomi Tilli
6; Description : Functions for calculation menu window dimensions.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; MenuLocation_GetScrollbarCoordinatesToAXforItemInAX
13; Parameters
14; AX: Item index
15; SS:BP: Ptr to MENU
16; Returns:
17; AL: Column (X)
18; AH: Row (Y)
19; Corrupts registers:
20; Nothing
21;--------------------------------------------------------------------
22ALIGN JUMP_ALIGN
23MenuLocation_GetScrollbarCoordinatesToAXforItemInAX:
24 call MenuLocation_GetTextCoordinatesToAXforItemInAX
25 add al, [bp+MENUINIT.bWidth]
26 sub al, MENU_TEXT_COLUMN_OFFSET*2
27 ret
28
29
30;--------------------------------------------------------------------
31; MenuLocation_GetTitleTextTopLeftCoordinatesToAX
32; MenuLocation_GetInformationTextTopLeftCoordinatesToAX
33; Parameters
34; SS:BP: Ptr to MENU
35; Returns:
36; AL: Column (X)
37; AH: Row (Y)
38; Corrupts registers:
39; Nothing
40;--------------------------------------------------------------------
41ALIGN JUMP_ALIGN
42MenuLocation_GetTitleTextTopLeftCoordinatesToAX:
43 mov ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
44 jmp SHORT MenuLocation_AddTitleBordersTopLeftCoordinatesToAX
45
46ALIGN JUMP_ALIGN
47MenuLocation_GetInformationTextTopLeftCoordinatesToAX:
48 mov ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
49 jmp SHORT AddInformationBordersTopLeftCoordinatesToAX
50
51
52;--------------------------------------------------------------------
53; MenuLocation_GetTextCoordinatesToAXforItemInAX
54; Parameters
55; AX: Item index
56; SS:BP: Ptr to MENU
57; Returns:
58; AL: Column (X)
59; AH: Row (Y)
60; Corrupts registers:
61; Nothing
62;--------------------------------------------------------------------
63ALIGN JUMP_ALIGN
64MenuLocation_GetTextCoordinatesToAXforItemInAX:
65 sub ax, [bp+MENU.wFirstVisibleItem] ; Item to line
66 xchg al, ah ; Line to AH, clear AL
67 add ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
68 jmp SHORT AddItemBordersTopLeftCoordinatesToAX
69
70
71;--------------------------------------------------------------------
72; MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
73; MenuLocation_GetItemBordersTopLeftCoordinatesToAX
74; MenuLocation_GetInformationBordersTopLeftCoordinatesToAX
75; MenuLocation_GetBottomBordersTopLeftCoordinatesToAX
76; Parameters
77; SS:BP: Ptr to MENU
78; Returns:
79; AL: Column (X)
80; AH: Row (Y)
81; Corrupts registers:
82; Nothing
83;--------------------------------------------------------------------
84ALIGN JUMP_ALIGN
85MenuLocation_GetTitleBordersTopLeftCoordinatesToAX:
86 xor ax, ax
87 jmp SHORT MenuLocation_AddTitleBordersTopLeftCoordinatesToAX
88
89ALIGN JUMP_ALIGN
90MenuLocation_GetItemBordersTopLeftCoordinatesToAX:
91 xor ax, ax
92 jmp SHORT AddItemBordersTopLeftCoordinatesToAX
93
94ALIGN JUMP_ALIGN
95MenuLocation_GetInformationBordersTopLeftCoordinatesToAX:
96 xor ax, ax
97 jmp SHORT AddInformationBordersTopLeftCoordinatesToAX
98
99ALIGN JUMP_ALIGN
100MenuLocation_GetBottomBordersTopLeftCoordinatesToAX:
101 xor ax, ax
102 ; Fall to AddBottomBordersTopLeftCoordinatesToAX
103
104;--------------------------------------------------------------------
105; AddBottomBordersTopLeftCoordinatesToAX
106; AddInformationBordersTopLeftCoordinatesToAX
107; AddItemBordersTopLeftCoordinatesToAX
108; MenuLocation_AddTitleBordersTopLeftCoordinatesToAX
109; Parameters
110; AX: Zero of offset
111; SS:BP: Ptr to MENU
112; Returns:
113; AL: Column (X)
114; AH: Row (Y)
115; Corrupts registers:
116; Nothing
117;--------------------------------------------------------------------
118ALIGN JUMP_ALIGN
119AddBottomBordersTopLeftCoordinatesToAX:
120 stc ; Compensate for Information top border
121 adc ah, [bp+MENUINIT.bInfoLines]
122ALIGN JUMP_ALIGN
123AddInformationBordersTopLeftCoordinatesToAX:
124 push cx
125 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
126 inc cx ; Compensate for Items top border
127 add ah, cl
128 pop cx
129ALIGN JUMP_ALIGN
130AddItemBordersTopLeftCoordinatesToAX:
131 stc ; Compensate for Title top border
132 adc ah, [bp+MENUINIT.bTitleLines]
133ALIGN JUMP_ALIGN
134MenuLocation_AddTitleBordersTopLeftCoordinatesToAX:
135 push di
136 push ax
137 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
138 sub al, [bp+MENUINIT.bWidth]
139 sub ah, [bp+MENUINIT.bHeight]
140 shr al, 1
141 shr ah, 1
142 pop di ; Old AX to DI
143 add ax, di ; Add old AX to menu top left coordinates
144 pop di
145 ret
146
147
148;--------------------------------------------------------------------
149; MenuLocation_GetMaxTextLineLengthToAX
150; Parameters
151; SS:BP: Ptr to MENU
152; Returns:
153; AX: Maximum text line length in characters
154; Corrupts registers:
155; Nothing
156;--------------------------------------------------------------------
157ALIGN JUMP_ALIGN
158MenuLocation_GetMaxTextLineLengthToAX:
159 eMOVZX ax, BYTE [bp+MENUINIT.bWidth]
160 sub ax, BYTE MENU_HORIZONTAL_BORDER_LINES + MENU_TEXT_COLUMN_OFFSET
161 ret
Note: See TracBrowser for help on using the repository browser.