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"
|
2017-05-31 18:49:03 +02:00
|
|
|
|
|
|
|
#include "supernova/supernova.h"
|
2017-06-13 14:24:13 +02:00
|
|
|
//#include "supernova/rooms.h"
|
2017-05-31 18:49:03 +02:00
|
|
|
|
2017-06-03 22:58:42 +02:00
|
|
|
|
2017-05-31 18:49:03 +02:00
|
|
|
namespace Supernova {
|
|
|
|
|
2017-06-15 19:55:09 +02:00
|
|
|
const char *const Object::defaultDescription = "Es ist nichts Besonderes daran.";
|
|
|
|
|
|
|
|
ObjectType operator|(ObjectType a, ObjectType b) {
|
|
|
|
return static_cast<ObjectType>(+a | +b);
|
|
|
|
}
|
|
|
|
|
2017-06-16 10:25:41 +02:00
|
|
|
ObjectType operator&(ObjectType a, ObjectType b) {
|
|
|
|
return static_cast<ObjectType>(+a & +b);
|
|
|
|
}
|
|
|
|
|
2017-06-15 19:55:09 +02:00
|
|
|
ObjectType operator^(ObjectType a, ObjectType b) {
|
|
|
|
return static_cast<ObjectType>(+a ^ +b);
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjectType &operator|=(ObjectType &a, ObjectType b) {
|
|
|
|
return a = a | b;
|
|
|
|
}
|
|
|
|
|
2017-06-16 10:25:41 +02:00
|
|
|
ObjectType &operator&=(ObjectType &a, ObjectType b) {
|
|
|
|
return a = a & b;
|
|
|
|
}
|
|
|
|
|
2017-06-15 19:55:09 +02:00
|
|
|
ObjectType &operator^=(ObjectType &a, ObjectType b) {
|
|
|
|
return a = a ^ b;
|
|
|
|
}
|
|
|
|
|
2017-05-31 18:49:03 +02:00
|
|
|
SupernovaEngine::SupernovaEngine(OSystem *syst)
|
2017-06-15 22:16:48 +02:00
|
|
|
: Engine(syst)
|
|
|
|
, _console(NULL)
|
2017-06-10 00:17:19 +02:00
|
|
|
, _brightness(255)
|
|
|
|
, _menuBrightness(255)
|
2017-06-13 14:24:13 +02:00
|
|
|
, _imageIndex(10)
|
|
|
|
, _sectionIndex(0)
|
2017-06-13 20:22:37 +02:00
|
|
|
, _delay(33)
|
2017-06-15 22:16:48 +02:00
|
|
|
, _gameRunning(true)
|
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-15 22:16:48 +02:00
|
|
|
|
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-03 22:58:42 +02:00
|
|
|
initData();
|
2017-06-10 00:17:19 +02:00
|
|
|
initPalette();
|
|
|
|
paletteFadeIn();
|
2017-06-03 22:58:42 +02:00
|
|
|
|
2017-06-15 22:16:48 +02:00
|
|
|
CursorMan.showMouse(true);
|
|
|
|
|
2017-06-05 16:27:06 +02:00
|
|
|
while (_gameRunning) {
|
|
|
|
updateEvents();
|
2017-06-15 22:16:48 +02:00
|
|
|
|
2017-06-13 14:24:13 +02:00
|
|
|
renderImage(_imageIndex, _sectionIndex);
|
2017-06-15 22:16:48 +02:00
|
|
|
renderText(Common::String::format("%u | %u", _imageIndex, _sectionIndex).c_str(), 0, 190, kColorLightRed);
|
2017-06-03 22:58:42 +02:00
|
|
|
_system->updateScreen();
|
2017-06-13 20:22:37 +02:00
|
|
|
_system->delayMillis(_delay);
|
2017-06-03 22:58:42 +02:00
|
|
|
}
|
2017-06-15 22:16:48 +02:00
|
|
|
|
2017-06-03 22:58:42 +02:00
|
|
|
//deinit timer/sound/..
|
|
|
|
stopSound();
|
2017-05-31 18:49:03 +02:00
|
|
|
|
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
2017-06-18 17:44:33 +02:00
|
|
|
// Emulates DOS int 1A/00
|
|
|
|
uint SupernovaEngine::getDOSTicks() {
|
|
|
|
TimeDate systemTime;
|
|
|
|
_system->getTimeAndDate(systemTime);
|
|
|
|
|
|
|
|
return static_cast<uint>((systemTime.tm_hour * 24 +
|
|
|
|
systemTime.tm_min * 60 +
|
|
|
|
systemTime.tm_sec) * 18.2065);
|
|
|
|
}
|
|
|
|
|
2017-06-05 16:27:06 +02:00
|
|
|
void SupernovaEngine::updateEvents() {
|
|
|
|
Common::Event event;
|
2017-06-15 22:16:48 +02:00
|
|
|
|
2017-06-05 16:27:06 +02:00
|
|
|
while (g_system->getEventManager()->pollEvent(event)) {
|
|
|
|
switch (event.type) {
|
|
|
|
case Common::EVENT_QUIT:
|
|
|
|
case Common::EVENT_RTL:
|
|
|
|
_gameRunning = false;
|
|
|
|
break;
|
2017-06-15 22:16:48 +02:00
|
|
|
|
2017-06-05 16:27:06 +02:00
|
|
|
case Common::EVENT_KEYDOWN:
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_d && event.kbd.hasFlags(Common::KBD_CTRL)) {
|
2017-06-10 00:17:19 +02:00
|
|
|
paletteFadeOut();
|
|
|
|
}
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_d && !event.kbd.hasFlags(Common::KBD_CTRL)) {
|
|
|
|
paletteFadeIn();
|
2017-06-05 16:27:06 +02:00
|
|
|
}
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_q) {
|
|
|
|
playSound(48, 13530);
|
|
|
|
}
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_w) {
|
2017-06-13 14:24:13 +02:00
|
|
|
_sectionIndex = 0;
|
|
|
|
++_imageIndex;
|
|
|
|
if (_imageIndex == 31) {
|
2017-06-15 22:16:48 +02:00
|
|
|
renderText("Das Schicksal", 44, 132, kColorWhite99);
|
|
|
|
renderText("des Horst Hummel", 35, 142, kColorWhite99);
|
|
|
|
renderText("Teil 1:", 64, 120, kColorLightBlue);
|
2017-06-10 00:17:19 +02:00
|
|
|
}
|
2017-06-13 14:24:13 +02:00
|
|
|
}
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_e) {
|
2017-06-13 20:22:37 +02:00
|
|
|
renderImage(_imageIndex, 0);
|
|
|
|
renderImage(_imageIndex, ++_sectionIndex);
|
2017-06-05 16:27:06 +02:00
|
|
|
}
|
|
|
|
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() {
|
2017-06-10 00:17:19 +02:00
|
|
|
_system->getPaletteManager()->setPalette(initVGAPalette, 0, 256);
|
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
|
|
|
}
|
2017-06-15 22:16:48 +02:00
|
|
|
|
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!");
|
|
|
|
}
|
2017-06-15 22:16:48 +02:00
|
|
|
|
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-15 22:16:48 +02:00
|
|
|
|
2017-06-05 16:27:06 +02:00
|
|
|
// play Supernova MOD file
|
|
|
|
}
|
|
|
|
|
2017-06-13 20:22:37 +02:00
|
|
|
void SupernovaEngine::renderImage(int filenumber, int section, bool fullscreen) {
|
2017-06-05 16:27:06 +02:00
|
|
|
Common::File file;
|
|
|
|
if (!file.open(Common::String::format("msn_data.0%2d", filenumber))) {
|
|
|
|
error("File %s could not be read!", file.getName());
|
|
|
|
}
|
2017-06-15 22:16:48 +02:00
|
|
|
|
2017-06-05 16:27:06 +02:00
|
|
|
_image.loadStream(file);
|
|
|
|
_image.loadSection(section);
|
2017-06-13 20:22:37 +02:00
|
|
|
_system->getPaletteManager()->setPalette(_image.getPalette(), 16, 239);
|
2017-06-10 00:17:19 +02:00
|
|
|
paletteBrightness();
|
2017-06-13 20:22:37 +02:00
|
|
|
if (fullscreen) {
|
|
|
|
_system->copyRectToScreen(_image.getSurface()->getPixels(), 320, 0, 0, 320, 200);
|
|
|
|
} else {
|
|
|
|
size_t offset = _image._section[section].y1 * 320 + _image._section[section].x1;
|
|
|
|
_system->copyRectToScreen(static_cast<const byte *>(_image.getSurface()->getPixels()) + offset,
|
2017-06-15 22:16:48 +02:00
|
|
|
320,
|
|
|
|
_image._section[section].x1,
|
|
|
|
_image._section[section].y1,
|
|
|
|
_image._section[section].x2 - _image._section[section].x1,
|
|
|
|
_image._section[section].y2 - _image._section[section].y1);
|
2017-06-13 20:22:37 +02:00
|
|
|
}
|
2017-06-03 22:58:42 +02:00
|
|
|
}
|
|
|
|
|
2017-06-08 12:15:24 +02:00
|
|
|
static int characterWidth(const char *text) {
|
|
|
|
int charWidth = 0;
|
|
|
|
while (*text != '\0') {
|
|
|
|
byte c = *text++;
|
|
|
|
if (c < 32) {
|
|
|
|
continue;
|
|
|
|
} else if (c == 225) {
|
|
|
|
c = 35;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 0; i < 5; ++i) {
|
|
|
|
++charWidth;
|
|
|
|
if (font[c - 32][i] == 0xff) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return charWidth;
|
|
|
|
}
|
2017-06-07 18:34:11 +02:00
|
|
|
|
2017-06-09 06:47:56 +02:00
|
|
|
void SupernovaEngine::renderMessage(char *text, MessagePosition position) {
|
|
|
|
char *row[20];
|
|
|
|
char *p = text;
|
|
|
|
size_t numRows = 0;
|
|
|
|
int rowWidthMax = 0;
|
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
byte textColor = 0;
|
2017-06-15 22:16:48 +02:00
|
|
|
|
2017-06-09 06:47:56 +02:00
|
|
|
while (*p != '\0') {
|
|
|
|
row[numRows] = p;
|
|
|
|
++numRows;
|
|
|
|
while ((*p != '\0') && (*p != '|')) {
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
if (*p == '|') {
|
|
|
|
*p = '\0';
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (size_t i = 0; i < numRows; ++i) {
|
|
|
|
int rowWidth = characterWidth(row[i]);
|
|
|
|
if (rowWidth > rowWidthMax)
|
|
|
|
rowWidthMax = rowWidth;
|
|
|
|
}
|
2017-06-15 22:16:48 +02:00
|
|
|
|
2017-06-09 06:47:56 +02:00
|
|
|
switch (position) {
|
|
|
|
case kMessageNormal:
|
|
|
|
x = rowWidthMax / 2 - 160;
|
|
|
|
textColor = COL_MELD;
|
|
|
|
break;
|
|
|
|
case kMessageTop:
|
|
|
|
x = rowWidthMax / 2 - 160;
|
2017-06-15 22:16:48 +02:00
|
|
|
textColor = kColorLightYellow;
|
2017-06-09 06:47:56 +02:00
|
|
|
break;
|
|
|
|
case kMessageCenter:
|
|
|
|
x = rowWidthMax / 2 - 160;
|
2017-06-15 22:16:48 +02:00
|
|
|
textColor = kColorLightRed;
|
2017-06-09 06:47:56 +02:00
|
|
|
break;
|
|
|
|
case kMessageLeft:
|
|
|
|
x = 3;
|
2017-06-15 22:16:48 +02:00
|
|
|
textColor = kColorLightYellow;
|
2017-06-09 06:47:56 +02:00
|
|
|
break;
|
|
|
|
case kMessageRight:
|
|
|
|
x = 317 - rowWidthMax;
|
2017-06-15 22:16:48 +02:00
|
|
|
textColor = kColorLightGreen;
|
2017-06-09 06:47:56 +02:00
|
|
|
break;
|
|
|
|
}
|
2017-06-15 22:16:48 +02:00
|
|
|
|
2017-06-09 06:47:56 +02:00
|
|
|
if (position == kMessageNormal) {
|
|
|
|
y = 70 - ((numRows * 9) / 2);
|
|
|
|
} else if (position == kMessageTop) {
|
|
|
|
y = 5;
|
|
|
|
} else {
|
|
|
|
y = 142;
|
|
|
|
}
|
2017-06-15 22:16:48 +02:00
|
|
|
|
2017-06-09 06:47:56 +02:00
|
|
|
int message_columns = x - 3;
|
|
|
|
int message_rows = y - 3;
|
|
|
|
int message_width = rowWidthMax + 6;
|
|
|
|
int message_height = numRows * 9 + 5;
|
2017-06-15 22:16:48 +02:00
|
|
|
renderBox(message_columns, message_rows, message_width, message_height, HGR_MELD);
|
2017-06-09 06:47:56 +02:00
|
|
|
for (size_t i = 0; i < numRows; ++i) {
|
|
|
|
renderText(row[i], x, y, textColor);
|
|
|
|
y += 9;
|
|
|
|
}
|
2017-06-15 22:16:48 +02:00
|
|
|
|
2017-06-09 06:47:56 +02:00
|
|
|
// timer1 = (Common::strnlen(text, BUFSIZ) + 20) * textspeed / 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SupernovaEngine::renderText(const char *text, int x, int y, byte color) {
|
|
|
|
Graphics::Surface *screen = _system->lockScreen();
|
|
|
|
byte *cursor = static_cast<byte *>(screen->getBasePtr(x, y));
|
|
|
|
byte c;
|
|
|
|
while ((c = *text++) != '\0') {
|
|
|
|
if (c < 32) {
|
|
|
|
continue;
|
|
|
|
} else if (c == 225) {
|
|
|
|
c = 128;
|
|
|
|
}
|
2017-06-15 22:16:48 +02:00
|
|
|
|
2017-06-09 06:47:56 +02:00
|
|
|
for (size_t i = 0; i < 5; ++i) {
|
|
|
|
if (font[c - 32][i] == 0xff) {
|
|
|
|
++cursor;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte *ascentLine = cursor;
|
|
|
|
for (byte j = font[c - 32][i]; j != 0; j >>= 1) {
|
|
|
|
if (j & 1) {
|
|
|
|
*cursor = color;
|
|
|
|
}
|
|
|
|
cursor += kScreenWidth;
|
|
|
|
}
|
|
|
|
cursor = ++ascentLine;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_system->unlockScreen();
|
|
|
|
}
|
|
|
|
|
2017-06-07 18:34:11 +02:00
|
|
|
void SupernovaEngine::renderBox(int x, int y, int width, int height, byte color) {
|
|
|
|
Graphics::Surface *screen = _system->lockScreen();
|
2017-06-09 06:47:56 +02:00
|
|
|
screen->fillRect(Common::Rect(x, y, width, height), color);
|
2017-06-07 18:34:11 +02:00
|
|
|
_system->unlockScreen();
|
|
|
|
}
|
|
|
|
|
2017-06-10 00:17:19 +02:00
|
|
|
void SupernovaEngine::paletteBrightness() {
|
|
|
|
byte palette[768];
|
2017-06-15 22:16:48 +02:00
|
|
|
|
2017-06-12 11:11:35 +02:00
|
|
|
_system->getPaletteManager()->grabPalette(palette, 0, 255);
|
2017-06-10 00:17:19 +02:00
|
|
|
for (size_t i = 0; i < 48; ++i) {
|
|
|
|
palette[i] = (initVGAPalette[i] * _menuBrightness) >> 8;
|
|
|
|
}
|
2017-06-12 11:11:35 +02:00
|
|
|
for (size_t i = 0; i < 717; ++i) {
|
2017-06-10 00:17:19 +02:00
|
|
|
const byte *imagePalette;
|
|
|
|
if (_image.getPalette()) {
|
|
|
|
imagePalette = _image.getPalette();
|
|
|
|
} else {
|
|
|
|
imagePalette = palette;
|
|
|
|
}
|
2017-06-12 11:11:35 +02:00
|
|
|
palette[i + 48] = (imagePalette[i] * _brightness) >> 8;
|
2017-06-10 00:17:19 +02:00
|
|
|
}
|
2017-06-12 11:11:35 +02:00
|
|
|
_system->getPaletteManager()->setPalette(palette, 0, 255);
|
2017-05-31 18:49:03 +02:00
|
|
|
}
|
2017-06-08 12:15:24 +02:00
|
|
|
|
2017-06-10 00:17:19 +02:00
|
|
|
void SupernovaEngine::paletteFadeOut() {
|
|
|
|
// TODO: scene 0 (newspaper article in intro, mode 0x11)
|
|
|
|
// needs to be handled differently
|
2017-06-15 22:16:48 +02:00
|
|
|
|
2017-06-10 00:17:19 +02:00
|
|
|
while (_brightness > 20) {
|
|
|
|
_menuBrightness = _brightness;
|
|
|
|
paletteBrightness();
|
|
|
|
_brightness -= 20;
|
|
|
|
_system->updateScreen();
|
2017-06-13 20:22:37 +02:00
|
|
|
_system->delayMillis(_delay);
|
2017-06-10 00:17:19 +02:00
|
|
|
}
|
|
|
|
_menuBrightness = 0;
|
|
|
|
_brightness = 0;
|
|
|
|
paletteBrightness();
|
|
|
|
_system->updateScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SupernovaEngine::paletteFadeIn() {
|
|
|
|
// TODO: scene 0 (newspaper article in intro, mode 0x11)
|
|
|
|
// needs to be handled differently
|
2017-06-15 22:16:48 +02:00
|
|
|
|
2017-06-10 00:17:19 +02:00
|
|
|
while (_brightness < 235) {
|
|
|
|
_menuBrightness = _brightness;
|
|
|
|
paletteBrightness();
|
|
|
|
_brightness += 20;
|
|
|
|
_system->updateScreen();
|
2017-06-13 20:22:37 +02:00
|
|
|
_system->delayMillis(_delay);
|
2017-06-10 00:17:19 +02:00
|
|
|
}
|
|
|
|
_menuBrightness = 255;
|
|
|
|
_brightness = 255;
|
|
|
|
paletteBrightness();
|
|
|
|
_system->updateScreen();
|
|
|
|
}
|
|
|
|
|
2017-06-15 22:57:59 +02:00
|
|
|
Inventory::Inventory()
|
|
|
|
: _numObjects(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
// TODO: Update Inventory surface for scrolling
|
|
|
|
void Inventory::add(Object &obj) {
|
|
|
|
if (_numObjects < kMaxCarry)
|
|
|
|
_inventory[_numObjects] = &obj;
|
2017-06-18 18:20:46 +02:00
|
|
|
|
|
|
|
// if (inventory_amount>8) inventory_scroll = ((inventory_amount+1)/2)*2-8;
|
|
|
|
// show_inventory();
|
2017-06-15 22:57:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Update Inventory surface for scrolling
|
|
|
|
void Inventory::remove(Object &obj) {
|
|
|
|
for (size_t i = 0; i < _numObjects; ++i) {
|
|
|
|
if (_inventory[i] == &obj) {
|
|
|
|
--_numObjects;
|
|
|
|
while (i < _numObjects) {
|
|
|
|
_inventory[i] = _inventory[i + 1];
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
obj.disableProperty(CARRIED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-18 18:20:46 +02:00
|
|
|
Object *Inventory::get(size_t index) const {
|
2017-06-15 22:57:59 +02:00
|
|
|
if (index < _numObjects)
|
|
|
|
return _inventory[index];
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-06-18 18:20:46 +02:00
|
|
|
Object *Inventory::get(ObjectID id) const {
|
|
|
|
for (size_t i = 0; i < _numObjects; ++i) {
|
|
|
|
if (_inventory[i]->_id == id)
|
|
|
|
return _inventory[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-06-18 17:05:21 +02:00
|
|
|
ScreenBufferStack::ScreenBufferStack()
|
|
|
|
: _last(_buffer) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScreenBufferStack::push(int x, int y, int width, int height, int pitch) {
|
|
|
|
if (_last == ARRAYEND(_buffer))
|
|
|
|
return;
|
|
|
|
|
|
|
|
byte *pixels = new byte[width * height];
|
|
|
|
const byte *screen = static_cast<byte *>(g_system->lockScreen()->getBasePtr(x, y));
|
|
|
|
for (int i = 0; i < height; ++i) {
|
|
|
|
Common::copy(screen, screen + width, pixels);
|
|
|
|
screen += pitch * i;
|
|
|
|
}
|
|
|
|
g_system->unlockScreen();
|
|
|
|
|
|
|
|
_last->_x = x;
|
|
|
|
_last->_y = y;
|
|
|
|
_last->_width = width;
|
|
|
|
_last->_height = height;
|
|
|
|
_last->_pitch = pitch;
|
|
|
|
_last->_pixels = pixels;
|
|
|
|
|
|
|
|
++_last;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScreenBufferStack::restore() {
|
|
|
|
if (_last == _buffer)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_system->lockScreen()->copyRectToSurface(
|
|
|
|
_last->_pixels, _last->_width, _last->_x, _last->_y,
|
|
|
|
_last->_width, _last->_height);
|
|
|
|
g_system->unlockScreen();
|
|
|
|
--_last;
|
|
|
|
}
|
|
|
|
|
2017-06-10 00:17:19 +02:00
|
|
|
}
|