source: xtideuniversalbios/trunk/Configurator/Src/MenuEvent.asm@ 545

Last change on this file since 545 was 2, checked in by Tomi Tilli, 15 years ago
File size: 8.2 KB
Line 
1; File name : MenuEvent.asm
2; Project name : XTIDE Univeral BIOS Configurator
3; Created date : 16.4.2010
4; Last update : 29.4.2010
5; Author : Tomi Tilli
6; Description : Handlers for menu library events.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; Main event handler for all incoming events.
13;
14; MenuEvent_Handler
15; Parameters:
16; BX: Callback event
17; CX: Menuitem index (usually index of selected Menuitem)
18; DX: Event parameter (event specific)
19; SS:BP: Ptr to MENUVARS
20; Returns:
21; AH: Event specific or unused. Set to 0 if unused.
22; AL: 1=Event processed
23; 0=Event not processed (default action if any)
24; Corrupts registers:
25; BX, CX, DX
26;--------------------------------------------------------------------
27ALIGN JUMP_ALIGN
28MenuEvent_Handler:
29 push es
30 push ds
31 push di
32 push si
33
34 xor ax, ax ; Event not processed
35 cmp bx, BYTE EVNT_MNU_INITDONE ; Event in jump table?
36 ja SHORT .Return
37 shl bx, 1
38 call [cs:bx+.rgwEventJmp]
39.Return:
40 pop si
41 pop di
42 pop ds
43 pop es
44 ret
45ALIGN WORD_ALIGN
46.rgwEventJmp:
47 dw MenuEvent_Exit ; 0, EVNT_MNU_EXIT (Menu will quit)
48 dw MenuEvent_EventItemSelectionChanged ; 1, EVNT_MMU_SELCHG (Menuitem selection changed (with arrows))
49 dw MenuEvent_EventItemSelected ; 2, EVNT_MNU_SELSET (Menuitem selected (with Enter))
50 dw MenuEvent_EventKeyPressed ; 3, EVNT_MNU_KEY (Keyboard key pressed)
51 dw MenuEvent_EventMenuDraw ; 4, EVNT_MNU_UPD (Menu needs to be updated)
52 dw MenuEvent_EventGetDefaultMenuitem ; 5, EVNT_MNU_GETDEF (Request menuitem to be selected by default)
53 dw MenuEvent_EventMenuInitDone ; 6, EVNT_MNU_INITDONE (Menu has been initialized but not yet drawn)
54
55
56;--------------------------------------------------------------------
57; Handles Menu Exit notification (EVNT_MNU_EXIT).
58;
59; MenuEvent_Exit
60; Parameters:
61; SS:BP: Ptr to MENUVARS
62; Returns:
63; AH: 1 to cancel exit
64; 0 to allow menu exit
65; AL: 1 = Event processed
66; Corrupts registers:
67; Nothing
68;--------------------------------------------------------------------
69ALIGN JUMP_ALIGN
70MenuEvent_Exit:
71 cmp WORD [bp+MENUVARS.user], g_MenuPageMain ; Exiting main menu?
72 je SHORT .AskUserAboutQuitting
73 mov ax, 1 ; Event handled
74 ret
75ALIGN JUMP_ALIGN
76.AskUserAboutQuitting:
77 call BiosFile_SaveUnsavedChanges
78 mov ax, 1 ; Event handled
79 ret
80
81
82;--------------------------------------------------------------------
83; Handles Menuitem Selection Changed notification (EVNT_MMU_SELCHG).
84;
85; MenuEvent_EventItemSelectionChanged
86; Parameters:
87; CX: Index of selected Menuitem
88; SS:BP: Ptr to MENUVARS
89; Returns:
90; AX: 1 = Event processed
91; Corrupts registers:
92; BX, CX, DX, DI
93;--------------------------------------------------------------------
94ALIGN JUMP_ALIGN
95MenuEvent_EventItemSelectionChanged:
96 mov dl, MFL_UPD_NFO
97 call Menu_Invalidate ; Invalidate info message
98 mov ax, 1 ; Event handled
99 ret
100
101
102;--------------------------------------------------------------------
103; Handles Menuitem Selected notification (EVNT_MNU_SELSET).
104;
105; MenuEvent_EventItemSelected
106; Parameters:
107; CX: Index of selected Menuitem
108; SS:BP: Ptr to MENUVARS
109; Returns:
110; AX: 1 = Event processed
111; Corrupts registers:
112; BX, CX, DX, SI, DI, DS, ES
113;--------------------------------------------------------------------
114ALIGN JUMP_ALIGN
115MenuEvent_EventItemSelected:
116 lds si, [bp+MENUVARS.user] ; DS:SI now points to MENUPAGE
117 call MenuPage_GetMenuPageItemForVisibleIndex ; DS:DI now points to MENUPAGEITEM
118 jnc SHORT .Return
119 push cx
120 call [di+MENUPAGEITEM.fnActivate]
121 pop cx
122 jnc SHORT .Return ; No changes
123 mov dl, MFL_UPD_ITEM | MFL_UPD_NOCLEAR
124 call Menu_Invalidate ; Invalidate menuitem
125.Return:
126 mov ax, 1 ; Event handled
127 ret
128
129
130;--------------------------------------------------------------------
131; Handles Key pressed notification (EVNT_MNU_KEY).
132;
133; MenuEvent_EventKeyPressed
134; Parameters:
135; CX: Index of currently selected Menuitem
136; DL: ASCII character
137; DH: BIOS Scan Code
138; SS:BP: Ptr to MENUVARS
139; Returns:
140; AX: 1 = Event processed
141; Corrupts registers:
142; BX, CX, DX, SI, DI, DS, ES
143;--------------------------------------------------------------------
144ALIGN JUMP_ALIGN
145MenuEvent_EventKeyPressed:
146 lds si, [bp+MENUVARS.user] ; DS:SI now points to MENUPAGE
147 call MenuPage_GetMenuPageItemForVisibleIndex ; DS:DI now points to MENUPAGEITEM
148 jnc SHORT .Return
149 call MenuEventHotkey_Pressed
150.Return:
151 mov ax, 1
152 ret
153
154
155;--------------------------------------------------------------------
156; Handles Menu Update notification (EVNT_MNU_UPD).
157;
158; MenuEvent_EventMenuDraw
159; Parameters:
160; CX: Index of Menuitem to update (if MFL_UPD_ITEM or MFL_UPD_NFO set)
161; DL: Update flag (only one):
162; MFL_UPD_TITLE Update Menu Title string(s)
163; MFL_UPD_NFO Update Menu Info string(s)
164; MFL_UPD_ITEM Update Menuitem string
165; SS:BP: Ptr to MENUVARS
166; Returns:
167; AX: Was event processed
168; Corrupts registers:
169; BX, CX, DX, SI, DI, DS, ES
170;--------------------------------------------------------------------
171ALIGN JUMP_ALIGN
172MenuEvent_EventMenuDraw:
173 test dl, MFL_UPD_ITEM ; Need to update Menuitem?
174 jnz SHORT MenuEvent_DrawMenuitem
175 test dl, MFL_UPD_NFO ; Need to update Info String(s)?
176 jnz SHORT MenuEvent_DrawInfo
177 test dl, MFL_UPD_TITLE ; Need to update Title String(s)?
178 jnz SHORT MenuEvent_DrawTitle
179 xor ax, ax
180 ret
181
182;--------------------------------------------------------------------
183; Draws Menuitem string. Cursor is set to a menuitem location.
184;
185; MenuEvent_DrawMenuitem
186; Parameters:
187; CX: Index of Menuitem to draw
188; SS:BP: Ptr to MENUVARS
189; Returns:
190; AX: Was event processed
191; Corrupts registers:
192; BX, CX, DX, SI, DI, DS, ES
193;--------------------------------------------------------------------
194ALIGN JUMP_ALIGN
195MenuEvent_DrawMenuitem:
196 lds si, [bp+MENUVARS.user] ; DS:SI now points to MENUPAGE
197 call MenuPage_GetMenuPageItemForVisibleIndex ; DS:DI now points to MENUPAGEITEM
198 jnc SHORT .Return
199 call [di+MENUPAGEITEM.fnNameFormat]
200.Return:
201 mov ax, 1
202 ret
203
204;--------------------------------------------------------------------
205; Draws information strings. Cursor is set to a first information line.
206;
207; MenuEvent_DrawInfo
208; Parameters:
209; CX: Index of selected menuitem
210; SS:BP: Ptr to MENUVARS
211; Returns:
212; AX: Was event processed
213; Corrupts registers:
214; BX, CX, DX, SI, DI, DS, ES
215;--------------------------------------------------------------------
216ALIGN JUMP_ALIGN
217MenuEvent_DrawInfo:
218 lds si, [bp+MENUVARS.user] ; DS:SI now points to MENUPAGE
219 call MenuPage_GetMenuPageItemForVisibleIndex ; DS:DI now points to MENUPAGEITEM
220 jnc SHORT .Return
221 call MenuPageItem_PrintInfo
222.Return:
223 mov ax, 1
224 ret
225
226;--------------------------------------------------------------------
227; Draws title strings. Cursor is set to a first title line.
228;
229; MenuEvent_DrawTitle
230; Parameters:
231; SS:BP: Ptr to MENUVARS
232; Returns:
233; AX: Was event processed
234; Corrupts registers:
235; BX, CX, DX, SI, DI, DS, ES
236;--------------------------------------------------------------------
237ALIGN JUMP_ALIGN
238MenuEvent_DrawTitle:
239 call FormatTitle_String
240 mov ax, 1
241 ret
242
243
244;--------------------------------------------------------------------
245; Handles Get Default Menuitem notification (EVNT_MNU_GETDEF).
246;
247; MenuEvent_EventGetDefaultMenuitem
248; Parameters:
249; SS:BP: Ptr to MENUVARS
250; Returns:
251; AX: Was event processed
252; CX: Index of menuitem to set selected
253; Corrupts registers:
254; Nothing
255;--------------------------------------------------------------------
256ALIGN JUMP_ALIGN
257MenuEvent_EventGetDefaultMenuitem:
258 xor ax, ax ; Not processed, default to menuitem 0
259 ret
260
261
262;--------------------------------------------------------------------
263; Handles Menu Initialized notification (EVNT_MNU_INITDONE).
264;
265; MenuEvent_EventMenuInitDone
266; Parameters:
267; SS:BP: Ptr to MENUVARS
268; Returns:
269; AX: Was event processed
270; Corrupts registers:
271; Nothing
272;--------------------------------------------------------------------
273ALIGN JUMP_ALIGN
274MenuEvent_EventMenuInitDone:
275 mov ax, 1
276 ret
Note: See TracBrowser for help on using the repository browser.