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

Last change on this file since 92 was 92, checked in by Tomi Tilli, 14 years ago

Changes to XTIDE Universal BIOS:

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