2008-07-23 09:02:47 +00: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.
|
|
|
|
*
|
|
|
|
* Functions to set up moving actors' reels.
|
|
|
|
*/
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
#include "tinsel/handle.h"
|
2008-07-23 09:02:47 +00:00
|
|
|
#include "tinsel/pcode.h" // For D_UP, D_DOWN
|
|
|
|
#include "tinsel/rince.h"
|
|
|
|
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/textconsole.h"
|
2008-07-23 09:02:47 +00:00
|
|
|
#include "common/util.h"
|
|
|
|
|
|
|
|
namespace Tinsel {
|
|
|
|
|
|
|
|
//----------------- LOCAL GLOBAL DATA --------------------
|
|
|
|
|
|
|
|
enum {
|
2008-12-01 20:35:36 +00:00
|
|
|
NUM_INTERVALS = REQ_MAIN_SCALES - 1,
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// 2 for up and down, 3 allow enough entries for 3 fully subscribed moving actors' worth
|
|
|
|
MAX_SCRENTRIES = NUM_INTERVALS*2*3
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SCIdataStruct {
|
|
|
|
int actor;
|
|
|
|
int scale;
|
|
|
|
int direction;
|
|
|
|
SCNHANDLE reels[4];
|
|
|
|
};
|
|
|
|
|
2010-11-16 09:53:55 +00:00
|
|
|
// FIXME: Avoid non-const global vars
|
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
static SCIdataStruct g_SCIdata[MAX_SCRENTRIES];
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
static int g_scrEntries = 0;
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
/**
|
|
|
|
* Sets an actor's walk reels
|
|
|
|
*/
|
|
|
|
|
|
|
|
void SetWalkReels(PMOVER pMover, int scale,
|
|
|
|
SCNHANDLE al, SCNHANDLE ar, SCNHANDLE af, SCNHANDLE aa) {
|
|
|
|
assert(scale > 0 && scale <= TOTAL_SCALES);
|
|
|
|
|
|
|
|
pMover->walkReels[scale-1][LEFTREEL] = al;
|
|
|
|
pMover->walkReels[scale-1][RIGHTREEL] = ar;
|
|
|
|
pMover->walkReels[scale-1][FORWARD] = af;
|
|
|
|
pMover->walkReels[scale-1][AWAY] = aa;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets an actor's stand reels
|
|
|
|
*/
|
|
|
|
|
|
|
|
void SetStandReels(PMOVER pMover, int scale,
|
|
|
|
SCNHANDLE al, SCNHANDLE ar, SCNHANDLE af, SCNHANDLE aa) {
|
|
|
|
assert(scale > 0 && scale <= TOTAL_SCALES);
|
|
|
|
|
|
|
|
pMover->standReels[scale-1][LEFTREEL] = al;
|
|
|
|
pMover->standReels[scale-1][RIGHTREEL] = ar;
|
|
|
|
pMover->standReels[scale-1][FORWARD] = af;
|
|
|
|
pMover->standReels[scale-1][AWAY] = aa;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets an actor's talk reels
|
|
|
|
*/
|
|
|
|
|
|
|
|
void SetTalkReels(PMOVER pMover, int scale,
|
|
|
|
SCNHANDLE al, SCNHANDLE ar, SCNHANDLE af, SCNHANDLE aa) {
|
|
|
|
assert(scale > 0 && scale <= TOTAL_SCALES);
|
|
|
|
|
|
|
|
pMover->talkReels[scale-1][LEFTREEL] = al;
|
|
|
|
pMover->talkReels[scale-1][RIGHTREEL] = ar;
|
|
|
|
pMover->talkReels[scale-1][FORWARD] = af;
|
|
|
|
pMover->talkReels[scale-1][AWAY] = aa;
|
|
|
|
}
|
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
/**
|
|
|
|
* Return handle to actor's talk reel at present scale and direction.
|
|
|
|
*/
|
2008-12-01 20:35:36 +00:00
|
|
|
SCNHANDLE GetMoverTalkReel(PMOVER pActor, TFTYPE dirn) {
|
2008-07-23 09:02:47 +00:00
|
|
|
assert(1 <= pActor->scale && pActor->scale <= TOTAL_SCALES);
|
|
|
|
switch (dirn) {
|
|
|
|
case TF_NONE:
|
2008-12-01 20:35:36 +00:00
|
|
|
return pActor->talkReels[pActor->scale-1][pActor->direction];
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
case TF_UP:
|
2008-12-01 20:35:36 +00:00
|
|
|
return pActor->talkReels[pActor->scale-1][AWAY];
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
case TF_DOWN:
|
2008-12-01 20:35:36 +00:00
|
|
|
return pActor->talkReels[pActor->scale-1][FORWARD];
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
case TF_LEFT:
|
2008-12-01 20:35:36 +00:00
|
|
|
return pActor->talkReels[pActor->scale-1][LEFTREEL];
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
case TF_RIGHT:
|
2008-12-01 20:35:36 +00:00
|
|
|
return pActor->talkReels[pActor->scale-1][RIGHTREEL];
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
default:
|
2009-05-31 10:02:16 +00:00
|
|
|
error("GetMoverTalkReel() - illegal direction");
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* scalingreels
|
|
|
|
*/
|
2008-12-01 20:35:36 +00:00
|
|
|
void SetScalingReels(int actor, int scale, int direction,
|
2008-07-23 09:02:47 +00:00
|
|
|
SCNHANDLE left, SCNHANDLE right, SCNHANDLE forward, SCNHANDLE away) {
|
|
|
|
assert(scale >= 1 && scale <= NUM_MAINSCALES); // invalid scale
|
|
|
|
assert(!(scale == 1 && direction == D_UP) &&
|
|
|
|
!(scale == NUM_MAINSCALES && direction == D_DOWN)); // illegal direction from scale
|
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
assert(g_scrEntries < MAX_SCRENTRIES); // Scaling reels limit reached!
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
g_SCIdata[g_scrEntries].actor = actor;
|
|
|
|
g_SCIdata[g_scrEntries].scale = scale;
|
|
|
|
g_SCIdata[g_scrEntries].direction = direction;
|
|
|
|
g_SCIdata[g_scrEntries].reels[LEFTREEL] = left;
|
|
|
|
g_SCIdata[g_scrEntries].reels[RIGHTREEL] = right;
|
|
|
|
g_SCIdata[g_scrEntries].reels[FORWARD] = forward;
|
|
|
|
g_SCIdata[g_scrEntries].reels[AWAY] = away;
|
|
|
|
g_scrEntries++;
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ScalingReel
|
|
|
|
*/
|
2008-12-01 20:35:36 +00:00
|
|
|
SCNHANDLE ScalingReel(int ano, int scale1, int scale2, DIRECTION reel) {
|
2008-07-23 09:02:47 +00:00
|
|
|
int d; // Direction
|
|
|
|
|
|
|
|
// The smaller the number, the bigger the scale
|
|
|
|
if (scale1 < scale2)
|
|
|
|
d = D_DOWN;
|
|
|
|
else
|
|
|
|
d = D_UP;
|
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
for (int i = 0; i < g_scrEntries; i++) {
|
|
|
|
if (g_SCIdata[i].actor == ano && g_SCIdata[i].scale == scale1 && g_SCIdata[i].direction == d) {
|
|
|
|
if (g_SCIdata[i].reels[reel] == TF_NONE)
|
2008-07-23 09:02:47 +00:00
|
|
|
return 0;
|
|
|
|
else
|
2012-02-22 22:14:29 +00:00
|
|
|
return g_SCIdata[i].reels[reel];
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RebootScalingReels
|
|
|
|
*/
|
2009-11-02 21:54:57 +00:00
|
|
|
void RebootScalingReels() {
|
2012-02-22 22:14:29 +00:00
|
|
|
g_scrEntries = 0;
|
|
|
|
memset(g_SCIdata, 0, sizeof(g_SCIdata));
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
/**
|
|
|
|
* Discourage them from being ditched.
|
|
|
|
*/
|
2009-11-02 21:54:57 +00:00
|
|
|
void TouchMoverReels() {
|
2008-12-01 20:35:36 +00:00
|
|
|
PMOVER pMover;
|
|
|
|
int scale;
|
|
|
|
|
|
|
|
pMover = NextMover(NULL);
|
|
|
|
|
|
|
|
do {
|
|
|
|
for (scale = 0; scale < TOTAL_SCALES; scale++) {
|
|
|
|
TouchMem(pMover->walkReels[scale][LEFTREEL]);
|
|
|
|
}
|
|
|
|
} while ((pMover = NextMover(pMover)) != NULL);
|
|
|
|
}
|
|
|
|
|
2009-10-04 21:26:33 +00:00
|
|
|
} // End of namespace Tinsel
|