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

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

ifdef'd out more unused code. Also added a tool for looking through the listing and the output of the precompiler to aid in finding dead code. Some changes in the files are to add annotations for the tool to avoid false positives.

File size: 15.5 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
256;   Corrupts registers:
257;       AX, DI
258;--------------------------------------------------------------------
259ALIGN JUMP_ALIGN
260BootMenuPrint_FormatCSSIfromParamsInSSBP:
261    CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
262    stc             ; Successfull return from menu event
263    pop     bp
264    ret     
265
266       
267;--------------------------------------------------------------------
[3]268; Prints Hard Disk Menuitem information strings.
269;
270; BootMenuPrint_HardDiskMenuitemInformation
271;   Parameters:
272;       DL:     Untranslated Hard Disk number
273;       DS:     RAMVARS segment
274;   Returns:
[88]275;       CF:     Set since menu event was handled successfully
[3]276;   Corrupts registers:
277;       BX, CX, DX, SI, DI, ES
278;--------------------------------------------------------------------
279ALIGN JUMP_ALIGN
280BootMenuPrint_HardDiskMenuitemInformation:
[150]281    call    RamVars_IsDriveHandledByThisBIOS
282    jnc     SHORT .HardDiskMenuitemInfoForForeignDrive
[3]283    call    FindDPT_ForDriveNumber      ; DS:DI to point DPT
[127]284    ; Fall to .HardDiskMenuitemInfoForOurDrive
[3]285
286;--------------------------------------------------------------------
[127]287; .HardDiskMenuitemInfoForOurDrive
[3]288;   Parameters:
289;       DL:     Untranslated Hard Disk number
[127]290;       DS:DI:  Ptr to DPT
[3]291;   Returns:
[127]292;       Nothing
[3]293;   Corrupts registers:
[127]294;       AX, BX, CX, DX, SI, DI, ES
[3]295;--------------------------------------------------------------------
[127]296.HardDiskMenuitemInfoForOurDrive:
297    push    di
298    ePUSH_T ax, BootMenuPrintCfg_ForOurDrive    ; Return from BootMenuPrint_FormatCSSIfromParamsInSSBP
[88]299    push    bp
300    mov     bp, sp
301    ePUSH_T ax, g_szCapacity
302
[127]303    ; Get and push L-CHS size
[155]304    mov     [RAMVARS.bTimeoutTicksLeft], dl     ; Store drive number
[150]305    call    AH15h_GetSectorCountToDXAX
[88]306    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
307
[127]308    ; Get and push total LBA size
[155]309    mov     dl, [RAMVARS.bTimeoutTicksLeft]     ; Restore drive number
[127]310    call    BootInfo_GetTotalSectorCount
311    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
312
313    mov     si, g_szSizeDual
[88]314    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]315
[127]316
[3]317;--------------------------------------------------------------------
[127]318; .HardDiskMenuitemInfoForForeignDrive
[3]319;   Parameters:
320;       DL:     Untranslated Hard Disk number
[127]321;       DS:     RAMVARS segment
[3]322;   Returns:
[127]323;       CF:     Set since menu event was handled successfully
[3]324;   Corrupts registers:
[127]325;       AX, BX, CX, DX, SI, DI
[3]326;--------------------------------------------------------------------
327ALIGN JUMP_ALIGN
[127]328.HardDiskMenuitemInfoForForeignDrive:
[88]329    push    bp
330    mov     bp, sp
331    ePUSH_T ax, g_szCapacity
[3]332
[127]333    call    DriveXlate_ToOrBack
[150]334    call    AH15h_GetSectorCountFromForeignDriveToDXAX
[88]335    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
336
[127]337    mov     si, g_szSizeSingle
[192]338    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]339
[192]340       
[3]341;--------------------------------------------------------------------
[192]342; BootMenuPrint_ClearInformationArea
[88]343;   Parameters:
[192]344;       Nothing
[88]345;   Returns:
[192]346;       CF:     Set
[88]347;   Corrupts registers:
[120]348;       AX, DI
[88]349;--------------------------------------------------------------------
350ALIGN JUMP_ALIGN
[192]351BootMenuPrint_ClearInformationArea:
352    CALL_MENU_LIBRARY ClearInformationArea
353    stc
[88]354    ret
355
[192]356       
[88]357;--------------------------------------------------------------------
[192]358; BootMenuPrint_ClearScreen
[88]359;   Parameters:
[192]360;       Nothing
[88]361;   Returns:
[192]362;       Nothing
[88]363;   Corrupts registers:
[192]364;       AX, DI
[88]365;--------------------------------------------------------------------
366ALIGN JUMP_ALIGN
[192]367BootMenuPrint_ClearScreen:
368    call    BootMenuPrint_InitializeDisplayContext
369    xor     ax, ax
370    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
371    mov     ax, ' ' | (MONO_NORMAL<<8)
372    CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
373    ret
[88]374
[192]375       
[88]376;--------------------------------------------------------------------
[192]377; PrintDriveNumberAfterTranslationFromDL
[88]378;   Parameters:
[192]379;       DL:     Untranslated Floppy Drive number
380;       DS:     RAMVARS segment
381;   Returns:
[88]382;       Nothing
383;   Corrupts registers:
384;       AX, DI
385;--------------------------------------------------------------------
386ALIGN JUMP_ALIGN
[192]387PrintDriveNumberAfterTranslationFromDL:
388    mov     ax, dx
389    call    DriveXlate_ToOrBack
390    xchg    dx, ax              ; Restore DX, WORD to print in AL
391    xor     ah, ah
392    push    bp
393    mov     bp, sp
394    mov     si, g_szDriveNum
395    push    ax
396       
397BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay: 
398    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
[88]399
400
401;--------------------------------------------------------------------
402; BootMenuPrint_TheBottomOfScreen
[3]403;   Parameters:
404;       DS:     RAMVARS segment
405;   Returns:
[88]406;       Nothing
[3]407;   Corrupts registers:
[92]408;       AX, BX, CX, DX, SI, DI
[3]409;--------------------------------------------------------------------
410ALIGN JUMP_ALIGN
[88]411BootMenuPrint_TheBottomOfScreen:
[124]412    call    FloppyDrive_GetCountToCX
[88]413    mov     bl, cl                  ; Floppy Drive count to BL
414    call    RamVars_GetHardDiskCountFromBDAtoCX
415    mov     bh, cl                  ; Hard Disk count to BH
[92]416    ; Fall to .MoveCursorToHotkeyStrings
[3]417
[92]418;--------------------------------------------------------------------
419; .MoveCursorToHotkeyStrings
420;   Parameters:
421;       Nothing
422;   Returns:
423;       Nothing
424;   Corrupts registers:
425;       AX, DI
426;--------------------------------------------------------------------
427.MoveCursorToHotkeyStrings:
428    CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
429    xor     al, al
430    dec     ah
431    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
432    ; Fall to .PrintHotkeyString
[3]433
434;--------------------------------------------------------------------
[92]435; .PrintHotkeyString
[3]436;   Parameters:
[92]437;       BL:     Floppy Drives
438;       BH:     Hard Drives
[88]439;   Returns:
[92]440;       Nothing
[88]441;   Corrupts registers:
[120]442;       AX, CX, DX, SI, DI
[88]443;--------------------------------------------------------------------
[92]444.PrintHotkeyString:
445    ; Display Library should not be called like this
446    mov     si, ATTRIBUTE_CHARS.cHighlightedItem
447    call    MenuAttribute_GetToAXfromTypeInSI
448    xchg    dx, ax
[122]449    mov     cx, MONO_BRIGHT
[88]450
[92]451    test    bl, bl      ; Any Floppy Drives?
452    jz      SHORT .SkipFloppyDriveHotkeys
453    mov     ax, 'A' | (ANGLE_QUOTE_RIGHT<<8)
454    mov     si, g_szFDD
455    call    PushHotkeyParamsAndFormat
[88]456
[92]457.SkipFloppyDriveHotkeys:
458    test    bh, bh      ; Any Hard Drives?
459    jz      SHORT .SkipHardDriveHotkeys
[122]460    xchg    ax, cx      ; Store Key Attribute
[92]461    call    BootMenu_GetLetterForFirstHardDiskToCL
462    mov     ch, ANGLE_QUOTE_RIGHT
463    xchg    ax, cx
464    mov     si, g_szHDD
465    call    PushHotkeyParamsAndFormat
466
467.SkipHardDriveHotkeys:
468    ; Fall to .PrintRomBootHotkey
469
[88]470;--------------------------------------------------------------------
[92]471; .PrintRomBootHotkey
[88]472;   Parameters:
[92]473;       CX:     Key Attribute
474;       DX:     Description Attribute
[3]475;   Returns:
[88]476;       Nothing
[3]477;   Corrupts registers:
[120]478;       AX, SI, DI
[3]479;--------------------------------------------------------------------
[92]480.PrintRomBootHotkey:
481    mov     ax, 'F' | ('8'<<8)      ; F8
482    mov     si, g_szRomBoot
483    ; Fall to PushHotkeyParamsAndFormat
484
485;--------------------------------------------------------------------
486; PushHotkeyParamsAndFormat
487;   Parameters:
488;       AL:     First character
489;       AH:     Second character
490;       CX:     Key Attribute
491;       DX:     Description Attribute
492;       CS:SI:  Description string
493;   Returns:
494;       Nothing
495;   Corrupts registers:
[120]496;       AX, SI, DI
[92]497;--------------------------------------------------------------------
[3]498ALIGN JUMP_ALIGN
[92]499PushHotkeyParamsAndFormat:
500    push    bp
501    mov     bp, sp
502
503    push    cx          ; Key attribute
504    push    ax          ; First character
505    xchg    al, ah
506    push    ax          ; Second character
507    push    dx          ; Description attribute
508    push    si          ; Description string
509    push    cx          ; Key attribute for last space
510    mov     si, g_szHotkey
[192]511    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay
[161]512
[182]513
[192]514;--------------------------------------------------------------------
515; BootMenuPrint_InitializeDisplayContext
516;   Parameters:
517;       Nothing
518;   Returns:
519;       Nothing
520;   Corrupts registers:
521;       AX, DI
522;--------------------------------------------------------------------
523ALIGN JUMP_ALIGN
524BootMenuPrint_InitializeDisplayContext:
525    CALL_DISPLAY_LIBRARY InitializeDisplayContext
526    ret
527
528
529       
530
531
532       
Note: See TracBrowser for help on using the repository browser.