aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorEugene Sandulenko2011-08-14 18:47:51 +0100
committerEugene Sandulenko2011-08-14 18:48:59 +0100
commit273e37f7263ab30b445a8123af52fe81ddb762d0 (patch)
tree8bec238ddc1696530e7b59f1408dc6eca1c6cc62 /engines/agi
parent026a2c52da9d1efb9fc4f852c9f8cfa2473fcda5 (diff)
downloadscummvm-rg350-273e37f7263ab30b445a8123af52fe81ddb762d0.tar.gz
scummvm-rg350-273e37f7263ab30b445a8123af52fe81ddb762d0.tar.bz2
scummvm-rg350-273e37f7263ab30b445a8123af52fe81ddb762d0.zip
AGI: Renamed some #defines to our code conventions and moved them to enums
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/checks.cpp30
-rw-r--r--engines/agi/cycle.cpp6
-rw-r--r--engines/agi/keyboard.cpp4
-rw-r--r--engines/agi/motion.cpp28
-rw-r--r--engines/agi/op_cmd.cpp160
-rw-r--r--engines/agi/op_test.cpp2
-rw-r--r--engines/agi/saveload.cpp4
-rw-r--r--engines/agi/sprite.cpp10
-rw-r--r--engines/agi/view.cpp48
-rw-r--r--engines/agi/view.h66
10 files changed, 182 insertions, 176 deletions
diff --git a/engines/agi/checks.cpp b/engines/agi/checks.cpp
index 20276657ff..c3b31f6ba9 100644
--- a/engines/agi/checks.cpp
+++ b/engines/agi/checks.cpp
@@ -31,7 +31,7 @@ int AgiEngine::checkPosition(VtEntry *v) {
v->xPos + v->xSize > _WIDTH ||
v->yPos - v->ySize + 1 < 0 ||
v->yPos >= _HEIGHT ||
- ((~v->flags & IGNORE_HORIZON) && v->yPos <= _game.horizon)) {
+ ((~v->flags & fIgnoreHorizon) && v->yPos <= _game.horizon)) {
debugC(4, kDebugLevelSprites, "check position failed: x=%d, y=%d, h=%d, w=%d",
v->xPos, v->yPos, v->xSize, v->ySize);
return 0;
@@ -52,14 +52,14 @@ int AgiEngine::checkPosition(VtEntry *v) {
int AgiEngine::checkCollision(VtEntry *v) {
VtEntry *u;
- if (v->flags & IGNORE_OBJECTS)
+ if (v->flags & fIgnoreObjects)
return 0;
for (u = _game.viewTable; u < &_game.viewTable[MAX_VIEWTABLE]; u++) {
- if ((u->flags & (ANIMATED | DRAWN)) != (ANIMATED | DRAWN))
+ if ((u->flags & (fAnimated | fDrawn)) != (fAnimated | fDrawn))
continue;
- if (u->flags & IGNORE_OBJECTS)
+ if (u->flags & fIgnoreObjects)
continue;
// Same object, check next
@@ -92,7 +92,7 @@ int AgiEngine::checkPriority(VtEntry *v) {
int i, trigger, water, pass, pri;
uint8 *p0;
- if (~v->flags & FIXED_PRIORITY) {
+ if (~v->flags & fFixedPriority) {
// Priority bands
v->priority = _game.priTable[v->yPos];
}
@@ -129,7 +129,7 @@ int AgiEngine::checkPriority(VtEntry *v) {
water = 0;
if (pri == 1) { // conditional blue
- if (v->flags & IGNORE_BLOCKS)
+ if (v->flags & fIgnoreBlocks)
continue;
debugC(4, kDebugLevelSprites, "Blocks observed!");
@@ -145,9 +145,9 @@ int AgiEngine::checkPriority(VtEntry *v) {
}
if (pass) {
- if (!water && v->flags & ON_WATER)
+ if (!water && v->flags & fOnWater)
pass = 0;
- if (water && v->flags & ON_LAND)
+ if (water && v->flags & fOnLand)
pass = 0;
}
@@ -180,7 +180,7 @@ void AgiEngine::updatePosition() {
_game.vars[vBorderTouchObj] = 0;
for (v = _game.viewTable; v < &_game.viewTable[MAX_VIEWTABLE]; v++) {
- if ((v->flags & (ANIMATED | UPDATE | DRAWN)) != (ANIMATED | UPDATE | DRAWN)) {
+ if ((v->flags & (fAnimated | fUpdate | fDrawn)) != (fAnimated | fUpdate | fDrawn)) {
continue;
}
@@ -195,7 +195,7 @@ void AgiEngine::updatePosition() {
y = oldY = v->yPos;
// If object has moved, update its position
- if (~v->flags & UPDATE_POS) {
+ if (~v->flags & fUpdatePos) {
int dx[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 };
int dy[9] = { 0, -1, -1, 0, 1, 1, 1, 0, -1 };
x += v->stepSize * dx[v->direction];
@@ -212,7 +212,7 @@ void AgiEngine::updatePosition() {
} else if (x <= 0 && getVersion() == 0x3086) { // KQ4
x = 0; // See Sarien bug #590462
border = 4;
- } else if (v->entry == 0 && x == 0 && v->flags & ADJ_EGO_XY) {
+ } else if (v->entry == 0 && x == 0 && v->flags & fAdjEgoXY) {
// Extra test to walk west clicking the mouse
x = 0;
border = 4;
@@ -228,7 +228,7 @@ void AgiEngine::updatePosition() {
} else if (y > _HEIGHT - 1) {
y = _HEIGHT - 1;
border = 3;
- } else if ((~v->flags & IGNORE_HORIZON) && y <= _game.horizon) {
+ } else if ((~v->flags & fIgnoreHorizon) && y <= _game.horizon) {
debugC(4, kDebugLevelSprites, "y = %d, horizon = %d", y, _game.horizon);
y = _game.horizon + 1;
border = 1;
@@ -251,12 +251,12 @@ void AgiEngine::updatePosition() {
_game.vars[vBorderCode] = v->entry;
_game.vars[vBorderTouchObj] = border;
}
- if (v->motion == MOTION_MOVE_OBJ) {
+ if (v->motion == kMotionMoveObj) {
inDestination(v);
}
}
- v->flags &= ~UPDATE_POS;
+ v->flags &= ~fUpdatePos;
}
}
@@ -276,7 +276,7 @@ void AgiEngine::fixPosition(int n) {
debugC(4, kDebugLevelSprites, "adjusting view table entry #%d (%d,%d)", n, v->xPos, v->yPos);
// test horizon
- if ((~v->flags & IGNORE_HORIZON) && v->yPos <= _game.horizon)
+ if ((~v->flags & fIgnoreHorizon) && v->yPos <= _game.horizon)
v->yPos = _game.horizon + 1;
dir = 0;
diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp
index d86fb36709..e6f122f9f6 100644
--- a/engines/agi/cycle.cpp
+++ b/engines/agi/cycle.cpp
@@ -47,8 +47,8 @@ void AgiEngine::newRoom(int n) {
i = 0;
for (v = _game.viewTable; v < &_game.viewTable[MAX_VIEWTABLE]; v++) {
v->entry = i++;
- v->flags &= ~(ANIMATED | DRAWN);
- v->flags |= UPDATE;
+ v->flags &= ~(fAnimated | fDrawn);
+ v->flags |= fUpdate;
v->stepTime = 1;
v->stepTimeCount = 1;
v->cycleTime = 1;
@@ -220,7 +220,7 @@ int AgiEngine::mainCycle() {
}
// Click-to-walk mouse interface
- if (_game.playerControl && v->flags & ADJ_EGO_XY) {
+ if (_game.playerControl && v->flags & fAdjEgoXY) {
int toX = v->parm1;
int toY = v->parm2;
diff --git a/engines/agi/keyboard.cpp b/engines/agi/keyboard.cpp
index f5810a6e8c..d899a6e202 100644
--- a/engines/agi/keyboard.cpp
+++ b/engines/agi/keyboard.cpp
@@ -180,7 +180,7 @@ int AgiEngine::handleController(int key) {
if (!(getFeatures() & GF_AGIMOUSE)) {
// Handle mouse button events
if (key == BUTTON_LEFT) {
- v->flags |= ADJ_EGO_XY;
+ v->flags |= fAdjEgoXY;
v->parm1 = WIN_TO_PIC_X(_mouse.x);
v->parm2 = WIN_TO_PIC_Y(_mouse.y);
return true;
@@ -188,7 +188,7 @@ int AgiEngine::handleController(int key) {
}
if (d || key == KEY_STATIONARY) {
- v->flags &= ~ADJ_EGO_XY;
+ v->flags &= ~fAdjEgoXY;
v->direction = v->direction == d ? 0 : d;
return true;
}
diff --git a/engines/agi/motion.cpp b/engines/agi/motion.cpp
index 261a7f3e61..e4de232267 100644
--- a/engines/agi/motion.cpp
+++ b/engines/agi/motion.cpp
@@ -52,9 +52,9 @@ void AgiEngine::changePos(VtEntry *v) {
y += v->stepSize * dy[v->direction];
if (checkBlock(x, y) == b) {
- v->flags &= ~MOTION;
+ v->flags &= ~fMotion;
} else {
- v->flags |= MOTION;
+ v->flags |= fMotion;
v->direction = 0;
if (isEgoView(v))
_game.vars[vEgoDir] = 0;
@@ -63,7 +63,7 @@ void AgiEngine::changePos(VtEntry *v) {
void AgiEngine::motionWander(VtEntry *v) {
if (v->parm1--) {
- if (~v->flags & DIDNT_MOVE)
+ if (~v->flags & fDidntMove)
return;
}
@@ -94,14 +94,14 @@ void AgiEngine::motionFollowEgo(VtEntry *v) {
// Already at ego coordinates
if (dir == 0) {
v->direction = 0;
- v->motion = MOTION_NORMAL;
+ v->motion = kMotionNormal;
setflag(v->parm2, true);
return;
}
if (v->parm3 == 0xff) {
v->parm3 = 0;
- } else if (v->flags & DIDNT_MOVE) {
+ } else if (v->flags & fDidntMove) {
int d;
while ((v->direction = _rnd->getRandomNumber(8)) == 0) {
@@ -152,18 +152,20 @@ void AgiEngine::motionMoveObj(VtEntry *v) {
void AgiEngine::checkMotion(VtEntry *v) {
switch (v->motion) {
- case MOTION_WANDER:
+ case kMotionNormal:
+ break;
+ case kMotionWander:
motionWander(v);
break;
- case MOTION_FOLLOW_EGO:
+ case kMotionFollowEgo:
motionFollowEgo(v);
break;
- case MOTION_MOVE_OBJ:
+ case kMotionMoveObj:
motionMoveObj(v);
break;
}
- if ((_game.block.active && (~v->flags & IGNORE_BLOCKS)) && v->direction)
+ if ((_game.block.active && (~v->flags & fIgnoreBlocks)) && v->direction)
changePos(v);
}
@@ -178,7 +180,7 @@ void AgiEngine::checkAllMotions() {
VtEntry *v;
for (v = _game.viewTable; v < &_game.viewTable[MAX_VIEWTABLE]; v++) {
- if ((v->flags & (ANIMATED | UPDATE | DRAWN)) == (ANIMATED | UPDATE | DRAWN)
+ if ((v->flags & (fAnimated | fUpdate | fDrawn)) == (fAnimated | fUpdate | fDrawn)
&& v->stepTimeCount == 1) {
checkMotion(v);
}
@@ -192,11 +194,11 @@ void AgiEngine::checkAllMotions() {
* @param v Pointer to view table entry
*/
void AgiEngine::inDestination(VtEntry *v) {
- if (v->motion == MOTION_MOVE_OBJ) {
+ if (v->motion == kMotionMoveObj) {
v->stepSize = v->parm3;
setflag(v->parm4, true);
}
- v->motion = MOTION_NORMAL;
+ v->motion = kMotionNormal;
if (isEgoView(v))
_game.playerControl = true;
}
@@ -204,7 +206,7 @@ void AgiEngine::inDestination(VtEntry *v) {
/**
* Wrapper for static function motion_moveobj().
* This function is used by cmd_move_object() in the first motion cycle
- * after setting the motion mode to MOTION_MOVE_OBJ.
+ * after setting the motion mode to kMotionMoveObj.
* @param v Pointer to view table entry
*/
void AgiEngine::moveObj(VtEntry *v) {
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index 7148ef6407..80b150d2d6 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -209,39 +209,39 @@ void cmdDiscardView(AgiGame *state, uint8 *p) {
}
void cmdObjectOnAnything(AgiGame *state, uint8 *p) {
- vt.flags &= ~(ON_WATER | ON_LAND);
+ vt.flags &= ~(fOnWater | fOnLand);
}
void cmdObjectOnLand(AgiGame *state, uint8 *p) {
- vt.flags |= ON_LAND;
+ vt.flags |= fOnLand;
}
void cmdObjectOnWater(AgiGame *state, uint8 *p) {
- vt.flags |= ON_WATER;
+ vt.flags |= fOnWater;
}
void cmdObserveHorizon(AgiGame *state, uint8 *p) {
- vt.flags &= ~IGNORE_HORIZON;
+ vt.flags &= ~fIgnoreHorizon;
}
void cmdIgnoreHorizon(AgiGame *state, uint8 *p) {
- vt.flags |= IGNORE_HORIZON;
+ vt.flags |= fIgnoreHorizon;
}
void cmdObserveObjs(AgiGame *state, uint8 *p) {
- vt.flags &= ~IGNORE_OBJECTS;
+ vt.flags &= ~fIgnoreObjects;
}
void cmdIgnoreObjs(AgiGame *state, uint8 *p) {
- vt.flags |= IGNORE_OBJECTS;
+ vt.flags |= fIgnoreObjects;
}
void cmdObserveBlocks(AgiGame *state, uint8 *p) {
- vt.flags &= ~IGNORE_BLOCKS;
+ vt.flags &= ~fIgnoreBlocks;
}
void cmdIgnoreBlocks(AgiGame *state, uint8 *p) {
- vt.flags |= IGNORE_BLOCKS;
+ vt.flags |= fIgnoreBlocks;
}
void cmdSetHorizon(AgiGame *state, uint8 *p) {
@@ -253,7 +253,7 @@ void cmdGetPriority(AgiGame *state, uint8 *p) {
}
void cmdSetPriority(AgiGame *state, uint8 *p) {
- vt.flags |= FIXED_PRIORITY;
+ vt.flags |= fFixedPriority;
vt.priority = p1;
// WORKAROUND: this fixes bug #1712585 in KQ4 (dwarf sprite priority)
@@ -270,18 +270,18 @@ void cmdSetPriority(AgiGame *state, uint8 *p) {
// Therefore, this workaround only affects that specific part of this scene
// Ego is set to object 19 by script 54
if (getGameID() == GID_KQ4 && vt.currentView == 152) {
- state->viewTable[19].flags |= FIXED_PRIORITY;
+ state->viewTable[19].flags |= fFixedPriority;
state->viewTable[19].priority = 7;
}
}
void cmdSetPriorityF(AgiGame *state, uint8 *p) {
- vt.flags |= FIXED_PRIORITY;
+ vt.flags |= fFixedPriority;
vt.priority = _v[p1];
}
void cmdReleasePriority(AgiGame *state, uint8 *p) {
- vt.flags &= ~FIXED_PRIORITY;
+ vt.flags &= ~fFixedPriority;
}
void cmdSetUpperLeft(AgiGame *state, uint8 *p) { // do nothing (AGI 2.917)
@@ -316,13 +316,13 @@ void cmdSetCel(AgiGame *state, uint8 *p) {
state->_vm->setCel(&vt, p1);
if (getVersion() >= 0x2000) {
- vt.flags &= ~DONTUPDATE;
+ vt.flags &= ~fDontupdate;
}
}
void cmdSetCelF(AgiGame *state, uint8 *p) {
state->_vm->setCel(&vt, _v[p1]);
- vt.flags &= ~DONTUPDATE;
+ vt.flags &= ~fDontupdate;
}
void cmdSetView(AgiGame *state, uint8 *p) {
@@ -346,11 +346,11 @@ void cmdNumberOfLoops(AgiGame *state, uint8 *p) {
}
void cmdFixLoop(AgiGame *state, uint8 *p) {
- vt.flags |= FIX_LOOP;
+ vt.flags |= fFixLoop;
}
void cmdReleaseLoop(AgiGame *state, uint8 *p) {
- vt.flags &= ~FIX_LOOP;
+ vt.flags &= ~fFixLoop;
}
void cmdStepSize(AgiGame *state, uint8 *p) {
@@ -366,21 +366,21 @@ void cmdCycleTime(AgiGame *state, uint8 *p) {
}
void cmdStopCycling(AgiGame *state, uint8 *p) {
- vt.flags &= ~CYCLING;
+ vt.flags &= ~fCycling;
}
void cmdStartCycling(AgiGame *state, uint8 *p) {
- vt.flags |= CYCLING;
+ vt.flags |= fCycling;
}
void cmdNormalCycle(AgiGame *state, uint8 *p) {
- vt.cycle = CYCLE_NORMAL;
- vt.flags |= CYCLING;
+ vt.cycle = kCycleNormal;
+ vt.flags |= fCycling;
}
void cmdReverseCycle(AgiGame *state, uint8 *p) {
- vt.cycle = CYCLE_REVERSE;
- vt.flags |= CYCLING;
+ vt.cycle = kCycleReverse;
+ vt.flags |= fCycling;
}
void cmdSetDir(AgiGame *state, uint8 *p) {
@@ -540,16 +540,16 @@ void cmdObjStatusF(AgiGame *state, uint8 *p) {
// Generate cycle description line
switch (vt_v.cycle) {
- case CYCLE_NORMAL:
+ case kCycleNormal:
cycleDesc = "normal cycle";
break;
- case CYCLE_END_OF_LOOP:
+ case kCycleEndOfLoop:
cycleDesc = "end of loop";
break;
- case CYCLE_REV_LOOP:
+ case kCycleRevLoop:
cycleDesc = "reverse loop";
break;
- case CYCLE_REVERSE:
+ case kCycleReverse:
cycleDesc = "reverse cycle";
break;
default:
@@ -559,16 +559,16 @@ void cmdObjStatusF(AgiGame *state, uint8 *p) {
// Generate motion description line
switch (vt_v.motion) {
- case MOTION_NORMAL:
+ case kMotionNormal:
motionDesc = "normal motion";
break;
- case MOTION_WANDER:
+ case kMotionWander:
motionDesc = "wandering";
break;
- case MOTION_FOLLOW_EGO:
+ case kMotionFollowEgo:
motionDesc = "following ego";
break;
- case MOTION_MOVE_OBJ:
+ case kMotionMoveObj:
// Amiga's Gold Rush! most probably uses "move to (x, y)"
// here with real values for x and y. The same output
// is used when moving the ego around using the mouse.
@@ -655,7 +655,7 @@ void cmdHideMouse(AgiGame *state, uint8 *p) {
// to walk somewhere else than to the right using the mouse.
// FIXME: Write a proper implementation using disassembly and
// apply it to other games as well if applicable.
- state->viewTable[0].flags &= ~ADJ_EGO_XY;
+ state->viewTable[0].flags &= ~fAdjEgoXY;
g_system->showMouse(false);
}
@@ -705,7 +705,7 @@ void cmdAdjEgoMoveToXY(AgiGame *state, uint8 *p) {
// by something else because this command doesn't do any flag manipulations
// in the Amiga version - checked it with disassembly).
if (x != state->adjMouseX || y != state->adjMouseY)
- state->viewTable[EGO_VIEW_TABLE].flags &= ~ADJ_EGO_XY;
+ state->viewTable[EGO_VIEW_TABLE].flags &= ~fAdjEgoXY;
state->adjMouseX = x;
state->adjMouseY = y;
@@ -715,7 +715,7 @@ void cmdAdjEgoMoveToXY(AgiGame *state, uint8 *p) {
// TODO: Check where (if anywhere) the 0 arguments version is used
case 0:
default:
- state->viewTable[0].flags |= ADJ_EGO_XY;
+ state->viewTable[0].flags |= fAdjEgoXY;
break;
}
}
@@ -838,22 +838,22 @@ void cmdShowPriScreen(AgiGame *state, uint8 *p) {
void cmdAnimateObj(AgiGame *state, uint8 *p) {
if (getVersion() < 0x2000) {
- if (vt.flags & DIDNT_MOVE)
+ if (vt.flags & fDidntMove)
return;
} else {
- if (vt.flags & ANIMATED)
+ if (vt.flags & fAnimated)
return;
}
debugC(4, kDebugLevelScripts, "animate vt entry #%d", p0);
- vt.flags = ANIMATED | UPDATE | CYCLING;
+ vt.flags = fAnimated | fUpdate | fCycling;
if (getVersion() < 0x2000) {
- vt.flags |= DIDNT_MOVE;
+ vt.flags |= fDidntMove;
}
- vt.motion = MOTION_NORMAL;
- vt.cycle = CYCLE_NORMAL;
+ vt.motion = kMotionNormal;
+ vt.cycle = kCycleNormal;
vt.direction = 0;
}
@@ -861,11 +861,11 @@ void cmdUnanimateAll(AgiGame *state, uint8 *p) {
int i;
for (i = 0; i < MAX_VIEWTABLE; i++)
- state->viewTable[i].flags &= ~(ANIMATED | DRAWN);
+ state->viewTable[i].flags &= ~(fAnimated | fDrawn);
}
void cmdDraw(AgiGame *state, uint8 *p) {
- if (vt.flags & DRAWN)
+ if (vt.flags & fDrawn)
return;
if (vt.ySize <= 0 || vt.xSize <= 0)
@@ -873,7 +873,7 @@ void cmdDraw(AgiGame *state, uint8 *p) {
debugC(4, kDebugLevelScripts, "draw entry %d", vt.entry);
- vt.flags |= UPDATE;
+ vt.flags |= fUpdate;
if (getVersion() >= 0x3000) {
state->_vm->setLoop(&vt, vt.currentLoop);
state->_vm->setCel(&vt, vt.currentCel);
@@ -884,7 +884,7 @@ void cmdDraw(AgiGame *state, uint8 *p) {
vt.yPos2 = vt.yPos;
vt.celData2 = vt.celData;
state->_vm->_sprites->eraseUpdSprites();
- vt.flags |= DRAWN;
+ vt.flags |= fDrawn;
// WORKAROUND: This fixes a bug with AGI Fanmade _game Space Trek.
// The original workaround checked if AGI version was <= 2.440, which could
@@ -898,10 +898,10 @@ void cmdDraw(AgiGame *state, uint8 *p) {
// games are affected. If yes, then it'd be best to set this for Space
// Trek only
if (getFeatures() & GF_FANMADE) // See Sarien bug #546562
- vt.flags |= ANIMATED;
+ vt.flags |= fAnimated;
state->_vm->_sprites->blitUpdSprites();
- vt.flags &= ~DONTUPDATE;
+ vt.flags &= ~fDontupdate;
state->_vm->_sprites->commitBlock(vt.xPos, vt.yPos - vt.ySize + 1, vt.xPos + vt.xSize - 1, vt.yPos, true);
@@ -909,16 +909,16 @@ void cmdDraw(AgiGame *state, uint8 *p) {
}
void cmdErase(AgiGame *state, uint8 *p) {
- if (~vt.flags & DRAWN)
+ if (~vt.flags & fDrawn)
return;
state->_vm->_sprites->eraseUpdSprites();
- if (vt.flags & UPDATE) {
- vt.flags &= ~DRAWN;
+ if (vt.flags & fUpdate) {
+ vt.flags &= ~fDrawn;
} else {
state->_vm->_sprites->eraseNonupdSprites();
- vt.flags &= ~DRAWN;
+ vt.flags &= ~fDrawn;
state->_vm->_sprites->blitNonupdSprites();
}
state->_vm->_sprites->blitUpdSprites();
@@ -984,7 +984,7 @@ void cmdReposition(AgiGame *state, uint8 *p) {
int dx = (int8) _v[p1], dy = (int8) _v[p2];
debugC(4, kDebugLevelScripts, "dx=%d, dy=%d", dx, dy);
- vt.flags |= UPDATE_POS;
+ vt.flags |= fUpdatePos;
if (dx < 0 && vt.xPos < -dx)
vt.xPos = 0;
@@ -1002,7 +1002,7 @@ void cmdReposition(AgiGame *state, uint8 *p) {
void cmdRepositionV1(AgiGame *state, uint8 *p) {
vt.xPos2 = vt.xPos;
vt.yPos2 = vt.yPos;
- vt.flags |= UPDATE_POS;
+ vt.flags |= fUpdatePos;
vt.xPos = (vt.xPos + p1) & 0xff;
vt.yPos = (vt.yPos + p2) & 0xff;
@@ -1011,14 +1011,14 @@ void cmdRepositionV1(AgiGame *state, uint8 *p) {
void cmdRepositionTo(AgiGame *state, uint8 *p) {
vt.xPos = p1;
vt.yPos = p2;
- vt.flags |= UPDATE_POS;
+ vt.flags |= fUpdatePos;
state->_vm->fixPosition(p0);
}
void cmdRepositionToF(AgiGame *state, uint8 *p) {
vt.xPos = _v[p1];
vt.yPos = _v[p2];
- vt.flags |= UPDATE_POS;
+ vt.flags |= fUpdatePos;
state->_vm->fixPosition(p0);
}
@@ -1038,34 +1038,34 @@ void cmdForceUpdate(AgiGame *state, uint8 *p) {
void cmdReverseLoop(AgiGame *state, uint8 *p) {
debugC(4, kDebugLevelScripts, "o%d, f%d", p0, p1);
- vt.cycle = CYCLE_REV_LOOP;
- vt.flags |= (DONTUPDATE | UPDATE | CYCLING);
+ vt.cycle = kCycleRevLoop;
+ vt.flags |= (fDontupdate | fUpdate | fCycling);
vt.parm1 = p1;
setflag(p1, false);
}
void cmdReverseLoopV1(AgiGame *state, uint8 *p) {
debugC(4, kDebugLevelScripts, "o%d, f%d", p0, p1);
- vt.cycle = CYCLE_REV_LOOP;
+ vt.cycle = kCycleRevLoop;
state->_vm->setCel(&vt, 0);
- vt.flags |= (DONTUPDATE | UPDATE | CYCLING);
+ vt.flags |= (fDontupdate | fUpdate | fCycling);
vt.parm1 = p1;
vt.parm3 = 0;
}
void cmdEndOfLoop(AgiGame *state, uint8 *p) {
debugC(4, kDebugLevelScripts, "o%d, f%d", p0, p1);
- vt.cycle = CYCLE_END_OF_LOOP;
- vt.flags |= (DONTUPDATE | UPDATE | CYCLING);
+ vt.cycle = kCycleEndOfLoop;
+ vt.flags |= (fDontupdate | fUpdate | fCycling);
vt.parm1 = p1;
setflag(p1, false);
}
void cmdEndOfLoopV1(AgiGame *state, uint8 *p) {
debugC(4, kDebugLevelScripts, "o%d, f%d", p0, p1);
- vt.cycle = CYCLE_END_OF_LOOP;
+ vt.cycle = kCycleEndOfLoop;
state->_vm->setCel(&vt, 0);
- vt.flags |= (DONTUPDATE | UPDATE | CYCLING);
+ vt.flags |= (fDontupdate | fUpdate | fCycling);
vt.parm1 = p1;
vt.parm3 = 0;
}
@@ -1084,12 +1084,12 @@ void cmdUnblock(AgiGame *state, uint8 *p) {
}
void cmdNormalMotion(AgiGame *state, uint8 *p) {
- vt.motion = MOTION_NORMAL;
+ vt.motion = kMotionNormal;
}
void cmdStopMotion(AgiGame *state, uint8 *p) {
vt.direction = 0;
- vt.motion = MOTION_NORMAL;
+ vt.motion = kMotionNormal;
if (p0 == 0) { // ego only
_v[vEgoDir] = 0;
state->playerControl = false;
@@ -1097,11 +1097,11 @@ void cmdStopMotion(AgiGame *state, uint8 *p) {
}
void cmdStopMotionV1(AgiGame *state, uint8 *p) {
- vt.flags &= ~ANIMATED;
+ vt.flags &= ~fAnimated;
}
void cmdStartMotion(AgiGame *state, uint8 *p) {
- vt.motion = MOTION_NORMAL;
+ vt.motion = kMotionNormal;
if (p0 == 0) { // ego only
_v[vEgoDir] = 0;
state->playerControl = true;
@@ -1109,12 +1109,12 @@ void cmdStartMotion(AgiGame *state, uint8 *p) {
}
void cmdStartMotionV1(AgiGame *state, uint8 *p) {
- vt.flags |= ANIMATED;
+ vt.flags |= fAnimated;
}
void cmdPlayerControl(AgiGame *state, uint8 *p) {
state->playerControl = true;
- state->viewTable[0].motion = MOTION_NORMAL;
+ state->viewTable[0].motion = kMotionNormal;
}
void cmdProgramControl(AgiGame *state, uint8 *p) {
@@ -1122,24 +1122,24 @@ void cmdProgramControl(AgiGame *state, uint8 *p) {
}
void cmdFollowEgo(AgiGame *state, uint8 *p) {
- vt.motion = MOTION_FOLLOW_EGO;
+ vt.motion = kMotionFollowEgo;
vt.parm1 = p1 > vt.stepSize ? p1 : vt.stepSize;
vt.parm2 = p2;
vt.parm3 = 0xff;
if (getVersion() < 0x2000) {
_v[p2] = 0;
- vt.flags |= UPDATE | ANIMATED;
+ vt.flags |= fUpdate | fAnimated;
} else {
setflag(p2, false);
- vt.flags |= UPDATE;
+ vt.flags |= fUpdate;
}
}
void cmdMoveObj(AgiGame *state, uint8 *p) {
// _D (_D_WARN "o=%d, x=%d, y=%d, s=%d, f=%d", p0, p1, p2, p3, p4);
- vt.motion = MOTION_MOVE_OBJ;
+ vt.motion = kMotionMoveObj;
vt.parm1 = p1;
vt.parm2 = p2;
vt.parm3 = vt.stepSize;
@@ -1150,10 +1150,10 @@ void cmdMoveObj(AgiGame *state, uint8 *p) {
if (getVersion() < 0x2000) {
_v[p4] = 0;
- vt.flags |= UPDATE | ANIMATED;
+ vt.flags |= fUpdate | fAnimated;
} else {
setflag(p4, false);
- vt.flags |= UPDATE;
+ vt.flags |= fUpdate;
}
if (p0 == 0)
@@ -1165,7 +1165,7 @@ void cmdMoveObj(AgiGame *state, uint8 *p) {
}
void cmdMoveObjF(AgiGame *state, uint8 *p) {
- vt.motion = MOTION_MOVE_OBJ;
+ vt.motion = kMotionMoveObj;
vt.parm1 = _v[p1];
vt.parm2 = _v[p2];
vt.parm3 = vt.stepSize;
@@ -1175,7 +1175,7 @@ void cmdMoveObjF(AgiGame *state, uint8 *p) {
vt.stepSize = _v[p3];
setflag(p4, false);
- vt.flags |= UPDATE;
+ vt.flags |= fUpdate;
if (p0 == 0)
state->playerControl = false;
@@ -1189,11 +1189,11 @@ void cmdWander(AgiGame *state, uint8 *p) {
if (p0 == 0)
state->playerControl = false;
- vt.motion = MOTION_WANDER;
+ vt.motion = kMotionWander;
if (getVersion() < 0x2000) {
- vt.flags |= UPDATE | ANIMATED;
+ vt.flags |= fUpdate | fAnimated;
} else {
- vt.flags |= UPDATE;
+ vt.flags |= fUpdate;
}
}
@@ -1357,7 +1357,7 @@ void cmdDistance(AgiGame *state, uint8 *p) {
VtEntry *v0 = &state->viewTable[p0];
VtEntry *v1 = &state->viewTable[p1];
- if (v0->flags & DRAWN && v1->flags & DRAWN) {
+ if (v0->flags & fDrawn && v1->flags & fDrawn) {
x1 = v0->xPos + v0->xSize / 2;
y1 = v0->yPos;
x2 = v1->xPos + v1->xSize / 2;
diff --git a/engines/agi/op_test.cpp b/engines/agi/op_test.cpp
index bc711652f9..a44c68e0fc 100644
--- a/engines/agi/op_test.cpp
+++ b/engines/agi/op_test.cpp
@@ -188,7 +188,7 @@ void condUnknown13(AgiGame *state, uint8 *p) {
// This command is used at least in the Amiga version of Gold Rush! v2.05 1989-03-09
// (AGI 2.316) in logics 1, 3, 5, 6, 137 and 192 (Logic.192 revealed this command's nature).
// TODO: Check this command's implementation using disassembly just to be sure.
- int ec = state->viewTable[0].flags & ADJ_EGO_XY;
+ int ec = state->viewTable[0].flags & fAdjEgoXY;
debugC(7, kDebugLevelScripts, "op_test: in.motion.using.mouse = %s (Amiga-specific testcase 19)", ec ? "true" : "false");
state->testResult = ec;
}
diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index f0d976bbbb..28dd0a53dd 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -474,8 +474,8 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
v->cycleTimeCount = in->readByte();
v->direction = in->readByte();
- v->motion = in->readByte();
- v->cycle = in->readByte();
+ v->motion = (MotionType)in->readByte();
+ v->cycle = (CycleType)in->readByte();
v->priority = in->readByte();
v->flags = in->readUint16BE();
diff --git a/engines/agi/sprite.cpp b/engines/agi/sprite.cpp
index ea0b07f4da..cb081065de 100644
--- a/engines/agi/sprite.cpp
+++ b/engines/agi/sprite.cpp
@@ -257,7 +257,7 @@ bool SpritesMgr::testUpdating(VtEntry *v, AgiEngine *agi) {
if (~agi->_game.dirView[v->currentView].flags & RES_LOADED)
return false;
- return (v->flags & (ANIMATED | UPDATE | DRAWN)) == (ANIMATED | UPDATE | DRAWN);
+ return (v->flags & (fAnimated | fUpdate | fDrawn)) == (fAnimated | fUpdate | fDrawn);
}
/**
@@ -268,7 +268,7 @@ bool SpritesMgr::testNotUpdating(VtEntry *v, AgiEngine *vm) {
if (~vm->_game.dirView[v->currentView].flags & RES_LOADED)
return false;
- return (v->flags & (ANIMATED | UPDATE | DRAWN)) == (ANIMATED | DRAWN);
+ return (v->flags & (fAnimated | fUpdate | fDrawn)) == (fAnimated | fDrawn);
}
/**
@@ -332,7 +332,7 @@ void SpritesMgr::buildList(SpriteList &l, bool (*test)(VtEntry *, AgiEngine *))
for (v = _vm->_game.viewTable; v < &_vm->_game.viewTable[MAX_VIEWTABLE]; v++) {
if ((*test)(v, _vm)) {
entry[i] = v;
- yVal[i] = v->flags & FIXED_PRIORITY ? prioToY(v->priority) : v->yPos;
+ yVal[i] = v->flags & fFixedPriority ? prioToY(v->priority) : v->yPos;
i++;
}
}
@@ -407,13 +407,13 @@ void SpritesMgr::commitSprites(SpriteList &l, bool immediate) {
continue;
if (s->v->xPos == s->v->xPos2 && s->v->yPos == s->v->yPos2) {
- s->v->flags |= DIDNT_MOVE;
+ s->v->flags |= fDidntMove;
continue;
}
s->v->xPos2 = s->v->xPos;
s->v->yPos2 = s->v->yPos;
- s->v->flags &= ~DIDNT_MOVE;
+ s->v->flags &= ~fDidntMove;
}
}
diff --git a/engines/agi/view.cpp b/engines/agi/view.cpp
index 956d398fb4..3f3686561e 100644
--- a/engines/agi/view.cpp
+++ b/engines/agi/view.cpp
@@ -47,7 +47,7 @@ void AgiEngine::lSetCel(VtEntry *v, int n) {
// in the KQ4 introduction
// It seems there's either a bug with KQ4's logic script 120 (the intro script)
// or flag 64 is not set correctly, which causes the erroneous behavior from the actors
- if (getGameID() == GID_KQ4 && !(v->flags & UPDATE) && (v->currentView == 172))
+ if (getGameID() == GID_KQ4 && !(v->flags & fUpdate) && (v->currentView == 172))
return;
currentVc = &currentVl->cel[n];
@@ -78,8 +78,8 @@ void AgiEngine::lSetLoop(VtEntry *v, int n) {
void AgiEngine::updateView(VtEntry *v) {
int cel, lastCel;
- if (v->flags & DONTUPDATE) {
- v->flags &= ~DONTUPDATE;
+ if (v->flags & fDontupdate) {
+ v->flags &= ~fDontupdate;
return;
}
@@ -87,32 +87,32 @@ void AgiEngine::updateView(VtEntry *v) {
lastCel = v->numCels - 1;
switch (v->cycle) {
- case CYCLE_NORMAL:
+ case kCycleNormal:
if (++cel > lastCel)
cel = 0;
break;
- case CYCLE_END_OF_LOOP:
+ case kCycleEndOfLoop:
if (cel < lastCel) {
debugC(5, kDebugLevelResources, "cel %d (last = %d)", cel + 1, lastCel);
if (++cel != lastCel)
break;
}
setflag(v->parm1, true);
- v->flags &= ~CYCLING;
+ v->flags &= ~fCycling;
v->direction = 0;
- v->cycle = CYCLE_NORMAL;
+ v->cycle = kCycleNormal;
break;
- case CYCLE_REV_LOOP:
+ case kCycleRevLoop:
if (cel) {
if (--cel)
break;
}
setflag(v->parm1, true);
- v->flags &= ~CYCLING;
+ v->flags &= ~fCycling;
v->direction = 0;
- v->cycle = CYCLE_NORMAL;
+ v->cycle = kCycleNormal;
break;
- case CYCLE_REVERSE:
+ case kCycleReverse:
if (cel == 0) {
cel = lastCel;
} else {
@@ -259,20 +259,20 @@ void AgiEngine::setCel(VtEntry *v, int n) {
*/
void AgiEngine::clipViewCoordinates(VtEntry *v) {
if (v->xPos + v->xSize > _WIDTH) {
- v->flags |= UPDATE_POS;
+ v->flags |= fUpdatePos;
v->xPos = _WIDTH - v->xSize;
}
if (v->yPos - v->ySize + 1 < 0) {
- v->flags |= UPDATE_POS;
+ v->flags |= fUpdatePos;
v->yPos = v->ySize - 1;
}
- if (v->yPos <= _game.horizon && (~v->flags & IGNORE_HORIZON)) {
- v->flags |= UPDATE_POS;
+ if (v->yPos <= _game.horizon && (~v->flags & fIgnoreHorizon)) {
+ v->flags |= fUpdatePos;
v->yPos = _game.horizon + 1;
}
if (getVersion() < 0x2000) {
- v->flags |= DONTUPDATE;
+ v->flags |= fDontupdate;
}
}
@@ -313,10 +313,10 @@ void AgiEngine::setView(VtEntry *v, int n) {
* @param v pointer to view table entry
*/
void AgiEngine::startUpdate(VtEntry *v) {
- if (~v->flags & UPDATE) {
+ if (~v->flags & fUpdate) {
_sprites->eraseBoth();
- v->flags |= UPDATE;
+ v->flags |= fUpdate;
_sprites->blitBoth();
_sprites->commitBoth();
}
@@ -327,10 +327,10 @@ void AgiEngine::startUpdate(VtEntry *v) {
* @param v pointer to view table entry
*/
void AgiEngine::stopUpdate(VtEntry *v) {
- if (v->flags & UPDATE) {
+ if (v->flags & fUpdate) {
_sprites->eraseBoth();
- v->flags &= ~UPDATE;
+ v->flags &= ~fUpdate;
_sprites->blitBoth();
_sprites->commitBoth();
}
@@ -357,14 +357,14 @@ void AgiEngine::updateViewtable() {
i = 0;
for (v = _game.viewTable; v < &_game.viewTable[MAX_VIEWTABLE]; v++) {
- if ((v->flags & (ANIMATED | UPDATE | DRAWN)) != (ANIMATED | UPDATE | DRAWN)) {
+ if ((v->flags & (fAnimated | fUpdate | fDrawn)) != (fAnimated | fUpdate | fDrawn)) {
continue;
}
i++;
loop = 4;
- if (~v->flags & FIX_LOOP) {
+ if (~v->flags & fFixLoop) {
switch (v->numLoops) {
case 2:
case 3:
@@ -389,7 +389,7 @@ void AgiEngine::updateViewtable() {
}
}
- if (~v->flags & CYCLING)
+ if (~v->flags & fCycling)
continue;
if (v->cycleTimeCount == 0)
@@ -406,7 +406,7 @@ void AgiEngine::updateViewtable() {
updatePosition();
_sprites->blitUpdSprites();
_sprites->commitUpdSprites();
- _game.viewTable[0].flags &= ~(ON_WATER | ON_LAND);
+ _game.viewTable[0].flags &= ~(fOnWater | fOnLand);
}
}
diff --git a/engines/agi/view.h b/engines/agi/view.h
index 0ef443f8e5..5cf59d7df5 100644
--- a/engines/agi/view.h
+++ b/engines/agi/view.h
@@ -50,6 +50,39 @@ struct AgiView {
uint8 *rdata;
};
+enum MotionType {
+ kMotionNormal = 0,
+ kMotionWander = 1,
+ kMotionFollowEgo = 2,
+ kMotionMoveObj = 3
+};
+
+enum CycleType {
+ kCycleNormal = 0,
+ kCycleEndOfLoop = 1,
+ kCycleRevLoop = 2,
+ kCycleReverse = 3
+ };
+
+enum ViewFlags {
+ fDrawn = (1 << 0),
+ fIgnoreBlocks = (1 << 1),
+ fFixedPriority = (1 << 2),
+ fIgnoreHorizon = (1 << 3),
+ fUpdate = (1 << 4),
+ fCycling = (1 << 5),
+ fAnimated = (1 << 6),
+ fMotion = (1 << 7),
+ fOnWater = (1 << 8),
+ fIgnoreObjects = (1 << 9),
+ fUpdatePos = (1 << 10),
+ fOnLand = (1 << 11),
+ fDontupdate = (1 << 12),
+ fFixLoop = (1 << 13),
+ fDidntMove = (1 << 14),
+ fAdjEgoXY = (1 << 15)
+};
+
/**
* AGI view table entry
*/
@@ -78,39 +111,10 @@ struct VtEntry {
uint8 cycleTime;
uint8 cycleTimeCount;
uint8 direction;
-
-#define MOTION_NORMAL 0
-#define MOTION_WANDER 1
-#define MOTION_FOLLOW_EGO 2
-#define MOTION_MOVE_OBJ 3
- uint8 motion;
-
-#define CYCLE_NORMAL 0
-#define CYCLE_END_OF_LOOP 1
-#define CYCLE_REV_LOOP 2
-#define CYCLE_REVERSE 3
- uint8 cycle;
-
+ MotionType motion;
+ CycleType cycle;
uint8 priority;
-
-#define DRAWN 0x0001
-#define IGNORE_BLOCKS 0x0002
-#define FIXED_PRIORITY 0x0004
-#define IGNORE_HORIZON 0x0008
-#define UPDATE 0x0010
-#define CYCLING 0x0020
-#define ANIMATED 0x0040
-#define MOTION 0x0080
-#define ON_WATER 0x0100
-#define IGNORE_OBJECTS 0x0200
-#define UPDATE_POS 0x0400
-#define ON_LAND 0x0800
-#define DONTUPDATE 0x1000
-#define FIX_LOOP 0x2000
-#define DIDNT_MOVE 0x4000
-#define ADJ_EGO_XY 0x8000
uint16 flags;
-
uint8 parm1;
uint8 parm2;
uint8 parm3;