[Scummvm-cvs-logs] SF.net SVN: scummvm: [30637] residual/trunk

aquadran at users.sourceforge.net aquadran at users.sourceforge.net
Sat Jan 26 10:18:08 CET 2008


Revision: 30637
          http://scummvm.svn.sourceforge.net/scummvm/?rev=30637&view=rev
Author:   aquadran
Date:     2008-01-26 01:18:08 -0800 (Sat, 26 Jan 2008)

Log Message:
-----------
files structure reorganization, compilation BROKEN. compilation will be fixed soon.

Added Paths:
-----------
    residual/trunk/common/
    residual/trunk/common/bits.h
    residual/trunk/common/debug.cpp
    residual/trunk/common/debug.h
    residual/trunk/common/matrix3.cpp
    residual/trunk/common/matrix3.h
    residual/trunk/common/matrix4.cpp
    residual/trunk/common/matrix4.h
    residual/trunk/common/stdafx.h
    residual/trunk/common/timer.cpp
    residual/trunk/common/timer.h
    residual/trunk/common/vector3d.h
    residual/trunk/dists/residual.rc
    residual/trunk/engine/
    residual/trunk/engine/actor.cpp
    residual/trunk/engine/actor.h
    residual/trunk/engine/backend/
    residual/trunk/engine/backend/dc/
    residual/trunk/engine/backend/driver.h
    residual/trunk/engine/backend/sdl/
    residual/trunk/engine/backend/sdl/driver_gl.cpp
    residual/trunk/engine/backend/sdl/driver_gl.h
    residual/trunk/engine/backend/sdl/driver_sdl.cpp
    residual/trunk/engine/backend/sdl/driver_sdl.h
    residual/trunk/engine/backend/sdl/driver_tinygl.cpp
    residual/trunk/engine/backend/sdl/driver_tinygl.h
    residual/trunk/engine/bitmap.cpp
    residual/trunk/engine/bitmap.h
    residual/trunk/engine/color.h
    residual/trunk/engine/colormap.h
    residual/trunk/engine/costume.cpp
    residual/trunk/engine/costume.h
    residual/trunk/engine/engine.cpp
    residual/trunk/engine/engine.h
    residual/trunk/engine/font.cpp
    residual/trunk/engine/font.h
    residual/trunk/engine/imuse/
    residual/trunk/engine/keyframe.cpp
    residual/trunk/engine/keyframe.h
    residual/trunk/engine/lab.cpp
    residual/trunk/engine/lab.h
    residual/trunk/engine/lipsynch.cpp
    residual/trunk/engine/lipsynch.h
    residual/trunk/engine/localize.cpp
    residual/trunk/engine/localize.h
    residual/trunk/engine/lua/
    residual/trunk/engine/lua.cpp
    residual/trunk/engine/lua.h
    residual/trunk/engine/main.cpp
    residual/trunk/engine/material.cpp
    residual/trunk/engine/material.h
    residual/trunk/engine/model.cpp
    residual/trunk/engine/model.h
    residual/trunk/engine/objectstate.cpp
    residual/trunk/engine/objectstate.h
    residual/trunk/engine/primitives.cpp
    residual/trunk/engine/primitives.h
    residual/trunk/engine/registry.cpp
    residual/trunk/engine/registry.h
    residual/trunk/engine/resource.cpp
    residual/trunk/engine/resource.h
    residual/trunk/engine/savegame.cpp
    residual/trunk/engine/savegame.h
    residual/trunk/engine/scene.cpp
    residual/trunk/engine/scene.h
    residual/trunk/engine/smush/
    residual/trunk/engine/smush/blocky16.cpp
    residual/trunk/engine/smush/blocky16.h
    residual/trunk/engine/smush/smush.cpp
    residual/trunk/engine/smush/smush.h
    residual/trunk/engine/smush/vima.cpp
    residual/trunk/engine/textobject.cpp
    residual/trunk/engine/textobject.h
    residual/trunk/engine/textsplit.cpp
    residual/trunk/engine/textsplit.h
    residual/trunk/engine/tinygl/
    residual/trunk/engine/walkplane.cpp
    residual/trunk/engine/walkplane.h

Removed Paths:
-------------
    residual/trunk/actor.cpp
    residual/trunk/actor.h
    residual/trunk/bitmap.cpp
    residual/trunk/bitmap.h
    residual/trunk/bits.h
    residual/trunk/blocky16.cpp
    residual/trunk/blocky16.h
    residual/trunk/color.h
    residual/trunk/colormap.h
    residual/trunk/costume.cpp
    residual/trunk/costume.h
    residual/trunk/dc/
    residual/trunk/debug.cpp
    residual/trunk/debug.h
    residual/trunk/driver.h
    residual/trunk/driver_gl.cpp
    residual/trunk/driver_gl.h
    residual/trunk/driver_sdl.cpp
    residual/trunk/driver_sdl.h
    residual/trunk/driver_tinygl.cpp
    residual/trunk/driver_tinygl.h
    residual/trunk/engine.cpp
    residual/trunk/engine.h
    residual/trunk/font.cpp
    residual/trunk/font.h
    residual/trunk/imuse/
    residual/trunk/keyframe.cpp
    residual/trunk/keyframe.h
    residual/trunk/lab.cpp
    residual/trunk/lab.h
    residual/trunk/lipsynch.cpp
    residual/trunk/lipsynch.h
    residual/trunk/localize.cpp
    residual/trunk/localize.h
    residual/trunk/lua/
    residual/trunk/lua.cpp
    residual/trunk/lua.h
    residual/trunk/main.cpp
    residual/trunk/material.cpp
    residual/trunk/material.h
    residual/trunk/matrix3.cpp
    residual/trunk/matrix3.h
    residual/trunk/matrix4.cpp
    residual/trunk/matrix4.h
    residual/trunk/model.cpp
    residual/trunk/model.h
    residual/trunk/objectstate.cpp
    residual/trunk/objectstate.h
    residual/trunk/primitives.cpp
    residual/trunk/primitives.h
    residual/trunk/registry.cpp
    residual/trunk/registry.h
    residual/trunk/residual.rc
    residual/trunk/resource.cpp
    residual/trunk/resource.h
    residual/trunk/savegame.cpp
    residual/trunk/savegame.h
    residual/trunk/scene.cpp
    residual/trunk/scene.h
    residual/trunk/smush.cpp
    residual/trunk/smush.h
    residual/trunk/stdafx.h
    residual/trunk/textobject.cpp
    residual/trunk/textobject.h
    residual/trunk/textsplit.cpp
    residual/trunk/textsplit.h
    residual/trunk/timer.cpp
    residual/trunk/timer.h
    residual/trunk/tinygl/
    residual/trunk/vector3d.h
    residual/trunk/vima.cpp
    residual/trunk/walkplane.cpp
    residual/trunk/walkplane.h

Deleted: residual/trunk/actor.cpp
===================================================================
--- residual/trunk/actor.cpp	2008-01-26 08:25:27 UTC (rev 30636)
+++ residual/trunk/actor.cpp	2008-01-26 09:18:08 UTC (rev 30637)
@@ -1,665 +0,0 @@
-/* Residual - Virtual machine to run LucasArts' 3D adventure games
- * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "stdafx.h"
-#include "actor.h"
-#include "engine.h"
-#include "costume.h"
-#include "lipsynch.h"
-#include "localize.h"
-#include "driver.h"
-#include "smush.h"
-#include "walkplane.h"
-
-#include "mixer/mixer.h"
-
-#include "imuse/imuse.h"
-
-#include <cmath>
-#include <cstring>
-
-Actor::Actor(const char *name) :
-		_name(name), _setName(""), _talkColor(255, 255, 255), _pos(0, 0, 0),
-		// Some actors don't set walk and turn rates, so we default the
-		// _turnRate so Doug at the cat races can turn and we set the
-		// _walkRate so Glottis at the demon beaver entrance can walk
-		_pitch(0), _yaw(0), _roll(0), _walkRate(1.0f), _turnRate(100.0f),
-		_reflectionAngle(80),
-		_visible(true), _lipSynch(NULL), _turning(false), _walking(false),
-		_restCostume(NULL), _restChore(-1),
-		_walkCostume(NULL), _walkChore(-1), _walkedLast(false), _walkedCur(false),
-		_turnCostume(NULL), _leftTurnChore(-1), _rightTurnChore(-1),
-		_lastTurnDir(0), _currTurnDir(0),
-		_mumbleCostume(NULL), _mumbleChore(-1), _sayLineText(NULL) {
-	g_engine->registerActor(this);
-	_lookingMode = false;
-	_constrain = false;
-	_talkSoundName = "";
-	_activeShadowSlot = -1;
-	_shadowArray = new Shadow[5];
-
-	for (int i = 0; i < 5; i++) {
-		_shadowArray[i].active = true;
-	}
-
-	for (int i = 0; i < 10; i++) {
-		_talkCostume[i] = NULL;
-		_talkChore[i] = -1;
-	}
-}
-
-void Actor::setYaw(float yaw) {
-	// While the program correctly handle yaw angles outside
-	// of the range [0, 360), proper convention is to roll
-	// these values over correctly
-	if (yaw >= 360.0)
-		_yaw = yaw - 360;
-	else if (yaw < 0.0)
-		_yaw = yaw + 360;
-	else
-		_yaw = yaw;
-}
-
-void Actor::setRot(float pitch, float yaw, float roll) {
-	_pitch = pitch;
-	setYaw(yaw);
-	_roll = roll;
-}
-
-void Actor::turnTo(float pitch, float yaw, float roll) {
-	_pitch = pitch;
-	_roll = roll;
-	if (_yaw != yaw) {
-		_turning = true;
-		_destYaw = yaw;
-	} else
-		_turning = false;
-}
-
-void Actor::walkTo(Vector3d p) {
-	// For now, this is just the ignoring-boxes version (which afaict
-	// isn't even in the original).  This will eventually need a
-	// following-boxes version also.
-	if (p == _pos)
-		_walking = false;
-	else {
-		_walking = true;
-		_destPos = p;
-
-		if (p.x() != _pos.x() || p.y() != _pos.y())
-			turnTo(_pitch, yawTo(p), _roll);
-	}
-}
-
-bool Actor::isWalking() const {
-	return _walkedLast || _walkedCur || _walking;
-}
-
-bool Actor::isTurning() const {
-	if (_turning)
-		return true;
-
-	if (_lastTurnDir != 0 || _currTurnDir != 0)
-		return true;
-
-	return false;
-}
-
-void Actor::walkForward() {
-	float dist = g_engine->perSecond(_walkRate);
-	float yaw_rad = _yaw * (M_PI / 180), pitch_rad = _pitch * (M_PI / 180);
-	//float yaw;
-	Vector3d forwardVec(-std::sin(yaw_rad) * std::cos(pitch_rad),
-		std::cos(yaw_rad) * std::cos(pitch_rad),
-		std::sin(pitch_rad));
-	Vector3d destPos = _pos + forwardVec * dist;
-
-	if (! _constrain) {
-		_pos += forwardVec * dist;
-		_walkedCur = true;
-		return;
-	}
-
-	if (dist < 0) {
-		dist = -dist;
-		forwardVec = -forwardVec;
-	}
-
-	Sector *currSector = NULL, *prevSector = NULL;
-	Sector::ExitInfo ei;
-
-	g_engine->currScene()->findClosestSector(_pos, &currSector, &_pos);
-	if (currSector == NULL) { // Shouldn't happen...
-		_pos += forwardVec * dist;
-		_walkedCur = true;
-		return;
-	}
-
-	while (currSector != NULL) {
-		prevSector = currSector;
-		Vector3d puckVector = currSector->projectToPuckVector(forwardVec);
-		puckVector /= puckVector.magnitude();
-		currSector->getExitInfo(_pos, puckVector, &ei);
-		float exitDist = (ei.exitPoint - _pos).magnitude();
-		if (dist < exitDist) {
-			_pos += puckVector * dist;
-			_walkedCur = true;
-			return;
-		}
-		_pos = ei.exitPoint;
-		dist -= exitDist;
-		if (exitDist > 0.0001)
-			_walkedCur = true;
-
-		// Check for an adjacent sector which can continue
-		// the path
-		currSector = g_engine->currScene()->findPointSector(ei.exitPoint + (float)0.0001 * puckVector, 0x1000);
-		if (currSector == prevSector)
-			break;
-	}
-
-	ei.angleWithEdge *= (float)(180.0 / M_PI);
-	int turnDir = 1;
-	if (ei.angleWithEdge > 90) {
-		ei.angleWithEdge = 180 - ei.angleWithEdge;
-		ei.edgeDir = -ei.edgeDir;
-		turnDir = -1;
-	}
-	if (ei.angleWithEdge > _reflectionAngle)
-		return;
-
-	ei.angleWithEdge += (float)0.1;
-	float turnAmt = g_engine->perSecond(_turnRate);
-	if (turnAmt > ei.angleWithEdge)
-		turnAmt = ei.angleWithEdge;
-	setYaw(_yaw + turnAmt * turnDir);
-}
-
-Vector3d Actor::puckVector() const {
-	float yaw_rad = _yaw * (M_PI / 180);
-	Vector3d forwardVec(-std::sin(yaw_rad), std::cos(yaw_rad), 0);
-
-	Sector *sector = g_engine->currScene()->findPointSector(_pos, 0x1000);
-	if (sector == NULL)
-		return forwardVec;
-	else
-		return sector->projectToPuckVector(forwardVec);
-}
-
-void Actor::setRestChore(int chore, Costume *cost) {
-	if (_restCostume == cost && _restChore == chore)
-		return;
-
-	if (_restChore >= 0)
-		_restCostume->stopChore(_restChore);
-
-	_restCostume = cost;
-	_restChore = chore;
-
-	if (_restChore >= 0)
-		_restCostume->playChoreLooping(_restChore);
-}
-
-void Actor::setWalkChore(int chore, Costume *cost) {
-	if (_walkCostume == cost && _walkChore == chore)
-		return;
-
-	if (_walkChore >= 0)
-		_walkCostume->stopChore(_walkChore);
-
-	_walkCostume = cost;
-	_walkChore = chore;
-}
-
-void Actor::setTurnChores(int left_chore, int right_chore, Costume *cost) {
-	if (_turnCostume == cost && _leftTurnChore == left_chore &&
-	    _rightTurnChore == right_chore)
-		return;
-
-	if (_leftTurnChore >= 0) {
-		_turnCostume->stopChore(_leftTurnChore);
-		_turnCostume->stopChore(_rightTurnChore);
-	}
-
-	_turnCostume = cost;
-	_leftTurnChore = left_chore;
-	_rightTurnChore = right_chore;
-
-	if ((left_chore >= 0 && right_chore < 0) || (left_chore < 0 && right_chore >= 0))
-		error("Unexpectedly got only one turn chore\n");
-}
-
-void Actor::setTalkChore(int index, int chore, Costume *cost) {
-	if (index < 1 || index > 10)
-		error("Got talk chore index out of range (%d)\n", index);
-
-	index--;
-
-	if (_talkCostume[index] == cost && _talkChore[index] == chore)
-		return;
-
-	if (_talkChore[index] >= 0)
-		_talkCostume[index]->stopChore(_talkChore[index]);
-
-	_talkCostume[index] = cost;
-	_talkChore[index] = chore;
-}
-
-void Actor::setMumbleChore(int chore, Costume *cost) {
-	if (_mumbleChore >= 0)
-		_mumbleCostume->stopChore(_mumbleChore);
-
-	_mumbleCostume = cost;
-	_mumbleChore = chore;
-}
-
-void Actor::turn(int dir) {
-	float delta = g_engine->perSecond(_turnRate) * dir;
-	setYaw(_yaw + delta);
-	_currTurnDir = dir;
-}
-
-float Actor::angleTo(const Actor &a) const {
-	float yaw_rad = _yaw * (M_PI / 180);
-	Vector3d forwardVec(-std::sin(yaw_rad), std::cos(yaw_rad), 0);
-	Vector3d delta = a.pos() - _pos;
-	delta.z() = 0;
-
-	return angle(forwardVec, delta) * (180 / M_PI);
-}
-
-float Actor::yawTo(Vector3d p) const {
-	Vector3d dpos = p - _pos;
-
-	if (dpos.x() == 0 && dpos.y() == 0)
-		return 0;
-	else
-		return std::atan2(-dpos.x(), dpos.y()) * (180 / M_PI);
-}
-
-void Actor::sayLine(const char *msg, const char *msgId) {
-	assert(msg);
-	assert(msgId);
-
-	std::string textName = msgId;
-	textName += ".txt";
-
-	if (msgId[0] == 0) {
-		error("Actor::sayLine: No message ID for text!");
-		return;
-	}
-
-	// During Fullscreen movies SayLine is called for text display only
-	// However, normal SMUSH movies may call SayLine, for example:
-	// When Domino yells at Manny (a SMUSH movie) he does it with
-	// a SayLine request rather than as part of the movie!
-	if (!g_smush->isPlaying() || g_engine->getMode() == ENGINE_MODE_NORMAL) {
-		std::string soundName = msgId;
-		std::string soundLip = msgId;
-		soundName += ".wav";
-		soundLip += ".lip";
-
-		if (_talkSoundName == soundName)
-			return;
-
-		if (g_imuse->getSoundStatus(_talkSoundName.c_str()))
-			shutUp();
-
-		_talkSoundName = soundName;
-		g_imuse->startVoice(_talkSoundName.c_str());
-		if (g_engine->currScene()) {
-			g_engine->currScene()->setSoundPosition(_talkSoundName.c_str(), pos());
-		}
-
-		// If the actor is clearly not visible then don't try to play the lip synch
-		if (visible()) {
-			// Sometimes actors speak offscreen before they, including their
-			// talk chores are initialized.
-			// For example, when reading the work order (a LIP file exists for no reason).
-			// Also, some lip synch files have no entries
-			// In these cases, revert to using the mumble chore.
-			_lipSynch = g_resourceloader->loadLipSynch(soundLip.c_str());
-			// If there's no lip synch file then load the mumble chore if it exists
-			// (the mumble chore doesn't exist with the cat races announcer)
-			if (_lipSynch == NULL && _mumbleChore != -1)
-				_mumbleCostume->playChoreLooping(_mumbleChore);
-			
-			_talkAnim = -1;
-		}
-	}
-
-	if (_sayLineText) {
-		g_engine->killTextObject(_sayLineText);
-		_sayLineText = NULL;
-	}
-
-	_sayLineText = new TextObject();
-	_sayLineText->setDefaults(&sayLineDefaults);
-	_sayLineText->setText((char *)msg);
-	_sayLineText->setFGColor(&_talkColor);
-	// if the actor isn't visible render their text at the bottom
-	// of the screen
-	if (!visible() || !inSet(g_engine->currScene()->name())) {
-		_sayLineText->setX(640 / 2);
-		_sayLineText->setY(420);
-	} else {
-		// render at the top for active actors for now
-		_sayLineText->setX(640 / 2);
-		_sayLineText->setY(0);
-	}
-	_sayLineText->createBitmap();
-	g_engine->registerTextObject(_sayLineText);
-}
-
-bool Actor::talking() {
-	// If there's no sound file then we're obviously not talking
-	if (strlen(_talkSoundName.c_str()) == 0)
-		return false;
-	
-	return g_imuse->getSoundStatus(_talkSoundName.c_str());
-}
-
-void Actor::shutUp() {
-	// While the call to stop the sound is usually made by the game,
-	// we also need to handle when the user terminates the dialog.
-	// Some warning messages will occur when the user terminates the
-	// actor dialog but the game will continue alright.
-	if (_talkSoundName != "") {
-		g_imuse->stopSound(_talkSoundName.c_str());
-		_talkSoundName = "";
-	}
-	if (_lipSynch != NULL) {
-		if ((_talkAnim != -1) && (_talkChore[_talkAnim] >= 0))
-			_talkCostume[_talkAnim]->stopChore(_talkChore[_talkAnim]);
-		_lipSynch = NULL;
-	} else if (_mumbleChore >= 0) {
-		_mumbleCostume->stopChore(_mumbleChore);
-	}
-
-	if (_sayLineText != NULL) {
-		g_engine->killTextObject(_sayLineText);
-		_sayLineText = NULL;
-	}
-}
-
-void Actor::pushCostume(const char *name) {
-	Costume *newCost = g_resourceloader->loadCostume(name, currentCostume());
-	
-	newCost->setColormap(NULL);
-	_costumeStack.push_back(newCost);
-}
-
-void Actor::setColormap(const char *map) {
-	if (!_costumeStack.empty()) {
-		Costume *cost = _costumeStack.back();
-		cost->setColormap((char *) map);
-	} else {
-		warning("Actor::setColormap: No costumes");
-	}
-}
-
-void Actor::setCostume(const char *name) {
-	if (!_costumeStack.empty())
-		popCostume();
-
-	pushCostume(name);
-}
-
-void Actor::popCostume() {
-	if (!_costumeStack.empty()) {
-		freeCostumeChore(_costumeStack.back(), _restCostume, _restChore);
-		freeCostumeChore(_costumeStack.back(), _walkCostume, _walkChore);
-
-		if (_turnCostume == _costumeStack.back()) {
-			_turnCostume = NULL;
-			_leftTurnChore = -1;
-			_rightTurnChore = -1;
-		}
-
-		freeCostumeChore(_costumeStack.back(), _mumbleCostume, _mumbleChore);
-		for (int i = 0; i < 10; i++)
-			freeCostumeChore(_costumeStack.back(), _talkCostume[i], _talkChore[i]);
-		delete _costumeStack.back();
-		_costumeStack.pop_back();
-		Costume *newCost;
-		if (_costumeStack.empty())
-			newCost = NULL;
-		else
-			newCost = _costumeStack.back();
-		if (newCost == NULL) {
-			if (debugLevel == DEBUG_NORMAL || debugLevel == DEBUG_ALL)
-				printf("Popped (freed) the last costume for an actor.\n");
-		}
-	} else {
-		if (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
-			warning("Attempted to pop (free) a costume when the stack is empty!");
-	}
-}
-
-void Actor::clearCostumes() {
-	// Make sure to destroy costume copies in reverse order
-	while (!_costumeStack.empty())
-		popCostume();
-}
-
-void Actor::setHead( int joint1, int joint2, int joint3, float maxRoll, float maxPitch, float maxYaw ) {
-	if (!_costumeStack.empty()) {
-		_costumeStack.back()->setHead(joint1, joint2, joint3, maxRoll, maxPitch, maxYaw);
-	}
-}
-
-Costume *Actor::findCostume(const char *name) {
-	for (std::list<Costume *>::iterator i = _costumeStack.begin(); i != _costumeStack.end(); i++)
-		if (std::strcmp((*i)->filename(), name) == 0)
-			return *i;
-
-	return NULL;
-}
-
-void Actor::update() {
-	// Snap actor to walkboxes if following them.  This might be
-	// necessary for example after activating/deactivating
-	// walkboxes, etc.
-	if (_constrain && !_walking) {
-		g_engine->currScene()->findClosestSector(_pos, NULL, &_pos);
-	}
-
-	if (_turning) {
-		float turnAmt = g_engine->perSecond(_turnRate);
-		float dyaw = _destYaw - _yaw;
-		while (dyaw > 180)
-			dyaw -= 360;
-		while (dyaw < -180)
-			dyaw += 360;
-		// If the actor won't turn because the rate is set to zero then
-		// have the actor turn all the way to the destination yaw.
-		// Without this some actors will lock the interface on changing
-		// scenes, this affects the Bone Wagon in particular.
-		if (turnAmt == 0 || turnAmt >= std::abs(dyaw)) {
-			setYaw(_destYaw);
-			_turning = false;
-		}
-		else if (dyaw > 0)
-			setYaw(_yaw + turnAmt);
-		else
-			setYaw(_yaw -= turnAmt);
-		_currTurnDir = (dyaw > 0 ? 1 : -1);
-	}
-
-	if (_walking) {
-		Vector3d dir = _destPos - _pos;
-		float dist = dir.magnitude();
-
-		if (dist > 0)
-			dir /= dist;
-
-		float walkAmt = g_engine->perSecond(_walkRate);
-
-		if (walkAmt >= dist) {
-			_pos = _destPos;
-			_walking = false;
-// It seems that we need to allow an already active turning motion to
-// continue or else turning actors away from barriers won't work right
-//			_turning = false;
-		} else
-			_pos += dir * walkAmt;
-
-		_walkedCur = true;
-	}
-
-	// The rest chore might have been stopped because of a
-	// StopActorChore(nil).  Restart it if so.
-	if (_restChore >= 0 && _restCostume->isChoring(_restChore, false) < 0)
-		_restCostume->playChoreLooping(_restChore);
-
-	if (_walkChore >= 0) {
-		if (_walkedCur) {
-			if (_walkCostume->isChoring(_walkChore, false) < 0)
-				_walkCostume->playChoreLooping(_walkChore);
-		} else {
-			if (_walkCostume->isChoring(_walkChore, false) >= 0)
-				_walkCostume->stopChore(_walkChore);
-		}
-	}
-
-	if (_leftTurnChore >= 0) {
-		if (_walkedCur)
-			_currTurnDir = 0;
-		if (_lastTurnDir != 0 && _lastTurnDir != _currTurnDir)
-			_turnCostume->stopChore(getTurnChore(_lastTurnDir));
-		if (_currTurnDir != 0 && _currTurnDir != _lastTurnDir)
-			_turnCostume->playChore(getTurnChore(_currTurnDir));
-	} else
-		_currTurnDir = 0;
-
-	_walkedLast = _walkedCur;
-	_walkedCur = false;
-	_lastTurnDir = _currTurnDir;
-	_currTurnDir = 0;
-
-	// Update lip synching
-	if (_lipSynch != NULL) {
-		int posSound;
-		
-		// While getPosIn60HzTicks will return "-1" to indicate that the
-		// sound is no longer playing, it is more appropriate to check first
-		if(g_imuse->getSoundStatus(_talkSoundName.c_str()))
-			posSound = g_imuse->getPosIn60HzTicks(_talkSoundName.c_str());
-		else
-			posSound = -1;
-		if (posSound != -1) {
-			int anim = _lipSynch->getAnim(posSound);
-			if (_talkAnim != anim) {
-				if (_talkAnim != -1 && _talkChore[_talkAnim] >= 0)
-					_talkCostume[_talkAnim]->stopChore(_talkChore[_talkAnim]);
-				if (anim != -1) {
-					_talkAnim = anim;
-					if (_talkChore[_talkAnim] >= 0) {
-						_talkCostume[_talkAnim]->playChoreLooping(_talkChore[_talkAnim]);
-					}
-				}
-			}
-		}
-	}
-
-	for (std::list<Costume *>::iterator i = _costumeStack.begin(); i != _costumeStack.end(); i++) {
-		(*i)->setPosRotate(_pos, _pitch, _yaw, _roll);
-		(*i)->update();
-	}
-
-	if (_lookingMode) {
-		/*float lookAtAmt = */g_engine->perSecond(_lookAtRate);
-	}
-}
-
-void Actor::draw() {
-	for (std::list<Costume *>::iterator i = _costumeStack.begin(); i != _costumeStack.end(); i++)
-		(*i)->setupTextures();
-
-	if (!_costumeStack.empty()) {
-		setupDrawShadow();
-		g_driver->startActorDraw(_pos, _yaw, _pitch, _roll);
-		_costumeStack.back()->draw();
-		g_driver->finishActorDraw();
-		finishDrawShadow();
-	}
-}
-
-// "Undraw objects" (handle objects for actors that may not be on screen)
-void Actor::undraw(bool /*visible*/) {
-	if (!talking() || !g_imuse->isVoicePlaying())
-		shutUp();
-}
-
-#define strmatch(src, dst)     (strlen(src) == strlen(dst) && strcmp(src, dst) == 0)
-
-void Actor::setShadowPlane(const char *name) {
-	assert(_activeShadowSlot != -1);
-
-	_shadowArray[_activeShadowSlot].name = name;
-}
-
-void Actor::addShadowPlane(const char *name) {
-	assert(_activeShadowSlot != -1);
-
-	int numSectors = g_engine->currScene()->getSectorCount();
-
-	for (int i = 0; i < numSectors; i++) {
-		Sector *sector = g_engine->currScene()->getSectorBase(i);
-		if (strmatch(sector->name(), name)) {
-			_shadowArray[_activeShadowSlot].planeList.push_back(sector);
-			return;
-		}
-	}
-}
-
-void Actor::setActiveShadow(int shadowId) {
-	assert(shadowId >= 0 && shadowId <= 4);
-
-	_activeShadowSlot = shadowId;
-}
-
-void Actor::setShadowPoint(Vector3d pos) {
-	assert(_activeShadowSlot != -1);
-
-	_shadowArray[_activeShadowSlot].pos = pos;
-}
-
-void Actor::clearShadowPlanes() {
-	for (int i = 0; i < 5; i++) {
-		Shadow *shadow = &_shadowArray[i];
-		while (!shadow->planeList.empty()) {
-			shadow->planeList.pop_back();
-		}
-	}
-}
-
-void Actor::setupDrawShadow() {
-	if (_activeShadowSlot == -1)
-		return;
-
-	g_driver->setupShadower(_shadowArray);
-}
-
-void Actor::finishDrawShadow() {
-	g_driver->setupShadower(NULL);
-}

Deleted: residual/trunk/actor.h
===================================================================
--- residual/trunk/actor.h	2008-01-26 08:25:27 UTC (rev 30636)
+++ residual/trunk/actor.h	2008-01-26 09:18:08 UTC (rev 30637)
@@ -1,228 +0,0 @@
-/* Residual - Virtual machine to run LucasArts' 3D adventure games
- * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef ACTOR_H
-#define ACTOR_H
-
-#include "color.h"
-#include "vector3d.h"
-#include "resource.h"
-#include "font.h"
-
-#include <string>
-#include <list>
-
-class Costume;
-class LipSynch;
-class TextObject;
-class Sector;
-
-typedef std::list<Sector *> SectorListType;
-
-struct Shadow {
-	std::string name;
-	Vector3d pos;
-	SectorListType planeList;
-	bool active;
-};
-
-class Actor {
-public:
-	Actor(const char *name);
-
-	const char *name() const { return _name.c_str(); }
-
-	void setTalkColor(const Color& c) { _talkColor = c; }
-	Color talkColor() const { return _talkColor; }
-	void setPos(Vector3d pos) { _pos = pos; }
-	// When the actor is walking report where the actor is going to and
-	// not the actual current position, this fixes some scene change
-	// change issues with the Bone Wagon (along with other fixes)
-	Vector3d pos() const {
-		if (_walking)
-			return _destPos;
-		else
-			return _pos;
-	}
-	void walkTo(Vector3d p);
-	void stopWalking() { _walking = false; }
-	bool isWalking() const;
-	void setRot(float pitch, float yaw, float roll);
-	void turnTo(float pitch, float yaw, float roll);
-	bool isTurning() const;
-	float pitch() const { return _pitch; }
-	float yaw() const { return _yaw; }
-	float roll() const { return _roll; }
-	void setVisibility(bool val) { _visible = val; }
-	bool visible() const { return _visible; }
-	// The set should change immediately, otherwise a very rapid set change
-	// for an actor will be recognized incorrectly and the actor will be lost.
-	void putInSet(const char *name) { _setName = name; }
-	void setTurnRate(float rate) { _turnRate = rate; }
-	float turnRate() const { return _turnRate; }
-	void setWalkRate(float rate) { _walkRate = rate; }
-	float walkRate() const { return _walkRate; }
-	void setLooking(bool lookingMode) { _lookingMode = lookingMode; }
-
-	float angleTo(const Actor &a) const;
-	float yawTo(Vector3d p) const;
-
-	bool inSet(const char *name) const {
-		return _setName == name;
-	}
-	void walkForward();
-	void setReflection(float angle) { _reflectionAngle = angle; }
-	Vector3d puckVector() const;
-	void turn(int dir);
-
-	void sayLine(const char *msg, const char *msgId);
-	// When we clean all text objects we don't want the actors to clean their
-	// objects again since they're already freed
-	void lineCleanup() { _sayLineText = NULL; }
-	void shutUp();
-	bool talking();
-
-	void setRestChore(int choreNumber, Costume *cost);
-	void setWalkChore(int choreNumber, Costume *cost);
-	void setTurnChores(int left_chore, int right_chore, Costume *cost);
-	void setTalkChore(int index, int choreNumber, Costume *cost);
-	void setMumbleChore(int choreNumber, Costume *cost);
-
-	void setColormap(const char *map);
-	void pushCostume(const char *name);
-	void setCostume(const char *name);
-	void popCostume();
-	void clearCostumes();
-	Costume *currentCostume() {
-		if (_costumeStack.empty())
-			return NULL;
-		else
-			return _costumeStack.back();
-	}
-	Costume *findCostume(const char *name);
-	int costumeStackDepth() const {
-		return _costumeStack.size();
-	}
-
-	void setActiveShadow(int shadowId);
-	void setShadowPoint(Vector3d pos);
-	void setShadowPlane(const char *name);
-	void addShadowPlane(const char *name);
-	void clearShadowPlanes();
-	void setupDrawShadow();
-	void finishDrawShadow();
-
-	void setConstrain(bool constrain) {
-		_constrain = constrain;
-	}
-	void update();
-	void draw();
-	void undraw(bool);
-
-	bool isLookAtVectorZero() {
-		return _lookAtVector.isZero();
-	}
-	void setLookAtVectorZero() {
-		_lookAtVector.set( 0.f, 0.f, 0.f );
-	}
-	void setLookAtVector(Vector3d vector) {
-		_lookAtVector = vector;
-	}
-	void setLookAtRate(float rate) {
-		_lookAtRate = rate;
-	}
-	float lookAtRate() {
-		return _lookAtRate;
-	}
-	void setHead( int joint1, int joint2, int joint3, float maxRoll, float maxPitch, float maxYaw);
-
-private:
-	std::string _name;
-	std::string _setName;    // The actual current set
-	Color _talkColor;
-	Vector3d _pos;
-	float _pitch, _yaw, _roll;
-	float _walkRate, _turnRate;
-
-	bool _constrain;	// Constrain to walkboxes
-	float _reflectionAngle;	// Maximum angle to turn by at walls
-	bool _visible;
-	bool _lookingMode;
-	std::string _talkSoundName;
-	ResPtr<LipSynch> _lipSynch;
-	std::list<Costume *> _costumeStack;
-
-	// Variables for gradual turning
-	bool _turning;
-	float _destYaw;
-
-	// Variables for walking to a point
-	bool _walking;
-	Vector3d _destPos;
-
-	// chores
-	Costume *_restCostume;
-	int _restChore;
-
-	Costume *_walkCostume;
-	int _walkChore;
-	bool _walkedLast, _walkedCur;
-
-	Costume *_turnCostume;
-	int _leftTurnChore, _rightTurnChore;
-	int _lastTurnDir, _currTurnDir;
-
-	Costume *_talkCostume[10];
-	int _talkChore[10];
-	int _talkAnim;
-
-	Costume *_mumbleCostume;
-	int _mumbleChore;
-
-	Shadow *_shadowArray;
-	int _activeShadowSlot;
-
-	static Font *_sayLineFont;
-	TextObject *_sayLineText;
-
-	// Validate a yaw angle then set it appropriately
-	void setYaw(float yaw);
-
-	int getTurnChore(int dir) {
-		return (dir > 0 ? _rightTurnChore : _leftTurnChore);
-	}
-
-	void freeCostumeChore(Costume *toFree, Costume *&cost, int &chore) {
-		if (cost == toFree) {
-			cost = NULL;
-			chore = -1;
-		}
-	}
-
-	// lookAt
-	Vector3d _lookAtVector;
-	float _lookAtRate;
-
-	friend class Engine;
-};
-
-#endif

Deleted: residual/trunk/bitmap.cpp
===================================================================
--- residual/trunk/bitmap.cpp	2008-01-26 08:25:27 UTC (rev 30636)
+++ residual/trunk/bitmap.cpp	2008-01-26 09:18:08 UTC (rev 30637)
@@ -1,173 +0,0 @@
-/* Residual - Virtual machine to run LucasArts' 3D adventure games
- * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "stdafx.h"
-#include "bits.h"
-#include "debug.h"
-#include "bitmap.h"
-#include "smush.h"
-#include "driver.h"
-
-#include <cstdlib>
-#include <cstring>
-
-static void decompress_codec3(const char *compressed, char *result);
-
-Bitmap::Bitmap(const char *filename, const char *data, int len) :
-		Resource(filename) {
-
-	if (len < 8 || memcmp(data, "BM  F\0\0\0", 8) != 0) {
-		if (debugLevel == DEBUG_BITMAPS || debugLevel == DEBUG_ERROR || debugLevel == DEBUG_ALL)
-			error("Invalid magic loading bitmap\n");
-	}
-
-	strcpy(_filename, filename);
-
-	int codec = READ_LE_UINT32(data + 8);
-//	_paletteIncluded = READ_LE_UINT32(data + 12);
-	_numImages = READ_LE_UINT32(data + 16);
-	_x = READ_LE_UINT32(data + 20);
-	_y = READ_LE_UINT32(data + 24);
-//	_transparentColor = READ_LE_UINT32(data + 28);
-	_format = READ_LE_UINT32(data + 32);
-//	_numBits = READ_LE_UINT32(data + 36);
-//	_blueBits = READ_LE_UINT32(data + 40);
-//	_greenBits = READ_LE_UINT32(data + 44);
-//	_redBits = READ_LE_UINT32(data + 48);
-//	_blueShift = READ_LE_UINT32(data + 52);
-//	_greenShift = READ_LE_UINT32(data + 56);
-//	_redShift = READ_LE_UINT32(data + 60);
-	_width = READ_LE_UINT32(data + 128);
-	_height = READ_LE_UINT32(data + 132);
-	_currImage = 1;
-
-	_data = new char *[_numImages];
-	int pos = 0x88;
-	for (int i = 0; i < _numImages; i++) {
-		_data[i] = new char[2 * _width * _height];
-		if (codec == 0) {
-			memcpy(_data[i], data + pos, 2 * _width * _height);
-			pos += 2 * _width * _height + 8;
-		} else if (codec == 3) {
-			int compressed_len = READ_LE_UINT32(data + pos);
-			decompress_codec3(data + pos + 4, _data[i]);
-			pos += compressed_len + 12;
-		}
-
-#ifdef SYSTEM_BIG_ENDIAN
-		if (_format == 1)
-			for (int j = 0; j < _width * _height; ++j) {
-				((uint16 *)_data[i])[j] = SWAP_BYTES_16(((uint16 *)_data[i])[j]);
-			}
-#endif
-	}
-
-	g_driver->createBitmap(this);
-}
-
-Bitmap::Bitmap(const char *data, int width, int height, const char *filename) :
-		Resource(filename) {
-	if (debugLevel == DEBUG_BITMAPS || debugLevel == DEBUG_NORMAL || debugLevel == DEBUG_ALL)
-		printf("New bitmap loaded: %s\n", filename);
-	strcpy(_filename, filename);
-	_currImage = 1;
-	_numImages = 1;
-	_x = 0;
-	_y = 0;
-	_width = width;
-	_height = height;
-	_format = 1;
-	_numTex = 0;
-	_texIds = NULL;
-	_hasTransparency = false;
-	_data = new char *[_numImages];
-	_data[0] = new char[2 * _width * _height];
-	memcpy(_data[0], data, 2 * _width * _height);
-	g_driver->createBitmap(this);
-}
-
-void Bitmap::draw() const {
-	if (_currImage == 0)
-		return;
-
-	g_driver->drawBitmap(this);
-}
-
-Bitmap::~Bitmap() {
-	if(_data != NULL) {
-		for (int i = 0; i < _numImages; i++)
-			if(_data[i])
-				delete[] _data[i];
-
-		delete[] _data;
-		_data = NULL;
-	}
-	g_driver->destroyBitmap(this);
-}
-
-#define GET_BIT do { bit = bitstr_value & 1; \
-	bitstr_len--; \
-	bitstr_value >>= 1; \
-	if (bitstr_len == 0) { \
-		bitstr_value = READ_LE_UINT16(compressed); \
-		bitstr_len = 16; \
-		compressed += 2; \
-	} \
-} while (0)
-
-static void decompress_codec3(const char *compressed, char *result) {
-	int bitstr_value = READ_LE_UINT16(compressed);
-	int bitstr_len = 16;
-	compressed += 2;
-	bool bit;
-
-	for (;;) {
-		GET_BIT;
-		if (bit == 1)
-			*result++ = *compressed++;
-		else {
-			GET_BIT;
-			int copy_len, copy_offset;
-			if (bit == 0) {
-				GET_BIT;
-				copy_len = 2 * bit;
-				GET_BIT;
-				copy_len += bit + 3;
-				copy_offset = *(uint8 *)(compressed++) - 0x100;
-			} else {
-				copy_offset = (*(uint8 *)(compressed) | (*(uint8 *)(compressed + 1) & 0xf0) << 4) - 0x1000;
-				copy_len = (*(uint8 *)(compressed + 1) & 0xf) + 3;
-				compressed += 2;
-				if (copy_len == 3) {
-					copy_len = *(uint8 *)(compressed++) + 1;
-					if (copy_len == 1)
-						return;
-				}
-			}
-			while (copy_len > 0) {
-				*result = result[copy_offset];
-				result++;
-				copy_len--;
-			}
-		}
-	}
-}

Deleted: residual/trunk/bitmap.h
===================================================================
--- residual/trunk/bitmap.h	2008-01-26 08:25:27 UTC (rev 30636)
+++ residual/trunk/bitmap.h	2008-01-26 09:18:08 UTC (rev 30637)
@@ -1,69 +0,0 @@
-/* Residual - Virtual machine to run LucasArts' 3D adventure games
- * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef BITMAP_H
-#define BITMAP_H
-
-#include "resource.h"
-#include "debug.h"
-
-#include <cstring>
-
-class Bitmap : public Resource {
-public:
-	// Construct a bitmap from the given data.
-	Bitmap(const char *filename, const char *data, int len);
-	Bitmap(const char *data, int width, int height, const char *filename);
-
-	void draw() const;
-
-	// Set which image in an animated bitmap to use
-	void setNumber(int n) { if ((n - 1) >= _numImages) warning("Bitmap::setNumber: no anim image: %d", n); else _currImage = n; }
-
-	int numImages() const { return _numImages; }
-	int currentImage() const { return _currImage; }
-
-	int width() const { return _width; }
-	int height() const { return _height; }
-	int x() const { return _x; }
-	int y() const { return _y; }
-	void setX(int x) { _x = x; }
-	void setY(int y) { _y = y; }
-
-	char *getData() { return _data[_currImage]; }
-
-	char *getFilename() { return _filename; }
-
-	~Bitmap();
-
-//private:
-	char **_data;
-	int _numImages, _currImage;
-	int _width, _height, _x, _y;
-	int _format;
-	int _numTex;
-	void *_texIds;
-	bool _hasTransparency;
-	char _filename[32];
-};
-
-#endif

Deleted: residual/trunk/bits.h
===================================================================
--- residual/trunk/bits.h	2008-01-26 08:25:27 UTC (rev 30636)
+++ residual/trunk/bits.h	2008-01-26 09:18:08 UTC (rev 30637)
@@ -1,388 +0,0 @@
-/* Residual - Virtual machine to run LucasArts' 3D adventure games
- * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef BITS_H
-#define BITS_H
-
-#include "stdafx.h"
-#include "vector3d.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#ifndef __DC__
-#include <SDL_byteorder.h>
-#endif
-
-// Use config.h, generated by configure
-#if defined(HAVE_CONFIG_H)
-#include "config.h"
-#endif
-
-#ifndef PI
-#define PI 3.14159265358979323846
-#endif
-
-#define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0])))
-
-template<typename T> inline T ABS (T x)			{ return (x>=0) ? x : -x; }
-template<typename T> inline T MIN (T a, T b)	{ return (a<b) ? a : b; }
-template<typename T> inline T MAX (T a, T b)	{ return (a>b) ? a : b; }
-
-#ifndef round
-#define round(x) ((x > 0.0) ? floor((x) + 0.5) : ceil((x) - 0.5))
-#endif
-
-#if defined(_MSC_VER)
-
-	#define snprintf _snprintf
-
-	#if defined(CHECK_HEAP)
-	#undef CHECK_HEAP
-	#define CHECK_HEAP checkHeap();
-	#else
-	#define CHECK_HEAP
-	#endif
-
-	#define SYSTEM_LITTLE_ENDIAN
-
-	#define FORCEINLINE __forceinline
-	#define NORETURN _declspec(noreturn)
-
-	typedef unsigned char byte;
-	typedef unsigned char uint8;
-	typedef unsigned short uint16;
-	typedef unsigned long uint32;
-	typedef unsigned int uint;
-	typedef signed char int8;
-	typedef signed short int16;
-	typedef signed long int32;
-	
-	#define START_PACK_STRUCTS pack(push, 1)
-	#define END_PACK_STRUCTS	 pack(pop)
-	#define GCC_PACK
-
-#elif defined(__MINGW32__)
-
-	#define CHECK_HEAP
-	#define SYSTEM_LITTLE_ENDIAN
-
-	#define NORETURN __attribute__((__noreturn__))
-	#define GCC_PACK __attribute__((packed))
-	#define _HEAPOK 0
-
-	typedef unsigned char byte;
-	typedef unsigned char uint8;
-	typedef unsigned short uint16;
-	typedef unsigned int uint32;
-	typedef unsigned int uint;
-	typedef signed char int8;
-	typedef signed short int16;
-	typedef signed int int32;
-
-	#define START_PACK_STRUCTS pack (push, 1)
-	#define END_PACK_STRUCTS	 pack(pop)
-
-#elif defined(UNIX)
-
-	#define CHECK_HEAP
-
-	#ifdef X11_BACKEND
-
-	// You need to set this manually if necessary
-//	#define SYSTEM_LITTLE_ENDIAN
-	
-	#else
-	/* need this for the SDL_BYTEORDER define */
-	#include <SDL_byteorder.h>
-
-	#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-	#define SYSTEM_LITTLE_ENDIAN
-	#elif SDL_BYTEORDER == SDL_BIG_ENDIAN
-	#define SYSTEM_BIG_ENDIAN
-	#else
-	#error Neither SDL_BIG_ENDIAN nor SDL_LIL_ENDIAN is set.
-	#endif
-	#endif
-
-	// You need to set this manually if necessary
-//	#define SYSTEM_NEED_ALIGNMENT
-
-	#define FORCEINLINE inline
-	#define CDECL 
-
-	#ifndef HAVE_CONFIG_H
-	typedef unsigned char byte;
-	typedef unsigned char uint8;
-	typedef unsigned short uint16;
-	typedef unsigned int uint;
-	typedef unsigned int uint32;
-	typedef signed char int8;
-	typedef signed short int16;
-	typedef signed int int32;
-	#endif
-
-	#if defined(__DECCXX) // Assume alpha architecture
-	#define INVERSE_MKID
-	#define SYSTEM_NEED_ALIGNMENT
-	#endif
-
-	#if defined(__GNUC__)
-	#define START_PACK_STRUCTS
-	#define END_PACK_STRUCTS
-	#define GCC_PACK __attribute__((packed))
-	#define NORETURN __attribute__((__noreturn__)) 
-	#else
-	#define START_PACK_STRUCTS pack (1)
-	#define END_PACK_STRUCTS	 pack ()
-	#define GCC_PACK
-	#define NORETURN
-	#endif
-
-	#ifdef __FreeBSD__
-	#undef ROUND
-	#define ROUND(x) rint(x)
-	#endif
-
-	#if defined(__APPLE__) && defined(__MACH__)
-	#define MACOSX
-	#endif
-	
-#elif defined(__MORPHOS__)
-	#define scumm_stricmp stricmp
-	#define scumm_strnicmp strnicmp
-	#define CHECK_HEAP
-
-	#define SYSTEM_BIG_ENDIAN
-	#define SYSTEM_NEED_ALIGNMENT
-
-	#define FORCEINLINE inline
-	#define CDECL
-
-	typedef unsigned char byte;
-	typedef unsigned char uint8;
-	typedef unsigned short uint16;
-	typedef unsigned long uint32;
-	typedef unsigned int uint;
-	typedef signed char int8;
-	typedef signed short int16;
-	typedef signed long int32;
-
-	#if defined(__GNUC__)
-		#define START_PACK_STRUCTS
-		#define END_PACK_STRUCTS
-		#define GCC_PACK __attribute__((packed))
-		#define NORETURN __attribute__((__noreturn__))
-	#else
-		#define START_PACK_STRUCTS pack (1)
-		#define END_PACK_STRUCTS	 pack ()
-		#define GCC_PACK
-		#define NORETURN
-	#endif
-	#define main morphos_main
-
-#elif defined(__DC__)
-
-	#define CHECK_HEAP
-	#define SYSTEM_LITTLE_ENDIAN
-	#define SYSTEM_NEED_ALIGNMENT
-
-	#define FORCEINLINE inline
-	#define NORETURN __attribute__((__noreturn__))
-	#define GCC_PACK __attribute__((packed))
-	#define CDECL
-
-	typedef unsigned char byte;
-	typedef unsigned char uint8;
-	typedef unsigned short uint16;
-	typedef unsigned long uint32;
-	typedef unsigned int uint;
-	typedef signed char int8;
-	typedef signed short int16;
-	typedef signed long int32;
-
-	#define START_PACK_STRUCTS pack (push, 1)
-	#define END_PACK_STRUCTS	 pack(pop)
-
-#else
-	#error No system type defined
-#endif
-
-FORCEINLINE uint32 SWAP_BYTES_32(uint32 a) {
-	return ((a >> 24) & 0x000000FF) |
-		   ((a >>  8) & 0x0000FF00) |
-		   ((a <<  8) & 0x00FF0000) |
-		   ((a << 24) & 0xFF000000);
-}
-
-FORCEINLINE uint16 SWAP_BYTES_16(uint16 a) {
-	return ((a >> 8) & 0x00FF) + ((a << 8) & 0xFF00);
-}
-
-
-#if defined(SYSTEM_LITTLE_ENDIAN)
-
-	#define PROTO_MKID(a) ((uint32) \
-			(((a) >> 24) & 0x000000FF) | \
-			(((a) >>  8) & 0x0000FF00) | \
-			(((a) <<  8) & 0x00FF0000) | \
-			(((a) << 24) & 0xFF000000))
-	#define PROTO_MKID_BE(a) ((uint32)(a))
-
-	#if defined(INVERSE_MKID)
-	#  define MKID(a) PROTO_MKID_BE(a)
-	#  define MKID_BE(a) PROTO_MKID(a)
-	#else
-	#  define MKID(a) PROTO_MKID(a)
-	#  define MKID_BE(a) PROTO_MKID_BE(a)
-	#endif
-
-	#define READ_UINT32(a) READ_LE_UINT32(a)
-
-	#define FROM_LE_32(a) ((uint32)(a))
-	#define FROM_LE_16(a) ((uint16)(a))
-
-	#define TO_LE_32(a) ((uint32)(a))
-	#define TO_LE_16(a) ((uint16)(a))
-
-	#define TO_BE_32(a) SWAP_BYTES_32(a)
-	#define TO_BE_16(a) SWAP_BYTES_16(a)
-
-#elif defined(SYSTEM_BIG_ENDIAN)
-
-	#define MKID(a) ((uint32)(a))
-	#define MKID_BE(a) ((uint32)(a))
-
-	#define READ_UINT32(a) READ_BE_UINT32(a)
-
-	#define FROM_LE_32(a) SWAP_BYTES_32(a)
-	#define FROM_LE_16(a) SWAP_BYTES_16(a)
-
-	#define TO_LE_32(a) SWAP_BYTES_32(a)
-	#define TO_LE_16(a) SWAP_BYTES_16(a)
-
-	#define TO_BE_32(a) ((uint32)(a))
-	#define TO_BE_16(a) ((uint16)(a))
-
-#else
-
-	#error No endianness defined
-
-#endif
-
-
-#if defined(SYSTEM_NEED_ALIGNMENT) || defined(SYSTEM_BIG_ENDIAN)
-	FORCEINLINE uint16 READ_LE_UINT16(const void *ptr) {
-		const byte *b = (const byte *)ptr;
-		return (b[1] << 8) + b[0];
-	}
-	FORCEINLINE uint32 READ_LE_UINT32(const void *ptr) {
-		const byte *b = (const byte *)ptr;
-		return (b[3] << 24) + (b[2] << 16) + (b[1] << 8) + (b[0]);
-	}
-	FORCEINLINE void WRITE_LE_UINT16(void *ptr, uint16 value) {
-		byte *b = (byte *)ptr;
-		b[0] = (byte)(value >> 0);
-		b[1] = (byte)(value >> 8);
-	}
-	FORCEINLINE void WRITE_LE_UINT32(void *ptr, uint32 value) {
-		byte *b = (byte *)ptr;
-		b[0] = (byte)(value >>  0);
-		b[1] = (byte)(value >>  8);
-		b[2] = (byte)(value >> 16);
-		b[3] = (byte)(value >> 24);
-	}
-#else
-	FORCEINLINE uint16 READ_LE_UINT16(const void *ptr) {
-		return *(const uint16 *)(ptr);
-	}
-	FORCEINLINE uint32 READ_LE_UINT32(const void *ptr) {
-		return *(const uint32 *)(ptr);
-	}
-	FORCEINLINE void WRITE_LE_UINT16(void *ptr, uint16 value) {
-		*(uint16 *)(ptr) = value;
-	}
-	FORCEINLINE void WRITE_LE_UINT32(void *ptr, uint32 value) {
-		*(uint32 *)(ptr) = value;
-	}
-#endif
-
-
-#if defined(SYSTEM_NEED_ALIGNMENT) || defined(SYSTEM_LITTLE_ENDIAN)
-	FORCEINLINE uint16 READ_BE_UINT16(const void *ptr) {
-		const byte *b = (const byte *)ptr;
-		return (b[0] << 8) + b[1];
-	}
-	FORCEINLINE uint32 READ_BE_UINT32(const void *ptr) {
-		const byte *b = (const byte*)ptr;
-		return (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + (b[3]);
-	}
-	FORCEINLINE void WRITE_BE_UINT16(void *ptr, uint16 value) {
-		byte *b = (byte *)ptr;
-		b[0] = (byte)(value >> 8);
-		b[1] = (byte)(value >> 0);
-	}
-	FORCEINLINE void WRITE_BE_UINT32(void *ptr, uint32 value) {
-		byte *b = (byte *)ptr;
-		b[0] = (byte)(value >> 24);
-		b[1] = (byte)(value >> 16);
-		b[2] = (byte)(value >>  8);
-		b[3] = (byte)(value >>  0);
-	}
-#else
-	FORCEINLINE uint16 READ_BE_UINT16(const void *ptr) {
-		return *(const uint16 *)(ptr);
-	}
-	FORCEINLINE uint32 READ_BE_UINT32(const void *ptr) {
-		return *(const uint32 *)(ptr);
-	}
-	FORCEINLINE void WRITE_BE_UINT16(void *ptr, uint16 value) {
-		*(uint16 *)(ptr) = value;
-	}
-	FORCEINLINE void WRITE_BE_UINT32(void *ptr, uint32 value) {
-		*(uint32 *)(ptr) = value;
-	}
-#endif
-
-#if defined(SYSTEM_BIG_ENDIAN)
-
-inline float get_float(const char *data) {
-	const unsigned char *udata = reinterpret_cast<const unsigned char *>(data);
-	unsigned char fdata[4];
-	fdata[0] = udata[3];
-	fdata[1] = udata[2];
-	fdata[2] = udata[1];
-	fdata[3] = udata[0];
-	return *(reinterpret_cast<const float *>(fdata));
-}
-
-#else
-
-inline float get_float(const char *data) {
-	return *(reinterpret_cast<const float *>(data));
-}
-#endif
-
-inline Vector3d get_vector3d(const char *data) {
-	return Vector3d(get_float(data), get_float(data + 4), get_float(data + 8));
-}
-
-#endif

Deleted: residual/trunk/blocky16.cpp
===================================================================
--- residual/trunk/blocky16.cpp	2008-01-26 08:25:27 UTC (rev 30636)
+++ residual/trunk/blocky16.cpp	2008-01-26 09:18:08 UTC (rev 30637)
@@ -1,824 +0,0 @@
-/* Residual - Virtual machine to run LucasArts' 3D adventure games
- * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "stdafx.h"
-#include "bits.h"
-#include "debug.h"
-#include "blocky16.h"
-
-#if defined(SYSTEM_NEED_ALIGNMENT)
-
-#define COPY_4X1_LINE(dst, src)			\
-	do {					\
-		(dst)[0] = (src)[0];	\
-		(dst)[1] = (src)[1];	\
-		(dst)[2] = (src)[2];	\
-		(dst)[3] = (src)[3];	\
-	} while (0)
-
-#if defined(SYSTEM_BIG_ENDIAN)
-
-#define WRITE_2X1_LINE(dst, v)		\
-	do {				\
-		(dst)[0] = (byte)((v >> 8) & 0xFF);	\
-		(dst)[1] = (byte)((v >> 0) & 0xFF);	\
-	} while (0)
-
-#define WRITE_4X1_LINE(dst, v)		\
-	do {				\
-		(dst)[0] = (byte)((v >> 24) & 0xFF);	\
-		(dst)[1] = (byte)((v >> 16) & 0XFF);	\
-		(dst)[2] = (byte)((v >>  8) & 0xFF);	\
-		(dst)[3] = (byte)((v >>  0) & 0xFF);	\
-	} while (0)
-
-#else /* SYSTEM_BIG_ENDIAN */
-
-#define WRITE_2X1_LINE(dst, v)		\
-	do {				\
-		(dst)[0] = (byte)((v >> 0) & 0xFF);	\
-		(dst)[1] = (byte)((v >> 8) & 0xFF);	\
-	} while (0)
-
-#define WRITE_4X1_LINE(dst, v)		\
-	do {				\
-		(dst)[0] = (byte)((v >>  0) & 0xFF);	\
-		(dst)[1] = (byte)((v >>  8) & 0XFF);	\
-		(dst)[2] = (byte)((v >> 16) & 0xFF);	\
-		(dst)[3] = (byte)((v >> 24) & 0xFF);	\
-	} while (0)
-
-#endif
-
-#else /* SYSTEM_NEED_ALIGNMENT */
-
-#define COPY_4X1_LINE(dst, src)			\
-	*(uint32 *)(dst) = *(const uint32 *)(src);
-
-#define WRITE_2X1_LINE(dst, v)		\
-	*(uint16 *)(dst) = v;
-
-#define WRITE_4X1_LINE(dst, v)		\
-	*(uint32 *)(dst) = v;
-
-#endif
-
-static int8 blocky16_table_small1[] = {
-	0, 1, 2, 3, 3, 3, 3, 2, 1, 0, 0, 0, 1, 2, 2, 1,
-};
-
-static int8 blocky16_table_small2[] = {
-	0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 2, 1, 1, 1, 2, 2,
-};
-
-static int8 blocky16_table_big1[] = {
-	0, 2, 5, 7, 7, 7, 7, 7, 7, 5, 2, 0, 0, 0, 0, 0,
-};
-
-static int8 blocky16_table_big2[] = {
-	0, 0, 0, 0, 1, 3, 4, 6, 7, 7, 7, 7, 6, 4, 3, 1,
-};
-
-static int8 blocky16_table[] = {
-	  0,   0,  -1, -43,   6, -43,  -9, -42,  13, -41,
-	-16, -40,  19, -39, -23, -36,  26, -34,  -2, -33,
-	  4, -33, -29, -32,  -9, -32,  11, -31, -16, -29,
-	 32, -29,  18, -28, -34, -26, -22, -25,  -1, -25,
-	  3, -25,  -7, -24,   8, -24,  24, -23,  36, -23,
-	-12, -22,  13, -21, -38, -20,   0, -20, -27, -19,
-	 -4, -19,   4, -19, -17, -18,  -8, -17,   8, -17,
-	 18, -17,  28, -17,  39, -17, -12, -15,  12, -15,
-	-21, -14,  -1, -14,   1, -14, -41, -13,  -5, -13,
-	  5, -13,  21, -13, -31, -12, -15, -11,  -8, -11,
-	  8, -11,  15, -11,  -2, -10,   1, -10,  31, -10,
-	-23,  -9, -11,  -9,  -5,  -9,   4,  -9,  11,  -9,
-	 42,  -9,   6,  -8,  24,  -8, -18,  -7,  -7,  -7,
-	 -3,  -7,  -1,  -7,   2,  -7,  18,  -7, -43,  -6,
-	-13,  -6,  -4,  -6,   4,  -6,   8,  -6, -33,  -5,
-	 -9,  -5,  -2,  -5,   0,  -5,   2,  -5,   5,  -5,
-	 13,  -5, -25,  -4,  -6,  -4,  -3,  -4,   3,  -4,
-	  9,  -4, -19,  -3,  -7,  -3,  -4,  -3,  -2,  -3,
-	 -1,  -3,   0,  -3,   1,  -3,   2,  -3,   4,  -3,
-	  6,  -3,  33,  -3, -14,  -2, -10,  -2,  -5,  -2,
-	 -3,  -2,  -2,  -2,  -1,  -2,   0,  -2,   1,  -2,
-	  2,  -2,   3,  -2,   5,  -2,   7,  -2,  14,  -2,
-	 19,  -2,  25,  -2,  43,  -2,  -7,  -1,  -3,  -1,
-	 -2,  -1,  -1,  -1,   0,  -1,   1,  -1,   2,  -1,
-	  3,  -1,  10,  -1,  -5,   0,  -3,   0,  -2,   0,
-	 -1,   0,   1,   0,   2,   0,   3,   0,   5,   0,
-	  7,   0, -10,   1,  -7,   1,  -3,   1,  -2,   1,
-	 -1,   1,   0,   1,   1,   1,   2,   1,   3,   1,
-	-43,   2, -25,   2, -19,   2, -14,   2,  -5,   2,
-	 -3,   2,  -2,   2,  -1,   2,   0,   2,   1,   2,
-	  2,   2,   3,   2,   5,   2,   7,   2,  10,   2,
-	 14,   2, -33,   3,  -6,   3,  -4,   3,  -2,   3,
-	 -1,   3,   0,   3,   1,   3,   2,   3,   4,   3,
-	 19,   3,  -9,   4,  -3,   4,   3,   4,   7,   4,
-	 25,   4, -13,   5,  -5,   5,  -2,   5,   0,   5,
-	  2,   5,   5,   5,   9,   5,  33,   5,  -8,   6,
-	 -4,   6,   4,   6,  13,   6,  43,   6, -18,   7,
-	 -2,   7,   0,   7,   2,   7,   7,   7,  18,   7,
-	-24,   8,  -6,   8, -42,   9, -11,   9,  -4,   9,
-	  5,   9,  11,   9,  23,   9, -31,  10,  -1,  10,
-	  2,  10, -15,  11,  -8,  11,   8,  11,  15,  11,
-	 31,  12, -21,  13,  -5,  13,   5,  13,  41,  13,
-	 -1,  14,   1,  14,  21,  14, -12,  15,  12,  15,
-	-39,  17, -28,  17, -18,  17,  -8,  17,   8,  17,
-	 17,  18,  -4,  19,   0,  19,   4,  19,  27,  19,
-	 38,  20, -13,  21,  12,  22, -36,  23, -24,  23,
-	 -8,  24,   7,  24,  -3,  25,   1,  25,  22,  25,
-	 34,  26, -18,  28, -32,  29,  16,  29, -11,  31,
-	  9,  32,  29,  32,  -4,  33,   2,  33, -26,  34,
-	 23,  36, -19,  39,  16,  40, -13,  41,   9,  42,
-	 -6,  43,   1,  43,   0,   0,   0,   0,   0,   0
-};
-
-void Blocky16::makeTablesInterpolation(int param) {
-	int32 variable1, variable2;
-	int32 b1, b2;
-	int32 value_table47_1_2, value_table47_1_1, value_table47_2_2, value_table47_2_1;
-	int32 tableSmallBig[64], tmp, s;
-	int8 *table47_1 = 0, *table47_2 = 0;
-	int32 *ptr_small_big;
-	byte *ptr;
-	int i, x, y;
-
-	if (param == 8) {
-		table47_1 = blocky16_table_big1;
-		table47_2 = blocky16_table_big2;
-		ptr = _tableBig + 384;
-		for (i = 0; i < 256; i++) {
-			*ptr = 0;
-			ptr += 388;
-		}
-		ptr = _tableBig + 385;
-		for (i = 0; i < 256; i++) {
-			*ptr = 0;
-			ptr += 388;
-		}
-	} else if (param == 4) {
-		table47_1 = blocky16_table_small1;
-		table47_2 = blocky16_table_small2;
-		ptr = _tableSmall + 96;
-		for (i = 0; i < 256; i++) {
-			*ptr = 0;
-			ptr += 128;
-		}
-		ptr = _tableSmall + 97;
-		for (i = 0; i < 256; i++) {
-			*ptr = 0;
-			ptr += 128;
-		}
-	} else {
-		error("Blocky16::makeTablesInterpolation: unknown param %d", param);
-	}
-
-	s = 0;
-	for (x = 0; x < 16; x++) {
-		value_table47_1_1 = table47_1[x];
-		value_table47_2_1 = table47_2[x];
-		for (y = 0; y < 16; y++) {
-			value_table47_1_2 = table47_1[y];
-			value_table47_2_2 = table47_2[y];
-
-			if (value_table47_2_1 == 0) {
-				b1 = 0;
-			} else if (value_table47_2_1 == param - 1) {
-				b1 = 1;
-			} else if (value_table47_1_1 == 0) {
-				b1 = 2;
-			} else if (value_table47_1_1 == param - 1) {
-				b1 = 3;
-			} else {
-				b1 = 4;
-			}
-
-			if (value_table47_2_2 == 0) {
-				b2 = 0;
-			} else if (value_table47_2_2 == param - 1) {
-				b2 = 1;
-			} else if (value_table47_1_2 == 0) {
-				b2 = 2;
-			} else if (value_table47_1_2 == param - 1) {
-				b2 = 3;
-			} else {
-				b2 = 4;
-			}
-			
-			memset(tableSmallBig, 0, param * param * 4);
-
-			variable2 = abs(value_table47_2_2 - value_table47_2_1);
-			tmp = abs(value_table47_1_2 - value_table47_1_1);
-			if (variable2 <= tmp) {
-				variable2 = tmp;
-			}
-
-			for (variable1 = 0; variable1 <= variable2; variable1++) {
-				int32 variable3, variable4;
-
-				if (variable2 > 0) {
-					// Linearly interpolate between value_table47_1_1 and value_table47_1_2
-					// respectively value_table47_2_1 and value_table47_2_2.
-					variable4 = (value_table47_1_1 * variable1 + value_table47_1_2 * (variable2 - variable1) + variable2 / 2) / variable2;
-					variable3 = (value_table47_2_1 * variable1 + value_table47_2_2 * (variable2 - variable1) + variable2 / 2) / variable2;
-				} else {
-					variable4 = value_table47_1_1;
-					variable3 = value_table47_2_1;
-				}
-				ptr_small_big = &tableSmallBig[param * variable3 + variable4];
-				*ptr_small_big = 1;
-
-				if ((b1 == 2 && b2 == 3) || (b2 == 2 && b1 == 3) ||
-				    (b1 == 0 && b2 != 1) || (b2 == 0 && b1 != 1)) {
-					if (variable3 >= 0) {
-						i = variable3 + 1;
-						while (i--) {
-							*ptr_small_big = 1;
-							ptr_small_big -= param;
-						}
-					}
-				} else if ((b2 != 0 && b1 == 1) || (b1 != 0 && b2 == 1)) {
-					if (param > variable3) {
-						i = param - variable3;
-						while (i--) {
-							*ptr_small_big = 1;
-							ptr_small_big += param;
-						}
-					}
-				} else if ((b1 == 2 && b2 != 3) || (b2 == 2 && b1 != 3)) {
-					if (variable4 >= 0) {
-						i = variable4 + 1;
-						while (i--) {
-							*(ptr_small_big--) = 1;
-						}
-					}
-				} else if ((b1 == 0 && b2 == 1) || (b2 == 0 && b1 == 1) ||
-				           (b1 == 3 && b2 != 2) || (b2 == 3 && b1 != 2)) {
-					if (param > variable4) {
-						i = param - variable4;
-						while (i--) {
-							*(ptr_small_big++) = 1;
-						}
-					}
-				}
-			}
-
-			if (param == 8) {
-				for (i = 64 - 1; i >= 0; i--) {
-					if (tableSmallBig[i] != 0) {
-						_tableBig[256 + s + _tableBig[384 + s]] = (byte)i;
-						_tableBig[384 + s]++;
-					} else {
-						_tableBig[320 + s + _tableBig[385 + s]] = (byte)i;
-						_tableBig[385 + s]++;
-					}
-				}
-				s += 388;
-			}
-			if (param == 4) {
-				for (i = 16 - 1; i >= 0; i--) {
-					if (tableSmallBig[i] != 0) {
-						_tableSmall[64 + s + _tableSmall[96 + s]] = (byte)i;
-						_tableSmall[96 + s]++;
-					} else {
-						_tableSmall[80 + s + _tableSmall[97 + s]] = (byte)i;
-						_tableSmall[97 + s]++;
-					}
-				}
-				s += 128;
-			}
-		}
-	}
-}
-
-void Blocky16::makeTables47(int width) {
-	if (_lastTableWidth == width)
-		return;
-
-	_lastTableWidth = width;
-
-	int32 a, c, d;
-	int16 tmp;
-
-	for (int l = 0; l < 512; l += 2) {
-		_table[l / 2] = (int16)(blocky16_table[l + 1] * width + blocky16_table[l]);
-	}
-
-	a = 0;
-	c = 0;
-	do {
-		for (d = 0; d < _tableSmall[96 + c]; d++) {
-			tmp = _tableSmall[64 + c + d];
-			tmp = (int16)((byte)(tmp >> 2) * width + (tmp & 3));
-			_tableSmall[c + d * 2] = (byte)tmp;
-			_tableSmall[c + d * 2 + 1] = tmp >> 8;
-		}
-		for (d = 0; d < _tableSmall[97 + c]; d++) {
-			tmp = _tableSmall[80 + c + d];
-			tmp = (int16)((byte)(tmp >> 2) * width + (tmp & 3));
-			_tableSmall[32 + c + d * 2] = (byte)tmp;
-			_tableSmall[32 + c + d * 2 + 1] = tmp >> 8;
-		}
-		for (d = 0; d < _tableBig[384 + a]; d++) {
-			tmp = _tableBig[256 + a + d];
-			tmp = (int16)((byte)(tmp >> 3) * width + (tmp & 7));
-			_tableBig[a + d * 2] = (byte)tmp;
-			_tableBig[a + d * 2 + 1] = tmp >> 8;
-		}
-		for (d = 0; d < _tableBig[385 + a]; d++) {
-			tmp = _tableBig[320 + a + d];
-			tmp = (int16)((byte)(tmp >> 3) * width + (tmp & 7));
-			_tableBig[128 + a + d * 2] = (byte)tmp;
-			_tableBig[128 + a + d * 2 + 1] = tmp >> 8;
-		}
-		
-		a += 388;
-		c += 128;
-	} while (c < 32768);
-}
-
-void Blocky16::level3(byte *d_dst) {
-	int32 tmp2;
-	uint32 t;
-	byte code = *_d_src++;
-	int i;
-
-	if (code <= 0xF5) {
-		if (code == 0xF5) {
-			int16 tmp = READ_LE_UINT16(_d_src);
-			tmp2 = tmp * 2;
-			_d_src += 2;
-		} else {
-			tmp2 = _table[code] * 2;
-		}
-		tmp2 += _offset1;
-		for (i = 0; i < 2; i++) {
-			COPY_4X1_LINE(d_dst + 0, d_dst + tmp2 + 0);
-			d_dst += _d_pitch;
-		}
-	} else if ((code == 0xFF) || (code == 0xF8)) {
-		WRITE_2X1_LINE(d_dst + 0, READ_LE_UINT16(_d_src + 0)); 
-		WRITE_2X1_LINE(d_dst + 2, READ_LE_UINT16(_d_src + 2)); 
-		d_dst += _d_pitch;
-		WRITE_2X1_LINE(d_dst + 0, READ_LE_UINT16(_d_src + 4)); 
-		WRITE_2X1_LINE(d_dst + 2, READ_LE_UINT16(_d_src + 6)); 
-		_d_src += 8;
-	} else if (code == 0xFD) {
-		t = *_d_src++;
-		t = READ_LE_UINT16(_param6_7Ptr + t * 2);
-		t = (t << 16) | t;
-		for (i = 0; i < 2; i++) {
-			WRITE_4X1_LINE(d_dst + 0, t);
-			d_dst += _d_pitch;
-		}
-	} else if (code == 0xFE) {
-		t = READ_LE_UINT16(_d_src);
-		_d_src += 2;
-		t = (t << 16) | t;
-		for (i = 0; i < 2; i++) {
-			WRITE_4X1_LINE(d_dst + 0, t);
-			d_dst += _d_pitch;
-		}
-	} else if (code == 0xF6) {
-		tmp2 = _offset2;
-		for (i = 0; i < 2; i++) {
-			COPY_4X1_LINE(d_dst + 0, d_dst + tmp2 + 0);
-			d_dst += _d_pitch;
-		}
-	} else if (code == 0xF7) {
-		tmp2 = READ_LE_UINT32(_d_src);
-		_d_src += 4;
-		WRITE_2X1_LINE(d_dst + 0, READ_LE_UINT16(_param6_7Ptr + (byte)tmp2 * 2));
-		WRITE_2X1_LINE(d_dst + 2, READ_LE_UINT16(_param6_7Ptr + (byte)(tmp2 >> 8) * 2));
-		tmp2 >>= 16;
-		d_dst += _d_pitch;
-		WRITE_2X1_LINE(d_dst + 0, READ_LE_UINT16(_param6_7Ptr + (byte)tmp2 * 2));
-		WRITE_2X1_LINE(d_dst + 2, READ_LE_UINT16(_param6_7Ptr + (byte)(tmp2 >> 8) * 2));
-	} else if ((code >= 0xF9) && (code <= 0xFC))  {
-		t = READ_LE_UINT16(_paramPtr + code * 2);
-		t = (t << 16) | t;
-		for (i = 0; i < 2; i++) {
-			WRITE_4X1_LINE(d_dst + 0, t); 
-			d_dst += _d_pitch;
-		}
-	}
-}
-
-void Blocky16::level2(byte *d_dst) {
-	int32 tmp2;
-	uint32 t, val;
-	byte code = *_d_src++;
-	int i;
-
-	if (code <= 0xF5) {
-		if (code == 0xF5) {
-			int16 tmp = READ_LE_UINT16(_d_src);
-			tmp2 = tmp * 2;
-			_d_src += 2;
-		} else {
-			tmp2 = _table[code] * 2;
-		}
-		tmp2 += _offset1;
-		for (i = 0; i < 4; i++) {
-			COPY_4X1_LINE(d_dst +  0, d_dst + tmp2 +  0);
-			COPY_4X1_LINE(d_dst +  4, d_dst + tmp2 +  4);
-			d_dst += _d_pitch;
-		}
-	} else if (code == 0xFF) {
-		level3(d_dst);
-		d_dst += 4;
-		level3(d_dst);
-		d_dst += _d_pitch * 2 - 4;
-		level3(d_dst);
-		d_dst += 4;
-		level3(d_dst);
-	} else if (code == 0xF6) {
-		tmp2 = _offset2;
-		for (i = 0; i < 4; i++) {
-			COPY_4X1_LINE(d_dst +  0, d_dst + tmp2 +  0);
-			COPY_4X1_LINE(d_dst +  4, d_dst + tmp2 +  4);
-			d_dst += _d_pitch;
-		}
-	} else if ((code == 0xF7) || (code == 0xF8)) {
-		byte tmp = *_d_src++;
-		if (code == 0xF8) {
-			val = READ_LE_UINT32(_d_src);
-			_d_src += 4;
-		} else {
-			tmp2 = READ_LE_UINT16(_d_src);
-			val = READ_LE_UINT16(_param6_7Ptr + (byte)(tmp2 >> 8) * 2) << 16;
-			val |= READ_LE_UINT16(_param6_7Ptr + (byte)tmp2 * 2);
-			_d_src += 2;
-		}
-		byte *tmp_ptr = _tableSmall + (tmp * 128);
-		byte l = tmp_ptr[96];
-		int16 *tmp_ptr2 = (int16 *)tmp_ptr;
-		while (l--) {
-			WRITE_2X1_LINE(d_dst + READ_LE_UINT16(tmp_ptr2) * 2, val); 
-			tmp_ptr2++;
-		}
-		l = tmp_ptr[97];
-		val >>= 16;
-		tmp_ptr2 = (int16 *)(tmp_ptr + 32);
-		while (l--) {
-			WRITE_2X1_LINE(d_dst + READ_LE_UINT16(tmp_ptr2) * 2, val);
-			tmp_ptr2++;
-		}
-	} else if (code >= 0xF9) {
-		if (code == 0xFD) {
-			t = *_d_src++;
-			t = READ_LE_UINT16(_param6_7Ptr + t * 2);
-			t = (t << 16) | t;
-		} else if (code == 0xFE) {
-			t = READ_LE_UINT16(_d_src);
-			t = (t << 16) | t;
-			_d_src += 2;
-		} else if ((code >= 0xF9) && (code <= 0xFC))  {
-			t = READ_LE_UINT16(_paramPtr + code * 2);
-			t = (t << 16) | t;
-		}
-		for (i = 0; i < 4; i++) {
-			WRITE_4X1_LINE(d_dst + 0, t);
-			WRITE_4X1_LINE(d_dst + 4, t);
-			d_dst += _d_pitch;
-		}
-	}
-}
-
-void Blocky16::level1(byte *d_dst) {
-	int32 tmp2;
-	uint32 t, val;
-	byte code = *_d_src++;
-	int i;
-
-	if (code <= 0xF5) {
-		if (code == 0xF5) {
-			int16 tmp = READ_LE_UINT16(_d_src);
-			tmp2 = tmp * 2;
-			_d_src += 2;
-		} else {
-			tmp2 = _table[code] * 2;
-		}
-		tmp2 += _offset1;
-		for (i = 0; i < 8; i++) {
-			COPY_4X1_LINE(d_dst +  0, d_dst + tmp2 +  0);
-			COPY_4X1_LINE(d_dst +  4, d_dst + tmp2 +  4);
-			COPY_4X1_LINE(d_dst +  8, d_dst + tmp2 +  8);
-			COPY_4X1_LINE(d_dst + 12, d_dst + tmp2 + 12);
-			d_dst += _d_pitch;
-		}
-	} else if (code == 0xFF) {
-		level2(d_dst);
-		d_dst += 8;
-		level2(d_dst);
-		d_dst += _d_pitch * 4 - 8;
-		level2(d_dst);
-		d_dst += 8;
-		level2(d_dst);
-	} else if (code == 0xF6) {
-		tmp2 = _offset2;
-		for (i = 0; i < 8; i++) {
-			COPY_4X1_LINE(d_dst +  0, d_dst + tmp2 +  0);
-			COPY_4X1_LINE(d_dst +  4, d_dst + tmp2 +  4);
-			COPY_4X1_LINE(d_dst +  8, d_dst + tmp2 +  8);
-			COPY_4X1_LINE(d_dst + 12, d_dst + tmp2 + 12);
-			d_dst += _d_pitch;
-		}
-	} else if ((code == 0xF7) || (code == 0xF8)) {
-		byte tmp = *_d_src++;
-		if (code == 0xF8) {
-			val = READ_LE_UINT32(_d_src);
-			_d_src += 4;
-		} else {
-			tmp2 = READ_LE_UINT16(_d_src);
-			val = READ_LE_UINT16(_param6_7Ptr + (byte)(tmp2 >> 8) * 2) << 16;
-			val |= READ_LE_UINT16(_param6_7Ptr + (byte)tmp2 * 2);
-			_d_src += 2;
-		}
-		byte *tmp_ptr = _tableBig + (tmp * 388);
-		byte l = tmp_ptr[384];
-		int16 *tmp_ptr2 = (int16 *)tmp_ptr;
-		while (l--) {
-			WRITE_2X1_LINE(d_dst + READ_LE_UINT16(tmp_ptr2) * 2, val);
-			tmp_ptr2++;
-		}
-		l = tmp_ptr[385];
-		val >>= 16;
-		tmp_ptr2 = (int16 *)(tmp_ptr + 128);
-		while (l--) {
-			WRITE_2X1_LINE(d_dst + READ_LE_UINT16(tmp_ptr2) * 2, val); 
-			tmp_ptr2++;
-		}
-	} else if (code >= 0xF9) {
-		if (code == 0xFD) {
-			t = *_d_src++;
-			t = READ_LE_UINT16(_param6_7Ptr + t * 2);
-			t = (t << 16) | t;
-		} else if (code == 0xFE) {
-			t = READ_LE_UINT16(_d_src);
-			t = (t << 16) | t;
-			_d_src += 2;
-		} else if ((code >= 0xF9) && (code <= 0xFC))  {
-			t = READ_LE_UINT16(_paramPtr + code * 2);
-			t = (t << 16) | t;
-		}
-		for (i = 0; i < 8; i++) {
-			WRITE_4X1_LINE(d_dst +  0, t);
-			WRITE_4X1_LINE(d_dst +  4, t);
-			WRITE_4X1_LINE(d_dst +  8, t);
-			WRITE_4X1_LINE(d_dst + 12, t);
-			d_dst += _d_pitch;
-		}
-	}
-}
-
-void Blocky16::decode2(byte *dst, const byte *src, int width, int height, const byte *param_ptr, const byte *param6_7_ptr) {
-	_d_src = src;
-	_paramPtr = param_ptr - 0xf9 - 0xf9;
-	_param6_7Ptr = param6_7_ptr;
-	int bw = (width + 7) / 8;
-	int bh = (height + 7) / 8;
-	int next_line = width * 2 * 7;
-	_d_pitch = width * 2;
-
-	do {
-		int tmp_bw = bw;
-		do {
-			level1(dst);
-			dst += 16;
-		} while (--tmp_bw);
-		dst += next_line;
-	} while (--bh);
-}
-
-void Blocky16::init(int width, int height) {
-	deinit();
-	_width = width;
-	_height = height;
-	makeTablesInterpolation(4);
-	makeTablesInterpolation(8);
-
-	_frameSize = _width * _height * 2;
-	// workaround for read over buffer by increasing buffer
-	// 200 bytes is enough for smush anims:
-	// lol, byeruba, crushed, eldepot, heltrain, hostage
-	// but for tb_kitty.snm 5700 bytes is needed
-	_deltaSize = _frameSize * 3 + 5700;
-	_deltaBuf = (byte *)malloc(_deltaSize);
-	memset(_deltaBuf, 0, _deltaSize);
-	_deltaBufs[0] = _deltaBuf;
-	_deltaBufs[1] = _deltaBuf + _frameSize;
-	_curBuf = _deltaBuf + _frameSize * 2;
-}
-
-Blocky16::Blocky16() {
-	_tableBig = (byte *)malloc(99328);
-	_tableSmall = (byte *)malloc(32768);
-	memset(_tableBig, 0, 99328);
-	memset(_tableSmall, 0, 32768);
-	_deltaBuf = NULL;
-}
-
-void Blocky16::deinit() {
-	_lastTableWidth = -1;
-	if (_deltaBuf) {
-		free(_deltaBuf);
-		_deltaSize = 0;
-		_deltaBuf = NULL;
-		_deltaBufs[0] = NULL;
-		_deltaBufs[1] = NULL;
-	}
-}
-
-Blocky16::~Blocky16() {
-	deinit();
-	if (_tableBig) {
-		free(_tableBig);
-		_tableBig = NULL;
-	}
-	if (_tableSmall) {
-		free(_tableSmall);
-		_tableSmall = NULL;
-	}
-}
-
-static int bomp_left;
-static int bomp_num;
-static int bomp_color;
-static const byte *bomp_src;
-
-static byte bompDecode() {
-	byte code, result;
-	const byte *src;
-
-	if (bomp_left == 2) {
-		src = bomp_src;
-		bomp_num = (*src >> 1) + 1;
-		code = *(src++) & 1;
-		bomp_src = src;
-		if (code != 0) {
-			bomp_left = 1;
-			bomp_color = *src++;
-			bomp_src = src;
-		} else {
-			bomp_left = 0;
-		}
-	} else {
-		src = bomp_src;
-	}
-	if (bomp_left != 0) {
-		if (bomp_left - 1 == 0) {
-			result = bomp_color;
-		} else {
-			result = 255;
-		}
-	} else {
-		result = *(src++);
-		bomp_src = src;
-	}
-
-	bomp_num--;
-	if (bomp_num == 0) {
-		bomp_left = 2;
-	}
-	
-	return result;
-}
-
-static void bompInit(const byte *src) {
-	bomp_left = 2;
-	bomp_src = src;
-}
-
-static void bompDecodeMain(byte *dst, const byte *src, int size) {
-	size /= 2;
-	bompInit(src);
-	while (size--) {
-#ifdef SYSTEM_BIG_ENDIAN
-		*(dst + 1) = bompDecode();
-		*(dst + 0) = bompDecode();
-#else
-		*(dst + 0) = bompDecode();
-		*(dst + 1) = bompDecode();
-#endif
-		dst += 2;
-	}
-}
-
-void Blocky16::decode(byte *dst, const byte *src) {
-	_offset1 = ((_deltaBufs[1] - _curBuf) / 2) * 2;
-	_offset2 = ((_deltaBufs[0] - _curBuf) / 2) * 2;
-
-	int32 seq_nb = READ_LE_UINT16(src + 16);
-
-	const byte *gfx_data = src + 560;
-
-	if (seq_nb == 0) {
-		makeTables47(_width);
-		if (src[32] == src[33]) {
-			memset(_deltaBufs[0], src[32], _frameSize);
-			memset(_deltaBufs[1], src[32], _frameSize);
-		} else {
-			int count = _frameSize / 2;
-			uint16 *ptr1 = (uint16 *)_deltaBufs[0];
-			uint16 *ptr2 = (uint16 *)_deltaBufs[1];
-			uint16 val = READ_LE_UINT16(src + 32);
-			while (count--) {
-				*(uint16 *)(ptr1++) = val;
-				*(uint16 *)(ptr2++) = val;
-			};
-		
-		}
-		_prevSeqNb = -1;
-	}
-
-	switch(src[18]) {
-	case 0:
-#if defined(SYSTEM_BIG_ENDIAN)
-		for (int i = 0; i < _width * _height; i++) {
-			((uint16 *)_curBuf)[i] = READ_LE_UINT16(gfx_data + i * 2);
-		}
-#else
-		memcpy(_curBuf, gfx_data, _frameSize);
-#endif
-		break;
-	case 1:
-		error("blocky16: not implemented decode1 proc");
-		break;
-	case 2:
-		if (seq_nb == _prevSeqNb + 1) {
-			decode2(_curBuf, gfx_data, _width, _height, src + 24, src + 40);
-		}
-		
-		break;
-	case 3:
-		memcpy(_curBuf, _deltaBufs[1], _frameSize);
-		break;
-	case 4:
-		memcpy(_curBuf, _deltaBufs[0], _frameSize);
-		break;
-	case 5:
-		bompDecodeMain(_curBuf, gfx_data, READ_LE_UINT32(src + 36));
-		break;
-	case 6:
-		{
-			int count = _frameSize / 2;
-			uint16 *ptr = (uint16 *)_curBuf;
-			while (count--) {
-				int offset = *gfx_data++ * 2;
-				*(uint16 *)ptr++ = READ_LE_UINT16(src + 40 + offset);
-			};
-			break;
-		}
-	case 7:
-		error("blocky16: not implemented decode7 proc");
-		break;
-	case 8:
-		{
-			bompInit(gfx_data);
-			int count = _frameSize / 2;
-			uint16 *ptr = (uint16 *)_curBuf;
-			while (count--) {
-				int offset = bompDecode() * 2;
-				*(uint16 *)ptr++ = READ_LE_UINT16(src + 40 + offset);
-			};
-			break;
-		}
-	}
-
-	memcpy(dst, _curBuf, _frameSize);
-
-	if (seq_nb == _prevSeqNb + 1) {
-		byte *tmp_ptr = NULL;
-		if (src[19] == 1) {
-			tmp_ptr = _curBuf;
-			_curBuf = _deltaBufs[1];
-			_deltaBufs[1] = tmp_ptr;
-		} else if (src[19] == 2) {
-			tmp_ptr = _deltaBufs[0];
-			_deltaBufs[0] = _deltaBufs[1];
-			_deltaBufs[1] = _curBuf;
-			_curBuf = tmp_ptr;
-		}
-	}
-	_prevSeqNb = seq_nb;
-}

Deleted: residual/trunk/blocky16.h
===================================================================
--- residual/trunk/blocky16.h	2008-01-26 08:25:27 UTC (rev 30636)
+++ residual/trunk/blocky16.h	2008-01-26 09:18:08 UTC (rev 30637)
@@ -1,61 +0,0 @@
-/* Residual - Virtual machine to run LucasArts' 3D adventure games
- * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef BLOCKY16_H
-#define BLOCKY16_H
-
-#include "bits.h"
-
-class Blocky16 {
-private:
-
-	int32 _deltaSize;
-	byte *_deltaBufs[2];
-	byte *_deltaBuf;
-	byte *_curBuf;
-	int32 _prevSeqNb;
-	int _lastTableWidth;
-	const byte *_d_src, *_paramPtr, *_param6_7Ptr;
-	int _d_pitch;
-	int32 _offset1, _offset2;
-	byte *_tableBig;
-	byte *_tableSmall;
-	int16 _table[256];
-	int32 _frameSize;
-	int _width, _height;
-
-	void makeTablesInterpolation(int param);
-	void makeTables47(int width);
-	void level1(byte *d_dst);
-	void level2(byte *d_dst);
-	void level3(byte *d_dst);
-	void decode2(byte *dst, const byte *src, int width, int height, const byte *param_ptr, const byte *param6_7_ptr);
-
-public:
-	Blocky16();
-	~Blocky16();
-	void init(int width, int height);
-	void deinit();
-	void decode(byte *dst, const byte *src);
-};
-
-#endif

Deleted: residual/trunk/color.h
===================================================================
--- residual/trunk/color.h	2008-01-26 08:25:27 UTC (rev 30636)
+++ residual/trunk/color.h	2008-01-26 09:18:08 UTC (rev 30637)
@@ -1,57 +0,0 @@
-/* Residual - Virtual machine to run LucasArts' 3D adventure games
- * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef COLOR_H
-#define COLOR_H
-
-#include "bits.h"
-
-class Color {
-public:
-	byte _vals[3];
-
-	Color() {}
-	Color(byte r, byte g, byte b) {
-		_vals[0] = r; _vals[1] = g; _vals[2] = b;
-	}
-	Color(const Color& c) {
-		_vals[0] = c._vals[0]; _vals[1] = c._vals[1]; _vals[2] = c._vals[2];
-	}
-	byte &red() { return _vals[0]; }
-	byte red() const { return _vals[0]; }
-	byte &green() { return _vals[1]; }
-	byte green() const { return _vals[1]; }
-	byte &blue() { return _vals[2]; }
-	byte blue() const { return _vals[2]; }
-
-	Color& operator =(const Color &c) {
-		_vals[0] = c._vals[0]; _vals[1] = c._vals[1]; _vals[2] = c._vals[2];
-		return *this;
-	}
-
-	Color& operator =(Color *c) {
-		_vals[0] = c->_vals[0]; _vals[1] = c->_vals[1]; _vals[2] = c->_vals[2];
-		return *this;
-	}
-};
-
-#endif

Deleted: residual/trunk/colormap.h
===================================================================
--- residual/trunk/colormap.h	2008-01-26 08:25:27 UTC (rev 30636)
+++ residual/trunk/colormap.h	2008-01-26 09:18:08 UTC (rev 30637)
@@ -1,45 +0,0 @@
-/* Residual - Virtual machine to run LucasArts' 3D adventure games
- * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef COLORMAP_H
-#define COLORMAP_H
-
-#include "debug.h"
-#include "resource.h"
-
-#include <cstring>
-
-class CMap : public Resource {
-public:
-	// Load a colormap from the given data.
-	CMap(const char *filename, const char *data, int len) :
-		Resource(filename) {
-	if (len < 4 || std::memcmp(data, "CMP ", 4) != 0)
-		error("Invalid magic loading colormap\n");
-		std::memcpy(_colors, data + 64, sizeof(_colors));
-	}
-
-	// The color data, in RGB format
-	char _colors[256 * 3];
-};
-
-#endif

Copied: residual/trunk/common/bits.h (from rev 30636, residual/trunk/bits.h)
===================================================================
--- residual/trunk/common/bits.h	                        (rev 0)
+++ residual/trunk/common/bits.h	2008-01-26 09:18:08 UTC (rev 30637)
@@ -0,0 +1,388 @@
+/* Residual - Virtual machine to run LucasArts' 3D adventure games
+ * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef BITS_H
+#define BITS_H
+
+#include "stdafx.h"
+#include "vector3d.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#ifndef __DC__
+#include <SDL_byteorder.h>
+#endif
+
+// Use config.h, generated by configure
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
+#ifndef PI
+#define PI 3.14159265358979323846
+#endif
+
+#define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0])))
+
+template<typename T> inline T ABS (T x)			{ return (x>=0) ? x : -x; }
+template<typename T> inline T MIN (T a, T b)	{ return (a<b) ? a : b; }
+template<typename T> inline T MAX (T a, T b)	{ return (a>b) ? a : b; }
+
+#ifndef round
+#define round(x) ((x > 0.0) ? floor((x) + 0.5) : ceil((x) - 0.5))
+#endif
+
+#if defined(_MSC_VER)
+
+	#define snprintf _snprintf
+
+	#if defined(CHECK_HEAP)
+	#undef CHECK_HEAP
+	#define CHECK_HEAP checkHeap();
+	#else
+	#define CHECK_HEAP
+	#endif
+
+	#define SYSTEM_LITTLE_ENDIAN
+
+	#define FORCEINLINE __forceinline
+	#define NORETURN _declspec(noreturn)
+
+	typedef unsigned char byte;
+	typedef unsigned char uint8;
+	typedef unsigned short uint16;
+	typedef unsigned long uint32;
+	typedef unsigned int uint;
+	typedef signed char int8;
+	typedef signed short int16;
+	typedef signed long int32;
+	
+	#define START_PACK_STRUCTS pack(push, 1)
+	#define END_PACK_STRUCTS	 pack(pop)
+	#define GCC_PACK
+
+#elif defined(__MINGW32__)
+
+	#define CHECK_HEAP
+	#define SYSTEM_LITTLE_ENDIAN
+
+	#define NORETURN __attribute__((__noreturn__))
+	#define GCC_PACK __attribute__((packed))
+	#define _HEAPOK 0
+
+	typedef unsigned char byte;
+	typedef unsigned char uint8;
+	typedef unsigned short uint16;
+	typedef unsigned int uint32;
+	typedef unsigned int uint;
+	typedef signed char int8;
+	typedef signed short int16;
+	typedef signed int int32;
+
+	#define START_PACK_STRUCTS pack (push, 1)
+	#define END_PACK_STRUCTS	 pack(pop)
+
+#elif defined(UNIX)
+
+	#define CHECK_HEAP
+
+	#ifdef X11_BACKEND
+
+	// You need to set this manually if necessary
+//	#define SYSTEM_LITTLE_ENDIAN
+	
+	#else
+	/* need this for the SDL_BYTEORDER define */
+	#include <SDL_byteorder.h>
+
+	#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+	#define SYSTEM_LITTLE_ENDIAN
+	#elif SDL_BYTEORDER == SDL_BIG_ENDIAN
+	#define SYSTEM_BIG_ENDIAN
+	#else
+	#error Neither SDL_BIG_ENDIAN nor SDL_LIL_ENDIAN is set.
+	#endif
+	#endif
+
+	// You need to set this manually if necessary
+//	#define SYSTEM_NEED_ALIGNMENT
+
+	#define FORCEINLINE inline
+	#define CDECL 
+
+	#ifndef HAVE_CONFIG_H
+	typedef unsigned char byte;
+	typedef unsigned char uint8;
+	typedef unsigned short uint16;
+	typedef unsigned int uint;
+	typedef unsigned int uint32;
+	typedef signed char int8;
+	typedef signed short int16;
+	typedef signed int int32;
+	#endif
+
+	#if defined(__DECCXX) // Assume alpha architecture
+	#define INVERSE_MKID
+	#define SYSTEM_NEED_ALIGNMENT
+	#endif
+
+	#if defined(__GNUC__)
+	#define START_PACK_STRUCTS
+	#define END_PACK_STRUCTS
+	#define GCC_PACK __attribute__((packed))
+	#define NORETURN __attribute__((__noreturn__)) 
+	#else
+	#define START_PACK_STRUCTS pack (1)
+	#define END_PACK_STRUCTS	 pack ()
+	#define GCC_PACK
+	#define NORETURN
+	#endif
+
+	#ifdef __FreeBSD__
+	#undef ROUND
+	#define ROUND(x) rint(x)
+	#endif
+
+	#if defined(__APPLE__) && defined(__MACH__)
+	#define MACOSX
+	#endif
+	
+#elif defined(__MORPHOS__)
+	#define scumm_stricmp stricmp
+	#define scumm_strnicmp strnicmp
+	#define CHECK_HEAP
+
+	#define SYSTEM_BIG_ENDIAN
+	#define SYSTEM_NEED_ALIGNMENT
+
+	#define FORCEINLINE inline
+	#define CDECL
+
+	typedef unsigned char byte;
+	typedef unsigned char uint8;
+	typedef unsigned short uint16;
+	typedef unsigned long uint32;
+	typedef unsigned int uint;
+	typedef signed char int8;
+	typedef signed short int16;
+	typedef signed long int32;
+
+	#if defined(__GNUC__)
+		#define START_PACK_STRUCTS
+		#define END_PACK_STRUCTS
+		#define GCC_PACK __attribute__((packed))
+		#define NORETURN __attribute__((__noreturn__))
+	#else
+		#define START_PACK_STRUCTS pack (1)
+		#define END_PACK_STRUCTS	 pack ()
+		#define GCC_PACK
+		#define NORETURN
+	#endif
+	#define main morphos_main
+
+#elif defined(__DC__)
+
+	#define CHECK_HEAP
+	#define SYSTEM_LITTLE_ENDIAN
+	#define SYSTEM_NEED_ALIGNMENT
+
+	#define FORCEINLINE inline
+	#define NORETURN __attribute__((__noreturn__))
+	#define GCC_PACK __attribute__((packed))
+	#define CDECL
+
+	typedef unsigned char byte;
+	typedef unsigned char uint8;
+	typedef unsigned short uint16;
+	typedef unsigned long uint32;
+	typedef unsigned int uint;
+	typedef signed char int8;
+	typedef signed short int16;
+	typedef signed long int32;
+
+	#define START_PACK_STRUCTS pack (push, 1)
+	#define END_PACK_STRUCTS	 pack(pop)
+
+#else
+	#error No system type defined
+#endif
+
+FORCEINLINE uint32 SWAP_BYTES_32(uint32 a) {
+	return ((a >> 24) & 0x000000FF) |
+		   ((a >>  8) & 0x0000FF00) |
+		   ((a <<  8) & 0x00FF0000) |
+		   ((a << 24) & 0xFF000000);
+}
+
+FORCEINLINE uint16 SWAP_BYTES_16(uint16 a) {
+	return ((a >> 8) & 0x00FF) + ((a << 8) & 0xFF00);
+}
+
+
+#if defined(SYSTEM_LITTLE_ENDIAN)
+
+	#define PROTO_MKID(a) ((uint32) \
+			(((a) >> 24) & 0x000000FF) | \
+			(((a) >>  8) & 0x0000FF00) | \
+			(((a) <<  8) & 0x00FF0000) | \
+			(((a) << 24) & 0xFF000000))
+	#define PROTO_MKID_BE(a) ((uint32)(a))
+
+	#if defined(INVERSE_MKID)
+	#  define MKID(a) PROTO_MKID_BE(a)
+	#  define MKID_BE(a) PROTO_MKID(a)
+	#else
+	#  define MKID(a) PROTO_MKID(a)
+	#  define MKID_BE(a) PROTO_MKID_BE(a)
+	#endif
+
+	#define READ_UINT32(a) READ_LE_UINT32(a)
+
+	#define FROM_LE_32(a) ((uint32)(a))
+	#define FROM_LE_16(a) ((uint16)(a))
+
+	#define TO_LE_32(a) ((uint32)(a))
+	#define TO_LE_16(a) ((uint16)(a))
+
+	#define TO_BE_32(a) SWAP_BYTES_32(a)
+	#define TO_BE_16(a) SWAP_BYTES_16(a)
+
+#elif defined(SYSTEM_BIG_ENDIAN)
+
+	#define MKID(a) ((uint32)(a))
+	#define MKID_BE(a) ((uint32)(a))
+
+	#define READ_UINT32(a) READ_BE_UINT32(a)
+
+	#define FROM_LE_32(a) SWAP_BYTES_32(a)
+	#define FROM_LE_16(a) SWAP_BYTES_16(a)
+
+	#define TO_LE_32(a) SWAP_BYTES_32(a)
+	#define TO_LE_16(a) SWAP_BYTES_16(a)
+
+	#define TO_BE_32(a) ((uint32)(a))
+	#define TO_BE_16(a) ((uint16)(a))
+
+#else
+
+	#error No endianness defined
+
+#endif
+
+
+#if defined(SYSTEM_NEED_ALIGNMENT) || defined(SYSTEM_BIG_ENDIAN)
+	FORCEINLINE uint16 READ_LE_UINT16(const void *ptr) {
+		const byte *b = (const byte *)ptr;
+		return (b[1] << 8) + b[0];
+	}
+	FORCEINLINE uint32 READ_LE_UINT32(const void *ptr) {
+		const byte *b = (const byte *)ptr;
+		return (b[3] << 24) + (b[2] << 16) + (b[1] << 8) + (b[0]);
+	}
+	FORCEINLINE void WRITE_LE_UINT16(void *ptr, uint16 value) {
+		byte *b = (byte *)ptr;
+		b[0] = (byte)(value >> 0);
+		b[1] = (byte)(value >> 8);
+	}
+	FORCEINLINE void WRITE_LE_UINT32(void *ptr, uint32 value) {
+		byte *b = (byte *)ptr;
+		b[0] = (byte)(value >>  0);
+		b[1] = (byte)(value >>  8);
+		b[2] = (byte)(value >> 16);
+		b[3] = (byte)(value >> 24);
+	}
+#else
+	FORCEINLINE uint16 READ_LE_UINT16(const void *ptr) {
+		return *(const uint16 *)(ptr);
+	}
+	FORCEINLINE uint32 READ_LE_UINT32(const void *ptr) {
+		return *(const uint32 *)(ptr);
+	}
+	FORCEINLINE void WRITE_LE_UINT16(void *ptr, uint16 value) {
+		*(uint16 *)(ptr) = value;
+	}
+	FORCEINLINE void WRITE_LE_UINT32(void *ptr, uint32 value) {
+		*(uint32 *)(ptr) = value;
+	}
+#endif
+
+
+#if defined(SYSTEM_NEED_ALIGNMENT) || defined(SYSTEM_LITTLE_ENDIAN)
+	FORCEINLINE uint16 READ_BE_UINT16(const void *ptr) {
+		const byte *b = (const byte *)ptr;
+		return (b[0] << 8) + b[1];
+	}
+	FORCEINLINE uint32 READ_BE_UINT32(const void *ptr) {
+		const byte *b = (const byte*)ptr;
+		return (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + (b[3]);
+	}
+	FORCEINLINE void WRITE_BE_UINT16(void *ptr, uint16 value) {
+		byte *b = (byte *)ptr;
+		b[0] = (byte)(value >> 8);
+		b[1] = (byte)(value >> 0);
+	}
+	FORCEINLINE void WRITE_BE_UINT32(void *ptr, uint32 value) {
+		byte *b = (byte *)ptr;
+		b[0] = (byte)(value >> 24);
+		b[1] = (byte)(value >> 16);
+		b[2] = (byte)(value >>  8);
+		b[3] = (byte)(value >>  0);
+	}
+#else
+	FORCEINLINE uint16 READ_BE_UINT16(const void *ptr) {
+		return *(const uint16 *)(ptr);
+	}
+	FORCEINLINE uint32 READ_BE_UINT32(const void *ptr) {
+		return *(const uint32 *)(ptr);
+	}
+	FORCEINLINE void WRITE_BE_UINT16(void *ptr, uint16 value) {
+		*(uint16 *)(ptr) = value;
+	}
+	FORCEINLINE void WRITE_BE_UINT32(void *ptr, uint32 value) {
+		*(uint32 *)(ptr) = value;
+	}
+#endif
+
+#if defined(SYSTEM_BIG_ENDIAN)
+
+inline float get_float(const char *data) {
+	const unsigned char *udata = reinterpret_cast<const unsigned char *>(data);
+	unsigned char fdata[4];
+	fdata[0] = udata[3];
+	fdata[1] = udata[2];
+	fdata[2] = udata[1];
+	fdata[3] = udata[0];
+	return *(reinterpret_cast<const float *>(fdata));
+}
+
+#else
+
+inline float get_float(const char *data) {
+	return *(reinterpret_cast<const float *>(data));
+}
+#endif
+
+inline Vector3d get_vector3d(const char *data) {
+	return Vector3d(get_float(data), get_float(data + 4), get_float(data + 8));
+}
+
+#endif

Copied: residual/trunk/common/debug.cpp (from rev 30636, residual/trunk/debug.cpp)
===================================================================
--- residual/trunk/common/debug.cpp	                        (rev 0)
+++ residual/trunk/common/debug.cpp	2008-01-26 09:18:08 UTC (rev 30637)
@@ -0,0 +1,143 @@
+/* Residual - Virtual machine to run LucasArts' 3D adventure games
+ * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "stdafx.h"
+#include "debug.h"
+
+#include <cstdarg>
+#include <cstdio>
+#include <cstdlib>
+
+const char *tag2str(uint32 tag) {
+	static char str[5];
+	str[0] = (char)(tag >> 24);
+	str[1] = (char)(tag >> 16);
+	str[2] = (char)(tag >> 8);
+	str[3] = (char)tag;
+	str[4] = '\0';
+	return str;
+}
+
+void hexdump(const byte * data, int len, int bytesPerLine) {
+	assert(1 <= bytesPerLine && bytesPerLine <= 32);
+	int i;
+	byte c;
+	int offset = 0;
+
+	while (len >= bytesPerLine) {
+		printf("%06x: ", offset);
+		for (i = 0; i < bytesPerLine; i++) {
+			printf("%02x ", data[i]);
+			if (i % 4 == 3)
+				printf(" ");
+		}
+		printf(" |");
+		for (i = 0; i < bytesPerLine; i++) {
+			c = data[i];
+			if (c < 32 || c >= 127)
+				c = '.';
+			printf("%c", c);
+		}
+		printf("|\n");
+		data += bytesPerLine;
+		len -= bytesPerLine;
+		offset += bytesPerLine;
+	}
+
+	if (len <= 0)
+		return;
+
+	printf("%06x: ", offset);
+	for (i = 0; i < bytesPerLine; i++) {
+		if (i < len)
+			printf("%02x ", data[i]);
+		else
+			printf("   ");
+		if (i % 4 == 3)
+			printf(" ");
+	}
+	printf(" |");
+	for (i = 0; i < len; i++) {
+		c = data[i];
+		if (c < 32 || c >= 127)
+			c = '.';
+		printf("%c", c);
+	}
+	for (; i < bytesPerLine; i++)
+		printf(" ");
+	printf("|\n");
+}
+
+void warning(const char *fmt, ...) {
+	std::fprintf(stderr, "WARNING: ");
+
+	std::va_list va;
+
+	va_start(va, fmt);
+	std::vfprintf(stderr, fmt, va);
+	va_end(va);
+	std::fprintf(stderr, "\n");
+}
+
+void error(const char *fmt, ...) {
+	std::fprintf(stderr, "ERROR: ");
+
+	std::va_list va;
+
+	va_start(va, fmt);
+	std::vfprintf(stderr, fmt, va);
+	va_end(va);
+	std::fprintf(stderr, "\n");
+
+	exit(1);
+}
+
+const char *debug_levels[] = {
+	"NONE",
+	"NORMAL",
+	"WARN",
+	"ERROR",
+	"FUNC",
+	"BITMAP",
+	"MODEL",
+	"STUB",
+	"SMUSH",
+	"IMUSE",
+	"CHORE",
+	"ALL"
+};
+
+const char *debug_descriptions[] = {
+	"No debug messages will be printed (default)",
+	"\"Normal\" debug messages will be printed",
+	"Warning debug messages will be printed",
+	"Error debug messages will be printed",
+	"Function (normal and stub) debug messages will be printed",
+	"Bitmap debug messages will be printed",
+	"Model debug messages will be printed",
+	"Stub (missing function) debug messages will be printed",
+	"SMUSH (video) debug messages will be printed",
+	"IMUSE (audio) debug messages will be printed",
+	"Chore debug messages will be printed",
+	"All debug messages will be printed",
+};
+

Copied: residual/trunk/common/debug.h (from rev 30636, residual/trunk/debug.h)
===================================================================
--- residual/trunk/common/debug.h	                        (rev 0)
+++ residual/trunk/common/debug.h	2008-01-26 09:18:08 UTC (rev 30637)
@@ -0,0 +1,55 @@
+/* Residual - Virtual machine to run LucasArts' 3D adventure games
+ * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "bits.h"
+
+#ifndef DEBUG_H
+#define DEBUG_H
+
+enum enDebugLevels {
+	DEBUG_NONE,
+	DEBUG_NORMAL,
+	DEBUG_WARN,
+	DEBUG_ERROR,
+	DEBUG_FUNC,
+	DEBUG_BITMAPS,
+	DEBUG_MODEL,
+	DEBUG_STUB,
+	DEBUG_SMUSH,
+	DEBUG_IMUSE,
+	DEBUG_CHORES,
+	DEBUG_ALL
+};
+extern enDebugLevels debugLevel;
+extern const char *debug_levels[];
+extern const char *debug_descriptions[];
+
+// Hacky toggles for experimental / debug code (defined/set in main.cpp)
+extern bool ZBUFFER_GLOBAL, SHOWFPS_GLOBAL;
+
+void warning(const char *fmt, ...);
+void error(const char *fmt, ...);
+
+const char *tag2str(uint32 tag);
+void hexdump(const byte * data, int len, int bytesPerLine);
+
+#endif

Copied: residual/trunk/common/matrix3.cpp (from rev 30636, residual/trunk/matrix3.cpp)
===================================================================
--- residual/trunk/common/matrix3.cpp	                        (rev 0)
+++ residual/trunk/common/matrix3.cpp	2008-01-26 09:18:08 UTC (rev 30637)
@@ -0,0 +1,186 @@
+/* Residual - Virtual machine to run LucasArts' 3D adventure games
+ * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "matrix3.h"
+
+#include <math.h>
+
+void Matrix3::setAsIdentity() {
+	_right.set(1.f, 0.f, 0.f);
+	_up.set(0.f, 1.f, 0.f);
+	_at.set(0.f, 0.f, 0.f);
+}
+
+void Matrix3::buildFromPitchYawRoll(float pitch, float yaw, float roll) {
+	Matrix3 temp1, temp2;
+
+	temp1.constructAroundPitch(pitch);
+	constructAroundRoll(roll);
+
+	(*this) *= temp1;
+
+	temp2.constructAroundYaw(yaw);
+
+	(*this) *= temp2;
+}
+
+#define MYPI 3.14159265358979323846
+#define DEGTORAD(a) (a * MYPI / 180.0) 
+#define RADTODEG(a) (a * 180.0 / MYPI) 
+
+float RadianToDegree(float rad) {
+	return (float)RADTODEG(rad);
+}
+
+float DegreeToRadian(float degrees) {
+	return (float)DEGTORAD(degrees);
+}
+
+// right
+void Matrix3::constructAroundPitch(float pitch) {
+	float cosa;
+	float sina;
+
+	cosa = (float)cos(DegreeToRadian(pitch));
+	sina = (float)sin(DegreeToRadian(pitch));
+
+	_right.set(1.f, 0.f, 0.f);
+	_up.set(0.f, cosa, -sina);
+	_at.set(0.f, sina, cosa);
+}
+
+// up
+void Matrix3::constructAroundYaw(float yaw) {
+	float cosa;
+	float sina;
+
+	cosa = (float)cos(DegreeToRadian(yaw));
+	sina = (float)sin(DegreeToRadian(yaw));
+
+	_right.set(cosa, 0.f, sina);
+	_up.set(0.f, 1.f, 0.f);
+	_at.set(-sina, 0.f, cosa);
+}
+
+// at
+void Matrix3::constructAroundRoll(float roll) {
+	float cosa;
+	float sina;
+
+	cosa = (float)cos(DegreeToRadian(roll));
+	sina = (float)sin(DegreeToRadian(roll));
+
+	_right.set(cosa, -sina, 0.f);
+	_up.set(sina, cosa, 0.f);
+	_at.set(0.f, 0.f, 1.f);
+}
+
+/*
+0 1 2 3
+4 5 6 7
+8 9 10 11
+*/
+
+// WARNING: Still buggy in some occasions.
+void Matrix3::getPitchYawRoll(float* pPitch, float* pYaw, float* pRoll) {
+	float D;
+	float C;
+	float ftrx;
+	float ftry;
+	float angle_x;
+	float angle_y;
+	float angle_z;
+
+	angle_y = D = asin(_right.z());        /* Calculate Y-axis angle */
+	C			= cos(angle_y);
+	angle_y		= RadianToDegree(angle_y);
+
+	if (fabs( C ) > 0.005) {            /* Gimball lock? */
+		ftrx		=  _at.z() / C;           /* No, so get X-axis angle */
+		ftry		= -_up.z() / C;
+
+		angle_x		= RadianToDegree(atan2(ftry, ftrx));
+
+		ftrx		=  _right.x() / C;            /* Get Z-axis angle */
+		ftry		= -_right.y() / C;
+
+		angle_z		= RadianToDegree(atan2(ftry, ftrx));
+	} else {                                 /* Gimball lock has occurred */
+		angle_x		= 0;                      /* Set X-axis angle to zqero */
+
+		ftrx		= _up.y();                 /* And calculate Z-axis angle */
+		ftry		= _up.x();
+
+		angle_z  = RadianToDegree(atan2(ftry, ftrx));
+	}
+
+	/* return only positive angles in [0,360] */
+	if (angle_x < 0) angle_x += 360;
+	if (angle_y < 0) angle_y += 360;
+	if (angle_z < 0) angle_z += 360;
+
+	if (pPitch)
+		*pPitch = angle_x;
+
+	if (pYaw)
+		*pYaw = angle_y;
+
+	if (pRoll)
+		*pRoll = angle_z;
+}
+
+float Matrix3::getPitch() {
+	float pitch;
+
+	getPitchYawRoll(&pitch, 0, 0);
+
+	return pitch;
+}
+
+float Matrix3::getYaw() {
+	float yaw;
+
+	getPitchYawRoll(0, &yaw, 0);
+
+	return yaw;
+}
+
+float Matrix3::getRoll() {
+	float roll;
+
+	getPitchYawRoll(0, 0, &roll);
+
+	return roll;
+}
+
+void Matrix3::transform(Vector3d* v) {
+	float x;
+	float y;
+	float z;
+
+	x = v->dotProduct(_right.x(), _up.x(), _at.x());
+	y = v->dotProduct(_right.x(), _up.x(), _at.x());
+	z = v->dotProduct(_right.x(), _up.x(), _at.x());
+
+	v->set(x, y, z);
+}
+

Copied: residual/trunk/common/matrix3.h (from rev 30636, residual/trunk/matrix3.h)
===================================================================
--- residual/trunk/common/matrix3.h	                        (rev 0)
+++ residual/trunk/common/matrix3.h	2008-01-26 09:18:08 UTC (rev 30637)
@@ -0,0 +1,86 @@
+/* Residual - Virtual machine to run LucasArts' 3D adventure games
+ * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef MATRIX3_HH
+#define MATRIX3_HH
+
+#include "vector3d.h"
+
+// matrix 3 is a rotation matrix
+class Matrix3{
+public:
+	Vector3d _right;
+	Vector3d _up;
+	Vector3d _at;
+
+	void buildFromPitchYawRoll(float pitch, float yaw, float roll);
+	void setAsIdentity();
+
+	void constructAroundPitch(float pitch);
+	void constructAroundYaw(float pitch);
+	void constructAroundRoll(float pitch);
+
+	void getPitchYawRoll(float* pPitch, float* pYaw, float* pRoll);
+
+	float getPitch();
+	float getYaw();
+	float getRoll();
+
+	void transform(Vector3d* v);
+
+	// operators
+	Matrix3& operator *=(const Matrix3& s) {
+		float x, y, z;
+
+		x = _right.dotProduct(s._right.x(), s._up.x(), s._at.x());
+		y = _right.dotProduct(s._right.y(), s._up.y(), s._at.y());
+		z = _right.dotProduct(s._right.z(), s._up.z(), s._at.z());
+
+		_right.set(x, y, z);
+
+		x = _up.dotProduct(s._right.x(), s._up.x(), s._at.x());
+		y = _up.dotProduct(s._right.y(), s._up.y(), s._at.y());
+		z = _up.dotProduct(s._right.z(), s._up.z(), s._at.z());
+
+		_up.set( x, y, z );
+
+		x = _at.dotProduct(s._right.x(), s._up.x(), s._at.x());
+		y = _at.dotProduct(s._right.y(), s._up.y(), s._at.y());
+		z = _at.dotProduct(s._right.z(), s._up.z(), s._at.z());
+
+		_at.set(x, y, z);
+
+		return *this;
+	}
+	Matrix3& operator =(const Matrix3& s) {
+		_right = s._right;
+		_up = s._up;
+		_at = s._at;
+
+		return *this;
+	}
+
+private:
+};
+
+#endif // MATRIX_HH
+

Copied: residual/trunk/common/matrix4.cpp (from rev 30636, residual/trunk/matrix4.cpp)
===================================================================
--- residual/trunk/common/matrix4.cpp	                        (rev 0)
+++ residual/trunk/common/matrix4.cpp	2008-01-26 09:18:08 UTC (rev 30637)
@@ -0,0 +1,37 @@
+/* Residual - Virtual machine to run LucasArts' 3D adventure games
+ * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "matrix4.h"
+
+Matrix4::Matrix4() {
+	_pos.set(0.f, 0.f, 0.f);
+	_rot.setAsIdentity();
+}
+
+void Matrix4::translate(float x, float y, float z) {
+	Vector3d v;
+
+	v.set(x, y, z);
+	_rot.transform(&v);
+	_pos += v;
+}
+

Copied: residual/trunk/common/matrix4.h (from rev 30636, residual/trunk/matrix4.h)
===================================================================
--- residual/trunk/common/matrix4.h	                        (rev 0)
+++ residual/trunk/common/matrix4.h	2008-01-26 09:18:08 UTC (rev 30637)
@@ -0,0 +1,61 @@
+/* Residual - Virtual machine to run LucasArts' 3D adventure games
+ * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef MATRIX4_HH
+#define MATRIX4_HH
+
+#include "vector3d.h"
+#include "matrix3.h"
+
+// matrix 4 is a rotation matrix + position
+class Matrix4 {
+public:
+	Matrix3 _rot;
+	Vector3d _pos;
+
+	Matrix4();
+
+	Matrix4& operator =(const Matrix4& s) {
+		_pos = s._pos;
+		_rot = s._rot;
+
+		return *this;
+	}
+
+	Matrix4& operator *=(const Matrix4& s) {
+		Vector3d v;
+
+		v = s._pos;
+		_rot.transform(&v);
+		_pos += v;
+		_rot *= s._rot;
+
+		return *this;
+	}
+
+	void translate(float x, float y, float z);
+
+private:
+};
+
+#endif // MATRIX_HH
+

Copied: residual/trunk/common/stdafx.h (from rev 30636, residual/trunk/stdafx.h)
===================================================================
--- residual/trunk/common/stdafx.h	                        (rev 0)
+++ residual/trunk/common/stdafx.h	2008-01-26 09:18:08 UTC (rev 30637)
@@ -0,0 +1,131 @@
+/* Residual - Virtual machine to run LucasArts' 3D adventure games
+ * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef _STDAFX_H
+#define _STDAFX_H
+
+
+typedef struct Mutex *MutexRef;
+
+#ifndef _MSC_VER
+#include <unistd.h>
+#endif
+
+#if defined(WIN32)
+
+#ifdef _MSC_VER
+#pragma once
+#pragma warning( disable : 4068 ) // turn off "unknown pragma" warning
+#pragma warning( disable : 4244 ) // turn off "conversion type" warning
+#endif
+
+#if !defined(_WIN32_WCE)
+
+
+#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
+#define NOGDICAPMASKS
+#define OEMRESOURCE
+#define NONLS
+#define NOICONS
+#define NOMCX
+#define NOPROFILER
+#define NOKANJI
+#define NOSERVICE
+#define NOMETAFILE
+#define NOCOMM
+#define NOCRYPT
+#define NOIME
+#define NOATOM
+#define NOCTLMGR
+#define NOCLIPBOARD
+#define NOMEMMGR
+#define NOSYSMETRICS
+#define NOMENUS
+#define NOOPENFILE
+#define NOWH
+#define NOSOUND
+#define NODRAWTEXT
+
+
+#endif
+
+
+#include <windows.h>
+#if defined(ARRAYSIZE)
+// VS2005beta2 introduces new stuff in winnt.h
+#undef ARRAYSIZE
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <io.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <conio.h>
+#include <assert.h>
+#include <mmsystem.h>
+#include <ctype.h>
+#include <winuser.h>
+#include <direct.h>
+#define strcasecmp stricmp
+#define M_PI 3.14159265358979323846
+
+#ifndef _MSC_VER
+#include <stdint.h>
+#include <dirent.h>
+#endif
+
+#else
+
+#if defined(__MORPHOS__)
+#include <devices/timer.h>
+#undef CMD_INVALID
+#endif
+#if !defined(macintosh)
+#include <sys/types.h>
+#if !defined(__DC__)
+#include <sys/uio.h>
+#endif
+#endif
+#if !defined (__BEOS__)
+#include <unistd.h>
+#endif
+#if defined(__QNXNTO__)
+#include <strings.h>	/* For strcasecmp */
+#endif
+#include <stdio.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <ctype.h>
+#if defined(__DC__)
+#include <ronin/cdfs.h>
+#else
+#include <dirent.h>
+#endif
+
+
+#endif
+
+#endif

Copied: residual/trunk/common/timer.cpp (from rev 30636, residual/trunk/timer.cpp)
===================================================================
--- residual/trunk/common/timer.cpp	                        (rev 0)
+++ residual/trunk/common/timer.cpp	2008-01-26 09:18:08 UTC (rev 30637)
@@ -0,0 +1,134 @@
+/* Residual - Virtual machine to run LucasArts' 3D adventure games
+ * Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "stdafx.h"
+#include "bits.h"
+#include "debug.h"
+#include "timer.h"
+#include "driver.h"
+
+Timer *g_timer = NULL;
+
+Timer::Timer() :
+	_mutex(0),
+	_timerHandler(0),
+	_lastTime(0) {
+
+	_mutex = g_driver->createMutex();
+
+	g_timer = this;
+
+	for (int i = 0; i < MAX_TIMERS; i++) {
+		_timerSlots[i].procedure = NULL;
+		_timerSlots[i].interval = 0;
+		_timerSlots[i].counter = 0;
+	}
+
+	_thisTime = g_driver->getMillis();
+
+	// Set the timer last, after everything has been initialised
+	g_driver->setTimerCallback(timer_handler, 10);
+}
+
+Timer::~Timer() {
+	g_driver->setTimerCallback(NULL, 0);
+
+	{
+		StackLock lock(_mutex);
+		for (int i = 0; i < MAX_TIMERS; i++) {
+			_timerSlots[i].procedure = NULL;
+			_timerSlots[i].interval = 0;
+			_timerSlots[i].counter = 0;
+		}
+	}
+
+	g_driver->deleteMutex(_mutex);
+}
+
+int Timer::timer_handler(int t) {
+	if (g_timer)
+		return g_timer->handler(t);
+	return 0;
+}
+
+int Timer::handler(int t) {
+	StackLock lock(_mutex);
+	uint32 interval, l;
+
+	_lastTime = _thisTime;
+	_thisTime = g_driver->getMillis();
+	interval = 1000 * (_thisTime - _lastTime);
+
+	// If the timer has been frozen for a long time, don't
+	// call the procedures a silly number of times, just resynchronize
+	if(interval > 1000000) {
+		interval = 0;
+		warning("Timer skipped forward");
+	}
+
+	for (l = 0; l < MAX_TIMERS; l++) {
+		if (_timerSlots[l].procedure && _timerSlots[l].interval > 0) {
+			_timerSlots[l].counter -= interval;
+			while (_timerSlots[l].counter <= 0) {
+				// A small paranoia check which catches the case where
+				// a timer removes itself (which it never should do).
+				assert(_timerSlots[l].procedure && _timerSlots[l].interval > 0);
+				_timerSlots[l].counter += _timerSlots[l].interval;
+				_timerSlots[l].procedure(_timerSlots[l].refCon);
+			}
+		}
+	}
+
+	return t;
+}
+

@@ Diff output truncated at 100000 characters. @@

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list