source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenu.asm @ 376

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

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 7.0 KB
RevLine 
[88]1; Project name  :   XTIDE Universal BIOS
[3]2; Description   :   Displays Boot Menu.
3
[376]4;
5; XTIDE Universal BIOS and Associated Tools 
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12; 
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html       
18;       
19
[3]20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; Displays Boot Menu and returns Drive or Function number.
25;
[243]26; BootMenu_DisplayAndReturnSelectionInDX
[3]27;   Parameters:
28;       DS:     RAMVARS segment
29;   Returns:
[95]30;       DX:     Untranslated drive number to be used for booting
[3]31;   Corrupts registers:
32;       All General Purpose Registers
33;--------------------------------------------------------------------
[243]34BootMenu_DisplayAndReturnSelectionInDX:
[3]35    call    DriveXlate_Reset
36    call    BootMenuPrint_TheBottomOfScreen
37    call    BootMenu_Enter          ; Get selected menuitem index to CX
38    call    BootMenuPrint_ClearScreen
[241]39    call    BootMenu_GetDriveToDXforMenuitemInCX
[243]40    jnc     BootMenu_DisplayAndReturnSelectionInDX
[241]41    ret
[88]42
[128]43;--------------------------------------------------------------------
[248]44; BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS
[130]45; BootMenu_GetDriveToDXforMenuitemInCX
[128]46;   Parameters:
47;       CX:     Index of menuitem selected from Boot Menu
48;   Returns:
49;       DX:     Drive number to be used for booting
[241]50;       DS:     RAMVARS segment
51;       CF:     Set: There is a selected menu item, DL is valid
52;               Clear: There is no selected menu item, DL is not valid
[128]53;   Corrupts registers:
[258]54;       AX, DI
[128]55;--------------------------------------------------------------------
[241]56BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS:
57    call    RamVars_GetSegmentToDS
58;;; fall-through
[294]59
[130]60BootMenu_GetDriveToDXforMenuitemInCX:
[241]61    cmp     cl, NO_ITEM_HIGHLIGHTED
62    je      SHORT .ReturnFloppyDriveInDX    ; Clear CF if branch taken
63
64    mov     dl, cl                          ; Copy menuitem index to DX
[258]65    call    FloppyDrive_GetCountToAX
66    cmp     dl, al                          ; Floppy drive?
[241]67    jb      SHORT .ReturnFloppyDriveInDX    ; Set CF if branch taken
[258]68    or      al, 80h                         ; Or 80h into AL before the sub
[241]69                                            ; to cause CF to be set after
70                                            ; and result has high order bit set
[258]71    sub     dl, al                          ; Remove floppy drives from index
[241]72
[128]73.ReturnFloppyDriveInDX:
74    ret
[88]75
[128]76
[88]77;--------------------------------------------------------------------
78; Enters Boot Menu or submenu.
79;
80; BootMenu_Enter
81;   Parameters:
82;       Nothing
83;   Returns:
84;       CX:     Index of selected item or NO_ITEM_SELECTED
85;   Corrupts registers:
[127]86;       AX, BX, DI
[88]87;--------------------------------------------------------------------
88BootMenu_Enter:
89    mov     bx, BootMenuEvent_Handler
90    CALL_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX
91    xchg    cx, ax
[3]92    ret
93
94
95;--------------------------------------------------------------------
96; Returns number of menuitems in Boot Menu.
97;
[124]98; BootMenu_GetMenuitemCountToAX
[3]99;   Parameters:
100;       DS:     RAMVARS segment
101;   Returns:
[124]102;       AX:     Number of boot menu items
[3]103;   Corrupts registers:
[124]104;       CX
[3]105;--------------------------------------------------------------------
[124]106BootMenu_GetMenuitemCountToAX:
[258]107    call    RamVars_GetHardDiskCountFromBDAtoAX
[32]108    xchg    ax, cx
[258]109    call    FloppyDrive_GetCountToAX
[3]110    add     ax, cx
111    ret
112
113
114;--------------------------------------------------------------------
[124]115; BootMenu_GetHeightToAHwithItemCountInAL
[3]116;   Parameters:
[124]117;       AL:     Number of menuitems
[3]118;   Returns:
[88]119;       AH:     Boot menu height
[3]120;   Corrupts registers:
[124]121;       AL, CX, DI
[3]122;--------------------------------------------------------------------
[124]123BootMenu_GetHeightToAHwithItemCountInAL:
[128]124    add     al, BOOT_MENU_HEIGHT_WITHOUT_ITEMS
[124]125    xchg    cx, ax
[88]126    CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
[124]127    sub     ah, MENU_SCREEN_BOTTOM_LINES*2  ; Leave space for bottom info
[181]128    cmp     ah, cl
129    jb      SHORT .Return
130    mov     ah, cl
[369]131
[181]132.Return:
[3]133    ret
134
135
136;--------------------------------------------------------------------
[130]137; BootMenu_GetMenuitemToAXforAsciiHotkeyInAL
[3]138;   Parameters:
[130]139;       AL:     ASCII hotkey
[3]140;   Returns:
[130]141;       AX:     Menuitem index
[3]142;   Corrupts registers:
[130]143;       CX
[3]144;--------------------------------------------------------------------
[130]145BootMenu_GetMenuitemToAXforAsciiHotkeyInAL:
146    call    Char_ALtoUpperCaseLetter
[294]147    cbw
[258]148    xchg    ax, cx
149    call    BootMenu_GetLetterForFirstHardDiskToAL
150    cmp     cl, al                      ; Letter is for Hard Disk?
[3]151    jae     SHORT .StartFromHardDiskLetter
[258]152    xchg    ax, cx
[3]153    sub     al, 'A'                     ; Letter to Floppy Drive menuitem
154    ret
[369]155
[3]156.StartFromHardDiskLetter:
[258]157    sub     cl, al                      ; Hard Disk index
158    call    FloppyDrive_GetCountToAX
[130]159    add     ax, cx                      ; Menuitem index
[258]160                                        ; Note: no need to xchg ax, cx as above, since adding with result to ax
[3]161    ret
162
[128]163
[3]164;--------------------------------------------------------------------
165; Returns letter for first hard disk. Usually it will be 'c' but it
166; can be higher if more than two floppy drives are found.
167;
[92]168; BootMenu_GetLetterForFirstHardDiskToCL
[3]169;   Parameters:
170;       Nothing
171;   Returns:
172;       CL:     Upper case letter for first hard disk
173;   Corrupts registers:
[258]174;       AX
[3]175;--------------------------------------------------------------------
[258]176BootMenu_GetLetterForFirstHardDiskToAL:
177    call    FloppyDrive_GetCountToAX
178    add     al, 'A'
179    cmp     al, 'C'
[181]180    ja      .Return
[258]181    mov     al, 'C'
[369]182       
[181]183.Return:
[3]184    ret
185
186
187;--------------------------------------------------------------------
[124]188; BootMenu_GetMenuitemToDXforDriveInDL
[3]189;   Parameters:
190;       DL:     Drive number
191;   Returns:
[124]192;       DX:     Menuitem index (assuming drive is available)
[3]193;   Corrupts registers:
[258]194;       AX
[3]195;--------------------------------------------------------------------
[124]196BootMenu_GetMenuitemToDXforDriveInDL:
197    xor     dh, dh                      ; Drive number now in DX
[128]198    test    dl, dl
199    jns     SHORT .ReturnItemIndexInDX  ; Return if floppy drive (HD bit not set)
[258]200    call    FloppyDrive_GetCountToAX
[127]201    and     dl, ~80h                    ; Clear HD bit
[258]202    add     dx, ax
[124]203.ReturnItemIndexInDX:
[3]204    ret
205
206
207;--------------------------------------------------------------------
208; Checks is drive number valid for this system.
209;
210; BootMenu_IsDriveInSystem
211;   Parameters:
212;       DL:     Drive number
213;       DS:     RAMVARS segment
214;   Returns:
[28]215;       CF:     Set if drive number is valid
[3]216;               Clear if drive is not present in system
217;   Corrupts registers:
[28]218;       AX, CX
[3]219;--------------------------------------------------------------------
220BootMenu_IsDriveInSystem:
[128]221    test    dl, dl                              ; Floppy drive?
[130]222    jns     SHORT .IsFloppyDriveInSystem
[258]223    call    RamVars_GetHardDiskCountFromBDAtoAX ; Hard Disk count to AX
224    or      al, 80h                             ; Set Hard Disk bit to AX
[28]225    jmp     SHORT .CompareDriveNumberToDriveCount
[130]226.IsFloppyDriveInSystem:
[258]227    call    FloppyDrive_GetCountToAX
[28]228.CompareDriveNumberToDriveCount:
[258]229    cmp     dl, al                              ; Set CF when DL is smaller
[3]230    ret
Note: See TracBrowser for help on using the repository browser.