[Scummvm-git-logs] scummvm master -> 41d4212da897dddd7f07e166848789fe3b78adf0
bluegr
bluegr at gmail.com
Fri Sep 25 19:29:28 UTC 2020
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
4f269c76d1 TINSEL: Move all cursor-related functions into a new Cursor class
c83e7cd6b0 TINSEL: Rename variables in the Cursor class
0931d7d3fc TINSEL: rework a static variable, and use C++ style lists
41d4212da8 TINSEL: Remove an unneeded static
Commit: 4f269c76d1e9b4adecc5977f58c8c52d34caf79f
https://github.com/scummvm/scummvm/commit/4f269c76d1e9b4adecc5977f58c8c52d34caf79f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-09-25T22:24:14+03:00
Commit Message:
TINSEL: Move all cursor-related functions into a new Cursor class
Changed paths:
engines/tinsel/bg.cpp
engines/tinsel/cursor.cpp
engines/tinsel/cursor.h
engines/tinsel/dialogs.cpp
engines/tinsel/events.cpp
engines/tinsel/move.cpp
engines/tinsel/object.h
engines/tinsel/pdisplay.cpp
engines/tinsel/scene.cpp
engines/tinsel/scroll.cpp
engines/tinsel/tinlib.cpp
engines/tinsel/tinsel.cpp
engines/tinsel/tinsel.h
diff --git a/engines/tinsel/bg.cpp b/engines/tinsel/bg.cpp
index e98c66fe13..cf25b50fd5 100644
--- a/engines/tinsel/bg.cpp
+++ b/engines/tinsel/bg.cpp
@@ -23,6 +23,7 @@
#include "tinsel/anim.h"
#include "tinsel/background.h"
+#include "tinsel/cursor.h"
#include "tinsel/dw.h"
#include "tinsel/faders.h"
#include "tinsel/film.h"
@@ -171,7 +172,7 @@ void Background::StartupBackground(CORO_PARAM, SCNHANDLE hFilm) {
_hBackground = hFilm; // Save handle in case of Save_Scene()
- pim = GetImageFromFilm(hFilm, 0, NULL, NULL, &pfilm);
+ pim = _vm->_cursor->GetImageFromFilm(hFilm, 0, NULL, NULL, &pfilm);
SetBackPal(FROM_32(pim->hImgPal));
diff --git a/engines/tinsel/cursor.cpp b/engines/tinsel/cursor.cpp
index bc741bee87..c85715c294 100644
--- a/engines/tinsel/cursor.cpp
+++ b/engines/tinsel/cursor.cpp
@@ -51,65 +51,40 @@ namespace Tinsel {
#define ITERATION_BASE FRAC_ONE
#define ITER_ACCELERATION (10L << (FRAC_BITS - 4))
+Cursor::Cursor() {
+ g_McurObj = nullptr;
+ g_AcurObj = nullptr;
-//----------------- LOCAL GLOBAL DATA --------------------
+ g_McurAnim = {0, 0, 0, 0, 0};
+ g_AcurAnim = {0, 0, 0, 0, 0};
-// FIXME: Avoid non-const global vars
-
-static OBJECT *g_McurObj = nullptr; // Main cursor object
-static OBJECT *g_AcurObj = nullptr; // Auxiliary cursor object
-
-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 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 g_bFrozenCursor = false; // Set when cursor position is frozen
-
-static frac_t g_IterationSize = 0;
-
-static SCNHANDLE g_hCursorFilm = 0; // Handle to cursor reel data
-
-static int g_numTrails = 0;
-static int g_nextTrail = 0;
-
-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 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 g_ACoX = 0, g_ACoY = 0; // Auxillary cursor image's animation offsets
-
-
-
-#define MAX_TRAILERS 10
-
-static struct {
+ g_bHiddenCursor = false;
+ g_bTempNoTrailers = false;
+ g_bTempHide = false;
+ g_bFrozenCursor = false;
- ANIM trailAnim; // Animation structure
- OBJECT *trailObj; // This trailer's object
+ g_IterationSize = 0;
-} g_ntrailData [MAX_TRAILERS];
+ g_hCursorFilm = 0;
-static int g_lastCursorX = 0, g_lastCursorY = 0;
+ g_numTrails = 0;
+ g_nextTrail = 0;
+ g_bWhoa = false;
+ g_restart = false;
-//----------------- FORWARD REFERENCES --------------------
+ g_ACoX = 0;
+ g_ACoY = 0;
-static void DoCursorMove();
+ g_lastCursorX = 0;
+ g_lastCursorY = 0;
+}
/**
* Initialize and insert a cursor trail object, set its Z-pos, and hide
* it. Also initialize its animation script.
*/
-static void InitCurTrailObj(int i, int x, int y) {
+void Cursor::InitCurTrailObj(int i, int x, int y) {
const FREEL *pfr; // pointer to reel
IMAGE *pim; // pointer to image
const MULTI_INIT *pmi; // MULTI_INIT structure
@@ -141,7 +116,7 @@ static void InitCurTrailObj(int i, int x, int y) {
/**
* Get the cursor position from the mouse driver.
*/
-static bool GetDriverPosition(int *x, int *y) {
+bool Cursor::GetDriverPosition(int *x, int *y) {
Common::Point ptMouse = _vm->getMousePosition();
*x = ptMouse.x;
*y = ptMouse.y;
@@ -153,7 +128,7 @@ static bool GetDriverPosition(int *x, int *y) {
/**
* Move the cursor relative to current position.
*/
-void AdjustCursorXY(int deltaX, int deltaY) {
+void Cursor::AdjustCursorXY(int deltaX, int deltaY) {
int x, y;
if (deltaX || deltaY) {
@@ -166,7 +141,7 @@ void AdjustCursorXY(int deltaX, int deltaY) {
/**
* Move the cursor to an absolute position.
*/
-void SetCursorXY(int newx, int newy) {
+void Cursor::SetCursorXY(int newx, int newy) {
int x, y;
int Loffset, Toffset; // Screen offset
@@ -182,7 +157,7 @@ void SetCursorXY(int newx, int newy) {
/**
* Move the cursor to a screen position.
*/
-void SetCursorScreenXY(int newx, int newy) {
+void Cursor::SetCursorScreenXY(int newx, int newy) {
int x, y;
if (GetDriverPosition(&x, &y))
@@ -195,7 +170,7 @@ void SetCursorScreenXY(int newx, int newy) {
* Returns the cursor's animation position in (x,y).
* Returns false if there is no cursor object.
*/
-bool GetCursorXYNoWait(int *x, int *y, bool absolute) {
+bool Cursor::GetCursorXYNoWait(int *x, int *y, bool absolute) {
if (g_McurObj == NULL) {
*x = *y = 0;
return false;
@@ -219,7 +194,7 @@ bool GetCursorXYNoWait(int *x, int *y, bool absolute) {
* If called while there is no cursor object, the calling process ends
* up waiting until there is.
*/
-void GetCursorXY(int *x, int *y, bool absolute) {
+void Cursor::GetCursorXY(int *x, int *y, bool absolute) {
//while (McurObj == NULL)
// ProcessSleepSelf();
assert(g_McurObj);
@@ -231,7 +206,7 @@ void GetCursorXY(int *x, int *y, bool absolute) {
* Called from TINLIB.C to restore cursor after hiding it.
* Called from INVENTRY.C to restore cursor after customising it.
*/
-void RestoreMainCursor() {
+void Cursor::RestoreMainCursor() {
const FILM *pfilm;
if (g_McurObj != NULL) {
@@ -247,7 +222,7 @@ void RestoreMainCursor() {
/**
* Called from INVENTRY.C to customise the main cursor.
*/
-void SetTempCursor(SCNHANDLE pScript) {
+void Cursor::SetTempCursor(SCNHANDLE pScript) {
if (g_McurObj != NULL)
InitStepAnimScript(&g_McurAnim, g_McurObj, pScript, 2);
}
@@ -255,9 +230,7 @@ void SetTempCursor(SCNHANDLE pScript) {
/**
* Hide the cursor.
*/
-void DwHideCursor() {
- int i;
-
+void Cursor::DwHideCursor() {
g_bHiddenCursor = true;
if (g_McurObj)
@@ -265,7 +238,7 @@ void DwHideCursor() {
if (g_AcurObj)
MultiHideObject(g_AcurObj);
- for (i = 0; i < g_numTrails; i++) {
+ for (int i = 0; i < g_numTrails; i++) {
if (g_ntrailData[i].trailObj != NULL) {
MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
g_ntrailData[i].trailObj = nullptr;
@@ -273,31 +246,43 @@ void DwHideCursor() {
}
}
+void Cursor::HideCursorProcess() {
+ if (g_McurObj)
+ MultiHideObject(g_McurObj);
+ if (g_AcurObj)
+ MultiHideObject(g_AcurObj);
+
+ for (int i = 0; i < g_numTrails; i++) {
+ if (g_ntrailData[i].trailObj != NULL)
+ MultiHideObject(g_ntrailData[i].trailObj);
+ }
+}
+
/**
* Unhide the cursor.
*/
-void UnHideCursor() {
+void Cursor::UnHideCursor() {
g_bHiddenCursor = false;
}
/**
* Freeze the cursor.
*/
-void FreezeCursor() {
+void Cursor::FreezeCursor() {
g_bFrozenCursor = true;
}
/**
* Freeze the cursor, or not.
*/
-void DoFreezeCursor(bool bFreeze) {
+void Cursor::DoFreezeCursor(bool bFreeze) {
g_bFrozenCursor = bFreeze;
}
/**
* HideCursorTrails
*/
-void HideCursorTrails() {
+void Cursor::HideCursorTrails() {
int i;
g_bTempNoTrailers = true;
@@ -313,14 +298,14 @@ void HideCursorTrails() {
/**
* UnHideCursorTrails
*/
-void UnHideCursorTrails() {
+void Cursor::UnHideCursorTrails() {
g_bTempNoTrailers = false;
}
/**
* Get pointer to image from a film reel. And the rest.
*/
-IMAGE *GetImageFromReel(const FREEL *pfr, const MULTI_INIT **ppmi) {
+IMAGE *Cursor::GetImageFromReel(const FREEL *pfr, const MULTI_INIT **ppmi) {
const MULTI_INIT *pmi;
const FRAME *pFrame;
@@ -337,7 +322,7 @@ IMAGE *GetImageFromReel(const FREEL *pfr, const MULTI_INIT **ppmi) {
/**
* Get pointer to image from a film. And the rest.
*/
-IMAGE *GetImageFromFilm(SCNHANDLE hFilm, int reel, const FREEL **ppfr, const MULTI_INIT **ppmi, const FILM **ppfilm) {
+IMAGE *Cursor::GetImageFromFilm(SCNHANDLE hFilm, int reel, const FREEL **ppfr, const MULTI_INIT **ppmi, const FILM **ppfilm) {
const FILM *pfilm;
const FREEL *pfr;
@@ -355,7 +340,7 @@ IMAGE *GetImageFromFilm(SCNHANDLE hFilm, int reel, const FREEL **ppfr, const MUL
/**
* Delete auxillary cursor. Restore animation offsets in the image.
*/
-void DelAuxCursor() {
+void Cursor::DelAuxCursor() {
if (g_AcurObj != NULL) {
MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_AcurObj);
g_AcurObj = nullptr;
@@ -366,7 +351,7 @@ void DelAuxCursor() {
* Set auxillary cursor.
* Save animation offsets from the image if required.
*/
-void SetAuxCursor(SCNHANDLE hFilm) {
+void Cursor::SetAuxCursor(SCNHANDLE hFilm) {
IMAGE *pim; // Pointer to auxillary cursor's image
const FREEL *pfr;
const MULTI_INIT *pmi;
@@ -405,7 +390,7 @@ void SetAuxCursor(SCNHANDLE hFilm) {
/**
* MoveCursor
*/
-static void DoCursorMove() {
+void Cursor::DoCursorMove() {
int startX, startY;
Common::Point ptMouse;
frac_t newX, newY;
@@ -476,7 +461,7 @@ static void DoCursorMove() {
/**
* Initialize cursor object.
*/
-static void InitCurObj() {
+void Cursor::InitCurObj() {
const FILM *pFilm;
const FREEL *pfr;
const MULTI_INIT *pmi;
@@ -506,7 +491,7 @@ static void InitCurObj() {
/**
* Initialize the cursor position.
*/
-static void InitCurPos() {
+void Cursor::InitCurPos() {
Common::Point ptMouse = _vm->getMousePosition();
g_lastCursorX = ptMouse.x;
g_lastCursorY = ptMouse.y;
@@ -518,107 +503,11 @@ static void InitCurPos() {
g_IterationSize = ITERATION_BASE;
}
-/**
- * CursorStoppedCheck
- */
-static void CursorStoppedCheck(CORO_PARAM) {
- // COROUTINE
- CORO_BEGIN_CONTEXT;
- CORO_END_CONTEXT(_ctx);
-
- CORO_BEGIN_CODE(_ctx);
-
- // If scene is closing down
- if (g_bWhoa) {
- // ...wait for next scene start-up
- while (g_restart != 0x8000)
- CORO_SLEEP(1);
-
- // Re-initialize
- InitCurObj();
- InitCurPos();
- InventoryIconCursor(false); // May be holding something
-
- // Re-start the cursor trails
- g_restart = (uint16)-1; // set all bits
- g_bWhoa = false;
- }
- CORO_END_CODE;
-}
-
-/**
- * The main cursor process.
- */
-void CursorProcess(CORO_PARAM, const void *) {
- // COROUTINE
- CORO_BEGIN_CONTEXT;
- CORO_END_CONTEXT(_ctx);
-
- CORO_BEGIN_CODE(_ctx);
-
- while (!g_hCursorFilm || !_vm->_bg->BgPal())
- CORO_SLEEP(1);
-
- InitCurObj();
- InitCurPos();
- InventoryIconCursor(false); // May be holding something
-
- g_bWhoa = false;
- g_restart = 0;
-
- while (1) {
- // allow rescheduling
- CORO_SLEEP(1);
-
- // Stop/start between scenes
- CORO_INVOKE_0(CursorStoppedCheck);
-
- // Step the animation script(s)
- 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(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
- g_ntrailData[i].trailObj = nullptr;
- }
- }
- }
-
- // Move the cursor as appropriate
- if (!g_bFrozenCursor)
- DoCursorMove();
-
- // If the cursor should be hidden...
- if (g_bHiddenCursor || g_bTempHide) {
- // ...hide the cursor object(s)
- MultiHideObject(g_McurObj);
- if (g_AcurObj)
- MultiHideObject(g_AcurObj);
-
- 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 (g_bHiddenCursor) {
- CORO_SLEEP(1);
-
- // Stop/start between scenes
- CORO_INVOKE_0(CursorStoppedCheck);
- }
- }
- }
- CORO_END_CODE;
-}
-
/**
* Called from dec_cursor() Glitter function.
* Register the handle to cursor reel data.
*/
-void DwInitCursor(SCNHANDLE bfilm) {
+void Cursor::DwInitCursor(SCNHANDLE bfilm) {
const FILM *pfilm;
g_hCursorFilm = bfilm;
@@ -632,14 +521,14 @@ void DwInitCursor(SCNHANDLE bfilm) {
/**
* DropCursor is called when a scene is closing down.
*/
-void DropCursor() {
+void Cursor::DropCursor() {
if (TinselV2) {
if (g_AcurObj)
MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_AcurObj);
if (g_McurObj)
MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_McurObj);
- g_restart = 0;
+ g_restart = false;
}
g_AcurObj = nullptr; // No auxillary cursor
@@ -659,15 +548,15 @@ void DropCursor() {
/**
* RestartCursor is called when a new scene is starting up.
*/
-void RestartCursor() {
- g_restart = 0x8000; // Get the main cursor to re-initialize
+void Cursor::RestartCursor() {
+ g_restart = true; // Get the main cursor to re-initialize
}
/**
* Called when restarting the game, ensures correct re-start with NULL
* pointers etc.
*/
-void RebootCursor() {
+void Cursor::RebootCursor() {
g_McurObj = g_AcurObj = nullptr;
for (int i = 0; i < MAX_TRAILERS; i++)
g_ntrailData[i].trailObj = nullptr;
@@ -677,23 +566,115 @@ void RebootCursor() {
g_hCursorFilm = 0;
g_bWhoa = false;
- g_restart = 0;
+ g_restart = false;
}
-void StartCursorFollowed() {
+void Cursor::StartCursorFollowed() {
DelAuxCursor();
if (!SysVar(SV_ENABLEPRINTCURSOR))
g_bTempHide = true;
}
-void EndCursorFollowed() {
+void Cursor::EndCursorFollowed() {
InventoryIconCursor(false); // May be holding something
g_bTempHide = false;
}
-bool isCursorShown() {
+bool Cursor::isCursorShown() {
return !(g_bTempHide || g_bHiddenCursor);
}
+void Cursor::AnimateProcess() {
+ // Step the animation script(s)
+ StepAnimScript(&g_McurAnim);
+ if (g_AcurObj != NULL)
+ StepAnimScript(&g_AcurAnim);
+ for (int i = 0; i < _vm->_cursor->NumTrails(); i++) {
+ if (g_ntrailData[i].trailObj != NULL) {
+ if (StepAnimScript(&g_ntrailData[i].trailAnim) == ScriptFinished) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
+ g_ntrailData[i].trailObj = nullptr;
+ }
+ }
+ }
+
+ // Move the cursor as appropriate
+ if (!_vm->_cursor->CursorIsFrozen())
+ _vm->_cursor->DoCursorMove();
+}
+
+/**
+ * CursorStoppedCheck
+ */
+void CursorStoppedCheck(CORO_PARAM) {
+ // COROUTINE
+ CORO_BEGIN_CONTEXT;
+ CORO_END_CONTEXT(_ctx);
+
+ CORO_BEGIN_CODE(_ctx);
+
+ // If scene is closing down
+ if (_vm->_cursor->g_bWhoa) {
+ // ...wait for next scene start-up
+ while (!_vm->_cursor->g_restart)
+ CORO_SLEEP(1);
+
+ // Re-initialize
+ _vm->_cursor->InitCurObj();
+ _vm->_cursor->InitCurPos();
+ InventoryIconCursor(false); // May be holding something
+
+ // Re-start the cursor trails
+ _vm->_cursor->g_restart = true;
+ _vm->_cursor->g_bWhoa = false;
+ }
+ CORO_END_CODE;
+}
+
+/**
+ * The main cursor process.
+ */
+void CursorProcess(CORO_PARAM, const void *) {
+ // COROUTINE
+ CORO_BEGIN_CONTEXT;
+ CORO_END_CONTEXT(_ctx);
+
+ CORO_BEGIN_CODE(_ctx);
+
+ while (!_vm->_cursor->HasReelData() || !_vm->_bg->BgPal())
+ CORO_SLEEP(1);
+
+ _vm->_cursor->InitCurObj();
+ _vm->_cursor->InitCurPos();
+ InventoryIconCursor(false); // May be holding something
+
+ _vm->_cursor->g_bWhoa = false;
+ _vm->_cursor->g_restart = false;
+
+ while (1) {
+ // allow rescheduling
+ CORO_SLEEP(1);
+
+ // Stop/start between scenes
+ CORO_INVOKE_0(CursorStoppedCheck);
+
+ _vm->_cursor->AnimateProcess();
+
+ // If the cursor should be hidden...
+ if (_vm->_cursor->ShouldBeHidden()) {
+ _vm->_cursor->HideCursorProcess();
+
+ // Wait 'til cursor is again required.
+ while (_vm->_cursor->IsHidden()) {
+ CORO_SLEEP(1);
+
+ // Stop/start between scenes
+ CORO_INVOKE_0(CursorStoppedCheck);
+ }
+ }
+ }
+ CORO_END_CODE;
+}
+
} // End of namespace Tinsel
diff --git a/engines/tinsel/cursor.h b/engines/tinsel/cursor.h
index 997d7ae479..2e9ce17e4e 100644
--- a/engines/tinsel/cursor.h
+++ b/engines/tinsel/cursor.h
@@ -21,37 +21,105 @@
* Clipping rectangle defines
*/
-#ifndef TINSEL_CURSOR_H // prevent multiple includes
+#ifndef TINSEL_CURSOR_H // prevent multiple includes
#define TINSEL_CURSOR_H
-#include "tinsel/dw.h" // for SCNHANDLE
+#include "common/frac.h"
+#include "tinsel/anim.h"
+#include "tinsel/dw.h" // for SCNHANDLE
namespace Tinsel {
-void AdjustCursorXY(int deltaX, int deltaY);
-void SetCursorXY(int x, int y);
-void SetCursorScreenXY(int newx, int newy);
-void GetCursorXY(int *x, int *y, bool absolute);
-bool GetCursorXYNoWait(int *x, int *y, bool absolute);
-bool isCursorShown();
-
-void RestoreMainCursor();
-void SetTempCursor(SCNHANDLE pScript);
-void DwHideCursor();
-void UnHideCursor();
-void FreezeCursor();
-void DoFreezeCursor(bool bFreeze);
-void HideCursorTrails();
-void UnHideCursorTrails();
-void DelAuxCursor();
-void SetAuxCursor(SCNHANDLE hFilm);
-void DwInitCursor(SCNHANDLE bfilm);
-void DropCursor();
-void RestartCursor();
-void RebootCursor();
-void StartCursorFollowed();
-void EndCursorFollowed();
+struct IMAGE;
+struct FREEL;
+struct MULTI_INIT;
+struct FILM;
+struct OBJECT;
+
+#define MAX_TRAILERS 10
+
+class Cursor {
+public:
+ Cursor();
+ virtual ~Cursor() {}
+ void AdjustCursorXY(int deltaX, int deltaY);
+ void SetCursorXY(int x, int y);
+ void SetCursorScreenXY(int newx, int newy);
+ void GetCursorXY(int *x, int *y, bool absolute);
+ bool GetCursorXYNoWait(int *x, int *y, bool absolute);
+ bool isCursorShown();
+
+ void RestoreMainCursor();
+ void SetTempCursor(SCNHANDLE pScript);
+ void DwHideCursor();
+ void UnHideCursor();
+ void HideCursorProcess();
+ void AnimateProcess();
+ void FreezeCursor();
+ void DoFreezeCursor(bool bFreeze);
+ void HideCursorTrails();
+ void UnHideCursorTrails();
+ void DelAuxCursor();
+ void SetAuxCursor(SCNHANDLE hFilm);
+ void DwInitCursor(SCNHANDLE bfilm);
+ void DropCursor();
+ void RestartCursor();
+ void RebootCursor();
+ void StartCursorFollowed();
+ void EndCursorFollowed();
+ void InitCurObj();
+ void InitCurPos();
+ void DoCursorMove();
+ IMAGE *GetImageFromReel(const FREEL *pfr, const MULTI_INIT **ppmi = nullptr);
+ IMAGE *GetImageFromFilm(SCNHANDLE hFilm, int reel, const FREEL **ppfr = nullptr, const MULTI_INIT **ppmi = nullptr, const FILM **ppfilm = nullptr);
+
+ bool CursorIsFrozen() { return g_bFrozenCursor; }
+ int NumTrails() { return g_numTrails; }
+ bool IsHidden() { return g_bHiddenCursor; }
+ bool ShouldBeHidden() { return g_bHiddenCursor || g_bTempHide; }
+ bool HasReelData() { return g_hCursorFilm != 0; }
+
+ bool g_bWhoa; // Set by DropCursor() at the end of a scene
+ // - causes cursor processes to do nothing
+ // Reset when main cursor has re-initialized
+
+ bool g_restart; // When main cursor has been bWhoa-ed, it waits
+ // for this to be true.
+ // Main cursor sets this to true after a re-start
+
+private:
+ void InitCurTrailObj(int i, int x, int y);
+ bool GetDriverPosition(int *x, int *y);
+
+ OBJECT *g_McurObj; // Main cursor object
+ OBJECT *g_AcurObj; // Auxiliary cursor object
+
+ ANIM g_McurAnim; // Main cursor animation structure
+ ANIM g_AcurAnim; // Auxiliary cursor animation structure
+
+ bool g_bHiddenCursor; // Set when cursor is hidden
+ bool g_bTempNoTrailers; // Set when cursor trails are hidden
+ bool g_bTempHide; // Set when cursor is hidden
+
+ bool g_bFrozenCursor; // Set when cursor position is frozen
+
+ frac_t g_IterationSize;
+
+ SCNHANDLE g_hCursorFilm; // Handle to cursor reel data
+
+ int g_numTrails;
+ int g_nextTrail;
+
+ short g_ACoX = 0, g_ACoY; // Auxillary cursor image's animation offsets
+
+ struct {
+ ANIM trailAnim; // Animation structure
+ OBJECT *trailObj; // This trailer's object
+ } g_ntrailData[MAX_TRAILERS];
+
+ int g_lastCursorX, g_lastCursorY;
+};
} // End of namespace Tinsel
-#endif // TINSEL_CURSOR_H
+#endif // TINSEL_CURSOR_H
diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp
index db5709a1d4..22cf0e8e4d 100644
--- a/engines/tinsel/dialogs.cpp
+++ b/engines/tinsel/dialogs.cpp
@@ -1340,10 +1340,10 @@ extern void InventoryIconCursor(bool bNewItem) {
int objIndex = GetObjectIndex(g_heldItem);
g_heldFilm = g_invFilms[objIndex];
}
- SetAuxCursor(g_heldFilm);
+ _vm->_cursor->SetAuxCursor(g_heldFilm);
} else {
INV_OBJECT *invObj = GetInvObject(g_heldItem);
- SetAuxCursor(invObj->hIconFilm);
+ _vm->_cursor->SetAuxCursor(invObj->hIconFilm);
}
}
}
@@ -1401,7 +1401,7 @@ static void ObjectProcess(CORO_PARAM, const void *param) {
while (1) {
CORO_SLEEP(1);
int x, y;
- GetCursorXY(&x, &y, false);
+ _vm->_cursor->GetCursorXY(&x, &y, false);
if (InvItemId(x, y) != to->pinvo->id)
break;
@@ -1722,7 +1722,7 @@ static void Select(int i, bool force) {
extern void DropItem(int item) {
if (g_heldItem == item) {
g_heldItem = INV_NOICON; // Item not held
- DelAuxCursor(); // no longer aux cursor
+ _vm->_cursor->DelAuxCursor(); // no longer aux cursor
}
// Redraw contents - held item was not displayed as a content.
@@ -1883,7 +1883,7 @@ extern void HoldItem(int item, bool bKeepFilm) {
if (g_heldItem != item) {
if (TinselV2 && (g_heldItem != NOOBJECT)) {
// No longer holding previous item
- DelAuxCursor(); // no longer aux cursor
+ _vm->_cursor->DelAuxCursor(); // no longer aux cursor
// If old held object is not in an inventory, and
// has a default, stick it in its default inventory.
@@ -1901,11 +1901,11 @@ extern void HoldItem(int item, bool bKeepFilm) {
} else if (!TinselV2) {
if (item == INV_NOICON && g_heldItem != INV_NOICON)
- DelAuxCursor(); // no longer aux cursor
+ _vm->_cursor->DelAuxCursor(); // no longer aux cursor
if (item != INV_NOICON) {
invObj = GetInvObject(item);
- SetAuxCursor(invObj->hIconFilm); // and is aux. cursor
+ _vm->_cursor->SetAuxCursor(invObj->hIconFilm); // and is aux. cursor
}
// WORKAROUND: If a held item is being removed that's not in either inventory (i.e. it was picked up
@@ -2570,7 +2570,7 @@ static OBJECT *AddInvObject(int num, const FREEL **pfreel, const FILM **pfilm) {
invObj = GetInvObject(num);
// Get pointer to image
- pim = GetImageFromFilm(invObj->hIconFilm, 0, pfreel, &pmi, pfilm);
+ pim = _vm->_cursor->GetImageFromFilm(invObj->hIconFilm, 0, pfreel, &pmi, pfilm);
// Poke in the background palette
pim->hImgPal = TO_32(_vm->_bg->BgPal());
@@ -2699,7 +2699,7 @@ static OBJECT *AddObject(const FREEL *pfreel, int num) {
OBJECT *pPlayObj;
// Get pointer to image
- pim = GetImageFromReel(pfreel, &pmi);
+ pim = _vm->_cursor->GetImageFromReel(pfreel, &pmi);
// Poke in the background palette
pim->hImgPal = TO_32(_vm->_bg->BgPal());
@@ -3408,12 +3408,12 @@ static void AlterCursor(int num) {
IMAGE *pim;
// Get pointer to image
- pim = GetImageFromFilm(g_hWinParts, num, &pfreel);
+ pim = _vm->_cursor->GetImageFromFilm(g_hWinParts, num, &pfreel);
// Poke in the background palette
pim->hImgPal = TO_32(_vm->_bg->BgPal());
- SetTempCursor(FROM_32(pfreel->script));
+ _vm->_cursor->SetTempCursor(FROM_32(pfreel->script));
}
enum InvCursorFN {IC_AREA, IC_DROP};
@@ -3449,9 +3449,9 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {
// No cursor trails while within inventory window
if (area == I_NOTIN)
- UnHideCursorTrails();
+ _vm->_cursor->UnHideCursorTrails();
else
- HideCursorTrails();
+ _vm->_cursor->HideCursorTrails();
switch (area) {
case I_NOTIN:
@@ -3520,7 +3520,7 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {
}
if (restoreMain && ICursor != IC_NORMAL) {
- RestoreMainCursor();
+ _vm->_cursor->RestoreMainCursor();
ICursor = IC_NORMAL;
}
}
@@ -3807,7 +3807,7 @@ extern void HideConversation(bool bHide) {
}
}
- GetCursorXY(&aniX, &aniY, false);
+ _vm->_cursor->GetCursorXY(&aniX, &aniY, false);
InvLabels(true, aniX, aniY);
}
}
@@ -3911,7 +3911,7 @@ extern void OpenMenu(CONFTYPE menuType) {
case SAVE_MENU:
g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true); // Show VK when saving a game
if (!TinselV2)
- SetCursorScreenXY(262, 91);
+ _vm->_cursor->SetCursorScreenXY(262, 91);
SetMenuGlobals(&ciSave);
cd.editableRgroup = true;
FirstFile(0);
@@ -3925,11 +3925,11 @@ extern void OpenMenu(CONFTYPE menuType) {
case RESTART_MENU:
if (TinselV2)
- SetCursorScreenXY(360, 153);
+ _vm->_cursor->SetCursorScreenXY(360, 153);
else if (_vm->getLanguage() == Common::JA_JPN)
- SetCursorScreenXY(180, 106);
+ _vm->_cursor->SetCursorScreenXY(180, 106);
else
- SetCursorScreenXY(180, 90);
+ _vm->_cursor->SetCursorScreenXY(180, 90);
SetMenuGlobals(&ciRestart);
break;
@@ -3965,11 +3965,11 @@ extern void OpenMenu(CONFTYPE menuType) {
case QUIT_MENU:
if (TinselV2)
- SetCursorScreenXY(360, 153);
+ _vm->_cursor->SetCursorScreenXY(360, 153);
else if (_vm->getLanguage() == Common::JA_JPN)
- SetCursorScreenXY(180, 106);
+ _vm->_cursor->SetCursorScreenXY(180, 106);
else
- SetCursorScreenXY(180, 90);
+ _vm->_cursor->SetCursorScreenXY(180, 90);
SetMenuGlobals(&ciQuit);
break;
@@ -4034,7 +4034,7 @@ extern void OpenMenu(CONFTYPE menuType) {
}
if (g_heldItem != INV_NOICON)
- DelAuxCursor(); // no longer aux cursor
+ _vm->_cursor->DelAuxCursor(); // no longer aux cursor
PopUpInventory(INV_CONF);
@@ -4058,7 +4058,7 @@ extern void OpenMenu(CONFTYPE menuType) {
}
}
- GetCursorXY(&curX, &curY, false);
+ _vm->_cursor->GetCursorXY(&curX, &curY, false);
InvCursor(IC_AREA, curX, curY);
}
@@ -4079,7 +4079,7 @@ extern void KillInventory() {
g_InvD[g_ino].bMax = g_InventoryMaximised;
- UnHideCursorTrails();
+ _vm->_cursor->UnHideCursorTrails();
_vm->divertKeyInput(NULL);
}
@@ -4118,7 +4118,7 @@ extern void CloseInventory() {
KillInventory();
- RestoreMainCursor();
+ _vm->_cursor->RestoreMainCursor();
}
@@ -4149,7 +4149,7 @@ extern void InventoryProcess(CORO_PARAM, const void *) {
// Needed when clicking on scroll bar.
int curX, curY;
- GetCursorXY(&curX, &curY, false);
+ _vm->_cursor->GetCursorXY(&curX, &curY, false);
InvCursor(IC_AREA, curX, curY);
g_ItemsChanged = false;
@@ -4652,7 +4652,7 @@ extern void Xmovement(int x) {
break;
case ID_NONE:
- GetCursorXY(&aniX, &aniY, false);
+ _vm->_cursor->GetCursorXY(&aniX, &aniY, false);
InvCursor(IC_AREA, aniX, aniY);
break;
@@ -4708,7 +4708,7 @@ extern void Ymovement(int y) {
break;
case ID_NONE:
- GetCursorXY(&aniX, &aniY, false);
+ _vm->_cursor->GetCursorXY(&aniX, &aniY, false);
InvCursor(IC_AREA, aniX, aniY);
break;
@@ -4724,7 +4724,7 @@ extern void Ymovement(int y) {
static void InvDragStart() {
int curX, curY; // cursor's animation position
- GetCursorXY(&curX, &curY, false);
+ _vm->_cursor->GetCursorXY(&curX, &curY, false);
/*
* Do something different for Save/Restore screens
@@ -4843,7 +4843,7 @@ static void InvDragStart() {
static void InvDragEnd() {
int curX, curY; // cursor's animation position
- GetCursorXY(&curX, &curY, false);
+ _vm->_cursor->GetCursorXY(&curX, &curY, false);
if (g_InvDragging != ID_NONE) {
if (g_InvDragging == ID_SLIDE) {
@@ -5162,9 +5162,9 @@ static void InvPutDown(int index) {
g_heldItem = INV_NOICON;
g_ItemsChanged = true;
- DelAuxCursor();
- RestoreMainCursor();
- GetCursorXY(&aniX, &aniY, false);
+ _vm->_cursor->DelAuxCursor();
+ _vm->_cursor->RestoreMainCursor();
+ _vm->_cursor->GetCursorXY(&aniX, &aniY, false);
InvCursor(IC_DROP, aniX, aniY);
}
@@ -5316,7 +5316,7 @@ static void InvAction() {
int aniX, aniY;
int i;
- GetCursorXY(&aniX, &aniY, false);
+ _vm->_cursor->GetCursorXY(&aniX, &aniY, false);
switch (InvArea(aniX, aniY)) {
case I_BODY:
diff --git a/engines/tinsel/events.cpp b/engines/tinsel/events.cpp
index 5f2fb56db9..36055b2148 100644
--- a/engines/tinsel/events.cpp
+++ b/engines/tinsel/events.cpp
@@ -135,10 +135,10 @@ void ControlOn() {
if (g_bStartOff == true)
g_bStartOff = false;
else
- SetCursorXY(g_controlX, g_controlY);
+ _vm->_cursor->SetCursorXY(g_controlX, g_controlY);
// Re-instate cursor
- UnHideCursor();
+ _vm->_cursor->UnHideCursor();
// Turn tags back on
if (!InventoryActive())
@@ -162,10 +162,10 @@ void ControlOff() {
g_controlState = CONTROL_OFF;
// Store cursor position
- GetCursorXY(&g_controlX, &g_controlY, true);
+ _vm->_cursor->GetCursorXY(&g_controlX, &g_controlY, true);
// Blank out cursor
- DwHideCursor();
+ _vm->_cursor->DwHideCursor();
// Switch off tags
DisableTags();
@@ -187,7 +187,7 @@ void ControlStartOff() {
g_controlState = CONTROL_OFF;
// Blank out cursor
- DwHideCursor();
+ _vm->_cursor->DwHideCursor();
// Switch off tags
DisableTags();
@@ -306,7 +306,7 @@ static void ProcessUserEvent(TINSEL_EVENT uEvent, const Common::Point &coOrds, P
PolygonEvent(Common::nullContext, hPoly, uEvent, 0, false, 0);
} else {
- GetCursorXY(&aniX, &aniY, true);
+ _vm->_cursor->GetCursorXY(&aniX, &aniY, true);
// There could be a poly involved which has no tag.
if ((hPoly = InPolygon(aniX, aniY, TAG)) != NOPOLY ||
@@ -369,7 +369,7 @@ void ProcessButEvent(PLR_EVENT be) {
void ProcessKeyEvent(PLR_EVENT ke) {
// Pass the keyboard event to the player event handler
int xp, yp;
- GetCursorXYNoWait(&xp, &yp, true);
+ _vm->_cursor->GetCursorXYNoWait(&xp, &yp, true);
const Common::Point mousePos(xp, yp);
PlayerEvent(ke, mousePos);
diff --git a/engines/tinsel/move.cpp b/engines/tinsel/move.cpp
index a4310411e4..7a59568609 100644
--- a/engines/tinsel/move.cpp
+++ b/engines/tinsel/move.cpp
@@ -485,7 +485,7 @@ static void GotThereWithoutMoving(PMOVER pActor) {
DIRECTION reel;
if (!pActor->bSpecReel) {
- GetCursorXYNoWait(&curX, &curY, true);
+ _vm->_cursor->GetCursorXYNoWait(&curX, &curY, true);
reel = GetDirection(pActor->objX, pActor->objY, curX, curY, pActor->direction, pActor->hCpath);
@@ -512,7 +512,7 @@ static void GotThere(PMOVER pMover) {
int curX, curY;
DIRECTION direction;
- GetCursorXY(&curX, &curY, true);
+ _vm->_cursor->GetCursorXY(&curX, &curY, true);
direction = GetDirection(pMover->objX, pMover->objY,
curX, curY,
pMover->direction,
diff --git a/engines/tinsel/object.h b/engines/tinsel/object.h
index 351b4d36ef..95d918a01e 100644
--- a/engines/tinsel/object.h
+++ b/engines/tinsel/object.h
@@ -207,21 +207,6 @@ OBJECT *TranslucentObject( // create a translucent rectangle object of the given
int width, // width of rectangle
int height); // height of rectangle
-void ResizeRectangle( // resizes a rectangle object
- OBJECT *pRect, // rectangle object pointer
- int width, // new width of rectangle
- int height); // new height of rectangle
-
-
-// FIXME: This does not belong here
-struct FILM;
-struct FREEL;
-struct MULTI_INIT;
-IMAGE *GetImageFromReel(const FREEL *pfreel, const MULTI_INIT **ppmi = 0);
-IMAGE *GetImageFromFilm(SCNHANDLE hFilm, int reel, const FREEL **ppfr = 0,
- const MULTI_INIT **ppmi = 0, const FILM **ppfilm = 0);
-
-
} // End of namespace Tinsel
#endif // TINSEL_OBJECT_H
diff --git a/engines/tinsel/pdisplay.cpp b/engines/tinsel/pdisplay.cpp
index 165be434e2..4ce844f11d 100644
--- a/engines/tinsel/pdisplay.cpp
+++ b/engines/tinsel/pdisplay.cpp
@@ -408,7 +408,7 @@ static bool ActorTag(int curX, int curY, HotSpotTag *pTag, OBJECT **ppText) {
LoadStringRes(GetActorTagHandle(actor), g_tagBuffer, sizeof(g_tagBuffer));
// May have buggered cursor
- EndCursorFollowed();
+ _vm->_cursor->EndCursorFollowed();
*ppText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_tagBuffer,
0, tagX, tagY, _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
assert(*ppText);
@@ -556,7 +556,7 @@ static bool PolyTag(HotSpotTag *pTag, OBJECT **ppText) {
ppText = nullptr;
else if (TinselV2 && !PolyTagFollowsCursor(hp)) {
// May have buggered cursor
- EndCursorFollowed();
+ _vm->_cursor->EndCursorFollowed();
*ppText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), 0, tagx - Loffset, tagy - Toffset,
@@ -565,9 +565,9 @@ static bool PolyTag(HotSpotTag *pTag, OBJECT **ppText) {
// Bugger cursor
const char *tagPtr = _vm->_font->TextBufferAddr();
if (tagPtr[0] < ' ' && tagPtr[1] == EOS_CHAR)
- StartCursorFollowed();
+ _vm->_cursor->StartCursorFollowed();
- GetCursorXYNoWait(&curX, &curY, false);
+ _vm->_cursor->GetCursorXYNoWait(&curX, &curY, false);
*ppText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(),
0, curX, curY, _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
} else {
@@ -604,7 +604,7 @@ static bool PolyTag(HotSpotTag *pTag, OBJECT **ppText) {
Toffset = nToff;
}
} else {
- GetCursorXY(&tagx, &tagy, false);
+ _vm->_cursor->GetCursorXY(&tagx, &tagy, false);
if (tagx != curX || tagy != curY) {
MultiMoveRelXY(*ppText, tagx - curX, tagy - curY);
curX = tagx;
@@ -655,7 +655,7 @@ void TagProcess(CORO_PARAM, const void *) {
while (1) {
if (g_bTagsActive) {
int curX, curY; // cursor position
- while (!GetCursorXYNoWait(&curX, &curY, true))
+ while (!_vm->_cursor->GetCursorXYNoWait(&curX, &curY, true))
CORO_SLEEP(1);
if (!ActorTag(curX, curY, &_ctx->Tag, &_ctx->pText)
@@ -667,7 +667,7 @@ void TagProcess(CORO_PARAM, const void *) {
if (TinselV2)
// May have buggered cursor
- EndCursorFollowed();
+ _vm->_cursor->EndCursorFollowed();
}
}
} else {
@@ -750,7 +750,7 @@ void PointProcess(CORO_PARAM, const void *) {
EnablePointing();
while (1) {
- while (!GetCursorXYNoWait(&_ctx->curX, &_ctx->curY, true))
+ while (!_vm->_cursor->GetCursorXYNoWait(&_ctx->curX, &_ctx->curY, true))
CORO_SLEEP(1);
/*----------------------------------*\
diff --git a/engines/tinsel/scene.cpp b/engines/tinsel/scene.cpp
index 9409758c1c..baa04cd230 100644
--- a/engines/tinsel/scene.cpp
+++ b/engines/tinsel/scene.cpp
@@ -316,7 +316,7 @@ void EndScene() {
DropScroll(); // No no-scrolls
_vm->_bg->DropBackground(); // No background
DropMovers(); // No moving actors
- DropCursor(); // No cursor
+ _vm->_cursor->DropCursor(); // No cursor
DropActors(); // No actor reels running
FreeAllTokens(); // No-one has tokens
FreeMostInterpretContexts(); // Only master script still interpreting
@@ -353,7 +353,7 @@ void PrimeScene() {
SetNoBlocking(false);
SetSysVar(SYS_SceneFxDimFactor, SysVar(SYS_DefaultFxDimFactor));
- RestartCursor(); // Restart the cursor
+ _vm->_cursor->RestartCursor(); // Restart the cursor
if (!TinselV2)
EnableTags(); // Next scene with tags enabled
diff --git a/engines/tinsel/scroll.cpp b/engines/tinsel/scroll.cpp
index b52b6597c9..c6cdf718e9 100644
--- a/engines/tinsel/scroll.cpp
+++ b/engines/tinsel/scroll.cpp
@@ -253,7 +253,7 @@ static void ScrollImage() {
* Keeping cursor on a tag?
*/
if (g_ScrollCursor) {
- GetCursorXYNoWait(&curX, &curY, true);
+ _vm->_cursor->GetCursorXYNoWait(&curX, &curY, true);
if (InPolygon(curX, curY, TAG) != NOPOLY || InPolygon(curX, curY, EXIT) != NOPOLY) {
OldLoffset = Loffset;
OldToffset = Toffset;
@@ -331,7 +331,7 @@ static void ScrollImage() {
* Move cursor if keeping cursor on a tag.
*/
if (g_ScrollCursor)
- AdjustCursorXY(OldLoffset - Loffset, OldToffset - Toffset);
+ _vm->_cursor->AdjustCursorXY(OldLoffset - Loffset, OldToffset - Toffset);
_vm->_bg->PlayfieldSetPos(FIELD_WORLD, Loffset, Toffset);
}
diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp
index 6d92e98d01..c22aae9328 100644
--- a/engines/tinsel/tinlib.cpp
+++ b/engines/tinsel/tinlib.cpp
@@ -760,7 +760,7 @@ void Control(int param) {
case CONTROL_STARTOFF:
GetControlToken(); // Take control
DisableTags(); // Switch off tags
- DwHideCursor(); // Blank out cursor
+ _vm->_cursor->DwHideCursor(); // Blank out cursor
g_offtype = param;
break;
@@ -771,7 +771,7 @@ void Control(int param) {
GetControlToken(); // Take control
DisableTags(); // Switch off tags
- GetCursorXYNoWait(&g_controlX, &g_controlY, true); // Store cursor position
+ _vm->_cursor->GetCursorXYNoWait(&g_controlX, &g_controlY, true); // Store cursor position
// There may be a button timing out
GetToken(TOKEN_LEFT_BUT);
@@ -779,30 +779,30 @@ void Control(int param) {
}
if (g_offtype == CONTROL_STARTOFF)
- GetCursorXYNoWait(&g_controlX, &g_controlY, true); // Store cursor position
+ _vm->_cursor->GetCursorXYNoWait(&g_controlX, &g_controlY, true); // Store cursor position
g_offtype = param;
if (param == CONTROL_OFF)
- DwHideCursor(); // Blank out cursor
+ _vm->_cursor->DwHideCursor(); // Blank out cursor
else if (param == CONTROL_OFFV) {
- UnHideCursor();
- FreezeCursor();
+ _vm->_cursor->UnHideCursor();
+ _vm->_cursor->FreezeCursor();
} else if (param == CONTROL_OFFV2) {
- UnHideCursor();
+ _vm->_cursor->UnHideCursor();
}
break;
case CONTROL_ON:
if (g_offtype != CONTROL_OFFV2 && g_offtype != CONTROL_STARTOFF)
- SetCursorXY(g_controlX, g_controlY);// ... where it was
+ _vm->_cursor->SetCursorXY(g_controlX, g_controlY); // ... where it was
FreeControlToken(); // Release control
if (!InventoryActive())
EnableTags(); // Tags back on
- RestoreMainCursor(); // Re-instate cursor...
+ _vm->_cursor->RestoreMainCursor(); // Re-instate cursor...
break;
default:
@@ -878,10 +878,10 @@ static void ConvTopic(int icon) {
void Cursor(int onoff) {
if (onoff) {
// Re-instate cursor
- UnHideCursor();
+ _vm->_cursor->UnHideCursor();
} else {
// Blank out cursor
- DwHideCursor();
+ _vm->_cursor->DwHideCursor();
}
}
@@ -891,7 +891,7 @@ void Cursor(int onoff) {
static int CursorPos(int xory) {
int x, y;
- GetCursorXY(&x, &y, true);
+ _vm->_cursor->GetCursorXY(&x, &y, true);
return (xory == CURSORXPOS) ? x : y;
}
@@ -915,7 +915,7 @@ static void DecCStrings(SCNHANDLE *tp) {
* Declare cursor's reels.
*/
static void DecCursor(SCNHANDLE hFilm) {
- DwInitCursor(hFilm);
+ _vm->_cursor->DwInitCursor(hFilm);
}
/**
@@ -1148,7 +1148,7 @@ static void FadeMidi(CORO_PARAM, int inout) {
* Freeze the cursor, or not.
*/
static void FreezeCursor(bool bFreeze) {
- DoFreezeCursor(bFreeze);
+ _vm->_cursor->DoFreezeCursor(bFreeze);
}
/**
@@ -1383,7 +1383,7 @@ static int LToffset(int lort) {
* Set new cursor position.
*/
static void MoveCursor(int x, int y) {
- SetCursorXY(x, y);
+ _vm->_cursor->SetCursorXY(x, y);
g_controlX = x; // Save these values so that
g_controlY = y; // control(on) doesn't undo this
@@ -1631,8 +1631,8 @@ static void PlayMovie(CORO_PARAM, SCNHANDLE hFileStem, int myEscape) {
// Get rid of the cursor
for (_ctx->i = 0; _ctx->i < 3; _ctx->i++) {
- DwHideCursor();
- DropCursor();
+ _vm->_cursor->DwHideCursor();
+ _vm->_cursor->DropCursor();
CORO_SLEEP(1);
}
@@ -2041,7 +2041,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
/*
* Find out which icon the cursor is over, and where to put the text.
*/
- GetCursorXY(&_ctx->textx, &_ctx->texty, false); // Cursor position..
+ _vm->_cursor->GetCursorXY(&_ctx->textx, &_ctx->texty, false); // Cursor position..
_ctx->item = InvItem(&_ctx->textx, &_ctx->texty, true); // ..to text position
if (_ctx->item == INV_NOICON)
return;
@@ -2129,7 +2129,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
while (g_bNotPointedRunning)
CORO_SLEEP(1);
- GetCursorXY(&x, &y, false);
+ _vm->_cursor->GetCursorXY(&x, &y, false);
if (InvItem(&x, &y, false) != _ctx->item)
break;
@@ -2147,7 +2147,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
CORO_SLEEP(1);
// Carry on until the cursor leaves this icon
- GetCursorXY(&x, &y, false);
+ _vm->_cursor->GetCursorXY(&x, &y, false);
} while (InvItemId(x, y) == pinvo->id);
} else {
@@ -2246,7 +2246,7 @@ static void PrintObjPointed(CORO_PARAM, const SCNHANDLE text, const INV_OBJECT *
while (g_bNotPointedRunning)
CORO_SLEEP(1);
- GetCursorXY(&x, &y, false);
+ _vm->_cursor->GetCursorXY(&x, &y, false);
if (InvItem(&x, &y, false) != item)
break;
@@ -2261,7 +2261,7 @@ static void PrintObjPointed(CORO_PARAM, const SCNHANDLE text, const INV_OBJECT *
CORO_SLEEP(1);
// Carry on until the cursor leaves this icon
- GetCursorXY(&x, &y, false);
+ _vm->_cursor->GetCursorXY(&x, &y, false);
} while (InvItemId(x, y) == pinvo->id);
CORO_END_CODE;
@@ -3039,7 +3039,7 @@ static void Swalk(CORO_PARAM, int actor, int x1, int y1, int x2, int y2, SCNHAND
if (actor == GetLeadId() || actor == LEAD_ACTOR) {
_ctx->bTookControl = GetControl(CONTROL_OFFV2);
if (TinselV2 && _ctx->bTookControl)
- RestoreMainCursor();
+ _vm->_cursor->RestoreMainCursor();
} else {
_ctx->bTookControl = false;
}
@@ -3707,7 +3707,7 @@ static void WaitKey(CORO_PARAM, bool escOn, int myEscape) {
_ctx->startEvent = getUserEvents();
if (TinselV1) {
// Store cursor position
- while (!GetCursorXYNoWait(&_ctx->startX, &_ctx->startY, false))
+ while (!_vm->_cursor->GetCursorXYNoWait(&_ctx->startX, &_ctx->startY, false))
CORO_SLEEP(1);
}
@@ -3717,7 +3717,7 @@ static void WaitKey(CORO_PARAM, bool escOn, int myEscape) {
// Not necessary to monitor escape as it's an event anyway
if (TinselV1) {
int curX, curY;
- GetCursorXY(&curX, &curY, false); // Store cursor position
+ _vm->_cursor->GetCursorXY(&curX, &curY, false); // Store cursor position
if (curX != _ctx->startX || curY != _ctx->startY)
break;
}
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index a43688f485..423fa536ac 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -308,7 +308,7 @@ static void MouseProcess(CORO_PARAM, const void *) {
_vm->_mouseButtons.pop_front();
int xp, yp;
- GetCursorXYNoWait(&xp, &yp, true);
+ _vm->_cursor->GetCursorXYNoWait(&xp, &yp, true);
const Common::Point mousePos(xp, yp);
switch (type) {
@@ -849,6 +849,7 @@ TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc)
TinselEngine::~TinselEngine() {
_system->getAudioCDManager()->stop();
+ delete _cursor;
delete _bg;
delete _font;
delete _bmv;
@@ -896,6 +897,7 @@ Common::Error TinselEngine::run() {
_bmv = new BMVPlayer();
_font = new Font();
_bg = new Background(_font);
+ _cursor = new Cursor();
// Initialize backend
if (getGameID() == GID_DW2) {
@@ -927,7 +929,7 @@ Common::Error TinselEngine::run() {
// It may have to be adjusted a bit
CountOut = 1;
- RebootCursor();
+ _vm->_cursor->RebootCursor();
RebootDeadTags();
RebootMovers();
resetUserEventTime();
@@ -1109,7 +1111,7 @@ void TinselEngine::RestartGame() {
// -> reset the count used by ChangeScene
CountOut = 1;
- RebootCursor();
+ _vm->_cursor->RebootCursor();
RebootDeadTags();
RebootMovers();
RebootTimers();
diff --git a/engines/tinsel/tinsel.h b/engines/tinsel/tinsel.h
index 2e9d36c82e..b73c779afb 100644
--- a/engines/tinsel/tinsel.h
+++ b/engines/tinsel/tinsel.h
@@ -59,6 +59,7 @@ class Music;
class SoundManager;
class Background;
class Font;
+class Cursor;
typedef Common::List<Common::Rect> RectList;
@@ -202,6 +203,7 @@ public:
BMVPlayer *_bmv;
Background* _bg;
Font *_font;
+ Cursor *_cursor;
Config *_config;
Commit: c83e7cd6b00c0519cb45312310b4e9228785147f
https://github.com/scummvm/scummvm/commit/c83e7cd6b00c0519cb45312310b4e9228785147f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-09-25T22:24:14+03:00
Commit Message:
TINSEL: Rename variables in the Cursor class
Changed paths:
engines/tinsel/cursor.cpp
engines/tinsel/cursor.h
diff --git a/engines/tinsel/cursor.cpp b/engines/tinsel/cursor.cpp
index c85715c294..32b177e960 100644
--- a/engines/tinsel/cursor.cpp
+++ b/engines/tinsel/cursor.cpp
@@ -52,32 +52,32 @@ namespace Tinsel {
#define ITER_ACCELERATION (10L << (FRAC_BITS - 4))
Cursor::Cursor() {
- g_McurObj = nullptr;
- g_AcurObj = nullptr;
+ _mainCursor = nullptr;
+ _auxCursor = nullptr;
- g_McurAnim = {0, 0, 0, 0, 0};
- g_AcurAnim = {0, 0, 0, 0, 0};
+ _mainCursorAnim = {0, 0, 0, 0, 0};
+ _auxCursorAnim = {0, 0, 0, 0, 0};
- g_bHiddenCursor = false;
- g_bTempNoTrailers = false;
- g_bTempHide = false;
- g_bFrozenCursor = false;
+ _hiddenCursor = false;
+ _hiddenTrails = false;
+ _tempHiddenCursor = false;
+ _frozenCursor = false;
- g_IterationSize = 0;
+ _iterationSize = 0;
- g_hCursorFilm = 0;
+ _cursorFilm = 0;
- g_numTrails = 0;
- g_nextTrail = 0;
+ _numTrails = 0;
+ _nextTrail = 0;
- g_bWhoa = false;
- g_restart = false;
+ _cursorProcessesStopped = false;
+ _cursorProcessesRestarted = false;
- g_ACoX = 0;
- g_ACoY = 0;
+ _auxCursorOffsetX = 0;
+ _auxCursorOffsetY = 0;
- g_lastCursorX = 0;
- g_lastCursorY = 0;
+ _lastCursorX = 0;
+ _lastCursorY = 0;
}
/**
@@ -91,26 +91,26 @@ void Cursor::InitCurTrailObj(int i, int x, int y) {
const FILM *pfilm;
- if (!g_numTrails)
+ if (!_numTrails)
return;
// Get rid of old object
- if (g_ntrailData[i].trailObj != NULL)
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
+ if (_trailData[i].trailObj != NULL)
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _trailData[i].trailObj);
- pim = GetImageFromFilm(g_hCursorFilm, i+1, &pfr, &pmi, &pfilm);// Get pointer to image
+ pim = GetImageFromFilm(_cursorFilm, i+1, &pfr, &pmi, &pfilm);// Get pointer to image
assert(_vm->_bg->BgPal()); // No background palette
pim->hImgPal = TO_32(_vm->_bg->BgPal());
// Initialize and insert the object, set its Z-pos, and hide it
- g_ntrailData[i].trailObj = MultiInitObject(pmi);
- MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
- MultiSetZPosition(g_ntrailData[i].trailObj, Z_CURSORTRAIL);
- MultiSetAniXY(g_ntrailData[i].trailObj, x, y);
+ _trailData[i].trailObj = MultiInitObject(pmi);
+ MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _trailData[i].trailObj);
+ MultiSetZPosition(_trailData[i].trailObj, Z_CURSORTRAIL);
+ MultiSetAniXY(_trailData[i].trailObj, x, y);
// Initialize the animation script
- InitStepAnimScript(&g_ntrailData[i].trailAnim, g_ntrailData[i].trailObj, FROM_32(pfr->script), ONE_SECOND / FROM_32(pfilm->frate));
- StepAnimScript(&g_ntrailData[i].trailAnim);
+ InitStepAnimScript(&_trailData[i].trailAnim, _trailData[i].trailObj, FROM_32(pfr->script), ONE_SECOND / FROM_32(pfilm->frate));
+ StepAnimScript(&_trailData[i].trailAnim);
}
/**
@@ -171,12 +171,12 @@ void Cursor::SetCursorScreenXY(int newx, int newy) {
* Returns false if there is no cursor object.
*/
bool Cursor::GetCursorXYNoWait(int *x, int *y, bool absolute) {
- if (g_McurObj == NULL) {
+ if (_mainCursor == NULL) {
*x = *y = 0;
return false;
}
- GetAniPosition(g_McurObj, x, y);
+ GetAniPosition(_mainCursor, x, y);
if (absolute) {
int Loffset, Toffset; // Screen offset
@@ -197,7 +197,7 @@ bool Cursor::GetCursorXYNoWait(int *x, int *y, bool absolute) {
void Cursor::GetCursorXY(int *x, int *y, bool absolute) {
//while (McurObj == NULL)
// ProcessSleepSelf();
- assert(g_McurObj);
+ assert(_mainCursor);
GetCursorXYNoWait(x, y, absolute);
}
@@ -209,52 +209,52 @@ void Cursor::GetCursorXY(int *x, int *y, bool absolute) {
void Cursor::RestoreMainCursor() {
const FILM *pfilm;
- if (g_McurObj != NULL) {
- pfilm = (const FILM *)LockMem(g_hCursorFilm);
+ if (_mainCursor != NULL) {
+ pfilm = (const FILM *)LockMem(_cursorFilm);
- InitStepAnimScript(&g_McurAnim, g_McurObj, FROM_32(pfilm->reels->script), ONE_SECOND / FROM_32(pfilm->frate));
- StepAnimScript(&g_McurAnim);
+ InitStepAnimScript(&_mainCursorAnim, _mainCursor, FROM_32(pfilm->reels->script), ONE_SECOND / FROM_32(pfilm->frate));
+ StepAnimScript(&_mainCursorAnim);
}
- g_bHiddenCursor = false;
- g_bFrozenCursor = false;
+ _hiddenCursor = false;
+ _frozenCursor = false;
}
/**
* Called from INVENTRY.C to customise the main cursor.
*/
void Cursor::SetTempCursor(SCNHANDLE pScript) {
- if (g_McurObj != NULL)
- InitStepAnimScript(&g_McurAnim, g_McurObj, pScript, 2);
+ if (_mainCursor != NULL)
+ InitStepAnimScript(&_mainCursorAnim, _mainCursor, pScript, 2);
}
/**
* Hide the cursor.
*/
void Cursor::DwHideCursor() {
- g_bHiddenCursor = true;
+ _hiddenCursor = true;
- if (g_McurObj)
- MultiHideObject(g_McurObj);
- if (g_AcurObj)
- MultiHideObject(g_AcurObj);
+ if (_mainCursor)
+ MultiHideObject(_mainCursor);
+ if (_auxCursor)
+ MultiHideObject(_auxCursor);
- for (int i = 0; i < g_numTrails; i++) {
- if (g_ntrailData[i].trailObj != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
- g_ntrailData[i].trailObj = nullptr;
+ for (int i = 0; i < _numTrails; i++) {
+ if (_trailData[i].trailObj != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _trailData[i].trailObj);
+ _trailData[i].trailObj = nullptr;
}
}
}
void Cursor::HideCursorProcess() {
- if (g_McurObj)
- MultiHideObject(g_McurObj);
- if (g_AcurObj)
- MultiHideObject(g_AcurObj);
-
- for (int i = 0; i < g_numTrails; i++) {
- if (g_ntrailData[i].trailObj != NULL)
- MultiHideObject(g_ntrailData[i].trailObj);
+ if (_mainCursor)
+ MultiHideObject(_mainCursor);
+ if (_auxCursor)
+ MultiHideObject(_auxCursor);
+
+ for (int i = 0; i < _numTrails; i++) {
+ if (_trailData[i].trailObj != NULL)
+ MultiHideObject(_trailData[i].trailObj);
}
}
@@ -262,21 +262,21 @@ void Cursor::HideCursorProcess() {
* Unhide the cursor.
*/
void Cursor::UnHideCursor() {
- g_bHiddenCursor = false;
+ _hiddenCursor = false;
}
/**
* Freeze the cursor.
*/
void Cursor::FreezeCursor() {
- g_bFrozenCursor = true;
+ _frozenCursor = true;
}
/**
* Freeze the cursor, or not.
*/
void Cursor::DoFreezeCursor(bool bFreeze) {
- g_bFrozenCursor = bFreeze;
+ _frozenCursor = bFreeze;
}
/**
@@ -285,12 +285,12 @@ void Cursor::DoFreezeCursor(bool bFreeze) {
void Cursor::HideCursorTrails() {
int i;
- g_bTempNoTrailers = true;
+ _hiddenTrails = true;
- for (i = 0; i < g_numTrails; i++) {
- if (g_ntrailData[i].trailObj != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
- g_ntrailData[i].trailObj = nullptr;
+ for (i = 0; i < _numTrails; i++) {
+ if (_trailData[i].trailObj != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _trailData[i].trailObj);
+ _trailData[i].trailObj = nullptr;
}
}
}
@@ -299,7 +299,7 @@ void Cursor::HideCursorTrails() {
* UnHideCursorTrails
*/
void Cursor::UnHideCursorTrails() {
- g_bTempNoTrailers = false;
+ _hiddenTrails = false;
}
/**
@@ -341,9 +341,9 @@ IMAGE *Cursor::GetImageFromFilm(SCNHANDLE hFilm, int reel, const FREEL **ppfr, c
* Delete auxillary cursor. Restore animation offsets in the image.
*/
void Cursor::DelAuxCursor() {
- if (g_AcurObj != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_AcurObj);
- g_AcurObj = nullptr;
+ if (_auxCursor != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _auxCursor);
+ _auxCursor = nullptr;
}
}
@@ -370,21 +370,21 @@ void Cursor::SetAuxCursor(SCNHANDLE hFilm) {
assert(_vm->_bg->BgPal()); // no background palette
pim->hImgPal = TO_32(_vm->_bg->BgPal()); // Poke in the background palette
- g_ACoX = (short)(FROM_16(pim->imgWidth)/2 - ((int16) FROM_16(pim->anioffX)));
- g_ACoY = (short)((FROM_16(pim->imgHeight) & ~C16_FLAG_MASK)/2 -
+ _auxCursorOffsetX = (short)(FROM_16(pim->imgWidth)/2 - ((int16) FROM_16(pim->anioffX)));
+ _auxCursorOffsetY = (short)((FROM_16(pim->imgHeight) & ~C16_FLAG_MASK)/2 -
((int16) FROM_16(pim->anioffY)));
// Initialize and insert the auxillary cursor object
- g_AcurObj = MultiInitObject(pmi);
- MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_AcurObj);
+ _auxCursor = MultiInitObject(pmi);
+ MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _auxCursor);
// Initialize the animation and set its position
- InitStepAnimScript(&g_AcurAnim, g_AcurObj, FROM_32(pfr->script), ONE_SECOND / FROM_32(pfilm->frate));
- MultiSetAniXY(g_AcurObj, x - g_ACoX, y - g_ACoY);
- MultiSetZPosition(g_AcurObj, Z_ACURSOR);
+ InitStepAnimScript(&_auxCursorAnim, _auxCursor, FROM_32(pfr->script), ONE_SECOND / FROM_32(pfilm->frate));
+ MultiSetAniXY(_auxCursor, x - _auxCursorOffsetX, y - _auxCursorOffsetY);
+ MultiSetZPosition(_auxCursor, Z_ACURSOR);
- if (g_bHiddenCursor)
- MultiHideObject(g_AcurObj);
+ if (_hiddenCursor)
+ MultiHideObject(_auxCursor);
}
/**
@@ -410,52 +410,52 @@ void Cursor::DoCursorMove() {
dir = _vm->getKeyDirection();
if (dir != 0) {
if (dir & MSK_LEFT)
- newX -= g_IterationSize;
+ newX -= _iterationSize;
if (dir & MSK_RIGHT)
- newX += g_IterationSize;
+ newX += _iterationSize;
if (dir & MSK_UP)
- newY -= g_IterationSize;
+ newY -= _iterationSize;
if (dir & MSK_DOWN)
- newY += g_IterationSize;
+ newY += _iterationSize;
- g_IterationSize += ITER_ACCELERATION;
+ _iterationSize += ITER_ACCELERATION;
// set new mouse driver position
_vm->setMousePosition(Common::Point(fracToInt(newX), fracToInt(newY)));
} else
- g_IterationSize = ITERATION_BASE;
+ _iterationSize = ITERATION_BASE;
// get new mouse driver position - could have been modified
ptMouse = _vm->getMousePosition();
- if (g_lastCursorX != ptMouse.x || g_lastCursorY != ptMouse.y) {
+ if (_lastCursorX != ptMouse.x || _lastCursorY != ptMouse.y) {
resetUserEventTime();
- if (!g_bTempNoTrailers && !g_bHiddenCursor) {
- InitCurTrailObj(g_nextTrail++, g_lastCursorX, g_lastCursorY);
- if (g_nextTrail == g_numTrails)
- g_nextTrail = 0;
+ if (!_hiddenTrails && !_hiddenCursor) {
+ InitCurTrailObj(_nextTrail++, _lastCursorX, _lastCursorY);
+ if (_nextTrail == _numTrails)
+ _nextTrail = 0;
}
}
// adjust cursor to new mouse position
- 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 (_mainCursor)
+ MultiSetAniXY(_mainCursor, ptMouse.x, ptMouse.y);
+ if (_auxCursor != NULL)
+ MultiSetAniXY(_auxCursor, ptMouse.x - _auxCursorOffsetX, ptMouse.y - _auxCursorOffsetY);
- if (InventoryActive() && g_McurObj) {
+ if (InventoryActive() && _mainCursor) {
// Notify the inventory
Xmovement(ptMouse.x - startX);
Ymovement(ptMouse.y - startY);
}
- g_lastCursorX = ptMouse.x;
- g_lastCursorY = ptMouse.y;
+ _lastCursorX = ptMouse.x;
+ _lastCursorY = ptMouse.y;
}
/**
@@ -468,7 +468,7 @@ void Cursor::InitCurObj() {
IMAGE *pim;
if (TinselV2) {
- pFilm = (const FILM *)LockMem(g_hCursorFilm);
+ pFilm = (const FILM *)LockMem(_cursorFilm);
pfr = (const FREEL *)&pFilm->reels[0];
pmi = (MULTI_INIT *)LockMem(FROM_32(pfr->mobj));
@@ -476,16 +476,16 @@ void Cursor::InitCurObj() {
} else {
assert(_vm->_bg->BgPal()); // no background palette
- pim = GetImageFromFilm(g_hCursorFilm, 0, &pfr, &pmi, &pFilm);// Get pointer to image
+ pim = GetImageFromFilm(_cursorFilm, 0, &pfr, &pmi, &pFilm);// Get pointer to image
pim->hImgPal = TO_32(_vm->_bg->BgPal());
- g_AcurObj = nullptr; // No auxillary cursor
+ _auxCursor = nullptr; // No auxillary cursor
}
- g_McurObj = MultiInitObject(pmi);
- MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_McurObj);
+ _mainCursor = MultiInitObject(pmi);
+ MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _mainCursor);
- InitStepAnimScript(&g_McurAnim, g_McurObj, FROM_32(pfr->script), ONE_SECOND / FROM_32(pFilm->frate));
+ InitStepAnimScript(&_mainCursorAnim, _mainCursor, FROM_32(pfr->script), ONE_SECOND / FROM_32(pFilm->frate));
}
/**
@@ -493,14 +493,14 @@ void Cursor::InitCurObj() {
*/
void Cursor::InitCurPos() {
Common::Point ptMouse = _vm->getMousePosition();
- g_lastCursorX = ptMouse.x;
- g_lastCursorY = ptMouse.y;
+ _lastCursorX = ptMouse.x;
+ _lastCursorY = ptMouse.y;
- MultiSetZPosition(g_McurObj, Z_CURSOR);
+ MultiSetZPosition(_mainCursor, Z_CURSOR);
DoCursorMove();
- MultiHideObject(g_McurObj);
+ MultiHideObject(_mainCursor);
- g_IterationSize = ITERATION_BASE;
+ _iterationSize = ITERATION_BASE;
}
/**
@@ -510,12 +510,12 @@ void Cursor::InitCurPos() {
void Cursor::DwInitCursor(SCNHANDLE bfilm) {
const FILM *pfilm;
- g_hCursorFilm = bfilm;
+ _cursorFilm = bfilm;
- pfilm = (const FILM *)LockMem(g_hCursorFilm);
- g_numTrails = FROM_32(pfilm->numreels) - 1;
+ pfilm = (const FILM *)LockMem(_cursorFilm);
+ _numTrails = FROM_32(pfilm->numreels) - 1;
- assert(g_numTrails <= MAX_TRAILERS);
+ assert(_numTrails <= MAX_TRAILERS);
}
/**
@@ -523,24 +523,24 @@ void Cursor::DwInitCursor(SCNHANDLE bfilm) {
*/
void Cursor::DropCursor() {
if (TinselV2) {
- if (g_AcurObj)
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_AcurObj);
- if (g_McurObj)
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_McurObj);
+ if (_auxCursor)
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _auxCursor);
+ if (_mainCursor)
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _mainCursor);
- g_restart = false;
+ _cursorProcessesRestarted = false;
}
- g_AcurObj = nullptr; // No auxillary cursor
- g_McurObj = nullptr; // 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
+ _auxCursor = nullptr; // No auxillary cursor
+ _mainCursor = nullptr; // No cursor object (imminently deleted elsewhere)
+ _hiddenCursor = false; // Not hidden in next scene
+ _hiddenTrails = false; // Trailers not hidden in next scene
+ _cursorProcessesStopped = true; // Suspend cursor processes
- for (int i = 0; i < g_numTrails; i++) {
- if (g_ntrailData[i].trailObj != NULL) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
- g_ntrailData[i].trailObj = nullptr;
+ for (int i = 0; i < _numTrails; i++) {
+ if (_trailData[i].trailObj != NULL) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _trailData[i].trailObj);
+ _trailData[i].trailObj = nullptr;
}
}
}
@@ -549,7 +549,7 @@ void Cursor::DropCursor() {
* RestartCursor is called when a new scene is starting up.
*/
void Cursor::RestartCursor() {
- g_restart = true; // Get the main cursor to re-initialize
+ _cursorProcessesRestarted = true; // Get the main cursor to re-initialize
}
/**
@@ -557,44 +557,44 @@ void Cursor::RestartCursor() {
* pointers etc.
*/
void Cursor::RebootCursor() {
- g_McurObj = g_AcurObj = nullptr;
+ _mainCursor = _auxCursor = nullptr;
for (int i = 0; i < MAX_TRAILERS; i++)
- g_ntrailData[i].trailObj = nullptr;
+ _trailData[i].trailObj = nullptr;
- g_bHiddenCursor = g_bTempNoTrailers = g_bFrozenCursor = false;
+ _hiddenCursor = _hiddenTrails = _frozenCursor = false;
- g_hCursorFilm = 0;
+ _cursorFilm = 0;
- g_bWhoa = false;
- g_restart = false;
+ _cursorProcessesStopped = false;
+ _cursorProcessesRestarted = false;
}
void Cursor::StartCursorFollowed() {
DelAuxCursor();
if (!SysVar(SV_ENABLEPRINTCURSOR))
- g_bTempHide = true;
+ _tempHiddenCursor = true;
}
void Cursor::EndCursorFollowed() {
InventoryIconCursor(false); // May be holding something
- g_bTempHide = false;
+ _tempHiddenCursor = false;
}
bool Cursor::isCursorShown() {
- return !(g_bTempHide || g_bHiddenCursor);
+ return !(_tempHiddenCursor || _hiddenCursor);
}
void Cursor::AnimateProcess() {
// Step the animation script(s)
- StepAnimScript(&g_McurAnim);
- if (g_AcurObj != NULL)
- StepAnimScript(&g_AcurAnim);
+ StepAnimScript(&_mainCursorAnim);
+ if (_auxCursor != NULL)
+ StepAnimScript(&_auxCursorAnim);
for (int i = 0; i < _vm->_cursor->NumTrails(); i++) {
- if (g_ntrailData[i].trailObj != NULL) {
- if (StepAnimScript(&g_ntrailData[i].trailAnim) == ScriptFinished) {
- MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
- g_ntrailData[i].trailObj = nullptr;
+ if (_trailData[i].trailObj != NULL) {
+ if (StepAnimScript(&_trailData[i].trailAnim) == ScriptFinished) {
+ MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _trailData[i].trailObj);
+ _trailData[i].trailObj = nullptr;
}
}
}
@@ -615,9 +615,9 @@ void CursorStoppedCheck(CORO_PARAM) {
CORO_BEGIN_CODE(_ctx);
// If scene is closing down
- if (_vm->_cursor->g_bWhoa) {
+ if (_vm->_cursor->_cursorProcessesStopped) {
// ...wait for next scene start-up
- while (!_vm->_cursor->g_restart)
+ while (!_vm->_cursor->_cursorProcessesRestarted)
CORO_SLEEP(1);
// Re-initialize
@@ -626,8 +626,8 @@ void CursorStoppedCheck(CORO_PARAM) {
InventoryIconCursor(false); // May be holding something
// Re-start the cursor trails
- _vm->_cursor->g_restart = true;
- _vm->_cursor->g_bWhoa = false;
+ _vm->_cursor->_cursorProcessesRestarted = true;
+ _vm->_cursor->_cursorProcessesStopped = false;
}
CORO_END_CODE;
}
@@ -649,8 +649,8 @@ void CursorProcess(CORO_PARAM, const void *) {
_vm->_cursor->InitCurPos();
InventoryIconCursor(false); // May be holding something
- _vm->_cursor->g_bWhoa = false;
- _vm->_cursor->g_restart = false;
+ _vm->_cursor->_cursorProcessesStopped = false;
+ _vm->_cursor->_cursorProcessesRestarted = false;
while (1) {
// allow rescheduling
diff --git a/engines/tinsel/cursor.h b/engines/tinsel/cursor.h
index 2e9ce17e4e..3c1aa1d44e 100644
--- a/engines/tinsel/cursor.h
+++ b/engines/tinsel/cursor.h
@@ -73,17 +73,17 @@ public:
IMAGE *GetImageFromReel(const FREEL *pfr, const MULTI_INIT **ppmi = nullptr);
IMAGE *GetImageFromFilm(SCNHANDLE hFilm, int reel, const FREEL **ppfr = nullptr, const MULTI_INIT **ppmi = nullptr, const FILM **ppfilm = nullptr);
- bool CursorIsFrozen() { return g_bFrozenCursor; }
- int NumTrails() { return g_numTrails; }
- bool IsHidden() { return g_bHiddenCursor; }
- bool ShouldBeHidden() { return g_bHiddenCursor || g_bTempHide; }
- bool HasReelData() { return g_hCursorFilm != 0; }
+ bool CursorIsFrozen() { return _frozenCursor; }
+ int NumTrails() { return _numTrails; }
+ bool IsHidden() { return _hiddenCursor; }
+ bool ShouldBeHidden() { return _hiddenCursor || _tempHiddenCursor; }
+ bool HasReelData() { return _cursorFilm != 0; }
- bool g_bWhoa; // Set by DropCursor() at the end of a scene
+ bool _cursorProcessesStopped; // Set by DropCursor() at the end of a scene
// - causes cursor processes to do nothing
// Reset when main cursor has re-initialized
- bool g_restart; // When main cursor has been bWhoa-ed, it waits
+ bool _cursorProcessesRestarted; // When main cursor has been bWhoa-ed, it waits
// for this to be true.
// Main cursor sets this to true after a re-start
@@ -91,33 +91,33 @@ private:
void InitCurTrailObj(int i, int x, int y);
bool GetDriverPosition(int *x, int *y);
- OBJECT *g_McurObj; // Main cursor object
- OBJECT *g_AcurObj; // Auxiliary cursor object
+ OBJECT *_mainCursor; // Main cursor object
+ OBJECT *_auxCursor; // Auxiliary cursor object
- ANIM g_McurAnim; // Main cursor animation structure
- ANIM g_AcurAnim; // Auxiliary cursor animation structure
+ ANIM _mainCursorAnim; // Main cursor animation structure
+ ANIM _auxCursorAnim; // Auxiliary cursor animation structure
- bool g_bHiddenCursor; // Set when cursor is hidden
- bool g_bTempNoTrailers; // Set when cursor trails are hidden
- bool g_bTempHide; // Set when cursor is hidden
+ bool _hiddenCursor; // Set when cursor is hidden
+ bool _hiddenTrails; // Set when cursor trails are hidden
+ bool _tempHiddenCursor; // Set when cursor is hidden
- bool g_bFrozenCursor; // Set when cursor position is frozen
+ bool _frozenCursor; // Set when cursor position is frozen
- frac_t g_IterationSize;
+ frac_t _iterationSize;
- SCNHANDLE g_hCursorFilm; // Handle to cursor reel data
+ SCNHANDLE _cursorFilm; // Handle to cursor reel data
- int g_numTrails;
- int g_nextTrail;
+ int _numTrails;
+ int _nextTrail;
- short g_ACoX = 0, g_ACoY; // Auxillary cursor image's animation offsets
+ short _auxCursorOffsetX = 0, _auxCursorOffsetY; // Auxillary cursor image's animation offsets
struct {
ANIM trailAnim; // Animation structure
OBJECT *trailObj; // This trailer's object
- } g_ntrailData[MAX_TRAILERS];
+ } _trailData[MAX_TRAILERS];
- int g_lastCursorX, g_lastCursorY;
+ int _lastCursorX, _lastCursorY;
};
} // End of namespace Tinsel
Commit: 0931d7d3fc99806cc44244a8da12d25a63293d70
https://github.com/scummvm/scummvm/commit/0931d7d3fc99806cc44244a8da12d25a63293d70
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-09-25T22:24:14+03:00
Commit Message:
TINSEL: rework a static variable, and use C++ style lists
Changed paths:
engines/tinsel/background.cpp
engines/tinsel/background.h
diff --git a/engines/tinsel/background.cpp b/engines/tinsel/background.cpp
index 2dc91f435d..740236e1ad 100644
--- a/engines/tinsel/background.cpp
+++ b/engines/tinsel/background.cpp
@@ -44,26 +44,23 @@ Background::Background(Font* font) : _font(font), _pCurBgnd(nullptr), _hBgPal(0)
* Called to initialize a background.
*/
void Background::InitBackground() {
- // FIXME: Avoid non-const global vars
- static PLAYFIELD playfield[] = {
- { // FIELD WORLD
- NULL, // display list
- 0, // init field x
- 0, // init field y
- 0, // x vel
- 0, // y vel
- Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), // clip rect
- false // moved flag
- },
- { // FIELD STATUS
- NULL, // display list
- 0, // init field x
- 0, // init field y
- 0, // x vel
- 0, // y vel
- Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), // clip rect
- false // moved flag
- }
+ PLAYFIELD worldPlayfield = {
+ NULL, // display list
+ 0, // init field x
+ 0, // init field y
+ 0, // x vel
+ 0, // y vel
+ Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), // clip rect
+ false // moved flag
+ };
+ PLAYFIELD statusPlayfield = {
+ NULL, // display list
+ 0, // init field x
+ 0, // init field y
+ 0, // x vel
+ 0, // y vel
+ Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), // clip rect
+ false // moved flag
};
// set current background
@@ -74,31 +71,29 @@ void Background::InitBackground() {
_pCurBgnd->refreshRate = 0; // no background update process
_pCurBgnd->pXscrollTable = nullptr;
_pCurBgnd->pYscrollTable = nullptr;
- _pCurBgnd->numPlayfields = 2;
- _pCurBgnd->fieldArray = playfield;
+ _pCurBgnd->fieldArray.push_back(worldPlayfield);
+ _pCurBgnd->fieldArray.push_back(statusPlayfield);
_pCurBgnd->bAutoErase = false;
// init background sky color
SetBgndColor(_pCurBgnd->rgbSkyColor);
- // start of playfield array
- PLAYFIELD* pPlayfield = _pCurBgnd->fieldArray;
-
// for each background playfield
- for (int i = 0; i < _pCurBgnd->numPlayfields; i++, pPlayfield++) {
+ for (int i = 0; i < _pCurBgnd->fieldArray.size(); i++) {
+ PLAYFIELD cur = _pCurBgnd->fieldArray[i];
// init playfield pos
- pPlayfield->fieldX = intToFrac(_pCurBgnd->ptInitWorld.x);
- pPlayfield->fieldY = intToFrac(_pCurBgnd->ptInitWorld.y);
+ cur.fieldX = intToFrac(_pCurBgnd->ptInitWorld.x);
+ cur.fieldY = intToFrac(_pCurBgnd->ptInitWorld.y);
// no scrolling
- pPlayfield->fieldXvel = intToFrac(0);
- pPlayfield->fieldYvel = intToFrac(0);
+ cur.fieldXvel = intToFrac(0);
+ cur.fieldYvel = intToFrac(0);
// clear playfield display list
- pPlayfield->pDispList = nullptr;
+ cur.pDispList = nullptr;
// clear playfield moved flag
- pPlayfield->bMoved = false;
+ cur.bMoved = false;
}
}
@@ -116,10 +111,10 @@ void Background::PlayfieldSetPos(int which, int newXpos, int newYpos) {
assert(_pCurBgnd != NULL);
// make sure the playfield number is in range
- assert(which >= 0 && which < _pCurBgnd->numPlayfields);
+ assert(which >= 0 && which < _pCurBgnd->fieldArray.size());
// get playfield pointer
- pPlayfield = _pCurBgnd->fieldArray + which;
+ pPlayfield = &_pCurBgnd->fieldArray[which];
// set new integer position
pPlayfield->fieldX = intToFrac(newXpos);
@@ -143,10 +138,10 @@ void Background::PlayfieldGetPos(int which, int *pXpos, int *pYpos) {
assert(_pCurBgnd != NULL);
// make sure the playfield number is in range
- assert(which >= 0 && which < _pCurBgnd->numPlayfields);
+ assert(which >= 0 && which < _pCurBgnd->fieldArray.size());
// get playfield pointer
- pPlayfield = _pCurBgnd->fieldArray + which;
+ pPlayfield = &_pCurBgnd->fieldArray[which];
// get current integer position
*pXpos = fracToInt(pPlayfield->fieldX);
@@ -165,10 +160,10 @@ int Background::PlayfieldGetCenterX(int which) {
assert(_pCurBgnd != NULL);
// make sure the playfield number is in range
- assert(which >= 0 && which < _pCurBgnd->numPlayfields);
+ assert(which >= 0 && which < _pCurBgnd->fieldArray.size());
// get playfield pointer
- pPlayfield = _pCurBgnd->fieldArray + which;
+ pPlayfield = &_pCurBgnd->fieldArray[which];
// get current integer position
return fracToInt(pPlayfield->fieldX) + SCREEN_WIDTH/2;
@@ -186,10 +181,10 @@ OBJECT **Background::GetPlayfieldList(int which) {
assert(_pCurBgnd != NULL);
// make sure the playfield number is in range
- assert(which >= 0 && which < _pCurBgnd->numPlayfields);
+ assert(which >= 0 && which < _pCurBgnd->fieldArray.size());
// get playfield pointer
- pPlayfield = _pCurBgnd->fieldArray + which;
+ pPlayfield = &_pCurBgnd->fieldArray[which];
// return the display list pointer for this playfield
return &pPlayfield->pDispList;
@@ -211,9 +206,9 @@ void Background::DrawBackgnd() {
return; // no current background
// scroll each background playfield
- for (i = 0; i < _pCurBgnd->numPlayfields; i++) {
+ for (i = 0; i < _pCurBgnd->fieldArray.size(); i++) {
// get pointer to correct playfield
- pPlay = _pCurBgnd->fieldArray + i;
+ pPlay = &_pCurBgnd->fieldArray[i];
// save integer part of position
prevX = fracToInt(pPlay->fieldX);
@@ -250,11 +245,11 @@ void Background::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 < _pCurBgnd->fieldArray.size(); i++) {
Common::Rect rcPlayClip; // clip rect for this playfield
// get pointer to correct playfield
- pPlay = _pCurBgnd->fieldArray + i;
+ pPlay = &_pCurBgnd->fieldArray[i];
// convert fixed point window pos to a int
ptWin.x = fracToInt(pPlay->fieldX);
diff --git a/engines/tinsel/background.h b/engines/tinsel/background.h
index 625d5b5a1f..312ae6d09d 100644
--- a/engines/tinsel/background.h
+++ b/engines/tinsel/background.h
@@ -24,6 +24,7 @@
#ifndef TINSEL_BACKGND_H // prevent multiple includes
#define TINSEL_BACKGND_H
+#include "common/array.h"
#include "common/coroutines.h"
#include "common/frac.h"
#include "common/rect.h"
@@ -65,8 +66,7 @@ struct BACKGND {
int refreshRate; ///< background update process refresh rate
frac_t *pXscrollTable; ///< pointer to x direction scroll table for this background
frac_t *pYscrollTable; ///< pointer to y direction scroll table for this background
- int numPlayfields; ///< number of playfields for this background
- PLAYFIELD *fieldArray; ///< pointer to array of all playfields for this background
+ Common::Array<PLAYFIELD> fieldArray; ///< list of all playfields for this background
bool bAutoErase; ///< when set - screen is cleared before anything is plotted (unused)
};
@@ -93,6 +93,7 @@ public:
void DropBackground();
void ResetBackground() {
+ _pCurBgnd->fieldArray.clear();
delete _pCurBgnd;
_pCurBgnd = nullptr;
}
Commit: 41d4212da897dddd7f07e166848789fe3b78adf0
https://github.com/scummvm/scummvm/commit/41d4212da897dddd7f07e166848789fe3b78adf0
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-09-25T22:24:15+03:00
Commit Message:
TINSEL: Remove an unneeded static
Changed paths:
engines/tinsel/dialogs.cpp
diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp
index 22cf0e8e4d..12ea026a04 100644
--- a/engines/tinsel/dialogs.cpp
+++ b/engines/tinsel/dialogs.cpp
@@ -2259,7 +2259,7 @@ static int WhichMenuBox(int curX, int curY, bool bSlides) {
* InvBoxes
*/
static void InvBoxes(bool InBody, int curX, int curY) {
- static int rotateIndex = -1; // FIXME: Avoid non-const global vars
+ int rotateIndex = -1;
int index; // Box pointed to on this call
const FILM *pfilm;
More information about the Scummvm-git-logs
mailing list