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
|
---|
22 | SECTION .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 | ;--------------------------------------------------------------------
|
---|
35 | ALIGN MENU_JUMP_ALIGN
|
---|
36 | MenuLocation_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
|
---|
58 | MenuLocation_GetItemBordersTopLeftCoordinatesToAX:
|
---|
59 | %endif
|
---|
60 | xor ax, ax
|
---|
61 | jmp SHORT AddItemBordersTopLeftCoordinatesToAX
|
---|
62 |
|
---|
63 | ALIGN MENU_JUMP_ALIGN
|
---|
64 | MenuLocation_GetTitleTextTopLeftCoordinatesToAX:
|
---|
65 | mov ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
|
---|
66 | SKIP2B f ; cmp ax, <next instruction>
|
---|
67 | MenuLocation_GetTitleBordersTopLeftCoordinatesToAX:
|
---|
68 | xor ax, ax
|
---|
69 | jmp SHORT MenuLocation_AddTitleBordersTopLeftCoordinatesToAX
|
---|
70 |
|
---|
71 | ALIGN MENU_JUMP_ALIGN
|
---|
72 | MenuLocation_GetInformationTextTopLeftCoordinatesToAX:
|
---|
73 | mov ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
|
---|
74 | jmp SHORT AddInformationBordersTopLeftCoordinatesToAX
|
---|
75 |
|
---|
76 | ALIGN MENU_JUMP_ALIGN
|
---|
77 | MenuLocation_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]
|
---|
98 | ALIGN MENU_JUMP_ALIGN
|
---|
99 | AddInformationBordersTopLeftCoordinatesToAX:
|
---|
100 | push cx
|
---|
101 | call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
|
---|
102 | inc cx ; Compensate for Items top border
|
---|
103 | add ah, cl
|
---|
104 | pop cx
|
---|
105 | ALIGN MENU_JUMP_ALIGN
|
---|
106 | AddItemBordersTopLeftCoordinatesToAX:
|
---|
107 | stc ; Compensate for Title top border
|
---|
108 | adc ah, [bp+MENUINIT.bTitleLines]
|
---|
109 | ALIGN MENU_JUMP_ALIGN
|
---|
110 | MenuLocation_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 | ;--------------------------------------------------------------------
|
---|
133 | ALIGN MENU_JUMP_ALIGN
|
---|
134 | MenuLocation_GetMaxTextLineLengthToAX:
|
---|
135 | mov ax, -(MENU_HORIZONTAL_BORDER_LINES + MENU_TEXT_COLUMN_OFFSET) & 0FFh
|
---|
136 | add al, [bp+MENUINIT.bWidth]
|
---|
137 | ret
|
---|