ACCESS: Implement fading routines
This commit is contained in:
parent
857f94423f
commit
a94bf197ef
9 changed files with 195 additions and 7 deletions
|
@ -34,12 +34,14 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
|
||||||
_debugger = nullptr;
|
_debugger = nullptr;
|
||||||
_events = nullptr;
|
_events = nullptr;
|
||||||
_graphics = nullptr;
|
_graphics = nullptr;
|
||||||
|
_screen = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
AccessEngine::~AccessEngine() {
|
AccessEngine::~AccessEngine() {
|
||||||
delete _debugger;
|
delete _debugger;
|
||||||
delete _events;
|
delete _events;
|
||||||
delete _graphics;
|
delete _graphics;
|
||||||
|
delete _screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccessEngine::initialize() {
|
void AccessEngine::initialize() {
|
||||||
|
@ -51,16 +53,18 @@ void AccessEngine::initialize() {
|
||||||
_debugger = new Debugger(this);
|
_debugger = new Debugger(this);
|
||||||
_events = new EventsManager(this);
|
_events = new EventsManager(this);
|
||||||
_graphics = new GraphicsManager(this);
|
_graphics = new GraphicsManager(this);
|
||||||
|
_screen = new Screen(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Error AccessEngine::run() {
|
Common::Error AccessEngine::run() {
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
setVGA();
|
setVGA();
|
||||||
_graphics->setPalettte();
|
_screen->setInitialPalettte();
|
||||||
_graphics->setPanel(0);
|
|
||||||
_events->setCursor(CURSOR_0);
|
_events->setCursor(CURSOR_0);
|
||||||
_events->showCursor();
|
_events->showCursor();
|
||||||
|
_graphics->setPanel(0);
|
||||||
|
doTitle();
|
||||||
|
|
||||||
dummyLoop();
|
dummyLoop();
|
||||||
return Common::kNoError;
|
return Common::kNoError;
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "access/debugger.h"
|
#include "access/debugger.h"
|
||||||
#include "access/events.h"
|
#include "access/events.h"
|
||||||
#include "access/graphics.h"
|
#include "access/graphics.h"
|
||||||
|
#include "access/screen.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the namespace of the Access engine.
|
* This is the namespace of the Access engine.
|
||||||
|
@ -77,10 +78,16 @@ protected:
|
||||||
// Engine APIs
|
// Engine APIs
|
||||||
virtual Common::Error run();
|
virtual Common::Error run();
|
||||||
virtual bool hasFeature(EngineFeature f) const;
|
virtual bool hasFeature(EngineFeature f) const;
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* Show game title
|
||||||
|
*/
|
||||||
|
virtual void doTitle() = 0;
|
||||||
public:
|
public:
|
||||||
Debugger *_debugger;
|
Debugger *_debugger;
|
||||||
EventsManager *_events;
|
EventsManager *_events;
|
||||||
GraphicsManager *_graphics;
|
GraphicsManager *_graphics;
|
||||||
|
Screen *_screen;
|
||||||
public:
|
public:
|
||||||
AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
|
AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
|
||||||
virtual ~AccessEngine();
|
virtual ~AccessEngine();
|
||||||
|
|
|
@ -30,6 +30,13 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
|
||||||
AccessEngine(syst, gameDesc) {
|
AccessEngine(syst, gameDesc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AmazonEngine::doTitle() {
|
||||||
|
_screen->setDisplayScan();
|
||||||
|
_screen->forceFadeOut();
|
||||||
|
_events->hideCursor();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Amazon
|
} // End of namespace Amazon
|
||||||
|
|
||||||
} // End of namespace Access
|
} // End of namespace Access
|
||||||
|
|
|
@ -30,6 +30,8 @@ namespace Access {
|
||||||
namespace Amazon {
|
namespace Amazon {
|
||||||
|
|
||||||
class AmazonEngine : public AccessEngine {
|
class AmazonEngine : public AccessEngine {
|
||||||
|
protected:
|
||||||
|
virtual void doTitle();
|
||||||
public:
|
public:
|
||||||
AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
|
AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,4 @@ void GraphicsManager::setPanel(int num) {
|
||||||
_msVirtualOffset = _virtualOffsetsTable[num];
|
_msVirtualOffset = _virtualOffsetsTable[num];
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsManager::setPalettte() {
|
|
||||||
g_system->getPaletteManager()->setPalette(INITIAL_PALETTE, 0, 18);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // End of namespace Access
|
} // End of namespace Access
|
||||||
|
|
|
@ -43,7 +43,6 @@ public:
|
||||||
GraphicsManager(AccessEngine *vm);
|
GraphicsManager(AccessEngine *vm);
|
||||||
|
|
||||||
void setPanel(int num);
|
void setPanel(int num);
|
||||||
void setPalettte();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Access
|
} // End of namespace Access
|
||||||
|
|
|
@ -7,6 +7,7 @@ MODULE_OBJS := \
|
||||||
events.o \
|
events.o \
|
||||||
graphics.o \
|
graphics.o \
|
||||||
resources.o \
|
resources.o \
|
||||||
|
screen.o \
|
||||||
amazon\amazon_game.o
|
amazon\amazon_game.o
|
||||||
|
|
||||||
# This module can be built as a plugin
|
# This module can be built as a plugin
|
||||||
|
|
100
engines/access/screen.cpp
Normal file
100
engines/access/screen.cpp
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
/* ScummVM - Graphic Adventure Engine
|
||||||
|
*
|
||||||
|
* ScummVM is the legal property of its developers, whose names
|
||||||
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||||
|
* file distributed with this source distribution.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "common/algorithm.h"
|
||||||
|
#include "common/textconsole.h"
|
||||||
|
#include "common/system.h"
|
||||||
|
#include "graphics/palette.h"
|
||||||
|
#include "access/screen.h"
|
||||||
|
#include "access/resources.h"
|
||||||
|
|
||||||
|
namespace Access {
|
||||||
|
|
||||||
|
Screen::Screen(AccessEngine *vm) : _vm(vm) {
|
||||||
|
create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
|
||||||
|
Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Screen::setDisplayScan() {
|
||||||
|
warning("TODO: setDisplayScan");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Screen::updateScreen() {
|
||||||
|
g_system->updateScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Screen::setInitialPalettte() {
|
||||||
|
Common::copy(&INITIAL_PALETTE[0], &INITIAL_PALETTE[18 * 3], _rawPalette);
|
||||||
|
Common::fill(&_rawPalette[18 * 3], &_rawPalette[PALETTE_SIZE], 0);
|
||||||
|
|
||||||
|
g_system->getPaletteManager()->setPalette(INITIAL_PALETTE, 0, 18);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Screen::updatePalette() {
|
||||||
|
g_system->getPaletteManager()->setPalette(&_tempPalette[0], 0, PALETTE_COUNT);
|
||||||
|
updateScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Screen::forceFadeOut() {
|
||||||
|
const int FADE_AMOUNT = 2;
|
||||||
|
bool repeatFlag;
|
||||||
|
byte *srcP;
|
||||||
|
int count;
|
||||||
|
|
||||||
|
do {
|
||||||
|
repeatFlag = false;
|
||||||
|
for (srcP = &_tempPalette[0], count = 0; count < PALETTE_COUNT; ++count, ++srcP) {
|
||||||
|
int v = *srcP;
|
||||||
|
if (v) {
|
||||||
|
repeatFlag = true;
|
||||||
|
*srcP = MAX(*srcP - FADE_AMOUNT, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updatePalette();
|
||||||
|
g_system->delayMillis(10);
|
||||||
|
} while (repeatFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Screen::forceFadeIn() {
|
||||||
|
Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0);
|
||||||
|
|
||||||
|
const int FADE_AMOUNT = 2;
|
||||||
|
bool repeatFlag;
|
||||||
|
do {
|
||||||
|
repeatFlag = false;
|
||||||
|
const byte *srcP = &_rawPalette[0];
|
||||||
|
byte *destP = &_tempPalette[0];
|
||||||
|
|
||||||
|
for (int idx = 0; idx < PALETTE_SIZE; ++idx, ++srcP, ++destP) {
|
||||||
|
if (*destP != *srcP) {
|
||||||
|
repeatFlag = true;
|
||||||
|
*destP = MAX((int)*destP + FADE_AMOUNT, (int)*srcP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updatePalette();
|
||||||
|
g_system->delayMillis(10);
|
||||||
|
} while (repeatFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // End of namespace Access
|
72
engines/access/screen.h
Normal file
72
engines/access/screen.h
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/* ScummVM - Graphic Adventure Engine
|
||||||
|
*
|
||||||
|
* ScummVM is the legal property of its developers, whose names
|
||||||
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||||
|
* file distributed with this source distribution.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ACCESS_SCREEN_H
|
||||||
|
#define ACCESS_SCREEN_H
|
||||||
|
|
||||||
|
#include "common/scummsys.h"
|
||||||
|
#include "common/rect.h"
|
||||||
|
#include "graphics/surface.h"
|
||||||
|
|
||||||
|
namespace Access {
|
||||||
|
|
||||||
|
class AccessEngine;
|
||||||
|
|
||||||
|
#define PALETTE_COUNT 256
|
||||||
|
#define PALETTE_SIZE (256 * 3)
|
||||||
|
|
||||||
|
class Screen: public Graphics::Surface {
|
||||||
|
private:
|
||||||
|
AccessEngine *_vm;
|
||||||
|
byte _tempPalette[PALETTE_SIZE];
|
||||||
|
byte _rawPalette[PALETTE_SIZE];
|
||||||
|
|
||||||
|
void updatePalette();
|
||||||
|
public:
|
||||||
|
Screen(AccessEngine *vm);
|
||||||
|
|
||||||
|
void setDisplayScan();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the underlying screen
|
||||||
|
*/
|
||||||
|
void updateScreen();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fade out screen
|
||||||
|
*/
|
||||||
|
void forceFadeOut();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fade in screen
|
||||||
|
*/
|
||||||
|
void forceFadeIn();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the initial palette
|
||||||
|
*/
|
||||||
|
void setInitialPalettte();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // End of namespace Access
|
||||||
|
|
||||||
|
#endif /* ACCESS_SCREEN_H */
|
Loading…
Add table
Add a link
Reference in a new issue