[Scummvm-git-logs] scummvm master -> 4dc6aa2d93a3e166891713549d73c4e40fe9f4f2
bluegr
bluegr at gmail.com
Sun Jan 8 19:25:07 CET 2017
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
981ff3b224 CHEWY: Clean up cursors a bit
b20df6b417 CHEWY: Make the error for invalid text resources more verbose
f3ea11f402 CHEWY: Initial implementation of scene sprites, props and hotspots
4dc6aa2d93 CHEWY: Add console command to change scenes
Commit: 981ff3b2240c5c104f333ecd4dd541a97c188203
https://github.com/scummvm/scummvm/commit/981ff3b2240c5c104f333ecd4dd541a97c188203
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2017-01-08T20:24:38+02:00
Commit Message:
CHEWY: Clean up cursors a bit
Changed paths:
engines/chewy/cursor.cpp
diff --git a/engines/chewy/cursor.cpp b/engines/chewy/cursor.cpp
index 18e001f..df8a6da 100644
--- a/engines/chewy/cursor.cpp
+++ b/engines/chewy/cursor.cpp
@@ -32,21 +32,25 @@
namespace Chewy {
const byte _cursorFrames[] = {
- 4, 1, 1, 1, // walk
- 4, 1, 1, 1, // pick up / use
- 1, 1, 1, 1, 1,
- 4, 1, 1, 1, // look
- 4, 1, 1, 1, // talk
- 4, 1, 1, 1, // open
- 1,
- 1, 1, 1, 1, // left, right, up, down
- 1, // save
- 1,
- 5, 1, 1, 1, 1,
- 1,
- 1, // use (inventory)
- 1, // look (inventory)
- 1 // gun
+ 4, 1, 1, 1, // 0-3: walk
+ 4, 1, 1, 1, // 5-7: use (+ no use, 4)
+ 1, // 8: go to
+ 4, 1, 1, 1, // 9-12: nope
+ 4, 1, 1, 1, // 13-16: look
+ 4, 1, 1, 1, // 17-20: talk (+ no talk, 17)
+ 4, 1, 1, 1, // 21-24: inventory
+ 1, // 25: save
+ 1, // 26: exit left
+ 1, // 27: exit right
+ 1, // 28: exit up
+ 1, // 29: exit down
+ 1, // 30: disk
+ 1, // 31: Howard
+ 5, 1, 1, 1, 1, // 32: animated arrow
+ 1, // 37: Nichelle
+ 1, // 38: use (inventory)
+ 1, // 39: look (inventory)
+ 1 // 40: gun
};
Cursor::Cursor(ChewyEngine *vm) : _vm(vm) {
Commit: b20df6b41758f64cddf0fe8ca17b287c7f4a1bf3
https://github.com/scummvm/scummvm/commit/b20df6b41758f64cddf0fe8ca17b287c7f4a1bf3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2017-01-08T20:24:39+02:00
Commit Message:
CHEWY: Make the error for invalid text resources more verbose
Changed paths:
engines/chewy/text.cpp
diff --git a/engines/chewy/text.cpp b/engines/chewy/text.cpp
index fcf07a6..cf0fb04 100644
--- a/engines/chewy/text.cpp
+++ b/engines/chewy/text.cpp
@@ -113,7 +113,7 @@ TextEntry *Text::getText(uint dialogNum, uint entryNum) {
} while (*ptr);
if (*(ptr + 1) != kEndText || *(ptr + 2) != kEndChunk)
- error("Invalid text resource - %d", dialogNum);
+ error("Invalid text resource - %d, %d", dialogNum, entryNum);
if (!isText)
ptr += 3; // 0, kEndText, kEndChunk
Commit: f3ea11f402102f88750e98dd5b55779695ff832f
https://github.com/scummvm/scummvm/commit/f3ea11f402102f88750e98dd5b55779695ff832f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2017-01-08T20:24:39+02:00
Commit Message:
CHEWY: Initial implementation of scene sprites, props and hotspots
Changed paths:
engines/chewy/events.cpp
engines/chewy/scene.cpp
engines/chewy/scene.h
diff --git a/engines/chewy/events.cpp b/engines/chewy/events.cpp
index 6675fea..55a7b62 100644
--- a/engines/chewy/events.cpp
+++ b/engines/chewy/events.cpp
@@ -28,6 +28,7 @@
#include "chewy/cursor.h"
#include "chewy/events.h"
#include "chewy/graphics.h"
+#include "chewy/scene.h"
namespace Chewy {
@@ -56,6 +57,8 @@ void Events::processEvents() {
}
} else if (_event.type == Common::EVENT_RBUTTONUP) {
_vm->_cursor->nextCursor();
+ } else if (_event.type == Common::EVENT_MOUSEMOVE) {
+ _vm->_scene->updateMouse(_event.mouse);
}
}
}
diff --git a/engines/chewy/scene.cpp b/engines/chewy/scene.cpp
index 03e4332..c6c12fc 100644
--- a/engines/chewy/scene.cpp
+++ b/engines/chewy/scene.cpp
@@ -35,10 +35,53 @@
namespace Chewy {
+#define MAX_DETAILS 32
+#define MAX_HOTSPOTS 50
+
+// Animated details - scene animations
+struct AnimatedDetails {
+ uint16 x;
+ uint16 y;
+ // 66 bytes animated details - TODO
+};
+
+// Static details - scene sprites and props
+struct StaticDetails {
+ int16 x;
+ int16 y;
+ int16 spriteNum;
+ uint16 z;
+ byte hide;
+ // 1 byte dummy
+};
+
+struct SceneInfo {
+ uint16 staticDetailsCount;
+ uint16 animatedDetailsCount;
+ uint32 spritePtr;
+ AnimatedDetails animatedDetails[MAX_DETAILS];
+ StaticDetails staticDetails[MAX_DETAILS];
+ Common::Rect hotspot[MAX_HOTSPOTS];
+ uint16 hotspotDescRes[MAX_HOTSPOTS];
+ Common::String hotspotDesc[MAX_HOTSPOTS];
+ byte roomNum;
+ byte picNum;
+ byte autoMoveCount;
+ byte loadTaf;
+ Common::String tafName; // 14 bytes
+ byte zoomFactor;
+ // 1 byte dummy
+ // 6 * 20 = 120 bytes automove coordinates - TODO
+ // MAX_DETAILS * 3 * 2 = 192 bytes voc - TODO
+ // MAX_DETAILS * 3 = 96 bytes samples - TODO
+};
+
Scene::Scene(ChewyEngine *vm) : _vm(vm) {
+ _sceneInfo = new SceneInfo();
}
Scene::~Scene() {
+ delete _sceneInfo;
}
void Scene::change(uint scene) {
@@ -46,14 +89,121 @@ void Scene::change(uint scene) {
_vm->_cursor->setCursor(0);
_vm->_cursor->showCursor();
+ loadSceneInfo();
draw();
}
void Scene::draw() {
+ // Background
_vm->_graphics->drawImage("episode1.tgp", _curScene);
+
+ // Static details
+ for (uint16 i = 0; i < MAX_HOTSPOTS; i++) {
+ StaticDetails s = _sceneInfo->staticDetails[i];
+ if (s.spriteNum >= 0 && s.x >= 0 && s.y >= 0 && !s.hide)
+ _vm->_graphics->drawSprite(Common::String::format("det%d.taf", _curScene), s.spriteNum, s.x, s.y);
+ }
+
+ // TODO: These are all hardcoded for now
_vm->_graphics->drawSprite("det1.taf", 0, 200, 100);
_vm->_graphics->loadFont("6x8.tff");
_vm->_graphics->drawText("This is a test", 200, 80);
}
+void Scene::updateMouse(Common::Point coords) {
+ // Animated details
+ // TODO: handle these
+
+ // Static details
+ for (uint16 i = 0; i < MAX_HOTSPOTS; i++) {
+ if (_sceneInfo->hotspot[i].contains(coords)) {
+ // TODO: Draw hotspot description on screen
+ debug("Coords %d, %d: '%s'", coords.x, coords.y, _sceneInfo->hotspotDesc[i].c_str());
+ break;
+ }
+ }
+}
+
+void Scene::loadSceneInfo() {
+ const uint32 sceneInfoSize = 3784;
+ const uint32 headerRDI = MKTAG('R', 'D', 'I', '\0');
+ const char *sceneIndexFileName = "test.rdi";
+ Common::File indexFile;
+ if (!Common::File::exists(sceneIndexFileName))
+ error("File %s not found", sceneIndexFileName);
+ Text *text = new Text();
+
+ indexFile.open(sceneIndexFileName);
+
+ uint32 header = indexFile.readUint32BE();
+ if (header != headerRDI)
+ error("Invalid resource - %s", sceneIndexFileName);
+
+ indexFile.seek(sceneInfoSize * _curScene, SEEK_CUR);
+
+ // TODO: These can be set to larger numbers than MAX_DETAILS
+ _sceneInfo->staticDetailsCount = indexFile.readUint16LE();
+ _sceneInfo->animatedDetailsCount = indexFile.readUint16LE();
+ indexFile.skip(6);
+
+ // Animated details
+ for (int i = 0; i < MAX_DETAILS; i++) {
+ _sceneInfo->animatedDetails[i].x = indexFile.readUint16LE();
+ _sceneInfo->animatedDetails[i].y = indexFile.readUint16LE();
+ indexFile.skip(66); // animated details info - TODO: read these
+ }
+
+ // Static details
+ for (int i = 0; i < MAX_DETAILS; i++) {
+ _sceneInfo->staticDetails[i].x = indexFile.readSint16LE();
+ _sceneInfo->staticDetails[i].y = indexFile.readSint16LE();
+ _sceneInfo->staticDetails[i].spriteNum = indexFile.readSint16LE();
+ _sceneInfo->staticDetails[i].z = indexFile.readUint16LE();
+ _sceneInfo->staticDetails[i].hide = indexFile.readByte();
+ indexFile.readByte(); // padding
+ }
+
+ // Hotspots
+ for (int i = 0; i < MAX_HOTSPOTS; i++) {
+ _sceneInfo->hotspot[i].left = indexFile.readUint16LE();
+ _sceneInfo->hotspot[i].top = indexFile.readUint16LE();
+ _sceneInfo->hotspot[i].right = indexFile.readUint16LE();
+ _sceneInfo->hotspot[i].bottom = indexFile.readUint16LE();
+ if (!_sceneInfo->hotspot[i].isValidRect())
+ warning("Hotspot %d has an invalid rect", i);
+ }
+
+ // Hotspot descriptions
+ for (int i = 0; i < MAX_HOTSPOTS; i++) {
+ _sceneInfo->hotspotDescRes[i] = indexFile.readUint16LE();
+
+ if (_sceneInfo->hotspotDescRes[i] < kATSTextMax) {
+ // TODO: Hotspot description IDs are off... investigate why
+ _sceneInfo->hotspotDesc[i] = text->getText(_curScene + kADSTextMax, _sceneInfo->hotspotDescRes[i])->text;
+ } else {
+ // TODO: Handle these types of hotspot descriptions
+ warning("Hotspot %d has an invalid description resource (%d)", i, _sceneInfo->hotspotDescRes[i]);
+ _sceneInfo->hotspotDesc[i] = Common::String::format("Hotspot %d", _sceneInfo->hotspotDescRes[i]);
+ }
+ }
+
+ _sceneInfo->roomNum = indexFile.readByte();
+ _sceneInfo->picNum = indexFile.readByte();
+ _sceneInfo->autoMoveCount = indexFile.readByte();
+ _sceneInfo->loadTaf = indexFile.readByte();
+
+ for (int i = 0; i < 14; i++)
+ _sceneInfo->tafName += indexFile.readByte();
+
+ _sceneInfo->zoomFactor = indexFile.readByte();
+ indexFile.readByte(); // padding
+
+ // 6 * 20 = 120 bytes automove coordinates - TODO: read these
+ // MAX_DETAILS * 3 * 2 = 192 bytes voc - TODO: read these
+ // MAX_DETAILS * 3 = 96 bytes samples - TODO: read these
+
+ delete text;
+ indexFile.close();
+}
+
} // End of namespace Chewy
diff --git a/engines/chewy/scene.h b/engines/chewy/scene.h
index 37601d0..24692c8 100644
--- a/engines/chewy/scene.h
+++ b/engines/chewy/scene.h
@@ -27,6 +27,8 @@
namespace Chewy {
+struct SceneInfo;
+
class Scene {
public:
Scene(ChewyEngine *vm);
@@ -34,10 +36,14 @@ public:
void change(uint scene);
void draw();
+ void updateMouse(Common::Point coords);
private:
+ void loadSceneInfo();
+
ChewyEngine *_vm;
uint _curScene;
+ SceneInfo *_sceneInfo;
};
} // End of namespace Chewy
Commit: 4dc6aa2d93a3e166891713549d73c4e40fe9f4f2
https://github.com/scummvm/scummvm/commit/4dc6aa2d93a3e166891713549d73c4e40fe9f4f2
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2017-01-08T20:24:39+02:00
Commit Message:
CHEWY: Add console command to change scenes
Changed paths:
engines/chewy/console.cpp
engines/chewy/console.h
engines/chewy/scene.cpp
engines/chewy/scene.h
diff --git a/engines/chewy/console.cpp b/engines/chewy/console.cpp
index cb2d5e2..6fbd992 100644
--- a/engines/chewy/console.cpp
+++ b/engines/chewy/console.cpp
@@ -26,6 +26,7 @@
#include "chewy/console.h"
#include "chewy/graphics.h"
#include "chewy/resource.h"
+#include "chewy/scene.h"
#include "chewy/sound.h"
#include "chewy/text.h"
@@ -43,6 +44,7 @@ Console::Console(ChewyEngine *vm) : GUI::Debugger(), _vm(vm) {
registerCmd("error_message", WRAP_METHOD(Console, Cmd_ErrorMessage));
registerCmd("dialog", WRAP_METHOD(Console, Cmd_Dialog));
registerCmd("text", WRAP_METHOD(Console, Cmd_Text));
+ registerCmd("scene", WRAP_METHOD(Console, Cmd_Scene));
}
Console::~Console() {
@@ -235,4 +237,17 @@ bool Console::Cmd_Text(int argc, const char **argv) {
return true;
}
+bool Console::Cmd_Scene(int argc, const char **argv) {
+ if (argc < 2) {
+ debugPrintf("Current scene is: %d\n", _vm->_scene->getCurScene());
+ debugPrintf("Use scene <scene num> to change the scene\n");
+ return true;
+ }
+
+ int sceneNum = atoi(argv[1]);
+ _vm->_scene->change(sceneNum);
+
+ return false;
+}
+
} // End of namespace Chewy
diff --git a/engines/chewy/console.h b/engines/chewy/console.h
index 4953480..ae2be15 100644
--- a/engines/chewy/console.h
+++ b/engines/chewy/console.h
@@ -48,6 +48,7 @@ private:
bool Cmd_ErrorMessage(int argc, const char **argv);
bool Cmd_Dialog(int argc, const char **argv);
bool Cmd_Text(int argc, const char **argv);
+ bool Cmd_Scene(int argc, const char **argv);
};
} // End of namespace Chewy
diff --git a/engines/chewy/scene.cpp b/engines/chewy/scene.cpp
index c6c12fc..0f12219 100644
--- a/engines/chewy/scene.cpp
+++ b/engines/chewy/scene.cpp
@@ -177,7 +177,7 @@ void Scene::loadSceneInfo() {
for (int i = 0; i < MAX_HOTSPOTS; i++) {
_sceneInfo->hotspotDescRes[i] = indexFile.readUint16LE();
- if (_sceneInfo->hotspotDescRes[i] < kATSTextMax) {
+ if (_sceneInfo->hotspotDescRes[i] < 12) {
// TODO: Hotspot description IDs are off... investigate why
_sceneInfo->hotspotDesc[i] = text->getText(_curScene + kADSTextMax, _sceneInfo->hotspotDescRes[i])->text;
} else {
diff --git a/engines/chewy/scene.h b/engines/chewy/scene.h
index 24692c8..c5b87ac 100644
--- a/engines/chewy/scene.h
+++ b/engines/chewy/scene.h
@@ -37,6 +37,9 @@ public:
void change(uint scene);
void draw();
void updateMouse(Common::Point coords);
+ uint getCurScene() const {
+ return _curScene;
+ }
private:
void loadSceneInfo();
More information about the Scummvm-git-logs
mailing list