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

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

Changes to XTIDE Universal BIOS:

  • Booting with hotkey now properly maintains FD and HD drive swappings (it is now again possible to boot with both translated FD and HD drives).
  • Had to change file orders so compressed strings could be included after recent changes to Assembly Library size.
File size: 6.4 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; CX, 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_GetCountToCX
53 cmp dl, cl ; Floppy drive?
54 jb SHORT .ReturnFloppyDriveInDX ; Set CF if branch taken
55 or cl, 80h ; Or 80h into CL before the sub
56 ; to cause CF to be set after
57 ; and result has high order bit set
58 sub dl, cl ; 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_GetHardDiskCountFromBDAtoCX
97 xchg ax, cx
98 call FloppyDrive_GetCountToCX
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 call BootMenu_GetLetterForFirstHardDiskToCL
139 xor ah, ah
140 cmp al, cl ; Letter is for Hard Disk?
141 jae SHORT .StartFromHardDiskLetter
142 sub al, 'A' ; Letter to Floppy Drive menuitem
143 ret
144ALIGN JUMP_ALIGN
145.StartFromHardDiskLetter:
146 sub al, cl ; Hard Disk index
147 call FloppyDrive_GetCountToCX
148 add ax, cx ; Menuitem index
149 ret
150
151
152;--------------------------------------------------------------------
153; Returns letter for first hard disk. Usually it will be 'c' but it
154; can be higher if more than two floppy drives are found.
155;
156; BootMenu_GetLetterForFirstHardDiskToCL
157; Parameters:
158; Nothing
159; Returns:
160; CL: Upper case letter for first hard disk
161; Corrupts registers:
162; CH
163;--------------------------------------------------------------------
164ALIGN JUMP_ALIGN
165BootMenu_GetLetterForFirstHardDiskToCL:
166 call FloppyDrive_GetCountToCX
167 add cl, 'A'
168 cmp cl, 'C'
169 ja .Return
170 mov cl, 'C'
171ALIGN JUMP_ALIGN, ret
172.Return:
173 ret
174
175
176;--------------------------------------------------------------------
177; BootMenu_GetMenuitemToDXforDriveInDL
178; Parameters:
179; DL: Drive number
180; Returns:
181; DX: Menuitem index (assuming drive is available)
182; Corrupts registers:
183; Nothing
184;--------------------------------------------------------------------
185ALIGN JUMP_ALIGN
186BootMenu_GetMenuitemToDXforDriveInDL:
187 xor dh, dh ; Drive number now in DX
188 test dl, dl
189 jns SHORT .ReturnItemIndexInDX ; Return if floppy drive (HD bit not set)
190 call FloppyDrive_GetCountToCX
191 and dl, ~80h ; Clear HD bit
192 add dx, cx
193.ReturnItemIndexInDX:
194 ret
195
196
197;--------------------------------------------------------------------
198; Checks is drive number valid for this system.
199;
200; BootMenu_IsDriveInSystem
201; Parameters:
202; DL: Drive number
203; DS: RAMVARS segment
204; Returns:
205; CF: Set if drive number is valid
206; Clear if drive is not present in system
207; Corrupts registers:
208; AX, CX
209;--------------------------------------------------------------------
210ALIGN JUMP_ALIGN
211BootMenu_IsDriveInSystem:
212 test dl, dl ; Floppy drive?
213 jns SHORT .IsFloppyDriveInSystem
214 call RamVars_GetHardDiskCountFromBDAtoCX ; Hard Disk count to CX
215 or cl, 80h ; Set Hard Disk bit to CX
216 jmp SHORT .CompareDriveNumberToDriveCount
217.IsFloppyDriveInSystem:
218 call FloppyDrive_GetCountToCX
219.CompareDriveNumberToDriveCount:
220 cmp dl, cl ; Set CF when DL is smaller
221 ret
Note: See TracBrowser for help on using the repository browser.