2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2007-01-14 21:29:12 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PARALLACTION_GRAPHICS_H
|
|
|
|
#define PARALLACTION_GRAPHICS_H
|
|
|
|
|
2007-04-07 10:02:59 +00:00
|
|
|
#include "common/rect.h"
|
2007-03-03 10:10:46 +00:00
|
|
|
#include "common/stream.h"
|
|
|
|
|
2007-08-06 13:22:21 +00:00
|
|
|
#include "graphics/surface.h"
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-04-07 10:02:59 +00:00
|
|
|
#include "parallaction/defs.h"
|
|
|
|
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
namespace Parallaction {
|
|
|
|
|
|
|
|
|
2007-02-12 21:14:34 +00:00
|
|
|
#include "common/pack-start.h" // START STRUCT PACKING
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
struct PaletteFxRange {
|
|
|
|
|
|
|
|
uint16 _timer;
|
|
|
|
uint16 _step;
|
|
|
|
uint16 _flags;
|
|
|
|
byte _first;
|
|
|
|
byte _last;
|
|
|
|
|
2007-07-01 18:18:43 +00:00
|
|
|
} PACKED_STRUCT;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-02-12 21:14:34 +00:00
|
|
|
#include "common/pack-end.h" // END STRUCT PACKING
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-04-16 20:16:18 +00:00
|
|
|
class Font {
|
|
|
|
|
2007-04-23 17:22:47 +00:00
|
|
|
protected:
|
2007-04-16 20:16:18 +00:00
|
|
|
byte _color;
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
Font() {}
|
|
|
|
virtual ~Font() {}
|
|
|
|
|
|
|
|
virtual void setColor(byte color) {
|
|
|
|
_color = color;
|
|
|
|
}
|
|
|
|
virtual uint32 getStringWidth(const char *s) = 0;
|
|
|
|
virtual uint16 height() = 0;
|
|
|
|
|
|
|
|
virtual void drawString(byte* buffer, uint32 pitch, const char *s) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2007-08-25 20:34:10 +00:00
|
|
|
|
|
|
|
struct Frames {
|
|
|
|
|
|
|
|
virtual uint16 getNum() = 0;
|
|
|
|
virtual byte* getData(uint16 index) = 0;
|
|
|
|
virtual void getRect(uint16 index, Common::Rect &r) = 0;
|
|
|
|
|
|
|
|
virtual ~Frames() { }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct Cnv : public Frames {
|
2007-04-07 10:02:59 +00:00
|
|
|
uint16 _count; // # of frames
|
|
|
|
uint16 _width; //
|
|
|
|
uint16 _height; //
|
|
|
|
byte** field_8; // unused
|
|
|
|
byte* _data;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Cnv() {
|
|
|
|
_width = _height = _count = 0;
|
|
|
|
_data = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Cnv(uint16 numFrames, uint16 width, uint16 height, byte* data) : _count(numFrames), _width(width), _height(height), _data(data) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
~Cnv() {
|
|
|
|
free(_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
byte* getFramePtr(uint16 index) {
|
|
|
|
if (index >= _count)
|
|
|
|
return NULL;
|
|
|
|
return &_data[index * _width * _height];
|
|
|
|
}
|
2007-08-25 20:34:10 +00:00
|
|
|
|
|
|
|
uint16 getNum() {
|
|
|
|
return _count;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte *getData(uint16 index) {
|
|
|
|
return getFramePtr(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void getRect(uint16 index, Common::Rect &r) {
|
|
|
|
r.left = 0;
|
|
|
|
r.top = 0;
|
|
|
|
r.setWidth(_width);
|
|
|
|
r.setHeight(_height);
|
|
|
|
}
|
2007-04-07 10:02:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-04-07 16:40:27 +00:00
|
|
|
#define NUM_BUFFERS 4
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
class Parallaction;
|
|
|
|
|
2007-03-12 19:58:10 +00:00
|
|
|
struct DoorData;
|
|
|
|
struct GetData;
|
2007-09-02 18:34:11 +00:00
|
|
|
struct Label;
|
2007-04-15 20:57:56 +00:00
|
|
|
|
2007-08-06 22:03:17 +00:00
|
|
|
struct MaskBuffer {
|
2007-08-06 19:13:51 +00:00
|
|
|
// handles a 2-bit depth buffer used for z-buffering
|
|
|
|
|
|
|
|
uint16 w;
|
|
|
|
uint16 internalWidth;
|
|
|
|
uint16 h;
|
|
|
|
uint size;
|
|
|
|
byte *data;
|
|
|
|
|
|
|
|
public:
|
2007-08-07 14:53:58 +00:00
|
|
|
MaskBuffer() : w(0), internalWidth(0), h(0), size(0), data(0) {
|
2007-08-06 19:13:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void create(uint16 width, uint16 height) {
|
|
|
|
w = width;
|
|
|
|
internalWidth = w >> 2;
|
|
|
|
h = height;
|
|
|
|
size = (internalWidth * h);
|
2007-08-06 21:58:25 +00:00
|
|
|
data = (byte*)calloc(size, 1);
|
2007-08-06 19:13:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void free() {
|
2007-11-18 13:22:38 +00:00
|
|
|
::free(data);
|
2007-08-07 14:53:58 +00:00
|
|
|
data = 0;
|
|
|
|
w = 0;
|
|
|
|
h = 0;
|
|
|
|
internalWidth = 0;
|
|
|
|
size = 0;
|
2007-08-06 19:13:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline byte getValue(uint16 x, uint16 y) {
|
|
|
|
byte m = data[(x >> 2) + y * internalWidth];
|
|
|
|
uint n = (x & 3) << 1;
|
|
|
|
return ((3 << n) & m) >> n;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2007-08-09 18:02:37 +00:00
|
|
|
class Palette {
|
|
|
|
|
|
|
|
byte _data[768];
|
|
|
|
uint _colors;
|
|
|
|
uint _size;
|
|
|
|
bool _hb;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
public:
|
2007-08-09 18:02:37 +00:00
|
|
|
Palette();
|
|
|
|
Palette(const Palette &pal);
|
|
|
|
|
2007-08-11 12:26:17 +00:00
|
|
|
void clone(const Palette &pal);
|
|
|
|
|
2007-08-09 18:02:37 +00:00
|
|
|
void makeBlack();
|
|
|
|
void setEntries(byte* data, uint first, uint num);
|
|
|
|
void setEntry(uint index, int red, int green, int blue);
|
|
|
|
void makeGrayscale();
|
|
|
|
void fadeTo(const Palette& target, uint step);
|
|
|
|
uint fillRGBA(byte *rgba);
|
2007-03-28 20:12:00 +00:00
|
|
|
|
2007-08-09 18:02:37 +00:00
|
|
|
void rotate(uint first, uint last, bool forward);
|
|
|
|
};
|
|
|
|
|
|
|
|
class Gfx {
|
|
|
|
|
|
|
|
public:
|
2007-01-14 21:29:12 +00:00
|
|
|
enum Buffers {
|
|
|
|
// bit buffers
|
|
|
|
kBitFront,
|
|
|
|
kBitBack,
|
2007-08-06 13:22:21 +00:00
|
|
|
kBit2
|
2007-01-14 21:29:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2007-08-07 14:05:39 +00:00
|
|
|
// balloons and text
|
2007-03-13 19:59:45 +00:00
|
|
|
void drawBalloon(const Common::Rect& r, uint16 arg_8);
|
2007-07-02 07:32:06 +00:00
|
|
|
void displayString(uint16 x, uint16 y, const char *text, byte color);
|
2007-05-06 09:31:45 +00:00
|
|
|
void displayCenteredString(uint16 y, const char *text);
|
2007-07-26 18:30:27 +00:00
|
|
|
bool displayWrappedString(char *text, uint16 x, uint16 y, byte color, int16 wrapwidth = -1);
|
2007-01-14 21:29:12 +00:00
|
|
|
uint16 getStringWidth(const char *text);
|
|
|
|
void getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height);
|
2007-08-07 14:05:39 +00:00
|
|
|
|
2007-11-21 20:04:14 +00:00
|
|
|
// labels
|
|
|
|
Label *_label;
|
|
|
|
void setLabel(Label *label);
|
2007-09-02 18:34:11 +00:00
|
|
|
|
2007-08-07 14:05:39 +00:00
|
|
|
// cut/paste
|
2007-08-07 15:08:45 +00:00
|
|
|
void flatBlitCnv(Graphics::Surface *cnv, int16 x, int16 y, Gfx::Buffers buffer);
|
2007-08-25 20:34:10 +00:00
|
|
|
void flatBlitCnv(Frames *cnv, uint16 frame, int16 x, int16 y, Gfx::Buffers buffer);
|
2007-08-07 15:08:45 +00:00
|
|
|
void blitCnv(Graphics::Surface *cnv, int16 x, int16 y, uint16 z, Gfx::Buffers buffer);
|
2007-08-07 14:05:39 +00:00
|
|
|
void restoreBackground(const Common::Rect& r);
|
2007-03-12 19:58:10 +00:00
|
|
|
void backupDoorBackground(DoorData *data, int16 x, int16 y);
|
2007-08-08 18:33:55 +00:00
|
|
|
void restoreDoorBackground(const Common::Rect& r, byte *data, byte* background);
|
2007-03-12 19:58:10 +00:00
|
|
|
void backupGetBackground(GetData *data, int16 x, int16 y);
|
2007-08-04 18:58:50 +00:00
|
|
|
void restoreGetBackground(const Common::Rect& r, byte *data);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
|
2007-08-07 14:05:39 +00:00
|
|
|
// low level surfaces
|
2007-03-12 20:41:25 +00:00
|
|
|
void clearScreen(Gfx::Buffers buffer);
|
|
|
|
void copyScreen(Gfx::Buffers srcbuffer, Gfx::Buffers dstbuffer);
|
2007-03-13 23:30:36 +00:00
|
|
|
void copyRect(Gfx::Buffers dstbuffer, const Common::Rect& r, byte *src, uint16 pitch);
|
|
|
|
void grabRect(byte *dst, const Common::Rect& r, Gfx::Buffers srcbuffer, uint16 pitch);
|
|
|
|
void floodFill(Gfx::Buffers buffer, const Common::Rect& r, byte color);
|
2007-11-01 21:56:14 +00:00
|
|
|
void invertRect(Gfx::Buffers buffer, const Common::Rect& r);
|
2007-03-18 09:16:12 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
// palette
|
2007-08-09 18:02:37 +00:00
|
|
|
void setPalette(Palette palette);
|
2007-03-28 20:12:00 +00:00
|
|
|
void setBlackPalette();
|
|
|
|
void animatePalette();
|
2007-04-21 12:51:40 +00:00
|
|
|
|
|
|
|
// amiga specific
|
|
|
|
void setHalfbriteMode(bool enable);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-08-07 14:05:39 +00:00
|
|
|
// misc
|
|
|
|
int16 queryMask(int16 v);
|
2007-08-11 17:25:57 +00:00
|
|
|
void setFont(Font* font);
|
2007-08-07 14:05:39 +00:00
|
|
|
void swapBuffers();
|
|
|
|
void updateScreen();
|
|
|
|
void setBackground(Graphics::Surface *surf);
|
|
|
|
void setMask(MaskBuffer *buffer);
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
// init
|
2007-03-12 20:41:25 +00:00
|
|
|
Gfx(Parallaction* vm);
|
|
|
|
virtual ~Gfx();
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
public:
|
2007-03-15 21:56:21 +00:00
|
|
|
uint16 _bgLayers[4];
|
|
|
|
PaletteFxRange _palettefx[6];
|
2007-03-28 20:12:00 +00:00
|
|
|
Palette _palette;
|
2007-03-15 21:56:21 +00:00
|
|
|
|
2007-08-12 08:47:45 +00:00
|
|
|
int _backgroundWidth;
|
|
|
|
int _backgroundHeight;
|
2007-08-12 08:37:46 +00:00
|
|
|
|
2007-08-12 08:26:20 +00:00
|
|
|
uint _screenX; // scrolling position
|
|
|
|
uint _screenY;
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
protected:
|
|
|
|
Parallaction* _vm;
|
2007-08-06 13:22:21 +00:00
|
|
|
Graphics::Surface *_buffers[NUM_BUFFERS];
|
2007-08-06 22:03:17 +00:00
|
|
|
MaskBuffer *_depthMask;
|
2007-04-16 20:16:18 +00:00
|
|
|
Font *_font;
|
2007-04-21 12:51:40 +00:00
|
|
|
bool _halfbrite;
|
2007-02-27 19:39:33 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
protected:
|
2007-11-21 20:04:14 +00:00
|
|
|
void drawInventory();
|
|
|
|
void drawLabel();
|
|
|
|
|
2007-08-12 08:47:45 +00:00
|
|
|
void initBuffers(int w, int h);
|
|
|
|
void freeBuffers();
|
|
|
|
|
2007-08-08 18:33:55 +00:00
|
|
|
void copyRect(uint width, uint height, byte *dst, uint dstPitch, byte *src, uint srcPitch);
|
2007-11-21 20:04:14 +00:00
|
|
|
|
|
|
|
void blit(const Common::Rect& r, uint16 z, byte *data, Graphics::Surface *surf);
|
|
|
|
void flatBlit(const Common::Rect& r, byte *data, Graphics::Surface *surf, byte transparentColor);
|
2007-01-14 21:29:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // Parallaction
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2007-08-06 22:03:17 +00:00
|
|
|
|
2007-08-07 15:08:45 +00:00
|
|
|
|
2007-08-25 20:34:10 +00:00
|
|
|
|
2007-09-02 18:34:11 +00:00
|
|
|
|