source: xtideuniversalbios/trunk/Assembly_Library/Src/Menu/MenuLoop.asm@ 505

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

Removed the dependency between MODULE_BOOT_MENU and MODULE_HOTKEYS. With these changes, 0, 1, or 2 of them can be included in a build. This change also means that the hotkeys don't work while the menu is up. But the most important hotkey there was for Rom Boot, and that has been added to the menu as a choice proper. Lots of changes across the board in the hotkeys code - even if we eventually back this change out (becaue, for example we want hotkeys to work in the menu) we should probably start from this base and add that functionality back in, as these changes results in approximately 120 bytes of savings and includes new functionality, such as the Rom Boot menu item and the Com Detect hotkey.

File size: 5.8 KB
Line 
1; Project name : Assembly Library
2; Description : Menu loop for waiting keystrokes.
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; MenuLoop_Enter
26; Parameters
27; SS:BP: Ptr to MENU
28; Returns:
29; Nothing
30; Corrupts registers:
31; AX, BX, CX, DX, SI, DI
32;--------------------------------------------------------------------
33ALIGN MENU_JUMP_ALIGN
34MenuLoop_Enter:
35 call KeystrokeProcessing
36 call TimeoutProcessing
37%ifdef MENUEVENT_IDLEPROCESSING_ENABLE
38 call MenuEvent_IdleProcessing ; User idle processing
39%endif
40 test BYTE [bp+MENU.bFlags], FLG_MENU_EXIT
41 jz SHORT MenuLoop_Enter
42 ret
43
44
45;--------------------------------------------------------------------
46; KeystrokeProcessing
47; TimeoutProcessing
48; Parameters
49; SS:BP: Ptr to MENU
50; Returns:
51; Nothing
52; Corrupts registers:
53; All, except SS:BP
54;--------------------------------------------------------------------
55ALIGN MENU_JUMP_ALIGN
56KeystrokeProcessing:
57 call Keyboard_GetKeystrokeToAX
58 jnz SHORT ProcessKeystrokeFromAX
59NoKeystrokeToProcess:
60 ret
61
62ALIGN MENU_JUMP_ALIGN
63TimeoutProcessing:
64 call MenuTime_UpdateSelectionTimeout
65 jnc NoKeystrokeToProcess
66 mov al, CR ; Fake ENTER to select item
67 ; Fall to ProcessKeystrokeFromAX
68
69
70;--------------------------------------------------------------------
71; ProcessKeystrokeFromAX
72; Parameters
73; AL: ASCII character
74; AH: BIOS scan code
75; SS:BP: Ptr to MENU
76; Returns:
77; Nothing
78; Corrupts registers:
79; AX, BX, CX, DX, SI, DI
80;--------------------------------------------------------------------
81ALIGN MENU_JUMP_ALIGN
82ProcessKeystrokeFromAX:
83 xchg cx, ax
84 call MenuTime_StopSelectionTimeout
85 xchg ax, cx
86 call .ProcessMenuSystemKeystrokeFromAX
87%ifdef MENUEVENT_KeyStrokeInAX
88 jc SHORT NoKeystrokeToProcess
89 jmp MenuEvent_KeyStrokeInAX
90%else
91 jmp SHORT NoKeystrokeToProcess
92%endif
93
94;--------------------------------------------------------------------
95; .ProcessMenuSystemKeystrokeFromAX
96; Parameters
97; AL: ASCII character
98; AH: BIOS scan code
99; SS:BP: Ptr to MENU
100; Returns:
101; CF: Set if keystroke processed
102; Cleared if keystroke not processed
103; AL: ASCII character (if CF cleared)
104; AH: BIOS scan code (if CF cleared)
105; Corrupts registers:
106; BX, CX, DX, SI, DI
107;--------------------------------------------------------------------
108ALIGN MENU_JUMP_ALIGN
109.ProcessMenuSystemKeystrokeFromAX:
110%ifndef MENU_NO_ESC
111 cmp al, ESC
112 je SHORT .LeaveMenuWithoutSelectingItem
113%endif
114 cmp al, CR
115 je SHORT .SelectItem
116
117 test BYTE [bp+MENU.bFlags], FLG_MENU_USER_HANDLES_SCROLLING
118 jz SHORT MenuLoop_ProcessScrollingKeysFromAX
119 ret ; Return with CF cleared since keystroke not processed
120
121%ifndef MENU_NO_ESC
122ALIGN MENU_JUMP_ALIGN
123.LeaveMenuWithoutSelectingItem:
124 call MenuEvent_ExitMenu
125 jnc SHORT .CancelMenuExit
126 call MenuInit_CloseMenuWindow
127 mov WORD [bp+MENUINIT.wHighlightedItem], NO_ITEM_HIGHLIGHTED
128.CancelMenuExit:
129 stc
130 ret
131%endif
132
133ALIGN MENU_JUMP_ALIGN
134.SelectItem:
135 mov cx, [bp+MENUINIT.wHighlightedItem]
136 call MenuEvent_ItemSelectedFromCX
137 stc
138 ret
139
140
141;--------------------------------------------------------------------
142; MenuLoop_ProcessScrollingKeysFromAX
143; Parameters
144; AL: ASCII character
145; AH: BIOS scan code
146; SS:BP: Ptr to MENU
147; Returns:
148; CF: Set if keystroke processed
149; Cleared if keystroke not processed
150; AL: ASCII character (if CF cleared)
151; AH: BIOS scan code (if CF cleared)
152; Corrupts registers:
153; BX, CX, DX, SI, DI
154;--------------------------------------------------------------------
155ALIGN MENU_JUMP_ALIGN
156MenuLoop_ProcessScrollingKeysFromAX:
157 xchg ah, al
158 cmp al, MENU_KEY_PGUP
159 je SHORT .ChangeToPreviousPage
160 cmp al, MENU_KEY_PGDN
161 je SHORT .ChangeToNextPage
162 cmp al, MENU_KEY_HOME
163 je SHORT .SelectFirstItem
164 cmp al, MENU_KEY_END
165 je SHORT .SelectLastItem
166
167 cmp al, MENU_KEY_UP
168 je SHORT .DecrementSelectedItem
169 cmp al, MENU_KEY_DOWN
170 je SHORT .IncrementSelectedItem
171 clc ; Clear CF since keystroke not processed
172 xchg ah, al
173 ret
174
175ALIGN MENU_JUMP_ALIGN
176.ChangeToPreviousPage:
177 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
178 xchg ax, cx
179 neg ax
180 mov cx, [bp+MENUINIT.wHighlightedItem]
181 add cx, ax
182 jge SHORT .MoveHighlightedItemByAX ; No rotation for PgUp
183 ; Fall to .SelectFirstItem
184ALIGN MENU_JUMP_ALIGN
185.SelectFirstItem:
186 mov ax, [bp+MENUINIT.wHighlightedItem]
187 neg ax
188 jmp SHORT .MoveHighlightedItemByAX
189
190ALIGN MENU_JUMP_ALIGN
191.ChangeToNextPage:
192 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
193 xchg ax, cx
194 mov cx, [bp+MENUINIT.wHighlightedItem]
195 add cx, ax
196 cmp cx, [bp+MENUINIT.wItems]
197 jb SHORT .MoveHighlightedItemByAX ; No rotation for PgDn
198 ; Fall to .SelectLastItem
199ALIGN MENU_JUMP_ALIGN
200.SelectLastItem:
201 stc
202 mov ax, [bp+MENUINIT.wItems]
203 sbb ax, [bp+MENUINIT.wHighlightedItem]
204 jmp SHORT .MoveHighlightedItemByAX
205
206ALIGN MENU_JUMP_ALIGN
207.DecrementSelectedItem:
208 mov ax, -1
209 SKIP2B cx ; mov cx, <next instruction>
210.IncrementSelectedItem:
211 mov al, 1 ; AH is already 0
212ALIGN MENU_JUMP_ALIGN
213.MoveHighlightedItemByAX:
214 call MenuScrollbars_MoveHighlightedItemByAX
215 stc
216 ret
Note: See TracBrowser for help on using the repository browser.