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