aboutsummaryrefslogtreecommitdiff
path: root/queen/graphics.cpp
diff options
context:
space:
mode:
authorGregory Montoir2004-01-09 13:36:37 +0000
committerGregory Montoir2004-01-09 13:36:37 +0000
commit634df6923d644a5de603beb14c5f9720b5ff44fb (patch)
treeb44aebd45f697dfe1c448ee460f204e2fa7945ac /queen/graphics.cpp
parent93f3c0df348b77d284d66309e36d775df4765c99 (diff)
downloadscummvm-rg350-634df6923d644a5de603beb14c5f9720b5ff44fb.tar.gz
scummvm-rg350-634df6923d644a5de603beb14c5f9720b5ff44fb.tar.bz2
scummvm-rg350-634df6923d644a5de603beb14c5f9720b5ff44fb.zip
renamed some methods and moved some code to Display
svn-id: r12276
Diffstat (limited to 'queen/graphics.cpp')
-rw-r--r--queen/graphics.cpp244
1 files changed, 98 insertions, 146 deletions
diff --git a/queen/graphics.cpp b/queen/graphics.cpp
index 56f4813caa..14c56a00d8 100644
--- a/queen/graphics.cpp
+++ b/queen/graphics.cpp
@@ -196,25 +196,28 @@ Graphics::~Graphics() {
}
-void Graphics::bobSetupControl() {
+void Graphics::unpackControlBank() {
_vm->bankMan()->load("control.BBK",17);
_vm->bankMan()->unpack(1, 1, 17); // Mouse pointer
_vm->bankMan()->unpack(3, 3, 17); // Up arrow dialogue
_vm->bankMan()->unpack(4, 4, 17); // Down arrow dialogue
_vm->bankMan()->close(17);
+}
+
+void Graphics::setupMouseCursor() {
BobFrame *bf = _vm->bankMan()->fetchFrame(1);
_vm->display()->setMouseCursor(bf->data, bf->width, bf->height, bf->xhotspot, bf->yhotspot);
}
-void Graphics::bobDraw(const BobSlot *bs, int16 x, int16 y) {
- debug(9, "Graphics::bobDraw(%d, %d, %d)", bs->frameNum, x, y);
+void Graphics::drawBob(const BobSlot *bs, int16 x, int16 y) {
+ debug(9, "Graphics::drawBob(%d, %d, %d)", bs->frameNum, x, y);
uint16 w, h;
BobFrame *pbf = _vm->bankMan()->fetchFrame(bs->frameNum);
if (bs->scale < 100) {
- bobShrink(pbf, bs->scale);
+ shrinkFrame(pbf, bs->scale);
pbf = &_shrinkBuffer;
}
w = pbf->width;
@@ -262,7 +265,7 @@ void Graphics::bobDraw(const BobSlot *bs, int16 x, int16 y) {
}
-void Graphics::bobDrawInventoryItem(uint32 frameNum, uint16 x, uint16 y) {
+void Graphics::drawInventoryItem(uint32 frameNum, uint16 x, uint16 y) {
if (frameNum != 0) {
BobFrame *bf = _vm->bankMan()->fetchFrame(frameNum);
_vm->display()->drawInventoryItem(bf->data, x, y, bf->width, bf->height);
@@ -272,7 +275,7 @@ void Graphics::bobDrawInventoryItem(uint32 frameNum, uint16 x, uint16 y) {
}
-void Graphics::bobPaste(uint16 objNum, uint16 image) {
+void Graphics::pasteBob(uint16 objNum, uint16 image) {
GraphicData *pgd = _vm->logic()->graphicData(objNum);
_vm->bankMan()->unpack(pgd->firstFrame, image, 15);
BobFrame *bf = _vm->bankMan()->fetchFrame(image);
@@ -281,12 +284,12 @@ void Graphics::bobPaste(uint16 objNum, uint16 image) {
}
-void Graphics::bobShrink(const BobFrame *bf, uint16 percentage) {
+void Graphics::shrinkFrame(const BobFrame *bf, uint16 percentage) {
// computing new size, rounding to upper value
uint16 new_w = (bf->width * percentage + 50) / 100;
uint16 new_h = (bf->height * percentage + 50) / 100;
- debug(9, "Graphics::bobShrink() - scale = %d, bufsize = %d", percentage, new_w * new_h);
+ debug(9, "Graphics::shrinkFrame() - scale = %d, bufsize = %d", percentage, new_w * new_h);
if (new_w != 0 && new_h != 0) {
@@ -326,7 +329,7 @@ void Graphics::bobShrink(const BobFrame *bf, uint16 percentage) {
}
-void Graphics::bobClear(uint32 bobNum) {
+void Graphics::clearBob(uint32 bobNum) {
BobSlot *pbs = bob(bobNum);
pbs->clear();
if (_vm->display()->fullscreen()) {
@@ -335,7 +338,7 @@ void Graphics::bobClear(uint32 bobNum) {
}
-void Graphics::bobSortAll() {
+void Graphics::sortBobs() {
_sortedBobsCount = 0;
// animate/move the bobs
@@ -378,7 +381,7 @@ void Graphics::bobSortAll() {
}
-void Graphics::bobDrawAll() {
+void Graphics::drawBobs() {
int i;
for (i = 0; i < _sortedBobsCount; ++i) {
BobSlot *pbs = _sortedBobs[i];
@@ -404,20 +407,20 @@ void Graphics::bobDrawAll() {
x = pbs->x - xh - _vm->display()->horizontalScroll();
y = pbs->y - yh;
- bobDraw(pbs, x, y);
+ drawBob(pbs, x, y);
}
}
}
-void Graphics::bobClearAll() {
+void Graphics::clearBobs() {
for(int32 i = 0; i < ARRAYSIZE(_bobs); ++i) {
- bobClear(i);
+ clearBob(i);
}
}
-void Graphics::bobStopAll() {
+void Graphics::stopBobs() {
for(int32 i = 0; i < ARRAYSIZE(_bobs); ++i) {
_bobs[i].moving = false;
}
@@ -434,75 +437,7 @@ BobSlot *Graphics::bob(int index) {
}
-void Graphics::bobCustomParallax(uint16 roomNum) {
- int i;
- uint16 screenScroll = _vm->display()->horizontalScroll();
- switch (roomNum) {
- case ROOM_AMAZON_HIDEOUT:
- _bobs[8].x = 250 - screenScroll / 2;
- break;
- case ROOM_TEMPLE_MAZE_5:
- _bobs[5].x = 410 - screenScroll / 2;
- _bobs[6].x = 790 - screenScroll / 2;
- break;
- case ROOM_TEMPLE_OUTSIDE:
- _bobs[5].x = 320 - screenScroll / 2;
- break;
- case ROOM_TEMPLE_TREE:
- _bobs[5].x = 280 - screenScroll / 2;
- break;
- 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();
- break;
- case ROOM_FINAL_FIGHT:
- _vm->bam()->updateFightAnimation();
- break;
- case ROOM_INTRO_RITA_JOE_HEADS: // CR 2 - CD-Rom pan right while Rita talks...
- _cameraBob = -1;
- if (screenScroll < 80) {
- _vm->display()->horizontalScroll(screenScroll + 4);
- // Joe's body and head
- _bobs[ 1].x += 4;
- _bobs[20].x += 4;
- // Rita's body and head
- _bobs[ 2].x -= 2;
- _bobs[21].x -= 2;
- }
- break;
- case ROOM_INTRO_EXPLOSION: // CR 2 - CD-Rom the guys move off screen
- _bobs[21].x += 2;
- _bobs[21].y += 2;
- break;
- }
-}
-
-
-void Graphics::bobSetText(
+void Graphics::setBobText(
BobSlot *pbs,
const char *text,
int textX, int textY,
@@ -559,7 +494,7 @@ void Graphics::bobSetText(
int maxLineWidth = 0;
for (i = 0; i < lineCount; i++) {
- int width = textWidth(lines[i]);
+ int width = _vm->display()->textWidth(lines[i]);
if (maxLineWidth < width)
maxLineWidth = width;
}
@@ -606,69 +541,88 @@ void Graphics::bobSetText(
else if ((x + maxLineWidth) > 320)
x = 320 - maxLineWidth - 4;
- textCurrentColor(color);
+ _vm->display()->textCurrentColor(color);
for (i = 0; i < lineCount; i++) {
- int lineX = x + (maxLineWidth - textWidth(lines[i])) / 2;
+ int lineX = x + (maxLineWidth - _vm->display()->textWidth(lines[i])) / 2;
//debug(0, "Setting text '%s' at (%i, %i)", lines[i], lineX, y + 9 * i);
- textSet(lineX, y + 9 * i, lines[i]);
+ _vm->display()->setText(lineX, y + 9 * i, lines[i]);
}
}
-void Graphics::textSet(uint16 x, uint16 y, const char *text, bool outlined) {
- if (y < GAME_SCREEN_HEIGHT) {
- if (x == 0) x = 1;
- if (y == 0) y = 1;
- TextSlot *pts = &_texts[y];
-
- pts->x = x;
- pts->color = _curTextColor;
- pts->outlined = outlined;
- pts->text = text;
- }
-}
-
-
-void Graphics::textSetCentered(uint16 y, const char *text, bool outlined) {
- uint16 x = (GAME_SCREEN_WIDTH - textWidth(text)) / 2;
- textSet(x, y, text, outlined);
-}
-
-
-void Graphics::textDrawAll() {
- int y;
- for (y = GAME_SCREEN_HEIGHT - 1; y > 0; --y) {
- const TextSlot *pts = &_texts[y];
- if (!pts->text.isEmpty()) {
- _vm->display()->drawText(pts->x, y, pts->color, pts->text.c_str(), pts->outlined);
+void Graphics::handleParallax(uint16 roomNum) {
+ int i;
+ uint16 screenScroll = _vm->display()->horizontalScroll();
+ switch (roomNum) {
+ case ROOM_AMAZON_HIDEOUT:
+ _bobs[8].x = 250 - screenScroll / 2;
+ break;
+ case ROOM_TEMPLE_MAZE_5:
+ _bobs[5].x = 410 - screenScroll / 2;
+ _bobs[6].x = 790 - screenScroll / 2;
+ break;
+ case ROOM_TEMPLE_OUTSIDE:
+ _bobs[5].x = 320 - screenScroll / 2;
+ break;
+ case ROOM_TEMPLE_TREE:
+ _bobs[5].x = 280 - screenScroll / 2;
+ break;
+ 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();
+ break;
+ case ROOM_FINAL_FIGHT:
+ _vm->bam()->updateFightAnimation();
+ break;
+ case ROOM_INTRO_RITA_JOE_HEADS: // CR 2 - CD-Rom pan right while Rita talks...
+ _cameraBob = -1;
+ if (screenScroll < 80) {
+ _vm->display()->horizontalScroll(screenScroll + 4);
+ // Joe's body and head
+ _bobs[ 1].x += 4;
+ _bobs[20].x += 4;
+ // Rita's body and head
+ _bobs[ 2].x -= 2;
+ _bobs[21].x -= 2;
+ }
+ break;
+ case ROOM_INTRO_EXPLOSION: // CR 2 - CD-Rom the guys move off screen
+ _bobs[21].x += 2;
+ _bobs[21].y += 2;
+ break;
}
}
-void Graphics::textClear(uint16 y1, uint16 y2) {
- while (y1 <= y2) {
- _texts[y1].text.clear();
- ++y1;
- }
-}
-
-
-uint16 Graphics::textWidth(const char* text) const {
- return _vm->display()->textWidth(text);
-}
-
-
-int Graphics::textCenterX(const char *text) const {
- return 160 - textWidth(text) / 2;
-}
-
-
void Graphics::setupNewRoom(const char *room, uint16 roomNum, int16 *furniture, uint16 furnitureCount) {
// reset sprites table (bounding box...)
- bobClearAll();
+ clearBobs();
// load/setup objects associated to this room
char filename[20];
@@ -885,7 +839,7 @@ uint16 Graphics::refreshObject(uint16 obj) {
if (pod->image == -3 || pod->image == -4) {
// a person object
if (pod->name <= 0) {
- bobClear(curBob);
+ clearBob(curBob);
} else {
// find person number
uint16 pNum = _vm->logic()->findPersonNumber(obj);
@@ -903,7 +857,7 @@ uint16 Graphics::refreshObject(uint16 obj) {
if (pod->name < 0 || pod->image < 0) {
// object is hidden or disabled
- bobClear(curBob);
+ clearBob(curBob);
return curImage;
}
@@ -1015,7 +969,7 @@ void Graphics::setupRoomFurniture(int16 *furniture, uint16 furnitureCount) {
// unpack the paste downs
for (i = 1; i <= furnitureCount; ++i) {
if (furniture[i] > 5000) {;
- bobPaste(furniture[i] - 5000, curImage + 1);
+ pasteBob(furniture[i] - 5000, curImage + 1);
}
}
}
@@ -1090,7 +1044,7 @@ void Graphics::setupRoomObjects() {
// static objects
curBob = 20 + _numFurnitureStatic + numObjectStatic;
++curImage;
- bobClear(curBob);
+ clearBob(curBob);
// XXX if((COMPANEL==2) && (FULLSCREEN==1)) bobs[CURRBOB].y2=199;
@@ -1126,7 +1080,7 @@ void Graphics::setupRoomObjects() {
for (i = firstRoomObj; i <= lastRoomObj; ++i) {
ObjectData *pod = _vm->logic()->objectData(i);
if (pod->name > 0 && pod->image > 5000) {
- bobPaste(pod->image - 5000, curImage);
+ pasteBob(pod->image - 5000, curImage);
}
}
}
@@ -1173,7 +1127,6 @@ uint16 Graphics::setupPerson(uint16 noun, uint16 curImage) {
uint16 Graphics::allocPerson(uint16 noun, uint16 curImage) {
Person p;
if (_vm->logic()->initPerson(noun, "", false, &p) && p.anim != NULL) {
- debug(0, "allocPerson() : anim=%s", p.anim);
curImage += countAnimFrames(p.anim);
_personFrames[p.actor->bobNum] = curImage + 1;
}
@@ -1182,14 +1135,13 @@ uint16 Graphics::allocPerson(uint16 noun, uint16 curImage) {
void Graphics::update(uint16 room) {
- bobSortAll();
+ sortBobs();
if (_cameraBob >= 0) {
_vm->display()->horizontalScrollUpdate(_bobs[_cameraBob].x);
}
- bobCustomParallax(room);
+ handleParallax(room);
_vm->display()->prepareUpdate();
- bobDrawAll();
- textDrawAll();
+ drawBobs();
}
@@ -1201,15 +1153,15 @@ BamScene::BamScene(QueenEngine *vm)
void BamScene::prepareAnimation() {
_obj1 = _vm->graphics()->bob(BOB_OBJ1);
- _vm->graphics()->bobClear(BOB_OBJ1);
+ _obj1->clear();
_obj1->active = true;
_obj2 = _vm->graphics()->bob(BOB_OBJ2);
- _vm->graphics()->bobClear(BOB_OBJ2);
+ _obj2->clear();
_obj2->active = true;
_objfx = _vm->graphics()->bob(BOB_FX);
- _vm->graphics()->bobClear(BOB_FX);
+ _objfx->clear();
_objfx->active = true;
_index = 0;