1 | ; Project name : XTIDE Universal BIOS |
---|
2 | ; Description : Functions for printing boot menu strings. |
---|
3 | |
---|
4 | ; Section containing code |
---|
5 | SECTION .text |
---|
6 | |
---|
7 | ;-------------------------------------------------------------------- |
---|
8 | ; BootMenuPrint_RefreshItem |
---|
9 | ; |
---|
10 | ; Parameters: |
---|
11 | ; DL: Untranslated Floppy Drive number |
---|
12 | ; Returns: |
---|
13 | ; Nothing |
---|
14 | ; Corrupts registers: |
---|
15 | ; AX, BX, DX, SI, DI |
---|
16 | ;-------------------------------------------------------------------- |
---|
17 | ALIGN JUMP_ALIGN |
---|
18 | BootMenuPrint_RefreshItem: |
---|
19 | call BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS |
---|
20 | jnc BootMenuEvent_EventCompleted ; if no menu item selected, out we go |
---|
21 | |
---|
22 | push bp |
---|
23 | mov bp, sp |
---|
24 | |
---|
25 | call RamVars_IsDriveHandledByThisBIOS |
---|
26 | jnc .notOurs |
---|
27 | |
---|
28 | call FindDPT_ForDriveNumber ; if it is one of ours, print the string in bootnfo |
---|
29 | call BootMenuInfo_ConvertDPTtoBX |
---|
30 | mov si, g_szDriveNumBOOTNFO ; special g_szDriveNum that prints from BDA |
---|
31 | jmp .go |
---|
32 | |
---|
33 | .notOurs: |
---|
34 | mov si,g_szDriveNum |
---|
35 | mov bx,g_szForeignHD ; assume a hard disk for the moment |
---|
36 | |
---|
37 | test dl,80h |
---|
38 | js .go |
---|
39 | mov bl,((g_szFloppyDrv)-$$ & 0xff) ; and revisit the earlier assumption... |
---|
40 | |
---|
41 | .go: |
---|
42 | mov ax, dx ; preserve DL for the floppy drive letter addition |
---|
43 | call DriveXlate_ToOrBack |
---|
44 | push dx ; translated drive number |
---|
45 | push bx ; sub string |
---|
46 | add al, 'A' ; floppy drive letter (we always push this although |
---|
47 | push ax ; the hard disks don't ever use it, but it does no harm) |
---|
48 | |
---|
49 | jmp short BootMenuPrint_FormatCSSIfromParamsInSSBP |
---|
50 | |
---|
51 | ;-------------------------------------------------------------------- |
---|
52 | ; Prints Boot Menu title strings. |
---|
53 | ; |
---|
54 | ; BootMenuPrint_TitleStrings |
---|
55 | ; Parameters: |
---|
56 | ; Nothing |
---|
57 | ; Returns: |
---|
58 | ; CF: Set since menu event handled |
---|
59 | ; Corrupts registers: |
---|
60 | ; AX, SI, DI |
---|
61 | ;-------------------------------------------------------------------- |
---|
62 | ALIGN JUMP_ALIGN |
---|
63 | BootMenuPrint_TitleStrings: |
---|
64 | mov si, ROMVARS.szTitle |
---|
65 | call BootMenuPrint_NullTerminatedStringFromCSSIandSetCF |
---|
66 | CALL_DISPLAY_LIBRARY PrintNewlineCharacters |
---|
67 | mov si, ROMVARS.szVersion |
---|
68 | ; Fall to BootMenuPrint_NullTerminatedStringFromCSSIandSetCF |
---|
69 | |
---|
70 | ;-------------------------------------------------------------------- |
---|
71 | ; BootMenuPrint_NullTerminatedStringFromCSSIandSetCF |
---|
72 | ; Parameters: |
---|
73 | ; CS:SI: Ptr to NULL terminated string to print |
---|
74 | ; Returns: |
---|
75 | ; CF: Set since menu event was handled successfully |
---|
76 | ; Corrupts registers: |
---|
77 | ; AX, DI |
---|
78 | ;-------------------------------------------------------------------- |
---|
79 | ALIGN JUMP_ALIGN |
---|
80 | BootMenuPrint_NullTerminatedStringFromCSSIandSetCF: |
---|
81 | ; |
---|
82 | ; We send all CSSI strings through the Format routine for the case of |
---|
83 | ; compressed strings, but this doesn't hurt in the non-compressed case either |
---|
84 | ; (perhaps a little slower, but shouldn't be noticeable to the user) |
---|
85 | ; and results in smaller code size. |
---|
86 | ; |
---|
87 | push bp |
---|
88 | mov bp,sp |
---|
89 | jmp short BootMenuPrint_FormatCSSIfromParamsInSSBP |
---|
90 | |
---|
91 | |
---|
92 | ;-------------------------------------------------------------------- |
---|
93 | ; BootMenuPrint_FloppyMenuitemInformation |
---|
94 | ; Parameters: |
---|
95 | ; DL: Untranslated Floppy Drive number |
---|
96 | ; DS: RAMVARS segment |
---|
97 | ; Returns: |
---|
98 | ; CF: Set since menu event was handled successfully |
---|
99 | ; Corrupts registers: |
---|
100 | ; AX, BX, CX, DX, SI, DI, ES |
---|
101 | ;-------------------------------------------------------------------- |
---|
102 | ALIGN JUMP_ALIGN |
---|
103 | BootMenuPrint_RefreshInformation: |
---|
104 | CALL_MENU_LIBRARY ClearInformationArea |
---|
105 | |
---|
106 | call BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS |
---|
107 | jnc BootMenuEvent_EventCompleted ; if no menu selection, abort |
---|
108 | |
---|
109 | push bp |
---|
110 | mov bp, sp |
---|
111 | |
---|
112 | test dl, dl ; are we a hard disk? |
---|
113 | js BootMenuPrint_HardDiskRefreshInformation |
---|
114 | |
---|
115 | call FloppyDrive_GetType ; Get Floppy Drive type to BX |
---|
116 | |
---|
117 | mov cx, g_szFddSizeOr ; .PrintXTFloppyType |
---|
118 | test bx, bx ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD) |
---|
119 | jz SHORT BootMenuPrint_HardDiskRefreshInformation.output |
---|
120 | |
---|
121 | mov cl, (g_szFddUnknown - $$) & 0xff ; .PrintUnknownFloppyType |
---|
122 | cmp bl, FLOPPY_TYPE_35_ED |
---|
123 | ja SHORT BootMenuPrint_HardDiskRefreshInformation.output |
---|
124 | |
---|
125 | ; Fall to .PrintKnownFloppyType |
---|
126 | |
---|
127 | ;-------------------------------------------------------------------- |
---|
128 | ; .PrintKnownFloppyType |
---|
129 | ; Parameters: |
---|
130 | ; BX: Floppy drive type |
---|
131 | ; Returns: |
---|
132 | ; CF: Set since menu event was handled successfully |
---|
133 | ; Corrupts registers: |
---|
134 | ; AX, BX, SI, DI |
---|
135 | ; |
---|
136 | ; Floppy Drive Types: |
---|
137 | ; |
---|
138 | ; 0 Handled above |
---|
139 | ; 1 FLOPPY_TYPE_525_DD 5 1/4 360K |
---|
140 | ; 2 FLOPPY_TYPE_525_HD 5 1/4 1.2M |
---|
141 | ; 3 FLOPPY_TYPE_35_DD 3 1/2 720K |
---|
142 | ; 4 FLOPPY_TYPE_35_HD 3 1/2 1.44M |
---|
143 | ; 5 3.5" ED on some BIOSes 3 1/2 2.88M |
---|
144 | ; 6 FLOPPY_TYPE_35_ED 3 1/2 2.88M |
---|
145 | ; >6 Unknwon, handled above |
---|
146 | ; |
---|
147 | ;-------------------------------------------------------------------- |
---|
148 | .PrintKnownFloppyType: |
---|
149 | mov cl, (g_szFddSize - $$) & 0xff |
---|
150 | push cx |
---|
151 | |
---|
152 | mov cl, (g_szFddThreeHalf - $$) & 0xff |
---|
153 | cmp bl, FLOPPY_TYPE_525_HD |
---|
154 | ja .ThreeHalf |
---|
155 | mov cl, (g_szFddFiveQuarter - $$) & 0xff |
---|
156 | .ThreeHalf: |
---|
157 | push cx ; "5 1/4" or "3 1/2" |
---|
158 | |
---|
159 | mov al,FloppyTypes.rgbCapacityMultiplier |
---|
160 | mul byte [cs:bx+FloppyTypes.rgbCapacity - 1] ; -1 since 0 is handled above and not in the table |
---|
161 | push ax |
---|
162 | |
---|
163 | jmp short BootMenuPrint_HardDiskRefreshInformation.output |
---|
164 | |
---|
165 | |
---|
166 | ;-------------------------------------------------------------------- |
---|
167 | ; Prints Hard Disk Menuitem information strings. |
---|
168 | ; |
---|
169 | ; BootMenuPrint_HardDiskMenuitemInformation |
---|
170 | ; Parameters: |
---|
171 | ; DL: Untranslated Hard Disk number |
---|
172 | ; DS: RAMVARS segment |
---|
173 | ; Returns: |
---|
174 | ; CF: Set since menu event was handled successfully |
---|
175 | ; Corrupts registers: |
---|
176 | ; BX, CX, DX, SI, DI, ES |
---|
177 | ;-------------------------------------------------------------------- |
---|
178 | ALIGN JUMP_ALIGN |
---|
179 | BootMenuPrint_HardDiskRefreshInformation: |
---|
180 | call RamVars_IsDriveHandledByThisBIOS |
---|
181 | jnc SHORT .HardDiskMenuitemInfoForForeignDrive |
---|
182 | call FindDPT_ForDriveNumber ; DS:DI to point DPT |
---|
183 | ; Fall to .HardDiskMenuitemInfoForOurDrive |
---|
184 | |
---|
185 | ;-------------------------------------------------------------------- |
---|
186 | ; .HardDiskMenuitemInfoForOurDrive |
---|
187 | ; Parameters: |
---|
188 | ; DL: Untranslated Hard Disk number |
---|
189 | ; DS:DI: Ptr to DPT |
---|
190 | ; Returns: |
---|
191 | ; Nothing |
---|
192 | ; Corrupts registers: |
---|
193 | ; AX, BX, CX, DX, SI, DI, ES |
---|
194 | ;-------------------------------------------------------------------- |
---|
195 | .HardDiskMenuitemInfoForOurDrive: |
---|
196 | ePUSH_T ax, g_szInformation |
---|
197 | |
---|
198 | ; Get and push total LBA size |
---|
199 | call BootMenuInfo_GetTotalSectorCount |
---|
200 | call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat |
---|
201 | jmp BootMenuPrintCfg_ForOurDrive |
---|
202 | |
---|
203 | ;-------------------------------------------------------------------- |
---|
204 | ; .HardDiskMenuitemInfoForForeignDrive |
---|
205 | ; Parameters: |
---|
206 | ; DL: Untranslated Hard Disk number |
---|
207 | ; DS: RAMVARS segment |
---|
208 | ; Returns: |
---|
209 | ; CF: Set since menu event was handled successfully |
---|
210 | ; Corrupts registers: |
---|
211 | ; AX, BX, CX, DX, SI, DI |
---|
212 | ;-------------------------------------------------------------------- |
---|
213 | ALIGN JUMP_ALIGN |
---|
214 | .HardDiskMenuitemInfoForForeignDrive: |
---|
215 | call DriveXlate_ToOrBack |
---|
216 | call AH15h_GetSectorCountFromForeignDriveToDXAX |
---|
217 | call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat |
---|
218 | |
---|
219 | ALIGN JUMP_ALIGN |
---|
220 | .output: |
---|
221 | mov si, g_szCapacity |
---|
222 | ;;; fall-through |
---|
223 | |
---|
224 | ;-------------------------------------------------------------------- |
---|
225 | ; BootMenuPrint_FormatCSSIfromParamsInSSBP |
---|
226 | ; Parameters: |
---|
227 | ; CS:SI: Ptr to string to format |
---|
228 | ; BP: SP before pushing parameters |
---|
229 | ; Returns: |
---|
230 | ; BP: Popped from stack |
---|
231 | ; CF: Set since menu event was handled successfully |
---|
232 | ; Corrupts registers: |
---|
233 | ; AX, DI |
---|
234 | ;-------------------------------------------------------------------- |
---|
235 | ALIGN JUMP_ALIGN |
---|
236 | BootMenuPrint_FormatCSSIfromParamsInSSBP: |
---|
237 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI |
---|
238 | stc ; Successfull return from menu event |
---|
239 | pop bp |
---|
240 | ret |
---|
241 | |
---|
242 | |
---|
243 | ;-------------------------------------------------------------------- |
---|
244 | ; BootMenuPrint_ClearScreen |
---|
245 | ; Parameters: |
---|
246 | ; Nothing |
---|
247 | ; Returns: |
---|
248 | ; Nothing |
---|
249 | ; Corrupts registers: |
---|
250 | ; AX, DI |
---|
251 | ;-------------------------------------------------------------------- |
---|
252 | ALIGN JUMP_ALIGN |
---|
253 | BootMenuPrint_ClearScreen: |
---|
254 | call BootMenuPrint_InitializeDisplayContext |
---|
255 | xor ax, ax |
---|
256 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX |
---|
257 | mov ax, ' ' | (MONO_NORMAL<<8) |
---|
258 | CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH |
---|
259 | ret |
---|
260 | |
---|
261 | |
---|
262 | ;-------------------------------------------------------------------- |
---|
263 | ; BootMenuPrint_TheBottomOfScreen |
---|
264 | ; Parameters: |
---|
265 | ; DS: RAMVARS segment |
---|
266 | ; Returns: |
---|
267 | ; Nothing |
---|
268 | ; Corrupts registers: |
---|
269 | ; AX, BX, CX, DX, SI, DI |
---|
270 | ;-------------------------------------------------------------------- |
---|
271 | ALIGN JUMP_ALIGN |
---|
272 | BootMenuPrint_TheBottomOfScreen: |
---|
273 | call FloppyDrive_GetCountToCX |
---|
274 | mov bl, cl ; Floppy Drive count to BL |
---|
275 | call RamVars_GetHardDiskCountFromBDAtoCX |
---|
276 | mov bh, cl ; Hard Disk count to BH |
---|
277 | ; Fall to .MoveCursorToHotkeyStrings |
---|
278 | |
---|
279 | ;-------------------------------------------------------------------- |
---|
280 | ; .MoveCursorToHotkeyStrings |
---|
281 | ; Parameters: |
---|
282 | ; Nothing |
---|
283 | ; Returns: |
---|
284 | ; Nothing |
---|
285 | ; Corrupts registers: |
---|
286 | ; AX, DI |
---|
287 | ;-------------------------------------------------------------------- |
---|
288 | .MoveCursorToHotkeyStrings: |
---|
289 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH |
---|
290 | xor al, al |
---|
291 | dec ah |
---|
292 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX |
---|
293 | ; Fall to .PrintHotkeyString |
---|
294 | |
---|
295 | ;-------------------------------------------------------------------- |
---|
296 | ; .PrintHotkeyString |
---|
297 | ; Parameters: |
---|
298 | ; BL: Floppy Drives |
---|
299 | ; BH: Hard Drives |
---|
300 | ; Returns: |
---|
301 | ; Nothing |
---|
302 | ; Corrupts registers: |
---|
303 | ; AX, CX, DX, SI, DI |
---|
304 | ;-------------------------------------------------------------------- |
---|
305 | .PrintHotkeyString: |
---|
306 | ; Display Library should not be called like this |
---|
307 | mov si, ATTRIBUTE_CHARS.cHighlightedItem |
---|
308 | call MenuAttribute_GetToAXfromTypeInSI |
---|
309 | xchg dx, ax |
---|
310 | mov cx, MONO_BRIGHT |
---|
311 | |
---|
312 | test bl, bl ; Any Floppy Drives? |
---|
313 | jz SHORT .SkipFloppyDriveHotkeys |
---|
314 | mov ax, 'A' | (ANGLE_QUOTE_RIGHT<<8) |
---|
315 | mov si, g_szFDD |
---|
316 | call PushHotkeyParamsAndFormat |
---|
317 | |
---|
318 | .SkipFloppyDriveHotkeys: |
---|
319 | test bh, bh ; Any Hard Drives? |
---|
320 | jz SHORT .SkipHardDriveHotkeys |
---|
321 | xchg ax, cx ; Store Key Attribute |
---|
322 | call BootMenu_GetLetterForFirstHardDiskToCL |
---|
323 | mov ch, ANGLE_QUOTE_RIGHT |
---|
324 | xchg ax, cx |
---|
325 | mov si, g_szHDD |
---|
326 | call PushHotkeyParamsAndFormat |
---|
327 | |
---|
328 | .SkipHardDriveHotkeys: |
---|
329 | ; Fall to .PrintRomBootHotkey |
---|
330 | |
---|
331 | ;-------------------------------------------------------------------- |
---|
332 | ; .PrintRomBootHotkey |
---|
333 | ; Parameters: |
---|
334 | ; CX: Key Attribute |
---|
335 | ; DX: Description Attribute |
---|
336 | ; Returns: |
---|
337 | ; Nothing |
---|
338 | ; Corrupts registers: |
---|
339 | ; AX, SI, DI |
---|
340 | ;-------------------------------------------------------------------- |
---|
341 | .PrintRomBootHotkey: |
---|
342 | mov ax, 'F' | ('8'<<8) ; F8 |
---|
343 | mov si, g_szRomBoot |
---|
344 | ; Fall to PushHotkeyParamsAndFormat |
---|
345 | |
---|
346 | ;-------------------------------------------------------------------- |
---|
347 | ; PushHotkeyParamsAndFormat |
---|
348 | ; Parameters: |
---|
349 | ; AL: First character |
---|
350 | ; AH: Second character |
---|
351 | ; CX: Key Attribute |
---|
352 | ; DX: Description Attribute |
---|
353 | ; CS:SI: Description string |
---|
354 | ; Returns: |
---|
355 | ; Nothing |
---|
356 | ; Corrupts registers: |
---|
357 | ; AX, SI, DI |
---|
358 | ;-------------------------------------------------------------------- |
---|
359 | ALIGN JUMP_ALIGN |
---|
360 | PushHotkeyParamsAndFormat: |
---|
361 | push bp |
---|
362 | mov bp, sp |
---|
363 | |
---|
364 | push cx ; Key attribute |
---|
365 | push ax ; First character |
---|
366 | xchg al, ah |
---|
367 | push ax ; Second character |
---|
368 | push dx ; Description attribute |
---|
369 | push si ; Description string |
---|
370 | push cx ; Key attribute for last space |
---|
371 | mov si, g_szHotkey |
---|
372 | |
---|
373 | BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay: |
---|
374 | jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP |
---|
375 | |
---|
376 | |
---|
377 | ;-------------------------------------------------------------------- |
---|
378 | ; BootMenuPrint_InitializeDisplayContext |
---|
379 | ; Parameters: |
---|
380 | ; Nothing |
---|
381 | ; Returns: |
---|
382 | ; Nothing |
---|
383 | ; Corrupts registers: |
---|
384 | ; AX, DI |
---|
385 | ;-------------------------------------------------------------------- |
---|
386 | ALIGN JUMP_ALIGN |
---|
387 | BootMenuPrint_InitializeDisplayContext: |
---|
388 | CALL_DISPLAY_LIBRARY InitializeDisplayContext |
---|
389 | ret |
---|
390 | |
---|
391 | |
---|
392 | ;-------------------------------------------------------------------- |
---|
393 | ; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat |
---|
394 | ; Parameters: |
---|
395 | ; BX:DX:AX: Sector count |
---|
396 | ; Returns: |
---|
397 | ; Size in stack |
---|
398 | ; Corrupts registers: |
---|
399 | ; AX, BX, CX, DX, SI |
---|
400 | ;-------------------------------------------------------------------- |
---|
401 | ALIGN JUMP_ALIGN |
---|
402 | ConvertSectorCountInBXDXAXtoSizeAndPushForFormat: |
---|
403 | pop si ; Pop return address |
---|
404 | ePUSH_T cx, g_szCapacityNum ; Push format substring |
---|
405 | call Size_ConvertSectorCountInBXDXAXtoKiB |
---|
406 | mov cx, BYTE_MULTIPLES.kiB |
---|
407 | call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX |
---|
408 | push ax ; Size in magnitude |
---|
409 | push cx ; Tenths |
---|
410 | push dx ; Magnitude character |
---|
411 | jmp si |
---|
412 | |
---|
413 | |
---|
414 | FloppyTypes: |
---|
415 | .rgbCapacityMultiplier equ 20 ; Multiplier to reduce word sized values to byte size |
---|
416 | .rgbCapacity: |
---|
417 | db 360 / FloppyTypes.rgbCapacityMultiplier ; type 1 |
---|
418 | db 1200 / FloppyTypes.rgbCapacityMultiplier ; type 2 |
---|
419 | db 720 / FloppyTypes.rgbCapacityMultiplier ; type 3 |
---|
420 | db 1440 / FloppyTypes.rgbCapacityMultiplier ; type 4 |
---|
421 | db 2880 / FloppyTypes.rgbCapacityMultiplier ; type 5 |
---|
422 | db 2880 / FloppyTypes.rgbCapacityMultiplier ; type 6 |
---|