Initial commit
This commit is contained in:
190
engines/freescape/games/eclipse/atari.cpp
Normal file
190
engines/freescape/games/eclipse/atari.cpp
Normal file
@@ -0,0 +1,190 @@
|
||||
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/file.h"
|
||||
#include "common/memstream.h"
|
||||
|
||||
#include "freescape/freescape.h"
|
||||
#include "freescape/games/eclipse/eclipse.h"
|
||||
#include "freescape/language/8bitDetokeniser.h"
|
||||
|
||||
namespace Freescape {
|
||||
|
||||
void EclipseEngine::initAmigaAtari() {
|
||||
_viewArea = Common::Rect(32, 16, 288, 118);
|
||||
}
|
||||
|
||||
/*void EclipseEngine::loadAssetsCPCFullGame() {
|
||||
Common::File file;
|
||||
|
||||
if (isEclipse2())
|
||||
file.open("TE2.BI1");
|
||||
else
|
||||
file.open("TESCR.SCR");
|
||||
|
||||
if (!file.isOpen())
|
||||
error("Failed to open TESCR.SCR/TE2.BI1");
|
||||
|
||||
_title = readCPCImage(&file, true);
|
||||
_title->setPalette((byte*)&kCPCPaletteTitleData, 0, 4);
|
||||
|
||||
file.close();
|
||||
if (isEclipse2())
|
||||
file.open("TE2.BI3");
|
||||
else
|
||||
file.open("TECON.SCR");
|
||||
|
||||
if (!file.isOpen())
|
||||
error("Failed to open TECON.SCR/TE2.BI3");
|
||||
|
||||
_border = readCPCImage(&file, true);
|
||||
_border->setPalette((byte*)&kCPCPaletteTitleData, 0, 4);
|
||||
|
||||
file.close();
|
||||
if (isEclipse2())
|
||||
file.open("TE2.BI2");
|
||||
else
|
||||
file.open("TECODE.BIN");
|
||||
|
||||
if (!file.isOpen())
|
||||
error("Failed to open TECODE.BIN/TE2.BI2");
|
||||
|
||||
if (isEclipse2()) {
|
||||
loadFonts(&file, 0x60bc, _font);
|
||||
loadMessagesFixedSize(&file, 0x326, 16, 30);
|
||||
load8bitBinary(&file, 0x62b4, 16);
|
||||
} else {
|
||||
loadFonts(&file, 0x6076, _font);
|
||||
loadMessagesFixedSize(&file, 0x326, 16, 30);
|
||||
load8bitBinary(&file, 0x626e, 16);
|
||||
}
|
||||
|
||||
for (auto &it : _areaMap) {
|
||||
it._value->addStructure(_areaMap[255]);
|
||||
|
||||
if (isEclipse2() && it._value->getAreaID() == 1)
|
||||
continue;
|
||||
|
||||
if (isEclipse2() && it._value->getAreaID() == _startArea)
|
||||
continue;
|
||||
|
||||
for (int16 id = 183; id < 207; id++)
|
||||
it._value->addObjectFromArea(id, _areaMap[255]);
|
||||
}
|
||||
loadColorPalette();
|
||||
swapPalette(1);
|
||||
|
||||
_indicators.push_back(loadBundledImage("eclipse_ankh_indicator"));
|
||||
|
||||
for (auto &it : _indicators)
|
||||
it->convertToInPlace(_gfx->_texturePixelFormat);
|
||||
}
|
||||
|
||||
void EclipseEngine::drawCPCUI(Graphics::Surface *surface) {
|
||||
uint32 color = _currentArea->_underFireBackgroundColor;
|
||||
uint8 r, g, b;
|
||||
|
||||
_gfx->readFromPalette(color, r, g, b);
|
||||
uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
color = _currentArea->_usualBackgroundColor;
|
||||
if (_gfx->_colorRemaps && _gfx->_colorRemaps->contains(color)) {
|
||||
color = (*_gfx->_colorRemaps)[color];
|
||||
}
|
||||
|
||||
_gfx->readFromPalette(color, r, g, b);
|
||||
uint32 back = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
color = _currentArea->_inkColor;
|
||||
|
||||
_gfx->readFromPalette(color, r, g, b);
|
||||
uint32 other = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
int score = _gameStateVars[k8bitVariableScore];
|
||||
int shield = _gameStateVars[k8bitVariableShield] * 100 / _maxShield;
|
||||
shield = shield < 0 ? 0 : shield;
|
||||
|
||||
Common::String message;
|
||||
int deadline;
|
||||
getLatestMessages(message, deadline);
|
||||
if (deadline <= _countdown) {
|
||||
drawStringInSurface(message, 102, 135, back, front, surface);
|
||||
_temporaryMessages.push_back(message);
|
||||
_temporaryMessageDeadlines.push_back(deadline);
|
||||
} else if (!_currentAreaMessages.empty())
|
||||
drawStringInSurface(_currentArea->_name, 102, 135, back, front, surface);
|
||||
|
||||
Common::String scoreStr = Common::String::format("%07d", score);
|
||||
drawStringInSurface(scoreStr, 136, 6, back, other, surface, 'Z' - '0' + 1);
|
||||
|
||||
int x = 171;
|
||||
if (shield < 10)
|
||||
x = 179;
|
||||
else if (shield < 100)
|
||||
x = 175;
|
||||
|
||||
Common::String shieldStr = Common::String::format("%d", shield);
|
||||
drawStringInSurface(shieldStr, x, 162, back, other, surface);
|
||||
|
||||
drawStringInSurface(Common::String('0' + _angleRotationIndex - 3), 79, 135, back, front, surface, 'Z' - '$' + 1);
|
||||
drawStringInSurface(Common::String('3' - _playerStepIndex), 63, 135, back, front, surface, 'Z' - '$' + 1);
|
||||
drawStringInSurface(Common::String('7' - _playerHeightNumber), 240, 135, back, front, surface, 'Z' - '$' + 1);
|
||||
|
||||
if (_shootingFrames > 0) {
|
||||
drawStringInSurface("4", 232, 135, back, front, surface, 'Z' - '$' + 1);
|
||||
drawStringInSurface("<", 240, 135, back, front, surface, 'Z' - '$' + 1);
|
||||
}
|
||||
drawAnalogClock(surface, 90, 172, back, other, front);
|
||||
drawIndicator(surface, 45, 4, 12);
|
||||
drawEclipseIndicator(surface, 228, 0, front, other);
|
||||
}*/
|
||||
|
||||
void EclipseEngine::loadAssetsAtariFullGame() {
|
||||
Common::File file;
|
||||
file.open("0.tec");
|
||||
_title = loadAndConvertNeoImage(&file, 0x17ac);
|
||||
file.close();
|
||||
|
||||
Common::SeekableReadStream *stream = decryptFileAmigaAtari("1.tec", "0.tec", 0x1774 - 4 * 1024);
|
||||
parseAmigaAtariHeader(stream);
|
||||
|
||||
loadMessagesVariableSize(stream, 0x87a6, 28);
|
||||
load8bitBinary(stream, 0x2a53c, 16);
|
||||
|
||||
_border = loadAndConvertNeoImage(stream, 0x139c8);
|
||||
loadPalettes(stream, 0x2a0fa);
|
||||
loadSoundsFx(stream, 0x3030c, 6);
|
||||
|
||||
/*
|
||||
loadFonts(stream, 0xd06b, _fontBig);
|
||||
loadFonts(stream, 0xd49a, _fontMedium);
|
||||
loadFonts(stream, 0xd49b, _fontSmall);
|
||||
|
||||
load8bitBinary(stream, 0x20918, 16);
|
||||
loadMessagesVariableSize(stream, 0x3f6f, 66);
|
||||
|
||||
loadPalettes(stream, 0x204d6);
|
||||
loadGlobalObjects(stream, 0x32f6, 24);
|
||||
loadSoundsFx(stream, 0x266e8, 11);*/
|
||||
}
|
||||
|
||||
} // End of namespace Freescape
|
||||
180
engines/freescape/games/eclipse/c64.cpp
Normal file
180
engines/freescape/games/eclipse/c64.cpp
Normal file
@@ -0,0 +1,180 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/file.h"
|
||||
|
||||
#include "freescape/freescape.h"
|
||||
#include "freescape/games/eclipse/eclipse.h"
|
||||
#include "freescape/language/8bitDetokeniser.h"
|
||||
|
||||
namespace Freescape {
|
||||
|
||||
void EclipseEngine::initC64() {
|
||||
_viewArea = Common::Rect(32, 32, 288, 136);
|
||||
|
||||
_maxEnergy = 35;
|
||||
}
|
||||
|
||||
extern byte kC64Palette[16][3];
|
||||
|
||||
void EclipseEngine::loadAssetsC64FullGame() {
|
||||
Common::File file;
|
||||
file.open(isEclipse2() ? "totaleclipse2.c64.data" : "totaleclipse.c64.data");
|
||||
|
||||
if (_variant & GF_C64_TAPE) {
|
||||
int size = file.size();
|
||||
|
||||
byte *buffer = (byte *)malloc(size * sizeof(byte));
|
||||
file.read(buffer, file.size());
|
||||
|
||||
_extraBuffer = decompressC64RLE(buffer, &size, isEclipse2() ? 0xd2 : 0xe1);
|
||||
// size should be the size of the decompressed data
|
||||
Common::MemoryReadStream dfile(_extraBuffer, size, DisposeAfterUse::NO);
|
||||
|
||||
loadMessagesFixedSize(&dfile, 0x1d84, 16, 30);
|
||||
loadFonts(&dfile, 0xc3e);
|
||||
load8bitBinary(&dfile, 0x9a3e, 16);
|
||||
} else if (_variant & GF_C64_DISC) {
|
||||
loadMessagesFixedSize(&file, 0x1534, 16, 30);
|
||||
loadFonts(&file, 0x3f2);
|
||||
if (isEclipse2())
|
||||
load8bitBinary(&file, 0x7ac4, 16);
|
||||
else
|
||||
load8bitBinary(&file, 0x7ab4, 16);
|
||||
} else
|
||||
error("Unknown C64 variant %x", _variant);
|
||||
|
||||
Graphics::Surface *surf = loadBundledImage("eclipse_border");
|
||||
surf->convertToInPlace(_gfx->_texturePixelFormat);
|
||||
_border = new Graphics::ManagedSurface();
|
||||
_border->copyFrom(*surf);
|
||||
surf->free();
|
||||
delete surf;
|
||||
|
||||
file.close();
|
||||
file.open(isEclipse2() ? "totaleclipse2.c64.title.bitmap" : "totaleclipse.c64.title.bitmap");
|
||||
|
||||
Common::File colorFile1;
|
||||
colorFile1.open(isEclipse2() ? "totaleclipse2.c64.title.colors1" : "totaleclipse.c64.title.colors1");
|
||||
Common::File colorFile2;
|
||||
colorFile2.open(isEclipse2() ? "totaleclipse2.c64.title.colors2" : "totaleclipse.c64.title.colors2");
|
||||
|
||||
_title = loadAndConvertDoodleImage(&file, &colorFile1, &colorFile2, (byte *)&kC64Palette);
|
||||
|
||||
_indicators.push_back(loadBundledImage("eclipse_ankh_indicator"));
|
||||
|
||||
for (auto &it : _indicators)
|
||||
it->convertToInPlace(_gfx->_texturePixelFormat);
|
||||
}
|
||||
|
||||
|
||||
void EclipseEngine::drawC64UI(Graphics::Surface *surface) {
|
||||
uint32 color = _currentArea->_underFireBackgroundColor;
|
||||
uint8 r, g, b;
|
||||
|
||||
_gfx->readFromPalette(color, r, g, b);
|
||||
uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
color = _currentArea->_usualBackgroundColor;
|
||||
if (_gfx->_colorRemaps && _gfx->_colorRemaps->contains(color)) {
|
||||
color = (*_gfx->_colorRemaps)[color];
|
||||
}
|
||||
|
||||
_gfx->readFromPalette(color, r, g, b);
|
||||
uint32 back = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
_gfx->readFromPalette(13, r, g, b);
|
||||
uint32 green = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
_gfx->readFromPalette(3, r, g, b);
|
||||
uint32 blue = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
_gfx->readFromPalette(2, r, g, b);
|
||||
uint32 red = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
_gfx->readFromPalette(0, r, g, b);
|
||||
uint32 black = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
_gfx->readFromPalette(1, r, g, b);
|
||||
uint32 white = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
int score = _gameStateVars[k8bitVariableScore];
|
||||
int shield = _gameStateVars[k8bitVariableShield] * 100 / _maxShield;
|
||||
int energy = _gameStateVars[k8bitVariableEnergy];
|
||||
shield = shield < 0 ? 0 : shield;
|
||||
|
||||
_gfx->readFromPalette(7, r, g, b);
|
||||
uint32 yellow = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
Common::String message;
|
||||
int deadline;
|
||||
getLatestMessages(message, deadline);
|
||||
if (deadline <= _countdown) {
|
||||
drawStringInSurface(message, 104, 138, back, yellow, surface);
|
||||
_temporaryMessages.push_back(message);
|
||||
_temporaryMessageDeadlines.push_back(deadline);
|
||||
} else if (!_currentAreaMessages.empty())
|
||||
drawStringInSurface(_currentArea->_name, 104, 138, back, yellow, surface);
|
||||
|
||||
drawScoreString(score, 128, 7, black, white, surface);
|
||||
|
||||
Common::String shieldStr = Common::String::format("%d", shield);
|
||||
|
||||
int x = 174;
|
||||
if (shield < 10)
|
||||
x = 182;
|
||||
else if (shield < 100)
|
||||
x = 179;
|
||||
|
||||
if (energy < 0)
|
||||
energy = 0;
|
||||
|
||||
drawStringInSurface(shieldStr, x, 161, back, red, surface);
|
||||
|
||||
Common::Rect jarBackground(112, 170, 144, 196);
|
||||
surface->fillRect(jarBackground, back);
|
||||
|
||||
Common::Rect jarWater(112, 196 - energy, 144, 196);
|
||||
surface->fillRect(jarWater, blue);
|
||||
|
||||
// TODO
|
||||
/*drawStringInSurface(shiftStr("0", 'Z' - '$' + 1 - _angleRotationIndex), 79, 138, back, yellow, surface);
|
||||
drawStringInSurface(shiftStr("3", 'Z' - '$' + 1 - _playerStepIndex), 63, 138, back, yellow, surface);
|
||||
drawStringInSurface(shiftStr("7", 'Z' - '$' + 1 - _playerHeightNumber), 240, 138, back, yellow, surface);
|
||||
|
||||
if (_shootingFrames > 0) {
|
||||
drawStringInSurface(shiftStr("4", 'Z' - '$' + 1), 232, 138, back, yellow, surface);
|
||||
drawStringInSurface(shiftStr("<", 'Z' - '$' + 1) , 240, 138, back, yellow, surface);
|
||||
}*/
|
||||
|
||||
drawAnalogClockHand(surface, 72, 172, 38 * 6 - 90, 11, white);
|
||||
drawAnalogClockHand(surface, 72, 172, 37 * 6 - 90, 11, white);
|
||||
drawAnalogClockHand(surface, 72, 172, 36 * 6 - 90, 11, white);
|
||||
drawAnalogClock(surface, 72, 172, back, red, white);
|
||||
|
||||
surface->fillRect(Common::Rect(236, 170, 258, 187), white);
|
||||
drawCompass(surface, 247, 177, _yaw, 13, back);
|
||||
|
||||
drawIndicator(surface, 56, 4, 8);
|
||||
drawEclipseIndicator(surface, 224, 0, front, green);
|
||||
}
|
||||
|
||||
} // End of namespace Freescape
|
||||
203
engines/freescape/games/eclipse/cpc.cpp
Normal file
203
engines/freescape/games/eclipse/cpc.cpp
Normal file
@@ -0,0 +1,203 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/file.h"
|
||||
#include "common/memstream.h"
|
||||
|
||||
#include "freescape/freescape.h"
|
||||
#include "freescape/games/eclipse/eclipse.h"
|
||||
#include "freescape/language/8bitDetokeniser.h"
|
||||
|
||||
namespace Freescape {
|
||||
|
||||
void EclipseEngine::initCPC() {
|
||||
_viewArea = Common::Rect(36 + 3, 24 + 8, 284, 130 + 3);
|
||||
}
|
||||
|
||||
byte kCPCPaletteEclipseTitleData[4][3] = {
|
||||
{0x00, 0x00, 0x00},
|
||||
{0xff, 0xff, 0x00},
|
||||
{0xff, 0x00, 0xff},
|
||||
{0xff, 0x80, 0x00},
|
||||
};
|
||||
|
||||
byte kCPCPaletteEclipseBorderData[4][3] = {
|
||||
{0x00, 0x00, 0x00},
|
||||
{0xff, 0x80, 0x00},
|
||||
{0x80, 0xff, 0xff},
|
||||
{0x00, 0x80, 0x00},
|
||||
};
|
||||
|
||||
|
||||
extern Graphics::ManagedSurface *readCPCImage(Common::SeekableReadStream *file, bool mode0);
|
||||
|
||||
void EclipseEngine::loadAssetsCPCFullGame() {
|
||||
Common::File file;
|
||||
|
||||
if (isEclipse2())
|
||||
file.open("TE2.BI1");
|
||||
else
|
||||
file.open("TESCR.SCR");
|
||||
|
||||
if (!file.isOpen())
|
||||
error("Failed to open TESCR.SCR/TE2.BI1");
|
||||
|
||||
_title = readCPCImage(&file, true);
|
||||
_title->setPalette((byte*)&kCPCPaletteEclipseTitleData, 0, 4);
|
||||
|
||||
file.close();
|
||||
if (isEclipse2())
|
||||
file.open("TE2.BI3");
|
||||
else
|
||||
file.open("TECON.SCR");
|
||||
|
||||
if (!file.isOpen())
|
||||
error("Failed to open TECON.SCR/TE2.BI3");
|
||||
|
||||
_border = readCPCImage(&file, true);
|
||||
_border->setPalette((byte*)&kCPCPaletteEclipseBorderData, 0, 4);
|
||||
|
||||
file.close();
|
||||
if (isEclipse2())
|
||||
file.open("TE2.BI2");
|
||||
else
|
||||
file.open("TECODE.BIN");
|
||||
|
||||
if (!file.isOpen())
|
||||
error("Failed to open TECODE.BIN/TE2.BI2");
|
||||
|
||||
if (isEclipse2()) {
|
||||
loadFonts(&file, 0x60bc);
|
||||
loadMessagesFixedSize(&file, 0x326, 16, 30);
|
||||
load8bitBinary(&file, 0x62b4, 16);
|
||||
} else {
|
||||
loadFonts(&file, 0x6076);
|
||||
loadMessagesFixedSize(&file, 0x326, 16, 30);
|
||||
load8bitBinary(&file, 0x626e, 16);
|
||||
}
|
||||
|
||||
loadColorPalette();
|
||||
swapPalette(1);
|
||||
|
||||
_indicators.push_back(loadBundledImage("eclipse_ankh_indicator"));
|
||||
|
||||
for (auto &it : _indicators)
|
||||
it->convertToInPlace(_gfx->_texturePixelFormat);
|
||||
}
|
||||
|
||||
void EclipseEngine::loadAssetsCPCDemo() {
|
||||
Common::File file;
|
||||
|
||||
file.open("TECON.BIN");
|
||||
if (!file.isOpen())
|
||||
error("Failed to open TECON.BIN");
|
||||
|
||||
_border = readCPCImage(&file, true);
|
||||
_border->setPalette((byte*)&kCPCPaletteEclipseTitleData, 0, 4);
|
||||
|
||||
file.close();
|
||||
file.open("TEPROG.BIN");
|
||||
|
||||
if (!file.isOpen())
|
||||
error("Failed to open TEPROG.BIN");
|
||||
|
||||
loadFonts(&file, 0x63ce);
|
||||
loadMessagesFixedSize(&file, 0x362, 16, 23);
|
||||
loadMessagesFixedSize(&file, 0x570b, 264, 5);
|
||||
load8bitBinary(&file, 0x65c6, 16);
|
||||
loadColorPalette();
|
||||
swapPalette(1);
|
||||
|
||||
_indicators.push_back(loadBundledImage("eclipse_ankh_indicator"));
|
||||
|
||||
for (auto &it : _indicators)
|
||||
it->convertToInPlace(_gfx->_texturePixelFormat);
|
||||
}
|
||||
|
||||
void EclipseEngine::drawCPCUI(Graphics::Surface *surface) {
|
||||
uint32 color = _currentArea->_underFireBackgroundColor;
|
||||
uint8 r, g, b;
|
||||
|
||||
_gfx->readFromPalette(color, r, g, b);
|
||||
uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
color = _currentArea->_usualBackgroundColor;
|
||||
if (_gfx->_colorRemaps && _gfx->_colorRemaps->contains(color)) {
|
||||
color = (*_gfx->_colorRemaps)[color];
|
||||
}
|
||||
|
||||
_gfx->readFromPalette(color, r, g, b);
|
||||
uint32 back = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
color = _currentArea->_inkColor;
|
||||
|
||||
_gfx->readFromPalette(color, r, g, b);
|
||||
uint32 other = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
int score = _gameStateVars[k8bitVariableScore];
|
||||
int shield = _gameStateVars[k8bitVariableShield] * 100 / _maxShield;
|
||||
shield = shield < 0 ? 0 : shield;
|
||||
|
||||
Common::String message;
|
||||
int deadline;
|
||||
getLatestMessages(message, deadline);
|
||||
if (deadline <= _countdown) {
|
||||
drawStringInSurface(message, 102, 135, back, front, surface);
|
||||
_temporaryMessages.push_back(message);
|
||||
_temporaryMessageDeadlines.push_back(deadline);
|
||||
} else if (!_currentAreaMessages.empty())
|
||||
drawStringInSurface(_currentArea->_name, 102, 135, back, front, surface);
|
||||
|
||||
drawScoreString(score, 136, 6, back, other, surface);
|
||||
|
||||
int x = 171;
|
||||
if (shield < 10)
|
||||
x = 179;
|
||||
else if (shield < 100)
|
||||
x = 175;
|
||||
|
||||
Common::String shieldStr = Common::String::format("%d", shield);
|
||||
drawStringInSurface(shieldStr, x, 162, back, other, surface);
|
||||
|
||||
drawStringInSurface(shiftStr("0", 'Z' - '$' + 1 - _angleRotationIndex), 79, 135, back, front, surface);
|
||||
drawStringInSurface(shiftStr("3", 'Z' - '$' + 1 - _playerStepIndex), 63, 135, back, front, surface);
|
||||
drawStringInSurface(shiftStr("7", 'Z' - '$' + 1 - _playerHeightNumber), 240, 135, back, front, surface);
|
||||
|
||||
if (_shootingFrames > 0) {
|
||||
drawStringInSurface(shiftStr("4", 'Z' - '$' + 1), 232, 135, back, front, surface);
|
||||
drawStringInSurface(shiftStr("<", 'Z' - '$' + 1), 240, 135, back, front, surface);
|
||||
}
|
||||
drawAnalogClock(surface, 90, 172, back, other, front);
|
||||
drawIndicator(surface, 45, 4, 12);
|
||||
drawEclipseIndicator(surface, 228, 0, front, other);
|
||||
|
||||
Common::Rect jarBackground(124, 165, 148, 192);
|
||||
surface->fillRect(jarBackground, back);
|
||||
|
||||
Common::Rect jarWater(124, 192 - _gameStateVars[k8bitVariableEnergy], 148, 192);
|
||||
surface->fillRect(jarWater, color);
|
||||
|
||||
surface->fillRect(Common::Rect(225, 168, 235, 187), front);
|
||||
drawCompass(surface, 229, 177, _yaw, 10, back);
|
||||
|
||||
}
|
||||
|
||||
} // End of namespace Freescape
|
||||
207
engines/freescape/games/eclipse/dos.cpp
Normal file
207
engines/freescape/games/eclipse/dos.cpp
Normal file
@@ -0,0 +1,207 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "audio/audiostream.h"
|
||||
#include "audio/decoders/raw.h"
|
||||
|
||||
#include "freescape/freescape.h"
|
||||
#include "freescape/games/eclipse/eclipse.h"
|
||||
#include "freescape/language/8bitDetokeniser.h"
|
||||
|
||||
namespace Freescape {
|
||||
|
||||
extern byte kEGADefaultPalette[16][3];
|
||||
extern byte kCGAPaletteRedGreen[4][3];
|
||||
extern byte kCGAPalettePinkBlue[4][3];
|
||||
|
||||
void EclipseEngine::initDOS() {
|
||||
_viewArea = Common::Rect(40, 33, 280, 133);
|
||||
_soundIndexShoot = 18;
|
||||
_soundIndexCollide = 1;
|
||||
_soundIndexStepDown = 3;
|
||||
_soundIndexStepUp = 3;
|
||||
_soundIndexMenu = -1;
|
||||
_soundIndexStart = 9;
|
||||
_soundIndexAreaChange = 5;
|
||||
}
|
||||
|
||||
void EclipseEngine::loadAssetsDOSFullGame() {
|
||||
Common::File file;
|
||||
if (_renderMode == Common::kRenderEGA) {
|
||||
file.open("SCN1E.DAT");
|
||||
if (file.isOpen()) {
|
||||
_title = load8bitBinImage(&file, 0x0);
|
||||
_title->setPalette((byte *)&kEGADefaultPalette, 0, 16);
|
||||
}
|
||||
file.close();
|
||||
file.open("TOTEE.EXE");
|
||||
|
||||
if (!file.isOpen())
|
||||
error("Failed to open TOTEE.EXE");
|
||||
|
||||
loadMessagesFixedSize(&file, 0x710f, 16, 20);
|
||||
loadSoundsFx(&file, 0xd670, 5);
|
||||
loadSpeakerFxDOS(&file, 0x7396 + 0x200, 0x72a1 + 0x200, 20);
|
||||
loadFonts(&file, 0xd403);
|
||||
load8bitBinary(&file, 0x3ce0, 16);
|
||||
|
||||
_border = load8bitBinImage(&file, 0x210);
|
||||
_border->setPalette((byte *)&kEGADefaultPalette, 0, 16);
|
||||
|
||||
_indicators.push_back(loadBundledImage("eclipse_ankh_indicator"));
|
||||
|
||||
for (auto &it : _indicators)
|
||||
it->convertToInPlace(_gfx->_texturePixelFormat);
|
||||
|
||||
} else if (_renderMode == Common::kRenderCGA) {
|
||||
file.open("SCN1C.DAT");
|
||||
if (file.isOpen()) {
|
||||
_title = load8bitBinImage(&file, 0x0);
|
||||
_title->setPalette((byte *)&kCGAPaletteRedGreen, 0, 4);
|
||||
}
|
||||
file.close();
|
||||
file.open("TOTEC.EXE");
|
||||
|
||||
if (!file.isOpen())
|
||||
error("Failed to open TOTEC.EXE");
|
||||
|
||||
loadMessagesFixedSize(&file, 0x594f, 16, 20);
|
||||
loadSoundsFx(&file, 0xb9f0, 5);
|
||||
loadFonts(&file, 0xb785);
|
||||
load8bitBinary(&file, 0x2530, 4);
|
||||
_border = load8bitBinImage(&file, 0x210);
|
||||
_border->setPalette((byte *)&kCGAPaletteRedGreen, 0, 4);
|
||||
swapPalette(_startArea);
|
||||
} else
|
||||
error("Invalid or unsupported render mode %s for Total Eclipse", Common::getRenderModeDescription(_renderMode));
|
||||
}
|
||||
|
||||
void EclipseEngine::drawDOSUI(Graphics::Surface *surface) {
|
||||
int score = _gameStateVars[k8bitVariableScore];
|
||||
int shield = _gameStateVars[k8bitVariableShield] * 100 / _maxShield;
|
||||
shield = shield < 0 ? 0 : shield;
|
||||
|
||||
uint32 yellow = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0xFF, 0xFF, 0x55);
|
||||
uint32 black = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0x00, 0x00);
|
||||
uint32 white = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
uint32 red = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0xFF, 0x00, 0x00);
|
||||
uint32 blue = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x55, 0x55, 0xFF);
|
||||
uint32 green = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x55, 0xFF, 0x55);
|
||||
uint32 redish = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0xFF, 0x55, 0x55);
|
||||
|
||||
Common::String message;
|
||||
int deadline;
|
||||
getLatestMessages(message, deadline);
|
||||
if (deadline <= _countdown) {
|
||||
drawStringInSurface(message, 102, 135, black, yellow, surface);
|
||||
_temporaryMessages.push_back(message);
|
||||
_temporaryMessageDeadlines.push_back(deadline);
|
||||
} else if (!_currentAreaMessages.empty())
|
||||
drawStringInSurface(_currentArea->_name, 102, 135, black, yellow, surface);
|
||||
|
||||
drawScoreString(score, 136, 6, black, white, surface);
|
||||
|
||||
int x = 171;
|
||||
if (shield < 10)
|
||||
x = 179;
|
||||
else if (shield < 100)
|
||||
x = 175;
|
||||
|
||||
Common::String shieldStr = Common::String::format("%d", shield);
|
||||
drawStringInSurface(shieldStr, x, 162, black, redish, surface);
|
||||
|
||||
drawStringInSurface(shiftStr("0", 'Z' - '$' + 1 - _angleRotationIndex), 79, 135, black, yellow, surface);
|
||||
drawStringInSurface(shiftStr("3", 'Z' - '$' + 1 - _playerStepIndex), 63, 135, black, yellow, surface);
|
||||
drawStringInSurface(shiftStr("7", 'Z' - '$' + 1 - _playerHeightNumber), 240, 135, black, yellow, surface);
|
||||
|
||||
if (_shootingFrames > 0) {
|
||||
drawStringInSurface(shiftStr("4", 'Z' - '$' + 1), 232, 135, black, yellow, surface);
|
||||
drawStringInSurface(shiftStr("<", 'Z' - '$' + 1), 240, 135, black, yellow, surface);
|
||||
}
|
||||
drawAnalogClock(surface, 90, 172, black, red, white);
|
||||
|
||||
Common::Rect jarBackground(124, 165, 148, 192);
|
||||
surface->fillRect(jarBackground, black);
|
||||
|
||||
Common::Rect jarWater(124, 192 - _gameStateVars[k8bitVariableEnergy], 148, 192);
|
||||
surface->fillRect(jarWater, blue);
|
||||
|
||||
drawIndicator(surface, 41, 4, 16);
|
||||
drawEclipseIndicator(surface, 228, 0, yellow, green);
|
||||
surface->fillRect(Common::Rect(225, 168, 235, 187), white);
|
||||
drawCompass(surface, 229, 177, _yaw, 10, black);
|
||||
}
|
||||
|
||||
soundFx *EclipseEngine::load1bPCM(Common::SeekableReadStream *file, int offset) {
|
||||
soundFx *sound = (soundFx *)malloc(sizeof(soundFx));
|
||||
file->seek(offset);
|
||||
sound->size = file->readUint16LE();
|
||||
debugC(1, kFreescapeDebugParser, "size: %d", sound->size);
|
||||
sound->sampleRate = file->readUint16LE();
|
||||
debugC(1, kFreescapeDebugParser, "sample rate?: %f", sound->sampleRate);
|
||||
|
||||
uint8 *data = (uint8 *)malloc(sound->size * sizeof(uint8) * 8);
|
||||
for (int i = 0; i < sound->size; i++) {
|
||||
uint8 byte = file->readByte();
|
||||
for (int j = 0; j < 8; j++) {
|
||||
data[8 * i + j] = byte & 1 ? 255 : 0;
|
||||
byte = byte >> 1;
|
||||
}
|
||||
}
|
||||
sound->size = sound->size * 8;
|
||||
sound->data = (byte *)data;
|
||||
return sound;
|
||||
}
|
||||
|
||||
void EclipseEngine::loadSoundsFx(Common::SeekableReadStream *file, int offset, int number) {
|
||||
if (isAmiga() || isAtariST()) {
|
||||
FreescapeEngine::loadSoundsFx(file, offset, number);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < number; i++) {
|
||||
_soundsFx[i] = load1bPCM(file, offset);
|
||||
offset += (_soundsFx[i]->size / 8) + 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EclipseEngine::playSoundFx(int index, bool sync) {
|
||||
if (isAmiga() || isAtariST()) {
|
||||
FreescapeEngine::playSoundFx(index, sync);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_soundsFx.size() == 0) {
|
||||
debugC(1, kFreescapeDebugMedia, "WARNING: Sounds are not loaded");
|
||||
return;
|
||||
}
|
||||
|
||||
int size = _soundsFx[index]->size;
|
||||
//int sampleRate = _soundsFx[index]->sampleRate;
|
||||
byte *data = _soundsFx[index]->data;
|
||||
|
||||
Audio::SeekableAudioStream *stream = Audio::makeRawStream(data, size, 11025, Audio::FLAG_UNSIGNED, DisposeAfterUse::NO);
|
||||
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundFxHandle, stream, -1, kFreescapeDefaultVolume / 10);
|
||||
}
|
||||
|
||||
|
||||
} // End of namespace Freescape
|
||||
812
engines/freescape/games/eclipse/eclipse.cpp
Normal file
812
engines/freescape/games/eclipse/eclipse.cpp
Normal file
@@ -0,0 +1,812 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/file.h"
|
||||
|
||||
#include "backends/keymapper/action.h"
|
||||
#include "backends/keymapper/keymap.h"
|
||||
#include "backends/keymapper/standard-actions.h"
|
||||
#include "common/translation.h"
|
||||
|
||||
#include "freescape/freescape.h"
|
||||
#include "freescape/games/eclipse/eclipse.h"
|
||||
#include "freescape/language/8bitDetokeniser.h"
|
||||
|
||||
namespace Freescape {
|
||||
|
||||
EclipseEngine::EclipseEngine(OSystem *syst, const ADGameDescription *gd) : FreescapeEngine(syst, gd) {
|
||||
// These sounds can be overriden by the class of each platform
|
||||
_soundIndexStartFalling = -1;
|
||||
_soundIndexEndFalling = -1;
|
||||
|
||||
_soundIndexNoShield = -1;
|
||||
_soundIndexNoEnergy = -1;
|
||||
_soundIndexFallen = -1;
|
||||
_soundIndexTimeout = -1;
|
||||
_soundIndexForceEndGame = -1;
|
||||
_soundIndexCrushed = -1;
|
||||
_soundIndexMissionComplete = -1;
|
||||
|
||||
_maxEnergy = 27;
|
||||
_maxShield = 50;
|
||||
|
||||
_initialEnergy = 16;
|
||||
_initialShield = 50;
|
||||
|
||||
if (isDOS())
|
||||
initDOS();
|
||||
else if (isCPC())
|
||||
initCPC();
|
||||
else if (isC64())
|
||||
initC64();
|
||||
else if (isSpectrum())
|
||||
initZX();
|
||||
else if (isAmiga() || isAtariST())
|
||||
initAmigaAtari();
|
||||
|
||||
_playerHeightNumber = 1;
|
||||
_playerHeightMaxNumber = 1;
|
||||
|
||||
_playerWidth = 8;
|
||||
_playerDepth = 8;
|
||||
_stepUpDistance = 32;
|
||||
|
||||
_playerStepIndex = 2;
|
||||
_playerSteps.clear();
|
||||
_playerSteps.push_back(2);
|
||||
_playerSteps.push_back(30);
|
||||
_playerSteps.push_back(60);
|
||||
|
||||
_angleRotationIndex = 1;
|
||||
_angleRotations.push_back(5);
|
||||
_angleRotations.push_back(10);
|
||||
_angleRotations.push_back(15);
|
||||
|
||||
_endArea = 1;
|
||||
_endEntrance = 33;
|
||||
|
||||
_lastThirtySeconds = 0;
|
||||
_lastFiveSeconds = 0;
|
||||
_lastSecond = -1;
|
||||
_resting = false;
|
||||
}
|
||||
|
||||
void EclipseEngine::initGameState() {
|
||||
FreescapeEngine::initGameState();
|
||||
|
||||
_playerHeightNumber = 1;
|
||||
|
||||
_gameStateVars[k8bitVariableEnergy] = _initialEnergy;
|
||||
_gameStateVars[k8bitVariableShield] = _initialShield;
|
||||
|
||||
int seconds, minutes, hours;
|
||||
getTimeFromCountdown(seconds, minutes, hours);
|
||||
_lastThirtySeconds = seconds / 30;
|
||||
_lastFiveSeconds = seconds / 5;
|
||||
_resting = false;
|
||||
|
||||
// Start playing music, if any, in any supported format
|
||||
playMusic("Total Eclipse Theme");
|
||||
}
|
||||
|
||||
void EclipseEngine::loadAssets() {
|
||||
FreescapeEngine::loadAssets();
|
||||
|
||||
Common::List<int> globalIds = _areaMap[255]->getEntranceIds();
|
||||
for (auto &it : _areaMap) {
|
||||
if (it._value->getAreaID() == 255)
|
||||
continue;
|
||||
|
||||
it._value->addStructure(_areaMap[255]);
|
||||
|
||||
if (isDemo()) {
|
||||
it._value->_name = " NOW TRAINING ";
|
||||
}
|
||||
|
||||
for (auto &id : globalIds) {
|
||||
if (it._value->entranceWithID(id))
|
||||
continue;
|
||||
|
||||
Object *obj = _areaMap[255]->entranceWithID(id);
|
||||
assert(obj);
|
||||
assert(obj->getType() == ObjectType::kEntranceType);
|
||||
// The entrance is not in the current area, so we need to add it
|
||||
it._value->addObjectFromArea(id, _areaMap[255]);
|
||||
}
|
||||
}
|
||||
|
||||
_timeoutMessage = _messagesList[1];
|
||||
_noShieldMessage = _messagesList[0];
|
||||
//_noEnergyMessage = _messagesList[16];
|
||||
_fallenMessage = _messagesList[3];
|
||||
_crushedMessage = _messagesList[2];
|
||||
|
||||
_areaMap[1]->addFloor();
|
||||
if (isSpectrum())
|
||||
_areaMap[1]->_paperColor = 1;
|
||||
|
||||
if (!isDemo() && !isEclipse2()) {
|
||||
_areaMap[51]->addFloor();
|
||||
_areaMap[51]->_paperColor = 1;
|
||||
|
||||
// Workaround for fixing some planar objects from area 9 that have null size
|
||||
Object *obj = nullptr;
|
||||
obj = _areaMap[9]->objectWithID(7);
|
||||
assert(obj);
|
||||
obj->_size = 32 * Math::Vector3d(3, 0, 2);
|
||||
|
||||
obj = _areaMap[9]->objectWithID(8);
|
||||
assert(obj);
|
||||
obj->_size = 32 * Math::Vector3d(3, 0, 2);
|
||||
|
||||
obj = _areaMap[9]->objectWithID(9);
|
||||
assert(obj);
|
||||
obj->_size = 32 * Math::Vector3d(3, 0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
bool EclipseEngine::checkIfGameEnded() {
|
||||
if (_gameStateControl == kFreescapeGameStatePlaying) {
|
||||
if (_hasFallen && _avoidRenderingFrames == 0) {
|
||||
_hasFallen = false;
|
||||
if (isDOS())
|
||||
playSoundFx(4, false);
|
||||
else
|
||||
playSound(_soundIndexStartFalling, false, _soundFxHandle);
|
||||
|
||||
stopMovement();
|
||||
// If shield is less than 11 after a fall, the game ends
|
||||
if (_gameStateVars[k8bitVariableShield] > 15 + 11) {
|
||||
_gameStateVars[k8bitVariableShield] -= 15;
|
||||
return false; // Game can continue
|
||||
}
|
||||
if (!_fallenMessage.empty())
|
||||
insertTemporaryMessage(_fallenMessage, _countdown - 4);
|
||||
_gameStateControl = kFreescapeGameStateEnd;
|
||||
} else if (getGameBit(16)) {
|
||||
_gameStateControl = kFreescapeGameStateEnd;
|
||||
insertTemporaryMessage(_messagesList[4], INT_MIN);
|
||||
}
|
||||
|
||||
FreescapeEngine::checkIfGameEnded();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void EclipseEngine::endGame() {
|
||||
FreescapeEngine::endGame();
|
||||
|
||||
if (!_endGamePlayerEndArea)
|
||||
return;
|
||||
|
||||
if (_gameStateControl == kFreescapeGameStateEnd) {
|
||||
removeTimers();
|
||||
if (getGameBit(16)) {
|
||||
if (_countdown > - 3600)
|
||||
_countdown -= 10;
|
||||
else
|
||||
_countdown = -3600;
|
||||
} else {
|
||||
if (_countdown > 0)
|
||||
_countdown -= 10;
|
||||
else
|
||||
_countdown = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (_endGameKeyPressed && (_countdown == 0 || _countdown == -3600)) {
|
||||
if (isSpectrum())
|
||||
playSound(5, true, _soundFxHandle);
|
||||
_gameStateControl = kFreescapeGameStateRestart;
|
||||
}
|
||||
_endGameKeyPressed = false;
|
||||
}
|
||||
|
||||
void EclipseEngine::initKeymaps(Common::Keymap *engineKeyMap, Common::Keymap *infoScreenKeyMap, const char *target) {
|
||||
FreescapeEngine::initKeymaps(engineKeyMap, infoScreenKeyMap, target);
|
||||
Common::Action *act;
|
||||
|
||||
act = new Common::Action("SAVE", _("Save game"));
|
||||
act->setCustomEngineActionEvent(kActionSave);
|
||||
act->addDefaultInputMapping("s");
|
||||
infoScreenKeyMap->addAction(act);
|
||||
|
||||
act = new Common::Action("LOAD", _("Load game"));
|
||||
act->setCustomEngineActionEvent(kActionLoad);
|
||||
act->addDefaultInputMapping("l");
|
||||
infoScreenKeyMap->addAction(act);
|
||||
|
||||
act = new Common::Action("QUIT", _("Quit game"));
|
||||
act->setCustomEngineActionEvent(kActionEscape);
|
||||
if (isSpectrum())
|
||||
act->addDefaultInputMapping("1");
|
||||
else
|
||||
act->addDefaultInputMapping("ESCAPE");
|
||||
infoScreenKeyMap->addAction(act);
|
||||
|
||||
act = new Common::Action("TOGGLESOUND", _("Toggle Sound"));
|
||||
act->setCustomEngineActionEvent(kActionToggleSound);
|
||||
act->addDefaultInputMapping("t");
|
||||
infoScreenKeyMap->addAction(act);
|
||||
|
||||
act = new Common::Action("ROTL", _("Rotate Left"));
|
||||
act->setCustomEngineActionEvent(kActionRotateLeft);
|
||||
act->addDefaultInputMapping("q");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Common::Action("ROTR", _("Rotate Right"));
|
||||
act->setCustomEngineActionEvent(kActionRotateRight);
|
||||
act->addDefaultInputMapping("w");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
// I18N: Illustrates the angle at which you turn left or right.
|
||||
act = new Common::Action("CHNGANGLE", _("Change Angle"));
|
||||
act->setCustomEngineActionEvent(kActionIncreaseAngle);
|
||||
act->addDefaultInputMapping("a");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
// I18N: STEP SIZE: Measures the size of one movement in the direction you are facing (1-250 standard distance units (SDUs))
|
||||
act = new Common::Action("CHNGSTEPSIZE", _("Change Step Size"));
|
||||
act->setCustomEngineActionEvent(kActionChangeStepSize);
|
||||
act->addDefaultInputMapping("s");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Common::Action("TGGLHEIGHT", _("Toggle Height"));
|
||||
act->setCustomEngineActionEvent(kActionToggleRiseLower);
|
||||
act->addDefaultInputMapping("JOY_B");
|
||||
act->addDefaultInputMapping("h");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Common::Action("REST", _("Rest"));
|
||||
act->setCustomEngineActionEvent(kActionRest);
|
||||
act->addDefaultInputMapping("JOY_Y");
|
||||
act->addDefaultInputMapping("r");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Common::Action("FACEFRWARD", _("Face Forward"));
|
||||
act->setCustomEngineActionEvent(kActionFaceForward);
|
||||
act->addDefaultInputMapping("f");
|
||||
engineKeyMap->addAction(act);
|
||||
}
|
||||
|
||||
void EclipseEngine::gotoArea(uint16 areaID, int entranceID) {
|
||||
debugC(1, kFreescapeDebugMove, "Jumping to area: %d, entrance: %d", areaID, entranceID);
|
||||
|
||||
assert(_areaMap.contains(areaID));
|
||||
_currentArea = _areaMap[areaID];
|
||||
_currentArea->show();
|
||||
|
||||
_currentAreaMessages.clear();
|
||||
_currentAreaMessages.push_back(_currentArea->_name);
|
||||
|
||||
if (entranceID > 0)
|
||||
traverseEntrance(entranceID);
|
||||
else if (entranceID == -1)
|
||||
debugC(1, kFreescapeDebugMove, "Loading game, no change in position");
|
||||
else
|
||||
error("Invalid area change!");
|
||||
|
||||
_lastPosition = _position;
|
||||
|
||||
if (areaID == _startArea && entranceID == _startEntrance) {
|
||||
if (_pitch >= 180)
|
||||
_pitch = 360 - _pitch;
|
||||
playSound(_soundIndexStart, false, _soundFxHandle);
|
||||
if (isEclipse2()) {
|
||||
_gameStateControl = kFreescapeGameStateStart;
|
||||
_pitch = -10;
|
||||
}
|
||||
|
||||
} if (areaID == _endArea && entranceID == _endEntrance) {
|
||||
_flyMode = true;
|
||||
if (isDemo())
|
||||
_pitch = 20;
|
||||
else
|
||||
_pitch = 10;
|
||||
} else {
|
||||
playSound(_soundIndexAreaChange, false, _soundFxHandle);
|
||||
}
|
||||
|
||||
_gfx->_keyColor = 0;
|
||||
swapPalette(areaID);
|
||||
_currentArea->_usualBackgroundColor = isCPC() ? 1 : 0;
|
||||
if (isAmiga() || isAtariST())
|
||||
_currentArea->_skyColor = 15;
|
||||
|
||||
resetInput();
|
||||
}
|
||||
|
||||
void EclipseEngine::drawBackground() {
|
||||
clearBackground();
|
||||
_gfx->drawBackground(_currentArea->_skyColor);
|
||||
if (_currentArea && _currentArea->getAreaID() == 1) {
|
||||
if (ABS(_countdown) <= 15 * 60) // Last 15 minutes
|
||||
_gfx->drawBackground(5);
|
||||
if (ABS(_countdown) <= 10) // Last 10 seconds
|
||||
_gfx->drawBackground(1);
|
||||
|
||||
float progress = 0;
|
||||
if (_countdown >= 0 || getGameBit(16))
|
||||
progress = float(_countdown) / _initialCountdown;
|
||||
|
||||
uint8 color1 = 15;
|
||||
uint8 color2 = 10;
|
||||
|
||||
if (isSpectrum() || isCPC() || isC64()) {
|
||||
color1 = 2;
|
||||
color2 = 10;
|
||||
} else if (isAmiga() || isAtariST()) {
|
||||
color1 = 8;
|
||||
color2 = 14;
|
||||
}
|
||||
|
||||
_gfx->drawEclipse(color1, color2, progress);
|
||||
}
|
||||
}
|
||||
|
||||
void EclipseEngine::titleScreen() {
|
||||
if (isDOS())
|
||||
playSoundFx(2, true);
|
||||
FreescapeEngine::titleScreen();
|
||||
}
|
||||
|
||||
|
||||
void EclipseEngine::borderScreen() {
|
||||
if (_border) {
|
||||
drawBorder();
|
||||
if (isDemo() && isCPC()) {
|
||||
drawFullscreenMessageAndWait(_messagesList[23]);
|
||||
drawFullscreenMessageAndWait(_messagesList[24]);
|
||||
drawFullscreenMessageAndWait(_messagesList[25]);
|
||||
} else if (isDemo() && isSpectrum()) {
|
||||
if (_variant & GF_ZX_DEMO_MICROHOBBY) {
|
||||
drawFullscreenMessageAndWait(_messagesList[23]);
|
||||
} else if (_variant & GF_ZX_DEMO_CRASH) {
|
||||
drawFullscreenMessageAndWait(_messagesList[9]);
|
||||
drawFullscreenMessageAndWait(_messagesList[10]);
|
||||
drawFullscreenMessageAndWait(_messagesList[11]);
|
||||
}
|
||||
} else {
|
||||
FreescapeEngine::borderScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EclipseEngine::drawInfoMenu() {
|
||||
PauseToken pauseToken = pauseEngine();
|
||||
if (_savedScreen) {
|
||||
_savedScreen->free();
|
||||
delete _savedScreen;
|
||||
}
|
||||
_savedScreen = _gfx->getScreenshot();
|
||||
uint32 color = 0;
|
||||
switch (_renderMode) {
|
||||
case Common::kRenderCGA:
|
||||
color = 1;
|
||||
break;
|
||||
case Common::kRenderZX:
|
||||
color = 6;
|
||||
break;
|
||||
default:
|
||||
color = 14;
|
||||
}
|
||||
uint8 r, g, b;
|
||||
_gfx->readFromPalette(color, r, g, b);
|
||||
uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
uint32 black = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0x00, 0x00);
|
||||
|
||||
Graphics::Surface *surface = new Graphics::Surface();
|
||||
surface->create(_screenW, _screenH, _gfx->_texturePixelFormat);
|
||||
|
||||
surface->fillRect(Common::Rect(88, 48, 231, 103), black);
|
||||
surface->frameRect(Common::Rect(88, 48, 231, 103), front);
|
||||
|
||||
surface->frameRect(Common::Rect(90, 50, 229, 101), front);
|
||||
|
||||
drawStringInSurface("L-LOAD S-SAVE", 105, 56, front, black, surface);
|
||||
if (isSpectrum())
|
||||
drawStringInSurface("1-TERMINATE", 105, 64, front, black, surface);
|
||||
else
|
||||
drawStringInSurface("ESC-TERMINATE", 105, 64, front, black, surface);
|
||||
|
||||
drawStringInSurface("T-TOGGLE", 128, 81, front, black, surface);
|
||||
drawStringInSurface("SOUND ON/OFF", 113, 88, front, black, surface);
|
||||
|
||||
Texture *menuTexture = _gfx->createTexture(surface);
|
||||
Common::Event event;
|
||||
bool cont = true;
|
||||
while (!shouldQuit() && cont) {
|
||||
while (_eventManager->pollEvent(event)) {
|
||||
|
||||
// Events
|
||||
switch (event.type) {
|
||||
case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
|
||||
if (event.customType == kActionLoad) {
|
||||
_gfx->setViewport(_fullscreenViewArea);
|
||||
_eventManager->purgeKeyboardEvents();
|
||||
loadGameDialog();
|
||||
_gfx->setViewport(_viewArea);
|
||||
} else if (event.customType == kActionSave) {
|
||||
_gfx->setViewport(_fullscreenViewArea);
|
||||
_eventManager->purgeKeyboardEvents();
|
||||
saveGameDialog();
|
||||
_gfx->setViewport(_viewArea);
|
||||
} else if (isDOS() && event.customType == kActionToggleSound) {
|
||||
playSound(_soundIndexMenu, false, _soundFxHandle);
|
||||
} else if ((isDOS() || isCPC() || isSpectrum()) && event.customType == kActionEscape) {
|
||||
_forceEndGame = true;
|
||||
cont = false;
|
||||
} else
|
||||
cont = false;
|
||||
break;
|
||||
case Common::EVENT_KEYDOWN:
|
||||
cont = false;
|
||||
break;
|
||||
case Common::EVENT_SCREEN_CHANGED:
|
||||
_gfx->computeScreenViewport();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
drawFrame();
|
||||
_gfx->drawTexturedRect2D(_fullscreenViewArea, _fullscreenViewArea, menuTexture);
|
||||
|
||||
_gfx->flipBuffer();
|
||||
g_system->updateScreen();
|
||||
g_system->delayMillis(15); // try to target ~60 FPS
|
||||
}
|
||||
|
||||
_savedScreen->free();
|
||||
delete _savedScreen;
|
||||
_savedScreen = nullptr;
|
||||
surface->free();
|
||||
delete surface;
|
||||
delete menuTexture;
|
||||
pauseToken.clear();
|
||||
}
|
||||
|
||||
void EclipseEngine::pressedKey(const int keycode) {
|
||||
if (keycode == kActionIncreaseAngle) {
|
||||
changeAngle(1, true);
|
||||
} else if (keycode == kActionChangeStepSize) {
|
||||
changeStepSize();
|
||||
} else if (keycode == kActionToggleRiseLower) {
|
||||
if (_playerHeightNumber == 0)
|
||||
rise();
|
||||
else if (_playerHeightNumber == 1)
|
||||
lower();
|
||||
else
|
||||
error("Invalid player height index: %d", _playerHeightNumber);
|
||||
} else if (keycode == kActionRest) {
|
||||
if (_currentArea->getAreaID() == 1) {
|
||||
playSoundFx(3, false);
|
||||
if (_temporaryMessages.empty())
|
||||
insertTemporaryMessage(_messagesList[6], _countdown - 2);
|
||||
} else {
|
||||
_resting = true;
|
||||
if (_temporaryMessages.empty())
|
||||
insertTemporaryMessage(_messagesList[7], _countdown - 2);
|
||||
_countdown = _countdown - 5;
|
||||
}
|
||||
} else if (keycode == kActionFaceForward) {
|
||||
_pitch = 0;
|
||||
updateCamera();
|
||||
}
|
||||
}
|
||||
|
||||
void EclipseEngine::releasedKey(const int keycode) {
|
||||
if (keycode == kActionRiseOrFlyUp)
|
||||
_resting = false;
|
||||
}
|
||||
|
||||
void EclipseEngine::drawAnalogClock(Graphics::Surface *surface, int x, int y, uint32 colorHand1, uint32 colorHand2, uint32 colorBack) {
|
||||
// These calls will cover the pixels of the hardcoded clock image
|
||||
drawAnalogClockHand(surface, x, y, 6 * 6 - 90, 12, colorBack);
|
||||
drawAnalogClockHand(surface, x, y, 7 * 6 - 90, 12, colorBack);
|
||||
drawAnalogClockHand(surface, x, y, 41 * 6 - 90, 11, colorBack);
|
||||
drawAnalogClockHand(surface, x, y, 42 * 6 - 90, 11, colorBack);
|
||||
drawAnalogClockHand(surface, x, y, 0 * 6 - 90, 11, colorBack);
|
||||
|
||||
int seconds, minutes, hours;
|
||||
getTimeFromCountdown(seconds, minutes, hours);
|
||||
hours = 7 + 2 - hours; // It's 7 o-clock when the game starts
|
||||
minutes = 59 - minutes;
|
||||
seconds = 59 - seconds;
|
||||
drawAnalogClockHand(surface, x, y, hours * 30 - 90, 11, colorHand1);
|
||||
drawAnalogClockHand(surface, x, y, minutes * 6 - 90, 11, colorHand1);
|
||||
drawAnalogClockHand(surface, x, y, seconds * 6 - 90, 11, colorHand2);
|
||||
}
|
||||
|
||||
void EclipseEngine::drawAnalogClockHand(Graphics::Surface *surface, int x, int y, double degrees, double magnitude, uint32 color) {
|
||||
const double degtorad = (M_PI * 2) / 360;
|
||||
double w = magnitude * cos(degrees * degtorad);
|
||||
double h = magnitude * sin(degrees * degtorad);
|
||||
surface->drawLine(x, y, x+(int)w, y+(int)h, color);
|
||||
if (isC64()) {
|
||||
surface->drawLine(x+1, y, x+1+(int)w, y+(int)h, color);
|
||||
}
|
||||
}
|
||||
|
||||
void EclipseEngine::drawCompass(Graphics::Surface *surface, int x, int y, double degrees, double magnitude, uint32 color) {
|
||||
const double degtorad = (M_PI * 2) / 360;
|
||||
double w = magnitude * cos(-degrees * degtorad);
|
||||
double h = magnitude * sin(-degrees * degtorad);
|
||||
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
|
||||
// Adjust dx and dy to make the compass look like a compass
|
||||
if (degrees == 0 || degrees == 360) {
|
||||
dx = 1;
|
||||
dy = 2;
|
||||
} else if (degrees > 0 && degrees < 90) {
|
||||
dx = 2;
|
||||
dy = 1;
|
||||
} else if (degrees == 90) {
|
||||
dx = 2;
|
||||
dy = 1;
|
||||
} else if (degrees > 90 && degrees < 180) {
|
||||
dx = 2;
|
||||
dy = -1;
|
||||
} else if (degrees == 180) {
|
||||
dx = 1;
|
||||
dy = 2;
|
||||
} else if (degrees > 180 && degrees < 270) {
|
||||
dx = -2;
|
||||
dy = -1;
|
||||
} else if (degrees == 270) {
|
||||
dx = 2;
|
||||
dy = 1;
|
||||
} else if (degrees > 270 && degrees < 360) {
|
||||
dx = -2;
|
||||
dy = 1;
|
||||
}
|
||||
|
||||
surface->drawLine(x, y, x+(int)w, y+(int)h, color);
|
||||
surface->drawLine(x - dx, y - dy, x+(int)w, y+(int)h, color);
|
||||
surface->drawLine(x + dx, y + dy, x+(int)w, y+(int)h, color);
|
||||
|
||||
surface->drawLine(x - dx, y - dy, x+(int)-w, y+(int)-h, color);
|
||||
surface->drawLine(x + dx, y + dy, x+(int)-w, y+(int)-h, color);
|
||||
}
|
||||
|
||||
// Copied from BITMAP::circlefill in engines/ags/lib/allegro/surface.cpp
|
||||
void fillCircle(Graphics::Surface *surface, int x, int y, int radius, int color) {
|
||||
int cx = 0;
|
||||
int cy = radius;
|
||||
int df = 1 - radius;
|
||||
int d_e = 3;
|
||||
int d_se = -2 * radius + 5;
|
||||
|
||||
do {
|
||||
surface->hLine(x - cy, y - cx, x + cy, color);
|
||||
|
||||
if (cx)
|
||||
surface->hLine(x - cy, y + cx, x + cy, color);
|
||||
|
||||
if (df < 0) {
|
||||
df += d_e;
|
||||
d_e += 2;
|
||||
d_se += 2;
|
||||
} else {
|
||||
if (cx != cy) {
|
||||
surface->hLine(x - cx, y - cy, x + cx, color);
|
||||
|
||||
if (cy)
|
||||
surface->hLine(x - cx, y + cy, x + cx, color);
|
||||
}
|
||||
|
||||
df += d_se;
|
||||
d_e += 2;
|
||||
d_se += 4;
|
||||
cy--;
|
||||
}
|
||||
|
||||
cx++;
|
||||
|
||||
} while (cx <= cy);
|
||||
}
|
||||
|
||||
void EclipseEngine::drawEclipseIndicator(Graphics::Surface *surface, int x, int y, uint32 color1, uint32 color2) {
|
||||
uint32 black = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0x00, 0x00);
|
||||
|
||||
// These calls will cover the pixels of the hardcoded eclipse image
|
||||
surface->fillRect(Common::Rect(x, y, x + 50, y + 20), black);
|
||||
|
||||
float progress = 0;
|
||||
if (_countdown >= 0)
|
||||
progress = float(_countdown) / _initialCountdown;
|
||||
|
||||
int difference = 14 * progress;
|
||||
|
||||
fillCircle(surface, x + 7, y + 10, 7, color1); // Sun
|
||||
fillCircle(surface, x + 7 + difference, y + 10, 7, color2); // Moon
|
||||
}
|
||||
|
||||
void EclipseEngine::drawIndicator(Graphics::Surface *surface, int xPosition, int yPosition, int separation) {
|
||||
if (_indicators.size() == 0)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (isSpectrum() || isC64()) {
|
||||
if (_gameStateVars[kVariableEclipseAnkhs] <= i)
|
||||
continue;
|
||||
} else if (_gameStateVars[kVariableEclipseAnkhs] > i)
|
||||
continue;
|
||||
surface->copyRectToSurface(*_indicators[0], xPosition + separation * i, yPosition, Common::Rect(_indicators[0]->w, _indicators[0]->h));
|
||||
}
|
||||
}
|
||||
|
||||
void EclipseEngine::drawSensorShoot(Sensor *sensor) {
|
||||
Math::Vector3d target;
|
||||
float distance = 5;
|
||||
int axisToSkip = -1;
|
||||
|
||||
if (sensor->_axis == 0x1 || sensor->_axis == 0x2)
|
||||
axisToSkip = 0;
|
||||
|
||||
if (sensor->_axis == 0x10 || sensor->_axis == 0x20)
|
||||
axisToSkip = 2;
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
if (i == j) {
|
||||
target = sensor->getOrigin();
|
||||
if (i != axisToSkip)
|
||||
target.setValue(i, target.getValue(i) + distance);
|
||||
|
||||
_gfx->renderSensorShoot(1, sensor->getOrigin(), target, _viewArea);
|
||||
|
||||
target = sensor->getOrigin();
|
||||
|
||||
if (i != axisToSkip)
|
||||
target.setValue(i, target.getValue(i) - distance);
|
||||
|
||||
_gfx->renderSensorShoot(1, sensor->getOrigin(), target, _viewArea);
|
||||
} else {
|
||||
target = sensor->getOrigin();
|
||||
if (i != axisToSkip)
|
||||
target.setValue(i, target.getValue(i) + distance);
|
||||
|
||||
if (j != axisToSkip)
|
||||
target.setValue(j, target.getValue(j) + distance);
|
||||
|
||||
_gfx->renderSensorShoot(1, sensor->getOrigin(), target, _viewArea);
|
||||
|
||||
target = sensor->getOrigin();
|
||||
if (i != axisToSkip)
|
||||
target.setValue(i, target.getValue(i) + distance);
|
||||
|
||||
if (j != axisToSkip)
|
||||
target.setValue(j, target.getValue(j) - distance);
|
||||
|
||||
_gfx->renderSensorShoot(1, sensor->getOrigin(), target, _viewArea);
|
||||
|
||||
target = sensor->getOrigin();
|
||||
|
||||
if (i != axisToSkip)
|
||||
target.setValue(i, target.getValue(i) - distance);
|
||||
|
||||
if (j != axisToSkip)
|
||||
target.setValue(j, target.getValue(j) - distance);
|
||||
|
||||
_gfx->renderSensorShoot(1, sensor->getOrigin(), target, _viewArea);
|
||||
|
||||
target = sensor->getOrigin();
|
||||
if (i != axisToSkip)
|
||||
target.setValue(i, target.getValue(i) - distance);
|
||||
|
||||
if (j != axisToSkip)
|
||||
target.setValue(j, target.getValue(j) + distance);
|
||||
|
||||
_gfx->renderSensorShoot(1, sensor->getOrigin(), target, _viewArea);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EclipseEngine::drawScoreString(int score, int x, int y, uint32 front, uint32 back, Graphics::Surface *surface) {
|
||||
Common::String scoreStr = Common::String::format("%07d", score);
|
||||
|
||||
if (isDOS() || isCPC() || isSpectrum()) {
|
||||
scoreStr = shiftStr(scoreStr, 'Z' - '0' + 1);
|
||||
if (_renderMode == Common::RenderMode::kRenderEGA || isSpectrum()) {
|
||||
drawStringInSurface(scoreStr, x, y, front, back, surface);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Start in x,y and draw each digit, from left to right, adding a gap every 3 digits
|
||||
int gapSize = isC64() ? 8 : 4;
|
||||
|
||||
for (int i = 0; i < int(scoreStr.size()); i++) {
|
||||
drawStringInSurface(Common::String(scoreStr[i]), x, y, front, back, surface);
|
||||
x += 8;
|
||||
if ((i - scoreStr.size() + 1) % 3 == 1)
|
||||
x += gapSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void EclipseEngine::updateTimeVariables() {
|
||||
if (isEclipse2() && _gameStateControl == kFreescapeGameStateStart) {
|
||||
executeLocalGlobalConditions(false, true, false);
|
||||
_gameStateControl = kFreescapeGameStatePlaying;
|
||||
}
|
||||
|
||||
if (_gameStateControl != kFreescapeGameStatePlaying)
|
||||
return;
|
||||
// This function only executes "on collision" room/global conditions
|
||||
int seconds, minutes, hours;
|
||||
getTimeFromCountdown(seconds, minutes, hours);
|
||||
|
||||
|
||||
if (_lastFiveSeconds != seconds / 5) {
|
||||
_lastFiveSeconds = seconds / 5;
|
||||
executeLocalGlobalConditions(false, false, true);
|
||||
}
|
||||
|
||||
if (_lastThirtySeconds != seconds / 30) {
|
||||
_lastThirtySeconds = seconds / 30;
|
||||
|
||||
if (!_resting && _gameStateVars[k8bitVariableEnergy] > 0) {
|
||||
_gameStateVars[k8bitVariableEnergy] -= 1;
|
||||
}
|
||||
|
||||
if (_gameStateVars[k8bitVariableShield] < _maxShield) {
|
||||
_gameStateVars[k8bitVariableShield] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (isEclipse() && isSpectrum() && _currentArea->getAreaID() == 42) {
|
||||
if (_lastSecond != seconds) { // Swap ink and paper colors every second
|
||||
_lastSecond = seconds;
|
||||
int tmp = _gfx->_inkColor;
|
||||
_gfx->_inkColor = _gfx->_paperColor;
|
||||
_gfx->_paperColor = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EclipseEngine::executePrint(FCLInstruction &instruction) {
|
||||
uint16 index = instruction._source - 1;
|
||||
debugC(1, kFreescapeDebugCode, "Printing message %d", index);
|
||||
if (index > 127) {
|
||||
index = _messagesList.size() - (index - 254) - 2;
|
||||
drawFullscreenMessageAndWait(_messagesList[index]);
|
||||
return;
|
||||
}
|
||||
insertTemporaryMessage(_messagesList[index], _countdown - 2);
|
||||
}
|
||||
|
||||
Common::Error EclipseEngine::saveGameStreamExtended(Common::WriteStream *stream, bool isAutosave) {
|
||||
return Common::kNoError;
|
||||
}
|
||||
|
||||
Common::Error EclipseEngine::loadGameStreamExtended(Common::SeekableReadStream *stream) {
|
||||
return Common::kNoError;
|
||||
}
|
||||
|
||||
} // End of namespace Freescape
|
||||
108
engines/freescape/games/eclipse/eclipse.h
Normal file
108
engines/freescape/games/eclipse/eclipse.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/file.h"
|
||||
|
||||
#include "freescape/sound.h"
|
||||
|
||||
namespace Freescape {
|
||||
|
||||
enum EclipseReleaseFlags {
|
||||
GF_ZX_DEMO_CRASH = (1 << 0),
|
||||
GF_ZX_DEMO_MICROHOBBY = (1 << 1),
|
||||
};
|
||||
|
||||
enum {
|
||||
kVariableEclipseAnkhs = 32,
|
||||
};
|
||||
|
||||
class EclipseEngine : public FreescapeEngine {
|
||||
public:
|
||||
EclipseEngine(OSystem *syst, const ADGameDescription *gd);
|
||||
|
||||
void gotoArea(uint16 areaID, int entranceID) override;
|
||||
|
||||
void borderScreen() override;
|
||||
void titleScreen() override;
|
||||
void drawInfoMenu() override;
|
||||
void drawIndicator(Graphics::Surface *surface, int xPosition, int yPosition, int separation);
|
||||
|
||||
void drawSensorShoot(Sensor *sensor) override;
|
||||
|
||||
void loadAssets() override;
|
||||
void loadAssetsDOSFullGame() override;
|
||||
void pressedKey(const int keycode) override;
|
||||
void releasedKey(const int keycode) override;
|
||||
|
||||
uint32 _initialEnergy;
|
||||
uint32 _initialShield;
|
||||
|
||||
int _soundIndexStartFalling;
|
||||
int _soundIndexEndFalling;
|
||||
|
||||
bool _resting;
|
||||
int _lastThirtySeconds;
|
||||
int _lastFiveSeconds;
|
||||
|
||||
int _lastSecond;
|
||||
void updateTimeVariables() override;
|
||||
|
||||
void initDOS();
|
||||
void initCPC();
|
||||
void initZX();
|
||||
void initC64();
|
||||
void initAmigaAtari();
|
||||
|
||||
void loadAssetsZXFullGame() override;
|
||||
void loadAssetsCPCFullGame() override;
|
||||
void loadAssetsC64FullGame() override;
|
||||
void loadAssetsAtariFullGame() override;
|
||||
void loadAssetsCPCDemo() override;
|
||||
void loadAssetsZXDemo() override;
|
||||
|
||||
void initKeymaps(Common::Keymap *engineKeyMap, Common::Keymap *infoScreenKeyMap, const char *target) override;
|
||||
void initGameState() override;
|
||||
void executePrint(FCLInstruction &instruction) override;
|
||||
|
||||
void drawBackground() override;
|
||||
void drawDOSUI(Graphics::Surface *surface) override;
|
||||
void drawCPCUI(Graphics::Surface *surface) override;
|
||||
void drawC64UI(Graphics::Surface *surface) override;
|
||||
void drawZXUI(Graphics::Surface *surface) override;
|
||||
void drawAnalogClock(Graphics::Surface *surface, int x, int y, uint32 colorHand1, uint32 colorHand2, uint32 colorBack);
|
||||
void drawAnalogClockHand(Graphics::Surface *surface, int x, int y, double degrees, double magnitude, uint32 color);
|
||||
void drawCompass(Graphics::Surface *surface, int x, int y, double degrees, double magnitude, uint32 color);
|
||||
void drawEclipseIndicator(Graphics::Surface *surface, int x, int y, uint32 color1, uint32 color2);
|
||||
Common::String getScoreString(int score);
|
||||
void drawScoreString(int score, int x, int y, uint32 front, uint32 back, Graphics::Surface *surface);
|
||||
|
||||
soundFx *load1bPCM(Common::SeekableReadStream *file, int offset);
|
||||
|
||||
bool checkIfGameEnded() override;
|
||||
void endGame() override;
|
||||
void loadSoundsFx(Common::SeekableReadStream *file, int offset, int number) override;
|
||||
void playSoundFx(int index, bool sync) override;
|
||||
|
||||
Common::Error saveGameStreamExtended(Common::WriteStream *stream, bool isAutosave = false) override;
|
||||
Common::Error loadGameStreamExtended(Common::SeekableReadStream *stream) override;
|
||||
};
|
||||
|
||||
}
|
||||
220
engines/freescape/games/eclipse/zx.cpp
Normal file
220
engines/freescape/games/eclipse/zx.cpp
Normal file
@@ -0,0 +1,220 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/file.h"
|
||||
|
||||
#include "freescape/freescape.h"
|
||||
#include "freescape/games/eclipse/eclipse.h"
|
||||
#include "freescape/language/8bitDetokeniser.h"
|
||||
|
||||
namespace Freescape {
|
||||
|
||||
void EclipseEngine::initZX() {
|
||||
_viewArea = Common::Rect(56, 36, 265, 139);
|
||||
_maxEnergy = 25;
|
||||
_maxShield = 50;
|
||||
|
||||
_soundIndexShoot = 5;
|
||||
_soundIndexCollide = -1; // Scripted
|
||||
_soundIndexStepDown = 12;
|
||||
_soundIndexStepUp = 12;
|
||||
_soundIndexMenu = -1;
|
||||
_soundIndexStart = 7;
|
||||
_soundIndexAreaChange = 7;
|
||||
|
||||
_soundIndexStartFalling = 6;
|
||||
_soundIndexEndFalling = 5;
|
||||
|
||||
_soundIndexNoShield = 8;
|
||||
_soundIndexNoEnergy = -1;
|
||||
_soundIndexFallen = 8;
|
||||
_soundIndexTimeout = 8;
|
||||
_soundIndexForceEndGame = 8;
|
||||
_soundIndexCrushed = 8;
|
||||
_soundIndexMissionComplete = 16;
|
||||
}
|
||||
|
||||
void EclipseEngine::loadAssetsZXFullGame() {
|
||||
Common::File file;
|
||||
|
||||
file.open("totaleclipse.zx.title");
|
||||
if (file.isOpen()) {
|
||||
_title = loadAndConvertScrImage(&file);
|
||||
} else
|
||||
error("Unable to find totaleclipse.zx.title");
|
||||
|
||||
file.close();
|
||||
file.open("totaleclipse.zx.border");
|
||||
if (file.isOpen()) {
|
||||
_border = loadAndConvertScrImage(&file);
|
||||
} else
|
||||
error("Unable to find totaleclipse.zx.border");
|
||||
file.close();
|
||||
|
||||
file.open("totaleclipse.zx.data");
|
||||
if (!file.isOpen())
|
||||
error("Failed to open totaleclipse.zx.data");
|
||||
|
||||
if (isEclipse2()) {
|
||||
loadMessagesFixedSize(&file, 0x2ac, 16, 30);
|
||||
loadFonts(&file, 0x61c3);
|
||||
loadSpeakerFxZX(&file, 0x8c6, 0x91a);
|
||||
load8bitBinary(&file, 0x63bb, 4);
|
||||
} else {
|
||||
loadMessagesFixedSize(&file, 0x2ac, 16, 23);
|
||||
loadFonts(&file, 0x6163);
|
||||
loadSpeakerFxZX(&file, 0x816, 0x86a);
|
||||
load8bitBinary(&file, 0x635b, 4);
|
||||
|
||||
// These paper colors are also invalid, but to signal the use of a special effect (only in zx release)
|
||||
_areaMap[42]->_paperColor = 0;
|
||||
_areaMap[42]->_underFireBackgroundColor = 0;
|
||||
}
|
||||
|
||||
_indicators.push_back(loadBundledImage("eclipse_ankh_indicator"));
|
||||
|
||||
for (auto &it : _indicators)
|
||||
it->convertToInPlace(_gfx->_texturePixelFormat);
|
||||
}
|
||||
|
||||
void EclipseEngine::loadAssetsZXDemo() {
|
||||
Common::File file;
|
||||
|
||||
file.open("totaleclipse.zx.title");
|
||||
if (file.isOpen()) {
|
||||
_title = loadAndConvertScrImage(&file);
|
||||
} else
|
||||
error("Unable to find totaleclipse.zx.title");
|
||||
|
||||
file.close();
|
||||
file.open("totaleclipse.zx.border");
|
||||
if (file.isOpen()) {
|
||||
_border = loadAndConvertScrImage(&file);
|
||||
} else
|
||||
error("Unable to find totaleclipse.zx.border");
|
||||
file.close();
|
||||
|
||||
file.open("totaleclipse.zx.data");
|
||||
if (!file.isOpen())
|
||||
error("Failed to open totaleclipse.zx.data");
|
||||
|
||||
if (_variant & GF_ZX_DEMO_MICROHOBBY) {
|
||||
loadSpeakerFxZX(&file, 0x798, 0x7ec);
|
||||
loadMessagesFixedSize(&file, 0x2ac, 16, 23);
|
||||
loadMessagesFixedSize(&file, 0x56e6, 264, 1);
|
||||
loadFonts(&file, 0x5f7b);
|
||||
load8bitBinary(&file, 0x6173, 4);
|
||||
} else if (_variant & GF_ZX_DEMO_CRASH) {
|
||||
loadSpeakerFxZX(&file, 0x65c, 0x6b0);
|
||||
loadMessagesFixedSize(&file, 0x364, 16, 9);
|
||||
loadMessagesFixedSize(&file, 0x5901, 264, 5);
|
||||
loadFonts(&file, 0x6589);
|
||||
load8bitBinary(&file, 0x6781, 4);
|
||||
} else
|
||||
error("Unknown ZX Spectrum demo variant");
|
||||
|
||||
_indicators.push_back(loadBundledImage("eclipse_ankh_indicator"));
|
||||
|
||||
for (auto &it : _indicators)
|
||||
it->convertToInPlace(_gfx->_texturePixelFormat);
|
||||
}
|
||||
|
||||
void EclipseEngine::drawZXUI(Graphics::Surface *surface) {
|
||||
uint32 color = _currentArea->_underFireBackgroundColor;
|
||||
uint8 r, g, b;
|
||||
|
||||
_gfx->readFromPalette(color, r, g, b);
|
||||
uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
color = _currentArea->_usualBackgroundColor;
|
||||
if (_gfx->_colorRemaps && _gfx->_colorRemaps->contains(color)) {
|
||||
color = (*_gfx->_colorRemaps)[color];
|
||||
}
|
||||
|
||||
_gfx->readFromPalette(color, r, g, b);
|
||||
uint32 back = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
_gfx->readFromPalette(7, r, g, b);
|
||||
uint32 gray = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
_gfx->readFromPalette(5, r, g, b);
|
||||
uint32 blue = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
_gfx->readFromPalette(2, r, g, b);
|
||||
uint32 red = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
|
||||
|
||||
|
||||
int score = _gameStateVars[k8bitVariableScore];
|
||||
int shield = _gameStateVars[k8bitVariableShield] * 100 / _maxShield;
|
||||
int energy = _gameStateVars[k8bitVariableEnergy];
|
||||
shield = shield < 0 ? 0 : shield;
|
||||
|
||||
uint32 yellow = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0xFF, 0xFF, 0);
|
||||
|
||||
Common::String message;
|
||||
int deadline;
|
||||
getLatestMessages(message, deadline);
|
||||
if (deadline <= _countdown) {
|
||||
drawStringInSurface(message, 102, 141, back, yellow, surface);
|
||||
_temporaryMessages.push_back(message);
|
||||
_temporaryMessageDeadlines.push_back(deadline);
|
||||
} else if (!_currentAreaMessages.empty())
|
||||
drawStringInSurface(_currentArea->_name, 102, 141, back, yellow, surface);
|
||||
|
||||
drawScoreString(score, 135, 11, back, gray, surface);
|
||||
|
||||
Common::String shieldStr = Common::String::format("%d", shield);
|
||||
|
||||
int x = 171;
|
||||
if (shield < 10)
|
||||
x = 179;
|
||||
else if (shield < 100)
|
||||
x = 175;
|
||||
|
||||
if (energy < 0)
|
||||
energy = 0;
|
||||
|
||||
drawStringInSurface(shieldStr, x, 161, back, red, surface);
|
||||
|
||||
Common::Rect jarBackground(120, 162, 144, 192 - 4);
|
||||
surface->fillRect(jarBackground, back);
|
||||
|
||||
Common::Rect jarWater(120, 192 - energy - 4, 144, 192 - 4);
|
||||
surface->fillRect(jarWater, blue);
|
||||
|
||||
drawStringInSurface(shiftStr("0", 'Z' - '$' + 1 - _angleRotationIndex), 79, 141, back, yellow, surface);
|
||||
drawStringInSurface(shiftStr("3", 'Z' - '$' + 1 - _playerStepIndex), 63, 141, back, yellow, surface);
|
||||
drawStringInSurface(shiftStr("7", 'Z' - '$' + 1 - _playerHeightNumber), 240, 141, back, yellow, surface);
|
||||
|
||||
if (_shootingFrames > 0) {
|
||||
drawStringInSurface(shiftStr("4", 'Z' - '$' + 1), 232, 141, back, yellow, surface);
|
||||
drawStringInSurface(shiftStr("<", 'Z' - '$' + 1) , 240, 141, back, yellow, surface);
|
||||
}
|
||||
drawAnalogClock(surface, 89, 172, back, back, gray);
|
||||
|
||||
surface->fillRect(Common::Rect(227, 168, 235, 187), gray);
|
||||
drawCompass(surface, 231, 177, _yaw, 10, back);
|
||||
|
||||
drawIndicator(surface, 65, 7, 8);
|
||||
drawEclipseIndicator(surface, 215, 3, front, gray);
|
||||
}
|
||||
|
||||
} // End of namespace Freescape
|
||||
Reference in New Issue
Block a user