aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authoruruk2014-02-04 08:58:48 +0100
committeruruk2014-02-04 08:59:03 +0100
commit9a08e0459c7544050bd18a637562ec444b5875a7 (patch)
treec578ed154e817227d229637d2ac08caae1893dc4 /engines
parenta67b7f487c47fa833a5fa273d96f531708557edf (diff)
downloadscummvm-rg350-9a08e0459c7544050bd18a637562ec444b5875a7.tar.gz
scummvm-rg350-9a08e0459c7544050bd18a637562ec444b5875a7.tar.bz2
scummvm-rg350-9a08e0459c7544050bd18a637562ec444b5875a7.zip
AVALANCHE: Implement loading and drawing of the picture of the ghost.
Diffstat (limited to 'engines')
-rw-r--r--engines/avalanche/animation.cpp1
-rw-r--r--engines/avalanche/ghostroom.cpp36
-rw-r--r--engines/avalanche/ghostroom.h24
-rw-r--r--engines/avalanche/graphics.cpp27
-rw-r--r--engines/avalanche/graphics.h8
5 files changed, 81 insertions, 15 deletions
diff --git a/engines/avalanche/animation.cpp b/engines/avalanche/animation.cpp
index 375d393acf..a3c01af404 100644
--- a/engines/avalanche/animation.cpp
+++ b/engines/avalanche/animation.cpp
@@ -815,7 +815,6 @@ void Animation::callSpecial(uint16 which) {
}
break;
case 4: // This is the ghost room link.
- _vm->fadeOut();
_sprites[0]->turn(kDirRight); // you'll see this after we get back from bootstrap
_vm->_timer->addTimer(1, Timer::kProcGhostRoomPhew, Timer::kReasonGhostRoomPhew);
_vm->_ghostroom->run();
diff --git a/engines/avalanche/ghostroom.cpp b/engines/avalanche/ghostroom.cpp
index f56fcd202d..491a686b86 100644
--- a/engines/avalanche/ghostroom.cpp
+++ b/engines/avalanche/ghostroom.cpp
@@ -78,7 +78,43 @@ void GhostRoom::bigGreenEyes(byte how) {
warning("STUB: bigGreenEyes()");
}
+GhostRoom::ChunkBlockType GhostRoom::readChunkBlock(Common::File &file) {
+ ChunkBlockType cb;
+ cb._flavour = (FlavourType)file.readByte();
+ cb._x = file.readSint16LE();
+ cb._y = file.readSint16LE();
+ cb._xl = file.readSint16LE();
+ cb._yl = file.readSint16LE();
+ cb._size = file.readSint32LE();
+ return cb;
+}
+
void GhostRoom::run() {
+ _vm->_graphics->saveScreen();
+ _vm->fadeOut();
+ _vm->fadeIn();
+ _vm->_graphics->drawFilledRectangle(Common::Rect(0, 0, 640, 200), kColorBlack);
+
+ if (!_file.open("spooky.avd"))
+ error("AVALANCHE: Trip: File not found: spooky.avd");
+
+ _file.seek(44);
+
+ // Initializing array.
+ for (int i = 0; i < 5; i++)
+ for (int j = 0; j < 2; j++)
+ for (int y = 0; y < 66; y++)
+ for (int x = 0; x < 26; x++)
+ _ghost[i][j][y][x] = 0;
+
+ // Reading in the pictures of the ghost.
+ for (int i = 0; i < 5; i++) {
+ ChunkBlockType cb = readChunkBlock(_file);
+ for (int j = 0; j < 2; j++)
+ for (uint16 y = 0; y <= cb._yl; y++)
+ _file.read(_ghost[i][j][y], cb._xl / 8);
+ }
+
warning("STUB: run()");
}
diff --git a/engines/avalanche/ghostroom.h b/engines/avalanche/ghostroom.h
index e6dbfe4d52..8950a8aade 100644
--- a/engines/avalanche/ghostroom.h
+++ b/engines/avalanche/ghostroom.h
@@ -29,6 +29,7 @@
#define AVALANCHE_GHOSTROOM_H
#include "common/scummsys.h"
+#include "graphics/surface.h"
namespace Avalanche {
class AvalancheEngine;
@@ -40,6 +41,15 @@ public:
void run();
private:
+ enum FlavourType { ch_EGA, ch_BGI, ch_Natural, ch_Two, ch_One };
+
+ struct ChunkBlockType {
+ FlavourType _flavour;
+ int16 _x, _y;
+ int16 _xl, _yl;
+ int32 _size;
+ };
+
AvalancheEngine *_vm;
static const int8 kAdjustment[5];
@@ -48,19 +58,9 @@ private:
static const byte kGlerkFade[26];
static const byte kGreldetFade[18];
- enum FlavourType { ch_EGA, ch_BGI, ch_Natural, ch_Two, ch_One };
-
- struct ChunkBlockType {
- FlavourType _flavour;
- int8 _x, _y;
- int8 _xl, _yl;
- int32 _size;
- };
-
typedef byte GlerkType[6][4][35][9];
- Common::File _f;
- ChunkBlockType _cb;
+ Common::File _file;
byte _ghost[5][2][66][26];
void *_memLevel;
byte _y, _yy, _bit, _xofs;
@@ -72,7 +72,6 @@ private:
void *_greenEyes[5];
void *_greldet[6][2];
Common::Point _aarghWhere[6];
- int16 _gd, _gm;
bool _gb;
byte _glerkStage;
int16 _batX, _batY;
@@ -88,6 +87,7 @@ private:
void wait(uint16 howLong);
void doBat();
void bigGreenEyes(byte how);
+ ChunkBlockType readChunkBlock(Common::File &file);
};
} // End of namespace Avalanche
diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp
index a8efc4be9b..a85d7ebbf4 100644
--- a/engines/avalanche/graphics.cpp
+++ b/engines/avalanche/graphics.cpp
@@ -500,6 +500,33 @@ void GraphicManager::nimFree() {
_nimLogo.free();
}
+void GraphicManager::ghostDrawPicture(byte ghostArr[2][66][26], uint16 destX, uint16 destY) {
+ const byte kPlaneToUse[4] = { 0, 0, 0, 1 };
+ // Constants from the original code.
+ uint16 height = 66;
+ uint16 width = 26 * 8;
+
+ 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][x];
+ for (int bit = 0; bit < 8; bit++) {
+ byte pixelBit = (pixel >> bit) & 1;
+ if (pixelBit != 0)
+ *(byte *)ghostPic.getBasePtr(x * 8 + 7 - bit, y) += (pixelBit << plane);
+ }
+ }
+ }
+ }
+
+ drawPicture(_surface, ghostPic, destX, destY);
+
+ ghostPic.free();
+}
+
/**
* This function mimics Pascal's getimage().
*/
diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h
index 636ae6fdf9..92b311e32c 100644
--- a/engines/avalanche/graphics.h
+++ b/engines/avalanche/graphics.h
@@ -38,6 +38,7 @@ namespace Avalanche {
class AvalancheEngine;
class AnimationType;
struct SpriteType;
+struct ChunkBlockType;
typedef byte FontType[256][16];
typedef byte ManiType[2049];
@@ -62,6 +63,8 @@ public:
Common::Point drawScreenArc(int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color);
void drawPieSlice(int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color);
void drawTriangle(Common::Point *p, Color color);
+ void drawFilledRectangle(Common::Rect rect, Color color);
+ void drawRectangle(Common::Rect rect, Color color);
void drawNormalText(const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color);
void drawScrollText(const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color);
void drawDigit(int index, int x, int y);
@@ -79,8 +82,6 @@ public:
void drawDebugLines();
// For the mini-game "Nim".
- void drawFilledRectangle(Common::Rect rect, Color color);
- void drawRectangle(Common::Rect rect, Color color);
void nimLoad();
void nimDrawStone(int x, int y);
void nimDrawInitials();
@@ -90,6 +91,9 @@ public:
// Used in wobble()
void shiftScreen();
+ // Ghostroom's functions:
+ void ghostDrawPicture(byte ghostArr[2][66][26], uint16 destX, uint16 destY); // Very similar to loadPictureSign(). TODO: Unify the two later if possible.
+
void clearAlso();
void clearTextBar();
void setAlsoLine(int x1, int y1, int x2, int y2, Color color);