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