mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-21 17:45:39 +00:00
MYST3: Added a simple debugging console
This commit is contained in:
parent
3f69d8db1a
commit
b541e3507e
89
engines/myst3/console.cpp
Normal file
89
engines/myst3/console.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
/* Residual - A 3D game interpreter
|
||||
*
|
||||
* Residual is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the AUTHORS
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "engines/myst3/console.h"
|
||||
|
||||
namespace Myst3 {
|
||||
|
||||
Console::Console(Myst3Engine *vm) : GUI::Debugger(), _vm(vm) {
|
||||
DCmd_Register("infos", WRAP_METHOD(Console, Cmd_Infos));
|
||||
DCmd_Register("lookAt", WRAP_METHOD(Console, Cmd_LookAt));
|
||||
}
|
||||
|
||||
Console::~Console() {
|
||||
}
|
||||
|
||||
bool Console::Cmd_Infos(int argc, const char **argv) {
|
||||
|
||||
uint16 nodeId = _vm->_node.getId();
|
||||
NodePtr nodeData = _vm->_db->getNodeData(nodeId);
|
||||
|
||||
char roomName[8];
|
||||
_vm->_db->getRoomName(roomName);
|
||||
|
||||
Common::Point lookAt = _vm->_scene.getMousePos();
|
||||
|
||||
DebugPrintf("current node: %s%d ", roomName, nodeId);
|
||||
DebugPrintf("pitch: %d heading: %d", lookAt.x, lookAt.y);
|
||||
|
||||
for (uint i = 0; i < nodeData->hotspots.size(); i++) {
|
||||
DebugPrintf("\nhotspot %d > condition: %d\n",
|
||||
i, nodeData->hotspots[i].condition);
|
||||
|
||||
for(uint j = 0; j < nodeData->hotspots[i].rects.size(); j++) {
|
||||
PolarRect &rect = nodeData->hotspots[i].rects[j];
|
||||
|
||||
DebugPrintf(" rect > pitch: %d heading: %d height: %d width: %d\n",
|
||||
rect.centerPitch, rect.centerHeading, rect.width, rect.height);
|
||||
}
|
||||
|
||||
for(uint j = 0; j < nodeData->hotspots[i].script.size(); j++) {
|
||||
Opcode &opcode = nodeData->hotspots[i].script[j];
|
||||
|
||||
DebugPrintf(" op %d ( ",
|
||||
opcode.op);
|
||||
|
||||
for(uint k = 0; k < opcode.args.size(); k++) {
|
||||
DebugPrintf("%d ", opcode.args[k]);
|
||||
}
|
||||
|
||||
DebugPrintf(")\n");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Console::Cmd_LookAt(int argc, const char **argv) {
|
||||
|
||||
if (argc != 3) {
|
||||
DebugPrintf("Usage :\n");
|
||||
DebugPrintf("lookAt pitch heading\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
_vm->_scene.lookAt(atof(argv[1]), atof(argv[2]));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} /* namespace Myst3 */
|
47
engines/myst3/console.h
Normal file
47
engines/myst3/console.h
Normal file
@ -0,0 +1,47 @@
|
||||
/* Residual - A 3D game interpreter
|
||||
*
|
||||
* Residual is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the AUTHORS
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CONSOLE_H_
|
||||
#define CONSOLE_H_
|
||||
|
||||
#include "gui/debugger.h"
|
||||
|
||||
#include "engines/myst3/myst3.h"
|
||||
|
||||
namespace Myst3 {
|
||||
|
||||
class Myst3Engine;
|
||||
|
||||
class Console : public GUI::Debugger {
|
||||
public:
|
||||
Console(Myst3Engine *vm);
|
||||
virtual ~Console();
|
||||
|
||||
private:
|
||||
Myst3Engine *_vm;
|
||||
|
||||
bool Cmd_Infos(int argc, const char **argv);
|
||||
bool Cmd_LookAt(int argc, const char **argv);
|
||||
};
|
||||
|
||||
} /* namespace Myst3 */
|
||||
#endif /* CONSOLE_H_ */
|
@ -18,9 +18,6 @@
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#include "engines/myst3/directorysubentry.h"
|
||||
@ -38,7 +35,7 @@ void DirectorySubEntry::readFromStream(Common::SeekableReadStream &inStream) {
|
||||
_face = inStream.readByte();
|
||||
_type = inStream.readByte();
|
||||
|
||||
dump();
|
||||
// dump();
|
||||
|
||||
if (_padding == 2) {
|
||||
uint32 _padding2 = inStream.readUint32LE();
|
||||
|
@ -2,6 +2,7 @@ MODULE := engines/myst3
|
||||
|
||||
MODULE_OBJS := \
|
||||
archive.o \
|
||||
console.o \
|
||||
database.o \
|
||||
detection.o \
|
||||
directoryentry.o \
|
||||
|
@ -49,7 +49,7 @@ namespace Myst3 {
|
||||
Myst3Engine::Myst3Engine(OSystem *syst, int gameFlags) :
|
||||
Engine(syst), _system(syst), _scriptEngine(this),
|
||||
_db(0) {
|
||||
_console = new GUI::Debugger();
|
||||
_console = new Console(this);
|
||||
}
|
||||
|
||||
Myst3Engine::~Myst3Engine() {
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "common/system.h"
|
||||
|
||||
#include "engines/myst3/archive.h"
|
||||
#include "engines/myst3/console.h"
|
||||
#include "engines/myst3/database.h"
|
||||
#include "engines/myst3/node.h"
|
||||
#include "engines/myst3/scene.h"
|
||||
@ -35,12 +36,14 @@
|
||||
|
||||
namespace Myst3 {
|
||||
|
||||
class Console;
|
||||
|
||||
class Myst3Engine : public Engine {
|
||||
|
||||
protected:
|
||||
// Engine APIs
|
||||
virtual Common::Error run();
|
||||
virtual GUI::Debugger *getDebugger() { return _console; }
|
||||
virtual GUI::Debugger *getDebugger() { return (GUI::Debugger *)_console; }
|
||||
public:
|
||||
|
||||
Myst3Engine(OSystem *syst, int gameFlags);
|
||||
@ -50,13 +53,15 @@ public:
|
||||
|
||||
private:
|
||||
OSystem *_system;
|
||||
GUI::Debugger *_console;
|
||||
Console *_console;
|
||||
|
||||
Node _node;
|
||||
Scene _scene;
|
||||
Archive _archive;
|
||||
Script _scriptEngine;
|
||||
Database *_db;
|
||||
|
||||
friend class Console;
|
||||
};
|
||||
|
||||
} // end of namespace Myst3
|
||||
|
@ -27,6 +27,11 @@
|
||||
|
||||
namespace Myst3 {
|
||||
|
||||
Scene::Scene():
|
||||
_cameraPitch(0.0f), _cameraHeading(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
void Scene::init(int width, int height) {
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
@ -38,9 +43,6 @@ void Scene::init(int width, int height) {
|
||||
glDisable(GL_LIGHTING);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
_cameraPitch = 0.0f;
|
||||
_cameraHeading = 0.0f;
|
||||
}
|
||||
|
||||
void Scene::clear() {
|
||||
@ -69,4 +71,9 @@ void Scene::updateCamera(Common::Point &mouse) {
|
||||
_cameraPitch = CLIP(_cameraPitch, -60.0f, 80.0f);
|
||||
}
|
||||
|
||||
void Scene::lookAt(float pitch, float heading) {
|
||||
_cameraPitch = pitch;
|
||||
_cameraHeading = heading;
|
||||
}
|
||||
|
||||
} // end of namespace Myst3
|
||||
|
@ -44,11 +44,15 @@ class Scene {
|
||||
Common::Point _mouseOld;
|
||||
|
||||
public:
|
||||
Scene();
|
||||
|
||||
void init(int width, int height);
|
||||
void clear();
|
||||
void setupCamera();
|
||||
void updateCamera(Common::Point &mouse);
|
||||
Common::Point getMousePos() { return Common::Point(_cameraHeading, _cameraPitch); }
|
||||
|
||||
void lookAt(float pitch, float heading);
|
||||
};
|
||||
|
||||
} // end of namespace Myst3
|
||||
|
@ -35,9 +35,13 @@ Script::~Script() {
|
||||
}
|
||||
|
||||
void Script::run(Common::Array<Opcode> *script) {
|
||||
debug("Script start %p", (void *) script);
|
||||
|
||||
for (uint i = 0; i < script->size(); i++) {
|
||||
runOp(&script->operator[](i));
|
||||
}
|
||||
|
||||
debug("Script stop %p ", (void *) script);
|
||||
}
|
||||
|
||||
void Script::runOp(Opcode *op) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user