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"
|
2021-01-17 00:03:41 +01:00
|
|
|
#include "common/stream.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/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"
|
2021-01-11 20:21:49 +01:00
|
|
|
#include "twine/resources/hqr.h"
|
2020-12-21 19:37:07 +01:00
|
|
|
#include "twine/resources/resources.h"
|
2021-01-17 00:03:41 +01:00
|
|
|
#include "twine/scene/animations.h"
|
2021-01-11 21:32:35 +01:00
|
|
|
#include "twine/scene/collision.h"
|
2021-01-11 20:21:49 +01:00
|
|
|
#include "twine/scene/gamestate.h"
|
2021-01-17 00:03:41 +01:00
|
|
|
#include "twine/scene/movements.h"
|
2020-12-21 12:31:32 +01:00
|
|
|
#include "twine/scene/scene.h"
|
2021-01-17 00:03:41 +01:00
|
|
|
#include "twine/shared.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::loadHolomapGFX() {
|
|
|
|
_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];
|
|
|
|
}
|
|
|
|
|
|
|
|
needToLoadHolomapGFX = 0;
|
|
|
|
}
|
|
|
|
|
2021-01-24 15:16:37 +01:00
|
|
|
static int sortHolomapSurfaceCoordsByDepth(const void *a1, const void *a2) {
|
|
|
|
return *(const int16 *)a1 - *(const int16 *)a2;
|
|
|
|
}
|
|
|
|
|
2021-01-17 00:03:41 +01:00
|
|
|
void Holomap::prepareHolomapSurface() {
|
|
|
|
Common::MemoryReadStream stream(_engine->_resources->holomapSurfacePtr, _engine->_resources->holomapSurfaceSize);
|
2021-01-24 15:16:37 +01:00
|
|
|
int holomapSurfaceArrayIdx = 0;
|
|
|
|
int projectedIndex = 0;
|
2021-01-17 00:03:41 +01:00
|
|
|
for (int32 angle = -ANGLE_90; angle <= ANGLE_90; angle += ANGLE_11_25) {
|
2021-01-24 15:16:37 +01:00
|
|
|
int rotation = 0;
|
|
|
|
for (int32 stepWidth = ANGLE_11_25; stepWidth != 0; --stepWidth) {
|
2021-01-17 00:03:41 +01:00
|
|
|
const int32 destX = stream.readSint16LE();
|
|
|
|
const int32 destY = stream.readSint16LE();
|
|
|
|
const int32 destZ = stream.readSint16LE();
|
|
|
|
_engine->_renderer->getBaseRotationPosition(destX, destY, destZ);
|
2021-01-24 15:16:37 +01:00
|
|
|
if (angle != ANGLE_90) {
|
|
|
|
_holomapSurface[holomapSurfaceArrayIdx].z = destZ;
|
|
|
|
_holomapSurface[holomapSurfaceArrayIdx].projectedPosIdx = projectedIndex;
|
|
|
|
++holomapSurfaceArrayIdx;
|
2021-01-17 00:03:41 +01:00
|
|
|
}
|
|
|
|
_engine->_renderer->projectPositionOnScreen(destX, destY, destZ);
|
2021-01-24 15:16:37 +01:00
|
|
|
_projectedSurfacePositions[projectedIndex].x = _engine->_renderer->projPosX;
|
|
|
|
_projectedSurfacePositions[projectedIndex].y = _engine->_renderer->projPosY;
|
2021-01-24 15:31:54 +01:00
|
|
|
_projectedSurfacePositions[projectedIndex].unk1 = _engine->_screens->crossDot(0, 0xffff, ANGLE_360 - 1, rotation);
|
2021-01-24 15:16:37 +01:00
|
|
|
if (angle == ANGLE_90) {
|
|
|
|
_projectedSurfacePositions[projectedIndex].unk2 = 0xffff;
|
|
|
|
} else {
|
2021-01-24 15:31:54 +01:00
|
|
|
_projectedSurfacePositions[projectedIndex].unk2 = (int16)(((angle + ANGLE_90) * ANGLE_90) / 2);
|
2021-01-24 15:16:37 +01:00
|
|
|
}
|
|
|
|
rotation = rotation + ANGLE_11_25;
|
|
|
|
++projectedIndex;
|
2021-01-17 00:03:41 +01:00
|
|
|
}
|
|
|
|
const int32 destX = stream.readSint16LE();
|
|
|
|
const int32 destY = stream.readSint16LE();
|
|
|
|
const int32 destZ = stream.readSint16LE();
|
|
|
|
_engine->_renderer->getBaseRotationPosition(destX, destY, destZ);
|
|
|
|
_engine->_renderer->projectPositionOnScreen(destX, destY, destZ);
|
2021-01-24 15:16:37 +01:00
|
|
|
_projectedSurfacePositions[projectedIndex].x = _engine->_renderer->projPosX;
|
|
|
|
_projectedSurfacePositions[projectedIndex].y = _engine->_renderer->projPosY;
|
|
|
|
_projectedSurfacePositions[projectedIndex].unk1 = 0xffff;
|
|
|
|
if (angle == ANGLE_90) {
|
|
|
|
_projectedSurfacePositions[projectedIndex].unk2 = 0xffff;
|
|
|
|
} else {
|
2021-01-24 15:31:54 +01:00
|
|
|
_projectedSurfacePositions[projectedIndex].unk2 = (int16)(((angle + ANGLE_90) * ANGLE_90) / 2);
|
2021-01-24 15:16:37 +01:00
|
|
|
}
|
|
|
|
++projectedIndex;
|
2021-01-17 00:03:41 +01:00
|
|
|
}
|
2021-01-24 15:16:37 +01:00
|
|
|
qsort(_holomapSurface, ARRAYSIZE(_holomapSurface), sizeof(HolomapSurface), sortHolomapSurfaceCoordsByDepth);
|
2021-01-17 00:03:41 +01:00
|
|
|
}
|
|
|
|
|
2021-01-24 15:16:37 +01:00
|
|
|
void Holomap::renderHolomapSurfacePolygons() {
|
|
|
|
prepareHolomapSurface();
|
|
|
|
for (int32 i = 0; i < ARRAYSIZE(_holomapSurface); ++i) {
|
|
|
|
// const HolomapProjectedPos &pos1 = _projectedSurfacePositions[_holomapSurface[i].projectedPosIdx + 0];
|
|
|
|
// const HolomapProjectedPos &pos2 = _projectedSurfacePositions[_holomapSurface[i].projectedPosIdx + 1];
|
|
|
|
// const HolomapProjectedPos &pos3 = _projectedSurfacePositions[_holomapSurface[i].projectedPosIdx + 2];
|
|
|
|
// const HolomapProjectedPos &pos4 = _projectedSurfacePositions[_holomapSurface[i].projectedPosIdx + 3];
|
|
|
|
// TODO: build triangles from projected pos with texcoords from holomapimg
|
|
|
|
# if 0
|
|
|
|
v2 = _projectedSurfacePositions + 2 * *(_WORD *)(i + _holomapSurface + 2);
|
|
|
|
backDialogueBoxRight = *(_WORD *)v2;
|
|
|
|
backDialogueBoxBottom = *(_WORD *)(v2 + 2);
|
|
|
|
back2DialogueBoxRight = *(_WORD *)(v2 + 264);
|
|
|
|
back2DialogueBoxBottom = *(_WORD *)(v2 + 266);
|
|
|
|
back3DialogueBoxRight = *(_WORD *)(v2 + 8);
|
|
|
|
back3DialogueBoxBottom = *(_WORD *)(v2 + 10);
|
|
|
|
if (sub_26DAB(v0)) {
|
|
|
|
word_4B776 = *(_WORD *)(v2 + 4);
|
|
|
|
word_4B778 = *(_WORD *)(v2 + 6);
|
|
|
|
word_4B77C = *(_WORD *)(v2 + 268);
|
|
|
|
word_4B77E = *(_WORD *)(v2 + 270);
|
|
|
|
word_4B782 = *(_WORD *)(v2 + 12);
|
|
|
|
word_4B784 = *(_WORD *)(v2 + 14);
|
|
|
|
sub_2E894(); // handles polyTab, polyTab2, circleBuffer, maybe model rendering?
|
|
|
|
sub_2F1D1(v0); // some kind of blitting?
|
|
|
|
}
|
|
|
|
backDialogueBoxRight = *(_WORD *)(v2 + 264);
|
|
|
|
backDialogueBoxBottom = *(_WORD *)(v2 + 266);
|
|
|
|
back2DialogueBoxRight = *(_WORD *)(v2 + 272);
|
|
|
|
back2DialogueBoxBottom = *(_WORD *)(v2 + 274);
|
|
|
|
back3DialogueBoxRight = *(_WORD *)(v2 + 8);
|
|
|
|
back3DialogueBoxBottom = *(_WORD *)(v2 + 10);
|
|
|
|
v3 = sub_26DAB(v0);
|
|
|
|
if (v3) {
|
|
|
|
word_4B776 = *(_WORD *)(v2 + 268);
|
|
|
|
word_4B778 = *(_WORD *)(v2 + 270);
|
|
|
|
word_4B77C = *(_WORD *)(v2 + 276);
|
|
|
|
word_4B77E = *(_WORD *)(v2 + 278);
|
|
|
|
word_4B782 = *(_WORD *)(v2 + 12);
|
|
|
|
word_4B784 = *(_WORD *)(v2 + 14);
|
|
|
|
sub_2E894();
|
|
|
|
LOBYTE(v3) = sub_2F1D1(v0); // some kind of blitting?
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2021-01-24 09:54:13 +01:00
|
|
|
}
|
|
|
|
|
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
|
2021-01-11 21:32:35 +01:00
|
|
|
// TODO: faded in? - looks like it - printText10 was used
|
2020-12-22 17:16:27 +01:00
|
|
|
_engine->_text->drawText(x, y, title);
|
2020-10-21 11:41:37 +02:00
|
|
|
}
|
|
|
|
|
2021-01-24 09:54:13 +01:00
|
|
|
void Holomap::renderHolomapModel(byte *mdl_1, int32 x_2, int32 y_3, int32 zPos) {
|
|
|
|
_engine->_renderer->setBaseRotation(x_2, y_3, 0);
|
|
|
|
_engine->_renderer->getBaseRotationPosition(0, 0, zPos + 1000);
|
|
|
|
const int32 iVar1 = _engine->_renderer->destZ;
|
|
|
|
const int32 y_2 = _engine->_renderer->destY;
|
|
|
|
const int32 x_1 = _engine->_renderer->destX;
|
|
|
|
int32 trajRotPosX = 0; // TODO DAT_0043f706 4th short value of the trajectory data TrajectoryData::x
|
|
|
|
int32 trajRotPosY = 0; // TODO DAT_0043f710 5th short value of the trajectory data TrajectoryData::y
|
|
|
|
int32 trajRotPosZ = 0; // TODO _DAT_0043f7f8 6th short value of the trajectory data TrajectoryData::z
|
|
|
|
_engine->_renderer->setCameraAngle(0, 0, 0, trajRotPosX, trajRotPosY, trajRotPosZ, 5300);
|
2021-01-24 15:16:37 +01:00
|
|
|
_engine->_renderer->getBaseRotationPosition(x_1, y_2, iVar1);
|
2021-01-24 09:54:13 +01:00
|
|
|
_engine->_interface->resetClip();
|
2021-01-24 15:16:37 +01:00
|
|
|
_engine->_renderer->renderIsoModel(x_1, y_2, iVar1, x_2, y_3, 0, mdl_1);
|
2021-01-24 09:54:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Holomap::TrajectoryData Holomap::loadTrajectoryData(int32 trajectoryIdx) {
|
|
|
|
TrajectoryData data;
|
2021-01-24 15:16:37 +01:00
|
|
|
Common::MemoryReadStream stream(_engine->_resources->holomapPointAnimPtr, _engine->_resources->holomapPointAnimSize);
|
2021-01-24 09:54:13 +01:00
|
|
|
for (int32 trajIdx = 0; trajIdx < trajectoryIdx; ++trajIdx) {
|
2021-01-24 15:16:37 +01:00
|
|
|
stream.skip(12);
|
|
|
|
const int16 animVal = stream.readSint16LE();
|
|
|
|
stream.skip(4 * animVal);
|
|
|
|
}
|
|
|
|
data.locationIdx = stream.readSint16LE();
|
|
|
|
data.trajLocationIdx = stream.readSint16LE();
|
|
|
|
data.vehicleIdx = stream.readSint16LE();
|
|
|
|
data.x = stream.readSint16LE();
|
|
|
|
data.y = stream.readSint16LE();
|
|
|
|
data.z = stream.readSint16LE();
|
|
|
|
data.numAnimFrames = stream.readSint16LE();
|
|
|
|
assert(data.numAnimFrames < ARRAYSIZE(data.positions));
|
|
|
|
for (int32 i = 0; i < data.numAnimFrames; ++i) {
|
|
|
|
data.positions[i].x = stream.readSint16LE();
|
|
|
|
data.positions[i].y = stream.readSint16LE();
|
2021-01-24 09:54:13 +01:00
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
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);
|
2021-01-24 09:54:13 +01:00
|
|
|
const Holomap::TrajectoryData &data = loadTrajectoryData(trajectoryIndex);
|
2021-01-11 20:21:49 +01:00
|
|
|
ScopedEngineFreeze timeFreeze(_engine);
|
2021-01-17 00:03:41 +01:00
|
|
|
ScopedKeyMap holomapKeymap(_engine, holomapKeyMapId);
|
2021-01-11 20:21:49 +01:00
|
|
|
_engine->_renderer->setCameraPosition(400, 240, 128, 1024, 1024);
|
2021-01-24 15:16:37 +01:00
|
|
|
loadHolomapGFX();
|
|
|
|
|
|
|
|
renderHolomapSurfacePolygons();
|
2021-01-24 09:54:13 +01:00
|
|
|
|
2021-01-24 15:16:37 +01:00
|
|
|
const Location &loc = _locations[data.locationIdx];
|
2021-01-24 09:54:13 +01:00
|
|
|
renderHolomapModel(_engine->_resources->holomapPointModelPtr, loc.x, loc.y, 0);
|
|
|
|
|
|
|
|
_engine->flip();
|
2021-01-11 20:21:49 +01:00
|
|
|
ActorMoveStruct move;
|
2021-01-24 15:16:37 +01:00
|
|
|
AnimTimerDataStruct animData;
|
|
|
|
uint8 *animPtr = nullptr;
|
|
|
|
HQR::getAllocEntry(&animPtr, Resources::HQR_RESS_FILE, data.getAnimation());
|
|
|
|
uint8 *modelPtr = nullptr;
|
|
|
|
HQR::getAllocEntry(&modelPtr, Resources::HQR_RESS_FILE, data.getModel());
|
2021-01-12 22:44:58 +01:00
|
|
|
int frameNumber = 0;
|
|
|
|
int frameTime = _engine->lbaTime;
|
2021-01-24 15:16:37 +01:00
|
|
|
int trajAnimFrameIdx = 0;
|
2021-01-11 20:21:49 +01:00
|
|
|
for (;;) {
|
|
|
|
ScopedFPS scopedFps;
|
|
|
|
_engine->readKeys();
|
|
|
|
if (_engine->shouldQuit() || _engine->_input->toggleAbortAction()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-01-24 15:16:37 +01:00
|
|
|
#if 0
|
2021-01-11 20:21:49 +01:00
|
|
|
// TODO
|
|
|
|
if (!v28) {
|
2021-01-24 15:16:37 +01:00
|
|
|
setPalette2(576 / 3, 96 / 3, (int)&paletteHolomap[3 * needToLoadHolomapGFX++]);
|
|
|
|
if (needToLoadHolomapGFX == 96 / 3) {
|
2021-01-11 20:21:49 +01:00
|
|
|
needToLoadHolomapGFX = 0;
|
|
|
|
}
|
|
|
|
}
|
2021-01-24 15:16:37 +01:00
|
|
|
#endif
|
2021-01-11 20:21:49 +01:00
|
|
|
const int16 newAngle = move.getRealAngle(_engine->lbaTime);
|
|
|
|
if (move.numOfStep == 0) {
|
2021-01-12 22:44:58 +01:00
|
|
|
const int startAngle = ANGLE_0;
|
|
|
|
_engine->_movements->setActorAngleSafe(startAngle, startAngle - ANGLE_90, 500, &move);
|
2021-01-11 20:21:49 +01:00
|
|
|
}
|
2021-01-12 22:44:58 +01:00
|
|
|
|
2021-01-24 15:16:37 +01:00
|
|
|
if (_engine->_animations->setModelAnimation(frameNumber, animPtr, modelPtr, &animData)) {
|
2021-01-12 22:44:58 +01:00
|
|
|
frameNumber++;
|
|
|
|
if (frameNumber >= _engine->_animations->getNumKeyframes(animPtr)) {
|
|
|
|
frameNumber = _engine->_animations->getStartKeyframe(animPtr);
|
2021-01-11 20:21:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
_engine->_renderer->setCameraPosition(100, 400, 128, 900, 900);
|
2021-01-24 09:54:13 +01:00
|
|
|
_engine->_renderer->setCameraAngle(0, 0, 0, 0x3c, 0x80, 0, 30000);
|
|
|
|
_engine->_renderer->setLightVector(0xffffffc4, 0x80, 0);
|
2021-01-24 15:16:37 +01:00
|
|
|
_engine->_interface->drawSplittedBox(Common::Rect(0, 200, 199, 0x1df), 0);
|
|
|
|
_engine->_renderer->renderIsoModel(0, 0, 0, 0, newAngle, 0, modelPtr);
|
2021-01-24 09:54:13 +01:00
|
|
|
_engine->copyBlockPhys(0, 200, 199, 0x1df);
|
2021-01-11 20:21:49 +01:00
|
|
|
_engine->_renderer->setCameraPosition(400, 240, 128, 1024, 1024);
|
2021-01-24 09:54:13 +01:00
|
|
|
const int32 trajRotPosX = data.x; // DAT_0043f706
|
|
|
|
const int32 trajRotPosY = data.y; // DAT_0043f710
|
|
|
|
const int32 trajRotPosZ = data.z; // _DAT_0043f7f8
|
|
|
|
_engine->_renderer->setCameraAngle(0, 0, 0, trajRotPosX, trajRotPosY, trajRotPosZ, 0x14b4);
|
|
|
|
_engine->_renderer->setLightVector(trajRotPosX, trajRotPosY, 0);
|
2021-01-12 22:44:58 +01:00
|
|
|
if (frameTime + 40 <= _engine->lbaTime) {
|
|
|
|
frameTime = _engine->lbaTime;
|
2021-01-24 15:16:37 +01:00
|
|
|
int model_x;
|
|
|
|
int model_y;
|
|
|
|
if (trajAnimFrameIdx < data.numAnimFrames) {
|
|
|
|
model_x = data.positions[trajAnimFrameIdx].x;
|
|
|
|
model_y = data.positions[trajAnimFrameIdx].y;
|
2021-01-24 09:54:13 +01:00
|
|
|
} else {
|
2021-01-24 15:16:37 +01:00
|
|
|
if (data.numAnimFrames < trajAnimFrameIdx) {
|
2021-01-24 09:54:13 +01:00
|
|
|
break;
|
|
|
|
}
|
2021-01-24 15:16:37 +01:00
|
|
|
model_x = _locations[data.trajLocationIdx].x;
|
|
|
|
model_y = _locations[data.trajLocationIdx].y;
|
2021-01-11 20:21:49 +01:00
|
|
|
}
|
2021-01-24 15:16:37 +01:00
|
|
|
renderHolomapModel(_engine->_resources->holomapPointModelPtr, model_x, model_y, 0);
|
|
|
|
trajAnimFrameIdx = trajAnimFrameIdx + 1;
|
2021-01-11 20:21:49 +01:00
|
|
|
}
|
2021-01-24 15:16:37 +01:00
|
|
|
#if 0
|
2021-01-11 20:21:49 +01:00
|
|
|
if (v28) {
|
|
|
|
v28 = 0;
|
|
|
|
_engine->_screens->fadeToPal((int)palette);
|
|
|
|
}
|
2021-01-24 15:16:37 +01:00
|
|
|
#endif
|
2021-01-11 20:21:49 +01:00
|
|
|
}
|
2021-01-11 21:32:35 +01:00
|
|
|
_engine->_screens->fadeToBlack(_engine->_screens->paletteRGBA);
|
|
|
|
// TODO: flip()?
|
2021-01-24 15:16:37 +01:00
|
|
|
free(animPtr);
|
|
|
|
free(modelPtr);
|
2020-10-21 11:41:37 +02:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2021-01-12 13:23:25 +01:00
|
|
|
int32 Holomap::getNextHolomapLocation(int32 currentLocation, int32 dir) const {
|
2021-01-10 22:08:52 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-01-13 00:09:57 +01:00
|
|
|
void Holomap::renderLocations(int xRot, int yRot, int zRot, bool lower) {
|
|
|
|
int n = 0;
|
|
|
|
for (int locationIdx = 0; locationIdx < NUM_LOCATIONS; ++locationIdx) {
|
|
|
|
if ((_engine->_gameState->holomapFlags[locationIdx] & 0x80) || locationIdx == _engine->_scene->currentSceneIdx) {
|
|
|
|
uint8 flags = _engine->_gameState->holomapFlags[locationIdx] & 1;
|
|
|
|
if (locationIdx == _engine->_scene->currentSceneIdx) {
|
|
|
|
flags |= 2u; // model type
|
|
|
|
}
|
|
|
|
const Location &loc = _locations[locationIdx];
|
2021-01-17 00:04:44 +01:00
|
|
|
_engine->_renderer->setBaseRotation(loc.x, loc.y, 0);
|
|
|
|
_engine->_renderer->getBaseRotationPosition(0, 0, loc.z + 1000);
|
2021-01-13 00:09:57 +01:00
|
|
|
int32 v20 = _engine->_renderer->destX;
|
|
|
|
int32 v18 = _engine->_renderer->destY;
|
2021-01-17 00:04:44 +01:00
|
|
|
int32 v19 = _engine->_renderer->destZ;
|
|
|
|
_engine->_renderer->getBaseRotationPosition(0, 0, 1500);
|
|
|
|
int32 v22 = _engine->_renderer->destX;
|
|
|
|
int32 v23 = _engine->_renderer->destY;
|
|
|
|
int32 v24 = _engine->_renderer->destZ;
|
|
|
|
_engine->_renderer->setBaseRotation(xRot, yRot, zRot);
|
2021-01-13 00:09:57 +01:00
|
|
|
_engine->_renderer->baseRotPosX = 0;
|
|
|
|
_engine->_renderer->baseRotPosY = 0;
|
|
|
|
_engine->_renderer->baseRotPosZ = 9500;
|
2021-01-17 00:04:44 +01:00
|
|
|
_engine->_renderer->getBaseRotationPosition(v20, v18, v19);
|
|
|
|
int v21 = _engine->_renderer->destZ;
|
|
|
|
_engine->_renderer->getBaseRotationPosition(v22, v23, v24);
|
2021-01-13 00:09:57 +01:00
|
|
|
if (lower) {
|
|
|
|
if (v21 > _engine->_renderer->destY) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (v21 < _engine->_renderer->destY) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawListStruct &drawList = _engine->_redraw->drawList[n];
|
2021-01-17 00:04:44 +01:00
|
|
|
drawList.posValue = v21;
|
|
|
|
drawList.actorIdx = locationIdx;
|
|
|
|
drawList.type = 0;
|
2021-01-13 00:09:57 +01:00
|
|
|
drawList.x = v20;
|
2021-01-17 00:04:44 +01:00
|
|
|
drawList.y = v18;
|
|
|
|
drawList.z = v21;
|
|
|
|
drawList.offset = n;
|
|
|
|
drawList.field_C = flags;
|
|
|
|
drawList.field_E = 0;
|
|
|
|
drawList.field_10 = 0;
|
2021-01-13 00:09:57 +01:00
|
|
|
++n;
|
|
|
|
}
|
|
|
|
}
|
2021-01-17 00:04:44 +01:00
|
|
|
_engine->_redraw->sortDrawingList(_engine->_redraw->drawList, n);
|
2021-01-13 00:09:57 +01:00
|
|
|
for (int v13 = 0; v13 < n; ++v13) {
|
2021-01-17 00:04:44 +01:00
|
|
|
const DrawListStruct &drawList = _engine->_redraw->drawList[v13];
|
|
|
|
const uint16 flags = drawList.field_C;
|
|
|
|
const uint8 *bodyPtr = nullptr;
|
2021-01-24 15:16:37 +01:00
|
|
|
if (flags == 1u) {
|
2021-01-17 00:04:44 +01:00
|
|
|
bodyPtr = _engine->_resources->holomapArrowPtr;
|
|
|
|
} else if (flags == 2u) {
|
|
|
|
bodyPtr = _engine->_resources->holomapTwinsenModelPtr;
|
2021-01-24 15:16:37 +01:00
|
|
|
} else if (flags == 3u) {
|
2021-01-17 00:04:44 +01:00
|
|
|
bodyPtr = _engine->_resources->holomapTwinsenArrowPtr;
|
2021-01-13 00:09:57 +01:00
|
|
|
}
|
|
|
|
if (bodyPtr != nullptr) {
|
2021-01-17 00:04:44 +01:00
|
|
|
int32 angleX = _locations[drawList.actorIdx].x;
|
|
|
|
int32 angleY = _locations[drawList.actorIdx].y;
|
|
|
|
_engine->_renderer->renderIsoModel(drawList.x, drawList.y, drawList.z, angleX, angleY, 0, bodyPtr);
|
2021-01-13 00:09:57 +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-24 15:16:37 +01:00
|
|
|
renderHolomapSurfacePolygons();
|
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);
|
|
|
|
|
2021-01-17 00:04:44 +01:00
|
|
|
int32 time = _engine->lbaTime;
|
2021-01-11 21:32:35 +01:00
|
|
|
int32 xRot = 0;
|
|
|
|
int32 yRot = 0;
|
|
|
|
bool rotate = false;
|
|
|
|
bool redraw = true;
|
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;
|
|
|
|
}
|
|
|
|
|
2021-01-11 21:32:35 +01:00
|
|
|
if (_engine->_input->toggleActionIfActive(TwinEActionType::HolomapPrev)) {
|
2021-01-10 22:08:52 +01:00
|
|
|
const int32 nextLocation = getNextHolomapLocation(currentLocation, -1);
|
|
|
|
if (nextLocation != -1) {
|
|
|
|
currentLocation = nextLocation;
|
|
|
|
drawHolomapLocation(currentLocation);
|
2021-01-17 00:04:44 +01:00
|
|
|
time = _engine->lbaTime;
|
|
|
|
rotate = true;
|
2021-01-10 22:08:52 +01:00
|
|
|
}
|
2021-01-11 21:32:35 +01:00
|
|
|
} else if (_engine->_input->toggleActionIfActive(TwinEActionType::HolomapNext)) {
|
2021-01-10 22:08:52 +01:00
|
|
|
const int32 nextLocation = getNextHolomapLocation(currentLocation, 1);
|
|
|
|
if (nextLocation != -1) {
|
|
|
|
currentLocation = nextLocation;
|
|
|
|
drawHolomapLocation(currentLocation);
|
2021-01-17 00:04:44 +01:00
|
|
|
time = _engine->lbaTime;
|
|
|
|
rotate = true;
|
2021-01-10 22:08:52 +01:00
|
|
|
}
|
2020-12-22 14:44:56 +01:00
|
|
|
}
|
|
|
|
|
2021-01-17 00:04:44 +01:00
|
|
|
if (_engine->_input->isActionActive(TwinEActionType::HolomapLeft)) {
|
2021-01-11 21:32:35 +01:00
|
|
|
xRot += 8;
|
|
|
|
rotate = true;
|
2021-01-17 00:04:44 +01:00
|
|
|
time = _engine->lbaTime;
|
|
|
|
} else if (_engine->_input->isActionActive(TwinEActionType::HolomapRight)) {
|
2021-01-11 21:32:35 +01:00
|
|
|
xRot -= 8;
|
|
|
|
rotate = true;
|
2021-01-17 00:04:44 +01:00
|
|
|
time = _engine->lbaTime;
|
2021-01-11 21:32:35 +01:00
|
|
|
}
|
|
|
|
|
2021-01-17 00:04:44 +01:00
|
|
|
if (_engine->_input->isActionActive(TwinEActionType::HolomapUp)) {
|
2021-01-11 21:32:35 +01:00
|
|
|
yRot += 8;
|
|
|
|
rotate = true;
|
2021-01-17 00:04:44 +01:00
|
|
|
time = _engine->lbaTime;
|
|
|
|
} else if (_engine->_input->isActionActive(TwinEActionType::HolomapDown)) {
|
2021-01-11 21:32:35 +01:00
|
|
|
yRot -= 8;
|
|
|
|
rotate = true;
|
2021-01-17 00:04:44 +01:00
|
|
|
time = _engine->lbaTime;
|
2021-01-11 21:32:35 +01:00
|
|
|
}
|
2021-01-17 00:04:44 +01:00
|
|
|
|
2021-01-11 21:32:35 +01:00
|
|
|
if (rotate) {
|
2021-01-17 00:04:44 +01:00
|
|
|
const int32 dt = _engine->lbaTime - time;
|
|
|
|
xRot = _engine->_collision->getAverageValue(xRot, _locations[currentLocation].x, 75, dt);
|
|
|
|
yRot = _engine->_collision->getAverageValue(yRot, _locations[currentLocation].y, 75, dt);
|
2021-01-11 21:32:35 +01:00
|
|
|
redraw = true;
|
2020-12-22 14:44:56 +01:00
|
|
|
}
|
|
|
|
|
2021-01-11 21:32:35 +01:00
|
|
|
if (redraw) {
|
|
|
|
redraw = false;
|
2021-01-13 00:09:57 +01:00
|
|
|
const Common::Rect rect(170, 0, 470, 330);
|
|
|
|
_engine->_interface->drawSplittedBox(rect, 0);
|
|
|
|
_engine->_renderer->setBaseRotation(xRot, yRot, 0);
|
|
|
|
_engine->_renderer->setLightVector(xRot, yRot, 0);
|
2021-01-24 15:16:37 +01:00
|
|
|
// renderLocations(xRot, yRot, 0, false); // TODO: activate me
|
2021-01-13 00:09:57 +01:00
|
|
|
_engine->_renderer->setBaseRotation(xRot, yRot, 0);
|
2021-01-24 15:16:37 +01:00
|
|
|
renderHolomapSurfacePolygons();
|
|
|
|
// renderLocations(xRot, yRot, 0, true); // TODO: activate me
|
2021-01-13 00:09:57 +01:00
|
|
|
if (rotate) {
|
|
|
|
_engine->_menu->drawBox(300, 170, 340, 210);
|
2021-01-12 22:46:15 +01:00
|
|
|
}
|
2021-01-17 00:04:44 +01:00
|
|
|
//_engine->copyBlockPhys(rect);
|
|
|
|
_engine->flip();
|
2021-01-13 00:09:57 +01:00
|
|
|
}
|
2021-01-12 22:46:15 +01:00
|
|
|
|
2021-01-13 00:09:57 +01:00
|
|
|
if (rotate && xRot == _locations[currentLocation].x && yRot == _locations[currentLocation].y) {
|
|
|
|
rotate = false;
|
2021-01-11 21:32:35 +01:00
|
|
|
}
|
2020-12-22 14:44:56 +01:00
|
|
|
|
2021-01-17 00:04:44 +01:00
|
|
|
++_engine->lbaTime;
|
|
|
|
|
2021-01-13 00:09:57 +01:00
|
|
|
// TODO: text afterwards on top (not before as it is currently implemented)?
|
|
|
|
// pos 0x140,0x19?
|
|
|
|
|
2020-12-22 14:44:56 +01:00
|
|
|
//_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
|