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

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

Changes to XTIDE Universal BIOS:

  • INT 13h functions should no longer use Assembly Library.
  • Boot menu now properly displays swapped drive numbers.
File size: 5.4 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 call RamVars_GetSegmentToDS
88 call DriveXlate_Reset
89 call BootMenu_GetDriveToDXforMenuitemInCX
90 call DriveXlate_SetDriveToSwap
91
92 xor ax, ax ; Update first floppy drive (for translated drive number)
93 CALL_MENU_LIBRARY RefreshItemFromAX
94 mov dl, 80h
95 call BootMenu_GetMenuitemToDXforDriveInDL
96 xchg ax, dx ; Update first hard disk (for translated drive number)
97 CALL_MENU_LIBRARY RefreshItemFromAX
98 pop ax ; Update new item (for translated drive number)
99 CALL_MENU_LIBRARY RefreshItemFromAX
100 CALL_MENU_LIBRARY RefreshInformation
101 stc
102 ret
103
104
105; Parameters:
106; AL: ASCII character for the key
107; AH: Keyboard library scan code for the key
108ALIGN JUMP_ALIGN
109.KeyStrokeInAX:
110 cmp ah, ROM_BOOT_HOTKEY_SCANCODE
111 jne SHORT .CheckDriveHotkeys
112 jmp Int19hMenu_RomBoot
113ALIGN JUMP_ALIGN
114.CheckDriveHotkeys:
115 call BootMenu_GetMenuitemToAXforAsciiHotkeyInAL
116 cmp ax, [bp+MENUINIT.wItems]
117 jae SHORT .EventCompleted ; Invalid key
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;--------------------------------------------------------------------
157.RefreshItemOrInformationWithJumpTableInCSBX:
158 cmp cl, NO_ITEM_HIGHLIGHTED
159 je SHORT .EventCompleted
160
161 call RamVars_GetSegmentToDS
162 call BootMenu_GetDriveToDXforMenuitemInCX
163 test dl, dl ; Floppy drive?
164 jns SHORT .DrawFloppyDrive
165 jmp [cs:bx+ITEM_TYPE_REFRESH.HardDisk]
166ALIGN JUMP_ALIGN
167.DrawFloppyDrive:
168 jmp [cs:bx+ITEM_TYPE_REFRESH.FloppyDrive]
169
170; Jump tables for .RefreshItemOrInformationWithJumpTableInCSBX
171ALIGN WORD_ALIGN
172.rgwItemTypeRefresh:
173istruc ITEM_TYPE_REFRESH
174 at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitem
175 at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitem
176iend
177.rgwInformationItemTypeRefresh:
178istruc ITEM_TYPE_REFRESH
179 at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitemInformation
180 at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitemInformation
181iend
Note: See TracBrowser for help on using the repository browser.