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

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

Changes to XTIDE Universal BIOS:

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