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

Last change on this file since 344 was 294, checked in by krille_n_@…, 13 years ago

Commit 2/2 (BIOS):

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