aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/startrek/graphics.cpp78
-rw-r--r--engines/startrek/graphics.h8
-rw-r--r--engines/startrek/startrek.cpp8
3 files changed, 75 insertions, 19 deletions
diff --git a/engines/startrek/graphics.cpp b/engines/startrek/graphics.cpp
index 457313cd51..c94d9f7b1f 100644
--- a/engines/startrek/graphics.cpp
+++ b/engines/startrek/graphics.cpp
@@ -52,13 +52,17 @@ Graphics::Graphics(StarTrekEngine *vm) : _vm(vm), _egaMode(false) {
_textboxVar6 = 0;
_textboxHasMultipleChoices = false;
+ _palData = new byte[256 * 3];
+ _lutData = new byte[256 * 3];
+
+ _paletteFadeLevel = 0;
+
setMouseCursor(loadBitmap("pushbtn"));
CursorMan.showMouse(true);
}
Graphics::~Graphics() {
delete[] _egaData;
- delete[] _lutData;
delete _font;
}
@@ -68,35 +72,79 @@ void Graphics::setBackgroundImage(SharedPtr<Bitmap> bitmap) {
_backgroundImage = bitmap;
}
+/**
+ * Note: this doesn't flush the palette to the screen (must call "setPaletteFadeLevel")
+ */
void Graphics::loadPalette(const Common::String &paletteName) {
// Set the palette from a PAL file
Common::String palFile = paletteName + ".PAL";
Common::String lutFile = paletteName + ".LUT";
SharedPtr<Common::SeekableReadStream> palStream = _vm->loadFile(palFile.c_str());
- byte *palette = new byte[256 * 3];
- palStream->read(palette, 256 * 3);
-
- // Expand color components
- if (_vm->getPlatform() == Common::kPlatformDOS || _vm->getPlatform() == Common::kPlatformMacintosh)
- for (uint16 i = 0; i < 256 * 3; i++)
- palette[i] <<= 2;
-
- _vm->_system->getPaletteManager()->setPalette(palette, 0, 256);
-
- delete[] palette;
+ palStream->read(_palData, 256 * 3);
// Load LUT file
SharedPtr<Common::SeekableReadStream> lutStream = _vm->loadFile(lutFile.c_str());
- delete[] _lutData;
- _lutData = new byte[256];
lutStream->read(_lutData, 256);
}
+void Graphics::fadeinScreen() {
+ while (_paletteFadeLevel <= 100) {
+ TrekEvent event;
+ do {
+ _vm->popNextEvent(&event);
+ }
+ while (event.type != TREKEVENT_TICK);
+
+ setPaletteFadeLevel(_palData, _paletteFadeLevel);
+ _paletteFadeLevel += 10;
+ }
+
+ _paletteFadeLevel = 100;
+}
+
+void Graphics::fadeoutScreen() {
+ while (_paletteFadeLevel >= 0) {
+ TrekEvent event;
+ do {
+ _vm->popNextEvent(&event);
+ }
+ while (event.type != TREKEVENT_TICK);
+
+ setPaletteFadeLevel(_palData, _paletteFadeLevel);
+ _paletteFadeLevel -= 10;
+ }
+
+ _paletteFadeLevel = 0;
+}
+
+/**
+ * This flushes the palette to the screen. fadeLevel ranges from 0-100.
+ */
+void Graphics::setPaletteFadeLevel(byte *palData, int fadeLevel) {
+ byte palBuffer[256 * 3];
+
+ int multiplier = (fadeLevel << 8) / 100;
+
+ for (uint16 i = 0; i < 256 * 3; i++) {
+ palBuffer[i] = (palData[i] * multiplier) >> 8;
+
+ // Expand color components
+ if (_vm->getPlatform() == Common::kPlatformDOS || _vm->getPlatform() == Common::kPlatformMacintosh)
+ palBuffer[i] <<= 2;
+ }
+
+ _vm->_system->getPaletteManager()->setPalette(palBuffer, 0, 256);
+
+ // FIXME: this isn't supposed to flush changes to graphics, only palettes.
+ // Might not matter...
+ _vm->_system->updateScreen();
+}
+
void Graphics::loadPri(const char *priFile) {
SharedPtr<Common::SeekableReadStream> priStream = _vm->loadFile(priFile);
- priStream->read(_priData, SCREEN_WIDTH*SCREEN_HEIGHT / 2);
+ priStream->read(_priData, SCREEN_WIDTH * SCREEN_HEIGHT / 2);
}
void Graphics::clearPri() {
diff --git a/engines/startrek/graphics.h b/engines/startrek/graphics.h
index 758f327d6b..c50a39fdb5 100644
--- a/engines/startrek/graphics.h
+++ b/engines/startrek/graphics.h
@@ -71,7 +71,12 @@ public:
~Graphics();
void setBackgroundImage(SharedPtr<Bitmap> bitmap);
+
void loadPalette(const String &paletteFile);
+ void fadeinScreen();
+ void fadeoutScreen();
+ void setPaletteFadeLevel(byte *palData, int fadeLevel);
+
void loadPri(const char *priFile);
void clearPri();
byte getPriValue(int x, int y);
@@ -99,9 +104,12 @@ private:
bool _egaMode;
byte *_egaData;
+ byte *_palData;
byte *_lutData;
byte _priData[SCREEN_WIDTH*SCREEN_HEIGHT / 2];
+ int16 _paletteFadeLevel;
+
Common::Rect _screenRect;
SharedPtr<Bitmap> _backgroundImage;
diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp
index 3a434bf171..7c3f728518 100644
--- a/engines/startrek/startrek.cpp
+++ b/engines/startrek/startrek.cpp
@@ -214,7 +214,7 @@ void StarTrekEngine::runTransportSequence(const Common::String &name) {
};
_sound->stopAllVocSounds();
- // sub_1e70d();
+ _gfx->fadeoutScreen();
objectFunc1();
initObjects();
@@ -229,7 +229,7 @@ void StarTrekEngine::runTransportSequence(const Common::String &name) {
Common::String filename = getCrewmanAnimFilename(i, name);
int x = crewmanTransportPositions[i][0];
int y = crewmanTransportPositions[i][1];
- loadAnimationForObject(i, filename, x, y, 128);
+ loadAnimationForObject(i, filename, x, y, 256);
_objectList[i].animationString[0] = '\0';
}
@@ -252,7 +252,7 @@ void StarTrekEngine::runTransportSequence(const Common::String &name) {
// TODO: redraw mouse and sprite_52c4e?
_gfx->drawAllSprites();
- // sub_1e6ab();
+ _gfx->fadeinScreen();
playSoundEffectIndex(0x0a);
@@ -276,7 +276,7 @@ void StarTrekEngine::runTransportSequence(const Common::String &name) {
// TODO: redraw sprite_52c4e?
_gfx->drawAllSprites();
- // sub_1e70d();
+ _gfx->fadeoutScreen();
objectFunc1();
initObjects();
}