2017-05-31 18:49:03 +02:00
|
|
|
/* 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 "common/config-manager.h"
|
|
|
|
#include "common/debug.h"
|
|
|
|
#include "common/debug-channels.h"
|
|
|
|
#include "common/error.h"
|
2017-06-03 22:58:42 +02:00
|
|
|
#include "common/events.h"
|
2017-05-31 18:49:03 +02:00
|
|
|
#include "common/file.h"
|
|
|
|
#include "common/fs.h"
|
2017-06-03 22:58:42 +02:00
|
|
|
#include "common/str.h"
|
|
|
|
#include "common/system.h"
|
2017-05-31 18:49:03 +02:00
|
|
|
#include "engines/util.h"
|
2017-06-03 22:58:42 +02:00
|
|
|
#include "graphics/cursorman.h"
|
|
|
|
#include "graphics/surface.h"
|
|
|
|
#include "graphics/screen.h"
|
|
|
|
#include "graphics/palette.h"
|
|
|
|
//#include "graphics/font.h"
|
|
|
|
//#include "graphics/fontman.h"
|
2017-05-31 18:49:03 +02:00
|
|
|
|
|
|
|
#include "supernova/supernova.h"
|
|
|
|
|
2017-06-03 22:58:42 +02:00
|
|
|
|
2017-05-31 18:49:03 +02:00
|
|
|
namespace Supernova {
|
|
|
|
|
|
|
|
SupernovaEngine::SupernovaEngine(OSystem *syst)
|
|
|
|
: Engine(syst)
|
|
|
|
, _console(NULL)
|
2017-06-05 16:27:06 +02:00
|
|
|
, _colorIndex(0)
|
2017-05-31 18:49:03 +02:00
|
|
|
{
|
2017-06-03 22:58:42 +02:00
|
|
|
// const Common::FSNode gameDataDir(ConfMan.get("path"));
|
|
|
|
// SearchMan.addSubDirectoryMatching(gameDataDir, "sound");
|
2017-05-31 18:49:03 +02:00
|
|
|
|
|
|
|
// setup engine specific debug channels
|
|
|
|
DebugMan.addDebugChannel(kDebugGeneral, "general", "Supernova general debug channel");
|
|
|
|
|
|
|
|
_rnd = new Common::RandomSource("supernova");
|
|
|
|
}
|
|
|
|
|
|
|
|
SupernovaEngine::~SupernovaEngine() {
|
|
|
|
DebugMan.clearAllDebugChannels();
|
2017-06-03 22:58:42 +02:00
|
|
|
|
|
|
|
delete _rnd;
|
|
|
|
delete _console;
|
2017-05-31 18:49:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error SupernovaEngine::run() {
|
2017-06-03 22:58:42 +02:00
|
|
|
initGraphics(kScreenWidth, kScreenHeight);
|
2017-06-05 16:27:06 +02:00
|
|
|
debug(_system->getScreenFormat().toString().c_str());
|
2017-05-31 18:49:03 +02:00
|
|
|
_console = new Console(this);
|
|
|
|
|
2017-06-05 16:27:06 +02:00
|
|
|
initPalette();
|
2017-06-03 22:58:42 +02:00
|
|
|
initData();
|
|
|
|
|
2017-06-05 16:27:06 +02:00
|
|
|
_gameRunning = true;
|
|
|
|
while (_gameRunning) {
|
|
|
|
updateEvents();
|
|
|
|
renderImage(31, 0);
|
|
|
|
|
2017-06-03 22:58:42 +02:00
|
|
|
_system->updateScreen();
|
|
|
|
_system->delayMillis(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
//deinit timer/sound/..
|
|
|
|
stopSound();
|
2017-05-31 18:49:03 +02:00
|
|
|
|
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
2017-06-05 16:27:06 +02:00
|
|
|
void SupernovaEngine::updateEvents() {
|
|
|
|
Common::Event event;
|
|
|
|
|
|
|
|
while (g_system->getEventManager()->pollEvent(event)) {
|
|
|
|
switch (event.type) {
|
|
|
|
case Common::EVENT_QUIT:
|
|
|
|
case Common::EVENT_RTL:
|
|
|
|
_gameRunning = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Common::EVENT_KEYDOWN:
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_d && event.kbd.hasFlags(Common::KBD_CTRL)) {
|
|
|
|
_console->attach();
|
|
|
|
}
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_q) {
|
|
|
|
playSound(48, 13530);
|
|
|
|
}
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_w) {
|
|
|
|
++_colorIndex;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2017-06-03 22:58:42 +02:00
|
|
|
}
|
2017-06-05 16:27:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SupernovaEngine::initData() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void SupernovaEngine::initPalette() {
|
|
|
|
// Default VGA palette
|
|
|
|
byte pal[768] = {
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x00, 0xa8, 0x00, 0x00, 0xa8, 0xa8, 0xa8, 0x00, 0x00, 0xa8, 0x00, 0xa8,
|
|
|
|
0xa8, 0x54, 0x00, 0xa8, 0xa8, 0xa8, 0x54, 0x54, 0x54, 0x54, 0x54, 0xfc, 0x54, 0xfc, 0x54, 0x54, 0xfc, 0xfc,
|
|
|
|
0xfc, 0x54, 0x54, 0xfc, 0x54, 0xfc, 0xfc, 0xfc, 0x54, 0xfc, 0xfc, 0xfc, 0x00, 0x00, 0x00, 0x14, 0x14, 0x14,
|
|
|
|
0x20, 0x20, 0x20, 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|
|
|
0x70, 0x38, 0x70, 0x70, 0x38, 0x60, 0x70, 0x38, 0x54, 0x70, 0x38, 0x44, 0x70, 0x38, 0x38, 0x70, 0x44, 0x38,
|
|
|
|
0x70, 0x54, 0x38, 0x70, 0x60, 0x38, 0x70, 0x70, 0x38, 0x60, 0x70, 0x38, 0x54, 0x70, 0x38, 0x44, 0x70, 0x38,
|
|
|
|
0x38, 0x70, 0x38, 0x38, 0x70, 0x44, 0x38, 0x70, 0x54, 0x38, 0x70, 0x60, 0x38, 0x70, 0x70, 0x38, 0x60, 0x70,
|
|
|
|
0x38, 0x54, 0x70, 0x38, 0x44, 0x70, 0x50, 0x50, 0x70, 0x58, 0x50, 0x70, 0x60, 0x50, 0x70, 0x68, 0x50, 0x70,
|
|
|
|
0x70, 0x50, 0x70, 0x70, 0x50, 0x68, 0x70, 0x50, 0x60, 0x70, 0x50, 0x58, 0x70, 0x50, 0x50, 0x70, 0x58, 0x50,
|
|
|
|
0x70, 0x60, 0x50, 0x70, 0x68, 0x50, 0x70, 0x70, 0x50, 0x68, 0x70, 0x50, 0x60, 0x70, 0x50, 0x58, 0x70, 0x50,
|
|
|
|
0x50, 0x70, 0x50, 0x50, 0x70, 0x58, 0x50, 0x70, 0x60, 0x50, 0x70, 0x68, 0x50, 0x70, 0x70, 0x50, 0x68, 0x70,
|
|
|
|
0x50, 0x60, 0x70, 0x50, 0x58, 0x70, 0x00, 0x00, 0x40, 0x10, 0x00, 0x40, 0x20, 0x00, 0x40, 0x30, 0x00, 0x40,
|
|
|
|
0x40, 0x00, 0x40, 0x40, 0x00, 0x30, 0x40, 0x00, 0x20, 0x40, 0x00, 0x10, 0x40, 0x00, 0x00, 0x40, 0x10, 0x00,
|
|
|
|
0x40, 0x20, 0x00, 0x40, 0x30, 0x00, 0x40, 0x40, 0x00, 0x30, 0x40, 0x00, 0x20, 0x40, 0x00, 0x10, 0x40, 0x00,
|
|
|
|
0x00, 0x40, 0x00, 0x00, 0x40, 0x10, 0x00, 0x40, 0x20, 0x00, 0x40, 0x30, 0x00, 0x40, 0x40, 0x00, 0x30, 0x40,
|
|
|
|
0x00, 0x20, 0x40, 0x00, 0x10, 0x40, 0x20, 0x20, 0x40, 0x28, 0x20, 0x40, 0x30, 0x20, 0x40, 0x38, 0x20, 0x40,
|
|
|
|
0x40, 0x20, 0x40, 0x40, 0x20, 0x38, 0x40, 0x20, 0x30, 0x40, 0x20, 0x28, 0x40, 0x20, 0x20, 0x40, 0x28, 0x20,
|
|
|
|
0x40, 0x30, 0x20, 0x40, 0x38, 0x20, 0x40, 0x40, 0x20, 0x38, 0x40, 0x20, 0x30, 0x40, 0x20, 0x28, 0x40, 0x20,
|
|
|
|
0x20, 0x40, 0x20, 0x20, 0x40, 0x28, 0x20, 0x40, 0x30, 0x20, 0x40, 0x38, 0x20, 0x40, 0x40, 0x20, 0x38, 0x40,
|
|
|
|
0x20, 0x30, 0x40, 0x20, 0x28, 0x40, 0x2c, 0x2c, 0x40, 0x30, 0x2c, 0x40, 0x34, 0x2c, 0x40, 0x3c, 0x2c, 0x40,
|
|
|
|
0x40, 0x2c, 0x40, 0x40, 0x2c, 0x3c, 0x40, 0x2c, 0x34, 0x40, 0x2c, 0x30, 0x40, 0x2c, 0x2c, 0x40, 0x30, 0x2c,
|
|
|
|
0x40, 0x34, 0x2c, 0x40, 0x3c, 0x2c, 0x40, 0x40, 0x2c, 0x3c, 0x40, 0x2c, 0x34, 0x40, 0x2c, 0x30, 0x40, 0x2c,
|
|
|
|
0x2c, 0x40, 0x2c, 0x2c, 0x40, 0x30, 0x2c, 0x40, 0x34, 0x2c, 0x40, 0x3c, 0x2c, 0x40, 0x40, 0x2c, 0x3c, 0x40,
|
|
|
|
0x2c, 0x34, 0x40, 0x2c, 0x30, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
|
};
|
|
|
|
|
|
|
|
byte init_pal[] = {
|
|
|
|
0, 0, 0, 16,16,16, 22,22,22, 28,28,28,
|
|
|
|
63,63,63, 0,52, 0, 0,63, 0, 54, 0, 0,
|
|
|
|
63, 0, 0, 0, 0,30, 0, 0,45, 40,40,40,
|
|
|
|
20,50,63, 10,63,10, 60,60, 0, 63,10,10
|
|
|
|
};
|
2017-06-03 22:58:42 +02:00
|
|
|
|
2017-06-05 16:27:06 +02:00
|
|
|
_system->getPaletteManager()->setPalette(pal, 0, 256);
|
2017-06-07 14:17:16 +02:00
|
|
|
_system->getPaletteManager()->setPalette(init_pal, 0, 16);
|
2017-06-03 22:58:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SupernovaEngine::playSound(int filenumber, int offset) {
|
2017-06-05 16:27:06 +02:00
|
|
|
Common::File *file = new Common::File;
|
|
|
|
if (!file->open(Common::String::format("msn_data.0%2d", filenumber))) {
|
|
|
|
error("File %s could not be read!", file->getName());
|
2017-06-03 22:58:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
file->seek(offset);
|
|
|
|
Audio::SeekableAudioStream *audioStream = Audio::makeRawStream(file, 11931, Audio::FLAG_UNSIGNED | Audio::FLAG_LITTLE_ENDIAN);
|
|
|
|
stopSound();
|
|
|
|
_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, audioStream);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SupernovaEngine::stopSound() {
|
|
|
|
if (_mixer->isSoundHandleActive(_soundHandle))
|
|
|
|
_mixer->stopHandle(_soundHandle);
|
|
|
|
}
|
|
|
|
|
2017-06-05 16:27:06 +02:00
|
|
|
void playSoundMod(int filenumber)
|
|
|
|
{
|
|
|
|
if (filenumber != 49 || filenumber != 52) {
|
|
|
|
error("File not supposed to be played!");
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::File *file = new Common::File;
|
|
|
|
if (!file->open(Common::String::format("msn_data.0%2d", filenumber))) {
|
|
|
|
error("File %s could not be read!", file->getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
// play Supernova MOD file
|
|
|
|
}
|
|
|
|
|
|
|
|
void SupernovaEngine::renderImage(int filenumber, int section) {
|
|
|
|
Common::File file;
|
|
|
|
if (!file.open(Common::String::format("msn_data.0%2d", filenumber))) {
|
|
|
|
error("File %s could not be read!", file.getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
_image.loadStream(file);
|
|
|
|
_image.loadSection(section);
|
|
|
|
_system->copyRectToScreen(_image.getSurface()->getPixels(), 320, 0, 0, 320, 200);
|
2017-06-03 22:58:42 +02:00
|
|
|
}
|
|
|
|
|
2017-05-31 18:49:03 +02:00
|
|
|
}
|