diff options
author | Sven Hesse | 2006-11-20 13:03:30 +0000 |
---|---|---|
committer | Sven Hesse | 2006-11-20 13:03:30 +0000 |
commit | c22920484a23210c47a6786d86b0eeca7f5859f2 (patch) | |
tree | da7b93920e38ed4ee07c1a1af939a948c9084317 /engines/gob | |
parent | d64d6bcb7e56404dc585c62edcf39861f102f05b (diff) | |
download | scummvm-rg350-c22920484a23210c47a6786d86b0eeca7f5859f2.tar.gz scummvm-rg350-c22920484a23210c47a6786d86b0eeca7f5859f2.tar.bz2 scummvm-rg350-c22920484a23210c47a6786d86b0eeca7f5859f2.zip |
Changed the way sprites-freeing is handled, now the menu sprites and window decorations are drawn
svn-id: r24752
Diffstat (limited to 'engines/gob')
-rw-r--r-- | engines/gob/draw.cpp | 15 | ||||
-rw-r--r-- | engines/gob/draw.h | 12 | ||||
-rw-r--r-- | engines/gob/draw_v1.cpp | 7 | ||||
-rw-r--r-- | engines/gob/draw_v2.cpp | 67 | ||||
-rw-r--r-- | engines/gob/game.cpp | 73 | ||||
-rw-r--r-- | engines/gob/game.h | 7 | ||||
-rw-r--r-- | engines/gob/game_v1.cpp | 3 | ||||
-rw-r--r-- | engines/gob/game_v2.cpp | 94 | ||||
-rw-r--r-- | engines/gob/gob.cpp | 4 | ||||
-rw-r--r-- | engines/gob/inter.cpp | 3 | ||||
-rw-r--r-- | engines/gob/inter.h | 5 | ||||
-rw-r--r-- | engines/gob/inter_v1.cpp | 10 | ||||
-rw-r--r-- | engines/gob/inter_v2.cpp | 86 | ||||
-rw-r--r-- | engines/gob/mult_v1.cpp | 12 | ||||
-rw-r--r-- | engines/gob/mult_v2.cpp | 9 |
15 files changed, 250 insertions, 157 deletions
diff --git a/engines/gob/draw.cpp b/engines/gob/draw.cpp index bc2547dd81..b48ec98e3c 100644 --- a/engines/gob/draw.cpp +++ b/engines/gob/draw.cpp @@ -135,8 +135,13 @@ Draw::Draw(GobEngine *vm) : _vm(vm) { _cursorTimeKey = 0; - warning("GOB2 Stub! _word_2E8E2"); + warning("GOB2 Stub! _word_2E8E2, _word_2FC9C, _word_2FC9E, _word_2E51F, _off_2E51B, _off_2E517"); _word_2E8E2 = 2; + _word_2FC9C = 0; + _word_2FC9E = 0; + _word_2E51F = 0; + _off_2E51B = 0; + _off_2E517 = 0; } void Draw::invalidateRect(int16 left, int16 top, int16 right, int16 bottom) { @@ -552,4 +557,12 @@ int32 Draw::getSpriteRectSize(int16 index) { 0, _vm->_global->_videoMode); } +void Draw::initSpriteSurf(int16 index, int16 vidMode, int16 width, int16 height, int16 flags) { + if (index != 22) + _vm->_video->freeSurfDesc(_spritesArray[index]); + + _spritesArray[index] = + _vm->_video->initSurfDesc(vidMode, width, height, flags); +} + } // End of namespace Gob diff --git a/engines/gob/draw.h b/engines/gob/draw.h index 24585cd106..e67e2981fd 100644 --- a/engines/gob/draw.h +++ b/engines/gob/draw.h @@ -115,6 +115,11 @@ public: int16 _palLoadData2[4]; int16 _word_2E8E2; + int16 _word_2FC9C; + int16 _word_2FC9E; + int16 _word_2E51F; + Video::SurfaceDesc *_off_2E51B; + Video::SurfaceDesc *_off_2E517; void invalidateRect(int16 left, int16 top, int16 right, int16 bottom); void blitInvalidated(void); @@ -136,12 +141,15 @@ public: void printTextCentered(int16 arg_0, int16 left, int16 top, int16 right, int16 bottom, char *str, int16 fontIndex, int16 color); int32 getSpriteRectSize(int16 index); + void initSpriteSurf(int16 index, int16 vidMode, int16 width, int16 height, int16 flags); virtual void initBigSprite(int16 index, int16 width, int16 height, int16 flags) = 0; virtual void printText(void) = 0; virtual void spriteOperation(int16 operation) = 0; virtual void blitCursor(void) = 0; virtual void animateCursor(int16 cursor) = 0; + virtual void initScreen(void) = 0; + virtual void closeScreen(void) = 0; Draw(GobEngine *vm); virtual ~Draw() {}; @@ -157,6 +165,8 @@ public: virtual void spriteOperation(int16 operation); virtual void blitCursor(void); virtual void animateCursor(int16 cursor); + virtual void initScreen(void); + virtual void closeScreen(void); Draw_v1(GobEngine *vm); virtual ~Draw_v1() {}; @@ -169,6 +179,8 @@ public: virtual void spriteOperation(int16 operation); virtual void blitCursor(void); virtual void animateCursor(int16 cursor); + virtual void initScreen(void); + virtual void closeScreen(void); Draw_v2(GobEngine *vm); virtual ~Draw_v2() {}; diff --git a/engines/gob/draw_v1.cpp b/engines/gob/draw_v1.cpp index e06cd95467..5b799dff3f 100644 --- a/engines/gob/draw_v1.cpp +++ b/engines/gob/draw_v1.cpp @@ -608,4 +608,11 @@ void Draw_v1::animateCursor(int16 cursor) { _cursorY = newY; } +void Draw_v1::initScreen(void) { + _backSurface = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 320, 200, 0); +} + +void Draw_v1::closeScreen(void) { +} + } // End of namespace Gob diff --git a/engines/gob/draw_v2.cpp b/engines/gob/draw_v2.cpp index aa25237e09..6858e372d2 100644 --- a/engines/gob/draw_v2.cpp +++ b/engines/gob/draw_v2.cpp @@ -62,8 +62,7 @@ void Draw_v2::initBigSprite(int16 index, int16 width, int16 height, int16 flags) } partsheight = _spritesHeights[index]; - _spritesArray[index] = - _vm->_video->initSurfDesc(_vm->_global->_videoMode, width, partsheight, flags); + initSpriteSurf(index, _vm->_global->_videoMode, width, partsheight, flags); fragment = 0; while (partsheight < height) { remainheight = height - partsheight; @@ -82,8 +81,7 @@ void Draw_v2::initBigSprite(int16 index, int16 width, int16 height, int16 flags) fragment++; } } else - _spritesArray[index] = - _vm->_video->initSurfDesc(_vm->_global->_videoMode, width, height, flags); + initSpriteSurf(index, _vm->_global->_videoMode, width, height, flags); _vm->_video->clearSurf(_spritesArray[index]); // '------ @@ -533,7 +531,7 @@ void Draw_v2::spriteOperation(int16 operation) { sourceSurface = _sourceSurface; // warning("GOB2 Stub! _off_2E51B"); - if (_vm->_game->_off_2E51B != 0) { + if (_off_2E51B != 0) { if ((_frontSurface->height <= _destSpriteY) && ((_destSurface == 20) || (_destSurface == 21))) { _destSpriteY -= _frontSurface->height; @@ -544,7 +542,7 @@ void Draw_v2::spriteOperation(int16 operation) { } if (_destSurface == 21) invalidateRect(0, _frontSurface->height, 319, - _frontSurface->height + _vm->_game->_off_2E51B->height - 1); + _frontSurface->height + _off_2E51B->height - 1); destSurface += 4; } if ((_frontSurface->height <= _spriteTop) && (operation == DRAW_BLITSURF) @@ -1017,4 +1015,61 @@ void Draw_v2::animateCursor(int16 cursor) { _cursorY = newY; } +void Draw_v2::initScreen(void) { + _word_2FC9C = 0; + _word_2FC9E = 0; + + if (_word_2E51F != 0) { + _off_2E51B = new Video::SurfaceDesc; + memcpy(_off_2E51B, _frontSurface, sizeof(Video::SurfaceDesc)); + _off_2E51B->height = _vm->_global->_primaryHeight - _word_2E51F; + _frontSurface->height -= _off_2E51B->height; + _frontSurface->vidPtr = + _off_2E51B->vidPtr + ((_off_2E51B->width * _off_2E51B->height) / 4); + + _off_2E517 = new Video::SurfaceDesc; + memcpy(_off_2E517, _off_2E51B, sizeof(Video::SurfaceDesc)); + _off_2E517->width = _vm->_global->_primaryWidth; + _off_2E517->vidPtr = _frontSurface->vidPtr + + ((_frontSurface->width * _frontSurface->height ) / 4); + } + initBigSprite(21, 320, 200, 0); + _backSurface = _spritesArray[21]; + _vm->_video->clearSurf(_backSurface); + + initBigSprite(23, 32, 16, 2); + _cursorSpritesBack = _spritesArray[23]; + _cursorSprites = _cursorSpritesBack; + _scummvmCursor = + _vm->_video->initSurfDesc(_vm->_global->_videoMode, 16, 16, SCUMMVM_CURSOR); + + _spritesArray[20] = _frontSurface; + _spritesArray[21] = _backSurface; + +/* if (_word_2E51F != 0) { + dword_2F92D = _off_2E51B; + dword_2F931 = _off_2E517; + }*/ +} + +void Draw_v2::closeScreen(void) { + freeSprite(23); + _cursorSprites = 0; + _cursorSpritesBack = 0; + _vm->_video->freeSurfDesc(_scummvmCursor); + _scummvmCursor = 0; + if (_off_2E51B != 0) { + memcpy(_frontSurface, _off_2E51B, sizeof(Video::SurfaceDesc)); + _frontSurface->width = 320; + _frontSurface->height = 200; + delete _off_2E51B; + delete _off_2E517; + _off_2E51B = 0; + _off_2E517 = 0; + } + if (_frontSurface != _backSurface) + freeSprite(21); + _spritesArray[21] = 0; +} + } // End of namespace Gob diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp index 161fd39011..0807eb0094 100644 --- a/engines/gob/game.cpp +++ b/engines/gob/game.cpp @@ -123,13 +123,8 @@ Game::Game(GobEngine *vm) : _vm(vm) { _byte_2FC83 = 0; _word_2FC80 = 0; - warning("GOB2 Stub! _byte_2FC9B, _word_2FC9C, _word_2FC9E, _word_2E51F, _off_2E51B, _off_2E517, _dword_2F2B6"); + warning("GOB2 Stub! _byte_2FC9B, _dword_2F2B6"); _byte_2FC9B = 0; - _word_2FC9C = 0; - _word_2FC9E = 0; - _word_2E51F = 0; - _off_2E51B = 0; - _off_2E517 = 0; _dword_2F2B6 = 0; } @@ -304,6 +299,7 @@ void Game::capturePop(char doDraw) { _vm->_draw->spriteOperation(0); } _vm->_video->freeSurfDesc(_vm->_draw->_spritesArray[30 + _captureCount]); + _vm->_draw->_spritesArray[30 + _captureCount] = 0; } char *Game::loadTotResource(int16 id) { @@ -436,6 +432,8 @@ void Game::loadImFile(void) { } void Game::start(void) { + int i; + _collisionAreas = new Collision[250]; memset(_collisionAreas, 0, 250 * sizeof(Collision)); @@ -443,10 +441,14 @@ void Game::start(void) { playTot(-2); delete[] _collisionAreas; + _vm->_draw->closeScreen(); - _vm->_video->freeSurfDesc(_vm->_draw->_cursorSprites); + _vm->_draw->_spritesArray[20] = 0; + for (i = 0; i < 50; i++) { + _vm->_video->freeSurfDesc(_vm->_draw->_spritesArray[i]); + _vm->_draw->_spritesArray[i] = 0; + } _vm->_video->freeSurfDesc(_vm->_draw->_scummvmCursor); - _vm->_video->freeSurfDesc(_vm->_draw->_backSurface); } // flagbits: 0 = freeInterVariables, 1 = skipPlay @@ -730,61 +732,6 @@ void Game::collAreaSub(int16 index, int8 enter) { } } -// "DEVinitscreen" -void Game::sub_ADD2(void) { - _word_2FC9C = 0; - _word_2FC9E = 0; - - if (_word_2E51F != 0) { - _off_2E51B = new Video::SurfaceDesc; - memcpy(_off_2E51B, _vm->_draw->_frontSurface, sizeof(Video::SurfaceDesc)); - _off_2E51B->height = _vm->_global->_primaryHeight - _word_2E51F; - _vm->_draw->_frontSurface->height -= _off_2E51B->height; - _vm->_draw->_frontSurface->vidPtr = - _off_2E51B->vidPtr + ((_off_2E51B->width * _off_2E51B->height) / 4); - - _off_2E517 = new Video::SurfaceDesc; - memcpy(_off_2E517, _off_2E51B, sizeof(Video::SurfaceDesc)); - _off_2E517->width = _vm->_global->_primaryWidth; - _off_2E517->vidPtr = _vm->_draw->_frontSurface->vidPtr + - ((_vm->_draw->_frontSurface->width * _vm->_draw->_frontSurface->height ) / 4); - } - _vm->_draw->initBigSprite(21, 320, 200, 0); - _vm->_draw->_backSurface = _vm->_draw->_spritesArray[21]; - _vm->_video->clearSurf(_vm->_draw->_backSurface); - - _vm->_draw->initBigSprite(23, 32, 16, 2); - _vm->_draw->_cursorSpritesBack = _vm->_draw->_spritesArray[23]; - _vm->_draw->_cursorSprites = _vm->_draw->_cursorSpritesBack; - _vm->_draw->_scummvmCursor = - _vm->_video->initSurfDesc(_vm->_global->_videoMode, 16, 16, SCUMMVM_CURSOR); - - _vm->_draw->_spritesArray[20] = _vm->_draw->_frontSurface; - _vm->_draw->_spritesArray[21] = _vm->_draw->_backSurface; - -/* if (_word_2E51F != 0) { - dword_2F92D = _off_2E51B; - dword_2F931 = _off_2E517; - }*/ -} - -// "DEVclosescreen" -void Game::sub_BB28(void) { - _vm->_draw->freeSprite(23); - _vm->_video->freeSurfDesc(_vm->_draw->_scummvmCursor); - if (_off_2E51B != 0) { - memcpy(_vm->_draw->_frontSurface, _off_2E51B, sizeof(Video::SurfaceDesc)); - _vm->_draw->_frontSurface->width = 320; - _vm->_draw->_frontSurface->height = 200; - delete _off_2E51B; - delete _off_2E517; - _off_2E51B = 0; - _off_2E517 = 0; - } - if (_vm->_draw->_frontSurface != _vm->_draw->_backSurface) - _vm->_draw->freeSprite(21); -} - Snd::SoundDesc *Game::loadSND(const char *path, int8 arg_4) { Snd::SoundDesc *soundDesc; int32 dsize; diff --git a/engines/gob/game.h b/engines/gob/game.h index 859b1bad6e..8097c577c9 100644 --- a/engines/gob/game.h +++ b/engines/gob/game.h @@ -234,14 +234,7 @@ public: virtual void prepareStart(void) = 0; int8 _byte_2FC9B; - int16 _word_2FC9C; - int16 _word_2FC9E; - int16 _word_2E51F; int32 _dword_2F2B6; - Video::SurfaceDesc *_off_2E51B; - Video::SurfaceDesc *_off_2E517; - void sub_ADD2(void); - void sub_BB28(void); protected: diff --git a/engines/gob/game_v1.cpp b/engines/gob/game_v1.cpp index 8e1304849a..fe1404dba7 100644 --- a/engines/gob/game_v1.cpp +++ b/engines/gob/game_v1.cpp @@ -594,8 +594,7 @@ void Game_v1::prepareStart(void) { _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc); - _vm->_draw->_backSurface = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 320, 200, 0); - + _vm->_draw->initScreen(); _vm->_video->fillRect(_vm->_draw->_backSurface, 0, 0, 319, 199, 1); _vm->_draw->_frontSurface = _vm->_global->_pPrimarySurfDesc; _vm->_video->fillRect(_vm->_draw->_frontSurface, 0, 0, 319, 199, 1); diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp index bae1a6871b..696ecfa0d5 100644 --- a/engines/gob/game_v2.cpp +++ b/engines/gob/game_v2.cpp @@ -89,8 +89,8 @@ void Game_v2::playTot(int16 skipPlay) { _vm->_mult->initAll(); _vm->_mult->zeroMultData(); - for (i = 0; i < 50; i++) - _vm->_draw->_spritesArray[i] = 0; +/* for (i = 0; i < 50; i++) + _vm->_draw->_spritesArray[i] = 0;*/ _vm->_draw->_spritesArray[20] = _vm->_draw->_frontSurface; _vm->_draw->_spritesArray[21] = _vm->_draw->_backSurface; @@ -241,11 +241,12 @@ void Game_v2::playTot(int16 skipPlay) { if (skipPlay != -1) { _vm->_goblin->freeObjects(); - for (i = 0; i < 20; i++) { +/* for (i = 0; i < 50; i++) { if (_vm->_draw->_spritesArray[i] != 0) _vm->_video->freeSurfDesc(_vm->_draw->_spritesArray[i]); _vm->_draw->_spritesArray[i] = 0; - } + }*/ + _vm->_snd->stopSound(0); for (i = 0; i < 60; i++) @@ -474,66 +475,69 @@ int16 Game_v2::checkCollisions(char handleMouse, int16 deltaTime, int16 *pResId, width = _vm->_draw->_frontSurface->width; height = _vm->_draw->_frontSurface->height; if ((width > _vm->_global->_primaryWidth) || (height > _vm->_global->_primaryHeight) - || ((_off_2E51B != 0) && (height > _off_2E51B->height))) { + || ((_vm->_draw->_off_2E51B != 0) && (height > _vm->_draw->_off_2E51B->height))) { sWidth = _vm->_global->_primaryWidth; sHeight = _vm->_global->_primaryHeight; - if (_off_2E51B != 0) - sHeight -= _off_2E51B->height; - oldWord_2FC9E = _word_2FC9E; - oldWord_2FC9C = _word_2FC9C; - if ((width > sWidth) && (_vm->_global->_inter_mouseX >= _word_2FC9E)) { + if (_vm->_draw->_off_2E51B != 0) + sHeight -= _vm->_draw->_off_2E51B->height; + oldWord_2FC9E = _vm->_draw->_word_2FC9E; + oldWord_2FC9C = _vm->_draw->_word_2FC9C; + if ((width > sWidth) && (_vm->_global->_inter_mouseX >= _vm->_draw->_word_2FC9E)) { cursorRight = _vm->_global->_inter_mouseX + _vm->_draw->_cursorWidth; - if (cursorRight > (_word_2FC9E + sWidth)) - _word_2FC9E = MIN(cursorRight - sWidth, width - sWidth); - } else if (_vm->_global->_inter_mouseX < _word_2FC9E) - _word_2FC9E = _vm->_global->_inter_mouseX; + if (cursorRight > (_vm->_draw->_word_2FC9E + sWidth)) + _vm->_draw->_word_2FC9E = MIN(cursorRight - sWidth, width - sWidth); + } else if (_vm->_global->_inter_mouseX < _vm->_draw->_word_2FC9E) + _vm->_draw->_word_2FC9E = _vm->_global->_inter_mouseX; height = _vm->_draw->_frontSurface->height; - if ((height > sHeight) && (_vm->_global->_inter_mouseY >= _word_2FC9C)) { + if ((height > sHeight) && (_vm->_global->_inter_mouseY >= _vm->_draw->_word_2FC9C)) { cursorBottom = _vm->_global->_inter_mouseY + _vm->_draw->_cursorHeight; - if (cursorBottom > (_word_2FC9C + sHeight)) - _word_2FC9C = MIN(cursorBottom - sHeight, height - sHeight); - } else if (_vm->_global->_inter_mouseY < _word_2FC9C) - _word_2FC9C = _vm->_global->_inter_mouseY; - if ((oldWord_2FC9E != _word_2FC9E) || (oldWord_2FC9C != _word_2FC9C)) { + if (cursorBottom > (_vm->_draw->_word_2FC9C + sHeight)) + _vm->_draw->_word_2FC9C = MIN(cursorBottom - sHeight, height - sHeight); + } else if (_vm->_global->_inter_mouseY < _vm->_draw->_word_2FC9C) + _vm->_draw->_word_2FC9C = _vm->_global->_inter_mouseY; + if ((oldWord_2FC9E != _vm->_draw->_word_2FC9E) || + (oldWord_2FC9C != _vm->_draw->_word_2FC9C)) { if (_byte_2FC9B == 0) { - _word_2FC9E = oldWord_2FC9E; - _word_2FC9C = oldWord_2FC9C; + _vm->_draw->_word_2FC9E = oldWord_2FC9E; + _vm->_draw->_word_2FC9C = oldWord_2FC9C; if ((_vm->_draw->_frontSurface->width > sWidth) && (_vm->_global->_inter_mouseX >= oldWord_2FC9E)) { if ((_vm->_global->_inter_mouseX + _vm->_draw->_cursorWidth) > - (_word_2FC9E + sWidth)) - _vm->_global->_inter_mouseX = _word_2FC9E + sWidth - _vm->_draw->_cursorWidth; + (_vm->_draw->_word_2FC9E + sWidth)) + _vm->_global->_inter_mouseX = _vm->_draw->_word_2FC9E + + sWidth - _vm->_draw->_cursorWidth; } else if (_vm->_global->_inter_mouseX < oldWord_2FC9E) _vm->_global->_inter_mouseX = oldWord_2FC9E; if ((_vm->_draw->_frontSurface->height > sHeight) && - (_vm->_global->_inter_mouseY >= _word_2FC9C)) { + (_vm->_global->_inter_mouseY >= _vm->_draw->_word_2FC9C)) { if ((_vm->_global->_inter_mouseY + _vm->_draw->_cursorHeight) > - (_word_2FC9C + sHeight)) - _vm->_global->_inter_mouseY = _word_2FC9C + sHeight - _vm->_draw->_cursorHeight; + (_vm->_draw->_word_2FC9C + sHeight)) + _vm->_global->_inter_mouseY = _vm->_draw->_word_2FC9C + + sHeight - _vm->_draw->_cursorHeight; } else if (_vm->_global->_inter_mouseY < oldWord_2FC9E) - _vm->_global->_inter_mouseY = _word_2FC9C; + _vm->_global->_inter_mouseY = _vm->_draw->_word_2FC9C; } else { - if (oldWord_2FC9E > _word_2FC9E) { - _vm->_global->_inter_mouseX += (oldWord_2FC9E - _word_2FC9E) / 2; - _word_2FC9E += (oldWord_2FC9E - _word_2FC9E) / 2; + if (oldWord_2FC9E > _vm->_draw->_word_2FC9E) { + _vm->_global->_inter_mouseX += (oldWord_2FC9E - _vm->_draw->_word_2FC9E) / 2; + _vm->_draw->_word_2FC9E += (oldWord_2FC9E - _vm->_draw->_word_2FC9E) / 2; } else { - _vm->_global->_inter_mouseX -= (_word_2FC9E - oldWord_2FC9E) / 2; - _word_2FC9E -= (_word_2FC9E - oldWord_2FC9E) / 2; + _vm->_global->_inter_mouseX -= (_vm->_draw->_word_2FC9E - oldWord_2FC9E) / 2; + _vm->_draw->_word_2FC9E -= (_vm->_draw->_word_2FC9E - oldWord_2FC9E) / 2; } - if (oldWord_2FC9C > _word_2FC9C) { - _vm->_global->_inter_mouseY += (oldWord_2FC9C - _word_2FC9C) / 2; - _word_2FC9C += (oldWord_2FC9C - _word_2FC9C) / 2; - if (_word_2FC9C < 2) - _word_2FC9C = 0; + if (oldWord_2FC9C > _vm->_draw->_word_2FC9C) { + _vm->_global->_inter_mouseY += (oldWord_2FC9C - _vm->_draw->_word_2FC9C) / 2; + _vm->_draw->_word_2FC9C += (oldWord_2FC9C - _vm->_draw->_word_2FC9C) / 2; + if (_vm->_draw->_word_2FC9C < 2) + _vm->_draw->_word_2FC9C = 0; } else { - _vm->_global->_inter_mouseY -= (_word_2FC9C - oldWord_2FC9C) / 2; - _word_2FC9C -= (_word_2FC9C - oldWord_2FC9C) / 2; + _vm->_global->_inter_mouseY -= (_vm->_draw->_word_2FC9C - oldWord_2FC9C) / 2; + _vm->_draw->_word_2FC9C -= (_vm->_draw->_word_2FC9C - oldWord_2FC9C) / 2; } - if (_off_2E51B == 0) - warning("_vid_setPixelShift(_word_2FC9E, _word_2FC9C);"); + if (_vm->_draw->_off_2E51B == 0) + warning("_vid_setPixelShift(_vm->_draw->_word_2FC9E, _vm->_draw->_word_2FC9C);"); else - warning("_vid_setPixelShift(_word_2FC9E, _word_2FC9C + _off_2E51B->height);"); + warning("_vid_setPixelShift(_vm->_draw->_word_2FC9E, _vm->_draw->_word_2FC9C + _vm->_draw->_off_2E51B->height);"); } _vm->_util->setMousePos(_vm->_global->_inter_mouseX, _vm->_global->_inter_mouseY); } @@ -652,9 +656,7 @@ void Game_v2::prepareStart(void) { _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc); - _vm->_draw->_backSurface = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 320, 200, 0); - - sub_ADD2(); + _vm->_draw->initScreen(); _vm->_video->fillRect(_vm->_draw->_frontSurface, 0, 0, 319, 199, 1); _vm->_util->setMousePos(152, 92); diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index f6a8d2dca8..20b040ee93 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -189,9 +189,9 @@ GobEngine::GobEngine(OSystem * syst, uint32 features, Common::Language lang, } GobEngine::~GobEngine() { + delete _mult; delete _game; delete _snd; - delete _video; delete _global; delete _draw; delete _anim; @@ -201,7 +201,6 @@ GobEngine::~GobEngine() { delete _init; delete _inter; delete _map; - delete _mult; delete _pack; delete _palanim; delete _parse; @@ -209,6 +208,7 @@ GobEngine::~GobEngine() { delete _gtimer; delete _util; delete _music; + delete _video; delete[] _startTot; delete[] _startTot0; diff --git a/engines/gob/inter.cpp b/engines/gob/inter.cpp index 1f18c30d43..09f8900f30 100644 --- a/engines/gob/inter.cpp +++ b/engines/gob/inter.cpp @@ -56,6 +56,9 @@ Inter::Inter(GobEngine *vm) : _vm(vm) { _soundStopVal = 0; _breakFromLevel = 0; _nestLevel = 0; + + memset(_pasteBuf, 0, 300); + _pastePos = 0; } int16 Inter::load16(void) { diff --git a/engines/gob/inter.h b/engines/gob/inter.h index 17362f17b4..5ecb57e91c 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -51,6 +51,9 @@ public: int16 peek16(char *ptr); int32 peek32(char *ptr); + char _pasteBuf[300]; + int16 _pastePos; + char evalExpr(int16 *pRes); char evalBoolResult(void); void funcBlock(int16 retFlag); @@ -332,6 +335,8 @@ protected: bool o2_loadTot(char &cmdCount, int16 &counter, int16 &retFlag); bool o2_freeSprite(char &cmdCount, int16 &counter, int16 &retFlag); bool o2_loadSound(char &cmdCount, int16 &counter, int16 &retFlag); + void o2_copyVars(void); + void o2_pasteVars(void); void o2_loadFontToSprite(void); void o2_renderStatic(void); void o2_loadMapObjects(void); diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index 747df52ad2..09b708a306 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -804,7 +804,9 @@ void Inter_v1::o1_initCursor(void) { _vm->_draw->_cursorSprites->width != width * count) { _vm->_video->freeSurfDesc(_vm->_draw->_cursorSprites); + _vm->_draw->_spritesArray[23] = 0; _vm->_video->freeSurfDesc(_vm->_draw->_scummvmCursor); + _vm->_draw->_scummvmCursor = 0; _vm->_draw->_cursorWidth = width; _vm->_draw->_cursorHeight = height; @@ -1168,9 +1170,11 @@ bool Inter_v1::o1_createSprite(char &cmdCount, int16 &counter, int16 &retFlag) { flag = load16(); if (flag == 1) - _vm->_draw->_spritesArray[index] = _vm->_video->initSurfDesc(_vm->_global->_videoMode, width, height, 2); +// _vm->_draw->_spritesArray[index] = _vm->_video->initSurfDesc(_vm->_global->_videoMode, width, height, 2); + _vm->_draw->initSpriteSurf(index, _vm->_global->_videoMode, width, height, 2); else - _vm->_draw->_spritesArray[index] = _vm->_video->initSurfDesc(_vm->_global->_videoMode, width, height, 0); +// _vm->_draw->_spritesArray[index] = _vm->_video->initSurfDesc(_vm->_global->_videoMode, width, height, 0); + _vm->_draw->initSpriteSurf(index, _vm->_global->_videoMode, width, height, 0); _vm->_video->clearSurf(_vm->_draw->_spritesArray[index]); return false; @@ -1558,12 +1562,12 @@ void Inter_v1::o1_initMult(void) { || oldAnimHeight != _vm->_anim->_areaHeight)) { _vm->_video->freeSurfDesc(_vm->_anim->_animSurf); _vm->_anim->_animSurf = 0; + _vm->_draw->_spritesArray[22] = 0; } if (_vm->_anim->_animSurf == 0) { _vm->_anim->_animSurf = _vm->_video->initSurfDesc(_vm->_global->_videoMode, _vm->_anim->_areaWidth, _vm->_anim->_areaHeight, 0); - _vm->_draw->_spritesArray[22] = _vm->_anim->_animSurf; } diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index 774348081e..963dcaa27a 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -207,8 +207,8 @@ void Inter_v2::setupOpcodes(void) { /* 40 */ OPCODE(o2_totSub), OPCODE(o2_switchTotSub), - OPCODE(o2_drawStub), - OPCODE(o2_drawStub), + OPCODE(o2_copyVars), + OPCODE(o2_pasteVars), /* 44 */ {NULL, ""}, {NULL, ""}, @@ -671,6 +671,7 @@ bool Inter_v2::executeFuncOpcode(byte i, byte j, char &cmdCount, int16 &counter, warning("unimplemented opcodeFunc: %d.%d", i, j); else return (this->*op) (cmdCount, counter, retFlag); + return false; } @@ -833,7 +834,7 @@ void Inter_v2::o2_stub0x80(void) { else _vm->_video->_extraMode = false; - _vm->_game->sub_BB28(); + _vm->_draw->closeScreen(); _vm->_util->clearPalette(); memset(_vm->_global->_redPalette, 0, 256); memset(_vm->_global->_greenPalette, 0, 256); @@ -869,12 +870,12 @@ void Inter_v2::o2_stub0x80(void) { _vm->_util->clearPalette(); if (start == 0) - _vm->_game->_word_2E51F = 0; + _vm->_draw->_word_2E51F = 0; else - _vm->_game->_word_2E51F = _vm->_global->_primaryHeight - start; - _vm->_game->sub_ADD2(); + _vm->_draw->_word_2E51F = _vm->_global->_primaryHeight - start; + _vm->_draw->initScreen(); - if (_vm->_game->_off_2E51B != 0) { + if (_vm->_draw->_off_2E51B != 0) { warning("GOB2 Stub! _vid_setSplit(_vm->_global->_primaryHeight - start);"); warning("GOB2 Stub! _vid_setPixelShift(0, start);"); } @@ -889,16 +890,16 @@ void Inter_v2::o2_stub0x82(void) { if (_vm->_game->_byte_2FC9B != 0) _vm->_game->_byte_2FC9B = 1; _vm->_parse->parseValExpr(); - WRITE_VAR(2, _vm->_game->_word_2FC9E); - WRITE_VAR(3, _vm->_game->_word_2FC9C); + WRITE_VAR(2, _vm->_draw->_word_2FC9E); + WRITE_VAR(3, _vm->_draw->_word_2FC9C); } else { - _vm->_game->_word_2FC9E = expr; - _vm->_game->_word_2FC9C = _vm->_parse->parseValExpr(); + _vm->_draw->_word_2FC9E = expr; + _vm->_draw->_word_2FC9C = _vm->_parse->parseValExpr(); } -/* if (_vm->_game->_off_2E51B != 0) - warning("GOB2 Stub! _vid_setPixelShift(_vm->_game->_word_2FC9E, _vm->_game->_word_2FC9C + 200 - _vm->_game->_word_2E51F)"); +/* if (_vm->_draw->_off_2E51B != 0) + warning("GOB2 Stub! _vid_setPixelShift(_vm->_draw->_word_2FC9E, _vm->_draw->_word_2FC9C + 200 - _vm->_draw->_word_2E51F)"); else - warning("GOB2 Stub! _vid_setPixelShift(_vm->_game->_word_2FC9E, _vm->_game->_word_2FC9C);");*/ + warning("GOB2 Stub! _vid_setPixelShift(_vm->_draw->_word_2FC9E, _vm->_draw->_word_2FC9C);");*/ } void Inter_v2::o2_stub0x85(void) { @@ -1013,6 +1014,46 @@ int16 Inter_v2::loadSound(int16 search) { return slot; } +void Inter_v2::o2_copyVars(void) { + byte count; + int16 varOff; + int i; + + count = *_vm->_global->_inter_execPtr++; + for (i = 0; i < count; i++) { + if ((*_vm->_global->_inter_execPtr == 25) || (*_vm->_global->_inter_execPtr == 28)) { + varOff = _vm->_parse->parseVarIndex(); + _vm->_global->_inter_execPtr++; + memcpy(_pasteBuf + _pastePos, _vm->_global->_inter_variables + varOff, + _vm->_global->_inter_animDataSize * 4); + _pastePos += _vm->_global->_inter_animDataSize * 4; + _pasteBuf[_pastePos] = _vm->_global->_inter_animDataSize * 4; + } else { + if (evalExpr(&varOff) == 20) + _vm->_global->_inter_resVal = 0; + memcpy(_pasteBuf + _pastePos, &_vm->_global->_inter_resVal, 4); + _pastePos += 4; + _pasteBuf[_pastePos] = 4; + } + _pastePos++; + } +} + +void Inter_v2::o2_pasteVars(void) { + byte count; + int16 varOff; + int16 size; + int i; + + count = *_vm->_global->_inter_execPtr++; + for (i = 0; i < count; i++) { + varOff = _vm->_parse->parseVarIndex(); + size = _pasteBuf[--_pastePos]; + _pastePos -= size; + memcpy(_vm->_global->_inter_variables + varOff, _pasteBuf + _pastePos, size); + } +} + void Inter_v2::o2_loadFontToSprite(void) { int16 i = load16(); @@ -1903,9 +1944,10 @@ void Inter_v2::o2_initMult(void) { (oldAnimWidth != _vm->_anim->_areaWidth || oldAnimHeight != _vm->_anim->_areaHeight)) { if (_vm->_anim->_animSurf->vidMode & 0x80) - _vm->_draw->freeSprite(0x16); + _vm->_draw->freeSprite(22); else delete _vm->_anim->_animSurf; + _vm->_draw->_spritesArray[22] = 0; } _vm->_draw->adjustCoords(0, &_vm->_anim->_areaWidth, &_vm->_anim->_areaHeight); @@ -1918,6 +1960,7 @@ void Inter_v2::o2_initMult(void) { _vm->_anim->_animSurf->width -= (_vm->_anim->_areaLeft & 0x0FFF8) - 1; _vm->_anim->_animSurf->height = _vm->_anim->_areaHeight; _vm->_anim->_animSurf->vidPtr += 0x0C000; + _vm->_draw->_spritesArray[22] = _vm->_anim->_animSurf; } else { if (_vm->_global->_videoMode == 20) { if (((_vm->_draw->_backSurface->width * _vm->_draw->_backSurface->height) / 2 @@ -1929,10 +1972,13 @@ void Inter_v2::o2_initMult(void) { _vm->_anim->_animSurf->height = _vm->_anim->_areaHeight; _vm->_anim->_animSurf->vidPtr = _vm->_draw->_backSurface->vidPtr + _vm->_draw->_backSurface->width * _vm->_draw->_backSurface->height / 4; + _vm->_draw->_spritesArray[22] = _vm->_anim->_animSurf; } else - _vm->_draw->initBigSprite(0x16, _vm->_anim->_areaWidth, _vm->_anim->_areaHeight, 0); + _vm->_draw->initBigSprite(22, _vm->_anim->_areaWidth, _vm->_anim->_areaHeight, 0); + _vm->_anim->_animSurf = _vm->_draw->_spritesArray[22]; } else - _vm->_draw->initBigSprite(0x16, _vm->_anim->_areaWidth, _vm->_anim->_areaHeight, 0); + _vm->_draw->initBigSprite(22, _vm->_anim->_areaWidth, _vm->_anim->_areaHeight, 0); + _vm->_anim->_animSurf = _vm->_draw->_spritesArray[22]; } if (_terminate) return; @@ -2059,8 +2105,12 @@ void Inter_v2::o2_initCursor(void) { if (width != _vm->_draw->_cursorWidth || height != _vm->_draw->_cursorHeight || _vm->_draw->_cursorSprites->width != width * count) { - _vm->_video->freeSurfDesc(_vm->_draw->_cursorSprites); + _vm->_draw->freeSprite(23); + _vm->_draw->_cursorSprites = 0; + _vm->_draw->_cursorSpritesBack = 0; + _vm->_video->freeSurfDesc(_vm->_draw->_scummvmCursor); + _vm->_draw->_scummvmCursor = 0; _vm->_draw->_cursorWidth = width; _vm->_draw->_cursorHeight = height; diff --git a/engines/gob/mult_v1.cpp b/engines/gob/mult_v1.cpp index c1f4f68994..f1be776f40 100644 --- a/engines/gob/mult_v1.cpp +++ b/engines/gob/mult_v1.cpp @@ -319,9 +319,9 @@ void Mult_v1::playMult(int16 startFrame, int16 endFrame, char checkEscape, delete[] _animArrayData; _animArrayData = 0; - if (_vm->_anim->_animSurf) - _vm->_video->freeSurfDesc(_vm->_anim->_animSurf); + _vm->_video->freeSurfDesc(_vm->_anim->_animSurf); _vm->_anim->_animSurf = 0; + _vm->_draw->_spritesArray[22] = 0; _animDataAllocated = 0; } @@ -891,8 +891,7 @@ void Mult_v1::animate(void) { } void Mult_v1::freeMult(void) { - if (_vm->_anim->_animSurf != 0) - _vm->_video->freeSurfDesc(_vm->_anim->_animSurf); + _vm->_video->freeSurfDesc(_vm->_anim->_animSurf); delete[] _objects; delete[] _renderData; @@ -902,6 +901,7 @@ void Mult_v1::freeMult(void) { _renderData = 0; _orderArray = 0; _vm->_anim->_animSurf = 0; + _vm->_draw->_spritesArray[22] = 0; } void Mult_v1::playSound(Snd::SoundDesc * soundDesc, int16 repCount, int16 freq, @@ -958,9 +958,9 @@ void Mult_v1::freeMultKeys(void) { delete[] _animArrayData; _animArrayData = 0; - if (_vm->_anim->_animSurf) - _vm->_video->freeSurfDesc(_vm->_anim->_animSurf); + _vm->_video->freeSurfDesc(_vm->_anim->_animSurf); _vm->_anim->_animSurf = 0; + _vm->_draw->_spritesArray[22] = 0; _animDataAllocated = 0; } diff --git a/engines/gob/mult_v2.cpp b/engines/gob/mult_v2.cpp index 89fc627445..20b61626e8 100644 --- a/engines/gob/mult_v2.cpp +++ b/engines/gob/mult_v2.cpp @@ -483,8 +483,11 @@ void Mult_v2::playMult(int16 startFrame, int16 endFrame, char checkEscape, _vm->_anim->_animSurf->height = _vm->_anim->_areaHeight; _vm->_anim->_animSurf->vidPtr += (_vm->_draw->_backSurface->width * _vm->_draw->_backSurface->height) / 2; - } else + _vm->_draw->_spritesArray[22] = _vm->_anim->_animSurf; + } else { _vm->_draw->initBigSprite(22, _vm->_anim->_areaWidth, _vm->_anim->_areaHeight, 0); + _vm->_anim->_animSurf = _vm->_draw->_spritesArray[22]; + } _vm->_draw->adjustCoords(1, &_vm->_anim->_areaWidth, &_vm->_anim->_areaHeight); _vm->_draw->_sourceSurface = 21; @@ -569,9 +572,9 @@ void Mult_v2::playMult(int16 startFrame, int16 endFrame, char checkEscape, delete[] _orderArray; _orderArray = 0; - if (_vm->_anim->_animSurf) - _vm->_video->freeSurfDesc(_vm->_anim->_animSurf); + _vm->_video->freeSurfDesc(_vm->_anim->_animSurf); _vm->_anim->_animSurf = 0; + _vm->_draw->_spritesArray[22] = 0; _animDataAllocated = 0; } |