mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-05 09:49:14 +00:00
MADS: Finished remainder of Scene::doFrame
This commit is contained in:
parent
f6888eef10
commit
1607a91047
@ -139,6 +139,7 @@ Animation *Animation::init(MADSEngine *vm, Scene *scene) {
|
||||
|
||||
Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) {
|
||||
_font = nullptr;
|
||||
_resetFlag = false;
|
||||
}
|
||||
|
||||
Animation::~Animation() {
|
||||
@ -147,6 +148,31 @@ Animation::~Animation() {
|
||||
delete _spriteSets[i];
|
||||
}
|
||||
|
||||
void Animation::free() {
|
||||
Scene &scene = _vm->_game->_scene;
|
||||
Player &player = _vm->_game->_player;
|
||||
|
||||
if (!scene._freeAnimationFlag) {
|
||||
scene._spriteSlots.fullRefresh(true);
|
||||
scene._sequences.scan();
|
||||
}
|
||||
|
||||
// Refresh the player
|
||||
if (player._visible) {
|
||||
player._forceRefresh = true;
|
||||
player.update();
|
||||
}
|
||||
|
||||
// Remove any kernel messages in use by the animation
|
||||
for (uint i = 0; i < _messages.size(); ++i) {
|
||||
int msgIndex = _messages[i]._kernelMsgIndex;
|
||||
scene._kernelMessages.remove(msgIndex);
|
||||
}
|
||||
|
||||
_resetFlag = false;
|
||||
delete this;
|
||||
}
|
||||
|
||||
void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
|
||||
const Common::String &resName, int flags, Common::Array<RGB4> *palAnimData,
|
||||
SceneInfo *sceneInfo) {
|
||||
@ -179,7 +205,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
|
||||
for (int i = 0; i < aaHeader._spriteSetsCount; ++i)
|
||||
_spriteListIndexes.push_back(-1);
|
||||
|
||||
_kernelMessages.clear();
|
||||
_messages.clear();
|
||||
if (aaHeader._messagesCount > 0) {
|
||||
// Chunk 2: Following is a list of any messages for the animation
|
||||
Common::SeekableReadStream *msgStream = madsPack.getItemStream(1);
|
||||
@ -187,7 +213,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
|
||||
for (int i = 0; i < aaHeader._messagesCount; ++i) {
|
||||
AnimMessage rec;
|
||||
rec.load(msgStream);
|
||||
_kernelMessages.push_back(rec);
|
||||
_messages.push_back(rec);
|
||||
}
|
||||
|
||||
delete msgStream;
|
||||
|
@ -119,17 +119,23 @@ public:
|
||||
static Animation *init(MADSEngine *vm, Scene *scene);
|
||||
public:
|
||||
Common::Array<int> _spriteListIndexes;
|
||||
Common::Array<AnimMessage> _kernelMessages;
|
||||
Common::Array<AnimMessage> _messages;
|
||||
Common::Array<AnimFrameEntry> _frameEntries;
|
||||
Common::Array<AnimMiscEntry> _miscEntries;
|
||||
Common::Array<SpriteAsset *> _spriteSets;
|
||||
Font *_font;
|
||||
bool _resetFlag;
|
||||
public:
|
||||
/*
|
||||
* Destructor
|
||||
*/
|
||||
~Animation();
|
||||
|
||||
/**
|
||||
* Releases scene resources used by the animation, and then deletes it
|
||||
*/
|
||||
void free();
|
||||
|
||||
/**
|
||||
* Loads animation data
|
||||
*/
|
||||
|
@ -35,7 +35,8 @@ namespace MADS {
|
||||
EventsManager::EventsManager(MADSEngine *vm) {
|
||||
_vm = vm;
|
||||
_cursorSprites = nullptr;
|
||||
_gameCounter = 0;
|
||||
_frameCounter = 0;
|
||||
_frameNumber = 0;
|
||||
_priorFrameTime = 0;
|
||||
_keyPressed = false;
|
||||
_mouseClicked = false;
|
||||
@ -140,7 +141,7 @@ void EventsManager::checkForNextFrameCounter() {
|
||||
// Check for next game frame
|
||||
uint32 milli = g_system->getMillis();
|
||||
if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) {
|
||||
++_gameCounter;
|
||||
++_frameCounter;
|
||||
_priorFrameTime = milli;
|
||||
|
||||
// Give time to the debugger
|
||||
@ -165,6 +166,12 @@ void EventsManager::delay(int cycles) {
|
||||
}
|
||||
}
|
||||
|
||||
void EventsManager::waitForNextFrame() {
|
||||
uint32 frameNum = getFrameCounter();
|
||||
while (!_vm->shouldQuit() && !_vm->_game->_abortTimers && frameNum == _frameNumber)
|
||||
delay(1);
|
||||
}
|
||||
|
||||
void EventsManager::initVars() {
|
||||
_mousePos = Common::Point(-1, -1);
|
||||
_vD4 = _vCC;
|
||||
|
@ -37,7 +37,8 @@ class MADSEngine;
|
||||
class EventsManager {
|
||||
private:
|
||||
MADSEngine *_vm;
|
||||
uint32 _gameCounter;
|
||||
uint32 _frameCounter;
|
||||
uint32 _frameNumber;
|
||||
uint32 _priorFrameTime;
|
||||
Common::Point _mousePos;
|
||||
Common::Point _currentPos;
|
||||
@ -131,10 +132,15 @@ public:
|
||||
*/
|
||||
void delay(int amount);
|
||||
|
||||
/**
|
||||
* Wait for the next frame
|
||||
*/
|
||||
void waitForNextFrame();
|
||||
|
||||
/**
|
||||
* Gets the current frame counter
|
||||
*/
|
||||
uint32 getFrameCounter() const { return _gameCounter; }
|
||||
uint32 getFrameCounter() const { return _frameCounter; }
|
||||
|
||||
void initVars();
|
||||
};
|
||||
|
@ -40,6 +40,7 @@ Player::Player(MADSEngine *vm): _vm(vm) {
|
||||
_ticksAmount = 0;
|
||||
_priorTimer = 0;
|
||||
_unk3 = 0;
|
||||
_forceRefresh = false;
|
||||
}
|
||||
|
||||
void Player::reset() {
|
||||
@ -80,6 +81,10 @@ void Player::updateFrame() {
|
||||
warning("TODO: Player::updateFrame");
|
||||
}
|
||||
|
||||
void Player::update() {
|
||||
warning("TODO: Player::update");
|
||||
}
|
||||
|
||||
void Player::resetActionList() {
|
||||
warning("TODO: Player::resetActionList");
|
||||
}
|
||||
@ -115,8 +120,4 @@ void Player::postUpdate() {
|
||||
warning("TODO: Player::postUpdate");
|
||||
}
|
||||
|
||||
void Player::update() {
|
||||
warning("TODO: Player::update");
|
||||
}
|
||||
|
||||
} // End of namespace MADS
|
||||
|
@ -43,8 +43,6 @@ private:
|
||||
void move();
|
||||
|
||||
void postUpdate();
|
||||
|
||||
void update();
|
||||
public:
|
||||
int _direction;
|
||||
int _newDirection;
|
||||
@ -66,6 +64,7 @@ public:
|
||||
int _ticksAmount;
|
||||
uint32 _priorTimer;
|
||||
int _unk3;
|
||||
bool _forceRefresh;
|
||||
public:
|
||||
Player(MADSEngine *vm);
|
||||
|
||||
@ -79,6 +78,8 @@ public:
|
||||
|
||||
void updateFrame();
|
||||
|
||||
void update();
|
||||
|
||||
void idle();
|
||||
|
||||
void setDest(const Common::Point &pt, int facing);
|
||||
|
@ -368,10 +368,12 @@ void Scene::doFrame() {
|
||||
}
|
||||
|
||||
// If the debugget flag is set, show the mouse position
|
||||
int mouseTextIndex = 0;
|
||||
if (_vm->_debugger->_showMousePos) {
|
||||
Common::Point pt = _vm->_events->mousePos();
|
||||
Common::String msg = Common::String::format("(%d,%d)", pt.x, pt.y);
|
||||
_kernelMessages.add(Common::Point(5, 5), 0x203, 0, 0, 1, msg);
|
||||
mouseTextIndex = _kernelMessages.add(Common::Point(5, 5),
|
||||
0x203, 0, 0, 1, msg);
|
||||
}
|
||||
|
||||
if (!_vm->_game->_abortTimers) {
|
||||
@ -399,11 +401,26 @@ void Scene::doFrame() {
|
||||
_kernelMessages.delay(newTime, priorTime);
|
||||
}
|
||||
|
||||
warning("TODO: sub_1DA5A");
|
||||
if (_vm->_debugger->_showMousePos)
|
||||
// Mouse position display isn't persistent, so remove it
|
||||
_kernelMessages.remove(mouseTextIndex);
|
||||
|
||||
// TODO: Rest of Scene::doFrame
|
||||
|
||||
warning("TODO: sub_1DA3E");
|
||||
}
|
||||
}
|
||||
|
||||
if (_vm->_game->_abortTimers2)
|
||||
_animFlag = true;
|
||||
_vm->_game->_abortTimers2 = 0;
|
||||
|
||||
if (_freeAnimationFlag) {
|
||||
_activeAnimation->free();
|
||||
_activeAnimation = nullptr;
|
||||
}
|
||||
|
||||
// TODO: Verify correctness of frame wait
|
||||
|
||||
}
|
||||
|
||||
void Scene::drawElements(bool transitionFlag, bool surfaceFlag) {
|
||||
|
@ -186,6 +186,13 @@ void SpriteSlots::deleteEntry(int index) {
|
||||
remove_at(index);
|
||||
}
|
||||
|
||||
void SpriteSlots::fullRefresh(bool clearAll) {
|
||||
if (clearAll)
|
||||
Common::Array<SpriteSlot>::clear();
|
||||
|
||||
push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1));
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
int SpriteSets::add(SpriteAsset *asset, int idx) {
|
||||
|
@ -158,6 +158,11 @@ public:
|
||||
*/
|
||||
void deleteEntry(int index);
|
||||
|
||||
/**
|
||||
* Adds a full screen refresh to the sprite slots
|
||||
*/
|
||||
void fullRefresh(bool clearAll = false);
|
||||
|
||||
SpriteAsset &getSprite(int idx) {
|
||||
error("TODO");
|
||||
}
|
||||
@ -168,7 +173,6 @@ public:
|
||||
warning("TODO: SpriteSlots::indexOf");
|
||||
return -1;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class SpriteSets: public Common::Array<SpriteAsset *> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user