| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 
 | /* 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.
 */
#include "tinsel/handle.h"
#include "tinsel/pcode.h"	// For D_UP, D_DOWN
#include "tinsel/rince.h"
#include "common/textconsole.h"
#include "common/util.h"
namespace Tinsel {
//----------------- LOCAL GLOBAL DATA --------------------
enum {
	NUM_INTERVALS = REQ_MAIN_SCALES - 1,
	// 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];
};
// FIXME: Avoid non-const global vars
static SCIdataStruct g_SCIdata[MAX_SCRENTRIES];
static int g_scrEntries = 0;
/**
 * 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;
}
/**
 * Return handle to actor's talk reel at present scale and direction.
 */
SCNHANDLE GetMoverTalkReel(PMOVER pActor, TFTYPE dirn) {
	assert(1 <= pActor->scale && pActor->scale <= TOTAL_SCALES);
	switch (dirn) {
	case TF_NONE:
		return pActor->talkReels[pActor->scale-1][pActor->direction];
	case TF_UP:
		return pActor->talkReels[pActor->scale-1][AWAY];
	case TF_DOWN:
		return pActor->talkReels[pActor->scale-1][FORWARD];
	case TF_LEFT:
		return pActor->talkReels[pActor->scale-1][LEFTREEL];
	case TF_RIGHT:
		return pActor->talkReels[pActor->scale-1][RIGHTREEL];
	default:
		error("GetMoverTalkReel() - illegal direction");
	}
}
/**
 * scalingreels
 */
void SetScalingReels(int actor, int scale, int direction,
		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
	assert(g_scrEntries < MAX_SCRENTRIES); // Scaling reels limit reached!
	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++;
}
/**
 * ScalingReel
 */
SCNHANDLE ScalingReel(int ano, int scale1, int scale2, DIRECTION reel) {
	int d;	// Direction
	// The smaller the number, the bigger the scale
	if (scale1 < scale2)
		d = D_DOWN;
	else
		d = D_UP;
	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)
				return 0;
			else
				return g_SCIdata[i].reels[reel];
		}
	}
	return 0;
}
/**
 * RebootScalingReels
 */
void RebootScalingReels() {
	g_scrEntries = 0;
	memset(g_SCIdata, 0, sizeof(g_SCIdata));
}
/**
 * Discourage them from being ditched.
 */
void TouchMoverReels() {
	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);
}
} // End of namespace Tinsel
 |