diff options
author | Strangerke | 2017-01-17 00:02:31 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2017-01-25 22:42:23 +0100 |
commit | 1e7779edd3f63b35d54c6ae83c9b99acba728f32 (patch) | |
tree | 5cd8ed8d0ce90c6bbc3f50b59776d6c5e3fb8f5e | |
parent | e4555b86dbed1e4d8ec0b5477abcd3d814f50b4c (diff) | |
download | scummvm-rg350-1e7779edd3f63b35d54c6ae83c9b99acba728f32.tar.gz scummvm-rg350-1e7779edd3f63b35d54c6ae83c9b99acba728f32.tar.bz2 scummvm-rg350-1e7779edd3f63b35d54c6ae83c9b99acba728f32.zip |
CRYO: Rename cube code
-rw-r--r-- | engines/cryo/defs.h | 2 | ||||
-rw-r--r-- | engines/cryo/eden.cpp | 138 | ||||
-rw-r--r-- | engines/cryo/eden.h | 16 | ||||
-rw-r--r-- | engines/cryo/staticdata.cpp | 2 |
4 files changed, 79 insertions, 79 deletions
diff --git a/engines/cryo/defs.h b/engines/cryo/defs.h index 72e535cd92..1cbd54ca83 100644 --- a/engines/cryo/defs.h +++ b/engines/cryo/defs.h @@ -832,7 +832,7 @@ struct cube_t { int16 *_vertices; }; -extern float flt_2DF7C; +extern float _translationZ; extern float flt_2DF80; extern float flt_2DF84; diff --git a/engines/cryo/eden.cpp b/engines/cryo/eden.cpp index bb8d00a4d9..6f8fec1e92 100644 --- a/engines/cryo/eden.cpp +++ b/engines/cryo/eden.cpp @@ -143,8 +143,8 @@ EdenGame::EdenGame(CryoEngine *vm) : _vm(vm) { word_378CC = 0; //TODO: set by CLComputer_Init to 0 word_378CE = 0; - word_32448 = word_3244A = word_3244C = 0; - flt_32450 = flt_32454 = 0.0; //TODO: never changed, make consts? + _rotationAngleY = _rotationAngleX = _rotationAngleZ = 0; + _translationY = _translationX = 0.0; //TODO: never changed, make consts? _cursorOldTick = 0; _invIconsBase = 19; @@ -8568,47 +8568,47 @@ void EdenGame::actionNop() { // Original name: make_tabcos void EdenGame::initCosTable() { for (int i = 0; i < 361; i++) { - _cosTable[i * 2] = (int)(cos(3.1416 * i / 180.0) * 255.0); - _cosTable[i * 2 + 1] = (int)(sin(3.1416 * i / 180.0) * 255.0); + _cosSinTable[i * 2] = (int)(cos(3.1416 * i / 180.0) * 255.0); + _cosSinTable[i * 2 + 1] = (int)(sin(3.1416 * i / 180.0) * 255.0); } } -void EdenGame::make_matrice_fix() { - int16 r30 = word_3244C; - int16 r28 = word_3244A; - int16 r29 = word_32448; +void EdenGame::makeMatriceFix() { + int16 rotAngleTheta = _rotationAngleX; + int16 rotAnglePhi = _rotationAngleY; + int16 rotAnglePsi = _rotationAngleZ; - dword_32424 = (_cosTable[r29 * 2] * _cosTable[r28 * 2]) >> 8; - dword_32430 = (_cosTable[r29 * 2 + 1] * _cosTable[r28 * 2]) >> 8; - dword_3243C = -_cosTable[r28 * 2 + 1]; - dword_32428 = ((-_cosTable[r29 * 2 + 1] * _cosTable[r30 * 2]) >> 8) - + ((_cosTable[r30 * 2 + 1] * ((_cosTable[r29 * 2] * _cosTable[r28 * 2 + 1]) >> 8)) >> 8); - dword_32434 = ((_cosTable[r29 * 2] * _cosTable[r30 * 2]) >> 8) - + ((_cosTable[r30 * 2 + 1] * ((_cosTable[r29 * 2 + 1] * _cosTable[r28 * 2 + 1]) >> 8)) >> 8); - dword_32440 = (_cosTable[r28 * 2] * _cosTable[r30 * 2 + 1]) >> 8; - dword_3242C = ((_cosTable[r29 * 2 + 1] * _cosTable[r30 * 2 + 1]) >> 8) - + ((_cosTable[r30 * 2] * ((_cosTable[r29 * 2] * _cosTable[r28 * 2 + 1]) >> 8)) >> 8); - dword_32438 = ((-_cosTable[r29 * 2] * _cosTable[r30 * 2 + 1]) >> 8) - + ((_cosTable[r30 * 2] * ((_cosTable[r29 * 2 + 1] * _cosTable[r28 * 2 + 1]) >> 8)) >> 8); - dword_32444 = (_cosTable[r28 * 2] * _cosTable[r30 * 2]) >> 8; + _passMat31 = (_cosSinTable[rotAnglePhi * 2] * _cosSinTable[rotAngleTheta * 2]) >> 8; + _passMat32 = (_cosSinTable[rotAnglePhi * 2 + 1] * _cosSinTable[rotAngleTheta * 2]) >> 8; + _passMat33 = -_cosSinTable[rotAngleTheta * 2 + 1]; + _passMat21 = ((-_cosSinTable[rotAnglePhi * 2 + 1] * _cosSinTable[rotAnglePsi * 2]) >> 8) + + ((_cosSinTable[rotAnglePsi * 2 + 1] * ((_cosSinTable[rotAnglePhi * 2] * _cosSinTable[rotAngleTheta * 2 + 1]) >> 8)) >> 8); + _passMat22 = ((_cosSinTable[rotAnglePhi * 2] * _cosSinTable[rotAnglePsi * 2]) >> 8) + + ((_cosSinTable[rotAnglePsi * 2 + 1] * ((_cosSinTable[rotAnglePhi * 2 + 1] * _cosSinTable[rotAngleTheta * 2 + 1]) >> 8)) >> 8); + _passMat23 = (_cosSinTable[rotAngleTheta * 2] * _cosSinTable[rotAnglePsi * 2 + 1]) >> 8; + _passMat11 = ((_cosSinTable[rotAnglePhi * 2 + 1] * _cosSinTable[rotAnglePsi * 2 + 1]) >> 8) + + ((_cosSinTable[rotAnglePsi * 2] * ((_cosSinTable[rotAnglePhi * 2] * _cosSinTable[rotAngleTheta * 2 + 1]) >> 8)) >> 8); + _passMat12 = ((-_cosSinTable[rotAnglePhi * 2] * _cosSinTable[rotAnglePsi * 2 + 1]) >> 8) + + ((_cosSinTable[rotAnglePsi * 2] * ((_cosSinTable[rotAnglePhi * 2 + 1] * _cosSinTable[rotAngleTheta * 2 + 1]) >> 8)) >> 8); + _passMat13 = (_cosSinTable[rotAngleTheta * 2] * _cosSinTable[rotAnglePsi * 2]) >> 8; } void EdenGame::projectionFix(cube_t *cubep, int n) { for (int i = 0; i < n; i++) { - int r28 = cubep->_vertices[i * 4]; - int r27 = cubep->_vertices[i * 4 + 1]; - int r26 = cubep->_vertices[i * 4 + 2]; + int x = cubep->_vertices[i * 4]; + int y = cubep->_vertices[i * 4 + 1]; + int z = cubep->_vertices[i * 4 + 2]; - int r25 = dword_32424 * r28 + dword_32428 * r27 + dword_3242C * r26 + (int)(flt_32454 * 256.0f); - int r24 = dword_32430 * r28 + dword_32434 * r27 + dword_32438 * r26 + (int)(flt_32450 * 256.0f); - int r29 = dword_3243C * r28 + dword_32440 * r27 + dword_32444 * r26 + (int)(flt_2DF7C * 256.0f); + int transformX = _passMat31 * x + _passMat21 * y + _passMat11 * z + (int)(_translationX * 256.0f); + int transformY = _passMat32 * x + _passMat22 * y + _passMat12 * z + (int)(_translationY * 256.0f); + int transformZ = _passMat33 * x + _passMat23 * y + _passMat13 * z + (int)(_translationZ * 256.0f); - r29 >>= 8; - if (r29 == -256) - r29++; - 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; + transformZ >>= 8; + if (transformZ == -256) + transformZ++; + cubep->_projection[i * 4 ] = transformX / (transformZ + 256) + _cursorPosX + 14 + _scrollPos; + cubep->_projection[i * 4 + 1] = transformY / (transformZ + 256) + _cursorPosY + 14; + cubep->_projection[i * 4 + 2] = transformZ; } } @@ -8621,7 +8621,7 @@ void EdenGame::initCubeMac() { void EdenGame::engineMac() { Eden_dep_and_rot(); - make_matrice_fix(); + makeMatriceFix(); projectionFix(&_cube, _cubeFaces); displayObject(&_cube); } @@ -8831,72 +8831,72 @@ void EdenGame::Eden_dep_and_rot() { _cursorOldTick = _cursorNewTick; switch (_currCursor) { case 0: - word_3244C = (word_3244C + 2) % 360; - word_3244A = (word_3244A + 2) % 360; + _rotationAngleZ = (_rotationAngleZ + 2) % 360; + _rotationAngleX = (_rotationAngleX + 2) % 360; restoreZDEP(); break; case 1: - word_3244C = 0; - word_3244A -= 2; - if (word_3244A < 0) - word_3244A += 360; + _rotationAngleZ = 0; + _rotationAngleX -= 2; + if (_rotationAngleX < 0) + _rotationAngleX += 360; restoreZDEP(); break; case 2: - word_3244C = (word_3244C + 2) % 360; - word_3244A = 0; + _rotationAngleZ = (_rotationAngleZ + 2) % 360; + _rotationAngleX = 0; restoreZDEP(); break; case 3: - word_3244C -= 2; - if (word_3244C < 0) - word_3244C += 360; - word_3244A = 0; + _rotationAngleZ -= 2; + if (_rotationAngleZ < 0) + _rotationAngleZ += 360; + _rotationAngleX = 0; restoreZDEP(); break; case 4: - word_3244C = 0; - word_3244A = (word_3244A + 2) % 360; + _rotationAngleZ = 0; + _rotationAngleX = (_rotationAngleX + 2) % 360; restoreZDEP(); break; case 5: - word_3244C = 0; - word_3244A = 0; - flt_2DF7C += flt_2DF84; - if ((flt_2DF7C < -3600.0 + flt_2DF80) || flt_2DF7C > flt_2DF80) + _rotationAngleZ = 0; + _rotationAngleX = 0; + _translationZ += flt_2DF84; + if ((_translationZ < -3600.0 + flt_2DF80) || _translationZ > flt_2DF80) flt_2DF84 = -flt_2DF84; break; case 6: - word_3244C = 0; - word_3244A = 0; - flt_2DF7C = flt_2DF80; + _rotationAngleZ = 0; + _rotationAngleX = 0; + _translationZ = flt_2DF80; break; case 7: - word_3244C -= 2; - if (word_3244C < 0) - word_3244C += 360; - word_3244A = 0; + _rotationAngleZ -= 2; + if (_rotationAngleZ < 0) + _rotationAngleZ += 360; + _rotationAngleX = 0; restoreZDEP(); break; case 8: - word_3244C = 0; - word_3244A = 0; - flt_2DF7C = flt_2DF80; + _rotationAngleZ = 0; + _rotationAngleX = 0; + _translationZ = flt_2DF80; break; case 9: - word_3244C = 0; - word_3244A = 0; - flt_2DF7C = flt_2DF80; + _rotationAngleZ = 0; + _rotationAngleX = 0; + _translationZ = flt_2DF80; break; } } void EdenGame::restoreZDEP() { flt_2DF84 = 200.0; - if (flt_2DF7C < flt_2DF80) - flt_2DF7C += flt_2DF84; - if (flt_2DF7C > flt_2DF80) - flt_2DF7C -= flt_2DF84; + if (_translationZ < flt_2DF80) + _translationZ += flt_2DF84; + if (_translationZ > flt_2DF80) + _translationZ -= flt_2DF84; } // Original name: affiche_polygone_mapping diff --git a/engines/cryo/eden.h b/engines/cryo/eden.h index 9b33301285..f1a9df6517 100644 --- a/engines/cryo/eden.h +++ b/engines/cryo/eden.h @@ -488,7 +488,7 @@ private: uint16 fetchValue(); void actionNop(); void initCosTable(); - void make_matrice_fix(); + void makeMatriceFix(); void projectionFix(cube_t *cube, int n); void initCubeMac(); void engineMac(); @@ -717,13 +717,13 @@ private: int _roomIconsBase; //// cube.c - int16 _cosTable[361 * 2]; - int dword_32424, dword_32428, dword_3242C; - int dword_32430, dword_32434, dword_32438; - int dword_3243C, dword_32440, dword_32444; - int16 word_32448; // CHECKME: USeless? - int16 word_3244A, word_3244C; - float flt_32450, flt_32454; // CHECKME: Useless? + int16 _cosSinTable[361 * 2]; + int _passMat31, _passMat21, _passMat11; + int _passMat32, _passMat22, _passMat12; + int _passMat33, _passMat23, _passMat13; + int16 _rotationAngleY; // CHECKME: USeless? + int16 _rotationAngleX, _rotationAngleZ; + float _translationY, _translationX; // CHECKME: Useless? cube_t _cube; int16 _cursCurPCMap; int16 _lines[200 * 8]; diff --git a/engines/cryo/staticdata.cpp b/engines/cryo/staticdata.cpp index ea56fd2dfe..a9783412ac 100644 --- a/engines/cryo/staticdata.cpp +++ b/engines/cryo/staticdata.cpp @@ -557,7 +557,7 @@ int16 kActionCursors[299] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -float flt_2DF7C = -3400; +float _translationZ = -3400; float flt_2DF80 = -3400; float flt_2DF84 = 200; |