aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2010-06-03 10:46:55 +0000
committerPaul Gilbert2010-06-03 10:46:55 +0000
commit26860b8e5170d9da92b5da82325c137fddfd8778 (patch)
tree340cceee0b47095bf530f605a62b3a7f86f9addb
parent2ae4c5796b44f6ab6ecf68425e096dde50cb9f95 (diff)
downloadscummvm-rg350-26860b8e5170d9da92b5da82325c137fddfd8778.tar.gz
scummvm-rg350-26860b8e5170d9da92b5da82325c137fddfd8778.tar.bz2
scummvm-rg350-26860b8e5170d9da92b5da82325c137fddfd8778.zip
Properly implemented the logic for loading the correct interface background as specified in a scene's resources
svn-id: r49409
-rw-r--r--engines/m4/animation.cpp32
-rw-r--r--engines/m4/animation.h4
-rw-r--r--engines/m4/graphics.cpp20
-rw-r--r--engines/m4/graphics.h3
4 files changed, 31 insertions, 28 deletions
diff --git a/engines/m4/animation.cpp b/engines/m4/animation.cpp
index 412f514e5b..58d829c4a2 100644
--- a/engines/m4/animation.cpp
+++ b/engines/m4/animation.cpp
@@ -45,7 +45,7 @@ MadsAnimation::~MadsAnimation() {
delete _font;
}
-void MadsAnimation::load(const Common::String &filename, uint16 flags, M4Surface *walkSurface, M4Surface *sceneSurface) {
+void MadsAnimation::load(const Common::String &filename, uint16 flags, M4Surface *interfaceSurface, M4Surface *sceneSurface) {
MadsPack anim(filename.c_str(), _vm);
bool madsRes = filename[0] == '*';
char buffer[20];
@@ -66,8 +66,8 @@ void MadsAnimation::load(const Common::String &filename, uint16 flags, M4Surface
animStream->skip(2);
_animMode = animStream->readUint16LE();
_roomNumber = animStream->readUint16LE();
+ animStream->skip(2);
_field12 = animStream->readUint16LE() != 0;
- animStream->skip(4);
_spriteListIndex = animStream->readUint16LE();
_scrollX = animStream->readUint16LE();
_scrollY = animStream->readSint16LE();
@@ -96,7 +96,7 @@ void MadsAnimation::load(const Common::String &filename, uint16 flags, M4Surface
if (_animMode == 4)
flags |= 0x4000;
if (flags & 0x100)
- loadInterface(walkSurface, sceneSurface);
+ loadInterface(interfaceSurface, sceneSurface);
// Initialise the reference list
for (int i = 0; i < spriteListCount; ++i)
@@ -424,18 +424,28 @@ bool MadsAnimation::proc1(SpriteAsset &spriteSet, const Common::Point &pt, int f
return 0;
}
-void MadsAnimation::loadInterface(M4Surface *walkSurface, M4Surface *sceneSurface) {
- walkSurface->madsloadInterface(0);
+void MadsAnimation::loadInterface(M4Surface *&interfaceSurface, M4Surface *&depthSurface) {
+ if (_animMode <= 2) {
+ MadsSceneResources sceneResources;
+ sceneResources.load(_roomNumber, _infoFilename.c_str(), 0, depthSurface, interfaceSurface);
+ // Rex only supports a single dialog draw style
+ assert(sceneResources.dialogStyle == 2);
- /* TODO - implement properly
- if (_animMode > 2) {
- warning("Mode1");
+ } else if (_animMode == 4) {
+ // Load a scene interface
+ interfaceSurface->madsLoadInterface(_infoFilename);
} else {
- MadsSceneResources sceneResources;
- sceneResources.load(_roomNumber, _infoFilename.c_str(), 0, walkSurface, sceneSurface);
+ // This mode allocates two large surfaces for the animation
+ // TODO: Are these ever properly freed?
+error("Anim mode %d - need to check free logic", _animMode);
+ assert(!interfaceSurface);
+ assert(!depthSurface);
+ depthSurface = new M4Surface(MADS_SURFACE_WIDTH, MADS_SCREEN_HEIGHT);
+ interfaceSurface = new M4Surface(MADS_SURFACE_WIDTH, MADS_SCREEN_HEIGHT);
+ depthSurface->clear();
+ interfaceSurface->clear();
}
- */
}
} // End of namespace M4
diff --git a/engines/m4/animation.h b/engines/m4/animation.h
index cb68b27853..838e4b6175 100644
--- a/engines/m4/animation.h
+++ b/engines/m4/animation.h
@@ -104,12 +104,12 @@ private:
void load1(int frameNumber);
bool proc1(SpriteAsset &spriteSet, const Common::Point &pt, int frameNumber);
- void loadInterface(M4Surface *walkSurface, M4Surface *sceneSurface);
+ void loadInterface(M4Surface *&interfaceSurface, M4Surface *&depthSurface);
public:
MadsAnimation(MadsM4Engine *vm, MadsView *view);
virtual ~MadsAnimation();
- virtual void load(const Common::String &filename, uint16 flags, M4Surface *walkSurface, M4Surface *sceneSurface);
+ virtual void load(const Common::String &filename, uint16 flags, M4Surface *interfaceSurface, M4Surface *sceneSurface);
virtual void start();
virtual bool update();
virtual void stop();
diff --git a/engines/m4/graphics.cpp b/engines/m4/graphics.cpp
index edabcd8b22..29aaa184a3 100644
--- a/engines/m4/graphics.cpp
+++ b/engines/m4/graphics.cpp
@@ -727,16 +727,10 @@ void M4Surface::m4LoadBackground(Common::SeekableReadStream *source) {
delete tileBuffer;
}
-void M4Surface::madsloadInterface(int index, RGBList **palData) {
- char resourceName[20];
- sprintf(resourceName, "i%d.int", index);
- MadsPack intFile(resourceName, _vm);
+void M4Surface::madsLoadInterface(const Common::String &filename) {
+ MadsPack intFile(filename.c_str(), _vm);
RGB8 *palette = new RGB8[16];
- bool hasPalette = palData != NULL;
- if (!hasPalette)
- palData = &_rgbList;
-
// Chunk 0, palette
Common::SeekableReadStream *intStream = intFile.getItemStream(0);
@@ -748,7 +742,7 @@ void M4Surface::madsloadInterface(int index, RGBList **palData) {
intStream->readByte();
intStream->readByte();
}
- *palData = new RGBList(16, palette, true);
+ _rgbList = new RGBList(16, palette, true);
delete intStream;
// Chunk 1, data
@@ -757,11 +751,9 @@ void M4Surface::madsloadInterface(int index, RGBList **palData) {
intStream->read(pixels, 320 * 44);
delete intStream;
- if (!hasPalette) {
- // Translate the interface palette
- _vm->_palette->addRange(_rgbList);
- this->translate(_rgbList);
- }
+ // Translate the interface palette
+ _vm->_palette->addRange(_rgbList);
+ this->translate(_rgbList);
}
void M4Surface::scrollX(int xAmount) {
diff --git a/engines/m4/graphics.h b/engines/m4/graphics.h
index 97fdfc0d6c..8c4b9ac072 100644
--- a/engines/m4/graphics.h
+++ b/engines/m4/graphics.h
@@ -122,7 +122,8 @@ public:
// loads the specified background
void loadBackground(int sceneNumber, RGBList **palData = NULL);
void loadBackgroundRiddle(const char *sceneName);
- void madsloadInterface(int index, RGBList **palData = NULL);
+ void madsLoadInterface(int index, RGBList **palData = NULL);
+ void madsLoadInterface(const Common::String &filename);
void setColor(byte value) { _color = value; }
void setColour(byte value) { _color = value; }