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 | struc ITEM_TYPE_REFRESH
|
---|
8 | .HardDisk resb 2
|
---|
9 | .FloppyDrive resb 2
|
---|
10 | endstruc
|
---|
11 |
|
---|
12 |
|
---|
13 | ;--------------------------------------------------------------------
|
---|
14 | ; BootMenuEvent_Handler
|
---|
15 | ; Common parameters for all events:
|
---|
16 | ; BX: Menu event (anything from MENUEVENT struct)
|
---|
17 | ; SS:BP: Menu library handle
|
---|
18 | ; Common return values for all events:
|
---|
19 | ; CF: Set if event processed
|
---|
20 | ; Cleared if event not processed
|
---|
21 | ; Corrupts registers:
|
---|
22 | ; All
|
---|
23 | ;--------------------------------------------------------------------
|
---|
24 | ALIGN JUMP_ALIGN
|
---|
25 | BootMenuEvent_Handler:
|
---|
26 | cmp bx, BYTE MENUEVENT.RefreshItemFromCX ; Above last supported item?
|
---|
27 | ja SHORT .EventNotHandled
|
---|
28 | jmp [cs:bx+.rgfnEventSpecificHandlers]
|
---|
29 | .EventNotHandled:
|
---|
30 | clc
|
---|
31 | ret
|
---|
32 |
|
---|
33 | ALIGN WORD_ALIGN
|
---|
34 | .rgfnEventSpecificHandlers:
|
---|
35 | dw .InitializeMenuinitFromDSSI ; MENUEVENT.InitializeMenuinitFromDSSI
|
---|
36 | dw .EventCompleted ; MENUEVENT.ExitMenu
|
---|
37 | dw .EventNotHandled ; MENUEVENT.IdleProcessing
|
---|
38 | dw .ItemHighlightedFromCX ; MENUEVENT.ItemHighlightedFromCX
|
---|
39 | dw .ItemSelectedFromCX ; MENUEVENT.ItemSelectedFromCX
|
---|
40 | dw .KeyStrokeInAX ; MENUEVENT.KeyStrokeInAX
|
---|
41 | dw BootMenuPrint_TitleStrings ; MENUEVENT.RefreshTitle
|
---|
42 | dw .RefreshInformation ; MENUEVENT.RefreshInformation
|
---|
43 | dw .RefreshItemFromCX ; MENUEVENT.RefreshItemFromCX
|
---|
44 |
|
---|
45 |
|
---|
46 | ; Parameters:
|
---|
47 | ; DS:SI: Ptr to MENUINIT struct to initialize
|
---|
48 | ; Returns:
|
---|
49 | ; DS:SI: Ptr to initialized MENUINIT struct
|
---|
50 | ALIGN JUMP_ALIGN
|
---|
51 | .InitializeMenuinitFromDSSI:
|
---|
52 | push ds
|
---|
53 | call RamVars_GetSegmentToDS
|
---|
54 | call .GetDefaultMenuitemToDX
|
---|
55 | call BootMenu_GetMenuitemCountToAX
|
---|
56 | pop ds
|
---|
57 | mov [si+MENUINIT.wItems], ax
|
---|
58 | mov [si+MENUINIT.wHighlightedItem], dx
|
---|
59 | mov WORD [si+MENUINIT.wTitleAndInfoLines], BOOT_MENU_TITLE_AND_INFO_LINES
|
---|
60 | mov BYTE [si+MENUINIT.bWidth], BOOT_MENU_WIDTH
|
---|
61 | call BootMenu_GetHeightToAHwithItemCountInAL
|
---|
62 | mov [si+MENUINIT.bHeight], ah
|
---|
63 | mov al, TICKS_PER_SECOND
|
---|
64 | mul BYTE [cs:ROMVARS.bBootDelay]
|
---|
65 | CALL_MENU_LIBRARY StartSelectionTimeoutWithTicksInAX
|
---|
66 | stc
|
---|
67 | ret
|
---|
68 |
|
---|
69 | ALIGN JUMP_ALIGN
|
---|
70 | .GetDefaultMenuitemToDX:
|
---|
71 | mov dl, [cs:ROMVARS.bBootDrv] ; Default boot drive
|
---|
72 | call BootMenu_IsDriveInSystem
|
---|
73 | jnc SHORT .DoNotSetDefaultMenuitem
|
---|
74 | call DriveXlate_SetDriveToSwap
|
---|
75 | jmp BootMenu_GetMenuitemToDXforDriveInDL
|
---|
76 | ALIGN JUMP_ALIGN
|
---|
77 | .DoNotSetDefaultMenuitem:
|
---|
78 | xor dx, dx ; Whatever appears first on boot menu
|
---|
79 | ret
|
---|
80 |
|
---|
81 |
|
---|
82 | ; Parameters:
|
---|
83 | ; CX: Index of new highlighted item
|
---|
84 | ; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
|
---|
85 | ALIGN JUMP_ALIGN
|
---|
86 | .ItemHighlightedFromCX:
|
---|
87 | push cx
|
---|
88 | push dx
|
---|
89 | call RamVars_GetSegmentToDS
|
---|
90 | call DriveXlate_Reset
|
---|
91 | call BootMenu_GetDriveToDXforMenuitemInCX
|
---|
92 | call DriveXlate_SetDriveToSwap
|
---|
93 | pop ax ; Update previous item
|
---|
94 | CALL_MENU_LIBRARY RefreshItemFromAX
|
---|
95 | pop ax ; Update new item
|
---|
96 | CALL_MENU_LIBRARY RefreshItemFromAX
|
---|
97 | CALL_MENU_LIBRARY RefreshInformation
|
---|
98 | stc
|
---|
99 | ret
|
---|
100 |
|
---|
101 |
|
---|
102 | ; Parameters:
|
---|
103 | ; AL: ASCII character for the key
|
---|
104 | ; AH: Keyboard library scan code for the key
|
---|
105 | ALIGN JUMP_ALIGN
|
---|
106 | .KeyStrokeInAX:
|
---|
107 | cmp ah, ROM_BOOT_HOTKEY_SCANCODE
|
---|
108 | jne SHORT .CheckDriveHotkeys
|
---|
109 | jmp Int19hMenu_RomBoot
|
---|
110 | ALIGN JUMP_ALIGN
|
---|
111 | .CheckDriveHotkeys:
|
---|
112 | call BootMenu_GetMenuitemToAXforAsciiHotkeyInAL
|
---|
113 | cmp ax, [bp+MENUINIT.wItems]
|
---|
114 | jae SHORT .EventCompleted ; Invalid key
|
---|
115 | CALL_MENU_LIBRARY HighlightItemFromAX
|
---|
116 | ; Fall to .ItemSelectedFromCX
|
---|
117 |
|
---|
118 |
|
---|
119 | ; Parameters:
|
---|
120 | ; CX: Index of selected item
|
---|
121 | ALIGN JUMP_ALIGN
|
---|
122 | .ItemSelectedFromCX:
|
---|
123 | CALL_MENU_LIBRARY Close
|
---|
124 | .EventCompleted:
|
---|
125 | stc
|
---|
126 | ret
|
---|
127 |
|
---|
128 |
|
---|
129 | ; Parameters:
|
---|
130 | ; CX: Index of item to refresh
|
---|
131 | ; Cursor has been positioned to the beginning of item line
|
---|
132 | ALIGN JUMP_ALIGN
|
---|
133 | .RefreshItemFromCX:
|
---|
134 | mov bx, .rgwItemTypeRefresh
|
---|
135 | jmp SHORT .RefreshItemOrInformationWithJumpTableInCSBX
|
---|
136 |
|
---|
137 |
|
---|
138 | ; Parameters:
|
---|
139 | ; CX: Index of highlighted item
|
---|
140 | ; Cursor has been positioned to the beginning of first line
|
---|
141 | ALIGN JUMP_ALIGN
|
---|
142 | .RefreshInformation:
|
---|
143 | mov bx, .rgwInformationItemTypeRefresh
|
---|
144 | ; Fall to .RefreshItemOrInformationWithJumpTableInCSBX
|
---|
145 |
|
---|
146 | ;--------------------------------------------------------------------
|
---|
147 | ; RefreshItemOrInformationWithJumpTableInCSBX
|
---|
148 | ; Parameters:
|
---|
149 | ; CX: Index of selected menuitem
|
---|
150 | ; CS:BX: Ptr to ITEM_TYPE_REFRESH jump table
|
---|
151 | ; Returns:
|
---|
152 | ; CF: set since event processed
|
---|
153 | ;--------------------------------------------------------------------
|
---|
154 | .RefreshItemOrInformationWithJumpTableInCSBX:
|
---|
155 | cmp cl, NO_ITEM_HIGHLIGHTED
|
---|
156 | je SHORT .EventCompleted
|
---|
157 |
|
---|
158 | call RamVars_GetSegmentToDS
|
---|
159 | call BootMenu_GetDriveToDXforMenuitemInCX
|
---|
160 | test dl, dl ; Floppy drive?
|
---|
161 | jns SHORT .DrawFloppyDrive
|
---|
162 | jmp [cs:bx+ITEM_TYPE_REFRESH.HardDisk]
|
---|
163 | ALIGN JUMP_ALIGN
|
---|
164 | .DrawFloppyDrive:
|
---|
165 | jmp [cs:bx+ITEM_TYPE_REFRESH.FloppyDrive]
|
---|
166 |
|
---|
167 | ; Jump tables for .RefreshItemOrInformationWithJumpTableInCSBX
|
---|
168 | ALIGN WORD_ALIGN
|
---|
169 | .rgwItemTypeRefresh:
|
---|
170 | istruc ITEM_TYPE_REFRESH
|
---|
171 | at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitem
|
---|
172 | at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitem
|
---|
173 | iend
|
---|
174 | .rgwInformationItemTypeRefresh:
|
---|
175 | istruc ITEM_TYPE_REFRESH
|
---|
176 | at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitemInformation
|
---|
177 | at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitemInformation
|
---|
178 | iend
|
---|