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

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

Added logic to skip scanning COM ports if a COM port was already found during the normal detection process, to avoid finding the same serial drive twice and preseting the OS with two drives which in reality point to the same physical file on the server. Also added logic to skip scanning for the slave serial drive if the master was not found. And various small optimizations.

File size: 15.6 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
[194]34%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
[189]35%if BootMenuPrint_FloppyMenuitem <> BootMenuEvent_FallThroughToFloppyMenuitem
36%error "BootMenuPrint.asm must follow BootMenuEvent.asm, and BootMenuPrint_FloppyMenuitem must be the first routine in BootMenuPrint.asm"
37%endif
[194]38%endif
[189]39       
40;--------------------------------------------------------------------
[192]41; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
[130]42;   Parameters:
[192]43;       BX:DX:AX:   Sector count
[130]44;   Returns:
[192]45;       Size in stack
[130]46;   Corrupts registers:
[192]47;       AX, BX, CX, DX, SI
[130]48;--------------------------------------------------------------------
49ALIGN JUMP_ALIGN
[192]50ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
51    pop     si      ; Pop return address
52    call    Size_ConvertSectorCountInBXDXAXtoKiB
53    mov     cx, BYTE_MULTIPLES.kiB
54    call    Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
55    push    ax      ; Size in magnitude
56    push    cx      ; Tenths
57    push    dx      ; Magnitude character
58    jmp     si
[130]59
60
61;--------------------------------------------------------------------
[88]62; Prints Boot Menu title strings.
[3]63;
[88]64; BootMenuPrint_TitleStrings
[3]65;   Parameters:
[88]66;       Nothing
[3]67;   Returns:
[88]68;       CF:     Set since menu event handled
[3]69;   Corrupts registers:
[88]70;       AX, SI, DI
[3]71;--------------------------------------------------------------------
72ALIGN JUMP_ALIGN
[88]73BootMenuPrint_TitleStrings:
74    mov     si, ROMVARS.szTitle
[96]75    call    BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
76    CALL_DISPLAY_LIBRARY PrintNewlineCharacters
[88]77    mov     si, ROMVARS.szVersion
[161]78    ; Fall to BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
[3]79
80
81;--------------------------------------------------------------------
[128]82; BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
83;   Parameters:
84;       CS:SI:  Ptr to NULL terminated string to print
85;   Returns:
86;       CF:     Set since menu event was handled successfully
87;   Corrupts registers:
[186]88;       AX, DI
[128]89;--------------------------------------------------------------------
90ALIGN JUMP_ALIGN
91BootMenuPrint_NullTerminatedStringFromCSSIandSetCF:
[186]92;
93; We send all CSSI strings through the Format routine for the case of
94; compressed strings, but this doesn't hurt in the non-compressed case either
95; (perhaps a little slower, but shouldn't be noticeable to the user)
96; and results in smaller code size.
97;
98    push    bp
99    mov     bp,sp
[192]100    jmp     short BootMenuPrint_FormatCSSIfromParamsInSSBP
[128]101
[192]102       
[128]103;--------------------------------------------------------------------
[3]104; BootMenuPrint_HardDiskMenuitem
105;   Parameters:
106;       DL:     Untranslated Hard Disk number
107;       DS:     RAMVARS segment
[190]108;       SF:     set for Information, clear for Item     
[3]109;   Returns:
[88]110;       CF:     Set since menu event handled
[3]111;   Corrupts registers:
[88]112;       AX, BX, SI, DI
[3]113;--------------------------------------------------------------------
114ALIGN JUMP_ALIGN
115BootMenuPrint_HardDiskMenuitem:
[192]116    js      short BootMenuPrint_HardDiskMenuitemInformation
[135]117    call    PrintDriveNumberAfterTranslationFromDL
[150]118    call    RamVars_IsDriveHandledByThisBIOS
[88]119    jnc     SHORT .HardDiskMenuitemForForeignDrive
120    ; Fall to .HardDiskMenuitemForOurDrive
[3]121
122;--------------------------------------------------------------------
[88]123; .HardDiskMenuitemForOurDrive
[3]124;   Parameters:
125;       DL:     Untranslated Hard Disk number
126;       DS:     RAMVARS segment
127;   Returns:
[88]128;       CF:     Set since menu event handled
[3]129;   Corrupts registers:
[88]130;       AX, BX, SI, DI
[3]131;--------------------------------------------------------------------
[88]132.HardDiskMenuitemForOurDrive:
133    call    BootInfo_GetOffsetToBX
134    lea     si, [bx+BOOTNFO.szDrvName]
135    xor     bx, bx          ; BDA segment
136    CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
137    stc
138    ret
[3]139
140;--------------------------------------------------------------------
[88]141; BootMenuPrint_HardDiskMenuitemForForeignDrive
[3]142;   Parameters:
143;       DL:     Untranslated Hard Disk number
144;       DS:     RAMVARS segment
145;   Returns:
[88]146;       CF:     Set since menu event handled
[3]147;   Corrupts registers:
[88]148;       AX, SI, DI
[3]149;--------------------------------------------------------------------
150ALIGN JUMP_ALIGN
[88]151.HardDiskMenuitemForForeignDrive:
152    mov     si, g_szforeignHD
[128]153    jmp     SHORT BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
[3]154
155
156;--------------------------------------------------------------------
157; BootMenuPrint_FloppyMenuitemInformation
158;   Parameters:
159;       DL:     Untranslated Floppy Drive number
160;       DS:     RAMVARS segment
161;   Returns:
[88]162;       CF:     Set since menu event was handled successfully
[3]163;   Corrupts registers:
[88]164;       AX, BX, CX, DX, SI, DI, ES
[3]165;--------------------------------------------------------------------
[192]166
167FloppyTypes:
168.rgbCapacityMultiplier equ 20           ; Multiplier to reduce word sized values to byte size
169.rgbCapacity:
170    db      360   / FloppyTypes.rgbCapacityMultiplier    ;  type 1
171    db      1200  / FloppyTypes.rgbCapacityMultiplier    ;  type 2
172    db      720   / FloppyTypes.rgbCapacityMultiplier    ;  type 3
173    db      1440  / FloppyTypes.rgbCapacityMultiplier    ;  type 4
174    db      2880  / FloppyTypes.rgbCapacityMultiplier    ;  type 5
175    db      2880  / FloppyTypes.rgbCapacityMultiplier    ;  type 6
176
[194]177%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
[192]178%if g_szFddFiveQuarter <> g_szFddThreeHalf+g_szFddThreeFive_Displacement
179%error "FddThreeFive_Displacement incorrect"
180%endif
[194]181%endif
[192]182       
[3]183ALIGN JUMP_ALIGN
184BootMenuPrint_FloppyMenuitemInformation:
[88]185    call    BootMenuPrint_ClearInformationArea
186    call    FloppyDrive_GetType         ; Get Floppy Drive type to BX
[182]187
[161]188    push    bp
189    mov     bp, sp
[182]190    ePUSH_T ax, g_szCapacity
191       
192    mov     si, g_szFddSizeOr           ; .PrintXTFloppyType
193    test    bx, bx                      ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)     
194    jz      SHORT .output
195
196    mov     si, g_szFddUnknown          ; .PrintUnknownFloppyType
[3]197    cmp     bl, FLOPPY_TYPE_35_ED
[182]198    ja      SHORT .output
199       
[161]200    ; Fall to .PrintKnownFloppyType
[3]201
[161]202
[3]203;--------------------------------------------------------------------
[161]204; .PrintKnownFloppyType
[3]205;   Parameters:
[161]206;       BX:     Floppy drive type
[3]207;   Returns:
[88]208;       CF:     Set since menu event was handled successfully
[3]209;   Corrupts registers:
[161]210;       AX, BX, SI, DI
[182]211; 
212; Floppy Drive Types:
213;
214;   0  Handled above 
215;   1  FLOPPY_TYPE_525_DD          5 1/4   360K
216;   2  FLOPPY_TYPE_525_HD          5 1/4   1.2M
217;   3  FLOPPY_TYPE_35_DD           3 1/2   720K
218;   4  FLOPPY_TYPE_35_HD           3 1/2   1.44M
219;   5  3.5" ED on some BIOSes      3 1/2   2.88M
220;   6  FLOPPY_TYPE_35_ED           3 1/2   2.88M
221;   >6 Unknwon, handled above
222; 
[3]223;--------------------------------------------------------------------
[161]224.PrintKnownFloppyType:
225    mov     si, g_szFddSize
[182]226       
227    mov     ax, g_szFddThreeHalf
228    cmp     bl, FLOPPY_TYPE_525_HD
229    ja      .ThreeHalf
[194]230%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
[186]231%if g_szFddThreeFive_Displacement = 2       
232    inc     ax                      ; compressed string case
233    inc     ax
234%else
[182]235    add     ax, g_szFddThreeFive_Displacement
[186]236%endif
[194]237%endif
[182]238.ThreeHalf:     
239    push    ax                      ; "5 1/4" or "3 1/2"
[3]240
[182]241    mov     al,FloppyTypes.rgbCapacityMultiplier
242    mul     byte [cs:bx+FloppyTypes.rgbCapacity - 1]    ; -1 since 0 is handled above and not in the table
243    push    ax
[161]244
[182]245ALIGN JUMP_ALIGN       
[192]246.output:
247;;; fall-through
[88]248
[3]249;--------------------------------------------------------------------
[192]250; BootMenuPrint_FormatCSSIfromParamsInSSBP
251;   Parameters:
252;       CS:SI:  Ptr to string to format
253;       BP:     SP before pushing parameters
254;   Returns:
255;       BP:     Popped from stack
[200]256;       CF:     Set since menu event was handled successfully       
[192]257;   Corrupts registers:
258;       AX, DI
259;--------------------------------------------------------------------
260ALIGN JUMP_ALIGN
261BootMenuPrint_FormatCSSIfromParamsInSSBP:
262    CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
263    stc             ; Successfull return from menu event
264    pop     bp
265    ret     
266
267       
268;--------------------------------------------------------------------
[3]269; Prints Hard Disk Menuitem information strings.
270;
271; BootMenuPrint_HardDiskMenuitemInformation
272;   Parameters:
273;       DL:     Untranslated Hard Disk number
274;       DS:     RAMVARS segment
275;   Returns:
[88]276;       CF:     Set since menu event was handled successfully
[3]277;   Corrupts registers:
278;       BX, CX, DX, SI, DI, ES
279;--------------------------------------------------------------------
280ALIGN JUMP_ALIGN
281BootMenuPrint_HardDiskMenuitemInformation:
[150]282    call    RamVars_IsDriveHandledByThisBIOS
283    jnc     SHORT .HardDiskMenuitemInfoForForeignDrive
[3]284    call    FindDPT_ForDriveNumber      ; DS:DI to point DPT
[127]285    ; Fall to .HardDiskMenuitemInfoForOurDrive
[3]286
287;--------------------------------------------------------------------
[127]288; .HardDiskMenuitemInfoForOurDrive
[3]289;   Parameters:
290;       DL:     Untranslated Hard Disk number
[127]291;       DS:DI:  Ptr to DPT
[3]292;   Returns:
[127]293;       Nothing
[3]294;   Corrupts registers:
[127]295;       AX, BX, CX, DX, SI, DI, ES
[3]296;--------------------------------------------------------------------
[127]297.HardDiskMenuitemInfoForOurDrive:
298    push    di
299    ePUSH_T ax, BootMenuPrintCfg_ForOurDrive    ; Return from BootMenuPrint_FormatCSSIfromParamsInSSBP
[88]300    push    bp
301    mov     bp, sp
302    ePUSH_T ax, g_szCapacity
303
[127]304    ; Get and push L-CHS size
[155]305    mov     [RAMVARS.bTimeoutTicksLeft], dl     ; Store drive number
[150]306    call    AH15h_GetSectorCountToDXAX
[88]307    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
308
[127]309    ; Get and push total LBA size
[155]310    mov     dl, [RAMVARS.bTimeoutTicksLeft]     ; Restore drive number
[127]311    call    BootInfo_GetTotalSectorCount
312    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
313
314    mov     si, g_szSizeDual
[88]315    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]316
[127]317
[3]318;--------------------------------------------------------------------
[127]319; .HardDiskMenuitemInfoForForeignDrive
[3]320;   Parameters:
321;       DL:     Untranslated Hard Disk number
[127]322;       DS:     RAMVARS segment
[3]323;   Returns:
[127]324;       CF:     Set since menu event was handled successfully
[3]325;   Corrupts registers:
[127]326;       AX, BX, CX, DX, SI, DI
[3]327;--------------------------------------------------------------------
328ALIGN JUMP_ALIGN
[127]329.HardDiskMenuitemInfoForForeignDrive:
[88]330    push    bp
331    mov     bp, sp
332    ePUSH_T ax, g_szCapacity
[3]333
[127]334    call    DriveXlate_ToOrBack
[150]335    call    AH15h_GetSectorCountFromForeignDriveToDXAX
[88]336    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
337
[127]338    mov     si, g_szSizeSingle
[192]339    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]340
[192]341       
[3]342;--------------------------------------------------------------------
[192]343; BootMenuPrint_ClearInformationArea
[88]344;   Parameters:
[192]345;       Nothing
[88]346;   Returns:
[192]347;       CF:     Set
[88]348;   Corrupts registers:
[120]349;       AX, DI
[88]350;--------------------------------------------------------------------
351ALIGN JUMP_ALIGN
[192]352BootMenuPrint_ClearInformationArea:
353    CALL_MENU_LIBRARY ClearInformationArea
354    stc
[88]355    ret
356
[192]357       
[88]358;--------------------------------------------------------------------
[192]359; BootMenuPrint_ClearScreen
[88]360;   Parameters:
[192]361;       Nothing
[88]362;   Returns:
[192]363;       Nothing
[88]364;   Corrupts registers:
[192]365;       AX, DI
[88]366;--------------------------------------------------------------------
367ALIGN JUMP_ALIGN
[192]368BootMenuPrint_ClearScreen:
369    call    BootMenuPrint_InitializeDisplayContext
370    xor     ax, ax
371    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
372    mov     ax, ' ' | (MONO_NORMAL<<8)
373    CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
374    ret
[88]375
[192]376       
[88]377;--------------------------------------------------------------------
[192]378; PrintDriveNumberAfterTranslationFromDL
[88]379;   Parameters:
[192]380;       DL:     Untranslated Floppy Drive number
381;       DS:     RAMVARS segment
382;   Returns:
[88]383;       Nothing
384;   Corrupts registers:
385;       AX, DI
386;--------------------------------------------------------------------
387ALIGN JUMP_ALIGN
[192]388PrintDriveNumberAfterTranslationFromDL:
389    mov     ax, dx
390    call    DriveXlate_ToOrBack
391    xchg    dx, ax              ; Restore DX, WORD to print in AL
392    xor     ah, ah
393    push    bp
394    mov     bp, sp
395    mov     si, g_szDriveNum
396    push    ax
397       
398BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay: 
399    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[88]400
401
402;--------------------------------------------------------------------
403; BootMenuPrint_TheBottomOfScreen
[3]404;   Parameters:
405;       DS:     RAMVARS segment
406;   Returns:
[88]407;       Nothing
[3]408;   Corrupts registers:
[92]409;       AX, BX, CX, DX, SI, DI
[3]410;--------------------------------------------------------------------
411ALIGN JUMP_ALIGN
[88]412BootMenuPrint_TheBottomOfScreen:
[124]413    call    FloppyDrive_GetCountToCX
[88]414    mov     bl, cl                  ; Floppy Drive count to BL
415    call    RamVars_GetHardDiskCountFromBDAtoCX
416    mov     bh, cl                  ; Hard Disk count to BH
[92]417    ; Fall to .MoveCursorToHotkeyStrings
[3]418
[92]419;--------------------------------------------------------------------
420; .MoveCursorToHotkeyStrings
421;   Parameters:
422;       Nothing
423;   Returns:
424;       Nothing
425;   Corrupts registers:
426;       AX, DI
427;--------------------------------------------------------------------
428.MoveCursorToHotkeyStrings:
429    CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
430    xor     al, al
431    dec     ah
432    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
433    ; Fall to .PrintHotkeyString
[3]434
435;--------------------------------------------------------------------
[92]436; .PrintHotkeyString
[3]437;   Parameters:
[92]438;       BL:     Floppy Drives
439;       BH:     Hard Drives
[88]440;   Returns:
[92]441;       Nothing
[88]442;   Corrupts registers:
[120]443;       AX, CX, DX, SI, DI
[88]444;--------------------------------------------------------------------
[92]445.PrintHotkeyString:
446    ; Display Library should not be called like this
447    mov     si, ATTRIBUTE_CHARS.cHighlightedItem
448    call    MenuAttribute_GetToAXfromTypeInSI
449    xchg    dx, ax
[122]450    mov     cx, MONO_BRIGHT
[88]451
[92]452    test    bl, bl      ; Any Floppy Drives?
453    jz      SHORT .SkipFloppyDriveHotkeys
454    mov     ax, 'A' | (ANGLE_QUOTE_RIGHT<<8)
455    mov     si, g_szFDD
456    call    PushHotkeyParamsAndFormat
[88]457
[92]458.SkipFloppyDriveHotkeys:
459    test    bh, bh      ; Any Hard Drives?
460    jz      SHORT .SkipHardDriveHotkeys
[122]461    xchg    ax, cx      ; Store Key Attribute
[92]462    call    BootMenu_GetLetterForFirstHardDiskToCL
463    mov     ch, ANGLE_QUOTE_RIGHT
464    xchg    ax, cx
465    mov     si, g_szHDD
466    call    PushHotkeyParamsAndFormat
467
468.SkipHardDriveHotkeys:
469    ; Fall to .PrintRomBootHotkey
470
[88]471;--------------------------------------------------------------------
[92]472; .PrintRomBootHotkey
[88]473;   Parameters:
[92]474;       CX:     Key Attribute
475;       DX:     Description Attribute
[3]476;   Returns:
[88]477;       Nothing
[3]478;   Corrupts registers:
[120]479;       AX, SI, DI
[3]480;--------------------------------------------------------------------
[92]481.PrintRomBootHotkey:
482    mov     ax, 'F' | ('8'<<8)      ; F8
483    mov     si, g_szRomBoot
484    ; Fall to PushHotkeyParamsAndFormat
485
486;--------------------------------------------------------------------
487; PushHotkeyParamsAndFormat
488;   Parameters:
489;       AL:     First character
490;       AH:     Second character
491;       CX:     Key Attribute
492;       DX:     Description Attribute
493;       CS:SI:  Description string
494;   Returns:
495;       Nothing
496;   Corrupts registers:
[120]497;       AX, SI, DI
[92]498;--------------------------------------------------------------------
[3]499ALIGN JUMP_ALIGN
[92]500PushHotkeyParamsAndFormat:
501    push    bp
502    mov     bp, sp
503
504    push    cx          ; Key attribute
505    push    ax          ; First character
506    xchg    al, ah
507    push    ax          ; Second character
508    push    dx          ; Description attribute
509    push    si          ; Description string
510    push    cx          ; Key attribute for last space
511    mov     si, g_szHotkey
[192]512    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay
[161]513
[182]514
[192]515;--------------------------------------------------------------------
516; BootMenuPrint_InitializeDisplayContext
517;   Parameters:
518;       Nothing
519;   Returns:
520;       Nothing
521;   Corrupts registers:
522;       AX, DI
523;--------------------------------------------------------------------
524ALIGN JUMP_ALIGN
525BootMenuPrint_InitializeDisplayContext:
526    CALL_DISPLAY_LIBRARY InitializeDisplayContext
527    ret
528
529
530       
531
532
533       
Note: See TracBrowser for help on using the repository browser.