aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2013-09-28 14:31:54 +0200
committerStrangerke2013-09-28 14:31:54 +0200
commit0edb0e0434359d5ced78fa4f0a32ed1dafc51103 (patch)
treee066392f1df4517255ac7fff6c52c31ef5211616
parentfdbcb5f785dcc4a4bf8b178c11f4a92d07467e6c (diff)
downloadscummvm-rg350-0edb0e0434359d5ced78fa4f0a32ed1dafc51103.tar.gz
scummvm-rg350-0edb0e0434359d5ced78fa4f0a32ed1dafc51103.tar.bz2
scummvm-rg350-0edb0e0434359d5ced78fa4f0a32ed1dafc51103.zip
AVALANCHE: Set the Magic surface as private, some associated rework
-rw-r--r--engines/avalanche/animation.cpp10
-rw-r--r--engines/avalanche/avalot.cpp16
-rw-r--r--engines/avalanche/graphics.cpp25
-rw-r--r--engines/avalanche/graphics.h6
4 files changed, 33 insertions, 24 deletions
diff --git a/engines/avalanche/animation.cpp b/engines/avalanche/animation.cpp
index 5d60a73d14..2a309f31a9 100644
--- a/engines/avalanche/animation.cpp
+++ b/engines/avalanche/animation.cpp
@@ -379,16 +379,8 @@ byte Animation::checkFeet(int16 x1, int16 x2, int16 oy, int16 y, byte yl) {
int16 minY = MIN(oy, y) + yl;
int16 maxY = MAX(oy, y) + yl;
- byte returnColor = 0;
- for (int16 i = x1; i <= x2; i++) {
- for (int16 j = minY; j <= maxY; j++) {
- byte actColor = *(byte *)_vm->_graphics->_magics.getBasePtr(i, j);
- returnColor = MAX(returnColor, actColor);
- }
- }
-
- return returnColor;
+ return _vm->_graphics->getAlsoColor(x1, minY, x2, maxY);
}
byte Animation::geidaPed(byte ped) {
diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp
index bcd501001e..7527bb6371 100644
--- a/engines/avalanche/avalot.cpp
+++ b/engines/avalanche/avalot.cpp
@@ -543,14 +543,24 @@ void AvalancheEngine::loadAlso(byte num) {
for (int i = 0; i < 26; i++)
_flags += file.readByte();
- int16 listen_length = file.readByte();
+ int16 size = file.readByte();
_listen.clear();
- for (int i = 0; i < listen_length; i++)
+ for (int i = 0; i < size; i++)
_listen += file.readByte();
- _graphics->drawAlsoLines();
+ _graphics->prepareAlsoDisplay();
+
+ CursorMan.showMouse(false);
+ for (int i = 0; i < _lineNum; i++) {
+ // We had to check if the lines are within the borders of the screen.
+ if ((_lines[i]._x1 >= 0) && (_lines[i]._x1 < kScreenWidth) && (_lines[i]._y1 >= 0) && (_lines[i]._y1 < kScreenHeight)
+ && (_lines[i]._x2 >= 0) && (_lines[i]._x2 < kScreenWidth) && (_lines[i]._y2 >= 0) && (_lines[i]._y2 < kScreenHeight))
+ _graphics->drawAlsoLines(_lines[i]._x1, _lines[i]._y1, _lines[i]._x2, _lines[i]._y2, _lines[i]._color);
+ }
+ CursorMan.showMouse(true);
file.close();
+
unScramble();
for (int i = 0; i <= alsoNum; i++) {
tmpStr = Common::String::format(",%s,", _also[i][0]->c_str());
diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp
index 9c7c07e748..12e43671ee 100644
--- a/engines/avalanche/graphics.cpp
+++ b/engines/avalanche/graphics.cpp
@@ -379,24 +379,29 @@ void Graphics::drawDirection(int index, int x, int y) {
return picture;
}
-void Graphics::drawAlsoLines() {
- CursorMan.showMouse(false);
-
+void Graphics::prepareAlsoDisplay() {
_magics.fillRect(Common::Rect(0, 0, 640, 200), 0);
_magics.frameRect(Common::Rect(0, 45, 640, 161), 15);
+}
- for (int i = 0; i < _vm->_lineNum; i++) {
- // We had to check if the lines are within the borders of the screen.
- if ((_vm->_lines[i]._x1 >= 0) && (_vm->_lines[i]._x1 < kScreenWidth) && (_vm->_lines[i]._y1 >= 0) && (_vm->_lines[i]._y1 < kScreenHeight)
- && (_vm->_lines[i]._x2 >= 0) && (_vm->_lines[i]._x2 < kScreenWidth) && (_vm->_lines[i]._y2 >= 0) && (_vm->_lines[i]._y2 < kScreenHeight))
- _magics.drawLine(_vm->_lines[i]._x1, _vm->_lines[i]._y1, _vm->_lines[i]._x2, _vm->_lines[i]._y2, _vm->_lines[i]._color);
+void Graphics::drawAlsoLines(int x1, int y1, int x2, int y2, Color color) {
+ _magics.drawLine(x1, y1, x2, y2, color);
+}
+
+byte Graphics::getAlsoColor(int x1, int y1, int x2, int y2) {
+ byte returnColor = 0;
+ for (int16 i = x1; i <= x2; i++) {
+ for (int16 j = y1; j <= y2; j++) {
+ byte actColor = *(byte *)_vm->_graphics->_magics.getBasePtr(i, j);
+ returnColor = MAX(returnColor, actColor);
+ }
}
- CursorMan.showMouse(true);
+ return returnColor;
}
void Graphics::drawSprite(const SpriteInfo &sprite, byte picnum, int16 x, int16 y) {
- // First we make the pixels of the spirte blank.
+ // First we make the pixels of the sprite blank.
for (int j = 0; j < sprite._yLength; j++) {
for (int i = 0; i < sprite._xLength; i++) {
if (((*sprite._sil[picnum])[j][i / 8] >> ((7 - i % 8)) & 1) == 0)
diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h
index 3df59727a5..b1b65edf84 100644
--- a/engines/avalanche/graphics.h
+++ b/engines/avalanche/graphics.h
@@ -58,7 +58,6 @@ class Graphics {
public:
::Graphics::Surface _surface;
::Graphics::Surface _background;
- ::Graphics::Surface _magics; // Lucerna::draw_also_lines() draws the "magical" lines here. Further information: https://github.com/urukgit/avalot/wiki/Also
::Graphics::Surface _scrolls;
Graphics(AvalancheEngine *vm);
@@ -79,7 +78,9 @@ public:
void drawText(::Graphics::Surface &surface, const Common::String &text, FontType font, byte fontHeight, int16 x, int16 y, Color color);
void drawDigit(int index, int x, int y);
void drawDirection(int index, int x, int y);
- void drawAlsoLines();
+ void prepareAlsoDisplay();
+ void drawAlsoLines(int x1, int y1, int x2, int y2, Color color);
+ byte getAlsoColor(int x1, int y1, int x2, int y2);
// The caller has to .free() the returned Surfaces!!!
// Further information about these two: http://www.shikadi.net/moddingwiki/Raw_EGA_data
@@ -104,6 +105,7 @@ private:
// The 8 = number of bits in a byte, and 12080 comes from Lucerna::load().
static const byte kEgaPaletteIndex[16];
+ ::Graphics::Surface _magics; // Lucerna::draw_also_lines() draws the "magical" lines here. Further information: https://github.com/urukgit/avalot/wiki/Also
::Graphics::Surface _digits[10]; // digitsize and rwlitesize are defined in loadDigits() !!!
::Graphics::Surface _directions[9]; // Maybe it will be needed to move them to the class itself instead.
::Graphics::Surface _screen; // Only used in refreshScreen() to make it more optimized. (No recreation of it at every call of the function.)