1 | ; Project name : XTIDE Universal BIOS |
---|
2 | ; Description : Displays Boot Menu. |
---|
3 | |
---|
4 | ; Section containing code |
---|
5 | SECTION .text |
---|
6 | |
---|
7 | ;-------------------------------------------------------------------- |
---|
8 | ; Displays Boot Menu and returns Drive or Function number. |
---|
9 | ; |
---|
10 | ; BootMenu_DisplayAndReturnSelection |
---|
11 | ; Parameters: |
---|
12 | ; DS: RAMVARS segment |
---|
13 | ; Returns: |
---|
14 | ; DX: Untranslated drive number to be used for booting (if CF cleared) |
---|
15 | ; Function number (if CF set) |
---|
16 | ; CF: Cleared if drive selected |
---|
17 | ; Set if function selected |
---|
18 | ; Corrupts registers: |
---|
19 | ; All General Purpose Registers |
---|
20 | ;-------------------------------------------------------------------- |
---|
21 | ALIGN JUMP_ALIGN |
---|
22 | BootMenu_DisplayAndReturnSelection: |
---|
23 | call DriveXlate_Reset |
---|
24 | call BootMenuPrint_TheBottomOfScreen |
---|
25 | call BootMenu_Enter ; Get selected menuitem index to CX |
---|
26 | call BootMenuPrint_ClearScreen |
---|
27 | cmp cx, BYTE NO_ITEM_SELECTED |
---|
28 | je SHORT BootMenu_DisplayAndReturnSelection |
---|
29 | jmp BootMenu_ConvertMenuitemToDriveOrFunction |
---|
30 | |
---|
31 | |
---|
32 | ;-------------------------------------------------------------------- |
---|
33 | ; Enters Boot Menu or submenu. |
---|
34 | ; |
---|
35 | ; BootMenu_Enter |
---|
36 | ; Parameters: |
---|
37 | ; Nothing |
---|
38 | ; Returns: |
---|
39 | ; CX: Index of selected item or NO_ITEM_SELECTED |
---|
40 | ; Corrupts registers: |
---|
41 | ; BX, DI |
---|
42 | ;-------------------------------------------------------------------- |
---|
43 | ALIGN JUMP_ALIGN |
---|
44 | BootMenu_Enter: |
---|
45 | mov bx, BootMenuEvent_Handler |
---|
46 | CALL_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX |
---|
47 | xchg cx, ax |
---|
48 | ret |
---|
49 | |
---|
50 | |
---|
51 | ;-------------------------------------------------------------------- |
---|
52 | ; Returns number of menuitems in Boot Menu. |
---|
53 | ; |
---|
54 | ; BootMenu_GetMenuitemCountToCX |
---|
55 | ; Parameters: |
---|
56 | ; DS: RAMVARS segment |
---|
57 | ; Returns: |
---|
58 | ; CX: Number of boot menu items |
---|
59 | ; Corrupts registers: |
---|
60 | ; AX |
---|
61 | ;-------------------------------------------------------------------- |
---|
62 | ALIGN JUMP_ALIGN |
---|
63 | BootMenu_GetMenuitemCountToCX: |
---|
64 | call RamVars_GetHardDiskCountFromBDAtoCX |
---|
65 | xchg ax, cx |
---|
66 | call FloppyDrive_GetCount |
---|
67 | add ax, cx |
---|
68 | call BootMenu_GetMenuFunctionCount |
---|
69 | add cx, ax |
---|
70 | ret |
---|
71 | |
---|
72 | ;-------------------------------------------------------------------- |
---|
73 | ; Returns number of functions displayed in Boot Menu. |
---|
74 | ; |
---|
75 | ; BootMenu_GetMenuFunctionCount |
---|
76 | ; Parameters: |
---|
77 | ; Nothing |
---|
78 | ; Returns: |
---|
79 | ; CX: Number of boot menu functions |
---|
80 | ; Corrupts registers: |
---|
81 | ; Nothing |
---|
82 | ;-------------------------------------------------------------------- |
---|
83 | ALIGN JUMP_ALIGN |
---|
84 | BootMenu_GetMenuFunctionCount: |
---|
85 | xor cx, cx |
---|
86 | test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_ROMBOOT |
---|
87 | jz SHORT .DontIncludeRomBoot |
---|
88 | inc cx |
---|
89 | ALIGN JUMP_ALIGN |
---|
90 | .DontIncludeRomBoot: |
---|
91 | ret |
---|
92 | |
---|
93 | |
---|
94 | ;-------------------------------------------------------------------- |
---|
95 | ; BootMenu_GetHeightToALwithItemCountInCL |
---|
96 | ; Parameters: |
---|
97 | ; CL: Number of menuitems |
---|
98 | ; Returns: |
---|
99 | ; AH: Boot menu height |
---|
100 | ; Corrupts registers: |
---|
101 | ; AL, CL, DI |
---|
102 | ;-------------------------------------------------------------------- |
---|
103 | ALIGN JUMP_ALIGN |
---|
104 | BootMenu_GetHeightToAHwithItemCountInCL: |
---|
105 | add cl, BOOT_MENU_HEIGHT_WITHOUT_ITEMS |
---|
106 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH |
---|
107 | MIN_U ah, cl |
---|
108 | ret |
---|
109 | |
---|
110 | |
---|
111 | ;-------------------------------------------------------------------- |
---|
112 | ; Converts any hotkey to Boot Menu menuitem index. |
---|
113 | ; |
---|
114 | ; BootMenu_ConvertHotkeyToMenuitem |
---|
115 | ; Parameters: |
---|
116 | ; AX: ASCII hotkey starting from upper case 'A' |
---|
117 | ; Returns: |
---|
118 | ; CX: Menuitem index |
---|
119 | ; Corrupts registers: |
---|
120 | ; AX |
---|
121 | ;-------------------------------------------------------------------- |
---|
122 | ALIGN JUMP_ALIGN |
---|
123 | BootMenu_ConvertHotkeyToMenuitem: |
---|
124 | call BootMenu_GetLetterForFirstHardDisk |
---|
125 | cmp al, cl ; Letter is for Hard Disk? |
---|
126 | jae SHORT .StartFromHardDiskLetter |
---|
127 | sub al, 'A' ; Letter to Floppy Drive menuitem |
---|
128 | xchg ax, cx ; Menuitem index to CX |
---|
129 | ret |
---|
130 | ALIGN JUMP_ALIGN |
---|
131 | .StartFromHardDiskLetter: |
---|
132 | sub al, cl ; Hard Disk index |
---|
133 | call FloppyDrive_GetCount |
---|
134 | add cx, ax ; Menuitem index |
---|
135 | ret |
---|
136 | |
---|
137 | ;-------------------------------------------------------------------- |
---|
138 | ; Returns letter for first hard disk. Usually it will be 'c' but it |
---|
139 | ; can be higher if more than two floppy drives are found. |
---|
140 | ; |
---|
141 | ; BootMenu_GetLetterForFirstHardDisk |
---|
142 | ; Parameters: |
---|
143 | ; Nothing |
---|
144 | ; Returns: |
---|
145 | ; CL: Upper case letter for first hard disk |
---|
146 | ; Corrupts registers: |
---|
147 | ; CH |
---|
148 | ;-------------------------------------------------------------------- |
---|
149 | ALIGN JUMP_ALIGN |
---|
150 | BootMenu_GetLetterForFirstHardDisk: |
---|
151 | call FloppyDrive_GetCount |
---|
152 | add cl, 'A' |
---|
153 | MAX_U cl, 'C' |
---|
154 | ret |
---|
155 | |
---|
156 | |
---|
157 | ;-------------------------------------------------------------------- |
---|
158 | ; Converts selected menuitem index to drive number or function ID. |
---|
159 | ; |
---|
160 | ; BootMenu_ConvertMenuitemToDriveOrFunction |
---|
161 | ; Parameters: |
---|
162 | ; CX: Index of menuitem selected from Boot Menu |
---|
163 | ; DS: RAMVARS segment |
---|
164 | ; Returns: |
---|
165 | ; DX: Drive number to be used for booting (if CF cleared) |
---|
166 | ; Function ID (if CF set) |
---|
167 | ; CF: Cleared if drive selected |
---|
168 | ; Set if function selected |
---|
169 | ; Corrupts registers: |
---|
170 | ; AX, CX |
---|
171 | ;-------------------------------------------------------------------- |
---|
172 | ALIGN JUMP_ALIGN |
---|
173 | BootMenu_ConvertMenuitemToDriveOrFunction: |
---|
174 | mov dx, cx ; Copy menuitem index to DX |
---|
175 | call FloppyDrive_GetCount |
---|
176 | cmp dx, cx ; Floppy drive? |
---|
177 | jb SHORT .ReturnFloppyDriveInDX |
---|
178 | sub dx, cx ; Remove floppy drives from index |
---|
179 | call RamVars_GetHardDiskCountFromBDAtoCX |
---|
180 | cmp dx, cx ; Hard disk? |
---|
181 | jb SHORT .ReturnHardDiskInDX |
---|
182 | sub dx, cx ; Remove hard disks from index |
---|
183 | jmp SHORT BootMenu_ConvertFunctionIndexToID |
---|
184 | ALIGN JUMP_ALIGN |
---|
185 | .ReturnHardDiskInDX: |
---|
186 | or dl, 80h |
---|
187 | ALIGN JUMP_ALIGN |
---|
188 | .ReturnFloppyDriveInDX: |
---|
189 | clc |
---|
190 | ret |
---|
191 | |
---|
192 | |
---|
193 | ;-------------------------------------------------------------------- |
---|
194 | ; Converts selected menuitem index to drive number or function ID. |
---|
195 | ; |
---|
196 | ; BootMenu_ConvertFunctionIndexToID |
---|
197 | ; Parameters: |
---|
198 | ; CX: Menuitem index |
---|
199 | ; DX: Function index (Menuitem index - floppy count - HD count) |
---|
200 | ; Returns: |
---|
201 | ; DX: Function ID |
---|
202 | ; CF: Set to indicate function |
---|
203 | ; Corrupts registers: |
---|
204 | ; AX, CX |
---|
205 | ;-------------------------------------------------------------------- |
---|
206 | ALIGN JUMP_ALIGN |
---|
207 | BootMenu_ConvertFunctionIndexToID: |
---|
208 | mov dx, ID_BOOTFUNC_ROMBOOT |
---|
209 | stc |
---|
210 | ret |
---|
211 | |
---|
212 | |
---|
213 | ;-------------------------------------------------------------------- |
---|
214 | ; Converts Floppy or Hard Disk Drive number to menuitem index. |
---|
215 | ; This function does not check does the drive really exists. |
---|
216 | ; |
---|
217 | ; BootMenu_ConvertDriveToMenuitem |
---|
218 | ; Parameters: |
---|
219 | ; DL: Drive number |
---|
220 | ; Returns: |
---|
221 | ; CX: Menuitem index (assuming drive is available) |
---|
222 | ; Corrupts registers: |
---|
223 | ; AX |
---|
224 | ;-------------------------------------------------------------------- |
---|
225 | ALIGN JUMP_ALIGN |
---|
226 | BootMenu_ConvertDriveToMenuitem: |
---|
227 | test dl, 80h ; Floppy drive? |
---|
228 | jz SHORT .ReturnFloppyMenuitem |
---|
229 | call FloppyDrive_GetCount |
---|
230 | mov ax, 7Fh ; Load mask to clear floppy bit |
---|
231 | and ax, dx ; AX = Hard Disk index |
---|
232 | add cx, ax ; Add hard disk index to floppy drive count |
---|
233 | ret |
---|
234 | ALIGN JUMP_ALIGN |
---|
235 | .ReturnFloppyMenuitem: |
---|
236 | eMOVZX cx, dl ; Drive number and item index are equal |
---|
237 | ret |
---|
238 | |
---|
239 | |
---|
240 | ;-------------------------------------------------------------------- |
---|
241 | ; Checks is drive number valid for this system. |
---|
242 | ; |
---|
243 | ; BootMenu_IsDriveInSystem |
---|
244 | ; Parameters: |
---|
245 | ; DL: Drive number |
---|
246 | ; DS: RAMVARS segment |
---|
247 | ; Returns: |
---|
248 | ; CF: Set if drive number is valid |
---|
249 | ; Clear if drive is not present in system |
---|
250 | ; Corrupts registers: |
---|
251 | ; AX, CX |
---|
252 | ;-------------------------------------------------------------------- |
---|
253 | ALIGN JUMP_ALIGN |
---|
254 | BootMenu_IsDriveInSystem: |
---|
255 | test dl, 80h ; Floppy drive? |
---|
256 | jz SHORT .IsFloppyDriveIsInSystem |
---|
257 | call RamVars_GetHardDiskCountFromBDAtoCX ; Hard Disk count to CX |
---|
258 | or cl, 80h ; Set Hard Disk bit to CX |
---|
259 | jmp SHORT .CompareDriveNumberToDriveCount |
---|
260 | .IsFloppyDriveIsInSystem: |
---|
261 | call FloppyDrive_GetCount ; Floppy Drive count to CX |
---|
262 | .CompareDriveNumberToDriveCount: |
---|
263 | cmp dl, cl |
---|
264 | ret |
---|