aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2012-12-28 08:51:25 +0100
committerStrangerke2012-12-28 08:51:25 +0100
commit0adb2a31da83003038531b2a7b14448af7736fc5 (patch)
treef34e1154bf6e0ad7429b0945e7c974a1e8ca36c9
parentc9343637902ed94f0a511ff9fa0d1bffe346d5e3 (diff)
downloadscummvm-rg350-0adb2a31da83003038531b2a7b14448af7736fc5.tar.gz
scummvm-rg350-0adb2a31da83003038531b2a7b14448af7736fc5.tar.bz2
scummvm-rg350-0adb2a31da83003038531b2a7b14448af7736fc5.zip
HOPKINS: More renaming and refactoring
-rw-r--r--engines/hopkins/anim.cpp59
-rw-r--r--engines/hopkins/computer.cpp84
-rw-r--r--engines/hopkins/computer.h2
3 files changed, 67 insertions, 78 deletions
diff --git a/engines/hopkins/anim.cpp b/engines/hopkins/anim.cpp
index af3ee8aa05..e0e64b4b72 100644
--- a/engines/hopkins/anim.cpp
+++ b/engines/hopkins/anim.cpp
@@ -276,7 +276,7 @@ void AnimationManager::playAnim2(const Common::String &filename, uint32 a2, uint
ptr = _vm->_globals.allocMemory(307200);
memcpy(ptr, v12, 307200);
}
- if (_vm->_animationManager.NO_SEQ) {
+ if (NO_SEQ) {
if (v8 == 1)
memcpy(ptr, _vm->_graphicsManager._vesaBuffer, 307200);
_vm->_graphicsManager.setpal_vga256(_vm->_graphicsManager._palette);
@@ -708,11 +708,8 @@ int AnimationManager::loadSpriteBank(int idx, const Common::String &filename) {
* Search Animation
*/
void AnimationManager::searchAnim(const byte *data, int animIndex, int count) {
- int v3;
- const byte *v5;
int v6;
int v7;
- int v8;
byte *v9;
int v10;
int v11;
@@ -720,58 +717,49 @@ void AnimationManager::searchAnim(const byte *data, int animIndex, int count) {
int v13;
int v15;
int v16;
- int v17;
- int v19;
- int v20;
int v21;
int v22;
const byte *v23;
int v;
v21 = 0;
- v3 = 0;
- v19 = animIndex;
+ bool loopCond = false;
do {
- v20 = *(v21 + data);
- if (v20 == 'A' && *(data + v21 + 1) == 'N' && *(data + v21 + 2) == 'I' && *(data + v21 + 3) == 'M') {
- int entryIndex = *(data + v21 + 4);
+ if (data[v21] == 'A' && data[v21 + 1] == 'N' && data[v21 + 2] == 'I' && data[v21 + 3] == 'M') {
+ int entryIndex = data[v21 + 4];
if (animIndex == entryIndex) {
- v5 = v21 + data + 5;
v6 = v21 + 5;
v7 = 0;
- v8 = 0;
+ bool innerLoopCond = false;
do {
- if (*v5 == 'A' && *(v5 + 1) == 'N' && *(v5 + 2) == 'I' && *(v5 + 3) == 'M')
- v8 = 1;
- if (*v5 == 'F' && *(v5 + 1) == 'I' && *(v5 + 2) == 'N')
- v8 = 1;
+ if ((data[v6] == 'A' && data[v6 + 1] == 'N' && data[v6 + 2] == 'I' && data[v6 + 3] == 'M') ||
+ (data[v6] == 'F' && data[v6 + 1] == 'I' && data[v6 + 2] == 'N'))
+ innerLoopCond = true;
if (count < v6) {
_vm->_globals.Bqe_Anim[animIndex].field4 = 0;
- _vm->_globals.Bqe_Anim[v19]._data = g_PTRNUL;
+ _vm->_globals.Bqe_Anim[animIndex]._data = g_PTRNUL;
return;
}
++v6;
++v7;
- ++v5;
- } while (v8 != 1);
- _vm->_globals.Bqe_Anim[v19]._data = _vm->_globals.allocMemory(v7 + 50);
+ } while (!innerLoopCond);
+ _vm->_globals.Bqe_Anim[animIndex]._data = _vm->_globals.allocMemory(v7 + 50);
_vm->_globals.Bqe_Anim[animIndex].field4 = 1;
- memcpy(_vm->_globals.Bqe_Anim[v19]._data, v21 + data + 5, 20);
+ memcpy(_vm->_globals.Bqe_Anim[animIndex]._data, v21 + data + 5, 20);
- byte *dataP = _vm->_globals.Bqe_Anim[v19]._data;
+ byte *dataP = _vm->_globals.Bqe_Anim[animIndex]._data;
v9 = dataP + 20;
v23 = v21 + data + 25;
v10 = READ_LE_UINT16(v21 + data + 25);
v11 = READ_LE_UINT16(v21 + data + 27);
v22 = READ_LE_UINT16(v21 + data + 29);
v12 = READ_LE_UINT16(v21 + data + 31);
- v13 = *(v21 + data + 33);
- *(dataP + 29) = *(v21 + data + 34);
WRITE_LE_UINT16(dataP + 20, v10);
WRITE_LE_UINT16(dataP + 22, v11);
WRITE_LE_UINT16(dataP + 24, v22);
WRITE_LE_UINT16(dataP + 26, v12);
- *(dataP + 28) = v13;
+ *(dataP + 28) = *(v21 + data + 33);
+ *(dataP + 29) = *(v21 + data + 34);
for (int v14 = 1; v14 <= 4999; v14++) {
v9 += 10;
@@ -783,21 +771,20 @@ void AnimationManager::searchAnim(const byte *data, int animIndex, int count) {
v15 = READ_LE_UINT16(v23 + 2);
v22 = READ_LE_UINT16(v23 + 4);
v16 = READ_LE_UINT16(v23 + 6);
- v17 = *(v23 + 8);
- *(v9 + 9) = *(v23 + 9);
WRITE_LE_UINT16(v9, v);
WRITE_LE_UINT16(v9 + 2, v15);
WRITE_LE_UINT16(v9 + 4, v22);
WRITE_LE_UINT16(v9 + 6, v16);
- *(v9 + 8) = v17;
+ *(v9 + 8) = *(v23 + 8);
+ *(v9 + 9) = *(v23 + 9);
}
- v3 = 1;
+ loopCond = true;
}
}
- if (v20 == 'F' && *(data + v21 + 1) == 'I' && *(data + v21 + 2) == 'N')
- v3 = 1;
+ if (data[v21] == 'F' && data[v21 + 1] == 'I' && data[v21 + 2] == 'N')
+ loopCond = true;
++v21;
- } while (v21 <= count && v3 != 1);
+ } while (v21 <= count && !loopCond);
}
/**
@@ -846,7 +833,7 @@ void AnimationManager::playSequence(const Common::String &file, uint32 rate1, ui
ptr = _vm->_globals.allocMemory(307200);
memcpy(ptr, v9, 307200);
}
- if (_vm->_animationManager.NO_SEQ) {
+ if (NO_SEQ) {
if (v7)
memcpy(ptr, _vm->_graphicsManager._vesaBuffer, 307200);
if (!_vm->getIsDemo()) {
@@ -1009,7 +996,7 @@ void AnimationManager::playSequence2(const Common::String &file, uint32 rate1, u
ptr = _vm->_globals.allocMemory(307200);
memcpy((void *)ptr, v10, 307200);
}
- if (_vm->_animationManager.NO_SEQ) {
+ if (NO_SEQ) {
if (v7 == 1) {
assert(ptr != NULL);
memcpy((void *)ptr, _vm->_graphicsManager._vesaBuffer, 307200);
diff --git a/engines/hopkins/computer.cpp b/engines/hopkins/computer.cpp
index 0079d7f234..7513902fd3 100644
--- a/engines/hopkins/computer.cpp
+++ b/engines/hopkins/computer.cpp
@@ -49,7 +49,7 @@ ComputerManager::ComputerManager() {
_ballRightFl = false;
_ballUpFl = false;
_breakoutLevelNbr = 0;
- RAQX = 0;
+ _padPositionX = 0;
CASSEP1 = 0;
CASSEP2 = 0;
CASSDER = 0;
@@ -683,7 +683,7 @@ void ComputerManager::newLevel() {
_vm->_objectsManager.SPRITE(_breakoutSpr, Common::Point(150, 192), 0, 13, 0, 0, 0, 0);
_vm->_objectsManager.SPRITE(_breakoutSpr, Common::Point(164, 187), 1, 14, 0, 0, 0, 0);
_ballPosition = Common::Point(164, 187);
- RAQX = 150;
+ _padPositionX = 150;
_vm->_objectsManager.SPRITE_ON(0);
_vm->_objectsManager.SPRITE_ON(1);
_vm->_eventsManager.mouseOn();
@@ -772,7 +772,7 @@ void ComputerManager::playBreakout() {
while (!_vm->shouldQuit()) {
// Set up the racket and ball
_vm->_eventsManager.mouseOff();
- _ballPosition = Common::Point(RAQX + 14, 187);
+ _ballPosition = Common::Point(_padPositionX + 14, 187);
_vm->_objectsManager.setSpriteY(1, 187);
_vm->_objectsManager.setSpriteX(1, _ballPosition.x);
_vm->_graphicsManager.RESET_SEGMENT_VESA();
@@ -781,32 +781,32 @@ void ComputerManager::playBreakout() {
// Wait for mouse press to start playing
do {
- RAQX = _vm->_eventsManager.getMouseX();
+ _padPositionX = _vm->_eventsManager.getMouseX();
if (_vm->_eventsManager._mousePos.x <= 4)
- RAQX = 5;
- if (RAQX > 282)
- RAQX = 282;
- _vm->_objectsManager.setSpriteX(0, RAQX);
- _vm->_objectsManager.setSpriteX(1, RAQX + 14);
+ _padPositionX = 5;
+ if (_padPositionX > 282)
+ _padPositionX = 282;
+ _vm->_objectsManager.setSpriteX(0, _padPositionX);
+ _vm->_objectsManager.setSpriteX(1, _padPositionX + 14);
_vm->_objectsManager.setSpriteY(1, 187);
_vm->_eventsManager.VBL();
} while (!_vm->shouldQuit() && _vm->_eventsManager.getMouseButton() != 1);
_breakoutSpeed = 1;
- _ballPosition = Common::Point(RAQX + 14, 187);
- _ballRightFl = (RAQX > 135);
+ _ballPosition = Common::Point(_padPositionX + 14, 187);
+ _ballRightFl = (_padPositionX > 135);
_ballUpFl = false;
// Play loop
do {
_vm->_soundManager.checkSounds();
- RAQX = _vm->_eventsManager.getMouseX();
+ _padPositionX = _vm->_eventsManager.getMouseX();
if (_vm->_eventsManager._mousePos.x <= 4)
- RAQX = 5;
- if (RAQX > 282)
- RAQX = 282;
- _vm->_objectsManager.setSpriteX(0, RAQX);
+ _padPositionX = 5;
+ if (_padPositionX > 282)
+ _padPositionX = 282;
+ _vm->_objectsManager.setSpriteX(0, _padPositionX);
v1 = moveBall();
_vm->_eventsManager.VBL();
} while (!_vm->shouldQuit() && !v1);
@@ -1107,28 +1107,30 @@ void ComputerManager::displayHiscoreLine(byte *objectData, int x, int y, int a4)
* Handle ball moves
*/
int ComputerManager::moveBall() {
- int16 v1;
- int16 v4 = 0;
+ int16 retVal = 0;
//(signed int)(6.0 * (long double)_vm->getRandomNumber( rand() / 2147483648.0) + 1;
// TODO: Figure out random number
- int v0 = _vm->getRandomNumber(6);
- if (_breakoutSpeed == 1) {
+ int randVal = _vm->getRandomNumber(6);
+ switch (_breakoutSpeed) {
+ case 1:
CASSEP1 = 1;
CASSEP2 = 1;
- }
- if (_breakoutSpeed == 2) {
+ break;
+ case 2:
CASSEP1 = 1;
CASSEP2 = 2;
- }
- if (_breakoutSpeed == 3) {
+ break;
+ case 3:
CASSEP1 = 2;
CASSEP2 = 2;
- }
- if (_breakoutSpeed == 4) {
+ break;
+ case 4:
CASSEP1 = 3;
CASSEP2 = 2;
+ break;
}
- v1 = CASSEP1;
+
+ int v1 = CASSEP1;
if (CASSDER == CASSEP1)
v1 = CASSEP2;
@@ -1145,50 +1147,50 @@ int ComputerManager::moveBall() {
CASSDER = v1;
if (_ballPosition.x <= 6) {
_vm->_soundManager.PLAY_SAMPLE(2, 6);
- _ballPosition.x = v0 + 6;
+ _ballPosition.x = randVal + 6;
_ballRightFl = !_ballRightFl;
}
if (_ballPosition.x > 307) {
_vm->_soundManager.PLAY_SAMPLE(2, 6);
- _ballPosition.x = 307 - v0;
+ _ballPosition.x = 307 - randVal;
_ballRightFl = !_ballRightFl;
}
if (_ballPosition.y <= 6) {
_vm->_soundManager.PLAY_SAMPLE(2, 6);
- _ballPosition.y = v0 + 7;
+ _ballPosition.y = randVal + 7;
_ballUpFl = !_ballUpFl;
}
if ((uint16)(_ballPosition.y - 186) <= 8u) {
_vm->_soundManager.PLAY_SAMPLE(2, 6);
- if (_ballPosition.x > RAQX - 2) {
+ if (_ballPosition.x > _padPositionX - 2) {
int v2 = _ballPosition.x + 6;
- if (v2 < RAQX + 36) {
+ if (v2 < _padPositionX + 36) {
_ballUpFl = false;
- if (v2 <= RAQX + 15) {
+ if (v2 <= _padPositionX + 15) {
_ballRightFl = false;
- if (_ballPosition.x >= RAQX && v2 <= RAQX + 5)
+ if (_ballPosition.x >= _padPositionX && v2 <= _padPositionX + 5)
_ballPosition.x -= 4;
- if (_ballPosition.x >= RAQX + 5 && _ballPosition.x + 6 <= RAQX + 10)
+ if (_ballPosition.x >= _padPositionX + 5 && _ballPosition.x + 6 <= _padPositionX + 10)
_ballPosition.x -= 2;
}
- if (_ballPosition.x >= RAQX + 19 && _ballPosition.x + 6 <= RAQX + 36) {
+ if (_ballPosition.x >= _padPositionX + 19 && _ballPosition.x + 6 <= _padPositionX + 36) {
_ballRightFl = true;
- if (_ballPosition.x >= RAQX + 29)
+ if (_ballPosition.x >= _padPositionX + 29)
_ballPosition.x += 4;
- if (_ballPosition.x >= RAQX + 24 && _ballPosition.x + 6 <= RAQX + 29)
+ if (_ballPosition.x >= _padPositionX + 24 && _ballPosition.x + 6 <= _padPositionX + 29)
_ballPosition.x += 2;
}
}
}
}
if (_ballPosition.y > 194)
- v4 = 1;
+ retVal = 1;
checkBallCollisions();
_vm->_objectsManager.setSpriteX(1, _ballPosition.x);
_vm->_objectsManager.setSpriteY(1, _ballPosition.y);
if (!_breakoutBrickNbr)
- v4 = 2;
- return v4;
+ retVal = 2;
+ return retVal;
}
/**
diff --git a/engines/hopkins/computer.h b/engines/hopkins/computer.h
index dfa7529633..6bad921451 100644
--- a/engines/hopkins/computer.h
+++ b/engines/hopkins/computer.h
@@ -62,7 +62,7 @@ private:
bool _ballRightFl;
bool _ballUpFl;
int _breakoutLevelNbr;
- int RAQX;
+ int _padPositionX;
int _breakoutHiscore;
int CASSEP1;
int CASSEP2;