[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 | ;--------------------------------------------------------------------
|
---|
| 18 | ALIGN JUMP_ALIGN
|
---|
[243] | 19 | BootMenu_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:
|
---|
[241] | 39 | ; CX, DI
|
---|
[128] | 40 | ;--------------------------------------------------------------------
|
---|
| 41 | ALIGN JUMP_ALIGN
|
---|
[241] | 42 | BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS:
|
---|
| 43 | call RamVars_GetSegmentToDS
|
---|
| 44 | ;;; fall-through
|
---|
| 45 |
|
---|
| 46 | ALIGN JUMP_ALIGN
|
---|
[130] | 47 | BootMenu_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
|
---|
[128] | 52 | call FloppyDrive_GetCountToCX
|
---|
[241] | 53 | cmp dl, cl ; Floppy drive?
|
---|
| 54 | jb SHORT .ReturnFloppyDriveInDX ; Set CF if branch taken
|
---|
| 55 | or cl, 80h ; Or 80h into CL before the sub
|
---|
| 56 | ; to cause CF to be set after
|
---|
| 57 | ; and result has high order bit set
|
---|
| 58 | sub dl, cl ; Remove floppy drives from index
|
---|
| 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] | 75 | ALIGN JUMP_ALIGN
|
---|
[88] | 76 | BootMenu_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 | ;--------------------------------------------------------------------
|
---|
| 94 | ALIGN JUMP_ALIGN
|
---|
[124] | 95 | BootMenu_GetMenuitemCountToAX:
|
---|
[32] | 96 | call RamVars_GetHardDiskCountFromBDAtoCX
|
---|
| 97 | xchg ax, cx
|
---|
[124] | 98 | call FloppyDrive_GetCountToCX
|
---|
[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 | ;--------------------------------------------------------------------
|
---|
| 112 | ALIGN JUMP_ALIGN
|
---|
[124] | 113 | BootMenu_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
|
---|
| 121 | ALIGN 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 | ;--------------------------------------------------------------------
|
---|
| 135 | ALIGN JUMP_ALIGN
|
---|
[130] | 136 | BootMenu_GetMenuitemToAXforAsciiHotkeyInAL:
|
---|
| 137 | call Char_ALtoUpperCaseLetter
|
---|
[92] | 138 | call BootMenu_GetLetterForFirstHardDiskToCL
|
---|
[130] | 139 | xor ah, ah
|
---|
[3] | 140 | cmp al, cl ; Letter is for Hard Disk?
|
---|
| 141 | jae SHORT .StartFromHardDiskLetter
|
---|
| 142 | sub al, 'A' ; Letter to Floppy Drive menuitem
|
---|
| 143 | ret
|
---|
| 144 | ALIGN JUMP_ALIGN
|
---|
| 145 | .StartFromHardDiskLetter:
|
---|
| 146 | sub al, cl ; Hard Disk index
|
---|
[124] | 147 | call FloppyDrive_GetCountToCX
|
---|
[130] | 148 | add ax, cx ; Menuitem index
|
---|
[3] | 149 | ret
|
---|
| 150 |
|
---|
[128] | 151 |
|
---|
[3] | 152 | ;--------------------------------------------------------------------
|
---|
| 153 | ; Returns letter for first hard disk. Usually it will be 'c' but it
|
---|
| 154 | ; can be higher if more than two floppy drives are found.
|
---|
| 155 | ;
|
---|
[92] | 156 | ; BootMenu_GetLetterForFirstHardDiskToCL
|
---|
[3] | 157 | ; Parameters:
|
---|
| 158 | ; Nothing
|
---|
| 159 | ; Returns:
|
---|
| 160 | ; CL: Upper case letter for first hard disk
|
---|
| 161 | ; Corrupts registers:
|
---|
| 162 | ; CH
|
---|
| 163 | ;--------------------------------------------------------------------
|
---|
| 164 | ALIGN JUMP_ALIGN
|
---|
[92] | 165 | BootMenu_GetLetterForFirstHardDiskToCL:
|
---|
[124] | 166 | call FloppyDrive_GetCountToCX
|
---|
[3] | 167 | add cl, 'A'
|
---|
[181] | 168 | cmp cl, 'C'
|
---|
| 169 | ja .Return
|
---|
| 170 | mov cl, 'C'
|
---|
| 171 | ALIGN JUMP_ALIGN, ret
|
---|
| 172 | .Return:
|
---|
[3] | 173 | ret
|
---|
| 174 |
|
---|
| 175 |
|
---|
| 176 | ;--------------------------------------------------------------------
|
---|
[124] | 177 | ; BootMenu_GetMenuitemToDXforDriveInDL
|
---|
[3] | 178 | ; Parameters:
|
---|
| 179 | ; DL: Drive number
|
---|
| 180 | ; Returns:
|
---|
[124] | 181 | ; DX: Menuitem index (assuming drive is available)
|
---|
[3] | 182 | ; Corrupts registers:
|
---|
[124] | 183 | ; Nothing
|
---|
[3] | 184 | ;--------------------------------------------------------------------
|
---|
| 185 | ALIGN JUMP_ALIGN
|
---|
[124] | 186 | BootMenu_GetMenuitemToDXforDriveInDL:
|
---|
| 187 | xor dh, dh ; Drive number now in DX
|
---|
[128] | 188 | test dl, dl
|
---|
| 189 | jns SHORT .ReturnItemIndexInDX ; Return if floppy drive (HD bit not set)
|
---|
[124] | 190 | call FloppyDrive_GetCountToCX
|
---|
[127] | 191 | and dl, ~80h ; Clear HD bit
|
---|
[124] | 192 | add dx, cx
|
---|
| 193 | .ReturnItemIndexInDX:
|
---|
[3] | 194 | ret
|
---|
| 195 |
|
---|
| 196 |
|
---|
| 197 | ;--------------------------------------------------------------------
|
---|
| 198 | ; Checks is drive number valid for this system.
|
---|
| 199 | ;
|
---|
| 200 | ; BootMenu_IsDriveInSystem
|
---|
| 201 | ; Parameters:
|
---|
| 202 | ; DL: Drive number
|
---|
| 203 | ; DS: RAMVARS segment
|
---|
| 204 | ; Returns:
|
---|
[28] | 205 | ; CF: Set if drive number is valid
|
---|
[3] | 206 | ; Clear if drive is not present in system
|
---|
| 207 | ; Corrupts registers:
|
---|
[28] | 208 | ; AX, CX
|
---|
[3] | 209 | ;--------------------------------------------------------------------
|
---|
| 210 | ALIGN JUMP_ALIGN
|
---|
| 211 | BootMenu_IsDriveInSystem:
|
---|
[128] | 212 | test dl, dl ; Floppy drive?
|
---|
[130] | 213 | jns SHORT .IsFloppyDriveInSystem
|
---|
[32] | 214 | call RamVars_GetHardDiskCountFromBDAtoCX ; Hard Disk count to CX
|
---|
| 215 | or cl, 80h ; Set Hard Disk bit to CX
|
---|
[28] | 216 | jmp SHORT .CompareDriveNumberToDriveCount
|
---|
[130] | 217 | .IsFloppyDriveInSystem:
|
---|
[124] | 218 | call FloppyDrive_GetCountToCX
|
---|
[28] | 219 | .CompareDriveNumberToDriveCount:
|
---|
[124] | 220 | cmp dl, cl ; Set CF when DL is smaller
|
---|
[3] | 221 | ret
|
---|