Changed Gfx::_backgroundInfo to be a pointer. This temporarily kills all z-buffering.

svn-id: r33468
This commit is contained in:
Nicola Mettifogo 2008-07-31 12:26:12 +00:00
parent 538fdcc61a
commit 591973c827
8 changed files with 51 additions and 53 deletions

View file

@ -291,8 +291,8 @@ void Parallaction_ns::_c_onMouse(void *parm) {
void Parallaction_ns::_c_setMask(void *parm) {
memset(_gfx->_backgroundInfo.mask.data + 3600, 0, 3600);
_gfx->_backgroundInfo.layers[1] = 500;
memset(_gfx->_backgroundInfo->mask.data + 3600, 0, 3600);
_gfx->_backgroundInfo->layers[1] = 500;
return;
}
@ -502,11 +502,11 @@ void Parallaction_ns::_c_shade(void *parm) {
_rightHandAnim->_top
);
uint16 _di = r.left/4 + r.top * _gfx->_backgroundInfo.mask.internalWidth;
uint16 _di = r.left/4 + r.top * _gfx->_backgroundInfo->mask.internalWidth;
for (uint16 _si = r.top; _si < r.bottom; _si++) {
memset(_gfx->_backgroundInfo.mask.data + _di, 0, r.width()/4+1);
_di += _gfx->_backgroundInfo.mask.internalWidth;
memset(_gfx->_backgroundInfo->mask.data + _di, 0, r.width()/4+1);
_di += _gfx->_backgroundInfo->mask.internalWidth;
}
return;

View file

@ -347,7 +347,7 @@ void Parallaction_ns::drawAnimations() {
if (anim->_flags & kFlagsNoMasked)
layer = 3;
else
layer = _gfx->_backgroundInfo.getLayer(anim->_top + anim->height());
layer = _gfx->_backgroundInfo->getLayer(anim->_top + anim->height());
if (obj) {
_gfx->showGfxObj(obj, true);

View file

@ -291,8 +291,8 @@ void Gfx::blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16
for (uint16 j = 0; j < q.width(); j++) {
if (*s != transparentColor) {
if (_backgroundInfo.mask.data && (z < LAYER_FOREGROUND)) {
byte v = _backgroundInfo.mask.getValue(dp.x + j, dp.y + i);
if (_backgroundInfo->mask.data && (z < LAYER_FOREGROUND)) {
byte v = _backgroundInfo->mask.getValue(dp.x + j, dp.y + i);
if (z >= v) *d = 5;
} else {
*d = 5;
@ -308,13 +308,13 @@ void Gfx::blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16
}
} else {
if (_backgroundInfo.mask.data && (z < LAYER_FOREGROUND)) {
if (_backgroundInfo->mask.data && (z < LAYER_FOREGROUND)) {
for (uint16 i = 0; i < q.height(); i++) {
for (uint16 j = 0; j < q.width(); j++) {
if (*s != transparentColor) {
byte v = _backgroundInfo.mask.getValue(dp.x + j, dp.y + i);
byte v = _backgroundInfo->mask.getValue(dp.x + j, dp.y + i);
if (z >= v) *d = *s;
}

View file

@ -269,7 +269,7 @@ void Gfx::animatePalette() {
PaletteFxRange *range;
for (uint16 i = 0; i < 4; i++) {
range = &_backgroundInfo.ranges[i];
range = &_backgroundInfo->ranges[i];
if ((range->_flags & 1) == 0) continue; // animated palette
range->_timer += range->_step * 2; // update timer
@ -359,7 +359,7 @@ void Gfx::clearScreen() {
}
void Gfx::beginFrame() {
_skipBackground = (_backgroundInfo.bg.pixels == 0); // don't render frame if background is missing
_skipBackground = (_backgroundInfo->bg.pixels == 0); // don't render frame if background is missing
if (!_skipBackground) {
int32 oldBackgroundMode = _varBackgroundMode;
@ -370,11 +370,11 @@ void Gfx::beginFrame() {
_bitmapMask.free();
break;
case 2:
_bitmapMask.create(_backgroundInfo.width, _backgroundInfo.height, 1);
_bitmapMask.create(_backgroundInfo->width, _backgroundInfo->height, 1);
byte *data = (byte*)_bitmapMask.pixels;
for (uint y = 0; y < _bitmapMask.h; y++) {
for (uint x = 0; x < _bitmapMask.w; x++) {
*data++ = _backgroundInfo.mask.getValue(x, y);
*data++ = _backgroundInfo->mask.getValue(x, y);
}
}
break;
@ -389,7 +389,7 @@ void Gfx::beginFrame() {
warning("Path zones are supported only in Big Red Adventure");
}
if (_skipBackground || (_vm->_screenWidth >= _backgroundInfo.width)) {
if (_skipBackground || (_vm->_screenWidth >= _backgroundInfo->width)) {
_varScrollX = 0;
} else {
_varScrollX = getVar("scroll_x");
@ -416,22 +416,22 @@ void Gfx::updateScreen() {
if (!_skipBackground) {
// background may not cover the whole screen, so adjust bulk update size
uint w = MIN(_vm->_screenWidth, (int32)_backgroundInfo.width);
uint h = MIN(_vm->_screenHeight, (int32)_backgroundInfo.height);
uint w = MIN(_vm->_screenWidth, (int32)_backgroundInfo->width);
uint h = MIN(_vm->_screenHeight, (int32)_backgroundInfo->height);
byte *backgroundData = 0;
uint16 backgroundPitch = 0;
switch (_varBackgroundMode) {
case 1:
backgroundData = (byte*)_backgroundInfo.bg.getBasePtr(_varScrollX, 0);
backgroundPitch = _backgroundInfo.bg.pitch;
backgroundData = (byte*)_backgroundInfo->bg.getBasePtr(_varScrollX, 0);
backgroundPitch = _backgroundInfo->bg.pitch;
break;
case 2:
backgroundData = (byte*)_bitmapMask.getBasePtr(_varScrollX, 0);
backgroundPitch = _bitmapMask.pitch;
break;
}
g_system->copyRectToScreen(backgroundData, backgroundPitch, _backgroundInfo.x, _backgroundInfo.y, w, h);
g_system->copyRectToScreen(backgroundData, backgroundPitch, _backgroundInfo->x, _backgroundInfo->y, w, h);
}
if (_varDrawPathZones == 1) {
@ -499,17 +499,17 @@ void Gfx::patchBackground(Graphics::Surface &surf, int16 x, int16 y, bool mask)
Common::Rect r(surf.w, surf.h);
r.moveTo(x, y);
uint16 z = (mask) ? _backgroundInfo.getLayer(y) : LAYER_FOREGROUND;
blt(r, (byte*)surf.pixels, &_backgroundInfo.bg, z, 0);
uint16 z = (mask) ? _backgroundInfo->getLayer(y) : LAYER_FOREGROUND;
blt(r, (byte*)surf.pixels, &_backgroundInfo->bg, z, 0);
}
void Gfx::fillBackground(const Common::Rect& r, byte color) {
_backgroundInfo.bg.fillRect(r, color);
_backgroundInfo->bg.fillRect(r, color);
}
void Gfx::invertBackground(const Common::Rect& r) {
byte *d = (byte*)_backgroundInfo.bg.getBasePtr(r.left, r.top);
byte *d = (byte*)_backgroundInfo->bg.getBasePtr(r.left, r.top);
for (int i = 0; i < r.height(); i++) {
for (int j = 0; j < r.width(); j++) {
@ -517,7 +517,7 @@ void Gfx::invertBackground(const Common::Rect& r) {
d++;
}
d += (_backgroundInfo.bg.pitch - r.width());
d += (_backgroundInfo->bg.pitch - r.width());
}
}
@ -724,7 +724,7 @@ void Gfx::copyRect(const Common::Rect &r, Graphics::Surface &src, Graphics::Surf
}
void Gfx::grabBackground(const Common::Rect& r, Graphics::Surface &dst) {
copyRect(r, _backgroundInfo.bg, dst);
copyRect(r, _backgroundInfo->bg, dst);
}
@ -744,6 +744,8 @@ Gfx::Gfx(Parallaction* vm) :
_screenX = 0;
_screenY = 0;
_backgroundInfo = 0;
_halfbrite = false;
_hbCircleRadius = 0;
@ -766,7 +768,6 @@ Gfx::Gfx(Parallaction* vm) :
BackgroundInfo paletteInfo;
_disk->loadSlide(paletteInfo, "pointer");
_backupPal.clone(paletteInfo.palette);
paletteInfo.free();
}
return;
@ -774,7 +775,8 @@ Gfx::Gfx(Parallaction* vm) :
Gfx::~Gfx() {
freeBackground();
delete _backgroundInfo;
freeLabels();
delete []_unpackedBitmap;
@ -829,16 +831,14 @@ void Gfx::freeItems() {
_numItems = 0;
}
void Gfx::freeBackground() {
_backgroundInfo.free();
}
void Gfx::setBackground(uint type, const char* name, const char* mask, const char* path) {
freeBackground();
delete _backgroundInfo;
_backgroundInfo = new BackgroundInfo;
if (type == kBackgroundLocation) {
_disk->loadScenery(_backgroundInfo, name, mask, path);
_disk->loadScenery(*_backgroundInfo, name, mask, path);
// The PC version of BRA needs the entries 20-31 of the palette to be constant, but
// the background resource files are screwed up. The right colors come from an unused
@ -847,17 +847,17 @@ void Gfx::setBackground(uint type, const char* name, const char* mask, const cha
int r, g, b;
for (uint i = 16; i < 32; i++) {
_backupPal.getEntry(i, r, g, b);
_backgroundInfo.palette.setEntry(i, r, g, b);
_backgroundInfo->palette.setEntry(i, r, g, b);
}
}
setPalette(_backgroundInfo.palette);
_palette.clone(_backgroundInfo.palette);
setPalette(_backgroundInfo->palette);
_palette.clone(_backgroundInfo->palette);
} else {
_disk->loadSlide(_backgroundInfo, name);
_disk->loadSlide(*_backgroundInfo, name);
for (uint i = 0; i < 6; i++)
_backgroundInfo.ranges[i]._flags = 0; // disable palette cycling for slides
setPalette(_backgroundInfo.palette);
_backgroundInfo->ranges[i]._flags = 0; // disable palette cycling for slides
setPalette(_backgroundInfo->palette);
}
}

View file

@ -436,7 +436,7 @@ struct BackgroundInfo {
return LAYER_FOREGROUND;
}
void free() {
~BackgroundInfo() {
bg.free();
mask.free();
path.free();
@ -511,7 +511,7 @@ public:
void freeItems();
// background surface
BackgroundInfo _backgroundInfo;
BackgroundInfo *_backgroundInfo;
void setBackground(uint type, const char* name, const char* mask, const char* path);
void patchBackground(Graphics::Surface &surf, int16 x, int16 y, bool mask = false);
void grabBackground(const Common::Rect& r, Graphics::Surface &dst);

View file

@ -65,7 +65,7 @@ public:
uint32 curTime = _vm->_system->getMillis();
if (curTime - _startTime > _timeOut) {
_fadeSteps = 64;
pal.clone(_vm->_gfx->_backgroundInfo.palette);
pal.clone(_vm->_gfx->_backgroundInfo->palette);
}
return this;
}
@ -73,8 +73,8 @@ public:
virtual void enter() {
_vm->_gfx->clearScreen();
_vm->_gfx->setBackground(kBackgroundSlide, _slideName.c_str(), 0, 0);
_vm->_gfx->_backgroundInfo.x = (_vm->_screenWidth - _vm->_gfx->_backgroundInfo.width) >> 1;
_vm->_gfx->_backgroundInfo.y = (_vm->_screenHeight - _vm->_gfx->_backgroundInfo.height) >> 1;
_vm->_gfx->_backgroundInfo->x = (_vm->_screenWidth - _vm->_gfx->_backgroundInfo->width) >> 1;
_vm->_gfx->_backgroundInfo->y = (_vm->_screenHeight - _vm->_gfx->_backgroundInfo->height) >> 1;
_vm->_input->setMouseState(MOUSE_DISABLED);
_startTime = g_system->getMillis();
@ -217,8 +217,8 @@ public:
_vm->_gfx->clearScreen();
_vm->_gfx->setBackground(kBackgroundSlide, "tbra", 0, 0);
if (_vm->getPlatform() == Common::kPlatformPC) {
_vm->_gfx->_backgroundInfo.x = 20;
_vm->_gfx->_backgroundInfo.y = 50;
_vm->_gfx->_backgroundInfo->x = 20;
_vm->_gfx->_backgroundInfo->y = 50;
}
// TODO: load progress from savefile

View file

@ -264,7 +264,6 @@ void Parallaction::freeLocation() {
_location._walkPoints.clear();
_gfx->clearGfxObjects(kGfxObjNormal);
freeBackground();
_location._programs.clear();
freeZones();
@ -284,7 +283,6 @@ void Parallaction::freeLocation() {
void Parallaction::freeBackground() {
_gfx->freeBackground();
_pathBuffer = 0;
}
@ -292,7 +290,7 @@ void Parallaction::freeBackground() {
void Parallaction::setBackground(const char* name, const char* mask, const char* path) {
_gfx->setBackground(kBackgroundLocation, name, mask, path);
_pathBuffer = &_gfx->_backgroundInfo.path;
_pathBuffer = &_gfx->_backgroundInfo->path;
return;
}

View file

@ -464,9 +464,9 @@ DECLARE_LOCATION_PARSER(mask) {
debugC(7, kDebugParser, "LOCATION_PARSER(mask) ");
ctxt.maskName = strdup(_tokens[1]);
_vm->_gfx->_backgroundInfo.layers[0] = atoi(_tokens[2]);
_vm->_gfx->_backgroundInfo.layers[1] = atoi(_tokens[3]);
_vm->_gfx->_backgroundInfo.layers[2] = atoi(_tokens[4]);
_vm->_gfx->_backgroundInfo->layers[0] = atoi(_tokens[2]);
_vm->_gfx->_backgroundInfo->layers[1] = atoi(_tokens[3]);
_vm->_gfx->_backgroundInfo->layers[2] = atoi(_tokens[4]);
}
@ -1179,7 +1179,7 @@ void LocationParser_br::parse(Script *script) {
LocationParser_ns::parse(script);
_vm->_gfx->setBackground(kBackgroundLocation, ctxt.bgName, ctxt.maskName, ctxt.pathName);
_vm->_pathBuffer = &_vm->_gfx->_backgroundInfo.path;
_vm->_pathBuffer = &_vm->_gfx->_backgroundInfo->path;
if (ctxt.characterName) {
_vm->changeCharacter(ctxt.characterName);