Skip to content

Commit

Permalink
PRINCE: Object class update, showObjects() beginning
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaslw committed Jun 22, 2014
1 parent 9933505 commit 6f19bd8
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 12 deletions.
1 change: 1 addition & 0 deletions engines/prince/graphics.cpp
Expand Up @@ -101,6 +101,7 @@ void GraphicsMan::drawMask(int32 posX, int32 posY, int32 width, int32 height, by
if ((maskData[tempMaskPostion] & maskCounter) != 0) {
byte orgPixel = *((byte*)originalRoomSurface->getBasePtr(x + posX, y + posY));
*((byte*)_frontScreen->getBasePtr(x + posX, y + posY)) = orgPixel;
//*((byte*)_frontScreen->getBasePtr(x + posX, y + posY)) = 0; // for debugging
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions engines/prince/object.cpp
Expand Up @@ -32,7 +32,9 @@

namespace Prince {

Object::Object() : _surface(NULL), _x(0), _y(0), _z(0), _overlay(0) {
Object::Object() : _surface(NULL), _x(0), _y(0), _z(0), _mask(0),
_zoomInSource(0), _zoomInLen(0), _zoomInAddr(0), _zoomInTime(0)
{
}

Object::~Object() {
Expand Down Expand Up @@ -73,12 +75,12 @@ bool Object::loadFromStream(Common::SeekableReadStream &stream) {
loadSurface(*obStream);
delete obStream;

_overlay = stream.readUint16LE();
_mask = stream.readUint16LE();
_z = stream.readUint16LE();

stream.seek(pos + 16);

debug("Object x %d, y %d, z %d overlay %d", _x, _y, _z, _overlay);
debug("Object x %d, y %d, z %d overlay %d", _x, _y, _z, _mask);

return true;
}
Expand Down
10 changes: 9 additions & 1 deletion engines/prince/object.h
Expand Up @@ -33,9 +33,17 @@ class Object {
Object();
~Object();

int32 _x;
int32 _y;
int32 _z;
int32 _mask; // or flags
int32 _zoomInSource;
int32 _zoomInLen;
int32 _zoomInAddr;
int32 _zoomInTime;

bool loadFromStream(Common::SeekableReadStream &stream);
const Graphics::Surface *getSurface() const { return _surface; }
uint16 _x, _y, _z, _overlay;
private:
void loadSurface(Common::SeekableReadStream &stream);
Graphics::Surface *_surface;
Expand Down
49 changes: 41 additions & 8 deletions engines/prince/prince.cpp
Expand Up @@ -977,6 +977,44 @@ void PrinceEngine::clearBackAnimList() {
_backAnimList.clear();
}

void PrinceEngine::showObjects() {
if (!_objList.empty()) {
for (uint i = 0; i < _objList.size(); i++) {
if ((_objList[i]->_mask & 32768) != 0) { // 8000h
_objList[i]->_zoomInTime--;
if (_objList[i]->_zoomInTime == 0) {
_objList[i]->_mask &= 32767; //7FFFh
} else {
// doZoomIn();
// mov edx, d [esi.Obj_ZoomInAddr]
}
}
if ((_objList[i]->_mask & 16384) != 0) { // 4000h
_objList[i]->_zoomInTime--;
if (_objList[i]->_zoomInTime == 0) {
_objList[i]->_mask &= 49151; //0BFFFh
} else {
// doZoomOut();
// mov edx, d [esi.Obj_ZoomInAddr]
}
}
const Graphics::Surface *objSurface = _objList[i]->getSurface();
if (spriteCheck(objSurface->w, objSurface->h, _objList[i]->_x, _objList[i]->_y)) {
if ((_objList[i]->_mask & 512) == 0) { // 0200h
int destX = _objList[i]->_x - _picWindowX;
int destY = _objList[i]->_y - _picWindowY;
_graph->drawTransparent(destX, destY, objSurface);
} else {
// showBackSprite();
}
}
if ((_objList[i]->_mask & 1) != 0) {
checkMasks(_objList[i]->_x, _objList[i]->_y, objSurface->w, objSurface->h, _objList[i]->_z);
}
}
}
}

void PrinceEngine::drawScreen() {
const Graphics::Surface *roomSurface = _roomBmp->getSurface();
Graphics::Surface visiblePart;
Expand All @@ -1002,15 +1040,10 @@ void PrinceEngine::drawScreen() {
delete mainHeroSurface;
}

/*
if (!_objList.empty()) {
for (int i = 0; i < _objList.size(); i++) {
_graph->drawTransparent(_objList[i]->_x, _objList[i]->_y, _objList[i]->getSurface());
}
}
*/

showBackAnims();

showObjects();

if (roomSurface) {
insertMasks(&visiblePart);
}
Expand Down
2 changes: 2 additions & 0 deletions engines/prince/prince.h
Expand Up @@ -171,6 +171,7 @@ struct Mask {
int16 getHeight() const {
return READ_LE_UINT16(_data + 6);
}

byte *getMask() const {
return (byte *)(_data + 8);
}
Expand Down Expand Up @@ -266,6 +267,7 @@ class PrinceEngine : public Engine {
bool spriteCheck(int sprWidth, int sprHeight, int destX, int destY);
void showSprite(Graphics::Surface *backAnimSurface, int destX, int destY);
void showSpriteShadow(Graphics::Surface *shadowSurface, int destX, int destY);
void showObjects();
void makeShadowTable(int brightness);

uint32 getTextWidth(const char *s);
Expand Down

0 comments on commit 6f19bd8

Please sign in to comment.