Moved depth buffer and palette rotation data into BackgroundInfo.

svn-id: r30725
This commit is contained in:
Nicola Mettifogo 2008-02-02 00:41:31 +00:00
parent 7adfb1a295
commit 249877fa82
6 changed files with 62 additions and 57 deletions

View file

@ -331,7 +331,7 @@ void Parallaction_ns::_c_onMouse(void *parm) {
void Parallaction_ns::_c_setMask(void *parm) {
memset(_gfx->_backgroundInfo->mask.data + 3600, 0, 3600);
_gfx->_bgLayers[1] = 500;
_gfx->_backgroundInfo->layers[1] = 500;
return;
}

View file

@ -133,7 +133,7 @@ private:
Frames* loadExternalStaticCnv(const char *filename);
void loadBackground(BackgroundInfo& info, const char *filename);
void loadMaskAndPath(BackgroundInfo& info, const char *name);
void parseDepths(Common::SeekableReadStream &stream);
void parseDepths(BackgroundInfo &info, Common::SeekableReadStream &stream);
void parseBackground(BackgroundInfo& info, Common::SeekableReadStream &stream);
Font *createFont(const char *name, Cnv* cnv);

View file

@ -24,7 +24,6 @@
*/
#include "graphics/iff.h"
#include "graphics/surface.h"
#include "parallaction/parallaction.h"
@ -321,7 +320,6 @@ DosDisk_ns::~DosDisk_ns() {
// loads a cnv from an external file
//
Cnv* DosDisk_ns::loadExternalCnv(const char *filename) {
// printf("Gfx::loadExternalCnv(%s)...", filename);
char path[PATH_LEN];
@ -367,7 +365,6 @@ Frames* DosDisk_ns::loadExternalStaticCnv(const char *filename) {
}
Cnv* DosDisk_ns::loadCnv(const char *filename) {
// printf("Gfx::loadCnv(%s)\n", filename);
char path[PATH_LEN];
@ -525,12 +522,11 @@ void DosDisk_ns::unpackBackground(Common::ReadStream *stream, byte *screen, byte
return;
}
void DosDisk_ns::parseDepths(Common::SeekableReadStream &stream) {
_vm->_gfx->_bgLayers[0] = stream.readByte();
_vm->_gfx->_bgLayers[1] = stream.readByte();
_vm->_gfx->_bgLayers[2] = stream.readByte();
_vm->_gfx->_bgLayers[3] = stream.readByte();
void DosDisk_ns::parseDepths(BackgroundInfo &info, Common::SeekableReadStream &stream) {
info.layers[0] = stream.readByte();
info.layers[1] = stream.readByte();
info.layers[2] = stream.readByte();
info.layers[3] = stream.readByte();
}
@ -545,14 +541,17 @@ void DosDisk_ns::parseBackground(BackgroundInfo& info, Common::SeekableReadStrea
info.palette.setEntry(i, tmp[0], tmp[1], tmp[2]);
}
parseDepths(stream);
parseDepths(info, stream);
PaletteFxRange range;
for (uint32 _si = 0; _si < 6; _si++) {
_vm->_gfx->_palettefx[_si]._timer = stream.readUint16BE();
_vm->_gfx->_palettefx[_si]._step = stream.readUint16BE();
_vm->_gfx->_palettefx[_si]._flags = stream.readUint16BE();
_vm->_gfx->_palettefx[_si]._first = stream.readByte();
_vm->_gfx->_palettefx[_si]._last = stream.readByte();
range._timer = stream.readUint16BE();
range._step = stream.readUint16BE();
range._flags = stream.readUint16BE();
range._first = stream.readByte();
range._last = stream.readByte();
info.setPaletteRange(_si, range);
}
}
@ -590,7 +589,7 @@ void DosDisk_ns::loadMaskAndPath(BackgroundInfo& info, const char *name) {
if (!_resArchive.openArchivedFile(path))
errorFileNotFound(name);
parseDepths(_resArchive);
parseDepths(info, _resArchive);
info.path.create(info.width, info.height);
_resArchive.read(info.path.data, info.path.size);
@ -1145,15 +1144,18 @@ void AmigaDisk_ns::loadBackground(BackgroundInfo& info, const char *name) {
Common::SeekableReadStream *s = openArchivedFile(name, true);
byte *pal;
PaletteFxRange ranges[6];
BackgroundDecoder decoder(*s, info.bg, pal, _vm->_gfx->_palettefx);
BackgroundDecoder decoder(*s, info.bg, pal, ranges);
decoder.decode();
uint i;
info.width = info.bg.w;
info.height = info.bg.h;
byte *p = pal;
for (uint i = 0; i < 32; i++) {
for (i = 0; i < 32; i++) {
byte r = *p >> 2;
p++;
byte g = *p >> 2;
@ -1165,6 +1167,10 @@ void AmigaDisk_ns::loadBackground(BackgroundInfo& info, const char *name) {
free(pal);
for (i = 0; i < 6; i++) {
info.setPaletteRange(i, ranges[i]);
}
delete s;
return;
@ -1191,12 +1197,9 @@ void AmigaDisk_ns::loadMask(BackgroundInfo& info, const char *name) {
g = s->readByte();
b = s->readByte();
_vm->_gfx->_bgLayers[i] = (((r << 4) & 0xF00) | (g & 0xF0) | (b >> 4)) & 0xFF;
// printf("rgb = (%x, %x, %x) -> %x\n", r, g, b, _vm->_gfx->_bgLayers[i]);
info.layers[i] = (((r << 4) & 0xF00) | (g & 0xF0) | (b >> 4)) & 0xFF;
}
s->seek(0x126, SEEK_SET); // HACK: skipping IFF/ILBM header should be done by analysis, not magic
Graphics::PackBitsReadStream stream(*s);

View file

@ -413,10 +413,11 @@ DECLARE_INSTRUCTION_OPCODE(color) {
DECLARE_INSTRUCTION_OPCODE(mask) {
Instruction *inst = *_instRunCtxt.inst;
#if 0
_gfx->_bgLayers[0] = inst->_opA.getRValue();
_gfx->_bgLayers[1] = inst->_opB.getRValue();
_gfx->_bgLayers[2] = inst->_opC.getRValue();
#endif
}

View file

@ -260,17 +260,18 @@ void Gfx::animatePalette() {
// avoid forcing setPalette when not needed
bool done = false;
PaletteFxRange *range;
for (uint16 i = 0; i < 4; i++) {
range = &_backgroundInfo->ranges[i];
if ((_palettefx[i]._flags & 1) == 0) continue; // animated palette
if ((range->_flags & 1) == 0) continue; // animated palette
range->_timer += range->_step * 2; // update timer
_palettefx[i]._timer += _palettefx[i]._step * 2; // update timer
if (range->_timer < 0x4000) continue; // check timeout
if (_palettefx[i]._timer < 0x4000) continue; // check timeout
range->_timer = 0; // reset timer
_palettefx[i]._timer = 0; // reset timer
_palette.rotate(_palettefx[i]._first, _palettefx[i]._last, (_palettefx[i]._flags & 2) != 0);
_palette.rotate(range->_first, range->_last, (range->_flags & 2) != 0);
done = true;
}
@ -733,7 +734,7 @@ void Gfx::grabBackground(const Common::Rect& r, Graphics::Surface &dst) {
uint16 Gfx::queryMask(uint16 v) {
for (uint16 _si = 0; _si < 3; _si++) {
if (_bgLayers[_si+1] > v) return _si;
if (_backgroundInfo->layers[_si+1] > v) return _si;
}
return BUFFER_FOREGROUND;
@ -757,10 +758,6 @@ Gfx::Gfx(Parallaction* vm) :
_screenX = 0;
_screenY = 0;
_bgLayers[0] = _bgLayers[1] = _bgLayers[2] = _bgLayers[3] = 0;
memset(_palettefx, 0, sizeof(_palettefx));
_halfbrite = false;
_hbCircleRadius = 0;

View file

@ -335,6 +335,19 @@ struct BackgroundInfo {
PathBuffer path;
Palette palette;
int layers[4];
PaletteFxRange ranges[6];
BackgroundInfo() : width(0), height(0) {
layers[0] = layers[1] = layers[2] = layers[3] = 0;
memset(ranges, 0, sizeof(ranges));
}
void setPaletteRange(int index, const PaletteFxRange& range) {
assert(index < 6);
memcpy(&ranges[index], &range, sizeof(PaletteFxRange));
}
};
@ -348,25 +361,15 @@ class Gfx {
public:
Disk *_disk;
GfxObjList _gfxobjList[3];
GfxObj* loadAnim(const char *name);
GfxObj* loadGet(const char *name);
GfxObj* loadDoor(const char *name);
void clearGfxObjects();
void showGfxObj(GfxObj* obj, bool visible);
GfxObjList _gfxobjList[3];
void drawGfxObjects(Graphics::Surface &surf);
void showGfxObj(GfxObj* obj, bool visible);
void clearGfxObjects();
void sortAnimations();
BackgroundInfo *_backgroundInfo;
void freeBackground();
void setBackground(uint type, const char* name, const char* mask, const char* path);
public:
// balloons and text
void getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height);
// labels
void setFloatingLabel(Label *label);
Label *renderFloatingLabel(Font *font, char *text);
@ -375,27 +378,30 @@ public:
void hideLabel(uint id);
void freeLabels();
// cut/paste
void patchBackground(Graphics::Surface &surf, int16 x, int16 y, bool mask = false);
// dialogue balloons
int setLocationBalloon(char *text, bool endGame);
int setDialogueBalloon(char *text, uint16 winding, byte textColor);
int setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, byte textColor);
void setBalloonText(uint id, char *text, byte textColor);
int hitTestDialogueBalloon(int x, int y);
void getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height);
// other items
int setItem(Frames* frames, uint16 x, uint16 y);
void setItemFrame(uint item, uint16 f);
void hideDialogueStuff();
void freeBalloons();
void freeItems();
// low level surfaces
// background surface
BackgroundInfo *_backgroundInfo;
void setBackground(uint type, const char* name, const char* mask, const char* path);
void clearBackground();
void patchBackground(Graphics::Surface &surf, int16 x, int16 y, bool mask = false);
void grabBackground(const Common::Rect& r, Graphics::Surface &dst);
void fillBackground(const Common::Rect& r, byte color);
void invertBackground(const Common::Rect& r);
void freeBackground();
// palette
void setPalette(Palette palette);
@ -408,17 +414,15 @@ public:
// misc
uint16 queryMask(uint16 v);
void updateScreen();
void setMask(MaskBuffer *buffer);
// init
Gfx(Parallaction* vm);
virtual ~Gfx();
void updateScreen();
public:
uint16 _bgLayers[4];
PaletteFxRange _palettefx[6];
Palette _palette;
uint _screenX; // scrolling position