aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/graphics
diff options
context:
space:
mode:
authorFilippos Karapetis2010-10-23 19:23:07 +0000
committerFilippos Karapetis2010-10-23 19:23:07 +0000
commit6c47ca8253d970045f817dc75008cfb21c499d62 (patch)
tree84102fc964d4d74a01c8d3a97aa49b4d34527a70 /engines/sci/graphics
parentbd14661fdfc3efcc649edf5db683c96ef4cc09d9 (diff)
downloadscummvm-rg350-6c47ca8253d970045f817dc75008cfb21c499d62.tar.gz
scummvm-rg350-6c47ca8253d970045f817dc75008cfb21c499d62.tar.bz2
scummvm-rg350-6c47ca8253d970045f817dc75008cfb21c499d62.zip
SCI2/SCI2.1: Some changes to the screen drawing code.
- Implemented kernelUpdateScreenITem - Changed the list of screen items to be a list of FrameoutEntry entries, so that it doesn't get recreated on every frame svn-id: r53744
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r--engines/sci/graphics/frameout.cpp102
-rw-r--r--engines/sci/graphics/frameout.h2
2 files changed, 54 insertions, 50 deletions
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index fc374ea143..035a4cfe45 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -130,6 +130,15 @@ void GfxFrameout::kernelUpdatePlane(reg_t object) {
it->planeBack = readSelectorValue(_segMan, object, SELECTOR(back));
sortPlanes();
+
+ // Update the items in the plane
+ for (FrameoutList::iterator listIterator = _screenItems.begin(); listIterator != _screenItems.end(); listIterator++) {
+ reg_t itemPlane = readSelector(_segMan, (*listIterator)->object, SELECTOR(plane));
+ if (object == itemPlane) {
+ kernelUpdateScreenItem((*listIterator)->object);
+ }
+ }
+
return;
}
}
@@ -186,17 +195,50 @@ void GfxFrameout::deletePlanePictures(reg_t object) {
}
void GfxFrameout::kernelAddScreenItem(reg_t object) {
- _screenItems.push_back(object);
+ // Ignore invalid items
+ if (!_segMan->isObject(object))
+ return;
+
+ FrameoutEntry *itemEntry = new FrameoutEntry();
+ itemEntry->object = object;
+ itemEntry->givenOrderNr = _screenItems.size();
+ _screenItems.push_back(itemEntry);
+
+ kernelUpdateScreenItem(object);
}
void GfxFrameout::kernelUpdateScreenItem(reg_t object) {
- // TODO
+ // Ignore invalid items
+ if (!_segMan->isObject(object))
+ return;
+
+ for (FrameoutList::iterator listIterator = _screenItems.begin(); listIterator != _screenItems.end(); listIterator++) {
+ FrameoutEntry *itemEntry = *listIterator;
+
+ if (itemEntry->object == object) {
+ itemEntry->viewId = readSelectorValue(_segMan, object, SELECTOR(view));
+ itemEntry->loopNo = readSelectorValue(_segMan, object, SELECTOR(loop));
+ itemEntry->celNo = readSelectorValue(_segMan, object, SELECTOR(cel));
+ itemEntry->x = readSelectorValue(_segMan, object, SELECTOR(x));
+ itemEntry->y = readSelectorValue(_segMan, object, SELECTOR(y));
+ itemEntry->z = readSelectorValue(_segMan, object, SELECTOR(z));
+ itemEntry->priority = readSelectorValue(_segMan, object, SELECTOR(priority));
+ if (readSelectorValue(_segMan, object, SELECTOR(fixPriority)) == 0)
+ itemEntry->priority = itemEntry->y;
+
+ itemEntry->signal = readSelectorValue(_segMan, object, SELECTOR(signal));
+ itemEntry->scaleX = readSelectorValue(_segMan, object, SELECTOR(scaleX));
+ itemEntry->scaleY = readSelectorValue(_segMan, object, SELECTOR(scaleY));
+ return;
+ }
+ }
}
void GfxFrameout::kernelDeleteScreenItem(reg_t object) {
- for (uint32 itemNr = 0; itemNr < _screenItems.size(); itemNr++) {
- if (_screenItems[itemNr] == object) {
- _screenItems.remove_at(itemNr);
+ for (FrameoutList::iterator listIterator = _screenItems.begin(); listIterator != _screenItems.end(); listIterator++) {
+ FrameoutEntry *itemEntry = *listIterator;
+ if (itemEntry->object == object) {
+ _screenItems.remove(itemEntry);
return;
}
}
@@ -252,11 +294,6 @@ void GfxFrameout::sortPlanes() {
void GfxFrameout::kernelFrameout() {
_palette->palVaryUpdate();
- // Allocate enough space for all screen items
- // TODO: Modify _screenItems to hold FrameoutEntry entries instead.
- // Creating and destroying this in kernelFrameout() is overkill!
- FrameoutEntry *itemData = new FrameoutEntry[_screenItems.size()];
-
for (PlaneList::iterator it = _planes.begin(); it != _planes.end(); it++) {
reg_t planeObject = it->object;
uint16 planeLastPriority = it->lastPriority;
@@ -280,43 +317,14 @@ void GfxFrameout::kernelFrameout() {
_coordAdjuster->pictureSetDisplayArea(it->planeRect);
_palette->drewPicture(planeMainPictureId);
- // Fill our itemlist for this plane
- int16 itemCount = 0;
- FrameoutEntry *itemEntry = itemData;
FrameoutList itemList;
- for (uint32 itemNr = 0; itemNr < _screenItems.size(); itemNr++) {
- reg_t itemObject = _screenItems[itemNr];
-
- // Remove any invalid items
- if (!_segMan->isObject(itemObject)) {
- _screenItems.remove_at(itemNr);
- itemNr--;
- continue;
- }
-
- reg_t itemPlane = readSelector(_segMan, itemObject, SELECTOR(plane));
+ // Copy screen items of the current frame to the list of items to be drawn
+ for (FrameoutList::iterator listIterator = _screenItems.begin(); listIterator != _screenItems.end(); listIterator++) {
+ reg_t itemPlane = readSelector(_segMan, (*listIterator)->object, SELECTOR(plane));
if (planeObject == itemPlane) {
- // Found an item on current plane
- itemEntry->viewId = readSelectorValue(_segMan, itemObject, SELECTOR(view));
- itemEntry->loopNo = readSelectorValue(_segMan, itemObject, SELECTOR(loop));
- itemEntry->celNo = readSelectorValue(_segMan, itemObject, SELECTOR(cel));
- itemEntry->x = readSelectorValue(_segMan, itemObject, SELECTOR(x));
- itemEntry->y = readSelectorValue(_segMan, itemObject, SELECTOR(y));
- itemEntry->z = readSelectorValue(_segMan, itemObject, SELECTOR(z));
- itemEntry->priority = readSelectorValue(_segMan, itemObject, SELECTOR(priority));
- if (readSelectorValue(_segMan, itemObject, SELECTOR(fixPriority)) == 0)
- itemEntry->priority = itemEntry->y;
-
- itemEntry->signal = readSelectorValue(_segMan, itemObject, SELECTOR(signal));
- itemEntry->scaleX = readSelectorValue(_segMan, itemObject, SELECTOR(scaleX));
- itemEntry->scaleY = readSelectorValue(_segMan, itemObject, SELECTOR(scaleY));
- itemEntry->object = itemObject;
- itemEntry->givenOrderNr = itemNr;
-
- itemList.push_back(itemEntry);
- itemEntry++;
- itemCount++;
+ kernelUpdateScreenItem((*listIterator)->object); // TODO: Why is this necessary?
+ itemList.push_back(*listIterator);
}
}
@@ -348,13 +356,10 @@ void GfxFrameout::kernelFrameout() {
// Now sort our itemlist
Common::sort(itemList.begin(), itemList.end(), sortHelper);
- // Now display itemlist
- itemEntry = itemData;
-
// warning("Plane %s", _segMan->getObjectName(planeObject));
for (FrameoutList::iterator listIterator = itemList.begin(); listIterator != itemList.end(); listIterator++) {
- itemEntry = *listIterator;
+ FrameoutEntry *itemEntry = *listIterator;
if (itemEntry->object.isNull()) {
// Picture cel data
@@ -530,7 +535,6 @@ void GfxFrameout::kernelFrameout() {
}
}
- delete[] itemData;
_screen->copyToScreen();
g_sci->getEngineState()->_throttleTrigger = true;
diff --git a/engines/sci/graphics/frameout.h b/engines/sci/graphics/frameout.h
index 07297a91af..bd708dbc79 100644
--- a/engines/sci/graphics/frameout.h
+++ b/engines/sci/graphics/frameout.h
@@ -109,7 +109,7 @@ private:
GfxScreen *_screen;
GfxPaint32 *_paint32;
- Common::Array<reg_t> _screenItems;
+ Common::List<FrameoutEntry *> _screenItems;
PlaneList _planes;
PlanePictureList _planePictures;