1 | ; Project name : XTIDE Universal BIOS
|
---|
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 |
|
---|
23 | mov ah, 80h ; Assume hard disk
|
---|
24 | mov al, [RAMVARS.xlateVars+XLATEVARS.bHDSwap]
|
---|
25 | test dl, ah ; Hard disk?
|
---|
26 | jnz SHORT .SwapDrive ; If so, jump to swap
|
---|
27 | mov al, [RAMVARS.xlateVars+XLATEVARS.bFDSwap]
|
---|
28 | cbw
|
---|
29 |
|
---|
30 | ALIGN JUMP_ALIGN
|
---|
31 | .SwapDrive:
|
---|
32 | cmp ah, dl ; Swap DL from 00h/80h to xxh?
|
---|
33 | je SHORT .SwapToXXhInAL
|
---|
34 | cmp al, dl ; Swap DL from xxh to 00h/80h?
|
---|
35 | jne SHORT .RestoreAXandReturn
|
---|
36 | mov al, ah
|
---|
37 | ALIGN JUMP_ALIGN
|
---|
38 | .SwapToXXhInAL:
|
---|
39 | mov dl, al
|
---|
40 | ALIGN JUMP_ALIGN
|
---|
41 | .RestoreAXandReturn:
|
---|
42 | xchg ax, di ; Restore AX
|
---|
43 | ALIGN JUMP_ALIGN, ret
|
---|
44 | .Return:
|
---|
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:
|
---|
57 | ; Nothing
|
---|
58 | ;--------------------------------------------------------------------
|
---|
59 | ALIGN JUMP_ALIGN
|
---|
60 | DriveXlate_Reset:
|
---|
61 | mov WORD [RAMVARS.xlateVars+XLATEVARS.wFDandHDswap], 8000h
|
---|
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
|
---|
76 | ;--------------------------------------------------------------------
|
---|
77 | ALIGN JUMP_ALIGN
|
---|
78 | DriveXlate_SetDriveToSwap:
|
---|
79 | test dl, dl ; Floppy drive?
|
---|
80 | js SHORT .SetHardDiskToSwap
|
---|
81 | .SetFloppyDriveToSwap:
|
---|
82 | mov [RAMVARS.xlateVars+XLATEVARS.bFDSwap], dl
|
---|
83 | ret
|
---|
84 | ALIGN JUMP_ALIGN
|
---|
85 | .SetHardDiskToSwap:
|
---|
86 | mov [RAMVARS.xlateVars+XLATEVARS.bHDSwap], dl
|
---|
87 | ret
|
---|