aboutsummaryrefslogtreecommitdiff
path: root/engines/m4/mads_anim.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/m4/mads_anim.cpp')
-rw-r--r--engines/m4/mads_anim.cpp149
1 files changed, 40 insertions, 109 deletions
diff --git a/engines/m4/mads_anim.cpp b/engines/m4/mads_anim.cpp
index 954916700c..e1dbbaf106 100644
--- a/engines/m4/mads_anim.cpp
+++ b/engines/m4/mads_anim.cpp
@@ -37,7 +37,7 @@ namespace M4 {
TextviewView::TextviewView(MadsM4Engine *vm):
View(vm, Common::Rect(0, 0, vm->_screen->width(), vm->_screen->height())),
_bgSurface(vm->_screen->width(), MADS_SURFACE_HEIGHT),
- _textSurface(vm->_screen->width(), MADS_SURFACE_HEIGHT + vm->_font->getHeight() +
+ _textSurface(vm->_screen->width(), MADS_SURFACE_HEIGHT + vm->_font->current()->getHeight() +
TEXTVIEW_LINE_SPACING) {
_screenType = VIEWID_TEXTVIEW;
@@ -60,7 +60,7 @@ TextviewView::TextviewView(MadsM4Engine *vm):
_vm->_palette->setPalette(&palData[0], 4, 3);
_vm->_palette->blockRange(4, 3);
- _vm->_font->setColors(5, 6, 4);
+ _vm->_font->current()->setColours(5, 6, 4);
clear();
_bgSurface.clear();
@@ -222,7 +222,7 @@ void TextviewView::updateState() {
}
} else {
// Handling a text row
- if (++_lineY == (_vm->_font->getHeight() + TEXTVIEW_LINE_SPACING))
+ if (++_lineY == (_vm->_font->current()->getHeight() + TEXTVIEW_LINE_SPACING))
processLines();
}
@@ -404,7 +404,7 @@ void TextviewView::processText() {
if (!strcmp(_currentLine, "***")) {
// Special signifier for end of script
- _scrollCount = _vm->_font->getHeight() * 13;
+ _scrollCount = _vm->_font->current()->getHeight() * 13;
_lineY = -1;
return;
}
@@ -416,7 +416,7 @@ void TextviewView::processText() {
char *centerP = strchr(_currentLine, '@');
if (centerP) {
*centerP = '\0';
- xStart = (width() / 2) - _vm->_font->getWidth(_currentLine);
+ xStart = (width() / 2) - _vm->_font->current()->getWidth(_currentLine);
// Delete the @ character and shift back the remainder of the string
char *p = centerP + 1;
@@ -424,16 +424,16 @@ void TextviewView::processText() {
strcpy(centerP, p);
} else {
- lineWidth = _vm->_font->getWidth(_currentLine);
+ lineWidth = _vm->_font->current()->getWidth(_currentLine);
xStart = (width() - lineWidth) / 2;
}
// Copy the text line onto the bottom of the textSurface surface, which will allow it
// to gradually scroll onto the screen
- int yp = _textSurface.height() - _vm->_font->getHeight() - TEXTVIEW_LINE_SPACING;
+ int yp = _textSurface.height() - _vm->_font->current()->getHeight() - TEXTVIEW_LINE_SPACING;
_textSurface.fillRect(Common::Rect(0, yp, _textSurface.width(), _textSurface.height()),
_vm->_palette->BLACK);
- _vm->_font->writeString(&_textSurface, _currentLine, xStart, yp);
+ _vm->_font->current()->writeString(&_textSurface, _currentLine, xStart, yp);
}
@@ -441,7 +441,12 @@ 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;
+ MadsView::_yOffset = MADS_Y_OFFSET;
_screenType = VIEWID_ANIMVIEW;
_screenFlags.layer = LAYER_BACKGROUND;
@@ -452,27 +457,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;
}
@@ -507,27 +513,26 @@ void AnimviewView::updateState() {
if (!_script)
return;
- // Only update state if wait period has expired
- if (_previousUpdate > 0) {
- if (g_system->getMillis() - _previousUpdate < 100)
- return;
-
- _previousUpdate = g_system->getMillis();
+ if (!_activeAnimation) {
+ readNextCommand();
+ assert(_activeAnimation);
}
- // Check if we're ready for the next command
- bool animRunning = false;
- if (!animRunning) {
+ // 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 +567,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);
- }
-
-
- 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);
- }
+ _activeAnimation = new MadsAnimation(_vm, this);
+ _activeAnimation->load(_currentLine, 0);
- // Grab what the final palete will be
- RGB8 destPalette[256];
- _vm->_palette->grabPalette(destPalette, 0, 256);
+ _backgroundSurface.loadBackground(_activeAnimation->roomNumber());
+ _codeSurface.setSize(_backgroundSurface.width(), _backgroundSurface.height());
+ _codeSurface.fillRect(_codeSurface.bounds(), 0xff);
+ _spriteSlots.fullRefresh();
+/*
// Handle scene transition
switch (_transition) {
case kTransitionNone:
@@ -631,16 +605,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 +686,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);
-}
-
}