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

Last change on this file since 153 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
RevLine 
[88]1; Project name : XTIDE Universal BIOS
[3]2; Description : Functions for printing boot menu strings.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
[130]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;--------------------------------------------------------------------
[88]42; Prints Boot Menu title strings.
[3]43;
[88]44; BootMenuPrint_TitleStrings
[3]45; Parameters:
[88]46; Nothing
[3]47; Returns:
[88]48; CF: Set since menu event handled
[3]49; Corrupts registers:
[88]50; AX, SI, DI
[3]51;--------------------------------------------------------------------
52ALIGN JUMP_ALIGN
[88]53BootMenuPrint_TitleStrings:
54 mov si, ROMVARS.szTitle
[96]55 call BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
56 CALL_DISPLAY_LIBRARY PrintNewlineCharacters
[88]57 mov si, ROMVARS.szVersion
[128]58 ; Fall through to BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
[3]59
60
61;--------------------------------------------------------------------
[128]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;--------------------------------------------------------------------
[3]80; BootMenuPrint_FloppyMenuitem
81; Parameters:
82; DL: Untranslated Floppy Drive number
83; Returns:
[88]84; Nothing
[3]85; Corrupts registers:
[120]86; AX, DX, SI, DI
[3]87;--------------------------------------------------------------------
88ALIGN JUMP_ALIGN
89BootMenuPrint_FloppyMenuitem:
[135]90 call PrintDriveNumberAfterTranslationFromDL
[88]91 push bp
92 mov bp, sp
93 mov si, g_szFDLetter
[3]94 ePUSH_T ax, g_szFloppyDrv
[88]95 add dl, 'A'
96 push dx ; Drive letter
97 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]98
99
100;--------------------------------------------------------------------
101; BootMenuPrint_HardDiskMenuitem
102; Parameters:
103; DL: Untranslated Hard Disk number
104; DS: RAMVARS segment
105; Returns:
[88]106; CF: Set since menu event handled
[3]107; Corrupts registers:
[88]108; AX, BX, SI, DI
[3]109;--------------------------------------------------------------------
110ALIGN JUMP_ALIGN
111BootMenuPrint_HardDiskMenuitem:
[135]112 call PrintDriveNumberAfterTranslationFromDL
[150]113 call RamVars_IsDriveHandledByThisBIOS
[88]114 jnc SHORT .HardDiskMenuitemForForeignDrive
115 ; Fall to .HardDiskMenuitemForOurDrive
[3]116
117;--------------------------------------------------------------------
[88]118; .HardDiskMenuitemForOurDrive
[3]119; Parameters:
120; DL: Untranslated Hard Disk number
121; DS: RAMVARS segment
122; Returns:
[88]123; CF: Set since menu event handled
[3]124; Corrupts registers:
[88]125; AX, BX, SI, DI
[3]126;--------------------------------------------------------------------
[88]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
[3]134
135;--------------------------------------------------------------------
[88]136; BootMenuPrint_HardDiskMenuitemForForeignDrive
[3]137; Parameters:
138; DL: Untranslated Hard Disk number
139; DS: RAMVARS segment
140; Returns:
[88]141; CF: Set since menu event handled
[3]142; Corrupts registers:
[88]143; AX, SI, DI
[3]144;--------------------------------------------------------------------
145ALIGN JUMP_ALIGN
[88]146.HardDiskMenuitemForForeignDrive:
147 mov si, g_szforeignHD
[128]148 jmp SHORT BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
[3]149
150
151;--------------------------------------------------------------------
[135]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;--------------------------------------------------------------------
[3]175; BootMenuPrint_FloppyMenuitemInformation
176; Parameters:
177; DL: Untranslated Floppy Drive number
178; DS: RAMVARS segment
179; Returns:
[88]180; CF: Set since menu event was handled successfully
[3]181; Corrupts registers:
[88]182; AX, BX, CX, DX, SI, DI, ES
[3]183;--------------------------------------------------------------------
184ALIGN JUMP_ALIGN
185BootMenuPrint_FloppyMenuitemInformation:
[88]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
[3]190 cmp bl, FLOPPY_TYPE_35_ED
[88]191 ja SHORT .PrintUnknownFloppyType
192 jmp SHORT .PrintKnownFloppyType
[3]193
194;--------------------------------------------------------------------
[88]195; .PrintXTFloppyType
[3]196; Parameters:
197; Nothing
198; Returns:
[88]199; CF: Set since menu event was handled successfully
[3]200; Corrupts registers:
[88]201; AX, SI, DI
[3]202;--------------------------------------------------------------------
203ALIGN JUMP_ALIGN
[88]204.PrintXTFloppyType:
205 push bp
[3]206 mov si, g_szFddSizeOr
[88]207 jmp SHORT .FormatXTorUnknownTypeFloppyDrive
[3]208
209;--------------------------------------------------------------------
[88]210; .PrintUnknownFloppyType
[3]211; Parameters:
212; Nothing
213; Returns:
[88]214; CF: Set since menu event was handled successfully
[3]215; Corrupts registers:
[88]216; AX, SI, DI
[3]217;--------------------------------------------------------------------
218ALIGN JUMP_ALIGN
[88]219.PrintUnknownFloppyType:
220 push bp
[3]221 mov si, g_szFddUnknown
[88]222.FormatXTorUnknownTypeFloppyDrive:
223 mov bp, sp
[3]224 ePUSH_T ax, g_szCapacity
[88]225 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]226
227;--------------------------------------------------------------------
[88]228; .PrintKnownFloppyType
[3]229; Parameters:
230; BX: Floppy drive type
231; Returns:
[88]232; CF: Set since menu event was handled successfully
[3]233; Corrupts registers:
[88]234; AX, BX, SI, DI
[3]235;--------------------------------------------------------------------
236ALIGN JUMP_ALIGN
[88]237.PrintKnownFloppyType:
238 push bp
239 mov bp, sp
240 mov si, g_szFddSize
241 ePUSH_T ax, g_szCapacity
[3]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]
[88]245 push ax ; '5' or '3'
246 mov al, ah
[3]247 push ax ; '1/4' or '1/2'
[88]248 push WORD [cs:bx+.rgwCapacity]
249 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
250
[3]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:
[88]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
[3]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:
[88]276; CF: Set since menu event was handled successfully
[3]277; Corrupts registers:
278; BX, CX, DX, SI, DI, ES
279;--------------------------------------------------------------------
280ALIGN JUMP_ALIGN
281BootMenuPrint_HardDiskMenuitemInformation:
[150]282 call RamVars_IsDriveHandledByThisBIOS
283 jnc SHORT .HardDiskMenuitemInfoForForeignDrive
[3]284 call FindDPT_ForDriveNumber ; DS:DI to point DPT
[127]285 ; Fall to .HardDiskMenuitemInfoForOurDrive
[3]286
287;--------------------------------------------------------------------
[127]288; .HardDiskMenuitemInfoForOurDrive
[3]289; Parameters:
290; DL: Untranslated Hard Disk number
[127]291; DS:DI: Ptr to DPT
[3]292; Returns:
[127]293; Nothing
[3]294; Corrupts registers:
[127]295; AX, BX, CX, DX, SI, DI, ES
[3]296;--------------------------------------------------------------------
297ALIGN JUMP_ALIGN
[127]298.HardDiskMenuitemInfoForOurDrive:
299 push di
300 ePUSH_T ax, BootMenuPrintCfg_ForOurDrive ; Return from BootMenuPrint_FormatCSSIfromParamsInSSBP
[88]301 push bp
302 mov bp, sp
303 ePUSH_T ax, g_szCapacity
304
[127]305 ; Get and push L-CHS size
[150]306 mov [RAMVARS.wTimeoutCounter], dl ; Store drive number
307 call AH15h_GetSectorCountToDXAX
[88]308 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
309
[127]310 ; Get and push total LBA size
[150]311 mov dl, [RAMVARS.wTimeoutCounter] ; Restore drive number
[127]312 call BootInfo_GetTotalSectorCount
313 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
314
315 mov si, g_szSizeDual
[88]316 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]317
[127]318
[3]319;--------------------------------------------------------------------
[127]320; .HardDiskMenuitemInfoForForeignDrive
[3]321; Parameters:
322; DL: Untranslated Hard Disk number
[127]323; DS: RAMVARS segment
[3]324; Returns:
[127]325; CF: Set since menu event was handled successfully
[3]326; Corrupts registers:
[127]327; AX, BX, CX, DX, SI, DI
[3]328;--------------------------------------------------------------------
329ALIGN JUMP_ALIGN
[127]330.HardDiskMenuitemInfoForForeignDrive:
[88]331 push bp
332 mov bp, sp
333 ePUSH_T ax, g_szCapacity
[3]334
[127]335 call DriveXlate_ToOrBack
[150]336 call AH15h_GetSectorCountFromForeignDriveToDXAX
[88]337 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
338
[127]339 mov si, g_szSizeSingle
[88]340 ; Fall to BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]341
342
343;--------------------------------------------------------------------
[88]344; BootMenuPrint_FormatCSSIfromParamsInSSBP
345; Parameters:
346; CS:SI: Ptr to string to format
[120]347; BP: SP before pushing parameters
[88]348; Returns:
349; BP: Popped from stack
350; Corrupts registers:
[120]351; AX, DI
[88]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
[3]400; Parameters:
401; DS: RAMVARS segment
402; Returns:
[88]403; Nothing
[3]404; Corrupts registers:
[92]405; AX, BX, CX, DX, SI, DI
[3]406;--------------------------------------------------------------------
407ALIGN JUMP_ALIGN
[88]408BootMenuPrint_TheBottomOfScreen:
[124]409 call FloppyDrive_GetCountToCX
[88]410 mov bl, cl ; Floppy Drive count to BL
411 call RamVars_GetHardDiskCountFromBDAtoCX
412 mov bh, cl ; Hard Disk count to BH
[92]413 ; Fall to .MoveCursorToHotkeyStrings
[3]414
[92]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
[3]430
431;--------------------------------------------------------------------
[92]432; .PrintHotkeyString
[3]433; Parameters:
[92]434; BL: Floppy Drives
435; BH: Hard Drives
[88]436; Returns:
[92]437; Nothing
[88]438; Corrupts registers:
[120]439; AX, CX, DX, SI, DI
[88]440;--------------------------------------------------------------------
[92]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
[122]446 mov cx, MONO_BRIGHT
[88]447
[92]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
[88]453
[92]454.SkipFloppyDriveHotkeys:
455 test bh, bh ; Any Hard Drives?
456 jz SHORT .SkipHardDriveHotkeys
[122]457 xchg ax, cx ; Store Key Attribute
[92]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
[88]467;--------------------------------------------------------------------
[92]468; .PrintRomBootHotkey
[88]469; Parameters:
[92]470; CX: Key Attribute
471; DX: Description Attribute
[3]472; Returns:
[88]473; Nothing
[3]474; Corrupts registers:
[120]475; AX, SI, DI
[3]476;--------------------------------------------------------------------
[92]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:
[120]493; AX, SI, DI
[92]494;--------------------------------------------------------------------
[3]495ALIGN JUMP_ALIGN
[92]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.