diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp index bad68dd9a7e..9fdff1f1f2a 100644 --- a/engines/saga2/saga2.cpp +++ b/engines/saga2/saga2.cpp @@ -90,6 +90,7 @@ Saga2Engine::Saga2Engine(OSystem *syst) _edpList = nullptr; _sdpList = nullptr; _containerList = nullptr; + _tileImageBanks = nullptr; } Saga2Engine::~Saga2Engine() { diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h index fe31a57c4d5..3b6a10596e3 100644 --- a/engines/saga2/saga2.h +++ b/engines/saga2/saga2.h @@ -68,6 +68,7 @@ class Properties; class PlayerActor; class ProtoObj; class ActorProto; +class HandleArray; enum { kDebugResources = 1 << 0, @@ -150,6 +151,7 @@ public: ActiveRegion *_activeRegionList; gToolBase *_toolBase; Properties *_properties; + HandleArray *_tileImageBanks; gDisplayPort _mainPort; gPort _backPort; diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp index 9c5716ec6df..3a33b350b28 100644 --- a/engines/saga2/tile.cpp +++ b/engines/saga2/tile.cpp @@ -96,7 +96,6 @@ void setAreaSound(const TilePoint &baseCoords); * ===================================================================== */ TileBankPtr tileBanks[maxBanks]; -extern HandleArray tileImageBanks; void updateHandleRefs(const TilePoint &pt); //, StandingTileInfo *stiResult ) void updateFrameCount(void); @@ -284,7 +283,7 @@ TileInfo *TileInfo::tileAddress(TileID id, uint8 **imageData) { } if (ti != nullptr) { - if ((tibh = tileImageBanks[tileBank]) != nullptr) + if ((tibh = (*g_vm->_tileImageBanks)[tileBank]) != nullptr) *imageData = &tibh[ti->offset]; else *imageData = nullptr; diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp index f74dd490938..9436fcb5f90 100644 --- a/engines/saga2/tileload.cpp +++ b/engines/saga2/tileload.cpp @@ -35,7 +35,7 @@ namespace Saga2 { -const uint16 tileBankCount = 25; +const uint16 tileBankCount = 64; const uint32 tileImageID = MKTAG('T', 'I', 'L', 0); @@ -52,31 +52,16 @@ static byte *tileResLoad(hResID i, bool asynch = false) { return nullptr; } -HandleArray tileImageBanks(64, tileResLoad, tileImageID); - -void initTileBank(int16 bankNum) { -} - -void RHeapsAMess(void); - void freeAllTileBanks(void) { - tileImageBanks.flush(); -} - -void unlockAllTileBanks(void) { - tileImageBanks.flush(); -} - -void freeTileBank(int16) { + g_vm->_tileImageBanks->flush(); } void updateHandleRefs(const TilePoint &) { //, StandingTileInfo *stiResult ) - tileImageBanks.flush(); + g_vm->_tileImageBanks->flush(); } void initTileBanks(void) { - for (int16 i = 0; i < tileBankCount; i++) - initTileBank(i); + g_vm->_tileImageBanks = new HandleArray(tileBankCount, tileResLoad, tileImageID); } void drawPlatform( diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp index eec2bf1b260..c6183df0367 100644 --- a/engines/saga2/tilemode.cpp +++ b/engines/saga2/tilemode.cpp @@ -42,6 +42,7 @@ #include "saga2/uidialog.h" #include "saga2/contain.h" #include "saga2/saveload.h" +#include "saga2/oncall.h" namespace Saga2 { @@ -679,6 +680,7 @@ void TileModeCleanup(void) { tileControls->enable(false); freeAllTileBanks(); + delete g_vm->_tileImageBanks; // freePalette();