diff options
-rw-r--r-- | engines/titanic/star_control/surface_area.cpp | 69 | ||||
-rw-r--r-- | engines/titanic/star_control/surface_area.h | 37 |
2 files changed, 92 insertions, 14 deletions
diff --git a/engines/titanic/star_control/surface_area.cpp b/engines/titanic/star_control/surface_area.cpp index 77f8222dad..2d25d64541 100644 --- a/engines/titanic/star_control/surface_area.cpp +++ b/engines/titanic/star_control/surface_area.cpp @@ -39,12 +39,71 @@ CSurfaceArea::CSurfaceArea(CVideoSurface *surface) { void CSurfaceArea::initialize() { _bounds = Rect(0, 0, _width - 1, _height - 1); - _centroid = Point(_width / 2, _height / 2); - _field22 = _field21 = _field20 = 0xFF; + _centroid = FPoint(_width / 2.0, _height / 2.0); + _pixel = 0xffffff; _field27 = _field26 = _field25 = 0; - _field24 = _field23 = 0; - _field28 = _field2C = 0; - _field38 = 0; + _field24 = 0; + _rgb = _field2C = 0; + _mode = SA_NONE; +} + +void CSurfaceArea::setColor(uint rgb) { + switch (_mode) { + case SA_MODE1: + _color = 0; + _colorMask = rgb; + break; + case SA_MODE2: + _color = rgb; + _colorMask = ~rgb; + break; + case SA_MODE3: + _color = rgb; + _colorMask = 0xFFFFFFFF; + break; + case SA_MODE4: + _color = 0; + _colorMask = ~rgb; + break; + default: + break; + } +} + +SurfaceAreaMode CSurfaceArea::setMode(SurfaceAreaMode mode) { + SurfaceAreaMode oldMode = _mode; + _mode = mode; + setColor(_color); + return oldMode; +} + +void CSurfaceArea::setColorFromPixel() { + pixelToRGB(_pixel, &_rgb); + setColor(_rgb); +} + +void CSurfaceArea::pixelToRGB(uint pixel, uint *rgb) { + switch (_bpp) { + case 0: + *rgb = 0; + break; + + case 1: + case 2: { + uint r = pixel & 0xF8; + uint g = (pixel >> 8) & 0xf8; + uint b = ((pixel >> 16) & 0xff) >> 3; + uint value = (((r << 5) | g) << 2) | b; + value &= 0xffff; + *rgb = (value << 16) | value; + break; + } + + case 3: + case 4: + *rgb = pixel; + break; + } } } // End of namespace Titanic diff --git a/engines/titanic/star_control/surface_area.h b/engines/titanic/star_control/surface_area.h index 4d1913123c..bb851b7a07 100644 --- a/engines/titanic/star_control/surface_area.h +++ b/engines/titanic/star_control/surface_area.h @@ -25,15 +25,27 @@ #include "titanic/support/rect.h" #include "titanic/support/video_surface.h" +#include "titanic/star_control/fpoint.h" namespace Titanic { +enum SurfaceAreaMode { + SA_NONE = 0, SA_MODE1 = 1, SA_MODE2 = 2, SA_MODE3 = 3, SA_MODE4 = 4 +}; + class CSurfaceArea { private: /** * Initialize data for the class */ void initialize(); + + /** + * Sets the drawing color and mask + */ + void setColor(uint rgb); + + void pixelToRGB(uint pixel, uint *rgb); public: int _field0; int _width; @@ -41,23 +53,30 @@ public: int _pitch; int _bpp; uint16 *_pixelsPtr; - Point _centroid; - byte _field20; - byte _field21; - byte _field22; - byte _field23; + FPoint _centroid; + uint _pixel; byte _field24; byte _field25; byte _field26; byte _field27; - int _field28; + uint _rgb; int _field2C; - int _field30; - int _field34; - int _field38; + uint _colorMask; + uint _color; + SurfaceAreaMode _mode; Rect _bounds; public: CSurfaceArea(CVideoSurface *surface); + + /** + * Sets the drawing mode, and returns the old mode + */ + SurfaceAreaMode setMode(SurfaceAreaMode mode); + + /** + * Sets the color from the current pixel + */ + void setColorFromPixel(); }; } // End of namespace Titanic |