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

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

Removed align directives for initalization code and added define for align in boot-time calls to the assembly library (defaulting to 1), resulting in a significant savings for the AT and 386 builds. Fixed a bug with switch command line handling in the serial server. Put in CR characters in licesnse.txt, so that it properly displays on Windows. In the configurator, added default values for user supplied CHS and LBA values, defaulting to values within range when those features are enabled. Updated the copyright message in the configurator as the literal word Copyright is important.

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;--------------------------------------------------------------------
18BootMenu_DisplayAndReturnSelectionInDX:
19 call DriveXlate_Reset
20 call BootMenuPrint_TheBottomOfScreen
21 call BootMenu_Enter ; Get selected menuitem index to CX
22 call BootMenuPrint_ClearScreen
23 call BootMenu_GetDriveToDXforMenuitemInCX
24 jnc BootMenu_DisplayAndReturnSelectionInDX
25 ret
26
27;--------------------------------------------------------------------
28; BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS
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; AX, DI
39;--------------------------------------------------------------------
40BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS:
41 call RamVars_GetSegmentToDS
42;;; fall-through
43
44BootMenu_GetDriveToDXforMenuitemInCX:
45 cmp cl, NO_ITEM_HIGHLIGHTED
46 je SHORT .ReturnFloppyDriveInDX ; Clear CF if branch taken
47
48 mov dl, cl ; Copy menuitem index to DX
49 call FloppyDrive_GetCountToAX
50 cmp dl, al ; Floppy drive?
51 jb SHORT .ReturnFloppyDriveInDX ; Set CF if branch taken
52 or al, 80h ; Or 80h into AL before the sub
53 ; to cause CF to be set after
54 ; and result has high order bit set
55 sub dl, al ; Remove floppy drives from index
56
57.ReturnFloppyDriveInDX:
58 ret
59
60
61;--------------------------------------------------------------------
62; Enters Boot Menu or submenu.
63;
64; BootMenu_Enter
65; Parameters:
66; Nothing
67; Returns:
68; CX: Index of selected item or NO_ITEM_SELECTED
69; Corrupts registers:
70; AX, BX, DI
71;--------------------------------------------------------------------
72BootMenu_Enter:
73 mov bx, BootMenuEvent_Handler
74 CALL_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX
75 xchg cx, ax
76 ret
77
78
79;--------------------------------------------------------------------
80; Returns number of menuitems in Boot Menu.
81;
82; BootMenu_GetMenuitemCountToAX
83; Parameters:
84; DS: RAMVARS segment
85; Returns:
86; AX: Number of boot menu items
87; Corrupts registers:
88; CX
89;--------------------------------------------------------------------
90BootMenu_GetMenuitemCountToAX:
91 call RamVars_GetHardDiskCountFromBDAtoAX
92 xchg ax, cx
93 call FloppyDrive_GetCountToAX
94 add ax, cx
95 ret
96
97
98;--------------------------------------------------------------------
99; BootMenu_GetHeightToAHwithItemCountInAL
100; Parameters:
101; AL: Number of menuitems
102; Returns:
103; AH: Boot menu height
104; Corrupts registers:
105; AL, CX, DI
106;--------------------------------------------------------------------
107BootMenu_GetHeightToAHwithItemCountInAL:
108 add al, BOOT_MENU_HEIGHT_WITHOUT_ITEMS
109 xchg cx, ax
110 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
111 sub ah, MENU_SCREEN_BOTTOM_LINES*2 ; Leave space for bottom info
112 cmp ah, cl
113 jb SHORT .Return
114 mov ah, cl
115
116.Return:
117 ret
118
119
120;--------------------------------------------------------------------
121; BootMenu_GetMenuitemToAXforAsciiHotkeyInAL
122; Parameters:
123; AL: ASCII hotkey
124; Returns:
125; AX: Menuitem index
126; Corrupts registers:
127; CX
128;--------------------------------------------------------------------
129BootMenu_GetMenuitemToAXforAsciiHotkeyInAL:
130 call Char_ALtoUpperCaseLetter
131 cbw
132 xchg ax, cx
133 call BootMenu_GetLetterForFirstHardDiskToAL
134 cmp cl, al ; Letter is for Hard Disk?
135 jae SHORT .StartFromHardDiskLetter
136 xchg ax, cx
137 sub al, 'A' ; Letter to Floppy Drive menuitem
138 ret
139
140.StartFromHardDiskLetter:
141 sub cl, al ; Hard Disk index
142 call FloppyDrive_GetCountToAX
143 add ax, cx ; Menuitem index
144 ; Note: no need to xchg ax, cx as above, since adding with result to ax
145 ret
146
147
148;--------------------------------------------------------------------
149; Returns letter for first hard disk. Usually it will be 'c' but it
150; can be higher if more than two floppy drives are found.
151;
152; BootMenu_GetLetterForFirstHardDiskToCL
153; Parameters:
154; Nothing
155; Returns:
156; CL: Upper case letter for first hard disk
157; Corrupts registers:
158; AX
159;--------------------------------------------------------------------
160BootMenu_GetLetterForFirstHardDiskToAL:
161 call FloppyDrive_GetCountToAX
162 add al, 'A'
163 cmp al, 'C'
164 ja .Return
165 mov al, 'C'
166
167.Return:
168 ret
169
170
171;--------------------------------------------------------------------
172; BootMenu_GetMenuitemToDXforDriveInDL
173; Parameters:
174; DL: Drive number
175; Returns:
176; DX: Menuitem index (assuming drive is available)
177; Corrupts registers:
178; AX
179;--------------------------------------------------------------------
180BootMenu_GetMenuitemToDXforDriveInDL:
181 xor dh, dh ; Drive number now in DX
182 test dl, dl
183 jns SHORT .ReturnItemIndexInDX ; Return if floppy drive (HD bit not set)
184 call FloppyDrive_GetCountToAX
185 and dl, ~80h ; Clear HD bit
186 add dx, ax
187.ReturnItemIndexInDX:
188 ret
189
190
191;--------------------------------------------------------------------
192; Checks is drive number valid for this system.
193;
194; BootMenu_IsDriveInSystem
195; Parameters:
196; DL: Drive number
197; DS: RAMVARS segment
198; Returns:
199; CF: Set if drive number is valid
200; Clear if drive is not present in system
201; Corrupts registers:
202; AX, CX
203;--------------------------------------------------------------------
204BootMenu_IsDriveInSystem:
205 test dl, dl ; Floppy drive?
206 jns SHORT .IsFloppyDriveInSystem
207 call RamVars_GetHardDiskCountFromBDAtoAX ; Hard Disk count to AX
208 or al, 80h ; Set Hard Disk bit to AX
209 jmp SHORT .CompareDriveNumberToDriveCount
210.IsFloppyDriveInSystem:
211 call FloppyDrive_GetCountToAX
212.CompareDriveNumberToDriveCount:
213 cmp dl, al ; Set CF when DL is smaller
214 ret
Note: See TracBrowser for help on using the repository browser.