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

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

Changes to XTIDE Universal BIOS:

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