1 | ; Project name : Assembly Library
|
---|
2 | ; Description : Functions for initializing menu system.
|
---|
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
|
---|
22 | SECTION .text
|
---|
23 |
|
---|
24 | ;--------------------------------------------------------------------
|
---|
25 | ; MenuInit_DisplayMenuWithHandlerInBXandUserDataInDXAX
|
---|
26 | ; Parameters
|
---|
27 | ; DX:AX: User specified data
|
---|
28 | ; BX: Menu event handler
|
---|
29 | ; Returns:
|
---|
30 | ; AX: Index of selected item or NO_ITEM_SELECTED
|
---|
31 | ; Corrupts registers:
|
---|
32 | ; All except segments
|
---|
33 | ;--------------------------------------------------------------------
|
---|
34 | ALIGN MENU_JUMP_ALIGN
|
---|
35 | MenuInit_DisplayMenuWithHandlerInBXandUserDataInDXAX:
|
---|
36 | push es
|
---|
37 | push ds
|
---|
38 | LOAD_BDA_SEGMENT_TO ds, cx, !
|
---|
39 | push WORD [BDA.wVidCurShape]
|
---|
40 | mov cl, MENU_size
|
---|
41 | eENTER_STRUCT cx
|
---|
42 |
|
---|
43 | call Memory_ZeroSSBPwithSizeInCX
|
---|
44 | call MenuInit_EnterMenuWithHandlerInBXandUserDataInDXAX
|
---|
45 | mov dx, [bp+MENUINIT.wHighlightedItem]
|
---|
46 |
|
---|
47 | eLEAVE_STRUCT MENU_size
|
---|
48 | pop ax
|
---|
49 | CALL_DISPLAY_LIBRARY SetCursorShapeFromAX
|
---|
50 | CALL_DISPLAY_LIBRARY SynchronizeDisplayContextToHardware
|
---|
51 | xchg ax, dx ; Return highlighted item in AX
|
---|
52 | pop ds
|
---|
53 | pop es
|
---|
54 | ret
|
---|
55 |
|
---|
56 |
|
---|
57 | ;--------------------------------------------------------------------
|
---|
58 | ; MenuInit_EnterMenuWithHandlerInBXandUserDataInDXAX
|
---|
59 | ; Parameters
|
---|
60 | ; DX:AX: User specified data
|
---|
61 | ; BX: Menu event handler
|
---|
62 | ; SS:BP: Ptr to MENU
|
---|
63 | ; Returns:
|
---|
64 | ; Nothing
|
---|
65 | ; Corrupts registers:
|
---|
66 | ; All, except SS:BP
|
---|
67 | ;--------------------------------------------------------------------
|
---|
68 | ALIGN MENU_JUMP_ALIGN
|
---|
69 | MenuInit_EnterMenuWithHandlerInBXandUserDataInDXAX:
|
---|
70 | mov [bp+MENU.fnEventHandler], bx
|
---|
71 | mov [bp+MENU.dwUserData], ax
|
---|
72 | mov [bp+MENU.dwUserData+2], dx
|
---|
73 |
|
---|
74 | mov ax, CURSOR_HIDDEN
|
---|
75 | CALL_DISPLAY_LIBRARY SetCursorShapeFromAX
|
---|
76 | call MenuEvent_InitializeMenuinit ; User initialization
|
---|
77 | %ifndef USE_186
|
---|
78 | call MenuInit_RefreshMenuWindow
|
---|
79 | jmp MenuLoop_Enter
|
---|
80 | %else
|
---|
81 | push MenuLoop_Enter
|
---|
82 | ; Fall to MenuInit_RefreshMenuWindow
|
---|
83 | %endif
|
---|
84 |
|
---|
85 |
|
---|
86 | ;--------------------------------------------------------------------
|
---|
87 | ; MenuInit_RefreshMenuWindow
|
---|
88 | ; Parameters
|
---|
89 | ; SS:BP: Ptr to MENU
|
---|
90 | ; Returns:
|
---|
91 | ; Nothing
|
---|
92 | ; Corrupts registers:
|
---|
93 | ; AX, BX, CX, DX, SI, DI
|
---|
94 | ;--------------------------------------------------------------------
|
---|
95 | ALIGN MENU_JUMP_ALIGN
|
---|
96 | MenuInit_RefreshMenuWindow:
|
---|
97 | call MenuBorders_RefreshAll ; Draw borders
|
---|
98 | call MenuText_RefreshTitle ; Draw title strings
|
---|
99 | call MenuText_RefreshAllItems ; Draw item strings
|
---|
100 | jmp MenuText_RefreshInformation ; Draw information strings
|
---|
101 |
|
---|
102 |
|
---|
103 | ;--------------------------------------------------------------------
|
---|
104 | ; MenuInit_CloseMenuIfExitEventAllows
|
---|
105 | ; Parameters
|
---|
106 | ; SS:BP: Ptr to MENU
|
---|
107 | ; Returns:
|
---|
108 | ; Nothing
|
---|
109 | ; Corrupts registers:
|
---|
110 | ; AX, BX, DX
|
---|
111 | ;--------------------------------------------------------------------
|
---|
112 | %ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
|
---|
113 | ALIGN MENU_JUMP_ALIGN
|
---|
114 | MenuInit_CloseMenuIfExitEventAllows:
|
---|
115 | call MenuEvent_ExitMenu
|
---|
116 | jc SHORT MenuInit_CloseMenuWindow
|
---|
117 | ret
|
---|
118 | %endif
|
---|
119 |
|
---|
120 |
|
---|
121 | ;--------------------------------------------------------------------
|
---|
122 | ; MenuInit_CloseMenuWindow
|
---|
123 | ; Parameters
|
---|
124 | ; SS:BP: Ptr to MENU
|
---|
125 | ; Returns:
|
---|
126 | ; Nothing
|
---|
127 | ; Corrupts registers:
|
---|
128 | ; Nothing
|
---|
129 | ;--------------------------------------------------------------------
|
---|
130 | ALIGN MENU_JUMP_ALIGN
|
---|
131 | MenuInit_CloseMenuWindow:
|
---|
132 | or BYTE [bp+MENU.bFlags], FLG_MENU_EXIT
|
---|
133 | ret
|
---|
134 |
|
---|
135 |
|
---|
136 | ;--------------------------------------------------------------------
|
---|
137 | ; MenuInit_HighlightItemFromAX
|
---|
138 | ; Parameters
|
---|
139 | ; AX: Item to highlight
|
---|
140 | ; SS:BP: Ptr to MENU
|
---|
141 | ; Returns:
|
---|
142 | ; Nothing
|
---|
143 | ; Corrupts registers:
|
---|
144 | ; AX, BX, CX, DX, SI, DI
|
---|
145 | ;--------------------------------------------------------------------
|
---|
146 | ALIGN MENU_JUMP_ALIGN
|
---|
147 | MenuInit_HighlightItemFromAX:
|
---|
148 | sub ax, [bp+MENUINIT.wHighlightedItem]
|
---|
149 | jmp MenuScrollbars_MoveHighlightedItemByAX
|
---|
150 |
|
---|
151 | ;--------------------------------------------------------------------
|
---|
152 | ; MenuInit_GetHighlightedItemToAX
|
---|
153 | ; Parameters
|
---|
154 | ; SS:BP: Ptr to MENU
|
---|
155 | ; Returns:
|
---|
156 | ; AX: Index of highlighted item or NO_ITEM_HIGHLIGHTED
|
---|
157 | ; Corrupts registers:
|
---|
158 | ; Nothing
|
---|
159 | ;--------------------------------------------------------------------
|
---|
160 | %ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
|
---|
161 | ALIGN MENU_JUMP_ALIGN
|
---|
162 | MenuInit_GetHighlightedItemToAX:
|
---|
163 | mov ax, [bp+MENUINIT.wHighlightedItem]
|
---|
164 | ret
|
---|
165 | %endif
|
---|
166 |
|
---|
167 |
|
---|
168 | ;--------------------------------------------------------------------
|
---|
169 | ; MenuInit_SetTitleHeightFromAL
|
---|
170 | ; MenuInit_SetInformationHeightFromAL
|
---|
171 | ; MenuInit_SetTotalItemsFromAX
|
---|
172 | ; Parameters
|
---|
173 | ; AX/AL: Parameter
|
---|
174 | ; SS:BP: Ptr to MENU
|
---|
175 | ; Returns:
|
---|
176 | ; Nothing
|
---|
177 | ; Corrupts registers:
|
---|
178 | ; Nothing
|
---|
179 | ;--------------------------------------------------------------------
|
---|
180 | %ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
|
---|
181 | ALIGN MENU_JUMP_ALIGN
|
---|
182 | MenuInit_SetTitleHeightFromAL:
|
---|
183 | mov [bp+MENUINIT.bTitleLines], al
|
---|
184 | ret
|
---|
185 |
|
---|
186 | ALIGN MENU_JUMP_ALIGN
|
---|
187 | MenuInit_SetInformationHeightFromAL:
|
---|
188 | mov [bp+MENUINIT.bInfoLines], al
|
---|
189 | ret
|
---|
190 |
|
---|
191 | ALIGN MENU_JUMP_ALIGN
|
---|
192 | MenuInit_SetTotalItemsFromAX:
|
---|
193 | mov [bp+MENUINIT.wItems], ax
|
---|
194 | ret
|
---|
195 | %endif
|
---|
196 |
|
---|
197 |
|
---|
198 | ;--------------------------------------------------------------------
|
---|
199 | ; MenuInit_SetUserDataFromDSSI
|
---|
200 | ; MenuInit_GetUserDataToDSSI
|
---|
201 | ; Parameters
|
---|
202 | ; DS:SI: User data (MenuInit_SetUserDataFromDSSI)
|
---|
203 | ; SS:BP: Ptr to MENU
|
---|
204 | ; Returns:
|
---|
205 | ; DS:SI: User data (MenuInit_GetUserDataToDSSI)
|
---|
206 | ; Corrupts registers:
|
---|
207 | ; Nothing
|
---|
208 | ;--------------------------------------------------------------------
|
---|
209 | %ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
|
---|
210 | ALIGN MENU_JUMP_ALIGN
|
---|
211 | MenuInit_SetUserDataFromDSSI:
|
---|
212 | mov [bp+MENU.dwUserData], si
|
---|
213 | mov [bp+MENU.dwUserData+2], ds
|
---|
214 | ret
|
---|
215 |
|
---|
216 | ALIGN MENU_JUMP_ALIGN
|
---|
217 | MenuInit_GetUserDataToDSSI:
|
---|
218 | lds si, [bp+MENU.dwUserData]
|
---|
219 | ret
|
---|
220 | %endif
|
---|