[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: |
---|
[258] | 39 | ; AX, 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 |
---|
[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] | 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: |
---|
[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 | ;-------------------------------------------------------------------- |
---|
| 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 |
---|
| 138 | xor ah, ah |
---|
[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 |
---|
| 146 | ALIGN 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 | ;-------------------------------------------------------------------- |
---|
| 167 | ALIGN JUMP_ALIGN |
---|
[258] | 168 | BootMenu_GetLetterForFirstHardDiskToAL: |
---|
| 169 | call FloppyDrive_GetCountToAX |
---|
| 170 | add al, 'A' |
---|
| 171 | cmp al, 'C' |
---|
[181] | 172 | ja .Return |
---|
[258] | 173 | mov al, 'C' |
---|
[181] | 174 | ALIGN 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 | ;-------------------------------------------------------------------- |
---|
| 188 | ALIGN JUMP_ALIGN |
---|
[124] | 189 | BootMenu_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 | ;-------------------------------------------------------------------- |
---|
| 213 | ALIGN JUMP_ALIGN |
---|
| 214 | BootMenu_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 |
---|