PRINCE: Rename Overlay to Mask, loadAllMasks update

This commit is contained in:
lukaslw 2014-05-30 23:36:49 +02:00
parent 16a6d99a86
commit 4be66f5110
5 changed files with 91 additions and 48 deletions

View File

@ -208,7 +208,7 @@ void Hero::countDrawPosition() {
tempMiddleX = _middleX - width; //eax
int z = _middleY; //ebp
int y = _middleY - _scaledFrameYSize; //ecx
_vm->checkNak(tempMiddleX, y, _scaledFrameXSize, _scaledFrameYSize, z);
_vm->checkMasks(tempMiddleX, y, _scaledFrameXSize, _scaledFrameYSize, z);
if (_zoomFactor != 0) {
//notfullSize

View File

@ -299,29 +299,32 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
loadZoom(_mainHero->_zoomBitmap, _mainHero->kZoomBitmapLen, "zoom");
loadShadow(_mainHero->_shadowBitmap, _mainHero->kShadowBitmapSize, "shadow", "shadow2");
_picWindowX = 0;
_mobList.clear();
Resource::loadResource(_mobList, "mob.lst", false);
_animList.clear();
Resource::loadResource(_animList, "anim.lst", false);
for (uint32 i = 0; i < _objList.size(); i++) {
delete _objList[i];
}
_objList.clear();
Resource::loadResource(_objList, "obj.lst", false);
_animList.clear();
Resource::loadResource(_animList, "anim.lst", false);
_room->loadRoom(_script->getRoomOffset(_locationNr));
for (uint i = 0; i < _maskList.size(); i++) {
free(_maskList[i]._data);
}
_maskList.clear();
_script->loadAllMasks(_maskList, _room->_nak);
_picWindowX = 0;
_mainHero->_lightX = _script->getLightX(_locationNr);
_mainHero->_lightY = _script->getLightY(_locationNr);
_mainHero->setShadowScale(_script->getShadowScale(_locationNr));
_room->loadRoom(_script->getRoomOffset(_locationNr));
_overlayList.clear();
_script->loadOverlays(_overlayList, _room->_nak);
clearBackAnimList();
_script->installBackAnims(_backAnimList, _room->_backAnim);
@ -746,18 +749,19 @@ bool PrinceEngine::spriteCheck(Graphics::Surface *backAnimSurface, int destX, in
return true;
}
void PrinceEngine::checkNak(int x1, int y1, int sprWidth, int sprHeight, int z) {
// CheckNak
void PrinceEngine::checkMasks(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;
for (uint i = 0; i < _maskList.size() ; i++) {
if (_maskList[i]._state != 1 && _maskList[i]._flags != 1) {
if (_maskList[i]._z > z) {
if (_maskList[i]._x1 <= x2 && _maskList[i]._x2 >= x1) {
if (_maskList[i]._y1 <= y2 && _maskList[i]._y2 >= y1) {
_maskList[i]._state = 1;
}
}
}
@ -765,6 +769,22 @@ void PrinceEngine::checkNak(int x1, int y1, int sprWidth, int sprHeight, int z)
}
}
// InsertNakladki
void PrinceEngine::insertMasks() {
for (uint i = 0; i < _maskList.size(); i++) {
if (_maskList[i]._state == 1) {
showMask(i);
}
}
}
// ShowNak
void PrinceEngine::showMask(int maskNr) {
if (_maskList[maskNr]._flags == 0) {
}
}
void PrinceEngine::showSprite(Graphics::Surface *backAnimSurface, int destX, int destY) {
if (spriteCheck(backAnimSurface, destX, destY)) {
destX -= _picWindowX;

View File

@ -85,7 +85,7 @@ struct AnimListItem {
int16 _y;
uint16 _loopType;
uint16 _nextAnim; // number of animation to do for loop = 3
uint16 _flags; // byte 0 - draw overlays, byte 1 - draw in front of overlay, byte 2 - load but turn off drawing
uint16 _flags; // byte 0 - draw masks, byte 1 - draw in front of mask, byte 2 - load but turn off drawing
bool loadFromStream(Common::SeekableReadStream &stream);
};
@ -142,15 +142,16 @@ struct BackgroundAnim {
};
// Nak (PL - Nakladka)
struct Overlay {
struct Mask {
int16 _state; // visible / invisible
int16 _flags; // turning on / turning off of an overlay
int16 _flags; // turning on / turning off of an mask
int16 _x1;
int16 _y1;
int16 _x2;
int16 _y2;
int16 _z;
int16 _number; // number of mask for background recreating
byte *_data;
};
struct DebugChannel {
@ -221,7 +222,9 @@ public:
static const int16 kNormalWidth = 640;
static const int16 kNormalHeight = 480;
void checkNak(int x1, int y1, int sprWidth, int sprHeight, int z);
void checkMasks(int x1, int y1, int sprWidth, int sprHeight, int z);
void insertMasks();
void showMask(int maskNr);
int testAnimNr;
int testAnimFrame;
@ -269,7 +272,7 @@ private:
Animation *_zoom;
Common::Array<Mob> _mobList;
Common::Array<Object *> _objList;
Common::Array<Overlay> _overlayList;
Common::Array<Mask> _maskList;
bool _flicLooped;

View File

@ -291,33 +291,53 @@ void Script::installBackAnims(Common::Array<BackgroundAnim> &backanimList, int o
}
}
void Script::loadOverlays(Common::Array<Overlay> &overlayList, int offset) {
Overlay tempOverlay;
bool Script::loadAllMasks(Common::Array<Mask> &maskList, int offset) {
Mask tempMask;
while (1) {
tempOverlay._state = READ_UINT32(&_data[offset]);
if (tempOverlay._state == -1) {
tempMask._state = READ_UINT32(&_data[offset]);
if (tempMask._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("tempMask._state: %d", tempMask._state);
tempMask._flags = READ_UINT32(&_data[offset + 2]);
debug("tempMask._flags: %d", tempMask._flags);
tempMask._x1 = READ_UINT32(&_data[offset + 4]);
debug("tempMask._x1: %d", tempMask._x1);
tempMask._y1 = READ_UINT32(&_data[offset + 6]);
debug("tempMask._y1: %d", tempMask._y1);
tempMask._x2 = READ_UINT32(&_data[offset + 8]);
debug("tempMask._x2: %d", tempMask._x2);
tempMask._y2 = READ_UINT32(&_data[offset + 10]);
debug("tempMask._y2: %d", tempMask._y2);
tempMask._z = READ_UINT32(&_data[offset + 12]);
debug("tempMask._z: %d", tempMask._z);
tempMask._number = READ_UINT32(&_data[offset + 14]);
debug("tempMask._number: %d\n", tempMask._number);
const Common::String msStreamName = Common::String::format("MS%02d", tempMask._number);
Common::SeekableReadStream *msStream = SearchMan.createReadStreamForMember(msStreamName);
if (!msStream) {
error("Can't load %s", msStreamName.c_str());
delete msStream;
return false;
}
uint32 dataSize = msStream->size();
if (dataSize != -1) {
tempMask._data = (byte *)malloc(dataSize);
if (msStream->read(tempMask._data, dataSize) != dataSize) {
free(tempMask._data);
delete msStream;
return false;
}
delete msStream;
}
maskList.push_back(tempMask);
offset += 16; // size of tempMask (Nak) struct
}
debug("NAK size: %d", sizeof(Overlay));
debug("overlayList size: %d", overlayList.size());
debug("Mask size: %d", sizeof(tempMask));
debug("maskList size: %d", maskList.size());
return true;
}
InterpreterFlags::InterpreterFlags() {

View File

@ -39,7 +39,7 @@ class PrinceEngine;
class Animation;
struct Anim;
struct BackgroundAnim;
struct Overlay;
struct Mask;
namespace Detail {
template <typename T> T LittleEndianReader(void *data);
@ -54,7 +54,7 @@ public:
int _mobs; // mob flag offset
int _backAnim; // offset to array of animation numbers
int _obj; // offset to array of object numbers
int _nak; // offset to array of overlays
int _nak; // offset to array of masks
int _itemUse;
int _itemGive;
int _walkTo; // offset to array of WALKTO events or 0
@ -135,7 +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);
bool loadAllMasks(Common::Array<Mask> &maskList, int offset);
const char *getString(uint32 offset) {
return (const char *)(&_data[offset]);