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

Last change on this file since 338 was 294, checked in by krille_n_@…, 13 years ago

Commit 2/2 (BIOS):

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