aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen/swordsofxeen/swordsofxeen.cpp
blob: 6f3963e1d06fad53ef8369d2c49d890411cc797b (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
/* 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.
 *
 */

#include "xeen/swordsofxeen/swordsofxeen.h"
#include "xeen/swordsofxeen/swordsofxeen_menu.h"

namespace Xeen {
namespace SwordsOfXeen {

SwordsOfXeenEngine::SwordsOfXeenEngine(OSystem *syst, const XeenGameDescription *gameDesc)
		: XeenEngine(syst, gameDesc) {
}

void SwordsOfXeenEngine::showMainMenu() {
	MainMenu::show(this);
}

void SwordsOfXeenEngine::death() {
	Windows &windows = *g_vm->_windows;

	_screen->loadBackground("blank.raw");
	windows[28].setBounds(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT));
	_screen->fadeIn(0x81);
	_screen->loadPalette("scr.pal");
	_screen->fadeIn(0x81);

	SpriteResource lose("lose.int");
	lose.draw(0, 0, Common::Point(0, 0));
	lose.draw(0, 1, Common::Point(160, 0));
	_sound->playSound("laff1.voc");

	bool breakFlag = false;
	for (int idx = 0, idx2 = 0; idx < (_files->_ccNum ? 10 : 23); ++idx) {
		_events->updateGameCounter();

		if (_files->_ccNum) {
			breakFlag = _events->wait(2);
		} else {
			if (idx == 1 || idx == 11)
				_sound->playFX(33);
			breakFlag = _events->wait(2);

			if (idx == 15)
				_sound->playFX(34);
		}

		if ((_files->_ccNum ? 9 : 10) == idx) {
			if ((_files->_ccNum ? 2 : 1) > idx2) {
				// Restart loop
				idx = -1;
				++idx2;
			}
		}
	}

	// Wait for press
	if (!breakFlag)
		_events->waitForPress();

	_screen->fadeOut(4);
	_screen->loadBackground("blank.raw");
	_screen->loadPalette("dark.pal");
	_sound->stopAllAudio();
}

bool SwordsOfXeenEngine::showEnding() {
	Windows &windows = *_windows;
	SpriteResource win("win.int");

	_screen->loadBackground("blank.raw");
	windows[28].setBounds(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT));
	_screen->fadeIn(0x81);
	_screen->loadPalette("scr.pal");
	_screen->fadeIn(0x81);

	win.draw(0, 0, Common::Point(0, 0));
	win.draw(0, 1, Common::Point(160, 0));
	_sound->playSound("ch1.voc");
	_events->waitForPress();

	_screen->fadeOut();
	_screen->loadBackground("blank.raw");
	return true;
}

void SwordsOfXeenEngine::dream() {
	// Swords of Xeen doesn't have any dreams
}

void SwordsOfXeenEngine::showCutscene(const Common::String &name, int status, uint score) {
	_sound->stopAllAudio();
	_events->clearEvents();

	if (name != "ENDGAME")
		error("Unknown cutscene specified");

	showEnding();

	_screen->freePages();
	_sound->stopAllAudio();
	_events->clearEvents();
	_gameMode = GMODE_MENU;

}

} // End of namespace SwordsOfXeen
} // End of namespace Xeen