diff options
author | uruk | 2014-02-04 10:30:41 +0100 |
---|---|---|
committer | uruk | 2014-02-04 10:30:41 +0100 |
commit | 29cd1614219c73385b40376d2762596f3dc3218a (patch) | |
tree | b0d78c16cc7bf25a2e553271f8039b98d3c1eaca | |
parent | 08e7b5a8f388a904243408eee5d4642c9c6c4eab (diff) | |
download | scummvm-rg350-29cd1614219c73385b40376d2762596f3dc3218a.tar.gz scummvm-rg350-29cd1614219c73385b40376d2762596f3dc3218a.tar.bz2 scummvm-rg350-29cd1614219c73385b40376d2762596f3dc3218a.zip |
AVALANCHE: Rename/move/implement getMe().
-rw-r--r-- | engines/avalanche/ghostroom.cpp | 20 | ||||
-rw-r--r-- | engines/avalanche/ghostroom.h | 27 | ||||
-rw-r--r-- | engines/avalanche/graphics.cpp | 28 | ||||
-rw-r--r-- | engines/avalanche/graphics.h | 4 |
4 files changed, 55 insertions, 24 deletions
diff --git a/engines/avalanche/ghostroom.cpp b/engines/avalanche/ghostroom.cpp index 93034a4eec..f81a74df3f 100644 --- a/engines/avalanche/ghostroom.cpp +++ b/engines/avalanche/ghostroom.cpp @@ -31,7 +31,6 @@ namespace Avalanche { const int8 GhostRoom::kAdjustment[5] = { 7, 0, 7, 7, 7 }; -const byte GhostRoom::kPlaneToUse[4] = { 2, 2, 2, 3 }; const byte GhostRoom::kWaveOrder[5] = { 5, 1, 2, 3, 4 }; const byte GhostRoom::kGlerkFade[26] = { 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1 }; const byte GhostRoom::kGreldetFade[18] = { 1, 2, 3, 4, 5, 6, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1 }; @@ -53,12 +52,14 @@ GhostRoom::GhostRoom(AvalancheEngine *vm) { _redGreldet = false; } -void GhostRoom::plainGrab() { - warning("STUB: plainGrab()"); +GhostRoom::~GhostRoom() { + for (int i = 0; i < 2; i++) + _eyes[i].free(); + _exclamation.free(); } -void GhostRoom::getMe(void *p) { - warning("STUB: getMe()"); +void GhostRoom::plainGrab() { + warning("STUB: plainGrab()"); } void GhostRoom::getMeAargh(byte which) { @@ -77,7 +78,7 @@ void GhostRoom::bigGreenEyes(byte how) { warning("STUB: bigGreenEyes()"); } -GhostRoom::ChunkBlockType GhostRoom::readChunkBlock(Common::File &file) { +ChunkBlockType GhostRoom::readChunkBlock(Common::File &file) { ChunkBlockType cb; cb._flavour = (FlavourType)file.readByte(); cb._x = file.readSint16LE(); @@ -99,7 +100,7 @@ void GhostRoom::run() { _file.seek(44); - // Initializing array. + // Initializing ghost's array. for (int i = 0; i < 5; i++) for (int j = 0; j < 2; j++) for (int y = 0; y < 66; y++) @@ -114,6 +115,11 @@ void GhostRoom::run() { _file.read(_ghost[i][j][y], cb._xl / 8); } + // Load some smaller pictures. + for (int i = 0; i < 2; i++) + _eyes[i] = _vm->_graphics->ghostLoadPicture(_file); + _exclamation = _vm->_graphics->ghostLoadPicture(_file); + warning("STUB: run()"); } diff --git a/engines/avalanche/ghostroom.h b/engines/avalanche/ghostroom.h index 8950a8aade..c6d0686d83 100644 --- a/engines/avalanche/ghostroom.h +++ b/engines/avalanche/ghostroom.h @@ -34,26 +34,27 @@ namespace Avalanche { class AvalancheEngine; +enum FlavourType { ch_EGA, ch_BGI, ch_Natural, ch_Two, ch_One }; + +struct ChunkBlockType { + FlavourType _flavour; + int16 _x, _y; + int16 _xl, _yl; + int32 _size; +}; + class GhostRoom { public: GhostRoom(AvalancheEngine *vm); + ~GhostRoom(); void run(); + ChunkBlockType readChunkBlock(Common::File &file); 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]; - static const byte kPlaneToUse[4]; static const byte kWaveOrder[5]; static const byte kGlerkFade[26]; static const byte kGreldetFade[18]; @@ -64,8 +65,8 @@ private: byte _ghost[5][2][66][26]; void *_memLevel; byte _y, _yy, _bit, _xofs; - void *_eyes[2]; - void *_exclamation; + Graphics::Surface _eyes[2]; + Graphics::Surface _exclamation; void *_aargh[6]; void *_bat[3]; GlerkType *_glerk; @@ -82,12 +83,10 @@ private: bool _redGreldet; void plainGrab(); - void getMe(void *p); void getMeAargh(byte which); 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 a85d7ebbf4..a11773a6e2 100644 --- a/engines/avalanche/graphics.cpp +++ b/engines/avalanche/graphics.cpp @@ -500,7 +500,7 @@ void GraphicManager::nimFree() { _nimLogo.free(); } -void GraphicManager::ghostDrawPicture(byte ghostArr[2][66][26], uint16 destX, uint16 destY) { +void GraphicManager::ghostDrawGhost(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; @@ -528,6 +528,30 @@ void GraphicManager::ghostDrawPicture(byte ghostArr[2][66][26], uint16 destX, ui } /** + * @remarks Originally called 'get_me' and was located in Ghostroom. + */ +Graphics::Surface GraphicManager::ghostLoadPicture(Common::File &file) { + ChunkBlockType cb = _vm->_ghostroom->readChunkBlock(file); + + Graphics::Surface picture = loadPictureGraphic(file); + + int bytesPerRow = (picture.w / 8); + if ((picture.w % 8) > 0) + bytesPerRow += 1; + int loadedBytes = picture.h * bytesPerRow * 4 + 4; + // * 4 is for the four planes, + 4 is for the reading of the width and the height at loadPictureGraphic's beginning. + + int bytesToSkip = cb._size - loadedBytes; + file.skip(bytesToSkip); + + return picture; +} + +void GraphicManager::ghostDrawPicture(const Graphics::Surface &picture, uint16 destX, uint16 destY) { + drawPicture(_surface, picture, destX, destY); +} + +/** * This function mimics Pascal's getimage(). */ Graphics::Surface GraphicManager::loadPictureGraphic(Common::File &file) { @@ -537,7 +561,7 @@ Graphics::Surface GraphicManager::loadPictureGraphic(Common::File &file) { Graphics::Surface picture; // We make a Surface object for the picture itself. picture.create(width, height, Graphics::PixelFormat::createFormatCLUT8()); - + // Produce the picture. We read it in row-by-row, and every row has 4 planes. for (int y = 0; y < height; y++) { for (int8 plane = 3; plane >= 0; plane--) { // The planes are in the opposite way. diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h index 92b311e32c..ed5a47b7a1 100644 --- a/engines/avalanche/graphics.h +++ b/engines/avalanche/graphics.h @@ -92,7 +92,9 @@ public: 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 ghostDrawGhost(byte ghostArr[2][66][26], uint16 destX, uint16 destY); // Very similar to loadPictureSign(). TODO: Unify the two later if possible. + Graphics::Surface ghostLoadPicture(Common::File &file); + void ghostDrawPicture(const Graphics::Surface &picture, uint16 destX, uint16 destY); void clearAlso(); void clearTextBar(); |