diff options
author | Johannes Schickel | 2008-05-02 15:39:51 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-05-02 15:39:51 +0000 |
commit | 5e4fceec2eb837257386f790d920eadf483da3cf (patch) | |
tree | 38f440c89b59dca258225d64c78b86e11c4954a9 /engines | |
parent | c6830b4138be54e056a7cf18b6b900c3e46ab4ff (diff) | |
download | scummvm-rg350-5e4fceec2eb837257386f790d920eadf483da3cf.tar.gz scummvm-rg350-5e4fceec2eb837257386f790d920eadf483da3cf.tar.bz2 scummvm-rg350-5e4fceec2eb837257386f790d920eadf483da3cf.zip |
Moved some character code from kyra2/kyra3 to KyraEngine_v2.
svn-id: r31822
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/animator_hof.cpp | 8 | ||||
-rw-r--r-- | engines/kyra/kyra_hof.cpp | 65 | ||||
-rw-r--r-- | engines/kyra/kyra_mr.cpp | 54 | ||||
-rw-r--r-- | engines/kyra/kyra_mr.h | 30 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.cpp | 54 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.h | 29 | ||||
-rw-r--r-- | engines/kyra/saveload.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/saveload_hof.cpp | 12 | ||||
-rw-r--r-- | engines/kyra/scene_hof.cpp | 6 | ||||
-rw-r--r-- | engines/kyra/staticres.cpp | 46 |
10 files changed, 130 insertions, 176 deletions
diff --git a/engines/kyra/animator_hof.cpp b/engines/kyra/animator_hof.cpp index 4667f11498..0d234e8987 100644 --- a/engines/kyra/animator_hof.cpp +++ b/engines/kyra/animator_hof.cpp @@ -216,10 +216,10 @@ void KyraEngine_HoF::updateCharacterAnim(int) { int xAdd = _shapeDescTable[c->animFrame-9].xAdd; int yAdd = _shapeDescTable[c->animFrame-9].yAdd; - _charScaleX = _charScaleY = getScale(c->x1, c->y1); + _charScale = getScale(c->x1, c->y1); - animState->xPos2 += (xAdd * _charScaleX) >> 8; - animState->yPos2 += (yAdd * _charScaleY) >> 8; + animState->xPos2 += (xAdd * _charScale) >> 8; + animState->yPos2 += (yAdd * _charScale) >> 8; animState->width2 = 8; animState->height2 = 10; @@ -315,7 +315,7 @@ void KyraEngine_HoF::drawCharacterAnimObject(AnimObj *obj, int x, int y, int lay debugC(9, kDebugLevelAnimator, "KyraEngine_HoF::drawCharacterAnimObject(%p, %d, %d, %d)", (const void*)obj, x, y, layer); if (_drawNoShapeFlag || obj->shapeIndex1 == 0xFFFF) return; - _screen->drawShape(2, getShapePtr(obj->shapeIndex1), x, y, 2, obj->flags | 4, layer, _charScaleX, _charScaleY); + _screen->drawShape(2, getShapePtr(obj->shapeIndex1), x, y, 2, obj->flags | 4, layer, _charScale, _charScale); } void KyraEngine_HoF::addItemToAnimList(int item) { diff --git a/engines/kyra/kyra_hof.cpp b/engines/kyra/kyra_hof.cpp index 6b6a62ea55..c9c30c52d4 100644 --- a/engines/kyra/kyra_hof.cpp +++ b/engines/kyra/kyra_hof.cpp @@ -514,7 +514,7 @@ void KyraEngine_HoF::handleInput(int x, int y) { } } - if (checkCharCollision(x, y) >= 0 && _unk3 >= -1) { + if (checkCharCollision(x, y) && _unk3 >= -1) { runSceneScript2(); return; } else if (pickUpItem(x, y)) { @@ -543,7 +543,7 @@ void KyraEngine_HoF::handleInput(int x, int y) { if (skipHandling) return; - if (checkCharCollision(x, y) >= 0) { + if (checkCharCollision(x, y)) { runSceneScript2(); return; } @@ -1397,59 +1397,8 @@ int KyraEngine_HoF::inputSceneChange(int x, int y, int unk1, int unk2) { return refreshNPC; } -void KyraEngine_HoF::moveCharacter(int facing, int x, int y) { - _mainCharacter.facing = facing; - x &= ~3; - y &= ~1; - - _screen->hideMouse(); - switch (facing) { - case 0: - while (y < _mainCharacter.y1) - updateCharPosWithUpdate(); - break; - - case 2: - while (_mainCharacter.x1 < x) - updateCharPosWithUpdate(); - break; - - case 4: - while (y > _mainCharacter.y1) - updateCharPosWithUpdate(); - break; - - case 6: - while (_mainCharacter.x1 > x) - updateCharPosWithUpdate(); - break; - - default: - break; - } - - _screen->showMouse(); -} - -int KyraEngine_HoF::updateCharPos(int *table) { - static uint32 nextUpdate = 0; - static const int updateX[] = { 0, 4, 4, 4, 0, -4, -4, -4 }; - static const int updateY[] = { -2, -2, 0, 2, 2, 2, 0, -2 }; - - if (_system->getMillis() < nextUpdate) - return 0; - - int facing = _mainCharacter.facing; - _mainCharacter.x1 += updateX[facing]; - _mainCharacter.y1 += updateY[facing]; - updateCharAnimFrame(0, table); - nextUpdate = _system->getMillis() + _timer->getDelay(0) * _tickLength; - return 1; -} - -void KyraEngine_HoF::updateCharPosWithUpdate() { - updateCharPos(0); - update(); +int KyraEngine_HoF::getCharacterWalkspeed() const { + return _timer->getDelay(0); } void KyraEngine_HoF::updateCharAnimFrame(int charId, int *table) { @@ -1517,7 +1466,7 @@ void KyraEngine_HoF::updateCharAnimFrame(int charId, int *table) { updateCharacterAnim(charId); } -int KyraEngine_HoF::checkCharCollision(int x, int y) { +bool KyraEngine_HoF::checkCharCollision(int x, int y) { int scale1 = 0, scale2 = 0, scale3 = 0; int x1 = 0, x2 = 0, y1 = 0, y2 = 0; scale1 = getScale(_mainCharacter.x1, _mainCharacter.y1); @@ -1530,9 +1479,9 @@ int KyraEngine_HoF::checkCharCollision(int x, int y) { y2 = _mainCharacter.y1; if (x >= x1 && x <= x2 && y >= y1 && y <= y2) - return 0; + return true; - return -1; + return false; } int KyraEngine_HoF::initNewShapes(uint8 *filedata) { diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp index 4548067b6d..864d741847 100644 --- a/engines/kyra/kyra_mr.cpp +++ b/engines/kyra/kyra_mr.cpp @@ -71,7 +71,6 @@ KyraEngine_MR::KyraEngine_MR(OSystem *system, const GameFlags &flags) : KyraEngi _inventoryState = false; memset(&_sceneScriptState, 0, sizeof(_sceneScriptState)); memset(&_sceneScriptData, 0, sizeof(_sceneScriptData)); - _updateCharPosNextUpdate = 0; memset(_characterAnimTable, 0, sizeof(_characterAnimTable)); _overwriteSceneFacing = false; _maskPageMinY = _maskPageMaxY = 0; @@ -586,7 +585,6 @@ void KyraEngine_MR::startup() { _talkObjectList[i].sceneId = 0xFF; musicUpdate(0); - updateMalcolmShapes(); _gfxBackUpRect = new uint8[_screen->getRectSize(32, 32)]; initItemList(50); resetItemList(); @@ -598,6 +596,7 @@ void KyraEngine_MR::startup() { musicUpdate(0); _characterShapeFile = 0; loadCharacterShapes(_characterShapeFile); + updateMalcolmShapes(); musicUpdate(0); initMainButtonList(true); loadInterfaceShapes(); @@ -803,55 +802,8 @@ void KyraEngine_MR::updateMalcolmShapes() { #pragma mark - -void KyraEngine_MR::moveCharacter(int facing, int x, int y) { - debugC(9, kDebugLevelMain, "KyraEngine_MR::moveCharacter(%d, %d, %d)", facing, x, y); - x &= ~3; - y &= ~1; - _mainCharacter.facing = facing; - - _screen->hideMouse(); - switch (facing) { - case 0: - while (_mainCharacter.y1 > y) - updateCharPosWithUpdate(); - break; - - case 2: - while (_mainCharacter.x1 < x) - updateCharPosWithUpdate(); - break; - - case 4: - while (_mainCharacter.y1 < y) - updateCharPosWithUpdate(); - break; - - case 6: - while (_mainCharacter.x1 > x) - updateCharPosWithUpdate(); - break; - - default: - break; - } - _screen->showMouse(); -} - -void KyraEngine_MR::updateCharPosWithUpdate() { - debugC(9, kDebugLevelMain, "KyraEngine_MR::updateCharPosWithUpdate()"); - updateCharPos(0, 0); - update(); -} - -int KyraEngine_MR::updateCharPos(int *table, int force) { - debugC(9, kDebugLevelMain, "KyraEngine_MR::updateCharPos(%p, %d)", (const void*)table, force); - if (_updateCharPosNextUpdate > _system->getMillis() && !force) - return 0; - _mainCharacter.x1 += _updateCharPosXTable[_mainCharacter.facing]; - _mainCharacter.y1 += _updateCharPosYTable[_mainCharacter.facing]; - updateCharAnimFrame(0, table); - _updateCharPosNextUpdate = _system->getMillis() + _mainCharacter.walkspeed * _tickLength; - return 1; +int KyraEngine_MR::getCharacterWalkspeed() const { + return _mainCharacter.walkspeed; } void KyraEngine_MR::updateCharAnimFrame(int character, int *table) { diff --git a/engines/kyra/kyra_mr.h b/engines/kyra/kyra_mr.h index 20f8349008..542e4de78e 100644 --- a/engines/kyra/kyra_mr.h +++ b/engines/kyra/kyra_mr.h @@ -370,39 +370,11 @@ private: bool _unkSceneScreenFlag1; // character - struct Character { - uint16 sceneId; - uint16 dlgIndex; - uint8 height; - uint8 facing; - uint16 animFrame; - //uint8 unk8, unk9; - byte walkspeed; - uint16 inventory[10]; - int16 x1, y1; - int16 x2, y2; - int16 x3, y3; - }; - - Character _mainCharacter; - int _mainCharX, _mainCharY; - int _charScale; - - void moveCharacter(int facing, int x, int y); - - void updateCharPosWithUpdate(); - int updateCharPos(int *table, int force); - - uint32 _updateCharPosNextUpdate; - static const int8 _updateCharPosXTable[]; - static const int8 _updateCharPosYTable[]; - + int getCharacterWalkspeed() const; void updateCharAnimFrame(int character, int *table); int8 _characterAnimTable[2]; static const uint8 _characterFrameTable[]; - bool _overwriteSceneFacing; - void updateCharPal(int unk1); int _lastCharPalLayer; bool _charPalUpdate; diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index ac8ae55bea..b8ede4f50b 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -39,6 +39,8 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi _itemListSize = 0; _characterShapeFile = -1; + + _updateCharPosNextUpdate = 0; } KyraEngine_v2::~KyraEngine_v2() { @@ -146,5 +148,57 @@ uint8 *KyraEngine_v2::getShapePtr(int shape) const { return iter->_value; } +void KyraEngine_v2::moveCharacter(int facing, int x, int y) { + debugC(9, kDebugLevelMain, "KyraEngine_v2::moveCharacter(%d, %d, %d)", facing, x, y); + x &= ~3; + y &= ~1; + _mainCharacter.facing = facing; + + Screen *scr = screen(); + scr->hideMouse(); + switch (facing) { + case 0: + while (_mainCharacter.y1 > y) + updateCharPosWithUpdate(); + break; + + case 2: + while (_mainCharacter.x1 < x) + updateCharPosWithUpdate(); + break; + + case 4: + while (_mainCharacter.y1 < y) + updateCharPosWithUpdate(); + break; + + case 6: + while (_mainCharacter.x1 > x) + updateCharPosWithUpdate(); + break; + + default: + break; + } + scr->showMouse(); +} + +void KyraEngine_v2::updateCharPosWithUpdate() { + debugC(9, kDebugLevelMain, "KyraEngine_v2::updateCharPosWithUpdate()"); + updateCharPos(0, 0); + update(); +} + +int KyraEngine_v2::updateCharPos(int *table, int force) { + debugC(9, kDebugLevelMain, "KyraEngine_v2::updateCharPos(%p, %d)", (const void*)table, force); + if (_updateCharPosNextUpdate > _system->getMillis() && !force) + return 0; + _mainCharacter.x1 += _updateCharPosXTable[_mainCharacter.facing]; + _mainCharacter.y1 += _updateCharPosYTable[_mainCharacter.facing]; + updateCharAnimFrame(0, table); + _updateCharPosNextUpdate = _system->getMillis() + getCharacterWalkspeed() * _tickLength; + return 1; +} + } // end of namespace Kyra diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h index e15d0a7acd..c5be20e363 100644 --- a/engines/kyra/kyra_v2.h +++ b/engines/kyra/kyra_v2.h @@ -238,6 +238,35 @@ protected: void setHandItem(uint16 item); void removeHandItem(); + + // character + struct Character { + uint16 sceneId; + uint16 dlgIndex; + uint8 height; + uint8 facing; + uint16 animFrame; + byte walkspeed; + uint16 inventory[20]; + int16 x1, y1; + int16 x2, y2; + int16 x3, y3; + }; + + Character _mainCharacter; + int _mainCharX, _mainCharY; + int _charScale; + + void moveCharacter(int facing, int x, int y); + int updateCharPos(int *table, int force = 0); + void updateCharPosWithUpdate(); + + uint32 _updateCharPosNextUpdate; + static const int8 _updateCharPosXTable[]; + static const int8 _updateCharPosYTable[]; + + virtual int getCharacterWalkspeed() const = 0; + virtual void updateCharAnimFrame(int num, int *table) = 0; }; } // end of namespace Kyra diff --git a/engines/kyra/saveload.cpp b/engines/kyra/saveload.cpp index 3b78ce579c..fa3266685f 100644 --- a/engines/kyra/saveload.cpp +++ b/engines/kyra/saveload.cpp @@ -29,7 +29,7 @@ #include "kyra/kyra.h" -#define CURRENT_SAVE_VERSION 10 +#define CURRENT_SAVE_VERSION 11 #define GF_FLOPPY (1 << 0) #define GF_TALKIE (1 << 1) diff --git a/engines/kyra/saveload_hof.cpp b/engines/kyra/saveload_hof.cpp index 34bafe5d3c..283e40acaa 100644 --- a/engines/kyra/saveload_hof.cpp +++ b/engines/kyra/saveload_hof.cpp @@ -77,9 +77,6 @@ void KyraEngine_HoF::saveGame(const char *fileName, const char *saveName) { out->writeByte(_mainCharacter.height); out->writeByte(_mainCharacter.facing); out->writeUint16BE(_mainCharacter.animFrame); - out->writeByte(_mainCharacter.unk8); - out->writeByte(_mainCharacter.unk9); - out->writeByte(_mainCharacter.unkA); for (int i = 0; i < 20; ++i) out->writeUint16BE(_mainCharacter.inventory[i]); out->writeSint16BE(_mainCharacter.x1); @@ -212,9 +209,10 @@ void KyraEngine_HoF::loadGame(const char *fileName) { _mainCharacter.height = in.readByte(); _mainCharacter.facing = in.readByte(); _mainCharacter.animFrame = in.readUint16(); - _mainCharacter.unk8 = in.readByte(); - _mainCharacter.unk9 = in.readByte(); - _mainCharacter.unkA = in.readByte(); + + if (header.version <= 10 || header.originalSave) + in.seek(3, SEEK_CUR); + for (int i = 0; i < 20; ++i) _mainCharacter.inventory[i] = in.readUint16(); _mainCharacter.x1 = in.readSint16(); @@ -227,7 +225,7 @@ void KyraEngine_HoF::loadGame(const char *fileName) { _itemList[i].sceneId = in.readUint16(); _itemList[i].x = in.readSint16(); _itemList[i].y = in.readByte(); - if (header.version <= 9) + if (header.version <= 9 || header.originalSave) in.readUint16(); } diff --git a/engines/kyra/scene_hof.cpp b/engines/kyra/scene_hof.cpp index 216c453b4b..30f514262b 100644 --- a/engines/kyra/scene_hof.cpp +++ b/engines/kyra/scene_hof.cpp @@ -552,10 +552,10 @@ void KyraEngine_HoF::initSceneAnims(int unk1) { animState->xPos2 = _mainCharacter.x1; animState->yPos2 = _mainCharacter.y1; - _charScaleX = _charScaleY = getScale(_mainCharacter.x1, _mainCharacter.y1); + _charScale = getScale(_mainCharacter.x1, _mainCharacter.y1); - int shapeXScaled = (shapeX * _charScaleX) >> 8; - int shapeYScaled = (shapeY * _charScaleY) >> 8; + int shapeXScaled = (shapeX * _charScale) >> 8; + int shapeYScaled = (shapeY * _charScale) >> 8; animState->xPos2 += shapeXScaled; animState->yPos2 += shapeYScaled; diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index 6f9d005288..9c9ced2387 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -1508,22 +1508,14 @@ const int8 KyraEngine_v1::_dosTrackMap[] = { const int KyraEngine_v1::_dosTrackMapSize = ARRAYSIZE(KyraEngine_v1::_dosTrackMap); -// Kyra 2 and 3 main menu +// kyra engine v2 static data -const char *KyraEngine_MR::_mainMenuStrings[] = { - "Start a new game", - "Introduction", - "Load a game", - "Exit the game", - "Nouvelle Partie", - "Introduction", - "Charger une partie", - "Quitter le jeu", - "Neues Spiel starten", - "Intro", - "Spielstand laden", - "Spiel beenden", - 0 +const int8 KyraEngine_v2::_updateCharPosXTable[] = { + 0, 4, 4, 4, 0, -4, -4, -4 +}; + +const int8 KyraEngine_v2::_updateCharPosYTable[] = { + -2, -2, 0, 2, 2, 2, 0, -2 }; // kyra 2 static res @@ -1940,6 +1932,22 @@ const uint8 KyraEngine_HoF::_rainbowRoomData[] = { // kyra 3 static res +const char *KyraEngine_MR::_mainMenuStrings[] = { + "Start a new game", + "Introduction", + "Load a game", + "Exit the game", + "Nouvelle Partie", + "Introduction", + "Charger une partie", + "Quitter le jeu", + "Neues Spiel starten", + "Intro", + "Spielstand laden", + "Spiel beenden", + 0 +}; + const char *KyraEngine_MR::_soundList[] = { "ARREST1.AUD", "BATH1.AUD", @@ -2014,14 +2022,6 @@ const KyraEngine_MR::ShapeDesc KyraEngine_MR::_shapeDescs[] = { const int KyraEngine_MR::_shapeDescsSize = ARRAYSIZE(KyraEngine_MR::_shapeDescs); -const int8 KyraEngine_MR::_updateCharPosXTable[] = { - 0, 4, 4, 4, 0, -4, -4, -4 -}; - -const int8 KyraEngine_MR::_updateCharPosYTable[] = { - -2, -2, 0, 2, 2, 2, 0, -2 -}; - const uint8 KyraEngine_MR::_characterFrameTable[] = { 0x36, 0x35, 0x35, 0x33, 0x32, 0x32, 0x34, 0x34 }; |