aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2012-05-06 21:24:55 +1000
committerPaul Gilbert2012-05-06 21:24:55 +1000
commit156d8cdb733fe03688da9e2e9844b722681bed7f (patch)
tree6f255fd9f1e53c84e434907c30dc1769af0b930e
parent8bfc60f5c9bdba4b1f37fcf42df4b0aa360c325f (diff)
downloadscummvm-rg350-156d8cdb733fe03688da9e2e9844b722681bed7f.tar.gz
scummvm-rg350-156d8cdb733fe03688da9e2e9844b722681bed7f.tar.bz2
scummvm-rg350-156d8cdb733fe03688da9e2e9844b722681bed7f.zip
TONY: Bugfix for waitForSingleObject, and added action process debug information
-rw-r--r--engines/tony/custom.cpp14
-rw-r--r--engines/tony/custom.h16
-rw-r--r--engines/tony/mpal/mpal.cpp18
-rw-r--r--engines/tony/mpal/mpal.h3
-rw-r--r--engines/tony/sched.cpp2
-rw-r--r--engines/tony/tony.cpp10
-rw-r--r--engines/tony/tony.h1
7 files changed, 44 insertions, 20 deletions
diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp
index 2683634012..dadc84e606 100644
--- a/engines/tony/custom.cpp
+++ b/engines/tony/custom.cpp
@@ -1680,7 +1680,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes
// Cerca di eseguire la funzione custom per chiudere la parlata
if (MCharacter[nChar].item) {
- h=mpalQueryDoAction(31,MCharacter[nChar].item->MpalCode(),parm);
+ h = mpalQueryDoAction(31,MCharacter[nChar].item->MpalCode(),parm);
if (h!=INVALID_HANDLE_VALUE)
WaitForSingleObject(h,INFINITE);
}
@@ -1724,7 +1724,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg
g_system->unlockMutex(vdb);
}
- string=mpalQueryDialogPeriod(nMsg);
+ string = mpalQueryDialogPeriod(nMsg);
if (nPers == 0) {
text = new RMTextDialog;
@@ -1847,7 +1847,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg
if ((MCharacter[nPers].bInTexts && MCharacter[nPers].numtexts== 0) || !MCharacter[nPers].bInTexts) {
// Cerca di eseguire la funzione custom per chiudere la parlata
MCharacter[nPers].curTalk = (MCharacter[nPers].curTalk%10) + MCharacter[nPers].curgroup*10;
- h=mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk);
+ h = mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk);
if (h!=INVALID_HANDLE_VALUE)
WaitForSingleObject(h,INFINITE);
@@ -1872,7 +1872,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg
}
-// @@@@ QUESTA NON SI PUO' SKIPPARE!!!!!!!!!!!!!!!!!!!
+// @@@@ This cannot be skipped!!!!!!!!!!!!!!!!!!!
DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGroup, uint32, uint32) {
int nChoice;
@@ -1888,9 +1888,9 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr
mpalQueryDoDialogU32(nDialog, nStartGroup);
// Aspetta che una scelta si presenti
- while ((nChoice=mpalQueryDialogWaitForChoice()) != -1) {
+ while ((nChoice = mpalQueryDialogWaitForChoice()) != -1) {
// Si fa dare la lista di opzioni e le conta
- sl=mpalQueryDialogSelectList(nChoice);
+ sl = mpalQueryDialogSelectList(nChoice);
for (num = 0; sl[num] != 0; num++)
;
@@ -1906,7 +1906,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr
dc.SetNumChoices(num);
// Scrive tutte le possibili opzioni
- for (i = 0;i < num; i++) {
+ for (i = 0; i < num; i++) {
string = mpalQueryDialogPeriod(sl[i]);
assert(string != NULL);
dc.AddChoice(string);
diff --git a/engines/tony/custom.h b/engines/tony/custom.h
index a9f4ac2aab..4b9701cec4 100644
--- a/engines/tony/custom.h
+++ b/engines/tony/custom.h
@@ -49,6 +49,7 @@
#ifndef TONY_CUSTOM_H
#define TONY_CUSTOM_H
+#include "common/str.h"
#include "tony/mpal/mpal.h"
namespace Tony {
@@ -70,18 +71,19 @@ typedef uint32 HWND;
static void AssignError(int num) { \
error("Custom function %u has been already assigned!", num); \
} \
- void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap) \
+ void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap, Common::String *lpStrMap) \
{
-#define END_CUSTOM_FUNCTION_MAP() \
+#define END_CUSTOM_FUNCTION_MAP() \
}
-#define ASSIGN(num, func) \
- if (lpMap[num] != NULL) \
- AssignError(num); \
- lpMap[num] = func;
+#define ASSIGN(num, func) \
+ if (lpMap[num] != NULL) \
+ AssignError(num); \
+ lpMap[num] = func; \
+ lpStrMap[num] = #func;
class RMTony;
class RMPointer;
@@ -90,7 +92,7 @@ class RMLocation;
class RMInventory;
class RMInput;
-void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap);
+void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap, Common::String *lpStrMap);
void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input);
#endif
diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp
index 9000693292..26cbf3652d 100644
--- a/engines/tony/mpal/mpal.cpp
+++ b/engines/tony/mpal/mpal.cpp
@@ -102,7 +102,8 @@ static byte * lpMpcImage;
LPITEMIRQFUNCTION lpiifCustom=NULL;
-LPLPCUSTOMFUNCTION lplpFunctions=NULL;
+LPLPCUSTOMFUNCTION lplpFunctions = NULL;
+Common::String * lplpFunctionStrings = NULL;
uint16 nObjs;
uint16 nVars;
@@ -959,6 +960,12 @@ void ActionThread(CORO_PARAM, const void *param) {
if (item->Command[_ctx->k].type == 1) {
// Custom function
+ debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d",
+ _vm->_scheduler.getCurrentPID(), lplpFunctionStrings[item->Command[_ctx->k].nCf].c_str(),
+ item->Command[_ctx->k].arg1, item->Command[_ctx->k].arg2,
+ item->Command[_ctx->k].arg3, item->Command[_ctx->k].arg4
+ );
+
CORO_INVOKE_4(lplpFunctions[item->Command[_ctx->k].nCf],
item->Command[_ctx->k].arg1,
item->Command[_ctx->k].arg2,
@@ -968,6 +975,9 @@ void ActionThread(CORO_PARAM, const void *param) {
);
} else if (item->Command[_ctx->k].type == 2) {
// Variable assign
+ debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Variable=%s",
+ _vm->_scheduler.getCurrentPID(), item->Command[_ctx->k].lpszVarName);
+
LockVar();
varSetValue(item->Command[_ctx->k].lpszVarName, EvaluateExpression(item->Command[_ctx->k].expr));
UnlockVar();
@@ -981,6 +991,8 @@ void ActionThread(CORO_PARAM, const void *param) {
GlobalFree(item);
+ debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", _vm->_scheduler.getCurrentPID());
+
CORO_KILL_SELF();
CORO_END_CODE;
@@ -1705,7 +1717,8 @@ bool DoSelection(uint32 i, uint32 dwData) {
*
\****************************************************************************/
-bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray) {
+bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName,
+ LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings) {
Common::File hMpc;
byte buf[5];
uint32 nBytesRead;
@@ -1719,6 +1732,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, LPLPCUST
/* Si salva l'array delle funzioni custom */
lplpFunctions = lplpcfArray;
+ lplpFunctionStrings = lpcfStrings;
/* Apre il file MPC in lettura */
if (!hMpc.open(lpszMpcFileName))
diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h
index 9da963d39e..c9f8625744 100644
--- a/engines/tony/mpal/mpal.h
+++ b/engines/tony/mpal/mpal.h
@@ -119,6 +119,7 @@
#include "common/scummsys.h"
#include "common/rect.h"
+#include "common/str.h"
#include "tony/coroutine.h"
namespace Tony {
@@ -602,7 +603,7 @@ extern "C" {
\****************************************************************************/
bool EXPORT mpalInit(const char *lpszFileName, const char *lpszMprFileName,
- LPLPCUSTOMFUNCTION lplpcfArray);
+ LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings);
diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp
index 421f4d1ac7..f8a7fd2538 100644
--- a/engines/tony/sched.cpp
+++ b/engines/tony/sched.cpp
@@ -314,7 +314,7 @@ void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration, bool *exp
while (g_system->getMillis() < _ctx->endTime) {
// Check to see if a process with the given Id exists
_ctx->pProc = active->pNext;
- while ((_ctx->pProc != NULL) && (_ctx->pProc->pid == pid))
+ while ((_ctx->pProc != NULL) && (_ctx->pProc->pid != pid))
_ctx->pProc = _ctx->pProc->pNext;
if (_ctx->pProc == NULL) {
diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp
index 01d0cf9add..a4a478d40d 100644
--- a/engines/tony/tony.cpp
+++ b/engines/tony/tony.cpp
@@ -23,6 +23,7 @@
#include "common/scummsys.h"
#include "common/algorithm.h"
#include "common/config-manager.h"
+#include "common/debug-channels.h"
#include "common/events.h"
#include "common/file.h"
#include "tony/tony.h"
@@ -37,6 +38,11 @@ TonyEngine *_vm;
TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst),
_gameDescription(gameDesc), _randomSource("tony") {
_vm = this;
+
+ DebugMan.addDebugChannel(kTonyDebugAnimations, "animations", "Animations debugging");
+ DebugMan.addDebugChannel(kTonyDebugActions, "actions", "Actions debugging");
+ DebugMan.addDebugChannel(kTonyDebugSound, "sound", "Sound debugging");
+ DebugMan.addDebugChannel(kTonyDebugMusic, "music", "Music debugging");
}
TonyEngine::~TonyEngine() {
@@ -84,7 +90,7 @@ Common::ErrorCode TonyEngine::Init() {
return Common::kReadingFailed;
f.close();
- if (!mpalInit("ROASTED.MPC", "ROASTED.MPR", FuncList))
+ if (!mpalInit("ROASTED.MPC", "ROASTED.MPR", FuncList, FuncListStrings))
return Common::kUnknownError;
// Initialise the update resources
@@ -133,7 +139,7 @@ Common::ErrorCode TonyEngine::Init() {
}
void TonyEngine::InitCustomFunctionMap() {
- INIT_CUSTOM_FUNCTION(FuncList);
+ INIT_CUSTOM_FUNCTION(FuncList, FuncListStrings);
}
/**
diff --git a/engines/tony/tony.h b/engines/tony/tony.h
index 1eafe54afb..3c7e8fe6b2 100644
--- a/engines/tony/tony.h
+++ b/engines/tony/tony.h
@@ -88,6 +88,7 @@ protected:
virtual bool hasFeature(EngineFeature f) const;
public:
LPCUSTOMFUNCTION FuncList[300];
+ Common::String FuncListStrings[300];
Common::RandomSource _randomSource;
MPAL::MemoryManager _memoryManager;
RMResUpdate _resUpdate;