source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm@ 152

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

Changes to XTIDE Universal BIOS:

  • Redesigned Disk Parameter Tables.
  • Code generalizations for supporting non-IDE devices in the future.
File size: 14.4 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for printing boot menu strings.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; BootMenuPrint_ClearScreen
9; Parameters:
10; Nothing
11; Returns:
12; Nothing
13; Corrupts registers:
14; AX, DI
15;--------------------------------------------------------------------
16ALIGN JUMP_ALIGN
17BootMenuPrint_ClearScreen:
18 call BootMenuPrint_InitializeDisplayContext
19 xor ax, ax
20 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
21 mov ax, ' ' | (MONO_NORMAL<<8)
22 CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
23 ret
24
25
26;--------------------------------------------------------------------
27; BootMenuPrint_InitializeDisplayContext
28; Parameters:
29; Nothing
30; Returns:
31; Nothing
32; Corrupts registers:
33; AX, DI
34;--------------------------------------------------------------------
35ALIGN JUMP_ALIGN
36BootMenuPrint_InitializeDisplayContext:
37 CALL_DISPLAY_LIBRARY InitializeDisplayContext
38 ret
39
40
41;--------------------------------------------------------------------
42; Prints Boot Menu title strings.
43;
44; BootMenuPrint_TitleStrings
45; Parameters:
46; Nothing
47; Returns:
48; CF: Set since menu event handled
49; Corrupts registers:
50; AX, SI, DI
51;--------------------------------------------------------------------
52ALIGN JUMP_ALIGN
53BootMenuPrint_TitleStrings:
54 mov si, ROMVARS.szTitle
55 call BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
56 CALL_DISPLAY_LIBRARY PrintNewlineCharacters
57 mov si, ROMVARS.szVersion
58 ; Fall through to BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
59
60
61;--------------------------------------------------------------------
62; BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
63; Parameters:
64; CS:SI: Ptr to NULL terminated string to print
65; Returns:
66; CF: Set since menu event was handled successfully
67; Corrupts registers:
68; AX
69;--------------------------------------------------------------------
70ALIGN JUMP_ALIGN
71BootMenuPrint_NullTerminatedStringFromCSSIandSetCF:
72 push di
73 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
74 pop di
75 stc
76 ret
77
78
79;--------------------------------------------------------------------
80; BootMenuPrint_FloppyMenuitem
81; Parameters:
82; DL: Untranslated Floppy Drive number
83; Returns:
84; Nothing
85; Corrupts registers:
86; AX, DX, SI, DI
87;--------------------------------------------------------------------
88ALIGN JUMP_ALIGN
89BootMenuPrint_FloppyMenuitem:
90 call PrintDriveNumberAfterTranslationFromDL
91 push bp
92 mov bp, sp
93 mov si, g_szFDLetter
94 ePUSH_T ax, g_szFloppyDrv
95 add dl, 'A'
96 push dx ; Drive letter
97 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
98
99
100;--------------------------------------------------------------------
101; BootMenuPrint_HardDiskMenuitem
102; Parameters:
103; DL: Untranslated Hard Disk number
104; DS: RAMVARS segment
105; Returns:
106; CF: Set since menu event handled
107; Corrupts registers:
108; AX, BX, SI, DI
109;--------------------------------------------------------------------
110ALIGN JUMP_ALIGN
111BootMenuPrint_HardDiskMenuitem:
112 call PrintDriveNumberAfterTranslationFromDL
113 call RamVars_IsDriveHandledByThisBIOS
114 jnc SHORT .HardDiskMenuitemForForeignDrive
115 ; Fall to .HardDiskMenuitemForOurDrive
116
117;--------------------------------------------------------------------
118; .HardDiskMenuitemForOurDrive
119; Parameters:
120; DL: Untranslated Hard Disk number
121; DS: RAMVARS segment
122; Returns:
123; CF: Set since menu event handled
124; Corrupts registers:
125; AX, BX, SI, DI
126;--------------------------------------------------------------------
127.HardDiskMenuitemForOurDrive:
128 call BootInfo_GetOffsetToBX
129 lea si, [bx+BOOTNFO.szDrvName]
130 xor bx, bx ; BDA segment
131 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
132 stc
133 ret
134
135;--------------------------------------------------------------------
136; BootMenuPrint_HardDiskMenuitemForForeignDrive
137; Parameters:
138; DL: Untranslated Hard Disk number
139; DS: RAMVARS segment
140; Returns:
141; CF: Set since menu event handled
142; Corrupts registers:
143; AX, SI, DI
144;--------------------------------------------------------------------
145ALIGN JUMP_ALIGN
146.HardDiskMenuitemForForeignDrive:
147 mov si, g_szforeignHD
148 jmp SHORT BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
149
150
151;--------------------------------------------------------------------
152; PrintDriveNumberAfterTranslationFromDL
153; Parameters:
154; DL: Untranslated Floppy Drive number
155; DS: RAMVARS segment
156; Returns:
157; Nothing
158; Corrupts registers:
159; AX, DI
160;--------------------------------------------------------------------
161ALIGN JUMP_ALIGN
162PrintDriveNumberAfterTranslationFromDL:
163 mov ax, dx
164 call DriveXlate_ToOrBack
165 xchg dx, ax ; Restore DX, WORD to print in AL
166 xor ah, ah
167 push bp
168 mov bp, sp
169 mov si, g_szDriveNum
170 push ax
171 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
172
173
174;--------------------------------------------------------------------
175; BootMenuPrint_FloppyMenuitemInformation
176; Parameters:
177; DL: Untranslated Floppy Drive number
178; DS: RAMVARS segment
179; Returns:
180; CF: Set since menu event was handled successfully
181; Corrupts registers:
182; AX, BX, CX, DX, SI, DI, ES
183;--------------------------------------------------------------------
184ALIGN JUMP_ALIGN
185BootMenuPrint_FloppyMenuitemInformation:
186 call BootMenuPrint_ClearInformationArea
187 call FloppyDrive_GetType ; Get Floppy Drive type to BX
188 test bx, bx ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)
189 jz SHORT .PrintXTFloppyType
190 cmp bl, FLOPPY_TYPE_35_ED
191 ja SHORT .PrintUnknownFloppyType
192 jmp SHORT .PrintKnownFloppyType
193
194;--------------------------------------------------------------------
195; .PrintXTFloppyType
196; Parameters:
197; Nothing
198; Returns:
199; CF: Set since menu event was handled successfully
200; Corrupts registers:
201; AX, SI, DI
202;--------------------------------------------------------------------
203ALIGN JUMP_ALIGN
204.PrintXTFloppyType:
205 push bp
206 mov si, g_szFddSizeOr
207 jmp SHORT .FormatXTorUnknownTypeFloppyDrive
208
209;--------------------------------------------------------------------
210; .PrintUnknownFloppyType
211; Parameters:
212; Nothing
213; Returns:
214; CF: Set since menu event was handled successfully
215; Corrupts registers:
216; AX, SI, DI
217;--------------------------------------------------------------------
218ALIGN JUMP_ALIGN
219.PrintUnknownFloppyType:
220 push bp
221 mov si, g_szFddUnknown
222.FormatXTorUnknownTypeFloppyDrive:
223 mov bp, sp
224 ePUSH_T ax, g_szCapacity
225 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
226
227;--------------------------------------------------------------------
228; .PrintKnownFloppyType
229; Parameters:
230; BX: Floppy drive type
231; Returns:
232; CF: Set since menu event was handled successfully
233; Corrupts registers:
234; AX, BX, SI, DI
235;--------------------------------------------------------------------
236ALIGN JUMP_ALIGN
237.PrintKnownFloppyType:
238 push bp
239 mov bp, sp
240 mov si, g_szFddSize
241 ePUSH_T ax, g_szCapacity
242 dec bx ; Cannot be 0 (FLOPPY_TYPE_525_OR_35_DD)
243 shl bx, 1 ; Shift for WORD lookup
244 mov ax, [cs:bx+.rgwPhysicalSize]
245 push ax ; '5' or '3'
246 mov al, ah
247 push ax ; '1/4' or '1/2'
248 push WORD [cs:bx+.rgwCapacity]
249 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
250
251ALIGN WORD_ALIGN
252.rgwCapacity:
253 dw 360
254 dw 1200
255 dw 720
256 dw 1440
257 dw 2880
258 dw 2880
259.rgwPhysicalSize:
260 db '5', 172 ; 1, FLOPPY_TYPE_525_DD
261 db '5', 172 ; 2, FLOPPY_TYPE_525_HD
262 db '3', 171 ; 3, FLOPPY_TYPE_35_DD
263 db '3', 171 ; 4, FLOPPY_TYPE_35_HD
264 db '3', 171 ; 5, 3.5" ED on some BIOSes
265 db '3', 171 ; 6, FLOPPY_TYPE_35_ED
266
267
268;--------------------------------------------------------------------
269; Prints Hard Disk Menuitem information strings.
270;
271; BootMenuPrint_HardDiskMenuitemInformation
272; Parameters:
273; DL: Untranslated Hard Disk number
274; DS: RAMVARS segment
275; Returns:
276; CF: Set since menu event was handled successfully
277; Corrupts registers:
278; BX, CX, DX, SI, DI, ES
279;--------------------------------------------------------------------
280ALIGN JUMP_ALIGN
281BootMenuPrint_HardDiskMenuitemInformation:
282 call RamVars_IsDriveHandledByThisBIOS
283 jnc SHORT .HardDiskMenuitemInfoForForeignDrive
284 call FindDPT_ForDriveNumber ; DS:DI to point DPT
285 ; Fall to .HardDiskMenuitemInfoForOurDrive
286
287;--------------------------------------------------------------------
288; .HardDiskMenuitemInfoForOurDrive
289; Parameters:
290; DL: Untranslated Hard Disk number
291; DS:DI: Ptr to DPT
292; Returns:
293; Nothing
294; Corrupts registers:
295; AX, BX, CX, DX, SI, DI, ES
296;--------------------------------------------------------------------
297ALIGN JUMP_ALIGN
298.HardDiskMenuitemInfoForOurDrive:
299 push di
300 ePUSH_T ax, BootMenuPrintCfg_ForOurDrive ; Return from BootMenuPrint_FormatCSSIfromParamsInSSBP
301 push bp
302 mov bp, sp
303 ePUSH_T ax, g_szCapacity
304
305 ; Get and push L-CHS size
306 mov [RAMVARS.wTimeoutCounter], dl ; Store drive number
307 call AH15h_GetSectorCountToDXAX
308 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
309
310 ; Get and push total LBA size
311 mov dl, [RAMVARS.wTimeoutCounter] ; Restore drive number
312 call BootInfo_GetTotalSectorCount
313 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
314
315 mov si, g_szSizeDual
316 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
317
318
319;--------------------------------------------------------------------
320; .HardDiskMenuitemInfoForForeignDrive
321; Parameters:
322; DL: Untranslated Hard Disk number
323; DS: RAMVARS segment
324; Returns:
325; CF: Set since menu event was handled successfully
326; Corrupts registers:
327; AX, BX, CX, DX, SI, DI
328;--------------------------------------------------------------------
329ALIGN JUMP_ALIGN
330.HardDiskMenuitemInfoForForeignDrive:
331 push bp
332 mov bp, sp
333 ePUSH_T ax, g_szCapacity
334
335 call DriveXlate_ToOrBack
336 call AH15h_GetSectorCountFromForeignDriveToDXAX
337 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
338
339 mov si, g_szSizeSingle
340 ; Fall to BootMenuPrint_FormatCSSIfromParamsInSSBP
341
342
343;--------------------------------------------------------------------
344; BootMenuPrint_FormatCSSIfromParamsInSSBP
345; Parameters:
346; CS:SI: Ptr to string to format
347; BP: SP before pushing parameters
348; Returns:
349; BP: Popped from stack
350; Corrupts registers:
351; AX, DI
352;--------------------------------------------------------------------
353ALIGN JUMP_ALIGN
354BootMenuPrint_FormatCSSIfromParamsInSSBP:
355 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
356 stc ; Successfull return from menu event
357 pop bp
358 ret
359
360
361;--------------------------------------------------------------------
362; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
363; Parameters:
364; BX:DX:AX: Sector count
365; Returns:
366; Size in stack
367; Corrupts registers:
368; AX, BX, CX, DX, SI
369;--------------------------------------------------------------------
370ALIGN JUMP_ALIGN
371ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
372 pop si ; Pop return address
373 call Size_ConvertSectorCountInBXDXAXtoKiB
374 mov cx, BYTE_MULTIPLES.kiB
375 call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
376 push ax ; Size in magnitude
377 push cx ; Tenths
378 push dx ; Magnitude character
379 jmp si
380
381
382;--------------------------------------------------------------------
383; BootMenuPrint_ClearInformationArea
384; Parameters:
385; Nothing
386; Returns:
387; CF: Set
388; Corrupts registers:
389; AX, DI
390;--------------------------------------------------------------------
391ALIGN JUMP_ALIGN
392BootMenuPrint_ClearInformationArea:
393 CALL_MENU_LIBRARY ClearInformationArea
394 stc
395 ret
396
397
398;--------------------------------------------------------------------
399; BootMenuPrint_TheBottomOfScreen
400; Parameters:
401; DS: RAMVARS segment
402; Returns:
403; Nothing
404; Corrupts registers:
405; AX, BX, CX, DX, SI, DI
406;--------------------------------------------------------------------
407ALIGN JUMP_ALIGN
408BootMenuPrint_TheBottomOfScreen:
409 call FloppyDrive_GetCountToCX
410 mov bl, cl ; Floppy Drive count to BL
411 call RamVars_GetHardDiskCountFromBDAtoCX
412 mov bh, cl ; Hard Disk count to BH
413 ; Fall to .MoveCursorToHotkeyStrings
414
415;--------------------------------------------------------------------
416; .MoveCursorToHotkeyStrings
417; Parameters:
418; Nothing
419; Returns:
420; Nothing
421; Corrupts registers:
422; AX, DI
423;--------------------------------------------------------------------
424.MoveCursorToHotkeyStrings:
425 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
426 xor al, al
427 dec ah
428 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
429 ; Fall to .PrintHotkeyString
430
431;--------------------------------------------------------------------
432; .PrintHotkeyString
433; Parameters:
434; BL: Floppy Drives
435; BH: Hard Drives
436; Returns:
437; Nothing
438; Corrupts registers:
439; AX, CX, DX, SI, DI
440;--------------------------------------------------------------------
441.PrintHotkeyString:
442 ; Display Library should not be called like this
443 mov si, ATTRIBUTE_CHARS.cHighlightedItem
444 call MenuAttribute_GetToAXfromTypeInSI
445 xchg dx, ax
446 mov cx, MONO_BRIGHT
447
448 test bl, bl ; Any Floppy Drives?
449 jz SHORT .SkipFloppyDriveHotkeys
450 mov ax, 'A' | (ANGLE_QUOTE_RIGHT<<8)
451 mov si, g_szFDD
452 call PushHotkeyParamsAndFormat
453
454.SkipFloppyDriveHotkeys:
455 test bh, bh ; Any Hard Drives?
456 jz SHORT .SkipHardDriveHotkeys
457 xchg ax, cx ; Store Key Attribute
458 call BootMenu_GetLetterForFirstHardDiskToCL
459 mov ch, ANGLE_QUOTE_RIGHT
460 xchg ax, cx
461 mov si, g_szHDD
462 call PushHotkeyParamsAndFormat
463
464.SkipHardDriveHotkeys:
465 ; Fall to .PrintRomBootHotkey
466
467;--------------------------------------------------------------------
468; .PrintRomBootHotkey
469; Parameters:
470; CX: Key Attribute
471; DX: Description Attribute
472; Returns:
473; Nothing
474; Corrupts registers:
475; AX, SI, DI
476;--------------------------------------------------------------------
477.PrintRomBootHotkey:
478 mov ax, 'F' | ('8'<<8) ; F8
479 mov si, g_szRomBoot
480 ; Fall to PushHotkeyParamsAndFormat
481
482;--------------------------------------------------------------------
483; PushHotkeyParamsAndFormat
484; Parameters:
485; AL: First character
486; AH: Second character
487; CX: Key Attribute
488; DX: Description Attribute
489; CS:SI: Description string
490; Returns:
491; Nothing
492; Corrupts registers:
493; AX, SI, DI
494;--------------------------------------------------------------------
495ALIGN JUMP_ALIGN
496PushHotkeyParamsAndFormat:
497 push bp
498 mov bp, sp
499
500 push cx ; Key attribute
501 push ax ; First character
502 xchg al, ah
503 push ax ; Second character
504 push dx ; Description attribute
505 push si ; Description string
506 push cx ; Key attribute for last space
507 mov si, g_szHotkey
508 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
Note: See TracBrowser for help on using the repository browser.