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

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

Changes to XTIDE Universal BIOS:

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