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

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

Bug fix in BootMenuPrint, introduced in r241, where floppy disk information was not being properly displayed.

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
[255]117    mov     ax, g_szFddSizeOr                           ; .PrintXTFloppyType
[241]118    test    bx, bx                                      ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)     
[255]119    jz      SHORT .PushAXAndOutput
[241]120
[255]121    mov     al, (g_szFddUnknown - $$) & 0xff            ; .PrintUnknownFloppyType
[3]122    cmp     bl, FLOPPY_TYPE_35_ED
[255]123    ja      SHORT .PushAXAndOutput
[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:
[255]149    mov     al, (g_szFddSize - $$) & 0xff
150    push    ax
[182]151       
[255]152    mov     al, (g_szFddThreeHalf - $$) & 0xff
[182]153    cmp     bl, FLOPPY_TYPE_525_HD
154    ja      .ThreeHalf
[255]155    mov     al, (g_szFddFiveQuarter - $$) & 0xff
[182]156.ThreeHalf:     
[255]157    push    ax                                          ; "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
[255]161
162.PushAXAndOutput:                   
[182]163    push    ax
[161]164
[241]165    jmp     short BootMenuPrint_HardDiskRefreshInformation.output
[88]166
[192]167
168;--------------------------------------------------------------------
[3]169; Prints Hard Disk Menuitem information strings.
170;
171; BootMenuPrint_HardDiskMenuitemInformation
172;   Parameters:
173;       DL:     Untranslated Hard Disk number
174;       DS:     RAMVARS segment
175;   Returns:
[88]176;       CF:     Set since menu event was handled successfully
[3]177;   Corrupts registers:
178;       BX, CX, DX, SI, DI, ES
179;--------------------------------------------------------------------
180ALIGN JUMP_ALIGN
[241]181BootMenuPrint_HardDiskRefreshInformation:       
[150]182    call    RamVars_IsDriveHandledByThisBIOS
183    jnc     SHORT .HardDiskMenuitemInfoForForeignDrive
[241]184    call    FindDPT_ForDriveNumber                      ; DS:DI to point DPT
[127]185    ; Fall to .HardDiskMenuitemInfoForOurDrive
[3]186
187;--------------------------------------------------------------------
[127]188; .HardDiskMenuitemInfoForOurDrive
[3]189;   Parameters:
190;       DL:     Untranslated Hard Disk number
[127]191;       DS:DI:  Ptr to DPT
[3]192;   Returns:
[127]193;       Nothing
[3]194;   Corrupts registers:
[127]195;       AX, BX, CX, DX, SI, DI, ES
[3]196;--------------------------------------------------------------------
[127]197.HardDiskMenuitemInfoForOurDrive:
[252]198    ePUSH_T ax, g_szInformation
[88]199
[127]200    ; Get and push total LBA size
[254]201    call    BootMenuInfo_GetTotalSectorCount
[241]202    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat       
203    jmp     BootMenuPrintCfg_ForOurDrive
[252]204
[3]205;--------------------------------------------------------------------
[127]206; .HardDiskMenuitemInfoForForeignDrive
[3]207;   Parameters:
208;       DL:     Untranslated Hard Disk number
[127]209;       DS:     RAMVARS segment
[3]210;   Returns:
[127]211;       CF:     Set since menu event was handled successfully
[3]212;   Corrupts registers:
[127]213;       AX, BX, CX, DX, SI, DI
[3]214;--------------------------------------------------------------------
215ALIGN JUMP_ALIGN
[127]216.HardDiskMenuitemInfoForForeignDrive:
217    call    DriveXlate_ToOrBack
[150]218    call    AH15h_GetSectorCountFromForeignDriveToDXAX
[88]219    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
220
[241]221ALIGN JUMP_ALIGN       
222.output:
223    mov     si, g_szCapacity
224;;; fall-through
[3]225
226;--------------------------------------------------------------------
[241]227; BootMenuPrint_FormatCSSIfromParamsInSSBP
[88]228;   Parameters:
[241]229;       CS:SI:  Ptr to string to format
230;       BP:     SP before pushing parameters
[88]231;   Returns:
[241]232;       BP:     Popped from stack
233;       CF:     Set since menu event was handled successfully       
[88]234;   Corrupts registers:
[120]235;       AX, DI
[88]236;--------------------------------------------------------------------
237ALIGN JUMP_ALIGN
[241]238BootMenuPrint_FormatCSSIfromParamsInSSBP:
239    CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
240    stc             ; Successfull return from menu event
241    pop     bp
[88]242    ret
[192]243       
[241]244       
[88]245;--------------------------------------------------------------------
[192]246; BootMenuPrint_ClearScreen
[88]247;   Parameters:
[192]248;       Nothing
[88]249;   Returns:
[192]250;       Nothing
[88]251;   Corrupts registers:
[192]252;       AX, DI
[88]253;--------------------------------------------------------------------
254ALIGN JUMP_ALIGN
[192]255BootMenuPrint_ClearScreen:
256    call    BootMenuPrint_InitializeDisplayContext
257    xor     ax, ax
258    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
259    mov     ax, ' ' | (MONO_NORMAL<<8)
260    CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
261    ret
[88]262
263
264;--------------------------------------------------------------------
265; BootMenuPrint_TheBottomOfScreen
[3]266;   Parameters:
267;       DS:     RAMVARS segment
268;   Returns:
[88]269;       Nothing
[3]270;   Corrupts registers:
[92]271;       AX, BX, CX, DX, SI, DI
[3]272;--------------------------------------------------------------------
273ALIGN JUMP_ALIGN
[88]274BootMenuPrint_TheBottomOfScreen:
[124]275    call    FloppyDrive_GetCountToCX
[88]276    mov     bl, cl                  ; Floppy Drive count to BL
277    call    RamVars_GetHardDiskCountFromBDAtoCX
278    mov     bh, cl                  ; Hard Disk count to BH
[92]279    ; Fall to .MoveCursorToHotkeyStrings
[3]280
[92]281;--------------------------------------------------------------------
282; .MoveCursorToHotkeyStrings
283;   Parameters:
284;       Nothing
285;   Returns:
286;       Nothing
287;   Corrupts registers:
288;       AX, DI
289;--------------------------------------------------------------------
290.MoveCursorToHotkeyStrings:
291    CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
292    xor     al, al
293    dec     ah
294    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
295    ; Fall to .PrintHotkeyString
[3]296
297;--------------------------------------------------------------------
[92]298; .PrintHotkeyString
[3]299;   Parameters:
[92]300;       BL:     Floppy Drives
301;       BH:     Hard Drives
[88]302;   Returns:
[92]303;       Nothing
[88]304;   Corrupts registers:
[120]305;       AX, CX, DX, SI, DI
[88]306;--------------------------------------------------------------------
[92]307.PrintHotkeyString:
308    ; Display Library should not be called like this
309    mov     si, ATTRIBUTE_CHARS.cHighlightedItem
310    call    MenuAttribute_GetToAXfromTypeInSI
311    xchg    dx, ax
[122]312    mov     cx, MONO_BRIGHT
[88]313
[92]314    test    bl, bl      ; Any Floppy Drives?
315    jz      SHORT .SkipFloppyDriveHotkeys
316    mov     ax, 'A' | (ANGLE_QUOTE_RIGHT<<8)
317    mov     si, g_szFDD
318    call    PushHotkeyParamsAndFormat
[88]319
[92]320.SkipFloppyDriveHotkeys:
321    test    bh, bh      ; Any Hard Drives?
322    jz      SHORT .SkipHardDriveHotkeys
[122]323    xchg    ax, cx      ; Store Key Attribute
[92]324    call    BootMenu_GetLetterForFirstHardDiskToCL
325    mov     ch, ANGLE_QUOTE_RIGHT
326    xchg    ax, cx
327    mov     si, g_szHDD
328    call    PushHotkeyParamsAndFormat
329
330.SkipHardDriveHotkeys:
331    ; Fall to .PrintRomBootHotkey
332
[88]333;--------------------------------------------------------------------
[92]334; .PrintRomBootHotkey
[88]335;   Parameters:
[92]336;       CX:     Key Attribute
337;       DX:     Description Attribute
[3]338;   Returns:
[88]339;       Nothing
[3]340;   Corrupts registers:
[120]341;       AX, SI, DI
[3]342;--------------------------------------------------------------------
[92]343.PrintRomBootHotkey:
344    mov     ax, 'F' | ('8'<<8)      ; F8
345    mov     si, g_szRomBoot
346    ; Fall to PushHotkeyParamsAndFormat
347
348;--------------------------------------------------------------------
349; PushHotkeyParamsAndFormat
350;   Parameters:
351;       AL:     First character
352;       AH:     Second character
353;       CX:     Key Attribute
354;       DX:     Description Attribute
355;       CS:SI:  Description string
356;   Returns:
357;       Nothing
358;   Corrupts registers:
[120]359;       AX, SI, DI
[92]360;--------------------------------------------------------------------
[3]361ALIGN JUMP_ALIGN
[92]362PushHotkeyParamsAndFormat:
363    push    bp
364    mov     bp, sp
365
366    push    cx          ; Key attribute
367    push    ax          ; First character
368    xchg    al, ah
369    push    ax          ; Second character
370    push    dx          ; Description attribute
371    push    si          ; Description string
372    push    cx          ; Key attribute for last space
373    mov     si, g_szHotkey
[241]374       
375BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay: 
376    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[161]377
[182]378
[192]379;--------------------------------------------------------------------
380; BootMenuPrint_InitializeDisplayContext
381;   Parameters:
382;       Nothing
383;   Returns:
384;       Nothing
385;   Corrupts registers:
386;       AX, DI
387;--------------------------------------------------------------------
388ALIGN JUMP_ALIGN
389BootMenuPrint_InitializeDisplayContext:
390    CALL_DISPLAY_LIBRARY InitializeDisplayContext
391    ret
392
393
[241]394;--------------------------------------------------------------------
395; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
396;   Parameters:
397;       BX:DX:AX:   Sector count
398;   Returns:
399;       Size in stack
400;   Corrupts registers:
401;       AX, BX, CX, DX, SI
402;--------------------------------------------------------------------
403ALIGN JUMP_ALIGN
404ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
405    pop     si                      ; Pop return address
406    ePUSH_T cx, g_szCapacityNum     ; Push format substring
407    call    Size_ConvertSectorCountInBXDXAXtoKiB
408    mov     cx, BYTE_MULTIPLES.kiB
409    call    Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
410    push    ax                      ; Size in magnitude
411    push    cx                      ; Tenths
412    push    dx                      ; Magnitude character
413    jmp     si
414
415
416FloppyTypes:
417.rgbCapacityMultiplier equ 20           ; Multiplier to reduce word sized values to byte size
418.rgbCapacity:
419    db      360   / FloppyTypes.rgbCapacityMultiplier    ;  type 1
420    db      1200  / FloppyTypes.rgbCapacityMultiplier    ;  type 2
421    db      720   / FloppyTypes.rgbCapacityMultiplier    ;  type 3
422    db      1440  / FloppyTypes.rgbCapacityMultiplier    ;  type 4
423    db      2880  / FloppyTypes.rgbCapacityMultiplier    ;  type 5
424    db      2880  / FloppyTypes.rgbCapacityMultiplier    ;  type 6
Note: See TracBrowser for help on using the repository browser.