-
Notifications
You must be signed in to change notification settings - Fork 0
/
PROTECT.C
101 lines (91 loc) · 1.36 KB
/
PROTECT.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
/*
* C copy protection routines
*/
#include "swint.h"
extern int goodchk;
int no_step;
#define UNDEFINED 0
#define DONTCARE 0
#define CRC 0x10
static struct sw_regs rom_read = {
0x206,
0,
0x2701,
UNDEFINED,
DONTCARE,
DONTCARE,
DONTCARE,
0xF800
} ;
static struct sw_regs sig1_read = {
0x201,
UNDEFINED,
0x2707,
UNDEFINED,
DONTCARE,
DONTCARE,
DONTCARE,
UNDEFINED
} ;
static struct sw_regs sig2_read = {
0x201,
UNDEFINED,
0x27F1,
UNDEFINED,
DONTCARE,
DONTCARE,
DONTCARE,
UNDEFINED
} ;
protect(drive)
{
int i, flags;
struct sw_regs rgs;
char buf2[512];
char buf1[32];
no_step++;
rom_read.dx = sig1_read.dx = sig2_read.dx = drive;
sig1_read.es = sig2_read.es = getds();
sig1_read.bx = (int)(&buf1[0]);
sig2_read.bx = (int)(&buf2[0]);
for (i=0,flags=CF;i<7 && (flags&CF);i++)
{
rgs = rom_read;
no_step = 0;
flags = sysint(SW_DSK,&rgs,&rgs);
no_step++;
}
if (CF&flags)
{
no_step = 0;
return;
}
for (i=0,flags=CF;i<3 && (flags&CF);i++)
{
rgs = sig1_read;
no_step = 0;
flags = sysint(SW_DSK,&rgs,&rgs);
no_step++;
}
if (CF&flags)
{
no_step = 0;
return;
}
for (i=0;i<4;i++)
{
rgs = sig2_read;
no_step = 0;
flags = sysint(SW_DSK,&rgs,&rgs);
no_step++;
if ((flags&CF) && HI(rgs.ax) == CRC)
{
if (memcmp(&buf1[0],&buf2[0x8c],32) == 0)
goodchk = 0xD0D;
no_step = 0;
return ;
}
}
no_step = 0;
}