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

Last change on this file since 494 was 493, checked in by gregli@…, 12 years ago

Separated MODULE_8BIT_IDE into the basic part used by XTIDE rev 1 and rev 2 which is PIO based, and MODULE_8BIT_IDE_ADVANCED for JRIDE and XTCF support which requires memory mapping and/or DMA. This allows for creating an 8KB image with boot menu support (but no hotkeys) for the XTIDE rev 1. Cleaned up how we reset the drive translation information, ensuring it is properly set between boot attempt on a primary and secondary drive - as a result we clean it when needed, rather than trying to always keep it clean. Also fixed translation bugs in int13h.asm where I had previously missed converting some MODULE_HOTKEYS into MODULE_DRIVEXLATE.

File size: 7.1 KB
RevLine 
[392]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
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
[489]63.EventNotHandled:
64.DoNotSetDefaultMenuitem:
[392]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_ItemSelectedFromCX equ (EventItemSelectedFromCX - FirstEvent)
72MENUEVENT_RefreshTitle equ (BootMenuPrint_TitleStrings - FirstEvent)
73MENUEVENT_RefreshInformation equ (BootMenuPrint_RefreshInformation - FirstEvent)
74MENUEVENT_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?
[489]83 ja SHORT .EventNotHandled
[392]84 jmp [cs:bx+rgfnEventSpecificHandlers]
85
[489]86.EventNotHandled:
87.DoNotSetDefaultMenuitem:
[392]88 xor dx, dx ; Clear CF (and menuitem index for DoNotSetDefaultMenuitem)
89 ret
90
91rgfnEventSpecificHandlers:
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;--------------------------------------------------------------------
117FirstEvent:
118EventInitializeMenuinitFromSSBP:
119 ; Store default Menuitem (=default drive to boot from)
[492]120 xor dx, dx
[392]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
[492]128 inc ax ; extra entry for ROM Boot item
[392]129 mov [bp+MENUINIT.wItems], ax
[492]130
[392]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;--------------------------------------------------------------------
161EventItemHighlightedFromCX:
162 push cx
163 call BootMenu_GetDriveToDXforMenuitemInCX
[492]164 jnc .noDriveSwap
[392]165 call DriveXlate_SetDriveToSwap
[492]166.noDriveSwap:
167
[392]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
[492]181
[392]182;--------------------------------------------------------------------
[395]183; EventItemSelectedFromCX
[392]184; Parameters
[395]185; CX: Index of selected item
[392]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;--------------------------------------------------------------------
[395]195EventItemSelectedFromCX:
[392]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;--------------------------------------------------------------------
209CloseBootMenu:
210 CALL_MENU_LIBRARY Close
211 ; Fall to BootMenuEvent_Completed
212
[492]213
[392]214;--------------------------------------------------------------------
215; BootMenuEvent_Completed
216; Parameters
217; Nothing
218; Returns:
219; CF: Set to exit from menu
220; Corrupts registers:
221; Nothing
222;--------------------------------------------------------------------
223BootMenuEvent_Completed:
224 stc
225 ret
Note: See TracBrowser for help on using the repository browser.