Skip to content

Commit

Permalink
MADS: Phantom: Implement scene 310
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Oct 29, 2015
1 parent 73614e9 commit af7a233
Show file tree
Hide file tree
Showing 8 changed files with 268 additions and 8 deletions.
6 changes: 6 additions & 0 deletions engines/mads/animation.cpp
Expand Up @@ -162,6 +162,7 @@ Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) {
_flags = 0;
_font = nullptr;
_resetFlag = false;
_canChangeView = false;
_messageCtr = 0;
_skipLoad = false;
_freeFlag = false;
Expand Down Expand Up @@ -616,4 +617,9 @@ void Animation::eraseSprites() {
}
}

Common::Point Animation::getFramePosAdjust(int idx) {
warning("TODO: Implement getFramePosAdjust");

return Common::Point(0, 0);
}
} // End of namespace MADS
3 changes: 3 additions & 0 deletions engines/mads/animation.h
Expand Up @@ -189,6 +189,7 @@ class Animation {
Common::Array<AnimUIEntry> _uiEntries;
Common::Array<AnimMessage> _messages;
bool _resetFlag;
bool _canChangeView;
int _currentFrame;
int _oldFrameEntry;
int _dynamicHotspotIndex;
Expand Down Expand Up @@ -236,6 +237,8 @@ class Animation {
void resetSpriteSetsCount() { _header._spriteSetsCount = 0; } // CHECKME: See if it doesn't leak the memory when the destructor is called

SpriteAsset *getSpriteSet(int idx) { return _spriteSets[idx]; }

Common::Point getFramePosAdjust(int idx);
};

} // End of namespace MADS
Expand Down
4 changes: 4 additions & 0 deletions engines/mads/game.cpp
Expand Up @@ -605,5 +605,9 @@ void Game::syncTimers(int slave_type, int slave_id, int master_type, int master_

void Game::camPanTo(Camera *camera, int target) {
warning("TODO: Game::camPanTo");
if (camera) {
// Incomplete
camera->_panMode = 1;
}
}
} // End of namespace MADS
1 change: 1 addition & 0 deletions engines/mads/game.h
Expand Up @@ -241,6 +241,7 @@ class Game {
typedef struct {
//TODO
bool _panFrame;
int _panMode;
} Camera;
Camera _camX, _camY;

Expand Down
14 changes: 14 additions & 0 deletions engines/mads/messages.cpp
Expand Up @@ -193,6 +193,10 @@ void KernelMessages::processText(int msgIndex) {
msg._timeout = 0;
}

if (msg._flags & KMSG_ANIM) {
warning("TODO: Implement animated text");
}

if ((msg._timeout <= 0) && (_vm->_game->_trigger == 0)) {
msg._flags |= KMSG_EXPIRE;
if (msg._trigger != 0) {
Expand Down Expand Up @@ -465,6 +469,16 @@ void KernelMessages::initRandomMessages(int maxSimultaneousMessages,
va_end(va);
}

void KernelMessages::setAnim(int msgId, int seqId, int val3 = 0) {
if (msgId < 0)
return;

_entries[msgId]._flags |= KMSG_ANIM;
_entries[msgId]._sequenceIndex = seqId;

warning("TODO: KernelMessages::setAnim, unused parameter");
}


/*------------------------------------------------------------------------*/

Expand Down
3 changes: 2 additions & 1 deletion engines/mads/messages.h
Expand Up @@ -39,7 +39,7 @@ namespace MADS {
enum KernelMessageFlags {
KMSG_QUOTED = 1, KMSG_PLAYER_TIMEOUT = 2, KMSG_SEQ_ENTRY = 4, KMSG_SCROLL = 8,
KMSG_RIGHT_ALIGN = 0x10, KMSG_CENTER_ALIGN = 0x20, KMSG_EXPIRE = 0x40,
KMSG_ACTIVE = 0x80
KMSG_ACTIVE = 0x80, KMSG_ANIM = 0x100
};

class MADSEngine;
Expand Down Expand Up @@ -104,6 +104,7 @@ class KernelMessages {
int addQuote(int quoteId, int endTrigger, uint32 timeout);
void scrollMessage(int msgIndex, int numTicks, bool quoted);
void setSeqIndex(int msgIndex, int seqIndex);
void setAnim(int msgId, int seqId, int val3);
void remove(int msgIndex);
void reset();
void update();
Expand Down
210 changes: 210 additions & 0 deletions engines/mads/phantom/phantom_scenes3.cpp
Expand Up @@ -2560,5 +2560,215 @@ void Scene309::handleBoatAnimation() {

/*------------------------------------------------------------------------*/

Scene310::Scene310(MADSEngine *vm) : Scene3xx(vm) {
_raoulMessageColor = -1;
_chrisMessageColor = -1;
_lakeFrame = -1;
for (int i = 0; i < 4; i++)
_multiplanePosX[i] = -1;
}

void Scene310::synchronize(Common::Serializer &s) {
Scene3xx::synchronize(s);

s.syncAsSint16LE(_raoulMessageColor);
s.syncAsSint16LE(_chrisMessageColor);
s.syncAsSint16LE(_lakeFrame);
for (int i = 0; i < 4; i++)
s.syncAsSint16LE(_multiplanePosX[i]);
}

void Scene310::setup() {
setPlayerSpritesPrefix();
setAAName();
}

void Scene310::enter() {
warning("TODO: Switch to letter box view. See definition of MADS_MENU_Y");

for (int i = 0; i < 4; i++) {
_globals._spriteIndexes[i] = _scene->_sprites.addSprites(formAnimName('f', i), false);
_globals._sequenceIndexes[i] = -1;
}

_multiplanePosX[0] = 100;
_multiplanePosX[1] = 210;
_multiplanePosX[2] = 320;
_multiplanePosX[3] = 472;

_game.loadQuoteSet(0x66, 0x67, 0x69, 0x6A, 0x6C, 0x6D, 0x6E, 0x6F, 0x71, 0x72, 0x74, 0x70, 0x68, 0x73, 0x6B, 0);
_game._player._stepEnabled = false;
_game._player._visible = false;
_globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('l', 1), 80);
_scene->_animation[_globals._animationIndexes[0]]->_canChangeView = true;
_game._camX._panMode = 1;

_raoulMessageColor = 0x102;
_chrisMessageColor = 0x1110;

_scene->_userInterface.emptyConversationList();
_scene->_userInterface.setup(kInputConversation);

sceneEntrySound();
}

void Scene310::step() {
handleLakeAnimation();

if (_game._trigger == 80)
_scene->_nextSceneId = 309;

bool positionsSetFl = false;

if (_globals._animationIndexes[0] >= 0) {
MADS::Animation *anim = _scene->_animation[_globals._animationIndexes[0]];
int curFrame = anim->getCurrentFrame();
uint32 clock = anim->getNextFrameTimer();
if ((curFrame > 0) && (_scene->_frameStartTime >= clock)) {
Common::Point pos = anim->getFramePosAdjust(curFrame);
if (pos.x != _scene->_posAdjust.x) {
setMultiplanePos(pos.x);
positionsSetFl = true;
}
}
}

if (!positionsSetFl && (_game._fx != kTransitionNone))
setMultiplanePos(320);
}

void Scene310::actions() {
}

void Scene310::preActions() {
}

void Scene310::setMultiplanePos(int x_new) {
int center = x_new + 160;

for (int i = 0; i < 4; i++) {
if (_globals._sequenceIndexes[i] >= 0)
_scene->deleteSequence(_globals._sequenceIndexes[i]);

int difference = center - _multiplanePosX[i];

int direction = 0;
if (difference < 0)
direction = 1;
else if (difference > 0)
direction = -1;

int displace = abs(difference);
if (direction < 0)
displace = -displace;

int x = _multiplanePosX[i] + displace - 1;
int y = _scene->_sprites[_globals._spriteIndexes[i]]->getFrameWidth(0) + 29;
int halfWidth = 1 + (_scene->_sprites[_globals._spriteIndexes[i]]->getFrameHeight(0) / 2);

if (((x - halfWidth) >= (x_new + 320)) || ((x + halfWidth) < x_new))
_globals._sequenceIndexes[i] = -1;
else {
_globals._sequenceIndexes[i] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[i], false, 1);
_scene->_sequences.setPosition(_globals._sequenceIndexes[i], Common::Point(x, y));
_scene->_sequences.setDepth(_globals._sequenceIndexes[i], 1);
}
}
}

void Scene310::handleLakeAnimation() {
if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == _lakeFrame)
return;


_lakeFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame();
int resetFrame = -1;
int id;

switch (_lakeFrame) {
case 60:
id = _scene->_kernelMessages.add(Common::Point(-142, 0), _chrisMessageColor, 0, 61, 600, _game.getQuote(0x66));
_scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0);
id = _scene->_kernelMessages.add(Common::Point(-142, 15), _chrisMessageColor, 0, 0, 600, _game.getQuote(0x67));
_scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0);
id = _scene->_kernelMessages.add(Common::Point(-142, 30), _chrisMessageColor, 0, 0, 600, _game.getQuote(0x68));
_scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0);
break;

case 120:
_scene->_kernelMessages.reset();
break;

case 140:
id = _scene->_kernelMessages.add(Common::Point(-120, 0), _chrisMessageColor, 0, 63, 360, _game.getQuote(0x69));
_scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0);
id = _scene->_kernelMessages.add(Common::Point(-120, 15), _chrisMessageColor, 0, 0, 360, _game.getQuote(0x6A));
_scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0);
id = _scene->_kernelMessages.add(Common::Point(-120, 30), _chrisMessageColor, 0, 0, 360, _game.getQuote(0x6B));
_scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0);
break;

case 200:
_scene->_kernelMessages.reset();
break;

case 220:
id = _scene->_kernelMessages.add(Common::Point(-32, 30), _chrisMessageColor, 0, 65, 240, _game.getQuote(0x6C));
_scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0);
id = _scene->_kernelMessages.add(Common::Point(-32, 45), _chrisMessageColor, 0, 0, 240, _game.getQuote(0x6D));
_scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0);
break;

case 280:
_scene->_kernelMessages.reset();
break;

case 300:
id = _scene->_kernelMessages.add(Common::Point(101, 0), _raoulMessageColor, 0, 67, 360, _game.getQuote(0x6E));
_scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0);
id = _scene->_kernelMessages.add(Common::Point(101, 15), _raoulMessageColor, 0, 0, 360, _game.getQuote(0x6F));
_scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0);
id = _scene->_kernelMessages.add(Common::Point(101, 30), _raoulMessageColor, 0, 0, 360, _game.getQuote(0x70));
_scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0);
break;

case 360:
_scene->_kernelMessages.reset();
break;

case 380:
id = _scene->_kernelMessages.add(Common::Point(107, 0), _chrisMessageColor, 0, 69, 360, _game.getQuote(0x71));
_scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0);
id = _scene->_kernelMessages.add(Common::Point(107, 15), _chrisMessageColor, 0, 0, 360, _game.getQuote(0x72));
_scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0);
id = _scene->_kernelMessages.add(Common::Point(107, 30), _chrisMessageColor, 0, 0, 360, _game.getQuote(0x73));
_scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0);
break;

case 440:
_scene->_kernelMessages.reset();
break;

case 460:
id = _scene->_kernelMessages.add(Common::Point(107, 7), _chrisMessageColor, 0, 0, 180, _game.getQuote(0x74));
_scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0);
break;

case 510:
_scene->_kernelMessages.reset();
break;

default:
break;
}

if (resetFrame >= 0) {
_scene->setAnimFrame(_globals._animationIndexes[0], resetFrame);
_lakeFrame = resetFrame;
}
}

/*------------------------------------------------------------------------*/

} // End of namespace Phantom
} // End of namespace MADS
35 changes: 28 additions & 7 deletions engines/mads/phantom/phantom_scenes3.h
Expand Up @@ -11,7 +11,7 @@
* 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
* 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
Expand Down Expand Up @@ -55,12 +55,12 @@ class Scene3xx : public PhantomScene {

class Scene301 : public Scene3xx {
private:
bool _anim0ActvFl;
bool _skip1Fl;
bool _skip2Fl;
bool _anim0ActvFl;
bool _skip1Fl;
bool _skip2Fl;

int _lightingHotspotId;
int _sandbagHotspotId;
int _lightingHotspotId;
int _sandbagHotspotId;

public:
Scene301(MADSEngine *vm);
Expand All @@ -87,7 +87,7 @@ class Scene302 : public Scene3xx {

class Scene303 : public Scene3xx {
private:
bool _anim0ActvFl;
bool _anim0ActvFl;
int _hempHotspotId;
int _skipFrameCheckFl;
public:
Expand Down Expand Up @@ -221,6 +221,27 @@ class Scene309 : public Scene3xx {
virtual void preActions();
virtual void actions();
};

class Scene310 : public Scene3xx {
private:
int _raoulMessageColor;
int _chrisMessageColor;
int _multiplanePosX[4];
int _lakeFrame;

void setMultiplanePos(int x_new);
void handleLakeAnimation();

public:
Scene310(MADSEngine *vm);
virtual void synchronize(Common::Serializer &s);

virtual void setup();
virtual void enter();
virtual void step();
virtual void preActions();
virtual void actions();
};
} // End of namespace Phantom
} // End of namespace MADS

Expand Down

0 comments on commit af7a233

Please sign in to comment.