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) {
|
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;
|
|
|
|
torchCursor = false;
|
|
|
|
_curBankNum = 0;
|
2016-10-09 01:44:52 +03:00
|
|
|
glow_h = glow_w = glow_y = glow_x = 0;
|
2016-10-25 23:32:15 +02:00
|
|
|
needPaletteUpdate = false;
|
2016-10-09 00:01:32 +03:00
|
|
|
curs_saved = false;
|
|
|
|
showBlackBars = false;
|
2016-10-25 23:32:15 +02:00
|
|
|
fond_saved = false;
|
2016-10-09 00:01:32 +03:00
|
|
|
bank_data_ptr = nullptr;
|
|
|
|
tyranPtr = nullptr;
|
|
|
|
last_anim_frame_num = cur_anim_frame_num = 0;
|
|
|
|
_lastAnimTicks = 0;
|
|
|
|
cur_perso_rect = nullptr;
|
2016-10-09 01:44:52 +03:00
|
|
|
num_anim_frames = max_perso_desc = num_img_desc = 0;
|
2016-10-25 23:32:15 +02:00
|
|
|
restartAnimation = animationActive = false;
|
2016-10-09 01:44:52 +03:00
|
|
|
animationDelay = animationIndex = lastAnimationIndex = 0;
|
2016-10-09 00:01:32 +03:00
|
|
|
dword_30724 = dword_30728 = dword_3072C = animationTable = nullptr;
|
|
|
|
perso_img_bank_data_ptr = nullptr;
|
2016-10-25 23:32:15 +02:00
|
|
|
savedUnderSubtitles = false;
|
2016-10-09 01:44:52 +03:00
|
|
|
num_text_lines = 0;
|
2016-10-09 00:01:32 +03:00
|
|
|
text_ptr = nullptr;
|
2016-10-09 01:44:52 +03:00
|
|
|
textoutptr = textout = nullptr;
|
2016-10-09 00:01:32 +03:00
|
|
|
currentSpecialObject = nullptr;
|
2016-10-09 01:44:52 +03:00
|
|
|
word_30AFC = 0;
|
2016-10-24 00:04:32 +02:00
|
|
|
parlemoiNormalFlag = false;
|
2016-11-28 22:33:39 -08:00
|
|
|
closeCharacterDialog = false;
|
2016-10-09 01:44:52 +03:00
|
|
|
dword_30B04 = 0;
|
2016-10-09 00:01:32 +03:00
|
|
|
lastPhrasesFile = 0;
|
|
|
|
dialogSkipFlags = 0;
|
|
|
|
voiceSamplesBuffer = nullptr;
|
2016-11-13 15:46:36 -08:00
|
|
|
needToFade = false;
|
2016-10-09 00:01:32 +03:00
|
|
|
lastMusicNum = 0;
|
|
|
|
main_bank_buf = nullptr;
|
|
|
|
music_buf = nullptr;
|
|
|
|
gameLipsync = nullptr;
|
|
|
|
gamePhrases = nullptr;
|
|
|
|
gameDialogs = nullptr;
|
|
|
|
gameConditions = nullptr;
|
|
|
|
sal_buf = nullptr;
|
|
|
|
bank_data_buf = nullptr;
|
|
|
|
gameIcons = nullptr;
|
|
|
|
gameRooms = nullptr;
|
|
|
|
bigfile_header = nullptr;
|
|
|
|
glow_buffer = nullptr;
|
|
|
|
gameFont = nullptr;
|
|
|
|
p_global = nullptr;
|
2016-10-09 01:44:52 +03:00
|
|
|
mouse_y_center = mouse_x_center = 0;
|
2016-10-09 00:01:32 +03:00
|
|
|
bufferAllocationErrorFl = quit_flag2 = quit_flag3 = false;
|
|
|
|
gameStarted = false;
|
|
|
|
_soundAllocated = false;
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel = _voiceChannel = nullptr;
|
2016-11-17 15:40:07 -08:00
|
|
|
_hnmSoundChannel = nullptr;
|
2016-10-09 00:01:32 +03:00
|
|
|
voiceSound = nullptr;
|
|
|
|
p_view2 = p_underSubtitlesView = p_subtitlesview = p_underBarsView = p_mainview = p_hnmview = nullptr;
|
|
|
|
_hnmContext = nullptr;
|
|
|
|
_doubledScreen = false;
|
|
|
|
curs_x_pan = 0;
|
|
|
|
_inventoryScrollDelay = 0;
|
|
|
|
curs_y = curs_x = 0;
|
2016-11-13 13:56:20 -08:00
|
|
|
_currCursor = 0;
|
2016-10-09 00:01:32 +03:00
|
|
|
current_spot = current_spot2 = nullptr;
|
2016-11-13 13:56:20 -08:00
|
|
|
pomme_q = false;
|
2016-10-09 00:01:32 +03:00
|
|
|
keybd_held = false;
|
2016-10-25 23:32:15 +02:00
|
|
|
mouse_held = false;
|
|
|
|
normalCursor = false;
|
2016-11-13 13:56:20 -08:00
|
|
|
showVideoSubtitle = false;
|
2016-10-09 00:01:32 +03:00
|
|
|
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-11-13 13:56:20 -08:00
|
|
|
musicPlaying = false;
|
2016-10-09 00:01:32 +03:00
|
|
|
mus_samples_ptr = mus_patterns_ptr = mus_sequence_ptr = nullptr;
|
2016-10-22 14:15:45 +03:00
|
|
|
mus_enabled = false;
|
2016-10-09 00:01:32 +03:00
|
|
|
pCurrentObjectLocation = nullptr;
|
2016-10-09 01:44:52 +03:00
|
|
|
byte_31D64 = false;
|
2016-11-13 13:56:20 -08:00
|
|
|
_noPalette = false;
|
|
|
|
_gameLoaded = false;
|
2016-10-09 01:44:52 +03:00
|
|
|
memset(tapes, 0, sizeof(tapes));
|
|
|
|
confirmMode = 0;
|
|
|
|
cur_slider_value_ptr = nullptr;
|
|
|
|
lastMenuItemIdLo = 0;
|
|
|
|
lastTapeRoomNum = 0;
|
|
|
|
cur_slider_x = cur_slider_y = 0;
|
|
|
|
destinationRoom = 0;
|
|
|
|
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
|
|
|
|
2016-10-21 23:11:03 +03:00
|
|
|
word_32448 = word_3244A = word_3244C = 0;
|
|
|
|
flt_32450 = flt_32454 = 0.0; //TODO: never changed, make consts?
|
|
|
|
curs_old_tick = 0;
|
|
|
|
|
2016-10-17 03:05:37 +03:00
|
|
|
invIconsBase = 19;
|
2016-11-09 13:40:08 -08:00
|
|
|
// invIconsCount = (_vm->getPlatform() == Common::kPlatformMacintosh) ? 9 : 11;
|
2016-10-17 03:05:37 +03:00
|
|
|
invIconsCount = 11;
|
|
|
|
roomIconsBase = invIconsBase + invIconsCount;
|
|
|
|
|
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-09-30 07:48:27 +02:00
|
|
|
p_mainview->_normal._srcLeft = _scrollPos;
|
|
|
|
p_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-09-29 07:43:13 +02:00
|
|
|
p_mainview->_normal._srcLeft = 0;
|
|
|
|
p_mainview->_zoom._srcLeft = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-25 23:17:25 +02:00
|
|
|
void EdenGame::scrollFrescoes() {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (curs_y > 16 && curs_y < 176) {
|
2016-10-24 22:02:43 +02:00
|
|
|
if (curs_x >= 0 && curs_x < 32 && _scrollPos > 3)
|
2016-09-30 07:48:27 +02:00
|
|
|
_scrollPos -= 4;
|
2016-10-24 22:02:43 +02:00
|
|
|
else if (curs_x > 288 && curs_x < 320 && _scrollPos < p_global->fresqWidth)
|
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() {
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(p_global->fresqImgBank);
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(0, 0, 16);
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(p_global->fresqImgBank + 1);
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(0, 320, 16);
|
2016-10-25 23:32:15 +02:00
|
|
|
needPaletteUpdate = 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();
|
|
|
|
p_global->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-09-28 07:29:12 +02:00
|
|
|
curs_saved = false;
|
2016-09-26 23:44:42 +02:00
|
|
|
torchCursor = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
glow_x = -1;
|
|
|
|
glow_y = -1;
|
|
|
|
p_global->gameFlags |= GameFlags::gfFlag20;
|
|
|
|
p_global->ff_D4 = 0;
|
|
|
|
p_global->curObjectId = 0;
|
|
|
|
p_global->iconsIndex = 13;
|
2016-09-26 07:57:27 +02:00
|
|
|
p_global->autoDialog = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
gametofresques();
|
2016-09-26 23:44:42 +02:00
|
|
|
p_global->frescoNumber = 3;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
// Original name: finfresques
|
|
|
|
void EdenGame::endFrescoes() {
|
|
|
|
torchCursor = false;
|
2016-09-28 07:29:12 +02:00
|
|
|
curs_saved = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->displayFlags = DisplayFlags::dfFlag1;
|
2016-09-26 23:44:42 +02:00
|
|
|
resetScroll();
|
2016-09-25 23:17:25 +02:00
|
|
|
p_global->ff_100 = 0xFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
maj_salle(p_global->roomNum);
|
|
|
|
if (p_global->phaseNum == 114)
|
|
|
|
p_global->narratorSequence = 1;
|
|
|
|
p_global->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-09-14 23:39:27 +02:00
|
|
|
if (curs_y > 16 && curs_y < 165) {
|
|
|
|
if (curs_x >= 0 && curs_x < 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();
|
|
|
|
}
|
|
|
|
} else if (curs_x > 290 && curs_x < 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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::scrollpano() {
|
|
|
|
if (curs_y > 16 && curs_y < 165) {
|
|
|
|
if (curs_x >= 0 && curs_x < 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
|
|
|
}
|
|
|
|
} else if (curs_x > 290 && curs_x < 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-09-14 23:39:27 +02:00
|
|
|
icon_t *icon1 = &gameIcons[3];
|
2016-10-17 03:05:37 +03:00
|
|
|
icon_t *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++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->party & (1 << i))
|
|
|
|
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;
|
|
|
|
icon->cursor_id = icon1->cursor_id;
|
|
|
|
icon->action_id = icon1->action_id;
|
|
|
|
icon->object_id = icon1->object_id;
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (perso->_roomNum != p_global->roomNum)
|
|
|
|
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;
|
|
|
|
icon->cursor_id = 8;
|
2016-10-07 00:45:08 +02:00
|
|
|
icon->action_id = 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-09-14 23:48:01 +02:00
|
|
|
void EdenGame::gametomiroir(byte arg1) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->displayFlags != DisplayFlags::dfFlag2) {
|
|
|
|
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
|
|
|
}
|
2016-10-24 22:02:43 +02:00
|
|
|
int16 bank = p_global->roomBgBankNum;
|
2016-10-17 03:05:37 +03:00
|
|
|
unsigned int resNum = bank + 326;
|
2016-11-09 13:40:08 -08:00
|
|
|
if (_vm->getPlatform() == Common::kPlatformMacintosh) {
|
2016-10-17 03:05:37 +03:00
|
|
|
if (bank == 76 || bank == 128)
|
|
|
|
resNum = 2487; // PCIMG.HSQ
|
|
|
|
}
|
|
|
|
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-10-25 23:32:15 +02:00
|
|
|
needPaletteUpdate = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->iconsIndex = 16;
|
2016-09-26 07:57:27 +02:00
|
|
|
p_global->autoDialog = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->displayFlags = DisplayFlags::dfMirror;
|
|
|
|
p_global->ff_102 = arg1;
|
|
|
|
}
|
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
void EdenGame::flipMode() {
|
2016-10-06 00:15:02 +02:00
|
|
|
if (_personTalking) {
|
2016-09-14 23:39:27 +02:00
|
|
|
endpersovox();
|
|
|
|
if (p_global->displayFlags == DisplayFlags::dfPerson) {
|
|
|
|
if (p_global->perso_ptr == &kPersons[PER_THOO] && p_global->phaseNum >= 80)
|
2016-08-18 13:15:54 +02:00
|
|
|
af_subtitle();
|
2016-09-14 23:39:27 +02:00
|
|
|
else {
|
|
|
|
getdatasync();
|
|
|
|
load_perso_cour();
|
|
|
|
addanim();
|
2016-10-25 23:32:15 +02:00
|
|
|
restartAnimation = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
anim_perso();
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
af_subtitle();
|
|
|
|
persovox();
|
|
|
|
} else {
|
2016-09-26 23:44:42 +02:00
|
|
|
if (p_global->displayFlags != DisplayFlags::dfFrescoes && p_global->displayFlags != DisplayFlags::dfFlag2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
closesalle();
|
|
|
|
if (p_global->displayFlags & DisplayFlags::dfFlag1)
|
|
|
|
gametomiroir(1);
|
|
|
|
else {
|
2016-09-26 23:44:42 +02:00
|
|
|
quitMirror();
|
2016-09-14 23:39:27 +02:00
|
|
|
maj_salle(p_global->roomNum);
|
|
|
|
if (byte_31D64) {
|
|
|
|
dialautoon();
|
|
|
|
parle_moi();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-26 07:57:27 +02: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();
|
|
|
|
afficher();
|
2016-09-26 23:44:42 +02:00
|
|
|
resetScroll();
|
2016-09-27 07:53:50 +02:00
|
|
|
saveFriezes();
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->displayFlags = DisplayFlags::dfFlag1;
|
2016-09-25 23:17:25 +02:00
|
|
|
p_global->ff_100 = 0xFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->eventType = EventType::etEventC;
|
|
|
|
p_global->ff_102 = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::clictimbre() {
|
2016-09-26 23:44:42 +02:00
|
|
|
flipMode();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::clicplanval() {
|
|
|
|
if ((p_global->partyOutside & PersonMask::pmDina) && p_global->phaseNum == 371) {
|
2016-09-26 23:44:42 +02:00
|
|
|
quitMirror();
|
2016-09-14 23:39:27 +02:00
|
|
|
maj_salle(p_global->roomNum);
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->roomNum == 8 || p_global->roomNum < 16)
|
|
|
|
return;
|
|
|
|
rundcurs();
|
|
|
|
afficher();
|
|
|
|
if (p_global->displayFlags == DisplayFlags::dfMirror)
|
2016-09-26 23:44:42 +02:00
|
|
|
quitMirror();
|
2016-09-14 23:39:27 +02:00
|
|
|
deplaval((p_global->roomNum & 0xFF00) | 1); //TODO: check me
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::gotolieu(goto_t *go) {
|
|
|
|
p_global->valleyVidNum = go->arriveVid;
|
|
|
|
p_global->travelTime = go->travelTime * 256;
|
|
|
|
p_global->stepsToFindAppleFast = 0;
|
|
|
|
p_global->eventType = EventType::etEvent2;
|
|
|
|
init_oui();
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!verif_oui())
|
|
|
|
return;
|
|
|
|
if (p_global->ff_113) {
|
|
|
|
waitendspeak();
|
|
|
|
if (!pomme_q)
|
|
|
|
close_perso();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (go->departVid) {
|
|
|
|
bars_out();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(go->departVid);
|
2016-11-13 15:46:36 -08:00
|
|
|
needToFade = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-10-07 23:06:10 +02:00
|
|
|
initPlace(p_global->newRoomNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
specialoutside();
|
|
|
|
faire_suivre(p_global->newRoomNum);
|
|
|
|
closesalle();
|
2016-09-30 07:48:27 +02:00
|
|
|
_adamMapMarkPos.x = -1;
|
|
|
|
_adamMapMarkPos.y = -1;
|
2016-09-14 23:39:27 +02:00
|
|
|
temps_passe(p_global->travelTime);
|
|
|
|
p_global->ff_100 = p_global->room_ptr->ff_0;
|
|
|
|
p_global->roomNum = p_global->newRoomNum;
|
|
|
|
p_global->areaNum = p_global->roomNum >> 8;
|
|
|
|
p_global->eventType = EventType::etEvent5;
|
|
|
|
p_global->newMusicType = MusicType::mt2;
|
|
|
|
setpersohere();
|
|
|
|
musique();
|
|
|
|
majsalle1(p_global->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) {
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->newLocation = roomNum & 0xFF;
|
|
|
|
p_global->valleyVidNum = 0;
|
|
|
|
p_global->phaseActionsCount++;
|
|
|
|
closesalle();
|
|
|
|
endpersovox();
|
2016-10-24 00:04:32 +02:00
|
|
|
byte c1 = roomNum & 0xFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (c1 == 0)
|
|
|
|
return;
|
|
|
|
if (c1 < 0x80) {
|
|
|
|
p_global->displayFlags = DisplayFlags::dfFlag1;
|
2016-08-18 13:15:54 +02:00
|
|
|
init_oui();
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->eventType = EventType::etEvent1;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-08-18 13:15:54 +02:00
|
|
|
if (!verif_oui())
|
|
|
|
return;
|
|
|
|
if (p_global->ff_113) {
|
|
|
|
waitendspeak();
|
|
|
|
if (!pomme_q)
|
|
|
|
close_perso();
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
specialout();
|
|
|
|
if (p_global->area_ptr->type == AreaType::atValley) {
|
|
|
|
temps_passe(32);
|
|
|
|
p_global->stepsToFindAppleFast++;
|
|
|
|
p_global->stepsToFindAppleNormal++;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
faire_suivre((roomNum & 0xFF00) | p_global->newLocation);
|
2016-08-18 13:15:54 +02:00
|
|
|
p_global->ff_100 = p_global->room_ptr->ff_0;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->roomNum = roomNum;
|
|
|
|
p_global->areaNum = roomNum >> 8;
|
2016-08-18 13:15:54 +02:00
|
|
|
p_global->eventType = EventType::etEvent5;
|
|
|
|
setpersohere();
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->newMusicType = MusicType::mtNormal;
|
2016-08-18 13:15:54 +02:00
|
|
|
musique();
|
2016-09-14 23:39:27 +02:00
|
|
|
majsalle1(roomNum);
|
|
|
|
p_global->chrono_on = 0;
|
|
|
|
p_global->chrono = 0;
|
|
|
|
p_global->ff_54 = 0;
|
|
|
|
if (p_global->roomPersoType == PersonFlags::pftTyrann)
|
|
|
|
chronoon(3000);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (c1 == 0xFF) {
|
|
|
|
p_global->eventType = EventType::etEventE;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-10-07 23:06:10 +02:00
|
|
|
if (!kPersons[PER_MESSAGER]._roomNum && eloirevientq())
|
|
|
|
chronoon(800);
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
p_global->stepsToFindAppleFast = 0;
|
2016-10-24 00:04:32 +02:00
|
|
|
byte newAreaNum = c1 & 0x7F;
|
|
|
|
byte curAreaNum = p_global->roomNum >> 8;
|
|
|
|
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;
|
|
|
|
p_global->newRoomNum = newRoomNum;
|
|
|
|
if (newAreaNum == Areas::arTausCave)
|
|
|
|
gotolieu(&gotos[0]);
|
|
|
|
else {
|
2016-10-24 00:04:32 +02:00
|
|
|
for (goto_t *go = gotos + 1; go->curAreaNum != 0xFF; go++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (go->curAreaNum == curAreaNum) {
|
|
|
|
gotolieu(go);
|
|
|
|
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) {
|
2016-09-14 23:39:27 +02:00
|
|
|
room_t *room = p_global->room_ptr;
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 roomNum = p_global->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();
|
|
|
|
afficher();
|
|
|
|
p_global->prevLocation = roomNum & 0xFF;
|
|
|
|
switch (dir) {
|
2016-09-25 00:33:07 +02:00
|
|
|
case kCryoNorth:
|
2016-09-14 23:39:27 +02:00
|
|
|
newLoc = room->exits[0];
|
|
|
|
break;
|
2016-09-25 00:33:07 +02:00
|
|
|
case kCryoEast:
|
2016-09-14 23:39:27 +02:00
|
|
|
newLoc = room->exits[1];
|
|
|
|
break;
|
2016-09-25 00:33:07 +02:00
|
|
|
case kCryoSouth:
|
2016-09-14 23:39:27 +02:00
|
|
|
newLoc = room->exits[2];
|
|
|
|
break;
|
2016-09-25 00:33:07 +02:00
|
|
|
case kCryoWest:
|
2016-09-14 23:39:27 +02:00
|
|
|
newLoc = room->exits[3];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
deplaval((roomNum & 0xFF00) | newLoc);
|
|
|
|
}
|
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
// Original name: deplacement2
|
|
|
|
void EdenGame::move2(Direction dir) {
|
2016-09-14 23:39:27 +02:00
|
|
|
room_t *room = p_global->room_ptr;
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 roomNum = p_global->roomNum;
|
2016-09-26 07:57:27 +02:00
|
|
|
char newLoc = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->prevLocation = roomNum & 0xFF;
|
|
|
|
switch (dir) {
|
2016-09-25 00:33:07 +02:00
|
|
|
case kCryoNorth:
|
2016-09-14 23:39:27 +02:00
|
|
|
newLoc = room->exits[0];
|
|
|
|
break;
|
2016-09-25 00:33:07 +02:00
|
|
|
case kCryoEast:
|
2016-09-14 23:39:27 +02:00
|
|
|
newLoc = room->exits[1];
|
|
|
|
break;
|
2016-09-25 00:33:07 +02:00
|
|
|
case kCryoSouth:
|
2016-09-14 23:39:27 +02:00
|
|
|
newLoc = room->exits[2];
|
|
|
|
break;
|
2016-09-25 00:33:07 +02:00
|
|
|
case kCryoWest:
|
2016-09-14 23:39:27 +02:00
|
|
|
newLoc = room->exits[3];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
deplaval((roomNum & 0xFF00) | newLoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::dinosoufle() {
|
|
|
|
if (p_global->curObjectId == 0) {
|
|
|
|
bars_out();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::plaquemonk() {
|
|
|
|
if (p_global->curObjectId != 0) {
|
|
|
|
if (p_global->curObjectId == Objects::obPrism) {
|
2016-09-26 23:44:42 +02:00
|
|
|
loseObject(Objects::obPrism);
|
2016-08-18 13:15:54 +02:00
|
|
|
bars_out();
|
2016-09-26 23:44:42 +02:00
|
|
|
specialTextMode = true;
|
|
|
|
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();
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->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 {
|
|
|
|
bars_out();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(7);
|
2016-09-14 23:39:27 +02:00
|
|
|
maj2();
|
|
|
|
p_global->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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::fresquesgraa() {
|
|
|
|
if (p_global->curObjectId == 0) {
|
|
|
|
p_global->fresqWidth = 320;
|
|
|
|
p_global->fresqImgBank = 113;
|
2016-09-26 23:44:42 +02:00
|
|
|
doFrescoes();
|
2016-09-14 23:39:27 +02:00
|
|
|
dinaparle();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::fresqueslasc() {
|
|
|
|
if (p_global->curObjectId == 0) {
|
|
|
|
p_global->fresqWidth = 112;
|
|
|
|
p_global->fresqImgBank = 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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::pushpierre() {
|
|
|
|
if (p_global->curObjectId == 0) {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::tetemomie() {
|
|
|
|
if (p_global->curObjectId == Objects::obTooth) {
|
|
|
|
p_global->gameFlags |= GameFlags::gfMummyOpened;
|
2016-09-26 23:44:42 +02:00
|
|
|
move(kCryoNorth);
|
2016-09-14 23:39:27 +02:00
|
|
|
} else if (p_global->curObjectId == 0) {
|
|
|
|
if (p_global->gameFlags & GameFlags::gfMummyOpened)
|
2016-09-26 23:44:42 +02:00
|
|
|
move(kCryoNorth);
|
2016-09-14 23:39:27 +02:00
|
|
|
else {
|
|
|
|
p_global->eventType = EventType::etEvent6;
|
|
|
|
persoparle(PersonId::pidMonk);
|
|
|
|
p_global->eventType = 0;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::tetesquel() {
|
|
|
|
if (p_global->curObjectId == Objects::obTooth) {
|
|
|
|
gameRooms[22].exits[0] = 16;
|
|
|
|
gameRooms[26].exits[2] = 13;
|
|
|
|
gameIcons[16].cursor_id |= 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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::squelmoorkong() {
|
|
|
|
p_global->eventType = EventType::etEvent9;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::choisir() {
|
2016-09-26 07:57:27 +02:00
|
|
|
byte objid = current_spot2->object_id;
|
|
|
|
byte obj;
|
2016-09-14 23:39:27 +02:00
|
|
|
switch (objid) {
|
|
|
|
case 0:
|
|
|
|
obj = p_global->giveobj1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
obj = p_global->giveobj2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
obj = p_global->giveobj3;
|
|
|
|
break;
|
2016-09-26 07:57:27 +02:00
|
|
|
default:
|
|
|
|
warning("Unexpected object_id in choisir()");
|
|
|
|
return;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
objectmain(obj);
|
|
|
|
winobject(obj);
|
|
|
|
p_global->iconsIndex = 16;
|
2016-09-26 07:57:27 +02:00
|
|
|
p_global->autoDialog = false;
|
2016-10-24 22:02:43 +02:00
|
|
|
p_global->ff_60 = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
parle_moi();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::dinaparle() {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 num;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso = &kPersons[PER_DINA];
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_partyMask & (p_global->party | p_global->partyOutside)) {
|
2016-09-26 23:44:42 +02:00
|
|
|
if (p_global->frescoNumber < 3)
|
|
|
|
p_global->frescoNumber = 3;
|
|
|
|
p_global->frescoNumber++;
|
|
|
|
if (p_global->frescoNumber < 15) {
|
2016-09-14 23:39:27 +02:00
|
|
|
endpersovox();
|
2016-09-26 23:44:42 +02:00
|
|
|
if (p_global->frescoNumber == 7 && p_global->phaseNum == 113)
|
2016-09-14 23:39:27 +02:00
|
|
|
incphase1();
|
|
|
|
p_global->perso_ptr = perso;
|
|
|
|
p_global->dialogType = DialogType::dtInspect;
|
2016-10-07 00:45:08 +02:00
|
|
|
num = (perso->_id << 3) | DialogType::dtInspect; //TODO: combine
|
2016-11-13 15:46:36 -08:00
|
|
|
bool res = dialoscansvmas((dial_t *)getElem(gameDialogs, num));
|
2016-09-30 07:48:27 +02:00
|
|
|
_frescoTalk = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (res) {
|
|
|
|
restaurefondbulle();
|
2016-09-30 07:48:27 +02:00
|
|
|
_frescoTalk = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
persovox();
|
|
|
|
}
|
|
|
|
p_global->ff_CA = 0;
|
2016-10-24 00:04:32 +02:00
|
|
|
p_global->dialogType = DialogType::dtTalk;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else
|
2016-09-26 23:44:42 +02:00
|
|
|
endFrescoes();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::roiparle() {
|
|
|
|
if (p_global->phaseNum <= 400)
|
|
|
|
persoparle(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::roiparle1() {
|
|
|
|
if (p_global->curObjectId == Objects::obSword) {
|
|
|
|
p_global->gameFlags |= GameFlags::gfFlag80;
|
|
|
|
bars_out();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(76);
|
|
|
|
move2(kCryoNorth);
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-09-26 23:44:42 +02:00
|
|
|
p_global->frescoNumber = 1;
|
2016-08-18 13:15:54 +02:00
|
|
|
roiparle();
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::roiparle2() {
|
2016-09-26 23:44:42 +02:00
|
|
|
p_global->frescoNumber = 2;
|
2016-09-14 23:39:27 +02:00
|
|
|
roiparle();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::roiparle3() {
|
2016-09-26 23:44:42 +02:00
|
|
|
p_global->frescoNumber = 3;
|
2016-09-14 23:39:27 +02:00
|
|
|
roiparle();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::getcouteau() {
|
|
|
|
if (p_global->phaseNum >= 80) {
|
|
|
|
gameRooms[113].video = 0;
|
|
|
|
getobject(Objects::obKnife);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->eventType = EventType::etEvent7;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::getprisme() {
|
|
|
|
getobject(Objects::obPrism);
|
|
|
|
p_global->eventType = EventType::etEvent7;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::getchampb() {
|
|
|
|
getobject(Objects::obShroom);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::getchampm() {
|
|
|
|
getobject(Objects::obBadShroom);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::getor() {
|
|
|
|
getobject(Objects::obGold);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::getnido() {
|
|
|
|
if (p_global->curObjectId != 0)
|
|
|
|
return;
|
|
|
|
p_global->room_ptr->bank = 282; //TODO: fix me
|
|
|
|
p_global->room_ptr--;
|
|
|
|
p_global->room_ptr->bank = 281; //TODO: fix me
|
|
|
|
p_global->room_ptr->ff_0 = 3;
|
|
|
|
getobject(Objects::obFullNest);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::getnidv() {
|
|
|
|
if (p_global->curObjectId != 0)
|
|
|
|
return;
|
|
|
|
p_global->room_ptr->bank = 282; //TODO: fix me
|
|
|
|
p_global->room_ptr--;
|
|
|
|
p_global->room_ptr->bank = 281; //TODO: fix me
|
|
|
|
p_global->room_ptr->ff_0 = 3;
|
|
|
|
getobject(Objects::obNest);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::getcorne() {
|
|
|
|
if (p_global->curObjectId != 0)
|
|
|
|
return;
|
|
|
|
getobject(Objects::obHorn);
|
|
|
|
p_global->eventType = EventType::etEvent7;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-09-14 23:39:27 +02:00
|
|
|
bigphase1();
|
|
|
|
setpersohere();
|
|
|
|
p_global->room_ptr = getsalle(p_global->roomNum);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::getsoleil() {
|
|
|
|
if (p_global->curObjectId != 0)
|
|
|
|
return;
|
|
|
|
gameRooms[238].video = 0;
|
|
|
|
gameRooms[238].flags = RoomFlags::rf80;
|
|
|
|
getobject(Objects::obSunStone);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::getoeuf() {
|
|
|
|
if (p_global->curObjectId != 0)
|
|
|
|
return;
|
|
|
|
p_global->room_ptr->flags = 0;
|
|
|
|
p_global->room_ptr->video = 0;
|
|
|
|
getobject(Objects::obEgg);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::getplaque() {
|
|
|
|
if (p_global->curObjectId != 0 && p_global->curObjectId < Objects::obTablet1)
|
|
|
|
return;
|
|
|
|
p_global->curObjectId = 0;
|
|
|
|
getobject(Objects::obTablet2);
|
|
|
|
putobject();
|
2016-10-24 22:02:43 +02:00
|
|
|
for (int i = 0; i < 6; i++)
|
2016-10-07 00:45:08 +02:00
|
|
|
objects[Objects::obTablet1 - 1 + i]._count = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->curObjectFlags = 0;
|
|
|
|
p_global->inventoryScrollPos = 0;
|
|
|
|
p_global->curObjectCursor = 9;
|
|
|
|
gameIcons[16].cursor_id |= 0x8000;
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2016-09-14 23:39:27 +02:00
|
|
|
gameRooms[131].video = 0;
|
|
|
|
bars_out();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(149);
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_F1 = RoomFlags::rf04;
|
|
|
|
p_global->drawFlags = DrawFlags::drDrawFlag20;
|
2016-10-25 23:32:15 +02:00
|
|
|
normalCursor = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
maj2();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::voirlac() {
|
|
|
|
perso_t *perso = &kPersons[PER_MORKUS];
|
|
|
|
room_t *room = p_global->room_ptr;
|
|
|
|
area_t *area = p_global->area_ptr;
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 vid = p_global->curObjectId == Objects::obApple ? 81 : 54;
|
2016-10-07 00:45:08 +02:00
|
|
|
for (++perso; perso->_roomNum != 0xFFFF; perso++) {
|
|
|
|
if (perso->_roomNum != p_global->roomNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
|
|
|
vid++;
|
|
|
|
if (p_global->curObjectId != Objects::obApple)
|
|
|
|
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-09-14 23:39:27 +02:00
|
|
|
area->flags |= AreaFlags::afFlag8;
|
|
|
|
p_global->curAreaFlags |= AreaFlags::afFlag8;
|
|
|
|
room->ff_0 = 3;
|
|
|
|
}
|
|
|
|
debug("sea monster: room = %X, d0 = %X\n", p_global->roomNum, p_global->roomImgBank);
|
|
|
|
bars_out();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(vid);
|
2016-09-14 23:39:27 +02:00
|
|
|
maj_salle(p_global->roomNum); //TODO: getting memory trashed here?
|
|
|
|
if (p_global->curObjectId == Objects::obApple)
|
2016-09-26 23:44:42 +02:00
|
|
|
loseObject(Objects::obApple);
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->eventType = EventType::etEventF;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::gotohall() {
|
|
|
|
p_global->prevLocation = p_global->roomNum & 0xFF;
|
|
|
|
deplaval((p_global->roomNum & 0xFF00) | 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::demitourlabi() {
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 target;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->prevLocation = p_global->roomNum & 0xFF;
|
2016-09-25 23:17:25 +02:00
|
|
|
p_global->ff_100 = 0xFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
target = (p_global->roomNum & 0xFF00) | p_global->room_ptr->exits[2];
|
|
|
|
faire_suivre(target);
|
|
|
|
p_global->roomNum = target;
|
|
|
|
p_global->eventType = EventType::etEvent5;
|
|
|
|
maj_salle(p_global->roomNum);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::gotonido() {
|
|
|
|
p_global->room_ptr++;
|
|
|
|
p_global->eventType = 0;
|
|
|
|
p_global->roomImgBank = p_global->room_ptr->bank;
|
|
|
|
p_global->roomVidNum = p_global->room_ptr->video;
|
|
|
|
p_global->curRoomFlags = p_global->room_ptr->flags;
|
|
|
|
p_global->ff_F1 = p_global->room_ptr->flags;
|
|
|
|
animpiece();
|
|
|
|
p_global->ff_100 = 0;
|
|
|
|
maj2();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::gotoval() {
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 target = p_global->roomNum;
|
2016-09-14 23:39:27 +02:00
|
|
|
char obj;
|
|
|
|
rundcurs();
|
|
|
|
afficher();
|
2016-09-30 07:48:27 +02:00
|
|
|
_scrollPos = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
obj = current_spot2->object_id - 14; //TODO
|
|
|
|
p_global->prevLocation = target & 0xFF;
|
|
|
|
deplaval((target & 0xFF00) | obj); //TODO careful!
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::visiter() {
|
|
|
|
bars_out();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(144);
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_F1 = RoomFlags::rf04;
|
|
|
|
maj2();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::final() {
|
|
|
|
if (p_global->curObjectId != 0)
|
|
|
|
return;
|
|
|
|
bars_out();
|
2016-09-14 23:48:01 +02:00
|
|
|
*(int16 *)(gameRooms + 0x6DC) = 319; //TODO
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->roomImgBank = 319;
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(97);
|
2016-09-14 23:39:27 +02:00
|
|
|
maj2();
|
|
|
|
p_global->eventType = EventType::etEvent12;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->narratorSequence = 54;
|
|
|
|
}
|
|
|
|
|
2016-09-27 07:53:50 +02:00
|
|
|
// Original name: goto_nord
|
|
|
|
void EdenGame::moveNorth() {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->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
|
|
|
|
void EdenGame::moveEast() {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->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
|
|
|
|
void EdenGame::moveSouth() {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->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
|
|
|
|
void EdenGame::moveWest() {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->curObjectId == 0)
|
2016-09-26 23:44:42 +02:00
|
|
|
move(kCryoWest);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::afficher() {
|
|
|
|
if (!p_global->ff_102 && !p_global->ff_103) {
|
|
|
|
if (needPaletteUpdate) {
|
2016-10-25 23:32:15 +02:00
|
|
|
needPaletteUpdate = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
CLPalette_Send2Screen(global_palette, 0, 256);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_CopyView2Screen(p_mainview);
|
|
|
|
} else {
|
|
|
|
if (p_global->ff_102)
|
|
|
|
effet3();
|
|
|
|
else
|
|
|
|
effet2();
|
2016-10-25 23:32:15 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_103 = 0;
|
|
|
|
p_global->ff_102 = 0;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::afficher128() {
|
|
|
|
if (p_global->updatePaletteFlag == 16) {
|
|
|
|
CLPalette_Send2Screen(global_palette, 0, 129);
|
|
|
|
CLBlitter_CopyView2Screen(p_mainview);
|
|
|
|
p_global->updatePaletteFlag = 0;
|
|
|
|
} else {
|
|
|
|
ClearScreen();
|
|
|
|
fadetoblack128(1);
|
|
|
|
if (showBlackBars)
|
2016-09-28 07:29:12 +02:00
|
|
|
drawBlackBars();
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_CopyView2Screen(p_mainview);
|
|
|
|
fadefromblack128(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);
|
|
|
|
CLBlitter_CopyViewRect(p_mainview, p_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;
|
|
|
|
CLBlitter_CopyViewRect(p_mainview, p_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;
|
|
|
|
CLBlitter_CopyViewRect(p_underBarsView, p_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;
|
|
|
|
CLBlitter_CopyViewRect(p_underBarsView, p_mainview, &_underBottomBarBackupRect, &_underBottomBarScreenRect);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::use_main_bank() {
|
|
|
|
bank_data_ptr = main_bank_buf;
|
|
|
|
}
|
|
|
|
|
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-09-14 23:39:27 +02:00
|
|
|
bank_data_ptr = bank_data_buf;
|
2016-10-07 23:06:10 +02:00
|
|
|
if (_curBankNum != bank) {
|
2016-09-28 07:29:12 +02:00
|
|
|
loadFile(bank, bank_data_buf);
|
2016-09-14 23:39:27 +02:00
|
|
|
verifh(bank_data_buf);
|
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);
|
|
|
|
byte *scr = p_mainview_buf + _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-09-28 07:29:12 +02:00
|
|
|
curs_saved = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::rundcurs() {
|
2016-09-30 07:48:27 +02:00
|
|
|
byte *keep = _cursKeepBuf;
|
|
|
|
byte *scr = p_mainview_buf + _cursKeepPos.x + _cursKeepPos.y * 640;
|
2016-10-09 00:06:17 +03:00
|
|
|
if (!curs_saved || (_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) {
|
|
|
|
byte *pix = bank_data_ptr;
|
|
|
|
byte *scr = p_mainview_buf + x + y * 640;
|
|
|
|
byte h0, h1, mode;
|
|
|
|
int16 w, h;
|
2016-11-13 13:56:20 -08:00
|
|
|
if (_curBankNum != 117 && !_noPalette) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (PLE16(pix) > 2)
|
2016-09-28 07:29:12 +02:00
|
|
|
readPalette(pix + 2);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
pix += PLE16(pix);
|
|
|
|
pix += PLE16(pix + index * 2);
|
2016-09-14 23:48:01 +02:00
|
|
|
// int16 height:9
|
|
|
|
// int16 pad:6;
|
|
|
|
// int16 flag:1;
|
2016-09-14 23:39:27 +02:00
|
|
|
h0 = *pix++;
|
|
|
|
h1 = *pix++;
|
|
|
|
w = ((h1 & 1) << 8) | h0;
|
|
|
|
h = *pix++;
|
|
|
|
mode = *pix++;
|
|
|
|
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-09-14 23:48:01 +02:00
|
|
|
int16 ww;
|
2016-09-14 23:39:27 +02:00
|
|
|
for (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-09-14 23:48:01 +02:00
|
|
|
int16 ww;
|
2016-09-14 23:39:27 +02:00
|
|
|
for (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) {
|
|
|
|
byte *pix = bank_data_ptr;
|
|
|
|
byte *scr = p_mainview_buf + x + y * 640;
|
|
|
|
byte h0, h1, mode;
|
|
|
|
int16 w, h;
|
2016-10-07 23:06:10 +02:00
|
|
|
if (_curBankNum != 117) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (PLE16(pix) > 2)
|
2016-09-28 07:29:12 +02:00
|
|
|
readPalette(pix + 2);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
pix += PLE16(pix);
|
|
|
|
pix += PLE16(pix + index * 2);
|
2016-09-14 23:48:01 +02:00
|
|
|
// int16 height:9
|
|
|
|
// int16 pad:6;
|
|
|
|
// int16 flag:1;
|
2016-09-14 23:39:27 +02:00
|
|
|
h0 = *pix++;
|
|
|
|
h1 = *pix++;
|
|
|
|
w = ((h1 & 1) << 8) | h0;
|
|
|
|
h = *pix++;
|
|
|
|
mode = *pix++;
|
|
|
|
if (mode != 0xFF && mode != 0xFE)
|
|
|
|
return;
|
|
|
|
if (y + h > 200)
|
|
|
|
h -= (y + h - 200);
|
|
|
|
if (h1 & 0x80) {
|
|
|
|
// compressed
|
|
|
|
for (; h-- > 0;) {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 ww;
|
2016-09-14 23:39:27 +02:00
|
|
|
for (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-09-14 23:48:01 +02:00
|
|
|
int16 ww;
|
2016-09-14 23:39:27 +02:00
|
|
|
for (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) {
|
|
|
|
byte *scr = p_mainview_buf + x + y * 640;
|
|
|
|
byte *gl = glow_buffer;
|
2016-09-14 23:39:27 +02:00
|
|
|
glow_x = x;
|
|
|
|
glow_y = y;
|
|
|
|
glow_w = w;
|
|
|
|
glow_h = h;
|
|
|
|
for (; h--;) {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 ww;
|
2016-09-14 23:39:27 +02:00
|
|
|
for (ww = w; ww--;)
|
|
|
|
*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-09-14 23:48:01 +02:00
|
|
|
byte *gl = glow_buffer;
|
|
|
|
byte *scr = p_mainview_buf + glow_x + glow_y * 640;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (glow_x < 0 || glow_y < 0) //TODO: move it up
|
|
|
|
return;
|
|
|
|
for (; glow_h--;) {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 ww;
|
2016-09-14 23:39:27 +02:00
|
|
|
for (ww = glow_w; ww--;)
|
|
|
|
*scr++ = *gl++;
|
|
|
|
scr += 640 - glow_w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::glow(int16 index) {
|
2016-09-25 23:17:25 +02:00
|
|
|
// byte pixbase;
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *pix = bank_data_ptr;
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
index += 9;
|
|
|
|
pix += PLE16(pix);
|
|
|
|
pix += PLE16(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-10-24 22:02:43 +02:00
|
|
|
int16 x = curs_x + _scrollPos - 38;
|
|
|
|
int16 y = curs_y - 28;
|
2016-11-13 15:46:36 -08:00
|
|
|
int16 ex = p_global->fresqWidth + 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-11-13 15:46:36 -08:00
|
|
|
int16 dy;
|
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;
|
|
|
|
else
|
|
|
|
dy = 0;
|
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-11-13 15:46:36 -08:00
|
|
|
byte *scr = p_mainview_buf + 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-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-09-14 23:39:27 +02:00
|
|
|
CLPalette_SetRGBColor(global_palette, idx, &pal_entry);
|
|
|
|
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-09-14 23:48:01 +02:00
|
|
|
byte *pix = bank_data_ptr;
|
|
|
|
byte *scr = p_subtitlesview_buf + x + y * subtitles_x_width;
|
2016-10-07 23:06:10 +02:00
|
|
|
if ((_curBankNum != 117) && (PLE16(pix) > 2))
|
2016-09-28 07:29:12 +02:00
|
|
|
readPalette(pix + 2);
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
pix += PLE16(pix);
|
|
|
|
pix += PLE16(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-09-14 23:39:27 +02:00
|
|
|
scr += subtitles_x_width - w;
|
|
|
|
}
|
|
|
|
} 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-09-14 23:39:27 +02:00
|
|
|
scr += subtitles_x_width - w;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::bars_out() {
|
|
|
|
if (showBlackBars)
|
|
|
|
return;
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
afficher();
|
2016-09-30 07:48:27 +02:00
|
|
|
_underTopBarScreenRect.left = _scrollPos;
|
|
|
|
_underTopBarScreenRect.right = _scrollPos + 320 - 1;
|
|
|
|
CLBlitter_CopyViewRect(p_mainview, p_underBarsView, &_underTopBarScreenRect, &_underTopBarBackupRect);
|
|
|
|
_underBottomBarScreenRect.left = _underTopBarScreenRect.left;
|
|
|
|
_underBottomBarScreenRect.right = _underTopBarScreenRect.right;
|
|
|
|
CLBlitter_CopyViewRect(p_mainview, p_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;
|
|
|
|
CLBlitter_CopyViewRect(p_underBarsView, p_mainview, &_underTopBarScreenRect, &_underTopBarBackupRect);
|
2016-09-14 23:39:27 +02:00
|
|
|
scr40 = ((unsigned int *)p_mainview_buf) + r19 * 640 / 4;
|
|
|
|
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;
|
|
|
|
CLBlitter_CopyViewRect(p_underBarsView, p_mainview, &_underTopBarScreenRect, &_underTopBarBackupRect);
|
2016-09-14 23:39:27 +02:00
|
|
|
scr40 = ((unsigned int *)p_mainview_buf) + r20 * 640 / 4;
|
|
|
|
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;
|
|
|
|
afficher();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
scr40 = (unsigned int *)p_mainview_buf;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
scr40 = ((unsigned int *)p_mainview_buf) + r20 * 640 / 4;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
afficher();
|
2016-09-30 07:48:27 +02:00
|
|
|
initRects();
|
2016-09-28 07:29:12 +02: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-09-14 23:39:27 +02:00
|
|
|
if (!showBlackBars)
|
|
|
|
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;
|
|
|
|
CLBlitter_CopyViewRect(p_underBarsView, p_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;
|
|
|
|
CLBlitter_CopyViewRect(p_underBarsView, p_mainview, &_underTopBarScreenRect, &_underTopBarBackupRect);
|
2016-09-14 23:39:27 +02:00
|
|
|
r29 += 2;
|
|
|
|
r28 += 3;
|
|
|
|
afficher();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-30 07:48:27 +02:00
|
|
|
initRects();
|
2016-09-28 07:29:12 +02:00
|
|
|
showBlackBars = 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::sauvefondbouche() {
|
2016-09-29 07:43:13 +02:00
|
|
|
rect_src.left = cur_perso_rect->sx;
|
|
|
|
rect_src.top = cur_perso_rect->sy;
|
|
|
|
rect_src.right = cur_perso_rect->ex;
|
|
|
|
rect_src.bottom = cur_perso_rect->ey;
|
|
|
|
rect_dst.left = cur_perso_rect->sx + 320;
|
|
|
|
rect_dst.top = cur_perso_rect->sy;
|
|
|
|
rect_dst.right = cur_perso_rect->ex + 320;
|
|
|
|
rect_dst.bottom = cur_perso_rect->ey;
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_CopyViewRect(p_mainview, p_mainview, &rect_src, &rect_dst);
|
2016-10-25 23:32:15 +02:00
|
|
|
fond_saved = 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::restaurefondbouche() {
|
2016-09-29 07:43:13 +02:00
|
|
|
rect_src.left = cur_perso_rect->sx;
|
|
|
|
rect_src.top = cur_perso_rect->sy;
|
|
|
|
rect_src.right = cur_perso_rect->ex;
|
|
|
|
rect_src.bottom = cur_perso_rect->ey;
|
|
|
|
rect_dst.left = cur_perso_rect->sx + 320;
|
|
|
|
rect_dst.top = cur_perso_rect->sy;
|
|
|
|
rect_dst.right = cur_perso_rect->ex + 320;
|
|
|
|
rect_dst.bottom = cur_perso_rect->ey;
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_CopyViewRect(p_mainview, p_mainview, &rect_dst, &rect_src);
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-28 07:29:12 +02:00
|
|
|
// Original name : blackbars
|
|
|
|
void EdenGame::drawBlackBars() {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *scr = p_mainview_buf;
|
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)
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->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);
|
|
|
|
noclipax(p_global->area_ptr->num - 1, 0, 0);
|
|
|
|
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-10-25 23:32:15 +02:00
|
|
|
needPaletteUpdate = 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
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->area_ptr->type == AreaType::atValley) {
|
|
|
|
noclipax(p_global->area_ptr->num + 9, 266, 1);
|
2016-11-13 15:46:36 -08:00
|
|
|
for (perso_t *perso = &kPersons[PER_UNKN_18C]; perso->_roomNum != 0xFFFF; perso++) {
|
2016-10-07 00:45:08 +02:00
|
|
|
if (((perso->_roomNum >> 8) == p_global->areaNum)
|
|
|
|
&& !(perso->_flags & PersonFlags::pf80) && (perso->_flags & PersonFlags::pf20))
|
|
|
|
displayMapMark(33, perso->_roomNum & 0xFF);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
if (p_global->area_ptr->citadelLevel)
|
2016-09-29 00:32:49 +02:00
|
|
|
displayMapMark(34, p_global->area_ptr->citadelRoom->location);
|
2016-09-27 07:53:50 +02:00
|
|
|
saveTopFrieze(0);
|
2016-11-13 15:46:36 -08:00
|
|
|
int16 loc = p_global->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);
|
2016-09-29 07:43:13 +02:00
|
|
|
byte *pix = p_underBarsView->_bufferPtr;
|
|
|
|
int16 w = p_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;
|
2016-09-29 07:43:13 +02:00
|
|
|
byte *pix = p_underBarsView->_bufferPtr;
|
|
|
|
int16 w = p_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;
|
2016-09-29 07:43:13 +02:00
|
|
|
byte *pix = p_underBarsView->_bufferPtr;
|
|
|
|
int16 w = p_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
|
|
|
|
if (!tyranPtr)
|
2016-11-13 15:46:36 -08:00
|
|
|
return false;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-10-07 00:45:08 +02:00
|
|
|
for (; tyranPtr->_roomNum != 0xFFFF; tyranPtr++) {
|
|
|
|
if (tyranPtr->_flags & PersonFlags::pf80)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (tyranPtr->_roomNum == (area | (loc - 16)))
|
2016-11-13 15:46:36 -08:00
|
|
|
return true;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (tyranPtr->_roomNum == (area | (loc + 16)))
|
2016-11-13 15:46:36 -08:00
|
|
|
return true;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (tyranPtr->_roomNum == (area | (loc - 1)))
|
2016-11-13 15:46:36 -08:00
|
|
|
return true;
|
2016-10-07 00:45:08 +02: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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::istyranval(area_t *area) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte areaNum = area->num;
|
2016-09-14 23:39:27 +02: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-09-14 23:39:27 +02:00
|
|
|
area->flags |= AreaFlags::HasTyrann;
|
|
|
|
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) {
|
2016-09-14 23:39:27 +02:00
|
|
|
room_t *room = p_global->cita_area_firstRoom;
|
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
|
2016-09-14 23:39:27 +02:00
|
|
|
if (roomNum == p_global->roomNum)
|
2016-09-29 00:32:49 +02:00
|
|
|
return false;
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
for (; room->ff_0 != 0xFF; room++) {
|
|
|
|
if (room->location != loc)
|
|
|
|
continue;
|
|
|
|
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
|
|
|
|
void EdenGame::scramble1(char 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
|
|
|
|
void EdenGame::scramble2(char 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-09-29 00:32:49 +02:00
|
|
|
void EdenGame::melangedir() {
|
|
|
|
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;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (areaNum != p_global->cita_area_num)
|
|
|
|
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-09-14 23:48:01 +02:00
|
|
|
void EdenGame::newcita(char arg1, int16 arg2, room_t *room) {
|
2016-09-14 23:39:27 +02:00
|
|
|
cita_t *cita = cita_list;
|
|
|
|
while (cita->ff_0 < arg2)
|
|
|
|
cita++;
|
2016-11-13 15:46:36 -08:00
|
|
|
|
|
|
|
uint16 index = ((room->flags & 0xC0) >> 6); //TODO: this is very wrong
|
|
|
|
int16 *ptr = cita->ff_2 + index * 2;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (arg1 == 4 || arg1 == 6)
|
|
|
|
ptr++;
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
room->bank = ptr[0];
|
|
|
|
room->video = ptr[8];
|
|
|
|
room->flags |= RoomFlags::rf02;
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::citaevol(int16 level) {
|
2016-09-14 23:39:27 +02:00
|
|
|
room_t *room = p_global->cur_area_ptr->citadelRoom;
|
|
|
|
perso_t *perso = &kPersons[PER_UNKN_372];
|
2016-11-13 15:46:36 -08:00
|
|
|
byte loc = room->location;
|
|
|
|
if (level >= 80 && !istrice((p_global->cita_area_num << 8) | loc)) {
|
2016-09-14 23:39:27 +02:00
|
|
|
room->level = 79;
|
|
|
|
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-09-14 23:39:27 +02:00
|
|
|
if (room->level < 64 && level >= 64 && naitredino(PersonFlags::pftTriceraptor)) {
|
|
|
|
p_global->cur_area_ptr->flags |= AreaFlags::HasTriceraptors;
|
|
|
|
ajouinfo(p_global->cita_area_num + ValleyNews::vnTriceraptorsIn);
|
|
|
|
}
|
|
|
|
if (room->level < 40 && level >= 40 && naitredino(PersonFlags::pftVelociraptor)) {
|
|
|
|
p_global->cur_area_ptr->flags |= AreaFlags::HasVelociraptors;
|
|
|
|
ajouinfo(p_global->cita_area_num + ValleyNews::vnVelociraptorsIn);
|
|
|
|
}
|
|
|
|
room->level = level;
|
|
|
|
newcita(p_global->cita_area_num, level, room);
|
2016-11-13 15:46:36 -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;
|
2016-10-07 00:45:08 +02:00
|
|
|
if ((perso->_roomNum >> 8) == p_global->cita_area_num && perso->_targetLoc == loc)
|
|
|
|
perso->_speed = speed;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::citacapoute(int16 roomNum) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso = &kPersons[PER_UNKN_18C];
|
|
|
|
room_t *room = p_global->cur_area_ptr->citadelRoom;
|
|
|
|
room->flags |= RoomFlags::rf01;
|
|
|
|
room->flags &= ~RoomFlags::rfHasCitadel;
|
|
|
|
room->bank = 193;
|
|
|
|
room->video = 0;
|
|
|
|
room->level = 0;
|
|
|
|
p_global->cur_area_ptr->citadelLevel = 0;
|
|
|
|
p_global->cur_area_ptr->citadelRoom = 0;
|
|
|
|
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-09-14 23:39:27 +02:00
|
|
|
delinfo((roomNum >> 8) + ValleyNews::vnTyrannIn);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::buildcita() {
|
|
|
|
area_t *area = p_global->area_ptr;
|
|
|
|
p_global->cur_area_ptr = p_global->area_ptr;
|
|
|
|
if (area->citadelRoom)
|
|
|
|
citacapoute(p_global->roomNum);
|
|
|
|
p_global->ff_6A = p_global->ff_69;
|
|
|
|
p_global->narratorSequence = p_global->ff_69 | 0x80;
|
|
|
|
area->citadelRoom = p_global->room_ptr;
|
|
|
|
p_global->room_ptr->flags &= ~RoomFlags::rf01;
|
|
|
|
p_global->room_ptr->flags |= RoomFlags::rfHasCitadel;
|
|
|
|
p_global->room_ptr->level = 32;
|
|
|
|
newcita(p_global->areaNum, 32, p_global->room_ptr);
|
|
|
|
area->flags &= ~AreaFlags::TyrannSighted;
|
|
|
|
if (!(area->flags & AreaFlags::afFlag8000)) {
|
|
|
|
if (p_global->phaseNum == 304 || p_global->phaseNum != 384) //TODO: wha
|
|
|
|
eloirevient();
|
|
|
|
area->flags |= AreaFlags::afFlag8000;
|
|
|
|
}
|
2016-10-07 00:45:08 +02:00
|
|
|
p_global->room_perso->_flags |= PersonFlags::pf80;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->cita_area_num = p_global->areaNum;
|
|
|
|
naitredino(1);
|
|
|
|
delinfo(p_global->areaNum + ValleyNews::vnCitadelLost);
|
|
|
|
delinfo(p_global->areaNum + ValleyNews::vnTyrannLost);
|
|
|
|
if (p_global->phaseNum == 193 && p_global->areaNum == Areas::arUluru)
|
|
|
|
bigphase1();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::citatombe(char level) {
|
|
|
|
if (level)
|
|
|
|
newcita(p_global->cita_area_num, level, p_global->cur_area_ptr->citadelRoom);
|
|
|
|
else {
|
|
|
|
citacapoute(p_global->cita_area_num << 8);
|
|
|
|
ajouinfo(p_global->cita_area_num + ValleyNews::vnCitadelLost);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::constcita() {
|
|
|
|
// room_t *room = p_global->cur_area_ptr->room_ptr; //TODO: wrong? chk below
|
2016-09-14 23:48:01 +02:00
|
|
|
// byte id = room->ff_C;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!p_global->cur_area_ptr->citadelLevel || !p_global->cur_area_ptr->citadelRoom)
|
|
|
|
return;
|
2016-09-29 00:32:49 +02:00
|
|
|
|
|
|
|
room_t *room = p_global->cur_area_ptr->citadelRoom; //TODO: copied here by me
|
|
|
|
byte loc = room->location;
|
2016-09-14 23:39:27 +02:00
|
|
|
tyranPtr = &kPersons[PER_UNKN_372];
|
|
|
|
if (istyran((p_global->cita_area_num << 8) | loc)) {
|
|
|
|
if (!(p_global->cur_area_ptr->flags & AreaFlags::TyrannSighted)) {
|
|
|
|
ajouinfo(p_global->cita_area_num + ValleyNews::vnTyrannIn);
|
|
|
|
p_global->cur_area_ptr->flags |= AreaFlags::TyrannSighted;
|
|
|
|
}
|
2016-09-29 00:32:49 +02:00
|
|
|
byte level = room->level - 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (level < 32)
|
|
|
|
level = 32;
|
|
|
|
room->level = level;
|
|
|
|
citatombe(level);
|
|
|
|
} else {
|
|
|
|
p_global->cur_area_ptr->flags &= ~AreaFlags::TyrannSighted;
|
|
|
|
citaevol(room->level + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::depladino(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) {
|
|
|
|
melangedir();
|
2016-09-29 00:32:49 +02:00
|
|
|
char *dirs = tab_2CB1E[dir];
|
2016-10-07 00:45:08 +02:00
|
|
|
byte loc = perso->_roomNum & 0xFF;
|
2016-09-29 00:32:49 +02:00
|
|
|
char dir2 = *dirs++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (dir2 & 0x80)
|
|
|
|
dir2 = -(dir2 & ~0x80);
|
|
|
|
dir2 += loc;
|
2016-09-29 00:32:49 +02:00
|
|
|
if (canMoveThere(dir2, perso))
|
2016-09-14 23:39:27 +02:00
|
|
|
goto ok;
|
|
|
|
dir2 = *dirs++;
|
|
|
|
if (dir2 & 0x80)
|
|
|
|
dir2 = -(dir2 & ~0x80);
|
|
|
|
dir2 += loc;
|
2016-09-29 00:32:49 +02:00
|
|
|
if (canMoveThere(dir2, perso))
|
2016-09-14 23:39:27 +02:00
|
|
|
goto ok;
|
|
|
|
dir2 = *dirs++;
|
|
|
|
if (dir2 & 0x80)
|
|
|
|
dir2 = -(dir2 & ~0x80);
|
|
|
|
dir2 += loc;
|
2016-09-29 00:32:49 +02:00
|
|
|
if (canMoveThere(dir2, perso))
|
2016-09-14 23:39:27 +02:00
|
|
|
goto ok;
|
|
|
|
dir2 = *dirs++;
|
|
|
|
if (dir2 & 0x80)
|
|
|
|
dir2 = -(dir2 & ~0x80);
|
|
|
|
dir2 += loc;
|
2016-09-29 00:32:49 +02:00
|
|
|
if (canMoveThere(dir2, perso))
|
2016-09-14 23:39:27 +02:00
|
|
|
goto ok;
|
2016-10-07 00:45:08 +02:00
|
|
|
dir2 = perso->_lastLoc;
|
|
|
|
perso->_lastLoc = 0;
|
2016-09-29 00:32:49 +02:00
|
|
|
if (!canMoveThere(dir2, perso))
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
|
|
|
ok:
|
|
|
|
;
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_lastLoc = perso->_roomNum & 0xFF;
|
|
|
|
perso->_roomNum &= ~0xFF;
|
|
|
|
perso->_roomNum |= dir2 & 0xFF;
|
|
|
|
if (perso->_targetLoc - 16 == (perso->_roomNum & 0xFF))
|
|
|
|
perso->_targetLoc = 0;
|
|
|
|
if (perso->_targetLoc + 16 == (perso->_roomNum & 0xFF))
|
|
|
|
perso->_targetLoc = 0;
|
|
|
|
if (perso->_targetLoc - 1 == (perso->_roomNum & 0xFF))
|
|
|
|
perso->_targetLoc = 0;
|
|
|
|
if (perso->_targetLoc + 1 == (perso->_roomNum & 0xFF))
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::deplaalldino() {
|
|
|
|
perso_t *perso = &kPersons[PER_UNKN_18C - 1]; //TODO fix this
|
2016-10-07 00:45:08 +02:00
|
|
|
while ((++perso)->_roomNum != 0xFFFF) {
|
|
|
|
if (((perso->_roomNum >> 8) & 0xFF) != p_global->cita_area_num)
|
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
|
|
|
if (!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;
|
|
|
|
if (perso->_roomNum == p_global->roomNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
continue;
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_steps = perso->_speed;
|
2016-09-14 23:39:27 +02:00
|
|
|
depladino(perso);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::newvallee() {
|
|
|
|
perso_t *perso = &kPersons[PER_UNKN_372];
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 *ptr = tab_2CB16;
|
|
|
|
int16 roomNum;
|
2016-09-14 23:39:27 +02:00
|
|
|
while ((roomNum = *ptr++) != -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-10-07 00:45:08 +02:00
|
|
|
perso->_roomNum = 0xFFFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
kAreasTable[7].flags |= AreaFlags::HasTyrann;
|
|
|
|
p_global->worldHasTyrann = 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
char EdenGame::whereiscita() {
|
|
|
|
char res = -1;
|
2016-11-13 15:46:36 -08:00
|
|
|
for (room_t *room = p_global->cita_area_firstRoom; room->ff_0 != 0xFF; room++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!(room->flags & RoomFlags::rfHasCitadel))
|
|
|
|
continue;
|
|
|
|
res = room->location;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2016-09-29 00:32:49 +02:00
|
|
|
bool EdenGame::iscita(int16 loc) {
|
2016-09-14 23:39:27 +02:00
|
|
|
loc &= 0xFF;
|
2016-11-13 15:46:36 -08:00
|
|
|
for (room_t *room = p_global->cita_area_firstRoom; room->ff_0 != 0xFF; room++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!(room->flags & RoomFlags::rfHasCitadel))
|
|
|
|
continue;
|
|
|
|
if (room->location == loc + 16)
|
2016-09-29 00:32:49 +02:00
|
|
|
return true;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (room->location == loc - 16)
|
2016-09-29 00:32:49 +02:00
|
|
|
return true;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (room->location == loc - 1)
|
2016-09-29 00:32:49 +02:00
|
|
|
return true;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::lieuvava(area_t *area) {
|
|
|
|
if (area->type == AreaType::atValley) {
|
|
|
|
istyranval(area);
|
|
|
|
area->citadelLevel = 0;
|
|
|
|
if (area->citadelRoom)
|
|
|
|
area->citadelLevel = p_global->cita_area_firstRoom->level; //TODO: no search?
|
2016-11-13 15:46:36 -08:00
|
|
|
byte mask = ~(1 << (area->num - Areas::arChamaar));
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->worldTyrannSighted &= mask;
|
|
|
|
p_global->ff_4E &= mask;
|
|
|
|
p_global->worldGaveGold &= mask;
|
|
|
|
p_global->worldHasVelociraptors &= mask;
|
|
|
|
p_global->worldHasTriceraptors &= mask;
|
|
|
|
p_global->worldHasTyrann &= mask;
|
|
|
|
p_global->ff_53 &= mask;
|
|
|
|
mask = ~mask;
|
|
|
|
if (area->flags & AreaFlags::TyrannSighted)
|
|
|
|
p_global->worldTyrannSighted |= mask;
|
|
|
|
if (area->flags & AreaFlags::afFlag4)
|
|
|
|
p_global->ff_4E |= mask;
|
|
|
|
if (area->flags & AreaFlags::HasTriceraptors)
|
|
|
|
p_global->worldHasTriceraptors |= mask;
|
|
|
|
if (area->flags & AreaFlags::afGaveGold)
|
|
|
|
p_global->worldGaveGold |= mask;
|
|
|
|
if (area->flags & AreaFlags::HasVelociraptors)
|
|
|
|
p_global->worldHasVelociraptors |= mask;
|
|
|
|
if (area->flags & AreaFlags::HasTyrann)
|
|
|
|
p_global->worldHasTyrann |= mask;
|
|
|
|
if (area->flags & AreaFlags::afFlag20)
|
|
|
|
p_global->ff_53 |= mask;
|
|
|
|
if (area == p_global->area_ptr) {
|
|
|
|
p_global->curAreaFlags = area->flags;
|
|
|
|
p_global->curCitadelLevel = area->citadelLevel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
p_global->ff_4D &= p_global->worldTyrannSighted;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::vivredino() {
|
2016-11-13 15:46:36 -08:00
|
|
|
for (perso_t *perso = &kPersons[PER_UNKN_18C]; perso->_roomNum != 0xFFFF; perso++) {
|
2016-10-07 00:45:08 +02:00
|
|
|
if (((perso->_roomNum >> 8) & 0xFF) != p_global->cita_area_num)
|
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-10-07 00:45:08 +02:00
|
|
|
if (iscita(perso->_roomNum))
|
|
|
|
perso->_targetLoc = 0;
|
|
|
|
else if (!perso->_targetLoc) {
|
2016-09-29 00:32:49 +02: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) {
|
|
|
|
if (iscita(perso->_roomNum))
|
|
|
|
perso->_targetLoc = 0;
|
|
|
|
else if (!perso->_targetLoc) {
|
2016-09-29 00:32:49 +02: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) {
|
|
|
|
if (perso->_roomNum == p_global->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 {
|
|
|
|
tyranPtr = &kPersons[PER_UNKN_372];
|
2016-10-07 00:45:08 +02:00
|
|
|
if (istyran(perso->_roomNum)) {
|
|
|
|
if (p_global->phaseNum < 481 && (perso->_powers & (1 << (p_global->cita_area_num - 3)))) {
|
|
|
|
tyranPtr->_flags |= PersonFlags::pf80;
|
|
|
|
tyranPtr->_roomNum = 0;
|
|
|
|
perso->_flags &= ~PersonFlags::pf10;
|
|
|
|
perso->_flags |= PersonFlags::pfInParty;
|
2016-09-14 23:39:27 +02:00
|
|
|
ajouinfo(p_global->cita_area_num + ValleyNews::vnTyrannLost);
|
|
|
|
delinfo(p_global->cita_area_num + ValleyNews::vnTyrannIn);
|
|
|
|
if (naitredino(PersonFlags::pftTriceraptor))
|
|
|
|
ajouinfo(p_global->cita_area_num + ValleyNews::vnTriceraptorsIn);
|
|
|
|
constcita();
|
|
|
|
p_global->cur_area_ptr->flags &= ~AreaFlags::TyrannSighted;
|
|
|
|
} else {
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags &= ~PersonFlags::pf10;
|
|
|
|
perso->_flags &= ~PersonFlags::pfInParty;
|
2016-09-14 23:39:27 +02:00
|
|
|
ajouinfo(p_global->cita_area_num + ValleyNews::vnVelociraptorsLost);
|
|
|
|
}
|
|
|
|
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) {
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->cita_area_num = areaNum;
|
|
|
|
p_global->cur_area_ptr = &kAreasTable[areaNum - 1];
|
|
|
|
p_global->cita_area_firstRoom = &gameRooms[p_global->cur_area_ptr->firstRoomIndex];
|
|
|
|
deplaalldino();
|
|
|
|
constcita();
|
|
|
|
vivredino();
|
|
|
|
newchampi();
|
|
|
|
newnido();
|
|
|
|
newnidv();
|
|
|
|
if (p_global->phaseNum >= 226)
|
|
|
|
newor();
|
|
|
|
lieuvava(p_global->cur_area_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::chaquejour() {
|
|
|
|
vivreval(3);
|
|
|
|
vivreval(4);
|
|
|
|
vivreval(5);
|
|
|
|
vivreval(6);
|
|
|
|
vivreval(7);
|
|
|
|
vivreval(8);
|
|
|
|
p_global->drawFlags |= DrawFlags::drDrawTopScreen;
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::temps_passe(int16 t) {
|
|
|
|
int16 days = p_global->gameDays;
|
2016-11-13 15:46:36 -08:00
|
|
|
int16 lo = p_global->ff_56 + t;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (lo > 255) {
|
|
|
|
days++;
|
|
|
|
lo &= 0xFF;
|
|
|
|
}
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_56 = lo;
|
|
|
|
t = ((t >> 8) & 0xFF) + days;
|
|
|
|
t -= p_global->gameDays;
|
|
|
|
if (t) {
|
|
|
|
p_global->gameDays += t;
|
|
|
|
while (t--)
|
|
|
|
chaquejour();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::heurepasse() {
|
|
|
|
temps_passe(5);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::anim_perso() {
|
2016-10-07 23:06:10 +02:00
|
|
|
if (_curBankNum != p_global->perso_img_bank)
|
2016-09-14 23:39:27 +02:00
|
|
|
load_perso(p_global->perso_ptr);
|
|
|
|
restaurefondbulle();
|
|
|
|
if (restartAnimation) {
|
2016-11-28 22:33:39 -08:00
|
|
|
_lastAnimTicks = _vm->TimerTicks;
|
2016-10-25 23:32:15 +02:00
|
|
|
restartAnimation = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-11-28 22:33:39 -08:00
|
|
|
cur_anim_frame_num = (_vm->TimerTicks - _lastAnimTicks) >> 2; // TODO: check me!!!
|
2016-09-14 23:39:27 +02:00
|
|
|
if (cur_anim_frame_num > num_anim_frames) // TODO: bug?
|
2016-11-09 22:36:06 -08:00
|
|
|
_animateTalking = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->curPersoAnimPtr && !p_global->animationFlags && cur_anim_frame_num != last_anim_frame_num) {
|
|
|
|
last_anim_frame_num = cur_anim_frame_num;
|
|
|
|
if (*p_global->curPersoAnimPtr == 0xFF)
|
|
|
|
getanimrnd();
|
|
|
|
bank_data_ptr = perso_img_bank_data_ptr;
|
|
|
|
num_img_desc = 0;
|
|
|
|
perso_spr(p_global->curPersoAnimPtr);
|
|
|
|
p_global->curPersoAnimPtr += num_img_desc + 1;
|
|
|
|
dword_3072C = imagedesc + 200;
|
|
|
|
virespritebouche();
|
|
|
|
if (*dword_3072C)
|
|
|
|
af_image();
|
|
|
|
animationDelay--;
|
|
|
|
if (!animationDelay) { //TODO: combine
|
|
|
|
p_global->animationFlags = 1;
|
|
|
|
animationDelay = 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
animationDelay--;
|
|
|
|
if (!animationDelay) { //TODO: combine
|
|
|
|
getanimrnd();
|
|
|
|
//TODO: no reload?
|
|
|
|
}
|
2016-11-09 22:36:06 -08:00
|
|
|
if (_animateTalking) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!animationTable) {
|
|
|
|
animationTable = gameLipsync + 7262; //TODO: fix me
|
|
|
|
if (!fond_saved)
|
|
|
|
sauvefondbouche();
|
|
|
|
}
|
2016-10-06 00:15:02 +02:00
|
|
|
if (!_personTalking)
|
2016-09-14 23:39:27 +02:00
|
|
|
cur_anim_frame_num = num_anim_frames - 1;
|
|
|
|
animationIndex = animationTable[cur_anim_frame_num];
|
|
|
|
if (animationIndex == 0xFF)
|
2016-11-09 22:36:06 -08:00
|
|
|
_animateTalking = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
else if (animationIndex != lastAnimationIndex) {
|
|
|
|
bank_data_ptr = perso_img_bank_data_ptr;
|
|
|
|
restaurefondbouche();
|
|
|
|
// debug("perso spr %d", animationIndex);
|
2016-09-14 23:48:01 +02:00
|
|
|
perso_spr(p_global->persoSpritePtr2 + animationIndex * 2); //TODO: int16s?
|
2016-09-14 23:39:27 +02:00
|
|
|
dword_3072C = imagedesc + 200;
|
|
|
|
if (*dword_3072C)
|
|
|
|
af_image();
|
|
|
|
lastAnimationIndex = animationIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
af_subtitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::getanimrnd() {
|
|
|
|
animationDelay = 8;
|
2016-11-13 15:46:36 -08:00
|
|
|
int16 rnd = _vm->_rnd->getRandomNumber(65535) & (byte)~0x18; //TODO
|
2016-09-14 23:39:27 +02:00
|
|
|
dword_30724 = p_global->persoSpritePtr + 16; //TODO
|
|
|
|
p_global->curPersoAnimPtr = p_global->persoSpritePtr + ((dword_30724[1] << 8) + dword_30724[0]);
|
|
|
|
p_global->animationFlags = 1;
|
|
|
|
if (rnd >= 8)
|
|
|
|
return;
|
|
|
|
p_global->animationFlags = 0;
|
|
|
|
if (rnd <= 0)
|
|
|
|
return;
|
|
|
|
for (rnd *= 8; rnd > 0; rnd--) {
|
|
|
|
while (*p_global->curPersoAnimPtr)
|
|
|
|
p_global->curPersoAnimPtr++;
|
|
|
|
p_global->curPersoAnimPtr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::addanim() {
|
2016-09-25 23:17:25 +02:00
|
|
|
lastAnimationIndex = 0xFF;
|
2016-10-06 00:15:02 +02:00
|
|
|
_lastAnimTicks = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->animationFlags = 0xC0;
|
|
|
|
p_global->curPersoAnimPtr = p_global->persoSpritePtr;
|
|
|
|
getanimrnd();
|
2016-10-25 23:32:15 +02:00
|
|
|
animationActive = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->perso_ptr == &kPersons[PER_ROI])
|
|
|
|
return;
|
|
|
|
perso_spr(p_global->persoSpritePtr + PLE16(p_global->persoSpritePtr)); //TODO: GetElem(0)
|
|
|
|
dword_3072C = imagedesc + 200;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (p_global->perso_ptr->_id != PersonId::pidCabukaOfCantura && p_global->perso_ptr->_targetLoc != 7) //TODO: targetLoc is minisprite idx
|
2016-09-14 23:39:27 +02:00
|
|
|
virespritebouche();
|
|
|
|
if (*dword_3072C)
|
|
|
|
af_image();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::virespritebouche() {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *src = dword_3072C + 2;
|
|
|
|
byte *dst = src;
|
2016-09-14 23:39:27 +02:00
|
|
|
char cnt = dword_3072C[0];
|
|
|
|
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
|
|
|
|
dword_3072C[0]--;
|
|
|
|
} else
|
|
|
|
dst += 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::anim_perfin() {
|
|
|
|
p_global->animationFlags &= ~0x80;
|
|
|
|
animationDelay = 0;
|
2016-10-25 23:32:15 +02:00
|
|
|
animationActive = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::perso_spr(byte *spr) {
|
|
|
|
byte *img = imagedesc + 200 + 2;
|
|
|
|
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++;
|
|
|
|
}
|
|
|
|
num_img_desc++;
|
|
|
|
index = (cc << 8) | c;
|
|
|
|
index -= 2;
|
|
|
|
// debug("anim sprite %d", index);
|
|
|
|
|
|
|
|
if (index > max_perso_desc)
|
|
|
|
index = max_perso_desc;
|
|
|
|
index *= 2; //TODO: src = GetElem(ff_C2, index)
|
|
|
|
src = p_global->ff_C2;
|
|
|
|
src = src + PLE16(src + index);
|
|
|
|
while ((c = *src++)) {
|
|
|
|
*img++ = c;
|
|
|
|
*img++ = *src++;
|
|
|
|
*img++ = *src++;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
imagedesc[200] = count & 0xFF;
|
|
|
|
imagedesc[201] = count >> 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::af_image() {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *img = imagedesc + 200, *img_start, *curimg = imagedesc;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-11-13 15:46:36 -08:00
|
|
|
int16 count = PLE16(img);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!count)
|
|
|
|
return;
|
|
|
|
img_start = img;
|
|
|
|
img += 2;
|
|
|
|
count *= 3;
|
|
|
|
while (count--)
|
|
|
|
*curimg++ = *img++;
|
|
|
|
img = img_start;
|
|
|
|
count = PLE16(img);
|
|
|
|
img += 2;
|
|
|
|
/////// draw it
|
|
|
|
while (count--) {
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 index = *img++;
|
|
|
|
uint16 x = *img++ + gameIcons[0].sx;
|
|
|
|
uint16 y = *img++ + gameIcons[0].sy;
|
|
|
|
byte *pix = bank_data_ptr;
|
|
|
|
byte *scr = p_mainview_buf + x + y * 640;
|
|
|
|
byte h0, h1, mode;
|
|
|
|
int16 w, h;
|
2016-09-14 23:39:27 +02:00
|
|
|
index--;
|
|
|
|
if (PLE16(pix) > 2)
|
2016-09-28 07:29:12 +02:00
|
|
|
readPalette(pix + 2);
|
2016-08-18 13:15:54 +02:00
|
|
|
pix += PLE16(pix);
|
|
|
|
pix += PLE16(pix + index * 2);
|
2016-09-14 23:48:01 +02:00
|
|
|
// int16 height:9
|
|
|
|
// int16 pad:6;
|
|
|
|
// int16 flag:1;
|
2016-08-18 13:15:54 +02:00
|
|
|
h0 = *pix++;
|
|
|
|
h1 = *pix++;
|
|
|
|
w = ((h1 & 1) << 8) | h0;
|
|
|
|
h = *pix++;
|
|
|
|
mode = *pix++;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::af_perso1() {
|
|
|
|
perso_spr(p_global->persoSpritePtr + PLE16(p_global->persoSpritePtr));
|
|
|
|
af_image();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::af_perso() {
|
|
|
|
load_perso_cour();
|
|
|
|
af_perso1();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::ef_perso() {
|
|
|
|
p_global->animationFlags &= 0x3F;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::load_perso(perso_t *perso) {
|
2016-11-13 15:46:36 -08:00
|
|
|
perso_img_bank_data_ptr = 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
|
|
|
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_spriteBank != p_global->perso_img_bank) {
|
|
|
|
cur_perso_rect = &perso_rects[perso->_id]; //TODO: array of int16?
|
|
|
|
dword_30728 = tab_persxx[perso->_id];
|
2016-09-14 23:39:27 +02:00
|
|
|
ef_perso();
|
2016-10-07 00:45:08 +02:00
|
|
|
p_global->perso_img_bank = perso->_spriteBank;
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(p_global->perso_img_bank);
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_img_bank_data_ptr = bank_data_ptr;
|
2016-11-13 15:46:36 -08:00
|
|
|
byte *ptr = bank_data_ptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
ptr += PLE16(ptr);
|
2016-11-13 15:46:36 -08:00
|
|
|
byte *baseptr = ptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
ptr += PLE16(ptr) - 2;
|
|
|
|
ptr = baseptr + PLE16(ptr) + 4;
|
|
|
|
gameIcons[0].sx = PLE16(ptr);
|
|
|
|
gameIcons[0].sy = PLE16(ptr + 2);
|
|
|
|
gameIcons[0].ex = PLE16(ptr + 4);
|
|
|
|
gameIcons[0].ey = PLE16(ptr + 6);
|
|
|
|
ptr += 8;
|
|
|
|
p_global->ff_C2 = ptr + 2;
|
|
|
|
max_perso_desc = PLE16(ptr) / 2;
|
|
|
|
ptr += PLE16(ptr);
|
|
|
|
baseptr = ptr;
|
|
|
|
ptr += PLE16(ptr) - 2;
|
|
|
|
p_global->persoSpritePtr = baseptr;
|
|
|
|
p_global->persoSpritePtr2 = baseptr + PLE16(ptr);
|
2016-10-08 21:21:21 +02:00
|
|
|
debug("load perso: b6 len is %ld", p_global->persoSpritePtr2 - p_global->persoSpritePtr);
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(p_global->perso_img_bank);
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_img_bank_data_ptr = bank_data_ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::load_perso_cour() {
|
|
|
|
load_perso(p_global->perso_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::fin_perso() {
|
|
|
|
p_global->animationFlags &= 0x3F;
|
2016-11-13 22:59:45 -08:00
|
|
|
p_global->curPersoAnimPtr = nullptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_CA = 0;
|
|
|
|
p_global->perso_img_bank = -1;
|
|
|
|
anim_perfin();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::no_perso() {
|
|
|
|
if (p_global->displayFlags == DisplayFlags::dfPerson) {
|
|
|
|
p_global->displayFlags = p_global->oldDisplayFlags;
|
|
|
|
fin_perso();
|
|
|
|
}
|
|
|
|
endpersovox();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::close_perso() {
|
|
|
|
endpersovox();
|
2016-10-07 00:45:08 +02:00
|
|
|
if (p_global->displayFlags == DisplayFlags::dfPerson && p_global->perso_ptr->_id != PersonId::pidNarrator && p_global->eventType != EventType::etEventE) {
|
2016-09-14 23:39:27 +02:00
|
|
|
rundcurs();
|
2016-10-25 23:32:15 +02:00
|
|
|
savedUnderSubtitles = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
restaurefondbulle();
|
2016-08-18 13:15:54 +02:00
|
|
|
afficher();
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_103 = 16;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-10-07 00:45:08 +02:00
|
|
|
if (p_global->perso_ptr->_id == PersonId::pidNarrator)
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_103 = 69;
|
|
|
|
p_global->eloiHaveNews &= 1;
|
|
|
|
p_global->ff_CA = 0;
|
|
|
|
p_global->ff_F6 = 0;
|
|
|
|
if (p_global->displayFlags == DisplayFlags::dfPerson) {
|
|
|
|
p_global->displayFlags = p_global->oldDisplayFlags;
|
|
|
|
p_global->animationFlags &= 0x3F;
|
2016-11-13 22:59:45 -08:00
|
|
|
p_global->curPersoAnimPtr = nullptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
anim_perfin();
|
|
|
|
if (p_global->displayFlags & DisplayFlags::dfMirror) {
|
|
|
|
gametomiroir(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;
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->numGiveObjs) {
|
|
|
|
if (!(p_global->displayFlags & DisplayFlags::dfFlag2))
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->numGiveObjs = 0;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->ff_F2 & 1) {
|
|
|
|
p_global->ff_102 = 6;
|
|
|
|
p_global->ff_F2 &= ~1;
|
|
|
|
}
|
2016-11-13 15:46:36 -08:00
|
|
|
char oldLoc = p_global->newLocation;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->newLocation = 0;
|
|
|
|
if (!(p_global->narratorSequence & 0x80))
|
2016-09-25 23:17:25 +02:00
|
|
|
p_global->ff_100 = 0xFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
maj_salle(p_global->roomNum);
|
2016-11-13 15:46:36 -08:00
|
|
|
p_global->newLocation = oldLoc;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-11-13 15:46:36 -08:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->chrono)
|
|
|
|
p_global->chrono_on = 1;
|
|
|
|
}
|
|
|
|
|
2016-10-07 23:06:10 +02:00
|
|
|
// Original name: af_fondsuiveur
|
|
|
|
void EdenGame::displayBackgroundFollower() {
|
2016-10-07 00:45:08 +02:00
|
|
|
char id = p_global->perso_ptr->_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;
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(bank + p_global->roomBgBankNum);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::af_fondperso1() {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte bank;
|
2016-09-14 23:39:27 +02:00
|
|
|
char *ptab;
|
|
|
|
if (p_global->perso_ptr == &kPersons[PER_MESSAGER]) {
|
|
|
|
gameIcons[0].sx = 0;
|
|
|
|
perso_rects[PER_MESSAGER].sx = 2;
|
|
|
|
bank = p_global->persoBackgroundBankIdx;
|
|
|
|
if (p_global->eventType == EventType::etEventE) {
|
|
|
|
p_global->ff_103 = 1;
|
|
|
|
goto no_suiveur;
|
|
|
|
}
|
|
|
|
gameIcons[0].sx = 60;
|
|
|
|
perso_rects[PER_MESSAGER].sx = 62;
|
|
|
|
}
|
|
|
|
if (p_global->perso_ptr == &kPersons[PER_THOO]) {
|
|
|
|
bank = 37;
|
|
|
|
if (p_global->curObjectId == Objects::obShell)
|
|
|
|
goto no_suiveur;
|
|
|
|
}
|
2016-10-07 00:45:08 +02:00
|
|
|
ptab = kPersoRoomBankTable + p_global->perso_ptr->_roomBankId;
|
2016-09-14 23:39:27 +02:00
|
|
|
bank = *ptab++;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (!(p_global->perso_ptr->_partyMask & p_global->party)) {
|
2016-09-14 23:39:27 +02:00
|
|
|
while ((bank = *ptab++) != 0xFF) {
|
|
|
|
if (bank == (p_global->roomNum & 0xFF)) { //TODO: signed vs unsigned - chg r31 to uns?
|
|
|
|
bank = *ptab;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ptab++;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (bank != 0xFF)
|
|
|
|
goto no_suiveur;
|
2016-10-07 00:45:08 +02:00
|
|
|
ptab = kPersoRoomBankTable + p_global->perso_ptr->_roomBankId;
|
2016-09-14 23:39:27 +02:00
|
|
|
bank = *ptab++;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-10-07 23:06:10 +02:00
|
|
|
displayBackgroundFollower();
|
2016-09-14 23:39:27 +02:00
|
|
|
no_suiveur:
|
|
|
|
;
|
|
|
|
if (!bank)
|
|
|
|
return;
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(bank);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->perso_ptr == &kPersons[PER_UNKN_156])
|
|
|
|
noclipax_avecnoir(0, 0, 16);
|
|
|
|
else
|
|
|
|
noclipax(0, 0, 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::af_fondperso() {
|
2016-10-07 00:45:08 +02:00
|
|
|
if (p_global->perso_ptr->_spriteBank) {
|
2016-10-25 23:32:15 +02:00
|
|
|
fond_saved = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
af_fondperso1();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::setpersoicon() {
|
|
|
|
if (p_global->iconsIndex == 4)
|
|
|
|
return;
|
2016-11-29 14:03:36 -08:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->perso_ptr == &kPersons[PER_MESSAGER] && p_global->eventType == EventType::etEventE) {
|
|
|
|
p_global->iconsIndex = 123;
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-11-29 14:03:36 -08:00
|
|
|
icon_t *icon = gameIcons;
|
|
|
|
icon_t *icon2 = &gameIcons[roomIconsBase];
|
|
|
|
|
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-09-14 23:39:27 +02:00
|
|
|
void EdenGame::show_perso() {
|
|
|
|
perso_t *perso = p_global->perso_ptr;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_spriteBank) {
|
2016-09-14 23:39:27 +02:00
|
|
|
closesalle();
|
|
|
|
if (p_global->displayFlags != DisplayFlags::dfPerson) {
|
|
|
|
if (p_global->displayFlags & DisplayFlags::dfMirror)
|
2016-09-26 23:44:42 +02:00
|
|
|
resetScroll();
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->oldDisplayFlags = p_global->displayFlags;
|
|
|
|
p_global->displayFlags = DisplayFlags::dfPerson;
|
|
|
|
load_perso(perso);
|
|
|
|
setpersoicon();
|
|
|
|
af_fondperso();
|
|
|
|
if (perso == &kPersons[PER_THOO] && p_global->curObjectId == Objects::obShell) {
|
|
|
|
af_subtitle();
|
|
|
|
update_cursor();
|
2016-10-25 23:32:15 +02:00
|
|
|
needPaletteUpdate = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
afficher();
|
|
|
|
rundcurs();
|
|
|
|
return;
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
load_perso_cour();
|
|
|
|
addanim();
|
|
|
|
if (!p_global->curPersoAnimPtr) {
|
|
|
|
af_perso();
|
|
|
|
af_subtitle();
|
|
|
|
}
|
2016-10-25 23:32:15 +02:00
|
|
|
restartAnimation = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
anim_perso();
|
|
|
|
if (perso != &kPersons[PER_UNKN_156])
|
|
|
|
update_cursor();
|
2016-10-25 23:32:15 +02:00
|
|
|
needPaletteUpdate = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (perso != &kPersons[PER_UNKN_156])
|
|
|
|
rundcurs();
|
|
|
|
afficher();
|
|
|
|
} else {
|
2016-10-07 23:06:10 +02:00
|
|
|
displayPlace();
|
2016-09-14 23:39:27 +02:00
|
|
|
af_subtitle();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::showpersopanel() {
|
|
|
|
perso_t *perso = p_global->perso_ptr;
|
|
|
|
load_perso_cour();
|
|
|
|
addanim();
|
|
|
|
if (!p_global->curPersoAnimPtr) {
|
|
|
|
af_perso();
|
|
|
|
af_subtitle();
|
|
|
|
}
|
2016-10-25 23:32:15 +02:00
|
|
|
restartAnimation = true;
|
|
|
|
needPaletteUpdate = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->drawFlags & DrawFlags::drDrawFlag8)
|
|
|
|
return;
|
|
|
|
anim_perso();
|
|
|
|
if (perso != &kPersons[PER_UNKN_156])
|
|
|
|
update_cursor();
|
|
|
|
afficher();
|
|
|
|
if (perso != &kPersons[PER_UNKN_156])
|
|
|
|
rundcurs();
|
|
|
|
p_global->drawFlags |= DrawFlags::drDrawFlag8;
|
|
|
|
p_global->iconsIndex = 112;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::getdatasync() {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 num = p_global->textNum;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->textBankIndex != 1)
|
|
|
|
num += 565;
|
|
|
|
if (p_global->textBankIndex == 3)
|
|
|
|
num += 707;
|
|
|
|
if (num == 144)
|
|
|
|
num = 142;
|
2016-11-09 22:36:06 -08:00
|
|
|
_animateTalking = ReadDataSync(num - 1);
|
|
|
|
if (_animateTalking)
|
2016-09-14 23:39:27 +02:00
|
|
|
num_anim_frames = ReadNombreFrames();
|
|
|
|
else
|
|
|
|
num_anim_frames = 0;
|
|
|
|
if (p_global->textNum == 144)
|
|
|
|
num_anim_frames = 48;
|
|
|
|
animationTable = 0;
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 EdenGame::ReadNombreFrames() {
|
|
|
|
int16 num = 0;
|
2016-10-17 03:05:37 +03:00
|
|
|
animationTable = gameLipsync + 7260 + 2; //TODO: fix me
|
2016-09-14 23:39:27 +02:00
|
|
|
while (*animationTable++ != 0xFF)
|
|
|
|
num++;
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::waitendspeak() {
|
|
|
|
for (;;) {
|
|
|
|
if (animationActive)
|
|
|
|
anim_perso();
|
|
|
|
musicspy();
|
|
|
|
afficher();
|
|
|
|
CLKeyboard_Read();
|
|
|
|
testPommeQ();
|
|
|
|
if (pomme_q) {
|
|
|
|
close_perso();
|
|
|
|
PommeQ();
|
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!mouse_held)
|
|
|
|
if (CLMouse_IsDown())
|
|
|
|
break;
|
|
|
|
if (mouse_held)
|
|
|
|
if (!CLMouse_IsDown())
|
2016-10-25 23:32:15 +02:00
|
|
|
mouse_held = false;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-10-25 23:32:15 +02:00
|
|
|
mouse_held = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::my_bulle() {
|
2016-11-29 14:03:36 -08:00
|
|
|
if (!p_global->textNum)
|
|
|
|
return;
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *icons = phraseIconsBuffer;
|
2016-10-08 21:26:22 +02:00
|
|
|
byte *linesp = phraseCoordsBuffer;
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *phrasePtr = phraseBuffer;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->numGiveObjs = 0;
|
|
|
|
p_global->giveobj1 = 0;
|
|
|
|
p_global->giveobj2 = 0;
|
|
|
|
p_global->giveobj3 = 0;
|
|
|
|
p_global->textWidthLimit = subtitles_x_width;
|
|
|
|
text_ptr = gettxtad(p_global->textNum);
|
|
|
|
num_text_lines = 0;
|
2016-11-29 14:03:36 -08:00
|
|
|
int16 words_on_line = 0;
|
|
|
|
int16 word_width = 0;
|
|
|
|
int16 line_width = 0;
|
2016-11-13 15:46:36 -08:00
|
|
|
byte c;
|
2016-09-14 23:39:27 +02:00
|
|
|
while ((c = *text_ptr++) != 0xFF) {
|
|
|
|
if (c == 0x11 || c == 0x13) {
|
|
|
|
if (p_global->phaseNum <= 272 || p_global->phaseNum == 386) {
|
|
|
|
p_global->eloiHaveNews = c & 0xF;
|
|
|
|
p_global->ff_4D = p_global->worldTyrannSighted;
|
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) {
|
|
|
|
while (*text_ptr++ != 0xFF) ;
|
|
|
|
text_ptr--;
|
|
|
|
} else if (c >= 0xA0 && c < 0xC0)
|
|
|
|
p_global->textToken1 = c & 0xF;
|
|
|
|
else if (c >= 0xC0 && c < 0xD0)
|
|
|
|
p_global->textToken2 = c & 0xF;
|
|
|
|
else if (c >= 0xD0 && c < 0xE0) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte c1 = *text_ptr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (c == 0xD2)
|
|
|
|
#ifdef FAKE_DOS_VERSION
|
|
|
|
p_global->textWidthLimit = c1 + 160;
|
|
|
|
#else
|
|
|
|
p_global->textWidthLimit = c1 + subtitles_x_center; //TODO: signed? 160 in pc ver
|
|
|
|
#endif
|
|
|
|
else {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte c2 = *text_ptr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
switch (p_global->numGiveObjs) {
|
|
|
|
case 0:
|
|
|
|
p_global->giveobj1 = c2;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
p_global->giveobj2 = c2;
|
2016-08-18 13:15:54 +02:00
|
|
|
break;
|
2016-09-14 23:39:27 +02:00
|
|
|
case 2:
|
|
|
|
p_global->giveobj3 = c2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
p_global->numGiveObjs++;
|
|
|
|
*icons++ = *text_ptr++;
|
|
|
|
*icons++ = *text_ptr++;
|
|
|
|
*icons++ = c2;
|
|
|
|
}
|
|
|
|
} else if (c >= 0xE0 && c < 0xFF)
|
|
|
|
SysBeep(1);
|
|
|
|
else if (c != '\r') {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte width;
|
|
|
|
int16 overrun;
|
2016-09-14 23:39:27 +02:00
|
|
|
*phrasePtr++ = c;
|
|
|
|
width = gameFont[c];
|
|
|
|
#ifdef FAKE_DOS_VERSION
|
|
|
|
if (c == ' ')
|
|
|
|
width = space_width;
|
|
|
|
#endif
|
|
|
|
word_width += width;
|
|
|
|
line_width += width;
|
|
|
|
overrun = line_width - p_global->textWidthLimit;
|
|
|
|
if (overrun > 0) {
|
|
|
|
num_text_lines++;
|
|
|
|
if (c != ' ') {
|
2016-10-08 21:26:22 +02:00
|
|
|
*linesp++ = words_on_line;
|
|
|
|
*linesp++ = word_width + space_width - overrun;
|
2016-09-14 23:39:27 +02:00
|
|
|
line_width = word_width;
|
|
|
|
} else {
|
2016-10-08 21:26:22 +02:00
|
|
|
*linesp++ = words_on_line + 1;
|
|
|
|
*linesp++ = space_width - overrun; //TODO: checkme
|
2016-09-14 23:39:27 +02:00
|
|
|
line_width = 0;
|
|
|
|
}
|
|
|
|
word_width = 0;
|
|
|
|
words_on_line = 0;
|
|
|
|
} else {
|
|
|
|
if (c == ' ') {
|
|
|
|
words_on_line++;
|
|
|
|
word_width = 0;
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
num_text_lines++;
|
2016-10-08 21:26:22 +02:00
|
|
|
*linesp++ = words_on_line + 1;
|
|
|
|
*linesp++ = word_width;
|
2016-09-14 23:39:27 +02:00
|
|
|
*phrasePtr = c;
|
|
|
|
if (p_global->textBankIndex == 2 && p_global->textNum == 101 && p_global->pref_language == 1)
|
|
|
|
patchphrase();
|
|
|
|
my_pr_bulle();
|
|
|
|
if (!p_global->numGiveObjs)
|
|
|
|
return;
|
|
|
|
use_main_bank();
|
|
|
|
if (num_text_lines < 3)
|
|
|
|
num_text_lines = 3;
|
|
|
|
icons = phraseIconsBuffer;
|
2016-11-13 15:46:36 -08:00
|
|
|
for (byte i = 0; i < p_global->numGiveObjs; i++) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte x = *icons++;
|
|
|
|
byte y = *icons++;
|
|
|
|
byte s = *icons++;
|
2016-09-28 07:29:12 +02:00
|
|
|
spriteOnSubtitle(52, x + subtitles_x_center, y - 1);
|
|
|
|
spriteOnSubtitle(s + 9, x + subtitles_x_center + 1, y);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::my_pr_bulle() {
|
|
|
|
CLBlitter_FillView(p_subtitlesview, 0);
|
|
|
|
if (p_global->pref_language == 0)
|
|
|
|
return;
|
2016-11-29 14:03:36 -08:00
|
|
|
|
|
|
|
byte *coo = phraseCoordsBuffer;
|
|
|
|
bool done = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
textout = p_subtitlesview_buf;
|
|
|
|
text_ptr = phraseBuffer;
|
2016-10-17 03:05:37 +03:00
|
|
|
int16 lines = 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
while (!done) {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 num_words = *coo++; // num words on line
|
|
|
|
int16 pad_size = *coo++; // amount of extra spacing
|
2016-11-13 15:46:36 -08:00
|
|
|
byte *cur_out = textout;
|
|
|
|
int16 extraSpacing = num_words > 1 ? pad_size / (num_words - 1) + 1 : 0;
|
2016-10-17 03:05:37 +03:00
|
|
|
if (lines == num_text_lines)
|
2016-11-13 15:46:36 -08:00
|
|
|
extraSpacing = 0;
|
|
|
|
byte c = *text_ptr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
while (!done & (num_words > 0)) { //TODO: bug - missed & ?
|
|
|
|
if (c < 0x80 && c != '\r') {
|
|
|
|
if (c == ' ') {
|
|
|
|
num_words--;
|
2016-11-13 15:46:36 -08:00
|
|
|
if (pad_size >= extraSpacing) {
|
|
|
|
textout += extraSpacing + space_width;
|
|
|
|
pad_size -= extraSpacing;
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
|
|
|
textout += pad_size + space_width;
|
|
|
|
pad_size = 0;
|
|
|
|
}
|
|
|
|
} else {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 char_width = gameFont[c];
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!(p_global->drawFlags & DrawFlags::drDrawMenu)) {
|
|
|
|
textout += subtitles_x_width;
|
|
|
|
if (!specialTextMode)
|
|
|
|
charsurbulle(c, 195, char_width);
|
|
|
|
textout++;
|
|
|
|
if (!specialTextMode)
|
|
|
|
charsurbulle(c, 195, char_width);
|
|
|
|
textout -= subtitles_x_width + 1;
|
|
|
|
}
|
|
|
|
if (specialTextMode)
|
|
|
|
charsurbulle(c, 250, char_width);
|
|
|
|
else
|
|
|
|
charsurbulle(c, 230, char_width);
|
|
|
|
textout += char_width;
|
|
|
|
}
|
|
|
|
} else
|
2016-10-24 23:18:08 +02:00
|
|
|
error("my_pr_bulle: Unexpected format");
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
c = *text_ptr++;
|
|
|
|
if (c == 0xFF)
|
2016-11-13 15:46:36 -08:00
|
|
|
done = true;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
textout = cur_out + subtitles_x_width * FONT_HEIGHT;
|
2016-10-17 03:05:37 +03:00
|
|
|
lines++;
|
2016-09-14 23:39:27 +02:00
|
|
|
text_ptr--;
|
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::charsurbulle(byte c, byte color, int16 width) {
|
|
|
|
byte *glyph = gameFont + 256 + c * FONT_HEIGHT;
|
2016-09-14 23:39:27 +02: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)
|
|
|
|
*textoutptr = color;
|
|
|
|
textoutptr++;
|
|
|
|
mask >>= 1;
|
|
|
|
}
|
|
|
|
textoutptr += subtitles_x_width - width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::af_subtitle() {
|
2016-11-13 15:46:36 -08:00
|
|
|
byte *src = p_subtitlesview_buf;
|
|
|
|
byte *dst = p_mainview_buf;
|
|
|
|
int16 y;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->displayFlags & DisplayFlags::dfFlag2) {
|
|
|
|
y = 174;
|
|
|
|
if ((p_global->drawFlags & DrawFlags::drDrawMenu) && num_text_lines == 1)
|
|
|
|
y = 167;
|
|
|
|
dst += 640 * (y - num_text_lines * FONT_HEIGHT) + subtitles_x_scr_margin;
|
|
|
|
} else {
|
|
|
|
y = 174;
|
2016-09-30 07:48:27 +02:00
|
|
|
dst += 640 * (y - num_text_lines * FONT_HEIGHT) + _scrollPos + subtitles_x_scr_margin;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-10-06 00:15:02 +02:00
|
|
|
if (animationActive && !_personTalking)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
|
|
|
sauvefondbulle(y);
|
2016-11-13 15:46:36 -08:00
|
|
|
for (int16 h = 0; h < num_text_lines * FONT_HEIGHT + 1; h++) {
|
|
|
|
for (int16 w = 0; w < subtitles_x_width; 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-09-14 23:39:27 +02:00
|
|
|
dst += 640 - subtitles_x_width;
|
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::sauvefondbulle(int16 y) {
|
2016-09-30 07:48:27 +02:00
|
|
|
_underSubtitlesScreenRect.top = y - num_text_lines * FONT_HEIGHT;
|
|
|
|
_underSubtitlesScreenRect.left = _scrollPos + subtitles_x_scr_margin;
|
|
|
|
_underSubtitlesScreenRect.right = _scrollPos + subtitles_x_scr_margin + subtitles_x_width - 1;
|
|
|
|
_underSubtitlesScreenRect.bottom = y;
|
|
|
|
_underSubtitlesBackupRect.top = 0;
|
|
|
|
_underSubtitlesBackupRect.bottom = num_text_lines * FONT_HEIGHT;
|
|
|
|
CLBlitter_CopyViewRect(p_mainview, p_underSubtitlesView, &_underSubtitlesScreenRect, &_underSubtitlesBackupRect);
|
2016-10-25 23:32:15 +02:00
|
|
|
savedUnderSubtitles = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::restaurefondbulle() {
|
|
|
|
if (!savedUnderSubtitles)
|
|
|
|
return;
|
2016-09-30 07:48:27 +02:00
|
|
|
CLBlitter_CopyViewRect(p_underSubtitlesView, p_mainview, &_underSubtitlesBackupRect, &_underSubtitlesScreenRect);
|
2016-10-25 23:32:15 +02:00
|
|
|
savedUnderSubtitles = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::af_subtitlehnm() {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *src = p_subtitlesview_buf;
|
|
|
|
byte *dst = p_hnmview_buf + subtitles_x_scr_margin + (158 - num_text_lines * FONT_HEIGHT) * 320;
|
2016-11-13 15:46:36 -08:00
|
|
|
for (int16 y = 0; y < num_text_lines * FONT_HEIGHT; y++) {
|
|
|
|
for (int16 x = 0; x < subtitles_x_width; x++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
char c = *src++;
|
|
|
|
if (c)
|
|
|
|
*dst = c;
|
|
|
|
dst++;
|
|
|
|
}
|
|
|
|
dst += 320 - subtitles_x_width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::patchphrase() {
|
|
|
|
phraseBuffer[36] = 'c';
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::vavapers() {
|
|
|
|
perso_t *perso = p_global->perso_ptr;
|
2016-10-07 00:45:08 +02:00
|
|
|
p_global->curPersoFlags = perso->_flags;
|
|
|
|
p_global->curPersoItems = perso->_items;
|
|
|
|
p_global->curPersoPowers = perso->_powers;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::citadelle() {
|
|
|
|
p_global->ff_69++;
|
|
|
|
p_global->ff_F6++;
|
2016-10-24 00:04:32 +02:00
|
|
|
parlemoiNormalFlag = true;
|
2016-11-28 22:33:39 -08:00
|
|
|
closeCharacterDialog = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::choixzone() {
|
|
|
|
if (p_global->giveobj3)
|
|
|
|
p_global->iconsIndex = 6;
|
|
|
|
else
|
|
|
|
p_global->iconsIndex = 10;
|
2016-09-26 07:57:27 +02:00
|
|
|
p_global->autoDialog = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
putobject();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::showevents1() {
|
|
|
|
p_global->ff_113 = 0;
|
|
|
|
perso_ici(3);
|
|
|
|
}
|
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
void EdenGame::showEvents() {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->eventType && p_global->displayFlags != DisplayFlags::dfPerson)
|
|
|
|
showevents1();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::parle_mfin() {
|
|
|
|
perso_t *perso = p_global->perso_ptr;
|
|
|
|
if (p_global->curObjectId) {
|
2016-11-13 15:46:36 -08:00
|
|
|
char curobj = p_global->curObjectId;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->dialogType == DialogType::dtHint)
|
2016-08-18 13:15:54 +02:00
|
|
|
return;
|
2016-11-13 15:46:36 -08:00
|
|
|
object_t *obj = getobjaddr(p_global->curObjectId);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->dialogType == DialogType::dtDinoItem)
|
|
|
|
perso = p_global->room_perso;
|
|
|
|
if (verif_oui()) {
|
2016-09-26 23:44:42 +02:00
|
|
|
loseObject(p_global->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-09-14 23:39:27 +02:00
|
|
|
SpecialObjets(perso, curobj);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!verif_oui())
|
|
|
|
return;
|
|
|
|
nextinfo();
|
|
|
|
if (!p_global->last_info)
|
2016-11-28 22:33:39 -08:00
|
|
|
closeCharacterDialog = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
else {
|
2016-11-13 13:56:20 -08:00
|
|
|
p_global->_nextDialogPtr = nullptr;
|
2016-11-28 22:33:39 -08:00
|
|
|
closeCharacterDialog = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::parlemoi_normal() {
|
|
|
|
dial_t *dial;
|
2016-11-13 13:56:20 -08:00
|
|
|
if (!p_global->_nextDialogPtr) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso = p_global->perso_ptr;
|
|
|
|
if (perso) {
|
2016-10-07 00:45:08 +02:00
|
|
|
int16 num = (perso->_id << 3) | p_global->dialogType;
|
|
|
|
dial = (dial_t *)getElem(gameDialogs, num);
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
|
|
|
close_perso();
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-11-28 22:33:39 -08:00
|
|
|
if (closeCharacterDialog) {
|
2016-09-14 23:39:27 +02:00
|
|
|
close_perso();
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-11-13 13:56:20 -08:00
|
|
|
dial = p_global->_nextDialogPtr;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-11-13 15:46:36 -08:00
|
|
|
char ok = dial_scan(dial);
|
2016-11-13 13:56:20 -08:00
|
|
|
p_global->_nextDialogPtr = p_global->_dialogPtr;
|
2016-11-28 22:33:39 -08:00
|
|
|
closeCharacterDialog = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!ok)
|
|
|
|
close_perso();
|
|
|
|
else
|
|
|
|
parle_mfin();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::parle_moi() {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte r28;
|
2016-09-14 23:39:27 +02:00
|
|
|
char ok;
|
|
|
|
dial_t *dial;
|
|
|
|
endpersovox();
|
|
|
|
r28 = p_global->ff_F6;
|
|
|
|
p_global->ff_F6 = 0;
|
|
|
|
if (!r28) {
|
|
|
|
init_non();
|
|
|
|
if (p_global->drawFlags & DrawFlags::drDrawInventory)
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->drawFlags & DrawFlags::drDrawTopScreen)
|
2016-09-25 23:17:25 +02:00
|
|
|
drawTopScreen();
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->curObjectId) {
|
|
|
|
if (p_global->dialogType == DialogType::dtTalk) {
|
|
|
|
p_global->dialogType = DialogType::dtItem;
|
2016-11-13 13:56:20 -08:00
|
|
|
p_global->_nextDialogPtr = nullptr;
|
2016-11-28 22:33:39 -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
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->dialogType == DialogType::dtItem) {
|
|
|
|
p_global->dialogType = DialogType::dtTalk;
|
2016-11-28 22:33:39 -08:00
|
|
|
if (!closeCharacterDialog)
|
2016-11-13 13:56:20 -08:00
|
|
|
p_global->_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;
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!p_global->last_dialog_ptr) {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 num = 160;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->phaseNum >= 400)
|
|
|
|
num++;
|
2016-10-07 00:45:08 +02:00
|
|
|
dial = (dial_t *)getElem(gameDialogs, num);
|
2016-08-18 13:15:54 +02:00
|
|
|
} else
|
2016-09-14 23:39:27 +02:00
|
|
|
dial = p_global->last_dialog_ptr;
|
|
|
|
ok = dial_scan(dial);
|
2016-10-24 22:02:43 +02:00
|
|
|
p_global->last_dialog_ptr = p_global->_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;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->ff_60) {
|
|
|
|
if (p_global->perso_ptr == &kPersons[PER_MESSAGER]) {
|
2016-10-24 00:04:32 +02:00
|
|
|
p_global->dialogType = DialogType::dtTalk;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->eloiHaveNews)
|
|
|
|
parlemoi_normal();
|
|
|
|
else
|
|
|
|
close_perso();
|
|
|
|
} else
|
|
|
|
close_perso();
|
|
|
|
} else
|
|
|
|
parlemoi_normal();
|
|
|
|
} else
|
|
|
|
parle_mfin();
|
|
|
|
} else
|
|
|
|
close_perso();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::init_perso_ptr(perso_t *perso) {
|
2016-10-07 00:45:08 +02:00
|
|
|
p_global->metPersonsMask1 |= perso->_partyMask;
|
|
|
|
p_global->metPersonsMask2 |= perso->_partyMask;
|
2016-11-13 13:56:20 -08:00
|
|
|
p_global->_nextDialogPtr = nullptr;
|
2016-11-28 22:33:39 -08:00
|
|
|
closeCharacterDialog = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
dialogSkipFlags = DialogFlags::dfSpoken;
|
2016-10-24 22:02:43 +02:00
|
|
|
p_global->ff_60 = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->textToken1 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::perso1(perso_t *perso) {
|
|
|
|
p_global->phaseActionsCount++;
|
|
|
|
if (perso == &kPersons[PER_THOO])
|
|
|
|
p_global->phaseActionsCount--;
|
|
|
|
p_global->perso_ptr = perso;
|
|
|
|
init_perso_ptr(perso);
|
|
|
|
parle_moi();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::perso_normal(perso_t *perso) {
|
2016-10-24 00:04:32 +02:00
|
|
|
p_global->last_dialog_ptr = nullptr;
|
|
|
|
p_global->dialogType = DialogType::dtTalk;
|
|
|
|
parlemoiNormalFlag = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso1(perso);
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::persoparle(int16 pers) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso = &kPersons[pers];
|
|
|
|
p_global->perso_ptr = perso;
|
|
|
|
p_global->dialogType = DialogType::dtInspect;
|
2016-10-07 00:45:08 +02:00
|
|
|
uint16 idx = perso->_id * 8 | p_global->dialogType;
|
2016-11-13 15:46:36 -08:00
|
|
|
dialoscansvmas((dial_t *)getElem(gameDialogs, idx));
|
2016-10-07 23:06:10 +02:00
|
|
|
displayPlace();
|
2016-09-14 23:39:27 +02:00
|
|
|
af_subtitle();
|
|
|
|
persovox();
|
|
|
|
p_global->ff_CA = 0;
|
2016-10-24 00:04:32 +02:00
|
|
|
p_global->dialogType = DialogType::dtTalk;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::roi() {
|
|
|
|
perso_normal(&kPersons[PER_ROI]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::dina() {
|
|
|
|
perso_normal(&kPersons[PER_DINA]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::thoo() {
|
|
|
|
perso_normal(&kPersons[PER_THOO]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::monk() {
|
|
|
|
perso_normal(&kPersons[PER_MONK]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::bourreau() {
|
|
|
|
perso_normal(&kPersons[PER_BOURREAU]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::messager() {
|
|
|
|
perso_normal(&kPersons[PER_MESSAGER]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::mango() {
|
|
|
|
perso_normal(&kPersons[PER_MANGO]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::eve() {
|
|
|
|
perso_normal(&kPersons[PER_EVE]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::azia() {
|
|
|
|
perso_normal(&kPersons[PER_AZIA]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::mammi() {
|
|
|
|
perso_t *perso;
|
2016-10-07 00:45:08 +02:00
|
|
|
for (perso = &kPersons[PER_MAMMI]; perso->_partyMask == PersonMask::pmLeader; perso++) {
|
|
|
|
if (perso->_roomNum == p_global->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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::gardes() {
|
|
|
|
perso_normal(&kPersons[PER_GARDES]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::bambou() {
|
|
|
|
perso_normal(&kPersons[PER_BAMBOO]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::kabuka() {
|
|
|
|
if (p_global->roomNum == 0x711) perso_normal(&kPersons[PER_KABUKA]);
|
|
|
|
else bambou();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::fisher() {
|
|
|
|
if (p_global->roomNum == 0x902) perso_normal(&kPersons[PER_FISHER]);
|
|
|
|
else kabuka();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::dino() {
|
|
|
|
perso_t *perso = p_global->room_perso;
|
|
|
|
if (!perso)
|
|
|
|
return;
|
2016-10-24 00:04:32 +02:00
|
|
|
parlemoiNormalFlag = true;
|
|
|
|
p_global->dialogType = DialogType::dtTalk;
|
2016-10-07 00:45:08 +02:00
|
|
|
p_global->roomPersoFlags = perso->_flags;
|
|
|
|
p_global->roomPersoItems = perso->_items;
|
|
|
|
p_global->roomPersoPowers = perso->_powers;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->perso_ptr = perso;
|
|
|
|
init_perso_ptr(perso);
|
|
|
|
debug("beg dino talk");
|
|
|
|
parle_moi();
|
|
|
|
debug("end dino talk");
|
|
|
|
if (p_global->areaNum == Areas::arWhiteArch)
|
|
|
|
return;
|
|
|
|
if (p_global->ff_60)
|
|
|
|
waitendspeak();
|
|
|
|
if (pomme_q)
|
|
|
|
return;
|
|
|
|
perso = &kPersons[PER_MANGO];
|
|
|
|
if (!(p_global->party & PersonMask::pmMungo)) {
|
|
|
|
perso = &kPersons[PER_DINA];
|
|
|
|
if (!(p_global->party & PersonMask::pmDina)) {
|
|
|
|
perso = &kPersons[PER_EVE];
|
|
|
|
if (!(p_global->party & PersonMask::pmEve)) {
|
|
|
|
perso = &kPersons[PER_GARDES];
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->dialogType = DialogType::dtDinoAction;
|
|
|
|
if (p_global->curObjectId)
|
|
|
|
p_global->dialogType = DialogType::dtDinoItem;
|
|
|
|
perso1(perso);
|
|
|
|
if (p_global->roomPersoType == PersonFlags::pftMosasaurus && !p_global->curObjectId) {
|
|
|
|
p_global->area_ptr->flags |= AreaFlags::afFlag20;
|
|
|
|
lieuvava(p_global->area_ptr);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::tyran() {
|
|
|
|
perso_t *perso = p_global->room_perso;
|
|
|
|
if (!perso)
|
|
|
|
return;
|
2016-10-24 00:04:32 +02:00
|
|
|
|
|
|
|
parlemoiNormalFlag = true;
|
|
|
|
p_global->dialogType = DialogType::dtTalk;
|
2016-10-07 00:45:08 +02:00
|
|
|
p_global->roomPersoFlags = perso->_flags;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->perso_ptr = perso;
|
|
|
|
init_perso_ptr(perso);
|
|
|
|
perso = &kPersons[PER_MANGO];
|
|
|
|
if (!(p_global->party & PersonMask::pmMungo)) {
|
|
|
|
perso = &kPersons[PER_DINA];
|
|
|
|
if (!(p_global->party & PersonMask::pmDina)) {
|
|
|
|
perso = &kPersons[PER_EVE];
|
|
|
|
if (!(p_global->party & PersonMask::pmEve)) {
|
|
|
|
perso = &kPersons[PER_GARDES];
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->dialogType = DialogType::dtDinoAction;
|
|
|
|
if (p_global->curObjectId)
|
|
|
|
p_global->dialogType = DialogType::dtDinoItem;
|
|
|
|
perso1(perso);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::morkus() {
|
|
|
|
perso_normal(&kPersons[PER_MORKUS]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::comment() {
|
2016-10-24 00:04:32 +02:00
|
|
|
perso_t *perso = &kPersons[PER_DINA];
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!(p_global->party & PersonMask::pmDina)) {
|
|
|
|
perso = &kPersons[PER_EVE];
|
|
|
|
if (!(p_global->party & PersonMask::pmEve)) {
|
|
|
|
perso = &kPersons[PER_GARDES];
|
2016-10-24 00:04:32 +02:00
|
|
|
if (!(p_global->party & PersonMask::pmThugg))
|
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
|
|
|
p_global->dialogType = DialogType::dtHint;
|
|
|
|
perso1(perso);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::adam() {
|
2016-09-26 23:44:42 +02:00
|
|
|
resetScroll();
|
2016-09-14 23:39:27 +02:00
|
|
|
switch (p_global->curObjectId) {
|
|
|
|
case Objects::obNone:
|
|
|
|
gotopanel();
|
|
|
|
break;
|
|
|
|
case Objects::obRoot:
|
|
|
|
if (p_global->roomNum == 2817
|
|
|
|
&& p_global->phaseNum > 496 && p_global->phaseNum < 512) {
|
|
|
|
bigphase1();
|
2016-09-26 23:44:42 +02:00
|
|
|
loseObject(Objects::obRoot);
|
2016-09-25 23:17:25 +02:00
|
|
|
p_global->ff_100 = 0xFF;
|
2016-09-26 23:44:42 +02:00
|
|
|
quitMirror();
|
2016-09-14 23:39:27 +02:00
|
|
|
maj_salle(p_global->roomNum);
|
|
|
|
reste_ici(5);
|
|
|
|
p_global->eventType = EventType::etEvent3;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-09-14 23:39:27 +02:00
|
|
|
waitendspeak();
|
|
|
|
if (pomme_q)
|
|
|
|
return;
|
|
|
|
close_perso();
|
|
|
|
reste_ici(5);
|
|
|
|
p_global->roomNum = 2818;
|
|
|
|
p_global->areaNum = Areas::arWhiteArch;
|
|
|
|
p_global->eventType = EventType::etEvent5;
|
|
|
|
p_global->valleyVidNum = 0;
|
|
|
|
p_global->ff_102 = 6;
|
|
|
|
p_global->newMusicType = MusicType::mtNormal;
|
|
|
|
maj_salle(p_global->roomNum);
|
|
|
|
} else {
|
|
|
|
p_global->dialogType = DialogType::dtHint;
|
|
|
|
perso1(&kPersons[PER_EVE]);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
|
|
|
case Objects::obShell:
|
|
|
|
p_global->dialogType = DialogType::dtHint;
|
|
|
|
perso1(&kPersons[PER_THOO]);
|
|
|
|
break;
|
|
|
|
case Objects::obFlute:
|
|
|
|
case Objects::obTrumpet:
|
|
|
|
if (p_global->roomPersoType) {
|
2016-09-26 23:44:42 +02:00
|
|
|
quitMirror();
|
2016-09-14 23:39:27 +02:00
|
|
|
maj_salle(p_global->roomNum);
|
|
|
|
dino();
|
|
|
|
} 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: {
|
2016-09-14 23:39:27 +02:00
|
|
|
if ((p_global->partyOutside & PersonMask::pmDina)
|
|
|
|
&& p_global->curObjectId == Objects::obTablet1 && p_global->phaseNum == 370)
|
|
|
|
incphase1();
|
2016-10-24 00:04:32 +02:00
|
|
|
char *objvid = &kTabletView[(p_global->curObjectId - Objects::obTablet1) * 2];
|
|
|
|
object_t *object = getobjaddr(*objvid++);
|
|
|
|
int16 vid = 84;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (!object->_count)
|
2016-09-14 23:39:27 +02:00
|
|
|
vid = *objvid;
|
|
|
|
bars_out();
|
2016-09-26 23:44:42 +02:00
|
|
|
specialTextMode = true;
|
|
|
|
playHNM(vid);
|
2016-10-25 23:32:15 +02:00
|
|
|
needPaletteUpdate = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_102 = 16;
|
2016-09-28 07:29:12 +02:00
|
|
|
showBars();
|
2016-09-14 23:39:27 +02:00
|
|
|
gametomiroir(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:
|
|
|
|
if (p_global->party & PersonMask::pmThugg) {
|
|
|
|
p_global->dialogType = DialogType::dtHint;
|
|
|
|
perso1(&kPersons[PER_GARDES]);
|
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-09-14 23:39:27 +02:00
|
|
|
void EdenGame::init_oui() {
|
|
|
|
word_30AFC = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::init_non() {
|
|
|
|
word_30AFC = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::oui() {
|
|
|
|
word_30AFC = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::non() {
|
|
|
|
word_30AFC = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
char EdenGame::verif_oui() {
|
|
|
|
return word_30AFC == -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::SpcChampi(perso_t *perso) {
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags |= PersonFlags::pf10;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->area_ptr->flags |= AreaFlags::afFlag2;
|
|
|
|
p_global->curAreaFlags |= AreaFlags::afFlag2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::SpcNidv(perso_t *perso) {
|
|
|
|
if (!verif_oui())
|
|
|
|
return;
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags |= PersonFlags::pf10;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->roomPersoFlags |= PersonFlags::pf10;
|
|
|
|
p_global->gameFlags |= GameFlags::gfFlag400;
|
|
|
|
if (p_global->perso_ptr == &kPersons[PER_EVE]) {
|
|
|
|
p_global->area_ptr->flags |= AreaFlags::afFlag4;
|
|
|
|
p_global->curAreaFlags |= AreaFlags::afFlag4;
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags |= PersonFlags::pfInParty;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->roomPersoFlags |= PersonFlags::pfInParty;
|
|
|
|
lieuvava(p_global->area_ptr);
|
|
|
|
} else {
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags &= ~PersonFlags::pf10;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->roomPersoFlags &= ~PersonFlags::pf10;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::SpcNido(perso_t *perso) {
|
|
|
|
if (perso == &kPersons[PER_GARDES])
|
|
|
|
giveobject();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::SpcPomme(perso_t *perso) {
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags |= PersonFlags::pf10;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->area_ptr->flags |= AreaFlags::afFlag8;
|
|
|
|
p_global->curAreaFlags |= AreaFlags::afFlag8;
|
|
|
|
p_global->gameFlags |= GameFlags::gfFlag200;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::SpcOr(perso_t *perso) {
|
|
|
|
if (!verif_oui())
|
|
|
|
return;
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_items = currentSpecialObject->_itemMask;
|
|
|
|
p_global->roomPersoItems = currentSpecialObject->_itemMask;
|
|
|
|
perso->_flags |= PersonFlags::pf10;
|
|
|
|
perso->_flags &= ~PersonFlags::pfInParty;
|
|
|
|
perso->_targetLoc = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->area_ptr->flags |= AreaFlags::afGaveGold;
|
|
|
|
p_global->curAreaFlags |= AreaFlags::afGaveGold;
|
|
|
|
if (p_global->phaseNum == 226)
|
|
|
|
incphase1();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::SpcPrisme(perso_t *perso) {
|
|
|
|
if (perso == &kPersons[PER_DINA]) {
|
|
|
|
if (p_global->partyOutside & PersonMask::pmMonk)
|
|
|
|
p_global->gameFlags |= GameFlags::gfPrismAndMonk;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::SpcTalisman(perso_t *perso) {
|
|
|
|
if (perso == &kPersons[PER_DINA])
|
|
|
|
suis_moi(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::SpcMasque(perso_t *perso) {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::SpcSac(perso_t *perso) {
|
|
|
|
if (p_global->textToken1 != 3)
|
|
|
|
return;
|
|
|
|
if (perso == &kPersons[PER_KABUKA] || perso == &kPersons[PER_MAMMI_3])
|
2016-10-07 00:45:08 +02:00
|
|
|
loseObject(currentSpecialObject->_id);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::SpcTrompet(perso_t *perso) {
|
|
|
|
if (!verif_oui())
|
|
|
|
return;
|
|
|
|
p_global->ff_54 = 4;
|
|
|
|
winobject(Objects::obTrumpet);
|
|
|
|
p_global->drawFlags |= DrawFlags::drDrawInventory;
|
2016-11-28 22:33:39 -08:00
|
|
|
closeCharacterDialog = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
TyranMeurt(p_global->room_perso);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::SpcArmes(perso_t *perso) {
|
|
|
|
if (!verif_oui())
|
|
|
|
return;
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_powers = currentSpecialObject->_powerMask;
|
|
|
|
p_global->roomPersoPowers = currentSpecialObject->_powerMask;
|
2016-09-14 23:39:27 +02:00
|
|
|
giveobject();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::SpcInstru(perso_t *perso) {
|
|
|
|
if (!verif_oui())
|
|
|
|
return;
|
|
|
|
if (perso == &kPersons[PER_MONK]) {
|
|
|
|
p_global->partyInstruments &= ~1; //TODO: check me
|
2016-10-07 00:45:08 +02:00
|
|
|
if (currentSpecialObject->_id == Objects::obRing) {
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->partyInstruments |= 1;
|
|
|
|
p_global->monkGotRing++; //TODO: |= 1 ?
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (perso == &kPersons[PER_GARDES]) {
|
|
|
|
p_global->partyInstruments &= ~2;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (currentSpecialObject->_id == Objects::obDrum)
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->partyInstruments |= 2;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_powers = currentSpecialObject->_powerMask;
|
|
|
|
p_global->curPersoPowers = currentSpecialObject->_powerMask;
|
2016-09-14 23:39:27 +02:00
|
|
|
giveobject();
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
void EdenGame::SpcOeuf(perso_t *perso) {
|
|
|
|
if (!verif_oui())
|
|
|
|
return;
|
|
|
|
gameIcons[131].cursor_id &= ~0x8000;
|
|
|
|
p_global->persoBackgroundBankIdx = 62;
|
|
|
|
dialautoon();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::TyranMeurt(perso_t *perso) {
|
2016-10-07 00:45:08 +02:00
|
|
|
perso->_flags |= PersonFlags::pf80;
|
|
|
|
perso->_roomNum = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
delinfo(p_global->areaNum + ValleyNews::vnTyrannIn);
|
|
|
|
p_global->roomPersoType = 0;
|
|
|
|
p_global->roomPersoFlags = 0;
|
|
|
|
p_global->chrono_on = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::SpecialObjets(perso_t *perso, char objid) {
|
|
|
|
typedef void (EdenGame::*disp_t)(perso_t *perso);
|
|
|
|
struct spcobj_t {
|
|
|
|
char persoType;
|
|
|
|
char objectId;
|
|
|
|
//void (EdenGame::*disp)(perso_t *perso);
|
|
|
|
disp_t disp;
|
|
|
|
};
|
|
|
|
|
|
|
|
static spcobj_t kSpecialObjectActions[] = {
|
|
|
|
// perso, obj, disp
|
|
|
|
{ PersonFlags::pfType8, Objects::obShroom, &EdenGame::SpcChampi },
|
|
|
|
{ PersonFlags::pftTriceraptor, Objects::obNest, &EdenGame::SpcNidv },
|
|
|
|
{ PersonFlags::pfType0, Objects::obFullNest, &EdenGame::SpcNido },
|
|
|
|
{ PersonFlags::pftMosasaurus, Objects::obApple, &EdenGame::SpcPomme },
|
|
|
|
{ PersonFlags::pftVelociraptor, Objects::obGold, &EdenGame::SpcOr },
|
|
|
|
{ PersonFlags::pfType0, Objects::obPrism, &EdenGame::SpcPrisme },
|
|
|
|
{ PersonFlags::pfType0, Objects::obTalisman, &EdenGame::SpcTalisman },
|
|
|
|
{ PersonFlags::pfType2, Objects::obMaskOfDeath, &EdenGame::SpcMasque },
|
|
|
|
{ PersonFlags::pfType2, Objects::obMaskOfBonding, &EdenGame::SpcMasque },
|
|
|
|
{ PersonFlags::pfType2, Objects::obMaskOfBirth, &EdenGame::SpcMasque },
|
|
|
|
{ PersonFlags::pfType0, Objects::obBag, &EdenGame::SpcSac },
|
|
|
|
{ PersonFlags::pfType2, Objects::obBag, &EdenGame::SpcSac },
|
|
|
|
{ PersonFlags::pftTyrann, Objects::obTrumpet, &EdenGame::SpcTrompet },
|
|
|
|
{ PersonFlags::pftVelociraptor, Objects::obEyeInTheStorm, &EdenGame::SpcArmes },
|
|
|
|
{ PersonFlags::pftVelociraptor, Objects::obSkyHammer, &EdenGame::SpcArmes },
|
|
|
|
{ PersonFlags::pftVelociraptor, Objects::obFireInTheClouds, &EdenGame::SpcArmes },
|
|
|
|
{ PersonFlags::pftVelociraptor, Objects::obWithinAndWithout, &EdenGame::SpcArmes },
|
|
|
|
{ PersonFlags::pftVelociraptor, Objects::obEyeInTheCyclone, &EdenGame::SpcArmes },
|
|
|
|
{ PersonFlags::pftVelociraptor, Objects::obRiverThatWinds, &EdenGame::SpcArmes },
|
|
|
|
{ PersonFlags::pfType0, Objects::obTrumpet, &EdenGame::SpcInstru },
|
|
|
|
{ PersonFlags::pfType0, Objects::obDrum, &EdenGame::SpcInstru },
|
|
|
|
{ PersonFlags::pfType0, Objects::obRing, &EdenGame::SpcInstru },
|
|
|
|
{ PersonFlags::pfType0, Objects::obEgg, &EdenGame::SpcOeuf },
|
|
|
|
{ -1, -1, nullptr }
|
|
|
|
};
|
|
|
|
spcobj_t *spcobj = kSpecialObjectActions;
|
2016-10-07 00:45:08 +02:00
|
|
|
char persoType = perso->_flags & PersonFlags::pfTypeMask;
|
2016-09-14 23:39:27 +02:00
|
|
|
currentSpecialObject = &objects[objid - 1];
|
|
|
|
for (; spcobj->persoType != -1; spcobj++) {
|
|
|
|
if (spcobj->objectId == objid && spcobj->persoType == persoType) {
|
|
|
|
(this->*spcobj->disp)(perso);
|
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::dialautoon() {
|
|
|
|
p_global->iconsIndex = 4;
|
2016-09-26 07:57:27 +02:00
|
|
|
p_global->autoDialog = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
putobject();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::dialautooff() {
|
|
|
|
p_global->iconsIndex = 0x10;
|
2016-09-26 07:57:27 +02:00
|
|
|
p_global->autoDialog = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::follow() {
|
|
|
|
if (p_global->roomPersoType == PersonFlags::pfType12) {
|
2016-10-08 21:21:21 +02:00
|
|
|
debug("follow: hiding person %ld", p_global->room_perso - kPersons);
|
2016-10-07 00:45:08 +02:00
|
|
|
p_global->room_perso->_flags |= PersonFlags::pf80;
|
|
|
|
p_global->room_perso->_roomNum = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->gameFlags |= GameFlags::gfFlag8;
|
|
|
|
gameIcons[123].object_id = 18;
|
|
|
|
gameIcons[124].object_id = 35;
|
|
|
|
gameIcons[125].cursor_id &= ~0x8000;
|
|
|
|
p_global->persoBackgroundBankIdx = 56;
|
|
|
|
} else
|
|
|
|
suis_moi5();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::dialonfollow() {
|
|
|
|
p_global->iconsIndex = 4;
|
2016-09-26 07:57:27 +02:00
|
|
|
p_global->autoDialog = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
follow();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::abortdial() {
|
|
|
|
p_global->ff_F6++;
|
|
|
|
if (p_global->roomPersoType != PersonFlags::pftTriceraptor || p_global->perso_ptr != &kPersons[PER_EVE])
|
|
|
|
return;
|
|
|
|
p_global->area_ptr->flags |= AreaFlags::afFlag4;
|
|
|
|
p_global->curAreaFlags |= AreaFlags::afFlag4;
|
2016-10-07 00:45:08 +02:00
|
|
|
p_global->room_perso->_flags |= PersonFlags::pfInParty;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->roomPersoFlags |= PersonFlags::pfInParty;
|
|
|
|
lieuvava(p_global->area_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::narrateur() {
|
|
|
|
if (!(p_global->displayFlags & DisplayFlags::dfFlag1))
|
|
|
|
return;
|
|
|
|
if (!p_global->narratorSequence) {
|
|
|
|
if (p_global->ff_6A == p_global->ff_69)
|
|
|
|
goto skip;
|
|
|
|
buildcita();
|
|
|
|
}
|
|
|
|
p_global->ff_F5 |= 0x80;
|
|
|
|
p_global->ff_F2 &= ~1; //TODO: check me
|
|
|
|
p_global->perso_ptr = &kPersons[PER_UNKN_156];
|
2016-10-24 22:02:43 +02:00
|
|
|
p_global->ff_60 = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->eventType = 0;
|
|
|
|
p_global->ff_103 = 69;
|
|
|
|
if (dialo_even(&kPersons[PER_UNKN_156])) {
|
2016-10-24 22:02:43 +02:00
|
|
|
p_global->narrator_dialog_ptr = p_global->_dialogPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
|
|
|
p_global->ff_F2 |= 1;
|
|
|
|
waitendspeak();
|
|
|
|
if (pomme_q)
|
2016-08-18 13:15:54 +02:00
|
|
|
return;
|
2016-09-14 23:39:27 +02:00
|
|
|
endpersovox();
|
|
|
|
while (dialoscansvmas(p_global->narrator_dialog_ptr)) {
|
2016-10-24 22:02:43 +02:00
|
|
|
p_global->narrator_dialog_ptr = p_global->_dialogPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
waitendspeak();
|
|
|
|
if (pomme_q)
|
|
|
|
return;
|
|
|
|
endpersovox();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-10-24 22:02:43 +02:00
|
|
|
p_global->narrator_dialog_ptr = p_global->_dialogPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_102 = 0;
|
|
|
|
p_global->ff_103 = 0;
|
|
|
|
close_perso();
|
|
|
|
lieuvava(p_global->area_ptr);
|
|
|
|
if (p_global->narratorSequence == 8)
|
|
|
|
deplaval(134);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_103 = 0;
|
|
|
|
if (p_global->narratorSequence == 10) {
|
|
|
|
suis_moi(5);
|
|
|
|
suis_moi(7);
|
|
|
|
suis_moi(3);
|
|
|
|
suis_moi(18);
|
|
|
|
reste_ici(6);
|
|
|
|
p_global->eloiHaveNews = 0;
|
|
|
|
deplaval(139);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->eventType = EventType::etEventD;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_F5 &= ~0x80;
|
|
|
|
skip:
|
|
|
|
;
|
|
|
|
p_global->ff_F2 &= ~1; //TODO: check me
|
|
|
|
if (p_global->narratorSequence > 50 && p_global->narratorSequence <= 80)
|
|
|
|
p_global->endGameFlag = 50;
|
|
|
|
if (p_global->narratorSequence == 3)
|
|
|
|
chronoon(1200);
|
|
|
|
p_global->narratorSequence = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::vrf_phrases_file() {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 num = 3;
|
2016-10-24 22:02:43 +02:00
|
|
|
if (p_global->_dialogPtr < (dial_t *)getElem(gameDialogs, 48))
|
2016-09-14 23:39:27 +02:00
|
|
|
num = 1;
|
2016-10-24 22:02:43 +02:00
|
|
|
else if (p_global->_dialogPtr < (dial_t *)getElem(gameDialogs, 128))
|
2016-09-14 23:39:27 +02:00
|
|
|
num = 2;
|
|
|
|
p_global->textBankIndex = num;
|
|
|
|
if (p_global->pref_language)
|
|
|
|
num += (p_global->pref_language - 1) * 3;
|
|
|
|
if (num == lastPhrasesFile)
|
|
|
|
return;
|
|
|
|
lastPhrasesFile = num;
|
|
|
|
num += 404;
|
2016-09-28 07:29:12 +02:00
|
|
|
loadFile(num, gamePhrases);
|
2016-09-14 23:39:27 +02:00
|
|
|
verifh(gamePhrases);
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *EdenGame::gettxtad(int16 id) {
|
2016-09-14 23:39:27 +02:00
|
|
|
vrf_phrases_file();
|
2016-10-07 00:45:08 +02:00
|
|
|
return (byte *)getElem(gamePhrases, id - 1);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::gotocarte() {
|
|
|
|
goto_t *go = &gotos[current_spot2->object_id];
|
|
|
|
endpersovox();
|
2016-10-24 00:04:32 +02:00
|
|
|
char newArea = go->areaNum;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->newRoomNum = (go->areaNum << 8) | 1;
|
|
|
|
p_global->newLocation = 1;
|
|
|
|
p_global->prevLocation = p_global->roomNum & 0xFF;
|
2016-10-24 00:04:32 +02:00
|
|
|
char curArea = p_global->roomNum >> 8;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (curArea == go->areaNum)
|
|
|
|
newArea = 0;
|
|
|
|
else {
|
2016-10-24 00:04:32 +02:00
|
|
|
for (; go->curAreaNum != 0xFF; go++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (go->curAreaNum == curArea)
|
|
|
|
break;
|
2016-10-24 00:04:32 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
if (go->areaNum == 0xFF)
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->eventType = EventType::etGotoArea | newArea;
|
|
|
|
init_oui();
|
|
|
|
showevents1();
|
|
|
|
waitendspeak();
|
|
|
|
if (pomme_q)
|
|
|
|
return;
|
2016-10-24 00:04:32 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
close_perso();
|
|
|
|
if (verif_oui())
|
|
|
|
gotolieu(go);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::record() {
|
|
|
|
if (p_global->curObjectId)
|
|
|
|
return;
|
2016-10-24 00:04:32 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->perso_ptr >= &kPersons[PER_UNKN_18C])
|
|
|
|
return;
|
2016-10-24 00:04:32 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->eventType == EventType::etEventE || p_global->eventType >= EventType::etGotoArea)
|
|
|
|
return;
|
2016-10-24 00:04:32 +02:00
|
|
|
|
|
|
|
for (tape_t *tape = tapes; tape != tapes + MAX_TAPES; tape++) {
|
2016-10-07 23:06:10 +02:00
|
|
|
if (tape->_textNum == p_global->textNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-10-24 00:04:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
tape_t *tape = tapes;
|
|
|
|
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;
|
|
|
|
tape->_bgBankNum = tape[+1]._bgBankNum;
|
|
|
|
tape->_dialog = tape[+1]._dialog;
|
2016-09-14 23:39:27 +02:00
|
|
|
tape++;
|
|
|
|
}
|
2016-10-24 00:04:32 +02:00
|
|
|
|
|
|
|
perso_t *perso = p_global->perso_ptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (perso == &kPersons[PER_EVE])
|
|
|
|
perso = p_global->phaseNum >= 352 ? &kPersons[PER_UNKN_372]
|
|
|
|
: &kPersons[PER_UNKN_402];
|
2016-10-07 23:06:10 +02:00
|
|
|
tape->_textNum = p_global->textNum;
|
|
|
|
tape->_perso = perso;
|
|
|
|
tape->_party = p_global->party;
|
|
|
|
tape->_roomNum = p_global->roomNum;
|
|
|
|
tape->_bgBankNum = p_global->roomBgBankNum;
|
2016-10-24 22:02:43 +02:00
|
|
|
tape->_dialog = p_global->_dialogPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-11-13 15:46:36 -08:00
|
|
|
bool EdenGame::dial_scan(dial_t *dial) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->numGiveObjs) {
|
|
|
|
if (!(p_global->displayFlags & DisplayFlags::dfFlag2))
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->numGiveObjs = 0;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-10-24 22:02:43 +02:00
|
|
|
p_global->_dialogPtr = dial;
|
2016-09-14 23:39:27 +02:00
|
|
|
vavapers();
|
|
|
|
p_global->phraseBufferPtr = phraseBuffer;
|
2016-11-13 15:46:36 -08:00
|
|
|
byte hidx, lidx;
|
|
|
|
uint16 mask;
|
2016-10-24 22:02:43 +02:00
|
|
|
for (;; p_global->_dialogPtr++) {
|
|
|
|
for (;; p_global->_dialogPtr++) {
|
|
|
|
if (p_global->_dialogPtr->_flags == -1 && p_global->_dialogPtr->_condNumLow == -1)
|
2016-11-13 15:46:36 -08:00
|
|
|
return false;
|
2016-10-24 22:02:43 +02:00
|
|
|
byte flags = p_global->_dialogPtr->_flags;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->dialogFlags = flags;
|
|
|
|
if (!(flags & DialogFlags::dfSpoken) || (flags & DialogFlags::dfRepeatable)) {
|
2016-10-24 22:02:43 +02:00
|
|
|
hidx = (p_global->_dialogPtr->_textCondHiMask >> 6) & 3;
|
|
|
|
lidx = p_global->_dialogPtr->_condNumLow;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (flags & 0x10)
|
|
|
|
hidx |= 4;
|
|
|
|
if (testcondition(((hidx << 8) | lidx) & 0x7FF))
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
if (flags & dialogSkipFlags)
|
|
|
|
continue;
|
2016-10-24 22:02:43 +02:00
|
|
|
hidx = (p_global->_dialogPtr->_textCondHiMask >> 6) & 3;
|
|
|
|
lidx = p_global->_dialogPtr->_condNumLow;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (flags & 0x10)
|
|
|
|
hidx |= 4;
|
|
|
|
if (testcondition(((hidx << 8) | lidx) & 0x7FF))
|
|
|
|
break;
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-11-13 15:46:36 -08:00
|
|
|
char bidx = (p_global->_dialogPtr->_textCondHiMask >> 2) & 0xF;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!bidx)
|
|
|
|
goto no_perso; //TODO: rearrange
|
|
|
|
mask = (p_global->party | p_global->partyOutside) & (1 << (bidx - 1));
|
|
|
|
if (mask)
|
|
|
|
break;
|
|
|
|
}
|
2016-11-13 15:46:36 -08:00
|
|
|
perso_t *perso;
|
2016-10-24 00:04:32 +02:00
|
|
|
for (perso = kPersons; !(perso->_partyMask == mask && perso->_roomNum == p_global->roomNum); perso++)
|
|
|
|
; //Find matching
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->perso_ptr = perso;
|
|
|
|
init_perso_ptr(perso);
|
|
|
|
no_perso();
|
|
|
|
no_perso:
|
|
|
|
;
|
2016-10-24 22:02:43 +02:00
|
|
|
hidx = p_global->_dialogPtr->_textCondHiMask;
|
|
|
|
lidx = p_global->_dialogPtr->_textNumLow;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->textNum = ((hidx << 8) | lidx) & 0x3FF;
|
|
|
|
if (p_global->phraseBufferPtr != phraseBuffer) {
|
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[])() = {
|
|
|
|
&EdenGame::oui,
|
|
|
|
&EdenGame::non,
|
|
|
|
&EdenGame::eloipart,
|
|
|
|
&EdenGame::dialautoon,
|
|
|
|
&EdenGame::dialautooff,
|
|
|
|
&EdenGame::stay_here,
|
|
|
|
&EdenGame::follow,
|
|
|
|
&EdenGame::citadelle,
|
|
|
|
&EdenGame::dialonfollow,
|
|
|
|
&EdenGame::abortdial,
|
|
|
|
&EdenGame::incphase,
|
|
|
|
&EdenGame::bigphase,
|
|
|
|
&EdenGame::giveobject,
|
|
|
|
&EdenGame::choixzone,
|
|
|
|
&EdenGame::lostobject
|
|
|
|
};
|
2016-10-24 22:02:43 +02:00
|
|
|
char pnum = p_global->_dialogPtr->_flags & 0xF;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (pnum)
|
|
|
|
(this->*talk_subject[pnum - 1])();
|
2016-10-24 22:02:43 +02:00
|
|
|
p_global->ff_60 = true;
|
|
|
|
p_global->_dialogPtr->_flags |= DialogFlags::dfSpoken;
|
|
|
|
p_global->_dialogPtr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
if (p_global->dialogType != DialogType::dtInspect) {
|
|
|
|
record();
|
|
|
|
getdatasync();
|
|
|
|
show_perso();
|
|
|
|
persovox();
|
|
|
|
}
|
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
|
|
|
bool EdenGame::dialoscansvmas(dial_t *dial) {
|
2016-10-24 00:04:32 +02:00
|
|
|
char oldFlag = dialogSkipFlags;
|
2016-09-14 23:39:27 +02:00
|
|
|
dialogSkipFlags = DialogFlags::df20;
|
2016-10-24 00:04:32 +02:00
|
|
|
char res = dial_scan(dial);
|
|
|
|
dialogSkipFlags = oldFlag;
|
2016-09-14 23:39:27 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2016-11-13 15:46:36 -08:00
|
|
|
bool EdenGame::dialo_even(perso_t *perso) {
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->perso_ptr = perso;
|
2016-10-24 00:04:32 +02:00
|
|
|
int num = (perso->_id << 3) | DialogType::dtEvent;
|
|
|
|
dial_t *dial = (dial_t *)getElem(gameDialogs, num);
|
2016-11-13 15:46:36 -08:00
|
|
|
bool res = dialoscansvmas(dial);
|
2016-10-24 00:04:32 +02:00
|
|
|
p_global->last_dialog_ptr = nullptr;
|
|
|
|
parlemoiNormalFlag = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::stay_here() {
|
|
|
|
if (p_global->perso_ptr == &kPersons[PER_DINA] && p_global->roomNum == 260)
|
|
|
|
p_global->gameFlags |= GameFlags::gfFlag1000;
|
|
|
|
reste_ici5();
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::mort(int16 vid) {
|
2016-09-14 23:39:27 +02:00
|
|
|
bars_out();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(vid);
|
2016-09-14 23:39:27 +02:00
|
|
|
fadetoblack(2);
|
|
|
|
CLBlitter_FillScreenView(0);
|
|
|
|
CLBlitter_FillView(p_mainview, 0);
|
2016-09-28 07:29:12 +02:00
|
|
|
showBars();
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->narratorSequence = 51;
|
|
|
|
p_global->newMusicType = MusicType::mtNormal;
|
|
|
|
musique();
|
|
|
|
musicspy();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::evenchrono() {
|
|
|
|
if (!(p_global->displayFlags & DisplayFlags::dfFlag1))
|
|
|
|
return;
|
2016-10-24 00:04:32 +02:00
|
|
|
|
|
|
|
uint16 oldGameTime = p_global->gameTime;
|
2016-11-28 22:33:39 -08:00
|
|
|
currentTime = _vm->TimerTicks / 100;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->gameTime = currentTime;
|
2016-10-24 00:04:32 +02:00
|
|
|
if (p_global->gameTime <= oldGameTime)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
|
|
|
heurepasse();
|
|
|
|
if (!(p_global->chrono_on & 1))
|
|
|
|
return;
|
|
|
|
p_global->chrono -= 200;
|
|
|
|
if (p_global->chrono == 0)
|
|
|
|
p_global->chrono_on |= 2;
|
|
|
|
if (!(p_global->chrono_on & 2))
|
|
|
|
return;
|
|
|
|
p_global->chrono_on = 0;
|
|
|
|
p_global->chrono = 0;
|
|
|
|
if (p_global->roomPersoType == PersonFlags::pftTyrann) {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 vid = 272;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->curRoomFlags & 0xC0) {
|
|
|
|
vid += 2;
|
|
|
|
if ((p_global->curRoomFlags & 0xC0) != 0x80) {
|
|
|
|
vid += 2;
|
|
|
|
mort(vid);
|
2016-08-18 13:15:54 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->areaNum == Areas::arUluru || p_global->areaNum == Areas::arTamara) {
|
|
|
|
mort(vid);
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
vid++;
|
|
|
|
mort(vid);
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->roomNum == 2817) {
|
|
|
|
suis_moi(5);
|
|
|
|
p_global->gameFlags |= GameFlags::gfFlag40;
|
|
|
|
dialautoon();
|
|
|
|
} else
|
|
|
|
eloirevient();
|
|
|
|
p_global->eventType = EventType::etEvent10;
|
2016-09-26 23:44:42 +02:00
|
|
|
showEvents();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::chronoon(int16 t) {
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->chrono = t;
|
|
|
|
p_global->chrono_on = 1;
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::prechargephrases(int16 vid) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso = &kPersons[PER_MORKUS];
|
|
|
|
if (vid == 170)
|
|
|
|
perso = &kPersons[PER_UNKN_156];
|
|
|
|
p_global->perso_ptr = perso;
|
|
|
|
p_global->dialogType = DialogType::dtInspect;
|
2016-10-24 00:04:32 +02:00
|
|
|
int num = (perso->_id << 3) | p_global->dialogType;
|
|
|
|
dial_t *dial = (dial_t *)getElem(gameDialogs, num);
|
2016-09-14 23:39:27 +02:00
|
|
|
dialoscansvmas(dial);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::effet1() {
|
|
|
|
rectanglenoir32();
|
2016-09-30 07:48:27 +02:00
|
|
|
if (!_doubledScreen) {
|
2016-09-14 23:39:27 +02:00
|
|
|
setRS1(0, 0, 16 - 1, 4 - 1);
|
2016-11-13 15:46:36 -08:00
|
|
|
int y = p_mainview->_normal._dstTop;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 16; i <= 96; i += 4) {
|
2016-11-13 15:46:36 -08:00
|
|
|
for (int x = p_mainview->_normal._dstLeft; x < p_mainview->_normal._dstLeft + 320; x += 16) {
|
2016-09-14 23:39:27 +02:00
|
|
|
setRD1(x, y + i, x + 16 - 1, y + i + 4 - 1);
|
2016-11-28 22:33:39 -08:00
|
|
|
CLBlitter_CopyViewRect(p_view2, &_vm->ScreenView, &rect_src, &rect_dst);
|
2016-09-14 23:39:27 +02:00
|
|
|
setRD1(x, y + 192 - i, x + 16 - 1, y + 192 - i + 4 - 1);
|
2016-11-28 22:33:39 -08:00
|
|
|
CLBlitter_CopyViewRect(p_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 {
|
|
|
|
setRS1(0, 0, 16 * 2 - 1, 4 * 2 - 1);
|
2016-11-13 15:46:36 -08:00
|
|
|
int y = p_mainview->_zoom._dstTop;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 16 * 2; i <= 96 * 2; i += 4 * 2) {
|
2016-11-13 15:46:36 -08:00
|
|
|
for (int x = p_mainview->_zoom._dstLeft; x < p_mainview->_zoom._dstLeft + 320 * 2; x += 16 * 2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
setRD1(x, y + i, x + 16 * 2 - 1, y + i + 4 * 2 - 1);
|
2016-11-28 22:33:39 -08:00
|
|
|
CLBlitter_CopyViewRect(p_view2, &_vm->ScreenView, &rect_src, &rect_dst);
|
2016-09-14 23:39:27 +02:00
|
|
|
setRD1(x, y + 192 * 2 - i, x + 16 * 2 - 1, y + 192 * 2 - i + 4 * 2 - 1);
|
2016-11-28 22:33:39 -08:00
|
|
|
CLBlitter_CopyViewRect(p_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-09-14 23:39:27 +02:00
|
|
|
CLPalette_Send2Screen(global_palette, 0, 256);
|
2016-09-29 07:43:13 +02:00
|
|
|
p_mainview->_normal._height = 2;
|
|
|
|
p_mainview->_zoom._height = 4;
|
2016-11-13 15:46:36 -08:00
|
|
|
int16 ny = p_mainview->_normal._dstTop;
|
|
|
|
int16 dy = p_mainview->_zoom._dstTop;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 0; i < 100; i += 2) {
|
2016-09-29 07:43:13 +02:00
|
|
|
p_mainview->_normal._srcTop = 99 - i;
|
|
|
|
p_mainview->_zoom._srcTop = 99 - i;
|
|
|
|
p_mainview->_normal._dstTop = 99 - i + ny;
|
|
|
|
p_mainview->_zoom._dstTop = (99 - i) * 2 + dy;
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_CopyView2Screen(p_mainview);
|
2016-09-29 07:43:13 +02:00
|
|
|
p_mainview->_normal._srcTop = 100 + i;
|
|
|
|
p_mainview->_zoom._srcTop = 100 + i;
|
|
|
|
p_mainview->_normal._dstTop = 100 + i + ny;
|
|
|
|
p_mainview->_zoom._dstTop = (100 + i) * 2 + dy;
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_CopyView2Screen(p_mainview);
|
|
|
|
CLBlitter_UpdateScreen();
|
|
|
|
wait(1);
|
|
|
|
}
|
2016-09-29 07:43:13 +02:00
|
|
|
p_mainview->_normal._height = 200;
|
|
|
|
p_mainview->_zoom._height = 400;
|
|
|
|
p_mainview->_normal._srcTop = 0;
|
|
|
|
p_mainview->_zoom._srcTop = 0;
|
|
|
|
p_mainview->_normal._dstTop = ny;
|
|
|
|
p_mainview->_zoom._dstTop = dy;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_F1 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::effet2() {
|
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;
|
|
|
|
if (p_global->ff_103 == 69) {
|
|
|
|
effet4();
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::effet3() {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
CLBlitter_CopyView2Screen(p_mainview);
|
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 = global_palette[c].r >> (5 - i);
|
|
|
|
newColor.g = global_palette[c].g >> (5 - i);
|
|
|
|
newColor.b = global_palette[c].b >> (5 - i);
|
|
|
|
CLPalette_SetRGBColor(newPalette, c, &newColor);
|
|
|
|
}
|
|
|
|
CLPalette_Send2Screen(newPalette, 0, 256);
|
|
|
|
wait(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::effet4() {
|
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-09-14 23:39:27 +02:00
|
|
|
CLPalette_Send2Screen(global_palette, 0, 256);
|
2016-10-23 23:28:48 +02:00
|
|
|
|
|
|
|
// Unused
|
2016-11-28 22:33:39 -08:00
|
|
|
// int16 w = _vm->ScreenView._width;
|
|
|
|
// int16 h = _vm->ScreenView._height;
|
|
|
|
int16 ww = _vm->ScreenView._pitch;
|
2016-09-30 07:48:27 +02:00
|
|
|
if (!_doubledScreen) {
|
2016-09-29 07:43:13 +02:00
|
|
|
x = p_mainview->_normal._dstLeft;
|
|
|
|
y = p_mainview->_normal._dstTop;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 32; i > 0; i -= 2) {
|
2016-11-28 22:33:39 -08:00
|
|
|
scr = _vm->ScreenView._bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += (y + 16) * ww + x;
|
2016-09-29 07:43:13 +02:00
|
|
|
pix = p_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-09-29 07:43:13 +02:00
|
|
|
x = p_mainview->_zoom._dstLeft;
|
|
|
|
y = p_mainview->_zoom._dstTop;
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 32; i > 0; i -= 2) {
|
2016-11-28 22:33:39 -08:00
|
|
|
scr = _vm->ScreenView._bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += (y + 16 * 2) * ww + x;
|
2016-09-29 07:43:13 +02:00
|
|
|
pix = p_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-09-14 23:39:27 +02:00
|
|
|
CLBlitter_CopyView2Screen(p_mainview);
|
|
|
|
}
|
|
|
|
|
|
|
|
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-28 22:33:39 -08:00
|
|
|
// int16 w = _vm->ScreenView._width;
|
|
|
|
// int16 h = _vm->ScreenView._height;
|
|
|
|
int16 ww = _vm->ScreenView._pitch;
|
2016-09-30 07:48:27 +02:00
|
|
|
if (!_doubledScreen) {
|
2016-09-29 07:43:13 +02:00
|
|
|
x = p_mainview->_normal._dstLeft;
|
|
|
|
y = p_mainview->_normal._dstTop;
|
2016-11-28 22:33:39 -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-09-29 07:43:13 +02:00
|
|
|
x = p_mainview->_zoom._dstLeft;
|
|
|
|
y = p_mainview->_zoom._dstTop;
|
2016-11-28 22:33:39 -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-28 22:33:39 -08:00
|
|
|
// int16 w = _vm->ScreenView._width;
|
|
|
|
// int16 h = _vm->ScreenView._height;
|
|
|
|
int16 ww = _vm->ScreenView._pitch;
|
2016-09-30 07:48:27 +02:00
|
|
|
if (!_doubledScreen) {
|
2016-09-29 07:43:13 +02:00
|
|
|
x = p_mainview->_normal._dstLeft;
|
|
|
|
y = p_mainview->_normal._dstTop;
|
2016-11-28 22:33:39 -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-09-29 07:43:13 +02:00
|
|
|
x = p_mainview->_zoom._dstLeft;
|
|
|
|
y = p_mainview->_zoom._dstTop;
|
2016-11-28 22:33:39 -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-09-14 23:39:27 +02:00
|
|
|
CLPalette_Send2Screen(global_palette, 0, 256);
|
2016-09-30 07:48:27 +02:00
|
|
|
if (!_doubledScreen) {
|
2016-09-29 07:43:13 +02:00
|
|
|
pix = p_mainview->_bufferPtr;
|
|
|
|
x = p_mainview->_normal._dstLeft;
|
|
|
|
y = p_mainview->_normal._dstTop;
|
2016-09-14 23:39:27 +02:00
|
|
|
pix += 640 * 16;
|
2016-11-28 22:33:39 -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-09-29 07:43:13 +02:00
|
|
|
pix = p_mainview->_bufferPtr;
|
|
|
|
x = p_mainview->_zoom._dstLeft;
|
|
|
|
y = p_mainview->_zoom._dstTop;
|
2016-09-14 23:39:27 +02:00
|
|
|
pix += 640 * 16;
|
2016-11-28 22:33:39 -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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::fadetoblack(int delay) {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::fadetoblack128(int delay) {
|
|
|
|
CLPalette_GetLastPalette(oldPalette);
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 0; i < 6; i++) {
|
|
|
|
for (int16 j = 0; j < 129; j++) { //TODO: wha?
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::fadefromblack128(int delay) {
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int16 i = 0; i < 6; i++) {
|
|
|
|
for (int16 j = 0; j < 129; j++) { //TODO: wha?
|
2016-09-14 23:39:27 +02:00
|
|
|
newColor.r = global_palette[j].r >> (5 - i);
|
|
|
|
newColor.g = global_palette[j].g >> (5 - i);
|
|
|
|
newColor.b = global_palette[j].b >> (5 - 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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::rectanglenoir32() {
|
|
|
|
// blacken 32x32 rectangle
|
|
|
|
int *pix = (int *)p_view2_buf;
|
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-09-14 23:48:01 +02:00
|
|
|
void EdenGame::setRS1(int16 sx, int16 sy, int16 ex, int16 ey) {
|
2016-09-29 07:43:13 +02:00
|
|
|
rect_src.left = sx;
|
|
|
|
rect_src.top = sy;
|
|
|
|
rect_src.right = ex;
|
|
|
|
rect_src.bottom = ey;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::setRD1(int16 sx, int16 sy, int16 ex, int16 ey) {
|
2016-09-29 07:43:13 +02:00
|
|
|
rect_dst.left = sx;
|
|
|
|
rect_dst.top = sy;
|
|
|
|
rect_dst.right = ex;
|
|
|
|
rect_dst.bottom = ey;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::wait(int howlong) {
|
2016-10-23 23:28:48 +02:00
|
|
|
int t = TickCount();
|
2016-09-14 23:39:27 +02:00
|
|
|
#ifdef EDEN_DEBUG
|
|
|
|
howlong *= 10;
|
|
|
|
#endif
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int t2 = t; t2 - t < howlong; t2 = TickCount())
|
|
|
|
g_system->delayMillis(10); // waste time
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::effetpix() {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *scr, *pix;
|
2016-09-26 07:57:27 +02:00
|
|
|
int16 x, y;
|
|
|
|
int16 r25, r18, r31, r30; //TODO: change to xx/yy
|
2016-10-23 23:28:48 +02:00
|
|
|
|
|
|
|
// Unused
|
2016-11-28 22:33:39 -08:00
|
|
|
// int16 w = _vm->ScreenView._width;
|
|
|
|
// int16 h = _vm->ScreenView._height;
|
|
|
|
int16 ww = _vm->ScreenView._pitch;
|
2016-09-14 23:39:27 +02:00
|
|
|
r25 = ww * 80;
|
|
|
|
r18 = 640 * 80;
|
2016-09-29 07:43:13 +02:00
|
|
|
pix = p_mainview->_bufferPtr + 16 * 640;
|
2016-09-30 07:48:27 +02:00
|
|
|
if (!_doubledScreen) {
|
2016-09-29 07:43:13 +02:00
|
|
|
x = p_mainview->_normal._dstLeft;
|
|
|
|
y = p_mainview->_normal._dstTop;
|
2016-11-28 22:33:39 -08:00
|
|
|
scr = _vm->ScreenView._bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
scr += (y + 16) * ww + x;
|
|
|
|
} else {
|
2016-09-29 07:43:13 +02:00
|
|
|
x = p_mainview->_zoom._dstLeft;
|
|
|
|
y = p_mainview->_zoom._dstTop;
|
2016-11-28 22:33:39 -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);
|
|
|
|
CLPalette_Send2Screen(global_palette, 0, 256);
|
|
|
|
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);
|
2016-11-28 22:33:39 -08:00
|
|
|
assert(_vm->ScreenView._pitch == 320);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////// datfile.c
|
|
|
|
void EdenGame::verifh(void *ptr) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte sum = 0;
|
|
|
|
byte *head = (byte *)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-10-23 23:28:48 +02:00
|
|
|
uint16 h0 = PLE16(head);
|
2016-09-14 23:39:27 +02:00
|
|
|
head += 2;
|
2016-11-15 09:41:06 +01:00
|
|
|
/*char unused = * */head++;
|
2016-10-23 23:28:48 +02:00
|
|
|
uint16 h3 = PLE16(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-09-14 23:48:01 +02:00
|
|
|
data = (byte *)ptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
Expand_hsq(head, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::openbigfile() {
|
|
|
|
assert(sizeof(pakfile_t) == 25);
|
2016-10-08 23:31:21 +02:00
|
|
|
int32 size = 0x10000;
|
2016-11-13 03:47:40 -08:00
|
|
|
h_bigfile.open("EDEN.DAT");
|
2016-11-09 13:40:08 -08:00
|
|
|
h_bigfile.read(bigfile_header, size);
|
|
|
|
|
2016-11-27 22:27:46 -08:00
|
|
|
_hnmContext = _vm->_video->resetInternals();
|
2016-11-27 22:07:37 -08:00
|
|
|
_vm->_video->setFile(_hnmContext, &h_bigfile);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::closebigfile() {
|
2016-11-09 13:40:08 -08:00
|
|
|
h_bigfile.close();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-28 07:29:12 +02:00
|
|
|
void EdenGame::loadFile(uint16 num, void *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
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
assert(num < bigfile_header->count);
|
2016-09-28 07:29:12 +02:00
|
|
|
pakfile_t *file = &bigfile_header->files[num];
|
2016-10-08 23:31:21 +02:00
|
|
|
int32 size = PLE32(&file->size);
|
|
|
|
int32 offs = PLE32(&file->offs);
|
|
|
|
debug("* Loading resource %d (%s) at 0x%X, %d bytes", num, file->name, offs, size);
|
2016-11-10 15:37:48 -08:00
|
|
|
h_bigfile.seek(offs, SEEK_SET);
|
2016-11-09 13:40:08 -08:00
|
|
|
h_bigfile.read(buffer, size);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::shnmfl(uint16 num) {
|
2016-10-17 03:05:37 +03:00
|
|
|
unsigned int resNum = num - 1 + 485;
|
|
|
|
assert(resNum < bigfile_header->count);
|
|
|
|
pakfile_t *file = &bigfile_header->files[resNum];
|
2016-09-14 23:39:27 +02:00
|
|
|
int size = PLE32(&file->size);
|
|
|
|
int offs = PLE32(&file->offs);
|
2016-10-08 21:21:21 +02:00
|
|
|
debug("* Loading movie %d (%s) at 0x%X, %d bytes", num, file->name, (uint)offs, size);
|
2016-11-10 15:37:48 -08:00
|
|
|
_hnmContext->_file->seek(offs, SEEK_SET);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
int EdenGame::ssndfl(uint16 num) {
|
2016-11-09 13:40:08 -08:00
|
|
|
unsigned int resNum = num - 1 + ((_vm->getPlatform() == Common::kPlatformDOS && _vm->isDemo()) ? 656 : 661);
|
2016-10-10 01:26:23 +03:00
|
|
|
assert(resNum < bigfile_header->count);
|
|
|
|
pakfile_t *file = &bigfile_header->files[resNum];
|
2016-10-08 23:31:21 +02:00
|
|
|
int32 size = PLE32(&file->size);
|
|
|
|
int32 offs = PLE32(&file->offs);
|
2016-10-17 03:05:37 +03:00
|
|
|
debug("* Loading sound %d (%s) at 0x%X, %d bytes", num, file->name, (uint)offs, size);
|
2016-10-06 00:15:02 +02:00
|
|
|
if (_soundAllocated) {
|
|
|
|
free(voiceSamplesBuffer);
|
|
|
|
voiceSamplesBuffer = nullptr;
|
|
|
|
_soundAllocated = false; //TODO: bug??? no alloc
|
2016-09-14 23:39:27 +02:00
|
|
|
} else {
|
2016-10-06 00:15:02 +02:00
|
|
|
voiceSamplesBuffer = malloc(size);
|
|
|
|
_soundAllocated = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-11-10 15:37:48 -08:00
|
|
|
|
|
|
|
h_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)
|
|
|
|
h_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
|
2016-11-09 13:40:08 -08:00
|
|
|
h_bigfile.read(voiceSamplesBuffer, 0x1A);
|
|
|
|
|
2016-10-17 03:05:37 +03:00
|
|
|
// 2. Lipsync?
|
2016-11-09 13:40:08 -08:00
|
|
|
unsigned char chunkType = h_bigfile.readByte();
|
|
|
|
|
|
|
|
uint32 val;
|
|
|
|
h_bigfile.read(&val, 3);
|
|
|
|
unsigned int chunkLen = LE32(val);
|
|
|
|
|
2016-10-17 03:05:37 +03:00
|
|
|
if (chunkType == 5) {
|
2016-11-09 13:40:08 -08:00
|
|
|
h_bigfile.read(gameLipsync + 7260, chunkLen);
|
2016-10-17 03:05:37 +03:00
|
|
|
// anim_buffer_ptr = gameLipsync + 7260 + 2;
|
|
|
|
|
2016-11-09 13:40:08 -08:00
|
|
|
chunkType = h_bigfile.readByte();
|
|
|
|
h_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) {
|
2016-11-15 09:41:06 +01:00
|
|
|
/*unsigned short freq = */h_bigfile.readUint16LE();
|
2016-10-17 03:05:37 +03:00
|
|
|
size = chunkLen - 2;
|
2016-11-09 13:40:08 -08:00
|
|
|
h_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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::ConvertIcons(icon_t *icon, int count) {
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int i = 0; i < count; i++, icon++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
icon->sx = BE16(icon->sx);
|
|
|
|
icon->sy = BE16(icon->sy);
|
|
|
|
icon->ex = BE16(icon->ex);
|
|
|
|
icon->ey = BE16(icon->ey);
|
|
|
|
icon->cursor_id = BE16(icon->cursor_id);
|
|
|
|
icon->object_id = BE32(icon->object_id);
|
|
|
|
icon->action_id = BE32(icon->action_id);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::ConvertLinks(room_t *room, int count) {
|
2016-10-23 23:28:48 +02:00
|
|
|
for (int i = 0; i < count; i++, room++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
room->bank = BE16(room->bank);
|
|
|
|
room->party = BE16(room->party);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02: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
|
|
|
ConvertIcons(gameIcons, 136);
|
|
|
|
ConvertLinks(gameRooms, 424);
|
|
|
|
// Array of longs
|
|
|
|
int *p = (int *)gameLipsync;
|
|
|
|
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;
|
|
|
|
if (f.size() != kNumIcons * sizeof(icon_t) + kNumRooms * sizeof(room_t))
|
|
|
|
error("Mismatching aux data");
|
|
|
|
f.read(gameIcons, kNumIcons * sizeof(icon_t));
|
|
|
|
f.read(gameRooms, kNumRooms * sizeof(room_t));
|
|
|
|
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:
|
|
|
|
loadFile(2498, gameIcons);
|
|
|
|
loadFile(2497, gameRooms);
|
|
|
|
loadFile(2486, gameLipsync);
|
|
|
|
ConvertMacToPC();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("Unsupported platform");
|
|
|
|
}
|
|
|
|
|
2016-09-28 07:29:12 +02:00
|
|
|
loadFile(0, main_bank_buf);
|
|
|
|
loadFile(402, gameFont);
|
|
|
|
loadFile(404, gameDialogs);
|
|
|
|
loadFile(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) {
|
|
|
|
unsigned int 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);
|
2016-11-09 22:36:06 -08:00
|
|
|
loadpartoffile(resNum, gameLipsync + 7260, filePos, chunkLen);
|
|
|
|
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) {
|
2016-11-09 22:36:06 -08:00
|
|
|
long pos = PLE32(gameLipsync + num * 4);
|
|
|
|
long len = 1024;
|
2016-10-17 03:05:37 +03:00
|
|
|
if (pos != -1) {
|
|
|
|
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) {
|
2016-09-14 23:39:27 +02:00
|
|
|
assert(num < bigfile_header->count);
|
|
|
|
pakfile_t *file = &bigfile_header->files[num];
|
2016-10-08 23:31:21 +02:00
|
|
|
int32 offs = PLE32(&file->offs);
|
|
|
|
debug("* Loading partial resource %d (%s) at 0x%X(+0x%X), %d bytes", num, file->name, offs, pos, len);
|
2016-11-10 15:37:48 -08:00
|
|
|
h_bigfile.seek(offs + pos, SEEK_SET);
|
2016-11-09 13:40:08 -08:00
|
|
|
h_bigfile.read(buffer, len);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::Expand_hsq(void *input, void *output) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *src = (byte *)input;
|
|
|
|
byte *dst = (byte *)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-09-14 23:48:01 +02:00
|
|
|
void EdenGame::ajouinfo(byte info) {
|
|
|
|
byte idx = p_global->next_info_idx;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (kPersons[PER_MESSAGER]._roomNum)
|
2016-09-14 23:39:27 +02:00
|
|
|
info |= 0x80;
|
|
|
|
info_list[idx] = info;
|
|
|
|
if (idx == p_global->last_info_idx)
|
|
|
|
p_global->last_info = info;
|
|
|
|
idx++;
|
2016-11-13 22:59:45 -08:00
|
|
|
if (idx == 16)
|
|
|
|
idx = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->next_info_idx = idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::unlockinfo() {
|
2016-11-13 22:59:45 -08:00
|
|
|
for (byte idx = 0; idx < 16; idx++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (info_list[idx] != 0xFF)
|
|
|
|
info_list[idx] &= ~0x80;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->last_info &= ~0x80;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::nextinfo() {
|
|
|
|
do {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte idx = p_global->last_info_idx;
|
2016-09-14 23:39:27 +02:00
|
|
|
info_list[idx] = 0;
|
|
|
|
idx++;
|
2016-11-13 22:59:45 -08:00
|
|
|
if (idx == 16)
|
|
|
|
idx = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->last_info_idx = idx;
|
|
|
|
p_global->last_info = info_list[idx];
|
|
|
|
} while (p_global->last_info == 0xFF);
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::delinfo(byte info) {
|
2016-11-13 22:59:45 -08:00
|
|
|
for (byte idx = 0; idx < 16; idx++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if ((info_list[idx] & ~0x80) == info) {
|
|
|
|
info_list[idx] = 0xFF;
|
|
|
|
if (idx == p_global->last_info_idx)
|
|
|
|
nextinfo();
|
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::updateinfolist() {
|
2016-10-24 22:02:43 +02:00
|
|
|
for (int idx = 0; idx < 16; idx++)
|
2016-09-14 23:39:27 +02:00
|
|
|
info_list[idx] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::init_globals() {
|
|
|
|
gameIcons[16].cursor_id |= 0x8000;
|
|
|
|
|
|
|
|
p_global->areaNum = Areas::arMo;
|
|
|
|
p_global->areaVisitCount = 1;
|
|
|
|
p_global->menuItemIdLo = 0;
|
|
|
|
p_global->menuItemIdHi = 0;
|
|
|
|
p_global->randomNumber = 0;
|
|
|
|
p_global->gameTime = 0;
|
|
|
|
p_global->gameDays = 0;
|
|
|
|
p_global->chrono = 0;
|
|
|
|
p_global->eloiDepartureDay = 0;
|
|
|
|
p_global->roomNum = 259;
|
|
|
|
p_global->newRoomNum = 0;
|
|
|
|
p_global->phaseNum = 0;
|
|
|
|
p_global->metPersonsMask1 = 0;
|
|
|
|
p_global->party = 0;
|
|
|
|
p_global->partyOutside = 0;
|
|
|
|
p_global->metPersonsMask2 = 0;
|
|
|
|
p_global->__UNUSED_1C = 0;
|
|
|
|
p_global->phaseActionsCount = 0;
|
|
|
|
p_global->curAreaFlags = 0;
|
|
|
|
p_global->curItemsMask = 0;
|
|
|
|
p_global->curPowersMask = 0;
|
|
|
|
p_global->curPersoItems = 0;
|
|
|
|
p_global->curPersoPowers = 0;
|
|
|
|
p_global->wonItemsMask = 0;
|
|
|
|
p_global->wonPowersMask = 0;
|
|
|
|
p_global->stepsToFindAppleFast = 0;
|
|
|
|
p_global->stepsToFindAppleNormal = 0;
|
|
|
|
p_global->roomPersoItems = 0;
|
|
|
|
p_global->roomPersoPowers = 0;
|
|
|
|
p_global->gameFlags = 0;
|
|
|
|
p_global->morkusSpyVideoNum1 = 89;
|
|
|
|
p_global->morkusSpyVideoNum2 = 88;
|
|
|
|
p_global->morkusSpyVideoNum3 = 83;
|
|
|
|
p_global->morkusSpyVideoNum4 = 94;
|
|
|
|
p_global->newMusicType = MusicType::mtDontChange;
|
|
|
|
p_global->ff_43 = 0;
|
|
|
|
p_global->videoSubtitleIndex = 0;
|
|
|
|
p_global->partyInstruments = 0;
|
|
|
|
p_global->monkGotRing = 0;
|
|
|
|
p_global->chrono_on = 0;
|
|
|
|
p_global->curRoomFlags = 0;
|
|
|
|
p_global->endGameFlag = 0;
|
|
|
|
p_global->last_info = 0;
|
2016-09-26 07:57:27 +02:00
|
|
|
p_global->autoDialog = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->worldTyrannSighted = 0;
|
|
|
|
p_global->ff_4D = 0;
|
|
|
|
p_global->ff_4E = 0;
|
|
|
|
p_global->worldGaveGold = 0;
|
|
|
|
p_global->worldHasTriceraptors = 0;
|
|
|
|
p_global->worldHasVelociraptors = 0;
|
|
|
|
p_global->worldHasTyrann = 0;
|
|
|
|
p_global->ff_53 = 0;
|
|
|
|
p_global->ff_54 = 0;
|
|
|
|
p_global->ff_55 = 0;
|
|
|
|
p_global->ff_56 = 0;
|
|
|
|
p_global->textToken1 = 0;
|
|
|
|
p_global->textToken2 = 0;
|
|
|
|
p_global->eloiHaveNews = 0;
|
|
|
|
p_global->dialogFlags = 0;
|
|
|
|
p_global->curAreaType = 0;
|
|
|
|
p_global->curCitadelLevel = 0;
|
|
|
|
p_global->newLocation = 0;
|
|
|
|
p_global->prevLocation = 0;
|
|
|
|
p_global->curPersoFlags = 0;
|
2016-10-24 22:02:43 +02:00
|
|
|
p_global->ff_60 = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->eventType = EventType::etEvent5;
|
|
|
|
p_global->ff_62 = 0;
|
|
|
|
p_global->curObjectId = 0;
|
|
|
|
p_global->curObjectFlags = 0;
|
|
|
|
p_global->ff_65 = 1;
|
|
|
|
p_global->roomPersoType = 0;
|
|
|
|
p_global->roomPersoFlags = 0;
|
|
|
|
p_global->narratorSequence = 0;
|
|
|
|
p_global->ff_69 = 0;
|
|
|
|
p_global->ff_6A = 0;
|
2016-09-26 23:44:42 +02:00
|
|
|
p_global->frescoNumber = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_6C = 0;
|
|
|
|
p_global->ff_6D = 0;
|
|
|
|
p_global->labyrinthDirections = 0;
|
|
|
|
p_global->labyrinthRoom = 0;
|
2016-11-13 22:59:45 -08:00
|
|
|
p_global->curPersoAnimPtr = nullptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->perso_img_bank = 0;
|
|
|
|
p_global->roomImgBank = 0;
|
|
|
|
p_global->persoBackgroundBankIdx = 55;
|
|
|
|
p_global->ff_D4 = 0;
|
|
|
|
p_global->fresqWidth = 0;
|
|
|
|
p_global->fresqImgBank = 0;
|
|
|
|
p_global->ff_DA = 0;
|
|
|
|
p_global->ff_DC = 0;
|
|
|
|
p_global->room_x_base = 0;
|
|
|
|
p_global->ff_E0 = 0;
|
2016-10-24 00:04:32 +02:00
|
|
|
p_global->dialogType = DialogType::dtTalk;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_E4 = 0;
|
|
|
|
p_global->currentMusicNum = 0;
|
|
|
|
p_global->textNum = 0;
|
|
|
|
p_global->travelTime = 0;
|
|
|
|
p_global->ff_EC = 0;
|
|
|
|
p_global->displayFlags = DisplayFlags::dfFlag1;
|
|
|
|
p_global->oldDisplayFlags = 1;
|
|
|
|
p_global->drawFlags = 0;
|
|
|
|
p_global->ff_F1 = 0;
|
|
|
|
p_global->ff_F2 = 0;
|
|
|
|
p_global->menuFlags = 0;
|
|
|
|
p_global->ff_F5 = 0;
|
|
|
|
p_global->ff_F6 = 0;
|
|
|
|
p_global->ff_F7 = 0;
|
|
|
|
p_global->ff_F8 = 0;
|
|
|
|
p_global->ff_F9 = 0;
|
|
|
|
p_global->ff_FA = 0;
|
|
|
|
p_global->animationFlags = 0;
|
|
|
|
p_global->giveobj1 = 0;
|
|
|
|
p_global->giveobj2 = 0;
|
|
|
|
p_global->giveobj3 = 0;
|
|
|
|
p_global->ff_100 = 0;
|
|
|
|
p_global->roomVidNum = 0;
|
|
|
|
p_global->ff_102 = 0;
|
|
|
|
p_global->ff_103 = 0;
|
|
|
|
p_global->roomBgBankNum = 0;
|
|
|
|
p_global->valleyVidNum = 0;
|
|
|
|
p_global->updatePaletteFlag = 0;
|
|
|
|
p_global->inventoryScrollPos = 0;
|
|
|
|
p_global->obj_count = 0;
|
|
|
|
p_global->textBankIndex = 69;
|
|
|
|
p_global->cita_area_num = 0;
|
|
|
|
p_global->ff_113 = 0;
|
|
|
|
p_global->lastSalNum = 0;
|
2016-10-24 22:02:43 +02:00
|
|
|
p_global->_dialogPtr = nullptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->tape_ptr = tapes;
|
2016-11-13 13:56:20 -08:00
|
|
|
p_global->_nextDialogPtr = nullptr;
|
|
|
|
p_global->narrator_dialog_ptr = nullptr;
|
2016-10-24 00:04:32 +02:00
|
|
|
p_global->last_dialog_ptr = nullptr;
|
2016-11-13 13:56:20 -08:00
|
|
|
p_global->nextRoomIcon = nullptr;
|
|
|
|
p_global->phraseBufferPtr = nullptr;
|
|
|
|
p_global->room_ptr = nullptr;
|
|
|
|
p_global->area_ptr = nullptr;
|
2016-11-13 22:59:45 -08:00
|
|
|
p_global->last_area_ptr = nullptr;
|
|
|
|
p_global->cur_area_ptr = nullptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->cita_area_firstRoom = 0;
|
2016-11-13 22:59:45 -08:00
|
|
|
p_global->perso_ptr = nullptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->room_perso = 0;
|
|
|
|
p_global->last_info_idx = 0;
|
|
|
|
p_global->next_info_idx = 0;
|
|
|
|
p_global->iconsIndex = 16;
|
2016-11-13 22:59:45 -08:00
|
|
|
p_global->persoSpritePtr = nullptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->numGiveObjs = 0;
|
|
|
|
|
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;
|
|
|
|
_underSubtitlesScreenRect.left = subtitles_x_scr_margin;
|
|
|
|
_underSubtitlesScreenRect.right = subtitles_x_scr_margin + subtitles_x_width - 1;
|
|
|
|
_underSubtitlesScreenRect.bottom = 176 - 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-09-30 07:48:27 +02:00
|
|
|
_underSubtitlesBackupRect.top = 0;
|
|
|
|
_underSubtitlesBackupRect.left = subtitles_x_scr_margin;
|
|
|
|
_underSubtitlesBackupRect.right = subtitles_x_scr_margin + subtitles_x_width - 1;
|
|
|
|
_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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::closesalle() {
|
|
|
|
if (p_global->displayFlags & DisplayFlags::dfPanable) {
|
|
|
|
p_global->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
|
|
|
|
void EdenGame::displaySingleRoom(room_t *room) {
|
2016-10-07 00:45:08 +02:00
|
|
|
byte *ptr = (byte *)getElem(sal_buf, room->ff_0 - 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;
|
|
|
|
if (!(p_global->displayFlags & 0x80)) {
|
|
|
|
if (index == 1 || p_global->ff_F7)
|
|
|
|
noclipax_avecnoir(index - 1, x, y);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_F7 = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (b1 & 0x40) {
|
|
|
|
if (b1 & 0x20) {
|
|
|
|
char addIcon = 0;
|
|
|
|
icon_t *icon = p_global->nextRoomIcon;
|
|
|
|
if (b0 < 4) {
|
|
|
|
if (p_global->room_ptr->exits[b0])
|
|
|
|
addIcon = 1;
|
|
|
|
} else if (b0 > 229) {
|
|
|
|
if (p_global->partyOutside & (1 << (b0 - 230)))
|
|
|
|
addIcon = 1;
|
|
|
|
} else if (b0 >= 100) {
|
|
|
|
debug("add object %d", b0 - 100);
|
|
|
|
if (objecthere(b0 - 100)) {
|
|
|
|
addIcon = 1;
|
2016-09-26 07:57:27 +02:00
|
|
|
p_global->ff_F7 = 0xFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
addIcon = 1;
|
|
|
|
if (addIcon) {
|
|
|
|
icon->action_id = b0;
|
|
|
|
icon->object_id = b0;
|
|
|
|
icon->cursor_id = kActionCursors[b0];
|
2016-10-07 23:06:10 +02:00
|
|
|
int16 x = PLE16(ptr);
|
2016-09-14 23:39:27 +02:00
|
|
|
ptr += 2;
|
2016-10-07 23:06:10 +02:00
|
|
|
int16 y = PLE16(ptr);
|
2016-09-14 23:39:27 +02:00
|
|
|
ptr += 2;
|
2016-10-07 23:06:10 +02:00
|
|
|
int16 ex = PLE16(ptr);
|
2016-09-14 23:39:27 +02:00
|
|
|
ptr += 2;
|
2016-10-07 23:06:10 +02:00
|
|
|
int16 ey = PLE16(ptr);
|
2016-09-14 23:39:27 +02:00
|
|
|
ptr += 2;
|
|
|
|
x += p_global->room_x_base;
|
|
|
|
ex += p_global->room_x_base;
|
|
|
|
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++)
|
|
|
|
p_mainview_buf[y * 640 + iii] = p_mainview_buf[ey * 640 + iii] = (iii % 2) ? 0 : 255;
|
|
|
|
for (int iii = y; iii < ey; iii++)
|
|
|
|
p_mainview_buf[iii * 640 + x] = p_mainview_buf[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;
|
|
|
|
p_global->nextRoomIcon = ++icon;
|
|
|
|
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() {
|
2016-09-14 23:39:27 +02:00
|
|
|
room_t *room = p_global->room_ptr;
|
|
|
|
p_global->displayFlags = DisplayFlags::dfFlag1;
|
|
|
|
p_global->room_x_base = 0;
|
|
|
|
p_global->roomBgBankNum = room->background;
|
|
|
|
if (room->flags & RoomFlags::rf08) {
|
|
|
|
p_global->displayFlags |= DisplayFlags::dfFlag80;
|
|
|
|
if (room->flags & RoomFlags::rfPanable) {
|
2016-10-07 23:06:10 +02:00
|
|
|
// Scrollable room on 2 screens
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->displayFlags |= DisplayFlags::dfPanable;
|
|
|
|
p_global->ff_F4 = 0;
|
|
|
|
rundcurs();
|
2016-09-27 07:53:50 +02:00
|
|
|
saveFriezes();
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(room->bank - 1);
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax_avecnoir(0, 0, 16);
|
2016-10-07 23:06:10 +02: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);
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->room_x_base = 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!
|
|
|
|
debug("drawroom: room 0x%X using bank %d", p_global->roomNum, p_global->roomImgBank);
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(p_global->roomImgBank);
|
|
|
|
displaySingleRoom(room);
|
2016-11-28 22:33:39 -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();
|
|
|
|
if (!pomme_q) {
|
|
|
|
p_global->iconsIndex = 16;
|
2016-09-26 07:57:27 +02:00
|
|
|
p_global->autoDialog = false;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-10-17 03:05:37 +03:00
|
|
|
p_global->nextRoomIcon = &gameIcons[roomIconsBase];
|
2016-10-07 23:06:10 +02:00
|
|
|
displayRoom();
|
2016-10-25 23:32:15 +02:00
|
|
|
needPaletteUpdate = 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) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (num == p_global->lastSalNum)
|
|
|
|
return;
|
|
|
|
p_global->lastSalNum = num;
|
2016-09-28 07:29:12 +02:00
|
|
|
loadFile(num + 419, sal_buf);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::specialoutside() {
|
|
|
|
if (p_global->last_area_ptr->type == AreaType::atValley && (p_global->party & PersonMask::pmLeader))
|
|
|
|
perso_ici(5);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::specialout() {
|
|
|
|
if (p_global->gameDays - p_global->eloiDepartureDay > 2) {
|
2016-10-07 23:06:10 +02:00
|
|
|
if (eloirevientq())
|
2016-09-14 23:39:27 +02:00
|
|
|
eloirevient();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-10-07 23:06:10 +02:00
|
|
|
|
|
|
|
if (p_global->phaseNum >= 32 && p_global->phaseNum < 48) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->newLocation == 9 || p_global->newLocation == 4 || p_global->newLocation == 24) {
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MESSAGER]._roomNum = 263;
|
2016-08-18 13:15:54 +02:00
|
|
|
return;
|
|
|
|
}
|
2016-10-07 23:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((p_global->phaseNum == 434) && (p_global->newLocation == 5)) {
|
|
|
|
reste_ici(4);
|
|
|
|
kPersons[PER_BOURREAU]._roomNum = 264;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_global->phaseNum < 400) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if ((p_global->gameFlags & GameFlags::gfFlag4000) && p_global->prevLocation == 1
|
|
|
|
&& (p_global->party & PersonMask::pmEloi) && p_global->curAreaType == AreaType::atValley)
|
|
|
|
eloipart();
|
2016-10-07 23:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (p_global->phaseNum == 386) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->prevLocation == 1
|
|
|
|
&& (p_global->party & PersonMask::pmEloi) && p_global->areaNum == Areas::arCantura)
|
|
|
|
eloipart();
|
2016-10-07 23:06:10 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::specialin() {
|
|
|
|
if (!(p_global->party & PersonMask::pmEloi) && (p_global->partyOutside & PersonMask::pmEloi) && (p_global->roomNum & 0xFF) == 1) {
|
|
|
|
suis_moi(5);
|
|
|
|
p_global->eloiHaveNews = 1;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->roomNum == 288)
|
|
|
|
p_global->gameFlags |= GameFlags::gfFlag100 | GameFlags::gfFlag2000;
|
|
|
|
if (p_global->roomNum == 3075 && p_global->phaseNum == 546) {
|
|
|
|
incphase1();
|
|
|
|
if (p_global->curItemsMask & 0x2000) { // Morkus' tablet
|
|
|
|
bars_out();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(92);
|
2016-09-14 23:39:27 +02:00
|
|
|
gameRooms[129].exits[0] = 0;
|
|
|
|
gameRooms[129].exits[2] = 1;
|
|
|
|
p_global->roomNum = 3074;
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MANGO]._roomNum = 3074;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->eventType = EventType::etEvent5;
|
|
|
|
maj_salle(p_global->roomNum);
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->narratorSequence = 53;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->roomNum == 1793 && p_global->phaseNum == 336)
|
|
|
|
eloipart();
|
|
|
|
if (p_global->roomNum == 259 && p_global->phaseNum == 129)
|
|
|
|
p_global->narratorSequence = 12;
|
|
|
|
if (p_global->roomNum >= 289 && p_global->roomNum < 359)
|
|
|
|
p_global->labyrinthDirections = kLabyrinthPath[(p_global->roomNum & 0xFF) - 33];
|
|
|
|
if (p_global->roomNum == 305 && p_global->prevLocation == 103)
|
|
|
|
p_global->gameFlags &= ~GameFlags::gfFlag2000;
|
|
|
|
if (p_global->roomNum == 304 && p_global->prevLocation == 105)
|
|
|
|
p_global->gameFlags &= ~GameFlags::gfFlag2000;
|
|
|
|
if (p_global->phaseNum < 226) {
|
|
|
|
if (p_global->roomNum == 842)
|
|
|
|
p_global->gameFlags |= GameFlags::gfFlag2;
|
|
|
|
if (p_global->roomNum == 1072)
|
|
|
|
p_global->gameFlags |= GameFlags::gfFlag4;
|
|
|
|
if (p_global->roomNum == 1329)
|
|
|
|
p_global->gameFlags |= GameFlags::gfFlag8000;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::animpiece() {
|
|
|
|
room_t *room = p_global->room_ptr;
|
|
|
|
if (p_global->roomVidNum && p_global->ff_100 != 0xFF) {
|
|
|
|
if (p_global->valleyVidNum || !room->level || (room->flags & RoomFlags::rfHasCitadel)
|
|
|
|
|| room->level == p_global->ff_100) {
|
|
|
|
bars_out();
|
|
|
|
p_global->updatePaletteFlag = 16;
|
|
|
|
if (!p_global->narratorSequence & 0x80) //TODO: bug? !() @ 100DC
|
|
|
|
p_global->ff_102 = 0;
|
|
|
|
if (!needToFade)
|
|
|
|
needToFade = room->flags & RoomFlags::rf02;
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(p_global->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
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_F1 &= ~RoomFlags::rf04;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::getdino(room_t *room) {
|
|
|
|
assert(tab_2CEF0[4] == 0x25);
|
2016-11-15 09:39:49 +01:00
|
|
|
|
2016-09-14 23:39:27 +02: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;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_roomNum != p_global->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)
|
|
|
|
delinfo(p_global->cita_area_num + ValleyNews::vnVelociraptorsIn);
|
|
|
|
if (persoType == PersonFlags::pftTriceraptor)
|
|
|
|
delinfo(p_global->cita_area_num + 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;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->areaNum != Areas::arUluru && p_global->areaNum != Areas::arTamara)
|
|
|
|
tab = tab_2CEF0;
|
2016-11-13 22:59:45 -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;
|
|
|
|
p_global->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;
|
|
|
|
room->flags |= RoomFlags::rf08;
|
|
|
|
}
|
|
|
|
room->flags |= RoomFlags::rf04 | RoomFlags::rf02;
|
|
|
|
p_global->roomImgBank = bank;
|
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
room_t *EdenGame::getsalle(int16 loc) { //TODO: byte?
|
2016-09-14 23:39:27 +02:00
|
|
|
debug("get room for %X, starting from %d, looking for %X", loc, p_global->area_ptr->firstRoomIndex, p_global->partyOutside);
|
|
|
|
room_t *room = &gameRooms[p_global->area_ptr->firstRoomIndex];
|
|
|
|
loc &= 0xFF;
|
|
|
|
for (;; room++) {
|
|
|
|
for (; room->location != loc; room++) {
|
|
|
|
if (room->ff_0 == 0xFF)
|
|
|
|
return 0;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->partyOutside == room->party || room->party == 0xFFFF)
|
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
debug("found room: party = %X, bank = %X", room->party, room->bank);
|
|
|
|
p_global->roomImgBank = room->bank;
|
|
|
|
p_global->labyrinthRoom = 0;
|
|
|
|
if (p_global->roomImgBank > 104 && p_global->roomImgBank <= 112)
|
|
|
|
p_global->labyrinthRoom = p_global->roomImgBank - 103;
|
|
|
|
if (p_global->valleyVidNum)
|
|
|
|
p_global->roomVidNum = p_global->valleyVidNum;
|
|
|
|
else
|
|
|
|
p_global->roomVidNum = room->video;
|
|
|
|
if ((room->flags & 0xC0) == RoomFlags::rf40 || (room->flags & RoomFlags::rf01))
|
|
|
|
getdino(room);
|
|
|
|
if (room->flags & RoomFlags::rfHasCitadel) {
|
|
|
|
delinfo(p_global->areaNum + ValleyNews::vnCitadelLost);
|
2016-08-18 13:15:54 +02:00
|
|
|
delinfo(p_global->areaNum + ValleyNews::vnTyrannIn);
|
2016-09-14 23:39:27 +02:00
|
|
|
delinfo(p_global->areaNum + ValleyNews::vnTyrannLost);
|
|
|
|
delinfo(p_global->areaNum + ValleyNews::vnVelociraptorsLost);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (istyran(p_global->roomNum))
|
|
|
|
p_global->gameFlags |= GameFlags::gfFlag10;
|
|
|
|
else
|
|
|
|
p_global->gameFlags &= ~GameFlags::gfFlag10;
|
|
|
|
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) {
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->gameFlags |= GameFlags::gfFlag4000;
|
|
|
|
gameIcons[18].cursor_id |= 0x8000;
|
|
|
|
p_global->last_area_ptr = p_global->area_ptr;
|
|
|
|
p_global->area_ptr = &kAreasTable[((roomNum >> 8) & 0xFF) - 1];
|
2016-10-07 23:06:10 +02:00
|
|
|
area_t *area = p_global->area_ptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
area->visitCount++;
|
|
|
|
p_global->areaVisitCount = area->visitCount;
|
|
|
|
p_global->curAreaFlags = area->flags;
|
|
|
|
p_global->curAreaType = area->type;
|
|
|
|
p_global->curCitadelLevel = area->citadelLevel;
|
|
|
|
if (p_global->curAreaType == AreaType::atValley)
|
|
|
|
gameIcons[18].cursor_id &= ~0x8000;
|
2016-10-07 23:06:10 +02:00
|
|
|
loadPlace(area->salNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::maj2() {
|
2016-10-07 23:06:10 +02:00
|
|
|
displayPlace();
|
2016-11-28 22:33:39 -08:00
|
|
|
assert(_vm->ScreenView._pitch == 320);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->roomNum == 273 && p_global->prevLocation == 18)
|
|
|
|
p_global->ff_102 = 1;
|
|
|
|
if (p_global->eventType == EventType::etEventC) {
|
2016-09-25 23:17:25 +02:00
|
|
|
drawTopScreen();
|
|
|
|
showObjects();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
FRDevents();
|
2016-11-28 22:33:39 -08:00
|
|
|
assert(_vm->ScreenView._pitch == 320);
|
2016-11-13 22:59:45 -08:00
|
|
|
bool r30 = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->curAreaType == AreaType::atValley && !(p_global->displayFlags & DisplayFlags::dfPanable))
|
2016-11-13 22:59:45 -08:00
|
|
|
r30 = true;
|
|
|
|
//TODO: ^^ inlined func?
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->ff_102 || p_global->ff_103)
|
|
|
|
afficher();
|
|
|
|
else if (p_global->ff_F1 == (RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01)) {
|
2016-09-28 07:29:12 +02:00
|
|
|
drawBlackBars();
|
2016-09-14 23:39:27 +02:00
|
|
|
effet1();
|
|
|
|
} else if (p_global->ff_F1 && !(p_global->ff_F1 & RoomFlags::rf04) && !r30) {
|
|
|
|
if (!(p_global->displayFlags & DisplayFlags::dfPanable))
|
2016-09-28 07:29:12 +02:00
|
|
|
drawBlackBars();
|
2016-09-14 23:39:27 +02:00
|
|
|
else if (p_global->valleyVidNum)
|
2016-09-28 07:29:12 +02:00
|
|
|
drawBlackBars();
|
2016-09-14 23:39:27 +02:00
|
|
|
effet1();
|
|
|
|
} else if (r30 && !(p_global->ff_F1 & RoomFlags::rf04))
|
|
|
|
effetpix();
|
|
|
|
else
|
|
|
|
afficher128();
|
|
|
|
musique();
|
|
|
|
if (p_global->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();
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->labyrinthDirections = 0;
|
|
|
|
specialin();
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::majsalle1(int16 roomNum) {
|
2016-09-14 23:39:27 +02:00
|
|
|
room_t *room = getsalle(roomNum & 0xFF);
|
|
|
|
p_global->room_ptr = room;
|
|
|
|
debug("DrawRoom: room 0x%X, arg = 0x%X", p_global->roomNum, roomNum);
|
|
|
|
p_global->curRoomFlags = room->flags;
|
|
|
|
p_global->ff_F1 = room->flags;
|
|
|
|
animpiece();
|
|
|
|
p_global->ff_100 = 0;
|
|
|
|
maj2();
|
|
|
|
}
|
|
|
|
|
2016-10-07 23:06:10 +02:00
|
|
|
// Original name: updateRoom
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::maj_salle(uint16 roomNum) {
|
2016-09-14 23:39:27 +02:00
|
|
|
setpersohere();
|
|
|
|
majsalle1(roomNum);
|
|
|
|
}
|
|
|
|
|
2016-09-28 07:29:12 +02:00
|
|
|
// Original name: initbuf
|
|
|
|
void EdenGame::allocateBuffers() {
|
|
|
|
#define ALLOC(ptr, size, typ) if (!((ptr) = (typ*)malloc(size))) bufferAllocationErrorFl = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
ALLOC(bigfile_header, 0x10000, pak_t);
|
|
|
|
ALLOC(gameRooms, 0x4000, room_t);
|
|
|
|
ALLOC(gameIcons, 0x4000, icon_t);
|
2016-09-14 23:48:01 +02:00
|
|
|
ALLOC(bank_data_buf, 0x10000, byte);
|
2016-09-14 23:39:27 +02:00
|
|
|
ALLOC(p_global, sizeof(*p_global), global_t);
|
|
|
|
ALLOC(sal_buf, 2048, void);
|
2016-09-14 23:48:01 +02:00
|
|
|
ALLOC(gameConditions, 0x4800, byte);
|
|
|
|
ALLOC(gameDialogs, 0x2800, byte);
|
|
|
|
ALLOC(gamePhrases, 0x10000, byte);
|
|
|
|
ALLOC(main_bank_buf, 0x9400, byte);
|
|
|
|
ALLOC(glow_buffer, 0x2800, byte);
|
|
|
|
ALLOC(gameFont, 0x900, byte);
|
|
|
|
ALLOC(gameLipsync, 0x205C, byte);
|
|
|
|
ALLOC(music_buf, 0x140000, byte);
|
2016-09-14 23:39:27 +02:00
|
|
|
#undef ALLOC
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::freebuf() {
|
|
|
|
free(bigfile_header);
|
|
|
|
free(gameRooms);
|
|
|
|
free(gameIcons);
|
|
|
|
free(bank_data_buf);
|
|
|
|
free(p_global);
|
|
|
|
free(sal_buf);
|
|
|
|
free(gameConditions);
|
|
|
|
free(gameDialogs);
|
|
|
|
free(gamePhrases);
|
|
|
|
free(main_bank_buf);
|
|
|
|
free(glow_buffer);
|
|
|
|
free(gameFont);
|
|
|
|
free(gameLipsync);
|
|
|
|
free(music_buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::openwindow() {
|
|
|
|
p_underBarsView = CLView_New(320, 40);
|
2016-09-29 07:43:13 +02:00
|
|
|
p_underBarsView->_normal._width = 320;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
|
|
|
p_view2 = CLView_New(32, 32);
|
2016-09-29 07:43:13 +02:00
|
|
|
p_view2_buf = p_view2->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
|
|
|
p_subtitlesview = CLView_New(subtitles_x_width, 60);
|
2016-09-29 07:43:13 +02:00
|
|
|
p_subtitlesview_buf = p_subtitlesview->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
|
|
|
p_underSubtitlesView = CLView_New(subtitles_x_width, 60);
|
2016-09-29 07:43:13 +02:00
|
|
|
p_underSubtitlesView_buf = p_underSubtitlesView->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
|
|
|
p_mainview = CLView_New(640, 200);
|
2016-09-29 07:43:13 +02:00
|
|
|
p_mainview->_normal._width = 320;
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_FillView(p_mainview, 0xFFFFFFFF);
|
|
|
|
CLView_SetSrcZoomValues(p_mainview, 0, 0);
|
|
|
|
CLView_SetDisplayZoomValues(p_mainview, 640, 400);
|
2016-11-30 15:38:33 -08:00
|
|
|
CLView_CenterIn(&_vm->ScreenView, p_mainview);
|
2016-09-29 07:43:13 +02:00
|
|
|
p_mainview_buf = p_mainview->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-09-29 07:43:13 +02:00
|
|
|
mouse_x_center = p_mainview->_normal._dstLeft + p_mainview->_normal._width / 2;
|
|
|
|
mouse_y_center = p_mainview->_normal._dstTop + p_mainview->_normal._height / 2;
|
2016-09-14 23:39:27 +02:00
|
|
|
CLMouse_SetPosition(mouse_x_center, mouse_y_center);
|
|
|
|
CLMouse_Hide();
|
|
|
|
|
|
|
|
curs_x = 320 / 2;
|
|
|
|
curs_y = 200 / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::EmergencyExit() {
|
|
|
|
SysBeep(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::run() {
|
2016-11-09 13:40:08 -08:00
|
|
|
invIconsCount = (_vm->getPlatform() == Common::kPlatformMacintosh) ? 9 : 11;
|
2016-10-17 03:05:37 +03:00
|
|
|
roomIconsBase = invIconsBase + invIconsCount;
|
|
|
|
|
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);
|
2016-09-14 23:39:27 +02:00
|
|
|
voiceSound = CLSoundRaw_New(0, 11025 * 65536.0, 8, 0);
|
2016-11-27 12:47:04 -08:00
|
|
|
_hnmSoundChannel = _vm->_video->getSoundChannel();
|
2016-10-24 23:58:16 +02:00
|
|
|
CLSound_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();
|
|
|
|
openwindow();
|
|
|
|
loadpermfiles();
|
|
|
|
|
2016-09-28 07:29:12 +02: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-09-30 07:48:27 +02:00
|
|
|
p_mainview->_doubled = _doubledScreen;
|
2016-09-14 23:39:27 +02:00
|
|
|
while (!quit_flag2) {
|
|
|
|
init_globals();
|
2016-09-28 07:29:12 +02:00
|
|
|
quit_flag3 = false;
|
2016-10-25 23:32:15 +02:00
|
|
|
normalCursor = true;
|
2016-09-26 23:44:42 +02:00
|
|
|
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-09-14 23:39:27 +02:00
|
|
|
afficher();
|
|
|
|
fadetoblack(3);
|
|
|
|
ClearScreen();
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(95);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->endGameFlag == 50) {
|
|
|
|
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-11-13 13:56:20 -08:00
|
|
|
musicPlaying = false;
|
2016-10-22 14:15:45 +03:00
|
|
|
mus_enabled = 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-09-14 23:39:27 +02:00
|
|
|
fadetoblack(4);
|
|
|
|
closebigfile();
|
|
|
|
freebuf();
|
|
|
|
CRYOLib_ManagersDone();
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
void EdenGame::edmain() {
|
|
|
|
//TODO
|
|
|
|
entergame();
|
2016-09-28 07:29:12 +02:00
|
|
|
while (!bufferAllocationErrorFl && !quit_flag3 && p_global->endGameFlag != 50) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!gameStarted) {
|
|
|
|
// if in demo mode, reset game after a while
|
2016-11-28 22:33:39 -08:00
|
|
|
demoCurrentTicks = _vm->TimerTicks;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (demoCurrentTicks - demoStartTicks > 3000) {
|
|
|
|
rundcurs();
|
|
|
|
afficher();
|
|
|
|
fademusica0(2);
|
|
|
|
fadetoblack(3);
|
|
|
|
CLBlitter_FillScreenView(0);
|
|
|
|
CLBlitter_FillView(p_mainview, 0);
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel->stop();
|
2016-11-13 13:56:20 -08:00
|
|
|
musicPlaying = false;
|
2016-10-22 14:15:45 +03:00
|
|
|
mus_enabled = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
intro();
|
|
|
|
entergame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rundcurs();
|
|
|
|
musicspy();
|
|
|
|
FRDevents();
|
|
|
|
narrateur();
|
|
|
|
evenchrono();
|
2016-09-25 23:17:25 +02:00
|
|
|
if (p_global->drawFlags & DrawFlags::drDrawInventory)
|
|
|
|
showObjects();
|
|
|
|
if (p_global->drawFlags & DrawFlags::drDrawTopScreen)
|
|
|
|
drawTopScreen();
|
|
|
|
if ((p_global->displayFlags & DisplayFlags::dfPanable) && (p_global->displayFlags != DisplayFlags::dfPerson))
|
|
|
|
scrollpano();
|
|
|
|
if ((p_global->displayFlags & DisplayFlags::dfMirror) && (p_global->displayFlags != DisplayFlags::dfPerson))
|
|
|
|
scrollMirror();
|
2016-09-26 23:44:42 +02:00
|
|
|
if ((p_global->displayFlags & DisplayFlags::dfFrescoes) && (p_global->displayFlags != DisplayFlags::dfPerson))
|
2016-09-25 23:17:25 +02:00
|
|
|
scrollFrescoes();
|
|
|
|
if (p_global->displayFlags & DisplayFlags::dfFlag2)
|
|
|
|
noclicpanel();
|
|
|
|
if (animationActive)
|
|
|
|
anim_perso();
|
2016-09-14 23:39:27 +02:00
|
|
|
update_cursor();
|
|
|
|
afficher();
|
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
|
2016-11-17 15:40:07 -08:00
|
|
|
CLSoundChannel_Stop(_hnmSoundChannel);
|
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);
|
|
|
|
specialTextMode = false;
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(2001);
|
2016-11-17 15:40:07 -08:00
|
|
|
CLSoundChannel_Stop(_hnmSoundChannel);
|
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);
|
|
|
|
specialTextMode = false;
|
|
|
|
playHNM(170); // Intro video
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::entergame() {
|
|
|
|
char flag = 0;
|
2016-11-28 22:33:39 -08:00
|
|
|
currentTime = _vm->TimerTicks / 100;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->gameTime = currentTime;
|
2016-11-28 22:33:39 -08:00
|
|
|
demoStartTicks = _vm->TimerTicks;
|
2016-09-28 07:29:12 +02:00
|
|
|
gameStarted = false;
|
2016-11-13 13:56:20 -08:00
|
|
|
if (!_gameLoaded) {
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->roomNum = 279;
|
|
|
|
p_global->areaNum = Areas::arMo;
|
2016-09-25 23:17:25 +02:00
|
|
|
p_global->ff_100 = 0xFF;
|
2016-10-07 23:06:10 +02:00
|
|
|
initPlace(p_global->roomNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->currentMusicNum = 0;
|
|
|
|
startmusique(1);
|
|
|
|
} else {
|
2016-09-26 07:57:27 +02:00
|
|
|
flag = p_global->autoDialog; //TODO
|
2016-09-14 23:39:27 +02:00
|
|
|
initafterload();
|
|
|
|
lastMusicNum = p_global->currentMusicNum; //TODO: ???
|
|
|
|
p_global->currentMusicNum = 0;
|
|
|
|
startmusique(lastMusicNum);
|
|
|
|
p_global->inventoryScrollPos = 0;
|
2016-09-28 07:29:12 +02: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-09-28 07:29:12 +02:00
|
|
|
showBlackBars = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_102 = 1;
|
|
|
|
maj_salle(p_global->roomNum);
|
|
|
|
if (flag) {
|
2016-08-18 13:15:54 +02:00
|
|
|
p_global->iconsIndex = 4;
|
2016-09-26 07:57:27 +02:00
|
|
|
p_global->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::testPommeQ() {
|
|
|
|
if (!CLKeyboard_HasCmdDown())
|
|
|
|
return;
|
2016-10-25 23:32:15 +02:00
|
|
|
|
|
|
|
char key = CLKeyboard_GetLastASCII();
|
|
|
|
if (key == 'Q' || key == 'q') {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!pomme_q)
|
2016-10-25 23:32:15 +02:00
|
|
|
pomme_q = true;
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::FRDevents() {
|
|
|
|
CLKeyboard_Read();
|
2016-11-13 13:56:20 -08:00
|
|
|
if (_allowDoubled) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (CLKeyboard_IsScanCodeDown(0x30)) { //TODO: const
|
|
|
|
if (!keybd_held) {
|
2016-09-30 07:48:27 +02:00
|
|
|
_doubledScreen = !_doubledScreen;
|
|
|
|
p_mainview->_doubled = _doubledScreen;
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_FillScreenView(0);
|
2016-09-30 07:48:27 +02:00
|
|
|
keybd_held = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
} else
|
2016-09-30 07:48:27 +02:00
|
|
|
keybd_held = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-09-30 07:48:27 +02:00
|
|
|
int16 mouseY;
|
|
|
|
int16 mouseX;
|
|
|
|
CLMouse_GetPosition(&mouseX, &mouseY);
|
|
|
|
mouseX -= mouse_x_center;
|
|
|
|
mouseY -= mouse_y_center;
|
2016-09-14 23:39:27 +02:00
|
|
|
CLMouse_SetPosition(mouse_x_center, mouse_y_center);
|
2016-09-30 07:48:27 +02:00
|
|
|
curs_x += mouseX;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (curs_x < 4)
|
|
|
|
curs_x = 4;
|
|
|
|
if (curs_x > 292)
|
|
|
|
curs_x = 292;
|
2016-09-30 07:48:27 +02:00
|
|
|
curs_y += mouseY;
|
2016-11-14 14:51:52 -08:00
|
|
|
|
|
|
|
int16 max_y = p_global->displayFlags == DisplayFlags::dfFlag2 ? 190 : 170;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (curs_y < 4)
|
|
|
|
curs_y = 4;
|
|
|
|
if (curs_y > max_y)
|
|
|
|
curs_y = max_y;
|
|
|
|
curs_x_pan = curs_x;
|
2016-09-26 23:44:42 +02:00
|
|
|
if (curs_y >= 10 && curs_y <= 164 && !(p_global->displayFlags & DisplayFlags::dfFrescoes))
|
2016-09-30 07:48:27 +02:00
|
|
|
curs_x_pan += _scrollPos;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (normalCursor) {
|
2016-11-13 13:56:20 -08:00
|
|
|
_currCursor = 0;
|
|
|
|
current_spot = scan_icon_list(curs_x_pan + _cursCenter, curs_y + _cursCenter, p_global->iconsIndex);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (current_spot)
|
2016-11-13 13:56:20 -08:00
|
|
|
_currCursor = current_spot->cursor_id;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-11-13 13:56:20 -08:00
|
|
|
if (_cursCenter == 0 && _currCursor != 53) {
|
|
|
|
_cursCenter = 11;
|
2016-09-14 23:39:27 +02:00
|
|
|
curs_x -= 11;
|
|
|
|
}
|
2016-11-13 13:56:20 -08:00
|
|
|
if (_cursCenter == 11 && _currCursor == 53) {
|
|
|
|
_cursCenter = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
curs_x += 11;
|
|
|
|
}
|
|
|
|
if (p_global->displayFlags & DisplayFlags::dfPanable) {
|
|
|
|
//TODO: current_spot may be zero (due to scan_icon_list failure) if cursor slips between hot areas.
|
|
|
|
//fix me here or above?
|
|
|
|
if (current_spot) { // ok, plug it here
|
|
|
|
current_spot2 = current_spot;
|
2016-09-29 00:32:49 +02:00
|
|
|
displayAdamMapMark(current_spot2->action_id - 14);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->displayFlags == DisplayFlags::dfFlag2 && current_spot)
|
|
|
|
current_spot2 = current_spot;
|
2016-09-26 23:44:42 +02:00
|
|
|
if (p_global->displayFlags & DisplayFlags::dfFrescoes) {
|
2016-09-30 07:48:27 +02:00
|
|
|
if (_frescoTalk)
|
2016-09-14 23:39:27 +02:00
|
|
|
restaurefondbulle();
|
2016-11-13 13:56:20 -08:00
|
|
|
if (_currCursor == 9 && !torchCursor) {
|
2016-09-14 23:39:27 +02:00
|
|
|
rundcurs();
|
2016-09-26 23:44:42 +02:00
|
|
|
torchCursor = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
glow_x = -1;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-11-13 13:56:20 -08:00
|
|
|
if (_currCursor != 9 && torchCursor) {
|
2016-09-14 23:39:27 +02:00
|
|
|
unglow();
|
2016-09-26 23:44:42 +02:00
|
|
|
torchCursor = false;
|
2016-09-28 07:29:12 +02:00
|
|
|
curs_saved = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (CLMouse_IsDown()) {
|
|
|
|
if (!mouse_held) {
|
2016-10-25 23:32:15 +02:00
|
|
|
mouse_held = true;
|
2016-09-28 07:29:12 +02:00
|
|
|
gameStarted = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
mouse();
|
|
|
|
}
|
|
|
|
} else
|
2016-10-25 23:32:15 +02:00
|
|
|
mouse_held = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->displayFlags != DisplayFlags::dfFlag2) {
|
2016-09-30 07:48:27 +02:00
|
|
|
if (--_inventoryScrollDelay <= 0) {
|
2016-10-17 03:05:37 +03:00
|
|
|
if (p_global->obj_count > invIconsCount && curs_y > 164) {
|
|
|
|
if (curs_x > 284 && p_global->inventoryScrollPos + invIconsCount < p_global->obj_count) {
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->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
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
if (curs_x < 30 && p_global->inventoryScrollPos != 0) {
|
|
|
|
p_global->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;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!pomme_q) {
|
|
|
|
testPommeQ();
|
|
|
|
if (pomme_q) {
|
|
|
|
PommeQ();
|
|
|
|
return; //TODO: useless
|
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
|
|
|
icon_t *EdenGame::scan_icon_list(int16 x, int16 y, int16 index) {
|
2016-09-14 23:39:27 +02:00
|
|
|
icon_t *icon;
|
|
|
|
for (icon = &gameIcons[index]; icon->sx >= 0; icon++) {
|
|
|
|
if (icon->cursor_id & 0x8000)
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::update_cursor() {
|
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-09-14 23:39:27 +02:00
|
|
|
if (!torchCursor) {
|
|
|
|
use_main_bank();
|
2016-09-30 07:48:27 +02:00
|
|
|
sundcurs(curs_x + _scrollPos, curs_y);
|
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-10-17 03:05:37 +03:00
|
|
|
moteur();
|
|
|
|
else
|
|
|
|
pc_moteur();
|
|
|
|
} else
|
2016-11-13 13:56:20 -08:00
|
|
|
noclipax(_currCursor, curs_x + _scrollPos, curs_y);
|
2016-09-14 23:39:27 +02:00
|
|
|
glow_x = 1;
|
|
|
|
} else {
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(117);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (curs_x > 294)
|
|
|
|
curs_x = 294;
|
|
|
|
unglow();
|
2016-11-13 13:56:20 -08:00
|
|
|
glow(_glowIndex);
|
|
|
|
noclipax(_torchCurIndex, curs_x + _scrollPos, curs_y);
|
2016-09-30 07:48:27 +02:00
|
|
|
if (_frescoTalk)
|
2016-09-14 23:39:27 +02:00
|
|
|
af_subtitle();
|
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-09-27 07:53:50 +02:00
|
|
|
&EdenGame::moveNorth,
|
|
|
|
&EdenGame::moveEast,
|
|
|
|
&EdenGame::moveSouth,
|
|
|
|
&EdenGame::moveWest,
|
2016-09-14 23:39:27 +02:00
|
|
|
&EdenGame::plaquemonk,
|
|
|
|
&EdenGame::fresquesgraa,
|
|
|
|
&EdenGame::pushpierre,
|
|
|
|
&EdenGame::tetesquel,
|
|
|
|
&EdenGame::tetemomie,
|
2016-09-27 07:53:50 +02:00
|
|
|
&EdenGame::moveNorth,
|
2016-09-14 23:39:27 +02:00
|
|
|
&EdenGame::roiparle1,
|
|
|
|
&EdenGame::roiparle2,
|
|
|
|
&EdenGame::roiparle3,
|
|
|
|
&EdenGame::gotohall,
|
|
|
|
&EdenGame::demitourlabi,
|
|
|
|
&EdenGame::squelmoorkong,
|
|
|
|
&EdenGame::gotonido,
|
|
|
|
&EdenGame::voirlac,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::final,
|
2016-09-27 07:53:50 +02:00
|
|
|
&EdenGame::moveNorth,
|
|
|
|
&EdenGame::moveSouth,
|
2016-09-14 23:39:27 +02:00
|
|
|
&EdenGame::visiter,
|
|
|
|
&EdenGame::dinosoufle,
|
|
|
|
&EdenGame::fresqueslasc,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
&EdenGame::gotoval,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::getprisme,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::getoeuf,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::getchampb,
|
|
|
|
&EdenGame::getchampm,
|
|
|
|
&EdenGame::getcouteau,
|
|
|
|
&EdenGame::getnidv,
|
|
|
|
&EdenGame::getnido,
|
|
|
|
&EdenGame::getor,
|
|
|
|
nullptr,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::getsoleil,
|
|
|
|
&EdenGame::getcorne,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::ret,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
&EdenGame::getplaque,
|
|
|
|
&EdenGame::clicplanval,
|
2016-09-26 23:44:42 +02:00
|
|
|
&EdenGame::endFrescoes,
|
2016-09-14 23:39:27 +02:00
|
|
|
&EdenGame::choisir,
|
|
|
|
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,
|
|
|
|
&EdenGame::roi,
|
|
|
|
&EdenGame::dina,
|
|
|
|
&EdenGame::thoo,
|
|
|
|
&EdenGame::monk,
|
|
|
|
&EdenGame::bourreau,
|
|
|
|
&EdenGame::messager,
|
|
|
|
&EdenGame::mango,
|
|
|
|
&EdenGame::eve,
|
|
|
|
&EdenGame::azia,
|
|
|
|
&EdenGame::mammi,
|
|
|
|
&EdenGame::gardes,
|
|
|
|
&EdenGame::fisher,
|
|
|
|
&EdenGame::dino,
|
|
|
|
&EdenGame::tyran,
|
|
|
|
&EdenGame::morkus,
|
|
|
|
&EdenGame::ret,
|
|
|
|
&EdenGame::parle_moi,
|
|
|
|
&EdenGame::adam,
|
|
|
|
&EdenGame::takeobject,
|
|
|
|
&EdenGame::putobject,
|
|
|
|
&EdenGame::clictimbre,
|
|
|
|
&EdenGame::dinaparle,
|
|
|
|
&EdenGame::close_perso,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
&EdenGame::generique,
|
|
|
|
&EdenGame::choixsubtitle,
|
|
|
|
&EdenGame::EdenQuit,
|
|
|
|
&EdenGame::restart,
|
|
|
|
&EdenGame::cancel2,
|
|
|
|
&EdenGame::testvoice,
|
|
|
|
&EdenGame::reglervol,
|
|
|
|
&EdenGame::load,
|
|
|
|
&EdenGame::save,
|
|
|
|
&EdenGame::cliccurstape,
|
|
|
|
&EdenGame::playtape,
|
|
|
|
&EdenGame::stoptape,
|
|
|
|
&EdenGame::rewindtape,
|
|
|
|
&EdenGame::forwardtape,
|
|
|
|
&EdenGame::confirmyes,
|
|
|
|
&EdenGame::confirmno,
|
|
|
|
&EdenGame::gotocarte
|
|
|
|
};
|
|
|
|
|
2016-11-13 13:56:20 -08:00
|
|
|
if (!(current_spot = scan_icon_list(curs_x_pan + _cursCenter,
|
|
|
|
curs_y + _cursCenter, p_global->iconsIndex)))
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
|
|
|
current_spot2 = current_spot;
|
|
|
|
debug("invoking mouse action %d", current_spot->action_id);
|
|
|
|
if (mouse_actions[current_spot->action_id])
|
|
|
|
(this->*mouse_actions[current_spot->action_id])();
|
|
|
|
}
|
|
|
|
|
|
|
|
////// film.c
|
2016-09-27 07:53:50 +02:00
|
|
|
// Original name: showfilm
|
|
|
|
void EdenGame::showMovie(char arg1) {
|
2016-11-27 14:45:28 -08:00
|
|
|
_vm->_video->readHeader(_hnmContext);
|
2016-11-27 22:27:46 -08:00
|
|
|
if (_vm->_video->_curVideoNum == 92) {
|
2016-09-29 07:43:13 +02:00
|
|
|
// _hnmContext->_header._unusedFlag2 = 0; CHECKME: Useless?
|
2016-11-17 15:40:07 -08:00
|
|
|
CLSoundChannel_SetVolumeLeft(_hnmSoundChannel, 0);
|
|
|
|
CLSoundChannel_SetVolumeRight(_hnmSoundChannel, 0);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-11-27 12:47:04 -08:00
|
|
|
|
2016-11-27 14:45:28 -08:00
|
|
|
if (_vm->_video->getVersion(_hnmContext) != 4)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-11-27 12:47:04 -08:00
|
|
|
|
|
|
|
bool playing = true;
|
2016-11-27 14:45:28 -08:00
|
|
|
_vm->_video->allocMemory(_hnmContext);
|
2016-09-29 07:43:13 +02:00
|
|
|
p_hnmview = CLView_New(_hnmContext->_header._width, _hnmContext->_header._height);
|
2016-09-14 23:39:27 +02:00
|
|
|
CLView_SetSrcZoomValues(p_hnmview, 0, 0);
|
2016-09-29 07:43:13 +02:00
|
|
|
CLView_SetDisplayZoomValues(p_hnmview, _hnmContext->_header._width * 2, _hnmContext->_header._height * 2);
|
2016-11-30 15:38:33 -08:00
|
|
|
CLView_CenterIn(&_vm->ScreenView, p_hnmview);
|
2016-09-29 07:43:13 +02:00
|
|
|
p_hnmview_buf = p_hnmview->_bufferPtr;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (arg1) {
|
2016-09-29 07:43:13 +02:00
|
|
|
p_hnmview->_normal._height = 160;
|
|
|
|
p_hnmview->_zoom._height = 320; //TODO: width??
|
|
|
|
p_hnmview->_normal._dstTop = p_mainview->_normal._dstTop + 16;
|
|
|
|
p_hnmview->_zoom._dstTop = p_mainview->_zoom._dstTop + 32;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-11-27 14:45:28 -08:00
|
|
|
_vm->_video->setFinalBuffer(_hnmContext, p_hnmview->_bufferPtr);
|
2016-09-30 07:48:27 +02:00
|
|
|
p_hnmview->_doubled = _doubledScreen;
|
2016-09-14 23:39:27 +02:00
|
|
|
do {
|
2016-11-27 14:45:28 -08:00
|
|
|
hnm_position = _vm->_video->getFrameNum(_hnmContext);
|
2016-11-27 12:47:04 -08:00
|
|
|
_vm->_video->waitLoop(_hnmContext);
|
|
|
|
playing = _vm->_video->nextElement(_hnmContext);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (specialTextMode)
|
2016-09-26 23:44:42 +02:00
|
|
|
displayHNMSubtitles();
|
2016-09-14 23:39:27 +02:00
|
|
|
else
|
|
|
|
musicspy();
|
|
|
|
CLBlitter_CopyView2Screen(p_hnmview);
|
2016-11-28 22:33:39 -08:00
|
|
|
assert(_vm->ScreenView._pitch == 320);
|
2016-09-14 23:39:27 +02:00
|
|
|
CLKeyboard_Read();
|
2016-11-13 13:56:20 -08:00
|
|
|
if (_allowDoubled) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (CLKeyboard_IsScanCodeDown(0x30)) { //TODO: const
|
|
|
|
if (!keybd_held) {
|
2016-09-30 07:48:27 +02:00
|
|
|
_doubledScreen = !_doubledScreen;
|
|
|
|
p_hnmview->_doubled = _doubledScreen; //TODO: but mainview ?
|
2016-09-14 23:39:27 +02:00
|
|
|
CLBlitter_FillScreenView(0);
|
2016-09-30 07:48:27 +02:00
|
|
|
keybd_held = true;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
} else
|
2016-09-30 07:48:27 +02:00
|
|
|
keybd_held = false;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (arg1) {
|
|
|
|
if (CLMouse_IsDown()) {
|
|
|
|
if (!mouse_held) {
|
2016-10-25 23:32:15 +02:00
|
|
|
mouse_held = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
videoCanceled = 1;
|
|
|
|
}
|
|
|
|
} else
|
2016-10-25 23:32:15 +02:00
|
|
|
mouse_held = false;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
} while (playing && !videoCanceled);
|
|
|
|
CLView_Free(p_hnmview);
|
2016-11-27 14:45:28 -08:00
|
|
|
_vm->_video->deallocMemory(_hnmContext);
|
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;
|
2016-11-27 22:27:46 -08:00
|
|
|
_vm->_video->_curVideoNum = num;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (num != 2001 && num != 2012 && num != 98 && num != 171) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte oldMusicType = p_global->newMusicType;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->newMusicType = MusicType::mtEvent;
|
|
|
|
musique();
|
|
|
|
musicspy();
|
|
|
|
p_global->newMusicType = oldMusicType;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->videoSubtitleIndex = 1;
|
|
|
|
if (specialTextMode) {
|
|
|
|
perso = p_global->perso_ptr;
|
|
|
|
oldDialogType = p_global->dialogType;
|
|
|
|
prechargephrases(num);
|
|
|
|
fademusica0(1);
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel->stop();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-11-13 13:56:20 -08:00
|
|
|
showVideoSubtitle = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
videoCanceled = 0;
|
|
|
|
shnmfl(num);
|
2016-11-27 12:47:04 -08:00
|
|
|
_vm->_video->reset(_hnmContext);
|
|
|
|
_vm->_video->flushPreloadBuffer(_hnmContext);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (needToFade) {
|
|
|
|
fadetoblack(4);
|
|
|
|
ClearScreen();
|
2016-11-13 15:46:36 -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);
|
|
|
|
p_mainview->_doubled = _doubledScreen;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (specialTextMode) {
|
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
|
|
|
p_global->perso_ptr = perso;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->dialogType = oldDialogType;
|
2016-09-26 23:44:42 +02:00
|
|
|
specialTextMode = false;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (videoCanceled)
|
|
|
|
p_global->ff_F1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01;
|
2016-11-27 22:27:46 -08:00
|
|
|
if (_vm->_video->_curVideoNum == 167)
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_F1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01;
|
2016-11-27 22:27:46 -08:00
|
|
|
if (_vm->_video->_curVideoNum == 104)
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_F1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01;
|
2016-11-27 22:27:46 -08:00
|
|
|
if (_vm->_video->_curVideoNum == 102)
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_F1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01;
|
2016-11-27 22:27:46 -08:00
|
|
|
if (_vm->_video->_curVideoNum == 77)
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_F1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01;
|
2016-11-27 22:27:46 -08:00
|
|
|
if (_vm->_video->_curVideoNum == 149)
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_F1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01;
|
|
|
|
}
|
|
|
|
|
2016-09-26 23:44:42 +02:00
|
|
|
// Original name bullehnm
|
|
|
|
void EdenGame::displayHNMSubtitles() {
|
2016-09-26 07:57:27 +02:00
|
|
|
int16 *frames;
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *perso;
|
2016-11-27 22:27:46 -08:00
|
|
|
switch (_vm->_video->_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-09-26 07:57:27 +02:00
|
|
|
int16 *frames_start = frames;
|
|
|
|
int16 frame;
|
2016-09-14 23:39:27 +02:00
|
|
|
while ((frame = *frames++) != -1) {
|
|
|
|
if ((frame & ~0x8000) == hnm_position)
|
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (frame == -1) {
|
|
|
|
if (showVideoSubtitle)
|
|
|
|
af_subtitlehnm();
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (frame & 0x8000)
|
2016-11-13 13:56:20 -08:00
|
|
|
showVideoSubtitle = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
else {
|
|
|
|
p_global->videoSubtitleIndex = (frames - frames_start) / 2 + 1;
|
2016-08-18 13:15:54 +02:00
|
|
|
p_global->perso_ptr = perso;
|
|
|
|
p_global->dialogType = DialogType::dtInspect;
|
2016-10-07 00:45:08 +02:00
|
|
|
int16 num = (perso->_id << 3) | p_global->dialogType;
|
|
|
|
dialoscansvmas((dial_t *)getElem(gameDialogs, num));
|
2016-11-13 13:56:20 -08:00
|
|
|
showVideoSubtitle = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
if (showVideoSubtitle)
|
|
|
|
af_subtitlehnm();
|
|
|
|
}
|
|
|
|
|
|
|
|
////// sound.c
|
|
|
|
void EdenGame::musique() {
|
|
|
|
if (p_global->newMusicType == MusicType::mtDontChange)
|
|
|
|
return;
|
2016-11-14 14:51:52 -08:00
|
|
|
|
|
|
|
dial_t *dial = (dial_t *)getElem(gameDialogs, 128);
|
|
|
|
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;
|
|
|
|
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;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->newMusicType = MusicType::mtDontChange;
|
|
|
|
if (mus != 0 && mus != 2 && mus < 50)
|
|
|
|
startmusique(mus);
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::startmusique(byte num) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (num == p_global->currentMusicNum)
|
|
|
|
return;
|
2016-11-14 14:51:52 -08:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
if (musicPlaying) {
|
|
|
|
fademusica0(1);
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel->stop();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
loadmusicfile(num);
|
|
|
|
p_global->currentMusicNum = num;
|
|
|
|
mus_sequence_ptr = music_buf + 32; //TODO: rewrite it properly
|
2016-11-14 14:51:52 -08:00
|
|
|
int16 seq_size = PLE16(music_buf + 30);
|
2016-09-14 23:39:27 +02:00
|
|
|
mus_patterns_ptr = music_buf + 30 + seq_size;
|
2016-11-14 14:51:52 -08:00
|
|
|
int16 pat_size = PLE16(music_buf + 27);
|
2016-09-14 23:39:27 +02:00
|
|
|
mus_samples_ptr = music_buf + 32 + 4 + pat_size;
|
2016-11-14 14:51:52 -08:00
|
|
|
int16 freq = PLE16(mus_samples_ptr - 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-10-22 14:15:45 +03:00
|
|
|
mus_enabled = true;
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
musicSequencePos = 0;
|
|
|
|
mus_vol_left = p_global->pref_10C[0];
|
|
|
|
mus_vol_right = p_global->pref_10C[1];
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel->setVolume(mus_vol_left, mus_vol_right);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::musicspy() {
|
2016-10-22 14:15:45 +03:00
|
|
|
if (!mus_enabled)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
|
|
|
mus_vol_left = p_global->pref_10C[0];
|
|
|
|
mus_vol_right = p_global->pref_10C[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-11-14 14:51:52 -08:00
|
|
|
byte patnum = mus_sequence_ptr[(int)musicSequencePos];
|
2016-09-14 23:39:27 +02:00
|
|
|
if (patnum == 0xFF) {
|
|
|
|
// rewind
|
|
|
|
musicSequencePos = 0;
|
2016-10-08 21:21:21 +02:00
|
|
|
patnum = mus_sequence_ptr[(int)musicSequencePos];
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
musicSequencePos++;
|
2016-11-14 14:51:52 -08:00
|
|
|
byte *patptr = mus_patterns_ptr + patnum * 6;
|
|
|
|
int ofs = patptr[0] + (patptr[1] << 8) + (patptr[2] << 16);
|
|
|
|
int len = patptr[3] + (patptr[4] << 8) + (patptr[5] << 16);
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel->queueBuffer(mus_samples_ptr + ofs, len);
|
2016-11-13 13:56:20 -08:00
|
|
|
musicPlaying = 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) {
|
2016-09-14 23:39:27 +02:00
|
|
|
pakfile_t *file = &bigfile_header->files[num + 435];
|
2016-10-08 23:31:21 +02:00
|
|
|
int32 size = PLE32(&file->size);
|
|
|
|
int32 offs = PLE32(&file->offs);
|
2016-11-10 15:37:48 -08:00
|
|
|
h_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;
|
2016-11-09 13:40:08 -08:00
|
|
|
h_bigfile.read(music_buf, numread);
|
2016-09-14 23:39:27 +02:00
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::persovox() {
|
2016-09-14 23:48:01 +02:00
|
|
|
int16 num = p_global->textNum;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->textBankIndex != 1)
|
|
|
|
num += 565;
|
|
|
|
if (p_global->textBankIndex == 3)
|
|
|
|
num += 707;
|
|
|
|
voiceSamplesSize = ssndfl(num);
|
2016-10-06 00:15:02 +02:00
|
|
|
int16 volumeLeft = p_global->pref_110[0];
|
|
|
|
int16 volumeRight = p_global->pref_110[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);
|
|
|
|
volumeLeft = p_global->pref_10E[0];
|
|
|
|
volumeRight = p_global->pref_10E[1];
|
2016-10-22 14:15:45 +03:00
|
|
|
_voiceChannel->setVolume(volumeLeft, volumeRight);
|
|
|
|
_voiceChannel->queueBuffer((byte*)voiceSamplesBuffer, voiceSamplesSize, true);
|
2016-10-06 00:15:02 +02:00
|
|
|
_personTalking = true;
|
|
|
|
_musicFadeFlag = 0;
|
2016-11-28 22:33:39 -08:00
|
|
|
_lastAnimTicks = _vm->TimerTicks;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::endpersovox() {
|
|
|
|
restaurefondbulle();
|
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) {
|
|
|
|
free(voiceSamplesBuffer);
|
|
|
|
voiceSamplesBuffer = nullptr;
|
|
|
|
_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-09-14 23:39:27 +02:00
|
|
|
if (vol < mus_vol_left) {
|
|
|
|
vol += 8;
|
|
|
|
if (vol > mus_vol_left)
|
|
|
|
vol = mus_vol_left;
|
2016-08-18 13:15:54 +02:00
|
|
|
} else {
|
2016-09-14 23:39:27 +02:00
|
|
|
vol -= 8;
|
|
|
|
if (vol < mus_vol_left)
|
|
|
|
vol = mus_vol_left;
|
|
|
|
}
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel->setVolumeLeft(vol);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (vol == mus_vol_left)
|
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-09-14 23:39:27 +02:00
|
|
|
if (vol < mus_vol_right) {
|
|
|
|
vol += 8;
|
|
|
|
if (vol > mus_vol_right)
|
|
|
|
vol = mus_vol_right;
|
2016-08-18 13:15:54 +02:00
|
|
|
} else {
|
2016-09-14 23:39:27 +02:00
|
|
|
vol -= 8;
|
|
|
|
if (vol < mus_vol_right)
|
|
|
|
vol = mus_vol_right;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel->setVolumeRight(vol);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (vol == mus_vol_right)
|
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-09-14 23:48:01 +02:00
|
|
|
object_t *EdenGame::getobjaddr(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-10-07 00:45:08 +02:00
|
|
|
if (objects[i]._id == id)
|
2016-09-14 23:39:27 +02:00
|
|
|
break;
|
2016-10-06 00:15:02 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
return objects + i;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-10-07 00:45:08 +02: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;
|
|
|
|
goto show_all_objects; //DEBUG
|
2016-08-18 13:15:54 +02:00
|
|
|
#endif
|
2016-09-14 23:39:27 +02:00
|
|
|
if (count == 0)
|
|
|
|
continue;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (objects[i]._flags & ObjectFlags::ofInHands)
|
2016-09-14 23:39:27 +02:00
|
|
|
count--;
|
|
|
|
show_all_objects:
|
|
|
|
;
|
|
|
|
if (count) {
|
|
|
|
total += count;
|
|
|
|
while (count--)
|
2016-10-07 00:45:08 +02:00
|
|
|
own_objects[index++] = objects[i]._id;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->obj_count = total;
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-25 23:17:25 +02:00
|
|
|
void EdenGame::showObjects() {
|
2016-10-17 03:05:37 +03:00
|
|
|
icon_t *icon = &gameIcons[invIconsBase];
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->drawFlags &= ~(DrawFlags::drDrawInventory | DrawFlags::drDrawFlag2);
|
|
|
|
countobjects();
|
2016-11-14 14:51:52 -08:00
|
|
|
int16 total = p_global->obj_count;
|
|
|
|
for (int16 i = invIconsCount; i--; icon++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (total) {
|
|
|
|
icon->cursor_id &= ~0x8000;
|
|
|
|
total--;
|
|
|
|
} else
|
|
|
|
icon->cursor_id |= 0x8000;
|
|
|
|
}
|
|
|
|
use_main_bank();
|
|
|
|
noclipax(55, 0, 176);
|
2016-10-17 03:05:37 +03:00
|
|
|
icon = &gameIcons[invIconsBase];
|
2016-09-14 23:39:27 +02:00
|
|
|
total = p_global->obj_count;
|
2016-11-14 14:51:52 -08:00
|
|
|
int16 index = p_global->inventoryScrollPos;
|
|
|
|
for (int16 i = invIconsCount; total-- && i--; icon++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
char obj = own_objects[index++];
|
|
|
|
icon->object_id = obj;
|
|
|
|
noclipax(obj + 9, icon->sx, 178);
|
|
|
|
}
|
2016-10-25 23:32:15 +02:00
|
|
|
needPaletteUpdate = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
if ((p_global->displayFlags & DisplayFlags::dfMirror) || (p_global->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-09-14 23:48:01 +02:00
|
|
|
void EdenGame::winobject(int16 id) {
|
2016-09-14 23:39:27 +02:00
|
|
|
object_t *object = getobjaddr(id);
|
2016-10-07 00:45:08 +02:00
|
|
|
object->_flags |= ObjectFlags::ofFlag1;
|
|
|
|
object->_count++;
|
|
|
|
p_global->curItemsMask |= object->_itemMask;
|
|
|
|
p_global->wonItemsMask |= object->_itemMask;
|
|
|
|
p_global->curPowersMask |= object->_powerMask;
|
|
|
|
p_global->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-09-14 23:39:27 +02:00
|
|
|
object_t *object = getobjaddr(id);
|
2016-10-07 00:45:08 +02:00
|
|
|
if (object->_count > 0)
|
|
|
|
object->_count--;
|
|
|
|
if (!object->_count) {
|
|
|
|
object->_flags &= ~ObjectFlags::ofFlag1;
|
|
|
|
p_global->curItemsMask &= ~object->_itemMask;
|
|
|
|
p_global->curPowersMask &= ~object->_powerMask;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
p_global->curObjectId = 0;
|
|
|
|
p_global->curObjectFlags = 0;
|
|
|
|
p_global->curObjectCursor = 9;
|
|
|
|
gameIcons[16].cursor_id |= 0x8000;
|
2016-10-07 00:45:08 +02:00
|
|
|
object->_flags &= ~ObjectFlags::ofInHands;
|
2016-10-25 23:32:15 +02:00
|
|
|
normalCursor = true;
|
2016-11-13 13:56:20 -08:00
|
|
|
_currCursor = 0;
|
2016-09-26 23:44:42 +02:00
|
|
|
torchCursor = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::lostobject() {
|
2016-10-24 00:04:32 +02:00
|
|
|
parlemoiNormalFlag = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->curObjectId)
|
2016-09-26 23:44:42 +02:00
|
|
|
loseObject(p_global->curObjectId);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-11-14 14:51:52 -08:00
|
|
|
bool EdenGame::objecthere(int16 id) {
|
2016-09-14 23:39:27 +02:00
|
|
|
object_t *object = getobjaddr(id);
|
2016-10-07 00:45:08 +02:00
|
|
|
for (pCurrentObjectLocation = &kObjectLocations[object->_locations]; *pCurrentObjectLocation != -1; pCurrentObjectLocation++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (*pCurrentObjectLocation == p_global->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-09-14 23:39:27 +02:00
|
|
|
object_t *object = getobjaddr(id);
|
|
|
|
gameIcons[16].cursor_id &= ~0x8000;
|
2016-10-07 00:45:08 +02:00
|
|
|
p_global->curObjectId = object->_id;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->curObjectCursor = p_global->curObjectId + 9;
|
2016-10-07 00:45:08 +02:00
|
|
|
object->_flags |= ObjectFlags::ofInHands;
|
|
|
|
p_global->curObjectFlags = object->_flags;
|
2016-11-13 13:56:20 -08:00
|
|
|
_currCursor = p_global->curObjectId + 9;
|
2016-10-25 23:32:15 +02:00
|
|
|
normalCursor = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::getobject(int16 id) {
|
2016-09-14 23:39:27 +02:00
|
|
|
room_t *room = p_global->room_ptr;
|
|
|
|
if (p_global->curObjectId)
|
|
|
|
return;
|
|
|
|
if (!objecthere(id))
|
|
|
|
return;
|
|
|
|
*pCurrentObjectLocation |= 0x8000;
|
|
|
|
objectmain(id);
|
|
|
|
winobject(id);
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->roomImgBank = room->bank;
|
|
|
|
p_global->roomVidNum = room->video;
|
2016-10-07 23:06:10 +02:00
|
|
|
displayPlace();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::putobject() {
|
|
|
|
if (!p_global->curObjectId)
|
|
|
|
return;
|
|
|
|
gameIcons[16].cursor_id |= 0x8000;
|
2016-11-14 14:51:52 -08:00
|
|
|
object_t *object = getobjaddr(p_global->curObjectId);
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->curObjectCursor = 9;
|
|
|
|
p_global->curObjectId = 0;
|
|
|
|
p_global->curObjectFlags = 0;
|
2016-10-07 00:45:08 +02:00
|
|
|
object->_flags &= ~ObjectFlags::ofInHands;
|
2016-11-13 13:56:20 -08:00
|
|
|
p_global->_nextDialogPtr = nullptr;
|
2016-11-28 22:33:39 -08:00
|
|
|
closeCharacterDialog = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->dialogType = DialogType::dtTalk;
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2016-10-25 23:32:15 +02:00
|
|
|
normalCursor = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::newobject(int16 id, int16 arg2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
object_t *object = getobjaddr(id);
|
2016-10-07 00:45:08 +02:00
|
|
|
int16 e, *t = &kObjectLocations[object->_locations];
|
2016-09-14 23:39:27 +02:00
|
|
|
while ((e = *t) != -1) {
|
|
|
|
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)
|
|
|
|
p_global->stepsToFindAppleNormal = 0;
|
|
|
|
if (id >= Objects::obEyeInTheStorm && id < (Objects::obRiverThatWinds + 1) && p_global->roomPersoType == PersonFlags::pftVelociraptor) {
|
|
|
|
//TODO: fix that cond above
|
|
|
|
object_t *object = getobjaddr(id);
|
2016-10-07 00:45:08 +02:00
|
|
|
p_global->room_perso->_powers &= ~object->_powerMask;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
winobject(id);
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
void EdenGame::giveobject() {
|
2016-11-14 14:51:52 -08:00
|
|
|
byte id = p_global->giveobj1;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (id) {
|
|
|
|
p_global->giveobj1 = 0;
|
|
|
|
giveobjectal(id);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
id = p_global->giveobj2;
|
|
|
|
if (id) {
|
|
|
|
p_global->giveobj2 = 0;
|
|
|
|
giveobjectal(id);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
id = p_global->giveobj3;
|
|
|
|
if (id) {
|
|
|
|
p_global->giveobj3 = 0;
|
|
|
|
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-09-14 23:39:27 +02:00
|
|
|
void EdenGame::takeobject() {
|
|
|
|
objectmain(current_spot2->object_id);
|
2016-11-13 13:56:20 -08:00
|
|
|
p_global->_nextDialogPtr = nullptr;
|
2016-11-28 22:33:39 -08:00
|
|
|
closeCharacterDialog = false;
|
2016-10-24 00:04:32 +02:00
|
|
|
p_global->dialogType = DialogType::dtTalk;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->inventoryScrollPos)
|
|
|
|
p_global->inventoryScrollPos--;
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
////
|
|
|
|
void EdenGame::newchampi() {
|
2016-10-07 00:45:08 +02:00
|
|
|
if (objects[Objects::obShroom - 1]._count == 0) {
|
2016-09-14 23:39:27 +02:00
|
|
|
newobject(Objects::obShroom, p_global->cita_area_num);
|
|
|
|
newobject(Objects::obBadShroom, p_global->cita_area_num);
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::newnidv() {
|
|
|
|
room_t *room = p_global->cita_area_firstRoom;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (objects[Objects::obNest - 1]._count)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-11-14 14:51:52 -08:00
|
|
|
object_t *obj = getobjaddr(Objects::obNest);
|
|
|
|
for (int16 *ptr = kObjectLocations + obj->_locations; *ptr != -1; ptr++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if ((*ptr & ~0x8000) >> 8 != p_global->cita_area_num)
|
|
|
|
continue;
|
|
|
|
*ptr &= ~0x8000;
|
|
|
|
for (; room->ff_0 != 0xFF; room++) {
|
|
|
|
if (room->location == (*ptr & 0xFF)) {
|
|
|
|
room->bank = 279;
|
|
|
|
room->ff_0 = 9;
|
|
|
|
room++;
|
|
|
|
room->bank = 280;
|
|
|
|
return;
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::newnido() {
|
|
|
|
room_t *room = p_global->cita_area_firstRoom;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (objects[Objects::obFullNest - 1]._count)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (objects[Objects::obNest - 1]._count)
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
2016-11-14 14:51:52 -08:00
|
|
|
object_t *obj = getobjaddr(Objects::obFullNest);
|
|
|
|
for (int16 *ptr = kObjectLocations + obj->_locations; *ptr != -1; ptr++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
if ((*ptr & ~0x8000) >> 8 != p_global->cita_area_num)
|
|
|
|
continue;
|
|
|
|
*ptr &= ~0x8000;
|
|
|
|
for (; room->ff_0 != 0xFF; room++) {
|
|
|
|
if (room->location == (*ptr & 0xFF)) {
|
|
|
|
room->bank = 277;
|
|
|
|
room->ff_0 = 9;
|
|
|
|
room++;
|
|
|
|
room->bank = 278;
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::newor() {
|
2016-10-07 00:45:08 +02:00
|
|
|
if (objects[Objects::obGold - 1]._count == 0) {
|
2016-09-14 23:39:27 +02:00
|
|
|
newobject(Objects::obGold, p_global->cita_area_num);
|
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::gotopanel() {
|
|
|
|
if (pomme_q)
|
2016-09-26 07:57:27 +02:00
|
|
|
byte_31D64 = p_global->autoDialog; //TODO: check me
|
2016-11-13 13:56:20 -08:00
|
|
|
_noPalette = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->iconsIndex = 85;
|
2016-11-13 22:59:45 -08:00
|
|
|
p_global->perso_ptr = nullptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->drawFlags |= DrawFlags::drDrawMenu;
|
|
|
|
p_global->displayFlags = DisplayFlags::dfFlag2;
|
|
|
|
p_global->menuFlags = 0;
|
|
|
|
affpanel();
|
|
|
|
fadetoblack(3);
|
|
|
|
afftoppano();
|
|
|
|
CLBlitter_CopyView2Screen(p_mainview);
|
|
|
|
CLPalette_Send2Screen(global_palette, 0, 256);
|
|
|
|
curs_x = 320 / 2;
|
|
|
|
curs_y = 200 / 2;
|
|
|
|
CLMouse_SetPosition(mouse_x_center, mouse_y_center);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::noclicpanel() {
|
|
|
|
if (p_global->menuFlags & MenuFlags::mfFlag4) {
|
|
|
|
depcurstape();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (p_global->drawFlags & DrawFlags::drDrawFlag8)
|
|
|
|
return;
|
|
|
|
if (p_global->menuFlags & MenuFlags::mfFlag1) {
|
|
|
|
changervol();
|
|
|
|
return;
|
|
|
|
}
|
2016-11-14 14:51:52 -08:00
|
|
|
byte num;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (current_spot2 >= &gameIcons[119]) {
|
2016-10-08 21:21:21 +02:00
|
|
|
debug("noclic: objid = %p, glob3,2 = %2X %2X", (void *)current_spot2, p_global->menuItemIdHi, p_global->menuItemIdLo);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (current_spot2->object_id == (p_global->menuItemIdLo + p_global->menuItemIdHi) << 8) //TODO: check me
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
int idx = current_spot2 - &gameIcons[105];
|
|
|
|
if (idx == 0) {
|
|
|
|
p_global->menuItemIdLo = 1;
|
|
|
|
num = 1;
|
|
|
|
goto skip;
|
|
|
|
}
|
|
|
|
num = idx & 0x7F + 1;
|
|
|
|
if (num >= 5)
|
|
|
|
num = 1;
|
|
|
|
if (num == p_global->ff_43)
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
p_global->ff_43 = 0;
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
num = p_global->menuItemIdLo;
|
|
|
|
p_global->menuItemIdLo = current_spot2->object_id & 0xFF;
|
|
|
|
skip:
|
|
|
|
;
|
|
|
|
p_global->menuItemIdHi = (current_spot2->object_id & 0xFF00) >> 8;
|
|
|
|
debug("noclic: new glob3,2 = %2X %2X", p_global->menuItemIdHi, p_global->menuItemIdLo);
|
|
|
|
affresult();
|
|
|
|
num &= 0xF0;
|
|
|
|
if (num != 0x30)
|
|
|
|
num = p_global->menuItemIdLo & 0xF0;
|
|
|
|
if (num == 0x30)
|
|
|
|
affcurseurs();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::generique() {
|
2016-09-28 07:29:12 +02:00
|
|
|
drawBlackBars();
|
2016-09-14 23:39:27 +02:00
|
|
|
afficher();
|
|
|
|
fadetoblack(3);
|
|
|
|
ClearScreen();
|
2016-11-14 14:51:52 -08:00
|
|
|
int oldmusic = p_global->currentMusicNum;
|
2016-09-26 23:44:42 +02:00
|
|
|
playHNM(95);
|
2016-09-14 23:39:27 +02:00
|
|
|
affpanel();
|
|
|
|
afftoppano();
|
2016-10-25 23:32:15 +02:00
|
|
|
needPaletteUpdate = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
startmusique(oldmusic);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::cancel2() {
|
2016-09-25 23:17:25 +02:00
|
|
|
drawTopScreen();
|
|
|
|
showObjects();
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->iconsIndex = 16;
|
|
|
|
p_global->drawFlags &= ~DrawFlags::drDrawMenu;
|
|
|
|
gametomiroir(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::testvoice() {
|
2016-09-26 23:44:42 +02:00
|
|
|
p_global->frescoNumber = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->perso_ptr = kPersons;
|
|
|
|
p_global->dialogType = DialogType::dtInspect;
|
2016-11-14 14:51:52 -08:00
|
|
|
int16 num = (kPersons[0]._id << 3) | p_global->dialogType;
|
2016-11-13 15:46:36 -08:00
|
|
|
dialoscansvmas((dial_t *)getElem(gameDialogs, num));
|
2016-09-14 23:39:27 +02:00
|
|
|
restaurefondbulle();
|
|
|
|
af_subtitle();
|
|
|
|
persovox();
|
|
|
|
waitendspeak();
|
|
|
|
endpersovox();
|
|
|
|
p_global->ff_CA = 0;
|
|
|
|
p_global->dialogType = DialogType::dtTalk;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::load() {
|
|
|
|
char name[132];
|
2016-11-13 13:56:20 -08:00
|
|
|
_gameLoaded = false;
|
2016-11-14 14:51:52 -08:00
|
|
|
byte oldMusic = p_global->currentMusicNum; //TODO: from ush 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
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
CLMouse_Hide();
|
2016-09-26 07:57:27 +02:00
|
|
|
CLBlitter_FillScreenView(0xFFFFFFFF);
|
2016-09-14 23:39:27 +02:00
|
|
|
fadetoblack(3);
|
|
|
|
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-10-25 23:32:15 +02:00
|
|
|
needPaletteUpdate = true;
|
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 ((oldMusic & 0xFF) != p_global->currentMusicNum) { //TODO: r30 is uns char/bug???
|
|
|
|
oldMusic = p_global->currentMusicNum;
|
|
|
|
p_global->currentMusicNum = 0;
|
|
|
|
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
|
|
|
}
|
2016-11-14 14:51:52 -08:00
|
|
|
bool talk = p_global->autoDialog; //TODO check me
|
2016-09-14 23:39:27 +02:00
|
|
|
initafterload();
|
|
|
|
fadetoblack(3);
|
|
|
|
CLBlitter_FillScreenView(0);
|
|
|
|
CLBlitter_FillView(p_mainview, 0);
|
2016-09-25 23:17:25 +02:00
|
|
|
drawTopScreen();
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->inventoryScrollPos = 0;
|
2016-09-25 23:17:25 +02:00
|
|
|
showObjects();
|
2016-09-14 23:39:27 +02:00
|
|
|
maj_salle(p_global->roomNum);
|
|
|
|
if (talk) {
|
|
|
|
p_global->iconsIndex = 4;
|
2016-09-26 07:57:27 +02:00
|
|
|
p_global->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() {
|
|
|
|
p_global->perso_img_bank = 0;
|
|
|
|
p_global->lastSalNum = 0;
|
2016-10-07 23:06:10 +02:00
|
|
|
loadPlace(p_global->area_ptr->salNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
gameIcons[18].cursor_id |= 0x8000;
|
|
|
|
if (p_global->curAreaType == AreaType::atValley)
|
|
|
|
gameIcons[18].cursor_id &= ~0x8000;
|
|
|
|
kPersoRoomBankTable[30] = 27;
|
|
|
|
if (p_global->phaseNum >= 352)
|
|
|
|
kPersoRoomBankTable[30] = 26;
|
2016-11-09 22:36:06 -08:00
|
|
|
_animateTalking = false;
|
2016-10-25 23:32:15 +02:00
|
|
|
animationActive = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_100 = 0;
|
|
|
|
p_global->eventType = EventType::etEventC;
|
|
|
|
p_global->valleyVidNum = 0;
|
|
|
|
p_global->drawFlags &= ~DrawFlags::drDrawMenu;
|
2016-11-28 22:33:39 -08:00
|
|
|
currentTime = _vm->TimerTicks / 100;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->gameTime = currentTime;
|
|
|
|
if (p_global->roomPersoType == PersonFlags::pftTyrann)
|
|
|
|
chronoon(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);
|
|
|
|
CLMouse_Hide();
|
|
|
|
CLBlitter_FillScreenView(0xFFFFFFFF);
|
|
|
|
fadetoblack(3);
|
|
|
|
CLBlitter_FillScreenView(0);
|
2016-10-06 00:15:02 +02:00
|
|
|
_musicFadeFlag = 3;
|
2016-09-14 23:39:27 +02:00
|
|
|
musicspy();
|
2016-10-25 23:32:15 +02:00
|
|
|
needPaletteUpdate = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::desktopcolors() {
|
|
|
|
fadetoblack(3);
|
2016-09-26 07:57:27 +02:00
|
|
|
CLBlitter_FillScreenView(0xFFFFFFFF);
|
2016-09-14 23:39:27 +02:00
|
|
|
CLPalette_BeSystem();
|
|
|
|
CLMouse_Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::panelrestart() {
|
2016-11-13 13:56:20 -08:00
|
|
|
_gameLoaded = false;
|
2016-11-14 14:51:52 -08:00
|
|
|
byte curmus = p_global->currentMusicNum;
|
|
|
|
byte curlng = p_global->pref_language;
|
2016-09-14 23:39:27 +02:00
|
|
|
loadrestart();
|
|
|
|
p_global->pref_language = curlng;
|
2016-11-13 13:56:20 -08:00
|
|
|
if (!_gameLoaded) //TODO always?
|
2016-09-14 23:39:27 +02:00
|
|
|
return;
|
|
|
|
p_global->perso_img_bank = 0;
|
|
|
|
p_global->lastSalNum = 0;
|
2016-10-07 23:06:10 +02:00
|
|
|
loadPlace(p_global->area_ptr->salNum);
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->displayFlags = DisplayFlags::dfFlag1;
|
|
|
|
gameIcons[18].cursor_id |= 0x8000;
|
|
|
|
if (p_global->curAreaType == AreaType::atValley)
|
|
|
|
gameIcons[18].cursor_id &= ~0x8000;
|
|
|
|
kPersoRoomBankTable[30] = 27;
|
|
|
|
if (p_global->phaseNum >= 352)
|
|
|
|
kPersoRoomBankTable[30] = 26;
|
2016-11-09 22:36:06 -08:00
|
|
|
_animateTalking = false;
|
2016-10-25 23:32:15 +02:00
|
|
|
animationActive = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_100 = 0;
|
|
|
|
p_global->eventType = 0;
|
|
|
|
p_global->valleyVidNum = 0;
|
|
|
|
p_global->drawFlags &= ~DrawFlags::drDrawMenu;
|
|
|
|
p_global->inventoryScrollPos = 0;
|
2016-09-30 07:48:27 +02:00
|
|
|
_adamMapMarkPos.x = -1;
|
|
|
|
_adamMapMarkPos.y = -1;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (curmus != p_global->currentMusicNum) {
|
|
|
|
curmus = p_global->currentMusicNum;
|
|
|
|
p_global->currentMusicNum = 0;
|
|
|
|
startmusique(curmus);
|
|
|
|
}
|
|
|
|
fadetoblack(3);
|
|
|
|
CLBlitter_FillScreenView(0);
|
|
|
|
CLBlitter_FillView(p_mainview, 0);
|
2016-09-25 23:17:25 +02:00
|
|
|
drawTopScreen();
|
|
|
|
showObjects();
|
2016-09-27 07:53:50 +02:00
|
|
|
saveFriezes();
|
2016-09-28 07:29:12 +02:00
|
|
|
showBlackBars = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
maj_salle(p_global->roomNum);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::reallyquit() {
|
2016-09-28 07:29:12 +02:00
|
|
|
quit_flag3 = true;
|
|
|
|
quit_flag2 = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::confirmer(char mode, char yesId) {
|
|
|
|
p_global->iconsIndex = 119;
|
|
|
|
gameIcons[119].object_id = yesId;
|
|
|
|
confirmMode = mode;
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(65);
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(12, 117, 74);
|
|
|
|
curs_x = 156;
|
|
|
|
if (pomme_q)
|
|
|
|
curs_x = 136;
|
|
|
|
curs_y = 88;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::confirmyes() {
|
|
|
|
affpanel();
|
|
|
|
p_global->iconsIndex = 85;
|
|
|
|
switch (confirmMode) {
|
|
|
|
case 1:
|
|
|
|
panelrestart();
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
reallyquit();
|
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::confirmno() {
|
|
|
|
affpanel();
|
|
|
|
p_global->iconsIndex = 85;
|
2016-10-25 23:32:15 +02:00
|
|
|
pomme_q = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::restart() {
|
|
|
|
confirmer(1, current_spot2->object_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::EdenQuit() {
|
|
|
|
confirmer(2, current_spot2->object_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::choixsubtitle() {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte lang = current_spot2->object_id & 0xF;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (lang == p_global->pref_language)
|
|
|
|
return;
|
|
|
|
if (lang > 5)
|
|
|
|
return;
|
|
|
|
p_global->pref_language = lang;
|
|
|
|
langbuftopanel();
|
|
|
|
afflangue();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::reglervol() {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *valptr = &p_global->pref_10C[current_spot2->object_id & 7];
|
2016-09-14 23:39:27 +02:00
|
|
|
curs_y = 104 - ((*valptr >> 2) & 0x3F); // TODO: check me
|
|
|
|
cur_slider_value_ptr = valptr;
|
|
|
|
p_global->menuFlags |= MenuFlags::mfFlag1;
|
|
|
|
if (current_spot2->object_id & 8)
|
|
|
|
p_global->menuFlags |= MenuFlags::mfFlag2;
|
|
|
|
cur_slider_x = current_spot2->sx;
|
|
|
|
cur_slider_y = curs_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::changervol() {
|
|
|
|
if (mouse_held) {
|
|
|
|
limitezonecurs(cur_slider_x - 1, cur_slider_x + 3, 40, 110);
|
2016-11-14 14:51:52 -08:00
|
|
|
int16 delta = cur_slider_y - curs_y;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (delta == 0)
|
|
|
|
return;
|
|
|
|
newvol(cur_slider_value_ptr, delta);
|
|
|
|
if (p_global->menuFlags & MenuFlags::mfFlag2)
|
|
|
|
newvol(cur_slider_value_ptr + 1, delta);
|
|
|
|
cursbuftopanel();
|
|
|
|
affcurseurs();
|
|
|
|
cur_slider_y = curs_y;
|
|
|
|
} else
|
|
|
|
p_global->menuFlags &= ~(MenuFlags::mfFlag1 | MenuFlags::mfFlag2);
|
|
|
|
}
|
|
|
|
|
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;
|
2016-10-22 14:15:45 +03:00
|
|
|
_musicChannel->setVolume(p_global->pref_10C[0], p_global->pref_10C[1]);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::playtape() {
|
|
|
|
if (p_global->menuItemIdHi & 8)
|
|
|
|
p_global->tape_ptr++;
|
|
|
|
for (;; p_global->tape_ptr++) {
|
|
|
|
if (p_global->tape_ptr == &tapes[MAX_TAPES]) {
|
|
|
|
p_global->tape_ptr--;
|
|
|
|
stoptape();
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-10-07 23:06:10 +02:00
|
|
|
if (p_global->tape_ptr->_textNum)
|
2016-08-18 13:15:54 +02:00
|
|
|
break;
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->menuFlags |= MenuFlags::mfFlag8;
|
|
|
|
p_global->drawFlags &= ~DrawFlags::drDrawMenu;
|
2016-11-14 14:51:52 -08:00
|
|
|
uint16 oldRoomNum = p_global->roomNum;
|
|
|
|
uint16 oldParty = p_global->party;
|
|
|
|
byte oldBack = p_global->roomBgBankNum;
|
|
|
|
perso_t *oldPerso = p_global->perso_ptr;
|
2016-10-07 23:06:10 +02:00
|
|
|
p_global->party = p_global->tape_ptr->_party;
|
|
|
|
p_global->roomNum = p_global->tape_ptr->_roomNum;
|
|
|
|
p_global->roomBgBankNum = p_global->tape_ptr->_bgBankNum;
|
2016-10-24 22:02:43 +02:00
|
|
|
p_global->_dialogPtr = p_global->tape_ptr->_dialog;
|
2016-10-07 23:06:10 +02:00
|
|
|
p_global->perso_ptr = p_global->tape_ptr->_perso;
|
2016-09-14 23:39:27 +02:00
|
|
|
endpersovox();
|
|
|
|
affcurstape();
|
|
|
|
if (p_global->perso_ptr != oldPerso
|
|
|
|
|| p_global->roomNum != lastTapeRoomNum) {
|
|
|
|
lastTapeRoomNum = p_global->roomNum;
|
2016-11-13 22:59:45 -08:00
|
|
|
p_global->curPersoAnimPtr = nullptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_CA = 0;
|
|
|
|
p_global->perso_img_bank = -1;
|
|
|
|
anim_perfin();
|
|
|
|
load_perso_cour();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
af_fondperso();
|
2016-10-07 23:06:10 +02:00
|
|
|
p_global->textNum = p_global->tape_ptr->_textNum;
|
2016-09-14 23:39:27 +02:00
|
|
|
my_bulle();
|
|
|
|
getdatasync();
|
|
|
|
showpersopanel();
|
|
|
|
persovox();
|
|
|
|
p_global->roomBgBankNum = oldBack;
|
|
|
|
p_global->party = oldParty;
|
|
|
|
p_global->roomNum = oldRoomNum;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::rewindtape() {
|
|
|
|
if (p_global->tape_ptr > tapes) {
|
|
|
|
p_global->tape_ptr--;
|
|
|
|
p_global->menuFlags &= ~MenuFlags::mfFlag8;
|
|
|
|
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() {
|
|
|
|
if (mouse_held) {
|
|
|
|
limitezonecurs(95, 217, 179, 183);
|
2016-10-24 22:02:43 +02:00
|
|
|
int idx = (curs_x - 97);
|
|
|
|
if (idx < 0)
|
|
|
|
idx = 0;
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
idx /= 8;
|
2016-10-24 22:02:43 +02:00
|
|
|
tape_t *tape = tapes + idx;
|
|
|
|
if (tape >= tapes + 16)
|
|
|
|
tape = tapes + 16 - 1;
|
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
if (tape != p_global->tape_ptr) {
|
|
|
|
p_global->tape_ptr = tape;
|
|
|
|
affcurstape();
|
|
|
|
p_global->menuFlags &= ~MenuFlags::mfFlag8;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
p_global->menuFlags &= ~MenuFlags::mfFlag4;
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
void EdenGame::affcurstape() {
|
|
|
|
if (p_global->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);
|
2016-10-24 22:02:43 +02:00
|
|
|
int x = (p_global->tape_ptr - tapes) * 8 + 97;
|
2016-09-14 23:39:27 +02:00
|
|
|
gameIcons[112].sx = x - 3;
|
|
|
|
gameIcons[112].ex = x + 3;
|
|
|
|
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() {
|
|
|
|
if (p_global->tape_ptr < tapes + 16) {
|
|
|
|
p_global->tape_ptr++;
|
|
|
|
p_global->menuFlags &= ~MenuFlags::mfFlag8;
|
|
|
|
affcurstape();
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::stoptape() {
|
|
|
|
if (!(p_global->drawFlags & DrawFlags::drDrawFlag8))
|
2016-08-18 13:15:54 +02:00
|
|
|
return;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->menuFlags &= ~MenuFlags::mfFlag8;
|
|
|
|
p_global->drawFlags &= ~DrawFlags::drDrawFlag8;
|
|
|
|
p_global->menuFlags |= MenuFlags::mfFlag10;
|
|
|
|
p_global->iconsIndex = 85;
|
2016-11-13 22:59:45 -08:00
|
|
|
p_global->perso_ptr = nullptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
lastTapeRoomNum = 0;
|
|
|
|
endpersovox();
|
|
|
|
fin_perso();
|
|
|
|
affpanel();
|
|
|
|
afftoppano();
|
2016-10-25 23:32:15 +02:00
|
|
|
needPaletteUpdate = 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() {
|
|
|
|
p_global->menuFlags |= MenuFlags::mfFlag4;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::paneltobuf() {
|
|
|
|
setRS1(0, 16, 320 - 1, 169 - 1);
|
|
|
|
setRD1(320, 16, 640 - 1, 169 - 1);
|
|
|
|
CLBlitter_CopyViewRect(p_mainview, p_mainview, &rect_src, &rect_dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::cursbuftopanel() {
|
|
|
|
setRS1(434, 40, 525 - 1, 111 - 1);
|
|
|
|
setRD1(114, 40, 205 - 1, 111 - 1);
|
|
|
|
CLBlitter_CopyViewRect(p_mainview, p_mainview, &rect_src, &rect_dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::langbuftopanel() {
|
|
|
|
setRS1(328, 42, 407 - 1, 97 - 1);
|
|
|
|
setRD1(8, 42, 87 - 1, 97 - 1);
|
|
|
|
CLBlitter_CopyViewRect(p_mainview, p_mainview, &rect_src, &rect_dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::affpanel() {
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(65);
|
2016-09-14 23:39:27 +02:00
|
|
|
noclipax(0, 0, 16);
|
|
|
|
paneltobuf();
|
|
|
|
afflangue();
|
|
|
|
affcurseurs();
|
|
|
|
affcurstape();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::afflangue() {
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(65);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->pref_language < 0 //TODO: never happens
|
|
|
|
|| p_global->pref_language > 5)
|
|
|
|
return;
|
|
|
|
noclipax(6, 8, p_global->pref_language * 9 + 43); //TODO: * FONT_HEIGHT
|
|
|
|
noclipax(7, 77, p_global->pref_language * 9 + 44);
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::affcursvol(int16 x, int16 vol1, int16 vol2) {
|
|
|
|
int16 slider = 3;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (lastMenuItemIdLo && (lastMenuItemIdLo & 9) != 1) //TODO check me
|
|
|
|
slider = 4;
|
|
|
|
noclipax(slider, x, 104 - vol1);
|
|
|
|
slider = 3;
|
|
|
|
if ((lastMenuItemIdLo & 9) != 0)
|
|
|
|
slider = 4;
|
|
|
|
noclipax(slider, x + 12, 104 - vol2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::affcurseurs() {
|
2016-10-07 23:06:10 +02:00
|
|
|
useBank(65);
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->drawFlags & DrawFlags::drDrawFlag8)
|
|
|
|
return;
|
|
|
|
curseurselect(48);
|
|
|
|
affcursvol(114, p_global->pref_10C[0] / 4, p_global->pref_10C[1] / 4);
|
|
|
|
curseurselect(50);
|
|
|
|
affcursvol(147, p_global->pref_10E[0] / 4, p_global->pref_10E[1] / 4);
|
|
|
|
curseurselect(52);
|
|
|
|
affcursvol(179, p_global->pref_110[0] / 4, p_global->pref_110[1] / 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::curseurselect(int itemId) {
|
|
|
|
lastMenuItemIdLo = p_global->menuItemIdLo;
|
|
|
|
if ((lastMenuItemIdLo & ~9) != itemId)
|
|
|
|
lastMenuItemIdLo = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::afftoppano() {
|
|
|
|
noclipax(1, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::affresult() {
|
|
|
|
restaurefondbulle();
|
|
|
|
p_global->perso_ptr = &kPersons[19];
|
|
|
|
p_global->dialogType = DialogType::dtInspect;
|
2016-10-24 22:02:43 +02:00
|
|
|
int16 num = (kPersons[19]._id << 3) | p_global->dialogType;
|
2016-10-07 00:45:08 +02:00
|
|
|
if (dialoscansvmas((dial_t *)getElem(gameDialogs, num)))
|
2016-09-14 23:39:27 +02:00
|
|
|
af_subtitle();
|
|
|
|
p_global->ff_CA = 0;
|
|
|
|
p_global->dialogType = DialogType::dtTalk;
|
2016-11-13 22:59:45 -08:00
|
|
|
p_global->perso_ptr = nullptr;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::limitezonecurs(int16 xmin, int16 xmax, int16 ymin, int16 ymax) {
|
2016-10-24 22:32:04 +02:00
|
|
|
curs_x = CLIP(curs_x, xmin, xmax);
|
|
|
|
curs_y = CLIP(curs_y, ymin, ymax);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::PommeQ() {
|
|
|
|
icon_t *icon = &gameIcons[85];
|
2016-09-26 23:44:42 +02:00
|
|
|
if (p_global->displayFlags & DisplayFlags::dfFrescoes) {
|
|
|
|
torchCursor = false;
|
2016-09-28 07:29:12 +02:00
|
|
|
curs_saved = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->displayFlags & DisplayFlags::dfPerson)
|
|
|
|
close_perso();
|
|
|
|
p_global->displayFlags = DisplayFlags::dfFlag1;
|
2016-09-26 23:44:42 +02:00
|
|
|
resetScroll();
|
2016-09-25 23:17:25 +02:00
|
|
|
p_global->ff_100 = 0xFF;
|
2016-08-18 13:15:54 +02:00
|
|
|
maj_salle(p_global->roomNum);
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->displayFlags & DisplayFlags::dfPerson)
|
|
|
|
close_perso();
|
|
|
|
if (p_global->displayFlags & DisplayFlags::dfPanable)
|
2016-09-26 23:44:42 +02:00
|
|
|
resetScroll();
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->displayFlags & DisplayFlags::dfMirror)
|
2016-09-26 23:44:42 +02:00
|
|
|
resetScroll();
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->drawFlags & DrawFlags::drDrawFlag8)
|
|
|
|
stoptape();
|
2016-10-06 00:15:02 +02:00
|
|
|
if (_personTalking)
|
2016-09-14 23:39:27 +02:00
|
|
|
endpersovox();
|
|
|
|
p_global->ff_103 = 0;
|
|
|
|
p_global->ff_102 = 0;
|
|
|
|
putobject();
|
2016-11-13 13:56:20 -08:00
|
|
|
_currCursor = 53;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->displayFlags != DisplayFlags::dfFlag2)
|
|
|
|
gotopanel();
|
|
|
|
current_spot2 = icon + 7; //TODO
|
|
|
|
EdenQuit();
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
|
p_global->room_perso = perso;
|
|
|
|
p_global->roomPersoType = persType;
|
2016-10-07 00:45:08 +02:00
|
|
|
p_global->roomPersoFlags = perso->_flags;
|
|
|
|
p_global->roomPersoItems = perso->_items;
|
|
|
|
p_global->roomPersoPowers = perso->_powers;
|
|
|
|
p_global->partyOutside |= perso->_partyMask;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->roomPersoType == PersonFlags::pftTriceraptor)
|
|
|
|
delinfo(p_global->areaNum + ValleyNews::vnTriceraptorsIn);
|
|
|
|
else if (p_global->roomPersoType == PersonFlags::pftVelociraptor)
|
|
|
|
delinfo(p_global->areaNum + ValleyNews::vnVelociraptorsIn);
|
2016-10-07 00:45:08 +02:00
|
|
|
} else if (!(perso->_flags & PersonFlags::pfInParty))
|
|
|
|
p_global->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)
|
|
|
|
p_global->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) {
|
|
|
|
if (p_global->ff_113)
|
|
|
|
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
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
if (!dialo_even(perso))
|
|
|
|
return;
|
2016-10-24 22:02:43 +02:00
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->ff_113++;
|
|
|
|
p_global->oldDisplayFlags = 1;
|
|
|
|
perso = p_global->perso_ptr;
|
|
|
|
init_perso_ptr(perso);
|
2016-10-07 00:45:08 +02:00
|
|
|
if (!(perso->_partyMask & PersonMask::pmLeader))
|
2016-10-24 22:02:43 +02:00
|
|
|
p_global->ff_60 = true;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->eventType = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
perso->_roomNum = destinationRoom;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::rangermammi(perso_t *perso, room_t *room) {
|
2016-09-26 07:57:27 +02:00
|
|
|
room_t *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;
|
|
|
|
for (; room->ff_0 != 0xFF; room++) {
|
|
|
|
if (room->flags & RoomFlags::rfHasCitadel) {
|
|
|
|
found_room = room;
|
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if (room->party != 0xFFFF && (room->party & PersonMask::pmLeader))
|
|
|
|
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;
|
|
|
|
perso->_roomNum |= found_room->location;
|
|
|
|
perso->_flags &= ~PersonFlags::pfInParty;
|
|
|
|
p_global->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:
|
|
|
|
rangermammi(perso, p_global->last_area_ptr->citadelRoom);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
perso = kPersons;
|
|
|
|
do {
|
2016-10-07 00:45:08 +02:00
|
|
|
if (perso->_roomNum == p_global->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:
|
|
|
|
rangermammi(perso, p_global->last_area_ptr->citadelRoom);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::setpersohere() {
|
2016-10-08 21:21:21 +02:00
|
|
|
debug("setpersohere, perso is %ld", p_global->perso_ptr - kPersons);
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->partyOutside = 0;
|
|
|
|
p_global->party = 0;
|
|
|
|
p_global->room_perso = 0;
|
|
|
|
p_global->roomPersoType = 0;
|
|
|
|
p_global->roomPersoFlags = 0;
|
|
|
|
perso_ici(1);
|
|
|
|
perso_ici(0);
|
|
|
|
if (p_global->roomPersoType == PersonFlags::pftTyrann) delinfo(p_global->areaNum + ValleyNews::vnTyrannIn);
|
|
|
|
if (p_global->roomPersoType == PersonFlags::pftTriceraptor) delinfo(p_global->areaNum + ValleyNews::vnTriceraptorsIn);
|
|
|
|
if (p_global->roomPersoType == PersonFlags::pftVelociraptor) {
|
|
|
|
delinfo(p_global->areaNum + ValleyNews::vnTyrannIn);
|
|
|
|
delinfo(p_global->areaNum + ValleyNews::vnTyrannLost);
|
|
|
|
delinfo(p_global->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) {
|
2016-09-14 23:39:27 +02:00
|
|
|
destinationRoom = roomNum;
|
|
|
|
perso_ici(4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::suis_moi5() {
|
2016-10-08 21:21:21 +02:00
|
|
|
debug("adding person %ld to party", p_global->perso_ptr - kPersons);
|
2016-10-07 00:45:08 +02:00
|
|
|
p_global->perso_ptr->_flags |= PersonFlags::pfInParty;
|
|
|
|
p_global->perso_ptr->_roomNum = p_global->roomNum;
|
|
|
|
p_global->party |= p_global->perso_ptr->_partyMask;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->drawFlags |= DrawFlags::drDrawTopScreen;
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::suis_moi(int16 index) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *old_perso = p_global->perso_ptr;
|
|
|
|
p_global->perso_ptr = &kPersons[index];
|
|
|
|
suis_moi5();
|
|
|
|
p_global->perso_ptr = old_perso;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::reste_ici5() {
|
2016-10-08 21:21:21 +02:00
|
|
|
debug("removing person %ld from party", p_global->perso_ptr - kPersons);
|
2016-10-07 00:45:08 +02:00
|
|
|
p_global->perso_ptr->_flags &= ~PersonFlags::pfInParty;
|
|
|
|
p_global->partyOutside |= p_global->perso_ptr->_partyMask;
|
|
|
|
p_global->party &= ~p_global->perso_ptr->_partyMask;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->drawFlags |= DrawFlags::drDrawTopScreen;
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::reste_ici(int16 index) {
|
2016-09-14 23:39:27 +02:00
|
|
|
perso_t *old_perso = p_global->perso_ptr;
|
|
|
|
p_global->perso_ptr = &kPersons[index];
|
|
|
|
reste_ici5();
|
|
|
|
p_global->perso_ptr = old_perso;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::eloipart() {
|
|
|
|
reste_ici(5);
|
|
|
|
p_global->gameFlags &= ~GameFlags::gfFlag4000;
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MESSAGER]._roomNum = 0;
|
|
|
|
p_global->partyOutside &= ~kPersons[PER_MESSAGER]._partyMask;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->roomNum == 2817)
|
|
|
|
chronoon(3000);
|
|
|
|
p_global->eloiDepartureDay = p_global->gameDays;
|
|
|
|
p_global->eloiHaveNews = 0;
|
|
|
|
unlockinfo();
|
|
|
|
}
|
|
|
|
|
2016-10-07 23:06:10 +02:00
|
|
|
bool EdenGame::eloirevientq() {
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->phaseNum < 304)
|
2016-10-07 23:06:10 +02:00
|
|
|
return true;
|
|
|
|
if ((p_global->phaseNum <= 353) || (p_global->phaseNum == 370) || (p_global->phaseNum == 384))
|
|
|
|
return false;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->areaNum != Areas::arShandovra)
|
2016-10-07 23:06:10 +02:00
|
|
|
return true;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (p_global->phaseNum < 480)
|
2016-10-07 23:06:10 +02:00
|
|
|
return false;
|
|
|
|
return true;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::eloirevient() {
|
2016-10-07 00:45:08 +02:00
|
|
|
if (p_global->area_ptr->type == AreaType::atValley && !kPersons[PER_MESSAGER]._roomNum)
|
|
|
|
kPersons[PER_MESSAGER]._roomNum = (p_global->roomNum & 0xFF00) + 1;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
//// phase.c
|
2016-09-14 23:39:27 +02:00
|
|
|
void EdenGame::incphase1() {
|
|
|
|
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
|
|
|
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->phaseNum++;
|
|
|
|
debug("!!! next phase - %4X , room %4X", p_global->phaseNum, p_global->roomNum);
|
|
|
|
p_global->phaseActionsCount = 0;
|
2016-11-14 14:51:52 -08:00
|
|
|
for (phase_t *phase = phases; phase->_id != -1; phase++) {
|
2016-10-07 00:45:08 +02:00
|
|
|
if (p_global->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::incphase() {
|
|
|
|
incphase1();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase113() {
|
|
|
|
reste_ici(1);
|
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();
|
|
|
|
reste_ici(3);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase161() {
|
|
|
|
area_t *area = p_global->area_ptr;
|
|
|
|
suis_moi(9);
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MAMMI]._flags |= PersonFlags::pf10;
|
2016-09-14 23:39:27 +02:00
|
|
|
area->flags |= AreaFlags::afFlag1;
|
|
|
|
p_global->curAreaFlags |= AreaFlags::afFlag1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase226() {
|
|
|
|
newobject(16, 3);
|
|
|
|
newobject(16, 4);
|
|
|
|
newobject(16, 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase257() {
|
|
|
|
gameIcons[127].cursor_id &= ~0x8000;
|
|
|
|
p_global->persoBackgroundBankIdx = 58;
|
|
|
|
dialautooff();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase353() {
|
|
|
|
reste_ici(1);
|
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() {
|
|
|
|
suis_moi(5);
|
|
|
|
p_global->narratorSequence = 2;
|
|
|
|
gameRooms[334].exits[0] = 134;
|
|
|
|
gameRooms[335].exits[0] = 134;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase371() {
|
|
|
|
eloirevient();
|
|
|
|
gameIcons[128].cursor_id &= ~0x8000;
|
|
|
|
gameIcons[129].cursor_id &= ~0x8000;
|
|
|
|
gameIcons[127].cursor_id |= 0x8000;
|
|
|
|
p_global->persoBackgroundBankIdx = 59;
|
2016-09-26 07:57:27 +02:00
|
|
|
gameRooms[334].exits[0] = 0xFF;
|
|
|
|
gameRooms[335].exits[0] = 0xFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
gameIcons[123].object_id = 9;
|
|
|
|
gameIcons[124].object_id = 26;
|
|
|
|
gameIcons[125].object_id = 42;
|
|
|
|
gameIcons[126].object_id = 56;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase385() {
|
|
|
|
dialautooff();
|
|
|
|
eloirevient();
|
|
|
|
p_global->next_info_idx = 0;
|
|
|
|
p_global->last_info_idx = 0;
|
|
|
|
updateinfolist();
|
|
|
|
p_global->last_info = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase418() {
|
2016-09-26 23:44:42 +02:00
|
|
|
loseObject(Objects::obHorn);
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
|
|
|
suis_moi(4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase433() {
|
|
|
|
dialautoon();
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MAMMI_4]._flags &= ~PersonFlags::pf80;
|
|
|
|
kPersons[PER_BOURREAU]._flags &= ~PersonFlags::pf80;
|
2016-09-14 23:39:27 +02:00
|
|
|
setpersohere();
|
|
|
|
p_global->chrono_on = 0;
|
|
|
|
p_global->chrono = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase434() {
|
|
|
|
p_global->roomNum = 275;
|
|
|
|
gameRooms[16].bank = 44;
|
|
|
|
gameRooms[18].bank = 44;
|
|
|
|
gameIcons[132].cursor_id &= ~0x8000;
|
|
|
|
p_global->persoBackgroundBankIdx = 61;
|
2016-09-26 07:57:27 +02:00
|
|
|
gameRooms[118].exits[2] = 0xFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
abortdial();
|
|
|
|
gameRooms[7].bank = 322;
|
|
|
|
reste_ici(7);
|
|
|
|
reste_ici(3);
|
|
|
|
reste_ici(5);
|
|
|
|
reste_ici(18);
|
|
|
|
reste_ici(4);
|
|
|
|
p_global->drawFlags |= DrawFlags::drDrawTopScreen;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase513() {
|
2016-10-24 00:04:32 +02:00
|
|
|
p_global->last_dialog_ptr = nullptr;
|
|
|
|
parlemoiNormalFlag = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase514() {
|
|
|
|
gameRooms[123].exits[2] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase529() {
|
|
|
|
gameIcons[133].cursor_id &= ~0x8000;
|
|
|
|
p_global->persoBackgroundBankIdx = 63;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase545() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase561() {
|
|
|
|
p_global->narratorSequence = 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2016-10-24 22:32:04 +02:00
|
|
|
int16 phase = (p_global->phaseNum & ~3) + 0x10; //TODO: check me
|
2016-09-14 23:39:27 +02:00
|
|
|
debug("!!! big phase - %4X", phase);
|
|
|
|
p_global->phaseActionsCount = 0;
|
|
|
|
p_global->phaseNum = phase;
|
|
|
|
if (phase > 560)
|
|
|
|
return;
|
|
|
|
phase >>= 4;
|
|
|
|
(this->*bigphases[phase - 1])();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::bigphase() {
|
2016-10-24 22:02:43 +02:00
|
|
|
if (!(p_global->_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() {
|
|
|
|
gameRooms[8].exits[1] = 22;
|
|
|
|
dialautoon();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase64() {
|
|
|
|
suis_moi(1);
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MESSAGER]._roomNum = 259;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase80() {
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_THOO]._roomNum = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase96() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase112() {
|
|
|
|
giveobject();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase128() {
|
|
|
|
suis_moi(1);
|
|
|
|
giveobject();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase144() {
|
|
|
|
suis_moi(5);
|
|
|
|
gameRooms[113].video = 0;
|
|
|
|
gameRooms[113].bank = 317;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase160() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase176() {
|
|
|
|
dialonfollow();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase192() {
|
|
|
|
area_t *area = p_global->area_ptr;
|
|
|
|
suis_moi(10);
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MAMMI_1]._flags |= PersonFlags::pf10;
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
|
|
|
area->flags |= AreaFlags::afFlag1;
|
|
|
|
p_global->curAreaFlags |= AreaFlags::afFlag1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase208() {
|
|
|
|
eloirevient();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase224() {
|
|
|
|
gameIcons[126].cursor_id &= ~0x8000;
|
|
|
|
p_global->persoBackgroundBankIdx = 57;
|
|
|
|
dialautooff();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase240() {
|
|
|
|
area_t *area = p_global->area_ptr;
|
|
|
|
suis_moi(11);
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MAMMI_2]._flags |= PersonFlags::pf10;
|
2016-09-14 23:39:27 +02:00
|
|
|
area->flags |= AreaFlags::afFlag1;
|
|
|
|
p_global->curAreaFlags |= AreaFlags::afFlag1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase256() {
|
|
|
|
dialautoon();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase272() {
|
|
|
|
dialautoon();
|
|
|
|
p_global->eloiHaveNews = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase288() {
|
|
|
|
oui();
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MANGO]._roomNum = 0;
|
2016-09-14 23:39:27 +02:00
|
|
|
reste_ici(6);
|
|
|
|
suis_moi(5);
|
|
|
|
p_global->narratorSequence = 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase304() {
|
|
|
|
area_t *area = p_global->area_ptr;
|
|
|
|
suis_moi(7);
|
|
|
|
suis_moi(14);
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MAMMI_5]._flags |= PersonFlags::pf10;
|
2016-09-14 23:39:27 +02:00
|
|
|
dialautoon();
|
|
|
|
area->flags |= AreaFlags::afFlag1;
|
|
|
|
p_global->curAreaFlags |= AreaFlags::afFlag1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase320() {
|
|
|
|
dialonfollow();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase336() {
|
|
|
|
gameRooms[288].exits[0] = 135;
|
|
|
|
gameRooms[289].exits[0] = 135;
|
2016-09-26 23:44:42 +02:00
|
|
|
loseObject(p_global->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-09-26 07:57:27 +02:00
|
|
|
gameRooms[288].exits[0] = 0xFF;
|
|
|
|
gameRooms[289].exits[0] = 0xFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
gameRooms[288].flags &= ~RoomFlags::rf02;
|
|
|
|
gameRooms[289].flags &= ~RoomFlags::rf02;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase368() {
|
|
|
|
reste_ici(7);
|
|
|
|
dialautoon();
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MESSAGER]._roomNum = 1811;
|
|
|
|
kPersons[PER_DINA]._roomNum = 1607;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase384() {
|
|
|
|
area_t *area = p_global->area_ptr;
|
|
|
|
suis_moi(7);
|
|
|
|
reste_ici(1);
|
|
|
|
dialautoon();
|
|
|
|
area->flags |= AreaFlags::afFlag1;
|
|
|
|
p_global->curAreaFlags |= AreaFlags::afFlag1;
|
|
|
|
eloipart();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase400() {
|
|
|
|
dialonfollow();
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_ROI]._roomNum = 0;
|
|
|
|
kPersons[PER_MONK]._roomNum = 259;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->eloiHaveNews = 0;
|
|
|
|
kObjectLocations[20] = 259;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase416() {
|
|
|
|
suis_moi(3);
|
|
|
|
gameIcons[130].cursor_id &= ~0x8000;
|
|
|
|
p_global->persoBackgroundBankIdx = 60;
|
|
|
|
gameRooms[0].exits[0] = 138;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase432() {
|
|
|
|
p_global->narratorSequence = 3;
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MAMMI_4]._flags |= PersonFlags::pf80;
|
|
|
|
kPersons[PER_BOURREAU]._flags |= PersonFlags::pf80;
|
|
|
|
kPersons[PER_MESSAGER]._roomNum = 257;
|
2016-09-26 07:57:27 +02:00
|
|
|
gameRooms[0].exits[0] = 0xFF;
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->drawFlags |= DrawFlags::drDrawTopScreen;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase448() {
|
|
|
|
dialautoon();
|
|
|
|
eloipart();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase464() {
|
|
|
|
p_global->area_ptr->flags |= AreaFlags::afFlag1;
|
|
|
|
p_global->curAreaFlags |= AreaFlags::afFlag1;
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MAMMI_6]._flags |= PersonFlags::pf10;
|
2016-09-14 23:39:27 +02:00
|
|
|
suis_moi(8);
|
|
|
|
p_global->cita_area_num = p_global->areaNum;
|
|
|
|
naitredino(8);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase480() {
|
|
|
|
giveobject();
|
|
|
|
newvallee();
|
|
|
|
eloirevient();
|
|
|
|
kTabletView[1] = 94;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase496() {
|
|
|
|
dialautoon();
|
2016-10-24 00:04:32 +02:00
|
|
|
p_global->last_dialog_ptr = nullptr;
|
|
|
|
parlemoiNormalFlag = false;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase512() {
|
|
|
|
reste_ici(3);
|
|
|
|
reste_ici(7);
|
|
|
|
reste_ici(8);
|
|
|
|
reste_ici(18);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase528() {
|
|
|
|
p_global->narratorSequence = 11;
|
|
|
|
suis_moi(3);
|
|
|
|
suis_moi(5);
|
|
|
|
suis_moi(7);
|
|
|
|
suis_moi(8);
|
|
|
|
suis_moi(18);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase544() {
|
|
|
|
eloipart();
|
|
|
|
dialautoon();
|
|
|
|
reste_ici(8);
|
|
|
|
reste_ici(18);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::phase560() {
|
2016-10-07 00:45:08 +02:00
|
|
|
kPersons[PER_MESSAGER]._roomNum = 3073;
|
2016-09-14 23:39:27 +02:00
|
|
|
gameRooms[127].exits[1] = 0;
|
|
|
|
}
|
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;
|
|
|
|
// file_t 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();
|
|
|
|
size = (char *)(&p_global->save_end) - (char *)(p_global);
|
|
|
|
CLFile_Write(handle, p_global, &size);
|
|
|
|
size = (char *)(&gameIcons[134]) - (char *)(&gameIcons[123]);
|
|
|
|
CLFile_Write(handle, &gameIcons[123], &size);
|
|
|
|
lieuoffsetout();
|
|
|
|
size = (char *)(&kAreasTable[12]) - (char *)(&kAreasTable[0]);
|
|
|
|
CLFile_Write(handle, &kAreasTable[0], &size);
|
|
|
|
size = (char *)(&gameRooms[423]) - (char *)(&gameRooms[0]);
|
|
|
|
CLFile_Write(handle, &gameRooms[0], &size);
|
|
|
|
size = (char *)(&objects[42]) - (char *)(&objects[0]);
|
|
|
|
CLFile_Write(handle, &objects[0], &size);
|
|
|
|
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-09-14 23:39:27 +02:00
|
|
|
size = (char *)(&kPersons[55]) - (char *)(&kPersons[0]);
|
|
|
|
CLFile_Write(handle, &kPersons[0], &size);
|
|
|
|
bandeoffsetout();
|
|
|
|
size = (char *)(&tapes[16]) - (char *)(&tapes[0]);
|
|
|
|
CLFile_Write(handle, &tapes[0], &size);
|
|
|
|
size = (char *)(&kTabletView[6]) - (char *)(&kTabletView[0]);
|
|
|
|
CLFile_Write(handle, &kTabletView[0], &size);
|
|
|
|
size = (char *)(&gameDialogs[10240]) - (char *)(&gameDialogs[0]); //TODO: const size 10240
|
|
|
|
CLFile_Write(handle, &gameDialogs[0], &size);
|
|
|
|
|
|
|
|
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;
|
2016-09-14 23:39:27 +02:00
|
|
|
size = (char *)(&p_global->save_end) - (char *)(p_global);
|
|
|
|
loadpartoffile(2495, p_global, offs, size);
|
|
|
|
offs += size;
|
|
|
|
vavaoffsetin();
|
|
|
|
size = (char *)(&gameIcons[134]) - (char *)(&gameIcons[123]);
|
|
|
|
loadpartoffile(2495, &gameIcons[123], offs, size);
|
|
|
|
offs += size;
|
|
|
|
size = (char *)(&kAreasTable[12]) - (char *)(&kAreasTable[0]);
|
|
|
|
loadpartoffile(2495, &kAreasTable[0], offs, size);
|
|
|
|
offs += size;
|
|
|
|
lieuoffsetin();
|
|
|
|
size = (char *)(&gameRooms[423]) - (char *)(&gameRooms[0]);
|
|
|
|
loadpartoffile(2495, &gameRooms[0], offs, size);
|
|
|
|
offs += size;
|
|
|
|
size = (char *)(&objects[42]) - (char *)(&objects[0]);
|
|
|
|
loadpartoffile(2495, &objects[0], offs, size);
|
|
|
|
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;
|
|
|
|
size = (char *)(&kPersons[55]) - (char *)(&kPersons[0]);
|
|
|
|
loadpartoffile(2495, &kPersons[0], offs, size);
|
|
|
|
offs += size;
|
|
|
|
size = (char *)(&tapes[16]) - (char *)(&tapes[0]);
|
|
|
|
loadpartoffile(2495, &tapes[0], offs, size);
|
|
|
|
offs += size;
|
|
|
|
bandeoffsetin();
|
|
|
|
size = (char *)(&kTabletView[6]) - (char *)(&kTabletView[0]);
|
|
|
|
loadpartoffile(2495, &kTabletView[0], offs, size);
|
|
|
|
offs += size;
|
|
|
|
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;
|
|
|
|
// file_t handle;
|
|
|
|
// 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);
|
|
|
|
|
2016-10-24 22:32:04 +02:00
|
|
|
int32 size = (char *)(&p_global->save_end) - (char *)(p_global);
|
2016-09-14 23:39:27 +02:00
|
|
|
CLFile_Read(handle, p_global, &size);
|
|
|
|
vavaoffsetin();
|
|
|
|
size = (char *)(&gameIcons[134]) - (char *)(&gameIcons[123]);
|
|
|
|
CLFile_Read(handle, &gameIcons[123], &size);
|
|
|
|
size = (char *)(&kAreasTable[12]) - (char *)(&kAreasTable[0]);
|
|
|
|
CLFile_Read(handle, &kAreasTable[0], &size);
|
|
|
|
lieuoffsetin();
|
|
|
|
size = (char *)(&gameRooms[423]) - (char *)(&gameRooms[0]);
|
|
|
|
CLFile_Read(handle, &gameRooms[0], &size);
|
|
|
|
size = (char *)(&objects[42]) - (char *)(&objects[0]);
|
|
|
|
CLFile_Read(handle, &objects[0], &size);
|
|
|
|
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);
|
|
|
|
size = (char *)(&tapes[16]) - (char *)(&tapes[0]);
|
|
|
|
CLFile_Read(handle, &tapes[0], &size);
|
|
|
|
bandeoffsetin();
|
|
|
|
size = (char *)(&kTabletView[6]) - (char *)(&kTabletView[0]);
|
|
|
|
CLFile_Read(handle, &kTabletView[0], &size);
|
|
|
|
size = (char *)(&gameDialogs[10240]) - (char *)(&gameDialogs[0]); //TODO: const size 10240
|
|
|
|
CLFile_Read(handle, &gameDialogs[0], &size);
|
|
|
|
|
|
|
|
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() {
|
2016-10-24 22:02:43 +02:00
|
|
|
OFSOUT(p_global->_dialogPtr, gameDialogs, dial_t);
|
2016-11-13 13:56:20 -08:00
|
|
|
OFSOUT(p_global->_nextDialogPtr, gameDialogs, dial_t);
|
2016-09-14 23:39:27 +02:00
|
|
|
OFSOUT(p_global->narrator_dialog_ptr, gameDialogs, dial_t);
|
|
|
|
OFSOUT(p_global->last_dialog_ptr, gameDialogs, dial_t);
|
|
|
|
OFSOUT(p_global->tape_ptr, tapes, tape_t);
|
|
|
|
OFSOUT(p_global->nextRoomIcon, gameIcons, icon_t);
|
|
|
|
OFSOUT(p_global->room_ptr, gameRooms, room_t);
|
|
|
|
OFSOUT(p_global->cita_area_firstRoom, gameRooms, room_t);
|
|
|
|
OFSOUT(p_global->area_ptr, kAreasTable, area_t);
|
|
|
|
OFSOUT(p_global->last_area_ptr, kAreasTable, area_t);
|
|
|
|
OFSOUT(p_global->cur_area_ptr, kAreasTable, area_t);
|
|
|
|
OFSOUT(p_global->perso_ptr, kPersons, perso_t);
|
|
|
|
OFSOUT(p_global->room_perso, kPersons, perso_t);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::vavaoffsetin() {
|
2016-10-24 22:02:43 +02:00
|
|
|
OFSIN(p_global->_dialogPtr, gameDialogs, dial_t);
|
2016-11-13 13:56:20 -08:00
|
|
|
OFSIN(p_global->_nextDialogPtr, gameDialogs, dial_t);
|
2016-09-14 23:39:27 +02:00
|
|
|
OFSIN(p_global->narrator_dialog_ptr, gameDialogs, dial_t);
|
|
|
|
OFSIN(p_global->last_dialog_ptr, gameDialogs, dial_t);
|
|
|
|
OFSIN(p_global->tape_ptr, tapes, tape_t);
|
|
|
|
OFSIN(p_global->nextRoomIcon, gameIcons, icon_t);
|
|
|
|
OFSIN(p_global->room_ptr, gameRooms, room_t);
|
|
|
|
OFSIN(p_global->cita_area_firstRoom, gameRooms, room_t);
|
|
|
|
OFSIN(p_global->area_ptr, kAreasTable, area_t);
|
|
|
|
OFSIN(p_global->last_area_ptr, kAreasTable, area_t);
|
|
|
|
OFSIN(p_global->cur_area_ptr, kAreasTable, area_t);
|
|
|
|
OFSIN(p_global->perso_ptr, kPersons, perso_t);
|
|
|
|
OFSIN(p_global->room_perso, kPersons, perso_t);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::lieuoffsetout() {
|
2016-10-24 22:02:43 +02:00
|
|
|
for (int i = 0; i < 12; i++)
|
2016-09-14 23:39:27 +02:00
|
|
|
OFSOUT(kAreasTable[i].citadelRoom, gameRooms, room_t);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::lieuoffsetin() {
|
2016-10-24 22:02:43 +02:00
|
|
|
for (int i = 0; i < 12; i++)
|
2016-09-14 23:39:27 +02:00
|
|
|
OFSIN(kAreasTable[i].citadelRoom, gameRooms, room_t);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::bandeoffsetout() {
|
2016-10-24 22:02:43 +02:00
|
|
|
for (int i = 0; i < 16; i++) {
|
2016-10-07 23:06:10 +02:00
|
|
|
OFSOUT(tapes[i]._perso, kPersons, perso_t);
|
|
|
|
OFSOUT(tapes[i]._dialog, gameDialogs, dial_t);
|
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++) {
|
2016-10-07 23:06:10 +02:00
|
|
|
OFSIN(tapes[i]._perso, kPersons, perso_t);
|
|
|
|
OFSIN(tapes[i]._dialog, gameDialogs, dial_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
|
|
|
//// cond.c
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
byte *code_ptr;
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
char EdenGame::testcondition(int16 index) {
|
2016-09-14 23:39:27 +02:00
|
|
|
char end = 0;
|
2016-09-14 23:48:01 +02:00
|
|
|
byte op;
|
|
|
|
uint16 value, value2;
|
|
|
|
uint16 stack[32], *sp = stack, *sp2;
|
2016-09-14 23:39:27 +02:00
|
|
|
assert(index > 0);
|
2016-10-07 00:45:08 +02:00
|
|
|
code_ptr = (byte *)getElem(gameConditions, (index - 1));
|
2016-09-14 23:39:27 +02:00
|
|
|
do {
|
|
|
|
value = cher_valeur();
|
|
|
|
for (;;) {
|
|
|
|
op = *code_ptr++;
|
|
|
|
if (op == 0xFF) {
|
|
|
|
end = 1;
|
|
|
|
break;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
if ((op & 0x80) == 0) {
|
|
|
|
value2 = cher_valeur();
|
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-09-14 23:39:27 +02:00
|
|
|
} while (!end);
|
|
|
|
|
|
|
|
if (sp != stack) {
|
|
|
|
*sp++ = value;
|
|
|
|
sp2 = stack;
|
|
|
|
value = *sp2++;
|
|
|
|
do {
|
|
|
|
op = *sp2++;
|
|
|
|
value2 = *sp2++;
|
|
|
|
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-09-14 23:48:01 +02:00
|
|
|
uint16 EdenGame::opera_add(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 + v2;
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 EdenGame::opera_sub(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 - v2;
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 EdenGame::opera_and(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 & v2;
|
|
|
|
}
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 EdenGame::opera_or(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 | v2;
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 EdenGame::opera_egal(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 == v2 ? -1 : 0;
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 EdenGame::opera_petit(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 < v2 ? -1 : 0; //TODO: all comparisons are unsigned!
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 EdenGame::opera_grand(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 > v2 ? -1 : 0;
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 EdenGame::opera_diff(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 != v2 ? -1 : 0;
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 EdenGame::opera_petega(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 <= v2 ? -1 : 0;
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 EdenGame::opera_graega(uint16 v1, uint16 v2) {
|
2016-09-14 23:39:27 +02:00
|
|
|
return v1 >= v2 ? -1 : 0;
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 EdenGame::opera_faux(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-09-14 23:39:27 +02:00
|
|
|
&EdenGame::opera_egal,
|
|
|
|
&EdenGame::opera_petit,
|
|
|
|
&EdenGame::opera_grand,
|
|
|
|
&EdenGame::opera_diff,
|
|
|
|
&EdenGame::opera_petega,
|
|
|
|
&EdenGame::opera_graega,
|
|
|
|
&EdenGame::opera_add,
|
|
|
|
&EdenGame::opera_sub,
|
|
|
|
&EdenGame::opera_and,
|
|
|
|
&EdenGame::opera_or,
|
|
|
|
&EdenGame::opera_faux,
|
|
|
|
&EdenGame::opera_faux,
|
|
|
|
&EdenGame::opera_faux,
|
|
|
|
&EdenGame::opera_faux,
|
|
|
|
&EdenGame::opera_faux,
|
|
|
|
&EdenGame::opera_faux
|
|
|
|
};
|
|
|
|
return (this->*operations[(op & 0x1F) >> 1])(v1, v2);
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 EdenGame::cher_valeur() {
|
|
|
|
uint16 val;
|
|
|
|
byte typ = *code_ptr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (typ < 0x80) {
|
2016-09-14 23:48:01 +02:00
|
|
|
byte ofs = *code_ptr++;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (typ == 1)
|
2016-09-14 23:48:01 +02:00
|
|
|
val = *(byte *)(ofs + (byte *)p_global);
|
2016-09-14 23:39:27 +02:00
|
|
|
else
|
2016-09-14 23:48:01 +02:00
|
|
|
val = *(uint16 *)(ofs + (byte *)p_global);
|
2016-09-14 23:39:27 +02:00
|
|
|
} else if (typ == 0x80)
|
|
|
|
val = *code_ptr++;
|
|
|
|
else {
|
|
|
|
val = PLE16(code_ptr);
|
|
|
|
code_ptr += 2;
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::ret() {
|
|
|
|
}
|
|
|
|
|
2016-08-18 13:15:54 +02:00
|
|
|
//// cube.c
|
2016-09-14 23:39:27 +02:00
|
|
|
void EdenGame::make_tabcos() {
|
2016-10-08 21:26:22 +02:00
|
|
|
for (int i = 0; i < 361; i++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
tabcos[i * 2] = (int)(cos(3.1416 * i / 180.0) * 255.0);
|
|
|
|
tabcos[i * 2 + 1] = (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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::make_matrice_fix() {
|
2016-11-13 13:56:20 -08:00
|
|
|
int16 r30 = word_3244C;
|
|
|
|
int16 r28 = word_3244A;
|
|
|
|
int16 r29 = word_32448;
|
2016-09-14 23:39:27 +02:00
|
|
|
|
|
|
|
dword_32424 = (tabcos[r29 * 2] * tabcos[r28 * 2]) >> 8;
|
|
|
|
dword_32430 = (tabcos[r29 * 2 + 1] * tabcos[r28 * 2]) >> 8;
|
|
|
|
dword_3243C = -tabcos[r28 * 2 + 1];
|
|
|
|
dword_32428 = ((-tabcos[r29 * 2 + 1] * tabcos[r30 * 2]) >> 8)
|
|
|
|
+ ((tabcos[r30 * 2 + 1] * ((tabcos[r29 * 2] * tabcos[r28 * 2 + 1]) >> 8)) >> 8);
|
|
|
|
dword_32434 = ((tabcos[r29 * 2] * tabcos[r30 * 2]) >> 8)
|
|
|
|
+ ((tabcos[r30 * 2 + 1] * ((tabcos[r29 * 2 + 1] * tabcos[r28 * 2 + 1]) >> 8)) >> 8);
|
|
|
|
dword_32440 = (tabcos[r28 * 2] * tabcos[r30 * 2 + 1]) >> 8;
|
|
|
|
dword_3242C = ((tabcos[r29 * 2 + 1] * tabcos[r30 * 2 + 1]) >> 8)
|
|
|
|
+ ((tabcos[r30 * 2] * ((tabcos[r29 * 2] * tabcos[r28 * 2 + 1]) >> 8)) >> 8);
|
|
|
|
dword_32438 = ((-tabcos[r29 * 2] * tabcos[r30 * 2 + 1]) >> 8)
|
|
|
|
+ ((tabcos[r30 * 2] * ((tabcos[r29 * 2 + 1] * tabcos[r28 * 2 + 1]) >> 8)) >> 8);
|
|
|
|
dword_32444 = (tabcos[r28 * 2] * tabcos[r30 * 2]) >> 8;
|
|
|
|
}
|
|
|
|
|
2016-10-08 21:21:21 +02:00
|
|
|
void EdenGame::projection_fix(cube_t *cubep, int n) {
|
2016-10-08 21:26:22 +02:00
|
|
|
for (int i = 0; i < n; i++) {
|
2016-11-14 14:51:52 -08:00
|
|
|
int r28 = cubep->vertices[i * 4];
|
|
|
|
int r27 = cubep->vertices[i * 4 + 1];
|
|
|
|
int r26 = cubep->vertices[i * 4 + 2];
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-11-14 14:51:52 -08:00
|
|
|
int r25 = dword_32424 * r28 + dword_32428 * r27 + dword_3242C * r26 + (int)(flt_32454 * 256.0f);
|
|
|
|
int r24 = dword_32430 * r28 + dword_32434 * r27 + dword_32438 * r26 + (int)(flt_32450 * 256.0f);
|
|
|
|
int r29 = dword_3243C * r28 + dword_32440 * r27 + dword_32444 * r26 + (int)(flt_2DF7C * 256.0f);
|
2016-09-14 23:39:27 +02:00
|
|
|
|
|
|
|
r29 >>= 8;
|
|
|
|
if (r29 == -256)
|
|
|
|
r29++;
|
2016-10-08 21:21:21 +02:00
|
|
|
cubep->projection[i * 4 ] = r25 / (r29 + 256) + curs_x + 14 + _scrollPos;
|
|
|
|
cubep->projection[i * 4 + 1] = r24 / (r29 + 256) + curs_y + 14;
|
|
|
|
cubep->projection[i * 4 + 2] = r29;
|
2016-08-18 13:15:54 +02:00
|
|
|
|
|
|
|
// assert(cube->projection[i * 4] < 640);
|
|
|
|
// assert(cube->projection[i * 4 + 1] < 200);
|
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-10-25 23:32:15 +02:00
|
|
|
// Original name init_cube
|
|
|
|
void EdenGame::initCubeMac() {
|
2016-09-14 23:39:27 +02:00
|
|
|
NEWcharge_map(2493, cube_texture);
|
|
|
|
NEWcharge_objet_mob(&cube, 2494, cube_texture);
|
|
|
|
make_tabcos();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::moteur() {
|
|
|
|
Eden_dep_and_rot();
|
|
|
|
make_matrice_fix();
|
|
|
|
projection_fix(&cube, cube_faces);
|
|
|
|
affiche_objet(&cube);
|
|
|
|
}
|
|
|
|
|
2016-10-08 21:21:21 +02:00
|
|
|
void EdenGame::affiche_objet(cube_t *cubep) {
|
|
|
|
for (int i = 0; i < cubep->num; i++)
|
|
|
|
affiche_polygone_mapping(cubep, cubep->faces[i]);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 23:48:01 +02:00
|
|
|
void EdenGame::NEWcharge_map(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;
|
|
|
|
CLPalette_SetRGBColor(global_palette, i, &color);
|
|
|
|
}
|
|
|
|
CLPalette_Send2Screen(global_palette, 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
|
|
|
}
|
|
|
|
|
2016-10-08 21:21:21 +02:00
|
|
|
void EdenGame::NEWcharge_objet_mob(cube_t *cubep, int file_id, byte *texptr) {
|
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-10-17 03:05:37 +03:00
|
|
|
loadpartoffile(file_id, tmp1, 0, 454);
|
|
|
|
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;
|
2016-09-14 23:39:27 +02:00
|
|
|
cube_faces = next_val(&next, &error);
|
2016-11-14 14:51:52 -08:00
|
|
|
int16 *vertices = (int16 *)malloc(cube_faces * 4 * sizeof(*vertices));
|
|
|
|
int16 *projection = (int16 *)malloc(cube_faces * 4 * sizeof(*projection));
|
2016-10-08 21:26:22 +02:00
|
|
|
for (int i = 0; i < cube_faces; i++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
vertices[i * 4] = next_val(&next, &error);
|
|
|
|
vertices[i * 4 + 1] = next_val(&next, &error);
|
|
|
|
vertices[i * 4 + 2] = next_val(&next, &error);
|
|
|
|
}
|
2016-10-08 21:26:22 +02:00
|
|
|
int count2 = next_val(&next, &error);
|
2016-11-14 14:51:52 -08:00
|
|
|
cubeface_t **tmp4 = (cubeface_t **)malloc(count2 * sizeof(*tmp4));
|
2016-10-08 21:26:22 +02:00
|
|
|
for (int i = 0; i < count2; i++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
char textured;
|
|
|
|
tmp4[i] = (cubeface_t *)malloc(sizeof(cubeface_t));
|
|
|
|
tmp4[i]->tri = 3;
|
|
|
|
textured = next_val(&next, &error);
|
|
|
|
tmp4[i]->ff_5 = next_val(&next, &error);
|
2016-09-14 23:48:01 +02: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++) {
|
2016-09-14 23:39:27 +02:00
|
|
|
tmp4[i]->indices[j] = next_val(&next, &error);
|
2016-08-18 13:15:54 +02:00
|
|
|
if (textured) {
|
2016-09-14 23:39:27 +02:00
|
|
|
tmp4[i]->uv[j * 2] = next_val(&next, &error);
|
|
|
|
tmp4[i]->uv[j * 2 + 1] = next_val(&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;
|
|
|
|
tmp4[i]->texptr = texptr;
|
|
|
|
} else
|
|
|
|
tmp4[i]->ff_4 = 0;
|
2016-08-18 13:15:54 +02:00
|
|
|
}
|
2016-09-14 23:39:27 +02:00
|
|
|
free(tmp1);
|
2016-10-08 21:21:21 +02:00
|
|
|
cubep->num = count2;
|
|
|
|
cubep->faces = tmp4;
|
|
|
|
cubep->projection = projection;
|
|
|
|
cubep->vertices = vertices;
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int EdenGame::next_val(char **ptr, char *error) {
|
|
|
|
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-09-14 23:48:01 +02:00
|
|
|
void EdenGame::selectmap(int16 num) {
|
2016-09-14 23:39:27 +02:00
|
|
|
curs_cur_map = num;
|
2016-11-14 14:51:52 -08:00
|
|
|
int16 k = 0;
|
|
|
|
int mode = tab_2E138[num];
|
|
|
|
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++) {
|
2016-11-16 14:42:19 -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;
|
2016-09-14 23:39:27 +02:00
|
|
|
if (normalCursor && (p_global->drawFlags & DrawFlags::drDrawFlag20))
|
|
|
|
curs = 10;
|
|
|
|
selectmap(curs);
|
|
|
|
curs_new_tick = TickCount();
|
|
|
|
if (curs_new_tick - curs_old_tick < 1)
|
|
|
|
return;
|
|
|
|
curs_old_tick = curs_new_tick;
|
2016-11-13 13:56:20 -08:00
|
|
|
switch (_currCursor) {
|
2016-09-14 23:39:27 +02:00
|
|
|
case 0:
|
|
|
|
word_3244C = (word_3244C + 2) % 360;
|
|
|
|
word_3244A = (word_3244A + 2) % 360;
|
|
|
|
restoreZDEP();
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
word_3244C = 0;
|
|
|
|
word_3244A -= 2;
|
|
|
|
if (word_3244A < 0)
|
|
|
|
word_3244A += 360;
|
|
|
|
restoreZDEP();
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
word_3244C = (word_3244C + 2) % 360;
|
|
|
|
word_3244A = 0;
|
|
|
|
restoreZDEP();
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
word_3244C -= 2;
|
|
|
|
if (word_3244C < 0)
|
|
|
|
word_3244C += 360;
|
|
|
|
word_3244A = 0;
|
|
|
|
restoreZDEP();
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
word_3244C = 0;
|
|
|
|
word_3244A = (word_3244A + 2) % 360;
|
|
|
|
restoreZDEP();
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
word_3244C = 0;
|
|
|
|
word_3244A = 0;
|
|
|
|
flt_2DF7C += flt_2DF84;
|
|
|
|
if ((flt_2DF7C < -3600.0 + flt_2DF80) || flt_2DF7C > flt_2DF80)
|
|
|
|
flt_2DF84 = -flt_2DF84;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
word_3244C = 0;
|
|
|
|
word_3244A = 0;
|
|
|
|
flt_2DF7C = flt_2DF80;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
word_3244C -= 2;
|
|
|
|
if (word_3244C < 0)
|
|
|
|
word_3244C += 360;
|
|
|
|
word_3244A = 0;
|
|
|
|
restoreZDEP();
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
word_3244C = 0;
|
|
|
|
word_3244A = 0;
|
|
|
|
flt_2DF7C = flt_2DF80;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
word_3244C = 0;
|
|
|
|
word_3244A = 0;
|
|
|
|
flt_2DF7C = flt_2DF80;
|
|
|
|
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;
|
|
|
|
if (flt_2DF7C < flt_2DF80)
|
|
|
|
flt_2DF7C += flt_2DF84;
|
|
|
|
if (flt_2DF7C > flt_2DF80)
|
|
|
|
flt_2DF7C -= flt_2DF84;
|
|
|
|
}
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-10-08 21:21:21 +02:00
|
|
|
void EdenGame::affiche_polygone_mapping(cube_t *cubep, cubeface_t *face) {
|
2016-09-14 23:48:01 +02:00
|
|
|
uint16 *indices = face->indices;
|
2016-11-14 22:07:39 -08:00
|
|
|
int idx = indices[0] * 4;
|
|
|
|
int16 v46 = cubep->projection[idx];
|
|
|
|
int16 v48 = cubep->projection[idx + 1];
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-11-14 22:07:39 -08:00
|
|
|
idx = indices[1] * 4;
|
|
|
|
int16 v4A = cubep->projection[idx];
|
|
|
|
int16 v4C = cubep->projection[idx + 1];
|
2016-09-14 23:39:27 +02:00
|
|
|
|
2016-11-14 22:07:39 -08:00
|
|
|
idx = indices[2] * 4;
|
|
|
|
int16 v4E = cubep->projection[idx];
|
|
|
|
int16 v50 = cubep->projection[idx + 1];
|
2016-09-14 23:39:27 +02:00
|
|
|
|
|
|
|
if ((v4C - v48) * (v4E - v46) - (v50 - v48) * (v4A - v46) > 0)
|
|
|
|
return;
|
2016-08-18 13:15:54 +02:00
|
|
|
|
2016-11-14 22:07:39 -08:00
|
|
|
int16 *uv = face->uv;
|
|
|
|
int16 ymin = 200; // min y
|
|
|
|
int16 ymax = 0; // max y
|
|
|
|
idx = indices[0] * 4;
|
|
|
|
int16 r20 = cubep->projection[idx];
|
|
|
|
int16 r30 = cubep->projection[idx + 1];
|
|
|
|
int16 r19 = *uv++;
|
|
|
|
int16 r18 = *uv++;
|
2016-09-14 23:39:27 +02:00
|
|
|
indices++;
|
2016-11-14 22:07:39 -08:00
|
|
|
for (int r17 = 0; r17 < face->tri - 1; r17++, indices++) {
|
|
|
|
idx = indices[0] * 4;
|
|
|
|
int16 r26 = cubep->projection[idx];
|
|
|
|
int16 r31 = cubep->projection[idx + 1];
|
|
|
|
uint16 r25 = *uv++; //TODO: unsigned
|
|
|
|
int16 r24 = *uv++; //TODO: unsigned
|
2016-08-18 13:15:54 +02:00
|
|
|
if (r30 < ymin)
|
|
|
|
ymin = r30;
|
|
|
|
if (r30 > ymax)
|
|
|
|
ymax = r30;
|
|
|
|
if (r31 < ymin)
|
|
|
|
ymin = r31;
|
|
|
|
if (r31 > ymax)
|
|
|
|
ymax = r31;
|
2016-11-15 09:39:49 +01:00
|
|
|
trace_ligne_mapping(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;
|
|
|
|
}
|
2016-11-14 22:07:39 -08:00
|
|
|
idx = face->indices[0] * 4;
|
|
|
|
int16 r26 = cubep->projection[idx];
|
|
|
|
int16 r31 = cubep->projection[idx + 1];
|
2016-09-14 23:39:27 +02:00
|
|
|
uv = face->uv;
|
2016-11-14 22:07:39 -08:00
|
|
|
uint16 r25 = *uv++; //TODO: this is unsigned
|
|
|
|
int16 r24 = *uv; //TODO: this is signed
|
2016-09-14 23:39:27 +02:00
|
|
|
if (r30 < ymin)
|
|
|
|
ymin = r30;
|
|
|
|
if (r30 > ymax)
|
|
|
|
ymax = r30;
|
|
|
|
if (r31 < ymin)
|
|
|
|
ymin = r31;
|
|
|
|
if (r31 > ymax)
|
|
|
|
ymax = r31;
|
2016-11-15 09:39:49 +01:00
|
|
|
trace_ligne_mapping(r20, r30, r26, r31, r19, r18, r25, r24, _lines);
|
2016-09-29 07:43:13 +02:00
|
|
|
affiche_ligne_mapping(ymin, ymax, p_mainview->_bufferPtr, face->texptr);
|
2016-09-14 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2016-10-08 21:21:21 +02:00
|
|
|
void EdenGame::trace_ligne_mapping(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-09-14 23:48:01 +02:00
|
|
|
void EdenGame::affiche_ligne_mapping(int16 r3, int16 r4, byte *target, byte *texture) {
|
|
|
|
int16 height = r4 - r3;
|
2016-11-14 22:07:39 -08:00
|
|
|
byte *trg_line = p_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
|
|
|
|
cubeCursor pc_cursors[9] = {
|
|
|
|
{ { 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 }
|
|
|
|
};
|
|
|
|
|
|
|
|
XYZ pc_cube[6][3] = {
|
|
|
|
{ { -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 } }
|
|
|
|
};
|
|
|
|
|
|
|
|
signed short cosine[] = {
|
|
|
|
// = 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
|
|
|
|
};
|
|
|
|
|
|
|
|
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++)
|
2016-10-17 03:05:37 +03:00
|
|
|
tab3[i][j + 35] = (cosine[i] * j) >> 7;
|
2016-11-14 22:07:39 -08:00
|
|
|
}
|
2016-10-17 03:05:37 +03: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EdenGame::RotatePoint(XYZ *point, XYZ *rpoint) {
|
|
|
|
// see http://www.cprogramming.com/tutorial/3d/rotation.html
|
|
|
|
XYZ xrot;
|
|
|
|
|
|
|
|
xrot.x = point->x;
|
|
|
|
xrot.y = cos_x[point->y] + sin_x[point->z];
|
|
|
|
xrot.z = sin_x[-point->y] + cos_x[point->z];
|
|
|
|
|
|
|
|
rpoint->x = cos_y[xrot.x] + sin_y[-xrot.z];
|
|
|
|
rpoint->y = xrot.y;
|
|
|
|
rpoint->z = sin_y[xrot.x] + cos_y[xrot.z];
|
|
|
|
|
|
|
|
rpoint->z += zoom;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::MapPoint(XYZ *point, short *x, short *y) {
|
|
|
|
*y = ((12800 / point->z) * point->y) >> 7;
|
|
|
|
*x = ((12800 / point->z) * point->x) >> 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
short EdenGame::CalcFaceArea(XYZ *face) {
|
|
|
|
XYZ rpoint;
|
|
|
|
short x[3], y[3];
|
|
|
|
|
2016-11-14 22:07:39 -08:00
|
|
|
for (int i = 0; i < 3; i++) {
|
2016-10-17 03:05:37 +03:00
|
|
|
RotatePoint(&face[i], &rpoint);
|
|
|
|
MapPoint(&rpoint, &x[i], &y[i]);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::PaintPixel(XYZ *point, unsigned char pixel) {
|
|
|
|
short x, y;
|
|
|
|
MapPoint(point, &x, &y);
|
|
|
|
cursorcenter[y * 40 + x] = pixel;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::PaintFace0(XYZ *point) {
|
|
|
|
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;
|
|
|
|
RotatePoint(point, &rpoint);
|
2016-11-15 09:39:49 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::PaintFace1(XYZ *point) {
|
|
|
|
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;
|
|
|
|
RotatePoint(point, &rpoint);
|
2016-11-15 09:39:49 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::PaintFace2(XYZ *point) {
|
|
|
|
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;
|
|
|
|
RotatePoint(point, &rpoint);
|
2016-11-15 09:39:49 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::PaintFace3(XYZ *point) {
|
|
|
|
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;
|
|
|
|
RotatePoint(point, &rpoint);
|
2016-11-15 09:39:49 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::PaintFace4(XYZ *point) {
|
|
|
|
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;
|
|
|
|
RotatePoint(point, &rpoint);
|
2016-11-15 09:39:49 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::PaintFace5(XYZ *point) {
|
|
|
|
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-10-17 03:05:37 +03:00
|
|
|
RotatePoint(point, &rpoint);
|
2016-11-15 09:39:49 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::PaintFaces() {
|
|
|
|
XYZ point;
|
|
|
|
if (!(faceskip & 1)) {
|
|
|
|
point.z = -15;
|
|
|
|
PaintFace0(&point);
|
|
|
|
}
|
|
|
|
if (!(faceskip & 2)) {
|
|
|
|
point.x = -15;
|
|
|
|
PaintFace1(&point);
|
|
|
|
}
|
|
|
|
if (!(faceskip & 4)) {
|
|
|
|
point.y = -15;
|
|
|
|
PaintFace2(&point);
|
|
|
|
}
|
|
|
|
if (!(faceskip & 8)) {
|
|
|
|
point.z = 15;
|
|
|
|
PaintFace3(&point);
|
|
|
|
}
|
|
|
|
if (!(faceskip & 16)) {
|
|
|
|
point.x = 15;
|
|
|
|
PaintFace4(&point);
|
|
|
|
}
|
|
|
|
if (!(faceskip & 32)) {
|
|
|
|
point.y = 15;
|
|
|
|
PaintFace5(&point);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::RenderCube() {
|
2016-11-14 22:07:39 -08:00
|
|
|
for (int i = 0; i < sizeof(cursor); i++)
|
2016-10-17 03:05:37 +03:00
|
|
|
cursor[i] = 0;
|
|
|
|
cursorcenter = &cursor[40 * 20 + 20];
|
|
|
|
|
|
|
|
GetSinCosTables(angle_x, &cos_x, &sin_x);
|
|
|
|
GetSinCosTables(angle_y, &cos_y, &sin_y);
|
|
|
|
GetSinCosTables(angle_z, &cos_z, &sin_z);
|
|
|
|
|
2016-11-14 22:07:39 -08:00
|
|
|
for (int i = 0; i < 6; i++) {
|
2016-10-17 03:05:37 +03:00
|
|
|
int area = CalcFaceArea(pc_cube[i]);
|
|
|
|
if (area <= 0) {
|
2016-11-15 09:39:49 +01:00
|
|
|
_face[i] = _newface[i]; // set new texture for invisible area,
|
2016-10-17 03:05:37 +03:00
|
|
|
faceskip |= 1 << i; // but don't draw it just yet
|
2016-11-14 22:07:39 -08:00
|
|
|
} else
|
2016-10-17 03:05:37 +03:00
|
|
|
faceskip &= ~(1 << i);
|
|
|
|
}
|
|
|
|
|
|
|
|
PaintFaces();
|
|
|
|
|
|
|
|
const int xshift = -5; // TODO: temporary fix to decrease left margin
|
|
|
|
unsigned char *cur = cursor;
|
|
|
|
unsigned char *scr = p_mainview->_bufferPtr + curs_x + _scrollPos + xshift + curs_y * p_mainview->_pitch;
|
|
|
|
|
|
|
|
for (int y = 0; y < 40; y++) {
|
|
|
|
for (int x = 0; x < 40; x++) {
|
|
|
|
if (x + curs_x + _scrollPos + xshift < p_mainview->_pitch && y + curs_y < p_mainview->_height)
|
|
|
|
if (*cur)
|
|
|
|
*scr = *cur;
|
|
|
|
scr++;
|
|
|
|
cur++;
|
|
|
|
}
|
|
|
|
scr += p_mainview->_pitch - 40;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EdenGame::IncAngleX(int step) {
|
|
|
|
angle_x += step;
|
2016-11-14 22:07:39 -08:00
|
|
|
if (angle_x == 70 + 2)
|
|
|
|
angle_x = 0;
|
|
|
|
if (angle_x == 0 - 2)
|
|
|
|
angle_x = 70;
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::DecAngleX() {
|
|
|
|
if (angle_x != 0)
|
|
|
|
angle_x -= (angle_x > 4) ? 4 : 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::IncAngleY(int step) {
|
|
|
|
angle_y += step;
|
2016-11-14 22:07:39 -08:00
|
|
|
if (angle_y == 70 + 2)
|
|
|
|
angle_y = 0;
|
|
|
|
if (angle_y == 0 - 2)
|
|
|
|
angle_y = 70;
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::DecAngleY() {
|
|
|
|
if (angle_y != 0)
|
|
|
|
angle_y -= (angle_y > 4) ? 4 : 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::IncZoom() {
|
|
|
|
if (zoom == 170)
|
|
|
|
zoom_step = 40;
|
|
|
|
if (zoom == 570)
|
|
|
|
zoom_step = -40;
|
|
|
|
zoom += zoom_step;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::DecZoom() {
|
|
|
|
if (zoom != 170) {
|
|
|
|
if (zoom < 170)
|
|
|
|
zoom = 170;
|
|
|
|
else
|
|
|
|
zoom -= 40;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-25 23:32:15 +02:00
|
|
|
void EdenGame::initCubePC() {
|
2016-10-17 03:05:37 +03:00
|
|
|
zoom = 170;
|
|
|
|
zoom_step = 40;
|
|
|
|
angle_x = angle_y = angle_z = 0;
|
|
|
|
pc_cursor = &pc_cursors[0];
|
|
|
|
curs_cur_map = -1;
|
|
|
|
MakeTables();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::pc_selectmap(int16 num) {
|
|
|
|
if (num != curs_cur_map) {
|
|
|
|
pc_cursor = &pc_cursors[num];
|
|
|
|
unsigned char *bank = main_bank_buf + PLE16(main_bank_buf);
|
|
|
|
for (int i = 0; i < 6; i++) {
|
2016-11-15 09:39:49 +01:00
|
|
|
_newface[i] = 4 + (unsigned char*)getElem(bank, pc_cursor->sides[i]);
|
2016-10-17 03:05:37 +03:00
|
|
|
if (curs_cur_map == -1)
|
2016-11-15 09:39:49 +01:00
|
|
|
_face[i] = _newface[i];
|
2016-10-17 03:05:37 +03:00
|
|
|
}
|
|
|
|
curs_cur_map = num;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EdenGame::pc_moteur() {
|
2016-11-14 22:07:39 -08:00
|
|
|
int16 curs = _currCursor;
|
2016-10-17 03:05:37 +03:00
|
|
|
if (normalCursor && (p_global->drawFlags & DrawFlags::drDrawFlag20))
|
|
|
|
curs = 9;
|
|
|
|
pc_selectmap(curs);
|
|
|
|
curs_new_tick = TickCount();
|
|
|
|
if (curs_new_tick - curs_old_tick < 1)
|
|
|
|
return;
|
|
|
|
curs_old_tick = curs_new_tick;
|
|
|
|
int step = pc_cursor->speed;
|
|
|
|
switch (pc_cursor->kind) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1: // rot up-down
|
|
|
|
DecAngleY();
|
|
|
|
DecZoom();
|
|
|
|
IncAngleX(step);
|
|
|
|
break;
|
|
|
|
case 2: // rot left-right
|
|
|
|
DecAngleX();
|
|
|
|
DecZoom();
|
|
|
|
IncAngleY(step);
|
|
|
|
break;
|
|
|
|
case 3: // rotate random
|
|
|
|
DecZoom();
|
|
|
|
IncAngleX(step);
|
|
|
|
IncAngleY(step);
|
|
|
|
break;
|
|
|
|
case 4: // zoom in-out
|
2016-11-15 09:39:49 +01:00
|
|
|
_face[0] = _newface[0];
|
2016-10-17 03:05:37 +03:00
|
|
|
DecAngleY();
|
|
|
|
DecAngleX();
|
|
|
|
IncZoom();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
RenderCube();
|
|
|
|
}
|
|
|
|
|
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() {
|
|
|
|
p_global->pref_language = 1;
|
2016-09-30 07:48:27 +02:00
|
|
|
_doubledScreen = false; // TODO: set to true
|
2016-09-14 23:39:27 +02:00
|
|
|
p_global->pref_10C[0] = 192;
|
|
|
|
p_global->pref_10C[1] = 192;
|
|
|
|
p_global->pref_10E[0] = 255;
|
|
|
|
p_global->pref_10E[1] = 255;
|
|
|
|
p_global->pref_110[0] = 32;
|
|
|
|
p_global->pref_110[1] = 32;
|
|
|
|
}
|
|
|
|
|
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
|