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