aboutsummaryrefslogtreecommitdiff
path: root/engines/avalanche/helpbak.cpp
blob: 3e60289a3308be1be11062ab3eb15300761c22a5 (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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/* 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.
 */

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

                 HELPER           The help system unit. */

#define __helper_implementation__


#include "helpbak.h"


/*#include "Crt.h"*/
/*#include "Lucerna.h"*/

namespace Avalanche {

struct buttontype {
	char trigger;
	byte whither;
};

const integer buttonsize = 930;

const integer toolbar = 0;
const integer nim = 1;
const integer kbd = 2;
const integer credits = 3;
const integer joystick = 4;
const integer troubleshooting = 5;
const integer story = 6;
const integer mainscreen = 7;
const integer registering = 8;
const integer sound = 9;
const integer mouse = 10;
const integer filer = 11;
const integer back2game = 12;
const integer helponhelp = 13;
const integer pgdn = 14;
const integer pgup = 15;

array<1, 10, buttontype> buttons;

void plot_button(integer y, byte which) {
	untyped_file f;
	pointer p;

	getmem(p, buttonsize);
	assign(f, "buttons.avd");
	reset(f, 1);
	seek(f, which * buttonsize);
	blockread(f, p, buttonsize);
	putimage(470, y, p, 0);
	close(f);
	freemem(p, buttonsize);
}

void getme(byte which);


static void chalk(byte y, string z) {
	outtextxy(16, 41 + y * 10, z);
}

void getme(byte which) {     /* Help icons are 80x20 */
	string x;
	text t;
	byte y, fv;


	str(which, x);
	assign(t, string('h') + x + ".raw");
	y = 0;
	reset(t);

	t >> x >> NL;
	setfillstyle(1, 1);
	bar(0, 0, 640, 200);
	setfillstyle(1, 15);
	bar(8, 40, 450, 200);
	settextjustify(1, 1);
	setcolor(14);
	outtextxy(320, 15, x);
	settextjustify(0, 2);
	setcolor(3);
	settextstyle(0, 0, 2);
	outtextxy(550, 0, "help!");
	/***/ setcolor(0);
	settextstyle(0, 0, 1);

	do {
		t >> x >> NL;
		if (x == '!')  flush(); /* End of the help text is signalled with a !. */
		chalk(y, x);
		y += 1;
	} while (!false);

	/* We are now at the end of the text. Next we must read the icons. */

	y = 0;
	settextjustify(1, 1);
	setcolor(3);
	while (! eof(t)) {
		y += 1;
		t >> x >> NL; /* Get the name of this button, and... */
		if (x != '-') { /* (hyphen signals an empty button.) */
			t >> buttons[y].trigger >> NL;
			t >> fv >> NL;
			plot_button(13 + y * 27, fv);
			t >> buttons[y].whither >> NL; /* this is the position to jump to */

			switch (buttons[y].trigger) {
			case '�' :
				outtextxy(580, 25 + y * 27, "Esc");
				break;
			case '�' :
				outtextxy(580, 25 + y * 27, "\30");
				break;
			case '�' :
				outtextxy(580, 25 + y * 27, "\31");
				break;
			default:
				outtextxy(580, 25 + y * 27, buttons[y].trigger);
			}

		} else buttons[y].trigger = '\0';
	}

	settextjustify(0, 2);
	close(t);
}

void continue_help() {
	char r;
	byte fv;

	do {
		r = upcase(readkey());
		switch (r) {
		case '\33' :
			return;
			break;
		case '\0'  :
			switch (readkey()) {
			case '\110':
			case '\111':
				r = '�';
				break;
			case '\120':
			case '\121':
				r = '�';
				break;
			case '\73':
				r = 'H';
				break; /* Help on help */
			}
			break;
		}

		for (fv = 1; fv <= 10; fv ++) {
			buttontype &with = buttons[fv];
			if (with.trigger == r) {
				dusk;
				getme(with.whither);
				dawn;
				flush();
			}
		}

	} while (!false);
}

void boot_help() {
	setactivepage(2);

	getme(0);

	dusk;
	setvisualpage(2);
	dawn;

	continue_help();

	dusk;
	setvisualpage(cp);
	draw_also_lines;
	setactivepage(1 - cp);
	dawn;
}

} // End of namespace Avalanche.