From 1171400ccb65025a77f04dae3a224a3aec5920a3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Aug 2014 15:54:35 -0400 Subject: ACCESS: Beginnings of animation manager --- engines/access/access.cpp | 10 ++---- engines/access/access.h | 5 ++- engines/access/animation.cpp | 79 ++++++++++++++++++++++++++++++++++++++++++++ engines/access/animation.h | 68 ++++++++++++++++++++++++++++++++++++++ engines/access/module.mk | 1 + engines/access/room.cpp | 10 ++++-- engines/access/room.h | 2 ++ engines/access/screen.cpp | 1 + engines/access/screen.h | 1 + engines/access/scripts.cpp | 20 ++++++++--- engines/access/scripts.h | 4 +-- 11 files changed, 182 insertions(+), 19 deletions(-) create mode 100644 engines/access/animation.cpp create mode 100644 engines/access/animation.h (limited to 'engines/access') diff --git a/engines/access/access.cpp b/engines/access/access.cpp index cb1977a7f1..c98588f5ce 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -31,6 +31,7 @@ namespace Access { AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) : _gameDescription(gameDesc), Engine(syst), _randomSource("Access") { + _animation = nullptr; _debugger = nullptr; _events = nullptr; _files = nullptr; @@ -53,7 +54,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _inactive = nullptr; _manPal1 = nullptr; _music = nullptr; - _anim = nullptr; _title = nullptr; _converseMode = 0; _startInvItem = 0; @@ -122,6 +122,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) } AccessEngine::~AccessEngine() { + delete _animation; delete _debugger; delete _events; delete _files; @@ -140,7 +141,6 @@ AccessEngine::~AccessEngine() { delete[] _inactive; delete[] _manPal1; delete[] _music; - delete[] _anim; delete[] _title; } @@ -166,6 +166,7 @@ void AccessEngine::initialize() { } // Create sub-objects of the engine + _animation = new AnimationManager(this); _debugger = new Debugger(this); _events = new EventsManager(this); _files = new FileManager(this); @@ -224,11 +225,6 @@ void AccessEngine::freeCells() { } } -void AccessEngine::freeAnimationData() { - delete[] _anim; - _anim = nullptr; -} - void AccessEngine::freeInactiveData() { delete[] _inactive; _inactive = nullptr; diff --git a/engines/access/access.h b/engines/access/access.h index 18278bf56b..56600e4fb8 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -30,6 +30,7 @@ #include "common/util.h" #include "engines/engine.h" #include "graphics/surface.h" +#include "access\/animation.h" #include "access/data.h" #include "access/debugger.h" #include "access/events.h" @@ -100,6 +101,7 @@ protected: */ virtual void playGame() = 0; public: + AnimationManager *_animation; Debugger *_debugger; EventsManager *_events; FileManager *_files; @@ -135,7 +137,6 @@ public: byte *_inactive; byte *_manPal1; byte *_music; - byte *_anim; byte *_title; int _converseMode; int _startInvItem; @@ -209,8 +210,6 @@ public: int getRandomNumber(int maxNumber); - void freeAnimationData(); - void loadCells(Common::Array &cells); /** diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp new file mode 100644 index 0000000000..4d73801e5d --- /dev/null +++ b/engines/access/animation.cpp @@ -0,0 +1,79 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/endian.h" +#include "access/animation.h" + +namespace Access { + +AnimationManager::AnimationManager(AccessEngine *vm) : Manager(vm) { + _anim = nullptr; + _animation = nullptr; +} + +AnimationManager::~AnimationManager() { + delete[] _anim; + delete _animation; +} + +void AnimationManager::freeAnimationData() { + delete[] _anim; + _anim = nullptr; + _animation = nullptr; +} + +void AnimationManager::clearTimers() { + for (uint i = 0; i < _animationTimers.size(); ++i) + delete _animationTimers[i]; + + _animationTimers.clear(); +} + +Animation *AnimationManager::setAnimation(int animId) { + Animation *anim = findAnimation(animId); + + anim->_countdownTicks = anim->_ticks; + anim->_frameNumber = 0; + + anim->_currentLoopCount = (anim->_type != 3 && anim->_type != 4) ? 0 : + anim->_loopCount; + anim->_field10 = 0; + + return anim; +} + +void AnimationManager::setAnimTimer(Animation *anim) { + +} + +Animation *AnimationManager::findAnimation(int animId) { + _animation = new Animation(_anim + READ_LE_UINT16(_anim + animId * 4 + 2)); + return _animation; +} + +/*------------------------------------------------------------------------*/ + +Animation::Animation(const byte *data) { + +} + +} // End of namespace Access diff --git a/engines/access/animation.h b/engines/access/animation.h new file mode 100644 index 0000000000..010fab98ac --- /dev/null +++ b/engines/access/animation.h @@ -0,0 +1,68 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef ACCESS_ANIMATION_H +#define ACCESS_ANIMATION_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "access/data.h" + +namespace Access { + +class Animation; + +class AnimationManager : public Manager { +private: + Animation *findAnimation(int animId); +public: + const byte *_anim; + Animation *_animation; + Common::Array _animationTimers; +public: + AnimationManager(AccessEngine *vm); + ~AnimationManager(); + void freeAnimationData(); + void clearTimers(); + + Animation *setAnimation(int animId); + + void setAnimTimer(Animation *anim); +}; + +class Animation { +public: + int _type; + int _scaling; + int _frameNumber; + int _ticks; + int _loopCount; + int _countdownTicks; + int _currentLoopCount; + int _field10; +public: + Animation(const byte *data); +}; + +} // End of namespace Access + +#endif /* ACCESS_ANIMATION_H */ diff --git a/engines/access/module.mk b/engines/access/module.mk index 042e84ad86..24c237a18f 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -1,6 +1,7 @@ MODULE := engines/access MODULE_OBJS := \ + animation.o \ asurface.o \ access.o \ data.o \ diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 80ab3329ac..fb70e35ee0 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -144,7 +144,7 @@ void Room::clearRoom() { _vm->_sound->freeSounds(); _vm->_numAnimTimers = 0; - _vm->freeAnimationData(); + _vm->_animation->freeAnimationData(); _vm->_scripts->freeScriptData(); _vm->freeCells(); freePlayField(); @@ -198,9 +198,9 @@ void Room::loadRoomData(const byte *roomData) { roomInfo._scriptFile._subfile); // Load animation data - _vm->freeAnimationData(); + _vm->_animation->freeAnimationData(); if (roomInfo._animFile._fileNum != -1) - _vm->_anim = _vm->_files->loadFile(roomInfo._animFile._fileNum, + _vm->_animation->_anim = _vm->_files->loadFile(roomInfo._animFile._fileNum, roomInfo._animFile._subfile); _vm->_scaleI = roomInfo._scaleI; @@ -312,6 +312,10 @@ void Room::buildColumn(int playX, int screenX) { } } +void Room::init4Quads() { + error("TODO: init4Quads"); +} + /*------------------------------------------------------------------------*/ RoomInfo::RoomInfo(const byte *data) { diff --git a/engines/access/room.h b/engines/access/room.h index c01a753d0a..72963371d6 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -101,6 +101,8 @@ public: void clearRoom(); void buildColumn(int playX, int screenX); + + void init4Quads(); }; diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 1974b1a981..428c3d5df8 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -35,6 +35,7 @@ namespace Access { Screen::Screen(AccessEngine *vm) : _vm(vm) { create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0); + _vesaMode = 0; _vesaCurrentWin = 0; _currentPanel = 0; _hideFlag = true; diff --git a/engines/access/screen.h b/engines/access/screen.h index c32ae18e82..c4beacf17c 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -54,6 +54,7 @@ private: bool clip(Common::Rect &r); public: + int _vesaMode; bool _loadPalFlag; bool _scrollFlag; int _scrollThreshold; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 98ab7f8a54..2705d70d9f 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -87,7 +87,7 @@ void Scripts::executeCommand(int commandIndex, const byte *&pScript) { &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME, &Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, - &Scripts::CMDSETANIM, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, + &Scripts::cmdSetAnim, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL, &Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, &Scripts::CMDSETBUFFER, @@ -104,7 +104,7 @@ void Scripts::executeCommand(int commandIndex, const byte *&pScript) { &Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT, &Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, &Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL, - &Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH + &Scripts::cmdMainPanel, &Scripts::CMDRETFLASH }; (this->*COMMAND_LIST[commandIndex])(pScript); @@ -217,7 +217,12 @@ void Scripts::cmdCheckLoc(const byte *&pScript) { pScript += 2; } -void Scripts::CMDSETANIM(const byte *&pScript) { } +void Scripts::cmdSetAnim(const byte *&pScript) { + int animId = *pScript++; + Animation *anim = _vm->_animation->setAnimation(animId); + _vm->_animation->setAnimTimer(anim); +} + void Scripts::CMDDISPINV(const byte *&pScript) { } void Scripts::CMDSETTIMER(const byte *&pScript) { } void Scripts::CMDCHECKTIMER(const byte *&pScript) { } @@ -266,7 +271,14 @@ void Scripts::CMDCYCLEBACK(const byte *&pScript) { } void Scripts::CMDCHAPTER(const byte *&pScript) { } void Scripts::CMDSETHELP(const byte *&pScript) { } void Scripts::CMDCENTERPANEL(const byte *&pScript) { } -void Scripts::CMDMAINPANEL(const byte *&pScript) { } + +void Scripts::cmdMainPanel(const byte *&pScript) { + if (_vm->_screen->_vesaMode) { + _vm->_room->init4Quads(); + _vm->_screen->setPanel(0); + } +} + void Scripts::CMDRETFLASH(const byte *&pScript) { } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 8035450881..d78b74840d 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -67,7 +67,7 @@ protected: void CMDSND(const byte *&pScript); void CMDRETNEG(const byte *&pScript); void cmdCheckLoc(const byte *&pScript); - void CMDSETANIM(const byte *&pScript); + void cmdSetAnim(const byte *&pScript); void CMDDISPINV(const byte *&pScript); void CMDSETTIMER(const byte *&pScript); void CMDCHECKTIMER(const byte *&pScript); @@ -109,7 +109,7 @@ protected: void CMDCHAPTER(const byte *&pScript); void CMDSETHELP(const byte *&pScript); void CMDCENTERPANEL(const byte *&pScript); - void CMDMAINPANEL(const byte *&pScript); + void cmdMainPanel(const byte *&pScript); void CMDRETFLASH(const byte *&pScript); public: const byte *_script; -- cgit v1.2.3