[Scummvm-cvs-logs] CVS: residual actor.cpp,1.19,1.20 actor.h,1.8,1.9 bitmap.cpp,1.15,1.16 bitmap.h,1.4,1.5
Pawel Kolodziejski
aquadran at users.sourceforge.net
Tue Feb 24 00:36:08 CET 2004
- Previous message: [Scummvm-cvs-logs] CVS: residual bitmap.cpp,1.14,1.15 driver_gl.cpp,1.3,1.4 engine.cpp,1.14,1.15
- Next message: [Scummvm-cvs-logs] CVS: residual/mixer audiostream.cpp,1.2,1.3 audiostream.h,1.2,1.3 mixer.cpp,1.3,1.4 mixer.h,1.3,1.4 rate.cpp,1.2,1.3 rate.h,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18020
Modified Files:
actor.cpp actor.h bitmap.cpp bitmap.h
Log Message:
update copyright date, some formating stuff, rest later
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- actor.cpp 1 Feb 2004 12:32:53 -0000 1.19
+++ actor.cpp 24 Feb 2004 08:20:44 -0000 1.20
@@ -1,5 +1,5 @@
// Residual - Virtual machine to run LucasArts' 3D adventure games
-// Copyright (C) 2003 The ScummVM-Residual Team (www.scummvm.org)
+// Copyright (C) 2003-2004 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
@@ -25,157 +25,155 @@
#include "driver_gl.h"
Actor::Actor(const char *name) :
- name_(name), talkColor_(255, 255, 255), pos_(0, 0, 0),
- pitch_(0), yaw_(0), roll_(0), walkRate_(0), turnRate_(0),
- visible_(true), talkSound_(NULL), turning_(false), walking_(false), walkChore_(-1)
-{
- Engine::instance()->registerActor(this);
- lookingMode_ = false;
+ name_(name), talkColor_(255, 255, 255), pos_(0, 0, 0),
+ pitch_(0), yaw_(0), roll_(0), walkRate_(0), turnRate_(0),
+ visible_(true), talkSound_(NULL), turning_(false), walking_(false), walkChore_(-1) {
+ Engine::instance()->registerActor(this);
+ lookingMode_ = false;
}
void Actor::turnTo(float pitch, float yaw, float roll) {
- pitch_ = pitch;
- roll_ = roll;
- if (yaw_ != yaw) {
- turning_ = true;
- destYaw_ = yaw;
- }
- else
- turning_ = false;
+ 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;
+ // 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_);
- }
+ if (p.x() != pos_.x() || p.y() != pos_.y())
+ turnTo(pitch_, yawTo(p), roll_);
+ }
}
bool Actor::validBoxVector(Vector3d forwardVec, float dist) {
- // TODO: Obey Actor 'constrain' flags. Verify if any other sector flags allow walking
- // Possibly use a box-aware TraceLine function instead of just checking dest point
- Vector3d tempVec = pos_ + (forwardVec * dist);
- int numSectors = Engine::instance()->currScene()->getSectorCount();
+ //TODO: Obey Actor 'constrain' flags. Verify if any other sector flags allow walking
+ //Possibly use a box-aware TraceLine function instead of just checking dest point
+ Vector3d tempVec = pos_ + (forwardVec * dist);
+ int numSectors = Engine::instance()->currScene()->getSectorCount();
- for (int i = 0; i < numSectors; i++) {
- Sector *sector = Engine::instance()->currScene()->getSectorBase(i);
- if ((sector->type() & 0x1000) && sector->visible()) {
- if (sector->isPointInSector(tempVec))
- return true;
- }
- }
- return false;
+ for (int i = 0; i < numSectors; i++) {
+ Sector *sector = Engine::instance()->currScene()->getSectorBase(i);
+ if ((sector->type() & 0x1000) && sector->visible()) {
+ if (sector->isPointInSector(tempVec))
+ return true;
+ }
+ }
+ return false;
}
void Actor::walkForward() {
- float dist = Engine::instance()->perSecond(walkRate_);
- float yaw_rad = yaw_ * (M_PI / 180), pitch_rad = pitch_ * (M_PI / 180);
- Vector3d forwardVec(-std::sin(yaw_rad) * std::cos(pitch_rad),
- std::cos(yaw_rad) * std::cos(pitch_rad),
- std::sin(pitch_rad));
- if (validBoxVector(forwardVec, dist))
- pos_ += forwardVec * dist;
+ float dist = Engine::instance()->perSecond(walkRate_);
+ float yaw_rad = yaw_ * (M_PI / 180), pitch_rad = pitch_ * (M_PI / 180);
+ Vector3d forwardVec(-std::sin(yaw_rad) * std::cos(pitch_rad),
+ std::cos(yaw_rad) * std::cos(pitch_rad),
+ std::sin(pitch_rad));
+ if (validBoxVector(forwardVec, dist))
+ pos_ += forwardVec * dist;
}
void Actor::turn(int dir) {
- float delta = Engine::instance()->perSecond(turnRate_) * dir;
- yaw_ += delta;
+ float delta = Engine::instance()->perSecond(turnRate_) * dir;
+ yaw_ += delta;
}
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 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);
+ 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) {
- // For now, just play the appropriate sound if found. Eventually,
- // this needs to handle possibly displaying text, starting up
- // appropriate talking chores, etc.
+ // For now, just play the appropriate sound if found. Eventually,
+ // this needs to handle possibly displaying text, starting up
+ // appropriate talking chores, etc.
- // Find the message identifier
- if (msg[0] != '/')
- return;
- const char *secondSlash = std::strchr(msg + 1, '/');
- if (secondSlash == NULL)
- return;
- if (talkSound_) // Only once line at a time, please :)
- shutUp();
- std::string msgId(msg + 1, secondSlash);
- talkSound_ = ResourceLoader::instance()->loadSound((msgId + ".wav").c_str());
- if (talkSound_ != NULL)
- Mixer::instance()->playVoice(talkSound_);
+ // Find the message identifier
+ if (msg[0] != '/')
+ return;
+ const char *secondSlash = std::strchr(msg + 1, '/');
+ if (secondSlash == NULL)
+ return;
+ if (talkSound_) // Only once line at a time, please :)
+ shutUp();
+ std::string msgId(msg + 1, secondSlash);
+ talkSound_ = ResourceLoader::instance()->loadSound((msgId + ".wav").c_str());
+ if (talkSound_ != NULL)
+ Mixer::instance()->playVoice(talkSound_);
-// FIXME: Ender - Disabled until I work out why the wrong Chores play
-// if (!costumeStack_.empty()) {
-// printf("Requesting talk chore\n");
-// costumeStack_.back()->playTalkChores();
-// }
-}
+ //FIXME: Ender - Disabled until I work out why the wrong Chores play
+ // if (!costumeStack_.empty()) {
+ // printf("Requesting talk chore\n");
+ // costumeStack_.back()->playTalkChores();
+ //}
+ }
bool Actor::talking() {
- if (talkSound_ == NULL)
- return false;
- if (talkSound_->done()) {
-// FIXME: Ender - Disabled until I work out why the wrong Chores play
-// if (!costumeStack_.empty())
-// costumeStack_.back()->stopTalkChores();
- talkSound_ = NULL;
- return false;
- }
- return true;
+ if (talkSound_ == NULL)
+ return false;
+ if (talkSound_->done()) {
+ //FIXME: Ender - Disabled until I work out why the wrong Chores play
+ //if (!costumeStack_.empty())
+ //costumeStack_.back()->stopTalkChores();
+ talkSound_ = NULL;
+ return false;
+ }
+ return true;
}
void Actor::shutUp() {
- if (talkSound_) {
- Mixer::instance()->stopVoice(talkSound_);
- talkSound_ = NULL;
- }
+ if (talkSound_) {
+ Mixer::instance()->stopVoice(talkSound_);
+ talkSound_ = NULL;
+ }
}
void Actor::pushCostume(const char *name) {
- Costume *newCost = ResourceLoader::instance()->
- loadCostume(name, currentCostume());
- costumeStack_.push_back(newCost);
+ Costume *newCost = ResourceLoader::instance()->
+ loadCostume(name, currentCostume());
+ costumeStack_.push_back(newCost);
}
void Actor::setCostume(const char *name) {
- if (! costumeStack_.empty())
- popCostume();
- pushCostume(name);
+ if (! costumeStack_.empty())
+ popCostume();
+ pushCostume(name);
}
void Actor::popCostume() {
- if (! costumeStack_.empty()) {
- delete costumeStack_.back();
- costumeStack_.pop_back();
- }
+ if (! costumeStack_.empty()) {
+ delete costumeStack_.back();
+ costumeStack_.pop_back();
+ }
}
void Actor::clearCostumes() {
- // Make sure to destroy costume copies in reverse order
- while (! costumeStack_.empty()) {
- delete costumeStack_.back();
- costumeStack_.pop_back();
- }
+ // Make sure to destroy costume copies in reverse order
+ while (! costumeStack_.empty()) {
+ delete costumeStack_.back();
+ costumeStack_.pop_back();
+ }
}
void Actor::setHead( int joint1, int joint2, int joint3, float maxRoll, float maxPitch, float maxYaw ) {
@@ -185,62 +183,64 @@
}
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;
+ 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() {
- if (turning_) {
- float turnAmt = Engine::instance()->perSecond(turnRate_);
- float dyaw = destYaw_ - yaw_;
- while (dyaw > 180)
- dyaw -= 360;
- while (dyaw < -180)
- dyaw += 360;
- if (turnAmt >= std::abs(dyaw)) {
- yaw_ = destYaw_;
- turning_ = false;
- }
- else if (dyaw > 0)
- yaw_ += turnAmt;
- else
- yaw_ -= turnAmt;
- }
+ if (turning_) {
+ float turnAmt = Engine::instance()->perSecond(turnRate_);
+ float dyaw = destYaw_ - yaw_;
+ while (dyaw > 180)
+ dyaw -= 360;
+ while (dyaw < -180)
+ dyaw += 360;
+ if (turnAmt >= std::abs(dyaw)) {
+ yaw_ = destYaw_;
+ turning_ = false;
+ }
+ else if (dyaw > 0)
+ yaw_ += turnAmt;
+ else
+ yaw_ -= turnAmt;
+ }
- if (walking_) {
- Vector3d dir = destPos_ - pos_;
- float dist = dir.magnitude();
- if (dist > 0)
- dir /= dist;
- float walkAmt = Engine::instance()->perSecond(walkRate_);
- if (walkAmt >= dist) {
- pos_ = destPos_;
- walking_ = false;
- turning_ = false;
- }
- else
- pos_ += dir * walkAmt;
- }
+ if (walking_) {
+ Vector3d dir = destPos_ - pos_;
+ float dist = dir.magnitude();
- for (std::list<Costume *>::iterator i = costumeStack_.begin();
- i != costumeStack_.end(); i++)
- {
- (*i)->setPosRotate( pos_, pitch_, yaw_, roll_ );
- (*i)->update();
- }
+ if (dist > 0)
+ dir /= dist;
- if (lookingMode_) {
- float lookAtAmt = Engine::instance()->perSecond(lookAtRate_);
- }
+ float walkAmt = Engine::instance()->perSecond(walkRate_);
+
+ if (walkAmt >= dist) {
+ pos_ = destPos_;
+ walking_ = false;
+ turning_ = false;
+ }
+ else
+ pos_ += dir * walkAmt;
+ }
+
+ for (std::list<Costume *>::iterator i = costumeStack_.begin();
+ i != costumeStack_.end(); i++) {
+ (*i)->setPosRotate( pos_, pitch_, yaw_, roll_ );
+ (*i)->update();
+ }
+
+ if (lookingMode_) {
+ float lookAtAmt = Engine::instance()->perSecond(lookAtRate_);
+ }
}
void Actor::draw() {
- if (! costumeStack_.empty()) {
- g_driver->startActorDraw(pos_, yaw_, pitch_, roll_);
- costumeStack_.back()->draw();
- g_driver->finishActorDraw();
- }
-}
+ if (! costumeStack_.empty()) {
+ g_driver->startActorDraw(pos_, yaw_, pitch_, roll_);
+ costumeStack_.back()->draw();
+ g_driver->finishActorDraw();
+ }
+ }
Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- actor.h 11 Oct 2003 08:28:32 -0000 1.8
+++ actor.h 24 Feb 2004 08:20:44 -0000 1.9
@@ -1,5 +1,5 @@
// Residual - Virtual machine to run LucasArts' 3D adventure games
-// Copyright (C) 2003 The ScummVM-Residual Team (www.scummvm.org)
+// Copyright (C) 2003-2004 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
@@ -29,115 +29,114 @@
class Actor {
public:
- Actor(const char *name);
+ Actor(const char *name);
- const char *name() const { return name_.c_str(); }
+ 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; }
- Vector3d pos() const { return pos_; }
- void walkTo(Vector3d p);
- bool isWalking() const { return walking_; }
- void setRot(float pitch, float yaw, float roll) {
- pitch_ = pitch; yaw_ = yaw; roll_ = roll;
- }
- void turnTo(float pitch, float yaw, float roll);
- bool isTurning() const { return turning_; }
- 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_; }
- 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; }
+ void setTalkColor(const Color& c) { talkColor_ = c; }
+ Color talkColor() const { return talkColor_; }
+ void setPos(Vector3d pos) { pos_ = pos; }
+ Vector3d pos() const { return pos_; }
+ void walkTo(Vector3d p);
+ bool isWalking() const { return walking_; }
+ void setRot(float pitch, float yaw, float roll) {
+ pitch_ = pitch; yaw_ = yaw; roll_ = roll;
+ }
+ void turnTo(float pitch, float yaw, float roll);
+ bool isTurning() const { return turning_; }
+ 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_; }
+ 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;
+ float angleTo(const Actor &a) const;
+ float yawTo(Vector3d p) const;
- bool validBoxVector(Vector3d forwardVec, float dist);
+ bool validBoxVector(Vector3d forwardVec, float dist);
- bool inSet(const char *name) const {
- return setName_ == name;
- }
- void walkForward();
- void turn(int dir);
+ bool inSet(const char *name) const {
+ return setName_ == name;
+ }
+ void walkForward();
+ void turn(int dir);
- void sayLine(const char *msg);
- void shutUp();
- bool talking();
+ void sayLine(const char *msg);
+ void shutUp();
+ bool talking();
- void setWalkChore(int choreNumber) { walkChore_ = choreNumber; }
+ void setWalkChore(int choreNumber) { walkChore_ = choreNumber; }
- 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 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 update();
- void draw();
+ void update();
+ void draw();
- 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 );
+ 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_;
- Color talkColor_;
- Vector3d pos_;
- float pitch_, yaw_, roll_;
- float walkRate_, turnRate_;
-
- bool visible_;
- bool lookingMode_;
- ResPtr<Sound> talkSound_;
- std::list<Costume *> costumeStack_;
+ std::string name_;
+ std::string setName_;
+ Color talkColor_;
+ Vector3d pos_;
+ float pitch_, yaw_, roll_;
+ float walkRate_, turnRate_;
- // Variables for gradual turning
- bool turning_;
- float destYaw_;
+ bool visible_;
+ bool lookingMode_;
+ ResPtr<Sound> talkSound_;
+ std::list<Costume *> costumeStack_;
- // Variables for walking to a point
- bool walking_;
- Vector3d destPos_;
+ // Variables for gradual turning
+ bool turning_;
+ float destYaw_;
- // chores
- int walkChore_;
+ // Variables for walking to a point
+ bool walking_;
+ Vector3d destPos_;
- // lookAt
- Vector3d lookAtVector_;
- float lookAtRate_;
+ // chores
+ int walkChore_;
- friend class Engine;
+ // lookAt
+ Vector3d lookAtVector_;
+ float lookAtRate_;
+
+ friend class Engine;
};
#endif
Index: bitmap.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/bitmap.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- bitmap.cpp 24 Feb 2004 07:04:50 -0000 1.15
+++ bitmap.cpp 24 Feb 2004 08:20:44 -0000 1.16
@@ -1,5 +1,5 @@
// Residual - Virtual machine to run LucasArts' 3D adventure games
-// Copyright (C) 2003 The ScummVM-Residual Team (www.scummvm.org)
+// Copyright (C) 2003-2004 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
@@ -20,6 +20,7 @@
#include <cstring>
#include "bitmap.h"
#include "bits.h"
+#include "smush.h"
#include "debug.h"
#include "driver_gl.h"
@@ -29,194 +30,192 @@
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)
- error("Invalid magic loading bitmap\n");
+Resource(filename) {
+ if (len < 8 || memcmp(data, "BM F\0\0\0", 8) != 0)
+ error("Invalid magic loading bitmap\n");
- int codec = READ_LE_UINT32(data + 8);
- num_images_ = READ_LE_UINT32(data + 16);
- x_ = READ_LE_UINT32(data + 20);
- y_ = READ_LE_UINT32(data + 24);
- format_ = READ_LE_UINT32(data + 32);
- width_ = READ_LE_UINT32(data + 128);
- height_ = READ_LE_UINT32(data + 132);
- curr_image_ = 0;
+ int codec = READ_LE_UINT32(data + 8);
+ num_images_ = READ_LE_UINT32(data + 16);
+ x_ = READ_LE_UINT32(data + 20);
+ y_ = READ_LE_UINT32(data + 24);
+ format_ = READ_LE_UINT32(data + 32);
+ width_ = READ_LE_UINT32(data + 128);
+ height_ = READ_LE_UINT32(data + 132);
+ curr_image_ = 0;
- data_ = new char*[num_images_];
- int pos = 0x88;
- for (int i = 0; i < num_images_; 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;
- }
- }
+ data_ = new char*[num_images_];
+ int pos = 0x88;
+ for (int i = 0; i < num_images_; 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;
+ }
+ }
- if (format_ == 1) {
- num_tex_ = ((width_ + (BITMAP_TEXTURE_SIZE - 1)) / BITMAP_TEXTURE_SIZE) *
- ((height_ + (BITMAP_TEXTURE_SIZE - 1)) / BITMAP_TEXTURE_SIZE);
- tex_ids_ = new GLuint[num_tex_];
- glGenTextures(num_tex_, tex_ids_);
- for (int i = 0; i < num_tex_; i++) {
- glBindTexture(GL_TEXTURE_2D, tex_ids_[i]);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
- BITMAP_TEXTURE_SIZE, BITMAP_TEXTURE_SIZE, 0,
- GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL);
- }
-
- glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, width_);
+ if (format_ == 1) {
+ num_tex_ = ((width_ + (BITMAP_TEXTURE_SIZE - 1)) / BITMAP_TEXTURE_SIZE) *
+ ((height_ + (BITMAP_TEXTURE_SIZE - 1)) / BITMAP_TEXTURE_SIZE);
+ tex_ids_ = new GLuint[num_tex_];
+ glGenTextures(num_tex_, tex_ids_);
+ for (int i = 0; i < num_tex_; i++) {
+ glBindTexture(GL_TEXTURE_2D, tex_ids_[i]);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
+ BITMAP_TEXTURE_SIZE, BITMAP_TEXTURE_SIZE, 0,
+ GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL);
+ }
- int cur_tex_idx = 0;
- for (int y = 0; y < height_; y += BITMAP_TEXTURE_SIZE) {
- for (int x = 0; x < width_; x += BITMAP_TEXTURE_SIZE) {
- int width = (x + BITMAP_TEXTURE_SIZE >= width_) ? (width_ - x) : BITMAP_TEXTURE_SIZE;
- int height = (y + BITMAP_TEXTURE_SIZE >= height_) ? (height_ - y) : BITMAP_TEXTURE_SIZE;
- glBindTexture(GL_TEXTURE_2D, tex_ids_[cur_tex_idx]);
- glTexSubImage2D(GL_TEXTURE_2D,
- 0,
- 0, 0,
- width, height,
- GL_RGB,
- GL_UNSIGNED_SHORT_5_6_5,
- data_[curr_image_] + (y * 2 * width_) + (2 * x));
- cur_tex_idx++;
- }
- }
- glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- } else {
- for (int i = 0; i < (width_ * height_); i++) {
- uint16 val = READ_LE_UINT16(data_[curr_image_] + 2 * i);
- ((uint16 *) data_[curr_image_])[i] =
- 0xffff - ((uint32) val) * 0x10000 / 100 / (0x10000 - val);
- }
- tex_ids_ = NULL;
- }
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, width_);
+
+ int cur_tex_idx = 0;
+ for (int y = 0; y < height_; y += BITMAP_TEXTURE_SIZE) {
+ for (int x = 0; x < width_; x += BITMAP_TEXTURE_SIZE) {
+ int width = (x + BITMAP_TEXTURE_SIZE >= width_) ? (width_ - x) : BITMAP_TEXTURE_SIZE;
+ int height = (y + BITMAP_TEXTURE_SIZE >= height_) ? (height_ - y) : BITMAP_TEXTURE_SIZE;
+ glBindTexture(GL_TEXTURE_2D, tex_ids_[cur_tex_idx]);
+ glTexSubImage2D(GL_TEXTURE_2D,
+ 0,
+ 0, 0,
+ width, height,
+ GL_RGB,
+ GL_UNSIGNED_SHORT_5_6_5,
+ data_[curr_image_] + (y * 2 * width_) + (2 * x));
+ cur_tex_idx++;
+ }
+ }
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ } else {
+ for (int i = 0; i < (width_ * height_); i++) {
+ uint16 val = READ_LE_UINT16(data_[curr_image_] + 2 * i);
+ ((uint16 *) data_[curr_image_])[i] =
+ 0xffff - ((uint32) val) * 0x10000 / 100 / (0x10000 - val);
+ }
+ tex_ids_ = NULL;
+ }
}
void Bitmap::prepareDraw() {
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, 640, 480, 0, 0, 1);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- // A lot more may need to be put there : disabling Alpha test, blending, ...
- // For now, just keep this here :-)
- glDisable(GL_LIGHTING);
- glEnable(GL_TEXTURE_2D);
-}
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0, 640, 480, 0, 0, 1);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glMatrixMode(GL_TEXTURE);
+ glLoadIdentity();
+ // A lot more may need to be put there : disabling Alpha test, blending, ...
+ // For now, just keep this here :-)
+ glDisable(GL_LIGHTING);
+ glEnable(GL_TEXTURE_2D);
+ }
void Bitmap::draw() const {
- if (format_ == 1) { // Normal image
- if (curr_image_ != 0) {
- warning("Animation not handled yet in GL texture path !\n");
- }
- glDisable(GL_DEPTH_TEST);
- glDepthMask(GL_FALSE);
- glEnable(GL_SCISSOR_TEST);
- int cur_tex_idx = 0;
- for (int y = y_; y < (y_ + height_); y += BITMAP_TEXTURE_SIZE) {
- for (int x = x_; x < (x_ + width_); x += BITMAP_TEXTURE_SIZE) {
- int width = (x + BITMAP_TEXTURE_SIZE >= (x_ + width_)) ? ((x_ + width_) - x) : BITMAP_TEXTURE_SIZE;
- int height = (y + BITMAP_TEXTURE_SIZE >= (y_ + height_)) ? ((y_ + height_) - y) : BITMAP_TEXTURE_SIZE;
- glBindTexture(GL_TEXTURE_2D, tex_ids_[cur_tex_idx]);
- glScissor(x, 480 - (y + height), x + width, 480 - y);
- glBegin(GL_QUADS);
- glTexCoord2f(0.0, 0.0);
- glVertex2i(x, y);
- glTexCoord2f(1.0, 0.0);
- glVertex2i(x + BITMAP_TEXTURE_SIZE, y);
- glTexCoord2f(1.0, 1.0);
- glVertex2i(x + BITMAP_TEXTURE_SIZE, y + BITMAP_TEXTURE_SIZE);
- glTexCoord2f(0.0, 1.0);
- glVertex2i(x, y + BITMAP_TEXTURE_SIZE);
- glEnd();
- cur_tex_idx++;
- }
- }
+ if (format_ == 1) { // Normal image
+ if (curr_image_ != 0) {
+ warning("Animation not handled yet in GL texture path !\n");
+ }
+ glDisable(GL_DEPTH_TEST);
+ glDepthMask(GL_FALSE);
+ glEnable(GL_SCISSOR_TEST);
+ int cur_tex_idx = 0;
+ for (int y = y_; y < (y_ + height_); y += BITMAP_TEXTURE_SIZE) {
+ for (int x = x_; x < (x_ + width_); x += BITMAP_TEXTURE_SIZE) {
+ int width = (x + BITMAP_TEXTURE_SIZE >= (x_ + width_)) ? ((x_ + width_) - x) : BITMAP_TEXTURE_SIZE;
+ int height = (y + BITMAP_TEXTURE_SIZE >= (y_ + height_)) ? ((y_ + height_) - y) : BITMAP_TEXTURE_SIZE;
+ glBindTexture(GL_TEXTURE_2D, tex_ids_[cur_tex_idx]);
+ glScissor(x, 480 - (y + height), x + width, 480 - y);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0.0, 0.0);
+ glVertex2i(x, y);
+ glTexCoord2f(1.0, 0.0);
+ glVertex2i(x + BITMAP_TEXTURE_SIZE, y);
+ glTexCoord2f(1.0, 1.0);
+ glVertex2i(x + BITMAP_TEXTURE_SIZE, y + BITMAP_TEXTURE_SIZE);
+ glTexCoord2f(0.0, 1.0);
+ glVertex2i(x, y + BITMAP_TEXTURE_SIZE);
+ glEnd();
+ cur_tex_idx++;
+ }
+ }
- glDisable(GL_SCISSOR_TEST);
- glDisable(GL_TEXTURE_2D);
- glDepthMask(GL_TRUE);
- glEnable(GL_DEPTH_TEST);
- } else if (format_ == 5) { // ZBuffer image
- // Only draw the manual zbuffer when we are not using screenblocks, and when enabled
- if ((ZBUFFER_GLOBAL == 0) || (SCREENBLOCKS_GLOBAL == 1))
- return;
+ glDisable(GL_SCISSOR_TEST);
+ glDisable(GL_TEXTURE_2D);
+ glDepthMask(GL_TRUE);
+ glEnable(GL_DEPTH_TEST);
+ } else if (format_ == 5) { // ZBuffer image
+ // Only draw the manual zbuffer when we are not using screenblocks, and when enabled
+ if ((ZBUFFER_GLOBAL == 0) || (SCREENBLOCKS_GLOBAL == 1))
+ return;
- g_driver->drawDepthBitmap(curr_image_, x_, y_, width_, height_, data_);
- }
+ g_driver->drawDepthBitmap(curr_image_, x_, y_, width_, height_, data_);
+ }
}
Bitmap::~Bitmap() {
- for (int i = 0; i < num_images_; i++)
- delete[] data_[i];
- delete[] data_;
- if (tex_ids_) {
- glDeleteTextures(num_tex_, tex_ids_);
- delete[] tex_ids_;
- }
+ for (int i = 0; i < num_images_; i++)
+ delete[] data_[i];
+ delete[] data_;
+ if (tex_ids_) {
+ glDeleteTextures(num_tex_, tex_ids_);
+ delete[] tex_ids_;
+ }
}
#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)
+ 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;
+ int bitstr_value = READ_LE_UINT16(compressed);
+ int bitstr_len = 16;
compressed += 2;
- if (copy_len == 3) {
- copy_len = *(uint8 *)(compressed++) + 1;
- if (copy_len == 1)
- return;
+ 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--;
+ }
+ }
}
- }
- while (copy_len > 0) {
- *result = result[copy_offset];
- result++;
- copy_len--;
- }
- }
- }
}
Index: bitmap.h
===================================================================
RCS file: /cvsroot/scummvm/residual/bitmap.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- bitmap.h 23 Jan 2004 11:10:21 -0000 1.4
+++ bitmap.h 24 Feb 2004 08:20:44 -0000 1.5
@@ -1,5 +1,5 @@
// Residual - Virtual machine to run LucasArts' 3D adventure games
-// Copyright (C) 2003 The ScummVM-Residual Team (www.scummvm.org)
+// Copyright (C) 2003-2004 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
@@ -24,35 +24,35 @@
class Bitmap : public Resource {
public:
- // Construct a bitmap from the given data.
- Bitmap(const char *filename, const char *data, int len);
+ // Construct a bitmap from the given data.
+ Bitmap(const char *filename, const char *data, int len);
- // Set up Driver for drawing bitmaps
- static void prepareDraw();
- void draw() const;
+ // Set up Driver for drawing bitmaps
+ static void prepareDraw();
+ void draw() const;
- // Set which image in an animated bitmap to use
- void setNumber(int n) { curr_image_ = n; }
+ // Set which image in an animated bitmap to use
+ void setNumber(int n) { curr_image_ = n; }
- int numImages() const { return num_images_; }
- int currentImage() const { return curr_image_; }
+ int numImages() const { return num_images_; }
+ int currentImage() const { return curr_image_; }
- int width() const { return width_; }
- int height() const { return height_; }
- int x() const { return x_; }
- int y() const { return y_; }
+ int width() const { return width_; }
+ int height() const { return height_; }
+ int x() const { return x_; }
+ int y() const { return y_; }
- char * getData() { return data_[curr_image_]; }
+ char * getData() { return data_[curr_image_]; }
- ~Bitmap();
+ ~Bitmap();
private:
- char **data_;
- int num_images_, curr_image_;
- int width_, height_, x_, y_;
- int format_;
- int num_tex_;
- GLuint *tex_ids_;
+ char **data_;
+ int num_images_, curr_image_;
+ int width_, height_, x_, y_;
+ int format_;
+ int num_tex_;
+ GLuint *tex_ids_;
};
#endif
- Previous message: [Scummvm-cvs-logs] CVS: residual bitmap.cpp,1.14,1.15 driver_gl.cpp,1.3,1.4 engine.cpp,1.14,1.15
- Next message: [Scummvm-cvs-logs] CVS: residual/mixer audiostream.cpp,1.2,1.3 audiostream.h,1.2,1.3 mixer.cpp,1.3,1.4 mixer.h,1.3,1.4 rate.cpp,1.2,1.3 rate.h,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list