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-2012 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
|
---|
21 | SECTION .text
|
---|
22 |
|
---|
23 | ;--------------------------------------------------------------------
|
---|
24 | ; BootMenuEvent_Handler
|
---|
25 | ; Common parameters for all events:
|
---|
26 | ; BX: Menu event (anything from MENUEVENT struct)
|
---|
27 | ; SS:BP: Menu library handle
|
---|
28 | ; Common return values for all events:
|
---|
29 | ; CF: Set if event processed
|
---|
30 | ; Cleared if event not processed
|
---|
31 | ; Corrupts registers:
|
---|
32 | ; All
|
---|
33 | ;--------------------------------------------------------------------
|
---|
34 | BootMenuEvent_Handler:
|
---|
35 |
|
---|
36 | %ifdef MENUEVENT_INLINE_OFFSETS
|
---|
37 |
|
---|
38 | add bx, BootMenuEvent_Handler.FirstEvent
|
---|
39 | jmp bx
|
---|
40 |
|
---|
41 | MENUEVENT_InitializeMenuinitFromDSSI equ (BootMenuEvent_Handler.InitializeMenuinitFromDSSI - BootMenuEvent_Handler.FirstEvent)
|
---|
42 | MENUEVENT_ExitMenu equ (BootMenuEvent_EventCompleted - BootMenuEvent_Handler.FirstEvent)
|
---|
43 | MENUEVENT_ItemHighlightedFromCX equ (BootMenuEvent_Handler.ItemHighlightedFromCX - BootMenuEvent_Handler.FirstEvent)
|
---|
44 | MENUEVENT_ItemSelectedFromCX equ (BootMenuEvent_Handler.ItemSelectedFromCX - BootMenuEvent_Handler.FirstEvent)
|
---|
45 | MENUEVENT_KeyStrokeInAX equ (BootMenuEvent_Handler.KeyStrokeInAX - BootMenuEvent_Handler.FirstEvent)
|
---|
46 | MENUEVENT_RefreshTitle equ (BootMenuPrint_TitleStrings - BootMenuEvent_Handler.FirstEvent)
|
---|
47 | MENUEVENT_RefreshInformation equ (BootMenuPrint_RefreshInformation - BootMenuEvent_Handler.FirstEvent)
|
---|
48 | MENUEVENT_RefreshItemFromCX equ (BootMenuPrint_RefreshItem - BootMenuEvent_Handler.FirstEvent)
|
---|
49 | ;
|
---|
50 | ; Note that there is no entry for MENUEVENT_IdleProcessing. If MENUEVENT_IDLEPROCESSING_ENABLE is not %defined,
|
---|
51 | ; then the entry point will not be called (saving memory on this end and at the CALL point).
|
---|
52 | ;
|
---|
53 |
|
---|
54 | %else
|
---|
55 |
|
---|
56 | cmp bx, BYTE MENUEVENT.RefreshItemFromCX ; Above last supported item?
|
---|
57 | ja SHORT .EventNotHandled
|
---|
58 | jmp [cs:bx+.rgfnEventSpecificHandlers]
|
---|
59 |
|
---|
60 | .EventNotHandled:
|
---|
61 | clc
|
---|
62 | ret
|
---|
63 |
|
---|
64 | ALIGN WORD_ALIGN
|
---|
65 | .rgfnEventSpecificHandlers:
|
---|
66 | dw .InitializeMenuinitFromDSSI ; MENUEVENT.InitializeMenuinitFromDSSI
|
---|
67 | dw BootMenuEvent_EventCompleted ; MENUEVENT.ExitMenu
|
---|
68 | dw .EventNotHandled ; MENUEVENT.IdleProcessing
|
---|
69 | dw .ItemHighlightedFromCX ; MENUEVENT.ItemHighlightedFromCX
|
---|
70 | dw .ItemSelectedFromCX ; MENUEVENT.ItemSelectedFromCX
|
---|
71 | dw .KeyStrokeInAX ; MENUEVENT.KeyStrokeInAX
|
---|
72 | dw BootMenuPrint_TitleStrings ; MENUEVENT.RefreshTitle
|
---|
73 | dw BootMenuPrint_RefreshInformation ; MENUEVENT.RefreshInformation
|
---|
74 | dw BootMenuPrint_RefreshItem ; MENUEVENT.RefreshItemFromCX
|
---|
75 |
|
---|
76 | %endif
|
---|
77 |
|
---|
78 |
|
---|
79 | ; Parameters:
|
---|
80 | ; DS:SI: Ptr to MENUINIT struct to initialize
|
---|
81 | ; Returns:
|
---|
82 | ; DS:SI: Ptr to initialized MENUINIT struct
|
---|
83 | .FirstEvent:
|
---|
84 | .InitializeMenuinitFromDSSI:
|
---|
85 | push ds
|
---|
86 | call RamVars_GetSegmentToDS
|
---|
87 | call .GetDefaultMenuitemToDX
|
---|
88 | call BootMenu_GetMenuitemCountToAX
|
---|
89 | pop ds
|
---|
90 | mov [si+MENUINIT.wItems], ax
|
---|
91 | mov [si+MENUINIT.wHighlightedItem], dx
|
---|
92 | mov WORD [si+MENUINIT.wTitleAndInfoLines], BOOT_MENU_TITLE_AND_INFO_LINES
|
---|
93 | mov BYTE [si+MENUINIT.bWidth], BOOT_MENU_WIDTH
|
---|
94 | call BootMenu_GetHeightToAHwithItemCountInAL
|
---|
95 | mov [si+MENUINIT.bHeight], ah
|
---|
96 | mov ax, [cs:ROMVARS.wBootTimeout]
|
---|
97 | CALL_MENU_LIBRARY StartSelectionTimeoutWithTicksInAX
|
---|
98 | stc
|
---|
99 | ret
|
---|
100 |
|
---|
101 | .GetDefaultMenuitemToDX:
|
---|
102 | mov dl, [cs:ROMVARS.bBootDrv] ; Default boot drive
|
---|
103 | call BootMenu_IsDriveInSystem
|
---|
104 | jnc SHORT .DoNotSetDefaultMenuitem
|
---|
105 | call DriveXlate_SetDriveToSwap
|
---|
106 | jmp BootMenu_GetMenuitemToDXforDriveInDL
|
---|
107 |
|
---|
108 | .DoNotSetDefaultMenuitem:
|
---|
109 | xor dx, dx ; Whatever appears first on boot menu
|
---|
110 | ret
|
---|
111 |
|
---|
112 |
|
---|
113 | ; Parameters:
|
---|
114 | ; CX: Index of new highlighted item
|
---|
115 | ; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
|
---|
116 | .ItemHighlightedFromCX:
|
---|
117 | push cx
|
---|
118 | call BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS
|
---|
119 | call DriveXlate_Reset
|
---|
120 | call DriveXlate_SetDriveToSwap
|
---|
121 |
|
---|
122 | xor ax, ax ; Update first floppy drive (for translated drive number)
|
---|
123 | CALL_MENU_LIBRARY RefreshItemFromAX
|
---|
124 | mov dl, 80h
|
---|
125 | call BootMenu_GetMenuitemToDXforDriveInDL
|
---|
126 | xchg ax, dx ; Update first hard disk (for translated drive number)
|
---|
127 | CALL_MENU_LIBRARY RefreshItemFromAX
|
---|
128 | pop ax ; Update new item (for translated drive number)
|
---|
129 | CALL_MENU_LIBRARY RefreshItemFromAX
|
---|
130 | CALL_MENU_LIBRARY RefreshInformation
|
---|
131 | stc
|
---|
132 | ret
|
---|
133 |
|
---|
134 |
|
---|
135 | ; Parameters:
|
---|
136 | ; AL: ASCII character for the key
|
---|
137 | ; AH: Keyboard library scan code for the key
|
---|
138 | .KeyStrokeInAX:
|
---|
139 | cmp ah, ROM_BOOT_HOTKEY_SCANCODE
|
---|
140 | jne SHORT .CheckDriveHotkeys
|
---|
141 | ;; NOTE: carry flag will be clear after compare above that resulted in zero
|
---|
142 | jmp Int19hMenu_JumpToBootSector_or_RomBoot
|
---|
143 |
|
---|
144 | .CheckDriveHotkeys:
|
---|
145 | call BootMenu_GetMenuitemToAXforAsciiHotkeyInAL
|
---|
146 | cmp ax, [bp+MENUINIT.wItems]
|
---|
147 | jae SHORT BootMenuEvent_EventCompleted ; Invalid key
|
---|
148 |
|
---|
149 | ; Highlighting new item resets drive translation and we do not want that.
|
---|
150 | ; We must be able to translate both floppy drive and hard drive when using hotkey.
|
---|
151 | call RamVars_GetSegmentToDS
|
---|
152 | mov dx, [RAMVARS.xlateVars+XLATEVARS.wFDandHDswap]
|
---|
153 | CALL_MENU_LIBRARY HighlightItemFromAX
|
---|
154 | or [RAMVARS.xlateVars+XLATEVARS.wFDandHDswap], dx
|
---|
155 | ; Fall to .ItemSelectedFromCX
|
---|
156 |
|
---|
157 |
|
---|
158 | ; Parameters:
|
---|
159 | ; CX: Index of selected item
|
---|
160 | .ItemSelectedFromCX:
|
---|
161 | CALL_MENU_LIBRARY Close
|
---|
162 |
|
---|
163 | BootMenuEvent_EventCompleted:
|
---|
164 | stc
|
---|
165 | ret
|
---|
166 |
|
---|