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

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

Changes to XTIDE Universal BIOS:

  • Brought back optional "A then C" boot loader.
  • Now there is only one INT 19h handler that remains unchanged.
File size: 6.3 KB
Line 
1; Project name  :   XTIDE Universal BIOS
2; Description   :   Displays Boot Menu.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Displays Boot Menu and returns Drive or Function number.
9;
10; BootMenu_DisplayAndReturnSelectionInDX
11;   Parameters:
12;       DS:     RAMVARS segment
13;   Returns:
14;       DX:     Untranslated drive number to be used for booting
15;   Corrupts registers:
16;       All General Purpose Registers
17;--------------------------------------------------------------------
18ALIGN JUMP_ALIGN
19BootMenu_DisplayAndReturnSelectionInDX:
20    call    DriveXlate_Reset
21    call    BootMenuPrint_TheBottomOfScreen
22    call    BootMenu_Enter          ; Get selected menuitem index to CX
23    call    BootMenuPrint_ClearScreen
24    call    BootMenu_GetDriveToDXforMenuitemInCX
25    jnc     BootMenu_DisplayAndReturnSelectionInDX
26    ret
27
28;--------------------------------------------------------------------
29; BootMenu_GetDriveToDXforMenuitemInCX
30;   Parameters:
31;       CX:     Index of menuitem selected from Boot Menu
32;   Returns:
33;       DX:     Drive number to be used for booting
34;       DS:     RAMVARS segment
35;       CF:     Set: There is a selected menu item, DL is valid
36;               Clear: There is no selected menu item, DL is not valid
37;   Corrupts registers:
38;       CX, DI
39;--------------------------------------------------------------------
40ALIGN JUMP_ALIGN
41BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS:
42    call    RamVars_GetSegmentToDS
43;;; fall-through
44                       
45ALIGN JUMP_ALIGN
46BootMenu_GetDriveToDXforMenuitemInCX:
47    cmp     cl, NO_ITEM_HIGHLIGHTED
48    je      SHORT .ReturnFloppyDriveInDX    ; Clear CF if branch taken
49
50    mov     dl, cl                          ; Copy menuitem index to DX
51    call    FloppyDrive_GetCountToCX
52    cmp     dl, cl                          ; Floppy drive?
53    jb      SHORT .ReturnFloppyDriveInDX    ; Set CF if branch taken
54    or      cl, 80h                         ; Or 80h into CL before the sub
55                                            ; to cause CF to be set after
56                                            ; and result has high order bit set
57    sub     dl, cl                          ; Remove floppy drives from index
58
59.ReturnFloppyDriveInDX:
60    ret
61
62
63;--------------------------------------------------------------------
64; Enters Boot Menu or submenu.
65;
66; BootMenu_Enter
67;   Parameters:
68;       Nothing
69;   Returns:
70;       CX:     Index of selected item or NO_ITEM_SELECTED
71;   Corrupts registers:
72;       AX, BX, DI
73;--------------------------------------------------------------------
74ALIGN JUMP_ALIGN
75BootMenu_Enter:
76    mov     bx, BootMenuEvent_Handler
77    CALL_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX
78    xchg    cx, ax
79    ret
80
81
82;--------------------------------------------------------------------
83; Returns number of menuitems in Boot Menu.
84;
85; BootMenu_GetMenuitemCountToAX
86;   Parameters:
87;       DS:     RAMVARS segment
88;   Returns:
89;       AX:     Number of boot menu items
90;   Corrupts registers:
91;       CX
92;--------------------------------------------------------------------
93ALIGN JUMP_ALIGN
94BootMenu_GetMenuitemCountToAX:
95    call    RamVars_GetHardDiskCountFromBDAtoCX
96    xchg    ax, cx
97    call    FloppyDrive_GetCountToCX
98    add     ax, cx
99    ret
100
101
102;--------------------------------------------------------------------
103; BootMenu_GetHeightToAHwithItemCountInAL
104;   Parameters:
105;       AL:     Number of menuitems
106;   Returns:
107;       AH:     Boot menu height
108;   Corrupts registers:
109;       AL, CX, DI
110;--------------------------------------------------------------------
111ALIGN JUMP_ALIGN
112BootMenu_GetHeightToAHwithItemCountInAL:
113    add     al, BOOT_MENU_HEIGHT_WITHOUT_ITEMS
114    xchg    cx, ax
115    CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
116    sub     ah, MENU_SCREEN_BOTTOM_LINES*2  ; Leave space for bottom info
117    cmp     ah, cl
118    jb      SHORT .Return
119    mov     ah, cl
120ALIGN JUMP_ALIGN, ret
121.Return:
122    ret
123
124
125;--------------------------------------------------------------------
126; BootMenu_GetMenuitemToAXforAsciiHotkeyInAL
127;   Parameters:
128;       AL:     ASCII hotkey
129;   Returns:
130;       AX:     Menuitem index
131;   Corrupts registers:
132;       CX
133;--------------------------------------------------------------------
134ALIGN JUMP_ALIGN
135BootMenu_GetMenuitemToAXforAsciiHotkeyInAL:
136    call    Char_ALtoUpperCaseLetter
137    call    BootMenu_GetLetterForFirstHardDiskToCL
138    xor     ah, ah
139    cmp     al, cl                      ; Letter is for Hard Disk?
140    jae     SHORT .StartFromHardDiskLetter
141    sub     al, 'A'                     ; Letter to Floppy Drive menuitem
142    ret
143ALIGN JUMP_ALIGN
144.StartFromHardDiskLetter:
145    sub     al, cl                      ; Hard Disk index
146    call    FloppyDrive_GetCountToCX
147    add     ax, cx                      ; Menuitem index
148    ret
149
150
151;--------------------------------------------------------------------
152; Returns letter for first hard disk. Usually it will be 'c' but it
153; can be higher if more than two floppy drives are found.
154;
155; BootMenu_GetLetterForFirstHardDiskToCL
156;   Parameters:
157;       Nothing
158;   Returns:
159;       CL:     Upper case letter for first hard disk
160;   Corrupts registers:
161;       CH
162;--------------------------------------------------------------------
163ALIGN JUMP_ALIGN
164BootMenu_GetLetterForFirstHardDiskToCL:
165    call    FloppyDrive_GetCountToCX
166    add     cl, 'A'
167    cmp     cl, 'C'
168    ja      .Return
169    mov     cl, 'C'
170ALIGN JUMP_ALIGN, ret
171.Return:
172    ret
173
174
175;--------------------------------------------------------------------
176; BootMenu_GetMenuitemToDXforDriveInDL
177;   Parameters:
178;       DL:     Drive number
179;   Returns:
180;       DX:     Menuitem index (assuming drive is available)
181;   Corrupts registers:
182;       Nothing
183;--------------------------------------------------------------------
184ALIGN JUMP_ALIGN
185BootMenu_GetMenuitemToDXforDriveInDL:
186    xor     dh, dh                      ; Drive number now in DX
187    test    dl, dl
188    jns     SHORT .ReturnItemIndexInDX  ; Return if floppy drive (HD bit not set)
189    call    FloppyDrive_GetCountToCX
190    and     dl, ~80h                    ; Clear HD bit
191    add     dx, cx
192.ReturnItemIndexInDX:
193    ret
194
195
196;--------------------------------------------------------------------
197; Checks is drive number valid for this system.
198;
199; BootMenu_IsDriveInSystem
200;   Parameters:
201;       DL:     Drive number
202;       DS:     RAMVARS segment
203;   Returns:
204;       CF:     Set if drive number is valid
205;               Clear if drive is not present in system
206;   Corrupts registers:
207;       AX, CX
208;--------------------------------------------------------------------
209ALIGN JUMP_ALIGN
210BootMenu_IsDriveInSystem:
211    test    dl, dl                              ; Floppy drive?
212    jns     SHORT .IsFloppyDriveInSystem
213    call    RamVars_GetHardDiskCountFromBDAtoCX ; Hard Disk count to CX
214    or      cl, 80h                             ; Set Hard Disk bit to CX
215    jmp     SHORT .CompareDriveNumberToDriveCount
216.IsFloppyDriveInSystem:
217    call    FloppyDrive_GetCountToCX
218.CompareDriveNumberToDriveCount:
219    cmp     dl, cl                              ; Set CF when DL is smaller
220    ret
Note: See TracBrowser for help on using the repository browser.