CRYO: Get rid of sound's locked and forcewait, remove some dead code, renaming

This commit is contained in:
Strangerke 2017-01-05 02:06:50 -08:00 committed by Eugene Sandulenko
parent ad0616688c
commit e20f65e5ea
7 changed files with 25 additions and 53 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;
};

View File

@ -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);

View File

@ -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);

View File

@ -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 {