From 013bbbbad43d1a0b9c230bc84aaba620dc20e374 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 4 Feb 2013 08:06:50 +0100 Subject: HOPKINS: Start refactoring playSequence2. Remove 4 labels and the associated GOTOs --- engines/hopkins/anim.cpp | 114 ++++++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 65 deletions(-) (limited to 'engines/hopkins/anim.cpp') diff --git a/engines/hopkins/anim.cpp b/engines/hopkins/anim.cpp index 73f3a00b50..7b8d296624 100644 --- a/engines/hopkins/anim.cpp +++ b/engines/hopkins/anim.cpp @@ -769,11 +769,10 @@ void AnimationManager::playSequence(const Common::String &file, uint32 rate1, ui * Play Sequence type 2 */ void AnimationManager::playSequence2(const Common::String &file, uint32 rate1, uint32 rate2, uint32 rate3) { - bool v4; byte *screenCopy = NULL; byte *screenP; byte *v11 = NULL; - int v13; + int frameNumber; size_t nbytes; Common::File f; @@ -825,78 +824,63 @@ void AnimationManager::playSequence2(const Common::String &file, uint32 rate1, u _vm->_eventsManager._rateCounter = 0; _vm->_eventsManager._escKeyFl = false; _vm->_soundManager.loadAnimSound(); - if (_vm->_globals.iRegul != 1) - break; - while (!_vm->shouldQuit()) { - if (_vm->_eventsManager._escKeyFl) - goto LABEL_54; - _vm->_eventsManager.refreshEvents(); - _vm->_soundManager.checkSoundEnd(); - if (_vm->_eventsManager._rateCounter >= rate1) - goto LABEL_23; + if (_vm->_globals.iRegul == 1) { + do { + _vm->_eventsManager.refreshEvents(); + _vm->_soundManager.checkSoundEnd(); + } while (!_vm->shouldQuit() && !_vm->_eventsManager._escKeyFl && _vm->_eventsManager._rateCounter < rate1); } - if (_vm->_graphicsManager._skipVideoLockFl) - goto LABEL_54; - if (multiScreenFl) - screenCopy = _vm->_globals.freeMemory(screenCopy); - _vm->_globals.freeMemory(v11); - f.close(); - } -LABEL_23: - _vm->_eventsManager._rateCounter = 0; - v4 = false; - v13 = 0; - while (!_vm->shouldQuit()) { - _vm->_soundManager.playAnimSound(v13++); - - memset(v11, 0, 19); - if (f.read(v11, 16) != 16) - v4 = true; - - if (strncmp((const char *)v11, "IMAGE=", 6)) - v4 = true; - if (v4) - goto LABEL_44; - f.read(screenP, READ_LE_UINT32(v11 + 8)); - if (_vm->_globals.iRegul == 1) - break; -LABEL_33: + break; + } + + if (!_vm->_eventsManager._escKeyFl) { _vm->_eventsManager._rateCounter = 0; - _vm->_graphicsManager.lockScreen(); - if (multiScreenFl) { - if (*screenP != kByteStop) { - _vm->_graphicsManager.Copy_WinScan_Vbe(screenP, screenCopy); - _vm->_graphicsManager.m_scroll16A(screenCopy, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - } - } else if (*screenP != kByteStop) { - _vm->_graphicsManager.Copy_Video_Vbe16a(screenP); - } - _vm->_graphicsManager.unlockScreen(); - _vm->_graphicsManager.DD_VBL(); - _vm->_soundManager.checkSoundEnd(); -LABEL_44: - if (v4) { + frameNumber = 0; + while (!_vm->shouldQuit()) { + _vm->_soundManager.playAnimSound(frameNumber++); + + memset(v11, 0, 19); + if (f.read(v11, 16) != 16) + break; + + if (strncmp((const char *)v11, "IMAGE=", 6)) + break; + + f.read(screenP, READ_LE_UINT32(v11 + 8)); if (_vm->_globals.iRegul == 1) { - while (!_vm->_eventsManager._escKeyFl) { + do { _vm->_eventsManager.refreshEvents(); - _vm->_soundManager.checkSoundEnd(); - if (_vm->_eventsManager._rateCounter >= rate3) { - _vm->_eventsManager._rateCounter = 0; - break; - } + } while (!_vm->shouldQuit() && !_vm->_eventsManager._escKeyFl && _vm->_eventsManager._rateCounter < rate2); + } + + _vm->_eventsManager._rateCounter = 0; + _vm->_graphicsManager.lockScreen(); + if (multiScreenFl) { + if (*screenP != kByteStop) { + _vm->_graphicsManager.Copy_WinScan_Vbe(screenP, screenCopy); + _vm->_graphicsManager.m_scroll16A(screenCopy, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } - } else { - _vm->_eventsManager._rateCounter = 0; + } else if (*screenP != kByteStop) { + _vm->_graphicsManager.Copy_Video_Vbe16a(screenP); } - goto LABEL_54; + _vm->_graphicsManager.unlockScreen(); + _vm->_graphicsManager.DD_VBL(); + _vm->_soundManager.checkSoundEnd(); } } - while (!_vm->_eventsManager._escKeyFl) { - _vm->_eventsManager.refreshEvents(); - if (_vm->_eventsManager._rateCounter >= rate2) - goto LABEL_33; + + if (_vm->_globals.iRegul == 1) { + while (!_vm->_eventsManager._escKeyFl) { + _vm->_eventsManager.refreshEvents(); + _vm->_soundManager.checkSoundEnd(); + if (_vm->_eventsManager._rateCounter < rate3) { + break; + } + } } -LABEL_54: + + _vm->_eventsManager._rateCounter = 0; + if (_vm->_graphicsManager.FADE_LINUX == 2 && !multiScreenFl) { byte *ptra = _vm->_globals.allocMemory(307200); -- cgit v1.2.3