diff options
Diffstat (limited to 'queen')
-rw-r--r-- | queen/cutaway.cpp | 2 | ||||
-rw-r--r-- | queen/logic.cpp | 158 | ||||
-rw-r--r-- | queen/logic.h | 13 | ||||
-rw-r--r-- | queen/walk.cpp | 157 | ||||
-rw-r--r-- | queen/walk.h | 20 | ||||
-rw-r--r-- | queen/xref.txt | 4 |
6 files changed, 177 insertions, 177 deletions
diff --git a/queen/cutaway.cpp b/queen/cutaway.cpp index bd319c9b73..d70da67214 100644 --- a/queen/cutaway.cpp +++ b/queen/cutaway.cpp @@ -966,7 +966,7 @@ void Cutaway::goToFinalRoom() { joeBob->x = joeX; joeBob->y = joeY; joeBob->scale = _logic->findScale(joeX, joeY); - _walk->joeFace(); + _logic->joeFace(); } } diff --git a/queen/logic.cpp b/queen/logic.cpp index cbe3a4011b..ec3d206c12 100644 --- a/queen/logic.cpp +++ b/queen/logic.cpp @@ -295,7 +295,7 @@ void Logic::initialise() { _graphics->panelLoad(); _graphics->bobSetupControl(); - _walk->joeSetup(); + joeSetup(); zoneSetupPanel(); memset(_zones, 0, sizeof(_zones)); @@ -581,6 +581,10 @@ void Logic::joeScale(uint16 scale) { _joe.scale = scale; } +void Logic::joePrevFacing(uint16 dir) { + _joe.prevFacing = dir; +} + int16 Logic::gameState(int index) { if (index >= 0 && index < GAME_STATE_COUNT) return _gameState[index]; @@ -949,7 +953,7 @@ void Logic::roomDisplay(const char* room, RoomDisplayMode mode, uint16 scale, in zoneSetup(); ObjectData *pod = NULL; if (mode != RDM_FADE_NOJOE) { - pod = _walk->joeSetupInRoom(mode != RDM_FADE_JOE_XY, scale); + pod = joeSetupInRoom(mode != RDM_FADE_JOE_XY, scale); } if (mode != RDM_NOFADE_JOE) { _graphics->update(); @@ -1218,5 +1222,155 @@ StateDirection Logic::findStateDirection(uint16 state) { } +void Logic::joeSetup() { + int i; + + _graphics->bankLoad("joe_a.BBK", 13); + for (i = 11; i <= 28 + FRAMES_JOE_XTRA; ++i) { + _graphics->bankUnpack(i - 10, i, 13); + } + _graphics->bankErase(13); + + _graphics->bankLoad("joe_b.BBK", 7); + _graphics->bankUnpack(1, 33 + FRAMES_JOE_XTRA, 7); + _graphics->bankUnpack(3, 34 + FRAMES_JOE_XTRA, 7); + _graphics->bankUnpack(5, 35 + FRAMES_JOE_XTRA, 7); + + _joe.facing = DIR_FRONT; +} + + +ObjectData *Logic::joeSetupInRoom(bool autoPosition, uint16 scale) { + // queen.c SETUP_HERO() + + uint16 oldx; + uint16 oldy; + WalkOffData *pwo = NULL; + ObjectData *pod = &_objectData[_entryObj]; + if (pod == NULL) { + error("Logic::joeSetupInRoom() - No object data for obj %d", _entryObj); + } + + if (!autoPosition || _joe.x != 0 || _joe.y != 0) { + oldx = _joe.x; + oldy = _joe.y; + } + else { + // find the walk off point for the entry object and make + // Joe walking to that point + pwo = walkOffPointForObject(_entryObj); + if (pwo != NULL) { + oldx = pwo->x; + oldy = pwo->y; + } + else { + // no walk off point, use object position + oldx = pod->x; + oldy = pod->y; + } + } + + debug(9, "Logic::joeSetupInRoom() - oldx=%d, oldy=%d", oldx, oldy); + + if (scale > 0 && scale < 100) { + _joe.scale = scale; + } + else { + uint16 a = zoneInArea(ZONE_ROOM, oldx, oldy); + if (a > 0) { + _joe.scale = currentRoomArea(a)->calcScale(oldy); + } + else { + _joe.scale = 100; + } + } + + // TODO: cutawayJoeFacing + + // check to see which way Joe entered room + switch (findStateDirection(pod->state)) { + case STATE_DIR_FRONT: + _joe.facing = DIR_FRONT; + break; + case STATE_DIR_BACK: + _joe.facing = DIR_BACK; + break; + case STATE_DIR_LEFT: + _joe.facing = DIR_LEFT; + break; + case STATE_DIR_RIGHT: + _joe.facing = DIR_RIGHT; + break; + } + + _joe.prevFacing = _joe.facing; + BobSlot *pbs = _graphics->bob(0); + pbs->scale = _joe.scale; + + // TODO: room 108 specific + + joeFace(); + pbs->active = true; + pbs->x = oldx; + pbs->y = oldy; + pbs->frameNum = 29 + FRAMES_JOE_XTRA; + _joe.x = 0; + _joe.y = 0; + + if (pwo != NULL) { + // entryObj has a walk off point, then walk from there to object x,y + return pod; + } + return NULL; +} + + +uint16 Logic::joeFace() { + + debug(9, "Logic::joeFace() - curFace = %d, prevFace = %d", _joe.facing, _joe.prevFacing); + BobSlot *pbs = _graphics->bob(0); + uint16 frame; + if (_currentRoom == 108) { + frame = 1; + } + else { + frame = 33; + if (_joe.facing == DIR_FRONT) { + if (_joe.prevFacing == DIR_BACK) { + pbs->frameNum = 33 + FRAMES_JOE_XTRA; + _graphics->update(); + } + frame = 34; + } + else if (_joe.facing == DIR_BACK) { + if (_joe.prevFacing == DIR_FRONT) { + pbs->frameNum = 33 + FRAMES_JOE_XTRA; + _graphics->update(); + } + frame = 35; + } + else if ((_joe.facing == DIR_LEFT && _joe.prevFacing == DIR_RIGHT) + || (_joe.facing == DIR_RIGHT && _joe.prevFacing == DIR_LEFT)) { + pbs->frameNum = 34 + FRAMES_JOE_XTRA; + _graphics->update(); + } + pbs->frameNum = frame + FRAMES_JOE_XTRA; + pbs->scale = _joe.scale; + pbs->xflip = (_joe.facing == DIR_LEFT); + _graphics->update(); + _joe.prevFacing = _joe.facing; + switch (frame) { + case 33: frame = 1; break; + case 34: frame = 3; break; + case 35: frame = 5; break; + } + } + pbs->frameNum = 29 + FRAMES_JOE_XTRA; + _graphics->bankUnpack(frame, pbs->frameNum, 7); + return frame; +} + + + } // End of namespace Queen diff --git a/queen/logic.h b/queen/logic.h index 85fd2364b3..05ecd96105 100644 --- a/queen/logic.h +++ b/queen/logic.h @@ -79,12 +79,14 @@ public: uint16 joeY() { return _joe.y; } uint16 joeWalk() { return _joe.walk; } uint16 joeScale() { return _joe.scale; } + uint16 joePrevFacing() { return _joe.prevFacing; } void joeFacing(uint16 dir); void joeX(uint16 x); void joeY(uint16 y); void joeWalk(uint16 walk); void joeScale(uint16 scale); + void joePrevFacing(uint16 dir); int16 gameState(int index); void gameState(int index, int16 newValue); @@ -124,6 +126,15 @@ public: StateDirection findStateDirection(uint16 state); // == FIND_STATE(state, "DIR"); + //! SETUP_JOE(), loads the various bobs needed to animate Joe + void joeSetup(); + + //! SETUP_HERO(), places Joe at the right place when entering a room + ObjectData *joeSetupInRoom(bool autoPosition, uint16 scale); + + //! FACE_JOE() + uint16 joeFace(); + protected: bool _textToggle; @@ -191,7 +202,7 @@ protected: struct { uint16 x, y; - uint16 facing; + uint16 facing, prevFacing; uint16 walk; uint16 scale; } _joe; diff --git a/queen/walk.cpp b/queen/walk.cpp index 270b80c3d9..2205f27b6f 100644 --- a/queen/walk.cpp +++ b/queen/walk.cpp @@ -57,59 +57,13 @@ Walk::Walk(Logic *logic, Graphics *graphics) } -uint16 Walk::joeFace() { - - debug(9, "Walk::joeFace() - curFace = %d, prevFace = %d", _logic->joeFacing(), _joePrevFacing); - BobSlot *pbs = _graphics->bob(0); - uint16 frame; - if (_logic->currentRoom() == 108) { - frame = 1; - } - else { - frame = 33; - if (_logic->joeFacing() == DIR_FRONT) { - if (_joePrevFacing == DIR_BACK) { - pbs->frameNum = 33 + FRAMES_JOE_XTRA; - _graphics->update(); - } - frame = 34; - } - else if (_logic->joeFacing() == DIR_BACK) { - if (_joePrevFacing == DIR_FRONT) { - pbs->frameNum = 33 + FRAMES_JOE_XTRA; - _graphics->update(); - } - frame = 35; - } - else if ((_logic->joeFacing() == DIR_LEFT && _joePrevFacing == DIR_RIGHT) - || (_logic->joeFacing() == DIR_RIGHT && _joePrevFacing == DIR_LEFT)) { - pbs->frameNum = 34 + FRAMES_JOE_XTRA; - _graphics->update(); - } - pbs->frameNum = frame + FRAMES_JOE_XTRA; - pbs->scale = _logic->joeScale(); - pbs->xflip = (_logic->joeFacing() == DIR_LEFT); - _graphics->update(); - _joePrevFacing = _logic->joeFacing(); - switch (frame) { - case 33: frame = 1; break; - case 34: frame = 3; break; - case 35: frame = 5; break; - } - } - pbs->frameNum = 29 + FRAMES_JOE_XTRA; - _graphics->bankUnpack(frame, pbs->frameNum, 7); - return frame; -} - - void Walk::joeMoveBlock(int facing) { warning("Walk::moveJoeBlock() partially implemented"); _graphics->bob(0)->animating = false; // CAN=-2; // Make Joe face the right direction _logic->joeFacing(facing); - joeFace(); + _logic->joeFace(); // TODO: cutaway calls } @@ -164,7 +118,7 @@ void Walk::animateJoe() { BobSlot *pbs = _graphics->bob(0); _logic->joeFacing(_walkData[1].anim.facing); _logic->joeScale(_walkData[1].area->calcScale(pbs->y)); - joeFace(); + _logic->joeFace(); bool interrupted = false; for (i = 1; i <= _walkDataCount && !interrupted; ++i) { @@ -345,107 +299,6 @@ void Walk::animatePerson(const MovePersonData *mpd, uint16 image, uint16 bobNum, } -void Walk::joeSetup() { - int i; - - _graphics->bankLoad("joe_a.BBK", 13); - for (i = 11; i <= 28 + FRAMES_JOE_XTRA; ++i) { - _graphics->bankUnpack(i - 10, i, 13); - } - _graphics->bankErase(13); - - _graphics->bankLoad("joe_b.BBK", 7); - _graphics->bankUnpack(1, 33 + FRAMES_JOE_XTRA, 7); - _graphics->bankUnpack(3, 34 + FRAMES_JOE_XTRA, 7); - _graphics->bankUnpack(5, 35 + FRAMES_JOE_XTRA, 7); - - _logic->joeFacing(DIR_FRONT); -} - - -ObjectData *Walk::joeSetupInRoom(bool autoPosition, uint16 scale) { - // queen.c SETUP_HERO() - - uint16 oldx; - uint16 oldy; - WalkOffData *pwo = NULL; - ObjectData *pod = _logic->objectData(_logic->entryObj()); - if (pod == NULL) { - error("Walk::joeSetupInRoom() - No object data for obj %d", _logic->entryObj()); - } - - if (!autoPosition || _logic->joeX() != 0 || _logic->joeY() != 0) { - oldx = _logic->joeX(); - oldy = _logic->joeY(); - } - else { - // find the walk off point for the entry object and make - // Joe walking to that point - pwo = _logic->walkOffPointForObject(_logic->entryObj()); - if (pwo != NULL) { - oldx = pwo->x; - oldy = pwo->y; - } - else { - // no walk off point, use object position - oldx = pod->x; - oldy = pod->y; - } - } - - debug(9, "Walk::joeSetupInRoom() - oldx=%d, oldy=%d", oldx, oldy); - - if (scale > 0 && scale < 100) { - _logic->joeScale(scale); - } - else { - uint16 area = _logic->zoneInArea(ZONE_ROOM, oldx, oldy); - if (area > 0) { - _logic->joeScale(_logic->currentRoomArea(area)->calcScale(oldy)); - } - else { - _logic->joeScale(100); - } - } - - // TODO: cutawayJoeFacing - - // check to see which way Joe entered room - switch (_logic->findStateDirection(pod->state)) { - case STATE_DIR_FRONT: - _logic->joeFacing(DIR_FRONT); - break; - case STATE_DIR_BACK: - _logic->joeFacing(DIR_BACK); - break; - case STATE_DIR_LEFT: - _logic->joeFacing(DIR_LEFT); - break; - case STATE_DIR_RIGHT: - _logic->joeFacing(DIR_RIGHT); - break; - } - - _joePrevFacing = _logic->joeFacing(); - BobSlot *pbs = _graphics->bob(0); - pbs->scale = _logic->joeScale(); - - // TODO: room 108 specific - - joeFace(); - pbs->active = true; - pbs->x = oldx; - pbs->y = oldy; - pbs->frameNum = 29 + FRAMES_JOE_XTRA; - _logic->joeX(0); - _logic->joeY(0); - - if (pwo != NULL) { - // entryObj has a walk off point, then walk from there to object x,y - return pod; - } - return NULL; -} void Walk::joeMove(int direction, uint16 endx, uint16 endy, bool inCutaway) { @@ -483,14 +336,16 @@ void Walk::joeMove(int direction, uint16 endx, uint16 endy, bool inCutaway) { if (direction > 0) { _logic->joeFacing(direction); } - _joePrevFacing = _logic->joeFacing(); - joeFace(); + _logic->joePrevFacing(_logic->joeFacing()); + _logic->joeFace(); } void Walk::personMove(const Person *pp, uint16 endx, uint16 endy, uint16 curImage, int direction) { + // TODO: room 69 specific + // CAN = 0; initWalkData(); diff --git a/queen/walk.h b/queen/walk.h index 3c80024c26..e5d79aea18 100644 --- a/queen/walk.h +++ b/queen/walk.h @@ -64,15 +64,6 @@ struct MovePersonData { uint16 moveSpeed; }; -/* -struct Person { - const char* name; - uint16 bobNum; // P_BOB - uint16 bankNum; // P_BANK - uint16 image; // MOVE_OTHER, CI arg - int direction; // MOVE_OTHER, dir arg -}; -*/ class Logic; class Graphics; @@ -82,18 +73,9 @@ public: Walk(Logic* logic, Graphics* graphics); - //! SETUP_JOE(), loads the various bobs needed to animate Joe - void joeSetup(); - - //! SETUP_HERO(), places Joe at the right place when entering a room - ObjectData *joeSetupInRoom(bool autoPosition, uint16 scale); - //! MOVE_JOE() void joeMove(int direction, uint16 endx, uint16 endy, bool inCutaway); - //! FACE_JOE() - uint16 joeFace(); - //! MOVE_OTHER void personMove(const Person *pp, uint16 endx, uint16 endy, uint16 curImage, int direction); @@ -134,8 +116,6 @@ private: static const MovePersonData _moveData[]; - uint16 _joePrevFacing; - uint16 _walkDataCount; WalkData _walkData[16]; diff --git a/queen/xref.txt b/queen/xref.txt index dd469d6232..f76bff9751 100644 --- a/queen/xref.txt +++ b/queen/xref.txt @@ -126,7 +126,7 @@ SELECT_VERB() SETUP_BOBS() Graphics::bobSetupControl SETUP_FURNITURE() Logic::roomSetupFurniture SETUP_ITEMS() -SETUP_JOE() Walk::joeSetup +SETUP_JOE() Logic::joeSetup SETUP_ROOM() SETUP_SCRVARS() update() Graphics::update @@ -269,7 +269,7 @@ CALC_WALK() Walk::incWalkData CALC_X() Walk::calcC CALC_Y() Walk::calcC CALCSCALE() Area::calcScale -FACE_JOE() Walk::joeFace +FACE_JOE() Logic::joeFace FIND_FREE_AREA Walk::findFreeArea FIND_NEWP() Walk::findAreaPosition FIND_OLDP() Walk::findAreaPosition |