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

Last change on this file since 98 was 95, checked in by Tomi Tilli, 13 years ago

Changes to XTIDE Universal BIOS:

  • Smaller boot sector loading string.
  • Cleaned boot code a bit.
File size: 4.9 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_ConvertMenuitemFromCXtoDriveInDX
93 call DriveXlate_SetDriveToSwap
94 pop ax ; Update previous item
95 CALL_MENU_LIBRARY RefreshItemFromAX
96 pop ax ; Update new item
97 CALL_MENU_LIBRARY RefreshItemFromAX
98 CALL_MENU_LIBRARY RefreshInformation
99 stc
100 ret
101
102
103; Parameters:
104; AL: ASCII character for the key
105; AH: Keyboard library scan code for the key
106ALIGN JUMP_ALIGN
107.KeyStrokeInAX:
108 cmp ah, ROM_BOOT_HOTKEY_SCANCODE
109 jne SHORT .CheckDriveHotkeys
110 jmp Int19hMenu_RomBoot
111ALIGN JUMP_ALIGN
112.CheckDriveHotkeys:
113 call BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX
114 cmp cx, [bp+MENUINIT.wItems]
115 jae SHORT .EventCompleted ; Invalid key
116 xchg ax, cx
117 CALL_MENU_LIBRARY HighlightItemFromAX
118 ; Fall to .ItemSelectedFromCX
119
120
121; Parameters:
122; CX: Index of selected item
123ALIGN JUMP_ALIGN
124.ItemSelectedFromCX:
125 CALL_MENU_LIBRARY Close
126.EventCompleted:
127 stc
128 ret
129
130
131; Parameters:
132; CX: Index of item to refresh
133; Cursor has been positioned to the beginning of item line
134ALIGN JUMP_ALIGN
135.RefreshItemFromCX:
136 mov bx, .rgwItemTypeRefresh
137 jmp SHORT .RefreshItemOrInformationWithJumpTableInCSBX
138
139
140; Parameters:
141; CX: Index of highlighted item
142; Cursor has been positioned to the beginning of first line
143ALIGN JUMP_ALIGN
144.RefreshInformation:
145 mov bx, .rgwInformationItemTypeRefresh
146 ; Fall to .RefreshItemOrInformationWithJumpTableInCSBX
147
148;--------------------------------------------------------------------
149; RefreshItemOrInformationWithJumpTableInCSBX
150; Parameters:
151; CX: Index of selected menuitem
152; CS:BX: Ptr to ITEM_TYPE_REFRESH jump table
153; Returns:
154; CF: set since event processed
155;--------------------------------------------------------------------
156ALIGN JUMP_ALIGN
157.RefreshItemOrInformationWithJumpTableInCSBX:
158 cmp cl, NO_ITEM_HIGHLIGHTED
159 je SHORT .EventCompleted
160
161 call RamVars_GetSegmentToDS
162 call BootMenu_ConvertMenuitemFromCXtoDriveInDX
163 test dl, 80h ; Floppy drive?
164 jz 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.