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

Last change on this file since 254 was 254, checked in by aitotat@…, 12 years ago

Changes to XTIDE Universal BIOS:

  • Changed BOOTNFO to BOOTMENUINFO and moved it to BootMenu.inc.
File size: 12.8 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;--------------------------------------------------------------------
[241]8; BootMenuPrint_RefreshItem
9; 
[189]10;   Parameters:
11;       DL:     Untranslated Floppy Drive number
12;   Returns:
13;       Nothing
14;   Corrupts registers:
[241]15;       AX, BX, DX, SI, DI
[189]16;--------------------------------------------------------------------
17ALIGN JUMP_ALIGN
[241]18BootMenuPrint_RefreshItem:
19    call    BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS
20    jnc     BootMenuEvent_EventCompleted            ; if no menu item selected, out we go
21       
[189]22    push    bp
23    mov     bp, sp
24
[241]25    call    RamVars_IsDriveHandledByThisBIOS               
26    jnc     .notOurs
27
28    call    FindDPT_ForDriveNumber                  ; if it is one of ours, print the string in bootnfo
[254]29    call    BootMenuInfo_ConvertDPTtoBX
[241]30    mov     si, g_szDriveNumBOOTNFO                 ; special g_szDriveNum that prints from BDA
31    jmp     .go
[189]32       
[241]33.notOurs:
34    mov     si,g_szDriveNum                                 
35    mov     bx,g_szForeignHD                        ; assume a hard disk for the moment
36       
37    test    dl,80h                                         
38    js      .go
39    mov     bl,((g_szFloppyDrv)-$$ & 0xff)          ; and revisit the earlier assumption...
40       
41.go:
42    mov     ax, dx                                  ; preserve DL for the floppy drive letter addition
43    call    DriveXlate_ToOrBack
44    push    dx                                      ; translated drive number
45    push    bx                                      ; sub string
46    add     al, 'A'                                 ; floppy drive letter (we always push this although
47    push    ax                                      ; the hard disks don't ever use it, but it does no harm)
48       
49    jmp     short BootMenuPrint_FormatCSSIfromParamsInSSBP
[130]50
51;--------------------------------------------------------------------
[88]52; Prints Boot Menu title strings.
[3]53;
[88]54; BootMenuPrint_TitleStrings
[3]55;   Parameters:
[88]56;       Nothing
[3]57;   Returns:
[88]58;       CF:     Set since menu event handled
[3]59;   Corrupts registers:
[88]60;       AX, SI, DI
[3]61;--------------------------------------------------------------------
62ALIGN JUMP_ALIGN
[88]63BootMenuPrint_TitleStrings:
64    mov     si, ROMVARS.szTitle
[96]65    call    BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
66    CALL_DISPLAY_LIBRARY PrintNewlineCharacters
[88]67    mov     si, ROMVARS.szVersion
[161]68    ; Fall to BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
[3]69
70;--------------------------------------------------------------------
[128]71; BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
72;   Parameters:
73;       CS:SI:  Ptr to NULL terminated string to print
74;   Returns:
75;       CF:     Set since menu event was handled successfully
76;   Corrupts registers:
[186]77;       AX, DI
[128]78;--------------------------------------------------------------------
79ALIGN JUMP_ALIGN
80BootMenuPrint_NullTerminatedStringFromCSSIandSetCF:
[186]81;
82; We send all CSSI strings through the Format routine for the case of
83; compressed strings, but this doesn't hurt in the non-compressed case either
84; (perhaps a little slower, but shouldn't be noticeable to the user)
85; and results in smaller code size.
86;
87    push    bp
88    mov     bp,sp
[192]89    jmp     short BootMenuPrint_FormatCSSIfromParamsInSSBP
[128]90
[192]91       
[128]92;--------------------------------------------------------------------
[3]93; BootMenuPrint_FloppyMenuitemInformation
94;   Parameters:
95;       DL:     Untranslated Floppy Drive number
96;       DS:     RAMVARS segment
97;   Returns:
[88]98;       CF:     Set since menu event was handled successfully
[3]99;   Corrupts registers:
[88]100;       AX, BX, CX, DX, SI, DI, ES
[3]101;--------------------------------------------------------------------
[241]102ALIGN JUMP_ALIGN
103BootMenuPrint_RefreshInformation:
104    CALL_MENU_LIBRARY ClearInformationArea     
[192]105       
[241]106    call    BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS
107    jnc     BootMenuEvent_EventCompleted                ; if no menu selection, abort
[182]108
[161]109    push    bp
110    mov     bp, sp
[241]111
112    test    dl, dl                                      ; are we a hard disk?
113    js      BootMenuPrint_HardDiskRefreshInformation       
[182]114       
[241]115    call    FloppyDrive_GetType                         ; Get Floppy Drive type to BX
[182]116
[241]117    mov     cx, g_szFddSizeOr                           ; .PrintXTFloppyType
118    test    bx, bx                                      ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)     
119    jz      SHORT BootMenuPrint_HardDiskRefreshInformation.output
120
121    mov     cl, (g_szFddUnknown - $$) & 0xff            ; .PrintUnknownFloppyType
[3]122    cmp     bl, FLOPPY_TYPE_35_ED
[241]123    ja      SHORT BootMenuPrint_HardDiskRefreshInformation.output
[182]124       
[161]125    ; Fall to .PrintKnownFloppyType
[3]126
127;--------------------------------------------------------------------
[161]128; .PrintKnownFloppyType
[3]129;   Parameters:
[161]130;       BX:     Floppy drive type
[3]131;   Returns:
[88]132;       CF:     Set since menu event was handled successfully
[3]133;   Corrupts registers:
[161]134;       AX, BX, SI, DI
[182]135; 
136; Floppy Drive Types:
137;
138;   0  Handled above 
139;   1  FLOPPY_TYPE_525_DD          5 1/4   360K
140;   2  FLOPPY_TYPE_525_HD          5 1/4   1.2M
141;   3  FLOPPY_TYPE_35_DD           3 1/2   720K
142;   4  FLOPPY_TYPE_35_HD           3 1/2   1.44M
143;   5  3.5" ED on some BIOSes      3 1/2   2.88M
144;   6  FLOPPY_TYPE_35_ED           3 1/2   2.88M
145;   >6 Unknwon, handled above
146; 
[3]147;--------------------------------------------------------------------
[161]148.PrintKnownFloppyType:
[241]149    mov     cl, (g_szFddSize - $$) & 0xff
150    push    cx
[182]151       
[241]152    mov     cl, (g_szFddThreeHalf - $$) & 0xff
[182]153    cmp     bl, FLOPPY_TYPE_525_HD
154    ja      .ThreeHalf
[241]155    mov     cl, (g_szFddFiveQuarter - $$) & 0xff
[182]156.ThreeHalf:     
[241]157    push    cx                                          ; "5 1/4" or "3 1/2"
[3]158
[182]159    mov     al,FloppyTypes.rgbCapacityMultiplier
160    mul     byte [cs:bx+FloppyTypes.rgbCapacity - 1]    ; -1 since 0 is handled above and not in the table
161    push    ax
[161]162
[241]163    jmp     short BootMenuPrint_HardDiskRefreshInformation.output
[88]164
[192]165
166;--------------------------------------------------------------------
[3]167; Prints Hard Disk Menuitem information strings.
168;
169; BootMenuPrint_HardDiskMenuitemInformation
170;   Parameters:
171;       DL:     Untranslated Hard Disk number
172;       DS:     RAMVARS segment
173;   Returns:
[88]174;       CF:     Set since menu event was handled successfully
[3]175;   Corrupts registers:
176;       BX, CX, DX, SI, DI, ES
177;--------------------------------------------------------------------
178ALIGN JUMP_ALIGN
[241]179BootMenuPrint_HardDiskRefreshInformation:       
[150]180    call    RamVars_IsDriveHandledByThisBIOS
181    jnc     SHORT .HardDiskMenuitemInfoForForeignDrive
[241]182    call    FindDPT_ForDriveNumber                      ; DS:DI to point DPT
[127]183    ; Fall to .HardDiskMenuitemInfoForOurDrive
[3]184
185;--------------------------------------------------------------------
[127]186; .HardDiskMenuitemInfoForOurDrive
[3]187;   Parameters:
188;       DL:     Untranslated Hard Disk number
[127]189;       DS:DI:  Ptr to DPT
[3]190;   Returns:
[127]191;       Nothing
[3]192;   Corrupts registers:
[127]193;       AX, BX, CX, DX, SI, DI, ES
[3]194;--------------------------------------------------------------------
[127]195.HardDiskMenuitemInfoForOurDrive:
[252]196    ePUSH_T ax, g_szInformation
[88]197
[127]198    ; Get and push total LBA size
[254]199    call    BootMenuInfo_GetTotalSectorCount
[241]200    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat       
201    jmp     BootMenuPrintCfg_ForOurDrive
[252]202
[3]203;--------------------------------------------------------------------
[127]204; .HardDiskMenuitemInfoForForeignDrive
[3]205;   Parameters:
206;       DL:     Untranslated Hard Disk number
[127]207;       DS:     RAMVARS segment
[3]208;   Returns:
[127]209;       CF:     Set since menu event was handled successfully
[3]210;   Corrupts registers:
[127]211;       AX, BX, CX, DX, SI, DI
[3]212;--------------------------------------------------------------------
213ALIGN JUMP_ALIGN
[127]214.HardDiskMenuitemInfoForForeignDrive:
215    call    DriveXlate_ToOrBack
[150]216    call    AH15h_GetSectorCountFromForeignDriveToDXAX
[88]217    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
218
[241]219ALIGN JUMP_ALIGN       
220.output:
221    mov     si, g_szCapacity
222;;; fall-through
[3]223
224;--------------------------------------------------------------------
[241]225; BootMenuPrint_FormatCSSIfromParamsInSSBP
[88]226;   Parameters:
[241]227;       CS:SI:  Ptr to string to format
228;       BP:     SP before pushing parameters
[88]229;   Returns:
[241]230;       BP:     Popped from stack
231;       CF:     Set since menu event was handled successfully       
[88]232;   Corrupts registers:
[120]233;       AX, DI
[88]234;--------------------------------------------------------------------
235ALIGN JUMP_ALIGN
[241]236BootMenuPrint_FormatCSSIfromParamsInSSBP:
237    CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
238    stc             ; Successfull return from menu event
239    pop     bp
[88]240    ret
[192]241       
[241]242       
[88]243;--------------------------------------------------------------------
[192]244; BootMenuPrint_ClearScreen
[88]245;   Parameters:
[192]246;       Nothing
[88]247;   Returns:
[192]248;       Nothing
[88]249;   Corrupts registers:
[192]250;       AX, DI
[88]251;--------------------------------------------------------------------
252ALIGN JUMP_ALIGN
[192]253BootMenuPrint_ClearScreen:
254    call    BootMenuPrint_InitializeDisplayContext
255    xor     ax, ax
256    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
257    mov     ax, ' ' | (MONO_NORMAL<<8)
258    CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
259    ret
[88]260
261
262;--------------------------------------------------------------------
263; BootMenuPrint_TheBottomOfScreen
[3]264;   Parameters:
265;       DS:     RAMVARS segment
266;   Returns:
[88]267;       Nothing
[3]268;   Corrupts registers:
[92]269;       AX, BX, CX, DX, SI, DI
[3]270;--------------------------------------------------------------------
271ALIGN JUMP_ALIGN
[88]272BootMenuPrint_TheBottomOfScreen:
[124]273    call    FloppyDrive_GetCountToCX
[88]274    mov     bl, cl                  ; Floppy Drive count to BL
275    call    RamVars_GetHardDiskCountFromBDAtoCX
276    mov     bh, cl                  ; Hard Disk count to BH
[92]277    ; Fall to .MoveCursorToHotkeyStrings
[3]278
[92]279;--------------------------------------------------------------------
280; .MoveCursorToHotkeyStrings
281;   Parameters:
282;       Nothing
283;   Returns:
284;       Nothing
285;   Corrupts registers:
286;       AX, DI
287;--------------------------------------------------------------------
288.MoveCursorToHotkeyStrings:
289    CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
290    xor     al, al
291    dec     ah
292    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
293    ; Fall to .PrintHotkeyString
[3]294
295;--------------------------------------------------------------------
[92]296; .PrintHotkeyString
[3]297;   Parameters:
[92]298;       BL:     Floppy Drives
299;       BH:     Hard Drives
[88]300;   Returns:
[92]301;       Nothing
[88]302;   Corrupts registers:
[120]303;       AX, CX, DX, SI, DI
[88]304;--------------------------------------------------------------------
[92]305.PrintHotkeyString:
306    ; Display Library should not be called like this
307    mov     si, ATTRIBUTE_CHARS.cHighlightedItem
308    call    MenuAttribute_GetToAXfromTypeInSI
309    xchg    dx, ax
[122]310    mov     cx, MONO_BRIGHT
[88]311
[92]312    test    bl, bl      ; Any Floppy Drives?
313    jz      SHORT .SkipFloppyDriveHotkeys
314    mov     ax, 'A' | (ANGLE_QUOTE_RIGHT<<8)
315    mov     si, g_szFDD
316    call    PushHotkeyParamsAndFormat
[88]317
[92]318.SkipFloppyDriveHotkeys:
319    test    bh, bh      ; Any Hard Drives?
320    jz      SHORT .SkipHardDriveHotkeys
[122]321    xchg    ax, cx      ; Store Key Attribute
[92]322    call    BootMenu_GetLetterForFirstHardDiskToCL
323    mov     ch, ANGLE_QUOTE_RIGHT
324    xchg    ax, cx
325    mov     si, g_szHDD
326    call    PushHotkeyParamsAndFormat
327
328.SkipHardDriveHotkeys:
329    ; Fall to .PrintRomBootHotkey
330
[88]331;--------------------------------------------------------------------
[92]332; .PrintRomBootHotkey
[88]333;   Parameters:
[92]334;       CX:     Key Attribute
335;       DX:     Description Attribute
[3]336;   Returns:
[88]337;       Nothing
[3]338;   Corrupts registers:
[120]339;       AX, SI, DI
[3]340;--------------------------------------------------------------------
[92]341.PrintRomBootHotkey:
342    mov     ax, 'F' | ('8'<<8)      ; F8
343    mov     si, g_szRomBoot
344    ; Fall to PushHotkeyParamsAndFormat
345
346;--------------------------------------------------------------------
347; PushHotkeyParamsAndFormat
348;   Parameters:
349;       AL:     First character
350;       AH:     Second character
351;       CX:     Key Attribute
352;       DX:     Description Attribute
353;       CS:SI:  Description string
354;   Returns:
355;       Nothing
356;   Corrupts registers:
[120]357;       AX, SI, DI
[92]358;--------------------------------------------------------------------
[3]359ALIGN JUMP_ALIGN
[92]360PushHotkeyParamsAndFormat:
361    push    bp
362    mov     bp, sp
363
364    push    cx          ; Key attribute
365    push    ax          ; First character
366    xchg    al, ah
367    push    ax          ; Second character
368    push    dx          ; Description attribute
369    push    si          ; Description string
370    push    cx          ; Key attribute for last space
371    mov     si, g_szHotkey
[241]372       
373BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay: 
374    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[161]375
[182]376
[192]377;--------------------------------------------------------------------
378; BootMenuPrint_InitializeDisplayContext
379;   Parameters:
380;       Nothing
381;   Returns:
382;       Nothing
383;   Corrupts registers:
384;       AX, DI
385;--------------------------------------------------------------------
386ALIGN JUMP_ALIGN
387BootMenuPrint_InitializeDisplayContext:
388    CALL_DISPLAY_LIBRARY InitializeDisplayContext
389    ret
390
391
[241]392;--------------------------------------------------------------------
393; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
394;   Parameters:
395;       BX:DX:AX:   Sector count
396;   Returns:
397;       Size in stack
398;   Corrupts registers:
399;       AX, BX, CX, DX, SI
400;--------------------------------------------------------------------
401ALIGN JUMP_ALIGN
402ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
403    pop     si                      ; Pop return address
404    ePUSH_T cx, g_szCapacityNum     ; Push format substring
405    call    Size_ConvertSectorCountInBXDXAXtoKiB
406    mov     cx, BYTE_MULTIPLES.kiB
407    call    Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
408    push    ax                      ; Size in magnitude
409    push    cx                      ; Tenths
410    push    dx                      ; Magnitude character
411    jmp     si
412
413
414FloppyTypes:
415.rgbCapacityMultiplier equ 20           ; Multiplier to reduce word sized values to byte size
416.rgbCapacity:
417    db      360   / FloppyTypes.rgbCapacityMultiplier    ;  type 1
418    db      1200  / FloppyTypes.rgbCapacityMultiplier    ;  type 2
419    db      720   / FloppyTypes.rgbCapacityMultiplier    ;  type 3
420    db      1440  / FloppyTypes.rgbCapacityMultiplier    ;  type 4
421    db      2880  / FloppyTypes.rgbCapacityMultiplier    ;  type 5
422    db      2880  / FloppyTypes.rgbCapacityMultiplier    ;  type 6
Note: See TracBrowser for help on using the repository browser.