Skip to content

Commit

Permalink
WAGE: Get rid of hacky drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Dec 27, 2015
1 parent 327a9ec commit 4cfc0d0
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 23 deletions.
24 changes: 10 additions & 14 deletions engines/wage/design.cpp
Expand Up @@ -55,19 +55,13 @@ Design::Design(Common::SeekableReadStream *data) {
_len = data->readUint16BE() - 2;
_data = (byte *)malloc(_len);
data->read(_data, _len);

Graphics::Surface screen;
screen.create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
Common::Rect r(0, 0, 320, 200);
setBounds(&r);
paint(&screen, 0, true);
}

Design::~Design() {
free(_data);
}

void Design::paint(Graphics::Surface *canvas, TexturePaint *patterns, bool mask) {
void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
Common::MemoryReadStream in(_data, _len);

if (mask) {
Expand All @@ -80,6 +74,7 @@ void Design::paint(Graphics::Surface *canvas, TexturePaint *patterns, bool mask)
byte fillType = in.readByte();
byte borderThickness = in.readByte();
byte borderFillType = in.readByte();
warning("fill: %d border: %d borderFill: %d", fillType, borderThickness, borderFillType);
int type = in.readByte();
switch (type) {
case 4:
Expand Down Expand Up @@ -118,7 +113,7 @@ void Design::paint(Graphics::Surface *canvas, TexturePaint *patterns, bool mask)
}

void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
TexturePaint *patterns, byte fillType, byte borderThickness, byte borderFillType) {
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
int16 y = in.readSint16BE();
int16 x = in.readSint16BE();
int16 height = in.readSint16BE();
Expand All @@ -135,18 +130,19 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
}

void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
TexturePaint *patterns, byte fillType, byte borderThickness, byte borderFillType) {
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
//surface->setColor(Color.BLACK);
//in.readUint16BE();
warning("ignored => %d", in.readSint16BE());
int numBytes = in.readSint16BE(); // #bytes used by polygon data, including the numBytes
warning("Num bytes is %d", numBytes);
// Ignoring these values works!!!
//in.readUint16BE(); in.readUint16BE(); in.readUint16BE(); in.readUint16BE();
warning("Ignoring: %d", in.readSint16BE());
warning("Ignoring: %d", in.readSint16BE());
warning("Ignoring: %d", in.readSint16BE());
warning("Ignoring: %d", in.readSint16BE());
int16 by1 = in.readSint16BE();
int16 bx1 = in.readSint16BE();
int16 by2 = in.readSint16BE();
int16 bx2 = in.readSint16BE();
warning("Bbox: %d, %d, %d, %d", bx1, by1, bx2, by2);

numBytes -= 8;

Expand Down Expand Up @@ -186,7 +182,7 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
//surface->setColor(Color.black);
xcoords.push_back(x1);
ycoords.push_back(y1);
warning("%d %d %d %d", x1, y1, x2, y2);
debug(8, "%d %d %d %d", x1, y1, x2, y2);
//surface->drawLine(x1, y1, x2, y2);
x1 = x2;
y1 = y2;
Expand Down
8 changes: 3 additions & 5 deletions engines/wage/design.h
Expand Up @@ -54,8 +54,6 @@

namespace Wage {

struct TexturePaint;

enum {
kColorBlack = 0,
kColorGray = 1,
Expand All @@ -75,7 +73,7 @@ class Design {
return new Common::Rect(*_bounds);
}

void paint(Graphics::Surface *canvas, TexturePaint *patterns, bool mask);
void paint(Graphics::Surface *canvas, Patterns &patterns, bool mask);

private:
byte *_data;
Expand All @@ -84,9 +82,9 @@ class Design {

private:
void drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
TexturePaint *patterns, byte fillType, byte borderThickness, byte borderFillType);
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
TexturePaint *patterns, byte fillType, byte borderThickness, byte borderFillType);
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);

};

Expand Down
2 changes: 2 additions & 0 deletions engines/wage/entities.cpp
Expand Up @@ -62,6 +62,8 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
_name = name;
_design = new Design(data);

warning("Scene %s", _name.c_str());

setDesignBounds(readRect(data));
_worldY = data->readSint16BE();
_worldX = data->readSint16BE();
Expand Down
7 changes: 7 additions & 0 deletions engines/wage/wage.cpp
Expand Up @@ -61,6 +61,7 @@
#include "wage/wage.h"
#include "wage/entities.h"
#include "wage/world.h"
#include "wage/design.h"

namespace Wage {

Expand Down Expand Up @@ -104,6 +105,12 @@ Common::Error WageEngine::run() {
if (!_world->loadWorld(_resManager))
return Common::kNoGameDataFoundError;

Graphics::Surface screen;
screen.create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
Common::Rect r(0, 0, 320, 200);
_world->_scenes["entry"]->_design->setBounds(&r);
_world->_scenes["entry"]->_design->paint(&screen, _world->_patterns, true);

return Common::kNoError;
}

Expand Down
2 changes: 2 additions & 0 deletions engines/wage/wage.h
Expand Up @@ -79,6 +79,8 @@ enum {
Common::String readPascalString(Common::SeekableReadStream *in);
Common::Rect *readRect(Common::SeekableReadStream *in);

typedef Common::Array<byte *> Patterns;

class WageEngine : public Engine {
public:
WageEngine(OSystem *syst, const ADGameDescription *gameDesc);
Expand Down
8 changes: 4 additions & 4 deletions engines/wage/world.h
Expand Up @@ -56,7 +56,7 @@ class World {
public:
World();
~World();

bool loadWorld(Common::MacResManager *resMan);
void loadExternalSounds(String fname);

Expand All @@ -75,7 +75,7 @@ class World {
Common::Array<Obj *> _orderedObjs;
Common::Array<Chr *> _orderedChrs;
Common::Array<Sound *> _orderedSounds;
Common::Array<byte *> _patterns;
Patterns _patterns;
Scene _storageScene;
Chr *_player;
//List<MoveListener> moveListeners;
Expand Down Expand Up @@ -112,7 +112,7 @@ class World {
_orderedSounds.push_back(sound);
}
};

} // End of namespace Wage

#endif

0 comments on commit 4cfc0d0

Please sign in to comment.