aboutsummaryrefslogtreecommitdiff
path: root/engines/touche
diff options
context:
space:
mode:
authorEugene Sandulenko2007-11-25 10:27:50 +0000
committerEugene Sandulenko2007-11-25 10:27:50 +0000
commit8d228219c9121b0152fbf1f1fcab6a477574e9a2 (patch)
tree3aa964834553e77a9355662426e7f06c05a37cc8 /engines/touche
parent1266b7eb15ca9d095da8eef310726c3bf10899ad (diff)
downloadscummvm-rg350-8d228219c9121b0152fbf1f1fcab6a477574e9a2.tar.gz
scummvm-rg350-8d228219c9121b0152fbf1f1fcab6a477574e9a2.tar.bz2
scummvm-rg350-8d228219c9121b0152fbf1f1fcab6a477574e9a2.zip
Switch to our common drawLine routine
svn-id: r29635
Diffstat (limited to 'engines/touche')
-rw-r--r--engines/touche/graphics.cpp56
-rw-r--r--engines/touche/graphics.h12
-rw-r--r--engines/touche/menu.cpp9
3 files changed, 27 insertions, 50 deletions
diff --git a/engines/touche/graphics.cpp b/engines/touche/graphics.cpp
index cb5f60a4c9..13619eebd1 100644
--- a/engines/touche/graphics.cpp
+++ b/engines/touche/graphics.cpp
@@ -24,6 +24,7 @@
*/
#include "common/endian.h"
+#include "graphics/primitives.h"
#include "touche/graphics.h"
@@ -128,56 +129,15 @@ void Graphics::drawRect(uint8 *dst, int dstPitch, int x, int y, int w, int h, ui
const int y1 = y;
const int x2 = x + w - 1;
const int y2 = y + h - 1;
- drawLine(dst, dstPitch, x1, y1, x2, y1, color1);
- drawLine(dst, dstPitch, x1, y1, x1, y2, color1);
- drawLine(dst, dstPitch, x2, y1 + 1, x2, y2, color2);
- drawLine(dst, dstPitch, x1 + 1, y2, x2, y2, color2);
-}
-
-void Graphics::drawLine(uint8 *dst, int dstPitch, int x1, int y1, int x2, int y2, uint8 color) {
- assert(x1 >= 0 && y1 >= 0 && x2 >= 0 && y2 >= 0);
-
- dst += y1 * dstPitch + x1;
-
- int yInc, dy = y2 - y1;
- if (dy < 0) {
- dy = -dy;
- yInc = -dstPitch;
- } else {
- yInc = dstPitch;
- }
-
- int xInc, dx = x2 - x1;
- if (dx < 0) {
- dx = -dx;
- xInc = -1;
- } else {
- xInc = 1;
- }
+ drawProcP lineP;
- int step = 0;
+ lineP.dst = dst;
+ lineP.width = dstPitch;
- if (dx > dy) {
- for (int i = 0; i < dx + 1; ++i) {
- *dst = color;
- dst += xInc;
- step += dy;
- if (step > dx) {
- step -= dx;
- dst += yInc;
- }
- }
- } else {
- for (int i = 0; i < dy + 1; ++i) {
- *dst = color;
- dst += yInc;
- step += dx;
- if (step > 0) {
- step -= dy;
- dst += xInc;
- }
- }
- }
+ ::Graphics::drawLine(x1, y1, x2, y1, color1, drawProc, &lineP);
+ ::Graphics::drawLine(x1, y1, x1, y2, color1, drawProc, &lineP);
+ ::Graphics::drawLine(x2, y1 + 1, x2, y2, color2, drawProc, &lineP);
+ ::Graphics::drawLine(x1 + 1, y2, x2, y2, color2, drawProc, &lineP);
}
void Graphics::copyRect(uint8 *dst, int dstPitch, int dstX, int dstY, const uint8 *src, int srcPitch, int srcX, int srcY, int w, int h, int flags) {
diff --git a/engines/touche/graphics.h b/engines/touche/graphics.h
index 6b4072d896..74928cefcf 100644
--- a/engines/touche/graphics.h
+++ b/engines/touche/graphics.h
@@ -30,6 +30,11 @@
namespace Touche {
+struct drawProcP {
+ uint8 *dst;
+ int width;
+};
+
class Graphics {
public:
@@ -44,10 +49,15 @@ public:
static int drawChar16(uint8 *dst, int dstPitch, uint8 chr, int x, int y, uint16 color);
static void fillRect(uint8 *dst, int dstPitch, int x, int y, int w, int h, uint8 color);
static void drawRect(uint8 *dst, int dstPitch, int x, int y, int w, int h, uint8 color1, uint8 color2);
- static void drawLine(uint8 *dst, int dstPitch, int x1, int y1, int x2, int y2, uint8 color);
static void copyRect(uint8 *dst, int dstPitch, int dstX, int dstY, const uint8 *src, int srcPitch, int srcX, int srcY, int w, int h, int flags = 0);
static void copyMask(uint8 *dst, int dstPitch, int dstX, int dstY, const uint8 *src, int srcPitch, int srcX, int srcY, int w, int h, uint8 fillColor);
+ static void drawProc(int x, int y, int c, void *data) {
+ drawProcP *param = (drawProcP *)data;
+
+ *(param->dst + y * param->width + x) = c;
+ }
+
private:
/* font data for english version */
diff --git a/engines/touche/menu.cpp b/engines/touche/menu.cpp
index 2dacab4132..1c3dfe87ee 100644
--- a/engines/touche/menu.cpp
+++ b/engines/touche/menu.cpp
@@ -28,6 +28,8 @@
#include "common/system.h"
#include "common/savefile.h"
+#include "graphics/primitives.h"
+
#include "touche/graphics.h"
#include "touche/midi.h"
#include "touche/touche.h"
@@ -134,12 +136,17 @@ static void drawArrow(uint8 *dst, int dstPitch, int x, int y, int delta, uint8 c
{ -9, 0, 0, -9 },
{ 0, -9, 9, 0 }
};
+ drawProcP lineP;
+
+ lineP.dst = dst;
+ lineP.width = dstPitch;
+
for (uint i = 0; i < 7; ++i) {
const int x1 = x + arrowCoordsTable[i][0];
const int y1 = y + arrowCoordsTable[i][1] * delta;
const int x2 = x + arrowCoordsTable[i][2];
const int y2 = y + arrowCoordsTable[i][3] * delta;
- Graphics::drawLine(dst, dstPitch, x1, y1, x2, y2, color);
+ ::Graphics::drawLine(x1, y1, x2, y2, color, Graphics::drawProc, &lineP);
}
}