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

Last change on this file since 557 was 527, checked in by aitotat@…, 12 years ago

Changes to Assembly Library:

  • Menu system KeyStroke event related code now always included since the %ifdef did not seem to work.
File size: 5.7 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-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
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 jc SHORT NoKeystrokeToProcess
88 jmp MenuEvent_KeyStrokeInAX
89
90;--------------------------------------------------------------------
91; .ProcessMenuSystemKeystrokeFromAX
92; Parameters
93; AL: ASCII character
94; AH: BIOS scan code
95; SS:BP: Ptr to MENU
96; Returns:
97; CF: Set if keystroke processed
98; Cleared if keystroke not processed
99; AL: ASCII character (if CF cleared)
100; AH: BIOS scan code (if CF cleared)
101; Corrupts registers:
102; BX, CX, DX, SI, DI
103;--------------------------------------------------------------------
104ALIGN MENU_JUMP_ALIGN
105.ProcessMenuSystemKeystrokeFromAX:
106%ifndef MENU_NO_ESC
107 cmp al, ESC
108 je SHORT .LeaveMenuWithoutSelectingItem
109%endif
110 cmp al, CR
111 je SHORT .SelectItem
112
113 test BYTE [bp+MENU.bFlags], FLG_MENU_USER_HANDLES_SCROLLING
114 jz SHORT MenuLoop_ProcessScrollingKeysFromAX
115 ret ; Return with CF cleared since keystroke not processed
116
117%ifndef MENU_NO_ESC
118ALIGN MENU_JUMP_ALIGN
119.LeaveMenuWithoutSelectingItem:
120 call MenuEvent_ExitMenu
121 jnc SHORT .CancelMenuExit
122 call MenuInit_CloseMenuWindow
123 mov WORD [bp+MENUINIT.wHighlightedItem], NO_ITEM_HIGHLIGHTED
124.CancelMenuExit:
125 stc
126 ret
127%endif
128
129ALIGN MENU_JUMP_ALIGN
130.SelectItem:
131 mov cx, [bp+MENUINIT.wHighlightedItem]
132 call MenuEvent_ItemSelectedFromCX
133 stc
134 ret
135
136
137;--------------------------------------------------------------------
138; MenuLoop_ProcessScrollingKeysFromAX
139; Parameters
140; AL: ASCII character
141; AH: BIOS scan code
142; SS:BP: Ptr to MENU
143; Returns:
144; CF: Set if keystroke processed
145; Cleared if keystroke not processed
146; AL: ASCII character (if CF cleared)
147; AH: BIOS scan code (if CF cleared)
148; Corrupts registers:
149; BX, CX, DX, SI, DI
150;--------------------------------------------------------------------
151ALIGN MENU_JUMP_ALIGN
152MenuLoop_ProcessScrollingKeysFromAX:
153 xchg ah, al
154 cmp al, MENU_KEY_PGUP
155 je SHORT .ChangeToPreviousPage
156 cmp al, MENU_KEY_PGDN
157 je SHORT .ChangeToNextPage
158 cmp al, MENU_KEY_HOME
159 je SHORT .SelectFirstItem
160 cmp al, MENU_KEY_END
161 je SHORT .SelectLastItem
162
163 cmp al, MENU_KEY_UP
164 je SHORT .DecrementSelectedItem
165 cmp al, MENU_KEY_DOWN
166 je SHORT .IncrementSelectedItem
167 clc ; Clear CF since keystroke not processed
168 xchg ah, al
169 ret
170
171ALIGN MENU_JUMP_ALIGN
172.ChangeToPreviousPage:
173 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
174 xchg ax, cx
175 neg ax
176 mov cx, [bp+MENUINIT.wHighlightedItem]
177 add cx, ax
178 jge SHORT .MoveHighlightedItemByAX ; No rotation for PgUp
179 ; Fall to .SelectFirstItem
180ALIGN MENU_JUMP_ALIGN
181.SelectFirstItem:
182 mov ax, [bp+MENUINIT.wHighlightedItem]
183 neg ax
184 jmp SHORT .MoveHighlightedItemByAX
185
186ALIGN MENU_JUMP_ALIGN
187.ChangeToNextPage:
188 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
189 xchg ax, cx
190 mov cx, [bp+MENUINIT.wHighlightedItem]
191 add cx, ax
192 cmp cx, [bp+MENUINIT.wItems]
193 jb SHORT .MoveHighlightedItemByAX ; No rotation for PgDn
194 ; Fall to .SelectLastItem
195ALIGN MENU_JUMP_ALIGN
196.SelectLastItem:
197 stc
198 mov ax, [bp+MENUINIT.wItems]
199 sbb ax, [bp+MENUINIT.wHighlightedItem]
200 jmp SHORT .MoveHighlightedItemByAX
201
202ALIGN MENU_JUMP_ALIGN
203.DecrementSelectedItem:
204 mov ax, -1
205 SKIP2B cx ; mov cx, <next instruction>
206.IncrementSelectedItem:
207 mov al, 1 ; AH is already 0
208ALIGN MENU_JUMP_ALIGN
209.MoveHighlightedItemByAX:
210 call MenuScrollbars_MoveHighlightedItemByAX
211 stc
212 ret
Note: See TracBrowser for help on using the repository browser.