aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2014-08-07 21:59:45 -0400
committerPaul Gilbert2014-08-07 21:59:45 -0400
commit6715bb0864212edaf88076dce88e5df1138333da (patch)
treebd6461b488c5f70878e993b459f73390f94c9eb1
parent0c38730f3fd4965fbf1b854f76ff936dddf9f931 (diff)
downloadscummvm-rg350-6715bb0864212edaf88076dce88e5df1138333da.tar.gz
scummvm-rg350-6715bb0864212edaf88076dce88e5df1138333da.tar.bz2
scummvm-rg350-6715bb0864212edaf88076dce88e5df1138333da.zip
ACCESS: Move playField and tile data to Room class
-rw-r--r--engines/access/access.cpp14
-rw-r--r--engines/access/access.h13
-rw-r--r--engines/access/room.cpp33
-rw-r--r--engines/access/room.h16
4 files changed, 41 insertions, 35 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index ce5d8640f0..78274f1d59 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -53,8 +53,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_inactive = nullptr;
_manPal1 = nullptr;
_music = nullptr;
- _playField = nullptr;
- _tile = nullptr;
_anim = nullptr;
_title = nullptr;
_converseMode = 0;
@@ -142,8 +140,6 @@ AccessEngine::~AccessEngine() {
delete[] _inactive;
delete[] _manPal1;
delete[] _music;
- delete[] _playField;
- delete[] _tile;
delete[] _anim;
delete[] _title;
}
@@ -221,16 +217,6 @@ void AccessEngine::freeAnimationData() {
_anim = nullptr;
}
-void AccessEngine::freePlayField() {
- delete[] _playField;
- _playField = nullptr;
-}
-
-void AccessEngine::freeTileData() {
- delete[] _tile;
- _tile = nullptr;
-}
-
void AccessEngine::freeInactiveData() {
delete[] _inactive;
_inactive = nullptr;
diff --git a/engines/access/access.h b/engines/access/access.h
index a30c905dd7..a0099402fd 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -135,9 +135,6 @@ public:
byte *_inactive;
byte *_manPal1;
byte *_music;
- byte *_playField;
- Common::Point _playFieldSize;
- byte *_tile;
byte *_anim;
byte *_title;
int _converseMode;
@@ -226,16 +223,6 @@ public:
void freeCells();
/**
- * Free the playfield data
- */
- void freePlayField();
-
- /**
- * Free tile data
- */
- void freeTileData();
-
- /**
* Free the inactive data
*/
void freeInactiveData();
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 7a07f58bcb..136d6027e6 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -34,6 +34,23 @@ namespace Access {
Room::Room(AccessEngine *vm) : Manager(vm) {
_function = 0;
_roomFlag = 0;
+ _playField = nullptr;
+ _tile = nullptr;
+}
+
+Room::~Room() {
+ delete[] _playField;
+ delete[] _tile;
+}
+
+void Room::freePlayField() {
+ delete[] _playField;
+ _playField = nullptr;
+}
+
+void Room::freeTileData() {
+ delete[] _tile;
+ _tile = nullptr;
}
void Room::doRoom() {
@@ -130,7 +147,7 @@ void Room::clearRoom() {
_vm->freeAnimationData();
_vm->_scripts->freeScriptData();
_vm->freeCells();
- _vm->freePlayField();
+ freePlayField();
_vm->freeInactiveData();
_vm->freeManData();
}
@@ -229,7 +246,7 @@ void Room::setupRoom() {
if (_roomFlag != 2)
setIconPalette();
- if (_vm->_screen->_vWindowSize.x == _vm->_playFieldSize.x) {
+ if (_vm->_screen->_vWindowSize.x == _playFieldSize.x) {
_vm->_screen->_scrollX = 0;
_vm->_screen->_scrollCol = 0;
} else {
@@ -239,13 +256,13 @@ void Room::setupRoom() {
(_vm->_screen->_vWindowSize.x / 2), 0);
_vm->_screen->_scrollCol = xp;
- xp = xp + _vm->_screen->_vWindowSize.x - _vm->_playFieldSize.x;
+ xp = xp + _vm->_screen->_vWindowSize.x - _playFieldSize.x;
if (xp >= 0) {
_vm->_screen->_scrollCol = xp + 1;
}
}
- if (_vm->_screen->_vWindowSize.y == _vm->_playFieldSize.y) {
+ if (_vm->_screen->_vWindowSize.y == _playFieldSize.y) {
_vm->_screen->_scrollY = 0;
_vm->_screen->_scrollRow = 0;
}
@@ -256,7 +273,7 @@ void Room::setupRoom() {
(_vm->_screen->_vWindowSize.y / 2), 0);
_vm->_screen->_scrollRow = yp;
- yp = yp + _vm->_screen->_vWindowSize.y - _vm->_playFieldSize.y;
+ yp = yp + _vm->_screen->_vWindowSize.y - _playFieldSize.y;
if (yp >= 0) {
_vm->_screen->_scrollRow = yp + 1;
}
@@ -286,12 +303,12 @@ void Room::buildScreen() {
}
void Room::buildColumn(int playX, int screenX) {
- const byte *pSrc = _vm->_playField + _vm->_screen->_scrollRow *
- _vm->_playFieldSize.x + playX;
+ const byte *pSrc = _playField + _vm->_screen->_scrollRow *
+ _playFieldSize.x + playX;
byte *pDest = (byte *)_vm->_buffer1.getPixels();
for (int y = 0; y <= _vm->_screen->_vWindowSize.y; ++y) {
- byte *pTile = _vm->_tile + (*pSrc << 8);
+ byte *pTile = _tile + (*pSrc << 8);
for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) {
Common::copy(pTile, pTile + TILE_WIDTH, pDest);
diff --git a/engines/access/room.h b/engines/access/room.h
index fa41d32552..a202e437bb 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -62,6 +62,17 @@ protected:
void setWallCodes();
void buildScreen();
+ /**
+ * Free the playfield data
+ */
+ void freePlayField();
+
+ /**
+ * Free tile data
+ */
+ void freeTileData();
+
+
virtual void loadRoom(int roomNumber) = 0;
virtual void reloadRoom() = 0;
@@ -74,9 +85,14 @@ public:
Common::Array<JetFrame> _jetFrame;
int _function;
int _roomFlag;
+ byte *_playField;
+ Common::Point _playFieldSize;
+ byte *_tile;
public:
Room(AccessEngine *vm);
+ virtual ~Room();
+
void doRoom();
void doCommands();