-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdblspace.c
executable file
·102 lines (90 loc) · 1.98 KB
/
dblspace.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* Microsoft DoubleSpace disk compression software support
* Copyright (C) 1994-1996, 2005 Marko Kohtala
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "srdisk.h"
#include <dos.h>
typedef struct
{
char firstUsedDrive;
unsigned char drivesUsed;
word version;
} DblSpaceVersion;
typedef struct
{
char hostDrive;
unsigned char sequence;
} DblSpaceHost;
DblSpaceVersion DblSpace_getVersion(void)
{
union REGS inregs, outregs;
static const DblSpaceVersion retDefault = { 0, 0, 0 };
DblSpaceVersion ret = retDefault;
inregs.x.ax = 0x4A11;
inregs.x.bx = inregs.x.cx = inregs.x.dx = 0;
int86(0x2F, &inregs, &outregs);
if (outregs.x.ax == 0 && outregs.x.bx == 0x444D)
{
ret.firstUsedDrive = outregs.h.cl;
ret.drivesUsed = outregs.h.ch;
ret.version = outregs.x.dx;
}
return ret;
}
DblSpaceHost DblSpace_getDriveMapping(char drive)
{
union REGS inregs, outregs;
static const DblSpace retDefault = { 0, 0 };
DblSpaceHost ret = retDefault;
inregs.x.ax = 0x4A11;
inregs.x.bx = 1;
inregs.h.dl = drive;
int86(0x2F, &inregs, &outregs);
if (outregs.x.ax == 0)
{
ret.hostDrive = outregs.h.bl;
ret.sequence = outregs.h.bh;
}
return ret;
}
bool
DblSpace_activateDrive(char drive, char host, unsigned sequence)
{
union REGS inregs, outregs;
struct SREGS sregs;
typedef struct
{
word signature;
byte command;
byte status;
byte host;
????
} ActivationRecord;
static const ActivationRecord arInit = { 0x444D, 'M', 0xFF };
ActivationRecord ar = arInit;
inregs.x.ax = 0x4A11;
inregs.x.bx = 5;
inregs.h.dl = drive;
inregs.x.si = &ar;
sregs.es = sregs.ds = _DS;
int86x(0x2F, &inregs, &outregs, &sregs);
if (ar.status != 0)
{
return false;
}
return true;
}
bool
DblSpace_deactivateDrive(char drive)
{
union REGS regs;
inregs.x.ax = 0x4A11;
inregs.x.bx = 6;
inregs.h.dl = drive;
int86(0x2F, ®s, ®s);
if (regs.x.ax != 0)
{
return false
}
return true;
}