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

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

General code size optimizations, preparing for string compression, consolidating all strings into strings.asm. Note that some changes resulted in slightly larger size now uncompressed, but will be net win when compressed.

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