[Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.58,1.59 akos.cpp,1.38,1.39 costume.cpp,1.11,1.12 gfx.cpp,2.22,2.23 module.mk,1.9,1.10 object.cpp,1.56,1.57 saveload.cpp,1.43,1.44 saveload.h,1.9,1.10 scumm.h,1.130,1.131
James Brown
ender at users.sourceforge.net
Tue Jan 14 02:06:02 CET 2003
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv13033/scumm
Modified Files:
actor.cpp akos.cpp costume.cpp gfx.cpp module.mk object.cpp
saveload.cpp saveload.h scumm.h
Log Message:
Patch 667613: Extend gfxUsageBits[]
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- actor.cpp 13 Jan 2003 14:04:39 -0000 1.58
+++ actor.cpp 14 Jan 2003 10:05:37 -0000 1.59
@@ -28,6 +28,7 @@
#include "costume.h"
#include "resource.h"
#include "sound.h"
+#include "usage_bits.h"
#include <math.h>
@@ -1100,7 +1101,6 @@
void Scumm::setActorRedrawFlags(bool fg, bool bg)
{
int i, j;
- uint32 bits;
if (_fullRedraw) {
for (j = 0; j < NUM_ACTORS; j++) {
@@ -1112,10 +1112,10 @@
}
} else {
for (i = 0; i < gdi._numStrips; i++) {
- bits = gfxUsageBits[_screenStartStrip + i];
- if (bits & 0x3FFFFFFF) {
+ int strip = _screenStartStrip + i;
+ if (testGfxAnyUsageBits(strip)) {
for (j = 0; j < NUM_ACTORS; j++) {
- if ((bits & (1 << j)) && bits != (uint32)(1 << j)) {
+ if (testGfxUsageBit(strip, j) && testGfxOtherUsageBits(strip, j)) {
Actor *a = derefActor(j);
if (fg)
a->needRedraw = true;
@@ -1130,15 +1130,13 @@
int Scumm::getActorFromPos(int x, int y)
{
- uint32 drawbits;
int i;
- drawbits = gfxUsageBits[x >> 3];
- if (!(drawbits & 0x3FFFFFFF))
+ if (!testGfxAnyUsageBits(x >> 3))
return 0;
for (i = 1; i < NUM_ACTORS; i++) {
Actor *a = derefActor(i);
- if (drawbits & (1 << i) && !getClass(i, 32) && y >= a->top && y <= a->bottom) {
+ if (testGfxUsageBit(x >> 3, i) && !getClass(i, 32) && y >= a->top && y <= a->bottom) {
return i;
}
}
@@ -1541,23 +1539,17 @@
void Scumm::resetActorBgs()
{
Actor *a;
- int i;
- uint32 onlyActorFlags, bitpos;
+ int i, j;
for (i = 0; i < gdi._numStrips; i++) {
- onlyActorFlags = (gfxUsageBits[_screenStartStrip + i] &= 0x3FFFFFFF);
+ int strip = _screenStartStrip + i;
a = getFirstActor();
- bitpos = 1;
-
- while (onlyActorFlags) {
- if (onlyActorFlags & 1 && a->top != 0xFF && a->needBgReset) {
- gfxUsageBits[_screenStartStrip + i] ^= bitpos;
-
+ for (j = 0; j < NUM_ACTORS; j++) {
+ if (testGfxUsageBit(strip, j) && a->top != 0xFF && a->needBgReset) {
+ clearGfxUsageBit(strip, j);
if ((a->bottom - a->top) >= 0)
gdi.resetBackground(a->top, a->bottom, i);
}
- bitpos <<= 1;
- onlyActorFlags >>= 1;
a++;
}
}
Index: akos.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/akos.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- akos.cpp 12 Jan 2003 18:35:01 -0000 1.38
+++ akos.cpp 14 Jan 2003 10:05:38 -0000 1.39
@@ -829,7 +829,7 @@
if (v1.skip_width <= 0 || _height <= 0)
return;
- _vm->updateDirtyRect(0, x_left, x_right, y_top, y_bottom, 1 << _dirty_id);
+ _vm->updateDirtyRect(0, x_left, x_right, y_top, y_bottom, _dirty_id);
y_clipping = ((uint) y_bottom > outheight || y_top < 0);
@@ -949,7 +949,7 @@
if ((clip_right <= clip_left) || (clip_top >= clip_bottom))
return;
- _vm->updateDirtyRect(0, clip_left, clip_right + 1, clip_top, clip_bottom + 1, 1 << _dirty_id);
+ _vm->updateDirtyRect(0, clip_left, clip_right + 1, clip_top, clip_bottom + 1, _dirty_id);
if (_draw_top > clip_top)
_draw_top = clip_top;
@@ -1280,7 +1280,7 @@
if ((clip_left >= clip_right) || (clip_top >= clip_bottom))
return;
- _vm->updateDirtyRect(0, clip_left, clip_right + 1, clip_top, clip_bottom + 1, 1 << _dirty_id);
+ _vm->updateDirtyRect(0, clip_left, clip_right + 1, clip_top, clip_bottom + 1, _dirty_id);
if (_draw_top > clip_top)
_draw_top = clip_top;
Index: costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/costume.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- costume.cpp 7 Jan 2003 17:35:18 -0000 1.11
+++ costume.cpp 14 Jan 2003 10:05:38 -0000 1.12
@@ -213,7 +213,7 @@
_scaleIndexXStep = 1;
_ypostop = _ypos;
- _vm->updateDirtyRect(0, _left, _right + 1, _top, _bottom, 1 << _dirty_id);
+ _vm->updateDirtyRect(0, _left, _right + 1, _top, _bottom, _dirty_id);
if (_top >= (int)_outheight || _bottom <= 0)
return 0;
Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.22
retrieving revision 2.23
diff -u -d -r2.22 -r2.23
--- gfx.cpp 12 Jan 2003 13:58:16 -0000 2.22
+++ gfx.cpp 14 Jan 2003 10:05:39 -0000 2.23
@@ -24,6 +24,7 @@
#include "actor.h"
#include "charset.h"
#include "resource.h"
+#include "usage_bits.h"
#include "util.h"
@@ -295,12 +296,10 @@
return NULL;
}
-void Scumm::updateDirtyRect(int virt, int left, int right, int top, int bottom, uint32 dirtybits)
+void Scumm::updateDirtyRect(int virt, int left, int right, int top, int bottom, int dirtybit)
{
VirtScreen *vs = &virtscr[virt];
int lp, rp;
- uint32 *sp;
- int num;
if (top > vs->height || left > vs->width || right < 0 || bottom < 0)
return;
@@ -314,7 +313,7 @@
if (right > vs->width)
right = vs->width;
- if (virt == 0 && dirtybits) {
+ if (virt == 0 && dirtybit) {
lp = (left >> 3) + _screenStartStrip;
if (lp < 0)
lp = 0;
@@ -331,13 +330,8 @@
if (rp >= 200)
rp = 200;
}
- if (lp <= rp) {
- num = rp - lp + 1;
- sp = &gfxUsageBits[lp];
- do {
- *sp++ |= dirtybits;
- } while (--num);
- }
+ for (; lp <= rp; lp++)
+ setGfxUsageBit(lp, dirtybit);
}
setVirtscreenDirty(vs, left, top, right, bottom);
@@ -632,7 +626,7 @@
// Redraw any actors "under" the flashlight
for (i = _flashlight.x/8; i < (_flashlight.x+_flashlight.w)/8; i++) {
- gfxUsageBits[_screenStartStrip + i] |= 0x80000000;
+ setGfxUsageBit(_screenStartStrip + i, USAGE_BIT_DIRTY);
virtscr[0].tdirty[i] = 0;
virtscr[0].bdirty[i] = virtscr[0].height;
}
@@ -682,7 +676,7 @@
// Redraw parts of the background which are marked as dirty.
if (!_fullRedraw && _BgNeedsRedraw) {
for (i = 0; i != gdi._numStrips; i++) {
- if (gfxUsageBits[_screenStartStrip + i] & 0x80000000) {
+ if (testGfxUsageBit(_screenStartStrip + i, USAGE_BIT_DIRTY)) {
redrawBGStrip(i, 1);
}
}
@@ -723,10 +717,10 @@
{
int s = _screenStartStrip + start;
- assert(s >= 0 && (size_t) s < sizeof(gfxUsageBits) / sizeof(gfxUsageBits[0]));
+ assert(s >= 0 && (size_t) s < sizeof(gfxUsageBits) / (3 * sizeof(gfxUsageBits[0])));
for (int i = 0; i < num; i++)
- gfxUsageBits[s + i] |= 0x80000000;
+ setGfxUsageBit(s + i, USAGE_BIT_DIRTY);
gdi.drawBitmap(getResourceAddress(rtRoom, _roomResource) + _IM00_offs,
&virtscr[0], s, 0, virtscr[0].height, s, num, 0);
@@ -775,7 +769,7 @@
if (bottom >= height)
bottom = height;
- updateDirtyRect(vs->number, left, right, top - topline, bottom - topline, 0x40000000);
+ updateDirtyRect(vs->number, left, right, top - topline, bottom - topline, USAGE_BIT_RESTORED);
int offset = (top - topline) * _realWidth + vs->xstart + left;
backbuff = vs->screenPtr + offset;
Index: module.mk
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/module.mk,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- module.mk 28 Dec 2002 14:40:55 -0000 1.9
+++ module.mk 14 Jan 2003 10:05:39 -0000 1.10
@@ -27,6 +27,7 @@
scumm/scummvm.o \
scumm/sound.o \
scumm/string.o \
+ scumm/usage_bits.o \
scumm/vars.o \
scumm/verbs.o
Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- object.cpp 13 Jan 2003 16:00:19 -0000 1.56
+++ object.cpp 14 Jan 2003 10:05:40 -0000 1.57
@@ -25,6 +25,7 @@
#include "actor.h"
#include "object.h"
#include "resource.h"
+#include "usage_bits.h"
bool Scumm::getClass(int obj, int cls)
{
@@ -393,7 +394,7 @@
continue;
if (tmp < _screenStartStrip || tmp > _screenEndStrip)
continue;
- gfxUsageBits[tmp] |= 0x80000000;
+ setGfxUsageBit(tmp, USAGE_BIT_DIRTY);
if (tmp < x)
x = tmp;
numstrip++;
@@ -762,17 +763,13 @@
void Scumm::removeObjectFromRoom(int obj)
{
- int i, cnt;
- uint32 *ptr;
+ int i, j;
for (i = 1; i < _numLocalObjects; i++) {
if (_objs[i].obj_nr == (uint16)obj) {
if (_objs[i].width != 0) {
- ptr = &gfxUsageBits[_objs[i].x_pos >> 3];
- cnt = _objs[i].width >> 3;
- do {
- *ptr++ |= 0x80000000;
- } while (--cnt);
+ for (j = 0; j < _objs[i].width; j++)
+ setGfxUsageBit((_objs[i].x_pos >> 3) + j, USAGE_BIT_DIRTY);
}
_BgNeedsRedraw = true;
return;
@@ -1619,7 +1616,7 @@
for (i = left_strip; i <= right_strip; i++)
gdi.resetBackground(top, bottom, i);
- updateDirtyRect(0, left, right, top, bottom, 0x40000000);
+ updateDirtyRect(0, left, right, top, bottom, USAGE_BIT_RESTORED);
}
int Scumm::findLocalObjectSlot()
Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- saveload.cpp 13 Jan 2003 01:29:44 -0000 1.43
+++ saveload.cpp 14 Jan 2003 10:05:40 -0000 1.44
@@ -424,9 +424,10 @@
MKLINE(Scumm, _palManipEnd, sleByte, VER_V10),
MKLINE(Scumm, _palManipCounter, sleUint16, VER_V10),
- // gfxUsageBits grew from 200 to 410 entries:
+ // gfxUsageBits grew from 200 to 410 entries. Then 3 * 410 entries:
MKARRAY_OLD(Scumm, gfxUsageBits[0], sleUint32, 200, VER_V8, VER_V9),
- MKARRAY(Scumm, gfxUsageBits[0], sleUint32, 410, VER_V10),
+ MKARRAY_OLD(Scumm, gfxUsageBits[0], sleUint32, 410, VER_V10, VER_V13),
+ MKARRAY(Scumm, gfxUsageBits[0], sleUint32, 3 * 410, VER_V14),
MKLINE(Scumm, gdi._transparentColor, sleByte, VER_V8),
MKARRAY(Scumm, _currentPalette[0], sleByte, 768, VER_V8),
@@ -557,7 +558,14 @@
}
}
+ // Because old savegames won't fill the entire gfxUsageBits[] array,
+ // clear it here just to be sure it won't hold any unforseen garbage.
+ memset(gfxUsageBits, 0, sizeof(gfxUsageBits));
+
s->saveLoadEntries(this, mainEntries);
+
+ if (!s->isSaving() && savegameVersion < VER_V14)
+ upgradeGfxUsageBits();
s->saveLoadArrayOf(_actors, NUM_ACTORS, sizeof(_actors[0]), actorEntries);
Index: saveload.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- saveload.h 13 Jan 2003 01:29:44 -0000 1.9
+++ saveload.h 14 Jan 2003 10:05:41 -0000 1.10
@@ -32,10 +32,11 @@
VER_V10,
VER_V11,
VER_V12,
- VER_V13
+ VER_V13,
+ VER_V14
};
-#define CURRENT_VER VER_V13
+#define CURRENT_VER VER_V14
// To work around a warning in GCC 3.2 (and 3.1 ?) regarding non-POD types,
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -d -r1.130 -r1.131
--- scumm.h 13 Jan 2003 14:04:41 -0000 1.130
+++ scumm.h 14 Jan 2003 10:05:41 -0000 1.131
@@ -748,7 +748,7 @@
void useBompCursor(byte *im, int w, int h);
- void updateDirtyRect(int virt, int left, int right, int top, int bottom, uint32 dirtybits);
+ void updateDirtyRect(int virt, int left, int right, int top, int bottom, int dirtybit);
void setDirtyRange(int slot, int a, int height);
void drawDirtyScreenParts();
void updateDirtyScreen(int slot);
@@ -810,12 +810,18 @@
byte *_palManipPalette;
byte *_palManipIntermediatePal;
- /* For each screen strip, gfxUsageBits contains a bitmask.
- * The lower 30 bits each correspond to one actor and signify if any part
- * of that actor is currently contained in that strip.
- * If the left most bit is set, the strip (background) is dirty needs to be redrawn.
+ /* For each of the 410 screen strips, gfxUsageBits contains a
+ * bitmask. The lower 80 bits each correspond to one actor and
+ * signify if any part of that actor is currently contained in
+ * that strip.
+ *
+ * If the leftmost bit is set, the strip (background) is dirty
+ * needs to be redrawn.
+ *
+ * The second leftmost bit is set by removeBlastObject() and
+ * restoreBG(), but I'm not yet sure why.
*/
- uint32 gfxUsageBits[410];
+ uint32 gfxUsageBits[410 * 3];
byte *_shadowPalette;
int _shadowPaletteSize;
@@ -923,6 +929,13 @@
#elif defined(SCUMM_BIG_ENDIAN)
uint32 fileReadDword() { return _fileHandle.readUint32BE(); }
#endif
+
+ void upgradeGfxUsageBits();
+ void setGfxUsageBit(int strip, int bit);
+ void clearGfxUsageBit(int strip, int bit);
+ bool testGfxUsageBit(int strip, int bit);
+ bool testGfxAnyUsageBits(int strip);
+ bool testGfxOtherUsageBits(int strip, int bit);
/* Scumm Vars */
byte VAR_KEYPRESS;
More information about the Scummvm-git-logs
mailing list