[99] | 1 | ; Project name : XTIDE Universal BIOS |
---|
[3] | 2 | ; Description : Functions for swapping drive letters. |
---|
| 3 | |
---|
| 4 | ; Section containing code |
---|
| 5 | SECTION .text |
---|
| 6 | |
---|
| 7 | ;-------------------------------------------------------------------- |
---|
| 8 | ; DriveXlate_ToOrBack |
---|
| 9 | ; Parameters: |
---|
| 10 | ; DL: Drive number to be possibly translated |
---|
| 11 | ; DS: RAMVARS segment |
---|
| 12 | ; Returns: |
---|
| 13 | ; DL: Translated drive number |
---|
| 14 | ; Corrupts registers: |
---|
| 15 | ; DI |
---|
| 16 | ;-------------------------------------------------------------------- |
---|
| 17 | ALIGN JUMP_ALIGN |
---|
| 18 | DriveXlate_ToOrBack: |
---|
| 19 | test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_DRVXLAT |
---|
| 20 | jz SHORT .Return ; Return if translation disabled |
---|
| 21 | xchg di, ax ; Backup AX |
---|
| 22 | |
---|
[126] | 23 | mov ah, 80h ; Assume hard disk |
---|
[294] | 24 | mov al, [RAMVARS.xlateVars+XLATEVARS.bHDSwap] |
---|
[126] | 25 | test dl, ah ; Hard disk? |
---|
[322] | 26 | jnz SHORT .SwapDrive ; If so, jump to swap |
---|
[294] | 27 | mov al, [RAMVARS.xlateVars+XLATEVARS.bFDSwap] |
---|
[126] | 28 | cbw |
---|
[3] | 29 | |
---|
[126] | 30 | ALIGN JUMP_ALIGN |
---|
[322] | 31 | .SwapDrive: |
---|
| 32 | cmp ah, dl ; Swap DL from 00h/80h to xxh? |
---|
[3] | 33 | je SHORT .SwapToXXhInAL |
---|
[322] | 34 | cmp al, dl ; Swap DL from xxh to 00h/80h? |
---|
| 35 | jne SHORT .RestoreAXandReturn |
---|
[181] | 36 | mov al, ah |
---|
[3] | 37 | ALIGN JUMP_ALIGN |
---|
| 38 | .SwapToXXhInAL: |
---|
| 39 | mov dl, al |
---|
[322] | 40 | ALIGN JUMP_ALIGN |
---|
| 41 | .RestoreAXandReturn: |
---|
| 42 | xchg ax, di ; Restore AX |
---|
[181] | 43 | ALIGN JUMP_ALIGN, ret |
---|
| 44 | .Return: |
---|
[3] | 45 | ret |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | ;-------------------------------------------------------------------- |
---|
| 49 | ; Resets drive swapping variables to defaults (no swapping). |
---|
| 50 | ; |
---|
| 51 | ; DriveXlate_Reset |
---|
| 52 | ; Parameters: |
---|
| 53 | ; DS: RAMVARS segment |
---|
| 54 | ; Returns: |
---|
| 55 | ; Nothing |
---|
| 56 | ; Corrupts registers: |
---|
[181] | 57 | ; Nothing |
---|
[128] | 58 | ;-------------------------------------------------------------------- |
---|
[3] | 59 | ALIGN JUMP_ALIGN |
---|
| 60 | DriveXlate_Reset: |
---|
[248] | 61 | mov WORD [RAMVARS.xlateVars+XLATEVARS.wFDandHDswap], 8000h |
---|
[3] | 62 | ret |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | ;-------------------------------------------------------------------- |
---|
| 66 | ; Stores drive to be swapped. |
---|
| 67 | ; |
---|
| 68 | ; DriveXlate_SetDriveToSwap |
---|
| 69 | ; Parameters: |
---|
| 70 | ; DL: Drive to swap to 00h or 80h |
---|
| 71 | ; DS: RAMVARS segment |
---|
| 72 | ; Returns: |
---|
| 73 | ; Nothing |
---|
| 74 | ; Corrupts registers: |
---|
| 75 | ; Nothing |
---|
[128] | 76 | ;-------------------------------------------------------------------- |
---|
[3] | 77 | ALIGN JUMP_ALIGN |
---|
| 78 | DriveXlate_SetDriveToSwap: |
---|
[128] | 79 | test dl, dl ; Floppy drive? |
---|
| 80 | js SHORT .SetHardDiskToSwap |
---|
[99] | 81 | .SetFloppyDriveToSwap: |
---|
[3] | 82 | mov [RAMVARS.xlateVars+XLATEVARS.bFDSwap], dl |
---|
| 83 | ret |
---|
| 84 | ALIGN JUMP_ALIGN |
---|
[99] | 85 | .SetHardDiskToSwap: |
---|
[3] | 86 | mov [RAMVARS.xlateVars+XLATEVARS.bHDSwap], dl |
---|
| 87 | ret |
---|