diff options
author | Max Horn | 2010-02-05 22:55:18 +0000 |
---|---|---|
committer | Max Horn | 2010-02-05 22:55:18 +0000 |
commit | f86618f92be1350bf6e56573c2419e604c811548 (patch) | |
tree | 780ad7877423be3aa5d19dee510e187ba77f3477 /engines/sci/engine/kmovement.cpp | |
parent | 25a9df8a817de652a40d2cc48411310b081b5653 (diff) | |
download | scummvm-rg350-f86618f92be1350bf6e56573c2419e604c811548.tar.gz scummvm-rg350-f86618f92be1350bf6e56573c2419e604c811548.tar.bz2 scummvm-rg350-f86618f92be1350bf6e56573c2419e604c811548.zip |
SCI: Add a 'SELECTOR' macro
svn-id: r47918
Diffstat (limited to 'engines/sci/engine/kmovement.cpp')
-rw-r--r-- | engines/sci/engine/kmovement.cpp | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp index 6a2d468531..67fd835d67 100644 --- a/engines/sci/engine/kmovement.cpp +++ b/engines/sci/engine/kmovement.cpp @@ -157,8 +157,8 @@ reg_t kSetJump(EngineState *s, int argc, reg_t *argv) { debugC(2, kDebugLevelBresen, "SetJump for object at %04x:%04x", PRINT_REG(object)); debugC(2, kDebugLevelBresen, "xStep: %d, yStep: %d", vx, vy); - PUT_SEL32V(segMan, object, xStep, vx); - PUT_SEL32V(segMan, object, yStep, vy); + PUT_SEL32V(segMan, object, SELECTOR(xStep), vx); + PUT_SEL32V(segMan, object, SELECTOR(yStep), vy); return s->r_acc; } @@ -167,9 +167,9 @@ reg_t kSetJump(EngineState *s, int argc, reg_t *argv) { #define _K_BRESEN_AXIS_Y 1 static void initialize_bresen(SegManager *segMan, int argc, reg_t *argv, reg_t mover, int step_factor, int deltax, int deltay) { - reg_t client = GET_SEL32(segMan, mover, client); - int stepx = (int16)GET_SEL32V(segMan, client, xStep) * step_factor; - int stepy = (int16)GET_SEL32V(segMan, client, yStep) * step_factor; + reg_t client = GET_SEL32(segMan, mover, SELECTOR(client)); + int stepx = (int16)GET_SEL32V(segMan, client, SELECTOR(xStep)) * step_factor; + int stepy = (int16)GET_SEL32V(segMan, client, SELECTOR(yStep)) * step_factor; int numsteps_x = stepx ? (abs(deltax) + stepx - 1) / stepx : 0; int numsteps_y = stepy ? (abs(deltay) + stepy - 1) / stepy : 0; int bdi, i1; @@ -190,15 +190,15 @@ static void initialize_bresen(SegManager *segMan, int argc, reg_t *argv, reg_t m /* if (abs(deltax) > abs(deltay)) {*/ // Bresenham on y if (numsteps_y < numsteps_x) { - PUT_SEL32V(segMan, mover, b_xAxis, _K_BRESEN_AXIS_Y); - PUT_SEL32V(segMan, mover, b_incr, (deltay < 0) ? -1 : 1); + PUT_SEL32V(segMan, mover, SELECTOR(b_xAxis), _K_BRESEN_AXIS_Y); + PUT_SEL32V(segMan, mover, SELECTOR(b_incr), (deltay < 0) ? -1 : 1); //i1 = 2 * (abs(deltay) - abs(deltay_step * numsteps)) * abs(deltax_step); //bdi = -abs(deltax); i1 = 2 * (abs(deltay) - abs(deltay_step * (numsteps - 1))) * abs(deltax_step); bdi = -abs(deltax); } else { // Bresenham on x - PUT_SEL32V(segMan, mover, b_xAxis, _K_BRESEN_AXIS_X); - PUT_SEL32V(segMan, mover, b_incr, (deltax < 0) ? -1 : 1); + PUT_SEL32V(segMan, mover, SELECTOR(b_xAxis), _K_BRESEN_AXIS_X); + PUT_SEL32V(segMan, mover, SELECTOR(b_incr), (deltax < 0) ? -1 : 1); //i1= 2 * (abs(deltax) - abs(deltax_step * numsteps)) * abs(deltay_step); //bdi = -abs(deltay); i1 = 2 * (abs(deltax) - abs(deltax_step * (numsteps - 1))) * abs(deltay_step); @@ -206,26 +206,26 @@ static void initialize_bresen(SegManager *segMan, int argc, reg_t *argv, reg_t m } - PUT_SEL32V(segMan, mover, dx, deltax_step); - PUT_SEL32V(segMan, mover, dy, deltay_step); + PUT_SEL32V(segMan, mover, SELECTOR(dx), deltax_step); + PUT_SEL32V(segMan, mover, SELECTOR(dy), deltay_step); debugC(2, kDebugLevelBresen, "Init bresen for mover %04x:%04x: d=(%d,%d)", PRINT_REG(mover), deltax, deltay); debugC(2, kDebugLevelBresen, " steps=%d, mv=(%d, %d), i1= %d, i2=%d", numsteps, deltax_step, deltay_step, i1, bdi*2); - //PUT_SEL32V(segMan, mover, b_movCnt, numsteps); // Needed for HQ1/Ogre? - PUT_SEL32V(segMan, mover, b_di, bdi); - PUT_SEL32V(segMan, mover, b_i1, i1); - PUT_SEL32V(segMan, mover, b_i2, bdi * 2); + //PUT_SEL32V(segMan, mover, SELECTOR(b_movCnt), numsteps); // Needed for HQ1/Ogre? + PUT_SEL32V(segMan, mover, SELECTOR(b_di), bdi); + PUT_SEL32V(segMan, mover, SELECTOR(b_i1), i1); + PUT_SEL32V(segMan, mover, SELECTOR(b_i2), bdi * 2); } reg_t kInitBresen(EngineState *s, int argc, reg_t *argv) { SegManager *segMan = s->_segMan; reg_t mover = argv[0]; - reg_t client = GET_SEL32(segMan, mover, client); + reg_t client = GET_SEL32(segMan, mover, SELECTOR(client)); - int deltax = (int16)GET_SEL32V(segMan, mover, x) - (int16)GET_SEL32V(segMan, client, x); - int deltay = (int16)GET_SEL32V(segMan, mover, y) - (int16)GET_SEL32V(segMan, client, y); + int deltax = (int16)GET_SEL32V(segMan, mover, SELECTOR(x)) - (int16)GET_SEL32V(segMan, client, SELECTOR(x)); + int deltay = (int16)GET_SEL32V(segMan, mover, SELECTOR(y)) - (int16)GET_SEL32V(segMan, client, SELECTOR(y)); int step_factor = (argc < 1) ? argv[1].toUint16() : 1; initialize_bresen(s->_segMan, argc, argv, mover, step_factor, deltax, deltay); @@ -239,42 +239,42 @@ reg_t kInitBresen(EngineState *s, int argc, reg_t *argv) { reg_t kDoBresen(EngineState *s, int argc, reg_t *argv) { SegManager *segMan = s->_segMan; reg_t mover = argv[0]; - reg_t client = GET_SEL32(segMan, mover, client); + reg_t client = GET_SEL32(segMan, mover, SELECTOR(client)); - int x = (int16)GET_SEL32V(segMan, client, x); - int y = (int16)GET_SEL32V(segMan, client, y); + int x = (int16)GET_SEL32V(segMan, client, SELECTOR(x)); + int y = (int16)GET_SEL32V(segMan, client, SELECTOR(y)); int oldx, oldy, destx, desty, dx, dy, bdi, bi1, bi2, movcnt, bdelta, axis; - uint16 signal = GET_SEL32V(segMan, client, signal); + uint16 signal = GET_SEL32V(segMan, client, SELECTOR(signal)); int completed = 0; - int max_movcnt = GET_SEL32V(segMan, client, moveSpeed); + int max_movcnt = GET_SEL32V(segMan, client, SELECTOR(moveSpeed)); if (getSciVersion() > SCI_VERSION_01) signal &= ~kSignalHitObstacle; - PUT_SEL32(segMan, client, signal, make_reg(0, signal)); // This is a NOP for SCI0 + PUT_SEL32(segMan, client, SELECTOR(signal), make_reg(0, signal)); // This is a NOP for SCI0 oldx = x; oldy = y; - destx = (int16)GET_SEL32V(segMan, mover, x); - desty = (int16)GET_SEL32V(segMan, mover, y); - dx = (int16)GET_SEL32V(segMan, mover, dx); - dy = (int16)GET_SEL32V(segMan, mover, dy); - bdi = (int16)GET_SEL32V(segMan, mover, b_di); - bi1 = (int16)GET_SEL32V(segMan, mover, b_i1); - bi2 = (int16)GET_SEL32V(segMan, mover, b_i2); - movcnt = GET_SEL32V(segMan, mover, b_movCnt); - bdelta = (int16)GET_SEL32V(segMan, mover, b_incr); - axis = (int16)GET_SEL32V(segMan, mover, b_xAxis); + destx = (int16)GET_SEL32V(segMan, mover, SELECTOR(x)); + desty = (int16)GET_SEL32V(segMan, mover, SELECTOR(y)); + dx = (int16)GET_SEL32V(segMan, mover, SELECTOR(dx)); + dy = (int16)GET_SEL32V(segMan, mover, SELECTOR(dy)); + bdi = (int16)GET_SEL32V(segMan, mover, SELECTOR(b_di)); + bi1 = (int16)GET_SEL32V(segMan, mover, SELECTOR(b_i1)); + bi2 = (int16)GET_SEL32V(segMan, mover, SELECTOR(b_i2)); + movcnt = GET_SEL32V(segMan, mover, SELECTOR(b_movCnt)); + bdelta = (int16)GET_SEL32V(segMan, mover, SELECTOR(b_incr)); + axis = (int16)GET_SEL32V(segMan, mover, SELECTOR(b_xAxis)); //printf("movecnt %d, move speed %d\n", movcnt, max_movcnt); if (s->_features->handleMoveCount()) { if (max_movcnt > movcnt) { ++movcnt; - PUT_SEL32V(segMan, mover, b_movCnt, movcnt); // Needed for HQ1/Ogre? + PUT_SEL32V(segMan, mover, SELECTOR(b_movCnt), movcnt); // Needed for HQ1/Ogre? return NULL_REG; } else { movcnt = 0; - PUT_SEL32V(segMan, mover, b_movCnt, movcnt); // Needed for HQ1/Ogre? + PUT_SEL32V(segMan, mover, SELECTOR(b_movCnt), movcnt); // Needed for HQ1/Ogre? } } @@ -287,7 +287,7 @@ reg_t kDoBresen(EngineState *s, int argc, reg_t *argv) { dy += bdelta; } - PUT_SEL32V(segMan, mover, b_di, bdi); + PUT_SEL32V(segMan, mover, SELECTOR(b_di), bdi); x += dx; y += dy; @@ -309,8 +309,8 @@ reg_t kDoBresen(EngineState *s, int argc, reg_t *argv) { debugC(2, kDebugLevelBresen, "Finished mover %04x:%04x", PRINT_REG(mover)); } - PUT_SEL32V(segMan, client, x, x); - PUT_SEL32V(segMan, client, y, y); + PUT_SEL32V(segMan, client, SELECTOR(x), x); + PUT_SEL32V(segMan, client, SELECTOR(y), y); debugC(2, kDebugLevelBresen, "New data: (x,y)=(%d,%d), di=%d", x, y, bdi); @@ -322,11 +322,11 @@ reg_t kDoBresen(EngineState *s, int argc, reg_t *argv) { } if (!s->r_acc.offset) { // Contains the return value - signal = GET_SEL32V(segMan, client, signal); + signal = GET_SEL32V(segMan, client, SELECTOR(signal)); - PUT_SEL32V(segMan, client, x, oldx); - PUT_SEL32V(segMan, client, y, oldy); - PUT_SEL32V(segMan, client, signal, (signal | kSignalHitObstacle)); + PUT_SEL32V(segMan, client, SELECTOR(x), oldx); + PUT_SEL32V(segMan, client, SELECTOR(y), oldy); + PUT_SEL32V(segMan, client, SELECTOR(signal), (signal | kSignalHitObstacle)); debugC(2, kDebugLevelBresen, "Finished mover %04x:%04x by collision", PRINT_REG(mover)); completed = 1; @@ -377,15 +377,15 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { return NULL_REG; } - client = GET_SEL32(segMan, avoider, client); + client = GET_SEL32(segMan, avoider, SELECTOR(client)); if (!s->_segMan->isHeapObject(client)) { warning("DoAvoider() where client %04x:%04x is not an object", PRINT_REG(client)); return NULL_REG; } - looper = GET_SEL32(segMan, client, looper); - mover = GET_SEL32(segMan, client, mover); + looper = GET_SEL32(segMan, client, SELECTOR(looper)); + mover = GET_SEL32(segMan, client, SELECTOR(mover)); if (!s->_segMan->isHeapObject(mover)) { if (mover.segment) { @@ -394,8 +394,8 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { return s->r_acc; } - destx = GET_SEL32V(segMan, mover, x); - desty = GET_SEL32V(segMan, mover, y); + destx = GET_SEL32V(segMan, mover, SELECTOR(x)); + desty = GET_SEL32V(segMan, mover, SELECTOR(y)); debugC(2, kDebugLevelBresen, "Doing avoider %04x:%04x (dest=%d,%d)", PRINT_REG(avoider), destx, desty); @@ -404,7 +404,7 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { return NULL_REG; } - mover = GET_SEL32(segMan, client, mover); + mover = GET_SEL32(segMan, client, SELECTOR(mover)); if (!mover.segment) // Mover has been disposed? return s->r_acc; // Return gracefully. @@ -414,18 +414,18 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { return NULL_REG; } - dx = destx - GET_SEL32V(segMan, client, x); - dy = desty - GET_SEL32V(segMan, client, y); + dx = destx - GET_SEL32V(segMan, client, SELECTOR(x)); + dy = desty - GET_SEL32V(segMan, client, SELECTOR(y)); angle = getAngle(dx, dy); debugC(2, kDebugLevelBresen, "Movement (%d,%d), angle %d is %sblocked", dx, dy, angle, (s->r_acc.offset) ? " " : "not "); if (s->r_acc.offset) { // isBlocked() returned non-zero int rotation = (rand() & 1) ? 45 : (360 - 45); // Clockwise/counterclockwise - int oldx = GET_SEL32V(segMan, client, x); - int oldy = GET_SEL32V(segMan, client, y); - int xstep = GET_SEL32V(segMan, client, xStep); - int ystep = GET_SEL32V(segMan, client, yStep); + int oldx = GET_SEL32V(segMan, client, SELECTOR(x)); + int oldy = GET_SEL32V(segMan, client, SELECTOR(y)); + int xstep = GET_SEL32V(segMan, client, SELECTOR(xStep)); + int ystep = GET_SEL32V(segMan, client, SELECTOR(yStep)); int moves; debugC(2, kDebugLevelBresen, " avoider %04x:%04x", PRINT_REG(avoider)); @@ -434,8 +434,8 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { int move_x = (int)(sin(angle * PI / 180.0) * (xstep)); int move_y = (int)(-cos(angle * PI / 180.0) * (ystep)); - PUT_SEL32V(segMan, client, x, oldx + move_x); - PUT_SEL32V(segMan, client, y, oldy + move_y); + PUT_SEL32V(segMan, client, SELECTOR(x), oldx + move_x); + PUT_SEL32V(segMan, client, SELECTOR(y), oldy + move_y); debugC(2, kDebugLevelBresen, "Pos (%d,%d): Trying angle %d; delta=(%d,%d)", oldx, oldy, angle, move_x, move_y); @@ -445,12 +445,12 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { return NULL_REG; } - PUT_SEL32V(segMan, client, x, oldx); - PUT_SEL32V(segMan, client, y, oldy); + PUT_SEL32V(segMan, client, SELECTOR(x), oldx); + PUT_SEL32V(segMan, client, SELECTOR(y), oldy); if (s->r_acc.offset) { // We can be here debugC(2, kDebugLevelBresen, "Success"); - PUT_SEL32V(segMan, client, heading, angle); + PUT_SEL32V(segMan, client, SELECTOR(heading), angle); return make_reg(0, angle); } @@ -463,12 +463,12 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { warning("DoAvoider failed for avoider %04x:%04x", PRINT_REG(avoider)); } else { - int heading = GET_SEL32V(segMan, client, heading); + int heading = GET_SEL32V(segMan, client, SELECTOR(heading)); if (heading == -1) return s->r_acc; // No change - PUT_SEL32V(segMan, client, heading, angle); + PUT_SEL32V(segMan, client, SELECTOR(heading), angle); s->r_acc = make_reg(0, angle); |