Skip to content

Commit

Permalink
FULLPIPE: Bitmap loading
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Sep 6, 2013
1 parent c2103bb commit f18e318
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 5 deletions.
37 changes: 37 additions & 0 deletions engines/fullpipe/gfx.cpp
Expand Up @@ -24,8 +24,24 @@

#include "fullpipe/objects.h"

#include "common/memstream.h"

namespace Fullpipe {

void Bitmap::load(Common::ReadStream *s) {
x = s->readUint32LE();
y = s->readUint32LE();
width = s->readUint32LE();
height = s->readUint32LE();
s->readUint32LE(); // pixels
type = s->readUint32LE();
field_18 = s->readUint32LE();
flags = s->readUint32LE();

debug(9, "x: %d y: %d w: %d h: %d", x, y, width, height);
debug(9, "type: %d field_18: %d flags: 0x%x", type, field_18, flags);
}

Background::Background() {
_x = 0;
_y = 0;
Expand Down Expand Up @@ -227,6 +243,27 @@ void Picture::setAOIDs() {
warning("STUB: Picture::setAOIDs()");
}

void Picture::init() {
_bitmap = new Bitmap();

getDibInfo();

_bitmap->flags |= 0x1000000;
}

void Picture::getDibInfo() {
int off = _dataSize & ~0xf;

if (_dataSize != off) {
warning("Uneven data size: 0x%x", _dataSize);
}

Common::MemoryReadStream *s = new Common::MemoryReadStream(_data + off, 32);

_bitmap->load(s);
_bitmap->pixels = _data;
}

BigPicture::BigPicture() {
}

Expand Down
19 changes: 18 additions & 1 deletion engines/fullpipe/gfx.h
Expand Up @@ -23,12 +23,27 @@
#ifndef FULLPIPE_GFX_H
#define FULLPIPE_GFX_H

class Common::ReadStream;

namespace Fullpipe {

class ShadowsItemArray : public CObArray {
// empty
};

struct Bitmap {
int x;
int y;
int width;
int height;
byte *pixels;
int type;
int field_18;
int flags;

void load(Common::ReadStream *s);
};

class Picture : public MemoryObject {
friend class Movement;

Expand All @@ -39,7 +54,7 @@ class Picture : public MemoryObject {
int _field_44;
int _width;
int _height;
int _bitmap;
Bitmap *_bitmap;
int _field_54;
MemoryObject2 *_memoryObject2;
int _alpha;
Expand All @@ -49,6 +64,8 @@ class Picture : public MemoryObject {
Picture();
virtual bool load(MfcArchive &file);
void setAOIDs();
void init();
void getDibInfo();
};

class BigPicture : public Picture {
Expand Down
18 changes: 15 additions & 3 deletions engines/fullpipe/utils.cpp
Expand Up @@ -134,15 +134,27 @@ void MemoryObject::loadFile(char *filename) {
if (s) {
assert(s->size() > 0);

debug(0, "Loading %s", filename);
_data = calloc(s->size(), 1);
s->read(_data, s->size());
_dataSize = s->size();

debug(0, "Loading %s (%d bytes)", filename, _dataSize);
_data = (byte *)calloc(_dataSize, 1);
s->read(_data, _dataSize);

delete s;
}
}
}

void *MemoryObject::getData() {
load();

if (_field_14 || _flags & 1) {
return _data;
} else {
error("Unhandled packed data");
}
}

MemoryObject2::MemoryObject2() {
_data2 = 0;
}
Expand Down
4 changes: 3 additions & 1 deletion engines/fullpipe/utils.h
Expand Up @@ -89,7 +89,7 @@ class MemoryObject : CObject {
char _field_15;
char _field_16;
char _field_17;
void *_data;
byte *_data;
int _dataSize;
int _flags;
NGIArchive *_libHandle;
Expand All @@ -98,6 +98,8 @@ class MemoryObject : CObject {
MemoryObject();
virtual bool load(MfcArchive &file);
void loadFile(char *filename);
void load() { loadFile(_filename); }
void *getData();
};

class MemoryObject2 : public MemoryObject {
Expand Down

0 comments on commit f18e318

Please sign in to comment.