aboutsummaryrefslogtreecommitdiff
path: root/engines/avalanche/avalanche.cpp
blob: f66e293aed0d07c10a3f69393642e4188ac38aae (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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
/* 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.
 */

#include "common/system.h"
#include "common/random.h"
#include "common/error.h"
#include "common/events.h"
#include "common/debug-channels.h"
#include "common/config-manager.h"
#include "common/textconsole.h"

#include "avalanche/avalanche.h"

#include "engines/util.h"

namespace Avalanche {

	AvalancheEngine *AvalancheEngine::s_Engine = 0;

	AvalancheEngine::AvalancheEngine(OSystem *syst, const AvalancheGameDescription *gd) : Engine(syst), _gameDescription(gd) {
		_system = syst;
		_console = new AvalancheConsole(this);
		_rnd = 0;
	}

	AvalancheEngine::~AvalancheEngine() {
		delete _console;
		delete _rnd;
	}

	GUI::Debugger *AvalancheEngine::getDebugger() {
		return _console;
	}

	Common::Platform AvalancheEngine::getPlatform() const {
		return _platform;
	}

	bool AvalancheEngine::hasFeature(EngineFeature f) const {
		return (f == kSupportsRTL) || (f == kSupportsLoadingDuringRuntime) || (f == kSupportsSavingDuringRuntime);
	}

	const char *AvalancheEngine::getCopyrightString() const {
		return "Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.";
	}

	Common::String AvalancheEngine::getSavegameFilename(int slot) {
		return _targetName + Common::String::format("-%02d.SAV", slot);
	}

	void AvalancheEngine::syncSoundSettings() {
		Engine::syncSoundSettings();

		//	_sound->syncVolume();
	}

	void AvalancheEngine::initialize() {
		//debugC(1, kDebugEngine, "initialize");

		_rnd = new Common::RandomSource("avalanche");
		_rnd->setSeed(42);                              // Kick random number generator
	}



	// From Bootstrp:

	void AvalancheEngine::cursor_off() {
		warning("STUB: cursor_off()");
	}

	void AvalancheEngine::cursor_on() {
		warning("STUB: cursor_on()");
	}

	void AvalancheEngine::quit() {
		cursor_on();
	}

	Common::String AvalancheEngine::strf(int32 x) {
		Common::String q = Common::String::format("%d", x);
		return q;
	}

	Common::String AvalancheEngine::command_com() {
		warning("STUB: command_com()");
		return ("STUB: command_com()");
	}

	void AvalancheEngine::explain(byte error) {
		warning("STUB: explain()");
	}

	void AvalancheEngine::b_flight() {   /*interrupt;*/
		_storage.skellern++;
	}

	void AvalancheEngine::bflight_on() {
		_storage.skellern = _reset_;
		warning("STUB: bflight_on()");
		// setintvec(0x1c, &b_flight);
	}

	void AvalancheEngine::bflight_off() {
		warning("STUB: bflight_off()");
		// setintvec(0x1c, old_1c);
	}

	Common::String AvalancheEngine::elm2str(elm how) {
		Common::String elm2str_result;
		switch (how) {
		case Normal:
		case Musical:
			elm2str_result = "jsb";
			break;
		case Regi:
			elm2str_result = "REGI";
			break;
		case Elmpoyten:
			elm2str_result = "ELMPOYTEN";
			break;
		}
		return elm2str_result;
	}

	void AvalancheEngine::run(Common::String what, bool with_jsb, bool with_bflight, elm how) {
		warning("STUB: run()"); 
		// Probably there'll be no need of this function, as all *.AVX-es will become classes.
	}

	void AvalancheEngine::run_avalot() {
		warning("STUB: run_avalot()");
	}

	void AvalancheEngine::run_the_demo() {
		warning("STUB: run_the_demo()");
	}

	void AvalancheEngine::get_arguments() {
		warning("STUB: get_arguments()");
	}

	void AvalancheEngine::dos_shell() {
		warning("STUB: dos_shell()");
	}

	bool AvalancheEngine::keypressed1() {
		warning("STUB: keypressed1()");
		return false;
	}

	void AvalancheEngine::flush_buffer() {
		warning("STUB: flush_buffer()");
	}

	void AvalancheEngine::demo() {
		warning("STUB: demo()");
	}

	void AvalancheEngine::call_menu() {
		warning("STUB: call_menu()");
	}

	void AvalancheEngine::get_slope() {
		warning("STUB: get_slope()");
	}



	Common::Error AvalancheEngine::run() {
		s_Engine = this;
		initGraphics(320, 200, false);
		_console = new AvalancheConsole(this);



		// From bootstrp:

		/*original_mode = mem[seg0040 * 0x49];
		getintvec(0x1c, old_1c);*/

		first_time = true;

		get_arguments();
		get_slope();

		if (! zoomy)  call_menu();    /* Not run when zoomy. */

		do {
			run_avalot();

			//if (dosexitcode != 77)  quit(); /* Didn't stop for us. */

			switch (_storage.operation) {
			case _runShootemup:
				run("seu.avx", _jsb, _bflight, Normal);
				break;
			case _runDosshell:
				dos_shell();
				break;
			case _runGhostroom:
				run("g-room.avx", _jsb, _no_bflight, Normal);
				break;
			case _runGolden:
				run("golden.avx", _jsb, _bflight, Musical);
				break;
			}

		} while (true);



		//	_mouse = new MouseHandler(this);

		// Setup mixer
		syncSoundSettings();

		return Common::kNoError;
	}

	

} // End of namespace Avalanche