aboutsummaryrefslogtreecommitdiff
path: root/engines/avalanche/access.cpp
blob: ba87cd64a4c43036788bd3f54c2ea8732d1dd91b (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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

/*
 * This code is based on the original source code of Lord Avalot d'Argent version 1.3.
 * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
 */

/*
  ��� ��� ����  ��� ���  �� ���      �����  ��� ��  � ����  ��� ��� ��� �
  ��  ��  �  � � �  ��� ��   �      �  �  �  �  � ���  ����  �  ��  ��� �
  �   � �  ��   ��  ���   �  �      �  �  � ��� �  ��  ���   �  � � ��� ���

                 ACCESS           The temporary Sez handler. */

#define __access_implementation__


#include "access.h"


/*#include "Gyro.h"*/
/*#include "Scrolls.h"*/
/*#include "Acci.h"*/
/*#include "Trip5.h"*/
/*#include "Lucerna.h"*/

namespace Avalanche {

boolean int_say_went_ok;

void int_say(string filename, boolean bubble)
/* Internal use ONLY! */
{
	untyped_file f;
	/*$I-*/
	assign(f, filename);
	reset(f, 1);
	if (ioresult != 0) {
		int_say_went_ok = false;
		return;
	}
	bufsize = filesize(f);
	blockread(f, buffer, bufsize);
	if (bubble) {
		bufsize += 1;
		buffer[bufsize] = '\2';
	}
	close(f);
	/*$I+*/

	calldrivers;

	int_say_went_ok = true;
}

void dixi(char p, byte n) {
	exit(153);
	int_say(string('s') + p + strf(n) + ".raw", false);
}

void talkto(byte whom) {
	byte fv;
	boolean no_matches;
	exit(153);
	if (person == pardon) {
		person = chr(subjnumber);
		subjnumber = 0;
	}

	switch (chr(whom)) {
	case pspludwick:

		if ((dna.lustie_is_asleep) & (~ dna.obj[potion])) {
			dixi('q', 68);
			dna.obj[potion] = true;
			objectlist;
			points(3);
			return;
		} else {
			if (dna.talked_to_crapulus)
				switch (dna.given2spludwick) { /* Spludwick - what does he need? */
					/* 0 - let it through to use normal routine. */
				case RANGE_2(1, 2): {
					display(string("Can you get me ") +
					        get_better(spludwick_order[dna.given2spludwick]) + ", please?" +
					        "\232\2");
					return;
				}
				break;
				case 3: {
					dixi('q', 30); /* need any help with the game? */
					return;
				}
				break;
				}
			else dixi('q', 42); /* Haven't talked to Crapulus. Go and talk to him. */
		}
		break;

	case pibythneth:
		if (dna.givenbadgetoiby) {
			dixi('q', 33); /* Thanks a lot! */
			return; /* And leave the proc. */
		}
		break; /* Or... just continue, 'cos he hasn't got it. */
	case pdogfood:
		if (dna.wonnim) {
			;     /* We've won the game. */
			dixi('q', 6); /* "I'm Not Playing!" */
			return; /* Zap back. */
		}
		break;
	case payles:
		if (~ dna.ayles_is_awake) {
			dixi('q', 43); /* He's fast asleep! */
			return;
		}
		break;
	case pgeida:
		if (dna.geida_given_potion)
			dna.geida_follows = true;
		else {
			dixi('u', 17);
			return;
		}
		break;
	}

	if (whom > 149)  whom -= 149;

	no_matches = true;
	for (fv = 1; fv <= numtr; fv ++)
		if (tr[fv].a.accinum == whom) {
			display(string('\23') + chr(fv + 48) + '\4');
			no_matches = false;
			flush();
		}

	if (no_matches)  display("\23\23\4");

	if (subjnumber == 0) /* For the moment... later we'll parse "say". */
		int_say(string("ss") + strf(whom) + ".raw", true);
	else {
		int_say(string("ss") + strf(whom) + '-' + strf(subjnumber) + ".raw", true);
		if (! int_say_went_ok)      /* File not found! */
			dixi('n', whom);
	}

	switch (chr(whom + 149)) {
	case pcrapulus: {
		;     /* Crapulus: get the badge - first time only */
		dna.obj[badge] = true;
		objectlist;
		dixi('q', 1); /* Circular from Cardiff. */
		dna.talked_to_crapulus = true;

		whereis[pcrapulus] = 177; /* Crapulus walks off. */

		tr[2].vanishifstill = true;
		tr[2].walkto(4); /* Walks away. */

		points(2);
	}
	break;

	case payles:
		dixi('q', 44);
		break; /* Can you get me a pen? */

	}
}

} // End of namespace Avalanche.