[Scummvm-cvs-logs] SF.net SVN: scummvm: [31822] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Fri May 2 17:39:52 CEST 2008


Revision: 31822
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31822&view=rev
Author:   lordhoto
Date:     2008-05-02 08:39:51 -0700 (Fri, 02 May 2008)

Log Message:
-----------
Moved some character code from kyra2/kyra3 to KyraEngine_v2.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/animator_hof.cpp
    scummvm/trunk/engines/kyra/kyra_hof.cpp
    scummvm/trunk/engines/kyra/kyra_mr.cpp
    scummvm/trunk/engines/kyra/kyra_mr.h
    scummvm/trunk/engines/kyra/kyra_v2.cpp
    scummvm/trunk/engines/kyra/kyra_v2.h
    scummvm/trunk/engines/kyra/saveload.cpp
    scummvm/trunk/engines/kyra/saveload_hof.cpp
    scummvm/trunk/engines/kyra/scene_hof.cpp
    scummvm/trunk/engines/kyra/staticres.cpp

Modified: scummvm/trunk/engines/kyra/animator_hof.cpp
===================================================================
--- scummvm/trunk/engines/kyra/animator_hof.cpp	2008-05-02 15:21:51 UTC (rev 31821)
+++ scummvm/trunk/engines/kyra/animator_hof.cpp	2008-05-02 15:39:51 UTC (rev 31822)
@@ -216,10 +216,10 @@
 	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 @@
 	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) {

Modified: scummvm/trunk/engines/kyra/kyra_hof.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_hof.cpp	2008-05-02 15:21:51 UTC (rev 31821)
+++ scummvm/trunk/engines/kyra/kyra_hof.cpp	2008-05-02 15:39:51 UTC (rev 31822)
@@ -514,7 +514,7 @@
 		}
 	}
 
-	if (checkCharCollision(x, y) >= 0 && _unk3 >= -1) {
+	if (checkCharCollision(x, y) && _unk3 >= -1) {
 		runSceneScript2();
 		return;
 	} else if (pickUpItem(x, y)) {
@@ -543,7 +543,7 @@
 		if (skipHandling)
 			return;
 
-		if (checkCharCollision(x, y) >= 0) {
+		if (checkCharCollision(x, y)) {
 			runSceneScript2();
 			return;
 		}
@@ -1397,61 +1397,10 @@
 	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::getCharacterWalkspeed() const {
+	return _timer->getDelay(0);
 }
 
-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();
-}
-
 void KyraEngine_HoF::updateCharAnimFrame(int charId, int *table) {
 	static int unkTable1[] = { 0, 0 };
 	static const int unkTable2[] = { 17, 0 };
@@ -1517,7 +1466,7 @@
 	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 @@
 	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) {

Modified: scummvm/trunk/engines/kyra/kyra_mr.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_mr.cpp	2008-05-02 15:21:51 UTC (rev 31821)
+++ scummvm/trunk/engines/kyra/kyra_mr.cpp	2008-05-02 15:39:51 UTC (rev 31822)
@@ -71,7 +71,6 @@
 	_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 @@
 		_talkObjectList[i].sceneId = 0xFF;
 
 	musicUpdate(0);
-	updateMalcolmShapes();
 	_gfxBackUpRect = new uint8[_screen->getRectSize(32, 32)];
 	initItemList(50);
 	resetItemList();
@@ -598,6 +596,7 @@
 	musicUpdate(0);
 	_characterShapeFile = 0;
 	loadCharacterShapes(_characterShapeFile);
+	updateMalcolmShapes();
 	musicUpdate(0);
 	initMainButtonList(true);
 	loadInterfaceShapes();
@@ -803,57 +802,10 @@
 
 #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();
+int KyraEngine_MR::getCharacterWalkspeed() const {
+	return _mainCharacter.walkspeed;
 }
 
-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;
-}
-
 void KyraEngine_MR::updateCharAnimFrame(int character, int *table) {
 	debugC(9, kDebugLevelMain, "KyraEngine_MR::updateCharPos(%d, %p)", character, (const void*)table);
 	++_mainCharacter.animFrame;

Modified: scummvm/trunk/engines/kyra/kyra_mr.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_mr.h	2008-05-02 15:21:51 UTC (rev 31821)
+++ scummvm/trunk/engines/kyra/kyra_mr.h	2008-05-02 15:39:51 UTC (rev 31822)
@@ -370,39 +370,11 @@
 	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;

Modified: scummvm/trunk/engines/kyra/kyra_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.cpp	2008-05-02 15:21:51 UTC (rev 31821)
+++ scummvm/trunk/engines/kyra/kyra_v2.cpp	2008-05-02 15:39:51 UTC (rev 31822)
@@ -39,6 +39,8 @@
 	_itemListSize = 0;
 	
 	_characterShapeFile = -1;
+
+	_updateCharPosNextUpdate = 0;
 }
 
 KyraEngine_v2::~KyraEngine_v2() {
@@ -146,5 +148,57 @@
 	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
 

Modified: scummvm/trunk/engines/kyra/kyra_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.h	2008-05-02 15:21:51 UTC (rev 31821)
+++ scummvm/trunk/engines/kyra/kyra_v2.h	2008-05-02 15:39:51 UTC (rev 31822)
@@ -238,6 +238,35 @@
 
 	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

Modified: scummvm/trunk/engines/kyra/saveload.cpp
===================================================================
--- scummvm/trunk/engines/kyra/saveload.cpp	2008-05-02 15:21:51 UTC (rev 31821)
+++ scummvm/trunk/engines/kyra/saveload.cpp	2008-05-02 15:39:51 UTC (rev 31822)
@@ -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)

Modified: scummvm/trunk/engines/kyra/saveload_hof.cpp
===================================================================
--- scummvm/trunk/engines/kyra/saveload_hof.cpp	2008-05-02 15:21:51 UTC (rev 31821)
+++ scummvm/trunk/engines/kyra/saveload_hof.cpp	2008-05-02 15:39:51 UTC (rev 31822)
@@ -77,9 +77,6 @@
 	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 @@
 	_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 @@
 		_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();
 	}
 

Modified: scummvm/trunk/engines/kyra/scene_hof.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene_hof.cpp	2008-05-02 15:21:51 UTC (rev 31821)
+++ scummvm/trunk/engines/kyra/scene_hof.cpp	2008-05-02 15:39:51 UTC (rev 31822)
@@ -552,10 +552,10 @@
 	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;

Modified: scummvm/trunk/engines/kyra/staticres.cpp
===================================================================
--- scummvm/trunk/engines/kyra/staticres.cpp	2008-05-02 15:21:51 UTC (rev 31821)
+++ scummvm/trunk/engines/kyra/staticres.cpp	2008-05-02 15:39:51 UTC (rev 31822)
@@ -1508,24 +1508,16 @@
 
 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
 
 const uint8 KyraEngine_HoF::_seqTextColorPresets[] = { 0x01, 0x01, 0x00, 0x3f, 0x3f, 0x3f };
@@ -1940,6 +1932,22 @@
 
 // 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 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
 };


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list