/** * Starts up process to run actor's glitter code. */ void ActorEvent(CORO_PARAM, int ano, TINSEL_EVENT tEvent, bool bWait, int myEscape, bool *result) { ATP_INIT atp; int index; CORO_BEGIN_CONTEXT; PPROCESS pProc; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); index = TaggedActorIndex(ano); assert(taggedActors[index].hActorCode); if (result) *result = false; atp.id = 0; atp.event = tEvent; atp.pic = InitInterpretContext(GS_ACTOR, taggedActors[index].hActorCode, tEvent, NOPOLY, // No polygon ano, // Actor NULL, // No object myEscape); if (atp.pic != NULL) { _ctx->pProc = g_scheduler->createProcess(PID_TCODE, ActorTinselProcess, &atp, sizeof(atp)); AttachInterpret(atp.pic, _ctx->pProc); if (bWait) CORO_INVOKE_2(WaitInterpret,_ctx->pProc, result); } CORO_END_CODE; }
/** * Run the Polygon process with the given event */ void PolygonEvent(CORO_PARAM, HPOLYGON hPoly, TINSEL_EVENT tEvent, int actor, bool bWait, int myEscape, bool *result) { CORO_BEGIN_CONTEXT; Common::PPROCESS pProc; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); PTP_INIT to; if (result) *result = false; to.hPoly = -1; to.event = tEvent; to.pic = InitInterpretContext(GS_POLYGON, GetPolyScript(hPoly), tEvent, hPoly, // Polygon actor, // Actor NULL, // No Object myEscape); if (to.pic != NULL) { _ctx->pProc = CoroScheduler.createProcess(PID_TCODE, PolyTinselProcess, &to, sizeof(to)); AttachInterpret(to.pic, _ctx->pProc); if (bWait) CORO_INVOKE_2(WaitInterpret, _ctx->pProc, result); } CORO_END_CODE; }
/** * The code for for restored scene processes. */ static void RestoredProcessProcess(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; INT_CONTEXT *pic; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); // get the stuff copied to process when it was created _ctx->pic = *(const PINT_CONTEXT *)param; _ctx->pic = RestoreInterpretContext(_ctx->pic); AttachInterpret(_ctx->pic, g_scheduler->getCurrentProcess()); CORO_INVOKE_1(Interpret, _ctx->pic); CORO_END_CODE; }
/** * Run a scene process with the given event. */ void SceneProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWait, int myEscape, bool *result) { uint32 i; // Loop counter if (result) *result = false; CORO_BEGIN_CONTEXT; PROCESS_STRUC *pStruc; PPROCESS pProc; PINT_CONTEXT pic; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); _ctx->pStruc = (PROCESS_STRUC *)LockMem(hSceneProcess); for (i = 0; i < numSceneProcess; i++) { if (FROM_LE_32(_ctx->pStruc[i].processId) == procID) { assert(_ctx->pStruc[i].hProcessCode); // Must have some code to run _ctx->pic = InitInterpretContext(GS_PROCESS, FROM_LE_32(_ctx->pStruc[i].hProcessCode), event, NOPOLY, // No polygon 0, // No actor NULL, // No object myEscape); if (_ctx->pic == NULL) return; _ctx->pProc = g_scheduler->createProcess(PID_PROCESS + i, ProcessTinselProcess, &_ctx->pic, sizeof(_ctx->pic)); AttachInterpret(_ctx->pic, _ctx->pProc); break; } } if (i == numSceneProcess) return; if (bWait) { CORO_INVOKE_2(WaitInterpret, _ctx->pProc, result); } CORO_END_CODE; }
/** * Run a global process with the given event. */ bool GlobalProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWait, int myEscape) { CORO_BEGIN_CONTEXT; PINT_CONTEXT pic; PPROCESS pProc; CORO_END_CONTEXT(_ctx); bool result = false; CORO_BEGIN_CODE(_ctx); uint32 i; // Loop counter _ctx->pProc = NULL; for (i = 0; i < numGlobalProcess; ++i) { if (pGlobalProcess[i].processId == procID) { assert(pGlobalProcess[i].hProcessCode); // Must have some code to run _ctx->pic = InitInterpretContext(GS_GPROCESS, pGlobalProcess[i].hProcessCode, event, NOPOLY, // No polygon 0, // No actor NULL, // No object myEscape); if (_ctx->pic != NULL) { _ctx->pProc = g_scheduler->createProcess(PID_GPROCESS + i, ProcessTinselProcess, &_ctx->pic, sizeof(_ctx->pic)); AttachInterpret(_ctx->pic, _ctx->pProc); } break; } } if ((i == numGlobalProcess) || (_ctx->pic == NULL)) result = false; else if (bWait) CORO_INVOKE_ARGS_V(WaitInterpret, false, (CORO_SUBCTX, _ctx->pProc, &result)); CORO_END_CODE; return result; }