1 | ; File name : BootMenuEvent.asm |
---|
2 | ; Project name : IDE BIOS |
---|
3 | ; Created date : 26.3.2010 |
---|
4 | ; Last update : 1.4.2010 |
---|
5 | ; Author : Tomi Tilli |
---|
6 | ; Description : Boot Menu event handler for menu library callbacks. |
---|
7 | |
---|
8 | ; Section containing code |
---|
9 | SECTION .text |
---|
10 | |
---|
11 | ;-------------------------------------------------------------------- |
---|
12 | ; Boot Menu event handler. |
---|
13 | ; |
---|
14 | ; BootMenuEvent_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 | ;-------------------------------------------------------------------- |
---|
27 | ALIGN JUMP_ALIGN |
---|
28 | BootMenuEvent_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_GETDEF ; 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 |
---|
45 | ALIGN WORD_ALIGN |
---|
46 | .rgwEventJmp: |
---|
47 | dw BootMenuEvent_Exit ; 0, EVNT_MNU_EXIT (Menu will quit) |
---|
48 | dw BootMenuEvent_EventItemSelectionChanged ; 1, EVNT_MMU_SELCHG (Menuitem selection changed (with arrows)) |
---|
49 | dw BootMenuEvent_EventItemSelected ; 2, EVNT_MNU_SELSET (Menuitem selected (with Enter)) |
---|
50 | dw BootMenuEvent_EventKeyPressed ; 3, EVNT_MNU_KEY (Keyboard key pressed) |
---|
51 | dw BootMenuEvent_EventMenuDraw ; 4, EVNT_MNU_UPD (Menu needs to be updated) |
---|
52 | dw BootMenuEvent_EventGetDefaultMenuitem ; 5, EVNT_MNU_GETDEF (Request menuitem to be selected by default) |
---|
53 | |
---|
54 | |
---|
55 | ;-------------------------------------------------------------------- |
---|
56 | ; Boot Menu event handler. |
---|
57 | ; Handles Menu Exit notification (EVNT_MNU_EXIT). |
---|
58 | ; |
---|
59 | ; BootMenuEvent_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 | ;-------------------------------------------------------------------- |
---|
69 | ALIGN JUMP_ALIGN |
---|
70 | BootMenuEvent_Exit: |
---|
71 | mov ax, 1 ; Event handled |
---|
72 | ret |
---|
73 | |
---|
74 | |
---|
75 | ;-------------------------------------------------------------------- |
---|
76 | ; Boot Menu event handler. |
---|
77 | ; Handles Menuitem Selection Changed notification (EVNT_MMU_SELCHG). |
---|
78 | ; |
---|
79 | ; BootMenuEvent_EventItemSelectionChanged |
---|
80 | ; Parameters: |
---|
81 | ; CX: Index of selected Menuitem |
---|
82 | ; SS:BP: Ptr to MENUVARS |
---|
83 | ; Returns: |
---|
84 | ; AX: 1 = Event processed |
---|
85 | ; Corrupts registers: |
---|
86 | ; BX, CX, DX, DI |
---|
87 | ;-------------------------------------------------------------------- |
---|
88 | ALIGN JUMP_ALIGN |
---|
89 | BootMenuEvent_EventItemSelectionChanged: |
---|
90 | call RamVars_GetSegmentToDS |
---|
91 | call DriveXlate_Reset |
---|
92 | call BootMenu_ConvertMenuitemToDriveOrFunction |
---|
93 | jc SHORT BootMenuEvent_UpdateAllMenuitems ; Selection changed to a function |
---|
94 | call DriveXlate_SetDriveToSwap |
---|
95 | ; Fall to BootMenuEvent_UpdateAllMenuitems |
---|
96 | |
---|
97 | ;-------------------------------------------------------------------- |
---|
98 | ; Redraws all menuitems. |
---|
99 | ; |
---|
100 | ; BootMenuEvent_UpdateAllMenuitems |
---|
101 | ; Parameters: |
---|
102 | ; SS:BP: Ptr to MENUVARS |
---|
103 | ; Returns: |
---|
104 | ; AX: 1 = Event processed |
---|
105 | ; Corrupts registers: |
---|
106 | ; BX, CX, DX |
---|
107 | ;-------------------------------------------------------------------- |
---|
108 | ALIGN JUMP_ALIGN |
---|
109 | BootMenuEvent_UpdateAllMenuitems: |
---|
110 | mov cx, -1 ; Update all items |
---|
111 | mov dl, MFL_UPD_ITEM | MFL_UPD_NFO | MFL_UPD_NOCLEAR |
---|
112 | call Menu_Invalidate |
---|
113 | mov ax, 1 ; Event handled |
---|
114 | ret |
---|
115 | |
---|
116 | |
---|
117 | ;-------------------------------------------------------------------- |
---|
118 | ; Boot Menu event handler. |
---|
119 | ; Handles Menuitem Selected notification (EVNT_MNU_SELSET). |
---|
120 | ; |
---|
121 | ; BootMenuEvent_EventItemSelected |
---|
122 | ; Parameters: |
---|
123 | ; CX: Index of selected Menuitem |
---|
124 | ; SS:BP: Ptr to MENUVARS |
---|
125 | ; Returns: |
---|
126 | ; AX: 1 = Event processed |
---|
127 | ; Corrupts registers: |
---|
128 | ; BX, CX, DX |
---|
129 | ;-------------------------------------------------------------------- |
---|
130 | ALIGN JUMP_ALIGN |
---|
131 | BootMenuEvent_EventItemSelected: |
---|
132 | call Menu_Exit ; Exit from menu |
---|
133 | mov ax, 1 ; Event handled |
---|
134 | ret |
---|
135 | |
---|
136 | |
---|
137 | ;-------------------------------------------------------------------- |
---|
138 | ; Boot Menu event handler. |
---|
139 | ; Handles Key pressed notification (EVNT_MNU_KEY). |
---|
140 | ; |
---|
141 | ; BootMenuEvent_EventKeyPressed |
---|
142 | ; Parameters: |
---|
143 | ; CX: Index of currently selected Menuitem |
---|
144 | ; DL: ASCII character |
---|
145 | ; DH: BIOS Scan Code |
---|
146 | ; SS:BP: Ptr to MENUVARS |
---|
147 | ; Returns: |
---|
148 | ; AX: 1 = Event processed |
---|
149 | ; Corrupts registers: |
---|
150 | ; BX, CX, DX, DS |
---|
151 | ;-------------------------------------------------------------------- |
---|
152 | ALIGN JUMP_ALIGN |
---|
153 | BootMenuEvent_EventKeyPressed: |
---|
154 | mov al, dl ; Copy ASCII char to AL |
---|
155 | sub al, 'a'-'A' ; To upper case character |
---|
156 | cmp al, 'A' ; First possible drive letter? |
---|
157 | jb SHORT .Return ; If below, return |
---|
158 | cmp al, 'Z' ; Last possible drive letter? |
---|
159 | ja SHORT .Return ; If above, return |
---|
160 | LOAD_BDA_SEGMENT_TO ds, dx |
---|
161 | mov [BOOTVARS.bMenuHotkey], al |
---|
162 | jmp SHORT BootMenuEvent_EventItemSelected |
---|
163 | .Return: |
---|
164 | mov ax, 1 |
---|
165 | ret |
---|
166 | |
---|
167 | |
---|
168 | ;-------------------------------------------------------------------- |
---|
169 | ; Boot Menu event handler. |
---|
170 | ; Handles Menu Update notification (EVNT_MNU_UPD). |
---|
171 | ; |
---|
172 | ; BootMenuEvent_EventMenuDraw |
---|
173 | ; Parameters: |
---|
174 | ; CX: Index of Menuitem to update (if MFL_UPD_ITEM set) |
---|
175 | ; DL: Update flag (only one): |
---|
176 | ; MFL_UPD_TITLE Update Menu Title string(s) |
---|
177 | ; MFL_UPD_NFO Update Menu Info string(s) |
---|
178 | ; MFL_UPD_ITEM Update Menuitem string |
---|
179 | ; SS:BP: Ptr to MENUVARS |
---|
180 | ; Returns: |
---|
181 | ; AX: Was event processed |
---|
182 | ; Corrupts registers: |
---|
183 | ; BX, CX, DX, SI, DI, DS |
---|
184 | ;-------------------------------------------------------------------- |
---|
185 | ALIGN JUMP_ALIGN |
---|
186 | BootMenuEvent_EventMenuDraw: |
---|
187 | test dl, MFL_UPD_ITEM ; Need to update Menuitem? |
---|
188 | jnz SHORT BootMenuEvent_DrawMenuitem |
---|
189 | test dl, MFL_UPD_NFO ; Need to update Info String(s)? |
---|
190 | jnz SHORT BootMenuEvent_DrawInfo |
---|
191 | test dl, MFL_UPD_TITLE ; Need to update Title String(s)? |
---|
192 | jnz SHORT BootMenuEvent_DrawTitle |
---|
193 | xor ax, ax |
---|
194 | ret |
---|
195 | |
---|
196 | ;-------------------------------------------------------------------- |
---|
197 | ; Draws Menuitem string. Cursor is set to a menuitem location. |
---|
198 | ; |
---|
199 | ; BootMenuEvent_DrawMenuitem |
---|
200 | ; Parameters: |
---|
201 | ; CX: Index of Menuitem to draw |
---|
202 | ; SS:BP: Ptr to MENUVARS |
---|
203 | ; Returns: |
---|
204 | ; AX: Was event processed |
---|
205 | ; Corrupts registers: |
---|
206 | ; BX, CX, DX, SI, DI, DS, ES |
---|
207 | ;-------------------------------------------------------------------- |
---|
208 | ALIGN JUMP_ALIGN |
---|
209 | BootMenuEvent_DrawMenuitem: |
---|
210 | call RamVars_GetSegmentToDS |
---|
211 | call BootMenu_ConvertMenuitemToDriveOrFunction |
---|
212 | jc SHORT .DrawFunctionItem |
---|
213 | call BootMenuPrint_TranslatedDriveNumber |
---|
214 | test dl, 80h ; Floppy drive? |
---|
215 | jz SHORT .DrawFloppyDriveItem |
---|
216 | jmp BootMenuPrint_HardDiskMenuitem |
---|
217 | ALIGN JUMP_ALIGN |
---|
218 | .DrawFunctionItem: |
---|
219 | jmp BootMenuPrint_FunctionMenuitem |
---|
220 | ALIGN JUMP_ALIGN |
---|
221 | .DrawFloppyDriveItem: |
---|
222 | jmp BootMenuPrint_FloppyMenuitem |
---|
223 | |
---|
224 | ;-------------------------------------------------------------------- |
---|
225 | ; Draws information strings. Cursor is set to a first information line. |
---|
226 | ; |
---|
227 | ; BootMenuEvent_DrawInfo |
---|
228 | ; Parameters: |
---|
229 | ; CX: Index of selected menuitem |
---|
230 | ; SS:BP: Ptr to MENUVARS |
---|
231 | ; Returns: |
---|
232 | ; AX: Was event processed |
---|
233 | ; Corrupts registers: |
---|
234 | ; BX, CX, DX, SI, DI, DS, ES |
---|
235 | ;-------------------------------------------------------------------- |
---|
236 | ALIGN JUMP_ALIGN |
---|
237 | BootMenuEvent_DrawInfo: |
---|
238 | call RamVars_GetSegmentToDS |
---|
239 | call BootMenu_ConvertMenuitemToDriveOrFunction |
---|
240 | jc SHORT .DrawFunctionInfo |
---|
241 | test dl, 80h ; Floppy drive? |
---|
242 | jz SHORT .DrawFloppyDriveInfo |
---|
243 | jmp BootMenuPrint_HardDiskMenuitemInformation |
---|
244 | ALIGN JUMP_ALIGN |
---|
245 | .DrawFunctionInfo: |
---|
246 | jmp BootMenuPrint_FunctionMenuitemInformation |
---|
247 | ALIGN JUMP_ALIGN |
---|
248 | .DrawFloppyDriveInfo: |
---|
249 | jmp BootMenuPrint_FloppyMenuitemInformation |
---|
250 | |
---|
251 | ;-------------------------------------------------------------------- |
---|
252 | ; Draws title strings. Cursor is set to a first title line. |
---|
253 | ; |
---|
254 | ; BootMenuEvent_DrawTitle |
---|
255 | ; Parameters: |
---|
256 | ; SS:BP: Ptr to MENUVARS |
---|
257 | ; Returns: |
---|
258 | ; AX: Was event processed |
---|
259 | ; Corrupts registers: |
---|
260 | ; CX, DX, SI |
---|
261 | ;-------------------------------------------------------------------- |
---|
262 | ALIGN JUMP_ALIGN |
---|
263 | BootMenuEvent_DrawTitle: |
---|
264 | jmp BootMenuPrint_TitleStrings |
---|
265 | |
---|
266 | |
---|
267 | ;-------------------------------------------------------------------- |
---|
268 | ; Boot Menu event handler. |
---|
269 | ; Handles Get Default Menuitem notification (EVNT_MNU_GETDEF). |
---|
270 | ; |
---|
271 | ; BootMenuEvent_EventGetDefaultMenuitem |
---|
272 | ; Parameters: |
---|
273 | ; SS:BP: Ptr to MENUVARS |
---|
274 | ; Returns: |
---|
275 | ; AX: Was event processed |
---|
276 | ; CX: Index of menuitem to set selected |
---|
277 | ; Corrupts registers: |
---|
278 | ; BX, CX, DX, DI, DS |
---|
279 | ;-------------------------------------------------------------------- |
---|
280 | ALIGN JUMP_ALIGN |
---|
281 | BootMenuEvent_EventGetDefaultMenuitem: |
---|
282 | call RamVars_GetSegmentToDS |
---|
283 | mov dl, [cs:ROMVARS.bBootDrv] ; Default boot drive |
---|
284 | call BootMenu_IsDriveInSystem |
---|
285 | jns SHORT .DoNotSetDefaultMenuitem |
---|
286 | call BootMenu_ConvertDriveToMenuitem |
---|
287 | mov ax, 1 |
---|
288 | ret |
---|
289 | ALIGN JUMP_ALIGN |
---|
290 | .DoNotSetDefaultMenuitem: |
---|
291 | xor ax, ax |
---|
292 | ret |
---|