aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2010-02-17 11:37:17 +0000
committerPaul Gilbert2010-02-17 11:37:17 +0000
commitbf82639c04ccc4508a605f263d844138f6d22a6b (patch)
tree9d304fbfe846de37139a645080bc7d578697aa28 /engines
parent2d03db8a203a8628a2e55c25ad8c1ab0cb47d503 (diff)
downloadscummvm-rg350-bf82639c04ccc4508a605f263d844138f6d22a6b.tar.gz
scummvm-rg350-bf82639c04ccc4508a605f263d844138f6d22a6b.tar.bz2
scummvm-rg350-bf82639c04ccc4508a605f263d844138f6d22a6b.zip
Implemented player sprite loading portion of scene enter code
svn-id: r48076
Diffstat (limited to 'engines')
-rw-r--r--engines/m4/assets.cpp30
-rw-r--r--engines/m4/assets.h5
-rw-r--r--engines/m4/mads_logic.cpp20
-rw-r--r--engines/m4/scene.cpp72
-rw-r--r--engines/m4/scene.h11
5 files changed, 102 insertions, 36 deletions
diff --git a/engines/m4/assets.cpp b/engines/m4/assets.cpp
index de65c8b782..fa0ec9af34 100644
--- a/engines/m4/assets.cpp
+++ b/engines/m4/assets.cpp
@@ -26,6 +26,7 @@
#include "m4/assets.h"
#include "m4/globals.h"
#include "m4/compression.h"
+#include "m4/graphics.h"
namespace M4 {
@@ -99,6 +100,8 @@ long *DataAsset::getRow(int index) {
SpriteAsset::SpriteAsset(MadsM4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name, bool asStream) : BaseAsset(vm, stream, size, name) {
_stream = stream;
+ _palInterface = NULL;
+ _paletteData = NULL;
if (_vm->isM4()) {
loadM4SpriteAsset(vm, stream, asStream);
@@ -107,6 +110,19 @@ SpriteAsset::SpriteAsset(MadsM4Engine *vm, Common::SeekableReadStream* stream, i
}
}
+SpriteAsset::~SpriteAsset() {
+ if (_palInterface) {
+ // Internally stored palette translation data, so release it
+ _palInterface->deleteRange(_paletteData);
+ delete _paletteData;
+ }
+
+ // Delete the individual frames
+ for (Common::Array<SpriteAssetFrame>::iterator it = _frames.begin(); it != _frames.end(); ++it) {
+ delete (*it).frame;
+ }
+}
+
void SpriteAsset::loadM4SpriteAsset(MadsM4Engine *vm, Common::SeekableReadStream* stream, bool asStream) {
bool isBigEndian = false;
uint32 frameOffset;
@@ -220,12 +236,6 @@ void SpriteAsset::loadMadsSpriteAsset(MadsM4Engine *vm, Common::SeekableReadStre
delete spriteDataStream;
}
-SpriteAsset::~SpriteAsset() {
- for (Common::Array<SpriteAssetFrame>::iterator it = _frames.begin(); it != _frames.end(); ++it) {
- delete (*it).frame;
- }
-}
-
int32 SpriteAsset::parseSprite(bool isBigEndian) {
uint32 format, chunkType, chunkSize = 0;
@@ -325,6 +335,14 @@ void SpriteAsset::translate(RGBList *list, bool isTransparent) {
_frames[frameIndex].frame->translate(list, isTransparent);
}
+void SpriteAsset::translate(Palette *palette) {
+ _palInterface = palette;
+ _paletteData = this->getRgbList();
+ palette->addRange(_paletteData);
+ this->translate(_paletteData, true);
+}
+
+
int32 SpriteAsset::getFrameSize(int index) {
/*
if (index + 1 == _frameCount) {
diff --git a/engines/m4/assets.h b/engines/m4/assets.h
index af630514eb..7b0ce24dc4 100644
--- a/engines/m4/assets.h
+++ b/engines/m4/assets.h
@@ -45,6 +45,7 @@ namespace M4 {
#define CELS___SS MKID_BE(' SS') //' SS'
class MadsM4Engine;
+class Palette;
class BaseAsset {
public:
@@ -118,6 +119,7 @@ public:
int getColorCount() { return _colorCount; }
RGBList *getRgbList();
void translate(RGBList *list, bool isTransparent = false);
+ void translate(Palette *palette);
int32 getFrameSize(int index);
M4Sprite *operator[](int index) { return getFrame(index); }
protected:
@@ -133,6 +135,9 @@ protected:
Common::SeekableReadStream *_stream;
int32 parseSprite(bool isBigEndian = false);
void loadFrameHeader(SpriteAssetFrame &frameHeader, bool isBigEndian = false);
+private:
+ RGBList *_paletteData;
+ Palette *_palInterface;
};
enum AssetType {
diff --git a/engines/m4/mads_logic.cpp b/engines/m4/mads_logic.cpp
index 2199a05d52..693dd7d03f 100644
--- a/engines/m4/mads_logic.cpp
+++ b/engines/m4/mads_logic.cpp
@@ -36,9 +36,7 @@ const char *MadsSceneLogic::formAnimName(char sepChar, int suffixNum) {
}
void MadsSceneLogic::getSceneSpriteSet() {
- char *setName = _madsVm->scene()->_playerSpriteName;
- char oldName[100];
- strcpy(oldName, setName);
+ char prefix[100];
// Room change sound
_madsVm->_sound->playSound(5);
@@ -46,20 +44,20 @@ void MadsSceneLogic::getSceneSpriteSet() {
// Set up sprite set prefix to use
if ((_sceneNumber <= 103) || (_sceneNumber == 111)) {
if (_madsVm->globals()->_globals[0] == SEX_FEMALE)
- strcpy(setName, "ROX");
+ strcpy(prefix, "ROX");
else
- strcpy(setName, "RXM");
+ strcpy(prefix, "RXM");
} else if (_sceneNumber <= 110) {
- strcpy(setName, "RXSW");
+ strcpy(prefix, "RXSW");
_madsVm->globals()->_globals[0] = SEX_UNKNOWN;
} else if (_sceneNumber == 112)
- strcpy(setName, "");
+ strcpy(prefix, "");
- if (strcmp(setName, oldName) != 0)
- _madsVm->globals()->playerSpriteChanged = true;
+ _madsVm->globals()->playerSpriteChanged = true;
+ _madsVm->scene()->loadPlayerSprites(prefix);
- if ((_sceneNumber == 105)/* || ((_sceneNumber == 109) && (word_84800 != 0))*/)
- _madsVm->globals()->playerSpriteChanged = true;
+// if ((_sceneNumber == 105) ((_sceneNumber == 109) && (word_84800 != 0)))
+// _madsVm->globals()->playerSpriteChanged = true;
_vm->_palette->setEntry(16, 0x38, 0xFF, 0xFF);
_vm->_palette->setEntry(17, 0x38, 0xb4, 0xb4);
diff --git a/engines/m4/scene.cpp b/engines/m4/scene.cpp
index 610b6191f5..a5982219a0 100644
--- a/engines/m4/scene.cpp
+++ b/engines/m4/scene.cpp
@@ -55,22 +55,7 @@ Scene::Scene(MadsM4Engine *vm): View(vm, Common::Rect(0, 0, vm->_screen->width()
}
Scene::~Scene() {
- _sceneResources.hotspots->clear();
- _sceneResources.parallax->clear();
- _sceneResources.props->clear();
-
- delete _sceneResources.hotspots;
- delete _sceneResources.parallax;
- delete _sceneResources.props;
-
- delete _backgroundSurface;
- delete _codeSurface;
-
-// _vm->_palette->deleteAllRanges();
-
- delete _palData;
- delete _interfacePal;
- delete[] _inverseColorTable;
+ leaveScene();
}
void Scene::loadScene(int sceneNumber) {
@@ -88,6 +73,12 @@ void Scene::loadScene(int sceneNumber) {
}
}
+void Scene::leaveScene() {
+ delete _palData;
+ delete _interfacePal;
+ delete[] _inverseColorTable;
+}
+
void Scene::show() {
_vm->_viewManager->addView(this);
}
@@ -603,7 +594,6 @@ MadsScene::MadsScene(MadsEngine *vm): Scene(vm) {
_vm = vm;
strcpy(_statusText, "");
- strcpy(_playerSpriteName, "");
_interfaceSurface = new MadsInterfaceView(vm);
_currentAction = kVerbNone;
}
@@ -664,6 +654,25 @@ void MadsScene::loadScene(int sceneNumber) {
_vm->res()->purge();
}
+void MadsScene::leaveScene() {
+ _sceneResources.hotspots->clear();
+ _sceneResources.parallax->clear();
+ _sceneResources.props->clear();
+
+ delete _sceneResources.hotspots;
+ delete _sceneResources.parallax;
+ delete _sceneResources.props;
+
+ // Delete the sprites
+ for (uint i = 0; i <_sceneSprites.size(); ++i) delete _sceneSprites[i];
+ _sceneSprites.clear();
+
+ delete _backgroundSurface;
+ delete _codeSurface;
+
+ Scene::leaveScene();
+}
+
void MadsScene::show() {
Scene::show();
_vm->_viewManager->addView(_interfaceSurface);
@@ -773,6 +782,35 @@ void MadsScene::update() {
}
_interfaceSurface->copyTo(this, 0, this->height() - _interfaceSurface->height());
+
+ //***DEBUG***
+ _sceneSprites[0]->getFrame(1)->copyTo(this, 120, 90, 0);
+}
+
+void MadsScene::loadPlayerSprites(const char *prefix) {
+ const char suffixList[8] = { '8', '9', '6', '3', '2', '7', '4', '1' };
+ char setName[80];
+
+ strcpy(setName, "*");
+ strcat(setName, prefix);
+ strcat(setName, "_0.SS");
+ char *digitP = strchr(setName, '_') + 1;
+
+ for (int idx = 0; idx < 8; ++idx) {
+ *digitP = suffixList[idx];
+
+ if (_vm->res()->resourceExists(setName)) {
+ Common::SeekableReadStream *data = _vm->res()->get(setName);
+ SpriteAsset *playerSprites = new SpriteAsset(_vm, data, data->size(), setName);
+ playerSprites->translate(_vm->_palette);
+ _vm->res()->toss(setName);
+
+ _sceneSprites.push_back(playerSprites);
+ return;
+ }
+ }
+
+ error("Couldn't find player sprites");
}
} // End of namespace M4
diff --git a/engines/m4/scene.h b/engines/m4/scene.h
index d97d43de0d..b0f97ff1a5 100644
--- a/engines/m4/scene.h
+++ b/engines/m4/scene.h
@@ -36,6 +36,7 @@ class View;
#include "m4/m4_views.h"
#include "m4/mads_logic.h"
#include "m4/mads_views.h"
+#include "common/array.h"
namespace M4 {
@@ -101,6 +102,7 @@ public:
// Methods that differ between engines
virtual void loadScene(int sceneNumber);
+ virtual void leaveScene();
virtual void loadSceneCodes(int sceneNumber, int index = 0) = 0;
virtual void show();
virtual void checkHotspotAtMousePos(int x, int y) = 0;
@@ -146,6 +148,7 @@ public:
// Methods that differ between engines
virtual void loadScene(int sceneNumber);
+ virtual void leaveScene() {};
virtual void loadSceneCodes(int sceneNumber, int index = 0);
virtual void show();
virtual void checkHotspotAtMousePos(int x, int y);
@@ -158,6 +161,8 @@ public:
M4InterfaceView *getInterface() { return (M4InterfaceView *)_interfaceSurface; };
};
+typedef Common::Array<SpriteAsset *> SpriteAssetArray;
+
class MadsScene : public Scene {
private:
MadsEngine *_vm;
@@ -166,15 +171,15 @@ private:
char _statusText[100];
MadsSceneLogic _sceneLogic;
SpriteAsset *_playerSprites;
+ SpriteAssetArray _sceneSprites;
public:
- char _playerSpriteName[100];
char _aaName[100];
public:
MadsScene(MadsEngine *vm);
- virtual ~MadsScene() {};
// Methods that differ between engines
virtual void loadScene(int sceneNumber);
+ virtual void leaveScene();
virtual void loadSceneCodes(int sceneNumber, int index = 0);
virtual void show();
virtual void checkHotspotAtMousePos(int x, int y);
@@ -184,6 +189,8 @@ public:
virtual void setStatusText(const char *text);
virtual void update();
+ void loadPlayerSprites(const char *prefix);
+
MadsInterfaceView *getInterface() { return (MadsInterfaceView *)_interfaceSurface; };
};