forked from devshane/zork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lightp.c
153 lines (137 loc) · 3.07 KB
/
lightp.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// Copyright (c) 1980, InfoCom Computers and Communications, Cambridge MA 02142
// All rights reserved, commercial usage strictly prohibited.
// Written by R. M. Supnik.
// Revisions Copyright (c) 2021, Darth Spectra (Lydia Marie Williamson).
#include "extern.h"
#include "common.h"
// Light processor
bool lightp(int obj) {
// System generated locals
bool ret_val;
// Local variables
int flobts;
int i;
// LIGHTP, PAGE 2
ret_val = true;
// !ASSUME WINS
flobts = FlamO + LiteO + OnO;
if (obj != CandlOX) {
goto L20000;
}
// !CANDLE?
if (findex_1.orcand != 0) {
goto L19100;
}
// !FIRST REF?
findex_1.orcand = 1;
// !YES, CANDLES ARE
cevent.ctick[CndCX - 1] = 50;
// !BURNING WHEN SEEN.
L19100:
if (prsvec.prsi == CandlOX) {
goto L10;
}
// !IGNORE IND REFS.
if (prsvec.prsa != TrnOfW) {
goto L19200;
}
// !TURN OFF?
i = 513;
// !ASSUME OFF.
if ((objcts.oflag1[CandlOX - 1] & OnO) != 0) {
i = 514;
}
// !IF ON, DIFFERENT.
cevent.cflag[CndCX - 1] = false;
// !DISABLE COUNTDOWN.
objcts.oflag1[CandlOX - 1] &= ~OnO;
rspeak(i);
return ret_val;
L19200:
if (prsvec.prsa != BurnW && prsvec.prsa != TrnOnW) {
goto L10;
}
if ((objcts.oflag1[CandlOX - 1] & LiteO) != 0) {
goto L19300;
}
rspeak(515);
// !CANDLES TOO SHORT.
return ret_val;
L19300:
if (prsvec.prsi != 0) {
goto L19400;
}
// !ANY FLAME?
rspeak(516);
// !NO, LOSE.
prsvec.prswon = false;
return ret_val;
L19400:
if (prsvec.prsi != MatchOX || !((objcts.oflag1[MatchOX - 1] & OnO) != 0)) {
goto L19500;
}
i = 517;
// !ASSUME OFF.
if ((objcts.oflag1[CandlOX - 1] & OnO) != 0) {
i = 518;
}
// !IF ON, JOKE.
objcts.oflag1[CandlOX - 1] |= OnO;
cevent.cflag[CndCX - 1] = true;
// !RESUME COUNTDOWN.
rspeak(i);
return ret_val;
L19500:
if (prsvec.prsi != TorchOX || !((objcts.oflag1[TorchOX - 1] & OnO) != 0)) {
goto L19600;
}
if ((objcts.oflag1[CandlOX - 1] & OnO) != 0) {
goto L19700;
}
// !ALREADY ON?
newsta(CandlOX, 521, 0, 0, 0);
// !NO, VAPORIZE.
return ret_val;
L19600:
rspeak(519);
// !CANT LIGHT WITH THAT.
return ret_val;
L19700:
rspeak(520);
// !ALREADY ON.
return ret_val;
L20000:
if (obj != MatchOX) {
bug(6, obj);
}
if (prsvec.prsa != TrnOnW || prsvec.prso != MatchOX) {
goto L20500;
}
if (findex_1.ormtch != 0) {
goto L20100;
}
// !ANY MATCHES LEFT?
rspeak(183);
// !NO, LOSE.
return ret_val;
L20100:
--findex_1.ormtch;
// !DECREMENT NO MATCHES.
objcts.oflag1[MatchOX - 1] |= flobts;
cevent.ctick[MatCX - 1] = 2;
// !COUNTDOWN.
rspeak(184);
return ret_val;
L20500:
if (prsvec.prsa != TrnOfW || (objcts.oflag1[MatchOX - 1] & OnO) == 0) {
goto L10;
}
objcts.oflag1[MatchOX - 1] &= ~flobts;
cevent.ctick[MatCX - 1] = 0;
rspeak(185);
return ret_val;
// HERE FOR FALSE RETURN
L10:
ret_val = false;
return ret_val;
}