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

Last change on this file since 127 was 127, checked in by aitotat, 13 years ago

Changes to XTIDE Universal BIOS:

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