[Scummvm-git-logs] scummvm master -> 92f158384484c1bb00e82464c5af0de280e40877

dreammaster dreammaster at scummvm.org
Sun Feb 26 01:03:51 CET 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
92f1583844 TITANIC: Implementing CSurfaceArea methods


Commit: 92f158384484c1bb00e82464c5af0de280e40877
    https://github.com/scummvm/scummvm/commit/92f158384484c1bb00e82464c5af0de280e40877
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-02-25T19:03:47-05:00

Commit Message:
TITANIC: Implementing CSurfaceArea methods

Changed paths:
    engines/titanic/star_control/surface_area.cpp
    engines/titanic/star_control/surface_area.h


diff --git a/engines/titanic/star_control/surface_area.cpp b/engines/titanic/star_control/surface_area.cpp
index 77f8222..2d25d64 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 4d19131..bb851b7 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





More information about the Scummvm-git-logs mailing list