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

Last change on this file since 127 was 127, checked in by Tomi Tilli, 14 years ago

Changes to XTIDE Universal BIOS:

  • More boot menu fixes.
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 jmp SHORT BootMenu_ConvertMenuitemFromCXtoDriveInDX
27
28
29;--------------------------------------------------------------------
30; Enters Boot Menu or submenu.
31;
32; BootMenu_Enter
33; Parameters:
34; Nothing
35; Returns:
36; CX: Index of selected item or NO_ITEM_SELECTED
37; Corrupts registers:
38; AX, BX, DI
39;--------------------------------------------------------------------
40ALIGN JUMP_ALIGN
41BootMenu_Enter:
42 mov bx, BootMenuEvent_Handler
43 CALL_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX
44 xchg cx, ax
45 ret
46
47
48;--------------------------------------------------------------------
49; Returns number of menuitems in Boot Menu.
50;
51; BootMenu_GetMenuitemCountToAX
52; Parameters:
53; DS: RAMVARS segment
54; Returns:
55; AX: Number of boot menu items
56; Corrupts registers:
57; CX
58;--------------------------------------------------------------------
59ALIGN JUMP_ALIGN
60BootMenu_GetMenuitemCountToAX:
61 call RamVars_GetHardDiskCountFromBDAtoCX
62 xchg ax, cx
63 call FloppyDrive_GetCountToCX
64 add ax, cx
65 ret
66
67
68;--------------------------------------------------------------------
69; BootMenu_GetHeightToAHwithItemCountInAL
70; Parameters:
71; AL: Number of menuitems
72; Returns:
73; AH: Boot menu height
74; Corrupts registers:
75; AL, CX, DI
76;--------------------------------------------------------------------
77ALIGN JUMP_ALIGN
78BootMenu_GetHeightToAHwithItemCountInAL:
79 xchg cx, ax
80 add cl, BOOT_MENU_HEIGHT_WITHOUT_ITEMS
81 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
82 sub ah, MENU_SCREEN_BOTTOM_LINES*2 ; Leave space for bottom info
83 MIN_U ah, cl
84 ret
85
86
87;--------------------------------------------------------------------
88; BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX
89; Parameters:
90; AL: ASCII hotkey starting from upper case 'A'
91; Returns:
92; CX: Menuitem index
93; Corrupts registers:
94; AX
95;--------------------------------------------------------------------
96ALIGN JUMP_ALIGN
97BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX:
98 call BootMenu_GetLetterForFirstHardDiskToCL
99 cmp al, cl ; Letter is for Hard Disk?
100 jae SHORT .StartFromHardDiskLetter
101 sub al, 'A' ; Letter to Floppy Drive menuitem
102 xchg ax, cx ; Menuitem index to CX
103 ret
104ALIGN JUMP_ALIGN
105.StartFromHardDiskLetter:
106 sub al, cl ; Hard Disk index
107 call FloppyDrive_GetCountToCX
108 add cx, ax ; Menuitem index
109 ret
110
111;--------------------------------------------------------------------
112; Returns letter for first hard disk. Usually it will be 'c' but it
113; can be higher if more than two floppy drives are found.
114;
115; BootMenu_GetLetterForFirstHardDiskToCL
116; Parameters:
117; Nothing
118; Returns:
119; CL: Upper case letter for first hard disk
120; Corrupts registers:
121; CH
122;--------------------------------------------------------------------
123ALIGN JUMP_ALIGN
124BootMenu_GetLetterForFirstHardDiskToCL:
125 call FloppyDrive_GetCountToCX
126 add cl, 'A'
127 MAX_U cl, 'C'
128 ret
129
130
131;--------------------------------------------------------------------
132; BootMenu_ConvertMenuitemFromCXtoDriveInDX
133; Parameters:
134; CX: Index of menuitem selected from Boot Menu
135; DS: RAMVARS segment
136; Returns:
137; DX: Drive number to be used for booting
138; Corrupts registers:
139; CX
140;--------------------------------------------------------------------
141ALIGN JUMP_ALIGN
142BootMenu_ConvertMenuitemFromCXtoDriveInDX:
143 mov dx, cx ; Copy menuitem index to DX
144 call FloppyDrive_GetCountToCX
145 cmp dx, cx ; Floppy drive?
146 jb SHORT .ReturnFloppyDriveInDX
147 sub dx, cx ; Remove floppy drives from index
148 or dl, 80h
149.ReturnFloppyDriveInDX:
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, 80h
166 jz 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, 80h ; Floppy drive?
190 jz 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.