diff options
Diffstat (limited to 'engines/gob')
-rw-r--r-- | engines/gob/draw_v2.cpp | 10 | ||||
-rw-r--r-- | engines/gob/game.cpp | 7 | ||||
-rw-r--r-- | engines/gob/game_v2.cpp | 8 | ||||
-rw-r--r-- | engines/gob/gob.cpp | 5 | ||||
-rw-r--r-- | engines/gob/gob.h | 3 | ||||
-rw-r--r-- | engines/gob/goblin.cpp | 154 | ||||
-rw-r--r-- | engines/gob/goblin.h | 1 | ||||
-rw-r--r-- | engines/gob/init.cpp | 1 | ||||
-rw-r--r-- | engines/gob/inter.h | 1 | ||||
-rw-r--r-- | engines/gob/inter_v1.cpp | 1 | ||||
-rw-r--r-- | engines/gob/inter_v2.cpp | 97 | ||||
-rw-r--r-- | engines/gob/map_v2.cpp | 6 | ||||
-rw-r--r-- | engines/gob/mult.h | 17 | ||||
-rw-r--r-- | engines/gob/mult_v2.cpp | 6 | ||||
-rw-r--r-- | engines/gob/music.cpp | 9 | ||||
-rw-r--r-- | engines/gob/music.h | 4 | ||||
-rw-r--r-- | engines/gob/parse_v2.cpp | 57 |
17 files changed, 314 insertions, 73 deletions
diff --git a/engines/gob/draw_v2.cpp b/engines/gob/draw_v2.cpp index 7be6f20f52..b1c75a6955 100644 --- a/engines/gob/draw_v2.cpp +++ b/engines/gob/draw_v2.cpp @@ -478,7 +478,7 @@ void Draw_v2::spriteOperation(int16 operation) { int16 y; Video::SurfaceDesc *sourceSurf; Video::SurfaceDesc *destSurf; - bool deltaveto; + bool deltaVeto; int16 left; int16 ratio; int16 spriteLeft; @@ -494,10 +494,10 @@ void Draw_v2::spriteOperation(int16 operation) { // '--- if (operation & 0x10) { - deltaveto = true; + deltaVeto = true; operation &= 0x0F; } else - deltaveto = false; + deltaVeto = false; if (_sourceSurface >= 100) _sourceSurface -= 80; @@ -505,7 +505,7 @@ void Draw_v2::spriteOperation(int16 operation) { if (_destSurface >= 100) _destSurface -= 80; - if ((_renderFlags & RENDERFLAG_USEDELTAS) && !deltaveto) { + if ((_renderFlags & RENDERFLAG_USEDELTAS) && !deltaVeto) { if ((_sourceSurface == 21) && (operation != DRAW_LOADSPRITE)) { _spriteLeft += _backDeltaX; _spriteTop += _backDeltaY; @@ -864,7 +864,7 @@ void Draw_v2::spriteOperation(int16 operation) { _destSpriteX += len * strlen(_textToPrint); } - if ((_renderFlags & RENDERFLAG_USEDELTAS) && !deltaveto) { + if ((_renderFlags & RENDERFLAG_USEDELTAS) && !deltaVeto) { if (_sourceSurface == 21) { _spriteLeft -= _backDeltaX; _spriteTop -= _backDeltaY; diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp index 3445c66074..acc3ee2194 100644 --- a/engines/gob/game.cpp +++ b/engines/gob/game.cpp @@ -344,7 +344,8 @@ void Game::freeSoundSlot(int16 slot) { return; if (_soundADL[slot]) { - _vm->_music->stopPlay(); + if (_vm->_music->getIndex() == slot) + _vm->_music->stopPlay(); if (_soundFromExt[slot] == 1) { delete[] ((char *) _soundSamples[slot]); _soundFromExt[slot] = 0; @@ -866,8 +867,10 @@ char *Game::loadLocTexts(void) { warning("Your game version doesn't support the requested language, using the first one available"); for (i = 0; i < 10; i++) { handle = openLocTextFile(locTextFile, i); - if (handle >= 0) + if (handle >= 0) { _vm->_global->_language = i; + break; + } } } diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp index ec0ef0a27b..b81819f3f2 100644 --- a/engines/gob/game_v2.cpp +++ b/engines/gob/game_v2.cpp @@ -115,6 +115,7 @@ void Game_v2::playTot(int16 skipPlay) { loadTotFile(_curTotFile); if (_totFileData == 0) { _vm->_draw->blitCursor(); + _vm->_inter->_terminate = 2; break; } @@ -258,6 +259,13 @@ void Game_v2::playTot(int16 skipPlay) { strcpy(_curTotFile, _totToLoad); } + } else { + _vm->_scenery->_pCaptureCounter = oldCaptureCounter; + _vm->_global->_inter_execPtr = (char *)_totFileData; + _vm->_global->_inter_execPtr += READ_LE_UINT16(_totFileData + (skipPlay << 1) + 0x66); + _vm->_inter->callSub(2); + if (_vm->_inter->_terminate != 0) + _vm->_inter->_terminate = 2; } strcpy(_curTotFile, savedTotName); diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index e6016b1442..ec023f3ae3 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -193,6 +193,11 @@ void GobEngine::shutdown() { _quitRequested = true; } +void GobEngine::writeVarDebug(uint32 offs, uint32 v) { + warning("Setting var %d(%d) to %d", offs, offs >> 2, v); + (*(uint32 *)(_global->_inter_variables + (offs))) = v; +} + int GobEngine::init() { _snd = new Snd(this); _global = new Global(this); diff --git a/engines/gob/gob.h b/engines/gob/gob.h index ca84d2bed3..95880ef2dd 100644 --- a/engines/gob/gob.h +++ b/engines/gob/gob.h @@ -55,6 +55,7 @@ class Music; #define VAR(var) VAR_OFFSET((var) << 2) #define VAR_ADDRESS(var) (&VAR(var)) +//#define WRITE_VAR_OFFSET(offs, val) _vm->writeVarDebug(offs, val) #define WRITE_VAR_OFFSET(offs, val) (VAR_OFFSET(offs) = (val)) #define WRITE_VAR(var, val) WRITE_VAR_OFFSET((var) << 2, (val)) @@ -120,6 +121,8 @@ public: Util *_util; Inter *_inter; Music *_music; + + void writeVarDebug(uint32 offs, uint32 v); }; } // End of namespace Gob diff --git a/engines/gob/goblin.cpp b/engines/gob/goblin.cpp index 15809a8dc3..04f5ce79b9 100644 --- a/engines/gob/goblin.cpp +++ b/engines/gob/goblin.cpp @@ -1890,10 +1890,10 @@ void Goblin::sub_19BD3(void) { var_A = anim1->field_13; var_C = anim1->field_14; - pass = _vm->_map->getPass(gob1X, gob1Y, 40); + pass = _vm->_map->getPass(gob1X, gob1Y); if ((pass > 17) && (pass < 21)) warning("GOB2 Stub! sub_19AB7(anim0);"); - pass = _vm->_map->getPass(gob2X, gob2Y, 40); + pass = _vm->_map->getPass(gob2X, gob2Y); if ((pass > 17) && (pass < 21)) warning("GOB2 Stub! sub_19B45(anim1);"); @@ -1901,57 +1901,57 @@ void Goblin::sub_19BD3(void) { return; if (gob1Y > si) { - if (_vm->_map->getPass(di, si, 40) > 17) { + if (_vm->_map->getPass(di, si) > 17) { do { si--; - } while (_vm->_map->getPass(di, si, 40) > 17); + } while (_vm->_map->getPass(di, si) > 17); si++; - if (_vm->_map->getPass(di - 1, si, 40) == 0) { - if (_vm->_map->getPass(di + 1, si, 40) != 0) + if (_vm->_map->getPass(di - 1, si) == 0) { + if (_vm->_map->getPass(di + 1, si) != 0) di++; } else di--; - warning("GOB2 Stub! sub_197A6(di (=%d), si (=%d), 0);", si, di); + sub_197A6(di, si, 0); } } else { - if (_vm->_map->getPass(di, si, 40) > 17) { + if (_vm->_map->getPass(di, si) > 17) { do { si++; - } while (_vm->_map->getPass(di, si, 40) > 17); + } while (_vm->_map->getPass(di, si) > 17); si--; - if (_vm->_map->getPass(di - 1, si, 40) == 0) { - if (_vm->_map->getPass(di + 1, si, 40) != 0) + if (_vm->_map->getPass(di - 1, si) == 0) { + if (_vm->_map->getPass(di + 1, si) != 0) di++; } else di--; - warning("GOB2 Stub! sub_197A6(di (=%d), si (=%d), 0);", si, di); + sub_197A6(di, si, 0); } } if (gob2Y > var_C) { - if (_vm->_map->getPass(var_A, var_C, 40) > 17) { + if (_vm->_map->getPass(var_A, var_C) > 17) { do { var_C--; - } while (_vm->_map->getPass(var_A, var_C, 40) > 17); + } while (_vm->_map->getPass(var_A, var_C) > 17); var_C++; - if (_vm->_map->getPass(var_A - 1, var_C, 40) == 0) { - if (_vm->_map->getPass(var_A + 1, var_C, 40) != 0) + if (_vm->_map->getPass(var_A - 1, var_C) == 0) { + if (_vm->_map->getPass(var_A + 1, var_C) != 0) var_A++; } else var_A--; - warning("GOB2 Stub! sub_197A6(var_A (=%d), var_C (=%d), 1);", var_A, var_C); + sub_197A6(var_A, var_C, 1); } } else { - if (_vm->_map->getPass(var_A, var_C, 40) > 17) { + if (_vm->_map->getPass(var_A, var_C) > 17) { do { var_C++; - } while (_vm->_map->getPass(var_A, var_C, 40) > 17); + } while (_vm->_map->getPass(var_A, var_C) > 17); var_C--; - if (_vm->_map->getPass(var_A - 1, var_C, 40) == 0) { - if (_vm->_map->getPass(var_A + 1, var_C, 40) != 0) + if (_vm->_map->getPass(var_A - 1, var_C) == 0) { + if (_vm->_map->getPass(var_A + 1, var_C) != 0) var_A++; } else var_A--; - warning("GOB2 Stub! sub_197A6(var_A (=%d), var_C (=%d), 1);", var_A, var_C); + sub_197A6(var_A, var_C, 1); } } } @@ -2049,4 +2049,114 @@ void Goblin::sub_11984(Mult::Mult_Object *obj) { animData->frame--; } +void Goblin::sub_197A6(int16 destX, int16 destY, int16 objIndex) { + Mult::Mult_Object *obj; + Mult::Mult_AnimData *animData; + int16 mouseX; + int16 mouseY; + int16 gobDestX; + int16 gobDestY; + int16 mapWidth; + int16 mapHeight; + int16 di; + int16 si; + int16 var_1E; + int16 var_20; + int i; + + obj = &_vm->_mult->_objects[objIndex]; + animData = obj->pAnimData; + + obj->gobDestX = destX; + obj->gobDestY = destY; + animData->field_13 = destX; + animData->field_14 = destY; + + if ((animData->isBusy != 0) && (destX != -1) && (destY != -1)) { + if ((destX == -1) && (destY == -1)) { + mouseX = _vm->_global->_inter_mouseX; + mouseY = _vm->_global->_inter_mouseY; + if (_vm->_map->_bigTiles) + mouseY += ((_vm->_global->_inter_mouseX / _vm->_map->_tilesHeight) + 1) / 2; + obj->gobDestX = mouseX / _vm->_map->_tilesWidth; + obj->gobDestY = mouseY / _vm->_map->_tilesHeight; + gobDestX = obj->gobDestX; + gobDestY = obj->gobDestY; + if (_vm->_map->getPass(obj->gobDestX, obj->gobDestY) == 0) { + mapWidth = _vm->_map->_screenWidth / _vm->_map->_tilesWidth; + mapHeight = 200 / _vm->_map->_tilesHeight; + var_20 = 0; + di = -1; + si = -1; + + for (i = 1; i <= gobDestX; i++) + if (_vm->_map->getPass(gobDestX - i, gobDestY) != 0) + break; + if (i <= gobDestX) + di = ((i - 1) * _vm->_map->_tilesWidth) + (mouseX % _vm->_map->_tilesWidth) + 1; + var_1E = i; + + for (i = 1; (gobDestX + i) < mapWidth; i++) + if (_vm->_map->getPass(gobDestX + i, gobDestY) != 0) + break; + if ((gobDestX + i) < mapWidth) + si = (i * _vm->_map->_tilesWidth) - (mouseX % _vm->_map->_tilesWidth); + + if ((si != -1) && ((di == -1) || (di > si))) { + di = si; + var_20 = 1; + var_1E = i; + } + si = -1; + + for (i = 1; (gobDestY + i) < mapHeight; i++) + if (_vm->_map->getPass(gobDestX, gobDestY + i) != 0) + break; + if ((gobDestY + i) < mapHeight) + si = (i * _vm->_map->_tilesHeight) - (mouseY % _vm->_map->_tilesHeight); + + if ((si != -1) && ((di == -1) || (di > si))) { + di = si; + var_20 = 2; + var_1E = i; + } + si = -1; + + for (i = 1; i <= gobDestY; i++) + if (_vm->_map->getPass(gobDestX, gobDestY - i) != 0) + break; + if (i <= gobDestY) + si = ((i - 1) * _vm->_map->_tilesHeight) + (mouseY % _vm->_map->_tilesHeight) + 1; + + if ((si != -1) && ((di == -1) || (di > si))) { + var_20 = 3; + var_1E = i; + } + + if (var_20 == 0) + gobDestX -= var_1E; + else if (var_20 == 1) + gobDestX += var_1E; + else if (var_20 == 2) + gobDestY += var_1E; + else if (var_20 == 3) + gobDestY -= var_1E; + } + obj->gobDestX = gobDestX; + obj->gobDestY = gobDestY; + animData->field_13 = gobDestX; + animData->field_14 = gobDestY; + if (animData->field_13 == -1) { + animData->field_13 = obj->goblinX; + obj->gobDestX = obj->goblinX; + } + if (animData->field_14 == -1) { + animData->field_14 = obj->goblinY; + obj->gobDestY = obj->goblinY; + } + } + } + initiateMove(obj); +} + } // End of namespace Gob diff --git a/engines/gob/goblin.h b/engines/gob/goblin.h index 88c8254c4c..3e3c6d803e 100644 --- a/engines/gob/goblin.h +++ b/engines/gob/goblin.h @@ -220,6 +220,7 @@ public: void sub_19BD3(void); void sub_195C7(int16 index, int16 state); void sub_11984(Mult::Mult_Object *obj); + void sub_197A6(int16 destX, int16 destY, int16 objIndex); virtual void placeObject(Gob_Object * objDesc, char animated, int16 index, int16 x, int16 y, int16 state) = 0; diff --git a/engines/gob/init.cpp b/engines/gob/init.cpp index 299288878b..69e8f4f62b 100644 --- a/engines/gob/init.cpp +++ b/engines/gob/init.cpp @@ -205,6 +205,7 @@ memBlocks = word ptr -2*/ _vm->_global->_inter_variables = new char[varsCount * 4]; memset(_vm->_global->_inter_variables, 0, varsCount * 4); + WRITE_VAR(58, 1); strcpy(_vm->_game->_curTotFile, buffer); diff --git a/engines/gob/inter.h b/engines/gob/inter.h index a539173200..2680952507 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -314,6 +314,7 @@ protected: void o2_totSub(void); void o2_switchTotSub(void); void o2_stub0x54(void); + void o2_stub0x55(void); void o2_stub0x80(void); void o2_stub0x82(void); void o2_stub0x85(void); diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index 2c25322f38..c9067f39b9 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -1806,6 +1806,7 @@ bool Inter_v1::o1_call(char &cmdCount, int16 &counter, int16 &retFlag) { bool Inter_v1::o1_callBool(char &cmdCount, int16 &counter, int16 &retFlag) { byte cmd; bool boolRes = evalBoolResult() != 0; + if (boolRes != 0) { if (counter == cmdCount && retFlag == 2) diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index 608ffa4e05..23271de2fe 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -231,7 +231,7 @@ void Inter_v2::setupOpcodes(void) { OPCODE(o2_writeGoblinPos), /* 54 */ OPCODE(o2_stub0x54), - OPCODE(o2_drawStub), + OPCODE(o2_stub0x55), OPCODE(o2_placeGoblin), {NULL, ""}, /* 58 */ @@ -718,6 +718,97 @@ void Inter_v2::o2_stub0x54(void) { _vm->_mult->_objects[index].pAnimData->pathExistence = 4; } +void Inter_v2::o2_stub0x55(void) { + int16 index; + int16 state; + int16 f16; + int16 layer; + int16 animation; + int16 deltaX; + int16 deltaY; + int16 deltaHeight; + int16 deltaWidth; + Mult::Mult_Object *obj; + Mult::Mult_AnimData *objAnim; + + index = _vm->_parse->parseValExpr(); + state = _vm->_parse->parseValExpr(); + f16 = _vm->_parse->parseValExpr(); + + obj = &_vm->_mult->_objects[index]; + objAnim = obj->pAnimData; + + objAnim->field_16 = f16; + switch (f16) { + case 0: + if (obj->goblinStates[state] != 0) { + objAnim->frame = 0; + layer = obj->goblinStates[state][0].layer; + animation = obj->goblinStates[state][0].animation; + objAnim->state = state; + objAnim->layer = layer; + objAnim->animation = animation; + *obj->pPosX = _vm->_scenery->_animations[animation].layers[layer].posX; + *obj->pPosY = _vm->_scenery->_animations[animation].layers[layer].posY; + objAnim->isPaused = 0; + objAnim->isStatic = 0; + objAnim->newCycle = _vm->_scenery->_animations[animation].layers[layer].framesCount; + } + break; + + case 1: + case 4: + case 6: + if (obj->goblinStates[state] != 0) { + layer = obj->goblinStates[objAnim->state][0].layer; + animation = obj->goblinStates[objAnim->state][0].animation; + _vm->_scenery->updateAnim(layer, 0, animation, 0, *obj->pPosX, *obj->pPosY, 0); + deltaHeight = _vm->_scenery->_animBottom - _vm->_scenery->_animTop; + deltaWidth = _vm->_scenery->_animRight - _vm->_scenery->_animLeft; + deltaX = _vm->_scenery->_animations[objAnim->animation].layers[objAnim->layer].animDeltaX; + deltaY = _vm->_scenery->_animations[objAnim->animation].layers[objAnim->layer].animDeltaY; + layer = obj->goblinStates[state][0].layer; + animation = obj->goblinStates[state][0].animation; + objAnim->state = state; + objAnim->layer = layer; + objAnim->animation = animation; + objAnim->frame = 0; + objAnim->isPaused = 0; + objAnim->isStatic = 0; + objAnim->newCycle = _vm->_scenery->_animations[animation].layers[layer].framesCount; + _vm->_scenery->updateAnim(layer, 0, animation, 0, *obj->pPosX, *obj->pPosY, 0); + deltaHeight -= _vm->_scenery->_animBottom - _vm->_scenery->_animTop; + deltaWidth -= _vm->_scenery->_animRight - _vm->_scenery->_animLeft; + *obj->pPosX += deltaWidth + deltaX; + *obj->pPosY += deltaHeight + deltaY; + } + break; + + case 11: + if (obj->goblinStates[state] != 0) { + layer = obj->goblinStates[state][0].layer; + animation = obj->goblinStates[state][0].animation; + objAnim->state = state; + objAnim->layer = layer; + objAnim->animation = animation; + objAnim->frame = 0; + objAnim->isPaused = 0; + objAnim->isStatic = 0; + objAnim->newCycle = _vm->_scenery->_animations[animation].layers[layer].framesCount; + _vm->_scenery->updateAnim(layer, 0, animation, 0, *obj->pPosX, *obj->pPosY, 0); + if (_vm->_map->_bigTiles) + *obj->pPosY = ((obj->goblinY + 1) * _vm->_map->_tilesHeight) - + (_vm->_scenery->_animBottom - _vm->_scenery->_animTop) - + ((obj->goblinY + 1) / 2); + else + *obj->pPosY = ((obj->goblinY + 1) * _vm->_map->_tilesHeight) - + (_vm->_scenery->_animBottom - _vm->_scenery->_animTop); + *obj->pPosX = obj->goblinX * _vm->_map->_tilesWidth; + } + break; + } +} + void Inter_v2::o2_stub0x80(void) { int16 start; int16 videoMode; @@ -1276,7 +1367,7 @@ bool Inter_v2::o2_playSound(char &cmdCount, int16 &counter, int16 &retFlag) { } // loc_E2F3 if (_vm->_game->_soundTypes[index] & 8) { - _vm->_music->loadFromMemory((byte *) _vm->_game->_soundSamples[index]); + _vm->_music->loadFromMemory((byte *) _vm->_game->_soundSamples[index], index); _vm->_music->setRepeating(repCount - 1); _vm->_music->startPlay(); } else { @@ -1635,6 +1726,8 @@ void Inter_v2::o2_initMult(void) { for (i = 0; i < _vm->_mult->_objCount; i++) { _vm->_mult->_objects[i].pPosX = (int32 *)(_vm->_global->_inter_variables + i * 4 + (posXVar / 4) * 4); _vm->_mult->_objects[i].pPosY = (int32 *)(_vm->_global->_inter_variables + i * 4 + (posYVar / 4) * 4); + if ((i == 0) || (i == 1)) + warning("=> Goblin %d: %d (%d) (%d)", i, animDataVar + i * 4 * _vm->_global->_inter_animDataSize, (animDataVar + i * 4 * _vm->_global->_inter_animDataSize) / 4, _vm->_global->_inter_animDataSize); _vm->_mult->_objects[i].pAnimData = (Mult::Mult_AnimData *) (_vm->_global->_inter_variables + animDataVar + i * 4 * _vm->_global->_inter_animDataSize); diff --git a/engines/gob/map_v2.cpp b/engines/gob/map_v2.cpp index 561f13a8d1..ac94b39b39 100644 --- a/engines/gob/map_v2.cpp +++ b/engines/gob/map_v2.cpp @@ -117,11 +117,9 @@ void Map_v2::loadMapObjects(char *avjFile) { _passMap = (int8 *) variables; mapHeight = 200 / _tilesHeight; mapWidth = _screenWidth / _tilesWidth; - for (i = 0; i < mapHeight; i++) { - for (j = 0; j < mapWidth; j++) { + for (i = 0; i < mapHeight; i++) + for (j = 0; j < mapWidth; j++) setPass(j, i, mapData.readSByte()); - } - } } mapData.seek(dataPos1); diff --git a/engines/gob/mult.h b/engines/gob/mult.h index 8776bf444c..c6602b89a6 100644 --- a/engines/gob/mult.h +++ b/engines/gob/mult.h @@ -84,11 +84,7 @@ public: int16 lastRight; int16 lastTop; int16 lastBottom; - int8 someFlag; // New in GOB2 - int16 somethingLeft; // New in GOB2 - int16 somethingTop; // New in GOB2 - int16 somethingRight; // New in GOB2 - int16 somethingBottom; // New in GOB2 + Mult::Mult_GobState **goblinStates; // New in GOB2 int8 goblinX; // New in GOB2 int8 goblinY; // New in GOB2 int8 destX; // New in GOB2 @@ -97,7 +93,16 @@ public: int8 gobDestY; // New in GOB2 int8 nearestWayPoint; // New in GOB2 int8 nearestDest; // New in GOB2 - Mult::Mult_GobState **goblinStates; // New in GOB2 + int8 field_22; // New in GOB2 + int8 someFlag; // New in GOB2 + int8 field_24; // New in GOB2 + int8 field_25; // New in GOB2 + int8 field_26; // New in GOB2 + int8 field_27; // New in GOB2 + int16 somethingLeft; // New in GOB2 + int16 somethingTop; // New in GOB2 + int16 somethingRight; // New in GOB2 + int16 somethingBottom; // New in GOB2 }; struct Mult_StaticKey { diff --git a/engines/gob/mult_v2.cpp b/engines/gob/mult_v2.cpp index b73ed50eb6..14d14f3077 100644 --- a/engines/gob/mult_v2.cpp +++ b/engines/gob/mult_v2.cpp @@ -327,9 +327,9 @@ void Mult_v2::multSub(uint16 multindex) { } _multData2->field_124[index][0] = flags; - for (i = 1; i < 4; i++) { + for (i = 1; i < 4; i++) _multData2->field_124[index][i] = _vm->_parse->parseValExpr(); - } + expr = _vm->_parse->parseValExpr(); _multData2->animKeysFrames[index] = expr; _multData2->animKeysStartFrames[index] = expr; @@ -473,7 +473,7 @@ void Mult_v2::playMult(int16 startFrame, int16 endFrame, char checkEscape, _vm->_draw->adjustCoords(0, &_vm->_anim->_areaWidth, &_vm->_anim->_areaHeight); - if ((_vm->_global->_videoMode == 0x14) && + if ((_vm->_global->_videoMode == 0x13) && _vm->_video->_extraMode && ((_vm->_draw->_backSurface->width * _vm->_draw->_backSurface->height) / 2 + (_vm->_anim->_areaWidth * _vm->_anim->_areaHeight) / 4) < 64000) { _vm->_anim->_animSurf = new Video::SurfaceDesc; diff --git a/engines/gob/music.cpp b/engines/gob/music.cpp index 782e07bd04..56bbcb0313 100644 --- a/engines/gob/music.cpp +++ b/engines/gob/music.cpp @@ -76,6 +76,7 @@ const unsigned char Music::_volRegNums[] = { Music::Music(GobEngine *vm) : _vm(vm) { int i; + _index = -1; _data = 0; _playPos = 0; _dataSize = 0; @@ -365,6 +366,9 @@ void Music::pollMusic(void) { _pollNotes[channel] = note; setKey(channel, note, true, false); break; + case 0x60: + warning("GOB2 Stub! ADL command 0x60"); + break; // Last note off case 0x80: note = _pollNotes[channel]; @@ -452,6 +456,7 @@ void Music::playTrack(const char *trackname) { bool Music::loadMusic(const char *filename) { Common::File song; + unloadMusic(); song.open(filename); if (!song.isOpen()) return false; @@ -469,12 +474,13 @@ bool Music::loadMusic(const char *filename) { return true; } -void Music::loadFromMemory(byte *data) { +void Music::loadFromMemory(byte *data, int index) { unloadMusic(); _repCount = 0; _dataSize = (uint32) -1; _data = data; + _index = index; reset(); setVoices(); @@ -483,6 +489,7 @@ void Music::loadFromMemory(byte *data) { void Music::unloadMusic(void) { _playing = false; + _index = -1; if (_data && _needFree) delete[] _data; diff --git a/engines/gob/music.h b/engines/gob/music.h index 2f792f67ac..4752dc3e1d 100644 --- a/engines/gob/music.h +++ b/engines/gob/music.h @@ -45,12 +45,13 @@ public: bool playing() { return _playing; } bool getRepeating(void) { return _repCount != 0; } void setRepeating (int32 repCount) { _repCount = repCount; } + int getIndex(void) { return _index; } virtual void startPlay(void); virtual void stopPlay(void) { _mutex.lock(); _playing = false; _mutex.unlock(); } virtual void playTrack(const char *trackname); virtual void playBgMusic(void); virtual bool loadMusic(const char *filename); - virtual void loadFromMemory(byte *data); + virtual void loadFromMemory(byte *data, int index=-1); virtual void unloadMusic(void); // AudioStream API @@ -68,6 +69,7 @@ protected: static const unsigned char _operators[]; static const unsigned char _volRegNums []; FM_OPL *_opl; + int _index; byte *_data; byte *_playPos; uint32 _dataSize; diff --git a/engines/gob/parse_v2.cpp b/engines/gob/parse_v2.cpp index 982b6d09a2..d56d390ffc 100644 --- a/engines/gob/parse_v2.cpp +++ b/engines/gob/parse_v2.cpp @@ -148,24 +148,24 @@ int16 Parse_v2::parseValExpr(unsigned stopToken) { offset = arrDesc[dim] * offset + temp2; } if (operation == 16) - *valPtr = *(_vm->_global->_inter_variables + temp + offset); + *valPtr = *(int8 *)(_vm->_global->_inter_variables + temp + offset); else if (operation == 26) - *valPtr = *(uint16*)(_vm->_global->_inter_variables + temp * 4 + offset * 4); + *valPtr = *(uint16 *)(_vm->_global->_inter_variables + temp * 4 + offset * 4); else if (operation == 27) - *valPtr = *(uint16*)(_vm->_global->_inter_variables + temp * 2 + offset * 2); + *valPtr = *(uint16 *)(_vm->_global->_inter_variables + temp * 2 + offset * 2); else if (operation == 28) { _vm->_global->_inter_execPtr++; temp2 = parseValExpr(12); - *valPtr = (uint8)*(_vm->_global->_inter_variables + temp * 4 + offset * 4 * _vm->_global->_inter_animDataSize + temp2); + *valPtr = *(uint8 *)(_vm->_global->_inter_variables + temp * 4 + offset * 4 * _vm->_global->_inter_animDataSize + temp2); } break; case 17: - *valPtr = *(uint16*)(_vm->_global->_inter_variables + _vm->_inter->load16() * 2); + *valPtr = *(uint16 *)(_vm->_global->_inter_variables + _vm->_inter->load16() * 2); break; case 18: - *valPtr = *(_vm->_global->_inter_variables + _vm->_inter->load16()); + *valPtr = *(int8 *)(_vm->_global->_inter_variables + _vm->_inter->load16()); break; case 19: @@ -183,14 +183,14 @@ int16 Parse_v2::parseValExpr(unsigned stopToken) { case 23: case 24: - *valPtr = VAR(_vm->_inter->load16()); + *valPtr = *(uint16 *)(_vm->_global->_inter_variables + _vm->_inter->load16() * 4); break; case 25: temp = _vm->_inter->load16() * 4; _vm->_global->_inter_execPtr++; temp += parseValExpr(12); - *valPtr = *(_vm->_global->_inter_variables + temp); + *valPtr = *(uint8 *)(_vm->_global->_inter_variables + temp); break; case 29: @@ -257,7 +257,7 @@ int16 Parse_v2::parseValExpr(unsigned stopToken) { operPtr[-1] = operPtr[0]; valPtr[-1] = valPtr[0]; if (stkPos > 1 && operPtr[-2] == 1) { - valPtr[-2] = 20; + operPtr[-2] = 20; valPtr[-2] = -valPtr[-1]; stkPos--; @@ -265,26 +265,25 @@ int16 Parse_v2::parseValExpr(unsigned stopToken) { valPtr--; } - if (stkPos > 2 && operPtr[-2] > 4 - && operPtr[-2] < 9) { + if (stkPos > 2 && operPtr[-2] > 4 && operPtr[-2] < 9) { stkPos -= 2; operPtr -= 2; valPtr -= 2; switch (operPtr[0]) { case 5: - operPtr[-1] *= operPtr[1]; + valPtr[-1] *= valPtr[1]; break; case 6: - operPtr[-1] /= operPtr[1]; + valPtr[-1] /= valPtr[1]; break; case 7: - operPtr[-1] %= operPtr[1]; + valPtr[-1] %= valPtr[1]; break; case 8: - operPtr[-1] &= operPtr[1]; + valPtr[-1] &= valPtr[1]; break; } } @@ -352,7 +351,7 @@ int16 Parse_v2::parseExpr(char stopToken, byte *arg_2) { int32 prevVal; int32 curVal; int32 *valPtr; - char *operPtr; + byte *operPtr; byte *arrDescPtr; char var_C; byte operation; @@ -368,7 +367,7 @@ int16 Parse_v2::parseExpr(char stopToken, byte *arg_2) { memset(operStack, 0, 20); stkPos = -1; - operPtr = (char *)(operStack - 1); + operPtr = operStack - 1; valPtr = values - 1; while (1) { @@ -376,7 +375,7 @@ int16 Parse_v2::parseExpr(char stopToken, byte *arg_2) { operPtr++; valPtr++; operation = *_vm->_global->_inter_execPtr++; - if (operation >= 19 && operation <= 29) { + if (operation >= 16 && operation <= 29) { switch (operation) { case 16: case 26: @@ -396,30 +395,30 @@ int16 Parse_v2::parseExpr(char stopToken, byte *arg_2) { offset = offset * arrDescPtr[dim] + temp2; } if (operation == 16) - *valPtr = *(_vm->_global->_inter_variables + temp + offset); + *valPtr = *(int8 *)(_vm->_global->_inter_variables + temp + offset); else if (operation == 26) - *valPtr = *(uint32*)(_vm->_global->_inter_variables + temp * 4 + offset * 4); + *valPtr = *(uint32 *)(_vm->_global->_inter_variables + temp * 4 + offset * 4); else if (operation == 27) - *valPtr = *(uint16*)(_vm->_global->_inter_variables + temp * 2 + offset * 2); + *valPtr = *(int16 *)(_vm->_global->_inter_variables + temp * 2 + offset * 2); else if (operation == 28) { *valPtr = encodePtr(_vm->_global->_inter_variables + temp * 4 + offset * _vm->_global->_inter_animDataSize * 4, kInterVar); if (*_vm->_global->_inter_execPtr == 13) { _vm->_global->_inter_execPtr++; temp2 = parseValExpr(12); *operPtr = 20; - *valPtr = (uint8)*(_vm->_global->_inter_variables + temp * 4 + offset * 4 * _vm->_global->_inter_animDataSize + temp2); + *valPtr = *(uint8 *)(_vm->_global->_inter_variables + temp * 4 + offset * 4 * _vm->_global->_inter_animDataSize + temp2); } } break; case 17: *operPtr = 20; - *valPtr = *(uint16*)(_vm->_global->_inter_variables + _vm->_inter->load16() * 2); + *valPtr = *(int16 *)(_vm->_global->_inter_variables + _vm->_inter->load16() * 2); break; case 18: *operPtr = 20; - *valPtr = *(_vm->_global->_inter_variables + _vm->_inter->load16()); + *valPtr = *(int8 *)(_vm->_global->_inter_variables + _vm->_inter->load16()); break; case 19: @@ -445,11 +444,15 @@ int16 Parse_v2::parseExpr(char stopToken, byte *arg_2) { break; case 23: - case 24: *operPtr = 20; *valPtr = VAR(_vm->_inter->load16()); break; + case 24: + *operPtr = 20; + *valPtr = *(int16 *)(_vm->_global->_inter_variables + _vm->_inter->load16() * 4); + break; + case 25: *operPtr = 22; temp = _vm->_inter->load16() * 4; @@ -458,7 +461,7 @@ int16 Parse_v2::parseExpr(char stopToken, byte *arg_2) { _vm->_global->_inter_execPtr++; temp += parseValExpr(12); *operPtr = 20; - *valPtr = (uint8)*(_vm->_global->_inter_variables + temp); + *valPtr = *(uint8 *)(_vm->_global->_inter_variables + temp); } break; @@ -560,7 +563,7 @@ int16 Parse_v2::parseExpr(char stopToken, byte *arg_2) { break; } continue; - } // op>= 19 && op <= 29 + } // op >= 16 && op <= 29 if (operation == stopToken || operation == 30 || operation == 31 || operation == 10) { while (stkPos >= 2) { |