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

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

Initial string compression checkin. All changes are under MODULE_STRINGS_COMPRESSED, and this can still be turned off. With this checkin, the serial and ebios code can both be turned on at the same time and still we remain below the 8K boundary (barely). I still need to chekin StringsCompress.pl after some more code cleanup. The output, in StringsCompressed.asm is checked in here, and should continue be to checkin when Strings.asm is changed, for those who do not have/want to run the Perl script to recreate it.

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