1 | ; Project name : XTIDE Universal BIOS |
---|
2 | ; Description : Displays Boot Menu. |
---|
3 | |
---|
4 | ; Section containing code |
---|
5 | SECTION .text |
---|
6 | |
---|
7 | ;-------------------------------------------------------------------- |
---|
8 | ; Displays Boot Menu and returns Drive or Function number. |
---|
9 | ; |
---|
10 | ; BootMenu_DisplayAndReturnSelection |
---|
11 | ; Parameters: |
---|
12 | ; DS: RAMVARS segment |
---|
13 | ; Returns: |
---|
14 | ; DX: Untranslated drive number to be used for booting (if CF cleared) |
---|
15 | ; Function number (if CF set) |
---|
16 | ; CF: Cleared if drive selected |
---|
17 | ; Set if function selected |
---|
18 | ; Corrupts registers: |
---|
19 | ; All General Purpose Registers |
---|
20 | ;-------------------------------------------------------------------- |
---|
21 | ALIGN JUMP_ALIGN |
---|
22 | BootMenu_DisplayAndReturnSelection: |
---|
23 | call DriveXlate_Reset |
---|
24 | call BootMenuPrint_TheBottomOfScreen |
---|
25 | call BootMenu_Enter ; Get selected menuitem index to CX |
---|
26 | call BootMenuPrint_ClearScreen |
---|
27 | cmp cx, BYTE NO_ITEM_SELECTED |
---|
28 | je SHORT BootMenu_DisplayAndReturnSelection |
---|
29 | jmp SHORT BootMenu_ConvertMenuitemFromCXtoDriveInDX |
---|
30 | |
---|
31 | |
---|
32 | ;-------------------------------------------------------------------- |
---|
33 | ; Enters Boot Menu or submenu. |
---|
34 | ; |
---|
35 | ; BootMenu_Enter |
---|
36 | ; Parameters: |
---|
37 | ; Nothing |
---|
38 | ; Returns: |
---|
39 | ; CX: Index of selected item or NO_ITEM_SELECTED |
---|
40 | ; Corrupts registers: |
---|
41 | ; BX, DI |
---|
42 | ;-------------------------------------------------------------------- |
---|
43 | ALIGN JUMP_ALIGN |
---|
44 | BootMenu_Enter: |
---|
45 | mov bx, BootMenuEvent_Handler |
---|
46 | CALL_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX |
---|
47 | xchg cx, ax |
---|
48 | ret |
---|
49 | |
---|
50 | |
---|
51 | ;-------------------------------------------------------------------- |
---|
52 | ; Returns number of menuitems in Boot Menu. |
---|
53 | ; |
---|
54 | ; BootMenu_GetMenuitemCountToCX |
---|
55 | ; Parameters: |
---|
56 | ; DS: RAMVARS segment |
---|
57 | ; Returns: |
---|
58 | ; CX: Number of boot menu items |
---|
59 | ; Corrupts registers: |
---|
60 | ; AX |
---|
61 | ;-------------------------------------------------------------------- |
---|
62 | ALIGN JUMP_ALIGN |
---|
63 | BootMenu_GetMenuitemCountToCX: |
---|
64 | call RamVars_GetHardDiskCountFromBDAtoCX |
---|
65 | xchg ax, cx |
---|
66 | call FloppyDrive_GetCount |
---|
67 | add ax, cx |
---|
68 | ret |
---|
69 | |
---|
70 | |
---|
71 | ;-------------------------------------------------------------------- |
---|
72 | ; BootMenu_GetHeightToALwithItemCountInCL |
---|
73 | ; Parameters: |
---|
74 | ; CL: Number of menuitems |
---|
75 | ; Returns: |
---|
76 | ; AH: Boot menu height |
---|
77 | ; Corrupts registers: |
---|
78 | ; AL, CL, DI |
---|
79 | ;-------------------------------------------------------------------- |
---|
80 | ALIGN JUMP_ALIGN |
---|
81 | BootMenu_GetHeightToAHwithItemCountInCL: |
---|
82 | add cl, BOOT_MENU_HEIGHT_WITHOUT_ITEMS |
---|
83 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH |
---|
84 | sub ah, MENU_SCREEN_BOTTOM_LINES*2 |
---|
85 | MIN_U ah, cl |
---|
86 | ret |
---|
87 | |
---|
88 | |
---|
89 | ;-------------------------------------------------------------------- |
---|
90 | ; BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX |
---|
91 | ; Parameters: |
---|
92 | ; AL: ASCII hotkey starting from upper case 'A' |
---|
93 | ; Returns: |
---|
94 | ; CX: Menuitem index |
---|
95 | ; Corrupts registers: |
---|
96 | ; AX |
---|
97 | ;-------------------------------------------------------------------- |
---|
98 | ALIGN JUMP_ALIGN |
---|
99 | BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX: |
---|
100 | call BootMenu_GetLetterForFirstHardDiskToCL |
---|
101 | cmp al, cl ; Letter is for Hard Disk? |
---|
102 | jae SHORT .StartFromHardDiskLetter |
---|
103 | sub al, 'A' ; Letter to Floppy Drive menuitem |
---|
104 | xchg ax, cx ; Menuitem index to CX |
---|
105 | ret |
---|
106 | ALIGN JUMP_ALIGN |
---|
107 | .StartFromHardDiskLetter: |
---|
108 | sub al, cl ; Hard Disk index |
---|
109 | call FloppyDrive_GetCount |
---|
110 | add cx, ax ; Menuitem index |
---|
111 | ret |
---|
112 | |
---|
113 | ;-------------------------------------------------------------------- |
---|
114 | ; Returns letter for first hard disk. Usually it will be 'c' but it |
---|
115 | ; can be higher if more than two floppy drives are found. |
---|
116 | ; |
---|
117 | ; BootMenu_GetLetterForFirstHardDiskToCL |
---|
118 | ; Parameters: |
---|
119 | ; Nothing |
---|
120 | ; Returns: |
---|
121 | ; CL: Upper case letter for first hard disk |
---|
122 | ; Corrupts registers: |
---|
123 | ; CH |
---|
124 | ;-------------------------------------------------------------------- |
---|
125 | ALIGN JUMP_ALIGN |
---|
126 | BootMenu_GetLetterForFirstHardDiskToCL: |
---|
127 | call FloppyDrive_GetCount |
---|
128 | add cl, 'A' |
---|
129 | MAX_U cl, 'C' |
---|
130 | ret |
---|
131 | |
---|
132 | |
---|
133 | ;-------------------------------------------------------------------- |
---|
134 | ; BootMenu_ConvertMenuitemFromCXtoDriveInDX |
---|
135 | ; Parameters: |
---|
136 | ; CX: Index of menuitem selected from Boot Menu |
---|
137 | ; DS: RAMVARS segment |
---|
138 | ; Returns: |
---|
139 | ; DX: Drive number to be used for booting |
---|
140 | ; Corrupts registers: |
---|
141 | ; CX |
---|
142 | ;-------------------------------------------------------------------- |
---|
143 | ALIGN JUMP_ALIGN |
---|
144 | BootMenu_ConvertMenuitemFromCXtoDriveInDX: |
---|
145 | mov dx, cx ; Copy menuitem index to DX |
---|
146 | call FloppyDrive_GetCount |
---|
147 | cmp dx, cx ; Floppy drive? |
---|
148 | jb SHORT .ReturnFloppyDriveInDX |
---|
149 | sub dx, cx ; Remove floppy drives from index |
---|
150 | or dl, 80h |
---|
151 | .ReturnFloppyDriveInDX: |
---|
152 | ret |
---|
153 | |
---|
154 | |
---|
155 | ;-------------------------------------------------------------------- |
---|
156 | ; Converts Floppy or Hard Disk Drive number to menuitem index. |
---|
157 | ; This function does not check does the drive really exists. |
---|
158 | ; |
---|
159 | ; BootMenu_ConvertDriveToMenuitem |
---|
160 | ; Parameters: |
---|
161 | ; DL: Drive number |
---|
162 | ; Returns: |
---|
163 | ; CX: Menuitem index (assuming drive is available) |
---|
164 | ; Corrupts registers: |
---|
165 | ; AX |
---|
166 | ;-------------------------------------------------------------------- |
---|
167 | ALIGN JUMP_ALIGN |
---|
168 | BootMenu_ConvertDriveToMenuitem: |
---|
169 | test dl, 80h ; Floppy drive? |
---|
170 | jz SHORT .ReturnFloppyMenuitem |
---|
171 | call FloppyDrive_GetCount |
---|
172 | mov ax, 7Fh ; Load mask to clear floppy bit |
---|
173 | and ax, dx ; AX = Hard Disk index |
---|
174 | add cx, ax ; Add hard disk index to floppy drive count |
---|
175 | ret |
---|
176 | ALIGN JUMP_ALIGN |
---|
177 | .ReturnFloppyMenuitem: |
---|
178 | eMOVZX cx, dl ; Drive number and item index are equal |
---|
179 | ret |
---|
180 | |
---|
181 | |
---|
182 | ;-------------------------------------------------------------------- |
---|
183 | ; Checks is drive number valid for this system. |
---|
184 | ; |
---|
185 | ; BootMenu_IsDriveInSystem |
---|
186 | ; Parameters: |
---|
187 | ; DL: Drive number |
---|
188 | ; DS: RAMVARS segment |
---|
189 | ; Returns: |
---|
190 | ; CF: Set if drive number is valid |
---|
191 | ; Clear if drive is not present in system |
---|
192 | ; Corrupts registers: |
---|
193 | ; AX, CX |
---|
194 | ;-------------------------------------------------------------------- |
---|
195 | ALIGN JUMP_ALIGN |
---|
196 | BootMenu_IsDriveInSystem: |
---|
197 | test dl, 80h ; Floppy drive? |
---|
198 | jz SHORT .IsFloppyDriveIsInSystem |
---|
199 | call RamVars_GetHardDiskCountFromBDAtoCX ; Hard Disk count to CX |
---|
200 | or cl, 80h ; Set Hard Disk bit to CX |
---|
201 | jmp SHORT .CompareDriveNumberToDriveCount |
---|
202 | .IsFloppyDriveIsInSystem: |
---|
203 | call FloppyDrive_GetCount ; Floppy Drive count to CX |
---|
204 | .CompareDriveNumberToDriveCount: |
---|
205 | cmp dl, cl |
---|
206 | ret |
---|