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

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

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

File size: 7.0 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Displays Boot Menu.
3
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
20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; Displays Boot Menu and returns Drive or Function number.
25;
26; BootMenu_DisplayAndReturnSelectionInDX
27; Parameters:
28; DS: RAMVARS segment
29; Returns:
30; DX: Untranslated drive number to be used for booting
31; Corrupts registers:
32; All General Purpose Registers
33;--------------------------------------------------------------------
34BootMenu_DisplayAndReturnSelectionInDX:
35 call DriveXlate_Reset
36 call BootMenuPrint_TheBottomOfScreen
37 call BootMenu_Enter ; Get selected menuitem index to CX
38 call BootMenuPrint_ClearScreen
39 call BootMenu_GetDriveToDXforMenuitemInCX
40 jnc BootMenu_DisplayAndReturnSelectionInDX
41 ret
42
43;--------------------------------------------------------------------
44; BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS
45; BootMenu_GetDriveToDXforMenuitemInCX
46; Parameters:
47; CX: Index of menuitem selected from Boot Menu
48; Returns:
49; DX: Drive number to be used for booting
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
53; Corrupts registers:
54; AX, DI
55;--------------------------------------------------------------------
56BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS:
57 call RamVars_GetSegmentToDS
58;;; fall-through
59
60BootMenu_GetDriveToDXforMenuitemInCX:
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
65 call FloppyDrive_GetCountToAX
66 cmp dl, al ; Floppy drive?
67 jb SHORT .ReturnFloppyDriveInDX ; Set CF if branch taken
68 or al, 80h ; Or 80h into AL before the sub
69 ; to cause CF to be set after
70 ; and result has high order bit set
71 sub dl, al ; Remove floppy drives from index
72
73.ReturnFloppyDriveInDX:
74 ret
75
76
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:
86; AX, BX, DI
87;--------------------------------------------------------------------
88BootMenu_Enter:
89 mov bx, BootMenuEvent_Handler
90 CALL_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX
91 xchg cx, ax
92 ret
93
94
95;--------------------------------------------------------------------
96; Returns number of menuitems in Boot Menu.
97;
98; BootMenu_GetMenuitemCountToAX
99; Parameters:
100; DS: RAMVARS segment
101; Returns:
102; AX: Number of boot menu items
103; Corrupts registers:
104; CX
105;--------------------------------------------------------------------
106BootMenu_GetMenuitemCountToAX:
107 call RamVars_GetHardDiskCountFromBDAtoAX
108 xchg ax, cx
109 call FloppyDrive_GetCountToAX
110 add ax, cx
111 ret
112
113
114;--------------------------------------------------------------------
115; BootMenu_GetHeightToAHwithItemCountInAL
116; Parameters:
117; AL: Number of menuitems
118; Returns:
119; AH: Boot menu height
120; Corrupts registers:
121; AL, CX, DI
122;--------------------------------------------------------------------
123BootMenu_GetHeightToAHwithItemCountInAL:
124 add al, BOOT_MENU_HEIGHT_WITHOUT_ITEMS
125 xchg cx, ax
126 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
127 sub ah, MENU_SCREEN_BOTTOM_LINES*2 ; Leave space for bottom info
128 cmp ah, cl
129 jb SHORT .Return
130 mov ah, cl
131
132.Return:
133 ret
134
135
136;--------------------------------------------------------------------
137; BootMenu_GetMenuitemToAXforAsciiHotkeyInAL
138; Parameters:
139; AL: ASCII hotkey
140; Returns:
141; AX: Menuitem index
142; Corrupts registers:
143; CX
144;--------------------------------------------------------------------
145BootMenu_GetMenuitemToAXforAsciiHotkeyInAL:
146 call Char_ALtoUpperCaseLetter
147 cbw
148 xchg ax, cx
149 call BootMenu_GetLetterForFirstHardDiskToAL
150 cmp cl, al ; Letter is for Hard Disk?
151 jae SHORT .StartFromHardDiskLetter
152 xchg ax, cx
153 sub al, 'A' ; Letter to Floppy Drive menuitem
154 ret
155
156.StartFromHardDiskLetter:
157 sub cl, al ; Hard Disk index
158 call FloppyDrive_GetCountToAX
159 add ax, cx ; Menuitem index
160 ; Note: no need to xchg ax, cx as above, since adding with result to ax
161 ret
162
163
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;
168; BootMenu_GetLetterForFirstHardDiskToCL
169; Parameters:
170; Nothing
171; Returns:
172; CL: Upper case letter for first hard disk
173; Corrupts registers:
174; AX
175;--------------------------------------------------------------------
176BootMenu_GetLetterForFirstHardDiskToAL:
177 call FloppyDrive_GetCountToAX
178 add al, 'A'
179 cmp al, 'C'
180 ja .Return
181 mov al, 'C'
182
183.Return:
184 ret
185
186
187;--------------------------------------------------------------------
188; BootMenu_GetMenuitemToDXforDriveInDL
189; Parameters:
190; DL: Drive number
191; Returns:
192; DX: Menuitem index (assuming drive is available)
193; Corrupts registers:
194; AX
195;--------------------------------------------------------------------
196BootMenu_GetMenuitemToDXforDriveInDL:
197 xor dh, dh ; Drive number now in DX
198 test dl, dl
199 jns SHORT .ReturnItemIndexInDX ; Return if floppy drive (HD bit not set)
200 call FloppyDrive_GetCountToAX
201 and dl, ~80h ; Clear HD bit
202 add dx, ax
203.ReturnItemIndexInDX:
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:
215; CF: Set if drive number is valid
216; Clear if drive is not present in system
217; Corrupts registers:
218; AX, CX
219;--------------------------------------------------------------------
220BootMenu_IsDriveInSystem:
221 test dl, dl ; Floppy drive?
222 jns SHORT .IsFloppyDriveInSystem
223 call RamVars_GetHardDiskCountFromBDAtoAX ; Hard Disk count to AX
224 or al, 80h ; Set Hard Disk bit to AX
225 jmp SHORT .CompareDriveNumberToDriveCount
226.IsFloppyDriveInSystem:
227 call FloppyDrive_GetCountToAX
228.CompareDriveNumberToDriveCount:
229 cmp dl, al ; Set CF when DL is smaller
230 ret
Note: See TracBrowser for help on using the repository browser.