[Scummvm-cvs-logs] SF.net SVN: scummvm:[41927] scummvm/branches/gsoc2009-draci/engines/draci
dkasak13 at users.sourceforge.net
dkasak13 at users.sourceforge.net
Sun Jun 28 18:19:10 CEST 2009
Revision: 41927
http://scummvm.svn.sourceforge.net/scummvm/?rev=41927&view=rev
Author: dkasak13
Date: 2009-06-28 16:19:10 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Changed Script::run() to accept a GPL2Program struct instead of a byte pointer and a length. Also, Script::run() now executes the GPL program until a gplend instruction rather than to the end of the whole program. Modified GameObject according to the new changes.
Modified Paths:
--------------
scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp
scummvm/branches/gsoc2009-draci/engines/draci/game.cpp
scummvm/branches/gsoc2009-draci/engines/draci/game.h
scummvm/branches/gsoc2009-draci/engines/draci/script.cpp
scummvm/branches/gsoc2009-draci/engines/draci/script.h
Modified: scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp 2009-06-28 15:28:20 UTC (rev 41926)
+++ scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp 2009-06-28 16:19:10 UTC (rev 41927)
@@ -69,7 +69,7 @@
_screen = new Screen(this);
_font = new Font();
_mouse = new Mouse(this);
- _game = new Game();
+ _game = new Game(this);
_script = new Script();
// Load default font
Modified: scummvm/branches/gsoc2009-draci/engines/draci/game.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/game.cpp 2009-06-28 15:28:20 UTC (rev 41926)
+++ scummvm/branches/gsoc2009-draci/engines/draci/game.cpp 2009-06-28 16:19:10 UTC (rev 41927)
@@ -28,10 +28,11 @@
#include "draci/draci.h"
#include "draci/game.h"
#include "draci/barchive.h"
+#include "draci/script.h"
namespace Draci {
-Game::Game() {
+Game::Game(DraciEngine *vm) : _vm(vm) {
unsigned int i;
Common::String path("INIT.DFW");
@@ -161,9 +162,9 @@
memcpy(obj->_title, file->_data, file->_length);
file = objArchive[objNum * 3 + 2];
- obj->_program = new byte[file->_length];
- memcpy(obj->_program, file->_data, file->_length);
- obj->_progLen = file->_length;
+ obj->_program._bytecode = new byte[file->_length];
+ obj->_program._length = file->_length;
+ memcpy(obj->_program._bytecode, file->_data, file->_length);
}
Game::~Game() {
@@ -176,12 +177,9 @@
}
GameObject::~GameObject() {
- if (_seqTab)
- delete[] _seqTab;
- if (_title)
- delete[] _title;
- if (_program)
- delete[] _program;
+ delete[] _seqTab;
+ delete[] _title;
+ delete[] _program._bytecode;
}
}
Modified: scummvm/branches/gsoc2009-draci/engines/draci/game.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/game.h 2009-06-28 15:28:20 UTC (rev 41926)
+++ scummvm/branches/gsoc2009-draci/engines/draci/game.h 2009-06-28 16:19:10 UTC (rev 41927)
@@ -27,16 +27,19 @@
#define DRACI_GAME_H
#include "common/str.h"
+#include "draci/script.h"
namespace Draci {
+class DraciEngine;
+
enum StructSizes {
personSize = sizeof(uint16) * 2 + sizeof(byte)
};
struct GameObject {
- GameObject() : _seqTab(NULL), _title(NULL), _program(NULL) {}
+ GameObject() : _seqTab(NULL), _title(NULL) {}
~GameObject();
uint16 _init, _look, _use, _canUse;
@@ -49,9 +52,8 @@
uint16 _absNum;
byte _animObj;
uint16 *_seqTab;
- byte *_program;
+ GPL2Program _program;
byte *_title;
- uint32 _progLen;
};
struct GameInfo {
@@ -76,10 +78,12 @@
class Game {
public:
- Game();
+ Game(DraciEngine *vm);
~Game();
private:
+ DraciEngine *_vm;
+
GameInfo *_info;
Person *_persons;
uint16 *_dialogOffsets;
Modified: scummvm/branches/gsoc2009-draci/engines/draci/script.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/script.cpp 2009-06-28 15:28:20 UTC (rev 41926)
+++ scummvm/branches/gsoc2009-draci/engines/draci/script.cpp 2009-06-28 16:19:10 UTC (rev 41927)
@@ -246,8 +246,7 @@
/**
* @brief GPL2 bytecode disassembler
- * @param gplcode A pointer to the bytecode
- * @param len Length of the bytecode
+ * @param program GPL program in the form of a GPL2Program struct
*
* GPL2 is short for Game Programming Language 2 which is the script language
* used by Draci Historie. This is a simple disassembler for the language.
@@ -275,10 +274,11 @@
* value comes from.
*/
-int Script::run(byte *gplcode, uint16 len) {
- Common::MemoryReadStream reader(gplcode, len);
+int Script::run(GPL2Program program) {
+ Common::MemoryReadStream reader(program._bytecode, program._length);
- while (!reader.eos()) {
+ GPL2Command *cmd;
+ do {
// read in command pair
uint16 cmdpair = reader.readUint16BE();
@@ -288,7 +288,6 @@
// extract low byte, i.e. the command subnumber
byte subnum = cmdpair & 0xFF;
- GPL2Command *cmd;
if ((cmd = findCommand(num, subnum))) {
// Print command name
@@ -308,10 +307,8 @@
debugC(2, kDraciBytecodeDebugLevel, "Unknown opcode %hu, %hu",
num, subnum);
}
+ } while (cmd->_name != "gplend");
-
- }
-
return 0;
}
Modified: scummvm/branches/gsoc2009-draci/engines/draci/script.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/script.h 2009-06-28 15:28:20 UTC (rev 41926)
+++ scummvm/branches/gsoc2009-draci/engines/draci/script.h 2009-06-28 16:19:10 UTC (rev 41927)
@@ -50,10 +50,22 @@
int _paramTypes[kMaxParams];
};
+/**
+ * A convenience data type that holds both the actual bytecode and the
+ * length of the bytecode. Passed to Script::run().
+ */
+
+struct GPL2Program {
+ GPL2Program() : _bytecode(NULL), _length(0) {}
+
+ byte *_bytecode;
+ uint16 _length;
+};
+
class Script {
public:
- int run(byte *gplcode, uint16 len);
+ int run(GPL2Program program);
private:
GPL2Command *findCommand(byte num, byte subnum);
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