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

Last change on this file since 168 was 162, checked in by krille_n_@…, 13 years ago

Changes to all parts of the project:

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