2016-09-14 23:42:19 +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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-08-18 13:15:54 +02:00
|
|
|
#include "common/scummsys.h"
|
|
|
|
|
|
|
|
#include "common/config-manager.h"
|
|
|
|
#include "common/debug.h"
|
|
|
|
#include "common/debug-channels.h"
|
|
|
|
#include "common/error.h"
|
|
|
|
#include "gui/EventRecorder.h"
|
|
|
|
#include "common/file.h"
|
|
|
|
#include "common/savefile.h"
|
|
|
|
#include "common/fs.h"
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "graphics/surface.h"
|
|
|
|
#include "graphics/screen.h"
|
|
|
|
#include "graphics/palette.h"
|
|
|
|
#include "common/timer.h"
|
|
|
|
|
|
|
|
//#include "audio/audiostream.h"
|
|
|
|
#include "audio/mixer.h"
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
#include "cryo/defs.h"
|
2016-08-18 13:15:54 +02:00
|
|
|
#include "cryo/cryo.h"
|
2016-09-14 23:39:27 +02:00
|
|
|
#include "cryo/platdefs.h"
|
|
|
|
#include "cryo/cryolib.h"
|
2016-08-18 13:15:54 +02:00
|
|
|
#include "cryo/eden.h"
|
2016-10-22 14:15:45 +03:00
|
|
|
#include "cryo/sound.h"
|
2016-08-18 13:15:54 +02:00
|
|
|
|
|
|
|
namespace Cryo {
|
|
|
|
|
2016-11-13 13:56:20 -08:00
|
|
|
int16 _torchTick = 0;
|
|
|
|
int16 _glowIndex = 0;
|
|
|
|
int16 _torchCurIndex = 0;
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-11-13 13:56:20 -08:00
|
|
|
bool _allowDoubled = true;
|
|
|
|
int _cursCenter = 11;
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-11-09 13:40:08 -08:00
|
|
|
EdenGame::EdenGame(CryoEngine *vm) : _vm(vm) {
|
2017-01-22 22:38:18 +01:00
|
|
|
static uint8 statTab2CB1E[8][4] = {
|
|
|
|
{ 0x10, 0x81, 1, 0x90},
|
|
|
|
{ 0x90, 1, 0x81, 0x10},
|
|
|
|
{ 1, 0x90, 0x10, 0x81},
|
|
|
|
{ 1, 0x10, 0x90, 0x81},
|
|
|
|
{ 1, 0x90, 0x10, 0x81},
|
|
|
|
{ 0x81, 0x10, 0x90, 1},
|
|
|
|
{ 0x81, 0x10, 0x90, 1},
|
|
|
|
{ 0x81, 0x90, 1, 0x10}
|
|
|
|
};
|
|
|
|
|
2016-09-30 07:48:27 +02:00
|
|
|
_adamMapMarkPos = Common::Point(-1, -1);
|
2016-10-09 00:01:32 +03:00
|
|
|
|
2016-10-09 01:44:52 +03:00
|
|
|
_scrollPos = _oldScrollPos = 0;
|
2016-10-09 00:01:32 +03:00
|
|
|
_frescoTalk = false;
|
2016-12-18 13:09:56 -08:00
|
|
|
_torchCursor = false;
|
2016-10-09 00:01:32 +03:00
|
|
|
_curBankNum = 0;
|
2016-12-18 22:58:31 -08:00
|
|
|
_glowH = _glowW = _glowY = _glowX = 0;
|
2016-12-18 14:13:36 -08:00
|
|
|
_paletteUpdateRequired = false;
|
2016-12-18 13:09:56 -08:00
|
|
|
_cursorSaved = false;
|
2016-12-18 14:13:36 -08:00
|
|
|
_showBlackBars = false;
|
|
|
|
_backgroundSaved = false;
|
2016-12-04 14:26:44 -08:00
|
|
|
_bankData = nullptr;
|
2016-12-18 22:58:31 -08:00
|
|
|
_tyranPtr = nullptr;
|
2016-12-04 14:26:44 -08:00
|
|
|
_lastAnimFrameNumb = _curAnimFrameNumb = 0;
|
2016-10-09 00:01:32 +03:00
|
|
|
_lastAnimTicks = 0;
|
2017-01-15 22:59:50 +01:00
|
|
|
_curCharacterRect = nullptr;
|
2016-12-25 02:17:07 -08:00
|
|
|
_numAnimFrames = _maxPersoDesc = _numImgDesc = 0;
|
|
|
|
_restartAnimation = _animationActive = false;
|
|
|
|
_animationDelay = _animationIndex = _lastAnimationIndex = 0;
|
2016-12-25 13:45:47 -08:00
|
|
|
dword_30724 = dword_30728 = _mouthAnimations = _animationTable = nullptr;
|
2016-12-04 14:26:44 -08:00
|
|
|
_characterBankData = nullptr;
|
2016-12-25 02:17:07 -08:00
|
|
|
_savedUnderSubtitles = false;
|
2016-12-25 13:45:47 -08:00
|
|
|
_numTextLines = 0;
|
2016-12-29 06:28:11 -08:00
|
|
|
_textOutPtr = textout = nullptr;
|
2016-12-04 14:26:44 -08:00
|
|
|
_curSpecialObject = nullptr;
|
2016-12-04 13:15:38 -08:00
|
|
|
_lastDialogChoice = false;
|
2016-10-24 00:04:32 +02:00
|
|
|
parlemoiNormalFlag = false;
|
2016-12-04 13:15:38 -08:00
|
|
|
_closeCharacterDialog = false;
|
2016-10-09 01:44:52 +03:00
|
|
|
dword_30B04 = 0;
|
2017-01-21 01:12:01 +01:00
|
|
|
_lastPhrasesFile = 0;
|
|
|
|
_dialogSkipFlags = 0;
|
2016-12-26 22:47:24 -08:00
|
|
|
_voiceSamplesBuffer = nullptr;
|
2017-01-01 11:51:48 -08:00
|
|
|
_needToFade = false;
|
2016-12-04 14:54:58 -08:00
|
|
|
_mainBankBuf = nullptr;
|
|
|
|
_musicBuf = nullptr;
|
2017-01-01 11:51:48 -08:00
|
|
|
_gameLipsync = nullptr;
|
|
|
|
_gamePhrases = nullptr;
|
2016-12-28 03:43:13 -08:00
|
|
|
_gameDialogs = nullptr;
|
|
|
|
_gameConditions = nullptr;
|
2016-12-18 14:13:36 -08:00
|
|
|
_placeRawBuf = nullptr;
|
|
|
|
_bankDataBuf = nullptr;
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons = nullptr;
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms = nullptr;
|
|
|
|
_glowBuffer = nullptr;
|
|
|
|
_gameFont = nullptr;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals = nullptr;
|
2016-12-18 14:13:36 -08:00
|
|
|
_mouseCenterY = _mouseCenterX = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
_bufferAllocationErrorFl = _quitFlag2 = _quitFlag3 = false;
|
2016-12-18 13:09:56 -08:00
|
|
|
_gameStarted = false;
|
2016-10-09 00:01:32 +03:00
|
|
|
_soundAllocated = false;
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel = _voiceChannel = nullptr;
|
2016-11-17 15:40:07 -08:00
|
|
|
_hnmSoundChannel = nullptr;
|
2016-12-18 14:13:36 -08:00
|
|
|
_voiceSound = nullptr;
|
2017-01-01 11:51:48 -08:00
|
|
|
_view2 = _underSubtitlesView = _subtitlesView = _underBarsView = _mainView = _hnmView = nullptr;
|
2016-10-09 00:01:32 +03:00
|
|
|
_doubledScreen = false;
|
2016-12-18 13:09:56 -08:00
|
|
|
_cirsorPanX = 0;
|
2016-10-09 00:01:32 +03:00
|
|
|
_inventoryScrollDelay = 0;
|
2016-12-18 13:09:56 -08:00
|
|
|
_cursorPosY = _cursorPosX = 0;
|
2016-11-13 13:56:20 -08:00
|
|
|
_currCursor = 0;
|
2016-12-19 22:32:40 -08:00
|
|
|
_currSpot = _curSpot2 = nullptr;
|
2016-12-18 14:13:36 -08:00
|
|
|
_keyboardHeld = false;
|
2016-12-18 13:09:56 -08:00
|
|
|
_mouseHeld = false;
|
|
|
|
_normalCursor = false;
|
2016-12-18 14:13:36 -08:00
|
|
|
_showVideoSubtitle = false;
|
|
|
|
_specialTextMode = false;
|
|
|
|
_voiceSamplesSize = 0;
|
2016-11-09 22:36:06 -08:00
|
|
|
_animateTalking = false;
|
2016-10-09 00:01:32 +03:00
|
|
|
_personTalking = false;
|
|
|
|
_musicFadeFlag = 0;
|
2016-12-18 14:13:36 -08:00
|
|
|
_musicPlayingFlag = false;
|
|
|
|
_musicSamplesPtr = _musicPatternsPtr = _musSequencePtr = nullptr;
|
|
|
|
_musicEnabledFlag = false;
|
2017-01-01 11:51:48 -08:00
|
|
|
_currentObjectLocation = nullptr;
|
2016-10-09 01:44:52 +03:00
|
|
|
byte_31D64 = false;
|
2016-11-13 13:56:20 -08:00
|
|
|
_noPalette = false;
|
|
|
|
_gameLoaded = false;
|
2017-01-01 11:51:48 -08:00
|
|
|
memset(_tapes, 0, sizeof(_tapes));
|
|
|
|
_confirmMode = 0;
|
|
|
|
_curSliderValuePtr = nullptr;
|
2016-12-19 22:32:40 -08:00
|
|
|
_lastMenuItemIdLo = 0;
|
|
|
|
_lastTapeRoomNum = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
_curSliderX = _curSliderY = 0;
|
|
|
|
_destinationRoom = 0;
|
2016-10-09 01:44:52 +03:00
|
|
|
word_31E7A = 0;
|
2016-10-09 00:01:32 +03:00
|
|
|
word_378CC = 0; //TODO: set by CLComputer_Init to 0
|
2016-10-09 01:44:52 +03:00
|
|
|
word_378CE = 0;
|
2016-10-17 03:05:37 +03:00
|
|
|
|
2017-01-17 00:02:31 +01:00
|
|
|
_rotationAngleY = _rotationAngleX = _rotationAngleZ = 0;
|
|
|
|
_translationY = _translationX = 0.0; //TODO: never changed, make consts?
|
2016-12-25 23:14:03 -08:00
|
|
|
_cursorOldTick = 0;
|
2016-10-21 23:11:03 +03:00
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
_invIconsBase = 19;
|
2016-11-09 13:40:08 -08:00
|
|
|
// invIconsCount = (_vm->getPlatform() == Common::kPlatformMacintosh) ? 9 : 11;
|
2016-12-19 13:41:00 -08:00
|
|
|
_invIconsCount = 11;
|
2016-12-19 22:32:40 -08:00
|
|
|
_roomIconsBase = _invIconsBase + _invIconsCount;
|
2016-10-17 03:05:37 +03:00
|
|
|
|
2016-12-25 14:20:06 -08:00
|
|
|
_codePtr = nullptr;
|
2017-01-22 22:38:18 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
|
|
for (int j = 0; j < 4; j++)
|
|
|
|
tab_2CB1E[i][j] = statTab2CB1E[i][j];
|
|
|
|
}
|
2016-09-30 07:48:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
void EdenGame::removeConsole() {
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
void EdenGame::scroll() {
|
2016-09-27 07:53:50 +02:00
|
|
|
restoreFriezes();
|
2016-12-18 14:13:36 -08:00
|
|
|
_mainView->_normal._srcLeft = _scrollPos;
|
|
|
|
_mainView->_zoom._srcLeft = _scrollPos;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
void EdenGame::resetScroll() {
|
2016-09-30 07:48:27 +02:00
|
|
|
_oldScrollPos = _scrollPos;
|
|
|
|
_scrollPos = 0;
|
2016-09-27 07:53:50 +02:00
|
|
|
restoreFriezes(); //TODO: inlined scroll() ?
|
2016-12-18 14:13:36 -08:00
|
|
|
_mainView->_normal._srcLeft = 0;
|
|
|
|
_mainView->_zoom._srcLeft = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-25 23:17:25 +02:00
|
|
|
void EdenGame::scrollFrescoes() {
|
2016-12-18 13:09:56 -08:00
|
|
|
if (_cursorPosY > 16 && _cursorPosY < 176) {
|
|
|
|
if (_cursorPosX >= 0 && _cursorPosX < 32 && _scrollPos > 3)
|
2016-09-30 07:48:27 +02:00
|
|
|
_scrollPos -= 4;
|
2017-01-01 11:51:48 -08:00
|
|
|
else if (_cursorPosX > 288 && _cursorPosX < 320 && _scrollPos < _globals->_frescoeWidth)
|
2016-09-30 07:48:27 +02:00
|
|
|
_scrollPos += 4;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
scroll();
|
|
|
|
}
|
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
// Original name: afffresques
|
|
|
|
void EdenGame::displayFrescoes() {
|
2017-01-01 11:51:48 -08:00
|
|
|
useBank(_globals->_frescoeImgBank);
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(0, 0, 16);
|
2017-01-01 11:51:48 -08:00
|
|
|
useBank(_globals->_frescoeImgBank + 1);
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(0, 320, 16);
|
2016-12-18 14:13:36 -08:00
|
|
|
_paletteUpdateRequired = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::gametofresques() {
|
2016-09-30 07:48:27 +02:00
|
|
|
_frescoTalk = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
rundcurs();
|
2016-09-27 07:53:50 +02:00
|
|
|
saveFriezes();
|
2016-09-26 23:44:42 +02:00
|
|
|
displayFrescoes();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_displayFlags = DisplayFlags::dfFrescoes;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
// Original name: dofresques
|
|
|
|
void EdenGame::doFrescoes() {
|
2016-12-18 13:09:56 -08:00
|
|
|
_cursorSaved = false;
|
|
|
|
_torchCursor = true;
|
2016-12-18 22:58:31 -08:00
|
|
|
_glowX = -1;
|
|
|
|
_glowY = -1;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_gameFlags |= GameFlags::gfFlag20;
|
|
|
|
_globals->_varD4 = 0;
|
|
|
|
_globals->_curObjectId = 0;
|
|
|
|
_globals->_iconsIndex = 13;
|
|
|
|
_globals->_autoDialog = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
gametofresques();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_frescoNumber = 3;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
// Original name: finfresques
|
2016-12-26 12:35:21 -08:00
|
|
|
void EdenGame::actionEndFrescoes() {
|
2016-12-18 13:09:56 -08:00
|
|
|
_torchCursor = false;
|
|
|
|
_cursorSaved = true;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_displayFlags = DisplayFlags::dfFlag1;
|
2016-09-26 23:44:42 +02:00
|
|
|
resetScroll();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var100 = 0xFF;
|
|
|
|
updateRoom(_globals->_roomNum);
|
|
|
|
if (_globals->_phaseNum == 114)
|
|
|
|
_globals->_narratorSequence = 1;
|
|
|
|
_globals->_eventType = EventType::etEvent8;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-25 23:17:25 +02:00
|
|
|
void EdenGame::scrollMirror() {
|
2016-12-18 13:09:56 -08:00
|
|
|
if (_cursorPosY > 16 && _cursorPosY < 165) {
|
|
|
|
if (_cursorPosX >= 0 && _cursorPosX < 16) {
|
2016-09-30 07:48:27 +02:00
|
|
|
if (_scrollPos > 3) {
|
|
|
|
if (_doubledScreen)
|
|
|
|
_scrollPos -= 2;
|
2016-09-14 23:39:27 +02:00
|
|
|
else
|
2016-09-30 07:48:27 +02:00
|
|
|
_scrollPos -= 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
scroll();
|
|
|
|
}
|
2016-12-18 13:09:56 -08:00
|
|
|
} else if (_cursorPosX > 290 && _cursorPosX < 320) {
|
2016-09-30 07:48:27 +02:00
|
|
|
if (_scrollPos < 320) {
|
|
|
|
if (_doubledScreen)
|
|
|
|
_scrollPos += 2;
|
2016-09-14 23:39:27 +02:00
|
|
|
else
|
2016-09-30 07:48:27 +02:00
|
|
|
_scrollPos += 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
scroll();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-31 05:11:33 -08:00
|
|
|
// Original name: scrollpano
|
|
|
|
void EdenGame::scrollPanel() {
|
2016-12-18 13:09:56 -08:00
|
|
|
if (_cursorPosY > 16 && _cursorPosY < 165) {
|
|
|
|
if (_cursorPosX >= 0 && _cursorPosX < 16) {
|
2016-09-30 07:48:27 +02:00
|
|
|
if (_scrollPos > 3) {
|
|
|
|
if (_doubledScreen)
|
|
|
|
_scrollPos -= 2;
|
2016-09-14 23:39:27 +02:00
|
|
|
else
|
2016-09-30 07:48:27 +02:00
|
|
|
_scrollPos -= 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-18 13:09:56 -08:00
|
|
|
} else if (_cursorPosX > 290 && _cursorPosX < 320) {
|
2016-09-30 07:48:27 +02:00
|
|
|
if (_scrollPos < 320) {
|
|
|
|
if (_doubledScreen)
|
|
|
|
_scrollPos += 2;
|
2016-09-14 23:39:27 +02:00
|
|
|
else
|
2016-09-30 07:48:27 +02:00
|
|
|
_scrollPos += 1;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
scroll();
|
|
|
|
}
|
|
|
|
|
2016-10-07 23:06:10 +02:00
|
|
|
// Original name: affsuiveur
|
|
|
|
void EdenGame::displayFollower(Follower *follower, int16 x, int16 y) {
|
|
|
|
useBank(follower->_spriteBank);
|
|
|
|
noclipax(follower->_spriteNum, x, y + 16);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-10-24 22:02:43 +02:00
|
|
|
// Original name: persoinmiroir
|
|
|
|
void EdenGame::characterInMirror() {
|
2016-12-17 09:32:43 -08:00
|
|
|
Icon *icon1 = &_gameIcons[3];
|
2016-12-19 22:32:40 -08:00
|
|
|
Icon *icon = &_gameIcons[_roomIconsBase];
|
2016-10-07 23:06:10 +02:00
|
|
|
Follower *suiveur = followerList;
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 num = 1;
|
2016-10-24 22:02:43 +02:00
|
|
|
for (int i = 0; i < 16; i++) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_party & (1 << i))
|
2016-09-14 23:39:27 +02:00
|
|
|
num++;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
icon += num;
|
|
|
|
icon->sx = -1;
|
|
|
|
icon--;
|
|
|
|
icon->sx = icon1->sx;
|
|
|
|
icon->sy = icon1->sy;
|
|
|
|
icon->ex = icon1->ex;
|
|
|
|
icon->ey = 170;
|
2016-12-03 15:40:53 -08:00
|
|
|
icon->_cursorId = icon1->_cursorId;
|
|
|
|
icon->_actionId = icon1->_actionId;
|
|
|
|
icon->_objectId = icon1->_objectId;
|
2016-09-14 23:39:27 +02:00
|
|
|
icon--;
|
2016-10-07 23:06:10 +02:00
|
|
|
displayFollower(suiveur, suiveur->sx, suiveur->sy);
|
|
|
|
for (; suiveur->_id != -1; suiveur++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso;
|
|
|
|
for (perso = kPersons; perso != &kPersons[PER_UNKN_156]; perso++) {
|
2016-10-24 22:02:43 +02:00
|
|
|
if (perso->_id != suiveur->_id)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (perso->_flags & PersonFlags::pf80)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((perso->_flags & PersonFlags::pfInParty) == 0)
|
|
|
|
continue;
|
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
if (perso->_roomNum != _globals->_roomNum)
|
2016-10-24 22:02:43 +02:00
|
|
|
continue;
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
icon->sx = suiveur->sx;
|
|
|
|
icon->sy = suiveur->sy;
|
|
|
|
icon->ex = suiveur->ex;
|
|
|
|
icon->ey = suiveur->ey;
|
2016-12-03 15:40:53 -08:00
|
|
|
icon->_cursorId = 8;
|
|
|
|
icon->_actionId = perso->_actionId;
|
2016-09-14 23:39:27 +02:00
|
|
|
icon--;
|
2016-10-07 23:06:10 +02:00
|
|
|
displayFollower(suiveur, suiveur->sx, suiveur->sy);
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-31 05:11:33 -08:00
|
|
|
// Original name: gametomiroir
|
|
|
|
void EdenGame::gameToMirror(byte arg1) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags != DisplayFlags::dfFlag2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
rundcurs();
|
2016-09-27 07:53:50 +02:00
|
|
|
restoreFriezes();
|
2016-09-25 23:17:25 +02:00
|
|
|
drawTopScreen();
|
|
|
|
showObjects();
|
2016-09-27 07:53:50 +02:00
|
|
|
saveFriezes();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
int16 bank = _globals->_roomBackgroundBankNum;
|
2016-12-31 05:11:33 -08:00
|
|
|
uint16 resNum = bank + 326;
|
2017-01-18 23:05:38 +01:00
|
|
|
if ((_vm->getPlatform() == Common::kPlatformMacintosh) && (bank == 76 || bank == 128))
|
2016-10-17 03:05:37 +03:00
|
|
|
resNum = 2487; // PCIMG.HSQ
|
2017-01-18 23:05:38 +01:00
|
|
|
|
2016-10-17 03:05:37 +03:00
|
|
|
useBank(resNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(0, 0, 16);
|
2016-10-17 03:05:37 +03:00
|
|
|
useBank(resNum + 1);
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(0, 320, 16);
|
2016-10-24 22:02:43 +02:00
|
|
|
characterInMirror();
|
2016-12-18 14:13:36 -08:00
|
|
|
_paletteUpdateRequired = true;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_iconsIndex = 16;
|
|
|
|
_globals->_autoDialog = false;
|
|
|
|
_globals->_displayFlags = DisplayFlags::dfMirror;
|
|
|
|
_globals->_mirrorEffect = arg1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
void EdenGame::flipMode() {
|
2016-10-06 00:15:02 +02:00
|
|
|
if (_personTalking) {
|
2016-12-28 03:43:13 -08:00
|
|
|
endCharacterSpeech();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags == DisplayFlags::dfPerson) {
|
2017-01-15 23:51:17 +01:00
|
|
|
if (_globals->_characterPtr == &kPersons[PER_TAU] && _globals->_phaseNum >= 80)
|
2016-12-25 02:17:07 -08:00
|
|
|
displaySubtitles();
|
2016-09-14 23:39:27 +02:00
|
|
|
else {
|
2016-12-25 02:17:07 -08:00
|
|
|
getDataSync();
|
2017-01-15 22:59:50 +01:00
|
|
|
loadCurrCharacter();
|
2016-09-14 23:39:27 +02:00
|
|
|
addanim();
|
2016-12-04 14:26:44 -08:00
|
|
|
_restartAnimation = true;
|
2017-01-15 22:59:50 +01:00
|
|
|
animCharacter();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
} else
|
2016-12-25 02:17:07 -08:00
|
|
|
displaySubtitles();
|
2016-09-14 23:39:27 +02:00
|
|
|
persovox();
|
|
|
|
} else {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags != DisplayFlags::dfFrescoes && _globals->_displayFlags != DisplayFlags::dfFlag2) {
|
2016-12-28 03:43:13 -08:00
|
|
|
closeRoom();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags & DisplayFlags::dfFlag1)
|
2016-12-31 05:11:33 -08:00
|
|
|
gameToMirror(1);
|
2016-09-14 23:39:27 +02:00
|
|
|
else {
|
2016-09-26 23:44:42 +02:00
|
|
|
quitMirror();
|
2017-01-01 11:51:48 -08:00
|
|
|
updateRoom(_globals->_roomNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (byte_31D64) {
|
|
|
|
dialautoon();
|
|
|
|
parle_moi();
|
2017-01-22 22:38:18 +01:00
|
|
|
byte_31D64 = false;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
// Original name: quitmiroir
|
|
|
|
void EdenGame::quitMirror() {
|
2016-09-14 23:39:27 +02:00
|
|
|
rundcurs();
|
2016-12-26 13:40:28 -08:00
|
|
|
display();
|
2016-09-26 23:44:42 +02:00
|
|
|
resetScroll();
|
2016-09-27 07:53:50 +02:00
|
|
|
saveFriezes();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_displayFlags = DisplayFlags::dfFlag1;
|
|
|
|
_globals->_var100 = 0xFF;
|
|
|
|
_globals->_eventType = EventType::etEventC;
|
|
|
|
_globals->_mirrorEffect = 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::clictimbre() {
|
2016-09-26 23:44:42 +02:00
|
|
|
flipMode();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: clicplanval
|
|
|
|
void EdenGame::actionClickValleyPlan() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if ((_globals->_partyOutside & PersonMask::pmDina) && _globals->_phaseNum == 371) {
|
2016-09-26 23:44:42 +02:00
|
|
|
quitMirror();
|
2017-01-01 11:51:48 -08:00
|
|
|
updateRoom(_globals->_roomNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_roomNum == 8 || _globals->_roomNum < 16)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-18 23:05:38 +01:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
rundcurs();
|
2016-12-26 13:40:28 -08:00
|
|
|
display();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags == DisplayFlags::dfMirror)
|
2016-09-26 23:44:42 +02:00
|
|
|
quitMirror();
|
2017-01-01 11:51:48 -08:00
|
|
|
deplaval((_globals->_roomNum & 0xFF00) | 1); //TODO: check me
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-26 12:35:21 -08:00
|
|
|
// Original name: gotolieu
|
|
|
|
void EdenGame::gotoPlace(Goto *go) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_valleyVidNum = go->_arriveVideoNum;
|
|
|
|
_globals->_travelTime = go->_travelTime * 256;
|
|
|
|
_globals->_stepsToFindAppleFast = 0;
|
|
|
|
_globals->_eventType = EventType::etEvent2;
|
2016-12-04 13:15:38 -08:00
|
|
|
setChoiceYes();
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-12-04 13:15:38 -08:00
|
|
|
if (!isAnswerYes())
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-18 23:05:38 +01:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_var113) {
|
2016-12-04 13:15:38 -08:00
|
|
|
waitEndSpeak();
|
2017-01-01 14:14:02 -08:00
|
|
|
if (!_vm->shouldQuit())
|
2016-12-28 03:43:13 -08:00
|
|
|
closeCharacterScreen();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-15 22:47:29 -08:00
|
|
|
if (go->_enterVideoNum) {
|
2017-01-14 00:30:37 +01:00
|
|
|
hideBars();
|
2016-12-15 22:47:29 -08:00
|
|
|
playHNM(go->_enterVideoNum);
|
2017-01-01 11:51:48 -08:00
|
|
|
_needToFade = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
initPlace(_globals->_newRoomNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
specialoutside();
|
2017-01-01 11:51:48 -08:00
|
|
|
faire_suivre(_globals->_newRoomNum);
|
2016-12-28 03:43:13 -08:00
|
|
|
closeRoom();
|
2016-09-30 07:48:27 +02:00
|
|
|
_adamMapMarkPos.x = -1;
|
|
|
|
_adamMapMarkPos.y = -1;
|
2017-01-15 22:59:50 +01:00
|
|
|
addTime(_globals->_travelTime);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var100 = _globals->_roomPtr->_id;
|
|
|
|
_globals->_roomNum = _globals->_newRoomNum;
|
|
|
|
_globals->_areaNum = _globals->_roomNum >> 8;
|
|
|
|
_globals->_eventType = EventType::etEvent5;
|
|
|
|
_globals->_newMusicType = MusicType::mt2;
|
2016-12-31 05:11:33 -08:00
|
|
|
setCharacterHere();
|
2016-09-14 23:39:27 +02:00
|
|
|
musique();
|
2017-01-01 11:51:48 -08:00
|
|
|
updateRoom1(_globals->_roomNum);
|
2016-09-25 23:17:25 +02:00
|
|
|
drawTopScreen();
|
2016-09-30 07:48:27 +02:00
|
|
|
_adamMapMarkPos.x = -1;
|
|
|
|
_adamMapMarkPos.y = -1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::deplaval(uint16 roomNum) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_newLocation = roomNum & 0xFF;
|
|
|
|
_globals->_valleyVidNum = 0;
|
|
|
|
_globals->_phaseActionsCount++;
|
2016-12-28 03:43:13 -08:00
|
|
|
closeRoom();
|
|
|
|
endCharacterSpeech();
|
2016-10-24 00:04:32 +02:00
|
|
|
byte c1 = roomNum & 0xFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (c1 == 0)
|
|
|
|
return;
|
2017-01-18 23:05:38 +01:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
if (c1 < 0x80) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_displayFlags = DisplayFlags::dfFlag1;
|
2016-12-04 13:15:38 -08:00
|
|
|
setChoiceYes();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eventType = EventType::etEvent1;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-12-04 13:15:38 -08:00
|
|
|
if (!isAnswerYes())
|
2016-08-18 13:15:54 +02:00
|
|
|
return;
|
2017-01-18 23:05:38 +01:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_var113) {
|
2016-12-04 13:15:38 -08:00
|
|
|
waitEndSpeak();
|
2017-01-01 14:14:02 -08:00
|
|
|
if (!_vm->shouldQuit())
|
2016-12-28 03:43:13 -08:00
|
|
|
closeCharacterScreen();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
specialout();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_areaPtr->_type == AreaType::atValley) {
|
2017-01-15 22:59:50 +01:00
|
|
|
addTime(32);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_stepsToFindAppleFast++;
|
|
|
|
_globals->_stepsToFindAppleNormal++;
|
|
|
|
}
|
|
|
|
faire_suivre((roomNum & 0xFF00) | _globals->_newLocation);
|
|
|
|
_globals->_var100 = _globals->_roomPtr->_id;
|
|
|
|
_globals->_roomNum = roomNum;
|
|
|
|
_globals->_areaNum = roomNum >> 8;
|
|
|
|
_globals->_eventType = EventType::etEvent5;
|
2016-12-31 05:11:33 -08:00
|
|
|
setCharacterHere();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_newMusicType = MusicType::mtNormal;
|
2016-08-18 13:15:54 +02:00
|
|
|
musique();
|
2016-12-19 13:41:00 -08:00
|
|
|
updateRoom1(roomNum);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_chronoFlag = 0;
|
|
|
|
_globals->_chrono = 0;
|
|
|
|
_globals->_var54 = 0;
|
|
|
|
if (_globals->_roomCharacterType == PersonFlags::pftTyrann)
|
2016-12-11 13:44:58 -08:00
|
|
|
setChrono(3000);
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (c1 == 0xFF) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eventType = EventType::etEventE;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2017-01-15 23:51:17 +01:00
|
|
|
if (!kPersons[PER_ELOI]._roomNum && checkEloiReturn())
|
2016-12-11 13:44:58 -08:00
|
|
|
setChrono(800);
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_stepsToFindAppleFast = 0;
|
2016-10-24 00:04:32 +02:00
|
|
|
byte newAreaNum = c1 & 0x7F;
|
2017-01-01 11:51:48 -08:00
|
|
|
byte curAreaNum = _globals->_roomNum >> 8;
|
2016-10-24 00:04:32 +02:00
|
|
|
int16 newRoomNum = newAreaNum << 8;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (curAreaNum == Areas::arTausCave && newAreaNum == Areas::arMo)
|
|
|
|
newRoomNum |= 0x16;
|
|
|
|
else if (curAreaNum == Areas::arMoorkusLair)
|
|
|
|
newRoomNum |= 4;
|
|
|
|
else
|
|
|
|
newRoomNum |= 1;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_newRoomNum = newRoomNum;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (newAreaNum == Areas::arTausCave)
|
2016-12-26 12:35:21 -08:00
|
|
|
gotoPlace(&gotos[0]);
|
2016-09-14 23:39:27 +02:00
|
|
|
else {
|
2016-12-17 09:32:43 -08:00
|
|
|
for (Goto *go = gotos + 1; go->_curAreaNum != 0xFF; go++) {
|
2016-12-15 22:47:29 -08:00
|
|
|
if (go->_curAreaNum == curAreaNum) {
|
2016-12-26 12:35:21 -08:00
|
|
|
gotoPlace(go);
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-26 23:44:42 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
// Original name: deplacement
|
|
|
|
void EdenGame::move(Direction dir) {
|
2017-01-01 11:51:48 -08:00
|
|
|
Room *room = _globals->_roomPtr;
|
|
|
|
int16 roomNum = _globals->_roomNum;
|
2016-10-24 00:04:32 +02:00
|
|
|
debug("move: from room %4X", roomNum);
|
2016-09-26 07:57:27 +02:00
|
|
|
char newLoc = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
rundcurs();
|
2016-12-26 13:40:28 -08:00
|
|
|
display();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_prevLocation = roomNum & 0xFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
switch (dir) {
|
2016-09-25 00:33:07 +02:00
|
|
|
case kCryoNorth:
|
2016-12-15 22:47:29 -08:00
|
|
|
newLoc = room->_exits[0];
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-09-25 00:33:07 +02:00
|
|
|
case kCryoEast:
|
2016-12-15 22:47:29 -08:00
|
|
|
newLoc = room->_exits[1];
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-09-25 00:33:07 +02:00
|
|
|
case kCryoSouth:
|
2016-12-15 22:47:29 -08:00
|
|
|
newLoc = room->_exits[2];
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-09-25 00:33:07 +02:00
|
|
|
case kCryoWest:
|
2016-12-15 22:47:29 -08:00
|
|
|
newLoc = room->_exits[3];
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
deplaval((roomNum & 0xFF00) | newLoc);
|
|
|
|
}
|
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
// Original name: deplacement2
|
|
|
|
void EdenGame::move2(Direction dir) {
|
2017-01-01 11:51:48 -08:00
|
|
|
Room *room = _globals->_roomPtr;
|
|
|
|
int16 roomNum = _globals->_roomNum;
|
2016-09-26 07:57:27 +02:00
|
|
|
char newLoc = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_prevLocation = roomNum & 0xFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
switch (dir) {
|
2016-09-25 00:33:07 +02:00
|
|
|
case kCryoNorth:
|
2016-12-15 22:47:29 -08:00
|
|
|
newLoc = room->_exits[0];
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-09-25 00:33:07 +02:00
|
|
|
case kCryoEast:
|
2016-12-15 22:47:29 -08:00
|
|
|
newLoc = room->_exits[1];
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-09-25 00:33:07 +02:00
|
|
|
case kCryoSouth:
|
2016-12-15 22:47:29 -08:00
|
|
|
newLoc = room->_exits[2];
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-09-25 00:33:07 +02:00
|
|
|
case kCryoWest:
|
2016-12-15 22:47:29 -08:00
|
|
|
newLoc = room->_exits[3];
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
deplaval((roomNum & 0xFF00) | newLoc);
|
|
|
|
}
|
|
|
|
|
2016-12-26 12:35:21 -08:00
|
|
|
// Original name: dinosoufle
|
2017-01-16 22:27:25 +01:00
|
|
|
void EdenGame::actionDinoBlow() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId == 0) {
|
2017-01-14 00:30:37 +01:00
|
|
|
hideBars();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(148);
|
2016-09-14 23:39:27 +02:00
|
|
|
maj2();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 23:14:03 -08:00
|
|
|
// Original name: plaquemonk
|
|
|
|
void EdenGame::actionPlateMonk() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId != 0) {
|
|
|
|
if (_globals->_curObjectId == Objects::obPrism) {
|
2016-09-26 23:44:42 +02:00
|
|
|
loseObject(Objects::obPrism);
|
2017-01-14 00:30:37 +01:00
|
|
|
hideBars();
|
2016-12-18 14:13:36 -08:00
|
|
|
_specialTextMode = true;
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(89);
|
2016-09-30 07:48:27 +02:00
|
|
|
// CHECKME: Unused code
|
|
|
|
// word_2F514 |= 0x8000;
|
2016-08-18 13:15:54 +02:00
|
|
|
maj2();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eventType = EventType::etEventB;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2017-01-14 00:30:37 +01:00
|
|
|
hideBars();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(7);
|
2016-09-14 23:39:27 +02:00
|
|
|
maj2();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eventType = EventType::etEvent4;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 23:14:03 -08:00
|
|
|
// Original name: fresquesgraa
|
|
|
|
void EdenGame::actionGraaFrescoe() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId == 0) {
|
|
|
|
_globals->_frescoeWidth = 320;
|
|
|
|
_globals->_frescoeImgBank = 113;
|
2016-09-26 23:44:42 +02:00
|
|
|
doFrescoes();
|
2016-12-19 13:41:00 -08:00
|
|
|
handleDinaDialog();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 23:14:03 -08:00
|
|
|
// Original name: fresqueslasc
|
|
|
|
void EdenGame::actionLascFrescoe() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId == 0) {
|
|
|
|
_globals->_frescoeWidth = 112;
|
|
|
|
_globals->_frescoeImgBank = 315;
|
2016-09-26 23:44:42 +02:00
|
|
|
doFrescoes();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 23:14:03 -08:00
|
|
|
// Original name: pushpierre
|
|
|
|
void EdenGame::actionPushStone() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId == 0) {
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[22]._exits[0] = 17;
|
|
|
|
_gameRooms[26]._exits[2] = 9;
|
2016-09-26 23:44:42 +02:00
|
|
|
move(kCryoNorth);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 23:14:03 -08:00
|
|
|
// Original name: tetemomie
|
|
|
|
void EdenGame::actionMummyHead() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId == Objects::obTooth) {
|
|
|
|
_globals->_gameFlags |= GameFlags::gfMummyOpened;
|
2016-09-26 23:44:42 +02:00
|
|
|
move(kCryoNorth);
|
2017-01-01 11:51:48 -08:00
|
|
|
} else if (_globals->_curObjectId == 0) {
|
|
|
|
if (_globals->_gameFlags & GameFlags::gfMummyOpened)
|
2016-09-26 23:44:42 +02:00
|
|
|
move(kCryoNorth);
|
2016-09-14 23:39:27 +02:00
|
|
|
else {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eventType = EventType::etEvent6;
|
2016-12-11 22:52:10 -08:00
|
|
|
handleCharacterDialog(PersonId::pidMonk);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eventType = 0;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 23:14:03 -08:00
|
|
|
// Original name: tetesquel
|
2016-12-26 12:35:21 -08:00
|
|
|
void EdenGame::actionSkelettonHead() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId == Objects::obTooth) {
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[22]._exits[0] = 16;
|
|
|
|
_gameRooms[26]._exits[2] = 13;
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[16]._cursorId |= 0x8000;
|
2016-09-26 23:44:42 +02:00
|
|
|
loseObject(Objects::obTooth);
|
|
|
|
move(kCryoNorth);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 23:14:03 -08:00
|
|
|
// Original name: squelmoorkong
|
2016-12-26 12:35:21 -08:00
|
|
|
void EdenGame::actionSkelettonMoorkong() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eventType = EventType::etEvent9;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-26 12:35:21 -08:00
|
|
|
// Original name: choisir
|
|
|
|
void EdenGame::actionChoose() {
|
2016-12-19 22:32:40 -08:00
|
|
|
byte objid = _curSpot2->_objectId;
|
2016-09-26 07:57:27 +02:00
|
|
|
byte obj;
|
2016-09-14 23:39:27 +02:00
|
|
|
switch (objid) {
|
|
|
|
case 0:
|
2017-01-01 11:51:48 -08:00
|
|
|
obj = _globals->_giveObj1;
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2017-01-01 11:51:48 -08:00
|
|
|
obj = _globals->_giveObj2;
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2017-01-01 11:51:48 -08:00
|
|
|
obj = _globals->_giveObj3;
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-09-26 07:57:27 +02:00
|
|
|
default:
|
2017-01-18 23:05:38 +01:00
|
|
|
warning("Unexpected objid in actionChoose()");
|
2016-09-26 07:57:27 +02:00
|
|
|
return;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
objectmain(obj);
|
2016-12-04 14:26:44 -08:00
|
|
|
winObject(obj);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_iconsIndex = 16;
|
|
|
|
_globals->_autoDialog = false;
|
|
|
|
_globals->_var60 = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
parle_moi();
|
|
|
|
}
|
|
|
|
|
2016-12-19 13:41:00 -08:00
|
|
|
// Original name: dinaparle
|
|
|
|
void EdenGame::handleDinaDialog() {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso = &kPersons[PER_DINA];
|
2017-01-01 11:51:48 -08:00
|
|
|
if (perso->_partyMask & (_globals->_party | _globals->_partyOutside)) {
|
|
|
|
if (_globals->_frescoNumber < 3)
|
|
|
|
_globals->_frescoNumber = 3;
|
|
|
|
_globals->_frescoNumber++;
|
|
|
|
if (_globals->_frescoNumber < 15) {
|
2016-12-28 03:43:13 -08:00
|
|
|
endCharacterSpeech();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_frescoNumber == 7 && _globals->_phaseNum == 113)
|
2016-12-19 22:32:40 -08:00
|
|
|
incPhase();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterPtr = perso;
|
|
|
|
_globals->_dialogType = DialogType::dtInspect;
|
2017-01-21 01:12:01 +01:00
|
|
|
int16 num = (perso->_id << 3) | DialogType::dtInspect; //TODO: combine
|
2017-01-18 23:05:38 +01:00
|
|
|
bool res = dialoscansvmas((Dialog *)getElem(_gameDialogs, num));
|
2016-09-30 07:48:27 +02:00
|
|
|
_frescoTalk = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (res) {
|
2016-12-26 13:40:28 -08:00
|
|
|
restoreUnderSubtitles();
|
2016-09-30 07:48:27 +02:00
|
|
|
_frescoTalk = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
persovox();
|
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varCA = 0;
|
|
|
|
_globals->_dialogType = DialogType::dtTalk;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else
|
2016-12-26 12:35:21 -08:00
|
|
|
actionEndFrescoes();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-11 22:52:10 -08:00
|
|
|
// Original name: roiparle
|
|
|
|
void EdenGame::handleKingDialog() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_phaseNum <= 400)
|
2016-12-11 22:52:10 -08:00
|
|
|
handleCharacterDialog(0);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-11 22:52:10 -08:00
|
|
|
// Original name: roiparle1
|
2016-12-25 23:14:03 -08:00
|
|
|
void EdenGame::actionKingDialog1() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId == Objects::obSword) {
|
|
|
|
_globals->_gameFlags |= GameFlags::gfFlag80;
|
2017-01-14 00:30:37 +01:00
|
|
|
hideBars();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(76);
|
|
|
|
move2(kCryoNorth);
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_frescoNumber = 1;
|
2016-12-11 22:52:10 -08:00
|
|
|
handleKingDialog();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-11 22:52:10 -08:00
|
|
|
// Original name: roiparle2
|
2016-12-25 23:14:03 -08:00
|
|
|
void EdenGame::actionKingDialog2() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_frescoNumber = 2;
|
2016-12-11 22:52:10 -08:00
|
|
|
handleKingDialog();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-11 22:52:10 -08:00
|
|
|
// Original name: roiparle3
|
2016-12-25 23:14:03 -08:00
|
|
|
void EdenGame::actionKingDialog3() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_frescoNumber = 3;
|
2016-12-11 22:52:10 -08:00
|
|
|
handleKingDialog();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 13:41:00 -08:00
|
|
|
// Original name: getcouteau
|
2016-12-26 12:35:21 -08:00
|
|
|
void EdenGame::actionGetKnife() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_phaseNum >= 80) {
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[113]._video = 0;
|
2016-12-11 22:52:10 -08:00
|
|
|
getObject(Objects::obKnife);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eventType = EventType::etEvent7;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 13:41:00 -08:00
|
|
|
// Original name: getprisme
|
2016-12-26 12:35:21 -08:00
|
|
|
void EdenGame::actionGetPrism() {
|
2016-12-11 22:52:10 -08:00
|
|
|
getObject(Objects::obPrism);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eventType = EventType::etEvent7;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 13:41:00 -08:00
|
|
|
// Original name: getchampb
|
2016-12-26 12:35:21 -08:00
|
|
|
void EdenGame::actionGetMushroom() {
|
2016-12-11 22:52:10 -08:00
|
|
|
getObject(Objects::obShroom);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 13:41:00 -08:00
|
|
|
// Original name: getchampm
|
2016-12-26 12:35:21 -08:00
|
|
|
void EdenGame::actionGetBadMushroom() {
|
2016-12-11 22:52:10 -08:00
|
|
|
getObject(Objects::obBadShroom);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 13:41:00 -08:00
|
|
|
// Original name: getor
|
2016-12-26 12:35:21 -08:00
|
|
|
void EdenGame::actionGetGold() {
|
2016-12-11 22:52:10 -08:00
|
|
|
getObject(Objects::obGold);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 13:41:00 -08:00
|
|
|
// Original name: getnido
|
2016-12-26 12:35:21 -08:00
|
|
|
void EdenGame::actionGetFullNest() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId != 0)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomPtr->_bank = 282; //TODO: fix me
|
|
|
|
_globals->_roomPtr--;
|
|
|
|
_globals->_roomPtr->_bank = 281; //TODO: fix me
|
|
|
|
_globals->_roomPtr->_id = 3;
|
2016-12-11 22:52:10 -08:00
|
|
|
getObject(Objects::obFullNest);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 13:41:00 -08:00
|
|
|
// Original name: getnidv
|
2016-12-26 12:35:21 -08:00
|
|
|
void EdenGame::actionGetEmptyNest() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId != 0)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomPtr->_bank = 282; //TODO: fix me
|
|
|
|
_globals->_roomPtr--;
|
|
|
|
_globals->_roomPtr->_bank = 281; //TODO: fix me
|
|
|
|
_globals->_roomPtr->_id = 3;
|
2016-12-11 22:52:10 -08:00
|
|
|
getObject(Objects::obNest);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 13:41:00 -08:00
|
|
|
// Original name: getcorne
|
2016-12-26 12:35:21 -08:00
|
|
|
void EdenGame::actionGetHorn() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId != 0)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-11 22:52:10 -08:00
|
|
|
getObject(Objects::obHorn);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eventType = EventType::etEvent7;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-09-14 23:39:27 +02:00
|
|
|
bigphase1();
|
2016-12-31 05:11:33 -08:00
|
|
|
setCharacterHere();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomPtr = getRoom(_globals->_roomNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 13:41:00 -08:00
|
|
|
// Original name: getsoleil
|
2016-12-26 12:35:21 -08:00
|
|
|
void EdenGame::actionGetSunStone() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId != 0)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[238]._video = 0;
|
|
|
|
_gameRooms[238]._flags = RoomFlags::rf80;
|
2016-12-11 22:52:10 -08:00
|
|
|
getObject(Objects::obSunStone);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 13:41:00 -08:00
|
|
|
// Original name: getoueuf
|
2016-12-26 12:35:21 -08:00
|
|
|
void EdenGame::actionGetEgg() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId != 0)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomPtr->_flags = 0;
|
|
|
|
_globals->_roomPtr->_video = 0;
|
2016-12-11 22:52:10 -08:00
|
|
|
getObject(Objects::obEgg);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 13:41:00 -08:00
|
|
|
// Original name: getplaque
|
2016-12-26 12:35:21 -08:00
|
|
|
void EdenGame::actionGetTablet() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId != 0 && _globals->_curObjectId < Objects::obTablet1)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curObjectId = 0;
|
2016-12-11 22:52:10 -08:00
|
|
|
getObject(Objects::obTablet2);
|
2016-12-04 13:15:38 -08:00
|
|
|
putObject();
|
2016-10-24 22:02:43 +02:00
|
|
|
for (int i = 0; i < 6; i++)
|
2016-12-04 14:26:44 -08:00
|
|
|
_objects[Objects::obTablet1 - 1 + i]._count = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curObjectFlags = 0;
|
|
|
|
_globals->_inventoryScrollPos = 0;
|
|
|
|
_globals->_curObjectCursor = 9;
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[16]._cursorId |= 0x8000;
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[131]._video = 0;
|
2017-01-14 00:30:37 +01:00
|
|
|
hideBars();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(149);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varF1 = RoomFlags::rf04;
|
|
|
|
_globals->_drawFlags = DrawFlags::drDrawFlag20;
|
2016-12-18 13:09:56 -08:00
|
|
|
_normalCursor = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
maj2();
|
|
|
|
}
|
|
|
|
|
2016-12-25 23:14:03 -08:00
|
|
|
// Original name: voirlac
|
|
|
|
void EdenGame::actionLookLake() {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso = &kPersons[PER_MORKUS];
|
2017-01-01 11:51:48 -08:00
|
|
|
Room *room = _globals->_roomPtr;
|
|
|
|
Area *area = _globals->_areaPtr;
|
|
|
|
int16 vid = _globals->_curObjectId == Objects::obApple ? 81 : 54;
|
2016-10-07 00:45:08 +02:00
|
|
|
for (++perso; perso->_roomNum != 0xFFFF; perso++) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (perso->_roomNum != _globals->_roomNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
|
|
|
vid++;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId != Objects::obApple)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue; //TODO: pc breaks here
|
2016-10-07 00:45:08 +02:00
|
|
|
if ((perso->_flags & PersonFlags::pfTypeMask) != PersonFlags::pftMosasaurus)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (!(perso->_flags & PersonFlags::pf80))
|
2016-08-18 13:15:54 +02:00
|
|
|
return;
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags &= ~PersonFlags::pf80; //TODO: useless? see above
|
2016-12-04 14:26:44 -08:00
|
|
|
area->_flags |= AreaFlags::afFlag8;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curAreaFlags |= AreaFlags::afFlag8;
|
2016-12-15 22:47:29 -08:00
|
|
|
room->_id = 3;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
debug("sea monster: room = %X, d0 = %X\n", _globals->_roomNum, _globals->_roomImgBank);
|
2017-01-14 00:30:37 +01:00
|
|
|
hideBars();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(vid);
|
2017-01-01 11:51:48 -08:00
|
|
|
updateRoom(_globals->_roomNum); //TODO: getting memory trashed here?
|
|
|
|
if (_globals->_curObjectId == Objects::obApple)
|
2016-09-26 23:44:42 +02:00
|
|
|
loseObject(Objects::obApple);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eventType = EventType::etEventF;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 23:14:03 -08:00
|
|
|
// Original name: gotohall
|
|
|
|
void EdenGame::actionGotoHall() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_prevLocation = _globals->_roomNum & 0xFF;
|
|
|
|
deplaval((_globals->_roomNum & 0xFF00) | 6);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 23:14:03 -08:00
|
|
|
// Original name: demitourlabi
|
|
|
|
void EdenGame::actionLabyrinthTurnAround() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_prevLocation = _globals->_roomNum & 0xFF;
|
|
|
|
_globals->_var100 = 0xFF;
|
|
|
|
uint16 target = (_globals->_roomNum & 0xFF00) | _globals->_roomPtr->_exits[2];
|
2016-09-14 23:39:27 +02:00
|
|
|
faire_suivre(target);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomNum = target;
|
|
|
|
_globals->_eventType = EventType::etEvent5;
|
|
|
|
updateRoom(_globals->_roomNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 23:14:03 -08:00
|
|
|
// Original name: gotonido
|
2016-12-26 12:35:21 -08:00
|
|
|
void EdenGame::actionGotoFullNest() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomPtr++;
|
|
|
|
_globals->_eventType = 0;
|
|
|
|
_globals->_roomImgBank = _globals->_roomPtr->_bank;
|
|
|
|
_globals->_roomVidNum = _globals->_roomPtr->_video;
|
|
|
|
_globals->_curRoomFlags = _globals->_roomPtr->_flags;
|
|
|
|
_globals->_varF1 = _globals->_roomPtr->_flags;
|
2016-09-14 23:39:27 +02:00
|
|
|
animpiece();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var100 = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
maj2();
|
|
|
|
}
|
|
|
|
|
2016-12-26 12:35:21 -08:00
|
|
|
// Original name: gotoval
|
|
|
|
void EdenGame::actionGotoVal() {
|
2017-01-01 11:51:48 -08:00
|
|
|
uint16 target = _globals->_roomNum;
|
2016-09-14 23:39:27 +02:00
|
|
|
rundcurs();
|
2016-12-26 13:40:28 -08:00
|
|
|
display();
|
2016-09-30 07:48:27 +02:00
|
|
|
_scrollPos = 0;
|
2017-01-21 01:12:01 +01:00
|
|
|
char obj = _curSpot2->_objectId - 14; //TODO
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_prevLocation = target & 0xFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
deplaval((target & 0xFF00) | obj); //TODO careful!
|
|
|
|
}
|
|
|
|
|
2016-12-26 12:35:21 -08:00
|
|
|
// Original name: visiter
|
|
|
|
void EdenGame::actionVisit() {
|
2017-01-14 00:30:37 +01:00
|
|
|
hideBars();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(144);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varF1 = RoomFlags::rf04;
|
2016-09-14 23:39:27 +02:00
|
|
|
maj2();
|
|
|
|
}
|
|
|
|
|
2016-12-26 12:35:21 -08:00
|
|
|
// Original name: final
|
|
|
|
void EdenGame::actionFinal() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId != 0)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-26 12:35:21 -08:00
|
|
|
|
2017-01-14 00:30:37 +01:00
|
|
|
hideBars();
|
2016-12-18 14:13:36 -08:00
|
|
|
*(int16 *)(_gameRooms + 0x6DC) = 319; //TODO
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomImgBank = 319;
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(97);
|
2016-09-14 23:39:27 +02:00
|
|
|
maj2();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eventType = EventType::etEvent12;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_narratorSequence = 54;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-27 07:53:50 +02:00
|
|
|
// Original name: goto_nord
|
2016-12-25 23:14:03 -08:00
|
|
|
void EdenGame::actionMoveNorth() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId == 0)
|
2016-09-26 23:44:42 +02:00
|
|
|
move(kCryoNorth);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-27 07:53:50 +02:00
|
|
|
// Original name: goto_est
|
2016-12-25 23:14:03 -08:00
|
|
|
void EdenGame::actionMoveEast() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId == 0)
|
2016-09-26 23:44:42 +02:00
|
|
|
move(kCryoEast);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-27 07:53:50 +02:00
|
|
|
// Original name: goto_sud
|
2016-12-25 23:14:03 -08:00
|
|
|
void EdenGame::actionMoveSouth() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId == 0)
|
2016-09-26 23:44:42 +02:00
|
|
|
move(kCryoSouth);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-27 07:53:50 +02:00
|
|
|
// Original name: goto_ouest
|
2016-12-25 23:14:03 -08:00
|
|
|
void EdenGame::actionMoveWest() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId == 0)
|
2016-09-26 23:44:42 +02:00
|
|
|
move(kCryoWest);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-26 13:40:28 -08:00
|
|
|
// Original name: afficher
|
|
|
|
void EdenGame::display() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!_globals->_mirrorEffect && !_globals->_var103) {
|
2016-12-18 14:13:36 -08:00
|
|
|
if (_paletteUpdateRequired) {
|
|
|
|
_paletteUpdateRequired = false;
|
2016-12-25 13:45:47 -08:00
|
|
|
CLPalette_Send2Screen(_globalPalette, 0, 256);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-18 14:13:36 -08:00
|
|
|
CLBlitter_CopyView2Screen(_mainView);
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_mirrorEffect)
|
2016-12-31 05:11:33 -08:00
|
|
|
displayEffect3();
|
2016-09-14 23:39:27 +02:00
|
|
|
else
|
2016-12-31 05:11:33 -08:00
|
|
|
displayEffect2();
|
2016-10-25 23:32:15 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var103 = 0;
|
|
|
|
_globals->_mirrorEffect = 0;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::afficher128() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_updatePaletteFlag == 16) {
|
2016-12-25 13:45:47 -08:00
|
|
|
CLPalette_Send2Screen(_globalPalette, 0, 129);
|
2016-12-18 14:13:36 -08:00
|
|
|
CLBlitter_CopyView2Screen(_mainView);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_updatePaletteFlag = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-12-31 05:11:33 -08:00
|
|
|
clearScreen();
|
|
|
|
fadeToBlackLowPalette(1);
|
2016-12-18 14:13:36 -08:00
|
|
|
if (_showBlackBars)
|
2016-09-28 07:29:12 +02:00
|
|
|
drawBlackBars();
|
2016-12-18 14:13:36 -08:00
|
|
|
CLBlitter_CopyView2Screen(_mainView);
|
2016-12-31 05:11:33 -08:00
|
|
|
fadeFromBlackLowPalette(1);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-27 07:53:50 +02:00
|
|
|
// Original name: sauvefrises
|
|
|
|
void EdenGame::saveFriezes() {
|
|
|
|
saveTopFrieze(0);
|
|
|
|
saveBottomFrieze();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-27 07:53:50 +02:00
|
|
|
// Original name: sauvefriseshaut
|
|
|
|
void EdenGame::saveTopFrieze(int16 x) { // Save top bar
|
2016-09-30 07:48:27 +02:00
|
|
|
_underTopBarScreenRect = Common::Rect(x, 0, x + 320 - 1, 15);
|
|
|
|
_underTopBarBackupRect = Common::Rect(0, 0, 320 - 1, 15);
|
2017-01-01 11:51:48 -08:00
|
|
|
CLBlitter_CopyViewRect(_mainView, _underBarsView, &_underTopBarScreenRect, &_underTopBarBackupRect);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-27 07:53:50 +02:00
|
|
|
// Original name: sauvefrisesbas
|
|
|
|
void EdenGame::saveBottomFrieze() { // Save bottom bar
|
2016-09-30 07:48:27 +02:00
|
|
|
_underBottomBarScreenRect.left = 0;
|
|
|
|
_underBottomBarScreenRect.right = 320 - 1;
|
2017-01-01 11:51:48 -08:00
|
|
|
CLBlitter_CopyViewRect(_mainView, _underBarsView, &_underBottomBarScreenRect, &_underBottomBarBackupRect);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-27 07:53:50 +02:00
|
|
|
// Original name: restaurefrises
|
|
|
|
void EdenGame::restoreFriezes() {
|
|
|
|
restoreTopFrieze();
|
|
|
|
restoreBottomFrieze();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-27 07:53:50 +02:00
|
|
|
// Original name: restaurefriseshaut
|
|
|
|
void EdenGame::restoreTopFrieze() {
|
2016-09-30 07:48:27 +02:00
|
|
|
_underTopBarScreenRect.left = _scrollPos;
|
|
|
|
_underTopBarScreenRect.right = _scrollPos + 320 - 1;
|
2017-01-01 11:51:48 -08:00
|
|
|
CLBlitter_CopyViewRect(_underBarsView, _mainView, &_underTopBarBackupRect, &_underTopBarScreenRect);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-27 07:53:50 +02:00
|
|
|
// Original name: restaurefrisesbas
|
|
|
|
void EdenGame::restoreBottomFrieze() {
|
2016-09-30 07:48:27 +02:00
|
|
|
_underBottomBarScreenRect.left = _scrollPos;
|
|
|
|
_underBottomBarScreenRect.right = _scrollPos + 320 - 1;
|
2017-01-01 11:51:48 -08:00
|
|
|
CLBlitter_CopyViewRect(_underBarsView, _mainView, &_underBottomBarBackupRect, &_underBottomBarScreenRect);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 02:17:07 -08:00
|
|
|
void EdenGame::useMainBank() {
|
2016-12-04 14:54:58 -08:00
|
|
|
_bankData = _mainBankBuf;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 02:17:07 -08:00
|
|
|
void EdenGame::useCharacterBank() {
|
|
|
|
_bankData = _characterBankData;
|
|
|
|
}
|
|
|
|
|
2016-10-07 23:06:10 +02:00
|
|
|
// Original name: use_bank
|
|
|
|
void EdenGame::useBank(int16 bank) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (bank > 2500)
|
2016-10-07 23:06:10 +02:00
|
|
|
error("attempt to load bad bank %d", bank);
|
|
|
|
|
2016-12-18 14:13:36 -08:00
|
|
|
_bankData = _bankDataBuf;
|
2016-10-07 23:06:10 +02:00
|
|
|
if (_curBankNum != bank) {
|
2016-12-18 14:13:36 -08:00
|
|
|
loadRawFile(bank, _bankDataBuf);
|
|
|
|
verifh(_bankDataBuf);
|
2016-10-07 23:06:10 +02:00
|
|
|
_curBankNum = bank;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::sundcurs(int16 x, int16 y) {
|
2016-09-30 07:48:27 +02:00
|
|
|
byte *keep = _cursKeepBuf;
|
|
|
|
_cursKeepPos = Common::Point(x - 4, y - 4);
|
2016-12-29 06:28:11 -08:00
|
|
|
byte *scr = _mainViewBuf + _cursKeepPos.x + _cursKeepPos.y * 640;
|
2016-09-28 07:29:12 +02:00
|
|
|
for (int16 h = 48; h--;) {
|
|
|
|
for (int16 w = 48; w--;)
|
2016-09-14 23:39:27 +02:00
|
|
|
*keep++ = *scr++;
|
|
|
|
scr += 640 - 48;
|
|
|
|
}
|
2016-12-18 13:09:56 -08:00
|
|
|
_cursorSaved = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::rundcurs() {
|
2016-09-30 07:48:27 +02:00
|
|
|
byte *keep = _cursKeepBuf;
|
2016-12-29 06:28:11 -08:00
|
|
|
byte *scr = _mainViewBuf + _cursKeepPos.x + _cursKeepPos.y * 640;
|
2016-12-18 13:09:56 -08:00
|
|
|
if (!_cursorSaved || (_cursKeepPos == Common::Point(-1, -1))) //TODO ...
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-09-28 07:29:12 +02:00
|
|
|
|
|
|
|
for (int16 h = 48; h--;) {
|
|
|
|
for (int16 w = 48; w--;)
|
2016-09-14 23:39:27 +02:00
|
|
|
*scr++ = *keep++;
|
|
|
|
scr += 640 - 48;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::noclipax(int16 index, int16 x, int16 y) {
|
2016-12-04 14:26:44 -08:00
|
|
|
byte *pix = _bankData;
|
2016-12-29 06:28:11 -08:00
|
|
|
byte *scr = _mainViewBuf + x + y * 640;
|
2016-11-13 13:56:20 -08:00
|
|
|
if (_curBankNum != 117 && !_noPalette) {
|
2016-12-04 14:54:58 -08:00
|
|
|
if (READ_LE_UINT16(pix) > 2)
|
2016-09-28 07:29:12 +02:00
|
|
|
readPalette(pix + 2);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-04 14:54:58 -08:00
|
|
|
pix += READ_LE_UINT16(pix);
|
|
|
|
pix += READ_LE_UINT16(pix + index * 2);
|
2016-09-14 23:48:01 +02:00
|
|
|
// int16 height:9
|
|
|
|
// int16 pad:6;
|
|
|
|
// int16 flag:1;
|
2016-12-26 13:40:28 -08:00
|
|
|
byte h0 = *pix++;
|
|
|
|
byte h1 = *pix++;
|
|
|
|
int16 w = ((h1 & 1) << 8) | h0;
|
|
|
|
int16 h = *pix++;
|
|
|
|
byte mode = *pix++;
|
2016-09-14 23:39:27 +02:00
|
|
|
debug("- draw sprite %d at %d:%d, %dx%d", index, x, y, w, h);
|
|
|
|
if (mode != 0xFF && mode != 0xFE)
|
|
|
|
return;
|
|
|
|
if (y + h > 200)
|
|
|
|
h -= (y + h - 200);
|
|
|
|
if (h1 & 0x80) {
|
|
|
|
// compressed
|
|
|
|
for (; h-- > 0;) {
|
2016-12-26 13:40:28 -08:00
|
|
|
for (int16 ww = w; ww > 0;) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte c = *pix++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (c >= 0x80) {
|
|
|
|
if (c == 0x80) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte fill = *pix++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (fill == 0) {
|
|
|
|
scr += 128 + 1;
|
|
|
|
ww -= 128 + 1;
|
|
|
|
} else {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte run;
|
2016-09-14 23:39:27 +02:00
|
|
|
*scr++ = fill; //TODO: wha?
|
|
|
|
*scr++ = fill;
|
|
|
|
ww -= 128 + 1;
|
|
|
|
for (run = 127; run--;)
|
|
|
|
*scr++ = fill;
|
|
|
|
}
|
|
|
|
} else {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte fill = *pix++;
|
|
|
|
byte run = 255 - c + 2;
|
2016-09-14 23:39:27 +02:00
|
|
|
ww -= run;
|
|
|
|
if (fill == 0)
|
|
|
|
scr += run;
|
|
|
|
else
|
|
|
|
for (; run--;)
|
|
|
|
*scr++ = fill;
|
|
|
|
}
|
|
|
|
} else {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte run = c + 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
ww -= run;
|
|
|
|
for (; run--;) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte p = *pix++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p == 0)
|
|
|
|
scr++;
|
|
|
|
else
|
|
|
|
*scr++ = p;
|
|
|
|
}
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += 640 - w;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
|
|
|
// uncompressed
|
|
|
|
for (; h--;) {
|
2016-12-26 13:40:28 -08:00
|
|
|
for (int16 ww = w; ww--;) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte p = *pix++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p == 0)
|
|
|
|
scr++;
|
|
|
|
else
|
|
|
|
*scr++ = p;
|
|
|
|
}
|
|
|
|
scr += 640 - w;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::noclipax_avecnoir(int16 index, int16 x, int16 y) {
|
2016-12-04 14:26:44 -08:00
|
|
|
byte *pix = _bankData;
|
2016-12-29 06:28:11 -08:00
|
|
|
byte *scr = _mainViewBuf + x + y * 640;
|
2016-10-07 23:06:10 +02:00
|
|
|
if (_curBankNum != 117) {
|
2016-12-04 14:54:58 -08:00
|
|
|
if (READ_LE_UINT16(pix) > 2)
|
2016-09-28 07:29:12 +02:00
|
|
|
readPalette(pix + 2);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-04 14:54:58 -08:00
|
|
|
pix += READ_LE_UINT16(pix);
|
|
|
|
pix += READ_LE_UINT16(pix + index * 2);
|
2016-09-14 23:48:01 +02:00
|
|
|
// int16 height:9
|
|
|
|
// int16 pad:6;
|
|
|
|
// int16 flag:1;
|
2016-12-26 13:40:28 -08:00
|
|
|
byte h0 = *pix++;
|
|
|
|
byte h1 = *pix++;
|
|
|
|
int16 w = ((h1 & 1) << 8) | h0;
|
|
|
|
int16 h = *pix++;
|
|
|
|
byte mode = *pix++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (mode != 0xFF && mode != 0xFE)
|
|
|
|
return;
|
|
|
|
if (y + h > 200)
|
|
|
|
h -= (y + h - 200);
|
|
|
|
if (h1 & 0x80) {
|
|
|
|
// compressed
|
|
|
|
for (; h-- > 0;) {
|
2016-12-26 13:40:28 -08:00
|
|
|
for (int16 ww = w; ww > 0;) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte c = *pix++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (c >= 0x80) {
|
|
|
|
if (c == 0x80) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte fill = *pix++;
|
|
|
|
byte run;
|
2016-09-14 23:39:27 +02:00
|
|
|
*scr++ = fill; //TODO: wha?
|
|
|
|
*scr++ = fill;
|
|
|
|
ww -= 128 + 1;
|
|
|
|
for (run = 127; run--;)
|
|
|
|
*scr++ = fill;
|
|
|
|
} else {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte fill = *pix++;
|
|
|
|
byte run = 255 - c + 2;
|
2016-09-14 23:39:27 +02:00
|
|
|
ww -= run;
|
|
|
|
for (; run--;)
|
|
|
|
*scr++ = fill;
|
|
|
|
}
|
|
|
|
} else {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte run = c + 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
ww -= run;
|
|
|
|
for (; run--;) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte p = *pix++;
|
2016-09-14 23:39:27 +02:00
|
|
|
*scr++ = p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
scr += 640 - w;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
|
|
|
// uncompressed
|
|
|
|
for (; h--;) {
|
2016-12-26 13:40:28 -08:00
|
|
|
for (int16 ww = w; ww--;) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte p = *pix++;
|
2016-09-14 23:39:27 +02:00
|
|
|
*scr++ = p;
|
|
|
|
}
|
|
|
|
scr += 640 - w;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::getglow(int16 x, int16 y, int16 w, int16 h) {
|
2016-12-29 06:28:11 -08:00
|
|
|
byte *scr = _mainViewBuf + x + y * 640;
|
2016-12-18 14:13:36 -08:00
|
|
|
byte *gl = _glowBuffer;
|
2016-12-18 22:58:31 -08:00
|
|
|
_glowX = x;
|
|
|
|
_glowY = y;
|
|
|
|
_glowW = w;
|
|
|
|
_glowH = h;
|
2016-09-14 23:39:27 +02:00
|
|
|
for (; h--;) {
|
2016-12-26 13:40:28 -08:00
|
|
|
for (int16 ww = w; ww--;)
|
2016-09-14 23:39:27 +02:00
|
|
|
*gl++ = *scr++;
|
|
|
|
scr += 640 - w;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::unglow() {
|
2016-12-18 14:13:36 -08:00
|
|
|
byte *gl = _glowBuffer;
|
2016-12-29 06:28:11 -08:00
|
|
|
byte *scr = _mainViewBuf + _glowX + _glowY * 640;
|
2016-12-18 22:58:31 -08:00
|
|
|
if (_glowX < 0 || _glowY < 0) //TODO: move it up
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-18 22:58:31 -08:00
|
|
|
for (; _glowH--;) {
|
2016-12-26 13:40:28 -08:00
|
|
|
for (int16 ww = _glowW; ww--;)
|
2016-09-14 23:39:27 +02:00
|
|
|
*scr++ = *gl++;
|
2016-12-18 22:58:31 -08:00
|
|
|
scr += 640 - _glowW;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::glow(int16 index) {
|
2016-09-25 23:17:25 +02:00
|
|
|
// byte pixbase;
|
2016-12-04 14:26:44 -08:00
|
|
|
byte *pix = _bankData;
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
index += 9;
|
2016-12-04 14:54:58 -08:00
|
|
|
pix += READ_LE_UINT16(pix);
|
|
|
|
pix += READ_LE_UINT16(pix + index * 2);
|
2016-09-14 23:48:01 +02:00
|
|
|
// int16 height:9
|
|
|
|
// int16 pad:6;
|
|
|
|
// int16 flag:1;
|
2016-10-24 22:02:43 +02:00
|
|
|
byte h0 = *pix++;
|
|
|
|
byte h1 = *pix++;
|
|
|
|
int16 w = ((h1 & 1) << 8) | h0;
|
|
|
|
int16 h = *pix++;
|
|
|
|
byte mode = *pix++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (mode != 0xFF && mode != 0xFE)
|
|
|
|
return;
|
|
|
|
|
2016-12-18 13:09:56 -08:00
|
|
|
int16 x = _cursorPosX + _scrollPos - 38;
|
|
|
|
int16 y = _cursorPosY - 28;
|
2017-01-01 11:51:48 -08:00
|
|
|
int16 ex = _globals->_frescoeWidth + 320;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
|
|
|
if (x + w <= 0 || x >= ex || y + h <= 0 || y >= 176)
|
|
|
|
return;
|
|
|
|
|
2016-11-13 15:46:36 -08:00
|
|
|
int16 dx;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (x < 0) {
|
|
|
|
dx = -x;
|
|
|
|
x = 0;
|
|
|
|
} else if (x + w > ex)
|
|
|
|
dx = x + w - ex;
|
|
|
|
else
|
|
|
|
dx = 0;
|
|
|
|
|
2016-12-26 13:40:28 -08:00
|
|
|
int16 dy = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (y < 16) {
|
|
|
|
dy = 16 - y;
|
|
|
|
y = 16;
|
|
|
|
} else if (y + h > 175)
|
|
|
|
dy = y + h - 175;
|
2016-11-13 15:46:36 -08:00
|
|
|
|
|
|
|
int16 pstride = dx;
|
|
|
|
int16 sstride = 640 - (w - dx);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (y == 16)
|
|
|
|
pix += w * dy;
|
|
|
|
if (x == 0)
|
|
|
|
pix += dx;
|
|
|
|
|
2016-12-29 06:28:11 -08:00
|
|
|
byte *scr = _mainViewBuf + x + y * 640;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
|
|
|
w -= dx;
|
|
|
|
h -= dy;
|
|
|
|
|
|
|
|
getglow(x, y, w, h);
|
|
|
|
|
|
|
|
for (; h--;) {
|
2016-11-13 15:46:36 -08:00
|
|
|
for (int16 ww = w; ww--;) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte p = *pix++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p == 0)
|
|
|
|
scr++;
|
|
|
|
else
|
|
|
|
*scr++ += p << 4;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
pix += pstride;
|
|
|
|
scr += sstride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-28 07:29:12 +02:00
|
|
|
void EdenGame::readPalette(byte *ptr) {
|
|
|
|
bool doit = true;
|
2016-12-25 13:45:47 -08:00
|
|
|
color3_t pal_entry;
|
2016-09-14 23:39:27 +02:00
|
|
|
while (doit) {
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 idx = *ptr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (idx != 0xFF) {
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 cnt = *ptr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
while (cnt--) {
|
|
|
|
if (idx == 0) {
|
|
|
|
pal_entry.r = 0;
|
|
|
|
pal_entry.g = 0;
|
|
|
|
pal_entry.b = 0;
|
|
|
|
ptr += 3;
|
|
|
|
} else {
|
|
|
|
pal_entry.r = *ptr++ << 10;
|
|
|
|
pal_entry.g = *ptr++ << 10;
|
|
|
|
pal_entry.b = *ptr++ << 10;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-25 13:45:47 -08:00
|
|
|
CLPalette_SetRGBColor(_globalPalette, idx, &pal_entry);
|
2016-09-14 23:39:27 +02:00
|
|
|
idx++;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
} else
|
2016-09-28 07:29:12 +02:00
|
|
|
doit = false;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-28 07:29:12 +02:00
|
|
|
// Original name: spritesurbulle
|
|
|
|
void EdenGame::spriteOnSubtitle(int16 index, int16 x, int16 y) {
|
2016-12-04 14:26:44 -08:00
|
|
|
byte *pix = _bankData;
|
2016-12-29 06:28:11 -08:00
|
|
|
byte *scr = _subtitlesViewBuf + x + y * _subtitlesXWidth;
|
2016-12-04 14:54:58 -08:00
|
|
|
if ((_curBankNum != 117) && (READ_LE_UINT16(pix) > 2))
|
2016-09-28 07:29:12 +02:00
|
|
|
readPalette(pix + 2);
|
|
|
|
|
2016-12-04 14:54:58 -08:00
|
|
|
pix += READ_LE_UINT16(pix);
|
|
|
|
pix += READ_LE_UINT16(pix + index * 2);
|
2016-09-14 23:48:01 +02:00
|
|
|
// int16 height:9
|
|
|
|
// int16 pad:6;
|
|
|
|
// int16 flag:1;
|
2016-09-28 07:29:12 +02:00
|
|
|
byte h0 = *pix++;
|
|
|
|
byte h1 = *pix++;
|
|
|
|
int16 w = ((h1 & 1) << 8) | h0;
|
|
|
|
int16 h = *pix++;
|
|
|
|
byte mode = *pix++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (mode != 0xFF && mode != 0xFE)
|
|
|
|
return;
|
|
|
|
if (h1 & 0x80) {
|
|
|
|
// compressed
|
|
|
|
for (; h-- > 0;) {
|
2016-09-28 07:29:12 +02:00
|
|
|
for (int16 ww = w; ww > 0;) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte c = *pix++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (c >= 0x80) {
|
|
|
|
if (c == 0x80) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte fill = *pix++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (fill == 0) {
|
|
|
|
scr += 128 + 1;
|
|
|
|
ww -= 128 + 1;
|
|
|
|
} else {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte run;
|
2016-08-18 13:15:54 +02:00
|
|
|
*scr++ = fill; //TODO: wha?
|
|
|
|
*scr++ = fill;
|
|
|
|
ww -= 128 + 1;
|
|
|
|
for (run = 127; run--;)
|
|
|
|
*scr++ = fill;
|
|
|
|
}
|
|
|
|
} else {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte fill = *pix++;
|
|
|
|
byte run = 255 - c + 2;
|
2016-08-18 13:15:54 +02:00
|
|
|
ww -= run;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (fill == 0)
|
|
|
|
scr += run;
|
2016-09-28 07:29:12 +02:00
|
|
|
else {
|
2016-09-14 23:39:27 +02:00
|
|
|
for (; run--;)
|
|
|
|
*scr++ = fill;
|
2016-09-28 07:29:12 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
} else {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte run = c + 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
ww -= run;
|
|
|
|
for (; run--;) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte p = *pix++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p == 0)
|
|
|
|
scr++;
|
|
|
|
else
|
2016-08-18 13:15:54 +02:00
|
|
|
*scr++ = p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-12-26 13:40:28 -08:00
|
|
|
scr += _subtitlesXWidth - w;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// uncompressed
|
|
|
|
for (; h--;) {
|
2016-09-28 07:29:12 +02:00
|
|
|
for (int16 ww = w; ww--;) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte p = *pix++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p == 0)
|
|
|
|
scr++;
|
|
|
|
else
|
2016-08-18 13:15:54 +02:00
|
|
|
*scr++ = p;
|
|
|
|
}
|
2016-12-26 13:40:28 -08:00
|
|
|
scr += _subtitlesXWidth - w;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-14 00:30:37 +01:00
|
|
|
// Original name: bars_out
|
|
|
|
void EdenGame::hideBars() {
|
2016-12-18 14:13:36 -08:00
|
|
|
if (_showBlackBars)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2016-12-26 13:40:28 -08:00
|
|
|
display();
|
2016-09-30 07:48:27 +02:00
|
|
|
_underTopBarScreenRect.left = _scrollPos;
|
|
|
|
_underTopBarScreenRect.right = _scrollPos + 320 - 1;
|
2017-01-01 11:51:48 -08:00
|
|
|
CLBlitter_CopyViewRect(_mainView, _underBarsView, &_underTopBarScreenRect, &_underTopBarBackupRect);
|
2016-09-30 07:48:27 +02:00
|
|
|
_underBottomBarScreenRect.left = _underTopBarScreenRect.left;
|
|
|
|
_underBottomBarScreenRect.right = _underTopBarScreenRect.right;
|
2017-01-01 11:51:48 -08:00
|
|
|
CLBlitter_CopyViewRect(_mainView, _underBarsView, &_underBottomBarScreenRect, &_underBottomBarBackupRect);
|
2016-09-28 07:29:12 +02:00
|
|
|
int16 r19 = 14; // TODO - init in decl?
|
|
|
|
int16 r20 = 176;
|
|
|
|
int16 r25 = 14;
|
|
|
|
int16 r24 = 21;
|
2016-09-30 07:48:27 +02:00
|
|
|
_underTopBarScreenRect.left = 0;
|
|
|
|
_underTopBarScreenRect.right = 320 - 1;
|
|
|
|
_underTopBarBackupRect.left = _scrollPos;
|
|
|
|
_underTopBarBackupRect.right = _scrollPos + 320 - 1;
|
2016-11-13 15:46:36 -08:00
|
|
|
unsigned int *scr40, *scr41, *scr42;
|
2016-09-14 23:39:27 +02:00
|
|
|
while (r24 > 0) {
|
|
|
|
if (r25 > 0) {
|
2016-09-30 07:48:27 +02:00
|
|
|
_underTopBarScreenRect.top = 16 - r25;
|
|
|
|
_underTopBarScreenRect.bottom = 16 - 1;
|
|
|
|
_underTopBarBackupRect.top = 0;
|
|
|
|
_underTopBarBackupRect.bottom = r25 - 1;
|
2017-01-01 11:51:48 -08:00
|
|
|
CLBlitter_CopyViewRect(_underBarsView, _mainView, &_underTopBarScreenRect, &_underTopBarBackupRect);
|
2016-12-29 06:28:11 -08:00
|
|
|
scr40 = ((unsigned int *)_mainViewBuf) + r19 * 640 / 4;
|
2016-09-14 23:39:27 +02:00
|
|
|
scr41 = scr40 + 640 / 4;
|
2016-10-24 22:02:43 +02:00
|
|
|
for (int i = 0; i < 320; i += 4) {
|
2016-09-14 23:39:27 +02:00
|
|
|
*scr40++ = 0;
|
|
|
|
*scr41++ = 0;
|
|
|
|
}
|
|
|
|
}
|
2016-09-30 07:48:27 +02:00
|
|
|
_underTopBarScreenRect.top = 16;
|
|
|
|
_underTopBarScreenRect.bottom = r24 + 16 - 1;
|
|
|
|
_underTopBarBackupRect.top = 200 - r24;
|
|
|
|
_underTopBarBackupRect.bottom = 200 - 1;
|
2017-01-01 11:51:48 -08:00
|
|
|
CLBlitter_CopyViewRect(_underBarsView, _mainView, &_underTopBarScreenRect, &_underTopBarBackupRect);
|
2016-12-29 06:28:11 -08:00
|
|
|
scr40 = ((unsigned int *)_mainViewBuf) + r20 * 640 / 4;
|
2016-09-14 23:39:27 +02:00
|
|
|
scr41 = scr40 + 640 / 4;
|
|
|
|
scr42 = scr41 + 640 / 4;
|
2016-10-24 22:02:43 +02:00
|
|
|
for (int i = 0; i < 320; i += 4) {
|
2016-09-14 23:39:27 +02:00
|
|
|
*scr40++ = 0;
|
|
|
|
*scr41++ = 0;
|
|
|
|
*scr42++ = 0;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
r19 -= 2;
|
|
|
|
r20 += 3;
|
|
|
|
r25 -= 2;
|
|
|
|
r24 -= 3;
|
2016-12-26 13:40:28 -08:00
|
|
|
display();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-29 06:28:11 -08:00
|
|
|
scr40 = (unsigned int *)_mainViewBuf;
|
2016-09-14 23:39:27 +02:00
|
|
|
scr41 = scr40 + 640 / 4;
|
2016-10-24 22:02:43 +02:00
|
|
|
for (int i = 0; i < 320; i += 4) {
|
2016-09-14 23:39:27 +02:00
|
|
|
*scr40++ = 0;
|
|
|
|
*scr41++ = 0;
|
|
|
|
}
|
2016-12-29 06:28:11 -08:00
|
|
|
scr40 = ((unsigned int *)_mainViewBuf) + r20 * 640 / 4;
|
2016-09-14 23:39:27 +02:00
|
|
|
scr41 = scr40 + 640 / 4;
|
|
|
|
scr42 = scr41 + 640 / 4;
|
2016-10-24 22:02:43 +02:00
|
|
|
for (int i = 0; i < 320; i += 4) {
|
2016-09-14 23:39:27 +02:00
|
|
|
*scr40++ = 0;
|
|
|
|
*scr41++ = 0;
|
|
|
|
*scr42++ = 0;
|
|
|
|
}
|
2016-12-26 13:40:28 -08:00
|
|
|
display();
|
2016-09-30 07:48:27 +02:00
|
|
|
initRects();
|
2016-12-18 14:13:36 -08:00
|
|
|
_showBlackBars = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-28 07:29:12 +02:00
|
|
|
// Original name: bars_in
|
|
|
|
void EdenGame::showBars() {
|
2016-12-18 14:13:36 -08:00
|
|
|
if (!_showBlackBars)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-09-28 07:29:12 +02:00
|
|
|
|
|
|
|
drawBlackBars();
|
|
|
|
int16 r29 = 2;
|
|
|
|
int16 r28 = 2;
|
2016-09-30 07:48:27 +02:00
|
|
|
_underTopBarScreenRect.left = 0;
|
|
|
|
_underTopBarScreenRect.right = 320 - 1;
|
|
|
|
_underTopBarBackupRect.left = _scrollPos;
|
|
|
|
_underTopBarBackupRect.right = _scrollPos + 320 - 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
while (r28 < 24) {
|
|
|
|
if (r29 <= 16) {
|
2016-09-30 07:48:27 +02:00
|
|
|
_underTopBarScreenRect.top = 16 - r29;
|
|
|
|
_underTopBarScreenRect.bottom = 16 - 1;
|
|
|
|
_underTopBarBackupRect.top = 0;
|
|
|
|
_underTopBarBackupRect.bottom = r29 - 1;
|
2017-01-01 11:51:48 -08:00
|
|
|
CLBlitter_CopyViewRect(_underBarsView, _mainView, &_underTopBarScreenRect, &_underTopBarBackupRect);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-30 07:48:27 +02:00
|
|
|
_underTopBarScreenRect.top = 16;
|
|
|
|
_underTopBarScreenRect.bottom = 16 + r28;
|
|
|
|
_underTopBarBackupRect.top = 200 - 1 - r28;
|
|
|
|
_underTopBarBackupRect.bottom = 200 - 1;
|
2017-01-01 11:51:48 -08:00
|
|
|
CLBlitter_CopyViewRect(_underBarsView, _mainView, &_underTopBarScreenRect, &_underTopBarBackupRect);
|
2016-09-14 23:39:27 +02:00
|
|
|
r29 += 2;
|
|
|
|
r28 += 3;
|
2016-12-26 13:40:28 -08:00
|
|
|
display();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-30 07:48:27 +02:00
|
|
|
initRects();
|
2016-12-18 14:13:36 -08:00
|
|
|
_showBlackBars = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2017-01-14 00:30:37 +01:00
|
|
|
// Original name: sauvefondbouche
|
|
|
|
void EdenGame::saveMouthBackground() {
|
2017-01-15 22:59:50 +01:00
|
|
|
rect_src.left = _curCharacterRect->left;
|
|
|
|
rect_src.top = _curCharacterRect->top;
|
|
|
|
rect_src.right = _curCharacterRect->right;
|
|
|
|
rect_src.bottom = _curCharacterRect->bottom;
|
|
|
|
rect_dst.left = _curCharacterRect->left + 320;
|
|
|
|
rect_dst.top = _curCharacterRect->top;
|
|
|
|
rect_dst.right = _curCharacterRect->right + 320;
|
|
|
|
rect_dst.bottom = _curCharacterRect->bottom;
|
2016-12-18 14:13:36 -08:00
|
|
|
CLBlitter_CopyViewRect(_mainView, _mainView, &rect_src, &rect_dst);
|
|
|
|
_backgroundSaved = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2017-01-14 00:30:37 +01:00
|
|
|
// Original name: restaurefondbouche
|
|
|
|
void EdenGame::restoreMouthBackground() {
|
2017-01-15 22:59:50 +01:00
|
|
|
rect_src.left = _curCharacterRect->left;
|
|
|
|
rect_src.top = _curCharacterRect->top;
|
|
|
|
rect_src.right = _curCharacterRect->right;
|
|
|
|
rect_src.bottom = _curCharacterRect->bottom;
|
|
|
|
rect_dst.left = _curCharacterRect->left + 320;
|
|
|
|
rect_dst.top = _curCharacterRect->top;
|
|
|
|
rect_dst.right = _curCharacterRect->right + 320;
|
|
|
|
rect_dst.bottom = _curCharacterRect->bottom;
|
2016-12-18 14:13:36 -08:00
|
|
|
CLBlitter_CopyViewRect(_mainView, _mainView, &rect_dst, &rect_src);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-28 07:29:12 +02:00
|
|
|
// Original name : blackbars
|
|
|
|
void EdenGame::drawBlackBars() {
|
2016-12-29 06:28:11 -08:00
|
|
|
byte *scr = _mainViewBuf;
|
2016-11-13 15:46:36 -08:00
|
|
|
for (int16 y = 0; y < 16; y++) {
|
2016-09-28 07:29:12 +02:00
|
|
|
for (int16 x = 0; x < 640; x++)
|
2016-09-14 23:39:27 +02:00
|
|
|
*scr++ = 0;
|
2016-11-13 15:46:36 -08:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += 640 * (200 - 16 - 24);
|
2016-11-13 15:46:36 -08:00
|
|
|
for (int16 y = 0; y < 24; y++) {
|
2016-09-28 07:29:12 +02:00
|
|
|
for (int16 x = 0; x < 640; x++)
|
2016-09-14 23:39:27 +02:00
|
|
|
*scr++ = 0;
|
2016-11-13 15:46:36 -08:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-25 23:17:25 +02:00
|
|
|
void EdenGame::drawTopScreen() { // Draw top bar (location / party / map)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_drawFlags &= ~DrawFlags::drDrawTopScreen;
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(314);
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(36, 83, 0);
|
2017-01-01 11:51:48 -08:00
|
|
|
noclipax(_globals->_areaPtr->_num - 1, 0, 0);
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(23, 145, 0);
|
2016-11-13 15:46:36 -08:00
|
|
|
for (perso_t *perso = &kPersons[PER_DINA]; perso != &kPersons[PER_UNKN_156]; perso++) {
|
2016-10-07 00:45:08 +02:00
|
|
|
if ((perso->_flags & PersonFlags::pfInParty) && !(perso->_flags & PersonFlags::pf80))
|
|
|
|
noclipax(perso->_targetLoc + 18, perso->_lastLoc + 120, 0);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-09-30 07:48:27 +02:00
|
|
|
_adamMapMarkPos.x = -1;
|
|
|
|
_adamMapMarkPos.y = -1;
|
2016-09-29 00:32:49 +02:00
|
|
|
displayValleyMap();
|
2016-12-18 14:13:36 -08:00
|
|
|
_paletteUpdateRequired = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-29 00:32:49 +02:00
|
|
|
// Original name: affplanval
|
|
|
|
void EdenGame::displayValleyMap() { // Draw mini-map
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_areaPtr->_type == AreaType::atValley) {
|
|
|
|
noclipax(_globals->_areaPtr->_num + 9, 266, 1);
|
2016-11-13 15:46:36 -08:00
|
|
|
for (perso_t *perso = &kPersons[PER_UNKN_18C]; perso->_roomNum != 0xFFFF; perso++) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (((perso->_roomNum >> 8) == _globals->_areaNum)
|
2016-10-07 00:45:08 +02:00
|
|
|
&& !(perso->_flags & PersonFlags::pf80) && (perso->_flags & PersonFlags::pf20))
|
|
|
|
displayMapMark(33, perso->_roomNum & 0xFF);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_areaPtr->_citadelLevel)
|
|
|
|
displayMapMark(34, _globals->_areaPtr->_citadelRoomPtr->_location);
|
2016-09-27 07:53:50 +02:00
|
|
|
saveTopFrieze(0);
|
2017-01-01 11:51:48 -08:00
|
|
|
int16 loc = _globals->_roomNum & 0xFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (loc >= 16)
|
2016-09-29 00:32:49 +02:00
|
|
|
displayAdamMapMark(loc);
|
2016-09-27 07:53:50 +02:00
|
|
|
restoreTopFrieze();
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-09-27 07:53:50 +02:00
|
|
|
saveTopFrieze(0);
|
|
|
|
restoreTopFrieze();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-29 00:32:49 +02:00
|
|
|
// Original name: affrepere
|
|
|
|
void EdenGame::displayMapMark(int16 index, int16 location) {
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(index, 269 + location % 16 * 4, 2 + (location - 16) / 16 * 3);
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-29 00:32:49 +02:00
|
|
|
// Original name: affrepereadam
|
|
|
|
void EdenGame::displayAdamMapMark(int16 location) {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 x = 269;
|
|
|
|
int16 y = 2;
|
2016-09-29 00:32:49 +02:00
|
|
|
restoreAdamMapMark();
|
2016-09-14 23:39:27 +02:00
|
|
|
if (location > 15 && location < 76) {
|
|
|
|
x += (location & 15) * 4;
|
|
|
|
y += ((location - 16) >> 4) * 3;
|
2016-09-29 00:32:49 +02:00
|
|
|
saveAdamMapMark(x, y);
|
2017-01-01 11:51:48 -08:00
|
|
|
byte *pix = _underBarsView->_bufferPtr;
|
|
|
|
int16 w = _underBarsView->_width;
|
2016-09-14 23:39:27 +02:00
|
|
|
pix += x + w * y;
|
|
|
|
pix[1] = 0xC3;
|
|
|
|
pix[2] = 0xC3;
|
|
|
|
pix += w;
|
|
|
|
pix[0] = 0xC3;
|
|
|
|
pix[1] = 0xC3;
|
|
|
|
pix[2] = 0xC3;
|
|
|
|
pix[3] = 0xC3;
|
|
|
|
pix += w;
|
|
|
|
pix[1] = 0xC3;
|
|
|
|
pix[2] = 0xC3;
|
|
|
|
}
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-29 00:32:49 +02:00
|
|
|
// Original name: rest_repadam
|
|
|
|
void EdenGame::restoreAdamMapMark() {
|
2016-09-30 07:48:27 +02:00
|
|
|
if (_adamMapMarkPos.x == -1 && _adamMapMarkPos.y == -1)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-09-29 00:32:49 +02:00
|
|
|
|
2016-09-30 07:48:27 +02:00
|
|
|
int16 x = _adamMapMarkPos.x;
|
|
|
|
int16 y = _adamMapMarkPos.y;
|
2017-01-01 11:51:48 -08:00
|
|
|
byte *pix = _underBarsView->_bufferPtr;
|
|
|
|
int16 w = _underBarsView->_width;
|
2016-09-14 23:39:27 +02:00
|
|
|
pix += x + w * y;
|
2016-09-30 07:48:27 +02:00
|
|
|
pix[1] = _oldPix[0];
|
|
|
|
pix[2] = _oldPix[1];
|
2016-09-14 23:39:27 +02:00
|
|
|
pix += w;
|
2016-09-30 07:48:27 +02:00
|
|
|
pix[0] = _oldPix[2];
|
|
|
|
pix[1] = _oldPix[3];
|
|
|
|
pix[2] = _oldPix[4];
|
|
|
|
pix[3] = _oldPix[5];
|
2016-09-14 23:39:27 +02:00
|
|
|
pix += w;
|
2016-09-30 07:48:27 +02:00
|
|
|
pix[1] = _oldPix[6];
|
|
|
|
pix[2] = _oldPix[7];
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-29 00:32:49 +02:00
|
|
|
// Original name: save_repadam
|
|
|
|
void EdenGame::saveAdamMapMark(int16 x, int16 y) {
|
2016-09-30 07:48:27 +02:00
|
|
|
_adamMapMarkPos.x = x;
|
|
|
|
_adamMapMarkPos.y = y;
|
2017-01-01 11:51:48 -08:00
|
|
|
byte *pix = _underBarsView->_bufferPtr;
|
|
|
|
int16 w = _underBarsView->_width;
|
2016-09-14 23:39:27 +02:00
|
|
|
pix += x + w * y;
|
2016-09-30 07:48:27 +02:00
|
|
|
_oldPix[0] = pix[1];
|
|
|
|
_oldPix[1] = pix[2];
|
2016-09-14 23:39:27 +02:00
|
|
|
pix += w;
|
2016-09-30 07:48:27 +02:00
|
|
|
_oldPix[2] = pix[0];
|
|
|
|
_oldPix[3] = pix[1];
|
|
|
|
_oldPix[4] = pix[2];
|
|
|
|
_oldPix[5] = pix[3];
|
2016-09-14 23:39:27 +02:00
|
|
|
pix += w;
|
2016-09-30 07:48:27 +02:00
|
|
|
_oldPix[6] = pix[1];
|
|
|
|
_oldPix[7] = pix[2];
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-29 00:32:49 +02:00
|
|
|
bool EdenGame::istrice(int16 roomNum) {
|
2016-09-14 23:39:27 +02:00
|
|
|
char loc = roomNum & 0xFF;
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 area = roomNum & 0xFF00;
|
2016-09-29 00:32:49 +02:00
|
|
|
for (perso_t *perso = &kPersons[PER_UNKN_18C]; perso != &kPersons[PER_UNKN_372]; perso++) {
|
2016-10-07 00:45:08 +02:00
|
|
|
if ((perso->_flags & PersonFlags::pf80) || (perso->_flags & PersonFlags::pfTypeMask) != PersonFlags::pftTriceraptor)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_roomNum == (area | (loc - 16)))
|
2016-09-29 00:32:49 +02:00
|
|
|
return true;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_roomNum == (area | (loc + 16)))
|
2016-09-29 00:32:49 +02:00
|
|
|
return true;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_roomNum == (area | (loc - 1)))
|
2016-09-29 00:32:49 +02:00
|
|
|
return true;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_roomNum == (area | (loc + 1)))
|
2016-09-29 00:32:49 +02:00
|
|
|
return true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-09-29 00:32:49 +02:00
|
|
|
return false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-11-13 15:46:36 -08:00
|
|
|
bool EdenGame::istyran(int16 roomNum) {
|
2016-09-14 23:39:27 +02:00
|
|
|
char loc = roomNum & 0xFF;
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 area = roomNum & 0xFF00;
|
2016-09-14 23:39:27 +02:00
|
|
|
// TODO: orig bug: this ptr is not initialized when first called from getsalle
|
|
|
|
// PC version scans kPersons[] directly and is not affected
|
2016-12-18 22:58:31 -08:00
|
|
|
if (!_tyranPtr)
|
2016-11-13 15:46:36 -08:00
|
|
|
return false;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-12-18 22:58:31 -08:00
|
|
|
for (; _tyranPtr->_roomNum != 0xFFFF; _tyranPtr++) {
|
|
|
|
if (_tyranPtr->_flags & PersonFlags::pf80)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2016-12-18 22:58:31 -08:00
|
|
|
if (_tyranPtr->_roomNum == (area | (loc - 16)))
|
2016-11-13 15:46:36 -08:00
|
|
|
return true;
|
2016-12-18 22:58:31 -08:00
|
|
|
if (_tyranPtr->_roomNum == (area | (loc + 16)))
|
2016-11-13 15:46:36 -08:00
|
|
|
return true;
|
2016-12-18 22:58:31 -08:00
|
|
|
if (_tyranPtr->_roomNum == (area | (loc - 1)))
|
2016-11-13 15:46:36 -08:00
|
|
|
return true;
|
2016-12-18 22:58:31 -08:00
|
|
|
if (_tyranPtr->_roomNum == (area | (loc + 1)))
|
2016-11-13 15:46:36 -08:00
|
|
|
return true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-11-13 15:46:36 -08:00
|
|
|
return false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-17 09:32:43 -08:00
|
|
|
void EdenGame::istyranval(Area *area) {
|
2016-12-15 22:47:29 -08:00
|
|
|
byte areaNum = area->_num;
|
2016-12-04 14:26:44 -08:00
|
|
|
area->_flags &= ~AreaFlags::HasTyrann;
|
2016-11-13 15:46:36 -08:00
|
|
|
for (perso_t *perso = &kPersons[PER_UNKN_372]; perso->_roomNum != 0xFFFF; perso++) {
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_flags & PersonFlags::pf80)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2016-10-07 00:45:08 +02:00
|
|
|
if ((perso->_roomNum >> 8) == areaNum) {
|
2016-12-04 14:26:44 -08:00
|
|
|
area->_flags |= AreaFlags::HasTyrann;
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-29 00:32:49 +02:00
|
|
|
char EdenGame::getDirection(perso_t *perso) {
|
2016-09-14 23:39:27 +02:00
|
|
|
char dir = -1;
|
2016-10-07 00:45:08 +02:00
|
|
|
byte trgLoc = perso->_targetLoc;
|
|
|
|
byte curLoc = perso->_roomNum & 0xFF; //TODO name
|
2016-09-14 23:39:27 +02:00
|
|
|
if (curLoc != trgLoc) {
|
|
|
|
curLoc &= 0xF;
|
|
|
|
trgLoc &= 0xF;
|
|
|
|
if (curLoc != trgLoc) {
|
|
|
|
dir = 2;
|
|
|
|
if (curLoc > trgLoc)
|
|
|
|
dir = 5;
|
|
|
|
}
|
2016-10-07 00:45:08 +02:00
|
|
|
trgLoc = perso->_targetLoc;
|
|
|
|
curLoc = perso->_roomNum & 0xFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
curLoc &= 0xF0;
|
|
|
|
trgLoc &= 0xF0;
|
|
|
|
if (curLoc != trgLoc) {
|
|
|
|
if (curLoc > trgLoc)
|
|
|
|
dir++;
|
|
|
|
dir++;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
return dir;
|
|
|
|
}
|
|
|
|
|
2016-09-29 00:32:49 +02:00
|
|
|
// Original name: caselibre
|
|
|
|
bool EdenGame::canMoveThere(char loc, perso_t *perso) {
|
2017-01-01 11:51:48 -08:00
|
|
|
Room *room = _globals->_citaAreaFirstRoom;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (loc <= 0x10 || loc > 76 || (loc & 0xF) >= 12 || loc == perso->_lastLoc)
|
2016-09-29 00:32:49 +02:00
|
|
|
return false;
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2016-10-07 00:45:08 +02:00
|
|
|
int16 roomNum = (perso->_roomNum & ~0xFF) | loc; //TODO: danger! signed
|
2017-01-01 11:51:48 -08:00
|
|
|
if (roomNum == _globals->_roomNum)
|
2016-09-29 00:32:49 +02:00
|
|
|
return false;
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2016-12-15 22:47:29 -08:00
|
|
|
for (; room->_id != 0xFF; room++) {
|
|
|
|
if (room->_location != loc)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2016-12-15 22:47:29 -08:00
|
|
|
if (!(room->_flags & RoomFlags::rf01))
|
2016-09-29 00:32:49 +02:00
|
|
|
return false;
|
2016-10-07 00:45:08 +02:00
|
|
|
for (perso = &kPersons[PER_UNKN_18C]; perso->_roomNum != 0xFFFF; perso++) {
|
|
|
|
if (perso->_flags & PersonFlags::pf80)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_roomNum == roomNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_roomNum != 0xFFFF)
|
2016-09-29 00:32:49 +02:00
|
|
|
return false;
|
|
|
|
return true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-09-29 00:32:49 +02:00
|
|
|
return false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-29 00:32:49 +02:00
|
|
|
// Original name: melange1
|
2016-12-03 15:26:32 -08:00
|
|
|
void EdenGame::scramble1(uint8 elem[4]) {
|
2016-11-09 13:40:08 -08:00
|
|
|
if (_vm->_rnd->getRandomNumber(1) & 1)
|
2016-09-29 00:32:49 +02:00
|
|
|
SWAP(elem[1], elem[2]);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-29 00:32:49 +02:00
|
|
|
// Original name melange2
|
2016-12-03 15:26:32 -08:00
|
|
|
void EdenGame::scramble2(uint8 elem[4]) {
|
2016-11-09 13:40:08 -08:00
|
|
|
if (_vm->_rnd->getRandomNumber(1) & 1)
|
2016-09-29 00:32:49 +02:00
|
|
|
SWAP(elem[0], elem[1]);
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-11-09 13:40:08 -08:00
|
|
|
if (_vm->_rnd->getRandomNumber(1) & 1)
|
2016-09-29 00:32:49 +02:00
|
|
|
SWAP(elem[2], elem[3]);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-26 13:40:28 -08:00
|
|
|
// Original name: melangedir
|
|
|
|
void EdenGame::scrambleDirections() {
|
2016-09-29 00:32:49 +02:00
|
|
|
scramble1(tab_2CB1E[0]);
|
|
|
|
scramble1(tab_2CB1E[1]);
|
|
|
|
scramble1(tab_2CB1E[2]);
|
|
|
|
scramble2(tab_2CB1E[3]);
|
|
|
|
scramble2(tab_2CB1E[4]);
|
|
|
|
scramble1(tab_2CB1E[5]);
|
|
|
|
scramble2(tab_2CB1E[6]);
|
|
|
|
scramble2(tab_2CB1E[7]);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EdenGame::naitredino(char persoType) {
|
2016-10-07 00:45:08 +02:00
|
|
|
for (perso_t *perso = &kPersons[PER_MORKUS]; (++perso)->_roomNum != 0xFFFF;) {
|
|
|
|
char areaNum = perso->_roomNum >> 8;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (areaNum != _globals->_citadelAreaNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2016-10-07 00:45:08 +02:00
|
|
|
if ((perso->_flags & PersonFlags::pf80) && (perso->_flags & PersonFlags::pfTypeMask) == persoType) {
|
|
|
|
perso->_flags &= ~PersonFlags::pf80;
|
2016-09-29 00:32:49 +02:00
|
|
|
return true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-29 00:32:49 +02:00
|
|
|
return false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-17 09:32:43 -08:00
|
|
|
// Original name: newcita
|
|
|
|
void EdenGame::newCitadel(char area, int16 level, Room *room) {
|
|
|
|
Citadel *cita = _citadelList;
|
|
|
|
while (cita->_id < level)
|
2016-09-14 23:39:27 +02:00
|
|
|
cita++;
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2016-12-15 22:47:29 -08:00
|
|
|
uint16 index = ((room->_flags & 0xC0) >> 6); //TODO: this is very wrong
|
2016-12-17 09:32:43 -08:00
|
|
|
if (area == 4 || area == 6)
|
|
|
|
index++;
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2016-12-17 09:32:43 -08:00
|
|
|
room->_bank = cita->_bank[index];
|
|
|
|
room->_video = cita->_video[index];
|
2016-12-15 22:47:29 -08:00
|
|
|
room->_flags |= RoomFlags::rf02;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-26 13:40:28 -08:00
|
|
|
// Original name: citaevol
|
|
|
|
void EdenGame::evolveCitadel(int16 level) {
|
2017-01-01 11:51:48 -08:00
|
|
|
Room *room = _globals->_curAreaPtr->_citadelRoomPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso = &kPersons[PER_UNKN_372];
|
2016-12-15 22:47:29 -08:00
|
|
|
byte loc = room->_location;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (level >= 80 && !istrice((_globals->_citadelAreaNum << 8) | loc)) {
|
2016-12-15 22:47:29 -08:00
|
|
|
room->_level = 79;
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
|
|
|
}
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
if (level > 160)
|
|
|
|
level = 160;
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2016-12-15 22:47:29 -08:00
|
|
|
if (room->_level < 64 && level >= 64 && naitredino(PersonFlags::pftTriceraptor)) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curAreaPtr->_flags |= AreaFlags::HasTriceraptors;
|
|
|
|
addInfo(_globals->_citadelAreaNum + ValleyNews::vnTriceraptorsIn);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-15 22:47:29 -08:00
|
|
|
if (room->_level < 40 && level >= 40 && naitredino(PersonFlags::pftVelociraptor)) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curAreaPtr->_flags |= AreaFlags::HasVelociraptors;
|
|
|
|
addInfo(_globals->_citadelAreaNum + ValleyNews::vnVelociraptorsIn);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-15 22:47:29 -08:00
|
|
|
room->_level = level;
|
2017-01-01 11:51:48 -08:00
|
|
|
newCitadel(_globals->_citadelAreaNum, level, room);
|
2016-12-15 22:47:29 -08:00
|
|
|
byte speed = kDinoSpeedForCitaLevel[room->_level >> 4];
|
2016-10-07 00:45:08 +02:00
|
|
|
for (; perso->_roomNum != 0xFFFF; perso++) {
|
|
|
|
if (perso->_flags & PersonFlags::pf80)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2017-01-01 11:51:48 -08:00
|
|
|
if ((perso->_roomNum >> 8) == _globals->_citadelAreaNum && perso->_targetLoc == loc)
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_speed = speed;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-15 22:47:29 -08:00
|
|
|
// Original name: citacapoute
|
|
|
|
void EdenGame::destroyCitadelRoom(int16 roomNum) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso = &kPersons[PER_UNKN_18C];
|
2017-01-01 11:51:48 -08:00
|
|
|
Room *room = _globals->_curAreaPtr->_citadelRoomPtr;
|
2016-12-15 22:47:29 -08:00
|
|
|
room->_flags |= RoomFlags::rf01;
|
|
|
|
room->_flags &= ~RoomFlags::rfHasCitadel;
|
|
|
|
room->_bank = 193;
|
|
|
|
room->_video = 0;
|
|
|
|
room->_level = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curAreaPtr->_citadelLevel = 0;
|
|
|
|
_globals->_curAreaPtr->_citadelRoomPtr = 0;
|
2016-12-15 22:47:29 -08:00
|
|
|
roomNum = (roomNum & ~0xFF) | room->_location;
|
2016-10-07 00:45:08 +02:00
|
|
|
for (; perso->_roomNum != 0xFFFF; perso++) {
|
|
|
|
if (perso->_roomNum == roomNum) {
|
|
|
|
perso->_flags &= ~PersonFlags::pf80;
|
2016-12-11 13:44:58 -08:00
|
|
|
removeInfo((roomNum >> 8) + ValleyNews::vnTyrannIn);
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-15 22:47:29 -08:00
|
|
|
// Original name: buildcita
|
2017-01-14 00:30:37 +01:00
|
|
|
void EdenGame::narratorBuildCitadel() {
|
2017-01-01 11:51:48 -08:00
|
|
|
Area *area = _globals->_areaPtr;
|
|
|
|
_globals->_curAreaPtr = _globals->_areaPtr;
|
2016-12-15 22:47:29 -08:00
|
|
|
if (area->_citadelRoomPtr)
|
2017-01-01 11:51:48 -08:00
|
|
|
destroyCitadelRoom(_globals->_roomNum);
|
|
|
|
_globals->_var6A = _globals->_var69;
|
|
|
|
_globals->_narratorSequence = _globals->_var69 | 0x80;
|
|
|
|
area->_citadelRoomPtr = _globals->_roomPtr;
|
|
|
|
_globals->_roomPtr->_flags &= ~RoomFlags::rf01;
|
|
|
|
_globals->_roomPtr->_flags |= RoomFlags::rfHasCitadel;
|
|
|
|
_globals->_roomPtr->_level = 32;
|
|
|
|
newCitadel(_globals->_areaNum, 32, _globals->_roomPtr);
|
2016-12-04 14:26:44 -08:00
|
|
|
area->_flags &= ~AreaFlags::TyrannSighted;
|
|
|
|
if (!(area->_flags & AreaFlags::afFlag8000)) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_phaseNum == 304 || _globals->_phaseNum != 384) //TODO: wha
|
2016-12-19 22:32:40 -08:00
|
|
|
handleEloiReturn();
|
2016-12-04 14:26:44 -08:00
|
|
|
area->_flags |= AreaFlags::afFlag8000;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomCharacterPtr->_flags |= PersonFlags::pf80;
|
|
|
|
_globals->_citadelAreaNum = _globals->_areaNum;
|
2016-09-14 23:39:27 +02:00
|
|
|
naitredino(1);
|
2017-01-01 11:51:48 -08:00
|
|
|
removeInfo(_globals->_areaNum + ValleyNews::vnCitadelLost);
|
|
|
|
removeInfo(_globals->_areaNum + ValleyNews::vnTyrannLost);
|
|
|
|
if (_globals->_phaseNum == 193 && _globals->_areaNum == Areas::arUluru)
|
2016-09-14 23:39:27 +02:00
|
|
|
bigphase1();
|
|
|
|
}
|
|
|
|
|
2017-01-14 00:30:37 +01:00
|
|
|
// Original name: citatombe
|
|
|
|
void EdenGame::citadelFalls(char level) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (level)
|
2017-01-01 11:51:48 -08:00
|
|
|
newCitadel(_globals->_citadelAreaNum, level, _globals->_curAreaPtr->_citadelRoomPtr);
|
2016-09-14 23:39:27 +02:00
|
|
|
else {
|
2017-01-01 11:51:48 -08:00
|
|
|
destroyCitadelRoom(_globals->_citadelAreaNum << 8);
|
|
|
|
addInfo(_globals->_citadelAreaNum + ValleyNews::vnCitadelLost);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-14 00:30:37 +01:00
|
|
|
// Originam name: constcita
|
|
|
|
void EdenGame::buildCitadel() {
|
2016-12-18 13:09:56 -08:00
|
|
|
// Room *room = p_global->_curAreaPtr->_citadelRoomPtr; //TODO: wrong? chk below
|
|
|
|
// byte id = room->_location;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!_globals->_curAreaPtr->_citadelLevel || !_globals->_curAreaPtr->_citadelRoomPtr)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-09-29 00:32:49 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
Room *room = _globals->_curAreaPtr->_citadelRoomPtr; //TODO: copied here by me
|
2016-12-15 22:47:29 -08:00
|
|
|
byte loc = room->_location;
|
2016-12-18 22:58:31 -08:00
|
|
|
_tyranPtr = &kPersons[PER_UNKN_372];
|
2017-01-01 11:51:48 -08:00
|
|
|
if (istyran((_globals->_citadelAreaNum << 8) | loc)) {
|
|
|
|
if (!(_globals->_curAreaPtr->_flags & AreaFlags::TyrannSighted)) {
|
|
|
|
addInfo(_globals->_citadelAreaNum + ValleyNews::vnTyrannIn);
|
|
|
|
_globals->_curAreaPtr->_flags |= AreaFlags::TyrannSighted;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-15 22:47:29 -08:00
|
|
|
byte level = room->_level - 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (level < 32)
|
|
|
|
level = 32;
|
2016-12-15 22:47:29 -08:00
|
|
|
room->_level = level;
|
2017-01-14 00:30:37 +01:00
|
|
|
citadelFalls(level);
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curAreaPtr->_flags &= ~AreaFlags::TyrannSighted;
|
2016-12-26 13:40:28 -08:00
|
|
|
evolveCitadel(room->_level + 1);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-18 13:09:56 -08:00
|
|
|
// Original name: depladino
|
|
|
|
void EdenGame::moveDino(perso_t *perso) {
|
2016-10-08 21:21:21 +02:00
|
|
|
int dir = getDirection(perso);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (dir != -1) {
|
2016-12-26 13:40:28 -08:00
|
|
|
scrambleDirections();
|
2016-12-03 15:26:32 -08:00
|
|
|
uint8 *dirs = tab_2CB1E[dir];
|
2016-10-07 00:45:08 +02:00
|
|
|
byte loc = perso->_roomNum & 0xFF;
|
2017-01-22 22:38:18 +01:00
|
|
|
uint8 dir2 = dirs[0];
|
2016-09-14 23:39:27 +02:00
|
|
|
if (dir2 & 0x80)
|
|
|
|
dir2 = -(dir2 & ~0x80);
|
|
|
|
dir2 += loc;
|
2017-01-14 00:32:56 +01:00
|
|
|
if (!canMoveThere(dir2, perso)) {
|
2017-01-22 22:38:18 +01:00
|
|
|
dir2 = dirs[1];
|
2017-01-14 00:32:56 +01:00
|
|
|
if (dir2 & 0x80)
|
|
|
|
dir2 = -(dir2 & ~0x80);
|
|
|
|
dir2 += loc;
|
|
|
|
if (!canMoveThere(dir2, perso)) {
|
2017-01-22 22:38:18 +01:00
|
|
|
dir2 = dirs[2];
|
2017-01-14 00:32:56 +01:00
|
|
|
if (dir2 & 0x80)
|
|
|
|
dir2 = -(dir2 & ~0x80);
|
|
|
|
dir2 += loc;
|
|
|
|
if (!canMoveThere(dir2, perso)) {
|
2017-01-22 22:38:18 +01:00
|
|
|
dir2 = dirs[3];
|
2017-01-14 00:32:56 +01:00
|
|
|
if (dir2 & 0x80)
|
|
|
|
dir2 = -(dir2 & ~0x80);
|
|
|
|
dir2 += loc;
|
|
|
|
if (!canMoveThere(dir2, perso)) {
|
|
|
|
dir2 = perso->_lastLoc;
|
|
|
|
perso->_lastLoc = 0;
|
|
|
|
if (!canMoveThere(dir2, perso))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_lastLoc = perso->_roomNum & 0xFF;
|
|
|
|
perso->_roomNum &= ~0xFF;
|
|
|
|
perso->_roomNum |= dir2 & 0xFF;
|
2017-01-22 22:38:18 +01:00
|
|
|
if ((perso->_targetLoc - 16 == (perso->_roomNum & 0xFF))
|
|
|
|
|| (perso->_targetLoc + 16 == (perso->_roomNum & 0xFF))
|
|
|
|
|| (perso->_targetLoc - 1 == (perso->_roomNum & 0xFF))
|
|
|
|
|| (perso->_targetLoc + 1 == (perso->_roomNum & 0xFF)))
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_targetLoc = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_targetLoc = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-18 13:09:56 -08:00
|
|
|
// Original name: deplaalldino
|
|
|
|
void EdenGame::moveAllDino() {
|
|
|
|
for (perso_t *perso = &kPersons[PER_UNKN_18C]; perso->_roomNum != 0xFFFF; perso++) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (((perso->_roomNum >> 8) & 0xFF) != _globals->_citadelAreaNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2017-01-22 22:38:18 +01:00
|
|
|
if ((perso->_flags & PersonFlags::pf80) || !perso->_targetLoc)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (--perso->_steps)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_steps = 1;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (perso->_roomNum == _globals->_roomNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_steps = perso->_speed;
|
2016-12-18 13:09:56 -08:00
|
|
|
moveDino(perso);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-17 10:13:15 -08:00
|
|
|
// Original name: newvallee
|
|
|
|
void EdenGame::newValley() {
|
|
|
|
static int16 roomNumList[] = { 2075, 2080, 2119, -1};
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso = &kPersons[PER_UNKN_372];
|
2016-12-17 10:13:15 -08:00
|
|
|
int16 *ptr = roomNumList;
|
|
|
|
int16 roomNum = *ptr++;
|
|
|
|
while (roomNum != -1) {
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_roomNum = roomNum;
|
|
|
|
perso->_flags &= ~PersonFlags::pf80;
|
|
|
|
perso->_flags &= ~PersonFlags::pf20; //TODO: combine?
|
2016-09-14 23:39:27 +02:00
|
|
|
perso++;
|
2016-12-17 10:13:15 -08:00
|
|
|
roomNum = *ptr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_roomNum = 0xFFFF;
|
2016-12-04 14:26:44 -08:00
|
|
|
kAreasTable[7]._flags |= AreaFlags::HasTyrann;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_worldHasTyran = 32;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-26 12:35:21 -08:00
|
|
|
char EdenGame::whereIsCita() {
|
2016-09-14 23:39:27 +02:00
|
|
|
char res = -1;
|
2017-01-01 11:51:48 -08:00
|
|
|
for (Room *room = _globals->_citaAreaFirstRoom; room->_id != 0xFF; room++) {
|
2016-12-15 22:47:29 -08:00
|
|
|
if (!(room->_flags & RoomFlags::rfHasCitadel))
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2016-12-15 22:47:29 -08:00
|
|
|
res = room->_location;
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2016-12-26 12:35:21 -08:00
|
|
|
bool EdenGame::isCita(int16 loc) {
|
2016-09-14 23:39:27 +02:00
|
|
|
loc &= 0xFF;
|
2017-01-01 11:51:48 -08:00
|
|
|
for (Room *room = _globals->_citaAreaFirstRoom; room->_id != 0xFF; room++) {
|
2016-12-15 22:47:29 -08:00
|
|
|
if (!(room->_flags & RoomFlags::rfHasCitadel))
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2017-01-22 22:38:18 +01:00
|
|
|
|
|
|
|
if ((room->_location == loc + 16)
|
|
|
|
|| (room->_location == loc - 16)
|
|
|
|
|| (room->_location == loc - 1)
|
|
|
|
|| (room->_location == loc + 1))
|
2016-09-29 00:32:49 +02:00
|
|
|
return true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-09-29 00:32:49 +02:00
|
|
|
return false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-26 12:35:21 -08:00
|
|
|
// Original name: lieuvava
|
|
|
|
void EdenGame::placeVava(Area *area) {
|
2016-12-15 22:47:29 -08:00
|
|
|
if (area->_type == AreaType::atValley) {
|
2016-09-14 23:39:27 +02:00
|
|
|
istyranval(area);
|
2016-12-15 22:47:29 -08:00
|
|
|
area->_citadelLevel = 0;
|
|
|
|
if (area->_citadelRoomPtr)
|
2017-01-01 11:51:48 -08:00
|
|
|
area->_citadelLevel = _globals->_citaAreaFirstRoom->_level; //TODO: no search?
|
2016-12-15 22:47:29 -08:00
|
|
|
byte mask = ~(1 << (area->_num - Areas::arChamaar));
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_worldTyranSighted &= mask;
|
|
|
|
_globals->_var4E &= mask;
|
|
|
|
_globals->_worldGaveGold &= mask;
|
|
|
|
_globals->_worldHasVelociraptors &= mask;
|
|
|
|
_globals->_worldHasTriceraptors &= mask;
|
|
|
|
_globals->_worldHasTyran &= mask;
|
|
|
|
_globals->_var53 &= mask;
|
2016-09-14 23:39:27 +02:00
|
|
|
mask = ~mask;
|
2016-12-04 14:26:44 -08:00
|
|
|
if (area->_flags & AreaFlags::TyrannSighted)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_worldTyranSighted |= mask;
|
2016-12-04 14:26:44 -08:00
|
|
|
if (area->_flags & AreaFlags::afFlag4)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var4E |= mask;
|
2016-12-04 14:26:44 -08:00
|
|
|
if (area->_flags & AreaFlags::HasTriceraptors)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_worldHasTriceraptors |= mask;
|
2016-12-04 14:26:44 -08:00
|
|
|
if (area->_flags & AreaFlags::afGaveGold)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_worldGaveGold |= mask;
|
2016-12-04 14:26:44 -08:00
|
|
|
if (area->_flags & AreaFlags::HasVelociraptors)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_worldHasVelociraptors |= mask;
|
2016-12-04 14:26:44 -08:00
|
|
|
if (area->_flags & AreaFlags::HasTyrann)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_worldHasTyran |= mask;
|
2016-12-04 14:26:44 -08:00
|
|
|
if (area->_flags & AreaFlags::afFlag20)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var53 |= mask;
|
|
|
|
if (area == _globals->_areaPtr) {
|
|
|
|
_globals->_curAreaFlags = area->_flags;
|
|
|
|
_globals->_curCitadelLevel = area->_citadelLevel;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var4D &= _globals->_worldTyranSighted;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::vivredino() {
|
2016-11-13 15:46:36 -08:00
|
|
|
for (perso_t *perso = &kPersons[PER_UNKN_18C]; perso->_roomNum != 0xFFFF; perso++) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (((perso->_roomNum >> 8) & 0xFF) != _globals->_citadelAreaNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_flags & PersonFlags::pf80)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2016-10-07 00:45:08 +02:00
|
|
|
switch (perso->_flags & PersonFlags::pfTypeMask) {
|
2016-09-14 23:39:27 +02:00
|
|
|
case PersonFlags::pftTyrann:
|
2016-12-26 12:35:21 -08:00
|
|
|
if (isCita(perso->_roomNum))
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_targetLoc = 0;
|
|
|
|
else if (!perso->_targetLoc) {
|
2016-12-26 12:35:21 -08:00
|
|
|
char cita = whereIsCita();
|
2016-09-14 23:39:27 +02:00
|
|
|
if (cita != -1) {
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_targetLoc = cita;
|
|
|
|
perso->_speed = 2;
|
|
|
|
perso->_steps = 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PersonFlags::pftTriceraptor:
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_flags & PersonFlags::pfInParty) {
|
2016-12-26 12:35:21 -08:00
|
|
|
if (isCita(perso->_roomNum))
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_targetLoc = 0;
|
|
|
|
else if (!perso->_targetLoc) {
|
2016-12-26 12:35:21 -08:00
|
|
|
char cita = whereIsCita();
|
2016-09-14 23:39:27 +02:00
|
|
|
if (cita != -1) {
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_targetLoc = cita;
|
|
|
|
perso->_speed = 3;
|
|
|
|
perso->_steps = 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PersonFlags::pftVelociraptor:
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_flags & PersonFlags::pf10) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (perso->_roomNum == _globals->_roomNum) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso2 = &kPersons[PER_UNKN_372];
|
2016-11-13 15:46:36 -08:00
|
|
|
bool found = false;
|
2016-10-07 00:45:08 +02:00
|
|
|
for (; perso2->_roomNum != 0xFFFF; perso2++) {
|
|
|
|
if ((perso->_roomNum & ~0xFF) == (perso2->_roomNum & ~0xFF)) {
|
|
|
|
if (perso2->_flags & PersonFlags::pf80)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_targetLoc = perso2->_roomNum & 0xFF;
|
|
|
|
perso->_steps = 1;
|
2016-11-13 15:46:36 -08:00
|
|
|
found = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (found)
|
|
|
|
continue;
|
|
|
|
} else {
|
2016-12-18 22:58:31 -08:00
|
|
|
_tyranPtr = &kPersons[PER_UNKN_372];
|
2016-10-07 00:45:08 +02:00
|
|
|
if (istyran(perso->_roomNum)) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_phaseNum < 481 && (perso->_powers & (1 << (_globals->_citadelAreaNum - 3)))) {
|
2016-12-18 22:58:31 -08:00
|
|
|
_tyranPtr->_flags |= PersonFlags::pf80;
|
|
|
|
_tyranPtr->_roomNum = 0;
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags &= ~PersonFlags::pf10;
|
|
|
|
perso->_flags |= PersonFlags::pfInParty;
|
2017-01-01 11:51:48 -08:00
|
|
|
addInfo(_globals->_citadelAreaNum + ValleyNews::vnTyrannLost);
|
|
|
|
removeInfo(_globals->_citadelAreaNum + ValleyNews::vnTyrannIn);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (naitredino(PersonFlags::pftTriceraptor))
|
2017-01-01 11:51:48 -08:00
|
|
|
addInfo(_globals->_citadelAreaNum + ValleyNews::vnTriceraptorsIn);
|
2017-01-14 00:30:37 +01:00
|
|
|
buildCitadel();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curAreaPtr->_flags &= ~AreaFlags::TyrannSighted;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags &= ~PersonFlags::pf10;
|
|
|
|
perso->_flags &= ~PersonFlags::pfInParty;
|
2017-01-01 11:51:48 -08:00
|
|
|
addInfo(_globals->_citadelAreaNum + ValleyNews::vnVelociraptorsLost);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-10-07 00:45:08 +02:00
|
|
|
if (!perso->_targetLoc) {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 loc;
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_lastLoc = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
do {
|
2016-11-09 13:40:08 -08:00
|
|
|
loc = (_vm->_rnd->getRandomNumber(63) & 63) + 16;
|
2016-09-14 23:39:27 +02:00
|
|
|
if ((loc & 0xF) >= 12)
|
|
|
|
loc &= ~4; //TODO: ??? same as -= 4
|
2016-09-29 00:32:49 +02:00
|
|
|
} while (!canMoveThere(loc, perso));
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_targetLoc = loc;
|
|
|
|
perso->_steps = 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::vivreval(int16 areaNum) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_citadelAreaNum = areaNum;
|
|
|
|
_globals->_curAreaPtr = &kAreasTable[areaNum - 1];
|
|
|
|
_globals->_citaAreaFirstRoom = &_gameRooms[_globals->_curAreaPtr->_firstRoomIdx];
|
2016-12-18 13:09:56 -08:00
|
|
|
moveAllDino();
|
2017-01-14 00:30:37 +01:00
|
|
|
buildCitadel();
|
2016-09-14 23:39:27 +02:00
|
|
|
vivredino();
|
2016-12-18 13:09:56 -08:00
|
|
|
newMushroom();
|
2016-12-26 12:35:21 -08:00
|
|
|
newNestWithEggs();
|
|
|
|
newEmptyNest();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_phaseNum >= 226)
|
2017-01-22 22:38:18 +01:00
|
|
|
newGold();
|
2017-01-01 11:51:48 -08:00
|
|
|
placeVava(_globals->_curAreaPtr);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-15 22:59:50 +01:00
|
|
|
// Original name: chaquejour
|
|
|
|
void EdenGame::handleDay() {
|
2016-09-14 23:39:27 +02:00
|
|
|
vivreval(3);
|
|
|
|
vivreval(4);
|
|
|
|
vivreval(5);
|
|
|
|
vivreval(6);
|
|
|
|
vivreval(7);
|
|
|
|
vivreval(8);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_drawFlags |= DrawFlags::drDrawTopScreen;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-15 22:59:50 +01:00
|
|
|
// Original name: temps_passe
|
|
|
|
void EdenGame::addTime(int16 t) {
|
2017-01-01 11:51:48 -08:00
|
|
|
int16 days = _globals->_gameDays;
|
|
|
|
int16 lo = _globals->_gameHours + t;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (lo > 255) {
|
|
|
|
days++;
|
|
|
|
lo &= 0xFF;
|
|
|
|
}
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_gameHours = lo;
|
2016-09-14 23:39:27 +02:00
|
|
|
t = ((t >> 8) & 0xFF) + days;
|
2017-01-01 11:51:48 -08:00
|
|
|
t -= _globals->_gameDays;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (t) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_gameDays += t;
|
2016-09-14 23:39:27 +02:00
|
|
|
while (t--)
|
2017-01-15 22:59:50 +01:00
|
|
|
handleDay();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-15 22:59:50 +01:00
|
|
|
// Original name: anim_perso
|
|
|
|
void EdenGame::animCharacter() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_curBankNum != _globals->_characterImageBank)
|
|
|
|
loadCharacter(_globals->_characterPtr);
|
2016-12-26 13:40:28 -08:00
|
|
|
restoreUnderSubtitles();
|
2016-12-04 14:26:44 -08:00
|
|
|
if (_restartAnimation) {
|
|
|
|
_lastAnimTicks = _vm->_timerTicks;
|
|
|
|
_restartAnimation = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-04 14:26:44 -08:00
|
|
|
_curAnimFrameNumb = (_vm->_timerTicks - _lastAnimTicks) >> 2; // TODO: check me!!!
|
|
|
|
if (_curAnimFrameNumb > _numAnimFrames) // TODO: bug?
|
2016-11-09 22:36:06 -08:00
|
|
|
_animateTalking = false;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curCharacterAnimPtr && !_globals->_animationFlags && _curAnimFrameNumb != _lastAnimFrameNumb) {
|
2016-12-04 14:26:44 -08:00
|
|
|
_lastAnimFrameNumb = _curAnimFrameNumb;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (*_globals->_curCharacterAnimPtr == 0xFF)
|
2016-09-14 23:39:27 +02:00
|
|
|
getanimrnd();
|
2016-12-25 02:17:07 -08:00
|
|
|
useCharacterBank();
|
|
|
|
_numImgDesc = 0;
|
2017-01-15 22:59:50 +01:00
|
|
|
setCharacterSprite(_globals->_curCharacterAnimPtr);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curCharacterAnimPtr += _numImgDesc + 1;
|
2016-12-04 14:26:44 -08:00
|
|
|
_mouthAnimations = _imageDesc + 200;
|
|
|
|
removeMouthSprite();
|
|
|
|
if (*_mouthAnimations)
|
|
|
|
displayImage();
|
|
|
|
_animationDelay--;
|
|
|
|
if (!_animationDelay) { //TODO: combine
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_animationFlags = 1;
|
2016-12-04 14:26:44 -08:00
|
|
|
_animationDelay = 8;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
_animationDelay--;
|
|
|
|
if (!_animationDelay) { //TODO: combine
|
2016-09-14 23:39:27 +02:00
|
|
|
getanimrnd();
|
|
|
|
//TODO: no reload?
|
|
|
|
}
|
2016-11-09 22:36:06 -08:00
|
|
|
if (_animateTalking) {
|
2016-12-25 13:45:47 -08:00
|
|
|
if (!_animationTable) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_animationTable = _gameLipsync + 7262; //TODO: fix me
|
2016-12-18 14:13:36 -08:00
|
|
|
if (!_backgroundSaved)
|
2017-01-14 00:30:37 +01:00
|
|
|
saveMouthBackground();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-10-06 00:15:02 +02:00
|
|
|
if (!_personTalking)
|
2016-12-04 14:26:44 -08:00
|
|
|
_curAnimFrameNumb = _numAnimFrames - 1;
|
2016-12-25 13:45:47 -08:00
|
|
|
_animationIndex = _animationTable[_curAnimFrameNumb];
|
2016-12-25 02:17:07 -08:00
|
|
|
if (_animationIndex == 0xFF)
|
2016-11-09 22:36:06 -08:00
|
|
|
_animateTalking = false;
|
2016-12-25 02:17:07 -08:00
|
|
|
else if (_animationIndex != _lastAnimationIndex) {
|
|
|
|
useCharacterBank();
|
2017-01-14 00:30:37 +01:00
|
|
|
restoreMouthBackground();
|
2016-09-14 23:39:27 +02:00
|
|
|
// debug("perso spr %d", animationIndex);
|
2017-01-15 22:59:50 +01:00
|
|
|
setCharacterSprite(_globals->_persoSpritePtr2 + _animationIndex * 2); //TODO: int16s?
|
2016-12-04 14:26:44 -08:00
|
|
|
_mouthAnimations = _imageDesc + 200;
|
|
|
|
if (*_mouthAnimations)
|
|
|
|
displayImage();
|
2016-12-25 02:17:07 -08:00
|
|
|
_lastAnimationIndex = _animationIndex;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
2016-12-25 02:17:07 -08:00
|
|
|
displaySubtitles();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::getanimrnd() {
|
2016-12-04 14:26:44 -08:00
|
|
|
_animationDelay = 8;
|
2016-11-13 15:46:36 -08:00
|
|
|
int16 rnd = _vm->_rnd->getRandomNumber(65535) & (byte)~0x18; //TODO
|
2017-01-01 11:51:48 -08:00
|
|
|
dword_30724 = _globals->_persoSpritePtr + 16; //TODO
|
|
|
|
_globals->_curCharacterAnimPtr = _globals->_persoSpritePtr + ((dword_30724[1] << 8) + dword_30724[0]);
|
|
|
|
_globals->_animationFlags = 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (rnd >= 8)
|
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_animationFlags = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (rnd <= 0)
|
|
|
|
return;
|
|
|
|
for (rnd *= 8; rnd > 0; rnd--) {
|
2017-01-01 11:51:48 -08:00
|
|
|
while (*_globals->_curCharacterAnimPtr)
|
|
|
|
_globals->_curCharacterAnimPtr++;
|
|
|
|
_globals->_curCharacterAnimPtr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::addanim() {
|
2016-12-25 02:17:07 -08:00
|
|
|
_lastAnimationIndex = 0xFF;
|
2016-10-06 00:15:02 +02:00
|
|
|
_lastAnimTicks = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_animationFlags = 0xC0;
|
|
|
|
_globals->_curCharacterAnimPtr = _globals->_persoSpritePtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
getanimrnd();
|
2016-12-25 02:17:07 -08:00
|
|
|
_animationActive = true;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_characterPtr == &kPersons[PER_KING])
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-15 22:59:50 +01:00
|
|
|
setCharacterSprite(_globals->_persoSpritePtr + READ_LE_UINT16(_globals->_persoSpritePtr)); //TODO: GetElem(0)
|
2016-12-04 14:26:44 -08:00
|
|
|
_mouthAnimations = _imageDesc + 200;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_characterPtr->_id != PersonId::pidCabukaOfCantura && _globals->_characterPtr->_targetLoc != 7) //TODO: targetLoc is minisprite idx
|
2016-12-04 14:26:44 -08:00
|
|
|
removeMouthSprite();
|
|
|
|
if (*_mouthAnimations)
|
|
|
|
displayImage();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
// Original name: virespritebouche
|
|
|
|
void EdenGame::removeMouthSprite() {
|
|
|
|
byte *src = _mouthAnimations + 2;
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *dst = src;
|
2016-12-04 14:26:44 -08:00
|
|
|
char cnt = _mouthAnimations[0];
|
2016-09-14 23:39:27 +02:00
|
|
|
while (cnt--) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte a = *src++;
|
|
|
|
byte b = *src++;
|
|
|
|
byte c = *src++;
|
2016-09-14 23:39:27 +02:00
|
|
|
dst[0] = a;
|
|
|
|
dst[1] = b;
|
|
|
|
dst[2] = c;
|
|
|
|
if (dword_30728[0] != 0xFF) {
|
|
|
|
if ((a < dword_30728[0] || a > dword_30728[1])
|
|
|
|
&& (a < dword_30728[2] || a > dword_30728[3]))
|
|
|
|
dst += 3;
|
|
|
|
else
|
2016-12-04 14:26:44 -08:00
|
|
|
_mouthAnimations[0]--;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else
|
|
|
|
dst += 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-15 22:59:50 +01:00
|
|
|
// Original name: anim_perfin
|
|
|
|
void EdenGame::AnimEndCharacter() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_animationFlags &= ~0x80;
|
2016-12-04 14:26:44 -08:00
|
|
|
_animationDelay = 0;
|
2016-12-25 02:17:07 -08:00
|
|
|
_animationActive = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-15 22:59:50 +01:00
|
|
|
// Original name: perso_spr
|
|
|
|
void EdenGame::setCharacterSprite(byte *spr) {
|
2016-12-04 14:26:44 -08:00
|
|
|
byte *img = _imageDesc + 200 + 2;
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 count = 0;
|
2016-11-13 15:46:36 -08:00
|
|
|
byte c;
|
2016-09-14 23:39:27 +02:00
|
|
|
while ((c = *spr++)) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *src;
|
2016-10-08 21:21:21 +02:00
|
|
|
int16 index = 0;
|
2016-11-13 15:46:36 -08:00
|
|
|
byte cc = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (c == 1) {
|
|
|
|
cc = index;
|
|
|
|
c = *spr++;
|
|
|
|
}
|
2016-12-25 02:17:07 -08:00
|
|
|
_numImgDesc++;
|
2016-09-14 23:39:27 +02:00
|
|
|
index = (cc << 8) | c;
|
|
|
|
index -= 2;
|
|
|
|
|
2016-12-25 02:17:07 -08:00
|
|
|
if (index > _maxPersoDesc)
|
|
|
|
index = _maxPersoDesc;
|
2016-09-14 23:39:27 +02:00
|
|
|
index *= 2; //TODO: src = GetElem(ff_C2, index)
|
2017-01-01 11:51:48 -08:00
|
|
|
src = _globals->_varC2;
|
2016-12-04 14:54:58 -08:00
|
|
|
src += READ_LE_UINT16(src + index);
|
2016-09-14 23:39:27 +02:00
|
|
|
while ((c = *src++)) {
|
|
|
|
*img++ = c;
|
|
|
|
*img++ = *src++;
|
|
|
|
*img++ = *src++;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
2016-12-04 14:26:44 -08:00
|
|
|
_imageDesc[200] = count & 0xFF;
|
|
|
|
_imageDesc[201] = count >> 8;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
// Original name: af_image
|
|
|
|
void EdenGame::displayImage() {
|
2016-12-04 14:54:58 -08:00
|
|
|
byte *img = _imageDesc + 200;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-12-04 14:54:58 -08:00
|
|
|
int16 count = READ_LE_UINT16(img);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!count)
|
|
|
|
return;
|
2016-12-04 14:54:58 -08:00
|
|
|
|
|
|
|
byte *img_start = img;
|
|
|
|
byte *curimg = _imageDesc;
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
img += 2;
|
|
|
|
count *= 3;
|
|
|
|
while (count--)
|
|
|
|
*curimg++ = *img++;
|
|
|
|
img = img_start;
|
2016-12-04 14:54:58 -08:00
|
|
|
count = READ_LE_UINT16(img);
|
2016-09-14 23:39:27 +02:00
|
|
|
img += 2;
|
|
|
|
/////// draw it
|
|
|
|
while (count--) {
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 index = *img++;
|
2016-12-04 14:26:44 -08:00
|
|
|
uint16 x = *img++ + _gameIcons[0].sx;
|
|
|
|
uint16 y = *img++ + _gameIcons[0].sy;
|
|
|
|
byte *pix = _bankData;
|
2016-12-29 06:28:11 -08:00
|
|
|
byte *scr = _mainViewBuf + x + y * 640;
|
2016-09-14 23:39:27 +02:00
|
|
|
index--;
|
2016-12-04 14:54:58 -08:00
|
|
|
if (READ_LE_UINT16(pix) > 2)
|
2016-09-28 07:29:12 +02:00
|
|
|
readPalette(pix + 2);
|
2016-12-04 14:54:58 -08:00
|
|
|
pix += READ_LE_UINT16(pix);
|
|
|
|
pix += READ_LE_UINT16(pix + index * 2);
|
2016-09-14 23:48:01 +02:00
|
|
|
// int16 height:9
|
|
|
|
// int16 pad:6;
|
|
|
|
// int16 flag:1;
|
2016-12-04 14:54:58 -08:00
|
|
|
byte h0 = *pix++;
|
|
|
|
byte h1 = *pix++;
|
|
|
|
int16 w = ((h1 & 1) << 8) | h0;
|
|
|
|
int16 h = *pix++;
|
|
|
|
byte mode = *pix++;
|
2016-08-18 13:15:54 +02:00
|
|
|
if (mode != 0xFF && mode != 0xFE)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue; //TODO: enclosing block?
|
2016-08-18 13:15:54 +02:00
|
|
|
if (h1 & 0x80) {
|
|
|
|
// compressed
|
|
|
|
for (; h-- > 0;) {
|
2016-11-13 15:46:36 -08:00
|
|
|
for (int16 ww = w; ww > 0;) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte c = *pix++;
|
2016-08-18 13:15:54 +02:00
|
|
|
if (c >= 0x80) {
|
|
|
|
if (c == 0x80) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte fill = *pix++;
|
2016-08-18 13:15:54 +02:00
|
|
|
if (fill == 0) {
|
|
|
|
scr += 128 + 1;
|
|
|
|
ww -= 128 + 1;
|
|
|
|
} else {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte run;
|
2016-08-18 13:15:54 +02:00
|
|
|
*scr++ = fill; //TODO: wha?
|
|
|
|
*scr++ = fill;
|
|
|
|
ww -= 128 + 1;
|
|
|
|
for (run = 127; run--;)
|
|
|
|
*scr++ = fill;
|
|
|
|
}
|
|
|
|
} else {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte fill = *pix++;
|
|
|
|
byte run = 255 - c + 2;
|
2016-08-18 13:15:54 +02:00
|
|
|
ww -= run;
|
|
|
|
if (fill == 0)
|
|
|
|
scr += run;
|
2016-11-13 15:46:36 -08:00
|
|
|
else {
|
2016-08-18 13:15:54 +02:00
|
|
|
for (; run--;)
|
|
|
|
*scr++ = fill;
|
2016-11-13 15:46:36 -08:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
} else {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte run = c + 1;
|
2016-08-18 13:15:54 +02:00
|
|
|
ww -= run;
|
|
|
|
for (; run--;) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte p = *pix++;
|
2016-08-18 13:15:54 +02:00
|
|
|
if (p == 0)
|
|
|
|
scr++;
|
|
|
|
else
|
|
|
|
*scr++ = p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += 640 - w;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// uncompressed
|
|
|
|
for (; h--;) {
|
2016-11-13 15:46:36 -08:00
|
|
|
for (int16 ww = w; ww--;) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte p = *pix++;
|
2016-08-18 13:15:54 +02:00
|
|
|
if (p == 0)
|
|
|
|
scr++;
|
|
|
|
else
|
|
|
|
*scr++ = p;
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += 640 - w;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-15 22:59:50 +01:00
|
|
|
// Original name: af_perso1
|
|
|
|
void EdenGame::displayCharacter1() {
|
|
|
|
setCharacterSprite(_globals->_persoSpritePtr + READ_LE_UINT16(_globals->_persoSpritePtr));
|
2016-12-04 14:26:44 -08:00
|
|
|
displayImage();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-15 22:59:50 +01:00
|
|
|
// Original name: af_perso
|
|
|
|
void EdenGame::displayCharacter() {
|
|
|
|
loadCurrCharacter();
|
|
|
|
displayCharacter1();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::ef_perso() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_animationFlags &= 0x3F;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
// Original name: load_perso
|
|
|
|
void EdenGame::loadCharacter(perso_t *perso) {
|
|
|
|
_characterBankData = nullptr;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (!perso->_spriteBank)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
if (perso->_spriteBank != _globals->_characterImageBank) {
|
2017-01-15 22:59:50 +01:00
|
|
|
_curCharacterRect = &_characterRects[perso->_id]; //TODO: array of int16?
|
|
|
|
dword_30728 = _characterArray[perso->_id];
|
2016-09-14 23:39:27 +02:00
|
|
|
ef_perso();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterImageBank = perso->_spriteBank;
|
|
|
|
useBank(_globals->_characterImageBank);
|
2016-12-04 14:26:44 -08:00
|
|
|
_characterBankData = _bankData;
|
|
|
|
byte *ptr = _bankData;
|
2016-12-04 14:54:58 -08:00
|
|
|
ptr += READ_LE_UINT16(ptr);
|
2016-11-13 15:46:36 -08:00
|
|
|
byte *baseptr = ptr;
|
2016-12-04 14:54:58 -08:00
|
|
|
ptr += READ_LE_UINT16(ptr) - 2;
|
|
|
|
ptr = baseptr + READ_LE_UINT16(ptr) + 4;
|
|
|
|
_gameIcons[0].sx = READ_LE_UINT16(ptr);
|
|
|
|
_gameIcons[0].sy = READ_LE_UINT16(ptr + 2);
|
|
|
|
_gameIcons[0].ex = READ_LE_UINT16(ptr + 4);
|
|
|
|
_gameIcons[0].ey = READ_LE_UINT16(ptr + 6);
|
2016-09-14 23:39:27 +02:00
|
|
|
ptr += 8;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varC2 = ptr + 2;
|
2016-12-25 02:17:07 -08:00
|
|
|
_maxPersoDesc = READ_LE_UINT16(ptr) / 2;
|
2016-12-04 14:54:58 -08:00
|
|
|
ptr += READ_LE_UINT16(ptr);
|
2016-09-14 23:39:27 +02:00
|
|
|
baseptr = ptr;
|
2016-12-04 14:54:58 -08:00
|
|
|
ptr += READ_LE_UINT16(ptr) - 2;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_persoSpritePtr = baseptr;
|
|
|
|
_globals->_persoSpritePtr2 = baseptr + READ_LE_UINT16(ptr);
|
|
|
|
debug("load perso: b6 len is %ld", _globals->_persoSpritePtr2 - _globals->_persoSpritePtr);
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2017-01-01 11:51:48 -08:00
|
|
|
useBank(_globals->_characterImageBank);
|
2016-12-04 14:26:44 -08:00
|
|
|
_characterBankData = _bankData;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-15 22:59:50 +01:00
|
|
|
// Original name: load_perso_cour
|
|
|
|
void EdenGame::loadCurrCharacter() {
|
2017-01-01 11:51:48 -08:00
|
|
|
loadCharacter(_globals->_characterPtr);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::fin_perso() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_animationFlags &= 0x3F;
|
|
|
|
_globals->_curCharacterAnimPtr = nullptr;
|
|
|
|
_globals->_varCA = 0;
|
|
|
|
_globals->_characterImageBank = -1;
|
2017-01-15 22:59:50 +01:00
|
|
|
AnimEndCharacter();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::no_perso() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags == DisplayFlags::dfPerson) {
|
|
|
|
_globals->_displayFlags = _globals->_oldDisplayFlags;
|
2016-09-14 23:39:27 +02:00
|
|
|
fin_perso();
|
|
|
|
}
|
2016-12-28 03:43:13 -08:00
|
|
|
endCharacterSpeech();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: close_perso
|
|
|
|
void EdenGame::closeCharacterScreen() {
|
|
|
|
endCharacterSpeech();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags == DisplayFlags::dfPerson && _globals->_characterPtr->_id != PersonId::pidNarrator && _globals->_eventType != EventType::etEventE) {
|
2016-09-14 23:39:27 +02:00
|
|
|
rundcurs();
|
2016-12-25 02:17:07 -08:00
|
|
|
_savedUnderSubtitles = true;
|
2016-12-26 13:40:28 -08:00
|
|
|
restoreUnderSubtitles();
|
|
|
|
display();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var103 = 16;
|
|
|
|
}
|
|
|
|
if (_globals->_characterPtr->_id == PersonId::pidNarrator)
|
|
|
|
_globals->_var103 = 69;
|
|
|
|
_globals->_eloiHaveNews &= 1;
|
|
|
|
_globals->_varCA = 0;
|
|
|
|
_globals->_varF6 = 0;
|
|
|
|
if (_globals->_displayFlags == DisplayFlags::dfPerson) {
|
|
|
|
_globals->_displayFlags = _globals->_oldDisplayFlags;
|
|
|
|
_globals->_animationFlags &= 0x3F;
|
|
|
|
_globals->_curCharacterAnimPtr = nullptr;
|
2017-01-15 22:59:50 +01:00
|
|
|
AnimEndCharacter();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags & DisplayFlags::dfMirror) {
|
2016-12-31 05:11:33 -08:00
|
|
|
gameToMirror(1);
|
2016-09-30 07:48:27 +02:00
|
|
|
_scrollPos = _oldScrollPos;
|
2016-09-14 23:39:27 +02:00
|
|
|
scroll();
|
2016-08-18 13:15:54 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_numGiveObjs) {
|
|
|
|
if (!(_globals->_displayFlags & DisplayFlags::dfFlag2))
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_numGiveObjs = 0;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_varF2 & 1) {
|
|
|
|
_globals->_mirrorEffect = 6; // CHECKME: Verify the value
|
|
|
|
_globals->_varF2 &= ~1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
char oldLoc = _globals->_newLocation;
|
|
|
|
_globals->_newLocation = 0;
|
|
|
|
if (!(_globals->_narratorSequence & 0x80))
|
|
|
|
_globals->_var100 = 0xFF;
|
|
|
|
updateRoom(_globals->_roomNum);
|
|
|
|
_globals->_newLocation = oldLoc;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_chrono)
|
|
|
|
_globals->_chronoFlag = 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-10-07 23:06:10 +02:00
|
|
|
// Original name: af_fondsuiveur
|
|
|
|
void EdenGame::displayBackgroundFollower() {
|
2017-01-01 11:51:48 -08:00
|
|
|
char id = _globals->_characterPtr->_id;
|
2016-10-07 23:06:10 +02:00
|
|
|
for (Follower *follower = followerList; follower->_id != -1; follower++) {
|
|
|
|
if (follower->_id == id) {
|
2016-09-14 23:39:27 +02:00
|
|
|
int bank = 326;
|
2016-10-07 23:06:10 +02:00
|
|
|
if (follower->sx >= 320)
|
2016-09-14 23:39:27 +02:00
|
|
|
bank = 327;
|
2017-01-01 11:51:48 -08:00
|
|
|
useBank(bank + _globals->_roomBackgroundBankNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax_avecnoir(0, 0, 16);
|
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-15 22:24:28 +01:00
|
|
|
void EdenGame::displayNoFollower(int16 bank) {
|
|
|
|
if (bank) {
|
|
|
|
useBank(bank);
|
|
|
|
if (_globals->_characterPtr == &kPersons[PER_UNKN_156])
|
|
|
|
noclipax_avecnoir(0, 0, 16);
|
|
|
|
else
|
|
|
|
noclipax(0, 0, 16);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: af_fondperso1
|
|
|
|
void EdenGame::displayCharacterBackground1() {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte bank;
|
2016-09-14 23:39:27 +02:00
|
|
|
char *ptab;
|
2017-01-15 23:51:17 +01:00
|
|
|
if (_globals->_characterPtr == &kPersons[PER_ELOI]) {
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[0].sx = 0;
|
2017-01-15 23:51:17 +01:00
|
|
|
_characterRects[PER_ELOI].left = 2;
|
2017-01-01 11:51:48 -08:00
|
|
|
bank = _globals->_characterBackgroundBankIdx;
|
|
|
|
if (_globals->_eventType == EventType::etEventE) {
|
|
|
|
_globals->_var103 = 1;
|
2017-01-15 22:24:28 +01:00
|
|
|
displayNoFollower(bank);
|
|
|
|
return;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[0].sx = 60;
|
2017-01-15 23:51:17 +01:00
|
|
|
_characterRects[PER_ELOI].left = 62;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2017-01-15 23:51:17 +01:00
|
|
|
if (_globals->_characterPtr == &kPersons[PER_TAU]) {
|
2016-09-14 23:39:27 +02:00
|
|
|
bank = 37;
|
2017-01-15 22:24:28 +01:00
|
|
|
if (_globals->_curObjectId == Objects::obShell) {
|
|
|
|
displayNoFollower(bank);
|
|
|
|
return;
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
ptab = kPersoRoomBankTable + _globals->_characterPtr->_roomBankId;
|
2016-09-14 23:39:27 +02:00
|
|
|
bank = *ptab++;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_characterPtr->_partyMask & _globals->_party)) {
|
2016-09-14 23:39:27 +02:00
|
|
|
while ((bank = *ptab++) != 0xFF) {
|
2017-01-15 22:24:28 +01:00
|
|
|
if (bank == (_globals->_roomNum & 0xFF)) { //TODO: signed vs unsigned - chg bank to uns?
|
2016-09-14 23:39:27 +02:00
|
|
|
bank = *ptab;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ptab++;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-15 22:24:28 +01:00
|
|
|
if (bank == 0xFF) {
|
|
|
|
ptab = kPersoRoomBankTable + _globals->_characterPtr->_roomBankId;
|
|
|
|
bank = *ptab++;
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-10-07 23:06:10 +02:00
|
|
|
displayBackgroundFollower();
|
2017-01-15 22:24:28 +01:00
|
|
|
displayNoFollower(bank);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: af_fondperso
|
|
|
|
void EdenGame::displayCharacterBackground() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_characterPtr->_spriteBank) {
|
2016-12-18 14:13:36 -08:00
|
|
|
_backgroundSaved = false;
|
2016-12-28 03:43:13 -08:00
|
|
|
displayCharacterBackground1();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
// Original name: setpersoicon
|
|
|
|
void EdenGame::setCharacterIcon() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_iconsIndex == 4)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-11-29 14:03:36 -08:00
|
|
|
|
2017-01-15 23:51:17 +01:00
|
|
|
if (_globals->_characterPtr == &kPersons[PER_ELOI] && _globals->_eventType == EventType::etEventE) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_iconsIndex = 123;
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-17 09:32:43 -08:00
|
|
|
Icon *icon = _gameIcons;
|
2016-12-19 22:32:40 -08:00
|
|
|
Icon *icon2 = &_gameIcons[_roomIconsBase];
|
2016-11-29 14:03:36 -08:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
*icon2++ = *icon++; //TODO: is this ok?
|
|
|
|
*icon2++ = *icon++;
|
|
|
|
icon2->sx = -1;
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
// Original name: show_perso
|
|
|
|
void EdenGame::showCharacter() {
|
2017-01-01 11:51:48 -08:00
|
|
|
perso_t *perso = _globals->_characterPtr;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_spriteBank) {
|
2016-12-28 03:43:13 -08:00
|
|
|
closeRoom();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags != DisplayFlags::dfPerson) {
|
|
|
|
if (_globals->_displayFlags & DisplayFlags::dfMirror)
|
2016-09-26 23:44:42 +02:00
|
|
|
resetScroll();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_oldDisplayFlags = _globals->_displayFlags;
|
|
|
|
_globals->_displayFlags = DisplayFlags::dfPerson;
|
2016-12-04 14:26:44 -08:00
|
|
|
loadCharacter(perso);
|
|
|
|
setCharacterIcon();
|
2016-12-28 03:43:13 -08:00
|
|
|
displayCharacterBackground();
|
2017-01-15 23:51:17 +01:00
|
|
|
if (perso == &kPersons[PER_TAU] && _globals->_curObjectId == Objects::obShell) {
|
2016-12-25 02:17:07 -08:00
|
|
|
displaySubtitles();
|
2016-12-28 03:43:13 -08:00
|
|
|
updateCursor();
|
2016-12-18 14:13:36 -08:00
|
|
|
_paletteUpdateRequired = true;
|
2016-12-26 13:40:28 -08:00
|
|
|
display();
|
2016-09-14 23:39:27 +02:00
|
|
|
rundcurs();
|
|
|
|
return;
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-15 22:59:50 +01:00
|
|
|
loadCurrCharacter();
|
2016-09-14 23:39:27 +02:00
|
|
|
addanim();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!_globals->_curCharacterAnimPtr) {
|
2017-01-15 22:59:50 +01:00
|
|
|
displayCharacter();
|
2016-12-25 02:17:07 -08:00
|
|
|
displaySubtitles();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-04 14:26:44 -08:00
|
|
|
_restartAnimation = true;
|
2017-01-15 22:59:50 +01:00
|
|
|
animCharacter();
|
2016-09-14 23:39:27 +02:00
|
|
|
if (perso != &kPersons[PER_UNKN_156])
|
2016-12-28 03:43:13 -08:00
|
|
|
updateCursor();
|
2016-12-18 14:13:36 -08:00
|
|
|
_paletteUpdateRequired = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (perso != &kPersons[PER_UNKN_156])
|
|
|
|
rundcurs();
|
2016-12-26 13:40:28 -08:00
|
|
|
display();
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-10-07 23:06:10 +02:00
|
|
|
displayPlace();
|
2016-12-25 02:17:07 -08:00
|
|
|
displaySubtitles();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 02:17:07 -08:00
|
|
|
// Original name: showpersopanel
|
|
|
|
void EdenGame::displayCharacterPanel() {
|
2017-01-01 11:51:48 -08:00
|
|
|
perso_t *perso = _globals->_characterPtr;
|
2017-01-15 22:59:50 +01:00
|
|
|
loadCurrCharacter();
|
2016-09-14 23:39:27 +02:00
|
|
|
addanim();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!_globals->_curCharacterAnimPtr) {
|
2017-01-15 22:59:50 +01:00
|
|
|
displayCharacter();
|
2016-12-25 02:17:07 -08:00
|
|
|
displaySubtitles();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-04 14:26:44 -08:00
|
|
|
_restartAnimation = true;
|
2016-12-18 14:13:36 -08:00
|
|
|
_paletteUpdateRequired = true;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_drawFlags & DrawFlags::drDrawFlag8)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-15 22:59:50 +01:00
|
|
|
animCharacter();
|
2016-09-14 23:39:27 +02:00
|
|
|
if (perso != &kPersons[PER_UNKN_156])
|
2016-12-28 03:43:13 -08:00
|
|
|
updateCursor();
|
2016-12-26 13:40:28 -08:00
|
|
|
display();
|
2016-09-14 23:39:27 +02:00
|
|
|
if (perso != &kPersons[PER_UNKN_156])
|
|
|
|
rundcurs();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_drawFlags |= DrawFlags::drDrawFlag8;
|
|
|
|
_globals->_iconsIndex = 112;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 02:17:07 -08:00
|
|
|
void EdenGame::getDataSync() {
|
2017-01-01 11:51:48 -08:00
|
|
|
int16 num = _globals->_textNum;
|
|
|
|
if (_globals->_textBankIndex != 1)
|
2016-09-14 23:39:27 +02:00
|
|
|
num += 565;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_textBankIndex == 3)
|
2016-09-14 23:39:27 +02:00
|
|
|
num += 707;
|
|
|
|
if (num == 144)
|
|
|
|
num = 142;
|
2016-11-09 22:36:06 -08:00
|
|
|
_animateTalking = ReadDataSync(num - 1);
|
|
|
|
if (_animateTalking)
|
2016-12-29 06:28:11 -08:00
|
|
|
_numAnimFrames = readFrameNumber();
|
2016-09-14 23:39:27 +02:00
|
|
|
else
|
2016-12-04 14:26:44 -08:00
|
|
|
_numAnimFrames = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_textNum == 144)
|
2016-12-04 14:26:44 -08:00
|
|
|
_numAnimFrames = 48;
|
2016-12-25 13:45:47 -08:00
|
|
|
_animationTable = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-29 06:28:11 -08:00
|
|
|
// Original name: ReadNombreFrames
|
|
|
|
int16 EdenGame::readFrameNumber() {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 num = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
_animationTable = _gameLipsync + 7260 + 2; //TODO: fix me
|
2016-12-25 13:45:47 -08:00
|
|
|
while (*_animationTable++ != 0xFF)
|
2016-09-14 23:39:27 +02:00
|
|
|
num++;
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
2016-12-04 13:15:38 -08:00
|
|
|
void EdenGame::waitEndSpeak() {
|
2016-09-14 23:39:27 +02:00
|
|
|
for (;;) {
|
2016-12-25 02:17:07 -08:00
|
|
|
if (_animationActive)
|
2017-01-15 22:59:50 +01:00
|
|
|
animCharacter();
|
2016-09-14 23:39:27 +02:00
|
|
|
musicspy();
|
2016-12-26 13:40:28 -08:00
|
|
|
display();
|
2017-01-01 14:14:02 -08:00
|
|
|
_vm->pollEvents();
|
|
|
|
if (_vm->shouldQuit()) {
|
2016-12-28 03:43:13 -08:00
|
|
|
closeCharacterScreen();
|
2016-12-19 22:32:40 -08:00
|
|
|
edenShudown();
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-18 13:09:56 -08:00
|
|
|
if (!_mouseHeld)
|
2017-01-01 14:14:02 -08:00
|
|
|
if (_vm->isMouseButtonDown())
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-12-18 13:09:56 -08:00
|
|
|
if (_mouseHeld)
|
2017-01-01 14:14:02 -08:00
|
|
|
if (!_vm->isMouseButtonDown())
|
2016-12-18 13:09:56 -08:00
|
|
|
_mouseHeld = false;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-18 13:09:56 -08:00
|
|
|
_mouseHeld = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::my_bulle() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!_globals->_textNum)
|
2016-11-29 14:03:36 -08:00
|
|
|
return;
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *icons = phraseIconsBuffer;
|
2016-12-29 06:28:11 -08:00
|
|
|
byte *linesp = _sentenceCoordsBuffer;
|
2016-12-11 13:44:58 -08:00
|
|
|
byte *sentencePtr = _sentenceBuffer;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_numGiveObjs = 0;
|
|
|
|
_globals->_giveObj1 = 0;
|
|
|
|
_globals->_giveObj2 = 0;
|
|
|
|
_globals->_giveObj3 = 0;
|
|
|
|
_globals->_textWidthLimit = _subtitlesXWidth;
|
2017-01-14 00:30:37 +01:00
|
|
|
byte *textPtr = getPhrase(_globals->_textNum);
|
2016-12-25 13:45:47 -08:00
|
|
|
_numTextLines = 0;
|
2017-01-21 01:12:01 +01:00
|
|
|
int16 wordsOnLine = 0;
|
|
|
|
int16 wordWidth = 0;
|
|
|
|
int16 lineWidth = 0;
|
2016-11-13 15:46:36 -08:00
|
|
|
byte c;
|
2016-12-25 13:45:47 -08:00
|
|
|
while ((c = *textPtr++) != 0xFF) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (c == 0x11 || c == 0x13) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_phaseNum <= 272 || _globals->_phaseNum == 386) {
|
|
|
|
_globals->_eloiHaveNews = c & 0xF;
|
|
|
|
_globals->_var4D = _globals->_worldTyranSighted;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
} else if (c >= 0x80 && c < 0x90)
|
|
|
|
SysBeep(1);
|
|
|
|
else if (c >= 0x90 && c < 0xA0) {
|
2016-12-25 13:45:47 -08:00
|
|
|
while (*textPtr++ != 0xFF) ;
|
|
|
|
textPtr--;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else if (c >= 0xA0 && c < 0xC0)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_textToken1 = c & 0xF;
|
2016-09-14 23:39:27 +02:00
|
|
|
else if (c >= 0xC0 && c < 0xD0)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_textToken2 = c & 0xF;
|
2016-09-14 23:39:27 +02:00
|
|
|
else if (c >= 0xD0 && c < 0xE0) {
|
2016-12-25 13:45:47 -08:00
|
|
|
byte c1 = *textPtr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (c == 0xD2)
|
|
|
|
#ifdef FAKE_DOS_VERSION
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_textWidthLimit = c1 + 160;
|
2016-09-14 23:39:27 +02:00
|
|
|
#else
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_textWidthLimit = c1 + _subtitlesXCenter; //TODO: signed? 160 in pc ver
|
2016-09-14 23:39:27 +02:00
|
|
|
#endif
|
|
|
|
else {
|
2016-12-25 13:45:47 -08:00
|
|
|
byte c2 = *textPtr++;
|
2017-01-01 11:51:48 -08:00
|
|
|
switch (_globals->_numGiveObjs) {
|
2016-09-14 23:39:27 +02:00
|
|
|
case 0:
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_giveObj1 = c2;
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_giveObj2 = c2;
|
2016-08-18 13:15:54 +02:00
|
|
|
break;
|
2016-09-14 23:39:27 +02:00
|
|
|
case 2:
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_giveObj3 = c2;
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_numGiveObjs++;
|
2016-12-25 13:45:47 -08:00
|
|
|
*icons++ = *textPtr++;
|
|
|
|
*icons++ = *textPtr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
*icons++ = c2;
|
|
|
|
}
|
|
|
|
} else if (c >= 0xE0 && c < 0xFF)
|
|
|
|
SysBeep(1);
|
|
|
|
else if (c != '\r') {
|
2016-12-11 13:44:58 -08:00
|
|
|
*sentencePtr++ = c;
|
2016-12-26 14:25:19 -08:00
|
|
|
byte width = _gameFont[c];
|
2016-09-14 23:39:27 +02:00
|
|
|
#ifdef FAKE_DOS_VERSION
|
|
|
|
if (c == ' ')
|
2016-12-26 13:40:28 -08:00
|
|
|
width = _spaceWidth;
|
2016-09-14 23:39:27 +02:00
|
|
|
#endif
|
2017-01-21 01:12:01 +01:00
|
|
|
wordWidth += width;
|
|
|
|
lineWidth += width;
|
|
|
|
int16 overrun = lineWidth - _globals->_textWidthLimit;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (overrun > 0) {
|
2016-12-25 13:45:47 -08:00
|
|
|
_numTextLines++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (c != ' ') {
|
2017-01-21 01:12:01 +01:00
|
|
|
*linesp++ = wordsOnLine;
|
|
|
|
*linesp++ = wordWidth + _spaceWidth - overrun;
|
|
|
|
lineWidth = wordWidth;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2017-01-21 01:12:01 +01:00
|
|
|
*linesp++ = wordsOnLine + 1;
|
2016-12-26 13:40:28 -08:00
|
|
|
*linesp++ = _spaceWidth - overrun; //TODO: checkme
|
2017-01-21 01:12:01 +01:00
|
|
|
lineWidth = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2017-01-21 01:12:01 +01:00
|
|
|
wordWidth = 0;
|
|
|
|
wordsOnLine = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
|
|
|
if (c == ' ') {
|
2017-01-21 01:12:01 +01:00
|
|
|
wordsOnLine++;
|
|
|
|
wordWidth = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-12-25 13:45:47 -08:00
|
|
|
_numTextLines++;
|
2017-01-21 01:12:01 +01:00
|
|
|
*linesp++ = wordsOnLine + 1;
|
|
|
|
*linesp++ = wordWidth;
|
2016-12-11 13:44:58 -08:00
|
|
|
*sentencePtr = c;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_textBankIndex == 2 && _globals->_textNum == 101 && _globals->_prefLanguage == 1)
|
2016-12-29 06:28:11 -08:00
|
|
|
patchSentence();
|
2016-09-14 23:39:27 +02:00
|
|
|
my_pr_bulle();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!_globals->_numGiveObjs)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-25 02:17:07 -08:00
|
|
|
useMainBank();
|
2016-12-25 13:45:47 -08:00
|
|
|
if (_numTextLines < 3)
|
|
|
|
_numTextLines = 3;
|
2016-09-14 23:39:27 +02:00
|
|
|
icons = phraseIconsBuffer;
|
2017-01-01 11:51:48 -08:00
|
|
|
for (byte i = 0; i < _globals->_numGiveObjs; i++) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte x = *icons++;
|
|
|
|
byte y = *icons++;
|
|
|
|
byte s = *icons++;
|
2016-12-26 13:40:28 -08:00
|
|
|
spriteOnSubtitle(52, x + _subtitlesXCenter, y - 1);
|
|
|
|
spriteOnSubtitle(s + 9, x + _subtitlesXCenter + 1, y);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::my_pr_bulle() {
|
2016-12-29 06:28:11 -08:00
|
|
|
CLBlitter_FillView(_subtitlesView, 0);
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_prefLanguage == 0)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-11-29 14:03:36 -08:00
|
|
|
|
2016-12-29 06:28:11 -08:00
|
|
|
byte *coo = _sentenceCoordsBuffer;
|
2016-11-29 14:03:36 -08:00
|
|
|
bool done = false;
|
2016-12-29 06:28:11 -08:00
|
|
|
textout = _subtitlesViewBuf;
|
2016-12-25 13:45:47 -08:00
|
|
|
byte *textPtr = _sentenceBuffer;
|
2016-10-17 03:05:37 +03:00
|
|
|
int16 lines = 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
while (!done) {
|
2016-12-29 06:28:11 -08:00
|
|
|
int16 numWords = *coo++; // num words on line
|
|
|
|
int16 padSize = *coo++; // amount of extra spacing
|
|
|
|
byte *currOut = textout;
|
|
|
|
int16 extraSpacing = numWords > 1 ? padSize / (numWords - 1) + 1 : 0;
|
2016-12-25 13:45:47 -08:00
|
|
|
if (lines == _numTextLines)
|
2016-11-13 15:46:36 -08:00
|
|
|
extraSpacing = 0;
|
2016-12-25 13:45:47 -08:00
|
|
|
byte c = *textPtr++;
|
2016-12-29 06:28:11 -08:00
|
|
|
while (!done && (numWords > 0)) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (c < 0x80 && c != '\r') {
|
|
|
|
if (c == ' ') {
|
2016-12-29 06:28:11 -08:00
|
|
|
numWords--;
|
|
|
|
if (padSize >= extraSpacing) {
|
2016-12-26 13:40:28 -08:00
|
|
|
textout += extraSpacing + _spaceWidth;
|
2016-12-29 06:28:11 -08:00
|
|
|
padSize -= extraSpacing;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-12-29 06:28:11 -08:00
|
|
|
textout += padSize + _spaceWidth;
|
|
|
|
padSize = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
} else {
|
2016-12-29 06:28:11 -08:00
|
|
|
int16 charWidth = _gameFont[c];
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_drawFlags & DrawFlags::drDrawMenu)) {
|
2016-12-26 13:40:28 -08:00
|
|
|
textout += _subtitlesXWidth;
|
2016-12-18 14:13:36 -08:00
|
|
|
if (!_specialTextMode)
|
2016-12-29 06:28:11 -08:00
|
|
|
drawSubtitleChar(c, 195, charWidth);
|
2016-09-14 23:39:27 +02:00
|
|
|
textout++;
|
2016-12-18 14:13:36 -08:00
|
|
|
if (!_specialTextMode)
|
2016-12-29 06:28:11 -08:00
|
|
|
drawSubtitleChar(c, 195, charWidth);
|
2016-12-26 13:40:28 -08:00
|
|
|
textout -= _subtitlesXWidth + 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-18 14:13:36 -08:00
|
|
|
if (_specialTextMode)
|
2016-12-29 06:28:11 -08:00
|
|
|
drawSubtitleChar(c, 250, charWidth);
|
2016-09-14 23:39:27 +02:00
|
|
|
else
|
2016-12-29 06:28:11 -08:00
|
|
|
drawSubtitleChar(c, 230, charWidth);
|
|
|
|
textout += charWidth;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
} else
|
2016-10-24 23:18:08 +02:00
|
|
|
error("my_pr_bulle: Unexpected format");
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
c = *textPtr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (c == 0xFF)
|
2016-11-13 15:46:36 -08:00
|
|
|
done = true;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-29 06:28:11 -08:00
|
|
|
textout = currOut + _subtitlesXWidth * FONT_HEIGHT;
|
2016-10-17 03:05:37 +03:00
|
|
|
lines++;
|
2016-12-25 13:45:47 -08:00
|
|
|
textPtr--;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-29 06:28:11 -08:00
|
|
|
// Original name: charsurbulle
|
|
|
|
void EdenGame::drawSubtitleChar(byte c, byte color, int16 width) {
|
2016-12-18 14:13:36 -08:00
|
|
|
byte *glyph = _gameFont + 256 + c * FONT_HEIGHT;
|
2016-12-29 06:28:11 -08:00
|
|
|
_textOutPtr = textout;
|
2016-11-13 15:46:36 -08:00
|
|
|
for (int16 h = 0; h < FONT_HEIGHT; h++) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte bits = *glyph++;
|
|
|
|
int16 mask = 0x80;
|
2016-11-13 15:46:36 -08:00
|
|
|
for (int16 w = 0; w < width; w++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (bits & mask)
|
2016-12-29 06:28:11 -08:00
|
|
|
*_textOutPtr = color;
|
|
|
|
_textOutPtr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
mask >>= 1;
|
|
|
|
}
|
2016-12-29 06:28:11 -08:00
|
|
|
_textOutPtr += _subtitlesXWidth - width;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-25 02:17:07 -08:00
|
|
|
// Original name: af_subtitle
|
|
|
|
void EdenGame::displaySubtitles() {
|
2016-12-29 06:28:11 -08:00
|
|
|
byte *src = _subtitlesViewBuf;
|
|
|
|
byte *dst = _mainViewBuf;
|
2016-11-13 15:46:36 -08:00
|
|
|
int16 y;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags & DisplayFlags::dfFlag2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
y = 174;
|
2017-01-01 11:51:48 -08:00
|
|
|
if ((_globals->_drawFlags & DrawFlags::drDrawMenu) && _numTextLines == 1)
|
2016-09-14 23:39:27 +02:00
|
|
|
y = 167;
|
2016-12-26 13:40:28 -08:00
|
|
|
dst += 640 * (y - _numTextLines * FONT_HEIGHT) + _subtitlesXScrMargin;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
|
|
|
y = 174;
|
2016-12-26 13:40:28 -08:00
|
|
|
dst += 640 * (y - _numTextLines * FONT_HEIGHT) + _scrollPos + _subtitlesXScrMargin;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-25 02:17:07 -08:00
|
|
|
if (_animationActive && !_personTalking)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-26 13:40:28 -08:00
|
|
|
saveUnderSubtitles(y);
|
2016-12-25 13:45:47 -08:00
|
|
|
for (int16 h = 0; h < _numTextLines * FONT_HEIGHT + 1; h++) {
|
2016-12-26 13:40:28 -08:00
|
|
|
for (int16 w = 0; w < _subtitlesXWidth; w++) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte c = *src++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (c)
|
|
|
|
*dst = c;
|
|
|
|
dst++;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-26 13:40:28 -08:00
|
|
|
dst += 640 - _subtitlesXWidth;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 02:17:07 -08:00
|
|
|
// Original name: sauvefondbulle
|
2016-12-26 13:40:28 -08:00
|
|
|
void EdenGame::saveUnderSubtitles(int16 y) {
|
2016-12-25 13:45:47 -08:00
|
|
|
_underSubtitlesScreenRect.top = y - _numTextLines * FONT_HEIGHT;
|
2016-12-26 13:40:28 -08:00
|
|
|
_underSubtitlesScreenRect.left = _scrollPos + _subtitlesXScrMargin;
|
|
|
|
_underSubtitlesScreenRect.right = _scrollPos + _subtitlesXScrMargin + _subtitlesXWidth - 1;
|
2016-09-30 07:48:27 +02:00
|
|
|
_underSubtitlesScreenRect.bottom = y;
|
|
|
|
_underSubtitlesBackupRect.top = 0;
|
2016-12-25 13:45:47 -08:00
|
|
|
_underSubtitlesBackupRect.bottom = _numTextLines * FONT_HEIGHT;
|
2017-01-01 11:51:48 -08:00
|
|
|
CLBlitter_CopyViewRect(_mainView, _underSubtitlesView, &_underSubtitlesScreenRect, &_underSubtitlesBackupRect);
|
2016-12-25 02:17:07 -08:00
|
|
|
_savedUnderSubtitles = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 02:17:07 -08:00
|
|
|
// Original name: restaurefondbulle
|
2016-12-26 13:40:28 -08:00
|
|
|
void EdenGame::restoreUnderSubtitles() {
|
2016-12-25 02:17:07 -08:00
|
|
|
if (!_savedUnderSubtitles)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
CLBlitter_CopyViewRect(_underSubtitlesView, _mainView, &_underSubtitlesBackupRect, &_underSubtitlesScreenRect);
|
2016-12-25 02:17:07 -08:00
|
|
|
_savedUnderSubtitles = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-29 06:28:11 -08:00
|
|
|
// Original name: af_subtitlehnm
|
|
|
|
void EdenGame::displayHNMSubtitle() {
|
|
|
|
byte *src = _subtitlesViewBuf;
|
2016-12-26 13:40:28 -08:00
|
|
|
byte *dst = _hnmViewBuf + _subtitlesXScrMargin + (158 - _numTextLines * FONT_HEIGHT) * 320;
|
2016-12-25 13:45:47 -08:00
|
|
|
for (int16 y = 0; y < _numTextLines * FONT_HEIGHT; y++) {
|
2016-12-26 13:40:28 -08:00
|
|
|
for (int16 x = 0; x < _subtitlesXWidth; x++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
char c = *src++;
|
|
|
|
if (c)
|
|
|
|
*dst = c;
|
|
|
|
dst++;
|
|
|
|
}
|
2016-12-26 13:40:28 -08:00
|
|
|
dst += 320 - _subtitlesXWidth;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-29 06:28:11 -08:00
|
|
|
// Original name: patchPhrase
|
|
|
|
void EdenGame::patchSentence() {
|
2016-12-11 13:44:58 -08:00
|
|
|
_sentenceBuffer[36] = 'c';
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::vavapers() {
|
2017-01-01 11:51:48 -08:00
|
|
|
perso_t *perso = _globals->_characterPtr;
|
|
|
|
_globals->_curPersoFlags = perso->_flags;
|
|
|
|
_globals->_curPersoItems = perso->_items;
|
|
|
|
_globals->_curCharacterPowers = perso->_powers;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::citadelle() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var69++;
|
|
|
|
_globals->_varF6++;
|
2016-10-24 00:04:32 +02:00
|
|
|
parlemoiNormalFlag = true;
|
2016-12-04 13:15:38 -08:00
|
|
|
_closeCharacterDialog = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-14 00:30:37 +01:00
|
|
|
// Original name: choixzone
|
|
|
|
void EdenGame::selectZone() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_giveObj3)
|
|
|
|
_globals->_iconsIndex = 6;
|
2016-09-14 23:39:27 +02:00
|
|
|
else
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_iconsIndex = 10;
|
|
|
|
_globals->_autoDialog = false;
|
2016-12-04 13:15:38 -08:00
|
|
|
putObject();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
void EdenGame::showEvents1() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var113 = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_ici(3);
|
|
|
|
}
|
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
void EdenGame::showEvents() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_eventType && _globals->_displayFlags != DisplayFlags::dfPerson)
|
2016-12-28 03:43:13 -08:00
|
|
|
showEvents1();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::parle_mfin() {
|
2017-01-01 11:51:48 -08:00
|
|
|
perso_t *perso = _globals->_characterPtr;
|
|
|
|
if (_globals->_curObjectId) {
|
|
|
|
char curobj = _globals->_curObjectId;
|
|
|
|
if (_globals->_dialogType == DialogType::dtHint)
|
2016-08-18 13:15:54 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
object_t *obj = getObjectPtr(_globals->_curObjectId);
|
|
|
|
if (_globals->_dialogType == DialogType::dtDinoItem)
|
|
|
|
perso = _globals->_roomCharacterPtr;
|
2016-12-04 13:15:38 -08:00
|
|
|
if (isAnswerYes()) {
|
2017-01-01 11:51:48 -08:00
|
|
|
loseObject(_globals->_curObjectId);
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_powers |= obj->_powerMask;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_items |= obj->_itemMask;
|
2016-12-11 22:52:10 -08:00
|
|
|
specialObjects(perso, curobj);
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
|
|
|
}
|
2016-12-04 13:15:38 -08:00
|
|
|
if (!isAnswerYes())
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-11 13:44:58 -08:00
|
|
|
nextInfo();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!_globals->_lastInfo)
|
2016-12-04 13:15:38 -08:00
|
|
|
_closeCharacterDialog = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
else {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_nextDialogPtr = nullptr;
|
2016-12-04 13:15:38 -08:00
|
|
|
_closeCharacterDialog = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::parlemoi_normal() {
|
2017-01-18 23:05:38 +01:00
|
|
|
Dialog *dial;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!_globals->_nextDialogPtr) {
|
|
|
|
perso_t *perso = _globals->_characterPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (perso) {
|
2017-01-01 11:51:48 -08:00
|
|
|
int16 num = (perso->_id << 3) | _globals->_dialogType;
|
2017-01-18 23:05:38 +01:00
|
|
|
dial = (Dialog *)getElem(_gameDialogs, num);
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-12-28 03:43:13 -08:00
|
|
|
closeCharacterScreen();
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-12-04 13:15:38 -08:00
|
|
|
if (_closeCharacterDialog) {
|
2016-12-28 03:43:13 -08:00
|
|
|
closeCharacterScreen();
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
dial = _globals->_nextDialogPtr;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-11-13 15:46:36 -08:00
|
|
|
char ok = dial_scan(dial);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_nextDialogPtr = _globals->_dialogPtr;
|
2016-12-04 13:15:38 -08:00
|
|
|
_closeCharacterDialog = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!ok)
|
2016-12-28 03:43:13 -08:00
|
|
|
closeCharacterScreen();
|
2016-09-14 23:39:27 +02:00
|
|
|
else
|
|
|
|
parle_mfin();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::parle_moi() {
|
2016-12-28 03:43:13 -08:00
|
|
|
endCharacterSpeech();
|
2017-01-01 11:51:48 -08:00
|
|
|
byte r28 = _globals->_varF6;
|
|
|
|
_globals->_varF6 = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!r28) {
|
2016-12-04 13:15:38 -08:00
|
|
|
setChoiceNo();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_drawFlags & DrawFlags::drDrawInventory)
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_drawFlags & DrawFlags::drDrawTopScreen)
|
2016-09-25 23:17:25 +02:00
|
|
|
drawTopScreen();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId) {
|
|
|
|
if (_globals->_dialogType == DialogType::dtTalk) {
|
|
|
|
_globals->_dialogType = DialogType::dtItem;
|
|
|
|
_globals->_nextDialogPtr = nullptr;
|
2016-12-04 13:15:38 -08:00
|
|
|
_closeCharacterDialog = false;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
parlemoi_normal();
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_dialogType == DialogType::dtItem) {
|
|
|
|
_globals->_dialogType = DialogType::dtTalk;
|
2016-12-04 13:15:38 -08:00
|
|
|
if (!_closeCharacterDialog)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_nextDialogPtr = nullptr;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-10-24 00:04:32 +02:00
|
|
|
if (parlemoiNormalFlag) {
|
2016-09-14 23:39:27 +02:00
|
|
|
parlemoi_normal();
|
2016-08-18 13:15:54 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-01-18 23:05:38 +01:00
|
|
|
Dialog *dial;
|
2016-12-26 14:25:19 -08:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!_globals->_lastDialogPtr) {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 num = 160;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_phaseNum >= 400)
|
2016-09-14 23:39:27 +02:00
|
|
|
num++;
|
2017-01-18 23:05:38 +01:00
|
|
|
dial = (Dialog *)getElem(_gameDialogs, num);
|
2016-08-18 13:15:54 +02:00
|
|
|
} else
|
2017-01-01 11:51:48 -08:00
|
|
|
dial = _globals->_lastDialogPtr;
|
2016-12-26 14:25:19 -08:00
|
|
|
char ok = dial_scan(dial);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_lastDialogPtr = _globals->_dialogPtr;
|
2016-10-24 00:04:32 +02:00
|
|
|
parlemoiNormalFlag = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!ok) {
|
2016-10-24 00:04:32 +02:00
|
|
|
parlemoiNormalFlag = true;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_var60) {
|
2017-01-15 23:51:17 +01:00
|
|
|
if (_globals->_characterPtr == &kPersons[PER_ELOI]) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_dialogType = DialogType::dtTalk;
|
|
|
|
if (_globals->_eloiHaveNews)
|
2016-09-14 23:39:27 +02:00
|
|
|
parlemoi_normal();
|
|
|
|
else
|
2016-12-28 03:43:13 -08:00
|
|
|
closeCharacterScreen();
|
2016-09-14 23:39:27 +02:00
|
|
|
} else
|
2016-12-28 03:43:13 -08:00
|
|
|
closeCharacterScreen();
|
2016-09-14 23:39:27 +02:00
|
|
|
} else
|
|
|
|
parlemoi_normal();
|
|
|
|
} else
|
|
|
|
parle_mfin();
|
|
|
|
} else
|
2016-12-28 03:43:13 -08:00
|
|
|
closeCharacterScreen();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-14 00:30:37 +01:00
|
|
|
// Original name: init_perso_ptr
|
|
|
|
void EdenGame::initCharacterPointers(perso_t *perso) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_metPersonsMask1 |= perso->_partyMask;
|
|
|
|
_globals->_metPersonsMask2 |= perso->_partyMask;
|
|
|
|
_globals->_nextDialogPtr = nullptr;
|
2016-12-04 13:15:38 -08:00
|
|
|
_closeCharacterDialog = false;
|
2017-01-21 01:12:01 +01:00
|
|
|
_dialogSkipFlags = DialogFlags::dfSpoken;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var60 = 0;
|
|
|
|
_globals->_textToken1 = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::perso1(perso_t *perso) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_phaseActionsCount++;
|
2017-01-15 23:51:17 +01:00
|
|
|
if (perso == &kPersons[PER_TAU])
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_phaseActionsCount--;
|
|
|
|
_globals->_characterPtr = perso;
|
2017-01-14 00:30:37 +01:00
|
|
|
initCharacterPointers(perso);
|
2016-09-14 23:39:27 +02:00
|
|
|
parle_moi();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::perso_normal(perso_t *perso) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_lastDialogPtr = nullptr;
|
|
|
|
_globals->_dialogType = DialogType::dtTalk;
|
2016-10-24 00:04:32 +02:00
|
|
|
parlemoiNormalFlag = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso1(perso);
|
|
|
|
}
|
|
|
|
|
2016-12-11 22:52:10 -08:00
|
|
|
// Original name: persoparle
|
|
|
|
void EdenGame::handleCharacterDialog(int16 pers) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso = &kPersons[pers];
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterPtr = perso;
|
|
|
|
_globals->_dialogType = DialogType::dtInspect;
|
|
|
|
uint16 idx = perso->_id * 8 | _globals->_dialogType;
|
2017-01-18 23:05:38 +01:00
|
|
|
dialoscansvmas((Dialog *)getElem(_gameDialogs, idx));
|
2016-10-07 23:06:10 +02:00
|
|
|
displayPlace();
|
2016-12-25 02:17:07 -08:00
|
|
|
displaySubtitles();
|
2016-09-14 23:39:27 +02:00
|
|
|
persovox();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varCA = 0;
|
|
|
|
_globals->_dialogType = DialogType::dtTalk;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: roi
|
|
|
|
void EdenGame::actionKing() {
|
|
|
|
perso_normal(&kPersons[PER_KING]);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: dina
|
|
|
|
void EdenGame::actionDina() {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_normal(&kPersons[PER_DINA]);
|
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: thoo
|
|
|
|
void EdenGame::actionThoo() {
|
2017-01-15 23:51:17 +01:00
|
|
|
perso_normal(&kPersons[PER_TAU]);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: monk
|
|
|
|
void EdenGame::actionMonk() {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_normal(&kPersons[PER_MONK]);
|
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: bourreau
|
|
|
|
void EdenGame::actionTormentor() {
|
2017-01-15 23:51:17 +01:00
|
|
|
perso_normal(&kPersons[PER_JABBER]);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: messager
|
|
|
|
void EdenGame::actionMessenger() {
|
2017-01-15 23:51:17 +01:00
|
|
|
perso_normal(&kPersons[PER_ELOI]);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: mango
|
|
|
|
void EdenGame::actionMango() {
|
2017-01-15 23:51:17 +01:00
|
|
|
perso_normal(&kPersons[PER_MUNGO]);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: eve
|
|
|
|
void EdenGame::actionEve() {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_normal(&kPersons[PER_EVE]);
|
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: azia
|
|
|
|
void EdenGame::actionAzia() {
|
2017-01-15 23:51:17 +01:00
|
|
|
perso_normal(&kPersons[PER_SHAZIA]);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: mammi
|
|
|
|
void EdenGame::actionMammi() {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso;
|
2016-10-07 00:45:08 +02:00
|
|
|
for (perso = &kPersons[PER_MAMMI]; perso->_partyMask == PersonMask::pmLeader; perso++) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (perso->_roomNum == _globals->_roomNum) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_normal(perso);
|
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: gardes
|
|
|
|
void EdenGame::actionGuards() {
|
|
|
|
perso_normal(&kPersons[PER_GUARDS]);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: bambou
|
|
|
|
void EdenGame::actionBamboo() {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_normal(&kPersons[PER_BAMBOO]);
|
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: kabuka
|
|
|
|
void EdenGame::actionKabuka() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_roomNum == 0x711) perso_normal(&kPersons[PER_KABUKA]);
|
2016-12-28 03:43:13 -08:00
|
|
|
else actionBamboo();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: fisher
|
|
|
|
void EdenGame::actionFisher() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_roomNum == 0x902) perso_normal(&kPersons[PER_FISHER]);
|
2016-12-28 03:43:13 -08:00
|
|
|
else actionKabuka();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: dino
|
|
|
|
void EdenGame::actionDino() {
|
2017-01-01 11:51:48 -08:00
|
|
|
perso_t *perso = _globals->_roomCharacterPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!perso)
|
|
|
|
return;
|
2016-10-24 00:04:32 +02:00
|
|
|
parlemoiNormalFlag = true;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_dialogType = DialogType::dtTalk;
|
|
|
|
_globals->_roomCharacterFlags = perso->_flags;
|
|
|
|
_globals->_roomPersoItems = perso->_items;
|
|
|
|
_globals->_roomCharacterPowers = perso->_powers;
|
|
|
|
_globals->_characterPtr = perso;
|
2017-01-14 00:30:37 +01:00
|
|
|
initCharacterPointers(perso);
|
2016-09-14 23:39:27 +02:00
|
|
|
debug("beg dino talk");
|
|
|
|
parle_moi();
|
|
|
|
debug("end dino talk");
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_areaNum == Areas::arWhiteArch)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_var60)
|
2016-12-04 13:15:38 -08:00
|
|
|
waitEndSpeak();
|
2017-01-01 14:14:02 -08:00
|
|
|
if (_vm->shouldQuit())
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-15 23:51:17 +01:00
|
|
|
perso = &kPersons[PER_MUNGO];
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_party & PersonMask::pmMungo)) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso = &kPersons[PER_DINA];
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_party & PersonMask::pmDina)) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso = &kPersons[PER_EVE];
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_party & PersonMask::pmEve)) {
|
2016-12-28 03:43:13 -08:00
|
|
|
perso = &kPersons[PER_GUARDS];
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_dialogType = DialogType::dtDinoAction;
|
|
|
|
if (_globals->_curObjectId)
|
|
|
|
_globals->_dialogType = DialogType::dtDinoItem;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso1(perso);
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_roomCharacterType == PersonFlags::pftMosasaurus && !_globals->_curObjectId) {
|
|
|
|
_globals->_areaPtr->_flags |= AreaFlags::afFlag20;
|
|
|
|
placeVava(_globals->_areaPtr);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: tyran
|
|
|
|
void EdenGame::actionTyran() {
|
2017-01-01 11:51:48 -08:00
|
|
|
perso_t *perso = _globals->_roomCharacterPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!perso)
|
|
|
|
return;
|
2016-10-24 00:04:32 +02:00
|
|
|
|
|
|
|
parlemoiNormalFlag = true;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_dialogType = DialogType::dtTalk;
|
|
|
|
_globals->_roomCharacterFlags = perso->_flags;
|
|
|
|
_globals->_characterPtr = perso;
|
2017-01-14 00:30:37 +01:00
|
|
|
initCharacterPointers(perso);
|
2017-01-15 23:51:17 +01:00
|
|
|
perso = &kPersons[PER_MUNGO];
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_party & PersonMask::pmMungo)) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso = &kPersons[PER_DINA];
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_party & PersonMask::pmDina)) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso = &kPersons[PER_EVE];
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_party & PersonMask::pmEve)) {
|
2016-12-28 03:43:13 -08:00
|
|
|
perso = &kPersons[PER_GUARDS];
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_dialogType = DialogType::dtDinoAction;
|
|
|
|
if (_globals->_curObjectId)
|
|
|
|
_globals->_dialogType = DialogType::dtDinoItem;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso1(perso);
|
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: morkus
|
|
|
|
void EdenGame::actionMorkus() {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_normal(&kPersons[PER_MORKUS]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::comment() {
|
2016-10-24 00:04:32 +02:00
|
|
|
perso_t *perso = &kPersons[PER_DINA];
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_party & PersonMask::pmDina)) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso = &kPersons[PER_EVE];
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_party & PersonMask::pmEve)) {
|
2016-12-28 03:43:13 -08:00
|
|
|
perso = &kPersons[PER_GUARDS];
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_party & PersonMask::pmThugg))
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_dialogType = DialogType::dtHint;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso1(perso);
|
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: adam
|
|
|
|
void EdenGame::actionAdam() {
|
2016-09-26 23:44:42 +02:00
|
|
|
resetScroll();
|
2017-01-01 11:51:48 -08:00
|
|
|
switch (_globals->_curObjectId) {
|
2016-09-14 23:39:27 +02:00
|
|
|
case Objects::obNone:
|
2016-12-28 03:43:13 -08:00
|
|
|
gotoPanel();
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
case Objects::obRoot:
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_roomNum == 2817
|
|
|
|
&& _globals->_phaseNum > 496 && _globals->_phaseNum < 512) {
|
2016-09-14 23:39:27 +02:00
|
|
|
bigphase1();
|
2016-09-26 23:44:42 +02:00
|
|
|
loseObject(Objects::obRoot);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var100 = 0xFF;
|
2016-09-26 23:44:42 +02:00
|
|
|
quitMirror();
|
2017-01-01 11:51:48 -08:00
|
|
|
updateRoom(_globals->_roomNum);
|
2017-01-15 23:51:17 +01:00
|
|
|
removeFromParty(PER_ELOI);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eventType = EventType::etEvent3;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-12-04 13:15:38 -08:00
|
|
|
waitEndSpeak();
|
2017-01-01 14:14:02 -08:00
|
|
|
if (_vm->shouldQuit())
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-28 03:43:13 -08:00
|
|
|
closeCharacterScreen();
|
2017-01-15 23:51:17 +01:00
|
|
|
removeFromParty(PER_ELOI);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomNum = 2818;
|
|
|
|
_globals->_areaNum = Areas::arWhiteArch;
|
|
|
|
_globals->_eventType = EventType::etEvent5;
|
|
|
|
_globals->_valleyVidNum = 0;
|
|
|
|
_globals->_mirrorEffect = 6; // CHECKME: Verify the value
|
|
|
|
_globals->_newMusicType = MusicType::mtNormal;
|
|
|
|
updateRoom(_globals->_roomNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_dialogType = DialogType::dtHint;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso1(&kPersons[PER_EVE]);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
case Objects::obShell:
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_dialogType = DialogType::dtHint;
|
2017-01-15 23:51:17 +01:00
|
|
|
perso1(&kPersons[PER_TAU]);
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
case Objects::obFlute:
|
|
|
|
case Objects::obTrumpet:
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_roomCharacterType) {
|
2016-09-26 23:44:42 +02:00
|
|
|
quitMirror();
|
2017-01-01 11:51:48 -08:00
|
|
|
updateRoom(_globals->_roomNum);
|
2016-12-28 03:43:13 -08:00
|
|
|
actionDino();
|
2016-09-14 23:39:27 +02:00
|
|
|
} else
|
|
|
|
comment();
|
|
|
|
break;
|
|
|
|
case Objects::obTablet1:
|
|
|
|
case Objects::obTablet2:
|
|
|
|
case Objects::obTablet3:
|
|
|
|
case Objects::obTablet4:
|
|
|
|
case Objects::obTablet5:
|
2016-10-24 00:04:32 +02:00
|
|
|
case Objects::obTablet6: {
|
2017-01-01 11:51:48 -08:00
|
|
|
if ((_globals->_partyOutside & PersonMask::pmDina)
|
|
|
|
&& _globals->_curObjectId == Objects::obTablet1 && _globals->_phaseNum == 370)
|
2016-12-19 22:32:40 -08:00
|
|
|
incPhase();
|
2017-01-01 11:51:48 -08:00
|
|
|
char *objvid = &kTabletView[(_globals->_curObjectId - Objects::obTablet1) * 2];
|
2016-12-18 13:09:56 -08:00
|
|
|
object_t *object = getObjectPtr(*objvid++);
|
2016-10-24 00:04:32 +02:00
|
|
|
int16 vid = 84;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (!object->_count)
|
2016-09-14 23:39:27 +02:00
|
|
|
vid = *objvid;
|
2017-01-14 00:30:37 +01:00
|
|
|
hideBars();
|
2016-12-18 14:13:36 -08:00
|
|
|
_specialTextMode = true;
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(vid);
|
2016-12-18 14:13:36 -08:00
|
|
|
_paletteUpdateRequired = true;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_mirrorEffect = 16; // CHECKME: Verify the value
|
2016-09-28 07:29:12 +02:00
|
|
|
showBars();
|
2016-12-31 05:11:33 -08:00
|
|
|
gameToMirror(0);
|
2016-10-24 00:04:32 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
case Objects::obApple:
|
|
|
|
case Objects::obShroom:
|
|
|
|
case Objects::obBadShroom:
|
|
|
|
case Objects::obNest:
|
|
|
|
case Objects::obFullNest:
|
|
|
|
case Objects::obDrum:
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_party & PersonMask::pmThugg) {
|
|
|
|
_globals->_dialogType = DialogType::dtHint;
|
2016-12-28 03:43:13 -08:00
|
|
|
perso1(&kPersons[PER_GUARDS]);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
comment();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-12-04 13:15:38 -08:00
|
|
|
// Original name: oui and init_oui
|
|
|
|
void EdenGame::setChoiceYes() {
|
|
|
|
_lastDialogChoice = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 13:15:38 -08:00
|
|
|
// Original name: non and init_non
|
|
|
|
void EdenGame::setChoiceNo() {
|
|
|
|
_lastDialogChoice = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 13:15:38 -08:00
|
|
|
// Original name: verif_oui
|
|
|
|
bool EdenGame::isAnswerYes() {
|
|
|
|
return _lastDialogChoice;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 13:15:38 -08:00
|
|
|
// Original name: SpcChampi
|
|
|
|
void EdenGame::specialMushroom(perso_t *perso) {
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags |= PersonFlags::pf10;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_areaPtr->_flags |= AreaFlags::afFlag2;
|
|
|
|
_globals->_curAreaFlags |= AreaFlags::afFlag2;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 13:15:38 -08:00
|
|
|
// Original name: SpcNidv
|
2016-12-26 12:35:21 -08:00
|
|
|
void EdenGame::specialEmptyNest(perso_t *perso) {
|
2016-12-04 13:15:38 -08:00
|
|
|
if (!isAnswerYes())
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags |= PersonFlags::pf10;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomCharacterFlags |= PersonFlags::pf10;
|
|
|
|
_globals->_gameFlags |= GameFlags::gfFlag400;
|
|
|
|
if (_globals->_characterPtr == &kPersons[PER_EVE]) {
|
|
|
|
_globals->_areaPtr->_flags |= AreaFlags::afFlag4;
|
|
|
|
_globals->_curAreaFlags |= AreaFlags::afFlag4;
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags |= PersonFlags::pfInParty;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomCharacterFlags |= PersonFlags::pfInParty;
|
|
|
|
placeVava(_globals->_areaPtr);
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags &= ~PersonFlags::pf10;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomCharacterFlags &= ~PersonFlags::pf10;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
// Original name: SpcNido
|
2016-12-26 12:35:21 -08:00
|
|
|
void EdenGame::specialNestWithEggs(perso_t *perso) {
|
2016-12-28 03:43:13 -08:00
|
|
|
if (perso == &kPersons[PER_GUARDS])
|
2016-12-04 14:26:44 -08:00
|
|
|
giveObject();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
// Original name: SpcPomme
|
|
|
|
void EdenGame::specialApple(perso_t *perso) {
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags |= PersonFlags::pf10;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_areaPtr->_flags |= AreaFlags::afFlag8;
|
|
|
|
_globals->_curAreaFlags |= AreaFlags::afFlag8;
|
|
|
|
_globals->_gameFlags |= GameFlags::gfFlag200;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
// Original name: SpcOr
|
|
|
|
void EdenGame::specialGold(perso_t *perso) {
|
2016-12-04 13:15:38 -08:00
|
|
|
if (!isAnswerYes())
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-04 14:26:44 -08:00
|
|
|
perso->_items = _curSpecialObject->_itemMask;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomPersoItems = _curSpecialObject->_itemMask;
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags |= PersonFlags::pf10;
|
|
|
|
perso->_flags &= ~PersonFlags::pfInParty;
|
|
|
|
perso->_targetLoc = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_areaPtr->_flags |= AreaFlags::afGaveGold;
|
|
|
|
_globals->_curAreaFlags |= AreaFlags::afGaveGold;
|
|
|
|
if (_globals->_phaseNum == 226)
|
2016-12-19 22:32:40 -08:00
|
|
|
incPhase();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
// Original name: SpcPrisme
|
|
|
|
void EdenGame::specialPrism(perso_t *perso) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (perso == &kPersons[PER_DINA]) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_partyOutside & PersonMask::pmMonk)
|
|
|
|
_globals->_gameFlags |= GameFlags::gfPrismAndMonk;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
// Original name: SpcTalisman
|
|
|
|
void EdenGame::specialTalisman(perso_t *perso) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (perso == &kPersons[PER_DINA])
|
2016-12-31 05:11:33 -08:00
|
|
|
addToParty(PER_DINA);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
// Original name: SpcMasque
|
|
|
|
void EdenGame::specialMask(perso_t *perso) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (perso == &kPersons[PER_BAMBOO]) {
|
|
|
|
dialautoon();
|
2016-10-24 00:04:32 +02:00
|
|
|
parlemoiNormalFlag = true;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
// Original name: SpcSac
|
|
|
|
void EdenGame::specialBag(perso_t *perso) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_textToken1 != 3)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
|
|
|
if (perso == &kPersons[PER_KABUKA] || perso == &kPersons[PER_MAMMI_3])
|
2016-12-04 14:26:44 -08:00
|
|
|
loseObject(_curSpecialObject->_id);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
// Original name: SpcTrompet
|
|
|
|
void EdenGame::specialTrumpet(perso_t *perso) {
|
2016-12-04 13:15:38 -08:00
|
|
|
if (!isAnswerYes())
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var54 = 4;
|
2016-12-04 14:26:44 -08:00
|
|
|
winObject(Objects::obTrumpet);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_drawFlags |= DrawFlags::drDrawInventory;
|
2016-12-04 13:15:38 -08:00
|
|
|
_closeCharacterDialog = true;
|
2017-01-01 11:51:48 -08:00
|
|
|
tyranDies(_globals->_roomCharacterPtr);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
// Original name: SpcArmes
|
|
|
|
void EdenGame::specialWeapons(perso_t *perso) {
|
2016-12-04 13:15:38 -08:00
|
|
|
if (!isAnswerYes())
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-04 14:26:44 -08:00
|
|
|
perso->_powers = _curSpecialObject->_powerMask;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomCharacterPowers = _curSpecialObject->_powerMask;
|
2016-12-04 14:26:44 -08:00
|
|
|
giveObject();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
// Original name: SpcInstru
|
|
|
|
void EdenGame::specialInstrument(perso_t *perso) {
|
2016-12-04 13:15:38 -08:00
|
|
|
if (!isAnswerYes())
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
|
|
|
if (perso == &kPersons[PER_MONK]) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_partyInstruments &= ~1; //TODO: check me
|
2016-12-04 14:26:44 -08:00
|
|
|
if (_curSpecialObject->_id == Objects::obRing) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_partyInstruments |= 1;
|
|
|
|
_globals->_monkGotRing++; //TODO: |= 1 ?
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-12-28 03:43:13 -08:00
|
|
|
if (perso == &kPersons[PER_GUARDS]) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_partyInstruments &= ~2;
|
2016-12-04 14:26:44 -08:00
|
|
|
if (_curSpecialObject->_id == Objects::obDrum)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_partyInstruments |= 2;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-04 14:26:44 -08:00
|
|
|
perso->_powers = _curSpecialObject->_powerMask;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curCharacterPowers = _curSpecialObject->_powerMask;
|
2016-12-04 14:26:44 -08:00
|
|
|
giveObject();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
// Original name: SpcOeuf
|
|
|
|
void EdenGame::specialEgg(perso_t *perso) {
|
2016-12-04 13:15:38 -08:00
|
|
|
if (!isAnswerYes())
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[131]._cursorId &= ~0x8000;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterBackgroundBankIdx = 62;
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
|
|
|
}
|
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
// Original name: TyranMeurt
|
|
|
|
void EdenGame::tyranDies(perso_t *perso) {
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags |= PersonFlags::pf80;
|
|
|
|
perso->_roomNum = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
removeInfo(_globals->_areaNum + ValleyNews::vnTyrannIn);
|
|
|
|
_globals->_roomCharacterType = 0;
|
|
|
|
_globals->_roomCharacterFlags = 0;
|
|
|
|
_globals->_chronoFlag = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-11 22:52:10 -08:00
|
|
|
void EdenGame::specialObjects(perso_t *perso, char objid) {
|
2016-12-04 22:07:17 -08:00
|
|
|
#pragma pack(push, 1)
|
2016-12-04 14:26:44 -08:00
|
|
|
struct SpecialObject {
|
|
|
|
int8 _characterType;
|
|
|
|
int8 _objectId;
|
2016-12-04 13:15:38 -08:00
|
|
|
void (EdenGame::*dispFct)(perso_t *perso);
|
2016-09-14 23:39:27 +02:00
|
|
|
};
|
2016-12-04 22:07:17 -08:00
|
|
|
#pragma pack(pop)
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
static SpecialObject kSpecialObjectActions[] = {
|
2016-12-04 13:15:38 -08:00
|
|
|
// persoType, objectId, dispFct
|
|
|
|
{ PersonFlags::pfType8, Objects::obShroom, &EdenGame::specialMushroom },
|
2016-12-26 12:35:21 -08:00
|
|
|
{ PersonFlags::pftTriceraptor, Objects::obNest, &EdenGame::specialEmptyNest },
|
|
|
|
{ PersonFlags::pfType0, Objects::obFullNest, &EdenGame::specialNestWithEggs },
|
2016-12-04 14:26:44 -08:00
|
|
|
{ PersonFlags::pftMosasaurus, Objects::obApple, &EdenGame::specialApple },
|
|
|
|
{ PersonFlags::pftVelociraptor, Objects::obGold, &EdenGame::specialGold },
|
|
|
|
{ PersonFlags::pfType0, Objects::obPrism, &EdenGame::specialPrism },
|
|
|
|
{ PersonFlags::pfType0, Objects::obTalisman, &EdenGame::specialTalisman },
|
|
|
|
{ PersonFlags::pfType2, Objects::obMaskOfDeath, &EdenGame::specialMask },
|
|
|
|
{ PersonFlags::pfType2, Objects::obMaskOfBonding, &EdenGame::specialMask },
|
|
|
|
{ PersonFlags::pfType2, Objects::obMaskOfBirth, &EdenGame::specialMask },
|
|
|
|
{ PersonFlags::pfType0, Objects::obBag, &EdenGame::specialBag },
|
|
|
|
{ PersonFlags::pfType2, Objects::obBag, &EdenGame::specialBag },
|
|
|
|
{ PersonFlags::pftTyrann, Objects::obTrumpet, &EdenGame::specialTrumpet },
|
|
|
|
{ PersonFlags::pftVelociraptor, Objects::obEyeInTheStorm, &EdenGame::specialWeapons },
|
|
|
|
{ PersonFlags::pftVelociraptor, Objects::obSkyHammer, &EdenGame::specialWeapons },
|
|
|
|
{ PersonFlags::pftVelociraptor, Objects::obFireInTheClouds, &EdenGame::specialWeapons },
|
|
|
|
{ PersonFlags::pftVelociraptor, Objects::obWithinAndWithout, &EdenGame::specialWeapons },
|
|
|
|
{ PersonFlags::pftVelociraptor, Objects::obEyeInTheCyclone, &EdenGame::specialWeapons },
|
|
|
|
{ PersonFlags::pftVelociraptor, Objects::obRiverThatWinds, &EdenGame::specialWeapons },
|
|
|
|
{ PersonFlags::pfType0, Objects::obTrumpet, &EdenGame::specialInstrument },
|
|
|
|
{ PersonFlags::pfType0, Objects::obDrum, &EdenGame::specialInstrument },
|
|
|
|
{ PersonFlags::pfType0, Objects::obRing, &EdenGame::specialInstrument },
|
|
|
|
{ PersonFlags::pfType0, Objects::obEgg, &EdenGame::specialEgg },
|
2016-09-14 23:39:27 +02:00
|
|
|
{ -1, -1, nullptr }
|
|
|
|
};
|
2016-12-11 22:52:10 -08:00
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
char characterType = perso->_flags & PersonFlags::pfTypeMask;
|
|
|
|
_curSpecialObject = &_objects[objid - 1];
|
2016-12-11 22:52:10 -08:00
|
|
|
for (SpecialObject *spcObj = kSpecialObjectActions; spcObj->_characterType != -1; spcObj++) {
|
|
|
|
if (spcObj->_objectId == objid && spcObj->_characterType == characterType) {
|
|
|
|
(this->*spcObj->dispFct)(perso);
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::dialautoon() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_iconsIndex = 4;
|
|
|
|
_globals->_autoDialog = true;
|
2016-12-04 13:15:38 -08:00
|
|
|
putObject();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::dialautooff() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_iconsIndex = 0x10;
|
|
|
|
_globals->_autoDialog = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::follow() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_roomCharacterType == PersonFlags::pfType12) {
|
|
|
|
debug("follow: hiding person %ld", _globals->_roomCharacterPtr - kPersons);
|
|
|
|
_globals->_roomCharacterPtr->_flags |= PersonFlags::pf80;
|
|
|
|
_globals->_roomCharacterPtr->_roomNum = 0;
|
|
|
|
_globals->_gameFlags |= GameFlags::gfFlag8;
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[123]._objectId = 18;
|
|
|
|
_gameIcons[124]._objectId = 35;
|
|
|
|
_gameIcons[125]._cursorId &= ~0x8000;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterBackgroundBankIdx = 56;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else
|
2016-12-19 22:32:40 -08:00
|
|
|
AddCharacterToParty();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::dialonfollow() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_iconsIndex = 4;
|
|
|
|
_globals->_autoDialog = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
follow();
|
|
|
|
}
|
|
|
|
|
2017-01-14 00:30:37 +01:00
|
|
|
// Original name: abortdial
|
|
|
|
void EdenGame::abortDialogue() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varF6++;
|
|
|
|
if (_globals->_roomCharacterType != PersonFlags::pftTriceraptor || _globals->_characterPtr != &kPersons[PER_EVE])
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_areaPtr->_flags |= AreaFlags::afFlag4;
|
|
|
|
_globals->_curAreaFlags |= AreaFlags::afFlag4;
|
|
|
|
_globals->_roomCharacterPtr->_flags |= PersonFlags::pfInParty;
|
|
|
|
_globals->_roomCharacterFlags |= PersonFlags::pfInParty;
|
|
|
|
placeVava(_globals->_areaPtr);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-15 23:51:17 +01:00
|
|
|
void EdenGame::subHandleNarrator() {
|
|
|
|
_globals->_varF2 &= ~1; //TODO: check me
|
|
|
|
if (_globals->_narratorSequence > 50 && _globals->_narratorSequence <= 80)
|
|
|
|
_globals->_endGameFlag = 50;
|
|
|
|
if (_globals->_narratorSequence == 3)
|
|
|
|
setChrono(1200);
|
|
|
|
_globals->_narratorSequence = 0;
|
|
|
|
}
|
|
|
|
|
2017-01-14 00:30:37 +01:00
|
|
|
// Original name: narrateur
|
|
|
|
void EdenGame::handleNarrator() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_displayFlags & DisplayFlags::dfFlag1))
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!_globals->_narratorSequence) {
|
2017-01-15 23:51:17 +01:00
|
|
|
if (_globals->_var6A == _globals->_var69) {
|
|
|
|
subHandleNarrator();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-01-14 00:30:37 +01:00
|
|
|
narratorBuildCitadel();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varF5 |= 0x80;
|
|
|
|
_globals->_varF2 &= ~1; //TODO: check me
|
|
|
|
_globals->_characterPtr = &kPersons[PER_UNKN_156];
|
|
|
|
_globals->_var60 = 0;
|
|
|
|
_globals->_eventType = 0;
|
|
|
|
_globals->_var103 = 69;
|
2017-01-15 22:59:50 +01:00
|
|
|
if (dialogEvent(&kPersons[PER_UNKN_156])) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_narratorDialogPtr = _globals->_dialogPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varF2 |= 1;
|
2016-12-04 13:15:38 -08:00
|
|
|
waitEndSpeak();
|
2017-01-01 14:14:02 -08:00
|
|
|
if (_vm->shouldQuit())
|
2016-08-18 13:15:54 +02:00
|
|
|
return;
|
2016-12-28 03:43:13 -08:00
|
|
|
endCharacterSpeech();
|
2017-01-01 11:51:48 -08:00
|
|
|
while (dialoscansvmas(_globals->_narratorDialogPtr)) {
|
|
|
|
_globals->_narratorDialogPtr = _globals->_dialogPtr;
|
2016-12-04 13:15:38 -08:00
|
|
|
waitEndSpeak();
|
2017-01-01 14:14:02 -08:00
|
|
|
if (_vm->shouldQuit())
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-28 03:43:13 -08:00
|
|
|
endCharacterSpeech();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_narratorDialogPtr = _globals->_dialogPtr;
|
|
|
|
_globals->_mirrorEffect = 0;
|
|
|
|
_globals->_var103 = 0;
|
2016-12-28 03:43:13 -08:00
|
|
|
closeCharacterScreen();
|
2017-01-01 11:51:48 -08:00
|
|
|
placeVava(_globals->_areaPtr);
|
|
|
|
if (_globals->_narratorSequence == 8)
|
2016-09-14 23:39:27 +02:00
|
|
|
deplaval(134);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var103 = 0;
|
|
|
|
if (_globals->_narratorSequence == 10) {
|
2017-01-15 23:51:17 +01:00
|
|
|
addToParty(PER_ELOI);
|
2016-12-31 05:11:33 -08:00
|
|
|
addToParty(PER_EVE);
|
|
|
|
addToParty(PER_MONK);
|
|
|
|
addToParty(PER_GUARDS);
|
2017-01-15 23:51:17 +01:00
|
|
|
removeFromParty(PER_MUNGO);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eloiHaveNews = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
deplaval(139);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eventType = EventType::etEventD;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varF5 &= ~0x80;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2017-01-15 23:51:17 +01:00
|
|
|
subHandleNarrator();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-14 00:30:37 +01:00
|
|
|
// Original name: vrf_phrases_file
|
|
|
|
void EdenGame::checkPhraseFile() {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 num = 3;
|
2017-01-18 23:05:38 +01:00
|
|
|
if (_globals->_dialogPtr < (Dialog *)getElem(_gameDialogs, 48))
|
2016-09-14 23:39:27 +02:00
|
|
|
num = 1;
|
2017-01-18 23:05:38 +01:00
|
|
|
else if (_globals->_dialogPtr < (Dialog *)getElem(_gameDialogs, 128))
|
2016-09-14 23:39:27 +02:00
|
|
|
num = 2;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_textBankIndex = num;
|
|
|
|
if (_globals->_prefLanguage)
|
|
|
|
num += (_globals->_prefLanguage - 1) * 3;
|
2017-01-21 01:12:01 +01:00
|
|
|
if (num == _lastPhrasesFile)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-21 01:12:01 +01:00
|
|
|
_lastPhrasesFile = num;
|
2016-09-14 23:39:27 +02:00
|
|
|
num += 404;
|
2017-01-01 11:51:48 -08:00
|
|
|
loadRawFile(num, _gamePhrases);
|
|
|
|
verifh(_gamePhrases);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-14 00:30:37 +01:00
|
|
|
// Original name: gettxtad
|
|
|
|
byte *EdenGame::getPhrase(int16 id) {
|
|
|
|
checkPhraseFile();
|
2017-01-01 11:51:48 -08:00
|
|
|
return (byte *)getElem(_gamePhrases, id - 1);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: gotocarte
|
|
|
|
void EdenGame::actionGotoMap() {
|
2016-12-19 22:32:40 -08:00
|
|
|
Goto *go = &gotos[_curSpot2->_objectId];
|
2016-12-28 03:43:13 -08:00
|
|
|
endCharacterSpeech();
|
2016-12-15 22:47:29 -08:00
|
|
|
byte newArea = go->_areaNum;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_newRoomNum = (go->_areaNum << 8) | 1;
|
|
|
|
_globals->_newLocation = 1;
|
|
|
|
_globals->_prevLocation = _globals->_roomNum & 0xFF;
|
|
|
|
char curArea = _globals->_roomNum >> 8;
|
2016-12-15 22:47:29 -08:00
|
|
|
if (curArea == go->_areaNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
newArea = 0;
|
|
|
|
else {
|
2016-12-15 22:47:29 -08:00
|
|
|
for (; go->_curAreaNum != 0xFF; go++) {
|
|
|
|
if (go->_curAreaNum == curArea)
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-10-24 00:04:32 +02:00
|
|
|
}
|
|
|
|
|
2016-12-15 22:47:29 -08:00
|
|
|
if (go->_areaNum == 0xFF)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eventType = EventType::etGotoArea | newArea;
|
2016-12-04 13:15:38 -08:00
|
|
|
setChoiceYes();
|
2016-12-28 03:43:13 -08:00
|
|
|
showEvents1();
|
2016-12-04 13:15:38 -08:00
|
|
|
waitEndSpeak();
|
2017-01-01 14:14:02 -08:00
|
|
|
if (_vm->shouldQuit())
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-10-24 00:04:32 +02:00
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
closeCharacterScreen();
|
2016-12-04 13:15:38 -08:00
|
|
|
if (isAnswerYes())
|
2016-12-26 12:35:21 -08:00
|
|
|
gotoPlace(go);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::record() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-10-24 00:04:32 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_characterPtr >= &kPersons[PER_UNKN_18C])
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-10-24 00:04:32 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_eventType == EventType::etEventE || _globals->_eventType >= EventType::etGotoArea)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-10-24 00:04:32 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
for (tape_t *tape = _tapes; tape != _tapes + MAX_TAPES; tape++) {
|
|
|
|
if (tape->_textNum == _globals->_textNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-10-24 00:04:32 +02:00
|
|
|
}
|
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
tape_t *tape = _tapes;
|
2016-10-24 00:04:32 +02:00
|
|
|
for (int16 i = 0; i < MAX_TAPES - 1; i++) {
|
2016-10-07 23:06:10 +02:00
|
|
|
tape->_textNum = tape[+1]._textNum;
|
|
|
|
tape->_perso = tape[+1]._perso;
|
|
|
|
tape->_party = tape[+1]._party;
|
|
|
|
tape->_roomNum = tape[+1]._roomNum;
|
2016-12-11 13:44:58 -08:00
|
|
|
tape->_backgroundBankNum = tape[+1]._backgroundBankNum;
|
2016-10-07 23:06:10 +02:00
|
|
|
tape->_dialog = tape[+1]._dialog;
|
2016-09-14 23:39:27 +02:00
|
|
|
tape++;
|
|
|
|
}
|
2016-10-24 00:04:32 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
perso_t *perso = _globals->_characterPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (perso == &kPersons[PER_EVE])
|
2017-01-01 11:51:48 -08:00
|
|
|
perso = _globals->_phaseNum >= 352 ? &kPersons[PER_UNKN_372]
|
2016-09-14 23:39:27 +02:00
|
|
|
: &kPersons[PER_UNKN_402];
|
2017-01-01 11:51:48 -08:00
|
|
|
tape->_textNum = _globals->_textNum;
|
2016-10-07 23:06:10 +02:00
|
|
|
tape->_perso = perso;
|
2017-01-01 11:51:48 -08:00
|
|
|
tape->_party = _globals->_party;
|
|
|
|
tape->_roomNum = _globals->_roomNum;
|
|
|
|
tape->_backgroundBankNum = _globals->_roomBackgroundBankNum;
|
|
|
|
tape->_dialog = _globals->_dialogPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-18 23:05:38 +01:00
|
|
|
bool EdenGame::dial_scan(Dialog *dial) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_numGiveObjs) {
|
|
|
|
if (!(_globals->_displayFlags & DisplayFlags::dfFlag2))
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_numGiveObjs = 0;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_dialogPtr = dial;
|
2016-09-14 23:39:27 +02:00
|
|
|
vavapers();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_sentenceBufferPtr = _sentenceBuffer;
|
2016-11-13 15:46:36 -08:00
|
|
|
byte hidx, lidx;
|
2017-01-15 23:51:17 +01:00
|
|
|
uint16 mask = 0;
|
|
|
|
bool skipFl = false;
|
2017-01-01 11:51:48 -08:00
|
|
|
for (;; _globals->_dialogPtr++) {
|
|
|
|
for (;; _globals->_dialogPtr++) {
|
|
|
|
if (_globals->_dialogPtr->_flags == -1 && _globals->_dialogPtr->_condNumLow == -1)
|
2016-11-13 15:46:36 -08:00
|
|
|
return false;
|
2017-01-01 11:51:48 -08:00
|
|
|
byte flags = _globals->_dialogPtr->_flags;
|
|
|
|
_globals->_dialogFlags = flags;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!(flags & DialogFlags::dfSpoken) || (flags & DialogFlags::dfRepeatable)) {
|
2017-01-01 11:51:48 -08:00
|
|
|
hidx = (_globals->_dialogPtr->_textCondHiMask >> 6) & 3;
|
|
|
|
lidx = _globals->_dialogPtr->_condNumLow;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (flags & 0x10)
|
|
|
|
hidx |= 4;
|
2016-12-25 14:20:06 -08:00
|
|
|
if (testCondition(((hidx << 8) | lidx) & 0x7FF))
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
} else {
|
2017-01-21 01:12:01 +01:00
|
|
|
if (flags & _dialogSkipFlags)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2017-01-01 11:51:48 -08:00
|
|
|
hidx = (_globals->_dialogPtr->_textCondHiMask >> 6) & 3;
|
|
|
|
lidx = _globals->_dialogPtr->_condNumLow;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (flags & 0x10)
|
|
|
|
hidx |= 4;
|
2016-12-25 14:20:06 -08:00
|
|
|
if (testCondition(((hidx << 8) | lidx) & 0x7FF))
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
char bidx = (_globals->_dialogPtr->_textCondHiMask >> 2) & 0xF;
|
2017-01-15 23:51:17 +01:00
|
|
|
if (!bidx) {
|
|
|
|
skipFl = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
mask = (_globals->_party | _globals->_partyOutside) & (1 << (bidx - 1));
|
2016-09-14 23:39:27 +02:00
|
|
|
if (mask)
|
|
|
|
break;
|
|
|
|
}
|
2017-01-15 23:51:17 +01:00
|
|
|
|
|
|
|
if (!skipFl) {
|
|
|
|
perso_t *perso;
|
|
|
|
for (perso = kPersons; !(perso->_partyMask == mask && perso->_roomNum == _globals->_roomNum); perso++)
|
|
|
|
; //Find matching
|
|
|
|
|
|
|
|
_globals->_characterPtr = perso;
|
|
|
|
initCharacterPointers(perso);
|
|
|
|
no_perso();
|
|
|
|
}
|
2016-10-24 00:04:32 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
hidx = _globals->_dialogPtr->_textCondHiMask;
|
|
|
|
lidx = _globals->_dialogPtr->_textNumLow;
|
|
|
|
_globals->_textNum = ((hidx << 8) | lidx) & 0x3FF;
|
|
|
|
if (_globals->_sentenceBufferPtr != _sentenceBuffer) {
|
2016-10-24 00:04:32 +02:00
|
|
|
for (int16 i = 0; i < 32; i++)
|
2016-09-14 23:39:27 +02:00
|
|
|
SysBeep(1);
|
|
|
|
} else
|
|
|
|
my_bulle();
|
|
|
|
if (!dword_30B04) {
|
|
|
|
static void (EdenGame::*talk_subject[])() = {
|
2016-12-04 13:15:38 -08:00
|
|
|
&EdenGame::setChoiceYes,
|
|
|
|
&EdenGame::setChoiceNo,
|
2016-12-17 10:13:15 -08:00
|
|
|
&EdenGame::handleEloiDeparture,
|
2016-09-14 23:39:27 +02:00
|
|
|
&EdenGame::dialautoon,
|
|
|
|
&EdenGame::dialautooff,
|
2017-01-14 00:30:37 +01:00
|
|
|
&EdenGame::characterStayHere,
|
2016-09-14 23:39:27 +02:00
|
|
|
&EdenGame::follow,
|
|
|
|
&EdenGame::citadelle,
|
|
|
|
&EdenGame::dialonfollow,
|
2017-01-14 00:30:37 +01:00
|
|
|
&EdenGame::abortDialogue,
|
2016-12-19 22:32:40 -08:00
|
|
|
&EdenGame::incPhase,
|
2016-09-14 23:39:27 +02:00
|
|
|
&EdenGame::bigphase,
|
2016-12-04 14:26:44 -08:00
|
|
|
&EdenGame::giveObject,
|
2017-01-14 00:30:37 +01:00
|
|
|
&EdenGame::selectZone,
|
2016-12-11 22:52:10 -08:00
|
|
|
&EdenGame::lostObject
|
2016-09-14 23:39:27 +02:00
|
|
|
};
|
2017-01-01 11:51:48 -08:00
|
|
|
char pnum = _globals->_dialogPtr->_flags & 0xF;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (pnum)
|
|
|
|
(this->*talk_subject[pnum - 1])();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var60 = 1;
|
|
|
|
_globals->_dialogPtr->_flags |= DialogFlags::dfSpoken;
|
|
|
|
_globals->_dialogPtr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_dialogType != DialogType::dtInspect) {
|
2016-09-14 23:39:27 +02:00
|
|
|
record();
|
2016-12-25 02:17:07 -08:00
|
|
|
getDataSync();
|
2016-12-04 14:26:44 -08:00
|
|
|
showCharacter();
|
2016-09-14 23:39:27 +02:00
|
|
|
persovox();
|
|
|
|
}
|
2016-11-13 15:46:36 -08:00
|
|
|
return true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-18 23:05:38 +01:00
|
|
|
bool EdenGame::dialoscansvmas(Dialog *dial) {
|
2017-01-21 01:12:01 +01:00
|
|
|
byte oldFlag = _dialogSkipFlags;
|
|
|
|
_dialogSkipFlags = DialogFlags::df20;
|
2016-12-04 13:15:38 -08:00
|
|
|
bool res = dial_scan(dial);
|
2017-01-21 01:12:01 +01:00
|
|
|
_dialogSkipFlags = oldFlag;
|
2016-09-14 23:39:27 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2017-01-15 22:59:50 +01:00
|
|
|
// Original name: dialo_even
|
|
|
|
bool EdenGame::dialogEvent(perso_t *perso) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterPtr = perso;
|
2016-10-24 00:04:32 +02:00
|
|
|
int num = (perso->_id << 3) | DialogType::dtEvent;
|
2017-01-18 23:05:38 +01:00
|
|
|
Dialog *dial = (Dialog *)getElem(_gameDialogs, num);
|
2017-01-15 22:59:50 +01:00
|
|
|
bool retVal = dialoscansvmas(dial);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_lastDialogPtr = nullptr;
|
2016-10-24 00:04:32 +02:00
|
|
|
parlemoiNormalFlag = false;
|
2017-01-15 22:59:50 +01:00
|
|
|
return retVal;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-29 06:28:11 -08:00
|
|
|
// Original name: stay_here
|
2017-01-14 00:30:37 +01:00
|
|
|
void EdenGame::characterStayHere() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_characterPtr == &kPersons[PER_DINA] && _globals->_roomNum == 260)
|
|
|
|
_globals->_gameFlags |= GameFlags::gfFlag1000;
|
2016-12-19 22:32:40 -08:00
|
|
|
removeCharacterFromParty();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-14 00:30:37 +01:00
|
|
|
// Original name: mort
|
|
|
|
void EdenGame::endDeath(int16 vid) {
|
|
|
|
hideBars();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(vid);
|
2016-12-17 10:13:15 -08:00
|
|
|
fadeToBlack(2);
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_FillScreenView(0);
|
2016-12-18 14:13:36 -08:00
|
|
|
CLBlitter_FillView(_mainView, 0);
|
2016-09-28 07:29:12 +02:00
|
|
|
showBars();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_narratorSequence = 51;
|
|
|
|
_globals->_newMusicType = MusicType::mtNormal;
|
2016-09-14 23:39:27 +02:00
|
|
|
musique();
|
|
|
|
musicspy();
|
|
|
|
}
|
|
|
|
|
2017-01-15 22:59:50 +01:00
|
|
|
// Original name: evenchrono
|
|
|
|
void EdenGame::chronoEvent() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_displayFlags & DisplayFlags::dfFlag1))
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-10-24 00:04:32 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
uint16 oldGameTime = _globals->_gameTime;
|
2016-12-18 14:13:36 -08:00
|
|
|
_currentTime = _vm->_timerTicks / 100;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_gameTime = _currentTime;
|
|
|
|
if (_globals->_gameTime <= oldGameTime)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-15 22:59:50 +01:00
|
|
|
addTime(5);
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_chronoFlag & 1))
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_chrono -= 200;
|
|
|
|
if (_globals->_chrono == 0)
|
|
|
|
_globals->_chronoFlag |= 2;
|
|
|
|
if (!(_globals->_chronoFlag & 2))
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_chronoFlag = 0;
|
|
|
|
_globals->_chrono = 0;
|
|
|
|
if (_globals->_roomCharacterType == PersonFlags::pftTyrann) {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 vid = 272;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curRoomFlags & 0xC0) {
|
2016-09-14 23:39:27 +02:00
|
|
|
vid += 2;
|
2017-01-01 11:51:48 -08:00
|
|
|
if ((_globals->_curRoomFlags & 0xC0) != 0x80) {
|
2016-09-14 23:39:27 +02:00
|
|
|
vid += 2;
|
2017-01-14 00:30:37 +01:00
|
|
|
endDeath(vid);
|
2016-08-18 13:15:54 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_areaNum == Areas::arUluru || _globals->_areaNum == Areas::arTamara)
|
2017-01-14 00:30:37 +01:00
|
|
|
endDeath(vid);
|
2016-12-17 10:13:15 -08:00
|
|
|
else
|
2017-01-14 00:30:37 +01:00
|
|
|
endDeath(vid + 1);
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_roomNum == 2817) {
|
2017-01-15 23:51:17 +01:00
|
|
|
addToParty(PER_ELOI);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_gameFlags |= GameFlags::gfFlag40;
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
|
|
|
} else
|
2016-12-19 22:32:40 -08:00
|
|
|
handleEloiReturn();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eventType = EventType::etEvent10;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-11 13:44:58 -08:00
|
|
|
// Original name: chronoon
|
|
|
|
void EdenGame::setChrono(int16 t) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_chrono = t;
|
|
|
|
_globals->_chronoFlag = 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-15 22:59:50 +01:00
|
|
|
// Original name: prechargephrases
|
|
|
|
void EdenGame::preloadDialogs(int16 vid) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso = &kPersons[PER_MORKUS];
|
|
|
|
if (vid == 170)
|
|
|
|
perso = &kPersons[PER_UNKN_156];
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterPtr = perso;
|
|
|
|
_globals->_dialogType = DialogType::dtInspect;
|
|
|
|
int num = (perso->_id << 3) | _globals->_dialogType;
|
2017-01-18 23:05:38 +01:00
|
|
|
Dialog *dial = (Dialog *)getElem(_gameDialogs, num);
|
2016-09-14 23:39:27 +02:00
|
|
|
dialoscansvmas(dial);
|
|
|
|
}
|
|
|
|
|
2016-12-31 05:11:33 -08:00
|
|
|
// Original name: effet1
|
|
|
|
void EdenGame::displayEffect1() {
|
2016-12-27 10:11:37 -08:00
|
|
|
blackRect32();
|
2016-09-30 07:48:27 +02:00
|
|
|
if (!_doubledScreen) {
|
2016-12-27 10:11:37 -08:00
|
|
|
setSrcRect(0, 0, 16 - 1, 4 - 1);
|
2016-12-18 14:13:36 -08:00
|
|
|
int y = _mainView->_normal._dstTop;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 16; i <= 96; i += 4) {
|
2016-12-18 14:13:36 -08:00
|
|
|
for (int x = _mainView->_normal._dstLeft; x < _mainView->_normal._dstLeft + 320; x += 16) {
|
2016-12-27 10:11:37 -08:00
|
|
|
setDestRect(x, y + i, x + 16 - 1, y + i + 4 - 1);
|
2017-01-01 14:14:02 -08:00
|
|
|
CLBlitter_CopyViewRect(_view2, _vm->_screenView, &rect_src, &rect_dst);
|
2016-12-27 10:11:37 -08:00
|
|
|
setDestRect(x, y + 192 - i, x + 16 - 1, y + 192 - i + 4 - 1);
|
2017-01-01 14:14:02 -08:00
|
|
|
CLBlitter_CopyViewRect(_view2, _vm->_screenView, &rect_src, &rect_dst);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_UpdateScreen();
|
|
|
|
wait(1);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-12-27 10:11:37 -08:00
|
|
|
setSrcRect(0, 0, 16 * 2 - 1, 4 * 2 - 1);
|
2016-12-18 14:13:36 -08:00
|
|
|
int y = _mainView->_zoom._dstTop;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 16 * 2; i <= 96 * 2; i += 4 * 2) {
|
2016-12-18 14:13:36 -08:00
|
|
|
for (int x = _mainView->_zoom._dstLeft; x < _mainView->_zoom._dstLeft + 320 * 2; x += 16 * 2) {
|
2016-12-27 10:11:37 -08:00
|
|
|
setDestRect(x, y + i, x + 16 * 2 - 1, y + i + 4 * 2 - 1);
|
2017-01-01 14:14:02 -08:00
|
|
|
CLBlitter_CopyViewRect(_view2, _vm->_screenView, &rect_src, &rect_dst);
|
2016-12-27 10:11:37 -08:00
|
|
|
setDestRect(x, y + 192 * 2 - i, x + 16 * 2 - 1, y + 192 * 2 - i + 4 * 2 - 1);
|
2017-01-01 14:14:02 -08:00
|
|
|
CLBlitter_CopyViewRect(_view2, _vm->_screenView, &rect_src, &rect_dst);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
wait(1);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-12-25 13:45:47 -08:00
|
|
|
CLPalette_Send2Screen(_globalPalette, 0, 256);
|
2016-12-18 14:13:36 -08:00
|
|
|
_mainView->_normal._height = 2;
|
|
|
|
_mainView->_zoom._height = 4;
|
|
|
|
int16 ny = _mainView->_normal._dstTop;
|
|
|
|
int16 dy = _mainView->_zoom._dstTop;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 0; i < 100; i += 2) {
|
2016-12-18 14:13:36 -08:00
|
|
|
_mainView->_normal._srcTop = 99 - i;
|
|
|
|
_mainView->_zoom._srcTop = 99 - i;
|
|
|
|
_mainView->_normal._dstTop = 99 - i + ny;
|
|
|
|
_mainView->_zoom._dstTop = (99 - i) * 2 + dy;
|
|
|
|
CLBlitter_CopyView2Screen(_mainView);
|
|
|
|
_mainView->_normal._srcTop = 100 + i;
|
|
|
|
_mainView->_zoom._srcTop = 100 + i;
|
|
|
|
_mainView->_normal._dstTop = 100 + i + ny;
|
|
|
|
_mainView->_zoom._dstTop = (100 + i) * 2 + dy;
|
|
|
|
CLBlitter_CopyView2Screen(_mainView);
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_UpdateScreen();
|
|
|
|
wait(1);
|
|
|
|
}
|
2016-12-18 14:13:36 -08:00
|
|
|
_mainView->_normal._height = 200;
|
|
|
|
_mainView->_zoom._height = 400;
|
|
|
|
_mainView->_normal._srcTop = 0;
|
|
|
|
_mainView->_zoom._srcTop = 0;
|
|
|
|
_mainView->_normal._dstTop = ny;
|
|
|
|
_mainView->_zoom._dstTop = dy;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varF1 = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-31 05:11:33 -08:00
|
|
|
// Original name: effet2
|
|
|
|
void EdenGame::displayEffect2() {
|
2016-10-23 23:28:48 +02:00
|
|
|
static int16 pattern1[] = {0, 1, 2, 3, 7, 11, 15, 14, 13, 12, 8, 4, 5, 6, 10, 9};
|
|
|
|
static int16 pattern2[] = {0, 15, 1, 14, 2, 13, 3, 12, 7, 8, 11, 4, 5, 10, 6, 9};
|
|
|
|
static int16 pattern3[] = {0, 2, 5, 7, 8, 10, 13, 15, 1, 3, 4, 6, 9, 11, 12, 14};
|
|
|
|
static int16 pattern4[] = {0, 3, 15, 12, 1, 7, 14, 8, 2, 11, 13, 4, 5, 6, 10, 9};
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
static int eff2pat = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_var103 == 69) {
|
2016-12-31 05:11:33 -08:00
|
|
|
displayEffect4();
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
switch (++eff2pat) {
|
2016-10-23 23:28:48 +02:00
|
|
|
case 1:
|
|
|
|
colimacon(pattern1);
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-10-23 23:28:48 +02:00
|
|
|
case 2:
|
|
|
|
colimacon(pattern2);
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-10-23 23:28:48 +02:00
|
|
|
case 3:
|
|
|
|
colimacon(pattern3);
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-10-23 23:28:48 +02:00
|
|
|
case 4:
|
|
|
|
colimacon(pattern4);
|
2016-09-14 23:39:27 +02:00
|
|
|
eff2pat = 0;
|
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-31 05:11:33 -08:00
|
|
|
// Original name: effet3
|
|
|
|
void EdenGame::displayEffect3() {
|
2016-09-14 23:39:27 +02:00
|
|
|
CLPalette_GetLastPalette(oldPalette);
|
2016-10-23 23:28:48 +02:00
|
|
|
for (uint16 i = 0; i < 6; i++) {
|
|
|
|
for (uint16 c = 0; c < 256; c++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
newColor.r = oldPalette[c].r >> i;
|
|
|
|
newColor.g = oldPalette[c].g >> i;
|
|
|
|
newColor.b = oldPalette[c].b >> i;
|
|
|
|
CLPalette_SetRGBColor(newPalette, c, &newColor);
|
|
|
|
}
|
|
|
|
CLPalette_Send2Screen(newPalette, 0, 256);
|
|
|
|
wait(1);
|
|
|
|
}
|
2016-12-18 14:13:36 -08:00
|
|
|
CLBlitter_CopyView2Screen(_mainView);
|
2016-10-23 23:28:48 +02:00
|
|
|
for (uint16 i = 0; i < 6; i++) {
|
|
|
|
for (uint16 c = 0; c < 256; c++) {
|
2016-12-25 13:45:47 -08:00
|
|
|
newColor.r = _globalPalette[c].r >> (5 - i);
|
|
|
|
newColor.g = _globalPalette[c].g >> (5 - i);
|
|
|
|
newColor.b = _globalPalette[c].b >> (5 - i);
|
2016-09-14 23:39:27 +02:00
|
|
|
CLPalette_SetRGBColor(newPalette, c, &newColor);
|
|
|
|
}
|
|
|
|
CLPalette_Send2Screen(newPalette, 0, 256);
|
|
|
|
wait(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-31 05:11:33 -08:00
|
|
|
// Original name: effet4
|
|
|
|
void EdenGame::displayEffect4() {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *scr, *pix, *r24, *r25, *r30, c;
|
|
|
|
int16 x, y;
|
|
|
|
int16 r17, r23, r16, r18, r19, r22, r27, r31;
|
2016-12-25 13:45:47 -08:00
|
|
|
CLPalette_Send2Screen(_globalPalette, 0, 256);
|
2016-10-23 23:28:48 +02:00
|
|
|
|
|
|
|
// Unused
|
2016-11-30 22:51:15 -08:00
|
|
|
// int16 w = _vm->ScreenView->_width;
|
|
|
|
// int16 h = _vm->ScreenView->_height;
|
2017-01-01 14:14:02 -08:00
|
|
|
int16 ww = _vm->_screenView->_pitch;
|
2016-09-30 07:48:27 +02:00
|
|
|
if (!_doubledScreen) {
|
2016-12-18 14:13:36 -08:00
|
|
|
x = _mainView->_normal._dstLeft;
|
|
|
|
y = _mainView->_normal._dstTop;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 32; i > 0; i -= 2) {
|
2017-01-01 14:14:02 -08:00
|
|
|
scr = _vm->_screenView->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += (y + 16) * ww + x;
|
2016-12-18 14:13:36 -08:00
|
|
|
pix = _mainView->_bufferPtr + 16 * 640;
|
2016-09-14 23:39:27 +02:00
|
|
|
r17 = 320 / i;
|
|
|
|
r23 = 320 - 320 / i * i; //TODO: 320 % i ?
|
|
|
|
r16 = 160 / i;
|
|
|
|
r18 = 160 - 160 / i * i; //TODO: 160 % i ?
|
|
|
|
for (r19 = r16; r19 > 0; r19--) {
|
|
|
|
r24 = scr;
|
|
|
|
r25 = pix;
|
|
|
|
for (r22 = r17; r22 > 0; r22--) {
|
|
|
|
c = *r25;
|
|
|
|
r25 += i;
|
|
|
|
r30 = r24;
|
|
|
|
for (r27 = i; r27 > 0; r27--) {
|
|
|
|
for (r31 = i; r31 > 0; r31--)
|
|
|
|
*r30++ = c;
|
|
|
|
r30 += ww - i;
|
|
|
|
}
|
|
|
|
r24 += i;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (r23) {
|
|
|
|
c = *r25;
|
|
|
|
r30 = r24;
|
|
|
|
for (r27 = i; r27 > 0; r27--) {
|
|
|
|
for (r31 = r23; r31 > 0; r31--)
|
|
|
|
*r30++ = c;
|
|
|
|
r30 += ww - r23;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += i * ww;
|
|
|
|
pix += i * 640;
|
|
|
|
}
|
|
|
|
if (r18) {
|
|
|
|
r24 = scr;
|
|
|
|
r25 = pix;
|
|
|
|
for (r22 = r17; r22 > 0; r22--) {
|
|
|
|
c = *r25;
|
|
|
|
r25 += i;
|
|
|
|
r30 = r24;
|
|
|
|
for (r27 = r18; r27 > 0; r27--) {
|
|
|
|
for (r31 = i; r31 > 0; r31--)
|
|
|
|
*r30++ = c;
|
|
|
|
r30 += ww - i;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
r24 += i;
|
|
|
|
}
|
|
|
|
if (r23) {
|
|
|
|
c = *r25;
|
|
|
|
r30 = r24;
|
|
|
|
for (r27 = r18; r27 > 0; r27--) {
|
|
|
|
for (r31 = r23; r31 > 0; r31--)
|
|
|
|
*r30++ = c;
|
|
|
|
r30 += ww - r23;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_UpdateScreen();
|
|
|
|
wait(3);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-12-18 14:13:36 -08:00
|
|
|
x = _mainView->_zoom._dstLeft;
|
|
|
|
y = _mainView->_zoom._dstTop;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 32; i > 0; i -= 2) {
|
2017-01-01 14:14:02 -08:00
|
|
|
scr = _vm->_screenView->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += (y + 16 * 2) * ww + x;
|
2016-12-18 14:13:36 -08:00
|
|
|
pix = _mainView->_bufferPtr + 16 * 640;
|
2016-09-14 23:39:27 +02:00
|
|
|
r17 = 320 / i;
|
|
|
|
r23 = 320 % i;
|
|
|
|
r16 = 160 / i;
|
|
|
|
r18 = 160 % i;
|
|
|
|
for (r19 = r16; r19 > 0; r19--) {
|
|
|
|
r24 = scr;
|
|
|
|
r25 = pix;
|
|
|
|
for (r22 = r17; r22 > 0; r22--) {
|
|
|
|
c = *r25;
|
|
|
|
r25 += i;
|
|
|
|
r30 = r24;
|
|
|
|
for (r27 = i * 2; r27 > 0; r27--) {
|
|
|
|
for (r31 = i * 2; r31 > 0; r31--)
|
|
|
|
*r30++ = c;
|
|
|
|
r30 += ww - i * 2;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
r24 += i * 2;
|
|
|
|
}
|
|
|
|
if (r23) {
|
|
|
|
c = *r25;
|
|
|
|
r30 = r24;
|
|
|
|
for (r27 = i * 2; r27 > 0; r27--) {
|
|
|
|
for (r31 = r23 * 2; r31 > 0; r31--)
|
|
|
|
*r30++ = c;
|
|
|
|
r30 += ww - r23 * 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
scr += i * ww * 2;
|
|
|
|
pix += i * 640;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (r18) {
|
|
|
|
r24 = scr;
|
|
|
|
r25 = pix;
|
|
|
|
for (r22 = r17; r22 > 0; r22--) {
|
|
|
|
c = *r25;
|
|
|
|
r25 += i;
|
|
|
|
r30 = r24;
|
|
|
|
for (r27 = r18 * 2; r27 > 0; r27--) {
|
|
|
|
for (r31 = i * 2; r31 > 0; r31--)
|
|
|
|
*r30++ = c;
|
|
|
|
r30 += ww - i * 2;
|
|
|
|
}
|
|
|
|
r24 += i * 2;
|
|
|
|
}
|
|
|
|
if (r23) {
|
|
|
|
c = *r25;
|
|
|
|
r30 = r24;
|
|
|
|
for (r27 = i * 2; r27 > 0; r27--) {
|
|
|
|
for (r31 = r23 * 2; r31 > 0; r31--)
|
|
|
|
*r30++ = c;
|
|
|
|
r30 += ww - r23 * 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wait(3);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-12-18 14:13:36 -08:00
|
|
|
CLBlitter_CopyView2Screen(_mainView);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-31 05:11:33 -08:00
|
|
|
void EdenGame::clearScreen() {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *scr;
|
2016-10-23 23:28:48 +02:00
|
|
|
int16 x, y;
|
|
|
|
|
|
|
|
// Unused
|
2016-11-30 22:51:15 -08:00
|
|
|
// int16 w = _vm->ScreenView->_width;
|
|
|
|
// int16 h = _vm->ScreenView->_height;
|
2017-01-01 14:14:02 -08:00
|
|
|
int16 ww = _vm->_screenView->_pitch;
|
2016-09-30 07:48:27 +02:00
|
|
|
if (!_doubledScreen) {
|
2016-12-18 14:13:36 -08:00
|
|
|
x = _mainView->_normal._dstLeft;
|
|
|
|
y = _mainView->_normal._dstTop;
|
2017-01-01 14:14:02 -08:00
|
|
|
scr = _vm->_screenView->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += (y + 16) * ww + x;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 yy = 0; yy < 160; yy++) {
|
|
|
|
for (int16 xx = 0; xx < 320; xx++)
|
2016-09-14 23:39:27 +02:00
|
|
|
*scr++ = 0;
|
|
|
|
scr += ww - 320;
|
|
|
|
}
|
|
|
|
} else {
|
2016-12-18 14:13:36 -08:00
|
|
|
x = _mainView->_zoom._dstLeft;
|
|
|
|
y = _mainView->_zoom._dstTop;
|
2017-01-01 14:14:02 -08:00
|
|
|
scr = _vm->_screenView->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += (y + 32) * ww + x;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 yy = 0; yy < 160; yy++) {
|
|
|
|
for (int16 xx = 0; xx < 320; xx++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
scr[0] = 0;
|
|
|
|
scr[1] = 0;
|
|
|
|
scr[ww] = 0;
|
|
|
|
scr[ww + 1] = 0;
|
|
|
|
scr += 2;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += (ww - 320) * 2;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_UpdateScreen();
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::colimacon(int16 pattern[16]) {
|
|
|
|
byte *scr, *pix;
|
2016-09-26 07:57:27 +02:00
|
|
|
int16 x, y;
|
2016-10-23 23:28:48 +02:00
|
|
|
int16 p, r27, r25;
|
|
|
|
|
|
|
|
// Unused
|
2016-11-30 22:51:15 -08:00
|
|
|
// int16 w = _vm->ScreenView->_width;
|
|
|
|
// int16 h = _vm->ScreenView->_height;
|
2017-01-01 14:14:02 -08:00
|
|
|
int16 ww = _vm->_screenView->_pitch;
|
2016-09-30 07:48:27 +02:00
|
|
|
if (!_doubledScreen) {
|
2016-12-18 14:13:36 -08:00
|
|
|
x = _mainView->_normal._dstLeft;
|
|
|
|
y = _mainView->_normal._dstTop;
|
2017-01-01 14:14:02 -08:00
|
|
|
scr = _vm->_screenView->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += (y + 16) * ww + x;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 0; i < 16; i++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
p = pattern[i];
|
|
|
|
r27 = p % 4 + p / 4 * ww;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 j = 0; j < 320 * 160 / 16; j++)
|
2016-09-14 23:39:27 +02:00
|
|
|
scr[j / (320 / 4) * ww * 4 + j % (320 / 4) * 4 + r27] = 0;
|
|
|
|
CLBlitter_UpdateScreen();
|
|
|
|
wait(1);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-12-18 14:13:36 -08:00
|
|
|
x = _mainView->_zoom._dstLeft;
|
|
|
|
y = _mainView->_zoom._dstTop;
|
2017-01-01 14:14:02 -08:00
|
|
|
scr = _vm->_screenView->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += (y + 16 * 2) * ww + x;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 0; i < 16; i++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
p = pattern[i];
|
|
|
|
r27 = p % 4 * 2 + p / 4 * ww * 2;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 j = 0; j < 320 * 160 / 16; j++) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *sc = &scr[j / (320 / 4) * ww * 4 * 2 + j % (320 / 4) * 4 * 2 + r27];
|
2016-09-14 23:39:27 +02:00
|
|
|
sc[0] = 0;
|
|
|
|
sc[1] = 0;
|
|
|
|
sc[ww] = 0;
|
|
|
|
sc[ww + 1] = 0;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
wait(1);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-12-25 13:45:47 -08:00
|
|
|
CLPalette_Send2Screen(_globalPalette, 0, 256);
|
2016-09-30 07:48:27 +02:00
|
|
|
if (!_doubledScreen) {
|
2016-12-18 14:13:36 -08:00
|
|
|
pix = _mainView->_bufferPtr;
|
|
|
|
x = _mainView->_normal._dstLeft;
|
|
|
|
y = _mainView->_normal._dstTop;
|
2016-09-14 23:39:27 +02:00
|
|
|
pix += 640 * 16;
|
2017-01-01 14:14:02 -08:00
|
|
|
scr = _vm->_screenView->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += (y + 16) * ww + x;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 0; i < 16; i++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
p = pattern[i];
|
|
|
|
r25 = p % 4 + p / 4 * 640;
|
|
|
|
r27 = p % 4 + p / 4 * ww;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 j = 0; j < 320 * 160 / 16; j++)
|
2016-09-14 23:39:27 +02:00
|
|
|
scr[j / (320 / 4) * ww * 4 + j % (320 / 4) * 4 + r27] =
|
|
|
|
pix[j / (320 / 4) * 640 * 4 + j % (320 / 4) * 4 + r25];
|
|
|
|
CLBlitter_UpdateScreen();
|
|
|
|
wait(1);
|
|
|
|
}
|
|
|
|
} else {
|
2016-12-18 14:13:36 -08:00
|
|
|
pix = _mainView->_bufferPtr;
|
|
|
|
x = _mainView->_zoom._dstLeft;
|
|
|
|
y = _mainView->_zoom._dstTop;
|
2016-09-14 23:39:27 +02:00
|
|
|
pix += 640 * 16;
|
2017-01-01 14:14:02 -08:00
|
|
|
scr = _vm->_screenView->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += (y + 16 * 2) * ww + x;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 0; i < 16; i++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
p = pattern[i];
|
|
|
|
r25 = p % 4 + p / 4 * 640;
|
|
|
|
r27 = p % 4 * 2 + p / 4 * ww * 2;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 j = 0; j < 320 * 160 / 16; j++) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte c = pix[j / (320 / 4) * 640 * 4 + j % (320 / 4) * 4 + r25];
|
|
|
|
byte *sc = &scr[j / (320 / 4) * ww * 4 * 2 + j % (320 / 4) * 4 * 2 + r27];
|
2016-09-14 23:39:27 +02:00
|
|
|
sc[0] = c;
|
|
|
|
sc[1] = c;
|
|
|
|
sc[ww] = c;
|
|
|
|
sc[ww + 1] = c;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
wait(1);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-17 10:13:15 -08:00
|
|
|
void EdenGame::fadeToBlack(int delay) {
|
2016-09-14 23:39:27 +02:00
|
|
|
CLPalette_GetLastPalette(oldPalette);
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 0; i < 6; i++) {
|
|
|
|
for (int16 j = 0; j < 256; j++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
newColor.r = oldPalette[j].r >> i;
|
|
|
|
newColor.g = oldPalette[j].g >> i;
|
|
|
|
newColor.b = oldPalette[j].b >> i;
|
|
|
|
CLPalette_SetRGBColor(newPalette, j, &newColor);
|
|
|
|
}
|
|
|
|
CLPalette_Send2Screen(newPalette, 0, 256);
|
|
|
|
wait(delay);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-31 05:11:33 -08:00
|
|
|
// Original name: fadetoblack128
|
|
|
|
void EdenGame::fadeToBlackLowPalette(int delay) {
|
2016-09-14 23:39:27 +02:00
|
|
|
CLPalette_GetLastPalette(oldPalette);
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 0; i < 6; i++) {
|
2016-12-31 05:11:33 -08:00
|
|
|
for (int16 j = 0; j < 129; j++) { //CHECKME: Should be 128?
|
2016-09-14 23:39:27 +02:00
|
|
|
newColor.r = oldPalette[j].r >> i;
|
|
|
|
newColor.g = oldPalette[j].g >> i;
|
|
|
|
newColor.b = oldPalette[j].b >> i;
|
|
|
|
CLPalette_SetRGBColor(newPalette, j, &newColor);
|
|
|
|
}
|
|
|
|
CLPalette_Send2Screen(newPalette, 0, 128);
|
|
|
|
wait(delay);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-31 05:11:33 -08:00
|
|
|
// Original name: fadefromblack128
|
|
|
|
void EdenGame::fadeFromBlackLowPalette(int delay) {
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 0; i < 6; i++) {
|
2016-12-31 05:11:33 -08:00
|
|
|
for (int16 j = 0; j < 129; j++) { //CHECKME: Should be 128?
|
2016-12-25 13:45:47 -08:00
|
|
|
newColor.r = _globalPalette[j].r >> (5 - i);
|
|
|
|
newColor.g = _globalPalette[j].g >> (5 - i);
|
|
|
|
newColor.b = _globalPalette[j].b >> (5 - i);
|
2016-09-14 23:39:27 +02:00
|
|
|
CLPalette_SetRGBColor(newPalette, j, &newColor);
|
|
|
|
}
|
|
|
|
CLPalette_Send2Screen(newPalette, 0, 128);
|
|
|
|
wait(delay);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-27 10:11:37 -08:00
|
|
|
// Original name: rectanglenoir32
|
|
|
|
void EdenGame::blackRect32() {
|
2016-09-14 23:39:27 +02:00
|
|
|
// blacken 32x32 rectangle
|
2017-01-01 11:51:48 -08:00
|
|
|
int *pix = (int *)_view2Buf;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 0; i < 32; i++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
pix[0] = 0;
|
|
|
|
pix[1] = 0;
|
|
|
|
pix[2] = 0;
|
|
|
|
pix[3] = 0;
|
|
|
|
pix[4] = 0;
|
|
|
|
pix[5] = 0;
|
|
|
|
pix[6] = 0;
|
|
|
|
pix[7] = 0;
|
|
|
|
pix += 32 / 4;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-27 10:11:37 -08:00
|
|
|
void EdenGame::setSrcRect(int16 sx, int16 sy, int16 ex, int16 ey) {
|
|
|
|
rect_src = Common::Rect(sx, sy, ex, ey);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-27 10:11:37 -08:00
|
|
|
void EdenGame::setDestRect(int16 sx, int16 sy, int16 ex, int16 ey) {
|
|
|
|
rect_dst = Common::Rect(sx, sy, ex, ey);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::wait(int howlong) {
|
2017-01-05 02:06:50 -08:00
|
|
|
int t = g_system->getMillis();
|
2016-09-14 23:39:27 +02:00
|
|
|
#ifdef EDEN_DEBUG
|
|
|
|
howlong *= 10;
|
|
|
|
#endif
|
2017-01-05 02:06:50 -08:00
|
|
|
for (int t2 = t; t2 - t < howlong; t2 = g_system->getMillis())
|
2016-10-23 23:28:48 +02:00
|
|
|
g_system->delayMillis(10); // waste time
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::effetpix() {
|
2016-12-03 15:26:32 -08:00
|
|
|
byte *scr;
|
|
|
|
uint16 r25, r18, r31, r30; //TODO: change to xx/yy
|
2016-10-23 23:28:48 +02:00
|
|
|
|
2017-01-01 14:14:02 -08:00
|
|
|
uint16 ww = _vm->_screenView->_pitch;
|
2016-09-14 23:39:27 +02:00
|
|
|
r25 = ww * 80;
|
|
|
|
r18 = 640 * 80;
|
2016-12-18 14:13:36 -08:00
|
|
|
byte *pix = _mainView->_bufferPtr + 16 * 640;
|
2016-09-30 07:48:27 +02:00
|
|
|
if (!_doubledScreen) {
|
2016-12-18 14:13:36 -08:00
|
|
|
int x = _mainView->_normal._dstLeft;
|
|
|
|
int y = _mainView->_normal._dstTop;
|
2017-01-01 14:14:02 -08:00
|
|
|
scr = _vm->_screenView->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += (y + 16) * ww + x;
|
|
|
|
} else {
|
2016-12-18 14:13:36 -08:00
|
|
|
int x = _mainView->_zoom._dstLeft;
|
|
|
|
int y = _mainView->_zoom._dstTop;
|
2017-01-01 14:14:02 -08:00
|
|
|
scr = _vm->_screenView->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += (y + 16 * 2) * ww + x;
|
|
|
|
r25 *= 2;
|
|
|
|
}
|
2016-10-23 23:28:48 +02:00
|
|
|
int16 r20 = 0x4400; //TODO
|
|
|
|
int16 r27 = 1;
|
|
|
|
int16 r26 = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
do {
|
|
|
|
char r8 = r27 & 1;
|
|
|
|
r27 >>= 1;
|
|
|
|
if (r8)
|
|
|
|
r27 ^= r20;
|
|
|
|
if (r27 < 320 * 80) {
|
|
|
|
r31 = r27 / 320;
|
|
|
|
r30 = r27 % 320;
|
2016-09-30 07:48:27 +02:00
|
|
|
if (_doubledScreen) {
|
2016-09-14 23:39:27 +02:00
|
|
|
r31 *= 2;
|
|
|
|
r30 *= 2;
|
|
|
|
scr[r31 * ww + r30] = 0;
|
|
|
|
scr[r31 * ww + r30 + 1] = 0;
|
|
|
|
scr[r31 * ww + r25 + r30] = 0;
|
|
|
|
scr[r31 * ww + r25 + r30 + 1] = 0;
|
|
|
|
r31++;
|
|
|
|
scr[r31 * ww + r30] = 0;
|
|
|
|
scr[r31 * ww + r30 + 1] = 0;
|
|
|
|
scr[r31 * ww + r25 + r30] = 0;
|
|
|
|
scr[r31 * ww + r25 + r30 + 1] = 0;
|
|
|
|
if (++r26 == 960) {
|
|
|
|
wait(1);
|
|
|
|
r26 = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
scr[r31 * ww + r30] = 0;
|
|
|
|
scr[r31 * ww + r25 + r30] = 0;
|
|
|
|
if (++r26 == 960) {
|
|
|
|
CLBlitter_UpdateScreen();
|
|
|
|
wait(1);
|
|
|
|
r26 = 0;
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
} while (r27 != 1);
|
2016-12-25 13:45:47 -08:00
|
|
|
CLPalette_Send2Screen(_globalPalette, 0, 256);
|
2016-09-14 23:39:27 +02:00
|
|
|
r20 = 0x4400;
|
|
|
|
r27 = 1;
|
|
|
|
r26 = 0;
|
|
|
|
do {
|
|
|
|
char r8 = r27 & 1;
|
|
|
|
r27 >>= 1;
|
|
|
|
if (r8)
|
|
|
|
r27 ^= r20;
|
|
|
|
if (r27 < 320 * 80) {
|
|
|
|
r31 = r27 / 320;
|
|
|
|
r30 = r27 % 320;
|
2016-10-23 23:28:48 +02:00
|
|
|
byte p0 = pix[r31 * 640 + r30];
|
|
|
|
byte p1 = pix[r31 * 640 + r18 + r30];
|
2016-09-30 07:48:27 +02:00
|
|
|
if (_doubledScreen) {
|
2016-09-14 23:39:27 +02:00
|
|
|
r31 *= 2;
|
|
|
|
r30 *= 2;
|
2016-10-23 23:28:48 +02:00
|
|
|
scr[r31 * ww + r30] = p0;
|
|
|
|
scr[r31 * ww + r30 + 1] = p0;
|
|
|
|
scr[r31 * ww + r25 + r30] = p1;
|
|
|
|
scr[r31 * ww + r25 + r30 + 1] = p1;
|
2016-09-14 23:39:27 +02:00
|
|
|
r31++;
|
2016-10-23 23:28:48 +02:00
|
|
|
scr[r31 * ww + r30] = p0;
|
|
|
|
scr[r31 * ww + r30 + 1] = p0;
|
|
|
|
scr[r31 * ww + r25 + r30] = p1;
|
|
|
|
scr[r31 * ww + r25 + r30 + 1] = p1;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (++r26 == 960) {
|
|
|
|
wait(1);
|
|
|
|
r26 = 0;
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
} else {
|
2016-10-23 23:28:48 +02:00
|
|
|
scr[r31 * ww + r30] = p0;
|
|
|
|
scr[r31 * ww + r25 + r30] = p1;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (++r26 == 960) {
|
|
|
|
CLBlitter_UpdateScreen();
|
|
|
|
wait(1);
|
|
|
|
r26 = 0;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
} while (r27 != 1);
|
2017-01-01 14:14:02 -08:00
|
|
|
assert(_vm->_screenView->_pitch == 320);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////// datfile.c
|
2016-12-27 10:43:15 -08:00
|
|
|
void EdenGame::verifh(byte *ptr) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte sum = 0;
|
2016-12-27 10:43:15 -08:00
|
|
|
byte *head = ptr;
|
2016-10-23 23:28:48 +02:00
|
|
|
|
|
|
|
for (int8 i = 0; i < 6; i++)
|
2016-09-14 23:39:27 +02:00
|
|
|
sum += *head++;
|
2016-10-23 23:28:48 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
if (sum != 0xAB)
|
|
|
|
return;
|
2016-10-23 23:28:48 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
debug("* Begin unpacking resource");
|
|
|
|
head -= 6;
|
2016-12-04 14:54:58 -08:00
|
|
|
uint16 h0 = READ_LE_UINT16(head);
|
2016-09-14 23:39:27 +02:00
|
|
|
head += 2;
|
2016-11-15 09:41:06 +01:00
|
|
|
/*char unused = * */head++;
|
2016-12-04 14:54:58 -08:00
|
|
|
uint16 h3 = READ_LE_UINT16(head);
|
2016-09-14 23:39:27 +02:00
|
|
|
head += 2;
|
2016-10-23 23:28:48 +02:00
|
|
|
byte *data = h0 + head + 26;
|
2016-09-14 23:39:27 +02:00
|
|
|
h3 -= 6;
|
|
|
|
head += h3;
|
|
|
|
for (; h3; h3--)
|
|
|
|
*data-- = *head--;
|
|
|
|
head = data + 1;
|
2016-12-27 10:43:15 -08:00
|
|
|
data = ptr;
|
2016-12-31 05:11:33 -08:00
|
|
|
expandHSQ(head, data);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::openbigfile() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_bigfile.open("EDEN.DAT");
|
2016-12-06 23:08:32 -08:00
|
|
|
|
|
|
|
char buf[16];
|
2017-01-01 11:51:48 -08:00
|
|
|
int count = _bigfile.readUint16LE();
|
|
|
|
_bigfileHeader = new PakHeaderNode(count);
|
2016-12-06 23:08:32 -08:00
|
|
|
for (int j = 0; j < count; j++) {
|
|
|
|
for (int k = 0; k < 16; k++)
|
2017-01-01 11:51:48 -08:00
|
|
|
buf[k] = _bigfile.readByte();
|
|
|
|
_bigfileHeader->_files[j]._name = Common::String(buf);
|
|
|
|
_bigfileHeader->_files[j]._size = _bigfile.readUint32LE();
|
|
|
|
_bigfileHeader->_files[j]._offs = _bigfile.readUint32LE();
|
|
|
|
_bigfileHeader->_files[j]._flag = _bigfile.readByte();
|
2016-12-06 23:08:32 -08:00
|
|
|
}
|
2016-11-09 13:40:08 -08:00
|
|
|
|
2017-01-03 22:37:30 -08:00
|
|
|
_vm->_video->resetInternals();
|
|
|
|
_vm->_video->setFile(&_bigfile);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::closebigfile() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_bigfile.close();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-07 15:04:25 -08:00
|
|
|
void EdenGame::loadRawFile(uint16 num, byte *buffer) {
|
2016-11-09 13:40:08 -08:00
|
|
|
if (_vm->getPlatform() == Common::kPlatformDOS) {
|
2016-11-13 03:47:40 -08:00
|
|
|
if ((_vm->isDemo() && num > 2204) || num > 2472)
|
2016-10-10 01:26:23 +03:00
|
|
|
error("Trying to read invalid game resource");
|
|
|
|
}
|
2016-10-17 03:05:37 +03:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
assert(num < _bigfileHeader->_count);
|
|
|
|
PakHeaderItem *file = &_bigfileHeader->_files[num];
|
2016-12-07 15:04:25 -08:00
|
|
|
int32 size = file->_size;
|
|
|
|
int32 offs = file->_offs;
|
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
_bigfile.seek(offs, SEEK_SET);
|
|
|
|
_bigfile.read(buffer, size);
|
2016-12-07 15:04:25 -08:00
|
|
|
}
|
|
|
|
|
2016-12-17 09:32:43 -08:00
|
|
|
void EdenGame::loadIconFile(uint16 num, Icon *buffer) {
|
2016-12-07 15:04:25 -08:00
|
|
|
if (_vm->getPlatform() == Common::kPlatformDOS) {
|
|
|
|
if ((_vm->isDemo() && num > 2204) || num > 2472)
|
|
|
|
error("Trying to read invalid game resource");
|
|
|
|
}
|
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
assert(num < _bigfileHeader->_count);
|
|
|
|
PakHeaderItem *file = &_bigfileHeader->_files[num];
|
2016-12-07 15:04:25 -08:00
|
|
|
int32 size = file->_size;
|
|
|
|
int32 offs = file->_offs;
|
2016-12-22 23:00:21 -08:00
|
|
|
debug("* Loading icon - Resource %d (%s) at 0x%X, %d bytes", num, file->_name.c_str(), offs, size);
|
2017-01-01 11:51:48 -08:00
|
|
|
_bigfile.seek(offs, SEEK_SET);
|
2016-12-07 15:04:25 -08:00
|
|
|
|
2016-12-17 09:32:43 -08:00
|
|
|
int count = size / sizeof(Icon);
|
2016-12-07 15:04:25 -08:00
|
|
|
for (int i = 0; i < count; i++) {
|
2016-12-21 22:49:28 -08:00
|
|
|
if (_vm->getPlatform() == Common::kPlatformMacintosh) {
|
2017-01-01 11:51:48 -08:00
|
|
|
buffer[i].sx = _bigfile.readSint16BE();
|
|
|
|
buffer[i].sy = _bigfile.readSint16BE();
|
|
|
|
buffer[i].ex = _bigfile.readSint16BE();
|
|
|
|
buffer[i].ey = _bigfile.readSint16BE();
|
|
|
|
buffer[i]._cursorId = _bigfile.readUint16BE();;
|
|
|
|
buffer[i]._actionId= _bigfile.readUint32BE();;
|
|
|
|
buffer[i]._objectId= _bigfile.readUint32BE();;
|
2016-12-21 22:49:28 -08:00
|
|
|
} else {
|
2017-01-01 11:51:48 -08:00
|
|
|
buffer[i].sx = _bigfile.readSint16LE();
|
|
|
|
buffer[i].sy = _bigfile.readSint16LE();
|
|
|
|
buffer[i].ex = _bigfile.readSint16LE();
|
|
|
|
buffer[i].ey = _bigfile.readSint16LE();
|
|
|
|
buffer[i]._cursorId = _bigfile.readUint16LE();;
|
|
|
|
buffer[i]._actionId= _bigfile.readUint32LE();;
|
|
|
|
buffer[i]._objectId= _bigfile.readUint32LE();;
|
2016-12-21 22:49:28 -08:00
|
|
|
}
|
2016-12-07 15:04:25 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-17 09:32:43 -08:00
|
|
|
void EdenGame::loadRoomFile(uint16 num, Room *buffer) {
|
2016-12-07 15:04:25 -08:00
|
|
|
if (_vm->getPlatform() == Common::kPlatformDOS) {
|
|
|
|
if ((_vm->isDemo() && num > 2204) || num > 2472)
|
|
|
|
error("Trying to read invalid game resource");
|
|
|
|
}
|
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
assert(num < _bigfileHeader->_count);
|
|
|
|
PakHeaderItem *file = &_bigfileHeader->_files[num];
|
2016-12-07 15:04:25 -08:00
|
|
|
int32 size = file->_size;
|
|
|
|
int32 offs = file->_offs;
|
2016-12-22 23:00:21 -08:00
|
|
|
debug("* Loading room - Resource %d (%s) at 0x%X, %d bytes", num, file->_name.c_str(), offs, size);
|
2017-01-01 11:51:48 -08:00
|
|
|
_bigfile.seek(offs, SEEK_SET);
|
2016-12-07 15:04:25 -08:00
|
|
|
|
2016-12-17 09:32:43 -08:00
|
|
|
int count = size / sizeof(Room);
|
2016-12-07 15:04:25 -08:00
|
|
|
for (int i = 0; i < count; i++) {
|
2017-01-01 11:51:48 -08:00
|
|
|
buffer[i]._id = _bigfile.readByte();
|
2016-12-07 15:04:25 -08:00
|
|
|
for (int j = 0; j < 4; j++)
|
2017-01-01 11:51:48 -08:00
|
|
|
buffer[i]._exits[j] = _bigfile.readByte();
|
|
|
|
buffer[i]._flags = _bigfile.readByte();
|
2016-12-22 23:00:21 -08:00
|
|
|
if (_vm->getPlatform() == Common::kPlatformMacintosh) {
|
2017-01-01 11:51:48 -08:00
|
|
|
buffer[i]._bank = _bigfile.readUint16BE();
|
|
|
|
buffer[i]._party = _bigfile.readUint16BE();
|
2016-12-22 23:00:21 -08:00
|
|
|
} else {
|
2017-01-01 11:51:48 -08:00
|
|
|
buffer[i]._bank = _bigfile.readUint16LE();
|
|
|
|
buffer[i]._party = _bigfile.readUint16LE();
|
2016-12-22 23:00:21 -08:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
buffer[i]._level = _bigfile.readByte();
|
|
|
|
buffer[i]._video = _bigfile.readByte();
|
|
|
|
buffer[i]._location = _bigfile.readByte();
|
|
|
|
buffer[i]._backgroundBankNum = _bigfile.readByte();
|
2016-12-07 15:04:25 -08:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-12 07:19:17 +01:00
|
|
|
// Original name: shnmfl
|
|
|
|
void EdenGame::loadHnm(uint16 num) {
|
2016-10-17 03:05:37 +03:00
|
|
|
unsigned int resNum = num - 1 + 485;
|
2017-01-01 11:51:48 -08:00
|
|
|
assert(resNum < _bigfileHeader->_count);
|
|
|
|
PakHeaderItem *file = &_bigfileHeader->_files[resNum];
|
2016-12-07 15:04:25 -08:00
|
|
|
int size = file->_size;
|
|
|
|
int offs = file->_offs;
|
2016-12-06 23:08:32 -08:00
|
|
|
debug("* Loading movie %d (%s) at 0x%X, %d bytes", num, file->_name.c_str(), (uint)offs, size);
|
2017-01-03 22:37:30 -08:00
|
|
|
_vm->_video->_file->seek(offs, SEEK_SET);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-12 07:19:17 +01:00
|
|
|
// Original name: ssndfl
|
|
|
|
int EdenGame::loadSound(uint16 num) {
|
2016-11-09 13:40:08 -08:00
|
|
|
unsigned int resNum = num - 1 + ((_vm->getPlatform() == Common::kPlatformDOS && _vm->isDemo()) ? 656 : 661);
|
2017-01-01 11:51:48 -08:00
|
|
|
assert(resNum < _bigfileHeader->_count);
|
|
|
|
PakHeaderItem *file = &_bigfileHeader->_files[resNum];
|
2016-12-07 15:04:25 -08:00
|
|
|
int32 size = file->_size;
|
|
|
|
int32 offs = file->_offs;
|
2016-12-06 23:08:32 -08:00
|
|
|
debug("* Loading sound %d (%s) at 0x%X, %d bytes", num, file->_name.c_str(), (uint)offs, size);
|
2016-10-06 00:15:02 +02:00
|
|
|
if (_soundAllocated) {
|
2016-12-26 22:47:24 -08:00
|
|
|
free(_voiceSamplesBuffer);
|
|
|
|
_voiceSamplesBuffer = nullptr;
|
2016-10-06 00:15:02 +02:00
|
|
|
_soundAllocated = false; //TODO: bug??? no alloc
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-12-26 22:47:24 -08:00
|
|
|
_voiceSamplesBuffer = (byte *)malloc(size);
|
2016-10-06 00:15:02 +02:00
|
|
|
_soundAllocated = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-11-10 15:37:48 -08:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
_bigfile.seek(offs, SEEK_SET);
|
2016-10-17 03:05:37 +03:00
|
|
|
//For PC loaded data is a VOC file, on Mac version this is a raw samples
|
2016-11-09 13:40:08 -08:00
|
|
|
if (_vm->getPlatform() == Common::kPlatformMacintosh)
|
2017-01-01 11:51:48 -08:00
|
|
|
_bigfile.read(_voiceSamplesBuffer, size);
|
2016-10-17 03:05:37 +03:00
|
|
|
else {
|
|
|
|
// VOC files also include extra information for lipsync
|
|
|
|
// 1. Standard VOC header
|
2017-01-01 11:51:48 -08:00
|
|
|
_bigfile.read(_voiceSamplesBuffer, 0x1A);
|
2016-11-09 13:40:08 -08:00
|
|
|
|
2016-10-17 03:05:37 +03:00
|
|
|
// 2. Lipsync?
|
2017-01-01 11:51:48 -08:00
|
|
|
unsigned char chunkType = _bigfile.readByte();
|
2016-11-09 13:40:08 -08:00
|
|
|
|
2016-12-26 22:55:21 -08:00
|
|
|
uint32 val = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
_bigfile.read(&val, 3);
|
2016-11-09 13:40:08 -08:00
|
|
|
unsigned int chunkLen = LE32(val);
|
|
|
|
|
2016-10-17 03:05:37 +03:00
|
|
|
if (chunkType == 5) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_bigfile.read(_gameLipsync + 7260, chunkLen);
|
2017-01-12 07:19:17 +01:00
|
|
|
// _animBufferPtr = _gameLipsync + 7260 + 2;
|
2016-10-17 03:05:37 +03:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
chunkType = _bigfile.readByte();
|
|
|
|
_bigfile.read(&val, 3);
|
2016-11-09 22:02:32 -08:00
|
|
|
chunkLen = LE32(val);
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
2016-11-09 13:40:08 -08:00
|
|
|
|
2016-10-17 03:05:37 +03:00
|
|
|
// 3. Normal sound data
|
|
|
|
if (chunkType == 1) {
|
2017-01-12 07:19:17 +01:00
|
|
|
/*uint8 freq = */_bigfile.readUint16LE();
|
2016-10-17 03:05:37 +03:00
|
|
|
size = chunkLen - 2;
|
2017-01-01 11:51:48 -08:00
|
|
|
_bigfile.read(_voiceSamplesBuffer, size);
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-10-17 03:05:37 +03:00
|
|
|
return size;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-15 23:51:17 +01:00
|
|
|
void EdenGame::convertMacToPC() {
|
2016-10-23 23:28:48 +02:00
|
|
|
// Convert all mac (big-endian) resources to native format
|
2016-09-14 23:39:27 +02:00
|
|
|
// Array of longs
|
2017-01-01 11:51:48 -08:00
|
|
|
int *p = (int *)_gameLipsync;
|
2016-09-14 23:39:27 +02:00
|
|
|
for (int i = 0; i < 7240 / 4; i++)
|
|
|
|
p[i] = BE32(p[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::loadpermfiles() {
|
2016-11-09 13:40:08 -08:00
|
|
|
switch (_vm->getPlatform()) {
|
2016-10-10 01:26:23 +03:00
|
|
|
case Common::kPlatformDOS:
|
2016-10-17 03:05:37 +03:00
|
|
|
{
|
|
|
|
// Since PC version stores hotspots and rooms info in the executable, load them from premade resource file
|
|
|
|
Common::File f;
|
2016-10-23 23:28:48 +02:00
|
|
|
|
2016-10-17 03:05:37 +03:00
|
|
|
if (f.open("led.dat")) {
|
|
|
|
const int kNumIcons = 136;
|
|
|
|
const int kNumRooms = 424;
|
2016-12-17 09:32:43 -08:00
|
|
|
if (f.size() != kNumIcons * sizeof(Icon) + kNumRooms * sizeof(Room))
|
2016-10-17 03:05:37 +03:00
|
|
|
error("Mismatching aux data");
|
2016-12-07 15:04:25 -08:00
|
|
|
for (int i = 0; i < kNumIcons; i++) {
|
|
|
|
_gameIcons[i].sx = f.readSint16LE();
|
|
|
|
_gameIcons[i].sy = f.readSint16LE();
|
|
|
|
_gameIcons[i].ex = f.readSint16LE();
|
|
|
|
_gameIcons[i].ey = f.readSint16LE();
|
|
|
|
_gameIcons[i]._cursorId = f.readUint16LE();
|
|
|
|
_gameIcons[i]._actionId = f.readUint32LE();
|
|
|
|
_gameIcons[i]._objectId = f.readUint32LE();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i <kNumRooms; i++) {
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[i]._id = f.readByte();
|
2016-12-07 15:04:25 -08:00
|
|
|
for (int j = 0; j < 4; j++)
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[i]._exits[j] = f.readByte();
|
|
|
|
_gameRooms[i]._flags = f.readByte();
|
|
|
|
_gameRooms[i]._bank = f.readUint16LE();
|
|
|
|
_gameRooms[i]._party = f.readUint16LE();
|
|
|
|
_gameRooms[i]._level = f.readByte();
|
|
|
|
_gameRooms[i]._video = f.readByte();
|
|
|
|
_gameRooms[i]._location = f.readByte();
|
|
|
|
_gameRooms[i]._backgroundBankNum = f.readByte();
|
2016-12-07 15:04:25 -08:00
|
|
|
}
|
|
|
|
|
2016-10-17 03:05:37 +03:00
|
|
|
f.close();
|
2016-10-23 23:28:48 +02:00
|
|
|
} else
|
2016-10-17 03:05:37 +03:00
|
|
|
error("Can not load aux data");
|
|
|
|
}
|
2016-10-10 01:26:23 +03:00
|
|
|
break;
|
|
|
|
case Common::kPlatformMacintosh:
|
2016-12-07 15:04:25 -08:00
|
|
|
loadIconFile(2498, _gameIcons);
|
2016-12-18 14:13:36 -08:00
|
|
|
loadRoomFile(2497, _gameRooms);
|
2017-01-01 11:51:48 -08:00
|
|
|
loadRawFile(2486, _gameLipsync);
|
2017-01-15 23:51:17 +01:00
|
|
|
convertMacToPC();
|
2016-10-10 01:26:23 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("Unsupported platform");
|
|
|
|
}
|
|
|
|
|
2016-12-07 15:04:25 -08:00
|
|
|
loadRawFile(0, _mainBankBuf);
|
2016-12-18 14:13:36 -08:00
|
|
|
loadRawFile(402, _gameFont);
|
2016-12-28 03:43:13 -08:00
|
|
|
loadRawFile(404, _gameDialogs);
|
|
|
|
loadRawFile(403, _gameConditions);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-11-09 22:36:06 -08:00
|
|
|
bool EdenGame::ReadDataSyncVOC(unsigned int num) {
|
2016-11-09 13:40:08 -08:00
|
|
|
unsigned int resNum = num - 1 + ((_vm->getPlatform() == Common::kPlatformDOS && _vm->isDemo()) ? 656 : 661);
|
2016-10-17 03:05:37 +03:00
|
|
|
unsigned char vocHeader[0x1A];
|
2016-11-09 22:36:06 -08:00
|
|
|
int filePos = 0;
|
|
|
|
loadpartoffile(resNum, vocHeader, filePos, sizeof(vocHeader));
|
|
|
|
filePos += sizeof(vocHeader);
|
2016-10-17 03:05:37 +03:00
|
|
|
unsigned char chunkType = 0;
|
|
|
|
loadpartoffile(resNum, &chunkType, sizeof(vocHeader), 1);
|
2016-11-09 22:36:06 -08:00
|
|
|
filePos++;
|
2016-10-17 03:05:37 +03:00
|
|
|
if (chunkType == 5) {
|
2016-12-20 23:02:31 -08:00
|
|
|
uint32 chunkLen = 0;
|
2016-11-09 22:36:06 -08:00
|
|
|
loadpartoffile(resNum, &chunkLen, filePos, 3);
|
|
|
|
filePos += 3;
|
2016-10-17 03:05:37 +03:00
|
|
|
chunkLen = LE32(chunkLen);
|
2017-01-01 11:51:48 -08:00
|
|
|
loadpartoffile(resNum, _gameLipsync + 7260, filePos, chunkLen);
|
2016-11-09 22:36:06 -08:00
|
|
|
return true;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-11-09 22:36:06 -08:00
|
|
|
return false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-11-09 22:36:06 -08:00
|
|
|
bool EdenGame::ReadDataSync(uint16 num) {
|
2016-11-09 13:40:08 -08:00
|
|
|
if (_vm->getPlatform() == Common::kPlatformMacintosh) {
|
2017-01-01 11:51:48 -08:00
|
|
|
long pos = READ_LE_UINT32(_gameLipsync + num * 4);
|
2016-10-17 03:05:37 +03:00
|
|
|
if (pos != -1) {
|
2016-12-26 14:25:19 -08:00
|
|
|
long len = 1024;
|
2017-01-01 11:51:48 -08:00
|
|
|
loadpartoffile(1936, _gameLipsync + 7260, pos, len);
|
2016-11-09 22:36:06 -08:00
|
|
|
return true;
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
2016-11-09 22:36:06 -08:00
|
|
|
} else
|
2016-10-17 03:05:37 +03:00
|
|
|
return ReadDataSyncVOC(num + 1); //TODO: remove -1 in caller
|
2016-11-09 22:36:06 -08:00
|
|
|
return false;
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-10-08 23:31:21 +02:00
|
|
|
void EdenGame::loadpartoffile(uint16 num, void *buffer, int32 pos, int32 len) {
|
2017-01-01 11:51:48 -08:00
|
|
|
assert(num < _bigfileHeader->_count);
|
|
|
|
PakHeaderItem *file = &_bigfileHeader->_files[num];
|
2016-12-06 23:08:32 -08:00
|
|
|
int32 offs = READ_LE_UINT32(&file->_offs);
|
|
|
|
debug("* Loading partial resource %d (%s) at 0x%X(+0x%X), %d bytes", num, file->_name.c_str(), offs, pos, len);
|
2017-01-01 11:51:48 -08:00
|
|
|
_bigfile.seek(offs + pos, SEEK_SET);
|
|
|
|
_bigfile.read(buffer, len);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-31 05:11:33 -08:00
|
|
|
void EdenGame::expandHSQ(byte *input, byte *output) {
|
2016-12-27 10:43:15 -08:00
|
|
|
byte *src = input;
|
|
|
|
byte *dst = output;
|
|
|
|
byte *ptr;
|
|
|
|
uint16 bit; // bit
|
|
|
|
uint16 queue = 0; // queue
|
|
|
|
uint16 len = 0;
|
|
|
|
int16 ofs;
|
2016-09-14 23:39:27 +02:00
|
|
|
#define GetBit \
|
|
|
|
bit = queue & 1; \
|
|
|
|
queue >>= 1; \
|
|
|
|
if (!queue) { \
|
|
|
|
queue = (src[1] << 8) | src[0]; src += 2; \
|
|
|
|
bit = queue & 1; \
|
|
|
|
queue = (queue >> 1) | 0x8000; \
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
GetBit;
|
|
|
|
if (bit)
|
|
|
|
*dst++ = *src++;
|
|
|
|
else {
|
|
|
|
len = 0;
|
|
|
|
GetBit;
|
|
|
|
if (!bit) {
|
|
|
|
GetBit;
|
|
|
|
len = (len << 1) | bit;
|
|
|
|
GetBit;
|
|
|
|
len = (len << 1) | bit;
|
|
|
|
ofs = 0xFF00 | *src++; //TODO: -256
|
|
|
|
} else {
|
|
|
|
ofs = (src[1] << 8) | src[0];
|
|
|
|
src += 2;
|
|
|
|
len = ofs & 7;
|
|
|
|
ofs = (ofs >> 3) | 0xE000;
|
|
|
|
if (!len) {
|
|
|
|
len = *src++;
|
|
|
|
if (!len)
|
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
ptr = dst + ofs;
|
|
|
|
len += 2;
|
|
|
|
while (len--)
|
|
|
|
*dst++ = *ptr++;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//////
|
2016-12-11 13:44:58 -08:00
|
|
|
|
|
|
|
// Original name: ajouinfo
|
|
|
|
void EdenGame::addInfo(byte info) {
|
2017-01-01 11:51:48 -08:00
|
|
|
byte idx = _globals->_nextInfoIdx;
|
2017-01-15 23:51:17 +01:00
|
|
|
if (kPersons[PER_ELOI]._roomNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
info |= 0x80;
|
2016-12-11 13:44:58 -08:00
|
|
|
_infoList[idx] = info;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (idx == _globals->_lastInfoIdx)
|
|
|
|
_globals->_lastInfo = info;
|
2016-09-14 23:39:27 +02:00
|
|
|
idx++;
|
2016-11-13 22:59:45 -08:00
|
|
|
if (idx == 16)
|
|
|
|
idx = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_nextInfoIdx = idx;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-11 13:44:58 -08:00
|
|
|
void EdenGame::unlockInfo() {
|
2016-11-13 22:59:45 -08:00
|
|
|
for (byte idx = 0; idx < 16; idx++) {
|
2016-12-11 13:44:58 -08:00
|
|
|
if (_infoList[idx] != 0xFF)
|
|
|
|
_infoList[idx] &= ~0x80;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_lastInfo &= ~0x80;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-11 13:44:58 -08:00
|
|
|
void EdenGame::nextInfo() {
|
2016-09-14 23:39:27 +02:00
|
|
|
do {
|
2017-01-01 11:51:48 -08:00
|
|
|
byte idx = _globals->_lastInfoIdx;
|
2016-12-11 13:44:58 -08:00
|
|
|
_infoList[idx] = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
idx++;
|
2016-11-13 22:59:45 -08:00
|
|
|
if (idx == 16)
|
|
|
|
idx = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_lastInfoIdx = idx;
|
|
|
|
_globals->_lastInfo = _infoList[idx];
|
|
|
|
} while (_globals->_lastInfo == 0xFF);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-11 13:44:58 -08:00
|
|
|
// Original name: delinfo
|
|
|
|
void EdenGame::removeInfo(byte info) {
|
2016-11-13 22:59:45 -08:00
|
|
|
for (byte idx = 0; idx < 16; idx++) {
|
2016-12-11 13:44:58 -08:00
|
|
|
if ((_infoList[idx] & ~0x80) == info) {
|
|
|
|
_infoList[idx] = 0xFF;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (idx == _globals->_lastInfoIdx)
|
2016-12-11 13:44:58 -08:00
|
|
|
nextInfo();
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-11 13:44:58 -08:00
|
|
|
void EdenGame::updateInfoList() {
|
2016-10-24 22:02:43 +02:00
|
|
|
for (int idx = 0; idx < 16; idx++)
|
2016-12-11 13:44:58 -08:00
|
|
|
_infoList[idx] = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-31 05:11:33 -08:00
|
|
|
void EdenGame::initGlobals() {
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[16]._cursorId |= 0x8000;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_areaNum = Areas::arMo;
|
|
|
|
_globals->_areaVisitCount = 1;
|
|
|
|
_globals->_menuItemIdLo = 0;
|
|
|
|
_globals->_menuItemIdHi = 0;
|
|
|
|
_globals->_randomNumber = 0;
|
|
|
|
_globals->_gameTime = 0;
|
|
|
|
_globals->_gameDays = 0;
|
|
|
|
_globals->_chrono = 0;
|
|
|
|
_globals->_eloiDepartureDay = 0;
|
|
|
|
_globals->_roomNum = 259;
|
|
|
|
_globals->_newRoomNum = 0;
|
|
|
|
_globals->_phaseNum = 0;
|
|
|
|
_globals->_metPersonsMask1 = 0;
|
|
|
|
_globals->_party = 0;
|
|
|
|
_globals->_partyOutside = 0;
|
|
|
|
_globals->_metPersonsMask2 = 0;
|
|
|
|
_globals->_phaseActionsCount = 0;
|
|
|
|
_globals->_curAreaFlags = 0;
|
|
|
|
_globals->_curItemsMask = 0;
|
|
|
|
_globals->_curPowersMask = 0;
|
|
|
|
_globals->_curPersoItems = 0;
|
|
|
|
_globals->_curCharacterPowers = 0;
|
|
|
|
_globals->_wonItemsMask = 0;
|
|
|
|
_globals->_wonPowersMask = 0;
|
|
|
|
_globals->_stepsToFindAppleFast = 0;
|
|
|
|
_globals->_stepsToFindAppleNormal = 0;
|
|
|
|
_globals->_roomPersoItems = 0;
|
|
|
|
_globals->_roomCharacterPowers = 0;
|
|
|
|
_globals->_gameFlags = GameFlags::gfNone;
|
2017-01-22 23:55:31 +01:00
|
|
|
_globals->_curVideoNum = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_morkusSpyVideoNum1 = 89;
|
|
|
|
_globals->_morkusSpyVideoNum2 = 88;
|
|
|
|
_globals->_morkusSpyVideoNum3 = 83;
|
|
|
|
_globals->_morkusSpyVideoNum4 = 94;
|
|
|
|
_globals->_newMusicType = MusicType::mtDontChange;
|
|
|
|
_globals->_var43 = 0;
|
|
|
|
_globals->_videoSubtitleIndex = 0;
|
|
|
|
_globals->_partyInstruments = 0;
|
|
|
|
_globals->_monkGotRing = 0;
|
|
|
|
_globals->_chronoFlag = 0;
|
|
|
|
_globals->_curRoomFlags = 0;
|
|
|
|
_globals->_endGameFlag = 0;
|
|
|
|
_globals->_lastInfo = 0;
|
|
|
|
_globals->_autoDialog = false;
|
|
|
|
_globals->_worldTyranSighted = 0;
|
|
|
|
_globals->_var4D = 0;
|
|
|
|
_globals->_var4E = 0;
|
|
|
|
_globals->_worldGaveGold = 0;
|
|
|
|
_globals->_worldHasTriceraptors = 0;
|
|
|
|
_globals->_worldHasVelociraptors = 0;
|
|
|
|
_globals->_worldHasTyran = 0;
|
|
|
|
_globals->_var53 = 0;
|
|
|
|
_globals->_var54 = 0;
|
|
|
|
_globals->_var55 = 0;
|
|
|
|
_globals->_gameHours = 0;
|
|
|
|
_globals->_textToken1 = 0;
|
|
|
|
_globals->_textToken2 = 0;
|
|
|
|
_globals->_eloiHaveNews = 0;
|
|
|
|
_globals->_dialogFlags = 0;
|
|
|
|
_globals->_curAreaType = 0;
|
|
|
|
_globals->_curCitadelLevel = 0;
|
|
|
|
_globals->_newLocation = 0;
|
|
|
|
_globals->_prevLocation = 0;
|
|
|
|
_globals->_curPersoFlags = 0;
|
|
|
|
_globals->_var60 = 0;
|
|
|
|
_globals->_eventType = EventType::etEvent5;
|
|
|
|
_globals->_var62 = 0;
|
|
|
|
_globals->_curObjectId = 0;
|
|
|
|
_globals->_curObjectFlags = 0;
|
|
|
|
_globals->_var65 = 1;
|
|
|
|
_globals->_roomCharacterType = 0;
|
|
|
|
_globals->_roomCharacterFlags = 0;
|
|
|
|
_globals->_narratorSequence = 0;
|
|
|
|
_globals->_var69 = 0;
|
|
|
|
_globals->_var6A = 0;
|
|
|
|
_globals->_frescoNumber = 0;
|
|
|
|
_globals->_var6C = 0;
|
|
|
|
_globals->_var6D = 0;
|
|
|
|
_globals->_labyrinthDirections = 0;
|
|
|
|
_globals->_labyrinthRoom = 0;
|
|
|
|
_globals->_curCharacterAnimPtr = nullptr;
|
|
|
|
_globals->_characterImageBank = 0;
|
|
|
|
_globals->_roomImgBank = 0;
|
|
|
|
_globals->_characterBackgroundBankIdx = 55;
|
|
|
|
_globals->_varD4 = 0;
|
|
|
|
_globals->_frescoeWidth = 0;
|
|
|
|
_globals->_frescoeImgBank = 0;
|
|
|
|
_globals->_varDA = 0;
|
|
|
|
_globals->_varDC = 0;
|
|
|
|
_globals->_roomBaseX = 0;
|
|
|
|
_globals->_varE0 = 0;
|
|
|
|
_globals->_dialogType = DialogType::dtTalk;
|
|
|
|
_globals->_varE4 = 0;
|
|
|
|
_globals->_currMusicNum = 0;
|
|
|
|
_globals->_textNum = 0;
|
|
|
|
_globals->_travelTime = 0;
|
|
|
|
_globals->_varEC = 0;
|
|
|
|
_globals->_displayFlags = DisplayFlags::dfFlag1;
|
|
|
|
_globals->_oldDisplayFlags = 1;
|
|
|
|
_globals->_drawFlags = 0;
|
|
|
|
_globals->_varF1 = 0;
|
|
|
|
_globals->_varF2 = 0;
|
|
|
|
_globals->_menuFlags = 0;
|
|
|
|
_globals->_varF5 = 0;
|
|
|
|
_globals->_varF6 = 0;
|
|
|
|
_globals->_varF7 = 0;
|
|
|
|
_globals->_varF8 = 0;
|
|
|
|
_globals->_varF9 = 0;
|
|
|
|
_globals->_varFA = 0;
|
|
|
|
_globals->_animationFlags = 0;
|
|
|
|
_globals->_giveObj1 = 0;
|
|
|
|
_globals->_giveObj2 = 0;
|
|
|
|
_globals->_giveObj3 = 0;
|
|
|
|
_globals->_var100 = 0;
|
|
|
|
_globals->_roomVidNum = 0;
|
|
|
|
_globals->_mirrorEffect = 0;
|
|
|
|
_globals->_var103 = 0;
|
|
|
|
_globals->_roomBackgroundBankNum = 0;
|
|
|
|
_globals->_valleyVidNum = 0;
|
|
|
|
_globals->_updatePaletteFlag = 0;
|
|
|
|
_globals->_inventoryScrollPos = 0;
|
|
|
|
_globals->_objCount = 0;
|
|
|
|
_globals->_textBankIndex = 69;
|
|
|
|
_globals->_citadelAreaNum = 0;
|
|
|
|
_globals->_var113 = 0;
|
|
|
|
_globals->_lastPlaceNum = 0;
|
|
|
|
_globals->_dialogPtr = nullptr;
|
|
|
|
_globals->_tapePtr = _tapes;
|
|
|
|
_globals->_nextDialogPtr = nullptr;
|
|
|
|
_globals->_narratorDialogPtr = nullptr;
|
|
|
|
_globals->_lastDialogPtr = nullptr;
|
|
|
|
_globals->_nextRoomIcon = nullptr;
|
|
|
|
_globals->_sentenceBufferPtr = nullptr;
|
|
|
|
_globals->_roomPtr = nullptr;
|
|
|
|
_globals->_areaPtr = nullptr;
|
|
|
|
_globals->_lastAreaPtr = nullptr;
|
|
|
|
_globals->_curAreaPtr = nullptr;
|
|
|
|
_globals->_citaAreaFirstRoom = 0;
|
|
|
|
_globals->_characterPtr = nullptr;
|
|
|
|
_globals->_roomCharacterPtr = 0;
|
|
|
|
_globals->_lastInfoIdx = 0;
|
|
|
|
_globals->_nextInfoIdx = 0;
|
|
|
|
_globals->_iconsIndex = 16;
|
|
|
|
_globals->_persoSpritePtr = nullptr;
|
|
|
|
_globals->_numGiveObjs = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-09-30 07:48:27 +02:00
|
|
|
initRects();
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-09-30 07:48:27 +02:00
|
|
|
_underSubtitlesScreenRect.top = 0;
|
2016-12-26 13:40:28 -08:00
|
|
|
_underSubtitlesScreenRect.left = _subtitlesXScrMargin;
|
|
|
|
_underSubtitlesScreenRect.right = _subtitlesXScrMargin + _subtitlesXWidth - 1;
|
2016-09-30 07:48:27 +02:00
|
|
|
_underSubtitlesScreenRect.bottom = 176 - 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-09-30 07:48:27 +02:00
|
|
|
_underSubtitlesBackupRect.top = 0;
|
2016-12-26 13:40:28 -08:00
|
|
|
_underSubtitlesBackupRect.left = _subtitlesXScrMargin;
|
|
|
|
_underSubtitlesBackupRect.right = _subtitlesXScrMargin + _subtitlesXWidth - 1;
|
2016-09-30 07:48:27 +02:00
|
|
|
_underSubtitlesBackupRect.bottom = 60 - 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-30 07:48:27 +02:00
|
|
|
void EdenGame::initRects() {
|
|
|
|
_underTopBarScreenRect = Common::Rect(0, 0, 320 - 1, 16 - 1);
|
|
|
|
_underTopBarBackupRect = Common::Rect(0, 0, 320 - 1, 16 - 1);
|
|
|
|
_underBottomBarScreenRect = Common::Rect(0, 176, 320 - 1, 200 - 1); //TODO: original bug? this cause crash in copyrect (this, underBottomBarBackupRect)
|
|
|
|
_underBottomBarBackupRect = Common::Rect(0, 16, 320 - 1, 40 - 1);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: closesalle
|
|
|
|
void EdenGame::closeRoom() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags & DisplayFlags::dfPanable) {
|
|
|
|
_globals->_displayFlags &= ~DisplayFlags::dfPanable;
|
2016-09-26 23:44:42 +02:00
|
|
|
resetScroll();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-07 23:06:10 +02:00
|
|
|
// Original name afsalle1
|
2016-12-17 09:32:43 -08:00
|
|
|
void EdenGame::displaySingleRoom(Room *room) {
|
2016-12-18 14:13:36 -08:00
|
|
|
byte *ptr = (byte *)getElem(_placeRawBuf, room->_id - 1);
|
2016-09-14 23:39:27 +02:00
|
|
|
ptr++;
|
|
|
|
for (;;) {
|
2016-10-07 23:06:10 +02:00
|
|
|
byte b0 = *ptr++;
|
|
|
|
byte b1 = *ptr++;
|
|
|
|
int16 index = (b1 << 8) | b0;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (index == -1)
|
2016-08-18 13:15:54 +02:00
|
|
|
break;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (index > 0) {
|
2016-10-07 23:06:10 +02:00
|
|
|
int16 x = *ptr++ | (((b1 & 0x2) >> 1) << 8); //TODO: check me
|
|
|
|
int16 y = *ptr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
ptr++;
|
|
|
|
index &= 0x1FF;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_displayFlags & 0x80)) {
|
|
|
|
if (index == 1 || _globals->_varF7)
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax_avecnoir(index - 1, x, y);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varF7 = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (b1 & 0x40) {
|
|
|
|
if (b1 & 0x20) {
|
2016-12-13 22:54:31 -08:00
|
|
|
bool addIcon = false;
|
2017-01-01 11:51:48 -08:00
|
|
|
Icon *icon = _globals->_nextRoomIcon;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (b0 < 4) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_roomPtr->_exits[b0])
|
2016-12-13 22:54:31 -08:00
|
|
|
addIcon = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else if (b0 > 229) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_partyOutside & (1 << (b0 - 230)))
|
2016-12-13 22:54:31 -08:00
|
|
|
addIcon = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else if (b0 >= 100) {
|
|
|
|
debug("add object %d", b0 - 100);
|
2016-12-28 03:43:13 -08:00
|
|
|
if (isObjectHere(b0 - 100)) {
|
2016-12-13 22:54:31 -08:00
|
|
|
addIcon = true;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varF7 = 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
} else
|
2016-12-13 22:54:31 -08:00
|
|
|
addIcon = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (addIcon) {
|
2016-12-03 15:40:53 -08:00
|
|
|
icon->_actionId = b0;
|
|
|
|
icon->_objectId = b0;
|
|
|
|
icon->_cursorId = kActionCursors[b0];
|
2016-12-04 14:54:58 -08:00
|
|
|
int16 x = READ_LE_UINT16(ptr);
|
2016-09-14 23:39:27 +02:00
|
|
|
ptr += 2;
|
2016-12-04 14:54:58 -08:00
|
|
|
int16 y = READ_LE_UINT16(ptr);
|
2016-09-14 23:39:27 +02:00
|
|
|
ptr += 2;
|
2016-12-04 14:54:58 -08:00
|
|
|
int16 ex = READ_LE_UINT16(ptr);
|
2016-09-14 23:39:27 +02:00
|
|
|
ptr += 2;
|
2016-12-04 14:54:58 -08:00
|
|
|
int16 ey = READ_LE_UINT16(ptr);
|
2016-09-14 23:39:27 +02:00
|
|
|
ptr += 2;
|
2017-01-01 11:51:48 -08:00
|
|
|
x += _globals->_roomBaseX;
|
|
|
|
ex += _globals->_roomBaseX;
|
2016-09-14 23:39:27 +02:00
|
|
|
debug("add hotspot at %3d:%3d - %3d:%3d, action = %d", x, y, ex, ey, b0);
|
|
|
|
#ifdef EDEN_DEBUG
|
2016-11-13 22:59:45 -08:00
|
|
|
for (int iii = x; iii < ex; iii++)
|
2016-12-29 06:28:11 -08:00
|
|
|
_mainViewBuf[y * 640 + iii] = _mainViewBuf[ey * 640 + iii] = (iii % 2) ? 0 : 255;
|
2016-11-13 22:59:45 -08:00
|
|
|
for (int iii = y; iii < ey; iii++)
|
2016-12-29 06:28:11 -08:00
|
|
|
_mainViewBuf[iii * 640 + x] = _mainViewBuf[iii * 640 + ex] = (iii % 2) ? 0 : 255;
|
2016-09-14 23:39:27 +02:00
|
|
|
#endif
|
|
|
|
icon->sx = x;
|
|
|
|
icon->sy = y;
|
|
|
|
icon->ex = ex;
|
|
|
|
icon->ey = ey;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_nextRoomIcon = ++icon;
|
2016-09-14 23:39:27 +02:00
|
|
|
icon->sx = -1;
|
|
|
|
} else
|
|
|
|
ptr += 8;
|
2016-08-18 13:15:54 +02:00
|
|
|
} else
|
2016-09-14 23:39:27 +02:00
|
|
|
ptr += 8;
|
|
|
|
} else
|
|
|
|
ptr += 8;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-10-07 23:06:10 +02:00
|
|
|
// Original name: afsalle
|
|
|
|
void EdenGame::displayRoom() {
|
2017-01-01 11:51:48 -08:00
|
|
|
Room *room = _globals->_roomPtr;
|
|
|
|
_globals->_displayFlags = DisplayFlags::dfFlag1;
|
|
|
|
_globals->_roomBaseX = 0;
|
|
|
|
_globals->_roomBackgroundBankNum = room->_backgroundBankNum;
|
2016-12-15 22:47:29 -08:00
|
|
|
if (room->_flags & RoomFlags::rf08) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_displayFlags |= DisplayFlags::dfFlag80;
|
2016-12-15 22:47:29 -08:00
|
|
|
if (room->_flags & RoomFlags::rfPanable) {
|
2016-10-07 23:06:10 +02:00
|
|
|
// Scrollable room on 2 screens
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_displayFlags |= DisplayFlags::dfPanable;
|
|
|
|
_globals->_varF4 = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
rundcurs();
|
2016-09-27 07:53:50 +02:00
|
|
|
saveFriezes();
|
2016-12-15 22:47:29 -08:00
|
|
|
useBank(room->_bank - 1);
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax_avecnoir(0, 0, 16);
|
2016-12-15 22:47:29 -08:00
|
|
|
useBank(room->_bank);
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax_avecnoir(0, 320, 16);
|
2016-10-07 23:06:10 +02:00
|
|
|
displaySingleRoom(room);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomBaseX = 320;
|
2016-10-07 23:06:10 +02:00
|
|
|
displaySingleRoom(room + 1);
|
2016-09-14 23:39:27 +02:00
|
|
|
} else
|
2016-10-07 23:06:10 +02:00
|
|
|
displaySingleRoom(room);
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
|
|
|
//TODO: roomImgBank is garbage here!
|
2017-01-18 23:05:38 +01:00
|
|
|
debug("displayRoom: room 0x%X using bank %d", _globals->_roomNum, _globals->_roomImgBank);
|
2017-01-01 11:51:48 -08:00
|
|
|
useBank(_globals->_roomImgBank);
|
2016-10-07 23:06:10 +02:00
|
|
|
displaySingleRoom(room);
|
2017-01-01 14:14:02 -08:00
|
|
|
assert(_vm->_screenView->_pitch == 320);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-10-07 23:06:10 +02:00
|
|
|
// Original name: aflieu
|
|
|
|
void EdenGame::displayPlace() {
|
2016-09-14 23:39:27 +02:00
|
|
|
no_perso();
|
2017-01-01 14:14:02 -08:00
|
|
|
if (!_vm->shouldQuit()) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_iconsIndex = 16;
|
|
|
|
_globals->_autoDialog = false;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_nextRoomIcon = &_gameIcons[_roomIconsBase];
|
2016-10-07 23:06:10 +02:00
|
|
|
displayRoom();
|
2016-12-18 14:13:36 -08:00
|
|
|
_paletteUpdateRequired = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-10-07 23:06:10 +02:00
|
|
|
// Original name: loadsal
|
|
|
|
void EdenGame::loadPlace(int16 num) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (num == _globals->_lastPlaceNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_lastPlaceNum = num;
|
2016-12-18 14:13:36 -08:00
|
|
|
loadRawFile(num + 419, _placeRawBuf);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::specialoutside() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_lastAreaPtr->_type == AreaType::atValley && (_globals->_party & PersonMask::pmLeader))
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_ici(5);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::specialout() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_gameDays - _globals->_eloiDepartureDay > 2) {
|
2016-12-19 22:32:40 -08:00
|
|
|
if (checkEloiReturn())
|
|
|
|
handleEloiReturn();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-10-07 23:06:10 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_phaseNum >= 32 && _globals->_phaseNum < 48) {
|
|
|
|
if (_globals->_newLocation == 9 || _globals->_newLocation == 4 || _globals->_newLocation == 24) {
|
2017-01-15 23:51:17 +01:00
|
|
|
kPersons[PER_ELOI]._roomNum = 263;
|
2016-08-18 13:15:54 +02:00
|
|
|
return;
|
|
|
|
}
|
2016-10-07 23:06:10 +02:00
|
|
|
}
|
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
if ((_globals->_phaseNum == 434) && (_globals->_newLocation == 5)) {
|
2017-01-15 23:51:17 +01:00
|
|
|
removeFromParty(PER_JABBER);
|
|
|
|
kPersons[PER_JABBER]._roomNum = 264;
|
2016-10-07 23:06:10 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_phaseNum < 400) {
|
|
|
|
if ((_globals->_gameFlags & GameFlags::gfFlag4000) && _globals->_prevLocation == 1
|
|
|
|
&& (_globals->_party & PersonMask::pmEloi) && _globals->_curAreaType == AreaType::atValley)
|
2016-12-17 10:13:15 -08:00
|
|
|
handleEloiDeparture();
|
2016-10-07 23:06:10 +02:00
|
|
|
}
|
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_phaseNum == 386) {
|
|
|
|
if (_globals->_prevLocation == 1
|
|
|
|
&& (_globals->_party & PersonMask::pmEloi) && _globals->_areaNum == Areas::arCantura)
|
2016-12-17 10:13:15 -08:00
|
|
|
handleEloiDeparture();
|
2016-10-07 23:06:10 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::specialin() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_party & PersonMask::pmEloi) && (_globals->_partyOutside & PersonMask::pmEloi) && (_globals->_roomNum & 0xFF) == 1) {
|
2017-01-15 23:51:17 +01:00
|
|
|
addToParty(PER_ELOI);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eloiHaveNews = 1;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_roomNum == 288)
|
|
|
|
_globals->_gameFlags |= GameFlags::gfFlag100 | GameFlags::gfFlag2000;
|
|
|
|
if (_globals->_roomNum == 3075 && _globals->_phaseNum == 546) {
|
2016-12-19 22:32:40 -08:00
|
|
|
incPhase();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curItemsMask & 0x2000) { // Morkus' tablet
|
2017-01-14 00:30:37 +01:00
|
|
|
hideBars();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(92);
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[129]._exits[0] = 0;
|
|
|
|
_gameRooms[129]._exits[2] = 1;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomNum = 3074;
|
2017-01-15 23:51:17 +01:00
|
|
|
kPersons[PER_MUNGO]._roomNum = 3074;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eventType = EventType::etEvent5;
|
|
|
|
updateRoom(_globals->_roomNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_narratorSequence = 53;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_roomNum == 1793 && _globals->_phaseNum == 336)
|
2016-12-17 10:13:15 -08:00
|
|
|
handleEloiDeparture();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_roomNum == 259 && _globals->_phaseNum == 129)
|
|
|
|
_globals->_narratorSequence = 12;
|
|
|
|
if (_globals->_roomNum >= 289 && _globals->_roomNum < 359)
|
|
|
|
_globals->_labyrinthDirections = kLabyrinthPath[(_globals->_roomNum & 0xFF) - 33];
|
|
|
|
if (_globals->_roomNum == 305 && _globals->_prevLocation == 103)
|
|
|
|
_globals->_gameFlags &= ~GameFlags::gfFlag2000;
|
|
|
|
if (_globals->_roomNum == 304 && _globals->_prevLocation == 105)
|
|
|
|
_globals->_gameFlags &= ~GameFlags::gfFlag2000;
|
|
|
|
if (_globals->_phaseNum < 226) {
|
|
|
|
if (_globals->_roomNum == 842)
|
|
|
|
_globals->_gameFlags |= GameFlags::gfFlag2;
|
|
|
|
if (_globals->_roomNum == 1072)
|
|
|
|
_globals->_gameFlags |= GameFlags::gfFlag4;
|
|
|
|
if (_globals->_roomNum == 1329)
|
|
|
|
_globals->_gameFlags |= GameFlags::gfFlag8000;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::animpiece() {
|
2017-01-01 11:51:48 -08:00
|
|
|
Room *room = _globals->_roomPtr;
|
|
|
|
if (_globals->_roomVidNum && _globals->_var100 != 0xFF) {
|
|
|
|
if (_globals->_valleyVidNum || !room->_level || (room->_flags & RoomFlags::rfHasCitadel)
|
|
|
|
|| room->_level == _globals->_var100) {
|
2017-01-14 00:30:37 +01:00
|
|
|
hideBars();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_updatePaletteFlag = 16;
|
|
|
|
if (!(_globals->_narratorSequence & 0x80)) //TODO: bug? !() @ 100DC
|
|
|
|
_globals->_mirrorEffect = 0;
|
|
|
|
if (!_needToFade)
|
|
|
|
_needToFade = room->_flags & RoomFlags::rf02;
|
|
|
|
playHNM(_globals->_roomVidNum);
|
2016-08-18 13:15:54 +02:00
|
|
|
return;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varF1 &= ~RoomFlags::rf04;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-17 09:32:43 -08:00
|
|
|
void EdenGame::getdino(Room *room) {
|
2016-09-14 23:39:27 +02:00
|
|
|
assert(tab_2CEF0[4] == 0x25);
|
2016-11-15 09:39:49 +01:00
|
|
|
|
2016-12-15 22:47:29 -08:00
|
|
|
room->_flags &= ~0xC;
|
2016-11-13 22:59:45 -08:00
|
|
|
for (perso_t *perso = &kPersons[PER_UNKN_18C]; perso->_roomNum != 0xFFFF; perso++) {
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_flags & PersonFlags::pf80)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (perso->_roomNum != _globals->_roomNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2016-11-13 22:59:45 -08:00
|
|
|
byte persoType = perso->_flags & PersonFlags::pfTypeMask;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (persoType == PersonFlags::pftVelociraptor)
|
2017-01-01 11:51:48 -08:00
|
|
|
removeInfo(_globals->_citadelAreaNum + ValleyNews::vnVelociraptorsIn);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (persoType == PersonFlags::pftTriceraptor)
|
2017-01-01 11:51:48 -08:00
|
|
|
removeInfo(_globals->_citadelAreaNum + ValleyNews::vnTriceraptorsIn);
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags |= PersonFlags::pf20;
|
2016-11-13 22:59:45 -08:00
|
|
|
int16 *tab = tab_2CF70;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_areaNum != Areas::arUluru && _globals->_areaNum != Areas::arTamara)
|
2016-09-14 23:39:27 +02:00
|
|
|
tab = tab_2CEF0;
|
2016-12-15 22:47:29 -08:00
|
|
|
byte r27 = (room->_flags & 0xC0) >> 2; //TODO: check me (like pc)
|
2016-10-07 00:45:08 +02:00
|
|
|
persoType = perso->_flags & PersonFlags::pfTypeMask;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (persoType == PersonFlags::pftTyrann)
|
|
|
|
persoType = 13;
|
|
|
|
r27 |= (persoType & 7) << 1; //TODO: check me 13 & 7 = ???
|
|
|
|
tab += r27;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomVidNum = *tab++;
|
2016-11-13 22:59:45 -08:00
|
|
|
int16 bank = *tab;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (bank & 0x8000) {
|
|
|
|
bank &= ~0x8000;
|
2016-12-15 22:47:29 -08:00
|
|
|
room->_flags |= RoomFlags::rf08;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-15 22:47:29 -08:00
|
|
|
room->_flags |= RoomFlags::rf04 | RoomFlags::rf02;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomImgBank = bank;
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 13:41:00 -08:00
|
|
|
// Original name: getsalle
|
|
|
|
Room *EdenGame::getRoom(int16 loc) { //TODO: byte?
|
2017-01-01 11:51:48 -08:00
|
|
|
debug("get room for %X, starting from %d, looking for %X", loc, _globals->_areaPtr->_firstRoomIdx, _globals->_partyOutside);
|
|
|
|
Room *room = &_gameRooms[_globals->_areaPtr->_firstRoomIdx];
|
2016-09-14 23:39:27 +02:00
|
|
|
loc &= 0xFF;
|
|
|
|
for (;; room++) {
|
2016-12-15 22:47:29 -08:00
|
|
|
for (; room->_location != loc; room++) {
|
|
|
|
if (room->_id == 0xFF)
|
2016-09-14 23:39:27 +02:00
|
|
|
return 0;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_partyOutside == room->_party || room->_party == 0xFFFF)
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-15 22:47:29 -08:00
|
|
|
debug("found room: party = %X, bank = %X", room->_party, room->_bank);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomImgBank = room->_bank;
|
|
|
|
_globals->_labyrinthRoom = 0;
|
|
|
|
if (_globals->_roomImgBank > 104 && _globals->_roomImgBank <= 112)
|
|
|
|
_globals->_labyrinthRoom = _globals->_roomImgBank - 103;
|
|
|
|
if (_globals->_valleyVidNum)
|
|
|
|
_globals->_roomVidNum = _globals->_valleyVidNum;
|
2016-09-14 23:39:27 +02:00
|
|
|
else
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomVidNum = room->_video;
|
2016-12-15 22:47:29 -08:00
|
|
|
if ((room->_flags & 0xC0) == RoomFlags::rf40 || (room->_flags & RoomFlags::rf01))
|
2016-09-14 23:39:27 +02:00
|
|
|
getdino(room);
|
2016-12-15 22:47:29 -08:00
|
|
|
if (room->_flags & RoomFlags::rfHasCitadel) {
|
2017-01-01 11:51:48 -08:00
|
|
|
removeInfo(_globals->_areaNum + ValleyNews::vnCitadelLost);
|
|
|
|
removeInfo(_globals->_areaNum + ValleyNews::vnTyrannIn);
|
|
|
|
removeInfo(_globals->_areaNum + ValleyNews::vnTyrannLost);
|
|
|
|
removeInfo(_globals->_areaNum + ValleyNews::vnVelociraptorsLost);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if (istyran(_globals->_roomNum))
|
|
|
|
_globals->_gameFlags |= GameFlags::gfFlag10;
|
2016-09-14 23:39:27 +02:00
|
|
|
else
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_gameFlags &= ~GameFlags::gfFlag10;
|
2016-09-14 23:39:27 +02:00
|
|
|
return room;
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-10-07 23:06:10 +02:00
|
|
|
// Original name: initlieu
|
|
|
|
void EdenGame::initPlace(int16 roomNum) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_gameFlags |= GameFlags::gfFlag4000;
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[18]._cursorId |= 0x8000;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_lastAreaPtr = _globals->_areaPtr;
|
|
|
|
_globals->_areaPtr = &kAreasTable[((roomNum >> 8) & 0xFF) - 1];
|
|
|
|
Area *area = _globals->_areaPtr;
|
2016-12-15 22:47:29 -08:00
|
|
|
area->_visitCount++;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_areaVisitCount = area->_visitCount;
|
|
|
|
_globals->_curAreaFlags = area->_flags;
|
|
|
|
_globals->_curAreaType = area->_type;
|
|
|
|
_globals->_curCitadelLevel = area->_citadelLevel;
|
|
|
|
if (_globals->_curAreaType == AreaType::atValley)
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[18]._cursorId &= ~0x8000;
|
2016-12-15 22:47:29 -08:00
|
|
|
loadPlace(area->_placeNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::maj2() {
|
2016-10-07 23:06:10 +02:00
|
|
|
displayPlace();
|
2017-01-01 14:14:02 -08:00
|
|
|
assert(_vm->_screenView->_pitch == 320);
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_roomNum == 273 && _globals->_prevLocation == 18)
|
|
|
|
_globals->_mirrorEffect = 1;
|
|
|
|
if (_globals->_eventType == EventType::etEventC) {
|
2016-09-25 23:17:25 +02:00
|
|
|
drawTopScreen();
|
|
|
|
showObjects();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
FRDevents();
|
2017-01-01 14:14:02 -08:00
|
|
|
assert(_vm->_screenView->_pitch == 320);
|
2016-11-13 22:59:45 -08:00
|
|
|
bool r30 = false;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curAreaType == AreaType::atValley && !(_globals->_displayFlags & DisplayFlags::dfPanable))
|
2016-11-13 22:59:45 -08:00
|
|
|
r30 = true;
|
|
|
|
//TODO: ^^ inlined func?
|
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_mirrorEffect || _globals->_var103)
|
2016-12-26 13:40:28 -08:00
|
|
|
display();
|
2017-01-01 11:51:48 -08:00
|
|
|
else if (_globals->_varF1 == (RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01)) {
|
2016-09-28 07:29:12 +02:00
|
|
|
drawBlackBars();
|
2016-12-31 05:11:33 -08:00
|
|
|
displayEffect1();
|
2017-01-01 11:51:48 -08:00
|
|
|
} else if (_globals->_varF1 && !(_globals->_varF1 & RoomFlags::rf04) && !r30) {
|
|
|
|
if (!(_globals->_displayFlags & DisplayFlags::dfPanable))
|
2016-09-28 07:29:12 +02:00
|
|
|
drawBlackBars();
|
2017-01-01 11:51:48 -08:00
|
|
|
else if (_globals->_valleyVidNum)
|
2016-09-28 07:29:12 +02:00
|
|
|
drawBlackBars();
|
2016-12-31 05:11:33 -08:00
|
|
|
displayEffect1();
|
2017-01-01 11:51:48 -08:00
|
|
|
} else if (r30 && !(_globals->_varF1 & RoomFlags::rf04))
|
2016-09-14 23:39:27 +02:00
|
|
|
effetpix();
|
|
|
|
else
|
|
|
|
afficher128();
|
|
|
|
musique();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_eventType != EventType::etEventC) {
|
2016-09-25 23:17:25 +02:00
|
|
|
drawTopScreen();
|
|
|
|
showObjects();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-09-28 07:29:12 +02:00
|
|
|
showBars();
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_labyrinthDirections = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
specialin();
|
|
|
|
}
|
|
|
|
|
2016-12-19 13:41:00 -08:00
|
|
|
// Original name: majsalle1
|
|
|
|
void EdenGame::updateRoom1(int16 roomNum) {
|
|
|
|
Room *room = getRoom(roomNum & 0xFF);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomPtr = room;
|
|
|
|
debug("DrawRoom: room 0x%X, arg = 0x%X", _globals->_roomNum, roomNum);
|
|
|
|
_globals->_curRoomFlags = room->_flags;
|
|
|
|
_globals->_varF1 = room->_flags;
|
2016-09-14 23:39:27 +02:00
|
|
|
animpiece();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var100 = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
maj2();
|
|
|
|
}
|
|
|
|
|
2016-12-19 13:41:00 -08:00
|
|
|
// Original name: maj_salle
|
|
|
|
void EdenGame::updateRoom(uint16 roomNum) {
|
2016-12-31 05:11:33 -08:00
|
|
|
setCharacterHere();
|
2016-12-19 13:41:00 -08:00
|
|
|
updateRoom1(roomNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-28 07:29:12 +02:00
|
|
|
// Original name: initbuf
|
|
|
|
void EdenGame::allocateBuffers() {
|
2017-01-01 11:51:48 -08:00
|
|
|
#define ALLOC(ptr, size, typ) if (!((ptr) = (typ*)malloc(size))) _bufferAllocationErrorFl = true;
|
2016-12-18 14:13:36 -08:00
|
|
|
ALLOC(_gameRooms, 0x4000, Room);
|
2016-12-17 09:32:43 -08:00
|
|
|
ALLOC(_gameIcons, 0x4000, Icon);
|
2016-12-18 14:13:36 -08:00
|
|
|
ALLOC(_bankDataBuf, 0x10000, byte);
|
2017-01-01 11:51:48 -08:00
|
|
|
ALLOC(_globals, sizeof(*_globals), global_t);
|
2016-12-18 14:13:36 -08:00
|
|
|
ALLOC(_placeRawBuf, 2048, byte);
|
2016-12-28 03:43:13 -08:00
|
|
|
ALLOC(_gameConditions, 0x4800, byte);
|
|
|
|
ALLOC(_gameDialogs, 0x2800, byte);
|
2017-01-01 11:51:48 -08:00
|
|
|
ALLOC(_gamePhrases, 0x10000, byte);
|
2016-12-04 14:54:58 -08:00
|
|
|
ALLOC(_mainBankBuf, 0x9400, byte);
|
2016-12-18 14:13:36 -08:00
|
|
|
ALLOC(_glowBuffer, 0x2800, byte);
|
|
|
|
ALLOC(_gameFont, 0x900, byte);
|
2017-01-01 11:51:48 -08:00
|
|
|
ALLOC(_gameLipsync, 0x205C, byte);
|
2016-12-04 14:54:58 -08:00
|
|
|
ALLOC(_musicBuf, 0x140000, byte);
|
2016-09-14 23:39:27 +02:00
|
|
|
#undef ALLOC
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::freebuf() {
|
2017-01-01 11:51:48 -08:00
|
|
|
delete(_bigfileHeader);
|
|
|
|
_bigfileHeader = nullptr;
|
2016-12-06 23:08:32 -08:00
|
|
|
|
2016-12-18 14:13:36 -08:00
|
|
|
free(_gameRooms);
|
2016-12-04 14:26:44 -08:00
|
|
|
free(_gameIcons);
|
2016-12-18 14:13:36 -08:00
|
|
|
free(_bankDataBuf);
|
2017-01-01 11:51:48 -08:00
|
|
|
free(_globals);
|
2016-12-18 14:13:36 -08:00
|
|
|
free(_placeRawBuf);
|
2016-12-28 03:43:13 -08:00
|
|
|
free(_gameConditions);
|
|
|
|
free(_gameDialogs);
|
2017-01-01 11:51:48 -08:00
|
|
|
free(_gamePhrases);
|
2016-12-04 14:54:58 -08:00
|
|
|
free(_mainBankBuf);
|
2016-12-18 14:13:36 -08:00
|
|
|
free(_glowBuffer);
|
|
|
|
free(_gameFont);
|
2017-01-01 11:51:48 -08:00
|
|
|
free(_gameLipsync);
|
2016-12-04 14:54:58 -08:00
|
|
|
free(_musicBuf);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 13:41:00 -08:00
|
|
|
void EdenGame::openWindow() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_underBarsView = new View(_vm, 320, 40);
|
|
|
|
_underBarsView->_normal._width = 320;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
_view2 = new View(_vm, 32, 32);
|
|
|
|
_view2Buf = _view2->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-12-29 06:28:11 -08:00
|
|
|
_subtitlesView = new View(_vm, _subtitlesXWidth, 60);
|
|
|
|
_subtitlesViewBuf = _subtitlesView->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
_underSubtitlesView = new View(_vm, _subtitlesXWidth, 60);
|
|
|
|
_underSubtitlesViewBuf = _underSubtitlesView->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-12-18 14:13:36 -08:00
|
|
|
_mainView = new View(_vm, 640, 200);
|
|
|
|
_mainView->_normal._width = 320;
|
|
|
|
CLBlitter_FillView(_mainView, 0xFFFFFFFF);
|
|
|
|
_mainView->setSrcZoomValues(0, 0);
|
|
|
|
_mainView->setDisplayZoomValues(640, 400);
|
2017-01-01 14:14:02 -08:00
|
|
|
_mainView->centerIn(_vm->_screenView);
|
2016-12-29 06:28:11 -08:00
|
|
|
_mainViewBuf = _mainView->_bufferPtr;
|
2016-12-18 14:13:36 -08:00
|
|
|
|
|
|
|
_mouseCenterX = _mainView->_normal._dstLeft + _mainView->_normal._width / 2;
|
|
|
|
_mouseCenterY = _mainView->_normal._dstTop + _mainView->_normal._height / 2;
|
2017-01-01 14:14:02 -08:00
|
|
|
_vm->setMousePosition(_mouseCenterX, _mouseCenterY);
|
|
|
|
_vm->hideMouse();
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-12-18 13:09:56 -08:00
|
|
|
_cursorPosX = 320 / 2;
|
|
|
|
_cursorPosY = 200 / 2;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::EmergencyExit() {
|
|
|
|
SysBeep(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::run() {
|
2016-12-19 13:41:00 -08:00
|
|
|
_invIconsCount = (_vm->getPlatform() == Common::kPlatformMacintosh) ? 9 : 11;
|
2016-12-19 22:32:40 -08:00
|
|
|
_roomIconsBase = _invIconsBase + _invIconsCount;
|
2016-10-17 03:05:37 +03:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
word_378CE = 0;
|
|
|
|
CRYOLib_ManagersInit();
|
2016-11-27 12:47:04 -08:00
|
|
|
_vm->_video->setupSound(5, 0x2000, 8, 11025 * 65536.0 , 0);
|
|
|
|
_vm->_video->setForceZero2Black(true);
|
|
|
|
_vm->_video->setupTimer(12.5);
|
2017-01-03 16:26:15 -08:00
|
|
|
_voiceSound = new Sound(0, 11025 * 65536.0, 8, 0);
|
2016-11-27 12:47:04 -08:00
|
|
|
_hnmSoundChannel = _vm->_video->getSoundChannel();
|
2017-01-03 16:24:12 -08:00
|
|
|
_voiceSound->setWantsDesigned(1); // CHECKME: Used?
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-11-09 13:40:08 -08:00
|
|
|
_musicChannel = new CSoundChannel(_vm->_mixer, 11025, false);
|
|
|
|
_voiceChannel = new CSoundChannel(_vm->_mixer, 11025, false);
|
2016-10-22 14:15:45 +03:00
|
|
|
|
2016-09-28 07:29:12 +02:00
|
|
|
allocateBuffers();
|
2016-09-14 23:39:27 +02:00
|
|
|
openbigfile();
|
2016-12-19 13:41:00 -08:00
|
|
|
openWindow();
|
2016-09-14 23:39:27 +02:00
|
|
|
loadpermfiles();
|
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!_bufferAllocationErrorFl) {
|
2016-09-14 23:39:27 +02:00
|
|
|
LostEdenMac_InitPrefs();
|
2016-11-09 13:40:08 -08:00
|
|
|
if (_vm->getPlatform() == Common::kPlatformMacintosh)
|
2016-10-25 23:32:15 +02:00
|
|
|
initCubeMac();
|
2016-10-17 03:05:37 +03:00
|
|
|
else
|
2016-10-25 23:32:15 +02:00
|
|
|
initCubePC();
|
|
|
|
|
2016-12-18 14:13:36 -08:00
|
|
|
_mainView->_doubled = _doubledScreen;
|
|
|
|
while (!_quitFlag2) {
|
2016-12-31 05:11:33 -08:00
|
|
|
initGlobals();
|
2016-12-18 14:13:36 -08:00
|
|
|
_quitFlag3 = false;
|
2016-12-18 13:09:56 -08:00
|
|
|
_normalCursor = true;
|
|
|
|
_torchCursor = false;
|
2016-09-30 07:48:27 +02:00
|
|
|
_cursKeepPos = Common::Point(-1, -1);
|
2016-11-13 13:56:20 -08:00
|
|
|
if (!_gameLoaded)
|
2016-09-14 23:39:27 +02:00
|
|
|
intro();
|
|
|
|
edmain();
|
|
|
|
startmusique(1);
|
2016-09-28 07:29:12 +02:00
|
|
|
drawBlackBars();
|
2016-12-26 13:40:28 -08:00
|
|
|
display();
|
2016-12-17 10:13:15 -08:00
|
|
|
fadeToBlack(3);
|
2016-12-31 05:11:33 -08:00
|
|
|
clearScreen();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(95);
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_endGameFlag == 50) {
|
2016-09-14 23:39:27 +02:00
|
|
|
loadrestart();
|
2016-11-13 13:56:20 -08:00
|
|
|
_gameLoaded = false;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
fademusica0(2);
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel->stop();
|
2016-12-18 14:13:36 -08:00
|
|
|
_musicPlayingFlag = false;
|
|
|
|
_musicEnabledFlag = false;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
// LostEdenMac_SavePrefs();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-28 07:29:12 +02:00
|
|
|
|
2016-10-22 14:15:45 +03:00
|
|
|
delete _voiceChannel;
|
|
|
|
delete _musicChannel;
|
|
|
|
|
2016-12-17 10:13:15 -08:00
|
|
|
fadeToBlack(4);
|
2016-09-14 23:39:27 +02:00
|
|
|
closebigfile();
|
|
|
|
freebuf();
|
|
|
|
CRYOLib_ManagersDone();
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
void EdenGame::edmain() {
|
|
|
|
//TODO
|
2016-12-31 05:11:33 -08:00
|
|
|
enterGame();
|
2017-01-01 11:51:48 -08:00
|
|
|
while (!_bufferAllocationErrorFl && !_quitFlag3 && _globals->_endGameFlag != 50) {
|
2016-12-18 13:09:56 -08:00
|
|
|
if (!_gameStarted) {
|
2016-09-14 23:39:27 +02:00
|
|
|
// if in demo mode, reset game after a while
|
2016-12-18 14:13:36 -08:00
|
|
|
_demoCurrentTicks = _vm->_timerTicks;
|
|
|
|
if (_demoCurrentTicks - _demoStartTicks > 3000) {
|
2016-09-14 23:39:27 +02:00
|
|
|
rundcurs();
|
2016-12-26 13:40:28 -08:00
|
|
|
display();
|
2016-09-14 23:39:27 +02:00
|
|
|
fademusica0(2);
|
2016-12-17 10:13:15 -08:00
|
|
|
fadeToBlack(3);
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_FillScreenView(0);
|
2016-12-18 14:13:36 -08:00
|
|
|
CLBlitter_FillView(_mainView, 0);
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel->stop();
|
2016-12-18 14:13:36 -08:00
|
|
|
_musicPlayingFlag = false;
|
|
|
|
_musicEnabledFlag = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
intro();
|
2016-12-31 05:11:33 -08:00
|
|
|
enterGame();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
rundcurs();
|
|
|
|
musicspy();
|
|
|
|
FRDevents();
|
2017-01-14 00:30:37 +01:00
|
|
|
handleNarrator();
|
2017-01-15 22:59:50 +01:00
|
|
|
chronoEvent();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_drawFlags & DrawFlags::drDrawInventory)
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_drawFlags & DrawFlags::drDrawTopScreen)
|
2016-09-25 23:17:25 +02:00
|
|
|
drawTopScreen();
|
2017-01-01 11:51:48 -08:00
|
|
|
if ((_globals->_displayFlags & DisplayFlags::dfPanable) && (_globals->_displayFlags != DisplayFlags::dfPerson))
|
2016-12-31 05:11:33 -08:00
|
|
|
scrollPanel();
|
2017-01-01 11:51:48 -08:00
|
|
|
if ((_globals->_displayFlags & DisplayFlags::dfMirror) && (_globals->_displayFlags != DisplayFlags::dfPerson))
|
2016-09-25 23:17:25 +02:00
|
|
|
scrollMirror();
|
2017-01-01 11:51:48 -08:00
|
|
|
if ((_globals->_displayFlags & DisplayFlags::dfFrescoes) && (_globals->_displayFlags != DisplayFlags::dfPerson))
|
2016-09-25 23:17:25 +02:00
|
|
|
scrollFrescoes();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags & DisplayFlags::dfFlag2)
|
2016-09-25 23:17:25 +02:00
|
|
|
noclicpanel();
|
2016-12-25 02:17:07 -08:00
|
|
|
if (_animationActive)
|
2017-01-15 22:59:50 +01:00
|
|
|
animCharacter();
|
2016-12-28 03:43:13 -08:00
|
|
|
updateCursor();
|
2016-12-26 13:40:28 -08:00
|
|
|
display();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::intro() {
|
2016-11-09 13:40:08 -08:00
|
|
|
if (_vm->getPlatform() == Common::kPlatformMacintosh) {
|
2016-10-10 01:26:23 +03:00
|
|
|
// Play intro videos in HQ
|
2017-01-02 14:49:49 -08:00
|
|
|
_hnmSoundChannel->stop();
|
2016-11-27 12:47:04 -08:00
|
|
|
_vm->_video->closeSound();
|
|
|
|
_vm->_video->setupSound(5, 0x2000, 16, 22050 * 65536.0, 0);
|
|
|
|
_hnmSoundChannel = _vm->_video->getSoundChannel();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(2012);
|
2016-10-10 01:26:23 +03:00
|
|
|
playHNM(171);
|
|
|
|
CLBlitter_FillScreenView(0);
|
2016-12-18 14:13:36 -08:00
|
|
|
_specialTextMode = false;
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(2001);
|
2017-01-02 14:49:49 -08:00
|
|
|
_hnmSoundChannel->stop();
|
2016-11-27 12:47:04 -08:00
|
|
|
_vm->_video->closeSound();
|
|
|
|
_vm->_video->setupSound(5, 0x2000, 8, 11025 * 65536.0, 0);
|
|
|
|
_hnmSoundChannel = _vm->_video->getSoundChannel();
|
2016-10-10 01:26:23 +03:00
|
|
|
} else {
|
|
|
|
playHNM(98); // Cryo logo
|
|
|
|
playHNM(171); // Virgin logo
|
|
|
|
CLBlitter_FillScreenView(0);
|
2016-12-18 14:13:36 -08:00
|
|
|
_specialTextMode = false;
|
2016-10-10 01:26:23 +03:00
|
|
|
playHNM(170); // Intro video
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-31 05:11:33 -08:00
|
|
|
void EdenGame::enterGame() {
|
2016-09-14 23:39:27 +02:00
|
|
|
char flag = 0;
|
2016-12-18 14:13:36 -08:00
|
|
|
_currentTime = _vm->_timerTicks / 100;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_gameTime = _currentTime;
|
2016-12-18 14:13:36 -08:00
|
|
|
_demoStartTicks = _vm->_timerTicks;
|
2016-12-18 13:09:56 -08:00
|
|
|
_gameStarted = false;
|
2016-11-13 13:56:20 -08:00
|
|
|
if (!_gameLoaded) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomNum = 279;
|
|
|
|
_globals->_areaNum = Areas::arMo;
|
|
|
|
_globals->_var100 = 0xFF;
|
|
|
|
initPlace(_globals->_roomNum);
|
|
|
|
_globals->_currMusicNum = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
startmusique(1);
|
|
|
|
} else {
|
2017-01-01 11:51:48 -08:00
|
|
|
flag = _globals->_autoDialog; //TODO
|
2016-09-14 23:39:27 +02:00
|
|
|
initafterload();
|
2017-01-01 11:51:48 -08:00
|
|
|
byte lastMusicNum = _globals->_currMusicNum; //TODO: ???
|
|
|
|
_globals->_currMusicNum = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
startmusique(lastMusicNum);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_inventoryScrollPos = 0;
|
2016-12-18 13:09:56 -08:00
|
|
|
_gameStarted = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
|
|
|
drawTopScreen();
|
2016-09-27 07:53:50 +02:00
|
|
|
saveFriezes();
|
2016-12-18 14:13:36 -08:00
|
|
|
_showBlackBars = true;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_mirrorEffect = 1;
|
|
|
|
updateRoom(_globals->_roomNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (flag) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_iconsIndex = 4;
|
|
|
|
_globals->_autoDialog = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
parle_moi();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-10-08 21:21:21 +02:00
|
|
|
void EdenGame::signon(const char *s) {
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::FRDevents() {
|
2017-01-01 14:14:02 -08:00
|
|
|
_vm->pollEvents();
|
2016-11-13 13:56:20 -08:00
|
|
|
if (_allowDoubled) {
|
2017-01-01 14:14:02 -08:00
|
|
|
#if 0 // CLKeyboard_IsScanCodeDown currently always returns false
|
|
|
|
if (_vm->isScanCodeDown(0x30)) { //TODO: const
|
2016-12-18 14:13:36 -08:00
|
|
|
if (!_keyboardHeld) {
|
2016-09-30 07:48:27 +02:00
|
|
|
_doubledScreen = !_doubledScreen;
|
2016-12-18 14:13:36 -08:00
|
|
|
_mainView->_doubled = _doubledScreen;
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_FillScreenView(0);
|
2016-12-18 14:13:36 -08:00
|
|
|
_keyboardHeld = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
} else
|
2017-01-01 14:14:02 -08:00
|
|
|
#endif
|
|
|
|
_keyboardHeld = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-19 13:41:00 -08:00
|
|
|
|
|
|
|
int16 mouseY;
|
|
|
|
int16 mouseX;
|
2017-01-01 14:14:02 -08:00
|
|
|
_vm->getMousePosition(&mouseX, &mouseY);
|
2016-12-18 14:13:36 -08:00
|
|
|
mouseX -= _mouseCenterX;
|
|
|
|
mouseY -= _mouseCenterY;
|
2017-01-01 14:14:02 -08:00
|
|
|
_vm->setMousePosition(_mouseCenterX , _mouseCenterY);
|
2016-12-18 13:09:56 -08:00
|
|
|
_cursorPosX += mouseX;
|
2016-12-18 22:58:31 -08:00
|
|
|
_cursorPosX = CLIP<int16>(_cursorPosX, 4, 292);
|
2016-12-18 13:09:56 -08:00
|
|
|
_cursorPosY += mouseY;
|
2016-11-14 14:51:52 -08:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
int16 maxY = _globals->_displayFlags == DisplayFlags::dfFlag2 ? 190 : 170;
|
2016-12-18 22:58:31 -08:00
|
|
|
_cursorPosY = CLIP<int16>(_cursorPosY, 4, maxY);
|
2016-12-18 13:09:56 -08:00
|
|
|
_cirsorPanX = _cursorPosX;
|
2016-12-18 22:58:31 -08:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_cursorPosY >= 10 && _cursorPosY <= 164 && !(_globals->_displayFlags & DisplayFlags::dfFrescoes))
|
2016-12-18 13:09:56 -08:00
|
|
|
_cirsorPanX += _scrollPos;
|
|
|
|
if (_normalCursor) {
|
2016-11-13 13:56:20 -08:00
|
|
|
_currCursor = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
_currSpot = scan_icon_list(_cirsorPanX + _cursCenter, _cursorPosY + _cursCenter, _globals->_iconsIndex);
|
2016-12-18 13:09:56 -08:00
|
|
|
if (_currSpot)
|
|
|
|
_currCursor = _currSpot->_cursorId;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-11-13 13:56:20 -08:00
|
|
|
if (_cursCenter == 0 && _currCursor != 53) {
|
|
|
|
_cursCenter = 11;
|
2016-12-18 13:09:56 -08:00
|
|
|
_cursorPosX -= 11;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-11-13 13:56:20 -08:00
|
|
|
if (_cursCenter == 11 && _currCursor == 53) {
|
|
|
|
_cursCenter = 0;
|
2016-12-18 13:09:56 -08:00
|
|
|
_cursorPosX += 11;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags & DisplayFlags::dfPanable) {
|
2016-12-19 13:41:00 -08:00
|
|
|
//TODO: _currSpot may be zero (due to scan_icon_list failure) if cursor slips between hot areas.
|
2016-09-14 23:39:27 +02:00
|
|
|
//fix me here or above?
|
2016-12-18 13:09:56 -08:00
|
|
|
if (_currSpot) { // ok, plug it here
|
2016-12-19 22:32:40 -08:00
|
|
|
_curSpot2 = _currSpot;
|
|
|
|
displayAdamMapMark(_curSpot2->_actionId - 14);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags == DisplayFlags::dfFlag2 && _currSpot)
|
2016-12-19 22:32:40 -08:00
|
|
|
_curSpot2 = _currSpot;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags & DisplayFlags::dfFrescoes) {
|
2016-09-30 07:48:27 +02:00
|
|
|
if (_frescoTalk)
|
2016-12-26 13:40:28 -08:00
|
|
|
restoreUnderSubtitles();
|
2016-12-18 13:09:56 -08:00
|
|
|
if (_currCursor == 9 && !_torchCursor) {
|
2016-09-14 23:39:27 +02:00
|
|
|
rundcurs();
|
2016-12-18 13:09:56 -08:00
|
|
|
_torchCursor = true;
|
2016-12-18 22:58:31 -08:00
|
|
|
_glowX = -1;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-18 13:09:56 -08:00
|
|
|
if (_currCursor != 9 && _torchCursor) {
|
2016-09-14 23:39:27 +02:00
|
|
|
unglow();
|
2016-12-18 13:09:56 -08:00
|
|
|
_torchCursor = false;
|
|
|
|
_cursorSaved = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
2017-01-01 14:14:02 -08:00
|
|
|
if (_vm->isMouseButtonDown()) {
|
2016-12-18 13:09:56 -08:00
|
|
|
if (!_mouseHeld) {
|
|
|
|
_mouseHeld = true;
|
|
|
|
_gameStarted = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
mouse();
|
|
|
|
}
|
|
|
|
} else
|
2016-12-18 13:09:56 -08:00
|
|
|
_mouseHeld = false;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags != DisplayFlags::dfFlag2) {
|
2016-09-30 07:48:27 +02:00
|
|
|
if (--_inventoryScrollDelay <= 0) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_objCount > _invIconsCount && _cursorPosY > 164) {
|
|
|
|
if (_cursorPosX > 284 && _globals->_inventoryScrollPos + _invIconsCount < _globals->_objCount) {
|
|
|
|
_globals->_inventoryScrollPos++;
|
2016-09-30 07:48:27 +02:00
|
|
|
_inventoryScrollDelay = 20;
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-10-25 23:32:15 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_cursorPosX < 30 && _globals->_inventoryScrollPos != 0) {
|
|
|
|
_globals->_inventoryScrollPos--;
|
2016-09-30 07:48:27 +02:00
|
|
|
_inventoryScrollDelay = 20;
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-09-30 07:48:27 +02:00
|
|
|
if (_inventoryScrollDelay < 0)
|
|
|
|
_inventoryScrollDelay = 0;
|
2017-01-01 14:14:02 -08:00
|
|
|
|
|
|
|
if (_vm->shouldQuit())
|
|
|
|
edenShudown();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-12-17 09:32:43 -08:00
|
|
|
Icon *EdenGame::scan_icon_list(int16 x, int16 y, int16 index) {
|
|
|
|
for (Icon *icon = &_gameIcons[index]; icon->sx >= 0; icon++) {
|
2016-12-03 15:40:53 -08:00
|
|
|
if (icon->_cursorId & 0x8000)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
|
|
|
#if 0
|
|
|
|
// MAC version use this check. Same check is present in PC version, but never used
|
|
|
|
// Because of x >= clause two adjacent rooms has 1-pixel wide dead zone between them
|
|
|
|
// On valley view screens if cursor slips in this zone a crash in FRDevents occurs
|
|
|
|
// due to lack of proper checks
|
|
|
|
if (x < icon->ff_0 || x >= icon->ff_4
|
|
|
|
|| y < icon->ff_2 || y >= icon->ff_6)
|
|
|
|
#else
|
|
|
|
// PC version has this check inlined in FRDevents
|
|
|
|
// Should we keep it or fix edge coordinates in afroom() instead?
|
|
|
|
if (x < icon->sx || x > icon->ex
|
|
|
|
|| y < icon->sy || y > icon->ey)
|
|
|
|
#endif
|
|
|
|
continue;
|
|
|
|
return icon;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-11-13 13:56:20 -08:00
|
|
|
return nullptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
void EdenGame::updateCursor() {
|
2016-11-13 13:56:20 -08:00
|
|
|
if (++_torchTick > 3)
|
|
|
|
_torchTick = 0;
|
|
|
|
if (!_torchTick) {
|
|
|
|
_torchCurIndex++;
|
|
|
|
_glowIndex++;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-11-13 13:56:20 -08:00
|
|
|
if (_torchCurIndex > 8)
|
|
|
|
_torchCurIndex = 0;
|
|
|
|
if (_glowIndex > 4)
|
|
|
|
_glowIndex = 0;
|
2016-10-24 22:02:43 +02:00
|
|
|
|
2016-12-18 13:09:56 -08:00
|
|
|
if (!_torchCursor) {
|
2016-12-25 02:17:07 -08:00
|
|
|
useMainBank();
|
2016-12-18 13:09:56 -08:00
|
|
|
sundcurs(_cursorPosX + _scrollPos, _cursorPosY);
|
2016-11-13 13:56:20 -08:00
|
|
|
if (_currCursor != 53 && _currCursor < 10) { //TODO: cond
|
2016-11-09 13:40:08 -08:00
|
|
|
if (_vm->getPlatform() == Common::kPlatformMacintosh)
|
2016-12-25 13:45:47 -08:00
|
|
|
engineMac();
|
2016-10-17 03:05:37 +03:00
|
|
|
else
|
2016-12-25 13:45:47 -08:00
|
|
|
enginePC();
|
2016-10-17 03:05:37 +03:00
|
|
|
} else
|
2016-12-18 13:09:56 -08:00
|
|
|
noclipax(_currCursor, _cursorPosX + _scrollPos, _cursorPosY);
|
2016-12-18 22:58:31 -08:00
|
|
|
_glowX = 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(117);
|
2016-12-18 13:09:56 -08:00
|
|
|
if (_cursorPosX > 294)
|
|
|
|
_cursorPosX = 294;
|
2016-09-14 23:39:27 +02:00
|
|
|
unglow();
|
2016-11-13 13:56:20 -08:00
|
|
|
glow(_glowIndex);
|
2016-12-18 13:09:56 -08:00
|
|
|
noclipax(_torchCurIndex, _cursorPosX + _scrollPos, _cursorPosY);
|
2016-09-30 07:48:27 +02:00
|
|
|
if (_frescoTalk)
|
2016-12-25 02:17:07 -08:00
|
|
|
displaySubtitles();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::mouse() {
|
|
|
|
static void (EdenGame::*mouse_actions[])() = {
|
2016-12-25 23:14:03 -08:00
|
|
|
&EdenGame::actionMoveNorth,
|
|
|
|
&EdenGame::actionMoveEast,
|
|
|
|
&EdenGame::actionMoveSouth,
|
|
|
|
&EdenGame::actionMoveWest,
|
|
|
|
&EdenGame::actionPlateMonk,
|
|
|
|
&EdenGame::actionGraaFrescoe,
|
|
|
|
&EdenGame::actionPushStone,
|
2016-12-26 12:35:21 -08:00
|
|
|
&EdenGame::actionSkelettonHead,
|
2016-12-25 23:14:03 -08:00
|
|
|
&EdenGame::actionMummyHead,
|
|
|
|
&EdenGame::actionMoveNorth,
|
|
|
|
&EdenGame::actionKingDialog1,
|
|
|
|
&EdenGame::actionKingDialog2,
|
|
|
|
&EdenGame::actionKingDialog3,
|
|
|
|
&EdenGame::actionGotoHall,
|
|
|
|
&EdenGame::actionLabyrinthTurnAround,
|
2016-12-26 12:35:21 -08:00
|
|
|
&EdenGame::actionSkelettonMoorkong,
|
|
|
|
&EdenGame::actionGotoFullNest,
|
2016-12-25 23:14:03 -08:00
|
|
|
&EdenGame::actionLookLake,
|
|
|
|
&EdenGame::actionNop,
|
|
|
|
&EdenGame::actionNop,
|
|
|
|
&EdenGame::actionNop,
|
2016-12-26 12:35:21 -08:00
|
|
|
&EdenGame::actionFinal,
|
2016-12-25 23:14:03 -08:00
|
|
|
&EdenGame::actionMoveNorth,
|
|
|
|
&EdenGame::actionMoveSouth,
|
2016-12-26 12:35:21 -08:00
|
|
|
&EdenGame::actionVisit,
|
2017-01-16 22:27:25 +01:00
|
|
|
&EdenGame::actionDinoBlow,
|
2016-12-25 23:14:03 -08:00
|
|
|
&EdenGame::actionLascFrescoe,
|
|
|
|
&EdenGame::actionNop,
|
|
|
|
&EdenGame::actionNop,
|
|
|
|
&EdenGame::actionNop,
|
2016-12-26 12:35:21 -08:00
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
2016-09-14 23:39:27 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2016-12-26 12:35:21 -08:00
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
2016-09-14 23:39:27 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2016-12-26 12:35:21 -08:00
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
2016-09-14 23:39:27 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2016-12-26 12:35:21 -08:00
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
|
|
|
&EdenGame::actionGotoVal,
|
2016-09-14 23:39:27 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2016-12-25 23:14:03 -08:00
|
|
|
&EdenGame::actionNop,
|
|
|
|
&EdenGame::actionNop,
|
|
|
|
&EdenGame::actionNop,
|
|
|
|
&EdenGame::actionNop,
|
|
|
|
&EdenGame::actionNop,
|
2016-12-26 12:35:21 -08:00
|
|
|
&EdenGame::actionGetPrism,
|
2016-12-25 23:14:03 -08:00
|
|
|
&EdenGame::actionNop,
|
|
|
|
&EdenGame::actionNop,
|
2016-12-26 12:35:21 -08:00
|
|
|
&EdenGame::actionGetEgg,
|
2016-12-25 23:14:03 -08:00
|
|
|
&EdenGame::actionNop,
|
|
|
|
&EdenGame::actionNop,
|
2016-12-26 12:35:21 -08:00
|
|
|
&EdenGame::actionGetMushroom,
|
|
|
|
&EdenGame::actionGetBadMushroom,
|
|
|
|
&EdenGame::actionGetKnife,
|
|
|
|
&EdenGame::actionGetEmptyNest,
|
|
|
|
&EdenGame::actionGetFullNest,
|
|
|
|
&EdenGame::actionGetGold,
|
2016-09-14 23:39:27 +02:00
|
|
|
nullptr,
|
2016-12-25 23:14:03 -08:00
|
|
|
&EdenGame::actionNop,
|
2016-12-26 12:35:21 -08:00
|
|
|
&EdenGame::actionGetSunStone,
|
|
|
|
&EdenGame::actionGetHorn,
|
2016-12-25 23:14:03 -08:00
|
|
|
&EdenGame::actionNop,
|
|
|
|
&EdenGame::actionNop,
|
|
|
|
&EdenGame::actionNop,
|
|
|
|
&EdenGame::actionNop,
|
|
|
|
&EdenGame::actionNop,
|
|
|
|
&EdenGame::actionNop,
|
|
|
|
&EdenGame::actionNop,
|
2016-09-14 23:39:27 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2016-12-26 12:35:21 -08:00
|
|
|
&EdenGame::actionGetTablet,
|
2016-12-28 03:43:13 -08:00
|
|
|
&EdenGame::actionClickValleyPlan,
|
2016-12-26 12:35:21 -08:00
|
|
|
&EdenGame::actionEndFrescoes,
|
|
|
|
&EdenGame::actionChoose,
|
2016-09-14 23:39:27 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2016-12-28 03:43:13 -08:00
|
|
|
&EdenGame::actionKing,
|
|
|
|
&EdenGame::actionDina,
|
|
|
|
&EdenGame::actionThoo,
|
|
|
|
&EdenGame::actionMonk,
|
|
|
|
&EdenGame::actionTormentor,
|
|
|
|
&EdenGame::actionMessenger,
|
|
|
|
&EdenGame::actionMango,
|
|
|
|
&EdenGame::actionEve,
|
|
|
|
&EdenGame::actionAzia,
|
|
|
|
&EdenGame::actionMammi,
|
|
|
|
&EdenGame::actionGuards,
|
|
|
|
&EdenGame::actionFisher,
|
|
|
|
&EdenGame::actionDino,
|
|
|
|
&EdenGame::actionTyran,
|
|
|
|
&EdenGame::actionMorkus,
|
2016-12-25 23:14:03 -08:00
|
|
|
&EdenGame::actionNop,
|
2016-09-14 23:39:27 +02:00
|
|
|
&EdenGame::parle_moi,
|
2016-12-28 03:43:13 -08:00
|
|
|
&EdenGame::actionAdam,
|
|
|
|
&EdenGame::actionTakeObject,
|
2016-12-04 13:15:38 -08:00
|
|
|
&EdenGame::putObject,
|
2016-09-14 23:39:27 +02:00
|
|
|
&EdenGame::clictimbre,
|
2016-12-19 13:41:00 -08:00
|
|
|
&EdenGame::handleDinaDialog,
|
2016-12-28 03:43:13 -08:00
|
|
|
&EdenGame::closeCharacterScreen,
|
2016-09-14 23:39:27 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
&EdenGame::generique,
|
2016-12-19 22:32:40 -08:00
|
|
|
&EdenGame::choseSubtitleOption,
|
|
|
|
&EdenGame::edenQuit,
|
2016-09-14 23:39:27 +02:00
|
|
|
&EdenGame::restart,
|
|
|
|
&EdenGame::cancel2,
|
|
|
|
&EdenGame::testvoice,
|
2016-12-19 22:32:40 -08:00
|
|
|
&EdenGame::changeVolume,
|
2016-09-14 23:39:27 +02:00
|
|
|
&EdenGame::load,
|
|
|
|
&EdenGame::save,
|
|
|
|
&EdenGame::cliccurstape,
|
|
|
|
&EdenGame::playtape,
|
|
|
|
&EdenGame::stoptape,
|
|
|
|
&EdenGame::rewindtape,
|
|
|
|
&EdenGame::forwardtape,
|
2017-01-01 14:14:02 -08:00
|
|
|
&EdenGame::confirmYes,
|
|
|
|
&EdenGame::confirmNo,
|
2016-12-28 03:43:13 -08:00
|
|
|
&EdenGame::actionGotoMap
|
2016-09-14 23:39:27 +02:00
|
|
|
};
|
|
|
|
|
2016-12-18 13:09:56 -08:00
|
|
|
if (!(_currSpot = scan_icon_list(_cirsorPanX + _cursCenter,
|
2017-01-01 11:51:48 -08:00
|
|
|
_cursorPosY + _cursCenter, _globals->_iconsIndex)))
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-19 22:32:40 -08:00
|
|
|
_curSpot2 = _currSpot;
|
2016-12-18 13:09:56 -08:00
|
|
|
debug("invoking mouse action %d", _currSpot->_actionId);
|
|
|
|
if (mouse_actions[_currSpot->_actionId])
|
|
|
|
(this->*mouse_actions[_currSpot->_actionId])();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////// film.c
|
2016-09-27 07:53:50 +02:00
|
|
|
// Original name: showfilm
|
|
|
|
void EdenGame::showMovie(char arg1) {
|
2017-01-03 22:37:30 -08:00
|
|
|
_vm->_video->readHeader();
|
2017-01-22 23:55:31 +01:00
|
|
|
if (_globals->_curVideoNum == 92) {
|
2016-09-29 07:43:13 +02:00
|
|
|
// _hnmContext->_header._unusedFlag2 = 0; CHECKME: Useless?
|
2017-01-02 14:49:49 -08:00
|
|
|
_hnmSoundChannel->setVolumeLeft(0);
|
|
|
|
_hnmSoundChannel->setVolumeRight(0);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-11-27 12:47:04 -08:00
|
|
|
|
2017-01-03 22:37:30 -08:00
|
|
|
if (_vm->_video->getVersion() != 4)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-11-27 12:47:04 -08:00
|
|
|
|
|
|
|
bool playing = true;
|
2017-01-03 22:37:30 -08:00
|
|
|
_vm->_video->allocMemory();
|
|
|
|
_hnmView = new View(_vm, _vm->_video->_header._width, _vm->_video->_header._height);
|
2016-12-18 14:13:36 -08:00
|
|
|
_hnmView->setSrcZoomValues(0, 0);
|
2017-01-03 22:37:30 -08:00
|
|
|
_hnmView->setDisplayZoomValues(_vm->_video->_header._width * 2, _vm->_video->_header._height * 2);
|
2017-01-01 14:14:02 -08:00
|
|
|
_hnmView->centerIn(_vm->_screenView);
|
2016-12-18 14:13:36 -08:00
|
|
|
_hnmViewBuf = _hnmView->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (arg1) {
|
2016-12-18 14:13:36 -08:00
|
|
|
_hnmView->_normal._height = 160;
|
|
|
|
_hnmView->_zoom._height = 320; //TODO: width??
|
|
|
|
_hnmView->_normal._dstTop = _mainView->_normal._dstTop + 16;
|
|
|
|
_hnmView->_zoom._dstTop = _mainView->_zoom._dstTop + 32;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2017-01-03 22:37:30 -08:00
|
|
|
_vm->_video->setFinalBuffer(_hnmView->_bufferPtr);
|
2016-12-18 14:13:36 -08:00
|
|
|
_hnmView->_doubled = _doubledScreen;
|
2016-09-14 23:39:27 +02:00
|
|
|
do {
|
2017-01-03 22:37:30 -08:00
|
|
|
_hnmFrameNum = _vm->_video->getFrameNum();
|
|
|
|
_vm->_video->waitLoop();
|
|
|
|
playing = _vm->_video->nextElement();
|
2016-12-18 14:13:36 -08:00
|
|
|
if (_specialTextMode)
|
2016-12-29 06:28:11 -08:00
|
|
|
handleHNMSubtitles();
|
2016-09-14 23:39:27 +02:00
|
|
|
else
|
|
|
|
musicspy();
|
2016-12-18 14:13:36 -08:00
|
|
|
CLBlitter_CopyView2Screen(_hnmView);
|
2017-01-01 14:14:02 -08:00
|
|
|
assert(_vm->_screenView->_pitch == 320);
|
|
|
|
_vm->pollEvents();
|
2016-11-13 13:56:20 -08:00
|
|
|
if (_allowDoubled) {
|
2017-01-01 14:14:02 -08:00
|
|
|
#if 0 // CLKeyboard_IsScanCodeDown currently always returns false
|
|
|
|
if (_vm->isScanCodeDown(0x30)) { //TODO: const
|
2016-12-18 14:13:36 -08:00
|
|
|
if (!_keyboardHeld) {
|
2016-09-30 07:48:27 +02:00
|
|
|
_doubledScreen = !_doubledScreen;
|
2016-12-18 14:13:36 -08:00
|
|
|
_hnmView->_doubled = _doubledScreen; //TODO: but mainview ?
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_FillScreenView(0);
|
2016-12-18 14:13:36 -08:00
|
|
|
_keyboardHeld = true;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
} else
|
2017-01-01 14:14:02 -08:00
|
|
|
#endif
|
|
|
|
_keyboardHeld = false;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (arg1) {
|
2017-01-01 14:14:02 -08:00
|
|
|
if (_vm->isMouseButtonDown()) {
|
2016-12-18 13:09:56 -08:00
|
|
|
if (!_mouseHeld) {
|
|
|
|
_mouseHeld = true;
|
2016-12-18 14:13:36 -08:00
|
|
|
_videoCanceledFlag = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
} else
|
2016-12-18 13:09:56 -08:00
|
|
|
_mouseHeld = false;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-18 14:13:36 -08:00
|
|
|
} while (playing && !_videoCanceledFlag);
|
|
|
|
delete _hnmView;
|
2017-01-03 22:37:30 -08:00
|
|
|
_vm->_video->deallocMemory();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
void EdenGame::playHNM(int16 num) {
|
2016-09-26 07:57:27 +02:00
|
|
|
perso_t *perso = nullptr;
|
|
|
|
int16 oldDialogType = -1;
|
2017-01-22 23:55:31 +01:00
|
|
|
_globals->_curVideoNum = num;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (num != 2001 && num != 2012 && num != 98 && num != 171) {
|
2017-01-01 11:51:48 -08:00
|
|
|
byte oldMusicType = _globals->_newMusicType;
|
|
|
|
_globals->_newMusicType = MusicType::mtEvent;
|
2016-09-14 23:39:27 +02:00
|
|
|
musique();
|
|
|
|
musicspy();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_newMusicType = oldMusicType;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_videoSubtitleIndex = 1;
|
2016-12-18 14:13:36 -08:00
|
|
|
if (_specialTextMode) {
|
2017-01-01 11:51:48 -08:00
|
|
|
perso = _globals->_characterPtr;
|
|
|
|
oldDialogType = _globals->_dialogType;
|
2017-01-15 22:59:50 +01:00
|
|
|
preloadDialogs(num);
|
2016-09-14 23:39:27 +02:00
|
|
|
fademusica0(1);
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel->stop();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-18 14:13:36 -08:00
|
|
|
_showVideoSubtitle = false;
|
|
|
|
_videoCanceledFlag = false;
|
2017-01-12 07:19:17 +01:00
|
|
|
loadHnm(num);
|
2017-01-03 22:37:30 -08:00
|
|
|
_vm->_video->reset();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_needToFade) {
|
2016-12-17 10:13:15 -08:00
|
|
|
fadeToBlack(4);
|
2016-12-31 05:11:33 -08:00
|
|
|
clearScreen();
|
2017-01-01 11:51:48 -08:00
|
|
|
_needToFade = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
if (num == 2012 || num == 98 || num == 171)
|
2016-09-27 07:53:50 +02:00
|
|
|
showMovie(0);
|
2016-09-14 23:39:27 +02:00
|
|
|
else
|
2016-09-27 07:53:50 +02:00
|
|
|
showMovie(1);
|
2016-09-30 07:48:27 +02:00
|
|
|
_cursKeepPos = Common::Point(-1, -1);
|
2016-12-18 14:13:36 -08:00
|
|
|
_mainView->_doubled = _doubledScreen;
|
|
|
|
if (_specialTextMode) {
|
2016-10-06 00:15:02 +02:00
|
|
|
_musicFadeFlag = 3;
|
2016-09-14 23:39:27 +02:00
|
|
|
musicspy();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterPtr = perso;
|
|
|
|
_globals->_dialogType = oldDialogType;
|
2016-12-18 14:13:36 -08:00
|
|
|
_specialTextMode = false;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-18 14:13:36 -08:00
|
|
|
if (_videoCanceledFlag)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01;
|
2017-01-22 23:55:31 +01:00
|
|
|
if (_globals->_curVideoNum == 167)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01;
|
2017-01-22 23:55:31 +01:00
|
|
|
if (_globals->_curVideoNum == 104)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01;
|
2017-01-22 23:55:31 +01:00
|
|
|
if (_globals->_curVideoNum == 102)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01;
|
2017-01-22 23:55:31 +01:00
|
|
|
if (_globals->_curVideoNum == 77)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01;
|
2017-01-22 23:55:31 +01:00
|
|
|
if (_globals->_curVideoNum == 149)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
// Original name bullehnm
|
2016-12-29 06:28:11 -08:00
|
|
|
void EdenGame::handleHNMSubtitles() {
|
2017-01-18 22:33:00 +01:00
|
|
|
#define SUB_LINE(start, end) \
|
|
|
|
(start), (end) | 0x8000
|
|
|
|
|
|
|
|
static uint16 kFramesVid170[] = {
|
|
|
|
SUB_LINE( 68, 120),
|
|
|
|
SUB_LINE( 123, 196),
|
|
|
|
SUB_LINE( 199, 274),
|
|
|
|
SUB_LINE( 276, 370),
|
|
|
|
SUB_LINE( 799, 885),
|
|
|
|
SUB_LINE( 888, 940),
|
|
|
|
SUB_LINE( 947, 1000),
|
|
|
|
SUB_LINE(1319, 1378),
|
|
|
|
SUB_LINE(1380, 1440),
|
|
|
|
SUB_LINE(1854, 1898),
|
|
|
|
SUB_LINE(1900, 1960),
|
|
|
|
SUB_LINE(2116, 2184),
|
|
|
|
SUB_LINE(2186, 2252),
|
|
|
|
SUB_LINE(2254, 2320),
|
|
|
|
SUB_LINE(3038, 3094),
|
|
|
|
SUB_LINE(3096, 3160),
|
|
|
|
0xFFFF
|
|
|
|
};
|
|
|
|
|
|
|
|
static uint16 kFramesVid83[] = {
|
|
|
|
SUB_LINE(99, 155),
|
|
|
|
SUB_LINE(157, 256),
|
|
|
|
0xFFFF
|
|
|
|
};
|
|
|
|
|
|
|
|
static uint16 kFramesVid88[] = {
|
|
|
|
SUB_LINE(106, 173),
|
|
|
|
SUB_LINE(175, 244),
|
|
|
|
SUB_LINE(246, 350),
|
|
|
|
SUB_LINE(352, 467),
|
|
|
|
0xFFFF
|
|
|
|
};
|
|
|
|
|
|
|
|
static uint16 kFramesVid89[] = {
|
|
|
|
SUB_LINE(126, 176),
|
|
|
|
SUB_LINE(178, 267),
|
|
|
|
SUB_LINE(269, 342),
|
|
|
|
SUB_LINE(344, 398),
|
|
|
|
SUB_LINE(400, 458),
|
|
|
|
SUB_LINE(460, 558),
|
|
|
|
0xFFFF
|
|
|
|
};
|
|
|
|
|
|
|
|
static uint16 kFramesVid94[] = {
|
|
|
|
SUB_LINE(101, 213),
|
|
|
|
SUB_LINE(215, 353),
|
|
|
|
SUB_LINE(355, 455),
|
|
|
|
SUB_LINE(457, 518),
|
|
|
|
SUB_LINE(520, 660),
|
|
|
|
SUB_LINE(662, 768),
|
|
|
|
0xFFFF
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef SUB_LINE
|
|
|
|
|
2016-12-01 22:59:55 -08:00
|
|
|
uint16 *frames;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso;
|
2017-01-22 23:55:31 +01:00
|
|
|
switch (_globals->_curVideoNum) {
|
2016-09-14 23:39:27 +02:00
|
|
|
case 170:
|
2016-11-16 14:42:19 -08:00
|
|
|
frames = kFramesVid170;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso = &kPersons[PER_UNKN_156];
|
|
|
|
break;
|
|
|
|
case 83:
|
2016-11-16 14:42:19 -08:00
|
|
|
frames = kFramesVid83;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso = &kPersons[PER_MORKUS];
|
|
|
|
break;
|
|
|
|
case 88:
|
2016-11-16 14:42:19 -08:00
|
|
|
frames = kFramesVid88;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso = &kPersons[PER_MORKUS];
|
|
|
|
break;
|
|
|
|
case 89:
|
2016-11-16 14:42:19 -08:00
|
|
|
frames = kFramesVid89;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso = &kPersons[PER_MORKUS];
|
|
|
|
break;
|
|
|
|
case 94:
|
2016-11-16 14:42:19 -08:00
|
|
|
frames = kFramesVid94;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso = &kPersons[PER_MORKUS];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-01 22:59:55 -08:00
|
|
|
uint16 *frames_start = frames;
|
|
|
|
uint16 frame;
|
|
|
|
while ((frame = *frames++) != 0xFFFF) {
|
2016-12-18 14:13:36 -08:00
|
|
|
if ((frame & ~0x8000) == _hnmFrameNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-01 22:59:55 -08:00
|
|
|
if (frame == 0xFFFF) {
|
2016-12-18 14:13:36 -08:00
|
|
|
if (_showVideoSubtitle)
|
2016-12-29 06:28:11 -08:00
|
|
|
displayHNMSubtitle();
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (frame & 0x8000)
|
2016-12-18 14:13:36 -08:00
|
|
|
_showVideoSubtitle = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
else {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_videoSubtitleIndex = (frames - frames_start) / 2 + 1;
|
|
|
|
_globals->_characterPtr = perso;
|
|
|
|
_globals->_dialogType = DialogType::dtInspect;
|
|
|
|
int16 num = (perso->_id << 3) | _globals->_dialogType;
|
2017-01-18 23:05:38 +01:00
|
|
|
dialoscansvmas((Dialog *)getElem(_gameDialogs, num));
|
2016-12-18 14:13:36 -08:00
|
|
|
_showVideoSubtitle = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-18 14:13:36 -08:00
|
|
|
if (_showVideoSubtitle)
|
2016-12-29 06:28:11 -08:00
|
|
|
displayHNMSubtitle();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////// sound.c
|
|
|
|
void EdenGame::musique() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_newMusicType == MusicType::mtDontChange)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-11-14 14:51:52 -08:00
|
|
|
|
2017-01-18 23:05:38 +01:00
|
|
|
Dialog *dial = (Dialog *)getElem(_gameDialogs, 128);
|
2016-11-14 14:51:52 -08:00
|
|
|
for (;;dial++) {
|
2016-10-07 00:45:08 +02:00
|
|
|
if (dial->_flags == -1 && dial->_condNumLow == -1)
|
2016-08-18 13:15:54 +02:00
|
|
|
return;
|
2016-11-14 14:51:52 -08:00
|
|
|
byte flag = dial->_flags;
|
|
|
|
byte hidx = (dial->_textCondHiMask & 0xC0) >> 6;
|
|
|
|
byte lidx = dial->_condNumLow; //TODO: fixme - unsigned = signed
|
2016-09-14 23:39:27 +02:00
|
|
|
if (flag & 0x10)
|
|
|
|
hidx |= 4;
|
2016-12-25 14:20:06 -08:00
|
|
|
if (testCondition(((hidx << 8) | lidx) & 0x7FF))
|
2016-08-18 13:15:54 +02:00
|
|
|
break;
|
|
|
|
}
|
2016-11-14 14:51:52 -08:00
|
|
|
byte mus = dial->_textNumLow;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_newMusicType = MusicType::mtDontChange;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (mus != 0 && mus != 2 && mus < 50)
|
|
|
|
startmusique(mus);
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::startmusique(byte num) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (num == _globals->_currMusicNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-11-14 14:51:52 -08:00
|
|
|
|
2016-12-18 14:13:36 -08:00
|
|
|
if (_musicPlayingFlag) {
|
2016-09-14 23:39:27 +02:00
|
|
|
fademusica0(1);
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel->stop();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
loadmusicfile(num);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_currMusicNum = num;
|
2016-12-04 14:54:58 -08:00
|
|
|
_musSequencePtr = _musicBuf + 32; //TODO: rewrite it properly
|
|
|
|
int16 seq_size = READ_LE_UINT16(_musicBuf + 30);
|
2016-12-18 14:13:36 -08:00
|
|
|
_musicPatternsPtr = _musicBuf + 30 + seq_size;
|
2016-12-04 14:54:58 -08:00
|
|
|
int16 pat_size = READ_LE_UINT16(_musicBuf + 27);
|
2016-12-18 14:13:36 -08:00
|
|
|
_musicSamplesPtr = _musicBuf + 32 + 4 + pat_size;
|
|
|
|
int16 freq = READ_LE_UINT16(_musicSamplesPtr - 2);
|
2016-10-22 14:15:45 +03:00
|
|
|
|
|
|
|
delete _musicChannel;
|
2016-11-09 13:40:08 -08:00
|
|
|
_musicChannel = new CSoundChannel(_vm->_mixer, freq == 166 ? 11025 : 22050, false);
|
2016-12-18 14:13:36 -08:00
|
|
|
_musicEnabledFlag = true;
|
2016-10-22 14:15:45 +03:00
|
|
|
|
2016-12-18 14:13:36 -08:00
|
|
|
_musicSequencePos = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
_musicLeftVol = _globals->_prefMusicVol[0];
|
|
|
|
_musicRightVol = _globals->_prefMusicVol[1];
|
2016-12-18 14:13:36 -08:00
|
|
|
_musicChannel->setVolume(_musicLeftVol, _musicRightVol);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::musicspy() {
|
2016-12-18 14:13:36 -08:00
|
|
|
if (!_musicEnabledFlag)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
_musicLeftVol = _globals->_prefMusicVol[0];
|
|
|
|
_musicRightVol = _globals->_prefMusicVol[1];
|
2016-10-06 00:15:02 +02:00
|
|
|
if (_musicFadeFlag & 3)
|
2016-09-14 23:39:27 +02:00
|
|
|
fademusicup();
|
2016-10-22 14:15:45 +03:00
|
|
|
if (_personTalking && !_voiceChannel->numQueued())
|
2016-10-06 00:15:02 +02:00
|
|
|
_musicFadeFlag = 3;
|
2016-10-22 14:15:45 +03:00
|
|
|
if (_musicChannel->numQueued() < 3) {
|
2016-12-18 14:13:36 -08:00
|
|
|
byte patnum = _musSequencePtr[(int)_musicSequencePos];
|
2016-09-14 23:39:27 +02:00
|
|
|
if (patnum == 0xFF) {
|
|
|
|
// rewind
|
2016-12-18 14:13:36 -08:00
|
|
|
_musicSequencePos = 0;
|
|
|
|
patnum = _musSequencePtr[(int)_musicSequencePos];
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-18 14:13:36 -08:00
|
|
|
_musicSequencePos++;
|
|
|
|
byte *patptr = _musicPatternsPtr + patnum * 6;
|
2016-11-14 14:51:52 -08:00
|
|
|
int ofs = patptr[0] + (patptr[1] << 8) + (patptr[2] << 16);
|
|
|
|
int len = patptr[3] + (patptr[4] << 8) + (patptr[5] << 16);
|
2016-12-18 14:13:36 -08:00
|
|
|
_musicChannel->queueBuffer(_musicSamplesPtr + ofs, len);
|
|
|
|
_musicPlayingFlag = true;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
int EdenGame::loadmusicfile(int16 num) {
|
2017-01-01 11:51:48 -08:00
|
|
|
PakHeaderItem *file = &_bigfileHeader->_files[num + 435];
|
2016-12-07 15:04:25 -08:00
|
|
|
int32 size = file->_size;
|
|
|
|
int32 offs = file->_offs;
|
2017-01-01 11:51:48 -08:00
|
|
|
_bigfile.seek(offs, SEEK_SET);
|
2016-10-08 23:31:21 +02:00
|
|
|
int32 numread = size;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (numread > 0x140000) //TODO: const
|
|
|
|
numread = 0x140000;
|
2017-01-01 11:51:48 -08:00
|
|
|
_bigfile.read(_musicBuf, numread);
|
2016-09-14 23:39:27 +02:00
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::persovox() {
|
2017-01-01 11:51:48 -08:00
|
|
|
int16 num = _globals->_textNum;
|
|
|
|
if (_globals->_textBankIndex != 1)
|
2016-09-14 23:39:27 +02:00
|
|
|
num += 565;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_textBankIndex == 3)
|
2016-09-14 23:39:27 +02:00
|
|
|
num += 707;
|
2017-01-12 07:19:17 +01:00
|
|
|
_voiceSamplesSize = loadSound(num);
|
2017-01-01 11:51:48 -08:00
|
|
|
int16 volumeLeft = _globals->_prefSoundVolume[0];
|
|
|
|
int16 volumeRight = _globals->_prefSoundVolume[1];
|
2016-10-22 14:15:45 +03:00
|
|
|
int16 stepLeft = _musicChannel->_volumeLeft < volumeLeft ? stepLeft = 1 : -1;
|
|
|
|
int16 stepRight = _musicChannel->_volumeRight < volumeRight ? stepRight = 1 : -1;
|
2016-09-14 23:39:27 +02:00
|
|
|
do {
|
2016-10-06 00:15:02 +02:00
|
|
|
if (volumeLeft != _musicChannel->_volumeLeft)
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel->setVolumeLeft(_musicChannel->_volumeLeft + stepLeft);
|
2016-10-06 00:15:02 +02:00
|
|
|
if (volumeRight != _musicChannel->_volumeRight)
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel->setVolumeRight(_musicChannel->_volumeRight + stepRight);
|
2016-10-06 00:15:02 +02:00
|
|
|
} while (_musicChannel->_volumeLeft != volumeLeft || _musicChannel->_volumeRight != volumeRight);
|
2017-01-01 11:51:48 -08:00
|
|
|
volumeLeft = _globals->_prefVoiceVol[0];
|
|
|
|
volumeRight = _globals->_prefVoiceVol[1];
|
2016-10-22 14:15:45 +03:00
|
|
|
_voiceChannel->setVolume(volumeLeft, volumeRight);
|
2016-12-26 22:47:24 -08:00
|
|
|
_voiceChannel->queueBuffer(_voiceSamplesBuffer, _voiceSamplesSize, true);
|
2016-10-06 00:15:02 +02:00
|
|
|
_personTalking = true;
|
|
|
|
_musicFadeFlag = 0;
|
2016-12-04 14:26:44 -08:00
|
|
|
_lastAnimTicks = _vm->_timerTicks;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: endpersovox
|
|
|
|
void EdenGame::endCharacterSpeech() {
|
2016-12-26 13:40:28 -08:00
|
|
|
restoreUnderSubtitles();
|
2016-10-06 00:15:02 +02:00
|
|
|
if (_personTalking) {
|
2016-10-22 14:15:45 +03:00
|
|
|
_voiceChannel->stop();
|
2016-10-06 00:15:02 +02:00
|
|
|
_personTalking = false;
|
|
|
|
_musicFadeFlag = 3;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-10-06 00:15:02 +02:00
|
|
|
|
|
|
|
if (_soundAllocated) {
|
2016-12-26 22:47:24 -08:00
|
|
|
free(_voiceSamplesBuffer);
|
|
|
|
_voiceSamplesBuffer = nullptr;
|
2016-10-06 00:15:02 +02:00
|
|
|
_soundAllocated = false;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::fademusicup() {
|
2016-10-06 00:15:02 +02:00
|
|
|
if (_musicFadeFlag & 2) {
|
|
|
|
int16 vol = _musicChannel->_volumeLeft;
|
2016-12-18 14:13:36 -08:00
|
|
|
if (vol < _musicLeftVol) {
|
2016-09-14 23:39:27 +02:00
|
|
|
vol += 8;
|
2016-12-18 14:13:36 -08:00
|
|
|
if (vol > _musicLeftVol)
|
|
|
|
vol = _musicLeftVol;
|
2016-08-18 13:15:54 +02:00
|
|
|
} else {
|
2016-09-14 23:39:27 +02:00
|
|
|
vol -= 8;
|
2016-12-18 14:13:36 -08:00
|
|
|
if (vol < _musicLeftVol)
|
|
|
|
vol = _musicLeftVol;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel->setVolumeLeft(vol);
|
2016-12-18 14:13:36 -08:00
|
|
|
if (vol == _musicLeftVol)
|
2016-10-06 00:15:02 +02:00
|
|
|
_musicFadeFlag &= ~2;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-10-06 00:15:02 +02:00
|
|
|
if (_musicFadeFlag & 1) {
|
|
|
|
int16 vol = _musicChannel->_volumeRight;
|
2016-12-18 14:13:36 -08:00
|
|
|
if (vol < _musicRightVol) {
|
2016-09-14 23:39:27 +02:00
|
|
|
vol += 8;
|
2016-12-18 14:13:36 -08:00
|
|
|
if (vol > _musicRightVol)
|
|
|
|
vol = _musicRightVol;
|
2016-08-18 13:15:54 +02:00
|
|
|
} else {
|
2016-09-14 23:39:27 +02:00
|
|
|
vol -= 8;
|
2016-12-18 14:13:36 -08:00
|
|
|
if (vol < _musicRightVol)
|
|
|
|
vol = _musicRightVol;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel->setVolumeRight(vol);
|
2016-12-18 14:13:36 -08:00
|
|
|
if (vol == _musicRightVol)
|
2016-10-06 00:15:02 +02:00
|
|
|
_musicFadeFlag &= ~1;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::fademusica0(int16 delay) {
|
|
|
|
int16 volume;
|
2016-10-22 14:15:45 +03:00
|
|
|
while ((volume = _musicChannel->getVolume()) > 2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
volume -= 2;
|
|
|
|
if (volume < 2)
|
|
|
|
volume = 2;
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel->setVolume(volume, volume);
|
2016-09-14 23:39:27 +02:00
|
|
|
wait(delay);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//// obj.c
|
2016-12-18 13:09:56 -08:00
|
|
|
|
|
|
|
// Original name: getobjaddr
|
|
|
|
object_t *EdenGame::getObjectPtr(int16 id) {
|
2016-09-14 23:39:27 +02:00
|
|
|
int i;
|
2016-10-06 00:15:02 +02:00
|
|
|
for (i = 0; i < MAX_OBJECTS; i++) {
|
2016-12-04 14:26:44 -08:00
|
|
|
if (_objects[i]._id == id)
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-10-06 00:15:02 +02:00
|
|
|
}
|
|
|
|
|
2016-12-18 13:09:56 -08:00
|
|
|
return &_objects[i];
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-18 13:09:56 -08:00
|
|
|
void EdenGame::countObjects() {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 index = 0;
|
|
|
|
byte total = 0;
|
2016-10-06 00:15:02 +02:00
|
|
|
for (int i = 0; i < MAX_OBJECTS; i++) {
|
2016-12-04 14:26:44 -08:00
|
|
|
int16 count = _objects[i]._count;
|
2016-08-18 13:15:54 +02:00
|
|
|
#ifdef EDEN_DEBUG
|
2016-09-14 23:39:27 +02:00
|
|
|
count = 1;
|
2016-12-26 14:25:19 -08:00
|
|
|
goto show_all_objects;
|
2016-08-18 13:15:54 +02:00
|
|
|
#endif
|
2016-09-14 23:39:27 +02:00
|
|
|
if (count == 0)
|
|
|
|
continue;
|
2016-12-04 14:26:44 -08:00
|
|
|
if (_objects[i]._flags & ObjectFlags::ofInHands)
|
2016-09-14 23:39:27 +02:00
|
|
|
count--;
|
2016-12-26 14:25:19 -08:00
|
|
|
#ifdef EDEN_DEBUG
|
2016-09-14 23:39:27 +02:00
|
|
|
show_all_objects:
|
|
|
|
;
|
2016-12-26 14:25:19 -08:00
|
|
|
#endif
|
2016-09-14 23:39:27 +02:00
|
|
|
if (count) {
|
|
|
|
total += count;
|
|
|
|
while (count--)
|
2017-01-01 11:51:48 -08:00
|
|
|
_ownObjects[index++] = _objects[i]._id;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_objCount = total;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-25 23:17:25 +02:00
|
|
|
void EdenGame::showObjects() {
|
2016-12-19 22:32:40 -08:00
|
|
|
Icon *icon = &_gameIcons[_invIconsBase];
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_drawFlags &= ~(DrawFlags::drDrawInventory | DrawFlags::drDrawFlag2);
|
2016-12-18 13:09:56 -08:00
|
|
|
countObjects();
|
2017-01-01 11:51:48 -08:00
|
|
|
int16 total = _globals->_objCount;
|
2016-12-19 13:41:00 -08:00
|
|
|
for (int16 i = _invIconsCount; i--; icon++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (total) {
|
2016-12-03 15:40:53 -08:00
|
|
|
icon->_cursorId &= ~0x8000;
|
2016-09-14 23:39:27 +02:00
|
|
|
total--;
|
|
|
|
} else
|
2016-12-03 15:40:53 -08:00
|
|
|
icon->_cursorId |= 0x8000;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-25 02:17:07 -08:00
|
|
|
useMainBank();
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(55, 0, 176);
|
2016-12-19 22:32:40 -08:00
|
|
|
icon = &_gameIcons[_invIconsBase];
|
2017-01-01 11:51:48 -08:00
|
|
|
total = _globals->_objCount;
|
|
|
|
int16 index = _globals->_inventoryScrollPos;
|
2016-12-19 13:41:00 -08:00
|
|
|
for (int16 i = _invIconsCount; total-- && i--; icon++) {
|
2017-01-01 11:51:48 -08:00
|
|
|
char obj = _ownObjects[index++];
|
2016-12-03 15:40:53 -08:00
|
|
|
icon->_objectId = obj;
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(obj + 9, icon->sx, 178);
|
|
|
|
}
|
2016-12-18 14:13:36 -08:00
|
|
|
_paletteUpdateRequired = true;
|
2017-01-01 11:51:48 -08:00
|
|
|
if ((_globals->_displayFlags & DisplayFlags::dfMirror) || (_globals->_displayFlags & DisplayFlags::dfPanable)) {
|
2016-09-27 07:53:50 +02:00
|
|
|
saveBottomFrieze();
|
2016-09-14 23:39:27 +02:00
|
|
|
scroll();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
void EdenGame::winObject(int16 id) {
|
2016-12-18 13:09:56 -08:00
|
|
|
object_t *object = getObjectPtr(id);
|
2016-10-07 00:45:08 +02:00
|
|
|
object->_flags |= ObjectFlags::ofFlag1;
|
|
|
|
object->_count++;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curItemsMask |= object->_itemMask;
|
|
|
|
_globals->_wonItemsMask |= object->_itemMask;
|
|
|
|
_globals->_curPowersMask |= object->_powerMask;
|
|
|
|
_globals->_wonPowersMask |= object->_powerMask;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
void EdenGame::loseObject(int16 id) {
|
2016-12-18 13:09:56 -08:00
|
|
|
object_t *object = getObjectPtr(id);
|
2016-10-07 00:45:08 +02:00
|
|
|
if (object->_count > 0)
|
|
|
|
object->_count--;
|
|
|
|
if (!object->_count) {
|
|
|
|
object->_flags &= ~ObjectFlags::ofFlag1;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curItemsMask &= ~object->_itemMask;
|
|
|
|
_globals->_curPowersMask &= ~object->_powerMask;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curObjectId = 0;
|
|
|
|
_globals->_curObjectFlags = 0;
|
|
|
|
_globals->_curObjectCursor = 9;
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[16]._cursorId |= 0x8000;
|
2016-10-07 00:45:08 +02:00
|
|
|
object->_flags &= ~ObjectFlags::ofInHands;
|
2016-12-18 13:09:56 -08:00
|
|
|
_normalCursor = true;
|
2016-11-13 13:56:20 -08:00
|
|
|
_currCursor = 0;
|
2016-12-18 13:09:56 -08:00
|
|
|
_torchCursor = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-11 22:52:10 -08:00
|
|
|
void EdenGame::lostObject() {
|
2016-10-24 00:04:32 +02:00
|
|
|
parlemoiNormalFlag = true;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curObjectId)
|
|
|
|
loseObject(_globals->_curObjectId);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: objecthere
|
|
|
|
bool EdenGame::isObjectHere(int16 id) {
|
2016-12-18 13:09:56 -08:00
|
|
|
object_t *object = getObjectPtr(id);
|
2017-01-01 11:51:48 -08:00
|
|
|
for (_currentObjectLocation = &kObjectLocations[object->_locations]; *_currentObjectLocation != 0xFFFF; _currentObjectLocation++) {
|
|
|
|
if (*_currentObjectLocation == _globals->_roomNum)
|
2016-11-14 14:51:52 -08:00
|
|
|
return true;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-11-14 14:51:52 -08:00
|
|
|
return false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::objectmain(int16 id) {
|
2016-12-18 13:09:56 -08:00
|
|
|
object_t *object = getObjectPtr(id);
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[16]._cursorId &= ~0x8000;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curObjectId = object->_id;
|
|
|
|
_globals->_curObjectCursor = _globals->_curObjectId + 9;
|
2016-10-07 00:45:08 +02:00
|
|
|
object->_flags |= ObjectFlags::ofInHands;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curObjectFlags = object->_flags;
|
|
|
|
_currCursor = _globals->_curObjectId + 9;
|
2016-12-18 13:09:56 -08:00
|
|
|
_normalCursor = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-11 22:52:10 -08:00
|
|
|
void EdenGame::getObject(int16 id) {
|
2017-01-01 11:51:48 -08:00
|
|
|
Room *room = _globals->_roomPtr;
|
|
|
|
if (_globals->_curObjectId)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-28 03:43:13 -08:00
|
|
|
if (!isObjectHere(id))
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
*_currentObjectLocation |= 0x8000;
|
2016-09-14 23:39:27 +02:00
|
|
|
objectmain(id);
|
2016-12-04 14:26:44 -08:00
|
|
|
winObject(id);
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomImgBank = room->_bank;
|
|
|
|
_globals->_roomVidNum = room->_video;
|
2016-10-07 23:06:10 +02:00
|
|
|
displayPlace();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 13:15:38 -08:00
|
|
|
void EdenGame::putObject() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!_globals->_curObjectId)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[16]._cursorId |= 0x8000;
|
2017-01-01 11:51:48 -08:00
|
|
|
object_t *object = getObjectPtr(_globals->_curObjectId);
|
|
|
|
_globals->_curObjectCursor = 9;
|
|
|
|
_globals->_curObjectId = 0;
|
|
|
|
_globals->_curObjectFlags = 0;
|
2016-10-07 00:45:08 +02:00
|
|
|
object->_flags &= ~ObjectFlags::ofInHands;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_nextDialogPtr = nullptr;
|
2016-12-04 13:15:38 -08:00
|
|
|
_closeCharacterDialog = false;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_dialogType = DialogType::dtTalk;
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2016-12-18 13:09:56 -08:00
|
|
|
_normalCursor = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-11 22:52:10 -08:00
|
|
|
void EdenGame::newObject(int16 id, int16 arg2) {
|
2016-12-18 13:09:56 -08:00
|
|
|
object_t *object = getObjectPtr(id);
|
2016-12-01 22:59:55 -08:00
|
|
|
uint16 e, *t = &kObjectLocations[object->_locations];
|
|
|
|
while ((e = *t) != 0xFFFF) {
|
2016-09-14 23:39:27 +02:00
|
|
|
e &= ~0x8000;
|
|
|
|
if ((e >> 8) == arg2)
|
|
|
|
*t = e;
|
|
|
|
t++;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::giveobjectal(int16 id) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (id == Objects::obKnife)
|
|
|
|
kObjectLocations[2] = 0;
|
|
|
|
if (id == Objects::obApple)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_stepsToFindAppleNormal = 0;
|
|
|
|
if (id >= Objects::obEyeInTheStorm && id < (Objects::obRiverThatWinds + 1) && _globals->_roomCharacterType == PersonFlags::pftVelociraptor) {
|
2016-09-14 23:39:27 +02:00
|
|
|
//TODO: fix that cond above
|
2016-12-18 13:09:56 -08:00
|
|
|
object_t *object = getObjectPtr(id);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomCharacterPtr->_powers &= ~object->_powerMask;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-04 14:26:44 -08:00
|
|
|
winObject(id);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-12-04 14:26:44 -08:00
|
|
|
void EdenGame::giveObject() {
|
2017-01-01 11:51:48 -08:00
|
|
|
byte id = _globals->_giveObj1;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (id) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_giveObj1 = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
giveobjectal(id);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
id = _globals->_giveObj2;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (id) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_giveObj2 = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
giveobjectal(id);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
id = _globals->_giveObj3;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (id) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_giveObj3 = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
giveobjectal(id);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: takeObject
|
|
|
|
void EdenGame::actionTakeObject() {
|
2016-12-19 22:32:40 -08:00
|
|
|
objectmain(_curSpot2->_objectId);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_nextDialogPtr = nullptr;
|
2016-12-04 13:15:38 -08:00
|
|
|
_closeCharacterDialog = false;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_dialogType = DialogType::dtTalk;
|
|
|
|
if (_globals->_inventoryScrollPos)
|
|
|
|
_globals->_inventoryScrollPos--;
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
////
|
2016-12-18 13:09:56 -08:00
|
|
|
|
|
|
|
// Original name: newchampi
|
|
|
|
void EdenGame::newMushroom() {
|
2016-12-04 14:26:44 -08:00
|
|
|
if (_objects[Objects::obShroom - 1]._count == 0) {
|
2017-01-01 11:51:48 -08:00
|
|
|
newObject(Objects::obShroom, _globals->_citadelAreaNum);
|
|
|
|
newObject(Objects::obBadShroom, _globals->_citadelAreaNum);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-26 12:35:21 -08:00
|
|
|
// Original name: newnidv
|
|
|
|
void EdenGame::newEmptyNest() {
|
2017-01-01 11:51:48 -08:00
|
|
|
Room *room = _globals->_citaAreaFirstRoom;
|
2016-12-04 14:26:44 -08:00
|
|
|
if (_objects[Objects::obNest - 1]._count)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-18 13:09:56 -08:00
|
|
|
object_t *obj = getObjectPtr(Objects::obNest);
|
2016-12-01 22:59:55 -08:00
|
|
|
for (uint16 *ptr = kObjectLocations + obj->_locations; *ptr != 0xFFFF; ptr++) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if ((*ptr & ~0x8000) >> 8 != _globals->_citadelAreaNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
|
|
|
*ptr &= ~0x8000;
|
2016-12-15 22:47:29 -08:00
|
|
|
for (; room->_id != 0xFF; room++) {
|
|
|
|
if (room->_location == (*ptr & 0xFF)) {
|
|
|
|
room->_bank = 279;
|
|
|
|
room->_id = 9;
|
2016-09-14 23:39:27 +02:00
|
|
|
room++;
|
2016-12-15 22:47:29 -08:00
|
|
|
room->_bank = 280;
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-26 12:35:21 -08:00
|
|
|
// Original name: newnido
|
|
|
|
void EdenGame::newNestWithEggs() {
|
2017-01-01 11:51:48 -08:00
|
|
|
Room *room = _globals->_citaAreaFirstRoom;
|
2016-12-04 14:26:44 -08:00
|
|
|
if (_objects[Objects::obFullNest - 1]._count)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-04 14:26:44 -08:00
|
|
|
if (_objects[Objects::obNest - 1]._count)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-18 13:09:56 -08:00
|
|
|
object_t *obj = getObjectPtr(Objects::obFullNest);
|
2016-12-01 22:59:55 -08:00
|
|
|
for (uint16 *ptr = kObjectLocations + obj->_locations; *ptr != 0xFFFF; ptr++) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if ((*ptr & ~0x8000) >> 8 != _globals->_citadelAreaNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
|
|
|
*ptr &= ~0x8000;
|
2016-12-15 22:47:29 -08:00
|
|
|
for (; room->_id != 0xFF; room++) {
|
|
|
|
if (room->_location == (*ptr & 0xFF)) {
|
|
|
|
room->_bank = 277;
|
|
|
|
room->_id = 9;
|
2016-09-14 23:39:27 +02:00
|
|
|
room++;
|
2016-12-15 22:47:29 -08:00
|
|
|
room->_bank = 278;
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-22 22:38:18 +01:00
|
|
|
// Original name: newor
|
|
|
|
void EdenGame::newGold() {
|
|
|
|
if (_objects[Objects::obGold - 1]._count == 0)
|
2017-01-01 11:51:48 -08:00
|
|
|
newObject(Objects::obGold, _globals->_citadelAreaNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
void EdenGame::gotoPanel() {
|
2017-01-01 14:14:02 -08:00
|
|
|
if (_vm->shouldQuit())
|
2017-01-01 11:51:48 -08:00
|
|
|
byte_31D64 = _globals->_autoDialog; //TODO: check me
|
2016-11-13 13:56:20 -08:00
|
|
|
_noPalette = false;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_iconsIndex = 85;
|
|
|
|
_globals->_characterPtr = nullptr;
|
|
|
|
_globals->_drawFlags |= DrawFlags::drDrawMenu;
|
|
|
|
_globals->_displayFlags = DisplayFlags::dfFlag2;
|
|
|
|
_globals->_menuFlags = 0;
|
2016-12-19 22:32:40 -08:00
|
|
|
displayPanel();
|
2016-12-17 10:13:15 -08:00
|
|
|
fadeToBlack(3);
|
2016-12-19 22:32:40 -08:00
|
|
|
displayTopPanel();
|
2016-12-18 14:13:36 -08:00
|
|
|
CLBlitter_CopyView2Screen(_mainView);
|
2016-12-25 13:45:47 -08:00
|
|
|
CLPalette_Send2Screen(_globalPalette, 0, 256);
|
2016-12-18 13:09:56 -08:00
|
|
|
_cursorPosX = 320 / 2;
|
|
|
|
_cursorPosY = 200 / 2;
|
2017-01-01 14:14:02 -08:00
|
|
|
_vm->setMousePosition(_mouseCenterX, _mouseCenterY);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::noclicpanel() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_menuFlags & MenuFlags::mfFlag4) {
|
2016-09-14 23:39:27 +02:00
|
|
|
depcurstape();
|
|
|
|
return;
|
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_drawFlags & DrawFlags::drDrawFlag8)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_menuFlags & MenuFlags::mfFlag1) {
|
2016-09-14 23:39:27 +02:00
|
|
|
changervol();
|
|
|
|
return;
|
|
|
|
}
|
2016-11-14 14:51:52 -08:00
|
|
|
byte num;
|
2016-12-19 22:32:40 -08:00
|
|
|
if (_curSpot2 >= &_gameIcons[119]) {
|
2017-01-01 11:51:48 -08:00
|
|
|
debug("noclic: objid = %p, glob3,2 = %2X %2X", (void *)_curSpot2, _globals->_menuItemIdHi, _globals->_menuItemIdLo);
|
|
|
|
if (_curSpot2->_objectId == (uint16)((_globals->_menuItemIdLo + _globals->_menuItemIdHi) << 8)) //TODO: check me
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
|
|
|
} else {
|
2016-12-19 22:32:40 -08:00
|
|
|
int idx = _curSpot2 - &_gameIcons[105];
|
2016-09-14 23:39:27 +02:00
|
|
|
if (idx == 0) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_menuItemIdLo = 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
num = 1;
|
|
|
|
goto skip;
|
|
|
|
}
|
|
|
|
num = idx & 0x7F + 1;
|
|
|
|
if (num >= 5)
|
|
|
|
num = 1;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (num == _globals->_var43)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var43 = 0;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
num = _globals->_menuItemIdLo;
|
|
|
|
_globals->_menuItemIdLo = _curSpot2->_objectId & 0xFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
skip:
|
|
|
|
;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_menuItemIdHi = (_curSpot2->_objectId & 0xFF00) >> 8;
|
|
|
|
debug("noclic: new glob3,2 = %2X %2X", _globals->_menuItemIdHi, _globals->_menuItemIdLo);
|
2016-12-19 22:32:40 -08:00
|
|
|
displayResult();
|
2016-09-14 23:39:27 +02:00
|
|
|
num &= 0xF0;
|
|
|
|
if (num != 0x30)
|
2017-01-01 11:51:48 -08:00
|
|
|
num = _globals->_menuItemIdLo & 0xF0;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (num == 0x30)
|
2016-12-19 22:32:40 -08:00
|
|
|
displayCursors();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::generique() {
|
2016-09-28 07:29:12 +02:00
|
|
|
drawBlackBars();
|
2016-12-26 13:40:28 -08:00
|
|
|
display();
|
2016-12-17 10:13:15 -08:00
|
|
|
fadeToBlack(3);
|
2016-12-31 05:11:33 -08:00
|
|
|
clearScreen();
|
2017-01-01 11:51:48 -08:00
|
|
|
int oldmusic = _globals->_currMusicNum;
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(95);
|
2016-12-19 22:32:40 -08:00
|
|
|
displayPanel();
|
|
|
|
displayTopPanel();
|
2016-12-18 14:13:36 -08:00
|
|
|
_paletteUpdateRequired = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
startmusique(oldmusic);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::cancel2() {
|
2016-09-25 23:17:25 +02:00
|
|
|
drawTopScreen();
|
|
|
|
showObjects();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_iconsIndex = 16;
|
|
|
|
_globals->_drawFlags &= ~DrawFlags::drDrawMenu;
|
2016-12-31 05:11:33 -08:00
|
|
|
gameToMirror(1);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::testvoice() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_frescoNumber = 0;
|
|
|
|
_globals->_characterPtr = kPersons;
|
|
|
|
_globals->_dialogType = DialogType::dtInspect;
|
|
|
|
int16 num = (kPersons[PER_KING]._id << 3) | _globals->_dialogType;
|
2017-01-18 23:05:38 +01:00
|
|
|
dialoscansvmas((Dialog *)getElem(_gameDialogs, num));
|
2016-12-26 13:40:28 -08:00
|
|
|
restoreUnderSubtitles();
|
2016-12-25 02:17:07 -08:00
|
|
|
displaySubtitles();
|
2016-09-14 23:39:27 +02:00
|
|
|
persovox();
|
2016-12-04 13:15:38 -08:00
|
|
|
waitEndSpeak();
|
2016-12-28 03:43:13 -08:00
|
|
|
endCharacterSpeech();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varCA = 0;
|
|
|
|
_globals->_dialogType = DialogType::dtTalk;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::load() {
|
|
|
|
char name[132];
|
2016-11-13 13:56:20 -08:00
|
|
|
_gameLoaded = false;
|
2017-01-01 11:51:48 -08:00
|
|
|
byte oldMusic = _globals->_currMusicNum; //TODO: from uint16 to byte?!
|
2016-09-14 23:39:27 +02:00
|
|
|
fademusica0(1);
|
|
|
|
desktopcolors();
|
|
|
|
FlushEvents(-1, 0);
|
|
|
|
// if(OpenDialog(0, 0)) //TODO: write me
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
strcpy(name, "edsave1.000");
|
|
|
|
loadgame(name);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 14:14:02 -08:00
|
|
|
_vm->hideMouse();
|
2016-09-26 07:57:27 +02:00
|
|
|
CLBlitter_FillScreenView(0xFFFFFFFF);
|
2016-12-17 10:13:15 -08:00
|
|
|
fadeToBlack(3);
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_FillScreenView(0);
|
2016-11-13 13:56:20 -08:00
|
|
|
if (!_gameLoaded) {
|
2016-10-06 00:15:02 +02:00
|
|
|
_musicFadeFlag = 3;
|
2016-09-14 23:39:27 +02:00
|
|
|
musicspy();
|
2016-12-18 14:13:36 -08:00
|
|
|
_paletteUpdateRequired = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if ((oldMusic & 0xFF) != _globals->_currMusicNum) { //TODO: r30 is uns char/bug???
|
|
|
|
oldMusic = _globals->_currMusicNum;
|
|
|
|
_globals->_currMusicNum = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
startmusique(oldMusic);
|
|
|
|
} else {
|
2016-10-06 00:15:02 +02:00
|
|
|
_musicFadeFlag = 3;
|
2016-09-14 23:39:27 +02:00
|
|
|
musicspy();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
bool talk = _globals->_autoDialog; //TODO check me
|
2016-09-14 23:39:27 +02:00
|
|
|
initafterload();
|
2016-12-17 10:13:15 -08:00
|
|
|
fadeToBlack(3);
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_FillScreenView(0);
|
2016-12-18 14:13:36 -08:00
|
|
|
CLBlitter_FillView(_mainView, 0);
|
2016-09-25 23:17:25 +02:00
|
|
|
drawTopScreen();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_inventoryScrollPos = 0;
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2017-01-01 11:51:48 -08:00
|
|
|
updateRoom(_globals->_roomNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (talk) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_iconsIndex = 4;
|
|
|
|
_globals->_autoDialog = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
parle_moi();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::initafterload() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterImageBank = 0;
|
|
|
|
_globals->_lastPlaceNum = 0;
|
|
|
|
loadPlace(_globals->_areaPtr->_placeNum);
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[18]._cursorId |= 0x8000;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curAreaType == AreaType::atValley)
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[18]._cursorId &= ~0x8000;
|
2016-09-14 23:39:27 +02:00
|
|
|
kPersoRoomBankTable[30] = 27;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_phaseNum >= 352)
|
2016-09-14 23:39:27 +02:00
|
|
|
kPersoRoomBankTable[30] = 26;
|
2016-11-09 22:36:06 -08:00
|
|
|
_animateTalking = false;
|
2016-12-25 02:17:07 -08:00
|
|
|
_animationActive = false;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var100 = 0;
|
|
|
|
_globals->_eventType = EventType::etEventC;
|
|
|
|
_globals->_valleyVidNum = 0;
|
|
|
|
_globals->_drawFlags &= ~DrawFlags::drDrawMenu;
|
2016-12-18 14:13:36 -08:00
|
|
|
_currentTime = _vm->_timerTicks / 100;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_gameTime = _currentTime;
|
|
|
|
if (_globals->_roomCharacterType == PersonFlags::pftTyrann)
|
2016-12-11 13:44:58 -08:00
|
|
|
setChrono(3000);
|
2016-09-30 07:48:27 +02:00
|
|
|
_adamMapMarkPos.x = -1;
|
|
|
|
_adamMapMarkPos.y = -1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::save() {
|
|
|
|
char name[260];
|
|
|
|
fademusica0(1);
|
|
|
|
desktopcolors();
|
|
|
|
FlushEvents(-1, 0);
|
|
|
|
//SaveDialog(byte_37150, byte_37196->ff_A);
|
|
|
|
//TODO
|
|
|
|
strcpy(name, "edsave1.000");
|
|
|
|
savegame(name);
|
2017-01-01 14:14:02 -08:00
|
|
|
_vm->hideMouse();
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_FillScreenView(0xFFFFFFFF);
|
2016-12-17 10:13:15 -08:00
|
|
|
fadeToBlack(3);
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_FillScreenView(0);
|
2016-10-06 00:15:02 +02:00
|
|
|
_musicFadeFlag = 3;
|
2016-09-14 23:39:27 +02:00
|
|
|
musicspy();
|
2016-12-18 14:13:36 -08:00
|
|
|
_paletteUpdateRequired = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::desktopcolors() {
|
2016-12-17 10:13:15 -08:00
|
|
|
fadeToBlack(3);
|
2016-09-26 07:57:27 +02:00
|
|
|
CLBlitter_FillScreenView(0xFFFFFFFF);
|
2016-09-14 23:39:27 +02:00
|
|
|
CLPalette_BeSystem();
|
2017-01-01 14:14:02 -08:00
|
|
|
_vm->showMouse();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::panelrestart() {
|
2016-11-13 13:56:20 -08:00
|
|
|
_gameLoaded = false;
|
2017-01-01 11:51:48 -08:00
|
|
|
byte curmus = _globals->_currMusicNum;
|
|
|
|
byte curlng = _globals->_prefLanguage;
|
2016-09-14 23:39:27 +02:00
|
|
|
loadrestart();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_prefLanguage = curlng;
|
2016-11-13 13:56:20 -08:00
|
|
|
if (!_gameLoaded) //TODO always?
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterImageBank = 0;
|
|
|
|
_globals->_lastPlaceNum = 0;
|
|
|
|
loadPlace(_globals->_areaPtr->_placeNum);
|
|
|
|
_globals->_displayFlags = DisplayFlags::dfFlag1;
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[18]._cursorId |= 0x8000;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_curAreaType == AreaType::atValley)
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[18]._cursorId &= ~0x8000;
|
2016-09-14 23:39:27 +02:00
|
|
|
kPersoRoomBankTable[30] = 27;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_phaseNum >= 352)
|
2016-09-14 23:39:27 +02:00
|
|
|
kPersoRoomBankTable[30] = 26;
|
2016-11-09 22:36:06 -08:00
|
|
|
_animateTalking = false;
|
2016-12-25 02:17:07 -08:00
|
|
|
_animationActive = false;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var100 = 0;
|
|
|
|
_globals->_eventType = 0;
|
|
|
|
_globals->_valleyVidNum = 0;
|
|
|
|
_globals->_drawFlags &= ~DrawFlags::drDrawMenu;
|
|
|
|
_globals->_inventoryScrollPos = 0;
|
2016-09-30 07:48:27 +02:00
|
|
|
_adamMapMarkPos.x = -1;
|
|
|
|
_adamMapMarkPos.y = -1;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (curmus != _globals->_currMusicNum) {
|
|
|
|
curmus = _globals->_currMusicNum;
|
|
|
|
_globals->_currMusicNum = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
startmusique(curmus);
|
|
|
|
}
|
2016-12-17 10:13:15 -08:00
|
|
|
fadeToBlack(3);
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_FillScreenView(0);
|
2016-12-18 14:13:36 -08:00
|
|
|
CLBlitter_FillView(_mainView, 0);
|
2016-09-25 23:17:25 +02:00
|
|
|
drawTopScreen();
|
|
|
|
showObjects();
|
2016-09-27 07:53:50 +02:00
|
|
|
saveFriezes();
|
2016-12-18 14:13:36 -08:00
|
|
|
_showBlackBars = true;
|
2017-01-01 11:51:48 -08:00
|
|
|
updateRoom(_globals->_roomNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::reallyquit() {
|
2016-12-18 14:13:36 -08:00
|
|
|
_quitFlag3 = true;
|
|
|
|
_quitFlag2 = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::confirmer(char mode, char yesId) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_iconsIndex = 119;
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[119]._objectId = yesId;
|
2017-01-01 11:51:48 -08:00
|
|
|
_confirmMode = mode;
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(65);
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(12, 117, 74);
|
2016-12-18 13:09:56 -08:00
|
|
|
_cursorPosX = 156;
|
2017-01-01 14:14:02 -08:00
|
|
|
if (_vm->shouldQuit())
|
2016-12-18 13:09:56 -08:00
|
|
|
_cursorPosX = 136;
|
|
|
|
_cursorPosY = 88;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-01 14:14:02 -08:00
|
|
|
void EdenGame::confirmYes() {
|
2016-12-19 22:32:40 -08:00
|
|
|
displayPanel();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_iconsIndex = 85;
|
|
|
|
switch (_confirmMode) {
|
2016-09-14 23:39:27 +02:00
|
|
|
case 1:
|
|
|
|
panelrestart();
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
reallyquit();
|
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-01 14:14:02 -08:00
|
|
|
void EdenGame::confirmNo() {
|
2016-12-19 22:32:40 -08:00
|
|
|
displayPanel();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_iconsIndex = 85;
|
2017-01-01 14:14:02 -08:00
|
|
|
// pomme_q = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::restart() {
|
2016-12-19 22:32:40 -08:00
|
|
|
confirmer(1, _curSpot2->_objectId);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
void EdenGame::edenQuit() {
|
|
|
|
confirmer(2, _curSpot2->_objectId);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
// Original name: choixsubtitle
|
|
|
|
void EdenGame::choseSubtitleOption() {
|
|
|
|
byte lang = _curSpot2->_objectId & 0xF;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (lang == _globals->_prefLanguage)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
|
|
|
if (lang > 5)
|
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_prefLanguage = lang;
|
2016-09-14 23:39:27 +02:00
|
|
|
langbuftopanel();
|
2016-12-19 22:32:40 -08:00
|
|
|
displayLanguage();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
// Original name: reglervol
|
|
|
|
void EdenGame::changeVolume() {
|
2017-01-01 11:51:48 -08:00
|
|
|
byte *valptr = &_globals->_prefMusicVol[_curSpot2->_objectId & 7];
|
2016-12-18 13:09:56 -08:00
|
|
|
_cursorPosY = 104 - ((*valptr >> 2) & 0x3F); // TODO: check me
|
2017-01-01 11:51:48 -08:00
|
|
|
_curSliderValuePtr = valptr;
|
|
|
|
_globals->_menuFlags |= MenuFlags::mfFlag1;
|
2016-12-19 22:32:40 -08:00
|
|
|
if (_curSpot2->_objectId & 8)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_menuFlags |= MenuFlags::mfFlag2;
|
2016-12-19 22:32:40 -08:00
|
|
|
_curSliderX = _curSpot2->sx;
|
2017-01-01 11:51:48 -08:00
|
|
|
_curSliderY = _cursorPosY;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::changervol() {
|
2016-12-18 13:09:56 -08:00
|
|
|
if (_mouseHeld) {
|
2016-12-19 22:32:40 -08:00
|
|
|
restrictCursorArea(_curSliderX - 1, _curSliderX + 3, 40, 110);
|
2017-01-01 11:51:48 -08:00
|
|
|
int16 delta = _curSliderY - _cursorPosY;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (delta == 0)
|
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
newvol(_curSliderValuePtr, delta);
|
|
|
|
if (_globals->_menuFlags & MenuFlags::mfFlag2)
|
|
|
|
newvol(_curSliderValuePtr + 1, delta);
|
2016-09-14 23:39:27 +02:00
|
|
|
cursbuftopanel();
|
2016-12-19 22:32:40 -08:00
|
|
|
displayCursors();
|
2017-01-01 11:51:48 -08:00
|
|
|
_curSliderY = _cursorPosY;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_menuFlags &= ~(MenuFlags::mfFlag1 | MenuFlags::mfFlag2);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::newvol(byte *volptr, int16 delta) {
|
|
|
|
int16 vol = *volptr / 4;
|
2016-09-14 23:39:27 +02:00
|
|
|
vol += delta;
|
|
|
|
if (vol < 0)
|
|
|
|
vol = 0;
|
|
|
|
if (vol > 63)
|
|
|
|
vol = 63;
|
|
|
|
*volptr = vol * 4;
|
2017-01-01 11:51:48 -08:00
|
|
|
_musicChannel->setVolume(_globals->_prefMusicVol[0], _globals->_prefMusicVol[1]);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::playtape() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_menuItemIdHi & 8)
|
|
|
|
_globals->_tapePtr++;
|
|
|
|
for (;; _globals->_tapePtr++) {
|
|
|
|
if (_globals->_tapePtr == &_tapes[MAX_TAPES]) {
|
|
|
|
_globals->_tapePtr--;
|
2016-09-14 23:39:27 +02:00
|
|
|
stoptape();
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_tapePtr->_textNum)
|
2016-08-18 13:15:54 +02:00
|
|
|
break;
|
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_menuFlags |= MenuFlags::mfFlag8;
|
|
|
|
_globals->_drawFlags &= ~DrawFlags::drDrawMenu;
|
|
|
|
uint16 oldRoomNum = _globals->_roomNum;
|
|
|
|
uint16 oldParty = _globals->_party;
|
|
|
|
byte oldBack = _globals->_roomBackgroundBankNum;
|
|
|
|
perso_t *oldPerso = _globals->_characterPtr;
|
|
|
|
_globals->_party = _globals->_tapePtr->_party;
|
|
|
|
_globals->_roomNum = _globals->_tapePtr->_roomNum;
|
|
|
|
_globals->_roomBackgroundBankNum = _globals->_tapePtr->_backgroundBankNum;
|
|
|
|
_globals->_dialogPtr = _globals->_tapePtr->_dialog;
|
|
|
|
_globals->_characterPtr = _globals->_tapePtr->_perso;
|
2016-12-28 03:43:13 -08:00
|
|
|
endCharacterSpeech();
|
2016-09-14 23:39:27 +02:00
|
|
|
affcurstape();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_characterPtr != oldPerso
|
|
|
|
|| _globals->_roomNum != _lastTapeRoomNum) {
|
|
|
|
_lastTapeRoomNum = _globals->_roomNum;
|
|
|
|
_globals->_curCharacterAnimPtr = nullptr;
|
|
|
|
_globals->_varCA = 0;
|
|
|
|
_globals->_characterImageBank = -1;
|
2017-01-15 22:59:50 +01:00
|
|
|
AnimEndCharacter();
|
|
|
|
loadCurrCharacter();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-28 03:43:13 -08:00
|
|
|
displayCharacterBackground();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_textNum = _globals->_tapePtr->_textNum;
|
2016-09-14 23:39:27 +02:00
|
|
|
my_bulle();
|
2016-12-25 02:17:07 -08:00
|
|
|
getDataSync();
|
|
|
|
displayCharacterPanel();
|
2016-09-14 23:39:27 +02:00
|
|
|
persovox();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomBackgroundBankNum = oldBack;
|
|
|
|
_globals->_party = oldParty;
|
|
|
|
_globals->_roomNum = oldRoomNum;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::rewindtape() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_tapePtr > _tapes) {
|
|
|
|
_globals->_tapePtr--;
|
|
|
|
_globals->_menuFlags &= ~MenuFlags::mfFlag8;
|
2016-09-14 23:39:27 +02:00
|
|
|
affcurstape();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
void EdenGame::depcurstape() {
|
2016-12-18 13:09:56 -08:00
|
|
|
if (_mouseHeld) {
|
2016-12-19 22:32:40 -08:00
|
|
|
restrictCursorArea(95, 217, 179, 183);
|
2016-12-18 13:09:56 -08:00
|
|
|
int idx = (_cursorPosX - 97);
|
2016-10-24 22:02:43 +02:00
|
|
|
if (idx < 0)
|
|
|
|
idx = 0;
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
idx /= 8;
|
2017-01-01 11:51:48 -08:00
|
|
|
tape_t *tape = _tapes + idx;
|
|
|
|
if (tape >= _tapes + 16)
|
|
|
|
tape = _tapes + 16 - 1;
|
2016-10-24 22:02:43 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
if (tape != _globals->_tapePtr) {
|
|
|
|
_globals->_tapePtr = tape;
|
2016-09-14 23:39:27 +02:00
|
|
|
affcurstape();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_menuFlags &= ~MenuFlags::mfFlag8;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
} else
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_menuFlags &= ~MenuFlags::mfFlag4;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
void EdenGame::affcurstape() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_drawFlags & DrawFlags::drDrawFlag8)
|
2016-11-13 13:56:20 -08:00
|
|
|
_noPalette = true;
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(65);
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(2, 0, 176);
|
2017-01-01 11:51:48 -08:00
|
|
|
int x = (_globals->_tapePtr - _tapes) * 8 + 97;
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[112].sx = x - 3;
|
|
|
|
_gameIcons[112].ex = x + 3;
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(5, x, 179);
|
2016-11-13 13:56:20 -08:00
|
|
|
_noPalette = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
void EdenGame::forwardtape() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_tapePtr < _tapes + 16) {
|
|
|
|
_globals->_tapePtr++;
|
|
|
|
_globals->_menuFlags &= ~MenuFlags::mfFlag8;
|
2016-09-14 23:39:27 +02:00
|
|
|
affcurstape();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::stoptape() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_drawFlags & DrawFlags::drDrawFlag8))
|
2016-08-18 13:15:54 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_menuFlags &= ~MenuFlags::mfFlag8;
|
|
|
|
_globals->_drawFlags &= ~DrawFlags::drDrawFlag8;
|
|
|
|
_globals->_menuFlags |= MenuFlags::mfFlag10;
|
|
|
|
_globals->_iconsIndex = 85;
|
|
|
|
_globals->_characterPtr = nullptr;
|
2016-12-19 22:32:40 -08:00
|
|
|
_lastTapeRoomNum = 0;
|
2016-12-28 03:43:13 -08:00
|
|
|
endCharacterSpeech();
|
2016-09-14 23:39:27 +02:00
|
|
|
fin_perso();
|
2016-12-19 22:32:40 -08:00
|
|
|
displayPanel();
|
|
|
|
displayTopPanel();
|
2016-12-18 14:13:36 -08:00
|
|
|
_paletteUpdateRequired = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
void EdenGame::cliccurstape() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_menuFlags |= MenuFlags::mfFlag4;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::paneltobuf() {
|
2016-12-27 10:11:37 -08:00
|
|
|
setSrcRect(0, 16, 320 - 1, 169 - 1);
|
|
|
|
setDestRect(320, 16, 640 - 1, 169 - 1);
|
2016-12-18 14:13:36 -08:00
|
|
|
CLBlitter_CopyViewRect(_mainView, _mainView, &rect_src, &rect_dst);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::cursbuftopanel() {
|
2016-12-27 10:11:37 -08:00
|
|
|
setSrcRect(434, 40, 525 - 1, 111 - 1);
|
|
|
|
setDestRect(114, 40, 205 - 1, 111 - 1);
|
2016-12-18 14:13:36 -08:00
|
|
|
CLBlitter_CopyViewRect(_mainView, _mainView, &rect_src, &rect_dst);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::langbuftopanel() {
|
2016-12-27 10:11:37 -08:00
|
|
|
setSrcRect(328, 42, 407 - 1, 97 - 1);
|
|
|
|
setDestRect(8, 42, 87 - 1, 97 - 1);
|
2016-12-18 14:13:36 -08:00
|
|
|
CLBlitter_CopyViewRect(_mainView, _mainView, &rect_src, &rect_dst);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
// Original name: affpanel
|
|
|
|
void EdenGame::displayPanel() {
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(65);
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(0, 0, 16);
|
|
|
|
paneltobuf();
|
2016-12-19 22:32:40 -08:00
|
|
|
displayLanguage();
|
|
|
|
displayCursors();
|
2016-09-14 23:39:27 +02:00
|
|
|
affcurstape();
|
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
// Original name: afflangue
|
|
|
|
void EdenGame::displayLanguage() {
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(65);
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_prefLanguage < 0 //TODO: never happens
|
|
|
|
|| _globals->_prefLanguage > 5)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2017-01-01 11:51:48 -08:00
|
|
|
noclipax(6, 8, _globals->_prefLanguage * 9 + 43); //TODO: * FONT_HEIGHT
|
|
|
|
noclipax(7, 77, _globals->_prefLanguage * 9 + 44);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
// Original name: affcursvol
|
|
|
|
void EdenGame::displayVolCursor(int16 x, int16 vol1, int16 vol2) {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 slider = 3;
|
2016-12-19 22:32:40 -08:00
|
|
|
if (_lastMenuItemIdLo && (_lastMenuItemIdLo & 9) != 1) //TODO check me
|
2016-09-14 23:39:27 +02:00
|
|
|
slider = 4;
|
|
|
|
noclipax(slider, x, 104 - vol1);
|
|
|
|
slider = 3;
|
2016-12-19 22:32:40 -08:00
|
|
|
if ((_lastMenuItemIdLo & 9) != 0)
|
2016-09-14 23:39:27 +02:00
|
|
|
slider = 4;
|
|
|
|
noclipax(slider, x + 12, 104 - vol2);
|
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
// Original name: affcurseurs
|
|
|
|
void EdenGame::displayCursors() {
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(65);
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_drawFlags & DrawFlags::drDrawFlag8)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-19 22:32:40 -08:00
|
|
|
selectCursor(48);
|
2017-01-01 11:51:48 -08:00
|
|
|
displayVolCursor(114, _globals->_prefMusicVol[0] / 4, _globals->_prefMusicVol[1] / 4);
|
2016-12-19 22:32:40 -08:00
|
|
|
selectCursor(50);
|
2017-01-01 11:51:48 -08:00
|
|
|
displayVolCursor(147, _globals->_prefVoiceVol[0] / 4, _globals->_prefVoiceVol[1] / 4);
|
2016-12-19 22:32:40 -08:00
|
|
|
selectCursor(52);
|
2017-01-01 11:51:48 -08:00
|
|
|
displayVolCursor(179, _globals->_prefSoundVolume[0] / 4, _globals->_prefSoundVolume[1] / 4);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
// Original name: curseurselect
|
|
|
|
void EdenGame::selectCursor(int itemId) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_lastMenuItemIdLo = _globals->_menuItemIdLo;
|
2016-12-19 22:32:40 -08:00
|
|
|
if ((_lastMenuItemIdLo & ~9) != itemId)
|
|
|
|
_lastMenuItemIdLo = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
// Original name: afftoppano
|
|
|
|
void EdenGame::displayTopPanel() {
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(1, 0, 0);
|
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
// Original name: affresult
|
|
|
|
void EdenGame::displayResult() {
|
2016-12-26 13:40:28 -08:00
|
|
|
restoreUnderSubtitles();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterPtr = &kPersons[19];
|
|
|
|
_globals->_dialogType = DialogType::dtInspect;
|
|
|
|
int16 num = (kPersons[PER_UNKN_156]._id << 3) | _globals->_dialogType;
|
2017-01-18 23:05:38 +01:00
|
|
|
if (dialoscansvmas((Dialog *)getElem(_gameDialogs, num)))
|
2016-12-25 02:17:07 -08:00
|
|
|
displaySubtitles();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_varCA = 0;
|
|
|
|
_globals->_dialogType = DialogType::dtTalk;
|
|
|
|
_globals->_characterPtr = nullptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
// Original name: limitezonecurs
|
|
|
|
void EdenGame::restrictCursorArea(int16 xmin, int16 xmax, int16 ymin, int16 ymax) {
|
2016-12-18 13:09:56 -08:00
|
|
|
_cursorPosX = CLIP(_cursorPosX, xmin, xmax);
|
|
|
|
_cursorPosY = CLIP(_cursorPosY, ymin, ymax);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
// Original name: PommeQ
|
|
|
|
void EdenGame::edenShudown() {
|
2016-12-17 09:32:43 -08:00
|
|
|
Icon *icon = &_gameIcons[85];
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags & DisplayFlags::dfFrescoes) {
|
2016-12-18 13:09:56 -08:00
|
|
|
_torchCursor = false;
|
|
|
|
_cursorSaved = true;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags & DisplayFlags::dfPerson)
|
2016-12-28 03:43:13 -08:00
|
|
|
closeCharacterScreen();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_displayFlags = DisplayFlags::dfFlag1;
|
2016-09-26 23:44:42 +02:00
|
|
|
resetScroll();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var100 = 0xFF;
|
|
|
|
updateRoom(_globals->_roomNum);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags & DisplayFlags::dfPerson)
|
2016-12-28 03:43:13 -08:00
|
|
|
closeCharacterScreen();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags & DisplayFlags::dfPanable)
|
2016-09-26 23:44:42 +02:00
|
|
|
resetScroll();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags & DisplayFlags::dfMirror)
|
2016-09-26 23:44:42 +02:00
|
|
|
resetScroll();
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_drawFlags & DrawFlags::drDrawFlag8)
|
2016-09-14 23:39:27 +02:00
|
|
|
stoptape();
|
2016-10-06 00:15:02 +02:00
|
|
|
if (_personTalking)
|
2016-12-28 03:43:13 -08:00
|
|
|
endCharacterSpeech();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var103 = 0;
|
|
|
|
_globals->_mirrorEffect = 0;
|
2016-12-04 13:15:38 -08:00
|
|
|
putObject();
|
2016-11-13 13:56:20 -08:00
|
|
|
_currCursor = 53;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_displayFlags != DisplayFlags::dfFlag2)
|
2016-12-28 03:43:13 -08:00
|
|
|
gotoPanel();
|
2016-12-19 22:32:40 -08:00
|
|
|
_curSpot2 = icon + 7; //TODO
|
|
|
|
edenQuit();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::habitants(perso_t *perso) {
|
2016-10-07 00:45:08 +02:00
|
|
|
char persType = perso->_flags & PersonFlags::pfTypeMask; //TODO rename
|
2016-09-14 23:39:27 +02:00
|
|
|
if (persType && persType != PersonFlags::pfType2) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomCharacterPtr = perso;
|
|
|
|
_globals->_roomCharacterType = persType;
|
|
|
|
_globals->_roomCharacterFlags = perso->_flags;
|
|
|
|
_globals->_roomPersoItems = perso->_items;
|
|
|
|
_globals->_roomCharacterPowers = perso->_powers;
|
|
|
|
_globals->_partyOutside |= perso->_partyMask;
|
|
|
|
if (_globals->_roomCharacterType == PersonFlags::pftTriceraptor)
|
|
|
|
removeInfo(_globals->_areaNum + ValleyNews::vnTriceraptorsIn);
|
|
|
|
else if (_globals->_roomCharacterType == PersonFlags::pftVelociraptor)
|
|
|
|
removeInfo(_globals->_areaNum + ValleyNews::vnVelociraptorsIn);
|
2016-10-07 00:45:08 +02:00
|
|
|
} else if (!(perso->_flags & PersonFlags::pfInParty))
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_partyOutside |= perso->_partyMask;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::suiveurs(perso_t *perso) {
|
2016-10-07 00:45:08 +02:00
|
|
|
char persType = perso->_flags & PersonFlags::pfTypeMask;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (persType == 0 || persType == PersonFlags::pfType2) {
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_flags & PersonFlags::pfInParty)
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_party |= perso->_partyMask;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::evenements(perso_t *perso) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_var113)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-10-24 22:02:43 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
if (perso >= &kPersons[PER_UNKN_18C])
|
|
|
|
return;
|
2016-10-24 22:02:43 +02:00
|
|
|
|
2017-01-15 22:59:50 +01:00
|
|
|
if (!dialogEvent(perso))
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-10-24 22:02:43 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var113++;
|
|
|
|
_globals->_oldDisplayFlags = 1;
|
|
|
|
perso = _globals->_characterPtr;
|
2017-01-14 00:30:37 +01:00
|
|
|
initCharacterPointers(perso);
|
2016-10-07 00:45:08 +02:00
|
|
|
if (!(perso->_partyMask & PersonMask::pmLeader))
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_var60 = 1;
|
|
|
|
_globals->_eventType = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::followme(perso_t *perso) {
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_flags & PersonFlags::pfTypeMask)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_flags & PersonFlags::pfInParty)
|
2017-01-01 11:51:48 -08:00
|
|
|
perso->_roomNum = _destinationRoom;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-17 09:32:43 -08:00
|
|
|
void EdenGame::rangermammi(perso_t *perso, Room *room) {
|
|
|
|
Room *found_room = nullptr;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (!(perso->_partyMask & PersonMask::pmLeader))
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-15 22:47:29 -08:00
|
|
|
for (; room->_id != 0xFF; room++) {
|
|
|
|
if (room->_flags & RoomFlags::rfHasCitadel) {
|
2016-09-14 23:39:27 +02:00
|
|
|
found_room = room;
|
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-15 22:47:29 -08:00
|
|
|
if (room->_party != 0xFFFF && (room->_party & PersonMask::pmLeader))
|
2016-09-14 23:39:27 +02:00
|
|
|
found_room = room; //TODO: no brk?
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-26 07:57:27 +02:00
|
|
|
if (!found_room)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_roomNum &= ~0xFF;
|
2016-12-15 22:47:29 -08:00
|
|
|
perso->_roomNum |= found_room->_location;
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags &= ~PersonFlags::pfInParty;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_party &= ~perso->_partyMask;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::perso_ici(int16 action) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso = &kPersons[PER_UNKN_156];
|
2016-08-18 13:15:54 +02:00
|
|
|
// room_t *room = p_global->last_area_ptr->room_ptr; //TODO: compiler opt bug? causes access to zero ptr??? last_area_ptr == 0
|
2016-09-14 23:39:27 +02:00
|
|
|
switch (action) {
|
|
|
|
case 0:
|
|
|
|
suiveurs(perso);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
habitants(perso);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
evenements(perso);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
followme(perso);
|
|
|
|
break;
|
|
|
|
case 5:
|
2017-01-01 11:51:48 -08:00
|
|
|
rangermammi(perso, _globals->_lastAreaPtr->_citadelRoomPtr);
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
perso = kPersons;
|
|
|
|
do {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (perso->_roomNum == _globals->_roomNum && !(perso->_flags & PersonFlags::pf80)) {
|
2016-09-14 23:39:27 +02:00
|
|
|
switch (action) {
|
|
|
|
case 0:
|
|
|
|
suiveurs(perso);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
habitants(perso);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
evenements(perso);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
followme(perso);
|
|
|
|
break;
|
|
|
|
case 5:
|
2017-01-01 11:51:48 -08:00
|
|
|
rangermammi(perso, _globals->_lastAreaPtr->_citadelRoomPtr);
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
perso++;
|
2016-10-07 00:45:08 +02:00
|
|
|
} while (perso->_roomNum != 0xFFFF);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-31 05:11:33 -08:00
|
|
|
// Original name: setpersohere
|
|
|
|
void EdenGame::setCharacterHere() {
|
2017-01-01 11:51:48 -08:00
|
|
|
debug("setCharacterHere, perso is %ld", _globals->_characterPtr - kPersons);
|
|
|
|
_globals->_partyOutside = 0;
|
|
|
|
_globals->_party = 0;
|
|
|
|
_globals->_roomCharacterPtr = nullptr;
|
|
|
|
_globals->_roomCharacterType = 0;
|
|
|
|
_globals->_roomCharacterFlags = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_ici(1);
|
|
|
|
perso_ici(0);
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_roomCharacterType == PersonFlags::pftTyrann)
|
|
|
|
removeInfo(_globals->_areaNum + ValleyNews::vnTyrannIn);
|
|
|
|
if (_globals->_roomCharacterType == PersonFlags::pftTriceraptor)
|
|
|
|
removeInfo(_globals->_areaNum + ValleyNews::vnTriceraptorsIn);
|
|
|
|
if (_globals->_roomCharacterType == PersonFlags::pftVelociraptor) {
|
|
|
|
removeInfo(_globals->_areaNum + ValleyNews::vnTyrannIn);
|
|
|
|
removeInfo(_globals->_areaNum + ValleyNews::vnTyrannLost);
|
|
|
|
removeInfo(_globals->_areaNum + ValleyNews::vnVelociraptorsLost);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::faire_suivre(int16 roomNum) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_destinationRoom = roomNum;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_ici(4);
|
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
// Original name: suis_moi5
|
|
|
|
void EdenGame::AddCharacterToParty() {
|
2017-01-01 11:51:48 -08:00
|
|
|
debug("adding person %ld to party", _globals->_characterPtr - kPersons);
|
|
|
|
_globals->_characterPtr->_flags |= PersonFlags::pfInParty;
|
|
|
|
_globals->_characterPtr->_roomNum = _globals->_roomNum;
|
|
|
|
_globals->_party |= _globals->_characterPtr->_partyMask;
|
|
|
|
_globals->_drawFlags |= DrawFlags::drDrawTopScreen;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
// Original name: suis_moi
|
2016-12-31 05:11:33 -08:00
|
|
|
void EdenGame::addToParty(int16 index) {
|
2017-01-01 11:51:48 -08:00
|
|
|
perso_t *old_perso = _globals->_characterPtr;
|
|
|
|
_globals->_characterPtr = &kPersons[index];
|
2016-12-19 22:32:40 -08:00
|
|
|
AddCharacterToParty();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterPtr = old_perso;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
// Original name: reste_ici5
|
|
|
|
void EdenGame::removeCharacterFromParty() {
|
2017-01-01 11:51:48 -08:00
|
|
|
debug("removing person %ld from party", _globals->_characterPtr - kPersons);
|
|
|
|
_globals->_characterPtr->_flags &= ~PersonFlags::pfInParty;
|
|
|
|
_globals->_partyOutside |= _globals->_characterPtr->_partyMask;
|
|
|
|
_globals->_party &= ~_globals->_characterPtr->_partyMask;
|
|
|
|
_globals->_drawFlags |= DrawFlags::drDrawTopScreen;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
// Original name: reste_ici
|
|
|
|
void EdenGame::removeFromParty(int16 index) {
|
2017-01-01 11:51:48 -08:00
|
|
|
perso_t *old_perso = _globals->_characterPtr;
|
|
|
|
_globals->_characterPtr = &kPersons[index];
|
2016-12-19 22:32:40 -08:00
|
|
|
removeCharacterFromParty();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterPtr = old_perso;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-17 10:13:15 -08:00
|
|
|
// Original name: eloipart
|
|
|
|
void EdenGame::handleEloiDeparture() {
|
2017-01-15 23:51:17 +01:00
|
|
|
removeFromParty(PER_ELOI);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_gameFlags &= ~GameFlags::gfFlag4000;
|
2017-01-15 23:51:17 +01:00
|
|
|
kPersons[PER_ELOI]._roomNum = 0;
|
|
|
|
_globals->_partyOutside &= ~kPersons[PER_ELOI]._partyMask;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_roomNum == 2817)
|
2016-12-11 13:44:58 -08:00
|
|
|
setChrono(3000);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eloiDepartureDay = _globals->_gameDays;
|
|
|
|
_globals->_eloiHaveNews = 0;
|
2016-12-11 13:44:58 -08:00
|
|
|
unlockInfo();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
// Original name: eloirevientq
|
|
|
|
bool EdenGame::checkEloiReturn() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_phaseNum < 304)
|
2016-10-07 23:06:10 +02:00
|
|
|
return true;
|
2017-01-01 11:51:48 -08:00
|
|
|
if ((_globals->_phaseNum <= 353) || (_globals->_phaseNum == 370) || (_globals->_phaseNum == 384))
|
2016-10-07 23:06:10 +02:00
|
|
|
return false;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_areaNum != Areas::arShandovra)
|
2016-10-07 23:06:10 +02:00
|
|
|
return true;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_phaseNum < 480)
|
2016-10-07 23:06:10 +02:00
|
|
|
return false;
|
|
|
|
return true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 22:32:40 -08:00
|
|
|
// Original name: eloirevient
|
|
|
|
void EdenGame::handleEloiReturn() {
|
2017-01-15 23:51:17 +01:00
|
|
|
if (_globals->_areaPtr->_type == AreaType::atValley && !kPersons[PER_ELOI]._roomNum)
|
|
|
|
kPersons[PER_ELOI]._roomNum = (_globals->_roomNum & 0xFF00) + 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
//// phase.c
|
2016-12-19 22:32:40 -08:00
|
|
|
void EdenGame::incPhase() {
|
2016-09-14 23:39:27 +02:00
|
|
|
static phase_t phases[] = {
|
|
|
|
{ 65, &EdenGame::dialautoon },
|
|
|
|
{ 113, &EdenGame::phase113 },
|
|
|
|
{ 129, &EdenGame::dialautoon },
|
|
|
|
{ 130, &EdenGame::phase130 },
|
|
|
|
{ 161, &EdenGame::phase161 },
|
|
|
|
{ 211, &EdenGame::dialautoon },
|
|
|
|
{ 226, &EdenGame::phase226 },
|
|
|
|
{ 257, &EdenGame::phase257 },
|
|
|
|
{ 353, &EdenGame::phase353 },
|
|
|
|
{ 369, &EdenGame::phase369 },
|
|
|
|
{ 371, &EdenGame::phase371 },
|
|
|
|
{ 385, &EdenGame::phase385 },
|
|
|
|
{ 386, &EdenGame::dialonfollow },
|
|
|
|
{ 418, &EdenGame::phase418 },
|
|
|
|
{ 433, &EdenGame::phase433 },
|
|
|
|
{ 434, &EdenGame::phase434 },
|
|
|
|
{ 449, &EdenGame::dialautoon },
|
|
|
|
{ 497, &EdenGame::dialautoon },
|
|
|
|
{ 513, &EdenGame::phase513 },
|
|
|
|
{ 514, &EdenGame::phase514 },
|
|
|
|
{ 529, &EdenGame::phase529 },
|
|
|
|
{ 545, &EdenGame::phase545 },
|
|
|
|
{ 561, &EdenGame::phase561 },
|
|
|
|
{ -1, nullptr }
|
|
|
|
};
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_phaseNum++;
|
|
|
|
debug("!!! next phase - %4X , room %4X", _globals->_phaseNum, _globals->_roomNum);
|
|
|
|
_globals->_phaseActionsCount = 0;
|
2016-11-14 14:51:52 -08:00
|
|
|
for (phase_t *phase = phases; phase->_id != -1; phase++) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_globals->_phaseNum == phase->_id) {
|
2016-09-14 23:39:27 +02:00
|
|
|
(this->*phase->disp)();
|
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase113() {
|
2016-12-19 22:32:40 -08:00
|
|
|
removeFromParty(PER_DINA);
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_DINA]._roomNum = 274;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase130() {
|
|
|
|
dialautoon();
|
2016-12-19 22:32:40 -08:00
|
|
|
removeFromParty(PER_MONK);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase161() {
|
2017-01-01 11:51:48 -08:00
|
|
|
Area *area = _globals->_areaPtr;
|
2016-12-31 05:11:33 -08:00
|
|
|
addToParty(PER_MAMMI);
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MAMMI]._flags |= PersonFlags::pf10;
|
2016-12-04 14:26:44 -08:00
|
|
|
area->_flags |= AreaFlags::afFlag1;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curAreaFlags |= AreaFlags::afFlag1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase226() {
|
2016-12-11 22:52:10 -08:00
|
|
|
newObject(16, 3);
|
|
|
|
newObject(16, 4);
|
|
|
|
newObject(16, 5);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase257() {
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[127]._cursorId &= ~0x8000;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterBackgroundBankIdx = 58;
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautooff();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase353() {
|
2016-12-19 22:32:40 -08:00
|
|
|
removeFromParty(PER_DINA);
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_DINA]._roomNum = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
kTabletView[1] = 88;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase369() {
|
2017-01-15 23:51:17 +01:00
|
|
|
addToParty(PER_ELOI);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_narratorSequence = 2;
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[334]._exits[0] = 134;
|
|
|
|
_gameRooms[335]._exits[0] = 134;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase371() {
|
2016-12-19 22:32:40 -08:00
|
|
|
handleEloiReturn();
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[128]._cursorId &= ~0x8000;
|
|
|
|
_gameIcons[129]._cursorId &= ~0x8000;
|
|
|
|
_gameIcons[127]._cursorId |= 0x8000;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterBackgroundBankIdx = 59;
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[334]._exits[0] = 0xFF;
|
|
|
|
_gameRooms[335]._exits[0] = 0xFF;
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[123]._objectId = 9;
|
|
|
|
_gameIcons[124]._objectId = 26;
|
|
|
|
_gameIcons[125]._objectId = 42;
|
|
|
|
_gameIcons[126]._objectId = 56;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase385() {
|
|
|
|
dialautooff();
|
2016-12-19 22:32:40 -08:00
|
|
|
handleEloiReturn();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_nextInfoIdx = 0;
|
|
|
|
_globals->_lastInfoIdx = 0;
|
2016-12-11 13:44:58 -08:00
|
|
|
updateInfoList();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_lastInfo = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase418() {
|
2016-09-26 23:44:42 +02:00
|
|
|
loseObject(Objects::obHorn);
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
2017-01-15 23:51:17 +01:00
|
|
|
addToParty(PER_JABBER);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase433() {
|
|
|
|
dialautoon();
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MAMMI_4]._flags &= ~PersonFlags::pf80;
|
2017-01-15 23:51:17 +01:00
|
|
|
kPersons[PER_JABBER]._flags &= ~PersonFlags::pf80;
|
2016-12-31 05:11:33 -08:00
|
|
|
setCharacterHere();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_chronoFlag = 0;
|
|
|
|
_globals->_chrono = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase434() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_roomNum = 275;
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[16]._bank = 44;
|
|
|
|
_gameRooms[18]._bank = 44;
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[132]._cursorId &= ~0x8000;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterBackgroundBankIdx = 61;
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[118]._exits[2] = 0xFF;
|
2017-01-14 00:30:37 +01:00
|
|
|
abortDialogue();
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[7]._bank = 322;
|
2016-12-19 22:32:40 -08:00
|
|
|
removeFromParty(PER_EVE);
|
|
|
|
removeFromParty(PER_MONK);
|
2017-01-15 23:51:17 +01:00
|
|
|
removeFromParty(PER_ELOI);
|
2016-12-28 03:43:13 -08:00
|
|
|
removeFromParty(PER_GUARDS);
|
2017-01-15 23:51:17 +01:00
|
|
|
removeFromParty(PER_JABBER);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_drawFlags |= DrawFlags::drDrawTopScreen;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase513() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_lastDialogPtr = nullptr;
|
2016-10-24 00:04:32 +02:00
|
|
|
parlemoiNormalFlag = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase514() {
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[123]._exits[2] = 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase529() {
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[133]._cursorId &= ~0x8000;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterBackgroundBankIdx = 63;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase545() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase561() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_narratorSequence = 10;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::bigphase1() {
|
|
|
|
static void (EdenGame::*bigphases[])() = {
|
|
|
|
&EdenGame::phase16,
|
|
|
|
&EdenGame::phase32,
|
|
|
|
&EdenGame::phase48,
|
|
|
|
&EdenGame::phase64,
|
|
|
|
&EdenGame::phase80,
|
|
|
|
&EdenGame::phase96,
|
|
|
|
&EdenGame::phase112,
|
|
|
|
&EdenGame::phase128,
|
|
|
|
&EdenGame::phase144,
|
|
|
|
&EdenGame::phase160,
|
|
|
|
&EdenGame::phase176,
|
|
|
|
&EdenGame::phase192,
|
|
|
|
&EdenGame::phase208,
|
|
|
|
&EdenGame::phase224,
|
|
|
|
&EdenGame::phase240,
|
|
|
|
&EdenGame::phase256,
|
|
|
|
&EdenGame::phase272,
|
|
|
|
&EdenGame::phase288,
|
|
|
|
&EdenGame::phase304,
|
|
|
|
&EdenGame::phase320,
|
|
|
|
&EdenGame::phase336,
|
|
|
|
&EdenGame::phase352,
|
|
|
|
&EdenGame::phase368,
|
|
|
|
&EdenGame::phase384,
|
|
|
|
&EdenGame::phase400,
|
|
|
|
&EdenGame::phase416,
|
|
|
|
&EdenGame::phase432,
|
|
|
|
&EdenGame::phase448,
|
|
|
|
&EdenGame::phase464,
|
|
|
|
&EdenGame::phase480,
|
|
|
|
&EdenGame::phase496,
|
|
|
|
&EdenGame::phase512,
|
|
|
|
&EdenGame::phase528,
|
|
|
|
&EdenGame::phase544,
|
|
|
|
&EdenGame::phase560
|
|
|
|
};
|
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
int16 phase = (_globals->_phaseNum & ~3) + 0x10; //TODO: check me
|
2016-09-14 23:39:27 +02:00
|
|
|
debug("!!! big phase - %4X", phase);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_phaseActionsCount = 0;
|
|
|
|
_globals->_phaseNum = phase;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (phase > 560)
|
|
|
|
return;
|
|
|
|
phase >>= 4;
|
|
|
|
(this->*bigphases[phase - 1])();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::bigphase() {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (!(_globals->_dialogPtr->_flags & DialogFlags::dfSpoken))
|
2016-09-14 23:39:27 +02:00
|
|
|
bigphase1();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase16() {
|
|
|
|
dialautoon();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase32() {
|
|
|
|
word_31E7A &= ~0x8000;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase48() {
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[8]._exits[1] = 22;
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase64() {
|
2016-12-31 05:11:33 -08:00
|
|
|
addToParty(PER_DINA);
|
2017-01-15 23:51:17 +01:00
|
|
|
kPersons[PER_ELOI]._roomNum = 259;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase80() {
|
2017-01-15 23:51:17 +01:00
|
|
|
kPersons[PER_TAU]._roomNum = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase96() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase112() {
|
2016-12-04 14:26:44 -08:00
|
|
|
giveObject();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase128() {
|
2016-12-31 05:11:33 -08:00
|
|
|
addToParty(PER_DINA);
|
2016-12-04 14:26:44 -08:00
|
|
|
giveObject();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase144() {
|
2017-01-15 23:51:17 +01:00
|
|
|
addToParty(PER_ELOI);
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[113]._video = 0;
|
|
|
|
_gameRooms[113]._bank = 317;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase160() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase176() {
|
|
|
|
dialonfollow();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase192() {
|
2017-01-01 11:51:48 -08:00
|
|
|
Area *area = _globals->_areaPtr;
|
2016-12-31 05:11:33 -08:00
|
|
|
addToParty(PER_MAMMI_1);
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MAMMI_1]._flags |= PersonFlags::pf10;
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
2016-12-04 14:26:44 -08:00
|
|
|
area->_flags |= AreaFlags::afFlag1;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curAreaFlags |= AreaFlags::afFlag1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase208() {
|
2016-12-19 22:32:40 -08:00
|
|
|
handleEloiReturn();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase224() {
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[126]._cursorId &= ~0x8000;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterBackgroundBankIdx = 57;
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautooff();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase240() {
|
2017-01-01 11:51:48 -08:00
|
|
|
Area *area = _globals->_areaPtr;
|
2016-12-31 05:11:33 -08:00
|
|
|
addToParty(PER_MAMMI_2);
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MAMMI_2]._flags |= PersonFlags::pf10;
|
2016-12-04 14:26:44 -08:00
|
|
|
area->_flags |= AreaFlags::afFlag1;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curAreaFlags |= AreaFlags::afFlag1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase256() {
|
|
|
|
dialautoon();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase272() {
|
|
|
|
dialautoon();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eloiHaveNews = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase288() {
|
2016-12-04 13:15:38 -08:00
|
|
|
setChoiceYes();
|
2017-01-15 23:51:17 +01:00
|
|
|
kPersons[PER_MUNGO]._roomNum = 0;
|
|
|
|
removeFromParty(PER_MUNGO);
|
|
|
|
addToParty(PER_ELOI);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_narratorSequence = 8;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase304() {
|
2017-01-01 11:51:48 -08:00
|
|
|
Area *area = _globals->_areaPtr;
|
2016-12-31 05:11:33 -08:00
|
|
|
addToParty(PER_EVE);
|
|
|
|
addToParty(PER_MAMMI_5);
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MAMMI_5]._flags |= PersonFlags::pf10;
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
2016-12-04 14:26:44 -08:00
|
|
|
area->_flags |= AreaFlags::afFlag1;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curAreaFlags |= AreaFlags::afFlag1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase320() {
|
|
|
|
dialonfollow();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase336() {
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[288]._exits[0] = 135;
|
|
|
|
_gameRooms[289]._exits[0] = 135;
|
2017-01-01 11:51:48 -08:00
|
|
|
loseObject(_globals->_curObjectId);
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase352() {
|
|
|
|
kPersoRoomBankTable[30] = 26;
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_EVE]._spriteBank = 9;
|
|
|
|
kPersons[PER_EVE]._targetLoc = 8;
|
2016-10-07 23:06:10 +02:00
|
|
|
followerList[13]._spriteNum = 2;
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[288]._exits[0] = 0xFF;
|
|
|
|
_gameRooms[289]._exits[0] = 0xFF;
|
|
|
|
_gameRooms[288]._flags &= ~RoomFlags::rf02;
|
|
|
|
_gameRooms[289]._flags &= ~RoomFlags::rf02;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase368() {
|
2016-12-19 22:32:40 -08:00
|
|
|
removeFromParty(PER_EVE);
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
2017-01-15 23:51:17 +01:00
|
|
|
kPersons[PER_ELOI]._roomNum = 1811;
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_DINA]._roomNum = 1607;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase384() {
|
2017-01-01 11:51:48 -08:00
|
|
|
Area *area = _globals->_areaPtr;
|
2016-12-31 05:11:33 -08:00
|
|
|
addToParty(PER_EVE);
|
2016-12-19 22:32:40 -08:00
|
|
|
removeFromParty(PER_DINA);
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
2016-12-04 14:26:44 -08:00
|
|
|
area->_flags |= AreaFlags::afFlag1;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_curAreaFlags |= AreaFlags::afFlag1;
|
2016-12-17 10:13:15 -08:00
|
|
|
handleEloiDeparture();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase400() {
|
|
|
|
dialonfollow();
|
2016-12-28 03:43:13 -08:00
|
|
|
kPersons[PER_KING]._roomNum = 0;
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MONK]._roomNum = 259;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_eloiHaveNews = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
kObjectLocations[20] = 259;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase416() {
|
2016-12-31 05:11:33 -08:00
|
|
|
addToParty(PER_MONK);
|
2016-12-04 14:26:44 -08:00
|
|
|
_gameIcons[130]._cursorId &= ~0x8000;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_characterBackgroundBankIdx = 60;
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[0]._exits[0] = 138;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase432() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_narratorSequence = 3;
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MAMMI_4]._flags |= PersonFlags::pf80;
|
2017-01-15 23:51:17 +01:00
|
|
|
kPersons[PER_JABBER]._flags |= PersonFlags::pf80;
|
|
|
|
kPersons[PER_ELOI]._roomNum = 257;
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[0]._exits[0] = 0xFF;
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_drawFlags |= DrawFlags::drDrawTopScreen;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase448() {
|
|
|
|
dialautoon();
|
2016-12-17 10:13:15 -08:00
|
|
|
handleEloiDeparture();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase464() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_areaPtr->_flags |= AreaFlags::afFlag1;
|
|
|
|
_globals->_curAreaFlags |= AreaFlags::afFlag1;
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MAMMI_6]._flags |= PersonFlags::pf10;
|
2017-01-15 23:51:17 +01:00
|
|
|
addToParty(PER_SHAZIA);
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_citadelAreaNum = _globals->_areaNum;
|
2016-09-14 23:39:27 +02:00
|
|
|
naitredino(8);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase480() {
|
2016-12-04 14:26:44 -08:00
|
|
|
giveObject();
|
2016-12-17 10:13:15 -08:00
|
|
|
newValley();
|
2016-12-19 22:32:40 -08:00
|
|
|
handleEloiReturn();
|
2016-09-14 23:39:27 +02:00
|
|
|
kTabletView[1] = 94;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase496() {
|
|
|
|
dialautoon();
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_lastDialogPtr = nullptr;
|
2016-10-24 00:04:32 +02:00
|
|
|
parlemoiNormalFlag = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase512() {
|
2016-12-19 22:32:40 -08:00
|
|
|
removeFromParty(PER_MONK);
|
|
|
|
removeFromParty(PER_EVE);
|
2017-01-15 23:51:17 +01:00
|
|
|
removeFromParty(PER_SHAZIA);
|
2016-12-28 03:43:13 -08:00
|
|
|
removeFromParty(PER_GUARDS);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase528() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_narratorSequence = 11;
|
2016-12-31 05:11:33 -08:00
|
|
|
addToParty(PER_MONK);
|
2017-01-15 23:51:17 +01:00
|
|
|
addToParty(PER_ELOI);
|
2016-12-31 05:11:33 -08:00
|
|
|
addToParty(PER_EVE);
|
2017-01-15 23:51:17 +01:00
|
|
|
addToParty(PER_SHAZIA);
|
2016-12-31 05:11:33 -08:00
|
|
|
addToParty(PER_GUARDS);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase544() {
|
2016-12-17 10:13:15 -08:00
|
|
|
handleEloiDeparture();
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
2017-01-15 23:51:17 +01:00
|
|
|
removeFromParty(PER_SHAZIA);
|
2016-12-28 03:43:13 -08:00
|
|
|
removeFromParty(PER_GUARDS);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase560() {
|
2017-01-15 23:51:17 +01:00
|
|
|
kPersons[PER_ELOI]._roomNum = 3073;
|
2016-12-18 14:13:36 -08:00
|
|
|
_gameRooms[127]._exits[1] = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
|
|
|
//// saveload.c
|
2016-09-14 23:39:27 +02:00
|
|
|
void EdenGame::savegame(char *name) {
|
2016-08-18 13:15:54 +02:00
|
|
|
// filespec_t fs;
|
2016-12-05 22:44:24 -08:00
|
|
|
// Common::File handle;
|
2016-10-08 23:31:21 +02:00
|
|
|
int32 size;
|
2016-08-18 13:15:54 +02:00
|
|
|
// CLFile_MakeStruct(0, 0, name, &fs);
|
|
|
|
// CLFile_Create(&fs);
|
|
|
|
// CLFile_SetFinderInfos(&fs, 'EDNS', 'LEDN');
|
|
|
|
// CLFile_Open(&fs, 3, handle);
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
Common::OutSaveFile *handle = g_system->getSavefileManager()->openForSaving(name);
|
|
|
|
if (!handle)
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
|
|
|
|
#define CLFile_Write(h, ptr, size) \
|
2016-10-08 23:31:21 +02:00
|
|
|
debug("writing 0x%X bytes", *size); \
|
2016-09-14 23:39:27 +02:00
|
|
|
h->write(ptr, *size);
|
|
|
|
|
|
|
|
vavaoffsetout();
|
2017-01-01 11:51:48 -08:00
|
|
|
size = (char *)(&_globals->_saveEnd) - (char *)(_globals);
|
|
|
|
CLFile_Write(handle, _globals, &size);
|
2016-12-04 14:26:44 -08:00
|
|
|
size = (char *)(&_gameIcons[134]) - (char *)(&_gameIcons[123]);
|
|
|
|
CLFile_Write(handle, &_gameIcons[123], &size);
|
2016-09-14 23:39:27 +02:00
|
|
|
lieuoffsetout();
|
|
|
|
size = (char *)(&kAreasTable[12]) - (char *)(&kAreasTable[0]);
|
|
|
|
CLFile_Write(handle, &kAreasTable[0], &size);
|
2016-12-18 14:13:36 -08:00
|
|
|
size = (char *)(&_gameRooms[423]) - (char *)(&_gameRooms[0]);
|
|
|
|
CLFile_Write(handle, &_gameRooms[0], &size);
|
2016-12-04 14:26:44 -08:00
|
|
|
size = (char *)(&_objects[42]) - (char *)(&_objects[0]);
|
|
|
|
CLFile_Write(handle, &_objects[0], &size);
|
2016-09-14 23:39:27 +02:00
|
|
|
size = (char *)(&kObjectLocations[45]) - (char *)(&kObjectLocations[0]);
|
|
|
|
CLFile_Write(handle, &kObjectLocations[0], &size);
|
2016-10-07 23:06:10 +02:00
|
|
|
size = (char *)(&followerList[14]) - (char *)(&followerList[13]);
|
|
|
|
CLFile_Write(handle, &followerList[13], &size);
|
2016-12-28 03:43:13 -08:00
|
|
|
size = (char *)(&kPersons[PER_UNKN_3DE]) - (char *)(&kPersons[PER_KING]);
|
|
|
|
CLFile_Write(handle, &kPersons[PER_KING], &size);
|
2016-09-14 23:39:27 +02:00
|
|
|
bandeoffsetout();
|
2017-01-01 11:51:48 -08:00
|
|
|
size = (char *)(&_tapes[16]) - (char *)(&_tapes[0]);
|
|
|
|
CLFile_Write(handle, &_tapes[0], &size);
|
2016-09-14 23:39:27 +02:00
|
|
|
size = (char *)(&kTabletView[6]) - (char *)(&kTabletView[0]);
|
|
|
|
CLFile_Write(handle, &kTabletView[0], &size);
|
2016-12-28 03:43:13 -08:00
|
|
|
size = (char *)(&_gameDialogs[10240]) - (char *)(&_gameDialogs[0]); //TODO: const size 10240
|
|
|
|
CLFile_Write(handle, &_gameDialogs[0], &size);
|
2016-09-14 23:39:27 +02:00
|
|
|
|
|
|
|
delete handle;
|
2016-08-18 13:15:54 +02:00
|
|
|
|
|
|
|
#undef CLFile_Write
|
|
|
|
|
|
|
|
// CLFile_Close(handle);
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
vavaoffsetin();
|
|
|
|
lieuoffsetin();
|
|
|
|
bandeoffsetin();
|
|
|
|
|
|
|
|
debug("* Game saved to %s", name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::loadrestart() {
|
|
|
|
assert(0); //TODO: this won't work atm - all snapshots are BE
|
2016-10-08 23:31:21 +02:00
|
|
|
int32 offs = 0;
|
|
|
|
int32 size;
|
2017-01-01 11:51:48 -08:00
|
|
|
size = (char *)(&_globals->_saveEnd) - (char *)(_globals);
|
|
|
|
loadpartoffile(2495, _globals, offs, size);
|
2016-09-14 23:39:27 +02:00
|
|
|
offs += size;
|
|
|
|
vavaoffsetin();
|
2016-12-04 14:26:44 -08:00
|
|
|
size = (char *)(&_gameIcons[134]) - (char *)(&_gameIcons[123]);
|
|
|
|
loadpartoffile(2495, &_gameIcons[123], offs, size);
|
2016-09-14 23:39:27 +02:00
|
|
|
offs += size;
|
|
|
|
size = (char *)(&kAreasTable[12]) - (char *)(&kAreasTable[0]);
|
|
|
|
loadpartoffile(2495, &kAreasTable[0], offs, size);
|
|
|
|
offs += size;
|
|
|
|
lieuoffsetin();
|
2016-12-18 14:13:36 -08:00
|
|
|
size = (char *)(&_gameRooms[423]) - (char *)(&_gameRooms[0]);
|
|
|
|
loadpartoffile(2495, &_gameRooms[0], offs, size);
|
2016-09-14 23:39:27 +02:00
|
|
|
offs += size;
|
2016-12-04 14:26:44 -08:00
|
|
|
size = (char *)(&_objects[42]) - (char *)(&_objects[0]);
|
|
|
|
loadpartoffile(2495, &_objects[0], offs, size);
|
2016-09-14 23:39:27 +02:00
|
|
|
offs += size;
|
|
|
|
size = (char *)(&kObjectLocations[45]) - (char *)(&kObjectLocations[0]);
|
|
|
|
loadpartoffile(2495, &kObjectLocations[0], offs, size);
|
|
|
|
offs += size;
|
2016-10-07 23:06:10 +02:00
|
|
|
size = (char *)(&followerList[14]) - (char *)(&followerList[13]);
|
|
|
|
loadpartoffile(2495, &followerList[13], offs, size);
|
2016-09-14 23:39:27 +02:00
|
|
|
offs += size;
|
2016-12-28 03:43:13 -08:00
|
|
|
size = (char *)(&kPersons[PER_UNKN_3DE]) - (char *)(&kPersons[PER_KING]);
|
|
|
|
loadpartoffile(2495, &kPersons[PER_KING], offs, size);
|
2016-09-14 23:39:27 +02:00
|
|
|
offs += size;
|
2017-01-01 11:51:48 -08:00
|
|
|
size = (char *)(&_tapes[16]) - (char *)(&_tapes[0]);
|
|
|
|
loadpartoffile(2495, &_tapes[0], offs, size);
|
2016-09-14 23:39:27 +02:00
|
|
|
offs += size;
|
|
|
|
bandeoffsetin();
|
|
|
|
size = (char *)(&kTabletView[6]) - (char *)(&kTabletView[0]);
|
|
|
|
loadpartoffile(2495, &kTabletView[0], offs, size);
|
|
|
|
offs += size;
|
2016-12-28 03:43:13 -08:00
|
|
|
size = (char *)(&_gameDialogs[10240]) - (char *)(&_gameDialogs[0]); //TODO: const size 10240
|
|
|
|
loadpartoffile(2495, &_gameDialogs[0], offs, size);
|
2016-11-13 13:56:20 -08:00
|
|
|
_gameLoaded = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::loadgame(char *name) {
|
2016-08-18 13:15:54 +02:00
|
|
|
// filespec_t fs;
|
2016-12-05 22:44:24 -08:00
|
|
|
// Common::File handle;
|
2016-08-18 13:15:54 +02:00
|
|
|
// CLFile_MakeStruct(0, 0, name, &fs);
|
|
|
|
// CLFile_Open(&fs, 3, handle);
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
Common::InSaveFile *handle = g_system->getSavefileManager()->openForLoading(name);
|
|
|
|
if (!handle)
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
|
|
|
|
#define CLFile_Read(h, ptr, size) \
|
|
|
|
h->read(ptr, *size);
|
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
int32 size = (char *)(&_globals->_saveEnd) - (char *)(_globals);
|
|
|
|
CLFile_Read(handle, _globals, &size);
|
2016-09-14 23:39:27 +02:00
|
|
|
vavaoffsetin();
|
2016-12-04 14:26:44 -08:00
|
|
|
size = (char *)(&_gameIcons[134]) - (char *)(&_gameIcons[123]);
|
|
|
|
CLFile_Read(handle, &_gameIcons[123], &size);
|
2016-09-14 23:39:27 +02:00
|
|
|
size = (char *)(&kAreasTable[12]) - (char *)(&kAreasTable[0]);
|
|
|
|
CLFile_Read(handle, &kAreasTable[0], &size);
|
|
|
|
lieuoffsetin();
|
2016-12-18 14:13:36 -08:00
|
|
|
size = (char *)(&_gameRooms[423]) - (char *)(&_gameRooms[0]);
|
|
|
|
CLFile_Read(handle, &_gameRooms[0], &size);
|
2016-12-04 14:26:44 -08:00
|
|
|
size = (char *)(&_objects[42]) - (char *)(&_objects[0]);
|
|
|
|
CLFile_Read(handle, &_objects[0], &size);
|
2016-09-14 23:39:27 +02:00
|
|
|
size = (char *)(&kObjectLocations[45]) - (char *)(&kObjectLocations[0]);
|
|
|
|
CLFile_Read(handle, &kObjectLocations[0], &size);
|
2016-10-07 23:06:10 +02:00
|
|
|
size = (char *)(&followerList[14]) - (char *)(&followerList[13]);
|
|
|
|
CLFile_Read(handle, &followerList[13], &size);
|
2016-09-14 23:39:27 +02:00
|
|
|
size = (char *)(&kPersons[55]) - (char *)(&kPersons[0]);
|
|
|
|
CLFile_Read(handle, &kPersons[0], &size);
|
2017-01-01 11:51:48 -08:00
|
|
|
size = (char *)(&_tapes[16]) - (char *)(&_tapes[0]);
|
|
|
|
CLFile_Read(handle, &_tapes[0], &size);
|
2016-09-14 23:39:27 +02:00
|
|
|
bandeoffsetin();
|
|
|
|
size = (char *)(&kTabletView[6]) - (char *)(&kTabletView[0]);
|
|
|
|
CLFile_Read(handle, &kTabletView[0], &size);
|
2016-12-28 03:43:13 -08:00
|
|
|
size = (char *)(&_gameDialogs[10240]) - (char *)(&_gameDialogs[0]); //TODO: const size 10240
|
|
|
|
CLFile_Read(handle, &_gameDialogs[0], &size);
|
2016-09-14 23:39:27 +02:00
|
|
|
|
|
|
|
delete handle;
|
2016-08-18 13:15:54 +02:00
|
|
|
#undef CLFile_Read
|
|
|
|
|
|
|
|
// CLFile_Close(handle);
|
2016-11-13 13:56:20 -08:00
|
|
|
_gameLoaded = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
debug("* Game loaded from %s", name);
|
|
|
|
}
|
|
|
|
|
2016-08-18 13:15:54 +02:00
|
|
|
#define NULLPTR (void*)0xFFFFFF
|
2016-09-14 23:39:27 +02:00
|
|
|
#define OFSOUT(val, base, typ) if (val) (val) = (typ*)((char*)(val) - (size_t)(base)); else (val) = (typ*)NULLPTR;
|
|
|
|
#define OFSIN(val, base, typ) if ((void*)(val) != NULLPTR) (val) = (typ*)((char*)(val) + (size_t)(base)); else (val) = 0;
|
|
|
|
|
|
|
|
void EdenGame::vavaoffsetout() {
|
2017-01-18 23:05:38 +01:00
|
|
|
OFSOUT(_globals->_dialogPtr, _gameDialogs, Dialog);
|
|
|
|
OFSOUT(_globals->_nextDialogPtr, _gameDialogs, Dialog);
|
|
|
|
OFSOUT(_globals->_narratorDialogPtr, _gameDialogs, Dialog);
|
|
|
|
OFSOUT(_globals->_lastDialogPtr, _gameDialogs, Dialog);
|
2017-01-01 11:51:48 -08:00
|
|
|
OFSOUT(_globals->_tapePtr, _tapes, tape_t);
|
|
|
|
OFSOUT(_globals->_nextRoomIcon, _gameIcons, Icon);
|
|
|
|
OFSOUT(_globals->_roomPtr, _gameRooms, Room);
|
|
|
|
OFSOUT(_globals->_citaAreaFirstRoom, _gameRooms, Room);
|
|
|
|
OFSOUT(_globals->_areaPtr, kAreasTable, Area);
|
|
|
|
OFSOUT(_globals->_lastAreaPtr, kAreasTable, Area);
|
|
|
|
OFSOUT(_globals->_curAreaPtr, kAreasTable, Area);
|
|
|
|
OFSOUT(_globals->_characterPtr, kPersons, perso_t);
|
|
|
|
OFSOUT(_globals->_roomCharacterPtr, kPersons, perso_t);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::vavaoffsetin() {
|
2017-01-18 23:05:38 +01:00
|
|
|
OFSIN(_globals->_dialogPtr, _gameDialogs, Dialog);
|
|
|
|
OFSIN(_globals->_nextDialogPtr, _gameDialogs, Dialog);
|
|
|
|
OFSIN(_globals->_narratorDialogPtr, _gameDialogs, Dialog);
|
|
|
|
OFSIN(_globals->_lastDialogPtr, _gameDialogs, Dialog);
|
2017-01-01 11:51:48 -08:00
|
|
|
OFSIN(_globals->_tapePtr, _tapes, tape_t);
|
|
|
|
OFSIN(_globals->_nextRoomIcon, _gameIcons, Icon);
|
|
|
|
OFSIN(_globals->_roomPtr, _gameRooms, Room);
|
|
|
|
OFSIN(_globals->_citaAreaFirstRoom, _gameRooms, Room);
|
|
|
|
OFSIN(_globals->_areaPtr, kAreasTable, Area);
|
|
|
|
OFSIN(_globals->_lastAreaPtr, kAreasTable, Area);
|
|
|
|
OFSIN(_globals->_curAreaPtr, kAreasTable, Area);
|
|
|
|
OFSIN(_globals->_characterPtr, kPersons, perso_t);
|
|
|
|
OFSIN(_globals->_roomCharacterPtr, kPersons, perso_t);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::lieuoffsetout() {
|
2016-10-24 22:02:43 +02:00
|
|
|
for (int i = 0; i < 12; i++)
|
2016-12-18 14:13:36 -08:00
|
|
|
OFSOUT(kAreasTable[i]._citadelRoomPtr, _gameRooms, Room);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::lieuoffsetin() {
|
2016-10-24 22:02:43 +02:00
|
|
|
for (int i = 0; i < 12; i++)
|
2016-12-18 14:13:36 -08:00
|
|
|
OFSIN(kAreasTable[i]._citadelRoomPtr, _gameRooms, Room);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::bandeoffsetout() {
|
2016-10-24 22:02:43 +02:00
|
|
|
for (int i = 0; i < 16; i++) {
|
2017-01-01 11:51:48 -08:00
|
|
|
OFSOUT(_tapes[i]._perso, kPersons, perso_t);
|
2017-01-18 23:05:38 +01:00
|
|
|
OFSOUT(_tapes[i]._dialog, _gameDialogs, Dialog);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::bandeoffsetin() {
|
2016-10-24 22:02:43 +02:00
|
|
|
for (int i = 0; i < 16; i++) {
|
2017-01-01 11:51:48 -08:00
|
|
|
OFSIN(_tapes[i]._perso, kPersons, perso_t);
|
2017-01-18 23:05:38 +01:00
|
|
|
OFSIN(_tapes[i]._dialog, _gameDialogs, Dialog);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-08-18 13:15:54 +02:00
|
|
|
//// cond.c
|
|
|
|
|
2016-12-25 14:20:06 -08:00
|
|
|
char EdenGame::testCondition(int16 index) {
|
2016-12-26 14:25:19 -08:00
|
|
|
bool endFl = false;
|
|
|
|
uint16 stack[32];
|
|
|
|
uint16 *sp = stack;
|
2016-09-14 23:39:27 +02:00
|
|
|
assert(index > 0);
|
2016-12-28 03:43:13 -08:00
|
|
|
_codePtr = (byte *)getElem(_gameConditions, (index - 1));
|
2016-12-26 14:25:19 -08:00
|
|
|
uint16 value;
|
2016-09-14 23:39:27 +02:00
|
|
|
do {
|
2017-01-05 02:06:50 -08:00
|
|
|
value = fetchValue();
|
2016-09-14 23:39:27 +02:00
|
|
|
for (;;) {
|
2016-12-26 14:25:19 -08:00
|
|
|
byte op = *_codePtr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (op == 0xFF) {
|
2016-12-26 14:25:19 -08:00
|
|
|
endFl = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if ((op & 0x80) == 0) {
|
2017-01-05 02:06:50 -08:00
|
|
|
uint16 value2 = fetchValue();
|
2016-08-18 13:15:54 +02:00
|
|
|
value = operation(op, value, value2);
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
|
|
|
assert(sp < stack + 32);
|
|
|
|
*sp++ = value;
|
|
|
|
*sp++ = op;
|
|
|
|
break;
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-12-26 14:25:19 -08:00
|
|
|
} while (!endFl);
|
2016-09-14 23:39:27 +02:00
|
|
|
|
|
|
|
if (sp != stack) {
|
|
|
|
*sp++ = value;
|
2016-12-26 14:25:19 -08:00
|
|
|
uint16 *sp2 = stack;
|
2016-09-14 23:39:27 +02:00
|
|
|
value = *sp2++;
|
|
|
|
do {
|
2016-12-26 14:25:19 -08:00
|
|
|
byte op = *sp2++;
|
|
|
|
uint16 value2 = *sp2++;
|
2016-09-14 23:39:27 +02:00
|
|
|
value = operation(op, value, value2);
|
|
|
|
} while (sp2 != sp);
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
// if (value)
|
2016-09-14 23:39:27 +02:00
|
|
|
debug("cond %d(-1) returns %s", index, value ? "TRUE" : "false");
|
2016-08-18 13:15:54 +02:00
|
|
|
// if (index == 402) debug("(glob_61.b == %X) & (glob_12.w == %X) & (glob_4C.b == %X) & (glob_4E.b == %X)", p_global->eventType, p_global->phaseNum, p_global->worldTyrannSighted, p_global->ff_4E);
|
2016-09-14 23:39:27 +02:00
|
|
|
return value != 0;
|
|
|
|
}
|
|
|
|
|
2016-12-25 14:20:06 -08:00
|
|
|
// Original name: opera_add
|
2016-12-26 14:25:19 -08:00
|
|
|
uint16 EdenGame::operAdd(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 + v2;
|
|
|
|
}
|
|
|
|
|
2016-12-25 14:20:06 -08:00
|
|
|
// Original name: opera_sub
|
2016-12-26 14:25:19 -08:00
|
|
|
uint16 EdenGame::operSub(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 - v2;
|
|
|
|
}
|
|
|
|
|
2016-12-25 14:20:06 -08:00
|
|
|
// Original name: opera_and
|
2016-12-26 14:25:19 -08:00
|
|
|
uint16 EdenGame::operLogicalAnd(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 & v2;
|
|
|
|
}
|
2016-12-25 14:20:06 -08:00
|
|
|
|
|
|
|
// Original name: opera_or
|
2016-12-26 14:25:19 -08:00
|
|
|
uint16 EdenGame::operLogicalOr(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 | v2;
|
|
|
|
}
|
|
|
|
|
2016-12-25 14:20:06 -08:00
|
|
|
// Original name: opera_egal
|
2016-12-26 14:25:19 -08:00
|
|
|
uint16 EdenGame::operIsEqual(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 == v2 ? -1 : 0;
|
|
|
|
}
|
|
|
|
|
2016-12-25 14:20:06 -08:00
|
|
|
// Original name: opera_petit
|
2016-12-26 14:25:19 -08:00
|
|
|
uint16 EdenGame::operIsSmaller(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 < v2 ? -1 : 0; //TODO: all comparisons are unsigned!
|
|
|
|
}
|
|
|
|
|
2016-12-25 14:20:06 -08:00
|
|
|
// Original name: opera_grand
|
2016-12-26 14:25:19 -08:00
|
|
|
uint16 EdenGame::operIsGreater(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 > v2 ? -1 : 0;
|
|
|
|
}
|
|
|
|
|
2016-12-25 14:20:06 -08:00
|
|
|
// Original name: opera_diff
|
2016-12-26 14:25:19 -08:00
|
|
|
uint16 EdenGame::operIsDifferent(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 != v2 ? -1 : 0;
|
|
|
|
}
|
|
|
|
|
2016-12-25 14:20:06 -08:00
|
|
|
// Original name: opera_petega
|
2016-12-26 14:25:19 -08:00
|
|
|
uint16 EdenGame::operIsSmallerOrEqual(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 <= v2 ? -1 : 0;
|
|
|
|
}
|
|
|
|
|
2016-12-25 14:20:06 -08:00
|
|
|
// Original name: opera_graega
|
2016-12-26 14:25:19 -08:00
|
|
|
uint16 EdenGame::operIsGreaterOrEqual(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 >= v2 ? -1 : 0;
|
|
|
|
}
|
|
|
|
|
2016-12-25 14:20:06 -08:00
|
|
|
// Original name: opera_faux
|
2016-12-26 14:25:19 -08:00
|
|
|
uint16 EdenGame::operFalse(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 EdenGame::operation(byte op, uint16 v1, uint16 v2) {
|
|
|
|
static uint16(EdenGame::*operations[16])(uint16, uint16) = {
|
2016-12-25 14:20:06 -08:00
|
|
|
&EdenGame::operIsEqual,
|
|
|
|
&EdenGame::operIsSmaller,
|
|
|
|
&EdenGame::operIsGreater,
|
|
|
|
&EdenGame::operIsDifferent,
|
|
|
|
&EdenGame::operIsSmallerOrEqual,
|
|
|
|
&EdenGame::operIsGreaterOrEqual,
|
|
|
|
&EdenGame::operAdd,
|
|
|
|
&EdenGame::operSub,
|
|
|
|
&EdenGame::operLogicalAnd,
|
|
|
|
&EdenGame::operLogicalOr,
|
|
|
|
&EdenGame::operFalse,
|
|
|
|
&EdenGame::operFalse,
|
|
|
|
&EdenGame::operFalse,
|
|
|
|
&EdenGame::operFalse,
|
|
|
|
&EdenGame::operFalse,
|
|
|
|
&EdenGame::operFalse
|
2016-09-14 23:39:27 +02:00
|
|
|
};
|
|
|
|
return (this->*operations[(op & 0x1F) >> 1])(v1, v2);
|
|
|
|
}
|
|
|
|
|
2017-01-05 02:06:50 -08:00
|
|
|
// Original name: cher_valeur
|
|
|
|
uint16 EdenGame::fetchValue() {
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 val;
|
2016-12-25 14:20:06 -08:00
|
|
|
byte typ = *_codePtr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (typ < 0x80) {
|
2016-12-25 14:20:06 -08:00
|
|
|
byte ofs = *_codePtr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (typ == 1)
|
2017-01-01 11:51:48 -08:00
|
|
|
val = *(byte *)(ofs + (byte *)_globals);
|
2016-09-14 23:39:27 +02:00
|
|
|
else
|
2017-01-01 11:51:48 -08:00
|
|
|
val = *(uint16 *)(ofs + (byte *)_globals);
|
2016-09-14 23:39:27 +02:00
|
|
|
} else if (typ == 0x80)
|
2016-12-25 14:20:06 -08:00
|
|
|
val = *_codePtr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
else {
|
2016-12-25 14:20:06 -08:00
|
|
|
val = READ_LE_UINT16(_codePtr);
|
|
|
|
_codePtr += 2;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2016-12-25 23:14:03 -08:00
|
|
|
// Original name: ret
|
|
|
|
void EdenGame::actionNop() {
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-08-18 13:15:54 +02:00
|
|
|
//// cube.c
|
2016-12-25 23:14:03 -08:00
|
|
|
// Original name: make_tabcos
|
2017-01-17 07:18:32 +01:00
|
|
|
void EdenGame::initSinCosTable() {
|
2016-10-08 21:26:22 +02:00
|
|
|
for (int i = 0; i < 361; i++) {
|
2017-01-17 07:18:32 +01:00
|
|
|
_cosTable[i] = (int)(cos(3.1416 * i / 180.0) * 255.0);
|
|
|
|
_sinTable[i] = (int)(sin(3.1416 * i / 180.0) * 255.0);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-17 00:02:31 +01:00
|
|
|
void EdenGame::makeMatriceFix() {
|
|
|
|
int16 rotAngleTheta = _rotationAngleX;
|
|
|
|
int16 rotAnglePhi = _rotationAngleY;
|
|
|
|
int16 rotAnglePsi = _rotationAngleZ;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2017-01-17 07:18:32 +01:00
|
|
|
_passMat31 = (_cosTable[rotAnglePhi] * _cosTable[rotAngleTheta]) >> 8;
|
|
|
|
_passMat32 = (_sinTable[rotAnglePhi] * _cosTable[rotAngleTheta]) >> 8;
|
|
|
|
_passMat33 = -_sinTable[rotAngleTheta];
|
|
|
|
_passMat21 = ((-_sinTable[rotAnglePhi] * _cosTable[rotAnglePsi]) >> 8)
|
|
|
|
+ ((_sinTable[rotAnglePsi] * ((_cosTable[rotAnglePhi] * _sinTable[rotAngleTheta]) >> 8)) >> 8);
|
|
|
|
_passMat22 = ((_cosTable[rotAnglePhi] * _cosTable[rotAnglePsi]) >> 8)
|
|
|
|
+ ((_sinTable[rotAnglePsi] * ((_sinTable[rotAnglePhi] * _sinTable[rotAngleTheta]) >> 8)) >> 8);
|
|
|
|
_passMat23 = (_cosTable[rotAngleTheta] * _sinTable[rotAnglePsi]) >> 8;
|
|
|
|
_passMat11 = ((_sinTable[rotAnglePhi] * _sinTable[rotAnglePsi]) >> 8)
|
|
|
|
+ ((_cosTable[rotAnglePsi] * ((_cosTable[rotAnglePhi] * _sinTable[rotAngleTheta]) >> 8)) >> 8);
|
|
|
|
_passMat12 = ((-_cosTable[rotAnglePhi] * _sinTable[rotAnglePsi]) >> 8)
|
|
|
|
+ ((_cosTable[rotAnglePsi] * ((_sinTable[rotAnglePhi] * _sinTable[rotAngleTheta]) >> 8)) >> 8);
|
|
|
|
_passMat13 = (_cosTable[rotAngleTheta] * _cosTable[rotAnglePsi]) >> 8;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-18 22:33:00 +01:00
|
|
|
void EdenGame::projectionFix(Cube *cubep, int n) {
|
2016-10-08 21:26:22 +02:00
|
|
|
for (int i = 0; i < n; i++) {
|
2017-01-18 22:33:00 +01:00
|
|
|
int x = cubep->_vertices[i].x;
|
|
|
|
int y = cubep->_vertices[i].y;
|
|
|
|
int z = cubep->_vertices[i].z;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2017-01-17 00:02:31 +01:00
|
|
|
int transformX = _passMat31 * x + _passMat21 * y + _passMat11 * z + (int)(_translationX * 256.0f);
|
|
|
|
int transformY = _passMat32 * x + _passMat22 * y + _passMat12 * z + (int)(_translationY * 256.0f);
|
|
|
|
int transformZ = _passMat33 * x + _passMat23 * y + _passMat13 * z + (int)(_translationZ * 256.0f);
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2017-01-17 00:02:31 +01:00
|
|
|
transformZ >>= 8;
|
|
|
|
if (transformZ == -256)
|
|
|
|
transformZ++;
|
2017-01-18 07:24:39 +01:00
|
|
|
cubep->_projection[i].x = transformX / (transformZ + 256) + _cursorPosX + 14 + _scrollPos;
|
|
|
|
cubep->_projection[i].y = transformY / (transformZ + 256) + _cursorPosY + 14;
|
|
|
|
cubep->_projection[i].z = transformZ;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-10-25 23:32:15 +02:00
|
|
|
// Original name init_cube
|
|
|
|
void EdenGame::initCubeMac() {
|
2017-01-01 11:51:48 -08:00
|
|
|
loadMap(2493, _cubeTexture);
|
|
|
|
NEWcharge_objet_mob(&_cube, 2494, _cubeTexture);
|
2017-01-17 07:18:32 +01:00
|
|
|
initSinCosTable();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
void EdenGame::engineMac() {
|
2016-09-14 23:39:27 +02:00
|
|
|
Eden_dep_and_rot();
|
2017-01-17 00:02:31 +01:00
|
|
|
makeMatriceFix();
|
2017-01-01 11:51:48 -08:00
|
|
|
projectionFix(&_cube, _cubeFaces);
|
|
|
|
displayObject(&_cube);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 23:14:03 -08:00
|
|
|
// Original name: affiche_objet
|
2017-01-18 22:33:00 +01:00
|
|
|
void EdenGame::displayObject(Cube *cubep) {
|
2017-01-01 11:51:48 -08:00
|
|
|
for (int i = 0; i < cubep->_num; i++)
|
|
|
|
displayPolygoneMapping(cubep, cubep->_faces[i]);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-25 23:14:03 -08:00
|
|
|
// Original name: NEWcharge_map
|
|
|
|
void EdenGame::loadMap(int file_id, byte *buffer) {
|
2016-11-09 13:40:08 -08:00
|
|
|
if (_vm->getPlatform() == Common::kPlatformMacintosh) {
|
2016-10-17 03:05:37 +03:00
|
|
|
loadpartoffile(file_id, buffer, 32, 256 * 3);
|
|
|
|
|
2016-10-24 22:02:43 +02:00
|
|
|
for (int i = 0; i < 256; i++) {
|
2016-10-17 03:05:37 +03:00
|
|
|
color3_t color;
|
|
|
|
color.r = buffer[i * 3] << 8;
|
|
|
|
color.g = buffer[i * 3 + 1] << 8;
|
|
|
|
color.b = buffer[i * 3 + 2] << 8;
|
2016-12-25 13:45:47 -08:00
|
|
|
CLPalette_SetRGBColor(_globalPalette, i, &color);
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
2016-12-25 13:45:47 -08:00
|
|
|
CLPalette_Send2Screen(_globalPalette, 0, 256);
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-10-17 03:05:37 +03:00
|
|
|
loadpartoffile(file_id, buffer, 32 + 256 * 3, 0x4000);
|
|
|
|
} else {
|
|
|
|
#if 0
|
|
|
|
// Fake Mac cursor on PC
|
|
|
|
Common::File f;
|
|
|
|
if (f.open("curs.raw")) {
|
|
|
|
f.seek(32);
|
|
|
|
f.read(buffer, 256 * 3);
|
|
|
|
|
|
|
|
for (i = 0; i < 256; i++) {
|
|
|
|
color3_t color;
|
|
|
|
color.r = buffer[i * 3] << 8;
|
|
|
|
color.g = buffer[i * 3 + 1] << 8;
|
|
|
|
color.b = buffer[i * 3 + 2] << 8;
|
|
|
|
CLPalette_SetRGBColor(global_palette, i, &color);
|
|
|
|
}
|
|
|
|
CLPalette_Send2Screen(global_palette, 0, 256);
|
|
|
|
|
|
|
|
f.read(buffer, 0x4000);
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-10-17 03:05:37 +03:00
|
|
|
f.close();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
error("can not load cursor texture");
|
|
|
|
#endif
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2017-01-18 22:33:00 +01:00
|
|
|
void EdenGame::NEWcharge_objet_mob(Cube *cubep, int fileNum, byte *texturePtr) {
|
2016-11-14 14:51:52 -08:00
|
|
|
char *tmp1 = (char *)malloc(454);
|
2016-11-09 13:40:08 -08:00
|
|
|
if (_vm->getPlatform() == Common::kPlatformMacintosh)
|
2016-12-28 03:43:13 -08:00
|
|
|
loadpartoffile(fileNum, tmp1, 0, 454);
|
2016-10-17 03:05:37 +03:00
|
|
|
else {
|
|
|
|
#if 0
|
|
|
|
// Fake Mac cursor on PC
|
|
|
|
Common::File f;
|
|
|
|
if (f.open("curseden.mob")) {
|
|
|
|
f.read(tmp1, 454);
|
|
|
|
f.close();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
::error("can not load cursor model");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-11-14 14:51:52 -08:00
|
|
|
char *next = tmp1;
|
|
|
|
char error;
|
2017-01-01 11:51:48 -08:00
|
|
|
_cubeFaces = nextVal(&next, &error);
|
2017-01-18 22:33:00 +01:00
|
|
|
Point3D *vertices = (Point3D *)malloc(_cubeFaces * sizeof(*vertices));
|
|
|
|
Point3D *projection = (Point3D *)malloc(_cubeFaces * sizeof(*projection));
|
2017-01-01 11:51:48 -08:00
|
|
|
for (int i = 0; i < _cubeFaces; i++) {
|
2017-01-18 22:33:00 +01:00
|
|
|
vertices[i].x = nextVal(&next, &error);
|
|
|
|
vertices[i].y = nextVal(&next, &error);
|
|
|
|
vertices[i].z = nextVal(&next, &error);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-12-31 05:11:33 -08:00
|
|
|
int count2 = nextVal(&next, &error);
|
2017-01-18 22:33:00 +01:00
|
|
|
CubeFace **tmp4 = (CubeFace **)malloc(count2 * sizeof(*tmp4));
|
2016-10-08 21:26:22 +02:00
|
|
|
for (int i = 0; i < count2; i++) {
|
2017-01-18 22:33:00 +01:00
|
|
|
tmp4[i] = (CubeFace *)malloc(sizeof(CubeFace));
|
2016-09-14 23:39:27 +02:00
|
|
|
tmp4[i]->tri = 3;
|
2016-12-31 05:11:33 -08:00
|
|
|
char textured = nextVal(&next, &error);
|
|
|
|
tmp4[i]->ff_5 = nextVal(&next, &error);
|
2017-01-01 11:51:48 -08:00
|
|
|
tmp4[i]->_indices = (uint16 *)malloc(3 * sizeof(*tmp4[i]->_indices));
|
|
|
|
tmp4[i]->_uv = (int16 *)malloc(3 * 2 * sizeof(*tmp4[i]->_uv));
|
2016-10-08 21:26:22 +02:00
|
|
|
for (int j = 0; j < 3; j++) {
|
2017-01-01 11:51:48 -08:00
|
|
|
tmp4[i]->_indices[j] = nextVal(&next, &error);
|
2016-08-18 13:15:54 +02:00
|
|
|
if (textured) {
|
2017-01-01 11:51:48 -08:00
|
|
|
tmp4[i]->_uv[j * 2] = nextVal(&next, &error);
|
|
|
|
tmp4[i]->_uv[j * 2 + 1] = nextVal(&next, &error);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
if (textured) {
|
|
|
|
tmp4[i]->ff_4 = 3;
|
2016-12-28 03:43:13 -08:00
|
|
|
tmp4[i]->_texturePtr = texturePtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else
|
|
|
|
tmp4[i]->ff_4 = 0;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
free(tmp1);
|
2017-01-01 11:51:48 -08:00
|
|
|
cubep->_num = count2;
|
|
|
|
cubep->_faces = tmp4;
|
|
|
|
cubep->_projection = projection;
|
|
|
|
cubep->_vertices = vertices;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-31 05:11:33 -08:00
|
|
|
int EdenGame::nextVal(char **ptr, char *error) {
|
2016-09-14 23:39:27 +02:00
|
|
|
char c = 0;
|
|
|
|
char *p = *ptr;
|
|
|
|
int val = strtol(p, 0, 10);
|
2016-11-14 14:51:52 -08:00
|
|
|
while ((*p >= '0' && *p <= '9' && *p != 0) || *p == '-')
|
|
|
|
p++;
|
|
|
|
while ((*p == 13 || *p == 10 || *p == ',' || *p == ' ') && *p)
|
|
|
|
c = *p++;
|
2016-09-14 23:39:27 +02:00
|
|
|
*error = c == 10;
|
|
|
|
*ptr = p;
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2016-12-25 23:14:03 -08:00
|
|
|
void EdenGame::selectMap(int16 num) {
|
2016-12-03 15:26:32 -08:00
|
|
|
static const char mapMode[12] = { 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 2, 0 };
|
|
|
|
// Cube faces to texture coords mapping
|
|
|
|
// each entry is num_polys(6) * num_faces_per_poly(2) * vertex_per_face(3) * uv(2)
|
|
|
|
|
|
|
|
static const int16 cube_texcoords[3][6 * 2 * 3 * 2] = {
|
|
|
|
{
|
|
|
|
32, 32, 0, 32, 0, 0,
|
|
|
|
32, 32, 0, 0, 32, 0,
|
|
|
|
|
|
|
|
0, 32, 0, 0, 32, 0,
|
|
|
|
0, 32, 32, 0, 32, 32,
|
|
|
|
|
|
|
|
32, 32, 0, 32, 0, 0,
|
|
|
|
32, 32, 0, 0, 32, 0,
|
|
|
|
|
|
|
|
32, 0, 32, 32, 0, 32,
|
|
|
|
32, 0, 0, 32, 0, 0,
|
|
|
|
|
|
|
|
0, 0, 32, 0, 32, 32,
|
|
|
|
0, 0, 32, 32, 0, 32,
|
|
|
|
|
|
|
|
0, 32, 0, 0, 32, 0,
|
|
|
|
0, 32, 32, 0, 32, 32
|
|
|
|
}, {
|
|
|
|
32, 32, 0, 32, 0, 0,
|
|
|
|
32, 32, 0, 0, 32, 0,
|
|
|
|
|
|
|
|
32, 0, 32, 32, 0, 32,
|
|
|
|
32, 0, 0, 32, 0, 0,
|
|
|
|
|
|
|
|
32, 0, 32, 32, 0, 32,
|
|
|
|
32, 0, 0, 32, 0, 0,
|
|
|
|
|
|
|
|
0, 32, 0, 0, 32, 0,
|
|
|
|
0, 32, 32, 0, 32, 32,
|
|
|
|
|
|
|
|
32, 0, 32, 32, 0, 32,
|
|
|
|
32, 0, 0, 32, 0, 0,
|
|
|
|
|
|
|
|
32, 0, 32, 32, 0, 32,
|
|
|
|
32, 0, 0, 32, 0, 0
|
|
|
|
}, {
|
|
|
|
30, 30, 2, 30, 2, 2,
|
|
|
|
30, 30, 2, 2, 30, 2,
|
|
|
|
|
|
|
|
2, 30, 2, 2, 30, 2,
|
|
|
|
2, 30, 30, 2, 30, 30,
|
|
|
|
|
|
|
|
30, 30, 2, 30, 2, 2,
|
|
|
|
30, 30, 2, 2, 30, 2,
|
|
|
|
|
|
|
|
30, 2, 30, 30, 2, 30,
|
|
|
|
30, 2, 2, 30, 2, 2,
|
|
|
|
|
|
|
|
2, 2, 30, 2, 30, 30,
|
|
|
|
2, 2, 30, 30, 2, 30,
|
|
|
|
|
|
|
|
2, 30, 2, 2, 30, 2,
|
|
|
|
2, 30, 30, 2, 30, 30
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
_cursCurPCMap = num;
|
2016-11-14 14:51:52 -08:00
|
|
|
int16 k = 0;
|
2016-12-03 15:26:32 -08:00
|
|
|
int mode = mapMode[num];
|
2016-11-14 14:51:52 -08:00
|
|
|
int16 x = (num & 7) * 32;
|
|
|
|
int16 y = (num & 0x18) * 4;
|
|
|
|
for (int i = 0; i < 6 * 2; i++) {
|
|
|
|
for (int j = 0; j < 3; j++) {
|
2017-01-01 11:51:48 -08:00
|
|
|
_cube._faces[i]->_uv[j * 2 ] = x + cube_texcoords[mode][k++];
|
|
|
|
_cube._faces[i]->_uv[j * 2 + 1] = y + cube_texcoords[mode][k++];
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-11-14 14:51:52 -08:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::Eden_dep_and_rot() {
|
2016-11-14 14:51:52 -08:00
|
|
|
int16 curs = _currCursor;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_normalCursor && (_globals->_drawFlags & DrawFlags::drDrawFlag20))
|
2016-09-14 23:39:27 +02:00
|
|
|
curs = 10;
|
2016-12-25 23:14:03 -08:00
|
|
|
selectMap(curs);
|
2017-01-05 02:06:50 -08:00
|
|
|
_cursorNewTick = g_system->getMillis();
|
2016-12-25 23:14:03 -08:00
|
|
|
if (_cursorNewTick - _cursorOldTick < 1)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-12-25 23:14:03 -08:00
|
|
|
|
|
|
|
_cursorOldTick = _cursorNewTick;
|
2016-11-13 13:56:20 -08:00
|
|
|
switch (_currCursor) {
|
2016-09-14 23:39:27 +02:00
|
|
|
case 0:
|
2017-01-17 00:02:31 +01:00
|
|
|
_rotationAngleZ = (_rotationAngleZ + 2) % 360;
|
|
|
|
_rotationAngleX = (_rotationAngleX + 2) % 360;
|
2016-09-14 23:39:27 +02:00
|
|
|
restoreZDEP();
|
|
|
|
break;
|
|
|
|
case 1:
|
2017-01-17 00:02:31 +01:00
|
|
|
_rotationAngleZ = 0;
|
|
|
|
_rotationAngleX -= 2;
|
|
|
|
if (_rotationAngleX < 0)
|
|
|
|
_rotationAngleX += 360;
|
2016-09-14 23:39:27 +02:00
|
|
|
restoreZDEP();
|
|
|
|
break;
|
|
|
|
case 2:
|
2017-01-17 00:02:31 +01:00
|
|
|
_rotationAngleZ = (_rotationAngleZ + 2) % 360;
|
|
|
|
_rotationAngleX = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
restoreZDEP();
|
|
|
|
break;
|
|
|
|
case 3:
|
2017-01-17 00:02:31 +01:00
|
|
|
_rotationAngleZ -= 2;
|
|
|
|
if (_rotationAngleZ < 0)
|
|
|
|
_rotationAngleZ += 360;
|
|
|
|
_rotationAngleX = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
restoreZDEP();
|
|
|
|
break;
|
|
|
|
case 4:
|
2017-01-17 00:02:31 +01:00
|
|
|
_rotationAngleZ = 0;
|
|
|
|
_rotationAngleX = (_rotationAngleX + 2) % 360;
|
2016-09-14 23:39:27 +02:00
|
|
|
restoreZDEP();
|
|
|
|
break;
|
|
|
|
case 5:
|
2017-01-17 00:02:31 +01:00
|
|
|
_rotationAngleZ = 0;
|
|
|
|
_rotationAngleX = 0;
|
|
|
|
_translationZ += flt_2DF84;
|
|
|
|
if ((_translationZ < -3600.0 + flt_2DF80) || _translationZ > flt_2DF80)
|
2016-09-14 23:39:27 +02:00
|
|
|
flt_2DF84 = -flt_2DF84;
|
|
|
|
break;
|
|
|
|
case 6:
|
2017-01-17 00:02:31 +01:00
|
|
|
_rotationAngleZ = 0;
|
|
|
|
_rotationAngleX = 0;
|
|
|
|
_translationZ = flt_2DF80;
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
case 7:
|
2017-01-17 00:02:31 +01:00
|
|
|
_rotationAngleZ -= 2;
|
|
|
|
if (_rotationAngleZ < 0)
|
|
|
|
_rotationAngleZ += 360;
|
|
|
|
_rotationAngleX = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
restoreZDEP();
|
|
|
|
break;
|
|
|
|
case 8:
|
2017-01-17 00:02:31 +01:00
|
|
|
_rotationAngleZ = 0;
|
|
|
|
_rotationAngleX = 0;
|
|
|
|
_translationZ = flt_2DF80;
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
case 9:
|
2017-01-17 00:02:31 +01:00
|
|
|
_rotationAngleZ = 0;
|
|
|
|
_rotationAngleX = 0;
|
|
|
|
_translationZ = flt_2DF80;
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
void EdenGame::restoreZDEP() {
|
|
|
|
flt_2DF84 = 200.0;
|
2017-01-17 00:02:31 +01:00
|
|
|
if (_translationZ < flt_2DF80)
|
|
|
|
_translationZ += flt_2DF84;
|
|
|
|
if (_translationZ > flt_2DF80)
|
|
|
|
_translationZ -= flt_2DF84;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
// Original name: affiche_polygone_mapping
|
2017-01-18 22:33:00 +01:00
|
|
|
void EdenGame::displayPolygoneMapping(Cube *cubep, CubeFace *face) {
|
2017-01-01 11:51:48 -08:00
|
|
|
uint16 *indices = face->_indices;
|
2017-01-18 07:24:39 +01:00
|
|
|
int idx = indices[0];
|
|
|
|
int16 projX0 = cubep->_projection[idx].x;
|
|
|
|
int16 projY0 = cubep->_projection[idx].y;
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2017-01-18 07:24:39 +01:00
|
|
|
idx = indices[1];
|
|
|
|
int16 projX1 = cubep->_projection[idx].x;
|
|
|
|
int16 projY1 = cubep->_projection[idx].y;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2017-01-18 07:24:39 +01:00
|
|
|
idx = indices[2];
|
|
|
|
int16 projX2 = cubep->_projection[idx].x;
|
|
|
|
int16 projY2 = cubep->_projection[idx].y;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2017-01-18 07:24:39 +01:00
|
|
|
if ((projY1 - projY0) * (projX2 - projX0) - (projY2 - projY0) * (projX1 - projX0) > 0)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
int16 *uv = face->_uv;
|
2016-11-14 22:07:39 -08:00
|
|
|
int16 ymin = 200; // min y
|
|
|
|
int16 ymax = 0; // max y
|
2017-01-18 07:24:39 +01:00
|
|
|
idx = indices[0];
|
|
|
|
int16 r20 = cubep->_projection[idx].x;
|
|
|
|
int16 r30 = cubep->_projection[idx].y;
|
2016-11-14 22:07:39 -08:00
|
|
|
int16 r19 = *uv++;
|
|
|
|
int16 r18 = *uv++;
|
2016-09-14 23:39:27 +02:00
|
|
|
indices++;
|
2017-01-01 11:51:48 -08:00
|
|
|
for (int i = 0; i < face->tri - 1; i++, indices++) {
|
2017-01-18 07:24:39 +01:00
|
|
|
idx = indices[0];
|
|
|
|
int16 r26 = cubep->_projection[idx].x;
|
|
|
|
int16 r31 = cubep->_projection[idx].y;
|
2016-11-14 22:07:39 -08:00
|
|
|
uint16 r25 = *uv++; //TODO: unsigned
|
|
|
|
int16 r24 = *uv++; //TODO: unsigned
|
2017-01-18 07:24:39 +01:00
|
|
|
ymin = MIN(r30, ymin);
|
|
|
|
ymax = MAX(r30, ymax);
|
|
|
|
ymin = MIN(r31, ymin);
|
|
|
|
ymax = MAX(r31, ymax);
|
2016-12-28 03:43:13 -08:00
|
|
|
drawMappingLine(r20, r30, r26, r31, r19, r18, r25, r24, _lines);
|
2016-09-14 23:39:27 +02:00
|
|
|
r20 = r26;
|
|
|
|
r30 = r31;
|
|
|
|
r19 = r25;
|
|
|
|
r18 = r24;
|
|
|
|
}
|
2017-01-18 07:24:39 +01:00
|
|
|
idx = face->_indices[0];
|
|
|
|
int16 r26 = cubep->_projection[idx].x;
|
|
|
|
int16 r31 = cubep->_projection[idx].y;
|
2017-01-01 11:51:48 -08:00
|
|
|
uv = face->_uv;
|
|
|
|
uint16 r25 = *uv++;
|
|
|
|
int16 r24 = *uv;
|
2017-01-18 07:24:39 +01:00
|
|
|
ymin = MIN(r30, ymin);
|
|
|
|
ymax = MAX(r30, ymax);
|
|
|
|
ymin = MIN(r31, ymin);
|
|
|
|
ymax = MAX(r31, ymax);
|
2016-12-28 03:43:13 -08:00
|
|
|
drawMappingLine(r20, r30, r26, r31, r19, r18, r25, r24, _lines);
|
|
|
|
displayMappingLine(ymin, ymax, _mainView->_bufferPtr, face->_texturePtr);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: trace_ligne_mapping
|
|
|
|
void EdenGame::drawMappingLine(int16 r3, int16 r4, int16 r5, int16 r6, int16 r7, int16 r8, int16 r9, int16 r10, int16 *linesp) {
|
2016-11-14 22:07:39 -08:00
|
|
|
int16 r26 = r6 - r4;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (r26 <= 0) {
|
|
|
|
if (r26 == 0) {
|
2016-10-08 21:21:21 +02:00
|
|
|
linesp += r4 * 8;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (r5 - r3 > 0) {
|
2016-10-08 21:21:21 +02:00
|
|
|
linesp[0] = r3;
|
|
|
|
linesp[1] = r5;
|
|
|
|
linesp[4] = r7;
|
|
|
|
linesp[5] = r9;
|
|
|
|
linesp[6] = r8;
|
|
|
|
linesp[7] = r10;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-10-08 21:21:21 +02:00
|
|
|
linesp[0] = r5;
|
|
|
|
linesp[1] = r3;
|
|
|
|
linesp[4] = r9;
|
|
|
|
linesp[5] = r7;
|
|
|
|
linesp[6] = r10;
|
|
|
|
linesp[7] = r8;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
|
|
|
}
|
2016-11-14 22:07:39 -08:00
|
|
|
int16 t = r3;
|
2016-09-14 23:39:27 +02:00
|
|
|
r3 = r5;
|
|
|
|
r5 = t;
|
|
|
|
t = r7;
|
|
|
|
r7 = r9;
|
|
|
|
r9 = t;
|
|
|
|
t = r8;
|
|
|
|
r8 = r10;
|
|
|
|
r10 = t;
|
2016-10-08 21:21:21 +02:00
|
|
|
linesp += r6 * 8;
|
2016-09-14 23:39:27 +02:00
|
|
|
r26 = -r26;
|
|
|
|
} else
|
2016-10-08 21:21:21 +02:00
|
|
|
linesp += r4 * 8 + 1; //TODO wha???
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-11-14 22:07:39 -08:00
|
|
|
int r30 = r3 << 16;
|
|
|
|
int r29 = r7 << 16;
|
|
|
|
int r28 = r8 << 16;
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-11-14 22:07:39 -08:00
|
|
|
int r25 = ((r5 - r3) << 16) / r26;
|
|
|
|
int r24 = ((r9 - r7) << 16) / r26;
|
|
|
|
int r23 = ((r10 - r8) << 16) / r26;
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-11-14 22:07:39 -08:00
|
|
|
for (int i = 0; i < r26; i++) {
|
2016-10-08 21:21:21 +02:00
|
|
|
linesp[0] = r30 >> 16;
|
|
|
|
linesp[4] = r29 >> 16;
|
|
|
|
linesp[6] = r28 >> 16;
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
r30 += r25;
|
|
|
|
r29 += r24;
|
|
|
|
r28 += r23;
|
2016-10-08 21:21:21 +02:00
|
|
|
linesp += 8;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-12-28 03:43:13 -08:00
|
|
|
// Original name: affiche_ligne_mapping
|
|
|
|
void EdenGame::displayMappingLine(int16 r3, int16 r4, byte *target, byte *texture) {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 height = r4 - r3;
|
2016-12-18 14:13:36 -08:00
|
|
|
byte *trg_line = _mainView->_bufferPtr + r3 * 640; //TODO: target??
|
2016-11-15 09:39:49 +01:00
|
|
|
int16 *line = &_lines[r3 * 8];
|
2016-09-14 23:39:27 +02:00
|
|
|
// debug("curs: beg draw %d - %d", r3, r4);
|
2016-11-14 22:07:39 -08:00
|
|
|
for (int r22 = height; r22; r22--, line += 8, trg_line += 640) {
|
|
|
|
int16 r29 = line[0];
|
|
|
|
int16 r28 = line[1];
|
|
|
|
int16 len = r28 - r29;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (len < 0)
|
|
|
|
break;
|
|
|
|
if (len == 0)
|
|
|
|
continue;
|
2016-11-14 22:07:39 -08:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
// debug("curs: lin draw %d", r4 - height);
|
2016-11-14 22:07:39 -08:00
|
|
|
uint16 r31 = line[4] << 8;
|
|
|
|
uint16 r30 = line[6] << 8;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-11-14 22:07:39 -08:00
|
|
|
int16 r21 = line[5] - line[4];
|
|
|
|
int16 r20 = line[7] - line[6];
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-11-14 22:07:39 -08:00
|
|
|
int16 r26 = (r21 << 8) / len;
|
|
|
|
int16 r25 = (r20 << 8) / len;
|
|
|
|
byte *trg = trg_line + r29;
|
2016-08-18 13:15:54 +02:00
|
|
|
#if 1
|
2016-09-14 23:39:27 +02:00
|
|
|
while (r29++ < r28) {
|
|
|
|
*trg++ = texture[(r30 & 0xFF00) | (r31 >> 8)];
|
|
|
|
r31 += r26;
|
|
|
|
r30 += r25;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
#endif
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-10-17 03:05:37 +03:00
|
|
|
// PC cursor
|
2017-01-18 22:33:00 +01:00
|
|
|
CubeCursor _cursorsPC[9] = {
|
2016-10-17 03:05:37 +03:00
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, 3, 2 },
|
2016-11-06 16:49:12 +03:00
|
|
|
{ { 1, 1, 0, 1, 1, 0 }, 2, -2 },
|
2016-10-17 03:05:37 +03:00
|
|
|
{ { 2, 2, 2, 2, 2, 2 }, 1, 2 },
|
|
|
|
{ { 3, 3, 3, 3, 3, 3 }, 1, -2 },
|
|
|
|
{ { 4, 4, 4, 4, 4, 4 }, 2, 2 },
|
|
|
|
{ { 5, 5, 5, 5, 5, 5 }, 4, 0 },
|
|
|
|
{ { 6, 6, 6, 6, 6, 6 }, 1, 2 },
|
|
|
|
{ { 7, 7, 7, 7, 7, 7 }, 1, -2 },
|
|
|
|
// { { 0, 8, 0, 0, 8, 8 }, 2, 2 },
|
|
|
|
{ { 0, 8, 0, 0, 8, 8 }, 2, 2 }
|
|
|
|
};
|
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
XYZ _cubePC[6][3] = {
|
2016-10-17 03:05:37 +03:00
|
|
|
{ { -15, -15, -15 }, { -15, 15, -15 }, { 15, 15, -15 } },
|
|
|
|
{ { -15, -15, 15 }, { -15, 15, 15 }, { -15, 15, -15 } },
|
|
|
|
{ { -15, -15, 15 }, { -15, -15, -15 }, { 15, -15, -15 } },
|
|
|
|
{ { 15, -15, 15 }, { 15, 15, 15 }, { -15, 15, 15 } },
|
|
|
|
{ { 15, -15, -15 }, { 15, 15, -15 }, { 15, 15, 15 } },
|
|
|
|
{ { 15, 15, 15 }, { 15, 15, -15 }, { -15, 15, -15 } }
|
|
|
|
};
|
|
|
|
|
2017-01-01 11:51:48 -08:00
|
|
|
signed short cosineTable[] = {
|
2016-10-17 03:05:37 +03:00
|
|
|
// = cos(n) << 7; n += 10;
|
|
|
|
128, 126, 120, 111, 98, 82, 64, 44, 22, 0, -22, -44, -64, -82, -98, -111, -120, -126,
|
|
|
|
-128, -126, -120, -111, -98, -82, -64, -44, -22, 0, 22, 44, 64, 82, 98, 111, 120, 126,
|
|
|
|
128, 126, 120, 111, 98, 82, 64, 44, 22, 0
|
|
|
|
};
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
void EdenGame::makeTables() {
|
2016-11-14 22:07:39 -08:00
|
|
|
for (int i = -15; i < 15; i++) {
|
2016-10-17 03:05:37 +03:00
|
|
|
int v = (i * 11) / 15 + 11;
|
|
|
|
tab1[i + 15] = v;
|
|
|
|
tab2[i + 15] = v * 22;
|
|
|
|
}
|
|
|
|
|
2016-11-14 22:07:39 -08:00
|
|
|
for (int i = 0; i < 36; i++) {
|
|
|
|
for (int j = -35; j < 36; j++)
|
2017-01-01 11:51:48 -08:00
|
|
|
tab3[i][j + 35] = (cosineTable[i] * j) >> 7;
|
2016-11-14 22:07:39 -08:00
|
|
|
}
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
void EdenGame::getSinCosTables(unsigned short angle, signed char **cos_table, signed char **sin_table) {
|
2016-11-14 22:07:39 -08:00
|
|
|
angle /= 2;
|
2016-10-17 03:05:37 +03:00
|
|
|
*cos_table = tab3[angle] + 35;
|
|
|
|
|
2016-11-14 22:07:39 -08:00
|
|
|
angle += 9;
|
|
|
|
if (angle >= 36)
|
|
|
|
angle -= 36;
|
|
|
|
|
2016-10-17 03:05:37 +03:00
|
|
|
*sin_table = tab3[angle] + 35;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
void EdenGame::rotatePoint(XYZ *point, XYZ *rpoint) {
|
2016-10-17 03:05:37 +03:00
|
|
|
// see http://www.cprogramming.com/tutorial/3d/rotation.html
|
|
|
|
XYZ xrot;
|
|
|
|
|
|
|
|
xrot.x = point->x;
|
2016-12-25 13:45:47 -08:00
|
|
|
xrot.y = _cosX[point->y] + _sinX[point->z];
|
|
|
|
xrot.z = _sinX[-point->y] + _cosX[point->z];
|
2016-10-17 03:05:37 +03:00
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
rpoint->x = _cosY[xrot.x] + _sinY[-xrot.z];
|
2016-10-17 03:05:37 +03:00
|
|
|
rpoint->y = xrot.y;
|
2016-12-25 13:45:47 -08:00
|
|
|
rpoint->z = _sinY[xrot.x] + _cosY[xrot.z];
|
2016-10-17 03:05:37 +03:00
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
rpoint->z += _zoomZ;
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
void EdenGame::mapPoint(XYZ *point, short *x, short *y) {
|
2016-10-17 03:05:37 +03:00
|
|
|
*y = ((12800 / point->z) * point->y) >> 7;
|
|
|
|
*x = ((12800 / point->z) * point->x) >> 7;
|
|
|
|
}
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
short EdenGame::calcFaceArea(XYZ *face) {
|
2016-10-17 03:05:37 +03:00
|
|
|
XYZ rpoint;
|
|
|
|
short x[3], y[3];
|
|
|
|
|
2016-11-14 22:07:39 -08:00
|
|
|
for (int i = 0; i < 3; i++) {
|
2016-12-25 13:45:47 -08:00
|
|
|
rotatePoint(&face[i], &rpoint);
|
|
|
|
mapPoint(&rpoint, &x[i], &y[i]);
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-11-14 22:07:39 -08:00
|
|
|
short area = (y[1] - y[0]) * (x[2] - x[0]) - (y[2] - y[0]) * (x[1] - x[0]);
|
2016-10-17 03:05:37 +03:00
|
|
|
|
|
|
|
return area;
|
|
|
|
}
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
void EdenGame::paintPixel(XYZ *point, unsigned char pixel) {
|
2016-10-17 03:05:37 +03:00
|
|
|
short x, y;
|
2016-12-25 13:45:47 -08:00
|
|
|
mapPoint(point, &x, &y);
|
|
|
|
_cursorCenter[y * 40 + x] = pixel;
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
void EdenGame::paintFace0(XYZ *point) {
|
2016-10-17 03:05:37 +03:00
|
|
|
XYZ rpoint;
|
2016-11-14 22:07:39 -08:00
|
|
|
for (int y = -15; y < 15; y++) {
|
|
|
|
for (int x = -15; x < 15; x++) {
|
2016-10-17 03:05:37 +03:00
|
|
|
point->x = x;
|
|
|
|
point->y = y;
|
2016-12-25 13:45:47 -08:00
|
|
|
rotatePoint(point, &rpoint);
|
|
|
|
paintPixel(&rpoint, _face[0][tab1[x + 15] + tab2[y + 15]]);
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
2016-11-14 22:07:39 -08:00
|
|
|
}
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
void EdenGame::paintFace1(XYZ *point) {
|
2016-10-17 03:05:37 +03:00
|
|
|
XYZ rpoint;
|
2016-11-14 22:07:39 -08:00
|
|
|
for (int y = -15; y < 15; y++) {
|
|
|
|
for (int x = -15; x < 15; x++) {
|
2016-10-17 03:05:37 +03:00
|
|
|
point->y = y;
|
|
|
|
point->z = -x;
|
2016-12-25 13:45:47 -08:00
|
|
|
rotatePoint(point, &rpoint);
|
|
|
|
paintPixel(&rpoint, _face[1][tab1[x + 15] + tab2[y + 15]]);
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
2016-11-14 22:07:39 -08:00
|
|
|
}
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
void EdenGame::paintFace2(XYZ *point) {
|
2016-10-17 03:05:37 +03:00
|
|
|
XYZ rpoint;
|
2016-11-14 22:07:39 -08:00
|
|
|
for (int y = -15; y < 15; y++) {
|
|
|
|
for (int x = -15; x < 15; x++) {
|
2016-10-17 03:05:37 +03:00
|
|
|
point->x = x;
|
|
|
|
point->z = -y;
|
2016-12-25 13:45:47 -08:00
|
|
|
rotatePoint(point, &rpoint);
|
|
|
|
paintPixel(&rpoint, _face[2][tab1[x + 15] + tab2[y + 15]]);
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
2016-11-14 22:07:39 -08:00
|
|
|
}
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
void EdenGame::paintFace3(XYZ *point) {
|
2016-10-17 03:05:37 +03:00
|
|
|
XYZ rpoint;
|
2016-11-14 22:07:39 -08:00
|
|
|
for (int y = -15; y < 15; y++) {
|
|
|
|
for (int x = -15; x < 15; x++) {
|
2016-10-17 03:05:37 +03:00
|
|
|
point->x = -x;
|
|
|
|
point->y = -y;
|
2016-12-25 13:45:47 -08:00
|
|
|
rotatePoint(point, &rpoint);
|
|
|
|
paintPixel(&rpoint, _face[3][tab1[x + 15] + tab2[y + 15]]);
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
2016-11-14 22:07:39 -08:00
|
|
|
}
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
void EdenGame::paintFace4(XYZ *point) {
|
2016-10-17 03:05:37 +03:00
|
|
|
XYZ rpoint;
|
2016-11-14 22:07:39 -08:00
|
|
|
for (int y = -15; y < 15; y++) {
|
|
|
|
for (int x = -15; x < 15; x++) {
|
2016-10-17 03:05:37 +03:00
|
|
|
point->y = y;
|
|
|
|
point->z = x;
|
2016-12-25 13:45:47 -08:00
|
|
|
rotatePoint(point, &rpoint);
|
|
|
|
paintPixel(&rpoint, _face[4][tab1[x + 15] + tab2[y + 15]]);
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
2016-11-14 22:07:39 -08:00
|
|
|
}
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
void EdenGame::paintFace5(XYZ *point) {
|
2016-10-17 03:05:37 +03:00
|
|
|
XYZ rpoint;
|
2016-11-14 22:07:39 -08:00
|
|
|
for (int y = -15; y < 15; y++) {
|
|
|
|
for (int x = -15; x < 15; x++) {
|
2016-10-17 03:05:37 +03:00
|
|
|
point->x = x;
|
2016-11-06 16:49:12 +03:00
|
|
|
point->z = y;
|
2016-12-25 13:45:47 -08:00
|
|
|
rotatePoint(point, &rpoint);
|
|
|
|
paintPixel(&rpoint, _face[5][tab1[x + 15] + tab2[y + 15]]);
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
2016-11-14 22:07:39 -08:00
|
|
|
}
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
void EdenGame::paintFaces() {
|
2016-10-17 03:05:37 +03:00
|
|
|
XYZ point;
|
2016-12-25 13:45:47 -08:00
|
|
|
if (!(_faceSkip & 1)) {
|
2016-10-17 03:05:37 +03:00
|
|
|
point.z = -15;
|
2016-12-25 13:45:47 -08:00
|
|
|
paintFace0(&point);
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
2016-12-25 13:45:47 -08:00
|
|
|
if (!(_faceSkip & 2)) {
|
2016-10-17 03:05:37 +03:00
|
|
|
point.x = -15;
|
2016-12-25 13:45:47 -08:00
|
|
|
paintFace1(&point);
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
2016-12-25 13:45:47 -08:00
|
|
|
if (!(_faceSkip & 4)) {
|
2016-10-17 03:05:37 +03:00
|
|
|
point.y = -15;
|
2016-12-25 13:45:47 -08:00
|
|
|
paintFace2(&point);
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
2016-12-25 13:45:47 -08:00
|
|
|
if (!(_faceSkip & 8)) {
|
2016-10-17 03:05:37 +03:00
|
|
|
point.z = 15;
|
2016-12-25 13:45:47 -08:00
|
|
|
paintFace3(&point);
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
2016-12-25 13:45:47 -08:00
|
|
|
if (!(_faceSkip & 16)) {
|
2016-10-17 03:05:37 +03:00
|
|
|
point.x = 15;
|
2016-12-25 13:45:47 -08:00
|
|
|
paintFace4(&point);
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
2016-12-25 13:45:47 -08:00
|
|
|
if (!(_faceSkip & 32)) {
|
2016-10-17 03:05:37 +03:00
|
|
|
point.y = 15;
|
2016-12-25 13:45:47 -08:00
|
|
|
paintFace5(&point);
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
void EdenGame::renderCube() {
|
|
|
|
for (int i = 0; i < sizeof(_cursor); i++)
|
|
|
|
_cursor[i] = 0;
|
|
|
|
_cursorCenter = &_cursor[40 * 20 + 20];
|
2016-10-17 03:05:37 +03:00
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
getSinCosTables(_angleX, &_cosX, &_sinX);
|
|
|
|
getSinCosTables(_angleY, &_cosY, &_sinY);
|
|
|
|
getSinCosTables(_angleZ, &_cosZ, &_sinZ);
|
2016-10-17 03:05:37 +03:00
|
|
|
|
2016-11-14 22:07:39 -08:00
|
|
|
for (int i = 0; i < 6; i++) {
|
2017-01-01 11:51:48 -08:00
|
|
|
int area = calcFaceArea(_cubePC[i]);
|
2016-10-17 03:05:37 +03:00
|
|
|
if (area <= 0) {
|
2016-11-15 09:39:49 +01:00
|
|
|
_face[i] = _newface[i]; // set new texture for invisible area,
|
2016-12-25 13:45:47 -08:00
|
|
|
_faceSkip |= 1 << i; // but don't draw it just yet
|
2016-11-14 22:07:39 -08:00
|
|
|
} else
|
2016-12-25 13:45:47 -08:00
|
|
|
_faceSkip &= ~(1 << i);
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
paintFaces();
|
2016-10-17 03:05:37 +03:00
|
|
|
|
|
|
|
const int xshift = -5; // TODO: temporary fix to decrease left margin
|
2016-12-25 13:45:47 -08:00
|
|
|
unsigned char *cur = _cursor;
|
2016-12-18 14:13:36 -08:00
|
|
|
unsigned char *scr = _mainView->_bufferPtr + _cursorPosX + _scrollPos + xshift + _cursorPosY * _mainView->_pitch;
|
2016-10-17 03:05:37 +03:00
|
|
|
|
|
|
|
for (int y = 0; y < 40; y++) {
|
|
|
|
for (int x = 0; x < 40; x++) {
|
2016-12-18 14:13:36 -08:00
|
|
|
if (x + _cursorPosX + _scrollPos + xshift < _mainView->_pitch && y + _cursorPosY < _mainView->_height)
|
2016-10-17 03:05:37 +03:00
|
|
|
if (*cur)
|
|
|
|
*scr = *cur;
|
|
|
|
scr++;
|
|
|
|
cur++;
|
|
|
|
}
|
2016-12-18 14:13:36 -08:00
|
|
|
scr += _mainView->_pitch - 40;
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-18 14:13:36 -08:00
|
|
|
void EdenGame::incAngleX(int step) {
|
2016-12-25 13:45:47 -08:00
|
|
|
_angleX += step;
|
|
|
|
if (_angleX == 70 + 2)
|
|
|
|
_angleX = 0;
|
|
|
|
if (_angleX == 0 - 2)
|
|
|
|
_angleX = 70;
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-12-18 14:13:36 -08:00
|
|
|
void EdenGame::decAngleX() {
|
2016-12-25 13:45:47 -08:00
|
|
|
if (_angleX != 0)
|
|
|
|
_angleX -= (_angleX > 4) ? 4 : 2;
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-12-18 14:13:36 -08:00
|
|
|
void EdenGame::incAngleY(int step) {
|
2016-12-25 13:45:47 -08:00
|
|
|
_angleY += step;
|
|
|
|
if (_angleY == 70 + 2)
|
|
|
|
_angleY = 0;
|
|
|
|
if (_angleY == 0 - 2)
|
|
|
|
_angleY = 70;
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-12-18 14:13:36 -08:00
|
|
|
void EdenGame::decAngleY() {
|
2016-12-25 13:45:47 -08:00
|
|
|
if (_angleY != 0)
|
|
|
|
_angleY -= (_angleY > 4) ? 4 : 2;
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-12-18 14:13:36 -08:00
|
|
|
void EdenGame::incZoom() {
|
2016-12-25 13:45:47 -08:00
|
|
|
if (_zoomZ == 170)
|
|
|
|
_zoomZStep = 40;
|
2017-01-01 11:51:48 -08:00
|
|
|
else if (_zoomZ == 570)
|
2016-12-25 13:45:47 -08:00
|
|
|
_zoomZStep = -40;
|
|
|
|
_zoomZ += _zoomZStep;
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-12-18 14:13:36 -08:00
|
|
|
void EdenGame::decZoom() {
|
2016-12-25 13:45:47 -08:00
|
|
|
if (_zoomZ != 170) {
|
|
|
|
if (_zoomZ < 170)
|
|
|
|
_zoomZ = 170;
|
2016-10-17 03:05:37 +03:00
|
|
|
else
|
2016-12-25 13:45:47 -08:00
|
|
|
_zoomZ -= 40;
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-25 23:32:15 +02:00
|
|
|
void EdenGame::initCubePC() {
|
2016-12-25 13:45:47 -08:00
|
|
|
_zoomZ = 170;
|
|
|
|
_zoomZStep = 40;
|
|
|
|
_angleX = _angleY = _angleZ = 0;
|
2017-01-01 11:51:48 -08:00
|
|
|
_pcCursor = &_cursorsPC[0];
|
|
|
|
_cursCurPCMap = -1;
|
2016-12-25 13:45:47 -08:00
|
|
|
makeTables();
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
void EdenGame::selectPCMap(int16 num) {
|
2017-01-01 11:51:48 -08:00
|
|
|
if (num != _cursCurPCMap) {
|
|
|
|
_pcCursor = &_cursorsPC[num];
|
2016-12-04 14:54:58 -08:00
|
|
|
unsigned char *bank = _mainBankBuf + READ_LE_UINT16(_mainBankBuf);
|
2016-10-17 03:05:37 +03:00
|
|
|
for (int i = 0; i < 6; i++) {
|
2016-12-25 13:45:47 -08:00
|
|
|
_newface[i] = 4 + (unsigned char*)getElem(bank, _pcCursor->_sides[i]);
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_cursCurPCMap == -1)
|
2016-11-15 09:39:49 +01:00
|
|
|
_face[i] = _newface[i];
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
2017-01-01 11:51:48 -08:00
|
|
|
_cursCurPCMap = num;
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-25 13:45:47 -08:00
|
|
|
void EdenGame::enginePC() {
|
2016-11-14 22:07:39 -08:00
|
|
|
int16 curs = _currCursor;
|
2017-01-01 11:51:48 -08:00
|
|
|
if (_normalCursor && (_globals->_drawFlags & DrawFlags::drDrawFlag20))
|
2016-10-17 03:05:37 +03:00
|
|
|
curs = 9;
|
2016-12-25 13:45:47 -08:00
|
|
|
selectPCMap(curs);
|
2017-01-05 02:06:50 -08:00
|
|
|
_cursorNewTick = g_system->getMillis();
|
2016-12-25 23:14:03 -08:00
|
|
|
if (_cursorNewTick - _cursorOldTick < 1)
|
2016-10-17 03:05:37 +03:00
|
|
|
return;
|
2016-12-25 23:14:03 -08:00
|
|
|
_cursorOldTick = _cursorNewTick;
|
2017-01-01 11:51:48 -08:00
|
|
|
int step = _pcCursor->_speed;
|
|
|
|
switch (_pcCursor->_kind) {
|
2016-10-17 03:05:37 +03:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1: // rot up-down
|
2016-12-18 14:13:36 -08:00
|
|
|
decAngleY();
|
|
|
|
decZoom();
|
|
|
|
incAngleX(step);
|
2016-10-17 03:05:37 +03:00
|
|
|
break;
|
|
|
|
case 2: // rot left-right
|
2016-12-18 14:13:36 -08:00
|
|
|
decAngleX();
|
|
|
|
decZoom();
|
|
|
|
incAngleY(step);
|
2016-10-17 03:05:37 +03:00
|
|
|
break;
|
|
|
|
case 3: // rotate random
|
2016-12-18 14:13:36 -08:00
|
|
|
decZoom();
|
|
|
|
incAngleX(step);
|
|
|
|
incAngleY(step);
|
2016-10-17 03:05:37 +03:00
|
|
|
break;
|
|
|
|
case 4: // zoom in-out
|
2016-11-15 09:39:49 +01:00
|
|
|
_face[0] = _newface[0];
|
2016-12-18 14:13:36 -08:00
|
|
|
decAngleY();
|
|
|
|
decAngleX();
|
|
|
|
incZoom();
|
2016-10-17 03:05:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2016-12-25 13:45:47 -08:00
|
|
|
renderCube();
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
2016-08-18 13:15:54 +02:00
|
|
|
////// macgame.c
|
|
|
|
//void MyDlgHook() { }
|
|
|
|
//void PrepareReply() { }
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 EdenGame::OpenDialog(void *arg1, void *arg2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
//TODO
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-08-18 13:15:54 +02:00
|
|
|
//void SaveDialog() { }
|
|
|
|
//void LostEdenMac_SavePrefs() { }
|
|
|
|
//void LostEdenMac_LoadPrefs() { }
|
2016-09-14 23:39:27 +02:00
|
|
|
|
|
|
|
void EdenGame::LostEdenMac_InitPrefs() {
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_prefLanguage = 1;
|
2016-09-30 07:48:27 +02:00
|
|
|
_doubledScreen = false; // TODO: set to true
|
2017-01-01 11:51:48 -08:00
|
|
|
_globals->_prefMusicVol[0] = 192;
|
|
|
|
_globals->_prefMusicVol[1] = 192;
|
|
|
|
_globals->_prefVoiceVol[0] = 255;
|
|
|
|
_globals->_prefVoiceVol[1] = 255;
|
|
|
|
_globals->_prefSoundVolume[0] = 32;
|
|
|
|
_globals->_prefSoundVolume[1] = 32;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-08-18 13:15:54 +02:00
|
|
|
//void MacGame_DoAbout() { }
|
|
|
|
//void MacGame_DoAdjustMenus() { }
|
|
|
|
//void LostEdenMac_DoPreferences() { }
|
|
|
|
//void MacGame_DoSave() { }
|
|
|
|
//void MacGame_DoMenuCommand() { }
|
|
|
|
//void MacGame_DoOpen() { }
|
|
|
|
//void MacGame_DoSaveAs() { }
|
|
|
|
|
|
|
|
} // namespace Cryo
|