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

Last change on this file since 161 was 161, checked in by krille_n_@…, 14 years ago

Changes to XTIDE Universal BIOS:

  • Minor size optimizations.
  • Tried to minimize the time spent with interrupts disabled in IdeIrq.asm and Int13h.asm
File size: 14.2 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
[161]58 ; Fall 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
[161]171 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[135]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)
[161]189 push bp
190 mov bp, sp
[88]191 jz SHORT .PrintXTFloppyType
[3]192 cmp bl, FLOPPY_TYPE_35_ED
[88]193 ja SHORT .PrintUnknownFloppyType
[161]194 ; Fall to .PrintKnownFloppyType
[3]195
[161]196
[3]197;--------------------------------------------------------------------
[161]198; .PrintKnownFloppyType
[3]199; Parameters:
[161]200; BX: Floppy drive type
[3]201; Returns:
[88]202; CF: Set since menu event was handled successfully
[3]203; Corrupts registers:
[161]204; AX, BX, SI, DI
[3]205;--------------------------------------------------------------------
206ALIGN JUMP_ALIGN
[161]207.PrintKnownFloppyType:
208 mov si, g_szFddSize
209 ePUSH_T ax, g_szCapacity
210 dec bx ; Cannot be 0 (FLOPPY_TYPE_525_OR_35_DD)
211 shl bx, 1 ; Shift for WORD lookup
212 mov ax, [cs:bx+FloppyTypes.rgwPhysicalSize]
213 push ax ; '5' or '3'
214 mov al, ah
215 push ax ; '1/4' or '1/2'
216 push WORD [cs:bx+FloppyTypes.rgwCapacity]
217 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]218
[161]219
[3]220;--------------------------------------------------------------------
[161]221; .PrintXTFloppyType
[88]222; .PrintUnknownFloppyType
[3]223; Parameters:
224; Nothing
225; Returns:
[88]226; CF: Set since menu event was handled successfully
[3]227; Corrupts registers:
[88]228; AX, SI, DI
[3]229;--------------------------------------------------------------------
230ALIGN JUMP_ALIGN
[161]231.PrintXTFloppyType:
232 mov si, g_szFddSizeOr
233 jmp SHORT .FormatXTorUnknownTypeFloppyDrive
234ALIGN JUMP_ALIGN
[88]235.PrintUnknownFloppyType:
[3]236 mov si, g_szFddUnknown
[88]237.FormatXTorUnknownTypeFloppyDrive:
[3]238 ePUSH_T ax, g_szCapacity
[88]239 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
240
[3]241
242;--------------------------------------------------------------------
243; Prints Hard Disk Menuitem information strings.
244;
245; BootMenuPrint_HardDiskMenuitemInformation
246; Parameters:
247; DL: Untranslated Hard Disk number
248; DS: RAMVARS segment
249; Returns:
[88]250; CF: Set since menu event was handled successfully
[3]251; Corrupts registers:
252; BX, CX, DX, SI, DI, ES
253;--------------------------------------------------------------------
254ALIGN JUMP_ALIGN
255BootMenuPrint_HardDiskMenuitemInformation:
[150]256 call RamVars_IsDriveHandledByThisBIOS
257 jnc SHORT .HardDiskMenuitemInfoForForeignDrive
[3]258 call FindDPT_ForDriveNumber ; DS:DI to point DPT
[127]259 ; Fall to .HardDiskMenuitemInfoForOurDrive
[3]260
261;--------------------------------------------------------------------
[127]262; .HardDiskMenuitemInfoForOurDrive
[3]263; Parameters:
264; DL: Untranslated Hard Disk number
[127]265; DS:DI: Ptr to DPT
[3]266; Returns:
[127]267; Nothing
[3]268; Corrupts registers:
[127]269; AX, BX, CX, DX, SI, DI, ES
[3]270;--------------------------------------------------------------------
271ALIGN JUMP_ALIGN
[127]272.HardDiskMenuitemInfoForOurDrive:
273 push di
274 ePUSH_T ax, BootMenuPrintCfg_ForOurDrive ; Return from BootMenuPrint_FormatCSSIfromParamsInSSBP
[88]275 push bp
276 mov bp, sp
277 ePUSH_T ax, g_szCapacity
278
[127]279 ; Get and push L-CHS size
[155]280 mov [RAMVARS.bTimeoutTicksLeft], dl ; Store drive number
[150]281 call AH15h_GetSectorCountToDXAX
[88]282 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
283
[127]284 ; Get and push total LBA size
[155]285 mov dl, [RAMVARS.bTimeoutTicksLeft] ; Restore drive number
[127]286 call BootInfo_GetTotalSectorCount
287 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
288
289 mov si, g_szSizeDual
[88]290 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]291
[127]292
[3]293;--------------------------------------------------------------------
[127]294; .HardDiskMenuitemInfoForForeignDrive
[3]295; Parameters:
296; DL: Untranslated Hard Disk number
[127]297; DS: RAMVARS segment
[3]298; Returns:
[127]299; CF: Set since menu event was handled successfully
[3]300; Corrupts registers:
[127]301; AX, BX, CX, DX, SI, DI
[3]302;--------------------------------------------------------------------
303ALIGN JUMP_ALIGN
[127]304.HardDiskMenuitemInfoForForeignDrive:
[88]305 push bp
306 mov bp, sp
307 ePUSH_T ax, g_szCapacity
[3]308
[127]309 call DriveXlate_ToOrBack
[150]310 call AH15h_GetSectorCountFromForeignDriveToDXAX
[88]311 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
312
[127]313 mov si, g_szSizeSingle
[88]314 ; Fall to BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]315
316
317;--------------------------------------------------------------------
[88]318; BootMenuPrint_FormatCSSIfromParamsInSSBP
319; Parameters:
320; CS:SI: Ptr to string to format
[120]321; BP: SP before pushing parameters
[88]322; Returns:
323; BP: Popped from stack
324; Corrupts registers:
[120]325; AX, DI
[88]326;--------------------------------------------------------------------
327ALIGN JUMP_ALIGN
328BootMenuPrint_FormatCSSIfromParamsInSSBP:
329 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
330 stc ; Successfull return from menu event
331 pop bp
332 ret
333
334
335;--------------------------------------------------------------------
336; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
337; Parameters:
338; BX:DX:AX: Sector count
339; Returns:
340; Size in stack
341; Corrupts registers:
342; AX, BX, CX, DX, SI
343;--------------------------------------------------------------------
344ALIGN JUMP_ALIGN
345ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
346 pop si ; Pop return address
347 call Size_ConvertSectorCountInBXDXAXtoKiB
348 mov cx, BYTE_MULTIPLES.kiB
349 call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
350 push ax ; Size in magnitude
351 push cx ; Tenths
352 push dx ; Magnitude character
353 jmp si
354
355
356;--------------------------------------------------------------------
357; BootMenuPrint_ClearInformationArea
358; Parameters:
359; Nothing
360; Returns:
361; CF: Set
362; Corrupts registers:
363; AX, DI
364;--------------------------------------------------------------------
365ALIGN JUMP_ALIGN
366BootMenuPrint_ClearInformationArea:
367 CALL_MENU_LIBRARY ClearInformationArea
368 stc
369 ret
370
371
372;--------------------------------------------------------------------
373; BootMenuPrint_TheBottomOfScreen
[3]374; Parameters:
375; DS: RAMVARS segment
376; Returns:
[88]377; Nothing
[3]378; Corrupts registers:
[92]379; AX, BX, CX, DX, SI, DI
[3]380;--------------------------------------------------------------------
381ALIGN JUMP_ALIGN
[88]382BootMenuPrint_TheBottomOfScreen:
[124]383 call FloppyDrive_GetCountToCX
[88]384 mov bl, cl ; Floppy Drive count to BL
385 call RamVars_GetHardDiskCountFromBDAtoCX
386 mov bh, cl ; Hard Disk count to BH
[92]387 ; Fall to .MoveCursorToHotkeyStrings
[3]388
[92]389;--------------------------------------------------------------------
390; .MoveCursorToHotkeyStrings
391; Parameters:
392; Nothing
393; Returns:
394; Nothing
395; Corrupts registers:
396; AX, DI
397;--------------------------------------------------------------------
398.MoveCursorToHotkeyStrings:
399 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
400 xor al, al
401 dec ah
402 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
403 ; Fall to .PrintHotkeyString
[3]404
405;--------------------------------------------------------------------
[92]406; .PrintHotkeyString
[3]407; Parameters:
[92]408; BL: Floppy Drives
409; BH: Hard Drives
[88]410; Returns:
[92]411; Nothing
[88]412; Corrupts registers:
[120]413; AX, CX, DX, SI, DI
[88]414;--------------------------------------------------------------------
[92]415.PrintHotkeyString:
416 ; Display Library should not be called like this
417 mov si, ATTRIBUTE_CHARS.cHighlightedItem
418 call MenuAttribute_GetToAXfromTypeInSI
419 xchg dx, ax
[122]420 mov cx, MONO_BRIGHT
[88]421
[92]422 test bl, bl ; Any Floppy Drives?
423 jz SHORT .SkipFloppyDriveHotkeys
424 mov ax, 'A' | (ANGLE_QUOTE_RIGHT<<8)
425 mov si, g_szFDD
426 call PushHotkeyParamsAndFormat
[88]427
[92]428.SkipFloppyDriveHotkeys:
429 test bh, bh ; Any Hard Drives?
430 jz SHORT .SkipHardDriveHotkeys
[122]431 xchg ax, cx ; Store Key Attribute
[92]432 call BootMenu_GetLetterForFirstHardDiskToCL
433 mov ch, ANGLE_QUOTE_RIGHT
434 xchg ax, cx
435 mov si, g_szHDD
436 call PushHotkeyParamsAndFormat
437
438.SkipHardDriveHotkeys:
439 ; Fall to .PrintRomBootHotkey
440
[88]441;--------------------------------------------------------------------
[92]442; .PrintRomBootHotkey
[88]443; Parameters:
[92]444; CX: Key Attribute
445; DX: Description Attribute
[3]446; Returns:
[88]447; Nothing
[3]448; Corrupts registers:
[120]449; AX, SI, DI
[3]450;--------------------------------------------------------------------
[92]451.PrintRomBootHotkey:
452 mov ax, 'F' | ('8'<<8) ; F8
453 mov si, g_szRomBoot
454 ; Fall to PushHotkeyParamsAndFormat
455
456;--------------------------------------------------------------------
457; PushHotkeyParamsAndFormat
458; Parameters:
459; AL: First character
460; AH: Second character
461; CX: Key Attribute
462; DX: Description Attribute
463; CS:SI: Description string
464; Returns:
465; Nothing
466; Corrupts registers:
[120]467; AX, SI, DI
[92]468;--------------------------------------------------------------------
[3]469ALIGN JUMP_ALIGN
[92]470PushHotkeyParamsAndFormat:
471 push bp
472 mov bp, sp
473
474 push cx ; Key attribute
475 push ax ; First character
476 xchg al, ah
477 push ax ; Second character
478 push dx ; Description attribute
479 push si ; Description string
480 push cx ; Key attribute for last space
481 mov si, g_szHotkey
[161]482 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
483
484ALIGN WORD_ALIGN
485FloppyTypes:
486.rgwCapacity:
487 dw 360
488 dw 1200
489 dw 720
490 dw 1440
491 dw 2880
492 dw 2880
493.rgwPhysicalSize:
494 db '5', 172 ; 1, FLOPPY_TYPE_525_DD
495 db '5', 172 ; 2, FLOPPY_TYPE_525_HD
496 db '3', 171 ; 3, FLOPPY_TYPE_35_DD
497 db '3', 171 ; 4, FLOPPY_TYPE_35_HD
498 db '3', 171 ; 5, 3.5" ED on some BIOSes
499 db '3', 171 ; 6, FLOPPY_TYPE_35_ED
Note: See TracBrowser for help on using the repository browser.