[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.cpp,1.70,1.71 gfx.h,1.8,1.9 saveload.cpp,1.23,1.24 scumm.h,1.67,1.68 scummvm.cpp,1.87,1.88 string.cpp,1.51,1.52
Max Horn
fingolfin at users.sourceforge.net
Wed Dec 4 05:37:02 CET 2002
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv2432
Modified Files:
gfx.cpp gfx.h saveload.cpp scumm.h scummvm.cpp string.cpp
Log Message:
lots of cleanup to the graphics code; removed various global states (makes it easier to understand the code)
Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- gfx.cpp 1 Dec 2002 14:57:50 -0000 1.70
+++ gfx.cpp 4 Dec 2002 13:36:27 -0000 1.71
@@ -273,7 +273,7 @@
void Scumm::setCursor(int cursor)
{
if (cursor >= 0 && cursor <= 3)
- gdi._currentCursor = cursor;
+ _currentCursor = cursor;
else
warning("setCursor(%d)", cursor);
}
@@ -452,7 +452,7 @@
// check for that. And somebody before me added a check for V7 games, turning this
// off there, too... I wonder if it hurts other games, too? What exactly is broken
// if we remove this patch?
- if ((_gameId == GID_MONKEY_VGA) || (_features & GF_AFTER_V7) || (i <= 15 || r < 252 || g < 252 || b < 252)) {
+ if ((_features & GF_AFTER_V7) || (i <= 15 || r < 252 || g < 252 || b < 252)) {
*dest++ = r;
*dest++ = g;
*dest++ = b;
@@ -728,8 +728,7 @@
// Fill screen 0 with black
vs = &virtscr[0];
- gdi._backbuff_ptr = vs->screenPtr + vs->xstart;
- memset(gdi._backbuff_ptr, 0, vs->size);
+ memset(vs->screenPtr + vs->xstart, 0, vs->size);
// Fade to black with the specified effect, if any.
switch (effect) {
@@ -921,14 +920,14 @@
if (_vm->hasCharsetMask(sx << 3, y, (sx + 1) << 3, bottom)) {
if (flag & dbClear || !lightsOn)
- clear8ColWithMasking();
+ clear8ColWithMasking(_backbuff_ptr, h, _mask_ptr);
else
- draw8ColWithMasking();
+ draw8ColWithMasking(_backbuff_ptr, _bgbak_ptr, h, _mask_ptr);
} else {
if (flag & dbClear || !lightsOn)
- clear8Col();
+ clear8Col(_backbuff_ptr, h);
else
- _vm->blit(_backbuff_ptr, _bgbak_ptr, 8, h);
+ draw8Col(_backbuff_ptr, _bgbak_ptr, h);
}
}
CHECK_HEAP;
@@ -950,13 +949,13 @@
// are still too unstable for me to investigate.
if (flag & dbDrawMaskOnAll) {
- _z_plane_ptr = zplane_list[1] + READ_LE_UINT16(zplane_list[1] + stripnr * 2 + 8);
+ byte *z_plane_ptr = zplane_list[1] + READ_LE_UINT16(zplane_list[1] + stripnr * 2 + 8);
for (i = 0; i < numzbuf; i++) {
_mask_ptr_dest = _vm->getResourceAddress(rtBuffer, 9) + y * _numStrips + x + _imgBufOffs[i];
if (_useOrDecompress && flag & dbAllowMaskOr)
- decompressMaskImgOr();
+ decompressMaskImgOr(_mask_ptr_dest, z_plane_ptr, h);
else
- decompressMaskImg();
+ decompressMaskImg(_mask_ptr_dest, z_plane_ptr, h);
}
} else {
for (i = 1; i < numzbuf; i++) {
@@ -976,15 +975,15 @@
_mask_ptr_dest = _vm->getResourceAddress(rtBuffer, 9) + y * _numStrips + x + _imgBufOffs[i];
if (offs) {
- _z_plane_ptr = zplane_list[i] + offs;
+ byte *z_plane_ptr = zplane_list[i] + offs;
if (_useOrDecompress && flag & dbAllowMaskOr)
- decompressMaskImgOr();
+ decompressMaskImgOr(_mask_ptr_dest, z_plane_ptr, h);
else
- decompressMaskImg();
+ decompressMaskImg(_mask_ptr_dest, z_plane_ptr, h);
} else {
if (!(_useOrDecompress && flag & dbAllowMaskOr))
- for (int height = 0; height < _numLinesToProcess; height++)
+ for (int height = 0; height < h; height++)
_mask_ptr_dest[height * _numStrips] = 0;
/* needs better abstraction, FIXME */
}
@@ -1135,12 +1134,8 @@
return 1;
}
-void Gdi::draw8ColWithMasking()
+void Gdi::draw8ColWithMasking(byte *dst, byte *src, int height, byte *mask)
{
- int height = _numLinesToProcess;
- byte *mask = _mask_ptr;
- byte *dst = _backbuff_ptr;
- byte *src = _bgbak_ptr;
byte maskbits;
do {
@@ -1164,7 +1159,7 @@
dst[7] = src[7];
} else {
#if defined(SCUMM_NEED_ALIGNMENT)
- memcpy(dst, src, 2 * sizeof(uint32));
+ memcpy(dst, src, 8);
#else
((uint32 *)dst)[0] = ((uint32 *)src)[0];
((uint32 *)dst)[1] = ((uint32 *)src)[1];
@@ -1176,11 +1171,8 @@
} while (--height);
}
-void Gdi::clear8ColWithMasking()
+void Gdi::clear8ColWithMasking(byte *dst, int height, byte *mask)
{
- int height = _numLinesToProcess;
- byte *mask = _mask_ptr;
- byte *dst = _backbuff_ptr;
byte maskbits;
do {
@@ -1204,7 +1196,7 @@
dst[7] = 0;
} else {
#if defined(SCUMM_NEED_ALIGNMENT)
- memset(dst, 0, 2 * sizeof(uint32));
+ memset(dst, 0, 8);
#else
((uint32 *)dst)[0] = 0;
((uint32 *)dst)[1] = 0;
@@ -1215,14 +1207,11 @@
} while (--height);
}
-void Gdi::clear8Col()
+void Gdi::clear8Col(byte *dst, int height)
{
- int height = _numLinesToProcess;
- byte *dst = _backbuff_ptr;
-
do {
#if defined(SCUMM_NEED_ALIGNMENT)
- memset(dst, 0, 2 * sizeof(uint32));
+ memset(dst, 0, 8);
#else
((uint32 *)dst)[0] = 0;
((uint32 *)dst)[1] = 0;
@@ -1231,11 +1220,23 @@
} while (--height);
}
-void Gdi::decompressMaskImg()
+void Gdi::draw8Col(byte *dst, byte *src, int height)
+{
+ do {
+#if defined(SCUMM_NEED_ALIGNMENT)
+ memcpy(dst, src, 8);
+#else
+ ((uint32 *)dst)[0] = ((uint32 *)src)[0];
+ ((uint32 *)dst)[1] = ((uint32 *)src)[1];
+#endif
+ dst += _vm->_realWidth;
+ src += _vm->_realWidth;
+ } while (--height);
+}
+
+
+void Gdi::decompressMaskImg(byte *dst, byte *src, int height)
{
- byte *src = _z_plane_ptr;
- byte *dst = _mask_ptr_dest;
- int height = _numLinesToProcess;
byte b, c;
while (1) {
@@ -1262,15 +1263,13 @@
}
}
-void Gdi::decompressMaskImgOr()
+void Gdi::decompressMaskImgOr(byte *dst, byte *src, int height)
{
- byte *src = _z_plane_ptr;
- byte *dst = _mask_ptr_dest;
- int height = _numLinesToProcess;
byte b, c;
while (1) {
b = *src++;
+
if (b & 0x80) {
b &= 0x7F;
c = *src++;
@@ -1600,7 +1599,7 @@
do {
/* Endian safe */
#if defined(SCUMM_NEED_ALIGNMENT)
- memcpy(dst, src, 2 * sizeof(uint32));
+ memcpy(dst, src, 8);
#else
((uint32 *)dst)[0] = ((uint32 *)src)[0];
((uint32 *)dst)[1] = ((uint32 *)src)[1];
@@ -2720,11 +2719,11 @@
if (_numLinesToProcess) {
if ((_vm->_features & GF_AFTER_V6) || (_vm->_vars[_vm->VAR_CURRENT_LIGHTS] & LIGHTMODE_screen)) {
if (_vm->hasCharsetMask(strip << 3, top, (strip + 1) << 3, bottom))
- draw8ColWithMasking();
+ draw8ColWithMasking(_backbuff_ptr, _bgbak_ptr, _numLinesToProcess, _mask_ptr);
else
- _vm->blit(_backbuff_ptr, _bgbak_ptr, 8, _numLinesToProcess);
+ draw8Col(_backbuff_ptr, _bgbak_ptr, _numLinesToProcess);
} else {
- clear8Col();
+ clear8Col(_backbuff_ptr, _numLinesToProcess);
}
}
}
@@ -3028,12 +3027,12 @@
} else {
_cursorWidth = 16;
_cursorHeight = 16;
- _cursorHotspotX = default_cursor_hotspots[2 * gdi._currentCursor];
- _cursorHotspotY = default_cursor_hotspots[2 * gdi._currentCursor + 1];
+ _cursorHotspotX = default_cursor_hotspots[2 * _currentCursor];
+ _cursorHotspotY = default_cursor_hotspots[2 * _currentCursor + 1];
for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j++) {
- if (default_cursor_images[gdi._currentCursor][i] & (1 << j))
+ if (default_cursor_images[_currentCursor][i] & (1 << j))
_grabbedCursor[16 * i + 15 - j] = color;
}
}
Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- gfx.h 6 Nov 2002 17:55:44 -0000 1.8
+++ gfx.h 4 Dec 2002 13:36:27 -0000 1.9
@@ -109,17 +109,22 @@
uint16 shadowMode;
};
-struct Gdi {
+class Gdi {
+ friend class Scumm; // Mostly for the code in saveload.cpp ...
+public:
Scumm *_vm;
+protected:
byte *_readPtr;
uint _readOffs;
+public:
int _numZBuffer;
int _imgBufOffs[5];
byte _disable_zbuffer;
int32 _numStrips;
+protected:
bool _useOrDecompress;
int _numLinesToProcess;
int _tempNumLines;
@@ -130,8 +135,9 @@
int16 _drawMouseX;
int16 _drawMouseY;
+public:
int16 _mask_top, _mask_bottom, _mask_right, _mask_left;
- byte _currentCursor;
+protected:
byte _mouseColors[4];
byte _mouseColor;
byte _mouseClipMask1, _mouseClipMask2, _mouseClipMask3;
@@ -142,7 +148,6 @@
byte *_bgbak_ptr;
byte *_mask_ptr;
byte *_mask_ptr_dest;
- byte *_z_plane_ptr;
byte _palette_mod;
byte _decomp_shr, _decomp_mask;
@@ -164,27 +169,31 @@
void unkDecode10();
void unkDecode11();
+public:
void drawBitmap(byte *ptr, VirtScreen *vs, int x, int y, int h, int stripnr, int numstrip, byte flag);
void clearUpperMask();
void disableZBuffer() { _disable_zbuffer++; }
void enableZBuffer() { _disable_zbuffer--; }
- void draw8ColWithMasking();
- void clear8ColWithMasking();
- void clear8Col();
- void decompressMaskImgOr();
- void decompressMaskImg();
-
- void resetBackground(int top, int bottom, int strip);
- void drawStripToScreen(VirtScreen *vs, int x, int w, int t, int b);
- void updateDirtyScreen(VirtScreen *vs);
+protected:
+ void draw8ColWithMasking(byte *dst, byte *src, int height, byte *mask);
+ void draw8Col(byte *dst, byte *src, int height);
+ void clear8ColWithMasking(byte *dst, int height, byte *mask);
+ void clear8Col(byte *dst, int height);
+ void decompressMaskImgOr(byte *dst, byte *src, int height);
+ void decompressMaskImg(byte *dst, byte *src, int height);
+public:
enum DrawBitmapFlags {
dbAllowMaskOr = 1,
dbDrawMaskOnAll = 2,
dbClear = 4
};
+
+ void resetBackground(int top, int bottom, int strip);
+ void drawStripToScreen(VirtScreen *vs, int x, int w, int t, int b);
+ void updateDirtyScreen(VirtScreen *vs);
};
#endif
Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- saveload.cpp 1 Dec 2002 14:57:50 -0000 1.23
+++ saveload.cpp 4 Dec 2002 13:36:27 -0000 1.24
@@ -398,7 +398,7 @@
MKLINE(Scumm, _userPut, sleByte),
MKLINE(Scumm, _cursorState, sleByte),
MKLINE(Scumm, gdi._cursorActive, sleByte),
- MKLINE(Scumm, gdi._currentCursor, sleByte),
+ MKLINE(Scumm, _currentCursor, sleByte),
MKLINE(Scumm, _doEffect, sleByte),
MKLINE(Scumm, _switchRoomEffect, sleByte),
@@ -513,7 +513,7 @@
MKLINE(Scumm, _userPut, sleByte),
MKLINE(Scumm, _cursorState, sleByte),
MKLINE(Scumm, gdi._cursorActive, sleByte),
- MKLINE(Scumm, gdi._currentCursor, sleByte),
+ MKLINE(Scumm, _currentCursor, sleByte),
MKLINE(Scumm, _doEffect, sleByte),
MKLINE(Scumm, _switchRoomEffect, sleByte),
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- scumm.h 1 Dec 2002 14:57:50 -0000 1.67
+++ scumm.h 4 Dec 2002 13:36:27 -0000 1.68
@@ -200,14 +200,10 @@
byte _ignoreCharsetMask;
- byte *_backbuff_ptr, *_bgbak_ptr;
- byte *_mask_ptr;
- byte *_dest_ptr;
-
byte _colorMap[16];
byte _buffer[512];
- void drawBits();
+ void drawBits(byte *dst, byte *mask);
void printChar(int chr);
void printCharOld(int chr);
int getSpacing(byte chr, byte *charset);
@@ -696,6 +692,7 @@
int _cursorHotspotX, _cursorHotspotY, _cursorWidth, _cursorHeight;
byte _cursorAnimate, _cursorAnimateIndex, _grabbedCursor[2048];
int8 _cursorState;
+ byte _currentCursor;
byte _newEffect, _switchRoomEffect2, _switchRoomEffect;
bool _doEffect;
Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- scummvm.cpp 3 Dec 2002 23:53:42 -0000 1.87
+++ scummvm.cpp 4 Dec 2002 13:36:27 -0000 1.88
@@ -311,7 +311,7 @@
_talkDelay = 0;
_keepText = false;
- gdi._currentCursor = 0;
+ _currentCursor = 0;
_cursorState = 0;
_userPut = 0;
Index: string.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/string.cpp,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- string.cpp 29 Nov 2002 18:27:35 -0000 1.51
+++ string.cpp 4 Dec 2002 13:36:27 -0000 1.52
@@ -1023,10 +1023,14 @@
if (vs->number == 0 && _blitAlso == 0)
_hasMask = true;
+ byte *_backbuff_ptr;
+ byte *_mask_ptr;
+ byte *_dest_ptr;
+
_dest_ptr = _backbuff_ptr = vs->screenPtr + vs->xstart + _drawTop * _vm->_realWidth + _left;
if (_blitAlso) {
- _dest_ptr = _bgbak_ptr = _vm->getResourceAddress(rtBuffer, vs->number + 5)
+ _dest_ptr = _vm->getResourceAddress(rtBuffer, vs->number + 5)
+ vs->xstart + _drawTop * _vm->_realWidth + _left;
}
@@ -1036,10 +1040,10 @@
_virtScreenHeight = vs->height;
_charPtr += 4;
- drawBits();
+ drawBits(_dest_ptr, _mask_ptr);
if (_blitAlso)
- _vm->blit(_backbuff_ptr, _bgbak_ptr, _width, _height);
+ _vm->blit(_backbuff_ptr, _dest_ptr, _width, _height);
_left += _width;
if (_left > _strRight)
@@ -1051,10 +1055,10 @@
_top -= _offsY;
}
-void CharsetRenderer::drawBits()
+void CharsetRenderer::drawBits(byte *dst, byte *mask)
{
bool usemask;
- byte *dst, *mask, maskmask;
+ byte maskmask;
int y, x;
int maskpos;
int color;
@@ -1065,8 +1069,6 @@
bits = *_charPtr++;
numbits = 8;
- dst = _dest_ptr;
- mask = _mask_ptr;
y = 0;
for (y = 0; y < _height && y + _drawTop < _virtScreenHeight;) {
@@ -1092,7 +1094,7 @@
maskpos++;
}
}
- dst = (_dest_ptr += _vm->_realWidth);
+ dst += _vm->_realWidth - _width;
mask += _vm->gdi._numStrips;
y++;
}
More information about the Scummvm-git-logs
mailing list