[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 | ; |
---|
| 10 | ; BootMenu_DisplayAndReturnSelection |
---|
| 11 | ; Parameters: |
---|
| 12 | ; DS: RAMVARS segment |
---|
| 13 | ; Returns: |
---|
| 14 | ; DX: Untranslated drive number to be used for booting (if CF cleared) |
---|
| 15 | ; Function number (if CF set) |
---|
| 16 | ; CF: Cleared if drive selected |
---|
| 17 | ; Set if function selected |
---|
| 18 | ; Corrupts registers: |
---|
| 19 | ; All General Purpose Registers |
---|
| 20 | ;-------------------------------------------------------------------- |
---|
| 21 | ALIGN JUMP_ALIGN |
---|
| 22 | BootMenu_DisplayAndReturnSelection: |
---|
| 23 | call DriveXlate_Reset |
---|
| 24 | call BootMenuPrint_TheBottomOfScreen |
---|
| 25 | call BootMenu_Enter ; Get selected menuitem index to CX |
---|
| 26 | call BootMenuPrint_ClearScreen |
---|
[88] | 27 | cmp cx, BYTE NO_ITEM_SELECTED |
---|
| 28 | je SHORT BootMenu_DisplayAndReturnSelection |
---|
[92] | 29 | jmp SHORT BootMenu_ConvertMenuitemFromCXtoDriveInDX |
---|
[88] | 30 | |
---|
| 31 | |
---|
| 32 | ;-------------------------------------------------------------------- |
---|
| 33 | ; Enters Boot Menu or submenu. |
---|
| 34 | ; |
---|
| 35 | ; BootMenu_Enter |
---|
| 36 | ; Parameters: |
---|
| 37 | ; Nothing |
---|
| 38 | ; Returns: |
---|
| 39 | ; CX: Index of selected item or NO_ITEM_SELECTED |
---|
| 40 | ; Corrupts registers: |
---|
| 41 | ; BX, DI |
---|
| 42 | ;-------------------------------------------------------------------- |
---|
[3] | 43 | ALIGN JUMP_ALIGN |
---|
[88] | 44 | BootMenu_Enter: |
---|
| 45 | mov bx, BootMenuEvent_Handler |
---|
| 46 | CALL_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX |
---|
| 47 | xchg cx, ax |
---|
[3] | 48 | ret |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | ;-------------------------------------------------------------------- |
---|
| 52 | ; Returns number of menuitems in Boot Menu. |
---|
| 53 | ; |
---|
[88] | 54 | ; BootMenu_GetMenuitemCountToCX |
---|
[3] | 55 | ; Parameters: |
---|
| 56 | ; DS: RAMVARS segment |
---|
| 57 | ; Returns: |
---|
| 58 | ; CX: Number of boot menu items |
---|
| 59 | ; Corrupts registers: |
---|
| 60 | ; AX |
---|
| 61 | ;-------------------------------------------------------------------- |
---|
| 62 | ALIGN JUMP_ALIGN |
---|
[88] | 63 | BootMenu_GetMenuitemCountToCX: |
---|
[32] | 64 | call RamVars_GetHardDiskCountFromBDAtoCX |
---|
| 65 | xchg ax, cx |
---|
[3] | 66 | call FloppyDrive_GetCount |
---|
| 67 | add ax, cx |
---|
| 68 | ret |
---|
| 69 | |
---|
| 70 | |
---|
| 71 | ;-------------------------------------------------------------------- |
---|
[88] | 72 | ; BootMenu_GetHeightToALwithItemCountInCL |
---|
[3] | 73 | ; Parameters: |
---|
[88] | 74 | ; CL: Number of menuitems |
---|
[3] | 75 | ; Returns: |
---|
[88] | 76 | ; AH: Boot menu height |
---|
[3] | 77 | ; Corrupts registers: |
---|
[88] | 78 | ; AL, CL, DI |
---|
[3] | 79 | ;-------------------------------------------------------------------- |
---|
| 80 | ALIGN JUMP_ALIGN |
---|
[88] | 81 | BootMenu_GetHeightToAHwithItemCountInCL: |
---|
| 82 | add cl, BOOT_MENU_HEIGHT_WITHOUT_ITEMS |
---|
| 83 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH |
---|
| 84 | MIN_U ah, cl |
---|
[3] | 85 | ret |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | ;-------------------------------------------------------------------- |
---|
[92] | 89 | ; BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX |
---|
[3] | 90 | ; Parameters: |
---|
[92] | 91 | ; AL: ASCII hotkey starting from upper case 'A' |
---|
[3] | 92 | ; Returns: |
---|
| 93 | ; CX: Menuitem index |
---|
| 94 | ; Corrupts registers: |
---|
| 95 | ; AX |
---|
| 96 | ;-------------------------------------------------------------------- |
---|
| 97 | ALIGN JUMP_ALIGN |
---|
[92] | 98 | BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX: |
---|
| 99 | call BootMenu_GetLetterForFirstHardDiskToCL |
---|
[3] | 100 | cmp al, cl ; Letter is for Hard Disk? |
---|
| 101 | jae SHORT .StartFromHardDiskLetter |
---|
| 102 | sub al, 'A' ; Letter to Floppy Drive menuitem |
---|
| 103 | xchg ax, cx ; Menuitem index to CX |
---|
| 104 | ret |
---|
| 105 | ALIGN JUMP_ALIGN |
---|
| 106 | .StartFromHardDiskLetter: |
---|
| 107 | sub al, cl ; Hard Disk index |
---|
| 108 | call FloppyDrive_GetCount |
---|
| 109 | add cx, ax ; Menuitem index |
---|
| 110 | ret |
---|
| 111 | |
---|
| 112 | ;-------------------------------------------------------------------- |
---|
| 113 | ; Returns letter for first hard disk. Usually it will be 'c' but it |
---|
| 114 | ; can be higher if more than two floppy drives are found. |
---|
| 115 | ; |
---|
[92] | 116 | ; BootMenu_GetLetterForFirstHardDiskToCL |
---|
[3] | 117 | ; Parameters: |
---|
| 118 | ; Nothing |
---|
| 119 | ; Returns: |
---|
| 120 | ; CL: Upper case letter for first hard disk |
---|
| 121 | ; Corrupts registers: |
---|
| 122 | ; CH |
---|
| 123 | ;-------------------------------------------------------------------- |
---|
| 124 | ALIGN JUMP_ALIGN |
---|
[92] | 125 | BootMenu_GetLetterForFirstHardDiskToCL: |
---|
[3] | 126 | call FloppyDrive_GetCount |
---|
| 127 | add cl, 'A' |
---|
| 128 | MAX_U cl, 'C' |
---|
| 129 | ret |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | ;-------------------------------------------------------------------- |
---|
[92] | 133 | ; BootMenu_ConvertMenuitemFromCXtoDriveInDX |
---|
[3] | 134 | ; Parameters: |
---|
| 135 | ; CX: Index of menuitem selected from Boot Menu |
---|
| 136 | ; DS: RAMVARS segment |
---|
| 137 | ; Returns: |
---|
[92] | 138 | ; DX: Drive number to be used for booting |
---|
[3] | 139 | ; Corrupts registers: |
---|
[92] | 140 | ; CX |
---|
[3] | 141 | ;-------------------------------------------------------------------- |
---|
| 142 | ALIGN JUMP_ALIGN |
---|
[92] | 143 | BootMenu_ConvertMenuitemFromCXtoDriveInDX: |
---|
[3] | 144 | mov dx, cx ; Copy menuitem index to DX |
---|
| 145 | call FloppyDrive_GetCount |
---|
| 146 | cmp dx, cx ; Floppy drive? |
---|
| 147 | jb SHORT .ReturnFloppyDriveInDX |
---|
| 148 | sub dx, cx ; Remove floppy drives from index |
---|
| 149 | or dl, 80h |
---|
| 150 | .ReturnFloppyDriveInDX: |
---|
| 151 | ret |
---|
| 152 | |
---|
| 153 | |
---|
| 154 | ;-------------------------------------------------------------------- |
---|
| 155 | ; Converts Floppy or Hard Disk Drive number to menuitem index. |
---|
| 156 | ; This function does not check does the drive really exists. |
---|
| 157 | ; |
---|
| 158 | ; BootMenu_ConvertDriveToMenuitem |
---|
| 159 | ; Parameters: |
---|
| 160 | ; DL: Drive number |
---|
| 161 | ; Returns: |
---|
| 162 | ; CX: Menuitem index (assuming drive is available) |
---|
| 163 | ; Corrupts registers: |
---|
| 164 | ; AX |
---|
| 165 | ;-------------------------------------------------------------------- |
---|
| 166 | ALIGN JUMP_ALIGN |
---|
| 167 | BootMenu_ConvertDriveToMenuitem: |
---|
| 168 | test dl, 80h ; Floppy drive? |
---|
| 169 | jz SHORT .ReturnFloppyMenuitem |
---|
| 170 | call FloppyDrive_GetCount |
---|
| 171 | mov ax, 7Fh ; Load mask to clear floppy bit |
---|
| 172 | and ax, dx ; AX = Hard Disk index |
---|
| 173 | add cx, ax ; Add hard disk index to floppy drive count |
---|
| 174 | ret |
---|
| 175 | ALIGN JUMP_ALIGN |
---|
| 176 | .ReturnFloppyMenuitem: |
---|
| 177 | eMOVZX cx, dl ; Drive number and item index are equal |
---|
| 178 | ret |
---|
| 179 | |
---|
| 180 | |
---|
| 181 | ;-------------------------------------------------------------------- |
---|
| 182 | ; Checks is drive number valid for this system. |
---|
| 183 | ; |
---|
| 184 | ; BootMenu_IsDriveInSystem |
---|
| 185 | ; Parameters: |
---|
| 186 | ; DL: Drive number |
---|
| 187 | ; DS: RAMVARS segment |
---|
| 188 | ; Returns: |
---|
[28] | 189 | ; CF: Set if drive number is valid |
---|
[3] | 190 | ; Clear if drive is not present in system |
---|
| 191 | ; Corrupts registers: |
---|
[28] | 192 | ; AX, CX |
---|
[3] | 193 | ;-------------------------------------------------------------------- |
---|
| 194 | ALIGN JUMP_ALIGN |
---|
| 195 | BootMenu_IsDriveInSystem: |
---|
[32] | 196 | test dl, 80h ; Floppy drive? |
---|
[3] | 197 | jz SHORT .IsFloppyDriveIsInSystem |
---|
[32] | 198 | call RamVars_GetHardDiskCountFromBDAtoCX ; Hard Disk count to CX |
---|
| 199 | or cl, 80h ; Set Hard Disk bit to CX |
---|
[28] | 200 | jmp SHORT .CompareDriveNumberToDriveCount |
---|
[3] | 201 | .IsFloppyDriveIsInSystem: |
---|
[32] | 202 | call FloppyDrive_GetCount ; Floppy Drive count to CX |
---|
[28] | 203 | .CompareDriveNumberToDriveCount: |
---|
[3] | 204 | cmp dl, cl |
---|
| 205 | ret |
---|