[Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.82,1.83 actor.h,1.42,1.43 console.cpp,1.26,1.27 console.h,1.12,1.13 interface.cpp,1.53,1.54 interface.h,1.22,1.23 render.h,1.21,1.22 resnames.h,1.17,1.18 saga.cpp,1.81,1.82 saga.h,1.65,1.66 script.cpp,1.42,1.43 script.h,1.48,1.49 sfuncs.cpp,1.73,1.74 sprite.cpp,1.37,1.38 sprite.h,1.12,1.13 sthread.cpp,1.55,1.56
Andrew Kurushin
h00ligan at users.sourceforge.net
Sat Jan 8 12:31:07 CET 2005
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/base main.cpp,1.60.2.2,1.60.2.3
- Next message: [Scummvm-cvs-logs] CVS: scummvm/saga actor.h,1.43,1.44 saga.cpp,1.82,1.83 saga.h,1.66,1.67 script.h,1.49,1.50
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4486
Modified Files:
actor.cpp actor.h console.cpp console.h interface.cpp
interface.h render.h resnames.h saga.cpp saga.h script.cpp
script.h sfuncs.cpp sprite.cpp sprite.h sthread.cpp
Log Message:
begining of verb implementation
introduced getObjectName
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- actor.cpp 7 Jan 2005 22:18:52 -0000 1.82
+++ actor.cpp 8 Jan 2005 20:30:06 -0000 1.83
@@ -130,6 +130,9 @@
Actor::Actor(SagaEngine *vm) : _vm(vm) {
int i;
+ int result;
+ byte *stringsPointer;
+ size_t stringsLength;
ActorData *actor;
debug(9, "Actor::Actor()");
@@ -168,10 +171,18 @@
if (_actorContext == NULL) {
error("Actor::Actor(): Couldn't load actor module resource context.");
}
+
+ result = RSC_LoadResource(_actorContext, RID_ITE_ACTOR_NAMES, &stringsPointer, &stringsLength); // fixme: IHNM
+ if ((result != SUCCESS) || (stringsLength == 0)) {
+ error("Error loading strings list resource");
+ }
+
+ _vm->loadStrings(_actorsStrings, stringsPointer, stringsLength);
+ RSC_FreeResource(stringsPointer);
for (i = 0; i < ACTORCOUNT; i++) {
actor = &_actors[i];
- actor->actorId = ACTOR_INDEX_TO_ID(i);
+ actor->actorId = actorIndexToId(i);
actor->index = i;
debug(9, "init actorId=%d index=%d", actor->actorId, actor->index);
actor->nameIndex = ActorTable[i].nameIndex;
@@ -212,6 +223,7 @@
free(_newPathNodeList);
free(_pathList);
free(_pathCell);
+ _actorsStrings.freeMem();
//release resources
for (i = 0; i < ACTORCOUNT; i++) {
actor = &_actors[i];
@@ -307,7 +319,7 @@
}
if (objectId != ID_NOTHING) {
- if (IS_VALID_ACTOR_ID(objectId)) {
+ if (validActorId(objectId)) {
actor = getActor(objectId);
location.add( actor->location);
} else {
@@ -340,7 +352,7 @@
void Actor::actorFaceTowardsObject(uint16 actorId, uint16 objectId) {
ActorData *actor;
- if (IS_VALID_ACTOR_ID(objectId)) {
+ if (validActorId(objectId)) {
actor = getActor(objectId);
actorFaceTowardsPoint(actorId, actor->location);
} else {
@@ -348,10 +360,16 @@
}
}
+const char * Actor::getActorName(uint16 actorId) {
+ ActorData *actor;
+ actor = getActor(actorId);
+ return _actorsStrings.getString(actor->nameIndex);
+}
+
ActorData *Actor::getActor(uint16 actorId) {
ActorData *actor;
- if (!IS_VALID_ACTOR_ID(actorId))
+ if (!validActorId(actorId))
error("Actor::getActor Wrong actorId 0x%X", actorId);
if (actorId == ID_PROTAG) {
@@ -361,7 +379,7 @@
return _protagonist;
}
- actor = &_actors[ACTOR_ID_TO_INDEX(actorId)];
+ actor = &_actors[actorIdToIndex(actorId)];
if (actor->disabled)
error("Actor::getActor disabled actorId 0x%X", actorId);
@@ -907,7 +925,7 @@
ActorOrderList::iterator actorDrawOrderIterator;
ActorData *actor;
int frameNumber;
- SPRITELIST *spriteList;
+ SpriteList *spriteList;
SURFACE *back_buf;
@@ -924,7 +942,7 @@
continue;
}
frameNumber = 8;
- spriteList = _vm->_mainSprites;
+ spriteList = _vm->_sprite->_mainSprites;
} else {
frameNumber = actor->frameNumber;
spriteList = actor->spriteList;
@@ -1871,77 +1889,24 @@
#endif
}
-/*
// Console wrappers - must be safe to run
-// TODO - checkup ALL arguments, cause wrong arguments may fall function with "error"
-
-void Actor::CF_actor_move(int argc, const char **argv) {
- uint16 actorId = (uint16) atoi(argv[1]);
- Point movePoint;
-
- movePoint.x = atoi(argv[2]);
- movePoint.y = atoi(argv[3]);
-
- if (!IS_VALID_ACTOR_ID(actorId)) {
- _vm->_console->DebugPrintf("Actor::CF_actor_move Invalid actorId 0x%X.\n", actorId);
- return;
- }
-
- move(actorId, movePoint);
-}
-void Actor::CF_actor_moverel(int argc, const char **argv) {
+void Actor::cmdActorWalkTo(int argc, const char **argv) {
uint16 actorId = (uint16) atoi(argv[1]);
+ ActorLocation location;
Point movePoint;
movePoint.x = atoi(argv[2]);
movePoint.y = atoi(argv[3]);
- if (!IS_VALID_ACTOR_ID(actorId)) {
- _vm->_console->DebugPrintf("Actor::CF_actor_moverel Invalid actorId 0x%X.\n", actorId);
- return;
- }
-
- moveRelative(actorId, movePoint);
-}
-
-void Actor::CF_actor_seto(int argc, const char **argv) {
- uint16 actorId = (uint16) atoi(argv[1]);
- int orient;
+ location.fromScreenPoint(movePoint);
- orient = atoi(argv[2]);
-//TODO orient check
- if (!IS_VALID_ACTOR_ID(actorId)) {
- _vm->_console->DebugPrintf("Actor::CF_actor_seto Invalid actorId 0x%X.\n",actorId);
+ if (!validActorId(actorId)) {
+ _vm->_console->DebugPrintf("Actor::cmActorWalkTo Invalid actorId 0x%X.\n", actorId);
return;
}
+ actorWalkTo(actorId, location);
}
-void Actor::CF_actor_setact(int argc, const char **argv) {
- uint16 actorId = (uint16) atoi(argv[1]);
- int action_n = 0;
-
- action_n = atoi(argv[2]);
-
- if (!IS_VALID_ACTOR_ID(actorId)) {
- _vm->_console->DebugPrintf("Actor::CF_actor_setact Invalid actorId 0x%X.\n",actorId);
- return;
- }
-
-//TODO action_n check
- if ((action_n < 0) || (action_n >= actor->action_ct)) {
- _vm->_console->DebugPrintf("Invalid action number.\n");
- return;
- }
-
- _vm->_console->DebugPrintf("Action frame counts: %d %d %d %d.\n",
- actor->act_tbl[action_n].dir[0].frame_count,
- actor->act_tbl[action_n].dir[1].frame_count,
- actor->act_tbl[action_n].dir[2].frame_count,
- actor->act_tbl[action_n].dir[3].frame_count);
-
- setAction(actorId, action_n, ACTION_LOOP);
-}
-*/
} // End of namespace Saga
Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- actor.h 6 Jan 2005 23:02:53 -0000 1.42
+++ actor.h 8 Jan 2005 20:30:06 -0000 1.43
@@ -29,10 +29,11 @@
#include "saga/sprite.h"
#include "saga/actordata.h"
#include "saga/list.h"
+#include "saga/saga.h"
namespace Saga {
-//#define ACTOR_DEBUG
+#define ACTOR_DEBUG
#define ACTOR_BARRIERS_MAX 16
@@ -56,16 +57,6 @@
#define PATH_NODE_EMPTY -1
-
-#define ID_NOTHING 0
-#define ID_PROTAG 1
-
-#define IS_VALID_ACTOR_INDEX(index) ((index >= 0) && (index < ACTORCOUNT))
-#define IS_VALID_ACTOR_ID(id) ((id == 1) || (id >= 0x2000) && (id < (0x2000 | ACTORCOUNT)))
-#define ACTOR_ID_TO_INDEX(id) ((((uint16)id) == 1 ) ? 0 : (int)(((uint16)id) & ~0x2000))
-#define ACTOR_INDEX_TO_ID(index) ((((int)index) == 0 ) ? 1 : (uint16)(((int)index) | 0x2000))
-
-
enum ActorActions {
kActionWait = 0,
kActionWalkToPoint = 1,
@@ -207,7 +198,7 @@
uint8 cycleTimeCount;
uint8 cycleFlags;
- SPRITELIST *spriteList; // Actor's sprite list data
+ SpriteList *spriteList; // Actor's sprite list data
int spriteListResourceId; // Actor's sprite list resource id
ActorFrameSequence *frames; // Actor's frames
@@ -275,18 +266,20 @@
Actor(SagaEngine *vm);
~Actor();
-/*
- void CF_actor_move(int argc, const char **argv);
- void CF_actor_moverel(int argc, const char **argv);
- void CF_actor_seto(int argc, const char **argv);
- void CF_actor_setact(int argc, const char **argv);
-*/
+
+ void cmdActorWalkTo(int argc, const char **argv);
+
+ bool validActorId(uint16 id) { return (id == 1) || ((id >= 0x2000) && (id < (0x2000 | ACTORCOUNT))); }
+ int actorIdToIndex(uint16 id) { return (id == 1 ) ? 0 : (id & ~0x2000); }
+ uint16 actorIndexToId(int index) { return (index == 0 ) ? 1 : (index | 0x2000); }
+
int direct(int msec);
int drawActors();
void updateActorsScene(); // calls from scene loading to update Actors info
void drawPathTest();
+ const char * getActorName(uint16 actorId);
bool actorEndWalk(uint16 actorId, bool recurse);
bool actorWalkTo(uint16 actorId, const ActorLocation &toLocation);
ActorData *getActor(uint16 actorId);
@@ -350,6 +343,7 @@
ActorOrderList _drawOrderList;
ActorData _actors[ACTORCOUNT];
SpeechData _activeSpeech;
+ StringsList _actorsStrings;
//path stuff
Rect _barrierList[ACTOR_BARRIERS_MAX];
Index: console.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/console.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- console.cpp 3 Jan 2005 21:17:31 -0000 1.26
+++ console.cpp 8 Jan 2005 20:30:06 -0000 1.27
@@ -47,10 +47,7 @@
// CVAR_Register_I(&_musicEnabled, "music", NULL, CVAR_CFG, 0, 1);
// Actor commands
- DCmd_Register("actor_move", &Console::Cmd_ActorMove);
- DCmd_Register("actor_moverel", &Console::Cmd_ActorMoveRel);
- DCmd_Register("actor_seto", &Console::Cmd_ActorSetO);
- DCmd_Register("actor_setact", &Console::Cmd_ActorSetAct);
+ DCmd_Register("actor_walk_to", &Console::cmdActorWalkTo);
// Animation commands
DCmd_Register("anim_info", &Console::Cmd_AnimInfo);
@@ -135,37 +132,14 @@
return true;
}
-bool Console::Cmd_ActorMove(int argc, const char **argv) {
-/* if (argc != 4)
- DebugPrintf("Usage: %s <Actor id> <lx> <ly>\n", argv[0]);
- else
- _vm->_actor->CF_actor_move(argc, argv);*/
- return true;
-}
-
-bool Console::Cmd_ActorMoveRel(int argc, const char **argv) {
-/* if (argc != 4)
+bool Console::cmdActorWalkTo(int argc, const char **argv) {
+ if (argc != 4)
DebugPrintf("Usage: %s <Actor id> <lx> <ly>\n", argv[0]);
else
- _vm->_actor->CF_actor_moverel(argc, argv);*/
- return true;
-}
-
-bool Console::Cmd_ActorSetO(int argc, const char **argv) {
-/* if (argc != 3)
- DebugPrintf("Usage: %s <Actor id> <Orientation>\n", argv[0]);
- else
- _vm->_actor->CF_actor_seto(argc, argv);*/
+ _vm->_actor->cmdActorWalkTo(argc, argv);
return true;
}
-bool Console::Cmd_ActorSetAct(int argc, const char **argv) {
-/* if (argc != 3)
- DebugPrintf("Usage: %s <Actor id> <Action #>\n", argv[0]);
- else
- _vm->_actor->CF_actor_setact(argc, argv);*/
- return true;
-}
bool Console::Cmd_AnimInfo(int argc, const char **argv) {
_vm->_anim->animInfo();
Index: console.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/console.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- console.h 3 Jan 2005 21:17:32 -0000 1.12
+++ console.h 8 Jan 2005 20:30:06 -0000 1.13
@@ -43,10 +43,7 @@
bool Cmd_Exit(int argc, const char **argv);
bool Cmd_Help(int argc, const char **argv);
- bool Cmd_ActorMove(int argc, const char **argv);
- bool Cmd_ActorMoveRel(int argc, const char **argv);
- bool Cmd_ActorSetO(int argc, const char **argv);
- bool Cmd_ActorSetAct(int argc, const char **argv);
+ bool cmdActorWalkTo(int argc, const char **argv);
bool Cmd_AnimInfo(int argc, const char **argv);
Index: interface.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.cpp,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- interface.cpp 7 Jan 2005 21:13:26 -0000 1.53
+++ interface.cpp 8 Jan 2005 20:30:06 -0000 1.54
@@ -758,7 +758,7 @@
drawPoint.x = x + col * width;
drawPoint.y = y + row * height;
- _vm->_sprite->draw(back_buf, _vm->_mainSprites,
+ _vm->_sprite->draw(back_buf, _vm->_sprite->_mainSprites,
ObjectTable[_inventory[i]].spritelistRn,
drawPoint, 256);
Index: interface.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- interface.h 7 Jan 2005 00:57:43 -0000 1.22
+++ interface.h 8 Jan 2005 20:30:06 -0000 1.23
@@ -150,7 +150,7 @@
int set_button;
int nbuttons;
INTERFACE_BUTTON *buttons;
- SPRITELIST *sprites;
+ SpriteList *sprites;
};
struct INTERFACE_DESC {
@@ -252,8 +252,8 @@
char _statusText[STATUS_TEXT_LEN];
int _leftPortrait;
int _rightPortrait;
- SPRITELIST *_defPortraits;
- SPRITELIST *_scenePortraits;
+ SpriteList *_defPortraits;
+ SpriteList *_scenePortraits;
int _activeVerb;
SCRIPT_THREAD *_iThread;
Index: render.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/render.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- render.h 6 Jan 2005 19:15:01 -0000 1.21
+++ render.h 8 Jan 2005 20:30:06 -0000 1.22
@@ -83,7 +83,7 @@
int _tmp_buf_w;
int _tmp_buf_h;
- SPRITELIST *_test_sprite;
+ SpriteList *_test_sprite;
unsigned int _fps;
unsigned int _framecount;
Index: resnames.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/resnames.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- resnames.h 1 Jan 2005 16:18:36 -0000 1.17
+++ resnames.h 8 Jan 2005 20:30:06 -0000 1.18
@@ -55,6 +55,8 @@
#define RID_ITE_SETUP_PANEL 5
#define RID_ITE_MAIN_SPRITES 6
+#define RID_ITE_MAIN_STRINGS 35 //main strings
+#define RID_ITE_ACTOR_NAMES 36 //actors names
#define RID_ITE_COMMAND_BUTTONSPRITES 7
#define RID_ITE_DEFAULT_PORTRAITS 125
Index: saga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.cpp,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- saga.cpp 7 Jan 2005 15:49:47 -0000 1.81
+++ saga.cpp 8 Jan 2005 20:30:06 -0000 1.82
@@ -219,8 +219,6 @@
_previousTicks = _system->getMillis();
- _sprite->loadList(RID_ITE_MAIN_SPRITES, &_mainSprites);
-
// Begin Main Engine Loop
_scene->startScene();
@@ -285,4 +283,49 @@
_system->quit();
}
+void SagaEngine::loadStrings(StringsList &stringsList, const byte *stringsPointer, size_t stringsLength) {
+ uint16 stringsCount;
+ uint16 i;
+ size_t offset;
+
+
+ stringsList.stringsPointer = (byte*)malloc(stringsLength);
+ memcpy(stringsList.stringsPointer, stringsPointer, stringsLength);
+
+ MemoryReadStreamEndian scriptS(stringsList.stringsPointer, stringsLength, IS_BIG_ENDIAN);
+
+ offset = scriptS.readUint16();
+ if (offset > stringsLength) {
+ error("Invalid string offset");
+ }
+
+ stringsCount = offset / 2;
+ stringsList.stringsCount = stringsCount;
+
+ stringsList.strings = (const char **)malloc(stringsCount * sizeof(const char *));
+ if (stringsList.strings == NULL) {
+ error("No enough memory for strings list");
+ }
+
+ scriptS.seek(0);
+ for (i = 0; i < stringsCount; i++) {
+ offset = scriptS.readUint16();
+ if (offset > stringsLength) {
+ error("invalid string offset");
+ }
+ stringsList.strings[i] = (const char *)stringsList.stringsPointer + offset;
+ }
+}
+
+const char *SagaEngine::getObjectName(uint16 objectId) {
+
+ switch (objectIdType(objectId)) {
+ case kGameObjectActor:
+ return _actor->getActorName(objectId);
+ break;
+ }
+ //todo: object name & etc
+ return NULL;
+}
+
} // End of namespace Saga
Index: saga.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.h,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- saga.h 7 Jan 2005 15:49:47 -0000 1.65
+++ saga.h 8 Jan 2005 20:30:06 -0000 1.66
@@ -39,6 +39,7 @@
#include "saga/text.h"
#include "saga/gfx.h"
+#include "saga/list.h"
namespace Saga {
@@ -63,8 +64,13 @@
#define PBOUNDS(n,max) (((n)>=(0))&&((n)<(max)))
#define MAXPATH 512
+#define IS_BIG_ENDIAN ((_vm->_features & GF_BIG_ENDIAN_DATA) != 0)
+
+#define ID_NOTHING 0
+#define ID_PROTAG 1
+
struct RSCFILE_CONTEXT;
-struct SPRITELIST;
+struct StringList;
enum ERRORCODE {
MEM = -2,
@@ -77,6 +83,14 @@
GType_IHNM
};
+enum GameObjectTypes {
+ kGameObjectNone = 0,
+ kGameObjectActor = 1,
+ kGameObjectObject = 2,
+ kGameObjectHitZone = 3,
+ kGameObjectStepZone = 4
+};
+
enum scriptTimings {
kScriptTimeTicksPerSecond = (728L/10L),
kRepeatSpeed = 40, // 25 frames/sec
@@ -109,15 +123,33 @@
kHitZoneTerminus = (1 << 3)
};
+struct StringsList {
+ byte *stringsPointer;
+ int stringsCount;
+ const char **strings;
+
+ const char *getString(int index) const {
+ if (stringsCount <= index)
+ error("StringList::getString wrong index 0x%X", index);
+ return strings[index];
+ }
+
+ void freeMem() {
+ free(strings);
+ free(stringsPointer);
+ memset(this, 0, sizeof(*this));
+ }
+
+ StringsList() {
+ memset(this, 0, sizeof(*this));
+ }
+};
+
struct CLICKAREA {
int n_points;
Point *points;
};
-
-#define IS_BIG_ENDIAN ((_vm->_features & GF_BIG_ENDIAN_DATA) != 0)
-
-
enum GAME_IDS {
// Dreamers Guild
GID_ITE_DEMO_G = 0,
@@ -236,6 +268,10 @@
return ((i1) > (i2) ? 1 : ((i1) < (i2) ? -1 : 0));
}
+inline int objectIdType(uint16 objectId) {
+ return objectId >> 13;
+}
+
class SagaEngine : public Engine {
void errorString(const char *buf_input, char *buf_output);
@@ -273,7 +309,6 @@
Events *_events;
PalAnim *_palanim;
- SPRITELIST *_mainSprites;
/** Random number generator */
Common::RandomSource _rnd;
@@ -288,6 +323,8 @@
int decodeBGImage(const byte *image_data, size_t image_size,
byte **output_buf, size_t *output_buf_len, int *w, int *h);
const byte *getImagePal(const byte *image_data, size_t image_size);
+ void loadStrings(StringsList &stringsList, const byte *stringsPointer, size_t stringsLength);
+ const char *getObjectName(uint16 objectId);
public:
TEXTLIST *textCreateList();
Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/script.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- script.cpp 3 Jan 2005 21:17:32 -0000 1.42
+++ script.cpp 8 Jan 2005 20:30:06 -0000 1.43
@@ -30,6 +30,7 @@
#include "saga/script.h"
#include "saga/stream.h"
+#include "saga/interface.h"
namespace Saga {
@@ -38,11 +39,14 @@
Script::Script() {
GAME_RESOURCEDESC gr_desc;
RSCFILE_CONTEXT *s_lut_ctxt;
+ RSCFILE_CONTEXT *resourceContext;
byte *rsc_ptr;
size_t rsc_len;
int prevTell;
int result;
int i, j;
+ byte *stringsPointer;
+ size_t stringsLength;
//initialize member variables
_dbg_thread = 0;
@@ -54,6 +58,11 @@
_abortEnabled = true;
_skipSpeeches = false;
+ _currentVerb = kVerbNone;
+ _stickyVerb = kVerbWalkTo;
+ _leftButtonVerb = kVerbNone;
+ _rightButtonVerb = kVerbNone;
+
_dataBuf[0].data = _dataBuf[1].data = (ScriptDataWord *)calloc(SCRIPT_DATABUF_LEN, sizeof(ScriptDataWord));;
_dataBuf[0].length = _dataBuf[1].length = SCRIPT_DATABUF_LEN;
@@ -131,6 +140,16 @@
setupScriptFuncList();
+ resourceContext = _vm->getFileContext(GAME_RESOURCEFILE, 0);
+
+ result = RSC_LoadResource(resourceContext, RID_ITE_MAIN_STRINGS, &stringsPointer, &stringsLength); // fixme: IHNM
+ if ((result != SUCCESS) || (stringsLength == 0)) {
+ error("Error loading strings list resource");
+ }
+
+ _vm->loadStrings(_mainStrings, stringsPointer, stringsLength);
+ RSC_FreeResource(stringsPointer);
+
_initialized = true;
}
@@ -142,6 +161,8 @@
}
debug(0, "Shutting down scripting subsystem.");
+
+ _mainStrings.freeMem();
// Free script lookup table
free(_scriptLUT);
@@ -238,7 +259,7 @@
// Loads a script; including script bytecode and dialogue list
int Script::loadScript(int script_num) {
- SCRIPTDATA *script_data;
+ ScriptData *script_data;
byte *bytecode_p;
size_t bytecode_len;
uint32 scriptl_rn;
@@ -266,15 +287,14 @@
// Initialize script data structure
debug(0, "Loading script data for script #%d", script_num);
- script_data = (SCRIPTDATA *)malloc(sizeof(*script_data));
+ script_data = (ScriptData *)malloc(sizeof(*script_data));
if (script_data == NULL) {
error("Memory allocation failed");
}
script_data->loaded = 0;
- // Initialize script pointers
- script_data->strings = NULL;
+ // Initialize script pointers
script_data->bytecode = NULL;
script_data->voice = NULL;
@@ -304,8 +324,9 @@
}
// Convert strings list resource to logical strings list
- loadStrings(stringsPointer, stringsLength, script_data->strings);
-
+ _vm->loadStrings(script_data->strings, stringsPointer, stringsLength);
+ RSC_FreeResource(stringsPointer);
+
// Load voice resource lookup table
if (_voiceLUTPresent) {
voicelut_rn = _scriptLUT[script_num].voice_lut_rn;
@@ -343,10 +364,7 @@
debug(0, "Releasing script data.");
// Finish initialization
- if (_currentScript->strings != NULL) {
- free(_currentScript->strings->strings);
- }
- free(_currentScript->strings);
+ _currentScript->strings.freeMem();
if (_currentScript->bytecode != NULL) {
free(_currentScript->bytecode->entrypoints);
@@ -446,59 +464,10 @@
return bc_new_data;
}
-const char *Script::getString(int index) {
- if (_currentScript->strings->stringsCount <= index)
- error("Script::getString wrong index 0x%X", index);
- return _currentScript->strings->strings[index];
-}
-
-// Reads a logical strings list from a strings list resource in memory.
-// Returns NULL on failure.
-void Script::loadStrings(const byte *stringsPointer, size_t stringsLength, StringsList *&strings) {
- uint16 stringsCount;
- uint16 i;
- size_t offset;
-
- debug(9, "Loading strings list...");
-
- // Allocate dialogue list structure
- strings = (StringsList *)malloc(sizeof(*strings));
- if (strings == NULL) {
- error("No enough memory for strings list");
- }
-
- MemoryReadStreamEndian scriptS(stringsPointer, stringsLength, IS_BIG_ENDIAN);
-
- // First uint16 is the offset of the first string
- offset = scriptS.readUint16();
- if (offset > stringsLength) {
- error("Invalid string offset");
- }
-
- // Calculate table length
- stringsCount = offset / 2;
- strings->stringsCount = stringsCount;
-
- // Allocate table of string pointers
- strings->strings = (const char **)malloc(stringsCount * sizeof(const char *));
- if (strings->strings == NULL) {
- error("No enough memory for strings list");
- }
-
- // Read in tables from dialogue list resource
- scriptS.seek(0);
- for (i = 0; i < stringsCount; i++) {
- offset = scriptS.readUint16();
- if (offset > stringsLength) {
- error("invalid string offset");
- }
- strings->strings[i] = (const char *)stringsPointer + offset;
- }
-}
// Reads a logical voice LUT from a voice LUT resource in memory.
// Returns NULL on failure.
-VOICE_LUT *Script::loadVoiceLUT(const byte *voicelut_p, size_t voicelut_len, SCRIPTDATA *script) {
+VOICE_LUT *Script::loadVoiceLUT(const byte *voicelut_p, size_t voicelut_len, ScriptData *script) {
VOICE_LUT *voice_lut;
uint16 i;
@@ -509,7 +478,7 @@
}
voice_lut->n_voices = voicelut_len / 2;
- if (voice_lut->n_voices != script->strings->stringsCount) {
+ if (voice_lut->n_voices != script->strings.stringsCount) {
warning("Error: Voice LUT entries do not match dialogue entries");
return NULL;
}
@@ -588,6 +557,74 @@
SThreadExecute(_dbg_thread, ep_num);
}
+// verb
+void Script::showVerb() {
+ const char *verbName;
+ const char *object1Name;
+ const char *object2Name;
+ char statusString[STATUS_TEXT_LEN];
+
+
+ if (_leftButtonVerb == kVerbNone) {
+ _vm->_interface->setStatusText("");
+ return;
+ }
+
+ verbName = _mainStrings.getString(_leftButtonVerb - 1);
+
+ if (objectIdType(_currentObject[0]) == kGameObjectNone) {
+ _vm->_interface->setStatusText(verbName);
+ return;
+ }
+
+ object1Name = _vm->getObjectName(_currentObject[0]);
+
+ if (!_secondObjectNeeded) {
+ snprintf(statusString, STATUS_TEXT_LEN, "%s %s", verbName, object1Name);
+ _vm->_interface->setStatusText(statusString);
+ return;
+ }
+
+
+ if (objectIdType(_currentObject[1]) != kGameObjectNone) {
+ object2Name = _vm->getObjectName(_currentObject[1]);
+ } else {
+ object2Name = "";
+ }
+
+ if (_leftButtonVerb == kVerbGive) {
+ snprintf(statusString, STATUS_TEXT_LEN, "Give %s to %s", object1Name, object2Name);
+ _vm->_interface->setStatusText(statusString);
+ } else {
+ if (_leftButtonVerb == kVerbUse) {
+ snprintf(statusString, STATUS_TEXT_LEN, "Use %s with %s", object1Name, object2Name);
+ _vm->_interface->setStatusText(statusString);
+ } else {
+ snprintf(statusString, STATUS_TEXT_LEN, "%s %s", verbName, object1Name);
+ _vm->_interface->setStatusText(statusString);
+ }
+ }
+}
+
+void Script::setVerb(int verb) {
+ _pendingObject[0] = ID_NOTHING;
+ _currentObject[0] = ID_NOTHING;
+ _pendingObject[1] = ID_NOTHING;
+ _currentObject[1] = ID_NOTHING;
+ _firstObjectSet = false;
+ _secondObjectNeeded = false;
+
+ setLeftButtonVerb( verb );
+ showVerb();
+}
+
+void Script::setLeftButtonVerb(int verb) {
+}
+
+void Script::doVerb() {
+}
+
+// console wrappers
void Script::CF_script_togglestep() {
_dbg_singlestep = !_dbg_singlestep;
}
Index: script.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/script.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- script.h 6 Jan 2005 19:15:01 -0000 1.48
+++ script.h 8 Jan 2005 20:30:06 -0000 1.49
@@ -199,20 +199,15 @@
PROC_TBLENTRY *entrypoints;
};
-struct StringsList {
- int stringsCount;
- const char **strings;
-};
-
struct VOICE_LUT {
int n_voices;
int *voices;
};
-struct SCRIPTDATA {
+struct ScriptData {
int loaded;
SCRIPT_BYTECODE *bytecode;
- StringsList *strings;
+ StringsList strings;
VOICE_LUT *voice;
};
@@ -239,19 +234,23 @@
int loadScript(int scriptNum);
int freeScript();
SCRIPT_BYTECODE *loadBytecode(byte *bytecode_p, size_t bytecode_len);
- void loadStrings(const byte *stringsList, size_t stringsLength, StringsList *&strings);
- VOICE_LUT *loadVoiceLUT(const byte *voicelut_p, size_t voicelut_len, SCRIPTDATA *script);
+ VOICE_LUT *loadVoiceLUT(const byte *voicelut_p, size_t voicelut_len, ScriptData *script);
int disassemble(SCRIPT_BYTECODE *script_list, StringsList *strings);
bool isInitialized() const { return _initialized; }
bool isVoiceLUTPresent() const { return _voiceLUTPresent; }
- SCRIPTDATA *currentScript() { return _currentScript; }
+ ScriptData *currentScript() { return _currentScript; }
ScriptDataBuf *dataBuffer(int idx) { return &_dataBuf[idx]; }
int getWord(int bufNumber, int wordNumber, ScriptDataWord *data);
int putWord(int bufNumber, int wordNumber, ScriptDataWord data);
int setBit(int bufNumber, ScriptDataWord bitNumber, int bitState);
int getBit(int bufNumber, ScriptDataWord bitNumber, int *bitState);
- const char *getString(int index);
+ const char * getScriptString(int index) const { return _currentScript->strings.getString(index); }
+
+ void doVerb();
+ void showVerb();
+ void setVerb(int verb);
+ void setLeftButtonVerb(int verb);
void scriptInfo();
void scriptExec(int argc, const char **argv);
@@ -263,10 +262,22 @@
SCRIPT_LUT_ENTRY *_scriptLUT;
int _scriptLUTMax;
uint16 _scriptLUTEntryLen;
- SCRIPTDATA *_currentScript;
+ ScriptData *_currentScript;
ScriptDataBuf _dataBuf[SCRIPT_DATABUF_NUM];
ScriptThreadList _threadList;
+ StringsList _mainStrings;
+//verb
+ bool _firstObjectSet;
+ bool _secondObjectNeeded;
+ uint16 _currentObject[2];
+ uint16 _pendingObject[2];
+ int _currentVerb;
+ int _stickyVerb;
+ int _leftButtonVerb;
+ int _rightButtonVerb;
+ int _pendingVerb;
+
public:
bool _skipSpeeches;
Index: sfuncs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sfuncs.cpp,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- sfuncs.cpp 7 Jan 2005 22:18:53 -0000 1.73
+++ sfuncs.cpp 8 Jan 2005 20:30:06 -0000 1.74
@@ -135,7 +135,7 @@
int Script::SF_putString(SCRIPTFUNC_PARAMS) {
ScriptDataWord param = thread->pop();
- _vm->_console->DebugPrintf(getString(param));
+ _vm->_console->DebugPrintf(getScriptString(param));
return SUCCESS;
}
@@ -189,7 +189,7 @@
int Script::sfStatusBar(SCRIPTFUNC_PARAMS) {
ScriptDataWord param = thread->pop();
- return _vm->_interface->setStatusText(getString(param));
+ return _vm->_interface->setStatusText(getScriptString(param));
}
// Script function #5 (0x05)
@@ -352,7 +352,7 @@
actorId = getSWord(thread->pop());
targetObject = getSWord(thread->pop());
- debug(1, "sfSetFollower(%d, %d) [%d]", actorId, targetObject, ACTOR_ID_TO_INDEX(actorId));
+ debug(1, "sfSetFollower(%d, %d) [%d]", actorId, targetObject, _vm->_actor->actorIdToIndex(actorId));
actor = _vm->_actor->getActor(actorId);
actor->targetObject = targetObject;
@@ -738,7 +738,7 @@
for (i = 0; i < actorsCount; i++)
actorsIds[i] = getSWord(thread->pop());
- string = getString(stringId);
+ string = getScriptString(stringId);
_vm->_actor->simulSpeech(string, actorsIds, actorsCount, 0);
return SUCCESS;
@@ -1080,7 +1080,7 @@
text_entry.text_y = (disp.scene_h - _vm->_font->getHeight(MEDIUM_FONT_ID)) / 2;
text_entry.font_id = MEDIUM_FONT_ID;
text_entry.flags = FONT_OUTLINE | FONT_CENTERED;
- text_entry.string = getString(stringId);
+ text_entry.string = getScriptString(stringId);
placardTextEntry = _vm->textAddEntry(scene_info.text_list, &text_entry);
Index: sprite.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sprite.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- sprite.cpp 4 Jan 2005 17:15:53 -0000 1.37
+++ sprite.cpp 8 Jan 2005 20:30:06 -0000 1.38
@@ -52,6 +52,8 @@
return;
}
+ loadList(RID_ITE_MAIN_SPRITES, &_mainSprites); //fixme: IHNM may have no such list
+
_initialized = true;
}
@@ -65,8 +67,8 @@
free(_decodeBuf);
}
-int Sprite::loadList(int resource_num, SPRITELIST **sprite_list_p) {
- SPRITELIST *new_slist;
+int Sprite::loadList(int resource_num, SpriteList **sprite_list_p) {
+ SpriteList *new_slist;
byte *spritelist_data;
size_t spritelist_len;
uint16 sprite_count;
@@ -83,7 +85,7 @@
sprite_count = readS.readUint16();
- new_slist = (SPRITELIST *)malloc(sizeof(*new_slist));
+ new_slist = (SpriteList *)malloc(sizeof(*new_slist));
if (new_slist == NULL) {
return MEM;
}
@@ -113,7 +115,7 @@
return SUCCESS;
}
-int Sprite::appendList(int resource_num, SPRITELIST *spritelist) {
+int Sprite::appendList(int resource_num, SpriteList *spritelist) {
byte *spritelist_data;
size_t spritelist_len;
void *test_p;
@@ -157,11 +159,11 @@
return SUCCESS;
}
-int Sprite::getListLen(SPRITELIST *spritelist) {
+int Sprite::getListLen(SpriteList *spritelist) {
return spritelist->sprite_count;
}
-int Sprite::freeSprite(SPRITELIST *spritelist) {
+int Sprite::freeSprite(SpriteList *spritelist) {
int i;
for (i = 0; i <= spritelist->append_count; i++) {
@@ -175,7 +177,7 @@
return SUCCESS;
}
-int Sprite::draw(SURFACE *ds, SPRITELIST *sprite_list, int sprite_num, const Point &screenCoord, int scale) {
+int Sprite::draw(SURFACE *ds, SpriteList *sprite_list, int sprite_num, const Point &screenCoord, int scale) {
int offset;
int offset_idx;
byte *sprite_p;
@@ -266,7 +268,7 @@
return SUCCESS;
}
-int Sprite::drawOccluded(SURFACE *ds, SPRITELIST *sprite_list, int sprite_num, const Point &screenCoord, int scale, int depth) {
+int Sprite::drawOccluded(SURFACE *ds, SpriteList *sprite_list, int sprite_num, const Point &screenCoord, int scale, int depth) {
int offset;
int offset_idx;
byte *sprite_p;
Index: sprite.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sprite.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- sprite.h 4 Jan 2005 17:15:53 -0000 1.12
+++ sprite.h 8 Jan 2005 20:30:06 -0000 1.13
@@ -48,7 +48,7 @@
uint32 offset;
};
-struct SPRITELIST {
+struct SpriteList {
int append_count;
int sprite_count;
SPRITELIST_OFFSET *offset_list;
@@ -58,17 +58,19 @@
class Sprite {
- public:
+public:
+ SpriteList *_mainSprites;
+
Sprite(SagaEngine *vm);
~Sprite(void);
- int loadList(int resource_num, SPRITELIST **sprite_list_p);
- int appendList(int resource_num, SPRITELIST *spritelist);
- int getListLen(SPRITELIST *spritelist);
- int freeSprite(SPRITELIST *spritelist);
- int draw(SURFACE *ds, SPRITELIST *sprite_list, int sprite_num, const Point &screenCoord, int scale);
- int drawOccluded(SURFACE *ds, SPRITELIST *sprite_list, int sprite_num, const Point &screenCoord, int scale, int depth);
+ int loadList(int resource_num, SpriteList **sprite_list_p);
+ int appendList(int resource_num, SpriteList *spritelist);
+ int getListLen(SpriteList *spritelist);
+ int freeSprite(SpriteList *spritelist);
+ int draw(SURFACE *ds, SpriteList *sprite_list, int sprite_num, const Point &screenCoord, int scale);
+ int drawOccluded(SURFACE *ds, SpriteList *sprite_list, int sprite_num, const Point &screenCoord, int scale, int depth);
- private:
+private:
int decodeRLESprite(const byte *inbuf, size_t inbuf_len, byte *outbuf, size_t outbuf_len);
void scaleSprite(byte *buf, int width, int height, int scale);
void scaleSpriteCoords(int scale, int *width, int *height, int *x_align, int *y_align);
Index: sthread.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sthread.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- sthread.cpp 6 Jan 2005 14:02:53 -0000 1.55
+++ sthread.cpp 8 Jan 2005 20:30:07 -0000 1.56
@@ -754,7 +754,7 @@
data = first = thread->stackTop();
for (i = 0; i < stringsCount; i++) {
data = thread->pop();
- strings[i] = getString(data);
+ strings[i] = getScriptString(data);
}
// now data contains last string index
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/base main.cpp,1.60.2.2,1.60.2.3
- Next message: [Scummvm-cvs-logs] CVS: scummvm/saga actor.h,1.43,1.44 saga.cpp,1.82,1.83 saga.h,1.66,1.67 script.h,1.49,1.50
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list