aboutsummaryrefslogtreecommitdiff
path: root/engines/m4/assets.cpp
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/m4/assets.cpp
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/m4/assets.cpp')
-rw-r--r--engines/m4/assets.cpp30
1 files changed, 24 insertions, 6 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) {