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

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

Optimized away some long jumps, by rearranging routines within files, and file order within main.asm. Also added some 'relay' entry points for popular destinations, so that a short jump can go to an existing short jump and then on to the final destination, instead of using a long jump - clearly space over speed optimization. All 'relay's are limited to the UI code, and will not have an impact on IDE operational performance.

File size: 15.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
[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:
[192]24 js short BootMenuPrint_FloppyMenuitemInformation
[189]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
[192]32 jmp short BootMenuPrint_FormatCSSIfromParamsInSSBP
[189]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
[192]37
[189]38
39;--------------------------------------------------------------------
[192]40; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
[130]41; Parameters:
[192]42; BX:DX:AX: Sector count
[130]43; Returns:
[192]44; Size in stack
[130]45; Corrupts registers:
[192]46; AX, BX, CX, DX, SI
[130]47;--------------------------------------------------------------------
48ALIGN JUMP_ALIGN
[192]49ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
50 pop si ; Pop return address
51 call Size_ConvertSectorCountInBXDXAXtoKiB
52 mov cx, BYTE_MULTIPLES.kiB
53 call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
54 push ax ; Size in magnitude
55 push cx ; Tenths
56 push dx ; Magnitude character
57 jmp si
[130]58
59
60;--------------------------------------------------------------------
[88]61; Prints Boot Menu title strings.
[3]62;
[88]63; BootMenuPrint_TitleStrings
[3]64; Parameters:
[88]65; Nothing
[3]66; Returns:
[88]67; CF: Set since menu event handled
[3]68; Corrupts registers:
[88]69; AX, SI, DI
[3]70;--------------------------------------------------------------------
71ALIGN JUMP_ALIGN
[88]72BootMenuPrint_TitleStrings:
73 mov si, ROMVARS.szTitle
[96]74 call BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
75 CALL_DISPLAY_LIBRARY PrintNewlineCharacters
[88]76 mov si, ROMVARS.szVersion
[161]77 ; Fall to BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
[3]78
79
80;--------------------------------------------------------------------
[128]81; BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
82; Parameters:
83; CS:SI: Ptr to NULL terminated string to print
84; Returns:
85; CF: Set since menu event was handled successfully
86; Corrupts registers:
[186]87; AX, DI
[128]88;--------------------------------------------------------------------
89ALIGN JUMP_ALIGN
90BootMenuPrint_NullTerminatedStringFromCSSIandSetCF:
[186]91;
92; We send all CSSI strings through the Format routine for the case of
93; compressed strings, but this doesn't hurt in the non-compressed case either
94; (perhaps a little slower, but shouldn't be noticeable to the user)
95; and results in smaller code size.
96;
97 push bp
98 mov bp,sp
[192]99 jmp short BootMenuPrint_FormatCSSIfromParamsInSSBP
[128]100
[192]101
[128]102;--------------------------------------------------------------------
[3]103; BootMenuPrint_HardDiskMenuitem
104; Parameters:
105; DL: Untranslated Hard Disk number
106; DS: RAMVARS segment
[190]107; SF: set for Information, clear for Item
[3]108; Returns:
[88]109; CF: Set since menu event handled
[3]110; Corrupts registers:
[88]111; AX, BX, SI, DI
[3]112;--------------------------------------------------------------------
113ALIGN JUMP_ALIGN
114BootMenuPrint_HardDiskMenuitem:
[192]115 js short BootMenuPrint_HardDiskMenuitemInformation
[135]116 call PrintDriveNumberAfterTranslationFromDL
[150]117 call RamVars_IsDriveHandledByThisBIOS
[88]118 jnc SHORT .HardDiskMenuitemForForeignDrive
119 ; Fall to .HardDiskMenuitemForOurDrive
[3]120
121;--------------------------------------------------------------------
[88]122; .HardDiskMenuitemForOurDrive
[3]123; Parameters:
124; DL: Untranslated Hard Disk number
125; DS: RAMVARS segment
126; Returns:
[88]127; CF: Set since menu event handled
[3]128; Corrupts registers:
[88]129; AX, BX, SI, DI
[3]130;--------------------------------------------------------------------
[88]131.HardDiskMenuitemForOurDrive:
132 call BootInfo_GetOffsetToBX
133 lea si, [bx+BOOTNFO.szDrvName]
134 xor bx, bx ; BDA segment
135 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
136 stc
137 ret
[3]138
139;--------------------------------------------------------------------
[88]140; BootMenuPrint_HardDiskMenuitemForForeignDrive
[3]141; Parameters:
142; DL: Untranslated Hard Disk number
143; DS: RAMVARS segment
144; Returns:
[88]145; CF: Set since menu event handled
[3]146; Corrupts registers:
[88]147; AX, SI, DI
[3]148;--------------------------------------------------------------------
149ALIGN JUMP_ALIGN
[88]150.HardDiskMenuitemForForeignDrive:
151 mov si, g_szforeignHD
[128]152 jmp SHORT BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
[3]153
154
155;--------------------------------------------------------------------
156; BootMenuPrint_FloppyMenuitemInformation
157; Parameters:
158; DL: Untranslated Floppy Drive number
159; DS: RAMVARS segment
160; Returns:
[88]161; CF: Set since menu event was handled successfully
[3]162; Corrupts registers:
[88]163; AX, BX, CX, DX, SI, DI, ES
[3]164;--------------------------------------------------------------------
[192]165
166FloppyTypes:
167.rgbCapacityMultiplier equ 20 ; Multiplier to reduce word sized values to byte size
168.rgbCapacity:
169 db 360 / FloppyTypes.rgbCapacityMultiplier ; type 1
170 db 1200 / FloppyTypes.rgbCapacityMultiplier ; type 2
171 db 720 / FloppyTypes.rgbCapacityMultiplier ; type 3
172 db 1440 / FloppyTypes.rgbCapacityMultiplier ; type 4
173 db 2880 / FloppyTypes.rgbCapacityMultiplier ; type 5
174 db 2880 / FloppyTypes.rgbCapacityMultiplier ; type 6
175
176%if g_szFddFiveQuarter <> g_szFddThreeHalf+g_szFddThreeFive_Displacement
177%error "FddThreeFive_Displacement incorrect"
178%endif
179
[3]180ALIGN JUMP_ALIGN
181BootMenuPrint_FloppyMenuitemInformation:
[88]182 call BootMenuPrint_ClearInformationArea
183 call FloppyDrive_GetType ; Get Floppy Drive type to BX
[182]184
[161]185 push bp
186 mov bp, sp
[182]187 ePUSH_T ax, g_szCapacity
188
189 mov si, g_szFddSizeOr ; .PrintXTFloppyType
190 test bx, bx ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)
191 jz SHORT .output
192
193 mov si, g_szFddUnknown ; .PrintUnknownFloppyType
[3]194 cmp bl, FLOPPY_TYPE_35_ED
[182]195 ja SHORT .output
196
[161]197 ; Fall to .PrintKnownFloppyType
[3]198
[161]199
[3]200;--------------------------------------------------------------------
[161]201; .PrintKnownFloppyType
[3]202; Parameters:
[161]203; BX: Floppy drive type
[3]204; Returns:
[88]205; CF: Set since menu event was handled successfully
[3]206; Corrupts registers:
[161]207; AX, BX, SI, DI
[182]208;
209; Floppy Drive Types:
210;
211; 0 Handled above
212; 1 FLOPPY_TYPE_525_DD 5 1/4 360K
213; 2 FLOPPY_TYPE_525_HD 5 1/4 1.2M
214; 3 FLOPPY_TYPE_35_DD 3 1/2 720K
215; 4 FLOPPY_TYPE_35_HD 3 1/2 1.44M
216; 5 3.5" ED on some BIOSes 3 1/2 2.88M
217; 6 FLOPPY_TYPE_35_ED 3 1/2 2.88M
218; >6 Unknwon, handled above
219;
[3]220;--------------------------------------------------------------------
[161]221.PrintKnownFloppyType:
222 mov si, g_szFddSize
[182]223
224 mov ax, g_szFddThreeHalf
225 cmp bl, FLOPPY_TYPE_525_HD
226 ja .ThreeHalf
[186]227%if g_szFddThreeFive_Displacement = 2
228 inc ax ; compressed string case
229 inc ax
230%else
[182]231 add ax, g_szFddThreeFive_Displacement
[186]232%endif
[182]233.ThreeHalf:
234 push ax ; "5 1/4" or "3 1/2"
[3]235
[182]236 mov al,FloppyTypes.rgbCapacityMultiplier
237 mul byte [cs:bx+FloppyTypes.rgbCapacity - 1] ; -1 since 0 is handled above and not in the table
238 push ax
[161]239
[182]240ALIGN JUMP_ALIGN
[192]241.output:
242;;; fall-through
[88]243
[3]244;--------------------------------------------------------------------
[192]245; BootMenuPrint_FormatCSSIfromParamsInSSBP
246; Parameters:
247; CS:SI: Ptr to string to format
248; BP: SP before pushing parameters
249; Returns:
250; BP: Popped from stack
251; Corrupts registers:
252; AX, DI
253;--------------------------------------------------------------------
254ALIGN JUMP_ALIGN
255BootMenuPrint_FormatCSSIfromParamsInSSBP:
256 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
257 stc ; Successfull return from menu event
258 pop bp
259 ret
260
261
262;--------------------------------------------------------------------
[3]263; Prints Hard Disk Menuitem information strings.
264;
265; BootMenuPrint_HardDiskMenuitemInformation
266; Parameters:
267; DL: Untranslated Hard Disk number
268; DS: RAMVARS segment
269; Returns:
[88]270; CF: Set since menu event was handled successfully
[3]271; Corrupts registers:
272; BX, CX, DX, SI, DI, ES
273;--------------------------------------------------------------------
274ALIGN JUMP_ALIGN
275BootMenuPrint_HardDiskMenuitemInformation:
[150]276 call RamVars_IsDriveHandledByThisBIOS
277 jnc SHORT .HardDiskMenuitemInfoForForeignDrive
[3]278 call FindDPT_ForDriveNumber ; DS:DI to point DPT
[127]279 ; Fall to .HardDiskMenuitemInfoForOurDrive
[3]280
281;--------------------------------------------------------------------
[127]282; .HardDiskMenuitemInfoForOurDrive
[3]283; Parameters:
284; DL: Untranslated Hard Disk number
[127]285; DS:DI: Ptr to DPT
[3]286; Returns:
[127]287; Nothing
[3]288; Corrupts registers:
[127]289; AX, BX, CX, DX, SI, DI, ES
[3]290;--------------------------------------------------------------------
[127]291.HardDiskMenuitemInfoForOurDrive:
292 push di
293 ePUSH_T ax, BootMenuPrintCfg_ForOurDrive ; Return from BootMenuPrint_FormatCSSIfromParamsInSSBP
[88]294 push bp
295 mov bp, sp
296 ePUSH_T ax, g_szCapacity
297
[127]298 ; Get and push L-CHS size
[155]299 mov [RAMVARS.bTimeoutTicksLeft], dl ; Store drive number
[150]300 call AH15h_GetSectorCountToDXAX
[88]301 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
302
[127]303 ; Get and push total LBA size
[155]304 mov dl, [RAMVARS.bTimeoutTicksLeft] ; Restore drive number
[127]305 call BootInfo_GetTotalSectorCount
306 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
307
308 mov si, g_szSizeDual
[88]309 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]310
[127]311
[3]312;--------------------------------------------------------------------
[127]313; .HardDiskMenuitemInfoForForeignDrive
[3]314; Parameters:
315; DL: Untranslated Hard Disk number
[127]316; DS: RAMVARS segment
[3]317; Returns:
[127]318; CF: Set since menu event was handled successfully
[3]319; Corrupts registers:
[127]320; AX, BX, CX, DX, SI, DI
[3]321;--------------------------------------------------------------------
322ALIGN JUMP_ALIGN
[127]323.HardDiskMenuitemInfoForForeignDrive:
[88]324 push bp
325 mov bp, sp
326 ePUSH_T ax, g_szCapacity
[3]327
[127]328 call DriveXlate_ToOrBack
[150]329 call AH15h_GetSectorCountFromForeignDriveToDXAX
[88]330 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
331
[127]332 mov si, g_szSizeSingle
[192]333 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]334
[192]335
[3]336;--------------------------------------------------------------------
[192]337; BootMenuPrint_ClearInformationArea
[88]338; Parameters:
[192]339; Nothing
[88]340; Returns:
[192]341; CF: Set
[88]342; Corrupts registers:
[120]343; AX, DI
[88]344;--------------------------------------------------------------------
345ALIGN JUMP_ALIGN
[192]346BootMenuPrint_ClearInformationArea:
347 CALL_MENU_LIBRARY ClearInformationArea
348 stc
[88]349 ret
350
[192]351
[88]352;--------------------------------------------------------------------
[192]353; BootMenuPrint_ClearScreen
[88]354; Parameters:
[192]355; Nothing
[88]356; Returns:
[192]357; Nothing
[88]358; Corrupts registers:
[192]359; AX, DI
[88]360;--------------------------------------------------------------------
361ALIGN JUMP_ALIGN
[192]362BootMenuPrint_ClearScreen:
363 call BootMenuPrint_InitializeDisplayContext
364 xor ax, ax
365 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
366 mov ax, ' ' | (MONO_NORMAL<<8)
367 CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
368 ret
[88]369
[192]370
[88]371;--------------------------------------------------------------------
[192]372; PrintDriveNumberAfterTranslationFromDL
[88]373; Parameters:
[192]374; DL: Untranslated Floppy Drive number
375; DS: RAMVARS segment
376; Returns:
[88]377; Nothing
378; Corrupts registers:
379; AX, DI
380;--------------------------------------------------------------------
381ALIGN JUMP_ALIGN
[192]382PrintDriveNumberAfterTranslationFromDL:
383 mov ax, dx
384 call DriveXlate_ToOrBack
385 xchg dx, ax ; Restore DX, WORD to print in AL
386 xor ah, ah
387 push bp
388 mov bp, sp
389 mov si, g_szDriveNum
390 push ax
391
392BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay:
393 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[88]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
[192]506 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay
[161]507
[182]508
[192]509;--------------------------------------------------------------------
510; BootMenuPrint_InitializeDisplayContext
511; Parameters:
512; Nothing
513; Returns:
514; Nothing
515; Corrupts registers:
516; AX, DI
517;--------------------------------------------------------------------
518ALIGN JUMP_ALIGN
519BootMenuPrint_InitializeDisplayContext:
520 CALL_DISPLAY_LIBRARY InitializeDisplayContext
521 ret
522
523
524
525
526
527
Note: See TracBrowser for help on using the repository browser.