line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
# Signal - define the signal names and constants |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Games::3D::Signal; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# (C) by Tels |
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
20606
|
use strict; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
191
|
|
9
|
|
|
|
|
|
|
|
10
|
6
|
|
|
6
|
|
35
|
use Exporter; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
255
|
|
11
|
6
|
|
|
6
|
|
29
|
use vars qw/@ISA @EXPORT_OK $VERSION/; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
7148
|
|
12
|
|
|
|
|
|
|
@ISA = qw/Exporter/; |
13
|
|
|
|
|
|
|
@EXPORT_OK = qw/ |
14
|
|
|
|
|
|
|
SIG_ON SIG_UP SIG_OPEN |
15
|
|
|
|
|
|
|
SIG_OFF SIG_CLOSE SIG_DOWN |
16
|
|
|
|
|
|
|
SIG_FLIP SIG_DIE |
17
|
|
|
|
|
|
|
SIG_ACTIVATE SIG_DEACTIVATE |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
SIG_KILLED SIG_UNKNOWN |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
SIG_LEFT SIG_RIGHT |
22
|
|
|
|
|
|
|
STATE_FLIP |
23
|
|
|
|
|
|
|
STATE_ON STATE_UP STATE_OPEN |
24
|
|
|
|
|
|
|
STATE_OFF STATE_CLOSED STATE_DOWN |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
SIG_LEVEL_WON |
27
|
|
|
|
|
|
|
SIG_LEVEL_LOST |
28
|
|
|
|
|
|
|
invert state_from_signal signal_from_state signal_name |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
STATE_0 STATE_1 STATE_2 STATE_3 STATE_4 STATE_5 STATE_6 STATE_7 STATE_8 |
31
|
|
|
|
|
|
|
STATE_9 STATE_10 STATE_11 STATE_12 STATE_13 STATE_14 STATE_15 |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
SIG_STATE_0 SIG_STATE_1 SIG_STATE_2 SIG_STATE_3 SIG_STATE_4 SIG_STATE_5 |
34
|
|
|
|
|
|
|
SIG_STATE_6 SIG_STATE_7 SIG_STATE_8 |
35
|
|
|
|
|
|
|
SIG_STATE_9 SIG_STATE_10 SIG_STATE_11 SIG_STATE_12 SIG_STATE_13 SIG_STATE_14 |
36
|
|
|
|
|
|
|
SIG_STATE_15 |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
SIG_NOW_0 SIG_NOW_1 SIG_NOW_2 SIG_NOW_3 SIG_NOW_4 SIG_NOW_5 |
39
|
|
|
|
|
|
|
SIG_NOW_6 SIG_NOW_7 SIG_NOW_8 |
40
|
|
|
|
|
|
|
SIG_NOW_9 SIG_NOW_10 SIG_NOW_11 SIG_NOW_12 SIG_NOW_13 SIG_NOW_14 |
41
|
|
|
|
|
|
|
SIG_NOW_15 |
42
|
|
|
|
|
|
|
/; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$VERSION = '0.02'; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
############################################################################## |
47
|
|
|
|
|
|
|
# constants |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# todo: make SIG_ON == SIG_STATE_0 and SIG_OFF == SIG_STATE_1 |
50
|
|
|
|
|
|
|
sub SIG_ON () { 1; } |
51
|
|
|
|
|
|
|
sub SIG_OPEN () { 1; } |
52
|
|
|
|
|
|
|
sub SIG_UP () { 1; } |
53
|
|
|
|
|
|
|
sub SIG_RIGHT () { 1; } |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub SIG_OFF () { -1; } |
56
|
|
|
|
|
|
|
sub SIG_CLOSE () { -1; } |
57
|
|
|
|
|
|
|
sub SIG_DOWN () { -1; } |
58
|
|
|
|
|
|
|
sub SIG_LEFT () { -1; } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub SIG_FLIP () { 0; } |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# these don't need a state since they are not passed along |
63
|
|
|
|
|
|
|
sub SIG_ACTIVATE () { 2; } |
64
|
|
|
|
|
|
|
sub SIG_DEACTIVATE () { -2; } |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub STATE_0 () { 0; } |
67
|
|
|
|
|
|
|
sub STATE_1 () { 1; } |
68
|
|
|
|
|
|
|
sub STATE_2 () { 2; } |
69
|
|
|
|
|
|
|
sub STATE_3 () { 3; } |
70
|
|
|
|
|
|
|
sub STATE_4 () { 4; } |
71
|
|
|
|
|
|
|
sub STATE_5 () { 5; } |
72
|
|
|
|
|
|
|
sub STATE_6 () { 6; } |
73
|
|
|
|
|
|
|
sub STATE_7 () { 7; } |
74
|
|
|
|
|
|
|
sub STATE_8 () { 8; } |
75
|
|
|
|
|
|
|
sub STATE_9 () { 9; } |
76
|
|
|
|
|
|
|
sub STATE_10 () { 10; } |
77
|
|
|
|
|
|
|
sub STATE_11 () { 11; } |
78
|
|
|
|
|
|
|
sub STATE_12 () { 12; } |
79
|
|
|
|
|
|
|
sub STATE_13 () { 13; } |
80
|
|
|
|
|
|
|
sub STATE_14 () { 14; } |
81
|
|
|
|
|
|
|
sub STATE_15 () { 15; } |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub SIG_STATE_0 () { 100; } |
84
|
|
|
|
|
|
|
sub SIG_STATE_1 () { 101; } |
85
|
|
|
|
|
|
|
sub SIG_STATE_2 () { 102; } |
86
|
|
|
|
|
|
|
sub SIG_STATE_3 () { 103; } |
87
|
|
|
|
|
|
|
sub SIG_STATE_4 () { 104; } |
88
|
|
|
|
|
|
|
sub SIG_STATE_5 () { 105; } |
89
|
|
|
|
|
|
|
sub SIG_STATE_6 () { 106; } |
90
|
|
|
|
|
|
|
sub SIG_STATE_7 () { 107; } |
91
|
|
|
|
|
|
|
sub SIG_STATE_8 () { 108; } |
92
|
|
|
|
|
|
|
sub SIG_STATE_9 () { 109; } |
93
|
|
|
|
|
|
|
sub SIG_STATE_10 () { 110; } |
94
|
|
|
|
|
|
|
sub SIG_STATE_11 () { 111; } |
95
|
|
|
|
|
|
|
sub SIG_STATE_12 () { 112; } |
96
|
|
|
|
|
|
|
sub SIG_STATE_13 () { 113; } |
97
|
|
|
|
|
|
|
sub SIG_STATE_14 () { 114; } |
98
|
|
|
|
|
|
|
sub SIG_STATE_15 () { 115; } |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub SIG_NOW_0 () { 200; } |
101
|
|
|
|
|
|
|
sub SIG_NOW_1 () { 201; } |
102
|
|
|
|
|
|
|
sub SIG_NOW_2 () { 202; } |
103
|
|
|
|
|
|
|
sub SIG_NOW_3 () { 203; } |
104
|
|
|
|
|
|
|
sub SIG_NOW_4 () { 204; } |
105
|
|
|
|
|
|
|
sub SIG_NOW_5 () { 205; } |
106
|
|
|
|
|
|
|
sub SIG_NOW_6 () { 206; } |
107
|
|
|
|
|
|
|
sub SIG_NOW_7 () { 207; } |
108
|
|
|
|
|
|
|
sub SIG_NOW_8 () { 208; } |
109
|
|
|
|
|
|
|
sub SIG_NOW_9 () { 209; } |
110
|
|
|
|
|
|
|
sub SIG_NOW_10 () { 210; } |
111
|
|
|
|
|
|
|
sub SIG_NOW_11 () { 211; } |
112
|
|
|
|
|
|
|
sub SIG_NOW_12 () { 212; } |
113
|
|
|
|
|
|
|
sub SIG_NOW_13 () { 213; } |
114
|
|
|
|
|
|
|
sub SIG_NOW_14 () { 214; } |
115
|
|
|
|
|
|
|
sub SIG_NOW_15 () { 215; } |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub SIG_DIE () { 1000; } |
118
|
|
|
|
|
|
|
sub SIG_KILLED () { 1001; } |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub STATE_ON () { 1; } |
121
|
|
|
|
|
|
|
sub STATE_OPEN () { 1; } |
122
|
|
|
|
|
|
|
sub STATE_UP () { 1; } |
123
|
|
|
|
|
|
|
sub STATE_RIGHT () { 1; } |
124
|
|
|
|
|
|
|
sub STATE_OFF () { 0; } |
125
|
|
|
|
|
|
|
sub STATE_CLOSED () { 0; } |
126
|
|
|
|
|
|
|
sub STATE_DOWN () { 0; } |
127
|
|
|
|
|
|
|
sub STATE_LEFT () { 0; } |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub SIG_UNKNOWN () { 99999; } |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub STATE_FLIP () { -1; } |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub SIG_LEVEL_WON () { 10; } |
134
|
|
|
|
|
|
|
sub SIG_LEVEL_LOST () { -10; } |
135
|
|
|
|
|
|
|
|
136
|
6
|
|
|
6
|
|
39
|
use vars qw/$sig_names $sig_codes/; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
1688
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
BEGIN |
139
|
|
|
|
|
|
|
{ |
140
|
6
|
|
|
6
|
|
289
|
$sig_names = |
141
|
|
|
|
|
|
|
{ |
142
|
|
|
|
|
|
|
SIG_LEVEL_WON() => 'SIG_LEVEL_WON', |
143
|
|
|
|
|
|
|
SIG_LEVEL_LOST() => 'SIG_LEVEL_LOST', |
144
|
|
|
|
|
|
|
SIG_FLIP() => 'SIG_FLIP', |
145
|
|
|
|
|
|
|
SIG_DIE() => 'SIG_DIE', |
146
|
|
|
|
|
|
|
SIG_KILLED() => 'SIG_KILLED', |
147
|
|
|
|
|
|
|
SIG_ACTIVATE() => 'SIG_ACTIVATE', |
148
|
|
|
|
|
|
|
SIG_DEACTIVATE() => 'SIG_DEACTIVATE', |
149
|
|
|
|
|
|
|
SIG_ON() => 'SIG_ON', |
150
|
|
|
|
|
|
|
SIG_OFF() => 'SIG_OFF', |
151
|
|
|
|
|
|
|
SIG_STATE_0() => 'SIG_STATE_0', |
152
|
|
|
|
|
|
|
SIG_STATE_1() => 'SIG_STATE_1', |
153
|
|
|
|
|
|
|
SIG_STATE_2() => 'SIG_STATE_2', |
154
|
|
|
|
|
|
|
SIG_STATE_3() => 'SIG_STATE_3', |
155
|
|
|
|
|
|
|
SIG_STATE_4() => 'SIG_STATE_4', |
156
|
|
|
|
|
|
|
SIG_STATE_5() => 'SIG_STATE_5', |
157
|
|
|
|
|
|
|
SIG_STATE_6() => 'SIG_STATE_6', |
158
|
|
|
|
|
|
|
SIG_STATE_7() => 'SIG_STATE_7', |
159
|
|
|
|
|
|
|
SIG_STATE_8() => 'SIG_STATE_8', |
160
|
|
|
|
|
|
|
SIG_STATE_9() => 'SIG_STATE_9', |
161
|
|
|
|
|
|
|
SIG_STATE_10() => 'SIG_STATE_10', |
162
|
|
|
|
|
|
|
SIG_STATE_11() => 'SIG_STATE_11', |
163
|
|
|
|
|
|
|
SIG_STATE_12() => 'SIG_STATE_12', |
164
|
|
|
|
|
|
|
SIG_STATE_13() => 'SIG_STATE_13', |
165
|
|
|
|
|
|
|
SIG_STATE_14() => 'SIG_STATE_14', |
166
|
|
|
|
|
|
|
SIG_STATE_15() => 'SIG_STATE_15', |
167
|
|
|
|
|
|
|
SIG_NOW_0() => 'SIG_NOW_0', |
168
|
|
|
|
|
|
|
SIG_NOW_1() => 'SIG_NOW_1', |
169
|
|
|
|
|
|
|
SIG_NOW_2() => 'SIG_NOW_2', |
170
|
|
|
|
|
|
|
SIG_NOW_3() => 'SIG_NOW_3', |
171
|
|
|
|
|
|
|
SIG_NOW_4() => 'SIG_NOW_4', |
172
|
|
|
|
|
|
|
SIG_NOW_5() => 'SIG_NOW_5', |
173
|
|
|
|
|
|
|
SIG_NOW_6() => 'SIG_NOW_6', |
174
|
|
|
|
|
|
|
SIG_NOW_7() => 'SIG_NOW_7', |
175
|
|
|
|
|
|
|
SIG_NOW_8() => 'SIG_NOW_8', |
176
|
|
|
|
|
|
|
SIG_NOW_9() => 'SIG_NOW_9', |
177
|
|
|
|
|
|
|
SIG_NOW_10() => 'SIG_NOW_10', |
178
|
|
|
|
|
|
|
SIG_NOW_11() => 'SIG_NOW_11', |
179
|
|
|
|
|
|
|
SIG_NOW_12() => 'SIG_NOW_12', |
180
|
|
|
|
|
|
|
SIG_NOW_13() => 'SIG_NOW_13', |
181
|
|
|
|
|
|
|
SIG_NOW_14() => 'SIG_NOW_14', |
182
|
|
|
|
|
|
|
SIG_NOW_15() => 'SIG_NOW_15', |
183
|
|
|
|
|
|
|
}; |
184
|
|
|
|
|
|
|
|
185
|
6
|
|
|
|
|
14
|
$sig_codes = {}; |
186
|
|
|
|
|
|
|
# reverse map |
187
|
6
|
|
|
|
|
83
|
foreach my $key (keys %$sig_names) |
188
|
|
|
|
|
|
|
{ |
189
|
246
|
|
|
|
|
2296
|
$sig_codes->{ $sig_names->{$key} } = $key; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
############################################################################## |
194
|
|
|
|
|
|
|
# methods |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub invert |
197
|
|
|
|
|
|
|
{ |
198
|
12
|
50
|
33
|
12
|
1
|
887
|
shift if ref($_[0]) || $_[0] eq 'Games::3D::Signal'; |
199
|
12
|
|
|
|
|
17
|
my $signal = shift; |
200
|
|
|
|
|
|
|
|
201
|
12
|
100
|
|
|
|
30
|
$signal = -$signal if abs($signal < SIG_STATE_0); |
202
|
12
|
|
|
|
|
49
|
$signal; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub signal_from_state |
206
|
|
|
|
|
|
|
{ |
207
|
10
|
|
|
10
|
1
|
13
|
my $state = shift; |
208
|
|
|
|
|
|
|
|
209
|
10
|
|
|
|
|
31
|
SIG_NOW_0 + $state; # 0 => 100, 1 => 101 etc |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub signal_name |
213
|
|
|
|
|
|
|
{ |
214
|
1
|
|
|
1
|
1
|
2
|
my $sig = shift; |
215
|
|
|
|
|
|
|
|
216
|
1
|
|
50
|
|
|
7
|
my $s = $sig_names->{$sig} || 'SIG_UNKNOWN'; |
217
|
|
|
|
|
|
|
|
218
|
1
|
|
|
|
|
6
|
$s ."($sig)"; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub signal_by_name |
222
|
|
|
|
|
|
|
{ |
223
|
2
|
|
|
2
|
1
|
5
|
my $sig = shift; |
224
|
|
|
|
|
|
|
|
225
|
2
|
50
|
|
|
|
16
|
$sig_codes->{$sig} || SIG_UNKNOWN; |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub state_from_signal |
229
|
|
|
|
|
|
|
{ |
230
|
9
|
|
|
9
|
1
|
13
|
my $sig = shift; |
231
|
|
|
|
|
|
|
|
232
|
9
|
100
|
|
|
|
32
|
if ($sig == SIG_ON) |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
233
|
|
|
|
|
|
|
{ |
234
|
5
|
|
|
|
|
8
|
$sig = STATE_ON; |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
elsif ($sig == SIG_OFF) |
237
|
|
|
|
|
|
|
{ |
238
|
2
|
|
|
|
|
4
|
$sig = STATE_OFF; |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
elsif ($sig == SIG_FLIP) |
241
|
|
|
|
|
|
|
{ |
242
|
1
|
|
|
|
|
2
|
$sig = STATE_FLIP; |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
else |
245
|
|
|
|
|
|
|
{ |
246
|
1
|
|
|
|
|
2
|
$sig -= SIG_STATE_0; |
247
|
|
|
|
|
|
|
} |
248
|
9
|
|
|
|
|
30
|
$sig; |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
1; |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
__END__ |