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

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

Additional space optimizations, including making IdleProcessing an option in MENUEVENT. Note the fall-through from one file to another, but that there are assembler checks to ensure the proper linkage is maintained. First version of StringsCompress.pl, a perl script to make StringsCompressed.asm from Strings.asm.

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