NEVERHOOD: Start with the BaseSurface class (doesn't do much yet)

This commit is contained in:
johndoe123 2011-06-26 18:08:18 +00:00 committed by Willem Jan Palenstijn
parent 7d5d5f139f
commit a262055df2
2 changed files with 64 additions and 0 deletions

View File

@ -24,6 +24,39 @@
namespace Neverhood {
BaseSurface::BaseSurface(NeverhoodEngine *vm, int priority, int16 width, int16 height)
: _vm(vm), _priority(priority), _visible(true) {
_drawRect.x = 0;
_drawRect.y = 0;
_drawRect.width = width;
_drawRect.height = height;
_sysRect.x = 0;
_sysRect.y = 0;
_sysRect.width = (width + 3) & 0xFFFC; // align by 4 bytes
_sysRect.height = height;
_clipRect.x1 = 0;
_clipRect.y1 = 0;
_clipRect.x2 = 640;
_clipRect.y2 = 480;
_surface = new Graphics::Surface();
_surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
}
BaseSurface::~BaseSurface() {
delete _surface;
}
void BaseSurface::draw() {
// TODO
}
void BaseSurface::addDirtyRect() {
// TODO
}
// Misc
void parseBitmapResource(byte *sprite, bool *rle, NDimensions *dimensions, NUnknown *unknown, byte **palette, byte **pixels) {
uint16 flags;

View File

@ -25,6 +25,7 @@
#include "common/array.h"
#include "common/file.h"
#include "graphics/surface.h"
#include "neverhood/neverhood.h"
namespace Neverhood {
@ -37,6 +38,36 @@ struct NUnknown {
int16 unk1, unk2;
};
struct NRect {
int16 x1, y1, x2, y2;
NRect() : x1(0), y1(0), x2(0), y2(0) {}
};
struct NDrawRect {
int16 x, y, width, height;
NDrawRect() : x(0), y(0), width(0), height(0) {}
};
// NOTE: "Restore" methods aren't need in the reimplementation as they're DirectDraw-specific
class BaseSurface {
public:
BaseSurface(NeverhoodEngine *vm, int priority, int16 width, int16 height);
virtual ~BaseSurface();
virtual void draw();
virtual void addDirtyRect();
protected:
NeverhoodEngine *_vm;
int _priority;
bool _visible;
Graphics::Surface *_surface;
NDrawRect _drawRect;
NDrawRect _sysRect;
NRect _clipRect;
};
// Misc
void parseBitmapResource(byte *sprite, bool *rle, NDimensions *dimensions, NUnknown *unknown, byte **palette, byte **pixels);
void unpackSpriteRle(byte *source, int width, int height, byte *dest, int destPitch, bool flipX, bool flipY);