aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2013-06-29 18:24:26 -0400
committerPaul Gilbert2013-06-29 18:24:26 -0400
commit527b1b9b9cc730a87618c22d22fdff3e0a992daf (patch)
tree1184566f2e957ae13f408156ad259ceeafa6016f
parent61df7e35c98b9d6b0ed8d030faea5e81bb3888f0 (diff)
downloadscummvm-rg350-527b1b9b9cc730a87618c22d22fdff3e0a992daf.tar.gz
scummvm-rg350-527b1b9b9cc730a87618c22d22fdff3e0a992daf.tar.bz2
scummvm-rg350-527b1b9b9cc730a87618c22d22fdff3e0a992daf.zip
TSAGE: Implemented R2R MazeUI::draw method
-rw-r--r--engines/tsage/graphics.cpp7
-rw-r--r--engines/tsage/graphics.h2
-rw-r--r--engines/tsage/ringworld2/ringworld2_logic.cpp77
-rw-r--r--engines/tsage/ringworld2/ringworld2_logic.h9
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes1.cpp6
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes3.cpp4
6 files changed, 84 insertions, 21 deletions
diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp
index fb0b0b0cbb..bcc4d1bbd6 100644
--- a/engines/tsage/graphics.cpp
+++ b/engines/tsage/graphics.cpp
@@ -234,10 +234,15 @@ GfxSurface::GfxSurface(const GfxSurface &s) {
}
GfxSurface::~GfxSurface() {
+ clear();
+}
+
+void GfxSurface::clear() {
if (_customSurface) {
_customSurface->free();
delete _customSurface;
- }
+ _customSurface = NULL;
+ }
}
/**
diff --git a/engines/tsage/graphics.h b/engines/tsage/graphics.h
index 826f2fef6f..f006ceea53 100644
--- a/engines/tsage/graphics.h
+++ b/engines/tsage/graphics.h
@@ -42,6 +42,7 @@ class Rect : public Common::Rect, public Serialisable {
public:
Rect() : Common::Rect() {}
Rect(int16 x1, int16 y1, int16 x2, int16 y2) : Common::Rect(x1, y1, x2, y2) {}
+ Rect(const Common::Rect &r) : Common::Rect(r) {}
void set(int16 x1, int16 y1, int16 x2, int16 y2);
void collapse(int dx, int dy);
@@ -100,6 +101,7 @@ public:
void unlockSurface();
void synchronize(Serializer &s);
void create(int width, int height);
+ void clear();
void setBounds(const Rect &bounds) { _bounds = bounds; }
const Rect &getBounds() const { return _bounds; }
diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp
index 1cd6561d33..4ae12c966d 100644
--- a/engines/tsage/ringworld2/ringworld2_logic.cpp
+++ b/engines/tsage/ringworld2/ringworld2_logic.cpp
@@ -21,6 +21,7 @@
*/
#include "common/config-manager.h"
+#include "common/rect.h"
#include "tsage/graphics.h"
#include "tsage/scenes.h"
#include "tsage/tsage.h"
@@ -1276,15 +1277,14 @@ void SceneAreaObject::setDetails(int resNum, int lookLineNum, int talkLineNum, i
/*****************************************************************************/
MazeUI::MazeUI() {
- _field16 = _field3A = NULL;
+ _field16 = NULL;
_field12 = _field14 = 0;
_field26 = _field28 = _width = _height = _field2E = _field30 = 0;
- _resNum = _field34 = _field36 = _field38 = _field3E = _field40 = 0;
+ _resNum = _field34 = _field36 = _field38 = _mapImagePitch = _field40 = 0;
}
MazeUI::~MazeUI() {
DEALLOCATE(_field16);
- DEALLOCATE(_field3A);
}
void MazeUI::synchronize(Serializer &s) {
@@ -1305,7 +1305,7 @@ void MazeUI::synchronize(Serializer &s) {
s.syncAsSint16LE(_field34);
s.syncAsSint16LE(_field36);
s.syncAsSint16LE(_field38);
- s.syncAsSint16LE(_field3E);
+ s.syncAsSint16LE(_mapImagePitch);
s.syncAsSint16LE(_field40);
}
@@ -1336,8 +1336,8 @@ void MazeUI::load(int resNum) {
_field12 = (_rect1.width() + _width - 1) / _width;
_field14 = (_rect1.height() + _height - 1) / _height;
- _field3E = (_field12 + 1) * _width;
- _field3A = ALLOCATE(_field3E * _height);
+ _mapImagePitch = (_field12 + 1) * _width;
+ _mapImage.create(_mapImagePitch, _height);
_rect2 = Rect(0, 0, _width * _field26, _height * _field28);
}
@@ -1350,9 +1350,7 @@ void MazeUI::clear() {
DEALLOCATE(_field16);
_field16 = NULL;
- DEALLOCATE(_field3A);
- _field3A = NULL;
-
+ _mapImage.clear();
}
int MazeUI::sub51AF8(Common::Point pt) {
@@ -1397,8 +1395,65 @@ bool MazeUI::setMazePosition(Common::Point pt) {
return retval;
}
-void MazeUI::mazeProc1() {
- warning("STUB: MazeUI::mazeProc1()");
+void MazeUI::draw() {
+ int xs = _rect1.left;
+ int yPos = 0;
+ int yInc;
+ Visage visage;
+
+ for (int yp = 0; yp < _field14; yp += yInc) {
+ int y = yp + _field30 / _height;
+
+ for (int idx = 0; idx > _field12; ++idx) {
+ int x = _field2E / _width + idx;
+
+ int cell = getCellValue(Common::Point(x, y));
+ if (cell >= 0) {
+ int frameNum = (cell % _field36) + 1;
+ int rlbNum = (cell % _field38) / _field36 + 1;
+ int resNum = _field34 + (cell / _field38);
+
+ visage.setVisage(resNum, rlbNum);
+ GfxSurface frame = visage.getFrame(frameNum);
+
+ _mapImage.copyFrom(frame, 0, idx);
+ } else {
+ GfxSurface emptyRect;
+ emptyRect.create(_width, _height);
+
+ _mapImage.copyFrom(emptyRect, 0, idx);
+ }
+ }
+
+ if (yPos == 0) {
+ yPos = _rect1.top;
+ yInc = _height - (_field30 % _height);
+
+ Rect srcBounds(Common::Rect(_field2E % _width, _field30 % _height,
+ _rect1.width(), yInc));
+ Rect destBounds(Common::Rect(_rect1.left, yPos, _rect1.width(), yInc));
+
+ R2_GLOBALS._screenSurface.copyFrom(_mapImage, srcBounds, destBounds);
+ } else {
+ if ((yPos + _height) < _rect1.bottom) {
+ yInc = _height;
+ } else {
+ yInc = _rect1.bottom - yPos;
+ }
+
+ Rect srcBounds(Common::Rect(0, _field2E, _rect1.width(), yInc));
+ Rect destBounds(Common::Rect(_rect1.left, yPos, _rect1.width(), yInc));
+ R2_GLOBALS._screenSurface.copyFrom(_mapImage, srcBounds, destBounds);
+ }
+ }
+}
+
+int MazeUI::getCellValue(const Common::Point &p) {
+ if (p.x < 0 || p.y < 0 || p.x >= _field26 || p.y >= _field28) {
+ return -1;
+ } else {
+ return READ_LE_UINT16(_field16 + (_field26 * p.y + p.x) * 2);
+ }
}
void MazeUI::setUIBounds(Rect rect) {
diff --git a/engines/tsage/ringworld2/ringworld2_logic.h b/engines/tsage/ringworld2/ringworld2_logic.h
index 5a9120f161..93b67a49d4 100644
--- a/engines/tsage/ringworld2/ringworld2_logic.h
+++ b/engines/tsage/ringworld2/ringworld2_logic.h
@@ -279,12 +279,13 @@ public:
class MazeUI: public SavedObject {
private:
void clear();
+ int getCellValue(const Common::Point &p);
public:
Rect _rect1;
Rect _rect2;
byte *_field16;
- byte *_field3A;
+ GfxSurface _mapImage;
int _field12;
int _field14;
@@ -298,19 +299,19 @@ public:
int _field34;
int _field36;
int _field38;
- int _field3E;
+ int _mapImagePitch;
int _field40;
public:
MazeUI();
- ~MazeUI();
+ virtual ~MazeUI();
void load(int resNum);
+ void draw();
virtual Common::String getClassName() { return "MazeUI"; }
void synchronize(Serializer &s);
int sub51AF8(Common::Point pt);
bool setMazePosition(Common::Point pt);
- void mazeProc1();
void setUIBounds(Rect rect);
int sub9EE22(int &arg1, int &arg2);
};
diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.cpp b/engines/tsage/ringworld2/ringworld2_scenes1.cpp
index 70a504aa71..1f46c4b6d3 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes1.cpp
+++ b/engines/tsage/ringworld2/ringworld2_scenes1.cpp
@@ -1139,7 +1139,7 @@ void Scene1200::postInit(SceneObjectList *OwnerList) {
_object1.load(1);
_object1.setMazePosition(Common::Point(R2_GLOBALS._v56AA2, R2_GLOBALS._v56AA4));
warning("int unk = set_pane_p(_paneNumber);");
- _object1.mazeProc1();
+ _object1.draw();
warning("set_pane_p(unk);");
R2_GLOBALS._player.enableControl();
@@ -1546,7 +1546,7 @@ void Scene1200::dispatch() {
if (_field41C != 0) {
_object1.setMazePosition(Common::Point(R2_GLOBALS._v56AA2, R2_GLOBALS._v56AA4));
warning("int unk = set_pane_p(_paneNumber);");
- _object1.mazeProc1();
+ _object1.draw();
warning("_gfxManager.sub294AC(unk);");
warning("tmpRect.sub14DF3();");
_field41C = 0;
@@ -1573,7 +1573,7 @@ void Scene1200::dispatch() {
}
_object1.setMazePosition(Common::Point(R2_GLOBALS._v56AA2, R2_GLOBALS._v56AA4));
warning("int unk = set_pane_p(_paneNumber);");
- _object1.mazeProc1();
+ _object1.draw();
warning("_gfxManager.sub294AC(unk);");
warning("tmpRect.sub14DF3();");
diff --git a/engines/tsage/ringworld2/ringworld2_scenes3.cpp b/engines/tsage/ringworld2/ringworld2_scenes3.cpp
index a8d3fd370b..baf68ed812 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes3.cpp
+++ b/engines/tsage/ringworld2/ringworld2_scenes3.cpp
@@ -3671,7 +3671,7 @@ void Scene3500::postInit(SceneObjectList *OwnerList) {
_action1._field24 = 0;
warning("gfx_set_pane_p()");
- _mazeUI.mazeProc1();
+ _mazeUI.draw();
warning("gfx_set_pane_p()");
_field1286 = 1;
@@ -4126,7 +4126,7 @@ void Scene3500::dispatch() {
_rotation->_idxChange = 0;
}
warning("gfx_set_pane_p");
- _mazeUI.mazeProc1();
+ _mazeUI.draw();
if (_field1284 != 0)
++_field1284;
}