aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2010-06-07 09:19:42 +0000
committerPaul Gilbert2010-06-07 09:19:42 +0000
commit34f7c05e4dd0e7cd3f84576f57593d034f666d31 (patch)
treebe457ad91a6ec54dc233a6db1981d9558498fcbf
parent43ec405ffe08cef3168c9618be6169e6d81290f8 (diff)
downloadscummvm-rg350-34f7c05e4dd0e7cd3f84576f57593d034f666d31.tar.gz
scummvm-rg350-34f7c05e4dd0e7cd3f84576f57593d034f666d31.tar.bz2
scummvm-rg350-34f7c05e4dd0e7cd3f84576f57593d034f666d31.zip
Initial conversion of the AnimviewView class to use the expanded MadsAnimation class, rather than the older AAFile skeleton class
svn-id: r49478
-rw-r--r--engines/m4/animation.cpp12
-rw-r--r--engines/m4/animation.h3
-rw-r--r--engines/m4/graphics.cpp11
-rw-r--r--engines/m4/mads_anim.cpp128
-rw-r--r--engines/m4/mads_anim.h39
-rw-r--r--engines/m4/mads_menus.cpp2
-rw-r--r--engines/m4/viewmgr.h13
7 files changed, 63 insertions, 145 deletions
diff --git a/engines/m4/animation.cpp b/engines/m4/animation.cpp
index b372222bd0..1142ba48d1 100644
--- a/engines/m4/animation.cpp
+++ b/engines/m4/animation.cpp
@@ -39,6 +39,11 @@ MadsAnimation::MadsAnimation(MadsM4Engine *vm, MadsView *view): Animation(vm), _
_skipLoad = false;
_unkIndex = -1;
_messageCtr= 0;
+ _field12 = 0;
+
+ _currentFrame = 0;
+ _oldFrameEntry = 0;
+ _nextFrameTimer = _madsVm->_currentTimer;
}
MadsAnimation::~MadsAnimation() {
@@ -237,12 +242,14 @@ void MadsAnimation::load(const Common::String &filename, int abortTimers) {
_messageCtr = 0;
_skipLoad = true;
+/* TODO: figure out extra stuff in this routine
if (_field12) {
_unkIndex = -1;
int listIndex = _spriteListIndexes[_spriteListIndex];
SpriteAsset &spriteSet = _view->_spriteSlots.getSprite(listIndex);
-warning("%d", spriteSet.getCount());
+ ..?..
}
+*/
// Initialise miscellaneous fields
_currentFrame = 0;
@@ -463,9 +470,6 @@ void MadsAnimation::loadInterface(M4Surface *&interfaceSurface, M4Surface *&dept
MadsSceneResources sceneResources;
sceneResources.load(_roomNumber, _interfaceFile.c_str(), 0, depthSurface, interfaceSurface);
- // Rex only supports a single dialog draw style
- assert(sceneResources.drawStyle == 2);
-
} else if (_animMode == 4) {
// Load a scene interface
interfaceSurface->madsLoadInterface(_interfaceFile);
diff --git a/engines/m4/animation.h b/engines/m4/animation.h
index 883d3f2de6..5c7227a256 100644
--- a/engines/m4/animation.h
+++ b/engines/m4/animation.h
@@ -63,7 +63,7 @@ public:
#define ANIM_SPRITE_SET_SIZE 50
-enum MadsAnimationFlags {ANIM_CUSTOM_FONT = 0x20};
+enum MadsAnimationFlags {ANIM_CUSTOM_FONT = 0x20, ANIM_HAS_SOUND = 0x8000};
class MadsAnimation: public Animation {
private:
@@ -114,6 +114,7 @@ public:
virtual void setCurrentFrame(int frameNumber);
bool freeFlag() const { return _freeFlag; }
+ int roomNumber() const { return _roomNumber; }
};
} // End of namespace M4
diff --git a/engines/m4/graphics.cpp b/engines/m4/graphics.cpp
index 29aaa184a3..8624f18da1 100644
--- a/engines/m4/graphics.cpp
+++ b/engines/m4/graphics.cpp
@@ -633,16 +633,6 @@ void M4Surface::rexLoadBackground(Common::SeekableReadStream *source, RGBList **
int sceneWidth = sourceUnc->readUint16LE();
int sceneHeight = sourceUnc->readUint16LE();
int sceneSize = sceneWidth * sceneHeight;
- if (sceneWidth > this->width()) {
- warning("Background width is %i, too large to fit in screen. Setting it to %i", sceneWidth, this->width());
- sceneWidth = this->width();
- sceneSize = sceneWidth * sceneHeight;
- }
- if (sceneHeight > this->height()) {
- warning("Background height is %i, too large to fit in screen.Setting it to %i", sceneHeight, this->height());
- sceneHeight = this->height();
- sceneSize = sceneWidth * sceneHeight;
- }
// Set palette
if (!palData) {
@@ -658,6 +648,7 @@ void M4Surface::rexLoadBackground(Common::SeekableReadStream *source, RGBList **
sourceUnc = packData.getItemStream(1);
assert((int)sourceUnc->size() >= sceneSize);
+ create(sceneWidth, sceneHeight, 1);
byte *pData = (byte *)pixels;
sourceUnc->read(pData, sceneSize);
diff --git a/engines/m4/mads_anim.cpp b/engines/m4/mads_anim.cpp
index 24a041e04d..7709b65780 100644
--- a/engines/m4/mads_anim.cpp
+++ b/engines/m4/mads_anim.cpp
@@ -441,7 +441,11 @@ void TextviewView::processText() {
AnimviewView::AnimviewView(MadsM4Engine *vm):
View(vm, Common::Rect(0, 0, vm->_screen->width(), vm->_screen->height())),
- _bgSurface(vm->_screen->width(), MADS_SURFACE_HEIGHT) {
+ MadsView(this), _backgroundSurface(MADS_SURFACE_WIDTH, MADS_SURFACE_HEIGHT),
+ _codeSurface(MADS_SURFACE_WIDTH, MADS_SURFACE_HEIGHT) {
+
+ MadsView::_bgSurface = &_backgroundSurface;
+ MadsView::_depthSurface = &_codeSurface;
_screenType = VIEWID_ANIMVIEW;
_screenFlags.layer = LAYER_BACKGROUND;
@@ -452,27 +456,28 @@ AnimviewView::AnimviewView(MadsM4Engine *vm):
_palData = NULL;
_previousUpdate = 0;
_transition = kTransitionNone;
+ _activeAnimation = NULL;
reset();
// Set up system palette colors
_vm->_palette->setMadsSystemPalette();
clear();
- _bgSurface.clear();
+ _backgroundSurface.clear();
- int y = (height() - MADS_SURFACE_HEIGHT) / 2;
setColor(2);
- hLine(0, width() - 1, y - 2);
- hLine(0, width() - 1, height() - y + 1);
+ hLine(0, width() - 1, MADS_Y_OFFSET - 2);
+ hLine(0, width() - 1, MADS_Y_OFFSET + MADS_SURFACE_HEIGHT + 2);
}
AnimviewView::~AnimviewView() {
if (_script)
_vm->res()->toss(_resourceName);
+ delete _activeAnimation;
}
void AnimviewView::reset() {
- _bgSurface.clear();
+ _backgroundSurface.clear();
_soundDriverLoaded = false;
}
@@ -515,19 +520,26 @@ void AnimviewView::updateState() {
_previousUpdate = g_system->getMillis();
}
- // Check if we're ready for the next command
- bool animRunning = false;
- if (!animRunning) {
+ if (!_activeAnimation) {
+ readNextCommand();
+ assert(_activeAnimation);
+ }
+
+ // Update the current animation
+ _activeAnimation->update();
+ if (_activeAnimation->freeFlag()) {
+ delete _activeAnimation;
+ _activeAnimation = NULL;
+
if (_script->eos() || _script->err()) {
scriptDone();
return;
}
readNextCommand();
-
- // FIXME: Replace flag with proper animation end check
- animRunning = true;
}
+
+ refresh();
}
void AnimviewView::readNextCommand() {
@@ -562,46 +574,15 @@ void AnimviewView::readNextCommand() {
if (strchr(_currentLine, '.') == NULL)
strcat(_currentLine, ".aa");
- AAFile aaFile(_currentLine, _vm);
-
- // Initial validation
- if (aaFile.flags & AA_HAS_FONT) {
- assert(_vm->_resourceManager->resourceExists(aaFile.fontResource.c_str()));
- }
-
- for (int seriesCtr = 0; seriesCtr < aaFile.seriesCount; ++seriesCtr)
- assert(_vm->_resourceManager->resourceExists(aaFile.filenames[seriesCtr].c_str()));
-
- // Start sound
- if (aaFile.flags & AA_HAS_SOUND) {
- char buffer[100];
- strcpy(buffer, aaFile.soundName.c_str());
- buffer[0] = 'A'; // A for AdLib resource
-
- /*Common::SeekableReadStream *stream = */_vm->_resourceManager->get(buffer);
-
- _vm->_resourceManager->toss(buffer);
- }
+ _activeAnimation = new MadsAnimation(_vm, this);
+ _activeAnimation->load(_currentLine, 0);
+ _backgroundSurface.loadBackground(_activeAnimation->roomNumber());
+ _codeSurface.create(_backgroundSurface.width(), _backgroundSurface.height(), 1);
+ _codeSurface.clear();
- char artFile[80];
- sprintf(artFile, "rm%d.art", aaFile.roomNumber);
-
- // Not all scenes have a background. If there is one, refresh it
- if (_vm->_resourceManager->resourceExists(artFile)) {
- if (_palData) {
- _vm->_palette->deleteRange(_palData);
- delete _palData;
- }
- _bgSurface.loadBackground(aaFile.roomNumber, &_palData);
- _vm->_palette->addRange(_palData);
- _bgSurface.translate(_palData);
- }
-
- // Grab what the final palete will be
- RGB8 destPalette[256];
- _vm->_palette->grabPalette(destPalette, 0, 256);
-
+ _spriteSlots.fullRefresh();
+/*
// Handle scene transition
switch (_transition) {
case kTransitionNone:
@@ -631,16 +612,14 @@ void AnimviewView::readNextCommand() {
// nothing to do
break;
}
-
- // Refresh the view
- int yp = (height() - _bgSurface.height()) / 2;
- _bgSurface.copyTo(this, 0, yp);
+*/
_vm->_resourceManager->toss(_currentLine);
}
void AnimviewView::scriptDone() {
+return;
AnimviewCallback fn = _callback;
MadsM4Engine *vm = _vm;
@@ -714,45 +693,4 @@ void AnimviewView::processCommand() {
}
}
-AAFile::AAFile(const char *resourceName, MadsM4Engine* vm): MadsPack(resourceName, vm) {
- Common::MemoryReadStream stream1(*getItemStream(1));
- Common::MemoryReadStream stream2(*getItemStream(2));
-
- Common::MemoryReadStream stream(*getItemStream(0));
-
- seriesCount = stream.readUint16LE();
- frameCount = stream.readUint16LE();
- frameEntryCount = stream.readUint16LE();
- stream.skip(3);
- flags = stream.readByte();
- stream.skip(4);
- roomNumber = stream.readUint16LE();
- stream.skip(10);
- frameTicks = stream.readUint16LE();
-
- stream.skip(21);
- for (int i = 0; i < 10; ++i) {
- char filename[13];
- stream.read(filename, 13);
- filenames.push_back(Common::String(filename, 13));
- }
-
- stream.skip(81);
- char name[100];
- stream.read(name, 13);
- lbmFilename = Common::String(name, 13);
-
- stream.skip(365);
- stream.read(name, 13);
- spritesFilename = Common::String(name, 13);
-
- stream.skip(48);
- stream.read(name, 13);
- soundName = Common::String(name, 13);
-
- stream.skip(26);
- stream.read(name, 14);
- fontResource = Common::String(name, 14);
-}
-
}
diff --git a/engines/m4/mads_anim.h b/engines/m4/mads_anim.h
index 680c5ff901..8c4a5e6fb7 100644
--- a/engines/m4/mads_anim.h
+++ b/engines/m4/mads_anim.h
@@ -28,24 +28,12 @@
#include "m4/viewmgr.h"
#include "m4/compression.h"
+#include "m4/animation.h"
#include "common/str-array.h"
namespace M4 {
-enum SceneTransition {
- kTransitionNone = 0,
- kTransitionFadeIn = 1,
- kTransitionFadeIn2 = 2,
- kTransitionBoxInBottomLeft = 3,
- kTransitionBoxInBottomRight = 4,
- kTransitionBoxInTopLeft = 5,
- kTransitionBoxInTopRight = 6,
- kTransitionPanLeftToRight = 7,
- kTransitionPanRightToLeft = 8,
- kTransitionCircleIn = 9
-};
-
typedef void (*TextviewCallback)(MadsM4Engine *vm);
class TextviewView : public View {
@@ -89,36 +77,19 @@ public:
typedef void (*AnimviewCallback)(MadsM4Engine *vm);
-class AAFile : public MadsPack {
-public:
- AAFile(const char *resourceName, MadsM4Engine* vm);
-
- uint16 seriesCount;
- uint16 frameCount;
- uint16 frameEntryCount;
- uint8 flags;
- uint16 roomNumber;
- uint16 frameTicks;
- Common::StringArray filenames;
- Common::String lbmFilename;
- Common::String spritesFilename;
- Common::String soundName;
- Common::String fontResource;
-};
-
-enum AAFlags {AA_HAS_FONT = 0x20, AA_HAS_SOUND = 0x8000};
-
-class AnimviewView : public View {
+class AnimviewView : public View, MadsView {
private:
char _resourceName[80];
Common::SeekableReadStream *_script;
uint32 _previousUpdate;
char _currentLine[80];
- M4Surface _bgSurface;
+ M4Surface _backgroundSurface;
+ M4Surface _codeSurface;
AnimviewCallback _callback;
bool _soundDriverLoaded;
RGBList *_palData;
int _transition;
+ MadsAnimation *_activeAnimation;
void reset();
void readNextCommand();
diff --git a/engines/m4/mads_menus.cpp b/engines/m4/mads_menus.cpp
index d00272d31e..94894e78be 100644
--- a/engines/m4/mads_menus.cpp
+++ b/engines/m4/mads_menus.cpp
@@ -49,7 +49,7 @@ RexMainMenuView::RexMainMenuView(MadsM4Engine *vm):
_skipFlag = false;
// Load the background for the Rex Nebular game
- _bgSurface = new M4Surface(width(), MADS_SURFACE_HEIGHT);
+ _bgSurface = new M4Surface();
_bgSurface->loadBackground(REX_MENUSCREEN, &_bgPalData);
_vm->_palette->addRange(_bgPalData);
_bgSurface->translate(_bgPalData);
diff --git a/engines/m4/viewmgr.h b/engines/m4/viewmgr.h
index 16c3d6ecc3..211e6087f4 100644
--- a/engines/m4/viewmgr.h
+++ b/engines/m4/viewmgr.h
@@ -42,6 +42,19 @@ namespace M4 {
class View;
class ViewManager;
+enum SceneTransition {
+ kTransitionNone = 0,
+ kTransitionFadeIn = 1,
+ kTransitionFadeIn2 = 2,
+ kTransitionBoxInBottomLeft = 3,
+ kTransitionBoxInBottomRight = 4,
+ kTransitionBoxInTopLeft = 5,
+ kTransitionBoxInTopRight = 6,
+ kTransitionPanLeftToRight = 7,
+ kTransitionPanRightToLeft = 8,
+ kTransitionCircleIn = 9
+};
+
enum {SCREEN_DIALOG, SCREEN_BUFFER, SCREEN_TEXT, SCREEN_TRANSPARENT};
enum ScreenEventType {SCREVENT_NONE = 0, SCREVENT_KEY = 1, SCREVENT_MOUSE = 2, SCREVENT_ALL = 3};
enum ScreenLayers {