[Scummvm-cvs-logs] CVS: scummvm/saga isomap.cpp,1.13,1.14 render.cpp,1.35,1.36 scene.cpp,1.42,1.43 script.cpp,1.23,1.24 script.h,1.18,1.19 sdata.cpp,1.14,1.15 sthread.cpp,1.28,1.29 xref.txt,1.7,1.8
Torbjörn Andersson
eriktorbjorn at users.sourceforge.net
Sat Oct 9 00:42:51 CEST 2004
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm script_v80he.cpp,2.51,2.52 script_v90he.cpp,2.85,2.86
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm script_v100he.cpp,NONE,2.1 intern.h,2.296,2.297 module.mk,1.42,1.43 script_v72he.cpp,2.159,2.160 script_v7he.cpp,2.101,2.102 script_v80he.cpp,2.52,2.53 scumm.cpp,1.249,1.250
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30147
Modified Files:
isomap.cpp render.cpp scene.cpp script.cpp script.h sdata.cpp
sthread.cpp xref.txt
Log Message:
Initial attempt at fixing the SData problem. I'm still not sure exactly how
to fix the script "static" area, though.
In addition, initialise a few variables, and test for NULL-ness of a few
pointers. This fixes a few crashes I saw with yesterday's CVS snapshot.
There's still an unexpected scene change in the intro (I think it triggers
on Rhene walking too close to the exit), but at least it no longer crashes.
Index: isomap.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/isomap.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- isomap.cpp 4 Oct 2004 23:09:38 -0000 1.13
+++ isomap.cpp 9 Oct 2004 07:39:45 -0000 1.14
@@ -34,6 +34,7 @@
IsoMap::IsoMap(Gfx *gfx) {
_gfx = gfx;
_init = 1;
+ _tiles_loaded = 0;
}
int IsoMap::loadTileset(const byte *tileres_p, size_t tileres_len) {
Index: render.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/render.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- render.cpp 7 Oct 2004 23:26:41 -0000 1.35
+++ render.cpp 9 Oct 2004 07:39:45 -0000 1.36
@@ -134,8 +134,10 @@
// Display scene maps, if applicable
if (getFlags() & RF_OBJECTMAP_TEST) {
- _vm->_scene->_objectMap->draw(backbuf_surface, mouse_pt, _vm->_gfx->getWhite(), _vm->_gfx->getBlack());
- _vm->_scene->_actionMap->draw(backbuf_surface, _vm->_gfx->matchColor(R_RGB_RED));
+ if (_vm->_scene->_objectMap)
+ _vm->_scene->_objectMap->draw(backbuf_surface, mouse_pt, _vm->_gfx->getWhite(), _vm->_gfx->getBlack());
+ if (_vm->_scene->_actionMap)
+ _vm->_scene->_actionMap->draw(backbuf_surface, _vm->_gfx->matchColor(R_RGB_RED));
}
// Draw queued actors
Index: scene.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/scene.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- scene.cpp 7 Oct 2004 23:02:19 -0000 1.42
+++ scene.cpp 9 Oct 2004 07:39:45 -0000 1.43
@@ -138,6 +138,8 @@
_animEntries = 0;
_animList = NULL;
_sceneProc = NULL;
+ _objectMap = NULL;
+ _actionMap = NULL;
memset(&_bg, 0, sizeof(_bg));
memset(&_bgMask, 0, sizeof(_bgMask));
@@ -858,6 +860,9 @@
delete _objectMap;
delete _actionMap;
+ _objectMap = NULL;
+ _actionMap = NULL;
+
ys_dll_destroy(_animList);
_animEntries = 0;
@@ -984,6 +989,12 @@
_vm->_console->print("Thread creation failed.");
break;
}
+
+ _startScriptThread->threadVars[kVarAction] = 0;
+ _startScriptThread->threadVars[kVarObject] = _sceneNumber;
+ _startScriptThread->threadVars[kVarWithObject] = 0; // TOTO: entrance
+ _startScriptThread->threadVars[kVarActor] = 0;
+
_vm->_script->SThreadExecute(_startScriptThread, _desc.startScriptNum);
_vm->_script->SThreadCompleteThread();
}
@@ -998,7 +1009,7 @@
_vm->_events->queue(&event);
} else
_vm->_music->stop();
- //break; //HACK to disable faery script
+
if (_desc.sceneScriptNum > 0) {
R_SCRIPT_THREAD *_sceneScriptThread;
@@ -1010,8 +1021,10 @@
break;
}
- // TODO: Set up thread variables. First we'll need to
- // add the concept of thread variables...
+ _sceneScriptThread->threadVars[kVarAction] = 0;
+ _sceneScriptThread->threadVars[kVarObject] = _sceneNumber;
+ _sceneScriptThread->threadVars[kVarWithObject] = 0; // TODO: entrance
+ _sceneScriptThread->threadVars[kVarActor] = 0; // TODO: VERB_ENTER
_vm->_script->SThreadExecute(_sceneScriptThread, _desc.sceneScriptNum);
}
Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/script.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- script.cpp 27 Aug 2004 01:32:10 -0000 1.23
+++ script.cpp 9 Oct 2004 07:39:45 -0000 1.24
@@ -112,7 +112,7 @@
// Skip the unused portion of the structure
for (j = scriptS.pos(); j < prevTell + _scriptLUTEntryLen; j++) {
if (scriptS.readByte() != 0)
- error("Unused scriptLUT part isn't really unused for LUT %d (pos: %d)", i, j);
+ warning("Unused scriptLUT part isn't really unused for LUT %d (pos: %d)", i, j);
}
}
Index: script.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/script.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- script.h 3 Oct 2004 17:11:23 -0000 1.18
+++ script.h 9 Oct 2004 07:39:46 -0000 1.19
@@ -68,6 +68,13 @@
int hold_count;
};
+enum {
+ kVarObject = 0,
+ kVarWithObject,
+ kVarAction,
+ kVarActor
+};
+
struct R_SCRIPT_THREAD {
int executing;
@@ -87,6 +94,8 @@
int stackPtr;
int framePtr;
+ SDataWord_T threadVars[4];
+
SDataWord_T retVal;
SDataWord_T stackTop() {
@@ -203,6 +212,7 @@
int SThreadDestroy(R_SCRIPT_THREAD *thread);
private:
+ void setFramePtr(R_SCRIPT_THREAD *thread, int newPtr);
unsigned char *SThreadGetReadPtr(R_SCRIPT_THREAD *thread);
unsigned long SThreadGetReadOffset(const byte *read_p);
size_t SThreadGetReadLen(R_SCRIPT_THREAD *thread);
Index: sdata.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sdata.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- sdata.cpp 12 Aug 2004 23:57:45 -0000 1.14
+++ sdata.cpp 9 Oct 2004 07:39:46 -0000 1.15
@@ -30,29 +30,48 @@
namespace Saga {
SData::SData() {
- unsigned int i;
void *alloc_ptr;
+ int i;
debug(0, "Initializing script data buffers");
+
for (i = 0; i < R_SCRIPT_DATABUF_NUM; i++) {
alloc_ptr = malloc(sizeof *_vm->_script->dataBuffer(0));
+
if (alloc_ptr == NULL) {
error("Couldn't allocate memory for script data buffer %d", i);
}
_vm->_script->setBuffer(i, (R_SCRIPT_DATABUF *)alloc_ptr);
- alloc_ptr = calloc(R_SCRIPT_DATABUF_LEN, sizeof(SDataWord_T));
+ }
- if (alloc_ptr == NULL) {
- error("Couldn't allocate memory for script data buffer %d", i);
- }
+ alloc_ptr = calloc(R_SCRIPT_DATABUF_LEN, sizeof(SDataWord_T));
- _vm->_script->dataBuffer(i)->len = R_SCRIPT_DATABUF_LEN;
- _vm->_script->dataBuffer(i)->data = (SDataWord_T *)alloc_ptr;
+ if (alloc_ptr == NULL) {
+ error("Couldn't allocate memory for shared script buffer");
+ }
+
+ // Buffer 0 is the shared data buffer. All scripts can access this.
+ _vm->_script->dataBuffer(0)->len = R_SCRIPT_DATABUF_LEN;
+ _vm->_script->dataBuffer(0)->data = (SDataWord_T *)alloc_ptr;
+
+ // FIXME: Buffer 1 is the script's static area. The original
+ // interpreter uses part of buffer 0 for this, but I don't yet
+ // understand quite how.
+
+ _vm->_script->setBuffer(1, (R_SCRIPT_DATABUF *)alloc_ptr);
+ _vm->_script->dataBuffer(1)->len = R_SCRIPT_DATABUF_LEN;
+ _vm->_script->dataBuffer(1)->data = (SDataWord_T *)alloc_ptr;
+
+ // Remaining buffers are per-script.
+ for (i = 2; i < R_SCRIPT_DATABUF_NUM; i++) {
+ _vm->_script->dataBuffer(i)->len = 0;
+ _vm->_script->dataBuffer(i)->data = NULL;
}
}
SData::~SData() {
+ // TODO: Free the script data buffers
}
int SData::getWord(int n_buf, int n_word, SDataWord_T *data) {
Index: sthread.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sthread.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- sthread.cpp 3 Oct 2004 17:11:23 -0000 1.28
+++ sthread.cpp 9 Oct 2004 07:39:46 -0000 1.29
@@ -35,6 +35,12 @@
namespace Saga {
+void Script::setFramePtr(R_SCRIPT_THREAD *thread, int newPtr) {
+ thread->framePtr = newPtr;
+ dataBuffer(3)->len = 2 * (ARRAYSIZE(thread->stackBuf) - thread->framePtr);
+ dataBuffer(3)->data = (SDataWord_T *) &(thread->stackBuf[newPtr]);
+}
+
R_SCRIPT_THREAD *Script::SThreadCreate() {
YS_DL_NODE *new_node;
R_SCRIPT_THREAD *new_thread;
@@ -49,7 +55,10 @@
}
new_thread->stackPtr = ARRAYSIZE(new_thread->stackBuf) - 1;
- new_thread->framePtr = ARRAYSIZE(new_thread->stackBuf) - 1;
+ setFramePtr(new_thread, new_thread->stackPtr);
+
+ dataBuffer(4)->len = sizeof(new_thread->threadVars);
+ dataBuffer(4)->data = new_thread->threadVars;
new_node = ys_dll_add_head(threadList(), new_thread, sizeof *new_thread);
@@ -199,6 +208,9 @@
MemoryReadStream scriptS(currentScript()->bytecode->bytecode_p, currentScript()->bytecode->bytecode_len);
+ dataBuffer(2)->len = currentScript()->bytecode->bytecode_len;
+ dataBuffer(2)->data = (SDataWord_T *) currentScript()->bytecode->bytecode_p;
+
scriptS.seek(thread->i_offset);
for (instr_count = 0; instr_count < instr_limit; instr_count++) {
@@ -353,7 +365,7 @@
break;
case 0x1A: // (ENTR) Enter the dragon
thread->push(thread->framePtr);
- thread->framePtr = thread->stackPtr;
+ setFramePtr(thread, thread->stackPtr);
param1 = scriptS.readUint16LE();
thread->stackPtr -= (param1 / 2);
break;
@@ -362,7 +374,7 @@
// FALL THROUGH
case 0x1C: // Return with void
thread->stackPtr = thread->framePtr;
- thread->framePtr = thread->pop();
+ setFramePtr(thread, thread->pop());
if (thread->stackSize() == 0) {
_vm->_console->print("Script execution complete.");
thread->executing = 0;
Index: xref.txt
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/xref.txt,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- xref.txt 8 Oct 2004 01:22:39 -0000 1.7
+++ xref.txt 9 Oct 2004 07:39:46 -0000 1.8
@@ -65,4 +65,7 @@
ModuleEntry->codeID _scriptLUT->script_rn
ModuleEntry->strID _scriptLUT->diag_list_rn
ModuleEntry->vtableID _scriptLUT->voice_lut_rn
-
+ threadBase.theAction threadVars[kVarAction]
+ threadBase.theObject threadVars[kVarObject]
+ threadBase.withObject threadVars[kVarWithObject]
+ threadBase.theActor threadVars[kVarActor]
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm script_v80he.cpp,2.51,2.52 script_v90he.cpp,2.85,2.86
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm script_v100he.cpp,NONE,2.1 intern.h,2.296,2.297 module.mk,1.42,1.43 script_v72he.cpp,2.159,2.160 script_v7he.cpp,2.101,2.102 script_v80he.cpp,2.52,2.53 scumm.cpp,1.249,1.250
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list