aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/teenagent/animation.cpp28
-rw-r--r--engines/teenagent/animation.h2
-rw-r--r--engines/teenagent/inventory.cpp6
-rw-r--r--engines/teenagent/scene.cpp14
-rw-r--r--engines/teenagent/surface.cpp14
-rw-r--r--engines/teenagent/surface.h2
-rw-r--r--engines/teenagent/surface_list.cpp14
-rw-r--r--engines/teenagent/surface_list.h2
-rw-r--r--engines/teenagent/teenagent.cpp2
9 files changed, 42 insertions, 42 deletions
diff --git a/engines/teenagent/animation.cpp b/engines/teenagent/animation.cpp
index e945bda1e5..56107b67ca 100644
--- a/engines/teenagent/animation.cpp
+++ b/engines/teenagent/animation.cpp
@@ -106,11 +106,11 @@ void Animation::free() {
index = 0;
}
-void Animation::load(Common::SeekableReadStream *s, Type type) {
+void Animation::load(Common::SeekableReadStream &s, Type type) {
//fixme: do not reload the same animation each time
free();
- if (s == NULL || s->size() <= 1) {
+ if (s.size() <= 1) {
debug(1, "empty animation");
return;
}
@@ -119,29 +119,29 @@ void Animation::load(Common::SeekableReadStream *s, Type type) {
int off = 0;
switch (type) {
case kTypeLan:
- data_size = s->readUint16LE();
- if (s->eos()) {
+ data_size = s.readUint16LE();
+ if (s.eos()) {
debug(1, "empty animation");
return;
}
data_size -= 2;
data = new byte[data_size];
- data_size = s->read(data, data_size);
+ data_size = s.read(data, data_size);
/* for (int i = 0; i < data_size; ++i) {
debug(0, "%02x ", data[i]);
}
debug(0, ", %u frames", data_size / 3);
*/
- frames_count = s->readByte();
+ frames_count = s.readByte();
debug(1, "%u physical frames", frames_count);
if (frames_count == 0)
return;
frames = new Surface[frames_count];
- s->skip(frames_count * 2 - 2); //sizes
- /*pos = */s->readUint16LE();
+ s.skip(frames_count * 2 - 2); //sizes
+ /*pos = */s.readUint16LE();
//debug(0, "pos?: %04x", pos);
for (uint16 i = 0; i < frames_count; ++i) {
@@ -152,15 +152,15 @@ void Animation::load(Common::SeekableReadStream *s, Type type) {
break;
case kTypeInventory: {
- data_size = 3 * s->readByte();
+ data_size = 3 * s.readByte();
data = new byte[data_size];
frames_count = 0;
for (byte i = 0; i < data_size / 3; ++i) {
int idx = i * 3;
/* byte unk = */
- s->readByte();
- data[idx] = s->readByte();
+ s.readByte();
+ data[idx] = s.readByte();
if (data[idx] == 0)
data[idx] = 1; //fixme: investigate
if (data[idx] > frames_count)
@@ -179,17 +179,17 @@ void Animation::load(Common::SeekableReadStream *s, Type type) {
break;
case kTypeVaria:
- frames_count = s->readByte();
+ frames_count = s.readByte();
debug(1, "loading varia resource, %u physical frames", frames_count);
uint16 offset[255];
for (byte i = 0; i < frames_count; ++i) {
- offset[i] = s->readUint16LE();
+ offset[i] = s.readUint16LE();
//debug(0, "%u: %04x", i, offset[i]);
}
frames = new Surface[frames_count];
for (uint16 i = 0; i < frames_count; ++i) {
//debug(0, "%04x", offset[i]);
- s->seek(offset[i] + off);
+ s.seek(offset[i] + off);
frames[i].load(s, Surface::kTypeOns);
}
diff --git a/engines/teenagent/animation.h b/engines/teenagent/animation.h
index e98bb42ea0..d9092d1707 100644
--- a/engines/teenagent/animation.h
+++ b/engines/teenagent/animation.h
@@ -35,7 +35,7 @@ public:
enum Type {kTypeLan, kTypeVaria, kTypeInventory};
Animation();
- void load(Common::SeekableReadStream *s, Type type = kTypeLan);
+ void load(Common::SeekableReadStream&, Type type = kTypeLan);
void free();
Surface *firstFrame();
diff --git a/engines/teenagent/inventory.cpp b/engines/teenagent/inventory.cpp
index 4951b2d940..2b858bbb4d 100644
--- a/engines/teenagent/inventory.cpp
+++ b/engines/teenagent/inventory.cpp
@@ -43,7 +43,7 @@ Inventory::Inventory(TeenAgentEngine *engine) {
if (!s)
error("no inventory background");
debug(0, "loading inventory background...");
- _background.load(s, Surface::kTypeOns);
+ _background.load(*s, Surface::kTypeOns);
}
uint32 items_size = varia.getSize(4);
@@ -300,13 +300,13 @@ void Inventory::Item::load(Inventory *inventory, uint item_id) {
if (_animation.empty()) {
debug(0, "loading item %d from offset %x", obj->id, inventory->_offset[obj->id - 1]);
Common::MemoryReadStream s(inventory->_items + inventory->_offset[obj->id - 1], inventory->_offset[obj->id] - inventory->_offset[obj->id - 1]);
- _animation.load(&s, Animation::kTypeInventory);
+ _animation.load(s, Animation::kTypeInventory);
}
} else {
if (_surface.empty()) {
debug(0, "loading item %d from offset %x", obj->id, inventory->_offset[obj->id - 1]);
Common::MemoryReadStream s(inventory->_items + inventory->_offset[obj->id - 1], inventory->_offset[obj->id] - inventory->_offset[obj->id - 1]);
- _surface.load(&s, Surface::kTypeOns);
+ _surface.load(s, Surface::kTypeOns);
}
}
}
diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp
index 4be6c9c31a..39b77ea447 100644
--- a/engines/teenagent/scene.cpp
+++ b/engines/teenagent/scene.cpp
@@ -57,7 +57,7 @@ Scene::Scene(TeenAgentEngine *engine, OSystem *system) : intro(false), _id(0), o
if (!s)
error("invalid resource data");
- teenagent.load(s, Animation::kTypeVaria);
+ teenagent.load(*s, Animation::kTypeVaria);
if (teenagent.empty())
error("invalid mark animation");
@@ -65,7 +65,7 @@ Scene::Scene(TeenAgentEngine *engine, OSystem *system) : intro(false), _id(0), o
if (!s)
error("invalid resource data");
- teenagent_idle.load(s, Animation::kTypeVaria);
+ teenagent_idle.load(*s, Animation::kTypeVaria);
if (teenagent_idle.empty())
error("invalid mark animation");
@@ -340,7 +340,7 @@ void Scene::loadOns() {
for (uint32 i = 0; i < ons_count; ++i) {
Common::ScopedPtr<Common::SeekableReadStream> s(res->ons.getStream(on_id[i]));
if (s) {
- ons[i].load(s, Surface::kTypeOns);
+ ons[i].load(*s, Surface::kTypeOns);
}
}
}
@@ -363,7 +363,7 @@ void Scene::loadLans() {
Common::ScopedPtr<Common::SeekableReadStream> s(res->loadLan000(res_id));
if (s) {
- animation[i].load(s, Animation::kTypeLan);
+ animation[i].load(*s, Animation::kTypeLan);
if (bxv != 0 && bxv != 0xff)
animation[i].id = bxv;
}
@@ -412,7 +412,7 @@ void Scene::init(int id, const Common::Point &pos) {
sub_hack = 2;
}
}
- on.load(stream, SurfaceList::kTypeOn, sub_hack);
+ on.load(*stream, SurfaceList::kTypeOn, sub_hack);
loadOns();
loadLans();
@@ -434,7 +434,7 @@ void Scene::playAnimation(byte idx, uint id, bool loop, bool paused, bool ignore
if (!s)
error("playing animation %u failed", id);
- custom_animation[idx].load(s);
+ custom_animation[idx].load(*s);
custom_animation[idx].loop = loop;
custom_animation[idx].paused = paused;
custom_animation[idx].ignore = ignore;
@@ -446,7 +446,7 @@ void Scene::playActorAnimation(uint id, bool loop, bool ignore) {
if (!s)
error("playing animation %u failed", id);
- actor_animation.load(s);
+ actor_animation.load(*s);
actor_animation.loop = loop;
actor_animation.ignore = ignore;
actor_animation.id = id;
diff --git a/engines/teenagent/surface.cpp b/engines/teenagent/surface.cpp
index 2e23c7a8ed..e8b5a8ad59 100644
--- a/engines/teenagent/surface.cpp
+++ b/engines/teenagent/surface.cpp
@@ -33,26 +33,26 @@ Surface::~Surface() {
free();
}
-void Surface::load(Common::SeekableReadStream *stream, Type type) {
+void Surface::load(Common::SeekableReadStream &stream, Type type) {
//debug(0, "load()");
free();
x = y = 0;
- uint16 w_ = stream->readUint16LE();
- uint16 h_ = stream->readUint16LE();
+ uint16 w_ = stream.readUint16LE();
+ uint16 h_ = stream.readUint16LE();
if (type != kTypeLan) {
- uint16 pos = stream->readUint16LE();
+ uint16 pos = stream.readUint16LE();
x = pos % 320;
y = pos / 320;
}
//debug(0, "declared info: %ux%u (%04xx%04x) -> %u,%u", w_, h_, w_, h_, x, y);
- if (stream->eos() || w_ == 0)
+ if (stream.eos() || w_ == 0)
return;
- if (w_ * h_ > stream->size()) {
+ if (w_ * h_ > stream.size()) {
debug(0, "invalid surface %ux%u -> %u,%u", w_, h_, x, y);
return;
}
@@ -60,7 +60,7 @@ void Surface::load(Common::SeekableReadStream *stream, Type type) {
//debug(0, "creating surface %ux%u -> %u,%u", w_, h_, x, y);
create(w_, h_, Graphics::PixelFormat::createFormatCLUT8());
- stream->read(pixels, w_ * h_);
+ stream.read(pixels, w_ * h_);
}
Common::Rect Surface::render(Graphics::Surface *surface, int dx, int dy, bool mirror, Common::Rect src_rect, uint zoom) const {
diff --git a/engines/teenagent/surface.h b/engines/teenagent/surface.h
index 5f74176c68..64e45a7330 100644
--- a/engines/teenagent/surface.h
+++ b/engines/teenagent/surface.h
@@ -40,7 +40,7 @@ public:
Surface();
~Surface();
- void load(Common::SeekableReadStream *stream, Type type);
+ void load(Common::SeekableReadStream&, Type type);
Common::Rect render(Graphics::Surface *surface, int dx = 0, int dy = 0, bool mirror = false, Common::Rect src_rect = Common::Rect(), uint zoom = 256) const;
bool empty() const { return pixels == NULL; }
diff --git a/engines/teenagent/surface_list.cpp b/engines/teenagent/surface_list.cpp
index e98153a935..7f7eb1dc38 100644
--- a/engines/teenagent/surface_list.cpp
+++ b/engines/teenagent/surface_list.cpp
@@ -31,11 +31,11 @@ SurfaceList::~SurfaceList() {
free();
}
-void SurfaceList::load(Common::SeekableReadStream *stream, Type type, int sub_hack) {
+void SurfaceList::load(Common::SeekableReadStream &stream, Type type, int sub_hack) {
free();
- byte fn = stream->readByte();
- if (stream->eos())
+ byte fn = stream.readByte();
+ if (stream.eos())
return;
surfaces_n = fn - sub_hack;
@@ -47,11 +47,11 @@ void SurfaceList::load(Common::SeekableReadStream *stream, Type type, int sub_ha
surfaces = new Surface[surfaces_n];
for (byte i = 0; i < surfaces_n; ++i) {
- uint offset = stream->readUint16LE();
- uint pos = stream->pos();
- stream->seek(offset);
+ uint offset = stream.readUint16LE();
+ uint pos = stream.pos();
+ stream.seek(offset);
surfaces[i].load(stream, Surface::kTypeOns);
- stream->seek(pos);
+ stream.seek(pos);
}
}
diff --git a/engines/teenagent/surface_list.h b/engines/teenagent/surface_list.h
index a199839184..fcb4fb25c5 100644
--- a/engines/teenagent/surface_list.h
+++ b/engines/teenagent/surface_list.h
@@ -33,7 +33,7 @@ public:
SurfaceList();
~SurfaceList();
- void load(Common::SeekableReadStream *stream, Type type, int sub_hack = 0);
+ void load(Common::SeekableReadStream&, Type type, int sub_hack = 0);
void free();
void render(Graphics::Surface *surface, const Common::Rect & clip) const;
diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp
index 0289b994e6..e6a248334c 100644
--- a/engines/teenagent/teenagent.cpp
+++ b/engines/teenagent/teenagent.cpp
@@ -386,7 +386,7 @@ bool TeenAgentEngine::showLogo() {
}
Surface s;
- s.load(frame, Surface::kTypeOns);
+ s.load(*frame, Surface::kTypeOns);
if (s.empty()) {
free(bg);
return true;