diff options
author | Strangerke | 2016-11-27 22:27:46 -0800 |
---|---|---|
committer | Eugene Sandulenko | 2017-01-25 22:42:09 +0100 |
commit | 488e681e849bed8ad89dc997939e2798a87ada39 (patch) | |
tree | f4946f264f3861b78d55ce72385a404520c88bc5 /engines/cryo | |
parent | 2b4b3a3daf1db4f4c63745ba2129162c8d3e8ffa (diff) | |
download | scummvm-rg350-488e681e849bed8ad89dc997939e2798a87ada39.tar.gz scummvm-rg350-488e681e849bed8ad89dc997939e2798a87ada39.tar.bz2 scummvm-rg350-488e681e849bed8ad89dc997939e2798a87ada39.zip |
CRYO: Renaming in HnmPlayer, remove a couple of useless things
Diffstat (limited to 'engines/cryo')
-rw-r--r-- | engines/cryo/clhnm.cpp | 3 | ||||
-rw-r--r-- | engines/cryo/cryolib.h | 1 | ||||
-rw-r--r-- | engines/cryo/eden.cpp | 18 | ||||
-rw-r--r-- | engines/cryo/video.cpp | 179 | ||||
-rw-r--r-- | engines/cryo/video.h | 44 |
5 files changed, 121 insertions, 124 deletions
diff --git a/engines/cryo/clhnm.cpp b/engines/cryo/clhnm.cpp index e980341d5d..53e778c3d1 100644 --- a/engines/cryo/clhnm.cpp +++ b/engines/cryo/clhnm.cpp @@ -35,9 +35,6 @@ void CLHNM_Dispose(hnm_t *hnm) { free(hnm); } -void CLHNM_GiveTime(hnm_t *hnm) { -} - void CLHNM_CanLoop(hnm_t *hnm, bool canLoop) { hnm->_canLoop = canLoop; } diff --git a/engines/cryo/cryolib.h b/engines/cryo/cryolib.h index d4ac7cbbc6..cbb01259b2 100644 --- a/engines/cryo/cryolib.h +++ b/engines/cryo/cryolib.h @@ -255,7 +255,6 @@ void CRYOLib_ManagersDone(); void CLHNM_Done(); void CLHNM_Dispose(hnm_t *hnm); void CLHNM_CanLoop(hnm_t *hnm, bool canLoop); -void CLHNM_WantsSound(int16 sound); void CLHNM_SoundMono(int16 is_mono); diff --git a/engines/cryo/eden.cpp b/engines/cryo/eden.cpp index 0b79260bb5..fbc36baa98 100644 --- a/engines/cryo/eden.cpp +++ b/engines/cryo/eden.cpp @@ -4653,7 +4653,7 @@ void EdenGame::openbigfile() { h_bigfile.open("EDEN.DAT"); h_bigfile.read(bigfile_header, size); - _hnmContext = _vm->_video->resetInternals(128); + _hnmContext = _vm->_video->resetInternals(); _vm->_video->setFile(_hnmContext, &h_bigfile); } @@ -6208,7 +6208,7 @@ void EdenGame::mouse() { // Original name: showfilm void EdenGame::showMovie(char arg1) { _vm->_video->readHeader(_hnmContext); - if (_vm->_video->curVideoNum == 92) { + if (_vm->_video->_curVideoNum == 92) { // _hnmContext->_header._unusedFlag2 = 0; CHECKME: Useless? CLSoundChannel_SetVolumeLeft(_hnmSoundChannel, 0); CLSoundChannel_SetVolumeRight(_hnmSoundChannel, 0); @@ -6271,7 +6271,7 @@ void EdenGame::showMovie(char arg1) { void EdenGame::playHNM(int16 num) { perso_t *perso = nullptr; int16 oldDialogType = -1; - _vm->_video->curVideoNum = num; + _vm->_video->_curVideoNum = num; if (num != 2001 && num != 2012 && num != 98 && num != 171) { byte oldMusicType = p_global->newMusicType; p_global->newMusicType = MusicType::mtEvent; @@ -6312,15 +6312,15 @@ void EdenGame::playHNM(int16 num) { } if (videoCanceled) p_global->ff_F1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; - if (_vm->_video->curVideoNum == 167) + if (_vm->_video->_curVideoNum == 167) p_global->ff_F1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; - if (_vm->_video->curVideoNum == 104) + if (_vm->_video->_curVideoNum == 104) p_global->ff_F1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; - if (_vm->_video->curVideoNum == 102) + if (_vm->_video->_curVideoNum == 102) p_global->ff_F1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; - if (_vm->_video->curVideoNum == 77) + if (_vm->_video->_curVideoNum == 77) p_global->ff_F1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; - if (_vm->_video->curVideoNum == 149) + if (_vm->_video->_curVideoNum == 149) p_global->ff_F1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; } @@ -6328,7 +6328,7 @@ void EdenGame::playHNM(int16 num) { void EdenGame::displayHNMSubtitles() { int16 *frames; perso_t *perso; - switch (_vm->_video->curVideoNum) { + switch (_vm->_video->_curVideoNum) { case 170: frames = kFramesVid170; perso = &kPersons[PER_UNKN_156]; diff --git a/engines/cryo/video.cpp b/engines/cryo/video.cpp index 1e769adae3..3d4322ef90 100644 --- a/engines/cryo/video.cpp +++ b/engines/cryo/video.cpp @@ -25,31 +25,32 @@ namespace Cryo { HnmPlayer::HnmPlayer(CryoEngine *vm) : _vm(vm) { - curVideoNum = 0; - sound_started = false; - pending_sounds = 0; - time_drift = 0.0; - next_frame_time = 0.0; - expected_frame_time = 0.0; - hnm_rate = 0.0; - use_sound_sync = false; - use_sound = false; - soundChannel = nullptr; - soundGroup = nullptr; - soundChannel_adpcm = nullptr; - soundGroup_adpcm = nullptr; - pred_r = pred_l = 0; - use_adpcm = false; - custom_chunk_handler = nullptr; - preserve_color0 = false; - safe_palette = false; + _curVideoNum = 0; + _soundStarted = false; + _pendingSounds = 0; + _timeDrift = 0.0; + _nextFrameTime = 0.0; + _expectedFrameTime = 0.0; + _rate = 0.0; + _useSoundSync = false; + _useSound = false; + _soundChannel = nullptr; + _soundGroup = nullptr; + _soundChannelAdpcm = nullptr; + _soundGroupAdpcm = nullptr; + _prevRight = _prevLeft = 0; + _useAdpcm = false; + _customChunkHandler = nullptr; + _preserveColor0 = false; + _safePalette = false; for (int i = 0; i < 256; i++) - decomp_table[i] = 0; + decompTable[i] = 0; } // Original name: CLHNM_New -hnm_t *HnmPlayer::resetInternals(int preload_size) { +hnm_t *HnmPlayer::resetInternals() { + hnm_t *hnm = (hnm_t *)malloc(sizeof(*hnm)); hnm->_frameNum = 0; @@ -78,13 +79,13 @@ void HnmPlayer::setFile(hnm_t *hnm, file_t *file) { // Original name: CLHNM_SetupTimer void HnmPlayer::setupTimer(float rate) { - hnm_rate = 100.0 / rate; + _rate = 100.0 / rate; } // Original name: CLHNM_ResetInternalTimer void HnmPlayer::resetInternalTimer() { - time_drift = 0.0; - next_frame_time = expected_frame_time = TimerTicks; + _timeDrift = 0.0; + _nextFrameTime = _expectedFrameTime = TimerTicks; } // Original name: CLHNM_Reset @@ -92,75 +93,75 @@ void HnmPlayer::reset(hnm_t *hnm) { hnm->_frameNum = 0; hnm->ff_4 = 0; hnm->_totalRead = 0; - sound_started = false; - pending_sounds = 0; + _soundStarted = false; + _pendingSounds = 0; resetInternalTimer(); } // Original name: CLHNM_Init void HnmPlayer::init() { - custom_chunk_handler = nullptr; - preserve_color0 = false; + _customChunkHandler = nullptr; + _preserveColor0 = false; } // Original name: CLHNM_SetForceZero2Black void HnmPlayer::setForceZero2Black(bool forceblack) { - preserve_color0 = forceblack; + _preserveColor0 = forceblack; } // Original name: CLHNM_WaitLoop void HnmPlayer::waitLoop(hnm_t *hnm) { - expected_frame_time += hnm_rate; - next_frame_time = expected_frame_time - time_drift; - if (use_sound_sync && TimerTicks > 1000.0 + next_frame_time) - use_sound = false; - while (TimerTicks < next_frame_time) ; // waste time - time_drift = TimerTicks - next_frame_time; + _expectedFrameTime += _rate; + _nextFrameTime = _expectedFrameTime - _timeDrift; + if (_useSoundSync && TimerTicks > 1000.0 + _nextFrameTime) + _useSound = false; + while (TimerTicks < _nextFrameTime) ; // waste time + _timeDrift = TimerTicks - _nextFrameTime; } // Original name: CLHNM_WantsSound void HnmPlayer::wantsSound(bool sound) { - use_sound = sound; + _useSound = sound; } // Original name: CLHNM_SetupSound void HnmPlayer::setupSound(int16 numSounds, int16 length, int16 sampleSize, float rate, int16 mode) { - soundChannel = CLSoundChannel_New(mode); - soundGroup = CLSoundGroup_New(numSounds, length, sampleSize, rate, mode); + _soundChannel = CLSoundChannel_New(mode); + _soundGroup = CLSoundGroup_New(numSounds, length, sampleSize, rate, mode); if (sampleSize == 16) - CLSoundGroup_Reverse16All(soundGroup); + CLSoundGroup_Reverse16All(_soundGroup); } // Original name: CLHNM_SetupSoundADPCM void HnmPlayer::setupSoundADPCM(int16 numSounds, int16 length, int16 sampleSize, float rate, int16 mode) { - soundChannel_adpcm = CLSoundChannel_New(mode); - soundGroup_adpcm = CLSoundGroup_New(numSounds, length, sampleSize, rate, mode); + _soundChannelAdpcm = CLSoundChannel_New(mode); + _soundGroupAdpcm = CLSoundGroup_New(numSounds, length, sampleSize, rate, mode); } // Original name: CLHNM_SoundInADPCM void HnmPlayer::soundInADPCM(bool isAdpcm) { - use_adpcm = isAdpcm; + _useAdpcm = isAdpcm; } // Original name: CLHNM_CloseSound void HnmPlayer::closeSound() { - if (soundChannel) { - CLSoundChannel_Stop(soundChannel); - CLSoundChannel_Free(soundChannel); - soundChannel = nullptr; + if (_soundChannel) { + CLSoundChannel_Stop(_soundChannel); + CLSoundChannel_Free(_soundChannel); + _soundChannel = nullptr; } - if (soundGroup) { - CLSoundGroup_Free(soundGroup); - soundGroup = nullptr; + if (_soundGroup) { + CLSoundGroup_Free(_soundGroup); + _soundGroup = nullptr; } - if (soundChannel_adpcm) { - CLSoundChannel_Stop(soundChannel_adpcm); - CLSoundChannel_Free(soundChannel_adpcm); - soundChannel = nullptr; + if (_soundChannelAdpcm) { + CLSoundChannel_Stop(_soundChannelAdpcm); + CLSoundChannel_Free(_soundChannelAdpcm); + _soundChannel = nullptr; } - if (soundGroup_adpcm) { - CLSoundGroup_Free(soundGroup_adpcm); - soundGroup = nullptr; + if (_soundGroupAdpcm) { + CLSoundGroup_Free(_soundGroupAdpcm); + _soundGroup = nullptr; } } @@ -168,23 +169,23 @@ void HnmPlayer::closeSound() { void HnmPlayer::loadDecompTable(int16 *buffer) { for (int16 i = 0; i < 256; i++) { int16 e = *buffer++; - decomp_table[i] = LE16(e); + decompTable[i] = LE16(e); } } // Original name: CLHNM_DecompADPCM void HnmPlayer::decompADPCM(byte *buffer, int16 *output, int size) { - int16 l = pred_l; - int16 r = pred_r; + int16 l = _prevLeft; + int16 r = _prevRight; size &= ~1; while (size--) { - *output++ = l += decomp_table[*buffer++]; - *output++ = r += decomp_table[*buffer++]; + *output++ = l += decompTable[*buffer++]; + *output++ = r += decompTable[*buffer++]; if (l > 512 || r > 512) error("decompADPCM - Unexpected values"); } - pred_l = l; - pred_r = r; + _prevLeft = l; + _prevRight = r; } // Original name: CLHNM_ReadHeader @@ -466,7 +467,7 @@ void HnmPlayer::decompUBA(byte *output, byte *curr_buffer, byte *prev_buffer, by bool HnmPlayer::nextElement(hnm_t *hnm) { if (hnm->_frameNum == 0) { resetInternalTimer(); - pred_l = pred_r = 0; + _prevLeft = _prevRight = 0; } if (hnm->_frameNum == hnm->_header._numbFrame) return false; @@ -509,16 +510,16 @@ bool HnmPlayer::nextElement(hnm_t *hnm) { // else memcpy(hnm->finalBuffer, hnm->_newFrameBuffer, hnm->_header._height); //TODO: wrong size? } - if (use_adpcm) { - if (!sound_started) { - for (int16 i = 0; i < pending_sounds; i++) - CLSoundGroup_PlayNextSample(soundGroup_adpcm, soundChannel); - sound_started = true; + if (_useAdpcm) { + if (!_soundStarted) { + for (int16 i = 0; i < _pendingSounds; i++) + CLSoundGroup_PlayNextSample(_soundGroupAdpcm, _soundChannel); + _soundStarted = true; } - } else if (!sound_started) { - for (int16 i = 0; i < pending_sounds; i++) - CLSoundGroup_PlayNextSample(soundGroup, soundChannel); - sound_started = true; + } else if (!_soundStarted) { + for (int16 i = 0; i < _pendingSounds; i++) + CLSoundGroup_PlayNextSample(_soundGroup, _soundChannel); + _soundStarted = true; } return true; @@ -538,29 +539,29 @@ bool HnmPlayer::nextElement(hnm_t *hnm) { case BE16('sd'): case BE16('SD'): - if (use_sound) { + if (_useSound) { if (!h6) { int sound_size = sz - 8; - if (!use_adpcm) { - CLSoundGroup_SetDatas(soundGroup, hnm->_dataPtr, sound_size - 2, false); - if (sound_started) - CLSoundGroup_PlayNextSample(soundGroup, soundChannel); + if (!_useAdpcm) { + CLSoundGroup_SetDatas(_soundGroup, hnm->_dataPtr, sound_size - 2, false); + if (_soundStarted) + CLSoundGroup_PlayNextSample(_soundGroup, _soundChannel); else - pending_sounds++; + _pendingSounds++; } else { - int16 *sound_buffer = (int16 *)CLSoundGroup_GetNextBuffer(soundGroup_adpcm); - if (!pending_sounds) { + int16 *sound_buffer = (int16 *)CLSoundGroup_GetNextBuffer(_soundGroupAdpcm); + if (!_pendingSounds) { const int kDecompTableSize = 256 * sizeof(int16); loadDecompTable((int16 *)hnm->_dataPtr); decompADPCM(hnm->_dataPtr + kDecompTableSize, sound_buffer, sound_size - kDecompTableSize); - CLSoundGroup_AssignDatas(soundGroup_adpcm, sound_buffer, (sound_size - kDecompTableSize) * 2, false); + CLSoundGroup_AssignDatas(_soundGroupAdpcm, sound_buffer, (sound_size - kDecompTableSize) * 2, false); } else { decompADPCM(hnm->_dataPtr, sound_buffer, sound_size); - CLSoundGroup_AssignDatas(soundGroup_adpcm, sound_buffer, sound_size * 2, false); + CLSoundGroup_AssignDatas(_soundGroupAdpcm, sound_buffer, sound_size * 2, false); } - pending_sounds++; - if (sound_started) - CLSoundGroup_PlayNextSample(soundGroup_adpcm, soundChannel); + _pendingSounds++; + if (_soundStarted) + CLSoundGroup_PlayNextSample(_soundGroupAdpcm, _soundChannel); } } else error("nextElement - unexpected flag"); @@ -568,8 +569,8 @@ bool HnmPlayer::nextElement(hnm_t *hnm) { hnm->_dataPtr += sz - 8; break; default: - if (custom_chunk_handler) - custom_chunk_handler(hnm->_dataPtr, sz - 8, id, h6, h7); + if (_customChunkHandler) + _customChunkHandler(hnm->_dataPtr, sz - 8, id, h6, h7); hnm->_dataPtr += sz - 8; } } @@ -578,7 +579,7 @@ bool HnmPlayer::nextElement(hnm_t *hnm) { // Original name: CLHNM_GetSoundChannel soundchannel_t *HnmPlayer::getSoundChannel() { - return soundChannel; + return _soundChannel; } // Original name: CLHNM_FlushPreloadBuffer @@ -606,7 +607,7 @@ void HnmPlayer::changePalette(hnm_t *hnm) { if (maxcolor < fst + cnt) maxcolor = fst + cnt; color_t *color = hnm->_palette + fst; - if (safe_palette) { + if (_safePalette) { while (cnt--) { byte r = *pal++; byte g = *pal++; diff --git a/engines/cryo/video.h b/engines/cryo/video.h index 61021c5208..e86d5066b8 100644 --- a/engines/cryo/video.h +++ b/engines/cryo/video.h @@ -37,7 +37,7 @@ private: void loadDecompTable(int16 *buffer); void soundInADPCM(bool is_adpcm); // Unused bool loadFrame(hnm_t *hnm); - void tryRead(hnm_t *hnm, int size); // TODO: remove this function + void tryRead(hnm_t *hnm, int size); void changePalette(hnm_t *hnm); void selectBuffers(hnm_t *hnm); void decompLempelZiv(byte *buffer, byte *output); @@ -45,30 +45,30 @@ private: void desentrelace(hnm_t *hnm); void decompUBA(byte *output, byte *curr_buffer, byte *prev_buffer, byte *input, int width, char flags); - bool sound_started; - int16 pending_sounds; - float time_drift; - float next_frame_time; - float expected_frame_time; - float hnm_rate; - bool use_sound_sync; - bool use_sound; - int16 pred_r; - int16 pred_l; - bool use_adpcm; - bool preserve_color0; - int16 decomp_table[256]; - bool safe_palette; + bool _soundStarted; + int16 _pendingSounds; + float _timeDrift; + float _nextFrameTime; + float _expectedFrameTime; + float _rate; + bool _useSoundSync; + bool _useSound; + int16 _prevRight; + int16 _prevLeft; + bool _useAdpcm; + bool _preserveColor0; + int16 decompTable[256]; + bool _safePalette; - void (*custom_chunk_handler)(byte *buffer, int size, int16 id, char h6, char h7); + void (*_customChunkHandler)(byte *buffer, int size, int16 id, char h6, char h7); - soundchannel_t *soundChannel; - soundgroup_t *soundGroup; - soundchannel_t *soundChannel_adpcm; - soundgroup_t *soundGroup_adpcm; + soundchannel_t *_soundChannel; + soundgroup_t *_soundGroup; + soundchannel_t *_soundChannelAdpcm; + soundgroup_t *_soundGroupAdpcm; public: - uint16 curVideoNum; + uint16 _curVideoNum; HnmPlayer(CryoEngine *vm); @@ -88,7 +88,7 @@ public: void deallocMemory(hnm_t *hnm); void setFinalBuffer(hnm_t *hnm, byte *buffer); int getFrameNum(hnm_t *hnm); - hnm_t *resetInternals(int preload_size); // TODO: Remove useless parameter + hnm_t *resetInternals(); void setFile(hnm_t *hnm, file_t *file); soundchannel_t *getSoundChannel(); |