diff options
author | Gregory Montoir | 2004-01-22 22:28:57 +0000 |
---|---|---|
committer | Gregory Montoir | 2004-01-22 22:28:57 +0000 |
commit | 99e3175d548d5dce704aaedab9ed291a4b365dae (patch) | |
tree | cc1186fa37405b2bccb3b483390100e6edf591a0 | |
parent | 90b96a94abeb8ee02d5468f9088a23174a0ccc60 (diff) | |
download | scummvm-rg350-99e3175d548d5dce704aaedab9ed291a4b365dae.tar.gz scummvm-rg350-99e3175d548d5dce704aaedab9ed291a4b365dae.tar.bz2 scummvm-rg350-99e3175d548d5dce704aaedab9ed291a4b365dae.zip |
(slightly) less hackish bounding box code
svn-id: r12576
-rw-r--r-- | queen/cutaway.cpp | 19 | ||||
-rw-r--r-- | queen/graphics.cpp | 49 | ||||
-rw-r--r-- | queen/graphics.h | 7 | ||||
-rw-r--r-- | queen/logic.cpp | 6 | ||||
-rw-r--r-- | queen/structs.h | 12 | ||||
-rw-r--r-- | queen/talk.cpp | 2 |
6 files changed, 32 insertions, 63 deletions
diff --git a/queen/cutaway.cpp b/queen/cutaway.cpp index c9fc931061..c5e811598e 100644 --- a/queen/cutaway.cpp +++ b/queen/cutaway.cpp @@ -503,21 +503,9 @@ byte *Cutaway::getCutawayAnim(byte *ptr, int header, CutawayAnim &anim) { if (0 == header) { anim.object = 0; anim.originalFrame = 29 + FRAMES_JOE_XTRA; - - // 21/9/94, Make sure that bobs are clipped on 150 screens - if (_vm->display()->fullscreen()) - _vm->graphics()->bob(0)->box.y2 = 199; } else { - //warning("Stuff not yet implemented in Cutaway::getCutawayAnim()"); - anim.object = _vm->logic()->findBob(header); - - // If fullscreen cutaway then clip to 199 down - - // 21/9/94, Make sure that bobs are clipped on 150 screens - // XXX if(COMPANEL==2 && OBJ_CUT[6]<=0 && BDyres==200) bobs[Param].y2=199; - anim.originalFrame = _vm->logic()->findFrame(header); } @@ -1026,13 +1014,6 @@ void Cutaway::run(char *nextFilename) { joeBob->animating = 0; joeBob->moving = 0; - if (_vm->resource()->isInterview()) { - _vm->graphics()->bob(20)->box.y2 = 149; - _vm->graphics()->bob(21)->box.y2 = 149; - _vm->graphics()->bob(22)->box.y2 = 149; - } - // Make sure Joe is clipped! - joeBob->box.y2 = 149; _vm->input()->cutawayRunning(false); _vm->input()->cutawayQuitReset(); diff --git a/queen/graphics.cpp b/queen/graphics.cpp index 834e8d9952..a5ec6c6c9b 100644 --- a/queen/graphics.cpp +++ b/queen/graphics.cpp @@ -32,6 +32,8 @@ namespace Queen { +const Box BobSlot::_defaultBox(-1, -1, -1, -1); + void BobSlot::curPos(int16 xx, int16 yy) { active = true; x = xx; @@ -163,18 +165,18 @@ void BobSlot::animNormal(uint16 firstFrame, uint16 lastFrame, uint16 spd, bool r void BobSlot::clear() { active = false; - xflip = false; + xflip = false; animating = false; anim.string.buffer = NULL; moving = false; - scale = 100; - box.x1 = 0; - box.y1 = 0; - box.x2 = GAME_SCREEN_WIDTH - 1; - box.y2 = ROOM_ZONE_HEIGHT - 1; + scale = 100; + box = _defaultBox; } +const Box Graphics::_gameScreenBox(0, 0, GAME_SCREEN_WIDTH - 1, ROOM_ZONE_HEIGHT - 1); +const Box Graphics::_fullScreenBox(0, 0, GAME_SCREEN_WIDTH - 1, GAME_SCREEN_HEIGHT - 1); + Graphics::Graphics(QueenEngine *vm) : _cameraBob(0), _vm(vm) { memset(_bobs, 0, sizeof(_bobs)); @@ -200,7 +202,7 @@ void Graphics::setupMouseCursor() { _vm->display()->setMouseCursor(bf->data, bf->width, bf->height); } -void Graphics::drawBob(const BobSlot *bs, const BobFrame *bf, int16 x, int16 y) { +void Graphics::drawBob(const BobSlot *bs, const BobFrame *bf, const Box *bbox, int16 x, int16 y) { debug(9, "Graphics::drawBob(%d, %d, %d)", bs->frameNum, x, y); uint16 w, h; @@ -211,7 +213,7 @@ void Graphics::drawBob(const BobSlot *bs, const BobFrame *bf, int16 x, int16 y) w = bf->width; h = bf->height; - const Box *box = &bs->box; + const Box *box = (bs->box == BobSlot::_defaultBox) ? bbox : &bs->box; if(w != 0 && h != 0 && box->intersects(x, y, w, h)) { uint8 *src = bf->data; @@ -315,9 +317,6 @@ void Graphics::shrinkFrame(const BobFrame *bf, uint16 percentage) { void Graphics::clearBob(uint32 bobNum) { BobSlot *pbs = bob(bobNum); pbs->clear(); - if (_vm->display()->fullscreen()) { - pbs->box.y2 = GAME_SCREEN_HEIGHT - 1; - } } void Graphics::sortBobs() { @@ -362,8 +361,8 @@ void Graphics::sortBobs() { } void Graphics::drawBobs() { - int i; - for (i = 0; i < _sortedBobsCount; ++i) { + const Box *bobBox = _vm->display()->fullscreen() ? &_fullScreenBox : &_gameScreenBox; + for (int i = 0; i < _sortedBobsCount; ++i) { BobSlot *pbs = _sortedBobs[i]; if (pbs->active) { @@ -387,7 +386,7 @@ void Graphics::drawBobs() { x = pbs->x - xh - _vm->display()->horizontalScroll(); y = pbs->y - yh; - drawBob(pbs, pbf, x, y); + drawBob(pbs, pbf, bobBox, x, y); } } } @@ -524,7 +523,6 @@ void Graphics::setBobText( } void Graphics::handleParallax(uint16 roomNum) { - int i; uint16 screenScroll = _vm->display()->horizontalScroll(); switch (roomNum) { case ROOM_AMAZON_HIDEOUT: @@ -543,27 +541,10 @@ void Graphics::handleParallax(uint16 roomNum) { case ROOM_VALLEY_CARCASS: _bobs[5].x = 600 - screenScroll / 2; break; - case ROOM_HOTEL_LOBBY: - if(_vm->display()->fullscreen()) { - for(i = 1; i <= 3; ++i) { - _bobs[i].box.y2 = 199; - } - _bobs[24].box.y2 = 199; - } - break; case ROOM_UNUSED_INTRO_1: _bobs[5].x = 340 - screenScroll / 2; _bobs[6].x = 50 - screenScroll / 2; _bobs[7].x = 79 - screenScroll / 2; - for(i = 1; i <= 8; ++i) { - _bobs[i].box.y2 = 199; - } - _bobs[20].box.y2 = 199; - break; - case ROOM_UNUSED_INTRO_5: - for(i = 0; i < 3; ++i) { - _bobs[i].box.y2 = 199; - } break; case ROOM_CAR_CHASE: _vm->bam()->updateCarAnimation(); @@ -591,7 +572,7 @@ void Graphics::handleParallax(uint16 roomNum) { } void Graphics::setupNewRoom(const char *room, uint16 roomNum, int16 *furniture, uint16 furnitureCount) { - // reset sprites table (bounding box...) + // reset sprites table clearBobs(); // load/setup objects associated to this room @@ -1003,8 +984,6 @@ void Graphics::setupRoomObjects() { ++curImage; clearBob(curBob); - // XXX if((COMPANEL==2) && (FULLSCREEN==1)) bobs[CURRBOB].y2=199; - _vm->bankMan()->unpack(pgd->firstFrame, curImage, 15); ++_numFrames; if (pod->name > 0) { diff --git a/queen/graphics.h b/queen/graphics.h index 967657461b..46a86f5e9f 100644 --- a/queen/graphics.h +++ b/queen/graphics.h @@ -73,6 +73,8 @@ struct BobSlot { uint16 dx, dy; uint16 total; + static const Box _defaultBox; + void curPos(int16 xx, int16 yy); void move(int16 dstx, int16 dsty, int16 spd); void moveOneStep(); @@ -95,7 +97,7 @@ public: void unpackControlBank(); void setupMouseCursor(); - void drawBob(const BobSlot *bs, const BobFrame *bf, int16 x, int16 y); + void drawBob(const BobSlot *bs, const BobFrame *bf, const Box *box, int16 x, int16 y); void drawInventoryItem(uint32 frameNum, uint16 x, uint16 y); void pasteBob(uint16 objNum, uint16 image); void shrinkFrame(const BobFrame *bf, uint16 percentage); @@ -178,6 +180,9 @@ private: int _cameraBob; QueenEngine *_vm; + + static const Box _gameScreenBox; + static const Box _fullScreenBox; }; class BamScene { diff --git a/queen/logic.cpp b/queen/logic.cpp index 4ab3aaa865..4c034ffe87 100644 --- a/queen/logic.cpp +++ b/queen/logic.cpp @@ -1196,9 +1196,6 @@ void Logic::handlePinnacleRoom() { joe->frameNum = _vm->input()->mousePosX() / 36 + 43 + FRAMES_JOE_XTRA; - // adjust bounding box for fullscreen - joe->box.y2 = piton->box.y2 = GAME_SCREEN_HEIGHT - 1; - // bobs have been unpacked from animating objects, we don't need them // to animate anymore ; so turn animating off joe->animating = piton->animating = false; @@ -1483,7 +1480,6 @@ void Logic::asmMakeFrankGrowing() { BobSlot *bobFrank = _vm->graphics()->bob(5); bobFrank->frameNum = 38; bobFrank->curPos(160, 200); - bobFrank->box.y2 = GAME_SCREEN_HEIGHT - 1; int i; for (i = 10; i <= 100; i += 4) { @@ -1507,7 +1503,6 @@ void Logic::asmMakeRobotGrowing() { BobSlot *bobRobot = _vm->graphics()->bob(5); bobRobot->frameNum = 38; bobRobot->curPos(160, 200); - bobRobot->box.y2 = GAME_SCREEN_HEIGHT - 1; int i; for (i = 10; i <= 100; i += 4) { @@ -1694,7 +1689,6 @@ void Logic::asmMakeLightningHitPlane() { BobSlot *planeBob = _vm->graphics()->bob(5); BobSlot *lightningBob = _vm->graphics()->bob(20); - planeBob->box.y2 = lightningBob->box.y2 = 199; planeBob->y = 135; planeBob->scale = 20; diff --git a/queen/structs.h b/queen/structs.h index 1e2f1d2892..b0fba0d7fb 100644 --- a/queen/structs.h +++ b/queen/structs.h @@ -29,6 +29,14 @@ namespace Queen { struct Box { int16 x1, y1, x2, y2; + Box() + : x1(0), y1(0), x2(0), y2(0) { + } + + Box(int16 xx1, int16 yy1, int16 xx2, int16 yy2) + : x1(xx1), y1(yy1), x2(xx2), y2(yy2) { + } + void readFromBE(byte *&ptr) { x1 = (int16)READ_BE_UINT16(ptr); ptr += 2; y1 = (int16)READ_BE_UINT16(ptr); ptr += 2; @@ -58,6 +66,10 @@ struct Box { bool contains(int16 x, int16 y) const { return (x >= x1) && (x <= x2) && (y >= y1) && (y <= y2); } + + bool operator==(const Box &b) const { + return (x1 == b.x1) && (x2 == b.x2) && (y1 == b.y1) && (y2 == b.y2); + } }; diff --git a/queen/talk.cpp b/queen/talk.cpp index 1b5b4c00e9..099b5b9b5f 100644 --- a/queen/talk.cpp +++ b/queen/talk.cpp @@ -1305,13 +1305,11 @@ int16 Talk::selectSentence() { arrowBobUp->x = 303 + 8 + scrollX; arrowBobUp->y = 150 + 1; arrowBobUp->frameNum = 3; - arrowBobUp->box.y2 = 199; arrowBobUp->active = false; arrowBobDown->x = 303 + scrollX; arrowBobDown->y = 175; arrowBobDown->frameNum = 4; - arrowBobDown->box.y2 = 199; arrowBobDown->active = false; bool rezone = true; |