source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuEvent.asm@ 386

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

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 5.8 KB
RevLine 
[88]1; Project name : XTIDE Universal BIOS
[3]2; Description : Boot Menu event handler for menu library callbacks.
3
[376]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
[3]20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; BootMenuEvent_Handler
[88]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
[3]31; Corrupts registers:
[88]32; All
[3]33;--------------------------------------------------------------------
34BootMenuEvent_Handler:
[202]35
[183]36%ifdef MENUEVENT_INLINE_OFFSETS
[202]37
[258]38 add bx, BootMenuEvent_Handler.FirstEvent
[183]39 jmp bx
[3]40
[258]41MENUEVENT_InitializeMenuinitFromDSSI equ (BootMenuEvent_Handler.InitializeMenuinitFromDSSI - BootMenuEvent_Handler.FirstEvent)
42MENUEVENT_ExitMenu equ (BootMenuEvent_EventCompleted - BootMenuEvent_Handler.FirstEvent)
43MENUEVENT_ItemHighlightedFromCX equ (BootMenuEvent_Handler.ItemHighlightedFromCX - BootMenuEvent_Handler.FirstEvent)
44MENUEVENT_ItemSelectedFromCX equ (BootMenuEvent_Handler.ItemSelectedFromCX - BootMenuEvent_Handler.FirstEvent)
45MENUEVENT_KeyStrokeInAX equ (BootMenuEvent_Handler.KeyStrokeInAX - BootMenuEvent_Handler.FirstEvent)
46MENUEVENT_RefreshTitle equ (BootMenuPrint_TitleStrings - BootMenuEvent_Handler.FirstEvent)
47MENUEVENT_RefreshInformation equ (BootMenuPrint_RefreshInformation - BootMenuEvent_Handler.FirstEvent)
48MENUEVENT_RefreshItemFromCX equ (BootMenuPrint_RefreshItem - BootMenuEvent_Handler.FirstEvent)
[202]49;
50; Note that there is no entry for MENUEVENT_IdleProcessing. If MENUEVENT_IDLEPROCESSING_ENABLE is not %defined,
[189]51; then the entry point will not be called (saving memory on this end and at the CALL point).
52;
[202]53
[183]54%else
[202]55
[189]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
[202]63
[3]64ALIGN WORD_ALIGN
[88]65.rgfnEventSpecificHandlers:
[241]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
[202]75
[183]76%endif
[3]77
78
[88]79; Parameters:
80; DS:SI: Ptr to MENUINIT struct to initialize
81; Returns:
82; DS:SI: Ptr to initialized MENUINIT struct
[258]83.FirstEvent:
[88]84.InitializeMenuinitFromDSSI:
85 push ds
86 call RamVars_GetSegmentToDS
87 call .GetDefaultMenuitemToDX
[124]88 call BootMenu_GetMenuitemCountToAX
[88]89 pop ds
[124]90 mov [si+MENUINIT.wItems], ax
[88]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
[124]94 call BootMenu_GetHeightToAHwithItemCountInAL
[88]95 mov [si+MENUINIT.bHeight], ah
[137]96 mov ax, [cs:ROMVARS.wBootTimeout]
[135]97 CALL_MENU_LIBRARY StartSelectionTimeoutWithTicksInAX
[88]98 stc
[3]99 ret
100
[88]101.GetDefaultMenuitemToDX:
102 mov dl, [cs:ROMVARS.bBootDrv] ; Default boot drive
103 call BootMenu_IsDriveInSystem
104 jnc SHORT .DoNotSetDefaultMenuitem
105 call DriveXlate_SetDriveToSwap
[124]106 jmp BootMenu_GetMenuitemToDXforDriveInDL
[369]107
[88]108.DoNotSetDefaultMenuitem:
109 xor dx, dx ; Whatever appears first on boot menu
110 ret
[3]111
[88]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
[241]118 call BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS
[3]119 call DriveXlate_Reset
120 call DriveXlate_SetDriveToSwap
[140]121
122 xor ax, ax ; Update first floppy drive (for translated drive number)
[88]123 CALL_MENU_LIBRARY RefreshItemFromAX
[140]124 mov dl, 80h
125 call BootMenu_GetMenuitemToDXforDriveInDL
126 xchg ax, dx ; Update first hard disk (for translated drive number)
[88]127 CALL_MENU_LIBRARY RefreshItemFromAX
[140]128 pop ax ; Update new item (for translated drive number)
129 CALL_MENU_LIBRARY RefreshItemFromAX
[88]130 CALL_MENU_LIBRARY RefreshInformation
131 stc
[3]132 ret
133
134
[88]135; Parameters:
136; AL: ASCII character for the key
137; AH: Keyboard library scan code for the key
138.KeyStrokeInAX:
[92]139 cmp ah, ROM_BOOT_HOTKEY_SCANCODE
140 jne SHORT .CheckDriveHotkeys
[212]141 ;; NOTE: carry flag will be clear after compare above that resulted in zero
142 jmp Int19hMenu_JumpToBootSector_or_RomBoot
[369]143
[92]144.CheckDriveHotkeys:
[130]145 call BootMenu_GetMenuitemToAXforAsciiHotkeyInAL
146 cmp ax, [bp+MENUINIT.wItems]
[241]147 jae SHORT BootMenuEvent_EventCompleted ; Invalid key
[248]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]
[88]153 CALL_MENU_LIBRARY HighlightItemFromAX
[248]154 or [RAMVARS.xlateVars+XLATEVARS.wFDandHDswap], dx
[88]155 ; Fall to .ItemSelectedFromCX
[3]156
157
[88]158; Parameters:
159; CX: Index of selected item
160.ItemSelectedFromCX:
161 CALL_MENU_LIBRARY Close
[248]162
[241]163BootMenuEvent_EventCompleted:
[88]164 stc
[3]165 ret
166
Note: See TracBrowser for help on using the repository browser.