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

Last change on this file since 191 was 190, checked in by gregli@…, 13 years ago

More comments for changes to BootMenuEvent and BootMenuPrint.

File size: 15.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
[189]7;;;
8;;; Fall-through from BootMenuEvent.asm!
9;;; BootMenuPrint_FloppyMenuitem must be the first routine in this file
10;;; (checked at assembler time with the code after BootMenuPrint_FloppyMenuitem)
11;;;
[3]12;--------------------------------------------------------------------
[189]13; BootMenuPrint_FloppyMenuitem
14; Parameters:
15; DL: Untranslated Floppy Drive number
[190]16; SF: set for Information, clear for Item
[189]17; Returns:
18; Nothing
19; Corrupts registers:
20; AX, DX, SI, DI
21;--------------------------------------------------------------------
22ALIGN JUMP_ALIGN
23BootMenuPrint_FloppyMenuitem:
24 js BootMenuPrint_FloppyMenuitemInformation
25 call PrintDriveNumberAfterTranslationFromDL
26 push bp
27 mov bp, sp
28 mov si, g_szFDLetter
29 ePUSH_T ax, g_szFloppyDrv
30 add dl, 'A'
31 push dx ; Drive letter
32 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
33
34%if BootMenuPrint_FloppyMenuitem <> BootMenuEvent_FallThroughToFloppyMenuitem
35%error "BootMenuPrint.asm must follow BootMenuEvent.asm, and BootMenuPrint_FloppyMenuitem must be the first routine in BootMenuPrint.asm"
36%endif
37
38;--------------------------------------------------------------------
[130]39; BootMenuPrint_ClearScreen
40; Parameters:
41; Nothing
42; Returns:
43; Nothing
44; Corrupts registers:
45; AX, DI
46;--------------------------------------------------------------------
47ALIGN JUMP_ALIGN
48BootMenuPrint_ClearScreen:
49 call BootMenuPrint_InitializeDisplayContext
50 xor ax, ax
51 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
52 mov ax, ' ' | (MONO_NORMAL<<8)
53 CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
54 ret
55
56
57;--------------------------------------------------------------------
58; BootMenuPrint_InitializeDisplayContext
59; Parameters:
60; Nothing
61; Returns:
62; Nothing
63; Corrupts registers:
64; AX, DI
65;--------------------------------------------------------------------
66ALIGN JUMP_ALIGN
67BootMenuPrint_InitializeDisplayContext:
68 CALL_DISPLAY_LIBRARY InitializeDisplayContext
69 ret
70
71
72;--------------------------------------------------------------------
[88]73; Prints Boot Menu title strings.
[3]74;
[88]75; BootMenuPrint_TitleStrings
[3]76; Parameters:
[88]77; Nothing
[3]78; Returns:
[88]79; CF: Set since menu event handled
[3]80; Corrupts registers:
[88]81; AX, SI, DI
[3]82;--------------------------------------------------------------------
83ALIGN JUMP_ALIGN
[88]84BootMenuPrint_TitleStrings:
85 mov si, ROMVARS.szTitle
[96]86 call BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
87 CALL_DISPLAY_LIBRARY PrintNewlineCharacters
[88]88 mov si, ROMVARS.szVersion
[161]89 ; Fall to BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
[3]90
91
92;--------------------------------------------------------------------
[128]93; BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
94; Parameters:
95; CS:SI: Ptr to NULL terminated string to print
96; Returns:
97; CF: Set since menu event was handled successfully
98; Corrupts registers:
[186]99; AX, DI
[128]100;--------------------------------------------------------------------
101ALIGN JUMP_ALIGN
102BootMenuPrint_NullTerminatedStringFromCSSIandSetCF:
[186]103;
104; We send all CSSI strings through the Format routine for the case of
105; compressed strings, but this doesn't hurt in the non-compressed case either
106; (perhaps a little slower, but shouldn't be noticeable to the user)
107; and results in smaller code size.
108;
109 push bp
110 mov bp,sp
111 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
[128]112
113;--------------------------------------------------------------------
[3]114; BootMenuPrint_HardDiskMenuitem
115; Parameters:
116; DL: Untranslated Hard Disk number
117; DS: RAMVARS segment
[190]118; SF: set for Information, clear for Item
[3]119; Returns:
[88]120; CF: Set since menu event handled
[3]121; Corrupts registers:
[88]122; AX, BX, SI, DI
[3]123;--------------------------------------------------------------------
124ALIGN JUMP_ALIGN
125BootMenuPrint_HardDiskMenuitem:
[189]126 js BootMenuPrint_HardDiskMenuitemInformation
[135]127 call PrintDriveNumberAfterTranslationFromDL
[150]128 call RamVars_IsDriveHandledByThisBIOS
[88]129 jnc SHORT .HardDiskMenuitemForForeignDrive
130 ; Fall to .HardDiskMenuitemForOurDrive
[3]131
132;--------------------------------------------------------------------
[88]133; .HardDiskMenuitemForOurDrive
[3]134; Parameters:
135; DL: Untranslated Hard Disk number
136; DS: RAMVARS segment
137; Returns:
[88]138; CF: Set since menu event handled
[3]139; Corrupts registers:
[88]140; AX, BX, SI, DI
[3]141;--------------------------------------------------------------------
[88]142.HardDiskMenuitemForOurDrive:
143 call BootInfo_GetOffsetToBX
144 lea si, [bx+BOOTNFO.szDrvName]
145 xor bx, bx ; BDA segment
146 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
147 stc
148 ret
[3]149
150;--------------------------------------------------------------------
[88]151; BootMenuPrint_HardDiskMenuitemForForeignDrive
[3]152; Parameters:
153; DL: Untranslated Hard Disk number
154; DS: RAMVARS segment
155; Returns:
[88]156; CF: Set since menu event handled
[3]157; Corrupts registers:
[88]158; AX, SI, DI
[3]159;--------------------------------------------------------------------
160ALIGN JUMP_ALIGN
[88]161.HardDiskMenuitemForForeignDrive:
162 mov si, g_szforeignHD
[128]163 jmp SHORT BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
[3]164
165
166;--------------------------------------------------------------------
[135]167; PrintDriveNumberAfterTranslationFromDL
168; Parameters:
169; DL: Untranslated Floppy Drive number
170; DS: RAMVARS segment
171; Returns:
172; Nothing
173; Corrupts registers:
174; AX, DI
175;--------------------------------------------------------------------
176ALIGN JUMP_ALIGN
177PrintDriveNumberAfterTranslationFromDL:
178 mov ax, dx
179 call DriveXlate_ToOrBack
180 xchg dx, ax ; Restore DX, WORD to print in AL
181 xor ah, ah
182 push bp
183 mov bp, sp
184 mov si, g_szDriveNum
185 push ax
[161]186 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[135]187
188
189;--------------------------------------------------------------------
[3]190; BootMenuPrint_FloppyMenuitemInformation
191; Parameters:
192; DL: Untranslated Floppy Drive number
193; DS: RAMVARS segment
194; Returns:
[88]195; CF: Set since menu event was handled successfully
[3]196; Corrupts registers:
[88]197; AX, BX, CX, DX, SI, DI, ES
[3]198;--------------------------------------------------------------------
199ALIGN JUMP_ALIGN
200BootMenuPrint_FloppyMenuitemInformation:
[88]201 call BootMenuPrint_ClearInformationArea
202 call FloppyDrive_GetType ; Get Floppy Drive type to BX
[182]203
[161]204 push bp
205 mov bp, sp
[182]206 ePUSH_T ax, g_szCapacity
207
208 mov si, g_szFddSizeOr ; .PrintXTFloppyType
209 test bx, bx ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)
210 jz SHORT .output
211
212 mov si, g_szFddUnknown ; .PrintUnknownFloppyType
[3]213 cmp bl, FLOPPY_TYPE_35_ED
[182]214 ja SHORT .output
215
[161]216 ; Fall to .PrintKnownFloppyType
[3]217
[161]218
[3]219;--------------------------------------------------------------------
[161]220; .PrintKnownFloppyType
[3]221; Parameters:
[161]222; BX: Floppy drive type
[3]223; Returns:
[88]224; CF: Set since menu event was handled successfully
[3]225; Corrupts registers:
[161]226; AX, BX, SI, DI
[182]227;
228; Floppy Drive Types:
229;
230; 0 Handled above
231; 1 FLOPPY_TYPE_525_DD 5 1/4 360K
232; 2 FLOPPY_TYPE_525_HD 5 1/4 1.2M
233; 3 FLOPPY_TYPE_35_DD 3 1/2 720K
234; 4 FLOPPY_TYPE_35_HD 3 1/2 1.44M
235; 5 3.5" ED on some BIOSes 3 1/2 2.88M
236; 6 FLOPPY_TYPE_35_ED 3 1/2 2.88M
237; >6 Unknwon, handled above
238;
[3]239;--------------------------------------------------------------------
[161]240.PrintKnownFloppyType:
241 mov si, g_szFddSize
[182]242
243 mov ax, g_szFddThreeHalf
244 cmp bl, FLOPPY_TYPE_525_HD
245 ja .ThreeHalf
[186]246%if g_szFddThreeFive_Displacement = 2
247 inc ax ; compressed string case
248 inc ax
249%else
[182]250 add ax, g_szFddThreeFive_Displacement
[186]251%endif
[182]252.ThreeHalf:
253 push ax ; "5 1/4" or "3 1/2"
[3]254
[182]255 mov al,FloppyTypes.rgbCapacityMultiplier
256 mul byte [cs:bx+FloppyTypes.rgbCapacity - 1] ; -1 since 0 is handled above and not in the table
257 push ax
[161]258
[182]259ALIGN JUMP_ALIGN
260.output:
[88]261 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[182]262
263FloppyTypes:
264.rgbCapacityMultiplier equ 20 ; Multiplier to reduce word sized values to byte size
265.rgbCapacity:
266 db 360 / FloppyTypes.rgbCapacityMultiplier ; type 1
267 db 1200 / FloppyTypes.rgbCapacityMultiplier ; type 2
268 db 720 / FloppyTypes.rgbCapacityMultiplier ; type 3
269 db 1440 / FloppyTypes.rgbCapacityMultiplier ; type 4
270 db 2880 / FloppyTypes.rgbCapacityMultiplier ; type 5
271 db 2880 / FloppyTypes.rgbCapacityMultiplier ; type 6
[88]272
[182]273%if g_szFddFiveQuarter <> g_szFddThreeHalf+g_szFddThreeFive_Displacement
274%error "FddThreeFive_Displacement incorrect"
275%endif
276
[3]277;--------------------------------------------------------------------
278; Prints Hard Disk Menuitem information strings.
279;
280; BootMenuPrint_HardDiskMenuitemInformation
281; Parameters:
282; DL: Untranslated Hard Disk number
283; DS: RAMVARS segment
284; Returns:
[88]285; CF: Set since menu event was handled successfully
[3]286; Corrupts registers:
287; BX, CX, DX, SI, DI, ES
288;--------------------------------------------------------------------
289ALIGN JUMP_ALIGN
290BootMenuPrint_HardDiskMenuitemInformation:
[150]291 call RamVars_IsDriveHandledByThisBIOS
292 jnc SHORT .HardDiskMenuitemInfoForForeignDrive
[3]293 call FindDPT_ForDriveNumber ; DS:DI to point DPT
[127]294 ; Fall to .HardDiskMenuitemInfoForOurDrive
[3]295
296;--------------------------------------------------------------------
[127]297; .HardDiskMenuitemInfoForOurDrive
[3]298; Parameters:
299; DL: Untranslated Hard Disk number
[127]300; DS:DI: Ptr to DPT
[3]301; Returns:
[127]302; Nothing
[3]303; Corrupts registers:
[127]304; AX, BX, CX, DX, SI, DI, ES
[3]305;--------------------------------------------------------------------
[127]306.HardDiskMenuitemInfoForOurDrive:
307 push di
308 ePUSH_T ax, BootMenuPrintCfg_ForOurDrive ; Return from BootMenuPrint_FormatCSSIfromParamsInSSBP
[88]309 push bp
310 mov bp, sp
311 ePUSH_T ax, g_szCapacity
312
[127]313 ; Get and push L-CHS size
[155]314 mov [RAMVARS.bTimeoutTicksLeft], dl ; Store drive number
[150]315 call AH15h_GetSectorCountToDXAX
[88]316 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
317
[127]318 ; Get and push total LBA size
[155]319 mov dl, [RAMVARS.bTimeoutTicksLeft] ; Restore drive number
[127]320 call BootInfo_GetTotalSectorCount
321 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
322
323 mov si, g_szSizeDual
[88]324 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]325
[127]326
[3]327;--------------------------------------------------------------------
[127]328; .HardDiskMenuitemInfoForForeignDrive
[3]329; Parameters:
330; DL: Untranslated Hard Disk number
[127]331; DS: RAMVARS segment
[3]332; Returns:
[127]333; CF: Set since menu event was handled successfully
[3]334; Corrupts registers:
[127]335; AX, BX, CX, DX, SI, DI
[3]336;--------------------------------------------------------------------
337ALIGN JUMP_ALIGN
[127]338.HardDiskMenuitemInfoForForeignDrive:
[88]339 push bp
340 mov bp, sp
341 ePUSH_T ax, g_szCapacity
[3]342
[127]343 call DriveXlate_ToOrBack
[150]344 call AH15h_GetSectorCountFromForeignDriveToDXAX
[88]345 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
346
[127]347 mov si, g_szSizeSingle
[88]348 ; Fall to BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]349
350
351;--------------------------------------------------------------------
[88]352; BootMenuPrint_FormatCSSIfromParamsInSSBP
353; Parameters:
354; CS:SI: Ptr to string to format
[120]355; BP: SP before pushing parameters
[88]356; Returns:
357; BP: Popped from stack
358; Corrupts registers:
[120]359; AX, DI
[88]360;--------------------------------------------------------------------
361ALIGN JUMP_ALIGN
362BootMenuPrint_FormatCSSIfromParamsInSSBP:
363 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
364 stc ; Successfull return from menu event
365 pop bp
366 ret
367
368
369;--------------------------------------------------------------------
370; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
371; Parameters:
372; BX:DX:AX: Sector count
373; Returns:
374; Size in stack
375; Corrupts registers:
376; AX, BX, CX, DX, SI
377;--------------------------------------------------------------------
378ALIGN JUMP_ALIGN
379ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
380 pop si ; Pop return address
381 call Size_ConvertSectorCountInBXDXAXtoKiB
382 mov cx, BYTE_MULTIPLES.kiB
383 call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
384 push ax ; Size in magnitude
385 push cx ; Tenths
386 push dx ; Magnitude character
387 jmp si
388
389
390;--------------------------------------------------------------------
391; BootMenuPrint_ClearInformationArea
392; Parameters:
393; Nothing
394; Returns:
395; CF: Set
396; Corrupts registers:
397; AX, DI
398;--------------------------------------------------------------------
399ALIGN JUMP_ALIGN
400BootMenuPrint_ClearInformationArea:
401 CALL_MENU_LIBRARY ClearInformationArea
402 stc
403 ret
404
405
406;--------------------------------------------------------------------
407; BootMenuPrint_TheBottomOfScreen
[3]408; Parameters:
409; DS: RAMVARS segment
410; Returns:
[88]411; Nothing
[3]412; Corrupts registers:
[92]413; AX, BX, CX, DX, SI, DI
[3]414;--------------------------------------------------------------------
415ALIGN JUMP_ALIGN
[88]416BootMenuPrint_TheBottomOfScreen:
[124]417 call FloppyDrive_GetCountToCX
[88]418 mov bl, cl ; Floppy Drive count to BL
419 call RamVars_GetHardDiskCountFromBDAtoCX
420 mov bh, cl ; Hard Disk count to BH
[92]421 ; Fall to .MoveCursorToHotkeyStrings
[3]422
[92]423;--------------------------------------------------------------------
424; .MoveCursorToHotkeyStrings
425; Parameters:
426; Nothing
427; Returns:
428; Nothing
429; Corrupts registers:
430; AX, DI
431;--------------------------------------------------------------------
432.MoveCursorToHotkeyStrings:
433 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
434 xor al, al
435 dec ah
436 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
437 ; Fall to .PrintHotkeyString
[3]438
439;--------------------------------------------------------------------
[92]440; .PrintHotkeyString
[3]441; Parameters:
[92]442; BL: Floppy Drives
443; BH: Hard Drives
[88]444; Returns:
[92]445; Nothing
[88]446; Corrupts registers:
[120]447; AX, CX, DX, SI, DI
[88]448;--------------------------------------------------------------------
[92]449.PrintHotkeyString:
450 ; Display Library should not be called like this
451 mov si, ATTRIBUTE_CHARS.cHighlightedItem
452 call MenuAttribute_GetToAXfromTypeInSI
453 xchg dx, ax
[122]454 mov cx, MONO_BRIGHT
[88]455
[92]456 test bl, bl ; Any Floppy Drives?
457 jz SHORT .SkipFloppyDriveHotkeys
458 mov ax, 'A' | (ANGLE_QUOTE_RIGHT<<8)
459 mov si, g_szFDD
460 call PushHotkeyParamsAndFormat
[88]461
[92]462.SkipFloppyDriveHotkeys:
463 test bh, bh ; Any Hard Drives?
464 jz SHORT .SkipHardDriveHotkeys
[122]465 xchg ax, cx ; Store Key Attribute
[92]466 call BootMenu_GetLetterForFirstHardDiskToCL
467 mov ch, ANGLE_QUOTE_RIGHT
468 xchg ax, cx
469 mov si, g_szHDD
470 call PushHotkeyParamsAndFormat
471
472.SkipHardDriveHotkeys:
473 ; Fall to .PrintRomBootHotkey
474
[88]475;--------------------------------------------------------------------
[92]476; .PrintRomBootHotkey
[88]477; Parameters:
[92]478; CX: Key Attribute
479; DX: Description Attribute
[3]480; Returns:
[88]481; Nothing
[3]482; Corrupts registers:
[120]483; AX, SI, DI
[3]484;--------------------------------------------------------------------
[92]485.PrintRomBootHotkey:
486 mov ax, 'F' | ('8'<<8) ; F8
487 mov si, g_szRomBoot
488 ; Fall to PushHotkeyParamsAndFormat
489
490;--------------------------------------------------------------------
491; PushHotkeyParamsAndFormat
492; Parameters:
493; AL: First character
494; AH: Second character
495; CX: Key Attribute
496; DX: Description Attribute
497; CS:SI: Description string
498; Returns:
499; Nothing
500; Corrupts registers:
[120]501; AX, SI, DI
[92]502;--------------------------------------------------------------------
[3]503ALIGN JUMP_ALIGN
[92]504PushHotkeyParamsAndFormat:
505 push bp
506 mov bp, sp
507
508 push cx ; Key attribute
509 push ax ; First character
510 xchg al, ah
511 push ax ; Second character
512 push dx ; Description attribute
513 push si ; Description string
514 push cx ; Key attribute for last space
515 mov si, g_szHotkey
[161]516 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
517
[182]518
Note: See TracBrowser for help on using the repository browser.