[392] | 1 | ; Project name : XTIDE Universal BIOS |
---|
| 2 | ; Description : Hotkey Bar related functions. |
---|
| 3 | |
---|
| 4 | ; |
---|
[399] | 5 | ; XTIDE Universal BIOS and Associated Tools |
---|
[526] | 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team. |
---|
[392] | 7 | ; |
---|
| 8 | ; This program is free software; you can redistribute it and/or modify |
---|
| 9 | ; it under the terms of the GNU General Public License as published by |
---|
| 10 | ; the Free Software Foundation; either version 2 of the License, or |
---|
| 11 | ; (at your option) any later version. |
---|
[399] | 12 | ; |
---|
[392] | 13 | ; This program is distributed in the hope that it will be useful, |
---|
| 14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | ; GNU General Public License for more details. |
---|
[399] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 18 | ; |
---|
[392] | 19 | |
---|
| 20 | ; Section containing code |
---|
| 21 | SECTION .text |
---|
| 22 | |
---|
[599] | 23 | |
---|
[392] | 24 | ;-------------------------------------------------------------------- |
---|
[603] | 25 | ; Handler for INT 1Ch User Timer Tick. |
---|
[599] | 26 | ; Reads key presses and draws hotkey bar. |
---|
| 27 | ; |
---|
| 28 | ; HotkeyBar_TimerTickHandler |
---|
| 29 | ; Parameters: |
---|
[603] | 30 | ; Nothing |
---|
[599] | 31 | ; Returns: |
---|
| 32 | ; Nothing |
---|
| 33 | ; Corrupts registers: |
---|
[601] | 34 | ; Nothing |
---|
[599] | 35 | ;-------------------------------------------------------------------- |
---|
[601] | 36 | ALIGN JUMP_ALIGN |
---|
[599] | 37 | HotkeyBar_TimerTickHandler: |
---|
| 38 | push es |
---|
[603] | 39 | %ifndef USE_186 ; LOAD_BDA_SEGMENT_TO will corrupt AX on 8088/8086 |
---|
[599] | 40 | push ax |
---|
| 41 | %endif |
---|
| 42 | |
---|
[600] | 43 | ;!!! Keep interrupts disabled so there won't be another |
---|
| 44 | ; timer tick call before we are ready |
---|
| 45 | |
---|
[599] | 46 | LOAD_BDA_SEGMENT_TO es, ax |
---|
| 47 | |
---|
| 48 | ; Call previous handler |
---|
| 49 | pushf |
---|
[601] | 50 | call FAR [es:BOOTVARS.hotkeyVars+HOTKEYVARS.fpPrevTimerHandler] |
---|
[599] | 51 | |
---|
[600] | 52 | ; Update Hotkeybar (process key input and draw) every fourth tick |
---|
| 53 | test BYTE [es:BDA.dwTimerTicks], 11b |
---|
[599] | 54 | jnz SHORT .ReturnFromHandler |
---|
| 55 | |
---|
[603] | 56 | push ds |
---|
[599] | 57 | %ifdef USE_186 |
---|
[603] | 58 | pusha |
---|
[599] | 59 | %else |
---|
[603] | 60 | push di |
---|
| 61 | push si |
---|
| 62 | push dx |
---|
| 63 | push cx |
---|
| 64 | %endif |
---|
| 65 | call RamVars_GetSegmentToDS |
---|
| 66 | call HotkeyBar_UpdateDuringDriveDetection |
---|
| 67 | %ifdef USE_186 |
---|
| 68 | popa |
---|
| 69 | %else |
---|
[599] | 70 | pop cx |
---|
| 71 | pop dx |
---|
| 72 | pop si |
---|
| 73 | pop di |
---|
| 74 | %endif |
---|
| 75 | pop ds |
---|
[603] | 76 | |
---|
| 77 | .ReturnFromHandler: |
---|
| 78 | %ifndef USE_186 |
---|
| 79 | pop ax |
---|
| 80 | %endif |
---|
[599] | 81 | pop es |
---|
| 82 | iret |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | ;-------------------------------------------------------------------- |
---|
[528] | 86 | ; Scans key presses and draws any hotkey changes. |
---|
| 87 | ; |
---|
[392] | 88 | ; HotkeyBar_UpdateDuringDriveDetection |
---|
| 89 | ; Parameters: |
---|
| 90 | ; DS: RAMVARS segment |
---|
| 91 | ; ES: BDA segment (zero) |
---|
| 92 | ; Returns: |
---|
| 93 | ; Nothing |
---|
| 94 | ; Corrupts registers: |
---|
| 95 | ; AX, CX, DX, SI, DI |
---|
| 96 | ;-------------------------------------------------------------------- |
---|
[603] | 97 | HotkeyBar_UpdateDuringDriveDetection: |
---|
[528] | 98 | call ScanHotkeysFromKeyBufferAndStoreToBootvars |
---|
[599] | 99 | |
---|
| 100 | ; If ESC pressed, abort detection by forcing timeout |
---|
| 101 | cmp al, ESC_SCANCODE |
---|
| 102 | jne SHORT .ContinueDrawing |
---|
| 103 | mov BYTE [RAMVARS.bTimeoutTicksLeft], 0 |
---|
| 104 | .ContinueDrawing: |
---|
[392] | 105 | ; Fall to HotkeyBar_DrawToTopOfScreen |
---|
[505] | 106 | |
---|
| 107 | |
---|
[392] | 108 | ;-------------------------------------------------------------------- |
---|
| 109 | ; HotkeyBar_DrawToTopOfScreen |
---|
| 110 | ; Parameters: |
---|
| 111 | ; DS: RAMVARS segment |
---|
| 112 | ; ES: BDA segment (zero) |
---|
| 113 | ; Returns: |
---|
| 114 | ; Nothing |
---|
| 115 | ; Corrupts registers: |
---|
| 116 | ; AX, CX, DX, SI, DI |
---|
| 117 | ;-------------------------------------------------------------------- |
---|
| 118 | HotkeyBar_DrawToTopOfScreen: |
---|
[603] | 119 | ; Store current screen coordinates to stack |
---|
| 120 | ; (to be restored when Hotkey Bar is rendered) |
---|
| 121 | CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX |
---|
[392] | 122 | push ax |
---|
| 123 | |
---|
[603] | 124 | ; Move cursor to top left corner (0, 0) |
---|
| 125 | xor ax, ax |
---|
| 126 | call HotkeyBar_SetCursorCoordinatesFromAX |
---|
[392] | 127 | ; Fall to .PrintFloppyDriveHotkeys |
---|
| 128 | |
---|
| 129 | ;-------------------------------------------------------------------- |
---|
| 130 | ; .PrintFloppyDriveHotkeys |
---|
| 131 | ; Parameters: |
---|
| 132 | ; DS: RAMVARS segment |
---|
| 133 | ; ES: BDA segment (zero) |
---|
| 134 | ; Returns: |
---|
| 135 | ; Nothing |
---|
| 136 | ; Corrupts registers: |
---|
| 137 | ; AX, CX, DX, SI, DI |
---|
| 138 | ;-------------------------------------------------------------------- |
---|
| 139 | .PrintFloppyDriveHotkeys: |
---|
| 140 | call FloppyDrive_GetCountToAX |
---|
[568] | 141 | xchg cx, ax ; Any Floppy Drives? |
---|
| 142 | jcxz .SkipFloppyDriveHotkeys |
---|
[392] | 143 | |
---|
[492] | 144 | mov ax, (ANGLE_QUOTE_RIGHT << 8) | DEFAULT_FLOPPY_DRIVE_LETTER |
---|
[500] | 145 | mov cl, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFddLetter] |
---|
[492] | 146 | mov di, g_szFDD |
---|
[593] | 147 | |
---|
| 148 | ; Clear CH if floppy drive is selected for boot |
---|
[601] | 149 | %if 0 ; Not needed until more flags added |
---|
| 150 | mov ch, FLG_HOTKEY_HD_FIRST |
---|
| 151 | and ch, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags] |
---|
| 152 | %else |
---|
[593] | 153 | mov ch, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags] |
---|
[601] | 154 | %endif |
---|
[392] | 155 | call FormatDriveHotkeyString |
---|
| 156 | |
---|
| 157 | .SkipFloppyDriveHotkeys: |
---|
| 158 | ; Fall to .PrintHardDriveHotkeys |
---|
| 159 | |
---|
| 160 | ;-------------------------------------------------------------------- |
---|
| 161 | ; .PrintHardDriveHotkeys |
---|
| 162 | ; Parameters: |
---|
| 163 | ; DS: RAMVARS segment |
---|
| 164 | ; ES: BDA segment (zero) |
---|
| 165 | ; Returns: |
---|
| 166 | ; Nothing |
---|
| 167 | ; Corrupts registers: |
---|
| 168 | ; AX, CX, DX, SI, DI |
---|
| 169 | ;-------------------------------------------------------------------- |
---|
[547] | 170 | call BootVars_GetLetterForFirstHardDriveToAX |
---|
[392] | 171 | mov ah, ANGLE_QUOTE_RIGHT |
---|
[596] | 172 | mov cx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wHddLetterAndFlags] ; Letter to CL, flags to CH |
---|
[600] | 173 | ;and ch, FLG_HOTKEY_HD_FIRST ; Not needed until more flags added |
---|
[593] | 174 | xor ch, FLG_HOTKEY_HD_FIRST ; Clear CH if HD is selected for boot, set otherwise |
---|
[492] | 175 | mov di, g_szHDD |
---|
[392] | 176 | call FormatDriveHotkeyString |
---|
| 177 | ; Fall to .PrintBootMenuHotkey |
---|
| 178 | |
---|
| 179 | ;-------------------------------------------------------------------- |
---|
| 180 | ; .PrintBootMenuHotkey |
---|
| 181 | ; Parameters: |
---|
| 182 | ; ES: BDA segment (zero) |
---|
| 183 | ; Returns: |
---|
| 184 | ; Nothing |
---|
| 185 | ; Corrupts registers: |
---|
| 186 | ; AX, CX, DX, SI, DI |
---|
| 187 | ;-------------------------------------------------------------------- |
---|
| 188 | .PrintBootMenuHotkey: |
---|
| 189 | %ifdef MODULE_BOOT_MENU |
---|
[492] | 190 | mov ax, BOOT_MENU_HOTKEY_SCANCODE | ('2' << 8) |
---|
| 191 | mov di, g_szBootMenu |
---|
[392] | 192 | call FormatFunctionHotkeyString |
---|
| 193 | %endif |
---|
[492] | 194 | ; Fall to .PrintComDetectHotkey |
---|
[392] | 195 | |
---|
| 196 | ;-------------------------------------------------------------------- |
---|
[492] | 197 | ; .PrintComDetectHotkey |
---|
| 198 | ; Parameters: |
---|
| 199 | ; ES: BDA segment (zero) |
---|
| 200 | ; Returns: |
---|
| 201 | ; Nothing |
---|
| 202 | ; Corrupts registers: |
---|
| 203 | ; AX, CX, DX, SI, DI |
---|
| 204 | ;-------------------------------------------------------------------- |
---|
| 205 | .PrintComDetectHotkey: |
---|
| 206 | %ifdef MODULE_SERIAL |
---|
| 207 | mov ax, COM_DETECT_HOTKEY_SCANCODE | ('6' << 8) |
---|
| 208 | mov di, g_szHotComDetect |
---|
| 209 | call FormatFunctionHotkeyString |
---|
| 210 | %endif |
---|
[505] | 211 | ; Fall to .PrintRomBootHotkey |
---|
[492] | 212 | |
---|
| 213 | ;-------------------------------------------------------------------- |
---|
[392] | 214 | ; .PrintRomBootHotkey |
---|
| 215 | ; Parameters: |
---|
| 216 | ; ES: BDA segment (zero) |
---|
| 217 | ; Returns: |
---|
| 218 | ; Nothing |
---|
| 219 | ; Corrupts registers: |
---|
| 220 | ; AX, CX, DX, SI, DI |
---|
| 221 | ;-------------------------------------------------------------------- |
---|
| 222 | .PrintRomBootHotkey: |
---|
[492] | 223 | mov ax, ROM_BOOT_HOTKEY_SCANCODE | ('8' << 8) |
---|
| 224 | mov di, g_szRomBoot |
---|
[392] | 225 | call FormatFunctionHotkeyString |
---|
| 226 | ; Fall to .EndHotkeyBarRendering |
---|
| 227 | |
---|
| 228 | ;-------------------------------------------------------------------- |
---|
| 229 | ; .EndHotkeyBarRendering |
---|
| 230 | ; Parameters: |
---|
| 231 | ; Stack: Screen coordinates before drawing Hotkey Bar |
---|
| 232 | ; Returns: |
---|
| 233 | ; Nothing |
---|
| 234 | ; Corrupts registers: |
---|
| 235 | ; AX, CX, DI |
---|
| 236 | ;-------------------------------------------------------------------- |
---|
| 237 | .EndHotkeyBarRendering: |
---|
[603] | 238 | ; Clear the rest of the top row |
---|
| 239 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH |
---|
| 240 | eMOVZX cx, al |
---|
| 241 | CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX |
---|
| 242 | sub cl, al |
---|
| 243 | mov al, ' ' |
---|
| 244 | CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX |
---|
| 245 | |
---|
| 246 | ; Restore the saved coordinates from stack |
---|
[392] | 247 | pop ax |
---|
[603] | 248 | ; Fall to HotkeyBar_SetCursorCoordinatesFromAX |
---|
[392] | 249 | |
---|
| 250 | |
---|
| 251 | ;-------------------------------------------------------------------- |
---|
[603] | 252 | ; HotkeyBar_SetCursorCoordinatesFromAX |
---|
[392] | 253 | ; Parameters: |
---|
| 254 | ; Nothing |
---|
| 255 | ; Returns: |
---|
| 256 | ; Nothing |
---|
| 257 | ; Corrupts registers: |
---|
[603] | 258 | ; AX, DI |
---|
[392] | 259 | ;-------------------------------------------------------------------- |
---|
[603] | 260 | HotkeyBar_SetCursorCoordinatesFromAX: |
---|
| 261 | JMP_DISPLAY_LIBRARY SetCursorCoordinatesFromAX |
---|
[392] | 262 | |
---|
| 263 | |
---|
| 264 | ;-------------------------------------------------------------------- |
---|
| 265 | ; FormatDriveHotkeyString |
---|
| 266 | ; Parameters: |
---|
[593] | 267 | ; CH: Zero if letter in CL is selected for boot |
---|
[392] | 268 | ; CL: Drive letter hotkey from BOOTVARS |
---|
[492] | 269 | ; AL: First character for drive key string |
---|
| 270 | ; AH: Second character for drive key string (ANGLE_QUOTE_RIGHT) |
---|
[392] | 271 | ; SI: Offset to hotkey description string |
---|
| 272 | ; ES: BDA segment (zero) |
---|
| 273 | ; Returns: |
---|
| 274 | ; Nothing |
---|
| 275 | ; Corrupts registers: |
---|
| 276 | ; AX, CX, DX, SI, DI |
---|
| 277 | ;-------------------------------------------------------------------- |
---|
[593] | 278 | FormatDriveHotkeyString: |
---|
| 279 | ; Invalid scancodes are filtered on HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX |
---|
| 280 | ; so here we have either drive letter or function key pressed. If latter, draw |
---|
| 281 | ; drive letters as unselected |
---|
| 282 | cmp BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode], FIRST_FUNCTION_KEY_SCANCODE |
---|
| 283 | jae SHORT GetNonSelectedHotkeyDescriptionAttributeToDX |
---|
[392] | 284 | |
---|
[593] | 285 | ; Drive selected to boot from? |
---|
| 286 | test ch, ch |
---|
| 287 | jnz SHORT GetNonSelectedHotkeyDescriptionAttributeToDX |
---|
| 288 | jmp SHORT GetSelectedHotkeyDescriptionAttributeToDX |
---|
| 289 | |
---|
| 290 | |
---|
[392] | 291 | ;-------------------------------------------------------------------- |
---|
| 292 | ; FormatFunctionHotkeyString |
---|
| 293 | ; Parameters: |
---|
[492] | 294 | ; AL: Scancode of function key, to know which if any to show as selected |
---|
| 295 | ; Later replaced with an 'F' for the call to the output routine |
---|
| 296 | ; AH: Second character for drive key string |
---|
[392] | 297 | ; SI: Offset to hotkey description string |
---|
| 298 | ; ES: BDA segment (zero) |
---|
| 299 | ; Returns: |
---|
| 300 | ; Nothing |
---|
| 301 | ; Corrupts registers: |
---|
| 302 | ; AX, CX, DX, SI, DI |
---|
| 303 | ;-------------------------------------------------------------------- |
---|
| 304 | FormatFunctionHotkeyString: |
---|
[492] | 305 | xor cx, cx ; Null character, eaten in output routines |
---|
[392] | 306 | |
---|
[492] | 307 | cmp [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode], al |
---|
| 308 | mov al, 'F' ; Replace scancode with character for output |
---|
[392] | 309 | |
---|
| 310 | %ifdef MODULE_BOOT_MENU |
---|
[492] | 311 | |
---|
[593] | 312 | GetSelectedHotkeyDescriptionAttributeToDX: |
---|
[596] | 313 | mov si, ATTRIBUTE_CHARS.cHighlightedItem ; Selected hotkey |
---|
[593] | 314 | je SHORT GetDescriptionAttributeToDX ; From compare with bScancode above and from FormatDriveHotkeyString |
---|
[392] | 315 | |
---|
| 316 | GetNonSelectedHotkeyDescriptionAttributeToDX: |
---|
[596] | 317 | mov si, ATTRIBUTE_CHARS.cItem ; Unselected hotkey |
---|
[392] | 318 | |
---|
| 319 | ; Display Library should not be called like this |
---|
| 320 | GetDescriptionAttributeToDX: |
---|
[492] | 321 | xchg dx, ax |
---|
[392] | 322 | call MenuAttribute_GetToAXfromTypeInSI |
---|
| 323 | xchg dx, ax ; DX = Description attribute |
---|
[505] | 324 | ;; fall through to PushHotkeyParamsAndFormat |
---|
[392] | 325 | |
---|
| 326 | |
---|
[500] | 327 | %else ; if no MODULE_BOOT_MENU - No boot menu so use simpler attributes |
---|
| 328 | |
---|
[593] | 329 | GetSelectedHotkeyDescriptionAttributeToDX: |
---|
[410] | 330 | mov dx, (COLOR_ATTRIBUTE(COLOR_YELLOW, COLOR_CYAN) << 8) | MONO_REVERSE_BLINK |
---|
[593] | 331 | je SHORT SelectAttributeFromDHorDLbasedOnVideoMode ; From compare with bScancode above and from FormatDriveHotkeyString |
---|
[392] | 332 | |
---|
| 333 | GetNonSelectedHotkeyDescriptionAttributeToDX: |
---|
[410] | 334 | mov dx, (COLOR_ATTRIBUTE(COLOR_BLACK, COLOR_CYAN) << 8) | MONO_REVERSE |
---|
[492] | 335 | |
---|
[410] | 336 | SelectAttributeFromDHorDLbasedOnVideoMode: |
---|
[500] | 337 | mov ch, [es:BDA.bVidMode] ; We only need to preserve CL |
---|
| 338 | shr ch, 1 |
---|
[410] | 339 | jnc SHORT .AttributeLoadedToDL ; Black & White modes |
---|
[500] | 340 | shr ch, 1 |
---|
[410] | 341 | jnz SHORT .AttributeLoadedToDL ; MDA |
---|
| 342 | mov dl, dh |
---|
| 343 | .AttributeLoadedToDL: |
---|
[505] | 344 | ;; fall through to PushHotkeyParamsAndFormat |
---|
[410] | 345 | |
---|
[492] | 346 | %endif ; MODULE_BOOT_MENU |
---|
[392] | 347 | |
---|
| 348 | |
---|
| 349 | ;-------------------------------------------------------------------- |
---|
| 350 | ; PushHotkeyParamsAndFormat |
---|
| 351 | ; Parameters: |
---|
[500] | 352 | ; AL: First character |
---|
| 353 | ; AH: Second character |
---|
[392] | 354 | ; DX: Description Attribute |
---|
| 355 | ; CX: Description string parameter |
---|
[492] | 356 | ; CS:DI: Description string |
---|
[392] | 357 | ; Returns: |
---|
| 358 | ; Nothing |
---|
| 359 | ; Corrupts registers: |
---|
| 360 | ; AX, SI, DI |
---|
| 361 | ;-------------------------------------------------------------------- |
---|
| 362 | PushHotkeyParamsAndFormat: |
---|
| 363 | push bp |
---|
| 364 | mov bp, sp |
---|
| 365 | |
---|
[492] | 366 | mov si, MONO_BRIGHT |
---|
[392] | 367 | |
---|
[492] | 368 | push si ; Key attribute |
---|
| 369 | push ax ; First Character |
---|
| 370 | mov al, ah |
---|
| 371 | push ax ; Second Character |
---|
| 372 | |
---|
[392] | 373 | push dx ; Description attribute |
---|
[492] | 374 | push di ; Description string |
---|
[392] | 375 | push cx ; Description string parameter |
---|
[505] | 376 | |
---|
[492] | 377 | push si ; Key attribute for last space |
---|
[392] | 378 | |
---|
| 379 | mov si, g_szHotkey |
---|
| 380 | jmp DetectPrint_FormatCSSIfromParamsInSSBP |
---|
| 381 | |
---|
| 382 | |
---|
| 383 | ;-------------------------------------------------------------------- |
---|
[599] | 384 | ; HotkeyBar_StoreDefaultDriveLettersToHotkeyVars |
---|
| 385 | ; Parameters: |
---|
| 386 | ; ES: BDA Segment |
---|
| 387 | ; Returns: |
---|
| 388 | ; Nothing |
---|
| 389 | ; Corrupts registers: |
---|
| 390 | ; AX |
---|
| 391 | ;-------------------------------------------------------------------- |
---|
| 392 | HotkeyBar_StoreDefaultDriveLettersToHotkeyVars: |
---|
| 393 | call BootVars_GetLetterForFirstHardDriveToAX |
---|
| 394 | mov ah, DEFAULT_FLOPPY_DRIVE_LETTER |
---|
| 395 | xchg al, ah |
---|
| 396 | mov [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wFddAndHddLetters], ax |
---|
| 397 | ret |
---|
| 398 | |
---|
| 399 | |
---|
| 400 | ;-------------------------------------------------------------------- |
---|
| 401 | ; HotkeyBar_InitializeVariables |
---|
| 402 | ; Parameters: |
---|
| 403 | ; DS: RAMVARS Segment |
---|
| 404 | ; ES: BDA Segment |
---|
| 405 | ; Returns: |
---|
| 406 | ; Nothing |
---|
| 407 | ; Corrupts registers: |
---|
| 408 | ; AX, CX, DX, DI |
---|
| 409 | ;-------------------------------------------------------------------- |
---|
| 410 | HotkeyBar_InitializeVariables: |
---|
| 411 | push ds |
---|
| 412 | push es |
---|
| 413 | pop ds |
---|
| 414 | |
---|
| 415 | ; Store system 1Ch Timer Tick handler and install our hotkeybar handler |
---|
[603] | 416 | mov ax, [BIOS_USER_TIMER_TICK_INTERRUPT_1Ch*4] |
---|
[599] | 417 | mov [BOOTVARS.hotkeyVars+HOTKEYVARS.fpPrevTimerHandler], ax |
---|
[603] | 418 | mov ax, [BIOS_USER_TIMER_TICK_INTERRUPT_1Ch*4+2] |
---|
[599] | 419 | mov [BOOTVARS.hotkeyVars+HOTKEYVARS.fpPrevTimerHandler+2], ax |
---|
[603] | 420 | mov al, BIOS_USER_TIMER_TICK_INTERRUPT_1Ch |
---|
[599] | 421 | mov si, HotkeyBar_TimerTickHandler |
---|
| 422 | call Interrupts_InstallHandlerToVectorInALFromCSSI |
---|
| 423 | |
---|
| 424 | ; Store time when hotkeybar is displayed |
---|
| 425 | ; (it will be displayed after initialization is complete) |
---|
| 426 | call TimerTicks_ReadFromBdaToAX |
---|
| 427 | mov [BOOTVARS.hotkeyVars+HOTKEYVARS.wTimeWhenDisplayed], ax |
---|
| 428 | |
---|
| 429 | pop ds |
---|
| 430 | |
---|
| 431 | ; Initialize HOTKEYVARS by storing default drives to boot from |
---|
| 432 | call HotkeyBar_StoreDefaultDriveLettersToHotkeyVars |
---|
| 433 | mov dl, [cs:ROMVARS.bBootDrv] |
---|
| 434 | ; Fall to HotkeyBar_StoreHotkeyToBootvarsForDriveNumberInDL |
---|
| 435 | |
---|
| 436 | |
---|
| 437 | ;-------------------------------------------------------------------- |
---|
[528] | 438 | ; HotkeyBar_StoreHotkeyToBootvarsForDriveNumberInDL |
---|
[395] | 439 | ; Parameters: |
---|
| 440 | ; DS: RAMVARS segment |
---|
| 441 | ; ES: BDA segment (zero) |
---|
[528] | 442 | ; DL: Drive Number |
---|
| 443 | ; Returns: |
---|
| 444 | ; Nothing |
---|
| 445 | ; Corrupts registers: |
---|
| 446 | ; AX, CX, DL, DI |
---|
| 447 | ;-------------------------------------------------------------------- |
---|
| 448 | HotkeyBar_StoreHotkeyToBootvarsForDriveNumberInDL: |
---|
| 449 | call DriveXlate_ConvertDriveNumberFromDLtoDriveLetter |
---|
| 450 | ; Fall to StoreHotkeyToBootvarsForDriveLetterInDL |
---|
| 451 | |
---|
| 452 | |
---|
| 453 | ;-------------------------------------------------------------------- |
---|
| 454 | ; StoreHotkeyToBootvarsForDriveLetterInDL |
---|
| 455 | ; Parameters: |
---|
| 456 | ; DS: RAMVARS segment |
---|
| 457 | ; ES: BDA segment (zero) |
---|
[395] | 458 | ; DL: Drive Letter ('A'...) |
---|
| 459 | ; Returns: |
---|
| 460 | ; Nothing |
---|
| 461 | ; Corrupts registers: |
---|
| 462 | ; AX, CX, DI |
---|
| 463 | ;-------------------------------------------------------------------- |
---|
[528] | 464 | StoreHotkeyToBootvarsForDriveLetterInDL: |
---|
[395] | 465 | eMOVZX ax, dl |
---|
[505] | 466 | or al, 32 ; Upper case drive letter to lower case keystroke |
---|
[395] | 467 | jmp SHORT HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX |
---|
| 468 | |
---|
| 469 | |
---|
| 470 | ;-------------------------------------------------------------------- |
---|
[528] | 471 | ; ScanHotkeysFromKeyBufferAndStoreToBootvars |
---|
[392] | 472 | ; Parameters: |
---|
| 473 | ; DS: RAMVARS segment |
---|
| 474 | ; ES: BDA segment (zero) |
---|
| 475 | ; Returns: |
---|
[492] | 476 | ; AL: Last scancode value |
---|
[392] | 477 | ; Corrupts registers: |
---|
[492] | 478 | ; AH, CX |
---|
[392] | 479 | ;-------------------------------------------------------------------- |
---|
[528] | 480 | ScanHotkeysFromKeyBufferAndStoreToBootvars: |
---|
[392] | 481 | call Keyboard_GetKeystrokeToAX |
---|
| 482 | jz SHORT NoHotkeyToProcess |
---|
| 483 | |
---|
[528] | 484 | ; Prepare to read another key from buffer |
---|
| 485 | ePUSH_T cx, ScanHotkeysFromKeyBufferAndStoreToBootvars |
---|
[392] | 486 | ; Fall to HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX |
---|
| 487 | |
---|
| 488 | |
---|
| 489 | ;-------------------------------------------------------------------- |
---|
| 490 | ; HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX |
---|
| 491 | ; Parameters: |
---|
| 492 | ; AL: Hotkey ASCII code |
---|
| 493 | ; AH: Hotkey Scancode |
---|
| 494 | ; DS: RAMVARS segment |
---|
| 495 | ; ES: BDA segment (zero) |
---|
| 496 | ; Returns: |
---|
[567] | 497 | ; AL: Last scancode seen |
---|
[528] | 498 | ; CF: Set if valid hotkey in AL |
---|
| 499 | ; Clear if scancode in AL is not for any hotkey |
---|
[392] | 500 | ; Corrupts registers: |
---|
[492] | 501 | ; AH, CX, DI |
---|
[392] | 502 | ;-------------------------------------------------------------------- |
---|
| 503 | HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX: |
---|
[492] | 504 | mov di, BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode |
---|
[392] | 505 | |
---|
[492] | 506 | ; All scancodes are saved, even if it wasn't a drive letter, |
---|
| 507 | ; which also covers our function key case. Invalid function keys |
---|
[505] | 508 | ; will not do anything (won't be printed, won't be accepted as input) |
---|
[492] | 509 | mov [es:di], ah |
---|
[505] | 510 | |
---|
[392] | 511 | ; Drive letter hotkeys remaining, allow 'a' to 'z' |
---|
| 512 | call Char_IsLowerCaseLetterInAL |
---|
[492] | 513 | jnc SHORT .KeystrokeIsNotValidDriveLetter |
---|
[505] | 514 | and al, ~32 ; We want to print upper case letters |
---|
[392] | 515 | |
---|
| 516 | ; Clear HD First flag to assume Floppy Drive hotkey |
---|
[492] | 517 | dec di |
---|
[392] | 518 | and BYTE [es:di], ~FLG_HOTKEY_HD_FIRST |
---|
| 519 | |
---|
| 520 | ; Determine if Floppy or Hard Drive hotkey |
---|
[505] | 521 | xchg cx, ax |
---|
[547] | 522 | call BootVars_GetLetterForFirstHardDriveToAX |
---|
[392] | 523 | cmp cl, al |
---|
| 524 | jb SHORT .StoreDriveLetter ; Store Floppy Drive letter |
---|
| 525 | |
---|
| 526 | ; Store Hard Drive letter |
---|
| 527 | or BYTE [es:di], FLG_HOTKEY_HD_FIRST |
---|
| 528 | |
---|
| 529 | .StoreDriveLetter: |
---|
[505] | 530 | sbb di, BYTE 1 ; Sub CF if Floppy Drive |
---|
[392] | 531 | xchg ax, cx |
---|
[592] | 532 | stosb |
---|
[528] | 533 | stc ; Valid hotkey scancode returned in AL |
---|
[392] | 534 | |
---|
[505] | 535 | .KeystrokeIsNotValidDriveLetter: |
---|
[392] | 536 | NoHotkeyToProcess: |
---|
[492] | 537 | mov al, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode] |
---|
[392] | 538 | ret |
---|
| 539 | |
---|
[528] | 540 | |
---|
[392] | 541 | ;-------------------------------------------------------------------- |
---|
[492] | 542 | ; HotkeyBar_GetBootDriveNumbersToDX |
---|
[392] | 543 | ; Parameters: |
---|
| 544 | ; DS: RAMVARS segment |
---|
| 545 | ; ES: BDA segment (zero) |
---|
| 546 | ; Returns: |
---|
[492] | 547 | ; DX: Drives selected as boot device, DL is primary |
---|
[392] | 548 | ; Corrupts registers: |
---|
[492] | 549 | ; AX |
---|
[392] | 550 | ;-------------------------------------------------------------------- |
---|
[492] | 551 | HotkeyBar_GetBootDriveNumbersToDX: |
---|
[500] | 552 | mov dx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wFddAndHddLetters] |
---|
[600] | 553 | |
---|
| 554 | ; HotkeyBar_GetBootDriveNumbersToDX is called when all drives are detected and |
---|
| 555 | ; drive letters are known. |
---|
| 556 | ; Replace unavailable hard drive letter with first hard drive. |
---|
| 557 | ; If we have boot menu, it will be displayed instead. |
---|
| 558 | %ifndef MODULE_BOOT_MENU |
---|
| 559 | call BootVars_GetLetterForFirstHardDriveToAX |
---|
| 560 | mov ah, al |
---|
| 561 | add al, [es:BDA.bHDCount] ; AL now contains first unavailable HD letter |
---|
| 562 | cmp dh, al ; Unavailable drive? |
---|
| 563 | jb SHORT .ValidHardDriveLetterInDH |
---|
| 564 | mov dh, ah ; Replace unavailable drive with first drive |
---|
| 565 | .ValidHardDriveLetterInDH: |
---|
| 566 | %endif |
---|
| 567 | |
---|
[505] | 568 | test BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags], FLG_HOTKEY_HD_FIRST |
---|
[600] | 569 | jnz SHORT .noflip |
---|
[392] | 570 | xchg dl, dh |
---|
[505] | 571 | .noflip: |
---|
[492] | 572 | call DriveXlate_ConvertDriveLetterInDLtoDriveNumber |
---|
| 573 | xchg dl, dh |
---|
[505] | 574 | ; Fall to HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber |
---|
[392] | 575 | |
---|
[505] | 576 | HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber: |
---|
| 577 | |
---|