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

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

Changes to XTIDE Universal BIOS:

  • Some boot menu fixes but menu does not work yet.
File size: 5.8 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;
[124]51; BootMenu_GetMenuitemCountToAX
[3]52; Parameters:
53; DS: RAMVARS segment
54; Returns:
[124]55; AX: Number of boot menu items
[3]56; Corrupts registers:
[124]57; CX
[3]58;--------------------------------------------------------------------
59ALIGN JUMP_ALIGN
[124]60BootMenu_GetMenuitemCountToAX:
[32]61 call RamVars_GetHardDiskCountFromBDAtoCX
62 xchg ax, cx
[124]63 call FloppyDrive_GetCountToCX
[3]64 add ax, cx
65 ret
66
67
68;--------------------------------------------------------------------
[124]69; BootMenu_GetHeightToAHwithItemCountInAL
[3]70; Parameters:
[124]71; AL: Number of menuitems
[3]72; Returns:
[88]73; AH: Boot menu height
[3]74; Corrupts registers:
[124]75; AL, CX, DI
[3]76;--------------------------------------------------------------------
77ALIGN JUMP_ALIGN
[124]78BootMenu_GetHeightToAHwithItemCountInAL:
79 xchg cx, ax
[88]80 add cl, BOOT_MENU_HEIGHT_WITHOUT_ITEMS
81 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
[124]82 sub ah, MENU_SCREEN_BOTTOM_LINES*2 ; Leave space for bottom info
[88]83 MIN_U ah, cl
[3]84 ret
85
86
87;--------------------------------------------------------------------
[92]88; BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX
[3]89; Parameters:
[92]90; AL: ASCII hotkey starting from upper case 'A'
[3]91; Returns:
92; CX: Menuitem index
93; Corrupts registers:
94; AX
95;--------------------------------------------------------------------
96ALIGN JUMP_ALIGN
[92]97BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX:
98 call BootMenu_GetLetterForFirstHardDiskToCL
[3]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
[124]107 call FloppyDrive_GetCountToCX
[3]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;
[92]115; BootMenu_GetLetterForFirstHardDiskToCL
[3]116; Parameters:
117; Nothing
118; Returns:
119; CL: Upper case letter for first hard disk
120; Corrupts registers:
121; CH
122;--------------------------------------------------------------------
123ALIGN JUMP_ALIGN
[92]124BootMenu_GetLetterForFirstHardDiskToCL:
[124]125 call FloppyDrive_GetCountToCX
[3]126 add cl, 'A'
127 MAX_U cl, 'C'
128 ret
129
130
131;--------------------------------------------------------------------
[92]132; BootMenu_ConvertMenuitemFromCXtoDriveInDX
[3]133; Parameters:
134; CX: Index of menuitem selected from Boot Menu
135; DS: RAMVARS segment
136; Returns:
[92]137; DX: Drive number to be used for booting
[3]138; Corrupts registers:
[92]139; CX
[3]140;--------------------------------------------------------------------
141ALIGN JUMP_ALIGN
[92]142BootMenu_ConvertMenuitemFromCXtoDriveInDX:
[3]143 mov dx, cx ; Copy menuitem index to DX
[124]144 call FloppyDrive_GetCountToCX
[3]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;--------------------------------------------------------------------
[124]154; BootMenu_GetMenuitemToDXforDriveInDL
[3]155; Parameters:
156; DL: Drive number
157; Returns:
[124]158; DX: Menuitem index (assuming drive is available)
[3]159; Corrupts registers:
[124]160; Nothing
[3]161;--------------------------------------------------------------------
162ALIGN JUMP_ALIGN
[124]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 add dx, cx
169.ReturnItemIndexInDX:
[3]170 ret
171
172
173;--------------------------------------------------------------------
174; Checks is drive number valid for this system.
175;
176; BootMenu_IsDriveInSystem
177; Parameters:
178; DL: Drive number
179; DS: RAMVARS segment
180; Returns:
[28]181; CF: Set if drive number is valid
[3]182; Clear if drive is not present in system
183; Corrupts registers:
[28]184; AX, CX
[3]185;--------------------------------------------------------------------
186ALIGN JUMP_ALIGN
187BootMenu_IsDriveInSystem:
[32]188 test dl, 80h ; Floppy drive?
[3]189 jz SHORT .IsFloppyDriveIsInSystem
[32]190 call RamVars_GetHardDiskCountFromBDAtoCX ; Hard Disk count to CX
191 or cl, 80h ; Set Hard Disk bit to CX
[28]192 jmp SHORT .CompareDriveNumberToDriveCount
[3]193.IsFloppyDriveIsInSystem:
[124]194 call FloppyDrive_GetCountToCX
[28]195.CompareDriveNumberToDriveCount:
[124]196 cmp dl, cl ; Set CF when DL is smaller
[3]197 ret
Note: See TracBrowser for help on using the repository browser.