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

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

Changes to XTIDE Universal BIOS:

  • Menu selection timeout is now specified in timer ticks.
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
7struc ITEM_TYPE_REFRESH
8 .HardDisk resb 2
9 .FloppyDrive resb 2
10endstruc
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;--------------------------------------------------------------------
24ALIGN JUMP_ALIGN
25BootMenuEvent_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
33ALIGN 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
50ALIGN 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 ax, [cs:ROMVARS.wBootTimeout]
64 CALL_MENU_LIBRARY StartSelectionTimeoutWithTicksInAX
65 stc
66 ret
67
68ALIGN JUMP_ALIGN
69.GetDefaultMenuitemToDX:
70 mov dl, [cs:ROMVARS.bBootDrv] ; Default boot drive
71 call BootMenu_IsDriveInSystem
72 jnc SHORT .DoNotSetDefaultMenuitem
73 call DriveXlate_SetDriveToSwap
74 jmp BootMenu_GetMenuitemToDXforDriveInDL
75ALIGN JUMP_ALIGN
76.DoNotSetDefaultMenuitem:
77 xor dx, dx ; Whatever appears first on boot menu
78 ret
79
80
81; Parameters:
82; CX: Index of new highlighted item
83; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
84ALIGN JUMP_ALIGN
85.ItemHighlightedFromCX:
86 push cx
87 push dx
88 call RamVars_GetSegmentToDS
89 call DriveXlate_Reset
90 call BootMenu_GetDriveToDXforMenuitemInCX
91 call DriveXlate_SetDriveToSwap
92 pop ax ; Update previous item
93 CALL_MENU_LIBRARY RefreshItemFromAX
94 pop ax ; Update new item
95 CALL_MENU_LIBRARY RefreshItemFromAX
96 CALL_MENU_LIBRARY RefreshInformation
97 stc
98 ret
99
100
101; Parameters:
102; AL: ASCII character for the key
103; AH: Keyboard library scan code for the key
104ALIGN JUMP_ALIGN
105.KeyStrokeInAX:
106 cmp ah, ROM_BOOT_HOTKEY_SCANCODE
107 jne SHORT .CheckDriveHotkeys
108 jmp Int19hMenu_RomBoot
109ALIGN JUMP_ALIGN
110.CheckDriveHotkeys:
111 call BootMenu_GetMenuitemToAXforAsciiHotkeyInAL
112 cmp ax, [bp+MENUINIT.wItems]
113 jae SHORT .EventCompleted ; Invalid key
114 CALL_MENU_LIBRARY HighlightItemFromAX
115 ; Fall to .ItemSelectedFromCX
116
117
118; Parameters:
119; CX: Index of selected item
120ALIGN JUMP_ALIGN
121.ItemSelectedFromCX:
122 CALL_MENU_LIBRARY Close
123.EventCompleted:
124 stc
125 ret
126
127
128; Parameters:
129; CX: Index of item to refresh
130; Cursor has been positioned to the beginning of item line
131ALIGN JUMP_ALIGN
132.RefreshItemFromCX:
133 mov bx, .rgwItemTypeRefresh
134 jmp SHORT .RefreshItemOrInformationWithJumpTableInCSBX
135
136
137; Parameters:
138; CX: Index of highlighted item
139; Cursor has been positioned to the beginning of first line
140ALIGN JUMP_ALIGN
141.RefreshInformation:
142 mov bx, .rgwInformationItemTypeRefresh
143 ; Fall to .RefreshItemOrInformationWithJumpTableInCSBX
144
145;--------------------------------------------------------------------
146; RefreshItemOrInformationWithJumpTableInCSBX
147; Parameters:
148; CX: Index of selected menuitem
149; CS:BX: Ptr to ITEM_TYPE_REFRESH jump table
150; Returns:
151; CF: set since event processed
152;--------------------------------------------------------------------
153.RefreshItemOrInformationWithJumpTableInCSBX:
154 cmp cl, NO_ITEM_HIGHLIGHTED
155 je SHORT .EventCompleted
156
157 call RamVars_GetSegmentToDS
158 call BootMenu_GetDriveToDXforMenuitemInCX
159 test dl, dl ; Floppy drive?
160 jns SHORT .DrawFloppyDrive
161 jmp [cs:bx+ITEM_TYPE_REFRESH.HardDisk]
162ALIGN JUMP_ALIGN
163.DrawFloppyDrive:
164 jmp [cs:bx+ITEM_TYPE_REFRESH.FloppyDrive]
165
166; Jump tables for .RefreshItemOrInformationWithJumpTableInCSBX
167ALIGN WORD_ALIGN
168.rgwItemTypeRefresh:
169istruc ITEM_TYPE_REFRESH
170 at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitem
171 at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitem
172iend
173.rgwInformationItemTypeRefresh:
174istruc ITEM_TYPE_REFRESH
175 at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitemInformation
176 at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitemInformation
177iend
Note: See TracBrowser for help on using the repository browser.