From c2c00894f22ed8cf0b3d5fa469d8554ab0df96ef Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 18 Oct 2015 21:35:35 -0400 Subject: XEEN: Implement SPRFLAG_SCENE_CLIPPED drawing flag --- engines/xeen/interface_map.cpp | 74 +++++++++++++++++++++--------------------- engines/xeen/sprites.cpp | 7 ++-- engines/xeen/sprites.h | 2 +- 3 files changed, 43 insertions(+), 40 deletions(-) diff --git a/engines/xeen/interface_map.cpp b/engines/xeen/interface_map.cpp index a9e71d4e9c..a08ce808d8 100644 --- a/engines/xeen/interface_map.cpp +++ b/engines/xeen/interface_map.cpp @@ -60,11 +60,11 @@ OutdoorDrawList::OutdoorDrawList() : _sky1(_data[0]), _sky2(_data[1]), _data[25] = DrawStruct(0, 8, 109); _data[26] = DrawStruct(0, 201, 109); _data[27] = DrawStruct(0, 8, 109); - _data[28] = DrawStruct(1, -64, 61, 14, SPRFLAG_2000); + _data[28] = DrawStruct(1, -64, 61, 14, SPRFLAG_SCENE_CLIPPED); _data[29] = DrawStruct(1, -40, 61, 14, 0); _data[30] = DrawStruct(1, -16, 61, 14, 0); _data[31] = DrawStruct(1, 8, 61, 14, 0); - _data[32] = DrawStruct(1, 128, 61, 14, SPRFLAG_HORIZ_FLIPPED | SPRFLAG_2000); + _data[32] = DrawStruct(1, 128, 61, 14, SPRFLAG_HORIZ_FLIPPED | SPRFLAG_SCENE_CLIPPED); _data[33] = DrawStruct(1, 104, 61, 14, SPRFLAG_HORIZ_FLIPPED); _data[34] = DrawStruct(1, 80, 61, 14, SPRFLAG_HORIZ_FLIPPED); _data[35] = DrawStruct(1, 56, 61, 14, SPRFLAG_HORIZ_FLIPPED); @@ -120,10 +120,10 @@ OutdoorDrawList::OutdoorDrawList() : _sky1(_data[0]), _sky2(_data[1]), _data[85] = DrawStruct(2, 146, 40, 0, SPRFLAG_HORIZ_FLIPPED); _data[86] = DrawStruct(1, 32, 40, 6, 0); _data[87] = DrawStruct(0, -7, 30, 7, 0); - _data[88] = DrawStruct(0, -112, 30, 7, SPRFLAG_2000); - _data[89] = DrawStruct(0, 98, 30, 7, SPRFLAG_2000); - _data[90] = DrawStruct(0, -112, 30, 8, SPRFLAG_2000); - _data[91] = DrawStruct(0, 98, 30, 8, SPRFLAG_2000); + _data[88] = DrawStruct(0, -112, 30, 7, SPRFLAG_SCENE_CLIPPED); + _data[89] = DrawStruct(0, 98, 30, 7, SPRFLAG_SCENE_CLIPPED); + _data[90] = DrawStruct(0, -112, 30, 8, SPRFLAG_SCENE_CLIPPED); + _data[91] = DrawStruct(0, 98, 30, 8, SPRFLAG_SCENE_CLIPPED); _data[92] = DrawStruct(0, -38, 30, 8, 0); _data[93] = DrawStruct(0, 25, 30, 8, 0); _data[94] = DrawStruct(0, -7, 30, 8, 0); @@ -138,22 +138,22 @@ OutdoorDrawList::OutdoorDrawList() : _sky1(_data[0]), _sky2(_data[1]), _data[103] = DrawStruct(0, 8, 24); _data[104] = DrawStruct(0, 169, 24, 0, SPRFLAG_HORIZ_FLIPPED); _data[105] = DrawStruct(1, 32, 24); - _data[106] = DrawStruct(0, -23, 40, 0, SPRFLAG_2000); - _data[107] = DrawStruct(0, 200, 40, 0, SPRFLAG_HORIZ_FLIPPED | SPRFLAG_2000); + _data[106] = DrawStruct(0, -23, 40, 0, SPRFLAG_SCENE_CLIPPED); + _data[107] = DrawStruct(0, 200, 40, 0, SPRFLAG_HORIZ_FLIPPED | SPRFLAG_SCENE_CLIPPED); _data[108] = DrawStruct(0, 8, 47); _data[109] = DrawStruct(0, 169, 47, 0, SPRFLAG_HORIZ_FLIPPED); - _data[110] = DrawStruct(1, -56, -4, 0x8000, SPRFLAG_4000 | SPRFLAG_2000); - _data[111] = DrawStruct(0, -5, 2, 0, SPRFLAG_4000 | SPRFLAG_2000); - _data[112] = DrawStruct(0, -67, 2, 0, SPRFLAG_4000 | SPRFLAG_2000); + _data[110] = DrawStruct(1, -56, -4, 0x8000, SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED); + _data[111] = DrawStruct(0, -5, 2, 0, SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED); + _data[112] = DrawStruct(0, -67, 2, 0, SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED); _data[113] = DrawStruct(0, 44, 73); _data[114] = DrawStruct(0, 44, 73); - _data[115] = DrawStruct(0, 58, 14, 0, SPRFLAG_4000 | SPRFLAG_2000); + _data[115] = DrawStruct(0, 58, 14, 0, SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED); _data[116] = DrawStruct(0, 169, 73); _data[117] = DrawStruct(0, 169, 73); - _data[118] = DrawStruct(0, -5, 14, 0, SPRFLAG_4000 | SPRFLAG_2000); + _data[118] = DrawStruct(0, -5, 14, 0, SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED); _data[119] = DrawStruct(0, 110, 73); _data[120] = DrawStruct(0, 110, 73); - _data[121] = DrawStruct(0, -5, 14, 0, SPRFLAG_4000 | SPRFLAG_2000); + _data[121] = DrawStruct(0, -5, 14, 0, SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED); _data[122] = DrawStruct(0, 110, 73); _data[123] = DrawStruct(0, 110, 73); _data[124] = DrawStruct(0, 72, 43); @@ -280,16 +280,16 @@ IndoorDrawList::IndoorDrawList() : _data[84] = DrawStruct(0, 71, 53, 12, SPRFLAG_HORIZ_FLIPPED); _data[85] = DrawStruct(0, 80, 57, 12, 0); _data[86] = DrawStruct(0, 64, 57, 12, SPRFLAG_HORIZ_FLIPPED); - _data[87] = DrawStruct(7, -24, 52, 0, SPRFLAG_2000); + _data[87] = DrawStruct(7, -24, 52, 0, SPRFLAG_SCENE_CLIPPED); _data[88] = DrawStruct(7, 32, 52); _data[89] = DrawStruct(7, 88, 52); _data[90] = DrawStruct(0, 144, 52); - _data[91] = DrawStruct(0, 200, 52, 0, SPRFLAG_2000); - _data[92] = DrawStruct(0, -79, 52, 11, SPRFLAG_2000); + _data[91] = DrawStruct(0, 200, 52, 0, SPRFLAG_SCENE_CLIPPED); + _data[92] = DrawStruct(0, -79, 52, 11, SPRFLAG_SCENE_CLIPPED); _data[93] = DrawStruct(0, -27, 52, 11, 0); _data[94] = DrawStruct(0, 32, 52, 11, 0); _data[95] = DrawStruct(0, 89, 52, 11, 0); - _data[96] = DrawStruct(0, 145, 52, 11, SPRFLAG_2000); + _data[96] = DrawStruct(0, 145, 52, 11, SPRFLAG_SCENE_CLIPPED); _data[97] = DrawStruct(0, -8, 50, 12, 0); _data[98] = DrawStruct(0, -65, 50, 12, 0); _data[99] = DrawStruct(0, 49, 50, 12, 0); @@ -312,17 +312,17 @@ IndoorDrawList::IndoorDrawList() : _data[116] = DrawStruct(0, 63, 47, 8, SPRFLAG_HORIZ_FLIPPED); _data[117] = DrawStruct(0, 94, 52, 8, 0); _data[118] = DrawStruct(0, 50, 52, 8, SPRFLAG_HORIZ_FLIPPED); - _data[119] = DrawStruct(6, -40, 40, 0, SPRFLAG_2000); + _data[119] = DrawStruct(6, -40, 40, 0, SPRFLAG_SCENE_CLIPPED); _data[120] = DrawStruct(6, 64, 40); - _data[121] = DrawStruct(0, 168, 40, 0, SPRFLAG_2000); - _data[122] = DrawStruct(0, -72, 40, 6, SPRFLAG_2000); + _data[121] = DrawStruct(0, 168, 40, 0, SPRFLAG_SCENE_CLIPPED); + _data[122] = DrawStruct(0, -72, 40, 6, SPRFLAG_SCENE_CLIPPED); _data[123] = DrawStruct(0, 32, 40, 6, 0); - _data[124] = DrawStruct(0, 137, 40, 6, SPRFLAG_2000); + _data[124] = DrawStruct(0, 137, 40, 6, SPRFLAG_SCENE_CLIPPED); _data[125] = DrawStruct(0, -7, 25, 7, 0); - _data[126] = DrawStruct(0, -112, 25, 7, SPRFLAG_2000); - _data[127] = DrawStruct(0, 98, 25, 7, SPRFLAG_2000); - _data[128] = DrawStruct(0, -112, 29, 8, SPRFLAG_2000); - _data[129] = DrawStruct(0, 98, 29, 8, SPRFLAG_2000); + _data[126] = DrawStruct(0, -112, 25, 7, SPRFLAG_SCENE_CLIPPED); + _data[127] = DrawStruct(0, 98, 25, 7, SPRFLAG_SCENE_CLIPPED); + _data[128] = DrawStruct(0, -112, 29, 8, SPRFLAG_SCENE_CLIPPED); + _data[129] = DrawStruct(0, 98, 29, 8, SPRFLAG_SCENE_CLIPPED); _data[130] = DrawStruct(0, -38, 29, 8, 0); _data[131] = DrawStruct(0, 25, 29, 8, 0); _data[132] = DrawStruct(0, -7, 29, 8, 0); @@ -336,23 +336,23 @@ IndoorDrawList::IndoorDrawList() : _data[140] = DrawStruct(0, 55, 41, 4, SPRFLAG_HORIZ_FLIPPED); _data[141] = DrawStruct(0, 106, 47, 4, 0); _data[142] = DrawStruct(0, 38, 47, 4, SPRFLAG_HORIZ_FLIPPED); - _data[143] = DrawStruct(0, -136, 24, 0, SPRFLAG_2000); + _data[143] = DrawStruct(0, -136, 24, 0, SPRFLAG_SCENE_CLIPPED); _data[144] = DrawStruct(0, 8, 12); _data[145] = DrawStruct(0, 32, 24); _data[146] = DrawStruct(0, 200, 12, 0, SPRFLAG_HORIZ_FLIPPED); - _data[147] = DrawStruct(0, 200, 24, 0, SPRFLAG_2000); + _data[147] = DrawStruct(0, 200, 24, 0, SPRFLAG_SCENE_CLIPPED); _data[148] = DrawStruct(0, 32, 24); - _data[149] = DrawStruct(0, -5, 2, 0, SPRFLAG_4000 | SPRFLAG_2000); - _data[150] = DrawStruct(0, -67, 10, 0, SPRFLAG_4000 | SPRFLAG_2000); + _data[149] = DrawStruct(0, -5, 2, 0, SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED); + _data[150] = DrawStruct(0, -67, 10, 0, SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED); _data[151] = DrawStruct(0, 44, 73); _data[152] = DrawStruct(0, 44, 73); - _data[153] = DrawStruct(0, 58, 14, 0, SPRFLAG_4000 | SPRFLAG_2000); + _data[153] = DrawStruct(0, 58, 14, 0, SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED); _data[154] = DrawStruct(0, 169, 73); _data[155] = DrawStruct(0, 169, 73); - _data[156] = DrawStruct(0, -5, 14, 0, SPRFLAG_4000 | SPRFLAG_2000); + _data[156] = DrawStruct(0, -5, 14, 0, SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED); _data[157] = DrawStruct(0, 110, 73); _data[158] = DrawStruct(0, 110, 73); - _data[159] = DrawStruct(0, -5, 14, 0, SPRFLAG_4000 | SPRFLAG_2000); + _data[159] = DrawStruct(0, -5, 14, 0, SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED); _data[160] = DrawStruct(0, 110, 73); _data[161] = DrawStruct(0, 110, 73); _data[162] = DrawStruct(0, 72, 43); @@ -478,7 +478,7 @@ void InterfaceMap::drawMap() { ds2._y = 73; } - ds2._flags = SPRFLAG_4000 | SPRFLAG_2000; + ds2._flags = SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED; ds2._sprites = &_charPowSprites; } @@ -489,7 +489,7 @@ void InterfaceMap::drawMap() { if (ds1._scale == 0x8000) ds1._x /= 3; - ds1._flags = SPRFLAG_4000 | SPRFLAG_2000; + ds1._flags = SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED; ds1._sprites = &_charPowSprites; } } @@ -612,7 +612,7 @@ void InterfaceMap::drawMap() { ds1._y = 73; } - ds1._flags = SPRFLAG_4000 | SPRFLAG_2000; + ds1._flags = SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED; ds1._sprites = &_charPowSprites; } @@ -622,7 +622,7 @@ void InterfaceMap::drawMap() { ds2._scale = combat._elemScale[idx]; if (ds2._scale == 0x8000) ds2._x /= 3; - ds2._flags = SPRFLAG_4000 | SPRFLAG_2000; + ds2._flags = SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED; ds2._sprites = &_charPowSprites; } } diff --git a/engines/xeen/sprites.cpp b/engines/xeen/sprites.cpp index 218e712433..288d304523 100644 --- a/engines/xeen/sprites.cpp +++ b/engines/xeen/sprites.cpp @@ -30,6 +30,9 @@ namespace Xeen { +#define SCENE_CLIP_LEFT 8 +#define SCENE_CLIP_RIGHT 223 + SpriteResource::SpriteResource() { _filesize = 0; _data = nullptr; @@ -280,7 +283,8 @@ void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Poi scaleMaskX = ((scaleMaskX & 0x7fff) << 1) + bit; if (bit) { - if (*lineP != -1 && xp >= bounds.left && xp < bounds.right) { + if (*lineP != -1 && xp >= bounds.left && xp < bounds.right && + (!(flags & SPRFLAG_SCENE_CLIPPED) || (xp >= SCENE_CLIP_LEFT && xp < SCENE_CLIP_RIGHT))) { *destP = (byte)*lineP; drawBounds.left = MIN(drawBounds.left, xp); drawBounds.right = MAX(drawBounds.right, xp); @@ -317,7 +321,6 @@ void SpriteResource::draw(XSurface &dest, int frame, const Common::Point &destPo // TODO: TO test when I find sprites using scale values and flags assert(scale != 0x8000); assert(scale >= 0); -// assert((flags & SPRFLAG_2000) == 0); drawOffset(dest, _index[frame]._offset1, destPos, bounds, flags, scale); if (_index[frame]._offset2) diff --git a/engines/xeen/sprites.h b/engines/xeen/sprites.h index ce7b7861b2..2a00ecaf76 100644 --- a/engines/xeen/sprites.h +++ b/engines/xeen/sprites.h @@ -34,7 +34,7 @@ namespace Xeen { class XeenEngine; class Window; -enum SpriteFlags { SPRFLAG_2000 = 0x2000, SPRFLAG_4000 = 0x4000, +enum SpriteFlags { SPRFLAG_SCENE_CLIPPED = 0x2000, SPRFLAG_4000 = 0x4000, SPRFLAG_HORIZ_FLIPPED = 0x8000, SPRFLAG_RESIZE = 0x10000 }; class SpriteResource { -- cgit v1.2.3