[Scummvm-git-logs] scummvm master -> ce476064659aeba010a8c43df44c61f5e0021c0c
dreammaster
paulfgilbert at gmail.com
Fri Jun 5 03:12:14 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ec73cfe3ad GLK: COMPREHEND: Cleanup of drawing interpreter loop
ce47606465 GLK: COMPREHEND: Draw opcode B is for drawing a circle
Commit: ec73cfe3ad0cf867501e10dacb5cee9d27db81e1
https://github.com/scummvm/scummvm/commit/ec73cfe3ad0cf867501e10dacb5cee9d27db81e1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-04T20:10:57-07:00
Commit Message:
GLK: COMPREHEND: Cleanup of drawing interpreter loop
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 5cec0a4ea3..6827741064 100644
--- a/engines/glk/comprehend/draw_surface.cpp
+++ b/engines/glk/comprehend/draw_surface.cpp
@@ -191,8 +191,8 @@ void DrawSurface::setColorTable(uint index) {
_colorTable = COLOR_TABLES[index];
}
-uint DrawSurface::getPenColor(uint8 opcode) const {
- return PEN_COLORS[opcode - IMAGE_OP_PEN_COLOR_A];
+uint DrawSurface::getPenColor(uint8 param) const {
+ return PEN_COLORS[param];
}
uint32 DrawSurface::getFillColor(uint8 index) {
@@ -212,56 +212,56 @@ void DrawSurface::setColor(uint32 color) {
_renderColor = color;
}
-void DrawSurface::drawLine(uint16 x1, uint16 y1, uint16 x2, uint16 y2, uint32 color) {
+void DrawSurface::drawLine(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color) {
setColor(color);
Graphics::ManagedSurface::drawLine(x1, y1, x2, y2, _renderColor);
}
-void DrawSurface::drawBox(uint16 x1, uint16 y1, uint16 x2, uint16 y2,
+void DrawSurface::drawBox(int16 x1, int16 y1, int16 x2, int16 y2,
uint32 color) {
setColor(color);
- Common::Rect r(x1, y1, x2, y2);
+ Common::Rect r(x1, y1, x2 + 1, y2 + 1);
frameRect(r, _renderColor);
}
-void DrawSurface::drawFilledBox(uint16 x1, uint16 y1,
- uint16 x2, uint16 y2, uint32 color) {
+void DrawSurface::drawFilledBox(int16 x1, int16 y1,
+ int16 x2, int16 y2, uint32 color) {
setColor(color);
- Common::Rect r(x1, y1, x2, y2);
+ Common::Rect r(x1, y1, x2 + 1, y2 + 1);
fillRect(r, _renderColor);
}
-void DrawSurface::drawShape(int x, int y, int shape_type, uint32 fill_color) {
+void DrawSurface::drawShape(int16 x, int16 y, int shape_type, uint32 fill_color) {
int i, j;
switch (shape_type) {
- case IMAGE_OP_SHAPE_PIXEL:
+ case SHAPE_PIXEL:
x += 7;
y += 7;
drawPixel(x, y, fill_color);
break;
- case IMAGE_OP_SHAPE_BOX:
+ case SHAPE_BOX:
x += 6;
y += 7;
drawFilledBox(x, y, x + 2, y + 2, fill_color);
break;
- case IMAGE_OP_SHAPE_CIRCLE_TINY:
+ 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 IMAGE_OP_SHAPE_CIRCLE_SMALL:
+ 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 IMAGE_OP_SHAPE_CIRCLE_MED:
+ case SHAPE_CIRCLE_MED:
x += 1;
y += 1;
drawFilledBox(x + 1,
@@ -281,7 +281,7 @@ void DrawSurface::drawShape(int x, int y, int shape_type, uint32 fill_color) {
fill_color);
break;
- case IMAGE_OP_SHAPE_CIRCLE_LARGE:
+ case SHAPE_CIRCLE_LARGE:
drawFilledBox(x + 2,
y + 1,
x + 2 + (3 + 4 + 3),
@@ -304,11 +304,11 @@ void DrawSurface::drawShape(int x, int y, int shape_type, uint32 fill_color) {
fill_color);
break;
- case IMAGE_OP_SHAPE_A:
+ case SHAPE_A:
/* FIXME - very large circle? */
break;
- case IMAGE_OP_SHAPE_SPRAY: {
+ 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},
@@ -337,7 +337,7 @@ void DrawSurface::drawShape(int x, int y, int shape_type, uint32 fill_color) {
}
}
-void DrawSurface::floodFill(int x, int y, uint32 fill_color, uint32 old_color) {
+void DrawSurface::floodFill(int16 x, int16 y, uint32 fill_color, uint32 old_color) {
int x1, x2, i;
if (getPixelColor(x, y) != old_color || fill_color == old_color)
@@ -366,13 +366,17 @@ void DrawSurface::floodFill(int x, int y, uint32 fill_color, uint32 old_color) {
floodFill(i, y + 1, fill_color, old_color);
}
-void DrawSurface::drawPixel(uint16 x, uint16 y, uint32 color) {
+void DrawSurface::drawPixel(int16 x, int16 y, uint32 color) {
setColor(color);
+ drawPixel(x, y);
+}
+
+void DrawSurface::drawPixel(int16 x, int16 y) {
uint32 *ptr = (uint32 *)getBasePtr(x, y);
*ptr = _renderColor;
}
-uint32 DrawSurface::getPixelColor(uint16 x, uint16 y) {
+uint32 DrawSurface::getPixelColor(int16 x, int16 y) {
uint32 *ptr = (uint32 *)getBasePtr(x, y);
return *ptr;
}
@@ -382,5 +386,37 @@ void DrawSurface::clearScreen(uint32 color) {
fillRect(Common::Rect(0, 0, this->w, this->h), _renderColor);
}
+void DrawSurface::opcodeB(int16 x, int16 y, int8 param) {
+ int invert = -param;
+ int delta = 0;
+
+ do {
+ opcodeBPoint(x - delta, y - param);
+ opcodeBPoint(x + delta, y - param);
+ opcodeBPoint(x + delta, y + param);
+ opcodeBPoint(x - delta, y + param);
+
+ opcodeBPoint(x + param, y - delta);
+ opcodeBPoint(x - param, y - delta);
+ opcodeBPoint(x - param, y + delta);
+ opcodeBPoint(x + param, y + delta);
+
+ invert += (delta * 2) + 1;
+ ++delta;
+ if (!((uint)invert & 0x80)) {
+ invert += 2;
+ param <<= 1;
+ invert -= param;
+ param >>= 1;
+ --param;
+ }
+ } while (param >= delta);
+}
+
+void DrawSurface::opcodeBPoint(int16 x, int16 y) {
+ if (x < 280 && y < 160)
+ drawPixel(x, y);
+}
+
} // namespace Comprehend
} // namespace Glk
diff --git a/engines/glk/comprehend/draw_surface.h b/engines/glk/comprehend/draw_surface.h
index 6d2f08f78e..35d2b2d32c 100644
--- a/engines/glk/comprehend/draw_surface.h
+++ b/engines/glk/comprehend/draw_surface.h
@@ -84,18 +84,21 @@ public:
void reset();
void setColorTable(uint index);
- uint getPenColor(uint8 opcode) const;
+ uint getPenColor(uint8 param) const;
uint32 getFillColor(uint8 index);
void setColor(uint32 color);
- void drawLine(uint16 x1, uint16 y1, uint16 x2, uint16 y2, uint32 color);
- void drawBox(uint16 x1, uint16 y1, uint16 x2, uint16 y2, uint32 color);
- void drawFilledBox(uint16 x1, uint16 y1, uint16 x2, uint16 y2, uint32 color);
- void drawShape(int x, int y, int shape_type, uint32 fill_color);
- void floodFill(int x, int y, uint32 fill_color, uint32 old_color);
- void drawPixel(uint16 x, uint16 y, uint32 color);
- uint32 getPixelColor(uint16 x, uint16 y);
+ 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 floodFill(int16 x, int16 y, uint32 fill_color, uint32 old_color);
+ void drawPixel(int16 x, int16 y);
+ void drawPixel(int16 x, int16 y, uint32 color);
+ uint32 getPixelColor(int16 x, int16 y);
void clearScreen(uint32 color);
+ void opcodeB(int16 x, int16 y, int8 param);
+ void opcodeBPoint(int16 x, int16 y);
};
} // namespace Comprehend
diff --git a/engines/glk/comprehend/pics.cpp b/engines/glk/comprehend/pics.cpp
index c29a2f89e1..3065e34e80 100644
--- a/engines/glk/comprehend/pics.cpp
+++ b/engines/glk/comprehend/pics.cpp
@@ -34,6 +34,31 @@ namespace Comprehend {
#define IMAGES_PER_FILE 16
+enum Opcode {
+ OPCODE_END = 0,
+ OPCODE_SET_TEXT_POS = 1,
+ OPCODE_SET_PEN_COLOR = 2,
+ OPCODE_TEXT_CHAR1 = 3,
+ OPCODE_SET_SHAPE = 4,
+ OPCODE_TEXT_CHAR2 = 5,
+ OPCODE_SET_FILL_COLOR = 6,
+ OPCODE_END2 = 7,
+ OPCODE_MOVE_TO = 8,
+ OPCODE_DRAW_BOX = 9,
+ OPCODE_DRAW_LINE = 10,
+ OPCODE_B = 11,
+ OPCODE_DRAW_SHAPE = 12,
+ OPCODE_DELAY = 13,
+ OPCODE_PAINT = 14,
+ OPCODE_RESET = 15
+};
+
+enum SpecialOpcode {
+ RESETOP_0 = 0,
+ RESETOP_RESET = 1,
+ RESETOP_OO_TOPOS_UNKNOWN = 3
+};
+
/*-------------------------------------------------------*/
Pics::ImageFile::ImageFile(const Common::String &filename) {
@@ -89,108 +114,119 @@ bool Pics::ImageFile::doImageOp(Pics::ImageContext *ctx) const {
opcode = ctx->_file.readByte();
debugCN(kDebugGraphics, " %.4x [%.2x]: ", ctx->_file.pos() - 1, opcode);
+ byte param = opcode & 0xf;
+ opcode >>= 4;
+
switch (opcode) {
- case IMAGE_OP_SCENE_END:
- case IMAGE_OP_EOF:
- debugC(kDebugGraphics, "end");
+ case OPCODE_END:
+ case OPCODE_END2:
+ // End of the rendering
+ debugC(kDebugGraphics, "End of image");
return true;
- case IMAGE_OP_PEN_COLOR_A:
- case IMAGE_OP_PEN_COLOR_B:
- case IMAGE_OP_PEN_COLOR_C:
- case IMAGE_OP_PEN_COLOR_D:
- case IMAGE_OP_PEN_COLOR_E:
- case IMAGE_OP_PEN_COLOR_F:
- case IMAGE_OP_PEN_COLOR_G:
- case IMAGE_OP_PEN_COLOR_H:
+ case OPCODE_SET_TEXT_POS:
+ a = imageGetOperand(ctx) + (param & 1 ? 256 : 0);
+ b = imageGetOperand(ctx);
+ debugC(kDebugGraphics, "set_text_pos(%d, %d)", a, b);
+
+ ctx->_textX = a;
+ ctx->_textY = b;
+ break;
+
+ case OPCODE_SET_PEN_COLOR:
debugC(kDebugGraphics, "set_pen_color(%.2x)", opcode);
- ctx->_penColor = ctx->_drawSurface->getPenColor(opcode);
+ ctx->_penColor = ctx->_drawSurface->getPenColor(param);
break;
- case IMAGE_OP_DRAW_LINE:
- case IMAGE_OP_DRAW_LINE_FAR:
+ case OPCODE_TEXT_CHAR1:
+ case OPCODE_TEXT_CHAR2:
+ // In Transylvania at least, the CHAR1 opcode sets a flag that gets
+ // cleared when the character drawing is done, but is never used.
+ // So the two opcodes are functionally identical
a = imageGetOperand(ctx);
- b = imageGetOperand(ctx);
+ if (a < 0x20 || a >= 0x7f) {
+ warning("Invalid character - %c", a);
+ a = '?';
+ }
- if (opcode & 0x1)
- a += 255;
+ debugC(kDebugGraphics, "draw_char(%c)", a);
+ ctx->_font->drawChar(ctx->_drawSurface, a, ctx->_textX, ctx->_textY, ctx->_penColor);
+ ctx->_textX += ctx->_font->getCharWidth(a);
+ break;
- debugC(kDebugGraphics, "draw_line (%d, %d) - (%d, %d)",
- ctx->_x, ctx->_y, a, b);
- ctx->_drawSurface->drawLine(ctx->_x, ctx->_y, a, b, ctx->_penColor);
+ case OPCODE_SET_SHAPE:
+ debugC(kDebugGraphics, "set_shape_type(%.2x)", param);
- ctx->_x = a;
- ctx->_y = b;
+ if (param == 8) {
+ // FIXME: This appears to be a _shape type. Only used by OO-Topos
+ warning("TODO: Shape type 8");
+ ctx->_shape = SHAPE_PIXEL;
+ } else {
+ ctx->_shape = (Shape)param;
+ }
break;
- case IMAGE_OP_DRAW_BOX:
- case IMAGE_OP_DRAW_BOX_FAR:
+ case OPCODE_SET_FILL_COLOR:
a = imageGetOperand(ctx);
+ debugC(kDebugGraphics, "set_fill_color(%.2x)", a);
+ ctx->_fillColor = ctx->_drawSurface->getFillColor(a);
+ break;
+
+ case OPCODE_MOVE_TO:
+ a = imageGetOperand(ctx) + (param & 1 ? 256 : 0);
b = imageGetOperand(ctx);
- if (opcode & 0x1)
- a += 255;
+ debugC(kDebugGraphics, "move_to(%d, %d)", a, b);
+ ctx->_x = a;
+ ctx->_y = b;
+ break;
+
+ case OPCODE_DRAW_BOX:
+ a = imageGetOperand(ctx) + (param & 1 ? 256 : 0);
+ b = imageGetOperand(ctx);
debugC(kDebugGraphics, "draw_box (%d, %d) - (%d, %d)",
- ctx->_x, ctx->_y, a, b);
+ ctx->_x, ctx->_y, a, b);
ctx->_drawSurface->drawBox(ctx->_x, ctx->_y, a, b, ctx->_penColor);
break;
- case IMAGE_OP_MOVE_TO:
- case IMAGE_OP_MOVE_TO_FAR:
- /* Move to */
- a = imageGetOperand(ctx);
+ case OPCODE_DRAW_LINE:
+ a = imageGetOperand(ctx) + (param & 1 ? 256 : 0);
b = imageGetOperand(ctx);
- if (opcode & 0x1)
- a += 255;
+ debugC(kDebugGraphics, "draw_line (%d, %d) - (%d, %d)",
+ ctx->_x, ctx->_y, a, b);
+ ctx->_drawSurface->drawLine(ctx->_x, ctx->_y, a, b, ctx->_penColor);
- debugC(kDebugGraphics, "move_to(%d, %d)", a, b);
ctx->_x = a;
ctx->_y = b;
break;
- case IMAGE_OP_SHAPE_PIXEL:
- case IMAGE_OP_SHAPE_BOX:
- case IMAGE_OP_SHAPE_CIRCLE_TINY:
- case IMAGE_OP_SHAPE_CIRCLE_SMALL:
- case IMAGE_OP_SHAPE_CIRCLE_MED:
- case IMAGE_OP_SHAPE_CIRCLE_LARGE:
- case IMAGE_OP_SHAPE_A:
- case IMAGE_OP_SHAPE_SPRAY:
- debugC(kDebugGraphics,
- "set_shape_type(%.2x)", opcode - 0x40);
- ctx->_shape = opcode;
- break;
-
- case 0x48:
- /*
- * FIXME - This appears to be a _shape type. Only used by
- * OO-Topos.
- */
- debugC(kDebugGraphics, "shape_unknown()");
- ctx->_shape = IMAGE_OP_SHAPE_PIXEL;
+ case OPCODE_B:
+ // TODO: Figure out what shape this draws
+ a = imageGetOperand(ctx);
+ ctx->_drawSurface->opcodeB(ctx->_x, ctx->_y, a);
break;
- case IMAGE_OP_DRAW_SHAPE:
- case IMAGE_OP_DRAW_SHAPE_FAR:
- a = imageGetOperand(ctx);
+ case OPCODE_DRAW_SHAPE:
+ a = imageGetOperand(ctx) + (param & 1 ? 256 : 0);
b = imageGetOperand(ctx);
- if (opcode & 0x1)
- a += 255;
-
debugC(kDebugGraphics, "draw_shape(%d, %d), style=%.2x, fill=%.2x",
a, b, ctx->_shape, ctx->_fillColor);
ctx->_drawSurface->drawShape(a, b, ctx->_shape, ctx->_fillColor);
break;
- case IMAGE_OP_PAINT:
- case IMAGE_OP_PAINT_FAR:
- /* Paint */
- a = imageGetOperand(ctx);
+ case OPCODE_DELAY:
+ // The original allowed for rendering to be paused briefly. We don't do
+ // that in ScummVM, and just show the finished rendered image
+ (void)imageGetOperand(ctx);
+ break;
+
+ case OPCODE_PAINT:
+ a = imageGetOperand(ctx) + (param & 1 ? 256 : 0);
b = imageGetOperand(ctx);
if (opcode & 0x1)
@@ -202,69 +238,33 @@ bool Pics::ImageFile::doImageOp(Pics::ImageContext *ctx) const {
ctx->_drawSurface->getPixelColor(a, b));
break;
- case IMAGE_OP_FILL_COLOR:
+ case OPCODE_SPECIAL:
a = imageGetOperand(ctx);
- debugC(kDebugGraphics, "set_fill_color(%.2x)", a);
- ctx->_fillColor = ctx->_drawSurface->getFillColor(a);
+ doResetOp(ctx, a);
break;
+ }
- case IMAGE_OP_SET_TEXT_POS:
- a = imageGetOperand(ctx);
- b = imageGetOperand(ctx);
- debugC(kDebugGraphics, "set_text_pos(%d, %d)", a, b);
-
- ctx->_textX = a;
- ctx->_textY = b;
- break;
-
- case IMAGE_OP_DRAW_CHAR:
- a = imageGetOperand(ctx);
- if (a < 0x20 || a >= 0x7f) {
- warning("Invalid character - %c", a);
- a = '?';
- }
-
- debugC(kDebugGraphics, "draw_char(%c)", a);
- ctx->_font->drawChar(ctx->_drawSurface, a, ctx->_textX, ctx->_textY, ctx->_penColor);
- ctx->_textX += ctx->_font->getCharWidth(a);
- break;
+ return false;
+}
- case 0xf3:
- /*
- * FIXME - Oo-Topos uses this at the beginning of some room
- * images.
- */
- debugC(kDebugGraphics, "unknown()");
+void Pics::ImageFile::doResetOp(ImageContext *ctx, byte param) const {
+ switch (param) {
+ case RESETOP_0:
+ // In Transylvania this sub-opcode is a do nothing
break;
- case 0xb5:
- case 0x82:
- case 0x50:
- /* FIXME - unknown, no arguments */
- debugC(kDebugGraphics, "unknown");
+ case RESETOP_RESET:
+ // TODO: Calls same reset that first gets called when rendering starts.
+ // Figure out what the implication of resetting the variables does
break;
- case 0x73:
- case 0xb0:
- case 0xd0:
- /* FIXME - unknown, one argument */
- a = imageGetOperand(ctx);
- debugC(kDebugGraphics, "unknown %.2x: (%.2x) '%c'",
- opcode, a,
- a >= 0x20 && a < 0x7f ? a : '?');
- break;
+ case RESETOP_OO_TOPOS_UNKNOWN:
+ // TODO: This is called for some scenes in OO-Topis. Figure out what it does
+ break;
default:
- /* FIXME - Unknown, two arguments */
- a = imageGetOperand(ctx);
- b = imageGetOperand(ctx);
-
- debugC(kDebugGraphics, "unknown(%.2x, %.2x)", a, b);
- ctx->_drawSurface->drawPixel(a, b, 0x00ff00ff);
break;
}
-
- return false;
}
uint16 Pics::ImageFile::imageGetOperand(ImageContext *ctx) const {
diff --git a/engines/glk/comprehend/pics.h b/engines/glk/comprehend/pics.h
index bb96a6fc5e..6cb00acbbd 100644
--- a/engines/glk/comprehend/pics.h
+++ b/engines/glk/comprehend/pics.h
@@ -31,49 +31,6 @@
namespace Glk {
namespace Comprehend {
-#define IMAGE_OP_SCENE_END 0x00
-
-#define IMAGE_OP_SET_TEXT_POS 0x10
-
-#define IMAGE_OP_PEN_COLOR_A 0x20
-#define IMAGE_OP_PEN_COLOR_B 0x21
-#define IMAGE_OP_PEN_COLOR_C 0x22
-#define IMAGE_OP_PEN_COLOR_D 0x23
-#define IMAGE_OP_PEN_COLOR_E 0x24
-#define IMAGE_OP_PEN_COLOR_F 0x25
-#define IMAGE_OP_PEN_COLOR_G 0x26
-#define IMAGE_OP_PEN_COLOR_H 0x27
-
-#define IMAGE_OP_DRAW_CHAR 0x30
-
-#define IMAGE_OP_SHAPE_PIXEL 0x40
-#define IMAGE_OP_SHAPE_BOX 0x41
-#define IMAGE_OP_SHAPE_CIRCLE_TINY 0x42
-#define IMAGE_OP_SHAPE_CIRCLE_SMALL 0x43
-#define IMAGE_OP_SHAPE_CIRCLE_MED 0x44
-#define IMAGE_OP_SHAPE_CIRCLE_LARGE 0x45
-#define IMAGE_OP_SHAPE_A 0x46
-#define IMAGE_OP_SHAPE_SPRAY 0x47
-
-#define IMAGE_OP_EOF 0x55
-
-#define IMAGE_OP_FILL_COLOR 0x60
-
-#define IMAGE_OP_MOVE_TO 0x80
-#define IMAGE_OP_MOVE_TO_FAR 0x81
-
-#define IMAGE_OP_DRAW_BOX 0x90
-#define IMAGE_OP_DRAW_BOX_FAR 0x91
-
-#define IMAGE_OP_DRAW_LINE 0xa0
-#define IMAGE_OP_DRAW_LINE_FAR 0xa1
-
-#define IMAGE_OP_DRAW_SHAPE 0xc0
-#define IMAGE_OP_DRAW_SHAPE_FAR 0xc1
-
-#define IMAGE_OP_PAINT 0xe0
-#define IMAGE_OP_PAINT_FAR 0xe1
-
#define IMAGEF_NO_FLOODFILL (1 << 1)
enum {
@@ -85,6 +42,17 @@ 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;
@@ -96,7 +64,7 @@ class Pics : public Common::Archive {
uint16 _y;
uint32 _penColor;
uint32 _fillColor;
- uint32 _shape;
+ Shape _shape;
uint16 _textX;
uint16 _textY;
@@ -104,9 +72,8 @@ class Pics : public Common::Archive {
ImageContext(DrawSurface *drawSurface, Graphics::Font *font, uint flags) :
_drawSurface(drawSurface), _font(font), _drawFlags(0),
_x(0), _y(0), _penColor(G_COLOR_BLACK), _fillColor(G_COLOR_BLACK),
- _shape(IMAGE_OP_SHAPE_CIRCLE_LARGE), _textX(0), _textY(0) {
+ _shape(SHAPE_CIRCLE_LARGE), _textX(0), _textY(0) {
}
-
};
struct ImageFile {
@@ -117,7 +84,7 @@ class Pics : public Common::Archive {
private:
bool doImageOp(ImageContext *ctx) const;
uint16 imageGetOperand(ImageContext *ctx) const;
-
+ void doResetOp(ImageContext *ctx, byte param) const;
public:
ImageFile() {}
ImageFile(const Common::String &filename);
Commit: ce476064659aeba010a8c43df44c61f5e0021c0c
https://github.com/scummvm/scummvm/commit/ce476064659aeba010a8c43df44c61f5e0021c0c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-04T20:10:57-07:00
Commit Message:
GLK: COMPREHEND: Draw opcode B is for drawing a circle
Changed paths:
engines/glk/comprehend/draw_surface.cpp
engines/glk/comprehend/draw_surface.h
engines/glk/comprehend/pics.cpp
diff --git a/engines/glk/comprehend/draw_surface.cpp b/engines/glk/comprehend/draw_surface.cpp
index 6827741064..5908357ef4 100644
--- a/engines/glk/comprehend/draw_surface.cpp
+++ b/engines/glk/comprehend/draw_surface.cpp
@@ -386,34 +386,34 @@ void DrawSurface::clearScreen(uint32 color) {
fillRect(Common::Rect(0, 0, this->w, this->h), _renderColor);
}
-void DrawSurface::opcodeB(int16 x, int16 y, int8 param) {
- int invert = -param;
+void DrawSurface::drawCircle(int16 x, int16 y, int16 diameter) {
+ int invert = -diameter;
int delta = 0;
do {
- opcodeBPoint(x - delta, y - param);
- opcodeBPoint(x + delta, y - param);
- opcodeBPoint(x + delta, y + param);
- opcodeBPoint(x - delta, y + param);
+ drawCirclePoint(x - delta, y - diameter);
+ drawCirclePoint(x + delta, y - diameter);
+ drawCirclePoint(x + delta, y + diameter);
+ drawCirclePoint(x - delta, y + diameter);
- opcodeBPoint(x + param, y - delta);
- opcodeBPoint(x - param, y - delta);
- opcodeBPoint(x - param, y + delta);
- opcodeBPoint(x + param, y + delta);
+ drawCirclePoint(x + diameter, y - delta);
+ drawCirclePoint(x - diameter, y - delta);
+ drawCirclePoint(x - diameter, y + delta);
+ drawCirclePoint(x + diameter, y + delta);
invert += (delta * 2) + 1;
++delta;
if (!((uint)invert & 0x80)) {
invert += 2;
- param <<= 1;
- invert -= param;
- param >>= 1;
- --param;
+ diameter <<= 1;
+ invert -= diameter;
+ diameter >>= 1;
+ --diameter;
}
- } while (param >= delta);
+ } while (diameter >= delta);
}
-void DrawSurface::opcodeBPoint(int16 x, int16 y) {
+void DrawSurface::drawCirclePoint(int16 x, int16 y) {
if (x < 280 && y < 160)
drawPixel(x, y);
}
diff --git a/engines/glk/comprehend/draw_surface.h b/engines/glk/comprehend/draw_surface.h
index 35d2b2d32c..5c0f78bd33 100644
--- a/engines/glk/comprehend/draw_surface.h
+++ b/engines/glk/comprehend/draw_surface.h
@@ -97,8 +97,8 @@ public:
void drawPixel(int16 x, int16 y, uint32 color);
uint32 getPixelColor(int16 x, int16 y);
void clearScreen(uint32 color);
- void opcodeB(int16 x, int16 y, int8 param);
- void opcodeBPoint(int16 x, int16 y);
+ void drawCircle(int16 x, int16 y, int16 diameter);
+ void drawCirclePoint(int16 x, int16 y);
};
} // namespace Comprehend
diff --git a/engines/glk/comprehend/pics.cpp b/engines/glk/comprehend/pics.cpp
index 3065e34e80..fc26972da8 100644
--- a/engines/glk/comprehend/pics.cpp
+++ b/engines/glk/comprehend/pics.cpp
@@ -46,7 +46,7 @@ enum Opcode {
OPCODE_MOVE_TO = 8,
OPCODE_DRAW_BOX = 9,
OPCODE_DRAW_LINE = 10,
- OPCODE_B = 11,
+ OPCODE_DRAW_CIRCLE = 11,
OPCODE_DRAW_SHAPE = 12,
OPCODE_DELAY = 13,
OPCODE_PAINT = 14,
@@ -203,10 +203,12 @@ bool Pics::ImageFile::doImageOp(Pics::ImageContext *ctx) const {
ctx->_y = b;
break;
- case OPCODE_B:
- // TODO: Figure out what shape this draws
+ case OPCODE_DRAW_CIRCLE:
a = imageGetOperand(ctx);
- ctx->_drawSurface->opcodeB(ctx->_x, ctx->_y, a);
+ debugC(kDebugGraphics, "draw_circle (%d, %d) diameter=%d",
+ ctx->_x, ctx->_y, a);
+
+ ctx->_drawSurface->drawCircle(ctx->_x, ctx->_y, a);
break;
case OPCODE_DRAW_SHAPE:
More information about the Scummvm-git-logs
mailing list