aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction
diff options
context:
space:
mode:
authorNicola Mettifogo2007-08-07 15:08:45 +0000
committerNicola Mettifogo2007-08-07 15:08:45 +0000
commitd800f33ff16ce2d0806b85357b6f3e2111adcfb8 (patch)
tree3c5ee73f3c5c340292fe5b3f48c06e69575504f2 /engines/parallaction
parentd30c3650a358e4e5ba8a548d4e218d7b49fba34a (diff)
downloadscummvm-rg350-d800f33ff16ce2d0806b85357b6f3e2111adcfb8.tar.gz
scummvm-rg350-d800f33ff16ce2d0806b85357b6f3e2111adcfb8.tar.bz2
scummvm-rg350-d800f33ff16ce2d0806b85357b6f3e2111adcfb8.zip
Turned StaticCnv struct into stock Graphics::Surface, and changed all relevant code.
svn-id: r28484
Diffstat (limited to 'engines/parallaction')
-rw-r--r--engines/parallaction/animation.cpp24
-rw-r--r--engines/parallaction/dialogue.cpp2
-rw-r--r--engines/parallaction/disk.h31
-rw-r--r--engines/parallaction/disk_br.cpp6
-rw-r--r--engines/parallaction/disk_ns.cpp55
-rw-r--r--engines/parallaction/graphics.cpp93
-rw-r--r--engines/parallaction/graphics.h24
-rw-r--r--engines/parallaction/menu.cpp11
-rw-r--r--engines/parallaction/parallaction.cpp4
-rw-r--r--engines/parallaction/parallaction.h4
-rw-r--r--engines/parallaction/zone.cpp18
-rw-r--r--engines/parallaction/zone.h6
12 files changed, 114 insertions, 164 deletions
diff --git a/engines/parallaction/animation.cpp b/engines/parallaction/animation.cpp
index 4bfc480f8e..314cf2a18e 100644
--- a/engines/parallaction/animation.cpp
+++ b/engines/parallaction/animation.cpp
@@ -155,7 +155,7 @@ void Parallaction::freeAnimations() {
void jobDisplayAnimations(void *parm, Job *j) {
// printf("jobDisplayAnimations()...\n");
- StaticCnv v14;
+ Graphics::Surface v14;
uint16 _si = 0;
@@ -164,21 +164,20 @@ void jobDisplayAnimations(void *parm, Job *j) {
Animation *v18 = *it;
if ((v18->_flags & kFlagsActive) && ((v18->_flags & kFlagsRemove) == 0)) {
- v14._width = v18->width();
- v14._height = v18->height();
+ v14.w = v18->width();
+ v14.h = v18->height();
int16 frame = CLIP((int)v18->_frame, 0, v18->getFrameNum()-1);
- v14._data0 = v18->getFrameData(frame);
-// v14._data1 = v18->_cnv->field_8[frame];
+ v14.pixels = v18->getFrameData(frame);
if (v18->_flags & kFlagsNoMasked)
_si = 3;
else
_si = _vm->_gfx->queryMask(v18->_top + v18->height());
- debugC(9, kDebugLocation, "jobDisplayAnimations(%s, x:%i, y:%i, z:%i, w:%i, h:%i, f:%i/%i, %p)", v18->_label._text, v18->_left, v18->_top, _si, v14._width, v14._height,
- frame, v18->getFrameNum(), v14._data0);
+ debugC(9, kDebugLocation, "jobDisplayAnimations(%s, x:%i, y:%i, z:%i, w:%i, h:%i, f:%i/%i, %p)", v18->_label._text, v18->_left, v18->_top, _si, v14.w, v14.h,
+ frame, v18->getFrameNum(), v14.pixels);
_vm->_gfx->blitCnv(&v14, v18->_left, v18->_top, _si, Gfx::kBitBack);
}
@@ -359,7 +358,7 @@ void Parallaction::parseScriptLine(Instruction *inst, Animation *a, LocalVariabl
break;
case INST_SET: // set
- // WORKAROUND: At least one script (balzo.script) in Amiga versions didn't declare
+ // WORKAROUND: At least one script (balzo.script) in Amiga versions didn't declare
// local variables before using them, thus leading to crashes. The line launching the
// script was commented out on Dos version. This workaround enables the engine
// to dynamically add a local variable when it is encountered the first time in
@@ -477,7 +476,7 @@ void jobRunScripts(void *parm, Job *j) {
static uint16 modCounter = 0;
- StaticCnv v18;
+ Graphics::Surface v18;
for (AnimationList::iterator it = _vm->_animations.begin(); it != _vm->_animations.end(); it++) {
@@ -565,10 +564,9 @@ void jobRunScripts(void *parm, Job *j) {
break;
case INST_PUT: // put
- v18._width = (*inst)->_opBase._a->width();
- v18._height = (*inst)->_opBase._a->height();
- v18._data0 = (*inst)->_opBase._a->getFrameData((*inst)->_opBase._a->_frame);
- v18._data1 = NULL; // (*inst)->_opBase._a->_cnv.field_8[(*inst)->_opBase._a->_frame];
+ v18.w = (*inst)->_opBase._a->width();
+ v18.h = (*inst)->_opBase._a->height();
+ v18.pixels = (*inst)->_opBase._a->getFrameData((*inst)->_opBase._a->_frame);
if ((*inst)->_flags & kInstMaskedPut) {
uint16 _si = _vm->_gfx->queryMask((*inst)->_opB._value);
diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp
index e8a780f846..61d9ed2086 100644
--- a/engines/parallaction/dialogue.cpp
+++ b/engines/parallaction/dialogue.cpp
@@ -46,7 +46,7 @@ namespace Parallaction {
#define ANSWER_CHARACTER_X 10
#define ANSWER_CHARACTER_Y 80
-int16 selectAnswer(Question *q, StaticCnv*);
+int16 selectAnswer(Question *q, Graphics::Surface*);
int16 getHoverAnswer(int16 x, int16 y, Question *q);
int16 _answerBalloonX[10] = { 80, 120, 150, 150, 150, 0, 0, 0, 0, 0 };
diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h
index ae572b1122..d1bb404739 100644
--- a/engines/parallaction/disk.h
+++ b/engines/parallaction/disk.h
@@ -28,6 +28,7 @@
#include "parallaction/defs.h"
#include "common/file.h"
+#include "graphics/surface.h"
namespace Parallaction {
@@ -38,8 +39,6 @@ class Script;
class Font;
struct Cnv;
-struct StaticCnv;
-
class Disk {
@@ -54,10 +53,10 @@ public:
virtual Script* loadScript(const char* name) = 0;
virtual Cnv* loadTalk(const char *name) = 0;
virtual Cnv* loadObjects(const char *name) = 0;
- virtual StaticCnv* loadPointer() = 0;
- virtual StaticCnv* loadHead(const char* name) = 0;
+ virtual Graphics::Surface* loadPointer() = 0;
+ virtual Graphics::Surface* loadHead(const char* name) = 0;
virtual Font* loadFont(const char* name) = 0;
- virtual StaticCnv* loadStatic(const char* name) = 0;
+ virtual Graphics::Surface* loadStatic(const char* name) = 0;
virtual Cnv* loadFrames(const char* name) = 0;
virtual void loadSlide(const char *filename) = 0;
virtual void loadScenery(const char* background, const char* mask) = 0;
@@ -128,7 +127,7 @@ private:
void unpackBackground(Common::ReadStream *stream, byte *screen, byte *mask, byte *path);
Cnv* loadExternalCnv(const char *filename);
Cnv* loadCnv(const char *filename);
- StaticCnv *loadExternalStaticCnv(const char *filename);
+ Graphics::Surface *loadExternalStaticCnv(const char *filename);
void loadBackground(const char *filename);
void loadMaskAndPath(const char *name);
void parseDepths(Common::SeekableReadStream &stream);
@@ -146,10 +145,10 @@ public:
Script* loadScript(const char* name);
Cnv* loadTalk(const char *name);
Cnv* loadObjects(const char *name);
- StaticCnv* loadPointer();
- StaticCnv* loadHead(const char* name);
+ Graphics::Surface* loadPointer();
+ Graphics::Surface* loadHead(const char* name);
Font* loadFont(const char* name);
- StaticCnv* loadStatic(const char* name);
+ Graphics::Surface* loadStatic(const char* name);
Cnv* loadFrames(const char* name);
void loadSlide(const char *filename);
void loadScenery(const char* background, const char* mask);
@@ -162,7 +161,7 @@ class AmigaDisk_ns : public Disk_ns {
protected:
Cnv* makeCnv(Common::SeekableReadStream &stream);
- StaticCnv* makeStaticCnv(Common::SeekableReadStream &stream);
+ Graphics::Surface* makeStaticCnv(Common::SeekableReadStream &stream);
void patchFrame(byte *dst, byte *dlta, uint16 bytesPerPlane, uint16 height);
void unpackFrame(byte *dst, byte *src, uint16 planeSize);
void unpackBitmap(byte *dst, byte *src, uint16 numFrames, uint16 bytesPerPlane, uint16 height);
@@ -180,10 +179,10 @@ public:
Script* loadScript(const char* name);
Cnv* loadTalk(const char *name);
Cnv* loadObjects(const char *name);
- StaticCnv* loadPointer();
- StaticCnv* loadHead(const char* name);
+ Graphics::Surface* loadPointer();
+ Graphics::Surface* loadHead(const char* name);
Font* loadFont(const char* name);
- StaticCnv* loadStatic(const char* name);
+ Graphics::Surface* loadStatic(const char* name);
Cnv* loadFrames(const char* name);
void loadSlide(const char *filename);
void loadScenery(const char* background, const char* mask);
@@ -214,10 +213,10 @@ public:
Script* loadScript(const char* name);
Cnv* loadTalk(const char *name);
Cnv* loadObjects(const char *name);
- StaticCnv* loadPointer();
- StaticCnv* loadHead(const char* name);
+ Graphics::Surface* loadPointer();
+ Graphics::Surface* loadHead(const char* name);
Font* loadFont(const char* name);
- StaticCnv* loadStatic(const char* name);
+ Graphics::Surface* loadStatic(const char* name);
Cnv* loadFrames(const char* name);
void loadSlide(const char *filename);
void loadScenery(const char* background, const char* mask);
diff --git a/engines/parallaction/disk_br.cpp b/engines/parallaction/disk_br.cpp
index 452b74be51..256b364eea 100644
--- a/engines/parallaction/disk_br.cpp
+++ b/engines/parallaction/disk_br.cpp
@@ -69,13 +69,13 @@ Script* DosDisk_br::loadScript(const char* name) {
}
// there are no Head resources in Big Red Adventure
-StaticCnv* DosDisk_br::loadHead(const char* name) {
+Graphics::Surface* DosDisk_br::loadHead(const char* name) {
debugC(5, kDebugDisk, "DosDisk_br::loadHead");
return 0;
}
-StaticCnv* DosDisk_br::loadPointer() {
+Graphics::Surface* DosDisk_br::loadPointer() {
debugC(5, kDebugDisk, "DosDisk_br::loadPointer");
return 0;
}
@@ -93,7 +93,7 @@ Cnv* DosDisk_br::loadObjects(const char *name) {
}
-StaticCnv* DosDisk_br::loadStatic(const char* name) {
+Graphics::Surface* DosDisk_br::loadStatic(const char* name) {
debugC(5, kDebugDisk, "DosDisk_br::loadStatic");
return 0;
}
diff --git a/engines/parallaction/disk_ns.cpp b/engines/parallaction/disk_ns.cpp
index 0dbabd4bc9..d6ff9cc4bf 100644
--- a/engines/parallaction/disk_ns.cpp
+++ b/engines/parallaction/disk_ns.cpp
@@ -345,7 +345,7 @@ Cnv* DosDisk_ns::loadExternalCnv(const char *filename) {
return new Cnv(numFrames, width, height, data);
}
-StaticCnv *DosDisk_ns::loadExternalStaticCnv(const char *filename) {
+Graphics::Surface *DosDisk_ns::loadExternalStaticCnv(const char *filename) {
char path[PATH_LEN];
@@ -356,16 +356,14 @@ StaticCnv *DosDisk_ns::loadExternalStaticCnv(const char *filename) {
if (!stream.open(path))
errorFileNotFound(path);
- StaticCnv *cnv = new StaticCnv;
+ Graphics::Surface *cnv = new Graphics::Surface;
stream.skip(1);
- cnv->_width = stream.readByte();
- cnv->_height = stream.readByte();
+ byte w = stream.readByte();
+ byte h = stream.readByte();
- uint16 size = cnv->_width*cnv->_height;
-
- cnv->_data0 = (byte*)malloc(size);
- stream.read(cnv->_data0, size);
+ cnv->create(w, h, 1);
+ stream.read(cnv->pixels, w*h);
return cnv;
}
@@ -462,7 +460,7 @@ Script* DosDisk_ns::loadScript(const char* name) {
return new Script(new DummyArchiveStream(_resArchive), true);
}
-StaticCnv* DosDisk_ns::loadHead(const char* name) {
+Graphics::Surface* DosDisk_ns::loadHead(const char* name) {
char path[PATH_LEN];
@@ -477,7 +475,7 @@ StaticCnv* DosDisk_ns::loadHead(const char* name) {
}
-StaticCnv* DosDisk_ns::loadPointer() {
+Graphics::Surface* DosDisk_ns::loadPointer() {
return loadExternalStaticCnv("pointer");
}
@@ -501,7 +499,7 @@ Cnv* DosDisk_ns::loadObjects(const char *name) {
}
-StaticCnv* DosDisk_ns::loadStatic(const char* name) {
+Graphics::Surface* DosDisk_ns::loadStatic(const char* name) {
char path[PATH_LEN];
@@ -512,17 +510,16 @@ StaticCnv* DosDisk_ns::loadStatic(const char* name) {
errorFileNotFound(path);
}
- StaticCnv* cnv = new StaticCnv;
+ Graphics::Surface* cnv = new Graphics::Surface;
_resArchive.skip(1);
- cnv->_width = _resArchive.readByte();
- cnv->_height = _resArchive.readByte();
+ byte w = _resArchive.readByte();
+ byte h = _resArchive.readByte();
- uint16 size = cnv->_width*cnv->_height;
- cnv->_data0 = (byte*)malloc(size);
+ cnv->create(w, h, 1);
Graphics::PackBitsReadStream decoder(_resArchive);
- decoder.read(cnv->_data0, size);
+ decoder.read(cnv->pixels, w*h);
return cnv;
}
@@ -977,7 +974,7 @@ void AmigaDisk_ns::unpackBitmap(byte *dst, byte *src, uint16 numFrames, uint16 b
}
-StaticCnv* AmigaDisk_ns::makeStaticCnv(Common::SeekableReadStream &stream) {
+Graphics::Surface* AmigaDisk_ns::makeStaticCnv(Common::SeekableReadStream &stream) {
stream.skip(1);
uint16 width = stream.readByte();
@@ -992,17 +989,13 @@ StaticCnv* AmigaDisk_ns::makeStaticCnv(Common::SeekableReadStream &stream) {
stream.read(buf, rawsize);
uint32 decsize = width * height;
- byte *data = (byte*)calloc(decsize, 1);
- unpackBitmap(data, buf, 1, bytesPerPlane, height);
+ Graphics::Surface *cnv = new Graphics::Surface;
+ cnv->create(width, height, 1);
- free(buf);
+ unpackBitmap((byte*)cnv->pixels, buf, 1, bytesPerPlane, height);
- StaticCnv *cnv = new StaticCnv();
- cnv->_width = width;
- cnv->_height = height;
- cnv->_data0 = data;
- cnv->_data1 = NULL;
+ free(buf);
return cnv;
}
@@ -1066,7 +1059,7 @@ Script* AmigaDisk_ns::loadScript(const char* name) {
return new Script(new DummyArchiveStream(_resArchive), true);
}
-StaticCnv* AmigaDisk_ns::loadPointer() {
+Graphics::Surface* AmigaDisk_ns::loadPointer() {
debugC(1, kDebugDisk, "AmigaDisk_ns::loadPointer");
Common::File stream;
@@ -1076,11 +1069,11 @@ StaticCnv* AmigaDisk_ns::loadPointer() {
return makeStaticCnv(stream);
}
-StaticCnv* AmigaDisk_ns::loadStatic(const char* name) {
+Graphics::Surface* AmigaDisk_ns::loadStatic(const char* name) {
debugC(1, kDebugDisk, "AmigaDisk_ns::loadStatic '%s'", name);
Common::SeekableReadStream *s = openArchivedFile(name, true);
- StaticCnv *cnv = makeStaticCnv(*s);
+ Graphics::Surface *cnv = makeStaticCnv(*s);
delete s;
@@ -1325,14 +1318,14 @@ Cnv* AmigaDisk_ns::loadFrames(const char* name) {
return cnv;
}
-StaticCnv* AmigaDisk_ns::loadHead(const char* name) {
+Graphics::Surface* AmigaDisk_ns::loadHead(const char* name) {
debugC(1, kDebugDisk, "AmigaDisk_ns::loadHead '%s'", name);
char path[PATH_LEN];
sprintf(path, "%s.head", name);
Common::SeekableReadStream *s = openArchivedFile(path, true);
- StaticCnv *cnv = makeStaticCnv(*s);
+ Graphics::Surface *cnv = makeStaticCnv(*s);
delete s;
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index 5c31c87d7a..e9d8d40c57 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -399,7 +399,7 @@ void jobDisplayLabel(void *parm, Job *j) {
Label *label = (Label*)parm;
debugC(9, kDebugJobs, "jobDisplayLabel (%p)", (const void*) label);
- if (label->_cnv._width == 0)
+ if (label->_cnv.w == 0)
return;
_vm->_gfx->flatBlitCnv(&label->_cnv, _vm->_gfx->_labelPosition[0].x, _vm->_gfx->_labelPosition[0].y, Gfx::kBitBack);
@@ -414,20 +414,20 @@ void jobEraseLabel(void *parm, Job *j) {
int16 _si, _di;
if (_vm->_activeItem._id != 0) {
- _si = _vm->_mousePos.x + 16 - label->_cnv._width/2;
+ _si = _vm->_mousePos.x + 16 - label->_cnv.w/2;
_di = _vm->_mousePos.y + 34;
} else {
- _si = _vm->_mousePos.x + 8 - label->_cnv._width/2;
+ _si = _vm->_mousePos.x + 8 - label->_cnv.w/2;
_di = _vm->_mousePos.y + 21;
}
if (_si < 0) _si = 0;
if (_di > 190) _di = 190;
- if (label->_cnv._width + _si > _vm->_screenWidth)
- _si = _vm->_screenWidth - label->_cnv._width;
+ if (label->_cnv.w + _si > _vm->_screenWidth)
+ _si = _vm->_screenWidth - label->_cnv.w;
- Common::Rect r(label->_cnv._width, label->_cnv._height);
+ Common::Rect r(label->_cnv.w, label->_cnv.h);
r.moveTo(_vm->_gfx->_labelPosition[1]);
_vm->_gfx->restoreBackground(r);
@@ -463,7 +463,7 @@ void Gfx::setMousePointer(int16 index) {
} else {
// inventory item pointer
- byte *v8 = _mouseComposedArrow->_data0;
+ byte *v8 = (byte*)_mouseComposedArrow->pixels;
// FIXME: destination offseting is not clear
byte* s = _vm->_char._objs->getFramePtr(getInventoryItemIndex(index));
@@ -490,30 +490,29 @@ void Gfx::setMousePointer(int16 index) {
//
void Gfx::flatBlitCnv(Cnv *cnv, uint16 frame, int16 x, int16 y, Gfx::Buffers buffer) {
- StaticCnv scnv;
+ Graphics::Surface scnv;
- scnv._width = cnv->_width;
- scnv._height = cnv->_height;
- scnv._data0 = cnv->getFramePtr(frame);
- scnv._data1 = NULL; // ->field_8[v60->_mood & 0xF];
+ scnv.w = cnv->_width;
+ scnv.h = cnv->_height;
+ scnv.pixels = cnv->getFramePtr(frame);
flatBlitCnv(&scnv, x, y, buffer);
}
-void Gfx::flatBlitCnv(StaticCnv *cnv, int16 x, int16 y, Gfx::Buffers buffer) {
- Common::Rect r(cnv->_width, cnv->_height);
+void Gfx::flatBlitCnv(Graphics::Surface *cnv, int16 x, int16 y, Gfx::Buffers buffer) {
+ Common::Rect r(cnv->w, cnv->h);
r.moveTo(x, y);
- flatBlit(r, cnv->_data0, buffer);
+ flatBlit(r, (byte*)cnv->pixels, buffer);
return;
}
-void Gfx::blitCnv(StaticCnv *cnv, int16 x, int16 y, uint16 z, Gfx::Buffers buffer) {
- Common::Rect r(cnv->_width, cnv->_height);
+void Gfx::blitCnv(Graphics::Surface *cnv, int16 x, int16 y, uint16 z, Gfx::Buffers buffer) {
+ Common::Rect r(cnv->w, cnv->h);
r.moveTo(x, y);
- blit(r, z, cnv->_data0, buffer);
+ blit(r, z, (byte*)cnv->pixels, buffer);
return;
}
@@ -534,14 +533,14 @@ void Gfx::backupDoorBackground(DoorData *data, int16 x, int16 y) {
void Gfx::backupGetBackground(GetData *data, int16 x, int16 y) {
- byte *t = data->_cnv->_data0;
+ byte *t = (byte*)data->_cnv->pixels;
byte *s = (byte*)_buffers[kBitBack]->getBasePtr(x, y);
byte *d = data->_backup;
- uint pitch = _vm->_screenWidth - data->_cnv->_width;
+ uint pitch = _vm->_screenWidth - data->_cnv->w;
- for (uint16 i = 0; i < data->_cnv->_height ; i++) {
- for (uint16 j = 0; j < data->_cnv->_width ; j++) {
+ for (uint16 i = 0; i < data->_cnv->h ; i++) {
+ for (uint16 j = 0; j < data->_cnv->w ; j++) {
*d = (*t) ? *s : 0;
d++;
@@ -558,9 +557,9 @@ void Gfx::backupGetBackground(GetData *data, int16 x, int16 y) {
//
// restores background according to specified frame
//
-void Gfx::restoreDoorBackground(StaticCnv *cnv, const Common::Rect& r, byte* background) {
+void Gfx::restoreDoorBackground(Graphics::Surface *cnv, const Common::Rect& r, byte* background) {
- byte *t = cnv->_data0;
+ byte *t = (byte*)cnv->pixels;
byte *s = background;
byte *d0 = (byte*)_buffers[kBitBack]->getBasePtr(r.left, r.top);
byte *d1 = (byte*)_buffers[kBit2]->getBasePtr(r.left, r.top);
@@ -594,12 +593,11 @@ void Gfx::restoreDoorBackground(StaticCnv *cnv, const Common::Rect& r, byte* bac
//
void Gfx::restoreGetBackground(const Common::Rect& r, byte *data) {
- StaticCnv cnv;
+ Graphics::Surface cnv;
- cnv._data0 = data;
- cnv._data1 = NULL;
- cnv._width = r.width();
- cnv._height = r.height();
+ cnv.w = r.width();
+ cnv.h = r.height();
+ cnv.pixels = data;
flatBlitCnv(&cnv, r.left, r.top, kBitBack);
flatBlitCnv(&cnv, r.left, r.top, kBit2);
@@ -607,28 +605,22 @@ void Gfx::restoreGetBackground(const Common::Rect& r, byte *data) {
return;
}
-void Gfx::makeCnvFromString(StaticCnv *cnv, char *text) {
+void Gfx::makeCnvFromString(Graphics::Surface *cnv, char *text) {
assert(_font == _fonts[kFontLabel]);
if (_vm->getPlatform() == Common::kPlatformAmiga) {
- cnv->_width = _font->getStringWidth(text) + 16;
- cnv->_height = 10;
- cnv->_data0 = (byte*)malloc(cnv->_width * cnv->_height);
- memset(cnv->_data0, 0, cnv->_width * cnv->_height);
+ cnv->create(_font->getStringWidth(text) + 16, 10, 1);
_font->setColor(7);
- _font->drawString(cnv->_data0 + 1, cnv->_width, text);
- _font->drawString(cnv->_data0 + 1 + cnv->_width * 2, cnv->_width, text);
- _font->drawString(cnv->_data0 + cnv->_width, cnv->_width, text);
- _font->drawString(cnv->_data0 + 2 + cnv->_width, cnv->_width, text);
+ _font->drawString((byte*)cnv->pixels + 1, cnv->w, text);
+ _font->drawString((byte*)cnv->pixels + 1 + cnv->w * 2, cnv->w, text);
+ _font->drawString((byte*)cnv->pixels + cnv->w, cnv->w, text);
+ _font->drawString((byte*)cnv->pixels + 2 + cnv->w, cnv->w, text);
_font->setColor(1);
- _font->drawString(cnv->_data0 + 1 + cnv->_width, cnv->_width, text);
+ _font->drawString((byte*)cnv->pixels + 1 + cnv->w, cnv->w, text);
} else {
- cnv->_width = _font->getStringWidth(text);
- cnv->_height = _font->height();
- cnv->_data0 = (byte*)malloc(cnv->_width * cnv->_height);
- memset(cnv->_data0, 0, cnv->_width * cnv->_height);
- _font->drawString(cnv->_data0, cnv->_width, text);
+ cnv->create(_font->getStringWidth(text), _font->height(), 1);
+ _font->drawString((byte*)cnv->pixels, cnv->w, text);
}
}
@@ -758,18 +750,6 @@ void Gfx::restoreBackground(const Common::Rect& r) {
return;
}
-void Gfx::freeStaticCnv(StaticCnv *cnv) {
-
- if (!cnv) return;
-
- if (!cnv || !cnv->_data0) return;
- free(cnv->_data0);
- cnv->_data0 = NULL;
-
- return;
-}
-
-
void Gfx::setBackground(Graphics::Surface *surface) {
if (_buffers[kBit2]) {
@@ -916,7 +896,6 @@ Gfx::~Gfx() {
delete _fonts[kFontLabel];
delete _fonts[kFontMenu];
- freeStaticCnv(_mouseComposedArrow);
delete _mouseComposedArrow;
return;
diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h
index 9f7d2ffd6d..ee0383960f 100644
--- a/engines/parallaction/graphics.h
+++ b/engines/parallaction/graphics.h
@@ -91,18 +91,6 @@ public:
};
-struct StaticCnv {
- uint16 _width; //
- uint16 _height; //
- byte* _data0; // bitmap
- byte* _data1; // unused
-
- StaticCnv() {
- _width = _height = 0;
- _data0 = _data1 = NULL;
- }
-};
-
struct Cnv {
uint16 _count; // # of frames
uint16 _width; //
@@ -207,15 +195,15 @@ public:
bool displayWrappedString(char *text, uint16 x, uint16 y, byte color, int16 wrapwidth = -1);
uint16 getStringWidth(const char *text);
void getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height);
- void makeCnvFromString(StaticCnv *cnv, char *text);
+ void makeCnvFromString(Graphics::Surface *cnv, char *text);
// cut/paste
- void flatBlitCnv(StaticCnv *cnv, int16 x, int16 y, Gfx::Buffers buffer);
+ void flatBlitCnv(Graphics::Surface *cnv, int16 x, int16 y, Gfx::Buffers buffer);
void flatBlitCnv(Cnv *cnv, uint16 frame, int16 x, int16 y, Gfx::Buffers buffer);
- void blitCnv(StaticCnv *cnv, int16 x, int16 y, uint16 z, Gfx::Buffers buffer);
+ void blitCnv(Graphics::Surface *cnv, int16 x, int16 y, uint16 z, Gfx::Buffers buffer);
void restoreBackground(const Common::Rect& r);
void backupDoorBackground(DoorData *data, int16 x, int16 y);
- void restoreDoorBackground(StaticCnv *cnv, const Common::Rect& r, byte* background);
+ void restoreDoorBackground(Graphics::Surface *cnv, const Common::Rect& r, byte* background);
void backupGetBackground(GetData *data, int16 x, int16 y);
void restoreGetBackground(const Common::Rect& r, byte *data);
@@ -242,7 +230,6 @@ public:
void setHalfbriteMode(bool enable);
// misc
- void freeStaticCnv(StaticCnv *cnv);
int16 queryMask(int16 v);
void setMousePointer(int16 index);
void setFont(Fonts name);
@@ -267,7 +254,7 @@ protected:
Graphics::Surface *_buffers[NUM_BUFFERS];
MaskBuffer *_depthMask;
static byte _mouseArrow[256];
- StaticCnv *_mouseComposedArrow;
+ Graphics::Surface *_mouseComposedArrow;
Font *_font;
Font *_fonts[3];
bool _halfbrite;
@@ -287,3 +274,4 @@ protected:
#endif
+
diff --git a/engines/parallaction/menu.cpp b/engines/parallaction/menu.cpp
index 12b03ab4b0..ed065b4ae4 100644
--- a/engines/parallaction/menu.cpp
+++ b/engines/parallaction/menu.cpp
@@ -343,11 +343,8 @@ void Menu::selectCharacter() {
uint16 _donna_points, _dino_points, _dough_points;
- StaticCnv v14;
-
- v14._data0 = (byte*)malloc(BLOCK_WIDTH*BLOCK_HEIGHT);
- v14._width = BLOCK_WIDTH;
- v14._height = BLOCK_HEIGHT;
+ Graphics::Surface v14;
+ v14.create(BLOCK_WIDTH, BLOCK_HEIGHT, 1);
_vm->changeCursor(kCursorArrow);
_vm->_soundMan->stopMusic();
@@ -383,7 +380,7 @@ void Menu::selectCharacter() {
Common::Rect r;
int _si = getSelectedBlock(_vm->_mousePos, r);
if (_si != -1) {
- _vm->_gfx->grabRect(v14._data0, r, Gfx::kBitFront, BLOCK_WIDTH);
+ _vm->_gfx->grabRect((byte*)v14.pixels, r, Gfx::kBitFront, BLOCK_WIDTH);
_vm->_gfx->flatBlitCnv(&v14, _di * SLOT_WIDTH + SLOT_X, SLOT_Y, Gfx::kBitFront);
// beep();
@@ -435,7 +432,7 @@ void Menu::selectCharacter() {
_engineFlags |= kEngineChangeLocation;
- free(v14._data0);
+ v14.free();
return;
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 51b832062c..35e29351ca 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -701,9 +701,7 @@ void Parallaction::freeCharacter() {
delete _char._talk;
_char._talk = NULL;
- _gfx->freeStaticCnv(_char._head);
- if (_char._head)
- delete _char._head;
+ delete _char._head;
_char._head = NULL;
if (_char._objs)
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index 417f57c119..88c80bbf7b 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -238,7 +238,7 @@ struct Location {
struct Character {
Animation _ani;
- StaticCnv *_head;
+ Graphics::Surface *_head;
Cnv *_talk;
Cnv *_objs;
PathBuilder _builder;
@@ -256,7 +256,7 @@ struct Character {
_ani._frame = 0;
_ani._flags = kFlagsActive | kFlagsNoName;
_ani._type = kZoneYou;
- _ani._label._cnv._data0 = NULL;
+ _ani._label._cnv.pixels = NULL;
_ani._label._text = strdup("yourself");
}
diff --git a/engines/parallaction/zone.cpp b/engines/parallaction/zone.cpp
index 50f63b3b75..2ef1195b8e 100644
--- a/engines/parallaction/zone.cpp
+++ b/engines/parallaction/zone.cpp
@@ -236,7 +236,7 @@ void Parallaction::parseZoneTypeBlock(Script &script, Zone *z) {
if (!scumm_stricmp(_tokens[0], "file")) {
strcpy(vC8, _tokens[1]);
u->get->_cnv = _disk->loadStatic(vC8);
- u->get->_backup = (byte*)malloc(u->get->_cnv->_width*u->get->_cnv->_height);
+ u->get->_backup = (byte*)malloc(u->get->_cnv->w*u->get->_cnv->h);
if ((z->_flags & kFlagsRemove) == 0) {
_gfx->backupGetBackground(u->get, z->_left, z->_top);
@@ -338,8 +338,7 @@ void Parallaction::displayItemComment(ExamineData *data) {
char v68[PATH_LEN];
strcpy(v68, data->_filename);
data->_cnv = _disk->loadStatic(v68);
- _gfx->flatBlitCnv(data->_cnv, 140, (_screenHeight - data->_cnv->_height)/2, Gfx::kBitFront);
- _gfx->freeStaticCnv(data->_cnv);
+ _gfx->flatBlitCnv(data->_cnv, 140, (_screenHeight - data->_cnv->h)/2, Gfx::kBitFront);
delete data->_cnv;
int16 v6A = 0, v6C = 0;
@@ -421,16 +420,16 @@ void jobToggleDoor(void *parm, Job *j) {
Zone *z = (Zone*)parm;
- StaticCnv v14;
+ Graphics::Surface v14;
if (z->u.door->_cnv) {
Common::Rect r(z->_left, z->_top, z->_left+z->u.door->_cnv->_width, z->_top+z->u.door->_cnv->_height);
uint16 _ax = (z->_flags & kFlagsClosed ? 1 : 0);
- v14._width = z->u.door->_cnv->_width;
- v14._height = z->u.door->_cnv->_height;
- v14._data0 = z->u.door->_cnv->getFramePtr(_ax);
+ v14.w = z->u.door->_cnv->_width;
+ v14.h = z->u.door->_cnv->_height;
+ v14.pixels = z->u.door->_cnv->getFramePtr(_ax);
_vm->_gfx->restoreDoorBackground(&v14, r, z->u.door->_background);
@@ -470,7 +469,7 @@ void jobRemovePickedItem(void *parm, Job *j) {
static uint16 count = 0;
if (z->u.get->_cnv) {
- Common::Rect r(z->_left, z->_top, z->_left + z->u.get->_cnv->_width, z->_top + z->u.get->_cnv->_height);
+ Common::Rect r(z->_left, z->_top, z->_left + z->u.get->_cnv->w, z->_top + z->u.get->_cnv->h);
_vm->_gfx->restoreGetBackground(r, z->u.get->_backup);
}
@@ -635,7 +634,6 @@ Zone::~Zone() {
case kZoneGet:
free(u.get->_backup);
- _vm->_gfx->freeStaticCnv(u.get->_cnv);
if (u.get->_cnv)
delete u.get->_cnv;
delete u.get;
@@ -681,7 +679,7 @@ Label::Label() {
}
Label::~Label() {
- _vm->_gfx->freeStaticCnv(&_cnv);
+ _cnv.free();
if (_text)
free(_text);
}
diff --git a/engines/parallaction/zone.h b/engines/parallaction/zone.h
index 634a1364aa..c6a1164eb4 100644
--- a/engines/parallaction/zone.h
+++ b/engines/parallaction/zone.h
@@ -104,7 +104,7 @@ struct Dialogue {
struct GetData { // size = 24
uint32 _icon;
- StaticCnv *_cnv;
+ Graphics::Surface *_cnv;
byte *_backup;
uint16 field_14; // unused
uint16 field_16; // unused
@@ -125,7 +125,7 @@ struct SpeakData { // size = 36
}
};
struct ExamineData { // size = 28
- StaticCnv *_cnv;
+ Graphics::Surface *_cnv;
uint16 _opBase; // unused
uint16 field_12; // unused
char* _description;
@@ -193,7 +193,7 @@ struct TypeData {
struct Label {
char* _text;
- StaticCnv _cnv;
+ Graphics::Surface _cnv;
Label();
~Label();