aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2009-01-16 23:18:18 +0000
committerMax Horn2009-01-16 23:18:18 +0000
commitd53a340a4d79c2b00a7ac4c0c346607e5d1d0eb8 (patch)
tree245d7d6df133b21a3693f4461674c16b7cd47562 /engines
parent0a169612eeb24a483bd3a1f6d108e435a24fe8fd (diff)
downloadscummvm-rg350-d53a340a4d79c2b00a7ac4c0c346607e5d1d0eb8.tar.gz
scummvm-rg350-d53a340a4d79c2b00a7ac4c0c346607e5d1d0eb8.tar.bz2
scummvm-rg350-d53a340a4d79c2b00a7ac4c0c346607e5d1d0eb8.zip
Some cleanup (one could replace some of those switch/case by jump tables...)
svn-id: r35876
Diffstat (limited to 'engines')
-rw-r--r--engines/tucker/graphics.h4
-rw-r--r--engines/tucker/locations.cpp72
-rw-r--r--engines/tucker/tucker.cpp100
-rw-r--r--engines/tucker/tucker.h13
4 files changed, 94 insertions, 95 deletions
diff --git a/engines/tucker/graphics.h b/engines/tucker/graphics.h
index bb103588f1..3362a6219e 100644
--- a/engines/tucker/graphics.h
+++ b/engines/tucker/graphics.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef TUCKER_GRAPHICS_H__
-#define TUCKER_GRAPHICS_H__
+#ifndef TUCKER_GRAPHICS_H
+#define TUCKER_GRAPHICS_H
#include "common/util.h"
diff --git a/engines/tucker/locations.cpp b/engines/tucker/locations.cpp
index da0a1644d2..eb2559e5c3 100644
--- a/engines/tucker/locations.cpp
+++ b/engines/tucker/locations.cpp
@@ -578,6 +578,12 @@ void TuckerEngine::execData3PreUpdate_locationNum6Helper3(int dstOffset, const u
addDirtyRect(dstOffset % 640, dstOffset / 640, 4, 51);
}
+void TuckerEngine::execData3PostUpdate_locationNum6() {
+ if (_flagsTable[26] < 4) {
+ execData3PreUpdate_locationNum6Helper1();
+ }
+}
+
void TuckerEngine::updateSprite_locationNum7_0(int i) {
int state;
++_spritesTable[i].counter;
@@ -973,6 +979,9 @@ void TuckerEngine::updateSprite_locationNum14(int i) {
}
void TuckerEngine::execData3PreUpdate_locationNum14() {
+ if (_yPosCurrent >= 126)
+ return;
+
if (!isSoundPlaying(0)) {
int num = -1;
const int i = getRandomNumber();
@@ -1016,7 +1025,7 @@ void TuckerEngine::execData3PreUpdate_locationNum14() {
}
void TuckerEngine::execData3PreUpdate_locationNum14Helper1(int i) {
- const int y = 1872; // XXX bug, 187/182 ?
+ const int y = 1872; // FIXME: bug, 187/182 ?
if (_updateLocation14ObjNum[i] == 0) {
if (getRandomNumber() <= 30000) {
return;
@@ -1026,7 +1035,7 @@ void TuckerEngine::execData3PreUpdate_locationNum14Helper1(int i) {
_updateLocation14Step[i] = -55 - getRandomNumber() / 512;
_updateLocation14ObjNum[i] = 231;
_updateLocation14Delay[i] = 16 + getRandomNumber() / 2048;
- // XXX bug, missing return ?
+ // FIXME: bug, missing return ?
}
_updateLocation14Step[i] = 4;
_updateLocationYPosTable2[i] += _updateLocation14Step[i];
@@ -1054,6 +1063,12 @@ void TuckerEngine::execData3PreUpdate_locationNum14Helper2(int i) {
}
}
+void TuckerEngine::execData3PostUpdate_locationNum14() {
+ if (_yPosCurrent < 127) {
+ execData3PreUpdate_locationNum14();
+ }
+}
+
void TuckerEngine::updateSprite_locationNum15_0(int i) {
_spritesTable[i].state = -1;
}
@@ -1809,19 +1824,17 @@ void TuckerEngine::execData3PreUpdate_locationNum30() {
}
void TuckerEngine::execData3PreUpdate_locationNum31() {
- execData3PreUpdate_locationNum31Helper(32000, 110);
- execData3PreUpdate_locationNum31Helper(31000, 111);
+ if (getRandomNumber() > 32000 && _flagsTable[110] == 0) {
+ _flagsTable[110] = 1;
+ }
+ if (getRandomNumber() > 31000 && _flagsTable[111] == 0) {
+ _flagsTable[111] = 1;
+ }
if (_xPosCurrent < 112 && _flagsTable[104] == 0) {
_flagsTable[104] = 1;
}
}
-void TuckerEngine::execData3PreUpdate_locationNum31Helper(int r, int flag) {
- if (getRandomNumber() > r && _flagsTable[flag] == 0) {
- _flagsTable[flag] = 1;
- }
-}
-
void TuckerEngine::execData3PreUpdate_locationNum32() {
if (_spritesTable[0].state == 12 && _spritesTable[0].animationFrame < 22) {
_flagsTable[113] = 1;
@@ -1969,7 +1982,9 @@ void TuckerEngine::execData3PreUpdate_locationNum36() {
}
}
-void TuckerEngine::updateSprite_locationNum37(int i, int j, int offset) {
+void TuckerEngine::updateSprite_locationNum37(int i) {
+ int j = i + 1;
+ int offset = 200 - i * 45;
++_spritesTable[i].counter;
if (_spritesTable[i].counter > offset) {
_spritesTable[i].state = j;
@@ -2069,7 +2084,7 @@ void TuckerEngine::updateSprite_locationNum42(int i) {
} else if (_flagsTable[223] == 3) {
state = 5;
_spritesTable[i].updateDelay = 5;
- _spritesTable[i].state = _spritesTable[i].firstFrame - 1; // XXX bug, fxNum ?
+ _spritesTable[i].state = _spritesTable[i].firstFrame - 1; // FIXME: bug, fxNum ?
_updateSpriteFlag1 = 1;
} else {
state = 2;
@@ -2273,32 +2288,29 @@ void TuckerEngine::updateSprite_locationNum50(int i) {
_updateSpriteFlag1 = 1;
state = i + 1;
}
- state = i + 1; // XXX bug ?
+ state = i + 1; // FIXME: bug ?
_spritesTable[i].state = state;
}
-void TuckerEngine::updateSprite_locationNum51_0(int i) {
- static const int stateTable[] = { 3, 3, 4, 5, 3, 3, 5, 4, 3, 3, 4, 5, 4, 4 };
- ++_spritesTable[i].counter;
- if (_spritesTable[i].counter > 13) {
- _spritesTable[i].counter = 0;
+void TuckerEngine::updateSprite_locationNum51(int i) {
+ if (i == 2) {
+ _spritesTable[i].state = 1;
+ } else if (i == 0) {
+ static const int stateTable[] = { 3, 3, 4, 5, 3, 3, 5, 4, 3, 3, 4, 5, 4, 4 };
+ ++_spritesTable[i].counter;
+ if (_spritesTable[i].counter > 13) {
+ _spritesTable[i].counter = 0;
+ }
+ _spritesTable[i].state = stateTable[_spritesTable[i].counter];
+ } else {
+ i = 1;
+ _spritesTable[i].state = 6;
}
- _spritesTable[i].state = stateTable[_spritesTable[i].counter];
- _spritesTable[i].colorType = 1;
- _spritesTable[i].yMaxBackground = 0;
-}
-void TuckerEngine::updateSprite_locationNum51_1(int i) {
- _spritesTable[i].state = 6;
_spritesTable[i].colorType = 1;
_spritesTable[i].yMaxBackground = 0;
}
-void TuckerEngine::updateSprite_locationNum51_2(int i) {
- _spritesTable[i].state = 1;
- _spritesTable[i].colorType = 1;
- _spritesTable[i].yMaxBackground = 0;
-}
void TuckerEngine::execData3PreUpdate_locationNum52() {
if (_selectedObject.xPos > 108 && _panelLockedFlag > 0 && _nextAction == 0 && _locationMaskType == 0) {
@@ -2813,7 +2825,7 @@ void TuckerEngine::updateSprite_locationNum65(int i) {
_flagsTable[189] = 0;
}
} else {
- if (_xPosCurrent >= 150 && _yPosCurrent < 240) { // XXX bug
+ if (_xPosCurrent >= 150 && _yPosCurrent < 240) { // FIXME: bug
if (getRandomNumber() > 32000) {
state = 2;
_flagsTable[189] = 1;
diff --git a/engines/tucker/tucker.cpp b/engines/tucker/tucker.cpp
index 12f966ba9d..c95426a6a0 100644
--- a/engines/tucker/tucker.cpp
+++ b/engines/tucker/tucker.cpp
@@ -1550,9 +1550,7 @@ void TuckerEngine::execData3PreUpdate() {
execData3PreUpdate_locationNum13();
break;
case 14:
- if (_yPosCurrent > 126) {
- execData3PreUpdate_locationNum14();
- }
+ execData3PreUpdate_locationNum14();
break;
case 15:
execData3PreUpdate_locationNum15();
@@ -1659,6 +1657,47 @@ void TuckerEngine::execData3PreUpdate() {
}
}
+void TuckerEngine::execData3PostUpdate() {
+ switch (_locationNum) {
+ case 1:
+ execData3PostUpdate_locationNum1();
+ break;
+ case 6:
+ execData3PostUpdate_locationNum6();
+ break;
+ case 8:
+ execData3PostUpdate_locationNum8();
+ break;
+ case 9:
+ execData3PostUpdate_locationNum9();
+ break;
+ case 14:
+ execData3PostUpdate_locationNum14();
+ break;
+ case 21:
+ execData3PostUpdate_locationNum21();
+ break;
+ case 24:
+ execData3PostUpdate_locationNum24();
+ break;
+ case 27:
+ execData3PostUpdate_locationNum27();
+ break;
+ case 28:
+ execData3PostUpdate_locationNum28();
+ break;
+ case 32:
+ execData3PostUpdate_locationNum32();
+ break;
+ case 60:
+ execData3PostUpdate_locationNum60();
+ break;
+ case 66:
+ execData3PostUpdate_locationNum66();
+ break;
+ }
+}
+
void TuckerEngine::drawBackgroundSprites() {
if (_backgroundSpriteDataPtr && _backgroundSpriteCurrentFrame != 0 && _backgroundSpriteCurrentFrame <= _backgroundSpriteLastFrame) {
int frameOffset = READ_LE_UINT24(_backgroundSpriteDataPtr + _backgroundSpriteCurrentFrame * 4);
@@ -2181,51 +2220,6 @@ void TuckerEngine::updateCharacterAnimation() {
_characterPrevFacingDirection = _characterFacingDirection;
}
-void TuckerEngine::execData3PostUpdate() {
- switch (_locationNum) {
- case 1:
- execData3PostUpdate_locationNum1();
- break;
- case 6:
- if (_flagsTable[26] < 4) {
- execData3PreUpdate_locationNum6Helper1();
- }
- break;
- case 8:
- execData3PostUpdate_locationNum8();
- break;
- case 9:
- execData3PostUpdate_locationNum9();
- break;
- case 14:
- if (_yPosCurrent < 127) {
- execData3PreUpdate_locationNum14();
- }
- break;
- case 21:
- execData3PostUpdate_locationNum21();
- break;
- case 24:
- execData3PostUpdate_locationNum24();
- break;
- case 27:
- execData3PostUpdate_locationNum27();
- break;
- case 28:
- execData3PostUpdate_locationNum28();
- break;
- case 32:
- execData3PostUpdate_locationNum32();
- break;
- case 60:
- execData3PostUpdate_locationNum60();
- break;
- case 66:
- execData3PostUpdate_locationNum66();
- break;
- }
-}
-
void TuckerEngine::addObjectToInventory(int num) {
_inventoryObjectsList[_inventoryObjectsCount] = num;
_lastInventoryObjectIndex = _inventoryObjectsCount;
@@ -2618,7 +2612,7 @@ void TuckerEngine::updateSprite(int i) {
if (i == 0) {
_spritesTable[0].state = -1;
} else {
- updateSprite_locationNum37(i, i + 1, 200 - i * 45);
+ updateSprite_locationNum37(i);
}
break;
case 41:
@@ -2666,13 +2660,7 @@ void TuckerEngine::updateSprite(int i) {
}
break;
case 51:
- if (i == 2) {
- updateSprite_locationNum51_2(2);
- } else if (i == 0) {
- updateSprite_locationNum51_0(0);
- } else {
- updateSprite_locationNum51_1(1);
- }
+ updateSprite_locationNum51(i);
break;
case 53:
if (i == 0) {
diff --git a/engines/tucker/tucker.h b/engines/tucker/tucker.h
index 630e6fc766..1cd19c2753 100644
--- a/engines/tucker/tucker.h
+++ b/engines/tucker/tucker.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef TUCKER_ENGINE_H__
-#define TUCKER_ENGINE_H__
+#ifndef TUCKER_ENGINE_H
+#define TUCKER_ENGINE_H
#include "common/file.h"
#include "common/util.h"
@@ -366,6 +366,7 @@ protected:
void execData3PreUpdate_locationNum6Helper1();
void execData3PreUpdate_locationNum6Helper2(int dstOffset, const uint8 *src);
void execData3PreUpdate_locationNum6Helper3(int dstOffset, const uint8 *src);
+ void execData3PostUpdate_locationNum6();
void updateSprite_locationNum7_0(int i);
void updateSprite_locationNum7_1(int i);
void updateSprite_locationNum8_0(int i);
@@ -392,6 +393,7 @@ protected:
void execData3PreUpdate_locationNum14();
void execData3PreUpdate_locationNum14Helper1(int i);
void execData3PreUpdate_locationNum14Helper2(int i);
+ void execData3PostUpdate_locationNum14();
void updateSprite_locationNum15_0(int i);
void updateSprite_locationNum15_1(int i);
void updateSprite_locationNum15_2(int i);
@@ -443,7 +445,6 @@ protected:
void updateSprite_locationNum31_0(int i);
void updateSprite_locationNum31_1(int i);
void execData3PreUpdate_locationNum31();
- void execData3PreUpdate_locationNum31Helper(int r, int flag);
void updateSprite_locationNum32_0(int i);
void execData3PreUpdate_locationNum32();
void execData3PostUpdate_locationNum32();
@@ -455,7 +456,7 @@ protected:
void execData3PreUpdate_locationNum35();
void updateSprite_locationNum36(int i);
void execData3PreUpdate_locationNum36();
- void updateSprite_locationNum37(int i, int j, int offset);
+ void updateSprite_locationNum37(int i);
void execData3PreUpdate_locationNum38();
void updateSprite_locationNum41(int i);
void execData3PreUpdate_locationNum41();
@@ -472,9 +473,7 @@ protected:
void updateSprite_locationNum49(int i);
void execData3PreUpdate_locationNum49();
void updateSprite_locationNum50(int i);
- void updateSprite_locationNum51_0(int i);
- void updateSprite_locationNum51_1(int i);
- void updateSprite_locationNum51_2(int i);
+ void updateSprite_locationNum51(int i);
void execData3PreUpdate_locationNum52();
void updateSprite_locationNum53_0(int i);
void updateSprite_locationNum53_1(int i);