PRINCE: showMask, drawMask update
This commit is contained in:
parent
4be66f5110
commit
dab83cc3eb
5 changed files with 53 additions and 9 deletions
|
@ -89,6 +89,20 @@ void GraphicsMan::drawTransparent(int32 posX, int32 posY, const Graphics::Surfac
|
|||
change();
|
||||
}
|
||||
|
||||
void GraphicsMan::drawMask(int32 posX, int32 posY, int32 width, int32 height, byte *maskData, const Graphics::Surface *originalRoomSurface) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
if (x + posX < _frontScreen->w && x + posX >= 0) {
|
||||
if (y + posY < _frontScreen->h && y + posY >= 0) {
|
||||
byte orgPixel = *((byte*)originalRoomSurface->getBasePtr(x + posX, y + posY));
|
||||
*((byte*)_frontScreen->getBasePtr(x + posX, y + posY)) = orgPixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
change();
|
||||
}
|
||||
|
||||
void GraphicsMan::drawAsShadow(int32 posX, int32 posY, const Graphics::Surface *s, byte *shadowTable) {
|
||||
for (int y = 0; y < s->h; y++) {
|
||||
for (int x = 0; x < s->w; x++) {
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
void draw(uint16 x, uint16 y, const Graphics::Surface *s);
|
||||
void drawTransparent(int32 posX, int32 poxY, const Graphics::Surface *s);
|
||||
void drawAsShadow(int32 posX, int32 poxY, const Graphics::Surface *s, byte *shadowTable);
|
||||
void drawMask(int32 posX, int32 posY, int32 width, int32 height, byte *maskData, const Graphics::Surface *originalRoomSurface);
|
||||
|
||||
Graphics::Surface *_frontScreen;
|
||||
Graphics::Surface *_backScreen;
|
||||
|
|
|
@ -770,18 +770,18 @@ void PrinceEngine::checkMasks(int x1, int y1, int sprWidth, int sprHeight, int z
|
|||
}
|
||||
|
||||
// InsertNakladki
|
||||
void PrinceEngine::insertMasks() {
|
||||
void PrinceEngine::insertMasks(const Graphics::Surface *originalRoomSurface) {
|
||||
for (uint i = 0; i < _maskList.size(); i++) {
|
||||
if (_maskList[i]._state == 1) {
|
||||
showMask(i);
|
||||
showMask(i, originalRoomSurface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ShowNak
|
||||
void PrinceEngine::showMask(int maskNr) {
|
||||
void PrinceEngine::showMask(int maskNr, const Graphics::Surface *originalRoomSurface) {
|
||||
if (_maskList[maskNr]._flags == 0) {
|
||||
|
||||
_graph->drawMask(_maskList[maskNr]._x1, _maskList[maskNr]._y1, _maskList[maskNr]._width, _maskList[maskNr]._height, _maskList[maskNr].getMask(), originalRoomSurface);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -971,8 +971,9 @@ void PrinceEngine::clearBackAnimList() {
|
|||
|
||||
void PrinceEngine::drawScreen() {
|
||||
const Graphics::Surface *roomSurface = _roomBmp->getSurface();
|
||||
Graphics::Surface visiblePart;
|
||||
if (roomSurface) {
|
||||
const Graphics::Surface visiblePart = roomSurface->getSubArea(Common::Rect(_picWindowX, 0, roomSurface->w, roomSurface->h));
|
||||
visiblePart = roomSurface->getSubArea(Common::Rect(_picWindowX, 0, roomSurface->w, roomSurface->h));
|
||||
_graph->draw(0, 0, &visiblePart);
|
||||
}
|
||||
|
||||
|
@ -1002,6 +1003,9 @@ void PrinceEngine::drawScreen() {
|
|||
*/
|
||||
|
||||
showBackAnims();
|
||||
if (roomSurface) {
|
||||
insertMasks(&visiblePart);
|
||||
}
|
||||
|
||||
playNextFrame();
|
||||
|
||||
|
|
|
@ -151,7 +151,28 @@ struct Mask {
|
|||
int16 _y2;
|
||||
int16 _z;
|
||||
int16 _number; // number of mask for background recreating
|
||||
int16 _width;
|
||||
int16 _height;
|
||||
byte *_data;
|
||||
|
||||
int16 Mask::getX() const {
|
||||
return READ_LE_UINT16(_data);
|
||||
}
|
||||
|
||||
int16 Mask::getY() const {
|
||||
return READ_LE_UINT16(_data + 2);
|
||||
}
|
||||
|
||||
int16 Mask::getWidth() const {
|
||||
return READ_LE_UINT16(_data + 4);
|
||||
}
|
||||
|
||||
int16 Mask::getHeight() const {
|
||||
return READ_LE_UINT16(_data + 6);
|
||||
}
|
||||
byte *Mask::getMask() const {
|
||||
return (byte *)(_data + 8);
|
||||
}
|
||||
};
|
||||
|
||||
struct DebugChannel {
|
||||
|
@ -223,8 +244,8 @@ public:
|
|||
static const int16 kNormalHeight = 480;
|
||||
|
||||
void checkMasks(int x1, int y1, int sprWidth, int sprHeight, int z);
|
||||
void insertMasks();
|
||||
void showMask(int maskNr);
|
||||
void insertMasks(const Graphics::Surface *originalRoomSurface);
|
||||
void showMask(int maskNr, const Graphics::Surface *originalRoomSurface);
|
||||
|
||||
int testAnimNr;
|
||||
int testAnimFrame;
|
||||
|
|
|
@ -312,7 +312,7 @@ bool Script::loadAllMasks(Common::Array<Mask> &maskList, int offset) {
|
|||
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);
|
||||
debug("tempMask._number: %d", tempMask._number);
|
||||
|
||||
const Common::String msStreamName = Common::String::format("MS%02d", tempMask._number);
|
||||
Common::SeekableReadStream *msStream = SearchMan.createReadStreamForMember(msStreamName);
|
||||
|
@ -321,6 +321,7 @@ bool Script::loadAllMasks(Common::Array<Mask> &maskList, int offset) {
|
|||
delete msStream;
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 dataSize = msStream->size();
|
||||
if (dataSize != -1) {
|
||||
tempMask._data = (byte *)malloc(dataSize);
|
||||
|
@ -331,9 +332,12 @@ bool Script::loadAllMasks(Common::Array<Mask> &maskList, int offset) {
|
|||
}
|
||||
delete msStream;
|
||||
}
|
||||
tempMask._width = tempMask.getHeight();
|
||||
tempMask._height = tempMask.getHeight();
|
||||
debug("width: %d, height: %d\n", tempMask._width, tempMask._height);
|
||||
|
||||
maskList.push_back(tempMask);
|
||||
offset += 16; // size of tempMask (Nak) struct
|
||||
offset += 16; // size of Mask (Nak) struct
|
||||
}
|
||||
debug("Mask size: %d", sizeof(tempMask));
|
||||
debug("maskList size: %d", maskList.size());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue