aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/wage/design.cpp46
-rw-r--r--engines/wage/design.h3
-rw-r--r--engines/wage/entities.cpp18
-rw-r--r--engines/wage/entities.h3
-rw-r--r--engines/wage/wage.cpp9
-rw-r--r--engines/wage/wage.h7
6 files changed, 50 insertions, 36 deletions
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index d61c7ac342..c75d1f7758 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -67,17 +67,30 @@ Design::Design(Common::SeekableReadStream *data) {
_len = data->readUint16BE() - 2;
_data = (byte *)malloc(_len);
data->read(_data, _len);
+
+ _surface = NULL;
}
Design::~Design() {
free(_data);
+ delete _surface;
}
-void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask) {
+void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask, int x, int y) {
Common::MemoryReadStream in(_data, _len);
+ Common::Rect r(0, 0, _bounds->width(), _bounds->height());
+ bool needRender = false;
+
+ if (_surface == NULL) {
+ _surface = new Graphics::Surface;
+ _surface->create(_bounds->width(), _bounds->height(), Graphics::PixelFormat::createFormatCLUT8());
+ _surface->fillRect(r, kColorGreen);
+
+ needRender = true;
+ }
if (mask) {
- surface->fillRect(Common::Rect(0, 0, _bounds->width(), _bounds->height()), kColorWhite);
+ _surface->fillRect(r, kColorWhite);
}
/*
@@ -102,32 +115,32 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask) {
return;
*/
- while (true) {
+ while (true && needRender) {
byte fillType = in.readByte();
byte borderThickness = in.readByte();
byte borderFillType = in.readByte();
int type = in.readByte();
if (in.eos())
- return;
+ break;
debug(2, "fill: %d borderFill: %d border: %d type: %d", fillType, borderFillType, borderThickness, type);
switch (type) {
case 4:
- drawRect(surface, in, mask, patterns, fillType, borderThickness, borderFillType);
+ drawRect(_surface, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
case 8:
- drawRoundRect(surface, in, mask, patterns, fillType, borderThickness, borderFillType);
+ drawRoundRect(_surface, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
case 12:
- drawOval(surface, in, mask, patterns, fillType, borderThickness, borderFillType);
+ drawOval(_surface, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
case 16:
case 20:
- drawPolygon(surface, in, mask, patterns, fillType, borderThickness, borderFillType);
+ drawPolygon(_surface, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
case 24:
- drawBitmap(surface, in, mask);
+ drawBitmap(_surface, in, mask);
break;
default:
warning("Unknown type => %d", type);
@@ -136,13 +149,24 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask) {
g_system->updateScreen();
g_system->delayMillis(50);
}
- return;
+ break;
}
- //g_system->copyRectToScreen(surface->getPixels(), surface->pitch, 0, 0, surface->w, surface->h);
+ //g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 0, 0, _surface->w, _surface->h);
//((WageEngine *)g_engine)->processEvents();
//g_system->updateScreen();
}
+
+ for (int i = 0; i < _bounds->height(); i++) {
+ const byte *src = (const byte *)_surface->getBasePtr(0, i);
+ byte *dst = (byte *)surface->getBasePtr(0, i);
+ for (int j = 0; j < _bounds->width(); j++) {
+ if (*src != kColorGreen)
+ *dst = *src;
+ src++;
+ dst++;
+ }
+ }
}
void drawPixel(int x, int y, int color, void *data) {
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 118fbbb9c0..8e79a84530 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -67,13 +67,14 @@ public:
return _bounds;
}
- void paint(Graphics::Surface *canvas, Patterns &patterns, bool mask);
+ void paint(Graphics::Surface *canvas, Patterns &patterns, bool mask, int x, int y);
static void drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType);
private:
byte *_data;
int _len;
Common::Rect *_bounds;
+ Graphics::Surface *_surface;
private:
void drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index d557f080d3..96d6855b10 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -61,7 +61,6 @@ void Designed::setDesignBounds(Common::Rect *bounds) {
Scene::Scene() {
_script = NULL;
- _surface = NULL;
_design = NULL;
_textBounds = NULL;
_fontSize = 0;
@@ -84,7 +83,6 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
_design = new Design(data);
_script = NULL;
- _surface = NULL;
_textBounds = NULL;
_fontSize = 0;
_fontType = 0;
@@ -109,31 +107,23 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
}
Scene::~Scene() {
- delete _surface;
}
void Scene::paint(Graphics::Surface *surface, int x, int y) {
- if (_surface == NULL) {
- _surface = new Graphics::Surface;
- _surface->create(_design->getBounds()->width(), _design->getBounds()->height(), Graphics::PixelFormat::createFormatCLUT8());
- }
-
Common::Rect r(0, 0, _design->getBounds()->width(), _design->getBounds()->height());
- _surface->fillRect(r, kColorWhite);
+ surface->fillRect(r, kColorWhite);
- _design->paint(_surface, ((WageEngine *)g_engine)->_world->_patterns, false);
+ _design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false, x, y);
for (Common::List<Obj *>::const_iterator it = _objs.begin(); it != _objs.end(); ++it) {
debug(2, "paining Obj: %s", (*it)->_name.c_str());
- (*it)->_design->paint(_surface, ((WageEngine *)g_engine)->_world->_patterns, false);
+ (*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false, x, y);
}
for (Common::List<Chr *>::const_iterator it = _chrs.begin(); it != _chrs.end(); ++it) {
debug(2, "paining Chr: %s", (*it)->_name.c_str());
- (*it)->_design->paint(_surface, ((WageEngine *)g_engine)->_world->_patterns, false);
+ (*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false, x, y);
}
-
- surface->copyRectToSurface(*_surface, x, y, r);
}
// Source: Apple IIGS Technical Note #41, "Font Family Numbers"
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 0e20d2ef3a..5ecd33c846 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -405,9 +405,6 @@ public:
void paint(Graphics::Surface *screen, int x, int y);
const char *getFontName();
-
-private:
- Graphics::Surface *_surface;
};
class Sound {
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index ff867e5bb4..2b919e10b6 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -87,15 +87,16 @@ WageEngine::~WageEngine() {
}
static byte palette[] = {
- 0, 0, 0,
- 0x80, 0x80, 0x80,
- 0xff, 0xff, 0xff
+ 0, 0, 0, // Black
+ 0x80, 0x80, 0x80, // Gray
+ 0xff, 0xff, 0xff, // White
+ 0x00, 0xff, 0x00 // Green
};
Common::Error WageEngine::run() {
initGraphics(444, 333, true);
- g_system->getPaletteManager()->setPalette(palette, 0, 3);
+ g_system->getPaletteManager()->setPalette(palette, 0, 4);
// Create debugger console. It requires GFX to be initialized
_console = new Console(this);
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 614b5a12d5..c93e4e7b1b 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -90,9 +90,10 @@ enum {
};
enum {
- kColorBlack = 0,
- kColorGray = 1,
- kColorWhite = 2
+ kColorBlack = 0,
+ kColorGray = 1,
+ kColorWhite = 2,
+ kColorGreen = 3
};
Common::String readPascalString(Common::SeekableReadStream *in);