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

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

Changes to XTIDE Universal BIOS:

  • Boot menu now displays drive number (untested)
  • Timeout counter implemented to boot menu (untested)
File size: 14.3 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
[3]113 call FindDPT_ForDriveNumber ; DS:DI to point DPT
[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:
282 call FindDPT_ForDriveNumber ; DS:DI to point DPT
[88]283 jnc SHORT .HardDiskMenuitemInfoForForeignDrive
[127]284 ; Fall to .HardDiskMenuitemInfoForOurDrive
[3]285
286;--------------------------------------------------------------------
[127]287; .HardDiskMenuitemInfoForOurDrive
[3]288; Parameters:
289; DL: Untranslated Hard Disk number
[127]290; DS:DI: Ptr to DPT
[3]291; Returns:
[127]292; Nothing
[3]293; Corrupts registers:
[127]294; AX, BX, CX, DX, SI, DI, ES
[3]295;--------------------------------------------------------------------
296ALIGN JUMP_ALIGN
[127]297.HardDiskMenuitemInfoForOurDrive:
298 push di
299 ePUSH_T ax, BootMenuPrintCfg_ForOurDrive ; Return from BootMenuPrint_FormatCSSIfromParamsInSSBP
[88]300 push bp
301 mov bp, sp
302 ePUSH_T ax, g_szCapacity
303
[127]304 ; Get and push L-CHS size
305 call HCapacity_GetSectorCountFromOurAH08h
[88]306 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
307
[127]308 ; Get and push total LBA size
309 mov dl, [di+DPT.bDrvNum]
310 call BootInfo_GetTotalSectorCount
311 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
312
313 mov si, g_szSizeDual
[88]314 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]315
[127]316
[3]317;--------------------------------------------------------------------
[127]318; .HardDiskMenuitemInfoForForeignDrive
[3]319; Parameters:
320; DL: Untranslated Hard Disk number
[127]321; DS: RAMVARS segment
[3]322; Returns:
[127]323; CF: Set since menu event was handled successfully
[3]324; Corrupts registers:
[127]325; AX, BX, CX, DX, SI, DI
[3]326;--------------------------------------------------------------------
327ALIGN JUMP_ALIGN
[127]328.HardDiskMenuitemInfoForForeignDrive:
[88]329 push bp
330 mov bp, sp
331 ePUSH_T ax, g_szCapacity
[3]332
[127]333 call DriveXlate_ToOrBack
334 call HCapacity_GetSectorCountFromForeignAH08h
[88]335 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
336
[127]337 mov si, g_szSizeSingle
[88]338 ; Fall to BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]339
340
341;--------------------------------------------------------------------
[88]342; BootMenuPrint_FormatCSSIfromParamsInSSBP
343; Parameters:
344; CS:SI: Ptr to string to format
[120]345; BP: SP before pushing parameters
[88]346; Returns:
347; BP: Popped from stack
348; Corrupts registers:
[120]349; AX, DI
[88]350;--------------------------------------------------------------------
351ALIGN JUMP_ALIGN
352BootMenuPrint_FormatCSSIfromParamsInSSBP:
353 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
354 stc ; Successfull return from menu event
355 pop bp
356 ret
357
358
359;--------------------------------------------------------------------
360; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
361; Parameters:
362; BX:DX:AX: Sector count
363; Returns:
364; Size in stack
365; Corrupts registers:
366; AX, BX, CX, DX, SI
367;--------------------------------------------------------------------
368ALIGN JUMP_ALIGN
369ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
370 pop si ; Pop return address
371 call Size_ConvertSectorCountInBXDXAXtoKiB
372 mov cx, BYTE_MULTIPLES.kiB
373 call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
374 push ax ; Size in magnitude
375 push cx ; Tenths
376 push dx ; Magnitude character
377 jmp si
378
379
380;--------------------------------------------------------------------
381; BootMenuPrint_ClearInformationArea
382; Parameters:
383; Nothing
384; Returns:
385; CF: Set
386; Corrupts registers:
387; AX, DI
388;--------------------------------------------------------------------
389ALIGN JUMP_ALIGN
390BootMenuPrint_ClearInformationArea:
391 CALL_MENU_LIBRARY ClearInformationArea
392 stc
393 ret
394
395
396;--------------------------------------------------------------------
397; BootMenuPrint_TheBottomOfScreen
[3]398; Parameters:
399; DS: RAMVARS segment
400; Returns:
[88]401; Nothing
[3]402; Corrupts registers:
[92]403; AX, BX, CX, DX, SI, DI
[3]404;--------------------------------------------------------------------
405ALIGN JUMP_ALIGN
[88]406BootMenuPrint_TheBottomOfScreen:
[124]407 call FloppyDrive_GetCountToCX
[88]408 mov bl, cl ; Floppy Drive count to BL
409 call RamVars_GetHardDiskCountFromBDAtoCX
410 mov bh, cl ; Hard Disk count to BH
[92]411 ; Fall to .MoveCursorToHotkeyStrings
[3]412
[92]413;--------------------------------------------------------------------
414; .MoveCursorToHotkeyStrings
415; Parameters:
416; Nothing
417; Returns:
418; Nothing
419; Corrupts registers:
420; AX, DI
421;--------------------------------------------------------------------
422.MoveCursorToHotkeyStrings:
423 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
424 xor al, al
425 dec ah
426 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
427 ; Fall to .PrintHotkeyString
[3]428
429;--------------------------------------------------------------------
[92]430; .PrintHotkeyString
[3]431; Parameters:
[92]432; BL: Floppy Drives
433; BH: Hard Drives
[88]434; Returns:
[92]435; Nothing
[88]436; Corrupts registers:
[120]437; AX, CX, DX, SI, DI
[88]438;--------------------------------------------------------------------
[92]439.PrintHotkeyString:
440 ; Display Library should not be called like this
441 mov si, ATTRIBUTE_CHARS.cHighlightedItem
442 call MenuAttribute_GetToAXfromTypeInSI
443 xchg dx, ax
[122]444 mov cx, MONO_BRIGHT
[88]445
[92]446 test bl, bl ; Any Floppy Drives?
447 jz SHORT .SkipFloppyDriveHotkeys
448 mov ax, 'A' | (ANGLE_QUOTE_RIGHT<<8)
449 mov si, g_szFDD
450 call PushHotkeyParamsAndFormat
[88]451
[92]452.SkipFloppyDriveHotkeys:
453 test bh, bh ; Any Hard Drives?
454 jz SHORT .SkipHardDriveHotkeys
[122]455 xchg ax, cx ; Store Key Attribute
[92]456 call BootMenu_GetLetterForFirstHardDiskToCL
457 mov ch, ANGLE_QUOTE_RIGHT
458 xchg ax, cx
459 mov si, g_szHDD
460 call PushHotkeyParamsAndFormat
461
462.SkipHardDriveHotkeys:
463 ; Fall to .PrintRomBootHotkey
464
[88]465;--------------------------------------------------------------------
[92]466; .PrintRomBootHotkey
[88]467; Parameters:
[92]468; CX: Key Attribute
469; DX: Description Attribute
[3]470; Returns:
[88]471; Nothing
[3]472; Corrupts registers:
[120]473; AX, SI, DI
[3]474;--------------------------------------------------------------------
[92]475.PrintRomBootHotkey:
476 mov ax, 'F' | ('8'<<8) ; F8
477 mov si, g_szRomBoot
478 ; Fall to PushHotkeyParamsAndFormat
479
480;--------------------------------------------------------------------
481; PushHotkeyParamsAndFormat
482; Parameters:
483; AL: First character
484; AH: Second character
485; CX: Key Attribute
486; DX: Description Attribute
487; CS:SI: Description string
488; Returns:
489; Nothing
490; Corrupts registers:
[120]491; AX, SI, DI
[92]492;--------------------------------------------------------------------
[3]493ALIGN JUMP_ALIGN
[92]494PushHotkeyParamsAndFormat:
495 push bp
496 mov bp, sp
497
498 push cx ; Key attribute
499 push ax ; First character
500 xchg al, ah
501 push ax ; Second character
502 push dx ; Description attribute
503 push si ; Description string
504 push cx ; Key attribute for last space
505 mov si, g_szHotkey
506 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
Note: See TracBrowser for help on using the repository browser.