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

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

Additional space optimizations, including making IdleProcessing an option in MENUEVENT. Note the fall-through from one file to another, but that there are assembler checks to ensure the proper linkage is maintained. First version of StringsCompress.pl, a perl script to make StringsCompressed.asm from Strings.asm.

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