diff options
author | Nicola Mettifogo | 2007-12-15 20:56:05 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2007-12-15 20:56:05 +0000 |
commit | d632206248f2910afe6a9628d82c08e5b180fd6b (patch) | |
tree | a3d9aeead84f51a94494253c87148a2d1c4ce99e /engines/parallaction/graphics.cpp | |
parent | 3dd11b260b49aa524897eaff1c7eeca1b20886cb (diff) | |
download | scummvm-rg350-d632206248f2910afe6a9628d82c08e5b180fd6b.tar.gz scummvm-rg350-d632206248f2910afe6a9628d82c08e5b180fd6b.tar.bz2 scummvm-rg350-d632206248f2910afe6a9628d82c08e5b180fd6b.zip |
Added halfbrite effect to Nippon Safes Amiga. Implementation is not complete, since the spotlight during Donna's dance is not moving yet.
svn-id: r29863
Diffstat (limited to 'engines/parallaction/graphics.cpp')
-rw-r--r-- | engines/parallaction/graphics.cpp | 73 |
1 files changed, 62 insertions, 11 deletions
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 41f818a8a8..5b1c292ead 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -25,6 +25,7 @@ #include "common/system.h" #include "common/file.h" +#include "graphics/primitives.h" #include "parallaction/parallaction.h" @@ -32,6 +33,40 @@ namespace Parallaction { +void halfbritePixel(int x, int y, int color, void *data) { + byte *buffer = (byte*)data; + buffer[x + y * _vm->_screenWidth] &= ~0x20; +} + +void drawCircleLine(int xCenter, int yCenter, int x, int y, int color, void (*plotProc)(int, int, int, void *), void *data){ + Graphics::drawLine(xCenter + x, yCenter + y, xCenter - x, yCenter + y, color, plotProc, data); + Graphics::drawLine(xCenter + x, yCenter - y, xCenter - x, yCenter - y, color, plotProc, data); + Graphics::drawLine(xCenter + y, yCenter + x, xCenter - y, yCenter + x, color, plotProc, data); + Graphics::drawLine(xCenter + y, yCenter - x, xCenter - y, yCenter - x, color, plotProc, data); +} + +void drawCircle(int xCenter, int yCenter, int radius, int color, void (*plotProc)(int, int, int, void *), void *data) { + int x = 0; + int y = radius; + int p = 1 - radius; + + /* Plot first set of points */ + drawCircleLine(xCenter, yCenter, x, y, color, plotProc, data); + + while (x < y) { + x++; + if (p < 0) + p += 2*x + 1; + else { + y--; + p += 2 * (x-y) + 1; + } + drawCircleLine(xCenter, yCenter, x, y, color, plotProc, data); + } +} + + + Palette::Palette() { @@ -110,7 +145,7 @@ void Palette::fadeTo(const Palette& target, uint step) { uint Palette::fillRGBA(byte *rgba) { byte r, g, b; - byte *hbPal = rgba + _size; + byte *hbPal = rgba + _colors * 4; for (uint32 i = 0; i < _colors; i++) { r = (_data[i*3] << 2) | (_data[i*3] >> 4); @@ -269,22 +304,24 @@ void Gfx::animatePalette() { void Gfx::setHalfbriteMode(bool enable) { -#ifdef HALFBRITE if (_vm->getPlatform() != Common::kPlatformAmiga) return; if (enable == _halfbrite) return; - byte *buf = _buffers[kBitBack]; - for (uint32 i = 0; i < SCREEN_SIZE; i++) - *buf++ ^= 0x20; + _halfbrite = !_halfbrite; - buf = _buffers[kBitFront]; - for (uint32 i = 0; i < SCREEN_SIZE; i++) - *buf++ ^= 0x20; + if (!enable) { + _hbCircleRadius = 0; + } +} - _halfbrite = !_halfbrite; -#endif +#define HALFBRITE_CIRCLE_RADIUS 48 +void Gfx::setProjectorPos(int x, int y) { + _hbCircleRadius = HALFBRITE_CIRCLE_RADIUS; + _hbCirclePos.x = x + _hbCircleRadius; + _hbCirclePos.y = y + _hbCircleRadius; } + void Gfx::drawInventory() { if ((_engineFlags & kEngineInventory) == 0) { @@ -325,7 +362,20 @@ void Gfx::drawBalloons() { } void Gfx::updateScreen() { - g_system->copyRectToScreen((const byte*)_buffers[kBitFront]->pixels, _buffers[kBitFront]->pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight); + if (_halfbrite) { + Graphics::Surface *surf = g_system->lockScreen(); + byte *src = (byte*)_buffers[kBitFront]->pixels; + byte *dst = (byte*)surf->pixels; + for (int i = 0; i < surf->w*surf->h; i++) { + *dst++ = *src++ | 0x20; + } + if (_hbCircleRadius > 0) { + drawCircle(_hbCirclePos.x, _hbCirclePos.y, _hbCircleRadius, 0, &halfbritePixel, surf->pixels); + } + g_system->unlockScreen(); + } else { + g_system->copyRectToScreen((const byte*)_buffers[kBitFront]->pixels, _buffers[kBitFront]->pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight); + } drawInventory(); @@ -854,6 +904,7 @@ Gfx::Gfx(Parallaction* vm) : memset(_palettefx, 0, sizeof(_palettefx)); _halfbrite = false; + _hbCircleRadius = 0; _font = NULL; |