aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Turner2012-02-22 15:38:00 -0800
committerDavid Turner2012-02-22 15:38:00 -0800
commit8948a4a65647acf1c4968ba921413f70ea638219 (patch)
tree024ec7f595346559bb786afd38e519f4e6351ef3
parent784ee5dd655c3e0dfa7007e3cb746c3bc5cd7f29 (diff)
parentbe35baddc70e0299502ff4e5858a5865c8a3a108 (diff)
downloadscummvm-rg350-8948a4a65647acf1c4968ba921413f70ea638219.tar.gz
scummvm-rg350-8948a4a65647acf1c4968ba921413f70ea638219.tar.bz2
scummvm-rg350-8948a4a65647acf1c4968ba921413f70ea638219.zip
Merge pull request #194 from fuzzie/tinselglobals
TINSEL: Rename globals to add g_ prefix.
-rw-r--r--engines/tinsel/background.cpp38
-rw-r--r--engines/tinsel/bg.cpp98
-rw-r--r--engines/tinsel/cursor.cpp298
-rw-r--r--engines/tinsel/dialogs.cpp2249
-rw-r--r--engines/tinsel/drives.cpp38
-rw-r--r--engines/tinsel/events.cpp86
-rw-r--r--engines/tinsel/font.cpp32
-rw-r--r--engines/tinsel/graphics.cpp4
-rw-r--r--engines/tinsel/handle.cpp108
-rw-r--r--engines/tinsel/heapmem.cpp66
-rw-r--r--engines/tinsel/mareels.cpp34
-rw-r--r--engines/tinsel/move.cpp40
-rw-r--r--engines/tinsel/music.cpp72
-rw-r--r--engines/tinsel/palette.cpp132
-rw-r--r--engines/tinsel/pcode.cpp98
-rw-r--r--engines/tinsel/pdisplay.cpp54
-rw-r--r--engines/tinsel/play.cpp50
-rw-r--r--engines/tinsel/rince.cpp92
-rw-r--r--engines/tinsel/saveload.cpp155
-rw-r--r--engines/tinsel/savescn.cpp140
-rw-r--r--engines/tinsel/scene.cpp60
-rw-r--r--engines/tinsel/sched.cpp64
-rw-r--r--engines/tinsel/scroll.cpp292
-rw-r--r--engines/tinsel/scroll.h6
-rw-r--r--engines/tinsel/sound.cpp34
-rw-r--r--engines/tinsel/strres.cpp56
-rw-r--r--engines/tinsel/strres.h2
-rw-r--r--engines/tinsel/sysvar.cpp20
-rw-r--r--engines/tinsel/text.cpp8
-rw-r--r--engines/tinsel/timers.cpp50
-rw-r--r--engines/tinsel/tinlib.cpp108
-rw-r--r--engines/tinsel/tinsel.cpp172
-rw-r--r--engines/tinsel/token.cpp28
33 files changed, 2388 insertions, 2396 deletions
diff --git a/engines/tinsel/background.cpp b/engines/tinsel/background.cpp
index 72397db97f..8e3fc50f12 100644
--- a/engines/tinsel/background.cpp
+++ b/engines/tinsel/background.cpp
@@ -34,7 +34,7 @@ namespace Tinsel {
// FIXME: Avoid non-const global vars
// current background
-const BACKGND *pCurBgnd = NULL;
+const BACKGND *g_pCurBgnd = NULL;
/**
* Called to initialize a background.
@@ -46,7 +46,7 @@ void InitBackground(const BACKGND *pBgnd) {
PLAYFIELD *pPlayfield; // pointer to current playfield
// set current background
- pCurBgnd = pBgnd;
+ g_pCurBgnd = pBgnd;
// init background sky color
SetBgndColor(pBgnd->rgbSkyColor);
@@ -83,13 +83,13 @@ void PlayfieldSetPos(int which, int newXpos, int newYpos) {
PLAYFIELD *pPlayfield; // pointer to relavent playfield
// make sure there is a background
- assert(pCurBgnd != NULL);
+ assert(g_pCurBgnd != NULL);
// make sure the playfield number is in range
- assert(which >= 0 && which < pCurBgnd->numPlayfields);
+ assert(which >= 0 && which < g_pCurBgnd->numPlayfields);
// get playfield pointer
- pPlayfield = pCurBgnd->fieldArray + which;
+ pPlayfield = g_pCurBgnd->fieldArray + which;
// set new integer position
pPlayfield->fieldX = intToFrac(newXpos);
@@ -110,13 +110,13 @@ void PlayfieldGetPos(int which, int *pXpos, int *pYpos) {
PLAYFIELD *pPlayfield; // pointer to relavent playfield
// make sure there is a background
- assert(pCurBgnd != NULL);
+ assert(g_pCurBgnd != NULL);
// make sure the playfield number is in range
- assert(which >= 0 && which < pCurBgnd->numPlayfields);
+ assert(which >= 0 && which < g_pCurBgnd->numPlayfields);
// get playfield pointer
- pPlayfield = pCurBgnd->fieldArray + which;
+ pPlayfield = g_pCurBgnd->fieldArray + which;
// get current integer position
*pXpos = fracToInt(pPlayfield->fieldX);
@@ -132,13 +132,13 @@ int PlayfieldGetCenterX(int which) {
PLAYFIELD *pPlayfield; // pointer to relavent playfield
// make sure there is a background
- assert(pCurBgnd != NULL);
+ assert(g_pCurBgnd != NULL);
// make sure the playfield number is in range
- assert(which >= 0 && which < pCurBgnd->numPlayfields);
+ assert(which >= 0 && which < g_pCurBgnd->numPlayfields);
// get playfield pointer
- pPlayfield = pCurBgnd->fieldArray + which;
+ pPlayfield = g_pCurBgnd->fieldArray + which;
// get current integer position
return fracToInt(pPlayfield->fieldX) + SCREEN_WIDTH/2;
@@ -153,13 +153,13 @@ OBJECT **GetPlayfieldList(int which) {
PLAYFIELD *pPlayfield; // pointer to relavent playfield
// make sure there is a background
- assert(pCurBgnd != NULL);
+ assert(g_pCurBgnd != NULL);
// make sure the playfield number is in range
- assert(which >= 0 && which < pCurBgnd->numPlayfields);
+ assert(which >= 0 && which < g_pCurBgnd->numPlayfields);
// get playfield pointer
- pPlayfield = pCurBgnd->fieldArray + which;
+ pPlayfield = g_pCurBgnd->fieldArray + which;
// return the display list pointer for this playfield
return &pPlayfield->pDispList;
@@ -177,13 +177,13 @@ void DrawBackgnd() {
int prevX, prevY; // save interger part of position
Common::Point ptWin; // window top left
- if (pCurBgnd == NULL)
+ if (g_pCurBgnd == NULL)
return; // no current background
// scroll each background playfield
- for (i = 0; i < pCurBgnd->numPlayfields; i++) {
+ for (i = 0; i < g_pCurBgnd->numPlayfields; i++) {
// get pointer to correct playfield
- pPlay = pCurBgnd->fieldArray + i;
+ pPlay = g_pCurBgnd->fieldArray + i;
// save integer part of position
prevX = fracToInt(pPlay->fieldX);
@@ -220,11 +220,11 @@ void DrawBackgnd() {
for (RectList::const_iterator r = clipRects.begin(); r != clipRects.end(); ++r) {
// clear the clip rectangle on the virtual screen
// for each background playfield
- for (i = 0; i < pCurBgnd->numPlayfields; i++) {
+ for (i = 0; i < g_pCurBgnd->numPlayfields; i++) {
Common::Rect rcPlayClip; // clip rect for this playfield
// get pointer to correct playfield
- pPlay = pCurBgnd->fieldArray + i;
+ pPlay = g_pCurBgnd->fieldArray + i;
// convert fixed point window pos to a int
ptWin.x = fracToInt(pPlay->fieldX);
diff --git a/engines/tinsel/bg.cpp b/engines/tinsel/bg.cpp
index cf692e16ea..72ba05f0b9 100644
--- a/engines/tinsel/bg.cpp
+++ b/engines/tinsel/bg.cpp
@@ -47,59 +47,59 @@ namespace Tinsel {
#define MAX_BG 10
// FIXME: Avoid non-const global vars
-static SCNHANDLE hBgPal = 0; // Background's palette
-static POBJECT pBG[MAX_BG];
-static ANIM thisAnim[MAX_BG]; // used by BGmainProcess()
-static int BGspeed = 0;
-static SCNHANDLE hBackground = 0; // Current scene handle - stored in case of Save_Scene()
-static bool bDoFadeIn = false;
-static int bgReels;
+static SCNHANDLE g_hBgPal = 0; // Background's palette
+static POBJECT g_pBG[MAX_BG];
+static ANIM g_thisAnim[MAX_BG]; // used by BGmainProcess()
+static int g_BGspeed = 0;
+static SCNHANDLE g_hBackground = 0; // Current scene handle - stored in case of Save_Scene()
+static bool g_bDoFadeIn = false;
+static int g_bgReels;
/**
* GetBgObject
*/
OBJECT *GetBgObject() {
- return pBG[0];
+ return g_pBG[0];
}
/**
* BackPal
*/
SCNHANDLE BgPal() {
- return hBgPal;
+ return g_hBgPal;
}
/**
* SetDoFadeIn
*/
void SetDoFadeIn(bool tf) {
- bDoFadeIn = tf;
+ g_bDoFadeIn = tf;
}
/**
* Called before scene change.
*/
void DropBackground() {
- pBG[0] = NULL; // No background
+ g_pBG[0] = NULL; // No background
if (!TinselV2)
- hBgPal = 0; // No background palette
+ g_hBgPal = 0; // No background palette
}
/**
* Return the width of the current background.
*/
int BgWidth() {
- assert(pBG[0]);
- return MultiRightmost(pBG[0]) + 1;
+ assert(g_pBG[0]);
+ return MultiRightmost(g_pBG[0]) + 1;
}
/**
* Return the height of the current background.
*/
int BgHeight() {
- assert(pBG[0]);
- return MultiLowest(pBG[0]) + 1;
+ assert(g_pBG[0]);
+ return MultiLowest(g_pBG[0]) + 1;
}
/**
@@ -117,7 +117,7 @@ static void BGmainProcess(CORO_PARAM, const void *param) {
const MULTI_INIT *pmi;
// get the stuff copied to process when it was created
- if (pBG[0] == NULL) {
+ if (g_pBG[0] == NULL) {
/*** At start of scene ***/
if (!TinselV2) {
@@ -127,40 +127,40 @@ static void BGmainProcess(CORO_PARAM, const void *param) {
pmi = (const MULTI_INIT *)LockMem(FROM_LE_32(pReel->mobj));
// Initialize and insert the object, and initialize its script.
- pBG[0] = MultiInitObject(pmi);
- MultiInsertObject(GetPlayfieldList(FIELD_WORLD), pBG[0]);
- InitStepAnimScript(&thisAnim[0], pBG[0], FROM_LE_32(pReel->script), BGspeed);
- bgReels = 1;
+ g_pBG[0] = MultiInitObject(pmi);
+ MultiInsertObject(GetPlayfieldList(FIELD_WORLD), g_pBG[0]);
+ InitStepAnimScript(&g_thisAnim[0], g_pBG[0], FROM_LE_32(pReel->script), g_BGspeed);
+ g_bgReels = 1;
} else {
/*** At start of scene ***/
- pFilm = (const FILM *)LockMem(hBackground);
- bgReels = FROM_LE_32(pFilm->numreels);
+ pFilm = (const FILM *)LockMem(g_hBackground);
+ g_bgReels = FROM_LE_32(pFilm->numreels);
int i;
- for (i = 0; i < bgReels; i++) {
+ for (i = 0; i < g_bgReels; i++) {
// Get the MULTI_INIT structure
pmi = (PMULTI_INIT) LockMem(FROM_LE_32(pFilm->reels[i].mobj));
// Initialize and insert the object, and initialize its script.
- pBG[i] = MultiInitObject(pmi);
- MultiInsertObject(GetPlayfieldList(FIELD_WORLD), pBG[i]);
- MultiSetZPosition(pBG[i], 0);
- InitStepAnimScript(&thisAnim[i], pBG[i], FROM_LE_32(pFilm->reels[i].script), BGspeed);
+ g_pBG[i] = MultiInitObject(pmi);
+ MultiInsertObject(GetPlayfieldList(FIELD_WORLD), g_pBG[i]);
+ MultiSetZPosition(g_pBG[i], 0);
+ InitStepAnimScript(&g_thisAnim[i], g_pBG[i], FROM_LE_32(pFilm->reels[i].script), g_BGspeed);
if (i > 0)
- pBG[i-1]->pSlave = pBG[i];
+ g_pBG[i-1]->pSlave = g_pBG[i];
}
}
- if (bDoFadeIn) {
+ if (g_bDoFadeIn) {
FadeInFast(NULL);
- bDoFadeIn = false;
+ g_bDoFadeIn = false;
} else if (TinselV2)
PokeInTagColor();
for (;;) {
- for (int i = 0; i < bgReels; i++) {
- if (StepAnimScript(&thisAnim[i]) == ScriptFinished)
+ for (int i = 0; i < g_bgReels; i++) {
+ if (StepAnimScript(&g_thisAnim[i]) == ScriptFinished)
error("Background animation has finished");
}
@@ -170,16 +170,16 @@ static void BGmainProcess(CORO_PARAM, const void *param) {
// New background during scene
if (!TinselV2) {
pReel = (const FREEL *)param;
- InitStepAnimScript(&thisAnim[0], pBG[0], FROM_LE_32(pReel->script), BGspeed);
- StepAnimScript(&thisAnim[0]);
+ InitStepAnimScript(&g_thisAnim[0], g_pBG[0], FROM_LE_32(pReel->script), g_BGspeed);
+ StepAnimScript(&g_thisAnim[0]);
} else {
- pFilm = (const FILM *)LockMem(hBackground);
- assert(bgReels == (int32)FROM_LE_32(pFilm->numreels));
+ pFilm = (const FILM *)LockMem(g_hBackground);
+ assert(g_bgReels == (int32)FROM_LE_32(pFilm->numreels));
// Just re-initialize the scripts.
- for (int i = 0; i < bgReels; i++) {
- InitStepAnimScript(&thisAnim[i], pBG[i], pFilm->reels[i].script, BGspeed);
- StepAnimScript(&thisAnim[i]);
+ for (int i = 0; i < g_bgReels; i++) {
+ InitStepAnimScript(&g_thisAnim[i], g_pBG[i], pFilm->reels[i].script, g_BGspeed);
+ StepAnimScript(&g_thisAnim[i]);
}
}
}
@@ -206,7 +206,7 @@ static void BGotherProcess(CORO_PARAM, const void *param) {
_ctx->pObj = MultiInitObject(pmi);
MultiInsertObject(GetPlayfieldList(FIELD_WORLD), _ctx->pObj);
- InitStepAnimScript(&_ctx->anim, pBG[0], FROM_LE_32(pReel->script), BGspeed);
+ InitStepAnimScript(&_ctx->anim, g_pBG[0], FROM_LE_32(pReel->script), g_BGspeed);
while (StepAnimScript(&_ctx->anim) != ScriptFinished)
CORO_SLEEP(1);
@@ -218,14 +218,14 @@ static void BGotherProcess(CORO_PARAM, const void *param) {
* AetBgPal()
*/
void SetBackPal(SCNHANDLE hPal) {
- hBgPal = hPal;
+ g_hBgPal = hPal;
- FettleFontPal(hBgPal);
- CreateTranslucentPalette(hBgPal);
+ FettleFontPal(g_hBgPal);
+ CreateTranslucentPalette(g_hBgPal);
}
void ChangePalette(SCNHANDLE hPal) {
- SwapPalette(FindPalette(hBgPal), hPal);
+ SwapPalette(FindPalette(g_hBgPal), hPal);
SetBackPal(hPal);
}
@@ -245,14 +245,14 @@ void StartupBackground(CORO_PARAM, SCNHANDLE hFilm) {
const FILM *pfilm;
IMAGE *pim;
- hBackground = hFilm; // Save handle in case of Save_Scene()
+ g_hBackground = hFilm; // Save handle in case of Save_Scene()
pim = GetImageFromFilm(hFilm, 0, NULL, NULL, &pfilm);
SetBackPal(FROM_LE_32(pim->hImgPal));
// Extract the film speed
- BGspeed = ONE_SECOND / FROM_LE_32(pfilm->frate);
+ g_BGspeed = ONE_SECOND / FROM_LE_32(pfilm->frate);
// Start display process for each reel in the film
g_scheduler->createProcess(PID_REEL, BGmainProcess, &pfilm->reels[0], sizeof(FREEL));
@@ -262,7 +262,7 @@ void StartupBackground(CORO_PARAM, SCNHANDLE hFilm) {
g_scheduler->createProcess(PID_REEL, BGotherProcess, &pfilm->reels[i], sizeof(FREEL));
}
- if (pBG[0] == NULL)
+ if (g_pBG[0] == NULL)
ControlStartOff();
if (TinselV2 && (coroParam != nullContext))
@@ -275,7 +275,7 @@ void StartupBackground(CORO_PARAM, SCNHANDLE hFilm) {
* Return the current scene handle.
*/
SCNHANDLE GetBgroundHandle() {
- return hBackground;
+ return g_hBackground;
}
} // End of namespace Tinsel
diff --git a/engines/tinsel/cursor.cpp b/engines/tinsel/cursor.cpp
index 8248609a81..bf901c03b6 100644
--- a/engines/tinsel/cursor.cpp
+++ b/engines/tinsel/cursor.cpp
@@ -56,36 +56,36 @@ namespace Tinsel {
// FIXME: Avoid non-const global vars
-static OBJECT *McurObj = NULL; // Main cursor object
-static OBJECT *AcurObj = NULL; // Auxiliary cursor object
+static OBJECT *g_McurObj = NULL; // Main cursor object
+static OBJECT *g_AcurObj = NULL; // Auxiliary cursor object
-static ANIM McurAnim = {0,0,0,0,0}; // Main cursor animation structure
-static ANIM AcurAnim = {0,0,0,0,0}; // Auxiliary cursor animation structure
+static ANIM g_McurAnim = {0,0,0,0,0}; // Main cursor animation structure
+static ANIM g_AcurAnim = {0,0,0,0,0}; // Auxiliary cursor animation structure
-static bool bHiddenCursor = false; // Set when cursor is hidden
-static bool bTempNoTrailers = false; // Set when cursor trails are hidden
-static bool bTempHide = false; // Set when cursor is hidden
+static bool g_bHiddenCursor = false; // Set when cursor is hidden
+static bool g_bTempNoTrailers = false; // Set when cursor trails are hidden
+static bool g_bTempHide = false; // Set when cursor is hidden
-static bool bFrozenCursor = false; // Set when cursor position is frozen
+static bool g_bFrozenCursor = false; // Set when cursor position is frozen
-static frac_t IterationSize = 0;
+static frac_t g_IterationSize = 0;
-static SCNHANDLE hCursorFilm = 0; // Handle to cursor reel data
+static SCNHANDLE g_hCursorFilm = 0; // Handle to cursor reel data
-static int numTrails = 0;
-static int nextTrail = 0;
+static int g_numTrails = 0;
+static int g_nextTrail = 0;
-static bool bWhoa = false; // Set by DropCursor() at the end of a scene
+static bool g_bWhoa = false; // Set by DropCursor() at the end of a scene
// - causes cursor processes to do nothing
// Reset when main cursor has re-initialized
-static uint16 restart = 0; // When main cursor has been bWhoa-ed, it waits
+static uint16 g_restart = 0; // When main cursor has been bWhoa-ed, it waits
// for this to be set to 0x8000.
// Main cursor sets all the bits after a re-start
// - each cursor trail examines it's own bit
// to trigger a trail restart.
-static short ACoX = 0, ACoY = 0; // Auxillary cursor image's animation offsets
+static short g_ACoX = 0, g_ACoY = 0; // Auxillary cursor image's animation offsets
@@ -96,9 +96,9 @@ static struct {
ANIM trailAnim; // Animation structure
OBJECT *trailObj; // This trailer's object
-} ntrailData [MAX_TRAILERS];
+} g_ntrailData [MAX_TRAILERS];
-static int lastCursorX = 0, lastCursorY = 0;
+static int g_lastCursorX = 0, g_lastCursorY = 0;
//----------------- FORWARD REFERENCES --------------------
@@ -116,26 +116,26 @@ static void InitCurTrailObj(int i, int x, int y) {
const FILM *pfilm;
- if (!numTrails)
+ if (!g_numTrails)
return;
// Get rid of old object
- if (ntrailData[i].trailObj != NULL)
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), ntrailData[i].trailObj);
+ if (g_ntrailData[i].trailObj != NULL)
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
- pim = GetImageFromFilm(hCursorFilm, i+1, &pfr, &pmi, &pfilm);// Get pointer to image
+ pim = GetImageFromFilm(g_hCursorFilm, i+1, &pfr, &pmi, &pfilm);// Get pointer to image
assert(BgPal()); // No background palette
pim->hImgPal = TO_LE_32(BgPal());
// Initialize and insert the object, set its Z-pos, and hide it
- ntrailData[i].trailObj = MultiInitObject(pmi);
- MultiInsertObject(GetPlayfieldList(FIELD_STATUS), ntrailData[i].trailObj);
- MultiSetZPosition(ntrailData[i].trailObj, Z_CURSORTRAIL);
- MultiSetAniXY(ntrailData[i].trailObj, x, y);
+ g_ntrailData[i].trailObj = MultiInitObject(pmi);
+ MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
+ MultiSetZPosition(g_ntrailData[i].trailObj, Z_CURSORTRAIL);
+ MultiSetAniXY(g_ntrailData[i].trailObj, x, y);
// Initialize the animation script
- InitStepAnimScript(&ntrailData[i].trailAnim, ntrailData[i].trailObj, FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pfilm->frate));
- StepAnimScript(&ntrailData[i].trailAnim);
+ InitStepAnimScript(&g_ntrailData[i].trailAnim, g_ntrailData[i].trailObj, FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pfilm->frate));
+ StepAnimScript(&g_ntrailData[i].trailAnim);
}
/**
@@ -196,12 +196,12 @@ void SetCursorScreenXY(int newx, int newy) {
* Returns false if there is no cursor object.
*/
bool GetCursorXYNoWait(int *x, int *y, bool absolute) {
- if (McurObj == NULL) {
+ if (g_McurObj == NULL) {
*x = *y = 0;
return false;
}
- GetAniPosition(McurObj, x, y);
+ GetAniPosition(g_McurObj, x, y);
if (absolute) {
int Loffset, Toffset; // Screen offset
@@ -222,7 +222,7 @@ bool GetCursorXYNoWait(int *x, int *y, bool absolute) {
void GetCursorXY(int *x, int *y, bool absolute) {
//while (McurObj == NULL)
// ProcessSleepSelf();
- assert(McurObj);
+ assert(g_McurObj);
GetCursorXYNoWait(x, y, absolute);
}
@@ -234,22 +234,22 @@ void GetCursorXY(int *x, int *y, bool absolute) {
void RestoreMainCursor() {
const FILM *pfilm;
- if (McurObj != NULL) {
- pfilm = (const FILM *)LockMem(hCursorFilm);
+ if (g_McurObj != NULL) {
+ pfilm = (const FILM *)LockMem(g_hCursorFilm);
- InitStepAnimScript(&McurAnim, McurObj, FROM_LE_32(pfilm->reels->script), ONE_SECOND / FROM_LE_32(pfilm->frate));
- StepAnimScript(&McurAnim);
+ InitStepAnimScript(&g_McurAnim, g_McurObj, FROM_LE_32(pfilm->reels->script), ONE_SECOND / FROM_LE_32(pfilm->frate));
+ StepAnimScript(&g_McurAnim);
}
- bHiddenCursor = false;
- bFrozenCursor = false;
+ g_bHiddenCursor = false;
+ g_bFrozenCursor = false;
}
/**
* Called from INVENTRY.C to customise the main cursor.
*/
void SetTempCursor(SCNHANDLE pScript) {
- if (McurObj != NULL)
- InitStepAnimScript(&McurAnim, McurObj, pScript, 2);
+ if (g_McurObj != NULL)
+ InitStepAnimScript(&g_McurAnim, g_McurObj, pScript, 2);
}
/**
@@ -258,17 +258,17 @@ void SetTempCursor(SCNHANDLE pScript) {
void DwHideCursor() {
int i;
- bHiddenCursor = true;
+ g_bHiddenCursor = true;
- if (McurObj)
- MultiHideObject(McurObj);
- if (AcurObj)
- MultiHideObject(AcurObj);
+ if (g_McurObj)
+ MultiHideObject(g_McurObj);
+ if (g_AcurObj)
+ MultiHideObject(g_AcurObj);
- for (i = 0; i < numTrails; i++) {
- if (ntrailData[i].trailObj != NULL) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), ntrailData[i].trailObj);
- ntrailData[i].trailObj = NULL;
+ for (i = 0; i < g_numTrails; i++) {
+ if (g_ntrailData[i].trailObj != NULL) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
+ g_ntrailData[i].trailObj = NULL;
}
}
}
@@ -277,21 +277,21 @@ void DwHideCursor() {
* Unhide the cursor.
*/
void UnHideCursor() {
- bHiddenCursor = false;
+ g_bHiddenCursor = false;
}
/**
* Freeze the cursor.
*/
void FreezeCursor() {
- bFrozenCursor = true;
+ g_bFrozenCursor = true;
}
/**
* Freeze the cursor, or not.
*/
void DoFreezeCursor(bool bFreeze) {
- bFrozenCursor = bFreeze;
+ g_bFrozenCursor = bFreeze;
}
/**
@@ -300,12 +300,12 @@ void DoFreezeCursor(bool bFreeze) {
void HideCursorTrails() {
int i;
- bTempNoTrailers = true;
+ g_bTempNoTrailers = true;
- for (i = 0; i < numTrails; i++) {
- if (ntrailData[i].trailObj != NULL) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), ntrailData[i].trailObj);
- ntrailData[i].trailObj = NULL;
+ for (i = 0; i < g_numTrails; i++) {
+ if (g_ntrailData[i].trailObj != NULL) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
+ g_ntrailData[i].trailObj = NULL;
}
}
}
@@ -314,7 +314,7 @@ void HideCursorTrails() {
* UnHideCursorTrails
*/
void UnHideCursorTrails() {
- bTempNoTrailers = false;
+ g_bTempNoTrailers = false;
}
/**
@@ -356,9 +356,9 @@ IMAGE *GetImageFromFilm(SCNHANDLE hFilm, int reel, const FREEL **ppfr, const MUL
* Delete auxillary cursor. Restore animation offsets in the image.
*/
void DelAuxCursor() {
- if (AcurObj != NULL) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), AcurObj);
- AcurObj = NULL;
+ if (g_AcurObj != NULL) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_AcurObj);
+ g_AcurObj = NULL;
}
}
@@ -381,21 +381,21 @@ void SetAuxCursor(SCNHANDLE hFilm) {
assert(BgPal()); // no background palette
pim->hImgPal = TO_LE_32(BgPal()); // Poke in the background palette
- ACoX = (short)(FROM_LE_16(pim->imgWidth)/2 - ((int16) FROM_LE_16(pim->anioffX)));
- ACoY = (short)((FROM_LE_16(pim->imgHeight) & ~C16_FLAG_MASK)/2 -
+ g_ACoX = (short)(FROM_LE_16(pim->imgWidth)/2 - ((int16) FROM_LE_16(pim->anioffX)));
+ g_ACoY = (short)((FROM_LE_16(pim->imgHeight) & ~C16_FLAG_MASK)/2 -
((int16) FROM_LE_16(pim->anioffY)));
// Initialize and insert the auxillary cursor object
- AcurObj = MultiInitObject(pmi);
- MultiInsertObject(GetPlayfieldList(FIELD_STATUS), AcurObj);
+ g_AcurObj = MultiInitObject(pmi);
+ MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_AcurObj);
// Initialize the animation and set its position
- InitStepAnimScript(&AcurAnim, AcurObj, FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pfilm->frate));
- MultiSetAniXY(AcurObj, x - ACoX, y - ACoY);
- MultiSetZPosition(AcurObj, Z_ACURSOR);
+ InitStepAnimScript(&g_AcurAnim, g_AcurObj, FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pfilm->frate));
+ MultiSetAniXY(g_AcurObj, x - g_ACoX, y - g_ACoY);
+ MultiSetZPosition(g_AcurObj, Z_ACURSOR);
- if (bHiddenCursor)
- MultiHideObject(AcurObj);
+ if (g_bHiddenCursor)
+ MultiHideObject(g_AcurObj);
}
/**
@@ -421,52 +421,52 @@ static void DoCursorMove() {
dir = _vm->getKeyDirection();
if (dir != 0) {
if (dir & MSK_LEFT)
- newX -= IterationSize;
+ newX -= g_IterationSize;
if (dir & MSK_RIGHT)
- newX += IterationSize;
+ newX += g_IterationSize;
if (dir & MSK_UP)
- newY -= IterationSize;
+ newY -= g_IterationSize;
if (dir & MSK_DOWN)
- newY += IterationSize;
+ newY += g_IterationSize;
- IterationSize += ITER_ACCELERATION;
+ g_IterationSize += ITER_ACCELERATION;
// set new mouse driver position
_vm->setMousePosition(Common::Point(fracToInt(newX), fracToInt(newY)));
} else
- IterationSize = ITERATION_BASE;
+ g_IterationSize = ITERATION_BASE;
// get new mouse driver position - could have been modified
ptMouse = _vm->getMousePosition();
- if (lastCursorX != ptMouse.x || lastCursorY != ptMouse.y) {
+ if (g_lastCursorX != ptMouse.x || g_lastCursorY != ptMouse.y) {
resetUserEventTime();
- if (!bTempNoTrailers && !bHiddenCursor) {
- InitCurTrailObj(nextTrail++, lastCursorX, lastCursorY);
- if (nextTrail == numTrails)
- nextTrail = 0;
+ if (!g_bTempNoTrailers && !g_bHiddenCursor) {
+ InitCurTrailObj(g_nextTrail++, g_lastCursorX, g_lastCursorY);
+ if (g_nextTrail == g_numTrails)
+ g_nextTrail = 0;
}
}
// adjust cursor to new mouse position
- if (McurObj)
- MultiSetAniXY(McurObj, ptMouse.x, ptMouse.y);
- if (AcurObj != NULL)
- MultiSetAniXY(AcurObj, ptMouse.x - ACoX, ptMouse.y - ACoY);
+ if (g_McurObj)
+ MultiSetAniXY(g_McurObj, ptMouse.x, ptMouse.y);
+ if (g_AcurObj != NULL)
+ MultiSetAniXY(g_AcurObj, ptMouse.x - g_ACoX, ptMouse.y - g_ACoY);
- if (InventoryActive() && McurObj) {
+ if (InventoryActive() && g_McurObj) {
// Notify the inventory
Xmovement(ptMouse.x - startX);
Ymovement(ptMouse.y - startY);
}
- lastCursorX = ptMouse.x;
- lastCursorY = ptMouse.y;
+ g_lastCursorX = ptMouse.x;
+ g_lastCursorY = ptMouse.y;
}
/**
@@ -479,7 +479,7 @@ static void InitCurObj() {
IMAGE *pim;
if (TinselV2) {
- pFilm = (const FILM *)LockMem(hCursorFilm);
+ pFilm = (const FILM *)LockMem(g_hCursorFilm);
pfr = (const FREEL *)&pFilm->reels[0];
pmi = (MULTI_INIT *)LockMem(FROM_LE_32(pfr->mobj));
@@ -487,16 +487,16 @@ static void InitCurObj() {
} else {
assert(BgPal()); // no background palette
- pim = GetImageFromFilm(hCursorFilm, 0, &pfr, &pmi, &pFilm);// Get pointer to image
+ pim = GetImageFromFilm(g_hCursorFilm, 0, &pfr, &pmi, &pFilm);// Get pointer to image
pim->hImgPal = TO_LE_32(BgPal());
- AcurObj = NULL; // No auxillary cursor
+ g_AcurObj = NULL; // No auxillary cursor
}
- McurObj = MultiInitObject(pmi);
- MultiInsertObject(GetPlayfieldList(FIELD_STATUS), McurObj);
+ g_McurObj = MultiInitObject(pmi);
+ MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_McurObj);
- InitStepAnimScript(&McurAnim, McurObj, FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pFilm->frate));
+ InitStepAnimScript(&g_McurAnim, g_McurObj, FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pFilm->frate));
}
/**
@@ -504,14 +504,14 @@ static void InitCurObj() {
*/
static void InitCurPos() {
Common::Point ptMouse = _vm->getMousePosition();
- lastCursorX = ptMouse.x;
- lastCursorY = ptMouse.y;
+ g_lastCursorX = ptMouse.x;
+ g_lastCursorY = ptMouse.y;
- MultiSetZPosition(McurObj, Z_CURSOR);
+ MultiSetZPosition(g_McurObj, Z_CURSOR);
DoCursorMove();
- MultiHideObject(McurObj);
+ MultiHideObject(g_McurObj);
- IterationSize = ITERATION_BASE;
+ g_IterationSize = ITERATION_BASE;
}
/**
@@ -525,9 +525,9 @@ static void CursorStoppedCheck(CORO_PARAM) {
CORO_BEGIN_CODE(_ctx);
// If scene is closing down
- if (bWhoa) {
+ if (g_bWhoa) {
// ...wait for next scene start-up
- while (restart != 0x8000)
+ while (g_restart != 0x8000)
CORO_SLEEP(1);
// Re-initialize
@@ -536,8 +536,8 @@ static void CursorStoppedCheck(CORO_PARAM) {
InventoryIconCursor(false); // May be holding something
// Re-start the cursor trails
- restart = (uint16)-1; // set all bits
- bWhoa = false;
+ g_restart = (uint16)-1; // set all bits
+ g_bWhoa = false;
}
CORO_END_CODE;
}
@@ -552,15 +552,15 @@ void CursorProcess(CORO_PARAM, const void *) {
CORO_BEGIN_CODE(_ctx);
- while (!hCursorFilm || !BgPal())
+ while (!g_hCursorFilm || !BgPal())
CORO_SLEEP(1);
InitCurObj();
InitCurPos();
InventoryIconCursor(false); // May be holding something
- bWhoa = false;
- restart = 0;
+ g_bWhoa = false;
+ g_restart = 0;
while (1) {
// allow rescheduling
@@ -570,36 +570,36 @@ void CursorProcess(CORO_PARAM, const void *) {
CORO_INVOKE_0(CursorStoppedCheck);
// Step the animation script(s)
- StepAnimScript(&McurAnim);
- if (AcurObj != NULL)
- StepAnimScript(&AcurAnim);
- for (int i = 0; i < numTrails; i++) {
- if (ntrailData[i].trailObj != NULL) {
- if (StepAnimScript(&ntrailData[i].trailAnim) == ScriptFinished) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), ntrailData[i].trailObj);
- ntrailData[i].trailObj = NULL;
+ StepAnimScript(&g_McurAnim);
+ if (g_AcurObj != NULL)
+ StepAnimScript(&g_AcurAnim);
+ for (int i = 0; i < g_numTrails; i++) {
+ if (g_ntrailData[i].trailObj != NULL) {
+ if (StepAnimScript(&g_ntrailData[i].trailAnim) == ScriptFinished) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
+ g_ntrailData[i].trailObj = NULL;
}
}
}
// Move the cursor as appropriate
- if (!bFrozenCursor)
+ if (!g_bFrozenCursor)
DoCursorMove();
// If the cursor should be hidden...
- if (bHiddenCursor || bTempHide) {
+ if (g_bHiddenCursor || g_bTempHide) {
// ...hide the cursor object(s)
- MultiHideObject(McurObj);
- if (AcurObj)
- MultiHideObject(AcurObj);
+ MultiHideObject(g_McurObj);
+ if (g_AcurObj)
+ MultiHideObject(g_AcurObj);
- for (int i = 0; i < numTrails; i++) {
- if (ntrailData[i].trailObj != NULL)
- MultiHideObject(ntrailData[i].trailObj);
+ for (int i = 0; i < g_numTrails; i++) {
+ if (g_ntrailData[i].trailObj != NULL)
+ MultiHideObject(g_ntrailData[i].trailObj);
}
// Wait 'til cursor is again required.
- while (bHiddenCursor) {
+ while (g_bHiddenCursor) {
CORO_SLEEP(1);
// Stop/start between scenes
@@ -617,12 +617,12 @@ void CursorProcess(CORO_PARAM, const void *) {
void DwInitCursor(SCNHANDLE bfilm) {
const FILM *pfilm;
- hCursorFilm = bfilm;
+ g_hCursorFilm = bfilm;
- pfilm = (const FILM *)LockMem(hCursorFilm);
- numTrails = FROM_LE_32(pfilm->numreels) - 1;
+ pfilm = (const FILM *)LockMem(g_hCursorFilm);
+ g_numTrails = FROM_LE_32(pfilm->numreels) - 1;
- assert(numTrails <= MAX_TRAILERS);
+ assert(g_numTrails <= MAX_TRAILERS);
}
/**
@@ -630,24 +630,24 @@ void DwInitCursor(SCNHANDLE bfilm) {
*/
void DropCursor() {
if (TinselV2) {
- if (AcurObj)
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), AcurObj);
- if (McurObj)
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), McurObj);
+ if (g_AcurObj)
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_AcurObj);
+ if (g_McurObj)
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_McurObj);
- restart = 0;
+ g_restart = 0;
}
- AcurObj = NULL; // No auxillary cursor
- McurObj = NULL; // No cursor object (imminently deleted elsewhere)
- bHiddenCursor = false; // Not hidden in next scene
- bTempNoTrailers = false; // Trailers not hidden in next scene
- bWhoa = true; // Suspend cursor processes
+ g_AcurObj = NULL; // No auxillary cursor
+ g_McurObj = NULL; // No cursor object (imminently deleted elsewhere)
+ g_bHiddenCursor = false; // Not hidden in next scene
+ g_bTempNoTrailers = false; // Trailers not hidden in next scene
+ g_bWhoa = true; // Suspend cursor processes
- for (int i = 0; i < numTrails; i++) {
- if (ntrailData[i].trailObj != NULL) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), ntrailData[i].trailObj);
- ntrailData[i].trailObj = NULL;
+ for (int i = 0; i < g_numTrails; i++) {
+ if (g_ntrailData[i].trailObj != NULL) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
+ g_ntrailData[i].trailObj = NULL;
}
}
}
@@ -656,7 +656,7 @@ void DropCursor() {
* RestartCursor is called when a new scene is starting up.
*/
void RestartCursor() {
- restart = 0x8000; // Get the main cursor to re-initialize
+ g_restart = 0x8000; // Get the main cursor to re-initialize
}
/**
@@ -664,32 +664,32 @@ void RestartCursor() {
* pointers etc.
*/
void RebootCursor() {
- McurObj = AcurObj = NULL;
+ g_McurObj = g_AcurObj = NULL;
for (int i = 0; i < MAX_TRAILERS; i++)
- ntrailData[i].trailObj = NULL;
+ g_ntrailData[i].trailObj = NULL;
- bHiddenCursor = bTempNoTrailers = bFrozenCursor = false;
+ g_bHiddenCursor = g_bTempNoTrailers = g_bFrozenCursor = false;
- hCursorFilm = 0;
+ g_hCursorFilm = 0;
- bWhoa = false;
- restart = 0;
+ g_bWhoa = false;
+ g_restart = 0;
}
void StartCursorFollowed() {
DelAuxCursor();
if (!SysVar(SV_ENABLEPRINTCURSOR))
- bTempHide = true;
+ g_bTempHide = true;
}
void EndCursorFollowed() {
InventoryIconCursor(false); // May be holding something
- bTempHide = false;
+ g_bTempHide = false;
}
bool isCursorShown() {
- return !(bTempHide || bHiddenCursor);
+ return !(g_bTempHide || g_bHiddenCursor);
}
} // End of namespace Tinsel
diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp
index 6ca070b67a..5396e47566 100644
--- a/engines/tinsel/dialogs.cpp
+++ b/engines/tinsel/dialogs.cpp
@@ -63,17 +63,6 @@
namespace Tinsel {
-//----------------- EXTERNAL GLOBAL DATA --------------------
-
-// In DOS_DW.C
-extern bool bRestart; // restart flag - set to restart the game
-
-#ifdef MAC_OPTIONS
-// In MAC_SOUND.C
-extern int volMaster;
-#endif
-
-
//----------------- LOCAL DEFINES --------------------
#define HOPPER_FILENAME "hopper"
@@ -312,23 +301,23 @@ static const int vFillers[MAXVICONS] = {
//----- Permanent data (set once) -----
-static SCNHANDLE hWinParts = 0; // Window members and cursors' graphic data
-static SCNHANDLE flagFilm = 0; // Window members and cursors' graphic data
-static SCNHANDLE configStrings[20];
+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 *invObjects = NULL; // Inventory objects' data
-static int numObjects = 0; // Number of inventory objects
-static SCNHANDLE *invFilms = NULL;
-static bool bNoLanguage = false;
-static DIRECTION initialDirection;
+static INV_OBJECT *g_invObjects = NULL; // Inventory objects' data
+static int g_numObjects = 0; // Number of inventory objects
+static SCNHANDLE *g_invFilms = NULL;
+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} InventoryState;
+static enum {NO_INV, IDLE_INV, ACTIVE_INV, BOGUS_INV} g_InventoryState;
-static int HeldItem = INV_NOICON; // Current held item
+static int g_heldItem = INV_NOICON; // Current held item
-static SCNHANDLE heldFilm;
+static SCNHANDLE g_heldFilm;
struct INV_DEF {
@@ -364,60 +353,60 @@ struct INV_DEF {
};
-static INV_DEF InvD[NUM_INV]; // Conversation + 2 inventories + ...
+static INV_DEF g_InvD[NUM_INV]; // Conversation + 2 inventories + ...
// Permanent contents of conversation inventory
-static int permIcons[MAX_PERMICONS]; // Basic items i.e. permanent contents
-static int numPermIcons = 0; // - copy to conv. inventory at pop-up time
-static int numEndIcons = 0;
+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 ino = 0; // Which inventory is currently active
+static int g_ino = 0; // Which inventory is currently active
-static bool InventoryHidden = false;
-static bool InventoryMaximised = false;
+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 } InvDragging;
+ ID_CSLIDE, ID_MDCONT } g_InvDragging;
-static int SuppH = 0; // 'Linear' element of
-static int SuppV = 0; // dimensions during re-sizing
+static int g_SuppH = 0; // 'Linear' element of
+static int g_SuppV = 0; // dimensions during re-sizing
-static int Ychange = 0; //
-static int Ycompensate = 0; // All to do with re-sizing.
-static int Xchange = 0; //
-static int Xcompensate = 0; //
+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 ItemsChanged = 0; // When set, causes items to be re-drawn
+static bool g_ItemsChanged = 0; // When set, causes items to be re-drawn
-static bool bReOpenMenu = 0;
+static bool g_bReOpenMenu = 0;
-static int TL = 0, TR = 0, BL = 0, BR = 0; // Used during window construction
-static int TLwidth = 0, TLheight = 0; //
-static int TRwidth = 0; //
-static int BLheight = 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 displayedLanguage;
+static LANGUAGE g_displayedLanguage;
-static OBJECT *objArray[MAX_WCOMP]; // Current display objects (window)
-static OBJECT *iconArray[MAX_ICONS]; // Current display objects (icons)
-static ANIM iconAnims[MAX_ICONS];
-static OBJECT *DobjArray[MAX_WCOMP]; // Current display objects (re-sizing window)
+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 *RectObject = 0, *SlideObject = 0; // Current display objects, for reference
+static OBJECT *g_RectObject = 0, *g_SlideObject = 0; // Current display objects, for reference
// objects are in objArray.
-static int sliderYpos = 0; // For positioning the slider
-static int sliderYmax = 0, sliderYmin = 0; //
+static int g_sliderYpos = 0; // For positioning the slider
+static int g_sliderYmax = 0, g_sliderYmin = 0; //
-#define sliderRange (sliderYmax - sliderYmin)
+#define sliderRange (g_sliderYmax - g_sliderYmin)
// Also to do with the slider
-static struct { int n; int y; } slideStuff[MAX_ININV_TOT+1];
+static struct { int n; int y; } g_slideStuff[MAX_ININV_TOT+1];
#define MAXSLIDES 4
struct MDSLIDES {
@@ -425,25 +414,25 @@ struct MDSLIDES {
OBJECT *obj;
int min, max;
};
-static MDSLIDES mdSlides[MAXSLIDES];
-static int numMdSlides = 0;
+static MDSLIDES g_mdSlides[MAXSLIDES];
+static int g_numMdSlides = 0;
-static int GlitterIndex = 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 thisIcon = 0;
+static int g_thisIcon = 0;
-static CONV_PARAM thisConvFn; // Top, 'Middle' or Bottom
-static HPOLYGON thisConvPoly = 0; // Conversation code is in a polygon code block
-static int thisConvActor; // ...or an actor's code block.
-static int pointedIcon = INV_NOICON; // used by InvLabels - icon pointed to on last call
-static volatile int PointedWaitCount = 0; // used by ObjectProcess - fix the 'repeated pressing bug'
-static int sX = 0; // used by SlideMSlider() - current x-coordinate
-static int lX = 0; // used by SlideMSlider() - last x-coordinate
+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 bMoveOnUnHide; // Set before start of conversation
+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) -----
@@ -486,16 +475,16 @@ typedef HOPENTRY *PHOPENTRY;
#include "common/pack-end.h" // END STRUCT PACKING
-static PHOPPER pHopper;
-static PHOPENTRY pEntries;
-static int numScenes;
+static PHOPPER g_pHopper;
+static PHOPENTRY g_pEntries;
+static int g_numScenes;
-static int numEntries;
+static int g_numEntries;
-static PHOPPER pChosenScene = NULL;
+static PHOPPER g_pChosenScene = NULL;
-static int lastChosenScene;
-static bool bRemember;
+static int g_lastChosenScene;
+static bool g_bRemember;
//--------------------------------------------------------------
@@ -970,7 +959,7 @@ static struct {
};
// For editing save game names
-static char sedit[SG_DESC_LEN+2];
+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
@@ -1096,7 +1085,7 @@ static void PrimeSceneHopper() {
vSize = f.readUint32LE();
// allocate a buffer for it all
- assert(pHopper == NULL);
+ assert(g_pHopper == NULL);
uint32 size = f.size() - 8;
// make sure memory allocated
@@ -1111,9 +1100,9 @@ static void PrimeSceneHopper() {
error(FILE_IS_CORRUPT, HOPPER_FILENAME);
// Set data pointers
- pHopper = (PHOPPER)pBuffer;
- pEntries = (PHOPENTRY)(pBuffer + vSize);
- numScenes = vSize / sizeof(HOPPER);
+ g_pHopper = (PHOPPER)pBuffer;
+ g_pEntries = (PHOPENTRY)(pBuffer + vSize);
+ g_numScenes = vSize / sizeof(HOPPER);
// close the file
f.close();
@@ -1123,31 +1112,31 @@ static void PrimeSceneHopper() {
* Free the scene hopper data file
*/
static void FreeSceneHopper() {
- free(pHopper);
- pHopper = NULL;
+ free(g_pHopper);
+ g_pHopper = NULL;
}
static void FirstScene(int first) {
int i;
- assert(numScenes && pHopper);
+ assert(g_numScenes && g_pHopper);
- if (bRemember) {
+ if (g_bRemember) {
assert(first == 0);
- first = lastChosenScene;
- bRemember = false;
+ first = g_lastChosenScene;
+ g_bRemember = false;
}
// Force it to a sensible value
- if (first > numScenes - NUM_RGROUP_BOXES)
- first = numScenes - NUM_RGROUP_BOXES;
+ if (first > g_numScenes - NUM_RGROUP_BOXES)
+ first = g_numScenes - NUM_RGROUP_BOXES;
if (first < 0)
first = 0;
// Fill in the rest
- for (i = 0; i < NUM_RGROUP_BOXES && i + first < numScenes; i++) {
+ for (i = 0; i < NUM_RGROUP_BOXES && i + first < g_numScenes; i++) {
cd.box[i].textMethod = TM_STRINGNUM;
- cd.box[i].ixText = FROM_LE_32(pHopper[i + first].hSceneDesc);
+ cd.box[i].ixText = FROM_LE_32(g_pHopper[i + first].hSceneDesc);
}
// Blank out the spare ones (if any)
while (i < NUM_RGROUP_BOXES) {
@@ -1159,31 +1148,31 @@ static void FirstScene(int first) {
}
static void RememberChosenScene() {
- bRemember = true;
+ g_bRemember = true;
}
static void SetChosenScene() {
- lastChosenScene = cd.selBox + cd.extraBase;
- pChosenScene = &pHopper[cd.selBox + cd.extraBase];
+ g_lastChosenScene = cd.selBox + cd.extraBase;
+ g_pChosenScene = &g_pHopper[cd.selBox + cd.extraBase];
}
static void FirstEntry(int first) {
int i;
- InvD[INV_MENU].hInvTitle = FROM_LE_32(pChosenScene->hSceneDesc);
+ g_InvD[INV_MENU].hInvTitle = FROM_LE_32(g_pChosenScene->hSceneDesc);
// get number of entrances
- numEntries = FROM_LE_32(pChosenScene->numEntries);
+ g_numEntries = FROM_LE_32(g_pChosenScene->numEntries);
// Force first to a sensible value
- if (first > numEntries-NUM_RGROUP_BOXES)
- first = numEntries-NUM_RGROUP_BOXES;
+ if (first > g_numEntries-NUM_RGROUP_BOXES)
+ first = g_numEntries-NUM_RGROUP_BOXES;
if (first < 0)
first = 0;
- for (i = 0; i < NUM_RGROUP_BOXES && i < numEntries; i++) {
+ for (i = 0; i < NUM_RGROUP_BOXES && i < g_numEntries; i++) {
cd.box[i].textMethod = TM_STRINGNUM;
- cd.box[i].ixText = FROM_LE_32(pEntries[FROM_LE_32(pChosenScene->entryIndex) + i + first].hDesc);
+ cd.box[i].ixText = FROM_LE_32(g_pEntries[FROM_LE_32(g_pChosenScene->entryIndex) + i + first].hDesc);
}
// Blank out the spare ones (if any)
while (i < NUM_RGROUP_BOXES) {
@@ -1195,15 +1184,15 @@ static void FirstEntry(int first) {
}
static void HopAction() {
- PHOPENTRY pEntry = pEntries + FROM_LE_32(pChosenScene->entryIndex) + cd.selBox + cd.extraBase;
+ PHOPENTRY pEntry = g_pEntries + FROM_LE_32(g_pChosenScene->entryIndex) + cd.selBox + cd.extraBase;
- uint32 hScene = FROM_LE_32(pChosenScene->hScene);
+ uint32 hScene = FROM_LE_32(g_pChosenScene->hScene);
uint32 eNumber = FROM_LE_32(pEntry->eNumber);
debugC(DEBUG_BASIC, kTinselDebugAnimations, "Scene hopper chose scene %xh,%d\n", hScene, eNumber);
if (FROM_LE_32(pEntry->flags) & fCall) {
SaveScene(nullContext);
- NewScene(nullContext, pChosenScene->hScene, pEntry->eNumber, TRANS_FADE);
+ NewScene(nullContext, g_pChosenScene->hScene, pEntry->eNumber, TRANS_FADE);
}
else if (FROM_LE_32(pEntry->flags) & fHook)
HookScene(hScene, eNumber, TRANS_FADE);
@@ -1220,9 +1209,9 @@ static void HopAction() {
*/
static void DumpIconArray() {
for (int i = 0; i < MAX_ICONS; i++) {
- if (iconArray[i] != NULL) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[i]);
- iconArray[i] = NULL;
+ if (g_iconArray[i] != NULL) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[i]);
+ g_iconArray[i] = NULL;
}
}
}
@@ -1232,9 +1221,9 @@ static void DumpIconArray() {
*/
static void DumpDobjArray() {
for (int i = 0; i < MAX_WCOMP; i++) {
- if (DobjArray[i] != NULL) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), DobjArray[i]);
- DobjArray[i] = NULL;
+ if (g_DobjArray[i] != NULL) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_DobjArray[i]);
+ g_DobjArray[i] = NULL;
}
}
}
@@ -1244,9 +1233,9 @@ static void DumpDobjArray() {
*/
static void DumpObjArray() {
for (int i = 0; i < MAX_WCOMP; i++) {
- if (objArray[i] != NULL) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), objArray[i]);
- objArray[i] = NULL;
+ if (g_objArray[i] != NULL) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_objArray[i]);
+ g_objArray[i] = NULL;
}
}
}
@@ -1256,9 +1245,9 @@ static void DumpObjArray() {
* i.e. Image data and Glitter code.
*/
static INV_OBJECT *GetInvObject(int id) {
- INV_OBJECT *pObject = invObjects;
+ INV_OBJECT *pObject = g_invObjects;
- for (int i = 0; i < numObjects; i++, pObject++) {
+ for (int i = 0; i < g_numObjects; i++, pObject++) {
if (pObject->id == id)
return pObject;
}
@@ -1270,9 +1259,9 @@ static INV_OBJECT *GetInvObject(int id) {
* Convert item ID number to index.
*/
static int GetObjectIndex(int id) {
- INV_OBJECT *pObject = invObjects;
+ INV_OBJECT *pObject = g_invObjects;
- for (int i = 0; i < numObjects; i++, pObject++) {
+ for (int i = 0; i < g_numObjects; i++, pObject++) {
if (pObject->id == id)
return i;
}
@@ -1287,15 +1276,15 @@ static int GetObjectIndex(int id) {
extern int InventoryPos(int num) {
int i;
- for (i = 0; i < InvD[INV_1].NoofItems; i++) // First inventory
- if (InvD[INV_1].contents[i] == num)
+ 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 < InvD[INV_2].NoofItems; i++) // Second inventory
- if (InvD[INV_2].contents[i] == num)
+ for (i = 0; i < g_InvD[INV_2].NoofItems; i++) // Second inventory
+ if (g_InvD[INV_2].contents[i] == num)
return i;
- if (HeldItem == num)
+ if (g_heldItem == num)
return INV_HELDNOTIN; // Held, but not in either inventory
return INV_NOICON; // Not held, not in either inventory
@@ -1304,8 +1293,8 @@ extern int InventoryPos(int num) {
extern bool IsInInventory(int object, int invnum) {
assert(invnum == INV_1 || invnum == INV_2);
- for (int i = 0; i < InvD[invnum].NoofItems; i++) // First inventory
- if (InvD[invnum].contents[i] == object)
+ for (int i = 0; i < g_InvD[invnum].NoofItems; i++) // First inventory
+ if (g_InvD[invnum].contents[i] == object)
return true;
return false;
@@ -1315,7 +1304,7 @@ extern bool IsInInventory(int object, int invnum) {
* Returns which item is held (INV_NOICON (-1) if none)
*/
extern int WhichItemHeld() {
- return HeldItem;
+ return g_heldItem;
}
/**
@@ -1324,15 +1313,15 @@ extern int WhichItemHeld() {
*/
extern void InventoryIconCursor(bool bNewItem) {
- if (HeldItem != INV_NOICON) {
+ if (g_heldItem != INV_NOICON) {
if (TinselV2) {
if (bNewItem) {
- int objIndex = GetObjectIndex(HeldItem);
- heldFilm = invFilms[objIndex];
+ int objIndex = GetObjectIndex(g_heldItem);
+ g_heldFilm = g_invFilms[objIndex];
}
- SetAuxCursor(heldFilm);
+ SetAuxCursor(g_heldFilm);
} else {
- INV_OBJECT *invObj = GetInvObject(HeldItem);
+ INV_OBJECT *invObj = GetInvObject(g_heldItem);
SetAuxCursor(invObj->hIconFilm);
}
}
@@ -1342,14 +1331,14 @@ extern void InventoryIconCursor(bool bNewItem) {
* Returns true if the inventory is active.
*/
extern bool InventoryActive() {
- return (InventoryState == ACTIVE_INV);
+ return (g_InventoryState == ACTIVE_INV);
}
extern int WhichInventoryOpen() {
- if (InventoryState != ACTIVE_INV)
+ if (g_InventoryState != ACTIVE_INV)
return 0;
else
- return ino;
+ return g_ino;
}
@@ -1387,7 +1376,7 @@ static void ObjectProcess(CORO_PARAM, const void *param) {
CORO_INVOKE_1(Interpret, _ctx->pic);
if (to->event == POINTED) {
- _ctx->ThisPointedWait = ++PointedWaitCount;
+ _ctx->ThisPointedWait = ++g_PointedWaitCount;
while (1) {
CORO_SLEEP(1);
int x, y;
@@ -1396,7 +1385,7 @@ static void ObjectProcess(CORO_PARAM, const void *param) {
break;
// Fix the 'repeated pressing bug'
- if (_ctx->ThisPointedWait != PointedWaitCount)
+ if (_ctx->ThisPointedWait != g_PointedWaitCount)
CORO_KILL_SELF();
}
@@ -1413,10 +1402,10 @@ static void ObjectProcess(CORO_PARAM, const void *param) {
static void InvTinselEvent(INV_OBJECT *pinvo, TINSEL_EVENT event, PLR_EVENT be, int index) {
OP_INIT to = { pinvo, event, be, 0 };
- if (InventoryHidden || (TinselV2 && !pinvo->hScript))
+ if (g_InventoryHidden || (TinselV2 && !pinvo->hScript))
return;
- GlitterIndex = index;
+ g_GlitterIndex = index;
g_scheduler->createProcess(PID_TCODE, ObjectProcess, &to, sizeof(to));
}
@@ -1491,9 +1480,9 @@ static void FirstFile(int first) {
static void InvSaveGame() {
if (cd.selBox != NOBOX) {
#ifndef JAPAN
- sedit[strlen(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), sedit);
+ SaveGame(ListEntry(cd.selBox-cd.modifier+cd.extraBase, LE_NAME), g_sedit);
}
}
@@ -1506,17 +1495,17 @@ static void InvLoadGame() {
if (cd.selBox != NOBOX && (cd.selBox+cd.extraBase < cd.numSaved)) {
rGame = cd.selBox;
cd.selBox = NOBOX;
- if (iconArray[HL3] != NULL) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL3]);
- iconArray[HL3] = NULL;
+ if (g_iconArray[HL3] != NULL) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]);
+ g_iconArray[HL3] = NULL;
}
- if (iconArray[HL2] != NULL) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL2]);
- iconArray[HL2] = NULL;
+ if (g_iconArray[HL2] != NULL) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]);
+ g_iconArray[HL2] = NULL;
}
- if (iconArray[HL1] != NULL) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
- iconArray[HL1] = NULL;
+ if (g_iconArray[HL1] != NULL) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
+ g_iconArray[HL1] = NULL;
}
RestoreGame(rGame+cd.extraBase);
}
@@ -1533,7 +1522,7 @@ static bool UpdateString(const Common::KeyState &kbd) {
if (!cd.editableRgroup)
return false;
- cpos = strlen(sedit)-1;
+ cpos = strlen(g_sedit)-1;
if (kbd.ascii == 0)
return false;
@@ -1541,18 +1530,18 @@ static bool UpdateString(const Common::KeyState &kbd) {
if (kbd.keycode == Common::KEYCODE_BACKSPACE) {
if (!cpos)
return false;
- sedit[cpos] = 0;
+ g_sedit[cpos] = 0;
cpos--;
- sedit[cpos] = CURSOR_CHAR;
+ g_sedit[cpos] = CURSOR_CHAR;
return true;
// } else if (isalnum(c) || c == ',' || c == '.' || c == '\'' || (c == ' ' && cpos != 0)) {
} else if (IsCharImage(GetTagFontHandle(), kbd.ascii) || (kbd.ascii == ' ' && cpos != 0)) {
if (cpos == SG_DESC_LEN)
return false;
- sedit[cpos] = kbd.ascii;
+ g_sedit[cpos] = kbd.ascii;
cpos++;
- sedit[cpos] = CURSOR_CHAR;
- sedit[cpos+1] = 0;
+ g_sedit[cpos] = CURSOR_CHAR;
+ g_sedit[cpos+1] = 0;
return true;
}
return false;
@@ -1582,25 +1571,25 @@ static bool InvKeyIn(const Common::KeyState &kbd) {
* Delete display of text currently being edited,
* and replace it with freshly edited text.
*/
- if (iconArray[HL3] != NULL) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL3]);
- iconArray[HL3] = NULL;
+ if (g_iconArray[HL3] != NULL) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]);
+ g_iconArray[HL3] = NULL;
}
- iconArray[HL3] = ObjectTextOut(
- GetPlayfieldList(FIELD_STATUS), sedit, 0,
- InvD[ino].inventoryX + cd.box[cd.selBox].xpos + 2,
- InvD[ino].inventoryY + cd.box[cd.selBox].ypos + TYOFF,
+ g_iconArray[HL3] = ObjectTextOut(
+ 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,
GetTagFontHandle(), 0);
- if (MultiRightmost(iconArray[HL3]) > MAX_NAME_RIGHT) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL3]);
+ if (MultiRightmost(g_iconArray[HL3]) > MAX_NAME_RIGHT) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]);
UpdateString(Common::KeyState(Common::KEYCODE_BACKSPACE));
- iconArray[HL3] = ObjectTextOut(
- GetPlayfieldList(FIELD_STATUS), sedit, 0,
- InvD[ino].inventoryX + cd.box[cd.selBox].xpos + 2,
- InvD[ino].inventoryY + cd.box[cd.selBox].ypos + TYOFF,
+ g_iconArray[HL3] = ObjectTextOut(
+ 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,
GetTagFontHandle(), 0);
}
- MultiSetZPosition(iconArray[HL3], Z_INV_ITEXT + 2);
+ MultiSetZPosition(g_iconArray[HL3], Z_INV_ITEXT + 2);
}
#endif
}
@@ -1625,28 +1614,28 @@ static void Select(int i, bool force) {
cd.selBox = i;
// Clear previous selected highlight and text
- if (iconArray[HL2] != NULL) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL2]);
- iconArray[HL2] = NULL;
+ if (g_iconArray[HL2] != NULL) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]);
+ g_iconArray[HL2] = NULL;
}
- if (iconArray[HL3] != NULL) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL3]);
- iconArray[HL3] = NULL;
+ if (g_iconArray[HL3] != NULL) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]);
+ g_iconArray[HL3] = NULL;
}
// New highlight box
switch (cd.box[i].boxType) {
case RGROUP:
- iconArray[HL2] = RectangleObject(BgPal(),
+ g_iconArray[HL2] = RectangleObject(BgPal(),
(TinselV2 ? HighlightColor() : COL_HILIGHT), cd.box[i].w, cd.box[i].h);
- MultiInsertObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL2]);
- MultiSetAniXY(iconArray[HL2],
- InvD[ino].inventoryX + cd.box[i].xpos,
- InvD[ino].inventoryY + cd.box[i].ypos);
+ MultiInsertObject(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);
// Z-position of box, and add edit text if appropriate
if (cd.editableRgroup) {
- MultiSetZPosition(iconArray[HL2], Z_INV_ITEXT+1);
+ MultiSetZPosition(g_iconArray[HL2], Z_INV_ITEXT+1);
if (TinselV2) {
assert(cd.box[i].textMethod == TM_POINTER);
@@ -1657,29 +1646,29 @@ static void Select(int i, bool force) {
// Current date and time
time(&secs_now);
time_now = localtime(&secs_now);
- strftime(sedit, SG_DESC_LEN, "%D %H:%M", time_now);
+ strftime(g_sedit, SG_DESC_LEN, "%D %H:%M", time_now);
#else
// Current description with cursor appended
if (cd.box[i].boxText != NULL) {
- strcpy(sedit, cd.box[i].boxText);
- strcat(sedit, sCursor);
+ strcpy(g_sedit, cd.box[i].boxText);
+ strcat(g_sedit, sCursor);
} else {
- strcpy(sedit, sCursor);
+ strcpy(g_sedit, sCursor);
}
#endif
- iconArray[HL3] = ObjectTextOut(
- GetPlayfieldList(FIELD_STATUS), sedit, 0,
- InvD[ino].inventoryX + cd.box[i].xpos + 2,
+ g_iconArray[HL3] = ObjectTextOut(
+ GetPlayfieldList(FIELD_STATUS), g_sedit, 0,
+ g_InvD[g_ino].inventoryX + cd.box[i].xpos + 2,
#ifdef JAPAN
- InvD[ino].inventoryY + cd.box[i].ypos + 2,
+ g_InvD[g_ino].inventoryY + cd.box[i].ypos + 2,
#else
- InvD[ino].inventoryY + cd.box[i].ypos + TYOFF,
+ g_InvD[g_ino].inventoryY + cd.box[i].ypos + TYOFF,
#endif
GetTagFontHandle(), 0);
- MultiSetZPosition(iconArray[HL3], Z_INV_ITEXT + 2);
+ MultiSetZPosition(g_iconArray[HL3], Z_INV_ITEXT + 2);
} else {
- MultiSetZPosition(iconArray[HL2], Z_INV_ICONS + 1);
+ MultiSetZPosition(g_iconArray[HL2], Z_INV_ICONS + 1);
}
_vm->divertKeyInput(InvKeyIn);
@@ -1687,12 +1676,12 @@ static void Select(int i, bool force) {
break;
case FRGROUP:
- iconArray[HL2] = RectangleObject(BgPal(), COL_HILIGHT, cd.box[i].w+6, cd.box[i].h+6);
- MultiInsertObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL2]);
- MultiSetAniXY(iconArray[HL2],
- InvD[ino].inventoryX + cd.box[i].xpos - 2,
- InvD[ino].inventoryY + cd.box[i].ypos - 2);
- MultiSetZPosition(iconArray[HL2], Z_INV_BRECT+1);
+ g_iconArray[HL2] = RectangleObject(BgPal(), COL_HILIGHT, cd.box[i].w+6, cd.box[i].h+6);
+ MultiInsertObject(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);
break;
@@ -1710,13 +1699,13 @@ static void Select(int i, bool force) {
* Stop holding an item.
*/
extern void DropItem(int item) {
- if (HeldItem == item) {
- HeldItem = INV_NOICON; // Item not held
+ if (g_heldItem == item) {
+ g_heldItem = INV_NOICON; // Item not held
DelAuxCursor(); // no longer aux cursor
}
// Redraw contents - held item was not displayed as a content.
- ItemsChanged = true;
+ g_ItemsChanged = true;
}
/**
@@ -1725,8 +1714,8 @@ extern void DropItem(int item) {
extern void ClearInventory(int invno) {
assert(invno == INV_1 || invno == INV_2);
- InvD[invno].NoofItems = 0;
- memset(InvD[invno].contents, 0, sizeof(InvD[invno].contents));
+ g_InvD[invno].NoofItems = 0;
+ memset(g_InvD[invno].contents, 0, sizeof(g_InvD[invno].contents));
}
/**
@@ -1743,12 +1732,12 @@ extern void AddToInventory(int invno, int icon, bool hold) {
|| invno == INV_OPEN || (invno == INV_DEFAULT && TinselV2));
if (invno == INV_OPEN) {
- assert(InventoryState == ACTIVE_INV && (ino == INV_1 || ino == INV_2)); // addopeninv() with inventry not open
- invno = ino;
+ assert(g_InventoryState == ACTIVE_INV && (g_ino == INV_1 || g_ino == INV_2)); // addopeninv() with inventry not open
+ invno = g_ino;
bOpen = true;
// Make sure it doesn't get in both!
- RemFromInventory(ino == INV_1 ? INV_2 : INV_1, icon);
+ RemFromInventory(g_ino == INV_1 ? INV_2 : INV_1, icon);
} else {
bOpen = false;
@@ -1769,61 +1758,61 @@ extern void AddToInventory(int invno, int icon, bool hold) {
RemFromInventory(INV_1, icon);
// See if it's already there
- for (i = 0; i < InvD[invno].NoofItems; i++) {
- if (InvD[invno].contents[i] == icon)
+ for (i = 0; i < g_InvD[invno].NoofItems; i++) {
+ if (g_InvD[invno].contents[i] == icon)
break;
}
// Add it if it isn't already there
- if (i == InvD[invno].NoofItems) {
+ if (i == g_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 < InvD[INV_CONV].NoofItems; i++) {
- invObj = GetInvObject(InvD[INV_CONV].contents[i]);
+ for (i = 0, nei = 0; i < g_InvD[INV_CONV].NoofItems; i++) {
+ invObj = GetInvObject(g_InvD[INV_CONV].contents[i]);
if (invObj->attribute & CONVENDITEM)
nei++;
}
// For conversation, insert before end icons
- 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;
+ 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;
// Get the window to re-position
- bMoveOnUnHide = true;
+ g_bMoveOnUnHide = true;
} else {
// For conversation, insert before last icon
// which will always be the goodbye icon
- InvD[invno].contents[InvD[invno].NoofItems] = InvD[invno].contents[InvD[invno].NoofItems-1];
- InvD[invno].contents[InvD[invno].NoofItems-1] = icon;
- InvD[invno].NoofItems++;
+ 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 {
- InvD[invno].contents[InvD[invno].NoofItems++] = icon;
+ g_InvD[invno].contents[g_InvD[invno].NoofItems++] = icon;
}
- ItemsChanged = true;
+ g_ItemsChanged = true;
} else {
// It could be that the index is beyond what you'd expect
// as delinv may well have been called
- 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;
+ 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;
} else {
- InvD[invno].contents[InvD[invno].NoofItems] = icon;
+ g_InvD[invno].contents[g_InvD[invno].NoofItems] = icon;
}
- InvD[invno].NoofItems++;
+ g_InvD[invno].NoofItems++;
}
// Move here after bug on Japenese DW1
- ItemsChanged = true;
+ g_ItemsChanged = true;
}
// Hold it if requested
@@ -1841,25 +1830,25 @@ extern bool 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 < InvD[invno].NoofItems; i++) {
- if (InvD[invno].contents[i] == icon)
+ for (i = 0; i < g_InvD[invno].NoofItems; i++) {
+ if (g_InvD[invno].contents[i] == icon)
break;
}
- if (i == InvD[invno].NoofItems)
+ if (i == g_InvD[invno].NoofItems)
return false; // Item wasn't there
else {
- memmove(&InvD[invno].contents[i], &InvD[invno].contents[i+1], (InvD[invno].NoofItems-i)*sizeof(int));
- InvD[invno].NoofItems--;
+ 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) {
- InvD[INV_CONV].NoofHicons = InvD[invno].NoofItems;
+ g_InvD[INV_CONV].NoofHicons = g_InvD[invno].NoofItems;
// Get the window to re-position
- bMoveOnUnHide = true;
+ g_bMoveOnUnHide = true;
}
- ItemsChanged = true;
+ g_ItemsChanged = true;
return true; // Item removed
}
}
@@ -1870,27 +1859,27 @@ extern bool RemFromInventory(int invno, int icon) {
extern void HoldItem(int item, bool bKeepFilm) {
INV_OBJECT *invObj;
- if (HeldItem != item) {
- if (TinselV2 && (HeldItem != NOOBJECT)) {
+ if (g_heldItem != item) {
+ if (TinselV2 && (g_heldItem != NOOBJECT)) {
// No longer holding previous item
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(HeldItem, INV_1) && !IsInInventory(HeldItem, INV_2)) {
- invObj = GetInvObject(HeldItem);
+ if (!IsInInventory(g_heldItem, INV_1) && !IsInInventory(g_heldItem, INV_2)) {
+ invObj = GetInvObject(g_heldItem);
if (invObj->attribute & DEFINV1)
- AddToInventory(INV_1, HeldItem);
+ AddToInventory(INV_1, g_heldItem);
else if (invObj->attribute & DEFINV2)
- AddToInventory(INV_2, HeldItem);
+ AddToInventory(INV_2, g_heldItem);
else
// Hook for definable default inventory
- AddToInventory(INV_1, HeldItem);
+ AddToInventory(INV_1, g_heldItem);
}
} else if (!TinselV2) {
- if (item == INV_NOICON && HeldItem != INV_NOICON)
+ if (item == INV_NOICON && g_heldItem != INV_NOICON)
DelAuxCursor(); // no longer aux cursor
if (item != INV_NOICON) {
@@ -1899,19 +1888,19 @@ extern void HoldItem(int item, bool bKeepFilm) {
}
}
- HeldItem = item; // Item held
+ g_heldItem = item; // Item held
if (TinselV2) {
InventoryIconCursor(!bKeepFilm);
// Redraw contents - held item not displayed as a content.
- ItemsChanged = true;
+ g_ItemsChanged = true;
}
}
if (!TinselV2)
// Redraw contents - held item not displayed as a content.
- ItemsChanged = true;
+ g_ItemsChanged = true;
}
/**************************************************************************/
@@ -1929,8 +1918,8 @@ enum { I_NOTIN, I_HEADER, I_BODY,
// the active area of the borders for re-sizing.
/*---------------------------------*/
-#define LeftX InvD[ino].inventoryX
-#define TopY InvD[ino].inventoryY
+#define LeftX g_InvD[g_ino].inventoryX
+#define TopY g_InvD[g_ino].inventoryY
/*---------------------------------*/
/**
@@ -1943,8 +1932,8 @@ enum { I_NOTIN, I_HEADER, I_BODY,
*/
static int InvArea(int x, int y) {
if (TinselV2) {
- 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;
+ 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;
// Outside the whole rectangle?
if (x <= LeftX || x > RightX || y <= TopY || y > BottomY)
@@ -1983,7 +1972,7 @@ static int InvArea(int x, int y) {
return I_HEADER;
// Scroll bits
- if (!(ino == INV_MENU && cd.bExtraWin)) {
+ if (!(g_ino == 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;
@@ -1992,10 +1981,10 @@ static int InvArea(int x, int y) {
/* '3' is a magic adjustment with no apparent sense */
- if (y >= TopY + sliderYmin - 3 && y < TopY + sliderYmax + NM_SLH) {
- if (y < TopY + sliderYpos - 3)
+ if (y >= TopY + g_sliderYmin - 3 && y < TopY + g_sliderYmax + NM_SLH) {
+ if (y < TopY + g_sliderYpos - 3)
return I_SLIDE_UP;
- if (y < TopY + sliderYpos + NM_SLH - 3)
+ if (y < TopY + g_sliderYpos + NM_SLH - 3)
return I_SLIDE;
else
return I_SLIDE_DOWN;
@@ -2003,8 +1992,8 @@ static int InvArea(int x, int y) {
}
}
} else {
- int RightX = MultiRightmost(RectObject) + 1;
- int BottomY = MultiLowest(RectObject) + 1;
+ int RightX = MultiRightmost(g_RectObject) + 1;
+ int BottomY = MultiLowest(g_RectObject) + 1;
// Outside the whole rectangle?
if (x <= LeftX - EXTRA || x > RightX + EXTRA
@@ -2041,7 +2030,7 @@ static int InvArea(int x, int y) {
/*
* In the move area?
*/
- if (ino != INV_CONF
+ 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;
@@ -2049,17 +2038,17 @@ static int InvArea(int x, int y) {
/*
* Scroll bits
*/
- if (!(ino == INV_CONF && cd.bExtraWin)) {
+ if (!(g_ino == 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 + sliderYmin && y < TopY + sliderYmax + M_SH) {
- if (y < TopY + sliderYpos)
+ if (y >= TopY + g_sliderYmin && y < TopY + g_sliderYmax + M_SH) {
+ if (y < TopY + g_sliderYpos)
return I_SLIDE_UP;
- if (y < TopY + sliderYpos + M_SH)
+ if (y < TopY + g_sliderYpos + M_SH)
return I_SLIDE;
else
return I_SLIDE_DOWN;
@@ -2081,14 +2070,14 @@ extern int InvItem(int *x, int *y, bool update) {
int item;
int IconsX;
- itop = InvD[ino].inventoryY + START_ICONY;
+ itop = g_InvD[g_ino].inventoryY + START_ICONY;
- IconsX = InvD[ino].inventoryX + START_ICONX;
+ IconsX = g_InvD[g_ino].inventoryX + START_ICONX;
- for (item = InvD[ino].FirstDisp, row = 0; row < InvD[ino].NoofVicons; row++) {
+ for (item = g_InvD[g_ino].FirstDisp, row = 0; row < g_InvD[g_ino].NoofVicons; row++) {
ileft = IconsX;
- for (col = 0; col < InvD[ino].NoofHicons; col++, item++) {
+ for (col = 0; col < g_InvD[g_ino].NoofHicons; col++, item++) {
if (*x >= ileft && *x < ileft + ITEM_WIDTH &&
*y >= itop && *y < itop + ITEM_HEIGHT) {
if (update) {
@@ -2121,20 +2110,20 @@ int InvItemId(int x, int y) {
int row, col;
int item;
- if (InventoryHidden || InventoryState == IDLE_INV)
+ if (g_InventoryHidden || g_InventoryState == IDLE_INV)
return INV_NOICON;
- itop = InvD[ino].inventoryY + START_ICONY;
+ itop = g_InvD[g_ino].inventoryY + START_ICONY;
- int IconsX = InvD[ino].inventoryX + START_ICONX;
+ int IconsX = g_InvD[g_ino].inventoryX + START_ICONX;
- for (item = InvD[ino].FirstDisp, row = 0; row < InvD[ino].NoofVicons; row++) {
+ for (item = g_InvD[g_ino].FirstDisp, row = 0; row < g_InvD[g_ino].NoofVicons; row++) {
ileft = IconsX;
- for (col = 0; col < InvD[ino].NoofHicons; col++, item++) {
+ for (col = 0; col < g_InvD[g_ino].NoofHicons; col++, item++) {
if (x >= ileft && x < ileft + ITEM_WIDTH &&
y >= itop && y < itop + ITEM_HEIGHT) {
- return InvD[ino].contents[item];
+ return g_InvD[g_ino].contents[item];
}
ileft += ITEM_WIDTH + 1;
@@ -2149,15 +2138,15 @@ int InvItemId(int x, int y) {
*/
static int WhichMenuBox(int curX, int curY, bool bSlides) {
if (bSlides) {
- 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;
+ 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;
}
}
- curX -= InvD[ino].inventoryX;
- curY -= InvD[ino].inventoryY;
+ curX -= g_InvD[g_ino].inventoryX;
+ curY -= g_InvD[g_ino].inventoryY;
for (int i = 0; i < cd.NumBoxes; i++) {
switch (cd.box[i].boxType) {
@@ -2184,7 +2173,7 @@ static int WhichMenuBox(int curX, int curY, bool bSlides) {
break;
case ROTATE:
- if (bNoLanguage)
+ if (g_bNoLanguage)
break;
if (curY > cd.box[i].ypos && curY < cd.box[i].ypos + cd.box[i].h) {
@@ -2222,9 +2211,9 @@ static int WhichMenuBox(int curX, int curY, bool bSlides) {
return IB_UP;
else if (curY > (r.bottom - (TinselV2 ? 18 : 5)))
return IB_DOWN;
- else if (curY + InvD[ino].inventoryY < sliderYpos)
+ else if (curY + g_InvD[g_ino].inventoryY < g_sliderYpos)
return IB_SLIDE_UP;
- else if (curY + InvD[ino].inventoryY >= sliderYpos + NM_SLH)
+ else if (curY + g_InvD[g_ino].inventoryY >= g_sliderYpos + NM_SLH)
return IB_SLIDE_DOWN;
else
return IB_SLIDE;
@@ -2260,60 +2249,60 @@ static void InvBoxes(bool InBody, int curX, int curY) {
if (index < 0) {
// unhigh-light box (if one was)
cd.pointBox = NOBOX;
- if (iconArray[HL1] != NULL) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
- iconArray[HL1] = NULL;
+ if (g_iconArray[HL1] != NULL) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
+ g_iconArray[HL1] = NULL;
}
} else if (index != cd.pointBox) {
cd.pointBox = index;
// A new box is pointed to - high-light it
- if (iconArray[HL1] != NULL) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
- iconArray[HL1] = NULL;
+ if (g_iconArray[HL1] != NULL) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
+ g_iconArray[HL1] = NULL;
}
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) {
- iconArray[HL1] = RectangleObject(BgPal(),
+ g_iconArray[HL1] = RectangleObject(BgPal(),
(TinselV2 ? HighlightColor() : COL_HILIGHT),
cd.box[cd.pointBox].w, cd.box[cd.pointBox].h);
- MultiInsertObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
- MultiSetAniXY(iconArray[HL1],
- InvD[ino].inventoryX + cd.box[cd.pointBox].xpos,
- InvD[ino].inventoryY + cd.box[cd.pointBox].ypos);
- MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1);
+ MultiInsertObject(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);
} 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 *)LockMem(hWinParts);
+ pfilm = (const FILM *)LockMem(g_hWinParts);
- iconArray[HL1] = AddObject(&pfilm->reels[cd.box[cd.pointBox].bi+HIGRAPH], -1);
- MultiSetAniXY(iconArray[HL1],
- InvD[ino].inventoryX + cd.box[cd.pointBox].xpos,
- InvD[ino].inventoryY + cd.box[cd.pointBox].ypos);
- MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+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);
} else if (cd.box[cd.pointBox].boxType == ROTATE) {
- if (bNoLanguage)
+ if (g_bNoLanguage)
return;
- pfilm = (const FILM *)LockMem(hWinParts);
+ pfilm = (const FILM *)LockMem(g_hWinParts);
rotateIndex = cd.box[cd.pointBox].bi;
if (rotateIndex == IX2_LEFT1) {
- iconArray[HL1] = AddObject(&pfilm->reels[IX2_LEFT2], -1 );
- MultiSetAniXY(iconArray[HL1],
- InvD[ino].inventoryX + cd.box[cd.pointBox].xpos - ROTX1,
- InvD[ino].inventoryY + cd.box[cd.pointBox].ypos);
- MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+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);
} else if (rotateIndex == IX2_RIGHT1) {
- iconArray[HL1] = AddObject(&pfilm->reels[IX2_RIGHT2], -1);
- MultiSetAniXY(iconArray[HL1],
- InvD[ino].inventoryX + cd.box[cd.pointBox].xpos + ROTX1,
- InvD[ino].inventoryY + cd.box[cd.pointBox].ypos);
- MultiSetZPosition(iconArray[HL1], Z_INV_ICONS + 1);
+ 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);
}
}
}
@@ -2330,37 +2319,37 @@ static void ButtonPress(CORO_PARAM, CONFBOX *box) {
assert(box->boxType == AAGBUT || box->boxType == ARSGBUT);
// Replace highlight image with normal image
- pfilm = (const FILM *)LockMem(hWinParts);
- if (iconArray[HL1] != NULL)
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
- pfilm = (const FILM *)LockMem(hWinParts);
- iconArray[HL1] = AddObject(&pfilm->reels[box->bi+NORMGRAPH], -1);
- MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos);
- MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1);
+ pfilm = (const FILM *)LockMem(g_hWinParts);
+ if (g_iconArray[HL1] != NULL)
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
+ pfilm = (const FILM *)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 (iconArray[HL1] == NULL)
+ if (g_iconArray[HL1] == NULL)
return;
// Replace normal image with depresses image
- pfilm = (const FILM *)LockMem(hWinParts);
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
- iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1);
- MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos);
- MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1);
+ pfilm = (const FILM *)LockMem(g_hWinParts);
+ MultiDeleteObject(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 (iconArray[HL1] == NULL)
+ if (g_iconArray[HL1] == NULL)
return;
// Replace depressed image with normal image
- pfilm = (const FILM *)LockMem(hWinParts);
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
- iconArray[HL1] = AddObject(&pfilm->reels[box->bi+NORMGRAPH], -1);
- MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos);
- MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1);
+ pfilm = (const FILM *)LockMem(g_hWinParts);
+ MultiDeleteObject(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);
@@ -2379,25 +2368,25 @@ static void ButtonToggle(CORO_PARAM, CONFBOX *box) {
|| (box->boxType == TOGGLE2));
// Remove hilight image
- if (iconArray[HL1] != NULL) {
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
- iconArray[HL1] = NULL;
+ if (g_iconArray[HL1] != NULL) {
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
+ g_iconArray[HL1] = NULL;
}
// Hold normal image for 1 frame
CORO_SLEEP(1);
- if (InventoryState != ACTIVE_INV)
+ if (g_InventoryState != ACTIVE_INV)
return;
// Add depressed image
- pfilm = (const FILM *)LockMem(hWinParts);
- iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1);
- MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos);
- MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1);
+ pfilm = (const FILM *)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 (iconArray[HL1] == NULL)
+ if (g_iconArray[HL1] == NULL)
return;
// Toggle state
@@ -2409,34 +2398,34 @@ static void ButtonToggle(CORO_PARAM, CONFBOX *box) {
Select(cd.selBox, true);
// New state, depressed image
- pfilm = (const FILM *)LockMem(hWinParts);
- if (iconArray[HL1] != NULL)
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
- iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1);
- MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos);
- MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1);
+ pfilm = (const FILM *)LockMem(g_hWinParts);
+ if (g_iconArray[HL1] != NULL)
+ MultiDeleteObject(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 (iconArray[HL1] == NULL)
+ if (g_iconArray[HL1] == NULL)
return;
// New state, normal
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
- iconArray[HL1] = NULL;
+ MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
+ g_iconArray[HL1] = NULL;
// Hold normal image for 1 frame
CORO_SLEEP(1);
- if (InventoryState != ACTIVE_INV)
+ if (g_InventoryState != ACTIVE_INV)
return;
// New state, highlighted
- pfilm = (const FILM *)LockMem(hWinParts);
- if (iconArray[HL1] != NULL)
- MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
- iconArray[HL1] = AddObject(&pfilm->reels[box->bi+HIGRAPH], -1);
- MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos);
- MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1);
+ pfilm = (const FILM *)LockMem(g_hWinParts);
+ if (g_iconArray[HL1] != NULL)
+ MultiDeleteObject(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;
}
@@ -2454,23 +2443,23 @@ static void InvLabels(bool InBody, int aniX, int aniY) {
else {
index = InvItem(&aniX, &aniY, false);
if (index != INV_NOICON) {
- if (index >= InvD[ino].NoofItems)
+ if (index >= g_InvD[g_ino].NoofItems)
index = INV_NOICON;
else
- index = InvD[ino].contents[index];
+ 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!
- if (index == INV_NOICON || index == HeldItem) {
- pointedIcon = INV_NOICON;
- } else if (index != pointedIcon) {
+ if (index == INV_NOICON || index == g_heldItem) {
+ g_pointedIcon = INV_NOICON;
+ } else if (index != g_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);
- pointedIcon = index;
+ g_pointedIcon = index;
}
}
@@ -2492,54 +2481,54 @@ static void AdjustTop() {
int n, i;
// Only do this if there's a slider
- if (!SlideObject)
+ if (!g_SlideObject)
return;
- rowsWanted = (InvD[ino].NoofItems - InvD[ino].FirstDisp + InvD[ino].NoofHicons-1) / InvD[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 < InvD[ino].NoofVicons) {
- if (InvD[ino].FirstDisp) {
- InvD[ino].FirstDisp -= InvD[ino].NoofHicons;
- if (InvD[ino].FirstDisp < 0)
- InvD[ino].FirstDisp = 0;
+ 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;
rowsWanted++;
} else
break;
}
- tMissing = InvD[ino].FirstDisp ? (InvD[ino].FirstDisp + InvD[ino].NoofHicons-1)/InvD[ino].NoofHicons : 0;
- bMissing = (rowsWanted > InvD[ino].NoofVicons) ? rowsWanted - InvD[ino].NoofVicons : 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;
- slideRange = sliderYmax - sliderYmin;
+ slideRange = g_sliderYmax - g_sliderYmin;
if (!tMissing)
- nsliderYpos = sliderYmin;
+ nsliderYpos = g_sliderYmin;
else if (!bMissing)
- nsliderYpos = sliderYmax;
+ nsliderYpos = g_sliderYmax;
else {
nsliderYpos = tMissing*slideRange/nMissing;
- nsliderYpos += sliderYmin;
+ nsliderYpos += g_sliderYmin;
}
if (nMissing) {
- n = InvD[ino].FirstDisp - tMissing*InvD[ino].NoofHicons;
- for (i = 0; i <= nMissing; i++, n += InvD[ino].NoofHicons) {
- slideStuff[i].n = n;
- slideStuff[i].y = (i*slideRange/nMissing) + sliderYmin;
+ 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;
}
- if (slideStuff[0].n < 0)
- slideStuff[0].n = 0;
+ if (g_slideStuff[0].n < 0)
+ g_slideStuff[0].n = 0;
assert(i < MAX_ININV + 1);
- slideStuff[i].n = -1;
+ g_slideStuff[i].n = -1;
} else {
- slideStuff[0].n = 0;
- slideStuff[0].y = sliderYmin;
- slideStuff[1].n = -1;
+ g_slideStuff[0].n = 0;
+ g_slideStuff[0].y = g_sliderYmin;
+ g_slideStuff[1].n = -1;
}
- if (nsliderYpos != sliderYpos) {
- MultiMoveRelXY(SlideObject, 0, nsliderYpos - sliderYpos);
- sliderYpos = nsliderYpos;
+ if (nsliderYpos != g_sliderYpos) {
+ MultiMoveRelXY(g_SlideObject, 0, nsliderYpos - g_sliderYpos);
+ g_sliderYpos = nsliderYpos;
}
}
@@ -2580,26 +2569,26 @@ static void FillInInventory() {
DumpIconArray();
- if (InvDragging != ID_SLIDE)
+ if (g_InvDragging != ID_SLIDE)
AdjustTop(); // Set up slideStuff[]
- Index = InvD[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
- for (row = 0; row < InvD[ino].NoofVicons; row++, ypos += ITEM_HEIGHT + 1) {
+ 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 < InvD[ino].NoofHicons; col++) {
- if (Index >= InvD[ino].NoofItems)
+ for (col = 0; col < g_InvD[g_ino].NoofHicons; col++) {
+ if (Index >= g_InvD[g_ino].NoofItems)
break;
- else if (InvD[ino].contents[Index] != HeldItem) {
+ else if (g_InvD[g_ino].contents[Index] != g_heldItem) {
// Create a display object and position it
- iconArray[n] = AddInvObject(InvD[ino].contents[Index], &pfr, &pfilm);
- MultiSetAniXY(iconArray[n], InvD[ino].inventoryX + xpos , InvD[ino].inventoryY + ypos);
- MultiSetZPosition(iconArray[n], Z_INV_ICONS);
+ 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);
- InitStepAnimScript(&iconAnims[n], iconArray[n], FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pfilm->frate));
+ InitStepAnimScript(&g_iconAnims[n], g_iconArray[n], FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pfilm->frate));
n++;
}
@@ -2617,16 +2606,16 @@ enum {FROM_HANDLE, FROM_STRING};
*/
static void AddBackground(OBJECT **rect, OBJECT **title, int extraH, int extraV, int textFrom) {
// Why not 2 ????
- int width = TLwidth + extraH + TRwidth + NM_BG_SIZ_X;
- int height = TLheight + extraV + BLheight + NM_BG_SIZ_Y;
+ int width = g_TLwidth + extraH + g_TRwidth + NM_BG_SIZ_X;
+ int height = g_TLheight + extraV + g_BLheight + NM_BG_SIZ_Y;
// Create a rectangle object
- RectObject = *rect = TranslucentObject(width, height);
+ g_RectObject = *rect = TranslucentObject(width, height);
// add it to display list and position it
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), *rect);
- MultiSetAniXY(*rect, InvD[ino].inventoryX + NM_BG_POS_X,
- InvD[ino].inventoryY + NM_BG_POS_Y);
+ MultiSetAniXY(*rect, g_InvD[g_ino].inventoryX + NM_BG_POS_X,
+ g_InvD[g_ino].inventoryY + NM_BG_POS_Y);
MultiSetZPosition(*rect, Z_INV_BRECT);
if (title == NULL)
@@ -2634,16 +2623,16 @@ static void AddBackground(OBJECT **rect, OBJECT **title, int extraH, int extraV,
// Create text object using title string
if (textFrom == FROM_HANDLE) {
- LoadStringRes(InvD[ino].hInvTitle, TextBufferAddr(), TBUFSZ);
+ LoadStringRes(g_InvD[g_ino].hInvTitle, TextBufferAddr(), TBUFSZ);
*title = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0,
- InvD[ino].inventoryX + width/2, InvD[ino].inventoryY + M_TOFF,
+ g_InvD[g_ino].inventoryX + width/2, g_InvD[g_ino].inventoryY + M_TOFF,
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(configStrings[cd.ixHeading], TextBufferAddr(), TBUFSZ);
+ LoadStringRes(g_configStrings[cd.ixHeading], TextBufferAddr(), TBUFSZ);
*title = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0,
- InvD[ino].inventoryX + width/2, InvD[ino].inventoryY + M_TOFF,
+ g_InvD[g_ino].inventoryX + width/2, g_InvD[g_ino].inventoryY + M_TOFF,
GetTagFontHandle(), TXT_CENTER);
assert(*title); // Inventory title string produced NULL text
MultiSetZPosition(*title, Z_INV_HTEXT);
@@ -2661,13 +2650,13 @@ static void AddBackground(OBJECT **rect, int extraH, int extraV) {
* Adds a title for a dialog
*/
static void AddTitle(POBJECT *title, int extraH) {
- int width = TLwidth + extraH + TRwidth + NM_BG_SIZ_X;
+ int width = g_TLwidth + extraH + g_TRwidth + NM_BG_SIZ_X;
// Create text object using title string
- if (InvD[ino].hInvTitle != (SCNHANDLE)NO_HEADING) {
- LoadStringRes(InvD[ino].hInvTitle, TextBufferAddr(), TBUFSZ);
+ if (g_InvD[g_ino].hInvTitle != (SCNHANDLE)NO_HEADING) {
+ LoadStringRes(g_InvD[g_ino].hInvTitle, TextBufferAddr(), TBUFSZ);
*title = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0,
- InvD[ino].inventoryX + (width/2)+NM_BG_POS_X, InvD[ino].inventoryY + NM_TOFF,
+ g_InvD[g_ino].inventoryX + (width/2)+NM_BG_POS_X, g_InvD[g_ino].inventoryY + NM_TOFF,
GetTagFontHandle(), TXT_CENTER, 0);
assert(*title);
MultiSetZPosition(*title, Z_INV_HTEXT);
@@ -2691,13 +2680,13 @@ static OBJECT *AddObject(const FREEL *pfreel, int num) {
// Horrible bodge involving global variables to save
// width and/or height of some window frame components
- if (num == TL) {
- TLwidth = FROM_LE_16(pim->imgWidth);
- TLheight = FROM_LE_16(pim->imgHeight) & ~C16_FLAG_MASK;
- } else if (num == TR) {
- TRwidth = FROM_LE_16(pim->imgWidth);
- } else if (num == BL) {
- BLheight = FROM_LE_16(pim->imgHeight) & ~C16_FLAG_MASK;
+ if (num == g_TL) {
+ g_TLwidth = FROM_LE_16(pim->imgWidth);
+ g_TLheight = FROM_LE_16(pim->imgHeight) & ~C16_FLAG_MASK;
+ } else if (num == g_TR) {
+ g_TRwidth = FROM_LE_16(pim->imgWidth);
+ } else if (num == g_BL) {
+ g_BLheight = FROM_LE_16(pim->imgHeight) & ~C16_FLAG_MASK;
}
// Set up and insert the multi-object
@@ -2712,9 +2701,9 @@ static OBJECT *AddObject(const FREEL *pfreel, int num) {
*/
static void AddSlider(OBJECT **slide, const FILM *pfilm) {
- SlideObject = *slide = AddObject(&pfilm->reels[IX_SLIDE], -1);
- MultiSetAniXY(*slide, MultiRightmost(RectObject) + (TinselV2 ? NM_SLX : -M_SXOFF + 2) - 1,
- InvD[ino].inventoryY + sliderYpos);
+ g_SlideObject = *slide = AddObject(&pfilm->reels[IX_SLIDE], -1);
+ MultiSetAniXY(*slide, MultiRightmost(g_RectObject) + (TinselV2 ? NM_SLX : -M_SXOFF + 2) - 1,
+ g_InvD[g_ino].inventoryY + g_sliderYpos);
MultiSetZPosition(*slide, Z_INV_MFRAME);
}
@@ -2722,8 +2711,8 @@ static void AddSlider(OBJECT **slide, const FILM *pfilm) {
* Display a box with some text in it.
*/
static void AddBox(int *pi, const int i) {
- int x = InvD[ino].inventoryX + cd.box[i].xpos;
- int y = InvD[ino].inventoryY + cd.box[i].ypos;
+ 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;
const FILM *pFilm;
@@ -2735,11 +2724,11 @@ static void AddBox(int *pi, const int i) {
break;
// Give us a box
- iconArray[*pi] = RectangleObject(BgPal(), TinselV2 ? BoxColor() : COL_BOX,
+ g_iconArray[*pi] = RectangleObject(BgPal(), TinselV2 ? BoxColor() : COL_BOX,
cd.box[i].w, cd.box[i].h);
- MultiInsertObject(GetPlayfieldList(FIELD_STATUS), iconArray[*pi]);
- MultiSetAniXY(iconArray[*pi], x, y);
- MultiSetZPosition(iconArray[*pi], Z_INV_BRECT + 1);
+ MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[*pi]);
+ MultiSetAniXY(g_iconArray[*pi], x, y);
+ MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1;
// Stick in the text
@@ -2747,14 +2736,14 @@ static void 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) {
- iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0,
+ g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0,
#ifdef JAPAN
x + 2, y+2, GetTagFontHandle(), 0);
#else
x + 2, y + TYOFF, GetTagFontHandle(), 0);
#endif
} else {
- iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0,
+ g_iconArray[*pi] = ObjectTextOut(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);
@@ -2763,7 +2752,7 @@ static void AddBox(int *pi, const int i) {
#endif
}
- MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT);
+ MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
}
} else {
@@ -2775,61 +2764,61 @@ static void AddBox(int *pi, const int i) {
LoadStringRes(cd.box[i].ixText, TextBufferAddr(), TBUFSZ);
}
} else {
- LoadStringRes(configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ);
+ LoadStringRes(g_configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ);
assert(cd.box[i].boxType != RGROUP); // You'll need to add some code!
}
if (TinselV2 && (cd.box[i].boxType == RGROUP))
- iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(),
+ g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(),
0, x + 2, y + TYOFF, GetTagFontHandle(), 0, 0);
else
- iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),
+ g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),
TextBufferAddr(), 0,
#ifdef JAPAN
x + cd.box[i].w/2, y+2, GetTagFontHandle(), TXT_CENTER);
#else
x + cd.box[i].w / 2, y + TYOFF, GetTagFontHandle(), TXT_CENTER);
#endif
- MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT);
+ MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
}
break;
case AAGBUT:
case ARSGBUT:
- pFilm = (const FILM *)LockMem(hWinParts);
+ pFilm = (const FILM *)LockMem(g_hWinParts);
- iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + NORMGRAPH], -1);
- MultiSetAniXY(iconArray[*pi], x, y);
- MultiSetZPosition(iconArray[*pi], Z_INV_BRECT + 1);
+ 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);
*pi += 1;
break;
case FRGROUP:
- assert(flagFilm != 0); // Language flags not declared!
+ assert(g_flagFilm != 0); // Language flags not declared!
- pFilm = (const FILM *)LockMem(flagFilm);
+ pFilm = (const FILM *)LockMem(g_flagFilm);
if (_vm->_config->_isAmericanEnglishVersion && cd.box[i].bi == FIX_UK)
cd.box[i].bi = FIX_USA;
- iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi], -1);
- MultiSetAniXY(iconArray[*pi], x, y);
- MultiSetZPosition(iconArray[*pi], Z_INV_BRECT+2);
+ 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);
*pi += 1;
break;
case FLIP:
- pFilm = (const FILM *)LockMem(hWinParts);
+ pFilm = (const FILM *)LockMem(g_hWinParts);
if (*pival)
- iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi], -1);
+ g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi], -1);
else
- iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi+1], -1);
- MultiSetAniXY(iconArray[*pi], x, y);
- MultiSetZPosition(iconArray[*pi], Z_INV_BRECT+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);
*pi += 1;
// Stick in the text
@@ -2838,23 +2827,23 @@ static void AddBox(int *pi, const int i) {
LoadStringRes(SysString(cd.box[i].ixText), TextBufferAddr(), TBUFSZ);
} else {
assert(cd.box[i].ixText != USE_POINTER);
- LoadStringRes(configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ);
+ LoadStringRes(g_configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ);
}
- iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),
+ g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),
TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF, GetTagFontHandle(), TXT_RIGHT);
- MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT);
+ MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
break;
case TOGGLE:
case TOGGLE1:
case TOGGLE2:
- pFilm = (const FILM *)LockMem(hWinParts);
+ pFilm = (const FILM *)LockMem(g_hWinParts);
cd.box[i].bi = *pival ? IX_TICK1 : IX_CROSS1;
- iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + NORMGRAPH], -1);
- MultiSetAniXY(iconArray[*pi], x, y);
- MultiSetZPosition(iconArray[*pi], Z_INV_BRECT+1);
+ 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);
*pi += 1;
// Stick in the text
@@ -2863,39 +2852,39 @@ static void AddBox(int *pi, const int i) {
LoadStringRes(SysString(cd.box[i].ixText), TextBufferAddr(), TBUFSZ);
} else {
assert(cd.box[i].ixText != USE_POINTER);
- LoadStringRes(configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ);
+ LoadStringRes(g_configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ);
}
if (cd.box[i].boxType == TOGGLE2) {
- iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),
+ g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),
TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF,
GetTagFontHandle(), TXT_CENTER, 0);
} else {
- iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),
+ g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),
TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF,
GetTagFontHandle(), TXT_RIGHT, 0);
}
- MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT);
+ MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
break;
case SLIDER:
- pFilm = (const FILM *)LockMem(hWinParts);
+ pFilm = (const FILM *)LockMem(g_hWinParts);
xdisp = SLIDE_RANGE*(*pival)/cd.box[i].w;
- iconArray[*pi] = AddObject(&pFilm->reels[IX_MDGROOVE], -1);
- MultiSetAniXY(iconArray[*pi], x, y);
- MultiSetZPosition(iconArray[*pi], Z_MDGROOVE);
+ g_iconArray[*pi] = AddObject(&pFilm->reels[IX_MDGROOVE], -1);
+ MultiSetAniXY(g_iconArray[*pi], x, y);
+ MultiSetZPosition(g_iconArray[*pi], Z_MDGROOVE);
*pi += 1;
- 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];
+ 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];
*pi += 1;
// Stick in the text
@@ -2904,55 +2893,55 @@ static void AddBox(int *pi, const int i) {
LoadStringRes(SysString(cd.box[i].ixText), TextBufferAddr(), TBUFSZ);
} else {
assert(cd.box[i].ixText != USE_POINTER);
- LoadStringRes(configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ);
+ LoadStringRes(g_configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ);
}
- iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),
+ g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),
TextBufferAddr(), 0, x+MDTEXT_XOFF, y+MDTEXT_YOFF, GetTagFontHandle(), TXT_RIGHT);
- MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT);
+ MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
break;
case ROTATE:
- pFilm = (const FILM *)LockMem(hWinParts);
+ pFilm = (const FILM *)LockMem(g_hWinParts);
// Left one
- if (!bNoLanguage) {
- iconArray[*pi] = AddObject(&pFilm->reels[IX2_LEFT1], -1);
- MultiSetAniXY(iconArray[*pi], x-ROTX1, y);
- MultiSetZPosition(iconArray[*pi], Z_INV_BRECT + 1);
+ 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);
*pi += 1;
// Right one
- iconArray[*pi] = AddObject( &pFilm->reels[IX2_RIGHT1], -1);
- MultiSetAniXY(iconArray[*pi], x + ROTX1, y);
- MultiSetZPosition(iconArray[*pi], Z_INV_BRECT + 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;
// Stick in the text
assert(cd.box[i].textMethod == TM_INDEX);
LoadStringRes(SysString(cd.box[i].ixText), TextBufferAddr(), TBUFSZ);
- iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),
+ g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),
TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF,
GetTagFontHandle(), TXT_CENTER, 0);
- MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT);
+ MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
}
// Current language's text
- if (LanguageDesc(displayedLanguage) == 0)
+ if (LanguageDesc(g_displayedLanguage) == 0)
break;
- LoadStringRes(LanguageDesc(displayedLanguage), TextBufferAddr(), TBUFSZ);
- iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0,
+ LoadStringRes(LanguageDesc(g_displayedLanguage), TextBufferAddr(), TBUFSZ);
+ g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0,
x + cd.box[i].w / 2, y + ROT_YOFF, GetTagFontHandle(), TXT_CENTER, 0);
- MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT);
+ MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
// Current language's flag
- pFilm = (const FILM *)LockMem(LanguageFlag(displayedLanguage));
- iconArray[*pi] = AddObject(&pFilm->reels[0], -1);
- MultiSetAniXY(iconArray[*pi], x + FLAGX, y + FLAGY);
- MultiSetZPosition(iconArray[*pi], Z_INV_BRECT + 1);
+ pFilm = (const FILM *)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);
*pi += 1;
break;
}
@@ -2965,7 +2954,7 @@ static void AddBoxes(bool bPosnSlide) {
int objCount = NUMHL; // Object count - allow for HL1, HL2 etc.
DumpIconArray();
- numMdSlides = 0;
+ g_numMdSlides = 0;
for (int i = 0; i < cd.NumBoxes; i++) {
AddBox(&objCount, i);
@@ -2973,32 +2962,32 @@ static void AddBoxes(bool bPosnSlide) {
if (cd.bExtraWin) {
if (bPosnSlide && !TinselV2)
- sliderYpos = sliderYmin + (cd.extraBase*(sliderYmax-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 = sliderYpos;
+ int lastY = g_sliderYpos;
if (cd.box == loadBox || cd.box == saveBox)
- sliderYpos = sliderYmin + (cd.extraBase * (sliderRange)) /
+ g_sliderYpos = g_sliderYmin + (cd.extraBase * (sliderRange)) /
(MAX_SAVED_FILES - NUM_RGROUP_BOXES);
else if (cd.box == hopperBox1) {
- if (numScenes <= NUM_RGROUP_BOXES)
- sliderYpos = sliderYmin;
+ if (g_numScenes <= NUM_RGROUP_BOXES)
+ g_sliderYpos = g_sliderYmin;
else
- sliderYpos = sliderYmin + (cd.extraBase*(sliderRange))/(numScenes-NUM_RGROUP_BOXES);
+ g_sliderYpos = g_sliderYmin + (cd.extraBase*(sliderRange))/(g_numScenes-NUM_RGROUP_BOXES);
} else if (cd.box == hopperBox2) {
- if (numEntries <= NUM_RGROUP_BOXES)
- sliderYpos = sliderYmin;
+ if (g_numEntries <= NUM_RGROUP_BOXES)
+ g_sliderYpos = g_sliderYmin;
else
- sliderYpos = sliderYmin + (cd.extraBase * (sliderRange)) /
- (numEntries-NUM_RGROUP_BOXES);
+ g_sliderYpos = g_sliderYmin + (cd.extraBase * (sliderRange)) /
+ (g_numEntries-NUM_RGROUP_BOXES);
}
- MultiMoveRelXY(SlideObject, 0, sliderYpos - lastY);
+ MultiMoveRelXY(g_SlideObject, 0, g_sliderYpos - lastY);
}
if (!TinselV2)
- MultiSetAniXY(SlideObject, InvD[ino].inventoryX + 24 + 179, sliderYpos);
+ MultiSetAniXY(g_SlideObject, g_InvD[g_ino].inventoryX + 24 + 179, g_sliderYpos);
}
assert(objCount < MAX_ICONS); // added too many icons
@@ -3008,8 +2997,8 @@ static void AddBoxes(bool bPosnSlide) {
* Display the scroll bar slider.
*/
static void AddEWSlider(OBJECT **slide, const FILM *pfilm) {
- SlideObject = *slide = AddObject(&pfilm->reels[IX_SLIDE], -1);
- MultiSetAniXY(*slide, InvD[ino].inventoryX + 24 + 127, sliderYpos);
+ 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);
}
@@ -3021,7 +3010,7 @@ static int AddExtraWindow(int x, int y, OBJECT **retObj) {
const FILM *pfilm;
// Get the frame's data
- pfilm = (const FILM *)LockMem(hWinParts);
+ pfilm = (const FILM *)LockMem(g_hWinParts);
x += TinselV2 ? 30 : 20;
y += TinselV2 ? 38 : 24;
@@ -3032,56 +3021,56 @@ static int 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 ? TLwidth + 312 : 152), y);
+ 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
- MultiSetAniXY(retObj[n], x, y + (TinselV2 ? TLheight + 208 : 124));
+ 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
- MultiSetAniXY(retObj[n], x + (TinselV2 ? TLwidth + 312 : 152),
- y + (TinselV2 ? TLheight + 208 : 124));
+ MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth + 312 : 152),
+ 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
- MultiSetAniXY(retObj[n], x + (TinselV2 ? TLwidth : 6), y + NM_TBT);
+ 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 ? TLwidth : 6), y +
- (TinselV2 ? TLheight + 208 + BLheight + NM_BSY : 143));
+ 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
- MultiSetAniXY(retObj[n], x + NM_LSX, y + (TinselV2 ? TLheight : 20));
+ 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
- MultiSetAniXY(retObj[n], x + (TinselV2 ? TLwidth + 312 + TRwidth + NM_RSX : 179),
- y + (TinselV2 ? TLheight : 20));
+ MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth + 312 + g_TRwidth + NM_RSX : 179),
+ y + (TinselV2 ? g_TLheight : 20));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
retObj[n] = AddObject(&pfilm->reels[IX_V104], -1); // Right 2
- MultiSetAniXY(retObj[n], x + (TinselV2 ? TLwidth + 312 + TRwidth + NM_SBL : 188),
- y + (TinselV2 ? TLheight : 20));
+ MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth + 312 + g_TRwidth + NM_SBL : 188),
+ y + (TinselV2 ? g_TLheight : 20));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
if (TinselV2) {
- 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);
+ 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);
} else {
- sliderYpos = sliderYmin = y + 9;
- sliderYmax = y + 134;
+ g_sliderYpos = g_sliderYmin = y + 9;
+ g_sliderYmax = y + 134;
AddEWSlider(&retObj[n++], pfilm);
}
@@ -3099,17 +3088,17 @@ 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 = InvD[ino].inventoryX;
- int invY = InvD[ino].inventoryY;
+ 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 = objArray; // Standard window
+ retObj = g_objArray; // Standard window
zpos = Z_INV_MFRAME;
} else {
- retObj = DobjArray; // Re-sizing window
+ retObj = g_DobjArray; // Re-sizing window
zpos = Z_INV_RFRAME;
}
@@ -3122,83 +3111,83 @@ static void ConstructInventory(InventoryType filling) {
}
// Get the frame's data
- pfilm = (const FILM *)LockMem(hWinParts);
+ pfilm = (const FILM *)LockMem(g_hWinParts);
// Standard window is of granular dimensions
if (filling == FULL) {
// Round-up/down to nearest number of icons
- if (SuppH > ITEM_WIDTH / 2)
- InvD[ino].NoofHicons++;
- if (SuppV > ITEM_HEIGHT / 2)
- InvD[ino].NoofVicons++;
- SuppH = SuppV = 0;
+ 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;
}
// Extra width and height
- eH = (InvD[ino].NoofHicons - 1) * (ITEM_WIDTH+I_SEPARATION) + SuppH;
- eV = (InvD[ino].NoofVicons - 1) * (ITEM_HEIGHT+I_SEPARATION) + 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 && (ino == INV_CONV)) {
- TL = IX_TL;
- TR = IX2_TR4;
- BL = IX_BL;
- BR = IX_RBR;
- } else if ((filling == FULL) && (ino != INV_CONV)) {
- TL = IX_TL;
- TR = IX_TR;
- BL = IX_BL;
- BR = IX_BR;
+ 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;
} else {
- TL = IX_RTL;
- TR = IX_RTR;
- BL = IX_BL;
- BR = IX_RBR;
+ g_TL = IX_RTL;
+ g_TR = IX_RTR;
+ g_BL = IX_BL;
+ g_BR = IX_RBR;
}
// Draw the four corners
- retObj[n] = AddObject(&pfilm->reels[TL], TL);
+ retObj[n] = AddObject(&pfilm->reels[g_TL], g_TL);
MultiSetAniXY(retObj[n], invX, invY);
MultiSetZPosition(retObj[n], zpos);
n++;
- retObj[n] = AddObject(&pfilm->reels[TR], TR);
- MultiSetAniXY(retObj[n], invX + TLwidth + eH, invY);
+ retObj[n] = AddObject(&pfilm->reels[g_TR], g_TR);
+ MultiSetAniXY(retObj[n], invX + g_TLwidth + eH, invY);
MultiSetZPosition(retObj[n], zpos);
n++;
- retObj[n] = AddObject(&pfilm->reels[BL], BL);
- MultiSetAniXY(retObj[n], invX, invY + TLheight + eV);
+ retObj[n] = AddObject(&pfilm->reels[g_BL], g_BL);
+ MultiSetAniXY(retObj[n], invX, invY + g_TLheight + eV);
MultiSetZPosition(retObj[n], zpos);
n++;
- retObj[n] = AddObject(&pfilm->reels[BR], BR);
- MultiSetAniXY(retObj[n], invX + TLwidth + eH, invY + TLheight + eV);
+ retObj[n] = AddObject(&pfilm->reels[g_BR], g_BR);
+ MultiSetAniXY(retObj[n], invX + g_TLwidth + eH, invY + g_TLheight + eV);
MultiSetZPosition(retObj[n], zpos);
n++;
// Draw extra Top and bottom parts
- if (InvD[ino].NoofHicons > 1) {
+ if (g_InvD[g_ino].NoofHicons > 1) {
// Top side
- retObj[n] = AddObject(&pfilm->reels[hFillers[InvD[ino].NoofHicons-2]], -1);
- MultiSetAniXY(retObj[n], invX + TLwidth, invY + NM_TBT);
+ 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++;
// Bottom of header box
if (filling == FULL) {
if (TinselV2) {
- retObj[n] = AddObject(&pfilm->reels[hFillers[InvD[ino].NoofHicons-2]], -1);
- MultiSetAniXY(retObj[n], invX + TLwidth, invY + NM_TBB);
+ 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[InvD[ino].NoofHicons-2]], -1);
- MultiSetAniXY(retObj[n], invX + TLwidth, invY + M_TBB + 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++;
// Extra bits for conversation - hopefully temporary
- if (ino == INV_CONV) {
+ if (g_ino == INV_CONV) {
retObj[n] = AddObject(&pfilm->reels[IX_H26], -1);
- MultiSetAniXY(retObj[n], invX + TLwidth - 2, invY + M_TBB + 1);
+ MultiSetAniXY(retObj[n], invX + g_TLwidth - 2, invY + M_TBB + 1);
MultiSetZPosition(retObj[n], zpos);
n++;
@@ -3211,16 +3200,16 @@ static void ConstructInventory(InventoryType filling) {
}
// Bottom side
- retObj[n] = AddObject(&pfilm->reels[hFillers[InvD[ino].NoofHicons-2]], -1);
- MultiSetAniXY(retObj[n], invX + TLwidth, invY + TLheight + eV + BLheight + NM_BSY);
+ 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);
n++;
}
- if (SuppH) {
- int offx = TLwidth + eH - (TinselV2 ? ITEM_WIDTH + I_SEPARATION : 26);
- if (offx < TLwidth) // Not too far!
- offx = TLwidth;
+ if (g_SuppH) {
+ int offx = g_TLwidth + eH - (TinselV2 ? ITEM_WIDTH + I_SEPARATION : 26);
+ if (offx < g_TLwidth) // Not too far!
+ offx = g_TLwidth;
// Top side extra
retObj[n] = AddObject(&pfilm->reels[IX_H26], -1);
@@ -3230,39 +3219,39 @@ static void ConstructInventory(InventoryType filling) {
// Bottom side extra
retObj[n] = AddObject(&pfilm->reels[IX_H26], -1);
- MultiSetAniXY(retObj[n], invX + offx, invY + TLheight + eV + BLheight + NM_BSY);
+ MultiSetAniXY(retObj[n], invX + offx, invY + g_TLheight + eV + g_BLheight + NM_BSY);
MultiSetZPosition(retObj[n], zpos);
n++;
}
// Draw extra side parts
- if (InvD[ino].NoofVicons > 1) {
+ if (g_InvD[g_ino].NoofVicons > 1) {
// Left side
- retObj[n] = AddObject(&pfilm->reels[vFillers[InvD[ino].NoofVicons-2]], -1);
- MultiSetAniXY(retObj[n], invX + NM_LSX, invY + TLheight);
+ 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 && ino != INV_CONV) {
- retObj[n] = AddObject(&pfilm->reels[vFillers[InvD[ino].NoofVicons-2]], -1);
+ if (filling == FULL && g_ino != INV_CONV) {
+ retObj[n] = AddObject(&pfilm->reels[vFillers[g_InvD[g_ino].NoofVicons-2]], -1);
if (TinselV2)
- MultiSetAniXY(retObj[n], invX + TLwidth + eH + TRwidth + NM_SBL, invY + TLheight);
+ MultiSetAniXY(retObj[n], invX + g_TLwidth + eH + g_TRwidth + NM_SBL, invY + g_TLheight);
else
- MultiSetAniXY(retObj[n], invX + TLwidth + eH + M_SBL + 1, invY + TLheight);
+ MultiSetAniXY(retObj[n], invX + g_TLwidth + eH + M_SBL + 1, invY + g_TLheight);
MultiSetZPosition(retObj[n], zpos);
n++;
}
// Right side
- retObj[n] = AddObject(&pfilm->reels[vFillers[InvD[ino].NoofVicons-2]], -1);
- MultiSetAniXY(retObj[n], invX + TLwidth + eH + TRwidth + NM_RSX, invY + TLheight);
+ 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++;
}
- if (SuppV) {
- int offy = TLheight + eV - (TinselV2 ? ITEM_HEIGHT + I_SEPARATION : 26);
+ if (g_SuppV) {
+ int offy = g_TLheight + eV - (TinselV2 ? ITEM_HEIGHT + I_SEPARATION : 26);
int minAmount = TinselV2 ? 20 : 5;
if (offy < minAmount)
offy = minAmount;
@@ -3275,7 +3264,7 @@ static void ConstructInventory(InventoryType filling) {
// Right side extra
retObj[n] = AddObject(&pfilm->reels[IX_V26], -1);
- MultiSetAniXY(retObj[n], invX + TLwidth + eH + TRwidth + NM_RSX, invY + offy);
+ MultiSetAniXY(retObj[n], invX + g_TLwidth + eH + g_TRwidth + NM_RSX, invY + offy);
MultiSetZPosition(retObj[n], zpos);
n++;
}
@@ -3296,20 +3285,20 @@ static void ConstructInventory(InventoryType filling) {
AddBackground(rect, title, eH, eV, FROM_HANDLE);
}
- if (ino == INV_CONV) {
- SlideObject = NULL;
+ if (g_ino == INV_CONV) {
+ g_SlideObject = NULL;
if (TinselV2) {
// !!!!! MAGIC NUMBER ALERT !!!!!
// Make sure it's big enough for the heading
- if (MultiLeftmost(retObj[n-1]) < InvD[INV_CONV].inventoryX + 10) {
- InvD[INV_CONV].NoofHicons++;
+ if (MultiLeftmost(retObj[n-1]) < g_InvD[INV_CONV].inventoryX + 10) {
+ g_InvD[INV_CONV].NoofHicons++;
ConstructInventory(FULL);
}
}
- } else if (InvD[ino].NoofItems > InvD[ino].NoofHicons*InvD[ino].NoofVicons) {
- sliderYmin = TLheight - (TinselV2 ? 2 : 1);
- sliderYmax = TLheight + eV + (TinselV2 ? 12 : 10);
+ } else if (g_InvD[g_ino].NoofItems > g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons) {
+ g_sliderYmin = g_TLheight - (TinselV2 ? 2 : 1);
+ g_sliderYmax = g_TLheight + eV + (TinselV2 ? 12 : 10);
AddSlider(&retObj[n++], pfilm);
}
@@ -3333,7 +3322,7 @@ static void ConstructInventory(InventoryType filling) {
assert(n < MAX_WCOMP); // added more parts than we can handle!
// Reposition returns true if needs to move
- if (InvD[ino].bMoveable && filling == FULL && RePosition()) {
+ if (g_InvD[g_ino].bMoveable && filling == FULL && RePosition()) {
ConstructInventory(FULL);
}
}
@@ -3348,32 +3337,32 @@ static bool RePosition() {
int p;
bool bMoveitMoveit = false;
- assert(RectObject); // no recangle object!
+ assert(g_RectObject); // no recangle object!
// Test for off-screen horizontally
- p = MultiLeftmost(RectObject);
+ p = MultiLeftmost(g_RectObject);
if (p > MAXLEFT) {
// Too far to the right
- InvD[ino].inventoryX += MAXLEFT - p;
+ g_InvD[g_ino].inventoryX += MAXLEFT - p;
bMoveitMoveit = true; // I like to....
} else {
// Too far to the left?
- p = MultiRightmost(RectObject);
+ p = MultiRightmost(g_RectObject);
if (p < MINRIGHT) {
- InvD[ino].inventoryX += MINRIGHT - p;
+ g_InvD[g_ino].inventoryX += MINRIGHT - p;
bMoveitMoveit = true; // I like to....
}
}
// Test for off-screen vertically
- p = MultiHighest(RectObject);
+ p = MultiHighest(g_RectObject);
if (p < MINTOP) {
// Too high
- InvD[ino].inventoryY += MINTOP - p;
+ g_InvD[g_ino].inventoryY += MINTOP - p;
bMoveitMoveit = true; // I like to....
} else if (p > MAXTOP) {
// Too low
- InvD[ino].inventoryY += MAXTOP - p;
+ g_InvD[g_ino].inventoryY += MAXTOP - p;
bMoveitMoveit = true; // I like to....
}
@@ -3393,7 +3382,7 @@ static void AlterCursor(int num) {
IMAGE *pim;
// Get pointer to image
- pim = GetImageFromFilm(hWinParts, num, &pfreel);
+ pim = GetImageFromFilm(g_hWinParts, num, &pfreel);
// Poke in the background palette
pim->hImgPal = TO_LE_32(BgPal());
@@ -3414,7 +3403,7 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {
bool restoreMain = false;
// If currently dragging, don't be messing about with the cursor shape
- if (InvDragging != ID_NONE)
+ if (g_InvDragging != ID_NONE)
return;
switch (fn) {
@@ -3427,7 +3416,7 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {
area = InvArea(CurX, CurY);
// Check for POINTED events
- if (ino == INV_CONF)
+ if (g_ino == INV_CONF)
InvBoxes(area == I_BODY, CurX, CurY);
else
InvLabels(area == I_BODY, CurX, CurY);
@@ -3445,7 +3434,7 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {
case I_TLEFT:
case I_BRIGHT:
- if (!InvD[ino].resizable)
+ if (!g_InvD[g_ino].resizable)
restoreMain = true;
else if (ICursor != IC_DR) {
AlterCursor(IX_CURDD);
@@ -3455,7 +3444,7 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {
case I_TRIGHT:
case I_BLEFT:
- if (!InvD[ino].resizable)
+ if (!g_InvD[g_ino].resizable)
restoreMain = true;
else if (ICursor != IC_UR) {
AlterCursor(IX_CURDU);
@@ -3465,7 +3454,7 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {
case I_TOP:
case I_BOTTOM:
- if (!InvD[ino].resizable) {
+ if (!g_InvD[g_ino].resizable) {
restoreMain = true;
break;
}
@@ -3477,7 +3466,7 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {
case I_LEFT:
case I_RIGHT:
- if (!InvD[ino].resizable)
+ if (!g_InvD[g_ino].resizable)
restoreMain = true;
else if (ICursor != IC_LR) {
AlterCursor(IX_CURLR);
@@ -3516,7 +3505,7 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {
extern void ConvAction(int index) {
- assert(ino == INV_CONV); // not conv. window!
+ assert(g_ino == INV_CONV); // not conv. window!
PMOVER pMover = TinselV2 ? GetMover(GetLeadId()) : NULL;
switch (index) {
@@ -3524,36 +3513,36 @@ extern void ConvAction(int index) {
return;
case INV_CLOSEICON:
- 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)
- initialDirection = GetMoverDirection(pMover);
- thisIcon = -2; // Preamble
+ g_initialDirection = GetMoverDirection(pMover);
+ g_thisIcon = -2; // Preamble
break;
default:
- thisIcon = InvD[ino].contents[index];
+ g_thisIcon = g_InvD[g_ino].contents[index];
break;
}
if (!TinselV2)
- RunPolyTinselCode(thisConvPoly, CONVERSE, PLR_NOEVENT, true);
+ RunPolyTinselCode(g_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 != initialDirection) {
- SetMoverDirection(pMover, initialDirection);
+ if (currDirection != g_initialDirection) {
+ SetMoverDirection(pMover, g_initialDirection);
SetMoverStanding(pMover);
}
- if (thisConvPoly != NOPOLY)
- PolygonEvent(nullContext, thisConvPoly, CONVERSE, 0, false, 0);
+ if (g_thisConvPoly != NOPOLY)
+ PolygonEvent(nullContext, g_thisConvPoly, CONVERSE, 0, false, 0);
else
- ActorEvent(nullContext, thisConvActor, CONVERSE, false, 0);
+ ActorEvent(nullContext, g_thisConvActor, CONVERSE, false, 0);
}
}
@@ -3566,18 +3555,18 @@ 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) {
- thisConvFn = fn;
- thisConvPoly = hPoly;
- thisConvActor = ano;
+ g_thisConvFn = fn;
+ g_thisConvPoly = hPoly;
+ g_thisConvActor = ano;
- bMoveOnUnHide = true;
+ g_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, &InvD[INV_CONV].hInvTitle, &x, &y);
+ GetTagTag(hPoly, &g_InvD[INV_CONV].hInvTitle, &x, &y);
} else {
- InvD[INV_CONV].hInvTitle = GetActorTagHandle(ano);
+ g_InvD[INV_CONV].hInvTitle = GetActorTagHandle(ano);
}
}
@@ -3590,27 +3579,27 @@ extern void PermaConvIcon(int icon, bool bEnd) {
int i;
// See if it's already there
- for (i = 0; i < numPermIcons; i++) {
- if (permIcons[i] == icon)
+ for (i = 0; i < g_numPermIcons; i++) {
+ if (g_permIcons[i] == icon)
break;
}
// Add it if it isn't already there
- if (i == numPermIcons) {
- assert(numPermIcons < MAX_PERMICONS);
+ if (i == g_numPermIcons) {
+ assert(g_numPermIcons < MAX_PERMICONS);
- if (bEnd || !numEndIcons) {
+ if (bEnd || !g_numEndIcons) {
// Add it at the end
- permIcons[numPermIcons++] = icon;
+ g_permIcons[g_numPermIcons++] = icon;
if (bEnd)
- numEndIcons++;
+ g_numEndIcons++;
} else {
// Insert before end icons
- memmove(&permIcons[numPermIcons-numEndIcons+1],
- &permIcons[numPermIcons-numEndIcons],
- numEndIcons * sizeof(int));
- permIcons[numPermIcons-numEndIcons] = icon;
- numPermIcons++;
+ 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++;
}
}
}
@@ -3619,21 +3608,21 @@ extern void PermaConvIcon(int icon, bool bEnd) {
extern void convPos(int fn) {
if (fn == CONV_DEF)
- InvD[INV_CONV].inventoryY = 8;
+ g_InvD[INV_CONV].inventoryY = 8;
else if (fn == CONV_BOTTOM)
- InvD[INV_CONV].inventoryY = 150;
+ g_InvD[INV_CONV].inventoryY = 150;
}
extern void ConvPoly(HPOLYGON hPoly) {
- thisConvPoly = hPoly;
+ g_thisConvPoly = hPoly;
}
extern int GetIcon() {
- return thisIcon;
+ return g_thisIcon;
}
extern void CloseDownConv() {
- if (InventoryState == ACTIVE_INV && ino == INV_CONV) {
+ if (g_InventoryState == ACTIVE_INV && g_ino == INV_CONV) {
KillInventory();
}
}
@@ -3642,43 +3631,43 @@ extern void HideConversation(bool bHide) {
int aniX, aniY;
int i;
- if (InventoryState == ACTIVE_INV && ino == INV_CONV) {
+ if (g_InventoryState == ACTIVE_INV && g_ino == INV_CONV) {
if (bHide) {
// Move all the window and icons off-screen
- for (i = 0; objArray[i] && i < MAX_WCOMP; i++) {
- MultiAdjustXY(objArray[i], 2 * SCREEN_WIDTH, 0);
+ for (i = 0; g_objArray[i] && i < MAX_WCOMP; i++) {
+ MultiAdjustXY(g_objArray[i], 2 * SCREEN_WIDTH, 0);
}
- for (i = 0; iconArray[i] && i < MAX_ICONS; i++) {
- MultiAdjustXY(iconArray[i], 2 * SCREEN_WIDTH, 0);
+ for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) {
+ MultiAdjustXY(g_iconArray[i], 2 * SCREEN_WIDTH, 0);
}
// Window is hidden
- InventoryHidden = true;
+ g_InventoryHidden = true;
// Remove any labels
InvLabels(false, 0, 0);
} else {
// Window is not hidden
- InventoryHidden = false;
+ g_InventoryHidden = false;
- if (TinselV2 && ItemsChanged)
+ if (TinselV2 && g_ItemsChanged)
// Just rebuild the whole thing
ConstructInventory(FULL);
else {
// Move it all back on-screen
- for (i = 0; objArray[i] && i < MAX_WCOMP; i++) {
- MultiAdjustXY(objArray[i], -2 * SCREEN_WIDTH, 0);
+ for (i = 0; g_objArray[i] && i < MAX_WCOMP; i++) {
+ MultiAdjustXY(g_objArray[i], -2 * SCREEN_WIDTH, 0);
}
// Don't flash if items changed. If they have, will be redrawn anyway.
- if (TinselV2 || !ItemsChanged) {
- for (i = 0; iconArray[i] && i < MAX_ICONS; i++) {
- MultiAdjustXY(iconArray[i], -2*SCREEN_WIDTH, 0);
+ if (TinselV2 || !g_ItemsChanged) {
+ for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) {
+ MultiAdjustXY(g_iconArray[i], -2*SCREEN_WIDTH, 0);
}
}
}
- if (TinselV2 && bMoveOnUnHide) {
+ if (TinselV2 && g_bMoveOnUnHide) {
/*
* First time, position it appropriately
*/
@@ -3686,17 +3675,17 @@ extern void HideConversation(bool bHide) {
int x, y, deltay;
// Only do it once per conversation
- bMoveOnUnHide = false;
+ g_bMoveOnUnHide = false;
// Current center of the window
- left = MultiLeftmost(RectObject);
- center = (MultiRightmost(RectObject) + left) / 2;
+ left = MultiLeftmost(g_RectObject);
+ center = (MultiRightmost(g_RectObject) + left) / 2;
// Get the x-offset for the conversation window
- if (thisConvActor) {
+ if (g_thisConvActor) {
int Loffset, Toffset;
- GetActorMidTop(thisConvActor, &x, &y);
+ GetActorMidTop(g_thisConvActor, &x, &y);
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
x -= Loffset;
y -= Toffset;
@@ -3706,19 +3695,19 @@ extern void HideConversation(bool bHide) {
}
// Save old y-position
- deltay = InvD[INV_CONV].inventoryY;
+ deltay = g_InvD[INV_CONV].inventoryY;
- switch (thisConvFn) {
+ switch (g_thisConvFn) {
case CONV_TOP:
- InvD[INV_CONV].inventoryY = SysVar(SV_CONV_TOPY);
+ g_InvD[INV_CONV].inventoryY = SysVar(SV_CONV_TOPY);
break;
case CONV_BOTTOM:
- InvD[INV_CONV].inventoryY = SysVar(SV_CONV_BOTY);
+ g_InvD[INV_CONV].inventoryY = SysVar(SV_CONV_BOTY);
break;
case CONV_DEF:
- InvD[INV_CONV].inventoryY = y - SysVar(SV_CONV_ABOVE_Y);
+ g_InvD[INV_CONV].inventoryY = y - SysVar(SV_CONV_ABOVE_Y);
break;
default:
@@ -3726,34 +3715,34 @@ extern void HideConversation(bool bHide) {
}
// Calculate y change
- deltay = InvD[INV_CONV].inventoryY - deltay;
+ deltay = g_InvD[INV_CONV].inventoryY - deltay;
// Move it all
- for (i = 0; objArray[i] && i < MAX_WCOMP; i++) {
- MultiMoveRelXY(objArray[i], x - center, deltay);
+ for (i = 0; g_objArray[i] && i < MAX_WCOMP; i++) {
+ MultiMoveRelXY(g_objArray[i], x - center, deltay);
}
- for (i = 0; iconArray[i] && i < MAX_ICONS; i++) {
- MultiMoveRelXY(iconArray[i], x - center, deltay);
+ for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) {
+ MultiMoveRelXY(g_iconArray[i], x - center, deltay);
}
- InvD[INV_CONV].inventoryX += x - center;
+ g_InvD[INV_CONV].inventoryX += x - center;
/*
* Now positioned as worked out
* - but it must be in a sensible place
*/
- 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);
+ 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);
else
x = 0;
- if (thisConvFn == CONV_DEF && MultiHighest(RectObject) < SysVar(SV_CONV_MINY)
- && thisConvActor) {
+ if (g_thisConvFn == CONV_DEF && MultiHighest(g_RectObject) < SysVar(SV_CONV_MINY)
+ && g_thisConvActor) {
int Loffset, Toffset;
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
- y = GetActorBottom(thisConvActor) - MultiHighest(RectObject) +
+ y = GetActorBottom(g_thisConvActor) - MultiHighest(g_RectObject) +
SysVar(SV_CONV_BELOW_Y);
y -= Toffset;
}
@@ -3761,28 +3750,28 @@ extern void HideConversation(bool bHide) {
y = 0;
if (x || y) {
- for (i = 0; objArray[i] && i < MAX_WCOMP; i++) {
- MultiMoveRelXY(objArray[i], x, y);
+ for (i = 0; g_objArray[i] && i < MAX_WCOMP; i++) {
+ MultiMoveRelXY(g_objArray[i], x, y);
}
- for (i = 0; iconArray[i] && i < MAX_ICONS; i++) {
- MultiMoveRelXY(iconArray[i], x, y);
+ for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) {
+ MultiMoveRelXY(g_iconArray[i], x, y);
}
- InvD[INV_CONV].inventoryX += x;
- InvD[INV_CONV].inventoryY += y;
+ g_InvD[INV_CONV].inventoryX += x;
+ g_InvD[INV_CONV].inventoryY += y;
}
/*
* Oh shit! We might have gone off the bottom
*/
- if (MultiLowest(RectObject) > SCREEN_BOX_HEIGHT2 - SysVar(SV_CONV_MINY)) {
- y = (SCREEN_BOX_HEIGHT2 - SysVar(SV_CONV_MINY)) - MultiLowest(RectObject);
- for (i = 0; objArray[i] && i < MAX_WCOMP; i++) {
- MultiMoveRelXY(objArray[i], 0, y);
+ 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; g_objArray[i] && i < MAX_WCOMP; i++) {
+ MultiMoveRelXY(g_objArray[i], 0, y);
}
- for (i = 0; iconArray[i] && i < MAX_ICONS; i++) {
- MultiMoveRelXY(iconArray[i], 0, y);
+ for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) {
+ MultiMoveRelXY(g_iconArray[i], 0, y);
}
- InvD[INV_CONV].inventoryY += y;
+ g_InvD[INV_CONV].inventoryY += y;
}
}
@@ -3793,7 +3782,7 @@ extern void HideConversation(bool bHide) {
}
extern bool ConvIsHidden() {
- return InventoryHidden;
+ return g_InventoryHidden;
}
@@ -3808,8 +3797,8 @@ 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
- if (InventoryState == IDLE_INV) {
- bReOpenMenu = false; // Better safe than sorry...
+ if (g_InventoryState == IDLE_INV) {
+ g_bReOpenMenu = false; // Better safe than sorry...
DisableTags(); // Tags disabled during inventory
if (TinselV2)
@@ -3821,25 +3810,25 @@ extern void PopUpInventory(int invno) {
_vm->_pcmMusic->dim(false);
// Start conversation with permanent contents
- memset(InvD[INV_CONV].contents, 0, MAX_ININV*sizeof(int));
- memcpy(InvD[INV_CONV].contents, permIcons, numPermIcons*sizeof(int));
- InvD[INV_CONV].NoofItems = numPermIcons;
+ 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)
- InvD[INV_CONV].NoofHicons = numPermIcons;
+ g_InvD[INV_CONV].NoofHicons = g_numPermIcons;
else
- thisIcon = 0;
+ g_thisIcon = 0;
} else if (invno == INV_CONF) { // Configuration window?
cd.selBox = NOBOX;
cd.pointBox = NOBOX;
}
- ino = invno; // The open inventory
+ g_ino = invno; // The open inventory
- ItemsChanged = false; // Nothing changed
- InvDragging = ID_NONE; // Not dragging
- InventoryState = ACTIVE_INV; // Inventory actiive
- InventoryHidden = false; // Not hidden
- InventoryMaximised = InvD[ino].bMax;
+ 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
else {
@@ -3849,10 +3838,10 @@ extern void PopUpInventory(int invno) {
}
static void SetMenuGlobals(CONFINIT *ci) {
- 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;
+ 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;
cd.bExtraWin = ci->bExtraWin;
cd.box = ci->Box;
cd.NumBoxes = ci->NumBoxes;
@@ -3860,9 +3849,9 @@ static void SetMenuGlobals(CONFINIT *ci) {
if (TinselV2) {
if ((ci->ixHeading != NO_HEADING) && SysString(ci->ixHeading))
- InvD[INV_MENU].hInvTitle = SysString(ci->ixHeading);
+ g_InvD[INV_MENU].hInvTitle = SysString(ci->ixHeading);
else
- InvD[INV_MENU].hInvTitle = NO_HEADING;
+ g_InvD[INV_MENU].hInvTitle = NO_HEADING;
}
}
@@ -3876,11 +3865,11 @@ extern void OpenMenu(CONFTYPE menuType) {
if (TinselV0)
return;
- if (InventoryState != IDLE_INV)
+ if (g_InventoryState != IDLE_INV)
return;
- InvD[INV_CONF].resizable = false;
- InvD[INV_CONF].bMoveable = false;
+ g_InvD[INV_CONF].resizable = false;
+ g_InvD[INV_CONF].bMoveable = false;
switch (menuType) {
case MAIN_MENU:
@@ -3915,7 +3904,7 @@ extern void OpenMenu(CONFTYPE menuType) {
case SOUND_MENU:
if (TinselV2)
- displayedLanguage = TextLanguage();
+ g_displayedLanguage = TextLanguage();
#if 1
// FIXME: Hack to setup CONFBOX pointer to data in the global Config object
if (TinselV2) {
@@ -4003,16 +3992,16 @@ extern void OpenMenu(CONFTYPE menuType) {
case TOP_WINDOW:
SetMenuGlobals(&ciTopWin);
- ino = INV_CONF;
+ g_ino = INV_CONF;
ConstructInventory(CONF); // Draw it up
- InventoryState = BOGUS_INV;
+ g_InventoryState = BOGUS_INV;
return;
default:
return;
}
- if (HeldItem != INV_NOICON)
+ if (g_heldItem != INV_NOICON)
DelAuxCursor(); // no longer aux cursor
PopUpInventory(INV_CONF);
@@ -4045,38 +4034,38 @@ extern void OpenMenu(CONFTYPE menuType) {
* Close down an inventory window.
*/
extern void KillInventory() {
- if (objArray[0] != NULL) {
+ if (g_objArray[0] != NULL) {
DumpObjArray();
DumpDobjArray();
DumpIconArray();
}
- if (InventoryState == ACTIVE_INV) {
+ if (g_InventoryState == ACTIVE_INV) {
EnableTags();
if (TinselV2)
EnablePointing();
- InvD[ino].bMax = InventoryMaximised;
+ g_InvD[g_ino].bMax = g_InventoryMaximised;
UnHideCursorTrails();
_vm->divertKeyInput(NULL);
}
- InventoryState = IDLE_INV;
+ g_InventoryState = IDLE_INV;
- if (bReOpenMenu) {
- bReOpenMenu = false;
+ if (g_bReOpenMenu) {
+ g_bReOpenMenu = false;
OpenMenu(MAIN_MENU);
// Write config changes
_vm->_config->writeToDisk();
- } else if (ino == INV_CONF)
+ } else if (g_ino == INV_CONF)
InventoryIconCursor(false);
if (TinselV2)
// Pump up the volume
- if (ino == INV_CONV)
+ if (g_ino == INV_CONV)
_vm->_pcmMusic->unDim(false);
g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); // Hide VK after save dialog closes
@@ -4084,15 +4073,15 @@ extern void KillInventory() {
extern void CloseInventory() {
// If not active, ignore this
- if (InventoryState != ACTIVE_INV)
+ if (g_InventoryState != ACTIVE_INV)
return;
// If hidden, a conversation action is still underway - ignore this
- if (InventoryHidden)
+ if (g_InventoryHidden)
return;
// If conversation, this is a closeing event
- if (ino == INV_CONV)
+ if (g_ino == INV_CONV)
ConvAction(INV_CLOSEICON);
KillInventory();
@@ -4117,13 +4106,13 @@ extern void InventoryProcess(CORO_PARAM, const void *) {
CORO_BEGIN_CODE(_ctx);
if (NumberOfLanguages() <= 1)
- bNoLanguage = true;
+ g_bNoLanguage = true;
while (1) {
CORO_SLEEP(1); // allow scheduling
- if (objArray[0] != NULL) {
- if (ItemsChanged && ino != INV_CONF && !InventoryHidden) {
+ if (g_objArray[0] != NULL) {
+ if (g_ItemsChanged && g_ino != INV_CONF && !g_InventoryHidden) {
FillInInventory();
// Needed when clicking on scroll bar.
@@ -4131,15 +4120,15 @@ extern void InventoryProcess(CORO_PARAM, const void *) {
GetCursorXY(&curX, &curY, false);
InvCursor(IC_AREA, curX, curY);
- ItemsChanged = false;
+ g_ItemsChanged = false;
}
- if (ino != INV_CONF) {
+ if (g_ino != INV_CONF) {
for (int i = 0; i < MAX_ICONS; i++) {
- if (iconArray[i] != NULL)
- StepAnimScript(&iconAnims[i]);
+ if (g_iconArray[i] != NULL)
+ StepAnimScript(&g_iconAnims[i]);
}
}
- if (InvDragging == ID_MDCONT) {
+ if (g_InvDragging == ID_MDCONT) {
// Mixing desk control
int sval, index, *pival;
@@ -4263,12 +4252,12 @@ static int NearestSlideY(int fity) {
int i = 0;
do {
- thisDist = ABS(slideStuff[i].y - fity);
+ thisDist = ABS(g_slideStuff[i].y - fity);
if (thisDist < nearDist) {
nearDist = thisDist;
nearI = i;
}
- } while (slideStuff[++i].n != -1);
+ } while (g_slideStuff[++i].n != -1);
return nearI;
}
@@ -4281,44 +4270,44 @@ static void SlideSlider(int y, SSFN fn) {
int gotoY, ati;
// Only do this if there's a slider
- if (!SlideObject)
+ if (!g_SlideObject)
return;
switch (fn) {
case S_START: // Start of a drag on the slider
- newY = sliderYpos;
- lasti = NearestSlideY(sliderYpos);
+ newY = g_sliderYpos;
+ lasti = NearestSlideY(g_sliderYpos);
break;
case S_SLIDE: // Y-movement during drag
newY = newY + y; // New y-position
- if (newY < sliderYmin)
- gotoY = sliderYmin; // Above top limit
- else if (newY > sliderYmax)
- gotoY = sliderYmax; // Below bottom limit
+ if (newY < g_sliderYmin)
+ gotoY = g_sliderYmin; // Above top limit
+ else if (newY > g_sliderYmax)
+ gotoY = g_sliderYmax; // Below bottom limit
else
gotoY = newY; // Hunky-Dory
// Move slider to new position
- MultiMoveRelXY(SlideObject, 0, gotoY - sliderYpos);
- sliderYpos = gotoY;
+ MultiMoveRelXY(g_SlideObject, 0, gotoY - g_sliderYpos);
+ g_sliderYpos = gotoY;
// Re-draw icons if necessary
- ati = NearestSlideY(sliderYpos);
+ ati = NearestSlideY(g_sliderYpos);
if (ati != lasti) {
- InvD[ino].FirstDisp = slideStuff[ati].n;
- assert(InvD[ino].FirstDisp >= 0); // negative first displayed
- ItemsChanged = true;
+ g_InvD[g_ino].FirstDisp = g_slideStuff[ati].n;
+ assert(g_InvD[g_ino].FirstDisp >= 0); // negative first displayed
+ g_ItemsChanged = true;
lasti = ati;
}
break;
case S_END: // End of a drag on the slider
// Draw icons from new start icon
- ati = NearestSlideY(sliderYpos);
- InvD[ino].FirstDisp = slideStuff[ati].n;
- ItemsChanged = true;
+ ati = NearestSlideY(g_sliderYpos);
+ g_InvD[g_ino].FirstDisp = g_slideStuff[ati].n;
+ g_ItemsChanged = true;
break;
default:
@@ -4336,38 +4325,38 @@ static void SlideCSlider(int y, SSFN fn) {
int fc;
// Only do this if there's a slider
- if (!SlideObject)
+ if (!g_SlideObject)
return;
switch (fn) {
case S_START: // Start of a drag on the slider
- newY = sliderYpos;
+ newY = g_sliderYpos;
break;
case S_SLIDE: // Y-movement during drag
newY = newY + y; // New y-position
- if (newY < sliderYmin)
- gotoY = sliderYmin; // Above top limit
- else if (newY > sliderYmax)
- gotoY = sliderYmax; // Below bottom limit
+ if (newY < g_sliderYmin)
+ gotoY = g_sliderYmin; // Above top limit
+ else if (newY > g_sliderYmax)
+ gotoY = g_sliderYmax; // Below bottom limit
else
gotoY = newY; // Hunky-Dory
// Move slider to new position
if (TinselV2)
- MultiMoveRelXY(SlideObject, 0, gotoY - sliderYpos);
- sliderYpos = gotoY;
+ MultiMoveRelXY(g_SlideObject, 0, gotoY - g_sliderYpos);
+ g_sliderYpos = gotoY;
fc = cd.extraBase;
if ((cd.box == saveBox || cd.box == loadBox))
- FirstFile((sliderYpos - sliderYmin) * (MAX_SAVED_FILES - NUM_RGROUP_BOXES) /
- (sliderYmax - sliderYmin));
+ FirstFile((g_sliderYpos - g_sliderYmin) * (MAX_SAVED_FILES - NUM_RGROUP_BOXES) /
+ (g_sliderYmax - g_sliderYmin));
else if (cd.box == hopperBox1)
- FirstScene((sliderYpos - sliderYmin) * (numScenes - NUM_RGROUP_BOXES) / sliderRange);
+ FirstScene((g_sliderYpos - g_sliderYmin) * (g_numScenes - NUM_RGROUP_BOXES) / sliderRange);
else if (cd.box == hopperBox2)
- FirstEntry((sliderYpos - sliderYmin) * (numEntries - NUM_RGROUP_BOXES) / sliderRange);
+ FirstEntry((g_sliderYpos - g_sliderYmin) * (g_numEntries - NUM_RGROUP_BOXES) / sliderRange);
// If extraBase has changed...
if (fc != cd.extraBase) {
@@ -4409,16 +4398,16 @@ static void SlideMSlider(int x, SSFN fn) {
// Work out the indices
index = cd.selBox & ~IS_MASK;
- for (i = 0; i < numMdSlides; i++)
- if (mdSlides[i].num == index)
+ for (i = 0; i < g_numMdSlides; i++)
+ if (g_mdSlides[i].num == index)
break;
- assert(i < numMdSlides);
+ assert(i < g_numMdSlides);
switch (fn) {
case S_START: // Start of a drag on the slider
// can use index as a throw-away value
- GetAniPosition(mdSlides[i].obj, &newX, &index);
- lX = sX = newX;
+ GetAniPosition(g_mdSlides[i].obj, &newX, &index);
+ g_lX = g_sX = newX;
break;
case S_SLIDE: // X-movement during drag
@@ -4427,19 +4416,19 @@ static void SlideMSlider(int x, SSFN fn) {
newX = newX + x; // New x-position
- 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
+ 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
else
gotoX = newX; // Hunky-Dory
// Move slider to new position
- MultiMoveRelXY(mdSlides[i].obj, gotoX - sX, 0);
- sX = gotoX;
+ MultiMoveRelXY(g_mdSlides[i].obj, gotoX - g_sX, 0);
+ g_sX = gotoX;
- if (lX != sX) {
- *cd.box[index].ival = (sX - mdSlides[i].min)*cd.box[index].w/SLIDE_RANGE;
+ if (g_lX != g_sX) {
+ *cd.box[index].ival = (g_sX - g_mdSlides[i].min)*cd.box[index].w/SLIDE_RANGE;
if (cd.box[index].boxFunc == MUSICVOL)
SetMidiVolume(*cd.box[index].ival);
#ifdef MAC_OPTIONS
@@ -4449,14 +4438,14 @@ static void SlideMSlider(int x, SSFN fn) {
if (cd.box[index].boxFunc == SAMPVOL)
SetSampleVolume(*cd.box[index].ival);
#endif
- lX = sX;
+ g_lX = g_sX;
}
break;
case S_TIMEUP:
case S_TIMEDN:
gotoX = SLIDE_RANGE*(*cd.box[index].ival)/cd.box[index].w;
- MultiSetAniX(mdSlides[i].obj, mdSlides[i].min+gotoX);
+ MultiSetAniX(g_mdSlides[i].obj, g_mdSlides[i].min+gotoX);
if (cd.box[index].boxFunc == MUSICVOL)
SetMidiVolume(*cd.box[index].ival);
@@ -4471,7 +4460,7 @@ static void SlideMSlider(int x, SSFN fn) {
case S_END: // End of a drag on the slider
AddBoxes(false); // Might change position slightly
- if (ino == INV_CONF && cd.box == subtitlesBox)
+ if (g_ino == INV_CONF && cd.box == subtitlesBox)
Select(_vm->_config->_language, false);
break;
}
@@ -4481,23 +4470,23 @@ static void SlideMSlider(int x, SSFN fn) {
* Called from ChangeingSize() during re-sizing.
*/
static void GettingTaller() {
- if (SuppV) {
- Ychange += SuppV;
- if (Ycompensate == 'T')
- InvD[ino].inventoryY += SuppV;
- SuppV = 0;
+ if (g_SuppV) {
+ g_Ychange += g_SuppV;
+ if (g_Ycompensate == 'T')
+ g_InvD[g_ino].inventoryY += g_SuppV;
+ g_SuppV = 0;
}
- while (Ychange > (ITEM_HEIGHT+1) && InvD[ino].NoofVicons < InvD[ino].MaxVicons) {
- Ychange -= (ITEM_HEIGHT+1);
- InvD[ino].NoofVicons++;
- if (Ycompensate == 'T')
- InvD[ino].inventoryY -= (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);
}
- if (InvD[ino].NoofVicons < InvD[ino].MaxVicons) {
- SuppV = Ychange;
- Ychange = 0;
- if (Ycompensate == 'T')
- InvD[ino].inventoryY -= SuppV;
+ 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;
}
}
@@ -4505,73 +4494,73 @@ static void GettingTaller() {
* Called from ChangeingSize() during re-sizing.
*/
static void GettingShorter() {
- int StartNvi = InvD[ino].NoofVicons;
- int StartUv = SuppV;
+ int StartNvi = g_InvD[g_ino].NoofVicons;
+ int StartUv = g_SuppV;
- if (SuppV) {
- Ychange += (SuppV - (ITEM_HEIGHT+1));
- InvD[ino].NoofVicons++;
- SuppV = 0;
+ if (g_SuppV) {
+ g_Ychange += (g_SuppV - (ITEM_HEIGHT+1));
+ g_InvD[g_ino].NoofVicons++;
+ g_SuppV = 0;
}
- while (Ychange < -(ITEM_HEIGHT+1) && InvD[ino].NoofVicons > InvD[ino].MinVicons) {
- Ychange += (ITEM_HEIGHT+1);
- InvD[ino].NoofVicons--;
+ 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 (InvD[ino].NoofVicons > InvD[ino].MinVicons && Ychange) {
- SuppV = (ITEM_HEIGHT+1) + Ychange;
- InvD[ino].NoofVicons--;
- Ychange = 0;
+ 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 (Ycompensate == 'T')
- InvD[ino].inventoryY += (ITEM_HEIGHT+1)*(StartNvi - InvD[ino].NoofVicons) - (SuppV - StartUv);
+ if (g_Ycompensate == 'T')
+ 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() {
- int StartNhi = InvD[ino].NoofHicons;
- int StartUh = SuppH;
+ int StartNhi = g_InvD[g_ino].NoofHicons;
+ int StartUh = g_SuppH;
- if (SuppH) {
- Xchange += SuppH;
- SuppH = 0;
+ if (g_SuppH) {
+ g_Xchange += g_SuppH;
+ g_SuppH = 0;
}
- while (Xchange > (ITEM_WIDTH+1) && InvD[ino].NoofHicons < InvD[ino].MaxHicons) {
- Xchange -= (ITEM_WIDTH+1);
- InvD[ino].NoofHicons++;
+ 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 (InvD[ino].NoofHicons < InvD[ino].MaxHicons) {
- SuppH = Xchange;
- Xchange = 0;
+ if (g_InvD[g_ino].NoofHicons < g_InvD[g_ino].MaxHicons) {
+ g_SuppH = g_Xchange;
+ g_Xchange = 0;
}
- if (Xcompensate == 'L')
- InvD[ino].inventoryX += (ITEM_WIDTH+1)*(StartNhi - InvD[ino].NoofHicons) - (SuppH - StartUh);
+ if (g_Xcompensate == 'L')
+ 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() {
- int StartNhi = InvD[ino].NoofHicons;
- int StartUh = SuppH;
+ int StartNhi = g_InvD[g_ino].NoofHicons;
+ int StartUh = g_SuppH;
- if (SuppH) {
- Xchange += (SuppH - (ITEM_WIDTH+1));
- InvD[ino].NoofHicons++;
- SuppH = 0;
+ if (g_SuppH) {
+ g_Xchange += (g_SuppH - (ITEM_WIDTH+1));
+ g_InvD[g_ino].NoofHicons++;
+ g_SuppH = 0;
}
- while (Xchange < -(ITEM_WIDTH+1) && InvD[ino].NoofHicons > InvD[ino].MinHicons) {
- Xchange += (ITEM_WIDTH+1);
- InvD[ino].NoofHicons--;
+ 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 (InvD[ino].NoofHicons > InvD[ino].MinHicons && Xchange) {
- SuppH = (ITEM_WIDTH+1) + Xchange;
- InvD[ino].NoofHicons--;
- Xchange = 0;
+ 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 (Xcompensate == 'L')
- InvD[ino].inventoryX += (ITEM_WIDTH+1)*(StartNhi - InvD[ino].NoofHicons) - (SuppH - StartUh);
+ if (g_Xcompensate == 'L')
+ g_InvD[g_ino].inventoryX += (ITEM_WIDTH+1)*(StartNhi - g_InvD[g_ino].NoofHicons) - (g_SuppH - StartUh);
}
@@ -4580,15 +4569,15 @@ static void GettingNarrower() {
*/
static void ChangeingSize() {
/* Make it taller or shorter if necessary. */
- if (Ychange > 0)
+ if (g_Ychange > 0)
GettingTaller();
- else if (Ychange < 0)
+ else if (g_Ychange < 0)
GettingShorter();
/* Make it wider or narrower if necessary. */
- if (Xchange > 0)
+ if (g_Xchange > 0)
GettingWider();
- else if (Xchange < 0)
+ else if (g_Xchange < 0)
GettingNarrower();
ConstructInventory(EMPTY);
@@ -4601,29 +4590,29 @@ extern void Xmovement(int x) {
int aniX, aniY;
int i;
- if (x && objArray[0] != NULL) {
- switch (InvDragging) {
+ if (x && g_objArray[0] != NULL) {
+ switch (g_InvDragging) {
case ID_MOVE:
- GetAniPosition(objArray[0], &InvD[ino].inventoryX, &aniY);
- InvD[ino].inventoryX +=x;
- MultiSetAniX(objArray[0], InvD[ino].inventoryX);
- for (i = 1; objArray[i] && i < MAX_WCOMP; i++)
- MultiMoveRelXY(objArray[i], x, 0);
- for (i = 0; iconArray[i] && i < MAX_ICONS; i++)
- MultiMoveRelXY(iconArray[i], x, 0);
+ 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; g_objArray[i] && i < MAX_WCOMP; i++)
+ MultiMoveRelXY(g_objArray[i], x, 0);
+ for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++)
+ MultiMoveRelXY(g_iconArray[i], x, 0);
break;
case ID_LEFT:
case ID_TLEFT:
case ID_BLEFT:
- Xchange -= x;
+ g_Xchange -= x;
ChangeingSize();
break;
case ID_RIGHT:
case ID_TRIGHT:
case ID_BRIGHT:
- Xchange += x;
+ g_Xchange += x;
ChangeingSize();
break;
@@ -4649,16 +4638,16 @@ extern void Ymovement(int y) {
int aniX, aniY;
int i;
- if (y && objArray[0] != NULL) {
- switch (InvDragging) {
+ if (y && g_objArray[0] != NULL) {
+ switch (g_InvDragging) {
case ID_MOVE:
- GetAniPosition(objArray[0], &aniX, &InvD[ino].inventoryY);
- InvD[ino].inventoryY +=y;
- MultiSetAniY(objArray[0], InvD[ino].inventoryY);
- for (i = 1; objArray[i] && i < MAX_WCOMP; i++)
- MultiMoveRelXY(objArray[i], 0, y);
- for (i = 0; iconArray[i] && i < MAX_ICONS; i++)
- MultiMoveRelXY(iconArray[i], 0, y);
+ 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; g_objArray[i] && i < MAX_WCOMP; i++)
+ MultiMoveRelXY(g_objArray[i], 0, y);
+ for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++)
+ MultiMoveRelXY(g_iconArray[i], 0, y);
break;
case ID_SLIDE:
@@ -4672,14 +4661,14 @@ extern void Ymovement(int y) {
case ID_BOTTOM:
case ID_BLEFT:
case ID_BRIGHT:
- Ychange += y;
+ g_Ychange += y;
ChangeingSize();
break;
case ID_TOP:
case ID_TLEFT:
case ID_TRIGHT:
- Ychange -= y;
+ g_Ychange -= y;
ChangeingSize();
break;
@@ -4705,16 +4694,16 @@ static void InvDragStart() {
/*
* Do something different for Save/Restore screens
*/
- if (ino == INV_CONF) {
+ if (g_ino == INV_CONF) {
int whichbox;
whichbox = WhichMenuBox(curX, curY, true);
if (whichbox == IB_SLIDE) {
- InvDragging = ID_CSLIDE;
+ g_InvDragging = ID_CSLIDE;
SlideCSlider(0, S_START);
} else if (whichbox > 0 && (whichbox & IS_MASK)) {
- InvDragging = ID_MDCONT; // Mixing desk control
+ g_InvDragging = ID_MDCONT; // Mixing desk control
cd.selBox = whichbox;
SlideMSlider(0, S_START);
}
@@ -4726,85 +4715,85 @@ static void InvDragStart() {
*/
switch (InvArea(curX, curY)) {
case I_HEADER:
- if (InvD[ino].bMoveable) {
- InvDragging = ID_MOVE;
+ if (g_InvD[g_ino].bMoveable) {
+ g_InvDragging = ID_MOVE;
}
break;
case I_SLIDE:
- InvDragging = ID_SLIDE;
+ g_InvDragging = ID_SLIDE;
SlideSlider(0, S_START);
break;
case I_BOTTOM:
- if (InvD[ino].resizable) {
- Ychange = 0;
- InvDragging = ID_BOTTOM;
- Ycompensate = 'B';
+ if (g_InvD[g_ino].resizable) {
+ g_Ychange = 0;
+ g_InvDragging = ID_BOTTOM;
+ g_Ycompensate = 'B';
}
break;
case I_TOP:
- if (InvD[ino].resizable) {
- Ychange = 0;
- InvDragging = ID_TOP;
- Ycompensate = 'T';
+ if (g_InvD[g_ino].resizable) {
+ g_Ychange = 0;
+ g_InvDragging = ID_TOP;
+ g_Ycompensate = 'T';
}
break;
case I_LEFT:
- if (InvD[ino].resizable) {
- Xchange = 0;
- InvDragging = ID_LEFT;
- Xcompensate = 'L';
+ if (g_InvD[g_ino].resizable) {
+ g_Xchange = 0;
+ g_InvDragging = ID_LEFT;
+ g_Xcompensate = 'L';
}
break;
case I_RIGHT:
- if (InvD[ino].resizable) {
- Xchange = 0;
- InvDragging = ID_RIGHT;
- Xcompensate = 'R';
+ if (g_InvD[g_ino].resizable) {
+ g_Xchange = 0;
+ g_InvDragging = ID_RIGHT;
+ g_Xcompensate = 'R';
}
break;
case I_TLEFT:
- if (InvD[ino].resizable) {
- Ychange = 0;
- Ycompensate = 'T';
- Xchange = 0;
- Xcompensate = 'L';
- InvDragging = ID_TLEFT;
+ if (g_InvD[g_ino].resizable) {
+ g_Ychange = 0;
+ g_Ycompensate = 'T';
+ g_Xchange = 0;
+ g_Xcompensate = 'L';
+ g_InvDragging = ID_TLEFT;
}
break;
case I_TRIGHT:
- if (InvD[ino].resizable) {
- Ychange = 0;
- Ycompensate = 'T';
- Xchange = 0;
- Xcompensate = 'R';
- InvDragging = ID_TRIGHT;
+ if (g_InvD[g_ino].resizable) {
+ g_Ychange = 0;
+ g_Ycompensate = 'T';
+ g_Xchange = 0;
+ g_Xcompensate = 'R';
+ g_InvDragging = ID_TRIGHT;
}
break;
case I_BLEFT:
- if (InvD[ino].resizable) {
- Ychange = 0;
- Ycompensate = 'B';
- Xchange = 0;
- Xcompensate = 'L';
- InvDragging = ID_BLEFT;
+ if (g_InvD[g_ino].resizable) {
+ g_Ychange = 0;
+ g_Ycompensate = 'B';
+ g_Xchange = 0;
+ g_Xcompensate = 'L';
+ g_InvDragging = ID_BLEFT;
}
break;
case I_BRIGHT:
- if (InvD[ino].resizable) {
- Ychange = 0;
- Ycompensate = 'B';
- Xchange = 0;
- Xcompensate = 'R';
- InvDragging = ID_BRIGHT;
+ if (g_InvD[g_ino].resizable) {
+ g_Ychange = 0;
+ g_Ycompensate = 'B';
+ g_Xchange = 0;
+ g_Xcompensate = 'R';
+ g_InvDragging = ID_BRIGHT;
}
break;
}
@@ -4818,14 +4807,14 @@ static void InvDragEnd() {
GetCursorXY(&curX, &curY, false);
- if (InvDragging != ID_NONE) {
- if (InvDragging == ID_SLIDE) {
+ if (g_InvDragging != ID_NONE) {
+ if (g_InvDragging == ID_SLIDE) {
SlideSlider(0, S_END);
- } else if (InvDragging == ID_CSLIDE) {
+ } else if (g_InvDragging == ID_CSLIDE) {
; // No action
- } else if (InvDragging == ID_MDCONT) {
+ } else if (g_InvDragging == ID_MDCONT) {
SlideMSlider(0, S_END);
- } else if (InvDragging == ID_MOVE) {
+ } else if (g_InvDragging == ID_MOVE) {
; // No action
} else {
// Were re-sizing. Redraw the whole thing.
@@ -4834,21 +4823,21 @@ static void InvDragEnd() {
ConstructInventory(FULL);
// If this was the maximised, it no longer is!
- if (InventoryMaximised) {
- InventoryMaximised = false;
- InvD[ino].otherX = InvD[ino].inventoryX;
- InvD[ino].otherY = InvD[ino].inventoryY;
+ 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;
}
}
- InvDragging = ID_NONE;
+ g_InvDragging = ID_NONE;
ProcessedProvisional();
}
// Cursor could well now be inappropriate
InvCursor(IC_AREA, curX, curY);
- Xchange = Ychange = 0; // Probably no need, but does no harm!
+ g_Xchange = g_Ychange = 0; // Probably no need, but does no harm!
}
static void MenuPageDown() {
@@ -4860,7 +4849,7 @@ static void MenuPageDown() {
Select(cd.selBox, true);
}
} else if (cd.box == hopperBox1) {
- if (cd.extraBase < numScenes - NUM_RGROUP_BOXES) {
+ if (cd.extraBase < g_numScenes - NUM_RGROUP_BOXES) {
FirstScene(cd.extraBase + (NUM_RGROUP_BOXES - 1));
AddBoxes(true);
if (cd.selBox)
@@ -4868,7 +4857,7 @@ static void MenuPageDown() {
Select(cd.selBox, true);
}
} else if (cd.box == hopperBox2) {
- if (cd.extraBase < numEntries - NUM_RGROUP_BOXES) {
+ if (cd.extraBase < g_numEntries - NUM_RGROUP_BOXES) {
FirstEntry(cd.extraBase+(NUM_RGROUP_BOXES - 1));
AddBoxes(true);
if (cd.selBox)
@@ -5010,7 +4999,7 @@ static void ConfActionSpecial(int i) {
Select(cd.selBox, true);
}
} else if (cd.box == hopperBox1) {
- if (cd.extraBase < numScenes - NUM_RGROUP_BOXES) {
+ if (cd.extraBase < g_numScenes - NUM_RGROUP_BOXES) {
FirstScene(cd.extraBase + 1);
AddBoxes(true);
if (cd.selBox)
@@ -5018,7 +5007,7 @@ static void ConfActionSpecial(int i) {
Select(cd.selBox, true);
}
} else if (cd.box == hopperBox2) {
- if (cd.extraBase < numEntries - NUM_RGROUP_BOXES) {
+ if (cd.extraBase < g_numEntries - NUM_RGROUP_BOXES) {
FirstEntry(cd.extraBase + 1);
AddBoxes(true);
if (cd.selBox)
@@ -5045,25 +5034,25 @@ static void 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 < InvD[ino].NoofItems; hiIndex++)
- if (InvD[ino].contents[hiIndex] == HeldItem)
+ for (hiIndex = 0; hiIndex < g_InvD[g_ino].NoofItems; hiIndex++)
+ if (g_InvD[g_ino].contents[hiIndex] == g_heldItem)
break;
// If drop position would leave a gap, move it up
- if (index >= InvD[ino].NoofItems) {
- if (hiIndex == InvD[ino].NoofItems) // Not in, add it
- index = InvD[ino].NoofItems;
+ if (index >= g_InvD[g_ino].NoofItems) {
+ if (hiIndex == g_InvD[g_ino].NoofItems) // Not in, add it
+ index = g_InvD[g_ino].NoofItems;
else
- index = InvD[ino].NoofItems - 1;
+ index = g_InvD[g_ino].NoofItems - 1;
}
- if (hiIndex == InvD[ino].NoofItems) { // Not in, add it
- if (InvD[ino].NoofItems < InvD[ino].MaxInvObj) {
- InvD[ino].NoofItems++;
+ 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++;
// Don't leave it in the other inventory!
- if (InventoryPos(HeldItem) != INV_HELDNOTIN)
- RemFromInventory(ino == INV_1 ? INV_2 : INV_1, HeldItem);
+ if (InventoryPos(g_heldItem) != INV_HELDNOTIN)
+ RemFromInventory(g_ino == INV_1 ? INV_2 : INV_1, g_heldItem);
} else {
// No room at the inn!
return;
@@ -5072,17 +5061,17 @@ static void InvPutDown(int index) {
// Position it in the inventory
if (index < hiIndex) {
- memmove(&InvD[ino].contents[index + 1], &InvD[ino].contents[index], (hiIndex-index)*sizeof(int));
- InvD[ino].contents[index] = HeldItem;
+ 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(&InvD[ino].contents[hiIndex], &InvD[ino].contents[hiIndex+1], (index-hiIndex)*sizeof(int));
- InvD[ino].contents[index] = HeldItem;
+ 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 {
- InvD[ino].contents[index] = HeldItem;
+ g_InvD[g_ino].contents[index] = g_heldItem;
}
- HeldItem = INV_NOICON;
- ItemsChanged = true;
+ g_heldItem = INV_NOICON;
+ g_ItemsChanged = true;
DelAuxCursor();
RestoreMainCursor();
GetCursorXY(&aniX, &aniY, false);
@@ -5116,26 +5105,26 @@ static void InvPickup(int index) {
return;
// If not holding anything
- if (HeldItem == INV_NOICON && InvD[ino].contents[index] &&
- (!TinselV2 || InvD[ino].contents[index] != HeldItem)) {
+ if (g_heldItem == INV_NOICON && g_InvD[g_ino].contents[index] &&
+ (!TinselV2 || g_InvD[g_ino].contents[index] != g_heldItem)) {
// Pick-up
- invObj = GetInvObject(InvD[ino].contents[index]);
- thisIcon = InvD[ino].contents[index];
+ invObj = GetInvObject(g_InvD[g_ino].contents[index]);
+ g_thisIcon = g_InvD[g_ino].contents[index];
if (TinselV2)
InvTinselEvent(invObj, PICKUP, INV_PICKUP, index);
else if (invObj->hScript)
InvTinselEvent(invObj, WALKTO, INV_PICKUP, index);
- } else if (HeldItem != INV_NOICON) {
+ } else if (g_heldItem != INV_NOICON) {
// Put-down
- invObj = GetInvObject(HeldItem);
+ invObj = GetInvObject(g_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 && ino != INV_1)
- && !(invObj->attribute & IO_ONLYINV2 && 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
@@ -5152,7 +5141,7 @@ static void InvWalkTo(const Common::Point &coOrds) {
switch (InvArea(coOrds.x, coOrds.y)) {
case I_NOTIN:
- if (ino == INV_CONV)
+ if (g_ino == INV_CONV)
ConvAction(INV_CLOSEICON);
if ((cd.box == hopperBox1) || (cd.box == hopperBox2))
FreeSceneHopper();
@@ -5160,43 +5149,43 @@ static void InvWalkTo(const Common::Point &coOrds) {
break;
case I_SLIDE_UP:
- if (InvD[ino].NoofVicons == 1)
- InvD[ino].FirstDisp -= InvD[ino].NoofHicons;
- for (i = 1; i < InvD[ino].NoofVicons; i++)
- InvD[ino].FirstDisp -= InvD[ino].NoofHicons;
- if (InvD[ino].FirstDisp < 0)
- InvD[ino].FirstDisp = 0;
- ItemsChanged = true;
+ 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;
break;
case I_UP:
- InvD[ino].FirstDisp -= InvD[ino].NoofHicons;
- if (InvD[ino].FirstDisp < 0)
- InvD[ino].FirstDisp = 0;
- ItemsChanged = true;
+ 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;
break;
case I_SLIDE_DOWN:
- if (InvD[ino].NoofVicons == 1)
- if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems)
- InvD[ino].FirstDisp += InvD[ino].NoofHicons;
- for (i = 1; i < InvD[ino].NoofVicons; i++) {
- if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems)
- InvD[ino].FirstDisp += InvD[ino].NoofHicons;
+ 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;
}
- ItemsChanged = true;
+ g_ItemsChanged = true;
break;
case I_DOWN:
- if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems) {
- InvD[ino].FirstDisp += InvD[ino].NoofHicons;
- ItemsChanged = true;
+ 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_BODY:
- if (ino == INV_CONF) {
- if (!InventoryHidden)
+ if (g_ino == INV_CONF) {
+ if (!g_InventoryHidden)
MenuAction(WhichMenuBox(coOrds.x, coOrds.y, false), false);
} else {
Common::Point pt = coOrds;
@@ -5204,8 +5193,8 @@ 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 && HeldItem != INV_NOICON &&
- (ino == INV_1 || ino == INV_2)) {
+ if (i == INV_NOICON && g_heldItem != INV_NOICON &&
+ (g_ino == INV_1 || g_ino == INV_2)) {
pt.x += 1; // 1 to the right
i = InvItem(pt, false);
if (i == INV_NOICON) {
@@ -5219,7 +5208,7 @@ static void InvWalkTo(const Common::Point &coOrds) {
}
}
- if (ino == INV_CONV) {
+ if (g_ino == INV_CONV) {
ConvAction(i);
} else
InvPickup(i);
@@ -5238,19 +5227,19 @@ static void InvAction() {
switch (InvArea(aniX, aniY)) {
case I_BODY:
- if (ino == INV_CONF) {
- if (!InventoryHidden)
+ if (g_ino == INV_CONF) {
+ if (!g_InventoryHidden)
MenuAction(WhichMenuBox(aniX, aniY, false), true);
- } else if (ino == INV_CONV) {
+ } else if (g_ino == INV_CONV) {
index = InvItem(&aniX, &aniY, false);
ConvAction(index);
} else {
index = InvItem(&aniX, &aniY, false);
if (index != INV_NOICON) {
- if (InvD[ino].contents[index] && InvD[ino].contents[index] != HeldItem) {
- invObj = GetInvObject(InvD[ino].contents[index]);
+ if (g_InvD[g_ino].contents[index] && g_InvD[g_ino].contents[index] != g_heldItem) {
+ invObj = GetInvObject(g_InvD[g_ino].contents[index]);
if (TinselV2)
- thisIcon = InvD[ino].contents[index];
+ g_thisIcon = g_InvD[g_ino].contents[index];
if (TinselV2 || (invObj->hScript))
InvTinselEvent(invObj, ACTION, INV_ACTION, index);
}
@@ -5259,33 +5248,33 @@ static void InvAction() {
break;
case I_HEADER: // Maximise/unmaximise inventory
- if (!InvD[ino].resizable)
+ if (!g_InvD[g_ino].resizable)
break;
- if (!InventoryMaximised) {
- InvD[ino].sNoofHicons = InvD[ino].NoofHicons;
- InvD[ino].sNoofVicons = InvD[ino].NoofVicons;
- InvD[ino].NoofHicons = InvD[ino].MaxHicons;
- InvD[ino].NoofVicons = InvD[ino].MaxVicons;
- InventoryMaximised = true;
-
- i = InvD[ino].inventoryX;
- InvD[ino].inventoryX = InvD[ino].otherX;
- InvD[ino].otherX = i;
- i = InvD[ino].inventoryY;
- InvD[ino].inventoryY = InvD[ino].otherY;
- InvD[ino].otherY = i;
+ 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;
} else {
- InvD[ino].NoofHicons = InvD[ino].sNoofHicons;
- InvD[ino].NoofVicons = InvD[ino].sNoofVicons;
- InventoryMaximised = false;
-
- i = InvD[ino].inventoryX;
- InvD[ino].inventoryX = InvD[ino].otherX;
- InvD[ino].otherX = i;
- i = InvD[ino].inventoryY;
- InvD[ino].inventoryY = InvD[ino].otherY;
- InvD[ino].otherY = i;
+ 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;
}
// Delete current, and re-draw
@@ -5295,15 +5284,15 @@ static void InvAction() {
break;
case I_UP:
- InvD[ino].FirstDisp -= InvD[ino].NoofHicons;
- if (InvD[ino].FirstDisp < 0)
- InvD[ino].FirstDisp = 0;
- ItemsChanged = true;
+ 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;
break;
case I_DOWN:
- if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems) {
- InvD[ino].FirstDisp += InvD[ino].NoofHicons;
- ItemsChanged = true;
+ 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;
}
@@ -5319,8 +5308,8 @@ static void InvLook(const Common::Point &coOrds) {
case I_BODY:
index = InvItem(pt, false);
if (index != INV_NOICON) {
- if (InvD[ino].contents[index] && InvD[ino].contents[index] != HeldItem) {
- invObj = GetInvObject(InvD[ino].contents[index]);
+ if (g_InvD[g_ino].contents[index] && g_InvD[g_ino].contents[index] != g_heldItem) {
+ invObj = GetInvObject(g_InvD[g_ino].contents[index]);
if (invObj->hScript)
InvTinselEvent(invObj, LOOK, INV_LOOK, index);
}
@@ -5328,7 +5317,7 @@ static void InvLook(const Common::Point &coOrds) {
break;
case I_NOTIN:
- if (ino == INV_CONV)
+ if (g_ino == INV_CONV)
ConvAction(INV_CLOSEICON);
KillInventory();
break;
@@ -5341,7 +5330,7 @@ static void InvLook(const Common::Point &coOrds) {
/**************************************************************************/
extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
- if (InventoryHidden)
+ if (g_InventoryHidden)
return;
switch (pEvent) {
@@ -5364,7 +5353,7 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
break;
case PLR_ACTION: // PLR_DLEFT
- if (InvDragging != ID_MDCONT)
+ if (g_InvDragging != ID_MDCONT)
InvDragEnd();
InvAction();
break;
@@ -5380,7 +5369,7 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
case PLR_ESCAPE:
if (MenuActive()) {
if (cd.box != optionBox && cd.box != hopperBox1 && cd.box != hopperBox2)
- bReOpenMenu = true;
+ g_bReOpenMenu = true;
if ((cd.box == hopperBox1) || (cd.box == hopperBox2))
FreeSceneHopper();
}
@@ -5388,42 +5377,42 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
break;
case PLR_PGDN:
- if (ino == INV_MENU) {
+ if (g_ino == INV_MENU) {
// Only act if load or save screen
MenuPageDown();
} else {
// This code is a copy of the IB_SLIDE_DOWN case in InvWalkTo
// TODO: So share this duplicate code
- if (InvD[ino].NoofVicons == 1)
- if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems)
- InvD[ino].FirstDisp += InvD[ino].NoofHicons;
- for (int i = 1; i < InvD[ino].NoofVicons; i++) {
- if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems)
- InvD[ino].FirstDisp += InvD[ino].NoofHicons;
+ 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;
}
- ItemsChanged = true;
+ g_ItemsChanged = true;
}
break;
case PLR_PGUP:
- if (ino == INV_MENU) {
+ if (g_ino == INV_MENU) {
// Only act if load or save screen
MenuPageUp();
} else {
// This code is a copy of the I_SLIDE_UP case in InvWalkTo
// TODO: So share this duplicate code
- if (InvD[ino].NoofVicons == 1)
- InvD[ino].FirstDisp -= InvD[ino].NoofHicons;
- for (int i = 1; i < InvD[ino].NoofVicons; i++)
- InvD[ino].FirstDisp -= InvD[ino].NoofHicons;
- if (InvD[ino].FirstDisp < 0)
- InvD[ino].FirstDisp = 0;
- ItemsChanged = true;
+ 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;
}
break;
case PLR_HOME:
- if (ino == INV_MENU) {
+ if (g_ino == INV_MENU) {
// Only act if load or save screen
if (cd.box == loadBox || cd.box == saveBox)
FirstFile(0);
@@ -5438,19 +5427,19 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
cd.selBox = 0;
Select(cd.selBox, true);
} else {
- InvD[ino].FirstDisp = 0;
- ItemsChanged = true;
+ g_InvD[g_ino].FirstDisp = 0;
+ g_ItemsChanged = true;
}
break;
case PLR_END:
- if (ino == INV_MENU) {
+ if (g_ino == INV_MENU) {
if (cd.box == loadBox || cd.box == saveBox)
FirstFile(MAX_SAVED_FILES); // Will get reduced to appropriate value
else if (cd.box == hopperBox1)
- FirstScene(numScenes); // Will get reduced to appropriate value
+ FirstScene(g_numScenes); // Will get reduced to appropriate value
else if (cd.box == hopperBox2)
- FirstEntry(numEntries); // Will get reduced to appropriate value
+ FirstEntry(g_numEntries); // Will get reduced to appropriate value
else
break;
@@ -5458,10 +5447,10 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
cd.selBox = 0;
Select(cd.selBox, true);
} else {
- InvD[ino].FirstDisp = InvD[ino].NoofItems - InvD[ino].NoofHicons*InvD[ino].NoofVicons;
- if (InvD[ino].FirstDisp < 0)
- InvD[ino].FirstDisp = 0;
- ItemsChanged = true;
+ 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;
}
break;
default:
@@ -5483,8 +5472,8 @@ extern void SetObjectFilm(int object, SCNHANDLE hFilm) {
invObj = GetInvObject(object);
invObj->hIconFilm = hFilm;
- if (HeldItem != object)
- ItemsChanged = true;
+ if (g_heldItem != object)
+ g_ItemsChanged = true;
}
/**
@@ -5492,34 +5481,34 @@ extern void SetObjectFilm(int object, SCNHANDLE hFilm) {
*/
extern void syncInvInfo(Common::Serializer &s) {
for (int i = 0; i < NUM_INV; i++) {
- 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);
+ 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);
for (int j = 0; j < MAX_ININV; j++) {
- s.syncAsSint32LE(InvD[i].contents[j]);
+ s.syncAsSint32LE(g_InvD[i].contents[j]);
}
- 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);
+ 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);
}
if (TinselV2) {
- for (int i = 0; i < numObjects; ++i)
- s.syncAsUint32LE(invFilms[i]);
- s.syncAsUint32LE(heldFilm);
+ for (int i = 0; i < g_numObjects; ++i)
+ s.syncAsUint32LE(g_invFilms[i]);
+ s.syncAsUint32LE(g_heldFilm);
}
}
@@ -5533,18 +5522,18 @@ extern void syncInvInfo(Common::Serializer &s) {
*/
// Note: the SCHANDLE type here has been changed to a void*
extern void RegisterIcons(void *cptr, int num) {
- numObjects = num;
- invObjects = (INV_OBJECT *) cptr;
+ g_numObjects = num;
+ g_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(numObjects * sizeof(INV_OBJECT));
+ MEM_NODE *node = MemoryAllocFixed(g_numObjects * sizeof(INV_OBJECT));
assert(node);
- invObjects = (INV_OBJECT *)MemoryDeref(node);
- assert(invObjects);
+ g_invObjects = (INV_OBJECT *)MemoryDeref(node);
+ assert(g_invObjects);
byte *srcP = (byte *)cptr;
- INV_OBJECT *destP = (INV_OBJECT *)invObjects;
+ INV_OBJECT *destP = (INV_OBJECT *)g_invObjects;
for (int i = 0; i < num; ++i, ++destP, srcP += 12) {
memmove(destP, srcP, 12);
@@ -5552,12 +5541,12 @@ extern void RegisterIcons(void *cptr, int num) {
}
} else if (TinselV1Mac) {
// Macintosh version has BE encoded resources, so the values need to be byte swapped
- MEM_NODE *node = MemoryAllocFixed(numObjects * sizeof(INV_OBJECT));
+ MEM_NODE *node = MemoryAllocFixed(g_numObjects * sizeof(INV_OBJECT));
assert(node);
- invObjects = (INV_OBJECT *)MemoryDeref(node);
- assert(invObjects);
+ g_invObjects = (INV_OBJECT *)MemoryDeref(node);
+ assert(g_invObjects);
INV_OBJECT *srcP = (INV_OBJECT *)cptr;
- INV_OBJECT *destP = (INV_OBJECT *)invObjects;
+ INV_OBJECT *destP = (INV_OBJECT *)g_invObjects;
for (int i = 0; i < num; ++i, ++destP, ++srcP) {
destP->id = FROM_BE_32(srcP->id);
@@ -5566,14 +5555,14 @@ extern void RegisterIcons(void *cptr, int num) {
destP->attribute = FROM_BE_32(srcP->attribute);
}
} else if (TinselV2) {
- if (invFilms == NULL) {
+ if (g_invFilms == NULL) {
// First time - allocate memory
- MEM_NODE *node = MemoryAllocFixed(numObjects * sizeof(SCNHANDLE));
+ MEM_NODE *node = MemoryAllocFixed(g_numObjects * sizeof(SCNHANDLE));
assert(node);
- invFilms = (SCNHANDLE *)MemoryDeref(node);
- if (invFilms == NULL)
+ g_invFilms = (SCNHANDLE *)MemoryDeref(node);
+ if (g_invFilms == NULL)
error(NO_MEM, "inventory scripts");
- memset(invFilms, 0, numObjects * sizeof(SCNHANDLE));
+ memset(g_invFilms, 0, g_numObjects * sizeof(SCNHANDLE));
}
@@ -5581,11 +5570,11 @@ extern void RegisterIcons(void *cptr, int num) {
// and store all the films separately
int i;
INV_OBJECT *pio;
- for (i = 0, pio = invObjects; i < numObjects; i++, pio++) {
+ for (i = 0, pio = g_invObjects; i < g_numObjects; i++, pio++) {
if (pio->attribute & PERMACONV)
PermaConvIcon(pio->id, pio->attribute & CONVENDITEM);
- invFilms[i] = pio->hIconFilm;
+ g_invFilms[i] = pio->hIconFilm;
}
}
}
@@ -5599,7 +5588,7 @@ extern void setInvWinParts(SCNHANDLE hf) {
const FILM *pfilm;
#endif
- hWinParts = hf;
+ g_hWinParts = hf;
#ifdef DEBUG
pfilm = (const FILM *)LockMem(hf);
@@ -5616,7 +5605,7 @@ extern void setFlagFilms(SCNHANDLE hf) {
const FILM *pfilm;
#endif
- flagFilm = hf;
+ g_flagFilm = hf;
#ifdef DEBUG
pfilm = (const FILM *)LockMem(hf);
@@ -5628,7 +5617,7 @@ extern void setFlagFilms(SCNHANDLE hf) {
* Called from Glitter function 'DecCStrings()'
*/
extern void setConfigStrings(SCNHANDLE *tp) {
- memcpy(configStrings, tp, sizeof(configStrings));
+ memcpy(g_configStrings, tp, sizeof(g_configStrings));
}
/**
@@ -5652,36 +5641,36 @@ extern void idec_inv(int num, SCNHANDLE text, int MaxContents,
if (StartHeight > MaxHeight)
StartHeight = MaxHeight;
- InventoryState = IDLE_INV;
+ g_InventoryState = IDLE_INV;
- InvD[num].MaxHicons = MaxWidth;
- InvD[num].MinHicons = MinWidth;
- InvD[num].MaxVicons = MaxHeight;
- InvD[num].MinVicons = MinHeight;
+ g_InvD[num].MaxHicons = MaxWidth;
+ g_InvD[num].MinHicons = MinWidth;
+ g_InvD[num].MaxVicons = MaxHeight;
+ g_InvD[num].MinVicons = MinHeight;
- InvD[num].NoofHicons = StartWidth;
- InvD[num].NoofVicons = StartHeight;
+ g_InvD[num].NoofHicons = StartWidth;
+ g_InvD[num].NoofVicons = StartHeight;
- memset(InvD[num].contents, 0, sizeof(InvD[num].contents));
- InvD[num].NoofItems = 0;
+ memset(g_InvD[num].contents, 0, sizeof(g_InvD[num].contents));
+ g_InvD[num].NoofItems = 0;
- InvD[num].FirstDisp = 0;
+ g_InvD[num].FirstDisp = 0;
- InvD[num].inventoryX = startx;
- InvD[num].inventoryY = starty;
- InvD[num].otherX = 21;
- InvD[num].otherY = 15;
+ g_InvD[num].inventoryX = startx;
+ g_InvD[num].inventoryY = starty;
+ g_InvD[num].otherX = 21;
+ g_InvD[num].otherY = 15;
- InvD[num].MaxInvObj = MaxContents;
+ g_InvD[num].MaxInvObj = MaxContents;
- InvD[num].hInvTitle = text;
+ g_InvD[num].hInvTitle = text;
if (MaxWidth != MinWidth && MaxHeight != MinHeight)
- InvD[num].resizable = true;
+ g_InvD[num].resizable = true;
- InvD[num].bMoveable = moveable;
+ g_InvD[num].bMoveable = moveable;
- InvD[num].bMax = false;
+ g_InvD[num].bMax = false;
}
/**
@@ -5729,7 +5718,7 @@ extern void idec_inv2(SCNHANDLE text, int MaxContents,
extern int InvGetLimit(int invno) {
assert(invno == INV_1 || invno == INV_2); // only INV_1 and INV_2 supported
- return InvD[invno].MaxInvObj;
+ return g_InvD[invno].MaxInvObj;
}
/**
@@ -5737,12 +5726,12 @@ extern int InvGetLimit(int invno) {
*/
extern void InvSetLimit(int invno, int MaxContents) {
assert(invno == INV_1 || invno == INV_2); // only INV_1 and INV_2 supported
- assert(MaxContents >= InvD[invno].NoofItems); // can't reduce maximum contents below current contents
+ assert(MaxContents >= g_InvD[invno].NoofItems); // can't reduce maximum contents below current contents
if (MaxContents > MAX_ININV)
MaxContents = MAX_ININV; // Max contents
- InvD[invno].MaxInvObj = MaxContents;
+ g_InvD[invno].MaxInvObj = MaxContents;
}
/**
@@ -5757,34 +5746,34 @@ extern void InvSetSize(int invno, int MinWidth, int MinHeight,
if (StartHeight > MaxHeight)
StartHeight = MaxHeight;
- InvD[invno].MaxHicons = MaxWidth;
- InvD[invno].MinHicons = MinWidth;
- InvD[invno].MaxVicons = MaxHeight;
- InvD[invno].MinVicons = MinHeight;
+ g_InvD[invno].MaxHicons = MaxWidth;
+ g_InvD[invno].MinHicons = MinWidth;
+ g_InvD[invno].MaxVicons = MaxHeight;
+ g_InvD[invno].MinVicons = MinHeight;
- InvD[invno].NoofHicons = StartWidth;
- InvD[invno].NoofVicons = StartHeight;
+ g_InvD[invno].NoofHicons = StartWidth;
+ g_InvD[invno].NoofVicons = StartHeight;
if (MaxWidth != MinWidth && MaxHeight != MinHeight)
- InvD[invno].resizable = true;
+ g_InvD[invno].resizable = true;
else
- InvD[invno].resizable = false;
+ g_InvD[invno].resizable = false;
- InvD[invno].bMax = false;
+ g_InvD[invno].bMax = false;
}
/**************************************************************************/
extern bool IsTopWindow() {
- return (InventoryState == BOGUS_INV);
+ return (g_InventoryState == BOGUS_INV);
}
extern bool MenuActive() {
- return (InventoryState == ACTIVE_INV && ino == INV_CONF);
+ return (g_InventoryState == ACTIVE_INV && g_ino == INV_CONF);
}
extern bool IsConvWindow() {
- return (InventoryState == ACTIVE_INV && ino == INV_CONV);
+ return (g_InventoryState == ACTIVE_INV && g_ino == INV_CONV);
}
} // End of namespace Tinsel
diff --git a/engines/tinsel/drives.cpp b/engines/tinsel/drives.cpp
index 5977d3b718..d815fd165d 100644
--- a/engines/tinsel/drives.cpp
+++ b/engines/tinsel/drives.cpp
@@ -32,13 +32,13 @@ namespace Tinsel {
// FIXME: Avoid non-const global vars
-char currentCD = '1';
+char g_currentCD = '1';
-static bool bChangingCD = false;
-static char nextCD = '\0';
+static bool g_bChangingCD = false;
+static char g_nextCD = '\0';
-static uint32 lastTime = 0;
-extern LANGUAGE sampleLanguage;
+static uint32 g_lastTime = 0;
+extern LANGUAGE g_sampleLanguage;
void CdCD(CORO_PARAM) {
@@ -47,7 +47,7 @@ void CdCD(CORO_PARAM) {
CORO_BEGIN_CODE(_ctx);
- while (bChangingCD) {
+ while (g_bChangingCD) {
if (g_scheduler->getCurrentProcess()) {
// FIXME: CdCD gets passed a nullContext in RegisterGlobals() and
// PrimeSceneHopper(), because I didn't know how to get a proper
@@ -66,13 +66,13 @@ void CdCD(CORO_PARAM) {
int GetCurrentCD() {
// count from 1
- return (currentCD - '1' + 1);
+ return (g_currentCD - '1' + 1);
}
static const uint32 cdFlags[] = { fCd1, fCd2, fCd3, fCd4, fCd5, fCd6, fCd7, fCd8 };
void SetCD(int flags) {
- if (flags & cdFlags[currentCD - '1'])
+ if (flags & cdFlags[g_currentCD - '1'])
return;
error("SetCD() problem");
@@ -82,7 +82,7 @@ int GetCD(int flags) {
int i;
char cd = '\0';
- if (flags & cdFlags[currentCD - '1'])
+ if (flags & cdFlags[g_currentCD - '1'])
return GetCurrentCD();
for (i = 0; i < 8; i++) {
@@ -93,19 +93,19 @@ int GetCD(int flags) {
}
assert(i != 8);
- nextCD = cd;
+ g_nextCD = cd;
return cd;
}
void DoCdChange() {
- if (bChangingCD && (g_system->getMillis() > (lastTime + 1000))) {
- lastTime = g_system->getMillis();
+ if (g_bChangingCD && (g_system->getMillis() > (g_lastTime + 1000))) {
+ g_lastTime = g_system->getMillis();
_vm->_sound->closeSampleStream();
// Use the filesize of the sample file to determine, for Discworld 2, which CD it is
if (TinselV2) {
TinselFile f;
- if (!f.open(_vm->getSampleFile(sampleLanguage)))
+ if (!f.open(_vm->getSampleFile(g_sampleLanguage)))
// No CD present
return;
@@ -113,28 +113,28 @@ void DoCdChange() {
f.close();
- if (currentCD != sampleCdNumber)
+ if (g_currentCD != sampleCdNumber)
return;
}
_vm->_sound->openSampleFiles();
ChangeLanguage(TextLanguage());
- bChangingCD = false;
+ g_bChangingCD = false;
}
}
void SetNextCD(int cdNumber) {
assert(cdNumber == 1 || cdNumber == 2);
- nextCD = (char)(cdNumber + '1' - 1);
+ g_nextCD = (char)(cdNumber + '1' - 1);
}
bool GotoCD() {
// WORKAROUND: Somehow, CdDoChange() is called twice... Hopefully, this guard helps
- if (currentCD == nextCD)
+ if (g_currentCD == g_nextCD)
return false;
- currentCD = nextCD;
+ g_currentCD = g_nextCD;
/* if (bNoCD) {
strcpy(cdDirectory, hdDirectory);
@@ -142,7 +142,7 @@ bool GotoCD() {
strcat(cdDirectory, cdLastBit);
}
*/
- bChangingCD = true;
+ g_bChangingCD = true;
return true;
}
diff --git a/engines/tinsel/events.cpp b/engines/tinsel/events.cpp
index e701ddca99..74454c5f2a 100644
--- a/engines/tinsel/events.cpp
+++ b/engines/tinsel/events.cpp
@@ -54,37 +54,37 @@ extern HPOLYGON GetTaggedPoly();
//----------------- EXTERNAL GLOBAL DATA ---------------------
-extern bool bEnableMenu;
+extern bool g_bEnableMenu;
//----------------- LOCAL GLOBAL DATA --------------------
// FIXME: Avoid non-const global vars
-static uint32 lastUserEvent = 0; // Time it hapenned
-static int leftEvents = 0; // Single or double, left or right. Or escape key.
-static int escEvents = 1; // Escape key
-static int userEvents = 0; // Whenever a button or a key comes in
+static uint32 g_lastUserEvent = 0; // Time it hapenned
+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
-static int eCount = 0;
+static int g_eCount = 0;
-static int controlState;
-static bool bStartOff;
+static int g_controlState;
+static bool g_bStartOff;
-static int controlX, controlY;
-static bool bProvNotProcessed = false;
+static int g_controlX, g_controlY;
+static bool g_bProvNotProcessed = false;
/**
* Gets called before each schedule, only 1 user action per schedule
* is allowed.
*/
void ResetEcount() {
- eCount = 0;
+ g_eCount = 0;
}
void IncUserEvents() {
- userEvents++;
- lastUserEvent = DwGetCurrentTime();
+ g_userEvents++;
+ g_lastUserEvent = DwGetCurrentTime();
}
/**
@@ -104,7 +104,7 @@ void AllowDclick(CORO_PARAM, PLR_EVENT be) {
FreeToken(TOKEN_LEFT_BUT);
// Prevent activation of 2 events on the same tick
- if (++eCount != 1)
+ if (++g_eCount != 1)
CORO_KILL_SELF();
break;
@@ -125,17 +125,17 @@ void ControlOn() {
return;
}
- bEnableMenu = false;
+ g_bEnableMenu = false;
- if (controlState == CONTROL_OFF) {
+ if (g_controlState == CONTROL_OFF) {
// Control is on
- controlState = CONTROL_ON;
+ g_controlState = CONTROL_ON;
// Restore cursor to where it was
- if (bStartOff == true)
- bStartOff = false;
+ if (g_bStartOff == true)
+ g_bStartOff = false;
else
- SetCursorXY(controlX, controlY);
+ SetCursorXY(g_controlX, g_controlY);
// Re-instate cursor
UnHideCursor();
@@ -155,14 +155,14 @@ void ControlOff() {
return;
}
- bEnableMenu = false;
+ g_bEnableMenu = false;
- if (controlState == CONTROL_ON) {
+ if (g_controlState == CONTROL_ON) {
// Control is off
- controlState = CONTROL_OFF;
+ g_controlState = CONTROL_OFF;
// Store cursor position
- GetCursorXY(&controlX, &controlY, true);
+ GetCursorXY(&g_controlX, &g_controlY, true);
// Blank out cursor
DwHideCursor();
@@ -181,10 +181,10 @@ void ControlStartOff() {
return;
}
- bEnableMenu = false;
+ g_bEnableMenu = false;
// Control is off
- controlState = CONTROL_OFF;
+ g_controlState = CONTROL_OFF;
// Blank out cursor
DwHideCursor();
@@ -192,7 +192,7 @@ void ControlStartOff() {
// Switch off tags
DisableTags();
- bStartOff = true;
+ g_bStartOff = true;
}
/**
@@ -211,7 +211,7 @@ bool GetControl(int param) {
}
bool GetControl() {
- if (controlState == CONTROL_ON) {
+ if (g_controlState == CONTROL_ON) {
ControlOff();
return true;
} else
@@ -220,7 +220,7 @@ bool GetControl() {
bool ControlIsOn() {
if (TinselV2)
- return (controlState == CONTROL_ON);
+ return (g_controlState == CONTROL_ON);
return TestToken(TOKEN_CONTROL);
}
@@ -289,7 +289,7 @@ static void ProcessUserEvent(TINSEL_EVENT uEvent, const Common::Point &coOrds, P
HPOLYGON hPoly;
// Prevent activation of 2 events on the same tick
- if (++eCount != 1)
+ if (++g_eCount != 1)
return;
if ((actor = GetTaggedActor()) != 0) {
@@ -395,19 +395,19 @@ void PlayerEvent(PLR_EVENT pEvent, const Common::Point &coOrds) {
static uint32 lastRealAction = 0; // FIXME: Avoid non-const global vars
// This stuff to allow F1 key during startup.
- if (bEnableMenu && pEvent == PLR_MENU)
+ if (g_bEnableMenu && pEvent == PLR_MENU)
Control(CONTROL_ON);
else
IncUserEvents();
if (pEvent == PLR_ESCAPE) {
- ++escEvents;
- ++leftEvents; // Yes, I do mean this
+ ++g_escEvents;
+ ++g_leftEvents; // Yes, I do mean this
} else if ((pEvent == PLR_PROV_WALKTO)
|| (pEvent == PLR_WALKTO)
|| (pEvent == PLR_LOOK)
|| (pEvent == PLR_ACTION)) {
- ++leftEvents;
+ ++g_leftEvents;
}
// Only allow events if player control is on
@@ -484,18 +484,18 @@ void PlayerEvent(PLR_EVENT pEvent, const Common::Point &coOrds) {
* For ESCapable Glitter sequences
*/
int GetEscEvents() {
- return escEvents;
+ return g_escEvents;
}
/**
* For cutting short talk()s etc.
*/
int GetLeftEvents() {
- return leftEvents;
+ return g_leftEvents;
}
bool LeftEventChange(int myleftEvent) {
- if (leftEvents != myleftEvent) {
+ if (g_leftEvents != myleftEvent) {
ProcessedProvisional();
return true;
} else
@@ -506,15 +506,15 @@ bool LeftEventChange(int myleftEvent) {
* For waitkey() Glitter function
*/
int getUserEvents() {
- return userEvents;
+ return g_userEvents;
}
uint32 getUserEventTime() {
- return DwGetCurrentTime() - lastUserEvent;
+ return DwGetCurrentTime() - g_lastUserEvent;
}
void resetUserEventTime() {
- lastUserEvent = DwGetCurrentTime();
+ g_lastUserEvent = DwGetCurrentTime();
}
struct PTP_INIT {
@@ -655,18 +655,18 @@ void effRunPolyTinselCode(HPOLYGON hPoly, TINSEL_EVENT event, int actor) {
* subsequent 'real' event.
*/
void ProcessedProvisional() {
- bProvNotProcessed = false;
+ g_bProvNotProcessed = false;
}
/**
* Resets the bProvNotProcessed flag
*/
void ProvNotProcessed() {
- bProvNotProcessed = true;
+ g_bProvNotProcessed = true;
}
bool GetProvNotProcessed() {
- return bProvNotProcessed;
+ return g_bProvNotProcessed;
}
} // End of namespace Tinsel
diff --git a/engines/tinsel/font.cpp b/engines/tinsel/font.cpp
index e857dca509..54aa7cc15f 100644
--- a/engines/tinsel/font.cpp
+++ b/engines/tinsel/font.cpp
@@ -34,38 +34,38 @@ namespace Tinsel {
// FIXME: Avoid non-const global vars
-static char tBuffer[TBUFSZ];
+static char g_tBuffer[TBUFSZ];
-static SCNHANDLE hTagFont = 0, hTalkFont = 0;
-static SCNHANDLE hRegularTalkFont = 0, hRegularTagFont = 0;
+static SCNHANDLE g_hTagFont = 0, g_hTalkFont = 0;
+static SCNHANDLE g_hRegularTalkFont = 0, g_hRegularTagFont = 0;
/**
* Return address of tBuffer
*/
char *TextBufferAddr() {
- return tBuffer;
+ return g_tBuffer;
}
/**
* Return hTagFont handle.
*/
SCNHANDLE GetTagFontHandle() {
- return hTagFont;
+ return g_hTagFont;
}
/**
* Return hTalkFont handle.
*/
SCNHANDLE GetTalkFontHandle() {
- return hTalkFont;
+ return g_hTalkFont;
}
/**
* Called from dec_tagfont() Glitter function. Store the tag font handle.
*/
void SetTagFontHandle(SCNHANDLE hFont) {
- hTagFont = hRegularTagFont = hFont; // Store the font handle
+ g_hTagFont = g_hRegularTagFont = hFont; // Store the font handle
}
/**
@@ -73,20 +73,20 @@ void SetTagFontHandle(SCNHANDLE hFont) {
* Store the talk font handle.
*/
void SetTalkFontHandle(SCNHANDLE hFont) {
- hTalkFont = hRegularTalkFont = hFont; // Store the font handle
+ g_hTalkFont = g_hRegularTalkFont = hFont; // Store the font handle
}
void SetTempTagFontHandle(SCNHANDLE hFont) {
- hTagFont = hFont;
+ g_hTagFont = hFont;
}
void SetTempTalkFontHandle(SCNHANDLE hFont) {
- hTalkFont = hFont;
+ g_hTalkFont = hFont;
}
void ResetFontHandles() {
- hTagFont = hRegularTagFont;
- hTalkFont = hRegularTalkFont;
+ g_hTagFont = g_hRegularTagFont;
+ g_hTalkFont = g_hRegularTalkFont;
}
@@ -98,17 +98,17 @@ void FettleFontPal(SCNHANDLE fontPal) {
IMAGE *pImg;
assert(fontPal);
- assert(hTagFont); // Tag font not declared
- assert(hTalkFont); // Talk font not declared
+ assert(g_hTagFont); // Tag font not declared
+ assert(g_hTalkFont); // Talk font not declared
- pFont = (const FONT *)LockMem(hTagFont);
+ pFont = (const FONT *)LockMem(g_hTagFont);
pImg = (IMAGE *)LockMem(FROM_LE_32(pFont->fontInit.hObjImg)); // get image for char 0
if (!TinselV2)
pImg->hImgPal = TO_LE_32(fontPal);
else
pImg->hImgPal = 0;
- pFont = (const FONT *)LockMem(hTalkFont);
+ pFont = (const FONT *)LockMem(g_hTalkFont);
pImg = (IMAGE *)LockMem(FROM_LE_32(pFont->fontInit.hObjImg)); // get image for char 0
if (!TinselV2)
pImg->hImgPal = TO_LE_32(fontPal);
diff --git a/engines/tinsel/graphics.cpp b/engines/tinsel/graphics.cpp
index 4f3cc36994..9b06b1a501 100644
--- a/engines/tinsel/graphics.cpp
+++ b/engines/tinsel/graphics.cpp
@@ -40,7 +40,7 @@ namespace Tinsel {
#define CHAR_WIDTH 4
#define CHAR_HEIGHT 4
-extern uint8 transPalette[MAX_COLORS];
+extern uint8 g_transPalette[MAX_COLORS];
//----------------- SUPPORT FUNCTIONS ---------------------
@@ -559,7 +559,7 @@ static void WrtTrans(DRAWOBJECT *pObj, uint8 *destP, bool applyClipping) {
// Loop through any remaining lines
while (pObj->height > 0) {
for (int i = 0; i < pObj->width; ++i, ++destP)
- *destP = transPalette[*destP];
+ *destP = g_transPalette[*destP];
--pObj->height;
destP += lineOffset;
diff --git a/engines/tinsel/handle.cpp b/engines/tinsel/handle.cpp
index eeb83b1f98..e31b2141f5 100644
--- a/engines/tinsel/handle.cpp
+++ b/engines/tinsel/handle.cpp
@@ -69,17 +69,17 @@ enum {
// FIXME: Avoid non-const global vars
// handle table gets loaded from index file at runtime
-static MEMHANDLE *handleTable = 0;
+static MEMHANDLE *g_handleTable = 0;
// number of handles in the handle table
-static uint numHandles = 0;
+static uint g_numHandles = 0;
-static uint32 cdPlayHandle = (uint32)-1;
+static uint32 g_cdPlayHandle = (uint32)-1;
-static SCNHANDLE cdBaseHandle = 0, cdTopHandle = 0;
-static Common::File *cdGraphStream = 0;
+static SCNHANDLE g_cdBaseHandle = 0, g_cdTopHandle = 0;
+static Common::File *g_cdGraphStream = 0;
-static char szCdPlayFile[100];
+static char g_szCdPlayFile[100];
//----------------- FORWARD REFERENCES --------------------
@@ -110,24 +110,24 @@ void SetupHandleTable() {
}
// calc number of handles
- numHandles = len / RECORD_SIZE;
+ g_numHandles = len / RECORD_SIZE;
// allocate memory for the index file
- handleTable = (MEMHANDLE *)calloc(numHandles, sizeof(struct MEMHANDLE));
+ g_handleTable = (MEMHANDLE *)calloc(g_numHandles, sizeof(struct MEMHANDLE));
// make sure memory allocated
- assert(handleTable);
+ assert(g_handleTable);
// load data
- for (i = 0; i < numHandles; i++) {
- f.read(handleTable[i].szName, 12);
- handleTable[i].filesize = f.readUint32();
+ for (i = 0; i < g_numHandles; i++) {
+ f.read(g_handleTable[i].szName, 12);
+ g_handleTable[i].filesize = f.readUint32();
// The pointer should always be NULL. We don't
// need to read that from the file.
- handleTable[i]._node = NULL;
+ g_handleTable[i]._node = NULL;
f.seek(4, SEEK_CUR);
// For Discworld 2, read in the flags2 field
- handleTable[i].flags2 = t2Flag ? f.readUint32() : 0;
+ g_handleTable[i].flags2 = t2Flag ? f.readUint32() : 0;
}
if (f.eos() || f.err()) {
@@ -145,7 +145,7 @@ void SetupHandleTable() {
}
// allocate memory nodes and load all permanent graphics
- for (i = 0, pH = handleTable; i < numHandles; i++, pH++) {
+ for (i = 0, pH = g_handleTable; i < g_numHandles; i++, pH++) {
if (pH->filesize & fPreload) {
// allocate a fixed memory node for permanent files
pH->_node = MemoryAllocFixed((pH->filesize & FSIZE_MASK));
@@ -172,24 +172,24 @@ void SetupHandleTable() {
}
void FreeHandleTable() {
- free(handleTable);
- handleTable = NULL;
+ free(g_handleTable);
+ g_handleTable = NULL;
- delete cdGraphStream;
- cdGraphStream = NULL;
+ delete g_cdGraphStream;
+ g_cdGraphStream = NULL;
}
/**
* Loads a memory block as a file.
*/
void OpenCDGraphFile() {
- delete cdGraphStream;
+ delete g_cdGraphStream;
// As the theory goes, the right CD will be in there!
- cdGraphStream = new Common::File;
- if (!cdGraphStream->open(szCdPlayFile))
- error(CANNOT_FIND_FILE, szCdPlayFile);
+ g_cdGraphStream = new Common::File;
+ if (!g_cdGraphStream->open(g_szCdPlayFile))
+ error(CANNOT_FIND_FILE, g_szCdPlayFile);
}
void LoadCDGraphData(MEMHANDLE *pH) {
@@ -210,15 +210,15 @@ void LoadCDGraphData(MEMHANDLE *pH) {
assert(addr);
// Move to correct place in file and load the required data
- assert(cdGraphStream);
- cdGraphStream->seek(cdBaseHandle & OFFSETMASK, SEEK_SET);
- bytes = cdGraphStream->read(addr, (cdTopHandle - cdBaseHandle) & OFFSETMASK);
+ assert(g_cdGraphStream);
+ g_cdGraphStream->seek(g_cdBaseHandle & OFFSETMASK, SEEK_SET);
+ bytes = g_cdGraphStream->read(addr, (g_cdTopHandle - g_cdBaseHandle) & OFFSETMASK);
// New code to try and handle CD read failures 24/2/97
- while (bytes != ((cdTopHandle - cdBaseHandle) & OFFSETMASK) && retries++ < MAX_READ_RETRIES) {
+ while (bytes != ((g_cdTopHandle - g_cdBaseHandle) & OFFSETMASK) && retries++ < MAX_READ_RETRIES) {
// Try again
- cdGraphStream->seek(cdBaseHandle & OFFSETMASK, SEEK_SET);
- bytes = cdGraphStream->read(addr, (cdTopHandle - cdBaseHandle) & OFFSETMASK);
+ g_cdGraphStream->seek(g_cdBaseHandle & OFFSETMASK, SEEK_SET);
+ bytes = g_cdGraphStream->read(addr, (g_cdTopHandle - g_cdBaseHandle) & OFFSETMASK);
}
// discardable - unlock the memory
@@ -230,7 +230,7 @@ void LoadCDGraphData(MEMHANDLE *pH) {
// clear the loading flag
// pH->filesize &= ~fLoading;
- if (bytes != ((cdTopHandle - cdBaseHandle) & OFFSETMASK))
+ if (bytes != ((g_cdTopHandle - g_cdBaseHandle) & OFFSETMASK))
// file is corrupt
error(FILE_READ_ERROR, "CD play file");
}
@@ -245,22 +245,22 @@ void LoadCDGraphData(MEMHANDLE *pH) {
void LoadExtraGraphData(SCNHANDLE start, SCNHANDLE next) {
OpenCDGraphFile();
- MemoryDiscard((handleTable + cdPlayHandle)->_node); // Free it
+ MemoryDiscard((g_handleTable + g_cdPlayHandle)->_node); // Free it
// It must always be the same
- assert(cdPlayHandle == (start >> SCNHANDLE_SHIFT));
- assert(cdPlayHandle == (next >> SCNHANDLE_SHIFT));
+ assert(g_cdPlayHandle == (start >> SCNHANDLE_SHIFT));
+ assert(g_cdPlayHandle == (next >> SCNHANDLE_SHIFT));
- cdBaseHandle = start;
- cdTopHandle = next;
+ g_cdBaseHandle = start;
+ g_cdTopHandle = next;
}
void SetCdPlaySceneDetails(int fileNum, const char *fileName) {
- strcpy(szCdPlayFile, fileName);
+ strcpy(g_szCdPlayFile, fileName);
}
void SetCdPlayHandle(int fileNum) {
- cdPlayHandle = fileNum;
+ g_cdPlayHandle = fileNum;
}
@@ -323,26 +323,26 @@ byte *LockMem(SCNHANDLE offset) {
MEMHANDLE *pH; // points to table entry
// range check the memory handle
- assert(handle < numHandles);
+ 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 = handleTable + handle;
+ pH = g_handleTable + handle;
if (pH->filesize & fPreload) {
// permanent files are already loaded, nothing to be done
- } else if (handle == cdPlayHandle) {
+ } else if (handle == g_cdPlayHandle) {
// Must be in currently loaded/loadable range
- if (offset < cdBaseHandle || offset >= cdTopHandle)
+ if (offset < g_cdBaseHandle || offset >= g_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, cdTopHandle - cdBaseHandle);
+ MemoryReAlloc(pH->_node, g_cdTopHandle - g_cdBaseHandle);
LoadCDGraphData(pH);
@@ -353,7 +353,7 @@ byte *LockMem(SCNHANDLE offset) {
// make sure address is valid
assert(pH->filesize & fLoaded);
- offset -= cdBaseHandle;
+ offset -= g_cdBaseHandle;
} else {
if (!MemoryDeref(pH->_node)) {
// Data was discarded, we have to reload
@@ -387,9 +387,9 @@ void LockScene(SCNHANDLE offset) {
#endif
// range check the memory handle
- assert(handle < numHandles);
+ assert(handle < g_numHandles);
- pH = handleTable + handle;
+ pH = g_handleTable + handle;
if ((pH->filesize & fPreload) == 0) {
// Ensure the scene handle is allocated.
@@ -414,9 +414,9 @@ void UnlockScene(SCNHANDLE offset) {
MEMHANDLE *pH; // points to table entry
// range check the memory handle
- assert(handle < numHandles);
+ assert(handle < g_numHandles);
- pH = handleTable + handle;
+ pH = g_handleTable + handle;
if ((pH->filesize & fPreload) == 0) {
// unlock the scene data
@@ -441,9 +441,9 @@ bool ValidHandle(SCNHANDLE offset) {
MEMHANDLE *pH; // points to table entry
// range check the memory handle
- assert(handle < numHandles);
+ assert(handle < g_numHandles);
- pH = handleTable + handle;
+ pH = g_handleTable + handle;
return (pH->filesize & FSIZE_MASK) != 8;
}
@@ -458,7 +458,7 @@ void TouchMem(SCNHANDLE offset) {
uint32 handle = offset >> SCNHANDLE_SHIFT; // calc memory handle to use
if (offset != 0) {
- pH = handleTable + handle;
+ pH = g_handleTable + handle;
// update the LRU time whether its loaded or not!
if (pH->_node)
@@ -474,9 +474,9 @@ bool IsCdPlayHandle(SCNHANDLE offset) {
uint32 handle = offset >> SCNHANDLE_SHIFT; // calc memory handle to use
// range check the memory handle
- assert(handle < numHandles);
+ assert(handle < g_numHandles);
- return (handle == cdPlayHandle);
+ return (handle == g_cdPlayHandle);
}
/**
@@ -486,9 +486,9 @@ int CdNumber(SCNHANDLE offset) {
uint handle = offset >> SCNHANDLE_SHIFT; // calc memory handle to use
// range check the memory handle
- assert(handle < numHandles);
+ assert(handle < g_numHandles);
- MEMHANDLE *pH = handleTable + handle;
+ MEMHANDLE *pH = g_handleTable + handle;
if (!TinselV2)
return 1;
diff --git a/engines/tinsel/heapmem.cpp b/engines/tinsel/heapmem.cpp
index 819493bda1..597cc69e66 100644
--- a/engines/tinsel/heapmem.cpp
+++ b/engines/tinsel/heapmem.cpp
@@ -58,16 +58,16 @@ static const uint32 MemoryPoolSize[3] = {5 * 1024 * 1024, 5 * 1024 * 1024, 10 *
// list of all memory nodes
-MEM_NODE mnodeList[NUM_MNODES];
+MEM_NODE g_mnodeList[NUM_MNODES];
// pointer to the linked list of free mnodes
-static MEM_NODE *pFreeMemNodes;
+static MEM_NODE *g_pFreeMemNodes;
// list of all fixed memory nodes
-MEM_NODE s_fixedMnodesList[5];
+MEM_NODE g_s_fixedMnodesList[5];
// the mnode heap sentinel
-static MEM_NODE heapSentinel;
+static MEM_NODE g_heapSentinel;
//
static MEM_NODE *AllocMemNode();
@@ -80,7 +80,7 @@ static void MemoryStats() {
int lockedSize = 0;
int totalSize = 0;
- const MEM_NODE *pHeap = &heapSentinel;
+ const MEM_NODE *pHeap = &g_heapSentinel;
MEM_NODE *pCur;
for (pCur = pHeap->pNext; pCur != pHeap; pCur = pCur->pNext) {
@@ -104,43 +104,43 @@ static void MemoryStats() {
*/
void MemoryInit() {
// place first node on free list
- pFreeMemNodes = mnodeList;
+ g_pFreeMemNodes = g_mnodeList;
// link all other objects after first
- memset(mnodeList, 0, sizeof(mnodeList));
+ memset(g_mnodeList, 0, sizeof(g_mnodeList));
for (int i = 1; i < NUM_MNODES; i++) {
- mnodeList[i - 1].pNext = mnodeList + i;
+ g_mnodeList[i - 1].pNext = g_mnodeList + i;
}
// null the last mnode
- mnodeList[NUM_MNODES - 1].pNext = NULL;
+ g_mnodeList[NUM_MNODES - 1].pNext = NULL;
// clear list of fixed memory nodes
- memset(s_fixedMnodesList, 0, sizeof(s_fixedMnodesList));
+ memset(g_s_fixedMnodesList, 0, sizeof(g_s_fixedMnodesList));
// set cyclic links to the sentinel
- heapSentinel.pPrev = &heapSentinel;
- heapSentinel.pNext = &heapSentinel;
+ g_heapSentinel.pPrev = &g_heapSentinel;
+ g_heapSentinel.pNext = &g_heapSentinel;
// flag sentinel as locked
- heapSentinel.flags = DWM_LOCKED | DWM_SENTINEL;
+ g_heapSentinel.flags = DWM_LOCKED | DWM_SENTINEL;
// store the current heap size in the sentinel
uint32 size = MemoryPoolSize[0];
if (TinselVersion == TINSEL_V1) size = MemoryPoolSize[1];
else if (TinselVersion == TINSEL_V2) size = MemoryPoolSize[2];
- heapSentinel.size = size;
+ g_heapSentinel.size = size;
}
/**
* Deinitializes the memory manager.
*/
void MemoryDeinit() {
- const MEM_NODE *pHeap = &heapSentinel;
+ const MEM_NODE *pHeap = &g_heapSentinel;
MEM_NODE *pCur;
- pCur = s_fixedMnodesList;
- for (int i = 0; i < ARRAYSIZE(s_fixedMnodesList); ++i, ++pCur) {
+ pCur = g_s_fixedMnodesList;
+ for (int i = 0; i < ARRAYSIZE(g_s_fixedMnodesList); ++i, ++pCur) {
free(pCur->pBaseAddr);
pCur->pBaseAddr = 0;
}
@@ -157,13 +157,13 @@ void MemoryDeinit() {
*/
static MEM_NODE *AllocMemNode() {
// get the first free mnode
- MEM_NODE *pMemNode = pFreeMemNodes;
+ MEM_NODE *pMemNode = g_pFreeMemNodes;
// make sure a mnode is available
assert(pMemNode); // Out of memory nodes
// the next free mnode
- pFreeMemNodes = pMemNode->pNext;
+ g_pFreeMemNodes = pMemNode->pNext;
// wipe out the mnode
memset(pMemNode, 0, sizeof(MEM_NODE));
@@ -178,13 +178,13 @@ static MEM_NODE *AllocMemNode() {
*/
void FreeMemNode(MEM_NODE *pMemNode) {
// validate mnode pointer
- assert(pMemNode >= mnodeList && pMemNode <= mnodeList + NUM_MNODES - 1);
+ assert(pMemNode >= g_mnodeList && pMemNode <= g_mnodeList + NUM_MNODES - 1);
// place free list in mnode next
- pMemNode->pNext = pFreeMemNodes;
+ pMemNode->pNext = g_pFreeMemNodes;
// add mnode to top of free list
- pFreeMemNodes = pMemNode;
+ g_pFreeMemNodes = pMemNode;
}
@@ -194,11 +194,11 @@ void FreeMemNode(MEM_NODE *pMemNode) {
* @return true if any blocks were discarded, false otherwise
*/
static bool HeapCompact(long size) {
- const MEM_NODE *pHeap = &heapSentinel;
+ const MEM_NODE *pHeap = &g_heapSentinel;
MEM_NODE *pCur, *pOldest;
uint32 oldest; // time of the oldest discardable block
- while (heapSentinel.size < size) {
+ while (g_heapSentinel.size < size) {
// find the oldest discardable block
oldest = DwGetCurrentTime();
@@ -231,7 +231,7 @@ static bool HeapCompact(long size) {
* @param size Number of bytes to allocate
*/
static MEM_NODE *MemoryAlloc(long size) {
- MEM_NODE *pHeap = &heapSentinel;
+ MEM_NODE *pHeap = &g_heapSentinel;
#ifdef SCUMM_NEED_ALIGNMENT
const int alignPadding = sizeof(void *) - 1;
@@ -255,7 +255,7 @@ static MEM_NODE *MemoryAlloc(long size) {
assert(pNode->pBaseAddr);
// Subtract size of new block from total
- heapSentinel.size -= size;
+ g_heapSentinel.size -= size;
#ifdef DEBUG
MemoryStats();
@@ -282,7 +282,7 @@ static MEM_NODE *MemoryAlloc(long size) {
* by using MemoryReAlloc().
*/
MEM_NODE *MemoryNoAlloc() {
- MEM_NODE *pHeap = &heapSentinel;
+ MEM_NODE *pHeap = &g_heapSentinel;
// chain a discarded node onto the end of the heap
MEM_NODE *pNode = AllocMemNode();
@@ -315,8 +315,8 @@ MEM_NODE *MemoryAllocFixed(long size) {
#endif
// Search for a free entry in s_fixedMnodesList
- MEM_NODE *pNode = s_fixedMnodesList;
- for (int i = 0; i < ARRAYSIZE(s_fixedMnodesList); ++i, ++pNode) {
+ MEM_NODE *pNode = g_s_fixedMnodesList;
+ for (int i = 0; i < ARRAYSIZE(g_s_fixedMnodesList); ++i, ++pNode) {
if (!pNode->pBaseAddr) {
pNode->pNext = 0;
pNode->pPrev = 0;
@@ -326,7 +326,7 @@ MEM_NODE *MemoryAllocFixed(long size) {
pNode->flags = DWM_USED;
// Subtract size of new block from total
- heapSentinel.size -= size;
+ g_heapSentinel.size -= size;
return pNode;
}
@@ -342,7 +342,7 @@ MEM_NODE *MemoryAllocFixed(long size) {
*/
void MemoryDiscard(MEM_NODE *pMemNode) {
// validate mnode pointer
- assert(pMemNode >= mnodeList && pMemNode <= mnodeList + NUM_MNODES - 1);
+ assert(pMemNode >= g_mnodeList && pMemNode <= g_mnodeList + NUM_MNODES - 1);
// object must be in use and locked
assert((pMemNode->flags & (DWM_USED | DWM_LOCKED)) == DWM_USED);
@@ -351,7 +351,7 @@ void MemoryDiscard(MEM_NODE *pMemNode) {
if ((pMemNode->flags & DWM_DISCARDED) == 0) {
// free memory
free(pMemNode->pBaseAddr);
- heapSentinel.size += pMemNode->size;
+ g_heapSentinel.size += pMemNode->size;
#ifdef DEBUG
MemoryStats();
@@ -416,7 +416,7 @@ void MemoryReAlloc(MEM_NODE *pMemNode, long size) {
MEM_NODE *pNew;
// validate mnode pointer
- assert(pMemNode >= mnodeList && pMemNode <= mnodeList + NUM_MNODES - 1);
+ assert(pMemNode >= g_mnodeList && pMemNode <= g_mnodeList + NUM_MNODES - 1);
// align the size to machine boundary requirements
size = (size + sizeof(void *) - 1) & ~(sizeof(void *) - 1);
diff --git a/engines/tinsel/mareels.cpp b/engines/tinsel/mareels.cpp
index bd267a2c65..7dd905d0f2 100644
--- a/engines/tinsel/mareels.cpp
+++ b/engines/tinsel/mareels.cpp
@@ -48,9 +48,9 @@ struct SCIdataStruct {
// FIXME: Avoid non-const global vars
-static SCIdataStruct SCIdata[MAX_SCRENTRIES];
+static SCIdataStruct g_SCIdata[MAX_SCRENTRIES];
-static int scrEntries = 0;
+static int g_scrEntries = 0;
/**
* Sets an actor's walk reels
@@ -131,16 +131,16 @@ void SetScalingReels(int actor, int scale, int direction,
assert(!(scale == 1 && direction == D_UP) &&
!(scale == NUM_MAINSCALES && direction == D_DOWN)); // illegal direction from scale
- assert(scrEntries < MAX_SCRENTRIES); // Scaling reels limit reached!
+ assert(g_scrEntries < MAX_SCRENTRIES); // Scaling reels limit reached!
- SCIdata[scrEntries].actor = actor;
- SCIdata[scrEntries].scale = scale;
- SCIdata[scrEntries].direction = direction;
- SCIdata[scrEntries].reels[LEFTREEL] = left;
- SCIdata[scrEntries].reels[RIGHTREEL] = right;
- SCIdata[scrEntries].reels[FORWARD] = forward;
- SCIdata[scrEntries].reels[AWAY] = away;
- scrEntries++;
+ g_SCIdata[g_scrEntries].actor = actor;
+ g_SCIdata[g_scrEntries].scale = scale;
+ g_SCIdata[g_scrEntries].direction = direction;
+ g_SCIdata[g_scrEntries].reels[LEFTREEL] = left;
+ g_SCIdata[g_scrEntries].reels[RIGHTREEL] = right;
+ g_SCIdata[g_scrEntries].reels[FORWARD] = forward;
+ g_SCIdata[g_scrEntries].reels[AWAY] = away;
+ g_scrEntries++;
}
/**
@@ -155,12 +155,12 @@ SCNHANDLE ScalingReel(int ano, int scale1, int scale2, DIRECTION reel) {
else
d = D_UP;
- for (int i = 0; i < scrEntries; i++) {
- if (SCIdata[i].actor == ano && SCIdata[i].scale == scale1 && SCIdata[i].direction == d) {
- if (SCIdata[i].reels[reel] == TF_NONE)
+ for (int i = 0; i < g_scrEntries; i++) {
+ if (g_SCIdata[i].actor == ano && g_SCIdata[i].scale == scale1 && g_SCIdata[i].direction == d) {
+ if (g_SCIdata[i].reels[reel] == TF_NONE)
return 0;
else
- return SCIdata[i].reels[reel];
+ return g_SCIdata[i].reels[reel];
}
}
return 0;
@@ -170,8 +170,8 @@ SCNHANDLE ScalingReel(int ano, int scale1, int scale2, DIRECTION reel) {
* RebootScalingReels
*/
void RebootScalingReels() {
- scrEntries = 0;
- memset(SCIdata, 0, sizeof(SCIdata));
+ g_scrEntries = 0;
+ memset(g_SCIdata, 0, sizeof(g_SCIdata));
}
/**
diff --git a/engines/tinsel/move.cpp b/engines/tinsel/move.cpp
index e20f28d528..bb49e59fe7 100644
--- a/engines/tinsel/move.cpp
+++ b/engines/tinsel/move.cpp
@@ -77,14 +77,14 @@ HPOLYGON InitExtraBlock(PMOVER ca, PMOVER ta);
// FIXME: Avoid non-const global vars
#if SLOW_RINCE_DOWN
-static int Interlude = 0; // For slowing down walking, for testing
-static int BogusVar = 0; // For slowing down walking, for testing
+static int g_Interlude = 0; // For slowing down walking, for testing
+static int g_BogusVar = 0; // For slowing down walking, for testing
#endif
-static int32 DefaultRefer = 0;
-static int lastLeadXdest = 0, lastLeadYdest = 0;
+static int32 g_DefaultRefer = 0;
+static int g_lastLeadXdest = 0, g_lastLeadYdest = 0;
-static int hSlowVar = 0; // used by MoveActor()
+static int g_hSlowVar = 0; // used by MoveActor()
//----------------- FORWARD REFERENCES --------------------
@@ -101,9 +101,9 @@ static void NewCoOrdinates(int fromx, int fromy, int *targetX, int *targetY,
*/
void AddInterlude(int n) {
- Interlude += n;
- if (Interlude < 0)
- Interlude = 0;
+ g_Interlude += n;
+ if (g_Interlude < 0)
+ g_Interlude = 0;
}
#endif
@@ -251,7 +251,7 @@ static int ClickedOnNothing(int clickX, int clickY, int *ptgtX, int *ptgtY) {
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
- switch (DefaultRefer) {
+ switch (g_DefaultRefer) {
case REF_DEFAULT:
// Try searching down and up (onscreen).
for (i = clickY+1; i < SCREEN_HEIGHT+Toffset; i++)
@@ -1353,15 +1353,15 @@ int SetActorDest(PMOVER pMover, int clickX, int clickY, bool igPath, SCNHANDLE h
targetY = clickY;
if (pMover->actorID == GetLeadId()) {
- lastLeadXdest = targetX;
- lastLeadYdest = targetY;
+ g_lastLeadXdest = targetX;
+ g_lastLeadYdest = targetY;
}
} else {
int wodResult = WorkOutDestination(clickX, clickY, &targetX, &targetY);
if (pMover->actorID == GetLeadId()) {
- lastLeadXdest = targetX;
- lastLeadYdest = targetY;
+ g_lastLeadXdest = targetX;
+ g_lastLeadYdest = targetY;
}
if (wodResult == ALL_SORTED) {
@@ -1613,17 +1613,17 @@ void MoveActor(PMOVER pMover) {
}
#if SLOW_RINCE_DOWN
-/**/ if (BogusVar++ < Interlude) // Temporary slow-down-the-action code
+/**/ if (g_BogusVar++ < g_Interlude) // Temporary slow-down-the-action code
/**/ return; //
-/**/ BogusVar = 0; //
+/**/ g_BogusVar = 0; //
#endif
if (!TinselV2) {
// During swalk()s, movement while hidden may be slowed down.
if (pMover->bHidden) {
- if (++hSlowVar < pMover->SlowFactor)
+ if (++g_hSlowVar < pMover->SlowFactor)
return;
- hSlowVar = 0;
+ g_hSlowVar = 0;
}
}
@@ -1705,15 +1705,15 @@ void MoveActor(PMOVER pMover) {
* Store the default refer type for the current scene.
*/
void SetDefaultRefer(int32 defRefer) {
- DefaultRefer = defRefer;
+ g_DefaultRefer = defRefer;
}
int GetLastLeadXdest() {
- return lastLeadXdest;
+ return g_lastLeadXdest;
}
int GetLastLeadYdest() {
- return lastLeadYdest;
+ return g_lastLeadYdest;
}
diff --git a/engines/tinsel/music.cpp b/engines/tinsel/music.cpp
index f552c49491..781a378f13 100644
--- a/engines/tinsel/music.cpp
+++ b/engines/tinsel/music.cpp
@@ -64,13 +64,13 @@ struct SOUND_BUFFER {
// FIXME: Avoid non-const global vars
// MIDI buffer
-static SOUND_BUFFER midiBuffer = { 0, 0 };
+static SOUND_BUFFER g_midiBuffer = { 0, 0 };
-static SCNHANDLE currentMidi = 0;
-static bool currentLoop = false;
+static SCNHANDLE g_currentMidi = 0;
+static bool g_currentLoop = false;
// We allocate 155 entries because that's the maximum, used in the SCN version
-static SCNHANDLE midiOffsets[155];
+static SCNHANDLE g_midiOffsets[155];
static const int enhancedAudioGRAVersion[] = {
1, 2, 1, 1, 3, 3, 4, 4, 5, 6, // 1-10
@@ -110,16 +110,16 @@ static const int enhancedAudioSCNVersion[] = {
};
int GetTrackNumber(SCNHANDLE hMidi) {
- for (int i = 0; i < ARRAYSIZE(midiOffsets); i++)
- if (midiOffsets[i] == hMidi)
+ for (int i = 0; i < ARRAYSIZE(g_midiOffsets); i++)
+ if (g_midiOffsets[i] == hMidi)
return i;
return -1;
}
SCNHANDLE GetTrackOffset(int trackNumber) {
- assert(trackNumber < ARRAYSIZE(midiOffsets));
- return midiOffsets[trackNumber];
+ assert(trackNumber < ARRAYSIZE(g_midiOffsets));
+ return g_midiOffsets[trackNumber];
}
/**
@@ -128,8 +128,8 @@ SCNHANDLE GetTrackOffset(int trackNumber) {
* @param bLoop Whether to loop the sequence
*/
bool PlayMidiSequence(uint32 dwFileOffset, bool bLoop) {
- currentMidi = dwFileOffset;
- currentLoop = bLoop;
+ g_currentMidi = dwFileOffset;
+ g_currentLoop = bLoop;
// Tinsel V1 PSX uses a different music format, so i
// disable it here.
@@ -166,8 +166,8 @@ bool PlayMidiSequence(uint32 dwFileOffset, bool bLoop) {
StopMidi();
// StopMidi resets these fields, so set them again
- currentMidi = dwFileOffset;
- currentLoop = bLoop;
+ g_currentMidi = dwFileOffset;
+ g_currentLoop = bLoop;
// try to play track, but don't fall back to a true CD
g_system->getAudioCDManager()->play(track, bLoop ? -1 : 1, 0, 0, true);
@@ -203,13 +203,13 @@ bool PlayMidiSequence(uint32 dwFileOffset, bool bLoop) {
dwSeqLen = midiStream.readUint32LE();
// make sure buffer is large enough for this sequence
- assert(dwSeqLen > 0 && dwSeqLen <= midiBuffer.size);
+ assert(dwSeqLen > 0 && dwSeqLen <= g_midiBuffer.size);
// stop any currently playing tune
_vm->_midiMusic->stop();
// read the sequence
- if (midiStream.read(midiBuffer.pDat, dwSeqLen) != dwSeqLen)
+ if (midiStream.read(g_midiBuffer.pDat, dwSeqLen) != dwSeqLen)
error(FILE_IS_CORRUPT, MIDI_FILE);
midiStream.close();
@@ -231,14 +231,14 @@ bool PlayMidiSequence(uint32 dwFileOffset, bool bLoop) {
_vm->_midiMusic->send(0x7F07B0 | 13);
}
- _vm->_midiMusic->playXMIDI(midiBuffer.pDat, dwSeqLen, bLoop);
+ _vm->_midiMusic->playXMIDI(g_midiBuffer.pDat, dwSeqLen, bLoop);
// Store the length
//dwLastSeqLen = dwSeqLen;
} else {
// dwFileOffset == dwLastMidiIndex
_vm->_midiMusic->stop();
- _vm->_midiMusic->playXMIDI(midiBuffer.pDat, dwSeqLen, bLoop);
+ _vm->_midiMusic->playXMIDI(g_midiBuffer.pDat, dwSeqLen, bLoop);
}
return true;
@@ -259,8 +259,8 @@ bool MidiPlaying() {
* Stops any currently playing midi.
*/
bool StopMidi() {
- currentMidi = 0;
- currentLoop = false;
+ g_currentMidi = 0;
+ g_currentLoop = false;
if (_vm->getFeatures() & GF_ENHANCED_AUDIO_SUPPORT) {
g_system->getAudioCDManager()->stop();
@@ -295,8 +295,8 @@ void SetMidiVolume(int vol) {
_vm->_midiMusic->setVolume(vol);
} else if (vol != 0 && priorVolMusic == 0) {
// Perhaps restart last midi sequence
- if (currentLoop)
- PlayMidiSequence(currentMidi, true);
+ if (g_currentLoop)
+ PlayMidiSequence(g_currentMidi, true);
_vm->_midiMusic->setVolume(vol);
} else if (vol != 0 && priorVolMusic != 0) {
@@ -318,7 +318,7 @@ void OpenMidiFiles() {
if ((_vm->getFeatures() & GF_DEMO) || (TinselVersion == TINSEL_V2) || TinselV1PSX)
return;
- if (midiBuffer.pDat)
+ if (g_midiBuffer.pDat)
// already allocated
return;
@@ -327,15 +327,15 @@ void OpenMidiFiles() {
error(CANNOT_FIND_FILE, MIDI_FILE);
// gen length of the largest sequence
- midiBuffer.size = midiStream.readUint32LE();
+ g_midiBuffer.size = midiStream.readUint32LE();
if (midiStream.eos() || midiStream.err())
error(FILE_IS_CORRUPT, MIDI_FILE);
- if (midiBuffer.size) {
+ if (g_midiBuffer.size) {
// allocate a buffer big enough for the largest MIDI sequence
- if ((midiBuffer.pDat = (uint8 *)malloc(midiBuffer.size)) != NULL) {
+ if ((g_midiBuffer.pDat = (uint8 *)malloc(g_midiBuffer.size)) != NULL) {
// clear out the buffer
- memset(midiBuffer.pDat, 0, midiBuffer.size);
+ memset(g_midiBuffer.pDat, 0, g_midiBuffer.size);
// VMM_lock(midiBuffer.pDat, midiBuffer.size);
} else {
//mSeqHandle = NULL;
@@ -352,15 +352,15 @@ void OpenMidiFiles() {
uint32 songLength = 0;
// Init
- for (int i = 0; i < ARRAYSIZE(midiOffsets); i++)
- midiOffsets[i] = 0;
+ for (int i = 0; i < ARRAYSIZE(g_midiOffsets); i++)
+ g_midiOffsets[i] = 0;
while (!midiStream.eos() && !midiStream.err()) {
if (curOffset + (4 * curTrack) >= (uint32)midiStream.size())
break;
- assert(curTrack < ARRAYSIZE(midiOffsets));
- midiOffsets[curTrack] = curOffset + (4 * curTrack);
+ assert(curTrack < ARRAYSIZE(g_midiOffsets));
+ g_midiOffsets[curTrack] = curOffset + (4 * curTrack);
//debug("%d: %d", curTrack, midiOffsets[curTrack]);
songLength = midiStream.readUint32LE();
@@ -374,8 +374,8 @@ void OpenMidiFiles() {
}
void DeleteMidiBuffer() {
- free(midiBuffer.pDat);
- midiBuffer.pDat = NULL;
+ free(g_midiBuffer.pDat);
+ g_midiBuffer.pDat = NULL;
}
MidiMusicPlayer::MidiMusicPlayer() {
@@ -860,22 +860,22 @@ void PCMMusicPlayer::stop() {
}
void CurrentMidiFacts(SCNHANDLE *pMidi, bool *pLoop) {
- *pMidi = currentMidi;
- *pLoop = currentLoop;
+ *pMidi = g_currentMidi;
+ *pLoop = g_currentLoop;
}
void RestoreMidiFacts(SCNHANDLE Midi, bool Loop) {
StopMidi();
- currentMidi = Midi;
- currentLoop = Loop;
+ g_currentMidi = Midi;
+ g_currentLoop = Loop;
if (_vm->_config->_musicVolume != 0 && Loop) {
bool mute = false;
if (ConfMan.hasKey("mute"))
mute = ConfMan.getBool("mute");
- PlayMidiSequence(currentMidi, true);
+ PlayMidiSequence(g_currentMidi, true);
SetMidiVolume(mute ? 0 : _vm->_config->_musicVolume);
}
}
diff --git a/engines/tinsel/palette.cpp b/engines/tinsel/palette.cpp
index f2437bd17e..e6c9467fab 100644
--- a/engines/tinsel/palette.cpp
+++ b/engines/tinsel/palette.cpp
@@ -54,33 +54,33 @@ struct VIDEO_DAC_Q {
// FIXME: Avoid non-const global vars
/** palette allocator data */
-static PALQ palAllocData[NUM_PALETTES];
+static PALQ g_palAllocData[NUM_PALETTES];
/** video DAC transfer Q length */
#define VDACQLENGTH (NUM_PALETTES+2)
/** video DAC transfer Q */
-static VIDEO_DAC_Q vidDACdata[VDACQLENGTH];
+static VIDEO_DAC_Q g_vidDACdata[VDACQLENGTH];
/** video DAC transfer Q head pointer */
-static VIDEO_DAC_Q *pDAChead;
+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 transPalette[MAX_COLORS]; // used in graphics.cpp
+uint8 g_transPalette[MAX_COLORS]; // used in graphics.cpp
-uint8 ghostPalette[MAX_COLORS];
+uint8 g_ghostPalette[MAX_COLORS];
-static int translucentIndex = 228;
+static int g_translucentIndex = 228;
-static int talkIndex = 233;
+static int g_talkIndex = 233;
-static COLORREF talkColRef;
+static COLORREF g_talkColRef;
-static COLORREF tagColRef;
+static COLORREF g_tagColRef;
#ifdef DEBUG
@@ -131,11 +131,11 @@ void psxPaletteMapper(PALQ *originalPal, uint8 *psxClut, byte *mapperTable) {
*/
void PalettesToVideoDAC() {
PALQ *pPalQ; // palette Q iterator
- VIDEO_DAC_Q *pDACtail = vidDACdata; // set tail pointer
+ VIDEO_DAC_Q *pDACtail = g_vidDACdata; // set tail pointer
byte pal[768];
// while Q is not empty
- while (pDAChead != pDACtail) {
+ while (g_pDAChead != pDACtail) {
const PALETTE *pPalette; // pointer to hardware palette
const COLORREF *pColors; // pointer to list of RGB triples
@@ -179,10 +179,10 @@ void PalettesToVideoDAC() {
}
// reset video DAC transfer Q head pointer
- pDAChead = vidDACdata;
+ g_pDAChead = g_vidDACdata;
// clear all palette moved bits
- for (pPalQ = palAllocData; pPalQ < palAllocData + NUM_PALETTES; pPalQ++)
+ for (pPalQ = g_palAllocData; pPalQ < g_palAllocData + NUM_PALETTES; pPalQ++)
pPalQ->posInDAC &= ~PALETTE_MOVED;
}
@@ -196,10 +196,10 @@ void ResetPalAllocator() {
#endif
// wipe out the palette allocator data
- memset(palAllocData, 0, sizeof(palAllocData));
+ memset(g_palAllocData, 0, sizeof(g_palAllocData));
// reset video DAC transfer Q head pointer
- pDAChead = vidDACdata;
+ g_pDAChead = g_vidDACdata;
}
#ifdef DEBUG
@@ -220,19 +220,19 @@ void PaletteStats() {
*/
void UpdateDACqueueHandle(int posInDAC, int numColors, SCNHANDLE hPalette) {
// check Q overflow
- assert(pDAChead < vidDACdata + VDACQLENGTH);
+ assert(g_pDAChead < g_vidDACdata + VDACQLENGTH);
- pDAChead->destDACindex = posInDAC & ~PALETTE_MOVED; // set index in video DAC
- pDAChead->numColors = numColors; // set number of colors
- pDAChead->pal.hRGBarray = hPalette; // set handle of palette
- pDAChead->bHandle = true; // we are using a palette handle
+ g_pDAChead->destDACindex = posInDAC & ~PALETTE_MOVED; // set index in video DAC
+ g_pDAChead->numColors = numColors; // set number of colors
+ g_pDAChead->pal.hRGBarray = hPalette; // set handle of palette
+ g_pDAChead->bHandle = true; // we are using a palette handle
// update head pointer
- ++pDAChead;
+ ++g_pDAChead;
#ifdef DEBUG
- if ((pDAChead-vidDACdata) > maxDACQ)
- maxDACQ = pDAChead-vidDACdata;
+ if ((g_pDAChead-g_vidDACdata) > maxDACQ)
+ maxDACQ = g_pDAChead-g_vidDACdata;
#endif
}
@@ -244,22 +244,22 @@ void UpdateDACqueueHandle(int posInDAC, int numColors, SCNHANDLE hPalette) {
*/
void UpdateDACqueue(int posInDAC, int numColors, COLORREF *pColors) {
// check Q overflow
- assert(pDAChead < vidDACdata + NUM_PALETTES);
+ assert(g_pDAChead < g_vidDACdata + NUM_PALETTES);
- pDAChead->destDACindex = posInDAC & ~PALETTE_MOVED; // set index in video DAC
- pDAChead->numColors = numColors; // set number of colors
+ g_pDAChead->destDACindex = posInDAC & ~PALETTE_MOVED; // set index in video DAC
+ g_pDAChead->numColors = numColors; // set number of colors
if (numColors == 1)
- pDAChead->pal.singleRGB = *pColors; // set single color of which the "palette" consists
+ g_pDAChead->pal.singleRGB = *pColors; // set single color of which the "palette" consists
else
- pDAChead->pal.pRGBarray = pColors; // set addr of palette
- pDAChead->bHandle = false; // we are not using a palette handle
+ g_pDAChead->pal.pRGBarray = pColors; // set addr of palette
+ g_pDAChead->bHandle = false; // we are not using a palette handle
// update head pointer
- ++pDAChead;
+ ++g_pDAChead;
#ifdef DEBUG
- if ((pDAChead-vidDACdata) > maxDACQ)
- maxDACQ = pDAChead-vidDACdata;
+ if ((g_pDAChead-g_vidDACdata) > maxDACQ)
+ maxDACQ = g_pDAChead-g_vidDACdata;
#endif
}
@@ -271,19 +271,19 @@ void UpdateDACqueue(int posInDAC, int numColors, COLORREF *pColors) {
*/
void UpdateDACqueue(int posInDAC, COLORREF color) {
// check Q overflow
- assert(pDAChead < vidDACdata + NUM_PALETTES);
+ assert(g_pDAChead < g_vidDACdata + NUM_PALETTES);
- pDAChead->destDACindex = posInDAC & ~PALETTE_MOVED; // set index in video DAC
- pDAChead->numColors = 1; // set number of colors
- pDAChead->pal.singleRGB = color; // set single color of which the "palette" consists
- pDAChead->bHandle = false; // we are not using a palette handle
+ g_pDAChead->destDACindex = posInDAC & ~PALETTE_MOVED; // set index in video DAC
+ g_pDAChead->numColors = 1; // set number of colors
+ g_pDAChead->pal.singleRGB = color; // set single color of which the "palette" consists
+ g_pDAChead->bHandle = false; // we are not using a palette handle
// update head pointer
- ++pDAChead;
+ ++g_pDAChead;
#ifdef DEBUG
- if ((pDAChead-vidDACdata) > maxDACQ)
- maxDACQ = pDAChead-vidDACdata;
+ if ((g_pDAChead-g_vidDACdata) > maxDACQ)
+ maxDACQ = g_pDAChead-g_vidDACdata;
#endif
}
@@ -301,7 +301,7 @@ PALQ *AllocPalette(SCNHANDLE hNewPal) {
pNewPal = (PALETTE *)LockMem(hNewPal);
// search all structs in palette allocator - see if palette already allocated
- for (p = palAllocData; p < palAllocData + NUM_PALETTES; p++) {
+ for (p = g_palAllocData; p < g_palAllocData + NUM_PALETTES; p++) {
if (p->hPal == hNewPal) {
// found the desired palette in palette allocator
p->objCount++; // update number of objects using palette
@@ -312,7 +312,7 @@ PALQ *AllocPalette(SCNHANDLE hNewPal) {
// search all structs in palette allocator - find a free slot
iDAC = FGND_DAC_INDEX; // init DAC index to first available foreground color
- for (p = palAllocData; p < palAllocData + NUM_PALETTES; p++) {
+ for (p = g_palAllocData; p < g_palAllocData + NUM_PALETTES; p++) {
if (p->hPal == 0) {
// found a free slot in palette allocator
p->objCount = 1; // init number of objects using palette
@@ -337,7 +337,7 @@ PALQ *AllocPalette(SCNHANDLE hNewPal) {
UpdateDACqueueHandle(p->posInDAC, p->numColors, p->hPal);
// move all palettes after this one down (if necessary)
- for (pPrev = p, pNxtPal = pPrev + 1; pNxtPal < palAllocData + NUM_PALETTES; pNxtPal++) {
+ for (pPrev = p, pNxtPal = pPrev + 1; pNxtPal < g_palAllocData + NUM_PALETTES; pNxtPal++) {
if (pNxtPal->hPal != 0) {
// palette slot is in use
if (pNxtPal->posInDAC >= pPrev->posInDAC + pPrev->numColors)
@@ -381,7 +381,7 @@ PALQ *AllocPalette(SCNHANDLE hNewPal) {
*/
void FreePalette(PALQ *pFreePal) {
// validate palette Q pointer
- assert(pFreePal >= palAllocData && pFreePal <= palAllocData + NUM_PALETTES - 1);
+ assert(pFreePal >= g_palAllocData && pFreePal <= g_palAllocData + NUM_PALETTES - 1);
// reduce the palettes object reference count
pFreePal->objCount--;
@@ -408,7 +408,7 @@ PALQ *FindPalette(SCNHANDLE hSrchPal) {
PALQ *pPal; // palette allocator iterator
// search all structs in palette allocator
- for (pPal = palAllocData; pPal < palAllocData + NUM_PALETTES; pPal++) {
+ for (pPal = g_palAllocData; pPal < g_palAllocData + NUM_PALETTES; pPal++) {
if (pPal->hPal == hSrchPal)
// found palette in palette allocator
return pPal;
@@ -428,7 +428,7 @@ void SwapPalette(PALQ *pPalQ, SCNHANDLE hNewPal) {
PALETTE *pNewPal = (PALETTE *)LockMem(hNewPal);
// validate palette Q pointer
- assert(pPalQ >= palAllocData && pPalQ <= palAllocData + NUM_PALETTES - 1);
+ assert(pPalQ >= g_palAllocData && pPalQ <= g_palAllocData + NUM_PALETTES - 1);
if (pPalQ->numColors >= (int)FROM_LE_32(pNewPal->numColors)) {
// new palette will fit the slot
@@ -455,7 +455,7 @@ void SwapPalette(PALQ *pPalQ, SCNHANDLE hNewPal) {
PALQ *pNxtPalQ; // next palette queue position
- for (pNxtPalQ = pPalQ + 1; pNxtPalQ < palAllocData + NUM_PALETTES; pNxtPalQ++) {
+ for (pNxtPalQ = pPalQ + 1; pNxtPalQ < g_palAllocData + NUM_PALETTES; pNxtPalQ++) {
if (pNxtPalQ->posInDAC >= pPalQ->posInDAC + pPalQ->numColors)
// no need to move palettes down
break;
@@ -482,14 +482,14 @@ void SwapPalette(PALQ *pPalQ, SCNHANDLE hNewPal) {
PALQ *GetNextPalette(PALQ *pStrtPal) {
if (pStrtPal == NULL) {
// start of palette iteration - return 1st palette
- return (palAllocData[0].objCount) ? palAllocData : NULL;
+ return (g_palAllocData[0].objCount) ? g_palAllocData : NULL;
}
// validate palette Q pointer
- assert(pStrtPal >= palAllocData && pStrtPal <= palAllocData + NUM_PALETTES - 1);
+ assert(pStrtPal >= g_palAllocData && pStrtPal <= g_palAllocData + NUM_PALETTES - 1);
// return next active palette in list
- while (++pStrtPal < palAllocData + NUM_PALETTES) {
+ while (++pStrtPal < g_palAllocData + NUM_PALETTES) {
if (pStrtPal->objCount)
// active palette found
return pStrtPal;
@@ -515,7 +515,7 @@ void SetBgndColor(COLORREF color) {
*/
void FadingPalette(PALQ *pPalQ, bool bFading) {
// validate palette Q pointer
- assert(pPalQ >= palAllocData && pPalQ <= palAllocData + NUM_PALETTES - 1);
+ assert(pPalQ >= g_palAllocData && pPalQ <= g_palAllocData + NUM_PALETTES - 1);
// validate that this is a change
assert(pPalQ->bFading != bFading);
@@ -530,7 +530,7 @@ void FadingPalette(PALQ *pPalQ, bool bFading) {
void NoFadingPalettes() {
PALQ *pPalQ;
- for (pPalQ = palAllocData; pPalQ <= palAllocData + NUM_PALETTES - 1; pPalQ++) {
+ for (pPalQ = g_palAllocData; pPalQ <= g_palAllocData + NUM_PALETTES - 1; pPalQ++) {
pPalQ->bFading = false;
}
}
@@ -544,7 +544,7 @@ void CreateTranslucentPalette(SCNHANDLE hPalette) {
PALETTE *pPal = (PALETTE *)LockMem(hPalette);
// leave background color alone
- transPalette[0] = 0;
+ g_transPalette[0] = 0;
for (uint i = 0; i < FROM_LE_32(pPal->numColors); i++) {
// get the RGB color model values
@@ -558,7 +558,7 @@ void CreateTranslucentPalette(SCNHANDLE hPalette) {
// map the Value field to one of the 4 colors reserved for the translucent palette
val /= 63;
- transPalette[i + 1] = (uint8)((val == 0) ? 0 : val +
+ g_transPalette[i + 1] = (uint8)((val == 0) ? 0 : val +
(TinselV2 ? TranslucentColor() : COL_HILIGHT) - 1);
}
}
@@ -572,7 +572,7 @@ void CreateGhostPalette(SCNHANDLE hPalette) {
int i;
// leave background color alone
- ghostPalette[0] = 0;
+ g_ghostPalette[0] = 0;
for (i = 0; i < (int)FROM_LE_32(pPal->numColors); i++) {
// get the RGB color model values
@@ -587,7 +587,7 @@ void CreateGhostPalette(SCNHANDLE hPalette) {
// map the Value field to one of the 4 colors reserved for the translucent palette
val /= 64;
assert(/*val >= 0 &&*/ val <= 3);
- ghostPalette[i + 1] = (uint8)(val + SysVar(ISV_GHOST_BASE));
+ g_ghostPalette[i + 1] = (uint8)(val + SysVar(ISV_GHOST_BASE));
}
}
@@ -648,41 +648,41 @@ void DimPartPalette(SCNHANDLE hDimPal, int startColor, int length, int brightnes
}
int TranslucentColor() {
- return translucentIndex;
+ return g_translucentIndex;
}
int HighlightColor() {
- UpdateDACqueue(talkIndex, (COLORREF)SysVar(SYS_HighlightRGB));
+ UpdateDACqueue(g_talkIndex, (COLORREF)SysVar(SYS_HighlightRGB));
- return talkIndex;
+ return g_talkIndex;
}
int TalkColor() {
- return TinselV2 ? talkIndex : TALKFONT_COL;
+ return TinselV2 ? g_talkIndex : TALKFONT_COL;
}
void SetTalkColorRef(COLORREF colRef) {
- talkColRef = colRef;
+ g_talkColRef = colRef;
}
COLORREF GetTalkColorRef() {
- return talkColRef;
+ return g_talkColRef;
}
void SetTagColorRef(COLORREF colRef) {
- tagColRef = colRef;
+ g_tagColRef = colRef;
}
COLORREF GetTagColorRef() {
- return tagColRef;
+ return g_tagColRef;
}
void SetTranslucencyOffset(int offset) {
- translucentIndex = offset;
+ g_translucentIndex = offset;
}
void SetTalkTextOffset(int offset) {
- talkIndex = offset;
+ g_talkIndex = offset;
}
} // End of namespace Tinsel
diff --git a/engines/tinsel/pcode.cpp b/engines/tinsel/pcode.cpp
index 2ab1e653d4..145a6a8e5d 100644
--- a/engines/tinsel/pcode.cpp
+++ b/engines/tinsel/pcode.cpp
@@ -100,19 +100,19 @@ enum OPCODE {
#define OPMASK 0x3F ///< mask to isolate the opcode
-bool bNoPause = false;
+bool g_bNoPause = false;
//----------------- LOCAL GLOBAL DATA --------------------
// FIXME: Avoid non-const global vars
-static int32 *pGlobals = 0; // global vars
+static int32 *g_pGlobals = 0; // global vars
-static int numGlobals = 0; // How many global variables to save/restore
+static int g_numGlobals = 0; // How many global variables to save/restore
-static INT_CONTEXT *icList = 0;
+static INT_CONTEXT *g_icList = 0;
-static uint32 hMasterScript;
+static uint32 g_hMasterScript;
//----------------- SCRIPT BUGS WORKAROUNDS --------------
@@ -227,7 +227,7 @@ 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(hMasterScript);
+ ic->code = (byte *)LockMem(g_hMasterScript);
else
ic->code = (byte *)FindChunk(MASTER_SCNHANDLE, CHUNK_PCODE);
} else
@@ -241,7 +241,7 @@ static INT_CONTEXT *AllocateInterpretContext(GSORT gsort) {
INT_CONTEXT *pic;
int i;
- for (i = 0, pic = icList; i < NUM_INTERPRET; i++, pic++) {
+ for (i = 0, pic = g_icList; i < NUM_INTERPRET; i++, pic++) {
if (pic->GSort == GS_NONE) {
pic->pProc = g_scheduler->getCurrentProcess();
pic->GSort = gsort;
@@ -264,8 +264,8 @@ static void FreeWaitCheck(PINT_CONTEXT pic, bool bVoluntary) {
// Is this waiting for something?
if (pic->waitNumber1) {
for (i = 0; i < NUM_INTERPRET; i++) {
- if ((icList + i)->waitNumber2 == pic->waitNumber1) {
- (icList + i)->waitNumber2 = 0;
+ if ((g_icList + i)->waitNumber2 == pic->waitNumber1) {
+ (g_icList + i)->waitNumber2 = 0;
break;
}
}
@@ -274,10 +274,10 @@ static void FreeWaitCheck(PINT_CONTEXT pic, bool bVoluntary) {
// Is someone waiting for this?
if (pic->waitNumber2) {
for (i = 0; i < NUM_INTERPRET; i++) {
- if ((icList + i)->waitNumber1 == pic->waitNumber2) {
- (icList + i)->waitNumber1 = 0;
- (icList + i)->resumeCode = bVoluntary ? RES_FINISHED : RES_CUTSHORT;
- g_scheduler->reschedule((icList + i)->pProc);
+ if ((g_icList + i)->waitNumber1 == pic->waitNumber2) {
+ (g_icList + i)->waitNumber1 = 0;
+ (g_icList + i)->resumeCode = bVoluntary ? RES_FINISHED : RES_CUTSHORT;
+ g_scheduler->reschedule((g_icList + i)->pProc);
break;
}
}
@@ -305,7 +305,7 @@ void FreeInterpretContextPr(PROCESS *pProc) {
INT_CONTEXT *pic;
int i;
- for (i = 0, pic = icList; i < NUM_INTERPRET; i++, pic++) {
+ for (i = 0, pic = g_icList; i < NUM_INTERPRET; i++, pic++) {
if (pic->GSort != GS_NONE && pic->pProc == pProc) {
FreeWaitCheck(pic, false);
if (TinselV2)
@@ -323,7 +323,7 @@ void FreeMostInterpretContexts() {
INT_CONTEXT *pic;
int i;
- for (i = 0, pic = icList; i < NUM_INTERPRET; i++, pic++) {
+ for (i = 0, pic = g_icList; i < NUM_INTERPRET; i++, pic++) {
if ((pic->GSort != GS_MASTER) && (pic->GSort != GS_GPROCESS)) {
memset(pic, 0, sizeof(INT_CONTEXT));
pic->GSort = GS_NONE;
@@ -338,7 +338,7 @@ void FreeMasterInterpretContext() {
INT_CONTEXT *pic;
int i;
- for (i = 0, pic = icList; i < NUM_INTERPRET; i++, pic++) {
+ for (i = 0, pic = g_icList; i < NUM_INTERPRET; i++, pic++) {
if ((pic->GSort == GS_MASTER) || (pic->GSort == GS_GPROCESS)) {
memset(pic, 0, sizeof(INT_CONTEXT));
pic->GSort = GS_NONE;
@@ -405,30 +405,30 @@ INT_CONTEXT *RestoreInterpretContext(INT_CONTEXT *ric) {
* Allocates enough RAM to hold the global Glitter variables.
*/
void RegisterGlobals(int num) {
- if (pGlobals == NULL) {
- numGlobals = num;
+ if (g_pGlobals == NULL) {
+ g_numGlobals = num;
- hMasterScript = !TinselV2 ? 0 :
+ g_hMasterScript = !TinselV2 ? 0 :
READ_LE_UINT32(FindChunk(MASTER_SCNHANDLE, CHUNK_MASTER_SCRIPT));
// Allocate RAM for pGlobals and make sure it's allocated
- pGlobals = (int32 *)calloc(numGlobals, sizeof(int32));
- if (pGlobals == NULL) {
+ g_pGlobals = (int32 *)calloc(g_numGlobals, sizeof(int32));
+ if (g_pGlobals == NULL) {
error("Cannot allocate memory for global data");
}
// Allocate RAM for interpret contexts and make sure it's allocated
- icList = (INT_CONTEXT *)calloc(NUM_INTERPRET, sizeof(INT_CONTEXT));
- if (icList == NULL) {
+ g_icList = (INT_CONTEXT *)calloc(NUM_INTERPRET, sizeof(INT_CONTEXT));
+ if (g_icList == NULL) {
error("Cannot allocate memory for interpret contexts");
}
g_scheduler->setResourceCallback(FreeInterpretContextPr);
} else {
// Check size is still the same
- assert(numGlobals == num);
+ assert(g_numGlobals == num);
- memset(pGlobals, 0, numGlobals * sizeof(int32));
- memset(icList, 0, NUM_INTERPRET * sizeof(INT_CONTEXT));
+ memset(g_pGlobals, 0, g_numGlobals * sizeof(int32));
+ memset(g_icList, 0, NUM_INTERPRET * sizeof(INT_CONTEXT));
}
if (TinselV2) {
@@ -444,7 +444,7 @@ void RegisterGlobals(int num) {
error(FILE_IS_CORRUPT, GLOBALS_FILENAME);
for (int i = 0; i < length; ++i)
- pGlobals[i] = f.readSint32LE();
+ g_pGlobals[i] = f.readSint32LE();
if (f.eos() || f.err())
error(FILE_IS_CORRUPT, GLOBALS_FILENAME);
@@ -454,19 +454,19 @@ void RegisterGlobals(int num) {
}
void FreeGlobals() {
- free(pGlobals);
- pGlobals = NULL;
+ free(g_pGlobals);
+ g_pGlobals = NULL;
- free(icList);
- icList = NULL;
+ free(g_icList);
+ g_icList = NULL;
}
/**
* (Un)serialize the global data for save/restore game.
*/
void syncGlobInfo(Common::Serializer &s) {
- for (int i = 0; i < numGlobals; i++) {
- s.syncAsSint32LE(pGlobals[i]);
+ for (int i = 0; i < g_numGlobals; i++) {
+ s.syncAsSint32LE(g_pGlobals[i]);
}
}
@@ -502,7 +502,7 @@ void INT_CONTEXT::syncWithSerializer(Common::Serializer &s) {
* Return pointer to and size of global data for save/restore game.
*/
void SaveInterpretContexts(INT_CONTEXT *sICInfo) {
- memcpy(sICInfo, icList, NUM_INTERPRET * sizeof(INT_CONTEXT));
+ memcpy(sICInfo, g_icList, NUM_INTERPRET * sizeof(INT_CONTEXT));
}
/**
@@ -633,8 +633,8 @@ void Interpret(CORO_PARAM, INT_CONTEXT *ic) {
case OP_GLOAD: // loads global variable onto stack
tmp = Fetch(opcode, ic->code, wkEntry, ip);
- assert(0 <= tmp && tmp < numGlobals);
- ic->stack[++ic->sp] = pGlobals[tmp];
+ assert(0 <= tmp && tmp < g_numGlobals);
+ ic->stack[++ic->sp] = g_pGlobals[tmp];
break;
case OP_STORE: // pops stack and stores in local variable
@@ -645,8 +645,8 @@ void Interpret(CORO_PARAM, INT_CONTEXT *ic) {
case OP_GSTORE: // pops stack and stores in global variable
tmp = Fetch(opcode, ic->code, wkEntry, ip);
- assert(0 <= tmp && tmp < numGlobals);
- pGlobals[tmp] = ic->stack[ic->sp--];
+ assert(0 <= tmp && tmp < g_numGlobals);
+ g_pGlobals[tmp] = ic->stack[ic->sp--];
break;
case OP_CALL: // procedure call
@@ -809,7 +809,7 @@ void Interpret(CORO_PARAM, INT_CONTEXT *ic) {
break;
case OP_ESCON:
- bNoPause = true;
+ g_bNoPause = true;
ic->escOn = true;
ic->myEscape = GetEscEvents();
break;
@@ -856,8 +856,8 @@ static uint32 UniqueWaitNumber() {
retval = (uint32)-1;
for (i = 0; i < NUM_INTERPRET; i++) {
- if ((icList+i)->waitNumber1 == retval
- || (icList+i)->waitNumber2 == retval)
+ if ((g_icList+i)->waitNumber1 == retval
+ || (g_icList+i)->waitNumber2 == retval)
break;
}
@@ -887,7 +887,7 @@ void WaitInterpret(CORO_PARAM, PPROCESS pWaitProc, bool *result) {
CORO_BEGIN_CODE(_ctx);
- for (i = 0, _ctx->picWaiter = icList; i < NUM_INTERPRET; i++, _ctx->picWaiter++) {
+ for (i = 0, _ctx->picWaiter = g_icList; i < NUM_INTERPRET; i++, _ctx->picWaiter++) {
if (_ctx->picWaiter->GSort != GS_NONE && _ctx->picWaiter->pProc == currentProcess) {
break;
}
@@ -896,7 +896,7 @@ void WaitInterpret(CORO_PARAM, PPROCESS pWaitProc, bool *result) {
/*
* Find the interpret context of the process we're waiting for
*/
- for (i = 0, _ctx->picWaitee = icList; i < NUM_INTERPRET; i++, _ctx->picWaitee++) {
+ for (i = 0, _ctx->picWaitee = g_icList; i < NUM_INTERPRET; i++, _ctx->picWaitee++) {
if (_ctx->picWaitee->GSort != GS_NONE && _ctx->picWaitee->pProc == pWaitProc) {
break;
}
@@ -931,11 +931,11 @@ void CheckOutWaiters() {
// Check all waited for have someone waiting
for (i = 0; i < NUM_INTERPRET; i++) {
// If someone is supposedly waiting for this one
- if ((icList + i)->GSort != GS_NONE && (icList + i)->waitNumber2) {
+ if ((g_icList + i)->GSort != GS_NONE && (g_icList + i)->waitNumber2) {
// Someone really must be waiting for this one
for (j = 0; j < NUM_INTERPRET; j++) {
- if ((icList + j)->GSort != GS_NONE
- && (icList + j)->waitNumber1 == (icList + i)->waitNumber2) {
+ if ((g_icList + j)->GSort != GS_NONE
+ && (g_icList + j)->waitNumber1 == (g_icList + i)->waitNumber2) {
break;
}
}
@@ -946,11 +946,11 @@ void CheckOutWaiters() {
// Check waiting for someone to wait for
for (i = 0; i < NUM_INTERPRET; i++) {
// If someone is supposedly waiting for this one
- if ((icList + i)->GSort != GS_NONE && (icList + i)->waitNumber1) {
+ if ((g_icList + i)->GSort != GS_NONE && (g_icList + i)->waitNumber1) {
// Someone really must be waiting for this one
for (j = 0; j < NUM_INTERPRET; j++) {
- if ((icList + j)->GSort != GS_NONE
- && (icList + j)->waitNumber2 == (icList + i)->waitNumber1) {
+ if ((g_icList + j)->GSort != GS_NONE
+ && (g_icList + j)->waitNumber2 == (g_icList + i)->waitNumber1) {
break;
}
}
diff --git a/engines/tinsel/pdisplay.cpp b/engines/tinsel/pdisplay.cpp
index 7439c6f77d..9a9e6ab00f 100644
--- a/engines/tinsel/pdisplay.cpp
+++ b/engines/tinsel/pdisplay.cpp
@@ -50,7 +50,7 @@ namespace Tinsel {
#ifdef DEBUG
//extern int Overrun; // The overrun counter, in DOS_DW.C
-extern int newestString; // The overrun counter, in STRRES.C
+extern int g_newestString; // The overrun counter, in STRRES.C
#endif
@@ -73,17 +73,17 @@ enum HotSpotTag {
// FIXME: Avoid non-const global vars
-static bool DispPath = false;
-static bool bShowString = false;
+static bool g_DispPath = false;
+static bool g_bShowString = false;
-static int TaggedActor = 0;
-static HPOLYGON hTaggedPolygon = NOPOLY;
+static int g_TaggedActor = 0;
+static HPOLYGON g_hTaggedPolygon = NOPOLY;
-static bool bTagsActive = true;
+static bool g_bTagsActive = true;
-static bool bPointingActive = true;
+static bool g_bPointingActive = true;
-static char tagBuffer[64];
+static char g_tagBuffer[64];
#ifdef DEBUG
/**
@@ -158,7 +158,7 @@ void CursorPositionProcess(CORO_PARAM, const void *) {
sprintf(PositionString, "%d %d", aniX + Loffset, aniY + Toffset);
_ctx->cpText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), PositionString,
0, CPOSX, POSY, GetTagFontHandle(), TXT_CENTER);
- if (DispPath) {
+ if (g_DispPath) {
HPOLYGON hp = InPolygon(aniX + Loffset, aniY + Toffset, PATH);
if (hp == NOPOLY)
sprintf(PositionString, "No path");
@@ -226,18 +226,18 @@ void CursorPositionProcess(CORO_PARAM, const void *) {
/*-------------*\
| String number |
\*-------------*/
- if (bShowString && newestString != _ctx->prevString) {
+ if (g_bShowString && g_newestString != _ctx->prevString) {
// kill current text objects
if (_ctx->spText) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->spText);
}
- sprintf(PositionString, "String: %d", newestString);
+ sprintf(PositionString, "String: %d", g_newestString);
_ctx->spText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), PositionString,
0, SPOSX, POSY+10, GetTalkFontHandle(), TXT_CENTER);
// update previous value
- _ctx->prevString = newestString;
+ _ctx->prevString = g_newestString;
}
// update previous playfield position
@@ -257,7 +257,7 @@ void DisablePointing() {
int i;
HPOLYGON hPoly; // Polygon handle
- bPointingActive = false;
+ g_bPointingActive = false;
for (i = 0; i < MAX_POLY; i++) {
hPoly = GetPolyHandle(i);
@@ -284,7 +284,7 @@ void DisablePointing() {
* EnablePointing()
*/
void EnablePointing() {
- bPointingActive = true;
+ g_bPointingActive = true;
}
/**
@@ -292,7 +292,7 @@ void EnablePointing() {
* (if one is). Tag process asks us for this information, as does ProcessUserEvent().
*/
static void SaveTaggedActor(int ano) {
- TaggedActor = ano;
+ g_TaggedActor = ano;
}
/**
@@ -300,7 +300,7 @@ static void SaveTaggedActor(int ano) {
* (if one is). Tag process asks us for this information, as does ProcessUserEvent().
*/
int GetTaggedActor() {
- return TaggedActor;
+ return g_TaggedActor;
}
/**
@@ -308,11 +308,11 @@ int GetTaggedActor() {
* (if one is). Tag process asks us for this information, as does ProcessUserEvent().
*/
static void SaveTaggedPoly(HPOLYGON hp) {
- hTaggedPolygon = hp;
+ g_hTaggedPolygon = hp;
}
HPOLYGON GetTaggedPoly() {
- return hTaggedPolygon;
+ return g_hTaggedPolygon;
}
/**
@@ -405,11 +405,11 @@ static bool ActorTag(int curX, int curY, HotSpotTag *pTag, OBJECT **ppText) {
if (ActorTagIsWanted(actor)) {
GetActorTagPos(actor, &tagX, &tagY, false);
- LoadStringRes(GetActorTagHandle(actor), tagBuffer, sizeof(tagBuffer));
+ LoadStringRes(GetActorTagHandle(actor), g_tagBuffer, sizeof(g_tagBuffer));
// May have buggered cursor
EndCursorFollowed();
- *ppText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), tagBuffer,
+ *ppText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), g_tagBuffer,
0, tagX, tagY, GetTagFontHandle(), TXT_CENTER, 0);
assert(*ppText);
MultiSetZPosition(*ppText, Z_TAG_TEXT);
@@ -653,7 +653,7 @@ void TagProcess(CORO_PARAM, const void *) {
SaveTaggedPoly(NOPOLY); // No tagged polygon yet
while (1) {
- if (bTagsActive) {
+ if (g_bTagsActive) {
int curX, curY; // cursor position
while (!GetCursorXYNoWait(&curX, &curY, true))
CORO_SLEEP(1);
@@ -804,7 +804,7 @@ void PointProcess(CORO_PARAM, const void *) {
// allow re-scheduling
do {
CORO_SLEEP(1);
- } while (!bPointingActive);
+ } while (!g_bPointingActive);
} else {
// allow re-scheduling
CORO_SLEEP(1);
@@ -815,15 +815,15 @@ void PointProcess(CORO_PARAM, const void *) {
}
void DisableTags() {
- bTagsActive = false;
+ g_bTagsActive = false;
}
void EnableTags() {
- bTagsActive = true;
+ g_bTagsActive = true;
}
bool DisableTagsIfEnabled() {
- if (bTagsActive) {
+ if (g_bTagsActive) {
DisableTags();
return true;
} else
@@ -836,12 +836,12 @@ bool DisableTagsIfEnabled() {
* cursor is in.
*/
void TogglePathDisplay() {
- DispPath ^= 1; // Toggle path display (XOR with true)
+ g_DispPath ^= 1; // Toggle path display (XOR with true)
}
void setshowstring() {
- bShowString = true;
+ g_bShowString = true;
}
} // End of namespace Tinsel
diff --git a/engines/tinsel/play.cpp b/engines/tinsel/play.cpp
index 71e07721a6..40729d9f3a 100644
--- a/engines/tinsel/play.cpp
+++ b/engines/tinsel/play.cpp
@@ -62,10 +62,10 @@ struct PPINIT {
// FIXME: Avoid non-const global vars
-static SOUNDREELS soundReels[MAX_SOUNDREELS];
-static int soundReelNumbers[MAX_SOUNDREELS];
+static SOUNDREELS g_soundReels[MAX_SOUNDREELS];
+static int g_soundReelNumbers[MAX_SOUNDREELS];
-static int soundReelWait;
+static int g_soundReelWait;
//-------------------- METHODS ----------------------
@@ -148,31 +148,31 @@ static int RegisterSoundReel(SCNHANDLE hFilm, int column, int actorCol) {
for (i = 0; i < MAX_SOUNDREELS; i++) {
// Should assert this doesn't happen, but let's be tolerant
- if (soundReels[i].hFilm == hFilm && soundReels[i].column == column)
+ if (g_soundReels[i].hFilm == hFilm && g_soundReels[i].column == column)
break;
- if (!soundReels[i].hFilm) {
- soundReels[i].hFilm = hFilm;
- soundReels[i].column = column;
- soundReels[i].actorCol = actorCol;
+ if (!g_soundReels[i].hFilm) {
+ g_soundReels[i].hFilm = hFilm;
+ g_soundReels[i].column = column;
+ g_soundReels[i].actorCol = actorCol;
break;
}
}
- soundReelNumbers[i]++;
+ g_soundReelNumbers[i]++;
return i;
}
void NoSoundReels() {
- memset(soundReels, 0, sizeof(soundReels));
- soundReelWait = 0;
+ memset(g_soundReels, 0, sizeof(g_soundReels));
+ g_soundReelWait = 0;
}
static void DeRegisterSoundReel(SCNHANDLE hFilm, int column) {
for (int i = 0; i < MAX_SOUNDREELS; i++) {
// Should assert this doesn't happen, but let's be tolerant
- if (soundReels[i].hFilm == hFilm && soundReels[i].column == column) {
- soundReels[i].hFilm = 0;
+ if (g_soundReels[i].hFilm == hFilm && g_soundReels[i].column == column) {
+ g_soundReels[i].hFilm = 0;
break;
}
}
@@ -180,15 +180,15 @@ static void DeRegisterSoundReel(SCNHANDLE hFilm, int column) {
void SaveSoundReels(PSOUNDREELS psr) {
for (int i = 0; i < MAX_SOUNDREELS; i++) {
- if (IsCdPlayHandle(soundReels[i].hFilm))
- soundReels[i].hFilm = 0;
+ if (IsCdPlayHandle(g_soundReels[i].hFilm))
+ g_soundReels[i].hFilm = 0;
}
- memcpy(psr, soundReels, sizeof(soundReels));
+ memcpy(psr, g_soundReels, sizeof(g_soundReels));
}
void RestoreSoundReels(PSOUNDREELS psr) {
- memcpy(soundReels, psr, sizeof(soundReels));
+ memcpy(g_soundReels, psr, sizeof(g_soundReels));
}
static uint32 GetZfactor(int actorID, PMOVER pMover, bool bNewMover) {
@@ -245,7 +245,7 @@ static void SoundReel(CORO_PARAM, SCNHANDLE hFilm, int column, int speed,
_ctx->bFinished = false;
_ctx->bLooped = false;
_ctx->myId = RegisterSoundReel(hFilm, column, actorCol);
- _ctx->myNum = soundReelNumbers[_ctx->myId];
+ _ctx->myNum = g_soundReelNumbers[_ctx->myId];
do {
pFilm = (FILM *)LockMem(hFilm);
@@ -366,10 +366,10 @@ static void SoundReel(CORO_PARAM, SCNHANDLE hFilm, int column, int speed,
_ctx->bFinished = true;
}
- } while (!_ctx->bFinished && _ctx->myNum == soundReelNumbers[_ctx->myId]);
+ } while (!_ctx->bFinished && _ctx->myNum == g_soundReelNumbers[_ctx->myId]);
// De-register - if not been replaced
- if (_ctx->myNum == soundReelNumbers[_ctx->myId])
+ if (_ctx->myNum == g_soundReelNumbers[_ctx->myId])
DeRegisterSoundReel(hFilm, column);
CORO_END_CODE;
@@ -384,17 +384,17 @@ static void ResSoundReel(CORO_PARAM, const void *param) {
CORO_BEGIN_CODE(_ctx);
- CORO_INVOKE_ARGS(SoundReel, (CORO_SUBCTX, soundReels[i].hFilm, soundReels[i].column,
- -1, 0, soundReels[i].actorCol));
+ CORO_INVOKE_ARGS(SoundReel, (CORO_SUBCTX, g_soundReels[i].hFilm, g_soundReels[i].column,
+ -1, 0, g_soundReels[i].actorCol));
CORO_KILL_SELF();
CORO_END_CODE;
}
static void SoundReelWaitCheck() {
- if (--soundReelWait == 0) {
+ if (--g_soundReelWait == 0) {
for (int i = 0; i < MAX_SOUNDREELS; i++) {
- if (soundReels[i].hFilm) {
+ if (g_soundReels[i].hFilm) {
g_scheduler->createProcess(PID_REEL, ResSoundReel, &i, sizeof(i));
}
}
@@ -1162,7 +1162,7 @@ void RestoreActorReels(SCNHANDLE hFilm, int actor, int x, int y) {
// Start display process for the reel
g_scheduler->createProcess(PID_REEL, PlayProcess, &ppi, sizeof(ppi));
- soundReelWait++;
+ g_soundReelWait++;
}
}
}
diff --git a/engines/tinsel/rince.cpp b/engines/tinsel/rince.cpp
index ca196aac92..bb0aeabd2f 100644
--- a/engines/tinsel/rince.cpp
+++ b/engines/tinsel/rince.cpp
@@ -51,7 +51,7 @@ namespace Tinsel {
//----------------- LOCAL GLOBAL DATA --------------------
-static MOVER Movers[MAX_MOVERS]; // FIXME: Avoid non-const global vars
+static MOVER g_Movers[MAX_MOVERS]; // FIXME: Avoid non-const global vars
//----------------- FUNCTIONS ----------------------------
@@ -115,7 +115,7 @@ void MoverBrightness(PMOVER pMover, int brightness) {
* RebootMovers
*/
void RebootMovers() {
- memset(Movers, 0, sizeof(Movers));
+ memset(g_Movers, 0, sizeof(g_Movers));
}
/**
@@ -127,11 +127,11 @@ PMOVER GetMover(int ano) {
// Slot 0 is reserved for lead actor
if (ano == GetLeadId() || ano == LEAD_ACTOR)
- return &Movers[0];
+ return &g_Movers[0];
for (i = 1; i < MAX_MOVERS; i++)
- if (Movers[i].actorID == ano)
- return &Movers[i];
+ if (g_Movers[i].actorID == ano)
+ return &g_Movers[i];
return NULL;
}
@@ -144,25 +144,25 @@ PMOVER RegisterMover(int ano) {
// Slot 0 is reserved for lead actor
if (ano == GetLeadId() || ano == LEAD_ACTOR) {
- Movers[0].actorToken = TOKEN_LEAD;
- Movers[0].actorID = GetLeadId();
- return &Movers[0];
+ g_Movers[0].actorToken = TOKEN_LEAD;
+ g_Movers[0].actorID = GetLeadId();
+ return &g_Movers[0];
}
// Check it hasn't already been declared
for (i = 1; i < MAX_MOVERS; i++) {
- if (Movers[i].actorID == ano) {
+ if (g_Movers[i].actorID == ano) {
// Actor is already a moving actor
- return &Movers[i];
+ return &g_Movers[i];
}
}
// Find an empty slot
for (i = 1; i < MAX_MOVERS; i++)
- if (!Movers[i].actorID) {
- Movers[i].actorToken = TOKEN_LEAD + i;
- Movers[i].actorID = ano;
- return &Movers[i];
+ if (!g_Movers[i].actorID) {
+ g_Movers[i].actorToken = TOKEN_LEAD + i;
+ g_Movers[i].actorID = ano;
+ return &g_Movers[i];
}
error("Too many moving actors");
@@ -176,8 +176,8 @@ PMOVER RegisterMover(int ano) {
PMOVER GetLiveMover(int index) {
assert(index >= 0 && index < MAX_MOVERS); // out of range
- if (Movers[index].bActive)
- return &Movers[index];
+ if (g_Movers[index].bActive)
+ return &g_Movers[index];
else
return NULL;
}
@@ -185,13 +185,13 @@ PMOVER GetLiveMover(int index) {
bool IsMAinEffectPoly(int index) {
assert(index >= 0 && index < MAX_MOVERS); // out of range
- return Movers[index].bInEffect;
+ return g_Movers[index].bInEffect;
}
void SetMoverInEffect(int index, bool tf) {
assert(index >= 0 && index < MAX_MOVERS); // out of range
- Movers[index].bInEffect = tf;
+ g_Movers[index].bInEffect = tf;
}
/**
@@ -392,7 +392,7 @@ static void InitMover(PMOVER pMover) {
*/
void DropMovers() {
for (int i = 0; i < MAX_MOVERS; i++)
- InitMover(&Movers[i]);
+ InitMover(&g_Movers[i]);
}
@@ -880,30 +880,30 @@ PMOVER InMoverBlock(PMOVER pMover, int x, int y) {
caR = GetMoverRight(pMover) + x - caX;
for (int i = 0; i < MAX_MOVERS; i++) {
- if (pMover == &Movers[i] ||
- (TinselV2 && (Movers[i].actorObj == NULL)) ||
- (!TinselV2 && !Movers[i].bActive))
+ if (pMover == &g_Movers[i] ||
+ (TinselV2 && (g_Movers[i].actorObj == NULL)) ||
+ (!TinselV2 && !g_Movers[i].bActive))
continue;
// At around the same height?
- GetMoverPosition(&Movers[i], &taX, &taY);
- if (Movers[i].hFnpath != NOPOLY)
+ GetMoverPosition(&g_Movers[i], &taX, &taY);
+ if (g_Movers[i].hFnpath != NOPOLY)
continue;
if (ABS(y - taY) > 2) // 2 was 8
continue;
// To the left?
- taL = GetMoverLeft(&Movers[i]);
+ taL = GetMoverLeft(&g_Movers[i]);
if (caR <= taL)
continue;
// To the right?
- taR = GetMoverRight(&Movers[i]);
+ taR = GetMoverRight(&g_Movers[i]);
if (caL >= taR)
continue;
- return &Movers[i];
+ return &g_Movers[i];
}
return NULL;
}
@@ -913,33 +913,33 @@ PMOVER InMoverBlock(PMOVER pMover, int x, int y) {
*/
void SaveMovers(SAVED_MOVER *sMoverInfo) {
for (int i = 0; i < MAX_MOVERS; i++) {
- sMoverInfo[i].bActive = !TinselV2 ? Movers[i].bActive : Movers[i].actorObj != NULL;
- sMoverInfo[i].actorID = Movers[i].actorID;
- sMoverInfo[i].objX = Movers[i].objX;
- sMoverInfo[i].objY = Movers[i].objY;
- sMoverInfo[i].hLastfilm = Movers[i].hLastFilm;
+ sMoverInfo[i].bActive = !TinselV2 ? g_Movers[i].bActive : g_Movers[i].actorObj != NULL;
+ sMoverInfo[i].actorID = g_Movers[i].actorID;
+ sMoverInfo[i].objX = g_Movers[i].objX;
+ sMoverInfo[i].objY = g_Movers[i].objY;
+ sMoverInfo[i].hLastfilm = g_Movers[i].hLastFilm;
if (TinselV2) {
- sMoverInfo[i].bHidden = Movers[i].bHidden;
- sMoverInfo[i].brightness = Movers[i].brightness;
- sMoverInfo[i].startColor = Movers[i].startColor;
- sMoverInfo[i].paletteLength = Movers[i].paletteLength;
+ sMoverInfo[i].bHidden = g_Movers[i].bHidden;
+ sMoverInfo[i].brightness = g_Movers[i].brightness;
+ sMoverInfo[i].startColor = g_Movers[i].startColor;
+ sMoverInfo[i].paletteLength = g_Movers[i].paletteLength;
}
- memcpy(sMoverInfo[i].walkReels, Movers[i].walkReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE));
- memcpy(sMoverInfo[i].standReels, Movers[i].standReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE));
- memcpy(sMoverInfo[i].talkReels, Movers[i].talkReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE));
+ memcpy(sMoverInfo[i].walkReels, g_Movers[i].walkReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE));
+ memcpy(sMoverInfo[i].standReels, g_Movers[i].standReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE));
+ memcpy(sMoverInfo[i].talkReels, g_Movers[i].talkReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE));
}
}
void RestoreAuxScales(SAVED_MOVER *sMoverInfo) {
for (int i = 0; i < MAX_MOVERS; i++) {
if (TinselV2)
- Movers[i].actorID = sMoverInfo[i].actorID;
+ g_Movers[i].actorID = sMoverInfo[i].actorID;
- memcpy(Movers[i].walkReels, sMoverInfo[i].walkReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE));
- memcpy(Movers[i].standReels, sMoverInfo[i].standReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE));
- memcpy(Movers[i].talkReels, sMoverInfo[i].talkReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE));
+ memcpy(g_Movers[i].walkReels, sMoverInfo[i].walkReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE));
+ memcpy(g_Movers[i].standReels, sMoverInfo[i].standReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE));
+ memcpy(g_Movers[i].talkReels, sMoverInfo[i].talkReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE));
}
}
@@ -950,10 +950,10 @@ PMOVER NextMover(PMOVER pMover) {
if (pMover == NULL)
next = 0;
else
- next = pMover - Movers + 1;
+ next = pMover - g_Movers + 1;
- if (Movers[next].actorID)
- return &Movers[next];
+ if (g_Movers[next].actorID)
+ return &g_Movers[next];
else
return NULL;
}
diff --git a/engines/tinsel/saveload.cpp b/engines/tinsel/saveload.cpp
index f8598c05f8..0a552c8c2b 100644
--- a/engines/tinsel/saveload.cpp
+++ b/engines/tinsel/saveload.cpp
@@ -68,9 +68,9 @@ namespace Tinsel {
//----------------- GLOBAL GLOBAL DATA --------------------
-int thingHeld = 0;
-int restoreCD = 0;
-SRSTATE SRstate = SR_IDLE;
+int g_thingHeld = 0;
+int g_restoreCD = 0;
+SRSTATE g_SRstate = SR_IDLE;
//----------------- EXTERN FUNCTIONS --------------------
@@ -83,9 +83,9 @@ extern void syncGlobInfo(Common::Serializer &s);
// in POLYGONS.C
extern void syncPolyInfo(Common::Serializer &s);
-extern int sceneCtr;
+extern int g_sceneCtr;
-extern bool ASceneIsSaved;
+extern bool g_ASceneIsSaved;
//----------------- LOCAL DEFINES --------------------
@@ -123,21 +123,23 @@ struct SFILES {
// FIXME: Avoid non-const global vars
-static int numSfiles = 0;
-static SFILES savedFiles[MAX_SAVED_FILES];
+static int g_numSfiles = 0;
+static SFILES g_savedFiles[MAX_SAVED_FILES];
-static bool NeedLoad = true;
+static bool g_NeedLoad = true;
-static SAVED_DATA *srsd = 0;
-static int RestoreGameNumber = 0;
-static char *SaveSceneName = 0;
-static const char *SaveSceneDesc = 0;
-static int *SaveSceneSsCount = 0;
-static SAVED_DATA *SaveSceneSsData = 0; // points to 'SAVED_DATA ssdata[MAX_NEST]'
+static SAVED_DATA *g_srsd = 0;
+static int g_RestoreGameNumber = 0;
+static char *g_SaveSceneName = 0;
+static const char *g_SaveSceneDesc = 0;
+static int *g_SaveSceneSsCount = 0;
+static SAVED_DATA *g_SaveSceneSsData = 0; // points to 'SAVED_DATA ssdata[MAX_NEST]'
//------------- SAVE/LOAD SUPPORT METHODS ----------------
-void setNeedLoad() { NeedLoad = true; }
+void setNeedLoad() {
+ g_NeedLoad = true;
+}
static void syncTime(Common::Serializer &s, TimeDate &t) {
s.syncAsUint16LE(t.tm_year);
@@ -345,18 +347,18 @@ static int cmpTimeDate(const TimeDate &a, const TimeDate &b) {
int getList(Common::SaveFileManager *saveFileMan, const Common::String &target) {
// No change since last call?
// TODO/FIXME: Just always reload this data? Be careful about slow downs!!!
- if (!NeedLoad)
- return numSfiles;
+ if (!g_NeedLoad)
+ return g_numSfiles;
int i;
const Common::String pattern = target + ".???";
Common::StringArray files = saveFileMan->listSavefiles(pattern);
- numSfiles = 0;
+ g_numSfiles = 0;
for (Common::StringArray::const_iterator file = files.begin(); file != files.end(); ++file) {
- if (numSfiles >= MAX_SAVED_FILES)
+ if (g_numSfiles >= MAX_SAVED_FILES)
break;
const Common::String &fname = *file;
@@ -376,46 +378,46 @@ int getList(Common::SaveFileManager *saveFileMan, const Common::String &target)
// "incompatible version".
}
- i = numSfiles;
+ i = g_numSfiles;
#ifndef DISABLE_SAVEGAME_SORTING
- for (i = 0; i < numSfiles; i++) {
- if (cmpTimeDate(hdr.dateTime, savedFiles[i].dateTime) > 0) {
- Common::copy_backward(&savedFiles[i], &savedFiles[numSfiles], &savedFiles[numSfiles + 1]);
+ for (i = 0; i < g_numSfiles; i++) {
+ if (cmpTimeDate(hdr.dateTime, g_savedFiles[i].dateTime) > 0) {
+ Common::copy_backward(&g_savedFiles[i], &g_savedFiles[g_numSfiles], &g_savedFiles[g_numSfiles + 1]);
break;
}
}
#endif
- Common::strlcpy(savedFiles[i].name, fname.c_str(), FNAMELEN);
- Common::strlcpy(savedFiles[i].desc, hdr.desc, SG_DESC_LEN);
- savedFiles[i].dateTime = hdr.dateTime;
+ Common::strlcpy(g_savedFiles[i].name, fname.c_str(), FNAMELEN);
+ Common::strlcpy(g_savedFiles[i].desc, hdr.desc, SG_DESC_LEN);
+ g_savedFiles[i].dateTime = hdr.dateTime;
- ++numSfiles;
+ ++g_numSfiles;
}
// Next getList() needn't do its stuff again
- NeedLoad = false;
+ g_NeedLoad = false;
- return numSfiles;
+ return g_numSfiles;
}
int getList() {
// No change since last call?
// TODO/FIXME: Just always reload this data? Be careful about slow downs!!!
- if (!NeedLoad)
- return numSfiles;
+ if (!g_NeedLoad)
+ return g_numSfiles;
return getList(_vm->getSaveFileMan(), _vm->getTargetName());
}
char *ListEntry(int i, letype which) {
if (i == -1)
- i = numSfiles;
+ i = g_numSfiles;
assert(i >= 0);
- if (i < numSfiles)
- return which == LE_NAME ? savedFiles[i].name : savedFiles[i].desc;
+ if (i < g_numSfiles)
+ return which == LE_NAME ? g_savedFiles[i].name : g_savedFiles[i].desc;
else
return NULL;
}
@@ -425,14 +427,14 @@ static void DoSync(Common::Serializer &s) {
if (TinselV2) {
if (s.isSaving())
- restoreCD = GetCurrentCD();
- s.syncAsSint16LE(restoreCD);
+ g_restoreCD = GetCurrentCD();
+ s.syncAsSint16LE(g_restoreCD);
}
if (TinselV2 && s.isLoading())
HoldItem(INV_NOICON);
- syncSavedData(s, *srsd);
+ syncSavedData(s, *g_srsd);
syncGlobInfo(s); // Glitter globals
syncInvInfo(s); // Inventory data
@@ -442,7 +444,7 @@ static void DoSync(Common::Serializer &s) {
s.syncAsSint32LE(sg);
if (s.isLoading()) {
if (TinselV2)
- thingHeld = sg;
+ g_thingHeld = sg;
else
HoldItem(sg);
}
@@ -452,17 +454,17 @@ static void DoSync(Common::Serializer &s) {
syncPolyInfo(s); // Dead polygon data
syncSCdata(s); // Hook Scene and delayed scene
- s.syncAsSint32LE(*SaveSceneSsCount);
+ s.syncAsSint32LE(*g_SaveSceneSsCount);
- if (*SaveSceneSsCount != 0) {
- SAVED_DATA *sdPtr = SaveSceneSsData;
- for (int i = 0; i < *SaveSceneSsCount; ++i, ++sdPtr)
+ if (*g_SaveSceneSsCount != 0) {
+ SAVED_DATA *sdPtr = g_SaveSceneSsData;
+ for (int i = 0; i < *g_SaveSceneSsCount; ++i, ++sdPtr)
syncSavedData(s, *sdPtr);
// Flag that there is a saved scene to return to. Note that in this context 'saved scene'
// is a stored scene to return to from another scene, such as from the Summoning Book close-up
// in Discworld 1 to whatever scene Rincewind was in prior to that
- ASceneIsSaved = true;
+ g_ASceneIsSaved = true;
}
if (!TinselV2)
@@ -473,7 +475,7 @@ static void DoSync(Common::Serializer &s) {
* DoRestore
*/
static bool DoRestore() {
- Common::InSaveFile *f = _vm->getSaveFileMan()->openForLoading(savedFiles[RestoreGameNumber].name);
+ Common::InSaveFile *f = _vm->getSaveFileMan()->openForLoading(g_savedFiles[g_RestoreGameNumber].name);
if (f == NULL) {
return false;
@@ -507,8 +509,8 @@ static bool DoRestore() {
static void SaveFailure(Common::OutSaveFile *f) {
if (f) {
delete f;
- _vm->getSaveFileMan()->removeSavefile(SaveSceneName);
- SaveSceneName = NULL; // Invalidate save name
+ _vm->getSaveFileMan()->removeSavefile(g_SaveSceneName);
+ g_SaveSceneName = NULL; // Invalidate save name
}
GUI::MessageDialog dialog(_("Failed to save game state to file."));
dialog.runModal();
@@ -522,9 +524,9 @@ static void DoSave() {
char tmpName[FNAMELEN];
// Next getList() must do its stuff again
- NeedLoad = true;
+ g_NeedLoad = true;
- if (SaveSceneName == NULL) {
+ if (g_SaveSceneName == NULL) {
// Generate a new unique save name
int i;
int ano = 1; // Allocated number
@@ -533,23 +535,23 @@ static void DoSave() {
Common::String fname = _vm->getSavegameFilename(ano);
strcpy(tmpName, fname.c_str());
- for (i = 0; i < numSfiles; i++)
- if (!strcmp(savedFiles[i].name, tmpName))
+ for (i = 0; i < g_numSfiles; i++)
+ if (!strcmp(g_savedFiles[i].name, tmpName))
break;
- if (i == numSfiles)
+ if (i == g_numSfiles)
break;
ano++;
}
- SaveSceneName = tmpName;
+ g_SaveSceneName = tmpName;
}
- if (SaveSceneDesc[0] == 0)
- SaveSceneDesc = "unnamed";
+ if (g_SaveSceneDesc[0] == 0)
+ g_SaveSceneDesc = "unnamed";
- f = _vm->getSaveFileMan()->openForSaving(SaveSceneName);
+ f = _vm->getSaveFileMan()->openForSaving(g_SaveSceneName);
Common::Serializer s(0, f);
if (f == NULL) {
@@ -562,7 +564,7 @@ static void DoSave() {
hdr.id = SAVEGAME_ID;
hdr.size = SAVEGAME_HEADER_SIZE;
hdr.ver = CURRENT_VER;
- memcpy(hdr.desc, SaveSceneDesc, SG_DESC_LEN);
+ memcpy(hdr.desc, g_SaveSceneDesc, SG_DESC_LEN);
hdr.desc[SG_DESC_LEN - 1] = 0;
g_system->getTimeAndDate(hdr.dateTime);
hdr.scnFlag = _vm->getFeatures() & GF_SCNFILES;
@@ -584,28 +586,29 @@ static void DoSave() {
f->finalize();
delete f;
- SaveSceneName = NULL; // Invalidate save name
+ g_SaveSceneName = NULL; // Invalidate save name
}
/**
* ProcessSRQueue
*/
void ProcessSRQueue() {
- switch (SRstate) {
+ switch (g_SRstate) {
case SR_DORESTORE:
// If a load has been done directly from title screens, set a larger value for scene ctr so the
// code used to skip the title screens in Discworld 1 gets properly disabled
- if (sceneCtr < 10) sceneCtr = 10;
+ if (g_sceneCtr < 10)
+ g_sceneCtr = 10;
if (DoRestore()) {
- DoRestoreScene(srsd, false);
+ DoRestoreScene(g_srsd, false);
}
- SRstate = SR_IDLE;
+ g_SRstate = SR_IDLE;
break;
case SR_DOSAVE:
DoSave();
- SRstate = SR_IDLE;
+ g_SRstate = SR_IDLE;
break;
default:
break;
@@ -614,14 +617,14 @@ void ProcessSRQueue() {
void RequestSaveGame(char *name, char *desc, SAVED_DATA *sd, int *pSsCount, SAVED_DATA *pSsData) {
- assert(SRstate == SR_IDLE);
-
- SaveSceneName = name;
- SaveSceneDesc = desc;
- SaveSceneSsCount = pSsCount;
- SaveSceneSsData = pSsData;
- srsd = sd;
- SRstate = SR_DOSAVE;
+ assert(g_SRstate == SR_IDLE);
+
+ g_SaveSceneName = name;
+ g_SaveSceneDesc = desc;
+ g_SaveSceneSsCount = pSsCount;
+ g_SaveSceneSsData = pSsData;
+ g_srsd = sd;
+ g_SRstate = SR_DOSAVE;
}
void RequestRestoreGame(int num, SAVED_DATA *sd, int *pSsCount, SAVED_DATA *pSsData) {
@@ -630,17 +633,17 @@ void RequestRestoreGame(int num, SAVED_DATA *sd, int *pSsCount, SAVED_DATA *pSsD
return;
else if (num == -2) {
// From CD change for restore
- num = RestoreGameNumber;
+ num = g_RestoreGameNumber;
}
}
assert(num >= 0);
- RestoreGameNumber = num;
- SaveSceneSsCount = pSsCount;
- SaveSceneSsData = pSsData;
- srsd = sd;
- SRstate = SR_DORESTORE;
+ g_RestoreGameNumber = num;
+ g_SaveSceneSsCount = pSsCount;
+ g_SaveSceneSsData = pSsData;
+ g_srsd = sd;
+ g_SRstate = SR_DORESTORE;
}
/**
diff --git a/engines/tinsel/savescn.cpp b/engines/tinsel/savescn.cpp
index 39a8033d45..1b06e3929c 100644
--- a/engines/tinsel/savescn.cpp
+++ b/engines/tinsel/savescn.cpp
@@ -75,29 +75,29 @@ enum {
//----------------- EXTERNAL GLOBAL DATA --------------------
-extern int thingHeld;
-extern int restoreCD;
-extern SRSTATE SRstate;
+extern int g_thingHeld;
+extern int g_restoreCD;
+extern SRSTATE g_SRstate;
//----------------- LOCAL GLOBAL DATA --------------------
// FIXME: Avoid non-const global vars
-bool ASceneIsSaved = false;
+bool g_ASceneIsSaved = false;
-static int savedSceneCount = 0;
+static int g_savedSceneCount = 0;
-static bool bNotDoneYet = false;
+static bool g_bNotDoneYet = false;
//static SAVED_DATA ssData[MAX_NEST];
-static SAVED_DATA *ssData = NULL;
-static SAVED_DATA sgData;
+static SAVED_DATA *g_ssData = NULL;
+static SAVED_DATA g_sgData;
-static SAVED_DATA *rsd = 0;
+static SAVED_DATA *g_rsd = 0;
-static int RestoreSceneCount = 0;
+static int g_RestoreSceneCount = 0;
-static bool bNoFade = false;
+static bool g_bNoFade = false;
//----------------- FORWARD REFERENCES --------------------
@@ -133,7 +133,7 @@ void DoSaveScene(SAVED_DATA *sd) {
CurrentMidiFacts(&sd->SavedMidi, &sd->SavedLoop);
}
- ASceneIsSaved = true;
+ g_ASceneIsSaved = true;
}
/**
@@ -142,29 +142,29 @@ void DoSaveScene(SAVED_DATA *sd) {
* @param bFadeOut Flag to perform a fade out
*/
void DoRestoreScene(SAVED_DATA *sd, bool bFadeOut) {
- rsd = sd;
+ g_rsd = sd;
if (bFadeOut)
- RestoreSceneCount = RS_COUNT + COUNTOUT_COUNT; // Set restore scene count
+ g_RestoreSceneCount = RS_COUNT + COUNTOUT_COUNT; // Set restore scene count
else
- RestoreSceneCount = RS_COUNT; // Set restore scene count
+ g_RestoreSceneCount = RS_COUNT; // Set restore scene count
}
void InitializeSaveScenes() {
- if (ssData == NULL) {
- ssData = (SAVED_DATA *)calloc(MAX_NEST, sizeof(SAVED_DATA));
- if (ssData == NULL) {
+ if (g_ssData == NULL) {
+ g_ssData = (SAVED_DATA *)calloc(MAX_NEST, sizeof(SAVED_DATA));
+ if (g_ssData == NULL) {
error("Cannot allocate memory for scene changes");
}
} else {
// Re-initialize - no scenes saved
- savedSceneCount = 0;
+ g_savedSceneCount = 0;
}
}
void FreeSaveScenes() {
- free(ssData);
- ssData = NULL;
+ free(g_ssData);
+ g_ssData = NULL;
}
/**
@@ -212,29 +212,29 @@ static void SortMAProcess(CORO_PARAM, const void *) {
_ctx->viaActor = SysVar(ISV_DIVERT_ACTOR);
SetSysVar(ISV_DIVERT_ACTOR, 0);
- RestoreAuxScales(rsd->SavedMoverInfo);
+ RestoreAuxScales(g_rsd->SavedMoverInfo);
for (_ctx->i = 0; _ctx->i < MAX_MOVERS; _ctx->i++) {
- if (rsd->SavedMoverInfo[_ctx->i].bActive) {
- CORO_INVOKE_ARGS(Stand, (CORO_SUBCTX, rsd->SavedMoverInfo[_ctx->i].actorID,
- rsd->SavedMoverInfo[_ctx->i].objX, rsd->SavedMoverInfo[_ctx->i].objY,
- rsd->SavedMoverInfo[_ctx->i].hLastfilm));
+ if (g_rsd->SavedMoverInfo[_ctx->i].bActive) {
+ CORO_INVOKE_ARGS(Stand, (CORO_SUBCTX, g_rsd->SavedMoverInfo[_ctx->i].actorID,
+ g_rsd->SavedMoverInfo[_ctx->i].objX, g_rsd->SavedMoverInfo[_ctx->i].objY,
+ g_rsd->SavedMoverInfo[_ctx->i].hLastfilm));
- if (rsd->SavedMoverInfo[_ctx->i].bHidden)
- HideMover(GetMover(rsd->SavedMoverInfo[_ctx->i].actorID));
+ if (g_rsd->SavedMoverInfo[_ctx->i].bHidden)
+ HideMover(GetMover(g_rsd->SavedMoverInfo[_ctx->i].actorID));
}
- ActorPalette(rsd->SavedMoverInfo[_ctx->i].actorID,
- rsd->SavedMoverInfo[_ctx->i].startColor, rsd->SavedMoverInfo[_ctx->i].paletteLength);
+ ActorPalette(g_rsd->SavedMoverInfo[_ctx->i].actorID,
+ g_rsd->SavedMoverInfo[_ctx->i].startColor, g_rsd->SavedMoverInfo[_ctx->i].paletteLength);
- if (rsd->SavedMoverInfo[_ctx->i].brightness != BOGUS_BRIGHTNESS)
- ActorBrightness(rsd->SavedMoverInfo[_ctx->i].actorID, rsd->SavedMoverInfo[_ctx->i].brightness);
+ if (g_rsd->SavedMoverInfo[_ctx->i].brightness != BOGUS_BRIGHTNESS)
+ ActorBrightness(g_rsd->SavedMoverInfo[_ctx->i].actorID, g_rsd->SavedMoverInfo[_ctx->i].brightness);
}
// Restore via actor
SetSysVar(ISV_DIVERT_ACTOR, _ctx->viaActor);
- bNotDoneYet = false;
+ g_bNotDoneYet = false;
CORO_END_CODE;
}
@@ -244,49 +244,49 @@ static void SortMAProcess(CORO_PARAM, const void *) {
void ResumeInterprets() {
// Master script only affected on restore game, not restore scene
- if (!TinselV2 && (rsd == &sgData)) {
+ if (!TinselV2 && (g_rsd == &g_sgData)) {
g_scheduler->killMatchingProcess(PID_MASTER_SCR, -1);
FreeMasterInterpretContext();
}
for (int i = 0; i < NUM_INTERPRET; i++) {
- switch (rsd->SavedICInfo[i].GSort) {
+ switch (g_rsd->SavedICInfo[i].GSort) {
case GS_NONE:
break;
case GS_INVENTORY:
- if (rsd->SavedICInfo[i].event != POINTED) {
- RestoreProcess(&rsd->SavedICInfo[i]);
+ if (g_rsd->SavedICInfo[i].event != POINTED) {
+ RestoreProcess(&g_rsd->SavedICInfo[i]);
}
break;
case GS_MASTER:
// Master script only affected on restore game, not restore scene
- if (rsd == &sgData)
- RestoreMasterProcess(&rsd->SavedICInfo[i]);
+ if (g_rsd == &g_sgData)
+ RestoreMasterProcess(&g_rsd->SavedICInfo[i]);
break;
case GS_PROCESS:
// Tinsel 2 process
- RestoreSceneProcess(&rsd->SavedICInfo[i]);
+ RestoreSceneProcess(&g_rsd->SavedICInfo[i]);
break;
case GS_GPROCESS:
// Tinsel 2 Global processes only affected on restore game, not restore scene
- if (rsd == &sgData)
- RestoreGlobalProcess(&rsd->SavedICInfo[i]);
+ if (g_rsd == &g_sgData)
+ RestoreGlobalProcess(&g_rsd->SavedICInfo[i]);
break;
case GS_ACTOR:
if (TinselV2)
- RestoreProcess(&rsd->SavedICInfo[i]);
+ RestoreProcess(&g_rsd->SavedICInfo[i]);
else
- RestoreActorProcess(rsd->SavedICInfo[i].idActor, &rsd->SavedICInfo[i], rsd == &sgData);
+ RestoreActorProcess(g_rsd->SavedICInfo[i].idActor, &g_rsd->SavedICInfo[i], g_rsd == &g_sgData);
break;
case GS_POLYGON:
case GS_SCENE:
- RestoreProcess(&rsd->SavedICInfo[i]);
+ RestoreProcess(&g_rsd->SavedICInfo[i]);
break;
default:
@@ -313,7 +313,7 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {
if (TinselV2) {
// Master script only affected on restore game, not restore scene
- if (sd == &sgData) {
+ if (sd == &g_sgData) {
g_scheduler->killMatchingProcess(PID_MASTER_SCR);
KillGlobalProcesses();
FreeMasterInterpretContext();
@@ -322,12 +322,12 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {
RestorePolygonStuff(sd->SavedPolygonStuff);
// Abandon temporarily if different CD
- if (sd == &sgData && restoreCD != GetCurrentCD()) {
- SRstate = SR_IDLE;
+ if (sd == &g_sgData && g_restoreCD != GetCurrentCD()) {
+ g_SRstate = SR_IDLE;
EndScene();
- SetNextCD(restoreCD);
- CDChangeForRestore(restoreCD);
+ SetNextCD(g_restoreCD);
+ CDChangeForRestore(g_restoreCD);
return 0;
}
@@ -338,8 +338,8 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {
// Start up the scene
StartNewScene(sd->SavedSceneHandle, NO_ENTRY_NUM);
- SetDoFadeIn(!bNoFade);
- bNoFade = false;
+ SetDoFadeIn(!g_bNoFade);
+ g_bNoFade = false;
StartupBackground(nullContext, sd->SavedBgroundHandle);
if (TinselV2) {
@@ -355,7 +355,7 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {
if (TinselV2) {
// create process to sort out the moving actors
g_scheduler->createProcess(PID_MOVER, SortMAProcess, NULL, 0);
- bNotDoneYet = true;
+ g_bNotDoneYet = true;
RestoreActorZ(sd->savedActorZ);
RestoreZpositions(sd->zPositions);
@@ -374,11 +374,11 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {
case 1:
if (TinselV2) {
- if (bNotDoneYet)
+ if (g_bNotDoneYet)
return n;
- if (sd == &sgData)
- HoldItem(thingHeld, true);
+ if (sd == &g_sgData)
+ HoldItem(g_thingHeld, true);
if (sd->bTinselDim)
_vm->_pcmMusic->dim(true);
_vm->_pcmMusic->restoreThatTune(sd->SavedTune);
@@ -406,7 +406,7 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {
void RestoreGame(int num) {
KillInventory();
- RequestRestoreGame(num, &sgData, &savedSceneCount, ssData);
+ RequestRestoreGame(num, &g_sgData, &g_savedSceneCount, g_ssData);
// Actual restoring is performed by ProcessSRQueue
}
@@ -418,9 +418,9 @@ void RestoreGame(int num) {
*/
void SaveGame(char *name, char *desc) {
// Get current scene data
- DoSaveScene(&sgData);
+ DoSaveScene(&g_sgData);
- RequestSaveGame(name, desc, &sgData, &savedSceneCount, ssData);
+ RequestSaveGame(name, desc, &g_sgData, &g_savedSceneCount, g_ssData);
// Actual saving is performed by ProcessSRQueue
}
@@ -429,11 +429,11 @@ void SaveGame(char *name, char *desc) {
//---------------------------------------------------------------------------------
bool IsRestoringScene() {
- if (RestoreSceneCount) {
- RestoreSceneCount = DoRestoreSceneFrame(rsd, RestoreSceneCount);
+ if (g_RestoreSceneCount) {
+ g_RestoreSceneCount = DoRestoreSceneFrame(g_rsd, g_RestoreSceneCount);
}
- return RestoreSceneCount ? true : false;
+ return g_RestoreSceneCount ? true : false;
}
/**
@@ -441,13 +441,13 @@ bool IsRestoringScene() {
*/
void TinselRestoreScene(bool bFade) {
// only called by restore_scene PCODE
- if (RestoreSceneCount == 0) {
- assert(savedSceneCount >= 1); // No saved scene to restore
+ if (g_RestoreSceneCount == 0) {
+ assert(g_savedSceneCount >= 1); // No saved scene to restore
- if (ASceneIsSaved)
- DoRestoreScene(&ssData[--savedSceneCount], bFade);
+ if (g_ASceneIsSaved)
+ DoRestoreScene(&g_ssData[--g_savedSceneCount], bFade);
if (!bFade)
- bNoFade = true;
+ g_bNoFade = true;
}
}
@@ -461,14 +461,14 @@ void TinselSaveScene(CORO_PARAM) {
CORO_BEGIN_CODE(_ctx);
- assert(savedSceneCount < MAX_NEST); // nesting limit reached
+ assert(g_savedSceneCount < MAX_NEST); // nesting limit reached
// Don't save the same thing multiple times!
// FIXME/TODO: Maybe this can be changed to an assert?
- if (savedSceneCount && ssData[savedSceneCount-1].SavedSceneHandle == GetSceneHandle())
+ if (g_savedSceneCount && g_ssData[g_savedSceneCount-1].SavedSceneHandle == GetSceneHandle())
CORO_KILL_SELF();
- DoSaveScene(&ssData[savedSceneCount++]);
+ DoSaveScene(&g_ssData[g_savedSceneCount++]);
CORO_END_CODE;
}
diff --git a/engines/tinsel/scene.cpp b/engines/tinsel/scene.cpp
index 89b0da7d65..f635ce13a3 100644
--- a/engines/tinsel/scene.cpp
+++ b/engines/tinsel/scene.cpp
@@ -107,15 +107,15 @@ struct ENTRANCE_STRUC {
// FIXME: Avoid non-const global vars
#ifdef DEBUG
-static bool ShowPosition = false; // Set when showpos() has been called
+static bool g_ShowPosition = false; // Set when showpos() has been called
#endif
-int sceneCtr = 0;
-static int initialMyEscape;
+int g_sceneCtr = 0;
+static int g_initialMyEscape;
-static SCNHANDLE SceneHandle = 0; // Current scene handle - stored in case of Save_Scene()
+static SCNHANDLE g_SceneHandle = 0; // Current scene handle - stored in case of Save_Scene()
-SCENE_STRUC tempStruc;
+SCENE_STRUC g_tempStruc;
struct TP_INIT {
SCNHANDLE hTinselCode; // Code
@@ -128,18 +128,18 @@ const SCENE_STRUC *GetSceneStruc(const byte *pStruc) {
// Copy appropriate fields into tempStruc, and return a pointer to it
const byte *p = pStruc;
- memset(&tempStruc, 0, sizeof(SCENE_STRUC));
-
- tempStruc.numEntrance = READ_UINT32(p); p += sizeof(uint32);
- tempStruc.numPoly = READ_UINT32(p); p += sizeof(uint32);
- tempStruc.numTaggedActor = READ_UINT32(p); p += sizeof(uint32);
- tempStruc.defRefer = READ_UINT32(p); p += sizeof(uint32);
- tempStruc.hSceneScript = READ_UINT32(p); p += sizeof(uint32);
- tempStruc.hEntrance = READ_UINT32(p); p += sizeof(uint32);
- tempStruc.hPoly = READ_UINT32(p); p += sizeof(uint32);
- tempStruc.hTaggedActor = READ_UINT32(p); p += sizeof(uint32);
-
- return &tempStruc;
+ memset(&g_tempStruc, 0, sizeof(SCENE_STRUC));
+
+ g_tempStruc.numEntrance = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.numPoly = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.numTaggedActor = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.defRefer = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hSceneScript = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hEntrance = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hPoly = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hTaggedActor = READ_UINT32(p); p += sizeof(uint32);
+
+ return &g_tempStruc;
}
@@ -157,8 +157,8 @@ static void SceneTinselProcess(CORO_PARAM, const void *param) {
CORO_BEGIN_CODE(_ctx);
// The following myEscape value setting is used for enabling title screen skipping in DW1
- if (TinselV1 && (sceneCtr == 1)) initialMyEscape = GetEscEvents();
- _ctx->myEscape = (TinselV1 && (sceneCtr < 4)) ? initialMyEscape : 0;
+ if (TinselV1 && (g_sceneCtr == 1)) g_initialMyEscape = GetEscEvents();
+ _ctx->myEscape = (TinselV1 && (g_sceneCtr < 4)) ? g_initialMyEscape : 0;
// get the stuff copied to process when it was created
_ctx->pInit = (const TP_INIT *)param;
@@ -184,8 +184,8 @@ static void SceneTinselProcess(CORO_PARAM, const void *param) {
void SendSceneTinselProcess(TINSEL_EVENT event) {
SCENE_STRUC *ss;
- if (SceneHandle != (SCNHANDLE)NULL) {
- ss = (SCENE_STRUC *) FindChunk(SceneHandle, CHUNK_SCENE);
+ if (g_SceneHandle != (SCNHANDLE)NULL) {
+ ss = (SCENE_STRUC *) FindChunk(g_SceneHandle, CHUNK_SCENE);
if (ss->hSceneScript) {
TP_INIT init;
@@ -214,9 +214,9 @@ static void LoadScene(SCNHANDLE scene, int entry) {
const ENTRANCE_STRUC *es;
// Scene handle
- SceneHandle = scene; // Save scene handle in case of Save_Scene()
- LockMem(SceneHandle); // Make sure scene is loaded
- LockScene(SceneHandle); // Prevent current scene from being discarded
+ 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
if (TinselV2) {
// CdPlay() stuff
@@ -307,9 +307,9 @@ static void LoadScene(SCNHANDLE scene, int entry) {
* Wrap up the last scene.
*/
void EndScene() {
- if (SceneHandle != 0) {
- UnlockScene(SceneHandle);
- SceneHandle = 0;
+ if (g_SceneHandle != 0) {
+ UnlockScene(g_SceneHandle);
+ g_SceneHandle = 0;
}
KillInventory(); // Close down any open inventory
@@ -409,7 +409,7 @@ void PrimeScene() {
g_scheduler->createProcess(PID_SCROLL, EffectPolyProcess, NULL, 0);
#ifdef DEBUG
- if (ShowPosition)
+ if (g_ShowPosition)
g_scheduler->createProcess(PID_POSITION, CursorPositionProcess, NULL, 0);
#endif
@@ -445,7 +445,7 @@ void StartNewScene(SCNHANDLE scene, int entry) {
*/
void setshowpos() {
- ShowPosition = true;
+ g_ShowPosition = true;
}
#endif
@@ -454,7 +454,7 @@ void setshowpos() {
*/
SCNHANDLE GetSceneHandle() {
- return SceneHandle;
+ return g_SceneHandle;
}
/**
diff --git a/engines/tinsel/sched.cpp b/engines/tinsel/sched.cpp
index d6cd806eb2..343758d924 100644
--- a/engines/tinsel/sched.cpp
+++ b/engines/tinsel/sched.cpp
@@ -47,11 +47,11 @@ struct PROCESS_STRUC {
// FIXME: Avoid non-const global vars
-static uint32 numSceneProcess;
-static SCNHANDLE hSceneProcess;
+static uint32 g_numSceneProcess;
+static SCNHANDLE g_hSceneProcess;
-static uint32 numGlobalProcess;
-static PROCESS_STRUC *pGlobalProcess;
+static uint32 g_numGlobalProcess;
+static PROCESS_STRUC *g_pGlobalProcess;
//--------------------- FUNCTIONS ------------------------
@@ -574,8 +574,8 @@ void RestoreSceneProcess(INT_CONTEXT *pic) {
uint32 i;
PROCESS_STRUC *pStruc;
- pStruc = (PROCESS_STRUC *)LockMem(hSceneProcess);
- for (i = 0; i < numSceneProcess; i++) {
+ pStruc = (PROCESS_STRUC *)LockMem(g_hSceneProcess);
+ for (i = 0; i < g_numSceneProcess; i++) {
if (FROM_LE_32(pStruc[i].hProcessCode) == pic->hCode) {
g_scheduler->createProcess(PID_PROCESS + i, RestoredProcessProcess,
&pic, sizeof(pic));
@@ -583,7 +583,7 @@ void RestoreSceneProcess(INT_CONTEXT *pic) {
}
}
- assert(i < numSceneProcess);
+ assert(i < g_numSceneProcess);
}
/**
@@ -602,8 +602,8 @@ void SceneProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWait
CORO_BEGIN_CODE(_ctx);
- _ctx->pStruc = (PROCESS_STRUC *)LockMem(hSceneProcess);
- for (i = 0; i < numSceneProcess; i++) {
+ _ctx->pStruc = (PROCESS_STRUC *)LockMem(g_hSceneProcess);
+ for (i = 0; i < g_numSceneProcess; i++) {
if (FROM_LE_32(_ctx->pStruc[i].processId) == procID) {
assert(_ctx->pStruc[i].hProcessCode); // Must have some code to run
@@ -624,7 +624,7 @@ void SceneProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWait
}
}
- if (i == numSceneProcess)
+ if (i == g_numSceneProcess)
return;
if (bWait) {
@@ -641,8 +641,8 @@ void KillSceneProcess(uint32 procID) {
uint32 i; // Loop counter
PROCESS_STRUC *pStruc;
- pStruc = (PROCESS_STRUC *) LockMem(hSceneProcess);
- for (i = 0; i < numSceneProcess; i++) {
+ pStruc = (PROCESS_STRUC *) LockMem(g_hSceneProcess);
+ for (i = 0; i < g_numSceneProcess; i++) {
if (FROM_LE_32(pStruc[i].processId) == procID) {
g_scheduler->killMatchingProcess(PID_PROCESS + i, -1);
break;
@@ -654,8 +654,8 @@ void KillSceneProcess(uint32 procID) {
* Register the scene processes in a scene.
*/
void SceneProcesses(uint32 numProcess, SCNHANDLE hProcess) {
- numSceneProcess = numProcess;
- hSceneProcess = hProcess;
+ g_numSceneProcess = numProcess;
+ g_hSceneProcess = hProcess;
}
@@ -669,15 +669,15 @@ void SceneProcesses(uint32 numProcess, SCNHANDLE hProcess) {
void RestoreGlobalProcess(INT_CONTEXT *pic) {
uint32 i; // Loop counter
- for (i = 0; i < numGlobalProcess; i++) {
- if (pGlobalProcess[i].hProcessCode == pic->hCode) {
+ for (i = 0; i < g_numGlobalProcess; i++) {
+ if (g_pGlobalProcess[i].hProcessCode == pic->hCode) {
g_scheduler->createProcess(PID_GPROCESS + i, RestoredProcessProcess,
&pic, sizeof(pic));
break;
}
}
- assert(i < numGlobalProcess);
+ assert(i < g_numGlobalProcess);
}
/**
@@ -685,7 +685,7 @@ void RestoreGlobalProcess(INT_CONTEXT *pic) {
*/
void KillGlobalProcesses() {
- for (uint32 i = 0; i < numGlobalProcess; ++i) {
+ for (uint32 i = 0; i < g_numGlobalProcess; ++i) {
g_scheduler->killMatchingProcess(PID_GPROCESS + i, -1);
}
}
@@ -706,12 +706,12 @@ bool GlobalProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWai
uint32 i; // Loop counter
_ctx->pProc = NULL;
- for (i = 0; i < numGlobalProcess; ++i) {
- if (pGlobalProcess[i].processId == procID) {
- assert(pGlobalProcess[i].hProcessCode); // Must have some code to run
+ for (i = 0; i < g_numGlobalProcess; ++i) {
+ if (g_pGlobalProcess[i].processId == procID) {
+ assert(g_pGlobalProcess[i].hProcessCode); // Must have some code to run
_ctx->pic = InitInterpretContext(GS_GPROCESS,
- pGlobalProcess[i].hProcessCode,
+ g_pGlobalProcess[i].hProcessCode,
event,
NOPOLY, // No polygon
0, // No actor
@@ -728,7 +728,7 @@ bool GlobalProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWai
}
}
- if ((i == numGlobalProcess) || (_ctx->pic == NULL))
+ if ((i == g_numGlobalProcess) || (_ctx->pic == NULL))
result = false;
else if (bWait)
CORO_INVOKE_ARGS_V(WaitInterpret, false, (CORO_SUBCTX, _ctx->pProc, &result));
@@ -743,8 +743,8 @@ bool GlobalProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWai
void xKillGlobalProcess(uint32 procID) {
uint32 i; // Loop counter
- for (i = 0; i < numGlobalProcess; ++i) {
- if (pGlobalProcess[i].processId == procID) {
+ for (i = 0; i < g_numGlobalProcess; ++i) {
+ if (g_pGlobalProcess[i].processId == procID) {
g_scheduler->killMatchingProcess(PID_GPROCESS + i, -1);
break;
}
@@ -755,13 +755,13 @@ void xKillGlobalProcess(uint32 procID) {
* Register the global processes list
*/
void GlobalProcesses(uint32 numProcess, byte *pProcess) {
- pGlobalProcess = new PROCESS_STRUC[numProcess];
- numGlobalProcess = numProcess;
+ g_pGlobalProcess = new PROCESS_STRUC[numProcess];
+ g_numGlobalProcess = numProcess;
byte *p = pProcess;
for (uint i = 0; i < numProcess; ++i, p += 8) {
- pGlobalProcess[i].processId = READ_LE_UINT32(p);
- pGlobalProcess[i].hProcessCode = READ_LE_UINT32(p + 4);
+ g_pGlobalProcess[i].processId = READ_LE_UINT32(p);
+ g_pGlobalProcess[i].hProcessCode = READ_LE_UINT32(p + 4);
}
}
@@ -769,9 +769,9 @@ void GlobalProcesses(uint32 numProcess, byte *pProcess) {
* Frees the global processes list
*/
void FreeGlobalProcesses() {
- delete[] pGlobalProcess;
- pGlobalProcess = 0;
- numGlobalProcess = 0;
+ delete[] g_pGlobalProcess;
+ g_pGlobalProcess = 0;
+ g_numGlobalProcess = 0;
}
} // End of namespace Tinsel
diff --git a/engines/tinsel/scroll.cpp b/engines/tinsel/scroll.cpp
index d75e649be3..0a6a281d35 100644
--- a/engines/tinsel/scroll.cpp
+++ b/engines/tinsel/scroll.cpp
@@ -49,14 +49,14 @@ namespace Tinsel {
// FIXME: Avoid non-const global vars
-static int LeftScroll = 0, DownScroll = 0; // Number of iterations outstanding
+static int g_LeftScroll = 0, g_DownScroll = 0; // Number of iterations outstanding
-static int scrollActor = 0;
-static PMOVER pScrollMover = 0;
-static int oldx = 0, oldy = 0;
+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 sd = {
+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}
@@ -77,28 +77,28 @@ static SCROLLDATA sd = {
0
};
-static int ImageH = 0, ImageW = 0;
+static int g_ImageH = 0, g_ImageW = 0;
-static bool ScrollCursor = 0; // If a TAG or EXIT polygon is clicked on,
+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 scrollPixelsX = SCROLLPIXELS;
-static int scrollPixelsY = SCROLLPIXELS;
+static int g_scrollPixelsX = SCROLLPIXELS;
+static int g_scrollPixelsY = SCROLLPIXELS;
/**
* Reset the ScrollCursor flag
*/
void DontScrollCursor() {
- ScrollCursor = false;
+ g_ScrollCursor = false;
}
/**
* Set the ScrollCursor flag
*/
void DoScrollCursor() {
- ScrollCursor = true;
+ g_ScrollCursor = true;
}
/**
@@ -107,20 +107,20 @@ void DoScrollCursor() {
void SetNoScroll(int x1, int y1, int x2, int y2) {
if (x1 == x2) {
/* Vertical line */
- assert(sd.NumNoH < MAX_HNOSCROLL);
+ assert(g_sd.NumNoH < MAX_HNOSCROLL);
- sd.NoHScroll[sd.NumNoH].ln = x1; // X pos of vertical line
- sd.NoHScroll[sd.NumNoH].c1 = y1;
- sd.NoHScroll[sd.NumNoH].c2 = y2;
- sd.NumNoH++;
+ 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++;
} else if (y1 == y2) {
/* Horizontal line */
- assert(sd.NumNoV < MAX_VNOSCROLL);
+ assert(g_sd.NumNoV < MAX_VNOSCROLL);
- sd.NoVScroll[sd.NumNoV].ln = y1; // Y pos of horizontal line
- sd.NoVScroll[sd.NumNoV].c1 = x1;
- sd.NoVScroll[sd.NumNoV].c2 = x2;
- sd.NumNoV++;
+ 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++;
} else {
/* No-scroll lines must be horizontal or vertical */
}
@@ -144,21 +144,21 @@ static void NeedScroll(int direction) {
BottomLine = Toffset + (SCREEN_HEIGHT - 1);
RightCol = Loffset + (SCREEN_WIDTH - 1);
- for (i = 0; i < sd.NumNoH; i++) {
- if (RightCol >= sd.NoHScroll[i].ln - 1 && RightCol <= sd.NoHScroll[i].ln + 1 &&
- ((sd.NoHScroll[i].c1 >= Toffset && sd.NoHScroll[i].c1 <= BottomLine) ||
- (sd.NoHScroll[i].c2 >= Toffset && sd.NoHScroll[i].c2 <= BottomLine) ||
- (sd.NoHScroll[i].c1 < Toffset && sd.NoHScroll[i].c2 > BottomLine)))
+ 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)))
return;
}
- if (LeftScroll <= 0) {
+ if (g_LeftScroll <= 0) {
if (TinselV2) {
- scrollPixelsX = sd.xSpeed;
- LeftScroll += sd.xDistance;
+ g_scrollPixelsX = g_sd.xSpeed;
+ g_LeftScroll += g_sd.xDistance;
} else {
- scrollPixelsX = SCROLLPIXELS;
- LeftScroll = RLSCROLL;
+ g_scrollPixelsX = SCROLLPIXELS;
+ g_LeftScroll = RLSCROLL;
}
}
break;
@@ -167,21 +167,21 @@ static void NeedScroll(int direction) {
BottomLine = Toffset + (SCREEN_HEIGHT - 1);
- for (i = 0; i < sd.NumNoH; i++) {
- if (Loffset >= sd.NoHScroll[i].ln - 1 && Loffset <= sd.NoHScroll[i].ln + 1 &&
- ((sd.NoHScroll[i].c1 >= Toffset && sd.NoHScroll[i].c1 <= BottomLine) ||
- (sd.NoHScroll[i].c2 >= Toffset && sd.NoHScroll[i].c2 <= BottomLine) ||
- (sd.NoHScroll[i].c1 < Toffset && sd.NoHScroll[i].c2 > BottomLine)))
+ 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)))
return;
}
- if (LeftScroll >= 0) {
+ if (g_LeftScroll >= 0) {
if (TinselV2) {
- scrollPixelsX = sd.xSpeed;
- LeftScroll -= sd.xDistance;
+ g_scrollPixelsX = g_sd.xSpeed;
+ g_LeftScroll -= g_sd.xDistance;
} else {
- scrollPixelsX = SCROLLPIXELS;
- LeftScroll = -RLSCROLL;
+ g_scrollPixelsX = SCROLLPIXELS;
+ g_LeftScroll = -RLSCROLL;
}
}
break;
@@ -191,21 +191,21 @@ static void NeedScroll(int direction) {
BottomLine = Toffset + (SCREEN_HEIGHT - 1);
RightCol = Loffset + (SCREEN_WIDTH - 1);
- for (i = 0; i < sd.NumNoV; i++) {
- if ((BottomLine >= sd.NoVScroll[i].ln - 1 && BottomLine <= sd.NoVScroll[i].ln + 1) &&
- ((sd.NoVScroll[i].c1 >= Loffset && sd.NoVScroll[i].c1 <= RightCol) ||
- (sd.NoVScroll[i].c2 >= Loffset && sd.NoVScroll[i].c2 <= RightCol) ||
- (sd.NoVScroll[i].c1 < Loffset && sd.NoVScroll[i].c2 > RightCol)))
+ 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)))
return;
}
- if (DownScroll <= 0) {
+ if (g_DownScroll <= 0) {
if (TinselV2) {
- scrollPixelsY = sd.ySpeed;
- DownScroll += sd.yDistance;
+ g_scrollPixelsY = g_sd.ySpeed;
+ g_DownScroll += g_sd.yDistance;
} else {
- scrollPixelsY = SCROLLPIXELS;
- DownScroll = UDSCROLL;
+ g_scrollPixelsY = SCROLLPIXELS;
+ g_DownScroll = UDSCROLL;
}
}
break;
@@ -214,21 +214,21 @@ static void NeedScroll(int direction) {
RightCol = Loffset + (SCREEN_WIDTH - 1);
- for (i = 0; i < sd.NumNoV; i++) {
- if (Toffset >= sd.NoVScroll[i].ln - 1 && Toffset <= sd.NoVScroll[i].ln + 1 &&
- ((sd.NoVScroll[i].c1 >= Loffset && sd.NoVScroll[i].c1 <= RightCol) ||
- (sd.NoVScroll[i].c2 >= Loffset && sd.NoVScroll[i].c2 <= RightCol) ||
- (sd.NoVScroll[i].c1 < Loffset && sd.NoVScroll[i].c2 > RightCol)))
+ 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)))
return;
}
- if (DownScroll >= 0) {
+ if (g_DownScroll >= 0) {
if (TinselV2) {
- scrollPixelsY = sd.ySpeed;
- DownScroll -= sd.yDistance;
+ g_scrollPixelsY = g_sd.ySpeed;
+ g_DownScroll -= g_sd.yDistance;
} else {
- scrollPixelsY = SCROLLPIXELS;
- DownScroll = -UDSCROLL;
+ g_scrollPixelsY = SCROLLPIXELS;
+ g_DownScroll = -UDSCROLL;
}
}
break;
@@ -249,39 +249,39 @@ static void ScrollImage() {
/*
* Keeping cursor on a tag?
*/
- if (ScrollCursor) {
+ if (g_ScrollCursor) {
GetCursorXYNoWait(&curX, &curY, true);
if (InPolygon(curX, curY, TAG) != NOPOLY || InPolygon(curX, curY, EXIT) != NOPOLY) {
OldLoffset = Loffset;
OldToffset = Toffset;
} else
- ScrollCursor = false;
+ g_ScrollCursor = false;
}
/*
* Horizontal scrolling
*/
- if (LeftScroll > 0) {
- LeftScroll -= scrollPixelsX;
- if (LeftScroll < 0) {
- Loffset += LeftScroll;
- LeftScroll = 0;
+ if (g_LeftScroll > 0) {
+ g_LeftScroll -= g_scrollPixelsX;
+ if (g_LeftScroll < 0) {
+ Loffset += g_LeftScroll;
+ g_LeftScroll = 0;
}
- Loffset += scrollPixelsX; // Move right
- if (Loffset > ImageW - SCREEN_WIDTH)
- Loffset = ImageW - SCREEN_WIDTH;// Now at extreme right
+ Loffset += g_scrollPixelsX; // Move right
+ if (Loffset > g_ImageW - SCREEN_WIDTH)
+ Loffset = g_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 (LeftScroll < 0) {
- LeftScroll += scrollPixelsX;
- if (LeftScroll > 0) {
- Loffset += LeftScroll;
- LeftScroll = 0;
+ } else if (g_LeftScroll < 0) {
+ g_LeftScroll += g_scrollPixelsX;
+ if (g_LeftScroll > 0) {
+ Loffset += g_LeftScroll;
+ g_LeftScroll = 0;
}
- Loffset -= scrollPixelsX; // Move left
+ Loffset -= g_scrollPixelsX; // Move left
if (Loffset < 0)
Loffset = 0; // Now at extreme left
@@ -293,28 +293,28 @@ static void ScrollImage() {
/*
* Vertical scrolling
*/
- if (DownScroll > 0) {
- DownScroll -= scrollPixelsY;
- if (DownScroll < 0) {
- Toffset += DownScroll;
- DownScroll = 0;
+ if (g_DownScroll > 0) {
+ g_DownScroll -= g_scrollPixelsY;
+ if (g_DownScroll < 0) {
+ Toffset += g_DownScroll;
+ g_DownScroll = 0;
}
- Toffset += scrollPixelsY; // Move down
+ Toffset += g_scrollPixelsY; // Move down
- if (Toffset > ImageH - SCREEN_HEIGHT)
- Toffset = ImageH - SCREEN_HEIGHT;// Now at extreme bottom
+ if (Toffset > g_ImageH - SCREEN_HEIGHT)
+ Toffset = g_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 (DownScroll < 0) {
- DownScroll += scrollPixelsY;
- if (DownScroll > 0) {
- Toffset += DownScroll;
- DownScroll = 0;
+ } else if (g_DownScroll < 0) {
+ g_DownScroll += g_scrollPixelsY;
+ if (g_DownScroll > 0) {
+ Toffset += g_DownScroll;
+ g_DownScroll = 0;
}
- Toffset -= scrollPixelsY; // Move up
+ Toffset -= g_scrollPixelsY; // Move up
if (Toffset < 0)
Toffset = 0; // Now at extreme top
@@ -327,7 +327,7 @@ static void ScrollImage() {
/*
* Move cursor if keeping cursor on a tag.
*/
- if (ScrollCursor)
+ if (g_ScrollCursor)
AdjustCursorXY(OldLoffset - Loffset, OldToffset - Toffset);
PlayfieldSetPos(FIELD_WORLD, Loffset, Toffset);
@@ -345,12 +345,12 @@ static void MonitorScroll() {
/*
* Only do it if the actor is there and is visible
*/
- if (!pScrollMover || MoverHidden(pScrollMover) || !MoverIs(pScrollMover))
+ if (!g_pScrollMover || MoverHidden(g_pScrollMover) || !MoverIs(g_pScrollMover))
return;
- GetActorPos(scrollActor, &newx, &newy);
+ GetActorPos(g_scrollActor, &newx, &newy);
- if (oldx == newx && oldy == newy)
+ if (g_oldx == newx && g_oldy == newy)
return;
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
@@ -358,49 +358,49 @@ static void MonitorScroll() {
/*
* Approaching right side or left side of the screen?
*/
- if (newx > Loffset+SCREEN_WIDTH - RLDISTANCE && Loffset < ImageW - SCREEN_WIDTH) {
- if (newx > oldx)
+ if (newx > Loffset+SCREEN_WIDTH - RLDISTANCE && Loffset < g_ImageW - SCREEN_WIDTH) {
+ if (newx > g_oldx)
NeedScroll(LEFT);
} else if (newx < Loffset + RLDISTANCE && Loffset) {
- if (newx < oldx)
+ if (newx < g_oldx)
NeedScroll(RIGHT);
}
/*
* Approaching bottom or top of the screen?
*/
- if (newy > Toffset+SCREEN_HEIGHT-DDISTANCE && Toffset < ImageH-SCREEN_HEIGHT) {
- if (newy > oldy)
+ if (newy > Toffset+SCREEN_HEIGHT-DDISTANCE && Toffset < g_ImageH-SCREEN_HEIGHT) {
+ if (newy > g_oldy)
NeedScroll(UP);
- } else if (Toffset && newy < Toffset + UDISTANCE + GetActorBottom(scrollActor) - GetActorTop(scrollActor)) {
- if (newy < oldy)
+ } else if (Toffset && newy < Toffset + UDISTANCE + GetActorBottom(g_scrollActor) - GetActorTop(g_scrollActor)) {
+ if (newy < g_oldy)
NeedScroll(DOWN);
}
- oldx = newx;
- oldy = newy;
+ g_oldx = newx;
+ g_oldy = newy;
}
static void RestoreScrollDefaults() {
- sd.xTrigger = SysVar(SV_SCROLL_XTRIGGER);
- sd.xDistance = SysVar(SV_SCROLL_XDISTANCE);
- sd.xSpeed = SysVar(SV_SCROLL_XSPEED);
- sd.yTriggerTop = SysVar(SV_SCROLL_YTRIGGERTOP);
- sd.yTriggerBottom= SysVar(SV_SCROLL_YTRIGGERBOT);
- sd.yDistance = SysVar(SV_SCROLL_YDISTANCE);
- sd.ySpeed = SysVar(SV_SCROLL_YSPEED);
+ 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);
}
/**
* Does the obvious - called at the end of a scene.
*/
void DropScroll() {
- sd.NumNoH = sd.NumNoV = 0;
+ g_sd.NumNoH = g_sd.NumNoV = 0;
if (TinselV2) {
- LeftScroll = DownScroll = 0; // No iterations outstanding
- oldx = oldy = 0;
- scrollPixelsX = sd.xSpeed;
- scrollPixelsY = sd.ySpeed;
+ g_LeftScroll = g_DownScroll = 0; // No iterations outstanding
+ g_oldx = g_oldy = 0;
+ g_scrollPixelsX = g_sd.xSpeed;
+ g_scrollPixelsY = g_sd.ySpeed;
RestoreScrollDefaults();
}
}
@@ -420,28 +420,28 @@ void ScrollProcess(CORO_PARAM, const void *) {
while (!GetBgObject())
CORO_SLEEP(1);
- ImageH = BgHeight(); // Dimensions
- ImageW = BgWidth(); // of this scene.
+ g_ImageH = BgHeight(); // Dimensions
+ g_ImageW = BgWidth(); // of this scene.
// Give up if there'll be no purpose in this process
- if (ImageW == SCREEN_WIDTH && ImageH == SCREEN_HEIGHT)
+ if (g_ImageW == SCREEN_WIDTH && g_ImageH == SCREEN_HEIGHT)
CORO_KILL_SELF();
if (!TinselV2) {
- LeftScroll = DownScroll = 0; // No iterations outstanding
- oldx = oldy = 0;
- scrollPixelsX = scrollPixelsY = SCROLLPIXELS;
+ g_LeftScroll = g_DownScroll = 0; // No iterations outstanding
+ g_oldx = g_oldy = 0;
+ g_scrollPixelsX = g_scrollPixelsY = SCROLLPIXELS;
}
- if (!scrollActor)
- scrollActor = GetLeadId();
+ if (!g_scrollActor)
+ g_scrollActor = GetLeadId();
- pScrollMover = GetMover(scrollActor);
+ g_pScrollMover = GetMover(g_scrollActor);
while (1) {
MonitorScroll(); // Set scroll requirement
- if (LeftScroll || DownScroll) // Scroll if required
+ if (g_LeftScroll || g_DownScroll) // Scroll if required
ScrollImage();
CORO_SLEEP(1); // allow re-scheduling
@@ -454,11 +454,11 @@ void ScrollProcess(CORO_PARAM, const void *) {
* Change which actor the camera is following.
*/
void ScrollFocus(int ano) {
- if (scrollActor != ano) {
- oldx = oldy = 0;
- scrollActor = ano;
+ if (g_scrollActor != ano) {
+ g_oldx = g_oldy = 0;
+ g_scrollActor = ano;
- pScrollMover = ano ? GetMover(scrollActor) : NULL;
+ g_pScrollMover = ano ? GetMover(g_scrollActor) : NULL;
}
}
@@ -466,7 +466,7 @@ void ScrollFocus(int ano) {
* Returns the actor which the camera is following
*/
int GetScrollFocus() {
- return scrollActor;
+ return g_scrollActor;
}
@@ -476,29 +476,29 @@ int GetScrollFocus() {
void ScrollTo(int x, int y, int xIter, int yIter) {
int Loffset, Toffset; // for background offsets
- scrollPixelsX = xIter != 0 ? xIter : (TinselV2 ? sd.xSpeed : SCROLLPIXELS);
- scrollPixelsY = yIter != 0 ? yIter : (TinselV2 ? sd.ySpeed : SCROLLPIXELS);
+ g_scrollPixelsX = xIter != 0 ? xIter : (TinselV2 ? g_sd.xSpeed : SCROLLPIXELS);
+ g_scrollPixelsY = yIter != 0 ? yIter : (TinselV2 ? g_sd.ySpeed : SCROLLPIXELS);
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); // get background offsets
- LeftScroll = x - Loffset;
- DownScroll = y - Toffset;
+ g_LeftScroll = x - Loffset;
+ g_DownScroll = y - Toffset;
}
/**
* Kill of any current scroll.
*/
void KillScroll() {
- LeftScroll = DownScroll = 0;
+ g_LeftScroll = g_DownScroll = 0;
}
void GetNoScrollData(SCROLLDATA *ssd) {
- memcpy(ssd, &sd, sizeof(SCROLLDATA));
+ memcpy(ssd, &g_sd, sizeof(SCROLLDATA));
}
void RestoreNoScrollData(SCROLLDATA *ssd) {
- memcpy(&sd, ssd, sizeof(SCROLLDATA));
+ memcpy(&g_sd, ssd, sizeof(SCROLLDATA));
}
/**
@@ -512,24 +512,24 @@ void SetScrollParameters(int xTrigger, int xDistance, int xSpeed, int yTriggerTo
RestoreScrollDefaults();
} else {
if (xTrigger)
- sd.xTrigger = xTrigger;
+ g_sd.xTrigger = xTrigger;
if (xDistance)
- sd.xDistance = xDistance;
+ g_sd.xDistance = xDistance;
if (xSpeed)
- sd.xSpeed = xSpeed;
+ g_sd.xSpeed = xSpeed;
if (yTriggerTop)
- sd.yTriggerTop = yTriggerTop;
+ g_sd.yTriggerTop = yTriggerTop;
if (yTriggerBottom)
- sd.yTriggerBottom = yTriggerBottom;
+ g_sd.yTriggerBottom = yTriggerBottom;
if (yDistance)
- sd.yDistance = yDistance;
+ g_sd.yDistance = yDistance;
if (ySpeed)
- sd.ySpeed = ySpeed;
+ g_sd.ySpeed = ySpeed;
}
}
bool IsScrolling() {
- return (LeftScroll || DownScroll);
+ return (g_LeftScroll || g_DownScroll);
}
} // End of namespace Tinsel
diff --git a/engines/tinsel/scroll.h b/engines/tinsel/scroll.h
index 62562b20b2..bcdc15cda6 100644
--- a/engines/tinsel/scroll.h
+++ b/engines/tinsel/scroll.h
@@ -28,9 +28,9 @@ namespace Tinsel {
#define SCROLLPIXELS 8 // Number of pixels to scroll per iteration
// Distance from edge that triggers a scroll
-#define RLDISTANCE (TinselV2 ? sd.xTrigger : 50)
-#define UDISTANCE (TinselV2 ? sd.yTriggerTop : 20)
-#define DDISTANCE (TinselV2 ? sd.yTriggerBottom : 20)
+#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
diff --git a/engines/tinsel/sound.cpp b/engines/tinsel/sound.cpp
index 130928d885..f575b03270 100644
--- a/engines/tinsel/sound.cpp
+++ b/engines/tinsel/sound.cpp
@@ -49,7 +49,7 @@
namespace Tinsel {
-extern LANGUAGE sampleLanguage;
+extern LANGUAGE g_sampleLanguage;
//--------------------------- General data ----------------------------------
@@ -99,12 +99,12 @@ bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::Sound
// move to correct position in the sample file
_sampleStream.seek(dwSampleIndex);
if (_sampleStream.eos() || _sampleStream.err() || (uint32)_sampleStream.pos() != dwSampleIndex)
- error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
+ error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
// read the length of the sample
uint32 sampleLen = _sampleStream.readUint32();
if (_sampleStream.eos() || _sampleStream.err())
- error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
+ error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
if (TinselV1PSX) {
// Read the stream and create a XA ADPCM audio stream
@@ -124,7 +124,7 @@ bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::Sound
// read all of the sample
if (_sampleStream.read(sampleBuf, sampleLen) != sampleLen)
- error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
+ error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
// FIXME: Should set this in a different place ;)
_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, _vm->_config->_soundVolume);
@@ -254,12 +254,12 @@ bool SoundManager::playSample(int id, int sub, bool bLooped, int x, int y, int p
// move to correct position in the sample file
_sampleStream.seek(dwSampleIndex);
if (_sampleStream.eos() || _sampleStream.err() || (uint32)_sampleStream.pos() != dwSampleIndex)
- error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
+ error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
// read the length of the sample
uint32 sampleLen = _sampleStream.readUint32();
if (_sampleStream.eos() || _sampleStream.err())
- error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
+ error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
if (sampleLen & 0x80000000) {
// Has sub samples
@@ -273,11 +273,11 @@ bool SoundManager::playSample(int id, int sub, bool bLooped, int x, int y, int p
sampleLen = _sampleStream.readUint32();
_sampleStream.skip(sampleLen);
if (_sampleStream.eos() || _sampleStream.err())
- error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
+ error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
}
sampleLen = _sampleStream.readUint32();
if (_sampleStream.eos() || _sampleStream.err())
- error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
+ error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
}
debugC(DEBUG_DETAILED, kTinselDebugSound, "Playing sound %d.%d, %d bytes at %d (pan %d)", id, sub, sampleLen,
@@ -289,7 +289,7 @@ bool SoundManager::playSample(int id, int sub, bool bLooped, int x, int y, int p
// read all of the sample
if (_sampleStream.read(sampleBuf, sampleLen) != sampleLen)
- error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
+ error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
Common::MemoryReadStream *compressedStream =
new Common::MemoryReadStream(sampleBuf, sampleLen, DisposeAfterUse::YES);
@@ -481,7 +481,7 @@ void SoundManager::openSampleFiles() {
return;
// open sample index file in binary mode
- if (f.open(_vm->getSampleIndex(sampleLanguage))) {
+ if (f.open(_vm->getSampleIndex(g_sampleLanguage))) {
// get length of index file
f.seek(0, SEEK_END); // move to end of file
_sampleIndexLen = f.pos(); // get file pointer
@@ -502,7 +502,7 @@ void SoundManager::openSampleFiles() {
// load data
if (f.read(_sampleIndex, _sampleIndexLen) != (uint32)_sampleIndexLen)
// file must be corrupt if we get to here
- error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
+ error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
// close the file
f.close();
@@ -542,28 +542,28 @@ void SoundManager::openSampleFiles() {
_sampleIndex[0] = 0;
} else {
char buf[50];
- sprintf(buf, CANNOT_FIND_FILE, _vm->getSampleIndex(sampleLanguage));
+ sprintf(buf, CANNOT_FIND_FILE, _vm->getSampleIndex(g_sampleLanguage));
GUI::MessageDialog dialog(buf, "OK");
dialog.runModal();
- error(CANNOT_FIND_FILE, _vm->getSampleIndex(sampleLanguage));
+ error(CANNOT_FIND_FILE, _vm->getSampleIndex(g_sampleLanguage));
}
// open sample file in binary mode
- if (!_sampleStream.open(_vm->getSampleFile(sampleLanguage))) {
+ if (!_sampleStream.open(_vm->getSampleFile(g_sampleLanguage))) {
char buf[50];
- sprintf(buf, CANNOT_FIND_FILE, _vm->getSampleFile(sampleLanguage));
+ sprintf(buf, CANNOT_FIND_FILE, _vm->getSampleFile(g_sampleLanguage));
GUI::MessageDialog dialog(buf, "OK");
dialog.runModal();
- error(CANNOT_FIND_FILE, _vm->getSampleFile(sampleLanguage));
+ error(CANNOT_FIND_FILE, _vm->getSampleFile(g_sampleLanguage));
}
/*
// gen length of the largest sample
sampleBuffer.size = _sampleStream.readUint32LE();
if (_sampleStream.eos() || _sampleStream.err())
- error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
+ error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
*/
}
diff --git a/engines/tinsel/strres.cpp b/engines/tinsel/strres.cpp
index f3a7278993..5a29a4d2cd 100644
--- a/engines/tinsel/strres.cpp
+++ b/engines/tinsel/strres.cpp
@@ -38,11 +38,11 @@ namespace Tinsel {
#ifdef DEBUG
// Diagnostic number
-int newestString;
+int g_newestString;
#endif
// buffer for resource strings
-static uint8 *textBuffer = 0;
+static uint8 *g_textBuffer = 0;
static struct {
bool bPresent;
@@ -50,7 +50,7 @@ static struct {
SCNHANDLE hDescription;
SCNHANDLE hFlagFilm;
-} languages[NUM_LANGUAGES] = {
+} g_languages[NUM_LANGUAGES] = {
{ false, "English", 0, 0 },
{ false, "French", 0, 0 },
@@ -65,9 +65,9 @@ static struct {
// Set if we're handling 2-byte characters.
-bool bMultiByte = false;
+bool g_bMultiByte = false;
-LANGUAGE textLanguage, sampleLanguage = TXT_ENGLISH;
+LANGUAGE g_textLanguage, g_sampleLanguage = TXT_ENGLISH;
//----------------- LOCAL DEFINES ----------------------------
@@ -85,12 +85,12 @@ void ChangeLanguage(LANGUAGE newLang) {
TinselFile f;
uint32 textLen = 0; // length of buffer
- textLanguage = newLang;
- sampleLanguage = newLang;
+ g_textLanguage = newLang;
+ g_sampleLanguage = newLang;
// free the previous buffer
- free(textBuffer);
- textBuffer = NULL;
+ free(g_textBuffer);
+ g_textBuffer = NULL;
// Try and open the specified language file. If it fails, and the language
// isn't English, try falling back on opening 'english.txt' - some foreign
@@ -116,22 +116,22 @@ void ChangeLanguage(LANGUAGE newLang) {
if (textLen == CHUNK_STRING || textLen == CHUNK_MBSTRING) {
// the file is uncompressed
- bMultiByte = (textLen == CHUNK_MBSTRING);
+ g_bMultiByte = (textLen == CHUNK_MBSTRING);
// get length of uncompressed file
textLen = f.size();
f.seek(0, SEEK_SET); // Set to beginning of file
- if (textBuffer == NULL) {
+ if (g_textBuffer == NULL) {
// allocate a text buffer for the strings
- textBuffer = (uint8 *)malloc(textLen);
+ g_textBuffer = (uint8 *)malloc(textLen);
// make sure memory allocated
- assert(textBuffer);
+ assert(g_textBuffer);
}
// load data
- if (f.read(textBuffer, textLen) != textLen)
+ if (f.read(g_textBuffer, textLen) != textLen)
// file must be corrupt if we get to here
error(FILE_IS_CORRUPT, _vm->getTextFile(newLang));
@@ -147,7 +147,7 @@ void ChangeLanguage(LANGUAGE newLang) {
*/
static byte *FindStringBase(int id) {
// base of string resource table
- byte *pText = textBuffer;
+ byte *pText = g_textBuffer;
// For Tinsel 0, Ids are decremented by 1
if (TinselV0)
@@ -353,8 +353,8 @@ int SubStringCount(int id) {
void FreeTextBuffer() {
- free(textBuffer);
- textBuffer = NULL;
+ free(g_textBuffer);
+ g_textBuffer = NULL;
}
/**
@@ -364,29 +364,29 @@ void FreeTextBuffer() {
void LanguageFacts(int language, SCNHANDLE hDescription, SCNHANDLE hFlagFilm) {
assert(language >= 0 && language < NUM_LANGUAGES);
- languages[language].hDescription = hDescription;
- languages[language].hFlagFilm = hFlagFilm;
+ g_languages[language].hDescription = hDescription;
+ g_languages[language].hFlagFilm = hFlagFilm;
}
/**
* Gets the current subtitles language
*/
LANGUAGE TextLanguage() {
- return textLanguage;
+ return g_textLanguage;
}
/**
* Gets the current voice language
*/
LANGUAGE SampleLanguage() {
- return sampleLanguage;
+ return g_sampleLanguage;
}
int NumberOfLanguages() {
int i, count;
for (i = 0, count = 0; i < NUM_LANGUAGES; i++) {
- if (languages[i].bPresent)
+ if (g_languages[i].bPresent)
count++;
}
return count;
@@ -396,12 +396,12 @@ LANGUAGE NextLanguage(LANGUAGE thisOne) {
int i;
for (i = thisOne+1; i < NUM_LANGUAGES; i++) {
- if (languages[i].bPresent)
+ if (g_languages[i].bPresent)
return (LANGUAGE)i;
}
for (i = 0; i < thisOne; i++) {
- if (languages[i].bPresent)
+ if (g_languages[i].bPresent)
return (LANGUAGE)i;
}
@@ -413,12 +413,12 @@ LANGUAGE PrevLanguage(LANGUAGE thisOne) {
int i;
for (i = thisOne-1; i >= 0; i--) {
- if (languages[i].bPresent)
+ if (g_languages[i].bPresent)
return (LANGUAGE)i;
}
for (i = NUM_LANGUAGES-1; i > thisOne; i--) {
- if (languages[i].bPresent)
+ if (g_languages[i].bPresent)
return (LANGUAGE)i;
}
@@ -427,11 +427,11 @@ LANGUAGE PrevLanguage(LANGUAGE thisOne) {
}
SCNHANDLE LanguageDesc(LANGUAGE thisOne) {
- return languages[thisOne].hDescription;
+ return g_languages[thisOne].hDescription;
}
SCNHANDLE LanguageFlag(LANGUAGE thisOne) {
- return languages[thisOne].hFlagFilm;
+ return g_languages[thisOne].hFlagFilm;
}
} // End of namespace Tinsel
diff --git a/engines/tinsel/strres.h b/engines/tinsel/strres.h
index f6e86951b6..772896c81f 100644
--- a/engines/tinsel/strres.h
+++ b/engines/tinsel/strres.h
@@ -35,7 +35,7 @@ namespace Tinsel {
#define MAX_STRRES_SIZE 300000 // maximum size of string resource file
// Set if we're handling 2-byte characters.
-extern bool bMultiByte;
+extern bool g_bMultiByte;
/*----------------------------------------------------------------------*\
|* Function Prototypes *|
diff --git a/engines/tinsel/sysvar.cpp b/engines/tinsel/sysvar.cpp
index 88053f15c6..6ef4f165ab 100644
--- a/engines/tinsel/sysvar.cpp
+++ b/engines/tinsel/sysvar.cpp
@@ -43,7 +43,7 @@ extern int NewestSavedGame();
// FIXME: Avoid non-const global vars
-static int systemVars[SV_TOPVALID] = {
+static int g_systemVars[SV_TOPVALID] = {
INV_1, // Default inventory
@@ -105,7 +105,7 @@ static int systemVars[SV_TOPVALID] = {
0 // ISV_GHOST_COLOR
};
-static SCNHANDLE systemStrings[SS_MAX_VALID]; // FIXME: Avoid non-const global vars
+static SCNHANDLE g_systemStrings[SS_MAX_VALID]; // FIXME: Avoid non-const global vars
//static bool bFlagNoBlocking = false;
@@ -116,8 +116,8 @@ static SCNHANDLE systemStrings[SS_MAX_VALID]; // FIXME: Avoid non-const global v
*/
void InitSysVars() {
- systemVars[SV_SCROLL_XDISTANCE] = SCREEN_WIDTH / 2;
- systemVars[SV_SCROLL_YDISTANCE] = SCREEN_BOX_HEIGHT1 / 2;
+ g_systemVars[SV_SCROLL_XDISTANCE] = SCREEN_WIDTH / 2;
+ g_systemVars[SV_SCROLL_YDISTANCE] = SCREEN_BOX_HEIGHT1 / 2;
}
/**
@@ -138,7 +138,7 @@ void SetSysVar(int varId, int newValue) {
error("SetSystemVar(): read only identifier");
default:
- systemVars[varId] = newValue;
+ g_systemVars[varId] = newValue;
}
}
@@ -167,28 +167,28 @@ int SysVar(int varId) {
//return bDebuggingAllowed;
default:
- return systemVars[varId];
+ return g_systemVars[varId];
}
}
void SaveSysVars(int *pSv) {
- memcpy(pSv, systemVars, sizeof(systemVars));
+ memcpy(pSv, g_systemVars, sizeof(g_systemVars));
}
void RestoreSysVars(int *pSv) {
- memcpy(systemVars, pSv, sizeof(systemVars));
+ memcpy(g_systemVars, pSv, sizeof(g_systemVars));
}
void SetSysString(int number, SCNHANDLE hString) {
assert(number >= 0 && number < SS_MAX_VALID);
- systemStrings[number] = hString;
+ g_systemStrings[number] = hString;
}
SCNHANDLE SysString(int number) {
assert(number >= 0 && number < SS_MAX_VALID);
- return systemStrings[number];
+ return g_systemStrings[number];
}
/**
diff --git a/engines/tinsel/text.cpp b/engines/tinsel/text.cpp
index ecb1e153f3..5eb092d00d 100644
--- a/engines/tinsel/text.cpp
+++ b/engines/tinsel/text.cpp
@@ -25,7 +25,7 @@
#include "tinsel/graphics.h" // object plotting
#include "tinsel/handle.h"
#include "tinsel/sched.h" // process scheduler defines
-#include "tinsel/strres.h" // bMultiByte
+#include "tinsel/strres.h" // g_bMultiByte
#include "tinsel/text.h" // text defines
namespace Tinsel {
@@ -42,7 +42,7 @@ int StringLengthPix(char *szStr, const FONT *pFont) {
// while not end of string or end of line
for (strLen = 0; (c = *szStr) != EOS_CHAR && c != LF_CHAR; szStr++) {
- if (bMultiByte) {
+ if (g_bMultiByte) {
if (c & 0x80)
c = ((c & ~0x80) << 8) + *++szStr;
}
@@ -136,7 +136,7 @@ OBJECT *ObjectTextOut(OBJECT **pList, char *szStr, int color,
// repeat until end of string or end of line
while ((c = *szStr) != EOS_CHAR && c != LF_CHAR) {
- if (bMultiByte) {
+ if (g_bMultiByte) {
if (c & 0x80)
c = ((c & ~0x80) << 8) + *++szStr;
}
@@ -265,7 +265,7 @@ bool IsCharImage(SCNHANDLE hFont, char c) {
// Inventory save game name editor needs to be more clever for
// multi-byte characters. This bodge will stop it erring.
- if (bMultiByte && (c2 & 0x80))
+ if (g_bMultiByte && (c2 & 0x80))
return false;
// get font pointer
diff --git a/engines/tinsel/timers.cpp b/engines/tinsel/timers.cpp
index 1c3ff9b260..d3a7446565 100644
--- a/engines/tinsel/timers.cpp
+++ b/engines/tinsel/timers.cpp
@@ -49,7 +49,7 @@ struct TIMER {
//----------------- LOCAL GLOBAL DATA --------------------
-static TIMER timers[MAX_TIMERS]; // FIXME: Avoid non-const global vars
+static TIMER g_timers[MAX_TIMERS]; // FIXME: Avoid non-const global vars
//--------------------------------------------------------
@@ -72,7 +72,7 @@ uint32 DwGetCurrentTime() {
*/
void RebootTimers() {
- memset(timers, 0, sizeof(timers));
+ memset(g_timers, 0, sizeof(g_timers));
}
/**
@@ -80,11 +80,11 @@ void RebootTimers() {
*/
void syncTimerInfo(Common::Serializer &s) {
for (int i = 0; i < MAX_TIMERS; i++) {
- s.syncAsSint32LE(timers[i].tno);
- s.syncAsSint32LE(timers[i].ticks);
- s.syncAsSint32LE(timers[i].secs);
- s.syncAsSint32LE(timers[i].delta);
- s.syncAsSint32LE(timers[i].frame);
+ s.syncAsSint32LE(g_timers[i].tno);
+ s.syncAsSint32LE(g_timers[i].ticks);
+ s.syncAsSint32LE(g_timers[i].secs);
+ s.syncAsSint32LE(g_timers[i].delta);
+ s.syncAsSint32LE(g_timers[i].frame);
}
}
@@ -95,8 +95,8 @@ void syncTimerInfo(Common::Serializer &s) {
*/
static TIMER *findTimer(int num) {
for (int i = 0; i < MAX_TIMERS; i++) {
- if (timers[i].tno == num)
- return &timers[i];
+ if (g_timers[i].tno == num)
+ return &g_timers[i];
}
return NULL;
}
@@ -109,9 +109,9 @@ static TIMER *allocateTimer(int num) {
assert(!findTimer(num)); // Allocating already existant timer
for (int i = 0; i < MAX_TIMERS; i++) {
- if (!timers[i].tno) {
- timers[i].tno = num;
- return &timers[i];
+ if (!g_timers[i].tno) {
+ g_timers[i].tno = num;
+ return &g_timers[i];
}
}
@@ -123,23 +123,23 @@ static TIMER *allocateTimer(int num) {
*/
void FettleTimers() {
for (int i = 0; i < MAX_TIMERS; i++) {
- if (!timers[i].tno)
+ if (!g_timers[i].tno)
continue;
- timers[i].ticks += timers[i].delta; // Update tick value
+ g_timers[i].ticks += g_timers[i].delta; // Update tick value
- if (timers[i].frame) {
- if (timers[i].ticks < 0)
- timers[i].ticks = 0; // Have reached zero
+ if (g_timers[i].frame) {
+ if (g_timers[i].ticks < 0)
+ g_timers[i].ticks = 0; // Have reached zero
} else {
- if (timers[i].ticks < 0) {
- timers[i].ticks = ONE_SECOND;
- timers[i].secs--;
- if (timers[i].secs < 0)
- timers[i].secs = 0; // Have reached zero
- } else if (timers[i].ticks == ONE_SECOND) {
- timers[i].ticks = 0;
- timers[i].secs++; // Another second has passed
+ if (g_timers[i].ticks < 0) {
+ g_timers[i].ticks = ONE_SECOND;
+ g_timers[i].secs--;
+ if (g_timers[i].secs < 0)
+ g_timers[i].secs = 0; // Have reached zero
+ } else if (g_timers[i].ticks == ONE_SECOND) {
+ g_timers[i].ticks = 0;
+ g_timers[i].secs++; // Another second has passed
}
}
}
diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp
index 7fbec69cbf..c652abca25 100644
--- a/engines/tinsel/tinlib.cpp
+++ b/engines/tinsel/tinlib.cpp
@@ -74,11 +74,11 @@ namespace Tinsel {
//----------------- EXTERNAL GLOBAL DATA --------------------
// In DOS_DW.C
-extern bool bRestart; // restart flag - set to restart the game
-extern bool bHasRestarted; // Set after a restart
+extern bool g_bRestart; // restart flag - set to restart the game
+extern bool g_bHasRestarted; // Set after a restart
// In PCODE.CPP
-extern bool bNoPause;
+extern bool g_bNoPause;
// In DOS_MAIN.C
// TODO/FIXME: From dos_main.c: "Only used on PSX so far"
@@ -100,7 +100,7 @@ extern int NewestSavedGame();
// in SCENE.CPP
extern void setshowpos();
-extern int sceneCtr;
+extern int g_sceneCtr;
// in TINSEL.CPP
extern void SetCdChangeScene(SCNHANDLE hScene);
@@ -122,10 +122,10 @@ SCNHANDLE GetSceneHandle();
// FIXME: Avoid non-const global vars
-bool bEnableMenu;
+bool g_bEnableMenu;
-static bool bInstantScroll = false;
-static bool bEscapedCdPlay = false;
+static bool g_bInstantScroll = false;
+static bool g_bEscapedCdPlay = false;
//----------------- LOCAL DEFINES --------------------
@@ -298,13 +298,13 @@ static const MASTER_LIB_CODES DW2_CODES[] = {
// as it was at control(off).
// They are global so that MoveCursor(..) has a net effect if it
// precedes control(on).
-static int controlX = 0, controlY = 0;
+static int g_controlX = 0, g_controlY = 0;
-static int offtype = 0; // used by Control()
-static uint32 lastValue = 0; // used by RandomFn()
-static int scrollNumber = 0; // used by scroll()
+static int g_offtype = 0; // used by Control()
+static uint32 g_lastValue = 0; // used by RandomFn()
+static int g_scrollNumber = 0; // used by scroll()
-static bool bNotPointedRunning = false; // Used in Printobj and PrintObjPointed
+static bool g_bNotPointedRunning = false; // Used in Printobj and PrintObjPointed
//----------------- FORWARD REFERENCES --------------------
@@ -404,7 +404,7 @@ static void ScrollMonitorProcess(CORO_PARAM, const void *param) {
CORO_SLEEP(1);
// give up if have been superseded
- if (psm->thisScroll != scrollNumber)
+ if (psm->thisScroll != g_scrollNumber)
break;
// If ESCAPE is pressed...
@@ -706,7 +706,7 @@ static void CDload(SCNHANDLE start, SCNHANDLE next, int myEscape) {
if (TinselV2) {
if (myEscape && myEscape != GetEscEvents()) {
- bEscapedCdPlay = true;
+ g_bEscapedCdPlay = true;
return;
}
@@ -754,14 +754,14 @@ void Control(int param) {
}
// Tinsel 1 handling code
- bEnableMenu = false;
+ g_bEnableMenu = false;
switch (param) {
case CONTROL_STARTOFF:
GetControlToken(); // Take control
DisableTags(); // Switch off tags
DwHideCursor(); // Blank out cursor
- offtype = param;
+ g_offtype = param;
break;
case CONTROL_OFF:
@@ -771,17 +771,17 @@ void Control(int param) {
GetControlToken(); // Take control
DisableTags(); // Switch off tags
- GetCursorXYNoWait(&controlX, &controlY, true); // Store cursor position
+ GetCursorXYNoWait(&g_controlX, &g_controlY, true); // Store cursor position
// There may be a button timing out
GetToken(TOKEN_LEFT_BUT);
FreeToken(TOKEN_LEFT_BUT);
}
- if (offtype == CONTROL_STARTOFF)
- GetCursorXYNoWait(&controlX, &controlY, true); // Store cursor position
+ if (g_offtype == CONTROL_STARTOFF)
+ GetCursorXYNoWait(&g_controlX, &g_controlY, true); // Store cursor position
- offtype = param;
+ g_offtype = param;
if (param == CONTROL_OFF)
DwHideCursor(); // Blank out cursor
@@ -794,8 +794,8 @@ void Control(int param) {
break;
case CONTROL_ON:
- if (offtype != CONTROL_OFFV2 && offtype != CONTROL_STARTOFF)
- SetCursorXY(controlX, controlY);// ... where it was
+ if (g_offtype != CONTROL_OFFV2 && g_offtype != CONTROL_STARTOFF)
+ SetCursorXY(g_controlX, g_controlY);// ... where it was
FreeControlToken(); // Release control
@@ -1092,7 +1092,7 @@ static void DropEverything() {
* EnableMenu
*/
static void EnableMenu() {
- bEnableMenu = true;
+ g_bEnableMenu = true;
}
/**
@@ -1212,7 +1212,7 @@ static void HailScene(SCNHANDLE scene) {
* Returns TRUE if the game has been restarted, FALSE if not.
*/
static bool HasRestarted() {
- return bHasRestarted;
+ return g_bHasRestarted;
}
/**
@@ -1308,7 +1308,7 @@ static int IdleTime() {
* Set flag if InstantScroll(on), reset if InstantScroll(off)
*/
void InstantScroll(int onoff) {
- bInstantScroll = (onoff != 0);
+ g_bInstantScroll = (onoff != 0);
}
/**
@@ -1419,8 +1419,8 @@ static int LToffset(int lort) {
static void MoveCursor(int x, int y) {
SetCursorXY(x, y);
- controlX = x; // Save these values so that
- controlY = y; // control(on) doesn't undo this
+ g_controlX = x; // Save these values so that
+ g_controlY = y; // control(on) doesn't undo this
}
/**
@@ -1465,7 +1465,7 @@ void NewScene(CORO_PARAM, SCNHANDLE scene, int entrance, int transition) {
GetControl(CONTROL_STARTOFF);
if (TinselV1)
- ++sceneCtr;
+ ++g_sceneCtr;
// Prevent code subsequent to this call running before scene changes
if (g_scheduler->getCurrentPID() != PID_MASTER_SCR)
@@ -1541,8 +1541,8 @@ static void Play(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int compit, int acto
// Don't do CDPlay() for now if already escaped
- if (bEscapedCdPlay) {
- bEscapedCdPlay = false;
+ if (g_bEscapedCdPlay) {
+ g_bEscapedCdPlay = false;
return;
}
@@ -1583,8 +1583,8 @@ static void Play(CORO_PARAM, SCNHANDLE hFilm, int x, int y, bool bComplete, int
assert(hFilm != 0);
// Don't do CdPlay() for now if already escaped
- if (bEscapedCdPlay) {
- bEscapedCdPlay = false;
+ if (g_bEscapedCdPlay) {
+ g_bEscapedCdPlay = false;
return;
}
@@ -2068,11 +2068,11 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
_ctx->myEscape = myEscape;
if (hText == (SCNHANDLE)-1) { // 'OFF'
- bNotPointedRunning = true;
+ g_bNotPointedRunning = true;
return;
}
if (hText == (SCNHANDLE)-2) { // 'ON'
- bNotPointedRunning = false;
+ g_bNotPointedRunning = false;
return;
}
@@ -2092,10 +2092,10 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
* POINT/other event PrintObj() arbitration...
*/
if (event != POINTED) {
- bNotPointedRunning = true; // Get POINTED text to die
+ g_bNotPointedRunning = true; // Get POINTED text to die
CORO_SLEEP(1); // Give it chance to
} else if (!TinselV2)
- bNotPointedRunning = false; // There may have been an OFF without an ON
+ g_bNotPointedRunning = false; // There may have been an OFF without an ON
// Make multi-ones escape
if (TinselV2 && (SubStringCount(hText) > 1) && !_ctx->myEscape)
@@ -2163,12 +2163,12 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
break;
// Give way to non-POINTED-generated text
- if (bNotPointedRunning) {
+ if (g_bNotPointedRunning) {
// Delete the text, and wait for the all-clear
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->pText);
_ctx->pText = NULL;
- while (bNotPointedRunning)
+ while (g_bNotPointedRunning)
CORO_SLEEP(1);
GetCursorXY(&x, &y, false);
@@ -2262,7 +2262,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
// Let POINTED text back in if this is the last
if (event != POINTED)
- bNotPointedRunning = false;
+ g_bNotPointedRunning = false;
CORO_END_CODE;
}
@@ -2281,11 +2281,11 @@ static void PrintObjPointed(CORO_PARAM, const SCNHANDLE text, const INV_OBJECT *
break;
// Give way to non-POINTED-generated text
- if (bNotPointedRunning) {
+ if (g_bNotPointedRunning) {
// Delete the text, and wait for the all-clear
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), pText);
pText = NULL;
- while (bNotPointedRunning)
+ while (g_bNotPointedRunning)
CORO_SLEEP(1);
GetCursorXY(&x, &y, false);
@@ -2372,7 +2372,7 @@ static void PrintObjNonPointed(CORO_PARAM, const SCNHANDLE text, const OBJECT *p
}
} while (1);
- bNotPointedRunning = false; // Let POINTED text back in
+ g_bNotPointedRunning = false; // Let POINTED text back in
if (_ctx->took_control)
Control(CONTROL_ON); // Free control if we took it
@@ -2425,9 +2425,9 @@ static int RandomFn(int n1, int n2, int norpt) {
do {
value = n1 + _vm->getRandomNumber(n2 - n1);
- } while ((lastValue == value) && (norpt == RAND_NORPT) && (++i <= 10));
+ } while ((g_lastValue == value) && (norpt == RAND_NORPT) && (++i <= 10));
- lastValue = value;
+ g_lastValue = value;
return value;
}
@@ -2446,8 +2446,8 @@ void FnRestartGame() {
StopMidi();
StopSample();
- bRestart = true;
- sceneCtr = 0;
+ g_bRestart = true;
+ g_sceneCtr = 0;
}
/**
@@ -2554,15 +2554,15 @@ static void Scroll(CORO_PARAM, EXTREME extreme, int xp, int yp, int xIter, int y
CORO_BEGIN_CODE(_ctx);
- ++scrollNumber;
+ ++g_scrollNumber;
_ctx->x = xp;
_ctx->y = yp;
- if ((TinselV2 && bInstantScroll) || (escOn && myEscape != GetEscEvents())) {
+ if ((TinselV2 && g_bInstantScroll) || (escOn && myEscape != GetEscEvents())) {
// Instant completion!
Offset(extreme, _ctx->x, _ctx->y);
} else {
- _ctx->thisScroll = scrollNumber;
+ _ctx->thisScroll = g_scrollNumber;
if (TinselV2)
DecodeExtreme(extreme, &_ctx->x, &_ctx->y);
@@ -2581,7 +2581,7 @@ static void Scroll(CORO_PARAM, EXTREME extreme, int xp, int yp, int xIter, int y
}
// give up if have been superseded
- if (_ctx->thisScroll != scrollNumber)
+ if (_ctx->thisScroll != g_scrollNumber)
CORO_KILL_SELF();
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
@@ -2592,7 +2592,7 @@ static void Scroll(CORO_PARAM, EXTREME extreme, int xp, int yp, int xIter, int y
// Scroll is escapable even though we're not waiting for it
sm.x = _ctx->x;
sm.y = _ctx->y;
- sm.thisScroll = scrollNumber;
+ sm.thisScroll = g_scrollNumber;
sm.myEscape = myEscape;
g_scheduler->createProcess(PID_TCODE, ScrollMonitorProcess, &sm, sizeof(sm));
}
@@ -3410,8 +3410,8 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
if (TinselV2 && _ctx->bSample) {
// Kick off the sample now (perhaps with a delay)
- if (bNoPause)
- bNoPause = false;
+ if (g_bNoPause)
+ g_bNoPause = false;
else if (!IsDemo)
CORO_SLEEP(SysVar(SV_SPEECHDELAY));
@@ -4899,7 +4899,7 @@ int CallLibraryRoutine(CORO_PARAM, int operand, int32 *pp, const INT_CONTEXT *pi
case NOPAUSE:
// DW2 only
- bNoPause = true;
+ g_bNoPause = true;
return 0;
case NOSCROLL:
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index cd0f9b9fa4..65900cc7f3 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -66,7 +66,7 @@ namespace Tinsel {
// In BG.CPP
extern void SetDoFadeIn(bool tf);
extern void DropBackground();
-extern const BACKGND *pCurBgnd;
+extern const BACKGND *g_pCurBgnd;
// In CURSOR.CPP
extern void CursorProcess(CORO_PARAM, const void *);
@@ -85,16 +85,16 @@ void SetNewScene(SCNHANDLE scene, int entrance, int transition);
// FIXME: Avoid non-const global vars
-bool bRestart = false;
-bool bHasRestarted = false;
-bool loadingFromGMM = false;
+bool g_bRestart = false;
+bool g_bHasRestarted = false;
+bool g_loadingFromGMM = false;
-static bool bCuttingScene = false;
+static bool g_bCuttingScene = false;
-static bool bChangingForRestore = false;
+static bool g_bChangingForRestore = false;
#ifdef DEBUG
-bool bFast; // set to make it go ludicrously fast
+bool g_bFast; // set to make it go ludicrously fast
#endif
//----------------- LOCAL GLOBAL DATA --------------------
@@ -105,14 +105,14 @@ struct Scene {
int trans; // Transition - not yet used
};
-static Scene NextScene = { 0, 0, 0 };
-static Scene HookScene = { 0, 0, 0 };
-static Scene DelayedScene = { 0, 0, 0 };
+static Scene g_NextScene = { 0, 0, 0 };
+static Scene g_HookScene = { 0, 0, 0 };
+static Scene g_DelayedScene = { 0, 0, 0 };
-static PROCESS *pMouseProcess = 0;
-static PROCESS *pKeyboardProcess = 0;
+static PROCESS *g_pMouseProcess = 0;
+static PROCESS *g_pKeyboardProcess = 0;
-static SCNHANDLE hCdChangeScene;
+static SCNHANDLE g_hCdChangeScene;
//----------------- LOCAL PROCEDURES --------------------
@@ -457,49 +457,49 @@ static void MasterScriptProcess(CORO_PARAM, const void *) {
* Store the facts pertaining to a scene change.
*/
void SetNewScene(SCNHANDLE scene, int entrance, int transition) {
- if (!bCuttingScene && TinselV2)
+ if (!g_bCuttingScene && TinselV2)
WrapScene();
// If we're loading from the GMM, load the scene as a delayed one
- if (loadingFromGMM) {
- DelayedScene.scene = scene;
- DelayedScene.entry = entrance;
- DelayedScene.trans = transition;
- loadingFromGMM = false;
+ if (g_loadingFromGMM) {
+ g_DelayedScene.scene = scene;
+ g_DelayedScene.entry = entrance;
+ g_DelayedScene.trans = transition;
+ g_loadingFromGMM = false;
return;
}
// If CD change will be required, stick in the scene change scene
if (CdNumber(scene) != GetCurrentCD()) {
// This scene gets delayed
- DelayedScene.scene = scene;
- DelayedScene.entry = entrance;
- DelayedScene.trans = transition;
+ g_DelayedScene.scene = scene;
+ g_DelayedScene.entry = entrance;
+ g_DelayedScene.trans = transition;
- NextScene.scene = hCdChangeScene;
- NextScene.entry = CdNumber(scene) - '0';
- NextScene.trans = TRANS_FADE;
+ g_NextScene.scene = g_hCdChangeScene;
+ g_NextScene.entry = CdNumber(scene) - '0';
+ g_NextScene.trans = TRANS_FADE;
return;
}
- if (HookScene.scene == 0 || bCuttingScene) {
+ if (g_HookScene.scene == 0 || g_bCuttingScene) {
// This scene comes next
- NextScene.scene = scene;
- NextScene.entry = entrance;
- NextScene.trans = transition;
+ g_NextScene.scene = scene;
+ g_NextScene.entry = entrance;
+ g_NextScene.trans = transition;
} else {
// This scene gets delayed
- DelayedScene.scene = scene;
- DelayedScene.entry = entrance;
- DelayedScene.trans = transition;
+ g_DelayedScene.scene = scene;
+ g_DelayedScene.entry = entrance;
+ g_DelayedScene.trans = transition;
// The hooked scene comes next
- NextScene.scene = HookScene.scene;
- NextScene.entry = HookScene.entry;
- NextScene.trans = HookScene.trans;
+ g_NextScene.scene = g_HookScene.scene;
+ g_NextScene.entry = g_HookScene.entry;
+ g_NextScene.trans = g_HookScene.trans;
- HookScene.scene = 0;
+ g_HookScene.scene = 0;
}
// Workaround for "Missing Red Dragon in square" bug in Discworld 1 PSX, act IV.
@@ -509,10 +509,10 @@ void SetNewScene(SCNHANDLE scene, int entrance, int transition) {
// I'm forcing the load of the right scene by checking that the player has (or has not) the
// 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 && NextScene.scene == 0x1800000 && NextScene.entry == 2) {
+ 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)))
- NextScene.entry = 1;
+ g_NextScene.entry = 1;
}
}
@@ -520,72 +520,72 @@ void SetNewScene(SCNHANDLE scene, int entrance, int transition) {
* Store a scene as hooked
*/
void SetHookScene(SCNHANDLE scene, int entrance, int transition) {
- assert(HookScene.scene == 0); // scene already hooked
+ assert(g_HookScene.scene == 0); // scene already hooked
- HookScene.scene = scene;
- HookScene.entry = entrance;
- HookScene.trans = transition;
+ g_HookScene.scene = scene;
+ g_HookScene.entry = entrance;
+ g_HookScene.trans = transition;
}
/**
* Hooked scene is over, trigger a change to the delayed scene
*/
void UnHookScene() {
- assert(DelayedScene.scene != 0); // no scene delayed
+ assert(g_DelayedScene.scene != 0); // no scene delayed
// The delayed scene can go now
- NextScene.scene = DelayedScene.scene;
- NextScene.entry = DelayedScene.entry;
- NextScene.trans = DelayedScene.trans;
+ g_NextScene.scene = g_DelayedScene.scene;
+ g_NextScene.entry = g_DelayedScene.entry;
+ g_NextScene.trans = g_DelayedScene.trans;
- DelayedScene.scene = 0;
+ g_DelayedScene.scene = 0;
}
void SuspendHook() {
- bCuttingScene = true;
+ g_bCuttingScene = true;
}
void CdHasChanged() {
- if (bChangingForRestore) {
- bChangingForRestore = false;
+ if (g_bChangingForRestore) {
+ g_bChangingForRestore = false;
RestoreGame(-2);
} else {
- assert(DelayedScene.scene != 0);
+ assert(g_DelayedScene.scene != 0);
WrapScene();
// The delayed scene can go now
- NextScene.scene = DelayedScene.scene;
- NextScene.entry = DelayedScene.entry;
- NextScene.trans = DelayedScene.trans;
+ g_NextScene.scene = g_DelayedScene.scene;
+ g_NextScene.entry = g_DelayedScene.entry;
+ g_NextScene.trans = g_DelayedScene.trans;
- DelayedScene.scene = 0;
+ g_DelayedScene.scene = 0;
}
}
void SetCdChangeScene(SCNHANDLE hScene) {
- hCdChangeScene = hScene;
+ g_hCdChangeScene = hScene;
}
void CDChangeForRestore(int cdNumber) {
- NextScene.scene = hCdChangeScene;
- NextScene.entry = cdNumber;
- NextScene.trans = TRANS_FADE;
- bChangingForRestore = true;
+ g_NextScene.scene = g_hCdChangeScene;
+ g_NextScene.entry = cdNumber;
+ g_NextScene.trans = TRANS_FADE;
+ g_bChangingForRestore = true;
}
void UnSuspendHook() {
- bCuttingScene = false;
+ g_bCuttingScene = false;
}
void syncSCdata(Common::Serializer &s) {
- s.syncAsUint32LE(HookScene.scene);
- s.syncAsSint32LE(HookScene.entry);
- s.syncAsSint32LE(HookScene.trans);
+ s.syncAsUint32LE(g_HookScene.scene);
+ s.syncAsSint32LE(g_HookScene.entry);
+ s.syncAsSint32LE(g_HookScene.trans);
- s.syncAsUint32LE(DelayedScene.scene);
- s.syncAsSint32LE(DelayedScene.entry);
- s.syncAsSint32LE(DelayedScene.trans);
+ s.syncAsUint32LE(g_DelayedScene.scene);
+ s.syncAsSint32LE(g_DelayedScene.entry);
+ s.syncAsSint32LE(g_DelayedScene.trans);
}
@@ -640,16 +640,16 @@ bool ChangeScene(bool bReset) {
// Prevent attempt to fade-out when restarting game
if (bReset) {
CountOut = 1; // immediate start of first scene again
- DelayedScene.scene = HookScene.scene = 0;
+ g_DelayedScene.scene = g_HookScene.scene = 0;
return false;
}
if (IsRestoringScene())
return true;
- if (NextScene.scene != 0) {
+ if (g_NextScene.scene != 0) {
if (!CountOut) {
- switch (NextScene.trans) {
+ switch (g_NextScene.trans) {
case TRANS_CUT:
CountOut = 1;
break;
@@ -667,10 +667,10 @@ bool ChangeScene(bool bReset) {
if (!TinselV2)
ClearScreen();
- StartNewScene(NextScene.scene, NextScene.entry);
- NextScene.scene = 0;
+ StartNewScene(g_NextScene.scene, g_NextScene.entry);
+ g_NextScene.scene = 0;
- switch (NextScene.trans) {
+ switch (g_NextScene.trans) {
case TRANS_CUT:
SetDoFadeIn(false);
break;
@@ -691,7 +691,7 @@ bool ChangeScene(bool bReset) {
* CuttingScene
*/
void CuttingScene(bool bCutting) {
- bCuttingScene = bCutting;
+ g_bCuttingScene = bCutting;
if (!bCutting)
WrapScene();
@@ -927,7 +927,7 @@ Common::Error TinselEngine::run() {
RebootTimers();
RebootScalingReels();
- DelayedScene.scene = HookScene.scene = 0;
+ g_DelayedScene.scene = g_HookScene.scene = 0;
#endif
// Load in text strings
@@ -957,7 +957,7 @@ Common::Error TinselEngine::run() {
if (ConfMan.hasKey("save_slot")) {
if (loadGameState(ConfMan.getInt("save_slot")).getCode() == Common::kNoError)
- loadingFromGMM = true;
+ g_loadingFromGMM = true;
}
// Foreground loop
@@ -973,10 +973,10 @@ Common::Error TinselEngine::run() {
NextGameCycle();
}
- if (bRestart) {
+ if (g_bRestart) {
RestartGame();
- bRestart = false;
- bHasRestarted = true; // Set restarted flag
+ g_bRestart = false;
+ g_bHasRestarted = true; // Set restarted flag
}
// Save/Restore scene file transfers
@@ -986,7 +986,7 @@ Common::Error TinselEngine::run() {
_bmv->FettleBMV();
#ifdef DEBUG
- if (bFast)
+ if (g_bFast)
continue; // run flat-out
#endif
// Loop processing events while there are any pending
@@ -1005,7 +1005,7 @@ Common::Error TinselEngine::run() {
_vm->_config->writeToDisk();
EndScene();
- pCurBgnd = NULL;
+ g_pCurBgnd = NULL;
return Common::kNoError;
}
@@ -1106,7 +1106,7 @@ void TinselEngine::RestartGame() {
RebootTimers();
RebootScalingReels();
- DelayedScene.scene = HookScene.scene = 0;
+ g_DelayedScene.scene = g_HookScene.scene = 0;
// remove keyboard, mouse and joystick drivers
ChopDrivers();
@@ -1135,8 +1135,8 @@ void TinselEngine::RestartDrivers() {
_scheduler->reset();
// init the event handlers
- pMouseProcess = _scheduler->createProcess(PID_MOUSE, MouseProcess, NULL, 0);
- pKeyboardProcess = _scheduler->createProcess(PID_KEYBOARD, KeyboardProcess, NULL, 0);
+ g_pMouseProcess = _scheduler->createProcess(PID_MOUSE, MouseProcess, NULL, 0);
+ g_pKeyboardProcess = _scheduler->createProcess(PID_KEYBOARD, KeyboardProcess, NULL, 0);
// open MIDI files
OpenMidiFiles();
@@ -1164,8 +1164,8 @@ void TinselEngine::ChopDrivers() {
DeleteMidiBuffer();
// remove event drivers
- _scheduler->killProcess(pMouseProcess);
- _scheduler->killProcess(pKeyboardProcess);
+ _scheduler->killProcess(g_pMouseProcess);
+ _scheduler->killProcess(g_pKeyboardProcess);
}
/**
diff --git a/engines/tinsel/token.cpp b/engines/tinsel/token.cpp
index c7490a100b..c26fa40466 100644
--- a/engines/tinsel/token.cpp
+++ b/engines/tinsel/token.cpp
@@ -34,7 +34,7 @@ struct Token {
PROCESS *proc;
};
-static Token tokens[NUMTOKENS]; // FIXME: Avoid non-const global vars
+static Token g_tokens[NUMTOKENS]; // FIXME: Avoid non-const global vars
/**
@@ -44,8 +44,8 @@ static void TerminateProcess(PROCESS *tProc) {
// Release tokens held by the process
for (int i = 0; i < NUMTOKENS; i++) {
- if (tokens[i].proc == tProc) {
- tokens[i].proc = NULL;
+ if (g_tokens[i].proc == tProc) {
+ g_tokens[i].proc = NULL;
}
}
@@ -59,8 +59,8 @@ static void TerminateProcess(PROCESS *tProc) {
void GetControlToken() {
const int which = TOKEN_CONTROL;
- if (tokens[which].proc == NULL) {
- tokens[which].proc = g_scheduler->getCurrentProcess();
+ if (g_tokens[which].proc == NULL) {
+ g_tokens[which].proc = g_scheduler->getCurrentProcess();
}
}
@@ -69,7 +69,7 @@ void GetControlToken() {
*/
void FreeControlToken() {
// Allow anyone to free TOKEN_CONTROL
- tokens[TOKEN_CONTROL].proc = NULL;
+ g_tokens[TOKEN_CONTROL].proc = NULL;
}
@@ -84,12 +84,12 @@ void FreeControlToken() {
void GetToken(int which) {
assert(TOKEN_LEAD <= which && which < NUMTOKENS);
- if (tokens[which].proc != NULL) {
- assert(tokens[which].proc != g_scheduler->getCurrentProcess());
- TerminateProcess(tokens[which].proc);
+ if (g_tokens[which].proc != NULL) {
+ assert(g_tokens[which].proc != g_scheduler->getCurrentProcess());
+ TerminateProcess(g_tokens[which].proc);
}
- tokens[which].proc = g_scheduler->getCurrentProcess();
+ g_tokens[which].proc = g_scheduler->getCurrentProcess();
}
/**
@@ -99,9 +99,9 @@ void GetToken(int which) {
void FreeToken(int which) {
assert(TOKEN_LEAD <= which && which < NUMTOKENS);
- assert(tokens[which].proc == g_scheduler->getCurrentProcess()); // we'd have been killed if some other proc had taken this token
+ assert(g_tokens[which].proc == g_scheduler->getCurrentProcess()); // we'd have been killed if some other proc had taken this token
- tokens[which].proc = NULL;
+ g_tokens[which].proc = NULL;
}
/**
@@ -111,7 +111,7 @@ bool TestToken(int which) {
if (which < 0 || which >= NUMTOKENS)
return false;
- return (tokens[which].proc == NULL);
+ return (g_tokens[which].proc == NULL);
}
/**
@@ -119,7 +119,7 @@ bool TestToken(int which) {
*/
void FreeAllTokens() {
for (int i = 0; i < NUMTOKENS; i++) {
- tokens[i].proc = NULL;
+ g_tokens[i].proc = NULL;
}
}