aboutsummaryrefslogtreecommitdiff
path: root/engines/avalanche
diff options
context:
space:
mode:
Diffstat (limited to 'engines/avalanche')
-rw-r--r--engines/avalanche/enums.h1
-rw-r--r--engines/avalanche/ghostroom.cpp37
-rw-r--r--engines/avalanche/ghostroom.h4
-rw-r--r--engines/avalanche/graphics.cpp83
-rw-r--r--engines/avalanche/graphics.h3
5 files changed, 79 insertions, 49 deletions
diff --git a/engines/avalanche/enums.h b/engines/avalanche/enums.h
index 998c96a131..0ba39321bc 100644
--- a/engines/avalanche/enums.h
+++ b/engines/avalanche/enums.h
@@ -30,6 +30,7 @@
namespace Avalanche {
+enum MonsterType { kMonsterTypeGhost, kMonsterTypeGlerk };
enum Flavour { kFlavourEga, kFlavourBgi, kFlavourNatural, kFlavourTwo, kFlavourOne };
diff --git a/engines/avalanche/ghostroom.cpp b/engines/avalanche/ghostroom.cpp
index 1419a0cbab..68e3c9ba77 100644
--- a/engines/avalanche/ghostroom.cpp
+++ b/engines/avalanche/ghostroom.cpp
@@ -70,6 +70,28 @@ GhostRoom::~GhostRoom() {
for (int j = 0; j < 6; j++)
_greldet[j][i].free();
}
+
+ for (int i = 0; i < 5; i++) {
+ for (int j = 0; j < 2; j++) {
+ for (int y = 0; y < 66; y++) {
+ delete[] _ghost[i][j][y];
+ }
+ delete[] _ghost[i][j];
+ }
+ delete[] _ghost[i];
+ }
+ delete[] _ghost;
+
+ for (int i = 0; i < 6; i++) {
+ for (int j = 0; j < 4; j++) {
+ for (int y = 0; y < 35; y++) {
+ delete[] _glerk[i][j][y];
+ }
+ delete[] _glerk[i][j];
+ }
+ delete[] _glerk[i];
+ }
+ delete[] _glerk;
}
void GhostRoom::wait(uint16 howLong) {
@@ -141,9 +163,13 @@ void GhostRoom::loadPictures() {
file.seek(44);
// Initializing ghost's array.
+ _ghost = new byte***[5];
for (int i = 0; i < 5; i++) {
+ _ghost[i] = new byte**[2];
for (int j = 0; j < 2; j++) {
+ _ghost[i][j] = new byte*[66];
for (int y = 0; y < 66; y++) {
+ _ghost[i][j][y] = new byte[26];
for (int x = 0; x < 26; x++)
_ghost[i][j][y][x] = 0;
}
@@ -171,11 +197,14 @@ void GhostRoom::loadPictures() {
for (int i = 0; i < 3; i++)
_bat[i] = _vm->_graphics->ghostLoadPicture(file, dummyCoord);
-
// Initializing glerk's array.
+ _glerk = new byte***[6];
for (int i = 0; i < 6; i++) {
+ _glerk[i] = new byte**[4];
for (int j = 0; j < 4; j++) {
+ _glerk[i][j] = new byte*[35];
for (int y = 0; y < 35; y++) {
+ _glerk[i][j][y] = new byte[9];
for (int x = 0; x < 9; x++)
_glerk[i][j][y][x] = 0;
}
@@ -245,7 +274,7 @@ void GhostRoom::run() {
if (_glerkStage > 25)
break;
- _vm->_graphics->ghostDrawGlerk(_glerk[kGlerkFade[_glerkStage]], 456, 14);
+ _vm->_graphics->ghostDrawMonster(_glerk[kGlerkFade[_glerkStage]], 456, 14, kMonsterTypeGlerk);
_glerkStage++;
}
@@ -263,7 +292,7 @@ void GhostRoom::run() {
// Here comes the descending ghost:
for (int y = -64; y <= 103; y++) {
- _vm->_graphics->ghostDrawGhost(_ghost[1 + (abs(y / 7) % 2) * 3], 0, y);
+ _vm->_graphics->ghostDrawMonster(_ghost[1 + (abs(y / 7) % 2) * 3], 0, y, kMonsterTypeGhost);
if (y > 0)
_vm->_graphics->drawFilledRectangle(Common::Rect(0, y - 1, 26 * 8 + 1, y + 1), kColorBlack);
_vm->_graphics->refreshScreen();
@@ -277,7 +306,7 @@ void GhostRoom::run() {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 5; j++) {
_vm->_graphics->drawFilledRectangle(Common::Rect(0, 96, 26 * 8, 170), kColorBlack);
- _vm->_graphics->ghostDrawGhost(_ghost[kWaveOrder[j]], 0, 96 + kAdjustment[j]);
+ _vm->_graphics->ghostDrawMonster(_ghost[kWaveOrder[j]], 0, 96 + kAdjustment[j], kMonsterTypeGhost);
_aarghCount++;
diff --git a/engines/avalanche/ghostroom.h b/engines/avalanche/ghostroom.h
index ebb02f7aac..4c659128ce 100644
--- a/engines/avalanche/ghostroom.h
+++ b/engines/avalanche/ghostroom.h
@@ -58,11 +58,11 @@ private:
static const byte kGreldetFade[18];
Common::Point dummyCoord;
- byte _ghost[5][2][66][26];
+ byte ****_ghost;// [5][2][66][26]
Graphics::Surface _eyes[2];
Graphics::Surface _exclamation;
Graphics::Surface _bat[3];
- byte _glerk[6][4][35][9];
+ byte ****_glerk; // [6][4][35][9]
Graphics::Surface _aargh[6];
Common::Point _aarghWhere[6];
Graphics::Surface _greenEyes[5];
diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp
index ae53f3e034..513cd72c8c 100644
--- a/engines/avalanche/graphics.cpp
+++ b/engines/avalanche/graphics.cpp
@@ -527,64 +527,65 @@ void GraphicManager::nimFree() {
_nimLogo.free();
}
-void GraphicManager::ghostDrawGhost(byte ghostArr[2][66][26], uint16 destX, int16 destY) {
+void GraphicManager::ghostDrawMonster(byte ***picture, uint16 destX, int16 destY, MonsterType type) {
+ uint16 height = 0;
+ uint16 width = 0;
+ // Only for the Ghost:
const byte kPlaneToUse[4] = { 0, 0, 0, 1 };
- // Constants from the original code:
- uint16 height = 66;
- const uint16 width = 26 * 8;
-
- // We have to mess around with the coords and the sizes since
- // the ghost isn't always placed fully on the screen.
int yStart = 0;
- if (destY < 0) {
- yStart = abs(destY);
- height -= yStart;
- destY = 0;
- }
-
- Graphics::Surface ghostPic;
- ghostPic.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
-
- for (int y = 0; y < height; y++) {
- for (int plane = 0; plane < 4; plane++) {
- for (uint16 x = 0; x < width / 8; x ++) {
- byte pixel = ghostArr[kPlaneToUse[plane]][y + yStart][x];
- for (int bit = 0; bit < 8; bit++) {
- byte pixelBit = (pixel >> bit) & 1;
- *(byte *)ghostPic.getBasePtr(x * 8 + 7 - bit, y) += (pixelBit << plane);
- }
- }
+
+ // Constants from the original code:
+ switch (type) {
+ case kMonsterTypeGhost:
+ height = 66;
+ width = 208; // 26 * 8
+
+ // We have to mess around with the coords and the sizes since
+ // the ghost isn't always placed fully on the screen.
+ if (destY < 0) {
+ yStart = abs(destY);
+ height -= yStart;
+ destY = 0;
}
+ break;
+ case kMonsterTypeGlerk:
+ height = 35;
+ width = 72; // 9 * 8
+ break;
+ default:
+ break;
}
- drawPicture(_surface, ghostPic, destX, destY);
-
- ghostPic.free();
-}
-
-void GraphicManager::ghostDrawGlerk(byte glerkArr[4][35][9], uint16 destX, uint16 destY) {
- // Constants from the original code:
- const uint16 height = 35;
- const uint16 width = 9 * 8;
-
- Graphics::Surface glerkPic;
- glerkPic.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
+ Graphics::Surface monsterPicture;
+ monsterPicture.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
for (int y = 0; y < height; y++) {
for (int plane = 0; plane < 4; plane++) {
for (uint16 x = 0; x < width / 8; x++) {
- byte pixel = glerkArr[plane][y][x];
+ byte pixel = 0;
+
+ switch (type) {
+ case kMonsterTypeGhost:
+ pixel = picture[kPlaneToUse[plane]][y + yStart][x];
+ break;
+ case kMonsterTypeGlerk:
+ pixel = picture[plane][y][x];
+ break;
+ default:
+ break;
+ }
+
for (int bit = 0; bit < 8; bit++) {
byte pixelBit = (pixel >> bit) & 1;
- *(byte *)glerkPic.getBasePtr(x * 8 + 7 - bit, y) += (pixelBit << plane);
+ *(byte *)monsterPicture.getBasePtr(x * 8 + 7 - bit, y) += (pixelBit << plane);
}
}
}
}
- drawPicture(_surface, glerkPic, destX, destY);
+ drawPicture(_surface, monsterPicture, destX, destY);
- glerkPic.free();
+ monsterPicture.free();
}
/**
diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h
index 3fd633f0ab..bd8fc6c8ff 100644
--- a/engines/avalanche/graphics.h
+++ b/engines/avalanche/graphics.h
@@ -97,8 +97,7 @@ public:
void drawWinningPic();
// Ghostroom's functions:
- void ghostDrawGhost(byte ghostArr[2][66][26], uint16 destX, int16 destY);
- void ghostDrawGlerk(byte glerkArr[4][35][9], uint16 destX, uint16 destY); // Very similar to ghostDrawGhost(), but not enough to unify the two.
+ void ghostDrawMonster(byte ***picture, uint16 destX, int16 destY, MonsterType type);
Graphics::Surface ghostLoadPicture(Common::File &file, Common::Point &coord);
void ghostDrawPicture(const Graphics::Surface &picture, uint16 destX, uint16 destY);
void ghostDrawBackgroundItems(Common::File &file);