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
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    jmp     BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
25
26
27;--------------------------------------------------------------------
28; BootMenuPrint_ClearScreen
29;   Parameters:
30;       Nothing
31;   Returns:
32;       Nothing
33;   Corrupts registers:
34;       AX, DI
35;--------------------------------------------------------------------
36ALIGN JUMP_ALIGN
37BootMenuPrint_ClearScreen:
38    mov     ax, ' ' | (MONO_NORMAL<<8)
39    CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
40    ret
41
42
43;--------------------------------------------------------------------
44; BootMenuPrint_FloppyMenuitem
45;   Parameters:
46;       DL:     Untranslated Floppy Drive number
47;   Returns:
48;       Nothing
49;   Corrupts registers:
50;       AX, DX, SI, DI
51;--------------------------------------------------------------------
52ALIGN JUMP_ALIGN
53BootMenuPrint_FloppyMenuitem:
54    push    bp
55
56    mov     bp, sp
57    mov     si, g_szFDLetter
58    ePUSH_T ax, g_szFloppyDrv
59    add     dl, 'A'
60    push    dx                  ; Drive letter
61    jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
62
63
64;--------------------------------------------------------------------
65; BootMenuPrint_HardDiskMenuitem
66;   Parameters:
67;       DL:     Untranslated Hard Disk number
68;       DS:     RAMVARS segment
69;   Returns:
70;       CF:     Set since menu event handled
71;   Corrupts registers:
72;       AX, BX, SI, DI
73;--------------------------------------------------------------------
74ALIGN JUMP_ALIGN
75BootMenuPrint_HardDiskMenuitem:
76    call    FindDPT_ForDriveNumber      ; DS:DI to point DPT
77    jnc     SHORT .HardDiskMenuitemForForeignDrive
78    ; Fall to .HardDiskMenuitemForOurDrive
79
80;--------------------------------------------------------------------
81; .HardDiskMenuitemForOurDrive
82;   Parameters:
83;       DL:     Untranslated Hard Disk number
84;       DS:     RAMVARS segment
85;   Returns:
86;       CF:     Set since menu event handled
87;   Corrupts registers:
88;       AX, BX, SI, DI
89;--------------------------------------------------------------------
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
97
98;--------------------------------------------------------------------
99; BootMenuPrint_HardDiskMenuitemForForeignDrive
100;   Parameters:
101;       DL:     Untranslated Hard Disk number
102;       DS:     RAMVARS segment
103;   Returns:
104;       CF:     Set since menu event handled
105;   Corrupts registers:
106;       AX, SI, DI
107;--------------------------------------------------------------------
108ALIGN JUMP_ALIGN
109.HardDiskMenuitemForForeignDrive:
110    mov     si, g_szforeignHD
111    jmp     BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
112
113
114;--------------------------------------------------------------------
115; BootMenuPrint_FloppyMenuitemInformation
116;   Parameters:
117;       DL:     Untranslated Floppy Drive number
118;       DS:     RAMVARS segment
119;   Returns:
120;       CF:     Set since menu event was handled successfully
121;   Corrupts registers:
122;       AX, BX, CX, DX, SI, DI, ES
123;--------------------------------------------------------------------
124ALIGN JUMP_ALIGN
125BootMenuPrint_FloppyMenuitemInformation:
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
130    cmp     bl, FLOPPY_TYPE_35_ED
131    ja      SHORT .PrintUnknownFloppyType
132    jmp     SHORT .PrintKnownFloppyType
133
134;--------------------------------------------------------------------
135; .PrintXTFloppyType
136;   Parameters:
137;       Nothing
138;   Returns:
139;       CF:     Set since menu event was handled successfully
140;   Corrupts registers:
141;       AX, SI, DI
142;--------------------------------------------------------------------
143ALIGN JUMP_ALIGN
144.PrintXTFloppyType:
145    push    bp
146    mov     si, g_szFddSizeOr
147    jmp     SHORT .FormatXTorUnknownTypeFloppyDrive
148
149;--------------------------------------------------------------------
150; .PrintUnknownFloppyType
151;   Parameters:
152;       Nothing
153;   Returns:
154;       CF:     Set since menu event was handled successfully
155;   Corrupts registers:
156;       AX, SI, DI
157;--------------------------------------------------------------------
158ALIGN JUMP_ALIGN
159.PrintUnknownFloppyType:
160    push    bp
161    mov     si, g_szFddUnknown
162.FormatXTorUnknownTypeFloppyDrive:
163    mov     bp, sp
164    ePUSH_T ax, g_szCapacity
165    jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
166
167;--------------------------------------------------------------------
168; .PrintKnownFloppyType
169;   Parameters:
170;       BX:     Floppy drive type
171;   Returns:
172;       CF:     Set since menu event was handled successfully
173;   Corrupts registers:
174;       AX, BX, SI, DI
175;--------------------------------------------------------------------
176ALIGN JUMP_ALIGN
177.PrintKnownFloppyType:
178    push    bp
179
180    mov     bp, sp
181    mov     si, g_szFddSize
182    ePUSH_T ax, g_szCapacity
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]
186    push    ax                      ; '5' or '3'
187    mov     al, ah
188    push    ax                      ; '1/4' or '1/2'
189    push    WORD [cs:bx+.rgwCapacity]
190    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
191
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:
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
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:
217;       CF:     Set since menu event was handled successfully
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
224    jnc     SHORT .HardDiskMenuitemInfoForForeignDrive
225    ; Fall to .HardDiskMenuitemInfoForOurDrive
226
227;--------------------------------------------------------------------
228; .HardDiskMenuitemInfoForOurDrive
229;   Parameters:
230;       DL:     Untranslated Hard Disk number
231;       DS:DI:  Ptr to DPT
232;   Returns:
233;       Nothing
234;   Corrupts registers:
235;       AX, BX, CX, DX, SI, DI, ES
236;--------------------------------------------------------------------
237ALIGN JUMP_ALIGN
238.HardDiskMenuitemInfoForOurDrive:
239    push    di
240    ePUSH_T ax, BootMenuPrintCfg_ForOurDrive    ; Return from BootMenuPrint_FormatCSSIfromParamsInSSBP
241    push    bp
242    mov     bp, sp
243    ePUSH_T ax, g_szCapacity
244
245    ; Get and push L-CHS size
246    call    HCapacity_GetSectorCountFromOurAH08h
247    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
248
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
255    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
256
257
258;--------------------------------------------------------------------
259; .HardDiskMenuitemInfoForForeignDrive
260;   Parameters:
261;       DL:     Untranslated Hard Disk number
262;       DS:     RAMVARS segment
263;   Returns:
264;       CF:     Set since menu event was handled successfully
265;   Corrupts registers:
266;       AX, BX, CX, DX, SI, DI
267;--------------------------------------------------------------------
268ALIGN JUMP_ALIGN
269.HardDiskMenuitemInfoForForeignDrive:
270    push    bp
271    mov     bp, sp
272    ePUSH_T ax, g_szCapacity
273
274    call    DriveXlate_ToOrBack
275    call    HCapacity_GetSectorCountFromForeignAH08h
276    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
277
278    mov     si, g_szSizeSingle
279    ; Fall to BootMenuPrint_FormatCSSIfromParamsInSSBP
280
281
282;--------------------------------------------------------------------
283; BootMenuPrint_FormatCSSIfromParamsInSSBP
284;   Parameters:
285;       CS:SI:  Ptr to string to format
286;       BP:     SP before pushing parameters
287;   Returns:
288;       BP:     Popped from stack
289;   Corrupts registers:
290;       AX, DI
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;--------------------------------------------------------------------
322; BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
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:
328;       AX
329;--------------------------------------------------------------------
330ALIGN JUMP_ALIGN
331BootMenuPrint_NullTerminatedStringFromCSSIandSetCF:
332    push    di
333    CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
334    pop     di
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
357;   Parameters:
358;       DS:     RAMVARS segment
359;   Returns:
360;       Nothing
361;   Corrupts registers:
362;       AX, BX, CX, DX, SI, DI
363;--------------------------------------------------------------------
364ALIGN JUMP_ALIGN
365BootMenuPrint_TheBottomOfScreen:
366    call    FloppyDrive_GetCountToCX
367    mov     bl, cl                  ; Floppy Drive count to BL
368    call    RamVars_GetHardDiskCountFromBDAtoCX
369    mov     bh, cl                  ; Hard Disk count to BH
370    ; Fall to .MoveCursorToHotkeyStrings
371
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
387
388;--------------------------------------------------------------------
389; .PrintHotkeyString
390;   Parameters:
391;       BL:     Floppy Drives
392;       BH:     Hard Drives
393;   Returns:
394;       Nothing
395;   Corrupts registers:
396;       AX, CX, DX, SI, DI
397;--------------------------------------------------------------------
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
403    mov     cx, MONO_BRIGHT
404
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
410
411.SkipFloppyDriveHotkeys:
412    test    bh, bh      ; Any Hard Drives?
413    jz      SHORT .SkipHardDriveHotkeys
414    xchg    ax, cx      ; Store Key Attribute
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
424;--------------------------------------------------------------------
425; .PrintRomBootHotkey
426;   Parameters:
427;       CX:     Key Attribute
428;       DX:     Description Attribute
429;   Returns:
430;       Nothing
431;   Corrupts registers:
432;       AX, SI, DI
433;--------------------------------------------------------------------
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:
450;       AX, SI, DI
451;--------------------------------------------------------------------
452ALIGN JUMP_ALIGN
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.