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
104
105
106
107
108
109
110
111
112
|
#ifndef UNSUPPORTED
static INLINE int
look1(uih_context * context, int x, int y, int range, int max)
{
register cpixel_t *vbuff;
register int i, j, c = 0;
if (range < context->zengine->image->width / 2)
if (x < 0 || x > context->zengine->image->width ||
y < 0 || y > context->zengine->image->height)
return 0;
do {
max--;
c = 0;
if (range > context->zengine->image->width / 2)
context->x1 =
rand() % (context->zengine->image->width - 2 * LOOKSIZE -
1) + LOOKSIZE, context->y1 =
rand() % (context->zengine->image->height - 2 * LOOKSIZE -
1) + LOOKSIZE;
else {
context->x1 = rand() % range - (range >> 1) + x;
context->y1 = rand() % range - (range >> 1) + y;
if (context->x1 < LOOKSIZE)
context->x1 = LOOKSIZE;
if (context->y1 < LOOKSIZE)
context->y1 = LOOKSIZE;
if (context->x1 >
context->zengine->image->width - 2 - LOOKSIZE)
context->x1 =
context->zengine->image->width - 2 - LOOKSIZE;
if (context->y1 >
context->zengine->image->height - 2 - LOOKSIZE)
context->y1 =
context->zengine->image->height - 2 - LOOKSIZE;
}
for (j = context->y1 - LOOKSIZE; j <= context->y1 + LOOKSIZE; j++) {
vbuff = (cpixel_t *) context->zengine->image->currlines[j];
for (i = context->x1 - LOOKSIZE; i <= context->x1 + LOOKSIZE;
i++)
if (InSet(p_getp(vbuff, i)))
c++;
}
}
while ((c == 0 || c > LOOKSIZE * LOOKSIZE) && max > 0);
if (max > 0) {
context->c1 = BUTTON1, context->interlevel = 1;
return 1;
}
return (0);
}
static INLINE int
look2(uih_context * context, int x, int y, int range, int max)
{
register cpixel_t *vbuff, *vbuff2;
register int i, j, i1, j1, c = 0;
if (range < context->zengine->image->width / 2)
if (x < 0 || x > context->zengine->image->width ||
y < 0 || y > context->zengine->image->height)
return 0;
do {
max--;
c = 0;
if (range > context->zengine->image->width / 2)
context->x1 =
rand() % (context->zengine->image->width - 2 * LOOKSIZE -
1) + LOOKSIZE, context->y1 =
rand() % (context->zengine->image->height - 2 * LOOKSIZE -
1) + LOOKSIZE;
else {
context->x1 = rand() % range - (range >> 1) + x;
context->y1 = rand() % range - (range >> 1) + y;
if (context->x1 < LOOKSIZE)
context->x1 = LOOKSIZE;
if (context->y1 < LOOKSIZE)
context->y1 = LOOKSIZE;
if (context->x1 >
context->zengine->image->width - 2 - LOOKSIZE)
context->x1 =
context->zengine->image->width - 2 - LOOKSIZE;
if (context->y1 >
context->zengine->image->height - 2 - LOOKSIZE)
context->y1 =
context->zengine->image->height - 2 - LOOKSIZE;
}
for (j = context->y1 - LOOKSIZE; j < context->y1 + LOOKSIZE; j++) {
vbuff = (cpixel_t *) context->zengine->image->currlines[j];
for (i = context->x1 - LOOKSIZE; i <= context->x1 + LOOKSIZE;
i++)
for (j1 = j + 1; j1 < context->y1 + LOOKSIZE; j1++) {
vbuff2 =
(cpixel_t *) context->zengine->image->
currlines[j1];
for (i1 = i + 1; i1 < context->x1 + LOOKSIZE; i1++)
if (p_getp(vbuff, i) == p_getp(vbuff2, i1))
c++;
}
}
}
while ((c > LOOKSIZE * LOOKSIZE / 2) && max > 0);
if (max > 0) {
context->c1 = BUTTON1, context->interlevel = 2;
return 1;
}
return 0;
}
#endif
#undef look1
#undef look2
|