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

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

More comments for changes to BootMenuEvent and BootMenuPrint.

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