[Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.23,1.24 input.cpp,1.11,1.12 interface.cpp,1.20,1.21 interface.h,1.5,1.6 saga.cpp,1.46,1.47 scene.cpp,1.34,1.35 script.cpp,1.20,1.21 script.h,1.12,1.13 sdata.cpp,1.13,1.14 sdata.h,1.4,1.5 sdebug.cpp,1.16,1.17 sfuncs.cpp,1.15,1.16 sthread.cpp,1.21,1.22 script_mod.h,1.6,NONE sfuncs.h,1.5,NONE sthread.h,1.8,NONE
Eugene Sandulenko
sev at users.sourceforge.net
Thu Aug 12 16:59:08 CEST 2004
Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3565
Modified Files:
actor.cpp input.cpp interface.cpp interface.h saga.cpp
scene.cpp script.cpp script.h sdata.cpp sdata.h sdebug.cpp
sfuncs.cpp sthread.cpp
Removed Files:
script_mod.h sfuncs.h sthread.h
Log Message:
Merge SDEBUG_*, SF_* and STHREAD_* into Script class.
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- actor.cpp 10 Aug 2004 18:31:32 -0000 1.23
+++ actor.cpp 12 Aug 2004 23:57:45 -0000 1.24
@@ -29,7 +29,7 @@
#include "saga/cvar_mod.h"
#include "saga/console.h"
#include "saga/rscfile_mod.h"
-#include "saga/script_mod.h"
+#include "saga/script.h"
#include "saga/sndres.h"
#include "saga/sprite.h"
#include "saga/font.h"
@@ -282,7 +282,7 @@
if (a_dnode != NULL) {
a_dialogue = (R_ACTORDIALOGUE *)ys_dll_get_data(a_dnode);
if (a_dialogue->d_sem != NULL) {
- STHREAD_ReleaseSem(a_dialogue->d_sem);
+ _vm->_script->SThreadReleaseSem(a_dialogue->d_sem);
}
ys_dll_delete(a_dnode);
// And stop any currently playing voices
@@ -471,7 +471,7 @@
}
if (sem != NULL) {
- STHREAD_HoldSem(sem);
+ _vm->_script->SThreadHoldSem(sem);
}
return R_SUCCESS;
@@ -513,7 +513,7 @@
//actor->action = ACTION_IDLE;
if (a_dialogue->d_sem != NULL) {
- STHREAD_ReleaseSem(a_dialogue->d_sem);
+ _vm->_script->SThreadReleaseSem(a_dialogue->d_sem);
}
carry_time = a_dialogue->d_time;
@@ -770,7 +770,7 @@
ys_dll_add_tail(actor->a_intentlist, &actor_intent, sizeof actor_intent);
if (sem != NULL) {
- STHREAD_HoldSem(sem);
+ _vm->_script->SThreadHoldSem(sem);
}
return R_SUCCESS;
@@ -848,7 +848,7 @@
// Release path semaphore
if ((a_walkint->sem != NULL) && a_walkint->sem_held) {
- STHREAD_ReleaseSem(a_walkint->sem);
+ _vm->_script->SThreadReleaseSem(a_walkint->sem);
}
*complete_p = 1;
@@ -915,7 +915,7 @@
// Release path semaphore
if (a_walkint->sem != NULL) {
- STHREAD_ReleaseSem(a_walkint->sem);
+ _vm->_script->SThreadReleaseSem(a_walkint->sem);
}
actor->action_frame = 0;
@@ -931,7 +931,7 @@
// Release path semaphore
if (a_walkint->sem != NULL) {
- STHREAD_ReleaseSem(a_walkint->sem);
+ _vm->_script->SThreadReleaseSem(a_walkint->sem);
}
actor->action_frame = 0;
Index: input.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/input.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- input.cpp 11 Aug 2004 14:04:12 -0000 1.11
+++ input.cpp 12 Aug 2004 23:57:45 -0000 1.12
@@ -28,6 +28,7 @@
#include "saga/interface.h"
#include "saga/render.h"
#include "saga/scene.h"
+#include "saga/script.h"
namespace Saga {
@@ -90,7 +91,7 @@
_vm->_render->toggleFlag(RF_OBJECTMAP_TEST);
break;
case 9: // Tab
- STHREAD_DebugStep();
+ _vm->_script->SThreadDebugStep();
break;
// Actual game keys
Index: interface.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- interface.cpp 10 Aug 2004 18:31:32 -0000 1.20
+++ interface.cpp 12 Aug 2004 23:57:45 -0000 1.21
@@ -32,7 +32,7 @@
#include "saga/font.h"
#include "saga/objectmap.h"
#include "saga/rscfile_mod.h"
-#include "saga/script_mod.h"
+#include "saga/script.h"
#include "saga/sprite.h"
#include "saga/interface.h"
@@ -142,7 +142,7 @@
return;
}
- _iThread = STHREAD_Create();
+ _iThread = _vm->_script->SThreadCreate();
if (_iThread == NULL) {
warning("Interface::Interface(): Error creating script thread for game interface module");
return;
@@ -504,7 +504,7 @@
// Execute object script if present
if (script_num != 0) {
- STHREAD_Execute(_iThread, script_num);
+ _vm->_script->SThreadExecute(_iThread, script_num);
}
}
} else {
Index: interface.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- interface.h 6 Aug 2004 01:39:17 -0000 1.5
+++ interface.h 12 Aug 2004 23:57:45 -0000 1.6
@@ -27,7 +27,7 @@
#define SAGA_INTERFACE_H__
#include "saga/sprite.h"
-#include "saga/script_mod.h"
+#include "saga/script.h"
namespace Saga {
Index: saga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- saga.cpp 11 Aug 2004 22:27:38 -0000 1.46
+++ saga.cpp 12 Aug 2004 23:57:45 -0000 1.47
@@ -47,7 +47,6 @@
#include "saga/interface.h"
#include "saga/isomap.h"
#include "saga/script.h"
-#include "saga/script_mod.h"
#include "saga/scene.h"
#include "saga/sdata.h"
#include "saga/sndres.h"
@@ -228,8 +227,8 @@
msec = R_MAX_TIME_DELTA;
}
_actor->direct(msec);
- _vm->_events->handleEvents(msec);
- STHREAD_ExecThreads(msec);
+ _events->handleEvents(msec);
+ _script->SThreadExecThreads(msec);
}
// Per frame processing
_render->drawScene();
Index: scene.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/scene.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- scene.cpp 12 Aug 2004 01:11:10 -0000 1.34
+++ scene.cpp 12 Aug 2004 23:57:45 -0000 1.35
@@ -33,7 +33,6 @@
#include "saga/events.h"
#include "saga/actionmap.h"
#include "saga/isomap.h"
-#include "saga/script_mod.h"
#include "saga/objectmap.h"
#include "saga/palanim.h"
#include "saga/render.h"
@@ -953,13 +952,13 @@
debug(0, "Starting start script #%d", _desc.startScriptNum);
- _startScriptThread= STHREAD_Create();
+ _startScriptThread = _vm->_script->SThreadCreate();
if (_startScriptThread == NULL) {
_vm->_console->print("Thread creation failed.");
break;
}
- STHREAD_Execute(_startScriptThread, _desc.startScriptNum);
- STHREAD_completeThread();
+ _vm->_script->SThreadExecute(_startScriptThread, _desc.startScriptNum);
+ _vm->_script->SThreadCompleteThread();
}
debug(0, "Scene started");
Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/script.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- script.cpp 12 Aug 2004 21:39:11 -0000 1.20
+++ script.cpp 12 Aug 2004 23:57:45 -0000 1.21
@@ -31,9 +31,7 @@
#include "saga/console.h"
#include "saga/cvar_mod.h"
-#include "saga/script_mod.h"
#include "saga/script.h"
-#include "saga/sthread.h"
namespace Saga {
@@ -129,6 +127,8 @@
// Initialize script submodules
_threadList = ys_dll_create();
+ setupScriptFuncList();
+
_initialized = true;
}
@@ -151,7 +151,7 @@
for (thread_node = ys_dll_head(_threadList); thread_node != NULL;
thread_node = ys_dll_next(thread_node)) {
thread = (R_SCRIPT_THREAD *)ys_dll_get_data(thread_node);
- STHREAD_Destroy(thread);
+ SThreadDestroy(thread);
}
_initialized = false;
@@ -520,7 +520,7 @@
if (_dbg_thread == NULL) {
_vm->_console->print("Creating debug thread...");
- _dbg_thread = STHREAD_Create();
+ _dbg_thread = SThreadCreate();
if (_dbg_thread == NULL) {
_vm->_console->print("Thread creation failed.");
return;
@@ -532,7 +532,7 @@
return;
}
- STHREAD_Execute(_dbg_thread, ep_num);
+ SThreadExecute(_dbg_thread, ep_num);
}
void CF_script_info(int argc, char *argv[], void *refCon) {
Index: script.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/script.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- script.h 12 Aug 2004 21:39:11 -0000 1.12
+++ script.h 12 Aug 2004 23:57:45 -0000 1.13
@@ -26,12 +26,15 @@
#ifndef SAGA_SCRIPT_H
#define SAGA_SCRIPT_H
-#include "saga/sdata.h"
#include "saga/text.h"
#include "saga/yslib.h"
+#include "common/stack.h"
namespace Saga {
+#define R_SCRIPT_DATABUF_NUM 5
+#define R_SCRIPT_DATABUF_LEN 1024
+
#define R_S_LUT_ENTRYLEN_ITECD 22
#define R_S_LUT_ENTRYLEN_ITEDISK 16
@@ -47,6 +50,41 @@
#define S_ERROR_PREFIX "SError: "
#define S_WARN_PREFIX "SWarning: "
+#define R_SFUNC_NUM 78
+
+typedef unsigned int SDataWord_T;
+
+enum R_SCRIPT_VERBS {
+ S_VERB_WALKTO = 0,
+ S_VERB_LOOKAT = 2,
+ S_VERB_PICKUP = 1,
+ S_VERB_TALKTO,
+ S_VERB_OPEN = 5,
+ S_VERB_CLOSE = 6,
+ S_VERB_USE = 8,
+ S_VERB_GIVE
+};
+
+#define STHREAD_DEF_INSTR_COUNT 8
+
+struct R_SEMAPHORE {
+ int hold_count;
+};
+
+struct R_SCRIPT_THREAD_tag {
+ int executing;
+
+ int sleep_time;
+ int ep_num; // Entrypoint number
+ unsigned long ep_offset; // Entrypoint offset
+ unsigned long i_offset; // Instruction offset
+
+ R_SEMAPHORE sem;
+ Common::Stack<SDataWord_T> *stack;
+};
+
+typedef struct R_SCRIPT_THREAD_tag R_SCRIPT_THREAD;
+
struct R_PROC_TBLENTRY {
size_t name_offset;
size_t offset;
@@ -89,6 +127,7 @@
int len;
};
+#define R_SCRIPTFUNC_PARAMS R_SCRIPT_THREAD *thread
class Script {
public:
@@ -129,6 +168,69 @@
int _dbg_dostep;
R_SCRIPT_THREAD *_dbg_thread;
R_TEXTLIST_ENTRY *_dbg_txtentry;
+
+public:
+ R_SCRIPT_THREAD *SThreadCreate();
+ int SThreadExecute(R_SCRIPT_THREAD *thread, int ep_num);
+ int SThreadExecThreads(int msec);
+ int SThreadHoldSem(R_SEMAPHORE *sem);
+ int SThreadReleaseSem(R_SEMAPHORE *sem);
+ int SThreadDebugStep();
+ void SThreadCompleteThread(void);
+ int SThreadDestroy(R_SCRIPT_THREAD *thread);
+
+private:
+ unsigned char *SThreadGetReadPtr(R_SCRIPT_THREAD *thread);
+ unsigned long SThreadGetReadOffset(const byte *read_p);
+ size_t SThreadGetReadLen(R_SCRIPT_THREAD *thread);
+ int SThreadRun(R_SCRIPT_THREAD *thread, int instr_limit, int msec);
+ int SThreadSetEntrypoint(R_SCRIPT_THREAD *thread, int ep_num);
+
+private:
+ typedef int (Script::*SFunc_T)(R_SCRIPTFUNC_PARAMS);
+
+ struct R_SFUNC_ENTRY {
+ int sfunc_num;
+ int sfunc_argc;
+ SFunc_T sfunc_fp;
+ };
+
+ const R_SFUNC_ENTRY *_SFuncList;
+
+ void setupScriptFuncList(void);
+ int SDebugPrintInstr(R_SCRIPT_THREAD *thread);
+
+ int SF_sleep(R_SCRIPTFUNC_PARAMS);
+ int SF_3(R_SCRIPTFUNC_PARAMS);
+ int SF_setCommandText(R_SCRIPTFUNC_PARAMS);
+ int SF_actorWalkTo(R_SCRIPTFUNC_PARAMS);
+ int SF_setFacing(R_SCRIPTFUNC_PARAMS);
+ int SF_freezeInterface(R_SCRIPTFUNC_PARAMS);
+ int SF_startAnim(R_SCRIPTFUNC_PARAMS);
+ int SF_actorWalkToAsync(R_SCRIPTFUNC_PARAMS);
+ int SF_moveTo(R_SCRIPTFUNC_PARAMS);
+ int SF_actorWalk(R_SCRIPTFUNC_PARAMS);
+ int SF_cycleActorFrames(R_SCRIPTFUNC_PARAMS);
+ int SF_setFrame(R_SCRIPTFUNC_PARAMS);
+ int SF_linkAnim(R_SCRIPTFUNC_PARAMS);
+ int SF_placeActor(R_SCRIPTFUNC_PARAMS);
+ int SF_checkUserInterrupt(R_SCRIPTFUNC_PARAMS);
+ int SF_moveRelative(R_SCRIPTFUNC_PARAMS);
+ int SF_doAction(R_SCRIPTFUNC_PARAMS);
+ int SF_faceTowards(R_SCRIPTFUNC_PARAMS);
+ int SF_setFollower(R_SCRIPTFUNC_PARAMS);
+ int SF_centerActor(R_SCRIPTFUNC_PARAMS);
+ int SF_setActorState(R_SCRIPTFUNC_PARAMS);
+ int SF_swapActors(R_SCRIPTFUNC_PARAMS);
+ int SF_scriptSpecialWalk(R_SCRIPTFUNC_PARAMS);
+ int SF_walkRelative(R_SCRIPTFUNC_PARAMS);
+ int SF_throwActor(R_SCRIPTFUNC_PARAMS);
+ int SF_waitWalk(R_SCRIPTFUNC_PARAMS);
+ int SF_changeActorScene(R_SCRIPTFUNC_PARAMS);
+ int SF_climb(R_SCRIPTFUNC_PARAMS);
+ int SF_setActorZ(R_SCRIPTFUNC_PARAMS);
+ int SF_getActorX(R_SCRIPTFUNC_PARAMS);
+ int SF_getActorY(R_SCRIPTFUNC_PARAMS);
};
} // End of namespace Saga
Index: sdata.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sdata.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- sdata.cpp 3 Aug 2004 00:40:16 -0000 1.13
+++ sdata.cpp 12 Aug 2004 23:57:45 -0000 1.14
@@ -24,7 +24,6 @@
#include "saga/saga.h"
#include "saga/gfx.h"
-#include "saga/script_mod.h"
#include "saga/script.h"
#include "saga/sdata.h"
Index: sdata.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sdata.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sdata.h 1 Aug 2004 19:53:29 -0000 1.4
+++ sdata.h 12 Aug 2004 23:57:45 -0000 1.5
@@ -28,9 +28,6 @@
namespace Saga {
-#define R_SCRIPT_DATABUF_NUM 5
-#define R_SCRIPT_DATABUF_LEN 1024
-
class SData {
public:
SData();
Index: sdebug.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sdebug.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- sdebug.cpp 12 Aug 2004 21:39:11 -0000 1.16
+++ sdebug.cpp 12 Aug 2004 23:57:45 -0000 1.17
@@ -29,16 +29,14 @@
#include "saga/scene.h"
#include "saga/font.h"
-#include "saga/script_mod.h"
#include "saga/script.h"
-#include "saga/sthread.h"
namespace Saga {
#define SD_DISPLAY_LEN 128
#define SD_ADDTXT( x ) strncat( disp_buf, x, SD_DISPLAY_LEN );
-int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) {
+int Script::SDebugPrintInstr(R_SCRIPT_THREAD *thread) {
R_TEXTLIST_ENTRY tl_e;
char tmp_buf[80] = { 0 };
static char disp_buf[SD_DISPLAY_LEN] = { 0 };
@@ -52,9 +50,9 @@
disp_buf[0] = 0;
- if (_vm->_script->_dbg_txtentry != NULL) {
- _vm->textDeleteEntry(si.text_list, _vm->_script->_dbg_txtentry);
- _vm->_script->_dbg_txtentry = NULL;
+ if (_dbg_txtentry != NULL) {
+ _vm->textDeleteEntry(si.text_list, _dbg_txtentry);
+ _dbg_txtentry = NULL;
}
tl_e.color = 1;
@@ -66,9 +64,9 @@
tl_e.string = disp_buf;
tl_e.display = 1;
- MemoryReadStream readS(_vm->_script->currentScript()->bytecode->bytecode_p
+ MemoryReadStream readS(currentScript()->bytecode->bytecode_p
+ thread->i_offset,
- _vm->_script->currentScript()->bytecode->bytecode_len
+ currentScript()->bytecode->bytecode_len
- thread->i_offset);
in_char = readS.readByte();
sprintf(tmp_buf, "%04lX | %02X | ", thread->i_offset, in_char);
@@ -514,8 +512,8 @@
break;
}
- _vm->_script->_dbg_txtentry = _vm->textAddEntry(si.text_list, &tl_e);
- _vm->textSetDisplay(_vm->_script->_dbg_txtentry, 1);
+ _dbg_txtentry = _vm->textAddEntry(si.text_list, &tl_e);
+ _vm->textSetDisplay(_dbg_txtentry, 1);
return R_SUCCESS;
}
Index: sfuncs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sfuncs.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- sfuncs.cpp 12 Aug 2004 21:39:11 -0000 1.15
+++ sfuncs.cpp 12 Aug 2004 23:57:45 -0000 1.16
@@ -32,96 +32,102 @@
#include "saga/interface.h"
#include "saga/script.h"
-#include "saga/sfuncs.h"
+#include "saga/sdata.h"
+
#include "common/stack.h"
namespace Saga {
-R_SFUNC_ENTRY SFuncList[R_SFUNC_NUM] = {
- {0, 0, NULL},
- {1, 1, SF_sleep},
- {2, 0, NULL},
- {3, 1, SF_3},
- {4, 1, SF_setCommandText},
- {5, 0, NULL},
- {6, 3, SF_actorWalkTo},
- {7, 0, SF_doAction},
- {8, 2, SF_setFacing},
- {9, 0, NULL},
- {10, 0, NULL},
- {11, 1, SF_freezeInterface},
- {12, 0, NULL},
- {13, 0, NULL},
- {14, 0, SF_faceTowards},
- {15, 0, SF_setFollower},
- {16, 0, NULL},
- {17, 0, NULL},
- {18, 0, NULL},
- {19, 0, NULL},
- {20, 0, NULL},
- {21, 0, NULL},
- {22, 0, NULL},
- {23, 0, NULL},
- {24, 0, NULL},
- {25, 0, SF_centerActor},
- {26, 3, SF_startAnim},
- {27, 3, SF_actorWalkToAsync},
- {28, 0, NULL},
- {29, 0, SF_setActorState},
- {30, 3, SF_moveTo},
- {31, 0, NULL},
- {32, 0, NULL},
- {33, 0, NULL},
- {34, 0, SF_swapActors},
- {35, 0, NULL},
- {36, 4, SF_actorWalk},
- {37, 4, SF_cycleActorFrames},
- {38, 3, SF_setFrame},
- {39, 0, NULL},
- {40, 0, NULL},
- {41, 4, SF_linkAnim},
- {42, 0, SF_scriptSpecialWalk},
- {43, 6, SF_placeActor},
- {44, 0, SF_checkUserInterrupt},
- {45, 0, SF_walkRelative},
- {46, 0, SF_moveRelative},
- {47, 0, NULL},
- {48, 0, NULL},
- {49, 0, NULL},
- {50, 0, NULL},
- {51, 0, NULL},
- {52, 0, SF_throwActor},
- {53, 0, SF_waitWalk},
- {54, 0, NULL},
- {55, 0, SF_changeActorScene},
- {56, 0, SF_climb},
- {57, 0, NULL},
- {58, 0, SF_setActorZ},
- {59, 0, NULL},
- {60, 0, SF_getActorX},
- {61, 0, SF_getActorY},
- {62, 0, NULL},
- {63, 0, NULL},
- {64, 0, NULL},
- {65, 0, NULL},
- {66, 0, NULL},
- {67, 0, NULL},
- {68, 0, NULL},
- {69, 0, NULL},
- {70, 0, NULL},
- {71, 0, NULL},
- {72, 0, NULL},
- {73, 0, NULL},
- {74, 0, NULL},
- {75, 0, NULL},
- {76, 0, NULL},
- {77, 0, NULL}
-};
+#define OPCODE(x) &Script::x
+
+void Script::setupScriptFuncList(void) {
+ static const R_SFUNC_ENTRY SFuncList[R_SFUNC_NUM] = {
+ {0, 0, NULL},
+ {1, 1, OPCODE(SF_sleep)},
+ {2, 0, NULL},
+ {3, 1, OPCODE(SF_3)},
+ {4, 1, OPCODE(SF_setCommandText)},
+ {5, 0, NULL},
+ {6, 3, OPCODE(SF_actorWalkTo)},
+ {7, 0, OPCODE(SF_doAction)},
+ {8, 2, OPCODE(SF_setFacing)},
+ {9, 0, NULL},
+ {10, 0, NULL},
+ {11, 1, OPCODE(SF_freezeInterface)},
+ {12, 0, NULL},
+ {13, 0, NULL},
+ {14, 0, OPCODE(SF_faceTowards)},
+ {15, 0, OPCODE(SF_setFollower)},
+ {16, 0, NULL},
+ {17, 0, NULL},
+ {18, 0, NULL},
+ {19, 0, NULL},
+ {20, 0, NULL},
+ {21, 0, NULL},
+ {22, 0, NULL},
+ {23, 0, NULL},
+ {24, 0, NULL},
+ {25, 0, OPCODE(SF_centerActor)},
+ {26, 3, OPCODE(SF_startAnim)},
+ {27, 3, OPCODE(SF_actorWalkToAsync)},
+ {28, 0, NULL},
+ {29, 0, OPCODE(SF_setActorState)},
+ {30, 3, OPCODE(SF_moveTo)},
+ {31, 0, NULL},
+ {32, 0, NULL},
+ {33, 0, NULL},
+ {34, 0, OPCODE(SF_swapActors)},
+ {35, 0, NULL},
+ {36, 4, OPCODE(SF_actorWalk)},
+ {37, 4, OPCODE(SF_cycleActorFrames)},
+ {38, 3, OPCODE(SF_setFrame)},
+ {39, 0, NULL},
+ {40, 0, NULL},
+ {41, 4, OPCODE(SF_linkAnim)},
+ {42, 0, OPCODE(SF_scriptSpecialWalk)},
+ {43, 6, OPCODE(SF_placeActor)},
+ {44, 0, OPCODE(SF_checkUserInterrupt)},
+ {45, 0, OPCODE(SF_walkRelative)},
+ {46, 0, OPCODE(SF_moveRelative)},
+ {47, 0, NULL},
+ {48, 0, NULL},
+ {49, 0, NULL},
+ {50, 0, NULL},
+ {51, 0, NULL},
+ {52, 0, OPCODE(SF_throwActor)},
+ {53, 0, OPCODE(SF_waitWalk)},
+ {54, 0, NULL},
+ {55, 0, OPCODE(SF_changeActorScene)},
+ {56, 0, OPCODE(SF_climb)},
+ {57, 0, NULL},
+ {58, 0, OPCODE(SF_setActorZ)},
+ {59, 0, NULL},
+ {60, 0, OPCODE(SF_getActorX)},
+ {61, 0, OPCODE(SF_getActorY)},
+ {62, 0, NULL},
+ {63, 0, NULL},
+ {64, 0, NULL},
+ {65, 0, NULL},
+ {66, 0, NULL},
+ {67, 0, NULL},
+ {68, 0, NULL},
+ {69, 0, NULL},
+ {70, 0, NULL},
+ {71, 0, NULL},
+ {72, 0, NULL},
+ {73, 0, NULL},
+ {74, 0, NULL},
+ {75, 0, NULL},
+ {76, 0, NULL},
+ {77, 0, NULL}
+ };
+ _SFuncList = SFuncList;
+}
// Script function #1 (0x01) blocking
// Suspends thread execution for the specified time period
// Param1: time to suspend ( units? )
-int SF_sleep(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_sleep(R_SCRIPTFUNC_PARAMS) {
SDataWord_T time_param;
int time;
@@ -134,7 +140,7 @@
// Script function #3 (0x03)
// Unknown function; pops a parameter and pushes a return value
// Param1: unknown
-int SF_3(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_3(R_SCRIPTFUNC_PARAMS) {
// INCOMPLETE
SDataWord_T param1;
param1 = thread->stack->pop();
@@ -147,7 +153,7 @@
// Script function #4 (0x04) nonblocking
// Set the command display to the specified text string
// Param1: dialogue index of string
-int SF_setCommandText(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_setCommandText(R_SCRIPTFUNC_PARAMS) {
SDataWord_T s_idx_parm;
s_idx_parm = thread->stack->pop();
@@ -161,7 +167,7 @@
// Param1: actor id
// Param2: actor destination x
// Param3: actor destination y
-int SF_actorWalkTo(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_actorWalkTo(R_SCRIPTFUNC_PARAMS) {
SDataWord_T actor_parm;
SDataWord_T x_parm;
SDataWord_T y_parm;
@@ -189,7 +195,7 @@
}
// Script function #7
-int SF_doAction(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_doAction(R_SCRIPTFUNC_PARAMS) {
return R_SUCCESS;
}
@@ -197,7 +203,7 @@
// Sets the orientation of the specified actor.
// Param1: actor id
// Param2: actor orientation
-int SF_setFacing(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_setFacing(R_SCRIPTFUNC_PARAMS) {
SDataWord_T actor_parm;
SDataWord_T orient_parm;
int actor_id;
@@ -224,7 +230,7 @@
// continues to run. If the parameter is false, the user interface is
// reenabled.
// Param1: boolean
-int SF_freezeInterface(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_freezeInterface(R_SCRIPTFUNC_PARAMS) {
SDataWord_T b_param;
b_param = thread->stack->pop();
@@ -239,17 +245,17 @@
}
// Script function #14
-int SF_faceTowards(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_faceTowards(R_SCRIPTFUNC_PARAMS) {
return R_SUCCESS;
}
// Script function #15
-int SF_setFollower(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_setFollower(R_SCRIPTFUNC_PARAMS) {
return R_SUCCESS;
}
// Script function #25
-int SF_centerActor(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_centerActor(R_SCRIPTFUNC_PARAMS) {
return R_SUCCESS;
}
@@ -258,7 +264,7 @@
// Param1: ?
// Param2: frames of animation to play or -1 to loop
// Param3: animation id
-int SF_startAnim(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_startAnim(R_SCRIPTFUNC_PARAMS) {
// FIXME: implementation is wrong. Should link animation
SDataWord_T unk_parm;
SDataWord_T frame_parm;
@@ -286,7 +292,7 @@
// Param1: actor id
// Param2: actor destination x
// Param3: actor destination y
-int SF_actorWalkToAsync(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_actorWalkToAsync(R_SCRIPTFUNC_PARAMS) {
SDataWord_T actor_parm;
SDataWord_T x_parm;
SDataWord_T y_parm;
@@ -314,7 +320,7 @@
}
// Script function #29
-int SF_setActorState(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_setActorState(R_SCRIPTFUNC_PARAMS) {
return R_SUCCESS;
}
@@ -324,7 +330,7 @@
// Param1: actor id
// Param2: actor pos x
// Param3: actor pos y
-int SF_moveTo(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_moveTo(R_SCRIPTFUNC_PARAMS) {
SDataWord_T actor_parm;
SDataWord_T x_parm;
SDataWord_T y_parm;
@@ -356,7 +362,7 @@
}
// Script function #34
-int SF_swapActors(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_swapActors(R_SCRIPTFUNC_PARAMS) {
return R_SUCCESS;
}
@@ -366,7 +372,7 @@
// Param2: actor destination x
// Param3: actor destination y
// Param4: unknown
-int SF_actorWalk(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_actorWalk(R_SCRIPTFUNC_PARAMS) {
// INCOMPLETE
SDataWord_T actor_parm;
SDataWord_T x_parm;
@@ -404,7 +410,7 @@
// Param2: unknown
// Param3: actor action state
// Param4: unknown
-int SF_cycleActorFrames(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_cycleActorFrames(R_SCRIPTFUNC_PARAMS) {
// INCOMPLETE
SDataWord_T actor_parm;
SDataWord_T unk1_parm;
@@ -436,7 +442,7 @@
// Param1: actor id
// Param2: actor action state
// Param3: unknown
-int SF_setFrame(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_setFrame(R_SCRIPTFUNC_PARAMS) {
// INCOMPLETE
SDataWord_T actor_parm;
@@ -471,7 +477,7 @@
// Param2: total linked frame count
// Param3: animation id link target
// Param4: animation id link source
-int SF_linkAnim(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_linkAnim(R_SCRIPTFUNC_PARAMS) {
SDataWord_T unk_parm;
SDataWord_T tframes_parm;
SDataWord_T anim1_parm;
@@ -497,7 +503,7 @@
}
// Script function #42
-int SF_scriptSpecialWalk(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_scriptSpecialWalk(R_SCRIPTFUNC_PARAMS) {
return R_SUCCESS;
}
@@ -510,7 +516,7 @@
// Param4: ?
// Param5: actor action
// Param6: ?
-int SF_placeActor(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_placeActor(R_SCRIPTFUNC_PARAMS) {
// INCOMPLETE
SDataWord_T actor_parm;
SDataWord_T x_parm;
@@ -557,7 +563,7 @@
// Checks to see if the user has interrupted a currently playing
// game cinematic. Pushes a zero or positive value if the game
// has not been interrupted.
-int SF_checkUserInterrupt(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_checkUserInterrupt(R_SCRIPTFUNC_PARAMS) {
thread->stack->push(0);
// INCOMPLETE
@@ -566,47 +572,47 @@
}
// Script function #45
-int SF_walkRelative(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_walkRelative(R_SCRIPTFUNC_PARAMS) {
return R_SUCCESS;
}
// Script function #46
-int SF_moveRelative(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_moveRelative(R_SCRIPTFUNC_PARAMS) {
return R_SUCCESS;
}
// Script function #52
-int SF_throwActor(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_throwActor(R_SCRIPTFUNC_PARAMS) {
return R_SUCCESS;
}
// Script function #53
-int SF_waitWalk(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_waitWalk(R_SCRIPTFUNC_PARAMS) {
return R_SUCCESS;
}
// Script function #55
-int SF_changeActorScene(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_changeActorScene(R_SCRIPTFUNC_PARAMS) {
return R_SUCCESS;
}
// Script function #56
-int SF_climb(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_climb(R_SCRIPTFUNC_PARAMS) {
return R_SUCCESS;
}
// Script function #58
-int SF_setActorZ(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_setActorZ(R_SCRIPTFUNC_PARAMS) {
return R_SUCCESS;
}
// Script function #60
-int SF_getActorX(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_getActorX(R_SCRIPTFUNC_PARAMS) {
return R_SUCCESS;
}
// Script function #61
-int SF_getActorY(R_SCRIPTFUNC_PARAMS) {
+int Script::SF_getActorY(R_SCRIPTFUNC_PARAMS) {
return R_SUCCESS;
}
Index: sthread.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sthread.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- sthread.cpp 12 Aug 2004 21:39:11 -0000 1.21
+++ sthread.cpp 12 Aug 2004 23:57:45 -0000 1.22
@@ -29,22 +29,19 @@
#include "saga/actor.h"
#include "saga/console.h"
-#include "saga/script_mod.h"
#include "saga/script.h"
#include "saga/sdata.h"
-#include "saga/sthread.h"
-#include "saga/sfuncs.h"
#include "common/stack.h"
namespace Saga {
-R_SCRIPT_THREAD *STHREAD_Create() {
+R_SCRIPT_THREAD *Script::SThreadCreate() {
YS_DL_NODE *new_node;
R_SCRIPT_THREAD *new_thread;
- if (!_vm->_script->isInitialized()) {
+ if (!isInitialized()) {
return NULL;
}
@@ -55,14 +52,14 @@
new_thread->stack = new Common::Stack<SDataWord_T>();
- new_node = ys_dll_add_head(_vm->_script->threadList(), new_thread, sizeof *new_thread);
+ new_node = ys_dll_add_head(threadList(), new_thread, sizeof *new_thread);
free(new_thread);
return (R_SCRIPT_THREAD *)ys_dll_get_data(new_node);
}
-int STHREAD_Destroy(R_SCRIPT_THREAD *thread) {
+int Script::SThreadDestroy(R_SCRIPT_THREAD *thread) {
if (thread == NULL) {
return R_FAILURE;
}
@@ -72,36 +69,36 @@
return R_SUCCESS;
}
-int STHREAD_ExecThreads(int msec) {
+int Script::SThreadExecThreads(int msec) {
YS_DL_NODE *walk_p;
R_SCRIPT_THREAD *thread;
- if (!_vm->_script->isInitialized()) {
+ if (!isInitialized()) {
return R_FAILURE;
}
- for (walk_p = ys_dll_head(_vm->_script->threadList()); walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
+ for (walk_p = ys_dll_head(threadList()); walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
thread = (R_SCRIPT_THREAD *)ys_dll_get_data(walk_p);
if (thread->executing) {
- STHREAD_Run(thread, STHREAD_DEF_INSTR_COUNT, msec);
+ SThreadRun(thread, STHREAD_DEF_INSTR_COUNT, msec);
}
}
return R_SUCCESS;
}
-void STHREAD_completeThread(void) {
- for (int i = 0; i < 40 && (ys_dll_head(_vm->_script->threadList()) != NULL); i++)
- STHREAD_ExecThreads(0);
+void Script::SThreadCompleteThread(void) {
+ for (int i = 0; i < 40 && (ys_dll_head(threadList()) != NULL); i++)
+ SThreadExecThreads(0);
}
-int STHREAD_SetEntrypoint(R_SCRIPT_THREAD *thread, int ep_num) {
+int Script::SThreadSetEntrypoint(R_SCRIPT_THREAD *thread, int ep_num) {
R_SCRIPT_BYTECODE *bytecode;
int max_entrypoint;
- assert(_vm->_script->isInitialized());
+ assert(isInitialized());
- bytecode = _vm->_script->currentScript()->bytecode;
+ bytecode = currentScript()->bytecode;
max_entrypoint = bytecode->n_entrypoints;
if ((ep_num < 0) || (ep_num >= max_entrypoint)) {
@@ -114,14 +111,14 @@
return R_SUCCESS;
}
-int STHREAD_Execute(R_SCRIPT_THREAD *thread, int ep_num) {
- assert(_vm->_script->isInitialized());
+int Script::SThreadExecute(R_SCRIPT_THREAD *thread, int ep_num) {
+ assert(isInitialized());
- if ((_vm->_script->currentScript() == NULL) || (!_vm->_script->currentScript()->loaded)) {
+ if ((currentScript() == NULL) || (!currentScript()->loaded)) {
return R_FAILURE;
}
- STHREAD_SetEntrypoint(thread, ep_num);
+ SThreadSetEntrypoint(thread, ep_num);
thread->i_offset = thread->ep_offset;
thread->executing = 1;
@@ -129,20 +126,20 @@
return R_SUCCESS;
}
-unsigned char *GetReadPtr(R_SCRIPT_THREAD *thread) {
- return _vm->_script->currentScript()->bytecode->bytecode_p + thread->i_offset;
+unsigned char *Script::SThreadGetReadPtr(R_SCRIPT_THREAD *thread) {
+ return currentScript()->bytecode->bytecode_p + thread->i_offset;
}
-unsigned long GetReadOffset(const byte *read_p) {
- return (unsigned long)(read_p - (unsigned char *)_vm->_script->currentScript()->bytecode->bytecode_p);
+unsigned long Script::SThreadGetReadOffset(const byte *read_p) {
+ return (unsigned long)(read_p - (unsigned char *)currentScript()->bytecode->bytecode_p);
}
-size_t GetReadLen(R_SCRIPT_THREAD *thread) {
- return _vm->_script->currentScript()->bytecode->bytecode_len - thread->i_offset;
+size_t Script::SThreadGetReadLen(R_SCRIPT_THREAD *thread) {
+ return currentScript()->bytecode->bytecode_len - thread->i_offset;
}
-int STHREAD_HoldSem(R_SEMAPHORE *sem) {
+int Script::SThreadHoldSem(R_SEMAPHORE *sem) {
if (sem == NULL) {
return R_FAILURE;
}
@@ -152,7 +149,7 @@
return R_SUCCESS;
}
-int STHREAD_ReleaseSem(R_SEMAPHORE *sem) {
+int Script::SThreadReleaseSem(R_SEMAPHORE *sem) {
if (sem == NULL) {
return R_FAILURE;
}
@@ -165,15 +162,15 @@
return R_SUCCESS;
}
-int STHREAD_DebugStep() {
- if (_vm->_script->_dbg_singlestep) {
- _vm->_script->_dbg_dostep = 1;
+int Script::SThreadDebugStep() {
+ if (_dbg_singlestep) {
+ _dbg_dostep = 1;
}
return R_SUCCESS;
}
-int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) {
+int Script::SThreadRun(R_SCRIPT_THREAD *thread, int instr_limit, int msec) {
int instr_count;
uint32 saved_offset;
SDataWord_T param1;
@@ -191,12 +188,12 @@
int unhandled = 0;
// Handle debug single-stepping
- if ((thread == _vm->_script->_dbg_thread) && _vm->_script->_dbg_singlestep) {
- if (_vm->_script->_dbg_dostep) {
+ if ((thread == _dbg_thread) && _dbg_singlestep) {
+ if (_dbg_dostep) {
debug_print = 1;
thread->sleep_time = 0;
instr_limit = 1;
- _vm->_script->_dbg_dostep = 0;
+ _dbg_dostep = 0;
} else {
return R_SUCCESS;
}
@@ -218,7 +215,7 @@
saved_offset = thread->i_offset;
- MemoryReadStream readS(GetReadPtr(thread), GetReadLen(thread));
+ MemoryReadStream readS(SThreadGetReadPtr(thread), SThreadGetReadLen(thread));
in_char = readS.readByte();
@@ -347,7 +344,7 @@
break;
}
- sfunc = SFuncList[func_num].sfunc_fp;
+ sfunc = _SFuncList[func_num].sfunc_fp;
if (sfunc == NULL) {
_vm->_console->print(S_WARN_PREFIX "%X: Undefined script function number: (%X)\n",
thread->i_offset, func_num);
@@ -356,7 +353,7 @@
thread->stack->pop();
}
} else {
- FIXME_SHADOWED_result = sfunc(thread);
+ FIXME_SHADOWED_result = (this->*sfunc)(thread);
if (FIXME_SHADOWED_result != R_SUCCESS) {
_vm->_console->print(S_WARN_PREFIX "%X: Script function %d failed.\n", thread->i_offset, func_num);
}
@@ -732,12 +729,12 @@
data = thread->stack->pop();
if (a_index < 0)
continue;
- if (!_vm->_script->isVoiceLUTPresent()) {
+ if (!isVoiceLUTPresent()) {
voice_rn = -1;
} else {
- voice_rn = _vm->_script->currentScript()->voice->voices[data];
+ voice_rn = currentScript()->voice->voices[data];
}
- _vm->_actor->speak(a_index, _vm->_script->currentScript()->diag-> str[data], voice_rn, &thread->sem);
+ _vm->_actor->speak(a_index, currentScript()->diag-> str[data], voice_rn, &thread->sem);
}
}
break;
@@ -784,7 +781,7 @@
thread->executing = 0;
}
if (thread->executing && debug_print) {
- SDEBUG_PrintInstr(thread);
+ SDebugPrintInstr(thread);
}
}
--- script_mod.h DELETED ---
--- sfuncs.h DELETED ---
--- sthread.h DELETED ---
More information about the Scummvm-git-logs
mailing list