Some minor clean-up

svn-id: r40166
This commit is contained in:
Sven Hesse 2009-04-27 18:56:28 +00:00
parent f177c7142c
commit c88b077fcc
13 changed files with 71 additions and 143 deletions

View file

@ -348,7 +348,7 @@ void Draw::adjustCoords(char adjust, int16 *coord1, int16 *coord2) {
}
int Draw::stringLength(const char *str, int16 fontIndex) {
static const int8 dword_8F74C[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
static const int8 japaneseExtraCharLen[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
if ((fontIndex < 0) || (fontIndex > 7) || !_fonts[fontIndex])
return 0;
@ -359,7 +359,7 @@ int Draw::stringLength(const char *str, int16 fontIndex) {
for (int i = 0; str[i] != 0; i++) {
if (((unsigned char) str[i+1]) < 128) {
len += dword_8F74C[4];
len += japaneseExtraCharLen[4];
i++;
} else
len += _fonts[fontIndex]->itemWidth;

View file

@ -617,8 +617,8 @@ void Draw_v2::spriteOperation(int16 operation) {
bool deltaVeto;
int16 left;
int16 ratio;
// Some handle, but always assigned to -1 in Game::loadTotFile()
int16 word_2F2D2 = -1;
// Always assigned to -1 in Game::loadTotFile()
int16 someHandle = -1;
deltaVeto = (operation & 0x10) != 0;
operation &= 0x0F;
@ -816,7 +816,7 @@ void Draw_v2::spriteOperation(int16 operation) {
}
} else {
for (int i = 0; i < len; i++) {
if ((word_2F2D2 < 0) || (_textToPrint[i] != ' ')) {
if ((someHandle < 0) || (_textToPrint[i] != ' ')) {
_vm->_video->drawLetter(_textToPrint[i], _destSpriteX,
_destSpriteY, _fonts[_fontIndex], _transparency,
_frontColor, _backColor, _spritesArray[_destSurface]);

View file

@ -327,7 +327,7 @@ public:
virtual ~Game_v6() {}
protected:
uint32 _dword_63E44;
uint32 _someTimeDly;
virtual void setCollisions(byte arg_0 = 1);
virtual void collSub(uint16 offset);
@ -336,7 +336,7 @@ protected:
virtual int16 checkMousePoint(int16 all, int16 *resId, int16 *resIndex);
void sub_1BA78();
void collSubReenter();
};
} // End of namespace Gob

View file

@ -37,7 +37,7 @@
namespace Gob {
Game_v6::Game_v6(GobEngine *vm) : Game_v2(vm) {
_dword_63E44 = 0;
_someTimeDly = 0;
}
// flagbits: 5 = freeInterVariables, 6 = skipPlay
@ -266,7 +266,7 @@ int16 Game_v6::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId,
return 0;
}
sub_1BA78();
collSubReenter();
if (!_vm->_draw->_noInvalidated) {
if (handleMouse != 0)
_vm->_draw->animateCursor(-1);
@ -345,7 +345,7 @@ int16 Game_v6::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId,
if ((_lastCollKey != 0) && (_lastCollId & 0x8000))
collAreaSub(_lastCollAreaIndex, 1);
} else
sub_1BA78();
collSubReenter();
}
if ((deltaTime == -2) && (key == 0) && (_mouseButtons == 0)) {
@ -1022,7 +1022,7 @@ void Game_v6::collSub(uint16 offset) {
_shouldPushColls = 0;
_vm->_global->_inter_execPtr = savedIP;
if ((_vm->_util->getTimeKey() - _dword_63E44) > 500)
if ((_vm->_util->getTimeKey() - _someTimeDly) > 500)
setCollisions(0);
}
@ -1135,7 +1135,7 @@ int16 Game_v6::checkMousePoint(int16 all, int16 *resId, int16 *resIndex) {
return 0;
}
void Game_v6::sub_1BA78() {
void Game_v6::collSubReenter() {
int16 lastCollAreaIndex = _lastCollAreaIndex;
int16 lastCollId = _lastCollId;
int16 collKey = checkMousePoint(1, &_lastCollId, &_lastCollAreaIndex);

View file

@ -327,7 +327,7 @@ public:
virtual ~Goblin_v4() {}
private:
int16 sub_20430(int16 state, uint16 dir);
int16 turnState(int16 state, uint16 dir);
};
} // End of namespace Gob

View file

@ -126,17 +126,17 @@ void Goblin_v4::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
if (_vm->_map->_widthByte == 4) {
switch (dir) {
case Map::kDirNW:
animData->nextState = sub_20430(animData->state, Map::kDirNW);
animData->nextState = turnState(animData->state, Map::kDirNW);
if ((_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10) &&
(animData->nextState == 1))
animData->nextState = 40;
if (_vm->_map->getPass(obj->goblinX - 1, obj->goblinY - 2) != 10)
animData->nextState = sub_20430(animData->state, Map::kDirNW);
animData->nextState = turnState(animData->state, Map::kDirNW);
break;
case Map::kDirN:
animData->nextState =
(animData->curLookDir == 2) ? 2 : sub_20430(animData->state, Map::kDirN);
(animData->curLookDir == 2) ? 2 : turnState(animData->state, Map::kDirN);
if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10) {
if (_vm->_map->getPass(obj->goblinX - 1, obj->goblinY - 2) != 10) {
if (_vm->_map->getPass(obj->goblinX + 1, obj->goblinY - 2) == 10)
@ -155,34 +155,34 @@ void Goblin_v4::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
break;
case Map::kDirNE:
animData->nextState = sub_20430(animData->state, Map::kDirNE);
animData->nextState = turnState(animData->state, Map::kDirNE);
if ((_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10) &&
(animData->nextState == 3))
animData->nextState = 42;
if (_vm->_map->getPass(obj->goblinX + 1, obj->goblinY - 2) != 10)
animData->nextState = sub_20430(animData->state, Map::kDirNE);
animData->nextState = turnState(animData->state, Map::kDirNE);
break;
case Map::kDirW:
animData->nextState = sub_20430(animData->state, Map::kDirW);
animData->nextState = turnState(animData->state, Map::kDirW);
break;
case Map::kDirE:
animData->nextState = sub_20430(animData->state, Map::kDirE);
animData->nextState = turnState(animData->state, Map::kDirE);
break;
case Map::kDirSW:
animData->nextState = sub_20430(animData->state, Map::kDirSW);
animData->nextState = turnState(animData->state, Map::kDirSW);
if ((_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10) &&
(animData->nextState == 7))
animData->nextState = 41;
if (_vm->_map->getPass(obj->goblinX - 1, obj->goblinY) != 10)
animData->nextState = sub_20430(animData->state, Map::kDirSW);
animData->nextState = turnState(animData->state, Map::kDirSW);
break;
case Map::kDirS:
animData->nextState =
(animData->curLookDir == 6) ? 6 : sub_20430(animData->state, Map::kDirS);
(animData->curLookDir == 6) ? 6 : turnState(animData->state, Map::kDirS);
if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10) {
if (_vm->_map->getPass(obj->goblinX - 1, obj->goblinY + 2) != 10) {
if (_vm->_map->getPass(obj->goblinX + 1, obj->goblinY + 2) == 10)
@ -192,7 +192,7 @@ void Goblin_v4::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
} else
animData->nextState = 41;
}
// loc_20AAD
if ((_vm->_map->getPass(obj->goblinX, obj->goblinY) == 20) &&
(animData->nextState == 6))
animData->nextState = 39;
@ -202,66 +202,57 @@ void Goblin_v4::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
break;
case Map::kDirSE:
animData->nextState = sub_20430(animData->state, Map::kDirSE);
animData->nextState = turnState(animData->state, Map::kDirSE);
if ((_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10) &&
(animData->nextState == 5))
animData->nextState = 43;
if (_vm->_map->getPass(obj->goblinX + 1, obj->goblinY) != 10)
animData->nextState = sub_20430(animData->state, Map::kDirSE);
animData->nextState = turnState(animData->state, Map::kDirSE);
break;
default:
// loc_20D18
switch (animData->state) {
case 0:
case 8:
// loc_21134
animData->nextState = 8;
break;
case 1:
case 10:
case 40:
// loc_21152
animData->nextState = 10;
break;
case 2:
case 29:
// loc_2113E
animData->nextState = 29;
break;
case 3:
case 11:
case 42:
// loc_2115C
animData->nextState = 11;
break;
case 4:
case 9:
// loc_2112A
animData->nextState = 9;
break;
case 5:
case 30:
case 43:
// loc_21166
animData->nextState = 30;
break;
case 6:
case 28:
// loc_21148
animData->nextState = 28;
break;
case 7:
case 31:
case 41:
// loc_21170
animData->nextState = 31;
break;
}
@ -541,8 +532,8 @@ void Goblin_v4::moveAdvance(Mult::Mult_Object *obj, Gob_Object *gobDesc,
}
}
int16 Goblin_v4::sub_20430(int16 state, uint16 dir) {
static const int16 word_3F25E[8][8] = {
int16 Goblin_v4::turnState(int16 state, uint16 dir) {
static const int16 newStates[8][8] = {
{ 0, 1, 10, 10, 10, 31, 31, 7},
{ 0, 1, 2, 29, 29, 29, 8, 8},
{10, 1, 2, 3, 11, 11, 11, 10},
@ -557,56 +548,46 @@ int16 Goblin_v4::sub_20430(int16 state, uint16 dir) {
switch (state) {
case 0:
case 8:
// loc_20447
dx = 0;
break;
case 1:
case 10:
case 40:
// loc_2044B
dx = 1;
break;
case 3:
case 11:
case 42:
// loc_20455
dx = 3;
break;
case 5:
case 30:
case 43:
// loc_2045F
dx = 5;
break;
case 7:
case 31:
case 41:
// loc_20469
dx = 7;
break;
case 9:
// loc_2045A
dx = 4;
break;
case 28:
// loc_20464
dx = 6;
break;
case 29:
// loc_20450
dx = 2;
break;
}
// loc_2046C
switch (dir) {
case Map::kDirNW:
cx = 1;
@ -641,7 +622,7 @@ int16 Goblin_v4::sub_20430(int16 state, uint16 dir) {
break;
}
return word_3F25E[dx][cx];
return newStates[dx][cx];
}
} // End of namespace Gob

View file

@ -625,7 +625,7 @@ protected:
virtual const char *getOpcodeFuncDesc(byte i, byte j);
virtual const char *getOpcodeGoblinDesc(int i);
byte _byte_8AA14;
byte _gob_97_98_val;
void o5_deleteFile();
void o5_initScreen();

View file

@ -946,26 +946,24 @@ void Inter_v5::o5_loadSystemSpecs(OpGobParams &params) {
*/
/*
// Calculating whether speed throttling is necessary?
speedSum = MAX(_cdSpeed, 150);
speedSum += (_ram << 3);
speedSum += (_cpuSpeed << 3);
speedSum /= 17;
var_E = MAX(_cdSpeed, 150);
var_E += (_ram << 3);
var_E += (_cpuSpeed << 3);
var_E /= 17;
needThrottle2 = (speedSum > 81) ? 1 : 0;
needThrottle1 = (_total >= 95) ? 1 : 0;
byte_8A61E = (var_E > 81) ? 1 : 0;
byte_8A5E0 = (_total >= 95) ? 1 : 0;
if (byte_8A5E0 == 1) {
word_8AEE2 = 100;
byte_8AEE4 = 1;
byte_8AEE5 = 1;
word_8AEE6 = 0;
if (needThrottle1 == 1) {
speedThrottle1 = 100;
speedThrottle2 = 1;
speedThrottle3 = 1;
speedThrottle4 = 0;
} else {
word_8AEE2 = 0;
byte_8AEE4 = 0;
byte_8AEE5 = 0;
word_8AEE6 = 40;
speedThrottle1 = 0;
speedThrottle2 = 0;
speedThrottle3 = 0;
speedThrottle4 = 40;
}
*/
}
@ -975,7 +973,7 @@ void Inter_v5::o5_gob92(OpGobParams &params) {
_vm->_global->_inter_execPtr += 2;
WRITE_VAR_UINT32(load16(), 0 /* (uint32) ((int32) ((int8) byte_86B9E)) */);
WRITE_VAR_UINT32(load16(), 0 /* (uint32) ((int32) ((int8) _gob92_1)) */);
}
void Inter_v5::o5_gob95(OpGobParams &params) {
@ -983,87 +981,37 @@ void Inter_v5::o5_gob95(OpGobParams &params) {
_vm->_global->_inter_execPtr += 2;
WRITE_VAR_UINT32(load16(), 0 /* (uint32) ((int32) ((int16) word_8AEE6)) */);
WRITE_VAR_UINT32(load16(), 0 /* (uint32) ((int32) ((int8) byte_8AEE5)) */);
WRITE_VAR_UINT32(load16(), 0 /* (uint32) ((int32) ((int8) byte_8AEE4)) */);
WRITE_VAR_UINT32(load16(), 0 /* (uint32) ((int32) ((int16) word_8AEE2)) */);
WRITE_VAR_UINT32(load16(), 0 /* (uint32) ((int32) ((int16) speedThrottle4)) */);
WRITE_VAR_UINT32(load16(), 0 /* (uint32) ((int32) ((int8) speedThrottle3)) */);
WRITE_VAR_UINT32(load16(), 0 /* (uint32) ((int32) ((int8) speedThrottle2)) */);
WRITE_VAR_UINT32(load16(), 0 /* (uint32) ((int32) ((int16) speedThrottle1)) */);
}
void Inter_v5::o5_gob96(OpGobParams &params) {
int16 word_8AEE6, word_85B50, word_8AEE2;
byte byte_8AEE5, byte_8AEE4;
int16 speedThrottle4, speedThrottle1;
byte speedThrottle3, speedThrottle2;
_vm->_global->_inter_execPtr += 2;
word_8AEE6 = word_85B50 = READ_VAR_UINT16(load16());
byte_8AEE5 = READ_VAR_UINT8(load16());
byte_8AEE4 = READ_VAR_UINT8(load16());
word_8AEE2 = READ_VAR_UINT16(load16());
speedThrottle4 = READ_VAR_UINT16(load16());
speedThrottle3 = READ_VAR_UINT8(load16());
speedThrottle2 = READ_VAR_UINT8(load16());
speedThrottle1 = READ_VAR_UINT16(load16());
warning("Dynasty Stub: GobFunc 96: %d, %d, %d, %d",
word_8AEE6, byte_8AEE5, byte_8AEE4, word_8AEE2);
// .--- sub_194B0 ---
int16 word_8A8F0, word_8A8F2, word_8A8F4, word_8A8F6, word_8A8F8, word_8A8FA;
int16 word_8A62C = 1;
int16 word_8A63C, word_8A640, word_8B464, word_8B466;
byte byte_8A62E;
int16 var_2, var_4;
var_2 = word_85B50 + 31;
word_8A8F0 = word_8A8F2 = var_2;
word_8A8F4 = word_85B50;
var_4 = 315 - word_85B50;
word_8A8F6 = word_8A8F8 = var_4;
word_8A8FA = 479 - word_85B50;
if (word_8A62C == 0) {
word_8A63C = word_8A8F0;
word_8A640 = word_8A8F6;
word_8B464 = word_8A8F0;
word_8B466 = word_8A8F6;
} else if (word_8A62C == 1) {
word_8A63C = word_85B50;
word_8A640 = word_8A8FA;
word_8B464 = word_85B50;
word_8B466 = word_8A8FA;
} else if (word_8A62C == 2) {
word_8A63C = word_8A8F4;
word_8A640 = word_8A8FA;
word_8B464 = word_8A8F4;
word_8B466 = word_8A8FA;
} else if (word_8A62C == 3) {
word_8A63C = word_8A8F4;
word_8A640 = word_8A8FA;
word_8B464 = word_8A8F4;
word_8B466 = word_8A8FA;
} else if (word_8A62C == 4) {
word_8A63C = word_8A8F4;
word_8A640 = word_8A8FA;
word_8B464 = word_8A8F4;
word_8B466 = word_8A8FA;
}
byte_8A62E = 1;
// '--- ---
speedThrottle4, speedThrottle3, speedThrottle2, speedThrottle1);
// TODO
}
void Inter_v5::o5_gob97(OpGobParams &params) {
_byte_8AA14 = 1;
_gob_97_98_val = 1;
_vm->_global->_inter_execPtr += 2;
}
void Inter_v5::o5_gob98(OpGobParams &params) {
_byte_8AA14 = 0;
_gob_97_98_val = 0;
_vm->_global->_inter_execPtr += 2;
}

View file

@ -982,10 +982,10 @@ bool Inter_v6::o6_fillRect(OpFuncParams &params) {
evalExpr(0);
_vm->_draw->_backColor = _vm->_global->_inter_resVal & 0xFFFF;
uint16 word_63E64 = _vm->_global->_inter_resVal >> 16;
uint16 extraVar = _vm->_global->_inter_resVal >> 16;
if (word_63E64 != 0)
warning("Urban Stub: o6_fillRect(), word_63E64 = %d", word_63E64);
if (extraVar != 0)
warning("Urban Stub: o6_fillRect(), extraVar = %d", extraVar);
if (_vm->_draw->_spriteRight < 0) {
_vm->_draw->_destSpriteX += _vm->_draw->_spriteRight - 1;

View file

@ -628,7 +628,7 @@ void Mult_v2::drawStatics(bool &stop) {
}
}
void Mult_v2::drawAnims(bool &stop) { // loc_50D5
void Mult_v2::drawAnims(bool &stop) {
int16 count;
int animIndex;
@ -698,7 +698,6 @@ void Mult_v2::newCycleAnim(Mult_Object &animObj) {
}
if (animData.animType == 4) {
// loc_1E091
animData.frame = 0;
animData.isPaused = 1;
if (animData.animation < 0)

View file

@ -136,7 +136,7 @@ public:
Parse_v2(GobEngine *vm);
virtual ~Parse_v2() {}
virtual int16 sub_12063(int16 arg_0, byte arg_2, uint32 arg_3, uint16 arg_7, uint16 arg_9);
virtual int16 getOffset(int16 arg_0, byte arg_2, uint32 arg_3, uint16 arg_7, uint16 arg_9);
virtual int16 parseVarIndex(uint16 *arg_0 = 0, uint16 *arg_4 = 0);
virtual int16 parseValExpr(byte stopToken = 99);

View file

@ -87,7 +87,7 @@ int16 Parse_v2::parseVarIndex(uint16 *arg_0, uint16 *arg_4) {
for (int i = 0; i < var_A; i++) {
temp2 = parseValExpr(OP_END_MARKER);
int16 ax = sub_12063(temp2, var_12[i], varPos, 0, 0);
int16 ax = getOffset(temp2, var_12[i], varPos, 0, 0);
var_6 = var_6 * var_12[i] + ax;
}
@ -218,7 +218,7 @@ int16 Parse_v2::parseValExpr(byte stopToken) {
for (int i = 0; i < var_A; i++) {
temp2 = parseValExpr(OP_END_MARKER);
int16 ax = sub_12063(temp2, var_12[i], varPos, 0, 0);
int16 ax = getOffset(temp2, var_12[i], varPos, 0, 0);
var_6 = var_6 * var_12[i] + ax;
}
@ -510,7 +510,7 @@ int16 Parse_v2::parseExpr(byte stopToken, byte *arg_2) {
for (int i = 0; i < var_A; i++) {
temp2 = parseValExpr(OP_END_MARKER);
int16 ax = sub_12063(temp2, var_12[i], varPos, 0, 0);
int16 ax = getOffset(temp2, var_12[i], varPos, 0, 0);
var_6 = var_6 * var_12[i] + ax;
}
@ -1049,7 +1049,7 @@ int16 Parse_v2::parseExpr(byte stopToken, byte *arg_2) {
}
}
int16 Parse_v2::sub_12063(int16 arg_0, byte arg_2, uint32 arg_3, uint16 arg_7, uint16 arg_9) {
int16 Parse_v2::getOffset(int16 arg_0, byte arg_2, uint32 arg_3, uint16 arg_7, uint16 arg_9) {
if (arg_0 < 0)
return 0;

View file

@ -242,8 +242,8 @@ void Video_v6::drawPacked(const byte *sprBuf, int16 x, int16 y, SurfaceDesc *sur
uncBuf = new byte[size];
//sub_4F020(data, buf);
warning("Urban Stub: drawPacked: sub_4F020(data, uncBuf)");
//spriteUncompressor(data, buf);
warning("Urban Stub: drawPacked: spriteUncompressor(data, uncBuf)");
srcData = uncBuf;
}