PRINCE: loadOverlays(), checkNak()

This commit is contained in:
lukaslw 2014-05-30 22:05:40 +02:00
parent 4f291feadd
commit 16a6d99a86
6 changed files with 78 additions and 13 deletions

View file

@ -140,10 +140,6 @@ int Hero::getScaledValue(int size) {
}
}
void Hero::checkNak() {
}
Graphics::Surface *Hero::zoomSprite(Graphics::Surface *heroFrame) {
Graphics::Surface *zoomedFrame = new Graphics::Surface();
zoomedFrame->create(_scaledFrameXSize, _scaledFrameYSize, Graphics::PixelFormat::createFormatCLUT8());
@ -191,6 +187,7 @@ Graphics::Surface *Hero::zoomSprite(Graphics::Surface *heroFrame) {
}
void Hero::countDrawPosition() {
int16 tempMiddleX;
int16 tempMiddleY;
int16 baseX = _moveSet[_moveSetType]->getBaseX();
int16 baseY = _moveSet[_moveSetType]->getBaseY();
@ -206,12 +203,12 @@ void Hero::countDrawPosition() {
_scaledFrameYSize = getScaledValue(_frameYSize);
//TODO
//int tempHeroHeight = scaledY; // not used? global?
//int width = scaledX / 2;
//tempMiddleX = _middleX - width; //eax
//int z = _middleY; //ebp
//int y = _middleY - scaledY; //ecx
//checkNak();
int tempHeroHeight = _scaledFrameYSize; // not used? global?
int width = _frameXSize / 2;
tempMiddleX = _middleX - width; //eax
int z = _middleY; //ebp
int y = _middleY - _scaledFrameYSize; //ecx
_vm->checkNak(tempMiddleX, y, _scaledFrameXSize, _scaledFrameYSize, z);
if (_zoomFactor != 0) {
//notfullSize

View file

@ -115,7 +115,6 @@ public:
int getScaledValue(int size);
void selectZoom();
void countDrawPosition();
void checkNak();
Graphics::Surface *zoomSprite(Graphics::Surface *heroFrame);
void showHeroAnimFrame();
void line(int x1, int y1, int x2, int y2);

View file

@ -318,6 +318,10 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
_mainHero->setShadowScale(_script->getShadowScale(_locationNr));
_room->loadRoom(_script->getRoomOffset(_locationNr));
_overlayList.clear();
_script->loadOverlays(_overlayList, _room->_nak);
clearBackAnimList();
_script->installBackAnims(_backAnimList, _room->_backAnim);
@ -742,6 +746,25 @@ bool PrinceEngine::spriteCheck(Graphics::Surface *backAnimSurface, int destX, in
return true;
}
void PrinceEngine::checkNak(int x1, int y1, int sprWidth, int sprHeight, int z) {
int x2 = x1 + sprWidth - 1;
int y2 = y1 + sprHeight - 1;
if (x1 < 0) {
x1 = 0;
}
for (uint i = 0; i < _overlayList.size() ; i++) {
if (_overlayList[i]._state != 1 && _overlayList[i]._flags != 1) {
if (_overlayList[i]._z > z) {
if (_overlayList[i]._x1 <= x2 && _overlayList[i]._x2 >= x1) {
if (_overlayList[i]._y1 <= y2 && _overlayList[i]._y2 >= y1) {
_overlayList[i]._state = 1;
}
}
}
}
}
}
void PrinceEngine::showSprite(Graphics::Surface *backAnimSurface, int destX, int destY) {
if (spriteCheck(backAnimSurface, destX, destY)) {
destX -= _picWindowX;

View file

@ -141,6 +141,18 @@ struct BackgroundAnim {
Common::Array<Anim> backAnims;
};
// Nak (PL - Nakladka)
struct Overlay {
int16 _state; // visible / invisible
int16 _flags; // turning on / turning off of an overlay
int16 _x1;
int16 _y1;
int16 _x2;
int16 _y2;
int16 _z;
int16 _number; // number of mask for background recreating
};
struct DebugChannel {
enum Type {
@ -209,6 +221,8 @@ public:
static const int16 kNormalWidth = 640;
static const int16 kNormalHeight = 480;
void checkNak(int x1, int y1, int sprWidth, int sprHeight, int z);
int testAnimNr;
int testAnimFrame;
@ -255,6 +269,7 @@ private:
Animation *_zoom;
Common::Array<Mob> _mobList;
Common::Array<Object *> _objList;
Common::Array<Overlay> _overlayList;
bool _flicLooped;

View file

@ -284,13 +284,42 @@ void Script::installSingleBackAnim(Common::Array<BackgroundAnim> &_backanimList,
}
}
void Script::installBackAnims(Common::Array<BackgroundAnim> &_backanimList, int offset) {
void Script::installBackAnims(Common::Array<BackgroundAnim> &backanimList, int offset) {
for (uint i = 0; i < 64; i++) {
installSingleBackAnim(_backanimList, offset);
installSingleBackAnim(backanimList, offset);
offset += 4;
}
}
void Script::loadOverlays(Common::Array<Overlay> &overlayList, int offset) {
Overlay tempOverlay;
while (1) {
tempOverlay._state = READ_UINT32(&_data[offset]);
if (tempOverlay._state == -1) {
break;
}
debug("tempOverlay._state: %d", tempOverlay._state);
tempOverlay._flags = READ_UINT32(&_data[offset + 2]);
debug("tempOverlay._flags: %d", tempOverlay._flags);
tempOverlay._x1 = READ_UINT32(&_data[offset + 4]);
debug("tempOverlay._x1: %d", tempOverlay._x1);
tempOverlay._y1 = READ_UINT32(&_data[offset + 6]);
debug("tempOverlay._y1: %d", tempOverlay._y1);
tempOverlay._x2 = READ_UINT32(&_data[offset + 8]);
debug("tempOverlay._x2: %d", tempOverlay._x2);
tempOverlay._y2 = READ_UINT32(&_data[offset + 10]);
debug("tempOverlay._y2: %d", tempOverlay._y2);
tempOverlay._z = READ_UINT32(&_data[offset + 12]);
debug("tempOverlay._z: %d", tempOverlay._z);
tempOverlay._number = READ_UINT32(&_data[offset + 14]);
debug("tempOverlay._number: %d\n", tempOverlay._number);
overlayList.push_back(tempOverlay);
offset += 16; // size of Overlay (Nak) struct
}
debug("NAK size: %d", sizeof(Overlay));
debug("overlayList size: %d", overlayList.size());
}
InterpreterFlags::InterpreterFlags() {
resetAllFlags();
}

View file

@ -39,6 +39,7 @@ class PrinceEngine;
class Animation;
struct Anim;
struct BackgroundAnim;
struct Overlay;
namespace Detail {
template <typename T> T LittleEndianReader(void *data);
@ -134,6 +135,7 @@ public:
uint8 *getRoomOffset(int locationNr);
void installBackAnims(Common::Array<BackgroundAnim> &_backanimList, int offset);
void installSingleBackAnim(Common::Array<BackgroundAnim> &_backanimList, int offset);
void loadOverlays(Common::Array<Overlay> &overlayList, int offset);
const char *getString(uint32 offset) {
return (const char *)(&_data[offset]);