[Scummvm-git-logs] scummvm master -> 2b62338e5eb5d64d96dfa25cebd8976c712e995d
bluegr
bluegr at gmail.com
Sat Oct 3 22:16:09 UTC 2020
This automated email contains information about 17 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
bb54f3cd4f TINSEL: Move all actor-related functions into a new Actor class
8c50aa8902 TINSEL: Rename some actor variable and struct names
ae2e05cbd3 TINSEL: Move all handle-related functions into a new Handle class
5bb0332383 TINSEL: Rename variables in the Handle class
bbf81aa216 TINSEL: Move code into class destructors
efb0acb24f TINSEL: Clear some global vars upon engine destruction
9322b11fd8 TINSEL: Move all scroll-related functions into a new Scroll class
e1d1d72db8 TINSEL: Rename variables in the Scroll class, and move some defines
672ab3cca3 TINSEL: Clear some more vars upon engine destruction
05e7af7c65 TINSEL: Reset more global vars upon engine destruction
9c9fc0cf2b TINSEL: Reset more global vars upon engine destruction
ae91b7e056 TINSEL: Reset more global vars upon engine destruction
1bda5728a9 TINSEL: Reset more global vars upon engine destruction
94fae0c94d TINSEL: Move all dialog-related functions into a new Dialogs class
94997ef7d3 TINSEL: Rename variables of the Dialogs class
086f1832e5 TINSEL: Update metaengine.cpp with the changes to SG_DESC_LEN
2b62338e5e TINSEL: Enable the Return to Launcher feature
Commit: bb54f3cd4f025b454d95d5808d57dad505b8af6c
https://github.com/scummvm/scummvm/commit/bb54f3cd4f025b454d95d5808d57dad505b8af6c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-10-04T01:15:18+03:00
Commit Message:
TINSEL: Move all actor-related functions into a new Actor class
Also, merge the two different SetMoverZ() functions
Changed paths:
engines/tinsel/actors.cpp
engines/tinsel/actors.h
engines/tinsel/dialogs.cpp
engines/tinsel/faders.cpp
engines/tinsel/font.cpp
engines/tinsel/move.cpp
engines/tinsel/pdisplay.cpp
engines/tinsel/play.cpp
engines/tinsel/rince.cpp
engines/tinsel/saveload.cpp
engines/tinsel/savescn.cpp
engines/tinsel/scene.cpp
engines/tinsel/scroll.cpp
engines/tinsel/tinlib.cpp
engines/tinsel/tinsel.cpp
engines/tinsel/tinsel.h
diff --git a/engines/tinsel/actors.cpp b/engines/tinsel/actors.cpp
index e51973ad35..ce340d3996 100644
--- a/engines/tinsel/actors.cpp
+++ b/engines/tinsel/actors.cpp
@@ -46,10 +46,6 @@
namespace Tinsel {
-
-//----------------- LOCAL DEFINES --------------------
-
-
#include "common/pack-start.h" // START STRUCT PACKING
/** actor struct - one per actor */
@@ -69,20 +65,8 @@ struct T2_ACTOR_STRUC {
#include "common/pack-end.h" // END STRUCT PACKING
-//----------------- LOCAL MACROS ----------------------------
-
#define RANGE_CHECK(num) assert(num > 0 && num <= NumActors);
-//----------------- LOCAL GLOBAL DATA --------------------
-
-#define MAX_REELS 6
-
-// FIXME: Avoid non-const global vars
-
-static int LeadActorId = 0; // The lead actor
-
-static int NumActors = 0; // The total number of actors in the game
-
struct ACTORINFO {
bool bAlive; // TRUE == alive
bool bHidden; // TRUE == hidden
@@ -122,37 +106,10 @@ struct ACTORINFO {
int filmNum;
};
-struct TAGACTOR {
- // Copies of compiled data
- int id;
- SCNHANDLE hTagText; // handle to tag text
- int32 tagPortionV; // which portion is active
- int32 tagPortionH; // which portion is active
- SCNHANDLE hActorCode; // The actor's script
-
- int tagFlags;
- SCNHANDLE hOverrideTag; // Override tag.
+struct RATP_INIT {
+ INT_CONTEXT *pic;
+ int id; // Actor number
};
-typedef TAGACTOR *PTAGACTOR;
-
-
-static ACTORINFO *actorInfo = nullptr;
-
-static COLORREF defaultColor = 0; // Text color
-
-static bool bActorsOn = false;
-
-static int ti = 0;
-
-#define MAX_TAGACTORS 10
-
-static TAGACTOR taggedActors[MAX_TAGACTORS];
-
-static int numTaggedActors = 0;
-
-static uint8 *zFactors = nullptr;
-
-static Z_POSITIONS zPositions[NUM_ZPOSITIONS];
//-------------------- METHOD LIST -----------------------
@@ -161,7 +118,7 @@ static Z_POSITIONS zPositions[NUM_ZPOSITIONS];
* Registers the total number of actors in the game.
* @param num Chunk Id
*/
-void RegisterActors(int num) {
+void Actor::RegisterActors(int num) {
if (actorInfo == NULL) {
// Store the total number of actors in the game
NumActors = num;
@@ -196,7 +153,7 @@ void RegisterActors(int num) {
actorInfo[num].bAlive = true;
}
-void FreeActors() {
+void Actor::FreeActors() {
free(actorInfo);
actorInfo = nullptr;
if (TinselV2) {
@@ -209,7 +166,7 @@ void FreeActors() {
* Called from dec_lead(), i.e. normally once at start of master script.
* @param leadID Lead Id
*/
-void SetLeadId(int leadID) {
+void Actor::SetLeadId(int leadID) {
LeadActorId = leadID;
actorInfo[leadID-1].mtype = ACT_MASK;
}
@@ -217,11 +174,11 @@ void SetLeadId(int leadID) {
/**
* No comment.
*/
-int GetLeadId() {
+int Actor::GetLeadId() {
return LeadActorId;
}
-bool ActorIsGhost(int actor) {
+bool Actor::ActorIsGhost(int actor) {
return actor == SysVar(ISV_GHOST_ACTOR);
}
@@ -236,7 +193,7 @@ struct ATP_INIT {
/**
* Convert actor id to index into TaggedActors[]
*/
-static int TaggedActorIndex(int actor) {
+int Actor::TaggedActorIndex(int actor) {
int i;
for (i = 0; i < numTaggedActors; i++) {
@@ -247,165 +204,14 @@ static int TaggedActorIndex(int actor) {
error("You may say to yourself \"this is not my tagged actor\"");
}
-/**
- * Runs actor's glitter code.
- */
-static void ActorTinselProcess(CORO_PARAM, const void *param) {
- // COROUTINE
- CORO_BEGIN_CONTEXT;
- INT_CONTEXT *pic;
- bool bTookControl;
- CORO_END_CONTEXT(_ctx);
-
- // get the stuff copied to process when it was created
- const ATP_INIT *atp = (const ATP_INIT *)param;
-
- CORO_BEGIN_CODE(_ctx);
-
- if (TinselV2) {
- // Take control for CONVERSE events
- if (atp->event == CONVERSE) {
- _ctx->bTookControl = GetControl();
- HideConversation(true);
- } else
- _ctx->bTookControl = false;
-
- // Run the Glitter code
- CORO_INVOKE_1(Interpret, atp->pic);
-
- // Restore conv window if applicable
- if (atp->event == CONVERSE) {
- // Free control if we took it
- if (_ctx->bTookControl)
- ControlOn();
-
- HideConversation(false);
- }
- } else {
- CORO_INVOKE_1(AllowDclick, atp->bev); // May kill us if single click
-
- // Run the Glitter code
- assert(actorInfo[atp->id - 1].actorCode); // no code to run
-
- _ctx->pic = InitInterpretContext(GS_ACTOR, actorInfo[atp->id - 1].actorCode,
- atp->event, NOPOLY, atp->id, NULL);
- CORO_INVOKE_1(Interpret, _ctx->pic);
-
- // If it gets here, actor's code has run to completion
- actorInfo[atp->id - 1].completed = true;
- }
-
- CORO_END_CODE;
-}
-
-
//---------------------------------------------------------------------------
-struct RATP_INIT {
- INT_CONTEXT *pic;
- int id; // Actor number
-};
-
-static void ActorRestoredProcess(CORO_PARAM, const void *param) {
- // COROUTINE
- CORO_BEGIN_CONTEXT;
- INT_CONTEXT *pic;
- CORO_END_CONTEXT(_ctx);
-
- // get the stuff copied to process when it was created
- const RATP_INIT *r = (const RATP_INIT *)param;
- bool isSavegame = r->pic->resumeState == RES_SAVEGAME;
-
- CORO_BEGIN_CODE(_ctx);
-
- _ctx->pic = RestoreInterpretContext(r->pic);
-
- // The newly added check here specially sets the process to RES_NOT when loading a savegame.
- // This is needed particularly for the Psychiatrist scene in Discworld 1 - otherwise Rincewind
- // can't go upstairs without leaving the building and returning. If this patch causes problems
- // in other scenes, an added check for the hCode == 1174490602 could be added.
- if (isSavegame && TinselV1)
- _ctx->pic->resumeState = RES_NOT;
-
- CORO_INVOKE_1(Interpret, _ctx->pic);
-
- // If it gets here, actor's code has run to completion
- actorInfo[r->id - 1].completed = true;
-
- CORO_END_CODE;
-}
-
-void RestoreActorProcess(int id, INT_CONTEXT *pic, bool savegameFlag) {
- RATP_INIT r = { pic, id };
- if (savegameFlag)
- pic->resumeState = RES_SAVEGAME;
-
- CoroScheduler.createProcess(PID_TCODE, ActorRestoredProcess, &r, sizeof(r));
-}
-
-/**
- * Starts up process to runs actor's glitter code.
- * @param ano Actor Id
- * @param event Event structure
- * @param be ButEvent
- */
-void ActorEvent(int ano, TINSEL_EVENT event, PLR_EVENT be) {
- ATP_INIT atp;
-
- // Only if there is Glitter code associated with this actor.
- if (actorInfo[ano - 1].actorCode) {
- atp.id = ano;
- atp.event = event;
- atp.bev = be;
- atp.pic = nullptr;
- CoroScheduler.createProcess(PID_TCODE, ActorTinselProcess, &atp, sizeof(atp));
- }
-}
-
-/**
- * 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;
- Common::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 = CoroScheduler.createProcess(PID_TCODE, ActorTinselProcess, &atp, sizeof(atp));
- AttachInterpret(atp.pic, _ctx->pProc);
-
- if (bWait)
- CORO_INVOKE_2(WaitInterpret,_ctx->pProc, result);
- }
-
- CORO_END_CODE;
-}
-
-
/**
* Called at the start of each scene for each actor with a code block.
* @param as Actor structure
* @param bRunScript Flag for whether to run actor's script for the scene
*/
-void StartActor(const T1_ACTOR_STRUC *as, bool bRunScript) {
+void Actor::StartActor(const T1_ACTOR_STRUC *as, bool bRunScript) {
SCNHANDLE hActorId = FROM_32(as->hActorId);
// Zero-out many things
@@ -437,7 +243,7 @@ void StartActor(const T1_ACTOR_STRUC *as, bool bRunScript) {
* @param numActors Number of actors
* @param bRunScript Flag for whether to run actor scene scripts
*/
-void StartTaggedActors(SCNHANDLE ah, int numActors, bool bRunScript) {
+void Actor::StartTaggedActors(SCNHANDLE ah, int numActors, bool bRunScript) {
int i;
if (TinselV2) {
@@ -474,8 +280,8 @@ void StartTaggedActors(SCNHANDLE ah, int numActors, bool bRunScript) {
// Run actor's script for this scene
if (bRunScript) {
// Send in reverse order - they get swapped round in the scheduler
- ActorEvent(Common::nullContext, taggedActors[i].id, SHOWEVENT, false, 0);
- ActorEvent(Common::nullContext, taggedActors[i].id, STARTUP, false, 0);
+ ActorEvent(taggedActors[i].id, SHOWEVENT, false, 0);
+ ActorEvent(taggedActors[i].id, STARTUP, false, 0);
}
}
}
@@ -484,7 +290,7 @@ void StartTaggedActors(SCNHANDLE ah, int numActors, bool bRunScript) {
/**
* Called between scenes, zeroises all actors.
*/
-void DropActors() {
+void Actor::DropActors() {
for (int i = 0; i < NumActors; i++) {
if (TinselV2) {
@@ -520,7 +326,7 @@ void DropActors() {
* Kill actors.
* @param ano Actor Id
*/
-void DisableActor(int ano) {
+void Actor::DisableActor(int ano) {
PMOVER pActor;
assert(ano > 0 && ano <= NumActors); // illegal actor number
@@ -538,7 +344,7 @@ void DisableActor(int ano) {
* Enable actors.
* @param ano Actor Id
*/
-void EnableActor(int ano) {
+void Actor::EnableActor(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
// Re-incarnate only if it's dead, or it's script ran to completion
@@ -557,7 +363,7 @@ void EnableActor(int ano) {
* Returns the aliveness (to coin a word) of the actor.
* @param ano Actor Id
*/
-bool actorAlive(int ano) {
+bool Actor::actorAlive(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
return actorInfo[ano - 1].bAlive;
@@ -569,7 +375,7 @@ bool actorAlive(int ano) {
* @param tagtext Scene handle
* @param tp tType
*/
-void Tag_Actor(int ano, SCNHANDLE tagtext, int tp) {
+void Actor::Tag_Actor(int ano, SCNHANDLE tagtext, int tp) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
actorInfo[ano-1].tagged = true;
@@ -583,7 +389,7 @@ void Tag_Actor(int ano, SCNHANDLE tagtext, int tp) {
* @param tagtext Scene handle
* @param tp tType
*/
-void UnTagActor(int ano) {
+void Actor::UnTagActor(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
actorInfo[ano-1].tagged = false;
@@ -595,7 +401,7 @@ void UnTagActor(int ano) {
* @param tagtext Scene handle
* @param tp tType
*/
-void ReTagActor(int ano) {
+void Actor::ReTagActor(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
if (actorInfo[ano-1].hTag)
@@ -606,7 +412,7 @@ void ReTagActor(int ano) {
* Returns a tagged actor's tag type. e.g. TAG_Q1TO3
* @param ano Actor Id
*/
-int TagType(int ano) {
+int Actor::TagType(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
return actorInfo[ano-1].tType;
@@ -616,7 +422,7 @@ int TagType(int ano) {
* Returns handle to tagged actor's tag text
* @param ano Actor Id
*/
-SCNHANDLE GetActorTag(int ano) {
+SCNHANDLE Actor::GetActorTag(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
return actorInfo[ano - 1].hTag;
@@ -627,7 +433,7 @@ SCNHANDLE GetActorTag(int ano) {
* NextTagged Actor is repeatedly called until the caller gets fed up
* or there are no more tagged actors to look at.
*/
-void FirstTaggedActor() {
+void Actor::FirstTaggedActor() {
ti = 0;
}
@@ -636,7 +442,7 @@ void FirstTaggedActor() {
* NextTagged Actor is repeatedly called until the caller gets fed up
* or there are no more tagged actors to look at.
*/
-int NextTaggedActor() {
+int Actor::NextTaggedActor() {
PMOVER pActor;
bool hid;
@@ -663,7 +469,7 @@ int NextTaggedActor() {
* called repeatedly until the caller gets fed up or
* there are no more tagged actors to look at.
*/
-int NextTaggedActor(int previous) {
+int Actor::NextTaggedActor(int previous) {
PMOVER pMover;
// Convert actor number to index
@@ -697,7 +503,7 @@ int NextTaggedActor(int previous) {
* Returns the masking type of the actor.
* @param ano Actor Id
*/
-int32 actorMaskType(int ano) {
+int32 Actor::actorMaskType(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
return actorInfo[ano - 1].mtype;
@@ -710,26 +516,26 @@ int32 actorMaskType(int ano) {
* @param x X position
* @param y Y position
*/
-void StoreActorPos(int ano, int x, int y) {
+void Actor::StoreActorPos(int ano, int x, int y) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
actorInfo[ano - 1].x = x;
actorInfo[ano - 1].y = y;
}
-void StoreActorSteps(int ano, int steps) {
+void Actor::StoreActorSteps(int ano, int steps) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
actorInfo[ano - 1].steps = steps;
}
-int GetActorSteps(int ano) {
+int Actor::GetActorSteps(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
return actorInfo[ano - 1].steps;
}
-void StoreActorZpos(int ano, int z, int column) {
+void Actor::StoreActorZpos(int ano, int z, int column) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
if (!TinselV2) {
@@ -758,7 +564,7 @@ void StoreActorZpos(int ano, int z, int column) {
}
}
-int GetActorZpos(int ano, int column) {
+int Actor::GetActorZpos(int ano, int column) {
RANGE_CHECK(ano);
// Find entry, there should be one
@@ -771,19 +577,19 @@ int GetActorZpos(int ano, int column) {
return 1000; // Nominal value
}
-void IncLoopCount(int ano) {
+void Actor::IncLoopCount(int ano) {
RANGE_CHECK(ano);
actorInfo[ano - 1].loopCount++;
}
-int GetLoopCount(int ano) {
+int Actor::GetLoopCount(int ano) {
RANGE_CHECK(ano);
return actorInfo[ano - 1].loopCount;
}
-void GetActorPos(int ano, int *x, int *y) {
+void Actor::GetActorPos(int ano, int *x, int *y) {
PMOVER pActor;
assert((ano > 0 && ano <= NumActors) || ano == LEAD_ACTOR); // unknown actor
@@ -805,7 +611,7 @@ void GetActorPos(int ano, int *x, int *y) {
* @param x Output x
* @param y Output y
*/
-void GetActorMidTop(int ano, int *x, int *y) {
+void Actor::GetActorMidTop(int ano, int *x, int *y) {
// Not used in JAPAN version
PMOVER pActor;
@@ -830,7 +636,7 @@ void GetActorMidTop(int ano, int *x, int *y) {
* Return the appropriate co-ordinate of the actor.
* @param ano Actor Id
*/
-int GetActorLeft(int ano) {
+int Actor::GetActorLeft(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
if (!TinselV2) {
@@ -872,7 +678,7 @@ int GetActorLeft(int ano) {
* Return the appropriate co-ordinate of the actor.
* @param ano Actor Id
*/
-int GetActorRight(int ano) {
+int Actor::GetActorRight(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
if (!TinselV2) {
@@ -913,7 +719,7 @@ int GetActorRight(int ano) {
* Return the appropriate co-ordinate of the actor.
* @param ano Actor Id
*/
-int GetActorTop(int ano) {
+int Actor::GetActorTop(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
if (!TinselV2) {
@@ -954,7 +760,7 @@ int GetActorTop(int ano) {
/**
* Return the appropriate co-ordinate of the actor.
*/
-int GetActorBottom(int ano) {
+int Actor::GetActorBottom(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
if (!TinselV2) {
@@ -991,76 +797,10 @@ int GetActorBottom(int ano) {
}
}
-/**
- * Shows the given actor
- */
-void ShowActor(CORO_PARAM, int ano) {
- PMOVER pMover;
- RANGE_CHECK(ano);
-
- CORO_BEGIN_CONTEXT;
- CORO_END_CONTEXT(_ctx);
-
- CORO_BEGIN_CODE(_ctx);
-
- // reset hidden flag
- actorInfo[ano - 1].bHidden = false;
-
- // Send event to tagged actors
- if (IsTaggedActor(ano))
- CORO_INVOKE_ARGS(ActorEvent, (CORO_SUBCTX, ano, SHOWEVENT, true, 0));
-
- // If moving actor involved, un-hide it
- pMover = GetMover(ano);
- if (pMover)
- UnHideMover(pMover);
-
- CORO_END_CODE;
-}
-
-/**
- * Set actor hidden status to true.
- * For a moving actor, actually hide it.
- * @param ano Actor Id
- */
-void HideActor(CORO_PARAM, int ano) {
- PMOVER pMover;
- assert((ano > 0 && ano <= NumActors) || ano == LEAD_ACTOR); // illegal actor
-
- CORO_BEGIN_CONTEXT;
- CORO_END_CONTEXT(_ctx);
-
- CORO_BEGIN_CODE(_ctx);
-
- if (TinselV2) {
- actorInfo[ano - 1].bHidden = true;
-
- // Send event to tagged actors
- // (this is duplicated in HideMover())
- if (IsTaggedActor(ano)) {
- CORO_INVOKE_ARGS(ActorEvent, (CORO_SUBCTX, ano, HIDEEVENT, true, 0));
-
- // It may be pointed to
- SetActorPointedTo(ano, false);
- SetActorTagWanted(ano, false, false, 0);
- }
- }
-
- // Get moving actor involved
- pMover = GetMover(ano);
-
- if (pMover)
- HideMover(pMover, 0);
- else if (!TinselV2)
- actorInfo[ano - 1].bHidden = true;
-
- CORO_END_CODE;
-}
-
/**
* Return actor hidden status.
*/
-bool ActorHidden(int ano) {
+bool Actor::ActorHidden(int ano) {
RANGE_CHECK(ano);
return actorInfo[ano - 1].bHidden;
@@ -1071,7 +811,7 @@ bool ActorHidden(int ano) {
* @param ano Actor Id
* @param sf sf
*/
-bool HideMovingActor(int ano, int sf) {
+bool Actor::HideMovingActor(int ano, int sf) {
PMOVER pActor;
assert((ano > 0 && ano <= NumActors) || ano == LEAD_ACTOR); // illegal actor
@@ -1093,7 +833,7 @@ bool HideMovingActor(int ano, int sf) {
* Unhide an actor if it's a moving actor.
* @param ano Actor Id
*/
-void unHideMovingActor(int ano) {
+void Actor::unHideMovingActor(int ano) {
PMOVER pActor;
assert((ano > 0 && ano <= NumActors) || ano == LEAD_ACTOR); // illegal actor
@@ -1111,7 +851,7 @@ void unHideMovingActor(int ano) {
* Moves the actor to where the splay() left it, and continues the
* actor's walk (if any) from the new co-ordinates.
*/
-void restoreMovement(int ano) {
+void Actor::restoreMovement(int ano) {
PMOVER pActor;
assert(ano > 0 && ano <= NumActors); // illegal actor number
@@ -1135,7 +875,7 @@ void restoreMovement(int ano) {
* More properly should be called:
* 'store_actor_reel_and/or_film_and/or_object()'
*/
-void storeActorReel(int ano, const FREEL *reel, SCNHANDLE hFilm, OBJECT *pobj, int reelnum, int x, int y) {
+void Actor::storeActorReel(int ano, const FREEL *reel, SCNHANDLE hFilm, OBJECT *pobj, int reelnum, int x, int y) {
PMOVER pActor;
assert(ano > 0 && ano <= NumActors); // illegal actor number
@@ -1164,7 +904,7 @@ void storeActorReel(int ano, const FREEL *reel, SCNHANDLE hFilm, OBJECT *pobj, i
/**
* Return the present reel/film of the actor.
*/
-const FREEL *actorReel(int ano) {
+const FREEL *Actor::actorReel(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
return actorInfo[ano - 1].presReel; // the present reel
@@ -1172,50 +912,50 @@ const FREEL *actorReel(int ano) {
/***************************************************************************/
-void SetActorPlayFilm(int ano, SCNHANDLE hFilm) {
+void Actor::SetActorPlayFilm(int ano, SCNHANDLE hFilm) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
actorInfo[ano - 1].playFilm = hFilm;
}
-SCNHANDLE GetActorPlayFilm(int ano) {
+SCNHANDLE Actor::GetActorPlayFilm(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
return actorInfo[ano - 1].playFilm;
}
-void SetActorTalkFilm(int ano, SCNHANDLE hFilm) {
+void Actor::SetActorTalkFilm(int ano, SCNHANDLE hFilm) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
actorInfo[ano - 1].talkFilm = hFilm;
}
-SCNHANDLE GetActorTalkFilm(int ano) {
+SCNHANDLE Actor::GetActorTalkFilm(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
return actorInfo[ano - 1].talkFilm;
}
-void SetActorTalking(int ano, bool tf) {
+void Actor::SetActorTalking(int ano, bool tf) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
actorInfo[ano - 1].bTalking = tf;
}
-bool ActorIsTalking(int ano) {
+bool Actor::ActorIsTalking(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
return actorInfo[ano - 1].bTalking;
}
-void SetActorLatestFilm(int ano, SCNHANDLE hFilm) {
+void Actor::SetActorLatestFilm(int ano, SCNHANDLE hFilm) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
actorInfo[ano - 1].latestFilm = hFilm;
actorInfo[ano - 1].steps = 0;
}
-SCNHANDLE GetActorLatestFilm(int ano) {
+SCNHANDLE Actor::GetActorLatestFilm(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
return actorInfo[ano - 1].latestFilm;
@@ -1223,14 +963,14 @@ SCNHANDLE GetActorLatestFilm(int ano) {
/***************************************************************************/
-void UpdateActorEsc(int ano, bool escOn, int escEvent) {
+void Actor::UpdateActorEsc(int ano, bool escOn, int escEvent) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
actorInfo[ano - 1].bEscOn = escOn;
actorInfo[ano - 1].escEvent = escEvent;
}
-void UpdateActorEsc(int ano, int escEvent) {
+void Actor::UpdateActorEsc(int ano, int escEvent) {
RANGE_CHECK(ano);
if (escEvent) {
@@ -1243,13 +983,13 @@ void UpdateActorEsc(int ano, int escEvent) {
}
-bool ActorEsc(int ano) {
+bool Actor::ActorEsc(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
return actorInfo[ano - 1].bEscOn;
}
-int ActorEev(int ano) {
+int Actor::ActorEev(int ano) {
assert(ano > 0 && ano <= NumActors); // illegal actor number
return actorInfo[ano - 1].escEvent;
@@ -1258,7 +998,7 @@ int ActorEev(int ano) {
/**
* Guess what these do.
*/
-int AsetZPos(OBJECT *pObj, int y, int32 z) {
+int Actor::AsetZPos(OBJECT *pObj, int y, int32 z) {
int zPos;
z += z ? -1 : 0;
@@ -1268,28 +1008,11 @@ int AsetZPos(OBJECT *pObj, int y, int32 z) {
return zPos;
}
-/**
- * Guess what these do.
- */
-void SetMoverZ(PMOVER pMover, int y, int32 zFactor) {
- if (!pMover->bHidden) {
- if (!TinselV2)
- AsetZPos(pMover->actorObj, y, zFactor);
- else if (MoverIsSWalking(pMover) && pMover->zOverride != -1) {
- // Special for SWalk()
- MultiSetZPosition(pMover->actorObj, (pMover->zOverride << ZSHIFT) + y);
- } else {
- // Normal case
- MultiSetZPosition(pMover->actorObj, (zFactor << ZSHIFT) + y);
- }
- }
-}
-
/**
* Stores actor's attributes.
* Currently only the speech colors.
*/
-void storeActorAttr(int ano, int r1, int g1, int b1) {
+void Actor::storeActorAttr(int ano, int r1, int g1, int b1) {
assert((ano > 0 && ano <= NumActors) || ano == -1); // illegal actor number
if (r1 > MAX_INTENSITY) r1 = MAX_INTENSITY; // } Ensure
@@ -1306,7 +1029,7 @@ void storeActorAttr(int ano, int r1, int g1, int b1) {
* Called from ActorRGB() - Stores actor's speech color.
*/
-void SetActorRGB(int ano, COLORREF color) {
+void Actor::SetActorRGB(int ano, COLORREF color) {
assert(ano >= 0 && ano <= NumActors);
if (ano)
@@ -1319,7 +1042,7 @@ void SetActorRGB(int ano, COLORREF color) {
* Get the actor's stored speech color.
* @param ano Actor Id
*/
-COLORREF GetActorRGB(int ano) {
+COLORREF Actor::GetActorRGB(int ano) {
// Not used in JAPAN version
assert((ano >= -1) && (ano <= NumActors)); // illegal actor number
@@ -1332,13 +1055,13 @@ COLORREF GetActorRGB(int ano) {
/**
* Set the actor's Z-factor
*/
-void SetActorZfactor(int ano, uint32 zFactor) {
+void Actor::SetActorZfactor(int ano, uint32 zFactor) {
RANGE_CHECK(ano);
zFactors[ano - 1] = (uint8)zFactor;
}
-uint32 GetActorZfactor(int ano) {
+uint32 Actor::GetActorZfactor(int ano) {
RANGE_CHECK(ano);
return zFactors[ano - 1];
@@ -1347,7 +1070,7 @@ uint32 GetActorZfactor(int ano) {
/**
* Store relevant information pertaining to currently existing actors.
*/
-int SaveActors(SAVED_ACTOR *sActorInfo) {
+int Actor::SaveActors(PSAVED_ACTOR sActorInfo) {
int i, j, k;
for (i = 0, j = 0; i < NumActors; i++) {
@@ -1386,7 +1109,7 @@ int SaveActors(SAVED_ACTOR *sActorInfo) {
/**
* Restore actor data
*/
-void RestoreActors(int numActors, PSAVED_ACTOR sActorInfo) {
+void Actor::RestoreActors(int numActors, PSAVED_ACTOR sActorInfo) {
int i, aIndex;
for (i = 0; i < numActors; i++) {
@@ -1402,36 +1125,53 @@ void RestoreActors(int numActors, PSAVED_ACTOR sActorInfo) {
}
}
-void SaveZpositions(void *zpp) {
+void Actor::SaveZpositions(void *zpp) {
memcpy(zpp, zPositions, sizeof(zPositions));
}
-void RestoreZpositions(void *zpp) {
+void Actor::RestoreZpositions(void *zpp) {
memcpy(zPositions, zpp, sizeof(zPositions));
}
-void SaveActorZ(byte *saveActorZ) {
+void Actor::SaveActorZ(byte *saveActorZ) {
assert(NumActors <= MAX_SAVED_ACTOR_Z);
memcpy(saveActorZ, zFactors, NumActors);
}
-void RestoreActorZ(byte *saveActorZ) {
+void Actor::RestoreActorZ(byte *saveActorZ) {
memcpy(zFactors, saveActorZ, NumActors);
}
-void setactorson() {
+void Actor::SetActorsOn() {
bActorsOn = true;
}
-void ActorsLife(int ano, bool bAlive) {
+void Actor::ToggleActor(int ano, bool show) {
+ assert((ano > 0 && ano <= NumActors) || ano == -1); // illegal actor number
+ actorInfo[ano - 1].bHidden = !show;
+}
+
+SCNHANDLE Actor::GetActorCode(int ano) {
assert((ano > 0 && ano <= NumActors) || ano == -1); // illegal actor number
+ return actorInfo[ano - 1].actorCode;
+}
- actorInfo[ano-1].bAlive = bAlive;
+SCNHANDLE Actor::GetTaggedActorCode(int ano) {
+ return taggedActors[ano - 1].hActorCode;
}
+void Actor::RunCodeToCompletion(int ano) {
+ assert((ano > 0 && ano <= NumActors) || ano == -1); // illegal actor number
+ actorInfo[ano - 1].completed = true;
+}
-void syncAllActorsAlive(Common::Serializer &s) {
+void Actor::ActorsLife(int ano, bool bAlive) {
+ assert((ano > 0 && ano <= NumActors) || ano == -1); // illegal actor number
+ actorInfo[ano - 1].bAlive = bAlive;
+}
+
+void Actor::syncAllActorsAlive(Common::Serializer &s) {
for (int i = 0; i < MAX_SAVED_ALIVES; i++) {
s.syncAsByte(actorInfo[i].bAlive);
s.syncAsByte(actorInfo[i].tagged);
@@ -1443,7 +1183,7 @@ void syncAllActorsAlive(Common::Serializer &s) {
/**
* Called from EndActor()
*/
-void dwEndActor(int ano) {
+void Actor::dwEndActor(int ano) {
int i;
RANGE_CHECK(ano);
@@ -1469,7 +1209,7 @@ void dwEndActor(int ano) {
/**
* Returns a tagged actor's tag portion.
*/
-void GetActorTagPortion(int ano, unsigned *top, unsigned *bottom, unsigned *left, unsigned *right) {
+void Actor::GetActorTagPortion(int ano, unsigned *top, unsigned *bottom, unsigned *left, unsigned *right) {
// Convert actor number to index
ano = TaggedActorIndex(ano);
@@ -1488,7 +1228,7 @@ void GetActorTagPortion(int ano, unsigned *top, unsigned *bottom, unsigned *left
/**
* Returns handle to tagged actor's tag text.
*/
-SCNHANDLE GetActorTagHandle(int ano) {
+SCNHANDLE Actor::GetActorTagHandle(int ano) {
// Convert actor number to index
ano = TaggedActorIndex(ano);
@@ -1496,7 +1236,7 @@ SCNHANDLE GetActorTagHandle(int ano) {
taggedActors[ano].hOverrideTag : taggedActors[ano].hTagText;
}
-void SetActorPointedTo(int actor, bool bPointedTo) {
+void Actor::SetActorPointedTo(int actor, bool bPointedTo) {
// Convert actor number to index
actor = TaggedActorIndex(actor);
@@ -1506,14 +1246,14 @@ void SetActorPointedTo(int actor, bool bPointedTo) {
taggedActors[actor].tagFlags &= ~POINTING;
}
-bool ActorIsPointedTo(int actor) {
+bool Actor::ActorIsPointedTo(int actor) {
// Convert actor number to index
actor = TaggedActorIndex(actor);
return (taggedActors[actor].tagFlags & POINTING);
}
-void SetActorTagWanted(int actor, bool bTagWanted, bool bCursor, SCNHANDLE hOverrideTag) {
+void Actor::SetActorTagWanted(int actor, bool bTagWanted, bool bCursor, SCNHANDLE hOverrideTag) {
// Convert actor number to index
actor = TaggedActorIndex(actor);
@@ -1531,7 +1271,7 @@ void SetActorTagWanted(int actor, bool bTagWanted, bool bCursor, SCNHANDLE hOver
taggedActors[actor].tagFlags &= ~FOLLOWCURSOR;
}
-bool ActorTagIsWanted(int actor) {
+bool Actor::ActorTagIsWanted(int actor) {
// Convert actor number to index
actor = TaggedActorIndex(actor);
@@ -1543,7 +1283,7 @@ bool ActorTagIsWanted(int actor) {
* whether the cursor is within the actor's tag area.
* Returns True for a positive result, False for negative.
*/
-bool InHotSpot(int ano, int curX, int curY) {
+bool Actor::InHotSpot(int ano, int curX, int curY) {
int aTop, aBot; // Top and bottom limits }
int aHeight; // Height } of active area
int aLeft, aRight; // Left and right }
@@ -1581,7 +1321,7 @@ bool InHotSpot(int ano, int curX, int curY) {
/**
* Front Tagged Actor
*/
-int FrontTaggedActor() {
+int Actor::FrontTaggedActor() {
int i;
for (i = 0; i < numTaggedActors; i++) {
@@ -1594,7 +1334,7 @@ int FrontTaggedActor() {
/**
* GetActorTagPos
*/
-void GetActorTagPos(int actor, int *pTagX, int *pTagY, bool bAbsolute) {
+void Actor::GetActorTagPos(int actor, int *pTagX, int *pTagY, bool bAbsolute) {
unsigned topEighth, botEighth;
int aTop; // Top and bottom limits }
int aHeight; // Height } of active area
@@ -1619,7 +1359,7 @@ void GetActorTagPos(int actor, int *pTagX, int *pTagY, bool bAbsolute) {
/**
* Is Tagged Actor
*/
-bool IsTaggedActor(int actor) {
+bool Actor::IsTaggedActor(int actor) {
int i;
for (i = 0; i < numTaggedActors; i++) {
@@ -1632,7 +1372,7 @@ bool IsTaggedActor(int actor) {
/**
* StoreActorPresFilm
*/
-void StoreActorPresFilm(int ano, SCNHANDLE hFilm, int x, int y) {
+void Actor::StoreActorPresFilm(int ano, SCNHANDLE hFilm, int x, int y) {
int i;
RANGE_CHECK(ano);
@@ -1655,7 +1395,7 @@ void StoreActorPresFilm(int ano, SCNHANDLE hFilm, int x, int y) {
/**
* GetActorPresFilm
*/
-SCNHANDLE GetActorPresFilm(int ano) {
+SCNHANDLE Actor::GetActorPresFilm(int ano) {
RANGE_CHECK(ano);
return actorInfo[ano - 1].presFilm;
@@ -1665,7 +1405,7 @@ SCNHANDLE GetActorPresFilm(int ano) {
/**
* GetActorFilmNumber
*/
-int GetActorFilmNumber(int ano) {
+int Actor::GetActorFilmNumber(int ano) {
RANGE_CHECK(ano);
return actorInfo[ano - 1].filmNum;
@@ -1675,7 +1415,7 @@ int GetActorFilmNumber(int ano) {
* More properly should be called:
* 'StoreActorReelAndObject()'
*/
-void StoreActorReel(int actor, int column, OBJECT *pObj) {
+void Actor::StoreActorReel(int actor, int column, OBJECT *pObj) {
RANGE_CHECK(actor);
int i;
@@ -1694,7 +1434,7 @@ void StoreActorReel(int actor, int column, OBJECT *pObj) {
/**
* NotPlayingReel
*/
-void NotPlayingReel(int actor, int filmNumber, int column) {
+void Actor::NotPlayingReel(int actor, int filmNumber, int column) {
int i;
RANGE_CHECK(actor);
@@ -1720,7 +1460,7 @@ void NotPlayingReel(int actor, int filmNumber, int column) {
actorInfo[actor-1].presFilm = 0;
}
-bool ActorReelPlaying(int actor, int column) {
+bool Actor::ActorReelPlaying(int actor, int column) {
RANGE_CHECK(actor);
for (int i = 0; i < MAX_REELS; i++) {
@@ -1730,4 +1470,222 @@ bool ActorReelPlaying(int actor, int column) {
return false;
}
+/**
+ * Runs actor's glitter code.
+ */
+static void ActorTinselProcess(CORO_PARAM, const void *param) {
+ // COROUTINE
+ CORO_BEGIN_CONTEXT;
+ INT_CONTEXT *pic;
+ bool bTookControl;
+ CORO_END_CONTEXT(_ctx);
+
+ // get the stuff copied to process when it was created
+ const ATP_INIT *atp = (const ATP_INIT *)param;
+
+ CORO_BEGIN_CODE(_ctx);
+
+ if (TinselV2) {
+ // Take control for CONVERSE events
+ if (atp->event == CONVERSE) {
+ _ctx->bTookControl = GetControl();
+ HideConversation(true);
+ } else
+ _ctx->bTookControl = false;
+
+ // Run the Glitter code
+ CORO_INVOKE_1(Interpret, atp->pic);
+
+ // Restore conv window if applicable
+ if (atp->event == CONVERSE) {
+ // Free control if we took it
+ if (_ctx->bTookControl)
+ ControlOn();
+
+ HideConversation(false);
+ }
+ } else {
+ CORO_INVOKE_1(AllowDclick, atp->bev); // May kill us if single click
+
+ // Run the Glitter code
+ assert(_vm->_actor->GetActorCode(atp->id)); // no code to run
+
+ _ctx->pic = InitInterpretContext(GS_ACTOR, _vm->_actor->GetActorCode(atp->id),
+ atp->event, NOPOLY, atp->id, NULL);
+ CORO_INVOKE_1(Interpret, _ctx->pic);
+
+ // If it gets here, actor's code has run to completion
+ _vm->_actor->RunCodeToCompletion(atp->id);
+ }
+
+ CORO_END_CODE;
+}
+
+static void ActorRestoredProcess(CORO_PARAM, const void *param) {
+ // COROUTINE
+ CORO_BEGIN_CONTEXT;
+ INT_CONTEXT *pic;
+ CORO_END_CONTEXT(_ctx);
+
+ // get the stuff copied to process when it was created
+ const RATP_INIT *r = (const RATP_INIT *)param;
+ bool isSavegame = r->pic->resumeState == RES_SAVEGAME;
+
+ CORO_BEGIN_CODE(_ctx);
+
+ _ctx->pic = RestoreInterpretContext(r->pic);
+
+ // The newly added check here specially sets the process to RES_NOT when loading a savegame.
+ // This is needed particularly for the Psychiatrist scene in Discworld 1 - otherwise Rincewind
+ // can't go upstairs without leaving the building and returning. If this patch causes problems
+ // in other scenes, an added check for the hCode == 1174490602 could be added.
+ if (isSavegame && TinselV1)
+ _ctx->pic->resumeState = RES_NOT;
+
+ CORO_INVOKE_1(Interpret, _ctx->pic);
+
+ // If it gets here, actor's code has run to completion
+ _vm->_actor->RunCodeToCompletion(r->id);
+
+ CORO_END_CODE;
+}
+
+/**
+ * Starts up process to runs actor's glitter code.
+ * @param ano Actor Id
+ * @param event Event structure
+ * @param be ButEvent
+ */
+void ActorEvent(int ano, TINSEL_EVENT event, PLR_EVENT be) {
+ ATP_INIT atp;
+
+ // Only if there is Glitter code associated with this actor.
+ if (_vm->_actor->GetActorCode(ano)) {
+ atp.id = ano;
+ atp.event = event;
+ atp.bev = be;
+ atp.pic = nullptr;
+ CoroScheduler.createProcess(PID_TCODE, ActorTinselProcess, &atp, sizeof(atp));
+ }
+}
+
+/**
+ * Same with the normal ActorEvent, but with null CORO context
+ */
+void ActorEvent(int ano, TINSEL_EVENT tEvent, bool bWait, int myEscape, bool *result) {
+ ActorEvent(Common::nullContext, ano, tEvent, bWait, myEscape, result);
+}
+
+/**
+ * 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;
+ Common::PPROCESS pProc;
+ CORO_END_CONTEXT(_ctx);
+
+ CORO_BEGIN_CODE(_ctx);
+
+ index = _vm->_actor->TaggedActorIndex(ano);
+ assert(_vm->_actor->GetTaggedActorCode(index + 1));
+ if (result)
+ *result = false;
+
+ atp.id = 0;
+ atp.event = tEvent;
+ atp.pic = InitInterpretContext(GS_ACTOR,
+ _vm->_actor->GetTaggedActorCode(index + 1),
+ tEvent,
+ NOPOLY, // No polygon
+ ano, // Actor
+ NULL, // No object
+ myEscape);
+
+ if (atp.pic != NULL) {
+ _ctx->pProc = CoroScheduler.createProcess(PID_TCODE, ActorTinselProcess, &atp, sizeof(atp));
+ AttachInterpret(atp.pic, _ctx->pProc);
+
+ if (bWait)
+ CORO_INVOKE_2(WaitInterpret, _ctx->pProc, result);
+ }
+
+ CORO_END_CODE;
+}
+
+/**
+ * Shows the given actor
+ */
+void ShowActor(CORO_PARAM, int ano) {
+ PMOVER pMover;
+ assert(ano > 0 && ano <= _vm->_actor->GetCount());
+
+ CORO_BEGIN_CONTEXT;
+ CORO_END_CONTEXT(_ctx);
+
+ CORO_BEGIN_CODE(_ctx);
+
+ // reset hidden flag
+ _vm->_actor->ToggleActor(ano, true);
+
+ // Send event to tagged actors
+ if (_vm->_actor->IsTaggedActor(ano))
+ CORO_INVOKE_ARGS(ActorEvent, (CORO_SUBCTX, ano, SHOWEVENT, true, 0));
+
+ // If moving actor involved, un-hide it
+ pMover = GetMover(ano);
+ if (pMover)
+ UnHideMover(pMover);
+
+ CORO_END_CODE;
+}
+
+/**
+ * Set actor hidden status to true.
+ * For a moving actor, actually hide it.
+ * @param ano Actor Id
+ */
+void HideActor(CORO_PARAM, int ano) {
+ PMOVER pMover;
+ assert((ano > 0 && ano <= _vm->_actor->GetCount()) || ano == LEAD_ACTOR); // illegal actor
+
+ CORO_BEGIN_CONTEXT;
+ CORO_END_CONTEXT(_ctx);
+
+ CORO_BEGIN_CODE(_ctx);
+
+ if (TinselV2) {
+ _vm->_actor->ToggleActor(ano, false);
+
+ // Send event to tagged actors
+ // (this is duplicated in HideMover())
+ if (_vm->_actor->IsTaggedActor(ano)) {
+ CORO_INVOKE_ARGS(ActorEvent, (CORO_SUBCTX, ano, HIDEEVENT, true, 0));
+
+ // It may be pointed to
+ _vm->_actor->SetActorPointedTo(ano, false);
+ _vm->_actor->SetActorTagWanted(ano, false, false, 0);
+ }
+ }
+
+ // Get moving actor involved
+ pMover = GetMover(ano);
+
+ if (pMover)
+ HideMover(pMover, 0);
+ else if (!TinselV2)
+ _vm->_actor->ToggleActor(ano, false);
+
+ CORO_END_CODE;
+}
+
+void RestoreActorProcess(int id, INT_CONTEXT *pic, bool savegameFlag) {
+ RATP_INIT r = {pic, id};
+ if (savegameFlag)
+ pic->resumeState = RES_SAVEGAME;
+
+ CoroScheduler.createProcess(PID_TCODE, ActorRestoredProcess, &r, sizeof(r));
+}
+
} // End of namespace Tinsel
diff --git a/engines/tinsel/actors.h b/engines/tinsel/actors.h
index 4d82e14f6a..eca5184053 100644
--- a/engines/tinsel/actors.h
+++ b/engines/tinsel/actors.h
@@ -28,6 +28,11 @@
#include "tinsel/dw.h" // for SCNHANDLE
#include "tinsel/events.h" // for TINSEL_EVENT
#include "tinsel/palette.h" // for COLORREF
+#include "tinsel/rince.h" // for PMOVER
+
+namespace Common {
+class Serializer;
+}
namespace Tinsel {
@@ -35,140 +40,185 @@ struct FREEL;
struct INT_CONTEXT;
struct MOVER;
struct OBJECT;
+struct T1_ACTOR_STRUC;
+struct T2_ACTOR_STRUC;
+struct ACTORINFO;
+struct Z_POSITIONS;
#define ACTORTAG_KEY 0x1000000
-
#define OTH_RELATEDACTOR 0x00000fff
#define OTH_RELATIVE 0x00001000
#define OTH_ABSOLUTE 0x00002000
-
-/*----------------------------------------------------------------------*/
-
-void RegisterActors(int num);
-void FreeActors();
-void SetLeadId(int rid);
-int GetLeadId();
-bool ActorIsGhost(int actor);
-void StartTaggedActors(SCNHANDLE ah, int numActors, bool bRunScript);
-void DropActors(); // No actor reels running
-void DisableActor(int actor);
-void EnableActor(int actor);
-void Tag_Actor(int ano, SCNHANDLE tagtext, int tp);
-void UnTagActor(int ano);
-void ReTagActor(int ano);
-int TagType(int ano);
-bool actorAlive(int ano);
-int32 actorMaskType(int ano);
-void GetActorPos(int ano, int *x, int *y);
-void SetActorPos(int ano, int x, int y);
-void GetActorMidTop(int ano, int *x, int *y);
-int GetActorLeft(int ano);
-int GetActorRight(int ano);
-int GetActorTop(int ano);
-int GetActorBottom(int ano);
-void ShowActor(CORO_PARAM, int ano);
-void HideActor(CORO_PARAM, int ano);
-bool ActorHidden(int ano);
-bool HideMovingActor(int id, int sf);
-void unHideMovingActor(int id);
-void restoreMovement(int id);
-void storeActorReel(int ano, const FREEL *reel, SCNHANDLE hFilm, OBJECT *pobj, int reelnum, int x, int y);
-const FREEL *actorReel(int ano);
-SCNHANDLE actorFilm(int ano);
-
-void SetActorPlayFilm(int ano, SCNHANDLE hFilm);
-SCNHANDLE GetActorPlayFilm(int ano);
-void SetActorTalkFilm(int ano, SCNHANDLE hFilm);
-SCNHANDLE GetActorTalkFilm(int ano);
-void SetActorTalking(int ano, bool tf);
-bool ActorIsTalking(int ano);
-void SetActorLatestFilm(int ano, SCNHANDLE hFilm);
-SCNHANDLE GetActorLatestFilm(int ano);
-
-void UpdateActorEsc(int ano, bool escOn, int escEvent);
-void UpdateActorEsc(int ano, int escEvent);
-bool ActorEsc(int ano);
-int ActorEev(int ano);
-void StoreActorPos(int ano, int x, int y);
-void StoreActorSteps(int ano, int steps);
-int GetActorSteps(int ano);
-void StoreActorZpos(int ano, int z, int column = -1);
-int GetActorZpos(int ano, int column);
-void IncLoopCount(int ano);
-int GetLoopCount(int ano);
-SCNHANDLE GetActorTag(int ano);
-void FirstTaggedActor();
-int NextTaggedActor();
-int NextTaggedActor(int previous);
-int AsetZPos(OBJECT *pObj, int y, int32 zFactor);
-void SetMoverZ(MOVER *pMover, int y, int32 zFactor);
-void ActorEvent(int ano, TINSEL_EVENT event, PLR_EVENT be);
-
-void storeActorAttr(int ano, int r1, int g1, int b1);
-COLORREF GetActorRGB(int ano);
-void SetActorRGB(int ano, COLORREF color);
-void SetActorZfactor(int ano, uint32 zFactor);
-uint32 GetActorZfactor(int ano);
-
-void setactorson();
-
-void ActorsLife(int id, bool bAlive);
-
-void dwEndActor(int ano);
-
-void ActorEvent(CORO_PARAM, int ano, TINSEL_EVENT tEvent, bool bWait, int myEscape, bool *result = NULL);
-
-void GetActorTagPortion(int ano, unsigned *top, unsigned *bottom, unsigned *left, unsigned *right);
-SCNHANDLE GetActorTagHandle(int ano);
-void SetActorPointedTo(int actor, bool bPointedTo);
-bool ActorIsPointedTo(int actor);
-void SetActorTagWanted(int actor, bool bTagWanted, bool bCursor, SCNHANDLE hOverrideTag);
-bool ActorTagIsWanted(int actor);
-bool InHotSpot(int ano, int curX, int curY);
-int FrontTaggedActor();
-void GetActorTagPos(int actor, int *pTagX, int *pTagY, bool bAbsolute);
-bool IsTaggedActor(int actor);
-void StoreActorPresFilm(int ano, SCNHANDLE hFilm, int x, int y);
-SCNHANDLE GetActorPresFilm(int ano);
-int GetActorFilmNumber(int ano);
-void StoreActorReel(int actor, int column, OBJECT *pObj);
-void NotPlayingReel(int actor, int filmNumber, int column);
-bool ActorReelPlaying(int actor, int column);
-
-/*----------------------------------------------------------------------*/
+#define MAX_TAGACTORS 10
+#define NUM_ZPOSITIONS 200 // Reasonable-sounding number
+#define MAX_REELS 6
+
+struct TAGACTOR {
+ // Copies of compiled data
+ int id;
+ SCNHANDLE hTagText; // handle to tag text
+ int32 tagPortionV; // which portion is active
+ int32 tagPortionH; // which portion is active
+ SCNHANDLE hActorCode; // The actor's script
+
+ int tagFlags;
+ SCNHANDLE hOverrideTag; // Override tag.
+};
struct SAVED_ACTOR {
- short actorID;
- short zFactor;
- bool bAlive;
- bool bHidden;
- SCNHANDLE presFilm; ///< the film that reel belongs to
- short presRnum; ///< the present reel number
- short presPlayX, presPlayY;
+ short actorID;
+ short zFactor;
+ bool bAlive;
+ bool bHidden;
+ SCNHANDLE presFilm; ///< the film that reel belongs to
+ short presRnum; ///< the present reel number
+ short presPlayX, presPlayY;
};
-typedef SAVED_ACTOR *PSAVED_ACTOR;
-
-#define NUM_ZPOSITIONS 200 // Reasonable-sounding number
struct Z_POSITIONS {
- short actor;
- short column;
- int z;
+ short actor;
+ short column;
+ int z;
};
-void RestoreActorProcess(int id, INT_CONTEXT *pic, bool savegameFlag);
-
-int SaveActors(PSAVED_ACTOR sActorInfo);
-void RestoreActors(int numActors, PSAVED_ACTOR sActorInfo);
+typedef TAGACTOR *PTAGACTOR;
+typedef SAVED_ACTOR *PSAVED_ACTOR;
-void SaveZpositions(void *zpp);
-void RestoreZpositions(void *zpp);
+/*----------------------------------------------------------------------*/
-void SaveActorZ(byte *saveActorZ);
-void RestoreActorZ(byte *saveActorZ);
+class Actor {
+public:
+ Actor(): actorInfo(nullptr), defaultColor(0), bActorsOn(false), ti(0), numTaggedActors(0), zFactors(nullptr), LeadActorId(0), NumActors(0) {}
+ int GetLeadId();
+ SCNHANDLE GetActorTagHandle(int ano);
+ void ToggleActor(int ano, bool show);
+ SCNHANDLE GetActorCode(int ano);
+ SCNHANDLE GetTaggedActorCode(int ano);
+ void RunCodeToCompletion(int ano);
+ int GetCount() { return NumActors; }
+
+ void RegisterActors(int num);
+ void FreeActors();
+ void SetLeadId(int rid);
+ bool ActorIsGhost(int actor);
+ void StartTaggedActors(SCNHANDLE ah, int numActors, bool bRunScript);
+ void DropActors(); // No actor reels running
+
+ void DisableActor(int actor);
+ void EnableActor(int actor);
+
+ void Tag_Actor(int ano, SCNHANDLE tagtext, int tp);
+ void UnTagActor(int ano);
+ void ReTagActor(int ano);
+ int TagType(int ano);
+
+ bool actorAlive(int ano);
+ int32 actorMaskType(int ano);
+ void GetActorPos(int ano, int *x, int *y);
+ void GetActorMidTop(int ano, int *x, int *y);
+ int GetActorLeft(int ano);
+ int GetActorRight(int ano);
+ int GetActorTop(int ano);
+ int GetActorBottom(int ano);
+ bool ActorHidden(int ano);
+ bool HideMovingActor(int id, int sf);
+ void unHideMovingActor(int id);
+ void restoreMovement(int id);
+ void storeActorReel(int ano, const FREEL *reel, SCNHANDLE hFilm, OBJECT *pobj, int reelnum, int x, int y);
+ const FREEL *actorReel(int ano);
+
+ void SetActorPlayFilm(int ano, SCNHANDLE hFilm);
+ SCNHANDLE GetActorPlayFilm(int ano);
+ void SetActorTalkFilm(int ano, SCNHANDLE hFilm);
+ SCNHANDLE GetActorTalkFilm(int ano);
+
+ void SetActorTalking(int ano, bool tf);
+ bool ActorIsTalking(int ano);
+ void SetActorLatestFilm(int ano, SCNHANDLE hFilm);
+ SCNHANDLE GetActorLatestFilm(int ano);
+
+ void UpdateActorEsc(int ano, bool escOn, int escEvent);
+ void UpdateActorEsc(int ano, int escEvent);
+ bool ActorEsc(int ano);
+ int ActorEev(int ano);
+ void StoreActorPos(int ano, int x, int y);
+ void StoreActorSteps(int ano, int steps);
+ int GetActorSteps(int ano);
+
+ void StoreActorZpos(int ano, int z, int column = -1);
+ int GetActorZpos(int ano, int column);
+ void IncLoopCount(int ano);
+ int GetLoopCount(int ano);
+ SCNHANDLE GetActorTag(int ano);
+ void FirstTaggedActor();
+ int NextTaggedActor();
+ int NextTaggedActor(int previous);
+ int AsetZPos(OBJECT *pObj, int y, int32 zFactor);
+
+ void storeActorAttr(int ano, int r1, int g1, int b1);
+ COLORREF GetActorRGB(int ano);
+ void SetActorRGB(int ano, COLORREF color);
+ void SetActorZfactor(int ano, uint32 zFactor);
+ uint32 GetActorZfactor(int ano);
+ void SetActorsOn();
+ void ActorsLife(int id, bool bAlive);
+ void dwEndActor(int ano);
+
+ void SetActorPointedTo(int actor, bool bPointedTo);
+ bool ActorIsPointedTo(int actor);
+ void SetActorTagWanted(int actor, bool bTagWanted, bool bCursor, SCNHANDLE hOverrideTag);
+ bool ActorTagIsWanted(int actor);
+ bool InHotSpot(int ano, int curX, int curY);
+ int FrontTaggedActor();
+ void GetActorTagPos(int actor, int *pTagX, int *pTagY, bool bAbsolute);
+ bool IsTaggedActor(int actor);
+
+ void StoreActorPresFilm(int ano, SCNHANDLE hFilm, int x, int y);
+ SCNHANDLE GetActorPresFilm(int ano);
+ int GetActorFilmNumber(int ano);
+
+ void StoreActorReel(int actor, int column, OBJECT *pObj);
+ void NotPlayingReel(int actor, int filmNumber, int column);
+ bool ActorReelPlaying(int actor, int column);
+
+ int SaveActors(PSAVED_ACTOR sActorInfo);
+ void RestoreActors(int numActors, PSAVED_ACTOR sActorInfo);
+
+ void SaveZpositions(void *zpp);
+ void RestoreZpositions(void *zpp);
+
+ void SaveActorZ(byte *saveActorZ);
+ void RestoreActorZ(byte *saveActorZ);
+
+ int TaggedActorIndex(int actor);
+
+ void syncAllActorsAlive(Common::Serializer &s);
+
+private:
+ void StartActor(const T1_ACTOR_STRUC *as, bool bRunScript);
+ void GetActorTagPortion(int ano, unsigned *top, unsigned *bottom, unsigned *left, unsigned *right);
+
+ ACTORINFO *actorInfo;
+ COLORREF defaultColor; // Text color
+ bool bActorsOn;
+ int ti;
+ TAGACTOR taggedActors[MAX_TAGACTORS];
+ int numTaggedActors;
+ uint8 *zFactors;
+ Z_POSITIONS zPositions[NUM_ZPOSITIONS];
+ int LeadActorId; // The lead actor
+ int NumActors; // The total number of actors in the game
+};
/*----------------------------------------------------------------------*/
+void ActorEvent(int ano, TINSEL_EVENT event, PLR_EVENT be);
+void ActorEvent(CORO_PARAM, int ano, TINSEL_EVENT tEvent, bool bWait, int myEscape, bool *result = NULL);
+void ActorEvent(int ano, TINSEL_EVENT tEvent, bool bWait, int myEscape, bool *result = NULL);
+void ShowActor(CORO_PARAM, int ano);
+void HideActor(CORO_PARAM, int ano);
+void RestoreActorProcess(int id, INT_CONTEXT *pic, bool savegameFlag);
+
} // End of namespace Tinsel
#endif /* TINSEL_ACTOR_H */
diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp
index 12ea026a04..1c1422fae1 100644
--- a/engines/tinsel/dialogs.cpp
+++ b/engines/tinsel/dialogs.cpp
@@ -3538,7 +3538,7 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {
extern void ConvAction(int index) {
assert(g_ino == INV_CONV); // not conv. window!
- PMOVER pMover = TinselV2 ? GetMover(GetLeadId()) : NULL;
+ PMOVER pMover = TinselV2 ? GetMover(_vm->_actor->GetLeadId()) : NULL;
switch (index) {
case INV_NOICON:
@@ -3598,7 +3598,7 @@ extern void SetConvDetails(CONV_PARAM fn, HPOLYGON hPoly, int ano) {
int x, y;
GetTagTag(hPoly, &g_InvD[INV_CONV].hInvTitle, &x, &y);
} else {
- g_InvD[INV_CONV].hInvTitle = GetActorTagHandle(ano);
+ g_InvD[INV_CONV].hInvTitle = _vm->_actor->GetActorTagHandle(ano);
}
}
@@ -3717,7 +3717,7 @@ extern void HideConversation(bool bHide) {
if (g_thisConvActor) {
int Loffset, Toffset;
- GetActorMidTop(g_thisConvActor, &x, &y);
+ _vm->_actor->GetActorMidTop(g_thisConvActor, &x, &y);
_vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
x -= Loffset;
y -= Toffset;
@@ -3774,7 +3774,7 @@ extern void HideConversation(bool bHide) {
int Loffset, Toffset;
_vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
- y = GetActorBottom(g_thisConvActor) - MultiHighest(g_RectObject) +
+ y = _vm->_actor->GetActorBottom(g_thisConvActor) - MultiHighest(g_RectObject) +
SysVar(SV_CONV_BELOW_Y);
y -= Toffset;
}
diff --git a/engines/tinsel/faders.cpp b/engines/tinsel/faders.cpp
index 0a28ea1460..a518e9d065 100644
--- a/engines/tinsel/faders.cpp
+++ b/engines/tinsel/faders.cpp
@@ -209,7 +209,7 @@ void FadeInFast() {
void PokeInTagColor() {
if (SysVar(SV_TAGCOLOR)) {
- const COLORREF c = GetActorRGB(-1);
+ const COLORREF c = _vm->_actor->GetActorRGB(-1);
UpdateDACqueue(SysVar(SV_TAGCOLOR), c);
}
}
diff --git a/engines/tinsel/font.cpp b/engines/tinsel/font.cpp
index d1271cbdac..c3a34bbf45 100644
--- a/engines/tinsel/font.cpp
+++ b/engines/tinsel/font.cpp
@@ -65,7 +65,7 @@ void Font::FettleFontPal(SCNHANDLE fontPal) {
pImg->hImgPal = 0;
if (TinselV2 && SysVar(SV_TAGCOLOR)) {
- const COLORREF c = GetActorRGB(-1);
+ const COLORREF c = _vm->_actor->GetActorRGB(-1);
SetTagColorRef(c);
UpdateDACqueue(SysVar(SV_TAGCOLOR), c);
}
diff --git a/engines/tinsel/move.cpp b/engines/tinsel/move.cpp
index 7a59568609..826703bbf7 100644
--- a/engines/tinsel/move.cpp
+++ b/engines/tinsel/move.cpp
@@ -525,7 +525,7 @@ static void GotThere(PMOVER pMover) {
}
if (!TinselV2)
- ReTagActor(pMover->actorID); // Tag allowed while stationary
+ _vm->_actor->ReTagActor(pMover->actorID); // Tag allowed while stationary
SetMoverStanding(pMover);
pMover->bMoving = false;
@@ -1338,8 +1338,8 @@ int SetActorDest(PMOVER pMover, int clickX, int clickY, bool igPath, SCNHANDLE h
// Fix interrupted-walking-to-wardrobe bug in mortuary
StopMover(pMover);
} else {
- if (pMover->actorID == GetLeadId()) // Now only for lead actor
- UnTagActor(pMover->actorID); // Tag not allowed while moving
+ if (pMover->actorID == _vm->_actor->GetLeadId()) // Now only for lead actor
+ _vm->_actor->UnTagActor(pMover->actorID); // Tag not allowed while moving
}
pMover->walkNumber++;
@@ -1364,14 +1364,14 @@ int SetActorDest(PMOVER pMover, int clickX, int clickY, bool igPath, SCNHANDLE h
targetX = clickX;
targetY = clickY;
- if (pMover->actorID == GetLeadId()) {
+ if (pMover->actorID == _vm->_actor->GetLeadId()) {
g_lastLeadXdest = targetX;
g_lastLeadYdest = targetY;
}
} else {
int wodResult = WorkOutDestination(clickX, clickY, &targetX, &targetY);
- if (pMover->actorID == GetLeadId()) {
+ if (pMover->actorID == _vm->_actor->GetLeadId()) {
g_lastLeadXdest = targetX;
g_lastLeadYdest = targetY;
}
diff --git a/engines/tinsel/pdisplay.cpp b/engines/tinsel/pdisplay.cpp
index 4ce844f11d..afe5683409 100644
--- a/engines/tinsel/pdisplay.cpp
+++ b/engines/tinsel/pdisplay.cpp
@@ -270,10 +270,10 @@ void DisablePointing() {
}
// For each tagged actor
- for (i = 0; (i = NextTaggedActor(i)) != 0; ) {
- if (ActorIsPointedTo(i)) {
- SetActorPointedTo(i, false);
- SetActorTagWanted(i, false, false, 0);
+ for (i = 0; (i = _vm->_actor->NextTaggedActor(i)) != 0;) {
+ if (_vm->_actor->ActorIsPointedTo(i)) {
+ _vm->_actor->SetActorPointedTo(i, false);
+ _vm->_actor->SetActorTagWanted(i, false, false, 0);
ActorEvent(Common::nullContext, i, UNPOINT, false, 0);
}
@@ -328,12 +328,12 @@ static bool InHotSpot(int ano, int aniX, int aniY, int *pxtext, int *pytext) {
int qrt = 0; // 1/4 of height (sometimes 1/2)
// First check if within x-range
- if (aniX > (left = GetActorLeft(ano)) && aniX < (right = GetActorRight(ano))) {
- Top = GetActorTop(ano);
- Bot = GetActorBottom(ano);
+ if (aniX > (left = _vm->_actor->GetActorLeft(ano)) && aniX < (right = _vm->_actor->GetActorRight(ano))) {
+ Top = _vm->_actor->GetActorTop(ano);
+ Bot = _vm->_actor->GetActorBottom(ano);
// y-range varies according to tag-type
- switch (TagType(ano)) {
+ switch (_vm->_actor->TagType(ano)) {
case TAG_DEF:
// Next to bottom 1/4 of the actor's area
qrt = (Bot - Top) >> 1; // Half actor's height
@@ -359,7 +359,7 @@ static bool InHotSpot(int ano, int aniX, int aniY, int *pxtext, int *pytext) {
// Now check if within y-range
if (aniY >= Top && aniY <= Bot) {
- if (TagType(ano) == TAG_Q1TO3)
+ if (_vm->_actor->TagType(ano) == TAG_Q1TO3)
*pytext = Top + qrt;
else
*pytext = Top;
@@ -386,7 +386,7 @@ static bool ActorTag(int curX, int curY, HotSpotTag *pTag, OBJECT **ppText) {
if (TinselV2) {
// Tinsel 2 version
// Get the foremost pointed to actor
- int actor = FrontTaggedActor();
+ int actor = _vm->_actor->FrontTaggedActor();
if (actor == 0) {
SaveTaggedActor(0);
@@ -395,7 +395,7 @@ static bool ActorTag(int curX, int curY, HotSpotTag *pTag, OBJECT **ppText) {
// If new actor
// or actor has suddenly decided it wants tagging...
- if (actor != GetTaggedActor() || (ActorTagIsWanted(actor) && !*ppText)) {
+ if (actor != GetTaggedActor() || (_vm->_actor->ActorTagIsWanted(actor) && !*ppText)) {
// Put up actor tag
SaveTaggedActor(actor); // This actor tagged
SaveTaggedPoly(NOPOLY); // No tagged polygon
@@ -403,9 +403,9 @@ static bool ActorTag(int curX, int curY, HotSpotTag *pTag, OBJECT **ppText) {
if (*ppText)
MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), *ppText);
- if (ActorTagIsWanted(actor)) {
- GetActorTagPos(actor, &tagX, &tagY, false);
- LoadStringRes(GetActorTagHandle(actor), g_tagBuffer, sizeof(g_tagBuffer));
+ if (_vm->_actor->ActorTagIsWanted(actor)) {
+ _vm->_actor->GetActorTagPos(actor, &tagX, &tagY, false);
+ LoadStringRes(_vm->_actor->GetActorTagHandle(actor), g_tagBuffer, sizeof(g_tagBuffer));
// May have buggered cursor
_vm->_cursor->EndCursorFollowed();
@@ -417,7 +417,7 @@ static bool ActorTag(int curX, int curY, HotSpotTag *pTag, OBJECT **ppText) {
*ppText = nullptr;
} else if (*ppText) {
// Same actor, maintain tag position
- GetActorTagPos(actor, &newX, &newY, false);
+ _vm->_actor->GetActorTagPos(actor, &newX, &newY, false);
if (newX != tagX || newY != tagY) {
MultiMoveRelXY(*ppText, newX - tagX, newY - tagY);
@@ -431,8 +431,8 @@ static bool ActorTag(int curX, int curY, HotSpotTag *pTag, OBJECT **ppText) {
// Tinsel 1 version
// For each actor with a tag....
- FirstTaggedActor();
- while ((ano = NextTaggedActor()) != 0) {
+ _vm->_actor->FirstTaggedActor();
+ while ((ano = _vm->_actor->NextTaggedActor()) != 0) {
if (InHotSpot(ano, curX, curY, &xtext, &ytext)) {
// Put up or maintain actor tag
if (*pTag != ACTOR_HOTSPOT_TAG)
@@ -453,7 +453,7 @@ static bool ActorTag(int curX, int curY, HotSpotTag *pTag, OBJECT **ppText) {
SaveTaggedPoly(NOPOLY); // No tagged polygon
_vm->_bg->PlayfieldGetPos(FIELD_WORLD, &tagX, &tagY);
- LoadStringRes(GetActorTag(ano), _vm->_font->TextBufferAddr(), TBUFSZ);
+ LoadStringRes(_vm->_actor->GetActorTag(ano), _vm->_font->TextBufferAddr(), TBUFSZ);
*ppText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(),
0, xtext - tagX, ytext - tagY, _vm->_font->GetTagFontHandle(), TXT_CENTER);
assert(*ppText); // Actor tag string produced NULL text
@@ -786,16 +786,16 @@ void PointProcess(CORO_PARAM, const void *) {
if (TinselV2) {
// For each tagged actor
- for (_ctx->i = 0; (_ctx->i = NextTaggedActor(_ctx->i)) != 0; ) {
- if (!ActorIsPointedTo(_ctx->i)) {
- if (InHotSpot(_ctx->i, _ctx->curX, _ctx->curY)) {
- SetActorPointedTo(_ctx->i, true);
+ for (_ctx->i = 0; (_ctx->i = _vm->_actor->NextTaggedActor(_ctx->i)) != 0;) {
+ if (!_vm->_actor->ActorIsPointedTo(_ctx->i)) {
+ if (_vm->_actor->InHotSpot(_ctx->i, _ctx->curX, _ctx->curY)) {
+ _vm->_actor->SetActorPointedTo(_ctx->i, true);
CORO_INVOKE_ARGS(ActorEvent, (CORO_SUBCTX, _ctx->i, POINTED, false, 0));
}
} else {
- if (!InHotSpot(_ctx->i, _ctx->curX, _ctx->curY)) {
- SetActorPointedTo(_ctx->i, false);
- SetActorTagWanted(_ctx->i, false, false, 0);
+ if (!_vm->_actor->InHotSpot(_ctx->i, _ctx->curX, _ctx->curY)) {
+ _vm->_actor->SetActorPointedTo(_ctx->i, false);
+ _vm->_actor->SetActorTagWanted(_ctx->i, false, false, 0);
CORO_INVOKE_ARGS(ActorEvent, (CORO_SUBCTX, _ctx->i, UNPOINT, false, 0));
}
}
diff --git a/engines/tinsel/play.cpp b/engines/tinsel/play.cpp
index c9fa16b950..7829515baa 100644
--- a/engines/tinsel/play.cpp
+++ b/engines/tinsel/play.cpp
@@ -118,7 +118,7 @@ int32 NoNameFunc(int actorID, bool bNewMover) {
else
retval = GetPolyZfactor(pActor->hCpath);
} else {
- switch (actorMaskType(actorID)) {
+ switch (_vm->_actor->actorMaskType(actorID)) {
case ACT_DEFAULT:
retval = 0;
break;
@@ -129,7 +129,7 @@ int32 NoNameFunc(int actorID, bool bNewMover) {
retval = 10;
break;
default:
- retval = actorMaskType(actorID);
+ retval = _vm->_actor->actorMaskType(actorID);
break;
}
}
@@ -202,7 +202,7 @@ static uint32 GetZfactor(int actorID, PMOVER pMover, bool bNewMover) {
else
return GetPolyZfactor(pMover->hCpath);
} else {
- return GetActorZfactor(actorID);
+ return _vm->_actor->GetActorZfactor(actorID);
}
}
@@ -354,7 +354,7 @@ static void SoundReel(CORO_PARAM, SCNHANDLE hFilm, int column, int speed,
CORO_SLEEP(_ctx->speed);
_ctx->frameNumber++;
- if (_ctx->reelActor && GetActorPresFilm(_ctx->reelActor) != hFilm) {
+ if (_ctx->reelActor && _vm->_actor->GetActorPresFilm(_ctx->reelActor) != hFilm) {
// Stop this sample if repeating
if (_ctx->sampleNumber && _ctx->bLooped)
_vm->_sound->stopSpecSample(_ctx->sampleNumber, 0);
@@ -460,34 +460,34 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) {
_ctx->reelActor = (int32)FROM_32(pmi->mulID);
/**** New (experimental? bit 5/1/95 ****/
- if (!TinselV0 && !actorAlive(_ctx->reelActor))
+ if (!TinselV0 && !_vm->_actor->actorAlive(_ctx->reelActor))
return;
/**** Delete a bit down there if this stays ****/
- UpdateActorEsc(_ctx->reelActor, ppi->escOn, ppi->myescEvent);
+ _vm->_actor->UpdateActorEsc(_ctx->reelActor, ppi->escOn, ppi->myescEvent);
// To handle the play()-talk(), talk()-play(), talk()-talk() and play()-play() scenarios
- if (ppi->hFilm != GetActorLatestFilm(_ctx->reelActor)) {
+ if (ppi->hFilm != _vm->_actor->GetActorLatestFilm(_ctx->reelActor)) {
// This in not the last film scheduled for this actor
// It may be the last non-talk film though
- if (ActorIsTalking(_ctx->reelActor))
- SetActorPlayFilm(_ctx->reelActor, ppi->hFilm); // Revert to this film after talk
+ if (_vm->_actor->ActorIsTalking(_ctx->reelActor))
+ _vm->_actor->SetActorPlayFilm(_ctx->reelActor, ppi->hFilm); // Revert to this film after talk
return;
}
- if (ActorIsTalking(_ctx->reelActor)) {
+ if (_vm->_actor->ActorIsTalking(_ctx->reelActor)) {
// Note: will delete this and there'll be no need to store the talk film!
- if (ppi->hFilm != GetActorTalkFilm(_ctx->reelActor)) {
- SetActorPlayFilm(_ctx->reelActor, ppi->hFilm); // Revert to this film after talk
+ if (ppi->hFilm != _vm->_actor->GetActorTalkFilm(_ctx->reelActor)) {
+ _vm->_actor->SetActorPlayFilm(_ctx->reelActor, ppi->hFilm); // Revert to this film after talk
return;
}
} else {
- SetActorPlayFilm(_ctx->reelActor, ppi->hFilm);
+ _vm->_actor->SetActorPlayFilm(_ctx->reelActor, ppi->hFilm);
}
// If this reel is already playing for this actor, just forget it.
- if (actorReel(_ctx->reelActor) == _ctx->pfreel)
+ if (_vm->_actor->actorReel(_ctx->reelActor) == _ctx->pfreel)
return;
// Poke in the background palette
@@ -510,13 +510,13 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) {
} else if (_ctx->tmpX != -1 || _ctx->tmpY != -1) {
MultiSetAniXY(_ctx->pPlayObj, _ctx->tmpX, _ctx->tmpY);
} else if (!pmi->mulX && !pmi->mulY) {
- GetActorPos(_ctx->reelActor, &_ctx->tmpX, &_ctx->tmpY);
+ _vm->_actor->GetActorPos(_ctx->reelActor, &_ctx->tmpX, &_ctx->tmpY);
MultiSetAniXY(_ctx->pPlayObj, _ctx->tmpX, _ctx->tmpY);
}
// If it's a moving actor, this hides the moving actor
// used to do this only if (actorid == 0) - I don't know why
- _ctx->mActor = HideMovingActor(_ctx->reelActor, ppi->sf);
+ _ctx->mActor = _vm->_actor->HideMovingActor(_ctx->reelActor, ppi->sf);
// If it's a moving actor, get its MOVER structure.
// If it isn't in the scene yet, get its task running - using
@@ -530,11 +530,11 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) {
}
// Register the fact that we're playing this for this actor
- storeActorReel(_ctx->reelActor, _ctx->pfreel, ppi->hFilm, _ctx->pPlayObj, ppi->column, _ctx->tmpX, _ctx->tmpY);
+ _vm->_actor->storeActorReel(_ctx->reelActor, _ctx->pfreel, ppi->hFilm, _ctx->pPlayObj, ppi->column, _ctx->tmpX, _ctx->tmpY);
/**** Will get rid of this if the above is kept ****/
// We may be temporarily resuscitating a dead actor
- if (ppi->actorid == 0 && !actorAlive(_ctx->reelActor))
+ if (ppi->actorid == 0 && !_vm->_actor->actorAlive(_ctx->reelActor))
_ctx->lifeNoMatter = true;
InitStepAnimScript(&_ctx->thisAnim, _ctx->pPlayObj, FROM_32(_ctx->pfreel->script), ppi->speed);
@@ -544,15 +544,15 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) {
// N.B. It HAS been ensured that the first column gets here first
if (ppi->z != 0) {
MultiSetZPosition(_ctx->pPlayObj, ppi->z);
- StoreActorZpos(_ctx->reelActor, ppi->z);
+ _vm->_actor->StoreActorZpos(_ctx->reelActor, ppi->z);
} else if (ppi->bTop) {
if (ppi->column == 0) {
- firstColZ = Z_TOPPLAY + actorMaskType(_ctx->reelActor);
+ firstColZ = Z_TOPPLAY + _vm->_actor->actorMaskType(_ctx->reelActor);
MultiSetZPosition(_ctx->pPlayObj, firstColZ);
- StoreActorZpos(_ctx->reelActor, firstColZ);
+ _vm->_actor->StoreActorZpos(_ctx->reelActor, firstColZ);
} else {
MultiSetZPosition(_ctx->pPlayObj, firstColZ + ppi->column);
- StoreActorZpos(_ctx->reelActor, firstColZ + ppi->column);
+ _vm->_actor->StoreActorZpos(_ctx->reelActor, firstColZ + ppi->column);
}
} else if (ppi->column == 0) {
if (_ctx->mActor && !bNewMover) {
@@ -561,9 +561,9 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) {
fColZfactor = GetPolyZfactor(FirstPathPoly());
else
fColZfactor = GetPolyZfactor(_ctx->pActor->hCpath);
- firstColZ = AsetZPos(_ctx->pPlayObj, MultiLowest(_ctx->pPlayObj), fColZfactor);
+ firstColZ = _vm->_actor->AsetZPos(_ctx->pPlayObj, MultiLowest(_ctx->pPlayObj), fColZfactor);
} else {
- switch (actorMaskType(_ctx->reelActor)) {
+ switch (_vm->_actor->actorMaskType(_ctx->reelActor)) {
case ACT_DEFAULT:
fColZfactor = 0;
firstColZ = 2;
@@ -580,8 +580,8 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) {
MultiSetZPosition(_ctx->pPlayObj, firstColZ);
break;
default:
- fColZfactor = actorMaskType(_ctx->reelActor);
- firstColZ = AsetZPos(_ctx->pPlayObj, MultiLowest(_ctx->pPlayObj), fColZfactor);
+ fColZfactor = _vm->_actor->actorMaskType(_ctx->reelActor);
+ firstColZ = _vm->_actor->AsetZPos(_ctx->pPlayObj, MultiLowest(_ctx->pPlayObj), fColZfactor);
if (firstColZ < 2) {
// This is an experiment!
firstColZ = 2;
@@ -590,14 +590,14 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) {
break;
}
}
- StoreActorZpos(_ctx->reelActor, firstColZ);
+ _vm->_actor->StoreActorZpos(_ctx->reelActor, firstColZ);
} else {
if (NoNameFunc(_ctx->reelActor, bNewMover) > fColZfactor) {
fColZfactor = NoNameFunc(_ctx->reelActor, bNewMover);
firstColZ = fColZfactor << 10;
}
MultiSetZPosition(_ctx->pPlayObj, firstColZ + ppi->column);
- StoreActorZpos(_ctx->reelActor, firstColZ + ppi->column);
+ _vm->_actor->StoreActorZpos(_ctx->reelActor, firstColZ + ppi->column);
}
/*
@@ -610,7 +610,7 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) {
do {
if (_ctx->stepCount++ == 0) {
_ctx->frameCount++;
- StoreActorSteps(_ctx->reelActor, _ctx->frameCount);
+ _vm->_actor->StoreActorSteps(_ctx->reelActor, _ctx->frameCount);
}
if (_ctx->stepCount == ppi->speed)
_ctx->stepCount = 0;
@@ -620,23 +620,23 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) {
int x, y;
GetAniPosition(_ctx->pPlayObj, &x, &y);
- StoreActorPos(_ctx->reelActor, x, y);
+ _vm->_actor->StoreActorPos(_ctx->reelActor, x, y);
CORO_SLEEP(1);
- if (actorReel(_ctx->reelActor) != _ctx->pfreel) {
+ if (_vm->_actor->actorReel(_ctx->reelActor) != _ctx->pfreel) {
_ctx->replaced = true;
break;
}
- if (ActorEsc(_ctx->reelActor) && ActorEev(_ctx->reelActor) != GetEscEvents())
+ if (_vm->_actor->ActorEsc(_ctx->reelActor) && _vm->_actor->ActorEev(_ctx->reelActor) != GetEscEvents())
break;
- } while (_ctx->lifeNoMatter || actorAlive(_ctx->reelActor));
+ } while (_ctx->lifeNoMatter || _vm->_actor->actorAlive(_ctx->reelActor));
// Register the fact that we're NOT playing this for this actor
- if (actorReel(_ctx->reelActor) == _ctx->pfreel)
- storeActorReel(_ctx->reelActor, NULL, 0, NULL, 0, 0, 0);
+ if (_vm->_actor->actorReel(_ctx->reelActor) == _ctx->pfreel)
+ _vm->_actor->storeActorReel(_ctx->reelActor, NULL, 0, NULL, 0, 0, 0);
// Ditch the object
if (!ppi->bTop)
@@ -646,11 +646,11 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) {
if (_ctx->mActor) {
if (!_ctx->replaced)
- unHideMovingActor(_ctx->reelActor); // Restore moving actor
+ _vm->_actor->unHideMovingActor(_ctx->reelActor); // Restore moving actor
// Update it's co-ordinates if this is an splay()
if (ppi->splay)
- restoreMovement(_ctx->reelActor);
+ _vm->_actor->restoreMovement(_ctx->reelActor);
}
CORO_END_CODE;
}
@@ -720,37 +720,37 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA
// Save actor's ID
_ctx->reelActor = FROM_32(_ctx->pmi->mulID);
- UpdateActorEsc(_ctx->reelActor, myescEvent);
+ _vm->_actor->UpdateActorEsc(_ctx->reelActor, myescEvent);
// To handle the play()-talk(), talk()-play(), talk()-talk() and play()-play() scenarios
- if (hFilm != GetActorLatestFilm(_ctx->reelActor)) {
+ if (hFilm != _vm->_actor->GetActorLatestFilm(_ctx->reelActor)) {
// This in not the last film scheduled for this actor
// It may be the last non-talk film though
- if (ActorIsTalking(_ctx->reelActor))
- SetActorPlayFilm(_ctx->reelActor, hFilm); // Revert to this film after talk
+ if (_vm->_actor->ActorIsTalking(_ctx->reelActor))
+ _vm->_actor->SetActorPlayFilm(_ctx->reelActor, hFilm); // Revert to this film after talk
return;
}
- if (ActorIsTalking(_ctx->reelActor)) {
+ if (_vm->_actor->ActorIsTalking(_ctx->reelActor)) {
// Note: will delete this and there'll be no need to store the talk film!
- if (hFilm != GetActorTalkFilm(_ctx->reelActor)) {
- SetActorPlayFilm(_ctx->reelActor, hFilm); // Revert to this film after talk
+ if (hFilm != _vm->_actor->GetActorTalkFilm(_ctx->reelActor)) {
+ _vm->_actor->SetActorPlayFilm(_ctx->reelActor, hFilm); // Revert to this film after talk
return;
}
} else {
- SetActorPlayFilm(_ctx->reelActor, hFilm);
+ _vm->_actor->SetActorPlayFilm(_ctx->reelActor, hFilm);
}
// Register the film for this actor
- if (hFilm != GetActorPresFilm(_ctx->reelActor)) {
+ if (hFilm != _vm->_actor->GetActorPresFilm(_ctx->reelActor)) {
_ctx->bPrinciple = true;
- StoreActorPresFilm(_ctx->reelActor, hFilm, x, y);
+ _vm->_actor->StoreActorPresFilm(_ctx->reelActor, hFilm, x, y);
} else {
_ctx->bPrinciple = false;
// If this reel is already playing for this actor, just forget it.
- if (ActorReelPlaying(_ctx->reelActor, column))
+ if (_vm->_actor->ActorReelPlaying(_ctx->reelActor, column))
return;
}
@@ -761,7 +761,7 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA
PokeInPalette(_ctx->pmi);
// Set ghost bit if wanted
- if (ActorIsGhost(_ctx->reelActor)) {
+ if (_vm->_actor->ActorIsGhost(_ctx->reelActor)) {
assert(FROM_32(_ctx->pmi->mulFlags) == DMA_WNZ || FROM_32(_ctx->pmi->mulFlags) == (DMA_WNZ | DMA_GHOST));
_ctx->pmi->mulFlags = TO_32(FROM_32(_ctx->pmi->mulFlags) | DMA_GHOST);
}
@@ -789,9 +789,9 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA
}
// Register the reel for this actor
- StoreActorReel(_ctx->reelActor, column, _ctx->pPlayObj);
+ _vm->_actor->StoreActorReel(_ctx->reelActor, column, _ctx->pPlayObj);
- _ctx->filmNumber = GetActorFilmNumber(_ctx->reelActor);
+ _ctx->filmNumber = _vm->_actor->GetActorFilmNumber(_ctx->reelActor);
/*
* Sort out x and y
@@ -804,9 +804,9 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA
if (_ctx->bRelative) {
// Use actor's position. If (x, y) specified, move the actor.
if (x == -1 && y == -1)
- GetActorPos(_ctx->reelActor, &x, &y);
+ _vm->_actor->GetActorPos(_ctx->reelActor, &x, &y);
else
- StoreActorPos(_ctx->reelActor, x, y);
+ _vm->_actor->StoreActorPos(_ctx->reelActor, x, y);
} else if (x == -1 && y == -1)
x = y = 0; // Use (0,0) if no specified
@@ -817,7 +817,7 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA
* Sort out z
*/
if (bRestore) {
- _ctx->myZ = GetActorZpos(_ctx->reelActor, column);
+ _ctx->myZ = _vm->_actor->GetActorZpos(_ctx->reelActor, column);
SoundReelWaitCheck();
} else {
@@ -846,7 +846,7 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA
_ctx->myZ = baseZposn + column;
}
MultiSetZPosition(_ctx->pPlayObj, _ctx->myZ);
- StoreActorZpos(_ctx->reelActor, _ctx->myZ, column);
+ _vm->_actor->StoreActorZpos(_ctx->reelActor, _ctx->myZ, column);
/*
* Play until the script finishes,
@@ -855,8 +855,8 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA
*/
InitStepAnimScript(&_ctx->thisAnim, _ctx->pPlayObj, FROM_32(_ctx->pFreel->script), speed);
- if (bRestore || (ActorEsc(_ctx->reelActor) == true &&
- ActorEev(_ctx->reelActor) != GetEscEvents())) {
+ if (bRestore || (_vm->_actor->ActorEsc(_ctx->reelActor) == true &&
+ _vm->_actor->ActorEev(_ctx->reelActor) != GetEscEvents())) {
// From restore, step to jump or end
SkipFrames(&_ctx->thisAnim, -1);
}
@@ -864,29 +864,29 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA
for (;;) {
if (_ctx->stepCount++ == 0) {
_ctx->frameCount++;
- StoreActorSteps(_ctx->reelActor, _ctx->frameCount);
+ _vm->_actor->StoreActorSteps(_ctx->reelActor, _ctx->frameCount);
}
if (_ctx->stepCount == speed)
_ctx->stepCount = 0;
if (_ctx->bPrinciple && AboutToJumpOrEnd(&_ctx->thisAnim))
- IncLoopCount(_ctx->reelActor);
+ _vm->_actor->IncLoopCount(_ctx->reelActor);
if (StepAnimScript(&_ctx->thisAnim) == ScriptFinished)
break;
if (_ctx->bRelative) {
GetAniPosition(_ctx->pPlayObj, &x, &y);
- StoreActorPos(_ctx->reelActor, x, y);
+ _vm->_actor->StoreActorPos(_ctx->reelActor, x, y);
}
if (_ctx->bGotHidden) {
- if (!ActorHidden(_ctx->reelActor)) {
+ if (!_vm->_actor->ActorHidden(_ctx->reelActor)) {
MultiSetZPosition(_ctx->pPlayObj, _ctx->myZ);
_ctx->bGotHidden = false;
}
} else {
- if (ActorHidden(_ctx->reelActor)) {
+ if (_vm->_actor->ActorHidden(_ctx->reelActor)) {
MultiSetZPosition(_ctx->pPlayObj, -1);
_ctx->bGotHidden = true;
}
@@ -894,12 +894,12 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA
CORO_SLEEP(1);
- if (GetActorFilmNumber(_ctx->reelActor) != _ctx->filmNumber) {
+ if (_vm->_actor->GetActorFilmNumber(_ctx->reelActor) != _ctx->filmNumber) {
_ctx->bReplaced = true;
break;
}
- if (ActorEsc(_ctx->reelActor) == true && ActorEev(_ctx->reelActor) != GetEscEvents()) {
+ if (_vm->_actor->ActorEsc(_ctx->reelActor) == true && _vm->_actor->ActorEev(_ctx->reelActor) != GetEscEvents()) {
if (!_ctx->bEscapedAlready) {
SkipFrames(&_ctx->thisAnim, -1);
_ctx->bEscapedAlready = true;
@@ -913,7 +913,7 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA
}
// Register the fact that we're NOT playing this for this actor
- NotPlayingReel(_ctx->reelActor, _ctx->filmNumber, column);
+ _vm->_actor->NotPlayingReel(_ctx->reelActor, _ctx->filmNumber, column);
// Ditch the object
if (!bTop)
@@ -958,7 +958,7 @@ void NewestFilm(SCNHANDLE film, const FREEL *reel) {
pmi = (const MULTI_INIT *)LockMem(FROM_32(reel->mobj));
if (!TinselV2 || ((int32)FROM_32(pmi->mulID) != -2))
- SetActorLatestFilm((int32)FROM_32(pmi->mulID), film);
+ _vm->_actor->SetActorLatestFilm((int32)FROM_32(pmi->mulID), film);
}
// *******************************************************
@@ -1076,10 +1076,10 @@ void PlayFilmc(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int actorid, bool spla
CORO_GIVE_WAY;
_ctx->i = ExtractActor(hFilm);
- _ctx->loopCount = GetLoopCount(_ctx->i);
+ _ctx->loopCount = _vm->_actor->GetLoopCount(_ctx->i);
// Wait until film changes or loop count increases
- while (GetActorPresFilm(_ctx->i) == hFilm && GetLoopCount(_ctx->i) == _ctx->loopCount) {
+ while (_vm->_actor->GetActorPresFilm(_ctx->i) == hFilm && _vm->_actor->GetLoopCount(_ctx->i) == _ctx->loopCount) {
if (myescEvent && myescEvent != GetEscEvents()) {
CoroScheduler.rescheduleAll();
break;
diff --git a/engines/tinsel/rince.cpp b/engines/tinsel/rince.cpp
index 5185e085f2..3618f73417 100644
--- a/engines/tinsel/rince.cpp
+++ b/engines/tinsel/rince.cpp
@@ -126,7 +126,7 @@ PMOVER GetMover(int ano) {
int i;
// Slot 0 is reserved for lead actor
- if (ano == GetLeadId() || ano == LEAD_ACTOR)
+ if (ano == _vm->_actor->GetLeadId() || ano == LEAD_ACTOR)
return &g_Movers[0];
for (i = 1; i < MAX_MOVERS; i++)
@@ -143,9 +143,9 @@ PMOVER RegisterMover(int ano) {
int i;
// Slot 0 is reserved for lead actor
- if (ano == GetLeadId() || ano == LEAD_ACTOR) {
+ if (ano == _vm->_actor->GetLeadId() || ano == LEAD_ACTOR) {
g_Movers[0].actorToken = TOKEN_LEAD;
- g_Movers[0].actorID = GetLeadId();
+ g_Movers[0].actorID = _vm->_actor->GetLeadId();
return &g_Movers[0];
}
@@ -229,10 +229,10 @@ void HideMover(PMOVER pMover, int sf) {
pMover->SlowFactor = sf;
} else {
// Tinsel 2 specific code
- if (IsTaggedActor(pMover->actorID)) {
+ if (_vm->_actor->IsTaggedActor(pMover->actorID)) {
// It may be pointed to
- SetActorPointedTo(pMover->actorID, false);
- SetActorTagWanted(pMover->actorID, false, false, 0);
+ _vm->_actor->SetActorPointedTo(pMover->actorID, false);
+ _vm->_actor->SetActorTagWanted(pMover->actorID, false, false, 0);
}
}
@@ -299,7 +299,9 @@ int GetMoverId(PMOVER pMover) {
*/
void SetMoverZ(PMOVER pMover, int y, uint32 zFactor) {
if (!pMover->bHidden) {
- if (MoverIsSWalking(pMover) && pMover->zOverride != -1) {
+ if (!TinselV2)
+ _vm->_actor->AsetZPos(pMover->actorObj, y, zFactor);
+ else if (MoverIsSWalking(pMover) && pMover->zOverride != -1) {
// Special for SWalk()
MultiSetZPosition(pMover->actorObj, (pMover->zOverride << ZSHIFT) + y);
} else {
@@ -618,7 +620,7 @@ void SetMoverWalkReel(PMOVER pMover, DIRECTION reel, int scale, bool force) {
// Kill off any play that may be going on for this actor
// and restore the real actor
- storeActorReel(pMover->actorID, NULL, 0, NULL, 0, 0, 0);
+ _vm->_actor->storeActorReel(pMover->actorID, NULL, 0, NULL, 0, 0, 0);
UnHideMover(pMover);
// Don't do it if using a special walk reel
@@ -720,7 +722,7 @@ static void MoverProcessHelper(int X, int Y, int id, PMOVER pMover) {
// add it to display list
MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_WORLD), pMover->actorObj);
- storeActorReel(id, NULL, 0, pMover->actorObj, 0, 0, 0);
+ _vm->_actor->storeActorReel(id, NULL, 0, pMover->actorObj, 0, 0, 0);
InitStepAnimScript(&pMover->actorAnim, pMover->actorObj, FROM_32(pfilm->reels[0].script), ONE_SECOND / FROM_32(pfilm->frate));
pMover->stepCount = 0;
diff --git a/engines/tinsel/saveload.cpp b/engines/tinsel/saveload.cpp
index c9e0006628..aff2e8a7f4 100644
--- a/engines/tinsel/saveload.cpp
+++ b/engines/tinsel/saveload.cpp
@@ -246,8 +246,6 @@ static void syncSavedActor(Common::Serializer &s, SAVED_ACTOR &sa) {
s.syncAsUint16LE(sa.presPlayY);
}
-extern void syncAllActorsAlive(Common::Serializer &s);
-
static void syncNoScrollB(Common::Serializer &s, NOSCROLLB &ns) {
s.syncAsSint32LE(ns.ln);
s.syncAsSint32LE(ns.c1);
@@ -482,7 +480,7 @@ static bool DoSync(Common::Serializer &s, int numInterp) {
}
if (!TinselV2)
- syncAllActorsAlive(s);
+ _vm->_actor->syncAllActorsAlive(s);
return true;
}
diff --git a/engines/tinsel/savescn.cpp b/engines/tinsel/savescn.cpp
index 013b1fc4c9..bf3ef1235e 100644
--- a/engines/tinsel/savescn.cpp
+++ b/engines/tinsel/savescn.cpp
@@ -105,7 +105,7 @@ void DoSaveScene(SAVED_DATA *sd) {
sd->SavedSceneHandle = GetSceneHandle();
sd->SavedBgroundHandle = _vm->_bg->GetBgroundHandle();
SaveMovers(sd->SavedMoverInfo);
- sd->NumSavedActors = SaveActors(sd->SavedActorInfo);
+ sd->NumSavedActors = _vm->_actor->SaveActors(sd->SavedActorInfo);
_vm->_bg->PlayfieldGetPos(FIELD_WORLD, &sd->SavedLoffset, &sd->SavedToffset);
SaveInterpretContexts(sd->SavedICInfo);
sd->SavedControl = ControlIsOn();
@@ -114,8 +114,8 @@ void DoSaveScene(SAVED_DATA *sd) {
if (TinselV2) {
// Tinsel 2 specific data save
- SaveActorZ(sd->savedActorZ);
- SaveZpositions(sd->zPositions);
+ _vm->_actor->SaveActorZ(sd->savedActorZ);
+ _vm->_actor->SaveZpositions(sd->zPositions);
SavePolygonStuff(sd->SavedPolygonStuff);
_vm->_pcmMusic->getTunePlaying(sd->SavedTune, sizeof(sd->SavedTune));
sd->bTinselDim = _vm->_pcmMusic->getMusicTinselDimmed();
@@ -171,11 +171,11 @@ void FreeSaveScenes() {
void sortActors(SAVED_DATA *sd) {
assert(!TinselV2);
for (int i = 0; i < sd->NumSavedActors; i++) {
- ActorsLife(sd->SavedActorInfo[i].actorID, sd->SavedActorInfo[i].bAlive);
+ _vm->_actor->ActorsLife(sd->SavedActorInfo[i].actorID, sd->SavedActorInfo[i].bAlive);
// Should be playing the same reel.
if (sd->SavedActorInfo[i].presFilm != 0) {
- if (!actorAlive(sd->SavedActorInfo[i].actorID))
+ if (!_vm->_actor->actorAlive(sd->SavedActorInfo[i].actorID))
continue;
RestoreActorReels(sd->SavedActorInfo[i].presFilm, sd->SavedActorInfo[i].presRnum, sd->SavedActorInfo[i].zFactor,
@@ -353,10 +353,10 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {
CoroScheduler.createProcess(PID_MOVER, SortMAProcess, NULL, 0);
g_bNotDoneYet = true;
- RestoreActorZ(sd->savedActorZ);
- RestoreZpositions(sd->zPositions);
+ _vm->_actor->RestoreActorZ(sd->savedActorZ);
+ _vm->_actor->RestoreZpositions(sd->zPositions);
RestoreSysVars(sd->SavedSystemVars);
- RestoreActors(sd->NumSavedActors, sd->SavedActorInfo);
+ _vm->_actor->RestoreActors(sd->NumSavedActors, sd->SavedActorInfo);
RestoreSoundReels(sd->SavedSoundReels);
return 1;
}
diff --git a/engines/tinsel/scene.cpp b/engines/tinsel/scene.cpp
index baa04cd230..1aef8d4754 100644
--- a/engines/tinsel/scene.cpp
+++ b/engines/tinsel/scene.cpp
@@ -246,7 +246,7 @@ static void LoadScene(SCNHANDLE scene, int entry) {
InitPolygons(FROM_32(ss->hPoly), FROM_32(ss->numPoly), true);
// Initialize the actors for this scene
- StartTaggedActors(FROM_32(ss->hTaggedActor), FROM_32(ss->numTaggedActor), false);
+ _vm->_actor->StartTaggedActors(FROM_32(ss->hTaggedActor), FROM_32(ss->numTaggedActor), false);
if (TinselV2)
// Returning from cutscene
@@ -259,7 +259,7 @@ static void LoadScene(SCNHANDLE scene, int entry) {
InitPolygons(FROM_32(ss->hPoly), FROM_32(ss->numPoly), false);
// Initialize the actors for this scene
- StartTaggedActors(FROM_32(ss->hTaggedActor), FROM_32(ss->numTaggedActor), true);
+ _vm->_actor->StartTaggedActors(FROM_32(ss->hTaggedActor), FROM_32(ss->numTaggedActor), true);
// Run the appropriate entrance code (if any)
es = (const ENTRANCE_STRUC *)LockMem(FROM_32(ss->hEntrance));
@@ -317,7 +317,7 @@ void EndScene() {
_vm->_bg->DropBackground(); // No background
DropMovers(); // No moving actors
_vm->_cursor->DropCursor(); // No cursor
- DropActors(); // No actor reels running
+ _vm->_actor->DropActors(); // No actor reels running
FreeAllTokens(); // No-one has tokens
FreeMostInterpretContexts(); // Only master script still interpreting
diff --git a/engines/tinsel/scroll.cpp b/engines/tinsel/scroll.cpp
index c6cdf718e9..c4fd8fde1f 100644
--- a/engines/tinsel/scroll.cpp
+++ b/engines/tinsel/scroll.cpp
@@ -351,7 +351,7 @@ static void MonitorScroll() {
if (!g_pScrollMover || MoverHidden(g_pScrollMover) || !MoverIs(g_pScrollMover))
return;
- GetActorPos(g_scrollActor, &newx, &newy);
+ _vm->_actor->GetActorPos(g_scrollActor, &newx, &newy);
if (g_oldx == newx && g_oldy == newy)
return;
@@ -375,7 +375,7 @@ static void MonitorScroll() {
if (newy > Toffset+SCREEN_HEIGHT-DDISTANCE && Toffset < g_ImageH-SCREEN_HEIGHT) {
if (newy > g_oldy)
NeedScroll(UP);
- } else if (Toffset && newy < Toffset + UDISTANCE + GetActorBottom(g_scrollActor) - GetActorTop(g_scrollActor)) {
+ } else if (Toffset && newy < Toffset + UDISTANCE + _vm->_actor->GetActorBottom(g_scrollActor) - _vm->_actor->GetActorTop(g_scrollActor)) {
if (newy < g_oldy)
NeedScroll(DOWN);
}
@@ -437,7 +437,7 @@ void ScrollProcess(CORO_PARAM, const void *) {
}
if (!g_scrollActor)
- g_scrollActor = GetLeadId();
+ g_scrollActor = _vm->_actor->GetLeadId();
g_pScrollMover = GetMover(g_scrollActor);
diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp
index c22aae9328..12a1f972f0 100644
--- a/engines/tinsel/tinlib.cpp
+++ b/engines/tinsel/tinlib.cpp
@@ -523,7 +523,7 @@ void TinGetVersion(WHICH_VER which, char *buffer, int length) {
* - currently only the text color.
*/
static void ActorAttr(int actor, int r1, int g1, int b1) {
- storeActorAttr(actor, r1, g1, b1);
+ _vm->_actor->storeActorAttr(actor, r1, g1, b1);
}
/**
@@ -562,14 +562,14 @@ void ActorPalette(int actor, int startColor, int length) {
* Set actor's Z-factor.
*/
static void ActorPriority(int actor, int zFactor) {
- SetActorZfactor(actor, zFactor);
+ _vm->_actor->SetActorZfactor(actor, zFactor);
}
/**
* Set actor's text color.
*/
static void ActorRGB(int actor, COLORREF color) {
- SetActorRGB(actor, color);
+ _vm->_actor->SetActorRGB(actor, color);
}
/**
@@ -588,7 +588,7 @@ static int ActorScale(int actor) {
static int ActorPos(int xory, int actor) {
int x, y;
- GetActorPos(actor, &x, &y);
+ _vm->_actor->GetActorPos(actor, &x, &y);
return (xory == ACTORXPOS) ? x : y;
}
@@ -596,7 +596,7 @@ static int ActorPos(int xory, int actor) {
* Make all actors alive at the start of each scene.
*/
static void ActorsOn() {
- setactorson();
+ _vm->_actor->SetActorsOn();
}
/**
@@ -689,7 +689,7 @@ void CdEndActor(int actor, int myEscape) {
// Only do it if escaped!
if (myEscape && myEscape != GetEscEvents()) {
// End current graphic
- dwEndActor(actor);
+ _vm->_actor->dwEndActor(actor);
// un-hide movers
pMover = GetMover(actor);
@@ -972,13 +972,13 @@ static void DecLead(uint32 id, SCNHANDLE *rp = 0, SCNHANDLE text = 0) {
if (TinselV2) {
// Tinsel 2 only specifies the lead actor Id
- SetLeadId(id);
+ _vm->_actor->SetLeadId(id);
RegisterMover(id);
} else {
- Tag_Actor(id, text, TAG_DEF); // The lead actor is automatically tagged
- SetLeadId(id); // Establish this as the lead
+ _vm->_actor->Tag_Actor(id, text, TAG_DEF); // The lead actor is automatically tagged
+ _vm->_actor->SetLeadId(id); // Establish this as the lead
RegisterMover(id); // Establish as a moving actor
pMover = GetMover(id); // Get moving actor structure
@@ -1080,7 +1080,7 @@ static void EnableMenu() {
* Kill an actor's current graphics.
*/
static void EndActor(int actor) {
- dwEndActor(actor);
+ _vm->_actor->dwEndActor(actor);
}
/**
@@ -1112,7 +1112,7 @@ static void FaceTag(int actor, HPOLYGON hp) {
*/
// See where node is and where actor is
GetPolyNode(hp, &nodex, &nodey);
- GetActorPos(actor, &nowx, &nowy);
+ _vm->_actor->GetActorPos(actor, &nowx, &nowy);
if (nowx == nodex && nowy == nodey) {
// Stood at the tag, don't face in silly direction
@@ -1331,7 +1331,7 @@ static int InWhichInv(int object) {
* Kill an actor.
*/
static void KillActor(int actor) {
- DisableActor(actor);
+ _vm->_actor->DisableActor(actor);
}
/**
@@ -1517,7 +1517,7 @@ static void Play(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int compit, int acto
return;
// If this actor is dead, call a stop to the calling process
- if (actorid && !actorAlive(actorid))
+ if (actorid && !_vm->_actor->actorAlive(actorid))
CORO_KILL_SELF();
// 7/4/95
@@ -1559,7 +1559,7 @@ static void Play(CORO_PARAM, SCNHANDLE hFilm, int x, int y, bool bComplete, int
if (hPoly == NOPOLY) {
// Must be a tagged actor
- assert(taggedActor && IsTaggedActor(taggedActor));
+ assert(taggedActor && _vm->_actor->IsTaggedActor(taggedActor));
actor = taggedActor;
} else if (taggedActor == 0) {
// Must be a polygon with an actor ID
@@ -1571,8 +1571,8 @@ static void Play(CORO_PARAM, SCNHANDLE hFilm, int x, int y, bool bComplete, int
return;
}
- SetActorTalking(actor, true);
- SetActorTalkFilm(actor, hFilm);
+ _vm->_actor->SetActorTalking(actor, true);
+ _vm->_actor->SetActorTalkFilm(actor, hFilm);
}
if (bComplete) {
@@ -1757,9 +1757,9 @@ void PointActor(int actor) {
if (!SysVar(SV_ENABLEPOINTTAG))
return;
- assert(IsTaggedActor(actor));
+ assert(_vm->_actor->IsTaggedActor(actor));
- GetActorTagPos(actor, &x, &y, true);
+ _vm->_actor->GetActorTagPos(actor, &x, &y, true);
_vm->setMousePosition(Common::Point(x, y));
}
@@ -1792,10 +1792,10 @@ static void PostActor(CORO_PARAM, int actor, TINSEL_EVENT event, HPOLYGON hp,
if (actor == -1) {
actor = taggedActor;
assert(hp == NOPOLY && taggedActor);
- assert(IsTaggedActor(actor));
+ assert(_vm->_actor->IsTaggedActor(actor));
}
- if (IsTaggedActor(actor)) {
+ if (_vm->_actor->IsTaggedActor(actor)) {
assert(actor);
ActorEvent(coroParam, actor, event, false, myEscape);
} else {
@@ -2358,7 +2358,7 @@ static void PrintTag(HPOLYGON hp, SCNHANDLE text, int actor = 0, bool bCursor =
}
} else {
// Moving actor handling
- SetActorTagWanted(actor, true, bCursor, text);
+ _vm->_actor->SetActorTagWanted(actor, true, bCursor, text);
}
}
@@ -2573,7 +2573,7 @@ static void ScrollParameters(int xTrigger, int xDistance, int xSpeed, int yTrigg
int SendActor(CORO_PARAM, int actor, TINSEL_EVENT event, HPOLYGON hp, int myEscape) {
bool result;
- if (IsTaggedActor(actor)) {
+ if (_vm->_actor->IsTaggedActor(actor)) {
assert(actor);
ActorEvent(coroParam, actor, event, true, myEscape, &result);
} else {
@@ -2628,7 +2628,7 @@ static void SendTag(CORO_PARAM, int tagno, TINSEL_EVENT event, HPOLYGON hp, int
* Un-kill an actor.
*/
static void SetActor(int actor) {
- EnableActor(actor);
+ _vm->_actor->EnableActor(actor);
}
/**
@@ -2822,13 +2822,13 @@ void Stand(CORO_PARAM, int actor, int x, int y, SCNHANDLE hFilm) {
// Another new special.
// If lead actor, and TalkVia, ignore
- if ((actor == GetLeadId() || actor == LEAD_ACTOR) && SysVar(ISV_DIVERT_ACTOR))
+ if ((actor == _vm->_actor->GetLeadId() || actor == LEAD_ACTOR) && SysVar(ISV_DIVERT_ACTOR))
return;
}
if (!MoverIs(_ctx->pMover)) {
// create a moving actor process
- MoverProcessCreate(x, y, (actor == LEAD_ACTOR) ? GetLeadId() : actor, _ctx->pMover);
+ MoverProcessCreate(x, y, (actor == LEAD_ACTOR) ? _vm->_actor->GetLeadId() : actor, _ctx->pMover);
if (hFilm == TF_NONE) {
// Make sure there is an assigned actorObj
@@ -2928,14 +2928,14 @@ static void StandTag(int actor, HPOLYGON hp) {
// other actors can use direction
if (TinselV2) {
- if (actor != LEAD_ACTOR && actor != GetLeadId()
+ if (actor != LEAD_ACTOR && actor != _vm->_actor->GetLeadId()
&& hFilm != TF_UP && hFilm != TF_DOWN
&& hFilm != TF_LEFT && hFilm != TF_RIGHT)
hFilm = 0;
Stand(Common::nullContext, actor, pnodex, pnodey, hFilm);
- } else if (hFilm && (actor == LEAD_ACTOR || actor == GetLeadId()))
+ } else if (hFilm && (actor == LEAD_ACTOR || actor == _vm->_actor->GetLeadId()))
Stand(Common::nullContext, actor, pnodex, pnodey, hFilm);
else
Stand(Common::nullContext, actor, pnodex, pnodey, 0);
@@ -3036,7 +3036,7 @@ static void Swalk(CORO_PARAM, int actor, int x1, int y1, int x2, int y2, SCNHAND
}
// For lead actor, lock out the user (if not already locked out)
- if (actor == GetLeadId() || actor == LEAD_ACTOR) {
+ if (actor == _vm->_actor->GetLeadId() || actor == LEAD_ACTOR) {
_ctx->bTookControl = GetControl(CONTROL_OFFV2);
if (TinselV2 && _ctx->bTookControl)
_vm->_cursor->RestoreMainCursor();
@@ -3093,7 +3093,7 @@ static int SystemVar(int varId) {
* Define a tagged actor.
*/
static void TagActor(int actor, SCNHANDLE text, int tp) {
- Tag_Actor(actor, text, tp);
+ _vm->_actor->Tag_Actor(actor, text, tp);
}
/**
@@ -3133,8 +3133,8 @@ static void FinishTalkingReel(CORO_PARAM, PMOVER pMover, int actor) {
SetMoverStanding(pMover);
AlterMover(pMover, 0, AR_POPREEL);
} else {
- SetActorTalking(actor, false);
- CORO_INVOKE_ARGS(PlayFilm, (CORO_SUBCTX, GetActorPlayFilm(actor), -1, -1, 0, false, 0, false, 0, false));
+ _vm->_actor->SetActorTalking(actor, false);
+ CORO_INVOKE_ARGS(PlayFilm, (CORO_SUBCTX, _vm->_actor->GetActorPlayFilm(actor), -1, -1, 0, false, 0, false, 0, false));
}
CORO_END_CODE;
@@ -3186,7 +3186,7 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
_ctx->myLeftEvent = GetLeftEvents();
// If this actor is dead, call a stop to the calling process
- if (!TinselV2 && (actorId && !actorAlive(actorId)))
+ if (!TinselV2 && (actorId && !_vm->_actor->actorAlive(actorId)))
CORO_KILL_SELF();
if (!TinselV2 || (speechType == IS_TALK)) {
@@ -3200,7 +3200,7 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
case TF_DOWN:
case TF_LEFT:
case TF_RIGHT:
- _ctx->actor = GetLeadId(); // If no film, actor is lead actor
+ _ctx->actor = _vm->_actor->GetLeadId(); // If no film, actor is lead actor
_ctx->direction = (TFTYPE)hFilm;
break;
@@ -3218,7 +3218,7 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
* Lock out the user (for lead actor, if not already locked out)
* May need to disable tags for other actors
*/
- if (_ctx->actor == GetLeadId() || (TinselV2 && (_ctx->actor == LEAD_ACTOR)))
+ if (_ctx->actor == _vm->_actor->GetLeadId() || (TinselV2 && (_ctx->actor == LEAD_ACTOR)))
_ctx->bTookControl = GetControl(CONTROL_OFF);
else
_ctx->bTookControl = false;
@@ -3228,7 +3228,7 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
/*
* Divert stuff
*/
- if (SysVar(ISV_DIVERT_ACTOR) && (_ctx->actor == GetLeadId() || _ctx->actor == LEAD_ACTOR)) {
+ if (SysVar(ISV_DIVERT_ACTOR) && (_ctx->actor == _vm->_actor->GetLeadId() || _ctx->actor == LEAD_ACTOR)) {
_ctx->actor = SysVar(ISV_DIVERT_ACTOR);
if (_ctx->whatSort == IS_TALK)
_ctx->whatSort = IS_SAY;
@@ -3259,8 +3259,8 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
hFilm = GetMoverTalkReel(_ctx->pActor, _ctx->direction);
AlterMover(_ctx->pActor, hFilm, AR_PUSHREEL);
} else {
- SetActorTalking(_ctx->actor, true);
- SetActorTalkFilm(_ctx->actor, hFilm);
+ _vm->_actor->SetActorTalking(_ctx->actor, true);
+ _vm->_actor->SetActorTalkFilm(_ctx->actor, hFilm);
CORO_INVOKE_ARGS(PlayFilm, (CORO_SUBCTX, hFilm, -1, -1, 0, false, 0, escOn, myEscape, false));
}
_ctx->bTalkReel = true;
@@ -3271,7 +3271,7 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
} else if ((_ctx->whatSort == IS_SAY) || (_ctx->whatSort == IS_SAYAT)) {
_ctx->bTalkReel = false;
- if (IsTaggedActor(_ctx->actor)) {
+ if (_vm->_actor->IsTaggedActor(_ctx->actor)) {
CORO_INVOKE_ARGS(ActorEvent, (CORO_SUBCTX, _ctx->actor, TALKING, false, 0));
} else if (IsTagPolygon(_ctx->actor | ACTORTAG_KEY)) {
CORO_INVOKE_ARGS(PolygonEvent, (CORO_SUBCTX, GetTagHandle(_ctx->actor | ACTORTAG_KEY),
@@ -3309,10 +3309,10 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
_vm->_bg->PlayfieldGetPos(FIELD_WORLD, &_ctx->Loffset, &_ctx->Toffset);
if ((_ctx->whatSort == IS_SAY) || (_ctx->whatSort == IS_TALK))
- GetActorMidTop(_ctx->actor, &_ctx->x, &_ctx->y);
+ _vm->_actor->GetActorMidTop(_ctx->actor, &_ctx->x, &_ctx->y);
if (!TinselV0)
- SetTextPal(GetActorRGB(_ctx->actor));
+ SetTextPal(_vm->_actor->GetActorRGB(_ctx->actor));
if (TinselV2)
LoadSubString(hText, _ctx->sub, _vm->_font->TextBufferAddr(), TBUFSZ);
else {
@@ -3461,8 +3461,8 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
if (TinselV2) {
if ((_ctx->whatSort == IS_SAY) || (_ctx->whatSort == IS_SAYAT)) {
- SetActorTalking(_ctx->actor, false);
- if (IsTaggedActor(_ctx->actor))
+ _vm->_actor->SetActorTalking(_ctx->actor, false);
+ if (_vm->_actor->IsTaggedActor(_ctx->actor))
CORO_INVOKE_ARGS(ActorEvent, (CORO_SUBCTX, _ctx->actor, ENDTALK, false, 0));
else if (IsTagPolygon(_ctx->actor | ACTORTAG_KEY))
CORO_INVOKE_ARGS(PolygonEvent, (CORO_SUBCTX,
@@ -3497,7 +3497,7 @@ static void TalkAt(CORO_PARAM, int actor, int x, int y, SCNHANDLE text, bool esc
return;
if (!_vm->_config->isJapanMode() && (_vm->_config->_useSubtitles || !_vm->_sound->sampleExists(text)))
- SetTextPal(GetActorRGB(actor));
+ SetTextPal(_vm->_actor->GetActorRGB(actor));
}
Print(coroParam, x, y, text, 0, false, escOn, myEscape);
@@ -3515,7 +3515,7 @@ static void TalkAtS(CORO_PARAM, int actor, int x, int y, SCNHANDLE text, int sus
return;
if (!_vm->_config->isJapanMode())
- SetTextPal(GetActorRGB(actor));
+ SetTextPal(_vm->_actor->GetActorRGB(actor));
}
Print(coroParam, x, y, text, 0, sustain == 2, escOn, myEscape);
@@ -3659,7 +3659,7 @@ static void TryPlaySample(CORO_PARAM, int sample, bool bComplete, bool escOn, in
* Un-define an actor as tagged.
*/
static void UnTagActorFn(int actor) {
- UnTagActor(actor);
+ _vm->_actor->UnTagActor(actor);
}
/**
@@ -3677,7 +3677,7 @@ static void WaitFrame(CORO_PARAM, int actor, int frameNumber, bool escOn, int my
CORO_BEGIN_CODE(_ctx);
- while (GetActorSteps(actor) < frameNumber) {
+ while (_vm->_actor->GetActorSteps(actor) < frameNumber) {
// Don't do it if it's not wanted
if (escOn && myEscape != GetEscEvents())
break;
@@ -4115,7 +4115,7 @@ static void WalkTag(CORO_PARAM, int actor, SCNHANDLE film, HPOLYGON hp, bool esc
break;
default:
- if (actor == LEAD_ACTOR || actor == GetLeadId())
+ if (actor == LEAD_ACTOR || actor == _vm->_actor->GetLeadId())
AlterMover(pMover, pFilm, AR_NORMAL);
else
SetMoverStanding(pMover);
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index 423fa536ac..d1d02c65a8 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -711,7 +711,7 @@ void LoadBasicChunks() {
// CHUNK_TOTAL_ACTORS seems to be missing in the released version, hard coding a value
// TODO: Would be nice to just change 511 to MAX_SAVED_ALIVES
cptr = FindChunk(MASTER_SCNHANDLE, CHUNK_TOTAL_ACTORS);
- RegisterActors((cptr != NULL) ? READ_32(cptr) : 511);
+ _vm->_actor->RegisterActors((cptr != NULL) ? READ_32(cptr) : 511);
// CHUNK_TOTAL_GLOBALS seems to be missing in some versions.
// So if it is missing, set a reasonably high value for the number of globals.
@@ -861,11 +861,12 @@ TinselEngine::~TinselEngine() {
FreeSaveScenes();
FreeTextBuffer();
FreeHandleTable();
- FreeActors();
+ _actor->FreeActors();
FreeObjectList();
FreeGlobalProcesses();
FreeGlobals();
+ delete _actor;
delete _config;
MemoryDeinit();
@@ -898,6 +899,7 @@ Common::Error TinselEngine::run() {
_font = new Font();
_bg = new Background(_font);
_cursor = new Cursor();
+ _actor = new Actor();
// Initialize backend
if (getGameID() == GID_DW2) {
diff --git a/engines/tinsel/tinsel.h b/engines/tinsel/tinsel.h
index 32f47255cd..89e6072c05 100644
--- a/engines/tinsel/tinsel.h
+++ b/engines/tinsel/tinsel.h
@@ -61,6 +61,7 @@ class SoundManager;
class Background;
class Font;
class Cursor;
+class Actor;
typedef Common::List<Common::Rect> RectList;
@@ -168,6 +169,7 @@ public:
Background* _bg;
Font *_font;
Cursor *_cursor;
+ Actor *_actor;
Config *_config;
Commit: 8c50aa8902e799b7da7305e5bb2d7116f8723c32
https://github.com/scummvm/scummvm/commit/8c50aa8902e799b7da7305e5bb2d7116f8723c32
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-10-04T01:15:19+03:00
Commit Message:
TINSEL: Rename some actor variable and struct names
Changed paths:
engines/tinsel/actors.cpp
engines/tinsel/actors.h
diff --git a/engines/tinsel/actors.cpp b/engines/tinsel/actors.cpp
index ce340d3996..175f58621e 100644
--- a/engines/tinsel/actors.cpp
+++ b/engines/tinsel/actors.cpp
@@ -65,7 +65,7 @@ struct T2_ACTOR_STRUC {
#include "common/pack-end.h" // END STRUCT PACKING
-#define RANGE_CHECK(num) assert(num > 0 && num <= NumActors);
+#define RANGE_CHECK(num) assert(num > 0 && num <= _numActors);
struct ACTORINFO {
bool bAlive; // TRUE == alive
@@ -119,46 +119,46 @@ struct RATP_INIT {
* @param num Chunk Id
*/
void Actor::RegisterActors(int num) {
- if (actorInfo == NULL) {
+ if (_actorInfo == NULL) {
// Store the total number of actors in the game
- NumActors = num;
+ _numActors = num;
// Check we can save so many
- assert(NumActors <= MAX_SAVED_ALIVES);
+ assert(_numActors <= MAX_SAVED_ALIVES);
// Allocate RAM for actor structures
// FIXME: For now, we always allocate MAX_SAVED_ALIVES blocks,
// as this makes the save/load code simpler
// size of ACTORINFO is 148, so this allocates 512 * 148 = 75776 bytes, about 74KB
- actorInfo = (ACTORINFO *)calloc(MAX_SAVED_ALIVES, sizeof(ACTORINFO));
+ _actorInfo = (ACTORINFO *)calloc(MAX_SAVED_ALIVES, sizeof(ACTORINFO));
if (TinselV2)
- zFactors = (uint8 *)malloc(MAX_SAVED_ALIVES);
+ _zFactors = (uint8 *)malloc(MAX_SAVED_ALIVES);
// make sure memory allocated
- if (actorInfo == NULL) {
+ if (_actorInfo == NULL) {
error("Cannot allocate memory for actors");
}
} else {
// Check the total number of actors is still the same
- assert(num == NumActors);
+ assert(num == _numActors);
- memset(actorInfo, 0, MAX_SAVED_ALIVES * sizeof(ACTORINFO));
+ memset(_actorInfo, 0, MAX_SAVED_ALIVES * sizeof(ACTORINFO));
if (TinselV2)
- memset(zFactors, 0, MAX_SAVED_ALIVES);
+ memset(_zFactors, 0, MAX_SAVED_ALIVES);
}
// All actors start off alive.
while (num--)
- actorInfo[num].bAlive = true;
+ _actorInfo[num].bAlive = true;
}
void Actor::FreeActors() {
- free(actorInfo);
- actorInfo = nullptr;
+ free(_actorInfo);
+ _actorInfo = nullptr;
if (TinselV2) {
- free(zFactors);
- zFactors = nullptr;
+ free(_zFactors);
+ _zFactors = nullptr;
}
}
@@ -167,15 +167,15 @@ void Actor::FreeActors() {
* @param leadID Lead Id
*/
void Actor::SetLeadId(int leadID) {
- LeadActorId = leadID;
- actorInfo[leadID-1].mtype = ACT_MASK;
+ _leadActorId = leadID;
+ _actorInfo[leadID-1].mtype = ACT_MASK;
}
/**
* No comment.
*/
int Actor::GetLeadId() {
- return LeadActorId;
+ return _leadActorId;
}
bool Actor::ActorIsGhost(int actor) {
@@ -196,8 +196,8 @@ struct ATP_INIT {
int Actor::TaggedActorIndex(int actor) {
int i;
- for (i = 0; i < numTaggedActors; i++) {
- if (taggedActors[i].id == actor)
+ for (i = 0; i < _numTaggedActors; i++) {
+ if (_taggedActors[i].id == actor)
return i;
}
@@ -215,24 +215,24 @@ void Actor::StartActor(const T1_ACTOR_STRUC *as, bool bRunScript) {
SCNHANDLE hActorId = FROM_32(as->hActorId);
// Zero-out many things
- actorInfo[hActorId - 1].bHidden = false;
- actorInfo[hActorId - 1].completed = false;
- actorInfo[hActorId - 1].x = 0;
- actorInfo[hActorId - 1].y = 0;
- actorInfo[hActorId - 1].presReel = nullptr;
- actorInfo[hActorId - 1].presFilm = 0;
- actorInfo[hActorId - 1].presObj = nullptr;
+ _actorInfo[hActorId - 1].bHidden = false;
+ _actorInfo[hActorId - 1].completed = false;
+ _actorInfo[hActorId - 1].x = 0;
+ _actorInfo[hActorId - 1].y = 0;
+ _actorInfo[hActorId - 1].presReel = nullptr;
+ _actorInfo[hActorId - 1].presFilm = 0;
+ _actorInfo[hActorId - 1].presObj = nullptr;
// Store current scene's parameters for this actor
- actorInfo[hActorId - 1].mtype = FROM_32(as->masking);
- actorInfo[hActorId - 1].actorCode = FROM_32(as->hActorCode);
+ _actorInfo[hActorId - 1].mtype = FROM_32(as->masking);
+ _actorInfo[hActorId - 1].actorCode = FROM_32(as->hActorCode);
// Run actor's script for this scene
if (bRunScript) {
- if (bActorsOn)
- actorInfo[hActorId - 1].bAlive = true;
+ if (_actorsOn)
+ _actorInfo[hActorId - 1].bAlive = true;
- if (actorInfo[hActorId - 1].bAlive && FROM_32(as->hActorCode))
+ if (_actorInfo[hActorId - 1].bAlive && FROM_32(as->hActorCode))
ActorEvent(hActorId, STARTUP, PLR_NOEVENT);
}
}
@@ -248,13 +248,13 @@ void Actor::StartTaggedActors(SCNHANDLE ah, int numActors, bool bRunScript) {
if (TinselV2) {
// Clear it all out for a fresh start
- memset(taggedActors, 0, sizeof(taggedActors));
- numTaggedActors = numActors;
+ memset(_taggedActors, 0, sizeof(_taggedActors));
+ _numTaggedActors = numActors;
} else {
// Only actors with code blocks got (x, y) re-initialized, so...
- for (i = 0; i < NumActors; i++) {
- actorInfo[i].x = actorInfo[i].y = 0;
- actorInfo[i].mtype = 0;
+ for (i = 0; i < _numActors; i++) {
+ _actorInfo[i].x = _actorInfo[i].y = 0;
+ _actorInfo[i].mtype = 0;
}
}
@@ -271,17 +271,17 @@ void Actor::StartTaggedActors(SCNHANDLE ah, int numActors, bool bRunScript) {
assert(as->hActorCode);
// Store current scene's parameters for this tagged actor
- taggedActors[i].id = FROM_32(as->hActorId);
- taggedActors[i].hTagText = FROM_32(as->hTagText);
- taggedActors[i].tagPortionV = FROM_32(as->tagPortionV);
- taggedActors[i].tagPortionH = FROM_32(as->tagPortionH);
- taggedActors[i].hActorCode = FROM_32(as->hActorCode);
+ _taggedActors[i].id = FROM_32(as->hActorId);
+ _taggedActors[i].hTagText = FROM_32(as->hTagText);
+ _taggedActors[i].tagPortionV = FROM_32(as->tagPortionV);
+ _taggedActors[i].tagPortionH = FROM_32(as->tagPortionH);
+ _taggedActors[i].hActorCode = FROM_32(as->hActorCode);
// Run actor's script for this scene
if (bRunScript) {
// Send in reverse order - they get swapped round in the scheduler
- ActorEvent(taggedActors[i].id, SHOWEVENT, false, 0);
- ActorEvent(taggedActors[i].id, STARTUP, false, 0);
+ ActorEvent(_taggedActors[i].id, SHOWEVENT, false, 0);
+ ActorEvent(_taggedActors[i].id, STARTUP, false, 0);
}
}
}
@@ -292,32 +292,32 @@ void Actor::StartTaggedActors(SCNHANDLE ah, int numActors, bool bRunScript) {
*/
void Actor::DropActors() {
- for (int i = 0; i < NumActors; i++) {
+ for (int i = 0; i < _numActors; i++) {
if (TinselV2) {
// Save text color
- COLORREF tColor = actorInfo[i].textColor;
+ COLORREF tColor = _actorInfo[i].textColor;
- memset(&actorInfo[i], 0, sizeof(ACTORINFO));
+ memset(&_actorInfo[i], 0, sizeof(ACTORINFO));
// Restor text color
- actorInfo[i].textColor = tColor;
+ _actorInfo[i].textColor = tColor;
// Clear extra arrays
- memset(zFactors, 0, NumActors);
- memset(zPositions, 0, sizeof(zPositions));
+ memset(_zFactors, 0, _numActors);
+ memset(_zPositions, 0, sizeof(_zPositions));
} else {
// In Tinsel v1, only certain fields get reset
- actorInfo[i].actorCode = 0; // No script
- actorInfo[i].presReel = nullptr; // No reel running
- actorInfo[i].presFilm = 0; // ditto
- actorInfo[i].presObj = nullptr; // No object
- actorInfo[i].x = 0; // No position
- actorInfo[i].y = 0; // ditto
-
- actorInfo[i].talkFilm = 0;
- actorInfo[i].latestFilm = 0;
- actorInfo[i].playFilm = 0;
- actorInfo[i].bTalking = false;
+ _actorInfo[i].actorCode = 0; // No script
+ _actorInfo[i].presReel = nullptr; // No reel running
+ _actorInfo[i].presFilm = 0; // ditto
+ _actorInfo[i].presObj = nullptr; // No object
+ _actorInfo[i].x = 0; // No position
+ _actorInfo[i].y = 0; // ditto
+
+ _actorInfo[i].talkFilm = 0;
+ _actorInfo[i].latestFilm = 0;
+ _actorInfo[i].playFilm = 0;
+ _actorInfo[i].bTalking = false;
}
}
}
@@ -329,10 +329,10 @@ void Actor::DropActors() {
void Actor::DisableActor(int ano) {
PMOVER pActor;
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- actorInfo[ano - 1].bAlive = false; // Record as dead
- actorInfo[ano - 1].x = actorInfo[ano - 1].y = 0;
+ _actorInfo[ano - 1].bAlive = false; // Record as dead
+ _actorInfo[ano - 1].x = _actorInfo[ano - 1].y = 0;
// Kill off moving actor properly
pActor = GetMover(ano);
@@ -345,16 +345,16 @@ void Actor::DisableActor(int ano) {
* @param ano Actor Id
*/
void Actor::EnableActor(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
// Re-incarnate only if it's dead, or it's script ran to completion
- if (!actorInfo[ano - 1].bAlive || actorInfo[ano - 1].completed) {
- actorInfo[ano - 1].bAlive = true;
- actorInfo[ano - 1].bHidden = false;
- actorInfo[ano - 1].completed = false;
+ if (!_actorInfo[ano - 1].bAlive || _actorInfo[ano - 1].completed) {
+ _actorInfo[ano - 1].bAlive = true;
+ _actorInfo[ano - 1].bHidden = false;
+ _actorInfo[ano - 1].completed = false;
// Re-run actor's script for this scene
- if (actorInfo[ano-1].actorCode)
+ if (_actorInfo[ano-1].actorCode)
ActorEvent(ano, STARTUP, PLR_NOEVENT);
}
}
@@ -364,9 +364,9 @@ void Actor::EnableActor(int ano) {
* @param ano Actor Id
*/
bool Actor::actorAlive(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- return actorInfo[ano - 1].bAlive;
+ return _actorInfo[ano - 1].bAlive;
}
/**
@@ -376,11 +376,11 @@ bool Actor::actorAlive(int ano) {
* @param tp tType
*/
void Actor::Tag_Actor(int ano, SCNHANDLE tagtext, int tp) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- actorInfo[ano-1].tagged = true;
- actorInfo[ano-1].hTag = tagtext;
- actorInfo[ano-1].tType = tp;
+ _actorInfo[ano-1].tagged = true;
+ _actorInfo[ano-1].hTag = tagtext;
+ _actorInfo[ano-1].tType = tp;
}
/**
@@ -390,9 +390,9 @@ void Actor::Tag_Actor(int ano, SCNHANDLE tagtext, int tp) {
* @param tp tType
*/
void Actor::UnTagActor(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- actorInfo[ano-1].tagged = false;
+ _actorInfo[ano-1].tagged = false;
}
/**
@@ -402,10 +402,10 @@ void Actor::UnTagActor(int ano) {
* @param tp tType
*/
void Actor::ReTagActor(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- if (actorInfo[ano-1].hTag)
- actorInfo[ano-1].tagged = true;
+ if (_actorInfo[ano-1].hTag)
+ _actorInfo[ano-1].tagged = true;
}
/**
@@ -413,9 +413,9 @@ void Actor::ReTagActor(int ano) {
* @param ano Actor Id
*/
int Actor::TagType(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- return actorInfo[ano-1].tType;
+ return _actorInfo[ano-1].tType;
}
/**
@@ -423,9 +423,9 @@ int Actor::TagType(int ano) {
* @param ano Actor Id
*/
SCNHANDLE Actor::GetActorTag(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- return actorInfo[ano - 1].hTag;
+ return _actorInfo[ano - 1].hTag;
}
/**
@@ -446,13 +446,13 @@ int Actor::NextTaggedActor() {
PMOVER pActor;
bool hid;
- while (ti < NumActors) {
- if (actorInfo[ti].tagged) {
+ while (ti < _numActors) {
+ if (_actorInfo[ti].tagged) {
pActor = GetMover(ti+1);
if (pActor)
hid = MoverHidden(pActor);
else
- hid = actorInfo[ti].bHidden;
+ hid = _actorInfo[ti].bHidden;
if (!hid) {
return ++ti;
@@ -478,12 +478,12 @@ int Actor::NextTaggedActor(int previous) {
else
previous = TaggedActorIndex(previous);
- while (++previous < numTaggedActors) {
- pMover = GetMover(taggedActors[previous].id);
+ 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);
+ if ((_taggedActors[previous].id) == GetLeadId() && MoverMoving(pMover)) {
+ _taggedActors[previous].tagFlags &= ~(POINTING | TAGWANTED);
continue;
}
@@ -491,8 +491,8 @@ int Actor::NextTaggedActor(int previous) {
if (pMover && !MoverIs(pMover))
continue;
- if (!(pMover ? MoverHidden(pMover) : ActorHidden(taggedActors[previous].id))) {
- return taggedActors[previous].id;
+ if (!(pMover ? MoverHidden(pMover) : ActorHidden(_taggedActors[previous].id))) {
+ return _taggedActors[previous].id;
}
}
@@ -504,9 +504,9 @@ int Actor::NextTaggedActor(int previous) {
* @param ano Actor Id
*/
int32 Actor::actorMaskType(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- return actorInfo[ano - 1].mtype;
+ return _actorInfo[ano - 1].mtype;
}
/**
@@ -517,45 +517,45 @@ int32 Actor::actorMaskType(int ano) {
* @param y Y position
*/
void Actor::StoreActorPos(int ano, int x, int y) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- actorInfo[ano - 1].x = x;
- actorInfo[ano - 1].y = y;
+ _actorInfo[ano - 1].x = x;
+ _actorInfo[ano - 1].y = y;
}
void Actor::StoreActorSteps(int ano, int steps) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- actorInfo[ano - 1].steps = steps;
+ _actorInfo[ano - 1].steps = steps;
}
int Actor::GetActorSteps(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- return actorInfo[ano - 1].steps;
+ return _actorInfo[ano - 1].steps;
}
void Actor::StoreActorZpos(int ano, int z, int column) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
if (!TinselV2) {
// Prior to Tinsel 2, only a single z value was stored
- actorInfo[ano - 1].z = z;
+ _actorInfo[ano - 1].z = z;
} else {
// Alter existing entry, if there is one
for (int i = 0; i < NUM_ZPOSITIONS; i++) {
- if (zPositions[i].actor == ano && zPositions[i].column == column) {
- zPositions[i].z = z;
+ if (_zPositions[i].actor == ano && _zPositions[i].column == column) {
+ _zPositions[i].z = z;
return;
}
}
// No existing entry found, so find an empty slot
for (int i = 0; i < NUM_ZPOSITIONS; i++) {
- if (zPositions[i].actor == 0) {
- zPositions[i].actor = (short)ano;
- zPositions[i].column = (short)column;
- zPositions[i].z = z;
+ if (_zPositions[i].actor == 0) {
+ _zPositions[i].actor = (short)ano;
+ _zPositions[i].column = (short)column;
+ _zPositions[i].z = z;
return;
}
}
@@ -569,8 +569,8 @@ int Actor::GetActorZpos(int ano, int column) {
// Find entry, there should be one
for (int i = 0; i < NUM_ZPOSITIONS; i++) {
- if (zPositions[i].actor == ano && zPositions[i].column == column) {
- return zPositions[i].z;
+ if (_zPositions[i].actor == ano && _zPositions[i].column == column) {
+ return _zPositions[i].z;
}
}
@@ -580,27 +580,27 @@ int Actor::GetActorZpos(int ano, int column) {
void Actor::IncLoopCount(int ano) {
RANGE_CHECK(ano);
- actorInfo[ano - 1].loopCount++;
+ _actorInfo[ano - 1].loopCount++;
}
int Actor::GetLoopCount(int ano) {
RANGE_CHECK(ano);
- return actorInfo[ano - 1].loopCount;
+ return _actorInfo[ano - 1].loopCount;
}
void Actor::GetActorPos(int ano, int *x, int *y) {
PMOVER pActor;
- assert((ano > 0 && ano <= NumActors) || ano == LEAD_ACTOR); // unknown actor
+ assert((ano > 0 && ano <= _numActors) || ano == LEAD_ACTOR); // unknown actor
pActor = GetMover(ano);
if (pActor)
GetMoverPosition(pActor, x, y);
else {
- *x = actorInfo[ano - 1].x;
- *y = actorInfo[ano - 1].y;
+ *x = _actorInfo[ano - 1].x;
+ *y = _actorInfo[ano - 1].y;
}
}
@@ -615,7 +615,7 @@ void Actor::GetActorMidTop(int ano, int *x, int *y) {
// Not used in JAPAN version
PMOVER pActor;
- assert((ano > 0 && ano <= NumActors) || ano == LEAD_ACTOR); // unknown actor
+ assert((ano > 0 && ano <= _numActors) || ano == LEAD_ACTOR); // unknown actor
pActor = GetMover(ano);
@@ -624,10 +624,10 @@ void Actor::GetActorMidTop(int ano, int *x, int *y) {
else if (TinselV2) {
*x = (GetActorLeft(ano) + GetActorRight(ano)) / 2;
*y = GetActorTop(ano);
- } else if (actorInfo[ano - 1].presObj) {
- *x = (MultiLeftmost(actorInfo[ano - 1].presObj)
- + MultiRightmost(actorInfo[ano - 1].presObj)) / 2;
- *y = MultiHighest(actorInfo[ano - 1].presObj);
+ } else if (_actorInfo[ano - 1].presObj) {
+ *x = (MultiLeftmost(_actorInfo[ano - 1].presObj)
+ + MultiRightmost(_actorInfo[ano - 1].presObj)) / 2;
+ *y = MultiHighest(_actorInfo[ano - 1].presObj);
} else
GetActorPos(ano, x, y); // The best we can do!
}
@@ -637,14 +637,14 @@ void Actor::GetActorMidTop(int ano, int *x, int *y) {
* @param ano Actor Id
*/
int Actor::GetActorLeft(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
if (!TinselV2) {
// Tinsel 1 version
- if (!actorInfo[ano - 1].presObj)
+ if (!_actorInfo[ano - 1].presObj)
return 0;
- return MultiLeftmost(actorInfo[ano - 1].presObj);
+ return MultiLeftmost(_actorInfo[ano - 1].presObj);
}
// Tinsel 2 version
@@ -659,13 +659,13 @@ int Actor::GetActorLeft(int ano) {
for (i = 0, bIsObj = false; i < MAX_REELS; i++) {
// If there's an object
// and it is not a blank frame for it...
- if (actorInfo[ano-1].presObjs[i] && MultiHasShape(actorInfo[ano - 1].presObjs[i])) {
+ if (_actorInfo[ano-1].presObjs[i] && MultiHasShape(_actorInfo[ano - 1].presObjs[i])) {
if (!bIsObj) {
bIsObj = true;
- left = MultiLeftmost(actorInfo[ano - 1].presObjs[i]);
+ left = MultiLeftmost(_actorInfo[ano - 1].presObjs[i]);
} else {
- if (MultiLeftmost(actorInfo[ano - 1].presObjs[i]) < left)
- left = MultiLeftmost(actorInfo[ano - 1].presObjs[i]);
+ if (MultiLeftmost(_actorInfo[ano - 1].presObjs[i]) < left)
+ left = MultiLeftmost(_actorInfo[ano - 1].presObjs[i]);
}
}
}
@@ -679,14 +679,14 @@ int Actor::GetActorLeft(int ano) {
* @param ano Actor Id
*/
int Actor::GetActorRight(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
if (!TinselV2) {
// Tinsel 1 version
- if (!actorInfo[ano - 1].presObj)
+ if (!_actorInfo[ano - 1].presObj)
return 0;
- return MultiRightmost(actorInfo[ano - 1].presObj);
+ return MultiRightmost(_actorInfo[ano - 1].presObj);
}
// Tinsel 2 version
@@ -701,13 +701,13 @@ int Actor::GetActorRight(int ano) {
for (i = 0, bIsObj = false; i < MAX_REELS; i++) {
// If there's an object
// and it is not a blank frame for it...
- if (actorInfo[ano-1].presObjs[i] && MultiHasShape(actorInfo[ano-1].presObjs[i])) {
+ if (_actorInfo[ano-1].presObjs[i] && MultiHasShape(_actorInfo[ano-1].presObjs[i])) {
if (!bIsObj) {
bIsObj = true;
- right = MultiRightmost(actorInfo[ano-1].presObjs[i]);
+ right = MultiRightmost(_actorInfo[ano-1].presObjs[i]);
} else {
- if (MultiRightmost(actorInfo[ano-1].presObjs[i]) > right)
- right = MultiRightmost(actorInfo[ano-1].presObjs[i]);
+ if (MultiRightmost(_actorInfo[ano-1].presObjs[i]) > right)
+ right = MultiRightmost(_actorInfo[ano-1].presObjs[i]);
}
}
}
@@ -720,14 +720,14 @@ int Actor::GetActorRight(int ano) {
* @param ano Actor Id
*/
int Actor::GetActorTop(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
if (!TinselV2) {
// Tinsel 1 version
- if (!actorInfo[ano - 1].presObj)
+ if (!_actorInfo[ano - 1].presObj)
return 0;
- return MultiHighest(actorInfo[ano - 1].presObj);
+ return MultiHighest(_actorInfo[ano - 1].presObj);
}
// Tinsel 2 version
@@ -742,13 +742,13 @@ int Actor::GetActorTop(int ano) {
for (i = 0, bIsObj = false; i < MAX_REELS; i++) {
// If there's an object
// and it is not a blank frame for it...
- if (actorInfo[ano-1].presObjs[i] && MultiHasShape(actorInfo[ano-1].presObjs[i])) {
+ if (_actorInfo[ano-1].presObjs[i] && MultiHasShape(_actorInfo[ano-1].presObjs[i])) {
if (!bIsObj) {
bIsObj = true;
- top = MultiHighest(actorInfo[ano-1].presObjs[i]);
+ top = MultiHighest(_actorInfo[ano-1].presObjs[i]);
} else {
- if (MultiHighest(actorInfo[ano-1].presObjs[i]) < top)
- top = MultiHighest(actorInfo[ano-1].presObjs[i]);
+ if (MultiHighest(_actorInfo[ano-1].presObjs[i]) < top)
+ top = MultiHighest(_actorInfo[ano-1].presObjs[i]);
}
}
}
@@ -761,14 +761,14 @@ int Actor::GetActorTop(int ano) {
* Return the appropriate co-ordinate of the actor.
*/
int Actor::GetActorBottom(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
if (!TinselV2) {
// Tinsel 1 version
- if (!actorInfo[ano - 1].presObj)
+ if (!_actorInfo[ano - 1].presObj)
return 0;
- return MultiLowest(actorInfo[ano - 1].presObj);
+ return MultiLowest(_actorInfo[ano - 1].presObj);
}
// Tinsel 2 version
@@ -783,13 +783,13 @@ int Actor::GetActorBottom(int ano) {
for (i = 0, bIsObj = false; i < MAX_REELS; i++) {
// If there's an object
// and it is not a blank frame for it...
- if (actorInfo[ano-1].presObjs[i] && MultiHasShape(actorInfo[ano-1].presObjs[i])) {
+ if (_actorInfo[ano-1].presObjs[i] && MultiHasShape(_actorInfo[ano-1].presObjs[i])) {
if (!bIsObj) {
bIsObj = true;
- bottom = MultiLowest(actorInfo[ano-1].presObjs[i]);
+ bottom = MultiLowest(_actorInfo[ano-1].presObjs[i]);
} else {
- if (MultiLowest(actorInfo[ano-1].presObjs[i]) > bottom)
- bottom = MultiLowest(actorInfo[ano-1].presObjs[i]);
+ if (MultiLowest(_actorInfo[ano-1].presObjs[i]) > bottom)
+ bottom = MultiLowest(_actorInfo[ano-1].presObjs[i]);
}
}
}
@@ -803,7 +803,7 @@ int Actor::GetActorBottom(int ano) {
bool Actor::ActorHidden(int ano) {
RANGE_CHECK(ano);
- return actorInfo[ano - 1].bHidden;
+ return _actorInfo[ano - 1].bHidden;
}
/**
@@ -814,7 +814,7 @@ bool Actor::ActorHidden(int ano) {
bool Actor::HideMovingActor(int ano, int sf) {
PMOVER pActor;
- assert((ano > 0 && ano <= NumActors) || ano == LEAD_ACTOR); // illegal actor
+ assert((ano > 0 && ano <= _numActors) || ano == LEAD_ACTOR); // illegal actor
// Get moving actor involved
pActor = GetMover(ano);
@@ -823,8 +823,8 @@ bool Actor::HideMovingActor(int ano, int sf) {
HideMover(pActor, sf);
return true;
} else {
- if (actorInfo[ano - 1].presObj != NULL)
- MultiHideObject(actorInfo[ano - 1].presObj); // Hidee object
+ if (_actorInfo[ano - 1].presObj != NULL)
+ MultiHideObject(_actorInfo[ano - 1].presObj); // Hidee object
return false;
}
}
@@ -836,7 +836,7 @@ bool Actor::HideMovingActor(int ano, int sf) {
void Actor::unHideMovingActor(int ano) {
PMOVER pActor;
- assert((ano > 0 && ano <= NumActors) || ano == LEAD_ACTOR); // illegal actor
+ assert((ano > 0 && ano <= _numActors) || ano == LEAD_ACTOR); // illegal actor
// Get moving actor involved
pActor = GetMover(ano);
@@ -854,18 +854,18 @@ void Actor::unHideMovingActor(int ano) {
void Actor::restoreMovement(int ano) {
PMOVER pActor;
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
// Get moving actor involved
pActor = GetMover(ano);
assert(pActor); // not a moving actor
- if (pActor->objX == actorInfo[ano - 1].x && pActor->objY == actorInfo[ano - 1].y)
+ if (pActor->objX == _actorInfo[ano - 1].x && pActor->objY == _actorInfo[ano - 1].y)
return;
- pActor->objX = actorInfo[ano - 1].x;
- pActor->objY = actorInfo[ano - 1].y;
+ pActor->objX = _actorInfo[ano - 1].x;
+ pActor->objY = _actorInfo[ano - 1].y;
if (pActor->actorObj)
SSetActorDest(pActor);
@@ -878,7 +878,7 @@ void Actor::restoreMovement(int ano) {
void Actor::storeActorReel(int ano, const FREEL *reel, SCNHANDLE hFilm, OBJECT *pobj, int reelnum, int x, int y) {
PMOVER pActor;
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
pActor = GetMover(ano);
@@ -886,18 +886,18 @@ void Actor::storeActorReel(int ano, const FREEL *reel, SCNHANDLE hFilm, OBJECT *
// (MoverProcess() calls with reel=film=NULL, pobj not NULL)
if (!pActor
|| !(reel == NULL && hFilm == 0 && pobj != NULL)) {
- actorInfo[ano - 1].presReel = reel; // Store reel
- actorInfo[ano - 1].presRnum = reelnum; // Store reel number
- actorInfo[ano - 1].presFilm = hFilm; // Store film
- actorInfo[ano - 1].presPlayX = x;
- actorInfo[ano - 1].presPlayY = y;
+ _actorInfo[ano - 1].presReel = reel; // Store reel
+ _actorInfo[ano - 1].presRnum = reelnum; // Store reel number
+ _actorInfo[ano - 1].presFilm = hFilm; // Store film
+ _actorInfo[ano - 1].presPlayX = x;
+ _actorInfo[ano - 1].presPlayY = y;
}
// Only store the object for a moving actor if called from MoverProcess()
if (!pActor) {
- actorInfo[ano - 1].presObj = pobj; // Store object
+ _actorInfo[ano - 1].presObj = pobj; // Store object
} else if (reel == NULL && hFilm == 0 && pobj != NULL) {
- actorInfo[ano - 1].presObj = pobj; // Store object
+ _actorInfo[ano - 1].presObj = pobj; // Store object
}
}
@@ -905,94 +905,94 @@ void Actor::storeActorReel(int ano, const FREEL *reel, SCNHANDLE hFilm, OBJECT *
* Return the present reel/film of the actor.
*/
const FREEL *Actor::actorReel(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- return actorInfo[ano - 1].presReel; // the present reel
+ return _actorInfo[ano - 1].presReel; // the present reel
}
/***************************************************************************/
void Actor::SetActorPlayFilm(int ano, SCNHANDLE hFilm) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- actorInfo[ano - 1].playFilm = hFilm;
+ _actorInfo[ano - 1].playFilm = hFilm;
}
SCNHANDLE Actor::GetActorPlayFilm(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- return actorInfo[ano - 1].playFilm;
+ return _actorInfo[ano - 1].playFilm;
}
void Actor::SetActorTalkFilm(int ano, SCNHANDLE hFilm) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- actorInfo[ano - 1].talkFilm = hFilm;
+ _actorInfo[ano - 1].talkFilm = hFilm;
}
SCNHANDLE Actor::GetActorTalkFilm(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- return actorInfo[ano - 1].talkFilm;
+ return _actorInfo[ano - 1].talkFilm;
}
void Actor::SetActorTalking(int ano, bool tf) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- actorInfo[ano - 1].bTalking = tf;
+ _actorInfo[ano - 1].bTalking = tf;
}
bool Actor::ActorIsTalking(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- return actorInfo[ano - 1].bTalking;
+ return _actorInfo[ano - 1].bTalking;
}
void Actor::SetActorLatestFilm(int ano, SCNHANDLE hFilm) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- actorInfo[ano - 1].latestFilm = hFilm;
- actorInfo[ano - 1].steps = 0;
+ _actorInfo[ano - 1].latestFilm = hFilm;
+ _actorInfo[ano - 1].steps = 0;
}
SCNHANDLE Actor::GetActorLatestFilm(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- return actorInfo[ano - 1].latestFilm;
+ return _actorInfo[ano - 1].latestFilm;
}
/***************************************************************************/
void Actor::UpdateActorEsc(int ano, bool escOn, int escEvent) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- actorInfo[ano - 1].bEscOn = escOn;
- actorInfo[ano - 1].escEvent = escEvent;
+ _actorInfo[ano - 1].bEscOn = escOn;
+ _actorInfo[ano - 1].escEvent = escEvent;
}
void Actor::UpdateActorEsc(int ano, int escEvent) {
RANGE_CHECK(ano);
if (escEvent) {
- actorInfo[ano - 1].bEscOn = true;
- actorInfo[ano - 1].escEvent = escEvent;
+ _actorInfo[ano - 1].bEscOn = true;
+ _actorInfo[ano - 1].escEvent = escEvent;
} else {
- actorInfo[ano - 1].bEscOn = false;
- actorInfo[ano - 1].escEvent = GetEscEvents();
+ _actorInfo[ano - 1].bEscOn = false;
+ _actorInfo[ano - 1].escEvent = GetEscEvents();
}
}
bool Actor::ActorEsc(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- return actorInfo[ano - 1].bEscOn;
+ return _actorInfo[ano - 1].bEscOn;
}
int Actor::ActorEev(int ano) {
- assert(ano > 0 && ano <= NumActors); // illegal actor number
+ assert(ano > 0 && ano <= _numActors); // illegal actor number
- return actorInfo[ano - 1].escEvent;
+ return _actorInfo[ano - 1].escEvent;
}
/**
@@ -1013,16 +1013,16 @@ int Actor::AsetZPos(OBJECT *pObj, int y, int32 z) {
* Currently only the speech colors.
*/
void Actor::storeActorAttr(int ano, int r1, int g1, int b1) {
- assert((ano > 0 && ano <= NumActors) || ano == -1); // illegal actor number
+ assert((ano > 0 && ano <= _numActors) || ano == -1); // illegal actor number
if (r1 > MAX_INTENSITY) r1 = MAX_INTENSITY; // } Ensure
if (g1 > MAX_INTENSITY) g1 = MAX_INTENSITY; // } within limits
if (b1 > MAX_INTENSITY) b1 = MAX_INTENSITY; // }
if (ano == -1)
- defaultColor = TINSEL_RGB(r1, g1, b1);
+ _defaultColor = TINSEL_RGB(r1, g1, b1);
else
- actorInfo[ano - 1].textColor = TINSEL_RGB(r1, g1, b1);
+ _actorInfo[ano - 1].textColor = TINSEL_RGB(r1, g1, b1);
}
/**
@@ -1030,12 +1030,12 @@ void Actor::storeActorAttr(int ano, int r1, int g1, int b1) {
*/
void Actor::SetActorRGB(int ano, COLORREF color) {
- assert(ano >= 0 && ano <= NumActors);
+ assert(ano >= 0 && ano <= _numActors);
if (ano)
- actorInfo[ano - 1].textColor = TO_32(color);
+ _actorInfo[ano - 1].textColor = TO_32(color);
else
- defaultColor = TO_32(color);
+ _defaultColor = TO_32(color);
}
/**
@@ -1044,12 +1044,12 @@ void Actor::SetActorRGB(int ano, COLORREF color) {
*/
COLORREF Actor::GetActorRGB(int ano) {
// Not used in JAPAN version
- assert((ano >= -1) && (ano <= NumActors)); // illegal actor number
+ assert((ano >= -1) && (ano <= _numActors)); // illegal actor number
- if ((ano == -1) || !actorInfo[ano - 1].textColor)
- return defaultColor;
+ if ((ano == -1) || !_actorInfo[ano - 1].textColor)
+ return _defaultColor;
else
- return actorInfo[ano - 1].textColor;
+ return _actorInfo[ano - 1].textColor;
}
/**
@@ -1058,13 +1058,13 @@ COLORREF Actor::GetActorRGB(int ano) {
void Actor::SetActorZfactor(int ano, uint32 zFactor) {
RANGE_CHECK(ano);
- zFactors[ano - 1] = (uint8)zFactor;
+ _zFactors[ano - 1] = (uint8)zFactor;
}
uint32 Actor::GetActorZfactor(int ano) {
RANGE_CHECK(ano);
- return zFactors[ano - 1];
+ return _zFactors[ano - 1];
}
/**
@@ -1073,29 +1073,29 @@ uint32 Actor::GetActorZfactor(int ano) {
int Actor::SaveActors(PSAVED_ACTOR sActorInfo) {
int i, j, k;
- for (i = 0, j = 0; i < NumActors; i++) {
+ for (i = 0, j = 0; i < _numActors; i++) {
for (k = 0; k < (TinselV2 ? MAX_REELS : 1); ++k) {
- bool presFlag = !TinselV2 ? actorInfo[i].presObj != NULL :
- (actorInfo[i].presObjs[k] != NULL) && !IsCdPlayHandle(actorInfo[i].presFilm);
+ bool presFlag = !TinselV2 ? _actorInfo[i].presObj != NULL :
+ (_actorInfo[i].presObjs[k] != NULL) && !IsCdPlayHandle(_actorInfo[i].presFilm);
if (presFlag) {
assert(j < MAX_SAVED_ACTORS); // Saving too many actors
if (!TinselV2) {
- sActorInfo[j].bAlive = actorInfo[i].bAlive;
- sActorInfo[j].zFactor = (short)actorInfo[i].z;
- sActorInfo[j].presRnum = (short)actorInfo[i].presRnum;
+ sActorInfo[j].bAlive = _actorInfo[i].bAlive;
+ sActorInfo[j].zFactor = (short)_actorInfo[i].z;
+ sActorInfo[j].presRnum = (short)_actorInfo[i].presRnum;
}
sActorInfo[j].actorID = (short)(i+1);
if (TinselV2)
- sActorInfo[j].bHidden = actorInfo[i].bHidden;
+ sActorInfo[j].bHidden = _actorInfo[i].bHidden;
// sActorInfo[j].x = (short)actorInfo[i].x;
// sActorInfo[j].y = (short)actorInfo[i].y;
// sActorInfo[j].presReel = actorInfo[i].presReel;
- sActorInfo[j].presFilm = actorInfo[i].presFilm;
- sActorInfo[j].presPlayX = (short)actorInfo[i].presPlayX;
- sActorInfo[j].presPlayY = (short)actorInfo[i].presPlayY;
+ sActorInfo[j].presFilm = _actorInfo[i].presFilm;
+ sActorInfo[j].presPlayX = (short)_actorInfo[i].presPlayX;
+ sActorInfo[j].presPlayY = (short)_actorInfo[i].presPlayY;
j++;
break;
@@ -1115,7 +1115,7 @@ void Actor::RestoreActors(int numActors, PSAVED_ACTOR sActorInfo) {
for (i = 0; i < numActors; i++) {
aIndex = sActorInfo[i].actorID - 1;
- actorInfo[aIndex].bHidden = sActorInfo[i].bHidden;
+ _actorInfo[aIndex].bHidden = sActorInfo[i].bHidden;
// Play the same reel.
if (sActorInfo[i].presFilm != 0) {
@@ -1126,57 +1126,57 @@ void Actor::RestoreActors(int numActors, PSAVED_ACTOR sActorInfo) {
}
void Actor::SaveZpositions(void *zpp) {
- memcpy(zpp, zPositions, sizeof(zPositions));
+ memcpy(zpp, _zPositions, sizeof(_zPositions));
}
void Actor::RestoreZpositions(void *zpp) {
- memcpy(zPositions, zpp, sizeof(zPositions));
+ memcpy(_zPositions, zpp, sizeof(_zPositions));
}
void Actor::SaveActorZ(byte *saveActorZ) {
- assert(NumActors <= MAX_SAVED_ACTOR_Z);
+ assert(_numActors <= MAX_SAVED_ACTOR_Z);
- memcpy(saveActorZ, zFactors, NumActors);
+ memcpy(saveActorZ, _zFactors, _numActors);
}
void Actor::RestoreActorZ(byte *saveActorZ) {
- memcpy(zFactors, saveActorZ, NumActors);
+ memcpy(_zFactors, saveActorZ, _numActors);
}
void Actor::SetActorsOn() {
- bActorsOn = true;
+ _actorsOn = true;
}
void Actor::ToggleActor(int ano, bool show) {
- assert((ano > 0 && ano <= NumActors) || ano == -1); // illegal actor number
- actorInfo[ano - 1].bHidden = !show;
+ assert((ano > 0 && ano <= _numActors) || ano == -1); // illegal actor number
+ _actorInfo[ano - 1].bHidden = !show;
}
SCNHANDLE Actor::GetActorCode(int ano) {
- assert((ano > 0 && ano <= NumActors) || ano == -1); // illegal actor number
- return actorInfo[ano - 1].actorCode;
+ assert((ano > 0 && ano <= _numActors) || ano == -1); // illegal actor number
+ return _actorInfo[ano - 1].actorCode;
}
SCNHANDLE Actor::GetTaggedActorCode(int ano) {
- return taggedActors[ano - 1].hActorCode;
+ return _taggedActors[ano - 1].hActorCode;
}
void Actor::RunCodeToCompletion(int ano) {
- assert((ano > 0 && ano <= NumActors) || ano == -1); // illegal actor number
- actorInfo[ano - 1].completed = true;
+ assert((ano > 0 && ano <= _numActors) || ano == -1); // illegal actor number
+ _actorInfo[ano - 1].completed = true;
}
void Actor::ActorsLife(int ano, bool bAlive) {
- assert((ano > 0 && ano <= NumActors) || ano == -1); // illegal actor number
- actorInfo[ano - 1].bAlive = bAlive;
+ assert((ano > 0 && ano <= _numActors) || ano == -1); // illegal actor number
+ _actorInfo[ano - 1].bAlive = bAlive;
}
void Actor::syncAllActorsAlive(Common::Serializer &s) {
for (int i = 0; i < MAX_SAVED_ALIVES; i++) {
- s.syncAsByte(actorInfo[i].bAlive);
- s.syncAsByte(actorInfo[i].tagged);
- s.syncAsByte(actorInfo[i].tType);
- s.syncAsUint32LE(actorInfo[i].hTag);
+ s.syncAsByte(_actorInfo[i].bAlive);
+ s.syncAsByte(_actorInfo[i].tagged);
+ s.syncAsByte(_actorInfo[i].tType);
+ s.syncAsUint32LE(_actorInfo[i].hTag);
}
}
@@ -1193,14 +1193,14 @@ void Actor::dwEndActor(int ano) {
// actorInfo[ano - 1].presFilm = nullptr;
// but things were returning after a cut scene.
// so re-instate it and de-register the object
- actorInfo[ano - 1].presFilm = 0;
- actorInfo[ano-1].filmNum++;
+ _actorInfo[ano - 1].presFilm = 0;
+ _actorInfo[ano-1].filmNum++;
for (i = 0; i < MAX_REELS; i++) {
// It may take a frame to remove this, so make it invisible
- if (actorInfo[ano-1].presObjs[i] != NULL) {
- MultiHideObject(actorInfo[ano-1].presObjs[i]);
- actorInfo[ano-1].presObjs[i] = nullptr;
+ if (_actorInfo[ano-1].presObjs[i] != NULL) {
+ MultiHideObject(_actorInfo[ano-1].presObjs[i]);
+ _actorInfo[ano-1].presObjs[i] = nullptr;
}
}
}
@@ -1213,10 +1213,10 @@ void Actor::GetActorTagPortion(int ano, unsigned *top, unsigned *bottom, unsigne
// Convert actor number to index
ano = TaggedActorIndex(ano);
- *top = taggedActors[ano].tagPortionV >> 16;
- *bottom = taggedActors[ano].tagPortionV & 0xffff;
- *left = taggedActors[ano].tagPortionH >> 16;
- *right = taggedActors[ano].tagPortionH & 0xffff;
+ *top = _taggedActors[ano].tagPortionV >> 16;
+ *bottom = _taggedActors[ano].tagPortionV & 0xffff;
+ *left = _taggedActors[ano].tagPortionH >> 16;
+ *right = _taggedActors[ano].tagPortionH & 0xffff;
// ensure validity
assert(*top >= 1 && *top <= 8);
@@ -1232,8 +1232,8 @@ SCNHANDLE Actor::GetActorTagHandle(int ano) {
// Convert actor number to index
ano = TaggedActorIndex(ano);
- return taggedActors[ano].hOverrideTag ?
- taggedActors[ano].hOverrideTag : taggedActors[ano].hTagText;
+ return _taggedActors[ano].hOverrideTag ?
+ _taggedActors[ano].hOverrideTag : _taggedActors[ano].hTagText;
}
void Actor::SetActorPointedTo(int actor, bool bPointedTo) {
@@ -1241,16 +1241,16 @@ void Actor::SetActorPointedTo(int actor, bool bPointedTo) {
actor = TaggedActorIndex(actor);
if (bPointedTo)
- taggedActors[actor].tagFlags |= POINTING;
+ _taggedActors[actor].tagFlags |= POINTING;
else
- taggedActors[actor].tagFlags &= ~POINTING;
+ _taggedActors[actor].tagFlags &= ~POINTING;
}
bool Actor::ActorIsPointedTo(int actor) {
// Convert actor number to index
actor = TaggedActorIndex(actor);
- return (taggedActors[actor].tagFlags & POINTING);
+ return (_taggedActors[actor].tagFlags & POINTING);
}
void Actor::SetActorTagWanted(int actor, bool bTagWanted, bool bCursor, SCNHANDLE hOverrideTag) {
@@ -1258,24 +1258,24 @@ void Actor::SetActorTagWanted(int actor, bool bTagWanted, bool bCursor, SCNHANDL
actor = TaggedActorIndex(actor);
if (bTagWanted) {
- taggedActors[actor].tagFlags |= TAGWANTED;
- taggedActors[actor].hOverrideTag = hOverrideTag;
+ _taggedActors[actor].tagFlags |= TAGWANTED;
+ _taggedActors[actor].hOverrideTag = hOverrideTag;
} else {
- taggedActors[actor].tagFlags &= ~TAGWANTED;
- taggedActors[actor].hOverrideTag = 0;
+ _taggedActors[actor].tagFlags &= ~TAGWANTED;
+ _taggedActors[actor].hOverrideTag = 0;
}
if (bCursor)
- taggedActors[actor].tagFlags |= FOLLOWCURSOR;
+ _taggedActors[actor].tagFlags |= FOLLOWCURSOR;
else
- taggedActors[actor].tagFlags &= ~FOLLOWCURSOR;
+ _taggedActors[actor].tagFlags &= ~FOLLOWCURSOR;
}
bool Actor::ActorTagIsWanted(int actor) {
// Convert actor number to index
actor = TaggedActorIndex(actor);
- return (taggedActors[actor].tagFlags & TAGWANTED);
+ return (_taggedActors[actor].tagFlags & TAGWANTED);
}
/**
@@ -1324,9 +1324,9 @@ bool Actor::InHotSpot(int ano, int curX, int curY) {
int Actor::FrontTaggedActor() {
int i;
- for (i = 0; i < numTaggedActors; i++) {
- if (taggedActors[i].tagFlags & POINTING)
- return taggedActors[i].id;
+ for (i = 0; i < _numTaggedActors; i++) {
+ if (_taggedActors[i].tagFlags & POINTING)
+ return _taggedActors[i].id;
}
return 0;
}
@@ -1362,8 +1362,8 @@ void Actor::GetActorTagPos(int actor, int *pTagX, int *pTagY, bool bAbsolute) {
bool Actor::IsTaggedActor(int actor) {
int i;
- for (i = 0; i < numTaggedActors; i++) {
- if (taggedActors[i].id == actor)
+ for (i = 0; i < _numTaggedActors; i++) {
+ if (_taggedActors[i].id == actor)
return true;
}
return false;
@@ -1377,18 +1377,18 @@ void Actor::StoreActorPresFilm(int ano, SCNHANDLE hFilm, int x, int y) {
RANGE_CHECK(ano);
- actorInfo[ano-1].presFilm = hFilm;
- actorInfo[ano-1].presPlayX = x;
- actorInfo[ano-1].presPlayY = y;
- actorInfo[ano-1].filmNum++;
+ _actorInfo[ano-1].presFilm = hFilm;
+ _actorInfo[ano-1].presPlayX = x;
+ _actorInfo[ano-1].presPlayY = y;
+ _actorInfo[ano-1].filmNum++;
for (i = 0; i < MAX_REELS; i++) {
// It may take a frame to remove this, so make it invisible
- if (actorInfo[ano - 1].presObjs[i] != NULL)
- MultiHideObject(actorInfo[ano - 1].presObjs[i]);
+ if (_actorInfo[ano - 1].presObjs[i] != NULL)
+ MultiHideObject(_actorInfo[ano - 1].presObjs[i]);
- actorInfo[ano - 1].presColumns[i] = -1;
- actorInfo[ano - 1].presObjs[i] = nullptr;
+ _actorInfo[ano - 1].presColumns[i] = -1;
+ _actorInfo[ano - 1].presObjs[i] = nullptr;
}
}
@@ -1398,7 +1398,7 @@ void Actor::StoreActorPresFilm(int ano, SCNHANDLE hFilm, int x, int y) {
SCNHANDLE Actor::GetActorPresFilm(int ano) {
RANGE_CHECK(ano);
- return actorInfo[ano - 1].presFilm;
+ return _actorInfo[ano - 1].presFilm;
}
@@ -1408,7 +1408,7 @@ SCNHANDLE Actor::GetActorPresFilm(int ano) {
int Actor::GetActorFilmNumber(int ano) {
RANGE_CHECK(ano);
- return actorInfo[ano - 1].filmNum;
+ return _actorInfo[ano - 1].filmNum;
}
/**
@@ -1420,10 +1420,10 @@ void Actor::StoreActorReel(int actor, int column, OBJECT *pObj) {
int i;
for (i = 0; i < MAX_REELS; i++) {
- if (actorInfo[actor-1].presColumns[i] == -1) {
+ if (_actorInfo[actor-1].presColumns[i] == -1) {
// Store reel and object
- actorInfo[actor - 1].presColumns[i] = column;
- actorInfo[actor - 1].presObjs[i] = pObj;
+ _actorInfo[actor - 1].presColumns[i] = column;
+ _actorInfo[actor - 1].presObjs[i] = pObj;
break;
}
}
@@ -1439,32 +1439,32 @@ void Actor::NotPlayingReel(int actor, int filmNumber, int column) {
RANGE_CHECK(actor);
- if (actorInfo[actor-1].filmNum != filmNumber)
+ if (_actorInfo[actor-1].filmNum != filmNumber)
return;
// De-register this reel
for (i = 0; i < MAX_REELS; i++) {
- if (actorInfo[actor-1].presColumns[i] == column) {
- actorInfo[actor-1].presObjs[i] = nullptr;
- actorInfo[actor-1].presColumns[i] = -1;
+ if (_actorInfo[actor-1].presColumns[i] == column) {
+ _actorInfo[actor-1].presObjs[i] = nullptr;
+ _actorInfo[actor-1].presColumns[i] = -1;
break;
}
}
// De-register the film if this was the last reel
for (i = 0; i < MAX_REELS; i++) {
- if (actorInfo[actor-1].presColumns[i] != -1)
+ if (_actorInfo[actor-1].presColumns[i] != -1)
break;
}
if (i == MAX_REELS)
- actorInfo[actor-1].presFilm = 0;
+ _actorInfo[actor-1].presFilm = 0;
}
bool Actor::ActorReelPlaying(int actor, int column) {
RANGE_CHECK(actor);
for (int i = 0; i < MAX_REELS; i++) {
- if (actorInfo[actor - 1].presColumns[i] == column)
+ if (_actorInfo[actor - 1].presColumns[i] == column)
return true;
}
return false;
diff --git a/engines/tinsel/actors.h b/engines/tinsel/actors.h
index eca5184053..b26f976aeb 100644
--- a/engines/tinsel/actors.h
+++ b/engines/tinsel/actors.h
@@ -53,7 +53,7 @@ struct Z_POSITIONS;
#define NUM_ZPOSITIONS 200 // Reasonable-sounding number
#define MAX_REELS 6
-struct TAGACTOR {
+struct TAGACTORDATA {
// Copies of compiled data
int id;
SCNHANDLE hTagText; // handle to tag text
@@ -81,21 +81,20 @@ struct Z_POSITIONS {
int z;
};
-typedef TAGACTOR *PTAGACTOR;
typedef SAVED_ACTOR *PSAVED_ACTOR;
/*----------------------------------------------------------------------*/
class Actor {
public:
- Actor(): actorInfo(nullptr), defaultColor(0), bActorsOn(false), ti(0), numTaggedActors(0), zFactors(nullptr), LeadActorId(0), NumActors(0) {}
+ Actor(): _actorInfo(nullptr), _defaultColor(0), _actorsOn(false), ti(0), _numTaggedActors(0), _zFactors(nullptr), _leadActorId(0), _numActors(0) {}
int GetLeadId();
SCNHANDLE GetActorTagHandle(int ano);
void ToggleActor(int ano, bool show);
SCNHANDLE GetActorCode(int ano);
SCNHANDLE GetTaggedActorCode(int ano);
void RunCodeToCompletion(int ano);
- int GetCount() { return NumActors; }
+ int GetCount() { return _numActors; }
void RegisterActors(int num);
void FreeActors();
@@ -198,16 +197,16 @@ private:
void StartActor(const T1_ACTOR_STRUC *as, bool bRunScript);
void GetActorTagPortion(int ano, unsigned *top, unsigned *bottom, unsigned *left, unsigned *right);
- ACTORINFO *actorInfo;
- COLORREF defaultColor; // Text color
- bool bActorsOn;
+ ACTORINFO *_actorInfo;
+ COLORREF _defaultColor; // Text color
+ bool _actorsOn;
int ti;
- TAGACTOR taggedActors[MAX_TAGACTORS];
- int numTaggedActors;
- uint8 *zFactors;
- Z_POSITIONS zPositions[NUM_ZPOSITIONS];
- int LeadActorId; // The lead actor
- int NumActors; // The total number of actors in the game
+ TAGACTORDATA _taggedActors[MAX_TAGACTORS];
+ int _numTaggedActors;
+ uint8 *_zFactors;
+ Z_POSITIONS _zPositions[NUM_ZPOSITIONS];
+ int _leadActorId; // The lead actor
+ int _numActors; // The total number of actors in the game
};
/*----------------------------------------------------------------------*/
Commit: ae2e05cbd323663834ab5757035516eb9dfa74d7
https://github.com/scummvm/scummvm/commit/ae2e05cbd323663834ab5757035516eb9dfa74d7
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-10-04T01:15:19+03:00
Commit Message:
TINSEL: Move all handle-related functions into a new Handle class
Changed paths:
engines/tinsel/actors.cpp
engines/tinsel/anim.cpp
engines/tinsel/bg.cpp
engines/tinsel/bmv.cpp
engines/tinsel/cursor.cpp
engines/tinsel/dialogs.cpp
engines/tinsel/faders.cpp
engines/tinsel/font.cpp
engines/tinsel/graphics.cpp
engines/tinsel/handle.cpp
engines/tinsel/handle.h
engines/tinsel/mareels.cpp
engines/tinsel/multiobj.cpp
engines/tinsel/music.cpp
engines/tinsel/object.cpp
engines/tinsel/palette.cpp
engines/tinsel/pcode.cpp
engines/tinsel/play.cpp
engines/tinsel/polygons.cpp
engines/tinsel/rince.cpp
engines/tinsel/scene.cpp
engines/tinsel/sched.cpp
engines/tinsel/scn.cpp
engines/tinsel/text.cpp
engines/tinsel/tinlib.cpp
engines/tinsel/tinsel.cpp
engines/tinsel/tinsel.h
diff --git a/engines/tinsel/actors.cpp b/engines/tinsel/actors.cpp
index 175f58621e..6839bdae9f 100644
--- a/engines/tinsel/actors.cpp
+++ b/engines/tinsel/actors.cpp
@@ -260,13 +260,13 @@ void Actor::StartTaggedActors(SCNHANDLE ah, int numActors, bool bRunScript) {
if (!TinselV2) {
// Tinsel 1 load variation
- const T1_ACTOR_STRUC *as = (const T1_ACTOR_STRUC *)LockMem(ah);
+ const T1_ACTOR_STRUC *as = (const T1_ACTOR_STRUC *)_vm->_handle->LockMem(ah);
for (i = 0; i < numActors; i++, as++) {
StartActor(as, bRunScript);
}
} else if (numActors > 0) {
// Tinsel 2 load variation
- const T2_ACTOR_STRUC *as = (T2_ACTOR_STRUC *)LockMem(ah);
+ const T2_ACTOR_STRUC *as = (T2_ACTOR_STRUC *)_vm->_handle->LockMem(ah);
for (i = 0; i < numActors; i++, as++) {
assert(as->hActorCode);
@@ -1076,7 +1076,7 @@ int Actor::SaveActors(PSAVED_ACTOR sActorInfo) {
for (i = 0, j = 0; i < _numActors; i++) {
for (k = 0; k < (TinselV2 ? MAX_REELS : 1); ++k) {
bool presFlag = !TinselV2 ? _actorInfo[i].presObj != NULL :
- (_actorInfo[i].presObjs[k] != NULL) && !IsCdPlayHandle(_actorInfo[i].presFilm);
+ (_actorInfo[i].presObjs[k] != NULL) && !_vm->_handle->IsCdPlayHandle(_actorInfo[i].presFilm);
if (presFlag) {
assert(j < MAX_SAVED_ACTORS); // Saving too many actors
diff --git a/engines/tinsel/anim.cpp b/engines/tinsel/anim.cpp
index e241c7cba0..6111347879 100644
--- a/engines/tinsel/anim.cpp
+++ b/engines/tinsel/anim.cpp
@@ -39,7 +39,7 @@ namespace Tinsel {
*/
SCRIPTSTATE DoNextFrame(ANIM *pAnim) {
// get a pointer to the script
- const ANI_SCRIPT *pAni = (const ANI_SCRIPT *)LockMem(pAnim->hScript);
+ const ANI_SCRIPT *pAni = (const ANI_SCRIPT *)_vm->_handle->LockMem(pAnim->hScript);
while (1) { // repeat until a real image
debugC(DEBUG_DETAILED, kTinselDebugAnimations,
@@ -265,7 +265,7 @@ SCRIPTSTATE StepAnimScript(ANIM *pAnim) {
*/
void SkipFrames(ANIM *pAnim, int numFrames) {
// get a pointer to the script
- const ANI_SCRIPT *pAni = (const ANI_SCRIPT *)LockMem(pAnim->hScript);
+ const ANI_SCRIPT *pAni = (const ANI_SCRIPT *)_vm->_handle->LockMem(pAnim->hScript);
if (!TinselV2 && (numFrames <= 0))
// do nothing
@@ -409,7 +409,7 @@ void SkipFrames(ANIM *pAnim, int numFrames) {
bool AboutToJumpOrEnd(PANIM pAnim) {
if (pAnim->aniDelta == 1) {
// get a pointer to the script
- ANI_SCRIPT *pAni = (ANI_SCRIPT *)LockMem(pAnim->hScript);
+ ANI_SCRIPT *pAni = (ANI_SCRIPT *)_vm->_handle->LockMem(pAnim->hScript);
int zzz = pAnim->scriptIndex;
for (;;) {
diff --git a/engines/tinsel/bg.cpp b/engines/tinsel/bg.cpp
index cf25b50fd5..9f83936650 100644
--- a/engines/tinsel/bg.cpp
+++ b/engines/tinsel/bg.cpp
@@ -65,7 +65,7 @@ void BGmainProcess(CORO_PARAM, const void *param) {
pReel = (const FREEL *)param;
// Get the MULTI_INIT structure
- pmi = (const MULTI_INIT *)LockMem(FROM_32(pReel->mobj));
+ pmi = (const MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pReel->mobj));
// Initialize and insert the object, and initialize its script.
_vm->_bg->_pBG[0] = MultiInitObject(pmi);
@@ -74,13 +74,13 @@ void BGmainProcess(CORO_PARAM, const void *param) {
_vm->_bg->_bgReels = 1;
} else {
/*** At start of scene ***/
- pFilm = (const FILM *)LockMem(_vm->_bg->GetBgroundHandle());
+ pFilm = (const FILM *)_vm->_handle->LockMem(_vm->_bg->GetBgroundHandle());
_vm->_bg->_bgReels = FROM_32(pFilm->numreels);
int i;
for (i = 0; i < _vm->_bg->_bgReels; i++) {
// Get the MULTI_INIT structure
- pmi = (PMULTI_INIT) LockMem(FROM_32(pFilm->reels[i].mobj));
+ pmi = (PMULTI_INIT)_vm->_handle->LockMem(FROM_32(pFilm->reels[i].mobj));
// Initialize and insert the object, and initialize its script.
_vm->_bg->_pBG[i] = MultiInitObject(pmi);
@@ -114,7 +114,7 @@ void BGmainProcess(CORO_PARAM, const void *param) {
InitStepAnimScript(&_vm->_bg->_thisAnim[0], _vm->_bg->_pBG[0], FROM_32(pReel->script), _vm->_bg->getBgSpeed());
StepAnimScript(&_vm->_bg->_thisAnim[0]);
} else {
- pFilm = (const FILM *)LockMem(_vm->_bg->GetBgroundHandle());
+ pFilm = (const FILM *)_vm->_handle->LockMem(_vm->_bg->GetBgroundHandle());
assert(_vm->_bg->_bgReels == (int32)FROM_32(pFilm->numreels));
// Just re-initialize the scripts.
@@ -139,7 +139,7 @@ void BGotherProcess(CORO_PARAM, const void *param) {
CORO_END_CONTEXT(_ctx);
const FREEL *pReel = (const FREEL *)param;
- const MULTI_INIT *pmi = (const MULTI_INIT *)LockMem(FROM_32(pReel->mobj));
+ const MULTI_INIT *pmi = (const MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pReel->mobj));
CORO_BEGIN_CODE(_ctx);
diff --git a/engines/tinsel/bmv.cpp b/engines/tinsel/bmv.cpp
index a5e074cb66..6cae56f61d 100644
--- a/engines/tinsel/bmv.cpp
+++ b/engines/tinsel/bmv.cpp
@@ -567,7 +567,7 @@ void BMVPlayer::PlayBMV(CORO_PARAM, SCNHANDLE hFileStem, int myEscape) {
assert(!bMovieOn);
- Common::strlcpy(szMovieFile, (char *)LockMem(hFileStem), 14);
+ Common::strlcpy(szMovieFile, (char *)_vm->_handle->LockMem(hFileStem), 14);
Common::strlcat(szMovieFile, BMOVIE_EXTENSION, 14);
assert(strlen(szMovieFile) <= 12);
diff --git a/engines/tinsel/cursor.cpp b/engines/tinsel/cursor.cpp
index e1af8be948..f893019ced 100644
--- a/engines/tinsel/cursor.cpp
+++ b/engines/tinsel/cursor.cpp
@@ -207,7 +207,7 @@ void Cursor::RestoreMainCursor() {
const FILM *pfilm;
if (_mainCursor != NULL) {
- pfilm = (const FILM *)LockMem(_cursorFilm);
+ pfilm = (const FILM *)_vm->_handle->LockMem(_cursorFilm);
InitStepAnimScript(&_mainCursorAnim, _mainCursor, FROM_32(pfilm->reels->script), ONE_SECOND / FROM_32(pfilm->frate));
StepAnimScript(&_mainCursorAnim);
@@ -306,14 +306,14 @@ IMAGE *Cursor::GetImageFromReel(const FREEL *pfr, const MULTI_INIT **ppmi) {
const MULTI_INIT *pmi;
const FRAME *pFrame;
- pmi = (const MULTI_INIT *)LockMem(FROM_32(pfr->mobj));
+ pmi = (const MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pfr->mobj));
if (ppmi)
*ppmi = pmi;
- pFrame = (const FRAME *)LockMem(FROM_32(pmi->hMulFrame));
+ pFrame = (const FRAME *)_vm->_handle->LockMem(FROM_32(pmi->hMulFrame));
// get pointer to image
- return (IMAGE *)LockMem(READ_32(pFrame));
+ return (IMAGE *)_vm->_handle->LockMem(READ_32(pFrame));
}
/**
@@ -323,7 +323,7 @@ IMAGE *Cursor::GetImageFromFilm(SCNHANDLE hFilm, int reel, const FREEL **ppfr, c
const FILM *pfilm;
const FREEL *pfr;
- pfilm = (const FILM *)LockMem(hFilm);
+ pfilm = (const FILM *)_vm->_handle->LockMem(hFilm);
if (ppfilm)
*ppfilm = pfilm;
@@ -465,9 +465,9 @@ void Cursor::InitCurObj() {
IMAGE *pim;
if (TinselV2) {
- pFilm = (const FILM *)LockMem(_cursorFilm);
+ pFilm = (const FILM *)_vm->_handle->LockMem(_cursorFilm);
pfr = (const FREEL *)&pFilm->reels[0];
- pmi = (MULTI_INIT *)LockMem(FROM_32(pfr->mobj));
+ pmi = (MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pfr->mobj));
PokeInPalette(pmi);
} else {
@@ -509,7 +509,7 @@ void Cursor::DwInitCursor(SCNHANDLE bfilm) {
_cursorFilm = bfilm;
- pfilm = (const FILM *)LockMem(_cursorFilm);
+ pfilm = (const FILM *)_vm->_handle->LockMem(_cursorFilm);
_numTrails = FROM_32(pfilm->numreels) - 1;
assert(_numTrails <= MAX_TRAILERS);
diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp
index 1c1422fae1..0d7827eeaf 100644
--- a/engines/tinsel/dialogs.cpp
+++ b/engines/tinsel/dialogs.cpp
@@ -2303,7 +2303,7 @@ static void InvBoxes(bool InBody, int curX, int curY) {
cd.box[cd.pointBox].boxType == TOGGLE ||
cd.box[cd.pointBox].boxType == TOGGLE1 ||
cd.box[cd.pointBox].boxType == TOGGLE2) {
- pfilm = (const FILM *)LockMem(g_hWinParts);
+ pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
g_iconArray[HL1] = AddObject(&pfilm->reels[cd.box[cd.pointBox].bi+HIGRAPH], -1);
MultiSetAniXY(g_iconArray[HL1],
@@ -2314,7 +2314,7 @@ static void InvBoxes(bool InBody, int curX, int curY) {
if (g_bNoLanguage)
return;
- pfilm = (const FILM *)LockMem(g_hWinParts);
+ pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
rotateIndex = cd.box[cd.pointBox].bi;
if (rotateIndex == IX2_LEFT1) {
@@ -2345,10 +2345,10 @@ static void ButtonPress(CORO_PARAM, CONFBOX *box) {
assert(box->boxType == AAGBUT || box->boxType == ARSGBUT);
// Replace highlight image with normal image
- pfilm = (const FILM *)LockMem(g_hWinParts);
+ pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
if (g_iconArray[HL1] != NULL)
MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
- pfilm = (const FILM *)LockMem(g_hWinParts);
+ pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+NORMGRAPH], -1);
MultiSetAniXY(g_iconArray[HL1], g_InvD[g_ino].inventoryX + box->xpos, g_InvD[g_ino].inventoryY + box->ypos);
MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);
@@ -2359,7 +2359,7 @@ static void ButtonPress(CORO_PARAM, CONFBOX *box) {
return;
// Replace normal image with depresses image
- pfilm = (const FILM *)LockMem(g_hWinParts);
+ pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1);
MultiSetAniXY(g_iconArray[HL1], g_InvD[g_ino].inventoryX + box->xpos, g_InvD[g_ino].inventoryY + box->ypos);
@@ -2371,7 +2371,7 @@ static void ButtonPress(CORO_PARAM, CONFBOX *box) {
return;
// Replace depressed image with normal image
- pfilm = (const FILM *)LockMem(g_hWinParts);
+ pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+NORMGRAPH], -1);
MultiSetAniXY(g_iconArray[HL1], g_InvD[g_ino].inventoryX + box->xpos, g_InvD[g_ino].inventoryY + box->ypos);
@@ -2405,7 +2405,7 @@ static void ButtonToggle(CORO_PARAM, CONFBOX *box) {
return;
// Add depressed image
- pfilm = (const FILM *)LockMem(g_hWinParts);
+ pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1);
MultiSetAniXY(g_iconArray[HL1], g_InvD[g_ino].inventoryX + box->xpos, g_InvD[g_ino].inventoryY + box->ypos);
MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);
@@ -2424,7 +2424,7 @@ static void ButtonToggle(CORO_PARAM, CONFBOX *box) {
Select(cd.selBox, true);
// New state, depressed image
- pfilm = (const FILM *)LockMem(g_hWinParts);
+ pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
if (g_iconArray[HL1] != NULL)
MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1);
@@ -2446,7 +2446,7 @@ static void ButtonToggle(CORO_PARAM, CONFBOX *box) {
return;
// New state, highlighted
- pfilm = (const FILM *)LockMem(g_hWinParts);
+ pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
if (g_iconArray[HL1] != NULL)
MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+HIGRAPH], -1);
@@ -2812,7 +2812,7 @@ static void AddBox(int *pi, const int i) {
case AAGBUT:
case ARSGBUT:
- pFilm = (const FILM *)LockMem(g_hWinParts);
+ pFilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + NORMGRAPH], -1);
MultiSetAniXY(g_iconArray[*pi], x, y);
@@ -2824,7 +2824,7 @@ static void AddBox(int *pi, const int i) {
case FRGROUP:
assert(g_flagFilm != 0); // Language flags not declared!
- pFilm = (const FILM *)LockMem(g_flagFilm);
+ pFilm = (const FILM *)_vm->_handle->LockMem(g_flagFilm);
if (_vm->_config->_isAmericanEnglishVersion && cd.box[i].bi == FIX_UK)
cd.box[i].bi = FIX_USA;
@@ -2837,7 +2837,7 @@ static void AddBox(int *pi, const int i) {
break;
case FLIP:
- pFilm = (const FILM *)LockMem(g_hWinParts);
+ pFilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
if (*pival)
g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi], -1);
@@ -2864,7 +2864,7 @@ static void AddBox(int *pi, const int i) {
case TOGGLE:
case TOGGLE1:
case TOGGLE2:
- pFilm = (const FILM *)LockMem(g_hWinParts);
+ pFilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
cd.box[i].bi = *pival ? IX_TICK1 : IX_CROSS1;
g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + NORMGRAPH], -1);
@@ -2896,7 +2896,7 @@ static void AddBox(int *pi, const int i) {
break;
case SLIDER:
- pFilm = (const FILM *)LockMem(g_hWinParts);
+ pFilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
xdisp = SLIDE_RANGE*(*pival)/cd.box[i].w;
g_iconArray[*pi] = AddObject(&pFilm->reels[IX_MDGROOVE], -1);
@@ -2928,7 +2928,7 @@ static void AddBox(int *pi, const int i) {
break;
case ROTATE:
- pFilm = (const FILM *)LockMem(g_hWinParts);
+ pFilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
// Left one
if (!g_bNoLanguage) {
@@ -2964,7 +2964,7 @@ static void AddBox(int *pi, const int i) {
*pi += 1;
// Current language's flag
- pFilm = (const FILM *)LockMem(LanguageFlag(g_displayedLanguage));
+ pFilm = (const FILM *)_vm->_handle->LockMem(LanguageFlag(g_displayedLanguage));
g_iconArray[*pi] = AddObject(&pFilm->reels[0], -1);
MultiSetAniXY(g_iconArray[*pi], x + FLAGX, y + FLAGY);
MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);
@@ -3036,7 +3036,7 @@ static int AddExtraWindow(int x, int y, OBJECT **retObj) {
const FILM *pfilm;
// Get the frame's data
- pfilm = (const FILM *)LockMem(g_hWinParts);
+ pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
x += TinselV2 ? 30 : 20;
y += TinselV2 ? 38 : 24;
@@ -3137,7 +3137,7 @@ static void ConstructInventory(InventoryType filling) {
}
// Get the frame's data
- pfilm = (const FILM *)LockMem(g_hWinParts);
+ pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
// Standard window is of granular dimensions
if (filling == FULL) {
diff --git a/engines/tinsel/faders.cpp b/engines/tinsel/faders.cpp
index a518e9d065..db6b1bb302 100644
--- a/engines/tinsel/faders.cpp
+++ b/engines/tinsel/faders.cpp
@@ -106,7 +106,7 @@ static void FadeProcess(CORO_PARAM, const void *param) {
FadingPalette(pFade->pPalQ, true);
// get pointer to palette - reduce pointer indirection a bit
- _ctx->pPalette = (PALETTE *)LockMem(pFade->pPalQ->hPal);
+ _ctx->pPalette = (PALETTE *)_vm->_handle->LockMem(pFade->pPalQ->hPal);
for (_ctx->pColMult = pFade->pColorMultTable; *_ctx->pColMult >= 0; _ctx->pColMult++) {
// go through all multipliers in table - until a negative entry
diff --git a/engines/tinsel/font.cpp b/engines/tinsel/font.cpp
index c3a34bbf45..d7dee32f2e 100644
--- a/engines/tinsel/font.cpp
+++ b/engines/tinsel/font.cpp
@@ -50,15 +50,15 @@ void Font::FettleFontPal(SCNHANDLE fontPal) {
assert(_hTagFont); // Tag font not declared
assert(_hTalkFont); // Talk font not declared
- pFont = (const FONT *)LockMem(_hTagFont);
- pImg = (IMAGE *)LockMem(FROM_32(pFont->fontInit.hObjImg)); // get image for char 0
+ pFont = (const FONT *)_vm->_handle->LockMem(_hTagFont);
+ pImg = (IMAGE *)_vm->_handle->LockMem(FROM_32(pFont->fontInit.hObjImg)); // get image for char 0
if (!TinselV2)
pImg->hImgPal = TO_32(fontPal);
else
pImg->hImgPal = 0;
- pFont = (const FONT *)LockMem(_hTalkFont);
- pImg = (IMAGE *)LockMem(FROM_32(pFont->fontInit.hObjImg)); // get image for char 0
+ pFont = (const FONT *)_vm->_handle->LockMem(_hTalkFont);
+ pImg = (IMAGE *)_vm->_handle->LockMem(FROM_32(pFont->fontInit.hObjImg)); // get image for char 0
if (!TinselV2)
pImg->hImgPal = TO_32(fontPal);
else
diff --git a/engines/tinsel/graphics.cpp b/engines/tinsel/graphics.cpp
index fcd678a028..092376a29a 100644
--- a/engines/tinsel/graphics.cpp
+++ b/engines/tinsel/graphics.cpp
@@ -835,11 +835,11 @@ void DrawObject(DRAWOBJECT *pObj) {
// If writing constant data, don't bother locking the data pointer and reading src details
if ((pObj->flags & DMA_CONST) == 0) {
if (TinselV2) {
- srcPtr = (byte *)LockMem(pObj->hBits);
+ srcPtr = (byte *)_vm->_handle->LockMem(pObj->hBits);
pObj->charBase = nullptr;
pObj->transOffset = 0;
} else {
- byte *p = (byte *)LockMem(pObj->hBits & HANDLEMASK);
+ byte *p = (byte *)_vm->_handle->LockMem(pObj->hBits & HANDLEMASK);
srcPtr = p + (pObj->hBits & OFFSETMASK);
pObj->charBase = (char *)p + READ_LE_UINT32(p + 0x10);
diff --git a/engines/tinsel/handle.cpp b/engines/tinsel/handle.cpp
index 2f8e5775af..0c116e9d43 100644
--- a/engines/tinsel/handle.cpp
+++ b/engines/tinsel/handle.cpp
@@ -37,13 +37,6 @@
namespace Tinsel {
-//----------------- EXTERNAL GLOBAL DATA --------------------
-
-#ifdef DEBUG
-static uint32 s_lockedScene = 0;
-#endif
-
-
//----------------- LOCAL DEFINES --------------------
struct MEMHANDLE {
@@ -65,32 +58,11 @@ enum {
};
#define FSIZE_MASK 0x00FFFFFFL ///< mask to isolate the filesize
-//----------------- LOCAL GLOBAL DATA --------------------
-
-// FIXME: Avoid non-const global vars
-
-// handle table gets loaded from index file at runtime
-static MEMHANDLE *g_handleTable = 0;
-
-// number of handles in the handle table
-static uint g_numHandles = 0;
-
-static uint32 g_cdPlayHandle = (uint32)-1;
-
-static SCNHANDLE g_cdBaseHandle = 0, g_cdTopHandle = 0;
-static Common::File *g_cdGraphStream = 0;
-
-static char g_szCdPlayFile[100];
-
-//----------------- FORWARD REFERENCES --------------------
-
-static void LoadFile(MEMHANDLE *pH); // load a memory block as a file
-
/**
* Loads the graphics handle table index file and preloads all the
* permanent graphics etc.
*/
-void SetupHandleTable() {
+void Handle::SetupHandleTable() {
bool t2Flag = (TinselVersion == TINSEL_V2);
int RECORD_SIZE = t2Flag ? 24 : 20;
@@ -173,7 +145,7 @@ void SetupHandleTable() {
}
}
-void FreeHandleTable() {
+void Handle::FreeHandleTable() {
free(g_handleTable);
g_handleTable= nullptr;
@@ -184,7 +156,7 @@ void FreeHandleTable() {
/**
* Loads a memory block as a file.
*/
-void OpenCDGraphFile() {
+void Handle::OpenCDGraphFile() {
delete g_cdGraphStream;
// As the theory goes, the right CD will be in there!
@@ -194,7 +166,7 @@ void OpenCDGraphFile() {
error(CANNOT_FIND_FILE, g_szCdPlayFile);
}
-void LoadCDGraphData(MEMHANDLE *pH) {
+void Handle::LoadCDGraphData(MEMHANDLE *pH) {
// read the data
uint bytes;
byte *addr;
@@ -244,7 +216,7 @@ void LoadCDGraphData(MEMHANDLE *pH) {
* @param start Handle of start of range
* @param next Handle of end of range + 1
*/
-void LoadExtraGraphData(SCNHANDLE start, SCNHANDLE next) {
+void Handle::LoadExtraGraphData(SCNHANDLE start, SCNHANDLE next) {
OpenCDGraphFile();
MemoryDiscard((g_handleTable + g_cdPlayHandle)->_node); // Free it
@@ -257,11 +229,11 @@ void LoadExtraGraphData(SCNHANDLE start, SCNHANDLE next) {
g_cdTopHandle = next;
}
-void SetCdPlaySceneDetails(int fileNum, const char *fileName) {
+void Handle::SetCdPlaySceneDetails(int fileNum, const char *fileName) {
Common::strlcpy(g_szCdPlayFile, fileName, 100);
}
-void SetCdPlayHandle(int fileNum) {
+void Handle::SetCdPlayHandle(int fileNum) {
g_cdPlayHandle = fileNum;
}
@@ -270,7 +242,7 @@ void SetCdPlayHandle(int fileNum) {
* Loads a memory block as a file.
* @param pH Memory block pointer
*/
-void LoadFile(MEMHANDLE *pH) {
+void Handle::LoadFile(MEMHANDLE *pH) {
Common::File f;
char szFilename[sizeof(pH->szName) + 1];
@@ -320,7 +292,7 @@ void LoadFile(MEMHANDLE *pH) {
* Compute and return the address specified by a SCNHANDLE.
* @param offset Handle and offset to data
*/
-byte *LockMem(SCNHANDLE offset) {
+byte *Handle::LockMem(SCNHANDLE offset) {
uint32 handle = offset >> SCNHANDLE_SHIFT; // calc memory handle to use
//debug("Locking offset of type %d (%x), offset %d, handle %d", (offset & HANDLEMASK) >> SCNHANDLE_SHIFT, (offset & HANDLEMASK) >> SCNHANDLE_SHIFT, offset & OFFSETMASK, handle);
MEMHANDLE *pH; // points to table entry
@@ -328,11 +300,6 @@ byte *LockMem(SCNHANDLE offset) {
// range check the memory handle
assert(handle < g_numHandles);
-#ifdef DEBUG
- if (handle != s_lockedScene)
- warning(" Calling LockMem(0x%x), handle %d differs from active scene %d", offset, handle, s_lockedScene);
-#endif
-
pH = g_handleTable + handle;
if (pH->filesize & fPreload) {
@@ -380,15 +347,11 @@ byte *LockMem(SCNHANDLE offset) {
* Called to lock the current scene and make it non-discardable.
* @param offset Handle and offset to data
*/
-void LockScene(SCNHANDLE offset) {
+void Handle::LockScene(SCNHANDLE offset) {
uint32 handle = offset >> SCNHANDLE_SHIFT; // calc memory handle to use
MEMHANDLE *pH; // points to table entry
-#ifdef DEBUG
- assert(0 == s_lockedScene); // Trying to lock more than one scene
-#endif
-
// range check the memory handle
assert(handle < g_numHandles);
@@ -400,10 +363,6 @@ void LockScene(SCNHANDLE offset) {
// Now lock it to make sure it stays allocated and in a fixed position.
MemoryLock(pH->_node);
-
-#ifdef DEBUG
- s_lockedScene = handle;
-#endif
}
}
@@ -411,7 +370,7 @@ void LockScene(SCNHANDLE offset) {
* Called to make the current scene discardable again.
* @param offset Handle and offset to data
*/
-void UnlockScene(SCNHANDLE offset) {
+void Handle::UnlockScene(SCNHANDLE offset) {
uint32 handle = offset >> SCNHANDLE_SHIFT; // calc memory handle to use
MEMHANDLE *pH; // points to table entry
@@ -424,10 +383,6 @@ void UnlockScene(SCNHANDLE offset) {
if ((pH->filesize & fPreload) == 0) {
// unlock the scene data
MemoryUnlock(pH->_node);
-
-#ifdef DEBUG
- s_lockedScene = 0;
-#endif
}
}
@@ -439,7 +394,7 @@ void UnlockScene(SCNHANDLE offset) {
* Validates that a specified handle pointer is valid
* @param offset Handle and offset to data
*/
-bool ValidHandle(SCNHANDLE offset) {
+bool Handle::ValidHandle(SCNHANDLE offset) {
uint32 handle = offset >> SCNHANDLE_SHIFT; // calc memory handle to use
MEMHANDLE *pH; // points to table entry
@@ -456,7 +411,7 @@ bool ValidHandle(SCNHANDLE offset) {
* TouchMem
* @param offset Handle and offset to data
*/
-void TouchMem(SCNHANDLE offset) {
+void Handle::TouchMem(SCNHANDLE offset) {
MEMHANDLE *pH; // points to table entry
uint32 handle = offset >> SCNHANDLE_SHIFT; // calc memory handle to use
@@ -473,7 +428,7 @@ void TouchMem(SCNHANDLE offset) {
* Returns true if the given handle is into the cd graph data
* @param offset Handle and offset to data
*/
-bool IsCdPlayHandle(SCNHANDLE offset) {
+bool Handle::IsCdPlayHandle(SCNHANDLE offset) {
uint32 handle = offset >> SCNHANDLE_SHIFT; // calc memory handle to use
// range check the memory handle
@@ -485,7 +440,7 @@ bool IsCdPlayHandle(SCNHANDLE offset) {
/**
* Returns the CD for a given scene handle
*/
-int CdNumber(SCNHANDLE offset) {
+int Handle::CdNumber(SCNHANDLE offset) {
uint handle = offset >> SCNHANDLE_SHIFT; // calc memory handle to use
// range check the memory handle
diff --git a/engines/tinsel/handle.h b/engines/tinsel/handle.h
index ccc8f0f9db..3e1bcd290c 100644
--- a/engines/tinsel/handle.h
+++ b/engines/tinsel/handle.h
@@ -26,38 +26,67 @@
#include "tinsel/dw.h" // new data types
+namespace Common {
+class File;
+}
+
namespace Tinsel {
-/*----------------------------------------------------------------------*\
-|* Function Prototypes *|
-\*----------------------------------------------------------------------*/
+struct MEMHANDLE;
-/**
- * Loads the graphics handle table index file and preloads all the permanent graphics etc.
- */
-void SetupHandleTable();
-void FreeHandleTable();
+class Handle {
+public:
+ Handle() : g_handleTable(0), g_numHandles(0), g_cdPlayHandle((uint32)-1), g_cdBaseHandle(0), g_cdTopHandle(0), g_cdGraphStream(nullptr) {}
+
+ /**
+ * Loads the graphics handle table index file and preloads all the permanent graphics etc.
+ */
+ void SetupHandleTable();
+ void FreeHandleTable();
+
+ byte *LockMem(SCNHANDLE offset);
+
+ void LockScene(SCNHANDLE offset);
+ void UnlockScene(SCNHANDLE offset);
+
+ bool IsCdPlayHandle(SCNHANDLE offset);
+
+ void TouchMem(SCNHANDLE offset);
+
+ // Called at scene startup
+ void SetCdPlaySceneDetails(int sceneNum, const char *fileName);
+
+ // Called at game startup
+ void SetCdPlayHandle(int fileNum);
+
+ void LoadExtraGraphData(
+ SCNHANDLE start, // Handle of start of range
+ SCNHANDLE next); // Handle of end of range + 1
-byte *LockMem(SCNHANDLE offset);
+ int CdNumber(SCNHANDLE offset);
-void LockScene(SCNHANDLE offset);
-void UnlockScene(SCNHANDLE offset);
+#ifdef BODGE
+ bool ValidHandle(SCNHANDLE offset);
+#endif
-bool IsCdPlayHandle(SCNHANDLE offset);
+private:
+ void LoadFile(MEMHANDLE *pH); // load a memory block as a file
+ void OpenCDGraphFile();
+ void LoadCDGraphData(MEMHANDLE *pH);
-void TouchMem(SCNHANDLE offset);
+ // handle table gets loaded from index file at runtime
+ MEMHANDLE *g_handleTable;
-// Called at scene startup
-void SetCdPlaySceneDetails(int sceneNum, const char *fileName);
+ // number of handles in the handle table
+ uint g_numHandles;
-// Called at game startup
-void SetCdPlayHandle(int fileNum);
+ uint32 g_cdPlayHandle;
-void LoadExtraGraphData(
- SCNHANDLE start, // Handle of start of range
- SCNHANDLE next); // Handle of end of range + 1
+ SCNHANDLE g_cdBaseHandle, g_cdTopHandle;
+ Common::File *g_cdGraphStream;
-int CdNumber(SCNHANDLE offset);
+ char g_szCdPlayFile[100];
+};
} // End of namespace Tinsel
diff --git a/engines/tinsel/mareels.cpp b/engines/tinsel/mareels.cpp
index d906709f32..d996ee2d82 100644
--- a/engines/tinsel/mareels.cpp
+++ b/engines/tinsel/mareels.cpp
@@ -185,7 +185,7 @@ void TouchMoverReels() {
do {
for (scale = 0; scale < TOTAL_SCALES; scale++) {
- TouchMem(pMover->walkReels[scale][LEFTREEL]);
+ _vm->_handle->TouchMem(pMover->walkReels[scale][LEFTREEL]);
}
} while ((pMover = NextMover(pMover)) != NULL);
}
diff --git a/engines/tinsel/multiobj.cpp b/engines/tinsel/multiobj.cpp
index e35d282dec..3f57a6a67b 100644
--- a/engines/tinsel/multiobj.cpp
+++ b/engines/tinsel/multiobj.cpp
@@ -42,7 +42,7 @@ OBJECT *MultiInitObject(const MULTI_INIT *pInitTbl) {
if (FROM_32(pInitTbl->hMulFrame)) {
// we have a frame handle
- pFrame = (FRAME *)LockMem(FROM_32(pInitTbl->hMulFrame));
+ pFrame = (FRAME *)_vm->_handle->LockMem(FROM_32(pInitTbl->hMulFrame));
obj_init.hObjImg = READ_32(pFrame); // first objects shape
} else { // this must be a animation list for a NULL object
@@ -370,7 +370,7 @@ void MultiReshape(OBJECT *pMultiObj) {
// a valid shape frame which is different from previous
// get pointer to frame
- const FRAME *pFrame = (const FRAME *)LockMem(hFrame);
+ const FRAME *pFrame = (const FRAME *)_vm->_handle->LockMem(hFrame);
// update previous
pMultiObj->hMirror = hFrame;
diff --git a/engines/tinsel/music.cpp b/engines/tinsel/music.cpp
index 60a5dbe10a..623183ccb4 100644
--- a/engines/tinsel/music.cpp
+++ b/engines/tinsel/music.cpp
@@ -943,7 +943,7 @@ bool PCMMusicPlayer::getNextChunk() {
case S_NEXT:
_forcePlay = false;
- script = scriptBuffer = (int32 *)LockMem(_hScript);
+ script = scriptBuffer = (int32 *)_vm->_handle->LockMem(_hScript);
// Set parameters for this chunk of music
id = _scriptNum;
@@ -959,7 +959,7 @@ bool PCMMusicPlayer::getNextChunk() {
break;
}
- musicSegments = (MusicSegment *) LockMem(_hSegment);
+ musicSegments = (MusicSegment *)_vm->_handle->LockMem(_hSegment);
assert(FROM_32(musicSegments[snum].numChannels) == 1);
assert(FROM_32(musicSegments[snum].bitsPerSample) == 16);
@@ -999,7 +999,7 @@ bool PCMMusicPlayer::getNextChunk() {
debugC(DEBUG_DETAILED, kTinselDebugMusic, "Music reached state S_END1 (script %d.%d)",
_scriptNum, _scriptIndex);
- script = scriptBuffer = (int32 *) LockMem(_hScript);
+ script = scriptBuffer = (int32 *)_vm->_handle->LockMem(_hScript);
id = _scriptNum;
while (id--)
diff --git a/engines/tinsel/object.cpp b/engines/tinsel/object.cpp
index f8a62d0f21..9792c58c48 100644
--- a/engines/tinsel/object.cpp
+++ b/engines/tinsel/object.cpp
@@ -299,7 +299,7 @@ void SortObjectList(OBJECT **pObjList) {
*/
void GetAniOffset(SCNHANDLE hImg, int flags, int *pAniX, int *pAniY) {
if (hImg) {
- const IMAGE *pImg = (const IMAGE *)LockMem(hImg);
+ const IMAGE *pImg = (const IMAGE *)_vm->_handle->LockMem(hImg);
// set ani X
*pAniX = (int16) FROM_16(pImg->anioffX);
@@ -371,7 +371,7 @@ OBJECT *InitObject(const OBJ_INIT *pInitTbl) {
if (pInitTbl->hObjImg) {
int aniX, aniY; // objects animation offsets
PALQ *pPalQ= nullptr; // palette queue pointer
- const IMAGE *pImg = (const IMAGE *)LockMem(pInitTbl->hObjImg); // handle to image
+ const IMAGE *pImg = (const IMAGE *)_vm->_handle->LockMem(pInitTbl->hObjImg); // handle to image
if (pImg->hImgPal) {
// allocate a palette for this object
@@ -439,7 +439,7 @@ void AnimateObjectFlags(OBJECT *pAniObj, int newflags, SCNHANDLE hNewImg) {
if (hNewImg) {
// get pointer to image
- const IMAGE *pNewImg = (IMAGE *)LockMem(hNewImg);
+ const IMAGE *pNewImg = (IMAGE *)_vm->_handle->LockMem(hNewImg);
// setup new shape
pAniObj->width = FROM_16(pNewImg->imgWidth);
diff --git a/engines/tinsel/palette.cpp b/engines/tinsel/palette.cpp
index 495049d1a2..03a3028ad7 100644
--- a/engines/tinsel/palette.cpp
+++ b/engines/tinsel/palette.cpp
@@ -92,7 +92,7 @@ static int maxDACQ = 0;
* Map PSX palettes to original palette from resource file
*/
void psxPaletteMapper(PALQ *originalPal, uint8 *psxClut, byte *mapperTable) {
- PALETTE *pal = (PALETTE *)LockMem(originalPal->hPal);
+ PALETTE *pal = (PALETTE *)_vm->_handle->LockMem(originalPal->hPal);
bool colorFound = false;
uint16 clutEntry = 0;
@@ -152,7 +152,7 @@ void PalettesToVideoDAC() {
// we are using a palette handle
// get hardware palette pointer
- pPalette = (const PALETTE *)LockMem(pDACtail->pal.hRGBarray);
+ pPalette = (const PALETTE *)_vm->_handle->LockMem(pDACtail->pal.hRGBarray);
// get RGB pointer
pColors = pPalette->palRGB;
@@ -308,7 +308,7 @@ PALQ *AllocPalette(SCNHANDLE hNewPal) {
PALETTE *pNewPal;
// get pointer to new palette
- pNewPal = (PALETTE *)LockMem(hNewPal);
+ pNewPal = (PALETTE *)_vm->_handle->LockMem(hNewPal);
// search all structs in palette allocator - see if palette already allocated
for (p = g_palAllocData; p < g_palAllocData + NUM_PALETTES; p++) {
@@ -435,7 +435,7 @@ PALQ *FindPalette(SCNHANDLE hSrchPal) {
*/
void SwapPalette(PALQ *pPalQ, SCNHANDLE hNewPal) {
// convert handle to palette pointer
- PALETTE *pNewPal = (PALETTE *)LockMem(hNewPal);
+ PALETTE *pNewPal = (PALETTE *)_vm->_handle->LockMem(hNewPal);
// validate palette Q pointer
assert(pPalQ >= g_palAllocData && pPalQ <= g_palAllocData + NUM_PALETTES - 1);
@@ -551,7 +551,7 @@ void NoFadingPalettes() {
*/
void CreateTranslucentPalette(SCNHANDLE hPalette) {
// get a pointer to the palette
- PALETTE *pPal = (PALETTE *)LockMem(hPalette);
+ PALETTE *pPal = (PALETTE *)_vm->_handle->LockMem(hPalette);
// leave background color alone
g_transPalette[0] = 0;
@@ -611,7 +611,7 @@ void DimPartPalette(SCNHANDLE hDimPal, int startColor, int length, int brightnes
assert(pPalQ);
// get pointer to dim palette
- pDimPal = (PALETTE *)LockMem(hDimPal);
+ pDimPal = (PALETTE *)_vm->_handle->LockMem(hDimPal);
// Adjust for the fact that palettes don't contain color 0
startColor -= 1;
diff --git a/engines/tinsel/pcode.cpp b/engines/tinsel/pcode.cpp
index 71dff0f3b1..cdf8ec717b 100644
--- a/engines/tinsel/pcode.cpp
+++ b/engines/tinsel/pcode.cpp
@@ -242,11 +242,11 @@ void LockCode(INT_CONTEXT *ic) {
if (ic->GSort == GS_MASTER) {
if (TinselV2)
// Get the srcipt handle from a specific global chunk
- ic->code = (byte *)LockMem(g_hMasterScript);
+ ic->code = (byte *)_vm->_handle->LockMem(g_hMasterScript);
else
ic->code = (byte *)FindChunk(MASTER_SCNHANDLE, CHUNK_PCODE);
} else
- ic->code = (byte *)LockMem(ic->hCode);
+ ic->code = (byte *)_vm->_handle->LockMem(ic->hCode);
}
/**
diff --git a/engines/tinsel/play.cpp b/engines/tinsel/play.cpp
index 7829515baa..1191a0394c 100644
--- a/engines/tinsel/play.cpp
+++ b/engines/tinsel/play.cpp
@@ -78,10 +78,10 @@ static void PokeInPalette(SCNHANDLE hMulFrame) {
// Could be an empty column
if (hMulFrame) {
- pFrame = (const FRAME *)LockMem(hMulFrame);
+ pFrame = (const FRAME *)_vm->_handle->LockMem(hMulFrame);
// get pointer to image
- pim = (IMAGE *)LockMem(READ_32(pFrame)); // handle to image
+ pim = (IMAGE *)_vm->_handle->LockMem(READ_32(pFrame)); // handle to image
pim->hImgPal = TO_32(_vm->_bg->BgPal());
}
@@ -96,10 +96,10 @@ void PokeInPalette(const MULTI_INIT *pmi) {
// Could be an empty column
if (pmi->hMulFrame) {
- pFrame = (FRAME *)LockMem(FROM_32(pmi->hMulFrame));
+ pFrame = (FRAME *)_vm->_handle->LockMem(FROM_32(pmi->hMulFrame));
// get pointer to image
- pim = (IMAGE *)LockMem(READ_32(pFrame)); // handle to image
+ pim = (IMAGE *)_vm->_handle->LockMem(READ_32(pFrame)); // handle to image
pim->hImgPal = TO_32(_vm->_bg->BgPal());
}
@@ -138,7 +138,7 @@ int32 NoNameFunc(int actorID, bool bNewMover) {
}
static FREEL *GetReel(SCNHANDLE hFilm, int column) {
- FILM *pFilm = (FILM *)LockMem(hFilm);
+ FILM *pFilm = (FILM *)_vm->_handle->LockMem(hFilm);
return &pFilm->reels[column];
}
@@ -183,7 +183,7 @@ static void DeRegisterSoundReel(SCNHANDLE hFilm, int column) {
void SaveSoundReels(PSOUNDREELS psr) {
for (int i = 0; i < MAX_SOUNDREELS; i++) {
- if (IsCdPlayHandle(g_soundReels[i].hFilm))
+ if (_vm->_handle->IsCdPlayHandle(g_soundReels[i].hFilm))
g_soundReels[i].hFilm = 0;
}
@@ -237,7 +237,7 @@ static void SoundReel(CORO_PARAM, SCNHANDLE hFilm, int column, int speed,
PMULTI_INIT pmi; // MULTI_INIT structure
pReel = GetReel(hFilm, actorCol - 1);
- pmi = (PMULTI_INIT) LockMem(FROM_32(pReel->mobj));
+ pmi = (PMULTI_INIT)_vm->_handle->LockMem(FROM_32(pReel->mobj));
_ctx->reelActor = (int32)FROM_32(pmi->mulID);
} else
_ctx->reelActor = 0;
@@ -251,10 +251,10 @@ static void SoundReel(CORO_PARAM, SCNHANDLE hFilm, int column, int speed,
_ctx->myNum = g_soundReelNumbers[_ctx->myId];
do {
- pFilm = (FILM *)LockMem(hFilm);
+ pFilm = (FILM *)_vm->_handle->LockMem(hFilm);
pReel = &pFilm->reels[column];
- pAni = (ANI_SCRIPT *)LockMem(FROM_32(pReel->script));
+ pAni = (ANI_SCRIPT *)_vm->_handle->LockMem(FROM_32(pReel->script));
if (_ctx->speed == -1) {
_ctx->speed = (ONE_SECOND/FROM_32(pFilm->frate));
@@ -450,11 +450,11 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) {
_ctx->pActor= nullptr;
bNewMover = false;
- pfilm = (const FILM *)LockMem(ppi->hFilm);
+ pfilm = (const FILM *)_vm->_handle->LockMem(ppi->hFilm);
_ctx->pfreel = &pfilm->reels[ppi->column];
// Get the MULTI_INIT structure
- pmi = (const MULTI_INIT *)LockMem(FROM_32(_ctx->pfreel->mobj));
+ pmi = (const MULTI_INIT *)_vm->_handle->LockMem(FROM_32(_ctx->pfreel->mobj));
// Save actor's ID
_ctx->reelActor = (int32)FROM_32(pmi->mulID);
@@ -709,7 +709,7 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA
// Get the reel and MULTI_INIT structure
_ctx->pFreel = GetReel(hFilm, column);
- _ctx->pmi = (MULTI_INIT *)LockMem(FROM_32(_ctx->pFreel->mobj));
+ _ctx->pmi = (MULTI_INIT *)_vm->_handle->LockMem(FROM_32(_ctx->pFreel->mobj));
if ((int32)FROM_32(_ctx->pmi->mulID) == -2) {
CORO_INVOKE_ARGS(SoundReel, (CORO_SUBCTX, hFilm, column, speed, myescEvent,
@@ -955,7 +955,7 @@ void NewestFilm(SCNHANDLE film, const FREEL *reel) {
const MULTI_INIT *pmi; // MULTI_INIT structure
// Get the MULTI_INIT structure
- pmi = (const MULTI_INIT *)LockMem(FROM_32(reel->mobj));
+ pmi = (const MULTI_INIT *)_vm->_handle->LockMem(FROM_32(reel->mobj));
if (!TinselV2 || ((int32)FROM_32(pmi->mulID) != -2))
_vm->_actor->SetActorLatestFilm((int32)FROM_32(pmi->mulID), film);
@@ -979,7 +979,7 @@ void PlayFilm(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int actorid, bool splay
CORO_BEGIN_CODE(_ctx);
- pFilm = (const FILM *)LockMem(hFilm);
+ pFilm = (const FILM *)_vm->_handle->LockMem(hFilm);
PPINIT ppi;
// Now allowed empty films!
@@ -1041,7 +1041,7 @@ void PlayFilmc(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int actorid, bool spla
assert(hFilm != 0); // Trying to play NULL film
const FILM *pFilm;
- pFilm = (const FILM *)LockMem(hFilm);
+ pFilm = (const FILM *)_vm->_handle->LockMem(hFilm);
// Now allowed empty films!
if (pFilm->numreels == 0)
@@ -1105,7 +1105,7 @@ void PlayFilmc(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int actorid, bool spla
*/
void RestoreActorReels(SCNHANDLE hFilm, short reelnum, short z, int x, int y) {
assert(!TinselV2);
- const FILM *pfilm = (const FILM *)LockMem(hFilm);
+ const FILM *pfilm = (const FILM *)_vm->_handle->LockMem(hFilm);
PPINIT ppi;
ppi.hFilm = hFilm;
@@ -1139,7 +1139,7 @@ void RestoreActorReels(SCNHANDLE hFilm, short reelnum, short z, int x, int y) {
*/
void RestoreActorReels(SCNHANDLE hFilm, int actor, int x, int y) {
assert(TinselV2);
- FILM *pFilm = (FILM *)LockMem(hFilm);
+ FILM *pFilm = (FILM *)_vm->_handle->LockMem(hFilm);
PPINIT ppi;
int i;
@@ -1157,7 +1157,7 @@ void RestoreActorReels(SCNHANDLE hFilm, int actor, int x, int y) {
// Search backwards for now as later column will be the one
for (i = (int)FROM_32(pFilm->numreels) - 1; i >= 0; i--) {
pFreel = &pFilm->reels[i];
- pmi = (PMULTI_INIT) LockMem(FROM_32(pFreel->mobj));
+ pmi = (PMULTI_INIT)_vm->_handle->LockMem(FROM_32(pFreel->mobj));
if ((int32)FROM_32(pmi->mulID) == actor) {
ppi.column = (short)i;
NewestFilm(hFilm, &pFilm->reels[i]);
@@ -1174,9 +1174,9 @@ void RestoreActorReels(SCNHANDLE hFilm, int actor, int x, int y) {
* Get the actor id from a film (column 0)
*/
int ExtractActor(SCNHANDLE hFilm) {
- const FILM *pFilm = (const FILM *)LockMem(hFilm);
+ const FILM *pFilm = (const FILM *)_vm->_handle->LockMem(hFilm);
const FREEL *pReel = &pFilm->reels[0];
- const MULTI_INIT *pmi = (const MULTI_INIT *)LockMem(FROM_32(pReel->mobj));
+ const MULTI_INIT *pmi = (const MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pReel->mobj));
return (int)FROM_32(pmi->mulID);
}
diff --git a/engines/tinsel/polygons.cpp b/engines/tinsel/polygons.cpp
index cf1bec2067..d7efd91dab 100644
--- a/engines/tinsel/polygons.cpp
+++ b/engines/tinsel/polygons.cpp
@@ -585,7 +585,7 @@ void FindBestPoint(HPOLYGON hp, int *x, int *y, int *pline) {
pp = Polys[hp];
// Pointer to polygon data
- Poly ptp(LockMem(pHandle), pp->pIndex); // This polygon
+ Poly ptp(_vm->_handle->LockMem(pHandle), pp->pIndex); // This polygon
// Look for fit of perpendicular to lines between nodes
for (int i = 0; i < ptp.getNodecount() - 1; i++) {
@@ -824,7 +824,7 @@ int NearestEndNode(HPOLYGON hPath, int x, int y) {
CHECK_HP(hPath, "Out of range polygon handle (8)");
pp = Polys[hPath];
- Poly ptp(LockMem(pHandle), pp->pIndex); // This polygon
+ Poly ptp(_vm->_handle->LockMem(pHandle), pp->pIndex); // This polygon
const int nodecount = ptp.getNodecount() - 1;
@@ -851,7 +851,7 @@ int NearEndNode(HPOLYGON hSpath, HPOLYGON hDpath) {
pSpath = Polys[hSpath];
pDpath = Polys[hDpath];
- uint8 *pps = LockMem(pHandle); // All polygons
+ uint8 *pps = _vm->_handle->LockMem(pHandle); // All polygons
Poly ps(pps, pSpath->pIndex); // Start polygon
Poly pd(pps, pDpath->pIndex); // Dest polygon
@@ -894,7 +894,7 @@ int NearestNodeWithin(HPOLYGON hNpath, int x, int y) {
CHECK_HP(hNpath, "Out of range polygon handle (11)");
- Poly ptp(LockMem(pHandle), Polys[hNpath]->pIndex); // This polygon
+ Poly ptp(_vm->_handle->LockMem(pHandle), Polys[hNpath]->pIndex); // This polygon
const int numNodes = ptp.getNodecount(); // Number of nodes in this follow nodes path
@@ -991,7 +991,7 @@ int GetScale(HPOLYGON hPath, int y) {
CHECK_HP(hPath, "Out of range polygon handle (14)");
- Poly ptp(LockMem(pHandle), Polys[hPath]->pIndex);
+ Poly ptp(_vm->_handle->LockMem(pHandle), Polys[hPath]->pIndex);
// Path is of a constant scale?
if (FROM_32(ptp.scale2) == 0)
@@ -1030,7 +1030,7 @@ int GetBrightness(HPOLYGON hPath, int y) {
CHECK_HP(hPath, "Out of range polygon handle (38)");
- Poly ptp(LockMem(pHandle), Polys[hPath]->pIndex);
+ Poly ptp(_vm->_handle->LockMem(pHandle), Polys[hPath]->pIndex);
// Path is of a constant brightness?
if (FROM_32(ptp.bright1) == FROM_32(ptp.bright2))
@@ -1061,7 +1061,7 @@ void getNpathNode(HPOLYGON hNpath, int node, int *px, int *py) {
CHECK_HP(hNpath, "Out of range polygon handle (15)");
assert(Polys[hNpath] != NULL && Polys[hNpath]->polyType == PATH && Polys[hNpath]->subtype == NODE); // must be given a node path!
- Poly ptp(LockMem(pHandle), Polys[hNpath]->pIndex); // This polygon
+ Poly ptp(_vm->_handle->LockMem(pHandle), Polys[hNpath]->pIndex); // This polygon
// Might have just walked to the node from above.
if (node == ptp.getNodecount())
@@ -1077,7 +1077,7 @@ void getNpathNode(HPOLYGON hNpath, int node, int *px, int *py) {
void GetTagTag(HPOLYGON hp, SCNHANDLE *hTagText, int *tagx, int *tagy) {
CHECK_HP(hp, "Out of range polygon handle (16)");
- Poly ptp(LockMem(pHandle), Polys[hp]->pIndex);
+ Poly ptp(_vm->_handle->LockMem(pHandle), Polys[hp]->pIndex);
*tagx = (int)FROM_32(ptp.tagx) + (TinselV2 ? volatileStuff[hp].xoff : 0);
*tagy = (int)FROM_32(ptp.tagy) + (TinselV2 ? volatileStuff[hp].yoff : 0);
@@ -1090,7 +1090,7 @@ void GetTagTag(HPOLYGON hp, SCNHANDLE *hTagText, int *tagx, int *tagy) {
SCNHANDLE GetPolyFilm(HPOLYGON hp) {
CHECK_HP(hp, "Out of range polygon handle (17)");
- Poly ptp(LockMem(pHandle), Polys[hp]->pIndex);
+ Poly ptp(_vm->_handle->LockMem(pHandle), Polys[hp]->pIndex);
return FROM_32(ptp.hFilm);
}
@@ -1101,7 +1101,7 @@ SCNHANDLE GetPolyFilm(HPOLYGON hp) {
SCNHANDLE GetPolyScript(HPOLYGON hp) {
CHECK_HP(hp, "Out of range polygon handle (19)");
- Poly ptp(LockMem(pHandle), Polys[hp]->pIndex);
+ Poly ptp(_vm->_handle->LockMem(pHandle), Polys[hp]->pIndex);
return FROM_32(ptp.hScript);
}
@@ -1113,7 +1113,7 @@ REEL GetPolyReelType(HPOLYGON hp) {
CHECK_HP(hp, "Out of range polygon handle (20)");
- Poly ptp(LockMem(pHandle), Polys[hp]->pIndex);
+ Poly ptp(_vm->_handle->LockMem(pHandle), Polys[hp]->pIndex);
return (REEL)FROM_32(ptp.reel);
}
@@ -1122,7 +1122,7 @@ int32 GetPolyZfactor(HPOLYGON hp) {
CHECK_HP(hp, "Out of range polygon handle (21)");
assert(Polys[hp] != NULL);
- Poly ptp(LockMem(pHandle), Polys[hp]->pIndex);
+ Poly ptp(_vm->_handle->LockMem(pHandle), Polys[hp]->pIndex);
return (int)FROM_32(ptp.zFactor);
}
@@ -1131,7 +1131,7 @@ int numNodes(HPOLYGON hp) {
CHECK_HP(hp, "Out of range polygon handle (22)");
assert(Polys[hp] != NULL);
- Poly ptp(LockMem(pHandle), Polys[hp]->pIndex);
+ Poly ptp(_vm->_handle->LockMem(pHandle), Polys[hp]->pIndex);
return ptp.getNodecount();
}
@@ -1315,7 +1315,7 @@ static int DistinctCorners(HPOLYGON hp1, HPOLYGON hp2) {
* Returns true if the two paths are on the same level
*/
static bool MatchingLevels(PPOLYGON p1, PPOLYGON p2) {
- byte *pps = LockMem(pHandle); // All polygons
+ byte *pps = _vm->_handle->LockMem(pHandle); // All polygons
Poly pp1(pps, p1->pIndex); // This polygon 1
Poly pp2(pps, p2->pIndex); // This polygon 2
@@ -1817,7 +1817,7 @@ void InitPolygons(SCNHANDLE ph, int numPoly, bool bRestart) {
}
if (numPoly > 0) {
- Poly ptp(LockMem(ph));
+ Poly ptp(_vm->_handle->LockMem(ph));
for (int i = 0; i < numPoly; ++i, ++ptp) {
switch (ptp.getType()) {
@@ -1983,7 +1983,7 @@ void MaxPolygons(int numPolys) {
void GetPolyNode(HPOLYGON hp, int *pNodeX, int *pNodeY) {
CHECK_HP(hp, "GetPolyNode(): Out of range polygon handle");
- Poly ptp(LockMem(pHandle), Polys[hp]->pIndex);
+ Poly ptp(_vm->_handle->LockMem(pHandle), Polys[hp]->pIndex);
// WORKAROUND: Invalid node adjustment for DW2 Cartwheel scene refer polygon
if (TinselV2 && (pHandle == 0x74191900) && (hp == 8)) {
diff --git a/engines/tinsel/rince.cpp b/engines/tinsel/rince.cpp
index 3618f73417..c11e8e11c8 100644
--- a/engines/tinsel/rince.cpp
+++ b/engines/tinsel/rince.cpp
@@ -549,7 +549,7 @@ void AlterMover(PMOVER pMover, SCNHANDLE film, AR_FUNCTION fn) {
// Remember this one in case the actor talks
pMover->hLastFilm = film;
- pfilm = (const FILM *)LockMem(film);
+ pfilm = (const FILM *)_vm->_handle->LockMem(film);
assert(pfilm != NULL);
InitStepAnimScript(&pMover->actorAnim, pMover->actorObj, FROM_32(pfilm->reels[0].script), ONE_SECOND / FROM_32(pfilm->frate));
@@ -642,7 +642,7 @@ void SetMoverWalkReel(PMOVER pMover, DIRECTION reel, int scale, bool force) {
assert(whichReel); // no reel
}
- pfilm = (const FILM *)LockMem(whichReel);
+ pfilm = (const FILM *)_vm->_handle->LockMem(whichReel);
assert(pfilm != NULL); // no film
InitStepAnimScript(&pMover->actorAnim, pMover->actorObj, FROM_32(pfilm->reels[0].script), 1);
@@ -705,14 +705,14 @@ static void MoverProcessHelper(int X, int Y, int id, PMOVER pMover) {
InitMover(pMover);
InitialPathChecks(pMover, X, Y);
- pfilm = (const FILM *)LockMem(pMover->walkReels[0][FORWARD]);
- pmi = (const MULTI_INIT *)LockMem(FROM_32(pfilm->reels[0].mobj));
+ pfilm = (const FILM *)_vm->_handle->LockMem(pMover->walkReels[0][FORWARD]);
+ pmi = (const MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pfilm->reels[0].mobj));
//---
- pFrame = (const FRAME *)LockMem(FROM_32(pmi->hMulFrame));
+ pFrame = (const FRAME *)_vm->_handle->LockMem(FROM_32(pmi->hMulFrame));
// get pointer to image
- pim = (IMAGE *)LockMem(READ_32(pFrame)); // handle to image
+ pim = (IMAGE *)_vm->_handle->LockMem(READ_32(pFrame)); // handle to image
pim->hImgPal = TO_32(_vm->_bg->BgPal());
//---
pMover->actorObj = MultiInitObject(pmi);
@@ -803,8 +803,8 @@ void T2MoverProcess(CORO_PARAM, const void *param) {
InitMover(pMover);
InitialPathChecks(pMover, rpos->X, rpos->Y);
- pFilm = (FILM *)LockMem(pMover->walkReels[i][FORWARD]); // Any old reel
- pmi = (PMULTI_INIT)LockMem(FROM_32(pFilm->reels[0].mobj));
+ pFilm = (FILM *)_vm->_handle->LockMem(pMover->walkReels[i][FORWARD]); // Any old reel
+ pmi = (PMULTI_INIT)_vm->_handle->LockMem(FROM_32(pFilm->reels[0].mobj));
// Poke in the background palette
PokeInPalette(pmi);
diff --git a/engines/tinsel/scene.cpp b/engines/tinsel/scene.cpp
index 1aef8d4754..48bbb62163 100644
--- a/engines/tinsel/scene.cpp
+++ b/engines/tinsel/scene.cpp
@@ -214,8 +214,8 @@ static void LoadScene(SCNHANDLE scene, int entry) {
// Scene handle
g_SceneHandle = scene; // Save scene handle in case of Save_Scene()
- LockMem(g_SceneHandle); // Make sure scene is loaded
- LockScene(g_SceneHandle); // Prevent current scene from being discarded
+ _vm->_handle->LockMem(g_SceneHandle); // Make sure scene is loaded
+ _vm->_handle->LockScene(g_SceneHandle); // Prevent current scene from being discarded
if (TinselV2) {
// CdPlay() stuff
@@ -225,7 +225,7 @@ static void LoadScene(SCNHANDLE scene, int entry) {
assert(i < 512);
cptr = FindChunk(scene, CHUNK_CDPLAY_FILENAME);
assert(cptr);
- SetCdPlaySceneDetails(i, (const char *)cptr);
+ _vm->_handle->SetCdPlaySceneDetails(i, (const char *)cptr);
}
// Find scene structure
@@ -262,7 +262,7 @@ static void LoadScene(SCNHANDLE scene, int entry) {
_vm->_actor->StartTaggedActors(FROM_32(ss->hTaggedActor), FROM_32(ss->numTaggedActor), true);
// Run the appropriate entrance code (if any)
- es = (const ENTRANCE_STRUC *)LockMem(FROM_32(ss->hEntrance));
+ es = (const ENTRANCE_STRUC *)_vm->_handle->LockMem(FROM_32(ss->hEntrance));
for (i = 0; i < FROM_32(ss->numEntrance); i++) {
if (FROM_32(es->eNumber) == (uint)entry) {
if (es->hScript) {
@@ -306,7 +306,7 @@ static void LoadScene(SCNHANDLE scene, int entry) {
*/
void EndScene() {
if (g_SceneHandle != 0) {
- UnlockScene(g_SceneHandle);
+ _vm->_handle->UnlockScene(g_SceneHandle);
g_SceneHandle = 0;
}
@@ -382,7 +382,7 @@ void StartNewScene(SCNHANDLE scene, int entry) {
if (TinselV2) {
TouchMoverReels();
- LockMem(scene); // Do CD change before PrimeScene
+ _vm->_handle->LockMem(scene); // Do CD change before PrimeScene
}
PrimeScene(); // Start up the standard stuff for the next scene.
diff --git a/engines/tinsel/sched.cpp b/engines/tinsel/sched.cpp
index edc10075cb..59de7ed476 100644
--- a/engines/tinsel/sched.cpp
+++ b/engines/tinsel/sched.cpp
@@ -107,7 +107,7 @@ void RestoreSceneProcess(INT_CONTEXT *pic) {
uint32 i;
PROCESS_STRUC *pStruc;
- pStruc = (PROCESS_STRUC *)LockMem(g_hSceneProcess);
+ pStruc = (PROCESS_STRUC *)_vm->_handle->LockMem(g_hSceneProcess);
for (i = 0; i < g_numSceneProcess; i++) {
if (FROM_32(pStruc[i].hProcessCode) == pic->hCode) {
CoroScheduler.createProcess(PID_PROCESS + i, RestoredProcessProcess,
@@ -135,7 +135,7 @@ void SceneProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWait
CORO_BEGIN_CODE(_ctx);
- _ctx->pStruc = (PROCESS_STRUC *)LockMem(g_hSceneProcess);
+ _ctx->pStruc = (PROCESS_STRUC *)_vm->_handle->LockMem(g_hSceneProcess);
for (i = 0; i < g_numSceneProcess; i++) {
if (FROM_32(_ctx->pStruc[i].processId) == procID) {
assert(_ctx->pStruc[i].hProcessCode); // Must have some code to run
@@ -174,7 +174,7 @@ void KillSceneProcess(uint32 procID) {
uint32 i; // Loop counter
PROCESS_STRUC *pStruc;
- pStruc = (PROCESS_STRUC *) LockMem(g_hSceneProcess);
+ pStruc = (PROCESS_STRUC *)_vm->_handle->LockMem(g_hSceneProcess);
for (i = 0; i < g_numSceneProcess; i++) {
if (FROM_32(pStruc[i].processId) == procID) {
CoroScheduler.killMatchingProcess(PID_PROCESS + i, -1);
diff --git a/engines/tinsel/scn.cpp b/engines/tinsel/scn.cpp
index db14af27e2..54c53c97bb 100644
--- a/engines/tinsel/scn.cpp
+++ b/engines/tinsel/scn.cpp
@@ -37,7 +37,7 @@ namespace Tinsel {
* @param chunk Chunk Id
*/
byte *FindChunk(SCNHANDLE handle, uint32 chunk) {
- byte *bptr = LockMem(handle);
+ byte *bptr = _vm->_handle->LockMem(handle);
uint32 *lptr = (uint32 *)bptr;
uint32 add;
diff --git a/engines/tinsel/text.cpp b/engines/tinsel/text.cpp
index c741d0809f..02ddc9272e 100644
--- a/engines/tinsel/text.cpp
+++ b/engines/tinsel/text.cpp
@@ -50,7 +50,7 @@ int StringLengthPix(char *szStr, const FONT *pFont) {
if (hImg) {
// there is a IMAGE for this character
- const IMAGE *pChar = (const IMAGE *)LockMem(hImg);
+ const IMAGE *pChar = (const IMAGE *)_vm->_handle->LockMem(hImg);
// add width of font bitmap
strLen += FROM_16(pChar->imgWidth);
@@ -118,14 +118,14 @@ OBJECT *ObjectTextOut(OBJECT **pList, char *szStr, int color,
assert(pList);
// get font pointer
- const FONT *pFont = (const FONT *)LockMem(hFont);
+ const FONT *pFont = (const FONT *)_vm->_handle->LockMem(hFont);
// init head of text list
pFirst = nullptr;
// get image for capital W
assert(pFont->fontDef[(int)'W']);
- pImg = (const IMAGE *)LockMem(FROM_32(pFont->fontDef[(int)'W']));
+ pImg = (const IMAGE *)_vm->_handle->LockMem(FROM_32(pFont->fontDef[(int)'W']));
// get height of capital W for offset to next line
yOffset = FROM_16(pImg->imgHeight) & ~C16_FLAG_MASK;
@@ -168,7 +168,7 @@ OBJECT *ObjectTextOut(OBJECT **pList, char *szStr, int color,
pChar = pChar->pSlave = InitObject(&oi); // FIXME: endian issue using fontInit!!!
// convert image handle to pointer
- pImg = (const IMAGE *)LockMem(hImg);
+ pImg = (const IMAGE *)_vm->_handle->LockMem(hImg);
// fill in character object
pChar->hImg = hImg; // image def
@@ -269,7 +269,7 @@ bool IsCharImage(SCNHANDLE hFont, char c) {
return false;
// get font pointer
- const FONT *pFont = (const FONT *)LockMem(hFont);
+ const FONT *pFont = (const FONT *)_vm->_handle->LockMem(hFont);
return pFont->fontDef[c2] != 0;
}
diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp
index 12a1f972f0..e364b1e24e 100644
--- a/engines/tinsel/tinlib.cpp
+++ b/engines/tinsel/tinlib.cpp
@@ -108,9 +108,6 @@ extern void SuspendHook();
extern void UnSuspendHook();
#ifdef BODGE
-// In HANDLE.CPP
-bool ValidHandle(SCNHANDLE offset);
-
// In SCENE.CPP
SCNHANDLE GetSceneHandle();
#endif
@@ -710,7 +707,7 @@ static void CDload(SCNHANDLE start, SCNHANDLE next, int myEscape) {
return;
}
- LoadExtraGraphData(start, next);
+ _vm->_handle->LoadExtraGraphData(start, next);
}
}
@@ -1843,7 +1840,7 @@ static void PostTag(CORO_PARAM, int tagno, TINSEL_EVENT event, HPOLYGON hp, int
*/
static void PrepareScene(SCNHANDLE scene) {
#ifdef BODGE
- if (!ValidHandle(scene))
+ if (!_vm->_handle->ValidHandle(scene))
return;
#endif
}
@@ -4869,7 +4866,7 @@ int CallLibraryRoutine(CORO_PARAM, int operand, int32 *pp, const INT_CONTEXT *pi
// Common to both DW1 & DW2
if (TinselV2) {
pp -= 3; // 4 parameters
- if (*pResumeState == RES_1 && IsCdPlayHandle(pp[0]))
+ if (*pResumeState == RES_1 && _vm->_handle->IsCdPlayHandle(pp[0]))
*pResumeState = RES_NOT;
else {
Play(coroParam, pp[0], pp[1], pp[2], pp[3], pic->myEscape, false,
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index d1d02c65a8..8418dff4d3 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -473,14 +473,14 @@ void SetNewScene(SCNHANDLE scene, int entrance, int transition) {
}
// If CD change will be required, stick in the scene change scene
- if (CdNumber(scene) != GetCurrentCD()) {
+ if (_vm->_handle->CdNumber(scene) != GetCurrentCD()) {
// This scene gets delayed
g_DelayedScene.scene = scene;
g_DelayedScene.entry = entrance;
g_DelayedScene.trans = transition;
g_NextScene.scene = g_hCdChangeScene;
- g_NextScene.entry = CdNumber(scene) - '0';
+ g_NextScene.entry = _vm->_handle->CdNumber(scene) - '0';
g_NextScene.trans = TRANS_FADE;
return;
@@ -753,7 +753,7 @@ void LoadBasicChunks() {
assert(cptr);
uint32 playHandle = READ_32(cptr);
assert(playHandle < 512);
- SetCdPlayHandle(playHandle);
+ _vm->_handle->SetCdPlayHandle(playHandle);
}
}
@@ -860,12 +860,13 @@ TinselEngine::~TinselEngine() {
_screenSurface.free();
FreeSaveScenes();
FreeTextBuffer();
- FreeHandleTable();
+ _handle->FreeHandleTable();
_actor->FreeActors();
FreeObjectList();
FreeGlobalProcesses();
FreeGlobals();
+ delete _handle;
delete _actor;
delete _config;
@@ -900,6 +901,7 @@ Common::Error TinselEngine::run() {
_bg = new Background(_font);
_cursor = new Cursor();
_actor = new Actor();
+ _handle = new Handle();
// Initialize backend
if (getGameID() == GID_DW2) {
@@ -948,7 +950,7 @@ Common::Error TinselEngine::run() {
RestartDrivers();
// load in graphics info
- SetupHandleTable();
+ _vm->_handle->SetupHandleTable();
// Actors, globals and inventory icons
LoadBasicChunks();
diff --git a/engines/tinsel/tinsel.h b/engines/tinsel/tinsel.h
index 89e6072c05..c87496b562 100644
--- a/engines/tinsel/tinsel.h
+++ b/engines/tinsel/tinsel.h
@@ -62,6 +62,7 @@ class Background;
class Font;
class Cursor;
class Actor;
+class Handle;
typedef Common::List<Common::Rect> RectList;
@@ -170,7 +171,7 @@ public:
Font *_font;
Cursor *_cursor;
Actor *_actor;
-
+ Handle *_handle;
Config *_config;
KEYFPTR _keyHandler;
Commit: 5bb033238387e019e4d1e0d3cd6f8dfcbd96b672
https://github.com/scummvm/scummvm/commit/5bb033238387e019e4d1e0d3cd6f8dfcbd96b672
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-10-04T01:15:20+03:00
Commit Message:
TINSEL: Rename variables in the Handle class
Changed paths:
engines/tinsel/handle.cpp
engines/tinsel/handle.h
engines/tinsel/scene.cpp
diff --git a/engines/tinsel/handle.cpp b/engines/tinsel/handle.cpp
index 0c116e9d43..da0eb1d48d 100644
--- a/engines/tinsel/handle.cpp
+++ b/engines/tinsel/handle.cpp
@@ -84,24 +84,24 @@ void Handle::SetupHandleTable() {
}
// calc number of handles
- g_numHandles = len / RECORD_SIZE;
+ _numHandles = len / RECORD_SIZE;
// allocate memory for the index file
- g_handleTable = (MEMHANDLE *)calloc(g_numHandles, sizeof(struct MEMHANDLE));
+ _handleTable = (MEMHANDLE *)calloc(_numHandles, sizeof(struct MEMHANDLE));
// make sure memory allocated
- assert(g_handleTable);
+ assert(_handleTable);
// load data
- for (i = 0; i < g_numHandles; i++) {
- f.read(g_handleTable[i].szName, 12);
- g_handleTable[i].filesize = f.readUint32();
+ for (i = 0; i < _numHandles; i++) {
+ f.read(_handleTable[i].szName, 12);
+ _handleTable[i].filesize = f.readUint32();
// The pointer should always be NULL. We don't
// need to read that from the file.
- g_handleTable[i]._node= nullptr;
+ _handleTable[i]._node= nullptr;
f.seek(4, SEEK_CUR);
// For Discworld 2, read in the flags2 field
- g_handleTable[i].flags2 = t2Flag ? f.readUint32() : 0;
+ _handleTable[i].flags2 = t2Flag ? f.readUint32() : 0;
}
if (f.eos() || f.err()) {
@@ -119,7 +119,7 @@ void Handle::SetupHandleTable() {
}
// allocate memory nodes and load all permanent graphics
- for (i = 0, pH = g_handleTable; i < g_numHandles; i++, pH++) {
+ for (i = 0, pH = _handleTable; i < _numHandles; i++, pH++) {
if (pH->filesize & fPreload) {
// allocate a fixed memory node for permanent files
pH->_node = MemoryAllocFixed((pH->filesize & FSIZE_MASK));
@@ -146,24 +146,24 @@ void Handle::SetupHandleTable() {
}
void Handle::FreeHandleTable() {
- free(g_handleTable);
- g_handleTable= nullptr;
+ free(_handleTable);
+ _handleTable= nullptr;
- delete g_cdGraphStream;
- g_cdGraphStream= nullptr;
+ delete _cdGraphStream;
+ _cdGraphStream= nullptr;
}
/**
* Loads a memory block as a file.
*/
void Handle::OpenCDGraphFile() {
- delete g_cdGraphStream;
+ delete _cdGraphStream;
// As the theory goes, the right CD will be in there!
- g_cdGraphStream = new Common::File;
- if (!g_cdGraphStream->open(g_szCdPlayFile))
- error(CANNOT_FIND_FILE, g_szCdPlayFile);
+ _cdGraphStream = new Common::File;
+ if (!_cdGraphStream->open(_szCdPlayFile))
+ error(CANNOT_FIND_FILE, _szCdPlayFile.c_str());
}
void Handle::LoadCDGraphData(MEMHANDLE *pH) {
@@ -184,15 +184,15 @@ void Handle::LoadCDGraphData(MEMHANDLE *pH) {
assert(addr);
// Move to correct place in file and load the required data
- assert(g_cdGraphStream);
- g_cdGraphStream->seek(g_cdBaseHandle & OFFSETMASK, SEEK_SET);
- bytes = g_cdGraphStream->read(addr, (g_cdTopHandle - g_cdBaseHandle) & OFFSETMASK);
+ assert(_cdGraphStream);
+ _cdGraphStream->seek(_cdBaseHandle & OFFSETMASK, SEEK_SET);
+ bytes = _cdGraphStream->read(addr, (_cdTopHandle - _cdBaseHandle) & OFFSETMASK);
// New code to try and handle CD read failures 24/2/97
- while (bytes != ((g_cdTopHandle - g_cdBaseHandle) & OFFSETMASK) && retries++ < MAX_READ_RETRIES) {
+ while (bytes != ((_cdTopHandle - _cdBaseHandle) & OFFSETMASK) && retries++ < MAX_READ_RETRIES) {
// Try again
- g_cdGraphStream->seek(g_cdBaseHandle & OFFSETMASK, SEEK_SET);
- bytes = g_cdGraphStream->read(addr, (g_cdTopHandle - g_cdBaseHandle) & OFFSETMASK);
+ _cdGraphStream->seek(_cdBaseHandle & OFFSETMASK, SEEK_SET);
+ bytes = _cdGraphStream->read(addr, (_cdTopHandle - _cdBaseHandle) & OFFSETMASK);
}
// discardable - unlock the memory
@@ -204,7 +204,7 @@ void Handle::LoadCDGraphData(MEMHANDLE *pH) {
// clear the loading flag
// pH->filesize &= ~fLoading;
- if (bytes != ((g_cdTopHandle - g_cdBaseHandle) & OFFSETMASK))
+ if (bytes != ((_cdTopHandle - _cdBaseHandle) & OFFSETMASK))
// file is corrupt
error(FILE_READ_ERROR, "CD play file");
}
@@ -219,25 +219,24 @@ void Handle::LoadCDGraphData(MEMHANDLE *pH) {
void Handle::LoadExtraGraphData(SCNHANDLE start, SCNHANDLE next) {
OpenCDGraphFile();
- MemoryDiscard((g_handleTable + g_cdPlayHandle)->_node); // Free it
+ MemoryDiscard((_handleTable + _cdPlayHandle)->_node); // Free it
// It must always be the same
- assert(g_cdPlayHandle == (start >> SCNHANDLE_SHIFT));
- assert(g_cdPlayHandle == (next >> SCNHANDLE_SHIFT));
+ assert(_cdPlayHandle == (start >> SCNHANDLE_SHIFT));
+ assert(_cdPlayHandle == (next >> SCNHANDLE_SHIFT));
- g_cdBaseHandle = start;
- g_cdTopHandle = next;
+ _cdBaseHandle = start;
+ _cdTopHandle = next;
}
-void Handle::SetCdPlaySceneDetails(int fileNum, const char *fileName) {
- Common::strlcpy(g_szCdPlayFile, fileName, 100);
+void Handle::SetCdPlaySceneDetails(const char *fileName) {
+ _szCdPlayFile = fileName;
}
void Handle::SetCdPlayHandle(int fileNum) {
- g_cdPlayHandle = fileNum;
+ _cdPlayHandle = fileNum;
}
-
/**
* Loads a memory block as a file.
* @param pH Memory block pointer
@@ -298,21 +297,21 @@ byte *Handle::LockMem(SCNHANDLE offset) {
MEMHANDLE *pH; // points to table entry
// range check the memory handle
- assert(handle < g_numHandles);
+ assert(handle < _numHandles);
- pH = g_handleTable + handle;
+ pH = _handleTable + handle;
if (pH->filesize & fPreload) {
// permanent files are already loaded, nothing to be done
- } else if (handle == g_cdPlayHandle) {
+ } else if (handle == _cdPlayHandle) {
// Must be in currently loaded/loadable range
- if (offset < g_cdBaseHandle || offset >= g_cdTopHandle)
+ if (offset < _cdBaseHandle || offset >= _cdTopHandle)
error("Overlapping (in time) CD-plays");
// May have been discarded, if so, we have to reload
if (!MemoryDeref(pH->_node)) {
// Data was discarded, we have to reload
- MemoryReAlloc(pH->_node, g_cdTopHandle - g_cdBaseHandle);
+ MemoryReAlloc(pH->_node, _cdTopHandle - _cdBaseHandle);
LoadCDGraphData(pH);
@@ -323,7 +322,7 @@ byte *Handle::LockMem(SCNHANDLE offset) {
// make sure address is valid
assert(pH->filesize & fLoaded);
- offset -= g_cdBaseHandle;
+ offset -= _cdBaseHandle;
} else {
if (!MemoryDeref(pH->_node)) {
// Data was discarded, we have to reload
@@ -353,9 +352,9 @@ void Handle::LockScene(SCNHANDLE offset) {
MEMHANDLE *pH; // points to table entry
// range check the memory handle
- assert(handle < g_numHandles);
+ assert(handle < _numHandles);
- pH = g_handleTable + handle;
+ pH = _handleTable + handle;
if ((pH->filesize & fPreload) == 0) {
// Ensure the scene handle is allocated.
@@ -376,9 +375,9 @@ void Handle::UnlockScene(SCNHANDLE offset) {
MEMHANDLE *pH; // points to table entry
// range check the memory handle
- assert(handle < g_numHandles);
+ assert(handle < _numHandles);
- pH = g_handleTable + handle;
+ pH = _handleTable + handle;
if ((pH->filesize & fPreload) == 0) {
// unlock the scene data
@@ -399,9 +398,9 @@ bool Handle::ValidHandle(SCNHANDLE offset) {
MEMHANDLE *pH; // points to table entry
// range check the memory handle
- assert(handle < g_numHandles);
+ assert(handle < _numHandles);
- pH = g_handleTable + handle;
+ pH = _handleTable + handle;
return (pH->filesize & FSIZE_MASK) != 8;
}
@@ -416,7 +415,7 @@ void Handle::TouchMem(SCNHANDLE offset) {
uint32 handle = offset >> SCNHANDLE_SHIFT; // calc memory handle to use
if (offset != 0) {
- pH = g_handleTable + handle;
+ pH = _handleTable + handle;
// update the LRU time whether its loaded or not!
if (pH->_node)
@@ -432,9 +431,9 @@ bool Handle::IsCdPlayHandle(SCNHANDLE offset) {
uint32 handle = offset >> SCNHANDLE_SHIFT; // calc memory handle to use
// range check the memory handle
- assert(handle < g_numHandles);
+ assert(handle < _numHandles);
- return (handle == g_cdPlayHandle);
+ return (handle == _cdPlayHandle);
}
/**
@@ -444,9 +443,9 @@ int Handle::CdNumber(SCNHANDLE offset) {
uint handle = offset >> SCNHANDLE_SHIFT; // calc memory handle to use
// range check the memory handle
- assert(handle < g_numHandles);
+ assert(handle < _numHandles);
- MEMHANDLE *pH = g_handleTable + handle;
+ MEMHANDLE *pH = _handleTable + handle;
if (!TinselV2)
return 1;
diff --git a/engines/tinsel/handle.h b/engines/tinsel/handle.h
index 3e1bcd290c..213e10c47c 100644
--- a/engines/tinsel/handle.h
+++ b/engines/tinsel/handle.h
@@ -24,6 +24,7 @@
#ifndef TINSEL_HANDLE_H
#define TINSEL_HANDLE_H
+#include "common/str.h"
#include "tinsel/dw.h" // new data types
namespace Common {
@@ -36,7 +37,7 @@ struct MEMHANDLE;
class Handle {
public:
- Handle() : g_handleTable(0), g_numHandles(0), g_cdPlayHandle((uint32)-1), g_cdBaseHandle(0), g_cdTopHandle(0), g_cdGraphStream(nullptr) {}
+ Handle() : _handleTable(0), _numHandles(0), _cdPlayHandle((uint32)-1), _cdBaseHandle(0), _cdTopHandle(0), _cdGraphStream(nullptr) {}
/**
* Loads the graphics handle table index file and preloads all the permanent graphics etc.
@@ -54,7 +55,7 @@ public:
void TouchMem(SCNHANDLE offset);
// Called at scene startup
- void SetCdPlaySceneDetails(int sceneNum, const char *fileName);
+ void SetCdPlaySceneDetails(const char *fileName);
// Called at game startup
void SetCdPlayHandle(int fileNum);
@@ -75,17 +76,17 @@ private:
void LoadCDGraphData(MEMHANDLE *pH);
// handle table gets loaded from index file at runtime
- MEMHANDLE *g_handleTable;
+ MEMHANDLE *_handleTable;
// number of handles in the handle table
- uint g_numHandles;
+ uint _numHandles;
- uint32 g_cdPlayHandle;
+ uint32 _cdPlayHandle;
- SCNHANDLE g_cdBaseHandle, g_cdTopHandle;
- Common::File *g_cdGraphStream;
+ SCNHANDLE _cdBaseHandle, _cdTopHandle;
+ Common::File *_cdGraphStream;
- char g_szCdPlayFile[100];
+ Common::String _szCdPlayFile;
};
} // End of namespace Tinsel
diff --git a/engines/tinsel/scene.cpp b/engines/tinsel/scene.cpp
index 48bbb62163..938cac745f 100644
--- a/engines/tinsel/scene.cpp
+++ b/engines/tinsel/scene.cpp
@@ -225,7 +225,7 @@ static void LoadScene(SCNHANDLE scene, int entry) {
assert(i < 512);
cptr = FindChunk(scene, CHUNK_CDPLAY_FILENAME);
assert(cptr);
- _vm->_handle->SetCdPlaySceneDetails(i, (const char *)cptr);
+ _vm->_handle->SetCdPlaySceneDetails((const char *)cptr);
}
// Find scene structure
Commit: bbf81aa216b12a9af755d9652006e73b39faea38
https://github.com/scummvm/scummvm/commit/bbf81aa216b12a9af755d9652006e73b39faea38
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-10-04T01:15:20+03:00
Commit Message:
TINSEL: Move code into class destructors
Changed paths:
engines/tinsel/actors.cpp
engines/tinsel/actors.h
engines/tinsel/handle.cpp
engines/tinsel/handle.h
engines/tinsel/tinsel.cpp
diff --git a/engines/tinsel/actors.cpp b/engines/tinsel/actors.cpp
index 6839bdae9f..fa17ce7ccf 100644
--- a/engines/tinsel/actors.cpp
+++ b/engines/tinsel/actors.cpp
@@ -113,6 +113,18 @@ struct RATP_INIT {
//-------------------- METHOD LIST -----------------------
+Actor::Actor() : _actorInfo(nullptr), _defaultColor(0), _actorsOn(false), ti(0), _numTaggedActors(0), _zFactors(nullptr), _leadActorId(0), _numActors(0) {
+}
+
+Actor::~Actor() {
+ free(_actorInfo);
+ _actorInfo = nullptr;
+ if (TinselV2) {
+ free(_zFactors);
+ _zFactors = nullptr;
+ }
+}
+
/**
* Called once at start-up time, and again at restart time.
* Registers the total number of actors in the game.
@@ -153,15 +165,6 @@ void Actor::RegisterActors(int num) {
_actorInfo[num].bAlive = true;
}
-void Actor::FreeActors() {
- free(_actorInfo);
- _actorInfo = nullptr;
- if (TinselV2) {
- free(_zFactors);
- _zFactors = nullptr;
- }
-}
-
/**
* Called from dec_lead(), i.e. normally once at start of master script.
* @param leadID Lead Id
diff --git a/engines/tinsel/actors.h b/engines/tinsel/actors.h
index b26f976aeb..0c8f00f866 100644
--- a/engines/tinsel/actors.h
+++ b/engines/tinsel/actors.h
@@ -87,7 +87,9 @@ typedef SAVED_ACTOR *PSAVED_ACTOR;
class Actor {
public:
- Actor(): _actorInfo(nullptr), _defaultColor(0), _actorsOn(false), ti(0), _numTaggedActors(0), _zFactors(nullptr), _leadActorId(0), _numActors(0) {}
+ Actor();
+ virtual ~Actor();
+
int GetLeadId();
SCNHANDLE GetActorTagHandle(int ano);
void ToggleActor(int ano, bool show);
@@ -97,7 +99,6 @@ public:
int GetCount() { return _numActors; }
void RegisterActors(int num);
- void FreeActors();
void SetLeadId(int rid);
bool ActorIsGhost(int actor);
void StartTaggedActors(SCNHANDLE ah, int numActors, bool bRunScript);
diff --git a/engines/tinsel/handle.cpp b/engines/tinsel/handle.cpp
index da0eb1d48d..eac283108f 100644
--- a/engines/tinsel/handle.cpp
+++ b/engines/tinsel/handle.cpp
@@ -58,6 +58,17 @@ enum {
};
#define FSIZE_MASK 0x00FFFFFFL ///< mask to isolate the filesize
+Handle::Handle() : _handleTable(0), _numHandles(0), _cdPlayHandle((uint32)-1), _cdBaseHandle(0), _cdTopHandle(0), _cdGraphStream(nullptr) {
+}
+
+Handle::~Handle() {
+ free(_handleTable);
+ _handleTable = nullptr;
+
+ delete _cdGraphStream;
+ _cdGraphStream = nullptr;
+}
+
/**
* Loads the graphics handle table index file and preloads all the
* permanent graphics etc.
@@ -145,14 +156,6 @@ void Handle::SetupHandleTable() {
}
}
-void Handle::FreeHandleTable() {
- free(_handleTable);
- _handleTable= nullptr;
-
- delete _cdGraphStream;
- _cdGraphStream= nullptr;
-}
-
/**
* Loads a memory block as a file.
*/
diff --git a/engines/tinsel/handle.h b/engines/tinsel/handle.h
index 213e10c47c..55790fd361 100644
--- a/engines/tinsel/handle.h
+++ b/engines/tinsel/handle.h
@@ -37,13 +37,13 @@ struct MEMHANDLE;
class Handle {
public:
- Handle() : _handleTable(0), _numHandles(0), _cdPlayHandle((uint32)-1), _cdBaseHandle(0), _cdTopHandle(0), _cdGraphStream(nullptr) {}
+ Handle();
+ virtual ~Handle();
/**
* Loads the graphics handle table index file and preloads all the permanent graphics etc.
*/
void SetupHandleTable();
- void FreeHandleTable();
byte *LockMem(SCNHANDLE offset);
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index 8418dff4d3..32fab385d2 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -860,8 +860,6 @@ TinselEngine::~TinselEngine() {
_screenSurface.free();
FreeSaveScenes();
FreeTextBuffer();
- _handle->FreeHandleTable();
- _actor->FreeActors();
FreeObjectList();
FreeGlobalProcesses();
FreeGlobals();
Commit: efb0acb24f92f43b2a5e79a123a41f469df46613
https://github.com/scummvm/scummvm/commit/efb0acb24f92f43b2a5e79a123a41f469df46613
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-10-04T01:15:20+03:00
Commit Message:
TINSEL: Clear some global vars upon engine destruction
Changed paths:
engines/tinsel/drives.cpp
engines/tinsel/events.cpp
engines/tinsel/mareels.cpp
engines/tinsel/rince.cpp
engines/tinsel/timers.cpp
engines/tinsel/tinlib.cpp
engines/tinsel/tinsel.cpp
engines/tinsel/token.cpp
diff --git a/engines/tinsel/drives.cpp b/engines/tinsel/drives.cpp
index f425bb110d..dadfb4272e 100644
--- a/engines/tinsel/drives.cpp
+++ b/engines/tinsel/drives.cpp
@@ -30,7 +30,7 @@
namespace Tinsel {
-// FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
char g_currentCD = '1';
@@ -40,6 +40,14 @@ static char g_nextCD = '\0';
static uint32 g_lastTime = 0;
extern LANGUAGE g_sampleLanguage;
+void ResetVarsDrives() {
+ g_currentCD = '1';
+
+ g_bChangingCD = false;
+ g_nextCD = '\0';
+
+ g_lastTime = 0;
+}
void CdCD(CORO_PARAM) {
CORO_BEGIN_CONTEXT;
diff --git a/engines/tinsel/events.cpp b/engines/tinsel/events.cpp
index 36055b2148..a010825d3b 100644
--- a/engines/tinsel/events.cpp
+++ b/engines/tinsel/events.cpp
@@ -58,9 +58,9 @@ extern bool g_bEnableMenu;
//----------------- LOCAL GLOBAL DATA --------------------
-// FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
-static uint32 g_lastUserEvent = 0; // Time it hapenned
+static uint32 g_lastUserEvent = 0; // Time it happened
static int g_leftEvents = 0; // Single or double, left or right. Or escape key.
static int g_escEvents = 1; // Escape key
static int g_userEvents = 0; // Whenever a button or a key comes in
@@ -73,6 +73,26 @@ static bool g_bStartOff;
static int g_controlX, g_controlY;
static bool g_bProvNotProcessed = false;
+static uint32 lastRealAction = 0;
+
+void ResetVarsEvents() {
+ g_lastUserEvent = 0;
+ g_leftEvents = 0; // Single or double, left or right. Or escape key.
+ g_escEvents = 1; // Escape key
+ g_userEvents = 0; // Whenever a button or a key comes in
+
+ g_eCount = 0;
+
+ g_controlState = 0;
+ g_bStartOff = false;
+
+ g_controlX = 0;
+ g_controlY = 0;
+ g_bProvNotProcessed = false;
+
+ lastRealAction = 0;
+}
+
/**
* Gets called before each schedule, only 1 user action per schedule
* is allowed.
@@ -81,7 +101,6 @@ void ResetEcount() {
g_eCount = 0;
}
-
void IncUserEvents() {
g_userEvents++;
g_lastUserEvent = DwGetCurrentTime();
@@ -393,7 +412,6 @@ void PlayerEvent(PLR_EVENT pEvent, const Common::Point &coOrds) {
"PLR_WHEEL_DOWN"};
debugC(DEBUG_BASIC, kTinselDebugActions, "%s - (%d,%d)",
actionList[pEvent], coOrds.x, coOrds.y);
- static uint32 lastRealAction = 0; // FIXME: Avoid non-const global vars
// This stuff to allow F1 key during startup.
if (g_bEnableMenu && pEvent == PLR_MENU)
diff --git a/engines/tinsel/mareels.cpp b/engines/tinsel/mareels.cpp
index d996ee2d82..98474d106e 100644
--- a/engines/tinsel/mareels.cpp
+++ b/engines/tinsel/mareels.cpp
@@ -46,10 +46,8 @@ struct SCIdataStruct {
SCNHANDLE reels[4];
};
-// FIXME: Avoid non-const global vars
-
+// These vars are reset upon engine destruction
static SCIdataStruct g_SCIdata[MAX_SCRENTRIES];
-
static int g_scrEntries = 0;
/**
diff --git a/engines/tinsel/rince.cpp b/engines/tinsel/rince.cpp
index c11e8e11c8..8420207ce7 100644
--- a/engines/tinsel/rince.cpp
+++ b/engines/tinsel/rince.cpp
@@ -51,7 +51,8 @@ namespace Tinsel {
//----------------- LOCAL GLOBAL DATA --------------------
-static MOVER g_Movers[MAX_MOVERS]; // FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
+static MOVER g_Movers[MAX_MOVERS];
//----------------- FUNCTIONS ----------------------------
diff --git a/engines/tinsel/timers.cpp b/engines/tinsel/timers.cpp
index d4b20f4bfb..81c7b8586c 100644
--- a/engines/tinsel/timers.cpp
+++ b/engines/tinsel/timers.cpp
@@ -49,7 +49,8 @@ struct TIMER {
//----------------- LOCAL GLOBAL DATA --------------------
-static TIMER g_timers[MAX_TIMERS]; // FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
+static TIMER g_timers[MAX_TIMERS];
//--------------------------------------------------------
diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp
index e364b1e24e..341c914f01 100644
--- a/engines/tinsel/tinlib.cpp
+++ b/engines/tinsel/tinlib.cpp
@@ -112,16 +112,6 @@ extern void UnSuspendHook();
SCNHANDLE GetSceneHandle();
#endif
-//----------------- GLOBAL GLOBAL DATA --------------------
-
-// FIXME: Avoid non-const global vars
-
-bool g_bEnableMenu;
-
-static bool g_bInstantScroll = false;
-static bool g_bEscapedCdPlay = false;
-
-
//----------------- LOCAL DEFINES --------------------
#define JAP_TEXT_TIME (2*ONE_SECOND)
@@ -284,9 +274,18 @@ static const MASTER_LIB_CODES DW2_CODES[] = {
HIGHEST_LIBCODE
};
+//----------------- GLOBAL GLOBAL DATA --------------------
+
+// These vars are reset upon engine destruction
+
+bool g_bEnableMenu;
+
+static bool g_bInstantScroll = false;
+static bool g_bEscapedCdPlay = false;
+
//----------------- LOCAL GLOBAL DATA --------------------
-// FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
// Saved cursor co-ordinates for control(on) to restore cursor position
// as it was at control(off).
@@ -316,6 +315,21 @@ void Walk(CORO_PARAM, int actor, int x, int y, SCNHANDLE film, int hold, bool ig
//----------------- SUPPORT FUNCTIONS --------------------
+void ResetVarsTinlib() {
+ g_bEnableMenu = false;
+
+ g_bInstantScroll = false;
+ g_bEscapedCdPlay = false;
+ g_controlX = 0;
+ g_controlY = 0;
+
+ g_offtype = 0;
+ g_lastValue = 0;
+ g_scrollNumber = 0;
+
+ g_bNotPointedRunning = false;
+}
+
/**
* For Scroll() and Offset(), work out top left for a
* given screen position.
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index 32fab385d2..b73bb0308c 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -73,6 +73,15 @@ extern void InventoryProcess(CORO_PARAM, const void *);
// In SCENE.CPP
extern SCNHANDLE GetSceneHandle();
+extern void ResetVarsDrives();
+extern void ResetVarsEvents();
+extern void RebootScalingReels();
+extern void RebootMovers();
+extern void FreeTextBuffer();
+extern void FreeAllTokens();
+extern void RebootTimers();
+extern void ResetVarsTinlib();
+
//----------------- FORWARD DECLARATIONS ---------------------
void SetNewScene(SCNHANDLE scene, int entrance, int transition);
@@ -869,6 +878,33 @@ TinselEngine::~TinselEngine() {
delete _config;
MemoryDeinit();
+
+ // Reset global vars
+ // TODO: dialogs.cpp
+ ResetVarsDrives(); // drives.cpp
+ ResetVarsEvents(); // events.cpp
+ // TODO: heapmem.cpp
+ RebootScalingReels(); // mareels.cpp
+ // TODO: move.cpp
+ // TODO: object.cpp
+ // TODO: palette.cpp
+ // TODO: pcode.cpp
+ // TODO: pdisplay.cpp
+ // TODO: play.cpp
+ // TODO: polygons.cpp
+ RebootMovers(); // rince.cpp
+ // TODO: saveload.cpp
+ // TODO: savescn.cpp
+ // TODO: scene.cpp
+ // TODO: sched.cpp
+ // TODO: scroll.cpp
+ // TODO: strres.cpp
+ FreeTextBuffer(); // strres.cpp
+ // TODO: sysvar.cpp
+ FreeAllTokens(); // token.cpp
+ RebootTimers(); // timers.cpp
+ ResetVarsTinlib(); // tinlib.cpp
+ // TODO: tinsel.cpp
}
Common::String TinselEngine::getSavegameFilename(int16 saveNum) const {
diff --git a/engines/tinsel/token.cpp b/engines/tinsel/token.cpp
index 1f2483fbd8..705b96a4e6 100644
--- a/engines/tinsel/token.cpp
+++ b/engines/tinsel/token.cpp
@@ -34,7 +34,8 @@ struct Token {
Common::PROCESS *proc;
};
-static Token g_tokens[NUMTOKENS]; // FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
+static Token g_tokens[NUMTOKENS];
/**
Commit: 9322b11fd86fa9bc64f08fa3146dfbe130b438cd
https://github.com/scummvm/scummvm/commit/9322b11fd86fa9bc64f08fa3146dfbe130b438cd
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-10-04T01:15:20+03:00
Commit Message:
TINSEL: Move all scroll-related functions into a new Scroll class
Changed paths:
engines/tinsel/events.cpp
engines/tinsel/savescn.cpp
engines/tinsel/scene.cpp
engines/tinsel/scroll.cpp
engines/tinsel/scroll.h
engines/tinsel/tinlib.cpp
engines/tinsel/tinsel.cpp
engines/tinsel/tinsel.h
diff --git a/engines/tinsel/events.cpp b/engines/tinsel/events.cpp
index a010825d3b..86a6c6f83a 100644
--- a/engines/tinsel/events.cpp
+++ b/engines/tinsel/events.cpp
@@ -271,7 +271,7 @@ static void WalkProcess(CORO_PARAM, const void *param) {
assert(_ctx->pMover->hCpath != NOPOLY); // Lead actor is not in a path
_ctx->thisWalk = SetActorDest(_ctx->pMover, to->x, to->y, false, 0);
- DontScrollCursor();
+ _vm->_scroll->DontScrollCursor();
while (MoverMoving(_ctx->pMover) && (_ctx->thisWalk == GetWalkNumber(_ctx->pMover)))
CORO_SLEEP(1);
@@ -281,7 +281,7 @@ static void WalkProcess(CORO_PARAM, const void *param) {
GetToken(TOKEN_LEAD);
SetActorDest(_ctx->pMover, to->x, to->y, false, 0);
- DontScrollCursor();
+ _vm->_scroll->DontScrollCursor();
while (MoverMoving(_ctx->pMover))
CORO_SLEEP(1);
diff --git a/engines/tinsel/savescn.cpp b/engines/tinsel/savescn.cpp
index bf3ef1235e..6d1908ab31 100644
--- a/engines/tinsel/savescn.cpp
+++ b/engines/tinsel/savescn.cpp
@@ -110,7 +110,7 @@ void DoSaveScene(SAVED_DATA *sd) {
SaveInterpretContexts(sd->SavedICInfo);
sd->SavedControl = ControlIsOn();
sd->SavedNoBlocking = GetNoBlocking();
- GetNoScrollData(&sd->SavedNoScrollData);
+ _vm->_scroll->GetNoScrollData(&sd->SavedNoScrollData);
if (TinselV2) {
// Tinsel 2 specific data save
@@ -119,7 +119,7 @@ void DoSaveScene(SAVED_DATA *sd) {
SavePolygonStuff(sd->SavedPolygonStuff);
_vm->_pcmMusic->getTunePlaying(sd->SavedTune, sizeof(sd->SavedTune));
sd->bTinselDim = _vm->_pcmMusic->getMusicTinselDimmed();
- sd->SavedScrollFocus = GetScrollFocus();
+ sd->SavedScrollFocus = _vm->_scroll->GetScrollFocus();
SaveSysVars(sd->SavedSystemVars);
SaveSoundReels(sd->SavedSoundReels);
@@ -341,12 +341,12 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {
if (TinselV2) {
Offset(EX_USEXY, sd->SavedLoffset, sd->SavedToffset);
} else {
- KillScroll();
+ _vm->_scroll->KillScroll();
_vm->_bg->PlayfieldSetPos(FIELD_WORLD, sd->SavedLoffset, sd->SavedToffset);
SetNoBlocking(sd->SavedNoBlocking);
}
- RestoreNoScrollData(&sd->SavedNoScrollData);
+ _vm->_scroll->RestoreNoScrollData(&sd->SavedNoScrollData);
if (TinselV2) {
// create process to sort out the moving actors
@@ -377,7 +377,7 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {
if (sd->bTinselDim)
_vm->_pcmMusic->dim(true);
_vm->_pcmMusic->restoreThatTune(sd->SavedTune);
- ScrollFocus(sd->SavedScrollFocus);
+ _vm->_scroll->ScrollFocus(sd->SavedScrollFocus);
} else {
_vm->_music->RestoreMidiFacts(sd->SavedMidi, sd->SavedLoop);
}
diff --git a/engines/tinsel/scene.cpp b/engines/tinsel/scene.cpp
index 938cac745f..485976e7ec 100644
--- a/engines/tinsel/scene.cpp
+++ b/engines/tinsel/scene.cpp
@@ -313,7 +313,7 @@ void EndScene() {
KillInventory(); // Close down any open inventory
DropPolygons(); // No polygons
- DropScroll(); // No no-scrolls
+ _vm->_scroll->DropScroll(); // No no-scrolls
_vm->_bg->DropBackground(); // No background
DropMovers(); // No moving actors
_vm->_cursor->DropCursor(); // No cursor
diff --git a/engines/tinsel/scroll.cpp b/engines/tinsel/scroll.cpp
index c4fd8fde1f..891db7bdbe 100644
--- a/engines/tinsel/scroll.cpp
+++ b/engines/tinsel/scroll.cpp
@@ -42,69 +42,55 @@ namespace Tinsel {
#define UP 'U'
#define DOWN 'D'
-
-
-//----------------- LOCAL GLOBAL DATA --------------------
-
-// FIXME: Avoid non-const global vars
-
-
-static int g_LeftScroll = 0, g_DownScroll = 0; // Number of iterations outstanding
-
-static int g_scrollActor = 0;
-static PMOVER g_pScrollMover = 0;
-static int g_oldx = 0, g_oldy = 0;
-
-/** Boundaries and numbers of boundaries */
-static SCROLLDATA g_sd = {
- {
- {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
- {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}
- },
- {
- {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
- {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}
- },
- 0,
- 0,
- // DW2 fields
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0
- };
-
-static int g_ImageH = 0, g_ImageW = 0;
-
-static bool g_ScrollCursor = 0; // If a TAG or EXIT polygon is clicked on,
- // the cursor is kept over that polygon
- // whilst scrolling
-
-static int g_scrollPixelsX = SCROLLPIXELS;
-static int g_scrollPixelsY = SCROLLPIXELS;
-
+Scroll::Scroll() {
+ g_LeftScroll = 0;
+ g_DownScroll = 0;
+ g_scrollActor = 0;
+ g_pScrollMover = nullptr;
+ g_oldx = 0;
+ g_oldy = 0;
+
+ g_sd = {
+ {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
+ {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
+ 0,
+ 0,
+ // DW2 fields
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0};
+
+ g_ImageH = 0;
+ g_ImageW = 0;
+
+ g_ScrollCursor = 0;
+
+ g_scrollPixelsX = SCROLLPIXELS;
+ g_scrollPixelsY = SCROLLPIXELS;
+}
/**
* Reset the ScrollCursor flag
*/
-void DontScrollCursor() {
+void Scroll::DontScrollCursor() {
g_ScrollCursor = false;
}
/**
* Set the ScrollCursor flag
*/
-void DoScrollCursor() {
+void Scroll::DoScrollCursor() {
g_ScrollCursor = true;
}
/**
* Configure a no-scroll boundary for a scene.
*/
-void SetNoScroll(int x1, int y1, int x2, int y2) {
+void Scroll::SetNoScroll(int x1, int y1, int x2, int y2) {
if (x1 == x2) {
/* Vertical line */
assert(g_sd.NumNoH < MAX_HNOSCROLL);
@@ -130,7 +116,7 @@ void SetNoScroll(int x1, int y1, int x2, int y2) {
* Called from scroll process when it thinks that a scroll is in order.
* Checks for no-scroll boundaries and sets off a scroll if allowed.
*/
-static void NeedScroll(int direction) {
+void Scroll::NeedScroll(int direction) {
uint i;
int BottomLine, RightCol;
int Loffset, Toffset;
@@ -241,11 +227,14 @@ static void NeedScroll(int direction) {
/**
* Called from scroll process - Scrolls the image as appropriate.
*/
-static void ScrollImage() {
+void Scroll::ScrollImage() {
int OldLoffset = 0, OldToffset = 0; // Used when keeping cursor on a tag
int Loffset, Toffset;
int curX, curY;
+ if (!g_LeftScroll && !g_DownScroll) // Only scroll if required
+ return;
+
// get background offsets
_vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
@@ -341,7 +330,7 @@ static void ScrollImage() {
* See if the actor on whom the camera is is approaching an edge.
* Request a scroll if he is.
*/
-static void MonitorScroll() {
+void Scroll::MonitorScroll() {
int newx, newy;
int Loffset, Toffset;
@@ -384,7 +373,7 @@ static void MonitorScroll() {
g_oldy = newy;
}
-static void RestoreScrollDefaults() {
+void Scroll::RestoreScrollDefaults() {
g_sd.xTrigger = SysVar(SV_SCROLL_XTRIGGER);
g_sd.xDistance = SysVar(SV_SCROLL_XDISTANCE);
g_sd.xSpeed = SysVar(SV_SCROLL_XSPEED);
@@ -397,7 +386,7 @@ static void RestoreScrollDefaults() {
/**
* Does the obvious - called at the end of a scene.
*/
-void DropScroll() {
+void Scroll::DropScroll() {
g_sd.NumNoH = g_sd.NumNoV = 0;
if (TinselV2) {
g_LeftScroll = g_DownScroll = 0; // No iterations outstanding
@@ -408,55 +397,10 @@ void DropScroll() {
}
}
-/**
- * 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 (!_vm->_bg->GetBgObject())
- CORO_SLEEP(1);
-
- g_ImageH = _vm->_bg->BgHeight(); // Dimensions
- g_ImageW = _vm->_bg->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 = _vm->_actor->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;
-}
-
/**
* Change which actor the camera is following.
*/
-void ScrollFocus(int ano) {
+void Scroll::ScrollFocus(int ano) {
if (g_scrollActor != ano) {
g_oldx = g_oldy = 0;
g_scrollActor = ano;
@@ -468,15 +412,14 @@ void ScrollFocus(int ano) {
/**
* Returns the actor which the camera is following
*/
-int GetScrollFocus() {
+int Scroll::GetScrollFocus() {
return g_scrollActor;
}
-
/**
* Scroll to abslote position.
*/
-void ScrollTo(int x, int y, int xIter, int yIter) {
+void Scroll::ScrollTo(int x, int y, int xIter, int yIter) {
int Loffset, Toffset; // for background offsets
g_scrollPixelsX = xIter != 0 ? xIter : (TinselV2 ? g_sd.xSpeed : SCROLLPIXELS);
@@ -491,23 +434,22 @@ void ScrollTo(int x, int y, int xIter, int yIter) {
/**
* Kill of any current scroll.
*/
-void KillScroll() {
+void Scroll::KillScroll() {
g_LeftScroll = g_DownScroll = 0;
}
-
-void GetNoScrollData(SCROLLDATA *ssd) {
+void Scroll::GetNoScrollData(SCROLLDATA *ssd) {
memcpy(ssd, &g_sd, sizeof(SCROLLDATA));
}
-void RestoreNoScrollData(SCROLLDATA *ssd) {
+void Scroll::RestoreNoScrollData(SCROLLDATA *ssd) {
memcpy(&g_sd, ssd, sizeof(SCROLLDATA));
}
/**
* SetScrollParameters
*/
-void SetScrollParameters(int xTrigger, int xDistance, int xSpeed, int yTriggerTop,
+void Scroll::SetScrollParameters(int xTrigger, int xDistance, int xSpeed, int yTriggerTop,
int yTriggerBottom, int yDistance, int ySpeed) {
if (xTrigger == 0 && xDistance == 0 && xSpeed == 0
&& yTriggerTop == 0 && yTriggerBottom && yDistance == 0 && ySpeed == 0) {
@@ -531,8 +473,60 @@ void SetScrollParameters(int xTrigger, int xDistance, int xSpeed, int yTriggerTo
}
}
-bool IsScrolling() {
+bool Scroll::IsScrolling() {
return (g_LeftScroll || g_DownScroll);
}
+void Scroll::InitScroll(int width, int height) {
+ g_ImageH = height; // Dimensions
+ g_ImageW = width; // of this scene.
+
+ 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 = _vm->_actor->GetLeadId();
+
+ g_pScrollMover = GetMover(g_scrollActor);
+}
+
+/**
+ * Decide when to scroll and scroll when decided to.
+ */
+void ScrollProcess(CORO_PARAM, const void *) {
+ int width, height;
+
+ // 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 (!_vm->_bg->GetBgObject())
+ CORO_SLEEP(1);
+
+ width = _vm->_bg->BgWidth(); // Dimensions
+ height = _vm->_bg->BgHeight(); // of this scene.
+
+ // Give up if there'll be no purpose in this process
+ if (width == SCREEN_WIDTH && height == SCREEN_HEIGHT)
+ CORO_KILL_SELF();
+
+ _vm->_scroll->InitScroll(width, height);
+
+ while (1) {
+ _vm->_scroll->MonitorScroll(); // Set scroll requirement
+ _vm->_scroll->ScrollImage();
+
+ CORO_SLEEP(1); // allow re-scheduling
+ }
+
+ CORO_END_CODE;
+}
+
} // End of namespace Tinsel
diff --git a/engines/tinsel/scroll.h b/engines/tinsel/scroll.h
index 4d3f85dd0f..a36e7bcdbe 100644
--- a/engines/tinsel/scroll.h
+++ b/engines/tinsel/scroll.h
@@ -20,12 +20,12 @@
*
*/
-#ifndef TINSEL_SCROLL_H // prevent multiple includes
+#ifndef TINSEL_SCROLL_H // prevent multiple includes
#define TINSEL_SCROLL_H
namespace Tinsel {
-#define SCROLLPIXELS 8 // Number of pixels to scroll per iteration
+#define SCROLLPIXELS 8 // Number of pixels to scroll per iteration
// Distance from edge that triggers a scroll
#define RLDISTANCE (TinselV2 ? g_sd.xTrigger : 50)
@@ -33,9 +33,8 @@ namespace Tinsel {
#define DDISTANCE (TinselV2 ? g_sd.yTriggerBottom : 20)
// Number of iterations to make
-#define RLSCROLL 160 // 20*8 = 160 = half a screen
-#define UDSCROLL 100 // 12.5*8 = 100 = half a screen
-
+#define RLSCROLL 160 // 20*8 = 160 = half a screen
+#define UDSCROLL 100 // 12.5*8 = 100 = half a screen
// These structures defined here so boundaries can be saved
struct NOSCROLLB {
@@ -44,13 +43,13 @@ struct NOSCROLLB {
int c2;
};
-#define MAX_HNOSCROLL 10
-#define MAX_VNOSCROLL 10
+#define MAX_HNOSCROLL 10
+#define MAX_VNOSCROLL 10
-struct SCROLLDATA{
- NOSCROLLB NoVScroll[MAX_VNOSCROLL]; // Vertical no-scroll boundaries
- NOSCROLLB NoHScroll[MAX_HNOSCROLL]; // Horizontal no-scroll boundaries
- unsigned NumNoV, NumNoH; // Counts of no-scroll boundaries
+struct SCROLLDATA {
+ NOSCROLLB NoVScroll[MAX_VNOSCROLL]; // Vertical no-scroll boundaries
+ NOSCROLLB NoHScroll[MAX_HNOSCROLL]; // Horizontal no-scroll boundaries
+ unsigned NumNoV, NumNoH; // Counts of no-scroll boundaries
// DW2 fields
int xTrigger;
int xDistance;
@@ -61,28 +60,59 @@ struct SCROLLDATA{
int ySpeed;
};
+class Scroll {
+public:
+ Scroll();
-void DontScrollCursor();
-void DoScrollCursor();
+ void DontScrollCursor();
+ void DoScrollCursor();
-void SetNoScroll(int x1, int y1, int x2, int y2);
-void DropScroll();
+ void SetNoScroll(int x1, int y1, int x2, int y2);
+ void DropScroll();
-void ScrollProcess(CORO_PARAM, const void *);
+ void ScrollFocus(int actor);
+ int GetScrollFocus();
+ void ScrollTo(int x, int y, int xIter, int yIter);
+
+ void KillScroll();
+
+ void GetNoScrollData(SCROLLDATA *ssd);
+ void RestoreNoScrollData(SCROLLDATA *ssd);
+
+ void SetScrollParameters(int xTrigger, int xDistance, int xSpeed, int yTriggerTop,
+ int yTriggerBottom, int yDistance, int ySpeed);
+
+ bool IsScrolling();
+
+ void ScrollImage();
+ void MonitorScroll();
-void ScrollFocus(int actor);
-int GetScrollFocus();
-void ScrollTo(int x, int y, int xIter, int yIter);
+ void InitScroll(int width, int height);
-void KillScroll();
+private:
+ void NeedScroll(int direction);
+ void RestoreScrollDefaults();
-void GetNoScrollData(SCROLLDATA *ssd);
-void RestoreNoScrollData(SCROLLDATA *ssd);
+ int g_LeftScroll, g_DownScroll; // Number of iterations outstanding
-void SetScrollParameters(int xTrigger, int xDistance, int xSpeed, int yTriggerTop,
- int yTriggerBottom, int yDistance, int ySpeed);
+ int g_scrollActor;
+ PMOVER g_pScrollMover;
+ int g_oldx, g_oldy;
-bool IsScrolling();
+ /** Boundaries and numbers of boundaries */
+ SCROLLDATA g_sd;
+
+ int g_ImageH, g_ImageW;
+
+ bool g_ScrollCursor; // If a TAG or EXIT polygon is clicked on,
+ // the cursor is kept over that polygon
+ // whilst scrolling
+
+ int g_scrollPixelsX;
+ int g_scrollPixelsY;
+};
+
+void ScrollProcess(CORO_PARAM, const void *);
} // End of namespace Tinsel
diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp
index 341c914f01..c5b096f34f 100644
--- a/engines/tinsel/tinlib.cpp
+++ b/engines/tinsel/tinlib.cpp
@@ -661,7 +661,7 @@ void Blocking(bool onOrOff) {
* Sets focus of the scroll process.
*/
static void Camera(int actor) {
- ScrollFocus(actor);
+ _vm->_scroll->ScrollFocus(actor);
}
/**
@@ -1461,7 +1461,7 @@ static void NoBlocking() {
* Define a no-scroll boundary for the current scene.
*/
static void NoScroll(int x1, int y1, int x2, int y2) {
- SetNoScroll(x1, y1, x2, y2);
+ _vm->_scroll->SetNoScroll(x1, y1, x2, y2);
}
/**
@@ -1475,7 +1475,7 @@ static void ObjectHeld(int object) {
* Set the top left offset of the screen.
*/
void Offset(EXTREME extreme, int x, int y) {
- KillScroll();
+ _vm->_scroll->KillScroll();
if (TinselV2)
DecodeExtreme(extreme, &x, &y);
@@ -2535,7 +2535,7 @@ static void Scroll(CORO_PARAM, EXTREME extreme, int xp, int yp, int xIter, int y
if (TinselV2)
DecodeExtreme(extreme, &_ctx->x, &_ctx->y);
- ScrollTo(_ctx->x, _ctx->y, xIter, yIter);
+ _vm->_scroll->ScrollTo(_ctx->x, _ctx->y, xIter, yIter);
if (bComp) {
int Loffset, Toffset;
@@ -2574,7 +2574,7 @@ static void Scroll(CORO_PARAM, EXTREME extreme, int xp, int yp, int xIter, int y
*/
static void ScrollParameters(int xTrigger, int xDistance, int xSpeed, int yTriggerTop,
int yTriggerBottom, int yDistance, int ySpeed) {
- SetScrollParameters(xTrigger, xDistance, xSpeed,
+ _vm->_scroll->SetScrollParameters(xTrigger, xDistance, xSpeed,
yTriggerTop, yTriggerBottom, yDistance, ySpeed);
}
@@ -3760,7 +3760,7 @@ void WaitScroll(CORO_PARAM, int myescEvent) {
CORO_BEGIN_CODE(_ctx);
// wait for ongoing scroll
- while (IsScrolling()) {
+ while (_vm->_scroll->IsScrolling()) {
if (myescEvent && myescEvent != GetEscEvents())
break;
@@ -3842,7 +3842,7 @@ void Walk(CORO_PARAM, int actor, int x, int y, SCNHANDLE hFilm, int hold, bool i
_ctx->thisWalk = SetActorDest(pMover, x, y, igPath, hFilm);
SetMoverZoverride(pMover, zOverride);
- DontScrollCursor();
+ _vm->_scroll->DontScrollCursor();
if (!bQuick) {
while (MoverMoving(pMover)) {
@@ -3864,7 +3864,7 @@ void Walk(CORO_PARAM, int actor, int x, int y, SCNHANDLE hFilm, int hold, bool i
GetToken(pMover->actorToken);
SetActorDest(pMover, x, y, igPath, hFilm);
- DontScrollCursor();
+ _vm->_scroll->DontScrollCursor();
if (hold == 2) {
;
@@ -3934,7 +3934,7 @@ static void Walked(CORO_PARAM, int actor, int x, int y, SCNHANDLE film, bool esc
}
_ctx->thisWalk = SetActorDest(pMover, x, y, false, film);
- DontScrollCursor();
+ _vm->_scroll->DontScrollCursor();
while (MoverMoving(pMover) && (_ctx->thisWalk == GetWalkNumber(pMover))) {
// Straight there if escaped
@@ -4025,7 +4025,7 @@ static void WalkPoly(CORO_PARAM, int actor, SCNHANDLE film, HPOLYGON hp, bool es
GetPolyNode(hp, &pnodex, &pnodey);
_ctx->thisWalk = SetActorDest(pMover, pnodex, pnodey, false, film);
- DoScrollCursor();
+ _vm->_scroll->DoScrollCursor();
while (!MoverIsInPolygon(pMover, hp) && MoverMoving(pMover)) {
CORO_SLEEP(1);
@@ -4083,7 +4083,7 @@ static void WalkTag(CORO_PARAM, int actor, SCNHANDLE film, HPOLYGON hp, bool esc
GetPolyNode(hp, &pnodex, &pnodey);
_ctx->thisWalk = SetActorDest(pMover, pnodex, pnodey, false, film);
- DoScrollCursor();
+ _vm->_scroll->DoScrollCursor();
while (MoverMoving(pMover)) {
if (escOn && myEscape != GetEscEvents()) {
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index b73bb0308c..7cc86ed9fe 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -873,6 +873,7 @@ TinselEngine::~TinselEngine() {
FreeGlobalProcesses();
FreeGlobals();
+ delete _scroll;
delete _handle;
delete _actor;
delete _config;
@@ -897,7 +898,6 @@ TinselEngine::~TinselEngine() {
// TODO: savescn.cpp
// TODO: scene.cpp
// TODO: sched.cpp
- // TODO: scroll.cpp
// TODO: strres.cpp
FreeTextBuffer(); // strres.cpp
// TODO: sysvar.cpp
@@ -936,6 +936,7 @@ Common::Error TinselEngine::run() {
_cursor = new Cursor();
_actor = new Actor();
_handle = new Handle();
+ _scroll = new Scroll();
// Initialize backend
if (getGameID() == GID_DW2) {
diff --git a/engines/tinsel/tinsel.h b/engines/tinsel/tinsel.h
index c87496b562..d780844bb5 100644
--- a/engines/tinsel/tinsel.h
+++ b/engines/tinsel/tinsel.h
@@ -63,6 +63,7 @@ class Font;
class Cursor;
class Actor;
class Handle;
+class Scroll;
typedef Common::List<Common::Rect> RectList;
@@ -173,6 +174,7 @@ public:
Actor *_actor;
Handle *_handle;
Config *_config;
+ Scroll *_scroll;
KEYFPTR _keyHandler;
Commit: e1d1d72db8150de426fbdd01b8cba110a64cab2b
https://github.com/scummvm/scummvm/commit/e1d1d72db8150de426fbdd01b8cba110a64cab2b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-10-04T01:15:21+03:00
Commit Message:
TINSEL: Rename variables in the Scroll class, and move some defines
Changed paths:
engines/tinsel/scroll.cpp
engines/tinsel/scroll.h
diff --git a/engines/tinsel/scroll.cpp b/engines/tinsel/scroll.cpp
index 891db7bdbe..bade548b14 100644
--- a/engines/tinsel/scroll.cpp
+++ b/engines/tinsel/scroll.cpp
@@ -42,15 +42,26 @@ namespace Tinsel {
#define UP 'U'
#define DOWN 'D'
+#define SCROLLPIXELS 8 // Number of pixels to scroll per iteration
+
+// Distance from edge that triggers a scroll
+#define RLDISTANCE (TinselV2 ? _scrollData.xTrigger : 50)
+#define UDISTANCE (TinselV2 ? _scrollData.yTriggerTop : 20)
+#define DDISTANCE (TinselV2 ? _scrollData.yTriggerBottom : 20)
+
+// Number of iterations to make
+#define RLSCROLL 160 // 20*8 = 160 = half a screen
+#define UDSCROLL 100 // 12.5*8 = 100 = half a screen
+
Scroll::Scroll() {
- g_LeftScroll = 0;
- g_DownScroll = 0;
- g_scrollActor = 0;
- g_pScrollMover = nullptr;
- g_oldx = 0;
- g_oldy = 0;
-
- g_sd = {
+ _leftScroll = 0;
+ _downScroll = 0;
+ _scrollActor = 0;
+ _pScrollMover = nullptr;
+ _oldx = 0;
+ _oldy = 0;
+
+ _scrollData = {
{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
0,
@@ -64,27 +75,27 @@ Scroll::Scroll() {
0,
0};
- g_ImageH = 0;
- g_ImageW = 0;
+ _imageH = 0;
+ _imageW = 0;
- g_ScrollCursor = 0;
+ _scrollCursor = 0;
- g_scrollPixelsX = SCROLLPIXELS;
- g_scrollPixelsY = SCROLLPIXELS;
+ _scrollPixelsX = SCROLLPIXELS;
+ _scrollPixelsY = SCROLLPIXELS;
}
/**
* Reset the ScrollCursor flag
*/
void Scroll::DontScrollCursor() {
- g_ScrollCursor = false;
+ _scrollCursor = false;
}
/**
* Set the ScrollCursor flag
*/
void Scroll::DoScrollCursor() {
- g_ScrollCursor = true;
+ _scrollCursor = true;
}
/**
@@ -93,20 +104,20 @@ void Scroll::DoScrollCursor() {
void Scroll::SetNoScroll(int x1, int y1, int x2, int y2) {
if (x1 == x2) {
/* Vertical line */
- assert(g_sd.NumNoH < MAX_HNOSCROLL);
+ assert(_scrollData.NumNoH < MAX_HNOSCROLL);
- g_sd.NoHScroll[g_sd.NumNoH].ln = x1; // X pos of vertical line
- g_sd.NoHScroll[g_sd.NumNoH].c1 = y1;
- g_sd.NoHScroll[g_sd.NumNoH].c2 = y2;
- g_sd.NumNoH++;
+ _scrollData.NoHScroll[_scrollData.NumNoH].ln = x1; // X pos of vertical line
+ _scrollData.NoHScroll[_scrollData.NumNoH].c1 = y1;
+ _scrollData.NoHScroll[_scrollData.NumNoH].c2 = y2;
+ _scrollData.NumNoH++;
} else if (y1 == y2) {
/* Horizontal line */
- assert(g_sd.NumNoV < MAX_VNOSCROLL);
+ assert(_scrollData.NumNoV < MAX_VNOSCROLL);
- g_sd.NoVScroll[g_sd.NumNoV].ln = y1; // Y pos of horizontal line
- g_sd.NoVScroll[g_sd.NumNoV].c1 = x1;
- g_sd.NoVScroll[g_sd.NumNoV].c2 = x2;
- g_sd.NumNoV++;
+ _scrollData.NoVScroll[_scrollData.NumNoV].ln = y1; // Y pos of horizontal line
+ _scrollData.NoVScroll[_scrollData.NumNoV].c1 = x1;
+ _scrollData.NoVScroll[_scrollData.NumNoV].c2 = x2;
+ _scrollData.NumNoV++;
} else {
/* No-scroll lines must be horizontal or vertical */
}
@@ -130,21 +141,21 @@ void Scroll::NeedScroll(int direction) {
BottomLine = Toffset + (SCREEN_HEIGHT - 1);
RightCol = Loffset + (SCREEN_WIDTH - 1);
- for (i = 0; i < g_sd.NumNoH; i++) {
- if (RightCol >= g_sd.NoHScroll[i].ln - 1 && RightCol <= g_sd.NoHScroll[i].ln + 1 &&
- ((g_sd.NoHScroll[i].c1 >= Toffset && g_sd.NoHScroll[i].c1 <= BottomLine) ||
- (g_sd.NoHScroll[i].c2 >= Toffset && g_sd.NoHScroll[i].c2 <= BottomLine) ||
- (g_sd.NoHScroll[i].c1 < Toffset && g_sd.NoHScroll[i].c2 > BottomLine)))
+ for (i = 0; i < _scrollData.NumNoH; i++) {
+ if (RightCol >= _scrollData.NoHScroll[i].ln - 1 && RightCol <= _scrollData.NoHScroll[i].ln + 1 &&
+ ((_scrollData.NoHScroll[i].c1 >= Toffset && _scrollData.NoHScroll[i].c1 <= BottomLine) ||
+ (_scrollData.NoHScroll[i].c2 >= Toffset && _scrollData.NoHScroll[i].c2 <= BottomLine) ||
+ (_scrollData.NoHScroll[i].c1 < Toffset && _scrollData.NoHScroll[i].c2 > BottomLine)))
return;
}
- if (g_LeftScroll <= 0) {
+ if (_leftScroll <= 0) {
if (TinselV2) {
- g_scrollPixelsX = g_sd.xSpeed;
- g_LeftScroll += g_sd.xDistance;
+ _scrollPixelsX = _scrollData.xSpeed;
+ _leftScroll += _scrollData.xDistance;
} else {
- g_scrollPixelsX = SCROLLPIXELS;
- g_LeftScroll = RLSCROLL;
+ _scrollPixelsX = SCROLLPIXELS;
+ _leftScroll = RLSCROLL;
}
}
break;
@@ -153,21 +164,21 @@ void Scroll::NeedScroll(int direction) {
BottomLine = Toffset + (SCREEN_HEIGHT - 1);
- for (i = 0; i < g_sd.NumNoH; i++) {
- if (Loffset >= g_sd.NoHScroll[i].ln - 1 && Loffset <= g_sd.NoHScroll[i].ln + 1 &&
- ((g_sd.NoHScroll[i].c1 >= Toffset && g_sd.NoHScroll[i].c1 <= BottomLine) ||
- (g_sd.NoHScroll[i].c2 >= Toffset && g_sd.NoHScroll[i].c2 <= BottomLine) ||
- (g_sd.NoHScroll[i].c1 < Toffset && g_sd.NoHScroll[i].c2 > BottomLine)))
+ for (i = 0; i < _scrollData.NumNoH; i++) {
+ if (Loffset >= _scrollData.NoHScroll[i].ln - 1 && Loffset <= _scrollData.NoHScroll[i].ln + 1 &&
+ ((_scrollData.NoHScroll[i].c1 >= Toffset && _scrollData.NoHScroll[i].c1 <= BottomLine) ||
+ (_scrollData.NoHScroll[i].c2 >= Toffset && _scrollData.NoHScroll[i].c2 <= BottomLine) ||
+ (_scrollData.NoHScroll[i].c1 < Toffset && _scrollData.NoHScroll[i].c2 > BottomLine)))
return;
}
- if (g_LeftScroll >= 0) {
+ if (_leftScroll >= 0) {
if (TinselV2) {
- g_scrollPixelsX = g_sd.xSpeed;
- g_LeftScroll -= g_sd.xDistance;
+ _scrollPixelsX = _scrollData.xSpeed;
+ _leftScroll -= _scrollData.xDistance;
} else {
- g_scrollPixelsX = SCROLLPIXELS;
- g_LeftScroll = -RLSCROLL;
+ _scrollPixelsX = SCROLLPIXELS;
+ _leftScroll = -RLSCROLL;
}
}
break;
@@ -177,21 +188,21 @@ void Scroll::NeedScroll(int direction) {
BottomLine = Toffset + (SCREEN_HEIGHT - 1);
RightCol = Loffset + (SCREEN_WIDTH - 1);
- for (i = 0; i < g_sd.NumNoV; i++) {
- if ((BottomLine >= g_sd.NoVScroll[i].ln - 1 && BottomLine <= g_sd.NoVScroll[i].ln + 1) &&
- ((g_sd.NoVScroll[i].c1 >= Loffset && g_sd.NoVScroll[i].c1 <= RightCol) ||
- (g_sd.NoVScroll[i].c2 >= Loffset && g_sd.NoVScroll[i].c2 <= RightCol) ||
- (g_sd.NoVScroll[i].c1 < Loffset && g_sd.NoVScroll[i].c2 > RightCol)))
+ for (i = 0; i < _scrollData.NumNoV; i++) {
+ if ((BottomLine >= _scrollData.NoVScroll[i].ln - 1 && BottomLine <= _scrollData.NoVScroll[i].ln + 1) &&
+ ((_scrollData.NoVScroll[i].c1 >= Loffset && _scrollData.NoVScroll[i].c1 <= RightCol) ||
+ (_scrollData.NoVScroll[i].c2 >= Loffset && _scrollData.NoVScroll[i].c2 <= RightCol) ||
+ (_scrollData.NoVScroll[i].c1 < Loffset && _scrollData.NoVScroll[i].c2 > RightCol)))
return;
}
- if (g_DownScroll <= 0) {
+ if (_downScroll <= 0) {
if (TinselV2) {
- g_scrollPixelsY = g_sd.ySpeed;
- g_DownScroll += g_sd.yDistance;
+ _scrollPixelsY = _scrollData.ySpeed;
+ _downScroll += _scrollData.yDistance;
} else {
- g_scrollPixelsY = SCROLLPIXELS;
- g_DownScroll = UDSCROLL;
+ _scrollPixelsY = SCROLLPIXELS;
+ _downScroll = UDSCROLL;
}
}
break;
@@ -200,21 +211,21 @@ void Scroll::NeedScroll(int direction) {
RightCol = Loffset + (SCREEN_WIDTH - 1);
- for (i = 0; i < g_sd.NumNoV; i++) {
- if (Toffset >= g_sd.NoVScroll[i].ln - 1 && Toffset <= g_sd.NoVScroll[i].ln + 1 &&
- ((g_sd.NoVScroll[i].c1 >= Loffset && g_sd.NoVScroll[i].c1 <= RightCol) ||
- (g_sd.NoVScroll[i].c2 >= Loffset && g_sd.NoVScroll[i].c2 <= RightCol) ||
- (g_sd.NoVScroll[i].c1 < Loffset && g_sd.NoVScroll[i].c2 > RightCol)))
+ for (i = 0; i < _scrollData.NumNoV; i++) {
+ if (Toffset >= _scrollData.NoVScroll[i].ln - 1 && Toffset <= _scrollData.NoVScroll[i].ln + 1 &&
+ ((_scrollData.NoVScroll[i].c1 >= Loffset && _scrollData.NoVScroll[i].c1 <= RightCol) ||
+ (_scrollData.NoVScroll[i].c2 >= Loffset && _scrollData.NoVScroll[i].c2 <= RightCol) ||
+ (_scrollData.NoVScroll[i].c1 < Loffset && _scrollData.NoVScroll[i].c2 > RightCol)))
return;
}
- if (g_DownScroll >= 0) {
+ if (_downScroll >= 0) {
if (TinselV2) {
- g_scrollPixelsY = g_sd.ySpeed;
- g_DownScroll -= g_sd.yDistance;
+ _scrollPixelsY = _scrollData.ySpeed;
+ _downScroll -= _scrollData.yDistance;
} else {
- g_scrollPixelsY = SCROLLPIXELS;
- g_DownScroll = -UDSCROLL;
+ _scrollPixelsY = SCROLLPIXELS;
+ _downScroll = -UDSCROLL;
}
}
break;
@@ -232,7 +243,7 @@ void Scroll::ScrollImage() {
int Loffset, Toffset;
int curX, curY;
- if (!g_LeftScroll && !g_DownScroll) // Only scroll if required
+ if (!_leftScroll && !_downScroll) // Only scroll if required
return;
// get background offsets
@@ -241,39 +252,39 @@ void Scroll::ScrollImage() {
/*
* Keeping cursor on a tag?
*/
- if (g_ScrollCursor) {
+ if (_scrollCursor) {
_vm->_cursor->GetCursorXYNoWait(&curX, &curY, true);
if (InPolygon(curX, curY, TAG) != NOPOLY || InPolygon(curX, curY, EXIT) != NOPOLY) {
OldLoffset = Loffset;
OldToffset = Toffset;
} else
- g_ScrollCursor = false;
+ _scrollCursor = false;
}
/*
* Horizontal scrolling
*/
- if (g_LeftScroll > 0) {
- g_LeftScroll -= g_scrollPixelsX;
- if (g_LeftScroll < 0) {
- Loffset += g_LeftScroll;
- g_LeftScroll = 0;
+ if (_leftScroll > 0) {
+ _leftScroll -= _scrollPixelsX;
+ if (_leftScroll < 0) {
+ Loffset += _leftScroll;
+ _leftScroll = 0;
}
- Loffset += g_scrollPixelsX; // Move right
- if (Loffset > g_ImageW - SCREEN_WIDTH)
- Loffset = g_ImageW - SCREEN_WIDTH;// Now at extreme right
+ Loffset += _scrollPixelsX; // Move right
+ if (Loffset > _imageW - SCREEN_WIDTH)
+ Loffset = _imageW - SCREEN_WIDTH;// Now at extreme right
/*** New feature to prop up rickety scroll boundaries ***/
if (TinselV2 && SysVar(SV_MaximumXoffset) && (Loffset > SysVar(SV_MaximumXoffset)))
Loffset = SysVar(SV_MaximumXoffset);
- } else if (g_LeftScroll < 0) {
- g_LeftScroll += g_scrollPixelsX;
- if (g_LeftScroll > 0) {
- Loffset += g_LeftScroll;
- g_LeftScroll = 0;
+ } else if (_leftScroll < 0) {
+ _leftScroll += _scrollPixelsX;
+ if (_leftScroll > 0) {
+ Loffset += _leftScroll;
+ _leftScroll = 0;
}
- Loffset -= g_scrollPixelsX; // Move left
+ Loffset -= _scrollPixelsX; // Move left
if (Loffset < 0)
Loffset = 0; // Now at extreme left
@@ -285,28 +296,28 @@ void Scroll::ScrollImage() {
/*
* Vertical scrolling
*/
- if (g_DownScroll > 0) {
- g_DownScroll -= g_scrollPixelsY;
- if (g_DownScroll < 0) {
- Toffset += g_DownScroll;
- g_DownScroll = 0;
+ if (_downScroll > 0) {
+ _downScroll -= _scrollPixelsY;
+ if (_downScroll < 0) {
+ Toffset += _downScroll;
+ _downScroll = 0;
}
- Toffset += g_scrollPixelsY; // Move down
+ Toffset += _scrollPixelsY; // Move down
- if (Toffset > g_ImageH - SCREEN_HEIGHT)
- Toffset = g_ImageH - SCREEN_HEIGHT;// Now at extreme bottom
+ if (Toffset > _imageH - SCREEN_HEIGHT)
+ Toffset = _imageH - SCREEN_HEIGHT;// Now at extreme bottom
/*** New feature to prop up rickety scroll boundaries ***/
if (TinselV2 && SysVar(SV_MaximumYoffset) && Toffset > SysVar(SV_MaximumYoffset))
Toffset = SysVar(SV_MaximumYoffset);
- } else if (g_DownScroll < 0) {
- g_DownScroll += g_scrollPixelsY;
- if (g_DownScroll > 0) {
- Toffset += g_DownScroll;
- g_DownScroll = 0;
+ } else if (_downScroll < 0) {
+ _downScroll += _scrollPixelsY;
+ if (_downScroll > 0) {
+ Toffset += _downScroll;
+ _downScroll = 0;
}
- Toffset -= g_scrollPixelsY; // Move up
+ Toffset -= _scrollPixelsY; // Move up
if (Toffset < 0)
Toffset = 0; // Now at extreme top
@@ -319,7 +330,7 @@ void Scroll::ScrollImage() {
/*
* Move cursor if keeping cursor on a tag.
*/
- if (g_ScrollCursor)
+ if (_scrollCursor)
_vm->_cursor->AdjustCursorXY(OldLoffset - Loffset, OldToffset - Toffset);
_vm->_bg->PlayfieldSetPos(FIELD_WORLD, Loffset, Toffset);
@@ -337,12 +348,12 @@ void Scroll::MonitorScroll() {
/*
* Only do it if the actor is there and is visible
*/
- if (!g_pScrollMover || MoverHidden(g_pScrollMover) || !MoverIs(g_pScrollMover))
+ if (!_pScrollMover || MoverHidden(_pScrollMover) || !MoverIs(_pScrollMover))
return;
- _vm->_actor->GetActorPos(g_scrollActor, &newx, &newy);
+ _vm->_actor->GetActorPos(_scrollActor, &newx, &newy);
- if (g_oldx == newx && g_oldy == newy)
+ if (_oldx == newx && _oldy == newy)
return;
_vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
@@ -350,49 +361,49 @@ void Scroll::MonitorScroll() {
/*
* Approaching right side or left side of the screen?
*/
- if (newx > Loffset+SCREEN_WIDTH - RLDISTANCE && Loffset < g_ImageW - SCREEN_WIDTH) {
- if (newx > g_oldx)
+ if (newx > Loffset+SCREEN_WIDTH - RLDISTANCE && Loffset < _imageW - SCREEN_WIDTH) {
+ if (newx > _oldx)
NeedScroll(LEFT);
} else if (newx < Loffset + RLDISTANCE && Loffset) {
- if (newx < g_oldx)
+ if (newx < _oldx)
NeedScroll(RIGHT);
}
/*
* Approaching bottom or top of the screen?
*/
- if (newy > Toffset+SCREEN_HEIGHT-DDISTANCE && Toffset < g_ImageH-SCREEN_HEIGHT) {
- if (newy > g_oldy)
+ if (newy > Toffset+SCREEN_HEIGHT-DDISTANCE && Toffset < _imageH-SCREEN_HEIGHT) {
+ if (newy > _oldy)
NeedScroll(UP);
- } else if (Toffset && newy < Toffset + UDISTANCE + _vm->_actor->GetActorBottom(g_scrollActor) - _vm->_actor->GetActorTop(g_scrollActor)) {
- if (newy < g_oldy)
+ } else if (Toffset && newy < Toffset + UDISTANCE + _vm->_actor->GetActorBottom(_scrollActor) - _vm->_actor->GetActorTop(_scrollActor)) {
+ if (newy < _oldy)
NeedScroll(DOWN);
}
- g_oldx = newx;
- g_oldy = newy;
+ _oldx = newx;
+ _oldy = newy;
}
void Scroll::RestoreScrollDefaults() {
- g_sd.xTrigger = SysVar(SV_SCROLL_XTRIGGER);
- g_sd.xDistance = SysVar(SV_SCROLL_XDISTANCE);
- g_sd.xSpeed = SysVar(SV_SCROLL_XSPEED);
- g_sd.yTriggerTop = SysVar(SV_SCROLL_YTRIGGERTOP);
- g_sd.yTriggerBottom= SysVar(SV_SCROLL_YTRIGGERBOT);
- g_sd.yDistance = SysVar(SV_SCROLL_YDISTANCE);
- g_sd.ySpeed = SysVar(SV_SCROLL_YSPEED);
+ _scrollData.xTrigger = SysVar(SV_SCROLL_XTRIGGER);
+ _scrollData.xDistance = SysVar(SV_SCROLL_XDISTANCE);
+ _scrollData.xSpeed = SysVar(SV_SCROLL_XSPEED);
+ _scrollData.yTriggerTop = SysVar(SV_SCROLL_YTRIGGERTOP);
+ _scrollData.yTriggerBottom= SysVar(SV_SCROLL_YTRIGGERBOT);
+ _scrollData.yDistance = SysVar(SV_SCROLL_YDISTANCE);
+ _scrollData.ySpeed = SysVar(SV_SCROLL_YSPEED);
}
/**
* Does the obvious - called at the end of a scene.
*/
void Scroll::DropScroll() {
- g_sd.NumNoH = g_sd.NumNoV = 0;
+ _scrollData.NumNoH = _scrollData.NumNoV = 0;
if (TinselV2) {
- g_LeftScroll = g_DownScroll = 0; // No iterations outstanding
- g_oldx = g_oldy = 0;
- g_scrollPixelsX = g_sd.xSpeed;
- g_scrollPixelsY = g_sd.ySpeed;
+ _leftScroll = _downScroll = 0; // No iterations outstanding
+ _oldx = _oldy = 0;
+ _scrollPixelsX = _scrollData.xSpeed;
+ _scrollPixelsY = _scrollData.ySpeed;
RestoreScrollDefaults();
}
}
@@ -401,11 +412,11 @@ void Scroll::DropScroll() {
* Change which actor the camera is following.
*/
void Scroll::ScrollFocus(int ano) {
- if (g_scrollActor != ano) {
- g_oldx = g_oldy = 0;
- g_scrollActor = ano;
+ if (_scrollActor != ano) {
+ _oldx = _oldy = 0;
+ _scrollActor = ano;
- g_pScrollMover = ano ? GetMover(g_scrollActor) : NULL;
+ _pScrollMover = ano ? GetMover(_scrollActor) : NULL;
}
}
@@ -413,7 +424,7 @@ void Scroll::ScrollFocus(int ano) {
* Returns the actor which the camera is following
*/
int Scroll::GetScrollFocus() {
- return g_scrollActor;
+ return _scrollActor;
}
/**
@@ -422,28 +433,28 @@ int Scroll::GetScrollFocus() {
void Scroll::ScrollTo(int x, int y, int xIter, int yIter) {
int Loffset, Toffset; // for background offsets
- g_scrollPixelsX = xIter != 0 ? xIter : (TinselV2 ? g_sd.xSpeed : SCROLLPIXELS);
- g_scrollPixelsY = yIter != 0 ? yIter : (TinselV2 ? g_sd.ySpeed : SCROLLPIXELS);
+ _scrollPixelsX = xIter != 0 ? xIter : (TinselV2 ? _scrollData.xSpeed : SCROLLPIXELS);
+ _scrollPixelsY = yIter != 0 ? yIter : (TinselV2 ? _scrollData.ySpeed : SCROLLPIXELS);
_vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); // get background offsets
- g_LeftScroll = x - Loffset;
- g_DownScroll = y - Toffset;
+ _leftScroll = x - Loffset;
+ _downScroll = y - Toffset;
}
/**
* Kill of any current scroll.
*/
void Scroll::KillScroll() {
- g_LeftScroll = g_DownScroll = 0;
+ _leftScroll = _downScroll = 0;
}
void Scroll::GetNoScrollData(SCROLLDATA *ssd) {
- memcpy(ssd, &g_sd, sizeof(SCROLLDATA));
+ memcpy(ssd, &_scrollData, sizeof(SCROLLDATA));
}
void Scroll::RestoreNoScrollData(SCROLLDATA *ssd) {
- memcpy(&g_sd, ssd, sizeof(SCROLLDATA));
+ memcpy(&_scrollData, ssd, sizeof(SCROLLDATA));
}
/**
@@ -457,40 +468,40 @@ void Scroll::SetScrollParameters(int xTrigger, int xDistance, int xSpeed, int yT
RestoreScrollDefaults();
} else {
if (xTrigger)
- g_sd.xTrigger = xTrigger;
+ _scrollData.xTrigger = xTrigger;
if (xDistance)
- g_sd.xDistance = xDistance;
+ _scrollData.xDistance = xDistance;
if (xSpeed)
- g_sd.xSpeed = xSpeed;
+ _scrollData.xSpeed = xSpeed;
if (yTriggerTop)
- g_sd.yTriggerTop = yTriggerTop;
+ _scrollData.yTriggerTop = yTriggerTop;
if (yTriggerBottom)
- g_sd.yTriggerBottom = yTriggerBottom;
+ _scrollData.yTriggerBottom = yTriggerBottom;
if (yDistance)
- g_sd.yDistance = yDistance;
+ _scrollData.yDistance = yDistance;
if (ySpeed)
- g_sd.ySpeed = ySpeed;
+ _scrollData.ySpeed = ySpeed;
}
}
bool Scroll::IsScrolling() {
- return (g_LeftScroll || g_DownScroll);
+ return (_leftScroll || _downScroll);
}
void Scroll::InitScroll(int width, int height) {
- g_ImageH = height; // Dimensions
- g_ImageW = width; // of this scene.
+ _imageH = height; // Dimensions
+ _imageW = width; // of this scene.
if (!TinselV2) {
- g_LeftScroll = g_DownScroll = 0; // No iterations outstanding
- g_oldx = g_oldy = 0;
- g_scrollPixelsX = g_scrollPixelsY = SCROLLPIXELS;
+ _leftScroll = _downScroll = 0; // No iterations outstanding
+ _oldx = _oldy = 0;
+ _scrollPixelsX = _scrollPixelsY = SCROLLPIXELS;
}
- if (!g_scrollActor)
- g_scrollActor = _vm->_actor->GetLeadId();
+ if (!_scrollActor)
+ _scrollActor = _vm->_actor->GetLeadId();
- g_pScrollMover = GetMover(g_scrollActor);
+ _pScrollMover = GetMover(_scrollActor);
}
/**
diff --git a/engines/tinsel/scroll.h b/engines/tinsel/scroll.h
index a36e7bcdbe..00ffe0bab6 100644
--- a/engines/tinsel/scroll.h
+++ b/engines/tinsel/scroll.h
@@ -25,16 +25,8 @@
namespace Tinsel {
-#define SCROLLPIXELS 8 // Number of pixels to scroll per iteration
-
-// Distance from edge that triggers a scroll
-#define RLDISTANCE (TinselV2 ? g_sd.xTrigger : 50)
-#define UDISTANCE (TinselV2 ? g_sd.yTriggerTop : 20)
-#define DDISTANCE (TinselV2 ? g_sd.yTriggerBottom : 20)
-
-// Number of iterations to make
-#define RLSCROLL 160 // 20*8 = 160 = half a screen
-#define UDSCROLL 100 // 12.5*8 = 100 = half a screen
+#define MAX_HNOSCROLL 10
+#define MAX_VNOSCROLL 10
// These structures defined here so boundaries can be saved
struct NOSCROLLB {
@@ -43,9 +35,6 @@ struct NOSCROLLB {
int c2;
};
-#define MAX_HNOSCROLL 10
-#define MAX_VNOSCROLL 10
-
struct SCROLLDATA {
NOSCROLLB NoVScroll[MAX_VNOSCROLL]; // Vertical no-scroll boundaries
NOSCROLLB NoHScroll[MAX_HNOSCROLL]; // Horizontal no-scroll boundaries
@@ -93,23 +82,22 @@ private:
void NeedScroll(int direction);
void RestoreScrollDefaults();
- int g_LeftScroll, g_DownScroll; // Number of iterations outstanding
+ int _leftScroll, _downScroll; // Number of iterations outstanding
- int g_scrollActor;
- PMOVER g_pScrollMover;
- int g_oldx, g_oldy;
+ int _scrollActor;
+ PMOVER _pScrollMover;
+ int _oldx, _oldy;
/** Boundaries and numbers of boundaries */
- SCROLLDATA g_sd;
+ SCROLLDATA _scrollData;
- int g_ImageH, g_ImageW;
+ int _imageW, _imageH;
- bool g_ScrollCursor; // If a TAG or EXIT polygon is clicked on,
+ bool _scrollCursor; // If a TAG or EXIT polygon is clicked on,
// the cursor is kept over that polygon
// whilst scrolling
- int g_scrollPixelsX;
- int g_scrollPixelsY;
+ int _scrollPixelsX, _scrollPixelsY;
};
void ScrollProcess(CORO_PARAM, const void *);
Commit: 672ab3cca376ab398d8b1a31371b3ca18a9c0891
https://github.com/scummvm/scummvm/commit/672ab3cca376ab398d8b1a31371b3ca18a9c0891
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-10-04T01:15:21+03:00
Commit Message:
TINSEL: Clear some more vars upon engine destruction
Changed paths:
engines/tinsel/tinsel.cpp
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index 7cc86ed9fe..8e3a472620 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -87,7 +87,7 @@ void SetNewScene(SCNHANDLE scene, int entrance, int transition);
//----------------- GLOBAL GLOBAL DATA --------------------
-// FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
bool g_bRestart = false;
bool g_bHasRestarted = false;
@@ -97,6 +97,9 @@ static bool g_bCuttingScene = false;
static bool g_bChangingForRestore = false;
+// FIXME: CountOut is used by ChangeScene
+static int CountOut = 1; // == 1 for immediate start of first scene
+
#ifdef DEBUG
bool g_bFast; // set to make it go ludicrously fast
#endif
@@ -113,8 +116,8 @@ static Scene g_NextScene = { 0, 0, 0 };
static Scene g_HookScene = { 0, 0, 0 };
static Scene g_DelayedScene = { 0, 0, 0 };
-static Common::PROCESS *g_pMouseProcess = 0;
-static Common::PROCESS *g_pKeyboardProcess = 0;
+static Common::PROCESS *g_pMouseProcess = nullptr;
+static Common::PROCESS *g_pKeyboardProcess = nullptr;
static SCNHANDLE g_hCdChangeScene;
@@ -633,10 +636,6 @@ void RestoreMasterProcess(INT_CONTEXT *pic) {
CoroScheduler.createProcess(PID_MASTER_SCR, RestoredProcess, &pic, sizeof(pic));
}
-// FIXME: CountOut is used by ChangeScene
-// FIXME: Avoid non-const global vars
-static int CountOut = 1; // == 1 for immediate start of first scene
-
/**
* If a scene restore is going on, just return (we don't update the
* screen during this time).
@@ -766,6 +765,27 @@ void LoadBasicChunks() {
}
}
+void ResetVarsTinsel() {
+ g_bRestart = false;
+ g_bHasRestarted = false;
+ g_loadingFromGMM = false;
+
+ g_bCuttingScene = false;
+
+ g_bChangingForRestore = false;
+
+ CountOut = 1;
+
+ g_NextScene = {0, 0, 0};
+ g_HookScene = {0, 0, 0};
+ g_DelayedScene = {0, 0, 0};
+
+ g_pMouseProcess = nullptr;
+ g_pKeyboardProcess = nullptr;
+
+ g_hCdChangeScene = 0;
+}
+
//----------------- TinselEngine --------------------
// Global pointer to engine
@@ -904,7 +924,7 @@ TinselEngine::~TinselEngine() {
FreeAllTokens(); // token.cpp
RebootTimers(); // timers.cpp
ResetVarsTinlib(); // tinlib.cpp
- // TODO: tinsel.cpp
+ ResetVarsTinsel(); // tinsel.cpp
}
Common::String TinselEngine::getSavegameFilename(int16 saveNum) const {
Commit: 05e7af7c65d59bdf5d02c266f7eae6d2c368d5a6
https://github.com/scummvm/scummvm/commit/05e7af7c65d59bdf5d02c266f7eae6d2c368d5a6
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-10-04T01:15:21+03:00
Commit Message:
TINSEL: Reset more global vars upon engine destruction
Changed paths:
engines/tinsel/scene.cpp
engines/tinsel/sched.cpp
engines/tinsel/strres.cpp
engines/tinsel/tinsel.cpp
diff --git a/engines/tinsel/scene.cpp b/engines/tinsel/scene.cpp
index 485976e7ec..2c6005cbbc 100644
--- a/engines/tinsel/scene.cpp
+++ b/engines/tinsel/scene.cpp
@@ -101,14 +101,14 @@ struct ENTRANCE_STRUC {
//----------------- LOCAL GLOBAL DATA --------------------
-// FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
#ifdef DEBUG
static bool g_ShowPosition = false; // Set when showpos() has been called
#endif
int g_sceneCtr = 0;
-static int g_initialMyEscape;
+static int g_initialMyEscape = 0;
static SCNHANDLE g_SceneHandle = 0; // Current scene handle - stored in case of Save_Scene()
@@ -119,6 +119,15 @@ struct TP_INIT {
TINSEL_EVENT event; // Triggering event
};
+void ResetVarsScene() {
+ g_sceneCtr = 0;
+ g_initialMyEscape = 0;
+
+ g_SceneHandle = 0;
+
+ memset(&g_tempStruc, 0, sizeof(SCENE_STRUC));
+}
+
const SCENE_STRUC *GetSceneStruc(const byte *pStruc) {
if (TinselVersion == TINSEL_V2)
return (const SCENE_STRUC *)pStruc;
diff --git a/engines/tinsel/sched.cpp b/engines/tinsel/sched.cpp
index 59de7ed476..5f15926639 100644
--- a/engines/tinsel/sched.cpp
+++ b/engines/tinsel/sched.cpp
@@ -43,19 +43,27 @@ struct PROCESS_STRUC {
//----------------- LOCAL GLOBAL DATA --------------------
-// FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
-static uint32 g_numSceneProcess;
-static SCNHANDLE g_hSceneProcess;
+static uint32 g_numSceneProcess = 0;
+static SCNHANDLE g_hSceneProcess = 0;
-static uint32 g_numGlobalProcess;
-static PROCESS_STRUC *g_pGlobalProcess;
+static uint32 g_numGlobalProcess = 0;
+static PROCESS_STRUC *g_pGlobalProcess = nullptr;
/**************************************************************************\
|*********** Stuff to do with scene and global processes ************|
\**************************************************************************/
+void ResetVarsSched() {
+ g_numSceneProcess = 0;
+ g_hSceneProcess = 0;
+
+ g_numGlobalProcess = 0;
+ g_pGlobalProcess = nullptr;
+}
+
/**
* The code for for restored scene processes.
*/
diff --git a/engines/tinsel/strres.cpp b/engines/tinsel/strres.cpp
index e31e3c2a22..45b0b47e5c 100644
--- a/engines/tinsel/strres.cpp
+++ b/engines/tinsel/strres.cpp
@@ -34,7 +34,7 @@
namespace Tinsel {
-// FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
#ifdef DEBUG
// Diagnostic number
@@ -42,7 +42,7 @@ int g_newestString;
#endif
// buffer for resource strings
-static uint8 *g_textBuffer = 0;
+static uint8 *g_textBuffer = nullptr;
static struct {
bool bPresent;
@@ -77,6 +77,12 @@ LANGUAGE g_textLanguage, g_sampleLanguage = TXT_ENGLISH;
//----------------- FUNCTIONS --------------------------------
+void ResetVarsStrRes() {
+ g_textBuffer = nullptr;
+ g_bMultiByte = false;
+ g_textLanguage = g_sampleLanguage = TXT_ENGLISH;
+}
+
/**
* Called to load a resource file for a different language
* @param newLang The new language
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index 8e3a472620..9147a0aeaf 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -77,6 +77,9 @@ extern void ResetVarsDrives();
extern void ResetVarsEvents();
extern void RebootScalingReels();
extern void RebootMovers();
+extern void ResetVarsScene();
+extern void ResetVarsSched();
+extern void ResetVarsStrRes();
extern void FreeTextBuffer();
extern void FreeAllTokens();
extern void RebootTimers();
@@ -916,9 +919,9 @@ TinselEngine::~TinselEngine() {
RebootMovers(); // rince.cpp
// TODO: saveload.cpp
// TODO: savescn.cpp
- // TODO: scene.cpp
- // TODO: sched.cpp
- // TODO: strres.cpp
+ ResetVarsScene(); // scene.cpp
+ ResetVarsSched(); // sched.cpp
+ ResetVarsStrRes(); // strres.cpp
FreeTextBuffer(); // strres.cpp
// TODO: sysvar.cpp
FreeAllTokens(); // token.cpp
Commit: 9c9fc0cf2ba62d2524403c516dcde0240cdd35df
https://github.com/scummvm/scummvm/commit/9c9fc0cf2ba62d2524403c516dcde0240cdd35df
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-10-04T01:15:22+03:00
Commit Message:
TINSEL: Reset more global vars upon engine destruction
Changed paths:
engines/tinsel/palette.cpp
engines/tinsel/pcode.cpp
engines/tinsel/pdisplay.cpp
engines/tinsel/play.cpp
engines/tinsel/saveload.cpp
engines/tinsel/savescn.cpp
engines/tinsel/sysvar.cpp
engines/tinsel/tinsel.cpp
diff --git a/engines/tinsel/palette.cpp b/engines/tinsel/palette.cpp
index 03a3028ad7..54475a0630 100644
--- a/engines/tinsel/palette.cpp
+++ b/engines/tinsel/palette.cpp
@@ -49,36 +49,33 @@ struct VIDEO_DAC_Q {
};
+/** video DAC transfer Q length */
+#define VDACQLENGTH (NUM_PALETTES + 2)
+
+/** color index of the 4 colors used for the translucent palette */
+#define COL_HILIGHT TBLUE1
+
//----------------- LOCAL GLOBAL DATA --------------------
-// FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
/** palette allocator data */
static PALQ g_palAllocData[NUM_PALETTES];
-
-/** video DAC transfer Q length */
-#define VDACQLENGTH (NUM_PALETTES+2)
-
/** video DAC transfer Q */
static VIDEO_DAC_Q g_vidDACdata[VDACQLENGTH];
/** video DAC transfer Q head pointer */
static VIDEO_DAC_Q *g_pDAChead;
-/** color index of the 4 colors used for the translucent palette */
-#define COL_HILIGHT TBLUE1
-
/** the translucent palette lookup table */
uint8 g_transPalette[MAX_COLORS]; // used in graphics.cpp
static int g_translucentIndex = 228;
-
static int g_talkIndex = 233;
-static COLORREF g_talkColRef;
-
-static COLORREF g_tagColRef;
+static COLORREF g_talkColRef = 0;
+static COLORREF g_tagColRef = 0;
#ifdef DEBUG
@@ -88,6 +85,20 @@ static int maxPals = 0;
static int maxDACQ = 0;
#endif
+void ResetVarsPalette() {
+ memset(g_palAllocData, 0, sizeof(g_palAllocData));
+
+ g_pDAChead = g_vidDACdata;
+
+ memset(g_transPalette, 0, sizeof(g_transPalette));
+
+ g_translucentIndex = 228;
+ g_talkIndex = 233;
+
+ g_talkColRef = 0;
+ g_tagColRef = 0;
+}
+
/**
* Map PSX palettes to original palette from resource file
*/
diff --git a/engines/tinsel/pcode.cpp b/engines/tinsel/pcode.cpp
index cdf8ec717b..d87cccaac6 100644
--- a/engines/tinsel/pcode.cpp
+++ b/engines/tinsel/pcode.cpp
@@ -100,11 +100,11 @@ enum OPCODE {
#define OPMASK 0x3F ///< mask to isolate the opcode
-bool g_bNoPause = false;
-
//----------------- LOCAL GLOBAL DATA --------------------
-// FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
+
+bool g_bNoPause = false;
static int32 *g_pGlobals = 0; // global vars
@@ -233,7 +233,19 @@ const WorkaroundEntry workaroundList[] = {
{TINSEL_V0, false, false, Common::kPlatformUnknown, 0, 0, 0, NULL}
};
-//----------------- LOCAL GLOBAL DATA --------------------
+void ResetVarsPCode() {
+ g_bNoPause = false;
+
+ free(g_pGlobals);
+ g_pGlobals = nullptr;
+
+ g_numGlobals = 0;
+
+ free(g_icList);
+ g_icList = nullptr;
+
+ g_hMasterScript = 0;
+}
/**
* Keeps the code array pointer up to date.
@@ -420,7 +432,7 @@ INT_CONTEXT *RestoreInterpretContext(INT_CONTEXT *ric) {
* Allocates enough RAM to hold the global Glitter variables.
*/
void RegisterGlobals(int num) {
- if (g_pGlobals == NULL) {
+ if (g_pGlobals == nullptr) {
g_numGlobals = num;
g_hMasterScript = !TinselV2 ? 0 :
@@ -428,13 +440,13 @@ void RegisterGlobals(int num) {
// Allocate RAM for pGlobals and make sure it's allocated
g_pGlobals = (int32 *)calloc(g_numGlobals, sizeof(int32));
- if (g_pGlobals == NULL) {
+ if (g_pGlobals == nullptr) {
error("Cannot allocate memory for global data");
}
// Allocate RAM for interpret contexts and make sure it's allocated
g_icList = (INT_CONTEXT *)calloc(NUM_INTERPRET, sizeof(INT_CONTEXT));
- if (g_icList == NULL) {
+ if (g_icList == nullptr) {
error("Cannot allocate memory for interpret contexts");
}
CoroScheduler.setResourceCallback(FreeInterpretContextPr);
diff --git a/engines/tinsel/pdisplay.cpp b/engines/tinsel/pdisplay.cpp
index afe5683409..f976db06cd 100644
--- a/engines/tinsel/pdisplay.cpp
+++ b/engines/tinsel/pdisplay.cpp
@@ -71,7 +71,7 @@ enum HotSpotTag {
//----------------- LOCAL GLOBAL DATA --------------------
-// FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
static bool g_DispPath = false;
static bool g_bShowString = false;
@@ -82,8 +82,25 @@ static HPOLYGON g_hTaggedPolygon = NOPOLY;
static bool g_bTagsActive = true;
static bool g_bPointingActive = true;
+static int tagX = 0, tagY = 0; // Values when tag was displayed
+static int Loffset = 0, Toffset = 0; // Values when tag was displayed
+static int curX = 0, curY = 0;
-static char g_tagBuffer[64];
+void ResetVarsPDisplay() {
+ g_DispPath = false;
+ g_bShowString = false;
+
+ g_TaggedActor = 0;
+ g_hTaggedPolygon = NOPOLY;
+
+ g_bTagsActive = true;
+
+ g_bPointingActive = true;
+
+ tagX = tagY = 0;
+ Loffset = Toffset = 0;
+ curX = curY = 0;
+}
#ifdef DEBUG
/**
@@ -376,12 +393,11 @@ static bool InHotSpot(int ano, int aniX, int aniY, int *pxtext, int *pytext) {
* the screen.
*/
static bool ActorTag(int curX, int curY, HotSpotTag *pTag, OBJECT **ppText) {
- // FIXME: Avoid non-const global vars
- static int tagX = 0, tagY = 0; // Values when tag was displayed
int newX, newY; // new values, to keep tag in place
int ano;
int xtext, ytext;
bool newActor;
+ char tagBuffer[64];
if (TinselV2) {
// Tinsel 2 version
@@ -405,11 +421,11 @@ static bool ActorTag(int curX, int curY, HotSpotTag *pTag, OBJECT **ppText) {
if (_vm->_actor->ActorTagIsWanted(actor)) {
_vm->_actor->GetActorTagPos(actor, &tagX, &tagY, false);
- LoadStringRes(_vm->_actor->GetActorTagHandle(actor), g_tagBuffer, sizeof(g_tagBuffer));
+ LoadStringRes(_vm->_actor->GetActorTagHandle(actor), tagBuffer, sizeof(tagBuffer));
// May have buggered cursor
_vm->_cursor->EndCursorFollowed();
- *ppText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_tagBuffer,
+ *ppText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), tagBuffer,
0, tagX, tagY, _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
assert(*ppText);
MultiSetZPosition(*ppText, Z_TAG_TEXT);
@@ -488,9 +504,6 @@ static bool ActorTag(int curX, int curY, HotSpotTag *pTag, OBJECT **ppText) {
* code contains a printtag() call, its tagState flag gets set to TAG_ON.
*/
static bool PolyTag(HotSpotTag *pTag, OBJECT **ppText) {
- // FIXME: Avoid non-const global vars
- static int Loffset = 0, Toffset = 0; // Values when tag was displayed
- static int curX = 0, curY = 0;
int nLoff, nToff; // new values, to keep tag in place
HPOLYGON hp;
bool newPoly;
diff --git a/engines/tinsel/play.cpp b/engines/tinsel/play.cpp
index 1191a0394c..4325448c70 100644
--- a/engines/tinsel/play.cpp
+++ b/engines/tinsel/play.cpp
@@ -60,15 +60,29 @@ struct PPINIT {
//----------------- LOCAL GLOBAL DATA --------------------
-// FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
static SOUNDREELS g_soundReels[MAX_SOUNDREELS];
static int g_soundReelNumbers[MAX_SOUNDREELS];
static int g_soundReelWait;
+static int firstColZ = 0; // Z-position of column zero
+static int32 fColZfactor = 0; // Z-factor of column zero's actor
+static int baseZposn; // Z-position of column zero
+static uint32 baseZfact; // Z-factor of column zero's actor
//-------------------- METHODS ----------------------
+void ResetVarsPlay() {
+ memset(g_soundReels, 0, sizeof(g_soundReels));
+ memset(g_soundReelNumbers, 0, sizeof(g_soundReelNumbers));
+ g_soundReelWait = 0;
+ firstColZ = 0;
+ fColZfactor = 0;
+ baseZposn = 0;
+ baseZfact = 0;
+}
+
/**
* Poke the background palette into an image.
*/
@@ -434,10 +448,6 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) {
int tmpX, tmpY;
CORO_END_CONTEXT(_ctx);
- // FIXME: Avoid non-const global vars
- static int firstColZ = 0; // Z-position of column zero
- static int32 fColZfactor = 0; // Z-factor of column zero's actor
-
CORO_BEGIN_CODE(_ctx);
const MULTI_INIT *pmi; // MULTI_INIT structure
@@ -821,10 +831,6 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA
SoundReelWaitCheck();
} else {
- // FIXME: Avoid non-const global vars
- static int baseZposn; // Z-position of column zero
- static uint32 baseZfact; // Z-factor of column zero's actor
-
// N.B. It HAS been ensured that the first column gets here first
if ((int32)FROM_32(_ctx->pmi->mulZ) != -1) {
diff --git a/engines/tinsel/saveload.cpp b/engines/tinsel/saveload.cpp
index aff2e8a7f4..f8cf6d8283 100644
--- a/engines/tinsel/saveload.cpp
+++ b/engines/tinsel/saveload.cpp
@@ -57,12 +57,6 @@ namespace Tinsel {
*/
#define CURRENT_VER 3
-//----------------- GLOBAL GLOBAL DATA --------------------
-
-int g_thingHeld = 0;
-int g_restoreCD = 0;
-SRSTATE g_SRstate = SR_IDLE;
-
//----------------- EXTERN FUNCTIONS --------------------
// in DOS_DW.C
@@ -112,24 +106,48 @@ struct SFILES {
TimeDate dateTime;
};
+//----------------- GLOBAL GLOBAL DATA --------------------
+
+int g_thingHeld = 0;
+int g_restoreCD = 0;
+SRSTATE g_SRstate = SR_IDLE;
+
//----------------- LOCAL GLOBAL DATA --------------------
-// FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
static int g_numSfiles = 0;
static SFILES g_savedFiles[MAX_SAVED_FILES];
static bool g_NeedLoad = true;
-static SAVED_DATA *g_srsd = 0;
+static SAVED_DATA *g_srsd = nullptr;
static int g_RestoreGameNumber = 0;
-static char *g_SaveSceneName = 0;
-static const char *g_SaveSceneDesc = 0;
+static char *g_SaveSceneName = nullptr;
+static const char *g_SaveSceneDesc = nullptr;
static int *g_SaveSceneSsCount = 0;
-static SAVED_DATA *g_SaveSceneSsData = 0; // points to 'SAVED_DATA ssdata[MAX_NEST]'
+static SAVED_DATA *g_SaveSceneSsData = nullptr; // points to 'SAVED_DATA ssdata[MAX_NEST]'
//------------- SAVE/LOAD SUPPORT METHODS ----------------
+void ResetVarsSaveLoad() {
+ g_thingHeld = 0;
+ g_restoreCD = 0;
+ g_SRstate = SR_IDLE;
+
+ g_numSfiles = 0;
+ memset(g_savedFiles, 0, sizeof(g_savedFiles));
+
+ g_NeedLoad = true;
+
+ g_srsd = nullptr;
+ g_RestoreGameNumber = 0;
+ g_SaveSceneName = nullptr;
+ g_SaveSceneDesc = nullptr;
+ g_SaveSceneSsCount = 0;
+ g_SaveSceneSsData = nullptr;
+}
+
void setNeedLoad() {
g_NeedLoad = true;
}
diff --git a/engines/tinsel/savescn.cpp b/engines/tinsel/savescn.cpp
index 6d1908ab31..4ad4af1d54 100644
--- a/engines/tinsel/savescn.cpp
+++ b/engines/tinsel/savescn.cpp
@@ -77,7 +77,7 @@ extern SRSTATE g_SRstate;
//----------------- LOCAL GLOBAL DATA --------------------
-// FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
bool g_ASceneIsSaved = false;
@@ -85,17 +85,30 @@ static int g_savedSceneCount = 0;
static bool g_bNotDoneYet = false;
-//static SAVED_DATA ssData[MAX_NEST];
static SAVED_DATA *g_ssData = nullptr;
static SAVED_DATA g_sgData;
-
-static SAVED_DATA *g_rsd = 0;
+static SAVED_DATA *g_rsd = nullptr;
static int g_RestoreSceneCount = 0;
static bool g_bNoFade = false;
-//----------------- FORWARD REFERENCES --------------------
+void ResetVarsSaveScn() {
+ g_ASceneIsSaved = false;
+
+ g_savedSceneCount = 0;
+
+ g_bNotDoneYet = false;
+
+ free(g_ssData);
+ g_ssData = nullptr;
+
+ memset(&g_sgData, 0, sizeof(g_sgData));
+ g_rsd = nullptr;
+
+ g_RestoreSceneCount = 0;
+ g_bNoFade = false;
+}
/**
* Save current scene.
diff --git a/engines/tinsel/sysvar.cpp b/engines/tinsel/sysvar.cpp
index 6244c5c4d5..3495935676 100644
--- a/engines/tinsel/sysvar.cpp
+++ b/engines/tinsel/sysvar.cpp
@@ -107,8 +107,6 @@ static int g_systemVars[SV_TOPVALID] = {
static SCNHANDLE g_systemStrings[SS_MAX_VALID]; // FIXME: Avoid non-const global vars
-//static bool bFlagNoBlocking = false;
-
//----------------- FUNCTIONS --------------------------------
/**
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index 9147a0aeaf..8b7dac4e60 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -76,7 +76,13 @@ extern SCNHANDLE GetSceneHandle();
extern void ResetVarsDrives();
extern void ResetVarsEvents();
extern void RebootScalingReels();
+extern void ResetVarsPalette();
+extern void ResetVarsPCode();
+extern void ResetVarsPDisplay();
+extern void ResetVarsPlay();
extern void RebootMovers();
+extern void ResetVarsSaveLoad();
+extern void ResetVarsSaveScn();
extern void ResetVarsScene();
extern void ResetVarsSched();
extern void ResetVarsStrRes();
@@ -911,14 +917,14 @@ TinselEngine::~TinselEngine() {
RebootScalingReels(); // mareels.cpp
// TODO: move.cpp
// TODO: object.cpp
- // TODO: palette.cpp
- // TODO: pcode.cpp
- // TODO: pdisplay.cpp
- // TODO: play.cpp
+ ResetVarsPalette(); // palette.cpp
+ ResetVarsPCode();
+ ResetVarsPDisplay(); // pdisplay.cpp
+ ResetVarsPlay(); // play.cpp
// TODO: polygons.cpp
RebootMovers(); // rince.cpp
- // TODO: saveload.cpp
- // TODO: savescn.cpp
+ ResetVarsSaveLoad();
+ ResetVarsSaveScn(); // savescn.cpp
ResetVarsScene(); // scene.cpp
ResetVarsSched(); // sched.cpp
ResetVarsStrRes(); // strres.cpp
@@ -936,7 +942,7 @@ Common::String TinselEngine::getSavegameFilename(int16 saveNum) const {
void TinselEngine::initializePath(const Common::FSNode &gamePath) {
if (TinselV1PSX) {
- // Add subfolders needed for psx versions of Discworld 1
+ // Add subfolders needed for PSX versions of Discworld 1
SearchMan.addDirectory(gamePath.getPath(), gamePath, 0, 3, true);
} else {
// Add DW2 subfolder to search path in case user is running directly from the CDs
Commit: ae91b7e056852956c88352d782fac1988ccd564d
https://github.com/scummvm/scummvm/commit/ae91b7e056852956c88352d782fac1988ccd564d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-10-04T01:15:22+03:00
Commit Message:
TINSEL: Reset more global vars upon engine destruction
Changed paths:
engines/tinsel/move.cpp
engines/tinsel/object.cpp
engines/tinsel/polygons.cpp
engines/tinsel/tinsel.cpp
diff --git a/engines/tinsel/move.cpp b/engines/tinsel/move.cpp
index 826703bbf7..b297431b62 100644
--- a/engines/tinsel/move.cpp
+++ b/engines/tinsel/move.cpp
@@ -74,7 +74,7 @@ HPOLYGON InitExtraBlock(PMOVER ca, PMOVER ta);
//----------------- LOCAL GLOBAL DATA --------------------
-// FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
#if SLOW_RINCE_DOWN
static int g_Interlude = 0; // For slowing down walking, for testing
@@ -107,6 +107,12 @@ void AddInterlude(int n) {
}
#endif
+void ResetVarsMove() {
+ g_DefaultRefer = 0;
+ g_lastLeadXdest = g_lastLeadYdest = 0;
+ g_hSlowVar = 0;
+}
+
/**
* Given (x, y) of a click within a path polygon, checks that the
* co-ordinates are not within a blocking polygon. If it is not, the
diff --git a/engines/tinsel/object.cpp b/engines/tinsel/object.cpp
index 9792c58c48..5c0d88ca8f 100644
--- a/engines/tinsel/object.cpp
+++ b/engines/tinsel/object.cpp
@@ -35,13 +35,13 @@
namespace Tinsel {
-// FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
// list of all objects
-static OBJECT *objectList = 0;
+static OBJECT *objectList = nullptr;
// pointer to free object list
-static OBJECT *pFreeObjects = 0;
+static OBJECT *pFreeObjects = nullptr;
#ifdef DEBUG
// diagnostic object counters
diff --git a/engines/tinsel/polygons.cpp b/engines/tinsel/polygons.cpp
index d7efd91dab..662a4d6b4e 100644
--- a/engines/tinsel/polygons.cpp
+++ b/engines/tinsel/polygons.cpp
@@ -287,7 +287,7 @@ void Poly::nextPoly() {
//----------------- LOCAL GLOBAL DATA --------------------
-// FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
static int MaxPolys = MAX_POLY;
@@ -320,6 +320,16 @@ static POLY_VOLATILE volatileStuff[MAX_POLY];
//-------------------- METHODS ----------------------
+void ResetVarsPolygons() {
+ DropPolygons();
+
+ MaxPolys = MAX_POLY;
+ pHandle = 0;
+
+ memset(&extraBlock, 0, sizeof(extraBlock));
+ memset(volatileStuff, 0, sizeof(volatileStuff));
+}
+
static HPOLYGON PolygonIndex(const POLYGON *pp) {
for (int i = 0; i <= MAX_POLY; ++i) {
if (Polys[i] == pp)
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index 8b7dac4e60..5228479d2b 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -76,10 +76,12 @@ extern SCNHANDLE GetSceneHandle();
extern void ResetVarsDrives();
extern void ResetVarsEvents();
extern void RebootScalingReels();
+extern void ResetVarsMove();
extern void ResetVarsPalette();
extern void ResetVarsPCode();
extern void ResetVarsPDisplay();
extern void ResetVarsPlay();
+extern void ResetVarsPolygons();
extern void RebootMovers();
extern void ResetVarsSaveLoad();
extern void ResetVarsSaveScn();
@@ -915,13 +917,12 @@ TinselEngine::~TinselEngine() {
ResetVarsEvents(); // events.cpp
// TODO: heapmem.cpp
RebootScalingReels(); // mareels.cpp
- // TODO: move.cpp
- // TODO: object.cpp
+ ResetVarsMove();
ResetVarsPalette(); // palette.cpp
ResetVarsPCode();
ResetVarsPDisplay(); // pdisplay.cpp
ResetVarsPlay(); // play.cpp
- // TODO: polygons.cpp
+ ResetVarsPolygons(); // polygons.cpp
RebootMovers(); // rince.cpp
ResetVarsSaveLoad();
ResetVarsSaveScn(); // savescn.cpp
Commit: 1bda5728a954996eca052bc44aa698c3619e04c4
https://github.com/scummvm/scummvm/commit/1bda5728a954996eca052bc44aa698c3619e04c4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-10-04T01:15:22+03:00
Commit Message:
TINSEL: Reset more global vars upon engine destruction
Changed paths:
engines/tinsel/heapmem.cpp
engines/tinsel/sysvar.cpp
engines/tinsel/tinsel.cpp
diff --git a/engines/tinsel/heapmem.cpp b/engines/tinsel/heapmem.cpp
index 49062ca4ef..c1c036a2fa 100644
--- a/engines/tinsel/heapmem.cpp
+++ b/engines/tinsel/heapmem.cpp
@@ -54,8 +54,7 @@ struct MEM_NODE {
// If the memory is not enough, the engine throws an "Out of memory" error in handle.cpp inside LockMem()
static const uint32 MemoryPoolSize[3] = {5 * 1024 * 1024, 5 * 1024 * 1024, 10 * 1024 * 1024};
-// FIXME: Avoid non-const global vars
-
+// These vars are reset upon engine destruction
// list of all memory nodes
MEM_NODE g_mnodeList[NUM_MNODES];
@@ -149,6 +148,10 @@ void MemoryDeinit() {
free(pCur->pBaseAddr);
pCur->pBaseAddr = 0;
}
+
+ memset(g_mnodeList, 0, sizeof(g_mnodeList));
+ memset(g_s_fixedMnodesList, 0, sizeof(g_s_fixedMnodesList));
+ g_pFreeMemNodes = nullptr;
}
diff --git a/engines/tinsel/sysvar.cpp b/engines/tinsel/sysvar.cpp
index 3495935676..ee9fa79eae 100644
--- a/engines/tinsel/sysvar.cpp
+++ b/engines/tinsel/sysvar.cpp
@@ -41,79 +41,86 @@ extern int NewestSavedGame();
//----------------- LOCAL GLOBAL DATA --------------------
-// FIXME: Avoid non-const global vars
+// These vars are reset upon engine destruction
-static int g_systemVars[SV_TOPVALID] = {
+static int g_systemVars[SV_TOPVALID];
+static SCNHANDLE g_systemStrings[SS_MAX_VALID];
- INV_1, // Default inventory
+//----------------- FUNCTIONS --------------------------------
+
+void ResetVarsSysVar() {
+ memset(g_systemVars, 0, sizeof(g_systemVars));
+ memset(g_systemStrings, 0, sizeof(g_systemStrings));
+}
- 10, // Y-offset of Conversation(TOP)
- 320, // Y-offset of Conversation(BOT)
- 15, // Minimum distance from side
- 10, // Minimum distance from top
- 115, // Distance above actor
- 10, // Distance below actor
+/**
+ * Initializes the system variable list
+ */
- 0, // Current language **READ ONLY**
- 0, // Sample language **READ ONLY**
- 0, // Current state **READ ONLY**
- 0, // Saved Game Exists **READ ONLY**
+void InitSysVars() {
+ int initialSystemVars[SV_TOPVALID] = {
+ INV_1, // Default inventory
- true, // Should Conversation() wait for scroll? [TRUE]
- true, // Should Talk()/Say() wait for scroll? [TRUE]
+ 10, // Y-offset of Conversation(TOP)
+ 320, // Y-offset of Conversation(BOT)
+ 15, // Minimum distance from side
+ 10, // Minimum distance from top
+ 115, // Distance above actor
+ 10, // Distance below actor
- true, // Enable PointTag()
- true, // Enable cursor with PrintCursor()
+ 0, // Current language **READ ONLY**
+ 0, // Sample language **READ ONLY**
+ 0, // Current state **READ ONLY**
+ 0, // Saved Game Exists **READ ONLY**
- 100, // SV_SCROLL_XTRIGGER
- 0, // SV_SCROLL_XDISTANCE
- 16, // SV_SCROLL_XSPEED
- 40, // SV_SCROLL_YTRIGGERTOP
- 40, // SV_SCROLL_YTRIGGERBOT
- 0, // SV_SCROLL_YDISTANCE
- 16, // SV_SCROLL_YSPEED
+ true, // Should Conversation() wait for scroll? [TRUE]
+ true, // Should Talk()/Say() wait for scroll? [TRUE]
- 2, // Speech Delay
- 2, // Music dim factor
+ true, // Enable PointTag()
+ true, // Enable cursor with PrintCursor()
- 0, // if set, default actor's text color gets poked in here
+ 100, // SV_SCROLL_XTRIGGER
+ 0, // SV_SCROLL_XDISTANCE
+ 16, // SV_SCROLL_XSPEED
+ 40, // SV_SCROLL_YTRIGGERTOP
+ 40, // SV_SCROLL_YTRIGGERBOT
+ 0, // SV_SCROLL_YDISTANCE
+ 16, // SV_SCROLL_YSPEED
- 0, // user 1
- 0, // user 2
- 0, // user 3
- 0, // user 4
- 0, // user 5
- 0, // user 6
+ 2, // Speech Delay
+ 2, // Music dim factor
- 0, // SYS_MinimumXoffset
- 0, // SYS_MaximumXoffset
- 0, // SYS_MinimumYoffset
- 0, // SYS_MaximumYoffset
+ 0, // if set, default actor's text color gets poked in here
- 0, // SYS_DefaultFxDimFactor
- 0, // SYS_SceneFxDimFactor
+ 0, // user 1
+ 0, // user 2
+ 0, // user 3
+ 0, // user 4
+ 0, // user 5
+ 0, // user 6
- 0x606060, // SYS_HighlightRGB
- WIN_PC, // SYS_Platform,
- 0, // SYS_Debug
+ 0, // SYS_MinimumXoffset
+ 0, // SYS_MaximumXoffset
+ 0, // SYS_MinimumYoffset
+ 0, // SYS_MaximumYoffset
- 0, // ISV_DIVERT_ACTOR
- false, // ISV_NO_BLOCKING
+ 0, // SYS_DefaultFxDimFactor
+ 0, // SYS_SceneFxDimFactor
- 0, // ISV_GHOST_ACTOR
- 0, // ISV_GHOST_BASE
- 0 // ISV_GHOST_COLOR
-};
+ 0x606060, // SYS_HighlightRGB
+ WIN_PC, // SYS_Platform,
+ 0, // SYS_Debug
-static SCNHANDLE g_systemStrings[SS_MAX_VALID]; // FIXME: Avoid non-const global vars
+ 0, // ISV_DIVERT_ACTOR
+ false, // ISV_NO_BLOCKING
-//----------------- FUNCTIONS --------------------------------
+ 0, // ISV_GHOST_ACTOR
+ 0, // ISV_GHOST_BASE
+ 0 // ISV_GHOST_COLOR
+ };
-/**
- * Initializes the system variable list
- */
+ memcpy(g_systemVars, initialSystemVars, sizeof(g_systemVars));
-void InitSysVars() {
g_systemVars[SV_SCROLL_XDISTANCE] = SCREEN_WIDTH / 2;
g_systemVars[SV_SCROLL_YDISTANCE] = SCREEN_BOX_HEIGHT1 / 2;
}
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index 5228479d2b..c353934e91 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -89,6 +89,7 @@ extern void ResetVarsScene();
extern void ResetVarsSched();
extern void ResetVarsStrRes();
extern void FreeTextBuffer();
+extern void ResetVarsSysVar();
extern void FreeAllTokens();
extern void RebootTimers();
extern void ResetVarsTinlib();
@@ -915,22 +916,21 @@ TinselEngine::~TinselEngine() {
// TODO: dialogs.cpp
ResetVarsDrives(); // drives.cpp
ResetVarsEvents(); // events.cpp
- // TODO: heapmem.cpp
RebootScalingReels(); // mareels.cpp
- ResetVarsMove();
+ ResetVarsMove(); // move.cpp
ResetVarsPalette(); // palette.cpp
- ResetVarsPCode();
+ ResetVarsPCode(); // pcode.cpp
ResetVarsPDisplay(); // pdisplay.cpp
ResetVarsPlay(); // play.cpp
ResetVarsPolygons(); // polygons.cpp
RebootMovers(); // rince.cpp
- ResetVarsSaveLoad();
+ ResetVarsSaveLoad(); // saveload.cpp
ResetVarsSaveScn(); // savescn.cpp
ResetVarsScene(); // scene.cpp
ResetVarsSched(); // sched.cpp
ResetVarsStrRes(); // strres.cpp
FreeTextBuffer(); // strres.cpp
- // TODO: sysvar.cpp
+ ResetVarsSysVar(); // sysvar.cpp
FreeAllTokens(); // token.cpp
RebootTimers(); // timers.cpp
ResetVarsTinlib(); // tinlib.cpp
Commit: 94fae0c94d161f9ffadda0b0bebdb505fc6e04b1
https://github.com/scummvm/scummvm/commit/94fae0c94d161f9ffadda0b0bebdb505fc6e04b1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-10-04T01:15:23+03:00
Commit Message:
TINSEL: Move all dialog-related functions into a new Dialogs class
Changed paths:
engines/tinsel/actors.cpp
engines/tinsel/cursor.cpp
engines/tinsel/debugger.cpp
engines/tinsel/dialogs.cpp
engines/tinsel/dialogs.h
engines/tinsel/events.cpp
engines/tinsel/saveload.cpp
engines/tinsel/savescn.cpp
engines/tinsel/savescn.h
engines/tinsel/scene.cpp
engines/tinsel/tinlib.cpp
engines/tinsel/tinsel.cpp
engines/tinsel/tinsel.h
diff --git a/engines/tinsel/actors.cpp b/engines/tinsel/actors.cpp
index fa17ce7ccf..a8e06bf141 100644
--- a/engines/tinsel/actors.cpp
+++ b/engines/tinsel/actors.cpp
@@ -1492,7 +1492,7 @@ static void ActorTinselProcess(CORO_PARAM, const void *param) {
// Take control for CONVERSE events
if (atp->event == CONVERSE) {
_ctx->bTookControl = GetControl();
- HideConversation(true);
+ _vm->_dialogs->HideConversation(true);
} else
_ctx->bTookControl = false;
@@ -1505,7 +1505,7 @@ static void ActorTinselProcess(CORO_PARAM, const void *param) {
if (_ctx->bTookControl)
ControlOn();
- HideConversation(false);
+ _vm->_dialogs->HideConversation(false);
}
} else {
CORO_INVOKE_1(AllowDclick, atp->bev); // May kill us if single click
diff --git a/engines/tinsel/cursor.cpp b/engines/tinsel/cursor.cpp
index f893019ced..b90d763487 100644
--- a/engines/tinsel/cursor.cpp
+++ b/engines/tinsel/cursor.cpp
@@ -445,10 +445,10 @@ void Cursor::DoCursorMove() {
if (_auxCursor != NULL)
MultiSetAniXY(_auxCursor, ptMouse.x - _auxCursorOffsetX, ptMouse.y - _auxCursorOffsetY);
- if (InventoryActive() && _mainCursor) {
+ if (_vm->_dialogs->InventoryActive() && _mainCursor) {
// Notify the inventory
- Xmovement(ptMouse.x - startX);
- Ymovement(ptMouse.y - startY);
+ _vm->_dialogs->Xmovement(ptMouse.x - startX);
+ _vm->_dialogs->Ymovement(ptMouse.y - startY);
}
_lastCursorX = ptMouse.x;
@@ -574,7 +574,7 @@ void Cursor::StartCursorFollowed() {
}
void Cursor::EndCursorFollowed() {
- InventoryIconCursor(false); // May be holding something
+ _vm->_dialogs->InventoryIconCursor(false); // May be holding something
_tempHiddenCursor = false;
}
@@ -620,7 +620,7 @@ void CursorStoppedCheck(CORO_PARAM) {
// Re-initialize
_vm->_cursor->InitCurObj();
_vm->_cursor->InitCurPos();
- InventoryIconCursor(false); // May be holding something
+ _vm->_dialogs->InventoryIconCursor(false); // May be holding something
// Re-start the cursor trails
_vm->_cursor->_cursorProcessesRestarted = true;
@@ -644,7 +644,7 @@ void CursorProcess(CORO_PARAM, const void *) {
_vm->_cursor->InitCurObj();
_vm->_cursor->InitCurPos();
- InventoryIconCursor(false); // May be holding something
+ _vm->_dialogs->InventoryIconCursor(false); // May be holding something
_vm->_cursor->_cursorProcessesStopped = false;
_vm->_cursor->_cursorProcessesRestarted = false;
diff --git a/engines/tinsel/debugger.cpp b/engines/tinsel/debugger.cpp
index ba0402a997..cad6b4705f 100644
--- a/engines/tinsel/debugger.cpp
+++ b/engines/tinsel/debugger.cpp
@@ -79,8 +79,8 @@ bool Console::cmd_item(int argc, const char **argv) {
return true;
}
- HoldItem(INV_NOICON);
- HoldItem(strToInt(argv[1]));
+ _vm->_dialogs->HoldItem(INV_NOICON);
+ _vm->_dialogs->HoldItem(strToInt(argv[1]));
return false;
}
diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp
index 0d7827eeaf..4751b5a91a 100644
--- a/engines/tinsel/dialogs.cpp
+++ b/engines/tinsel/dialogs.cpp
@@ -26,6 +26,8 @@
* And there's still a bit of tidying and commenting to do yet.
*/
+#include "common/serializer.h"
+#include "tinsel/dialogs.h"
#include "tinsel/actors.h"
#include "tinsel/anim.h"
#include "tinsel/background.h"
@@ -38,7 +40,6 @@
#include "tinsel/graphics.h"
#include "tinsel/handle.h"
#include "tinsel/heapmem.h"
-#include "tinsel/dialogs.h"
#include "tinsel/multiobj.h"
#include "tinsel/music.h"
#include "tinsel/palette.h"
@@ -49,14 +50,13 @@
#include "tinsel/savescn.h"
#include "tinsel/sched.h"
#include "tinsel/scn.h"
-#include "common/serializer.h"
#include "tinsel/sound.h"
#include "tinsel/strres.h"
#include "tinsel/sysvar.h"
#include "tinsel/text.h"
-#include "tinsel/timers.h" // For ONE_SECOND constant
+#include "tinsel/timers.h" // For ONE_SECOND constant
#include "tinsel/tinlib.h"
-#include "tinsel/tinsel.h" // For engine access
+#include "tinsel/tinsel.h" // For engine access
#include "tinsel/token.h"
#include "common/textconsole.h"
@@ -65,37 +65,33 @@ namespace Tinsel {
//----------------- LOCAL DEFINES --------------------
-#define HOPPER_FILENAME "hopper"
+#define HOPPER_FILENAME "hopper"
-#define INV_PICKUP PLR_SLEFT // Local names
-#define INV_LOOK PLR_SRIGHT // for button events
-#define INV_ACTION PLR_DLEFT //
-// For SlideSlider() and similar
-enum SSFN {
- S_START, S_SLIDE, S_END, S_TIMEUP, S_TIMEDN
-};
+#define INV_PICKUP PLR_SLEFT // Local names
+#define INV_LOOK PLR_SRIGHT // for button events
+#define INV_ACTION PLR_DLEFT //
/** attribute values - may become bit field if further attributes are added */
enum {
- IO_ONLYINV1 = 0x01,
- IO_ONLYINV2 = 0x02,
- IO_DROPCODE = 0x04
+ IO_ONLYINV1 = 0x01,
+ IO_ONLYINV2 = 0x02,
+ IO_DROPCODE = 0x04
};
//-----------------------
// Moveable window translucent rectangle position limits
enum {
- MAXLEFT = 315, //
- MINRIGHT = 3, // These values keep 2 pixcells
- MINTOP = -13, // of header on the screen.
- MAXTOP = 195 //
+ MAXLEFT = 315, //
+ MINRIGHT = 3, // These values keep 2 pixcells
+ MINTOP = -13, // of header on the screen.
+ MAXTOP = 195 //
};
//-----------------------
// Indices into hWinParts's reels
enum PARTS_INDEX {
- IX_SLIDE = 0, // Slider
+ IX_SLIDE = 0, // Slider
IX_V26 = 1,
IX_V52 = 2,
IX_V78 = 3,
@@ -110,58 +106,58 @@ enum PARTS_INDEX {
IX_H182 = 12,
IX_H208 = 13,
IX_H234 = 14,
- IX_TL = 15, // Top left corner
- IX_TR = 16, // Top right corner
- IX_BL = 17, // Bottom left corner
- IX_BR = 18, // Bottom right corner
+ IX_TL = 15, // Top left corner
+ IX_TR = 16, // Top right corner
+ IX_BL = 17, // Bottom left corner
+ IX_BR = 18, // Bottom right corner
IX1_H25 = 19,
IX1_V11 = 20,
- IX1_RTL = 21, // Re-sizing top left corner
- IX1_RTR = 22, // Re-sizing top right corner
- IX1_RBR = 23, // Re-sizing bottom right corner
- IX1_CURLR = 24, // }
- IX1_CURUD = 25, // }
- IX1_CURDU = 26, // } Custom cursors
- IX1_CURDD = 27, // }
- IX1_CURUP = 28, // }
- IX1_CURDOWN = 29, // }
- IX1_MDGROOVE = 30, // 'Mixing desk' slider background
- IX1_MDSLIDER= 34, // 'Mixing desk' slider
- IX1_BLANK1 = 35, //
- IX1_BLANK2 = 36, //
- IX1_BLANK3 = 37, //
- IX1_CIRCLE1 = 38, //
- IX1_CIRCLE2 = 39, //
- IX1_CROSS1 = 40, //
- IX1_CROSS2 = 41, //
- IX1_CROSS3 = 42, //
- IX1_QUIT1 = 43, //
- IX1_QUIT2 = 44, //
- IX1_QUIT3 = 45, //
- IX1_TICK1 = 46, //
- IX1_TICK2 = 47, //
- IX1_TICK3 = 48, //
- IX1_NTR = 49, // New top right corner
-
- IX2_RTL = 19, // Re-sizing top left corner
- IX2_RTR = 20, // Re-sizing top right corner
- IX2_RBR = 21, // Re-sizing bottom right corner
- IX2_CURLR = 22, // }
- IX2_CURUD = 23, // }
- IX2_CURDU = 24, // } Custom cursors
- IX2_CURDD = 25, // }
- IX2_MDGROOVE = 26, // 'Mixing desk' slider background
- IX2_MDSLIDER = 27, // 'Mixing desk' slider
- IX2_CIRCLE1 = 28, //
- IX2_CIRCLE2 = 29, //
- IX2_CROSS1 = 30, //
- IX2_CROSS2 = 31, //
- IX2_CROSS3 = 32, //
- IX2_TICK1 = 33, //
- IX2_TICK2 = 34, //
- IX2_TICK3 = 35, //
- IX2_NTR = 36, // New top right corner
+ IX1_RTL = 21, // Re-sizing top left corner
+ IX1_RTR = 22, // Re-sizing top right corner
+ IX1_RBR = 23, // Re-sizing bottom right corner
+ IX1_CURLR = 24, // }
+ IX1_CURUD = 25, // }
+ IX1_CURDU = 26, // } Custom cursors
+ IX1_CURDD = 27, // }
+ IX1_CURUP = 28, // }
+ IX1_CURDOWN = 29, // }
+ IX1_MDGROOVE = 30, // 'Mixing desk' slider background
+ IX1_MDSLIDER = 34, // 'Mixing desk' slider
+ IX1_BLANK1 = 35, //
+ IX1_BLANK2 = 36, //
+ IX1_BLANK3 = 37, //
+ IX1_CIRCLE1 = 38, //
+ IX1_CIRCLE2 = 39, //
+ IX1_CROSS1 = 40, //
+ IX1_CROSS2 = 41, //
+ IX1_CROSS3 = 42, //
+ IX1_QUIT1 = 43, //
+ IX1_QUIT2 = 44, //
+ IX1_QUIT3 = 45, //
+ IX1_TICK1 = 46, //
+ IX1_TICK2 = 47, //
+ IX1_TICK3 = 48, //
+ IX1_NTR = 49, // New top right corner
+
+ IX2_RTL = 19, // Re-sizing top left corner
+ IX2_RTR = 20, // Re-sizing top right corner
+ IX2_RBR = 21, // Re-sizing bottom right corner
+ IX2_CURLR = 22, // }
+ IX2_CURUD = 23, // }
+ IX2_CURDU = 24, // } Custom cursors
+ IX2_CURDD = 25, // }
+ IX2_MDGROOVE = 26, // 'Mixing desk' slider background
+ IX2_MDSLIDER = 27, // 'Mixing desk' slider
+ IX2_CIRCLE1 = 28, //
+ IX2_CIRCLE2 = 29, //
+ IX2_CROSS1 = 30, //
+ IX2_CROSS2 = 31, //
+ IX2_CROSS3 = 32, //
+ IX2_TICK1 = 33, //
+ IX2_TICK2 = 34, //
+ IX2_TICK3 = 35, //
+ IX2_NTR = 36, // New top right corner
IX2_TR4 = 37,
IX2_LEFT1 = 38,
IX2_LEFT2 = 39,
@@ -173,480 +169,229 @@ enum PARTS_INDEX {
};
// The following defines select the correct constant depending on Tinsel version
-#define IX_CROSS1 (TinselV2 ? IX2_CROSS1 : IX1_CROSS1)
-#define IX_CURDD (TinselV2 ? IX2_CURDD : IX1_CURDD)
-#define IX_CURDU (TinselV2 ? IX2_CURDU : IX1_CURDU)
-#define IX_CURLR (TinselV2 ? IX2_CURLR : IX1_CURLR)
-#define IX_CURUD (TinselV2 ? IX2_CURUD : IX1_CURUD)
-#define IX_CURUL (TinselV2 ? IX2_CURUL : IX1_CURUL)
-#define IX_MDGROOVE (TinselV2 ? IX2_MDGROOVE : IX1_MDGROOVE)
-#define IX_MDSLIDER (TinselV2 ? IX2_MDSLIDER : IX1_MDSLIDER)
-#define IX_NTR (TinselV2 ? IX2_NTR : IX1_NTR)
-#define IX_RBR (TinselV2 ? IX2_RBR : IX1_RBR)
-#define IX_RTL (TinselV2 ? IX2_RTL : IX1_RTL)
-#define IX_RTR (TinselV2 ? IX2_RTR : IX1_RTR)
-#define IX_TICK1 (TinselV2 ? IX2_TICK1 : IX1_TICK1)
-
-
-
-#define NORMGRAPH 0
-#define DOWNGRAPH 1
-#define HIGRAPH 2
+#define IX_CROSS1 (TinselV2 ? IX2_CROSS1 : IX1_CROSS1)
+#define IX_CURDD (TinselV2 ? IX2_CURDD : IX1_CURDD)
+#define IX_CURDU (TinselV2 ? IX2_CURDU : IX1_CURDU)
+#define IX_CURLR (TinselV2 ? IX2_CURLR : IX1_CURLR)
+#define IX_CURUD (TinselV2 ? IX2_CURUD : IX1_CURUD)
+#define IX_CURUL (TinselV2 ? IX2_CURUL : IX1_CURUL)
+#define IX_MDGROOVE (TinselV2 ? IX2_MDGROOVE : IX1_MDGROOVE)
+#define IX_MDSLIDER (TinselV2 ? IX2_MDSLIDER : IX1_MDSLIDER)
+#define IX_NTR (TinselV2 ? IX2_NTR : IX1_NTR)
+#define IX_RBR (TinselV2 ? IX2_RBR : IX1_RBR)
+#define IX_RTL (TinselV2 ? IX2_RTL : IX1_RTL)
+#define IX_RTR (TinselV2 ? IX2_RTR : IX1_RTR)
+#define IX_TICK1 (TinselV2 ? IX2_TICK1 : IX1_TICK1)
+
+#define NORMGRAPH 0
+#define DOWNGRAPH 1
+#define HIGRAPH 2
//-----------------------
-#define FIX_UK 0
-#define FIX_FR 1
-#define FIX_GR 2
-#define FIX_IT 3
-#define FIX_SP 4
-#define FIX_USA 5
-#define HOPEDFORFREELS 6 // Expected flag reels
+#define FIX_UK 0
+#define FIX_FR 1
+#define FIX_GR 2
+#define FIX_IT 3
+#define FIX_SP 4
+#define FIX_USA 5
+#define HOPEDFORFREELS 6 // Expected flag reels
//-----------------------
-#define MAX_ININV (TinselV2 ? 160 : 150) // Max in an inventory
-#define MAX_ININV_TOT 160
-#define MAX_PERMICONS 10 // Max permanent conversation icons
-
-#define MAXHICONS 10 // Max dimensions of
-#define MAXVICONS 6 // an inventory window
-
-#define ITEM_WIDTH (TinselV2 ? 50 : 25) // Dimensions of an icon
-#define ITEM_HEIGHT (TinselV2 ? 50 : 25) //
-#define I_SEPARATION (TinselV2 ? 2 : 1) // Item separation
-
-#define NM_TOFF 11 // Title text Y offset from top
-#define NM_TBT (TinselV2 ? 4 : 0) // Y, title box top
-#define NM_TBB 33
-#define NM_LSX (TinselV2 ? 4 : 0) // X, left side
-#define NM_BSY (TinselV2 ? -9 : - M_TH + 1)
-#define NM_RSX (TinselV2 ? -9 : - M_SW + 1)
-#define NM_SBL (-27)
-#define NM_SLH (TinselV2 ? 11 : 5) // Slider height
-#define NM_SLX (-11) // Slider X offset (from right)
-
-#define NM_BG_POS_X (TinselV2 ? 9 : 1) // }
-#define NM_BG_POS_Y (TinselV2 ? 9 : 1) // } Offset of translucent rectangle
-#define NM_BG_SIZ_X (TinselV2 ? -18 : -3) // }
-#define NM_BG_SIZ_Y (TinselV2 ? -18 : -3) // } How much larger it is than edges
-
-#define NM_RS_T_INSET 3
-#define NM_RS_B_INSET 4
-#define NM_RS_L_INSET 3
-#define NM_RS_R_INSET 4
-#define NM_RS_THICKNESS 5
-#define NM_MOVE_AREA_B_Y 30
-#define NM_SLIDE_INSET (TinselV2 ? 18 : 9) // X offset (from right) of left of scroll region
-#define NM_SLIDE_THICKNESS (TinselV2 ? 13 : 7) // thickness of scroll region
-#define NM_UP_ARROW_TOP 34 // Y offset of top of up arrow
-#define NM_UP_ARROW_BOTTOM 49 // Y offset of bottom of up arrow
-#define NM_DN_ARROW_TOP 22 // Y offset (from bottom) of top of down arrow
-#define NM_DN_ARROW_BOTTOM 5 // Y offset (from bottom) of bottom of down arrow
-
-#define MD_YBUTTOP (TinselV2 ? 2 : 9)
-#define MD_YBUTBOT (TinselV2 ? 16 : 0)
-#define MD_XLBUTL (TinselV2 ? 4 : 1)
-#define MD_XLBUTR (TinselV2 ? 26 : 10)
-#define MD_XRBUTL (TinselV2 ? 173 : 105)
-#define MD_XRBUTR (TinselV2 ? 195 : 114)
-#define ROTX1 60 // Rotate button's offsets from the center
-
-// Number of objects that makes up an empty window
-#define MAX_WCOMP 21 // 4 corners + (3+3) sides + (2+2) extra sides
- // + Bground + title + slider
- // + more Needed for save game window
-
-#define MAX_ICONS MAXHICONS*MAXVICONS
+#define MAX_ININV (TinselV2 ? 160 : 150) // Max in an inventory
+
+#define ITEM_WIDTH (TinselV2 ? 50 : 25) // Dimensions of an icon
+#define ITEM_HEIGHT (TinselV2 ? 50 : 25) //
+#define I_SEPARATION (TinselV2 ? 2 : 1) // Item separation
+
+#define NM_TOFF 11 // Title text Y offset from top
+#define NM_TBT (TinselV2 ? 4 : 0) // Y, title box top
+#define NM_TBB 33
+#define NM_LSX (TinselV2 ? 4 : 0) // X, left side
+#define NM_BSY (TinselV2 ? -9 : -M_TH + 1)
+#define NM_RSX (TinselV2 ? -9 : -M_SW + 1)
+#define NM_SBL (-27)
+#define NM_SLH (TinselV2 ? 11 : 5) // Slider height
+#define NM_SLX (-11) // Slider X offset (from right)
+
+#define NM_BG_POS_X (TinselV2 ? 9 : 1) // }
+#define NM_BG_POS_Y (TinselV2 ? 9 : 1) // } Offset of translucent rectangle
+#define NM_BG_SIZ_X (TinselV2 ? -18 : -3) // }
+#define NM_BG_SIZ_Y (TinselV2 ? -18 : -3) // } How much larger it is than edges
+
+#define NM_RS_T_INSET 3
+#define NM_RS_B_INSET 4
+#define NM_RS_L_INSET 3
+#define NM_RS_R_INSET 4
+#define NM_RS_THICKNESS 5
+#define NM_MOVE_AREA_B_Y 30
+#define NM_SLIDE_INSET (TinselV2 ? 18 : 9) // X offset (from right) of left of scroll region
+#define NM_SLIDE_THICKNESS (TinselV2 ? 13 : 7) // thickness of scroll region
+#define NM_UP_ARROW_TOP 34 // Y offset of top of up arrow
+#define NM_UP_ARROW_BOTTOM 49 // Y offset of bottom of up arrow
+#define NM_DN_ARROW_TOP 22 // Y offset (from bottom) of top of down arrow
+#define NM_DN_ARROW_BOTTOM 5 // Y offset (from bottom) of bottom of down arrow
+
+#define MD_YBUTTOP (TinselV2 ? 2 : 9)
+#define MD_YBUTBOT (TinselV2 ? 16 : 0)
+#define MD_XLBUTL (TinselV2 ? 4 : 1)
+#define MD_XLBUTR (TinselV2 ? 26 : 10)
+#define MD_XRBUTL (TinselV2 ? 173 : 105)
+#define MD_XRBUTR (TinselV2 ? 195 : 114)
+#define ROTX1 60 // Rotate button's offsets from the center
#define MAX_NAME_RIGHT (TinselV2 ? 417 : 213)
-#define SLIDE_RANGE (TinselV2 ? 120 : 81)
-#define SLIDE_MINX (TinselV2 ? 25 : 8)
-#define SLIDE_MAXX (TinselV2 ? 25 + 120 : 8 + 81)
+#define SLIDE_RANGE (TinselV2 ? 120 : 81)
+#define SLIDE_MINX (TinselV2 ? 25 : 8)
+#define SLIDE_MAXX (TinselV2 ? 25 + 120 : 8 + 81)
-#define MDTEXT_YOFF (TinselV2 ? -1 : 6)
-#define MDTEXT_XOFF -4
-#define TOG2_YOFF -22
-#define ROT_YOFF 48
+#define MDTEXT_YOFF (TinselV2 ? -1 : 6)
+#define MDTEXT_XOFF -4
+#define TOG2_YOFF -22
+#define ROT_YOFF 48
#define TYOFF (TinselV2 ? 4 : 0)
#define FLAGX (-5)
#define FLAGY 4
-
//----------------- LOCAL GLOBAL DATA --------------------
//----- Permanent data (compiled in) -----
// Save game name editing cursor
-#define CURSOR_CHAR '_'
-char sCursor[2] = { CURSOR_CHAR, 0 };
+#define CURSOR_CHAR '_'
+char sCursor[2] = {CURSOR_CHAR, 0};
static const int hFillers[MAXHICONS] = {
- IX_H26, // 2 icons wide
- IX_H52, // 3
- IX_H78, // 4
- IX_H104, // 5
- IX_H130, // 6
- IX_H156, // 7
- IX_H182, // 8
- IX_H208, // 9
- IX_H234 // 10 icons wide
+ IX_H26, // 2 icons wide
+ IX_H52, // 3
+ IX_H78, // 4
+ IX_H104, // 5
+ IX_H130, // 6
+ IX_H156, // 7
+ IX_H182, // 8
+ IX_H208, // 9
+ IX_H234 // 10 icons wide
};
static const int vFillers[MAXVICONS] = {
- IX_V26, // 2 icons high
- IX_V52, // 3
- IX_V78, // 4
- IX_V104, // 5
- IX_V130 // 6 icons high
-};
-
-
-//----- Permanent data (set once) -----
-
-static SCNHANDLE g_hWinParts = 0; // Window members and cursors' graphic data
-static SCNHANDLE g_flagFilm = 0; // Window members and cursors' graphic data
-static SCNHANDLE g_configStrings[20];
-
-static INV_OBJECT *g_invObjects = nullptr; // Inventory objects' data
-static int g_numObjects = 0; // Number of inventory objects
-static SCNHANDLE *g_invFilms = nullptr;
-static bool g_bNoLanguage = false;
-static DIRECTION g_initialDirection;
-
-//----- Permanent data (updated, valid while inventory closed) -----
-
-static enum {NO_INV, IDLE_INV, ACTIVE_INV, BOGUS_INV} g_InventoryState;
-
-static int g_heldItem = INV_NOICON; // Current held item
-
-static SCNHANDLE g_heldFilm;
-
-struct INV_DEF {
-
- int MinHicons; // }
- int MinVicons; // } Dimension limits
- int MaxHicons; // }
- int MaxVicons; // }
-
- int NoofHicons; // }
- int NoofVicons; // } Current dimentsions
-
- int contents[160]; // Contained items
- int NoofItems; // Current number of held items
-
- int FirstDisp; // Index to first item currently displayed
-
- int inventoryX; // } Display position
- int inventoryY; // }
- int otherX; // } Display position
- int otherY; // }
-
- int MaxInvObj; // Max. allowed contents
-
- SCNHANDLE hInvTitle; // Window heading
-
- bool resizable; // Re-sizable window?
- bool bMoveable; // Moveable window?
-
- int sNoofHicons; // }
- int sNoofVicons; // } Current dimensions
-
- bool bMax; // Maximised last time open?
-
-};
-
-static INV_DEF g_InvD[NUM_INV]; // Conversation + 2 inventories + ...
-
-
-// Permanent contents of conversation inventory
-static int g_permIcons[MAX_PERMICONS]; // Basic items i.e. permanent contents
-static int g_numPermIcons = 0; // - copy to conv. inventory at pop-up time
-static int g_numEndIcons = 0;
-
-//----- Data pertinant to current active inventory -----
-
-static int g_ino = 0; // Which inventory is currently active
-
-static bool g_InventoryHidden = false;
-static bool g_InventoryMaximised = false;
-
-static enum { ID_NONE, ID_MOVE, ID_SLIDE,
- ID_BOTTOM, ID_TOP, ID_LEFT, ID_RIGHT,
- ID_TLEFT, ID_TRIGHT, ID_BLEFT, ID_BRIGHT,
- ID_CSLIDE, ID_MDCONT } g_InvDragging;
-
-static int g_SuppH = 0; // 'Linear' element of
-static int g_SuppV = 0; // dimensions during re-sizing
-
-static int g_Ychange = 0; //
-static int g_Ycompensate = 0; // All to do with re-sizing.
-static int g_Xchange = 0; //
-static int g_Xcompensate = 0; //
-
-static bool g_ItemsChanged = 0; // When set, causes items to be re-drawn
-
-static bool g_bReOpenMenu = 0;
-
-static int g_TL = 0, g_TR = 0, g_BL = 0, g_BR = 0; // Used during window construction
-static int g_TLwidth = 0, g_TLheight = 0; //
-static int g_TRwidth = 0; //
-static int g_BLheight = 0; //
-
-static LANGUAGE g_displayedLanguage;
-
-static OBJECT *g_objArray[MAX_WCOMP]; // Current display objects (window)
-static OBJECT *g_iconArray[MAX_ICONS]; // Current display objects (icons)
-static ANIM g_iconAnims[MAX_ICONS];
-static OBJECT *g_DobjArray[MAX_WCOMP]; // Current display objects (re-sizing window)
-
-static OBJECT *g_RectObject = 0, *g_SlideObject = 0; // Current display objects, for reference
- // objects are in objArray.
-
-static int g_sliderYpos = 0; // For positioning the slider
-static int g_sliderYmax = 0, g_sliderYmin = 0; //
-
-#define sliderRange (g_sliderYmax - g_sliderYmin)
-
-// Also to do with the slider
-static struct { int n; int y; } g_slideStuff[MAX_ININV_TOT+1];
-
-#define MAXSLIDES 4
-struct MDSLIDES {
- int num;
- OBJECT *obj;
- int min, max;
+ IX_V26, // 2 icons high
+ IX_V52, // 3
+ IX_V78, // 4
+ IX_V104, // 5
+ IX_V130 // 6 icons high
};
-static MDSLIDES g_mdSlides[MAXSLIDES];
-static int g_numMdSlides = 0;
-
-static int g_GlitterIndex = 0;
-
-// Icon clicked on to cause an event
-// - Passed to conversation polygon or actor code via Topic()
-// - (sometimes) Passed to inventory icon code via OtherObject()
-static int g_thisIcon = 0;
-
-static CONV_PARAM g_thisConvFn; // Top, 'Middle' or Bottom
-static HPOLYGON g_thisConvPoly = 0; // Conversation code is in a polygon code block
-static int g_thisConvActor; // ...or an actor's code block.
-static int g_pointedIcon = INV_NOICON; // used by InvLabels - icon pointed to on last call
-static volatile int g_PointedWaitCount = 0; // used by ObjectProcess - fix the 'repeated pressing bug'
-static int g_sX = 0; // used by SlideMSlider() - current x-coordinate
-static int g_lX = 0; // used by SlideMSlider() - last x-coordinate
-
-static bool g_bMoveOnUnHide; // Set before start of conversation
- // - causes conversation to be started in a sensible place
//----- Data pertinant to configure (incl. load/save game) -----
-#define COL_MAINBOX TBLUE1 // Base blue color
-#define COL_BOX TBLUE1
-#define COL_HILIGHT TBLUE4
+#define COL_MAINBOX TBLUE1 // Base blue color
+#define COL_BOX TBLUE1
+#define COL_HILIGHT TBLUE4
#ifdef JAPAN
-#define BOX_HEIGHT 17
-#define EDIT_BOX1_WIDTH 149
+#define BOX_HEIGHT 17
+#define EDIT_BOX1_WIDTH 149
#else
-#define BOX_HEIGHT 13
-#define EDIT_BOX1_WIDTH 145
+#define BOX_HEIGHT 13
+#define EDIT_BOX1_WIDTH 145
#endif
-#define EDIT_BOX2_WIDTH 166
+#define EDIT_BOX2_WIDTH 166
#define T2_EDIT_BOX1_WIDTH 290
#define T2_EDIT_BOX2_WIDTH 322
#define T2_BOX_HEIGHT 26
-//----- Data pertinant to scene hoppers ------------------------
-
-#include "common/pack-start.h" // START STRUCT PACKING
-
-struct HOPPER {
- uint32 hScene;
- SCNHANDLE hSceneDesc;
- uint32 numEntries;
- uint32 entryIndex;
-} PACKED_STRUCT;
-typedef HOPPER *PHOPPER;
-
-struct HOPENTRY {
- uint32 eNumber; // entrance number
- SCNHANDLE hDesc; // handle to entrance description
- uint32 flags;
-} PACKED_STRUCT;
-typedef HOPENTRY *PHOPENTRY;
-
-#include "common/pack-end.h" // END STRUCT PACKING
-
-static PHOPPER g_pHopper;
-static PHOPENTRY g_pEntries;
-static int g_numScenes;
-
-static int g_numEntries;
-
-static PHOPPER g_pChosenScene = nullptr;
-
-static int g_lastChosenScene;
-static bool g_bRemember;
-
-//--------------------------------------------------------------
-
-
-
-enum BTYPE {
- RGROUP, ///< Radio button group - 1 is selectable at a time. Action on double click
- ARSBUT, ///< Action if a radio button is selected
- AABUT, ///< Action always
- AATBUT, ///< Action always, text box
- ARSGBUT,
- AAGBUT, ///< Action always, graphic button
- SLIDER, ///< Not a button at all
- TOGGLE, ///< Discworld 1 toggle
- TOGGLE1, ///< Discworld 2 toggle type 1
- TOGGLE2, ///< Discworld 2 toggle type 2
- DCTEST,
- FLIP,
- FRGROUP,
- ROTATE,
- NOTHING
-};
-
-enum BFUNC {
- NOFUNC,
- SAVEGAME,
- LOADGAME,
- IQUITGAME,
- CLOSEWIN,
- OPENLOAD,
- OPENSAVE,
- OPENREST,
- OPENSOUND,
- OPENCONT,
-#ifndef JAPAN
- OPENSUBT,
-#endif
- OPENQUIT,
- INITGAME,
- MUSICVOL,
-
- HOPPER2, // Call up Scene Hopper 2
- BF_CHANGESCENE,
-
- CLANG,
- RLANG
-#ifdef MAC_OPTIONS
- , MASTERVOL, SAMPVOL
-#endif
-};
-
-#define NO_HEADING ((SCNHANDLE)-1)
-#define USE_POINTER (-1)
-#define SIX_LOAD_OPTION 0
-#define SIX_SAVE_OPTION 1
-#define SIX_RESTART_OPTION 2
-#define SIX_SOUND_OPTION 3
-#define SIX_CONTROL_OPTION 4
+#define NO_HEADING ((SCNHANDLE)-1)
+#define USE_POINTER (-1)
+#define SIX_LOAD_OPTION 0
+#define SIX_SAVE_OPTION 1
+#define SIX_RESTART_OPTION 2
+#define SIX_SOUND_OPTION 3
+#define SIX_CONTROL_OPTION 4
#ifndef JAPAN
-#define SIX_SUBTITLES_OPTION 5
+#define SIX_SUBTITLES_OPTION 5
#endif
-#define SIX_QUIT_OPTION 6
-#define SIX_RESUME_OPTION 7
-#define SIX_LOAD_HEADING 8
-#define SIX_SAVE_HEADING 9
-#define SIX_RESTART_HEADING 10
-#define SIX_MVOL_SLIDER 11
-#define SIX_SVOL_SLIDER 12
-#define SIX_VVOL_SLIDER 13
-#define SIX_DCLICK_SLIDER 14
-#define SIX_DCLICK_TEST 15
-#define SIX_SWAP_TOGGLE 16
-#define SIX_TSPEED_SLIDER 17
-#define SIX_STITLE_TOGGLE 18
-#define SIX_QUIT_HEADING 19
-
-enum TM {TM_POINTER, TM_INDEX, TM_STRINGNUM, TM_NONE};
-
-struct CONFBOX {
- BTYPE boxType;
- BFUNC boxFunc;
- TM textMethod;
-
- char *boxText;
- int ixText;
- int xpos;
- int ypos;
- int w; // Doubles as max value for SLIDERs
- int h; // Doubles as iteration size for SLIDERs
- int *ival;
- int bi; // Base index for AAGBUTs
-};
+#define SIX_QUIT_OPTION 6
+#define SIX_RESUME_OPTION 7
+#define SIX_LOAD_HEADING 8
+#define SIX_SAVE_HEADING 9
+#define SIX_RESTART_HEADING 10
+#define SIX_MVOL_SLIDER 11
+#define SIX_SVOL_SLIDER 12
+#define SIX_VVOL_SLIDER 13
+#define SIX_DCLICK_SLIDER 14
+#define SIX_DCLICK_TEST 15
+#define SIX_SWAP_TOGGLE 16
+#define SIX_TSPEED_SLIDER 17
+#define SIX_STITLE_TOGGLE 18
+#define SIX_QUIT_HEADING 19
struct CONFINIT {
- int h;
- int v;
- int x;
- int y;
+ int h;
+ int v;
+ int x;
+ int y;
bool bExtraWin;
CONFBOX *Box;
- int NumBoxes;
- uint32 ixHeading;
+ int NumBoxes;
+ uint32 ixHeading;
};
-#define BW 44 // Width of crosses and ticks etc. buttons
-#define BH 41 // Height of crosses and ticks etc. buttons
+#define BW 44 // Width of crosses and ticks etc. buttons
+#define BH 41 // Height of crosses and ticks etc. buttons
/*-------------------------------------------------------------*\
| This is the main menu (that comes up when you hit F1 on a PC) |
\*-------------------------------------------------------------*/
#ifdef JAPAN
-#define FBY 11 // y-offset of first button
-#define FBX 13 // x-offset of first button
+#define FBY 11 // y-offset of first button
+#define FBX 13 // x-offset of first button
#else
-#define FBY 20 // y-offset of first button
-#define FBX 15 // x-offset of first button
+#define FBY 20 // y-offset of first button
+#define FBX 15 // x-offset of first button
#endif
-#define OPTX 33
-#define OPTY 30
-#define BOX_V_SEP 7
+#define OPTX 33
+#define OPTY 30
+#define BOX_V_SEP 7
-#define BOXX 56 // X-position of text boxes
-#define BOXY 50 // Y-position of text boxes
-#define T2_OPTX 33
-#define T2_OPTY 36
-#define T2_BOX_V_SEP 12
-#define T2_BOX_V2_SEP 6
+#define BOXX 56 // X-position of text boxes
+#define BOXY 50 // Y-position of text boxes
+#define T2_OPTX 33
+#define T2_OPTY 36
+#define T2_BOX_V_SEP 12
+#define T2_BOX_V2_SEP 6
static CONFBOX t1OptionBox[] = {
- { AATBUT, OPENLOAD, TM_NONE, NULL, SIX_LOAD_OPTION, FBX, FBY, EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 },
- { AATBUT, OPENSAVE, TM_NONE, NULL, SIX_SAVE_OPTION, FBX, FBY + (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 },
- { AATBUT, OPENREST, TM_NONE, NULL, SIX_RESTART_OPTION, FBX, FBY + 2*(BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 },
- { AATBUT, OPENSOUND, TM_NONE, NULL, SIX_SOUND_OPTION, FBX, FBY + 3*(BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 },
- { AATBUT, OPENCONT, TM_NONE, NULL, SIX_CONTROL_OPTION, FBX, FBY + 4*(BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 },
+ {AATBUT, OPENLOAD, TM_NONE, NULL, SIX_LOAD_OPTION, FBX, FBY, EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0},
+ {AATBUT, OPENSAVE, TM_NONE, NULL, SIX_SAVE_OPTION, FBX, FBY + (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0},
+ {AATBUT, OPENREST, TM_NONE, NULL, SIX_RESTART_OPTION, FBX, FBY + 2 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0},
+ {AATBUT, OPENSOUND, TM_NONE, NULL, SIX_SOUND_OPTION, FBX, FBY + 3 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0},
+ {AATBUT, OPENCONT, TM_NONE, NULL, SIX_CONTROL_OPTION, FBX, FBY + 4 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0},
#ifdef JAPAN
-// TODO: If in JAPAN mode, simply disable the subtitles button?
- { AATBUT, OPENQUIT, NULL, SIX_QUIT_OPTION, FBX, FBY + 5*(BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 },
- { AATBUT, CLOSEWIN, NULL, SIX_RESUME_OPTION, FBX, FBY + 6*(BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 }
+ // TODO: If in JAPAN mode, simply disable the subtitles button?
+ {AATBUT, OPENQUIT, NULL, SIX_QUIT_OPTION, FBX, FBY + 5 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0},
+ {AATBUT, CLOSEWIN, NULL, SIX_RESUME_OPTION, FBX, FBY + 6 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}
#else
- { AATBUT, OPENSUBT, TM_NONE, NULL, SIX_SUBTITLES_OPTION,FBX, FBY + 5*(BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 },
- { AATBUT, OPENQUIT, TM_NONE, NULL, SIX_QUIT_OPTION, FBX, FBY + 6*(BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 },
- { AATBUT, CLOSEWIN, TM_NONE, NULL, SIX_RESUME_OPTION, FBX, FBY + 7*(BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 }
+ {AATBUT, OPENSUBT, TM_NONE, NULL, SIX_SUBTITLES_OPTION, FBX, FBY + 5 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0},
+ {AATBUT, OPENQUIT, TM_NONE, NULL, SIX_QUIT_OPTION, FBX, FBY + 6 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0},
+ {AATBUT, CLOSEWIN, TM_NONE, NULL, SIX_RESUME_OPTION, FBX, FBY + 7 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}
#endif
};
-static CONFINIT t1ciOption = { 6, 5, 72, 23, false, t1OptionBox, ARRAYSIZE(t1OptionBox), NO_HEADING };
+static CONFINIT t1ciOption = {6, 5, 72, 23, false, t1OptionBox, ARRAYSIZE(t1OptionBox), NO_HEADING};
static CONFBOX t2OptionBox[] = {
- { AATBUT, OPENLOAD, TM_INDEX, NULL, SS_LOAD_OPTION, T2_OPTX, T2_OPTY, T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { AATBUT, OPENSAVE, TM_INDEX, NULL, SS_SAVE_OPTION, T2_OPTX, T2_OPTY + (T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { AATBUT, OPENREST, TM_INDEX, NULL, SS_RESTART_OPTION, T2_OPTX, T2_OPTY + 2*(T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { AATBUT, OPENSOUND, TM_INDEX, NULL, SS_SOUND_OPTION, T2_OPTX, T2_OPTY + 3*(T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { AATBUT, OPENQUIT, TM_INDEX, NULL, SS_QUIT_OPTION, T2_OPTX, T2_OPTY + 4*(T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0 }
+ {AATBUT, OPENLOAD, TM_INDEX, NULL, SS_LOAD_OPTION, T2_OPTX, T2_OPTY, T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {AATBUT, OPENSAVE, TM_INDEX, NULL, SS_SAVE_OPTION, T2_OPTX, T2_OPTY + (T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {AATBUT, OPENREST, TM_INDEX, NULL, SS_RESTART_OPTION, T2_OPTX, T2_OPTY + 2 * (T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {AATBUT, OPENSOUND, TM_INDEX, NULL, SS_SOUND_OPTION, T2_OPTX, T2_OPTY + 3 * (T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {AATBUT, OPENQUIT, TM_INDEX, NULL, SS_QUIT_OPTION, T2_OPTX, T2_OPTY + 4 * (T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0}
};
-static CONFINIT t2ciOption = { 6, 4, 144, 60, false, t2OptionBox, sizeof(t2OptionBox)/sizeof(CONFBOX), NO_HEADING };
+static CONFINIT t2ciOption = {6, 4, 144, 60, false, t2OptionBox, sizeof(t2OptionBox) / sizeof(CONFBOX), NO_HEADING};
#define ciOption (TinselV2 ? t2ciOption : t1ciOption)
#define optionBox (TinselV2 ? t2OptionBox : t1OptionBox)
@@ -655,84 +400,79 @@ static CONFINIT t2ciOption = { 6, 4, 144, 60, false, t2OptionBox, sizeof(t2Optio
| These are the load and save game menus. |
\*-------------------------------------------------------------*/
-#define NUM_RGROUP_BOXES 9
+#define NUM_RGROUP_BOXES 9
#ifdef JAPAN
-#define NUM_RGROUP_BOXES 7 // number of visible slots
-#define SY 32 // y-position of first slot
+#define NUM_RGROUP_BOXES 7 // number of visible slots
+#define SY 32 // y-position of first slot
#else
-#define NUM_RGROUP_BOXES 9 // number of visible slots
-#define SY 31 // y-position of first slot
+#define NUM_RGROUP_BOXES 9 // number of visible slots
+#define SY 31 // y-position of first slot
#endif
-static CONFBOX t1LoadBox[NUM_RGROUP_BOXES+2] = {
- { RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY, EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
- { RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
- { RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 2*(BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
- { RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 3*(BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
- { RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 4*(BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
- { RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 5*(BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
- { RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 6*(BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
+static CONFBOX t1LoadBox[NUM_RGROUP_BOXES + 2] = {
+ {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY, EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
+ {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
+ {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 2 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
+ {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 3 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
+ {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 4 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
+ {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 5 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
+ {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 6 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
#ifndef JAPAN
- { RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 7*(BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
- { RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 8*(BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
+ {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 7 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
+ {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 8 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
#endif
- { ARSGBUT, LOADGAME, TM_NONE, NULL, USE_POINTER, 230, 44, 23, 19, NULL, IX1_TICK1 },
- { AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 230, 44+47, 23, 19, NULL, IX1_CROSS1 }
-};
+ {ARSGBUT, LOADGAME, TM_NONE, NULL, USE_POINTER, 230, 44, 23, 19, NULL, IX1_TICK1},
+ {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 230, 44 + 47, 23, 19, NULL, IX1_CROSS1}};
static CONFBOX t2LoadBox[] = {
- { RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 2*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 3*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 4*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 5*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 6*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 7*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 8*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
-
- { ARSGBUT, LOADGAME, TM_NONE, NULL, 0, 460, 100, BW, BH, NULL, IX2_TICK1 },
- { AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100+100, BW, BH, NULL, IX2_CROSS1 }
-};
-
-static CONFINIT t1ciLoad = { 10, 6, 20, 16, true, t1LoadBox, ARRAYSIZE(t1LoadBox), SIX_LOAD_HEADING };
-static CONFINIT t2ciLoad = { 10, 6, 40, 16, true, t2LoadBox, sizeof(t2LoadBox)/sizeof(CONFBOX), SS_LOAD_HEADING };
-
-
-static CONFBOX t1SaveBox[NUM_RGROUP_BOXES+2] = {
- { RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY, EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
- { RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
- { RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 2*(BOX_HEIGHT + 2),EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
- { RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 3*(BOX_HEIGHT + 2),EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
- { RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 4*(BOX_HEIGHT + 2),EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
- { RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 5*(BOX_HEIGHT + 2),EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
- { RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 6*(BOX_HEIGHT + 2),EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
+ {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 2 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 3 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 4 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 5 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 6 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 7 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 8 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+
+ {ARSGBUT, LOADGAME, TM_NONE, NULL, 0, 460, 100, BW, BH, NULL, IX2_TICK1},
+ {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100 + 100, BW, BH, NULL, IX2_CROSS1}};
+
+static CONFINIT t1ciLoad = {10, 6, 20, 16, true, t1LoadBox, ARRAYSIZE(t1LoadBox), SIX_LOAD_HEADING};
+static CONFINIT t2ciLoad = {10, 6, 40, 16, true, t2LoadBox, sizeof(t2LoadBox) / sizeof(CONFBOX), SS_LOAD_HEADING};
+
+static CONFBOX t1SaveBox[NUM_RGROUP_BOXES + 2] = {
+ {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY, EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
+ {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
+ {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 2 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
+ {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 3 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
+ {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 4 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
+ {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 5 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
+ {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 6 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
#ifndef JAPAN
- { RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 7*(BOX_HEIGHT + 2),EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
- { RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 8*(BOX_HEIGHT + 2),EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
+ {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 7 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
+ {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 8 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
#endif
- { ARSGBUT, SAVEGAME, TM_NONE, NULL,USE_POINTER, 230, 44, 23, 19, NULL, IX1_TICK1 },
- { AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 230, 44+47, 23, 19, NULL, IX1_CROSS1 }
-};
+ {ARSGBUT, SAVEGAME, TM_NONE, NULL, USE_POINTER, 230, 44, 23, 19, NULL, IX1_TICK1},
+ {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 230, 44 + 47, 23, 19, NULL, IX1_CROSS1}};
static CONFBOX t2SaveBox[] = {
- { RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 2*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 3*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 4*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 5*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 6*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 7*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 8*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
-
- { ARSGBUT, SAVEGAME, TM_NONE, NULL, 0, 460, 100, BW, BH, NULL, IX2_TICK1 },
- { AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100+100, BW, BH, NULL, IX2_CROSS1 }
-};
-
-static CONFINIT t1ciSave = { 10, 6, 20, 16, true, t1SaveBox, ARRAYSIZE(t1SaveBox), SIX_SAVE_HEADING };
-static CONFINIT t2ciSave = { 10, 6, 40, 16, true, t2SaveBox, sizeof(t2SaveBox)/sizeof(CONFBOX), SS_SAVE_HEADING };
+ {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 2 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 3 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 4 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 5 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 6 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 7 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 8 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+
+ {ARSGBUT, SAVEGAME, TM_NONE, NULL, 0, 460, 100, BW, BH, NULL, IX2_TICK1},
+ {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100 + 100, BW, BH, NULL, IX2_CROSS1}};
+
+static CONFINIT t1ciSave = {10, 6, 20, 16, true, t1SaveBox, ARRAYSIZE(t1SaveBox), SIX_SAVE_HEADING};
+static CONFINIT t2ciSave = {10, 6, 40, 16, true, t2SaveBox, sizeof(t2SaveBox) / sizeof(CONFBOX), SS_SAVE_HEADING};
#define ciLoad (TinselV2 ? t2ciLoad : t1ciLoad)
#define loadBox (TinselV2 ? t2LoadBox : t1LoadBox)
@@ -745,31 +485,29 @@ static CONFINIT t2ciSave = { 10, 6, 40, 16, true, t2SaveBox, sizeof(t2SaveBox)/s
static CONFBOX t1RestartBox[] = {
#ifdef JAPAN
- { AAGBUT, INITGAME, TM_NONE, NULL, USE_POINTER, 96, 44, 23, 19, NULL, IX_TICK1 },
- { AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 56, 44, 23, 19, NULL, IX_CROSS1 }
+ {AAGBUT, INITGAME, TM_NONE, NULL, USE_POINTER, 96, 44, 23, 19, NULL, IX_TICK1},
+ {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 56, 44, 23, 19, NULL, IX_CROSS1}
#else
- { AAGBUT, INITGAME, TM_NONE, NULL, USE_POINTER, 70, 28, 23, 19, NULL, IX1_TICK1 },
- { AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 30, 28, 23, 19, NULL, IX1_CROSS1 }
+ {AAGBUT, INITGAME, TM_NONE, NULL, USE_POINTER, 70, 28, 23, 19, NULL, IX1_TICK1},
+ {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 30, 28, 23, 19, NULL, IX1_CROSS1}
#endif
};
static CONFBOX t1RestartBoxPSX[] = {
- { AAGBUT, INITGAME, TM_NONE, NULL, USE_POINTER, 122, 48, 23, 19, NULL, IX1_TICK1 },
- { AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 82, 48, 23, 19, NULL, IX1_CROSS1 }
-};
+ {AAGBUT, INITGAME, TM_NONE, NULL, USE_POINTER, 122, 48, 23, 19, NULL, IX1_TICK1},
+ {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 82, 48, 23, 19, NULL, IX1_CROSS1}};
static CONFBOX t2RestartBox[] = {
- { AAGBUT, INITGAME, TM_NONE, NULL, 0, 140, 78, BW, BH, NULL, IX2_TICK1 },
- { AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 60, 78, BW, BH, NULL, IX2_CROSS1 }
-};
+ {AAGBUT, INITGAME, TM_NONE, NULL, 0, 140, 78, BW, BH, NULL, IX2_TICK1},
+ {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 60, 78, BW, BH, NULL, IX2_CROSS1}};
#ifdef JAPAN
-static CONFINIT t1ciRestart = { 6, 2, 72, 53, false, t1RestartBox, ARRAYSIZE(t1RestartBox), SIX_RESTART_HEADING };
+static CONFINIT t1ciRestart = {6, 2, 72, 53, false, t1RestartBox, ARRAYSIZE(t1RestartBox), SIX_RESTART_HEADING};
#else
-static CONFINIT t1ciRestart = { 4, 2, 98, 53, false, t1RestartBox, ARRAYSIZE(t1RestartBox), SIX_RESTART_HEADING };
+static CONFINIT t1ciRestart = {4, 2, 98, 53, false, t1RestartBox, ARRAYSIZE(t1RestartBox), SIX_RESTART_HEADING};
#endif
-static CONFINIT t1ciRestartPSX = { 8, 2, 46, 53, false, t1RestartBoxPSX, ARRAYSIZE(t1RestartBoxPSX), SIX_RESTART_HEADING };
-static CONFINIT t2ciRestart = { 4, 2, 196, 53, false, t2RestartBox, sizeof(t2RestartBox)/sizeof(CONFBOX), SS_RESTART_HEADING };
+static CONFINIT t1ciRestartPSX = {8, 2, 46, 53, false, t1RestartBoxPSX, ARRAYSIZE(t1RestartBoxPSX), SIX_RESTART_HEADING};
+static CONFINIT t2ciRestart = {4, 2, 196, 53, false, t2RestartBox, sizeof(t2RestartBox) / sizeof(CONFBOX), SS_RESTART_HEADING};
#define ciRestart (TinselV2 ? t2ciRestart : (TinselV1PSX ? t1ciRestartPSX : t1ciRestart))
@@ -779,23 +517,21 @@ static CONFINIT t2ciRestart = { 4, 2, 196, 53, false, t2RestartBox, sizeof(t2Res
\*-------------------------------------------------------------*/
static CONFBOX t1SoundBox[] = {
- { SLIDER, MUSICVOL, TM_NONE, NULL, SIX_MVOL_SLIDER, 142, 25, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_musicVolume*/, 0 },
- { SLIDER, NOFUNC, TM_NONE, NULL, SIX_SVOL_SLIDER, 142, 25+40, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_soundVolume*/, 0 },
- { SLIDER, NOFUNC, TM_NONE, NULL, SIX_VVOL_SLIDER, 142, 25+2*40, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_voiceVolume*/, 0 }
-};
+ {SLIDER, MUSICVOL, TM_NONE, NULL, SIX_MVOL_SLIDER, 142, 25, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_musicVolume*/, 0},
+ {SLIDER, NOFUNC, TM_NONE, NULL, SIX_SVOL_SLIDER, 142, 25 + 40, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_soundVolume*/, 0},
+ {SLIDER, NOFUNC, TM_NONE, NULL, SIX_VVOL_SLIDER, 142, 25 + 2 * 40, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_voiceVolume*/, 0}};
static CONFBOX t2SoundBox[] = {
- { SLIDER, MUSICVOL, TM_INDEX, NULL, SS_MVOL_SLIDER, 280, 50, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_musicVolume*/, 0 },
- { SLIDER, NOFUNC, TM_INDEX, NULL, SS_SVOL_SLIDER, 280, 50+30, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_soundVolume*/, 0 },
- { SLIDER, NOFUNC, TM_INDEX, NULL, SS_VVOL_SLIDER, 280, 50+2*30, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_voiceVolume*/, 0 },
+ {SLIDER, MUSICVOL, TM_INDEX, NULL, SS_MVOL_SLIDER, 280, 50, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_musicVolume*/, 0},
+ {SLIDER, NOFUNC, TM_INDEX, NULL, SS_SVOL_SLIDER, 280, 50 + 30, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_soundVolume*/, 0},
+ {SLIDER, NOFUNC, TM_INDEX, NULL, SS_VVOL_SLIDER, 280, 50 + 2 * 30, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_voiceVolume*/, 0},
- { SLIDER, NOFUNC, TM_INDEX, NULL, SS_TSPEED_SLIDER, 280, 160, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0 },
- { TOGGLE2, NOFUNC, TM_INDEX, NULL, SS_STITLE_TOGGLE, 100, 220, BW, BH, 0 /*&_vm->_config->_useSubtitles*/, 0 },
- { ROTATE, NOFUNC, TM_INDEX, NULL, SS_LANGUAGE_SELECT, 320,220, BW, BH, NULL, 0 }
-};
+ {SLIDER, NOFUNC, TM_INDEX, NULL, SS_TSPEED_SLIDER, 280, 160, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0},
+ {TOGGLE2, NOFUNC, TM_INDEX, NULL, SS_STITLE_TOGGLE, 100, 220, BW, BH, 0 /*&_vm->_config->_useSubtitles*/, 0},
+ {ROTATE, NOFUNC, TM_INDEX, NULL, SS_LANGUAGE_SELECT, 320, 220, BW, BH, NULL, 0}};
-static CONFINIT t1ciSound = { 10, 5, 20, 16, false, t1SoundBox, ARRAYSIZE(t1SoundBox), NO_HEADING };
-static CONFINIT t2ciSound = { 10, 5, 40, 16, false, t2SoundBox, sizeof(t2SoundBox)/sizeof(CONFBOX), SS_SOUND_HEADING };
+static CONFINIT t1ciSound = {10, 5, 20, 16, false, t1SoundBox, ARRAYSIZE(t1SoundBox), NO_HEADING};
+static CONFINIT t2ciSound = {10, 5, 40, 16, false, t2SoundBox, sizeof(t2SoundBox) / sizeof(CONFBOX), SS_SOUND_HEADING};
#define ciSound (TinselV2 ? t2ciSound : t1ciSound)
@@ -803,69 +539,64 @@ static CONFINIT t2ciSound = { 10, 5, 40, 16, false, t2SoundBox, sizeof(t2SoundBo
| This is the (mouse) control 'menu'. |
\*-------------------------------------------------------------*/
-static int bFlipped; // looks like this is just so the code has something to alter!
+static int bFlipped = 0; // looks like this is just so the code has something to alter!
static CONFBOX controlBox[] = {
- { SLIDER, NOFUNC, TM_NONE, NULL, SIX_DCLICK_SLIDER, 142, 25, 3*DOUBLE_CLICK_TIME, 1, 0 /*&_vm->_config->_dclickSpeed*/, 0 },
- { FLIP, NOFUNC, TM_NONE, NULL, SIX_DCLICK_TEST, 142, 25+30, 23, 19, &bFlipped, IX1_CIRCLE1 },
+ {SLIDER, NOFUNC, TM_NONE, NULL, SIX_DCLICK_SLIDER, 142, 25, 3 * DOUBLE_CLICK_TIME, 1, 0 /*&_vm->_config->_dclickSpeed*/, 0},
+ {FLIP, NOFUNC, TM_NONE, NULL, SIX_DCLICK_TEST, 142, 25 + 30, 23, 19, &bFlipped, IX1_CIRCLE1},
#ifdef JAPAN
- { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_SWAP_TOGGLE, 205, 25+70, 23, 19, 0 /*&_vm->_config->_swapButtons*/, 0 }
+ {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_SWAP_TOGGLE, 205, 25 + 70, 23, 19, 0 /*&_vm->_config->_swapButtons*/, 0}
#else
- { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_SWAP_TOGGLE, 155, 25+70, 23, 19, 0 /*&_vm->_config->_swapButtons*/, 0 }
+ {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_SWAP_TOGGLE, 155, 25 + 70, 23, 19, 0 /*&_vm->_config->_swapButtons*/, 0}
#endif
};
-static CONFINIT ciControl = { 10, 5, 20, 16, false, controlBox, ARRAYSIZE(controlBox), NO_HEADING };
+static CONFINIT ciControl = {10, 5, 20, 16, false, controlBox, ARRAYSIZE(controlBox), NO_HEADING};
/*-------------------------------------------------------------*\
| This is the subtitles 'menu'. |
\*-------------------------------------------------------------*/
static CONFBOX subtitlesBox[] = {
- { SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0 },
- { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20+40, 23, 19, 0 /*&_vm->_config->_useSubtitles*/, 0 },
+ {SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0},
+ {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20 + 40, 23, 19, 0 /*&_vm->_config->_useSubtitles*/, 0},
};
static CONFBOX subtitlesBox3Flags[] = {
- { FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 15, 118, 56, 32, NULL, FIX_FR },
- { FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 85, 118, 56, 32, NULL, FIX_GR },
- { FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 155, 118, 56, 32, NULL, FIX_SP },
+ {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 15, 118, 56, 32, NULL, FIX_FR},
+ {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 85, 118, 56, 32, NULL, FIX_GR},
+ {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 155, 118, 56, 32, NULL, FIX_SP},
- { SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0 },
- { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20+40, 23, 19, 0 /*&_vm->_config->_useSubtitles*/, 0 },
+ {SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0},
+ {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20 + 40, 23, 19, 0 /*&_vm->_config->_useSubtitles*/, 0},
- { ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1 },
- { AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1 }
-};
+ {ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1},
+ {AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1}};
static CONFBOX subtitlesBox4Flags[] = {
- { FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 20, 100, 56, 32, NULL, FIX_FR },
- { FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 108, 100, 56, 32, NULL, FIX_GR },
- { FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 64, 137, 56, 32, NULL, FIX_IT },
- { FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 152, 137, 56, 32, NULL, FIX_SP },
+ {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 20, 100, 56, 32, NULL, FIX_FR},
+ {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 108, 100, 56, 32, NULL, FIX_GR},
+ {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 64, 137, 56, 32, NULL, FIX_IT},
+ {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 152, 137, 56, 32, NULL, FIX_SP},
- { SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0 },
- { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20+40, 23, 19, 0 /*&_vm->_config->_useSubtitles*/, 0 },
-
- { ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1 },
- { AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1 }
-};
+ {SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0},
+ {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20 + 40, 23, 19, 0 /*&_vm->_config->_useSubtitles*/, 0},
+ {ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1},
+ {AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1}};
-static CONFBOX subtitlesBox5Flags[] = {
- { FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 15, 100, 56, 32, NULL, FIX_UK },
- { FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 85, 100, 56, 32, NULL, FIX_FR },
- { FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 155, 100, 56, 32, NULL, FIX_GR },
- { FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 50, 137, 56, 32, NULL, FIX_IT },
- { FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 120, 137, 56, 32, NULL, FIX_SP },
+static CONFBOX subtitlesBox5Flags[] = {
+ {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 15, 100, 56, 32, NULL, FIX_UK},
+ {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 85, 100, 56, 32, NULL, FIX_FR},
+ {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 155, 100, 56, 32, NULL, FIX_GR},
+ {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 50, 137, 56, 32, NULL, FIX_IT},
+ {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 120, 137, 56, 32, NULL, FIX_SP},
- { SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0 },
- { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20+40, 23, 19, 0 /*&_vm->_config->_useSubtitles*/, 0 },
-
- { ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1 },
- { AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1 }
-};
+ {SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0},
+ {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20 + 40, 23, 19, 0 /*&_vm->_config->_useSubtitles*/, 0},
+ {ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1},
+ {AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1}};
/*-------------------------------------------------------------*\
| This is the quit confirmation 'menu'. |
@@ -873,21 +604,20 @@ static CONFBOX subtitlesBox5Flags[] = {
static CONFBOX t1QuitBox[] = {
#ifdef JAPAN
- { AAGBUT, IQUITGAME, TM_NONE, NULL, USE_POINTER,70, 44, 23, 19, NULL, IX_TICK1 },
- { AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 30, 44, 23, 19, NULL, IX_CROSS1 }
+ {AAGBUT, IQUITGAME, TM_NONE, NULL, USE_POINTER, 70, 44, 23, 19, NULL, IX_TICK1},
+ {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 30, 44, 23, 19, NULL, IX_CROSS1}
#else
- { AAGBUT, IQUITGAME, TM_NONE, NULL, USE_POINTER,70, 28, 23, 19, NULL, IX1_TICK1 },
- { AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 30, 28, 23, 19, NULL, IX1_CROSS1 }
+ {AAGBUT, IQUITGAME, TM_NONE, NULL, USE_POINTER, 70, 28, 23, 19, NULL, IX1_TICK1},
+ {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 30, 28, 23, 19, NULL, IX1_CROSS1}
#endif
};
static CONFBOX t2QuitBox[] = {
- { AAGBUT, IQUITGAME, TM_NONE, NULL, 0,140, 78, BW, BH, NULL, IX2_TICK1 },
- { AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 60, 78, BW, BH, NULL, IX2_CROSS1 }
-};
+ {AAGBUT, IQUITGAME, TM_NONE, NULL, 0, 140, 78, BW, BH, NULL, IX2_TICK1},
+ {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 60, 78, BW, BH, NULL, IX2_CROSS1}};
-static CONFINIT t1ciQuit = { 4, 2, 98, 53, false, t1QuitBox, ARRAYSIZE(t1QuitBox), SIX_QUIT_HEADING };
-static CONFINIT t2ciQuit = { 4, 2, 196, 53, false, t2QuitBox, sizeof(t2QuitBox)/sizeof(CONFBOX), SS_QUIT_HEADING };
+static CONFINIT t1ciQuit = {4, 2, 98, 53, false, t1QuitBox, ARRAYSIZE(t1QuitBox), SIX_QUIT_HEADING};
+static CONFINIT t2ciQuit = {4, 2, 196, 53, false, t2QuitBox, sizeof(t2QuitBox) / sizeof(CONFBOX), SS_QUIT_HEADING};
#define quitBox (TinselV2 ? t2QuitBox : t1QuitBox)
#define ciQuit (TinselV2 ? t2ciQuit : t1ciQuit)
@@ -897,150 +627,223 @@ static CONFINIT t2ciQuit = { 4, 2, 196, 53, false, t2QuitBox, sizeof(t2QuitBox)/
\***************************************************************************/
static CONFBOX hopperBox1[] = {
- { RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 2*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 3*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 4*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 5*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 6*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 7*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 8*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
-
- { ARSGBUT, HOPPER2, TM_NONE, NULL, 0, 460, 100, BW, BH, NULL, IX2_TICK1 },
- { AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100 + 100, BW, BH, NULL, IX2_CROSS1 }
-};
+ {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 2 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 3 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 4 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 5 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 6 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 7 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 8 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
-static CONFINIT ciHopper1 = { 10, 6, 40, 16, true, hopperBox1, sizeof(hopperBox1) / sizeof(CONFBOX), SS_HOPPER1 };
+ {ARSGBUT, HOPPER2, TM_NONE, NULL, 0, 460, 100, BW, BH, NULL, IX2_TICK1},
+ {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100 + 100, BW, BH, NULL, IX2_CROSS1}};
+
+static CONFINIT ciHopper1 = {10, 6, 40, 16, true, hopperBox1, sizeof(hopperBox1) / sizeof(CONFBOX), SS_HOPPER1};
static CONFBOX hopperBox2[] = {
- { RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 2*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 3*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 4*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 5*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 6*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 7*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
- { RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 8*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
-
- { ARSGBUT, BF_CHANGESCENE, TM_NONE, NULL, 0, 460, 50, BW, BH, NULL, IX2_TICK1 },
- { AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 200, BW, BH, NULL, IX2_CROSS1 }
-};
+ {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 2 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 3 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 4 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 5 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 6 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 7 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
+ {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 8 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
-static CONFINIT ciHopper2 = { 10, 6, 40, 16, true, hopperBox2, sizeof(hopperBox2)/sizeof(CONFBOX), NO_HEADING };
+ {ARSGBUT, BF_CHANGESCENE, TM_NONE, NULL, 0, 460, 50, BW, BH, NULL, IX2_TICK1},
+ {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 200, BW, BH, NULL, IX2_CROSS1}};
+static CONFINIT ciHopper2 = {10, 6, 40, 16, true, hopperBox2, sizeof(hopperBox2) / sizeof(CONFBOX), NO_HEADING};
/***************************************************************************\
|**************************** Top Window *****************************|
\***************************************************************************/
static CONFBOX topwinBox[] = {
- { NOTHING, NOFUNC, TM_NONE, NULL, USE_POINTER, 0, 0, 0, 0, NULL, 0 }
-};
-
+ {NOTHING, NOFUNC, TM_NONE, NULL, USE_POINTER, 0, 0, 0, 0, NULL, 0}};
-static CONFINIT ciSubtitles = { 10, 3, 20, 16, false, subtitlesBox, ARRAYSIZE(subtitlesBox), NO_HEADING };
+static CONFINIT ciSubtitles = {10, 3, 20, 16, false, subtitlesBox, ARRAYSIZE(subtitlesBox), NO_HEADING};
-static CONFINIT ciTopWin = { 6, 5, 72, 23, false, topwinBox, 0, NO_HEADING };
+static CONFINIT ciTopWin = {6, 5, 72, 23, false, topwinBox, 0, NO_HEADING};
#define NOBOX (-1)
// Conf window globals
static struct {
CONFBOX *box;
- int NumBoxes;
+ int NumBoxes;
bool bExtraWin;
uint32 ixHeading;
bool editableRgroup;
- int selBox;
- int pointBox; // Box pointed to on last call
- int modifier;
- int extraBase;
- int numSaved;
+ int selBox;
+ int pointBox; // Box pointed to on last call
+ int modifier;
+ int extraBase;
+ int numSaved;
} cd = {
- NULL, 0, false, 0, false,
- NOBOX, NOBOX, 0, 0, 0
-};
-
-// For editing save game names
-static char g_sedit[SG_DESC_LEN+2];
-
-#define HL1 0 // Hilight that moves with the cursor
-#define HL2 1 // Hilight on selected RGROUP box
-#define HL3 2 // Text on selected RGROUP box
-#define NUMHL 3
-
-
-// Data for button press/toggle effects
-static struct {
- bool bButAnim;
- CONFBOX *box;
- bool press; // true = button press; false = button toggle
-} g_buttonEffect = { false, 0, false };
+ NULL, 0, false, 0, false,
+ NOBOX, NOBOX, 0, 0, 0};
+#define HL1 0 // Hilight that moves with the cursor
+#define HL2 1 // Hilight on selected RGROUP box
+#define HL3 2 // Text on selected RGROUP box
+#define NUMHL 3
//----- LOCAL FORWARD REFERENCES -----
enum {
- IB_NONE = -1, //
- IB_UP = -2, // negative numbers returned
- IB_DOWN = -3, // by WhichMenuBox()
- IB_SLIDE = -4, //
- IB_SLIDE_UP = -5, //
- IB_SLIDE_DOWN = -6 //
+ IB_NONE = -1, //
+ IB_UP = -2, // negative numbers returned
+ IB_DOWN = -3, // by WhichMenuBox()
+ IB_SLIDE = -4, //
+ IB_SLIDE_UP = -5, //
+ IB_SLIDE_DOWN = -6 //
};
enum {
- HI_BIT = ((uint)MIN_INT >> 1), // The next to top bit
- IS_LEFT = HI_BIT,
- IS_SLIDER = (IS_LEFT >> 1),
- IS_RIGHT = (IS_SLIDER >> 1),
- IS_MASK = (IS_LEFT | IS_SLIDER | IS_RIGHT)
+ HI_BIT = ((uint)MIN_INT >> 1), // The next to top bit
+ IS_LEFT = HI_BIT,
+ IS_SLIDER = (IS_LEFT >> 1),
+ IS_RIGHT = (IS_SLIDER >> 1),
+ IS_MASK = (IS_LEFT | IS_SLIDER | IS_RIGHT)
};
-static int WhichMenuBox(int curX, int curY, bool bSlides);
-static void SlideMSlider(int x, SSFN fn);
-static OBJECT *AddObject(const FREEL *pfreel, int num);
-static void AddBoxes(bool posnSlide);
-
-static void ConfActionSpecial(int i);
-
-static bool RePosition();
-
/*-------------------------------------------------------------------------*/
/*** Magic numbers ***/
-#define M_SW 5 // Side width
-#define M_TH 5 // Top height
+#define M_SW 5 // Side width
+#define M_TH 5 // Top height
#ifdef JAPAN
-#define M_TOFF 6 // Title text Y offset from top
-#define M_TBB 20 // Title box bottom Y offset
+#define M_TOFF 6 // Title text Y offset from top
+#define M_TBB 20 // Title box bottom Y offset
#else
-#define M_TOFF 4 // Title text Y offset from top
-#define M_TBB 14 // Title box bottom Y offset
+#define M_TOFF 4 // Title text Y offset from top
+#define M_TBB 14 // Title box bottom Y offset
#endif
-#define M_SBL 26 // Scroll bar left X offset
-#define M_SH 5 // Slider height (*)
-#define M_SW 5 // Slider width (*)
-#define M_SXOFF 9 // Slider X offset from right-hand side
+#define M_SBL 26 // Scroll bar left X offset
+#define M_SH 5 // Slider height (*)
+#define M_SW 5 // Slider width (*)
+#define M_SXOFF 9 // Slider X offset from right-hand side
#ifdef JAPAN
-#define M_IUT 22 // Y offset of top of up arrow
-#define M_IUB 30 // Y offset of bottom of up arrow
+#define M_IUT 22 // Y offset of top of up arrow
+#define M_IUB 30 // Y offset of bottom of up arrow
#else
-#define M_IUT 16 // Y offset of top of up arrow
-#define M_IUB 24 // Y offset of bottom of up arrow
+#define M_IUT 16 // Y offset of top of up arrow
+#define M_IUB 24 // Y offset of bottom of up arrow
#endif
-#define M_IDT 10 // Y offset (from bottom) of top of down arrow
-#define M_IDB 3 // Y offset (from bottom) of bottom of down arrow
+#define M_IDT 10 // Y offset (from bottom) of top of down arrow
+#define M_IDB 3 // Y offset (from bottom) of bottom of down arrow
-#define START_ICONX (TinselV2 ? 12 : (M_SW+1)) // } Relative offset of first icon
-#define START_ICONY (TinselV2 ? 40 : (M_TBB+M_TH+1)) // } within the inventory window
+#define START_ICONX (TinselV2 ? 12 : (M_SW + 1)) // } Relative offset of first icon
+#define START_ICONY (TinselV2 ? 40 : (M_TBB + M_TH + 1)) // } within the inventory window
/*-------------------------------------------------------------------------*/
+static void InvTinselEvent(INV_OBJECT *pinvo, TINSEL_EVENT event, PLR_EVENT be, int index);
+static void InvPdProcess(CORO_PARAM, const void *param);
+
+Dialogs::Dialogs() {
+ g_buttonEffect = {false, 0, false};
+
+ g_hWinParts = 0;
+ g_flagFilm = 0;
+ memset(g_configStrings, 0, sizeof(g_configStrings));
+
+ g_invObjects = nullptr;
+ g_numObjects = 0;
+ g_invFilms = nullptr;
+ g_bNoLanguage = false;
+
+ memset(g_objArray, 0, sizeof(g_objArray));
+ memset(g_iconArray, 0, sizeof(g_iconArray));
+ memset(g_DobjArray, 0, sizeof(g_DobjArray));
+ memset(g_iconAnims, 0, sizeof(g_iconAnims));
+ memset(g_permIcons, 0, sizeof(g_permIcons));
+ memset(g_InvD, 0, sizeof(g_InvD));
+
+ g_initialDirection = FORWARD;
+
+ g_heldItem = INV_NOICON;
+
+ g_heldFilm = 0;
+
+ g_numPermIcons = 0;
+ g_numEndIcons = 0;
+
+ g_ino = 0;
+
+ g_InventoryHidden = false;
+ g_InventoryMaximised = false;
+
+ g_SuppH = 0;
+ g_SuppV = 0;
+
+ g_Ychange = 0;
+ g_Ycompensate = 0;
+ g_Xchange = 0;
+ g_Xcompensate = 0;
+
+ g_ItemsChanged = 0;
+
+ g_bReOpenMenu = 0;
+
+ g_TL = g_TR = g_BL = g_BR = 0;
+ g_TLwidth = 0, g_TLheight = 0;
+ g_TRwidth = 0;
+ g_BLheight = 0;
+
+ g_displayedLanguage = TXT_ENGLISH;
+
+ g_RectObject = nullptr;
+ g_SlideObject = nullptr;
+
+ g_sliderYpos = 0;
+ g_sliderYmax = g_sliderYmin = 0;
+
+ memset(g_mdSlides, 0, sizeof(g_mdSlides));
-static bool LanguageChange() {
+ g_numMdSlides = 0;
+ g_GlitterIndex = 0;
+ g_thisIcon = 0;
+
+ memset(&g_thisConvFn, 0, sizeof(g_thisConvFn));
+
+ g_thisConvPoly = 0;
+ g_thisConvActor = 0;
+ g_pointedIcon = INV_NOICON;
+ g_PointedWaitCount = 0;
+ g_sX = 0;
+ g_lX = 0;
+
+ g_bMoveOnUnHide = false;
+
+ g_pHopper = nullptr;
+ g_pEntries = nullptr;
+
+ g_numScenes = 0;
+
+ g_numEntries = 0;
+
+ g_pChosenScene = nullptr;
+
+ g_lastChosenScene = 0;
+ g_bRemember = false;
+
+ *g_sedit = 0;
+}
+
+Dialogs::~Dialogs() {
+ if (g_objArray[0] != NULL) {
+ DumpObjArray();
+ DumpDobjArray();
+ DumpIconArray();
+ }
+}
+
+bool Dialogs::LanguageChange() {
LANGUAGE nLang = _vm->_config->_language;
if ((_vm->getFeatures() & GF_USE_3FLAGS) || (_vm->getFeatures() & GF_USE_4FLAGS) || (_vm->getFeatures() & GF_USE_5FLAGS)) {
@@ -1076,7 +879,7 @@ static bool LanguageChange() {
* Read in the scene hopper data file and set the
* pointers to the data and scene count.
*/
-static void PrimeSceneHopper() {
+void Dialogs::PrimeSceneHopper() {
Common::File f;
char *pBuffer;
uint32 vSize;
@@ -1118,13 +921,13 @@ static void PrimeSceneHopper() {
/**
* Free the scene hopper data file
*/
-static void FreeSceneHopper() {
+void Dialogs::FreeSceneHopper() {
free(g_pHopper);
g_pHopper = nullptr;
}
-static void FirstScene(int first) {
- int i;
+void Dialogs::FirstScene(int first) {
+ int i;
assert(g_numScenes && g_pHopper);
@@ -1154,17 +957,17 @@ static void FirstScene(int first) {
cd.extraBase = first;
}
-static void RememberChosenScene() {
+void Dialogs::RememberChosenScene() {
g_bRemember = true;
}
-static void SetChosenScene() {
+void Dialogs::SetChosenScene() {
g_lastChosenScene = cd.selBox + cd.extraBase;
g_pChosenScene = &g_pHopper[cd.selBox + cd.extraBase];
}
-static void FirstEntry(int first) {
- int i;
+void Dialogs::FirstEntry(int first) {
+ int i;
g_InvD[INV_MENU].hInvTitle = FROM_32(g_pChosenScene->hSceneDesc);
@@ -1172,8 +975,8 @@ static void FirstEntry(int first) {
g_numEntries = FROM_32(g_pChosenScene->numEntries);
// Force first to a sensible value
- if (first > g_numEntries-NUM_RGROUP_BOXES)
- first = g_numEntries-NUM_RGROUP_BOXES;
+ if (first > g_numEntries - NUM_RGROUP_BOXES)
+ first = g_numEntries - NUM_RGROUP_BOXES;
if (first < 0)
first = 0;
@@ -1190,7 +993,7 @@ static void FirstEntry(int first) {
cd.extraBase = first;
}
-static void HopAction() {
+void Dialogs::HopAction() {
PHOPENTRY pEntry = g_pEntries + FROM_32(g_pChosenScene->entryIndex) + cd.selBox + cd.extraBase;
uint32 hScene = FROM_32(g_pChosenScene->hScene);
@@ -1200,8 +1003,7 @@ static void HopAction() {
if (FROM_32(pEntry->flags) & fCall) {
SaveScene(Common::nullContext);
NewScene(Common::nullContext, g_pChosenScene->hScene, pEntry->eNumber, TRANS_FADE);
- }
- else if (FROM_32(pEntry->flags) & fHook)
+ } else if (FROM_32(pEntry->flags) & fHook)
HookScene(hScene, eNumber, TRANS_FADE);
else
NewScene(Common::nullContext, hScene, eNumber, TRANS_CUT);
@@ -1214,7 +1016,7 @@ static void HopAction() {
/**
* Delete all the objects in iconArray[]
*/
-static void DumpIconArray() {
+void Dialogs::DumpIconArray() {
for (int i = 0; i < MAX_ICONS; i++) {
if (g_iconArray[i] != NULL) {
MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[i]);
@@ -1226,7 +1028,7 @@ static void DumpIconArray() {
/**
* Delete all the objects in DobjArray[]
*/
-static void DumpDobjArray() {
+void Dialogs::DumpDobjArray() {
for (int i = 0; i < MAX_WCOMP; i++) {
if (g_DobjArray[i] != NULL) {
MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_DobjArray[i]);
@@ -1238,7 +1040,7 @@ static void DumpDobjArray() {
/**
* Delete all the objects in objArray[]
*/
-static void DumpObjArray() {
+void Dialogs::DumpObjArray() {
for (int i = 0; i < MAX_WCOMP; i++) {
if (g_objArray[i] != NULL) {
MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_objArray[i]);
@@ -1251,7 +1053,7 @@ static void DumpObjArray() {
* Convert item ID number to pointer to item's compiled data
* i.e. Image data and Glitter code.
*/
-static INV_OBJECT *GetInvObject(int id) {
+INV_OBJECT *Dialogs::GetInvObject(int id) {
INV_OBJECT *pObject = g_invObjects;
for (int i = 0; i < g_numObjects; i++, pObject++) {
@@ -1265,7 +1067,7 @@ static INV_OBJECT *GetInvObject(int id) {
/**
* Returns true if the given id represents a valid inventory object
*/
-bool GetIsInvObject(int id) {
+bool Dialogs::GetIsInvObject(int id) {
INV_OBJECT *pObject = g_invObjects;
for (int i = 0; i < g_numObjects; i++, pObject++) {
@@ -1279,7 +1081,7 @@ bool GetIsInvObject(int id) {
/**
* Convert item ID number to index.
*/
-static int GetObjectIndex(int id) {
+int Dialogs::GetObjectIndex(int id) {
INV_OBJECT *pObject = g_invObjects;
for (int i = 0; i < g_numObjects; i++, pObject++) {
@@ -1294,27 +1096,27 @@ static int GetObjectIndex(int id) {
* Returns position of an item in one of the inventories.
* The actual position is not important for the uses that this is put to.
*/
-extern int InventoryPos(int num) {
- int i;
+int Dialogs::InventoryPos(int num) {
+ int i;
- for (i = 0; i < g_InvD[INV_1].NoofItems; i++) // First inventory
+ for (i = 0; i < g_InvD[INV_1].NoofItems; i++) // First inventory
if (g_InvD[INV_1].contents[i] == num)
return i;
- for (i = 0; i < g_InvD[INV_2].NoofItems; i++) // Second inventory
+ for (i = 0; i < g_InvD[INV_2].NoofItems; i++) // Second inventory
if (g_InvD[INV_2].contents[i] == num)
return i;
if (g_heldItem == num)
- return INV_HELDNOTIN; // Held, but not in either inventory
+ return INV_HELDNOTIN; // Held, but not in either inventory
- return INV_NOICON; // Not held, not in either inventory
+ return INV_NOICON; // Not held, not in either inventory
}
-extern bool IsInInventory(int object, int invnum) {
+bool Dialogs::IsInInventory(int object, int invnum) {
assert(invnum == INV_1 || invnum == INV_2);
- for (int i = 0; i < g_InvD[invnum].NoofItems; i++) // First inventory
+ for (int i = 0; i < g_InvD[invnum].NoofItems; i++) // First inventory
if (g_InvD[invnum].contents[i] == object)
return true;
@@ -1324,7 +1126,7 @@ extern bool IsInInventory(int object, int invnum) {
/**
* Returns which item is held (INV_NOICON (-1) if none)
*/
-extern int WhichItemHeld() {
+int Dialogs::WhichItemHeld() {
return g_heldItem;
}
@@ -1332,12 +1134,12 @@ extern int WhichItemHeld() {
* Called from the cursor module when it re-initializes (at the start of
* a new scene). For if we are holding something at scene-change time.
*/
-extern void InventoryIconCursor(bool bNewItem) {
+void Dialogs::InventoryIconCursor(bool bNewItem) {
if (g_heldItem != INV_NOICON) {
if (TinselV2) {
if (bNewItem) {
- int objIndex = GetObjectIndex(g_heldItem);
+ int objIndex = GetObjectIndex(g_heldItem);
g_heldFilm = g_invFilms[objIndex];
}
_vm->_cursor->SetAuxCursor(g_heldFilm);
@@ -1351,114 +1153,17 @@ extern void InventoryIconCursor(bool bNewItem) {
/**
* Returns true if the inventory is active.
*/
-extern bool InventoryActive() {
+bool Dialogs::InventoryActive() {
return (g_InventoryState == ACTIVE_INV);
}
-extern int WhichInventoryOpen() {
+int Dialogs::WhichInventoryOpen() {
if (g_InventoryState != ACTIVE_INV)
return 0;
else
return g_ino;
}
-
-/**************************************************************************/
-/************** Running inventory item's Glitter code *********************/
-/**************************************************************************/
-
-struct OP_INIT {
- INV_OBJECT *pinvo;
- TINSEL_EVENT event;
- PLR_EVENT bev;
- int myEscape;
-};
-
-/**
- * Run inventory item's Glitter code
- */
-static void ObjectProcess(CORO_PARAM, const void *param) {
- // COROUTINE
- CORO_BEGIN_CONTEXT;
- INT_CONTEXT *pic;
- int ThisPointedWait; // Fix the 'repeated pressing bug'
- CORO_END_CONTEXT(_ctx);
-
- // get the stuff copied to process when it was created
- const OP_INIT *to = (const OP_INIT *)param;
-
- CORO_BEGIN_CODE(_ctx);
-
- if (!TinselV2)
- CORO_INVOKE_1(AllowDclick, to->bev);
-
- _ctx->pic = InitInterpretContext(GS_INVENTORY, to->pinvo->hScript, to->event, NOPOLY, 0, to->pinvo,
- to->myEscape);
- CORO_INVOKE_1(Interpret, _ctx->pic);
-
- if (to->event == POINTED) {
- _ctx->ThisPointedWait = ++g_PointedWaitCount;
- while (1) {
- CORO_SLEEP(1);
- int x, y;
- _vm->_cursor->GetCursorXY(&x, &y, false);
- if (InvItemId(x, y) != to->pinvo->id)
- break;
-
- // Fix the 'repeated pressing bug'
- if (_ctx->ThisPointedWait != g_PointedWaitCount)
- CORO_KILL_SELF();
- }
-
- _ctx->pic = InitInterpretContext(GS_INVENTORY, to->pinvo->hScript, UNPOINT, NOPOLY, 0, to->pinvo);
- CORO_INVOKE_1(Interpret, _ctx->pic);
- }
-
- CORO_END_CODE;
-}
-
-/**
- * Run inventory item's Glitter code
- */
-static void InvTinselEvent(INV_OBJECT *pinvo, TINSEL_EVENT event, PLR_EVENT be, int index) {
- OP_INIT to = { pinvo, event, be, 0 };
-
- if (g_InventoryHidden || (TinselV2 && !pinvo->hScript))
- return;
-
- g_GlitterIndex = index;
- CoroScheduler.createProcess(PID_TCODE, ObjectProcess, &to, sizeof(to));
-}
-
-extern void ObjectEvent(CORO_PARAM, int objId, TINSEL_EVENT event, bool bWait, int myEscape, bool *result) {
- // COROUTINE
- CORO_BEGIN_CONTEXT;
- Common::PROCESS *pProc;
- INV_OBJECT *pInvo;
- OP_INIT op;
- CORO_END_CONTEXT(_ctx);
-
- CORO_BEGIN_CODE(_ctx);
-
- if (result) *result = false;
- _ctx->pInvo = GetInvObject(objId);
- if (!_ctx->pInvo->hScript)
- return;
-
- _ctx->op.pinvo = _ctx->pInvo;
- _ctx->op.event = event;
- _ctx->op.myEscape = myEscape;
-
- CoroScheduler.createProcess(PID_TCODE, ObjectProcess, &_ctx->op, sizeof(_ctx->op));
-
- if (bWait)
- CORO_INVOKE_2(WaitInterpret, _ctx->pProc, result);
- else if (result)
- *result = false;
-
- CORO_END_CODE;
-}
-
/**************************************************************************/
/****************** Load/Save game specific functions *********************/
/**************************************************************************/
@@ -1467,8 +1172,8 @@ extern void ObjectEvent(CORO_PARAM, int objId, TINSEL_EVENT event, bool bWait, i
* Set first load/save file entry displayed.
* Point Box[] text pointers to appropriate file descriptions.
*/
-static void FirstFile(int first) {
- int i, j;
+void Dialogs::FirstFile(int first) {
+ int i, j;
i = getList();
@@ -1498,22 +1203,22 @@ static void FirstFile(int first) {
* Save the game using filename from selected slot & current description.
*/
-static void InvSaveGame() {
+void Dialogs::InvSaveGame() {
if (cd.selBox != NOBOX) {
#ifndef JAPAN
- g_sedit[strlen(g_sedit)-1] = 0; // Don't include the cursor!
+ g_sedit[strlen(g_sedit) - 1] = 0; // Don't include the cursor!
#endif
- SaveGame(ListEntry(cd.selBox-cd.modifier+cd.extraBase, LE_NAME), g_sedit);
+ SaveGame(ListEntry(cd.selBox - cd.modifier + cd.extraBase, LE_NAME), g_sedit);
}
}
/**
* Load the selected saved game.
*/
-static void InvLoadGame() {
- int rGame;
+void Dialogs::InvLoadGame() {
+ int rGame;
- if (cd.selBox != NOBOX && (cd.selBox+cd.extraBase < cd.numSaved)) {
+ if (cd.selBox != NOBOX && (cd.selBox + cd.extraBase < cd.numSaved)) {
rGame = cd.selBox;
cd.selBox = NOBOX;
if (g_iconArray[HL3] != NULL) {
@@ -1528,7 +1233,7 @@ static void InvLoadGame() {
MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
g_iconArray[HL1] = nullptr;
}
- RestoreGame(rGame+cd.extraBase);
+ RestoreGame(rGame + cd.extraBase);
}
}
@@ -1537,13 +1242,13 @@ static void InvLoadGame() {
* Returns true if the string was altered.
*/
#ifndef JAPAN
-static bool UpdateString(const Common::KeyState &kbd) {
- int cpos;
+bool Dialogs::UpdateString(const Common::KeyState &kbd) {
+ int cpos;
if (!cd.editableRgroup)
return false;
- cpos = strlen(g_sedit)-1;
+ cpos = strlen(g_sedit) - 1;
if (kbd.ascii == 0)
return false;
@@ -1555,14 +1260,14 @@ static bool UpdateString(const Common::KeyState &kbd) {
cpos--;
g_sedit[cpos] = CURSOR_CHAR;
return true;
-// } else if (isalnum(c) || c == ',' || c == '.' || c == '\'' || (c == ' ' && cpos != 0)) {
+ // } else if (isalnum(c) || c == ',' || c == '.' || c == '\'' || (c == ' ' && cpos != 0)) {
} else if (IsCharImage(_vm->_font->GetTagFontHandle(), kbd.ascii) || (kbd.ascii == ' ' && cpos != 0)) {
if (cpos == SG_DESC_LEN)
return false;
g_sedit[cpos] = kbd.ascii;
cpos++;
g_sedit[cpos] = CURSOR_CHAR;
- g_sedit[cpos+1] = 0;
+ g_sedit[cpos + 1] = 0;
return true;
}
return false;
@@ -1577,40 +1282,40 @@ static bool InvKeyIn(const Common::KeyState &kbd) {
kbd.keycode == Common::KEYCODE_PAGEDOWN ||
kbd.keycode == Common::KEYCODE_HOME ||
kbd.keycode == Common::KEYCODE_END)
- return true; // Key needs processing
+ return true; // Key needs processing
if (kbd.keycode == 0 && kbd.ascii == 0) {
;
} else if (kbd.keycode == Common::KEYCODE_RETURN) {
- return true; // Key needs processing
+ return true; // Key needs processing
} else if (kbd.keycode == Common::KEYCODE_ESCAPE) {
- return true; // Key needs processing
+ return true; // Key needs processing
} else {
#ifndef JAPAN
- if (UpdateString(kbd)) {
+ if (_vm->_dialogs->UpdateString(kbd)) {
/*
* Delete display of text currently being edited,
* and replace it with freshly edited text.
*/
- if (g_iconArray[HL3] != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]);
- g_iconArray[HL3] = nullptr;
+ if (_vm->_dialogs->g_iconArray[HL3] != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL3]);
+ _vm->_dialogs->g_iconArray[HL3] = nullptr;
}
- g_iconArray[HL3] = ObjectTextOut(
- _vm->_bg->GetPlayfieldList(FIELD_STATUS), g_sedit, 0,
- g_InvD[g_ino].inventoryX + cd.box[cd.selBox].xpos + 2,
- g_InvD[g_ino].inventoryY + cd.box[cd.selBox].ypos + TYOFF,
- _vm->_font->GetTagFontHandle(), 0);
- if (MultiRightmost(g_iconArray[HL3]) > MAX_NAME_RIGHT) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]);
- UpdateString(Common::KeyState(Common::KEYCODE_BACKSPACE));
- g_iconArray[HL3] = ObjectTextOut(
- _vm->_bg->GetPlayfieldList(FIELD_STATUS), g_sedit, 0,
- g_InvD[g_ino].inventoryX + cd.box[cd.selBox].xpos + 2,
- g_InvD[g_ino].inventoryY + cd.box[cd.selBox].ypos + TYOFF,
- _vm->_font->GetTagFontHandle(), 0);
+ _vm->_dialogs->g_iconArray[HL3] = ObjectTextOut(
+ _vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_sedit, 0,
+ _vm->_dialogs->CurrentInventoryX() + cd.box[cd.selBox].xpos + 2,
+ _vm->_dialogs->CurrentInventoryY() + cd.box[cd.selBox].ypos + TYOFF,
+ _vm->_font->GetTagFontHandle(), 0);
+ if (MultiRightmost(_vm->_dialogs->g_iconArray[HL3]) > MAX_NAME_RIGHT) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL3]);
+ _vm->_dialogs->UpdateString(Common::KeyState(Common::KEYCODE_BACKSPACE));
+ _vm->_dialogs->g_iconArray[HL3] = ObjectTextOut(
+ _vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_sedit, 0,
+ _vm->_dialogs->CurrentInventoryX() + cd.box[cd.selBox].xpos + 2,
+ _vm->_dialogs->CurrentInventoryY() + cd.box[cd.selBox].ypos + TYOFF,
+ _vm->_font->GetTagFontHandle(), 0);
}
- MultiSetZPosition(g_iconArray[HL3], Z_INV_ITEXT + 2);
+ MultiSetZPosition(_vm->_dialogs->g_iconArray[HL3], Z_INV_ITEXT + 2);
}
#endif
}
@@ -1621,10 +1326,10 @@ static bool InvKeyIn(const Common::KeyState &kbd) {
* Highlights selected box.
* If it's editable (save game), copy existing description and add a cursor.
*/
-static void Select(int i, bool force) {
+void Dialogs::Select(int i, bool force) {
#ifdef JAPAN
- time_t secs_now;
- struct tm *time_now;
+ time_t secs_now;
+ struct tm *time_now;
#endif
i &= ~IS_MASK;
@@ -1648,15 +1353,15 @@ static void Select(int i, bool force) {
switch (cd.box[i].boxType) {
case RGROUP:
g_iconArray[HL2] = RectangleObject(_vm->_bg->BgPal(),
- (TinselV2 ? HighlightColor() : COL_HILIGHT), cd.box[i].w, cd.box[i].h);
+ (TinselV2 ? HighlightColor() : COL_HILIGHT), cd.box[i].w, cd.box[i].h);
MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]);
MultiSetAniXY(g_iconArray[HL2],
- g_InvD[g_ino].inventoryX + cd.box[i].xpos,
- g_InvD[g_ino].inventoryY + cd.box[i].ypos);
+ g_InvD[g_ino].inventoryX + cd.box[i].xpos,
+ g_InvD[g_ino].inventoryY + cd.box[i].ypos);
// Z-position of box, and add edit text if appropriate
if (cd.editableRgroup) {
- MultiSetZPosition(g_iconArray[HL2], Z_INV_ITEXT+1);
+ MultiSetZPosition(g_iconArray[HL2], Z_INV_ITEXT + 1);
if (TinselV2) {
assert(cd.box[i].textMethod == TM_POINTER);
@@ -1671,22 +1376,22 @@ static void Select(int i, bool force) {
#else
// Current description with cursor appended
if (cd.box[i].boxText != NULL) {
- Common::strlcpy(g_sedit, cd.box[i].boxText, SG_DESC_LEN+2);
- Common::strlcat(g_sedit, sCursor, SG_DESC_LEN+2);
+ Common::strlcpy(g_sedit, cd.box[i].boxText, SG_DESC_LEN + 2);
+ Common::strlcat(g_sedit, sCursor, SG_DESC_LEN + 2);
} else {
- Common::strlcpy(g_sedit, sCursor, SG_DESC_LEN+2);
+ Common::strlcpy(g_sedit, sCursor, SG_DESC_LEN + 2);
}
#endif
g_iconArray[HL3] = ObjectTextOut(
- _vm->_bg->GetPlayfieldList(FIELD_STATUS), g_sedit, 0,
- g_InvD[g_ino].inventoryX + cd.box[i].xpos + 2,
+ _vm->_bg->GetPlayfieldList(FIELD_STATUS), g_sedit, 0,
+ g_InvD[g_ino].inventoryX + cd.box[i].xpos + 2,
#ifdef JAPAN
- g_InvD[g_ino].inventoryY + cd.box[i].ypos + 2,
+ g_InvD[g_ino].inventoryY + cd.box[i].ypos + 2,
#else
- g_InvD[g_ino].inventoryY + cd.box[i].ypos + TYOFF,
+ g_InvD[g_ino].inventoryY + cd.box[i].ypos + TYOFF,
#endif
- _vm->_font->GetTagFontHandle(), 0);
+ _vm->_font->GetTagFontHandle(), 0);
MultiSetZPosition(g_iconArray[HL3], Z_INV_ITEXT + 2);
} else {
MultiSetZPosition(g_iconArray[HL2], Z_INV_ICONS + 1);
@@ -1697,12 +1402,12 @@ static void Select(int i, bool force) {
break;
case FRGROUP:
- g_iconArray[HL2] = RectangleObject(_vm->_bg->BgPal(), COL_HILIGHT, cd.box[i].w+6, cd.box[i].h+6);
+ g_iconArray[HL2] = RectangleObject(_vm->_bg->BgPal(), COL_HILIGHT, cd.box[i].w + 6, cd.box[i].h + 6);
MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]);
MultiSetAniXY(g_iconArray[HL2],
- g_InvD[g_ino].inventoryX + cd.box[i].xpos - 2,
- g_InvD[g_ino].inventoryY + cd.box[i].ypos - 2);
- MultiSetZPosition(g_iconArray[HL2], Z_INV_BRECT+1);
+ g_InvD[g_ino].inventoryX + cd.box[i].xpos - 2,
+ g_InvD[g_ino].inventoryY + cd.box[i].ypos - 2);
+ MultiSetZPosition(g_iconArray[HL2], Z_INV_BRECT + 1);
break;
@@ -1711,7 +1416,6 @@ static void Select(int i, bool force) {
}
}
-
/**************************************************************************/
/***/
/**************************************************************************/
@@ -1719,9 +1423,9 @@ static void Select(int i, bool force) {
/**
* Stop holding an item.
*/
-extern void DropItem(int item) {
+void Dialogs::DropItem(int item) {
if (g_heldItem == item) {
- g_heldItem = INV_NOICON; // Item not held
+ g_heldItem = INV_NOICON; // Item not held
_vm->_cursor->DelAuxCursor(); // no longer aux cursor
}
@@ -1732,7 +1436,7 @@ extern void DropItem(int item) {
/**
* Clears the specified inventory
*/
-extern void ClearInventory(int invno) {
+void Dialogs::ClearInventory(int invno) {
assert(invno == INV_1 || invno == INV_2);
g_InvD[invno].NoofItems = 0;
@@ -1743,14 +1447,13 @@ extern void ClearInventory(int invno) {
* Stick the item into an inventory list (contents[]), and hold the
* item if requested.
*/
-extern void AddToInventory(int invno, int icon, bool hold) {
+void Dialogs::AddToInventory(int invno, int icon, bool hold) {
int i;
bool bOpen;
INV_OBJECT *invObj;
// Validate trying to add to a legal inventory
- assert(invno == INV_1 || invno == INV_2 || invno == INV_CONV
- || invno == INV_OPEN || (invno == INV_DEFAULT && TinselV2));
+ assert(invno == INV_1 || invno == INV_2 || invno == INV_CONV || invno == INV_OPEN || (invno == INV_DEFAULT && TinselV2));
if (invno == INV_OPEN) {
assert(g_InventoryState == ACTIVE_INV && (g_ino == INV_1 || g_ino == INV_2)); // addopeninv() with inventry not open
@@ -1799,8 +1502,8 @@ extern void AddToInventory(int invno, int icon, bool hold) {
}
// For conversation, insert before end icons
- memmove(&g_InvD[INV_CONV].contents[i-nei+1],
- &g_InvD[INV_CONV].contents[i-nei], nei * sizeof(int));
+ memmove(&g_InvD[INV_CONV].contents[i - nei + 1],
+ &g_InvD[INV_CONV].contents[i - nei], nei * sizeof(int));
g_InvD[INV_CONV].contents[i - nei] = icon;
g_InvD[INV_CONV].NoofItems++;
g_InvD[INV_CONV].NoofHicons = g_InvD[INV_CONV].NoofItems;
@@ -1810,8 +1513,8 @@ extern void AddToInventory(int invno, int icon, bool hold) {
} else {
// For conversation, insert before last icon
// which will always be the goodbye icon
- g_InvD[invno].contents[g_InvD[invno].NoofItems] = g_InvD[invno].contents[g_InvD[invno].NoofItems-1];
- g_InvD[invno].contents[g_InvD[invno].NoofItems-1] = icon;
+ g_InvD[invno].contents[g_InvD[invno].NoofItems] = g_InvD[invno].contents[g_InvD[invno].NoofItems - 1];
+ g_InvD[invno].contents[g_InvD[invno].NoofItems - 1] = icon;
g_InvD[invno].NoofItems++;
}
} else {
@@ -1823,8 +1526,8 @@ extern void AddToInventory(int invno, int icon, bool hold) {
// as delinv may well have been called
if (g_GlitterIndex < g_InvD[invno].NoofItems) {
memmove(&g_InvD[invno].contents[g_GlitterIndex + 1],
- &g_InvD[invno].contents[g_GlitterIndex],
- (g_InvD[invno].NoofItems - g_GlitterIndex) * sizeof(int));
+ &g_InvD[invno].contents[g_GlitterIndex],
+ (g_InvD[invno].NoofItems - g_GlitterIndex) * sizeof(int));
g_InvD[invno].contents[g_GlitterIndex] = icon;
} else {
g_InvD[invno].contents[g_InvD[invno].NoofItems] = icon;
@@ -1845,7 +1548,7 @@ extern void AddToInventory(int invno, int icon, bool hold) {
* Take the item from the inventory list (contents[]).
* Return FALSE if item wasn't present, true if it was.
*/
-extern bool RemFromInventory(int invno, int icon) {
+bool Dialogs::RemFromInventory(int invno, int icon) {
int i;
assert(invno == INV_1 || invno == INV_2 || invno == INV_CONV); // Trying to delete from illegal inventory
@@ -1857,9 +1560,9 @@ extern bool RemFromInventory(int invno, int icon) {
}
if (i == g_InvD[invno].NoofItems)
- return false; // Item wasn't there
+ return false; // Item wasn't there
else {
- memmove(&g_InvD[invno].contents[i], &g_InvD[invno].contents[i+1], (g_InvD[invno].NoofItems-i)*sizeof(int));
+ memmove(&g_InvD[invno].contents[i], &g_InvD[invno].contents[i + 1], (g_InvD[invno].NoofItems - i) * sizeof(int));
g_InvD[invno].NoofItems--;
if (TinselV2 && invno == INV_CONV) {
@@ -1870,14 +1573,14 @@ extern bool RemFromInventory(int invno, int icon) {
}
g_ItemsChanged = true;
- return true; // Item removed
+ return true; // Item removed
}
}
/**
* If the item is not already held, hold it.
*/
-extern void HoldItem(int item, bool bKeepFilm) {
+void Dialogs::HoldItem(int item, bool bKeepFilm) {
INV_OBJECT *invObj;
if (g_heldItem != item) {
@@ -1914,7 +1617,7 @@ extern void HoldItem(int item, bool bKeepFilm) {
AddToInventory(INV_1, g_heldItem);
}
- g_heldItem = item; // Item held
+ g_heldItem = item; // Item held
if (TinselV2) {
InventoryIconCursor(!bKeepFilm);
@@ -1933,19 +1636,31 @@ extern void HoldItem(int item, bool bKeepFilm) {
/***/
/**************************************************************************/
-enum { I_NOTIN, I_HEADER, I_BODY,
- I_TLEFT, I_TRIGHT, I_BLEFT, I_BRIGHT,
- I_TOP, I_BOTTOM, I_LEFT, I_RIGHT,
- I_UP, I_SLIDE_UP, I_SLIDE, I_SLIDE_DOWN, I_DOWN,
- I_ENDCHANGE
+enum { I_NOTIN,
+ I_HEADER,
+ I_BODY,
+ I_TLEFT,
+ I_TRIGHT,
+ I_BLEFT,
+ I_BRIGHT,
+ I_TOP,
+ I_BOTTOM,
+ I_LEFT,
+ I_RIGHT,
+ I_UP,
+ I_SLIDE_UP,
+ I_SLIDE,
+ I_SLIDE_DOWN,
+ I_DOWN,
+ I_ENDCHANGE
};
-#define EXTRA 1 // This was introduced when we decided to increase
- // the active area of the borders for re-sizing.
+#define EXTRA 1 // This was introduced when we decided to increase \
+ // the active area of the borders for re-sizing.
/*---------------------------------*/
-#define LeftX g_InvD[g_ino].inventoryX
-#define TopY g_InvD[g_ino].inventoryY
+#define LeftX g_InvD[g_ino].inventoryX
+#define TopY g_InvD[g_ino].inventoryY
/*---------------------------------*/
/**
@@ -1956,7 +1671,7 @@ enum { I_NOTIN, I_HEADER, I_BODY,
* changed and I got fed up of faffing about. It's probably easier just
* to rework all this.
*/
-static int InvArea(int x, int y) {
+int Dialogs::InvArea(int x, int y) {
if (TinselV2) {
int RightX = MultiRightmost(g_RectObject) - NM_BG_SIZ_X - NM_BG_POS_X - NM_RS_R_INSET;
int BottomY = MultiLowest(g_RectObject) - NM_BG_SIZ_Y - NM_BG_POS_Y - NM_RS_B_INSET;
@@ -1969,28 +1684,28 @@ static int InvArea(int x, int y) {
if (y > BottomY - NM_RS_THICKNESS) {
// Below top of bottom line?
if (x <= LeftX + NM_RS_THICKNESS)
- return I_BLEFT; // Bottom left corner
+ return I_BLEFT; // Bottom left corner
else if (x > RightX - NM_RS_THICKNESS)
- return I_BRIGHT; // Bottom right corner
+ return I_BRIGHT; // Bottom right corner
else
- return I_BOTTOM; // Just plain bottom
+ return I_BOTTOM; // Just plain bottom
}
// The top line
if (y <= TopY + NM_RS_THICKNESS) {
// Above bottom of top line?
if (x <= LeftX + NM_RS_THICKNESS)
- return I_TLEFT; // Top left corner
+ return I_TLEFT; // Top left corner
else if (x > RightX - NM_RS_THICKNESS)
- return I_TRIGHT; // Top right corner
+ return I_TRIGHT; // Top right corner
else
- return I_TOP; // Just plain top
+ return I_TOP; // Just plain top
}
// Sides
- if (x <= LeftX + NM_RS_THICKNESS) // Left of right of left side?
+ if (x <= LeftX + NM_RS_THICKNESS) // Left of right of left side?
return I_LEFT;
- else if (x > RightX - NM_RS_THICKNESS) // Right of left of right side?
+ else if (x > RightX - NM_RS_THICKNESS) // Right of left of right side?
return I_RIGHT;
// In the move area?
@@ -2022,43 +1737,41 @@ static int InvArea(int x, int y) {
int BottomY = MultiLowest(g_RectObject) + 1;
// Outside the whole rectangle?
- if (x <= LeftX - EXTRA || x > RightX + EXTRA
- || y <= TopY - EXTRA || y > BottomY + EXTRA)
+ if (x <= LeftX - EXTRA || x > RightX + EXTRA || y <= TopY - EXTRA || y > BottomY + EXTRA)
return I_NOTIN;
// The bottom line
- if (y > BottomY - 2 - EXTRA) { // Below top of bottom line?
+ if (y > BottomY - 2 - EXTRA) { // Below top of bottom line?
if (x <= LeftX + 2 + EXTRA)
- return I_BLEFT; // Bottom left corner
+ return I_BLEFT; // Bottom left corner
else if (x > RightX - 2 - EXTRA)
- return I_BRIGHT; // Bottom right corner
+ return I_BRIGHT; // Bottom right corner
else
- return I_BOTTOM; // Just plain bottom
+ return I_BOTTOM; // Just plain bottom
}
// The top line
- if (y <= TopY + 2 + EXTRA) { // Above bottom of top line?
+ if (y <= TopY + 2 + EXTRA) { // Above bottom of top line?
if (x <= LeftX + 2 + EXTRA)
- return I_TLEFT; // Top left corner
+ return I_TLEFT; // Top left corner
else if (x > RightX - 2 - EXTRA)
- return I_TRIGHT; // Top right corner
+ return I_TRIGHT; // Top right corner
else
- return I_TOP; // Just plain top
+ return I_TOP; // Just plain top
}
// Sides
- if (x <= LeftX + 2 + EXTRA) // Left of right of left side?
+ if (x <= LeftX + 2 + EXTRA) // Left of right of left side?
return I_LEFT;
- else if (x > RightX - 2 - EXTRA) // Right of left of right side?
+ else if (x > RightX - 2 - EXTRA) // Right of left of right side?
return I_RIGHT;
// From here down still needs fixing up properly
/*
* In the move area?
*/
- if (g_ino != INV_CONF
- && x >= LeftX + M_SW - 2 && x <= RightX - M_SW + 3 &&
- y >= TopY + M_TH - 2 && y < TopY + M_TBB + 2)
+ if (g_ino != INV_CONF && x >= LeftX + M_SW - 2 && x <= RightX - M_SW + 3 &&
+ y >= TopY + M_TH - 2 && y < TopY + M_TBB + 2)
return I_HEADER;
/*
@@ -2090,7 +1803,7 @@ static int InvArea(int x, int y) {
* Returns the id of the icon displayed under the given position.
* Also return co-ordinates of items tag display position, if requested.
*/
-extern int InvItem(int *x, int *y, bool update) {
+int Dialogs::InvItem(int *x, int *y, bool update) {
int itop, ileft;
int row, col;
int item;
@@ -2105,9 +1818,9 @@ extern int InvItem(int *x, int *y, bool update) {
for (col = 0; col < g_InvD[g_ino].NoofHicons; col++, item++) {
if (*x >= ileft && *x < ileft + ITEM_WIDTH &&
- *y >= itop && *y < itop + ITEM_HEIGHT) {
+ *y >= itop && *y < itop + ITEM_HEIGHT) {
if (update) {
- *x = ileft + ITEM_WIDTH/2;
+ *x = ileft + ITEM_WIDTH / 2;
*y = itop /*+ ITEM_HEIGHT/4*/;
}
return item;
@@ -2120,7 +1833,7 @@ extern int InvItem(int *x, int *y, bool update) {
return INV_NOICON;
}
-static int InvItem(Common::Point &coOrds, bool update) {
+int Dialogs::InvItem(Common::Point &coOrds, bool update) {
int x = coOrds.x;
int y = coOrds.y;
return InvItem(&x, &y, update);
@@ -2131,7 +1844,7 @@ static int InvItem(Common::Point &coOrds, bool update) {
/**
* Returns the id of the icon displayed under the given position.
*/
-int InvItemId(int x, int y) {
+int Dialogs::InvItemId(int x, int y) {
int itop, ileft;
int row, col;
int item;
@@ -2148,7 +1861,7 @@ int InvItemId(int x, int y) {
for (col = 0; col < g_InvD[g_ino].NoofHicons; col++, item++) {
if (x >= ileft && x < ileft + ITEM_WIDTH &&
- y >= itop && y < itop + ITEM_HEIGHT) {
+ y >= itop && y < itop + ITEM_HEIGHT) {
return g_InvD[g_ino].contents[item];
}
@@ -2162,11 +1875,10 @@ int InvItemId(int x, int y) {
/**
* Finds which box the cursor is in.
*/
-static int WhichMenuBox(int curX, int curY, bool bSlides) {
+int Dialogs::WhichMenuBox(int curX, int curY, bool bSlides) {
if (bSlides) {
for (int i = 0; i < g_numMdSlides; i++) {
- if (curY > MultiHighest(g_mdSlides[i].obj) && curY < MultiLowest(g_mdSlides[i].obj)
- && curX > MultiLeftmost(g_mdSlides[i].obj) && curX < MultiRightmost(g_mdSlides[i].obj))
+ if (curY > MultiHighest(g_mdSlides[i].obj) && curY < MultiLowest(g_mdSlides[i].obj) && curX > MultiLeftmost(g_mdSlides[i].obj) && curX < MultiRightmost(g_mdSlides[i].obj))
return g_mdSlides[i].num | IS_SLIDER;
}
}
@@ -2178,10 +1890,10 @@ static int WhichMenuBox(int curX, int curY, bool bSlides) {
switch (cd.box[i].boxType) {
case SLIDER:
if (bSlides) {
- if (curY >= cd.box[i].ypos+MD_YBUTTOP && curY < cd.box[i].ypos+MD_YBUTBOT) {
- if (curX >= cd.box[i].xpos+MD_XLBUTL && curX < cd.box[i].xpos+MD_XLBUTR)
+ if (curY >= cd.box[i].ypos + MD_YBUTTOP && curY < cd.box[i].ypos + MD_YBUTBOT) {
+ if (curX >= cd.box[i].xpos + MD_XLBUTL && curX < cd.box[i].xpos + MD_XLBUTR)
return i | IS_LEFT;
- if (curX >= cd.box[i].xpos+MD_XRBUTL && curX < cd.box[i].xpos+MD_XRBUTR)
+ if (curX >= cd.box[i].xpos + MD_XRBUTL && curX < cd.box[i].xpos + MD_XRBUTR)
return i | IS_RIGHT;
}
}
@@ -2193,8 +1905,7 @@ static int WhichMenuBox(int curX, int curY, bool bSlides) {
case TOGGLE1:
case TOGGLE2:
case FLIP:
- if (curY > cd.box[i].ypos && curY < cd.box[i].ypos + cd.box[i].h
- && curX > cd.box[i].xpos && curX < cd.box[i].xpos + cd.box[i].w)
+ if (curY > cd.box[i].ypos && curY < cd.box[i].ypos + cd.box[i].h && curX > cd.box[i].xpos && curX < cd.box[i].xpos + cd.box[i].w)
return i;
break;
@@ -2204,12 +1915,12 @@ static int WhichMenuBox(int curX, int curY, bool bSlides) {
if (curY > cd.box[i].ypos && curY < cd.box[i].ypos + cd.box[i].h) {
// Left one?
- if (curX > cd.box[i].xpos-ROTX1 && curX < cd.box[i].xpos-ROTX1 + cd.box[i].w) {
+ if (curX > cd.box[i].xpos - ROTX1 && curX < cd.box[i].xpos - ROTX1 + cd.box[i].w) {
cd.box[i].bi = IX2_LEFT1;
return i;
}
// Right one?
- if (curX > cd.box[i].xpos+ROTX1 && curX < cd.box[i].xpos+ROTX1 + cd.box[i].w) {
+ if (curX > cd.box[i].xpos + ROTX1 && curX < cd.box[i].xpos + ROTX1 + cd.box[i].w) {
cd.box[i].bi = IX2_RIGHT1;
return i;
}
@@ -2218,8 +1929,7 @@ static int WhichMenuBox(int curX, int curY, bool bSlides) {
default:
// 'Normal' box
- if (curY >= cd.box[i].ypos && curY < cd.box[i].ypos + cd.box[i].h
- && curX >= cd.box[i].xpos && curX < cd.box[i].xpos + cd.box[i].w)
+ if (curY >= cd.box[i].ypos && curY < cd.box[i].ypos + cd.box[i].h && curX >= cd.box[i].xpos && curX < cd.box[i].xpos + cd.box[i].w)
return i;
break;
}
@@ -2227,9 +1937,7 @@ static int WhichMenuBox(int curX, int curY, bool bSlides) {
// Slider on extra window
if (cd.bExtraWin) {
- const Common::Rect r = TinselV2 ?
- Common::Rect(411, 46, 425, 339) :
- Common::Rect(20 + 181, 24 + 2, 20 + 181 + 8, 24 + 139 + 5);
+ const Common::Rect r = TinselV2 ? Common::Rect(411, 46, 425, 339) : Common::Rect(20 + 181, 24 + 2, 20 + 181 + 8, 24 + 139 + 5);
if (r.contains(curX, curY)) {
@@ -2253,14 +1961,14 @@ static int WhichMenuBox(int curX, int curY, bool bSlides) {
/***/
/**************************************************************************/
-#define ROTX1 60 // Rotate button's offsets from the center
+#define ROTX1 60 // Rotate button's offsets from the center
/**
* InvBoxes
*/
-static void InvBoxes(bool InBody, int curX, int curY) {
+void Dialogs::InvBoxes(bool InBody, int curX, int curY) {
int rotateIndex = -1;
- int index; // Box pointed to on this call
+ int index; // Box pointed to on this call
const FILM *pfilm;
// Find out which icon is currently pointed to
@@ -2287,29 +1995,29 @@ static void InvBoxes(bool InBody, int curX, int curY) {
g_iconArray[HL1] = nullptr;
}
if ((cd.box[cd.pointBox].boxType == ARSBUT && cd.selBox != NOBOX) ||
-///* I don't agree */ cd.box[cd.pointBox].boxType == RGROUP ||
+ ///* I don't agree */ cd.box[cd.pointBox].boxType == RGROUP ||
cd.box[cd.pointBox].boxType == AATBUT ||
cd.box[cd.pointBox].boxType == AABUT) {
g_iconArray[HL1] = RectangleObject(_vm->_bg->BgPal(),
- (TinselV2 ? HighlightColor() : COL_HILIGHT),
- cd.box[cd.pointBox].w, cd.box[cd.pointBox].h);
+ (TinselV2 ? HighlightColor() : COL_HILIGHT),
+ cd.box[cd.pointBox].w, cd.box[cd.pointBox].h);
MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
MultiSetAniXY(g_iconArray[HL1],
- g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos,
- g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos);
- MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);
+ g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos,
+ g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos);
+ MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS + 1);
} else if (cd.box[cd.pointBox].boxType == AAGBUT ||
- cd.box[cd.pointBox].boxType == ARSGBUT ||
- cd.box[cd.pointBox].boxType == TOGGLE ||
- cd.box[cd.pointBox].boxType == TOGGLE1 ||
- cd.box[cd.pointBox].boxType == TOGGLE2) {
+ cd.box[cd.pointBox].boxType == ARSGBUT ||
+ cd.box[cd.pointBox].boxType == TOGGLE ||
+ cd.box[cd.pointBox].boxType == TOGGLE1 ||
+ cd.box[cd.pointBox].boxType == TOGGLE2) {
pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
- g_iconArray[HL1] = AddObject(&pfilm->reels[cd.box[cd.pointBox].bi+HIGRAPH], -1);
+ g_iconArray[HL1] = AddObject(&pfilm->reels[cd.box[cd.pointBox].bi + HIGRAPH], -1);
MultiSetAniXY(g_iconArray[HL1],
- g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos,
- g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos);
- MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);
+ g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos,
+ g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos);
+ MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS + 1);
} else if (cd.box[cd.pointBox].boxType == ROTATE) {
if (g_bNoLanguage)
return;
@@ -2318,163 +2026,41 @@ static void InvBoxes(bool InBody, int curX, int curY) {
rotateIndex = cd.box[cd.pointBox].bi;
if (rotateIndex == IX2_LEFT1) {
- g_iconArray[HL1] = AddObject(&pfilm->reels[IX2_LEFT2], -1 );
+ g_iconArray[HL1] = AddObject(&pfilm->reels[IX2_LEFT2], -1);
MultiSetAniXY(g_iconArray[HL1],
- g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos - ROTX1,
- g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos);
- MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);
+ g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos - ROTX1,
+ g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos);
+ MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS + 1);
} else if (rotateIndex == IX2_RIGHT1) {
g_iconArray[HL1] = AddObject(&pfilm->reels[IX2_RIGHT2], -1);
MultiSetAniXY(g_iconArray[HL1],
- g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos + ROTX1,
- g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos);
+ g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos + ROTX1,
+ g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos);
MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS + 1);
}
}
}
}
-static void ButtonPress(CORO_PARAM, CONFBOX *box) {
- CORO_BEGIN_CONTEXT;
- CORO_END_CONTEXT(_ctx);
+/**
+ * Monitors for POINTED event for inventory icons.
+ */
+void Dialogs::InvLabels(bool InBody, int aniX, int aniY) {
+ int index; // Icon pointed to on this call
+ INV_OBJECT *invObj;
- CORO_BEGIN_CODE(_ctx);
-
- const FILM *pfilm;
-
- assert(box->boxType == AAGBUT || box->boxType == ARSGBUT);
-
- // Replace highlight image with normal image
- pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
- if (g_iconArray[HL1] != NULL)
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
- pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
- g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+NORMGRAPH], -1);
- MultiSetAniXY(g_iconArray[HL1], g_InvD[g_ino].inventoryX + box->xpos, g_InvD[g_ino].inventoryY + box->ypos);
- MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);
-
- // Hold normal image for 1 frame
- CORO_SLEEP(1);
- if (g_iconArray[HL1] == NULL)
- return;
-
- // Replace normal image with depresses image
- pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
- g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1);
- MultiSetAniXY(g_iconArray[HL1], g_InvD[g_ino].inventoryX + box->xpos, g_InvD[g_ino].inventoryY + box->ypos);
- MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);
-
- // Hold depressed image for 2 frames
- CORO_SLEEP(2);
- if (g_iconArray[HL1] == NULL)
- return;
-
- // Replace depressed image with normal image
- pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
- g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+NORMGRAPH], -1);
- MultiSetAniXY(g_iconArray[HL1], g_InvD[g_ino].inventoryX + box->xpos, g_InvD[g_ino].inventoryY + box->ypos);
- MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);
-
- CORO_SLEEP(1);
-
- CORO_END_CODE;
-}
-
-static void ButtonToggle(CORO_PARAM, CONFBOX *box) {
- CORO_BEGIN_CONTEXT;
- CORO_END_CONTEXT(_ctx);
-
- CORO_BEGIN_CODE(_ctx);
-
- const FILM *pfilm;
-
- assert((box->boxType == TOGGLE) || (box->boxType == TOGGLE1)
- || (box->boxType == TOGGLE2));
-
- // Remove hilight image
- if (g_iconArray[HL1] != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
- g_iconArray[HL1] = nullptr;
- }
-
- // Hold normal image for 1 frame
- CORO_SLEEP(1);
- if (g_InventoryState != ACTIVE_INV)
- return;
-
- // Add depressed image
- pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
- g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1);
- MultiSetAniXY(g_iconArray[HL1], g_InvD[g_ino].inventoryX + box->xpos, g_InvD[g_ino].inventoryY + box->ypos);
- MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);
-
- // Hold depressed image for 1 frame
- CORO_SLEEP(1);
- if (g_iconArray[HL1] == NULL)
- return;
-
- // Toggle state
- (*box->ival) = *(box->ival) ^ 1; // XOR with true
- box->bi = *(box->ival) ? IX_TICK1 : IX_CROSS1;
- AddBoxes(false);
- // Keep highlight (e.g. flag)
- if (cd.selBox != NOBOX)
- Select(cd.selBox, true);
-
- // New state, depressed image
- pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
- if (g_iconArray[HL1] != NULL)
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
- g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1);
- MultiSetAniXY(g_iconArray[HL1], g_InvD[g_ino].inventoryX + box->xpos, g_InvD[g_ino].inventoryY + box->ypos);
- MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);
-
- // Hold new depressed image for 1 frame
- CORO_SLEEP(1);
- if (g_iconArray[HL1] == NULL)
- return;
-
- // New state, normal
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
- g_iconArray[HL1] = nullptr;
-
- // Hold normal image for 1 frame
- CORO_SLEEP(1);
- if (g_InventoryState != ACTIVE_INV)
- return;
-
- // New state, highlighted
- pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
- if (g_iconArray[HL1] != NULL)
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
- g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+HIGRAPH], -1);
- MultiSetAniXY(g_iconArray[HL1], g_InvD[g_ino].inventoryX + box->xpos, g_InvD[g_ino].inventoryY + box->ypos);
- MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);
-
- CORO_END_CODE;
-}
-
-/**
- * Monitors for POINTED event for inventory icons.
- */
-static void InvLabels(bool InBody, int aniX, int aniY) {
- int index; // Icon pointed to on this call
- INV_OBJECT *invObj;
-
- // Find out which icon is currently pointed to
- if (!InBody)
- index = INV_NOICON;
- else {
- index = InvItem(&aniX, &aniY, false);
- if (index != INV_NOICON) {
- if (index >= g_InvD[g_ino].NoofItems)
- index = INV_NOICON;
- else
- index = g_InvD[g_ino].contents[index];
- }
- }
+ // Find out which icon is currently pointed to
+ if (!InBody)
+ index = INV_NOICON;
+ else {
+ index = InvItem(&aniX, &aniY, false);
+ if (index != INV_NOICON) {
+ if (index >= g_InvD[g_ino].NoofItems)
+ index = INV_NOICON;
+ else
+ index = g_InvD[g_ino].contents[index];
+ }
+ }
// If no icon pointed to, or points to (logical position of)
// currently held icon, then no icon is pointed to!
@@ -2499,7 +2085,7 @@ static void InvLabels(bool InBody, int aniX, int aniY) {
* It seems to set up slideStuff[], an array of possible first-displayed
* icons set against the matching y-positions of the slider.
*/
-static void AdjustTop() {
+void Dialogs::AdjustTop() {
int tMissing, bMissing, nMissing;
int nsliderYpos;
int rowsWanted;
@@ -2510,7 +2096,7 @@ static void AdjustTop() {
if (!g_SlideObject)
return;
- rowsWanted = (g_InvD[g_ino].NoofItems - g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons-1) / g_InvD[g_ino].NoofHicons;
+ rowsWanted = (g_InvD[g_ino].NoofItems - g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons - 1) / g_InvD[g_ino].NoofHicons;
while (rowsWanted < g_InvD[g_ino].NoofVicons) {
if (g_InvD[g_ino].FirstDisp) {
@@ -2521,7 +2107,7 @@ static void AdjustTop() {
} else
break;
}
- tMissing = g_InvD[g_ino].FirstDisp ? (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons-1)/g_InvD[g_ino].NoofHicons : 0;
+ tMissing = g_InvD[g_ino].FirstDisp ? (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons - 1) / g_InvD[g_ino].NoofHicons : 0;
bMissing = (rowsWanted > g_InvD[g_ino].NoofVicons) ? rowsWanted - g_InvD[g_ino].NoofVicons : 0;
nMissing = tMissing + bMissing;
@@ -2532,15 +2118,15 @@ static void AdjustTop() {
else if (!bMissing)
nsliderYpos = g_sliderYmax;
else {
- nsliderYpos = tMissing*slideRange/nMissing;
+ nsliderYpos = tMissing * slideRange / nMissing;
nsliderYpos += g_sliderYmin;
}
if (nMissing) {
- n = g_InvD[g_ino].FirstDisp - tMissing*g_InvD[g_ino].NoofHicons;
+ n = g_InvD[g_ino].FirstDisp - tMissing * g_InvD[g_ino].NoofHicons;
for (i = 0; i <= nMissing; i++, n += g_InvD[g_ino].NoofHicons) {
g_slideStuff[i].n = n;
- g_slideStuff[i].y = (i*slideRange/nMissing) + g_sliderYmin;
+ g_slideStuff[i].y = (i * slideRange / nMissing) + g_sliderYmin;
}
if (g_slideStuff[0].n < 0)
g_slideStuff[0].n = 0;
@@ -2561,11 +2147,11 @@ static void AdjustTop() {
/**
* Insert an inventory icon object onto the display list.
*/
-static OBJECT *AddInvObject(int num, const FREEL **pfreel, const FILM **pfilm) {
- INV_OBJECT *invObj; // Icon data
- const MULTI_INIT *pmi; // Its INIT structure - from the reel
- IMAGE *pim; // ... you get the picture
- OBJECT *pPlayObj; // The object we insert
+OBJECT *Dialogs::AddInvObject(int num, const FREEL **pfreel, const FILM **pfilm) {
+ INV_OBJECT *invObj; // Icon data
+ const MULTI_INIT *pmi; // Its INIT structure - from the reel
+ IMAGE *pim; // ... you get the picture
+ OBJECT *pPlayObj; // The object we insert
invObj = GetInvObject(num);
@@ -2585,25 +2171,25 @@ static OBJECT *AddInvObject(int num, const FREEL **pfreel, const FILM **pfilm) {
/**
* Create display objects for the displayed icons in an inventory window.
*/
-static void FillInInventory() {
- int Index; // Index into contents[]
- int n = 0; // index into iconArray[]
- int xpos, ypos;
- int row, col;
+void Dialogs::FillInInventory() {
+ int Index; // Index into contents[]
+ int n = 0; // index into iconArray[]
+ int xpos, ypos;
+ int row, col;
const FREEL *pfr;
const FILM *pfilm;
DumpIconArray();
if (g_InvDragging != ID_SLIDE)
- AdjustTop(); // Set up slideStuff[]
+ AdjustTop(); // Set up slideStuff[]
- Index = g_InvD[g_ino].FirstDisp; // Start from first displayed object
+ Index = g_InvD[g_ino].FirstDisp; // Start from first displayed object
n = 0;
- ypos = START_ICONY; // Y-offset of first display row
+ ypos = START_ICONY; // Y-offset of first display row
- for (row = 0; row < g_InvD[g_ino].NoofVicons; row++, ypos += ITEM_HEIGHT + 1) {
- xpos = START_ICONX; // X-offset of first display column
+ for (row = 0; row < g_InvD[g_ino].NoofVicons; row++, ypos += ITEM_HEIGHT + 1) {
+ xpos = START_ICONX; // X-offset of first display column
for (col = 0; col < g_InvD[g_ino].NoofHicons; col++) {
if (Index >= g_InvD[g_ino].NoofItems)
@@ -2611,7 +2197,7 @@ static void FillInInventory() {
else if (g_InvD[g_ino].contents[Index] != g_heldItem) {
// Create a display object and position it
g_iconArray[n] = AddInvObject(g_InvD[g_ino].contents[Index], &pfr, &pfilm);
- MultiSetAniXY(g_iconArray[n], g_InvD[g_ino].inventoryX + xpos , g_InvD[g_ino].inventoryY + ypos);
+ MultiSetAniXY(g_iconArray[n], g_InvD[g_ino].inventoryX + xpos, g_InvD[g_ino].inventoryY + ypos);
MultiSetZPosition(g_iconArray[n], Z_INV_ICONS);
InitStepAnimScript(&g_iconAnims[n], g_iconArray[n], FROM_32(pfr->script), ONE_SECOND / FROM_32(pfilm->frate));
@@ -2619,18 +2205,19 @@ static void FillInInventory() {
n++;
}
Index++;
- xpos += ITEM_WIDTH + 1; // X-offset of next display column
+ xpos += ITEM_WIDTH + 1; // X-offset of next display column
}
}
}
-enum {FROM_HANDLE, FROM_STRING};
+enum { FROM_HANDLE,
+ FROM_STRING };
/**
* Set up a rectangle as the background to the inventory window.
* Additionally, sticks the window title up.
*/
-static void AddBackground(OBJECT **rect, OBJECT **title, int extraH, int extraV, int textFrom) {
+void Dialogs::AddBackground(OBJECT **rect, OBJECT **title, int extraH, int extraV, int textFrom) {
// Why not 2 ????
int width = g_TLwidth + extraH + g_TRwidth + NM_BG_SIZ_X;
int height = g_TLheight + extraV + g_BLheight + NM_BG_SIZ_Y;
@@ -2641,7 +2228,7 @@ static void AddBackground(OBJECT **rect, OBJECT **title, int extraH, int extraV,
// add it to display list and position it
MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), *rect);
MultiSetAniXY(*rect, g_InvD[g_ino].inventoryX + NM_BG_POS_X,
- g_InvD[g_ino].inventoryY + NM_BG_POS_Y);
+ g_InvD[g_ino].inventoryY + NM_BG_POS_Y);
MultiSetZPosition(*rect, Z_INV_BRECT);
if (title == NULL)
@@ -2651,15 +2238,15 @@ static void AddBackground(OBJECT **rect, OBJECT **title, int extraH, int extraV,
if (textFrom == FROM_HANDLE) {
LoadStringRes(g_InvD[g_ino].hInvTitle, _vm->_font->TextBufferAddr(), TBUFSZ);
*title = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), 0,
- g_InvD[g_ino].inventoryX + width/2, g_InvD[g_ino].inventoryY + M_TOFF,
- _vm->_font->GetTagFontHandle(), TXT_CENTER);
+ g_InvD[g_ino].inventoryX + width / 2, g_InvD[g_ino].inventoryY + M_TOFF,
+ _vm->_font->GetTagFontHandle(), TXT_CENTER);
assert(*title); // Inventory title string produced NULL text
MultiSetZPosition(*title, Z_INV_HTEXT);
} else if (textFrom == FROM_STRING && cd.ixHeading != NO_HEADING) {
LoadStringRes(g_configStrings[cd.ixHeading], _vm->_font->TextBufferAddr(), TBUFSZ);
*title = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), 0,
- g_InvD[g_ino].inventoryX + width/2, g_InvD[g_ino].inventoryY + M_TOFF,
- _vm->_font->GetTagFontHandle(), TXT_CENTER);
+ g_InvD[g_ino].inventoryX + width / 2, g_InvD[g_ino].inventoryY + M_TOFF,
+ _vm->_font->GetTagFontHandle(), TXT_CENTER);
assert(*title); // Inventory title string produced NULL text
MultiSetZPosition(*title, Z_INV_HTEXT);
}
@@ -2668,33 +2255,32 @@ static void AddBackground(OBJECT **rect, OBJECT **title, int extraH, int extraV,
/**
* Set up a rectangle as the background to the inventory window.
*/
-static void AddBackground(OBJECT **rect, int extraH, int extraV) {
+void Dialogs::AddBackground(OBJECT **rect, int extraH, int extraV) {
AddBackground(rect, NULL, extraH, extraV, 0);
}
/**
* Adds a title for a dialog
*/
-static void AddTitle(POBJECT *title, int extraH) {
+void Dialogs::AddTitle(POBJECT *title, int extraH) {
int width = g_TLwidth + extraH + g_TRwidth + NM_BG_SIZ_X;
// Create text object using title string
if (g_InvD[g_ino].hInvTitle != (SCNHANDLE)NO_HEADING) {
LoadStringRes(g_InvD[g_ino].hInvTitle, _vm->_font->TextBufferAddr(), TBUFSZ);
*title = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), 0,
- g_InvD[g_ino].inventoryX + (width/2)+NM_BG_POS_X, g_InvD[g_ino].inventoryY + NM_TOFF,
- _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
+ g_InvD[g_ino].inventoryX + (width / 2) + NM_BG_POS_X, g_InvD[g_ino].inventoryY + NM_TOFF,
+ _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
assert(*title);
MultiSetZPosition(*title, Z_INV_HTEXT);
}
}
-
/**
* Insert a part of the inventory window frame onto the display list.
*/
-static OBJECT *AddObject(const FREEL *pfreel, int num) {
- const MULTI_INIT *pmi; // Get the MULTI_INIT structure
+OBJECT *Dialogs::AddObject(const FREEL *pfreel, int num) {
+ const MULTI_INIT *pmi; // Get the MULTI_INIT structure
IMAGE *pim;
OBJECT *pPlayObj;
@@ -2726,21 +2312,21 @@ static OBJECT *AddObject(const FREEL *pfreel, int num) {
* Display the scroll bar slider.
*/
-static void AddSlider(OBJECT **slide, const FILM *pfilm) {
+void Dialogs::AddSlider(OBJECT **slide, const FILM *pfilm) {
g_SlideObject = *slide = AddObject(&pfilm->reels[IX_SLIDE], -1);
MultiSetAniXY(*slide, MultiRightmost(g_RectObject) + (TinselV2 ? NM_SLX : -M_SXOFF + 2),
- g_InvD[g_ino].inventoryY + g_sliderYpos);
+ g_InvD[g_ino].inventoryY + g_sliderYpos);
MultiSetZPosition(*slide, Z_INV_MFRAME);
}
/**
* Display a box with some text in it.
*/
-static void AddBox(int *pi, const int i) {
- int x = g_InvD[g_ino].inventoryX + cd.box[i].xpos;
- int y = g_InvD[g_ino].inventoryY + cd.box[i].ypos;
+void Dialogs::AddBox(int *pi, const int i) {
+ int x = g_InvD[g_ino].inventoryX + cd.box[i].xpos;
+ int y = g_InvD[g_ino].inventoryY + cd.box[i].ypos;
int *pival = cd.box[i].ival;
- int xdisp;
+ int xdisp;
const FILM *pFilm;
switch (cd.box[i].boxType) {
@@ -2751,7 +2337,7 @@ static void AddBox(int *pi, const int i) {
// Give us a box
g_iconArray[*pi] = RectangleObject(_vm->_bg->BgPal(), TinselV2 ? BoxColor() : COL_BOX,
- cd.box[i].w, cd.box[i].h);
+ cd.box[i].w, cd.box[i].h);
MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[*pi]);
MultiSetAniXY(g_iconArray[*pi], x, y);
MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);
@@ -2759,22 +2345,22 @@ static void AddBox(int *pi, const int i) {
// Stick in the text
if ((cd.box[i].textMethod == TM_POINTER) ||
- (!TinselV2 && (cd.box[i].ixText == USE_POINTER))) {
+ (!TinselV2 && (cd.box[i].ixText == USE_POINTER))) {
if (cd.box[i].boxText != NULL) {
if (cd.box[i].boxType == RGROUP) {
g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0,
#ifdef JAPAN
- x + 2, y+2, GetTagFontHandle(), 0);
+ x + 2, y + 2, GetTagFontHandle(), 0);
#else
- x + 2, y + TYOFF, _vm->_font->GetTagFontHandle(), 0);
+ x + 2, y + TYOFF, _vm->_font->GetTagFontHandle(), 0);
#endif
} else {
g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0,
#ifdef JAPAN
-// Note: it never seems to go here!
- x + cd.box[i].w/2, y+2, GetTagFontHandle(), TXT_CENTER);
+ // Note: it never seems to go here!
+ x + cd.box[i].w / 2, y + 2, GetTagFontHandle(), TXT_CENTER);
#else
- x + cd.box[i].w / 2, y + TYOFF, _vm->_font->GetTagFontHandle(), TXT_CENTER);
+ x + cd.box[i].w / 2, y + TYOFF, _vm->_font->GetTagFontHandle(), TXT_CENTER);
#endif
}
@@ -2796,14 +2382,14 @@ static void AddBox(int *pi, const int i) {
if (TinselV2 && (cd.box[i].boxType == RGROUP))
g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(),
- 0, x + 2, y + TYOFF, _vm->_font->GetTagFontHandle(), 0, 0);
+ 0, x + 2, y + TYOFF, _vm->_font->GetTagFontHandle(), 0, 0);
else
g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
- _vm->_font->TextBufferAddr(), 0,
+ _vm->_font->TextBufferAddr(), 0,
#ifdef JAPAN
- x + cd.box[i].w/2, y+2, GetTagFontHandle(), TXT_CENTER);
+ x + cd.box[i].w / 2, y + 2, GetTagFontHandle(), TXT_CENTER);
#else
- x + cd.box[i].w / 2, y + TYOFF, _vm->_font->GetTagFontHandle(), TXT_CENTER);
+ x + cd.box[i].w / 2, y + TYOFF, _vm->_font->GetTagFontHandle(), TXT_CENTER);
#endif
MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
@@ -2831,7 +2417,7 @@ static void AddBox(int *pi, const int i) {
g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi], -1);
MultiSetAniXY(g_iconArray[*pi], x, y);
- MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT+2);
+ MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 2);
*pi += 1;
break;
@@ -2842,9 +2428,9 @@ static void AddBox(int *pi, const int i) {
if (*pival)
g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi], -1);
else
- g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi+1], -1);
+ g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + 1], -1);
MultiSetAniXY(g_iconArray[*pi], x, y);
- MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT+1);
+ MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1;
// Stick in the text
@@ -2856,7 +2442,7 @@ static void AddBox(int *pi, const int i) {
LoadStringRes(g_configStrings[cd.box[i].ixText], _vm->_font->TextBufferAddr(), TBUFSZ);
}
g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
- _vm->_font->TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF, _vm->_font->GetTagFontHandle(), TXT_RIGHT);
+ _vm->_font->TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF, _vm->_font->GetTagFontHandle(), TXT_RIGHT);
MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
break;
@@ -2869,7 +2455,7 @@ static void AddBox(int *pi, const int i) {
cd.box[i].bi = *pival ? IX_TICK1 : IX_CROSS1;
g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + NORMGRAPH], -1);
MultiSetAniXY(g_iconArray[*pi], x, y);
- MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT+1);
+ MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1;
// Stick in the text
@@ -2883,12 +2469,12 @@ static void AddBox(int *pi, const int i) {
if (cd.box[i].boxType == TOGGLE2) {
g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
- _vm->_font->TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF,
- _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
+ _vm->_font->TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF,
+ _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
} else {
g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
- _vm->_font->TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF,
- _vm->_font->GetTagFontHandle(), TXT_RIGHT, 0);
+ _vm->_font->TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF,
+ _vm->_font->GetTagFontHandle(), TXT_RIGHT, 0);
}
MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
@@ -2897,14 +2483,14 @@ static void AddBox(int *pi, const int i) {
case SLIDER:
pFilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
- xdisp = SLIDE_RANGE*(*pival)/cd.box[i].w;
+ xdisp = SLIDE_RANGE * (*pival) / cd.box[i].w;
g_iconArray[*pi] = AddObject(&pFilm->reels[IX_MDGROOVE], -1);
MultiSetAniXY(g_iconArray[*pi], x, y);
MultiSetZPosition(g_iconArray[*pi], Z_MDGROOVE);
*pi += 1;
g_iconArray[*pi] = AddObject(&pFilm->reels[IX_MDSLIDER], -1);
- MultiSetAniXY(g_iconArray[*pi], x+SLIDE_MINX+xdisp, y);
+ MultiSetAniXY(g_iconArray[*pi], x + SLIDE_MINX + xdisp, y);
MultiSetZPosition(g_iconArray[*pi], Z_MDSLIDER);
assert(g_numMdSlides < MAXSLIDES);
g_mdSlides[g_numMdSlides].num = i;
@@ -2922,7 +2508,7 @@ static void AddBox(int *pi, const int i) {
LoadStringRes(g_configStrings[cd.box[i].ixText], _vm->_font->TextBufferAddr(), TBUFSZ);
}
g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
- _vm->_font->TextBufferAddr(), 0, x+MDTEXT_XOFF, y+MDTEXT_YOFF, _vm->_font->GetTagFontHandle(), TXT_RIGHT);
+ _vm->_font->TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF, _vm->_font->GetTagFontHandle(), TXT_RIGHT);
MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
break;
@@ -2933,12 +2519,12 @@ static void AddBox(int *pi, const int i) {
// Left one
if (!g_bNoLanguage) {
g_iconArray[*pi] = AddObject(&pFilm->reels[IX2_LEFT1], -1);
- MultiSetAniXY(g_iconArray[*pi], x-ROTX1, y);
+ MultiSetAniXY(g_iconArray[*pi], x - ROTX1, y);
MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1;
// Right one
- g_iconArray[*pi] = AddObject( &pFilm->reels[IX2_RIGHT1], -1);
+ g_iconArray[*pi] = AddObject(&pFilm->reels[IX2_RIGHT1], -1);
MultiSetAniXY(g_iconArray[*pi], x + ROTX1, y);
MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1;
@@ -2947,8 +2533,8 @@ static void AddBox(int *pi, const int i) {
assert(cd.box[i].textMethod == TM_INDEX);
LoadStringRes(SysString(cd.box[i].ixText), _vm->_font->TextBufferAddr(), TBUFSZ);
g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
- _vm->_font->TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF,
- _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
+ _vm->_font->TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF,
+ _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
}
@@ -2959,7 +2545,7 @@ static void AddBox(int *pi, const int i) {
LoadStringRes(LanguageDesc(g_displayedLanguage), _vm->_font->TextBufferAddr(), TBUFSZ);
g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), 0,
- x + cd.box[i].w / 2, y + ROT_YOFF, _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
+ x + cd.box[i].w / 2, y + ROT_YOFF, _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
@@ -2976,8 +2562,8 @@ static void AddBox(int *pi, const int i) {
/**
* Display some boxes.
*/
-static void AddBoxes(bool bPosnSlide) {
- int objCount = NUMHL; // Object count - allow for HL1, HL2 etc.
+void Dialogs::AddBoxes(bool bPosnSlide) {
+ int objCount = NUMHL; // Object count - allow for HL1, HL2 etc.
DumpIconArray();
g_numMdSlides = 0;
@@ -2988,25 +2574,25 @@ static void AddBoxes(bool bPosnSlide) {
if (cd.bExtraWin) {
if (bPosnSlide && !TinselV2)
- g_sliderYpos = g_sliderYmin + (cd.extraBase*(g_sliderYmax-g_sliderYmin))/(MAX_SAVED_FILES-NUM_RGROUP_BOXES);
+ g_sliderYpos = g_sliderYmin + (cd.extraBase * (g_sliderYmax - g_sliderYmin)) / (MAX_SAVED_FILES - NUM_RGROUP_BOXES);
else if (bPosnSlide) {
// Tinsel 2 bPosnSlide code
int lastY = g_sliderYpos;
if (cd.box == loadBox || cd.box == saveBox)
g_sliderYpos = g_sliderYmin + (cd.extraBase * (sliderRange)) /
- (MAX_SAVED_FILES - NUM_RGROUP_BOXES);
+ (MAX_SAVED_FILES - NUM_RGROUP_BOXES);
else if (cd.box == hopperBox1) {
if (g_numScenes <= NUM_RGROUP_BOXES)
g_sliderYpos = g_sliderYmin;
else
- g_sliderYpos = g_sliderYmin + (cd.extraBase*(sliderRange))/(g_numScenes-NUM_RGROUP_BOXES);
+ g_sliderYpos = g_sliderYmin + (cd.extraBase * (sliderRange)) / (g_numScenes - NUM_RGROUP_BOXES);
} else if (cd.box == hopperBox2) {
if (g_numEntries <= NUM_RGROUP_BOXES)
g_sliderYpos = g_sliderYmin;
else
g_sliderYpos = g_sliderYmin + (cd.extraBase * (sliderRange)) /
- (g_numEntries-NUM_RGROUP_BOXES);
+ (g_numEntries - NUM_RGROUP_BOXES);
}
MultiMoveRelXY(g_SlideObject, 0, g_sliderYpos - lastY);
@@ -3022,7 +2608,7 @@ static void AddBoxes(bool bPosnSlide) {
/**
* Display the scroll bar slider.
*/
-static void AddEWSlider(OBJECT **slide, const FILM *pfilm) {
+void Dialogs::AddEWSlider(OBJECT **slide, const FILM *pfilm) {
g_SlideObject = *slide = AddObject(&pfilm->reels[IX_SLIDE], -1);
MultiSetAniXY(*slide, g_InvD[g_ino].inventoryX + 24 + 127, g_sliderYpos);
MultiSetZPosition(*slide, Z_INV_MFRAME);
@@ -3031,8 +2617,8 @@ static void AddEWSlider(OBJECT **slide, const FILM *pfilm) {
/**
* AddExtraWindow
*/
-static int AddExtraWindow(int x, int y, OBJECT **retObj) {
- int n = 0;
+int Dialogs::AddExtraWindow(int x, int y, OBJECT **retObj) {
+ int n = 0;
const FILM *pfilm;
// Get the frame's data
@@ -3042,46 +2628,45 @@ static int AddExtraWindow(int x, int y, OBJECT **retObj) {
y += TinselV2 ? 38 : 24;
// Draw the four corners
- retObj[n] = AddObject(&pfilm->reels[IX_RTL], -1); // Top left
+ retObj[n] = AddObject(&pfilm->reels[IX_RTL], -1); // Top left
MultiSetAniXY(retObj[n], x, y);
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
- retObj[n] = AddObject(&pfilm->reels[IX_NTR], -1); // Top right
+ retObj[n] = AddObject(&pfilm->reels[IX_NTR], -1); // Top right
MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth + 312 : 152), y);
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
- retObj[n] = AddObject(&pfilm->reels[IX_BL], -1); // Bottom left
+ retObj[n] = AddObject(&pfilm->reels[IX_BL], -1); // Bottom left
MultiSetAniXY(retObj[n], x, y + (TinselV2 ? g_TLheight + 208 : 124));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
- retObj[n] = AddObject(&pfilm->reels[IX_BR], -1); // Bottom right
+ retObj[n] = AddObject(&pfilm->reels[IX_BR], -1); // Bottom right
MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth + 312 : 152),
- y + (TinselV2 ? g_TLheight + 208 : 124));
+ y + (TinselV2 ? g_TLheight + 208 : 124));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
// Draw the edges
- retObj[n] = AddObject(&pfilm->reels[IX_H156], -1); // Top
+ retObj[n] = AddObject(&pfilm->reels[IX_H156], -1); // Top
MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth : 6), y + NM_TBT);
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
- retObj[n] = AddObject(&pfilm->reels[IX_H156], -1); // Bottom
- MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth : 6), y +
- (TinselV2 ? g_TLheight + 208 + g_BLheight + NM_BSY : 143));
+ retObj[n] = AddObject(&pfilm->reels[IX_H156], -1); // Bottom
+ MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth : 6), y + (TinselV2 ? g_TLheight + 208 + g_BLheight + NM_BSY : 143));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
- retObj[n] = AddObject(&pfilm->reels[IX_V104], -1); // Left
+ retObj[n] = AddObject(&pfilm->reels[IX_V104], -1); // Left
MultiSetAniXY(retObj[n], x + NM_LSX, y + (TinselV2 ? g_TLheight : 20));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
- retObj[n] = AddObject(&pfilm->reels[IX_V104], -1); // Right 1
+ retObj[n] = AddObject(&pfilm->reels[IX_V104], -1); // Right 1
MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth + 312 + g_TRwidth + NM_RSX : 179),
- y + (TinselV2 ? g_TLheight : 20));
+ y + (TinselV2 ? g_TLheight : 20));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
- retObj[n] = AddObject(&pfilm->reels[IX_V104], -1); // Right 2
+ retObj[n] = AddObject(&pfilm->reels[IX_V104], -1); // Right 2
MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth + 312 + g_TRwidth + NM_SBL : 188),
- y + (TinselV2 ? g_TLheight : 20));
+ y + (TinselV2 ? g_TLheight : 20));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
@@ -3089,10 +2674,10 @@ static int AddExtraWindow(int x, int y, OBJECT **retObj) {
g_sliderYpos = g_sliderYmin = y + 27;
g_sliderYmax = y + 273;
- retObj[n++] = g_SlideObject = AddObject( &pfilm->reels[IX_SLIDE], -1);
+ retObj[n++] = g_SlideObject = AddObject(&pfilm->reels[IX_SLIDE], -1);
MultiSetAniXY(g_SlideObject,
- x + g_TLwidth + 320 + g_TRwidth - NM_BG_POS_X + NM_BG_SIZ_X - 2,
- g_sliderYpos);
+ x + g_TLwidth + 320 + g_TRwidth - NM_BG_POS_X + NM_BG_SIZ_X - 2,
+ g_sliderYpos);
MultiSetZPosition(g_SlideObject, Z_INV_MFRAME);
} else {
g_sliderYpos = g_sliderYmin = y + 9;
@@ -3103,28 +2688,25 @@ static int AddExtraWindow(int x, int y, OBJECT **retObj) {
return n;
}
-
-enum InventoryType { EMPTY, FULL, CONF };
-
/**
* Construct an inventory window - either a standard one, with
* background, slider and icons, or a re-sizing window.
*/
-static void ConstructInventory(InventoryType filling) {
- int eH, eV; // Extra width and height
- int n = 0; // Index into object array
- int zpos; // Z-position of frame
- int invX = g_InvD[g_ino].inventoryX;
- int invY = g_InvD[g_ino].inventoryY;
+void Dialogs::ConstructInventory(InventoryType filling) {
+ int eH, eV; // Extra width and height
+ int n = 0; // Index into object array
+ int zpos; // Z-position of frame
+ int invX = g_InvD[g_ino].inventoryX;
+ int invY = g_InvD[g_ino].inventoryY;
OBJECT **retObj;
const FILM *pfilm;
// Select the object array to use
if (filling == FULL || filling == CONF) {
- retObj = g_objArray; // Standard window
+ retObj = g_objArray; // Standard window
zpos = Z_INV_MFRAME;
} else {
- retObj = g_DobjArray; // Re-sizing window
+ retObj = g_DobjArray; // Re-sizing window
zpos = Z_INV_RFRAME;
}
@@ -3150,8 +2732,8 @@ static void ConstructInventory(InventoryType filling) {
}
// Extra width and height
- eH = (g_InvD[g_ino].NoofHicons - 1) * (ITEM_WIDTH+I_SEPARATION) + g_SuppH;
- eV = (g_InvD[g_ino].NoofVicons - 1) * (ITEM_HEIGHT+I_SEPARATION) + g_SuppV;
+ eH = (g_InvD[g_ino].NoofHicons - 1) * (ITEM_WIDTH + I_SEPARATION) + g_SuppH;
+ eV = (g_InvD[g_ino].NoofVicons - 1) * (ITEM_HEIGHT + I_SEPARATION) + g_SuppV;
// Which window frame corners to use
if (TinselV2 && (g_ino == INV_CONV)) {
@@ -3192,7 +2774,7 @@ static void ConstructInventory(InventoryType filling) {
// Draw extra Top and bottom parts
if (g_InvD[g_ino].NoofHicons > 1) {
// Top side
- retObj[n] = AddObject(&pfilm->reels[hFillers[g_InvD[g_ino].NoofHicons-2]], -1);
+ retObj[n] = AddObject(&pfilm->reels[hFillers[g_InvD[g_ino].NoofHicons - 2]], -1);
MultiSetAniXY(retObj[n], invX + g_TLwidth, invY + NM_TBT);
MultiSetZPosition(retObj[n], zpos);
n++;
@@ -3200,12 +2782,12 @@ static void ConstructInventory(InventoryType filling) {
// Bottom of header box
if (filling == FULL) {
if (TinselV2) {
- retObj[n] = AddObject(&pfilm->reels[hFillers[g_InvD[g_ino].NoofHicons-2]], -1);
+ retObj[n] = AddObject(&pfilm->reels[hFillers[g_InvD[g_ino].NoofHicons - 2]], -1);
MultiSetAniXY(retObj[n], invX + g_TLwidth, invY + NM_TBB);
MultiSetZPosition(retObj[n], zpos);
n++;
} else {
- retObj[n] = AddObject(&pfilm->reels[hFillers[g_InvD[g_ino].NoofHicons-2]], -1);
+ retObj[n] = AddObject(&pfilm->reels[hFillers[g_InvD[g_ino].NoofHicons - 2]], -1);
MultiSetAniXY(retObj[n], invX + g_TLwidth, invY + M_TBB + 1);
MultiSetZPosition(retObj[n], zpos);
n++;
@@ -3226,7 +2808,7 @@ static void ConstructInventory(InventoryType filling) {
}
// Bottom side
- retObj[n] = AddObject(&pfilm->reels[hFillers[g_InvD[g_ino].NoofHicons-2]], -1);
+ retObj[n] = AddObject(&pfilm->reels[hFillers[g_InvD[g_ino].NoofHicons - 2]], -1);
MultiSetAniXY(retObj[n], invX + g_TLwidth, invY + g_TLheight + eV + g_BLheight + NM_BSY);
MultiSetZPosition(retObj[n], zpos);
@@ -3234,7 +2816,7 @@ static void ConstructInventory(InventoryType filling) {
}
if (g_SuppH) {
int offx = g_TLwidth + eH - (TinselV2 ? ITEM_WIDTH + I_SEPARATION : 26);
- if (offx < g_TLwidth) // Not too far!
+ if (offx < g_TLwidth) // Not too far!
offx = g_TLwidth;
// Top side extra
@@ -3254,14 +2836,14 @@ static void ConstructInventory(InventoryType filling) {
// Draw extra side parts
if (g_InvD[g_ino].NoofVicons > 1) {
// Left side
- retObj[n] = AddObject(&pfilm->reels[vFillers[g_InvD[g_ino].NoofVicons-2]], -1);
+ retObj[n] = AddObject(&pfilm->reels[vFillers[g_InvD[g_ino].NoofVicons - 2]], -1);
MultiSetAniXY(retObj[n], invX + NM_LSX, invY + g_TLheight);
MultiSetZPosition(retObj[n], zpos);
n++;
// Left side of scroll bar
if (filling == FULL && g_ino != INV_CONV) {
- retObj[n] = AddObject(&pfilm->reels[vFillers[g_InvD[g_ino].NoofVicons-2]], -1);
+ retObj[n] = AddObject(&pfilm->reels[vFillers[g_InvD[g_ino].NoofVicons - 2]], -1);
if (TinselV2)
MultiSetAniXY(retObj[n], invX + g_TLwidth + eH + g_TRwidth + NM_SBL, invY + g_TLheight);
else
@@ -3271,7 +2853,7 @@ static void ConstructInventory(InventoryType filling) {
}
// Right side
- retObj[n] = AddObject(&pfilm->reels[vFillers[g_InvD[g_ino].NoofVicons-2]], -1);
+ retObj[n] = AddObject(&pfilm->reels[vFillers[g_InvD[g_ino].NoofVicons - 2]], -1);
MultiSetAniXY(retObj[n], invX + g_TLwidth + eH + g_TRwidth + NM_RSX, invY + g_TLheight);
MultiSetZPosition(retObj[n], zpos);
n++;
@@ -3317,12 +2899,12 @@ static void ConstructInventory(InventoryType filling) {
if (TinselV2) {
// !!!!! MAGIC NUMBER ALERT !!!!!
// Make sure it's big enough for the heading
- if (MultiLeftmost(retObj[n-1]) < g_InvD[INV_CONV].inventoryX + 10) {
+ if (MultiLeftmost(retObj[n - 1]) < g_InvD[INV_CONV].inventoryX + 10) {
g_InvD[INV_CONV].NoofHicons++;
ConstructInventory(FULL);
}
}
- } else if (g_InvD[g_ino].NoofItems > g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons) {
+ } else if (g_InvD[g_ino].NoofItems > g_InvD[g_ino].NoofHicons * g_InvD[g_ino].NoofVicons) {
g_sliderYmin = g_TLheight - (TinselV2 ? 1 : 2);
g_sliderYmax = g_TLheight + eV + (TinselV2 ? 12 : 10);
AddSlider(&retObj[n++], pfilm);
@@ -3353,15 +2935,14 @@ static void ConstructInventory(InventoryType filling) {
}
}
-
/**
* Call this when drawing a 'FULL', movable inventory. Checks that the
* position of the Translucent object is within limits. If it isn't,
* adjusts the x/y position of the current inventory and returns true.
*/
-static bool RePosition() {
- int p;
- bool bMoveitMoveit = false;
+bool Dialogs::RePosition() {
+ int p;
+ bool bMoveitMoveit = false;
assert(g_RectObject); // no recangle object!
@@ -3370,13 +2951,13 @@ static bool RePosition() {
if (p > MAXLEFT) {
// Too far to the right
g_InvD[g_ino].inventoryX += MAXLEFT - p;
- bMoveitMoveit = true; // I like to....
+ bMoveitMoveit = true; // I like to....
} else {
// Too far to the left?
p = MultiRightmost(g_RectObject);
if (p < MINRIGHT) {
g_InvD[g_ino].inventoryX += MINRIGHT - p;
- bMoveitMoveit = true; // I like to....
+ bMoveitMoveit = true; // I like to....
}
}
@@ -3385,11 +2966,11 @@ static bool RePosition() {
if (p < MINTOP) {
// Too high
g_InvD[g_ino].inventoryY += MINTOP - p;
- bMoveitMoveit = true; // I like to....
+ bMoveitMoveit = true; // I like to....
} else if (p > MAXTOP) {
// Too low
g_InvD[g_ino].inventoryY += MAXTOP - p;
- bMoveitMoveit = true; // I like to....
+ bMoveitMoveit = true; // I like to....
}
return bMoveitMoveit;
@@ -3403,7 +2984,7 @@ static bool RePosition() {
* Get the cursor's reel, poke in the background palette,
* and customise the cursor.
*/
-static void AlterCursor(int num) {
+void Dialogs::AlterCursor(int num) {
const FREEL *pfreel;
IMAGE *pim;
@@ -3416,17 +2997,12 @@ static void AlterCursor(int num) {
_vm->_cursor->SetTempCursor(FROM_32(pfreel->script));
}
-enum InvCursorFN {IC_AREA, IC_DROP};
-
/**
* InvCursor
*/
-static void InvCursor(InvCursorFN fn, int CurX, int CurY) {
- static enum { IC_NORMAL, IC_DR, IC_UR, IC_TB, IC_LR,
- IC_INV, IC_UP, IC_DN } ICursor = IC_NORMAL; // FIXME: Avoid non-const global vars
-
- int area; // The part of the window the cursor is over
- bool restoreMain = false;
+void Dialogs::InvCursor(InvCursorFN fn, int CurX, int CurY) {
+ int area; // The part of the window the cursor is over
+ bool restoreMain = false;
// If currently dragging, don't be messing about with the cursor shape
if (g_InvDragging != ID_NONE)
@@ -3525,18 +3101,13 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {
}
}
-
-
-
/*-------------------------------------------------------------------------*/
-
/**************************************************************************/
/******************** Conversation specific functions *********************/
/**************************************************************************/
-
-extern void ConvAction(int index) {
+void Dialogs::ConvAction(int index) {
assert(g_ino == INV_CONV); // not conv. window!
PMOVER pMover = TinselV2 ? GetMover(_vm->_actor->GetLeadId()) : NULL;
@@ -3545,14 +3116,14 @@ extern void ConvAction(int index) {
return;
case INV_CLOSEICON:
- g_thisIcon = -1; // Postamble
+ g_thisIcon = -1; // Postamble
break;
case INV_OPENICON:
// Store the direction the lead character is facing in when the conversation starts
if (TinselV2)
g_initialDirection = GetMoverDirection(pMover);
- g_thisIcon = -2; // Preamble
+ g_thisIcon = -2; // Preamble
break;
default:
@@ -3576,7 +3147,6 @@ extern void ConvAction(int index) {
else
ActorEvent(Common::nullContext, g_thisConvActor, CONVERSE, false, 0);
}
-
}
/**
@@ -3586,7 +3156,7 @@ extern void ConvAction(int index) {
*
* Note: ano may (will probably) be set when it's a polygon.
*/
-extern void SetConvDetails(CONV_PARAM fn, HPOLYGON hPoly, int ano) {
+void Dialogs::SetConvDetails(CONV_PARAM fn, HPOLYGON hPoly, int ano) {
g_thisConvFn = fn;
g_thisConvPoly = hPoly;
g_thisConvActor = ano;
@@ -3594,7 +3164,7 @@ extern void SetConvDetails(CONV_PARAM fn, HPOLYGON hPoly, int ano) {
g_bMoveOnUnHide = true;
// Get the Actor Tag's or Tagged Actor's label for the conversation window title
- if (hPoly != NOPOLY) {
+ if (hPoly != NOPOLY) {
int x, y;
GetTagTag(hPoly, &g_InvD[INV_CONV].hInvTitle, &x, &y);
} else {
@@ -3607,7 +3177,7 @@ extern void SetConvDetails(CONV_PARAM fn, HPOLYGON hPoly, int ano) {
/**
* Add an icon to the permanent conversation list.
*/
-extern void PermaConvIcon(int icon, bool bEnd) {
+void Dialogs::PermaConvIcon(int icon, bool bEnd) {
int i;
// See if it's already there
@@ -3627,10 +3197,10 @@ extern void PermaConvIcon(int icon, bool bEnd) {
g_numEndIcons++;
} else {
// Insert before end icons
- memmove(&g_permIcons[g_numPermIcons-g_numEndIcons+1],
- &g_permIcons[g_numPermIcons-g_numEndIcons],
- g_numEndIcons * sizeof(int));
- g_permIcons[g_numPermIcons-g_numEndIcons] = icon;
+ memmove(&g_permIcons[g_numPermIcons - g_numEndIcons + 1],
+ &g_permIcons[g_numPermIcons - g_numEndIcons],
+ g_numEndIcons * sizeof(int));
+ g_permIcons[g_numPermIcons - g_numEndIcons] = icon;
g_numPermIcons++;
}
}
@@ -3638,28 +3208,28 @@ extern void PermaConvIcon(int icon, bool bEnd) {
/*-------------------------------------------------------------------------*/
-extern void convPos(int fn) {
+void Dialogs::convPos(int fn) {
if (fn == CONV_DEF)
g_InvD[INV_CONV].inventoryY = 8;
else if (fn == CONV_BOTTOM)
g_InvD[INV_CONV].inventoryY = 150;
}
-extern void ConvPoly(HPOLYGON hPoly) {
+void Dialogs::ConvPoly(HPOLYGON hPoly) {
g_thisConvPoly = hPoly;
}
-extern int GetIcon() {
+int Dialogs::GetIcon() {
return g_thisIcon;
}
-extern void CloseDownConv() {
+void Dialogs::CloseDownConv() {
if (g_InventoryState == ACTIVE_INV && g_ino == INV_CONV) {
KillInventory();
}
}
-extern void HideConversation(bool bHide) {
+void Dialogs::HideConversation(bool bHide) {
int aniX, aniY;
int i;
@@ -3694,7 +3264,7 @@ extern void HideConversation(bool bHide) {
// Don't flash if items changed. If they have, will be redrawn anyway.
if (TinselV2 || !g_ItemsChanged) {
for (i = 0; i < MAX_ICONS && g_iconArray[i]; i++) {
- MultiAdjustXY(g_iconArray[i], -2*SCREEN_WIDTH, 0);
+ MultiAdjustXY(g_iconArray[i], -2 * SCREEN_WIDTH, 0);
}
}
}
@@ -3769,16 +3339,14 @@ extern void HideConversation(bool bHide) {
else
x = 0;
- if (g_thisConvFn == CONV_DEF && MultiHighest(g_RectObject) < SysVar(SV_CONV_MINY)
- && g_thisConvActor) {
+ if (g_thisConvFn == CONV_DEF && MultiHighest(g_RectObject) < SysVar(SV_CONV_MINY) && g_thisConvActor) {
int Loffset, Toffset;
_vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
y = _vm->_actor->GetActorBottom(g_thisConvActor) - MultiHighest(g_RectObject) +
- SysVar(SV_CONV_BELOW_Y);
+ SysVar(SV_CONV_BELOW_Y);
y -= Toffset;
- }
- else
+ } else
y = 0;
if (x || y) {
@@ -3813,11 +3381,10 @@ extern void HideConversation(bool bHide) {
}
}
-extern bool ConvIsHidden() {
+bool Dialogs::ConvIsHidden() {
return g_InventoryHidden;
}
-
/**************************************************************************/
/******************* Open and closing functions ***************************/
/**************************************************************************/
@@ -3825,51 +3392,50 @@ extern bool ConvIsHidden() {
/**
* Start up an inventory window.
*/
-extern void PopUpInventory(int invno) {
- assert(invno == INV_1 || invno == INV_2 || invno == INV_CONV
- || invno == INV_CONF || invno == INV_MENU); // Trying to open illegal inventory
+void Dialogs::PopUpInventory(int invno) {
+ assert(invno == INV_1 || invno == INV_2 || invno == INV_CONV || invno == INV_CONF || invno == INV_MENU); // Trying to open illegal inventory
if (g_InventoryState == IDLE_INV) {
- g_bReOpenMenu = false; // Better safe than sorry...
+ g_bReOpenMenu = false; // Better safe than sorry...
- DisableTags(); // Tags disabled during inventory
+ DisableTags(); // Tags disabled during inventory
if (TinselV2)
- DisablePointing(); // Pointing disabled during inventory
+ DisablePointing(); // Pointing disabled during inventory
- if (invno == INV_CONV) { // Conversation window?
+ if (invno == INV_CONV) { // Conversation window?
if (TinselV2)
// Quiet please..
_vm->_pcmMusic->dim(false);
// Start conversation with permanent contents
- memset(g_InvD[INV_CONV].contents, 0, MAX_ININV*sizeof(int));
- memcpy(g_InvD[INV_CONV].contents, g_permIcons, g_numPermIcons*sizeof(int));
+ memset(g_InvD[INV_CONV].contents, 0, MAX_ININV * sizeof(int));
+ memcpy(g_InvD[INV_CONV].contents, g_permIcons, g_numPermIcons * sizeof(int));
g_InvD[INV_CONV].NoofItems = g_numPermIcons;
if (TinselV2)
g_InvD[INV_CONV].NoofHicons = g_numPermIcons;
else
g_thisIcon = 0;
- } else if (invno == INV_CONF) { // Configuration window?
+ } else if (invno == INV_CONF) { // Configuration window?
cd.selBox = NOBOX;
cd.pointBox = NOBOX;
}
- g_ino = invno; // The open inventory
+ g_ino = invno; // The open inventory
- g_ItemsChanged = false; // Nothing changed
- g_InvDragging = ID_NONE; // Not dragging
- g_InventoryState = ACTIVE_INV; // Inventory actiive
- g_InventoryHidden = false; // Not hidden
+ g_ItemsChanged = false; // Nothing changed
+ g_InvDragging = ID_NONE; // Not dragging
+ g_InventoryState = ACTIVE_INV; // Inventory actiive
+ g_InventoryHidden = false; // Not hidden
g_InventoryMaximised = g_InvD[g_ino].bMax;
- if (invno != INV_CONF) // Configuration window?
- ConstructInventory(FULL); // Draw it up
+ if (invno != INV_CONF) // Configuration window?
+ ConstructInventory(FULL); // Draw it up
else {
- ConstructInventory(CONF); // Draw it up
+ ConstructInventory(CONF); // Draw it up
}
}
}
-static void SetMenuGlobals(CONFINIT *ci) {
+void Dialogs::SetMenuGlobals(CONFINIT *ci) {
g_InvD[INV_CONF].MinHicons = g_InvD[INV_CONF].MaxHicons = g_InvD[INV_CONF].NoofHicons = ci->h;
g_InvD[INV_CONF].MaxVicons = g_InvD[INV_CONF].MinVicons = g_InvD[INV_CONF].NoofVicons = ci->v;
g_InvD[INV_CONF].inventoryX = ci->x;
@@ -3890,7 +3456,7 @@ static void SetMenuGlobals(CONFINIT *ci) {
/**
* PopupConf
*/
-extern void OpenMenu(CONFTYPE menuType) {
+void Dialogs::OpenMenu(CONFTYPE menuType) {
int curX, curY;
// In the DW 1 demo, don't allow any menu to be opened
@@ -3909,7 +3475,7 @@ extern void OpenMenu(CONFTYPE menuType) {
break;
case SAVE_MENU:
- g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true); // Show VK when saving a game
+ g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true); // Show VK when saving a game
if (!TinselV2)
_vm->_cursor->SetCursorScreenXY(262, 91);
SetMenuGlobals(&ciSave);
@@ -4015,17 +3581,16 @@ extern void OpenMenu(CONFTYPE menuType) {
#if 1
// FIXME: Hack to setup CONFBOX pointer to data in the global Config object
ciSubtitles.Box[hackOffset].ival = &_vm->_config->_textSpeed;
- ciSubtitles.Box[hackOffset+1].ival = &_vm->_config->_useSubtitles;
+ ciSubtitles.Box[hackOffset + 1].ival = &_vm->_config->_useSubtitles;
#endif
SetMenuGlobals(&ciSubtitles);
- }
- break;
+ } break;
case TOP_WINDOW:
SetMenuGlobals(&ciTopWin);
g_ino = INV_CONF;
- ConstructInventory(CONF); // Draw it up
+ ConstructInventory(CONF); // Draw it up
g_InventoryState = BOGUS_INV;
return;
@@ -4039,8 +3604,7 @@ extern void OpenMenu(CONFTYPE menuType) {
PopUpInventory(INV_CONF);
// Make initial box selections if appropriate
- if (menuType == SAVE_MENU || menuType == LOAD_MENU
- || menuType == HOPPER_MENU1 || menuType == HOPPER_MENU2)
+ if (menuType == SAVE_MENU || menuType == LOAD_MENU || menuType == HOPPER_MENU1 || menuType == HOPPER_MENU2)
Select(0, false);
else if (menuType == SUBTITLES_MENU) {
if (_vm->getFeatures() & GF_USE_3FLAGS) {
@@ -4052,7 +3616,7 @@ extern void OpenMenu(CONFTYPE menuType) {
else
Select(2, false);
} else if (_vm->getFeatures() & GF_USE_4FLAGS) {
- Select(_vm->_config->_language-1, false);
+ Select(_vm->_config->_language - 1, false);
} else if (_vm->getFeatures() & GF_USE_5FLAGS) {
Select(_vm->_config->_language, false);
}
@@ -4065,7 +3629,7 @@ extern void OpenMenu(CONFTYPE menuType) {
/**
* Close down an inventory window.
*/
-extern void KillInventory() {
+void Dialogs::KillInventory() {
if (g_objArray[0] != NULL) {
DumpObjArray();
DumpDobjArray();
@@ -4100,10 +3664,10 @@ extern void KillInventory() {
if (g_ino == INV_CONV)
_vm->_pcmMusic->unDim(false);
- g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); // Hide VK after save dialog closes
+ g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); // Hide VK after save dialog closes
}
-extern void CloseInventory() {
+void Dialogs::CloseInventory() {
// If not active, ignore this
if (g_InventoryState != ACTIVE_INV)
return;
@@ -4121,154 +3685,6 @@ extern void CloseInventory() {
_vm->_cursor->RestoreMainCursor();
}
-
-
-/**************************************************************************/
-/************************ The inventory process ***************************/
-/**************************************************************************/
-
-/**
- * Redraws the icons if appropriate. Also handle button press/toggle effects
- */
-extern void InventoryProcess(CORO_PARAM, const void *) {
- // COROUTINE
- CORO_BEGIN_CONTEXT;
- CORO_END_CONTEXT(_ctx);
-
- CORO_BEGIN_CODE(_ctx);
-
- if (NumberOfLanguages() <= 1)
- g_bNoLanguage = true;
-
- while (1) {
- CORO_SLEEP(1); // allow scheduling
-
- if (g_objArray[0] != NULL) {
- if (g_ItemsChanged && g_ino != INV_CONF && !g_InventoryHidden) {
- FillInInventory();
-
- // Needed when clicking on scroll bar.
- int curX, curY;
- _vm->_cursor->GetCursorXY(&curX, &curY, false);
- InvCursor(IC_AREA, curX, curY);
-
- g_ItemsChanged = false;
- }
- if (g_ino != INV_CONF) {
- for (int i = 0; i < MAX_ICONS; i++) {
- if (g_iconArray[i] != NULL)
- StepAnimScript(&g_iconAnims[i]);
- }
- }
- if (g_InvDragging == ID_MDCONT) {
- // Mixing desk control
- int sval, index, *pival;
-
- index = cd.selBox & ~IS_MASK;
- pival = cd.box[index].ival;
- sval = *pival;
-
- if (cd.selBox & IS_LEFT) {
- *pival -= cd.box[index].h;
- if (*pival < 0)
- *pival = 0;
- } else if (cd.selBox & IS_RIGHT) {
- *pival += cd.box[index].h;
- if (*pival > cd.box[index].w)
- *pival = cd.box[index].w;
- }
-
- if (sval != *pival) {
- SlideMSlider(0, (cd.selBox & IS_RIGHT) ? S_TIMEUP : S_TIMEDN);
- }
- }
- }
-
- if (g_buttonEffect.bButAnim) {
- assert(g_buttonEffect.box);
- if (g_buttonEffect.press) {
- if (g_buttonEffect.box->boxType == AAGBUT || g_buttonEffect.box->boxType == ARSGBUT)
- CORO_INVOKE_1(ButtonPress, g_buttonEffect.box);
- switch (g_buttonEffect.box->boxFunc) {
- case SAVEGAME:
- KillInventory();
- InvSaveGame();
- break;
- case LOADGAME:
- KillInventory();
- InvLoadGame();
- break;
- case IQUITGAME:
- _vm->quitGame();
- break;
- case CLOSEWIN:
- KillInventory();
- if ((cd.box == hopperBox1) || (cd.box == hopperBox2))
- FreeSceneHopper();
- break;
- case OPENLOAD:
- KillInventory();
- OpenMenu(LOAD_MENU);
- break;
- case OPENSAVE:
- KillInventory();
- OpenMenu(SAVE_MENU);
- break;
- case OPENREST:
- KillInventory();
- OpenMenu(RESTART_MENU);
- break;
- case OPENSOUND:
- KillInventory();
- OpenMenu(SOUND_MENU);
- break;
- case OPENCONT:
- KillInventory();
- OpenMenu(CONTROLS_MENU);
- break;
- #ifndef JAPAN
- case OPENSUBT:
- KillInventory();
- OpenMenu(SUBTITLES_MENU);
- break;
- #endif
- case OPENQUIT:
- KillInventory();
- OpenMenu(QUIT_MENU);
- break;
- case INITGAME:
- KillInventory();
- FnRestartGame();
- break;
- case CLANG:
- if (!LanguageChange())
- KillInventory();
- break;
- case RLANG:
- KillInventory();
- break;
- case HOPPER2:
- KillInventory();
- OpenMenu(HOPPER_MENU2);
- break;
- case BF_CHANGESCENE:
- KillInventory();
- HopAction();
- FreeSceneHopper();
- break;
- default:
- break;
- }
- } else
- CORO_INVOKE_1(ButtonToggle, g_buttonEffect.box);
-
- g_buttonEffect.bButAnim = false;
- }
-
- }
- CORO_END_CODE;
-}
-
/**************************************************************************/
/*************** Drag stuff - Resizing and moving window ******************/
/**************************************************************************/
@@ -4277,10 +3693,10 @@ extern void InventoryProcess(CORO_PARAM, const void *) {
* Appears to find the nearest entry in slideStuff[] to the supplied
* y-coordinate.
*/
-static int NearestSlideY(int fity) {
+int Dialogs::NearestSlideY(int fity) {
int nearDist = 1000;
int thisDist;
- int nearI = 0; // Index of nearest fit
+ int nearI = 0; // Index of nearest fit
int i = 0;
do {
@@ -4297,8 +3713,8 @@ static int NearestSlideY(int fity) {
* Gets called at the start and end of a drag on the slider, and upon
* y-movement during such a drag.
*/
-static void SlideSlider(int y, SSFN fn) {
- static int newY = 0, lasti = 0; // FIXME: Avoid non-const global vars
+void Dialogs::SlideSlider(int y, SSFN fn) {
+ static int newY = 0, lasti = 0; // FIXME: Avoid non-const global vars
int gotoY, ati;
// Only do this if there's a slider
@@ -4306,20 +3722,20 @@ static void SlideSlider(int y, SSFN fn) {
return;
switch (fn) {
- case S_START: // Start of a drag on the slider
+ case S_START: // Start of a drag on the slider
newY = g_sliderYpos;
lasti = NearestSlideY(g_sliderYpos);
break;
- case S_SLIDE: // Y-movement during drag
- newY = newY + y; // New y-position
+ case S_SLIDE: // Y-movement during drag
+ newY = newY + y; // New y-position
if (newY < g_sliderYmin)
- gotoY = g_sliderYmin; // Above top limit
+ gotoY = g_sliderYmin; // Above top limit
else if (newY > g_sliderYmax)
- gotoY = g_sliderYmax; // Below bottom limit
+ gotoY = g_sliderYmax; // Below bottom limit
else
- gotoY = newY; // Hunky-Dory
+ gotoY = newY; // Hunky-Dory
// Move slider to new position
MultiMoveRelXY(g_SlideObject, 0, gotoY - g_sliderYpos);
@@ -4335,7 +3751,7 @@ static void SlideSlider(int y, SSFN fn) {
}
break;
- case S_END: // End of a drag on the slider
+ case S_END: // End of a drag on the slider
// Draw icons from new start icon
ati = NearestSlideY(g_sliderYpos);
g_InvD[g_ino].FirstDisp = g_slideStuff[ati].n;
@@ -4351,29 +3767,29 @@ static void SlideSlider(int y, SSFN fn) {
* Gets called at the start and end of a drag on the slider, and upon
* y-movement during such a drag.
*/
-static void SlideCSlider(int y, SSFN fn) {
- static int newY = 0; // FIXME: Avoid non-const global vars
- int gotoY;
- int fc;
+void Dialogs::SlideCSlider(int y, SSFN fn) {
+ static int newY = 0; // FIXME: Avoid non-const global vars
+ int gotoY;
+ int fc;
// Only do this if there's a slider
if (!g_SlideObject)
return;
switch (fn) {
- case S_START: // Start of a drag on the slider
+ case S_START: // Start of a drag on the slider
newY = g_sliderYpos;
break;
- case S_SLIDE: // Y-movement during drag
- newY = newY + y; // New y-position
+ case S_SLIDE: // Y-movement during drag
+ newY = newY + y; // New y-position
if (newY < g_sliderYmin)
- gotoY = g_sliderYmin; // Above top limit
+ gotoY = g_sliderYmin; // Above top limit
else if (newY > g_sliderYmax)
- gotoY = g_sliderYmax; // Below bottom limit
+ gotoY = g_sliderYmax; // Below bottom limit
else
- gotoY = newY; // Hunky-Dory
+ gotoY = newY; // Hunky-Dory
// Move slider to new position
if (TinselV2)
@@ -4384,7 +3800,7 @@ static void SlideCSlider(int y, SSFN fn) {
if ((cd.box == saveBox || cd.box == loadBox))
FirstFile((g_sliderYpos - g_sliderYmin) * (MAX_SAVED_FILES - NUM_RGROUP_BOXES) /
- (g_sliderYmax - g_sliderYmin));
+ (g_sliderYmax - g_sliderYmin));
else if (cd.box == hopperBox1)
FirstScene((g_sliderYpos - g_sliderYmin) * (g_numScenes - NUM_RGROUP_BOXES) / sliderRange);
else if (cd.box == hopperBox2)
@@ -4400,13 +3816,13 @@ static void SlideCSlider(int y, SSFN fn) {
if (cd.selBox < 0)
cd.selBox = 0;
else if (cd.selBox >= NUM_RGROUP_BOXES)
- cd.selBox = NUM_RGROUP_BOXES-1;
+ cd.selBox = NUM_RGROUP_BOXES - 1;
Select(cd.selBox, true);
}
break;
- case S_END: // End of a drag on the slider
+ case S_END: // End of a drag on the slider
break;
default:
@@ -4418,8 +3834,8 @@ static void SlideCSlider(int y, SSFN fn) {
* Gets called at the start and end of a drag on a mixing desk slider,
* and upon x-movement during such a drag.
*/
-static void SlideMSlider(int x, SSFN fn) {
- static int newX = 0; // FIXME: Avoid non-const global vars
+void Dialogs::SlideMSlider(int x, SSFN fn) {
+ static int newX = 0; // FIXME: Avoid non-const global vars
int gotoX;
int index, i;
@@ -4436,31 +3852,31 @@ static void SlideMSlider(int x, SSFN fn) {
assert(i < g_numMdSlides);
switch (fn) {
- case S_START: // Start of a drag on the slider
+ case S_START: // Start of a drag on the slider
// can use index as a throw-away value
GetAniPosition(g_mdSlides[i].obj, &newX, &index);
g_lX = g_sX = newX;
break;
- case S_SLIDE: // X-movement during drag
+ case S_SLIDE: // X-movement during drag
if (x == 0)
return;
- newX = newX + x; // New x-position
+ newX = newX + x; // New x-position
if (newX < g_mdSlides[i].min)
- gotoX = g_mdSlides[i].min; // Below bottom limit
+ gotoX = g_mdSlides[i].min; // Below bottom limit
else if (newX > g_mdSlides[i].max)
- gotoX = g_mdSlides[i].max; // Above top limit
+ gotoX = g_mdSlides[i].max; // Above top limit
else
- gotoX = newX; // Hunky-Dory
+ gotoX = newX; // Hunky-Dory
// Move slider to new position
MultiMoveRelXY(g_mdSlides[i].obj, gotoX - g_sX, 0);
g_sX = gotoX;
if (g_lX != g_sX) {
- *cd.box[index].ival = (g_sX - g_mdSlides[i].min)*cd.box[index].w/SLIDE_RANGE;
+ *cd.box[index].ival = (g_sX - g_mdSlides[i].min) * cd.box[index].w / SLIDE_RANGE;
if (cd.box[index].boxFunc == MUSICVOL)
_vm->_music->SetMidiVolume(*cd.box[index].ival);
#ifdef MAC_OPTIONS
@@ -4476,8 +3892,8 @@ static void SlideMSlider(int x, SSFN fn) {
case S_TIMEUP:
case S_TIMEDN:
- gotoX = SLIDE_RANGE*(*cd.box[index].ival)/cd.box[index].w;
- MultiSetAniX(g_mdSlides[i].obj, g_mdSlides[i].min+gotoX);
+ gotoX = SLIDE_RANGE * (*cd.box[index].ival) / cd.box[index].w;
+ MultiSetAniX(g_mdSlides[i].obj, g_mdSlides[i].min + gotoX);
if (cd.box[index].boxFunc == MUSICVOL)
_vm->_music->SetMidiVolume(*cd.box[index].ival);
@@ -4490,8 +3906,8 @@ static void SlideMSlider(int x, SSFN fn) {
#endif
break;
- case S_END: // End of a drag on the slider
- AddBoxes(false); // Might change position slightly
+ case S_END: // End of a drag on the slider
+ AddBoxes(false); // Might change position slightly
if (g_ino == INV_CONF && cd.box == subtitlesBox)
Select(_vm->_config->_language, false);
break;
@@ -4504,18 +3920,18 @@ static void SlideMSlider(int x, SSFN fn) {
/**
* Called from ChangeingSize() during re-sizing.
*/
-static void GettingTaller() {
+void Dialogs::GettingTaller() {
if (g_SuppV) {
g_Ychange += g_SuppV;
if (g_Ycompensate == 'T')
g_InvD[g_ino].inventoryY += g_SuppV;
g_SuppV = 0;
}
- while (g_Ychange > (ITEM_HEIGHT+1) && g_InvD[g_ino].NoofVicons < g_InvD[g_ino].MaxVicons) {
- g_Ychange -= (ITEM_HEIGHT+1);
+ while (g_Ychange > (ITEM_HEIGHT + 1) && g_InvD[g_ino].NoofVicons < g_InvD[g_ino].MaxVicons) {
+ g_Ychange -= (ITEM_HEIGHT + 1);
g_InvD[g_ino].NoofVicons++;
if (g_Ycompensate == 'T')
- g_InvD[g_ino].inventoryY -= (ITEM_HEIGHT+1);
+ g_InvD[g_ino].inventoryY -= (ITEM_HEIGHT + 1);
}
if (g_InvD[g_ino].NoofVicons < g_InvD[g_ino].MaxVicons) {
g_SuppV = g_Ychange;
@@ -4528,32 +3944,32 @@ static void GettingTaller() {
/**
* Called from ChangeingSize() during re-sizing.
*/
-static void GettingShorter() {
+void Dialogs::GettingShorter() {
int StartNvi = g_InvD[g_ino].NoofVicons;
int StartUv = g_SuppV;
if (g_SuppV) {
- g_Ychange += (g_SuppV - (ITEM_HEIGHT+1));
+ g_Ychange += (g_SuppV - (ITEM_HEIGHT + 1));
g_InvD[g_ino].NoofVicons++;
g_SuppV = 0;
}
- while (g_Ychange < -(ITEM_HEIGHT+1) && g_InvD[g_ino].NoofVicons > g_InvD[g_ino].MinVicons) {
- g_Ychange += (ITEM_HEIGHT+1);
+ while (g_Ychange < -(ITEM_HEIGHT + 1) && g_InvD[g_ino].NoofVicons > g_InvD[g_ino].MinVicons) {
+ g_Ychange += (ITEM_HEIGHT + 1);
g_InvD[g_ino].NoofVicons--;
}
if (g_InvD[g_ino].NoofVicons > g_InvD[g_ino].MinVicons && g_Ychange) {
- g_SuppV = (ITEM_HEIGHT+1) + g_Ychange;
+ g_SuppV = (ITEM_HEIGHT + 1) + g_Ychange;
g_InvD[g_ino].NoofVicons--;
g_Ychange = 0;
}
if (g_Ycompensate == 'T')
- g_InvD[g_ino].inventoryY += (ITEM_HEIGHT+1)*(StartNvi - g_InvD[g_ino].NoofVicons) - (g_SuppV - StartUv);
+ g_InvD[g_ino].inventoryY += (ITEM_HEIGHT + 1) * (StartNvi - g_InvD[g_ino].NoofVicons) - (g_SuppV - StartUv);
}
/**
* Called from ChangeingSize() during re-sizing.
*/
-static void GettingWider() {
+void Dialogs::GettingWider() {
int StartNhi = g_InvD[g_ino].NoofHicons;
int StartUh = g_SuppH;
@@ -4561,8 +3977,8 @@ static void GettingWider() {
g_Xchange += g_SuppH;
g_SuppH = 0;
}
- while (g_Xchange > (ITEM_WIDTH+1) && g_InvD[g_ino].NoofHicons < g_InvD[g_ino].MaxHicons) {
- g_Xchange -= (ITEM_WIDTH+1);
+ while (g_Xchange > (ITEM_WIDTH + 1) && g_InvD[g_ino].NoofHicons < g_InvD[g_ino].MaxHicons) {
+ g_Xchange -= (ITEM_WIDTH + 1);
g_InvD[g_ino].NoofHicons++;
}
if (g_InvD[g_ino].NoofHicons < g_InvD[g_ino].MaxHicons) {
@@ -4570,39 +3986,38 @@ static void GettingWider() {
g_Xchange = 0;
}
if (g_Xcompensate == 'L')
- g_InvD[g_ino].inventoryX += (ITEM_WIDTH+1)*(StartNhi - g_InvD[g_ino].NoofHicons) - (g_SuppH - StartUh);
+ g_InvD[g_ino].inventoryX += (ITEM_WIDTH + 1) * (StartNhi - g_InvD[g_ino].NoofHicons) - (g_SuppH - StartUh);
}
/**
* Called from ChangeingSize() during re-sizing.
*/
-static void GettingNarrower() {
+void Dialogs::GettingNarrower() {
int StartNhi = g_InvD[g_ino].NoofHicons;
int StartUh = g_SuppH;
if (g_SuppH) {
- g_Xchange += (g_SuppH - (ITEM_WIDTH+1));
+ g_Xchange += (g_SuppH - (ITEM_WIDTH + 1));
g_InvD[g_ino].NoofHicons++;
g_SuppH = 0;
}
- while (g_Xchange < -(ITEM_WIDTH+1) && g_InvD[g_ino].NoofHicons > g_InvD[g_ino].MinHicons) {
- g_Xchange += (ITEM_WIDTH+1);
+ while (g_Xchange < -(ITEM_WIDTH + 1) && g_InvD[g_ino].NoofHicons > g_InvD[g_ino].MinHicons) {
+ g_Xchange += (ITEM_WIDTH + 1);
g_InvD[g_ino].NoofHicons--;
}
if (g_InvD[g_ino].NoofHicons > g_InvD[g_ino].MinHicons && g_Xchange) {
- g_SuppH = (ITEM_WIDTH+1) + g_Xchange;
+ g_SuppH = (ITEM_WIDTH + 1) + g_Xchange;
g_InvD[g_ino].NoofHicons--;
g_Xchange = 0;
}
if (g_Xcompensate == 'L')
- g_InvD[g_ino].inventoryX += (ITEM_WIDTH+1)*(StartNhi - g_InvD[g_ino].NoofHicons) - (g_SuppH - StartUh);
+ g_InvD[g_ino].inventoryX += (ITEM_WIDTH + 1) * (StartNhi - g_InvD[g_ino].NoofHicons) - (g_SuppH - StartUh);
}
-
/**
* Called from Xmovement()/Ymovement() during re-sizing.
*/
-static void ChangeingSize() {
+void Dialogs::ChangeingSize() {
/* Make it taller or shorter if necessary. */
if (g_Ychange > 0)
GettingTaller();
@@ -4621,7 +4036,7 @@ static void ChangeingSize() {
/**
* Called from cursor module when cursor moves while inventory is up.
*/
-extern void Xmovement(int x) {
+void Dialogs::Xmovement(int x) {
int aniX, aniY;
int i;
@@ -4629,7 +4044,7 @@ extern void Xmovement(int x) {
switch (g_InvDragging) {
case ID_MOVE:
GetAniPosition(g_objArray[0], &g_InvD[g_ino].inventoryX, &aniY);
- g_InvD[g_ino].inventoryX +=x;
+ g_InvD[g_ino].inventoryX += x;
MultiSetAniX(g_objArray[0], g_InvD[g_ino].inventoryX);
for (i = 1; i < MAX_WCOMP && g_objArray[i]; i++)
MultiMoveRelXY(g_objArray[i], x, 0);
@@ -4669,7 +4084,7 @@ extern void Xmovement(int x) {
/**
* Called from cursor module when cursor moves while inventory is up.
*/
-extern void Ymovement(int y) {
+void Dialogs::Ymovement(int y) {
int aniX, aniY;
int i;
@@ -4677,7 +4092,7 @@ extern void Ymovement(int y) {
switch (g_InvDragging) {
case ID_MOVE:
GetAniPosition(g_objArray[0], &aniX, &g_InvD[g_ino].inventoryY);
- g_InvD[g_ino].inventoryY +=y;
+ g_InvD[g_ino].inventoryY += y;
MultiSetAniY(g_objArray[0], g_InvD[g_ino].inventoryY);
for (i = 1; i < MAX_WCOMP && g_objArray[i]; i++)
MultiMoveRelXY(g_objArray[i], 0, y);
@@ -4721,8 +4136,8 @@ extern void Ymovement(int y) {
/**
* Called when a drag is commencing.
*/
-static void InvDragStart() {
- int curX, curY; // cursor's animation position
+void Dialogs::InvDragStart() {
+ int curX, curY; // cursor's animation position
_vm->_cursor->GetCursorXY(&curX, &curY, false);
@@ -4730,7 +4145,7 @@ static void InvDragStart() {
* Do something different for Save/Restore screens
*/
if (g_ino == INV_CONF) {
- int whichbox;
+ int whichbox;
whichbox = WhichMenuBox(curX, curY, true);
@@ -4738,7 +4153,7 @@ static void InvDragStart() {
g_InvDragging = ID_CSLIDE;
SlideCSlider(0, S_START);
} else if (whichbox > 0 && (whichbox & IS_MASK)) {
- g_InvDragging = ID_MDCONT; // Mixing desk control
+ g_InvDragging = ID_MDCONT; // Mixing desk control
cd.selBox = whichbox;
SlideMSlider(0, S_START);
}
@@ -4840,8 +4255,8 @@ static void InvDragStart() {
/**
* Called when a drag is over.
*/
-static void InvDragEnd() {
- int curX, curY; // cursor's animation position
+void Dialogs::InvDragEnd() {
+ int curX, curY; // cursor's animation position
_vm->_cursor->GetCursorXY(&curX, &curY, false);
@@ -4849,11 +4264,11 @@ static void InvDragEnd() {
if (g_InvDragging == ID_SLIDE) {
SlideSlider(0, S_END);
} else if (g_InvDragging == ID_CSLIDE) {
- ; // No action
+ ; // No action
} else if (g_InvDragging == ID_MDCONT) {
SlideMSlider(0, S_END);
} else if (g_InvDragging == ID_MOVE) {
- ; // No action
+ ; // No action
} else {
// Were re-sizing. Redraw the whole thing.
DumpDobjArray();
@@ -4875,10 +4290,10 @@ static void InvDragEnd() {
// Cursor could well now be inappropriate
InvCursor(IC_AREA, curX, curY);
- g_Xchange = g_Ychange = 0; // Probably no need, but does no harm!
+ g_Xchange = g_Ychange = 0; // Probably no need, but does no harm!
}
-static bool MenuDown(int lines) {
+bool Dialogs::MenuDown(int lines) {
if (cd.box == loadBox || cd.box == saveBox) {
if (cd.extraBase < MAX_SAVED_FILES - NUM_RGROUP_BOXES) {
FirstFile(cd.extraBase + lines);
@@ -4901,7 +4316,7 @@ static bool MenuDown(int lines) {
return false;
}
-static bool MenuUp(int lines) {
+bool Dialogs::MenuUp(int lines) {
if (cd.extraBase > 0) {
if (cd.box == loadBox || cd.box == saveBox)
FirstFile(cd.extraBase - lines);
@@ -4918,7 +4333,7 @@ static bool MenuUp(int lines) {
return false;
}
-static void MenuRollDown() {
+void Dialogs::MenuRollDown() {
if (MenuDown(1)) {
if (cd.selBox > 0)
cd.selBox--;
@@ -4926,7 +4341,7 @@ static void MenuRollDown() {
}
}
-static void MenuRollUp() {
+void Dialogs::MenuRollUp() {
if (MenuUp(1)) {
if (cd.selBox < NUM_RGROUP_BOXES - 1)
cd.selBox++;
@@ -4934,34 +4349,34 @@ static void MenuRollUp() {
}
}
-static void MenuPageDown() {
+void Dialogs::MenuPageDown() {
if (MenuDown(NUM_RGROUP_BOXES - 1)) {
cd.selBox = NUM_RGROUP_BOXES - 1;
Select(cd.selBox, true);
}
}
-static void MenuPageUp() {
+void Dialogs::MenuPageUp() {
if (MenuUp(NUM_RGROUP_BOXES - 1)) {
cd.selBox = 0;
Select(cd.selBox, true);
}
}
-static void InventoryDown() {
+void Dialogs::InventoryDown() {
// This code is a copy of the IB_SLIDE_DOWN case in InvWalkTo
// TODO: So share this duplicate code
if (g_InvD[g_ino].NoofVicons == 1)
- if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
+ if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons * g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
for (int i = 1; i < g_InvD[g_ino].NoofVicons; i++) {
- if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
+ if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons * g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
}
g_ItemsChanged = true;
}
-static void InventoryUp() {
+void Dialogs::InventoryUp() {
// This code is a copy of the I_SLIDE_UP case in InvWalkTo
// TODO: So share this duplicate code
if (g_InvD[g_ino].NoofVicons == 1)
@@ -4980,13 +4395,13 @@ static void InventoryUp() {
/**
* MenuAction
*/
-static void MenuAction(int i, bool dbl) {
+void Dialogs::MenuAction(int i, bool dbl) {
if (i >= 0) {
switch (cd.box[i].boxType) {
case FLIP:
if (dbl) {
- *(cd.box[i].ival) ^= 1; // XOR with true
+ *(cd.box[i].ival) ^= 1; // XOR with true
AddBoxes(false);
}
break;
@@ -5059,12 +4474,12 @@ static void MenuAction(int i, bool dbl) {
}
}
-static void ConfActionSpecial(int i) {
+void Dialogs::ConfActionSpecial(int i) {
switch (i) {
case IB_NONE:
default:
break;
- case IB_UP: // Scroll up
+ case IB_UP: // Scroll up
if (cd.extraBase > 0) {
if ((cd.box == loadBox) || (cd.box == saveBox))
FirstFile(cd.extraBase - 1);
@@ -5079,7 +4494,7 @@ static void ConfActionSpecial(int i) {
Select(cd.selBox, true);
}
break;
- case IB_DOWN: // Scroll down
+ case IB_DOWN: // Scroll down
if ((cd.box == loadBox) || (cd.box == saveBox)) {
if (cd.extraBase < MAX_SAVED_FILES - NUM_RGROUP_BOXES) {
FirstFile(cd.extraBase + 1);
@@ -5118,10 +4533,10 @@ static void ConfActionSpecial(int i) {
}
// SLIDE_UP and SLIDE_DOWN on d click??????
-static void InvPutDown(int index) {
+void Dialogs::InvPutDown(int index) {
int aniX, aniY;
- // index is the drop position
- int hiIndex; // Current position of held item (if in)
+ // index is the drop position
+ int hiIndex; // Current position of held item (if in)
// Find where the held item is positioned in this inventory (if it is)
for (hiIndex = 0; hiIndex < g_InvD[g_ino].NoofItems; hiIndex++)
@@ -5130,13 +4545,13 @@ static void InvPutDown(int index) {
// If drop position would leave a gap, move it up
if (index >= g_InvD[g_ino].NoofItems) {
- if (hiIndex == g_InvD[g_ino].NoofItems) // Not in, add it
+ if (hiIndex == g_InvD[g_ino].NoofItems) // Not in, add it
index = g_InvD[g_ino].NoofItems;
else
index = g_InvD[g_ino].NoofItems - 1;
}
- if (hiIndex == g_InvD[g_ino].NoofItems) { // Not in, add it
+ if (hiIndex == g_InvD[g_ino].NoofItems) { // Not in, add it
if (g_InvD[g_ino].NoofItems < g_InvD[g_ino].MaxInvObj) {
g_InvD[g_ino].NoofItems++;
@@ -5151,10 +4566,10 @@ static void InvPutDown(int index) {
// Position it in the inventory
if (index < hiIndex) {
- memmove(&g_InvD[g_ino].contents[index + 1], &g_InvD[g_ino].contents[index], (hiIndex-index)*sizeof(int));
+ memmove(&g_InvD[g_ino].contents[index + 1], &g_InvD[g_ino].contents[index], (hiIndex - index) * sizeof(int));
g_InvD[g_ino].contents[index] = g_heldItem;
} else if (index > hiIndex) {
- memmove(&g_InvD[g_ino].contents[hiIndex], &g_InvD[g_ino].contents[hiIndex+1], (index-hiIndex)*sizeof(int));
+ memmove(&g_InvD[g_ino].contents[hiIndex], &g_InvD[g_ino].contents[hiIndex + 1], (index - hiIndex) * sizeof(int));
g_InvD[g_ino].contents[index] = g_heldItem;
} else {
g_InvD[g_ino].contents[index] = g_heldItem;
@@ -5168,26 +4583,7 @@ static void InvPutDown(int index) {
InvCursor(IC_DROP, aniX, aniY);
}
-static void InvPdProcess(CORO_PARAM, const void *param) {
- // COROUTINE
- CORO_BEGIN_CONTEXT;
- CORO_END_CONTEXT(_ctx);
-
- CORO_BEGIN_CODE(_ctx);
-
- GetToken(TOKEN_LEFT_BUT);
- CORO_SLEEP(_vm->_config->_dclickSpeed+1);
- FreeToken(TOKEN_LEFT_BUT);
-
- // get the stuff copied to process when it was created
- const int *pindex = (const int *)param;
-
- InvPutDown(*pindex);
-
- CORO_END_CODE;
-}
-
-static void InvPickup(int index) {
+void Dialogs::InvPickup(int index) {
INV_OBJECT *invObj;
// Do nothing if not clicked on anything
@@ -5196,7 +4592,7 @@ static void InvPickup(int index) {
// If not holding anything
if (g_heldItem == INV_NOICON && g_InvD[g_ino].contents[index] &&
- (!TinselV2 || g_InvD[g_ino].contents[index] != g_heldItem)) {
+ (!TinselV2 || g_InvD[g_ino].contents[index] != g_heldItem)) {
// Pick-up
invObj = GetInvObject(g_InvD[g_ino].contents[index]);
g_thisIcon = g_InvD[g_ino].contents[index];
@@ -5213,8 +4609,7 @@ static void InvPickup(int index) {
if (invObj->attribute & IO_DROPCODE && invObj->hScript)
InvTinselEvent(invObj, PUTDOWN, INV_PICKUP, index);
- else if (!(invObj->attribute & IO_ONLYINV1 && g_ino != INV_1)
- && !(invObj->attribute & IO_ONLYINV2 && g_ino != INV_2)) {
+ else if (!(invObj->attribute & IO_ONLYINV1 && g_ino != INV_1) && !(invObj->attribute & IO_ONLYINV2 && g_ino != INV_2)) {
if (TinselV2)
InvPutDown(index);
else
@@ -5226,7 +4621,7 @@ static void InvPickup(int index) {
/**
* Handle WALKTO event (Pick up/put down event)
*/
-static void InvWalkTo(const Common::Point &coOrds) {
+void Dialogs::InvWalkTo(const Common::Point &coOrds) {
int i;
switch (InvArea(coOrds.x, coOrds.y)) {
@@ -5257,17 +4652,17 @@ static void InvWalkTo(const Common::Point &coOrds) {
case I_SLIDE_DOWN:
if (g_InvD[g_ino].NoofVicons == 1)
- if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
+ if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons * g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
for (i = 1; i < g_InvD[g_ino].NoofVicons; i++) {
- if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
+ if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons * g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
}
g_ItemsChanged = true;
break;
case I_DOWN:
- if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems) {
+ if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons * g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems) {
g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
g_ItemsChanged = true;
}
@@ -5284,15 +4679,15 @@ static void InvWalkTo(const Common::Point &coOrds) {
// To cater for drop in dead space between icons,
// look 1 pixel right, then 1 down, then 1 right and down.
if (i == INV_NOICON && g_heldItem != INV_NOICON &&
- (g_ino == INV_1 || g_ino == INV_2)) {
- pt.x += 1; // 1 to the right
+ (g_ino == INV_1 || g_ino == INV_2)) {
+ pt.x += 1; // 1 to the right
i = InvItem(pt, false);
if (i == INV_NOICON) {
- pt.x -= 1; // 1 down
+ pt.x -= 1; // 1 down
pt.y += 1;
i = InvItem(pt, false);
if (i == INV_NOICON) {
- pt.x += 1; // 1 down-right
+ pt.x += 1; // 1 down-right
i = InvItem(pt, false);
}
}
@@ -5310,7 +4705,7 @@ static void InvWalkTo(const Common::Point &coOrds) {
}
}
-static void InvAction() {
+void Dialogs::InvAction() {
int index;
INV_OBJECT *invObj;
int aniX, aniY;
@@ -5340,7 +4735,7 @@ static void InvAction() {
}
break;
- case I_HEADER: // Maximise/unmaximise inventory
+ case I_HEADER: // Maximise/unmaximise inventory
if (!g_InvD[g_ino].resizable)
break;
@@ -5383,7 +4778,7 @@ static void InvAction() {
g_ItemsChanged = true;
break;
case I_DOWN:
- if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems) {
+ if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons * g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems) {
g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
g_ItemsChanged = true;
}
@@ -5392,10 +4787,9 @@ static void InvAction() {
default:
break;
}
-
}
-static void InvLook(const Common::Point &coOrds) {
+void Dialogs::InvLook(const Common::Point &coOrds) {
int index;
INV_OBJECT *invObj;
Common::Point pt = coOrds;
@@ -5423,12 +4817,11 @@ static void InvLook(const Common::Point &coOrds) {
}
}
-
/**************************************************************************/
/********************* Incoming events ************************************/
/**************************************************************************/
-extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
+void Dialogs::EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
if (g_InventoryHidden)
return;
@@ -5440,28 +4833,28 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
}
break;
- case PLR_WALKTO: // PLR_SLEFT
+ case PLR_WALKTO: // PLR_SLEFT
InvWalkTo(coOrds);
break;
- case INV_LOOK: // PLR_SRIGHT
+ case INV_LOOK: // PLR_SRIGHT
if (MenuActive())
InvWalkTo(coOrds);
else
InvLook(coOrds);
break;
- case PLR_ACTION: // PLR_DLEFT
+ case PLR_ACTION: // PLR_DLEFT
if (g_InvDragging != ID_MDCONT)
InvDragEnd();
InvAction();
break;
- case PLR_DRAG1_START: // Left drag start
+ case PLR_DRAG1_START: // Left drag start
InvDragStart();
break;
- case PLR_DRAG1_END: // Left drag end
+ case PLR_DRAG1_END: // Left drag end
InvDragEnd();
break;
@@ -5541,11 +4934,11 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
if (g_ino == INV_MENU) {
// Load or Save screen
if (cd.box == loadBox || cd.box == saveBox)
- FirstFile(MAX_SAVED_FILES); // Will get reduced to appropriate value
+ FirstFile(MAX_SAVED_FILES); // Will get reduced to appropriate value
else if (cd.box == hopperBox1)
- FirstScene(g_numScenes); // Will get reduced to appropriate value
+ FirstScene(g_numScenes); // Will get reduced to appropriate value
else if (cd.box == hopperBox2)
- FirstEntry(g_numEntries); // Will get reduced to appropriate value
+ FirstEntry(g_numEntries); // Will get reduced to appropriate value
else
break;
@@ -5554,7 +4947,7 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
Select(cd.selBox, true);
} else {
// Inventory window
- g_InvD[g_ino].FirstDisp = g_InvD[g_ino].NoofItems - g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons;
+ g_InvD[g_ino].FirstDisp = g_InvD[g_ino].NoofItems - g_InvD[g_ino].NoofHicons * g_InvD[g_ino].NoofVicons;
if (g_InvD[g_ino].FirstDisp < 0)
g_InvD[g_ino].FirstDisp = 0;
g_ItemsChanged = true;
@@ -5573,7 +4966,7 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
* Called from Glitter function invdepict()
* Changes (permanently) the animation film for that object.
*/
-extern void SetObjectFilm(int object, SCNHANDLE hFilm) {
+void Dialogs::SetObjectFilm(int object, SCNHANDLE hFilm) {
INV_OBJECT *invObj;
invObj = GetInvObject(object);
@@ -5586,7 +4979,7 @@ extern void SetObjectFilm(int object, SCNHANDLE hFilm) {
/**
* (Un)serialize the inventory data for save/restore game.
*/
-extern void syncInvInfo(Common::Serializer &s) {
+void Dialogs::syncInvInfo(Common::Serializer &s) {
for (int i = 0; i < NUM_INV; i++) {
s.syncAsSint32LE(g_InvD[i].MinHicons);
s.syncAsSint32LE(g_InvD[i].MinVicons);
@@ -5628,9 +5021,9 @@ extern void syncInvInfo(Common::Serializer &s) {
* its id, animation film and Glitter script.
*/
// Note: the SCHANDLE type here has been changed to a void*
-extern void RegisterIcons(void *cptr, int num) {
+void Dialogs::RegisterIcons(void *cptr, int num) {
g_numObjects = num;
- g_invObjects = (INV_OBJECT *) cptr;
+ g_invObjects = (INV_OBJECT *)cptr;
if (TinselV0) {
// In Tinsel 0, the INV_OBJECT structure doesn't have an attributes field, so we
@@ -5657,7 +5050,6 @@ extern void RegisterIcons(void *cptr, int num) {
memset(g_invFilms, 0, g_numObjects * sizeof(SCNHANDLE));
}
-
// Add defined permanent conversation icons
// and store all the films separately
int i;
@@ -5675,7 +5067,7 @@ extern void RegisterIcons(void *cptr, int num) {
* Called from Glitter function 'dec_invw()' - Declare the bits that the
* inventory windows are constructed from, and special cursors.
*/
-extern void setInvWinParts(SCNHANDLE hf) {
+void Dialogs::setInvWinParts(SCNHANDLE hf) {
#ifdef DEBUG
const FILM *pfilm;
#endif
@@ -5692,7 +5084,7 @@ extern void setInvWinParts(SCNHANDLE hf) {
* Called from Glitter function 'dec_flags()' - Declare the language
* flag films
*/
-extern void setFlagFilms(SCNHANDLE hf) {
+void Dialogs::setFlagFilms(SCNHANDLE hf) {
#ifdef DEBUG
const FILM *pfilm;
#endif
@@ -5708,7 +5100,7 @@ extern void setFlagFilms(SCNHANDLE hf) {
/**
* Called from Glitter function 'DecCStrings()'
*/
-extern void setConfigStrings(SCNHANDLE *tp) {
+void Dialogs::setConfigStrings(SCNHANDLE *tp) {
memcpy(g_configStrings, tp, sizeof(g_configStrings));
}
@@ -5716,17 +5108,17 @@ extern void setConfigStrings(SCNHANDLE *tp) {
* Called from Glitter functions: dec_convw()/dec_inv1()/dec_inv2()
* - Declare the heading text and dimensions etc.
*/
-extern void idec_inv(int num, SCNHANDLE text, int MaxContents,
- int MinWidth, int MinHeight,
- int StartWidth, int StartHeight,
- int MaxWidth, int MaxHeight,
- int startx, int starty, bool moveable) {
+void Dialogs::idec_inv(int num, SCNHANDLE text, int MaxContents,
+ int MinWidth, int MinHeight,
+ int StartWidth, int StartHeight,
+ int MaxWidth, int MaxHeight,
+ int startx, int starty, bool moveable) {
if (MaxWidth > MAXHICONS)
- MaxWidth = MAXHICONS; // Max window width
+ MaxWidth = MAXHICONS; // Max window width
if (MaxHeight > MAXVICONS)
- MaxHeight = MAXVICONS; // Max window height
+ MaxHeight = MAXVICONS; // Max window height
if (MaxContents > MAX_ININV)
- MaxContents = MAX_ININV; // Max contents
+ MaxContents = MAX_ININV; // Max contents
if (StartWidth > MaxWidth)
StartWidth = MaxWidth;
@@ -5769,45 +5161,45 @@ extern void idec_inv(int num, SCNHANDLE text, int MaxContents,
* Called from Glitter functions: dec_convw()/dec_inv1()/dec_inv2()
* - Declare the heading text and dimensions etc.
*/
-extern void idec_convw(SCNHANDLE text, int MaxContents,
- int MinWidth, int MinHeight,
- int StartWidth, int StartHeight,
- int MaxWidth, int MaxHeight) {
+void Dialogs::idec_convw(SCNHANDLE text, int MaxContents,
+ int MinWidth, int MinHeight,
+ int StartWidth, int StartHeight,
+ int MaxWidth, int MaxHeight) {
idec_inv(INV_CONV, text, MaxContents, MinWidth, MinHeight,
- StartWidth, StartHeight, MaxWidth, MaxHeight,
- 20, 8, true);
+ StartWidth, StartHeight, MaxWidth, MaxHeight,
+ 20, 8, true);
}
/**
* Called from Glitter functions: dec_convw()/dec_inv1()/dec_inv2()
* - Declare the heading text and dimensions etc.
*/
-extern void idec_inv1(SCNHANDLE text, int MaxContents,
- int MinWidth, int MinHeight,
- int StartWidth, int StartHeight,
- int MaxWidth, int MaxHeight) {
+void Dialogs::idec_inv1(SCNHANDLE text, int MaxContents,
+ int MinWidth, int MinHeight,
+ int StartWidth, int StartHeight,
+ int MaxWidth, int MaxHeight) {
idec_inv(INV_1, text, MaxContents, MinWidth, MinHeight,
- StartWidth, StartHeight, MaxWidth, MaxHeight,
- 100, 100, true);
+ StartWidth, StartHeight, MaxWidth, MaxHeight,
+ 100, 100, true);
}
/**
* Called from Glitter functions: dec_convw()/dec_inv1()/dec_inv2()
* - Declare the heading text and dimensions etc.
*/
-extern void idec_inv2(SCNHANDLE text, int MaxContents,
- int MinWidth, int MinHeight,
- int StartWidth, int StartHeight,
- int MaxWidth, int MaxHeight) {
+void Dialogs::idec_inv2(SCNHANDLE text, int MaxContents,
+ int MinWidth, int MinHeight,
+ int StartWidth, int StartHeight,
+ int MaxWidth, int MaxHeight) {
idec_inv(INV_2, text, MaxContents, MinWidth, MinHeight,
- StartWidth, StartHeight, MaxWidth, MaxHeight,
- 100, 100, true);
+ StartWidth, StartHeight, MaxWidth, MaxHeight,
+ 100, 100, true);
}
/**
* Called from Glitter function 'GetInvLimit()'
*/
-extern int InvGetLimit(int invno) {
+int Dialogs::InvGetLimit(int invno) {
assert(invno == INV_1 || invno == INV_2); // only INV_1 and INV_2 supported
return g_InvD[invno].MaxInvObj;
@@ -5816,12 +5208,12 @@ extern int InvGetLimit(int invno) {
/**
* Called from Glitter function 'SetInvLimit()'
*/
-extern void InvSetLimit(int invno, int MaxContents) {
- assert(invno == INV_1 || invno == INV_2); // only INV_1 and INV_2 supported
+void Dialogs::InvSetLimit(int invno, int MaxContents) {
+ assert(invno == INV_1 || invno == INV_2); // only INV_1 and INV_2 supported
assert(MaxContents >= g_InvD[invno].NoofItems); // can't reduce maximum contents below current contents
if (MaxContents > MAX_ININV)
- MaxContents = MAX_ININV; // Max contents
+ MaxContents = MAX_ININV; // Max contents
g_InvD[invno].MaxInvObj = MaxContents;
}
@@ -5829,8 +5221,8 @@ extern void InvSetLimit(int invno, int MaxContents) {
/**
* Called from Glitter function 'SetInvSize()'
*/
-extern void InvSetSize(int invno, int MinWidth, int MinHeight,
- int StartWidth, int StartHeight, int MaxWidth, int MaxHeight) {
+void Dialogs::InvSetSize(int invno, int MinWidth, int MinHeight,
+ int StartWidth, int StartHeight, int MaxWidth, int MaxHeight) {
assert(invno == INV_1 || invno == INV_2); // only INV_1 and INV_2 supported
if (StartWidth > MaxWidth)
@@ -5856,16 +5248,410 @@ extern void InvSetSize(int invno, int MinWidth, int MinHeight,
/**************************************************************************/
-extern bool IsTopWindow() {
+bool Dialogs::IsTopWindow() {
return (g_InventoryState == BOGUS_INV);
}
-extern bool MenuActive() {
+bool Dialogs::MenuActive() {
return (g_InventoryState == ACTIVE_INV && g_ino == INV_CONF);
}
-extern bool IsConvWindow() {
+bool Dialogs::IsConvWindow() {
return (g_InventoryState == ACTIVE_INV && g_ino == INV_CONV);
}
+void Dialogs::CallFunction(BFUNC boxFunc) {
+ switch (boxFunc) {
+ case SAVEGAME:
+ KillInventory();
+ InvSaveGame();
+ break;
+ case LOADGAME:
+ KillInventory();
+ InvLoadGame();
+ break;
+ case IQUITGAME:
+ _vm->quitGame();
+ break;
+ case CLOSEWIN:
+ KillInventory();
+ if ((cd.box == hopperBox1) || (cd.box == hopperBox2))
+ FreeSceneHopper();
+ break;
+ case OPENLOAD:
+ KillInventory();
+ OpenMenu(LOAD_MENU);
+ break;
+ case OPENSAVE:
+ KillInventory();
+ OpenMenu(SAVE_MENU);
+ break;
+ case OPENREST:
+ KillInventory();
+ OpenMenu(RESTART_MENU);
+ break;
+ case OPENSOUND:
+ KillInventory();
+ OpenMenu(SOUND_MENU);
+ break;
+ case OPENCONT:
+ KillInventory();
+ OpenMenu(CONTROLS_MENU);
+ break;
+#ifndef JAPAN
+ case OPENSUBT:
+ KillInventory();
+ OpenMenu(SUBTITLES_MENU);
+ break;
+#endif
+ case OPENQUIT:
+ KillInventory();
+ OpenMenu(QUIT_MENU);
+ break;
+ case INITGAME:
+ KillInventory();
+ FnRestartGame();
+ break;
+ case CLANG:
+ if (!LanguageChange())
+ KillInventory();
+ break;
+ case RLANG:
+ KillInventory();
+ break;
+ case HOPPER2:
+ _vm->_dialogs->KillInventory();
+ _vm->_dialogs->OpenMenu(HOPPER_MENU2);
+ break;
+ case BF_CHANGESCENE:
+ _vm->_dialogs->KillInventory();
+ _vm->_dialogs->HopAction();
+ _vm->_dialogs->FreeSceneHopper();
+ break;
+ default:
+ break;
+ }
+}
+
+const FILM *Dialogs::GetWindowData() {
+ return (const FILM *)_vm->_handle->LockMem(g_hWinParts);
+}
+
+void Dialogs::Redraw() {
+ if (DisplayObjectsActive()) {
+ if (g_ItemsChanged && !ConfigurationIsActive() && !InventoryIsHidden()) {
+ FillInInventory();
+
+ // Needed when clicking on scroll bar.
+ int curX, curY;
+ _vm->_cursor->GetCursorXY(&curX, &curY, false);
+ InvCursor(IC_AREA, curX, curY);
+
+ g_ItemsChanged = false;
+ }
+ if (!ConfigurationIsActive()) {
+ for (int i = 0; i < MAX_ICONS; i++) {
+ if (g_iconArray[i] != NULL)
+ StepAnimScript(&g_iconAnims[i]);
+ }
+ }
+ if (IsMixingDeskControl()) {
+ // Mixing desk control
+ int sval, index, *pival;
+
+ index = cd.selBox & ~IS_MASK;
+ pival = cd.box[index].ival;
+ sval = *pival;
+
+ if (cd.selBox & IS_LEFT) {
+ *pival -= cd.box[index].h;
+ if (*pival < 0)
+ *pival = 0;
+ } else if (cd.selBox & IS_RIGHT) {
+ *pival += cd.box[index].h;
+ if (*pival > cd.box[index].w)
+ *pival = cd.box[index].w;
+ }
+
+ if (sval != *pival) {
+ SlideMSlider(0, (cd.selBox & IS_RIGHT) ? S_TIMEUP : S_TIMEDN);
+ }
+ }
+ }
+}
+
+/**************************************************************************/
+/************************ The inventory process ***************************/
+/**************************************************************************/
+
+static void InvPdProcess(CORO_PARAM, const void *param) {
+ // COROUTINE
+ CORO_BEGIN_CONTEXT;
+ CORO_END_CONTEXT(_ctx);
+
+ CORO_BEGIN_CODE(_ctx);
+
+ GetToken(TOKEN_LEFT_BUT);
+ CORO_SLEEP(_vm->_config->_dclickSpeed + 1);
+ FreeToken(TOKEN_LEFT_BUT);
+
+ // get the stuff copied to process when it was created
+ const int *pindex = (const int *)param;
+
+ _vm->_dialogs->InvPutDown(*pindex);
+
+ CORO_END_CODE;
+}
+
+static void ButtonPress(CORO_PARAM, CONFBOX *box) {
+ CORO_BEGIN_CONTEXT;
+ CORO_END_CONTEXT(_ctx);
+
+ CORO_BEGIN_CODE(_ctx);
+
+ const FILM *pfilm;
+
+ assert(box->boxType == AAGBUT || box->boxType == ARSGBUT);
+
+ // Replace highlight image with normal image
+ pfilm = _vm->_dialogs->GetWindowData();
+ if (_vm->_dialogs->g_iconArray[HL1] != NULL)
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL1]);
+ pfilm = _vm->_dialogs->GetWindowData();
+ _vm->_dialogs->g_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + NORMGRAPH], -1);
+ MultiSetAniXY(_vm->_dialogs->g_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
+ MultiSetZPosition(_vm->_dialogs->g_iconArray[HL1], Z_INV_ICONS + 1);
+
+ // Hold normal image for 1 frame
+ CORO_SLEEP(1);
+ if (_vm->_dialogs->g_iconArray[HL1] == NULL)
+ return;
+
+ // Replace normal image with depresses image
+ pfilm = _vm->_dialogs->GetWindowData();
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL1]);
+ _vm->_dialogs->g_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + DOWNGRAPH], -1);
+ MultiSetAniXY(_vm->_dialogs->g_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
+ MultiSetZPosition(_vm->_dialogs->g_iconArray[HL1], Z_INV_ICONS + 1);
+
+ // Hold depressed image for 2 frames
+ CORO_SLEEP(2);
+ if (_vm->_dialogs->g_iconArray[HL1] == NULL)
+ return;
+
+ // Replace depressed image with normal image
+ pfilm = _vm->_dialogs->GetWindowData();
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL1]);
+ _vm->_dialogs->g_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + NORMGRAPH], -1);
+ MultiSetAniXY(_vm->_dialogs->g_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
+ MultiSetZPosition(_vm->_dialogs->g_iconArray[HL1], Z_INV_ICONS + 1);
+
+ CORO_SLEEP(1);
+
+ CORO_END_CODE;
+}
+
+static void ButtonToggle(CORO_PARAM, CONFBOX *box) {
+ CORO_BEGIN_CONTEXT;
+ CORO_END_CONTEXT(_ctx);
+
+ CORO_BEGIN_CODE(_ctx);
+
+ const FILM *pfilm;
+
+ assert((box->boxType == TOGGLE) || (box->boxType == TOGGLE1) || (box->boxType == TOGGLE2));
+
+ // Remove hilight image
+ if (_vm->_dialogs->g_iconArray[HL1] != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL1]);
+ _vm->_dialogs->g_iconArray[HL1] = nullptr;
+ }
+
+ // Hold normal image for 1 frame
+ CORO_SLEEP(1);
+ if (!_vm->_dialogs->InventoryIsActive())
+ return;
+
+ // Add depressed image
+ pfilm = _vm->_dialogs->GetWindowData();
+ _vm->_dialogs->g_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + DOWNGRAPH], -1);
+ MultiSetAniXY(_vm->_dialogs->g_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
+ MultiSetZPosition(_vm->_dialogs->g_iconArray[HL1], Z_INV_ICONS + 1);
+
+ // Hold depressed image for 1 frame
+ CORO_SLEEP(1);
+ if (_vm->_dialogs->g_iconArray[HL1] == NULL)
+ return;
+
+ // Toggle state
+ (*box->ival) = *(box->ival) ^ 1; // XOR with true
+ box->bi = *(box->ival) ? IX_TICK1 : IX_CROSS1;
+ _vm->_dialogs->AddBoxes(false);
+ // Keep highlight (e.g. flag)
+ if (cd.selBox != NOBOX)
+ _vm->_dialogs->Select(cd.selBox, true);
+
+ // New state, depressed image
+ pfilm = _vm->_dialogs->GetWindowData();
+ if (_vm->_dialogs->g_iconArray[HL1] != NULL)
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL1]);
+ _vm->_dialogs->g_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + DOWNGRAPH], -1);
+ MultiSetAniXY(_vm->_dialogs->g_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
+ MultiSetZPosition(_vm->_dialogs->g_iconArray[HL1], Z_INV_ICONS + 1);
+
+ // Hold new depressed image for 1 frame
+ CORO_SLEEP(1);
+ if (_vm->_dialogs->g_iconArray[HL1] == NULL)
+ return;
+
+ // New state, normal
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL1]);
+ _vm->_dialogs->g_iconArray[HL1] = nullptr;
+
+ // Hold normal image for 1 frame
+ CORO_SLEEP(1);
+ if (!_vm->_dialogs->InventoryIsActive())
+ return;
+
+ // New state, highlighted
+ pfilm = _vm->_dialogs->GetWindowData();
+ if (_vm->_dialogs->g_iconArray[HL1] != NULL)
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL1]);
+ _vm->_dialogs->g_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + HIGRAPH], -1);
+ MultiSetAniXY(_vm->_dialogs->g_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
+ MultiSetZPosition(_vm->_dialogs->g_iconArray[HL1], Z_INV_ICONS + 1);
+
+ CORO_END_CODE;
+}
+
+/**
+ * Redraws the icons if appropriate. Also handle button press/toggle effects
+ */
+extern void InventoryProcess(CORO_PARAM, const void *) {
+ // COROUTINE
+ CORO_BEGIN_CONTEXT;
+ CORO_END_CONTEXT(_ctx);
+
+ CORO_BEGIN_CODE(_ctx);
+
+ if (NumberOfLanguages() <= 1)
+ _vm->_dialogs->g_bNoLanguage = true;
+
+ while (1) {
+ CORO_SLEEP(1); // allow scheduling
+
+ _vm->_dialogs->Redraw();
+
+ if (g_buttonEffect.bButAnim) {
+ assert(g_buttonEffect.box);
+ if (g_buttonEffect.press) {
+ if (g_buttonEffect.box->boxType == AAGBUT || g_buttonEffect.box->boxType == ARSGBUT)
+ CORO_INVOKE_1(ButtonPress, g_buttonEffect.box);
+ _vm->_dialogs->CallFunction(g_buttonEffect.box->boxFunc);
+ } else
+ CORO_INVOKE_1(ButtonToggle, g_buttonEffect.box);
+
+ g_buttonEffect.bButAnim = false;
+ }
+ }
+ CORO_END_CODE;
+}
+
+/**************************************************************************/
+/************** Running inventory item's Glitter code *********************/
+/**************************************************************************/
+
+struct OP_INIT {
+ INV_OBJECT *pinvo;
+ TINSEL_EVENT event;
+ PLR_EVENT bev;
+ int myEscape;
+};
+
+/**
+ * Run inventory item's Glitter code
+ */
+static void ObjectProcess(CORO_PARAM, const void *param) {
+ // COROUTINE
+ CORO_BEGIN_CONTEXT;
+ INT_CONTEXT *pic;
+ int ThisPointedWait; // Fix the 'repeated pressing bug'
+ CORO_END_CONTEXT(_ctx);
+
+ // get the stuff copied to process when it was created
+ const OP_INIT *to = (const OP_INIT *)param;
+
+ CORO_BEGIN_CODE(_ctx);
+
+ if (!TinselV2)
+ CORO_INVOKE_1(AllowDclick, to->bev);
+
+ _ctx->pic = InitInterpretContext(GS_INVENTORY, to->pinvo->hScript, to->event, NOPOLY, 0, to->pinvo,
+ to->myEscape);
+ CORO_INVOKE_1(Interpret, _ctx->pic);
+
+ if (to->event == POINTED) {
+ _ctx->ThisPointedWait = ++_vm->_dialogs->g_PointedWaitCount;
+ while (1) {
+ CORO_SLEEP(1);
+ int x, y;
+ _vm->_cursor->GetCursorXY(&x, &y, false);
+ if (_vm->_dialogs->InvItemId(x, y) != to->pinvo->id)
+ break;
+
+ // Fix the 'repeated pressing bug'
+ if (_ctx->ThisPointedWait != _vm->_dialogs->g_PointedWaitCount)
+ CORO_KILL_SELF();
+ }
+
+ _ctx->pic = InitInterpretContext(GS_INVENTORY, to->pinvo->hScript, UNPOINT, NOPOLY, 0, to->pinvo);
+ CORO_INVOKE_1(Interpret, _ctx->pic);
+ }
+
+ CORO_END_CODE;
+}
+
+/**
+ * Run inventory item's Glitter code
+ */
+static void InvTinselEvent(INV_OBJECT *pinvo, TINSEL_EVENT event, PLR_EVENT be, int index) {
+ OP_INIT to = {pinvo, event, be, 0};
+
+ if (_vm->_dialogs->InventoryIsHidden() || (TinselV2 && !pinvo->hScript))
+ return;
+
+ _vm->_dialogs->g_GlitterIndex = index;
+ CoroScheduler.createProcess(PID_TCODE, ObjectProcess, &to, sizeof(to));
+}
+
+extern void ObjectEvent(CORO_PARAM, int objId, TINSEL_EVENT event, bool bWait, int myEscape, bool *result) {
+ // COROUTINE
+ CORO_BEGIN_CONTEXT;
+ Common::PROCESS *pProc;
+ INV_OBJECT *pInvo;
+ OP_INIT op;
+ CORO_END_CONTEXT(_ctx);
+
+ CORO_BEGIN_CODE(_ctx);
+
+ if (result)
+ *result = false;
+ _ctx->pInvo = _vm->_dialogs->GetInvObject(objId);
+ if (!_ctx->pInvo->hScript)
+ return;
+
+ _ctx->op.pinvo = _ctx->pInvo;
+ _ctx->op.event = event;
+ _ctx->op.myEscape = myEscape;
+
+ CoroScheduler.createProcess(PID_TCODE, ObjectProcess, &_ctx->op, sizeof(_ctx->op));
+
+ if (bWait)
+ CORO_INVOKE_2(WaitInterpret, _ctx->pProc, result);
+ else if (result)
+ *result = false;
+
+ CORO_END_CODE;
+}
+
} // End of namespace Tinsel
diff --git a/engines/tinsel/dialogs.h b/engines/tinsel/dialogs.h
index 47f831869f..d6a4154098 100644
--- a/engines/tinsel/dialogs.h
+++ b/engines/tinsel/dialogs.h
@@ -27,13 +27,21 @@
#include "tinsel/dw.h"
#include "tinsel/events.h" // for PLR_EVENT, PLR_EVENT
+#include "tinsel/object.h"
+#include "tinsel/rince.h"
namespace Common {
class Serializer;
+struct KeyState;
}
namespace Tinsel {
+struct OBJECT;
+struct FREEL;
+struct FILM;
+struct CONFINIT;
+
enum {
INV_OPEN = -1, // DW1 only
INV_CONV = 0,
@@ -48,119 +56,500 @@ enum {
INV_DEFAULT = 6
};
-/** structure of each inventory object */
-struct INV_OBJECT {
- int32 id; // inventory objects id
- SCNHANDLE hIconFilm; // inventory objects animation film
- SCNHANDLE hScript; // inventory objects event handling script
- int32 attribute; // inventory object's attribute
+enum {
+ NOOBJECT = -1,
+ INV_NOICON = -1,
+ INV_CLOSEICON = -2,
+ INV_OPENICON = -3,
+ INV_HELDNOTIN = -4
};
-// attribute values - not a bit bit field to prevent portability problems
-#define DROPCODE 0x01
-#define ONLYINV1 0x02
-#define ONLYINV2 0x04
-#define DEFINV1 0x08
-#define DEFINV2 0x10
-#define PERMACONV 0x20
-#define CONVENDITEM 0x40
-
-void PopUpInventory(int invno);
-
-enum CONFTYPE {
- MAIN_MENU, SAVE_MENU, LOAD_MENU, QUIT_MENU, RESTART_MENU, SOUND_MENU,
- CONTROLS_MENU, SUBTITLES_MENU, HOPPER_MENU1, HOPPER_MENU2, TOP_WINDOW
+enum CONV_PARAM {
+ CONV_DEF,
+ CONV_BOTTOM,
+ CONV_END,
+ CONV_TOP
};
-void OpenMenu(CONFTYPE type);
+enum InventoryType { EMPTY,
+ FULL,
+ CONF };
+enum InvCursorFN { IC_AREA,
+ IC_DROP };
-void Xmovement(int x);
-void Ymovement(int y);
+// attribute values - not a bit bit field to prevent portability problems
+#define DROPCODE 0x01
+#define ONLYINV1 0x02
+#define ONLYINV2 0x04
+#define DEFINV1 0x08
+#define DEFINV2 0x10
+#define PERMACONV 0x20
+#define CONVENDITEM 0x40
+#define sliderRange (g_sliderYmax - g_sliderYmin)
+#define MAXSLIDES 4
+#define MAX_PERMICONS 10 // Max permanent conversation icons
+#define MAXHICONS 10 // Max dimensions of
+#define MAXVICONS 6 // an inventory window
+#define SG_DESC_LEN 40 // Max. saved game description length
+
+// Number of objects that makes up an empty window
+#define MAX_WCOMP 21 // 4 corners + (3+3) sides + (2+2) extra sides \
+ // + Bground + title + slider \
+ // + more Needed for save game window
+
+#define MAX_ICONS MAXHICONS *MAXVICONS
+#define MAX_ININV_TOT 160
-void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds);
-void ButtonToInventory(PLR_EVENT be);
-void KeyToInventory(PLR_EVENT ke);
+enum CONFTYPE {
+ MAIN_MENU,
+ SAVE_MENU,
+ LOAD_MENU,
+ QUIT_MENU,
+ RESTART_MENU,
+ SOUND_MENU,
+ CONTROLS_MENU,
+ SUBTITLES_MENU,
+ HOPPER_MENU1,
+ HOPPER_MENU2,
+ TOP_WINDOW
+};
+
+/** structure of each inventory object */
+struct INV_OBJECT {
+ int32 id; // inventory objects id
+ SCNHANDLE hIconFilm; // inventory objects animation film
+ SCNHANDLE hScript; // inventory objects event handling script
+ int32 attribute; // inventory object's attribute
+};
+struct INV_DEF {
+ int MinHicons; // }
+ int MinVicons; // } Dimension limits
+ int MaxHicons; // }
+ int MaxVicons; // }
-int WhichItemHeld();
+ int NoofHicons; // }
+ int NoofVicons; // } Current dimentsions
-void HoldItem(int item, bool bKeepFilm = false);
-void DropItem(int item);
-void ClearInventory(int invno);
-void AddToInventory(int invno, int icon, bool hold = false);
-bool RemFromInventory(int invno, int icon);
+ int contents[160]; // Contained items
+ int NoofItems; // Current number of held items
+ int FirstDisp; // Index to first item currently displayed
-void RegisterIcons(void *cptr, int num);
+ int inventoryX; // } Display position
+ int inventoryY; // }
+ int otherX; // } Display position
+ int otherY; // }
-void idec_convw(SCNHANDLE text, int MaxContents, int MinWidth, int MinHeight,
- int StartWidth, int StartHeight, int MaxWidth, int MaxHeight);
-void idec_inv1(SCNHANDLE text, int MaxContents, int MinWidth, int MinHeight,
- int StartWidth, int StartHeight, int MaxWidth, int MaxHeight);
-void idec_inv2(SCNHANDLE text, int MaxContents, int MinWidth, int MinHeight,
- int StartWidth, int StartHeight, int MaxWidth, int MaxHeight);
+ int MaxInvObj; // Max. allowed contents
-bool InventoryActive();
+ SCNHANDLE hInvTitle; // Window heading
-void PermaConvIcon(int icon, bool bEnd = false);
+ bool resizable; // Re-sizable window?
+ bool bMoveable; // Moveable window?
-void convPos(int bpos);
-void ConvPoly(HPOLYGON hp);
-int GetIcon();
-void CloseDownConv();
-void HideConversation(bool hide);
-bool ConvIsHidden();
+ int sNoofHicons; // }
+ int sNoofVicons; // } Current dimensions
-enum {
- NOOBJECT = -1,
- INV_NOICON = -1,
- INV_CLOSEICON = -2,
- INV_OPENICON = -3,
- INV_HELDNOTIN = -4
+ bool bMax; // Maximised last time open?
};
-enum CONV_PARAM {
- CONV_DEF,
- CONV_BOTTOM,
- CONV_END,
- CONV_TOP
+//----- Data pertinant to scene hoppers ------------------------
+
+#include "common/pack-start.h" // START STRUCT PACKING
+
+struct HOPPER {
+ uint32 hScene;
+ SCNHANDLE hSceneDesc;
+ uint32 numEntries;
+ uint32 entryIndex;
+} PACKED_STRUCT;
+typedef HOPPER *PHOPPER;
+
+struct HOPENTRY {
+ uint32 eNumber; // entrance number
+ SCNHANDLE hDesc; // handle to entrance description
+ uint32 flags;
+} PACKED_STRUCT;
+typedef HOPENTRY *PHOPENTRY;
+
+#include "common/pack-end.h" // END STRUCT PACKING
+
+enum BTYPE {
+ RGROUP, ///< Radio button group - 1 is selectable at a time. Action on double click
+ ARSBUT, ///< Action if a radio button is selected
+ AABUT, ///< Action always
+ AATBUT, ///< Action always, text box
+ ARSGBUT,
+ AAGBUT, ///< Action always, graphic button
+ SLIDER, ///< Not a button at all
+ TOGGLE, ///< Discworld 1 toggle
+ TOGGLE1, ///< Discworld 2 toggle type 1
+ TOGGLE2, ///< Discworld 2 toggle type 2
+ DCTEST,
+ FLIP,
+ FRGROUP,
+ ROTATE,
+ NOTHING
};
+enum BFUNC {
+ NOFUNC,
+ SAVEGAME,
+ LOADGAME,
+ IQUITGAME,
+ CLOSEWIN,
+ OPENLOAD,
+ OPENSAVE,
+ OPENREST,
+ OPENSOUND,
+ OPENCONT,
+#ifndef JAPAN
+ OPENSUBT,
+#endif
+ OPENQUIT,
+ INITGAME,
+ MUSICVOL,
+
+ HOPPER2, // Call up Scene Hopper 2
+ BF_CHANGESCENE,
+
+ CLANG,
+ RLANG
+#ifdef MAC_OPTIONS
+ ,
+ MASTERVOL,
+ SAMPVOL
+#endif
+};
-void ConvAction(int index);
-void SetConvDetails(CONV_PARAM fn, HPOLYGON hPoly, int ano);
-void InventoryIconCursor(bool bNewItem);
-
-void setInvWinParts(SCNHANDLE hf);
-void setFlagFilms(SCNHANDLE hf);
-void setConfigStrings(SCNHANDLE *tp);
-
-int InvItem(int *x, int *y, bool update);
-int InvItemId(int x, int y);
-
-int InventoryPos(int num);
-
-bool IsInInventory(int object, int invnum);
-
-void KillInventory();
-
-void syncInvInfo(Common::Serializer &s);
-
-int InvGetLimit(int invno);
-void InvSetLimit(int invno, int n);
-void InvSetSize(int invno, int MinWidth, int MinHeight,
- int StartWidth, int StartHeight, int MaxWidth, int MaxHeight);
-
-bool GetIsInvObject(int id);
+enum TM { TM_POINTER,
+ TM_INDEX,
+ TM_STRINGNUM,
+ TM_NONE };
+
+// For SlideSlider() and similar
+enum SSFN {
+ S_START,
+ S_SLIDE,
+ S_END,
+ S_TIMEUP,
+ S_TIMEDN
+};
-int WhichInventoryOpen();
+struct CONFBOX {
+ BTYPE boxType;
+ BFUNC boxFunc;
+ TM textMethod;
+
+ char *boxText;
+ int ixText;
+ int xpos;
+ int ypos;
+ int w; // Doubles as max value for SLIDERs
+ int h; // Doubles as iteration size for SLIDERs
+ int *ival;
+ int bi; // Base index for AAGBUTs
+};
-bool IsTopWindow();
-bool MenuActive();
-bool IsConvWindow();
+// Data for button press/toggle effects
+struct {
+ bool bButAnim;
+ CONFBOX *box;
+ bool press; // true = button press; false = button toggle
+} g_buttonEffect;
+
+class Dialogs {
+public:
+ Dialogs();
+ virtual ~Dialogs();
-void SetObjectFilm(int object, SCNHANDLE hFilm);
+ void PopUpInventory(int invno);
+ void OpenMenu(CONFTYPE type);
+
+ void Xmovement(int x);
+ void Ymovement(int y);
+
+ void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds);
+
+ int WhichItemHeld();
+
+ void HoldItem(int item, bool bKeepFilm = false);
+ void DropItem(int item);
+ void ClearInventory(int invno);
+ void AddToInventory(int invno, int icon, bool hold = false);
+ bool RemFromInventory(int invno, int icon);
+
+ void RegisterIcons(void *cptr, int num);
+
+ void idec_convw(SCNHANDLE text, int MaxContents, int MinWidth, int MinHeight,
+ int StartWidth, int StartHeight, int MaxWidth, int MaxHeight);
+ void idec_inv1(SCNHANDLE text, int MaxContents, int MinWidth, int MinHeight,
+ int StartWidth, int StartHeight, int MaxWidth, int MaxHeight);
+ void idec_inv2(SCNHANDLE text, int MaxContents, int MinWidth, int MinHeight,
+ int StartWidth, int StartHeight, int MaxWidth, int MaxHeight);
+
+ bool InventoryActive();
+
+ void PermaConvIcon(int icon, bool bEnd = false);
+
+ void convPos(int bpos);
+ void ConvPoly(HPOLYGON hp);
+ int GetIcon();
+ void CloseDownConv();
+ void HideConversation(bool hide);
+ bool ConvIsHidden();
+
+ void ConvAction(int index);
+ void SetConvDetails(CONV_PARAM fn, HPOLYGON hPoly, int ano);
+ void InventoryIconCursor(bool bNewItem);
+
+ void setInvWinParts(SCNHANDLE hf);
+ void setFlagFilms(SCNHANDLE hf);
+ void setConfigStrings(SCNHANDLE *tp);
+
+ int InvItem(Common::Point &coOrds, bool update);
+ int InvItem(int *x, int *y, bool update);
+ int InvItemId(int x, int y);
+
+ int InventoryPos(int num);
+
+ bool IsInInventory(int object, int invnum);
+
+ void KillInventory();
+
+ void syncInvInfo(Common::Serializer &s);
+
+ int InvGetLimit(int invno);
+ void InvSetLimit(int invno, int n);
+ void InvSetSize(int invno, int MinWidth, int MinHeight,
+ int StartWidth, int StartHeight, int MaxWidth, int MaxHeight);
+
+ bool GetIsInvObject(int id);
+
+ int WhichInventoryOpen();
+
+ bool IsTopWindow();
+ bool MenuActive();
+ bool IsConvWindow();
+
+ void SetObjectFilm(int object, SCNHANDLE hFilm);
+ void CallFunction(BFUNC boxFunc);
+
+ OBJECT *AddObject(const FREEL *pfreel, int num);
+ void InvPutDown(int index);
+ void SlideMSlider(int x, SSFN fn);
+ void AddBoxes(bool posnSlide);
+ void Select(int i, bool force);
+ void FillInInventory();
+ void InvCursor(InvCursorFN fn, int CurX, int CurY);
+ INV_OBJECT *GetInvObject(int id);
+ bool UpdateString(const Common::KeyState &kbd);
+ bool InventoryIsActive() { return g_InventoryState == ACTIVE_INV; }
+ bool IsMixingDeskControl() { return g_InvDragging == ID_MDCONT; }
+ int CurrentInventoryX() { return g_InvD[g_ino].inventoryX; }
+ int CurrentInventoryY() { return g_InvD[g_ino].inventoryY; }
+ bool ConfigurationIsActive() { return g_ino == INV_CONF; }
+ bool DisplayObjectsActive() { return g_objArray[0] != NULL; }
+ bool InventoryIsHidden() { return g_InventoryHidden; }
+ const FILM *GetWindowData();
+ void Redraw();
+
+ bool g_bNoLanguage;
+ int g_GlitterIndex;
+ volatile int g_PointedWaitCount; // used by ObjectProcess - fix the 'repeated pressing bug'
+ // For editing save game names
+ char g_sedit[SG_DESC_LEN + 2];
+
+ OBJECT *g_iconArray[MAX_ICONS]; // Current display objects (icons)
+
+private:
+ int WhichMenuBox(int curX, int curY, bool bSlides);
+ void ConfActionSpecial(int i);
+ bool RePosition();
+ bool LanguageChange();
+ void PrimeSceneHopper();
+ void FreeSceneHopper();
+ void RememberChosenScene();
+ void SetChosenScene();
+ void FirstEntry(int first);
+ void HopAction();
+ void DumpIconArray();
+ void DumpDobjArray();
+ void DumpObjArray();
+ void FirstScene(int first);
+ void FirstFile(int first);
+ int GetObjectIndex(int id);
+ void InvSaveGame();
+ void InvLoadGame();
+ int InvArea(int x, int y);
+ void InvBoxes(bool InBody, int curX, int curY);
+ void InvLabels(bool InBody, int aniX, int aniY);
+ void AdjustTop();
+ OBJECT *AddInvObject(int num, const FREEL **pfreel, const FILM **pfilm);
+ void AddBackground(OBJECT **rect, OBJECT **title, int extraH, int extraV, int textFrom);
+ void AddBackground(OBJECT **rect, int extraH, int extraV);
+ void AddTitle(POBJECT *title, int extraH);
+ void AddSlider(OBJECT **slide, const FILM *pfilm);
+ void AddBox(int *pi, const int i);
+ void AddEWSlider(OBJECT **slide, const FILM *pfilm);
+ int AddExtraWindow(int x, int y, OBJECT **retObj);
+ void ConstructInventory(InventoryType filling);
+ void AlterCursor(int num);
+ void SetMenuGlobals(CONFINIT *ci);
+ void CloseInventory();
+ int NearestSlideY(int fity);
+ void SlideSlider(int y, SSFN fn);
+ void SlideCSlider(int y, SSFN fn);
+ void GettingTaller();
+ void GettingShorter();
+ void GettingWider();
+ void GettingNarrower();
+ void ChangeingSize();
+ void InvDragStart();
+ void InvDragEnd();
+ bool MenuDown(int lines);
+ bool MenuUp(int lines);
+ void MenuRollDown();
+ void MenuRollUp();
+ void MenuPageDown();
+ void MenuPageUp();
+ void InventoryDown();
+ void InventoryUp();
+ void MenuAction(int i, bool dbl);
+ void InvPickup(int index);
+ void InvWalkTo(const Common::Point &coOrds);
+ void InvAction();
+ void InvLook(const Common::Point &coOrds);
+ void idec_inv(int num, SCNHANDLE text, int MaxContents,
+ int MinWidth, int MinHeight,
+ int StartWidth, int StartHeight,
+ int MaxWidth, int MaxHeight,
+ int startx, int starty, bool moveable);
+
+ //----- Permanent data (set once) -----
+ SCNHANDLE g_flagFilm; // Window members and cursors' graphic data
+ SCNHANDLE g_configStrings[20];
+
+ INV_DEF g_InvD[NUM_INV]; // Conversation + 2 inventories + ...
+ int g_ino; // Which inventory is currently active
+ INV_OBJECT *g_invObjects; // Inventory objects' data
+ int g_numObjects; // Number of inventory objects
+ SCNHANDLE *g_invFilms;
+ DIRECTION g_initialDirection;
+
+ //----- Permanent data (updated, valid while inventory closed) -----
+ int g_heldItem = INV_NOICON; // Current held item
+
+ SCNHANDLE g_heldFilm;
+ SCNHANDLE g_hWinParts; // Window members and cursors' graphic data
+
+ // Permanent contents of conversation inventory
+ int g_permIcons[MAX_PERMICONS]; // Basic items i.e. permanent contents
+ int g_numPermIcons; // - copy to conv. inventory at pop-up time
+ int g_numEndIcons;
+
+ //----- Data pertinant to current active inventory -----
+
+ bool g_InventoryHidden;
+ bool g_InventoryMaximised;
+ bool g_ItemsChanged; // When set, causes items to be re-drawn
+
+ int g_SuppH; // 'Linear' element of
+ int g_SuppV; // dimensions during re-sizing
+
+ int g_Ychange; //
+ int g_Ycompensate; // All to do with re-sizing.
+ int g_Xchange; //
+ int g_Xcompensate; //
+
+ bool g_bReOpenMenu;
+
+ int g_TL, g_TR, g_BL, g_BR; // Used during window construction
+ int g_TLwidth, g_TLheight; //
+ int g_TRwidth; //
+ int g_BLheight; //
+
+ LANGUAGE g_displayedLanguage;
+
+ OBJECT *g_objArray[MAX_WCOMP]; // Current display objects (window)
+ OBJECT *g_DobjArray[MAX_WCOMP]; // Current display objects (re-sizing window)
+ ANIM g_iconAnims[MAX_ICONS];
+
+ OBJECT *g_RectObject, *g_SlideObject; // Current display objects, for reference
+ // objects are in objArray.
+
+ int g_sliderYpos; // For positioning the slider
+ int g_sliderYmax, g_sliderYmin; //
+
+ // Also to do with the slider
+ struct {
+ int n;
+ int y;
+ } g_slideStuff[MAX_ININV_TOT + 1];
+
+ struct MDSLIDES {
+ int num;
+ OBJECT *obj;
+ int min, max;
+ };
+ MDSLIDES g_mdSlides[MAXSLIDES];
+ int g_numMdSlides;
+
+ // Icon clicked on to cause an event
+ // - Passed to conversation polygon or actor code via Topic()
+ // - (sometimes) Passed to inventory icon code via OtherObject()
+ int g_thisIcon = 0;
+
+ CONV_PARAM g_thisConvFn; // Top, 'Middle' or Bottom
+ HPOLYGON g_thisConvPoly; // Conversation code is in a polygon code block
+ int g_thisConvActor; // ...or an actor's code block.
+ int g_pointedIcon; // used by InvLabels - icon pointed to on last call
+ int g_sX; // used by SlideMSlider() - current x-coordinate
+ int g_lX; // used by SlideMSlider() - last x-coordinate
+
+ bool g_bMoveOnUnHide; // Set before start of conversation
+ // - causes conversation to be started in a sensible place
+
+ PHOPPER g_pHopper;
+ PHOPENTRY g_pEntries;
+ int g_numScenes;
+
+ int g_numEntries;
+
+ PHOPPER g_pChosenScene;
+
+ int g_lastChosenScene;
+ bool g_bRemember;
+ enum { IC_NORMAL,
+ IC_DR,
+ IC_UR,
+ IC_TB,
+ IC_LR,
+ IC_INV,
+ IC_UP,
+ IC_DN } ICursor = IC_NORMAL;
+
+ enum { NO_INV,
+ IDLE_INV,
+ ACTIVE_INV,
+ BOGUS_INV } g_InventoryState;
+
+ enum { ID_NONE,
+ ID_MOVE,
+ ID_SLIDE,
+ ID_BOTTOM,
+ ID_TOP,
+ ID_LEFT,
+ ID_RIGHT,
+ ID_TLEFT,
+ ID_TRIGHT,
+ ID_BLEFT,
+ ID_BRIGHT,
+ ID_CSLIDE,
+ ID_MDCONT } g_InvDragging;
+};
void ObjectEvent(CORO_PARAM, int objId, TINSEL_EVENT event, bool bWait, int myEscape, bool *result = NULL);
diff --git a/engines/tinsel/events.cpp b/engines/tinsel/events.cpp
index 86a6c6f83a..9c526f199e 100644
--- a/engines/tinsel/events.cpp
+++ b/engines/tinsel/events.cpp
@@ -160,7 +160,7 @@ void ControlOn() {
_vm->_cursor->UnHideCursor();
// Turn tags back on
- if (!InventoryActive())
+ if (!_vm->_dialogs->InventoryActive())
EnableTags();
}
}
@@ -433,32 +433,32 @@ void PlayerEvent(PLR_EVENT pEvent, const Common::Point &coOrds) {
if (!ControlIsOn() && (pEvent != PLR_DRAG1_END))
return;
- if (TinselV2 && InventoryActive()) {
+ if (TinselV2 && _vm->_dialogs->InventoryActive()) {
int x, y;
_vm->_bg->PlayfieldGetPos(FIELD_WORLD, &x, &y);
- EventToInventory(pEvent, Common::Point(coOrds.x - x, coOrds.y - y));
+ _vm->_dialogs->EventToInventory(pEvent, Common::Point(coOrds.x - x, coOrds.y - y));
return;
}
switch (pEvent) {
case PLR_QUIT:
- OpenMenu(QUIT_MENU);
+ _vm->_dialogs->OpenMenu(QUIT_MENU);
break;
case PLR_MENU:
- OpenMenu(MAIN_MENU);
+ _vm->_dialogs->OpenMenu(MAIN_MENU);
break;
case PLR_JUMP:
- OpenMenu(HOPPER_MENU1);
+ _vm->_dialogs->OpenMenu(HOPPER_MENU1);
break;
case PLR_SAVE:
- OpenMenu(SAVE_MENU);
+ _vm->_dialogs->OpenMenu(SAVE_MENU);
break;
case PLR_LOAD:
- OpenMenu(LOAD_MENU);
+ _vm->_dialogs->OpenMenu(LOAD_MENU);
break;
case PLR_PROV_WALKTO: // Provisional WALKTO !
@@ -468,33 +468,33 @@ void PlayerEvent(PLR_EVENT pEvent, const Common::Point &coOrds) {
case PLR_WALKTO:
REAL_ACTION_CHECK;
- if (TinselV2 || !InventoryActive())
+ if (TinselV2 || !_vm->_dialogs->InventoryActive())
ProcessUserEvent(WALKTO, coOrds, PLR_SLEFT);
else
- EventToInventory(PLR_SLEFT, coOrds);
+ _vm->_dialogs->EventToInventory(PLR_SLEFT, coOrds);
break;
case PLR_ACTION:
REAL_ACTION_CHECK;
- if (TinselV2 || !InventoryActive())
+ if (TinselV2 || !_vm->_dialogs->InventoryActive())
ProcessUserEvent(ACTION, coOrds, PLR_DLEFT);
else
- EventToInventory(PLR_DLEFT, coOrds);
+ _vm->_dialogs->EventToInventory(PLR_DLEFT, coOrds);
break;
case PLR_LOOK:
REAL_ACTION_CHECK;
- if (TinselV2 || !InventoryActive())
+ if (TinselV2 || !_vm->_dialogs->InventoryActive())
ProcessUserEvent(LOOK, coOrds, PLR_SRIGHT);
else
- EventToInventory(PLR_SRIGHT, coOrds);
+ _vm->_dialogs->EventToInventory(PLR_SRIGHT, coOrds);
break;
default:
- if (InventoryActive())
- EventToInventory(pEvent, coOrds);
+ if (_vm->_dialogs->InventoryActive())
+ _vm->_dialogs->EventToInventory(pEvent, coOrds);
break;
}
}
@@ -567,7 +567,7 @@ void PolyTinselProcess(CORO_PARAM, const void *param) {
// Take control for CONVERSE events
if (to->event == CONVERSE) {
_ctx->bTookControl = GetControl();
- HideConversation(true);
+ _vm->_dialogs->HideConversation(true);
} else
_ctx->bTookControl = false;
@@ -579,7 +579,7 @@ void PolyTinselProcess(CORO_PARAM, const void *param) {
if (_ctx->bTookControl)
ControlOn();
- HideConversation(false);
+ _vm->_dialogs->HideConversation(false);
}
} else {
@@ -599,7 +599,7 @@ void PolyTinselProcess(CORO_PARAM, const void *param) {
// Hide conversation if appropriate
if (to->event == CONVERSE)
- HideConversation(true);
+ _vm->_dialogs->HideConversation(true);
// Run the code
_ctx->pic = InitInterpretContext(GS_POLYGON, GetPolyScript(to->hPoly), to->event, to->hPoly, to->actor, NULL);
@@ -611,7 +611,7 @@ void PolyTinselProcess(CORO_PARAM, const void *param) {
// Restore conv window if applicable
if (to->event == CONVERSE)
- HideConversation(false);
+ _vm->_dialogs->HideConversation(false);
}
CORO_END_CODE;
diff --git a/engines/tinsel/saveload.cpp b/engines/tinsel/saveload.cpp
index f8cf6d8283..f81170ff96 100644
--- a/engines/tinsel/saveload.cpp
+++ b/engines/tinsel/saveload.cpp
@@ -458,25 +458,25 @@ static bool DoSync(Common::Serializer &s, int numInterp) {
}
if (TinselV2 && s.isLoading())
- HoldItem(INV_NOICON);
+ _vm->_dialogs->HoldItem(INV_NOICON);
syncSavedData(s, *g_srsd, numInterp);
syncGlobInfo(s); // Glitter globals
- syncInvInfo(s); // Inventory data
+ _vm->_dialogs->syncInvInfo(s); // Inventory data
// Held object
if (s.isSaving())
- sg = WhichItemHeld();
+ sg = _vm->_dialogs->WhichItemHeld();
s.syncAsSint32LE(sg);
if (s.isLoading()) {
- if (sg != -1 && !GetIsInvObject(sg))
+ if (sg != -1 && !_vm->_dialogs->GetIsInvObject(sg))
// Not a valid inventory object, so return false
return false;
if (TinselV2)
g_thingHeld = sg;
else
- HoldItem(sg);
+ _vm->_dialogs->HoldItem(sg);
}
syncTimerInfo(s); // Timer data
diff --git a/engines/tinsel/savescn.cpp b/engines/tinsel/savescn.cpp
index 4ad4af1d54..258df34dc8 100644
--- a/engines/tinsel/savescn.cpp
+++ b/engines/tinsel/savescn.cpp
@@ -386,7 +386,7 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {
return n;
if (sd == &g_sgData)
- HoldItem(g_thingHeld, true);
+ _vm->_dialogs->HoldItem(g_thingHeld, true);
if (sd->bTinselDim)
_vm->_pcmMusic->dim(true);
_vm->_pcmMusic->restoreThatTune(sd->SavedTune);
@@ -412,7 +412,7 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {
* @param num num
*/
void RestoreGame(int num) {
- KillInventory();
+ _vm->_dialogs->KillInventory();
RequestRestoreGame(num, &g_sgData, &g_savedSceneCount, g_ssData);
diff --git a/engines/tinsel/savescn.h b/engines/tinsel/savescn.h
index b4f74b173a..794d504cf7 100644
--- a/engines/tinsel/savescn.h
+++ b/engines/tinsel/savescn.h
@@ -35,10 +35,8 @@
namespace Tinsel {
-enum {
- SG_DESC_LEN = 40, // Max. saved game description length
- MAX_SAVED_FILES = 100
-};
+#define SG_DESC_LEN 40 // Max. saved game description length
+#define MAX_SAVED_FILES 100
struct SAVED_DATA {
SCNHANDLE SavedSceneHandle; // Scene handle
diff --git a/engines/tinsel/scene.cpp b/engines/tinsel/scene.cpp
index 2c6005cbbc..1dd90d50a6 100644
--- a/engines/tinsel/scene.cpp
+++ b/engines/tinsel/scene.cpp
@@ -319,7 +319,7 @@ void EndScene() {
g_SceneHandle = 0;
}
- KillInventory(); // Close down any open inventory
+ _vm->_dialogs->KillInventory(); // Close down any open inventory
DropPolygons(); // No polygons
_vm->_scroll->DropScroll(); // No no-scrolls
diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp
index c5b096f34f..c4238d4574 100644
--- a/engines/tinsel/tinlib.cpp
+++ b/engines/tinsel/tinlib.cpp
@@ -614,7 +614,7 @@ static void ActorsOn() {
* Adds an icon to the conversation window.
*/
static void AddTopic(int icon) {
- AddToInventory(INV_CONV, icon, false);
+ _vm->_dialogs->AddToInventory(INV_CONV, icon, false);
}
/**
@@ -624,7 +624,7 @@ static void AddInv(int invno, int object) {
// illegal inventory number
assert(invno == INV_1 || invno == INV_2 || invno == INV_OPEN || invno == INV_DEFAULT);
- AddToInventory(invno, object, false);
+ _vm->_dialogs->AddToInventory(invno, object, false);
}
/**
@@ -736,7 +736,7 @@ static void ClearHookScene() {
* Guess what.
*/
static void CloseInventory() {
- KillInventory();
+ _vm->_dialogs->KillInventory();
}
/**
@@ -750,11 +750,11 @@ void Control(int param) {
else {
ControlOff();
- switch (WhichInventoryOpen()) {
+ switch (_vm->_dialogs->WhichInventoryOpen()) {
case INV_1:
case INV_2:
case INV_MENU:
- KillInventory();
+ _vm->_dialogs->KillInventory();
break;
default:
break;
@@ -810,7 +810,7 @@ void Control(int param) {
FreeControlToken(); // Release control
- if (!InventoryActive())
+ if (!_vm->_dialogs->InventoryActive())
EnableTags(); // Tags back on
_vm->_cursor->RestoreMainCursor(); // Re-instate cursor...
@@ -833,7 +833,7 @@ static void Conversation(CORO_PARAM, int fn, HPOLYGON hp, int actor, bool escOn,
if (fn == CONV_END) {
// Close down conversation
- CloseDownConv();
+ _vm->_dialogs->CloseDownConv();
} else if ((fn == CONV_TOP) || (fn == CONV_DEF) || (fn == CONV_BOTTOM)) {
// TOP of screen, Default (i.e. TOP of screen), or BOTTOM of screen
@@ -846,10 +846,10 @@ static void Conversation(CORO_PARAM, int fn, HPOLYGON hp, int actor, bool escOn,
return;
// Don't do it if already in a conversation
- if (IsConvWindow())
+ if (_vm->_dialogs->IsConvWindow())
return;
- KillInventory();
+ _vm->_dialogs->KillInventory();
if (TinselV2) {
// If this is from a tag polygon, get the associated
@@ -863,14 +863,14 @@ static void Conversation(CORO_PARAM, int fn, HPOLYGON hp, int actor, bool escOn,
}
// Top or bottom; tag polygon or tagged actor
- SetConvDetails((CONV_PARAM)fn, hp, actor);
+ _vm->_dialogs->SetConvDetails((CONV_PARAM)fn, hp, actor);
} else {
- convPos(fn);
- ConvPoly(hp);
+ _vm->_dialogs->convPos(fn);
+ _vm->_dialogs->ConvPoly(hp);
}
- PopUpInventory(INV_CONV); // Conversation window
- ConvAction(INV_OPENICON); // CONVERSATION event
+ _vm->_dialogs->PopUpInventory(INV_CONV); // Conversation window
+ _vm->_dialogs->ConvAction(INV_OPENICON); // CONVERSATION event
}
CORO_END_CODE;
@@ -880,7 +880,7 @@ static void Conversation(CORO_PARAM, int fn, HPOLYGON hp, int actor, bool escOn,
* Add icon to conversation window's permanent default list.
*/
static void ConvTopic(int icon) {
- PermaConvIcon(icon);
+ _vm->_dialogs->PermaConvIcon(icon);
}
/**
@@ -911,7 +911,7 @@ static int CursorPos(int xory) {
*/
static void DecConvW(SCNHANDLE text, int MaxContents, int MinWidth, int MinHeight,
int StartWidth, int StartHeight, int MaxWidth, int MaxHeight) {
- idec_convw(text, MaxContents, MinWidth, MinHeight,
+ _vm->_dialogs->idec_convw(text, MaxContents, MinWidth, MinHeight,
StartWidth, StartHeight, MaxWidth, MaxHeight);
}
@@ -919,7 +919,7 @@ static void DecConvW(SCNHANDLE text, int MaxContents, int MinWidth, int MinHeigh
* Declare config strings.
*/
static void DecCStrings(SCNHANDLE *tp) {
- setConfigStrings(tp);
+ _vm->_dialogs->setConfigStrings(tp);
}
/**
@@ -933,7 +933,7 @@ static void DecCursor(SCNHANDLE hFilm) {
* Declare the language flags.
*/
static void DecFlags(SCNHANDLE hFilm) {
- setFlagFilms(hFilm);
+ _vm->_dialogs->setFlagFilms(hFilm);
}
/**
@@ -943,7 +943,7 @@ static void DecInv1(SCNHANDLE text, int MaxContents,
int MinWidth, int MinHeight,
int StartWidth, int StartHeight,
int MaxWidth, int MaxHeight) {
- idec_inv1(text, MaxContents, MinWidth, MinHeight,
+ _vm->_dialogs->idec_inv1(text, MaxContents, MinWidth, MinHeight,
StartWidth, StartHeight, MaxWidth, MaxHeight);
}
@@ -954,7 +954,7 @@ static void DecInv2(SCNHANDLE text, int MaxContents,
int MinWidth, int MinHeight,
int StartWidth, int StartHeight,
int MaxWidth, int MaxHeight) {
- idec_inv2(text, MaxContents, MinWidth, MinHeight,
+ _vm->_dialogs->idec_inv2(text, MaxContents, MinWidth, MinHeight,
StartWidth, StartHeight, MaxWidth, MaxHeight);
}
@@ -962,7 +962,7 @@ static void DecInv2(SCNHANDLE text, int MaxContents,
* Declare the bits that the inventory windows are constructed from.
*/
static void DecInvW(SCNHANDLE hf) {
- setInvWinParts(hf);
+ _vm->_dialogs->setInvWinParts(hf);
}
/**
@@ -1037,24 +1037,24 @@ static void DecScale(int actor, int scale,
* Remove an icon from the conversation window.
*/
static void DelIcon(int icon) {
- RemFromInventory(INV_CONV, icon);
+ _vm->_dialogs->RemFromInventory(INV_CONV, icon);
}
/**
* Delete the object from inventory 1 or 2.
*/
static void DelInv(int object) {
- if (!RemFromInventory(INV_1, object)) // Remove from inventory 1...
- RemFromInventory(INV_2, object); // ...or 2 (whichever)
+ if (!_vm->_dialogs->RemFromInventory(INV_1, object)) // Remove from inventory 1...
+ _vm->_dialogs->RemFromInventory(INV_2, object); // ...or 2 (whichever)
- DropItem(object); // Stop holding it
+ _vm->_dialogs->DropItem(object); // Stop holding it
}
/**
* DelTopic
*/
static void DelTopic(int icon) {
- RemFromInventory(INV_CONV, icon);
+ _vm->_dialogs->RemFromInventory(INV_CONV, icon);
}
/**
@@ -1064,20 +1064,20 @@ static void Drop(int object) {
if (object == -1)
object = HeldObject();
- if (!RemFromInventory(INV_1, object)) // Remove from inventory 1...
- RemFromInventory(INV_2, object); // ...or 2 (whichever)
+ if (!_vm->_dialogs->RemFromInventory(INV_1, object)) // Remove from inventory 1...
+ _vm->_dialogs->RemFromInventory(INV_2, object); // ...or 2 (whichever)
- DropItem(object); // Stop holding it
+ _vm->_dialogs->DropItem(object); // Stop holding it
}
/**
* Delete all objects from inventory 1 and 2.
*/
static void DropEverything() {
- HoldItem(NOOBJECT, false);
+ _vm->_dialogs->HoldItem(NOOBJECT, false);
- ClearInventory(INV_1);
- ClearInventory(INV_2);
+ _vm->_dialogs->ClearInventory(INV_1);
+ _vm->_dialogs->ClearInventory(INV_2);
}
/**
@@ -1166,7 +1166,7 @@ static void FreezeCursor(bool bFreeze) {
* Guess what.
*/
static int GetInvLimit(int invno) {
- return InvGetLimit(invno);
+ return _vm->_dialogs->InvGetLimit(invno);
}
/**
@@ -1196,14 +1196,14 @@ static bool HasRestarted() {
* See if an object is in the inventory.
*/
int Have(int object) {
- return (InventoryPos(object) != NOOBJECT);
+ return (_vm->_dialogs->InventoryPos(object) != NOOBJECT);
}
/**
* Returns which object is currently held.
*/
static int HeldObject() {
- return WhichItemHeld();
+ return _vm->_dialogs->WhichItemHeld();
}
/**
@@ -1253,7 +1253,7 @@ static void HideTag(CORO_PARAM, int tag, HPOLYGON hp) {
* Hold the specified object.
*/
static void Hold(int object) {
- HoldItem(object, false);
+ _vm->_dialogs->HoldItem(object, false);
}
/**
@@ -1292,14 +1292,14 @@ void InstantScroll(int onoff) {
* invdepict
*/
static void InvDepict(int object, SCNHANDLE hFilm) {
- SetObjectFilm(object, hFilm);
+ _vm->_dialogs->SetObjectFilm(object, hFilm);
}
/**
* See if an object is in the inventory.
*/
int InInventory(int object) {
- return (InventoryPos(object) != INV_NOICON);
+ return (_vm->_dialogs->InventoryPos(object) != INV_NOICON);
}
/**
@@ -1312,27 +1312,27 @@ static void Inventory(int invno, bool escOn, int myEscape) {
assert((invno == INV_1 || invno == INV_2)); // Trying to open illegal inventory
- PopUpInventory(invno);
+ _vm->_dialogs->PopUpInventory(invno);
}
/**
* Alter inventory object's icon.
*/
static void InvPlay(int object, SCNHANDLE hFilm) {
- SetObjectFilm(object, hFilm);
+ _vm->_dialogs->SetObjectFilm(object, hFilm);
}
/**
* See if an object is in the inventory.
*/
static int InWhichInv(int object) {
- if (WhichItemHeld() == object)
+ if (_vm->_dialogs->WhichItemHeld() == object)
return 0;
- if (IsInInventory(object, INV_1))
+ if (_vm->_dialogs->IsInInventory(object, INV_1))
return 1;
- if (IsInInventory(object, INV_2))
+ if (_vm->_dialogs->IsInInventory(object, INV_2))
return 2;
return -1;
@@ -1468,7 +1468,7 @@ static void NoScroll(int x1, int y1, int x2, int y2) {
* Hold the specified object.
*/
static void ObjectHeld(int object) {
- HoldItem(object);
+ _vm->_dialogs->HoldItem(object);
}
/**
@@ -1495,12 +1495,12 @@ int OtherObject(INV_OBJECT *pinvo) {
// WhichItemHeld() gives the held object
// GetIcon() gives the object clicked on
- assert(GetIcon() == pinvo->id || WhichItemHeld() == pinvo->id);
+ assert(_vm->_dialogs->GetIcon() == pinvo->id || _vm->_dialogs->WhichItemHeld() == pinvo->id);
- if (GetIcon() == pinvo->id)
- return WhichItemHeld();
+ if (_vm->_dialogs->GetIcon() == pinvo->id)
+ return _vm->_dialogs->WhichItemHeld();
else
- return GetIcon();
+ return _vm->_dialogs->GetIcon();
}
/**
@@ -1923,7 +1923,7 @@ static void Print(CORO_PARAM, int x, int y, SCNHANDLE text, int time, bool bSust
// Adjust x, y, or z if necessary
KeepOnScreen(_ctx->pText, &x, &y);
- if (IsTopWindow())
+ if (_vm->_dialogs->IsTopWindow())
MultiSetZPosition(_ctx->pText, Z_TOPW_TEXT);
} else if (bJapDoPrintText || (!_vm->_config->isJapanMode() && (_vm->_config->_useSubtitles || !_ctx->bSample))) {
@@ -1933,7 +1933,7 @@ static void Print(CORO_PARAM, int x, int y, SCNHANDLE text, int time, bool bSust
0, x - Loffset, y - Toffset,
TinselV2 ? _vm->_font->GetTagFontHandle() : _vm->_font->GetTalkFontHandle(), TXT_CENTER);
assert(_ctx->pText); // string produced NULL text
- if (IsTopWindow())
+ if (_vm->_dialogs->IsTopWindow())
MultiSetZPosition(_ctx->pText, Z_TOPW_TEXT);
/*
@@ -2053,7 +2053,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
* Find out which icon the cursor is over, and where to put the text.
*/
_vm->_cursor->GetCursorXY(&_ctx->textx, &_ctx->texty, false); // Cursor position..
- _ctx->item = InvItem(&_ctx->textx, &_ctx->texty, true); // ..to text position
+ _ctx->item = _vm->_dialogs->InvItem(&_ctx->textx, &_ctx->texty, true); // ..to text position
if (_ctx->item == INV_NOICON)
return;
@@ -2128,7 +2128,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
int x, y;
do {
// Give up if this item gets picked up
- if (WhichItemHeld() == pinvo->id)
+ if (_vm->_dialogs->WhichItemHeld() == pinvo->id)
break;
// Give way to non-POINTED-generated text
@@ -2141,7 +2141,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
CORO_SLEEP(1);
_vm->_cursor->GetCursorXY(&x, &y, false);
- if (InvItem(&x, &y, false) != _ctx->item)
+ if (_vm->_dialogs->InvItem(&x, &y, false) != _ctx->item)
break;
// Re-display in the same place
@@ -2160,7 +2160,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
// Carry on until the cursor leaves this icon
_vm->_cursor->GetCursorXY(&x, &y, false);
- } while (InvItemId(x, y) == pinvo->id);
+ } while (_vm->_dialogs->InvItemId(x, y) == pinvo->id);
} else {
/*
* PrintObj() called from other event
@@ -2180,8 +2180,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
// Abort if sample times out
// Abort if conversation hidden
if (LeftEventChange(_ctx->myLeftEvent)
- || --_ctx->timeout <= 0
- || ConvIsHidden())
+ || --_ctx->timeout <= 0 || _vm->_dialogs->ConvIsHidden())
break;
if (_ctx->bSample) {
@@ -2246,7 +2245,7 @@ static void PrintObjPointed(CORO_PARAM, const SCNHANDLE text, const INV_OBJECT *
int x, y;
do {
// Give up if this item gets picked up
- if (WhichItemHeld() == pinvo->id)
+ if (_vm->_dialogs->WhichItemHeld() == pinvo->id)
break;
// Give way to non-POINTED-generated text
@@ -2258,7 +2257,7 @@ static void PrintObjPointed(CORO_PARAM, const SCNHANDLE text, const INV_OBJECT *
CORO_SLEEP(1);
_vm->_cursor->GetCursorXY(&x, &y, false);
- if (InvItem(&x, &y, false) != item)
+ if (_vm->_dialogs->InvItem(&x, &y, false) != item)
break;
// Re-display in the same place
@@ -2273,7 +2272,7 @@ static void PrintObjPointed(CORO_PARAM, const SCNHANDLE text, const INV_OBJECT *
// Carry on until the cursor leaves this icon
_vm->_cursor->GetCursorXY(&x, &y, false);
- } while (InvItemId(x, y) == pinvo->id);
+ } while (_vm->_dialogs->InvItemId(x, y) == pinvo->id);
CORO_END_CODE;
}
@@ -2316,7 +2315,7 @@ static void PrintObjNonPointed(CORO_PARAM, const SCNHANDLE text, const OBJECT *p
// Abort if left click - hardwired feature for talky-print!
// Abort if sample times out
// Abort if conversation hidden
- if (_ctx->myleftEvent != GetLeftEvents() || _ctx->timeout <= 0 || ConvIsHidden())
+ if (_ctx->myleftEvent != GetLeftEvents() || _ctx->timeout <= 0 || _vm->_dialogs->ConvIsHidden())
break;
if (_ctx->bSample) {
@@ -2509,7 +2508,7 @@ static void ScalingReels(int actor, int scale, int direction,
* Return the icon that caused the CONVERSE event.
*/
static int ScanIcon() {
- return GetIcon();
+ return _vm->_dialogs->GetIcon();
}
/**
@@ -2662,7 +2661,7 @@ static void SetExit(int exitno) {
* Guess what.
*/
static void SetInvLimit(int invno, int n) {
- InvSetLimit(invno, n);
+ _vm->_dialogs->InvSetLimit(invno, n);
}
/**
@@ -2670,7 +2669,7 @@ static void SetInvLimit(int invno, int n) {
*/
static void SetInvSize(int invno, int MinWidth, int MinHeight,
int StartWidth, int StartHeight, int MaxWidth, int MaxHeight) {
- InvSetSize(invno, MinWidth, MinHeight, StartWidth, StartHeight, MaxWidth, MaxHeight);
+ _vm->_dialogs->InvSetSize(invno, MinWidth, MinHeight, StartWidth, StartHeight, MaxWidth, MaxHeight);
}
/**
@@ -2773,7 +2772,7 @@ static void showstring() {
* Shows the main menu
*/
static void ShowMenu() {
- OpenMenu(MAIN_MENU);
+ _vm->_dialogs->OpenMenu(MAIN_MENU);
}
/**
@@ -3337,7 +3336,7 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
_vm->_font->GetTalkFontHandle(), TXT_CENTER);
assert(_ctx->pText); // talk() string produced NULL text;
- if (IsTopWindow())
+ if (_vm->_dialogs->IsTopWindow())
MultiSetZPosition(_ctx->pText, Z_TOPW_TEXT);
if ((_ctx->whatSort == IS_SAY) || (_ctx->whatSort == IS_TALK)) {
@@ -3613,7 +3612,7 @@ static int TimerFn(int timerno) {
* Return the icon that caused the CONVERSE event.
*/
int Topic() {
- return GetIcon();
+ return _vm->_dialogs->GetIcon();
}
/**
@@ -3632,10 +3631,10 @@ static void TopPlay(CORO_PARAM, SCNHANDLE hFilm, int x, int y, bool bComplete, i
static void TopWindow(int bpos) {
bool isStart = (TinselV2 && (bpos != 0)) || (!TinselV2 && (bpos == TW_START));
- KillInventory();
+ _vm->_dialogs->KillInventory();
if (isStart)
- OpenMenu(TOP_WINDOW);
+ _vm->_dialogs->OpenMenu(TOP_WINDOW);
}
/**
@@ -3733,16 +3732,16 @@ static void WaitKey(CORO_PARAM, bool escOn, int myEscape) {
break;
}
- if (MenuActive())
+ if (_vm->_dialogs->MenuActive())
break;
}
- if (!MenuActive())
+ if (!_vm->_dialogs->MenuActive())
return;
do {
CORO_SLEEP(1);
- } while (MenuActive());
+ } while (_vm->_dialogs->MenuActive());
CORO_SLEEP(ONE_SECOND / 2); // Let it die down
}
@@ -4164,7 +4163,7 @@ int WhichCd() {
* whichinventory
*/
int WhichInventory() {
- return WhichInventoryOpen();
+ return _vm->_dialogs->WhichInventoryOpen();
}
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index c353934e91..2e0a684a73 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -537,8 +537,8 @@ void SetNewScene(SCNHANDLE scene, int entrance, int transition) {
// right items: player must have Mambo the swamp dragon, and mustn't have fireworks (used on
// the swamp dragon previously to "load it up").
if (TinselV1PSX && g_NextScene.scene == 0x1800000 && g_NextScene.entry == 2) {
- if ((IsInInventory(261, INV_1) || IsInInventory(261, INV_2)) &&
- (!IsInInventory(232, INV_1) && !IsInInventory(232, INV_2)))
+ if ((_vm->_dialogs->IsInInventory(261, INV_1) || _vm->_dialogs->IsInInventory(261, INV_2)) &&
+ (!_vm->_dialogs->IsInInventory(232, INV_1) && !_vm->_dialogs->IsInInventory(232, INV_2)))
g_NextScene.entry = 1;
}
}
@@ -752,7 +752,7 @@ void LoadBasicChunks() {
io->attribute = FROM_32(io->attribute);
}
- RegisterIcons(cptr, numObjects);
+ _vm->_dialogs->RegisterIcons(cptr, numObjects);
cptr = FindChunk(MASTER_SCNHANDLE, CHUNK_TOTAL_POLY);
// Max polygons are 0 in DW1 Mac (both in the demo and the full version)
@@ -905,6 +905,7 @@ TinselEngine::~TinselEngine() {
FreeGlobalProcesses();
FreeGlobals();
+ delete _dialogs;
delete _scroll;
delete _handle;
delete _actor;
@@ -967,6 +968,7 @@ Common::Error TinselEngine::run() {
_actor = new Actor();
_handle = new Handle();
_scroll = new Scroll();
+ _dialogs = new Dialogs();
// Initialize backend
if (getGameID() == GID_DW2) {
@@ -1169,7 +1171,7 @@ void TinselEngine::CreateConstProcesses() {
* Restart the game
*/
void TinselEngine::RestartGame() {
- HoldItem(INV_NOICON); // Holding nothing
+ _vm->_dialogs->HoldItem(INV_NOICON); // Holding nothing
_bg->DropBackground(); // No background
diff --git a/engines/tinsel/tinsel.h b/engines/tinsel/tinsel.h
index d780844bb5..f7770cfe1c 100644
--- a/engines/tinsel/tinsel.h
+++ b/engines/tinsel/tinsel.h
@@ -64,6 +64,7 @@ class Cursor;
class Actor;
class Handle;
class Scroll;
+class Dialogs;
typedef Common::List<Common::Rect> RectList;
@@ -175,6 +176,7 @@ public:
Handle *_handle;
Config *_config;
Scroll *_scroll;
+ Dialogs *_dialogs;
KEYFPTR _keyHandler;
Commit: 94997ef7d3abb451714dbba634a46756d4195019
https://github.com/scummvm/scummvm/commit/94997ef7d3abb451714dbba634a46756d4195019
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-10-04T01:15:23+03:00
Commit Message:
TINSEL: Rename variables of the Dialogs class
Changed paths:
engines/tinsel/dialogs.cpp
engines/tinsel/dialogs.h
diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp
index 4751b5a91a..7c82ae6e44 100644
--- a/engines/tinsel/dialogs.cpp
+++ b/engines/tinsel/dialogs.cpp
@@ -748,95 +748,95 @@ static void InvPdProcess(CORO_PARAM, const void *param);
Dialogs::Dialogs() {
g_buttonEffect = {false, 0, false};
- g_hWinParts = 0;
- g_flagFilm = 0;
- memset(g_configStrings, 0, sizeof(g_configStrings));
+ _hWinParts = 0;
+ _flagFilm = 0;
+ memset(_configStrings, 0, sizeof(_configStrings));
- g_invObjects = nullptr;
- g_numObjects = 0;
- g_invFilms = nullptr;
- g_bNoLanguage = false;
+ _invObjects = nullptr;
+ _numObjects = 0;
+ _invFilms = nullptr;
+ _noLanguage = false;
- memset(g_objArray, 0, sizeof(g_objArray));
- memset(g_iconArray, 0, sizeof(g_iconArray));
- memset(g_DobjArray, 0, sizeof(g_DobjArray));
- memset(g_iconAnims, 0, sizeof(g_iconAnims));
- memset(g_permIcons, 0, sizeof(g_permIcons));
- memset(g_InvD, 0, sizeof(g_InvD));
+ memset(_objArray, 0, sizeof(_objArray));
+ memset(_iconArray, 0, sizeof(_iconArray));
+ memset(_dispObjArray, 0, sizeof(_dispObjArray));
+ memset(_iconAnims, 0, sizeof(_iconAnims));
+ memset(_permIcons, 0, sizeof(_permIcons));
+ memset(_invD, 0, sizeof(_invD));
- g_initialDirection = FORWARD;
+ _initialDirection = FORWARD;
- g_heldItem = INV_NOICON;
+ _heldItem = INV_NOICON;
- g_heldFilm = 0;
+ _heldFilm = 0;
- g_numPermIcons = 0;
- g_numEndIcons = 0;
+ _numPermIcons = 0;
+ _numEndIcons = 0;
- g_ino = 0;
+ _activeInv = 0;
- g_InventoryHidden = false;
- g_InventoryMaximised = false;
+ _InventoryHidden = false;
+ _InventoryMaximised = false;
- g_SuppH = 0;
- g_SuppV = 0;
+ _SuppH = 0;
+ _SuppV = 0;
- g_Ychange = 0;
- g_Ycompensate = 0;
- g_Xchange = 0;
- g_Xcompensate = 0;
+ _yChange = 0;
+ _yCompensate = 0;
+ _xChange = 0;
+ _xCompensate = 0;
- g_ItemsChanged = 0;
+ _ItemsChanged = 0;
- g_bReOpenMenu = 0;
+ _reOpenMenu = 0;
- g_TL = g_TR = g_BL = g_BR = 0;
- g_TLwidth = 0, g_TLheight = 0;
- g_TRwidth = 0;
- g_BLheight = 0;
+ _TL = _TR = _BL = _BR = 0;
+ _TLwidth = 0, _TLheight = 0;
+ _TRwidth = 0;
+ _BLheight = 0;
- g_displayedLanguage = TXT_ENGLISH;
+ _displayedLanguage = TXT_ENGLISH;
- g_RectObject = nullptr;
- g_SlideObject = nullptr;
+ _rectObject = nullptr;
+ _slideObject = nullptr;
- g_sliderYpos = 0;
- g_sliderYmax = g_sliderYmin = 0;
+ _sliderYpos = 0;
+ _sliderYmax = _sliderYmin = 0;
- memset(g_mdSlides, 0, sizeof(g_mdSlides));
+ memset(_mdSlides, 0, sizeof(_mdSlides));
- g_numMdSlides = 0;
- g_GlitterIndex = 0;
- g_thisIcon = 0;
+ _numMdSlides = 0;
+ _glitterIndex = 0;
+ _thisIcon = 0;
- memset(&g_thisConvFn, 0, sizeof(g_thisConvFn));
+ memset(&_thisConvFn, 0, sizeof(_thisConvFn));
- g_thisConvPoly = 0;
- g_thisConvActor = 0;
- g_pointedIcon = INV_NOICON;
- g_PointedWaitCount = 0;
- g_sX = 0;
- g_lX = 0;
+ _thisConvPoly = 0;
+ _thisConvActor = 0;
+ _pointedIcon = INV_NOICON;
+ _pointedWaitCount = 0;
+ _sX = 0;
+ _lX = 0;
- g_bMoveOnUnHide = false;
+ _bMoveOnUnHide = false;
- g_pHopper = nullptr;
- g_pEntries = nullptr;
+ _pHopper = nullptr;
+ _pEntries = nullptr;
- g_numScenes = 0;
+ _numScenes = 0;
- g_numEntries = 0;
+ _numEntries = 0;
- g_pChosenScene = nullptr;
+ _pChosenScene = nullptr;
- g_lastChosenScene = 0;
- g_bRemember = false;
+ _lastChosenScene = 0;
+ _bRemember = false;
- *g_sedit = 0;
+ *_saveGameDesc = 0;
}
Dialogs::~Dialogs() {
- if (g_objArray[0] != NULL) {
+ if (_objArray[0] != NULL) {
DumpObjArray();
DumpDobjArray();
DumpIconArray();
@@ -895,7 +895,7 @@ void Dialogs::PrimeSceneHopper() {
vSize = f.readUint32LE();
// allocate a buffer for it all
- assert(g_pHopper == NULL);
+ assert(_pHopper == NULL);
uint32 size = f.size() - 8;
// make sure memory allocated
@@ -910,9 +910,9 @@ void Dialogs::PrimeSceneHopper() {
error(FILE_IS_CORRUPT, HOPPER_FILENAME);
// Set data pointers
- g_pHopper = (PHOPPER)pBuffer;
- g_pEntries = (PHOPENTRY)(pBuffer + vSize);
- g_numScenes = vSize / sizeof(HOPPER);
+ _pHopper = (PHOPPER)pBuffer;
+ _pEntries = (PHOPENTRY)(pBuffer + vSize);
+ _numScenes = vSize / sizeof(HOPPER);
// close the file
f.close();
@@ -922,31 +922,31 @@ void Dialogs::PrimeSceneHopper() {
* Free the scene hopper data file
*/
void Dialogs::FreeSceneHopper() {
- free(g_pHopper);
- g_pHopper = nullptr;
+ free(_pHopper);
+ _pHopper = nullptr;
}
void Dialogs::FirstScene(int first) {
int i;
- assert(g_numScenes && g_pHopper);
+ assert(_numScenes && _pHopper);
- if (g_bRemember) {
+ if (_bRemember) {
assert(first == 0);
- first = g_lastChosenScene;
- g_bRemember = false;
+ first = _lastChosenScene;
+ _bRemember = false;
}
// Force it to a sensible value
- if (first > g_numScenes - NUM_RGROUP_BOXES)
- first = g_numScenes - NUM_RGROUP_BOXES;
+ if (first > _numScenes - NUM_RGROUP_BOXES)
+ first = _numScenes - NUM_RGROUP_BOXES;
if (first < 0)
first = 0;
// Fill in the rest
- for (i = 0; i < NUM_RGROUP_BOXES && i + first < g_numScenes; i++) {
+ for (i = 0; i < NUM_RGROUP_BOXES && i + first < _numScenes; i++) {
cd.box[i].textMethod = TM_STRINGNUM;
- cd.box[i].ixText = FROM_32(g_pHopper[i + first].hSceneDesc);
+ cd.box[i].ixText = FROM_32(_pHopper[i + first].hSceneDesc);
}
// Blank out the spare ones (if any)
while (i < NUM_RGROUP_BOXES) {
@@ -958,31 +958,31 @@ void Dialogs::FirstScene(int first) {
}
void Dialogs::RememberChosenScene() {
- g_bRemember = true;
+ _bRemember = true;
}
void Dialogs::SetChosenScene() {
- g_lastChosenScene = cd.selBox + cd.extraBase;
- g_pChosenScene = &g_pHopper[cd.selBox + cd.extraBase];
+ _lastChosenScene = cd.selBox + cd.extraBase;
+ _pChosenScene = &_pHopper[cd.selBox + cd.extraBase];
}
void Dialogs::FirstEntry(int first) {
int i;
- g_InvD[INV_MENU].hInvTitle = FROM_32(g_pChosenScene->hSceneDesc);
+ _invD[INV_MENU].hInvTitle = FROM_32(_pChosenScene->hSceneDesc);
// get number of entrances
- g_numEntries = FROM_32(g_pChosenScene->numEntries);
+ _numEntries = FROM_32(_pChosenScene->numEntries);
// Force first to a sensible value
- if (first > g_numEntries - NUM_RGROUP_BOXES)
- first = g_numEntries - NUM_RGROUP_BOXES;
+ if (first > _numEntries - NUM_RGROUP_BOXES)
+ first = _numEntries - NUM_RGROUP_BOXES;
if (first < 0)
first = 0;
- for (i = 0; i < NUM_RGROUP_BOXES && i < g_numEntries; i++) {
+ for (i = 0; i < NUM_RGROUP_BOXES && i < _numEntries; i++) {
cd.box[i].textMethod = TM_STRINGNUM;
- cd.box[i].ixText = FROM_32(g_pEntries[FROM_32(g_pChosenScene->entryIndex) + i + first].hDesc);
+ cd.box[i].ixText = FROM_32(_pEntries[FROM_32(_pChosenScene->entryIndex) + i + first].hDesc);
}
// Blank out the spare ones (if any)
while (i < NUM_RGROUP_BOXES) {
@@ -994,15 +994,15 @@ void Dialogs::FirstEntry(int first) {
}
void Dialogs::HopAction() {
- PHOPENTRY pEntry = g_pEntries + FROM_32(g_pChosenScene->entryIndex) + cd.selBox + cd.extraBase;
+ PHOPENTRY pEntry = _pEntries + FROM_32(_pChosenScene->entryIndex) + cd.selBox + cd.extraBase;
- uint32 hScene = FROM_32(g_pChosenScene->hScene);
+ uint32 hScene = FROM_32(_pChosenScene->hScene);
uint32 eNumber = FROM_32(pEntry->eNumber);
debugC(DEBUG_BASIC, kTinselDebugAnimations, "Scene hopper chose scene %xh,%d\n", hScene, eNumber);
if (FROM_32(pEntry->flags) & fCall) {
SaveScene(Common::nullContext);
- NewScene(Common::nullContext, g_pChosenScene->hScene, pEntry->eNumber, TRANS_FADE);
+ NewScene(Common::nullContext, _pChosenScene->hScene, pEntry->eNumber, TRANS_FADE);
} else if (FROM_32(pEntry->flags) & fHook)
HookScene(hScene, eNumber, TRANS_FADE);
else
@@ -1018,9 +1018,9 @@ void Dialogs::HopAction() {
*/
void Dialogs::DumpIconArray() {
for (int i = 0; i < MAX_ICONS; i++) {
- if (g_iconArray[i] != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[i]);
- g_iconArray[i] = nullptr;
+ if (_iconArray[i] != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _iconArray[i]);
+ _iconArray[i] = nullptr;
}
}
}
@@ -1030,9 +1030,9 @@ void Dialogs::DumpIconArray() {
*/
void Dialogs::DumpDobjArray() {
for (int i = 0; i < MAX_WCOMP; i++) {
- if (g_DobjArray[i] != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_DobjArray[i]);
- g_DobjArray[i] = nullptr;
+ if (_dispObjArray[i] != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _dispObjArray[i]);
+ _dispObjArray[i] = nullptr;
}
}
}
@@ -1042,9 +1042,9 @@ void Dialogs::DumpDobjArray() {
*/
void Dialogs::DumpObjArray() {
for (int i = 0; i < MAX_WCOMP; i++) {
- if (g_objArray[i] != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_objArray[i]);
- g_objArray[i] = nullptr;
+ if (_objArray[i] != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _objArray[i]);
+ _objArray[i] = nullptr;
}
}
}
@@ -1054,9 +1054,9 @@ void Dialogs::DumpObjArray() {
* i.e. Image data and Glitter code.
*/
INV_OBJECT *Dialogs::GetInvObject(int id) {
- INV_OBJECT *pObject = g_invObjects;
+ INV_OBJECT *pObject = _invObjects;
- for (int i = 0; i < g_numObjects; i++, pObject++) {
+ for (int i = 0; i < _numObjects; i++, pObject++) {
if (pObject->id == id)
return pObject;
}
@@ -1068,9 +1068,9 @@ INV_OBJECT *Dialogs::GetInvObject(int id) {
* Returns true if the given id represents a valid inventory object
*/
bool Dialogs::GetIsInvObject(int id) {
- INV_OBJECT *pObject = g_invObjects;
+ INV_OBJECT *pObject = _invObjects;
- for (int i = 0; i < g_numObjects; i++, pObject++) {
+ for (int i = 0; i < _numObjects; i++, pObject++) {
if (pObject->id == id)
return true;
}
@@ -1082,9 +1082,9 @@ bool Dialogs::GetIsInvObject(int id) {
* Convert item ID number to index.
*/
int Dialogs::GetObjectIndex(int id) {
- INV_OBJECT *pObject = g_invObjects;
+ INV_OBJECT *pObject = _invObjects;
- for (int i = 0; i < g_numObjects; i++, pObject++) {
+ for (int i = 0; i < _numObjects; i++, pObject++) {
if (pObject->id == id)
return i;
}
@@ -1099,15 +1099,15 @@ int Dialogs::GetObjectIndex(int id) {
int Dialogs::InventoryPos(int num) {
int i;
- for (i = 0; i < g_InvD[INV_1].NoofItems; i++) // First inventory
- if (g_InvD[INV_1].contents[i] == num)
+ for (i = 0; i < _invD[INV_1].NoofItems; i++) // First inventory
+ if (_invD[INV_1].contents[i] == num)
return i;
- for (i = 0; i < g_InvD[INV_2].NoofItems; i++) // Second inventory
- if (g_InvD[INV_2].contents[i] == num)
+ for (i = 0; i < _invD[INV_2].NoofItems; i++) // Second inventory
+ if (_invD[INV_2].contents[i] == num)
return i;
- if (g_heldItem == num)
+ if (_heldItem == num)
return INV_HELDNOTIN; // Held, but not in either inventory
return INV_NOICON; // Not held, not in either inventory
@@ -1116,8 +1116,8 @@ int Dialogs::InventoryPos(int num) {
bool Dialogs::IsInInventory(int object, int invnum) {
assert(invnum == INV_1 || invnum == INV_2);
- for (int i = 0; i < g_InvD[invnum].NoofItems; i++) // First inventory
- if (g_InvD[invnum].contents[i] == object)
+ for (int i = 0; i < _invD[invnum].NoofItems; i++) // First inventory
+ if (_invD[invnum].contents[i] == object)
return true;
return false;
@@ -1127,7 +1127,7 @@ bool Dialogs::IsInInventory(int object, int invnum) {
* Returns which item is held (INV_NOICON (-1) if none)
*/
int Dialogs::WhichItemHeld() {
- return g_heldItem;
+ return _heldItem;
}
/**
@@ -1136,15 +1136,15 @@ int Dialogs::WhichItemHeld() {
*/
void Dialogs::InventoryIconCursor(bool bNewItem) {
- if (g_heldItem != INV_NOICON) {
+ if (_heldItem != INV_NOICON) {
if (TinselV2) {
if (bNewItem) {
- int objIndex = GetObjectIndex(g_heldItem);
- g_heldFilm = g_invFilms[objIndex];
+ int objIndex = GetObjectIndex(_heldItem);
+ _heldFilm = _invFilms[objIndex];
}
- _vm->_cursor->SetAuxCursor(g_heldFilm);
+ _vm->_cursor->SetAuxCursor(_heldFilm);
} else {
- INV_OBJECT *invObj = GetInvObject(g_heldItem);
+ INV_OBJECT *invObj = GetInvObject(_heldItem);
_vm->_cursor->SetAuxCursor(invObj->hIconFilm);
}
}
@@ -1154,14 +1154,14 @@ void Dialogs::InventoryIconCursor(bool bNewItem) {
* Returns true if the inventory is active.
*/
bool Dialogs::InventoryActive() {
- return (g_InventoryState == ACTIVE_INV);
+ return (_inventoryState == ACTIVE_INV);
}
int Dialogs::WhichInventoryOpen() {
- if (g_InventoryState != ACTIVE_INV)
+ if (_inventoryState != ACTIVE_INV)
return 0;
else
- return g_ino;
+ return _activeInv;
}
/**************************************************************************/
@@ -1206,9 +1206,9 @@ void Dialogs::FirstFile(int first) {
void Dialogs::InvSaveGame() {
if (cd.selBox != NOBOX) {
#ifndef JAPAN
- g_sedit[strlen(g_sedit) - 1] = 0; // Don't include the cursor!
+ _saveGameDesc[strlen(_saveGameDesc) - 1] = 0; // Don't include the cursor!
#endif
- SaveGame(ListEntry(cd.selBox - cd.modifier + cd.extraBase, LE_NAME), g_sedit);
+ SaveGame(ListEntry(cd.selBox - cd.modifier + cd.extraBase, LE_NAME), _saveGameDesc);
}
}
@@ -1221,17 +1221,17 @@ void Dialogs::InvLoadGame() {
if (cd.selBox != NOBOX && (cd.selBox + cd.extraBase < cd.numSaved)) {
rGame = cd.selBox;
cd.selBox = NOBOX;
- if (g_iconArray[HL3] != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]);
- g_iconArray[HL3] = nullptr;
+ if (_iconArray[HL3] != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _iconArray[HL3]);
+ _iconArray[HL3] = nullptr;
}
- if (g_iconArray[HL2] != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]);
- g_iconArray[HL2] = nullptr;
+ if (_iconArray[HL2] != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _iconArray[HL2]);
+ _iconArray[HL2] = nullptr;
}
- if (g_iconArray[HL1] != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
- g_iconArray[HL1] = nullptr;
+ if (_iconArray[HL1] != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _iconArray[HL1]);
+ _iconArray[HL1] = nullptr;
}
RestoreGame(rGame + cd.extraBase);
}
@@ -1248,7 +1248,7 @@ bool Dialogs::UpdateString(const Common::KeyState &kbd) {
if (!cd.editableRgroup)
return false;
- cpos = strlen(g_sedit) - 1;
+ cpos = strlen(_saveGameDesc) - 1;
if (kbd.ascii == 0)
return false;
@@ -1256,18 +1256,18 @@ bool Dialogs::UpdateString(const Common::KeyState &kbd) {
if (kbd.keycode == Common::KEYCODE_BACKSPACE) {
if (!cpos)
return false;
- g_sedit[cpos] = 0;
+ _saveGameDesc[cpos] = 0;
cpos--;
- g_sedit[cpos] = CURSOR_CHAR;
+ _saveGameDesc[cpos] = CURSOR_CHAR;
return true;
// } else if (isalnum(c) || c == ',' || c == '.' || c == '\'' || (c == ' ' && cpos != 0)) {
} else if (IsCharImage(_vm->_font->GetTagFontHandle(), kbd.ascii) || (kbd.ascii == ' ' && cpos != 0)) {
if (cpos == SG_DESC_LEN)
return false;
- g_sedit[cpos] = kbd.ascii;
+ _saveGameDesc[cpos] = kbd.ascii;
cpos++;
- g_sedit[cpos] = CURSOR_CHAR;
- g_sedit[cpos + 1] = 0;
+ _saveGameDesc[cpos] = CURSOR_CHAR;
+ _saveGameDesc[cpos + 1] = 0;
return true;
}
return false;
@@ -1297,25 +1297,25 @@ static bool InvKeyIn(const Common::KeyState &kbd) {
* Delete display of text currently being edited,
* and replace it with freshly edited text.
*/
- if (_vm->_dialogs->g_iconArray[HL3] != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL3]);
- _vm->_dialogs->g_iconArray[HL3] = nullptr;
+ if (_vm->_dialogs->_iconArray[HL3] != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->_iconArray[HL3]);
+ _vm->_dialogs->_iconArray[HL3] = nullptr;
}
- _vm->_dialogs->g_iconArray[HL3] = ObjectTextOut(
- _vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_sedit, 0,
+ _vm->_dialogs->_iconArray[HL3] = ObjectTextOut(
+ _vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->_saveGameDesc, 0,
_vm->_dialogs->CurrentInventoryX() + cd.box[cd.selBox].xpos + 2,
_vm->_dialogs->CurrentInventoryY() + cd.box[cd.selBox].ypos + TYOFF,
_vm->_font->GetTagFontHandle(), 0);
- if (MultiRightmost(_vm->_dialogs->g_iconArray[HL3]) > MAX_NAME_RIGHT) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL3]);
+ if (MultiRightmost(_vm->_dialogs->_iconArray[HL3]) > MAX_NAME_RIGHT) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->_iconArray[HL3]);
_vm->_dialogs->UpdateString(Common::KeyState(Common::KEYCODE_BACKSPACE));
- _vm->_dialogs->g_iconArray[HL3] = ObjectTextOut(
- _vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_sedit, 0,
+ _vm->_dialogs->_iconArray[HL3] = ObjectTextOut(
+ _vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->_saveGameDesc, 0,
_vm->_dialogs->CurrentInventoryX() + cd.box[cd.selBox].xpos + 2,
_vm->_dialogs->CurrentInventoryY() + cd.box[cd.selBox].ypos + TYOFF,
_vm->_font->GetTagFontHandle(), 0);
}
- MultiSetZPosition(_vm->_dialogs->g_iconArray[HL3], Z_INV_ITEXT + 2);
+ MultiSetZPosition(_vm->_dialogs->_iconArray[HL3], Z_INV_ITEXT + 2);
}
#endif
}
@@ -1340,28 +1340,28 @@ void Dialogs::Select(int i, bool force) {
cd.selBox = i;
// Clear previous selected highlight and text
- if (g_iconArray[HL2] != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]);
- g_iconArray[HL2] = nullptr;
+ if (_iconArray[HL2] != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _iconArray[HL2]);
+ _iconArray[HL2] = nullptr;
}
- if (g_iconArray[HL3] != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]);
- g_iconArray[HL3] = nullptr;
+ if (_iconArray[HL3] != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _iconArray[HL3]);
+ _iconArray[HL3] = nullptr;
}
// New highlight box
switch (cd.box[i].boxType) {
case RGROUP:
- g_iconArray[HL2] = RectangleObject(_vm->_bg->BgPal(),
+ _iconArray[HL2] = RectangleObject(_vm->_bg->BgPal(),
(TinselV2 ? HighlightColor() : COL_HILIGHT), cd.box[i].w, cd.box[i].h);
- MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]);
- MultiSetAniXY(g_iconArray[HL2],
- g_InvD[g_ino].inventoryX + cd.box[i].xpos,
- g_InvD[g_ino].inventoryY + cd.box[i].ypos);
+ MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _iconArray[HL2]);
+ MultiSetAniXY(_iconArray[HL2],
+ _invD[_activeInv].inventoryX + cd.box[i].xpos,
+ _invD[_activeInv].inventoryY + cd.box[i].ypos);
// Z-position of box, and add edit text if appropriate
if (cd.editableRgroup) {
- MultiSetZPosition(g_iconArray[HL2], Z_INV_ITEXT + 1);
+ MultiSetZPosition(_iconArray[HL2], Z_INV_ITEXT + 1);
if (TinselV2) {
assert(cd.box[i].textMethod == TM_POINTER);
@@ -1372,29 +1372,29 @@ void Dialogs::Select(int i, bool force) {
// Current date and time
time(&secs_now);
time_now = localtime(&secs_now);
- strftime(g_sedit, SG_DESC_LEN, "%D %H:%M", time_now);
+ strftime(_saveGameDesc, SG_DESC_LEN, "%D %H:%M", time_now);
#else
// Current description with cursor appended
if (cd.box[i].boxText != NULL) {
- Common::strlcpy(g_sedit, cd.box[i].boxText, SG_DESC_LEN + 2);
- Common::strlcat(g_sedit, sCursor, SG_DESC_LEN + 2);
+ Common::strlcpy(_saveGameDesc, cd.box[i].boxText, SG_DESC_LEN + 2);
+ Common::strlcat(_saveGameDesc, sCursor, SG_DESC_LEN + 2);
} else {
- Common::strlcpy(g_sedit, sCursor, SG_DESC_LEN + 2);
+ Common::strlcpy(_saveGameDesc, sCursor, SG_DESC_LEN + 2);
}
#endif
- g_iconArray[HL3] = ObjectTextOut(
- _vm->_bg->GetPlayfieldList(FIELD_STATUS), g_sedit, 0,
- g_InvD[g_ino].inventoryX + cd.box[i].xpos + 2,
+ _iconArray[HL3] = ObjectTextOut(
+ _vm->_bg->GetPlayfieldList(FIELD_STATUS), _saveGameDesc, 0,
+ _invD[_activeInv].inventoryX + cd.box[i].xpos + 2,
#ifdef JAPAN
- g_InvD[g_ino].inventoryY + cd.box[i].ypos + 2,
+ _invD[_activeInv].inventoryY + cd.box[i].ypos + 2,
#else
- g_InvD[g_ino].inventoryY + cd.box[i].ypos + TYOFF,
+ _invD[_activeInv].inventoryY + cd.box[i].ypos + TYOFF,
#endif
_vm->_font->GetTagFontHandle(), 0);
- MultiSetZPosition(g_iconArray[HL3], Z_INV_ITEXT + 2);
+ MultiSetZPosition(_iconArray[HL3], Z_INV_ITEXT + 2);
} else {
- MultiSetZPosition(g_iconArray[HL2], Z_INV_ICONS + 1);
+ MultiSetZPosition(_iconArray[HL2], Z_INV_ICONS + 1);
}
_vm->divertKeyInput(InvKeyIn);
@@ -1402,12 +1402,12 @@ void Dialogs::Select(int i, bool force) {
break;
case FRGROUP:
- g_iconArray[HL2] = RectangleObject(_vm->_bg->BgPal(), COL_HILIGHT, cd.box[i].w + 6, cd.box[i].h + 6);
- MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]);
- MultiSetAniXY(g_iconArray[HL2],
- g_InvD[g_ino].inventoryX + cd.box[i].xpos - 2,
- g_InvD[g_ino].inventoryY + cd.box[i].ypos - 2);
- MultiSetZPosition(g_iconArray[HL2], Z_INV_BRECT + 1);
+ _iconArray[HL2] = RectangleObject(_vm->_bg->BgPal(), COL_HILIGHT, cd.box[i].w + 6, cd.box[i].h + 6);
+ MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _iconArray[HL2]);
+ MultiSetAniXY(_iconArray[HL2],
+ _invD[_activeInv].inventoryX + cd.box[i].xpos - 2,
+ _invD[_activeInv].inventoryY + cd.box[i].ypos - 2);
+ MultiSetZPosition(_iconArray[HL2], Z_INV_BRECT + 1);
break;
@@ -1424,13 +1424,13 @@ void Dialogs::Select(int i, bool force) {
* Stop holding an item.
*/
void Dialogs::DropItem(int item) {
- if (g_heldItem == item) {
- g_heldItem = INV_NOICON; // Item not held
+ if (_heldItem == item) {
+ _heldItem = INV_NOICON; // Item not held
_vm->_cursor->DelAuxCursor(); // no longer aux cursor
}
// Redraw contents - held item was not displayed as a content.
- g_ItemsChanged = true;
+ _ItemsChanged = true;
}
/**
@@ -1439,8 +1439,8 @@ void Dialogs::DropItem(int item) {
void Dialogs::ClearInventory(int invno) {
assert(invno == INV_1 || invno == INV_2);
- g_InvD[invno].NoofItems = 0;
- memset(g_InvD[invno].contents, 0, sizeof(g_InvD[invno].contents));
+ _invD[invno].NoofItems = 0;
+ memset(_invD[invno].contents, 0, sizeof(_invD[invno].contents));
}
/**
@@ -1456,12 +1456,12 @@ void Dialogs::AddToInventory(int invno, int icon, bool hold) {
assert(invno == INV_1 || invno == INV_2 || invno == INV_CONV || invno == INV_OPEN || (invno == INV_DEFAULT && TinselV2));
if (invno == INV_OPEN) {
- assert(g_InventoryState == ACTIVE_INV && (g_ino == INV_1 || g_ino == INV_2)); // addopeninv() with inventry not open
- invno = g_ino;
+ assert(_inventoryState == ACTIVE_INV && (_activeInv == INV_1 || _activeInv == INV_2)); // addopeninv() with inventry not open
+ invno = _activeInv;
bOpen = true;
// Make sure it doesn't get in both!
- RemFromInventory(g_ino == INV_1 ? INV_2 : INV_1, icon);
+ RemFromInventory(_activeInv == INV_1 ? INV_2 : INV_1, icon);
} else {
bOpen = false;
@@ -1482,61 +1482,61 @@ void Dialogs::AddToInventory(int invno, int icon, bool hold) {
RemFromInventory(INV_1, icon);
// See if it's already there
- for (i = 0; i < g_InvD[invno].NoofItems; i++) {
- if (g_InvD[invno].contents[i] == icon)
+ for (i = 0; i < _invD[invno].NoofItems; i++) {
+ if (_invD[invno].contents[i] == icon)
break;
}
// Add it if it isn't already there
- if (i == g_InvD[invno].NoofItems) {
+ if (i == _invD[invno].NoofItems) {
if (!bOpen) {
if (invno == INV_CONV) {
if (TinselV2) {
int nei;
// Count how many current contents have end attribute
- for (i = 0, nei = 0; i < g_InvD[INV_CONV].NoofItems; i++) {
- invObj = GetInvObject(g_InvD[INV_CONV].contents[i]);
+ for (i = 0, nei = 0; i < _invD[INV_CONV].NoofItems; i++) {
+ invObj = GetInvObject(_invD[INV_CONV].contents[i]);
if (invObj->attribute & CONVENDITEM)
nei++;
}
// For conversation, insert before end icons
- memmove(&g_InvD[INV_CONV].contents[i - nei + 1],
- &g_InvD[INV_CONV].contents[i - nei], nei * sizeof(int));
- g_InvD[INV_CONV].contents[i - nei] = icon;
- g_InvD[INV_CONV].NoofItems++;
- g_InvD[INV_CONV].NoofHicons = g_InvD[INV_CONV].NoofItems;
+ memmove(&_invD[INV_CONV].contents[i - nei + 1],
+ &_invD[INV_CONV].contents[i - nei], nei * sizeof(int));
+ _invD[INV_CONV].contents[i - nei] = icon;
+ _invD[INV_CONV].NoofItems++;
+ _invD[INV_CONV].NoofHicons = _invD[INV_CONV].NoofItems;
// Get the window to re-position
- g_bMoveOnUnHide = true;
+ _bMoveOnUnHide = true;
} else {
// For conversation, insert before last icon
// which will always be the goodbye icon
- g_InvD[invno].contents[g_InvD[invno].NoofItems] = g_InvD[invno].contents[g_InvD[invno].NoofItems - 1];
- g_InvD[invno].contents[g_InvD[invno].NoofItems - 1] = icon;
- g_InvD[invno].NoofItems++;
+ _invD[invno].contents[_invD[invno].NoofItems] = _invD[invno].contents[_invD[invno].NoofItems - 1];
+ _invD[invno].contents[_invD[invno].NoofItems - 1] = icon;
+ _invD[invno].NoofItems++;
}
} else {
- g_InvD[invno].contents[g_InvD[invno].NoofItems++] = icon;
+ _invD[invno].contents[_invD[invno].NoofItems++] = icon;
}
- g_ItemsChanged = true;
+ _ItemsChanged = true;
} else {
// It could be that the index is beyond what you'd expect
// as delinv may well have been called
- if (g_GlitterIndex < g_InvD[invno].NoofItems) {
- memmove(&g_InvD[invno].contents[g_GlitterIndex + 1],
- &g_InvD[invno].contents[g_GlitterIndex],
- (g_InvD[invno].NoofItems - g_GlitterIndex) * sizeof(int));
- g_InvD[invno].contents[g_GlitterIndex] = icon;
+ if (_glitterIndex < _invD[invno].NoofItems) {
+ memmove(&_invD[invno].contents[_glitterIndex + 1],
+ &_invD[invno].contents[_glitterIndex],
+ (_invD[invno].NoofItems - _glitterIndex) * sizeof(int));
+ _invD[invno].contents[_glitterIndex] = icon;
} else {
- g_InvD[invno].contents[g_InvD[invno].NoofItems] = icon;
+ _invD[invno].contents[_invD[invno].NoofItems] = icon;
}
- g_InvD[invno].NoofItems++;
+ _invD[invno].NoofItems++;
}
// Move here after bug on Japenese DW1
- g_ItemsChanged = true;
+ _ItemsChanged = true;
}
// Hold it if requested
@@ -1554,25 +1554,25 @@ bool Dialogs::RemFromInventory(int invno, int icon) {
assert(invno == INV_1 || invno == INV_2 || invno == INV_CONV); // Trying to delete from illegal inventory
// See if it's there
- for (i = 0; i < g_InvD[invno].NoofItems; i++) {
- if (g_InvD[invno].contents[i] == icon)
+ for (i = 0; i < _invD[invno].NoofItems; i++) {
+ if (_invD[invno].contents[i] == icon)
break;
}
- if (i == g_InvD[invno].NoofItems)
+ if (i == _invD[invno].NoofItems)
return false; // Item wasn't there
else {
- memmove(&g_InvD[invno].contents[i], &g_InvD[invno].contents[i + 1], (g_InvD[invno].NoofItems - i) * sizeof(int));
- g_InvD[invno].NoofItems--;
+ memmove(&_invD[invno].contents[i], &_invD[invno].contents[i + 1], (_invD[invno].NoofItems - i) * sizeof(int));
+ _invD[invno].NoofItems--;
if (TinselV2 && invno == INV_CONV) {
- g_InvD[INV_CONV].NoofHicons = g_InvD[invno].NoofItems;
+ _invD[INV_CONV].NoofHicons = _invD[invno].NoofItems;
// Get the window to re-position
- g_bMoveOnUnHide = true;
+ _bMoveOnUnHide = true;
}
- g_ItemsChanged = true;
+ _ItemsChanged = true;
return true; // Item removed
}
}
@@ -1583,27 +1583,27 @@ bool Dialogs::RemFromInventory(int invno, int icon) {
void Dialogs::HoldItem(int item, bool bKeepFilm) {
INV_OBJECT *invObj;
- if (g_heldItem != item) {
- if (TinselV2 && (g_heldItem != NOOBJECT)) {
+ if (_heldItem != item) {
+ if (TinselV2 && (_heldItem != NOOBJECT)) {
// No longer holding previous item
_vm->_cursor->DelAuxCursor(); // no longer aux cursor
// If old held object is not in an inventory, and
// has a default, stick it in its default inventory.
- if (!IsInInventory(g_heldItem, INV_1) && !IsInInventory(g_heldItem, INV_2)) {
- invObj = GetInvObject(g_heldItem);
+ if (!IsInInventory(_heldItem, INV_1) && !IsInInventory(_heldItem, INV_2)) {
+ invObj = GetInvObject(_heldItem);
if (invObj->attribute & DEFINV1)
- AddToInventory(INV_1, g_heldItem);
+ AddToInventory(INV_1, _heldItem);
else if (invObj->attribute & DEFINV2)
- AddToInventory(INV_2, g_heldItem);
+ AddToInventory(INV_2, _heldItem);
else
// Hook for definable default inventory
- AddToInventory(INV_1, g_heldItem);
+ AddToInventory(INV_1, _heldItem);
}
} else if (!TinselV2) {
- if (item == INV_NOICON && g_heldItem != INV_NOICON)
+ if (item == INV_NOICON && _heldItem != INV_NOICON)
_vm->_cursor->DelAuxCursor(); // no longer aux cursor
if (item != INV_NOICON) {
@@ -1613,23 +1613,23 @@ void Dialogs::HoldItem(int item, bool bKeepFilm) {
// WORKAROUND: If a held item is being removed that's not in either inventory (i.e. it was picked up
// but never put in them), then when removing it from being held, drop it in the luggage
- if (g_heldItem != INV_NOICON && InventoryPos(g_heldItem) == INV_HELDNOTIN)
- AddToInventory(INV_1, g_heldItem);
+ if (_heldItem != INV_NOICON && InventoryPos(_heldItem) == INV_HELDNOTIN)
+ AddToInventory(INV_1, _heldItem);
}
- g_heldItem = item; // Item held
+ _heldItem = item; // Item held
if (TinselV2) {
InventoryIconCursor(!bKeepFilm);
// Redraw contents - held item not displayed as a content.
- g_ItemsChanged = true;
+ _ItemsChanged = true;
}
}
if (!TinselV2)
// Redraw contents - held item not displayed as a content.
- g_ItemsChanged = true;
+ _ItemsChanged = true;
}
/**************************************************************************/
@@ -1659,8 +1659,8 @@ enum { I_NOTIN,
// the active area of the borders for re-sizing.
/*---------------------------------*/
-#define LeftX g_InvD[g_ino].inventoryX
-#define TopY g_InvD[g_ino].inventoryY
+#define LeftX _invD[_activeInv].inventoryX
+#define TopY _invD[_activeInv].inventoryY
/*---------------------------------*/
/**
@@ -1673,8 +1673,8 @@ enum { I_NOTIN,
*/
int Dialogs::InvArea(int x, int y) {
if (TinselV2) {
- int RightX = MultiRightmost(g_RectObject) - NM_BG_SIZ_X - NM_BG_POS_X - NM_RS_R_INSET;
- int BottomY = MultiLowest(g_RectObject) - NM_BG_SIZ_Y - NM_BG_POS_Y - NM_RS_B_INSET;
+ int RightX = MultiRightmost(_rectObject) - NM_BG_SIZ_X - NM_BG_POS_X - NM_RS_R_INSET;
+ int BottomY = MultiLowest(_rectObject) - NM_BG_SIZ_Y - NM_BG_POS_Y - NM_RS_B_INSET;
// Outside the whole rectangle?
if (x <= LeftX || x > RightX || y <= TopY || y > BottomY)
@@ -1713,7 +1713,7 @@ int Dialogs::InvArea(int x, int y) {
return I_HEADER;
// Scroll bits
- if (!(g_ino == INV_MENU && cd.bExtraWin)) {
+ if (!(_activeInv == INV_MENU && cd.bExtraWin)) {
if (x > RightX - NM_SLIDE_INSET && x <= RightX - NM_SLIDE_INSET + NM_SLIDE_THICKNESS) {
if (y > TopY + NM_UP_ARROW_TOP && y < TopY + NM_UP_ARROW_BOTTOM)
return I_UP;
@@ -1722,10 +1722,10 @@ int Dialogs::InvArea(int x, int y) {
/* '3' is a magic adjustment with no apparent sense */
- if (y >= TopY + g_sliderYmin - 3 && y < TopY + g_sliderYmax + NM_SLH) {
- if (y < TopY + g_sliderYpos - 3)
+ if (y >= TopY + _sliderYmin - 3 && y < TopY + _sliderYmax + NM_SLH) {
+ if (y < TopY + _sliderYpos - 3)
return I_SLIDE_UP;
- if (y < TopY + g_sliderYpos + NM_SLH - 3)
+ if (y < TopY + _sliderYpos + NM_SLH - 3)
return I_SLIDE;
else
return I_SLIDE_DOWN;
@@ -1733,8 +1733,8 @@ int Dialogs::InvArea(int x, int y) {
}
}
} else {
- int RightX = MultiRightmost(g_RectObject) + 1;
- int BottomY = MultiLowest(g_RectObject) + 1;
+ int RightX = MultiRightmost(_rectObject) + 1;
+ int BottomY = MultiLowest(_rectObject) + 1;
// Outside the whole rectangle?
if (x <= LeftX - EXTRA || x > RightX + EXTRA || y <= TopY - EXTRA || y > BottomY + EXTRA)
@@ -1770,24 +1770,24 @@ int Dialogs::InvArea(int x, int y) {
/*
* In the move area?
*/
- if (g_ino != INV_CONF && x >= LeftX + M_SW - 2 && x <= RightX - M_SW + 3 &&
+ if (_activeInv != INV_CONF && x >= LeftX + M_SW - 2 && x <= RightX - M_SW + 3 &&
y >= TopY + M_TH - 2 && y < TopY + M_TBB + 2)
return I_HEADER;
/*
* Scroll bits
*/
- if (!(g_ino == INV_CONF && cd.bExtraWin)) {
+ if (!(_activeInv == INV_CONF && cd.bExtraWin)) {
if (x > RightX - NM_SLIDE_INSET && x <= RightX - NM_SLIDE_INSET + NM_SLIDE_THICKNESS) {
if (y > TopY + M_IUT + 1 && y < TopY + M_IUB - 1)
return I_UP;
if (y > BottomY - M_IDT + 4 && y <= BottomY - M_IDB + 1)
return I_DOWN;
- if (y >= TopY + g_sliderYmin && y < TopY + g_sliderYmax + M_SH) {
- if (y < TopY + g_sliderYpos)
+ if (y >= TopY + _sliderYmin && y < TopY + _sliderYmax + M_SH) {
+ if (y < TopY + _sliderYpos)
return I_SLIDE_UP;
- if (y < TopY + g_sliderYpos + M_SH)
+ if (y < TopY + _sliderYpos + M_SH)
return I_SLIDE;
else
return I_SLIDE_DOWN;
@@ -1809,14 +1809,14 @@ int Dialogs::InvItem(int *x, int *y, bool update) {
int item;
int IconsX;
- itop = g_InvD[g_ino].inventoryY + START_ICONY;
+ itop = _invD[_activeInv].inventoryY + START_ICONY;
- IconsX = g_InvD[g_ino].inventoryX + START_ICONX;
+ IconsX = _invD[_activeInv].inventoryX + START_ICONX;
- for (item = g_InvD[g_ino].FirstDisp, row = 0; row < g_InvD[g_ino].NoofVicons; row++) {
+ for (item = _invD[_activeInv].FirstDisp, row = 0; row < _invD[_activeInv].NoofVicons; row++) {
ileft = IconsX;
- for (col = 0; col < g_InvD[g_ino].NoofHicons; col++, item++) {
+ for (col = 0; col < _invD[_activeInv].NoofHicons; col++, item++) {
if (*x >= ileft && *x < ileft + ITEM_WIDTH &&
*y >= itop && *y < itop + ITEM_HEIGHT) {
if (update) {
@@ -1849,20 +1849,20 @@ int Dialogs::InvItemId(int x, int y) {
int row, col;
int item;
- if (g_InventoryHidden || g_InventoryState == IDLE_INV)
+ if (_InventoryHidden || _inventoryState == IDLE_INV)
return INV_NOICON;
- itop = g_InvD[g_ino].inventoryY + START_ICONY;
+ itop = _invD[_activeInv].inventoryY + START_ICONY;
- int IconsX = g_InvD[g_ino].inventoryX + START_ICONX;
+ int IconsX = _invD[_activeInv].inventoryX + START_ICONX;
- for (item = g_InvD[g_ino].FirstDisp, row = 0; row < g_InvD[g_ino].NoofVicons; row++) {
+ for (item = _invD[_activeInv].FirstDisp, row = 0; row < _invD[_activeInv].NoofVicons; row++) {
ileft = IconsX;
- for (col = 0; col < g_InvD[g_ino].NoofHicons; col++, item++) {
+ for (col = 0; col < _invD[_activeInv].NoofHicons; col++, item++) {
if (x >= ileft && x < ileft + ITEM_WIDTH &&
y >= itop && y < itop + ITEM_HEIGHT) {
- return g_InvD[g_ino].contents[item];
+ return _invD[_activeInv].contents[item];
}
ileft += ITEM_WIDTH + 1;
@@ -1877,14 +1877,14 @@ int Dialogs::InvItemId(int x, int y) {
*/
int Dialogs::WhichMenuBox(int curX, int curY, bool bSlides) {
if (bSlides) {
- for (int i = 0; i < g_numMdSlides; i++) {
- if (curY > MultiHighest(g_mdSlides[i].obj) && curY < MultiLowest(g_mdSlides[i].obj) && curX > MultiLeftmost(g_mdSlides[i].obj) && curX < MultiRightmost(g_mdSlides[i].obj))
- return g_mdSlides[i].num | IS_SLIDER;
+ for (int i = 0; i < _numMdSlides; i++) {
+ if (curY > MultiHighest(_mdSlides[i].obj) && curY < MultiLowest(_mdSlides[i].obj) && curX > MultiLeftmost(_mdSlides[i].obj) && curX < MultiRightmost(_mdSlides[i].obj))
+ return _mdSlides[i].num | IS_SLIDER;
}
}
- curX -= g_InvD[g_ino].inventoryX;
- curY -= g_InvD[g_ino].inventoryY;
+ curX -= _invD[_activeInv].inventoryX;
+ curY -= _invD[_activeInv].inventoryY;
for (int i = 0; i < cd.NumBoxes; i++) {
switch (cd.box[i].boxType) {
@@ -1910,7 +1910,7 @@ int Dialogs::WhichMenuBox(int curX, int curY, bool bSlides) {
break;
case ROTATE:
- if (g_bNoLanguage)
+ if (_noLanguage)
break;
if (curY > cd.box[i].ypos && curY < cd.box[i].ypos + cd.box[i].h) {
@@ -1945,9 +1945,9 @@ int Dialogs::WhichMenuBox(int curX, int curY, bool bSlides) {
return IB_UP;
else if (curY > (r.bottom - (TinselV2 ? 18 : 5)))
return IB_DOWN;
- else if (curY + g_InvD[g_ino].inventoryY < g_sliderYpos)
+ else if (curY + _invD[_activeInv].inventoryY < _sliderYpos)
return IB_SLIDE_UP;
- else if (curY + g_InvD[g_ino].inventoryY >= g_sliderYpos + NM_SLH)
+ else if (curY + _invD[_activeInv].inventoryY >= _sliderYpos + NM_SLH)
return IB_SLIDE_DOWN;
else
return IB_SLIDE;
@@ -1983,60 +1983,60 @@ void Dialogs::InvBoxes(bool InBody, int curX, int curY) {
if (index < 0) {
// unhigh-light box (if one was)
cd.pointBox = NOBOX;
- if (g_iconArray[HL1] != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
- g_iconArray[HL1] = nullptr;
+ if (_iconArray[HL1] != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _iconArray[HL1]);
+ _iconArray[HL1] = nullptr;
}
} else if (index != cd.pointBox) {
cd.pointBox = index;
// A new box is pointed to - high-light it
- if (g_iconArray[HL1] != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
- g_iconArray[HL1] = nullptr;
+ if (_iconArray[HL1] != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _iconArray[HL1]);
+ _iconArray[HL1] = nullptr;
}
if ((cd.box[cd.pointBox].boxType == ARSBUT && cd.selBox != NOBOX) ||
///* I don't agree */ cd.box[cd.pointBox].boxType == RGROUP ||
cd.box[cd.pointBox].boxType == AATBUT ||
cd.box[cd.pointBox].boxType == AABUT) {
- g_iconArray[HL1] = RectangleObject(_vm->_bg->BgPal(),
+ _iconArray[HL1] = RectangleObject(_vm->_bg->BgPal(),
(TinselV2 ? HighlightColor() : COL_HILIGHT),
cd.box[cd.pointBox].w, cd.box[cd.pointBox].h);
- MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
- MultiSetAniXY(g_iconArray[HL1],
- g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos,
- g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos);
- MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS + 1);
+ MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _iconArray[HL1]);
+ MultiSetAniXY(_iconArray[HL1],
+ _invD[_activeInv].inventoryX + cd.box[cd.pointBox].xpos,
+ _invD[_activeInv].inventoryY + cd.box[cd.pointBox].ypos);
+ MultiSetZPosition(_iconArray[HL1], Z_INV_ICONS + 1);
} else if (cd.box[cd.pointBox].boxType == AAGBUT ||
cd.box[cd.pointBox].boxType == ARSGBUT ||
cd.box[cd.pointBox].boxType == TOGGLE ||
cd.box[cd.pointBox].boxType == TOGGLE1 ||
cd.box[cd.pointBox].boxType == TOGGLE2) {
- pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
+ pfilm = (const FILM *)_vm->_handle->LockMem(_hWinParts);
- g_iconArray[HL1] = AddObject(&pfilm->reels[cd.box[cd.pointBox].bi + HIGRAPH], -1);
- MultiSetAniXY(g_iconArray[HL1],
- g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos,
- g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos);
- MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS + 1);
+ _iconArray[HL1] = AddObject(&pfilm->reels[cd.box[cd.pointBox].bi + HIGRAPH], -1);
+ MultiSetAniXY(_iconArray[HL1],
+ _invD[_activeInv].inventoryX + cd.box[cd.pointBox].xpos,
+ _invD[_activeInv].inventoryY + cd.box[cd.pointBox].ypos);
+ MultiSetZPosition(_iconArray[HL1], Z_INV_ICONS + 1);
} else if (cd.box[cd.pointBox].boxType == ROTATE) {
- if (g_bNoLanguage)
+ if (_noLanguage)
return;
- pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
+ pfilm = (const FILM *)_vm->_handle->LockMem(_hWinParts);
rotateIndex = cd.box[cd.pointBox].bi;
if (rotateIndex == IX2_LEFT1) {
- g_iconArray[HL1] = AddObject(&pfilm->reels[IX2_LEFT2], -1);
- MultiSetAniXY(g_iconArray[HL1],
- g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos - ROTX1,
- g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos);
- MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS + 1);
+ _iconArray[HL1] = AddObject(&pfilm->reels[IX2_LEFT2], -1);
+ MultiSetAniXY(_iconArray[HL1],
+ _invD[_activeInv].inventoryX + cd.box[cd.pointBox].xpos - ROTX1,
+ _invD[_activeInv].inventoryY + cd.box[cd.pointBox].ypos);
+ MultiSetZPosition(_iconArray[HL1], Z_INV_ICONS + 1);
} else if (rotateIndex == IX2_RIGHT1) {
- g_iconArray[HL1] = AddObject(&pfilm->reels[IX2_RIGHT2], -1);
- MultiSetAniXY(g_iconArray[HL1],
- g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos + ROTX1,
- g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos);
- MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS + 1);
+ _iconArray[HL1] = AddObject(&pfilm->reels[IX2_RIGHT2], -1);
+ MultiSetAniXY(_iconArray[HL1],
+ _invD[_activeInv].inventoryX + cd.box[cd.pointBox].xpos + ROTX1,
+ _invD[_activeInv].inventoryY + cd.box[cd.pointBox].ypos);
+ MultiSetZPosition(_iconArray[HL1], Z_INV_ICONS + 1);
}
}
}
@@ -2055,23 +2055,23 @@ void Dialogs::InvLabels(bool InBody, int aniX, int aniY) {
else {
index = InvItem(&aniX, &aniY, false);
if (index != INV_NOICON) {
- if (index >= g_InvD[g_ino].NoofItems)
+ if (index >= _invD[_activeInv].NoofItems)
index = INV_NOICON;
else
- index = g_InvD[g_ino].contents[index];
+ index = _invD[_activeInv].contents[index];
}
}
// If no icon pointed to, or points to (logical position of)
// currently held icon, then no icon is pointed to!
- if (index == INV_NOICON || index == g_heldItem) {
- g_pointedIcon = INV_NOICON;
- } else if (index != g_pointedIcon) {
+ if (index == INV_NOICON || index == _heldItem) {
+ _pointedIcon = INV_NOICON;
+ } else if (index != _pointedIcon) {
// A new icon is pointed to - run its script with POINTED event
invObj = GetInvObject(index);
if (invObj->hScript)
InvTinselEvent(invObj, POINTED, PLR_NOEVENT, index);
- g_pointedIcon = index;
+ _pointedIcon = index;
}
}
@@ -2093,54 +2093,54 @@ void Dialogs::AdjustTop() {
int n, i;
// Only do this if there's a slider
- if (!g_SlideObject)
+ if (!_slideObject)
return;
- rowsWanted = (g_InvD[g_ino].NoofItems - g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons - 1) / g_InvD[g_ino].NoofHicons;
+ rowsWanted = (_invD[_activeInv].NoofItems - _invD[_activeInv].FirstDisp + _invD[_activeInv].NoofHicons - 1) / _invD[_activeInv].NoofHicons;
- while (rowsWanted < g_InvD[g_ino].NoofVicons) {
- if (g_InvD[g_ino].FirstDisp) {
- g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons;
- if (g_InvD[g_ino].FirstDisp < 0)
- g_InvD[g_ino].FirstDisp = 0;
+ while (rowsWanted < _invD[_activeInv].NoofVicons) {
+ if (_invD[_activeInv].FirstDisp) {
+ _invD[_activeInv].FirstDisp -= _invD[_activeInv].NoofHicons;
+ if (_invD[_activeInv].FirstDisp < 0)
+ _invD[_activeInv].FirstDisp = 0;
rowsWanted++;
} else
break;
}
- tMissing = g_InvD[g_ino].FirstDisp ? (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons - 1) / g_InvD[g_ino].NoofHicons : 0;
- bMissing = (rowsWanted > g_InvD[g_ino].NoofVicons) ? rowsWanted - g_InvD[g_ino].NoofVicons : 0;
+ tMissing = _invD[_activeInv].FirstDisp ? (_invD[_activeInv].FirstDisp + _invD[_activeInv].NoofHicons - 1) / _invD[_activeInv].NoofHicons : 0;
+ bMissing = (rowsWanted > _invD[_activeInv].NoofVicons) ? rowsWanted - _invD[_activeInv].NoofVicons : 0;
nMissing = tMissing + bMissing;
- slideRange = g_sliderYmax - g_sliderYmin;
+ slideRange = _sliderYmax - _sliderYmin;
if (!tMissing)
- nsliderYpos = g_sliderYmin;
+ nsliderYpos = _sliderYmin;
else if (!bMissing)
- nsliderYpos = g_sliderYmax;
+ nsliderYpos = _sliderYmax;
else {
nsliderYpos = tMissing * slideRange / nMissing;
- nsliderYpos += g_sliderYmin;
+ nsliderYpos += _sliderYmin;
}
if (nMissing) {
- n = g_InvD[g_ino].FirstDisp - tMissing * g_InvD[g_ino].NoofHicons;
- for (i = 0; i <= nMissing; i++, n += g_InvD[g_ino].NoofHicons) {
- g_slideStuff[i].n = n;
- g_slideStuff[i].y = (i * slideRange / nMissing) + g_sliderYmin;
+ n = _invD[_activeInv].FirstDisp - tMissing * _invD[_activeInv].NoofHicons;
+ for (i = 0; i <= nMissing; i++, n += _invD[_activeInv].NoofHicons) {
+ _slideStuff[i].n = n;
+ _slideStuff[i].y = (i * slideRange / nMissing) + _sliderYmin;
}
- if (g_slideStuff[0].n < 0)
- g_slideStuff[0].n = 0;
+ if (_slideStuff[0].n < 0)
+ _slideStuff[0].n = 0;
assert(i < MAX_ININV + 1);
- g_slideStuff[i].n = -1;
+ _slideStuff[i].n = -1;
} else {
- g_slideStuff[0].n = 0;
- g_slideStuff[0].y = g_sliderYmin;
- g_slideStuff[1].n = -1;
+ _slideStuff[0].n = 0;
+ _slideStuff[0].y = _sliderYmin;
+ _slideStuff[1].n = -1;
}
- if (nsliderYpos != g_sliderYpos) {
- MultiMoveRelXY(g_SlideObject, 0, nsliderYpos - g_sliderYpos);
- g_sliderYpos = nsliderYpos;
+ if (nsliderYpos != _sliderYpos) {
+ MultiMoveRelXY(_slideObject, 0, nsliderYpos - _sliderYpos);
+ _sliderYpos = nsliderYpos;
}
}
@@ -2181,26 +2181,26 @@ void Dialogs::FillInInventory() {
DumpIconArray();
- if (g_InvDragging != ID_SLIDE)
+ if (_invDragging != ID_SLIDE)
AdjustTop(); // Set up slideStuff[]
- Index = g_InvD[g_ino].FirstDisp; // Start from first displayed object
+ Index = _invD[_activeInv].FirstDisp; // Start from first displayed object
n = 0;
ypos = START_ICONY; // Y-offset of first display row
- for (row = 0; row < g_InvD[g_ino].NoofVicons; row++, ypos += ITEM_HEIGHT + 1) {
+ for (row = 0; row < _invD[_activeInv].NoofVicons; row++, ypos += ITEM_HEIGHT + 1) {
xpos = START_ICONX; // X-offset of first display column
- for (col = 0; col < g_InvD[g_ino].NoofHicons; col++) {
- if (Index >= g_InvD[g_ino].NoofItems)
+ for (col = 0; col < _invD[_activeInv].NoofHicons; col++) {
+ if (Index >= _invD[_activeInv].NoofItems)
break;
- else if (g_InvD[g_ino].contents[Index] != g_heldItem) {
+ else if (_invD[_activeInv].contents[Index] != _heldItem) {
// Create a display object and position it
- g_iconArray[n] = AddInvObject(g_InvD[g_ino].contents[Index], &pfr, &pfilm);
- MultiSetAniXY(g_iconArray[n], g_InvD[g_ino].inventoryX + xpos, g_InvD[g_ino].inventoryY + ypos);
- MultiSetZPosition(g_iconArray[n], Z_INV_ICONS);
+ _iconArray[n] = AddInvObject(_invD[_activeInv].contents[Index], &pfr, &pfilm);
+ MultiSetAniXY(_iconArray[n], _invD[_activeInv].inventoryX + xpos, _invD[_activeInv].inventoryY + ypos);
+ MultiSetZPosition(_iconArray[n], Z_INV_ICONS);
- InitStepAnimScript(&g_iconAnims[n], g_iconArray[n], FROM_32(pfr->script), ONE_SECOND / FROM_32(pfilm->frate));
+ InitStepAnimScript(&_iconAnims[n], _iconArray[n], FROM_32(pfr->script), ONE_SECOND / FROM_32(pfilm->frate));
n++;
}
@@ -2219,16 +2219,16 @@ enum { FROM_HANDLE,
*/
void Dialogs::AddBackground(OBJECT **rect, OBJECT **title, int extraH, int extraV, int textFrom) {
// Why not 2 ????
- int width = g_TLwidth + extraH + g_TRwidth + NM_BG_SIZ_X;
- int height = g_TLheight + extraV + g_BLheight + NM_BG_SIZ_Y;
+ int width = _TLwidth + extraH + _TRwidth + NM_BG_SIZ_X;
+ int height = _TLheight + extraV + _BLheight + NM_BG_SIZ_Y;
// Create a rectangle object
- g_RectObject = *rect = TranslucentObject(width, height);
+ _rectObject = *rect = TranslucentObject(width, height);
// add it to display list and position it
MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), *rect);
- MultiSetAniXY(*rect, g_InvD[g_ino].inventoryX + NM_BG_POS_X,
- g_InvD[g_ino].inventoryY + NM_BG_POS_Y);
+ MultiSetAniXY(*rect, _invD[_activeInv].inventoryX + NM_BG_POS_X,
+ _invD[_activeInv].inventoryY + NM_BG_POS_Y);
MultiSetZPosition(*rect, Z_INV_BRECT);
if (title == NULL)
@@ -2236,16 +2236,16 @@ void Dialogs::AddBackground(OBJECT **rect, OBJECT **title, int extraH, int extra
// Create text object using title string
if (textFrom == FROM_HANDLE) {
- LoadStringRes(g_InvD[g_ino].hInvTitle, _vm->_font->TextBufferAddr(), TBUFSZ);
+ LoadStringRes(_invD[_activeInv].hInvTitle, _vm->_font->TextBufferAddr(), TBUFSZ);
*title = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), 0,
- g_InvD[g_ino].inventoryX + width / 2, g_InvD[g_ino].inventoryY + M_TOFF,
+ _invD[_activeInv].inventoryX + width / 2, _invD[_activeInv].inventoryY + M_TOFF,
_vm->_font->GetTagFontHandle(), TXT_CENTER);
assert(*title); // Inventory title string produced NULL text
MultiSetZPosition(*title, Z_INV_HTEXT);
} else if (textFrom == FROM_STRING && cd.ixHeading != NO_HEADING) {
- LoadStringRes(g_configStrings[cd.ixHeading], _vm->_font->TextBufferAddr(), TBUFSZ);
+ LoadStringRes(_configStrings[cd.ixHeading], _vm->_font->TextBufferAddr(), TBUFSZ);
*title = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), 0,
- g_InvD[g_ino].inventoryX + width / 2, g_InvD[g_ino].inventoryY + M_TOFF,
+ _invD[_activeInv].inventoryX + width / 2, _invD[_activeInv].inventoryY + M_TOFF,
_vm->_font->GetTagFontHandle(), TXT_CENTER);
assert(*title); // Inventory title string produced NULL text
MultiSetZPosition(*title, Z_INV_HTEXT);
@@ -2263,13 +2263,13 @@ void Dialogs::AddBackground(OBJECT **rect, int extraH, int extraV) {
* Adds a title for a dialog
*/
void Dialogs::AddTitle(POBJECT *title, int extraH) {
- int width = g_TLwidth + extraH + g_TRwidth + NM_BG_SIZ_X;
+ int width = _TLwidth + extraH + _TRwidth + NM_BG_SIZ_X;
// Create text object using title string
- if (g_InvD[g_ino].hInvTitle != (SCNHANDLE)NO_HEADING) {
- LoadStringRes(g_InvD[g_ino].hInvTitle, _vm->_font->TextBufferAddr(), TBUFSZ);
+ if (_invD[_activeInv].hInvTitle != (SCNHANDLE)NO_HEADING) {
+ LoadStringRes(_invD[_activeInv].hInvTitle, _vm->_font->TextBufferAddr(), TBUFSZ);
*title = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), 0,
- g_InvD[g_ino].inventoryX + (width / 2) + NM_BG_POS_X, g_InvD[g_ino].inventoryY + NM_TOFF,
+ _invD[_activeInv].inventoryX + (width / 2) + NM_BG_POS_X, _invD[_activeInv].inventoryY + NM_TOFF,
_vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
assert(*title);
MultiSetZPosition(*title, Z_INV_HTEXT);
@@ -2292,13 +2292,13 @@ OBJECT *Dialogs::AddObject(const FREEL *pfreel, int num) {
// Horrible bodge involving global variables to save
// width and/or height of some window frame components
- if (num == g_TL) {
- g_TLwidth = FROM_16(pim->imgWidth);
- g_TLheight = FROM_16(pim->imgHeight) & ~C16_FLAG_MASK;
- } else if (num == g_TR) {
- g_TRwidth = FROM_16(pim->imgWidth);
- } else if (num == g_BL) {
- g_BLheight = FROM_16(pim->imgHeight) & ~C16_FLAG_MASK;
+ if (num == _TL) {
+ _TLwidth = FROM_16(pim->imgWidth);
+ _TLheight = FROM_16(pim->imgHeight) & ~C16_FLAG_MASK;
+ } else if (num == _TR) {
+ _TRwidth = FROM_16(pim->imgWidth);
+ } else if (num == _BL) {
+ _BLheight = FROM_16(pim->imgHeight) & ~C16_FLAG_MASK;
}
// Set up and insert the multi-object
@@ -2313,9 +2313,9 @@ OBJECT *Dialogs::AddObject(const FREEL *pfreel, int num) {
*/
void Dialogs::AddSlider(OBJECT **slide, const FILM *pfilm) {
- g_SlideObject = *slide = AddObject(&pfilm->reels[IX_SLIDE], -1);
- MultiSetAniXY(*slide, MultiRightmost(g_RectObject) + (TinselV2 ? NM_SLX : -M_SXOFF + 2),
- g_InvD[g_ino].inventoryY + g_sliderYpos);
+ _slideObject = *slide = AddObject(&pfilm->reels[IX_SLIDE], -1);
+ MultiSetAniXY(*slide, MultiRightmost(_rectObject) + (TinselV2 ? NM_SLX : -M_SXOFF + 2),
+ _invD[_activeInv].inventoryY + _sliderYpos);
MultiSetZPosition(*slide, Z_INV_MFRAME);
}
@@ -2323,8 +2323,8 @@ void Dialogs::AddSlider(OBJECT **slide, const FILM *pfilm) {
* Display a box with some text in it.
*/
void Dialogs::AddBox(int *pi, const int i) {
- int x = g_InvD[g_ino].inventoryX + cd.box[i].xpos;
- int y = g_InvD[g_ino].inventoryY + cd.box[i].ypos;
+ int x = _invD[_activeInv].inventoryX + cd.box[i].xpos;
+ int y = _invD[_activeInv].inventoryY + cd.box[i].ypos;
int *pival = cd.box[i].ival;
int xdisp;
const FILM *pFilm;
@@ -2336,11 +2336,11 @@ void Dialogs::AddBox(int *pi, const int i) {
break;
// Give us a box
- g_iconArray[*pi] = RectangleObject(_vm->_bg->BgPal(), TinselV2 ? BoxColor() : COL_BOX,
+ _iconArray[*pi] = RectangleObject(_vm->_bg->BgPal(), TinselV2 ? BoxColor() : COL_BOX,
cd.box[i].w, cd.box[i].h);
- MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[*pi]);
- MultiSetAniXY(g_iconArray[*pi], x, y);
- MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);
+ MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _iconArray[*pi]);
+ MultiSetAniXY(_iconArray[*pi], x, y);
+ MultiSetZPosition(_iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1;
// Stick in the text
@@ -2348,14 +2348,14 @@ void Dialogs::AddBox(int *pi, const int i) {
(!TinselV2 && (cd.box[i].ixText == USE_POINTER))) {
if (cd.box[i].boxText != NULL) {
if (cd.box[i].boxType == RGROUP) {
- g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0,
+ _iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0,
#ifdef JAPAN
x + 2, y + 2, GetTagFontHandle(), 0);
#else
x + 2, y + TYOFF, _vm->_font->GetTagFontHandle(), 0);
#endif
} else {
- g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0,
+ _iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0,
#ifdef JAPAN
// Note: it never seems to go here!
x + cd.box[i].w / 2, y + 2, GetTagFontHandle(), TXT_CENTER);
@@ -2364,7 +2364,7 @@ void Dialogs::AddBox(int *pi, const int i) {
#endif
}
- MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
+ MultiSetZPosition(_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
}
} else {
@@ -2376,61 +2376,61 @@ void Dialogs::AddBox(int *pi, const int i) {
LoadStringRes(cd.box[i].ixText, _vm->_font->TextBufferAddr(), TBUFSZ);
}
} else {
- LoadStringRes(g_configStrings[cd.box[i].ixText], _vm->_font->TextBufferAddr(), TBUFSZ);
+ LoadStringRes(_configStrings[cd.box[i].ixText], _vm->_font->TextBufferAddr(), TBUFSZ);
assert(cd.box[i].boxType != RGROUP); // You'll need to add some code!
}
if (TinselV2 && (cd.box[i].boxType == RGROUP))
- g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(),
+ _iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(),
0, x + 2, y + TYOFF, _vm->_font->GetTagFontHandle(), 0, 0);
else
- g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
+ _iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), 0,
#ifdef JAPAN
x + cd.box[i].w / 2, y + 2, GetTagFontHandle(), TXT_CENTER);
#else
x + cd.box[i].w / 2, y + TYOFF, _vm->_font->GetTagFontHandle(), TXT_CENTER);
#endif
- MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
+ MultiSetZPosition(_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
}
break;
case AAGBUT:
case ARSGBUT:
- pFilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
+ pFilm = (const FILM *)_vm->_handle->LockMem(_hWinParts);
- g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + NORMGRAPH], -1);
- MultiSetAniXY(g_iconArray[*pi], x, y);
- MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);
+ _iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + NORMGRAPH], -1);
+ MultiSetAniXY(_iconArray[*pi], x, y);
+ MultiSetZPosition(_iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1;
break;
case FRGROUP:
- assert(g_flagFilm != 0); // Language flags not declared!
+ assert(_flagFilm != 0); // Language flags not declared!
- pFilm = (const FILM *)_vm->_handle->LockMem(g_flagFilm);
+ pFilm = (const FILM *)_vm->_handle->LockMem(_flagFilm);
if (_vm->_config->_isAmericanEnglishVersion && cd.box[i].bi == FIX_UK)
cd.box[i].bi = FIX_USA;
- g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi], -1);
- MultiSetAniXY(g_iconArray[*pi], x, y);
- MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 2);
+ _iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi], -1);
+ MultiSetAniXY(_iconArray[*pi], x, y);
+ MultiSetZPosition(_iconArray[*pi], Z_INV_BRECT + 2);
*pi += 1;
break;
case FLIP:
- pFilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
+ pFilm = (const FILM *)_vm->_handle->LockMem(_hWinParts);
if (*pival)
- g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi], -1);
+ _iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi], -1);
else
- g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + 1], -1);
- MultiSetAniXY(g_iconArray[*pi], x, y);
- MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);
+ _iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + 1], -1);
+ MultiSetAniXY(_iconArray[*pi], x, y);
+ MultiSetZPosition(_iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1;
// Stick in the text
@@ -2439,23 +2439,23 @@ void Dialogs::AddBox(int *pi, const int i) {
LoadStringRes(SysString(cd.box[i].ixText), _vm->_font->TextBufferAddr(), TBUFSZ);
} else {
assert(cd.box[i].ixText != USE_POINTER);
- LoadStringRes(g_configStrings[cd.box[i].ixText], _vm->_font->TextBufferAddr(), TBUFSZ);
+ LoadStringRes(_configStrings[cd.box[i].ixText], _vm->_font->TextBufferAddr(), TBUFSZ);
}
- g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
+ _iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF, _vm->_font->GetTagFontHandle(), TXT_RIGHT);
- MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
+ MultiSetZPosition(_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
break;
case TOGGLE:
case TOGGLE1:
case TOGGLE2:
- pFilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
+ pFilm = (const FILM *)_vm->_handle->LockMem(_hWinParts);
cd.box[i].bi = *pival ? IX_TICK1 : IX_CROSS1;
- g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + NORMGRAPH], -1);
- MultiSetAniXY(g_iconArray[*pi], x, y);
- MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);
+ _iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + NORMGRAPH], -1);
+ MultiSetAniXY(_iconArray[*pi], x, y);
+ MultiSetZPosition(_iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1;
// Stick in the text
@@ -2464,39 +2464,39 @@ void Dialogs::AddBox(int *pi, const int i) {
LoadStringRes(SysString(cd.box[i].ixText), _vm->_font->TextBufferAddr(), TBUFSZ);
} else {
assert(cd.box[i].ixText != USE_POINTER);
- LoadStringRes(g_configStrings[cd.box[i].ixText], _vm->_font->TextBufferAddr(), TBUFSZ);
+ LoadStringRes(_configStrings[cd.box[i].ixText], _vm->_font->TextBufferAddr(), TBUFSZ);
}
if (cd.box[i].boxType == TOGGLE2) {
- g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
+ _iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF,
_vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
} else {
- g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
+ _iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF,
_vm->_font->GetTagFontHandle(), TXT_RIGHT, 0);
}
- MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
+ MultiSetZPosition(_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
break;
case SLIDER:
- pFilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
+ pFilm = (const FILM *)_vm->_handle->LockMem(_hWinParts);
xdisp = SLIDE_RANGE * (*pival) / cd.box[i].w;
- g_iconArray[*pi] = AddObject(&pFilm->reels[IX_MDGROOVE], -1);
- MultiSetAniXY(g_iconArray[*pi], x, y);
- MultiSetZPosition(g_iconArray[*pi], Z_MDGROOVE);
+ _iconArray[*pi] = AddObject(&pFilm->reels[IX_MDGROOVE], -1);
+ MultiSetAniXY(_iconArray[*pi], x, y);
+ MultiSetZPosition(_iconArray[*pi], Z_MDGROOVE);
*pi += 1;
- g_iconArray[*pi] = AddObject(&pFilm->reels[IX_MDSLIDER], -1);
- MultiSetAniXY(g_iconArray[*pi], x + SLIDE_MINX + xdisp, y);
- MultiSetZPosition(g_iconArray[*pi], Z_MDSLIDER);
- assert(g_numMdSlides < MAXSLIDES);
- g_mdSlides[g_numMdSlides].num = i;
- g_mdSlides[g_numMdSlides].min = x + SLIDE_MINX;
- g_mdSlides[g_numMdSlides].max = x + SLIDE_MAXX;
- g_mdSlides[g_numMdSlides++].obj = g_iconArray[*pi];
+ _iconArray[*pi] = AddObject(&pFilm->reels[IX_MDSLIDER], -1);
+ MultiSetAniXY(_iconArray[*pi], x + SLIDE_MINX + xdisp, y);
+ MultiSetZPosition(_iconArray[*pi], Z_MDSLIDER);
+ assert(_numMdSlides < MAXSLIDES);
+ _mdSlides[_numMdSlides].num = i;
+ _mdSlides[_numMdSlides].min = x + SLIDE_MINX;
+ _mdSlides[_numMdSlides].max = x + SLIDE_MAXX;
+ _mdSlides[_numMdSlides++].obj = _iconArray[*pi];
*pi += 1;
// Stick in the text
@@ -2505,55 +2505,55 @@ void Dialogs::AddBox(int *pi, const int i) {
LoadStringRes(SysString(cd.box[i].ixText), _vm->_font->TextBufferAddr(), TBUFSZ);
} else {
assert(cd.box[i].ixText != USE_POINTER);
- LoadStringRes(g_configStrings[cd.box[i].ixText], _vm->_font->TextBufferAddr(), TBUFSZ);
+ LoadStringRes(_configStrings[cd.box[i].ixText], _vm->_font->TextBufferAddr(), TBUFSZ);
}
- g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
+ _iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF, _vm->_font->GetTagFontHandle(), TXT_RIGHT);
- MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
+ MultiSetZPosition(_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
break;
case ROTATE:
- pFilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
+ pFilm = (const FILM *)_vm->_handle->LockMem(_hWinParts);
// Left one
- if (!g_bNoLanguage) {
- g_iconArray[*pi] = AddObject(&pFilm->reels[IX2_LEFT1], -1);
- MultiSetAniXY(g_iconArray[*pi], x - ROTX1, y);
- MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);
+ if (!_noLanguage) {
+ _iconArray[*pi] = AddObject(&pFilm->reels[IX2_LEFT1], -1);
+ MultiSetAniXY(_iconArray[*pi], x - ROTX1, y);
+ MultiSetZPosition(_iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1;
// Right one
- g_iconArray[*pi] = AddObject(&pFilm->reels[IX2_RIGHT1], -1);
- MultiSetAniXY(g_iconArray[*pi], x + ROTX1, y);
- MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);
+ _iconArray[*pi] = AddObject(&pFilm->reels[IX2_RIGHT1], -1);
+ MultiSetAniXY(_iconArray[*pi], x + ROTX1, y);
+ MultiSetZPosition(_iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1;
// Stick in the text
assert(cd.box[i].textMethod == TM_INDEX);
LoadStringRes(SysString(cd.box[i].ixText), _vm->_font->TextBufferAddr(), TBUFSZ);
- g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
+ _iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF,
_vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
- MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
+ MultiSetZPosition(_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
}
// Current language's text
- if (LanguageDesc(g_displayedLanguage) == 0)
+ if (LanguageDesc(_displayedLanguage) == 0)
break;
- LoadStringRes(LanguageDesc(g_displayedLanguage), _vm->_font->TextBufferAddr(), TBUFSZ);
- g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), 0,
+ LoadStringRes(LanguageDesc(_displayedLanguage), _vm->_font->TextBufferAddr(), TBUFSZ);
+ _iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), 0,
x + cd.box[i].w / 2, y + ROT_YOFF, _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
- MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
+ MultiSetZPosition(_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
// Current language's flag
- pFilm = (const FILM *)_vm->_handle->LockMem(LanguageFlag(g_displayedLanguage));
- g_iconArray[*pi] = AddObject(&pFilm->reels[0], -1);
- MultiSetAniXY(g_iconArray[*pi], x + FLAGX, y + FLAGY);
- MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);
+ pFilm = (const FILM *)_vm->_handle->LockMem(LanguageFlag(_displayedLanguage));
+ _iconArray[*pi] = AddObject(&pFilm->reels[0], -1);
+ MultiSetAniXY(_iconArray[*pi], x + FLAGX, y + FLAGY);
+ MultiSetZPosition(_iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1;
break;
}
@@ -2566,7 +2566,7 @@ void Dialogs::AddBoxes(bool bPosnSlide) {
int objCount = NUMHL; // Object count - allow for HL1, HL2 etc.
DumpIconArray();
- g_numMdSlides = 0;
+ _numMdSlides = 0;
for (int i = 0; i < cd.NumBoxes; i++) {
AddBox(&objCount, i);
@@ -2574,32 +2574,32 @@ void Dialogs::AddBoxes(bool bPosnSlide) {
if (cd.bExtraWin) {
if (bPosnSlide && !TinselV2)
- g_sliderYpos = g_sliderYmin + (cd.extraBase * (g_sliderYmax - g_sliderYmin)) / (MAX_SAVED_FILES - NUM_RGROUP_BOXES);
+ _sliderYpos = _sliderYmin + (cd.extraBase * (_sliderYmax - _sliderYmin)) / (MAX_SAVED_FILES - NUM_RGROUP_BOXES);
else if (bPosnSlide) {
// Tinsel 2 bPosnSlide code
- int lastY = g_sliderYpos;
+ int lastY = _sliderYpos;
if (cd.box == loadBox || cd.box == saveBox)
- g_sliderYpos = g_sliderYmin + (cd.extraBase * (sliderRange)) /
+ _sliderYpos = _sliderYmin + (cd.extraBase * (sliderRange)) /
(MAX_SAVED_FILES - NUM_RGROUP_BOXES);
else if (cd.box == hopperBox1) {
- if (g_numScenes <= NUM_RGROUP_BOXES)
- g_sliderYpos = g_sliderYmin;
+ if (_numScenes <= NUM_RGROUP_BOXES)
+ _sliderYpos = _sliderYmin;
else
- g_sliderYpos = g_sliderYmin + (cd.extraBase * (sliderRange)) / (g_numScenes - NUM_RGROUP_BOXES);
+ _sliderYpos = _sliderYmin + (cd.extraBase * (sliderRange)) / (_numScenes - NUM_RGROUP_BOXES);
} else if (cd.box == hopperBox2) {
- if (g_numEntries <= NUM_RGROUP_BOXES)
- g_sliderYpos = g_sliderYmin;
+ if (_numEntries <= NUM_RGROUP_BOXES)
+ _sliderYpos = _sliderYmin;
else
- g_sliderYpos = g_sliderYmin + (cd.extraBase * (sliderRange)) /
- (g_numEntries - NUM_RGROUP_BOXES);
+ _sliderYpos = _sliderYmin + (cd.extraBase * (sliderRange)) /
+ (_numEntries - NUM_RGROUP_BOXES);
}
- MultiMoveRelXY(g_SlideObject, 0, g_sliderYpos - lastY);
+ MultiMoveRelXY(_slideObject, 0, _sliderYpos - lastY);
}
if (!TinselV2)
- MultiSetAniXY(g_SlideObject, g_InvD[g_ino].inventoryX + 24 + 179, g_sliderYpos);
+ MultiSetAniXY(_slideObject, _invD[_activeInv].inventoryX + 24 + 179, _sliderYpos);
}
assert(objCount < MAX_ICONS); // added too many icons
@@ -2609,8 +2609,8 @@ void Dialogs::AddBoxes(bool bPosnSlide) {
* Display the scroll bar slider.
*/
void Dialogs::AddEWSlider(OBJECT **slide, const FILM *pfilm) {
- g_SlideObject = *slide = AddObject(&pfilm->reels[IX_SLIDE], -1);
- MultiSetAniXY(*slide, g_InvD[g_ino].inventoryX + 24 + 127, g_sliderYpos);
+ _slideObject = *slide = AddObject(&pfilm->reels[IX_SLIDE], -1);
+ MultiSetAniXY(*slide, _invD[_activeInv].inventoryX + 24 + 127, _sliderYpos);
MultiSetZPosition(*slide, Z_INV_MFRAME);
}
@@ -2622,7 +2622,7 @@ int Dialogs::AddExtraWindow(int x, int y, OBJECT **retObj) {
const FILM *pfilm;
// Get the frame's data
- pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
+ pfilm = (const FILM *)_vm->_handle->LockMem(_hWinParts);
x += TinselV2 ? 30 : 20;
y += TinselV2 ? 38 : 24;
@@ -2633,55 +2633,55 @@ int Dialogs::AddExtraWindow(int x, int y, OBJECT **retObj) {
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
retObj[n] = AddObject(&pfilm->reels[IX_NTR], -1); // Top right
- MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth + 312 : 152), y);
+ MultiSetAniXY(retObj[n], x + (TinselV2 ? _TLwidth + 312 : 152), y);
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
retObj[n] = AddObject(&pfilm->reels[IX_BL], -1); // Bottom left
- MultiSetAniXY(retObj[n], x, y + (TinselV2 ? g_TLheight + 208 : 124));
+ MultiSetAniXY(retObj[n], x, y + (TinselV2 ? _TLheight + 208 : 124));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
retObj[n] = AddObject(&pfilm->reels[IX_BR], -1); // Bottom right
- MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth + 312 : 152),
- y + (TinselV2 ? g_TLheight + 208 : 124));
+ MultiSetAniXY(retObj[n], x + (TinselV2 ? _TLwidth + 312 : 152),
+ y + (TinselV2 ? _TLheight + 208 : 124));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
// Draw the edges
retObj[n] = AddObject(&pfilm->reels[IX_H156], -1); // Top
- MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth : 6), y + NM_TBT);
+ MultiSetAniXY(retObj[n], x + (TinselV2 ? _TLwidth : 6), y + NM_TBT);
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
retObj[n] = AddObject(&pfilm->reels[IX_H156], -1); // Bottom
- MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth : 6), y + (TinselV2 ? g_TLheight + 208 + g_BLheight + NM_BSY : 143));
+ MultiSetAniXY(retObj[n], x + (TinselV2 ? _TLwidth : 6), y + (TinselV2 ? _TLheight + 208 + _BLheight + NM_BSY : 143));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
retObj[n] = AddObject(&pfilm->reels[IX_V104], -1); // Left
- MultiSetAniXY(retObj[n], x + NM_LSX, y + (TinselV2 ? g_TLheight : 20));
+ MultiSetAniXY(retObj[n], x + NM_LSX, y + (TinselV2 ? _TLheight : 20));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
retObj[n] = AddObject(&pfilm->reels[IX_V104], -1); // Right 1
- MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth + 312 + g_TRwidth + NM_RSX : 179),
- y + (TinselV2 ? g_TLheight : 20));
+ MultiSetAniXY(retObj[n], x + (TinselV2 ? _TLwidth + 312 + _TRwidth + NM_RSX : 179),
+ y + (TinselV2 ? _TLheight : 20));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
retObj[n] = AddObject(&pfilm->reels[IX_V104], -1); // Right 2
- MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth + 312 + g_TRwidth + NM_SBL : 188),
- y + (TinselV2 ? g_TLheight : 20));
+ MultiSetAniXY(retObj[n], x + (TinselV2 ? _TLwidth + 312 + _TRwidth + NM_SBL : 188),
+ y + (TinselV2 ? _TLheight : 20));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
if (TinselV2) {
- g_sliderYpos = g_sliderYmin = y + 27;
- g_sliderYmax = y + 273;
-
- retObj[n++] = g_SlideObject = AddObject(&pfilm->reels[IX_SLIDE], -1);
- MultiSetAniXY(g_SlideObject,
- x + g_TLwidth + 320 + g_TRwidth - NM_BG_POS_X + NM_BG_SIZ_X - 2,
- g_sliderYpos);
- MultiSetZPosition(g_SlideObject, Z_INV_MFRAME);
+ _sliderYpos = _sliderYmin = y + 27;
+ _sliderYmax = y + 273;
+
+ retObj[n++] = _slideObject = AddObject(&pfilm->reels[IX_SLIDE], -1);
+ MultiSetAniXY(_slideObject,
+ x + _TLwidth + 320 + _TRwidth - NM_BG_POS_X + NM_BG_SIZ_X - 2,
+ _sliderYpos);
+ MultiSetZPosition(_slideObject, Z_INV_MFRAME);
} else {
- g_sliderYpos = g_sliderYmin = y + 9;
- g_sliderYmax = y + 134;
+ _sliderYpos = _sliderYmin = y + 9;
+ _sliderYmax = y + 134;
AddEWSlider(&retObj[n++], pfilm);
}
@@ -2696,17 +2696,17 @@ void Dialogs::ConstructInventory(InventoryType filling) {
int eH, eV; // Extra width and height
int n = 0; // Index into object array
int zpos; // Z-position of frame
- int invX = g_InvD[g_ino].inventoryX;
- int invY = g_InvD[g_ino].inventoryY;
+ int invX = _invD[_activeInv].inventoryX;
+ int invY = _invD[_activeInv].inventoryY;
OBJECT **retObj;
const FILM *pfilm;
// Select the object array to use
if (filling == FULL || filling == CONF) {
- retObj = g_objArray; // Standard window
+ retObj = _objArray; // Standard window
zpos = Z_INV_MFRAME;
} else {
- retObj = g_DobjArray; // Re-sizing window
+ retObj = _dispObjArray; // Re-sizing window
zpos = Z_INV_RFRAME;
}
@@ -2719,83 +2719,83 @@ void Dialogs::ConstructInventory(InventoryType filling) {
}
// Get the frame's data
- pfilm = (const FILM *)_vm->_handle->LockMem(g_hWinParts);
+ pfilm = (const FILM *)_vm->_handle->LockMem(_hWinParts);
// Standard window is of granular dimensions
if (filling == FULL) {
// Round-up/down to nearest number of icons
- if (g_SuppH > ITEM_WIDTH / 2)
- g_InvD[g_ino].NoofHicons++;
- if (g_SuppV > ITEM_HEIGHT / 2)
- g_InvD[g_ino].NoofVicons++;
- g_SuppH = g_SuppV = 0;
+ if (_SuppH > ITEM_WIDTH / 2)
+ _invD[_activeInv].NoofHicons++;
+ if (_SuppV > ITEM_HEIGHT / 2)
+ _invD[_activeInv].NoofVicons++;
+ _SuppH = _SuppV = 0;
}
// Extra width and height
- eH = (g_InvD[g_ino].NoofHicons - 1) * (ITEM_WIDTH + I_SEPARATION) + g_SuppH;
- eV = (g_InvD[g_ino].NoofVicons - 1) * (ITEM_HEIGHT + I_SEPARATION) + g_SuppV;
+ eH = (_invD[_activeInv].NoofHicons - 1) * (ITEM_WIDTH + I_SEPARATION) + _SuppH;
+ eV = (_invD[_activeInv].NoofVicons - 1) * (ITEM_HEIGHT + I_SEPARATION) + _SuppV;
// Which window frame corners to use
- if (TinselV2 && (g_ino == INV_CONV)) {
- g_TL = IX_TL;
- g_TR = IX2_TR4;
- g_BL = IX_BL;
- g_BR = IX_RBR;
- } else if ((filling == FULL) && (g_ino != INV_CONV)) {
- g_TL = IX_TL;
- g_TR = IX_TR;
- g_BL = IX_BL;
- g_BR = IX_BR;
+ if (TinselV2 && (_activeInv == INV_CONV)) {
+ _TL = IX_TL;
+ _TR = IX2_TR4;
+ _BL = IX_BL;
+ _BR = IX_RBR;
+ } else if ((filling == FULL) && (_activeInv != INV_CONV)) {
+ _TL = IX_TL;
+ _TR = IX_TR;
+ _BL = IX_BL;
+ _BR = IX_BR;
} else {
- g_TL = IX_RTL;
- g_TR = IX_RTR;
- g_BL = IX_BL;
- g_BR = IX_RBR;
+ _TL = IX_RTL;
+ _TR = IX_RTR;
+ _BL = IX_BL;
+ _BR = IX_RBR;
}
// Draw the four corners
- retObj[n] = AddObject(&pfilm->reels[g_TL], g_TL);
+ retObj[n] = AddObject(&pfilm->reels[_TL], _TL);
MultiSetAniXY(retObj[n], invX, invY);
MultiSetZPosition(retObj[n], zpos);
n++;
- retObj[n] = AddObject(&pfilm->reels[g_TR], g_TR);
- MultiSetAniXY(retObj[n], invX + g_TLwidth + eH, invY);
+ retObj[n] = AddObject(&pfilm->reels[_TR], _TR);
+ MultiSetAniXY(retObj[n], invX + _TLwidth + eH, invY);
MultiSetZPosition(retObj[n], zpos);
n++;
- retObj[n] = AddObject(&pfilm->reels[g_BL], g_BL);
- MultiSetAniXY(retObj[n], invX, invY + g_TLheight + eV);
+ retObj[n] = AddObject(&pfilm->reels[_BL], _BL);
+ MultiSetAniXY(retObj[n], invX, invY + _TLheight + eV);
MultiSetZPosition(retObj[n], zpos);
n++;
- retObj[n] = AddObject(&pfilm->reels[g_BR], g_BR);
- MultiSetAniXY(retObj[n], invX + g_TLwidth + eH, invY + g_TLheight + eV);
+ retObj[n] = AddObject(&pfilm->reels[_BR], _BR);
+ MultiSetAniXY(retObj[n], invX + _TLwidth + eH, invY + _TLheight + eV);
MultiSetZPosition(retObj[n], zpos);
n++;
// Draw extra Top and bottom parts
- if (g_InvD[g_ino].NoofHicons > 1) {
+ if (_invD[_activeInv].NoofHicons > 1) {
// Top side
- retObj[n] = AddObject(&pfilm->reels[hFillers[g_InvD[g_ino].NoofHicons - 2]], -1);
- MultiSetAniXY(retObj[n], invX + g_TLwidth, invY + NM_TBT);
+ retObj[n] = AddObject(&pfilm->reels[hFillers[_invD[_activeInv].NoofHicons - 2]], -1);
+ MultiSetAniXY(retObj[n], invX + _TLwidth, invY + NM_TBT);
MultiSetZPosition(retObj[n], zpos);
n++;
// Bottom of header box
if (filling == FULL) {
if (TinselV2) {
- retObj[n] = AddObject(&pfilm->reels[hFillers[g_InvD[g_ino].NoofHicons - 2]], -1);
- MultiSetAniXY(retObj[n], invX + g_TLwidth, invY + NM_TBB);
+ retObj[n] = AddObject(&pfilm->reels[hFillers[_invD[_activeInv].NoofHicons - 2]], -1);
+ MultiSetAniXY(retObj[n], invX + _TLwidth, invY + NM_TBB);
MultiSetZPosition(retObj[n], zpos);
n++;
} else {
- retObj[n] = AddObject(&pfilm->reels[hFillers[g_InvD[g_ino].NoofHicons - 2]], -1);
- MultiSetAniXY(retObj[n], invX + g_TLwidth, invY + M_TBB + 1);
+ retObj[n] = AddObject(&pfilm->reels[hFillers[_invD[_activeInv].NoofHicons - 2]], -1);
+ MultiSetAniXY(retObj[n], invX + _TLwidth, invY + M_TBB + 1);
MultiSetZPosition(retObj[n], zpos);
n++;
// Extra bits for conversation - hopefully temporary
- if (g_ino == INV_CONV) {
+ if (_activeInv == INV_CONV) {
retObj[n] = AddObject(&pfilm->reels[IX_H26], -1);
- MultiSetAniXY(retObj[n], invX + g_TLwidth - 2, invY + M_TBB + 1);
+ MultiSetAniXY(retObj[n], invX + _TLwidth - 2, invY + M_TBB + 1);
MultiSetZPosition(retObj[n], zpos);
n++;
@@ -2808,16 +2808,16 @@ void Dialogs::ConstructInventory(InventoryType filling) {
}
// Bottom side
- retObj[n] = AddObject(&pfilm->reels[hFillers[g_InvD[g_ino].NoofHicons - 2]], -1);
- MultiSetAniXY(retObj[n], invX + g_TLwidth, invY + g_TLheight + eV + g_BLheight + NM_BSY);
+ retObj[n] = AddObject(&pfilm->reels[hFillers[_invD[_activeInv].NoofHicons - 2]], -1);
+ MultiSetAniXY(retObj[n], invX + _TLwidth, invY + _TLheight + eV + _BLheight + NM_BSY);
MultiSetZPosition(retObj[n], zpos);
n++;
}
- if (g_SuppH) {
- int offx = g_TLwidth + eH - (TinselV2 ? ITEM_WIDTH + I_SEPARATION : 26);
- if (offx < g_TLwidth) // Not too far!
- offx = g_TLwidth;
+ if (_SuppH) {
+ int offx = _TLwidth + eH - (TinselV2 ? ITEM_WIDTH + I_SEPARATION : 26);
+ if (offx < _TLwidth) // Not too far!
+ offx = _TLwidth;
// Top side extra
retObj[n] = AddObject(&pfilm->reels[IX_H26], -1);
@@ -2827,39 +2827,39 @@ void Dialogs::ConstructInventory(InventoryType filling) {
// Bottom side extra
retObj[n] = AddObject(&pfilm->reels[IX_H26], -1);
- MultiSetAniXY(retObj[n], invX + offx, invY + g_TLheight + eV + g_BLheight + NM_BSY);
+ MultiSetAniXY(retObj[n], invX + offx, invY + _TLheight + eV + _BLheight + NM_BSY);
MultiSetZPosition(retObj[n], zpos);
n++;
}
// Draw extra side parts
- if (g_InvD[g_ino].NoofVicons > 1) {
+ if (_invD[_activeInv].NoofVicons > 1) {
// Left side
- retObj[n] = AddObject(&pfilm->reels[vFillers[g_InvD[g_ino].NoofVicons - 2]], -1);
- MultiSetAniXY(retObj[n], invX + NM_LSX, invY + g_TLheight);
+ retObj[n] = AddObject(&pfilm->reels[vFillers[_invD[_activeInv].NoofVicons - 2]], -1);
+ MultiSetAniXY(retObj[n], invX + NM_LSX, invY + _TLheight);
MultiSetZPosition(retObj[n], zpos);
n++;
// Left side of scroll bar
- if (filling == FULL && g_ino != INV_CONV) {
- retObj[n] = AddObject(&pfilm->reels[vFillers[g_InvD[g_ino].NoofVicons - 2]], -1);
+ if (filling == FULL && _activeInv != INV_CONV) {
+ retObj[n] = AddObject(&pfilm->reels[vFillers[_invD[_activeInv].NoofVicons - 2]], -1);
if (TinselV2)
- MultiSetAniXY(retObj[n], invX + g_TLwidth + eH + g_TRwidth + NM_SBL, invY + g_TLheight);
+ MultiSetAniXY(retObj[n], invX + _TLwidth + eH + _TRwidth + NM_SBL, invY + _TLheight);
else
- MultiSetAniXY(retObj[n], invX + g_TLwidth + eH + M_SBL + 1, invY + g_TLheight);
+ MultiSetAniXY(retObj[n], invX + _TLwidth + eH + M_SBL + 1, invY + _TLheight);
MultiSetZPosition(retObj[n], zpos);
n++;
}
// Right side
- retObj[n] = AddObject(&pfilm->reels[vFillers[g_InvD[g_ino].NoofVicons - 2]], -1);
- MultiSetAniXY(retObj[n], invX + g_TLwidth + eH + g_TRwidth + NM_RSX, invY + g_TLheight);
+ retObj[n] = AddObject(&pfilm->reels[vFillers[_invD[_activeInv].NoofVicons - 2]], -1);
+ MultiSetAniXY(retObj[n], invX + _TLwidth + eH + _TRwidth + NM_RSX, invY + _TLheight);
MultiSetZPosition(retObj[n], zpos);
n++;
}
- if (g_SuppV) {
- int offy = g_TLheight + eV - (TinselV2 ? ITEM_HEIGHT + I_SEPARATION : 26);
+ if (_SuppV) {
+ int offy = _TLheight + eV - (TinselV2 ? ITEM_HEIGHT + I_SEPARATION : 26);
int minAmount = TinselV2 ? 20 : 5;
if (offy < minAmount)
offy = minAmount;
@@ -2872,7 +2872,7 @@ void Dialogs::ConstructInventory(InventoryType filling) {
// Right side extra
retObj[n] = AddObject(&pfilm->reels[IX_V26], -1);
- MultiSetAniXY(retObj[n], invX + g_TLwidth + eH + g_TRwidth + NM_RSX, invY + offy);
+ MultiSetAniXY(retObj[n], invX + _TLwidth + eH + _TRwidth + NM_RSX, invY + offy);
MultiSetZPosition(retObj[n], zpos);
n++;
}
@@ -2893,20 +2893,20 @@ void Dialogs::ConstructInventory(InventoryType filling) {
AddBackground(rect, title, eH, eV, FROM_HANDLE);
}
- if (g_ino == INV_CONV) {
- g_SlideObject = nullptr;
+ if (_activeInv == INV_CONV) {
+ _slideObject = nullptr;
if (TinselV2) {
// !!!!! MAGIC NUMBER ALERT !!!!!
// Make sure it's big enough for the heading
- if (MultiLeftmost(retObj[n - 1]) < g_InvD[INV_CONV].inventoryX + 10) {
- g_InvD[INV_CONV].NoofHicons++;
+ if (MultiLeftmost(retObj[n - 1]) < _invD[INV_CONV].inventoryX + 10) {
+ _invD[INV_CONV].NoofHicons++;
ConstructInventory(FULL);
}
}
- } else if (g_InvD[g_ino].NoofItems > g_InvD[g_ino].NoofHicons * g_InvD[g_ino].NoofVicons) {
- g_sliderYmin = g_TLheight - (TinselV2 ? 1 : 2);
- g_sliderYmax = g_TLheight + eV + (TinselV2 ? 12 : 10);
+ } else if (_invD[_activeInv].NoofItems > _invD[_activeInv].NoofHicons * _invD[_activeInv].NoofVicons) {
+ _sliderYmin = _TLheight - (TinselV2 ? 1 : 2);
+ _sliderYmax = _TLheight + eV + (TinselV2 ? 12 : 10);
AddSlider(&retObj[n++], pfilm);
}
@@ -2930,7 +2930,7 @@ void Dialogs::ConstructInventory(InventoryType filling) {
assert(n < MAX_WCOMP); // added more parts than we can handle!
// Reposition returns true if needs to move
- if (g_InvD[g_ino].bMoveable && filling == FULL && RePosition()) {
+ if (_invD[_activeInv].bMoveable && filling == FULL && RePosition()) {
ConstructInventory(FULL);
}
}
@@ -2944,32 +2944,32 @@ bool Dialogs::RePosition() {
int p;
bool bMoveitMoveit = false;
- assert(g_RectObject); // no recangle object!
+ assert(_rectObject); // no recangle object!
// Test for off-screen horizontally
- p = MultiLeftmost(g_RectObject);
+ p = MultiLeftmost(_rectObject);
if (p > MAXLEFT) {
// Too far to the right
- g_InvD[g_ino].inventoryX += MAXLEFT - p;
+ _invD[_activeInv].inventoryX += MAXLEFT - p;
bMoveitMoveit = true; // I like to....
} else {
// Too far to the left?
- p = MultiRightmost(g_RectObject);
+ p = MultiRightmost(_rectObject);
if (p < MINRIGHT) {
- g_InvD[g_ino].inventoryX += MINRIGHT - p;
+ _invD[_activeInv].inventoryX += MINRIGHT - p;
bMoveitMoveit = true; // I like to....
}
}
// Test for off-screen vertically
- p = MultiHighest(g_RectObject);
+ p = MultiHighest(_rectObject);
if (p < MINTOP) {
// Too high
- g_InvD[g_ino].inventoryY += MINTOP - p;
+ _invD[_activeInv].inventoryY += MINTOP - p;
bMoveitMoveit = true; // I like to....
} else if (p > MAXTOP) {
// Too low
- g_InvD[g_ino].inventoryY += MAXTOP - p;
+ _invD[_activeInv].inventoryY += MAXTOP - p;
bMoveitMoveit = true; // I like to....
}
@@ -2989,7 +2989,7 @@ void Dialogs::AlterCursor(int num) {
IMAGE *pim;
// Get pointer to image
- pim = _vm->_cursor->GetImageFromFilm(g_hWinParts, num, &pfreel);
+ pim = _vm->_cursor->GetImageFromFilm(_hWinParts, num, &pfreel);
// Poke in the background palette
pim->hImgPal = TO_32(_vm->_bg->BgPal());
@@ -3005,7 +3005,7 @@ void Dialogs::InvCursor(InvCursorFN fn, int CurX, int CurY) {
bool restoreMain = false;
// If currently dragging, don't be messing about with the cursor shape
- if (g_InvDragging != ID_NONE)
+ if (_invDragging != ID_NONE)
return;
switch (fn) {
@@ -3018,7 +3018,7 @@ void Dialogs::InvCursor(InvCursorFN fn, int CurX, int CurY) {
area = InvArea(CurX, CurY);
// Check for POINTED events
- if (g_ino == INV_CONF)
+ if (_activeInv == INV_CONF)
InvBoxes(area == I_BODY, CurX, CurY);
else
InvLabels(area == I_BODY, CurX, CurY);
@@ -3036,7 +3036,7 @@ void Dialogs::InvCursor(InvCursorFN fn, int CurX, int CurY) {
case I_TLEFT:
case I_BRIGHT:
- if (!g_InvD[g_ino].resizable)
+ if (!_invD[_activeInv].resizable)
restoreMain = true;
else if (ICursor != IC_DR) {
AlterCursor(IX_CURDD);
@@ -3046,7 +3046,7 @@ void Dialogs::InvCursor(InvCursorFN fn, int CurX, int CurY) {
case I_TRIGHT:
case I_BLEFT:
- if (!g_InvD[g_ino].resizable)
+ if (!_invD[_activeInv].resizable)
restoreMain = true;
else if (ICursor != IC_UR) {
AlterCursor(IX_CURDU);
@@ -3056,7 +3056,7 @@ void Dialogs::InvCursor(InvCursorFN fn, int CurX, int CurY) {
case I_TOP:
case I_BOTTOM:
- if (!g_InvD[g_ino].resizable) {
+ if (!_invD[_activeInv].resizable) {
restoreMain = true;
break;
}
@@ -3068,7 +3068,7 @@ void Dialogs::InvCursor(InvCursorFN fn, int CurX, int CurY) {
case I_LEFT:
case I_RIGHT:
- if (!g_InvD[g_ino].resizable)
+ if (!_invD[_activeInv].resizable)
restoreMain = true;
else if (ICursor != IC_LR) {
AlterCursor(IX_CURLR);
@@ -3108,7 +3108,7 @@ void Dialogs::InvCursor(InvCursorFN fn, int CurX, int CurY) {
/**************************************************************************/
void Dialogs::ConvAction(int index) {
- assert(g_ino == INV_CONV); // not conv. window!
+ assert(_activeInv == INV_CONV); // not conv. window!
PMOVER pMover = TinselV2 ? GetMover(_vm->_actor->GetLeadId()) : NULL;
switch (index) {
@@ -3116,36 +3116,36 @@ void Dialogs::ConvAction(int index) {
return;
case INV_CLOSEICON:
- g_thisIcon = -1; // Postamble
+ _thisIcon = -1; // Postamble
break;
case INV_OPENICON:
// Store the direction the lead character is facing in when the conversation starts
if (TinselV2)
- g_initialDirection = GetMoverDirection(pMover);
- g_thisIcon = -2; // Preamble
+ _initialDirection = GetMoverDirection(pMover);
+ _thisIcon = -2; // Preamble
break;
default:
- g_thisIcon = g_InvD[g_ino].contents[index];
+ _thisIcon = _invD[_activeInv].contents[index];
break;
}
if (!TinselV2)
- RunPolyTinselCode(g_thisConvPoly, CONVERSE, PLR_NOEVENT, true);
+ RunPolyTinselCode(_thisConvPoly, CONVERSE, PLR_NOEVENT, true);
else {
// If the lead's direction has changed for any reason (such as having broken the
// fourth wall and talked to the screen), reset back to the original direction
DIRECTION currDirection = GetMoverDirection(pMover);
- if (currDirection != g_initialDirection) {
- SetMoverDirection(pMover, g_initialDirection);
+ if (currDirection != _initialDirection) {
+ SetMoverDirection(pMover, _initialDirection);
SetMoverStanding(pMover);
}
- if (g_thisConvPoly != NOPOLY)
- PolygonEvent(Common::nullContext, g_thisConvPoly, CONVERSE, 0, false, 0);
+ if (_thisConvPoly != NOPOLY)
+ PolygonEvent(Common::nullContext, _thisConvPoly, CONVERSE, 0, false, 0);
else
- ActorEvent(Common::nullContext, g_thisConvActor, CONVERSE, false, 0);
+ ActorEvent(Common::nullContext, _thisConvActor, CONVERSE, false, 0);
}
}
@@ -3157,18 +3157,18 @@ void Dialogs::ConvAction(int index) {
* Note: ano may (will probably) be set when it's a polygon.
*/
void Dialogs::SetConvDetails(CONV_PARAM fn, HPOLYGON hPoly, int ano) {
- g_thisConvFn = fn;
- g_thisConvPoly = hPoly;
- g_thisConvActor = ano;
+ _thisConvFn = fn;
+ _thisConvPoly = hPoly;
+ _thisConvActor = ano;
- g_bMoveOnUnHide = true;
+ _bMoveOnUnHide = true;
// Get the Actor Tag's or Tagged Actor's label for the conversation window title
if (hPoly != NOPOLY) {
int x, y;
- GetTagTag(hPoly, &g_InvD[INV_CONV].hInvTitle, &x, &y);
+ GetTagTag(hPoly, &_invD[INV_CONV].hInvTitle, &x, &y);
} else {
- g_InvD[INV_CONV].hInvTitle = _vm->_actor->GetActorTagHandle(ano);
+ _invD[INV_CONV].hInvTitle = _vm->_actor->GetActorTagHandle(ano);
}
}
@@ -3181,27 +3181,27 @@ void Dialogs::PermaConvIcon(int icon, bool bEnd) {
int i;
// See if it's already there
- for (i = 0; i < g_numPermIcons; i++) {
- if (g_permIcons[i] == icon)
+ for (i = 0; i < _numPermIcons; i++) {
+ if (_permIcons[i] == icon)
break;
}
// Add it if it isn't already there
- if (i == g_numPermIcons) {
- assert(g_numPermIcons < MAX_PERMICONS);
+ if (i == _numPermIcons) {
+ assert(_numPermIcons < MAX_PERMICONS);
- if (bEnd || !g_numEndIcons) {
+ if (bEnd || !_numEndIcons) {
// Add it at the end
- g_permIcons[g_numPermIcons++] = icon;
+ _permIcons[_numPermIcons++] = icon;
if (bEnd)
- g_numEndIcons++;
+ _numEndIcons++;
} else {
// Insert before end icons
- memmove(&g_permIcons[g_numPermIcons - g_numEndIcons + 1],
- &g_permIcons[g_numPermIcons - g_numEndIcons],
- g_numEndIcons * sizeof(int));
- g_permIcons[g_numPermIcons - g_numEndIcons] = icon;
- g_numPermIcons++;
+ memmove(&_permIcons[_numPermIcons - _numEndIcons + 1],
+ &_permIcons[_numPermIcons - _numEndIcons],
+ _numEndIcons * sizeof(int));
+ _permIcons[_numPermIcons - _numEndIcons] = icon;
+ _numPermIcons++;
}
}
}
@@ -3210,21 +3210,21 @@ void Dialogs::PermaConvIcon(int icon, bool bEnd) {
void Dialogs::convPos(int fn) {
if (fn == CONV_DEF)
- g_InvD[INV_CONV].inventoryY = 8;
+ _invD[INV_CONV].inventoryY = 8;
else if (fn == CONV_BOTTOM)
- g_InvD[INV_CONV].inventoryY = 150;
+ _invD[INV_CONV].inventoryY = 150;
}
void Dialogs::ConvPoly(HPOLYGON hPoly) {
- g_thisConvPoly = hPoly;
+ _thisConvPoly = hPoly;
}
int Dialogs::GetIcon() {
- return g_thisIcon;
+ return _thisIcon;
}
void Dialogs::CloseDownConv() {
- if (g_InventoryState == ACTIVE_INV && g_ino == INV_CONV) {
+ if (_inventoryState == ACTIVE_INV && _activeInv == INV_CONV) {
KillInventory();
}
}
@@ -3233,43 +3233,43 @@ void Dialogs::HideConversation(bool bHide) {
int aniX, aniY;
int i;
- if (g_InventoryState == ACTIVE_INV && g_ino == INV_CONV) {
+ if (_inventoryState == ACTIVE_INV && _activeInv == INV_CONV) {
if (bHide) {
// Move all the window and icons off-screen
- for (i = 0; i < MAX_WCOMP && g_objArray[i]; i++) {
- MultiAdjustXY(g_objArray[i], 2 * SCREEN_WIDTH, 0);
+ for (i = 0; i < MAX_WCOMP && _objArray[i]; i++) {
+ MultiAdjustXY(_objArray[i], 2 * SCREEN_WIDTH, 0);
}
- for (i = 0; i < MAX_ICONS && g_iconArray[i]; i++) {
- MultiAdjustXY(g_iconArray[i], 2 * SCREEN_WIDTH, 0);
+ for (i = 0; i < MAX_ICONS && _iconArray[i]; i++) {
+ MultiAdjustXY(_iconArray[i], 2 * SCREEN_WIDTH, 0);
}
// Window is hidden
- g_InventoryHidden = true;
+ _InventoryHidden = true;
// Remove any labels
InvLabels(false, 0, 0);
} else {
// Window is not hidden
- g_InventoryHidden = false;
+ _InventoryHidden = false;
- if (TinselV2 && g_ItemsChanged)
+ if (TinselV2 && _ItemsChanged)
// Just rebuild the whole thing
ConstructInventory(FULL);
else {
// Move it all back on-screen
- for (i = 0; i < MAX_WCOMP && g_objArray[i]; i++) {
- MultiAdjustXY(g_objArray[i], -2 * SCREEN_WIDTH, 0);
+ for (i = 0; i < MAX_WCOMP && _objArray[i]; i++) {
+ MultiAdjustXY(_objArray[i], -2 * SCREEN_WIDTH, 0);
}
// Don't flash if items changed. If they have, will be redrawn anyway.
- if (TinselV2 || !g_ItemsChanged) {
- for (i = 0; i < MAX_ICONS && g_iconArray[i]; i++) {
- MultiAdjustXY(g_iconArray[i], -2 * SCREEN_WIDTH, 0);
+ if (TinselV2 || !_ItemsChanged) {
+ for (i = 0; i < MAX_ICONS && _iconArray[i]; i++) {
+ MultiAdjustXY(_iconArray[i], -2 * SCREEN_WIDTH, 0);
}
}
}
- if (TinselV2 && g_bMoveOnUnHide) {
+ if (TinselV2 && _bMoveOnUnHide) {
/*
* First time, position it appropriately
*/
@@ -3277,17 +3277,17 @@ void Dialogs::HideConversation(bool bHide) {
int x, y, deltay;
// Only do it once per conversation
- g_bMoveOnUnHide = false;
+ _bMoveOnUnHide = false;
// Current center of the window
- left = MultiLeftmost(g_RectObject);
- center = (MultiRightmost(g_RectObject) + left) / 2;
+ left = MultiLeftmost(_rectObject);
+ center = (MultiRightmost(_rectObject) + left) / 2;
// Get the x-offset for the conversation window
- if (g_thisConvActor) {
+ if (_thisConvActor) {
int Loffset, Toffset;
- _vm->_actor->GetActorMidTop(g_thisConvActor, &x, &y);
+ _vm->_actor->GetActorMidTop(_thisConvActor, &x, &y);
_vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
x -= Loffset;
y -= Toffset;
@@ -3297,19 +3297,19 @@ void Dialogs::HideConversation(bool bHide) {
}
// Save old y-position
- deltay = g_InvD[INV_CONV].inventoryY;
+ deltay = _invD[INV_CONV].inventoryY;
- switch (g_thisConvFn) {
+ switch (_thisConvFn) {
case CONV_TOP:
- g_InvD[INV_CONV].inventoryY = SysVar(SV_CONV_TOPY);
+ _invD[INV_CONV].inventoryY = SysVar(SV_CONV_TOPY);
break;
case CONV_BOTTOM:
- g_InvD[INV_CONV].inventoryY = SysVar(SV_CONV_BOTY);
+ _invD[INV_CONV].inventoryY = SysVar(SV_CONV_BOTY);
break;
case CONV_DEF:
- g_InvD[INV_CONV].inventoryY = y - SysVar(SV_CONV_ABOVE_Y);
+ _invD[INV_CONV].inventoryY = y - SysVar(SV_CONV_ABOVE_Y);
break;
default:
@@ -3317,61 +3317,61 @@ void Dialogs::HideConversation(bool bHide) {
}
// Calculate y change
- deltay = g_InvD[INV_CONV].inventoryY - deltay;
+ deltay = _invD[INV_CONV].inventoryY - deltay;
// Move it all
- for (i = 0; i < MAX_WCOMP && g_objArray[i]; i++) {
- MultiMoveRelXY(g_objArray[i], x - center, deltay);
+ for (i = 0; i < MAX_WCOMP && _objArray[i]; i++) {
+ MultiMoveRelXY(_objArray[i], x - center, deltay);
}
- for (i = 0; i < MAX_ICONS && g_iconArray[i]; i++) {
- MultiMoveRelXY(g_iconArray[i], x - center, deltay);
+ for (i = 0; i < MAX_ICONS && _iconArray[i]; i++) {
+ MultiMoveRelXY(_iconArray[i], x - center, deltay);
}
- g_InvD[INV_CONV].inventoryX += x - center;
+ _invD[INV_CONV].inventoryX += x - center;
/*
* Now positioned as worked out
* - but it must be in a sensible place
*/
- if (MultiLeftmost(g_RectObject) < SysVar(SV_CONV_MINX))
- x = SysVar(SV_CONV_MINX) - MultiLeftmost(g_RectObject);
- else if (MultiRightmost(g_RectObject) > SCREEN_WIDTH - SysVar(SV_CONV_MINX))
- x = SCREEN_WIDTH - SysVar(SV_CONV_MINX) - MultiRightmost(g_RectObject);
+ if (MultiLeftmost(_rectObject) < SysVar(SV_CONV_MINX))
+ x = SysVar(SV_CONV_MINX) - MultiLeftmost(_rectObject);
+ else if (MultiRightmost(_rectObject) > SCREEN_WIDTH - SysVar(SV_CONV_MINX))
+ x = SCREEN_WIDTH - SysVar(SV_CONV_MINX) - MultiRightmost(_rectObject);
else
x = 0;
- if (g_thisConvFn == CONV_DEF && MultiHighest(g_RectObject) < SysVar(SV_CONV_MINY) && g_thisConvActor) {
+ if (_thisConvFn == CONV_DEF && MultiHighest(_rectObject) < SysVar(SV_CONV_MINY) && _thisConvActor) {
int Loffset, Toffset;
_vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
- y = _vm->_actor->GetActorBottom(g_thisConvActor) - MultiHighest(g_RectObject) +
+ y = _vm->_actor->GetActorBottom(_thisConvActor) - MultiHighest(_rectObject) +
SysVar(SV_CONV_BELOW_Y);
y -= Toffset;
} else
y = 0;
if (x || y) {
- for (i = 0; i < MAX_WCOMP && g_objArray[i]; i++) {
- MultiMoveRelXY(g_objArray[i], x, y);
+ for (i = 0; i < MAX_WCOMP && _objArray[i]; i++) {
+ MultiMoveRelXY(_objArray[i], x, y);
}
- for (i = 0; i < MAX_ICONS && g_iconArray[i]; i++) {
- MultiMoveRelXY(g_iconArray[i], x, y);
+ for (i = 0; i < MAX_ICONS && _iconArray[i]; i++) {
+ MultiMoveRelXY(_iconArray[i], x, y);
}
- g_InvD[INV_CONV].inventoryX += x;
- g_InvD[INV_CONV].inventoryY += y;
+ _invD[INV_CONV].inventoryX += x;
+ _invD[INV_CONV].inventoryY += y;
}
/*
* Oh shit! We might have gone off the bottom
*/
- if (MultiLowest(g_RectObject) > SCREEN_BOX_HEIGHT2 - SysVar(SV_CONV_MINY)) {
- y = (SCREEN_BOX_HEIGHT2 - SysVar(SV_CONV_MINY)) - MultiLowest(g_RectObject);
- for (i = 0; i < MAX_WCOMP && g_objArray[i]; i++) {
- MultiMoveRelXY(g_objArray[i], 0, y);
+ if (MultiLowest(_rectObject) > SCREEN_BOX_HEIGHT2 - SysVar(SV_CONV_MINY)) {
+ y = (SCREEN_BOX_HEIGHT2 - SysVar(SV_CONV_MINY)) - MultiLowest(_rectObject);
+ for (i = 0; i < MAX_WCOMP && _objArray[i]; i++) {
+ MultiMoveRelXY(_objArray[i], 0, y);
}
- for (i = 0; i < MAX_ICONS && g_iconArray[i]; i++) {
- MultiMoveRelXY(g_iconArray[i], 0, y);
+ for (i = 0; i < MAX_ICONS && _iconArray[i]; i++) {
+ MultiMoveRelXY(_iconArray[i], 0, y);
}
- g_InvD[INV_CONV].inventoryY += y;
+ _invD[INV_CONV].inventoryY += y;
}
}
@@ -3382,7 +3382,7 @@ void Dialogs::HideConversation(bool bHide) {
}
bool Dialogs::ConvIsHidden() {
- return g_InventoryHidden;
+ return _InventoryHidden;
}
/**************************************************************************/
@@ -3395,8 +3395,8 @@ bool Dialogs::ConvIsHidden() {
void Dialogs::PopUpInventory(int invno) {
assert(invno == INV_1 || invno == INV_2 || invno == INV_CONV || invno == INV_CONF || invno == INV_MENU); // Trying to open illegal inventory
- if (g_InventoryState == IDLE_INV) {
- g_bReOpenMenu = false; // Better safe than sorry...
+ if (_inventoryState == IDLE_INV) {
+ _reOpenMenu = false; // Better safe than sorry...
DisableTags(); // Tags disabled during inventory
if (TinselV2)
@@ -3408,25 +3408,25 @@ void Dialogs::PopUpInventory(int invno) {
_vm->_pcmMusic->dim(false);
// Start conversation with permanent contents
- memset(g_InvD[INV_CONV].contents, 0, MAX_ININV * sizeof(int));
- memcpy(g_InvD[INV_CONV].contents, g_permIcons, g_numPermIcons * sizeof(int));
- g_InvD[INV_CONV].NoofItems = g_numPermIcons;
+ memset(_invD[INV_CONV].contents, 0, MAX_ININV * sizeof(int));
+ memcpy(_invD[INV_CONV].contents, _permIcons, _numPermIcons * sizeof(int));
+ _invD[INV_CONV].NoofItems = _numPermIcons;
if (TinselV2)
- g_InvD[INV_CONV].NoofHicons = g_numPermIcons;
+ _invD[INV_CONV].NoofHicons = _numPermIcons;
else
- g_thisIcon = 0;
+ _thisIcon = 0;
} else if (invno == INV_CONF) { // Configuration window?
cd.selBox = NOBOX;
cd.pointBox = NOBOX;
}
- g_ino = invno; // The open inventory
+ _activeInv = invno; // The open inventory
- g_ItemsChanged = false; // Nothing changed
- g_InvDragging = ID_NONE; // Not dragging
- g_InventoryState = ACTIVE_INV; // Inventory actiive
- g_InventoryHidden = false; // Not hidden
- g_InventoryMaximised = g_InvD[g_ino].bMax;
+ _ItemsChanged = false; // Nothing changed
+ _invDragging = ID_NONE; // Not dragging
+ _inventoryState = ACTIVE_INV; // Inventory actiive
+ _InventoryHidden = false; // Not hidden
+ _InventoryMaximised = _invD[_activeInv].bMax;
if (invno != INV_CONF) // Configuration window?
ConstructInventory(FULL); // Draw it up
else {
@@ -3436,10 +3436,10 @@ void Dialogs::PopUpInventory(int invno) {
}
void Dialogs::SetMenuGlobals(CONFINIT *ci) {
- g_InvD[INV_CONF].MinHicons = g_InvD[INV_CONF].MaxHicons = g_InvD[INV_CONF].NoofHicons = ci->h;
- g_InvD[INV_CONF].MaxVicons = g_InvD[INV_CONF].MinVicons = g_InvD[INV_CONF].NoofVicons = ci->v;
- g_InvD[INV_CONF].inventoryX = ci->x;
- g_InvD[INV_CONF].inventoryY = ci->y;
+ _invD[INV_CONF].MinHicons = _invD[INV_CONF].MaxHicons = _invD[INV_CONF].NoofHicons = ci->h;
+ _invD[INV_CONF].MaxVicons = _invD[INV_CONF].MinVicons = _invD[INV_CONF].NoofVicons = ci->v;
+ _invD[INV_CONF].inventoryX = ci->x;
+ _invD[INV_CONF].inventoryY = ci->y;
cd.bExtraWin = ci->bExtraWin;
cd.box = ci->Box;
cd.NumBoxes = ci->NumBoxes;
@@ -3447,9 +3447,9 @@ void Dialogs::SetMenuGlobals(CONFINIT *ci) {
if (TinselV2) {
if ((ci->ixHeading != NO_HEADING) && SysString(ci->ixHeading))
- g_InvD[INV_MENU].hInvTitle = SysString(ci->ixHeading);
+ _invD[INV_MENU].hInvTitle = SysString(ci->ixHeading);
else
- g_InvD[INV_MENU].hInvTitle = NO_HEADING;
+ _invD[INV_MENU].hInvTitle = NO_HEADING;
}
}
@@ -3463,11 +3463,11 @@ void Dialogs::OpenMenu(CONFTYPE menuType) {
if (TinselV0)
return;
- if (g_InventoryState != IDLE_INV)
+ if (_inventoryState != IDLE_INV)
return;
- g_InvD[INV_CONF].resizable = false;
- g_InvD[INV_CONF].bMoveable = false;
+ _invD[INV_CONF].resizable = false;
+ _invD[INV_CONF].bMoveable = false;
switch (menuType) {
case MAIN_MENU:
@@ -3502,7 +3502,7 @@ void Dialogs::OpenMenu(CONFTYPE menuType) {
case SOUND_MENU:
if (TinselV2)
- g_displayedLanguage = TextLanguage();
+ _displayedLanguage = TextLanguage();
#if 1
// FIXME: Hack to setup CONFBOX pointer to data in the global Config object
if (TinselV2) {
@@ -3589,16 +3589,16 @@ void Dialogs::OpenMenu(CONFTYPE menuType) {
case TOP_WINDOW:
SetMenuGlobals(&ciTopWin);
- g_ino = INV_CONF;
+ _activeInv = INV_CONF;
ConstructInventory(CONF); // Draw it up
- g_InventoryState = BOGUS_INV;
+ _inventoryState = BOGUS_INV;
return;
default:
return;
}
- if (g_heldItem != INV_NOICON)
+ if (_heldItem != INV_NOICON)
_vm->_cursor->DelAuxCursor(); // no longer aux cursor
PopUpInventory(INV_CONF);
@@ -3630,38 +3630,38 @@ void Dialogs::OpenMenu(CONFTYPE menuType) {
* Close down an inventory window.
*/
void Dialogs::KillInventory() {
- if (g_objArray[0] != NULL) {
+ if (_objArray[0] != NULL) {
DumpObjArray();
DumpDobjArray();
DumpIconArray();
}
- if (g_InventoryState == ACTIVE_INV) {
+ if (_inventoryState == ACTIVE_INV) {
EnableTags();
if (TinselV2)
EnablePointing();
- g_InvD[g_ino].bMax = g_InventoryMaximised;
+ _invD[_activeInv].bMax = _InventoryMaximised;
_vm->_cursor->UnHideCursorTrails();
_vm->divertKeyInput(NULL);
}
- g_InventoryState = IDLE_INV;
+ _inventoryState = IDLE_INV;
- if (g_bReOpenMenu) {
- g_bReOpenMenu = false;
+ if (_reOpenMenu) {
+ _reOpenMenu = false;
OpenMenu(MAIN_MENU);
// Write config changes
_vm->_config->writeToDisk();
- } else if (g_ino == INV_CONF)
+ } else if (_activeInv == INV_CONF)
InventoryIconCursor(false);
if (TinselV2)
// Pump up the volume
- if (g_ino == INV_CONV)
+ if (_activeInv == INV_CONV)
_vm->_pcmMusic->unDim(false);
g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); // Hide VK after save dialog closes
@@ -3669,15 +3669,15 @@ void Dialogs::KillInventory() {
void Dialogs::CloseInventory() {
// If not active, ignore this
- if (g_InventoryState != ACTIVE_INV)
+ if (_inventoryState != ACTIVE_INV)
return;
// If hidden, a conversation action is still underway - ignore this
- if (g_InventoryHidden)
+ if (_InventoryHidden)
return;
// If conversation, this is a closeing event
- if (g_ino == INV_CONV)
+ if (_activeInv == INV_CONV)
ConvAction(INV_CLOSEICON);
KillInventory();
@@ -3700,12 +3700,12 @@ int Dialogs::NearestSlideY(int fity) {
int i = 0;
do {
- thisDist = ABS(g_slideStuff[i].y - fity);
+ thisDist = ABS(_slideStuff[i].y - fity);
if (thisDist < nearDist) {
nearDist = thisDist;
nearI = i;
}
- } while (g_slideStuff[++i].n != -1);
+ } while (_slideStuff[++i].n != -1);
return nearI;
}
@@ -3718,44 +3718,44 @@ void Dialogs::SlideSlider(int y, SSFN fn) {
int gotoY, ati;
// Only do this if there's a slider
- if (!g_SlideObject)
+ if (!_slideObject)
return;
switch (fn) {
case S_START: // Start of a drag on the slider
- newY = g_sliderYpos;
- lasti = NearestSlideY(g_sliderYpos);
+ newY = _sliderYpos;
+ lasti = NearestSlideY(_sliderYpos);
break;
case S_SLIDE: // Y-movement during drag
newY = newY + y; // New y-position
- if (newY < g_sliderYmin)
- gotoY = g_sliderYmin; // Above top limit
- else if (newY > g_sliderYmax)
- gotoY = g_sliderYmax; // Below bottom limit
+ if (newY < _sliderYmin)
+ gotoY = _sliderYmin; // Above top limit
+ else if (newY > _sliderYmax)
+ gotoY = _sliderYmax; // Below bottom limit
else
gotoY = newY; // Hunky-Dory
// Move slider to new position
- MultiMoveRelXY(g_SlideObject, 0, gotoY - g_sliderYpos);
- g_sliderYpos = gotoY;
+ MultiMoveRelXY(_slideObject, 0, gotoY - _sliderYpos);
+ _sliderYpos = gotoY;
// Re-draw icons if necessary
- ati = NearestSlideY(g_sliderYpos);
+ ati = NearestSlideY(_sliderYpos);
if (ati != lasti) {
- g_InvD[g_ino].FirstDisp = g_slideStuff[ati].n;
- assert(g_InvD[g_ino].FirstDisp >= 0); // negative first displayed
- g_ItemsChanged = true;
+ _invD[_activeInv].FirstDisp = _slideStuff[ati].n;
+ assert(_invD[_activeInv].FirstDisp >= 0); // negative first displayed
+ _ItemsChanged = true;
lasti = ati;
}
break;
case S_END: // End of a drag on the slider
// Draw icons from new start icon
- ati = NearestSlideY(g_sliderYpos);
- g_InvD[g_ino].FirstDisp = g_slideStuff[ati].n;
- g_ItemsChanged = true;
+ ati = NearestSlideY(_sliderYpos);
+ _invD[_activeInv].FirstDisp = _slideStuff[ati].n;
+ _ItemsChanged = true;
break;
default:
@@ -3773,38 +3773,38 @@ void Dialogs::SlideCSlider(int y, SSFN fn) {
int fc;
// Only do this if there's a slider
- if (!g_SlideObject)
+ if (!_slideObject)
return;
switch (fn) {
case S_START: // Start of a drag on the slider
- newY = g_sliderYpos;
+ newY = _sliderYpos;
break;
case S_SLIDE: // Y-movement during drag
newY = newY + y; // New y-position
- if (newY < g_sliderYmin)
- gotoY = g_sliderYmin; // Above top limit
- else if (newY > g_sliderYmax)
- gotoY = g_sliderYmax; // Below bottom limit
+ if (newY < _sliderYmin)
+ gotoY = _sliderYmin; // Above top limit
+ else if (newY > _sliderYmax)
+ gotoY = _sliderYmax; // Below bottom limit
else
gotoY = newY; // Hunky-Dory
// Move slider to new position
if (TinselV2)
- MultiMoveRelXY(g_SlideObject, 0, gotoY - g_sliderYpos);
- g_sliderYpos = gotoY;
+ MultiMoveRelXY(_slideObject, 0, gotoY - _sliderYpos);
+ _sliderYpos = gotoY;
fc = cd.extraBase;
if ((cd.box == saveBox || cd.box == loadBox))
- FirstFile((g_sliderYpos - g_sliderYmin) * (MAX_SAVED_FILES - NUM_RGROUP_BOXES) /
- (g_sliderYmax - g_sliderYmin));
+ FirstFile((_sliderYpos - _sliderYmin) * (MAX_SAVED_FILES - NUM_RGROUP_BOXES) /
+ (_sliderYmax - _sliderYmin));
else if (cd.box == hopperBox1)
- FirstScene((g_sliderYpos - g_sliderYmin) * (g_numScenes - NUM_RGROUP_BOXES) / sliderRange);
+ FirstScene((_sliderYpos - _sliderYmin) * (_numScenes - NUM_RGROUP_BOXES) / sliderRange);
else if (cd.box == hopperBox2)
- FirstEntry((g_sliderYpos - g_sliderYmin) * (g_numEntries - NUM_RGROUP_BOXES) / sliderRange);
+ FirstEntry((_sliderYpos - _sliderYmin) * (_numEntries - NUM_RGROUP_BOXES) / sliderRange);
// If extraBase has changed...
if (fc != cd.extraBase) {
@@ -3846,16 +3846,16 @@ void Dialogs::SlideMSlider(int x, SSFN fn) {
// Work out the indices
index = cd.selBox & ~IS_MASK;
- for (i = 0; i < g_numMdSlides; i++)
- if (g_mdSlides[i].num == index)
+ for (i = 0; i < _numMdSlides; i++)
+ if (_mdSlides[i].num == index)
break;
- assert(i < g_numMdSlides);
+ assert(i < _numMdSlides);
switch (fn) {
case S_START: // Start of a drag on the slider
// can use index as a throw-away value
- GetAniPosition(g_mdSlides[i].obj, &newX, &index);
- g_lX = g_sX = newX;
+ GetAniPosition(_mdSlides[i].obj, &newX, &index);
+ _lX = _sX = newX;
break;
case S_SLIDE: // X-movement during drag
@@ -3864,19 +3864,19 @@ void Dialogs::SlideMSlider(int x, SSFN fn) {
newX = newX + x; // New x-position
- if (newX < g_mdSlides[i].min)
- gotoX = g_mdSlides[i].min; // Below bottom limit
- else if (newX > g_mdSlides[i].max)
- gotoX = g_mdSlides[i].max; // Above top limit
+ if (newX < _mdSlides[i].min)
+ gotoX = _mdSlides[i].min; // Below bottom limit
+ else if (newX > _mdSlides[i].max)
+ gotoX = _mdSlides[i].max; // Above top limit
else
gotoX = newX; // Hunky-Dory
// Move slider to new position
- MultiMoveRelXY(g_mdSlides[i].obj, gotoX - g_sX, 0);
- g_sX = gotoX;
+ MultiMoveRelXY(_mdSlides[i].obj, gotoX - _sX, 0);
+ _sX = gotoX;
- if (g_lX != g_sX) {
- *cd.box[index].ival = (g_sX - g_mdSlides[i].min) * cd.box[index].w / SLIDE_RANGE;
+ if (_lX != _sX) {
+ *cd.box[index].ival = (_sX - _mdSlides[i].min) * cd.box[index].w / SLIDE_RANGE;
if (cd.box[index].boxFunc == MUSICVOL)
_vm->_music->SetMidiVolume(*cd.box[index].ival);
#ifdef MAC_OPTIONS
@@ -3886,14 +3886,14 @@ void Dialogs::SlideMSlider(int x, SSFN fn) {
if (cd.box[index].boxFunc == SAMPVOL)
SetSampleVolume(*cd.box[index].ival);
#endif
- g_lX = g_sX;
+ _lX = _sX;
}
break;
case S_TIMEUP:
case S_TIMEDN:
gotoX = SLIDE_RANGE * (*cd.box[index].ival) / cd.box[index].w;
- MultiSetAniX(g_mdSlides[i].obj, g_mdSlides[i].min + gotoX);
+ MultiSetAniX(_mdSlides[i].obj, _mdSlides[i].min + gotoX);
if (cd.box[index].boxFunc == MUSICVOL)
_vm->_music->SetMidiVolume(*cd.box[index].ival);
@@ -3908,7 +3908,7 @@ void Dialogs::SlideMSlider(int x, SSFN fn) {
case S_END: // End of a drag on the slider
AddBoxes(false); // Might change position slightly
- if (g_ino == INV_CONF && cd.box == subtitlesBox)
+ if (_activeInv == INV_CONF && cd.box == subtitlesBox)
Select(_vm->_config->_language, false);
break;
@@ -3921,23 +3921,23 @@ void Dialogs::SlideMSlider(int x, SSFN fn) {
* Called from ChangeingSize() during re-sizing.
*/
void Dialogs::GettingTaller() {
- if (g_SuppV) {
- g_Ychange += g_SuppV;
- if (g_Ycompensate == 'T')
- g_InvD[g_ino].inventoryY += g_SuppV;
- g_SuppV = 0;
+ if (_SuppV) {
+ _yChange += _SuppV;
+ if (_yCompensate == 'T')
+ _invD[_activeInv].inventoryY += _SuppV;
+ _SuppV = 0;
}
- while (g_Ychange > (ITEM_HEIGHT + 1) && g_InvD[g_ino].NoofVicons < g_InvD[g_ino].MaxVicons) {
- g_Ychange -= (ITEM_HEIGHT + 1);
- g_InvD[g_ino].NoofVicons++;
- if (g_Ycompensate == 'T')
- g_InvD[g_ino].inventoryY -= (ITEM_HEIGHT + 1);
+ while (_yChange > (ITEM_HEIGHT + 1) && _invD[_activeInv].NoofVicons < _invD[_activeInv].MaxVicons) {
+ _yChange -= (ITEM_HEIGHT + 1);
+ _invD[_activeInv].NoofVicons++;
+ if (_yCompensate == 'T')
+ _invD[_activeInv].inventoryY -= (ITEM_HEIGHT + 1);
}
- if (g_InvD[g_ino].NoofVicons < g_InvD[g_ino].MaxVicons) {
- g_SuppV = g_Ychange;
- g_Ychange = 0;
- if (g_Ycompensate == 'T')
- g_InvD[g_ino].inventoryY -= g_SuppV;
+ if (_invD[_activeInv].NoofVicons < _invD[_activeInv].MaxVicons) {
+ _SuppV = _yChange;
+ _yChange = 0;
+ if (_yCompensate == 'T')
+ _invD[_activeInv].inventoryY -= _SuppV;
}
}
@@ -3945,73 +3945,73 @@ void Dialogs::GettingTaller() {
* Called from ChangeingSize() during re-sizing.
*/
void Dialogs::GettingShorter() {
- int StartNvi = g_InvD[g_ino].NoofVicons;
- int StartUv = g_SuppV;
+ int StartNvi = _invD[_activeInv].NoofVicons;
+ int StartUv = _SuppV;
- if (g_SuppV) {
- g_Ychange += (g_SuppV - (ITEM_HEIGHT + 1));
- g_InvD[g_ino].NoofVicons++;
- g_SuppV = 0;
+ if (_SuppV) {
+ _yChange += (_SuppV - (ITEM_HEIGHT + 1));
+ _invD[_activeInv].NoofVicons++;
+ _SuppV = 0;
}
- while (g_Ychange < -(ITEM_HEIGHT + 1) && g_InvD[g_ino].NoofVicons > g_InvD[g_ino].MinVicons) {
- g_Ychange += (ITEM_HEIGHT + 1);
- g_InvD[g_ino].NoofVicons--;
+ while (_yChange < -(ITEM_HEIGHT + 1) && _invD[_activeInv].NoofVicons > _invD[_activeInv].MinVicons) {
+ _yChange += (ITEM_HEIGHT + 1);
+ _invD[_activeInv].NoofVicons--;
}
- if (g_InvD[g_ino].NoofVicons > g_InvD[g_ino].MinVicons && g_Ychange) {
- g_SuppV = (ITEM_HEIGHT + 1) + g_Ychange;
- g_InvD[g_ino].NoofVicons--;
- g_Ychange = 0;
+ if (_invD[_activeInv].NoofVicons > _invD[_activeInv].MinVicons && _yChange) {
+ _SuppV = (ITEM_HEIGHT + 1) + _yChange;
+ _invD[_activeInv].NoofVicons--;
+ _yChange = 0;
}
- if (g_Ycompensate == 'T')
- g_InvD[g_ino].inventoryY += (ITEM_HEIGHT + 1) * (StartNvi - g_InvD[g_ino].NoofVicons) - (g_SuppV - StartUv);
+ if (_yCompensate == 'T')
+ _invD[_activeInv].inventoryY += (ITEM_HEIGHT + 1) * (StartNvi - _invD[_activeInv].NoofVicons) - (_SuppV - StartUv);
}
/**
* Called from ChangeingSize() during re-sizing.
*/
void Dialogs::GettingWider() {
- int StartNhi = g_InvD[g_ino].NoofHicons;
- int StartUh = g_SuppH;
+ int StartNhi = _invD[_activeInv].NoofHicons;
+ int StartUh = _SuppH;
- if (g_SuppH) {
- g_Xchange += g_SuppH;
- g_SuppH = 0;
+ if (_SuppH) {
+ _xChange += _SuppH;
+ _SuppH = 0;
}
- while (g_Xchange > (ITEM_WIDTH + 1) && g_InvD[g_ino].NoofHicons < g_InvD[g_ino].MaxHicons) {
- g_Xchange -= (ITEM_WIDTH + 1);
- g_InvD[g_ino].NoofHicons++;
+ while (_xChange > (ITEM_WIDTH + 1) && _invD[_activeInv].NoofHicons < _invD[_activeInv].MaxHicons) {
+ _xChange -= (ITEM_WIDTH + 1);
+ _invD[_activeInv].NoofHicons++;
}
- if (g_InvD[g_ino].NoofHicons < g_InvD[g_ino].MaxHicons) {
- g_SuppH = g_Xchange;
- g_Xchange = 0;
+ if (_invD[_activeInv].NoofHicons < _invD[_activeInv].MaxHicons) {
+ _SuppH = _xChange;
+ _xChange = 0;
}
- if (g_Xcompensate == 'L')
- g_InvD[g_ino].inventoryX += (ITEM_WIDTH + 1) * (StartNhi - g_InvD[g_ino].NoofHicons) - (g_SuppH - StartUh);
+ if (_xCompensate == 'L')
+ _invD[_activeInv].inventoryX += (ITEM_WIDTH + 1) * (StartNhi - _invD[_activeInv].NoofHicons) - (_SuppH - StartUh);
}
/**
* Called from ChangeingSize() during re-sizing.
*/
void Dialogs::GettingNarrower() {
- int StartNhi = g_InvD[g_ino].NoofHicons;
- int StartUh = g_SuppH;
+ int StartNhi = _invD[_activeInv].NoofHicons;
+ int StartUh = _SuppH;
- if (g_SuppH) {
- g_Xchange += (g_SuppH - (ITEM_WIDTH + 1));
- g_InvD[g_ino].NoofHicons++;
- g_SuppH = 0;
+ if (_SuppH) {
+ _xChange += (_SuppH - (ITEM_WIDTH + 1));
+ _invD[_activeInv].NoofHicons++;
+ _SuppH = 0;
}
- while (g_Xchange < -(ITEM_WIDTH + 1) && g_InvD[g_ino].NoofHicons > g_InvD[g_ino].MinHicons) {
- g_Xchange += (ITEM_WIDTH + 1);
- g_InvD[g_ino].NoofHicons--;
+ while (_xChange < -(ITEM_WIDTH + 1) && _invD[_activeInv].NoofHicons > _invD[_activeInv].MinHicons) {
+ _xChange += (ITEM_WIDTH + 1);
+ _invD[_activeInv].NoofHicons--;
}
- if (g_InvD[g_ino].NoofHicons > g_InvD[g_ino].MinHicons && g_Xchange) {
- g_SuppH = (ITEM_WIDTH + 1) + g_Xchange;
- g_InvD[g_ino].NoofHicons--;
- g_Xchange = 0;
+ if (_invD[_activeInv].NoofHicons > _invD[_activeInv].MinHicons && _xChange) {
+ _SuppH = (ITEM_WIDTH + 1) + _xChange;
+ _invD[_activeInv].NoofHicons--;
+ _xChange = 0;
}
- if (g_Xcompensate == 'L')
- g_InvD[g_ino].inventoryX += (ITEM_WIDTH + 1) * (StartNhi - g_InvD[g_ino].NoofHicons) - (g_SuppH - StartUh);
+ if (_xCompensate == 'L')
+ _invD[_activeInv].inventoryX += (ITEM_WIDTH + 1) * (StartNhi - _invD[_activeInv].NoofHicons) - (_SuppH - StartUh);
}
/**
@@ -4019,15 +4019,15 @@ void Dialogs::GettingNarrower() {
*/
void Dialogs::ChangeingSize() {
/* Make it taller or shorter if necessary. */
- if (g_Ychange > 0)
+ if (_yChange > 0)
GettingTaller();
- else if (g_Ychange < 0)
+ else if (_yChange < 0)
GettingShorter();
/* Make it wider or narrower if necessary. */
- if (g_Xchange > 0)
+ if (_xChange > 0)
GettingWider();
- else if (g_Xchange < 0)
+ else if (_xChange < 0)
GettingNarrower();
ConstructInventory(EMPTY);
@@ -4040,29 +4040,29 @@ void Dialogs::Xmovement(int x) {
int aniX, aniY;
int i;
- if (x && g_objArray[0] != NULL) {
- switch (g_InvDragging) {
+ if (x && _objArray[0] != NULL) {
+ switch (_invDragging) {
case ID_MOVE:
- GetAniPosition(g_objArray[0], &g_InvD[g_ino].inventoryX, &aniY);
- g_InvD[g_ino].inventoryX += x;
- MultiSetAniX(g_objArray[0], g_InvD[g_ino].inventoryX);
- for (i = 1; i < MAX_WCOMP && g_objArray[i]; i++)
- MultiMoveRelXY(g_objArray[i], x, 0);
- for (i = 0; i < MAX_ICONS && g_iconArray[i]; i++)
- MultiMoveRelXY(g_iconArray[i], x, 0);
+ GetAniPosition(_objArray[0], &_invD[_activeInv].inventoryX, &aniY);
+ _invD[_activeInv].inventoryX += x;
+ MultiSetAniX(_objArray[0], _invD[_activeInv].inventoryX);
+ for (i = 1; i < MAX_WCOMP && _objArray[i]; i++)
+ MultiMoveRelXY(_objArray[i], x, 0);
+ for (i = 0; i < MAX_ICONS && _iconArray[i]; i++)
+ MultiMoveRelXY(_iconArray[i], x, 0);
break;
case ID_LEFT:
case ID_TLEFT:
case ID_BLEFT:
- g_Xchange -= x;
+ _xChange -= x;
ChangeingSize();
break;
case ID_RIGHT:
case ID_TRIGHT:
case ID_BRIGHT:
- g_Xchange += x;
+ _xChange += x;
ChangeingSize();
break;
@@ -4088,16 +4088,16 @@ void Dialogs::Ymovement(int y) {
int aniX, aniY;
int i;
- if (y && g_objArray[0] != NULL) {
- switch (g_InvDragging) {
+ if (y && _objArray[0] != NULL) {
+ switch (_invDragging) {
case ID_MOVE:
- GetAniPosition(g_objArray[0], &aniX, &g_InvD[g_ino].inventoryY);
- g_InvD[g_ino].inventoryY += y;
- MultiSetAniY(g_objArray[0], g_InvD[g_ino].inventoryY);
- for (i = 1; i < MAX_WCOMP && g_objArray[i]; i++)
- MultiMoveRelXY(g_objArray[i], 0, y);
- for (i = 0; i < MAX_ICONS && g_iconArray[i]; i++)
- MultiMoveRelXY(g_iconArray[i], 0, y);
+ GetAniPosition(_objArray[0], &aniX, &_invD[_activeInv].inventoryY);
+ _invD[_activeInv].inventoryY += y;
+ MultiSetAniY(_objArray[0], _invD[_activeInv].inventoryY);
+ for (i = 1; i < MAX_WCOMP && _objArray[i]; i++)
+ MultiMoveRelXY(_objArray[i], 0, y);
+ for (i = 0; i < MAX_ICONS && _iconArray[i]; i++)
+ MultiMoveRelXY(_iconArray[i], 0, y);
break;
case ID_SLIDE:
@@ -4111,14 +4111,14 @@ void Dialogs::Ymovement(int y) {
case ID_BOTTOM:
case ID_BLEFT:
case ID_BRIGHT:
- g_Ychange += y;
+ _yChange += y;
ChangeingSize();
break;
case ID_TOP:
case ID_TLEFT:
case ID_TRIGHT:
- g_Ychange -= y;
+ _yChange -= y;
ChangeingSize();
break;
@@ -4144,16 +4144,16 @@ void Dialogs::InvDragStart() {
/*
* Do something different for Save/Restore screens
*/
- if (g_ino == INV_CONF) {
+ if (_activeInv == INV_CONF) {
int whichbox;
whichbox = WhichMenuBox(curX, curY, true);
if (whichbox == IB_SLIDE) {
- g_InvDragging = ID_CSLIDE;
+ _invDragging = ID_CSLIDE;
SlideCSlider(0, S_START);
} else if (whichbox > 0 && (whichbox & IS_MASK)) {
- g_InvDragging = ID_MDCONT; // Mixing desk control
+ _invDragging = ID_MDCONT; // Mixing desk control
cd.selBox = whichbox;
SlideMSlider(0, S_START);
}
@@ -4165,85 +4165,85 @@ void Dialogs::InvDragStart() {
*/
switch (InvArea(curX, curY)) {
case I_HEADER:
- if (g_InvD[g_ino].bMoveable) {
- g_InvDragging = ID_MOVE;
+ if (_invD[_activeInv].bMoveable) {
+ _invDragging = ID_MOVE;
}
break;
case I_SLIDE:
- g_InvDragging = ID_SLIDE;
+ _invDragging = ID_SLIDE;
SlideSlider(0, S_START);
break;
case I_BOTTOM:
- if (g_InvD[g_ino].resizable) {
- g_Ychange = 0;
- g_InvDragging = ID_BOTTOM;
- g_Ycompensate = 'B';
+ if (_invD[_activeInv].resizable) {
+ _yChange = 0;
+ _invDragging = ID_BOTTOM;
+ _yCompensate = 'B';
}
break;
case I_TOP:
- if (g_InvD[g_ino].resizable) {
- g_Ychange = 0;
- g_InvDragging = ID_TOP;
- g_Ycompensate = 'T';
+ if (_invD[_activeInv].resizable) {
+ _yChange = 0;
+ _invDragging = ID_TOP;
+ _yCompensate = 'T';
}
break;
case I_LEFT:
- if (g_InvD[g_ino].resizable) {
- g_Xchange = 0;
- g_InvDragging = ID_LEFT;
- g_Xcompensate = 'L';
+ if (_invD[_activeInv].resizable) {
+ _xChange = 0;
+ _invDragging = ID_LEFT;
+ _xCompensate = 'L';
}
break;
case I_RIGHT:
- if (g_InvD[g_ino].resizable) {
- g_Xchange = 0;
- g_InvDragging = ID_RIGHT;
- g_Xcompensate = 'R';
+ if (_invD[_activeInv].resizable) {
+ _xChange = 0;
+ _invDragging = ID_RIGHT;
+ _xCompensate = 'R';
}
break;
case I_TLEFT:
- if (g_InvD[g_ino].resizable) {
- g_Ychange = 0;
- g_Ycompensate = 'T';
- g_Xchange = 0;
- g_Xcompensate = 'L';
- g_InvDragging = ID_TLEFT;
+ if (_invD[_activeInv].resizable) {
+ _yChange = 0;
+ _yCompensate = 'T';
+ _xChange = 0;
+ _xCompensate = 'L';
+ _invDragging = ID_TLEFT;
}
break;
case I_TRIGHT:
- if (g_InvD[g_ino].resizable) {
- g_Ychange = 0;
- g_Ycompensate = 'T';
- g_Xchange = 0;
- g_Xcompensate = 'R';
- g_InvDragging = ID_TRIGHT;
+ if (_invD[_activeInv].resizable) {
+ _yChange = 0;
+ _yCompensate = 'T';
+ _xChange = 0;
+ _xCompensate = 'R';
+ _invDragging = ID_TRIGHT;
}
break;
case I_BLEFT:
- if (g_InvD[g_ino].resizable) {
- g_Ychange = 0;
- g_Ycompensate = 'B';
- g_Xchange = 0;
- g_Xcompensate = 'L';
- g_InvDragging = ID_BLEFT;
+ if (_invD[_activeInv].resizable) {
+ _yChange = 0;
+ _yCompensate = 'B';
+ _xChange = 0;
+ _xCompensate = 'L';
+ _invDragging = ID_BLEFT;
}
break;
case I_BRIGHT:
- if (g_InvD[g_ino].resizable) {
- g_Ychange = 0;
- g_Ycompensate = 'B';
- g_Xchange = 0;
- g_Xcompensate = 'R';
- g_InvDragging = ID_BRIGHT;
+ if (_invD[_activeInv].resizable) {
+ _yChange = 0;
+ _yCompensate = 'B';
+ _xChange = 0;
+ _xCompensate = 'R';
+ _invDragging = ID_BRIGHT;
}
break;
@@ -4260,14 +4260,14 @@ void Dialogs::InvDragEnd() {
_vm->_cursor->GetCursorXY(&curX, &curY, false);
- if (g_InvDragging != ID_NONE) {
- if (g_InvDragging == ID_SLIDE) {
+ if (_invDragging != ID_NONE) {
+ if (_invDragging == ID_SLIDE) {
SlideSlider(0, S_END);
- } else if (g_InvDragging == ID_CSLIDE) {
+ } else if (_invDragging == ID_CSLIDE) {
; // No action
- } else if (g_InvDragging == ID_MDCONT) {
+ } else if (_invDragging == ID_MDCONT) {
SlideMSlider(0, S_END);
- } else if (g_InvDragging == ID_MOVE) {
+ } else if (_invDragging == ID_MOVE) {
; // No action
} else {
// Were re-sizing. Redraw the whole thing.
@@ -4276,21 +4276,21 @@ void Dialogs::InvDragEnd() {
ConstructInventory(FULL);
// If this was the maximised, it no longer is!
- if (g_InventoryMaximised) {
- g_InventoryMaximised = false;
- g_InvD[g_ino].otherX = g_InvD[g_ino].inventoryX;
- g_InvD[g_ino].otherY = g_InvD[g_ino].inventoryY;
+ if (_InventoryMaximised) {
+ _InventoryMaximised = false;
+ _invD[_activeInv].otherX = _invD[_activeInv].inventoryX;
+ _invD[_activeInv].otherY = _invD[_activeInv].inventoryY;
}
}
- g_InvDragging = ID_NONE;
+ _invDragging = ID_NONE;
ProcessedProvisional();
}
// Cursor could well now be inappropriate
InvCursor(IC_AREA, curX, curY);
- g_Xchange = g_Ychange = 0; // Probably no need, but does no harm!
+ _xChange = _yChange = 0; // Probably no need, but does no harm!
}
bool Dialogs::MenuDown(int lines) {
@@ -4301,13 +4301,13 @@ bool Dialogs::MenuDown(int lines) {
return true;
}
} else if (cd.box == hopperBox1) {
- if (cd.extraBase < g_numScenes - NUM_RGROUP_BOXES) {
+ if (cd.extraBase < _numScenes - NUM_RGROUP_BOXES) {
FirstScene(cd.extraBase + lines);
AddBoxes(true);
return true;
}
} else if (cd.box == hopperBox2) {
- if (cd.extraBase < g_numEntries - NUM_RGROUP_BOXES) {
+ if (cd.extraBase < _numEntries - NUM_RGROUP_BOXES) {
FirstEntry(cd.extraBase + lines);
AddBoxes(true);
return true;
@@ -4366,26 +4366,26 @@ void Dialogs::MenuPageUp() {
void Dialogs::InventoryDown() {
// This code is a copy of the IB_SLIDE_DOWN case in InvWalkTo
// TODO: So share this duplicate code
- if (g_InvD[g_ino].NoofVicons == 1)
- if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons * g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
- g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
- for (int i = 1; i < g_InvD[g_ino].NoofVicons; i++) {
- if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons * g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
- g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
+ if (_invD[_activeInv].NoofVicons == 1)
+ if (_invD[_activeInv].FirstDisp + _invD[_activeInv].NoofHicons * _invD[_activeInv].NoofVicons < _invD[_activeInv].NoofItems)
+ _invD[_activeInv].FirstDisp += _invD[_activeInv].NoofHicons;
+ for (int i = 1; i < _invD[_activeInv].NoofVicons; i++) {
+ if (_invD[_activeInv].FirstDisp + _invD[_activeInv].NoofHicons * _invD[_activeInv].NoofVicons < _invD[_activeInv].NoofItems)
+ _invD[_activeInv].FirstDisp += _invD[_activeInv].NoofHicons;
}
- g_ItemsChanged = true;
+ _ItemsChanged = true;
}
void Dialogs::InventoryUp() {
// This code is a copy of the I_SLIDE_UP case in InvWalkTo
// TODO: So share this duplicate code
- if (g_InvD[g_ino].NoofVicons == 1)
- g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons;
- for (int i = 1; i < g_InvD[g_ino].NoofVicons; i++)
- g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons;
- if (g_InvD[g_ino].FirstDisp < 0)
- g_InvD[g_ino].FirstDisp = 0;
- g_ItemsChanged = true;
+ if (_invD[_activeInv].NoofVicons == 1)
+ _invD[_activeInv].FirstDisp -= _invD[_activeInv].NoofHicons;
+ for (int i = 1; i < _invD[_activeInv].NoofVicons; i++)
+ _invD[_activeInv].FirstDisp -= _invD[_activeInv].NoofHicons;
+ if (_invD[_activeInv].FirstDisp < 0)
+ _invD[_activeInv].FirstDisp = 0;
+ _ItemsChanged = true;
}
/**************************************************************************/
@@ -4504,7 +4504,7 @@ void Dialogs::ConfActionSpecial(int i) {
Select(cd.selBox, true);
}
} else if (cd.box == hopperBox1) {
- if (cd.extraBase < g_numScenes - NUM_RGROUP_BOXES) {
+ if (cd.extraBase < _numScenes - NUM_RGROUP_BOXES) {
FirstScene(cd.extraBase + 1);
AddBoxes(true);
if (cd.selBox)
@@ -4512,7 +4512,7 @@ void Dialogs::ConfActionSpecial(int i) {
Select(cd.selBox, true);
}
} else if (cd.box == hopperBox2) {
- if (cd.extraBase < g_numEntries - NUM_RGROUP_BOXES) {
+ if (cd.extraBase < _numEntries - NUM_RGROUP_BOXES) {
FirstEntry(cd.extraBase + 1);
AddBoxes(true);
if (cd.selBox)
@@ -4539,25 +4539,25 @@ void Dialogs::InvPutDown(int index) {
int hiIndex; // Current position of held item (if in)
// Find where the held item is positioned in this inventory (if it is)
- for (hiIndex = 0; hiIndex < g_InvD[g_ino].NoofItems; hiIndex++)
- if (g_InvD[g_ino].contents[hiIndex] == g_heldItem)
+ for (hiIndex = 0; hiIndex < _invD[_activeInv].NoofItems; hiIndex++)
+ if (_invD[_activeInv].contents[hiIndex] == _heldItem)
break;
// If drop position would leave a gap, move it up
- if (index >= g_InvD[g_ino].NoofItems) {
- if (hiIndex == g_InvD[g_ino].NoofItems) // Not in, add it
- index = g_InvD[g_ino].NoofItems;
+ if (index >= _invD[_activeInv].NoofItems) {
+ if (hiIndex == _invD[_activeInv].NoofItems) // Not in, add it
+ index = _invD[_activeInv].NoofItems;
else
- index = g_InvD[g_ino].NoofItems - 1;
+ index = _invD[_activeInv].NoofItems - 1;
}
- if (hiIndex == g_InvD[g_ino].NoofItems) { // Not in, add it
- if (g_InvD[g_ino].NoofItems < g_InvD[g_ino].MaxInvObj) {
- g_InvD[g_ino].NoofItems++;
+ if (hiIndex == _invD[_activeInv].NoofItems) { // Not in, add it
+ if (_invD[_activeInv].NoofItems < _invD[_activeInv].MaxInvObj) {
+ _invD[_activeInv].NoofItems++;
// Don't leave it in the other inventory!
- if (InventoryPos(g_heldItem) != INV_HELDNOTIN)
- RemFromInventory(g_ino == INV_1 ? INV_2 : INV_1, g_heldItem);
+ if (InventoryPos(_heldItem) != INV_HELDNOTIN)
+ RemFromInventory(_activeInv == INV_1 ? INV_2 : INV_1, _heldItem);
} else {
// No room at the inn!
return;
@@ -4566,17 +4566,17 @@ void Dialogs::InvPutDown(int index) {
// Position it in the inventory
if (index < hiIndex) {
- memmove(&g_InvD[g_ino].contents[index + 1], &g_InvD[g_ino].contents[index], (hiIndex - index) * sizeof(int));
- g_InvD[g_ino].contents[index] = g_heldItem;
+ memmove(&_invD[_activeInv].contents[index + 1], &_invD[_activeInv].contents[index], (hiIndex - index) * sizeof(int));
+ _invD[_activeInv].contents[index] = _heldItem;
} else if (index > hiIndex) {
- memmove(&g_InvD[g_ino].contents[hiIndex], &g_InvD[g_ino].contents[hiIndex + 1], (index - hiIndex) * sizeof(int));
- g_InvD[g_ino].contents[index] = g_heldItem;
+ memmove(&_invD[_activeInv].contents[hiIndex], &_invD[_activeInv].contents[hiIndex + 1], (index - hiIndex) * sizeof(int));
+ _invD[_activeInv].contents[index] = _heldItem;
} else {
- g_InvD[g_ino].contents[index] = g_heldItem;
+ _invD[_activeInv].contents[index] = _heldItem;
}
- g_heldItem = INV_NOICON;
- g_ItemsChanged = true;
+ _heldItem = INV_NOICON;
+ _ItemsChanged = true;
_vm->_cursor->DelAuxCursor();
_vm->_cursor->RestoreMainCursor();
_vm->_cursor->GetCursorXY(&aniX, &aniY, false);
@@ -4591,25 +4591,25 @@ void Dialogs::InvPickup(int index) {
return;
// If not holding anything
- if (g_heldItem == INV_NOICON && g_InvD[g_ino].contents[index] &&
- (!TinselV2 || g_InvD[g_ino].contents[index] != g_heldItem)) {
+ if (_heldItem == INV_NOICON && _invD[_activeInv].contents[index] &&
+ (!TinselV2 || _invD[_activeInv].contents[index] != _heldItem)) {
// Pick-up
- invObj = GetInvObject(g_InvD[g_ino].contents[index]);
- g_thisIcon = g_InvD[g_ino].contents[index];
+ invObj = GetInvObject(_invD[_activeInv].contents[index]);
+ _thisIcon = _invD[_activeInv].contents[index];
if (TinselV2)
InvTinselEvent(invObj, PICKUP, INV_PICKUP, index);
else if (invObj->hScript)
InvTinselEvent(invObj, WALKTO, INV_PICKUP, index);
- } else if (g_heldItem != INV_NOICON) {
+ } else if (_heldItem != INV_NOICON) {
// Put-down
- invObj = GetInvObject(g_heldItem);
+ invObj = GetInvObject(_heldItem);
// If DROPCODE set, send event, otherwise it's a putdown
if (invObj->attribute & IO_DROPCODE && invObj->hScript)
InvTinselEvent(invObj, PUTDOWN, INV_PICKUP, index);
- else if (!(invObj->attribute & IO_ONLYINV1 && g_ino != INV_1) && !(invObj->attribute & IO_ONLYINV2 && g_ino != INV_2)) {
+ else if (!(invObj->attribute & IO_ONLYINV1 && _activeInv != INV_1) && !(invObj->attribute & IO_ONLYINV2 && _activeInv != INV_2)) {
if (TinselV2)
InvPutDown(index);
else
@@ -4626,7 +4626,7 @@ void Dialogs::InvWalkTo(const Common::Point &coOrds) {
switch (InvArea(coOrds.x, coOrds.y)) {
case I_NOTIN:
- if (g_ino == INV_CONV)
+ if (_activeInv == INV_CONV)
ConvAction(INV_CLOSEICON);
if ((cd.box == hopperBox1) || (cd.box == hopperBox2))
FreeSceneHopper();
@@ -4634,43 +4634,43 @@ void Dialogs::InvWalkTo(const Common::Point &coOrds) {
break;
case I_SLIDE_UP:
- if (g_InvD[g_ino].NoofVicons == 1)
- g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons;
- for (i = 1; i < g_InvD[g_ino].NoofVicons; i++)
- g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons;
- if (g_InvD[g_ino].FirstDisp < 0)
- g_InvD[g_ino].FirstDisp = 0;
- g_ItemsChanged = true;
+ if (_invD[_activeInv].NoofVicons == 1)
+ _invD[_activeInv].FirstDisp -= _invD[_activeInv].NoofHicons;
+ for (i = 1; i < _invD[_activeInv].NoofVicons; i++)
+ _invD[_activeInv].FirstDisp -= _invD[_activeInv].NoofHicons;
+ if (_invD[_activeInv].FirstDisp < 0)
+ _invD[_activeInv].FirstDisp = 0;
+ _ItemsChanged = true;
break;
case I_UP:
- g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons;
- if (g_InvD[g_ino].FirstDisp < 0)
- g_InvD[g_ino].FirstDisp = 0;
- g_ItemsChanged = true;
+ _invD[_activeInv].FirstDisp -= _invD[_activeInv].NoofHicons;
+ if (_invD[_activeInv].FirstDisp < 0)
+ _invD[_activeInv].FirstDisp = 0;
+ _ItemsChanged = true;
break;
case I_SLIDE_DOWN:
- if (g_InvD[g_ino].NoofVicons == 1)
- if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons * g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
- g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
- for (i = 1; i < g_InvD[g_ino].NoofVicons; i++) {
- if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons * g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
- g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
+ if (_invD[_activeInv].NoofVicons == 1)
+ if (_invD[_activeInv].FirstDisp + _invD[_activeInv].NoofHicons * _invD[_activeInv].NoofVicons < _invD[_activeInv].NoofItems)
+ _invD[_activeInv].FirstDisp += _invD[_activeInv].NoofHicons;
+ for (i = 1; i < _invD[_activeInv].NoofVicons; i++) {
+ if (_invD[_activeInv].FirstDisp + _invD[_activeInv].NoofHicons * _invD[_activeInv].NoofVicons < _invD[_activeInv].NoofItems)
+ _invD[_activeInv].FirstDisp += _invD[_activeInv].NoofHicons;
}
- g_ItemsChanged = true;
+ _ItemsChanged = true;
break;
case I_DOWN:
- if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons * g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems) {
- g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
- g_ItemsChanged = true;
+ if (_invD[_activeInv].FirstDisp + _invD[_activeInv].NoofHicons * _invD[_activeInv].NoofVicons < _invD[_activeInv].NoofItems) {
+ _invD[_activeInv].FirstDisp += _invD[_activeInv].NoofHicons;
+ _ItemsChanged = true;
}
break;
case I_BODY:
- if (g_ino == INV_CONF) {
- if (!g_InventoryHidden)
+ if (_activeInv == INV_CONF) {
+ if (!_InventoryHidden)
MenuAction(WhichMenuBox(coOrds.x, coOrds.y, false), false);
} else {
Common::Point pt = coOrds;
@@ -4678,8 +4678,8 @@ void Dialogs::InvWalkTo(const Common::Point &coOrds) {
// To cater for drop in dead space between icons,
// look 1 pixel right, then 1 down, then 1 right and down.
- if (i == INV_NOICON && g_heldItem != INV_NOICON &&
- (g_ino == INV_1 || g_ino == INV_2)) {
+ if (i == INV_NOICON && _heldItem != INV_NOICON &&
+ (_activeInv == INV_1 || _activeInv == INV_2)) {
pt.x += 1; // 1 to the right
i = InvItem(pt, false);
if (i == INV_NOICON) {
@@ -4693,7 +4693,7 @@ void Dialogs::InvWalkTo(const Common::Point &coOrds) {
}
}
- if (g_ino == INV_CONV) {
+ if (_activeInv == INV_CONV) {
ConvAction(i);
} else
InvPickup(i);
@@ -4715,19 +4715,19 @@ void Dialogs::InvAction() {
switch (InvArea(aniX, aniY)) {
case I_BODY:
- if (g_ino == INV_CONF) {
- if (!g_InventoryHidden)
+ if (_activeInv == INV_CONF) {
+ if (!_InventoryHidden)
MenuAction(WhichMenuBox(aniX, aniY, false), true);
- } else if (g_ino == INV_CONV) {
+ } else if (_activeInv == INV_CONV) {
index = InvItem(&aniX, &aniY, false);
ConvAction(index);
} else {
index = InvItem(&aniX, &aniY, false);
if (index != INV_NOICON) {
- if (g_InvD[g_ino].contents[index] && g_InvD[g_ino].contents[index] != g_heldItem) {
- invObj = GetInvObject(g_InvD[g_ino].contents[index]);
+ if (_invD[_activeInv].contents[index] && _invD[_activeInv].contents[index] != _heldItem) {
+ invObj = GetInvObject(_invD[_activeInv].contents[index]);
if (TinselV2)
- g_thisIcon = g_InvD[g_ino].contents[index];
+ _thisIcon = _invD[_activeInv].contents[index];
if (TinselV2 || (invObj->hScript))
InvTinselEvent(invObj, ACTION, INV_ACTION, index);
}
@@ -4736,33 +4736,33 @@ void Dialogs::InvAction() {
break;
case I_HEADER: // Maximise/unmaximise inventory
- if (!g_InvD[g_ino].resizable)
+ if (!_invD[_activeInv].resizable)
break;
- if (!g_InventoryMaximised) {
- g_InvD[g_ino].sNoofHicons = g_InvD[g_ino].NoofHicons;
- g_InvD[g_ino].sNoofVicons = g_InvD[g_ino].NoofVicons;
- g_InvD[g_ino].NoofHicons = g_InvD[g_ino].MaxHicons;
- g_InvD[g_ino].NoofVicons = g_InvD[g_ino].MaxVicons;
- g_InventoryMaximised = true;
-
- i = g_InvD[g_ino].inventoryX;
- g_InvD[g_ino].inventoryX = g_InvD[g_ino].otherX;
- g_InvD[g_ino].otherX = i;
- i = g_InvD[g_ino].inventoryY;
- g_InvD[g_ino].inventoryY = g_InvD[g_ino].otherY;
- g_InvD[g_ino].otherY = i;
+ if (!_InventoryMaximised) {
+ _invD[_activeInv].sNoofHicons = _invD[_activeInv].NoofHicons;
+ _invD[_activeInv].sNoofVicons = _invD[_activeInv].NoofVicons;
+ _invD[_activeInv].NoofHicons = _invD[_activeInv].MaxHicons;
+ _invD[_activeInv].NoofVicons = _invD[_activeInv].MaxVicons;
+ _InventoryMaximised = true;
+
+ i = _invD[_activeInv].inventoryX;
+ _invD[_activeInv].inventoryX = _invD[_activeInv].otherX;
+ _invD[_activeInv].otherX = i;
+ i = _invD[_activeInv].inventoryY;
+ _invD[_activeInv].inventoryY = _invD[_activeInv].otherY;
+ _invD[_activeInv].otherY = i;
} else {
- g_InvD[g_ino].NoofHicons = g_InvD[g_ino].sNoofHicons;
- g_InvD[g_ino].NoofVicons = g_InvD[g_ino].sNoofVicons;
- g_InventoryMaximised = false;
-
- i = g_InvD[g_ino].inventoryX;
- g_InvD[g_ino].inventoryX = g_InvD[g_ino].otherX;
- g_InvD[g_ino].otherX = i;
- i = g_InvD[g_ino].inventoryY;
- g_InvD[g_ino].inventoryY = g_InvD[g_ino].otherY;
- g_InvD[g_ino].otherY = i;
+ _invD[_activeInv].NoofHicons = _invD[_activeInv].sNoofHicons;
+ _invD[_activeInv].NoofVicons = _invD[_activeInv].sNoofVicons;
+ _InventoryMaximised = false;
+
+ i = _invD[_activeInv].inventoryX;
+ _invD[_activeInv].inventoryX = _invD[_activeInv].otherX;
+ _invD[_activeInv].otherX = i;
+ i = _invD[_activeInv].inventoryY;
+ _invD[_activeInv].inventoryY = _invD[_activeInv].otherY;
+ _invD[_activeInv].otherY = i;
}
// Delete current, and re-draw
@@ -4772,15 +4772,15 @@ void Dialogs::InvAction() {
break;
case I_UP:
- g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons;
- if (g_InvD[g_ino].FirstDisp < 0)
- g_InvD[g_ino].FirstDisp = 0;
- g_ItemsChanged = true;
+ _invD[_activeInv].FirstDisp -= _invD[_activeInv].NoofHicons;
+ if (_invD[_activeInv].FirstDisp < 0)
+ _invD[_activeInv].FirstDisp = 0;
+ _ItemsChanged = true;
break;
case I_DOWN:
- if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons * g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems) {
- g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
- g_ItemsChanged = true;
+ if (_invD[_activeInv].FirstDisp + _invD[_activeInv].NoofHicons * _invD[_activeInv].NoofVicons < _invD[_activeInv].NoofItems) {
+ _invD[_activeInv].FirstDisp += _invD[_activeInv].NoofHicons;
+ _ItemsChanged = true;
}
break;
@@ -4798,8 +4798,8 @@ void Dialogs::InvLook(const Common::Point &coOrds) {
case I_BODY:
index = InvItem(pt, false);
if (index != INV_NOICON) {
- if (g_InvD[g_ino].contents[index] && g_InvD[g_ino].contents[index] != g_heldItem) {
- invObj = GetInvObject(g_InvD[g_ino].contents[index]);
+ if (_invD[_activeInv].contents[index] && _invD[_activeInv].contents[index] != _heldItem) {
+ invObj = GetInvObject(_invD[_activeInv].contents[index]);
if (invObj->hScript)
InvTinselEvent(invObj, LOOK, INV_LOOK, index);
}
@@ -4807,7 +4807,7 @@ void Dialogs::InvLook(const Common::Point &coOrds) {
break;
case I_NOTIN:
- if (g_ino == INV_CONV)
+ if (_activeInv == INV_CONV)
ConvAction(INV_CLOSEICON);
KillInventory();
break;
@@ -4822,7 +4822,7 @@ void Dialogs::InvLook(const Common::Point &coOrds) {
/**************************************************************************/
void Dialogs::EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
- if (g_InventoryHidden)
+ if (_InventoryHidden)
return;
switch (pEvent) {
@@ -4845,7 +4845,7 @@ void Dialogs::EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
break;
case PLR_ACTION: // PLR_DLEFT
- if (g_InvDragging != ID_MDCONT)
+ if (_invDragging != ID_MDCONT)
InvDragEnd();
InvAction();
break;
@@ -4861,7 +4861,7 @@ void Dialogs::EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
case PLR_ESCAPE:
if (MenuActive()) {
if (cd.box != optionBox && cd.box != hopperBox1 && cd.box != hopperBox2)
- g_bReOpenMenu = true;
+ _reOpenMenu = true;
if ((cd.box == hopperBox1) || (cd.box == hopperBox2))
FreeSceneHopper();
}
@@ -4869,7 +4869,7 @@ void Dialogs::EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
break;
case PLR_PGDN:
- if (g_ino == INV_MENU) {
+ if (_activeInv == INV_MENU) {
// Load or Save screen
MenuPageDown();
} else {
@@ -4879,7 +4879,7 @@ void Dialogs::EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
break;
case PLR_PGUP:
- if (g_ino == INV_MENU) {
+ if (_activeInv == INV_MENU) {
// Load or Save screen
MenuPageUp();
} else {
@@ -4889,7 +4889,7 @@ void Dialogs::EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
break;
case PLR_WHEEL_DOWN:
- if (g_ino == INV_MENU) {
+ if (_activeInv == INV_MENU) {
// Load or Save screen
MenuRollDown();
} else {
@@ -4899,7 +4899,7 @@ void Dialogs::EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
break;
case PLR_WHEEL_UP:
- if (g_ino == INV_MENU) {
+ if (_activeInv == INV_MENU) {
// Load or Save screen
MenuRollUp();
} else {
@@ -4909,7 +4909,7 @@ void Dialogs::EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
break;
case PLR_HOME:
- if (g_ino == INV_MENU) {
+ if (_activeInv == INV_MENU) {
// Load or Save screen
if (cd.box == loadBox || cd.box == saveBox)
FirstFile(0);
@@ -4925,20 +4925,20 @@ void Dialogs::EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
Select(cd.selBox, true);
} else {
// Inventory window
- g_InvD[g_ino].FirstDisp = 0;
- g_ItemsChanged = true;
+ _invD[_activeInv].FirstDisp = 0;
+ _ItemsChanged = true;
}
break;
case PLR_END:
- if (g_ino == INV_MENU) {
+ if (_activeInv == INV_MENU) {
// Load or Save screen
if (cd.box == loadBox || cd.box == saveBox)
FirstFile(MAX_SAVED_FILES); // Will get reduced to appropriate value
else if (cd.box == hopperBox1)
- FirstScene(g_numScenes); // Will get reduced to appropriate value
+ FirstScene(_numScenes); // Will get reduced to appropriate value
else if (cd.box == hopperBox2)
- FirstEntry(g_numEntries); // Will get reduced to appropriate value
+ FirstEntry(_numEntries); // Will get reduced to appropriate value
else
break;
@@ -4947,10 +4947,10 @@ void Dialogs::EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
Select(cd.selBox, true);
} else {
// Inventory window
- g_InvD[g_ino].FirstDisp = g_InvD[g_ino].NoofItems - g_InvD[g_ino].NoofHicons * g_InvD[g_ino].NoofVicons;
- if (g_InvD[g_ino].FirstDisp < 0)
- g_InvD[g_ino].FirstDisp = 0;
- g_ItemsChanged = true;
+ _invD[_activeInv].FirstDisp = _invD[_activeInv].NoofItems - _invD[_activeInv].NoofHicons * _invD[_activeInv].NoofVicons;
+ if (_invD[_activeInv].FirstDisp < 0)
+ _invD[_activeInv].FirstDisp = 0;
+ _ItemsChanged = true;
}
break;
default:
@@ -4972,8 +4972,8 @@ void Dialogs::SetObjectFilm(int object, SCNHANDLE hFilm) {
invObj = GetInvObject(object);
invObj->hIconFilm = hFilm;
- if (g_heldItem != object)
- g_ItemsChanged = true;
+ if (_heldItem != object)
+ _ItemsChanged = true;
}
/**
@@ -4981,34 +4981,34 @@ void Dialogs::SetObjectFilm(int object, SCNHANDLE hFilm) {
*/
void Dialogs::syncInvInfo(Common::Serializer &s) {
for (int i = 0; i < NUM_INV; i++) {
- s.syncAsSint32LE(g_InvD[i].MinHicons);
- s.syncAsSint32LE(g_InvD[i].MinVicons);
- s.syncAsSint32LE(g_InvD[i].MaxHicons);
- s.syncAsSint32LE(g_InvD[i].MaxVicons);
- s.syncAsSint32LE(g_InvD[i].NoofHicons);
- s.syncAsSint32LE(g_InvD[i].NoofVicons);
+ s.syncAsSint32LE(_invD[i].MinHicons);
+ s.syncAsSint32LE(_invD[i].MinVicons);
+ s.syncAsSint32LE(_invD[i].MaxHicons);
+ s.syncAsSint32LE(_invD[i].MaxVicons);
+ s.syncAsSint32LE(_invD[i].NoofHicons);
+ s.syncAsSint32LE(_invD[i].NoofVicons);
for (int j = 0; j < MAX_ININV; j++) {
- s.syncAsSint32LE(g_InvD[i].contents[j]);
+ s.syncAsSint32LE(_invD[i].contents[j]);
}
- s.syncAsSint32LE(g_InvD[i].NoofItems);
- s.syncAsSint32LE(g_InvD[i].FirstDisp);
- s.syncAsSint32LE(g_InvD[i].inventoryX);
- s.syncAsSint32LE(g_InvD[i].inventoryY);
- s.syncAsSint32LE(g_InvD[i].otherX);
- s.syncAsSint32LE(g_InvD[i].otherY);
- s.syncAsSint32LE(g_InvD[i].MaxInvObj);
- s.syncAsSint32LE(g_InvD[i].hInvTitle);
- s.syncAsSint32LE(g_InvD[i].resizable);
- s.syncAsSint32LE(g_InvD[i].bMoveable);
- s.syncAsSint32LE(g_InvD[i].sNoofHicons);
- s.syncAsSint32LE(g_InvD[i].sNoofVicons);
- s.syncAsSint32LE(g_InvD[i].bMax);
+ s.syncAsSint32LE(_invD[i].NoofItems);
+ s.syncAsSint32LE(_invD[i].FirstDisp);
+ s.syncAsSint32LE(_invD[i].inventoryX);
+ s.syncAsSint32LE(_invD[i].inventoryY);
+ s.syncAsSint32LE(_invD[i].otherX);
+ s.syncAsSint32LE(_invD[i].otherY);
+ s.syncAsSint32LE(_invD[i].MaxInvObj);
+ s.syncAsSint32LE(_invD[i].hInvTitle);
+ s.syncAsSint32LE(_invD[i].resizable);
+ s.syncAsSint32LE(_invD[i].bMoveable);
+ s.syncAsSint32LE(_invD[i].sNoofHicons);
+ s.syncAsSint32LE(_invD[i].sNoofVicons);
+ s.syncAsSint32LE(_invD[i].bMax);
}
if (TinselV2) {
- for (int i = 0; i < g_numObjects; ++i)
- s.syncAsUint32LE(g_invFilms[i]);
- s.syncAsUint32LE(g_heldFilm);
+ for (int i = 0; i < _numObjects; ++i)
+ s.syncAsUint32LE(_invFilms[i]);
+ s.syncAsUint32LE(_heldFilm);
}
}
@@ -5022,43 +5022,43 @@ void Dialogs::syncInvInfo(Common::Serializer &s) {
*/
// Note: the SCHANDLE type here has been changed to a void*
void Dialogs::RegisterIcons(void *cptr, int num) {
- g_numObjects = num;
- g_invObjects = (INV_OBJECT *)cptr;
+ _numObjects = num;
+ _invObjects = (INV_OBJECT *)cptr;
if (TinselV0) {
// In Tinsel 0, the INV_OBJECT structure doesn't have an attributes field, so we
// need to 'unpack' the source structures into the standard Tinsel v1/v2 format
- MEM_NODE *node = MemoryAllocFixed(g_numObjects * sizeof(INV_OBJECT));
+ MEM_NODE *node = MemoryAllocFixed(_numObjects * sizeof(INV_OBJECT));
assert(node);
- g_invObjects = (INV_OBJECT *)MemoryDeref(node);
- assert(g_invObjects);
+ _invObjects = (INV_OBJECT *)MemoryDeref(node);
+ assert(_invObjects);
byte *srcP = (byte *)cptr;
- INV_OBJECT *destP = (INV_OBJECT *)g_invObjects;
+ INV_OBJECT *destP = (INV_OBJECT *)_invObjects;
for (int i = 0; i < num; ++i, ++destP, srcP += 12) {
memmove(destP, srcP, 12);
destP->attribute = 0;
}
} else if (TinselV2) {
- if (g_invFilms == NULL) {
+ if (_invFilms == NULL) {
// First time - allocate memory
- MEM_NODE *node = MemoryAllocFixed(g_numObjects * sizeof(SCNHANDLE));
+ MEM_NODE *node = MemoryAllocFixed(_numObjects * sizeof(SCNHANDLE));
assert(node);
- g_invFilms = (SCNHANDLE *)MemoryDeref(node);
- if (g_invFilms == NULL)
+ _invFilms = (SCNHANDLE *)MemoryDeref(node);
+ if (_invFilms == NULL)
error(NO_MEM, "inventory scripts");
- memset(g_invFilms, 0, g_numObjects * sizeof(SCNHANDLE));
+ memset(_invFilms, 0, _numObjects * sizeof(SCNHANDLE));
}
// Add defined permanent conversation icons
// and store all the films separately
int i;
INV_OBJECT *pio;
- for (i = 0, pio = g_invObjects; i < g_numObjects; i++, pio++) {
+ for (i = 0, pio = _invObjects; i < _numObjects; i++, pio++) {
if (pio->attribute & PERMACONV)
PermaConvIcon(pio->id, pio->attribute & CONVENDITEM);
- g_invFilms[i] = pio->hIconFilm;
+ _invFilms[i] = pio->hIconFilm;
}
}
}
@@ -5072,7 +5072,7 @@ void Dialogs::setInvWinParts(SCNHANDLE hf) {
const FILM *pfilm;
#endif
- g_hWinParts = hf;
+ _hWinParts = hf;
#ifdef DEBUG
pfilm = (const FILM *)LockMem(hf);
@@ -5089,7 +5089,7 @@ void Dialogs::setFlagFilms(SCNHANDLE hf) {
const FILM *pfilm;
#endif
- g_flagFilm = hf;
+ _flagFilm = hf;
#ifdef DEBUG
pfilm = (const FILM *)LockMem(hf);
@@ -5101,7 +5101,7 @@ void Dialogs::setFlagFilms(SCNHANDLE hf) {
* Called from Glitter function 'DecCStrings()'
*/
void Dialogs::setConfigStrings(SCNHANDLE *tp) {
- memcpy(g_configStrings, tp, sizeof(g_configStrings));
+ memcpy(_configStrings, tp, sizeof(_configStrings));
}
/**
@@ -5125,36 +5125,36 @@ void Dialogs::idec_inv(int num, SCNHANDLE text, int MaxContents,
if (StartHeight > MaxHeight)
StartHeight = MaxHeight;
- g_InventoryState = IDLE_INV;
+ _inventoryState = IDLE_INV;
- g_InvD[num].MaxHicons = MaxWidth;
- g_InvD[num].MinHicons = MinWidth;
- g_InvD[num].MaxVicons = MaxHeight;
- g_InvD[num].MinVicons = MinHeight;
+ _invD[num].MaxHicons = MaxWidth;
+ _invD[num].MinHicons = MinWidth;
+ _invD[num].MaxVicons = MaxHeight;
+ _invD[num].MinVicons = MinHeight;
- g_InvD[num].NoofHicons = StartWidth;
- g_InvD[num].NoofVicons = StartHeight;
+ _invD[num].NoofHicons = StartWidth;
+ _invD[num].NoofVicons = StartHeight;
- memset(g_InvD[num].contents, 0, sizeof(g_InvD[num].contents));
- g_InvD[num].NoofItems = 0;
+ memset(_invD[num].contents, 0, sizeof(_invD[num].contents));
+ _invD[num].NoofItems = 0;
- g_InvD[num].FirstDisp = 0;
+ _invD[num].FirstDisp = 0;
- g_InvD[num].inventoryX = startx;
- g_InvD[num].inventoryY = starty;
- g_InvD[num].otherX = 21;
- g_InvD[num].otherY = 15;
+ _invD[num].inventoryX = startx;
+ _invD[num].inventoryY = starty;
+ _invD[num].otherX = 21;
+ _invD[num].otherY = 15;
- g_InvD[num].MaxInvObj = MaxContents;
+ _invD[num].MaxInvObj = MaxContents;
- g_InvD[num].hInvTitle = text;
+ _invD[num].hInvTitle = text;
if (MaxWidth != MinWidth && MaxHeight != MinHeight)
- g_InvD[num].resizable = true;
+ _invD[num].resizable = true;
- g_InvD[num].bMoveable = moveable;
+ _invD[num].bMoveable = moveable;
- g_InvD[num].bMax = false;
+ _invD[num].bMax = false;
}
/**
@@ -5202,7 +5202,7 @@ void Dialogs::idec_inv2(SCNHANDLE text, int MaxContents,
int Dialogs::InvGetLimit(int invno) {
assert(invno == INV_1 || invno == INV_2); // only INV_1 and INV_2 supported
- return g_InvD[invno].MaxInvObj;
+ return _invD[invno].MaxInvObj;
}
/**
@@ -5210,12 +5210,12 @@ int Dialogs::InvGetLimit(int invno) {
*/
void Dialogs::InvSetLimit(int invno, int MaxContents) {
assert(invno == INV_1 || invno == INV_2); // only INV_1 and INV_2 supported
- assert(MaxContents >= g_InvD[invno].NoofItems); // can't reduce maximum contents below current contents
+ assert(MaxContents >= _invD[invno].NoofItems); // can't reduce maximum contents below current contents
if (MaxContents > MAX_ININV)
MaxContents = MAX_ININV; // Max contents
- g_InvD[invno].MaxInvObj = MaxContents;
+ _invD[invno].MaxInvObj = MaxContents;
}
/**
@@ -5230,34 +5230,34 @@ void Dialogs::InvSetSize(int invno, int MinWidth, int MinHeight,
if (StartHeight > MaxHeight)
StartHeight = MaxHeight;
- g_InvD[invno].MaxHicons = MaxWidth;
- g_InvD[invno].MinHicons = MinWidth;
- g_InvD[invno].MaxVicons = MaxHeight;
- g_InvD[invno].MinVicons = MinHeight;
+ _invD[invno].MaxHicons = MaxWidth;
+ _invD[invno].MinHicons = MinWidth;
+ _invD[invno].MaxVicons = MaxHeight;
+ _invD[invno].MinVicons = MinHeight;
- g_InvD[invno].NoofHicons = StartWidth;
- g_InvD[invno].NoofVicons = StartHeight;
+ _invD[invno].NoofHicons = StartWidth;
+ _invD[invno].NoofVicons = StartHeight;
if (MaxWidth != MinWidth && MaxHeight != MinHeight)
- g_InvD[invno].resizable = true;
+ _invD[invno].resizable = true;
else
- g_InvD[invno].resizable = false;
+ _invD[invno].resizable = false;
- g_InvD[invno].bMax = false;
+ _invD[invno].bMax = false;
}
/**************************************************************************/
bool Dialogs::IsTopWindow() {
- return (g_InventoryState == BOGUS_INV);
+ return (_inventoryState == BOGUS_INV);
}
bool Dialogs::MenuActive() {
- return (g_InventoryState == ACTIVE_INV && g_ino == INV_CONF);
+ return (_inventoryState == ACTIVE_INV && _activeInv == INV_CONF);
}
bool Dialogs::IsConvWindow() {
- return (g_InventoryState == ACTIVE_INV && g_ino == INV_CONV);
+ return (_inventoryState == ACTIVE_INV && _activeInv == INV_CONV);
}
void Dialogs::CallFunction(BFUNC boxFunc) {
@@ -5334,12 +5334,12 @@ void Dialogs::CallFunction(BFUNC boxFunc) {
}
const FILM *Dialogs::GetWindowData() {
- return (const FILM *)_vm->_handle->LockMem(g_hWinParts);
+ return (const FILM *)_vm->_handle->LockMem(_hWinParts);
}
void Dialogs::Redraw() {
if (DisplayObjectsActive()) {
- if (g_ItemsChanged && !ConfigurationIsActive() && !InventoryIsHidden()) {
+ if (_ItemsChanged && !ConfigurationIsActive() && !InventoryIsHidden()) {
FillInInventory();
// Needed when clicking on scroll bar.
@@ -5347,12 +5347,12 @@ void Dialogs::Redraw() {
_vm->_cursor->GetCursorXY(&curX, &curY, false);
InvCursor(IC_AREA, curX, curY);
- g_ItemsChanged = false;
+ _ItemsChanged = false;
}
if (!ConfigurationIsActive()) {
for (int i = 0; i < MAX_ICONS; i++) {
- if (g_iconArray[i] != NULL)
- StepAnimScript(&g_iconAnims[i]);
+ if (_iconArray[i] != NULL)
+ StepAnimScript(&_iconAnims[i]);
}
}
if (IsMixingDeskControl()) {
@@ -5415,36 +5415,36 @@ static void ButtonPress(CORO_PARAM, CONFBOX *box) {
// Replace highlight image with normal image
pfilm = _vm->_dialogs->GetWindowData();
- if (_vm->_dialogs->g_iconArray[HL1] != NULL)
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL1]);
+ if (_vm->_dialogs->_iconArray[HL1] != NULL)
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->_iconArray[HL1]);
pfilm = _vm->_dialogs->GetWindowData();
- _vm->_dialogs->g_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + NORMGRAPH], -1);
- MultiSetAniXY(_vm->_dialogs->g_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
- MultiSetZPosition(_vm->_dialogs->g_iconArray[HL1], Z_INV_ICONS + 1);
+ _vm->_dialogs->_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + NORMGRAPH], -1);
+ MultiSetAniXY(_vm->_dialogs->_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
+ MultiSetZPosition(_vm->_dialogs->_iconArray[HL1], Z_INV_ICONS + 1);
// Hold normal image for 1 frame
CORO_SLEEP(1);
- if (_vm->_dialogs->g_iconArray[HL1] == NULL)
+ if (_vm->_dialogs->_iconArray[HL1] == NULL)
return;
// Replace normal image with depresses image
pfilm = _vm->_dialogs->GetWindowData();
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL1]);
- _vm->_dialogs->g_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + DOWNGRAPH], -1);
- MultiSetAniXY(_vm->_dialogs->g_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
- MultiSetZPosition(_vm->_dialogs->g_iconArray[HL1], Z_INV_ICONS + 1);
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->_iconArray[HL1]);
+ _vm->_dialogs->_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + DOWNGRAPH], -1);
+ MultiSetAniXY(_vm->_dialogs->_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
+ MultiSetZPosition(_vm->_dialogs->_iconArray[HL1], Z_INV_ICONS + 1);
// Hold depressed image for 2 frames
CORO_SLEEP(2);
- if (_vm->_dialogs->g_iconArray[HL1] == NULL)
+ if (_vm->_dialogs->_iconArray[HL1] == NULL)
return;
// Replace depressed image with normal image
pfilm = _vm->_dialogs->GetWindowData();
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL1]);
- _vm->_dialogs->g_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + NORMGRAPH], -1);
- MultiSetAniXY(_vm->_dialogs->g_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
- MultiSetZPosition(_vm->_dialogs->g_iconArray[HL1], Z_INV_ICONS + 1);
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->_iconArray[HL1]);
+ _vm->_dialogs->_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + NORMGRAPH], -1);
+ MultiSetAniXY(_vm->_dialogs->_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
+ MultiSetZPosition(_vm->_dialogs->_iconArray[HL1], Z_INV_ICONS + 1);
CORO_SLEEP(1);
@@ -5462,9 +5462,9 @@ static void ButtonToggle(CORO_PARAM, CONFBOX *box) {
assert((box->boxType == TOGGLE) || (box->boxType == TOGGLE1) || (box->boxType == TOGGLE2));
// Remove hilight image
- if (_vm->_dialogs->g_iconArray[HL1] != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL1]);
- _vm->_dialogs->g_iconArray[HL1] = nullptr;
+ if (_vm->_dialogs->_iconArray[HL1] != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->_iconArray[HL1]);
+ _vm->_dialogs->_iconArray[HL1] = nullptr;
}
// Hold normal image for 1 frame
@@ -5474,13 +5474,13 @@ static void ButtonToggle(CORO_PARAM, CONFBOX *box) {
// Add depressed image
pfilm = _vm->_dialogs->GetWindowData();
- _vm->_dialogs->g_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + DOWNGRAPH], -1);
- MultiSetAniXY(_vm->_dialogs->g_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
- MultiSetZPosition(_vm->_dialogs->g_iconArray[HL1], Z_INV_ICONS + 1);
+ _vm->_dialogs->_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + DOWNGRAPH], -1);
+ MultiSetAniXY(_vm->_dialogs->_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
+ MultiSetZPosition(_vm->_dialogs->_iconArray[HL1], Z_INV_ICONS + 1);
// Hold depressed image for 1 frame
CORO_SLEEP(1);
- if (_vm->_dialogs->g_iconArray[HL1] == NULL)
+ if (_vm->_dialogs->_iconArray[HL1] == NULL)
return;
// Toggle state
@@ -5493,20 +5493,20 @@ static void ButtonToggle(CORO_PARAM, CONFBOX *box) {
// New state, depressed image
pfilm = _vm->_dialogs->GetWindowData();
- if (_vm->_dialogs->g_iconArray[HL1] != NULL)
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL1]);
- _vm->_dialogs->g_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + DOWNGRAPH], -1);
- MultiSetAniXY(_vm->_dialogs->g_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
- MultiSetZPosition(_vm->_dialogs->g_iconArray[HL1], Z_INV_ICONS + 1);
+ if (_vm->_dialogs->_iconArray[HL1] != NULL)
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->_iconArray[HL1]);
+ _vm->_dialogs->_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + DOWNGRAPH], -1);
+ MultiSetAniXY(_vm->_dialogs->_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
+ MultiSetZPosition(_vm->_dialogs->_iconArray[HL1], Z_INV_ICONS + 1);
// Hold new depressed image for 1 frame
CORO_SLEEP(1);
- if (_vm->_dialogs->g_iconArray[HL1] == NULL)
+ if (_vm->_dialogs->_iconArray[HL1] == NULL)
return;
// New state, normal
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL1]);
- _vm->_dialogs->g_iconArray[HL1] = nullptr;
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->_iconArray[HL1]);
+ _vm->_dialogs->_iconArray[HL1] = nullptr;
// Hold normal image for 1 frame
CORO_SLEEP(1);
@@ -5515,11 +5515,11 @@ static void ButtonToggle(CORO_PARAM, CONFBOX *box) {
// New state, highlighted
pfilm = _vm->_dialogs->GetWindowData();
- if (_vm->_dialogs->g_iconArray[HL1] != NULL)
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->g_iconArray[HL1]);
- _vm->_dialogs->g_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + HIGRAPH], -1);
- MultiSetAniXY(_vm->_dialogs->g_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
- MultiSetZPosition(_vm->_dialogs->g_iconArray[HL1], Z_INV_ICONS + 1);
+ if (_vm->_dialogs->_iconArray[HL1] != NULL)
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_dialogs->_iconArray[HL1]);
+ _vm->_dialogs->_iconArray[HL1] = _vm->_dialogs->AddObject(&pfilm->reels[box->bi + HIGRAPH], -1);
+ MultiSetAniXY(_vm->_dialogs->_iconArray[HL1], _vm->_dialogs->CurrentInventoryX() + box->xpos, _vm->_dialogs->CurrentInventoryY() + box->ypos);
+ MultiSetZPosition(_vm->_dialogs->_iconArray[HL1], Z_INV_ICONS + 1);
CORO_END_CODE;
}
@@ -5535,7 +5535,7 @@ extern void InventoryProcess(CORO_PARAM, const void *) {
CORO_BEGIN_CODE(_ctx);
if (NumberOfLanguages() <= 1)
- _vm->_dialogs->g_bNoLanguage = true;
+ _vm->_dialogs->_noLanguage = true;
while (1) {
CORO_SLEEP(1); // allow scheduling
@@ -5591,7 +5591,7 @@ static void ObjectProcess(CORO_PARAM, const void *param) {
CORO_INVOKE_1(Interpret, _ctx->pic);
if (to->event == POINTED) {
- _ctx->ThisPointedWait = ++_vm->_dialogs->g_PointedWaitCount;
+ _ctx->ThisPointedWait = ++_vm->_dialogs->_pointedWaitCount;
while (1) {
CORO_SLEEP(1);
int x, y;
@@ -5600,7 +5600,7 @@ static void ObjectProcess(CORO_PARAM, const void *param) {
break;
// Fix the 'repeated pressing bug'
- if (_ctx->ThisPointedWait != _vm->_dialogs->g_PointedWaitCount)
+ if (_ctx->ThisPointedWait != _vm->_dialogs->_pointedWaitCount)
CORO_KILL_SELF();
}
@@ -5620,7 +5620,7 @@ static void InvTinselEvent(INV_OBJECT *pinvo, TINSEL_EVENT event, PLR_EVENT be,
if (_vm->_dialogs->InventoryIsHidden() || (TinselV2 && !pinvo->hScript))
return;
- _vm->_dialogs->g_GlitterIndex = index;
+ _vm->_dialogs->_glitterIndex = index;
CoroScheduler.createProcess(PID_TCODE, ObjectProcess, &to, sizeof(to));
}
diff --git a/engines/tinsel/dialogs.h b/engines/tinsel/dialogs.h
index d6a4154098..2191f742ab 100644
--- a/engines/tinsel/dialogs.h
+++ b/engines/tinsel/dialogs.h
@@ -86,7 +86,7 @@ enum InvCursorFN { IC_AREA,
#define DEFINV2 0x10
#define PERMACONV 0x20
#define CONVENDITEM 0x40
-#define sliderRange (g_sliderYmax - g_sliderYmin)
+#define sliderRange (_sliderYmax - _sliderYmin)
#define MAXSLIDES 4
#define MAX_PERMICONS 10 // Max permanent conversation icons
#define MAXHICONS 10 // Max dimensions of
@@ -346,23 +346,23 @@ public:
void InvCursor(InvCursorFN fn, int CurX, int CurY);
INV_OBJECT *GetInvObject(int id);
bool UpdateString(const Common::KeyState &kbd);
- bool InventoryIsActive() { return g_InventoryState == ACTIVE_INV; }
- bool IsMixingDeskControl() { return g_InvDragging == ID_MDCONT; }
- int CurrentInventoryX() { return g_InvD[g_ino].inventoryX; }
- int CurrentInventoryY() { return g_InvD[g_ino].inventoryY; }
- bool ConfigurationIsActive() { return g_ino == INV_CONF; }
- bool DisplayObjectsActive() { return g_objArray[0] != NULL; }
- bool InventoryIsHidden() { return g_InventoryHidden; }
+ bool InventoryIsActive() { return _inventoryState == ACTIVE_INV; }
+ bool IsMixingDeskControl() { return _invDragging == ID_MDCONT; }
+ int CurrentInventoryX() { return _invD[_activeInv].inventoryX; }
+ int CurrentInventoryY() { return _invD[_activeInv].inventoryY; }
+ bool ConfigurationIsActive() { return _activeInv == INV_CONF; }
+ bool DisplayObjectsActive() { return _objArray[0] != NULL; }
+ bool InventoryIsHidden() { return _InventoryHidden; }
const FILM *GetWindowData();
void Redraw();
- bool g_bNoLanguage;
- int g_GlitterIndex;
- volatile int g_PointedWaitCount; // used by ObjectProcess - fix the 'repeated pressing bug'
+ bool _noLanguage;
+ int _glitterIndex;
+ volatile int _pointedWaitCount; // used by ObjectProcess - fix the 'repeated pressing bug'
// For editing save game names
- char g_sedit[SG_DESC_LEN + 2];
+ char _saveGameDesc[SG_DESC_LEN + 2];
- OBJECT *g_iconArray[MAX_ICONS]; // Current display objects (icons)
+ OBJECT *_iconArray[MAX_ICONS]; // Current display objects (icons)
private:
int WhichMenuBox(int curX, int curY, bool bSlides);
@@ -429,99 +429,99 @@ private:
int startx, int starty, bool moveable);
//----- Permanent data (set once) -----
- SCNHANDLE g_flagFilm; // Window members and cursors' graphic data
- SCNHANDLE g_configStrings[20];
+ SCNHANDLE _flagFilm; // Window members and cursors' graphic data
+ SCNHANDLE _configStrings[20];
- INV_DEF g_InvD[NUM_INV]; // Conversation + 2 inventories + ...
- int g_ino; // Which inventory is currently active
- INV_OBJECT *g_invObjects; // Inventory objects' data
- int g_numObjects; // Number of inventory objects
- SCNHANDLE *g_invFilms;
- DIRECTION g_initialDirection;
+ INV_DEF _invD[NUM_INV]; // Conversation + 2 inventories + ...
+ int _activeInv; // Which inventory is currently active
+ INV_OBJECT *_invObjects; // Inventory objects' data
+ int _numObjects; // Number of inventory objects
+ SCNHANDLE *_invFilms;
+ DIRECTION _initialDirection;
//----- Permanent data (updated, valid while inventory closed) -----
- int g_heldItem = INV_NOICON; // Current held item
+ int _heldItem = INV_NOICON; // Current held item
- SCNHANDLE g_heldFilm;
- SCNHANDLE g_hWinParts; // Window members and cursors' graphic data
+ SCNHANDLE _heldFilm;
+ SCNHANDLE _hWinParts; // Window members and cursors' graphic data
// Permanent contents of conversation inventory
- int g_permIcons[MAX_PERMICONS]; // Basic items i.e. permanent contents
- int g_numPermIcons; // - copy to conv. inventory at pop-up time
- int g_numEndIcons;
+ int _permIcons[MAX_PERMICONS]; // Basic items i.e. permanent contents
+ int _numPermIcons; // - copy to conv. inventory at pop-up time
+ int _numEndIcons;
//----- Data pertinant to current active inventory -----
- bool g_InventoryHidden;
- bool g_InventoryMaximised;
- bool g_ItemsChanged; // When set, causes items to be re-drawn
+ bool _InventoryHidden;
+ bool _InventoryMaximised;
+ bool _ItemsChanged; // When set, causes items to be re-drawn
- int g_SuppH; // 'Linear' element of
- int g_SuppV; // dimensions during re-sizing
+ int _SuppH; // 'Linear' element of
+ int _SuppV; // dimensions during re-sizing
- int g_Ychange; //
- int g_Ycompensate; // All to do with re-sizing.
- int g_Xchange; //
- int g_Xcompensate; //
+ int _yChange; //
+ int _yCompensate; // All to do with re-sizing.
+ int _xChange; //
+ int _xCompensate; //
- bool g_bReOpenMenu;
+ bool _reOpenMenu;
- int g_TL, g_TR, g_BL, g_BR; // Used during window construction
- int g_TLwidth, g_TLheight; //
- int g_TRwidth; //
- int g_BLheight; //
+ int _TL, _TR, _BL, _BR; // Used during window construction
+ int _TLwidth, _TLheight; //
+ int _TRwidth; //
+ int _BLheight; //
- LANGUAGE g_displayedLanguage;
+ LANGUAGE _displayedLanguage;
- OBJECT *g_objArray[MAX_WCOMP]; // Current display objects (window)
- OBJECT *g_DobjArray[MAX_WCOMP]; // Current display objects (re-sizing window)
- ANIM g_iconAnims[MAX_ICONS];
+ OBJECT *_objArray[MAX_WCOMP]; // Current display objects (window)
+ OBJECT *_dispObjArray[MAX_WCOMP]; // Current display objects (re-sizing window)
+ ANIM _iconAnims[MAX_ICONS];
- OBJECT *g_RectObject, *g_SlideObject; // Current display objects, for reference
+ OBJECT *_rectObject, *_slideObject; // Current display objects, for reference
// objects are in objArray.
- int g_sliderYpos; // For positioning the slider
- int g_sliderYmax, g_sliderYmin; //
+ int _sliderYpos; // For positioning the slider
+ int _sliderYmax, _sliderYmin; //
// Also to do with the slider
struct {
int n;
int y;
- } g_slideStuff[MAX_ININV_TOT + 1];
+ } _slideStuff[MAX_ININV_TOT + 1];
struct MDSLIDES {
int num;
OBJECT *obj;
int min, max;
};
- MDSLIDES g_mdSlides[MAXSLIDES];
- int g_numMdSlides;
+ MDSLIDES _mdSlides[MAXSLIDES];
+ int _numMdSlides;
// Icon clicked on to cause an event
// - Passed to conversation polygon or actor code via Topic()
// - (sometimes) Passed to inventory icon code via OtherObject()
- int g_thisIcon = 0;
+ int _thisIcon = 0;
- CONV_PARAM g_thisConvFn; // Top, 'Middle' or Bottom
- HPOLYGON g_thisConvPoly; // Conversation code is in a polygon code block
- int g_thisConvActor; // ...or an actor's code block.
- int g_pointedIcon; // used by InvLabels - icon pointed to on last call
- int g_sX; // used by SlideMSlider() - current x-coordinate
- int g_lX; // used by SlideMSlider() - last x-coordinate
+ CONV_PARAM _thisConvFn; // Top, 'Middle' or Bottom
+ HPOLYGON _thisConvPoly; // Conversation code is in a polygon code block
+ int _thisConvActor; // ...or an actor's code block.
+ int _pointedIcon; // used by InvLabels - icon pointed to on last call
+ int _sX; // used by SlideMSlider() - current x-coordinate
+ int _lX; // used by SlideMSlider() - last x-coordinate
- bool g_bMoveOnUnHide; // Set before start of conversation
+ bool _bMoveOnUnHide; // Set before start of conversation
// - causes conversation to be started in a sensible place
- PHOPPER g_pHopper;
- PHOPENTRY g_pEntries;
- int g_numScenes;
+ PHOPPER _pHopper;
+ PHOPENTRY _pEntries;
+ int _numScenes;
- int g_numEntries;
+ int _numEntries;
- PHOPPER g_pChosenScene;
+ PHOPPER _pChosenScene;
- int g_lastChosenScene;
- bool g_bRemember;
+ int _lastChosenScene;
+ bool _bRemember;
enum { IC_NORMAL,
IC_DR,
IC_UR,
@@ -534,7 +534,7 @@ private:
enum { NO_INV,
IDLE_INV,
ACTIVE_INV,
- BOGUS_INV } g_InventoryState;
+ BOGUS_INV } _inventoryState;
enum { ID_NONE,
ID_MOVE,
@@ -548,7 +548,7 @@ private:
ID_BLEFT,
ID_BRIGHT,
ID_CSLIDE,
- ID_MDCONT } g_InvDragging;
+ ID_MDCONT } _invDragging;
};
void ObjectEvent(CORO_PARAM, int objId, TINSEL_EVENT event, bool bWait, int myEscape, bool *result = NULL);
Commit: 086f1832e568b79fd166751f0cb517f6cd4bcf73
https://github.com/scummvm/scummvm/commit/086f1832e568b79fd166751f0cb517f6cd4bcf73
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-10-04T01:15:23+03:00
Commit Message:
TINSEL: Update metaengine.cpp with the changes to SG_DESC_LEN
Changed paths:
engines/tinsel/metaengine.cpp
diff --git a/engines/tinsel/metaengine.cpp b/engines/tinsel/metaengine.cpp
index 91a33d7a9f..f620169b76 100644
--- a/engines/tinsel/metaengine.cpp
+++ b/engines/tinsel/metaengine.cpp
@@ -118,10 +118,10 @@ SaveStateDescriptor TinselMetaEngine::querySaveMetaInfos(const char *target, int
file->readUint32LE(); // skip id
file->readUint32LE(); // skip size
uint32 ver = file->readUint32LE();
- char saveDesc[Tinsel::SG_DESC_LEN];
+ char saveDesc[SG_DESC_LEN];
file->read(saveDesc, sizeof(saveDesc));
- saveDesc[Tinsel::SG_DESC_LEN - 1] = 0;
+ saveDesc[SG_DESC_LEN - 1] = 0;
SaveStateDescriptor desc(slot, saveDesc);
int8 tm_year = file->readUint16LE();
@@ -164,10 +164,10 @@ SaveStateList TinselMetaEngine::listSaves(const char *target) const {
in->readUint32LE(); // skip id
in->readUint32LE(); // skip size
in->readUint32LE(); // skip version
- char saveDesc[Tinsel::SG_DESC_LEN];
+ char saveDesc[SG_DESC_LEN];
in->read(saveDesc, sizeof(saveDesc));
- saveDesc[Tinsel::SG_DESC_LEN - 1] = 0;
+ saveDesc[SG_DESC_LEN - 1] = 0;
saveList.push_back(SaveStateDescriptor(slotNum, saveDesc));
delete in;
Commit: 2b62338e5eb5d64d96dfa25cebd8976c712e995d
https://github.com/scummvm/scummvm/commit/2b62338e5eb5d64d96dfa25cebd8976c712e995d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-10-04T01:15:24+03:00
Commit Message:
TINSEL: Enable the Return to Launcher feature
A lot of the global variables have been moved into classes, which get
reinitialized on launch. The rest of the global variables are reset
when the engine gets destroyed. Thus, this feature can be safely
enabled now.
Changed paths:
engines/tinsel/metaengine.cpp
diff --git a/engines/tinsel/metaengine.cpp b/engines/tinsel/metaengine.cpp
index f620169b76..f95abe155f 100644
--- a/engines/tinsel/metaengine.cpp
+++ b/engines/tinsel/metaengine.cpp
@@ -91,17 +91,7 @@ bool TinselMetaEngine::hasFeature(MetaEngineFeature f) const {
bool Tinsel::TinselEngine::hasFeature(EngineFeature f) const {
return
-#if 0
- // FIXME: It is possible to return to the launcher from tinsel.
- // But then any attempt to re-enter the engine will lead to
- // a crash or at least seriously broken behavior.
- //
- // This is because the Tinsel engine makes use of tons of
- // global variables (static and non-static) which are never
- // explicitly re-initialized when the engine is started
- // for a second time.
(f == kSupportsReturnToLauncher) ||
-#endif
(f == kSupportsLoadingDuringRuntime);
}
More information about the Scummvm-git-logs
mailing list