From e20f65e5ea3eac8420fc5b54e5ad64d538b98148 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 5 Jan 2017 02:06:50 -0800 Subject: CRYO: Get rid of sound's locked and forcewait, remove some dead code, renaming --- engines/cryo/cryolib.cpp | 18 ------------------ engines/cryo/cryolib.h | 3 --- engines/cryo/eden.cpp | 18 ++++++++---------- engines/cryo/eden.h | 4 ++-- engines/cryo/sound.cpp | 13 ------------- engines/cryo/sound.h | 1 - engines/cryo/video.cpp | 21 +++++++++++++++------ 7 files changed, 25 insertions(+), 53 deletions(-) diff --git a/engines/cryo/cryolib.cpp b/engines/cryo/cryolib.cpp index 89404d0548..6b0ff64518 100644 --- a/engines/cryo/cryolib.cpp +++ b/engines/cryo/cryolib.cpp @@ -32,27 +32,13 @@ namespace Cryo { ///// Mac APIs -typedef int16 OSErr; void SysBeep(int x) { } -OSErr SetFPos(int16 handle, int16 mode, int32 pos) { - return 0; -} - -OSErr FSRead(int16 handle, int32 *size, void *buffer) { - return 0; -} - void FlushEvents(int16 arg1, int16 arg2) { } -// from mw lib??? -int32 TickCount() { - return g_system->getMillis(); -} - ///// CLView View::View(CryoEngine *vm, int w, int h) : _vm(vm) { @@ -349,7 +335,6 @@ Sound::Sound(int16 length, float rate, int16 sampleSize, int16 mode) { _length = 0; _mode = 0; - _locked = 0; _loopStart = 0; _loopTimes = 0; _reversed = false; @@ -367,8 +352,6 @@ Sound::Sound(int16 length, float rate, int16 sampleSize, int16 mode) { } Sound::~Sound() { - while (_locked) - ; } void CLSoundRaw_AssignBuffer(Sound *sound, void *buffer, int bufferOffs, int length) { @@ -384,7 +367,6 @@ void CLSoundRaw_AssignBuffer(Sound *sound, void *buffer, int bufferOffs, int len void Sound::prepareSample(int16 mode) { _mode = mode; - _locked = 0; _loopTimes = 0; _reversed = false; _unused32 = 0; diff --git a/engines/cryo/cryolib.h b/engines/cryo/cryolib.h index 849a78e284..f28749d448 100644 --- a/engines/cryo/cryolib.h +++ b/engines/cryo/cryolib.h @@ -150,8 +150,6 @@ public: int _length; bool _reversed; - - volatile int16 _locked; }; #define kCryoMaxChSounds 10 @@ -177,7 +175,6 @@ public: }; void SysBeep(int x); -int32 TickCount(); void FlushEvents(int16 arg1, int16 arg2); void CLBlitter_CopyViewRect(View *view1, View *view2, Common::Rect *rect1, Common::Rect *rect2); diff --git a/engines/cryo/eden.cpp b/engines/cryo/eden.cpp index c76029d824..18f930a29f 100644 --- a/engines/cryo/eden.cpp +++ b/engines/cryo/eden.cpp @@ -4587,11 +4587,11 @@ void EdenGame::setDestRect(int16 sx, int16 sy, int16 ex, int16 ey) { } void EdenGame::wait(int howlong) { - int t = TickCount(); + int t = g_system->getMillis(); #ifdef EDEN_DEBUG howlong *= 10; #endif - for (int t2 = t; t2 - t < howlong; t2 = TickCount()) + for (int t2 = t; t2 - t < howlong; t2 = g_system->getMillis()) g_system->delayMillis(10); // waste time } @@ -8394,7 +8394,7 @@ char EdenGame::testCondition(int16 index) { _codePtr = (byte *)getElem(_gameConditions, (index - 1)); uint16 value; do { - value = cher_valeur(); + value = fetchValue(); for (;;) { byte op = *_codePtr++; if (op == 0xFF) { @@ -8402,7 +8402,7 @@ char EdenGame::testCondition(int16 index) { break; } if ((op & 0x80) == 0) { - uint16 value2 = cher_valeur(); + uint16 value2 = fetchValue(); value = operation(op, value, value2); } else { assert(sp < stack + 32); @@ -8506,7 +8506,8 @@ uint16 EdenGame::operation(byte op, uint16 v1, uint16 v2) { return (this->*operations[(op & 0x1F) >> 1])(v1, v2); } -uint16 EdenGame::cher_valeur() { +// Original name: cher_valeur +uint16 EdenGame::fetchValue() { uint16 val; byte typ = *_codePtr++; if (typ < 0x80) { @@ -8573,9 +8574,6 @@ void EdenGame::projectionFix(cube_t *cubep, int n) { cubep->_projection[i * 4 ] = r25 / (r29 + 256) + _cursorPosX + 14 + _scrollPos; cubep->_projection[i * 4 + 1] = r24 / (r29 + 256) + _cursorPosY + 14; cubep->_projection[i * 4 + 2] = r29; - -// assert(cube->projection[i * 4] < 640); -// assert(cube->projection[i * 4 + 1] < 200); } } @@ -8791,7 +8789,7 @@ void EdenGame::Eden_dep_and_rot() { if (_normalCursor && (_globals->_drawFlags & DrawFlags::drDrawFlag20)) curs = 10; selectMap(curs); - _cursorNewTick = TickCount(); + _cursorNewTick = g_system->getMillis(); if (_cursorNewTick - _cursorOldTick < 1) return; @@ -9325,7 +9323,7 @@ void EdenGame::enginePC() { if (_normalCursor && (_globals->_drawFlags & DrawFlags::drDrawFlag20)) curs = 9; selectPCMap(curs); - _cursorNewTick = TickCount(); + _cursorNewTick = g_system->getMillis(); if (_cursorNewTick - _cursorOldTick < 1) return; _cursorOldTick = _cursorNewTick; diff --git a/engines/cryo/eden.h b/engines/cryo/eden.h index 3e5c506725..bedd89caa3 100644 --- a/engines/cryo/eden.h +++ b/engines/cryo/eden.h @@ -484,7 +484,7 @@ private: uint16 operIsGreaterOrEqual(uint16 v1, uint16 v2); uint16 operFalse(uint16 v1, uint16 v2); uint16 operation(byte op, uint16 v1, uint16 v2); - uint16 cher_valeur(); + uint16 fetchValue(); void actionNop(); void initCosTable(); void make_matrice_fix(); @@ -728,7 +728,7 @@ private: int16 _lines[200 * 8]; byte _cubeTexture[0x4000]; int _cubeFaces; - int32 _cursorOldTick, _cursorNewTick; + uint32 _cursorOldTick, _cursorNewTick; byte *_codePtr; }; diff --git a/engines/cryo/sound.cpp b/engines/cryo/sound.cpp index 279e237454..bb2816870d 100644 --- a/engines/cryo/sound.cpp +++ b/engines/cryo/sound.cpp @@ -82,7 +82,6 @@ SoundGroup::SoundGroup(CryoEngine *vm, int16 numSounds, int16 length, int16 samp } _soundIndex = 0; _playIndex = 0; - _forceWait = true; } // Original name: CLSoundGroup_Free @@ -100,19 +99,12 @@ void SoundGroup::reverse16All() { // Original name: CLSoundGroup_GetNextBuffer void *SoundGroup::getNextBuffer() { Sound *sound = _sounds[_soundIndex]; - if (_forceWait) - while (sound->_locked) ; return sound->_sndHandle + sound->_headerLen; } // Original name: CLSoundGroup_AssignDatas bool SoundGroup::assignDatas(void *buffer, int length, bool isSigned) { Sound *sound = _sounds[_soundIndex]; - if (_forceWait) - while (sound->_locked) - ; - else if (sound->_locked) - return false; sound->_buffer = (char *)buffer; sound->setLength(length); @@ -135,11 +127,6 @@ bool SoundGroup::setDatas(void *data, int length, bool isSigned) { if (length >= sound->_maxLength) error("CLSoundGroup_SetDatas - Unexpected length"); - if (_forceWait) - while (sound->_locked) ; - else if (sound->_locked) - return false; - void *buffer = sound->_sndHandle + sound->_headerLen; sound->_buffer = (char *)buffer; memcpy(buffer, data, length); diff --git a/engines/cryo/sound.h b/engines/cryo/sound.h index 423e7ea73c..b993ff01ab 100644 --- a/engines/cryo/sound.h +++ b/engines/cryo/sound.h @@ -51,7 +51,6 @@ private: int16 _numSounds; int16 _soundIndex; int16 _playIndex; - bool _forceWait; public: SoundGroup(CryoEngine *vm, int16 numSounds, int16 length, int16 sampleSize, float rate, int16 mode); diff --git a/engines/cryo/video.cpp b/engines/cryo/video.cpp index c2b35829e9..7d783e96c1 100644 --- a/engines/cryo/video.cpp +++ b/engines/cryo/video.cpp @@ -490,14 +490,23 @@ bool HnmPlayer::nextElement() { _frameNum++; selectBuffers(); decompLempelZiv(_dataPtr + 4, _newFrameBuffer); +#if 0 switch (_header._width) { - // case 320: CLBlitter_RawCopy320ASM(_newFrameBuffer, _oldFrameBuffer, _header._height); break; - // case 480: CLBlitter_RawCopy480ASM(_newFrameBuffer, _oldFrameBuffer, _header._height); break; - // case 640: CLBlitter_RawCopy640ASM(_newFrameBuffer, _oldFrameBuffer, _header._height); break; - // default: memcpy(_oldFrameBuffer, _newFrameBuffer, _header._width * _header._height); - default: - memcpy(_oldFrameBuffer, _newFrameBuffer, _header._bufferSize); //TODO strange buffer size here + case 320: + CLBlitter_RawCopy320ASM(_newFrameBuffer, _oldFrameBuffer, _header._height); + break; + case 480: + CLBlitter_RawCopy480ASM(_newFrameBuffer, _oldFrameBuffer, _header._height); + break; + case 640: + CLBlitter_RawCopy640ASM(_newFrameBuffer, _oldFrameBuffer, _header._height); + break; + default: + memcpy(_oldFrameBuffer, _newFrameBuffer, _header._width * _header._height); } +#else + memcpy(_oldFrameBuffer, _newFrameBuffer, _header._bufferSize); //TODO strange buffer size here +#endif if (!(h6 & 1)) desentrelace(); else { -- cgit v1.2.3