source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuEvent.asm@ 547

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

Changes to XTIDE Universal BIOS:

  • Swapping Floppy and Hard Drives at the same time work again (broke in r492).
  • Hotkeys again work in boot menu (broke in r492).
File size: 9.0 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Boot Menu event handler for menu library callbacks.
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; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; GetMenuitemToDXforDriveInDL
25; Parameters:
26; DL: Drive number
27; Returns:
28; DX: Menuitem index (assuming drive is available)
29; Corrupts registers:
30; AX
31;--------------------------------------------------------------------
32GetMenuitemToDXforDriveInDL:
33 xor dh, dh ; Drive number now in DX
34 test dl, dl
35 jns SHORT .ReturnItemIndexInDX ; Return if floppy drive (HD bit not set)
36 call FloppyDrive_GetCountToAX
37 and dl, ~80h ; Clear HD bit
38 add dx, ax
39.ReturnItemIndexInDX:
40 ret
41
42
43;--------------------------------------------------------------------
44; BootMenuEvent_Handler
45; Common parameters for all events:
46; BX: Menu event (anything from MENUEVENT struct)
47; SS:BP: Menu library handle
48; Common return values for all events:
49; CF: Set if event processed
50; Cleared if event not processed
51; Corrupts registers:
52; All
53;--------------------------------------------------------------------
54BootMenuEvent_Handler:
55 LOAD_BDA_SEGMENT_TO es, di
56 call RamVars_GetSegmentToDS
57
58%ifdef MENUEVENT_INLINE_OFFSETS
59
60 add bx, FirstEvent
61 jmp bx
62
63.EventNotHandled:
64.DoNotSetDefaultMenuitem:
65 xor dx, dx ; Clear CF (and menuitem index for DoNotSetDefaultMenuitem)
66 ret
67
68MENUEVENT_InitializeMenuinitFromDSSI equ (EventInitializeMenuinitFromSSBP - FirstEvent)
69MENUEVENT_ExitMenu equ (BootMenuEvent_Completed - FirstEvent)
70MENUEVENT_ItemHighlightedFromCX equ (EventItemHighlightedFromCX - FirstEvent)
71MENUEVENT_KeyStrokeInAX equ (EventKeyStrokeInAX - FirstEvent)
72MENUEVENT_ItemSelectedFromCX equ (EventItemSelectedFromCX - FirstEvent)
73MENUEVENT_RefreshTitle equ (BootMenuPrint_TitleStrings - FirstEvent)
74MENUEVENT_RefreshInformation equ (BootMenuPrint_RefreshInformation - FirstEvent)
75MENUEVENT_RefreshItemFromCX equ (BootMenuPrint_RefreshItem - FirstEvent)
76;
77; Note that there is no entry for MENUEVENT_IdleProcessing. If MENUEVENT_IDLEPROCESSING_ENABLE is not %defined,
78; then the entry point will not be called (saving memory on this end and at the CALL point).
79;
80
81%else
82
83 cmp bx, BYTE MENUEVENT.RefreshItemFromCX ; Above last supported item?
84 ja SHORT .EventNotHandled
85 jmp [cs:bx+rgfnEventSpecificHandlers]
86
87.EventNotHandled:
88.DoNotSetDefaultMenuitem:
89 xor dx, dx ; Clear CF (and menuitem index for DoNotSetDefaultMenuitem)
90 ret
91
92rgfnEventSpecificHandlers:
93 dw EventInitializeMenuinitFromSSBP ; MENUEVENT.InitializeMenuinitFromDSSI
94 dw EventCompleted ; MENUEVENT.ExitMenu
95 dw EventNotHandled ; MENUEVENT.IdleProcessing
96 dw EventItemHighlightedFromCX ; MENUEVENT.ItemHighlightedFromCX
97
98 dw EventItemSelectedFromCX ; MENUEVENT.ItemSelectedFromCX
99 dw EventKeyStrokeInAX ; MENUEVENT.KeyStrokeInAX
100 dw BootMenuPrint_TitleStrings ; MENUEVENT.RefreshTitle
101 dw BootMenuPrint_RefreshInformation ; MENUEVENT.RefreshInformation
102 dw BootMenuPrint_RefreshItem ; MENUEVENT.RefreshItemFromCX
103
104%endif
105
106
107;--------------------------------------------------------------------
108; EventInitializeMenuinitFromSSBP
109; Parameters
110; DS: Ptr to RAMVARS
111; ES: Ptr to BDA (zero)
112; SS:BP: Ptr to MENUINIT struct to initialize
113; Returns:
114; CF: Set if event processed
115; Cleared if event not processed
116; Corrupts registers:
117; Does not matter
118;--------------------------------------------------------------------
119FirstEvent:
120EventInitializeMenuinitFromSSBP:
121 ; Store default Menuitem (=default drive to boot from)
122 xor dx, dx
123 mov [bp+MENUINIT.wHighlightedItem], dx
124
125 ; Store number of Menuitems
126 call RamVars_GetHardDiskCountFromBDAtoAX
127 xchg ax, cx
128 call FloppyDrive_GetCountToAX
129 add ax, cx
130 inc ax ; extra entry for ROM Boot item
131 mov [bp+MENUINIT.wItems], ax
132
133 ; Store menu size
134 mov WORD [bp+MENUINIT.wTitleAndInfoLines], BOOT_MENU_TITLE_AND_INFO_LINES
135 mov BYTE [bp+MENUINIT.bWidth], BOOT_MENU_WIDTH
136 add al, BOOT_MENU_HEIGHT_WITHOUT_ITEMS
137 xchg cx, ax
138 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
139 MIN_U ah, cl
140 mov [bp+MENUINIT.bHeight], ah
141
142 ; Store selection timeout
143 mov ax, [cs:ROMVARS.wBootTimeout]
144 CALL_MENU_LIBRARY StartSelectionTimeoutWithTicksInAX
145 stc
146 ret
147
148
149;--------------------------------------------------------------------
150; EventItemHighlightedFromCX
151; Parameters
152; CX: Index of new highlighted item
153; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
154; DS: Ptr to RAMVARS
155; ES: Ptr to BDA (zero)
156; SS:BP: Menu library handle
157; Returns:
158; CF: Set if event processed
159; Cleared if event not processed
160; Corrupts registers:
161; Does not matter
162;--------------------------------------------------------------------
163EventItemHighlightedFromCX:
164 push cx
165
166 ; Drive number translations and hotkeys must be reset to defaults so highlighted
167 ; selections are correctly displayed on Hotkey Bar and on Boot Menu
168%ifdef MODULE_HOTKEYS
169 call BootVars_StoreDefaultDriveLettersToHotkeyVars
170%endif
171 call DriveXlate_Reset
172
173 ; Set highlighted item to be drive to boot from for visual purposes only
174 call BootMenu_GetDriveToDXforMenuitemInCX
175 jnc SHORT .noDriveSwapSinceRomBootSelected
176 call DriveXlate_SetDriveToSwap
177
178%ifdef MODULE_HOTKEYS
179 ; Store highlighted drive as hotkey
180 call HotkeyBar_StoreHotkeyToBootvarsForDriveNumberInDL
181 jmp SHORT .UpdateHotkeyBar
182.noDriveSwapSinceRomBootSelected:
183 mov ah, ROM_BOOT_HOTKEY_SCANCODE
184 call HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
185
186.UpdateHotkeyBar:
187 ; Redraw Hotkey Bar for updated boot drive letters
188 mov al, MONO_NORMAL
189 CALL_DISPLAY_LIBRARY SetCharacterAttributeFromAL
190
191 mov bl, ATTRIBUTES_ARE_USED
192 mov ax, TELETYPE_OUTPUT_WITH_ATTRIBUTE
193 CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
194 call HotkeyBar_DrawToTopOfScreen
195%else
196.noDriveSwapSinceRomBootSelected:
197%endif ; MODULE_HOTKEYS
198
199 ; Redraw changes in drive numbers
200 xor ax, ax ; Update first floppy drive (for translated drive number)
201 CALL_MENU_LIBRARY RefreshItemFromAX
202 mov dl, 80h
203 call GetMenuitemToDXforDriveInDL
204 xchg ax, dx ; Update first hard disk (for translated drive number)
205 CALL_MENU_LIBRARY RefreshItemFromAX
206 pop ax ; Update new item (for translated drive number)
207 CALL_MENU_LIBRARY RefreshItemFromAX
208 CALL_MENU_LIBRARY RefreshInformation
209 stc
210 ret
211
212
213;--------------------------------------------------------------------
214; EventKeyStrokeInAX
215; Parameters
216; AL: ASCII character for the key
217; AH: Keyboard library scan code for the key
218; DS: Ptr to RAMVARS
219; ES: Ptr to BDA (zero)
220; SS:BP: Menu library handle
221; Returns:
222; CF: Set if event processed
223; Cleared if event not processed
224; Corrupts registers:
225; Does not matter
226;--------------------------------------------------------------------
227%ifdef MODULE_HOTKEYS
228EventKeyStrokeInAX:
229 ; Keypress will be the primary boot drive
230 cmp ah, BOOT_MENU_HOTKEY_SCANCODE
231 je SHORT BootMenuEvent_Completed ; Ignore Boot Menu hotkey
232 call HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
233 jnc SHORT BootMenuEvent_Completed
234 ; Fall to CloseBootMenu through EventItemSelectedFromCX
235%endif
236
237
238;--------------------------------------------------------------------
239; EventItemSelectedFromCX
240; Parameters
241; CX: Index of selected item
242; DS: Ptr to RAMVARS
243; ES: Ptr to BDA (zero)
244; SS:BP: Menu library handle
245; Returns:
246; CF: Set if event processed
247; Cleared if event not processed
248; Corrupts registers:
249; Does not matter
250;--------------------------------------------------------------------
251EventItemSelectedFromCX:
252 ; Fall to CloseBootMenu
253
254
255;--------------------------------------------------------------------
256; CloseBootMenu
257; Parameters
258; DS: RAMVARS segment
259; ES: BDA segment (zero)
260; Returns:
261; Nothing
262; Corrupts registers:
263; Does not matter
264;--------------------------------------------------------------------
265CloseBootMenu:
266 CALL_MENU_LIBRARY Close
267 ; Fall to BootMenuEvent_Completed
268
269
270;--------------------------------------------------------------------
271; BootMenuEvent_Completed
272; Parameters
273; Nothing
274; Returns:
275; CF: Set to exit from menu
276; Corrupts registers:
277; Nothing
278;--------------------------------------------------------------------
279BootMenuEvent_Completed:
280 stc
281%ifndef MODULE_HOTKEYS
282EventKeyStrokeInAX:
283%endif
284 ret
Note: See TracBrowser for help on using the repository browser.