Changeset 88 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm


Ignore:
Timestamp:
Jan 27, 2011, 8:14:13 AM (13 years ago)
Author:
aitotat
google:author:
aitotat
Message:

Changes to XTIDE Universal BIOS:

  • Now uses new libraries (untested)
  • Non-working since code size is too large
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm

    r84 r88  
    1 ; File name     :   BootMenuPrint.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   26.3.2010
    4 ; Last update   :   14.1.2011
    5 ; Author        :   Tomi Tilli,
    6 ;               :   Krister Nordvall (optimizations)
     1; Project name  :   XTIDE Universal BIOS
    72; Description   :   Functions for printing boot menu strings.
    83
    94; Section containing code
    105SECTION .text
     6
     7;--------------------------------------------------------------------
     8; Prints Boot Menu title strings.
     9;
     10; BootMenuPrint_TitleStrings
     11;   Parameters:
     12;       Nothing
     13;   Returns:
     14;       CF:     Set since menu event handled
     15;   Corrupts registers:
     16;       AX, SI, DI
     17;--------------------------------------------------------------------
     18ALIGN JUMP_ALIGN
     19BootMenuPrint_TitleStrings:
     20    mov     si, ROMVARS.szTitle
     21    call    PrintNullTerminatedStringFromCSSIandSetCF
     22    call    BootMenuPrint_Newline
     23    mov     si, ROMVARS.szVersion
     24    jmp     PrintNullTerminatedStringFromCSSIandSetCF
     25
     26
     27;--------------------------------------------------------------------
     28; BootMenuPrint_Newline
     29;   Parameters:
     30;       Nothing
     31;   Returns:
     32;       Nothing
     33;   Corrupts registers:
     34;       AX, DI
     35;--------------------------------------------------------------------
     36ALIGN JUMP_ALIGN
     37BootMenuPrint_Newline:
     38    CALL_DISPLAY_LIBRARY PrintNewlineCharacters
     39    ret
     40
     41
     42;--------------------------------------------------------------------
     43; Prints Floppy Drive hotkey string.
     44;
     45; BootMenuPrint_FloppyHotkeyString
     46;   Parameters:
     47;       BL:     Number of floppy drives in system
     48;   Returns:
     49;       Nothing
     50;   Corrupts registers:
     51;       AX, SI
     52;--------------------------------------------------------------------
     53ALIGN JUMP_ALIGN
     54BootMenuPrint_FloppyHotkeyString:
     55    test    bl, bl                  ; Any floppy drives?
     56    jz      SHORT NoFloppyDrivesOrHardDisksToPrint
     57    push    bp
     58
     59    mov     bp, sp
     60    mov     al, 'A'
     61    push    ax                      ; 'A'
     62    dec     ax
     63    add     al, bl
     64    push    ax                      ; Last floppy drive letter
     65    ePUSH_T ax, g_szFDD
     66    ePUSH_T ax, g_szHDD
     67    jmp     SHORT PrintHotkeyString
     68
     69;--------------------------------------------------------------------
     70; Prints Hard Disk hotkey string.
     71;
     72; BootMenuPrint_FloppyHotkeyString
     73;   Parameters:
     74;       BH:     Number of hard disks in system
     75;   Returns:
     76;       Nothing
     77;   Corrupts registers:
     78;       AX, CX, SI
     79;--------------------------------------------------------------------
     80ALIGN JUMP_ALIGN
     81BootMenuPrint_HardDiskHotkeyString:
     82    test    bh, bh                  ; Any hard disks?
     83    jz      SHORT NoFloppyDrivesOrHardDisksToPrint
     84    push    bp
     85
     86    mov     bp, sp
     87    call    BootMenu_GetLetterForFirstHardDisk
     88    push    cx                      ; First hard disk letter
     89    dec     cx
     90    add     cl, bh
     91    push    cx                      ; Last hard disk letter
     92    ePUSH_T ax, g_szHDD
     93    ePUSH_T ax, g_szFDD
     94    ; Fall to PrintHotkeyString
     95
     96ALIGN JUMP_ALIGN
     97PrintHotkeyString:
     98    mov     si, g_szBottomScrn
     99    jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
     100NoFloppyDrivesOrHardDisksToPrint:
     101    ret
     102
     103;--------------------------------------------------------------------
     104; BootMenuPrint_ClearScreen
     105;   Parameters:
     106;       Nothing
     107;   Returns:
     108;       Nothing
     109;   Corrupts registers:
     110;       AX
     111;--------------------------------------------------------------------
     112ALIGN JUMP_ALIGN
     113BootMenuPrint_ClearScreen:
     114    push    di
     115    mov     ax, ' ' | (MONO_NORMAL<<8)
     116    CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
     117    pop     di
     118    ret
     119
     120
     121;--------------------------------------------------------------------
     122; Translates and prints drive number.
     123;
     124; BootMenuPrint_TranslatedDriveNumber
     125;   Parameters:
     126;       DL:     Untranslated drive number
     127;       DS:     RAMVARS segment
     128;   Returns:
     129;       Nothing
     130;   Corrupts registers:
     131;       AX, DI
     132;--------------------------------------------------------------------
     133ALIGN JUMP_ALIGN
     134BootMenuPrint_TranslatedDriveNumber:
     135    push    dx
     136    push    bx
     137
     138    call    DriveXlate_ToOrBack
     139    eMOVZX  ax, dl      ; Drive number to AL
     140    CALL_DISPLAY_LIBRARY PrintWordFromAXwithBaseInBX
     141    mov     al, ' '     ; Print space
     142    CALL_DISPLAY_LIBRARY PrintCharacterFromAL
     143
     144    pop     bx
     145    pop     dx
     146    ret
     147
     148
     149;--------------------------------------------------------------------
     150; BootMenuPrint_FloppyMenuitem
     151;   Parameters:
     152;       DL:     Untranslated Floppy Drive number
     153;   Returns:
     154;       Nothing
     155;   Corrupts registers:
     156;       AX, DX, SI
     157;--------------------------------------------------------------------
     158ALIGN JUMP_ALIGN
     159BootMenuPrint_FloppyMenuitem:
     160    push    bp
     161
     162    mov     bp, sp
     163    mov     si, g_szFDLetter
     164    ePUSH_T ax, g_szFloppyDrv
     165    add     dl, 'A'
     166    push    dx                  ; Drive letter
     167    jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
     168
     169
     170;--------------------------------------------------------------------
     171; BootMenuPrint_HardDiskMenuitem
     172;   Parameters:
     173;       DL:     Untranslated Hard Disk number
     174;       DS:     RAMVARS segment
     175;   Returns:
     176;       CF:     Set since menu event handled
     177;   Corrupts registers:
     178;       AX, BX, SI, DI
     179;--------------------------------------------------------------------
     180ALIGN JUMP_ALIGN
     181BootMenuPrint_HardDiskMenuitem:
     182    call    FindDPT_ForDriveNumber      ; DS:DI to point DPT
     183    jnc     SHORT .HardDiskMenuitemForForeignDrive
     184    ; Fall to .HardDiskMenuitemForOurDrive
     185
     186;--------------------------------------------------------------------
     187; .HardDiskMenuitemForOurDrive
     188;   Parameters:
     189;       DL:     Untranslated Hard Disk number
     190;       DS:     RAMVARS segment
     191;   Returns:
     192;       CF:     Set since menu event handled
     193;   Corrupts registers:
     194;       AX, BX, SI, DI
     195;--------------------------------------------------------------------
     196;ALIGN JUMP_ALIGN
     197.HardDiskMenuitemForOurDrive:
     198    call    BootInfo_GetOffsetToBX
     199    lea     si, [bx+BOOTNFO.szDrvName]
     200    xor     bx, bx          ; BDA segment
     201    CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
     202    stc
     203    ret
     204
     205;--------------------------------------------------------------------
     206; BootMenuPrint_HardDiskMenuitemForForeignDrive
     207;   Parameters:
     208;       DL:     Untranslated Hard Disk number
     209;       DS:     RAMVARS segment
     210;   Returns:
     211;       CF:     Set since menu event handled
     212;   Corrupts registers:
     213;       AX, SI, DI
     214;--------------------------------------------------------------------
     215ALIGN JUMP_ALIGN
     216.HardDiskMenuitemForForeignDrive:
     217    mov     si, g_szforeignHD
     218    jmp     PrintNullTerminatedStringFromCSSIandSetCF
     219
     220
     221;--------------------------------------------------------------------
     222; BootMenuPrint_FunctionMenuitem
     223;   Parameters:
     224;       DX:     Function ID
     225;   Returns:
     226;       CF:     Set if menu event was handled successfully
     227;   Corrupts registers:
     228;       AX, DX, SI, DI
     229;--------------------------------------------------------------------
     230ALIGN JUMP_ALIGN
     231BootMenuPrint_FunctionMenuitem:
     232    test    dx, dx                  ; ID_BOOTFUNC_ROMBOOT
     233    jz      SHORT .PrintRomBootMenuitem
     234    ret
     235
     236ALIGN JUMP_ALIGN
     237.PrintRomBootMenuitem:
     238    mov     si, g_szRomBoot
     239    jmp     PrintNullTerminatedStringFromCSSIandSetCF
     240
     241
     242;--------------------------------------------------------------------
     243; BootMenuPrint_FloppyMenuitemInformation
     244;   Parameters:
     245;       DL:     Untranslated Floppy Drive number
     246;       DS:     RAMVARS segment
     247;   Returns:
     248;       CF:     Set since menu event was handled successfully
     249;   Corrupts registers:
     250;       AX, BX, CX, DX, SI, DI, ES
     251;--------------------------------------------------------------------
     252ALIGN JUMP_ALIGN
     253BootMenuPrint_FloppyMenuitemInformation:
     254    call    BootMenuPrint_ClearInformationArea
     255    call    FloppyDrive_GetType         ; Get Floppy Drive type to BX
     256    test    bx, bx                      ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)
     257    jz      SHORT .PrintXTFloppyType
     258    cmp     bl, FLOPPY_TYPE_35_ED
     259    ja      SHORT .PrintUnknownFloppyType
     260    jmp     SHORT .PrintKnownFloppyType
     261
     262;--------------------------------------------------------------------
     263; .PrintXTFloppyType
     264;   Parameters:
     265;       Nothing
     266;   Returns:
     267;       CF:     Set since menu event was handled successfully
     268;   Corrupts registers:
     269;       AX, SI, DI
     270;--------------------------------------------------------------------
     271ALIGN JUMP_ALIGN
     272.PrintXTFloppyType:
     273    push    bp
     274    mov     si, g_szFddSizeOr
     275    jmp     SHORT .FormatXTorUnknownTypeFloppyDrive
     276
     277;--------------------------------------------------------------------
     278; .PrintUnknownFloppyType
     279;   Parameters:
     280;       Nothing
     281;   Returns:
     282;       CF:     Set since menu event was handled successfully
     283;   Corrupts registers:
     284;       AX, SI, DI
     285;--------------------------------------------------------------------
     286ALIGN JUMP_ALIGN
     287.PrintUnknownFloppyType:
     288    push    bp
     289    mov     si, g_szFddUnknown
     290.FormatXTorUnknownTypeFloppyDrive:
     291    mov     bp, sp
     292    ePUSH_T ax, g_szCapacity
     293    jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
     294
     295;--------------------------------------------------------------------
     296; .PrintKnownFloppyType
     297;   Parameters:
     298;       BX:     Floppy drive type
     299;   Returns:
     300;       CF:     Set since menu event was handled successfully
     301;   Corrupts registers:
     302;       AX, BX, SI, DI
     303;--------------------------------------------------------------------
     304ALIGN JUMP_ALIGN
     305.PrintKnownFloppyType:
     306    push    bp
     307
     308    mov     bp, sp
     309    mov     si, g_szFddSize
     310    ePUSH_T ax, g_szCapacity
     311    dec     bx                      ; Cannot be 0 (FLOPPY_TYPE_525_OR_35_DD)
     312    shl     bx, 1                   ; Shift for WORD lookup
     313    mov     ax, [cs:bx+.rgwPhysicalSize]
     314    push    ax                      ; '5' or '3'
     315    mov     al, ah
     316    push    ax                      ; '1/4' or '1/2'
     317    push    WORD [cs:bx+.rgwCapacity]
     318    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
     319
     320ALIGN WORD_ALIGN
     321.rgwCapacity:
     322    dw      360
     323    dw      1200
     324    dw      720
     325    dw      1440
     326    dw      2880
     327    dw      2880
     328.rgwPhysicalSize:
     329    db      '5', 172    ; 1, FLOPPY_TYPE_525_DD
     330    db      '5', 172    ; 2, FLOPPY_TYPE_525_HD
     331    db      '3', 171    ; 3, FLOPPY_TYPE_35_DD
     332    db      '3', 171    ; 4, FLOPPY_TYPE_35_HD
     333    db      '3', 171    ; 5, 3.5" ED on some BIOSes
     334    db      '3', 171    ; 6, FLOPPY_TYPE_35_ED
     335
     336
     337;--------------------------------------------------------------------
     338; Prints Hard Disk Menuitem information strings.
     339;
     340; BootMenuPrint_HardDiskMenuitemInformation
     341;   Parameters:
     342;       DL:     Untranslated Hard Disk number
     343;       DS:     RAMVARS segment
     344;   Returns:
     345;       CF:     Set since menu event was handled successfully
     346;   Corrupts registers:
     347;       BX, CX, DX, SI, DI, ES
     348;--------------------------------------------------------------------
     349ALIGN JUMP_ALIGN
     350BootMenuPrint_HardDiskMenuitemInformation:
     351    call    FindDPT_ForDriveNumber      ; DS:DI to point DPT
     352    jnc     SHORT .HardDiskMenuitemInfoForForeignDrive
     353    call    .HardDiskMenuitemInfoSizeForOurDrive
     354    jmp     BootMenuPrintCfg_ForOurDrive
     355
     356;--------------------------------------------------------------------
     357; .HardDiskMenuitemInfoForForeignDrive
     358;   Parameters:
     359;       DL:     Untranslated Hard Disk number
     360;       DS:     RAMVARS segment
     361;   Returns:
     362;       CF:     Set since menu event was handled successfully
     363;   Corrupts registers:
     364;       AX, BX, CX, DX, SI, DI
     365;--------------------------------------------------------------------
     366ALIGN JUMP_ALIGN
     367.HardDiskMenuitemInfoForForeignDrive:
     368    push    bp
     369    mov     bp, sp
     370    ePUSH_T ax, g_szCapacity
     371
     372    call    DriveXlate_ToOrBack
     373    call    HCapacity_GetSectorCountFromForeignAH08h
     374    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
     375
     376    mov     si, g_szSizeSingle
     377    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
     378
     379;--------------------------------------------------------------------
     380; .HardDiskMenuitemInfoSizeForOurDrive
     381;   Parameters:
     382;       DL:     Untranslated Hard Disk number
     383;       DS:DI:  Ptr to DPT
     384;   Returns:
     385;       Nothing
     386;   Corrupts registers:
     387;       AX, BX, CX, DX, SI, ES
     388;--------------------------------------------------------------------
     389ALIGN JUMP_ALIGN
     390.HardDiskMenuitemInfoSizeForOurDrive:
     391    push    bp
     392    mov     bp, sp
     393    ePUSH_T ax, g_szCapacity
     394
     395    ; Get and push L-CHS size
     396    call    HCapacity_GetSectorCountFromOurAH08h
     397    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
     398
     399    ; Get and push total LBA size
     400    call    BootInfo_GetTotalSectorCount
     401    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
     402
     403    mov     si, g_szSizeDual
     404    ; Fall to BootMenuPrint_FormatCSSIfromParamsInSSBP
     405
     406
     407;--------------------------------------------------------------------
     408; BootMenuPrint_FormatCSSIfromParamsInSSBP
     409;   Parameters:
     410;       CS:SI:  Ptr to string to format
     411;       SS:BP:  Ptr to format parameters
     412;   Returns:
     413;       BP:     Popped from stack
     414;   Corrupts registers:
     415;       AX
     416;--------------------------------------------------------------------
     417ALIGN JUMP_ALIGN
     418BootMenuPrint_FormatCSSIfromParamsInSSBP:
     419    push    di
     420    CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
     421    stc             ; Successfull return from menu event
     422    pop     di
     423    pop     bp
     424    ret
     425
     426
     427;--------------------------------------------------------------------
     428; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
     429;   Parameters:
     430;       BX:DX:AX:   Sector count
     431;   Returns:
     432;       Size in stack
     433;   Corrupts registers:
     434;       AX, BX, CX, DX, SI
     435;--------------------------------------------------------------------
     436ALIGN JUMP_ALIGN
     437ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
     438    pop     si      ; Pop return address
     439    call    Size_ConvertSectorCountInBXDXAXtoKiB
     440    mov     cx, BYTE_MULTIPLES.kiB
     441    call    Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
     442    push    ax      ; Size in magnitude
     443    push    cx      ; Tenths
     444    push    dx      ; Magnitude character
     445    jmp     si
     446
     447
     448;--------------------------------------------------------------------
     449; PrintNullTerminatedStringFromCSSIandSetCF
     450;   Parameters:
     451;       CS:SI:  Ptr to NULL terminated string to print
     452;   Returns:
     453;       CF:     Set since menu event was handled successfully
     454;   Corrupts registers:
     455;       AX, DI
     456;--------------------------------------------------------------------
     457ALIGN JUMP_ALIGN
     458PrintNullTerminatedStringFromCSSIandSetCF:
     459    CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
     460    stc
     461    ret
     462
     463
     464;--------------------------------------------------------------------
     465; BootMenuPrint_ClearInformationArea
     466;   Parameters:
     467;       Nothing
     468;   Returns:
     469;       CF:     Set
     470;   Corrupts registers:
     471;       AX, DI
     472;--------------------------------------------------------------------
     473ALIGN JUMP_ALIGN
     474BootMenuPrint_ClearInformationArea:
     475    CALL_MENU_LIBRARY ClearInformationArea
     476    stc
     477    ret
     478
    11479
    12480;--------------------------------------------------------------------
     
    70538ALIGN JUMP_ALIGN
    71539BootMenuPrint_SetCursorPosition:
    72     push    bx
    73     call    MenuCrsr_SetCursor
    74     pop     bx
    75     ret
    76 
    77 
    78 ;--------------------------------------------------------------------
    79 ; Prints Floppy Drive hotkey string.
    80 ;
    81 ; BootMenuPrint_FloppyHotkeyString
    82 ;   Parameters:
    83 ;       BL:     Number of floppy drives in system
    84 ;   Returns:
    85 ;       Nothing
    86 ;   Corrupts registers:
    87 ;       AX, CX, DX, SI
    88 ;--------------------------------------------------------------------
    89 ALIGN JUMP_ALIGN
    90 BootMenuPrint_FloppyHotkeyString:
    91     test    bl, bl                  ; Any floppy drives?
    92     jz      .Return
    93     ePUSH_T ax, g_szHDD
    94     ePUSH_T ax, g_szFDD
    95     mov     ax, 'A'-1
    96     add     al, bl                  ; Last Floppy Drive letter
    97     push    ax
    98     ePUSH_T ax, 'A'
    99     jmp     SHORT BootMenuPrint_HotkeyString
    100 .Return:
    101     ret
    102 
    103 ;--------------------------------------------------------------------
    104 ; Prints Floppy Drive or Hard Disk hotkey string when
    105 ; parameters are pushed to stack.
    106 ;
    107 ; BootMenuPrint_HotkeyString
    108 ;   Parameters:
    109 ;       Stack:  String formatting parameters
    110 ;   Returns:
    111 ;       Nothing
    112 ;   Corrupts registers:
    113 ;       AX, CX, DX, SI
    114 ;--------------------------------------------------------------------
    115 ALIGN JUMP_ALIGN
    116 BootMenuPrint_HotkeyString:
    117     mov     si, g_szBottomScrn
    118     mov     dh, 8                   ; 8 bytes pushed to stack
    119     jmp     PrintString_JumpToFormat
    120 
    121 
    122 ;--------------------------------------------------------------------
    123 ; Prints Hard Disk hotkey string.
    124 ;
    125 ; BootMenuPrint_FloppyHotkeyString
    126 ;   Parameters:
    127 ;       BH:     Number of hard disks in system
    128 ;   Returns:
    129 ;       Nothing
    130 ;   Corrupts registers:
    131 ;       AX, CX, DX, SI
    132 ;--------------------------------------------------------------------
    133 ALIGN JUMP_ALIGN
    134 BootMenuPrint_HardDiskHotkeyString:
    135     test    bh, bh                  ; Any hard disks?
    136     jz      .Return
    137     ePUSH_T ax, g_szFDD
    138     ePUSH_T ax, g_szHDD
    139     call    BootMenu_GetLetterForFirstHardDisk
    140     eMOVZX  ax, bh                  ; Hard disk count to AX
    141     add     ax, cx                  ; One past last hard disk letter
    142     dec     ax                      ; Last hard disk letter
    143     push    ax
    144     push    cx
    145     jmp     SHORT BootMenuPrint_HotkeyString
    146 .Return:
    147     ret
    148 
    149 
    150 ;--------------------------------------------------------------------
    151 ; Clears screen.
    152 ;
    153 ; BootMenuPrint_ClearScreen
    154 ;   Parameters:
    155 ;       Nothing
    156 ;   Returns:
    157 ;       Nothing
    158 ;   Corrupts registers:
    159 ;       AX, BX, DX
    160 ;--------------------------------------------------------------------
    161 ALIGN JUMP_ALIGN
    162 BootMenuPrint_ClearScreen:
    163     push    cx
    164     call    MenuDraw_ClrScr
    165     pop     cx
    166     ret
    167 
    168 
    169 ;--------------------------------------------------------------------
    170 ; Translates and prints drive number.
    171 ;
    172 ; BootMenuPrint_TranslatedDriveNumber
    173 ;   Parameters:
    174 ;       DL:     Untranslated drive number
    175 ;       DS:     RAMVARS segment
    176 ;   Returns:
    177 ;       Nothing
    178 ;   Corrupts registers:
    179 ;       AX, DI
    180 ;--------------------------------------------------------------------
    181 ALIGN JUMP_ALIGN
    182 BootMenuPrint_TranslatedDriveNumber:
    183     push    dx
    184     call    DriveXlate_ToOrBack
    185     mov     al, dl                      ; Drive number to AL
    186     call    Print_IntHexB
    187     mov     dl, ' '
    188     PRINT_CHAR                          ; Print space
    189     pop     dx
    190     ret
    191 
    192 
    193 ;--------------------------------------------------------------------
    194 ; Prints Floppy Drive Menuitem string.
    195 ;
    196 ; BootMenuPrint_FloppyMenuitem
    197 ;   Parameters:
    198 ;       DL:     Untranslated Floppy Drive number
    199 ;   Returns:
    200 ;       AX:     1 if drive number was valid
    201 ;               0 if drive number was invalid
    202 ;   Corrupts registers:
    203 ;       CX, DX, SI
    204 ;--------------------------------------------------------------------
    205 ALIGN JUMP_ALIGN
    206 BootMenuPrint_FloppyMenuitem:
    207     ePUSH_T ax, BootMenuPrint_HardDiskPrinted   ; Return address
    208     add     dl, 'A'             ; Number to letter
    209     push    dx
    210     ePUSH_T ax, g_szFloppyDrv
    211     mov     si, g_szFDLetter
    212     mov     dh, 4               ; 4 bytes pushed to stack
    213     jmp     PrintString_JumpToFormat
    214 
    215 
    216 ;--------------------------------------------------------------------
    217 ; Prints Hard Disk Menuitem string.
    218 ;
    219 ; BootMenuPrint_HardDiskMenuitem
    220 ;   Parameters:
    221 ;       DL:     Untranslated Hard Disk number
    222 ;       DS:     RAMVARS segment
    223 ;   Returns:
    224 ;       AX:     1 if drive number was valid
    225 ;               0 if drive number was invalid
    226 ;   Corrupts registers:
    227 ;       CX, DX, SI, ES
    228 ;--------------------------------------------------------------------
    229 ALIGN JUMP_ALIGN
    230 BootMenuPrint_HardDiskMenuitem:
    231     ePUSH_T ax, BootMenuPrint_HardDiskPrinted
    232     call    FindDPT_ForDriveNumber      ; DS:DI to point DPT
    233     jnc     SHORT BootMenuPrint_HardDiskMenuitemForForeignDrive
    234     jmp     SHORT BootMenuPrint_HardDiskMenuitemForOurDrive
    235 ALIGN JUMP_ALIGN
    236 BootMenuPrint_HardDiskPrinted:
    237     mov     ax, 1
    238     ret
    239 
    240 ;--------------------------------------------------------------------
    241 ; Prints Hard Disk Menuitem string for drive that is handled by
    242 ; some another BIOS.
    243 ;
    244 ; BootMenuPrint_HardDiskMenuitemForForeignDrive
    245 ;   Parameters:
    246 ;       DL:     Untranslated Hard Disk number
    247 ;       DS:     RAMVARS segment
    248 ;   Returns:
    249 ;       AX:     1 if drive number was valid
    250 ;               0 if drive number was invalid
    251 ;   Corrupts registers:
    252 ;       CX, DX, SI
    253 ;--------------------------------------------------------------------
    254 ALIGN JUMP_ALIGN
    255 BootMenuPrint_HardDiskMenuitemForForeignDrive:
    256     mov     si, g_szforeignHD
    257     jmp     PrintString_FromCS
    258 
    259 ;--------------------------------------------------------------------
    260 ; Prints Hard Disk Menuitem string for drive that is handled by our BIOS.
    261 ;
    262 ; BootMenuPrint_HardDiskMenuitemForOurDrive
    263 ;   Parameters:
    264 ;       DL:     Untranslated Hard Disk number
    265 ;       DS:     RAMVARS segment
    266 ;   Returns:
    267 ;       AX:     1 if drive number was valid
    268 ;               0 if drive number was invalid
    269 ;   Corrupts registers:
    270 ;       CX, DX, SI, ES
    271 ;--------------------------------------------------------------------
    272 ALIGN JUMP_ALIGN
    273 BootMenuPrint_HardDiskMenuitemForOurDrive:
    274     call    BootInfo_GetOffsetToBX
    275     LOAD_BDA_SEGMENT_TO es, ax
    276     lea     si, [bx+BOOTNFO.szDrvName]
    277     jmp     PrintString_FromES
    278 
    279 
    280 ;--------------------------------------------------------------------
    281 ; Prints Function Menuitem string.
    282 ;
    283 ; BootMenuPrint_FunctionMenuitem
    284 ;   Parameters:
    285 ;       DX:     Function ID
    286 ;   Returns:
    287 ;       AX:     1 if function ID was valid
    288 ;               0 if function ID was invalid
    289 ;   Corrupts registers:
    290 ;       DX, SI
    291 ;--------------------------------------------------------------------
    292 ALIGN JUMP_ALIGN
    293 BootMenuPrint_FunctionMenuitem:
    294     test    dx, dx                  ; ID_BOOTFUNC_ROMBOOT
    295     jz      SHORT .PrintRomBootMenuitem
    296     xor     ax, ax                  ; Event not processed
    297     ret
    298 
    299 ALIGN JUMP_ALIGN
    300 .PrintRomBootMenuitem:
    301     mov     si, g_szRomBoot
    302     ; Fall to .PrintAndReturn
    303 
    304 ALIGN JUMP_ALIGN
    305 .PrintAndReturn:
    306     call    PrintString_FromCS
    307     mov     ax, 1                   ; Event processed
    308     ret
    309 
    310 
    311 ;--------------------------------------------------------------------
    312 ; Prints Floppy Drive Menuitem information strings.
    313 ;
    314 ; BootMenuPrint_FloppyMenuitemInformation
    315 ;   Parameters:
    316 ;       DL:     Untranslated Floppy Drive number
    317 ;       DS:     RAMVARS segment
    318 ;   Returns:
    319 ;       AX:     1 if drive number was valid
    320 ;               0 if drive number was invalid
    321 ;   Corrupts registers:
    322 ;       BX, CX, DX, SI, DI, ES
    323 ;--------------------------------------------------------------------
    324 ALIGN JUMP_ALIGN
    325 BootMenuPrint_FloppyMenuitemInformation:
    326     call    FloppyDrive_GetType                     ; Get Floppy Drive type to BX
    327     ePUSH_T ax, BootMenuPrint_ClearThreeInfoLines   ; New return address
    328     test    bx, bx                                  ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)
    329     jz      SHORT BootMenuPrint_PrintXTFloppyType
    330     cmp     bl, FLOPPY_TYPE_35_ED
    331     ja      SHORT BootMenuPrint_PrintUnknownFloppyType
    332     jmp     SHORT BootMenuPrint_PrintKnownFloppyType
    333 
    334 ;--------------------------------------------------------------------
    335 ; Prints Menuitem information string for two possible XT floppy drives.
    336 ;
    337 ; BootMenuPrint_PrintXTFloppyType
    338 ;   Parameters:
    339 ;       Nothing
    340 ;   Returns:
    341 ;       Nothing
    342 ;   Corrupts registers:
    343 ;       CX, DX, SI
    344 ;--------------------------------------------------------------------
    345 ALIGN JUMP_ALIGN
    346 BootMenuPrint_PrintXTFloppyType:
    347     mov     si, g_szFddSizeOr
    348     jmp     SHORT BootMenuPrint_FormatUnknownFloppyType
    349 
    350 ;--------------------------------------------------------------------
    351 ; Prints Menuitem information string for unknown floppy drive type.
    352 ;
    353 ; BootMenuPrint_PrintUnknownFloppyType
    354 ;   Parameters:
    355 ;       Nothing
    356 ;   Returns:
    357 ;       Nothing
    358 ;   Corrupts registers:
    359 ;       CX, DX, SI
    360 ;--------------------------------------------------------------------
    361 ALIGN JUMP_ALIGN
    362 BootMenuPrint_PrintUnknownFloppyType:
    363     mov     si, g_szFddUnknown
    364 BootMenuPrint_FormatUnknownFloppyType:
    365     ePUSH_T ax, g_szCapacity
    366     mov     dh, 2                   ; 2 bytes pushed to stack
    367     jmp     PrintString_JumpToFormat
    368 
    369 ;--------------------------------------------------------------------
    370 ; Prints Menuitem information string for known floppy drive type.
    371 ;
    372 ; BootMenuPrint_PrintKnownFloppyType
    373 ;   Parameters:
    374 ;       BX:     Floppy drive type
    375 ;   Returns:
    376 ;       Nothing
    377 ;   Corrupts registers:
    378 ;       CX, DX, SI
    379 ;--------------------------------------------------------------------
    380 ALIGN JUMP_ALIGN
    381 BootMenuPrint_PrintKnownFloppyType:
    382     dec     bx                      ; Cannot be 0 (FLOPPY_TYPE_525_OR_35_DD)
    383     shl     bx, 1                   ; Shift for WORD lookup
    384     push    WORD [cs:bx+.rgwCapacity]
    385     mov     ax, [cs:bx+.rgwPhysicalSize]
    386     push    ax                      ; '1/4' or '1/2'
    387     mov     al, ah
    388     push    ax                      ; '5' or '3'
    389     ePUSH_T ax, g_szCapacity
    390     mov     si, g_szFddSize
    391     mov     dh, 8                   ; 8 bytes pushed to stack
    392     jmp     PrintString_JumpToFormat
    393 ALIGN WORD_ALIGN
    394 .rgwCapacity:
    395     dw      360
    396     dw      1200
    397     dw      720
    398     dw      1440
    399     dw      2880
    400     dw      2880
    401 .rgwPhysicalSize:
    402     db      172, '5'    ; 1, FLOPPY_TYPE_525_DD
    403     db      172, '5'    ; 2, FLOPPY_TYPE_525_HD
    404     db      171, '3'    ; 3, FLOPPY_TYPE_35_DD
    405     db      171, '3'    ; 4, FLOPPY_TYPE_35_HD
    406     db      171, '3'    ; 5, 3.5" ED on some BIOSes
    407     db      171, '3'    ; 6, FLOPPY_TYPE_35_ED
    408 
    409 
    410 ;--------------------------------------------------------------------
    411 ; Clears remaining characters from current information line
    412 ; and clears following lines.
    413 ;
    414 ; BootMenuPrint_ClearThreeInfoLines
    415 ; BootMenuPrint_ClearTwoInfoLines
    416 ; BootMenuPrint_ClearOneInfoLine
    417 ;   Parameters:
    418 ;       Nothing
    419 ;   Returns:
    420 ;       AX:     1
    421 ;   Corrupts registers:
    422 ;       BX, DX
    423 ;--------------------------------------------------------------------
    424 ALIGN JUMP_ALIGN
    425 BootMenuPrint_ClearThreeInfoLines:
    426     call    MenuDraw_NewlineStrClrLn
    427 ALIGN JUMP_ALIGN
    428 BootMenuPrint_ClearTwoInfoLines:
    429     call    MenuDraw_NewlineStrClrLn
    430 ALIGN JUMP_ALIGN
    431 BootMenuPrint_ClearOneInfoLine:
    432     call    MenuDraw_NewlineStrClrLn
    433     mov     ax, 1
    434     ret
    435 
    436 
    437 ;--------------------------------------------------------------------
    438 ; Prints Hard Disk Menuitem information strings.
    439 ;
    440 ; BootMenuPrint_HardDiskMenuitemInformation
    441 ;   Parameters:
    442 ;       DL:     Untranslated Hard Disk number
    443 ;       DS:     RAMVARS segment
    444 ;   Returns:
    445 ;       AX:     1 if drive number was valid
    446 ;               0 if drive number was invalid
    447 ;   Corrupts registers:
    448 ;       BX, CX, DX, SI, DI, ES
    449 ;--------------------------------------------------------------------
    450 ALIGN JUMP_ALIGN
    451 BootMenuPrint_HardDiskMenuitemInformation:
    452     ePUSH_T ax, BootMenuPrint_HardDiskPrinted
    453     call    FindDPT_ForDriveNumber      ; DS:DI to point DPT
    454     jnc     SHORT BootMenuPrint_HardDiskMenuitemInfoForForeignDrive
    455     call    BootMenuPrint_HardDiskMenuitemInfoSizeForOurDrive
    456     jmp     BootMenuPrintCfg_ForOurDrive
    457 
    458 ;--------------------------------------------------------------------
    459 ; Prints Hard Disk Menuitem information strings for drive that
    460 ; is handled by some other BIOS.
    461 ;
    462 ; BootMenuPrint_HardDiskMenuitemInfoForForeignDrive
    463 ;   Parameters:
    464 ;       DL:     Untranslated Hard Disk number
    465 ;       DS:     RAMVARS segment
    466 ;   Returns:
    467 ;       Nothing
    468 ;   Corrupts registers:
    469 ;       AX, BX, CX, DX, SI, DI
    470 ;--------------------------------------------------------------------
    471 ALIGN JUMP_ALIGN
    472 BootMenuPrint_HardDiskMenuitemInfoForForeignDrive:
    473     call    DriveXlate_ToOrBack
    474     call    HCapacity_GetSectorCountFromForeignAH08h
    475     call    HCapacity_ConvertSectorCountToSize
    476     ePUSH_T dx, BootMenuPrint_ClearThreeInfoLines   ; Return address
    477     push    cx                          ; Magnitude character
    478     push    si                          ; Tenths
    479     push    ax                          ; Size in magnitude
    480     ePUSH_T ax, g_szCapacity            ; "Capacity"
    481     mov     si, g_szSizeSingle
    482     mov     dh, 8                       ; 8 bytes pushed to stack
    483     jmp     PrintString_JumpToFormat
    484 
    485 ;--------------------------------------------------------------------
    486 ; Prints Hard Disk Menuitem information size string for drive that
    487 ; is handled by our BIOS.
    488 ;
    489 ; BootMenuPrint_HardDiskMenuitemInfoSizeForOurDrive
    490 ;   Parameters:
    491 ;       DL:     Untranslated Hard Disk number
    492 ;       DS:DI:  Ptr to DPT
    493 ;   Returns:
    494 ;       Nothing
    495 ;   Corrupts registers:
    496 ;       AX, BX, CX, DX, SI, ES
    497 ;--------------------------------------------------------------------
    498 ALIGN JUMP_ALIGN
    499 BootMenuPrint_HardDiskMenuitemInfoSizeForOurDrive:
    500     ePUSH_T ax, BootMenuPrint_ClearOneInfoLine  ; Return address
    501 
    502     ; Get and push total LBA size
    503     call    BootInfo_GetTotalSectorCount
    504     call    HCapacity_ConvertSectorCountToSize
    505     push    cx                              ; Magnitude character
    506     push    si                              ; Tenths
    507     push    ax                              ; Size in magnitude
    508 
    509     ; Get and push L-CHS size
    510     mov     dl, [di+DPT.bDrvNum]            ; Restore drive number
    511     call    HCapacity_GetSectorCountFromOurAH08h
    512     call    HCapacity_ConvertSectorCountToSize
    513     push    cx                              ; Magnitude character
    514     push    si                              ; Tenths
    515     push    ax                              ; Size in magnitude
    516 
    517     ePUSH_T ax, g_szCapacity                ; "Capacity"
    518     mov     si, g_szSizeDual
    519     mov     dh, 14                          ; 14 bytes pushed to stack
    520     jmp     PrintString_JumpToFormat
    521 
    522 
    523 ;--------------------------------------------------------------------
    524 ; Prints Function Menuitem information strings.
    525 ;
    526 ; BootMenuPrint_HardDiskMenuitemInformation
    527 ;   Parameters:
    528 ;       DX:     Function ID
    529 ;       DS:     RAMVARS segment
    530 ;   Returns:
    531 ;       AX:     1 if function ID was valid
    532 ;               0 if function ID was valid
    533 ;   Corrupts registers:
    534 ;       BX, DX
    535 ;--------------------------------------------------------------------
    536 ALIGN JUMP_ALIGN
    537 BootMenuPrint_FunctionMenuitemInformation:
    538     jmp     SHORT BootMenuPrint_ClearThreeInfoLines
    539 
    540 
    541 ;--------------------------------------------------------------------
    542 ; Prints Boot Menu title strings.
    543 ;
    544 ; BootMenuPrint_TitleStrings
    545 ;   Parameters:
    546 ;       Nothing
    547 ;   Returns:
    548 ;       AX:     Was printing successfull
    549 ;   Corrupts registers:
    550 ;       BX, DX, SI
    551 ;--------------------------------------------------------------------
    552 ALIGN JUMP_ALIGN
    553 BootMenuPrint_TitleStrings:
    554     mov     si, ROMVARS.szTitle
    555     call    PrintString_FromCS
    556     call    BootMenuPrint_ClearOneInfoLine
    557     mov     si, ROMVARS.szVersion
    558     call    PrintString_FromCS
    559     call    BootMenuPrint_ClearOneInfoLine
    560     mov     si, g_szTitleLn3
    561     call    PrintString_FromCS
    562     jmp     SHORT BootMenuPrint_ClearOneInfoLine
     540    push    di
     541    mov     ax, dx
     542    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
     543    pop     di
     544    ret
Note: See TracChangeset for help on using the changeset viewer.