diff options
author | Eugene Sandulenko | 2004-08-11 00:27:43 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2004-08-11 00:27:43 +0000 |
commit | 57b158214949fbb24b37e23d0adeec2c52bbf86a (patch) | |
tree | 9f80672dc5bfc6674831404cbdc239011e59a844 | |
parent | aba3176b0edbe171ee1a73ee48b0aff18a81946a (diff) | |
download | scummvm-rg350-57b158214949fbb24b37e23d0adeec2c52bbf86a.tar.gz scummvm-rg350-57b158214949fbb24b37e23d0adeec2c52bbf86a.tar.bz2 scummvm-rg350-57b158214949fbb24b37e23d0adeec2c52bbf86a.zip |
Move CF_ commands to class and call them from wrappers. This will let us
remove global _vm later.
svn-id: r14552
-rw-r--r-- | saga/script.cpp | 32 | ||||
-rw-r--r-- | saga/script.h | 5 |
2 files changed, 24 insertions, 13 deletions
diff --git a/saga/script.cpp b/saga/script.cpp index afec808736..8147408db3 100644 --- a/saga/script.cpp +++ b/saga/script.cpp @@ -486,31 +486,31 @@ R_VOICE_LUT *Script::loadVoiceLUT(const byte *voicelut_p, size_t voicelut_len, R return voice_lut; } -void CF_script_info(int argc, char *argv[], void *refCon) { +void Script::scriptInfo(int argc, char *argv[]) { uint32 n_entrypoints; uint32 i; char *name_ptr; - if (((Script *)refCon)->currentScript() == NULL) { + if (currentScript() == NULL) { return; } - if (!((Script *)refCon)->currentScript()->loaded) { + if (!currentScript()->loaded) { return; } - n_entrypoints = ((Script *)refCon)->currentScript()->bytecode->n_entrypoints; + n_entrypoints = currentScript()->bytecode->n_entrypoints; _vm->_console->print("Current script contains %d entrypoints:", n_entrypoints); for (i = 0; i < n_entrypoints; i++) { - name_ptr = (char *)((Script *)refCon)->currentScript()->bytecode->bytecode_p + - ((Script *)refCon)->currentScript()->bytecode->entrypoints[i].name_offset; + name_ptr = (char *)currentScript()->bytecode->bytecode_p + + currentScript()->bytecode->entrypoints[i].name_offset; _vm->_console->print("%lu: %s", i, name_ptr); } } -void CF_script_exec(int argc, char *argv[], void *refCon) { +void Script::scriptExec(int argc, char *argv[]) { uint16 ep_num; if (argc < 1) { @@ -519,21 +519,29 @@ void CF_script_exec(int argc, char *argv[], void *refCon) { ep_num = atoi(argv[0]); - if (((Script *)refCon)->_dbg_thread == NULL) { + if (_dbg_thread == NULL) { _vm->_console->print("Creating debug thread..."); - ((Script *)refCon)->_dbg_thread = STHREAD_Create(); - if (((Script *)refCon)->_dbg_thread == NULL) { + _dbg_thread = STHREAD_Create(); + if (_dbg_thread == NULL) { _vm->_console->print("Thread creation failed."); return; } } - if (ep_num >= ((Script *)refCon)->currentScript()->bytecode->n_entrypoints) { + if (ep_num >= currentScript()->bytecode->n_entrypoints) { _vm->_console->print("Invalid entrypoint."); return; } - STHREAD_Execute(((Script *)refCon)->_dbg_thread, ep_num); + STHREAD_Execute(_dbg_thread, ep_num); +} + +void CF_script_info(int argc, char *argv[], void *refCon) { + ((Script *)refCon)->scriptInfo(argc, argv); +} + +void CF_script_exec(int argc, char *argv[], void *refCon) { + ((Script *)refCon)->scriptExec(argc, argv); } void CF_script_togglestep(int argc, char *argv[], void *refCon) { diff --git a/saga/script.h b/saga/script.h index 883ba872dd..38e8e9ba5e 100644 --- a/saga/script.h +++ b/saga/script.h @@ -110,6 +110,9 @@ public: void setBuffer(int idx, R_SCRIPT_DATABUF *ptr) { _dataBuf[idx] = ptr; } R_SCRIPT_DATABUF *dataBuffer(int idx) { return _dataBuf[idx]; } YS_DL_LIST *threadList() { return _threadList; } + + void scriptInfo(int argc, char *argv[]); + void scriptExec(int argc, char *argv[]); protected: bool _initialized; @@ -121,7 +124,7 @@ protected: R_SCRIPTDATA *_currentScript; R_SCRIPT_DATABUF *_dataBuf[R_SCRIPT_DATABUF_NUM]; YS_DL_LIST *_threadList; - + public: int _dbg_singlestep; int _dbg_dostep; |