summaryrefslogtreecommitdiff
path: root/csrc/fcn_4021f8.c
blob: 3c0f8ddeb4e064d3e26e94dbfaaab12548036072 (plain)
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
102
103
void fcn_004021f8(int a1, int a2, int a3)
{
	dw_48a0f4 = dw_46cb10 + 12 + a1 * 12;
	w_48a170 = a2;
	w_48a174 = a3;
	w_48a172 = w_48a176 = 0;
	GetCursorPos_35d(NULL);
	GetCursorPos_250(0);
}

/* 0x0040235d */
void GetCursorPos_35d(int * a1)
{
	POINT p; /* @ esp */

	if (b_48a178 != 1)
		return;

	if (b_46caf9 != 0)
		return;

	if ((b_48a179 & 1) == 0)
		return;

	GetCursorPos(&p);
	if (a1 != 0) {
		eax = w_48a172 * 12 + dw_48a0f4;
		edx = *(int16_t*)(eax + 4); /* sign extend */
		edx = p.x - edx;
		eax = *(int16_t*)(eax + 6);
		eax = p.y - eax;
		ecx = edx + 0x20;
		esi = eax + 0x20;
		if (edx >= a1[2] || ecx <= a1[0] || eax >= a1[3] || esi <= a1[1]) {
			eax = dw_48a0ec;
			if (eax >= a1[2])
				return;
			eax += 0x20;
			if (eax <= a1[0])
				return;
			eax = dw_48a0f0;
			if (eax >= a1[3])
				return;
			eax += 0x20;
			if (eax <= a1[1])
				return;
		}
	}
	b_48a17a = 1;
	IDirectDrawSurface_Lock(pddrawsf1, NULL, &sfdesc2, 1, 0);
	dw_46cb1c = dw_48a11c;
	fcn_00401f5e();
	IDirectDrawSurface_Unlock(pddrawsf1, NULL);
	b_48a17a = 0;
	b_48a179 &= ~1;
}

/* 0x00402250 */
void GetCursorPos_250(int * a1)
{
	POINT p;

	if (b_48a178 != 1)
		return;

	if (b_46caf9 != 0)
		return;

	if ((b_48a179 & 1) == 0)
		return;

	GetCursorPos(&p);
	if (a1 != 0) {
		eax = w_48a172 * 12 + dw_48a0f4;
		edx = *(int16_t*)(eax + 4); /* sign extend */
		edx = p.x - edx;
		eax = *(int16_t*)(eax + 6);
		eax = p.y - eax;
		ecx = edx + 0x20;
		esi = eax + 0x20;
		if (edx >= a1[2] || ecx <= a1[0] || eax >= a1[3] || esi <= a1[1]) {
			eax = dw_48a0ec;
			if (eax >= a1[2])
				return;
			eax += 0x20;
			if (eax <= a1[0])
				return;
			eax = dw_48a0f0;
			if (eax >= a1[3])
				return;
			eax += 0x20;
			if (eax <= a1[1])
				return;
		}
	}
	b_48a17a = 1;
	IDirectDrawSurface_Lock(pddrawsf1, NULL, &sfdesc2, 1, 0);
	dw_46cb1c = dw_48a11c;
	fcn_00401e59(p.x, p.y);
	IDirectDrawSurface_Unlock(pddrawsf1, NULL);
	b_48a17a = 0;
	b_48a179 |= 1;
}