diff options
author | Eugene Sandulenko | 2005-02-23 23:28:53 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2005-02-23 23:28:53 +0000 |
commit | e936c234af7b7dec0236f8d1ebba81c31aa6ecab (patch) | |
tree | f57a420dac8e43eb6b3154695e90383e9cee1371 | |
parent | 23306f592101f7a1323e3444fc366ef9707c6133 (diff) | |
download | scummvm-rg350-e936c234af7b7dec0236f8d1ebba81c31aa6ecab.tar.gz scummvm-rg350-e936c234af7b7dec0236f8d1ebba81c31aa6ecab.tar.bz2 scummvm-rg350-e936c234af7b7dec0236f8d1ebba81c31aa6ecab.zip |
implementation of spritesSortActiveSprites()
svn-id: r16885
-rw-r--r-- | scumm/intern.h | 1 | ||||
-rw-r--r-- | scumm/sprite_he.cpp | 48 |
2 files changed, 49 insertions, 0 deletions
diff --git a/scumm/intern.h b/scumm/intern.h index 5ccfca28d4..a2a76bd19e 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -971,6 +971,7 @@ protected: void spritesMarkDirty(bool unkFlag); void spritesUpdateImages(); void spriteInfoSet_addImageToList(int spriteId, int imageNum, int *spriteIdptr); + void spritesSortActiveSprites(); /* HE version 90 script opcodes */ void o90_dup(); diff --git a/scumm/sprite_he.cpp b/scumm/sprite_he.cpp index d17e2701bb..6e014a701c 100644 --- a/scumm/sprite_he.cpp +++ b/scumm/sprite_he.cpp @@ -1091,4 +1091,52 @@ void ScummEngine_v90he::spritesUpdateImages() { } } +static int compareSprTable(const void *a, const void *b) { + const SpriteInfo *spr1 = *(const SpriteInfo *const*)a; + const SpriteInfo *spr2 = *(const SpriteInfo *const*)b; + + if (spr1->field_0 > spr2->field_0) + return 1; + + if (spr1->field_0 < spr2->field_0) + return -1; + + return 0; +} + +void ScummEngine_v90he::spritesSortActiveSprites() { + int groupField; + + _numSpritesToProcess = 0; + + if (_varNumSprites <= 1) + return; + + for (int i = 1; i < _varNumSprites; i++) { + SpriteInfo *spi = &_spriteTable[i]; + + if (spi->flags & kSF08) { + if (!spi->flags & kSF23) { + if (!spi->flags & kSF30) + spi->flags |= kSFNeedRedraw; + if (!spi->flags & kSF31) + spi->flags |= kSF01; + } + if (spi->group_num) + groupField = _spriteGroups[spi->group_num].field_10; + else + groupField = 0; + + spi->field_0 = spi->field_18 + groupField; + + _activeSpritesTable[_numSpritesToProcess++] = spi; + } + } + + if (_numSpritesToProcess < 2) + return; + + qsort(_activeSpritesTable, _numSpritesToProcess, sizeof(SpriteInfo *), compareSprTable); +} + } // End of namespace Scumm |