source: xtideuniversalbios/trunk/Assembly_Library/Src/Menu/MenuInit.asm@ 501

Last change on this file since 501 was 489, checked in by gregli@…, 12 years ago

Added version string to initial title banner, for cases where there is not a boot menu (just hotkeys, or no hotkeys). Also ifdef'd out some unused code.

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