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

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

Changes to XTIDE Universal BIOS:

  • Smaller boot sector loading string.
  • Cleaned boot code a bit.
File size: 6.0 KB
RevLine 
[88]1; Project name : XTIDE Universal BIOS
[3]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:
[95]14; DX: Untranslated drive number to be used for booting
[3]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
[88]24 cmp cx, BYTE NO_ITEM_SELECTED
[95]25 je SHORT BootMenu_DisplayAndReturnSelection ; Clear screen and display menu
[92]26 jmp SHORT BootMenu_ConvertMenuitemFromCXtoDriveInDX
[88]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;--------------------------------------------------------------------
[3]40ALIGN JUMP_ALIGN
[88]41BootMenu_Enter:
42 mov bx, BootMenuEvent_Handler
43 CALL_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX
44 xchg cx, ax
[3]45 ret
46
47
48;--------------------------------------------------------------------
49; Returns number of menuitems in Boot Menu.
50;
[88]51; BootMenu_GetMenuitemCountToCX
[3]52; Parameters:
53; DS: RAMVARS segment
54; Returns:
55; CX: Number of boot menu items
56; Corrupts registers:
57; AX
58;--------------------------------------------------------------------
59ALIGN JUMP_ALIGN
[88]60BootMenu_GetMenuitemCountToCX:
[32]61 call RamVars_GetHardDiskCountFromBDAtoCX
62 xchg ax, cx
[3]63 call FloppyDrive_GetCount
64 add ax, cx
65 ret
66
67
68;--------------------------------------------------------------------
[88]69; BootMenu_GetHeightToALwithItemCountInCL
[3]70; Parameters:
[88]71; CL: Number of menuitems
[3]72; Returns:
[88]73; AH: Boot menu height
[3]74; Corrupts registers:
[88]75; AL, CL, DI
[3]76;--------------------------------------------------------------------
77ALIGN JUMP_ALIGN
[88]78BootMenu_GetHeightToAHwithItemCountInCL:
79 add cl, BOOT_MENU_HEIGHT_WITHOUT_ITEMS
80 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
[93]81 sub ah, MENU_SCREEN_BOTTOM_LINES*2
[88]82 MIN_U ah, cl
[3]83 ret
84
85
86;--------------------------------------------------------------------
[92]87; BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX
[3]88; Parameters:
[92]89; AL: ASCII hotkey starting from upper case 'A'
[3]90; Returns:
91; CX: Menuitem index
92; Corrupts registers:
93; AX
94;--------------------------------------------------------------------
95ALIGN JUMP_ALIGN
[92]96BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX:
97 call BootMenu_GetLetterForFirstHardDiskToCL
[3]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;
[92]114; BootMenu_GetLetterForFirstHardDiskToCL
[3]115; Parameters:
116; Nothing
117; Returns:
118; CL: Upper case letter for first hard disk
119; Corrupts registers:
120; CH
121;--------------------------------------------------------------------
122ALIGN JUMP_ALIGN
[92]123BootMenu_GetLetterForFirstHardDiskToCL:
[3]124 call FloppyDrive_GetCount
125 add cl, 'A'
126 MAX_U cl, 'C'
127 ret
128
129
130;--------------------------------------------------------------------
[92]131; BootMenu_ConvertMenuitemFromCXtoDriveInDX
[3]132; Parameters:
133; CX: Index of menuitem selected from Boot Menu
134; DS: RAMVARS segment
135; Returns:
[92]136; DX: Drive number to be used for booting
[3]137; Corrupts registers:
[92]138; CX
[3]139;--------------------------------------------------------------------
140ALIGN JUMP_ALIGN
[92]141BootMenu_ConvertMenuitemFromCXtoDriveInDX:
[3]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:
[28]187; CF: Set if drive number is valid
[3]188; Clear if drive is not present in system
189; Corrupts registers:
[28]190; AX, CX
[3]191;--------------------------------------------------------------------
192ALIGN JUMP_ALIGN
193BootMenu_IsDriveInSystem:
[32]194 test dl, 80h ; Floppy drive?
[3]195 jz SHORT .IsFloppyDriveIsInSystem
[32]196 call RamVars_GetHardDiskCountFromBDAtoCX ; Hard Disk count to CX
197 or cl, 80h ; Set Hard Disk bit to CX
[28]198 jmp SHORT .CompareDriveNumberToDriveCount
[3]199.IsFloppyDriveIsInSystem:
[32]200 call FloppyDrive_GetCount ; Floppy Drive count to CX
[28]201.CompareDriveNumberToDriveCount:
[3]202 cmp dl, cl
203 ret
Note: See TracBrowser for help on using the repository browser.