[Scummvm-git-logs] scummvm master -> e069605d25f0d6d3206c92367f57c57e0885d5dc

bluegr bluegr at gmail.com
Wed Mar 15 09:29:20 CET 2017


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
6c17fc85ad CHEWY: Add a command to draw sprites on screen to the debugger
e069605d25 CHEWY: Initial work on speech for hotspot actions


Commit: 6c17fc85ad3de5689b055e193d89c60dd56c9095
    https://github.com/scummvm/scummvm/commit/6c17fc85ad3de5689b055e193d89c60dd56c9095
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2017-03-15T10:28:58+02:00

Commit Message:
CHEWY: Add a command to draw sprites on screen to the debugger

Changed paths:
    engines/chewy/console.cpp
    engines/chewy/console.h


diff --git a/engines/chewy/console.cpp b/engines/chewy/console.cpp
index 6fbd992..65c4a68 100644
--- a/engines/chewy/console.cpp
+++ b/engines/chewy/console.cpp
@@ -35,7 +35,8 @@ namespace Chewy {
 Console::Console(ChewyEngine *vm) : GUI::Debugger(), _vm(vm) {
 	registerCmd("dump",          WRAP_METHOD(Console, Cmd_Dump));
 	registerCmd("dump_bg",       WRAP_METHOD(Console, Cmd_DumpBg));
-	registerCmd("draw",          WRAP_METHOD(Console, Cmd_Draw));
+	registerCmd("draw_image",    WRAP_METHOD(Console, Cmd_DrawImage));
+	registerCmd("draw_sprite",   WRAP_METHOD(Console, Cmd_DrawSprite));
 	registerCmd("play_sound",    WRAP_METHOD(Console, Cmd_PlaySound));
 	registerCmd("play_speech",   WRAP_METHOD(Console, Cmd_PlaySpeech));
 	registerCmd("play_music",    WRAP_METHOD(Console, Cmd_PlayMusic));
@@ -104,9 +105,9 @@ bool Console::Cmd_DumpBg(int argc, const char **argv) {
 }
 
 
-bool Console::Cmd_Draw(int argc, const char **argv) {
+bool Console::Cmd_DrawImage(int argc, const char **argv) {
 	if (argc < 3) {
-		debugPrintf("Usage: draw <file> <resource number>\n");
+		debugPrintf("Usage: draw_image <file> <resource number>\n");
 		return true;
 	}
 
@@ -118,6 +119,22 @@ bool Console::Cmd_Draw(int argc, const char **argv) {
 	return false;
 }
 
+bool Console::Cmd_DrawSprite(int argc, const char **argv) {
+	if (argc < 3) {
+		debugPrintf("Usage: draw_sprite <file> <resource number> [x] [y]\n");
+		return true;
+	}
+
+	Common::String filename = argv[1];
+	int spriteNum = atoi(argv[2]);
+	int x = (argc < 4) ? 0 : atoi(argv[3]);
+	int y = (argc < 5) ? 0 : atoi(argv[4]);
+
+	_vm->_graphics->drawSprite(filename, spriteNum, x, y);
+
+	return false;
+}
+
 bool Console::Cmd_PlaySound(int argc, const char **argv) {
 	if (argc < 2) {
 		debugPrintf("Usage: play_sound <number>\n");
diff --git a/engines/chewy/console.h b/engines/chewy/console.h
index ae2be15..2ceb1df 100644
--- a/engines/chewy/console.h
+++ b/engines/chewy/console.h
@@ -39,7 +39,8 @@ private:
 
 	bool Cmd_Dump(int argc, const char **argv);
 	bool Cmd_DumpBg(int argc, const char **argv);
-	bool Cmd_Draw(int argc, const char **argv);
+	bool Cmd_DrawImage(int argc, const char **argv);
+	bool Cmd_DrawSprite(int argc, const char **argv);
 	bool Cmd_PlaySound(int argc, const char **argv);
 	bool Cmd_PlaySpeech(int argc, const char **argv);
 	bool Cmd_PlayMusic(int argc, const char **argv);


Commit: e069605d25f0d6d3206c92367f57c57e0885d5dc
    https://github.com/scummvm/scummvm/commit/e069605d25f0d6d3206c92367f57c57e0885d5dc
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2017-03-15T10:28:59+02:00

Commit Message:
CHEWY: Initial work on speech for hotspot actions

Changed paths:
    engines/chewy/cursor.cpp
    engines/chewy/cursor.h
    engines/chewy/events.cpp
    engines/chewy/scene.cpp
    engines/chewy/scene.h


diff --git a/engines/chewy/cursor.cpp b/engines/chewy/cursor.cpp
index 4795221..54496ef 100644
--- a/engines/chewy/cursor.cpp
+++ b/engines/chewy/cursor.cpp
@@ -63,6 +63,35 @@ Cursor::~Cursor() {
 	delete _cursorSprites;
 }
 
+// TODO: This may need to be refactored, since in the original the user
+// selects the cursor to use from a pop-up menu
+CurrentCursor Cursor::getCurrentCursor() const {
+	switch (_curCursor) {
+	case 0:
+	case 1:
+	case 2:
+	case 3:
+		return kWalk;
+	case 4:
+	case 5:
+	case 6:
+	case 7:
+		return kUse;
+	case 13:
+	case 14:
+	case 15:
+	case 16:
+		return kLook;
+	case 17:
+	case 18:
+	case 19:
+	case 20:
+		return kTalk;
+	default:
+		return kOther;
+	}
+}
+
 void Cursor::setCursor(uint num, bool newCursor) {
 	TAFChunk *cursor = _cursorSprites->getSprite(num);
 	if (newCursor)
diff --git a/engines/chewy/cursor.h b/engines/chewy/cursor.h
index de5a707..bb39abb 100644
--- a/engines/chewy/cursor.h
+++ b/engines/chewy/cursor.h
@@ -30,6 +30,14 @@ namespace Chewy {
 class SpriteResource;
 class Font;
 
+enum CurrentCursor {
+	kWalk,
+	kLook,
+	kUse,
+	kTalk,
+	kOther
+};
+
 class Cursor {
 public:
 	Cursor();
@@ -40,6 +48,7 @@ public:
 	void hideCursor();
 	void animateCursor();
 	void nextCursor();
+	CurrentCursor getCurrentCursor() const;
 
 private:
 	uint _curCursor;
diff --git a/engines/chewy/events.cpp b/engines/chewy/events.cpp
index 3da9da2..532b1ac 100644
--- a/engines/chewy/events.cpp
+++ b/engines/chewy/events.cpp
@@ -55,6 +55,8 @@ void Events::processEvents() {
 			default:
 				break;
 			}
+		} else if (_event.type == Common::EVENT_LBUTTONUP) {
+			_vm->_scene->mouseClick(_event.mouse);
 		} else if (_event.type == Common::EVENT_RBUTTONUP) {
 			_vm->_cursor->nextCursor();
 		} else if (_event.type == Common::EVENT_MOUSEMOVE) {
diff --git a/engines/chewy/scene.cpp b/engines/chewy/scene.cpp
index 7f10b75..df8dd66 100644
--- a/engines/chewy/scene.cpp
+++ b/engines/chewy/scene.cpp
@@ -30,6 +30,7 @@
 #include "chewy/graphics.h"
 #include "chewy/scene.h"
 #include "chewy/resource.h"
+#include "chewy/sound.h"
 #include "chewy/text.h"
 #include "chewy/video/cfo_decoder.h"
 
@@ -38,6 +39,7 @@ namespace Chewy {
 #define MAX_DETAILS 32
 #define MAX_HOTSPOTS 50
 #define MAX_AUTOMOVE 20
+#define MAX_SOUNDS 3
 
 // Animated details - scene animations
 struct AnimatedDetails {
@@ -76,6 +78,16 @@ struct Hotspot {
 	Common::String desc;
 };
 
+struct RoomInfo {
+	byte roomNum;
+	byte picNum;
+	byte autoMoveCount;
+	byte loadTaf;
+	Common::String tafName;	// 14 bytes
+	byte zoomFactor;
+	// 1 byte dummy
+};
+
 struct AutoMove {
 	int16 x;
 	int16 y;
@@ -83,6 +95,12 @@ struct AutoMove {
 	// 1 byte dummy
 };
 
+struct HotspotSpeech {
+	int16 look;
+	int16 use;
+	int16 talk;
+};
+
 struct SceneInfo {
 	uint16 staticDetailsCount;
 	uint16 animatedDetailsCount;
@@ -90,16 +108,10 @@ struct SceneInfo {
 	AnimatedDetails animatedDetails[MAX_DETAILS];
 	StaticDetails staticDetails[MAX_DETAILS];
 	Hotspot hotspot[MAX_HOTSPOTS];
-	byte roomNum;
-	byte picNum;
-	byte autoMoveCount;
-	byte loadTaf;
-	Common::String tafName;	// 14 bytes
-	byte zoomFactor;
-	// 1 byte dummy
+	RoomInfo roomInfo;
 	AutoMove autoMove[MAX_AUTOMOVE];
-	// MAX_DETAILS * 3 * 2 = 192 bytes voc - TODO
-	// MAX_DETAILS * 3 = 96 bytes samples - TODO
+	HotspotSpeech hotspotSpeech[MAX_DETAILS];
+	byte hotspotSound[MAX_DETAILS][MAX_SOUNDS];
 };
 
 Scene::Scene(ChewyEngine *vm) : _vm(vm) {
@@ -155,6 +167,33 @@ void Scene::updateMouse(Common::Point coords) {
 	}
 }
 
+void Scene::mouseClick(Common::Point coords) {
+	// Static details
+	for (uint16 i = 0; i < MAX_HOTSPOTS; i++) {
+		//_vm->_graphics->drawRect(_sceneInfo->hotspot[i].rect, 0);	// debug
+		if (_sceneInfo->hotspot[i].rect.contains(coords)) {
+			int sample = -1;
+
+			switch (_vm->_cursor->getCurrentCursor()) {
+			case kLook:
+				sample = _sceneInfo->hotspotSpeech[i].look;
+				break;
+			case kUse:
+				sample = _sceneInfo->hotspotSpeech[i].use;
+				break;
+			case kTalk:
+				sample = _sceneInfo->hotspotSpeech[i].talk;
+				break;
+			default:
+				break;
+			}
+
+			if (sample >= 0)
+				_vm->_sound->playSpeech(sample);
+		}
+	}
+}
+
 void Scene::loadSceneInfo() {
 	const uint32 sceneInfoSize = 3784;
 	const uint32 headerRDI = MKTAG('R', 'D', 'I', '\0');
@@ -230,15 +269,17 @@ void Scene::loadSceneInfo() {
 		}
 	}
 
-	_sceneInfo->roomNum = indexFile.readByte();
-	_sceneInfo->picNum = indexFile.readByte();
-	_sceneInfo->autoMoveCount = indexFile.readByte();
-	_sceneInfo->loadTaf = indexFile.readByte();
+	// Room info
+	_sceneInfo->roomInfo.roomNum = indexFile.readByte();
+	_sceneInfo->roomInfo.picNum = indexFile.readByte();
+	_sceneInfo->roomInfo.autoMoveCount = indexFile.readByte();
+	_sceneInfo->roomInfo.loadTaf = indexFile.readByte();
 	
+	_sceneInfo->roomInfo.tafName = "";
 	for (int i = 0; i < 14; i++)
-		_sceneInfo->tafName += indexFile.readByte();
+		_sceneInfo->roomInfo.tafName += indexFile.readByte();
 
-	_sceneInfo->zoomFactor = indexFile.readByte();
+	_sceneInfo->roomInfo.zoomFactor = indexFile.readByte();
 	indexFile.readByte();	// padding
 	
 	for (int i = 0; i < MAX_AUTOMOVE; i++) {
@@ -246,10 +287,25 @@ void Scene::loadSceneInfo() {
 		_sceneInfo->autoMove[i].y = indexFile.readSint16LE();
 		_sceneInfo->autoMove[i].spriteNum = indexFile.readByte();
 		indexFile.readByte();	// padding
+		if (i > _sceneInfo->roomInfo.autoMoveCount && !(_sceneInfo->autoMove[i].x <= 0 || _sceneInfo->autoMove[i].y <= 0))
+			warning("Auto move %d should be unused, but it isn't (max auto move items are %d)", i, _sceneInfo->roomInfo.autoMoveCount);
+	}
+
+	for (int i = 0; i < MAX_DETAILS; i++) {
+		// FIXME: These are all wrong... investigate why
+		_sceneInfo->hotspotSpeech[i].look = indexFile.readSint16LE();
+		_sceneInfo->hotspotSpeech[i].use = indexFile.readSint16LE();
+		_sceneInfo->hotspotSpeech[i].talk = indexFile.readSint16LE();
+	}
+
+	for (int i = 0; i < MAX_DETAILS; i++) {
+		_sceneInfo->hotspotSound[i][0] = indexFile.readSint16LE();
+		_sceneInfo->hotspotSound[i][1] = indexFile.readSint16LE();
+		_sceneInfo->hotspotSound[i][2] = indexFile.readSint16LE();
 	}
 
-	// MAX_DETAILS * 3 * 2 = 192 bytes voc - TODO: read these
-	// MAX_DETAILS * 3 = 96 bytes samples - TODO: read these
+	// TODO: We seem to be missing a chunk of data (186 bytes) from the end of
+	// the room info structure
 
 	delete text;
 	indexFile.close();
diff --git a/engines/chewy/scene.h b/engines/chewy/scene.h
index c5b87ac..bcbbf67 100644
--- a/engines/chewy/scene.h
+++ b/engines/chewy/scene.h
@@ -37,6 +37,7 @@ public:
 	void change(uint scene);
 	void draw();
 	void updateMouse(Common::Point coords);
+	void mouseClick(Common::Point coords);
 	uint getCurScene() const {
 		return _curScene;
 	}





More information about the Scummvm-git-logs mailing list