[Scummvm-git-logs] scummvm master -> f4af269ba21348bcb7db4912e6642b40d8eb202a
dreammaster
paulfgilbert at gmail.com
Wed Jun 10 01:58:54 UTC 2020
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
226fbb2cf7 GLK: COMPREHEND: Improvement on floodfill
a22455377d GLK: COMPREHEND: Proper implementaiton of shape rendering
f4af269ba2 GLK: COMPREHEND: Implement draw shape to match the original
Commit: 226fbb2cf748792b552013670c5bb7d4323c97b8
https://github.com/scummvm/scummvm/commit/226fbb2cf748792b552013670c5bb7d4323c97b8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-09T18:58:29-07:00
Commit Message:
GLK: COMPREHEND: Improvement on floodfill
Changed paths:
engines/glk/comprehend/draw_surface.cpp
engines/glk/comprehend/draw_surface.h
diff --git a/engines/glk/comprehend/draw_surface.cpp b/engines/glk/comprehend/draw_surface.cpp
index d8d81a7980..dc57b3758c 100644
--- a/engines/glk/comprehend/draw_surface.cpp
+++ b/engines/glk/comprehend/draw_surface.cpp
@@ -211,7 +211,7 @@ void Surface::drawLine(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color) {
int xDiff = x1 - x2, yDiff = y1 - y2;
// Draw pixel at starting point
- drawPixel(x1, y1);
+ drawPixel(x1, y1, color);
// Figure out the deltas movement for creating the line
if (xDiff < 0) {
@@ -265,6 +265,7 @@ void Surface::drawFilledBox(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color
}
void Surface::drawShape(int16 x, int16 y, int shape_type, uint32 fill_color) {
+ return;//***DEBUG****
int i, j;
switch (shape_type) {
@@ -426,9 +427,17 @@ bool FloodFillSurface::isPixelWhite(int16 x, int16 y) const {
}
}
-void FloodFillSurface::floodFill(int16 x, int16 y, uint32 fillColor) {
- int x1, x2, i;
+#define SCALE 4
+void FloodFillSurface::dumpToScreen() {
+ Graphics::ManagedSurface s(w * SCALE, h * SCALE, format);
+ s.transBlitFrom(*this, Common::Rect(0, 0, w, h), Common::Rect(0, 0, w * SCALE,h * SCALE), 0x888888);
+ g_system->copyRectToScreen(s.getPixels(), s.pitch, 0, 0,
+ MIN(s.w, (uint16)g_system->getWidth()), MIN(s.h, (uint16)g_system->getHeight()));
+ g_system->updateScreen();
+}
+
+void FloodFillSurface::floodFill(int16 x, int16 y, uint32 fillColor) {
if (y == this->h)
y = this->h - 1;
else if (y > this->h)
@@ -437,6 +446,12 @@ void FloodFillSurface::floodFill(int16 x, int16 y, uint32 fillColor) {
if (!isPixelWhite(x, y))
return;
+ floodFillRow(x, y, fillColor);
+}
+
+void FloodFillSurface::floodFillRow(int16 x, int16 y, uint32 fillColor) {
+ int x1, x2, i;
+
// Left end of scanline
for (x1 = x; x1 > 0; x1--)
if (!isPixelWhite(x1 - 1, y))
@@ -449,18 +464,20 @@ void FloodFillSurface::floodFill(int16 x, int16 y, uint32 fillColor) {
drawLine(x1, y, x2, y, fillColor);
+ //dumpToScreen();
+
// Scanline above
if (y > 0) {
- for (i = x1; i < x2; i++)
+ for (i = x1; i <= x2; i++)
if (isPixelWhite(i, y - 1))
- floodFill(i, y - 1, fillColor);
+ floodFillRow(i, y - 1, fillColor);
}
// Scanline below
if (y < (this->h - 1)) {
- for (i = x1; i < x2; i++)
+ for (i = x1; i <= x2; i++)
if (isPixelWhite(i, y + 1))
- floodFill(i, y + 1, fillColor);
+ floodFillRow(i, y + 1, fillColor);
}
}
diff --git a/engines/glk/comprehend/draw_surface.h b/engines/glk/comprehend/draw_surface.h
index 635c0b1948..f33a5085a0 100644
--- a/engines/glk/comprehend/draw_surface.h
+++ b/engines/glk/comprehend/draw_surface.h
@@ -100,6 +100,9 @@ public:
class FloodFillSurface : public Surface {
private:
bool isPixelWhite(int16 x, int16 y) const;
+
+ void floodFillRow(int16 x, int16 y, uint32 fillColor);
+ void dumpToScreen();
public:
void floodFill(int16 x, int16 y, uint32 fillColor);
};
Commit: a22455377d88cf8234e8193fa7a2d85d29ad2e01
https://github.com/scummvm/scummvm/commit/a22455377d88cf8234e8193fa7a2d85d29ad2e01
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-09T18:58:29-07:00
Commit Message:
GLK: COMPREHEND: Proper implementaiton of shape rendering
Changed paths:
engines/glk/comprehend/pics.cpp
diff --git a/engines/glk/comprehend/pics.cpp b/engines/glk/comprehend/pics.cpp
index e97e7ca678..5b262657b0 100644
--- a/engines/glk/comprehend/pics.cpp
+++ b/engines/glk/comprehend/pics.cpp
@@ -152,7 +152,7 @@ bool Pics::ImageFile::doImageOp(Pics::ImageContext *ctx) const {
}
debugC(kDebugGraphics, "draw_char(%c)", a);
- ctx->_font->drawChar(ctx->_drawSurface, a, ctx->_textX, ctx->_textY, ctx->_penColor);
+ ctx->_font->drawChar(ctx->_drawSurface, a, ctx->_textX, ctx->_textY, ctx->_fillColor);
ctx->_textX += ctx->_font->getCharWidth(a);
break;
Commit: f4af269ba21348bcb7db4912e6642b40d8eb202a
https://github.com/scummvm/scummvm/commit/f4af269ba21348bcb7db4912e6642b40d8eb202a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-09T18:58:29-07:00
Commit Message:
GLK: COMPREHEND: Implement draw shape to match the original
Changed paths:
engines/glk/comprehend/draw_surface.cpp
engines/glk/comprehend/draw_surface.h
engines/glk/comprehend/pics.cpp
engines/glk/comprehend/pics.h
diff --git a/engines/glk/comprehend/draw_surface.cpp b/engines/glk/comprehend/draw_surface.cpp
index dc57b3758c..dbaaa08642 100644
--- a/engines/glk/comprehend/draw_surface.cpp
+++ b/engines/glk/comprehend/draw_surface.cpp
@@ -169,6 +169,41 @@ const uint32 *Surface::COLOR_TABLES[2] = {
COLOR_TABLE_1,
};
+static const byte SHAPE_DATA[32][8] = {
+ { 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0x80 },
+ { 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 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------------------------------------------------------*/
void Surface::reset() {
@@ -264,110 +299,29 @@ void Surface::drawFilledBox(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color
fillRect(r, color);
}
-void Surface::drawShape(int16 x, int16 y, int shape_type, uint32 fill_color) {
- return;//***DEBUG****
- int i, j;
-
- switch (shape_type) {
- case SHAPE_PIXEL:
- x += 7;
- y += 7;
- drawPixel(x, y, fill_color);
- break;
-
- case SHAPE_BOX:
- x += 6;
- y += 7;
- drawFilledBox(x, y, x + 2, y + 2, fill_color);
- break;
-
- case SHAPE_CIRCLE_TINY:
- x += 5;
- y += 5;
- drawFilledBox(x + 1, y, x + 3, y + 4, fill_color);
- drawFilledBox(x, y + 1, x + 4, y + 3, fill_color);
- break;
-
- case SHAPE_CIRCLE_SMALL:
- x += 4;
- y += 4;
- drawFilledBox(x + 1, y, x + 5, y + 6, fill_color);
- drawFilledBox(x, y + 1, x + 6, y + 5, fill_color);
- break;
-
- case SHAPE_CIRCLE_MED:
- x += 1;
- y += 1;
- drawFilledBox(x + 1,
- y + 1,
- x + 1 + (2 + 4 + 2),
- y + 1 + (2 + 4 + 2),
- fill_color);
- drawFilledBox(x + 3,
- y,
- x + 3 + 4,
- y + (1 + 2 + 4 + 2 + 1),
- fill_color);
- drawFilledBox(x,
- y + 3,
- x + (1 + 2 + 4 + 2 + 1),
- y + 3 + 4,
- fill_color);
- break;
-
- case SHAPE_CIRCLE_LARGE:
- drawFilledBox(x + 2,
- y + 1,
- x + 2 + (3 + 4 + 3),
- y + 1 + (1 + 3 + 4 + 3 + 1),
- fill_color);
- drawFilledBox(x + 1,
- y + 2,
- x + 1 + (1 + 3 + 4 + 3 + 1),
- y + 2 + (3 + 4 + 3),
- fill_color);
- drawFilledBox(x + 5,
- y,
- x + 5 + 4,
- y + 1 + 1 + 3 + 4 + 3 + 1 + 1,
- fill_color);
- drawFilledBox(x,
- y + 5,
- x + 1 + 1 + 3 + 4 + 3 + 1 + 1,
- y + 5 + 4,
- fill_color);
- break;
-
- case SHAPE_A:
- /* FIXME - very large circle? */
- break;
-
- case SHAPE_SPRAY: {
- char spray[13][13] = {
- {0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0},
- {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0},
- {0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1},
- {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
- {1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0},
- {0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0},
- {1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0},
- {0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0},
- {1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0},
- {0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0},
- {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0},
- };
- for (i = 0; i < 13; i++)
- for (j = 0; j < 13; j++)
- if (spray[i][j])
- drawPixel(x + i, y + j, fill_color);
- break;
- }
+void Surface::drawShape(int16 x, int16 y, Shape shapeType, uint32 fillColor) {
+ uint shapeNum = (uint)shapeType * 4;
+
+ // Outer loop to draw the shape across a 2x2 grid of 8x8 sub-shapes
+ for (int shapeX = 0; shapeX <= 8; shapeX += 8) {
+ for (int shapeY = 0; shapeY <= 8; shapeY += 8, ++shapeNum) {
+ // Inner loop for character
+ for (int charY = 0; charY < 8; ++charY) {
+ int yp = y + shapeY + charY;
+ if (yp < 0 || yp >= this->h)
+ continue;
- default:
- /* Unknown shape */
- break;
+ int xp = x + shapeX;
+ uint32 *lineP = (uint32 *)getBasePtr(xp, yp);
+ byte bits = SHAPE_DATA[shapeNum][charY];
+
+ for (int charX = 0; charX < 8; ++lineP, ++charX, ++xp, bits <<= 1) {
+ if (xp >= 0 && xp < this->w && (bits & 0x80) != 0)
+ *lineP = fillColor;
+ }
+ }
+
+ }
}
}
diff --git a/engines/glk/comprehend/draw_surface.h b/engines/glk/comprehend/draw_surface.h
index f33a5085a0..88d0bdc42e 100644
--- a/engines/glk/comprehend/draw_surface.h
+++ b/engines/glk/comprehend/draw_surface.h
@@ -63,6 +63,18 @@ namespace Comprehend {
#define G_COLOR_BROWN1 0x7a5200ff
#define G_COLOR_BROWN2 0x663300ff
+enum Shape {
+ SHAPE_PIXEL = 0,
+ SHAPE_BOX = 1,
+ SHAPE_CIRCLE_TINY = 2,
+ SHAPE_CIRCLE_SMALL = 3,
+ SHAPE_CIRCLE_MED = 4,
+ SHAPE_CIRCLE_LARGE = 5,
+ SHAPE_A = 6,
+ SHAPE_SPRAY = 7
+};
+
+
class Surface : public Graphics::ManagedSurface {
private:
static const uint32 PEN_COLORS[8];
@@ -89,7 +101,7 @@ public:
void drawLine(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color);
void drawBox(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color);
void drawFilledBox(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color);
- void drawShape(int16 x, int16 y, int shape_type, uint32 fill_color);
+ void drawShape(int16 x, int16 y, Shape shapeType, uint32 fill_color);
void drawPixel(int16 x, int16 y, uint32 color);
uint32 getPixelColor(int16 x, int16 y) const;
void clearScreen(uint32 color);
diff --git a/engines/glk/comprehend/pics.cpp b/engines/glk/comprehend/pics.cpp
index 5b262657b0..2fa555b57b 100644
--- a/engines/glk/comprehend/pics.cpp
+++ b/engines/glk/comprehend/pics.cpp
@@ -216,7 +216,6 @@ bool Pics::ImageFile::doImageOp(Pics::ImageContext *ctx) const {
case OPCODE_DRAW_SHAPE:
a = imageGetOperand(ctx) + (param & 1 ? 256 : 0);
b = imageGetOperand(ctx);
-
debugC(kDebugGraphics, "draw_shape(%d, %d), style=%.2x, fill=%.2x",
a, b, ctx->_shape, ctx->_fillColor);
diff --git a/engines/glk/comprehend/pics.h b/engines/glk/comprehend/pics.h
index 6cb00acbbd..503296f115 100644
--- a/engines/glk/comprehend/pics.h
+++ b/engines/glk/comprehend/pics.h
@@ -42,17 +42,6 @@ enum {
TITLE_IMAGE = 9999
};
-enum Shape {
- SHAPE_PIXEL = 0,
- SHAPE_BOX = 1,
- SHAPE_CIRCLE_TINY = 2,
- SHAPE_CIRCLE_SMALL = 3,
- SHAPE_CIRCLE_MED = 4,
- SHAPE_CIRCLE_LARGE = 5,
- SHAPE_A = 6,
- SHAPE_SPRAY = 7
-};
-
class Pics : public Common::Archive {
struct ImageContext {
Common::File _file;
More information about the Scummvm-git-logs
mailing list