mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-05 01:38:36 +00:00
Move low level background management into Gfx.
svn-id: r30681
This commit is contained in:
parent
3c2c16c705
commit
56eed45317
@ -330,7 +330,7 @@ void Parallaction_ns::_c_onMouse(void *parm) {
|
||||
|
||||
void Parallaction_ns::_c_setMask(void *parm) {
|
||||
|
||||
memset(_backgroundInfo->mask.data + 3600, 0, 3600);
|
||||
memset(_gfx->_backgroundInfo->mask.data + 3600, 0, 3600);
|
||||
_gfx->_bgLayers[1] = 500;
|
||||
|
||||
return;
|
||||
@ -586,7 +586,7 @@ void Parallaction_ns::_c_sketch(void *parm) {
|
||||
newx = _rightHandPositions[2*index];
|
||||
}
|
||||
|
||||
Graphics::drawLine(oldx, oldy, newx, newy, 0, zeroMask, _backgroundInfo);
|
||||
Graphics::drawLine(oldx, oldy, newx, newy, 0, zeroMask, _gfx->_backgroundInfo);
|
||||
|
||||
_rightHandAnim->_left = newx;
|
||||
_rightHandAnim->_top = newy - 20;
|
||||
@ -608,11 +608,11 @@ void Parallaction_ns::_c_shade(void *parm) {
|
||||
_rightHandAnim->_top
|
||||
);
|
||||
|
||||
uint16 _di = r.left/4 + r.top * _backgroundInfo->mask.internalWidth;
|
||||
uint16 _di = r.left/4 + r.top * _gfx->_backgroundInfo->mask.internalWidth;
|
||||
|
||||
for (uint16 _si = r.top; _si < r.bottom; _si++) {
|
||||
memset(_backgroundInfo->mask.data + _di, 0, r.width()/4+1);
|
||||
_di += _backgroundInfo->mask.internalWidth;
|
||||
memset(_gfx->_backgroundInfo->mask.data + _di, 0, r.width()/4+1);
|
||||
_di += _gfx->_backgroundInfo->mask.internalWidth;
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -345,6 +345,7 @@ void Gfx::drawBalloons() {
|
||||
}
|
||||
|
||||
void Gfx::updateScreen() {
|
||||
#if 0
|
||||
if (_halfbrite) {
|
||||
Graphics::Surface *surf = g_system->lockScreen();
|
||||
byte *src = (byte*)_buffers[kBitFront]->pixels;
|
||||
@ -359,6 +360,8 @@ void Gfx::updateScreen() {
|
||||
} else {
|
||||
g_system->copyRectToScreen((const byte*)_buffers[kBitFront]->pixels, _buffers[kBitFront]->pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight);
|
||||
}
|
||||
#endif
|
||||
g_system->copyRectToScreen((const byte*)_buffers[kBit2]->pixels, _buffers[kBit2]->pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight);
|
||||
|
||||
Graphics::Surface *surf = g_system->lockScreen();
|
||||
drawGfxObjects(*surf);
|
||||
@ -900,6 +903,7 @@ Gfx::Gfx(Parallaction* vm) :
|
||||
_hbCircleRadius = 0;
|
||||
|
||||
_font = NULL;
|
||||
_backgroundInfo = new BackgroundInfo;
|
||||
|
||||
return;
|
||||
}
|
||||
@ -908,6 +912,9 @@ Gfx::~Gfx() {
|
||||
|
||||
freeBuffers();
|
||||
|
||||
freeBackground();
|
||||
delete _backgroundInfo;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1173,4 +1180,41 @@ bool Gfx::drawWrappedText(Graphics::Surface* surf, char *text, byte color, int16
|
||||
|
||||
}
|
||||
|
||||
void Gfx::freeBackground() {
|
||||
|
||||
if (!_backgroundInfo)
|
||||
return;
|
||||
|
||||
_backgroundInfo->bg.free();
|
||||
_backgroundInfo->mask.free();
|
||||
_backgroundInfo->path.free();
|
||||
|
||||
}
|
||||
|
||||
void Gfx::setBackground(uint type, const char* name, const char* mask, const char* path) {
|
||||
|
||||
if (type == kBackgroundLocation) {
|
||||
|
||||
_disk->loadScenery(*_backgroundInfo, name, mask, path);
|
||||
|
||||
setPalette(_backgroundInfo->palette);
|
||||
_palette.clone(_backgroundInfo->palette);
|
||||
setBackground(&_backgroundInfo->bg);
|
||||
|
||||
if (_backgroundInfo->mask.data)
|
||||
setMask(&_backgroundInfo->mask);
|
||||
|
||||
} else {
|
||||
|
||||
_disk->loadSlide(*_backgroundInfo, name);
|
||||
|
||||
setPalette(_backgroundInfo->palette);
|
||||
setBackground(&_backgroundInfo->bg);
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Parallaction
|
||||
|
@ -152,6 +152,41 @@ public:
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct PathBuffer {
|
||||
// handles a 1-bit depth buffer used for masking non-walkable areas
|
||||
|
||||
uint16 w;
|
||||
uint16 internalWidth;
|
||||
uint16 h;
|
||||
uint size;
|
||||
byte *data;
|
||||
|
||||
public:
|
||||
PathBuffer() : w(0), internalWidth(0), h(0), size(0), data(0) {
|
||||
}
|
||||
|
||||
void create(uint16 width, uint16 height) {
|
||||
w = width;
|
||||
internalWidth = w >> 3;
|
||||
h = height;
|
||||
size = (internalWidth * h);
|
||||
data = (byte*)calloc(size, 1);
|
||||
}
|
||||
|
||||
void free() {
|
||||
::free(data);
|
||||
data = 0;
|
||||
w = 0;
|
||||
h = 0;
|
||||
internalWidth = 0;
|
||||
size = 0;
|
||||
}
|
||||
|
||||
inline byte getValue(uint16 x, uint16 y);
|
||||
};
|
||||
|
||||
|
||||
class Palette {
|
||||
|
||||
byte _data[768];
|
||||
@ -290,9 +325,25 @@ public:
|
||||
void release();
|
||||
};
|
||||
|
||||
|
||||
typedef Common::List<GfxObj*> GfxObjList;
|
||||
|
||||
struct BackgroundInfo {
|
||||
uint width;
|
||||
uint height;
|
||||
|
||||
Graphics::Surface bg;
|
||||
MaskBuffer mask;
|
||||
PathBuffer path;
|
||||
|
||||
Palette palette;
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
kBackgroundLocation = 1,
|
||||
kBackgroundSlide = 2
|
||||
};
|
||||
|
||||
class Gfx {
|
||||
|
||||
public:
|
||||
@ -315,6 +366,10 @@ public:
|
||||
void drawGfxObjects(Graphics::Surface &surf);
|
||||
void sortAnimations();
|
||||
|
||||
BackgroundInfo *_backgroundInfo;
|
||||
void freeBackground();
|
||||
void setBackground(uint type, const char* name, const char* mask, const char* path);
|
||||
|
||||
public:
|
||||
|
||||
// balloons and text
|
||||
|
@ -178,11 +178,12 @@ void Parallaction_ns::guiSplash() {
|
||||
showSlide("intro");
|
||||
_gfx->updateScreen();
|
||||
g_system->delayMillis(2000);
|
||||
freeBackground();
|
||||
|
||||
showSlide("minintro");
|
||||
_gfx->updateScreen();
|
||||
g_system->delayMillis(2000);
|
||||
|
||||
freeBackground();
|
||||
}
|
||||
|
||||
int Parallaction_ns::guiNewGame() {
|
||||
|
@ -118,9 +118,6 @@ Parallaction::Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gam
|
||||
Parallaction::~Parallaction() {
|
||||
delete _debugger;
|
||||
|
||||
freeBackground();
|
||||
delete _backgroundInfo;
|
||||
|
||||
delete _globalTable;
|
||||
|
||||
delete _callableNames;
|
||||
@ -160,14 +157,11 @@ int Parallaction::init() {
|
||||
_location._comment = NULL;
|
||||
_location._endComment = NULL;
|
||||
|
||||
_backgroundInfo = 0;
|
||||
_pathBuffer = 0;
|
||||
_activeZone = 0;
|
||||
|
||||
_screenSize = _screenWidth * _screenHeight;
|
||||
|
||||
_backgroundInfo = new BackgroundInfo;
|
||||
|
||||
strcpy(_characterName1, "null");
|
||||
|
||||
memset(_locationNames, 0, NUM_LOCATIONS * 32);
|
||||
@ -725,6 +719,7 @@ void Parallaction::freeLocation() {
|
||||
_location._walkNodes.clear();
|
||||
|
||||
_gfx->clearGfxObjects();
|
||||
freeBackground();
|
||||
|
||||
freeZones();
|
||||
freeAnimations();
|
||||
@ -743,30 +738,15 @@ void Parallaction::freeLocation() {
|
||||
|
||||
void Parallaction::freeBackground() {
|
||||
|
||||
if (!_backgroundInfo)
|
||||
return;
|
||||
|
||||
_backgroundInfo->bg.free();
|
||||
_backgroundInfo->mask.free();
|
||||
_backgroundInfo->path.free();
|
||||
|
||||
_gfx->freeBackground();
|
||||
_pathBuffer = 0;
|
||||
|
||||
}
|
||||
|
||||
void Parallaction::setBackground(const char* name, const char* mask, const char* path) {
|
||||
|
||||
_disk->loadScenery(*_backgroundInfo, name, mask, path);
|
||||
|
||||
_gfx->setPalette(_backgroundInfo->palette);
|
||||
_gfx->_palette.clone(_backgroundInfo->palette);
|
||||
_gfx->setBackground(&_backgroundInfo->bg);
|
||||
|
||||
if (_backgroundInfo->mask.data)
|
||||
_gfx->setMask(&_backgroundInfo->mask);
|
||||
|
||||
if (_backgroundInfo->path.data)
|
||||
_pathBuffer = &_backgroundInfo->path;
|
||||
_gfx->setBackground(kBackgroundLocation, name, mask, path);
|
||||
_pathBuffer = &_gfx->_backgroundInfo->path;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -237,16 +237,6 @@ public:
|
||||
|
||||
|
||||
|
||||
struct BackgroundInfo {
|
||||
uint width;
|
||||
uint height;
|
||||
|
||||
Graphics::Surface bg;
|
||||
MaskBuffer mask;
|
||||
PathBuffer path;
|
||||
|
||||
Palette palette;
|
||||
};
|
||||
|
||||
class Opcode {
|
||||
|
||||
@ -453,8 +443,6 @@ protected: // data
|
||||
bool _hasLocationSound;
|
||||
char _locationSound[50];
|
||||
|
||||
BackgroundInfo *_backgroundInfo;
|
||||
|
||||
Zone *_hoverZone;
|
||||
|
||||
|
||||
|
@ -266,24 +266,7 @@ void Parallaction_ns::switchBackground(const char* background, const char* mask)
|
||||
|
||||
|
||||
void Parallaction_ns::showSlide(const char *name) {
|
||||
|
||||
BackgroundInfo info;
|
||||
|
||||
_disk->loadSlide(info, name);
|
||||
|
||||
// TODO: avoid using screen buffers for displaying slides. Using a generic buffer
|
||||
// allows for positioning of graphics as needed by Big Red Adventure.
|
||||
// The main problem lies with menu, which relies on multiple buffers, mainly because
|
||||
// it is crappy code.
|
||||
_gfx->setBackground(&info.bg);
|
||||
_gfx->setPalette(info.palette);
|
||||
_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
|
||||
|
||||
info.bg.free();
|
||||
info.mask.free();
|
||||
info.path.free();
|
||||
|
||||
return;
|
||||
_gfx->setBackground(kBackgroundSlide, name, 0, 0);
|
||||
}
|
||||
|
||||
// changeLocation handles transitions between locations, and is able to display slides
|
||||
@ -315,6 +298,7 @@ void Parallaction_ns::changeLocation(char *location) {
|
||||
_gfx->showLabel(id, CENTER_LABEL_HORIZONTAL, 14);
|
||||
waitUntilLeftClick();
|
||||
_gfx->freeLabels();
|
||||
freeBackground();
|
||||
}
|
||||
|
||||
if (locname.hasCharacter()) {
|
||||
|
@ -125,7 +125,7 @@ DECLARE_LOCATION_PARSER(location) {
|
||||
} else {
|
||||
nextToken = 2;
|
||||
}
|
||||
|
||||
#if 0
|
||||
_disk->loadScenery(*_backgroundInfo, _location._name, NULL, NULL);
|
||||
|
||||
// if (flip) {
|
||||
@ -135,7 +135,7 @@ DECLARE_LOCATION_PARSER(location) {
|
||||
_gfx->setBackground(&_backgroundInfo->bg);
|
||||
_gfx->_palette.clone(_backgroundInfo->palette);
|
||||
_gfx->setPalette(_backgroundInfo->palette);
|
||||
|
||||
#endif
|
||||
|
||||
if (_tokens[nextToken][0] != '\0') {
|
||||
_char._ani._left = atoi(_tokens[nextToken]);
|
||||
@ -271,21 +271,23 @@ DECLARE_LOCATION_PARSER(null) {
|
||||
|
||||
DECLARE_LOCATION_PARSER(mask) {
|
||||
debugC(7, kDebugParser, "LOCATION_PARSER(mask) ");
|
||||
|
||||
#if 0
|
||||
_disk->loadScenery(*_backgroundInfo, NULL, _tokens[1], NULL);
|
||||
_gfx->setMask(&_backgroundInfo->mask);
|
||||
|
||||
_gfx->_bgLayers[0] = atoi(_tokens[2]);
|
||||
_gfx->_bgLayers[1] = atoi(_tokens[3]);
|
||||
_gfx->_bgLayers[2] = atoi(_tokens[4]);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
DECLARE_LOCATION_PARSER(path) {
|
||||
debugC(7, kDebugParser, "LOCATION_PARSER(path) ");
|
||||
|
||||
#if 0
|
||||
_disk->loadScenery(*_backgroundInfo, NULL, NULL, _tokens[1]);
|
||||
_pathBuffer = &_backgroundInfo->path;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,40 +47,6 @@ public:
|
||||
typedef ManagedList<WalkNode*> WalkNodeList;
|
||||
|
||||
|
||||
struct PathBuffer {
|
||||
// handles a 1-bit depth buffer used for masking non-walkable areas
|
||||
|
||||
uint16 w;
|
||||
uint16 internalWidth;
|
||||
uint16 h;
|
||||
uint size;
|
||||
byte *data;
|
||||
|
||||
public:
|
||||
PathBuffer() : w(0), internalWidth(0), h(0), size(0), data(0) {
|
||||
}
|
||||
|
||||
void create(uint16 width, uint16 height) {
|
||||
w = width;
|
||||
internalWidth = w >> 3;
|
||||
h = height;
|
||||
size = (internalWidth * h);
|
||||
data = (byte*)calloc(size, 1);
|
||||
}
|
||||
|
||||
void free() {
|
||||
::free(data);
|
||||
data = 0;
|
||||
w = 0;
|
||||
h = 0;
|
||||
internalWidth = 0;
|
||||
size = 0;
|
||||
}
|
||||
|
||||
inline byte getValue(uint16 x, uint16 y);
|
||||
};
|
||||
|
||||
|
||||
class PathBuilder {
|
||||
|
||||
Animation *_anim;
|
||||
|
Loading…
x
Reference in New Issue
Block a user