mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-20 19:21:46 +00:00
(slightly) less hackish bounding box code
svn-id: r12576
This commit is contained in:
parent
90b96a94ab
commit
99e3175d54
@ -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();
|
||||
|
@ -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) {
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user