AVALANCHE: Implement fadeIn and fadeOut (dusk and dawn)

This commit is contained in:
Strangerke 2013-10-09 00:39:16 +02:00
parent cf36706b98
commit b0255c9406
8 changed files with 96 additions and 47 deletions

View File

@ -769,7 +769,7 @@ void Animation::callSpecial(uint16 which) {
} }
break; break;
case 4: // This is the ghost room link. case 4: // This is the ghost room link.
_vm->dusk(); _vm->fadeOut();
_sprites[0].turn(kDirRight); // you'll see this after we get back from bootstrap _sprites[0].turn(kDirRight); // you'll see this after we get back from bootstrap
_vm->_timer->addTimer(1, Timer::kProcGhostRoomPhew, Timer::kReasonGhostRoomPhew); _vm->_timer->addTimer(1, Timer::kProcGhostRoomPhew, Timer::kReasonGhostRoomPhew);
//_vm->_enid->backToBootstrap(3); TODO: Replace it with proper ScummVM-friendly function(s)! Do not remove until then! //_vm->_enid->backToBootstrap(3); TODO: Replace it with proper ScummVM-friendly function(s)! Do not remove until then!
@ -837,7 +837,7 @@ void Animation::callSpecial(uint16 which) {
return; return;
} }
} }
_vm->dusk(); _vm->fadeOut();
_vm->_catacombY--; _vm->_catacombY--;
catacombMove(4); catacombMove(4);
if (_vm->_room != kRoomCatacombs) if (_vm->_room != kRoomCatacombs)
@ -855,7 +855,7 @@ void Animation::callSpecial(uint16 which) {
dawnDelay(); dawnDelay();
break; break;
case 11: // _vm->special 11: transfer east in catacombs. case 11: // _vm->special 11: transfer east in catacombs.
_vm->dusk(); _vm->fadeOut();
_vm->_catacombX++; _vm->_catacombX++;
catacombMove(1); catacombMove(1);
if (_vm->_room != kRoomCatacombs) if (_vm->_room != kRoomCatacombs)
@ -864,7 +864,7 @@ void Animation::callSpecial(uint16 which) {
dawnDelay(); dawnDelay();
break; break;
case 12: // _vm->special 12: transfer south in catacombs. case 12: // _vm->special 12: transfer south in catacombs.
_vm->dusk(); _vm->fadeOut();
_vm->_catacombY++; _vm->_catacombY++;
catacombMove(2); catacombMove(2);
if (_vm->_room != kRoomCatacombs) if (_vm->_room != kRoomCatacombs)
@ -873,7 +873,7 @@ void Animation::callSpecial(uint16 which) {
dawnDelay(); dawnDelay();
break; break;
case 13: // _vm->special 13: transfer west in catacombs. case 13: // _vm->special 13: transfer west in catacombs.
_vm->dusk(); _vm->fadeOut();
_vm->_catacombX--; _vm->_catacombX--;
catacombMove(3); catacombMove(3);
if (_vm->_room != kRoomCatacombs) if (_vm->_room != kRoomCatacombs)

View File

@ -50,6 +50,8 @@ AvalancheEngine::AvalancheEngine(OSystem *syst, const AvalancheGameDescription *
_totalTime = 0; _totalTime = 0;
_showDebugLines = false; _showDebugLines = false;
memset(_fxPal, 0, 16 * 16 * 3);
} }
AvalancheEngine::~AvalancheEngine() { AvalancheEngine::~AvalancheEngine() {
@ -359,7 +361,7 @@ bool AvalancheEngine::loadGame(const int16 slot) {
if (_holdTheDawn) { if (_holdTheDawn) {
_holdTheDawn = false; _holdTheDawn = false;
dawn(); fadeIn();
} }
_background->release(); _background->release();

View File

@ -274,8 +274,8 @@ public:
void fxToggle(); void fxToggle();
void refreshObjectList(); void refreshObjectList();
void errorLed(); void errorLed();
void dusk(); void fadeOut();
void dawn(); void fadeIn();
void drawDirection(); // Draws the little icon at the left end of the text input field. void drawDirection(); // Draws the little icon at the left end of the text input field.
void gameOver(); void gameOver();
uint16 bearing(byte whichPed); // Returns the bearing from ped 'whichped' to Avvy, in degrees. uint16 bearing(byte whichPed); // Returns the bearing from ped 'whichped' to Avvy, in degrees.
@ -306,6 +306,8 @@ private:
// Will be used in dusk() and dawn(). // Will be used in dusk() and dawn().
bool _fxHidden; bool _fxHidden;
byte _fxPal[16][16][3];
bool _spludwickAtHome; // Is Spludwick at home? bool _spludwickAtHome; // Is Spludwick at home?
bool _passedCwytalotInHerts; // Have you passed Cwytalot in Herts? bool _passedCwytalotInHerts; // Have you passed Cwytalot in Herts?
bool _holdTheDawn; // If this is true, calling Dawn will do nothing. It's used, for example, at the start, to stop Load from dawning. bool _holdTheDawn; // If this is true, calling Dawn will do nothing. It's used, for example, at the start, to stop Load from dawning.
@ -328,8 +330,6 @@ private:
void findPeople(byte room); void findPeople(byte room);
void putGeidaAt(byte whichPed, byte ped); void putGeidaAt(byte whichPed, byte ped);
void guideAvvy(Common::Point cursorPos); void guideAvvy(Common::Point cursorPos);
void fadeOut(byte n);
void fadeIn(byte n);
void enterRoom(Room room, byte ped); void enterRoom(Room room, byte ped);
void exitRoom(byte x); void exitRoom(byte x);
void drawToolbar(); void drawToolbar();
@ -339,8 +339,6 @@ private:
void fixFlashers(); void fixFlashers();
void loadAlso(byte num); void loadAlso(byte num);
void resetVariables(); void resetVariables();
int8 fades(int8 x);
}; };
} // End of namespace Avalanche } // End of namespace Avalanche

View File

@ -28,8 +28,11 @@
/* AVALOT The kernel of the program. */ /* AVALOT The kernel of the program. */
#include "avalanche/avalanche.h" #include "avalanche/avalanche.h"
#include "common/random.h" #include "common/random.h"
#include "common/system.h"
#include "common/config-manager.h" #include "common/config-manager.h"
#include "graphics/palette.h"
namespace Avalanche { namespace Avalanche {
@ -297,7 +300,7 @@ void AvalancheEngine::setup() {
init(); init();
_dialogs->reset(); _dialogs->reset();
dusk(); fadeOut();
_graphics->loadDigits(); _graphics->loadDigits();
_parser->_inputTextPos = 0; _parser->_inputTextPos = 0;
@ -308,7 +311,7 @@ void AvalancheEngine::setup() {
drawToolbar(); drawToolbar();
_dialogs->setReadyLight(2); _dialogs->setReadyLight(2);
dawn(); fadeIn();
_parser->_cursorState = false; _parser->_cursorState = false;
_parser->cursorOn(); _parser->cursorOn();
_animation->_sprites[0]._speedX = kWalk; _animation->_sprites[0]._speedX = kWalk;
@ -376,7 +379,6 @@ void AvalancheEngine::init() {
#endif #endif
_letMeOut = false; _letMeOut = false;
_holdTheDawn = true;
_currentMouse = 177; _currentMouse = 177;
_dropsOk = true; _dropsOk = true;
_mouseText = ""; _mouseText = "";
@ -837,7 +839,7 @@ void AvalancheEngine::enterRoom(Room roomId, byte ped) {
case kRoomMap: case kRoomMap:
// You're entering the map. // You're entering the map.
dawn(); fadeIn();
if (ped > 0) if (ped > 0)
_graphics->zoomOut(_peds[ped]._x, _peds[ped]._y); _graphics->zoomOut(_peds[ped]._x, _peds[ped]._y);
@ -1294,25 +1296,72 @@ void AvalancheEngine::errorLed() {
warning("STUB: errorled()"); warning("STUB: errorled()");
} }
int8 AvalancheEngine::fades(int8 x) { /**
warning("STUB: fades()"); * Displays a fade out, full screen.
return 0; * This version is different to the one in the original, which was fading in 3 steps.
* @remarks Originally called 'dusk'
*/
void AvalancheEngine::fadeOut() {
byte pal[3], tmpPal[3];
_graphics->setBackgroundColor(kColorBlack);
if (_fxHidden)
return;
_fxHidden = true;
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
g_system->getPaletteManager()->grabPalette((byte *)tmpPal, j, 1);
_fxPal[i][j][0] = tmpPal[0];
_fxPal[i][j][1] = tmpPal[1];
_fxPal[i][j][2] = tmpPal[2];
if (tmpPal[0] >= 16)
pal[0] = tmpPal[0] - 16;
else
pal[0] = 0;
if (tmpPal[1] >= 16)
pal[1] = tmpPal[1] - 16;
else
pal[1] = 0;
if (tmpPal[2] >= 16)
pal[2] = tmpPal[2] - 16;
else
pal[2] = 0;
g_system->getPaletteManager()->setPalette(pal, j, 1);
}
_system->delayMillis(10);
_graphics->refreshScreen();
}
} }
void AvalancheEngine::fadeOut(byte n) { /**
warning("STUB: fadeOut()"); * Displays a fade in, full screen.
} * This version is different to the one in the original, which was fading in 3 steps.
* @remarks Originally called 'dawn'
*/
void AvalancheEngine::fadeIn() {
if (_holdTheDawn || !_fxHidden)
return;
void AvalancheEngine::dusk() { _fxHidden = false;
warning("STUB: dusk()");
}
void AvalancheEngine::fadeIn(byte n) { byte pal[3];
warning("STUB: fadeIn()"); for (int i = 15; i >= 0; i--) {
} for (int j = 0; j < 16; j++) {
pal[0] = _fxPal[i][j][0];
pal[1] = _fxPal[i][j][1];
pal[2] = _fxPal[i][j][2];
g_system->getPaletteManager()->setPalette(pal, j, 1);
}
_system->delayMillis(10);
_graphics->refreshScreen();
}
void AvalancheEngine::dawn() { if ((_room == kRoomYours) && _avvyInBed && _teetotal)
warning("STUB: dawn()"); _graphics->setBackgroundColor(kColorYellow);
} }
void AvalancheEngine::drawDirection() { // It's data is loaded in load_digits(). void AvalancheEngine::drawDirection() { // It's data is loaded in load_digits().
@ -1344,7 +1393,7 @@ void AvalancheEngine::gameOver() {
} }
void AvalancheEngine::minorRedraw() { void AvalancheEngine::minorRedraw() {
dusk(); fadeOut();
enterRoom(_room, 0); // Ped unknown or non-existant. enterRoom(_room, 0); // Ped unknown or non-existant.
@ -1352,7 +1401,7 @@ void AvalancheEngine::minorRedraw() {
_scoreToDisplay[i] = -1; // impossible digits _scoreToDisplay[i] = -1; // impossible digits
drawScore(); drawScore();
dawn(); fadeIn();
} }
void AvalancheEngine::majorRedraw() { void AvalancheEngine::majorRedraw() {
@ -1652,7 +1701,7 @@ void AvalancheEngine::flipRoom(Room room, byte ped) {
} }
exitRoom(_room); exitRoom(_room);
dusk(); fadeOut();
for (int16 i = 1; i < _animation->kSpriteNumbMax; i++) { for (int16 i = 1; i < _animation->kSpriteNumbMax; i++) {
if (_animation->_sprites[i]._quick) if (_animation->_sprites[i]._quick)
@ -1669,7 +1718,7 @@ void AvalancheEngine::flipRoom(Room room, byte ped) {
_animation->setDirection(_animation->_sprites[0]._facingDir); _animation->setDirection(_animation->_sprites[0]._facingDir);
drawDirection(); drawDirection();
dawn(); fadeIn();
} }
/** /**

View File

@ -748,7 +748,7 @@ void GraphicManager::setDialogColor(Color bg, Color text) {
// Original name background() // Original name background()
void GraphicManager::setBackgroundColor(Color x) { void GraphicManager::setBackgroundColor(Color x) {
warning("STUB: setBackgroundColor(%d)", x); warning("STUB: setBackgroundColor()");
} }
} // End of namespace Avalanche } // End of namespace Avalanche

View File

@ -1421,7 +1421,7 @@ void Parser::drink() {
_vm->_avvyIsAwake = false; _vm->_avvyIsAwake = false;
_vm->_avvyInBed = true; _vm->_avvyInBed = true;
_vm->refreshObjectList(); _vm->refreshObjectList();
_vm->dusk(); _vm->fadeOut();
_vm->flipRoom(kRoomYours, 1); _vm->flipRoom(kRoomYours, 1);
_vm->_graphics->setBackgroundColor(kColorYellow); _vm->_graphics->setBackgroundColor(kColorYellow);
_vm->_animation->_sprites[0]._visible = false; _vm->_animation->_sprites[0]._visible = false;
@ -2348,17 +2348,17 @@ void Parser::doThat() {
_vm->_timer->addTimer(1, Timer::kProcAvvySitDown, Timer::kReasonSittingDown); _vm->_timer->addTimer(1, Timer::kProcAvvySitDown, Timer::kReasonSittingDown);
} }
} else { // Default doodah. } else { // Default doodah.
_vm->dusk(); _vm->fadeOut();
_vm->dawn(); _vm->fadeIn();
Common::String tmpStr = Common::String::format("A few hours later...%cnothing much has happened...", kControlParagraph); Common::String tmpStr = Common::String::format("A few hours later...%cnothing much has happened...", kControlParagraph);
_vm->_dialogs->displayText(tmpStr); _vm->_dialogs->displayText(tmpStr);
} }
break; break;
case kVerbCodeRestart: case kVerbCodeRestart:
if (_vm->_dialogs->displayQuestion("Restart game and lose changes?")) { if (_vm->_dialogs->displayQuestion("Restart game and lose changes?")) {
_vm->dusk(); _vm->fadeOut();
_vm->newGame(); _vm->newGame();
_vm->dawn(); _vm->fadeIn();
} }
break; break;
case kVerbCodePardon: case kVerbCodePardon:
@ -2383,12 +2383,12 @@ void Parser::doThat() {
} }
void Parser::verbOpt(byte verb, Common::String &answer, char &ansKey) { void Parser::verbOpt(byte verb, Common::String &answer, char &ansKey) {
// kVerbCodegive isn't dealt with by this procedure, but by ddm__with.
switch (verb) { switch (verb) {
case kVerbCodeExam: case kVerbCodeExam:
answer = "Examine"; answer = "Examine";
ansKey = 'x'; ansKey = 'x';
break; // The ubiquitous one. break;
// kVerbCodegive isn't dealt with by this procedure, but by ddm__with.
case kVerbCodeDrink: case kVerbCodeDrink:
answer = "Drink"; answer = "Drink";
ansKey = 'D'; ansKey = 'D';

View File

@ -70,7 +70,7 @@ void Pingo::zonk() {
void Pingo::winningPic() { void Pingo::winningPic() {
Common::File f; Common::File f;
_vm->dusk(); _vm->fadeOut();
if (!f.open("finale.avd")) if (!f.open("finale.avd"))
error("AVALANCHE: File not found: finale.avd"); error("AVALANCHE: File not found: finale.avd");
@ -89,7 +89,7 @@ void Pingo::winningPic() {
warning("STUB: Pingo::winningPic()"); warning("STUB: Pingo::winningPic()");
_vm->dawn(); _vm->fadeIn();
#if 0 #if 0
do { do {

View File

@ -149,7 +149,7 @@ void Timer::updateTimer() {
crapulusSaysSpludOut(); crapulusSaysSpludOut();
break; break;
case kProcDawnDelay: case kProcDawnDelay:
_vm->dawn(); _vm->fadeIn();
break; break;
case kProcBuyDrinks: case kProcBuyDrinks:
buyDrinks(); buyDrinks();