diff options
author | David Corrales | 2007-05-26 20:23:24 +0000 |
---|---|---|
committer | David Corrales | 2007-05-26 20:23:24 +0000 |
commit | 3646c968c9578c2a94d65ebd5fb06ec835f8c51d (patch) | |
tree | 8b57b339ebb31a1d7a67f1678aa5dc5c7759070a /engines/gob | |
parent | d1f56d93f934150f4b579c2e90564e2bf035f113 (diff) | |
parent | ac45c5b33d834acbc9718f89be76e49d403a4d2c (diff) | |
download | scummvm-rg350-3646c968c9578c2a94d65ebd5fb06ec835f8c51d.tar.gz scummvm-rg350-3646c968c9578c2a94d65ebd5fb06ec835f8c51d.tar.bz2 scummvm-rg350-3646c968c9578c2a94d65ebd5fb06ec835f8c51d.zip |
Merged the fs branch with trunk. r26472:26948
svn-id: r26949
Diffstat (limited to 'engines/gob')
33 files changed, 422 insertions, 245 deletions
diff --git a/engines/gob/dataio.cpp b/engines/gob/dataio.cpp index 3d4610d961..63c25b4659 100644 --- a/engines/gob/dataio.cpp +++ b/engines/gob/dataio.cpp @@ -27,6 +27,7 @@ #include "gob/gob.h" #include "gob/dataio.h" #include "gob/global.h" +#include "gob/util.h" namespace Gob { @@ -305,6 +306,13 @@ void DataIO::openDataFile(const char *src, bool itk) { dataDesc[i].size = file_getHandle(_dataFileHandles[file])->readUint32LE(); dataDesc[i].offset = file_getHandle(_dataFileHandles[file])->readUint32LE(); dataDesc[i].packed = file_getHandle(_dataFileHandles[file])->readByte(); + + // Replacing cyrillic characters + Util::replaceChar(dataDesc[i].chunkName, (char) 0x85, 'E'); + Util::replaceChar(dataDesc[i].chunkName, (char) 0x8A, 'K'); + Util::replaceChar(dataDesc[i].chunkName, (char) 0x8E, 'O'); + Util::replaceChar(dataDesc[i].chunkName, (char) 0x91, 'C'); + Util::replaceChar(dataDesc[i].chunkName, (char) 0x92, 'T'); } for (int i = 0; i < _numDataChunks[file]; i++) diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index 6afd79d06f..246ffa3b44 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -414,6 +414,18 @@ static const GOBGameDescription gameDescriptions[] = { GF_GOB2, "intro" }, + { // Supplied by bgk in bug report #1706861 + { + "gob2", + "", + AD_ENTRY1s("intro.stk", "4b13c02d1069b86bcfec80f4e474b98b", 554680), + FR_FRA, + kPlatformAtariST, + Common::ADGF_NO_FLAGS + }, + GF_GOB2, + "intro" + }, { { "gob2cd", @@ -642,6 +654,18 @@ static const GOBGameDescription gameDescriptions[] = { GF_GOB2, "intro" }, + { // Supplied by glorfindel in bugreport #1722142 + { + "ween", + "", + AD_ENTRY1s("intro.stk", "8b57cd510da8a3bbd99e3a0297a8ebd1", 7018771), + IT_ITA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + GF_GOB2, + "intro" + }, { { "ween", @@ -714,6 +738,18 @@ static const GOBGameDescription gameDescriptions[] = { GF_BARGON, "intro" }, + { // Supplied by glorfindel in bugreport #1722142 + { + "bargon", + "Fanmade", + AD_ENTRY1s("intro.stk", "da3c54be18ab73fbdb32db24624a9c23", 3181825), + IT_ITA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + GF_BARGON, + "intro" + }, { { "gob3", @@ -762,6 +798,18 @@ static const GOBGameDescription gameDescriptions[] = { GF_GOB3, "intro" }, + { // Supplied by Paranoimia on #scummvm + { + "gob3", + "", + AD_ENTRY1s("intro.stk", "fe8144daece35538085adb59c2d29613", 159402), + IT_ITA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + GF_GOB3, + "intro" + }, { { "gob3", @@ -791,7 +839,19 @@ static const GOBGameDescription gameDescriptions[] = { "gob3", "", AD_ENTRY1("intro.stk", "bd679eafde2084d8011f247e51b5a805"), - UNK_LANG, + EN_GRB, + kPlatformAmiga, + Common::ADGF_NO_FLAGS + }, + GF_GOB3, + "menu" + }, + { + { + "gob3", + "", + AD_ENTRY1("intro.stk", "bd679eafde2084d8011f247e51b5a805"), + DE_DEU, kPlatformAmiga, Common::ADGF_NO_FLAGS }, @@ -807,7 +867,7 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3, + GF_GOB3 | GF_CD, "intro" }, { // Supplied by paul66 and noizert in bug reports #1652352 and #1691230 @@ -819,7 +879,7 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3, + GF_GOB3 | GF_CD, "intro" }, { // Supplied by paul66 and noizert in bug reports #1652352 and #1691230 @@ -831,7 +891,7 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3, + GF_GOB3 | GF_CD, "intro" }, { // Supplied by paul66 and noizert in bug reports #1652352 and #1691230 @@ -843,7 +903,7 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3, + GF_GOB3 | GF_CD, "intro" }, { // Supplied by paul66 and noizert in bug reports #1652352 and #1691230 @@ -855,7 +915,7 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3, + GF_GOB3 | GF_CD, "intro" }, { // Supplied by paul66 and noizert in bug reports #1652352 and #1691230 @@ -867,7 +927,7 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3, + GF_GOB3 | GF_CD, "intro" }, { diff --git a/engines/gob/draw.h b/engines/gob/draw.h index 8e973a8ee5..62a4984267 100644 --- a/engines/gob/draw.h +++ b/engines/gob/draw.h @@ -139,6 +139,9 @@ public: _spritesArray[index] = 0; } void adjustCoords(char adjust, int16 *coord1, int16 *coord2); + void adjustCoords(char adjust, uint16 *coord1, uint16 *coord2) { + adjustCoords(adjust, (int16 *) coord1, (int16 *) coord2); + } void drawString(char *str, int16 x, int16 y, int16 color1, int16 color2, int16 transp, SurfaceDesc *dest, Video::FontDesc *font); void printTextCentered(int16 id, int16 left, int16 top, int16 right, @@ -154,7 +157,7 @@ public: virtual void spriteOperation(int16 operation) = 0; Draw(GobEngine *vm); - virtual ~Draw() {}; + virtual ~Draw() {} protected: GobEngine *_vm; @@ -170,7 +173,7 @@ public: virtual void spriteOperation(int16 operation); Draw_v1(GobEngine *vm); - virtual ~Draw_v1() {}; + virtual ~Draw_v1() {} }; class Draw_v2 : public Draw_v1 { @@ -183,7 +186,7 @@ public: virtual void spriteOperation(int16 operation); Draw_v2(GobEngine *vm); - virtual ~Draw_v2() {}; + virtual ~Draw_v2() {} }; class Draw_Bargon: public Draw_v2 { @@ -191,7 +194,7 @@ public: virtual void initScreen(); Draw_Bargon(GobEngine *vm); - virtual ~Draw_Bargon() {}; + virtual ~Draw_Bargon() {} }; // Draw operations diff --git a/engines/gob/draw_v1.cpp b/engines/gob/draw_v1.cpp index 58e0a3c2d3..bba9c790d6 100644 --- a/engines/gob/draw_v1.cpp +++ b/engines/gob/draw_v1.cpp @@ -63,7 +63,7 @@ void Draw_v1::animateCursor(int16 cursor) { if (cursorIndex == -1) { cursorIndex = 0; - for (ptr = _vm->_game->_collisionAreas; ptr->left != -1; ptr++) { + for (ptr = _vm->_game->_collisionAreas; ptr->left != 0xFFFF; ptr++) { if (ptr->flags & 0xFFF0) continue; diff --git a/engines/gob/draw_v2.cpp b/engines/gob/draw_v2.cpp index 6b7b1db0fd..67b8eb3c13 100644 --- a/engines/gob/draw_v2.cpp +++ b/engines/gob/draw_v2.cpp @@ -82,7 +82,7 @@ void Draw_v2::animateCursor(int16 cursor) { // .-- _draw_animateCursorSUB1 --- if (cursorIndex == -1) { cursorIndex = 0; - for (ptr = _vm->_game->_collisionAreas; ptr->left != -1; ptr++) { + for (ptr = _vm->_game->_collisionAreas; ptr->left != 0xFFFF; ptr++) { if ((ptr->flags & 0xF00) || (ptr->id & 0x4000)) continue; @@ -558,7 +558,7 @@ void Draw_v2::spriteOperation(int16 operation) { // Some handle, but always assigned to -1 in Game::loadTotFile() int16 word_2F2D2 = -1; - deltaVeto = (bool) (operation & 0x10); + deltaVeto = (operation & 0x10) != 0; operation &= 0x0F; if (_sourceSurface >= 100) diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp index f146cded6d..43eac76928 100644 --- a/engines/gob/game.cpp +++ b/engines/gob/game.cpp @@ -77,6 +77,8 @@ Game::Game(GobEngine *vm) : _vm(vm) { _handleMouse = 0; _forceHandleMouse = 0; _menuLevel = 0; + _noScroll = true; + _scrollHandleMouse = false; _tempStr[0] = 0; _curImaFile[0] = 0; @@ -133,7 +135,7 @@ byte *Game::loadExtData(int16 itemId, int16 *pResWidth, offset = item->offset; size = item->size; - isPacked = (bool) (item->width & 0x8000); + isPacked = (item->width & 0x8000) != 0; if (pResWidth != 0) { *pResWidth = item->width & 0x7FFF; @@ -196,7 +198,7 @@ byte *Game::loadExtData(int16 itemId, int16 *pResWidth, void Game::freeCollision(int16 id) { for (int i = 0; i < 250; i++) { if (_collisionAreas[i].id == id) - _collisionAreas[i].left = -1; + _collisionAreas[i].left = 0xFFFF; } } @@ -289,10 +291,10 @@ void Game::freeSoundSlot(int16 slot) { } void Game::evaluateScroll(int16 x, int16 y) { - if ((_handleMouse == 0) || (_menuLevel > 0)) + if (!_scrollHandleMouse || (_menuLevel > 0)) return; - if (_vm->_global->_videoMode != 0x14) + if (_noScroll || (_vm->_global->_videoMode != 0x14)) return; if ((x == 0) && (_vm->_draw->_scrollOffsetX > 0)) { @@ -301,10 +303,18 @@ void Game::evaluateScroll(int16 x, int16 y) { off = MIN(_vm->_draw->_cursorWidth, _vm->_draw->_scrollOffsetX); off = MAX(off / 2, 1); _vm->_draw->_scrollOffsetX -= off; + } else if ((y == 0) && (_vm->_draw->_scrollOffsetY > 0)) { + uint16 off; + + off = MIN(_vm->_draw->_cursorHeight, _vm->_draw->_scrollOffsetY); + off = MAX(off / 2, 1); + _vm->_draw->_scrollOffsetY -= off; } int16 cursorRight = x + _vm->_draw->_cursorWidth; int16 screenRight = _vm->_draw->_scrollOffsetX + 320; + int16 cursorBottom = y + _vm->_draw->_cursorHeight; + int16 screenBottom = _vm->_draw->_scrollOffsetY + 200; if ((cursorRight >= 320) && (screenRight < _vm->_video->_surfWidth)) { uint16 off; @@ -316,6 +326,18 @@ void Game::evaluateScroll(int16 x, int16 y) { _vm->_draw->_scrollOffsetX += off; _vm->_util->setMousePos(320 - _vm->_draw->_cursorWidth, y); + } else if ((cursorBottom >= (200 - _vm->_video->_splitHeight2)) && + (screenBottom < _vm->_video->_surfHeight)) { + uint16 off; + + off = MIN(_vm->_draw->_cursorHeight, + (int16) (_vm->_video->_surfHeight - screenBottom)); + off = MAX(off / 2, 1); + + _vm->_draw->_scrollOffsetY += off; + + _vm->_util->setMousePos(x, 200 - _vm->_video->_splitHeight2 - + _vm->_draw->_cursorHeight); } _vm->_util->setScrollOffset(); @@ -653,13 +675,13 @@ byte *Game::loadLocTexts(void) { void Game::setCollisions(void) { byte *savedIP; - int16 left; - int16 top; - int16 width; - int16 height; + uint16 left; + uint16 top; + uint16 width; + uint16 height; Collision *collArea; - for (collArea = _collisionAreas; collArea->left != -1; collArea++) { + for (collArea = _collisionAreas; collArea->left != 0xFFFF; collArea++) { if (((collArea->id & 0xC000) != 0x8000) || (collArea->funcSub == 0)) continue; @@ -669,7 +691,8 @@ void Game::setCollisions(void) { top = _vm->_parse->parseValExpr(); width = _vm->_parse->parseValExpr(); height = _vm->_parse->parseValExpr(); - if ((_vm->_draw->_renderFlags & RENDERFLAG_CAPTUREPOP) && (left != -1)) { + if ((_vm->_draw->_renderFlags & RENDERFLAG_CAPTUREPOP) && + (left != 0xFFFF)) { left += _vm->_draw->_backDeltaX; top += _vm->_draw->_backDeltaY; } diff --git a/engines/gob/game.h b/engines/gob/game.h index f509e0d6a0..66fa0179fd 100644 --- a/engines/gob/game.h +++ b/engines/gob/game.h @@ -37,10 +37,10 @@ public: struct Collision { int16 id; - int16 left; - int16 top; - int16 right; - int16 bottom; + uint16 left; + uint16 top; + uint16 right; + uint16 bottom; int16 flags; int16 key; uint16 funcEnter; @@ -128,6 +128,9 @@ public: int32 _startTimeKey; int16 _mouseButtons; + bool _noScroll; + bool _scrollHandleMouse; + Game(GobEngine *vm); virtual ~Game(); @@ -149,9 +152,9 @@ public: virtual void playTot(int16 skipPlay) = 0; virtual void clearCollisions(void) = 0; - virtual int16 addNewCollision(int16 id, int16 left, int16 top, int16 right, - int16 bottom, int16 flags, int16 key, uint16 funcEnter, - uint16 funcLeave) = 0; + virtual int16 addNewCollision(int16 id, uint16 left, uint16 top, + uint16 right, uint16 bottom, int16 flags, int16 key, + uint16 funcEnter, uint16 funcLeave) = 0; virtual void collisionsBlock(void) = 0; virtual int16 multiEdit(int16 time, int16 index, int16 *pCurPos, InputDesc *inpDesc, int16 *collResId, int16 *collIndex) = 0; @@ -230,9 +233,9 @@ public: virtual void playTot(int16 skipPlay); virtual void clearCollisions(void); - virtual int16 addNewCollision(int16 id, int16 left, int16 top, int16 right, - int16 bottom, int16 flags, int16 key, uint16 funcEnter, - uint16 funcLeave); + virtual int16 addNewCollision(int16 id, uint16 left, uint16 top, + uint16 right, uint16 bottom, int16 flags, int16 key, + uint16 funcEnter, uint16 funcLeave); virtual void collisionsBlock(void); virtual int16 multiEdit(int16 time, int16 index, int16 *pCurPos, InputDesc *inpDesc, int16 *collResId, int16 *collIndex); @@ -245,7 +248,7 @@ public: virtual void prepareStart(void); Game_v1(GobEngine *vm); - virtual ~Game_v1() {}; + virtual ~Game_v1() {} protected: virtual void pushCollisions(char all); @@ -258,9 +261,9 @@ public: virtual void playTot(int16 skipPlay); virtual void clearCollisions(void); - virtual int16 addNewCollision(int16 id, int16 left, int16 top, int16 right, - int16 bottom, int16 flags, int16 key, uint16 funcEnter, - uint16 funcLeave); + virtual int16 addNewCollision(int16 id, uint16 left, uint16 top, + uint16 right, uint16 bottom, int16 flags, int16 key, + uint16 funcEnter, uint16 funcLeave); virtual void collisionsBlock(void); virtual int16 multiEdit(int16 time, int16 index, int16 *pCurPos, InputDesc *inpDesc, int16 *collResId, int16 *collIndex); @@ -273,7 +276,7 @@ public: virtual void prepareStart(void); Game_v2(GobEngine *vm); - virtual ~Game_v2() {}; + virtual ~Game_v2() {} protected: struct CollLast { diff --git a/engines/gob/game_v1.cpp b/engines/gob/game_v1.cpp index ddc34f176c..6de1165470 100644 --- a/engines/gob/game_v1.cpp +++ b/engines/gob/game_v1.cpp @@ -257,12 +257,12 @@ void Game_v1::playTot(int16 skipPlay) { void Game_v1::clearCollisions() { for (int i = 0; i < 250; i++) { _collisionAreas[i].id = 0; - _collisionAreas[i].left = -1; + _collisionAreas[i].left = 0xFFFF; } } -int16 Game_v1::addNewCollision(int16 id, int16 left, int16 top, - int16 right, int16 bottom, int16 flags, int16 key, +int16 Game_v1::addNewCollision(int16 id, uint16 left, uint16 top, + uint16 right, uint16 bottom, int16 flags, int16 key, uint16 funcEnter, uint16 funcLeave) { Collision *ptr; @@ -275,7 +275,7 @@ int16 Game_v1::addNewCollision(int16 id, int16 left, int16 top, funcEnter, funcLeave); for (int i = 0; i < 250; i++) { - if (_collisionAreas[i].left != -1) + if (_collisionAreas[i].left != 0xFFFF) continue; ptr = &_collisionAreas[i]; @@ -300,7 +300,7 @@ void Game_v1::pushCollisions(char all) { int16 size; debugC(1, kDebugCollisions, "pushCollisions"); - for (size = 0, srcPtr = _collisionAreas; srcPtr->left != -1; srcPtr++) { + for (size = 0, srcPtr = _collisionAreas; srcPtr->left != 0xFFFF; srcPtr++) { if (all || (srcPtr->id & 0x8000)) size++; } @@ -310,10 +310,10 @@ void Game_v1::pushCollisions(char all) { _collStackElemSizes[_collStackSize] = size; _collStackSize++; - for (srcPtr = _collisionAreas; srcPtr->left != -1; srcPtr++) { + for (srcPtr = _collisionAreas; srcPtr->left != 0xFFFF; srcPtr++) { if (all || (srcPtr->id & 0x8000)) { memcpy(destPtr, srcPtr, sizeof(Collision)); - srcPtr->left = -1; + srcPtr->left = 0xFFFF; destPtr++; } } @@ -326,7 +326,7 @@ void Game_v1::popCollisions(void) { debugC(1, kDebugCollisions, "popCollision"); _collStackSize--; - for (destPtr = _collisionAreas; destPtr->left != -1; destPtr++); + for (destPtr = _collisionAreas; destPtr->left != 0xFFFF; destPtr++); srcPtr = _collStack[_collStackSize]; memcpy(destPtr, srcPtr, @@ -595,10 +595,10 @@ void Game_v1::collisionsBlock(void) { int16 cmdHigh; int16 key; int16 flags; - int16 left; - int16 top; - int16 width; - int16 height; + uint16 left; + uint16 top; + uint16 width; + uint16 height; int16 var_22; int16 index; int16 curEditIndex; @@ -693,7 +693,7 @@ void Game_v1::collisionsBlock(void) { _vm->_global->_inter_execPtr += _vm->_inter->load16(); } - if (left == -1) + if (left == 0xFFFF) break; if ((cmd & 1) == 0) { @@ -802,7 +802,7 @@ void Game_v1::collisionsBlock(void) { if (key == 0x1C0D) { for (i = 0; i < 250; i++) { - if (_collisionAreas[i].left == -1) + if (_collisionAreas[i].left == 0xFFFF) continue; if ((_collisionAreas[i].id & 0x8000) == 0) @@ -833,7 +833,7 @@ void Game_v1::collisionsBlock(void) { if (_activeCollResId == 0) { if (key != 0) { for (i = 0; i < 250; i++) { - if (_collisionAreas[i].left == -1) + if (_collisionAreas[i].left == 0xFFFF) continue; if ((_collisionAreas[i].id & 0x8000) == 0) @@ -850,7 +850,7 @@ void Game_v1::collisionsBlock(void) { if (_activeCollResId == 0) { for (i = 0; i < 250; i++) { - if (_collisionAreas[i].left == -1) + if (_collisionAreas[i].left == 0xFFFF) continue; if ((_collisionAreas[i].id & 0x8000) == 0) @@ -878,7 +878,7 @@ void Game_v1::collisionsBlock(void) { collPtr = _collisionAreas; for (i = 0, collPtr = _collisionAreas; - collPtr->left != -1; i++, collPtr++) { + collPtr->left != 0xFFFF; i++, collPtr++) { if ((collPtr->id & 0x8000) == 0) continue; @@ -923,7 +923,7 @@ void Game_v1::collisionsBlock(void) { if (descIndex != 0) { counter = 0; for (i = 0; i < 250; i++) { - if (_collisionAreas[i].left == -1) + if (_collisionAreas[i].left == 0xFFFF) continue; if ((_collisionAreas[i].id & 0x8000) == 0) @@ -939,7 +939,7 @@ void Game_v1::collisionsBlock(void) { } } else { for (i = 0; i < 250; i++) { - if (_collisionAreas[i].left == -1) + if (_collisionAreas[i].left == 0xFFFF) continue; if ((_collisionAreas[i].id & 0x8000) == 0) @@ -955,7 +955,7 @@ void Game_v1::collisionsBlock(void) { if (descIndex2 != 0) { counter = 0; for (i = 0; i < 250; i++) { - if (_collisionAreas[i].left == -1) + if (_collisionAreas[i].left == 0xFFFF) continue; if ((_collisionAreas[i].id & 0x8000) == 0) @@ -1010,7 +1010,7 @@ void Game_v1::collisionsBlock(void) { var_24 = 0; var_26 = 1; for (i = 0; i < 250; i++) { - if (_collisionAreas[i].left == -1) + if (_collisionAreas[i].left == 0xFFFF) continue; if ((_collisionAreas[i].id & 0x8000) == 0) @@ -1102,7 +1102,7 @@ int16 Game_v1::multiEdit(int16 time, int16 index, int16 *pCurPos, for (i = 0; i < 250; i++) { collArea = &_collisionAreas[i]; - if (collArea->left == -1) + if (collArea->left == 0xFFFF) continue; if ((collArea->id & 0x8000) == 0) @@ -1145,7 +1145,7 @@ int16 Game_v1::multiEdit(int16 time, int16 index, int16 *pCurPos, for (i = 0; i < 250; i++) { collArea = &_collisionAreas[i]; - if (collArea->left == -1) + if (collArea->left == 0xFFFF) continue; if ((collArea->id & 0x8000) == 0) @@ -1194,7 +1194,7 @@ int16 Game_v1::multiEdit(int16 time, int16 index, int16 *pCurPos, for (i = 0; i < 250; i++) { collArea = &_collisionAreas[i]; - if (collArea->left == -1) + if (collArea->left == 0xFFFF) continue; if ((collArea->id & 0x8000) == 0) @@ -1487,7 +1487,7 @@ int16 Game_v1::checkMousePoint(int16 all, int16 *resId, int16 *resIndex) { *resIndex = 0; ptr = _collisionAreas; - for (i = 0; ptr->left != -1; ptr++, i++) { + for (i = 0; ptr->left != 0xFFFF; ptr++, i++) { if (all) { if ((ptr->flags & 0xF) > 1) continue; diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp index 3113d81349..d10c599ddd 100644 --- a/engines/gob/game_v2.cpp +++ b/engines/gob/game_v2.cpp @@ -298,11 +298,12 @@ void Game_v2::clearCollisions() { _lastCollKey = 0; for (int i = 0; i < 150; i++) - _collisionAreas[i].left = -1; + _collisionAreas[i].left = 0xFFFF; } -int16 Game_v2::addNewCollision(int16 id, int16 left, int16 top, int16 right, int16 bottom, - int16 flags, int16 key, uint16 funcEnter, uint16 funcLeave) { +int16 Game_v2::addNewCollision(int16 id, uint16 left, uint16 top, + uint16 right, uint16 bottom, int16 flags, int16 key, + uint16 funcEnter, uint16 funcLeave) { Collision *ptr; debugC(5, kDebugCollisions, "addNewCollision"); @@ -314,7 +315,7 @@ int16 Game_v2::addNewCollision(int16 id, int16 left, int16 top, int16 right, int funcEnter, funcLeave); for (int i = 0; i < 150; i++) { - if ((_collisionAreas[i].left != -1) && (_collisionAreas[i].id != id)) + if ((_collisionAreas[i].left != 0xFFFF) && (_collisionAreas[i].id != id)) continue; ptr = &_collisionAreas[i]; @@ -341,7 +342,7 @@ void Game_v2::pushCollisions(char all) { int16 size; debugC(1, kDebugCollisions, "pushCollisions"); - for (size = 0, srcPtr = _collisionAreas; srcPtr->left != -1; srcPtr++) + for (size = 0, srcPtr = _collisionAreas; srcPtr->left != 0xFFFF; srcPtr++) if (all || (((uint16) srcPtr->id) >= 20)) size++; @@ -365,10 +366,10 @@ void Game_v2::pushCollisions(char all) { _lastCollAreaIndex = 0; _collStackSize++; - for (srcPtr = _collisionAreas; srcPtr->left != -1; srcPtr++) { + for (srcPtr = _collisionAreas; srcPtr->left != 0xFFFF; srcPtr++) { if (all || (((uint16) srcPtr->id) >= 20)) { memcpy(destPtr, srcPtr, sizeof(Collision)); - srcPtr->left = -1; + srcPtr->left = 0xFFFF; destPtr++; } } @@ -389,7 +390,7 @@ void Game_v2::popCollisions(void) { _lastCollId = _collLasts[_collStackSize].id; _lastCollAreaIndex = _collLasts[_collStackSize].areaIndex; - for (destPtr = _collisionAreas; destPtr->left != -1; destPtr++); + for (destPtr = _collisionAreas; destPtr->left != 0xFFFF; destPtr++); srcPtr = _collStack[_collStackSize]; memcpy(destPtr, srcPtr, @@ -407,7 +408,7 @@ int16 Game_v2::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId, int16 newkey; uint32 timeKey; - _handleMouse = handleMouse; + _scrollHandleMouse = handleMouse != 0; if (deltaTime >= -1) { _lastCollKey = 0; @@ -599,10 +600,10 @@ void Game_v2::collisionsBlock(void) { int16 cmdHigh; int16 key; int16 flags; - int16 left; - int16 top; - int16 width; - int16 height; + uint16 left; + uint16 top; + uint16 width; + uint16 height; int16 var_1C; int16 index; int16 curEditIndex; @@ -627,7 +628,7 @@ void Game_v2::collisionsBlock(void) { pushCollisions(0); collArea = _collisionAreas; - while (collArea->left != -1) + while (collArea->left != 0xFFFF) collArea++; _shouldPushColls = 0; @@ -680,12 +681,12 @@ void Game_v2::collisionsBlock(void) { height = _vm->_inter->load16(); } - if ((_vm->_draw->_renderFlags & RENDERFLAG_CAPTUREPOP) && (left != -1)) { + if ((_vm->_draw->_renderFlags & RENDERFLAG_CAPTUREPOP) && (left != 0xFFFF)) { left += _vm->_draw->_backDeltaX; top += _vm->_draw->_backDeltaY; } - if (left != -1) { + if (left != 0xFFFF) { _vm->_draw->adjustCoords(0, &left, &top); if (((cmd & 0x3F) < 20) && ((cmd & 0x3F) >= 3)) { if (_vm->_draw->_needAdjust != 2) @@ -766,7 +767,7 @@ void Game_v2::collisionsBlock(void) { } else descArray[index].ptr = 0; - if (left == -1) { + if (left == 0xFFFF) { if ((cmd & 1) == 0) { _vm->_global->_inter_execPtr += 2; _vm->_global->_inter_execPtr += @@ -875,7 +876,7 @@ void Game_v2::collisionsBlock(void) { WRITE_VAR(55, curEditIndex); if (key == 0x1C0D) { for (i = 0; i < 150; i++) { - if (_collisionAreas[i].left == -1) + if (_collisionAreas[i].left == 0xFFFF) break; if ((_collisionAreas[i].id & 0xC000) != 0x8000) @@ -905,7 +906,7 @@ void Game_v2::collisionsBlock(void) { if (_activeCollResId == 0) { if (key != 0) { for (i = 0; i < 150; i++) { - if (_collisionAreas[i].left == -1) + if (_collisionAreas[i].left == 0xFFFF) break; if ((_collisionAreas[i].id & 0xC000) != 0x8000) @@ -921,7 +922,7 @@ void Game_v2::collisionsBlock(void) { if (_activeCollResId == 0) { for (i = 0; i < 150; i++) { - if (_collisionAreas[i].left == -1) + if (_collisionAreas[i].left == 0xFFFF) break; if ((_collisionAreas[i].id & 0xC000) != 0x8000) @@ -945,7 +946,7 @@ void Game_v2::collisionsBlock(void) { if (stackPos2 != 0) { collStackPos = 0; - for (i = 0, collPtr = collArea; collPtr->left != -1; i++, collPtr++) { + for (i = 0, collPtr = collArea; collPtr->left != 0xFFFF; i++, collPtr++) { if ((collPtr->id & 0xF000) != 0x8000) continue; @@ -992,7 +993,7 @@ void Game_v2::collisionsBlock(void) { if (descIndex != 0) { counter = 0; - for (i = 0, collPtr = collArea; collPtr->left != -1; i++, collPtr++) { + for (i = 0, collPtr = collArea; collPtr->left != 0xFFFF; i++, collPtr++) { if ((collPtr->id & 0xF000) == 0x8000) if (++counter == descIndex) { _activeCollResId = collPtr->id; @@ -1003,7 +1004,7 @@ void Game_v2::collisionsBlock(void) { } else { - for (i = 0, collPtr = _collisionAreas; collPtr->left != -1; i++, collPtr++) { + for (i = 0, collPtr = _collisionAreas; collPtr->left != 0xFFFF; i++, collPtr++) { if ((collPtr->id & 0xF000) == 0x8000) { _activeCollResId = collPtr->id; _activeCollIndex = i; @@ -1043,7 +1044,7 @@ void Game_v2::collisionsBlock(void) { var_24 = 0; var_26 = 1; for (i = 0; i < 150; i++) { - if (_collisionAreas[i].left == -1) + if (_collisionAreas[i].left == 0xFFFF) continue; if ((_collisionAreas[i].id & 0xC000) == 0x8000) @@ -1148,7 +1149,7 @@ int16 Game_v2::multiEdit(int16 time, int16 index, int16 *pCurPos, for (i = 0; i < 150; i++) { collArea = &_collisionAreas[i]; - if (collArea->left == -1) + if (collArea->left == 0xFFFF) continue; if ((collArea->id & 0xC000) != 0x8000) @@ -1200,7 +1201,7 @@ int16 Game_v2::multiEdit(int16 time, int16 index, int16 *pCurPos, for (i = 0; i < 150; i++) { collArea = &_collisionAreas[i]; - if (collArea->left == -1) + if (collArea->left == 0xFFFF) continue; if ((collArea->id & 0xC000) != 0x8000) @@ -1241,7 +1242,7 @@ int16 Game_v2::multiEdit(int16 time, int16 index, int16 *pCurPos, if (_mouseButtons != 0) { for (collArea = _collisionAreas, i = 0; - collArea->left != -1; collArea++, i++) { + collArea->left != 0xFFFF; collArea++, i++) { if ((collArea->flags & 0xF00)) continue; @@ -1277,7 +1278,7 @@ int16 Game_v2::multiEdit(int16 time, int16 index, int16 *pCurPos, for (i = 0; i < 150; i++) { collArea = &_collisionAreas[i]; - if (collArea->left == -1) + if (collArea->left == 0xFFFF) continue; if ((collArea->id & 0xC000) != 0x8000) @@ -1586,7 +1587,7 @@ int16 Game_v2::checkMousePoint(int16 all, int16 *resId, int16 *resIndex) { *resIndex = 0; ptr = _collisionAreas; - for (i = 0; ptr->left != -1; ptr++, i++) { + for (i = 0; ptr->left != 0xFFFF; ptr++, i++) { if (ptr->id & 0x4000) continue; diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index e7ff850da1..6452ae279f 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -25,7 +25,7 @@ #include "base/plugins.h" #include "common/config-manager.h" -#include "common/fs.h" +//#include "common/fs.h" #include "common/md5.h" #include "sound/mididrv.h" @@ -191,7 +191,7 @@ int GobEngine::init() { _scenery = new Scenery_v2(this); _saveLoad = new SaveLoad_v2(this, _targetName.c_str()); } else if (_features & Gob::GF_GOB3) { - _init = new Init_v2(this); + _init = new Init_v3(this); _video = new Video_v2(this); _inter = new Inter_v3(this); _parse = new Parse_v2(this); diff --git a/engines/gob/goblin.cpp b/engines/gob/goblin.cpp index 61dfbaff31..4620afabaa 100644 --- a/engines/gob/goblin.cpp +++ b/engines/gob/goblin.cpp @@ -977,39 +977,48 @@ void Goblin::moveFindItem(int16 posX, int16 posY) { break; } - _pressedMapX = posX / 12; - _pressedMapY = posY / 6; + _pressedMapX = CLIP(posX / 12, 0, _vm->_map->_mapWidth - 1); + _pressedMapY = CLIP(posY / 6, 0, _vm->_map->_mapHeight - 1); if ((_vm->_map->_itemsMap[_pressedMapY][_pressedMapX] == 0) && (i < 20)) { - if (_vm->_map->_itemsMap[_pressedMapY + 1][_pressedMapX] != 0) { + if ((_pressedMapY < (_vm->_map->_mapHeight - 1)) && + (_vm->_map->_itemsMap[_pressedMapY + 1][_pressedMapX] != 0)) { _pressedMapY++; - } else if (_vm->_map->_itemsMap[_pressedMapY + 1][_pressedMapX + 1] != 0) { + } else if ((_pressedMapX < (_vm->_map->_mapWidth - 1)) && + (_pressedMapY < (_vm->_map->_mapHeight - 1)) && + (_vm->_map->_itemsMap[_pressedMapY + 1][_pressedMapX + 1] != 0)) { _pressedMapX++; _pressedMapY++; - } else if (_vm->_map->_itemsMap[_pressedMapY][_pressedMapX + 1] != 0) { + } else if ((_pressedMapX < (_vm->_map->_mapWidth - 1)) && + (_vm->_map->_itemsMap[_pressedMapY][_pressedMapX + 1] != 0)) { _pressedMapX++; - } else if (_vm->_map->_itemsMap[_pressedMapY - 1][_pressedMapX + 1] != 0) { + } else if ((_pressedMapX < (_vm->_map->_mapWidth - 1)) && + (_pressedMapY > 0) && + (_vm->_map->_itemsMap[_pressedMapY - 1][_pressedMapX + 1] != 0)) { _pressedMapX++; _pressedMapY--; - } else if (_vm->_map->_itemsMap[_pressedMapY - 1][_pressedMapX] != 0) { + } else if ((_pressedMapY > 0) && + (_vm->_map->_itemsMap[_pressedMapY - 1][_pressedMapX] != 0)) { _pressedMapY--; - } else if (_vm->_map->_itemsMap[_pressedMapY - 1][_pressedMapX - 1] != 0) { + } else if ((_pressedMapY > 0) && (_pressedMapX > 0) && + (_vm->_map->_itemsMap[_pressedMapY - 1][_pressedMapX - 1] != 0)) { _pressedMapY--; _pressedMapX--; - } else if (_vm->_map->_itemsMap[_pressedMapY][_pressedMapX - 1] != 0) { + } else if ((_pressedMapX > 0) && + (_vm->_map->_itemsMap[_pressedMapY][_pressedMapX - 1] != 0)) { _pressedMapX--; - } else if (_vm->_map->_itemsMap[_pressedMapY + 1][_pressedMapX - 1] != 0) { + } else if ((_pressedMapX > 0) && + (_pressedMapY < (_vm->_map->_mapHeight - 1)) && + (_vm->_map->_itemsMap[_pressedMapY + 1][_pressedMapX - 1] != 0)) { _pressedMapX--; _pressedMapY++; } } } else { - _pressedMapX = posX / 12; - _pressedMapY = posY / 6; + _pressedMapX = CLIP(posX / 12, 0, _vm->_map->_mapWidth - 1); + _pressedMapY = CLIP(posY / 6, 0, _vm->_map->_mapHeight - 1); } - _pressedMapX = CLIP((int) _pressedMapX, 0, _vm->_map->_mapWidth - 1); - _pressedMapY = CLIP((int) _pressedMapY, 0, _vm->_map->_mapHeight - 1); } void Goblin::moveCheckSelect(int16 framesCount, Gob_Object *gobDesc, diff --git a/engines/gob/goblin.h b/engines/gob/goblin.h index f8bddff332..a18213fcf7 100644 --- a/engines/gob/goblin.h +++ b/engines/gob/goblin.h @@ -271,7 +271,7 @@ public: int16 nextAct, int16 framesCount); Goblin_v1(GobEngine *vm); - virtual ~Goblin_v1() {}; + virtual ~Goblin_v1() {} protected: virtual bool isMovement(int8 state) { return false; } @@ -291,7 +291,7 @@ public: int16 nextAct, int16 framesCount); Goblin_v2(GobEngine *vm); - virtual ~Goblin_v2() {}; + virtual ~Goblin_v2() {} protected: virtual bool isMovement(int8 state); @@ -306,7 +306,7 @@ public: int16 index, int16 x, int16 y, int16 state); Goblin_v3(GobEngine *vm); - virtual ~Goblin_v3() {}; + virtual ~Goblin_v3() {} protected: virtual bool isMovement(int8 state); diff --git a/engines/gob/imd.cpp b/engines/gob/imd.cpp index d9faba5b61..d2fa69e067 100644 --- a/engines/gob/imd.cpp +++ b/engines/gob/imd.cpp @@ -961,7 +961,7 @@ uint16 ImdPlayer::checkFrameType(Imd *imdPtr, int16 frame) { } void ImdPlayer::seekFrame(Imd *imdPtr, int16 frame, int16 from, bool restart) { - uint32 framePos; + uint32 framePos = 0; if (!imdPtr) return; @@ -1011,6 +1011,8 @@ uint32 ImdPlayer::view(Imd *imdPtr, int16 frame) { _top = yBak = imdPtr->y; _bottom = heightBak= imdPtr->height; _right = widthBak = imdPtr->width; + _right += _left - 1; + _bottom += _top - 1; if ((frame == 0) && (imdPtr->verMin & 0x800)) _vm->_video->setPalette(imdPtr->palette); @@ -1106,7 +1108,7 @@ uint32 ImdPlayer::view(Imd *imdPtr, int16 frame) { cmd = _vm->_dataIO->readUint16(imdPtr->handle); - // Clear sound slice + // Empty sound slice } else if (!hasNextCmd && (!_noSound)) { soundBuf = new byte[_soundSliceSize]; assert(soundBuf); diff --git a/engines/gob/init.h b/engines/gob/init.h index 3ca935c6b4..6d8d71ae59 100644 --- a/engines/gob/init.h +++ b/engines/gob/init.h @@ -35,7 +35,7 @@ public: virtual void initVideo() = 0; Init(GobEngine *vm); - virtual ~Init() {}; + virtual ~Init() {} protected: Video::PalDesc *_palDesc; @@ -50,7 +50,7 @@ public: virtual void initVideo(); Init_v1(GobEngine *vm); - virtual ~Init_v1() {}; + virtual ~Init_v1() {} }; class Init_v2 : public Init_v1 { @@ -58,7 +58,15 @@ public: virtual void initVideo(); Init_v2(GobEngine *vm); - virtual ~Init_v2() {}; + virtual ~Init_v2() {} +}; + +class Init_v3 : public Init_v2 { +public: + virtual void initVideo(); + + Init_v3(GobEngine *vm); + virtual ~Init_v3() {} }; } // End of namespace Gob diff --git a/engines/gob/init_v3.cpp b/engines/gob/init_v3.cpp new file mode 100644 index 0000000000..5e10240257 --- /dev/null +++ b/engines/gob/init_v3.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2004 Ivan Dubrov + * Copyright (C) 2004-2006 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/stdafx.h" +#include "common/endian.h" + +#include "gob/gob.h" +#include "gob/init.h" +#include "gob/game.h" + +namespace Gob { + +Init_v3::Init_v3(GobEngine *vm) : Init_v2(vm) { +} + +void Init_v3::initVideo() { + Init_v2::initVideo(); + + _vm->_game->_noScroll = false; +} + +} // End of namespace Gob diff --git a/engines/gob/inter.h b/engines/gob/inter.h index cd685bd27e..90d0f7158e 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -61,7 +61,7 @@ public: virtual void animPalette() = 0; Inter(GobEngine *vm); - virtual ~Inter() {}; + virtual ~Inter() {} protected: struct OpFuncParams { @@ -108,7 +108,7 @@ protected: class Inter_v1 : public Inter { public: Inter_v1(GobEngine *vm); - virtual ~Inter_v1() {}; + virtual ~Inter_v1() {} virtual int16 loadSound(int16 slot); virtual void animPalette(); @@ -303,7 +303,7 @@ protected: class Inter_v2 : public Inter_v1 { public: Inter_v2(GobEngine *vm); - virtual ~Inter_v2() {}; + virtual ~Inter_v2() {} virtual int16 loadSound(int16 search); virtual void animPalette(); @@ -394,7 +394,7 @@ protected: class Inter_Bargon : public Inter_v2 { public: Inter_Bargon(GobEngine *vm); - virtual ~Inter_Bargon() {}; + virtual ~Inter_Bargon() {} protected: typedef void (Inter_Bargon::*OpcodeDrawProcBargon)(); @@ -440,7 +440,7 @@ protected: class Inter_v3 : public Inter_v2 { public: Inter_v3(GobEngine *vm); - virtual ~Inter_v3() {}; + virtual ~Inter_v3() {} protected: typedef void (Inter_v3::*OpcodeDrawProcV3)(); diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index 052aef0e25..822c96d749 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -1656,58 +1656,15 @@ bool Inter_v1::o1_keyFunc(OpFuncParams ¶ms) { break; case 1: + _vm->_util->forceMouseUp(true); key = _vm->_game->checkKeys(&_vm->_global->_inter_mouseX, &_vm->_global->_inter_mouseY, &_vm->_game->_mouseButtons, 0); storeKey(key); break; case 2: - key = 0; - - if (_vm->_global->_pressedKeys[0x48]) - key |= 1; - - if (_vm->_global->_pressedKeys[0x50]) - key |= 2; - - if (_vm->_global->_pressedKeys[0x4D]) - key |= 4; - - if (_vm->_global->_pressedKeys[0x4B]) - key |= 8; - - if (_vm->_global->_pressedKeys[0x1C]) - key |= 0x10; - - if (_vm->_global->_pressedKeys[0x39]) - key |= 0x20; - - if (_vm->_global->_pressedKeys[1]) - key |= 0x40; - - if (_vm->_global->_pressedKeys[0x1D]) - key |= 0x80; - - if (_vm->_global->_pressedKeys[0x2A]) - key |= 0x100; - - if (_vm->_global->_pressedKeys[0x36]) - key |= 0x200; - - if (_vm->_global->_pressedKeys[0x38]) - key |= 0x400; - - if (_vm->_global->_pressedKeys[0x3B]) - key |= 0x800; - - if (_vm->_global->_pressedKeys[0x3C]) - key |= 0x1000; - - if (_vm->_global->_pressedKeys[0x3D]) - key |= 0x2000; - - if (_vm->_global->_pressedKeys[0x3E]) - key |= 0x4000; + _vm->_util->processInput(true); + key = _vm->_util->checkKey(); WRITE_VAR(0, key); _vm->_util->clearKeyBuf(); @@ -2227,6 +2184,7 @@ bool Inter_v1::o1_readData(OpFuncParams ¶ms) { dataVar = _vm->_parse->parseVarIndex(); size = _vm->_parse->parseValExpr(); offset = _vm->_parse->parseValExpr(); + retSize = 0; if (_vm->_game->_extHandle >= 0) _vm->_dataIO->closeData(_vm->_game->_extHandle); diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index 3f76be5498..78ea9cab7a 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -975,7 +975,7 @@ void Inter_v2::o2_loadMultObject() { _vm->_global->_inter_execPtr++; } - if (_vm->_goblin->_gobsCount < 0) + if (_vm->_goblin->_gobsCount <= objIndex) return; Mult::Mult_Object &obj = _vm->_mult->_objects[objIndex]; @@ -1376,7 +1376,9 @@ void Inter_v2::o2_initScreen() { if (height > 0) _vm->_video->_surfHeight = height; - _vm->_video->_splitHeight = _vm->_video->_surfHeight - offY; + _vm->_video->_splitHeight1 = MIN(200, _vm->_video->_surfHeight - offY); + _vm->_video->_splitHeight2 = offY; + _vm->_video->_splitStart = _vm->_video->_surfHeight - offY; _vm->_draw->closeScreen(); _vm->_util->clearPalette(); @@ -1827,6 +1829,7 @@ bool Inter_v2::o2_readData(OpFuncParams ¶ms) { size = _vm->_parse->parseValExpr(); evalExpr(0); offset = _vm->_global->_inter_resVal; + retSize = 0; debugC(2, kDebugFileIO, "Read from file \"%s\" (%d, %d bytes at %d)", _vm->_global->_inter_resStr, dataVar, size, offset); @@ -2003,12 +2006,12 @@ void Inter_v2::o2_stopInfogrames(OpGobParams ¶ms) { } void Inter_v2::o2_handleGoblins(OpGobParams ¶ms) { - _vm->_goblin->_gob1NoTurn = (bool) VAR(load16()); - _vm->_goblin->_gob2NoTurn = (bool) VAR(load16()); + _vm->_goblin->_gob1NoTurn = VAR(load16()) != 0; + _vm->_goblin->_gob2NoTurn = VAR(load16()) != 0; _vm->_goblin->_gob1RelaxTimeVar = load16(); _vm->_goblin->_gob2RelaxTimeVar = load16(); - _vm->_goblin->_gob1Busy = (bool) VAR(load16()); - _vm->_goblin->_gob2Busy = (bool) VAR(load16()); + _vm->_goblin->_gob1Busy = VAR(load16()) != 0; + _vm->_goblin->_gob2Busy = VAR(load16()) != 0; _vm->_goblin->handleGoblins(); } @@ -2023,6 +2026,7 @@ int16 Inter_v2::loadSound(int16 search) { type = SOUND_SND; slotIdMask = 0; + dataSize = 0; if (!search) { slot = _vm->_parse->parseValExpr(); diff --git a/engines/gob/inter_v3.cpp b/engines/gob/inter_v3.cpp index 0fb270891b..f34953b40f 100644 --- a/engines/gob/inter_v3.cpp +++ b/engines/gob/inter_v3.cpp @@ -715,7 +715,7 @@ bool Inter_v3::o3_getTotTextItemPart(OpFuncParams ¶ms) { int16 totTextItem; int16 part, curPart = 0; int16 offX = 0, offY = 0; - int16 collId, collCmd; + int16 collId = 0, collCmd; uint32 stringStartVar, stringVar; bool end; diff --git a/engines/gob/module.mk b/engines/gob/module.mk index 63aea49a29..db0660fa5c 100644 --- a/engines/gob/module.mk +++ b/engines/gob/module.mk @@ -22,6 +22,7 @@ MODULE_OBJS := \ init.o \ init_v1.o \ init_v2.o \ + init_v3.o \ inter.o \ inter_v1.o \ inter_v2.o \ diff --git a/engines/gob/mult.cpp b/engines/gob/mult.cpp index d0b2a6589c..d407c41292 100644 --- a/engines/gob/mult.cpp +++ b/engines/gob/mult.cpp @@ -104,6 +104,8 @@ void Mult::initAll(void) { _objects = 0; _animSurf = 0; _renderData = 0; + + _vm->_scenery->init(); } void Mult::freeAll(void) { @@ -113,7 +115,6 @@ void Mult::freeAll(void) { _vm->_scenery->freeAnim(i); _vm->_scenery->freeStatic(i); } - _vm->_scenery->init(); } void Mult::freeMult() { diff --git a/engines/gob/mult.h b/engines/gob/mult.h index 7f318e8a7f..4be1290a87 100644 --- a/engines/gob/mult.h +++ b/engines/gob/mult.h @@ -293,7 +293,7 @@ protected: class Mult_v1 : public Mult { public: Mult_v1(GobEngine *vm); - virtual ~Mult_v1() {}; + virtual ~Mult_v1() {} virtual void loadMult(int16 resId); virtual void freeMultKeys(); diff --git a/engines/gob/mult_v2.cpp b/engines/gob/mult_v2.cpp index d973ea4c22..8b158ab314 100644 --- a/engines/gob/mult_v2.cpp +++ b/engines/gob/mult_v2.cpp @@ -227,6 +227,13 @@ void Mult_v2::loadMult(int16 resId) { case 3: _vm->_global->_inter_execPtr += 4; break; + + case -1: + break; + + default: + warning("Mult_v2::loadMult(): Unknown sound key command (%d)", + _multData->sndKeys[i].cmd); } } @@ -1185,6 +1192,8 @@ void Mult_v2::advanceObjects(int16 index) { } void Mult_v2::advanceAllObjects() { + Mult_Data *multData = _multData; + for (int i = 0; i < 8; i++) { if (_multDatas[i]) { _multData = _multDatas[i]; @@ -1192,6 +1201,8 @@ void Mult_v2::advanceAllObjects() { advanceObjects(j); } } + + _multData = multData; } } // End of namespace Gob diff --git a/engines/gob/parse.cpp b/engines/gob/parse.cpp index 93af23c82b..a603fd164e 100644 --- a/engines/gob/parse.cpp +++ b/engines/gob/parse.cpp @@ -196,17 +196,17 @@ void Parse::printExpr_internal(char stopToken) { debugN(5, "var8_%d", _vm->_inter->load16()); break; - case 19: // uint32 immediate + case 19: // int32/uint32 immediate debugN(5, "%d", READ_LE_UINT32(_vm->_global->_inter_execPtr)); _vm->_global->_inter_execPtr += 4; break; - case 20: // uint16 immediate + case 20: // int16 immediate debugN(5, "%d", _vm->_inter->load16()); break; - case 21: // uint8 immediate - debugN(5, "%d", *_vm->_global->_inter_execPtr++); + case 21: // int8 immediate + debugN(5, "%d", (int8) *_vm->_global->_inter_execPtr++); break; case 22: // string immediate diff --git a/engines/gob/parse.h b/engines/gob/parse.h index 27a6f50b1c..22853e24f0 100644 --- a/engines/gob/parse.h +++ b/engines/gob/parse.h @@ -36,7 +36,7 @@ public: virtual int16 parseExpr(byte stopToken, byte *resultPtr) = 0; Parse(GobEngine *vm); - virtual ~Parse() {}; + virtual ~Parse() {} protected: enum PointerType { @@ -56,7 +56,7 @@ protected: class Parse_v1 : public Parse { public: Parse_v1(GobEngine *vm); - virtual ~Parse_v1() {}; + virtual ~Parse_v1() {} virtual int16 parseVarIndex(void); virtual int16 parseValExpr(byte stopToken = 99); @@ -66,7 +66,7 @@ public: class Parse_v2 : public Parse_v1 { public: Parse_v2(GobEngine *vm); - virtual ~Parse_v2() {}; + virtual ~Parse_v2() {} virtual int16 parseVarIndex(void); virtual int16 parseValExpr(byte stopToken = 99); diff --git a/engines/gob/saveload.h b/engines/gob/saveload.h index 905ec6965d..6f867e30ec 100644 --- a/engines/gob/saveload.h +++ b/engines/gob/saveload.h @@ -114,7 +114,7 @@ public: virtual SaveType getSaveType(const char *fileName); SaveLoad_v2(GobEngine *vm, const char *targetName); - virtual ~SaveLoad_v2() {}; + virtual ~SaveLoad_v2() {} protected: virtual uint32 getSaveGameSize(); @@ -135,7 +135,7 @@ public: virtual SaveType getSaveType(const char *fileName); SaveLoad_v3(GobEngine *vm, const char *targetName); - virtual ~SaveLoad_v3() {}; + virtual ~SaveLoad_v3() {} protected: bool _useScreenshots; diff --git a/engines/gob/scenery.h b/engines/gob/scenery.h index 864b74f18d..365bbd326c 100644 --- a/engines/gob/scenery.h +++ b/engines/gob/scenery.h @@ -156,7 +156,7 @@ public: virtual int16 loadAnim(char search); Scenery_v1(GobEngine *vm); - virtual ~Scenery_v1() {}; + virtual ~Scenery_v1() {} }; class Scenery_v2 : public Scenery_v1 { @@ -164,7 +164,7 @@ public: virtual int16 loadAnim(char search); Scenery_v2(GobEngine *vm); - virtual ~Scenery_v2() {}; + virtual ~Scenery_v2() {} }; } // End of namespace Gob diff --git a/engines/gob/sound.cpp b/engines/gob/sound.cpp index c2e48adac1..baee878f4d 100644 --- a/engines/gob/sound.cpp +++ b/engines/gob/sound.cpp @@ -33,6 +33,8 @@ namespace Gob { +#define FRAC_BITS 16 + void SoundDesc::set(SoundType type, SoundSource src, byte *data, uint32 dSize) { @@ -168,15 +170,18 @@ Snd::Snd(GobEngine *vm) : _vm(vm) { _length = 0; _freq = 0; _repCount = 0; - _offset = 0.0; - _frac = 0.0; + _offset = 0; + _offsetFrac = 0; + _offsetInc = 0; + _offsetIncFrac = 0; + _cur = 0; _last = 0; _fade = false; - _fadeVol = 255.0; - _fadeVolStep = 0.0; + _fadeVol = 65536; + _fadeVolStep = 0; _fadeSamples = 0; _curFadeSamples = 0; @@ -228,9 +233,9 @@ void Snd::stopSound(int16 fadeLength, SoundDesc *sndDesc) { } _fade = true; - _fadeVol = 255.0; + _fadeVol = 65536; _fadeSamples = (int) (fadeLength * (((double) _rate) / 10.0)); - _fadeVolStep = 255.0 / ((double) _fadeSamples); + _fadeVolStep = MAX((int32) 1, (int32) (65536 / _fadeSamples)); _curFadeSamples = 0; } @@ -312,29 +317,31 @@ void Snd::setSample(SoundDesc &sndDesc, int16 repCount, int16 frequency, _length = sndDesc.size(); _freq = frequency; - if ((frequency % 100) == 0) - _freq--; - - _ratio = ((double) _freq) / _rate; - _offset = 0.0; - _frac = 0; - _last = _cur; - _cur = _data[0]; _repCount = repCount; _end = false; _playingSound = 1; + _offset = 0; + _offsetFrac = 0; + + uint32 incr = (_freq << FRAC_BITS) / _rate; + _offsetInc = incr >> FRAC_BITS; + _offsetIncFrac = incr & ((1UL << FRAC_BITS) - 1); + + _last = _cur; + _cur = _data[0]; + _curFadeSamples = 0; if (fadeLength == 0) { _fade = false; - _fadeVol = 255.0; + _fadeVol = 65536; _fadeSamples = 0; - _fadeVolStep = 0.0; + _fadeVolStep = 0; } else { _fade = true; - _fadeVol = 0.0; + _fadeVol = 0; _fadeSamples = (int) (fadeLength * (((double) _rate) / 10.0)); - _fadeVolStep = -(255.0 / ((double) _fadeSamples)); + _fadeVolStep = - MAX((int32) 1, (int32) (65536 / _fadeSamples)); } } @@ -371,8 +378,8 @@ void Snd::checkEndSample() { if (_compositionPos != -1) nextCompositionPos(); else if ((_repCount == -1) || (--_repCount > 0)) { - _offset = 0.0; - _frac = 0.0; + _offset = 0; + _offsetFrac = 0; _end = false; _playingSound = 1; } else { @@ -384,6 +391,9 @@ void Snd::checkEndSample() { int Snd::readBuffer(int16 *buffer, const int numSamples) { Common::StackLock slock(_mutex); + int16 val; + uint32 tmp, oldOffset; + for (int i = 0; i < numSamples; i++) { if (!_data) return i; @@ -392,16 +402,25 @@ int Snd::readBuffer(int16 *buffer, const int numSamples) { if (_end) return i; - *buffer++ = (int16) ((_last + (_cur - _last) * _frac) * _fadeVol); - _frac += _ratio; - _offset += _ratio; - while ((_frac > 1) && (_offset < _length)) { - _frac -= 1; + // Linear interpolation. See sound/rate.cpp + + val = (_last + (((_cur - _last) * _offsetFrac + + (1UL << (FRAC_BITS - 1))) >> FRAC_BITS)) << 8; + *buffer++ = (((int32) val) * _fadeVol) >> 16; + + oldOffset = _offset; + + tmp = _offsetFrac + _offsetIncFrac; + _offset += _offsetInc + (tmp >> FRAC_BITS); + _offsetFrac = tmp & ((1UL << FRAC_BITS) - 1); + + if (oldOffset < _offset) { _last = _cur; - _cur = _data[(int) _offset]; + _cur = _data[oldOffset]; } if (_fade) { + if (++_curFadeSamples >= _fadeSamples) { if (_fadeVolStep > 0) { _data = 0; @@ -410,11 +429,15 @@ int Snd::readBuffer(int16 *buffer, const int numSamples) { _compositionPos = -1; _curSoundDesc = 0; } else { - _fadeVol = 255.0; + _fadeVol = 65536; _fade = false; } } else _fadeVol -= _fadeVolStep; + + if (_fadeVol < 0) + _fadeVol = 0; + } } return numSamples; diff --git a/engines/gob/sound.h b/engines/gob/sound.h index ffdaf2a3d6..8f05fcf2e1 100644 --- a/engines/gob/sound.h +++ b/engines/gob/sound.h @@ -51,7 +51,7 @@ public: byte *getData() { return _dataPtr; } uint32 size() { return _size; } bool empty() { return !_dataPtr; } - bool isId(int16 id) { return _dataPtr && _id == id; }; + bool isId(int16 id) { return _dataPtr && _id == id; } SoundType getType() { return _type; } void set(SoundType type, SoundSource src, byte *data, uint32 dSize); @@ -171,16 +171,18 @@ protected: uint32 _rate; int32 _freq; int32 _repCount; - double _offset; - double _ratio; - double _frac; + uint32 _offset; + uint32 _offsetFrac; + uint32 _offsetInc; + uint32 _offsetIncFrac; + int16 _cur; int16 _last; bool _fade; - double _fadeVol; - double _fadeVolStep; + int32 _fadeVol; + int32 _fadeVolStep; uint8 _fadeLength; uint32 _fadeSamples; uint32 _curFadeSamples; diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp index e2ef60d5e2..ad10381dac 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -82,7 +82,7 @@ void Util::initInput(void) { void Util::processInput(bool scroll) { Common::Event event; Common::EventManager *eventMan = g_system->getEventManager(); - int16 x, y; + int16 x = 0, y = 0; bool hasMove = false; while (eventMan->pollEvent(event)) { @@ -112,7 +112,7 @@ void Util::processInput(bool scroll) { _fastMode ^= 2; break; } - addKeyToBuffer(event.kbd.keycode); + addKeyToBuffer(event.kbd.ascii); break; case Common::EVENT_KEYUP: break; @@ -125,8 +125,13 @@ void Util::processInput(bool scroll) { } _vm->_global->_speedFactor = MIN(_fastMode + 1, 3); - if (scroll && hasMove) + if (scroll && hasMove) { + if (y >= (200 - _vm->_video->_splitHeight2)) { + y = 200 - _vm->_video->_splitHeight2 - 1; + _vm->_util->setMousePos(x, y); + } _vm->_game->evaluateScroll(x, y); + } } void Util::clearKeyBuf(void) { @@ -171,16 +176,16 @@ int16 Util::translateKey(int16 key) { {274, 0x5000}, // Down arrow {275, 0x4D00}, // Right arrow {276, 0x4B00}, // Left arrow - {282, 0x3B00}, // F1 - {283, 0x3C00}, // F2 - {284, 0x3D00}, // F3 - {285, 0x3E00}, // F4 - {286, 0x011B}, // F5 - {287, 0x4000}, // F6 - {288, 0x4100}, // F7 - {289, 0x4200}, // F8 - {290, 0x4300}, // F9 - {291, 0x4400} // F10 + {315, 0x3B00}, // F1 + {316, 0x3C00}, // F2 + {317, 0x3D00}, // F3 + {318, 0x3E00}, // F4 + {319, 0x011B}, // F5 + {320, 0x4000}, // F6 + {321, 0x4100}, // F7 + {322, 0x4200}, // F8 + {323, 0x4300}, // F9 + {324, 0x4400} // F10 }; for (int i = 0; i < ARRAYSIZE(keys); i++) @@ -261,7 +266,10 @@ void Util::waitMouseRelease(char drawMouse) { } while (buttons != 0); } -void Util::forceMouseUp(void) { +void Util::forceMouseUp(bool onlyWhenSynced) { + if (onlyWhenSynced && (_vm->_game->_mouseButtons != _mouseButtons)) + return; + _vm->_game->_mouseButtons = 0; _mouseButtons = 0; } @@ -385,6 +393,11 @@ void Util::cutFromStr(char *str, int16 from, int16 cutlen) { } while (str[i] != 0); } +void Util::replaceChar(char *str, char c1, char c2) { + while ((str = strchr(str, c1))) + *str = c2; +} + static const char trStr1[] = " ' + - :0123456789: <=> abcdefghijklmnopqrstuvwxyz " "abcdefghijklmnopqrstuvwxyz "; diff --git a/engines/gob/util.h b/engines/gob/util.h index ca9042598c..3adc26385a 100644 --- a/engines/gob/util.h +++ b/engines/gob/util.h @@ -64,7 +64,7 @@ public: void waitMouseUp(void); void waitMouseDown(void); void waitMouseRelease(char drawMouse); - void forceMouseUp(void); + void forceMouseUp(bool onlyWhenSynced = false); void clearPalette(void); void setFrameRate(int16 rate); @@ -77,6 +77,7 @@ public: static void insertStr(const char *str1, char *str2, int16 pos); static void cutFromStr(char *str, int16 from, int16 cutlen); static void prepareStr(char *str); + static void replaceChar(char *str, char c1, char c2); static void listInsertFront(List *list, void *data); static void listInsertBack(List *list, void *data); diff --git a/engines/gob/video.cpp b/engines/gob/video.cpp index 4af5ece7c5..93b9f9b470 100644 --- a/engines/gob/video.cpp +++ b/engines/gob/video.cpp @@ -89,7 +89,9 @@ Video::Video(GobEngine *vm) : _vm(vm) { _surfHeight = 200; _scrollOffsetX = 0; _scrollOffsetY = 0; - _splitHeight = 200; + _splitHeight1 = 200; + _splitHeight2 = 0; + _splitStart = 0; _curSparse = 0; _lastSparse = 0xFFFFFFFF; @@ -162,11 +164,11 @@ void Video::retrace(bool mouse) { if (_vm->_global->_primarySurfDesc) { g_system->copyRectToScreen(_vm->_global->_primarySurfDesc->getVidMem() + _scrollOffsetY * _surfWidth + _scrollOffsetX, _surfWidth, - 0, 0, 320, _splitHeight); - if (_splitHeight < _surfHeight) + 0, 0, 320, _splitHeight1); + if (_splitHeight2 > 0) g_system->copyRectToScreen(_vm->_global->_primarySurfDesc->getVidMem() + - _splitHeight * _surfWidth, _surfWidth, 0, _splitHeight, 320, - _surfHeight - _splitHeight); + _splitStart * _surfWidth, _surfWidth, 0, + 200 - _splitHeight2, 320, _splitHeight2); g_system->updateScreen(); } } diff --git a/engines/gob/video.h b/engines/gob/video.h index d3d297d8cb..21c3e7d0f2 100644 --- a/engines/gob/video.h +++ b/engines/gob/video.h @@ -99,7 +99,9 @@ public: int16 _surfHeight; int16 _scrollOffsetX; int16 _scrollOffsetY; - int16 _splitHeight; + int16 _splitHeight1; + int16 _splitHeight2; + int16 _splitStart; void freeDriver(); void initPrimary(int16 mode); @@ -147,7 +149,7 @@ public: SurfaceDesc *destDesc) = 0; Video(class GobEngine *vm); - virtual ~Video() {}; + virtual ~Video() {} protected: class VideoDriver *_videoDriver; @@ -166,7 +168,7 @@ public: int16 x, int16 y, int16 transp, SurfaceDesc *destDesc); Video_v1(GobEngine *vm); - virtual ~Video_v1() {}; + virtual ~Video_v1() {} }; class Video_v2 : public Video_v1 { @@ -175,7 +177,7 @@ public: int16 x, int16 y, int16 transp, SurfaceDesc *destDesc); Video_v2(GobEngine *vm); - virtual ~Video_v2() {}; + virtual ~Video_v2() {} }; class VideoDriver { |