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 | ;--------------------------------------------------------------------
|
---|
24 | ; DriveXlate_ToOrBack
|
---|
25 | ; Parameters:
|
---|
26 | ; DL: Drive number to be possibly translated
|
---|
27 | ; DS: RAMVARS segment
|
---|
28 | ; Returns:
|
---|
29 | ; DL: Translated drive number
|
---|
30 | ; Corrupts registers:
|
---|
31 | ; DI
|
---|
32 | ;--------------------------------------------------------------------
|
---|
33 | ALIGN JUMP_ALIGN
|
---|
34 | DriveXlate_ToOrBack:
|
---|
35 | test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_DRVXLAT
|
---|
36 | jz SHORT .Return ; Return if translation disabled
|
---|
37 | xchg di, ax ; Backup AX
|
---|
38 |
|
---|
39 | mov ah, 80h ; Assume hard disk
|
---|
40 | mov al, [RAMVARS.xlateVars+XLATEVARS.bHDSwap]
|
---|
41 | test dl, ah ; Hard disk?
|
---|
42 | jnz SHORT .SwapDrive ; If so, jump to swap
|
---|
43 | mov al, [RAMVARS.xlateVars+XLATEVARS.bFDSwap]
|
---|
44 | cbw
|
---|
45 |
|
---|
46 | ALIGN JUMP_ALIGN
|
---|
47 | .SwapDrive:
|
---|
48 | cmp ah, dl ; Swap DL from 00h/80h to xxh?
|
---|
49 | je SHORT .SwapToXXhInAL
|
---|
50 | cmp al, dl ; Swap DL from xxh to 00h/80h?
|
---|
51 | jne SHORT .RestoreAXandReturn
|
---|
52 | mov al, ah
|
---|
53 | ALIGN JUMP_ALIGN
|
---|
54 | .SwapToXXhInAL:
|
---|
55 | mov dl, al
|
---|
56 | ALIGN JUMP_ALIGN
|
---|
57 | .RestoreAXandReturn:
|
---|
58 | xchg ax, di ; Restore AX
|
---|
59 | ALIGN JUMP_ALIGN, ret
|
---|
60 | .Return:
|
---|
61 | ret
|
---|
62 |
|
---|
63 |
|
---|
64 | ;--------------------------------------------------------------------
|
---|
65 | ; Resets drive swapping variables to defaults (no swapping).
|
---|
66 | ;
|
---|
67 | ; DriveXlate_Reset
|
---|
68 | ; Parameters:
|
---|
69 | ; DS: RAMVARS segment
|
---|
70 | ; Returns:
|
---|
71 | ; Nothing
|
---|
72 | ; Corrupts registers:
|
---|
73 | ; Nothing
|
---|
74 | ;--------------------------------------------------------------------
|
---|
75 | ALIGN JUMP_ALIGN
|
---|
76 | DriveXlate_Reset:
|
---|
77 | mov WORD [RAMVARS.xlateVars+XLATEVARS.wFDandHDswap], 8000h
|
---|
78 | ret
|
---|
79 |
|
---|
80 |
|
---|
81 | ;--------------------------------------------------------------------
|
---|
82 | ; Stores drive to be swapped.
|
---|
83 | ;
|
---|
84 | ; DriveXlate_SetDriveToSwap
|
---|
85 | ; Parameters:
|
---|
86 | ; DL: Drive to swap to 00h or 80h
|
---|
87 | ; DS: RAMVARS segment
|
---|
88 | ; Returns:
|
---|
89 | ; Nothing
|
---|
90 | ; Corrupts registers:
|
---|
91 | ; Nothing
|
---|
92 | ;--------------------------------------------------------------------
|
---|
93 | ALIGN JUMP_ALIGN
|
---|
94 | DriveXlate_SetDriveToSwap:
|
---|
95 | test dl, dl ; Floppy drive?
|
---|
96 | js SHORT .SetHardDiskToSwap
|
---|
97 | .SetFloppyDriveToSwap:
|
---|
98 | mov [RAMVARS.xlateVars+XLATEVARS.bFDSwap], dl
|
---|
99 | ret
|
---|
100 | ALIGN JUMP_ALIGN
|
---|
101 | .SetHardDiskToSwap:
|
---|
102 | mov [RAMVARS.xlateVars+XLATEVARS.bHDSwap], dl
|
---|
103 | ret
|
---|