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

Last change on this file since 3 was 3, checked in by aitotat, 14 years ago
File size: 16.0 KB
Line 
1; File name     :   BootMenuPrint.asm
2; Project name  :   IDE BIOS
3; Created date  :   26.3.2010
4; Last update   :   12.4.2010
5; Author        :   Tomi Tilli
6; Description   :   Functions for printing boot menu strings.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; Prints information strings to the bottom of the screen.
13;
14; BootMenuPrint_TheBottomOfScreen
15;   Parameters:
16;       DS:     RAMVARS segment
17;   Returns:
18;       Nothing
19;   Corrupts registers:
20;       AX, BX, CX, DX, SI
21;--------------------------------------------------------------------
22ALIGN JUMP_ALIGN
23BootMenuPrint_TheBottomOfScreen:
24    call    FloppyDrive_GetCount
25    mov     bl, cl                  ; Floppy Drive count to BL
26    call    RamVars_GetDriveCounts
27    mov     bh, cl                  ; Hard Disk count to BH
28    call    BootMenuPrint_GetCoordinatesForBottomStrings
29    call    BootMenuPrint_SetCursorPosition
30    call    BootMenuPrint_FloppyHotkeyString
31    jmp     BootMenuPrint_HardDiskHotkeyString
32
33
34;--------------------------------------------------------------------
35; Returns coordinates for bottom strings.
36;
37; BootMenuPrint_GetCoordinatesForBottomStrings
38;   Parameters:
39;       BL:     Number of floppy drives in system
40;       BH:     Number of hard disks in system
41;   Returns:
42;       DL:     Cursor X coordinate
43;       DH:     Cursor Y coordinate
44;   Corrupts registers:
45;       AX
46;--------------------------------------------------------------------
47ALIGN JUMP_ALIGN
48BootMenuPrint_GetCoordinatesForBottomStrings:
49    mov     dx, 1800h               ; (0, 24)
50    xor     ax, ax                  ; Zero AX
51    sub     al, bl                  ; Set CF if any floppy drives
52    sbb     dh, 0                   ; Decrement Y-coordinate if necessary
53    sub     ah, bh                  ; Set CF if any hard disks
54    sbb     dh, 0                   ; Decrement Y-coordinate if necessary
55    ret
56
57
58;--------------------------------------------------------------------
59; Sets cursor to wanted screen coordinates.
60;
61; BootMenuPrint_SetCursorPosition
62;   Parameters:
63;       DL:     Cursor X coordinate
64;       DH:     Cursor Y coordinate
65;   Returns:
66;       Nothing
67;   Corrupts registers:
68;       AX
69;--------------------------------------------------------------------
70ALIGN JUMP_ALIGN
71BootMenuPrint_SetCursorPosition:
72    push    bx
73    call    MenuCrsr_SetCursor
74    pop     bx
75    ret
76
77
78;--------------------------------------------------------------------
79; Prints Floppy Drive hotkey string.
80;
81; BootMenuPrint_FloppyHotkeyString
82;   Parameters:
83;       BL:     Number of floppy drives in system
84;   Returns:
85;       Nothing
86;   Corrupts registers:
87;       AX, CX, DX, SI
88;--------------------------------------------------------------------
89ALIGN JUMP_ALIGN
90BootMenuPrint_FloppyHotkeyString:
91    test    bl, bl                  ; Any floppy drives?
92    jz      .Return
93    ePUSH_T ax, g_szHDD
94    ePUSH_T ax, g_szFDD
95    mov     ax, 'A'-1
96    add     al, bl                  ; Last Floppy Drive letter
97    push    ax
98    ePUSH_T ax, 'A'
99    jmp     SHORT BootMenuPrint_HotkeyString
100.Return:
101    ret
102
103;--------------------------------------------------------------------
104; Prints Floppy Drive or Hard Disk hotkey string when
105; parameters are pushed to stack.
106;
107; BootMenuPrint_HotkeyString
108;   Parameters:
109;       Stack:  String formatting parameters
110;   Returns:
111;       Nothing
112;   Corrupts registers:
113;       AX, CX, DX, SI
114;--------------------------------------------------------------------
115ALIGN JUMP_ALIGN
116BootMenuPrint_HotkeyString:
117    mov     si, g_szBottomScrn
118    mov     dh, 8                   ; 8 bytes pushed to stack
119    jmp     PrintString_JumpToFormat
120
121
122;--------------------------------------------------------------------
123; Prints Hard Disk hotkey string.
124;
125; BootMenuPrint_FloppyHotkeyString
126;   Parameters:
127;       BH:     Number of hard disks in system
128;   Returns:
129;       Nothing
130;   Corrupts registers:
131;       AX, CX, DX, SI
132;--------------------------------------------------------------------
133ALIGN JUMP_ALIGN
134BootMenuPrint_HardDiskHotkeyString:
135    test    bh, bh                  ; Any hard disks?
136    jz      .Return
137    ePUSH_T ax, g_szFDD
138    ePUSH_T ax, g_szHDD
139    call    BootMenu_GetLetterForFirstHardDisk
140    eMOVZX  ax, bh                  ; Hard disk count to AX
141    add     ax, cx                  ; One past last hard disk letter
142    dec     ax                      ; Last hard disk letter
143    push    ax
144    push    cx
145    jmp     SHORT BootMenuPrint_HotkeyString
146.Return:
147    ret
148
149
150;--------------------------------------------------------------------
151; Clears screen.
152;
153; BootMenuPrint_ClearScreen
154;   Parameters:
155;       Nothing
156;   Returns:
157;       Nothing
158;   Corrupts registers:
159;       AX, BX, DX
160;--------------------------------------------------------------------
161ALIGN JUMP_ALIGN
162BootMenuPrint_ClearScreen:
163    push    cx
164    call    MenuDraw_ClrScr
165    pop     cx
166    ret
167
168
169;--------------------------------------------------------------------
170; Translates and prints drive number.
171;
172; BootMenuPrint_TranslatedDriveNumber
173;   Parameters:
174;       DL:     Untranslated drive number
175;       DS:     RAMVARS segment
176;   Returns:
177;       Nothing
178;   Corrupts registers:
179;       AX, DI
180;--------------------------------------------------------------------
181ALIGN JUMP_ALIGN
182BootMenuPrint_TranslatedDriveNumber:
183    push    dx
184    call    DriveXlate_ToOrBack
185    mov     al, dl                      ; Drive number to AL
186    call    Print_IntHexB
187    mov     dl, ' '
188    PRINT_CHAR                          ; Print space
189    pop     dx
190    ret
191
192
193;--------------------------------------------------------------------
194; Prints Floppy Drive Menuitem string.
195;
196; BootMenuPrint_FloppyMenuitem
197;   Parameters:
198;       DL:     Untranslated Floppy Drive number
199;   Returns:
200;       AX:     1 if drive number was valid
201;               0 if drive number was invalid
202;   Corrupts registers:
203;       CX, DX, SI
204;--------------------------------------------------------------------
205ALIGN JUMP_ALIGN
206BootMenuPrint_FloppyMenuitem:
207    ePUSH_T ax, BootMenuPrint_HardDiskPrinted   ; Return address
208    add     dl, 'A'             ; Number to letter
209    push    dx
210    ePUSH_T ax, g_szFloppyDrv
211    mov     si, g_szFDLetter
212    mov     dh, 4               ; 4 bytes pushed to stack
213    jmp     PrintString_JumpToFormat
214
215
216;--------------------------------------------------------------------
217; Prints Hard Disk Menuitem string.
218;
219; BootMenuPrint_HardDiskMenuitem
220;   Parameters:
221;       DL:     Untranslated Hard Disk number
222;       DS:     RAMVARS segment
223;   Returns:
224;       AX:     1 if drive number was valid
225;               0 if drive number was invalid
226;   Corrupts registers:
227;       CX, DX, SI, ES
228;--------------------------------------------------------------------
229ALIGN JUMP_ALIGN
230BootMenuPrint_HardDiskMenuitem:
231    ePUSH_T ax, BootMenuPrint_HardDiskPrinted
232    call    FindDPT_ForDriveNumber      ; DS:DI to point DPT
233    jnc     SHORT BootMenuPrint_HardDiskMenuitemForForeignDrive
234    jmp     SHORT BootMenuPrint_HardDiskMenuitemForOurDrive
235ALIGN JUMP_ALIGN
236BootMenuPrint_HardDiskPrinted:
237    mov     ax, 1
238    ret
239
240;--------------------------------------------------------------------
241; Prints Hard Disk Menuitem string for drive that is handled by
242; some another BIOS.
243;
244; BootMenuPrint_HardDiskMenuitemForForeignDrive
245;   Parameters:
246;       DL:     Untranslated Hard Disk number
247;       DS:     RAMVARS segment
248;   Returns:
249;       AX:     1 if drive number was valid
250;               0 if drive number was invalid
251;   Corrupts registers:
252;       CX, DX, SI
253;--------------------------------------------------------------------
254ALIGN JUMP_ALIGN
255BootMenuPrint_HardDiskMenuitemForForeignDrive:
256    mov     si, g_szforeignHD
257    jmp     PrintString_FromCS
258
259;--------------------------------------------------------------------
260; Prints Hard Disk Menuitem string for drive that is handled by our BIOS.
261;
262; BootMenuPrint_HardDiskMenuitemForOurDrive
263;   Parameters:
264;       DL:     Untranslated Hard Disk number
265;       DS:     RAMVARS segment
266;   Returns:
267;       AX:     1 if drive number was valid
268;               0 if drive number was invalid
269;   Corrupts registers:
270;       CX, DX, SI, ES
271;--------------------------------------------------------------------
272ALIGN JUMP_ALIGN
273BootMenuPrint_HardDiskMenuitemForOurDrive:
274    call    BootInfo_GetOffsetToBX
275    LOAD_BDA_SEGMENT_TO es, ax
276    lea     si, [bx+BOOTNFO.szDrvName]
277    jmp     PrintString_FromES
278
279
280;--------------------------------------------------------------------
281; Prints Function Menuitem string.
282;
283; BootMenuPrint_FunctionMenuitem
284;   Parameters:
285;       DX:     Function ID
286;   Returns:
287;       AX:     1 if function ID was valid
288;               0 if function ID was invalid
289;   Corrupts registers:
290;       DX, SI
291;--------------------------------------------------------------------
292ALIGN JUMP_ALIGN
293BootMenuPrint_FunctionMenuitem:
294    test    dx, dx                  ; ID_BOOTFUNC_ROMBOOT
295    jz      SHORT .PrintRomBootMenuitem
296    xor     ax, ax                  ; Event not processed
297    ret
298
299ALIGN JUMP_ALIGN
300.PrintRomBootMenuitem:
301    mov     si, g_szRomBoot
302    ; Fall to .PrintAndReturn
303
304ALIGN JUMP_ALIGN
305.PrintAndReturn:
306    call    PrintString_FromCS
307    mov     ax, 1                   ; Event processed
308    ret
309
310
311;--------------------------------------------------------------------
312; Prints Floppy Drive Menuitem information strings.
313;
314; BootMenuPrint_FloppyMenuitemInformation
315;   Parameters:
316;       DL:     Untranslated Floppy Drive number
317;       DS:     RAMVARS segment
318;   Returns:
319;       AX:     1 if drive number was valid
320;               0 if drive number was invalid
321;   Corrupts registers:
322;       BX, CX, DX, SI, DI, ES
323;--------------------------------------------------------------------
324ALIGN JUMP_ALIGN
325BootMenuPrint_FloppyMenuitemInformation:
326    call    FloppyDrive_GetType                     ; Get Floppy Drive type to BX
327    ePUSH_T ax, BootMenuPrint_ClearThreeInfoLines   ; New return address
328    test    bx, bx                                  ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)
329    jz      SHORT BootMenuPrint_PrintXTFloppyType
330    cmp     bl, FLOPPY_TYPE_35_ED
331    ja      SHORT BootMenuPrint_PrintUnknownFloppyType
332    jmp     SHORT BootMenuPrint_PrintKnownFloppyType
333
334;--------------------------------------------------------------------
335; Prints Menuitem information string for two possible XT floppy drives.
336;
337; BootMenuPrint_PrintXTFloppyType
338;   Parameters:
339;       Nothing
340;   Returns:
341;       Nothing
342;   Corrupts registers:
343;       CX, DX, SI
344;--------------------------------------------------------------------
345ALIGN JUMP_ALIGN
346BootMenuPrint_PrintXTFloppyType:
347    mov     si, g_szFddSizeOr
348    jmp     SHORT BootMenuPrint_FormatUnknownFloppyType
349
350;--------------------------------------------------------------------
351; Prints Menuitem information string for unknown floppy drive type.
352;
353; BootMenuPrint_PrintUnknownFloppyType
354;   Parameters:
355;       Nothing
356;   Returns:
357;       Nothing
358;   Corrupts registers:
359;       CX, DX, SI
360;--------------------------------------------------------------------
361ALIGN JUMP_ALIGN
362BootMenuPrint_PrintUnknownFloppyType:
363    mov     si, g_szFddUnknown
364BootMenuPrint_FormatUnknownFloppyType:
365    ePUSH_T ax, g_szCapacity
366    mov     dh, 2                   ; 2 bytes pushed to stack
367    jmp     PrintString_JumpToFormat
368
369;--------------------------------------------------------------------
370; Prints Menuitem information string for known floppy drive type.
371;
372; BootMenuPrint_PrintKnownFloppyType
373;   Parameters:
374;       BX:     Floppy drive type
375;   Returns:
376;       Nothing
377;   Corrupts registers:
378;       CX, DX, SI
379;--------------------------------------------------------------------
380ALIGN JUMP_ALIGN
381BootMenuPrint_PrintKnownFloppyType:
382    dec     bx                      ; Cannot be 0 (FLOPPY_TYPE_525_OR_35_DD)
383    shl     bx, 1                   ; Shift for WORD lookup
384    push    WORD [cs:bx+.rgwCapacity]
385    mov     ax, [cs:bx+.rgwPhysicalSize]
386    push    ax                      ; '1/4' or '1/2'
387    mov     al, ah
388    push    ax                      ; '5' or '3'
389    ePUSH_T ax, g_szCapacity
390    mov     si, g_szFddSize
391    mov     dh, 8                   ; 8 bytes pushed to stack
392    jmp     PrintString_JumpToFormat
393ALIGN WORD_ALIGN
394.rgwCapacity:
395    dw      360
396    dw      1200
397    dw      720
398    dw      1440
399    dw      2880
400    dw      2880
401.rgwPhysicalSize:
402    db      172, '5'    ; 1, FLOPPY_TYPE_525_DD
403    db      172, '5'    ; 2, FLOPPY_TYPE_525_HD
404    db      171, '3'    ; 3, FLOPPY_TYPE_35_DD
405    db      171, '3'    ; 4, FLOPPY_TYPE_35_HD
406    db      171, '3'    ; 5, 3.5" ED on some BIOSes
407    db      171, '3'    ; 6, FLOPPY_TYPE_35_ED
408
409
410;--------------------------------------------------------------------
411; Clears remaining characters from current information line
412; and clears following lines.
413;
414; BootMenuPrint_ClearThreeInfoLines
415; BootMenuPrint_ClearTwoInfoLines
416; BootMenuPrint_ClearOneInfoLine
417;   Parameters:
418;       Nothing
419;   Returns:
420;       AX:     1
421;   Corrupts registers:
422;       BX, DX
423;--------------------------------------------------------------------
424ALIGN JUMP_ALIGN
425BootMenuPrint_ClearThreeInfoLines:
426    call    MenuDraw_NewlineStrClrLn
427ALIGN JUMP_ALIGN
428BootMenuPrint_ClearTwoInfoLines:
429    call    MenuDraw_NewlineStrClrLn
430ALIGN JUMP_ALIGN
431BootMenuPrint_ClearOneInfoLine:
432    call    MenuDraw_NewlineStrClrLn
433    mov     ax, 1
434    ret
435
436
437;--------------------------------------------------------------------
438; Prints Hard Disk Menuitem information strings.
439;
440; BootMenuPrint_HardDiskMenuitemInformation
441;   Parameters:
442;       DL:     Untranslated Hard Disk number
443;       DS:     RAMVARS segment
444;   Returns:
445;       AX:     1 if drive number was valid
446;               0 if drive number was invalid
447;   Corrupts registers:
448;       BX, CX, DX, SI, DI, ES
449;--------------------------------------------------------------------
450ALIGN JUMP_ALIGN
451BootMenuPrint_HardDiskMenuitemInformation:
452    ePUSH_T ax, BootMenuPrint_HardDiskPrinted
453    call    FindDPT_ForDriveNumber      ; DS:DI to point DPT
454    jnc     SHORT BootMenuPrint_HardDiskMenuitemInfoForForeignDrive
455    call    BootMenuPrint_HardDiskMenuitemInfoSizeForOurDrive
456    jmp     BootMenuPrintCfg_ForOurDrive
457
458;--------------------------------------------------------------------
459; Prints Hard Disk Menuitem information strings for drive that
460; is handled by some other BIOS.
461;
462; BootMenuPrint_HardDiskMenuitemInfoForForeignDrive
463;   Parameters:
464;       DL:     Untranslated Hard Disk number
465;       DS:     RAMVARS segment
466;   Returns:
467;       Nothing
468;   Corrupts registers:
469;       AX, BX, CX, DX, SI, DI
470;--------------------------------------------------------------------
471ALIGN JUMP_ALIGN
472BootMenuPrint_HardDiskMenuitemInfoForForeignDrive:
473    call    DriveXlate_ToOrBack
474    call    HCapacity_GetSectorCountFromForeignAH08h
475    call    HCapacity_ConvertSectorCountToSize
476    ePUSH_T dx, BootMenuPrint_ClearThreeInfoLines   ; Return address
477    push    cx                          ; Magnitude character
478    push    si                          ; Tenths
479    push    ax                          ; Size in magnitude
480    ePUSH_T ax, g_szCapacity            ; "Capacity"
481    mov     si, g_szSizeSingle
482    mov     dh, 8                       ; 8 bytes pushed to stack
483    jmp     PrintString_JumpToFormat
484
485;--------------------------------------------------------------------
486; Prints Hard Disk Menuitem information size string for drive that
487; is handled by our BIOS.
488;
489; BootMenuPrint_HardDiskMenuitemInfoSizeForOurDrive
490;   Parameters:
491;       DL:     Untranslated Hard Disk number
492;       DS:DI:  Ptr to DPT
493;   Returns:
494;       Nothing
495;   Corrupts registers:
496;       AX, BX, CX, DX, SI, ES
497;--------------------------------------------------------------------
498ALIGN JUMP_ALIGN
499BootMenuPrint_HardDiskMenuitemInfoSizeForOurDrive:
500    ePUSH_T ax, BootMenuPrint_ClearOneInfoLine  ; Return address
501
502    ; Get and push total LBA size
503    call    BootInfo_GetTotalSectorCount
504    call    HCapacity_ConvertSectorCountToSize
505    push    cx                              ; Magnitude character
506    push    si                              ; Tenths
507    push    ax                              ; Size in magnitude
508
509    ; Get and push L-CHS size
510    mov     dl, [di+DPT.bDrvNum]            ; Restore drive number
511    call    HCapacity_GetSectorCountFromOurAH08h
512    call    HCapacity_ConvertSectorCountToSize
513    push    cx                              ; Magnitude character
514    push    si                              ; Tenths
515    push    ax                              ; Size in magnitude
516
517    ePUSH_T ax, g_szCapacity                ; "Capacity"
518    mov     si, g_szSizeDual
519    mov     dh, 14                          ; 14 bytes pushed to stack
520    jmp     PrintString_JumpToFormat
521
522
523;--------------------------------------------------------------------
524; Prints Function Menuitem information strings.
525;
526; BootMenuPrint_HardDiskMenuitemInformation
527;   Parameters:
528;       DX:     Function ID
529;       DS:     RAMVARS segment
530;   Returns:
531;       AX:     1 if function ID was valid
532;               0 if function ID was valid
533;   Corrupts registers:
534;       BX, DX
535;--------------------------------------------------------------------
536ALIGN JUMP_ALIGN
537BootMenuPrint_FunctionMenuitemInformation:
538    jmp     SHORT BootMenuPrint_ClearThreeInfoLines
539
540
541;--------------------------------------------------------------------
542; Prints Boot Menu title strings.
543;
544; BootMenuPrint_TitleStrings
545;   Parameters:
546;       Nothing
547;   Returns:
548;       AX:     Was printing successfull
549;   Corrupts registers:
550;       BX, DX, SI
551;--------------------------------------------------------------------
552ALIGN JUMP_ALIGN
553BootMenuPrint_TitleStrings:
554    mov     si, ROMVARS.szTitle
555    call    PrintString_FromCS
556    call    BootMenuPrint_ClearOneInfoLine
557    mov     si, ROMVARS.szVersion
558    call    PrintString_FromCS
559    call    BootMenuPrint_ClearOneInfoLine
560    mov     si, g_szTitleLn3
561    call    PrintString_FromCS
562    jmp     SHORT BootMenuPrint_ClearOneInfoLine
Note: See TracBrowser for help on using the repository browser.