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
|
---|
21 | SECTION .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 | ;--------------------------------------------------------------------
|
---|
32 | GetMenuitemToDXforDriveInDL:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
54 | BootMenuEvent_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 |
|
---|
68 | MENUEVENT_InitializeMenuinitFromDSSI equ (EventInitializeMenuinitFromSSBP - FirstEvent)
|
---|
69 | MENUEVENT_ExitMenu equ (BootMenuEvent_Completed - FirstEvent)
|
---|
70 | MENUEVENT_ItemHighlightedFromCX equ (EventItemHighlightedFromCX - FirstEvent)
|
---|
71 | MENUEVENT_ItemSelectedFromCX equ (EventItemSelectedFromCX - FirstEvent)
|
---|
72 | MENUEVENT_RefreshTitle equ (BootMenuPrint_TitleStrings - FirstEvent)
|
---|
73 | MENUEVENT_RefreshInformation equ (BootMenuPrint_RefreshInformation - FirstEvent)
|
---|
74 | MENUEVENT_RefreshItemFromCX equ (BootMenuPrint_RefreshItem - FirstEvent)
|
---|
75 | ;
|
---|
76 | ; Note that there is no entry for MENUEVENT_IdleProcessing. If MENUEVENT_IDLEPROCESSING_ENABLE is not %defined,
|
---|
77 | ; then the entry point will not be called (saving memory on this end and at the CALL point).
|
---|
78 | ;
|
---|
79 |
|
---|
80 | %else
|
---|
81 |
|
---|
82 | cmp bx, BYTE MENUEVENT.RefreshItemFromCX ; Above last supported item?
|
---|
83 | ja SHORT .EventNotHandled
|
---|
84 | jmp [cs:bx+rgfnEventSpecificHandlers]
|
---|
85 |
|
---|
86 | .EventNotHandled:
|
---|
87 | .DoNotSetDefaultMenuitem:
|
---|
88 | xor dx, dx ; Clear CF (and menuitem index for DoNotSetDefaultMenuitem)
|
---|
89 | ret
|
---|
90 |
|
---|
91 | rgfnEventSpecificHandlers:
|
---|
92 | dw EventInitializeMenuinitFromSSBP ; MENUEVENT.InitializeMenuinitFromDSSI
|
---|
93 | dw EventCompleted ; MENUEVENT.ExitMenu
|
---|
94 | dw EventNotHandled ; MENUEVENT.IdleProcessing
|
---|
95 | dw EventItemHighlightedFromCX ; MENUEVENT.ItemHighlightedFromCX
|
---|
96 | dw EventItemSelectedFromCX ; MENUEVENT.ItemSelectedFromCX
|
---|
97 | dw EventKeyStrokeInAX ; MENUEVENT.KeyStrokeInAX
|
---|
98 | dw BootMenuPrint_TitleStrings ; MENUEVENT.RefreshTitle
|
---|
99 | dw BootMenuPrint_RefreshInformation ; MENUEVENT.RefreshInformation
|
---|
100 | dw BootMenuPrint_RefreshItem ; MENUEVENT.RefreshItemFromCX
|
---|
101 |
|
---|
102 | %endif
|
---|
103 |
|
---|
104 |
|
---|
105 | ;--------------------------------------------------------------------
|
---|
106 | ; EventInitializeMenuinitFromSSBP
|
---|
107 | ; Parameters
|
---|
108 | ; DS: Ptr to RAMVARS
|
---|
109 | ; ES: Ptr to BDA (zero)
|
---|
110 | ; SS:BP: Ptr to MENUINIT struct to initialize
|
---|
111 | ; Returns:
|
---|
112 | ; CF: Set if event processed
|
---|
113 | ; Cleared if event not processed
|
---|
114 | ; Corrupts registers:
|
---|
115 | ; Does not matter
|
---|
116 | ;--------------------------------------------------------------------
|
---|
117 | FirstEvent:
|
---|
118 | EventInitializeMenuinitFromSSBP:
|
---|
119 | ; Store default Menuitem (=default drive to boot from)
|
---|
120 | xor dx, dx
|
---|
121 | mov [bp+MENUINIT.wHighlightedItem], dx
|
---|
122 |
|
---|
123 | ; Store number of Menuitems
|
---|
124 | call RamVars_GetHardDiskCountFromBDAtoAX
|
---|
125 | xchg ax, cx
|
---|
126 | call FloppyDrive_GetCountToAX
|
---|
127 | add ax, cx
|
---|
128 | inc ax ; extra entry for ROM Boot item
|
---|
129 | mov [bp+MENUINIT.wItems], ax
|
---|
130 |
|
---|
131 | ; Store menu size
|
---|
132 | mov WORD [bp+MENUINIT.wTitleAndInfoLines], BOOT_MENU_TITLE_AND_INFO_LINES
|
---|
133 | mov BYTE [bp+MENUINIT.bWidth], BOOT_MENU_WIDTH
|
---|
134 | add al, BOOT_MENU_HEIGHT_WITHOUT_ITEMS
|
---|
135 | xchg cx, ax
|
---|
136 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
|
---|
137 | MIN_U ah, cl
|
---|
138 | mov [bp+MENUINIT.bHeight], ah
|
---|
139 |
|
---|
140 | ; Store selection timeout
|
---|
141 | mov ax, [cs:ROMVARS.wBootTimeout]
|
---|
142 | CALL_MENU_LIBRARY StartSelectionTimeoutWithTicksInAX
|
---|
143 | stc
|
---|
144 | ret
|
---|
145 |
|
---|
146 |
|
---|
147 | ;--------------------------------------------------------------------
|
---|
148 | ; EventItemHighlightedFromCX
|
---|
149 | ; Parameters
|
---|
150 | ; CX: Index of new highlighted item
|
---|
151 | ; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
|
---|
152 | ; DS: Ptr to RAMVARS
|
---|
153 | ; ES: Ptr to BDA (zero)
|
---|
154 | ; SS:BP: Menu library handle
|
---|
155 | ; Returns:
|
---|
156 | ; CF: Set if event processed
|
---|
157 | ; Cleared if event not processed
|
---|
158 | ; Corrupts registers:
|
---|
159 | ; Does not matter
|
---|
160 | ;--------------------------------------------------------------------
|
---|
161 | EventItemHighlightedFromCX:
|
---|
162 | push cx
|
---|
163 | call BootMenu_GetDriveToDXforMenuitemInCX
|
---|
164 | jnc .noDriveSwap
|
---|
165 | call DriveXlate_SetDriveToSwap
|
---|
166 | .noDriveSwap:
|
---|
167 |
|
---|
168 | ; Redraw changes in drive numbers
|
---|
169 | xor ax, ax ; Update first floppy drive (for translated drive number)
|
---|
170 | CALL_MENU_LIBRARY RefreshItemFromAX
|
---|
171 | mov dl, 80h
|
---|
172 | call GetMenuitemToDXforDriveInDL
|
---|
173 | xchg ax, dx ; Update first hard disk (for translated drive number)
|
---|
174 | CALL_MENU_LIBRARY RefreshItemFromAX
|
---|
175 | pop ax ; Update new item (for translated drive number)
|
---|
176 | CALL_MENU_LIBRARY RefreshItemFromAX
|
---|
177 | CALL_MENU_LIBRARY RefreshInformation
|
---|
178 | stc
|
---|
179 | ret
|
---|
180 |
|
---|
181 |
|
---|
182 | ;--------------------------------------------------------------------
|
---|
183 | ; EventItemSelectedFromCX
|
---|
184 | ; Parameters
|
---|
185 | ; CX: Index of selected item
|
---|
186 | ; DS: Ptr to RAMVARS
|
---|
187 | ; ES: Ptr to BDA (zero)
|
---|
188 | ; SS:BP: Menu library handle
|
---|
189 | ; Returns:
|
---|
190 | ; CF: Set if event processed
|
---|
191 | ; Cleared if event not processed
|
---|
192 | ; Corrupts registers:
|
---|
193 | ; Does not matter
|
---|
194 | ;--------------------------------------------------------------------
|
---|
195 | EventItemSelectedFromCX:
|
---|
196 | ; Fall to CloseBootMenu
|
---|
197 |
|
---|
198 |
|
---|
199 | ;--------------------------------------------------------------------
|
---|
200 | ; CloseBootMenu
|
---|
201 | ; Parameters
|
---|
202 | ; DS: RAMVARS segment
|
---|
203 | ; ES: BDA segment (zero)
|
---|
204 | ; Returns:
|
---|
205 | ; Nothing
|
---|
206 | ; Corrupts registers:
|
---|
207 | ; Does not matter
|
---|
208 | ;--------------------------------------------------------------------
|
---|
209 | CloseBootMenu:
|
---|
210 | CALL_MENU_LIBRARY Close
|
---|
211 | ; Fall to BootMenuEvent_Completed
|
---|
212 |
|
---|
213 |
|
---|
214 | ;--------------------------------------------------------------------
|
---|
215 | ; BootMenuEvent_Completed
|
---|
216 | ; Parameters
|
---|
217 | ; Nothing
|
---|
218 | ; Returns:
|
---|
219 | ; CF: Set to exit from menu
|
---|
220 | ; Corrupts registers:
|
---|
221 | ; Nothing
|
---|
222 | ;--------------------------------------------------------------------
|
---|
223 | BootMenuEvent_Completed:
|
---|
224 | stc
|
---|
225 | ret
|
---|