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

Last change on this file since 374 was 369, checked in by gregli@…, 13 years ago

Removed align directives for initalization code and added define for align in boot-time calls to the assembly library (defaulting to 1), resulting in a significant savings for the AT and 386 builds. Fixed a bug with switch command line handling in the serial server. Put in CR characters in licesnse.txt, so that it properly displays on Windows. In the configurator, added default values for user supplied CHS and LBA values, defaulting to values within range when those features are enabled. Updated the copyright message in the configurator as the literal word Copyright is important.

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