/** * Register an actor as being a moving one. */ PMOVER RegisterMover(int ano) { int i; // Slot 0 is reserved for lead actor if (ano == GetLeadId() || ano == LEAD_ACTOR) { g_Movers[0].actorToken = TOKEN_LEAD; g_Movers[0].actorID = GetLeadId(); return &g_Movers[0]; } // Check it hasn't already been declared for (i = 1; i < MAX_MOVERS; i++) { if (g_Movers[i].actorID == ano) { // Actor is already a moving actor return &g_Movers[i]; } } // Find an empty slot for (i = 1; i < MAX_MOVERS; i++) if (!g_Movers[i].actorID) { g_Movers[i].actorToken = TOKEN_LEAD + i; g_Movers[i].actorID = ano; return &g_Movers[i]; } error("Too many moving actors"); }
/** * Called from TagProcess, NextTaggedActor() is * called repeatedly until the caller gets fed up or * there are no more tagged actors to look at. */ int NextTaggedActor(int previous) { PMOVER pMover; // Convert actor number to index if (!previous) previous = -1; else previous = TaggedActorIndex(previous); while (++previous < numTaggedActors) { pMover = GetMover(taggedActors[previous].id); // No tag on lead actor while he's moving if ((taggedActors[previous].id) == GetLeadId() && MoverMoving(pMover)) { taggedActors[previous].tagFlags &= ~(POINTING | TAGWANTED); continue; } // Not if the actor doesn't exist at the moment if (pMover && !MoverIs(pMover)) continue; if (!(pMover ? MoverHidden(pMover) : ActorHidden(taggedActors[previous].id))) { return taggedActors[previous].id; } } return 0; }
/** * Given an actor number, return pointer to its moving actor structure, * if it is a moving actor. */ PMOVER GetMover(int ano) { int i; // Slot 0 is reserved for lead actor if (ano == GetLeadId() || ano == LEAD_ACTOR) return &g_Movers[0]; for (i = 1; i < MAX_MOVERS; i++) if (g_Movers[i].actorID == ano) return &g_Movers[i]; return NULL; }
/** * Decide when to scroll and scroll when decided to. */ void ScrollProcess(CORO_PARAM, const void *) { // COROUTINE CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); // In Tinsel v2, scenes may play movies, so the background may not always // already be initialized like it is in v1 while (!GetBgObject()) CORO_SLEEP(1); g_ImageH = BgHeight(); // Dimensions g_ImageW = BgWidth(); // of this scene. // Give up if there'll be no purpose in this process if (g_ImageW == SCREEN_WIDTH && g_ImageH == SCREEN_HEIGHT) CORO_KILL_SELF(); if (!TinselV2) { g_LeftScroll = g_DownScroll = 0; // No iterations outstanding g_oldx = g_oldy = 0; g_scrollPixelsX = g_scrollPixelsY = SCROLLPIXELS; } if (!g_scrollActor) g_scrollActor = GetLeadId(); g_pScrollMover = GetMover(g_scrollActor); while (1) { MonitorScroll(); // Set scroll requirement if (g_LeftScroll || g_DownScroll) // Scroll if required ScrollImage(); CORO_SLEEP(1); // allow re-scheduling } CORO_END_CODE; }