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

Last change on this file since 128 was 128, checked in by krille_n_@…, 13 years ago

Changes to the XTIDE Universal BIOS:

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