[395] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
| 2 | ; Description : Functions for swapping drive letters.
|
---|
| 3 |
|
---|
| 4 | ;
|
---|
| 5 | ; XTIDE Universal BIOS and Associated Tools
|
---|
| 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
|
---|
| 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.
|
---|
| 12 | ;
|
---|
| 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.
|
---|
| 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
| 18 | ;
|
---|
| 19 |
|
---|
| 20 | ; Section containing code
|
---|
| 21 | SECTION .text
|
---|
| 22 |
|
---|
| 23 | ;--------------------------------------------------------------------
|
---|
[492] | 24 | ; DriveXlate_ConvertDriveLetterInDLtoDriveNumber
|
---|
| 25 | ; Parameters:
|
---|
| 26 | ; DS: RAMVARS segment
|
---|
| 27 | ; DL: Drive letter ('A'...)
|
---|
| 28 | ; Returns:
|
---|
| 29 | ; DL: Drive number (0xh for Floppy Drives, 8xh for Hard Drives)
|
---|
| 30 | ; Corrupts registers:
|
---|
| 31 | ; AX
|
---|
| 32 | ;--------------------------------------------------------------------
|
---|
| 33 | DriveXlate_ConvertDriveLetterInDLtoDriveNumber:
|
---|
| 34 | call DriveXlate_GetLetterForFirstHardDriveToAX
|
---|
| 35 | cmp dl, al
|
---|
| 36 | jb SHORT .ConvertLetterInDLtoFloppyDriveNumber
|
---|
| 37 |
|
---|
| 38 | ; Convert letter in DL to Hard Drive number
|
---|
| 39 | sub dl, al
|
---|
| 40 | or dl, 80h
|
---|
| 41 | ret
|
---|
| 42 |
|
---|
| 43 | .ConvertLetterInDLtoFloppyDriveNumber:
|
---|
| 44 | sub dl, DEFAULT_FLOPPY_DRIVE_LETTER
|
---|
| 45 | ret
|
---|
| 46 |
|
---|
| 47 | %ifdef MODULE_HOTKEY
|
---|
| 48 | %if HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber <> DriveXlate_ConvertDriveLetterInDLtoDriveNumber
|
---|
| 49 | %error "DriveXlate_ConvertDriveLetterInDLtoDriveNumber must be at the top of DriveXlate.asm, and that file must immediately follow HotKeys.asm"
|
---|
| 50 | %endif
|
---|
| 51 | %endif
|
---|
| 52 |
|
---|
| 53 | ;--------------------------------------------------------------------
|
---|
| 54 | ; DriveXlate_ConvertDriveNumberFromDLtoDriveLetter
|
---|
| 55 | ; Parameters:
|
---|
| 56 | ; DL: Drive number (0xh for Floppy Drives, 8xh for Hard Drives)
|
---|
| 57 | ; DS: RAMVARS Segment
|
---|
| 58 | ; Returns:
|
---|
| 59 | ; DL: Drive letter ('A'...)
|
---|
| 60 | ; CF: Set if Hard Drive
|
---|
| 61 | ; Clear if Floppy Drive
|
---|
| 62 | ; Corrupts registers:
|
---|
| 63 | ; AX
|
---|
| 64 | ;--------------------------------------------------------------------
|
---|
| 65 | DriveXlate_ConvertDriveNumberFromDLtoDriveLetter:
|
---|
| 66 | test dl, dl
|
---|
| 67 | jns SHORT .GetDefaultFloppyDrive
|
---|
| 68 |
|
---|
| 69 | ; Store default hard drive to boot from
|
---|
| 70 | call DriveXlate_GetLetterForFirstHardDriveToAX
|
---|
| 71 | sub dl, 80h
|
---|
| 72 | add dl, al
|
---|
| 73 | stc
|
---|
| 74 | ret
|
---|
| 75 |
|
---|
| 76 | .GetDefaultFloppyDrive:
|
---|
| 77 | add dl, DEFAULT_FLOPPY_DRIVE_LETTER ; Clears CF
|
---|
| 78 | ret
|
---|
| 79 |
|
---|
| 80 |
|
---|
| 81 | ;--------------------------------------------------------------------
|
---|
| 82 | ; Returns letter for first hard disk. Usually it will be 'C' but it
|
---|
| 83 | ; can be higher if more than two floppy drives are found.
|
---|
| 84 | ;
|
---|
| 85 | ; DriveXlate_GetLetterForFirstHardDriveToAX
|
---|
| 86 | ; Parameters:
|
---|
| 87 | ; DS: RAMVARS segment
|
---|
| 88 | ; Returns:
|
---|
| 89 | ; AX: Upper case letter for first hard disk
|
---|
| 90 | ; Corrupts registers:
|
---|
| 91 | ; Nothing
|
---|
| 92 | ;--------------------------------------------------------------------
|
---|
| 93 | DriveXlate_GetLetterForFirstHardDriveToAX:
|
---|
| 94 | call FloppyDrive_GetCountToAX
|
---|
| 95 | add al, DEFAULT_FLOPPY_DRIVE_LETTER
|
---|
| 96 | MAX_U al, DEFAULT_HARD_DRIVE_LETTER
|
---|
| 97 | ret
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 | ;--------------------------------------------------------------------
|
---|
[395] | 101 | ; DriveXlate_ToOrBack
|
---|
| 102 | ; Parameters:
|
---|
| 103 | ; DL: Drive number to be possibly translated
|
---|
| 104 | ; DS: RAMVARS segment
|
---|
| 105 | ; Returns:
|
---|
| 106 | ; DL: Translated drive number
|
---|
| 107 | ; Corrupts registers:
|
---|
| 108 | ; DI
|
---|
| 109 | ;--------------------------------------------------------------------
|
---|
| 110 | ALIGN JUMP_ALIGN
|
---|
| 111 | DriveXlate_ToOrBack:
|
---|
| 112 | xchg di, ax ; Backup AX
|
---|
| 113 |
|
---|
| 114 | mov ah, 80h ; Assume hard disk
|
---|
| 115 | mov al, [RAMVARS.xlateVars+XLATEVARS.bHDSwap]
|
---|
| 116 | test dl, ah ; Hard disk?
|
---|
| 117 | jnz SHORT .SwapDrive ; If so, jump to swap
|
---|
| 118 | mov al, [RAMVARS.xlateVars+XLATEVARS.bFDSwap]
|
---|
| 119 | cbw
|
---|
| 120 |
|
---|
| 121 | ALIGN JUMP_ALIGN
|
---|
| 122 | .SwapDrive:
|
---|
| 123 | cmp ah, dl ; Swap DL from 00h/80h to xxh?
|
---|
| 124 | je SHORT .SwapToXXhInAL
|
---|
| 125 | cmp al, dl ; Swap DL from xxh to 00h/80h?
|
---|
| 126 | jne SHORT .RestoreAXandReturn
|
---|
| 127 | mov al, ah
|
---|
| 128 | ALIGN JUMP_ALIGN
|
---|
| 129 | .SwapToXXhInAL:
|
---|
| 130 | mov dl, al
|
---|
| 131 | ALIGN JUMP_ALIGN
|
---|
| 132 | .RestoreAXandReturn:
|
---|
| 133 | xchg ax, di ; Restore AX
|
---|
| 134 | ret
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 | ;--------------------------------------------------------------------
|
---|
| 138 | ; Resets drive swapping variables to defaults (no swapping).
|
---|
| 139 | ;
|
---|
| 140 | ; DriveXlate_Reset
|
---|
| 141 | ; Parameters:
|
---|
| 142 | ; DS: RAMVARS segment
|
---|
| 143 | ; Returns:
|
---|
| 144 | ; Nothing
|
---|
| 145 | ; Corrupts registers:
|
---|
[493] | 146 | ; AX, DI, DL
|
---|
[395] | 147 | ;--------------------------------------------------------------------
|
---|
| 148 | DriveXlate_Reset:
|
---|
[493] | 149 | xor dl, dl ; no translation for a floppy
|
---|
| 150 | ;; fall through to DriveXlate_SetDriveToSwap
|
---|
[395] | 151 |
|
---|
| 152 | ;--------------------------------------------------------------------
|
---|
| 153 | ; Stores drive to be swapped.
|
---|
| 154 | ;
|
---|
| 155 | ; DriveXlate_SetDriveToSwap
|
---|
| 156 | ; Parameters:
|
---|
| 157 | ; DL: Drive to swap to 00h or 80h
|
---|
| 158 | ; DS: RAMVARS segment
|
---|
| 159 | ; Returns:
|
---|
| 160 | ; Nothing
|
---|
| 161 | ; Corrupts registers:
|
---|
[493] | 162 | ; AX, DI
|
---|
[395] | 163 | ;--------------------------------------------------------------------
|
---|
| 164 | DriveXlate_SetDriveToSwap:
|
---|
[493] | 165 | mov ax, 8000h ; Default mapping (no translation)
|
---|
[395] | 166 | test dl, dl ; Floppy drive?
|
---|
[397] | 167 | js SHORT .SetHardDriveToSwap
|
---|
[493] | 168 | mov al, dl ; Store floppy translation
|
---|
| 169 | SKIP2B di
|
---|
| 170 | .SetHardDriveToSwap:
|
---|
| 171 | mov ah, dl ; Store HD translation
|
---|
| 172 | mov WORD [RAMVARS.xlateVars+XLATEVARS.wFDandHDswap], ax
|
---|
[395] | 173 | ret
|
---|