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

Last change on this file since 98 was 95, checked in by Tomi Tilli, 13 years ago

Changes to XTIDE Universal BIOS:

  • Smaller boot sector loading string.
  • Cleaned boot code a bit.
File size: 6.0 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; 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_GetMenuitemCountToCX
52; Parameters:
53; DS: RAMVARS segment
54; Returns:
55; CX: Number of boot menu items
56; Corrupts registers:
57; AX
58;--------------------------------------------------------------------
59ALIGN JUMP_ALIGN
60BootMenu_GetMenuitemCountToCX:
61 call RamVars_GetHardDiskCountFromBDAtoCX
62 xchg ax, cx
63 call FloppyDrive_GetCount
64 add ax, cx
65 ret
66
67
68;--------------------------------------------------------------------
69; BootMenu_GetHeightToALwithItemCountInCL
70; Parameters:
71; CL: Number of menuitems
72; Returns:
73; AH: Boot menu height
74; Corrupts registers:
75; AL, CL, DI
76;--------------------------------------------------------------------
77ALIGN JUMP_ALIGN
78BootMenu_GetHeightToAHwithItemCountInCL:
79 add cl, BOOT_MENU_HEIGHT_WITHOUT_ITEMS
80 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
81 sub ah, MENU_SCREEN_BOTTOM_LINES*2
82 MIN_U ah, cl
83 ret
84
85
86;--------------------------------------------------------------------
87; BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX
88; Parameters:
89; AL: ASCII hotkey starting from upper case 'A'
90; Returns:
91; CX: Menuitem index
92; Corrupts registers:
93; AX
94;--------------------------------------------------------------------
95ALIGN JUMP_ALIGN
96BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX:
97 call BootMenu_GetLetterForFirstHardDiskToCL
98 cmp al, cl ; Letter is for Hard Disk?
99 jae SHORT .StartFromHardDiskLetter
100 sub al, 'A' ; Letter to Floppy Drive menuitem
101 xchg ax, cx ; Menuitem index to CX
102 ret
103ALIGN JUMP_ALIGN
104.StartFromHardDiskLetter:
105 sub al, cl ; Hard Disk index
106 call FloppyDrive_GetCount
107 add cx, ax ; Menuitem index
108 ret
109
110;--------------------------------------------------------------------
111; Returns letter for first hard disk. Usually it will be 'c' but it
112; can be higher if more than two floppy drives are found.
113;
114; BootMenu_GetLetterForFirstHardDiskToCL
115; Parameters:
116; Nothing
117; Returns:
118; CL: Upper case letter for first hard disk
119; Corrupts registers:
120; CH
121;--------------------------------------------------------------------
122ALIGN JUMP_ALIGN
123BootMenu_GetLetterForFirstHardDiskToCL:
124 call FloppyDrive_GetCount
125 add cl, 'A'
126 MAX_U cl, 'C'
127 ret
128
129
130;--------------------------------------------------------------------
131; BootMenu_ConvertMenuitemFromCXtoDriveInDX
132; Parameters:
133; CX: Index of menuitem selected from Boot Menu
134; DS: RAMVARS segment
135; Returns:
136; DX: Drive number to be used for booting
137; Corrupts registers:
138; CX
139;--------------------------------------------------------------------
140ALIGN JUMP_ALIGN
141BootMenu_ConvertMenuitemFromCXtoDriveInDX:
142 mov dx, cx ; Copy menuitem index to DX
143 call FloppyDrive_GetCount
144 cmp dx, cx ; Floppy drive?
145 jb SHORT .ReturnFloppyDriveInDX
146 sub dx, cx ; Remove floppy drives from index
147 or dl, 80h
148.ReturnFloppyDriveInDX:
149 ret
150
151
152;--------------------------------------------------------------------
153; Converts Floppy or Hard Disk Drive number to menuitem index.
154; This function does not check does the drive really exists.
155;
156; BootMenu_ConvertDriveToMenuitem
157; Parameters:
158; DL: Drive number
159; Returns:
160; CX: Menuitem index (assuming drive is available)
161; Corrupts registers:
162; AX
163;--------------------------------------------------------------------
164ALIGN JUMP_ALIGN
165BootMenu_ConvertDriveToMenuitem:
166 test dl, 80h ; Floppy drive?
167 jz SHORT .ReturnFloppyMenuitem
168 call FloppyDrive_GetCount
169 mov ax, 7Fh ; Load mask to clear floppy bit
170 and ax, dx ; AX = Hard Disk index
171 add cx, ax ; Add hard disk index to floppy drive count
172 ret
173ALIGN JUMP_ALIGN
174.ReturnFloppyMenuitem:
175 eMOVZX cx, dl ; Drive number and item index are equal
176 ret
177
178
179;--------------------------------------------------------------------
180; Checks is drive number valid for this system.
181;
182; BootMenu_IsDriveInSystem
183; Parameters:
184; DL: Drive number
185; DS: RAMVARS segment
186; Returns:
187; CF: Set if drive number is valid
188; Clear if drive is not present in system
189; Corrupts registers:
190; AX, CX
191;--------------------------------------------------------------------
192ALIGN JUMP_ALIGN
193BootMenu_IsDriveInSystem:
194 test dl, 80h ; Floppy drive?
195 jz SHORT .IsFloppyDriveIsInSystem
196 call RamVars_GetHardDiskCountFromBDAtoCX ; Hard Disk count to CX
197 or cl, 80h ; Set Hard Disk bit to CX
198 jmp SHORT .CompareDriveNumberToDriveCount
199.IsFloppyDriveIsInSystem:
200 call FloppyDrive_GetCount ; Floppy Drive count to CX
201.CompareDriveNumberToDriveCount:
202 cmp dl, cl
203 ret
Note: See TracBrowser for help on using the repository browser.