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