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

Last change on this file since 73 was 60, checked in by Tomi Tilli, 14 years ago

Changes to Assembly Library:

  • Timeout count down is now stopped when any key pressed.
File size: 5.1 KB
Line 
1; File name : MenuLoop.asm
2; Project name : Assembly Library
3; Created date : 22.7.2010
4; Last update : 25.11.2010
5; Author : Tomi Tilli
6; Description : Menu loop for waiting keystrokes.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; MenuLoop_Enter
13; Parameters
14; SS:BP: Ptr to MENU
15; Returns:
16; Nothing
17; Corrupts registers:
18; AX, BX, CX, DX, SI, DI
19;--------------------------------------------------------------------
20ALIGN JUMP_ALIGN
21MenuLoop_Enter:
22 call KeystrokeProcessing
23 call TimeoutProcessing
24 call IdleTimeProcessing
25 test BYTE [bp+MENU.bFlags], FLG_MENU_EXIT
26 jz SHORT MenuLoop_Enter
27 ret
28
29
30;--------------------------------------------------------------------
31; IdleTimeProcessing
32; TimeoutProcessing
33; KeystrokeProcessing
34; Parameters
35; SS:BP: Ptr to MENU
36; Returns:
37; Nothing
38; Corrupts registers:
39; All, except SS:BP
40;--------------------------------------------------------------------
41ALIGN JUMP_ALIGN
42IdleTimeProcessing:
43 jmp MenuEvent_IdleProcessing ; User idle processing
44
45ALIGN JUMP_ALIGN
46TimeoutProcessing:
47 call MenuTime_UpdateSelectionTimeout
48 mov ah, MENU_KEY_ENTER ; Fake ENTER to select item
49 jc SHORT ProcessKeystrokeFromAX ; Process faked ENTER
50 ret
51
52ALIGN JUMP_ALIGN
53KeystrokeProcessing:
54 call Keyboard_GetKeystrokeToAX
55 jnz SHORT ProcessKeystrokeFromAX
56 ret
57
58
59;--------------------------------------------------------------------
60; ProcessKeystrokeFromAX
61; Parameters
62; AL: ASCII character
63; AH: BIOS scan code
64; SS:BP: Ptr to MENU
65; Returns:
66; Nothing
67; Corrupts registers:
68; AX, BX, CX, DX, SI, DI
69;--------------------------------------------------------------------
70ALIGN JUMP_ALIGN
71ProcessKeystrokeFromAX:
72 xchg cx, ax
73 call MenuTime_StopSelectionTimeout
74 xchg ax, cx
75 call .ProcessMenuSystemKeystrokeFromAX
76 jc SHORT .Return
77 jmp MenuEvent_KeyStrokeInAX
78ALIGN JUMP_ALIGN, ret
79.Return:
80 ret
81
82;--------------------------------------------------------------------
83; .ProcessMenuSystemKeystrokeFromAX
84; Parameters
85; AL: ASCII character
86; AH: BIOS scan code
87; SS:BP: Ptr to MENU
88; Returns:
89; CF: Set if keystroke processed
90; Cleared if keystroke not processed
91; AL: ASCII character (if CF cleared)
92; AH: BIOS scan code (if CF cleared)
93; Corrupts registers:
94; BX, CX, DX, SI, DI
95;--------------------------------------------------------------------
96ALIGN JUMP_ALIGN
97.ProcessMenuSystemKeystrokeFromAX:
98 cmp ah, MENU_KEY_ESC
99 je SHORT .LeaveMenuWithoutSelectingItem
100 cmp ah, MENU_KEY_ENTER
101 je SHORT .SelectItem
102
103 test BYTE [bp+MENU.bFlags], FLG_MENU_USER_HANDLES_SCROLLING
104 jz SHORT MenuLoop_ProcessScrollingKeysFromAX
105 clc ; Clear CF since keystroke not processed
106 ret
107
108ALIGN JUMP_ALIGN
109.LeaveMenuWithoutSelectingItem:
110 call MenuEvent_ExitMenu
111 jnc SHORT .CancelMenuExit
112 call MenuInit_CloseMenuWindow
113 mov WORD [bp+MENUINIT.wHighlightedItem], NO_ITEM_HIGHLIGHTED
114.CancelMenuExit:
115 stc
116 ret
117
118ALIGN JUMP_ALIGN
119.SelectItem:
120 mov cx, [bp+MENUINIT.wHighlightedItem]
121 call MenuEvent_ItemSelectedFromCX
122 stc
123 ret
124
125
126;--------------------------------------------------------------------
127; MenuLoop_ProcessScrollingKeysFromAX
128; Parameters
129; AL: ASCII character
130; AH: BIOS scan code
131; SS:BP: Ptr to MENU
132; Returns:
133; CF: Set if keystroke processed
134; Cleared if keystroke not processed
135; AL: ASCII character (if CF cleared)
136; AH: BIOS scan code (if CF cleared)
137; Corrupts registers:
138; BX, CX, DX, SI, DI
139;--------------------------------------------------------------------
140ALIGN JUMP_ALIGN
141MenuLoop_ProcessScrollingKeysFromAX:
142 cmp ah, MENU_KEY_PGUP
143 je SHORT .ChangeToPreviousPage
144 cmp ah, MENU_KEY_PGDN
145 je SHORT .ChangeToNextPage
146 cmp ah, MENU_KEY_HOME
147 je SHORT .SelectFirstItem
148 cmp ah, MENU_KEY_END
149 je SHORT .SelectLastItem
150
151 cmp ah, MENU_KEY_UP
152 je SHORT .DecrementSelectedItem
153 cmp ah, MENU_KEY_DOWN
154 je SHORT .IncrementSelectedItem
155 clc ; Clear CF since keystroke not processed
156 ret
157
158ALIGN JUMP_ALIGN
159.ChangeToPreviousPage:
160 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
161 xchg ax, cx
162 neg ax
163 mov cx, [bp+MENUINIT.wHighlightedItem]
164 add cx, ax
165 jge SHORT .MoveHighlightedItemByAX ; No rotation for PgUp
166 ; Fall to .SelectFirstItem
167ALIGN JUMP_ALIGN
168.SelectFirstItem:
169 mov ax, [bp+MENUINIT.wHighlightedItem]
170 neg ax
171 jmp SHORT .MoveHighlightedItemByAX
172
173ALIGN JUMP_ALIGN
174.ChangeToNextPage:
175 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
176 xchg ax, cx
177 mov cx, [bp+MENUINIT.wHighlightedItem]
178 add cx, ax
179 cmp cx, [bp+MENUINIT.wItems]
180 jb SHORT .MoveHighlightedItemByAX ; No rotation for PgDn
181 ; Fall to .SelectLastItem
182ALIGN JUMP_ALIGN
183.SelectLastItem:
184 mov ax, [bp+MENUINIT.wItems]
185 sub ax, [bp+MENUINIT.wHighlightedItem]
186 dec ax
187 jmp SHORT .MoveHighlightedItemByAX
188
189ALIGN JUMP_ALIGN
190.DecrementSelectedItem:
191 mov ax, -1
192 jmp SHORT .MoveHighlightedItemByAX
193ALIGN JUMP_ALIGN
194.IncrementSelectedItem:
195 mov ax, 1
196ALIGN JUMP_ALIGN
197.MoveHighlightedItemByAX:
198 call MenuScrollbars_MoveHighlightedItemByAX
199 stc
200 ret
Note: See TracBrowser for help on using the repository browser.