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

Last change on this file since 246 was 243, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

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