2020-10-14 15:16:30 +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 "twine/holomap.h"
|
2020-12-22 17:16:27 +01:00
|
|
|
#include "common/debug.h"
|
2020-11-02 23:23:41 +01:00
|
|
|
#include "common/memstream.h"
|
2020-11-03 18:34:55 +01:00
|
|
|
#include "common/types.h"
|
2020-12-21 12:31:32 +01:00
|
|
|
#include "twine/audio/sound.h"
|
|
|
|
#include "twine/scene/gamestate.h"
|
2020-12-21 19:37:07 +01:00
|
|
|
#include "twine/resources/hqr.h"
|
2020-12-21 12:31:32 +01:00
|
|
|
#include "twine/menu/interface.h"
|
2020-12-22 17:05:39 +01:00
|
|
|
#include "twine/renderer/redraw.h"
|
2020-12-21 12:31:32 +01:00
|
|
|
#include "twine/renderer/renderer.h"
|
|
|
|
#include "twine/renderer/screens.h"
|
2020-12-21 19:37:07 +01:00
|
|
|
#include "twine/resources/resources.h"
|
2020-12-21 12:31:32 +01:00
|
|
|
#include "twine/scene/scene.h"
|
2020-10-21 11:41:37 +02:00
|
|
|
#include "twine/text.h"
|
2020-10-14 15:16:30 +02:00
|
|
|
#include "twine/twine.h"
|
|
|
|
|
|
|
|
namespace TwinE {
|
|
|
|
|
|
|
|
Holomap::Holomap(TwinEEngine *engine) : _engine(engine) {}
|
|
|
|
|
2020-11-02 23:23:41 +01:00
|
|
|
bool Holomap::loadLocations() {
|
2021-01-10 22:08:52 +01:00
|
|
|
uint8 *locationsPtr = nullptr;
|
2020-11-02 23:23:41 +01:00
|
|
|
const int32 locationsSize = HQR::getAllocEntry(&locationsPtr, Resources::HQR_RESS_FILE, RESSHQR_HOLOARROWINFO);
|
|
|
|
if (locationsSize == 0) {
|
|
|
|
warning("Could not find holomap locations at index %i in %s", RESSHQR_HOLOARROWINFO, Resources::HQR_RESS_FILE);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-11-03 18:34:55 +01:00
|
|
|
Common::MemoryReadStream stream(locationsPtr, locationsSize, DisposeAfterUse::YES);
|
2020-11-02 23:23:41 +01:00
|
|
|
_numLocations = locationsSize / sizeof(Location);
|
|
|
|
if (_numLocations > NUM_LOCATIONS) {
|
|
|
|
warning("Amount of locations (%i) exceeds the maximum of %i", _numLocations, NUM_LOCATIONS);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < _numLocations; i++) {
|
|
|
|
_locations[i].x = stream.readUint16LE();
|
|
|
|
_locations[i].y = stream.readUint16LE();
|
|
|
|
_locations[i].z = stream.readUint16LE();
|
|
|
|
_locations[i].textIndex = stream.readUint16LE();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-10-21 11:41:37 +02:00
|
|
|
void Holomap::setHolomapPosition(int32 locationIdx) {
|
|
|
|
assert(locationIdx >= 0 && locationIdx <= ARRAYSIZE(_engine->_gameState->holomapFlags));
|
|
|
|
_engine->_gameState->holomapFlags[locationIdx] = 0x81;
|
2020-12-22 17:05:39 +01:00
|
|
|
if (_engine->_gameState->hasItem(InventoryItems::kiHolomap)) {
|
|
|
|
_engine->_redraw->addOverlay(OverlayType::koInventoryItem, InventoryItems::kiHolomap, 0, 0, 0, OverlayPosType::koNormal, 3);
|
|
|
|
}
|
2020-10-14 14:20:38 +02:00
|
|
|
}
|
|
|
|
|
2020-10-21 11:41:37 +02:00
|
|
|
void Holomap::clearHolomapPosition(int32 locationIdx) {
|
|
|
|
assert(locationIdx >= 0 && locationIdx <= ARRAYSIZE(_engine->_gameState->holomapFlags));
|
|
|
|
_engine->_gameState->holomapFlags[locationIdx] &= 0x7E;
|
|
|
|
_engine->_gameState->holomapFlags[locationIdx] |= 0x40;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Holomap::loadGfxSub1() {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
void Holomap::loadGfxSub2() {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
void Holomap::loadHolomapGFX() {
|
2020-11-17 21:39:46 +01:00
|
|
|
uint8 *videoPtr3 = (uint8 *)_engine->workVideoBuffer.getBasePtr(174, 12);
|
|
|
|
uint8 *videoPtr4 = (uint8 *)_engine->workVideoBuffer.getBasePtr(78, 13);
|
|
|
|
uint8 *videoPtr5 = (uint8 *)_engine->workVideoBuffer.getBasePtr(334, 115);
|
2020-10-21 11:41:37 +02:00
|
|
|
|
2020-10-30 20:09:28 +01:00
|
|
|
HQR::getEntry(videoPtr3, Resources::HQR_RESS_FILE, RESSHQR_HOLOSURFACE);
|
|
|
|
HQR::getEntry(videoPtr4, Resources::HQR_RESS_FILE, RESSHQR_HOLOIMG);
|
2020-10-21 11:41:37 +02:00
|
|
|
|
2020-10-30 20:09:28 +01:00
|
|
|
uint8 *videoPtr6 = videoPtr5 + HQR::getEntry(videoPtr5, Resources::HQR_RESS_FILE, RESSHQR_HOLOTWINMDL);
|
|
|
|
uint8 *videoPtr7 = videoPtr6 + HQR::getEntry(videoPtr6, Resources::HQR_RESS_FILE, RESSHQR_HOLOARROWMDL);
|
|
|
|
uint8 *videoPtr8 = videoPtr7 + HQR::getEntry(videoPtr7, Resources::HQR_RESS_FILE, RESSHQR_HOLOTWINARROWMDL);
|
2020-10-21 11:41:37 +02:00
|
|
|
|
2020-12-09 22:52:17 +01:00
|
|
|
Renderer::prepareIsoModel(videoPtr5);
|
|
|
|
Renderer::prepareIsoModel(videoPtr6);
|
|
|
|
Renderer::prepareIsoModel(videoPtr7);
|
|
|
|
Renderer::prepareIsoModel(videoPtr8);
|
2020-10-21 11:41:37 +02:00
|
|
|
|
2020-10-23 10:52:33 +02:00
|
|
|
// TODO:
|
2020-11-17 21:39:46 +01:00
|
|
|
// uint8 *videoPtr1 = (uint8 *)_engine->workVideoBuffer.getPixels();
|
2020-10-23 10:52:33 +02:00
|
|
|
// uint8 *videoPtr2 = videoPtr1 + 4488;
|
2020-10-30 20:09:28 +01:00
|
|
|
// uint8 *videoPtr11 = videoPtr8 + HQR::getEntry(videoPtr8, Resources::HQR_RESS_FILE, RESSHQR_HOLOPOINTMDL);
|
2020-10-23 10:52:33 +02:00
|
|
|
// uint8 *videoPtr10 = videoPtr11 + 4488;
|
2020-10-30 20:09:28 +01:00
|
|
|
// uint8 *videoPtr12 = videoPtr10 + HQR::getEntry(videoPtr10, Resources::HQR_RESS_FILE, RESSHQR_HOLOARROWINFO);
|
|
|
|
// uint8 *videoPtr13 = videoPtr12 + HQR::getEntry(videoPtr12, Resources::HQR_RESS_FILE, RESSHQR_HOLOPOINTANIM);
|
2020-10-21 11:41:37 +02:00
|
|
|
|
|
|
|
_engine->_screens->loadCustomPalette(RESSHQR_HOLOPAL);
|
|
|
|
|
|
|
|
int32 j = 576;
|
|
|
|
for (int32 i = 0; i < 96; i += 3, j += 3) {
|
2020-10-23 10:52:33 +02:00
|
|
|
paletteHolomap[i + 0] = _engine->_screens->palette[j + 0];
|
2020-10-21 11:41:37 +02:00
|
|
|
paletteHolomap[i + 1] = _engine->_screens->palette[j + 1];
|
|
|
|
paletteHolomap[i + 2] = _engine->_screens->palette[j + 2];
|
|
|
|
}
|
|
|
|
|
|
|
|
j = 576;
|
|
|
|
for (int32 i = 96; i < 189; i += 3, j += 3) {
|
2020-10-23 10:52:33 +02:00
|
|
|
paletteHolomap[i + 0] = _engine->_screens->palette[j + 0];
|
2020-10-21 11:41:37 +02:00
|
|
|
paletteHolomap[i + 1] = _engine->_screens->palette[j + 1];
|
|
|
|
paletteHolomap[i + 2] = _engine->_screens->palette[j + 2];
|
|
|
|
}
|
|
|
|
|
|
|
|
loadGfxSub1();
|
|
|
|
loadGfxSub2();
|
|
|
|
|
|
|
|
needToLoadHolomapGFX = 0;
|
|
|
|
}
|
|
|
|
|
2020-12-22 17:16:27 +01:00
|
|
|
void Holomap::drawHolomapText(int32 centerx, int32 top, const char *title) {
|
|
|
|
const int32 size = _engine->_text->getTextSize(title);
|
|
|
|
const int32 x = centerx - size / 2;
|
|
|
|
const int32 y = top;
|
2021-01-10 22:08:52 +01:00
|
|
|
_engine->_text->setFontColor(COLOR_WHITE);
|
|
|
|
// TODO: handle @ newline
|
|
|
|
// TODO: faded in?
|
2020-12-22 17:16:27 +01:00
|
|
|
_engine->_text->drawText(x, y, title);
|
2020-10-21 11:41:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
|
2020-11-22 12:18:04 +01:00
|
|
|
debug("Draw trajectory index %i", trajectoryIndex);
|
2020-10-21 11:41:37 +02:00
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2021-01-10 22:08:52 +01:00
|
|
|
void Holomap::drawHolomapLocation(int32 location) {
|
2020-12-22 17:16:27 +01:00
|
|
|
char title[256] = "";
|
2021-01-10 22:08:52 +01:00
|
|
|
_engine->_text->getMenuText(_locations[location].textIndex, title, sizeof(title));
|
2020-12-22 17:16:27 +01:00
|
|
|
const int padding = 17;
|
|
|
|
Common::Rect rect;
|
|
|
|
rect.left = padding - 1;
|
2021-01-07 21:17:53 +01:00
|
|
|
rect.top = _engine->height() - 146;
|
|
|
|
rect.right = _engine->width() - padding;
|
|
|
|
rect.bottom = _engine->height() - padding;
|
2021-01-10 22:08:52 +01:00
|
|
|
_engine->_interface->blitBox(rect, _engine->workVideoBuffer, _engine->frontVideoBuffer);
|
2020-12-22 17:16:27 +01:00
|
|
|
_engine->_menu->drawBox(rect);
|
|
|
|
rect.grow(-1);
|
|
|
|
_engine->_interface->drawTransparentBox(rect, 3);
|
2021-01-10 22:08:52 +01:00
|
|
|
_engine->_interface->blitBox(rect, _engine->frontVideoBuffer, _engine->workVideoBuffer);
|
2020-12-31 00:13:49 +01:00
|
|
|
const int32 height = _engine->_text->getCharHeight(title[0]);
|
2020-12-22 17:16:27 +01:00
|
|
|
drawHolomapText(rect.left + (rect.right - rect.left) / 2, rect.top + (rect.bottom - rect.top) / 2 - height / 2, title);
|
2021-01-10 22:08:52 +01:00
|
|
|
rect.grow(1);
|
|
|
|
_engine->copyBlockPhys(rect);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32 Holomap::getNextHolomapLocation(int32 currentLocation, int dir) const {
|
|
|
|
const uint32 idx = currentLocation;
|
|
|
|
for (uint32 i = currentLocation + dir; i != idx; i = (i + dir) % NUM_LOCATIONS) {
|
|
|
|
if (_engine->_gameState->holomapFlags[i % NUM_LOCATIONS] & 0x81) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
2020-12-22 17:16:27 +01:00
|
|
|
}
|
|
|
|
|
2020-10-21 11:41:37 +02:00
|
|
|
void Holomap::processHolomap() {
|
2020-11-02 23:09:27 +01:00
|
|
|
ScopedEngineFreeze freeze(_engine);
|
2020-10-21 11:41:37 +02:00
|
|
|
|
2020-10-23 10:52:33 +02:00
|
|
|
const int32 alphaLightTmp = _engine->_scene->alphaLight;
|
|
|
|
const int32 betaLightTmp = _engine->_scene->betaLight;
|
2020-10-21 11:41:37 +02:00
|
|
|
|
2020-10-21 19:53:01 +02:00
|
|
|
_engine->_screens->fadeToBlack(_engine->_screens->paletteRGBA);
|
2020-10-21 11:41:37 +02:00
|
|
|
_engine->_sound->stopSamples();
|
2020-12-22 17:16:27 +01:00
|
|
|
_engine->_interface->saveClip();
|
2020-10-21 11:41:37 +02:00
|
|
|
_engine->_interface->resetClip();
|
|
|
|
_engine->_screens->clearScreen();
|
2020-12-22 17:16:27 +01:00
|
|
|
_engine->setPalette(_engine->_screens->paletteRGBA);
|
2020-10-21 11:41:37 +02:00
|
|
|
|
|
|
|
loadHolomapGFX();
|
2021-01-07 21:17:53 +01:00
|
|
|
_engine->_renderer->setCameraPosition(_engine->width() / 2, 190, 128, 1024, 1024);
|
2020-10-21 11:41:37 +02:00
|
|
|
|
2020-11-01 22:35:29 +01:00
|
|
|
_engine->_text->initTextBank(TextBankId::Inventory_Intro_and_Holomap);
|
2020-10-21 11:41:37 +02:00
|
|
|
_engine->_text->setFontCrossColor(9);
|
|
|
|
|
2021-01-10 22:08:52 +01:00
|
|
|
drawHolomapText(_engine->width() / 2, 25, "HoloMap"); // TODO: fix the index
|
|
|
|
int currentLocation = _engine->_scene->currentSceneIdx;
|
|
|
|
drawHolomapLocation(currentLocation);
|
2020-12-22 17:16:27 +01:00
|
|
|
_engine->flip();
|
|
|
|
|
2021-01-10 22:08:52 +01:00
|
|
|
// TODO: load RESSHQR_HOLOSURFACE and project the texture to the surface
|
|
|
|
//_engine->_screens->loadImage(RESSHQR_HOLOIMG, RESSHQR_HOLOPAL);
|
|
|
|
|
2020-12-22 14:44:56 +01:00
|
|
|
ScopedKeyMap holomapKeymap(_engine, holomapKeyMapId);
|
|
|
|
for (;;) {
|
2021-01-09 18:39:42 +01:00
|
|
|
FrameMarker frame;
|
2020-12-22 14:44:56 +01:00
|
|
|
ScopedFPS scopedFps;
|
|
|
|
_engine->_input->readKeys();
|
|
|
|
if (_engine->shouldQuit() || _engine->_input->toggleAbortAction()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_engine->_input->toggleActionIfActive(TwinEActionType::HolomapLeft)) {
|
2021-01-10 22:08:52 +01:00
|
|
|
const int32 nextLocation = getNextHolomapLocation(currentLocation, -1);
|
|
|
|
if (nextLocation != -1) {
|
|
|
|
currentLocation = nextLocation;
|
|
|
|
drawHolomapLocation(currentLocation);
|
|
|
|
}
|
2020-12-22 14:44:56 +01:00
|
|
|
} else if (_engine->_input->toggleActionIfActive(TwinEActionType::HolomapRight)) {
|
2021-01-10 22:08:52 +01:00
|
|
|
const int32 nextLocation = getNextHolomapLocation(currentLocation, 1);
|
|
|
|
if (nextLocation != -1) {
|
|
|
|
currentLocation = nextLocation;
|
|
|
|
drawHolomapLocation(currentLocation);
|
|
|
|
}
|
2020-12-22 14:44:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_engine->_input->toggleActionIfActive(TwinEActionType::HolomapUp)) {
|
|
|
|
} else if (_engine->_input->toggleActionIfActive(TwinEActionType::HolomapDown)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
|
|
|
//_engine->_screens->copyScreen(_engine->workVideoBuffer, _engine->frontVideoBuffer);
|
|
|
|
//_engine->flip();
|
|
|
|
}
|
2020-10-21 11:41:37 +02:00
|
|
|
|
2020-11-22 12:36:35 +01:00
|
|
|
_engine->_text->drawTextBoxBackground = true;
|
2020-10-21 19:53:01 +02:00
|
|
|
_engine->_screens->fadeToBlack(_engine->_screens->paletteRGBA);
|
2020-10-21 11:41:37 +02:00
|
|
|
_engine->_scene->alphaLight = alphaLightTmp;
|
|
|
|
_engine->_scene->betaLight = betaLightTmp;
|
2020-12-22 15:04:15 +01:00
|
|
|
|
|
|
|
_engine->_gameState->initEngineProjections();
|
2020-12-22 17:16:27 +01:00
|
|
|
_engine->_interface->loadClip();
|
2020-10-21 11:41:37 +02:00
|
|
|
|
2020-12-23 15:28:00 +01:00
|
|
|
_engine->_text->initSceneTextBank();
|
2020-10-14 14:20:38 +02:00
|
|
|
}
|
2020-10-14 15:16:30 +02:00
|
|
|
|
|
|
|
} // namespace TwinE
|