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

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

Changes to XTIDE Universal BIOS:

  • Now uses new libraries (untested)
  • Non-working since code size is too large
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
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 mov [si+MENUINIT.bHeight], ah
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 call BootMenu_ConvertDriveToMenuitem
75 mov dx, cx
76 ret
77ALIGN JUMP_ALIGN
78.DoNotSetDefaultMenuitem:
79 xor dx, dx ; Whatever appears first on boot menu
80 ret
81
82
83; Parameters:
84; CX: Index of new highlighted item
85; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
86ALIGN JUMP_ALIGN
87.ItemHighlightedFromCX:
88 push cx
89 push dx
90 call RamVars_GetSegmentToDS
91 call DriveXlate_Reset
92 call BootMenu_ConvertMenuitemToDriveOrFunction
93 jc SHORT .UpdatePreviousAndNewMenuitem ; Selection changed to a function
94 call DriveXlate_SetDriveToSwap
95
96.UpdatePreviousAndNewMenuitem:
97 pop ax ; Update previous item
98 CALL_MENU_LIBRARY RefreshItemFromAX
99 pop ax ; Update new item
100 CALL_MENU_LIBRARY RefreshItemFromAX
101 CALL_MENU_LIBRARY RefreshInformation
102 stc
103 ret
104
105
106; Parameters:
107; AL: ASCII character for the key
108; AH: Keyboard library scan code for the key
109ALIGN JUMP_ALIGN
110.KeyStrokeInAX:
111 xor ah, ah ; ASCII drive letter now in AX
112 call BootMenu_ConvertHotkeyToMenuitem
113 cmp cx, [bp+MENUINIT.wItems]
114 jae SHORT .EventNotHandled ; Invalid key
115 xchg ax, cx
116 CALL_MENU_LIBRARY HighlightItemFromAX
117 ; Fall to .ItemSelectedFromCX
118
119
120; Parameters:
121; CX: Index of selected item
122ALIGN JUMP_ALIGN
123.ItemSelectedFromCX:
124 CALL_MENU_LIBRARY Close
125.EventCompleted:
126 stc
127 ret
128
129
130; Parameters:
131; CX: Index of item to refresh
132; Cursor has been positioned to the beginning of item line
133ALIGN JUMP_ALIGN
134.RefreshItemFromCX:
135 mov bx, .rgwItemTypeRefresh
136 jmp SHORT .RefreshItemOrInformationWithJumpTableInCSBX
137
138
139; Parameters:
140; CX: Index of highlighted item
141; Cursor has been positioned to the beginning of first line
142ALIGN JUMP_ALIGN
143.RefreshInformation:
144 mov bx, .rgwInformationItemTypeRefresh
145 ; Fall to .RefreshItemOrInformationWithJumpTableInCSBX
146
147;--------------------------------------------------------------------
148; RefreshItemOrInformationWithJumpTableInCSBX
149; Parameters:
150; CX: Index of selected menuitem
151; CS:BX: Ptr to ITEM_TYPE_REFRESH jump table
152; Returns:
153; CF: set since event processed
154;--------------------------------------------------------------------
155ALIGN JUMP_ALIGN
156.RefreshItemOrInformationWithJumpTableInCSBX:
157 cmp cl, NO_ITEM_HIGHLIGHTED
158 je SHORT .EventCompleted
159
160 call RamVars_GetSegmentToDS
161 call BootMenu_ConvertMenuitemToDriveOrFunction
162 jc SHORT .DrawFunction
163 test dl, 80h ; Floppy drive?
164 jz SHORT .DrawFloppyDrive
165 jmp [cs:bx+ITEM_TYPE_REFRESH.HardDisk]
166ALIGN JUMP_ALIGN
167.DrawFunction:
168 jmp [cs:bx+ITEM_TYPE_REFRESH.SpecialFunction]
169ALIGN JUMP_ALIGN
170.DrawFloppyDrive:
171 jmp [cs:bx+ITEM_TYPE_REFRESH.FloppyDrive]
172
173; Jump tables for .RefreshItemOrInformationWithJumpTableInCSBX
174ALIGN WORD_ALIGN
175.rgwItemTypeRefresh:
176istruc ITEM_TYPE_REFRESH
177 at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitem
178 at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitem
179 at ITEM_TYPE_REFRESH.SpecialFunction, dw BootMenuPrint_FunctionMenuitem
180iend
181.rgwInformationItemTypeRefresh:
182istruc ITEM_TYPE_REFRESH
183 at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitemInformation
184 at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitemInformation
185 at ITEM_TYPE_REFRESH.SpecialFunction, dw BootMenuPrint_ClearInformationArea
186iend
Note: See TracBrowser for help on using the repository browser.