TINSEL: Move background related functions into a new Background class

This commit is contained in:
Filippos Karapetis 2020-02-22 18:17:57 +02:00
parent eed258261a
commit 64b750ab2e
21 changed files with 359 additions and 377 deletions

View File

@ -55,7 +55,7 @@ goto done
echo. echo.
echo Creating project files with all engines enabled (stable and unstable) echo Creating project files with all engines enabled (stable and unstable)
echo. echo.
create_project ..\.. --enable-all-engines --disable-fluidsynth --msvc create_project ..\.. --enable-all-engines --disable-fluidsynth --msvc --build-events --enable-vkeybd --enable-updates --enable-faad --enable-mpeg2
goto done goto done
:stable :stable

View File

@ -1610,7 +1610,7 @@ void GetActorTagPos(int actor, int *pTagX, int *pTagY, bool bAbsolute) {
*pTagY = aTop; *pTagY = aTop;
if (!bAbsolute) { if (!bAbsolute) {
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
*pTagX -= Loffset; *pTagX -= Loffset;
*pTagY -= Toffset; *pTagY -= Toffset;
} }

View File

@ -23,7 +23,9 @@
#include "tinsel/background.h" #include "tinsel/background.h"
#include "tinsel/cliprect.h" // object clip rect defs #include "tinsel/cliprect.h" // object clip rect defs
#include "tinsel/font.h"
#include "tinsel/graphics.h" #include "tinsel/graphics.h"
#include "tinsel/multiobj.h"
#include "tinsel/sched.h" // process sheduler defs #include "tinsel/sched.h" // process sheduler defs
#include "tinsel/object.h" #include "tinsel/object.h"
#include "tinsel/pid.h" // process identifiers #include "tinsel/pid.h" // process identifiers
@ -31,15 +33,10 @@
namespace Tinsel { namespace Tinsel {
// FIXME: Avoid non-const global vars
// current background
const BACKGND *g_pCurBgnd = NULL;
/** /**
* Called to initialize a background. * Called to initialize a background.
*/ */
void InitBackground() { void Background::InitBackground() {
// structure for playfields // structure for playfields
// FIXME: Avoid non-const global vars // FIXME: Avoid non-const global vars
static PLAYFIELD playfield[] = { static PLAYFIELD playfield[] = {
@ -80,7 +77,7 @@ void InitBackground() {
PLAYFIELD* pPlayfield; // pointer to current playfield PLAYFIELD* pPlayfield; // pointer to current playfield
// set current background // set current background
g_pCurBgnd = &backgnd; _pCurBgnd = &backgnd;
// init background sky color // init background sky color
SetBgndColor(backgnd.rgbSkyColor); SetBgndColor(backgnd.rgbSkyColor);
@ -113,17 +110,17 @@ void InitBackground() {
* @param newYpos New y position * @param newYpos New y position
*/ */
void PlayfieldSetPos(int which, int newXpos, int newYpos) { void Background::PlayfieldSetPos(int which, int newXpos, int newYpos) {
PLAYFIELD *pPlayfield; // pointer to relavent playfield PLAYFIELD *pPlayfield; // pointer to relavent playfield
// make sure there is a background // make sure there is a background
assert(g_pCurBgnd != NULL); assert(_pCurBgnd != NULL);
// make sure the playfield number is in range // make sure the playfield number is in range
assert(which >= 0 && which < g_pCurBgnd->numPlayfields); assert(which >= 0 && which < _pCurBgnd->numPlayfields);
// get playfield pointer // get playfield pointer
pPlayfield = g_pCurBgnd->fieldArray + which; pPlayfield = _pCurBgnd->fieldArray + which;
// set new integer position // set new integer position
pPlayfield->fieldX = intToFrac(newXpos); pPlayfield->fieldX = intToFrac(newXpos);
@ -140,17 +137,17 @@ void PlayfieldSetPos(int which, int newXpos, int newYpos) {
* @param pYpos Returns current y position * @param pYpos Returns current y position
*/ */
void PlayfieldGetPos(int which, int *pXpos, int *pYpos) { void Background::PlayfieldGetPos(int which, int *pXpos, int *pYpos) {
PLAYFIELD *pPlayfield; // pointer to relavent playfield PLAYFIELD *pPlayfield; // pointer to relavent playfield
// make sure there is a background // make sure there is a background
assert(g_pCurBgnd != NULL); assert(_pCurBgnd != NULL);
// make sure the playfield number is in range // make sure the playfield number is in range
assert(which >= 0 && which < g_pCurBgnd->numPlayfields); assert(which >= 0 && which < _pCurBgnd->numPlayfields);
// get playfield pointer // get playfield pointer
pPlayfield = g_pCurBgnd->fieldArray + which; pPlayfield = _pCurBgnd->fieldArray + which;
// get current integer position // get current integer position
*pXpos = fracToInt(pPlayfield->fieldX); *pXpos = fracToInt(pPlayfield->fieldX);
@ -162,17 +159,17 @@ void PlayfieldGetPos(int which, int *pXpos, int *pYpos) {
* @param which Which playfield * @param which Which playfield
*/ */
int PlayfieldGetCenterX(int which) { int Background::PlayfieldGetCenterX(int which) {
PLAYFIELD *pPlayfield; // pointer to relavent playfield PLAYFIELD *pPlayfield; // pointer to relavent playfield
// make sure there is a background // make sure there is a background
assert(g_pCurBgnd != NULL); assert(_pCurBgnd != NULL);
// make sure the playfield number is in range // make sure the playfield number is in range
assert(which >= 0 && which < g_pCurBgnd->numPlayfields); assert(which >= 0 && which < _pCurBgnd->numPlayfields);
// get playfield pointer // get playfield pointer
pPlayfield = g_pCurBgnd->fieldArray + which; pPlayfield = _pCurBgnd->fieldArray + which;
// get current integer position // get current integer position
return fracToInt(pPlayfield->fieldX) + SCREEN_WIDTH/2; return fracToInt(pPlayfield->fieldX) + SCREEN_WIDTH/2;
@ -183,17 +180,17 @@ int PlayfieldGetCenterX(int which) {
* @param which Which playfield * @param which Which playfield
*/ */
OBJECT **GetPlayfieldList(int which) { OBJECT **Background::GetPlayfieldList(int which) {
PLAYFIELD *pPlayfield; // pointer to relavent playfield PLAYFIELD *pPlayfield; // pointer to relavent playfield
// make sure there is a background // make sure there is a background
assert(g_pCurBgnd != NULL); assert(_pCurBgnd != NULL);
// make sure the playfield number is in range // make sure the playfield number is in range
assert(which >= 0 && which < g_pCurBgnd->numPlayfields); assert(which >= 0 && which < _pCurBgnd->numPlayfields);
// get playfield pointer // get playfield pointer
pPlayfield = g_pCurBgnd->fieldArray + which; pPlayfield = _pCurBgnd->fieldArray + which;
// return the display list pointer for this playfield // return the display list pointer for this playfield
return &pPlayfield->pDispList; return &pPlayfield->pDispList;
@ -205,19 +202,19 @@ OBJECT **GetPlayfieldList(int which) {
* to scroll each playfield before it is drawn. * to scroll each playfield before it is drawn.
*/ */
void DrawBackgnd() { void Background::DrawBackgnd() {
int i; // playfield counter int i; // playfield counter
PLAYFIELD *pPlay; // playfield pointer PLAYFIELD *pPlay; // playfield pointer
int prevX, prevY; // save interger part of position int prevX, prevY; // save interger part of position
Common::Point ptWin; // window top left Common::Point ptWin; // window top left
if (g_pCurBgnd == NULL) if (_pCurBgnd == NULL)
return; // no current background return; // no current background
// scroll each background playfield // scroll each background playfield
for (i = 0; i < g_pCurBgnd->numPlayfields; i++) { for (i = 0; i < _pCurBgnd->numPlayfields; i++) {
// get pointer to correct playfield // get pointer to correct playfield
pPlay = g_pCurBgnd->fieldArray + i; pPlay = _pCurBgnd->fieldArray + i;
// save integer part of position // save integer part of position
prevX = fracToInt(pPlay->fieldX); prevX = fracToInt(pPlay->fieldX);
@ -254,11 +251,11 @@ void DrawBackgnd() {
for (RectList::const_iterator r = clipRects.begin(); r != clipRects.end(); ++r) { for (RectList::const_iterator r = clipRects.begin(); r != clipRects.end(); ++r) {
// clear the clip rectangle on the virtual screen // clear the clip rectangle on the virtual screen
// for each background playfield // for each background playfield
for (i = 0; i < g_pCurBgnd->numPlayfields; i++) { for (i = 0; i < _pCurBgnd->numPlayfields; i++) {
Common::Rect rcPlayClip; // clip rect for this playfield Common::Rect rcPlayClip; // clip rect for this playfield
// get pointer to correct playfield // get pointer to correct playfield
pPlay = g_pCurBgnd->fieldArray + i; pPlay = _pCurBgnd->fieldArray + i;
// convert fixed point window pos to a int // convert fixed point window pos to a int
ptWin.x = fracToInt(pPlay->fieldX); ptWin.x = fracToInt(pPlay->fieldX);
@ -284,4 +281,33 @@ void DrawBackgnd() {
ResetClipRect(); ResetClipRect();
} }
int Background::BgWidth() {
assert(_pBG[0]);
return MultiRightmost(_pBG[0]) + 1;
}
int Background::BgHeight() {
assert(_pBG[0]);
return MultiLowest(_pBG[0]) + 1;
}
void Background::SetBackPal(SCNHANDLE hPal) {
_hBgPal = hPal;
_font->FettleFontPal(_hBgPal);
CreateTranslucentPalette(_hBgPal);
}
void Background::DropBackground() {
_pBG[0] = NULL; // No background
if (!TinselV2)
_hBgPal = 0; // No background palette
}
void Background::ChangePalette(SCNHANDLE hPal) {
SwapPalette(FindPalette(_hBgPal), hPal);
SetBackPal(hPal);
}
} // End of namespace Tinsel } // End of namespace Tinsel

View File

@ -27,7 +27,9 @@
#include "common/coroutines.h" #include "common/coroutines.h"
#include "common/frac.h" #include "common/frac.h"
#include "common/rect.h" #include "common/rect.h"
#include "tinsel/anim.h" // for ANIM
#include "tinsel/dw.h" // for SCNHANDLE #include "tinsel/dw.h" // for SCNHANDLE
#include "tinsel/object.h" // for POBJECT
#include "tinsel/palette.h" // palette definitions #include "tinsel/palette.h" // palette definitions
namespace Tinsel { namespace Tinsel {
@ -73,40 +75,90 @@ struct BACKGND {
|* Background Function Prototypes *| |* Background Function Prototypes *|
\*----------------------------------------------------------------------*/ \*----------------------------------------------------------------------*/
void InitBackground(); #define MAX_BG 10
void StartupBackground(CORO_PARAM, SCNHANDLE hFilm); class Font;
void PlayfieldSetPos( // Sets the xy position of the specified playfield in the current background class Background {
int which, // which playfield public:
int newXpos, // new x position Background(Font *font) : _font(font), _pCurBgnd(nullptr), _hBgPal(0), _BGspeed(0), _hBackground(0), _bDoFadeIn(false), _bgReels(0) {}
int newYpos); // new y position
void PlayfieldGetPos( // Returns the xy position of the specified playfield in the current background void InitBackground();
int which, // which playfield
int *pXpos, // returns current x position
int *pYpos); // returns current y position
int PlayfieldGetCenterX( // Returns the xy position of the specified playfield in the current background void DrawBackgnd(); // Draws all playfields for the current background
int which); // which playfield
OBJECT **GetPlayfieldList( // Returns the display list for the specified playfield void RedrawBackgnd(); // Completely redraws all the playfield object lists for the current background
int which); // which playfield
void KillPlayfieldList( // Kills all the objects on the display list for the specified playfield /**
int which); // which playfield * Called before scene change.
*/
void DropBackground();
void DrawBackgnd(); // Draws all playfields for the current background void ResetBackground() { _pCurBgnd = nullptr; }
void RedrawBackgnd(); // Completely redraws all the playfield object lists for the current background void StartupBackground(CORO_PARAM, SCNHANDLE hFilm);
OBJECT *GetBgObject(); void PlayfieldSetPos( // Sets the xy position of the specified playfield in the current background
int which, // which playfield
int newXpos, // new x position
int newYpos); // new y position
SCNHANDLE BgPal(); void PlayfieldGetPos( // Returns the xy position of the specified playfield in the current background
int which, // which playfield
int* pXpos, // returns current x position
int* pYpos); // returns current y position
int BgWidth(); int PlayfieldGetCenterX( // Returns the xy position of the specified playfield in the current background
int which); // which playfield
int BgHeight(); OBJECT** GetPlayfieldList( // Returns the display list for the specified playfield
int which); // which playfield
OBJECT* GetBgObject() { return _pBG[0]; }
void ChangePalette(SCNHANDLE hPal);
SCNHANDLE BgPal() { return _hBgPal; }
void SetDoFadeIn(bool tf) { _bDoFadeIn = tf; }
bool GetDoFadeIn() { return _bDoFadeIn; }
/**
* Return the current scene handle.
*/
SCNHANDLE GetBgroundHandle() { return _hBackground; }
/**
* Return the width of the current background.
*/
int BgWidth();
/**
* Return the height of the current background.
*/
int BgHeight();
void SetBackPal(SCNHANDLE hPal);
int getBgSpeed() { return _BGspeed; }
private:
Font *_font;
// current background
const BACKGND *_pCurBgnd;
SCNHANDLE _hBgPal; // Background's palette
int _BGspeed;
SCNHANDLE _hBackground; // Current scene handle - stored in case of Save_Scene()
bool _bDoFadeIn;
public:
int _bgReels;
POBJECT _pBG[MAX_BG];
ANIM _thisAnim[MAX_BG]; // used by BGmainProcess()
};
} // End of namespace Tinsel } // End of namespace Tinsel

View File

@ -42,70 +42,10 @@
namespace Tinsel { namespace Tinsel {
//----------------- LOCAL GLOBAL DATA --------------------
#define MAX_BG 10
// FIXME: Avoid non-const global vars
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 g_pBG[0];
}
/**
* BackPal
*/
SCNHANDLE BgPal() {
return g_hBgPal;
}
/**
* SetDoFadeIn
*/
void SetDoFadeIn(bool tf) {
g_bDoFadeIn = tf;
}
/**
* Called before scene change.
*/
void DropBackground() {
g_pBG[0] = NULL; // No background
if (!TinselV2)
g_hBgPal = 0; // No background palette
}
/**
* Return the width of the current background.
*/
int BgWidth() {
assert(g_pBG[0]);
return MultiRightmost(g_pBG[0]) + 1;
}
/**
* Return the height of the current background.
*/
int BgHeight() {
assert(g_pBG[0]);
return MultiLowest(g_pBG[0]) + 1;
}
/** /**
* Run main animation that comprises the scene background. * Run main animation that comprises the scene background.
*/ */
static void BGmainProcess(CORO_PARAM, const void *param) { void BGmainProcess(CORO_PARAM, const void *param) {
// COROUTINE // COROUTINE
CORO_BEGIN_CONTEXT; CORO_BEGIN_CONTEXT;
CORO_END_CONTEXT(_ctx); CORO_END_CONTEXT(_ctx);
@ -117,7 +57,7 @@ static void BGmainProcess(CORO_PARAM, const void *param) {
const MULTI_INIT *pmi; const MULTI_INIT *pmi;
// get the stuff copied to process when it was created // get the stuff copied to process when it was created
if (g_pBG[0] == NULL) { if (_vm->_bg->_pBG[0] == NULL) {
/*** At start of scene ***/ /*** At start of scene ***/
if (!TinselV2) { if (!TinselV2) {
@ -127,40 +67,40 @@ static void BGmainProcess(CORO_PARAM, const void *param) {
pmi = (const MULTI_INIT *)LockMem(FROM_32(pReel->mobj)); pmi = (const MULTI_INIT *)LockMem(FROM_32(pReel->mobj));
// Initialize and insert the object, and initialize its script. // Initialize and insert the object, and initialize its script.
g_pBG[0] = MultiInitObject(pmi); _vm->_bg->_pBG[0] = MultiInitObject(pmi);
MultiInsertObject(GetPlayfieldList(FIELD_WORLD), g_pBG[0]); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_WORLD), _vm->_bg->_pBG[0]);
InitStepAnimScript(&g_thisAnim[0], g_pBG[0], FROM_32(pReel->script), g_BGspeed); InitStepAnimScript(&_vm->_bg->_thisAnim[0], _vm->_bg->_pBG[0], FROM_32(pReel->script), _vm->_bg->getBgSpeed());
g_bgReels = 1; _vm->_bg->_bgReels = 1;
} else { } else {
/*** At start of scene ***/ /*** At start of scene ***/
pFilm = (const FILM *)LockMem(g_hBackground); pFilm = (const FILM *)LockMem(_vm->_bg->GetBgroundHandle());
g_bgReels = FROM_32(pFilm->numreels); _vm->_bg->_bgReels = FROM_32(pFilm->numreels);
int i; int i;
for (i = 0; i < g_bgReels; i++) { for (i = 0; i < _vm->_bg->_bgReels; i++) {
// Get the MULTI_INIT structure // Get the MULTI_INIT structure
pmi = (PMULTI_INIT) LockMem(FROM_32(pFilm->reels[i].mobj)); pmi = (PMULTI_INIT) LockMem(FROM_32(pFilm->reels[i].mobj));
// Initialize and insert the object, and initialize its script. // Initialize and insert the object, and initialize its script.
g_pBG[i] = MultiInitObject(pmi); _vm->_bg->_pBG[i] = MultiInitObject(pmi);
MultiInsertObject(GetPlayfieldList(FIELD_WORLD), g_pBG[i]); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_WORLD), _vm->_bg->_pBG[i]);
MultiSetZPosition(g_pBG[i], 0); MultiSetZPosition(_vm->_bg->_pBG[i], 0);
InitStepAnimScript(&g_thisAnim[i], g_pBG[i], FROM_32(pFilm->reels[i].script), g_BGspeed); InitStepAnimScript(&_vm->_bg->_thisAnim[i], _vm->_bg->_pBG[i], FROM_32(pFilm->reels[i].script), _vm->_bg->getBgSpeed());
if (i > 0) if (i > 0)
g_pBG[i-1]->pSlave = g_pBG[i]; _vm->_bg->_pBG[i-1]->pSlave = _vm->_bg->_pBG[i];
} }
} }
if (g_bDoFadeIn) { if (_vm->_bg->GetDoFadeIn()) {
FadeInFast(); FadeInFast();
g_bDoFadeIn = false; _vm->_bg->SetDoFadeIn(false);
} else if (TinselV2) } else if (TinselV2)
PokeInTagColor(); PokeInTagColor();
for (;;) { for (;;) {
for (int i = 0; i < g_bgReels; i++) { for (int i = 0; i < _vm->_bg->_bgReels; i++) {
if (StepAnimScript(&g_thisAnim[i]) == ScriptFinished) if (StepAnimScript(&_vm->_bg->_thisAnim[i]) == ScriptFinished)
error("Background animation has finished"); error("Background animation has finished");
} }
@ -170,16 +110,16 @@ static void BGmainProcess(CORO_PARAM, const void *param) {
// New background during scene // New background during scene
if (!TinselV2) { if (!TinselV2) {
pReel = (const FREEL *)param; pReel = (const FREEL *)param;
InitStepAnimScript(&g_thisAnim[0], g_pBG[0], FROM_32(pReel->script), g_BGspeed); InitStepAnimScript(&_vm->_bg->_thisAnim[0], _vm->_bg->_pBG[0], FROM_32(pReel->script), _vm->_bg->getBgSpeed());
StepAnimScript(&g_thisAnim[0]); StepAnimScript(&_vm->_bg->_thisAnim[0]);
} else { } else {
pFilm = (const FILM *)LockMem(g_hBackground); pFilm = (const FILM *)LockMem(_vm->_bg->GetBgroundHandle());
assert(g_bgReels == (int32)FROM_32(pFilm->numreels)); assert(_vm->_bg->_bgReels == (int32)FROM_32(pFilm->numreels));
// Just re-initialize the scripts. // Just re-initialize the scripts.
for (int i = 0; i < g_bgReels; i++) { for (int i = 0; i < _vm->_bg->_bgReels; i++) {
InitStepAnimScript(&g_thisAnim[i], g_pBG[i], pFilm->reels[i].script, g_BGspeed); InitStepAnimScript(&_vm->_bg->_thisAnim[i], _vm->_bg->_pBG[i], pFilm->reels[i].script, _vm->_bg->getBgSpeed());
StepAnimScript(&g_thisAnim[i]); StepAnimScript(&_vm->_bg->_thisAnim[i]);
} }
} }
} }
@ -190,7 +130,7 @@ static void BGmainProcess(CORO_PARAM, const void *param) {
/** /**
* Runs secondary reels for a scene background * Runs secondary reels for a scene background
*/ */
static void BGotherProcess(CORO_PARAM, const void *param) { void BGotherProcess(CORO_PARAM, const void *param) {
// COROUTINE // COROUTINE
CORO_BEGIN_CONTEXT; CORO_BEGIN_CONTEXT;
OBJECT *pObj; OBJECT *pObj;
@ -204,9 +144,9 @@ static void BGotherProcess(CORO_PARAM, const void *param) {
// Initialize and insert the object, and initialize its script. // Initialize and insert the object, and initialize its script.
_ctx->pObj = MultiInitObject(pmi); _ctx->pObj = MultiInitObject(pmi);
MultiInsertObject(GetPlayfieldList(FIELD_WORLD), _ctx->pObj); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_WORLD), _ctx->pObj);
InitStepAnimScript(&_ctx->anim, g_pBG[0], FROM_32(pReel->script), g_BGspeed); InitStepAnimScript(&_ctx->anim, _vm->_bg->_pBG[0], FROM_32(pReel->script), _vm->_bg->getBgSpeed());
while (StepAnimScript(&_ctx->anim) != ScriptFinished) while (StepAnimScript(&_ctx->anim) != ScriptFinished)
CORO_SLEEP(1); CORO_SLEEP(1);
@ -214,29 +154,13 @@ static void BGotherProcess(CORO_PARAM, const void *param) {
CORO_END_CODE; CORO_END_CODE;
} }
/**
* AetBgPal()
*/
void SetBackPal(SCNHANDLE hPal) {
g_hBgPal = hPal;
_vm->_font->FettleFontPal(g_hBgPal);
CreateTranslucentPalette(g_hBgPal);
}
void ChangePalette(SCNHANDLE hPal) {
SwapPalette(FindPalette(g_hBgPal), hPal);
SetBackPal(hPal);
}
/** /**
* Given the scene background film, extracts the palette handle for * Given the scene background film, extracts the palette handle for
* everything else's use, then starts a display process for each reel * everything else's use, then starts a display process for each reel
* in the film. * in the film.
* @param hFilm Scene background film * @param hFilm Scene background film
*/ */
void StartupBackground(CORO_PARAM, SCNHANDLE hFilm) { void Background::StartupBackground(CORO_PARAM, SCNHANDLE hFilm) {
CORO_BEGIN_CONTEXT; CORO_BEGIN_CONTEXT;
CORO_END_CONTEXT(_ctx); CORO_END_CONTEXT(_ctx);
@ -245,14 +169,14 @@ void StartupBackground(CORO_PARAM, SCNHANDLE hFilm) {
const FILM *pfilm; const FILM *pfilm;
IMAGE *pim; IMAGE *pim;
g_hBackground = hFilm; // Save handle in case of Save_Scene() _hBackground = hFilm; // Save handle in case of Save_Scene()
pim = GetImageFromFilm(hFilm, 0, NULL, NULL, &pfilm); pim = GetImageFromFilm(hFilm, 0, NULL, NULL, &pfilm);
SetBackPal(FROM_32(pim->hImgPal)); SetBackPal(FROM_32(pim->hImgPal));
// Extract the film speed // Extract the film speed
g_BGspeed = ONE_SECOND / FROM_32(pfilm->frate); _BGspeed = ONE_SECOND / FROM_32(pfilm->frate);
// Start display process for each reel in the film // Start display process for each reel in the film
CoroScheduler.createProcess(PID_REEL, BGmainProcess, &pfilm->reels[0], sizeof(FREEL)); CoroScheduler.createProcess(PID_REEL, BGmainProcess, &pfilm->reels[0], sizeof(FREEL));
@ -262,7 +186,7 @@ void StartupBackground(CORO_PARAM, SCNHANDLE hFilm) {
CoroScheduler.createProcess(PID_REEL, BGotherProcess, &pfilm->reels[i], sizeof(FREEL)); CoroScheduler.createProcess(PID_REEL, BGotherProcess, &pfilm->reels[i], sizeof(FREEL));
} }
if (g_pBG[0] == NULL) if (_pBG[0] == NULL)
ControlStartOff(); ControlStartOff();
if (TinselV2 && (coroParam != Common::nullContext)) if (TinselV2 && (coroParam != Common::nullContext))
@ -271,11 +195,4 @@ void StartupBackground(CORO_PARAM, SCNHANDLE hFilm) {
CORO_END_CODE; CORO_END_CODE;
} }
/**
* Return the current scene handle.
*/
SCNHANDLE GetBgroundHandle() {
return g_hBackground;
}
} // End of namespace Tinsel } // End of namespace Tinsel

View File

@ -440,7 +440,7 @@ void BMVPlayer::FettleMovieText() {
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
if (texts[i].pText) { if (texts[i].pText) {
if (currentFrame > texts[i].dieFrame) { if (currentFrame > texts[i].dieFrame) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), texts[i].pText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), texts[i].pText);
texts[i].pText = NULL; texts[i].pText = NULL;
} else { } else {
MultiForceRedraw(texts[i].pText); MultiForceRedraw(texts[i].pText);
@ -480,7 +480,7 @@ void BMVPlayer::BmvDrawText(bool bDraw) {
rcPlayClip.top = y; rcPlayClip.top = y;
rcPlayClip.right = x+w; rcPlayClip.right = x+w;
rcPlayClip.bottom = y+h; rcPlayClip.bottom = y+h;
UpdateClipRect(GetPlayfieldList(FIELD_STATUS), &ptWin, &rcPlayClip); UpdateClipRect(_vm->_bg->GetPlayfieldList(FIELD_STATUS), &ptWin, &rcPlayClip);
} }
} }
} }
@ -509,12 +509,12 @@ void BMVPlayer::MovieText(CORO_PARAM, int stringId, int x, int y, int fontId, CO
} }
if (texts[index].pText) if (texts[index].pText)
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), texts[index].pText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), texts[index].pText);
LoadSubString(stringId, 0, _vm->_font->TextBufferAddr(), TBUFSZ); LoadSubString(stringId, 0, _vm->_font->TextBufferAddr(), TBUFSZ);
texts[index].dieFrame = currentFrame + duration; texts[index].dieFrame = currentFrame + duration;
texts[index].pText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), texts[index].pText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), _vm->_font->TextBufferAddr(),
0, 0,
x, y, x, y,
@ -734,7 +734,7 @@ void BMVPlayer::FinishBMV() {
// Ditch any text objects // Ditch any text objects
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
if (texts[i].pText) { if (texts[i].pText) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), texts[i].pText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), texts[i].pText);
texts[i].pText = NULL; texts[i].pText = NULL;
} }
} }
@ -1025,7 +1025,7 @@ bool BMVPlayer::DoSoundFrame() {
void BMVPlayer::CopyMovieToScreen() { void BMVPlayer::CopyMovieToScreen() {
// Not if not up and running yet! // Not if not up and running yet!
if (!screenBuffer || (currentFrame == 0)) { if (!screenBuffer || (currentFrame == 0)) {
DrawBackgnd(); _vm->_bg->DrawBackgnd();
return; return;
} }

View File

@ -121,15 +121,15 @@ static void InitCurTrailObj(int i, int x, int y) {
// Get rid of old object // Get rid of old object
if (g_ntrailData[i].trailObj != NULL) if (g_ntrailData[i].trailObj != NULL)
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
pim = GetImageFromFilm(g_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 assert(_vm->_bg->BgPal()); // No background palette
pim->hImgPal = TO_32(BgPal()); pim->hImgPal = TO_32(_vm->_bg->BgPal());
// Initialize and insert the object, set its Z-pos, and hide it // Initialize and insert the object, set its Z-pos, and hide it
g_ntrailData[i].trailObj = MultiInitObject(pmi); g_ntrailData[i].trailObj = MultiInitObject(pmi);
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
MultiSetZPosition(g_ntrailData[i].trailObj, Z_CURSORTRAIL); MultiSetZPosition(g_ntrailData[i].trailObj, Z_CURSORTRAIL);
MultiSetAniXY(g_ntrailData[i].trailObj, x, y); MultiSetAniXY(g_ntrailData[i].trailObj, x, y);
@ -170,7 +170,7 @@ void SetCursorXY(int newx, int newy) {
int x, y; int x, y;
int Loffset, Toffset; // Screen offset int Loffset, Toffset; // Screen offset
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
newx -= Loffset; newx -= Loffset;
newy -= Toffset; newy -= Toffset;
@ -205,7 +205,7 @@ bool GetCursorXYNoWait(int *x, int *y, bool absolute) {
if (absolute) { if (absolute) {
int Loffset, Toffset; // Screen offset int Loffset, Toffset; // Screen offset
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
*x += Loffset; *x += Loffset;
*y += Toffset; *y += Toffset;
} }
@ -267,7 +267,7 @@ void DwHideCursor() {
for (i = 0; i < g_numTrails; i++) { for (i = 0; i < g_numTrails; i++) {
if (g_ntrailData[i].trailObj != NULL) { if (g_ntrailData[i].trailObj != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
g_ntrailData[i].trailObj = NULL; g_ntrailData[i].trailObj = NULL;
} }
} }
@ -304,7 +304,7 @@ void HideCursorTrails() {
for (i = 0; i < g_numTrails; i++) { for (i = 0; i < g_numTrails; i++) {
if (g_ntrailData[i].trailObj != NULL) { if (g_ntrailData[i].trailObj != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
g_ntrailData[i].trailObj = NULL; g_ntrailData[i].trailObj = NULL;
} }
} }
@ -357,7 +357,7 @@ IMAGE *GetImageFromFilm(SCNHANDLE hFilm, int reel, const FREEL **ppfr, const MUL
*/ */
void DelAuxCursor() { void DelAuxCursor() {
if (g_AcurObj != NULL) { if (g_AcurObj != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_AcurObj); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_AcurObj);
g_AcurObj = NULL; g_AcurObj = NULL;
} }
} }
@ -376,14 +376,14 @@ void SetAuxCursor(SCNHANDLE hFilm) {
DelAuxCursor(); // Get rid of previous DelAuxCursor(); // Get rid of previous
// WORKAROUND: There's no palette when loading a DW1 savegame with a held item, so exit if so // WORKAROUND: There's no palette when loading a DW1 savegame with a held item, so exit if so
if (!BgPal()) if (!_vm->_bg->BgPal())
return; return;
GetCursorXY(&x, &y, false); // Note: also waits for cursor to appear GetCursorXY(&x, &y, false); // Note: also waits for cursor to appear
pim = GetImageFromFilm(hFilm, 0, &pfr, &pmi, &pfilm);// Get pointer to image pim = GetImageFromFilm(hFilm, 0, &pfr, &pmi, &pfilm);// Get pointer to image
assert(BgPal()); // no background palette assert(_vm->_bg->BgPal()); // no background palette
pim->hImgPal = TO_32(BgPal()); // Poke in the 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_ACoX = (short)(FROM_16(pim->imgWidth)/2 - ((int16) FROM_16(pim->anioffX)));
g_ACoY = (short)((FROM_16(pim->imgHeight) & ~C16_FLAG_MASK)/2 - g_ACoY = (short)((FROM_16(pim->imgHeight) & ~C16_FLAG_MASK)/2 -
@ -391,7 +391,7 @@ void SetAuxCursor(SCNHANDLE hFilm) {
// Initialize and insert the auxillary cursor object // Initialize and insert the auxillary cursor object
g_AcurObj = MultiInitObject(pmi); g_AcurObj = MultiInitObject(pmi);
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_AcurObj); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_AcurObj);
// Initialize the animation and set its position // Initialize the animation and set its position
InitStepAnimScript(&g_AcurAnim, g_AcurObj, FROM_32(pfr->script), ONE_SECOND / FROM_32(pfilm->frate)); InitStepAnimScript(&g_AcurAnim, g_AcurObj, FROM_32(pfr->script), ONE_SECOND / FROM_32(pfilm->frate));
@ -489,16 +489,16 @@ static void InitCurObj() {
PokeInPalette(pmi); PokeInPalette(pmi);
} else { } else {
assert(BgPal()); // no background palette assert(_vm->_bg->BgPal()); // no background palette
pim = GetImageFromFilm(g_hCursorFilm, 0, &pfr, &pmi, &pFilm);// Get pointer to image pim = GetImageFromFilm(g_hCursorFilm, 0, &pfr, &pmi, &pFilm);// Get pointer to image
pim->hImgPal = TO_32(BgPal()); pim->hImgPal = TO_32(_vm->_bg->BgPal());
g_AcurObj = NULL; // No auxillary cursor g_AcurObj = NULL; // No auxillary cursor
} }
g_McurObj = MultiInitObject(pmi); g_McurObj = MultiInitObject(pmi);
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_McurObj); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_McurObj);
InitStepAnimScript(&g_McurAnim, g_McurObj, FROM_32(pfr->script), ONE_SECOND / FROM_32(pFilm->frate)); InitStepAnimScript(&g_McurAnim, g_McurObj, FROM_32(pfr->script), ONE_SECOND / FROM_32(pFilm->frate));
} }
@ -556,7 +556,7 @@ void CursorProcess(CORO_PARAM, const void *) {
CORO_BEGIN_CODE(_ctx); CORO_BEGIN_CODE(_ctx);
while (!g_hCursorFilm || !BgPal()) while (!g_hCursorFilm || !_vm->_bg->BgPal())
CORO_SLEEP(1); CORO_SLEEP(1);
InitCurObj(); InitCurObj();
@ -580,7 +580,7 @@ void CursorProcess(CORO_PARAM, const void *) {
for (int i = 0; i < g_numTrails; i++) { for (int i = 0; i < g_numTrails; i++) {
if (g_ntrailData[i].trailObj != NULL) { if (g_ntrailData[i].trailObj != NULL) {
if (StepAnimScript(&g_ntrailData[i].trailAnim) == ScriptFinished) { if (StepAnimScript(&g_ntrailData[i].trailAnim) == ScriptFinished) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
g_ntrailData[i].trailObj = NULL; g_ntrailData[i].trailObj = NULL;
} }
} }
@ -635,9 +635,9 @@ void DwInitCursor(SCNHANDLE bfilm) {
void DropCursor() { void DropCursor() {
if (TinselV2) { if (TinselV2) {
if (g_AcurObj) if (g_AcurObj)
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_AcurObj); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_AcurObj);
if (g_McurObj) if (g_McurObj)
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_McurObj); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_McurObj);
g_restart = 0; g_restart = 0;
} }
@ -650,7 +650,7 @@ void DropCursor() {
for (int i = 0; i < g_numTrails; i++) { for (int i = 0; i < g_numTrails; i++) {
if (g_ntrailData[i].trailObj != NULL) { if (g_ntrailData[i].trailObj != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj);
g_ntrailData[i].trailObj = NULL; g_ntrailData[i].trailObj = NULL;
} }
} }

View File

@ -1217,7 +1217,7 @@ static void HopAction() {
static void DumpIconArray() { static void DumpIconArray() {
for (int i = 0; i < MAX_ICONS; i++) { for (int i = 0; i < MAX_ICONS; i++) {
if (g_iconArray[i] != NULL) { if (g_iconArray[i] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[i]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[i]);
g_iconArray[i] = NULL; g_iconArray[i] = NULL;
} }
} }
@ -1229,7 +1229,7 @@ static void DumpIconArray() {
static void DumpDobjArray() { static void DumpDobjArray() {
for (int i = 0; i < MAX_WCOMP; i++) { for (int i = 0; i < MAX_WCOMP; i++) {
if (g_DobjArray[i] != NULL) { if (g_DobjArray[i] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_DobjArray[i]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_DobjArray[i]);
g_DobjArray[i] = NULL; g_DobjArray[i] = NULL;
} }
} }
@ -1241,7 +1241,7 @@ static void DumpDobjArray() {
static void DumpObjArray() { static void DumpObjArray() {
for (int i = 0; i < MAX_WCOMP; i++) { for (int i = 0; i < MAX_WCOMP; i++) {
if (g_objArray[i] != NULL) { if (g_objArray[i] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_objArray[i]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_objArray[i]);
g_objArray[i] = NULL; g_objArray[i] = NULL;
} }
} }
@ -1517,15 +1517,15 @@ static void InvLoadGame() {
rGame = cd.selBox; rGame = cd.selBox;
cd.selBox = NOBOX; cd.selBox = NOBOX;
if (g_iconArray[HL3] != NULL) { if (g_iconArray[HL3] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]);
g_iconArray[HL3] = NULL; g_iconArray[HL3] = NULL;
} }
if (g_iconArray[HL2] != NULL) { if (g_iconArray[HL2] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]);
g_iconArray[HL2] = NULL; g_iconArray[HL2] = NULL;
} }
if (g_iconArray[HL1] != NULL) { if (g_iconArray[HL1] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
g_iconArray[HL1] = NULL; g_iconArray[HL1] = NULL;
} }
RestoreGame(rGame+cd.extraBase); RestoreGame(rGame+cd.extraBase);
@ -1593,19 +1593,19 @@ static bool InvKeyIn(const Common::KeyState &kbd) {
* and replace it with freshly edited text. * and replace it with freshly edited text.
*/ */
if (g_iconArray[HL3] != NULL) { if (g_iconArray[HL3] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]);
g_iconArray[HL3] = NULL; g_iconArray[HL3] = NULL;
} }
g_iconArray[HL3] = ObjectTextOut( g_iconArray[HL3] = ObjectTextOut(
GetPlayfieldList(FIELD_STATUS), g_sedit, 0, _vm->_bg->GetPlayfieldList(FIELD_STATUS), g_sedit, 0,
g_InvD[g_ino].inventoryX + cd.box[cd.selBox].xpos + 2, g_InvD[g_ino].inventoryX + cd.box[cd.selBox].xpos + 2,
g_InvD[g_ino].inventoryY + cd.box[cd.selBox].ypos + TYOFF, g_InvD[g_ino].inventoryY + cd.box[cd.selBox].ypos + TYOFF,
_vm->_font->GetTagFontHandle(), 0); _vm->_font->GetTagFontHandle(), 0);
if (MultiRightmost(g_iconArray[HL3]) > MAX_NAME_RIGHT) { if (MultiRightmost(g_iconArray[HL3]) > MAX_NAME_RIGHT) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]);
UpdateString(Common::KeyState(Common::KEYCODE_BACKSPACE)); UpdateString(Common::KeyState(Common::KEYCODE_BACKSPACE));
g_iconArray[HL3] = ObjectTextOut( g_iconArray[HL3] = ObjectTextOut(
GetPlayfieldList(FIELD_STATUS), g_sedit, 0, _vm->_bg->GetPlayfieldList(FIELD_STATUS), g_sedit, 0,
g_InvD[g_ino].inventoryX + cd.box[cd.selBox].xpos + 2, g_InvD[g_ino].inventoryX + cd.box[cd.selBox].xpos + 2,
g_InvD[g_ino].inventoryY + cd.box[cd.selBox].ypos + TYOFF, g_InvD[g_ino].inventoryY + cd.box[cd.selBox].ypos + TYOFF,
_vm->_font->GetTagFontHandle(), 0); _vm->_font->GetTagFontHandle(), 0);
@ -1636,20 +1636,20 @@ static void Select(int i, bool force) {
// Clear previous selected highlight and text // Clear previous selected highlight and text
if (g_iconArray[HL2] != NULL) { if (g_iconArray[HL2] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]);
g_iconArray[HL2] = NULL; g_iconArray[HL2] = NULL;
} }
if (g_iconArray[HL3] != NULL) { if (g_iconArray[HL3] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]);
g_iconArray[HL3] = NULL; g_iconArray[HL3] = NULL;
} }
// New highlight box // New highlight box
switch (cd.box[i].boxType) { switch (cd.box[i].boxType) {
case RGROUP: case RGROUP:
g_iconArray[HL2] = RectangleObject(BgPal(), g_iconArray[HL2] = RectangleObject(_vm->_bg->BgPal(),
(TinselV2 ? HighlightColor() : COL_HILIGHT), cd.box[i].w, cd.box[i].h); (TinselV2 ? HighlightColor() : COL_HILIGHT), cd.box[i].w, cd.box[i].h);
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]);
MultiSetAniXY(g_iconArray[HL2], MultiSetAniXY(g_iconArray[HL2],
g_InvD[g_ino].inventoryX + cd.box[i].xpos, g_InvD[g_ino].inventoryX + cd.box[i].xpos,
g_InvD[g_ino].inventoryY + cd.box[i].ypos); g_InvD[g_ino].inventoryY + cd.box[i].ypos);
@ -1679,7 +1679,7 @@ static void Select(int i, bool force) {
#endif #endif
g_iconArray[HL3] = ObjectTextOut( g_iconArray[HL3] = ObjectTextOut(
GetPlayfieldList(FIELD_STATUS), g_sedit, 0, _vm->_bg->GetPlayfieldList(FIELD_STATUS), g_sedit, 0,
g_InvD[g_ino].inventoryX + cd.box[i].xpos + 2, g_InvD[g_ino].inventoryX + cd.box[i].xpos + 2,
#ifdef JAPAN #ifdef JAPAN
g_InvD[g_ino].inventoryY + cd.box[i].ypos + 2, g_InvD[g_ino].inventoryY + cd.box[i].ypos + 2,
@ -1697,8 +1697,8 @@ static void Select(int i, bool force) {
break; break;
case FRGROUP: case FRGROUP:
g_iconArray[HL2] = RectangleObject(BgPal(), COL_HILIGHT, cd.box[i].w+6, cd.box[i].h+6); g_iconArray[HL2] = RectangleObject(_vm->_bg->BgPal(), COL_HILIGHT, cd.box[i].w+6, cd.box[i].h+6);
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]);
MultiSetAniXY(g_iconArray[HL2], MultiSetAniXY(g_iconArray[HL2],
g_InvD[g_ino].inventoryX + cd.box[i].xpos - 2, g_InvD[g_ino].inventoryX + cd.box[i].xpos - 2,
g_InvD[g_ino].inventoryY + cd.box[i].ypos - 2); g_InvD[g_ino].inventoryY + cd.box[i].ypos - 2);
@ -2276,24 +2276,24 @@ static void InvBoxes(bool InBody, int curX, int curY) {
// unhigh-light box (if one was) // unhigh-light box (if one was)
cd.pointBox = NOBOX; cd.pointBox = NOBOX;
if (g_iconArray[HL1] != NULL) { if (g_iconArray[HL1] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
g_iconArray[HL1] = NULL; g_iconArray[HL1] = NULL;
} }
} else if (index != cd.pointBox) { } else if (index != cd.pointBox) {
cd.pointBox = index; cd.pointBox = index;
// A new box is pointed to - high-light it // A new box is pointed to - high-light it
if (g_iconArray[HL1] != NULL) { if (g_iconArray[HL1] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
g_iconArray[HL1] = NULL; g_iconArray[HL1] = NULL;
} }
if ((cd.box[cd.pointBox].boxType == ARSBUT && cd.selBox != NOBOX) || if ((cd.box[cd.pointBox].boxType == ARSBUT && cd.selBox != NOBOX) ||
///* I don't agree */ cd.box[cd.pointBox].boxType == RGROUP || ///* I don't agree */ cd.box[cd.pointBox].boxType == RGROUP ||
cd.box[cd.pointBox].boxType == AATBUT || cd.box[cd.pointBox].boxType == AATBUT ||
cd.box[cd.pointBox].boxType == AABUT) { cd.box[cd.pointBox].boxType == AABUT) {
g_iconArray[HL1] = RectangleObject(BgPal(), g_iconArray[HL1] = RectangleObject(_vm->_bg->BgPal(),
(TinselV2 ? HighlightColor() : COL_HILIGHT), (TinselV2 ? HighlightColor() : COL_HILIGHT),
cd.box[cd.pointBox].w, cd.box[cd.pointBox].h); cd.box[cd.pointBox].w, cd.box[cd.pointBox].h);
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
MultiSetAniXY(g_iconArray[HL1], MultiSetAniXY(g_iconArray[HL1],
g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos, g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos,
g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos); g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos);
@ -2347,7 +2347,7 @@ static void ButtonPress(CORO_PARAM, CONFBOX *box) {
// Replace highlight image with normal image // Replace highlight image with normal image
pfilm = (const FILM *)LockMem(g_hWinParts); pfilm = (const FILM *)LockMem(g_hWinParts);
if (g_iconArray[HL1] != NULL) if (g_iconArray[HL1] != NULL)
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
pfilm = (const FILM *)LockMem(g_hWinParts); pfilm = (const FILM *)LockMem(g_hWinParts);
g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+NORMGRAPH], -1); 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); MultiSetAniXY(g_iconArray[HL1], g_InvD[g_ino].inventoryX + box->xpos, g_InvD[g_ino].inventoryY + box->ypos);
@ -2360,7 +2360,7 @@ static void ButtonPress(CORO_PARAM, CONFBOX *box) {
// Replace normal image with depresses image // Replace normal image with depresses image
pfilm = (const FILM *)LockMem(g_hWinParts); pfilm = (const FILM *)LockMem(g_hWinParts);
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1); 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); 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); MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);
@ -2372,7 +2372,7 @@ static void ButtonPress(CORO_PARAM, CONFBOX *box) {
// Replace depressed image with normal image // Replace depressed image with normal image
pfilm = (const FILM *)LockMem(g_hWinParts); pfilm = (const FILM *)LockMem(g_hWinParts);
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+NORMGRAPH], -1); 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); 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); MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);
@ -2395,7 +2395,7 @@ static void ButtonToggle(CORO_PARAM, CONFBOX *box) {
// Remove hilight image // Remove hilight image
if (g_iconArray[HL1] != NULL) { if (g_iconArray[HL1] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
g_iconArray[HL1] = NULL; g_iconArray[HL1] = NULL;
} }
@ -2426,7 +2426,7 @@ static void ButtonToggle(CORO_PARAM, CONFBOX *box) {
// New state, depressed image // New state, depressed image
pfilm = (const FILM *)LockMem(g_hWinParts); pfilm = (const FILM *)LockMem(g_hWinParts);
if (g_iconArray[HL1] != NULL) if (g_iconArray[HL1] != NULL)
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1); 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); 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); MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);
@ -2437,7 +2437,7 @@ static void ButtonToggle(CORO_PARAM, CONFBOX *box) {
return; return;
// New state, normal // New state, normal
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
g_iconArray[HL1] = NULL; g_iconArray[HL1] = NULL;
// Hold normal image for 1 frame // Hold normal image for 1 frame
@ -2448,7 +2448,7 @@ static void ButtonToggle(CORO_PARAM, CONFBOX *box) {
// New state, highlighted // New state, highlighted
pfilm = (const FILM *)LockMem(g_hWinParts); pfilm = (const FILM *)LockMem(g_hWinParts);
if (g_iconArray[HL1] != NULL) if (g_iconArray[HL1] != NULL)
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]);
g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+HIGRAPH], -1); 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); 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); MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);
@ -2573,11 +2573,11 @@ static OBJECT *AddInvObject(int num, const FREEL **pfreel, const FILM **pfilm) {
pim = GetImageFromFilm(invObj->hIconFilm, 0, pfreel, &pmi, pfilm); pim = GetImageFromFilm(invObj->hIconFilm, 0, pfreel, &pmi, pfilm);
// Poke in the background palette // Poke in the background palette
pim->hImgPal = TO_32(BgPal()); pim->hImgPal = TO_32(_vm->_bg->BgPal());
// Set up the multi-object // Set up the multi-object
pPlayObj = MultiInitObject(pmi); pPlayObj = MultiInitObject(pmi);
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), pPlayObj); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), pPlayObj);
return pPlayObj; return pPlayObj;
} }
@ -2639,7 +2639,7 @@ static void AddBackground(OBJECT **rect, OBJECT **title, int extraH, int extraV,
g_RectObject = *rect = TranslucentObject(width, height); g_RectObject = *rect = TranslucentObject(width, height);
// add it to display list and position it // add it to display list and position it
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), *rect); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), *rect);
MultiSetAniXY(*rect, g_InvD[g_ino].inventoryX + NM_BG_POS_X, MultiSetAniXY(*rect, g_InvD[g_ino].inventoryX + NM_BG_POS_X,
g_InvD[g_ino].inventoryY + NM_BG_POS_Y); g_InvD[g_ino].inventoryY + NM_BG_POS_Y);
MultiSetZPosition(*rect, Z_INV_BRECT); MultiSetZPosition(*rect, Z_INV_BRECT);
@ -2650,14 +2650,14 @@ static void AddBackground(OBJECT **rect, OBJECT **title, int extraH, int extraV,
// Create text object using title string // Create text object using title string
if (textFrom == FROM_HANDLE) { if (textFrom == FROM_HANDLE) {
LoadStringRes(g_InvD[g_ino].hInvTitle, _vm->_font->TextBufferAddr(), TBUFSZ); LoadStringRes(g_InvD[g_ino].hInvTitle, _vm->_font->TextBufferAddr(), TBUFSZ);
*title = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), 0, *title = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), 0,
g_InvD[g_ino].inventoryX + width/2, g_InvD[g_ino].inventoryY + M_TOFF, g_InvD[g_ino].inventoryX + width/2, g_InvD[g_ino].inventoryY + M_TOFF,
_vm->_font->GetTagFontHandle(), TXT_CENTER); _vm->_font->GetTagFontHandle(), TXT_CENTER);
assert(*title); // Inventory title string produced NULL text assert(*title); // Inventory title string produced NULL text
MultiSetZPosition(*title, Z_INV_HTEXT); MultiSetZPosition(*title, Z_INV_HTEXT);
} else if (textFrom == FROM_STRING && cd.ixHeading != NO_HEADING) { } else if (textFrom == FROM_STRING && cd.ixHeading != NO_HEADING) {
LoadStringRes(g_configStrings[cd.ixHeading], _vm->_font->TextBufferAddr(), TBUFSZ); LoadStringRes(g_configStrings[cd.ixHeading], _vm->_font->TextBufferAddr(), TBUFSZ);
*title = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), 0, *title = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), 0,
g_InvD[g_ino].inventoryX + width/2, g_InvD[g_ino].inventoryY + M_TOFF, g_InvD[g_ino].inventoryX + width/2, g_InvD[g_ino].inventoryY + M_TOFF,
_vm->_font->GetTagFontHandle(), TXT_CENTER); _vm->_font->GetTagFontHandle(), TXT_CENTER);
assert(*title); // Inventory title string produced NULL text assert(*title); // Inventory title string produced NULL text
@ -2681,7 +2681,7 @@ static void AddTitle(POBJECT *title, int extraH) {
// Create text object using title string // Create text object using title string
if (g_InvD[g_ino].hInvTitle != (SCNHANDLE)NO_HEADING) { if (g_InvD[g_ino].hInvTitle != (SCNHANDLE)NO_HEADING) {
LoadStringRes(g_InvD[g_ino].hInvTitle, _vm->_font->TextBufferAddr(), TBUFSZ); LoadStringRes(g_InvD[g_ino].hInvTitle, _vm->_font->TextBufferAddr(), TBUFSZ);
*title = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), 0, *title = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), 0,
g_InvD[g_ino].inventoryX + (width/2)+NM_BG_POS_X, g_InvD[g_ino].inventoryY + NM_TOFF, g_InvD[g_ino].inventoryX + (width/2)+NM_BG_POS_X, g_InvD[g_ino].inventoryY + NM_TOFF,
_vm->_font->GetTagFontHandle(), TXT_CENTER, 0); _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
assert(*title); assert(*title);
@ -2702,7 +2702,7 @@ static OBJECT *AddObject(const FREEL *pfreel, int num) {
pim = GetImageFromReel(pfreel, &pmi); pim = GetImageFromReel(pfreel, &pmi);
// Poke in the background palette // Poke in the background palette
pim->hImgPal = TO_32(BgPal()); pim->hImgPal = TO_32(_vm->_bg->BgPal());
// Horrible bodge involving global variables to save // Horrible bodge involving global variables to save
// width and/or height of some window frame components // width and/or height of some window frame components
@ -2717,7 +2717,7 @@ static OBJECT *AddObject(const FREEL *pfreel, int num) {
// Set up and insert the multi-object // Set up and insert the multi-object
pPlayObj = MultiInitObject(pmi); pPlayObj = MultiInitObject(pmi);
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), pPlayObj); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), pPlayObj);
return pPlayObj; return pPlayObj;
} }
@ -2750,9 +2750,9 @@ static void AddBox(int *pi, const int i) {
break; break;
// Give us a box // Give us a box
g_iconArray[*pi] = RectangleObject(BgPal(), TinselV2 ? BoxColor() : COL_BOX, g_iconArray[*pi] = RectangleObject(_vm->_bg->BgPal(), TinselV2 ? BoxColor() : COL_BOX,
cd.box[i].w, cd.box[i].h); cd.box[i].w, cd.box[i].h);
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[*pi]); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_iconArray[*pi]);
MultiSetAniXY(g_iconArray[*pi], x, y); MultiSetAniXY(g_iconArray[*pi], x, y);
MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1); MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1; *pi += 1;
@ -2762,14 +2762,14 @@ static void AddBox(int *pi, const int i) {
(!TinselV2 && (cd.box[i].ixText == USE_POINTER))) { (!TinselV2 && (cd.box[i].ixText == USE_POINTER))) {
if (cd.box[i].boxText != NULL) { if (cd.box[i].boxText != NULL) {
if (cd.box[i].boxType == RGROUP) { if (cd.box[i].boxType == RGROUP) {
g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0, g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0,
#ifdef JAPAN #ifdef JAPAN
x + 2, y+2, GetTagFontHandle(), 0); x + 2, y+2, GetTagFontHandle(), 0);
#else #else
x + 2, y + TYOFF, _vm->_font->GetTagFontHandle(), 0); x + 2, y + TYOFF, _vm->_font->GetTagFontHandle(), 0);
#endif #endif
} else { } else {
g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0, g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0,
#ifdef JAPAN #ifdef JAPAN
// Note: it never seems to go here! // Note: it never seems to go here!
x + cd.box[i].w/2, y+2, GetTagFontHandle(), TXT_CENTER); x + cd.box[i].w/2, y+2, GetTagFontHandle(), TXT_CENTER);
@ -2795,10 +2795,10 @@ static void AddBox(int *pi, const int i) {
} }
if (TinselV2 && (cd.box[i].boxType == RGROUP)) if (TinselV2 && (cd.box[i].boxType == RGROUP))
g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(),
0, x + 2, y + TYOFF, _vm->_font->GetTagFontHandle(), 0, 0); 0, x + 2, y + TYOFF, _vm->_font->GetTagFontHandle(), 0, 0);
else else
g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), 0, _vm->_font->TextBufferAddr(), 0,
#ifdef JAPAN #ifdef JAPAN
x + cd.box[i].w/2, y+2, GetTagFontHandle(), TXT_CENTER); x + cd.box[i].w/2, y+2, GetTagFontHandle(), TXT_CENTER);
@ -2855,7 +2855,7 @@ static void AddBox(int *pi, const int i) {
assert(cd.box[i].ixText != USE_POINTER); assert(cd.box[i].ixText != USE_POINTER);
LoadStringRes(g_configStrings[cd.box[i].ixText], _vm->_font->TextBufferAddr(), TBUFSZ); LoadStringRes(g_configStrings[cd.box[i].ixText], _vm->_font->TextBufferAddr(), TBUFSZ);
} }
g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF, _vm->_font->GetTagFontHandle(), TXT_RIGHT); _vm->_font->TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF, _vm->_font->GetTagFontHandle(), TXT_RIGHT);
MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT); MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
*pi += 1; *pi += 1;
@ -2882,11 +2882,11 @@ static void AddBox(int *pi, const int i) {
} }
if (cd.box[i].boxType == TOGGLE2) { if (cd.box[i].boxType == TOGGLE2) {
g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF, _vm->_font->TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF,
_vm->_font->GetTagFontHandle(), TXT_CENTER, 0); _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
} else { } else {
g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF, _vm->_font->TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF,
_vm->_font->GetTagFontHandle(), TXT_RIGHT, 0); _vm->_font->GetTagFontHandle(), TXT_RIGHT, 0);
} }
@ -2921,7 +2921,7 @@ static void AddBox(int *pi, const int i) {
assert(cd.box[i].ixText != USE_POINTER); assert(cd.box[i].ixText != USE_POINTER);
LoadStringRes(g_configStrings[cd.box[i].ixText], _vm->_font->TextBufferAddr(), TBUFSZ); LoadStringRes(g_configStrings[cd.box[i].ixText], _vm->_font->TextBufferAddr(), TBUFSZ);
} }
g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), 0, x+MDTEXT_XOFF, y+MDTEXT_YOFF, _vm->_font->GetTagFontHandle(), TXT_RIGHT); _vm->_font->TextBufferAddr(), 0, x+MDTEXT_XOFF, y+MDTEXT_YOFF, _vm->_font->GetTagFontHandle(), TXT_RIGHT);
MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT); MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
*pi += 1; *pi += 1;
@ -2946,7 +2946,7 @@ static void AddBox(int *pi, const int i) {
// Stick in the text // Stick in the text
assert(cd.box[i].textMethod == TM_INDEX); assert(cd.box[i].textMethod == TM_INDEX);
LoadStringRes(SysString(cd.box[i].ixText), _vm->_font->TextBufferAddr(), TBUFSZ); LoadStringRes(SysString(cd.box[i].ixText), _vm->_font->TextBufferAddr(), TBUFSZ);
g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF, _vm->_font->TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF,
_vm->_font->GetTagFontHandle(), TXT_CENTER, 0); _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT); MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
@ -2958,7 +2958,7 @@ static void AddBox(int *pi, const int i) {
break; break;
LoadStringRes(LanguageDesc(g_displayedLanguage), _vm->_font->TextBufferAddr(), TBUFSZ); LoadStringRes(LanguageDesc(g_displayedLanguage), _vm->_font->TextBufferAddr(), TBUFSZ);
g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), 0, g_iconArray[*pi] = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), 0,
x + cd.box[i].w / 2, y + ROT_YOFF, _vm->_font->GetTagFontHandle(), TXT_CENTER, 0); x + cd.box[i].w / 2, y + ROT_YOFF, _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT); MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);
*pi += 1; *pi += 1;
@ -3131,7 +3131,7 @@ static void ConstructInventory(InventoryType filling) {
// Dispose of anything it may be replacing // Dispose of anything it may be replacing
for (int i = 0; i < MAX_WCOMP; i++) { for (int i = 0; i < MAX_WCOMP; i++) {
if (retObj[i] != NULL) { if (retObj[i] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), retObj[i]); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), retObj[i]);
retObj[i] = NULL; retObj[i] = NULL;
} }
} }
@ -3411,7 +3411,7 @@ static void AlterCursor(int num) {
pim = GetImageFromFilm(g_hWinParts, num, &pfreel); pim = GetImageFromFilm(g_hWinParts, num, &pfreel);
// Poke in the background palette // Poke in the background palette
pim->hImgPal = TO_32(BgPal()); pim->hImgPal = TO_32(_vm->_bg->BgPal());
SetTempCursor(FROM_32(pfreel->script)); SetTempCursor(FROM_32(pfreel->script));
} }
@ -3718,7 +3718,7 @@ extern void HideConversation(bool bHide) {
int Loffset, Toffset; int Loffset, Toffset;
GetActorMidTop(g_thisConvActor, &x, &y); GetActorMidTop(g_thisConvActor, &x, &y);
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
x -= Loffset; x -= Loffset;
y -= Toffset; y -= Toffset;
} else { } else {
@ -3773,7 +3773,7 @@ extern void HideConversation(bool bHide) {
&& g_thisConvActor) { && g_thisConvActor) {
int Loffset, Toffset; int Loffset, Toffset;
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
y = GetActorBottom(g_thisConvActor) - MultiHighest(g_RectObject) + y = GetActorBottom(g_thisConvActor) - MultiHighest(g_RectObject) +
SysVar(SV_CONV_BELOW_Y); SysVar(SV_CONV_BELOW_Y);
y -= Toffset; y -= Toffset;

View File

@ -417,7 +417,7 @@ void PlayerEvent(PLR_EVENT pEvent, const Common::Point &coOrds) {
if (TinselV2 && InventoryActive()) { if (TinselV2 && InventoryActive()) {
int x, y; int x, y;
PlayfieldGetPos(FIELD_WORLD, &x, &y); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &x, &y);
EventToInventory(pEvent, Common::Point(coOrds.x - x, coOrds.y - y)); EventToInventory(pEvent, Common::Point(coOrds.x - x, coOrds.y - y));
return; return;
} }

View File

@ -31,8 +31,6 @@ namespace Tinsel {
// Accessed using TextBufferAddr(), this is how big it is: // Accessed using TextBufferAddr(), this is how big it is:
#define TBUFSZ 512 #define TBUFSZ 512
class TinselEngine;
class Font { class Font {
public: public:
Font() : _hTagFont(0), _hTalkFont(0), _hRegularTalkFont(0), _hRegularTagFont(0), _tBuffer("") { Font() : _hTagFont(0), _hTalkFont(0), _hRegularTalkFont(0), _hRegularTagFont(0), _tBuffer("") {

View File

@ -133,7 +133,7 @@ static int ClickedOnPath(int clickX, int clickY, int *ptgtX, int *ptgtY) {
In a Blocking polygon - try searching down and up. In a Blocking polygon - try searching down and up.
If still nowhere (for now) give up! If still nowhere (for now) give up!
------------------------------------------------------*/ ------------------------------------------------------*/
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
for (i = clickY+1; i < SCREEN_HEIGHT + Toffset; i++) { for (i = clickY+1; i < SCREEN_HEIGHT + Toffset; i++) {
// Don't leave the path system // Don't leave the path system
@ -180,7 +180,7 @@ static int ClickedOnRefer(HPOLYGON hRefpoly, int clickX, int clickY, int *ptgtX,
int end; // Extreme of the scene int end; // Extreme of the scene
int Loffset, Toffset; int Loffset, Toffset;
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
*ptgtX = *ptgtY = -1; *ptgtX = *ptgtY = -1;
switch (PolySubtype(hRefpoly)) { switch (PolySubtype(hRefpoly)) {
@ -190,7 +190,7 @@ static int ClickedOnRefer(HPOLYGON hRefpoly, int clickX, int clickY, int *ptgtX,
break; break;
case REF_DOWN: // Search downwards case REF_DOWN: // Search downwards
end = BgHeight(); end = _vm->_bg->BgHeight();
for (i = clickY+1; i < end; i++) for (i = clickY+1; i < end; i++)
if (InPolygon(clickX, i, PATH) != NOPOLY if (InPolygon(clickX, i, PATH) != NOPOLY
&& InPolygon(clickX, i, BLOCK) == NOPOLY) { && InPolygon(clickX, i, BLOCK) == NOPOLY) {
@ -211,7 +211,7 @@ static int ClickedOnRefer(HPOLYGON hRefpoly, int clickX, int clickY, int *ptgtX,
break; break;
case REF_RIGHT: // Search to the right case REF_RIGHT: // Search to the right
end = BgWidth(); end = _vm->_bg->BgWidth();
for (i = clickX+1; i < end; i++) for (i = clickX+1; i < end; i++)
if (InPolygon(i, clickY, PATH) != NOPOLY if (InPolygon(i, clickY, PATH) != NOPOLY
&& InPolygon(i, clickY, BLOCK) == NOPOLY) { && InPolygon(i, clickY, BLOCK) == NOPOLY) {
@ -252,7 +252,7 @@ static int ClickedOnNothing(int clickX, int clickY, int *ptgtX, int *ptgtY) {
int end; // Extreme of the scene int end; // Extreme of the scene
int Loffset, Toffset; int Loffset, Toffset;
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
switch (g_DefaultRefer) { switch (g_DefaultRefer) {
case REF_DEFAULT: case REF_DEFAULT:
@ -266,7 +266,7 @@ static int ClickedOnNothing(int clickX, int clickY, int *ptgtX, int *ptgtY) {
return ClickedOnPath(clickX, i, ptgtX, ptgtY); return ClickedOnPath(clickX, i, ptgtX, ptgtY);
} }
// Try searching down and up (offscreen). // Try searching down and up (offscreen).
end = BgHeight(); end = _vm->_bg->BgHeight();
for (i = clickY+1; i < end; i++) for (i = clickY+1; i < end; i++)
if (InPolygon(clickX, i, PATH) != NOPOLY) { if (InPolygon(clickX, i, PATH) != NOPOLY) {
return ClickedOnPath(clickX, i, ptgtX, ptgtY); return ClickedOnPath(clickX, i, ptgtX, ptgtY);
@ -285,7 +285,7 @@ static int ClickedOnNothing(int clickX, int clickY, int *ptgtX, int *ptgtY) {
break; break;
case REF_DOWN: case REF_DOWN:
end = BgHeight(); end = _vm->_bg->BgHeight();
for (i = clickY+1; i < end; i++) for (i = clickY+1; i < end; i++)
if (InPolygon(clickX, i, PATH) != NOPOLY) { if (InPolygon(clickX, i, PATH) != NOPOLY) {
return ClickedOnPath(clickX, i, ptgtX, ptgtY); return ClickedOnPath(clickX, i, ptgtX, ptgtY);
@ -300,7 +300,7 @@ static int ClickedOnNothing(int clickX, int clickY, int *ptgtX, int *ptgtY) {
break; break;
case REF_RIGHT: case REF_RIGHT:
end = BgWidth(); end = _vm->_bg->BgWidth();
for (i = clickX + 1; i < end; i++) for (i = clickX + 1; i < end; i++)
if (InPolygon(i, clickY, PATH) != NOPOLY) { if (InPolygon(i, clickY, PATH) != NOPOLY) {
return ClickedOnPath(i, clickY, ptgtX, ptgtY); return ClickedOnPath(i, clickY, ptgtX, ptgtY);

View File

@ -147,16 +147,16 @@ void CursorPositionProcess(CORO_PARAM, const void *) {
Loffset != _ctx->prevsX || Toffset != _ctx->prevsY) { Loffset != _ctx->prevsX || Toffset != _ctx->prevsY) {
// kill current text objects // kill current text objects
if (_ctx->cpText) { if (_ctx->cpText) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->cpText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _ctx->cpText);
} }
if (_ctx->cpathText) { if (_ctx->cpathText) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->cpathText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _ctx->cpathText);
_ctx->cpathText = NULL; _ctx->cpathText = NULL;
} }
// New text objects // New text objects
sprintf(PositionString, "%d %d", aniX + Loffset, aniY + Toffset); sprintf(PositionString, "%d %d", aniX + Loffset, aniY + Toffset);
_ctx->cpText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), PositionString, _ctx->cpText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), PositionString,
0, CPOSX, POSY, GetTagFontHandle(), TXT_CENTER); 0, CPOSX, POSY, GetTagFontHandle(), TXT_CENTER);
if (g_DispPath) { if (g_DispPath) {
HPOLYGON hp = InPolygon(aniX + Loffset, aniY + Toffset, PATH); HPOLYGON hp = InPolygon(aniX + Loffset, aniY + Toffset, PATH);
@ -168,7 +168,7 @@ void CursorPositionProcess(CORO_PARAM, const void *) {
PolyCornerX(hp, 1), PolyCornerY(hp, 1), PolyCornerX(hp, 1), PolyCornerY(hp, 1),
PolyCornerX(hp, 2), PolyCornerY(hp, 2), PolyCornerX(hp, 2), PolyCornerY(hp, 2),
PolyCornerX(hp, 3), PolyCornerY(hp, 3)); PolyCornerX(hp, 3), PolyCornerY(hp, 3));
_ctx->cpathText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), PositionString, _ctx->cpathText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), PositionString,
0, 4, POSY+ 10, GetTagFontHandle(), 0); 0, 4, POSY+ 10, GetTagFontHandle(), 0);
} }
@ -184,11 +184,11 @@ void CursorPositionProcess(CORO_PARAM, const void *) {
if (Overrun != _ctx->prevOver) { if (Overrun != _ctx->prevOver) {
// kill current text objects // kill current text objects
if (_ctx->opText) { if (_ctx->opText) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->opText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _ctx->opText);
} }
sprintf(PositionString, "%d", Overrun); sprintf(PositionString, "%d", Overrun);
_ctx->opText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), PositionString, _ctx->opText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), PositionString,
0, OPOSX, POSY, GetTagFontHandle(), TXT_CENTER); 0, OPOSX, POSY, GetTagFontHandle(), TXT_CENTER);
// update previous value // update previous value
@ -209,12 +209,12 @@ void CursorPositionProcess(CORO_PARAM, const void *) {
Loffset != _ctx->prevsX || Toffset != _ctx->prevsY) { Loffset != _ctx->prevsX || Toffset != _ctx->prevsY) {
// Kill current text objects // Kill current text objects
if (_ctx->rpText) { if (_ctx->rpText) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->rpText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _ctx->rpText);
} }
// create new text object list // create new text object list
sprintf(PositionString, "%d %d", aniX, aniY); sprintf(PositionString, "%d %d", aniX, aniY);
_ctx->rpText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), PositionString, _ctx->rpText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), PositionString,
0, LPOSX, POSY, GetTagFontHandle(), TXT_CENTER); 0, LPOSX, POSY, GetTagFontHandle(), TXT_CENTER);
// update previous position // update previous position
@ -229,11 +229,11 @@ void CursorPositionProcess(CORO_PARAM, const void *) {
if (g_bShowString && g_newestString != _ctx->prevString) { if (g_bShowString && g_newestString != _ctx->prevString) {
// kill current text objects // kill current text objects
if (_ctx->spText) { if (_ctx->spText) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->spText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _ctx->spText);
} }
sprintf(PositionString, "String: %d", g_newestString); sprintf(PositionString, "String: %d", g_newestString);
_ctx->spText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), PositionString, _ctx->spText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), PositionString,
0, SPOSX, POSY+10, GetTalkFontHandle(), TXT_CENTER); 0, SPOSX, POSY+10, GetTalkFontHandle(), TXT_CENTER);
// update previous value // update previous value
@ -401,7 +401,7 @@ static bool ActorTag(int curX, int curY, HotSpotTag *pTag, OBJECT **ppText) {
SaveTaggedPoly(NOPOLY); // No tagged polygon SaveTaggedPoly(NOPOLY); // No tagged polygon
if (*ppText) if (*ppText)
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), *ppText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), *ppText);
if (ActorTagIsWanted(actor)) { if (ActorTagIsWanted(actor)) {
GetActorTagPos(actor, &tagX, &tagY, false); GetActorTagPos(actor, &tagX, &tagY, false);
@ -409,7 +409,7 @@ static bool ActorTag(int curX, int curY, HotSpotTag *pTag, OBJECT **ppText) {
// May have buggered cursor // May have buggered cursor
EndCursorFollowed(); EndCursorFollowed();
*ppText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), g_tagBuffer, *ppText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), g_tagBuffer,
0, tagX, tagY, _vm->_font->GetTagFontHandle(), TXT_CENTER, 0); 0, tagX, tagY, _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
assert(*ppText); assert(*ppText);
MultiSetZPosition(*ppText, Z_TAG_TEXT); MultiSetZPosition(*ppText, Z_TAG_TEXT);
@ -446,22 +446,22 @@ static bool ActorTag(int curX, int curY, HotSpotTag *pTag, OBJECT **ppText) {
// Display actor's tag // Display actor's tag
if (*ppText) if (*ppText)
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), *ppText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), *ppText);
*pTag = ACTOR_HOTSPOT_TAG; *pTag = ACTOR_HOTSPOT_TAG;
SaveTaggedActor(ano); // This actor tagged SaveTaggedActor(ano); // This actor tagged
SaveTaggedPoly(NOPOLY); // No tagged polygon SaveTaggedPoly(NOPOLY); // No tagged polygon
PlayfieldGetPos(FIELD_WORLD, &tagX, &tagY); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &tagX, &tagY);
LoadStringRes(GetActorTag(ano), _vm->_font->TextBufferAddr(), TBUFSZ); LoadStringRes(GetActorTag(ano), _vm->_font->TextBufferAddr(), TBUFSZ);
*ppText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), *ppText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(),
0, xtext - tagX, ytext - tagY, _vm->_font->GetTagFontHandle(), TXT_CENTER); 0, xtext - tagX, ytext - tagY, _vm->_font->GetTagFontHandle(), TXT_CENTER);
assert(*ppText); // Actor tag string produced NULL text assert(*ppText); // Actor tag string produced NULL text
MultiSetZPosition(*ppText, Z_TAG_TEXT); MultiSetZPosition(*ppText, Z_TAG_TEXT);
} else { } else {
// Maintain actor tag's position // Maintain actor tag's position
PlayfieldGetPos(FIELD_WORLD, &newX, &newY); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &newX, &newY);
if (newX != tagX || newY != tagY) { if (newX != tagX || newY != tagY) {
MultiMoveRelXY(*ppText, tagX - newX, tagY - newY); MultiMoveRelXY(*ppText, tagX - newX, tagY - newY);
tagX = newX; tagX = newX;
@ -511,7 +511,7 @@ static bool PolyTag(HotSpotTag *pTag, OBJECT **ppText) {
// This poly is entitled to be tagged // This poly is entitled to be tagged
if (hp != GetTaggedPoly()) { if (hp != GetTaggedPoly()) {
if (*ppText) { if (*ppText) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), *ppText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), *ppText);
*ppText = NULL; *ppText = NULL;
} }
*pTag = POLY_HOTSPOT_TAG; *pTag = POLY_HOTSPOT_TAG;
@ -535,14 +535,14 @@ static bool PolyTag(HotSpotTag *pTag, OBJECT **ppText) {
if (newPoly) { if (newPoly) {
if (*ppText) if (*ppText)
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), *ppText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), *ppText);
if (!TinselV2) if (!TinselV2)
*pTag = POLY_HOTSPOT_TAG; *pTag = POLY_HOTSPOT_TAG;
SaveTaggedActor(0); // No tagged actor SaveTaggedActor(0); // No tagged actor
SaveTaggedPoly(hp); // This polygon tagged SaveTaggedPoly(hp); // This polygon tagged
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
GetTagTag(hp, &hTagtext, &tagx, &tagy); GetTagTag(hp, &hTagtext, &tagx, &tagy);
int strLen; int strLen;
@ -558,7 +558,7 @@ static bool PolyTag(HotSpotTag *pTag, OBJECT **ppText) {
// May have buggered cursor // May have buggered cursor
EndCursorFollowed(); EndCursorFollowed();
*ppText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), *ppText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), 0, tagx - Loffset, tagy - Toffset, _vm->_font->TextBufferAddr(), 0, tagx - Loffset, tagy - Toffset,
_vm->_font->GetTagFontHandle(), TXT_CENTER, 0); _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
} else if (TinselV2) { } else if (TinselV2) {
@ -568,11 +568,11 @@ static bool PolyTag(HotSpotTag *pTag, OBJECT **ppText) {
StartCursorFollowed(); StartCursorFollowed();
GetCursorXYNoWait(&curX, &curY, false); GetCursorXYNoWait(&curX, &curY, false);
*ppText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), *ppText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(),
0, curX, curY, _vm->_font->GetTagFontHandle(), TXT_CENTER, 0); 0, curX, curY, _vm->_font->GetTagFontHandle(), TXT_CENTER, 0);
} else { } else {
// Handle displaying the tag text on-screen // Handle displaying the tag text on-screen
*ppText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), *ppText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(),
0, tagx - Loffset, tagy - Toffset, 0, tagx - Loffset, tagy - Toffset,
_vm->_font->GetTagFontHandle(), TXT_CENTER); _vm->_font->GetTagFontHandle(), TXT_CENTER);
assert(*ppText); // Polygon tag string produced NULL text assert(*ppText); // Polygon tag string produced NULL text
@ -586,18 +586,18 @@ static bool PolyTag(HotSpotTag *pTag, OBJECT **ppText) {
* New feature: Don't go off the side of the background * New feature: Don't go off the side of the background
*/ */
shift = MultiRightmost(*ppText) + Loffset + 2; shift = MultiRightmost(*ppText) + Loffset + 2;
if (shift >= BgWidth()) // Not off right if (shift >= _vm->_bg->BgWidth()) // Not off right
MultiMoveRelXY(*ppText, BgWidth() - shift, 0); MultiMoveRelXY(*ppText, _vm->_bg->BgWidth() - shift, 0);
shift = MultiLeftmost(*ppText) + Loffset - 1; shift = MultiLeftmost(*ppText) + Loffset - 1;
if (shift <= 0) // Not off left if (shift <= 0) // Not off left
MultiMoveRelXY(*ppText, -shift, 0); MultiMoveRelXY(*ppText, -shift, 0);
shift = MultiLowest(*ppText) + Toffset; shift = MultiLowest(*ppText) + Toffset;
if (shift > BgHeight()) // Not off bottom if (shift > _vm->_bg->BgHeight()) // Not off bottom
MultiMoveRelXY(*ppText, 0, BgHeight() - shift); MultiMoveRelXY(*ppText, 0, _vm->_bg->BgHeight() - shift);
} }
} else if (TinselV2 && (*ppText)) { } else if (TinselV2 && (*ppText)) {
if (!PolyTagFollowsCursor(hp)) { if (!PolyTagFollowsCursor(hp)) {
PlayfieldGetPos(FIELD_WORLD, &nLoff, &nToff); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &nLoff, &nToff);
if (nLoff != Loffset || nToff != Toffset) { if (nLoff != Loffset || nToff != Toffset) {
MultiMoveRelXY(*ppText, Loffset - nLoff, Toffset - nToff); MultiMoveRelXY(*ppText, Loffset - nLoff, Toffset - nToff);
Loffset = nLoff; Loffset = nLoff;
@ -612,7 +612,7 @@ static bool PolyTag(HotSpotTag *pTag, OBJECT **ppText) {
} }
} }
} else if (!TinselV2) { } else if (!TinselV2) {
PlayfieldGetPos(FIELD_WORLD, &nLoff, &nToff); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &nLoff, &nToff);
if (nLoff != Loffset || nToff != Toffset) { if (nLoff != Loffset || nToff != Toffset) {
MultiMoveRelXY(*ppText, Loffset - nLoff, Toffset - nToff); MultiMoveRelXY(*ppText, Loffset - nLoff, Toffset - nToff);
Loffset = nLoff; Loffset = nLoff;
@ -662,7 +662,7 @@ void TagProcess(CORO_PARAM, const void *) {
&& !PolyTag(&_ctx->Tag, &_ctx->pText)) { && !PolyTag(&_ctx->Tag, &_ctx->pText)) {
// Nothing tagged. Remove tag, if there is one // Nothing tagged. Remove tag, if there is one
if (_ctx->pText) { if (_ctx->pText) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->pText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _ctx->pText);
_ctx->pText = NULL; _ctx->pText = NULL;
if (TinselV2) if (TinselV2)
@ -677,7 +677,7 @@ void TagProcess(CORO_PARAM, const void *) {
// Remove tag, if there is one // Remove tag, if there is one
if (_ctx->pText) { if (_ctx->pText) {
// kill current text objects // kill current text objects
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->pText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _ctx->pText);
_ctx->pText = NULL; _ctx->pText = NULL;
_ctx->Tag = NO_HOTSPOT_TAG; _ctx->Tag = NO_HOTSPOT_TAG;
} }

View File

@ -83,7 +83,7 @@ static void PokeInPalette(SCNHANDLE hMulFrame) {
// get pointer to image // get pointer to image
pim = (IMAGE *)LockMem(READ_32(pFrame)); // handle to image pim = (IMAGE *)LockMem(READ_32(pFrame)); // handle to image
pim->hImgPal = TO_32(BgPal()); pim->hImgPal = TO_32(_vm->_bg->BgPal());
} }
} }
@ -101,7 +101,7 @@ void PokeInPalette(const MULTI_INIT *pmi) {
// get pointer to image // get pointer to image
pim = (IMAGE *)LockMem(READ_32(pFrame)); // handle to image pim = (IMAGE *)LockMem(READ_32(pFrame)); // handle to image
pim->hImgPal = TO_32(BgPal()); pim->hImgPal = TO_32(_vm->_bg->BgPal());
} }
} }
@ -496,9 +496,9 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) {
// Set up and insert the multi-object // Set up and insert the multi-object
_ctx->pPlayObj = MultiInitObject(pmi); _ctx->pPlayObj = MultiInitObject(pmi);
if (!ppi->bTop) if (!ppi->bTop)
MultiInsertObject(GetPlayfieldList(FIELD_WORLD), _ctx->pPlayObj); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_WORLD), _ctx->pPlayObj);
else else
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), _ctx->pPlayObj); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _ctx->pPlayObj);
// If co-ordinates are specified, use specified. // If co-ordinates are specified, use specified.
// Otherwise, use actor's position if there are not embedded co-ords. // Otherwise, use actor's position if there are not embedded co-ords.
@ -640,9 +640,9 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) {
// Ditch the object // Ditch the object
if (!ppi->bTop) if (!ppi->bTop)
MultiDeleteObject(GetPlayfieldList(FIELD_WORLD), _ctx->pPlayObj); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_WORLD), _ctx->pPlayObj);
else else
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->pPlayObj); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _ctx->pPlayObj);
if (_ctx->mActor) { if (_ctx->mActor) {
if (!_ctx->replaced) if (!_ctx->replaced)
@ -769,9 +769,9 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA
// Set up and insert the multi-object // Set up and insert the multi-object
_ctx->pPlayObj = MultiInitObject(_ctx->pmi); _ctx->pPlayObj = MultiInitObject(_ctx->pmi);
if (!bTop) if (!bTop)
MultiInsertObject(GetPlayfieldList(FIELD_WORLD), _ctx->pPlayObj); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_WORLD), _ctx->pPlayObj);
else else
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), _ctx->pPlayObj); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _ctx->pPlayObj);
/* /*
* More action for moving actors * More action for moving actors
@ -917,9 +917,9 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA
// Ditch the object // Ditch the object
if (!bTop) if (!bTop)
MultiDeleteObject(GetPlayfieldList(FIELD_WORLD), _ctx->pPlayObj); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_WORLD), _ctx->pPlayObj);
else else
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->pPlayObj); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _ctx->pPlayObj);
// Restore moving actor is nessesary // Restore moving actor is nessesary
if (_ctx->pMover != NULL && _ctx->bPrinciple && !_ctx->bReplaced) if (_ctx->pMover != NULL && _ctx->bPrinciple && !_ctx->bReplaced)

View File

@ -85,7 +85,7 @@ static void CheckBrightness(PMOVER pMover) {
else else
pMover->brightness--; // ramp down pMover->brightness--; // ramp down
DimPartPalette(BgPal(), DimPartPalette(_vm->_bg->BgPal(),
pMover->startColor, pMover->startColor,
pMover->paletteLength, pMover->paletteLength,
pMover->brightness); pMover->brightness);
@ -102,10 +102,10 @@ void MoverBrightness(PMOVER pMover, int brightness) {
// if BgPal is NULL, and has been changed for ScummVM to a simple assert // if BgPal is NULL, and has been changed for ScummVM to a simple assert
// This is changed from a ProcessGiveWay in DW2 to an assert in ScummVM // This is changed from a ProcessGiveWay in DW2 to an assert in ScummVM
assert(BgPal()); assert(_vm->_bg->BgPal());
// Do it all immediately // Do it all immediately
DimPartPalette(BgPal(), pMover->startColor, pMover->paletteLength, brightness); DimPartPalette(_vm->_bg->BgPal(), pMover->startColor, pMover->paletteLength, brightness);
// The actor is probably hidden at this point, // The actor is probably hidden at this point,
pMover->brightness = brightness; pMover->brightness = brightness;
@ -200,7 +200,7 @@ void SetMoverInEffect(int index, bool tf) {
void KillMover(PMOVER pMover) { void KillMover(PMOVER pMover) {
if (pMover->bActive) { if (pMover->bActive) {
pMover->bActive = false; pMover->bActive = false;
MultiDeleteObject(GetPlayfieldList(FIELD_WORLD), pMover->actorObj); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_WORLD), pMover->actorObj);
pMover->actorObj = NULL; pMover->actorObj = NULL;
assert(CoroScheduler.getCurrentProcess() != pMover->pProc); assert(CoroScheduler.getCurrentProcess() != pMover->pProc);
CoroScheduler.killProcess(pMover->pProc); CoroScheduler.killProcess(pMover->pProc);
@ -697,7 +697,7 @@ static void MoverProcessHelper(int X, int Y, int id, PMOVER pMover) {
IMAGE *pim; IMAGE *pim;
assert(BgPal()); // Can't start actor without a background palette assert(_vm->_bg->BgPal()); // Can't start actor without a background palette
assert(pMover->walkReels[0][FORWARD]); // Starting actor process without walk reels assert(pMover->walkReels[0][FORWARD]); // Starting actor process without walk reels
InitMover(pMover); InitMover(pMover);
@ -711,7 +711,7 @@ static void MoverProcessHelper(int X, int Y, int id, PMOVER pMover) {
// get pointer to image // get pointer to image
pim = (IMAGE *)LockMem(READ_32(pFrame)); // handle to image pim = (IMAGE *)LockMem(READ_32(pFrame)); // handle to image
pim->hImgPal = TO_32(BgPal()); pim->hImgPal = TO_32(_vm->_bg->BgPal());
//--- //---
pMover->actorObj = MultiInitObject(pmi); pMover->actorObj = MultiInitObject(pmi);
@ -719,7 +719,7 @@ static void MoverProcessHelper(int X, int Y, int id, PMOVER pMover) {
pMover->actorID = id; pMover->actorID = id;
// add it to display list // add it to display list
MultiInsertObject(GetPlayfieldList(FIELD_WORLD), pMover->actorObj); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_WORLD), pMover->actorObj);
storeActorReel(id, NULL, 0, pMover->actorObj, 0, 0, 0); storeActorReel(id, NULL, 0, pMover->actorObj, 0, 0, 0);
InitStepAnimScript(&pMover->actorAnim, pMover->actorObj, FROM_32(pfilm->reels[0].script), ONE_SECOND / FROM_32(pfilm->frate)); InitStepAnimScript(&pMover->actorAnim, pMover->actorObj, FROM_32(pfilm->reels[0].script), ONE_SECOND / FROM_32(pfilm->frate));
@ -813,7 +813,7 @@ void T2MoverProcess(CORO_PARAM, const void *param) {
pMover->bActive = true; pMover->bActive = true;
// add it to display list // add it to display list
MultiInsertObject( GetPlayfieldList(FIELD_WORLD), pMover->actorObj ); MultiInsertObject(_vm->_bg->GetPlayfieldList(FIELD_WORLD), pMover->actorObj);
InitStepAnimScript(&pMover->actorAnim, pMover->actorObj, pFilm->reels[0].script, ONE_SECOND/pFilm->frate); InitStepAnimScript(&pMover->actorAnim, pMover->actorObj, pFilm->reels[0].script, ONE_SECOND/pFilm->frate);
pMover->stepCount = 0; pMover->stepCount = 0;

View File

@ -51,10 +51,6 @@ namespace Tinsel {
//----------------- EXTERN FUNCTIONS -------------------- //----------------- EXTERN FUNCTIONS --------------------
// in BG.C
extern SCNHANDLE GetBgroundHandle();
extern void SetDoFadeIn(bool tf);
// In DOS_DW.C // In DOS_DW.C
void RestoreMasterProcess(INT_CONTEXT *pic); void RestoreMasterProcess(INT_CONTEXT *pic);
@ -107,10 +103,10 @@ static bool g_bNoFade = false;
*/ */
void DoSaveScene(SAVED_DATA *sd) { void DoSaveScene(SAVED_DATA *sd) {
sd->SavedSceneHandle = GetSceneHandle(); sd->SavedSceneHandle = GetSceneHandle();
sd->SavedBgroundHandle = GetBgroundHandle(); sd->SavedBgroundHandle = _vm->_bg->GetBgroundHandle();
SaveMovers(sd->SavedMoverInfo); SaveMovers(sd->SavedMoverInfo);
sd->NumSavedActors = SaveActors(sd->SavedActorInfo); sd->NumSavedActors = SaveActors(sd->SavedActorInfo);
PlayfieldGetPos(FIELD_WORLD, &sd->SavedLoffset, &sd->SavedToffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &sd->SavedLoffset, &sd->SavedToffset);
SaveInterpretContexts(sd->SavedICInfo); SaveInterpretContexts(sd->SavedICInfo);
sd->SavedControl = ControlIsOn(); sd->SavedControl = ControlIsOn();
sd->SavedNoBlocking = GetNoBlocking(); sd->SavedNoBlocking = GetNoBlocking();
@ -338,15 +334,15 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {
// Start up the scene // Start up the scene
StartNewScene(sd->SavedSceneHandle, NO_ENTRY_NUM); StartNewScene(sd->SavedSceneHandle, NO_ENTRY_NUM);
SetDoFadeIn(!g_bNoFade); _vm->_bg->SetDoFadeIn(!g_bNoFade);
g_bNoFade = false; g_bNoFade = false;
StartupBackground(Common::nullContext, sd->SavedBgroundHandle); _vm->_bg->StartupBackground(Common::nullContext, sd->SavedBgroundHandle);
if (TinselV2) { if (TinselV2) {
Offset(EX_USEXY, sd->SavedLoffset, sd->SavedToffset); Offset(EX_USEXY, sd->SavedLoffset, sd->SavedToffset);
} else { } else {
KillScroll(); KillScroll();
PlayfieldSetPos(FIELD_WORLD, sd->SavedLoffset, sd->SavedToffset); _vm->_bg->PlayfieldSetPos(FIELD_WORLD, sd->SavedLoffset, sd->SavedToffset);
SetNoBlocking(sd->SavedNoBlocking); SetNoBlocking(sd->SavedNoBlocking);
} }

View File

@ -54,9 +54,6 @@ namespace Tinsel {
//----------------- EXTERNAL FUNCTIONS --------------------- //----------------- EXTERNAL FUNCTIONS ---------------------
// in BG.C
extern void DropBackground();
// in EFFECT.C // in EFFECT.C
extern void EffectPolyProcess(CORO_PARAM, const void *); extern void EffectPolyProcess(CORO_PARAM, const void *);
@ -317,7 +314,7 @@ void EndScene() {
DropPolygons(); // No polygons DropPolygons(); // No polygons
DropScroll(); // No no-scrolls DropScroll(); // No no-scrolls
DropBackground(); // No background _vm->_bg->DropBackground(); // No background
DropMovers(); // No moving actors DropMovers(); // No moving actors
DropCursor(); // No cursor DropCursor(); // No cursor
DropActors(); // No actor reels running DropActors(); // No actor reels running
@ -372,7 +369,7 @@ void PrimeScene() {
CoroScheduler.createProcess(PID_TAG, PointProcess, NULL, 0); CoroScheduler.createProcess(PID_TAG, PointProcess, NULL, 0);
// init the current background // init the current background
InitBackground(); _vm->_bg->InitBackground();
} }
/** /**

View File

@ -136,7 +136,7 @@ static void NeedScroll(int direction) {
int Loffset, Toffset; int Loffset, Toffset;
// get background offsets // get background offsets
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
switch (direction) { switch (direction) {
case LEFT: /* Picture will go left, 'camera' right */ case LEFT: /* Picture will go left, 'camera' right */
@ -247,7 +247,7 @@ static void ScrollImage() {
int curX, curY; int curX, curY;
// get background offsets // get background offsets
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
/* /*
* Keeping cursor on a tag? * Keeping cursor on a tag?
@ -333,7 +333,7 @@ static void ScrollImage() {
if (g_ScrollCursor) if (g_ScrollCursor)
AdjustCursorXY(OldLoffset - Loffset, OldToffset - Toffset); AdjustCursorXY(OldLoffset - Loffset, OldToffset - Toffset);
PlayfieldSetPos(FIELD_WORLD, Loffset, Toffset); _vm->_bg->PlayfieldSetPos(FIELD_WORLD, Loffset, Toffset);
} }
@ -356,7 +356,7 @@ static void MonitorScroll() {
if (g_oldx == newx && g_oldy == newy) if (g_oldx == newx && g_oldy == newy)
return; return;
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
/* /*
* Approaching right side or left side of the screen? * Approaching right side or left side of the screen?
@ -420,11 +420,11 @@ void ScrollProcess(CORO_PARAM, const void *) {
// In Tinsel v2, scenes may play movies, so the background may not always // In Tinsel v2, scenes may play movies, so the background may not always
// already be initialized like it is in v1 // already be initialized like it is in v1
while (!GetBgObject()) while (!_vm->_bg->GetBgObject())
CORO_SLEEP(1); CORO_SLEEP(1);
g_ImageH = BgHeight(); // Dimensions g_ImageH = _vm->_bg->BgHeight(); // Dimensions
g_ImageW = BgWidth(); // of this scene. g_ImageW = _vm->_bg->BgWidth(); // of this scene.
// Give up if there'll be no purpose in this process // Give up if there'll be no purpose in this process
if (g_ImageW == SCREEN_WIDTH && g_ImageH == SCREEN_HEIGHT) if (g_ImageW == SCREEN_WIDTH && g_ImageH == SCREEN_HEIGHT)
@ -482,7 +482,7 @@ void ScrollTo(int x, int y, int xIter, int yIter) {
g_scrollPixelsX = xIter != 0 ? xIter : (TinselV2 ? g_sd.xSpeed : SCROLLPIXELS); g_scrollPixelsX = xIter != 0 ? xIter : (TinselV2 ? g_sd.xSpeed : SCROLLPIXELS);
g_scrollPixelsY = yIter != 0 ? yIter : (TinselV2 ? g_sd.ySpeed : SCROLLPIXELS); g_scrollPixelsY = yIter != 0 ? yIter : (TinselV2 ? g_sd.ySpeed : SCROLLPIXELS);
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); // get background offsets _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); // get background offsets
g_LeftScroll = x - Loffset; g_LeftScroll = x - Loffset;
g_DownScroll = y - Toffset; g_DownScroll = y - Toffset;

View File

@ -373,7 +373,7 @@ bool SoundManager::offscreenChecks(int x, int &y) {
return true; return true;
// convert x to offset from screen center // convert x to offset from screen center
x -= PlayfieldGetCenterX(FIELD_WORLD); x -= _vm->_bg->PlayfieldGetCenterX(FIELD_WORLD);
if (x < -SCREEN_WIDTH || x > SCREEN_WIDTH) { if (x < -SCREEN_WIDTH || x > SCREEN_WIDTH) {
// A long way offscreen, ignore it // A long way offscreen, ignore it
@ -392,7 +392,7 @@ int8 SoundManager::getPan(int x) {
if (x == -1) if (x == -1)
return 0; return 0;
x -= PlayfieldGetCenterX(FIELD_WORLD); x -= _vm->_bg->PlayfieldGetCenterX(FIELD_WORLD);
if (x == 0) if (x == 0)
return 0; return 0;

View File

@ -86,9 +86,6 @@ extern bool g_bNoPause;
//----------------- EXTERNAL FUNCTIONS --------------------- //----------------- EXTERNAL FUNCTIONS ---------------------
// in BG.CPP
extern void ChangePalette(SCNHANDLE hPal);
// in PDISPLAY.CPP // in PDISPLAY.CPP
extern void EnableTags(); extern void EnableTags();
extern void DisableTags(); extern void DisableTags();
@ -329,27 +326,27 @@ void Walk(CORO_PARAM, int actor, int x, int y, SCNHANDLE film, int hold, bool ig
static void DecodeExtreme(EXTREME extreme, int *px, int *py) { static void DecodeExtreme(EXTREME extreme, int *px, int *py) {
int Loffset, Toffset; int Loffset, Toffset;
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
switch (extreme) { switch (extreme) {
case EX_BOTTOM: case EX_BOTTOM:
*px = Loffset; *px = Loffset;
*py = BgHeight() - SCREEN_HEIGHT; *py = _vm->_bg->BgHeight() - SCREEN_HEIGHT;
break; break;
case EX_BOTTOMLEFT: case EX_BOTTOMLEFT:
*px = 0; *px = 0;
*py = BgHeight() - SCREEN_HEIGHT; *py = _vm->_bg->BgHeight() - SCREEN_HEIGHT;
break; break;
case EX_BOTTOMRIGHT: case EX_BOTTOMRIGHT:
*px = BgWidth() - SCREEN_WIDTH; *px = _vm->_bg->BgWidth() - SCREEN_WIDTH;
*py = BgHeight() - SCREEN_HEIGHT; *py = _vm->_bg->BgHeight() - SCREEN_HEIGHT;
break; break;
case EX_LEFT: case EX_LEFT:
*px = 0; *px = 0;
*py = Toffset; *py = Toffset;
break; break;
case EX_RIGHT: case EX_RIGHT:
*px = BgWidth() - SCREEN_WIDTH; *px = _vm->_bg->BgWidth() - SCREEN_WIDTH;
*py = Toffset; *py = Toffset;
break; break;
case EX_TOP: case EX_TOP:
@ -360,7 +357,7 @@ static void DecodeExtreme(EXTREME extreme, int *px, int *py) {
*px = *py = 0; *px = *py = 0;
break; break;
case EX_TOPRIGHT: case EX_TOPRIGHT:
*px = BgWidth() - SCREEN_WIDTH; *px = _vm->_bg->BgWidth() - SCREEN_WIDTH;
*py = 0; *py = 0;
break; break;
default: default:
@ -414,7 +411,7 @@ static void ScrollMonitorProcess(CORO_PARAM, const void *param) {
break; break;
} }
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
} while (Loffset != psm->x || Toffset != psm->y); } while (Loffset != psm->x || Toffset != psm->y);
@ -639,7 +636,7 @@ static void AuxScale(int actor, int scale, SCNHANDLE *rp) {
* Defines the background image for a scene. * Defines the background image for a scene.
*/ */
static void Background(CORO_PARAM, SCNHANDLE bfilm) { static void Background(CORO_PARAM, SCNHANDLE bfilm) {
StartupBackground(coroParam, bfilm); _vm->_bg->StartupBackground(coroParam, bfilm);
} }
/** /**
@ -1378,7 +1375,7 @@ static void KillProcess(uint32 procID) {
static int LToffset(int lort) { static int LToffset(int lort) {
int Loffset, Toffset; int Loffset, Toffset;
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
return (lort == SCREENXPOS) ? Loffset : Toffset; return (lort == SCREENXPOS) ? Loffset : Toffset;
} }
@ -1472,7 +1469,7 @@ void Offset(EXTREME extreme, int x, int y) {
if (TinselV2) if (TinselV2)
DecodeExtreme(extreme, &x, &y); DecodeExtreme(extreme, &x, &y);
PlayfieldSetPos(FIELD_WORLD, x, y); _vm->_bg->PlayfieldSetPos(FIELD_WORLD, x, y);
} }
/** /**
@ -1907,8 +1904,8 @@ static void Print(CORO_PARAM, int x, int y, SCNHANDLE text, int time, bool bSust
// Print the text // Print the text
if (TinselV2) { if (TinselV2) {
int Loffset, Toffset; int Loffset, Toffset;
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
_ctx->pText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), _ctx->pText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), 0, x - Loffset, y - Toffset, _vm->_font->GetTagFontHandle(), _vm->_font->TextBufferAddr(), 0, x - Loffset, y - Toffset, _vm->_font->GetTagFontHandle(),
TXT_CENTER, 0); TXT_CENTER, 0);
assert(_ctx->pText); assert(_ctx->pText);
@ -1920,8 +1917,8 @@ static void Print(CORO_PARAM, int x, int y, SCNHANDLE text, int time, bool bSust
} else if (bJapDoPrintText || (!isJapanMode() && (_vm->_config->_useSubtitles || !_ctx->bSample))) { } else if (bJapDoPrintText || (!isJapanMode() && (_vm->_config->_useSubtitles || !_ctx->bSample))) {
int Loffset, Toffset; // Screen position int Loffset, Toffset; // Screen position
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
_ctx->pText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), _ctx->pText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(),
0, x - Loffset, y - Toffset, 0, x - Loffset, y - Toffset,
TinselV2 ? _vm->_font->GetTagFontHandle() : _vm->_font->GetTalkFontHandle(), TXT_CENTER); TinselV2 ? _vm->_font->GetTagFontHandle() : _vm->_font->GetTalkFontHandle(), TXT_CENTER);
assert(_ctx->pText); // string produced NULL text assert(_ctx->pText); // string produced NULL text
@ -1933,14 +1930,14 @@ static void Print(CORO_PARAM, int x, int y, SCNHANDLE text, int time, bool bSust
*/ */
int shift; int shift;
shift = MultiRightmost(_ctx->pText) + 2; shift = MultiRightmost(_ctx->pText) + 2;
if (shift >= BgWidth()) // Not off right if (shift >= _vm->_bg->BgWidth()) // Not off right
MultiMoveRelXY(_ctx->pText, BgWidth() - shift, 0); MultiMoveRelXY(_ctx->pText, _vm->_bg->BgWidth() - shift, 0);
shift = MultiLeftmost(_ctx->pText) - 1; shift = MultiLeftmost(_ctx->pText) - 1;
if (shift <= 0) // Not off left if (shift <= 0) // Not off left
MultiMoveRelXY(_ctx->pText, -shift, 0); MultiMoveRelXY(_ctx->pText, -shift, 0);
shift = MultiLowest(_ctx->pText); shift = MultiLowest(_ctx->pText);
if (shift > BgHeight()) // Not off bottom if (shift > _vm->_bg->BgHeight()) // Not off bottom
MultiMoveRelXY(_ctx->pText, 0, BgHeight() - shift); MultiMoveRelXY(_ctx->pText, 0, _vm->_bg->BgHeight() - shift);
} }
// Give up if nothing printed and no sample // Give up if nothing printed and no sample
@ -1995,7 +1992,7 @@ static void Print(CORO_PARAM, int x, int y, SCNHANDLE text, int time, bool bSust
// Delete the text // Delete the text
if (_ctx->pText != NULL) if (_ctx->pText != NULL)
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->pText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _ctx->pText);
_vm->_mixer->stopHandle(_ctx->handle); _vm->_mixer->stopHandle(_ctx->handle);
CORO_END_CODE; CORO_END_CODE;
@ -2086,7 +2083,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
else else
LoadStringRes(hText, _vm->_font->TextBufferAddr(), TBUFSZ); LoadStringRes(hText, _vm->_font->TextBufferAddr(), TBUFSZ);
_ctx->pText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), _ctx->pText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(),
0, _ctx->textx, _ctx->texty, _vm->_font->GetTagFontHandle(), TXT_CENTER); 0, _ctx->textx, _ctx->texty, _vm->_font->GetTagFontHandle(), TXT_CENTER);
assert(_ctx->pText); // PrintObj() string produced NULL text assert(_ctx->pText); // PrintObj() string produced NULL text
@ -2126,7 +2123,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
// Give way to non-POINTED-generated text // Give way to non-POINTED-generated text
if (g_bNotPointedRunning) { if (g_bNotPointedRunning) {
// Delete the text, and wait for the all-clear // Delete the text, and wait for the all-clear
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->pText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _ctx->pText);
_ctx->pText = NULL; _ctx->pText = NULL;
while (g_bNotPointedRunning) while (g_bNotPointedRunning)
@ -2138,7 +2135,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
// Re-display in the same place // Re-display in the same place
LoadStringRes(hText, _vm->_font->TextBufferAddr(), TBUFSZ); LoadStringRes(hText, _vm->_font->TextBufferAddr(), TBUFSZ);
_ctx->pText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), _ctx->pText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), 0, _ctx->textx, _ctx->texty, _vm->_font->GetTagFontHandle(), _vm->_font->TextBufferAddr(), 0, _ctx->textx, _ctx->texty, _vm->_font->GetTagFontHandle(),
TXT_CENTER, 0); TXT_CENTER, 0);
assert(_ctx->pText); assert(_ctx->pText);
@ -2214,7 +2211,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
// Delete the text, if haven't already // Delete the text, if haven't already
if (_ctx->pText) if (_ctx->pText)
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->pText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _ctx->pText);
// If it hasn't already finished, stop sample // If it hasn't already finished, stop sample
if (_ctx->bSample) if (_ctx->bSample)
@ -2244,7 +2241,7 @@ static void PrintObjPointed(CORO_PARAM, const SCNHANDLE text, const INV_OBJECT *
// Give way to non-POINTED-generated text // Give way to non-POINTED-generated text
if (g_bNotPointedRunning) { if (g_bNotPointedRunning) {
// Delete the text, and wait for the all-clear // Delete the text, and wait for the all-clear
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), pText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), pText);
pText = NULL; pText = NULL;
while (g_bNotPointedRunning) while (g_bNotPointedRunning)
CORO_SLEEP(1); CORO_SLEEP(1);
@ -2255,7 +2252,7 @@ static void PrintObjPointed(CORO_PARAM, const SCNHANDLE text, const INV_OBJECT *
// Re-display in the same place // Re-display in the same place
LoadStringRes(text, _vm->_font->TextBufferAddr(), TBUFSZ); LoadStringRes(text, _vm->_font->TextBufferAddr(), TBUFSZ);
pText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(), pText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _vm->_font->TextBufferAddr(),
0, textx, texty, _vm->_font->GetTagFontHandle(), TXT_CENTER); 0, textx, texty, _vm->_font->GetTagFontHandle(), TXT_CENTER);
assert(pText); // PrintObj() string produced NULL text assert(pText); // PrintObj() string produced NULL text
MultiSetZPosition(pText, Z_INV_ITEXT); MultiSetZPosition(pText, Z_INV_ITEXT);
@ -2545,7 +2542,7 @@ static void Scroll(CORO_PARAM, EXTREME extreme, int xp, int yp, int xIter, int y
if (_ctx->thisScroll != g_scrollNumber) if (_ctx->thisScroll != g_scrollNumber)
CORO_KILL_SELF(); CORO_KILL_SELF();
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
} while (Loffset != _ctx->x || Toffset != _ctx->y); } while (Loffset != _ctx->x || Toffset != _ctx->y);
} else if (TinselV2 && myEscape) { } else if (TinselV2 && myEscape) {
SCROLL_MONITOR sm; SCROLL_MONITOR sm;
@ -2684,7 +2681,7 @@ static void SetPalette(SCNHANDLE hPal, bool escOn, int myEscape) {
if (escOn && myEscape != GetEscEvents()) if (escOn && myEscape != GetEscEvents())
return; return;
ChangePalette(hPal); _vm->_bg->ChangePalette(hPal);
} }
/** /**
@ -3310,7 +3307,7 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
*/ */
int xshift, yshift; int xshift, yshift;
PlayfieldGetPos(FIELD_WORLD, &_ctx->Loffset, &_ctx->Toffset); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &_ctx->Loffset, &_ctx->Toffset);
if ((_ctx->whatSort == IS_SAY) || (_ctx->whatSort == IS_TALK)) if ((_ctx->whatSort == IS_SAY) || (_ctx->whatSort == IS_TALK))
GetActorMidTop(_ctx->actor, &_ctx->x, &_ctx->y); GetActorMidTop(_ctx->actor, &_ctx->x, &_ctx->y);
@ -3324,7 +3321,7 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
_ctx->y -= _ctx->Toffset; _ctx->y -= _ctx->Toffset;
} }
_ctx->pText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), _ctx->pText = ObjectTextOut(_vm->_bg->GetPlayfieldList(FIELD_STATUS),
_vm->_font->TextBufferAddr(), 0, _ctx->x - _ctx->Loffset, _ctx->y - _ctx->Toffset, _vm->_font->TextBufferAddr(), 0, _ctx->x - _ctx->Loffset, _ctx->y - _ctx->Toffset,
_vm->_font->GetTalkFontHandle(), TXT_CENTER); _vm->_font->GetTalkFontHandle(), TXT_CENTER);
assert(_ctx->pText); // talk() string produced NULL text; assert(_ctx->pText); // talk() string produced NULL text;
@ -3387,7 +3384,7 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
if (_ctx->pText != NULL) { if (_ctx->pText != NULL) {
int nLoff, nToff; int nLoff, nToff;
PlayfieldGetPos(FIELD_WORLD, &nLoff, &nToff); _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &nLoff, &nToff);
if (nLoff != _ctx->Loffset || nToff != _ctx->Toffset) { if (nLoff != _ctx->Loffset || nToff != _ctx->Toffset) {
MultiMoveRelXY(_ctx->pText, _ctx->Loffset - nLoff, _ctx->Toffset - nToff); MultiMoveRelXY(_ctx->pText, _ctx->Loffset - nLoff, _ctx->Toffset - nToff);
_ctx->Loffset = nLoff; _ctx->Loffset = nLoff;
@ -3445,7 +3442,7 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
} while (1); } while (1);
if (_ctx->pText != NULL) { if (_ctx->pText != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->pText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _ctx->pText);
_ctx->pText = NULL; _ctx->pText = NULL;
} }
if (TinselV2 && _ctx->bSample) if (TinselV2 && _ctx->bSample)
@ -3460,7 +3457,7 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
if (_ctx->bTalkReel) if (_ctx->bTalkReel)
CORO_INVOKE_2(FinishTalkingReel, _ctx->pActor, _ctx->actor); CORO_INVOKE_2(FinishTalkingReel, _ctx->pActor, _ctx->actor);
if (_ctx->pText != NULL) if (_ctx->pText != NULL)
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->pText); MultiDeleteObject(_vm->_bg->GetPlayfieldList(FIELD_STATUS), _ctx->pText);
if (TinselV2) { if (TinselV2) {
if ((_ctx->whatSort == IS_SAY) || (_ctx->whatSort == IS_SAYAT)) { if ((_ctx->whatSort == IS_SAY) || (_ctx->whatSort == IS_SAYAT)) {

View File

@ -64,11 +64,6 @@ namespace Tinsel {
//----------------- EXTERNAL FUNCTIONS --------------------- //----------------- EXTERNAL FUNCTIONS ---------------------
// In BG.CPP
extern void SetDoFadeIn(bool tf);
extern void DropBackground();
extern const BACKGND *g_pCurBgnd;
// In CURSOR.CPP // In CURSOR.CPP
extern void CursorProcess(CORO_PARAM, const void *); extern void CursorProcess(CORO_PARAM, const void *);
@ -678,12 +673,12 @@ bool ChangeScene(bool bReset) {
switch (g_NextScene.trans) { switch (g_NextScene.trans) {
case TRANS_CUT: case TRANS_CUT:
SetDoFadeIn(false); _vm->_bg->SetDoFadeIn(false);
break; break;
case TRANS_FADE: case TRANS_FADE:
default: default:
SetDoFadeIn(true); _vm->_bg->SetDoFadeIn(true);
break; break;
} }
} else } else
@ -854,6 +849,7 @@ TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc)
TinselEngine::~TinselEngine() { TinselEngine::~TinselEngine() {
_system->getAudioCDManager()->stop(); _system->getAudioCDManager()->stop();
delete _bg;
delete _font; delete _font;
delete _bmv; delete _bmv;
delete _sound; delete _sound;
@ -897,6 +893,7 @@ Common::Error TinselEngine::run() {
_sound = new SoundManager(this); _sound = new SoundManager(this);
_bmv = new BMVPlayer(); _bmv = new BMVPlayer();
_font = new Font(); _font = new Font();
_bg = new Background(_font);
// Initialize backend // Initialize backend
if (getGameID() == GID_DW2) { if (getGameID() == GID_DW2) {
@ -1013,7 +1010,7 @@ Common::Error TinselEngine::run() {
_vm->_config->writeToDisk(); _vm->_config->writeToDisk();
EndScene(); EndScene();
g_pCurBgnd = NULL; _bg->ResetBackground();
return Common::kNoError; return Common::kNoError;
} }
@ -1036,7 +1033,7 @@ void TinselEngine::NextGameCycle() {
_bmv->CopyMovieToScreen(); _bmv->CopyMovieToScreen();
else else
// redraw background // redraw background
DrawBackgnd(); _bg->DrawBackgnd();
// Why waste resources on yet another process? // Why waste resources on yet another process?
FettleTimers(); FettleTimers();
@ -1101,10 +1098,10 @@ void TinselEngine::CreateConstProcesses() {
void TinselEngine::RestartGame() { void TinselEngine::RestartGame() {
HoldItem(INV_NOICON); // Holding nothing HoldItem(INV_NOICON); // Holding nothing
DropBackground(); // No background _bg->DropBackground(); // No background
// Ditches existing infrastructure background // Ditches existing infrastructure background
InitBackground(); _bg->InitBackground();
// Next scene change won't need to fade out // Next scene change won't need to fade out
// -> reset the count used by ChangeScene // -> reset the count used by ChangeScene

View File

@ -56,6 +56,7 @@ class MidiDriver;
class MidiMusicPlayer; class MidiMusicPlayer;
class PCMMusicPlayer; class PCMMusicPlayer;
class SoundManager; class SoundManager;
class Background;
class Font; class Font;
typedef Common::List<Common::Rect> RectList; typedef Common::List<Common::Rect> RectList;
@ -197,6 +198,7 @@ public:
MidiMusicPlayer *_midiMusic; MidiMusicPlayer *_midiMusic;
PCMMusicPlayer *_pcmMusic; PCMMusicPlayer *_pcmMusic;
BMVPlayer *_bmv; BMVPlayer *_bmv;
Background* _bg;
Font *_font; Font *_font;
Config *_config; Config *_config;