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

Last change on this file since 129 was 128, checked in by krille_n_@…, 14 years ago

Changes to the XTIDE Universal BIOS:

  • Size optimizations in various files.
File size: 5.8 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_DisplayAndReturnSelection
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_DisplayAndReturnSelection:
20 call DriveXlate_Reset
21 call BootMenuPrint_TheBottomOfScreen
22 call BootMenu_Enter ; Get selected menuitem index to CX
23 call BootMenuPrint_ClearScreen
24 cmp cx, BYTE NO_ITEM_SELECTED
25 je SHORT BootMenu_DisplayAndReturnSelection ; Clear screen and display menu
26 ; Fall through to BootMenu_ConvertMenuitemFromCXtoDriveInDX
27
28;--------------------------------------------------------------------
29; BootMenu_ConvertMenuitemFromCXtoDriveInDX
30; Parameters:
31; CX: Index of menuitem selected from Boot Menu
32; DS: RAMVARS segment
33; Returns:
34; DX: Drive number to be used for booting
35; Corrupts registers:
36; CX
37;--------------------------------------------------------------------
38ALIGN JUMP_ALIGN
39BootMenu_ConvertMenuitemFromCXtoDriveInDX:
40 mov dx, cx ; Copy menuitem index to DX
41 call FloppyDrive_GetCountToCX
42 cmp dx, cx ; Floppy drive?
43 jb SHORT .ReturnFloppyDriveInDX
44 sub dx, cx ; Remove floppy drives from index
45 or dl, 80h
46.ReturnFloppyDriveInDX:
47 ret
48
49
50;--------------------------------------------------------------------
51; Enters Boot Menu or submenu.
52;
53; BootMenu_Enter
54; Parameters:
55; Nothing
56; Returns:
57; CX: Index of selected item or NO_ITEM_SELECTED
58; Corrupts registers:
59; AX, BX, DI
60;--------------------------------------------------------------------
61ALIGN JUMP_ALIGN
62BootMenu_Enter:
63 mov bx, BootMenuEvent_Handler
64 CALL_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX
65 xchg cx, ax
66 ret
67
68
69;--------------------------------------------------------------------
70; Returns number of menuitems in Boot Menu.
71;
72; BootMenu_GetMenuitemCountToAX
73; Parameters:
74; DS: RAMVARS segment
75; Returns:
76; AX: Number of boot menu items
77; Corrupts registers:
78; CX
79;--------------------------------------------------------------------
80ALIGN JUMP_ALIGN
81BootMenu_GetMenuitemCountToAX:
82 call RamVars_GetHardDiskCountFromBDAtoCX
83 xchg ax, cx
84 call FloppyDrive_GetCountToCX
85 add ax, cx
86 ret
87
88
89;--------------------------------------------------------------------
90; BootMenu_GetHeightToAHwithItemCountInAL
91; Parameters:
92; AL: Number of menuitems
93; Returns:
94; AH: Boot menu height
95; Corrupts registers:
96; AL, CX, DI
97;--------------------------------------------------------------------
98ALIGN JUMP_ALIGN
99BootMenu_GetHeightToAHwithItemCountInAL:
100 add al, BOOT_MENU_HEIGHT_WITHOUT_ITEMS
101 xchg cx, ax
102 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
103 sub ah, MENU_SCREEN_BOTTOM_LINES*2 ; Leave space for bottom info
104 MIN_U ah, cl
105 ret
106
107
108;--------------------------------------------------------------------
109; BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX
110; Parameters:
111; AL: ASCII hotkey starting from upper case 'A'
112; Returns:
113; CX: Menuitem index
114; Corrupts registers:
115; AX
116;--------------------------------------------------------------------
117ALIGN JUMP_ALIGN
118BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX:
119 call BootMenu_GetLetterForFirstHardDiskToCL
120 cmp al, cl ; Letter is for Hard Disk?
121 jae SHORT .StartFromHardDiskLetter
122 sub al, 'A' ; Letter to Floppy Drive menuitem
123 xchg ax, cx ; Menuitem index to CX
124 ret
125ALIGN JUMP_ALIGN
126.StartFromHardDiskLetter:
127 sub al, cl ; Hard Disk index
128 call FloppyDrive_GetCountToCX
129 add cx, ax ; Menuitem index
130 ret
131
132
133;--------------------------------------------------------------------
134; Returns letter for first hard disk. Usually it will be 'c' but it
135; can be higher if more than two floppy drives are found.
136;
137; BootMenu_GetLetterForFirstHardDiskToCL
138; Parameters:
139; Nothing
140; Returns:
141; CL: Upper case letter for first hard disk
142; Corrupts registers:
143; CH
144;--------------------------------------------------------------------
145ALIGN JUMP_ALIGN
146BootMenu_GetLetterForFirstHardDiskToCL:
147 call FloppyDrive_GetCountToCX
148 add cl, 'A'
149 MAX_U cl, 'C'
150 ret
151
152
153;--------------------------------------------------------------------
154; BootMenu_GetMenuitemToDXforDriveInDL
155; Parameters:
156; DL: Drive number
157; Returns:
158; DX: Menuitem index (assuming drive is available)
159; Corrupts registers:
160; Nothing
161;--------------------------------------------------------------------
162ALIGN JUMP_ALIGN
163BootMenu_GetMenuitemToDXforDriveInDL:
164 xor dh, dh ; Drive number now in DX
165 test dl, dl
166 jns SHORT .ReturnItemIndexInDX ; Return if floppy drive (HD bit not set)
167 call FloppyDrive_GetCountToCX
168 and dl, ~80h ; Clear HD bit
169 add dx, cx
170.ReturnItemIndexInDX:
171 ret
172
173
174;--------------------------------------------------------------------
175; Checks is drive number valid for this system.
176;
177; BootMenu_IsDriveInSystem
178; Parameters:
179; DL: Drive number
180; DS: RAMVARS segment
181; Returns:
182; CF: Set if drive number is valid
183; Clear if drive is not present in system
184; Corrupts registers:
185; AX, CX
186;--------------------------------------------------------------------
187ALIGN JUMP_ALIGN
188BootMenu_IsDriveInSystem:
189 test dl, dl ; Floppy drive?
190 jns SHORT .IsFloppyDriveIsInSystem
191 call RamVars_GetHardDiskCountFromBDAtoCX ; Hard Disk count to CX
192 or cl, 80h ; Set Hard Disk bit to CX
193 jmp SHORT .CompareDriveNumberToDriveCount
194.IsFloppyDriveIsInSystem:
195 call FloppyDrive_GetCountToCX
196.CompareDriveNumberToDriveCount:
197 cmp dl, cl ; Set CF when DL is smaller
198 ret
Note: See TracBrowser for help on using the repository browser.