diff options
-rw-r--r-- | scumm/gfx.cpp | 24 | ||||
-rw-r--r-- | scumm/gfx.h | 17 | ||||
-rw-r--r-- | scumm/object.cpp | 11 | ||||
-rw-r--r-- | scumm/scumm.h | 2 | ||||
-rw-r--r-- | scumm/verbs.cpp | 6 |
5 files changed, 30 insertions, 30 deletions
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index 064282b38a..7d814d0c2c 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -540,10 +540,10 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i } if (_renderMode == Common::kRenderCGA) - gdi.ditherCGA(_compositeBuf + x + y * _screenWidth, _screenWidth, x, y, width, height); + ditherCGA(_compositeBuf + x + y * _screenWidth, _screenWidth, x, y, width, height); if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { - gdi.ditherHerc(_compositeBuf + x + y * _screenWidth, _herculesBuf, _screenWidth, &x, &y, &width, &height); + ditherHerc(_compositeBuf + x + y * _screenWidth, _herculesBuf, _screenWidth, &x, &y, &width, &height); // center image on the screen _system->copyRectToScreen(_herculesBuf + x + y * Common::kHercW, Common::kHercW, x + (Common::kHercW - _screenWidth * 2) / 2, y, width, height); @@ -575,7 +575,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i // CGA dithers 4x4 square with direct substitutes // Odd lines have colors swapped, so there will be checkered patterns. // But apparently there is a mistake for 10th color. -void Gdi::ditherCGA(byte *dst, int dstPitch, int x, int y, int width, int height) const { +void ScummEngine::ditherCGA(byte *dst, int dstPitch, int x, int y, int width, int height) const { byte *ptr; int idx1, idx2; static const byte cgaDither[2][2][16] = { @@ -589,7 +589,7 @@ void Gdi::ditherCGA(byte *dst, int dstPitch, int x, int y, int width, int height idx1 = (y + y1) % 2; - if (_vm->_version == 2) + if (_version == 2) idx1 = 0; for (int x1 = 0; x1 < width; x1++) { @@ -608,7 +608,7 @@ void Gdi::ditherCGA(byte *dst, int dstPitch, int x, int y, int width, int height // dd cccc0 // cccc1 // dddd0 -void Gdi::ditherHerc(byte *src, byte *hercbuf, int srcPitch, int *x, int *y, int *width, int *height) const { +void ScummEngine::ditherHerc(byte *src, byte *hercbuf, int srcPitch, int *x, int *y, int *width, int *height) const { byte *srcptr, *dstptr; int xo = *x, yo = *y, widtho = *width, heighto = *height; int idx1, idx2, dsty = 0, y1; @@ -813,9 +813,7 @@ void ScummEngine::redrawBGStrip(int start, int num) { else room = getResourceAddress(rtRoom, _roomResource); - gdi._objectMode = false; - gdi.drawBitmap(room + _IM00_offs, - &virtscr[0], s, 0, _roomWidth, virtscr[0].h, s, num, 0); + gdi.drawBitmap(room + _IM00_offs, &virtscr[0], s, 0, _roomWidth, virtscr[0].h, s, num, 0); } void ScummEngine::restoreBG(Common::Rect rect, byte backColor) { @@ -1340,6 +1338,16 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int wi // Check whether lights are turned on or not const bool lightsOn = _vm->isLightOn(); + _objectMode = (flag & dbObjectMode) == dbObjectMode; + + if (_objectMode && _vm->_version == 1) { + if (_vm->_features & GF_NES) { + // TODO: Maybe call decodeNESObject here? + } else { + decodeC64Gfx(ptr, _C64.objectMap, (width / 8) * (height / 8) * 3); + } + } + CHECK_HEAP; if (_vm->_features & GF_SMALL_HEADER) { smap_ptr = ptr; diff --git a/scumm/gfx.h b/scumm/gfx.h index b6238ce12b..f1ebe9ac3c 100644 --- a/scumm/gfx.h +++ b/scumm/gfx.h @@ -202,11 +202,11 @@ struct StripTable; #define CHARSET_MASK_TRANSPARENCY 253 class Gdi { - friend class ScummEngine; // Mostly for the code in saveload.cpp ... +// friend class ScummEngine; // Mostly for the code in saveload.cpp ... ScummEngine *_vm; public: - + byte _transparentColor; int _numZBuffer; int _imgBufOffs[8]; int32 _numStrips; @@ -217,7 +217,6 @@ public: protected: byte *_roomPalette; byte _decomp_shr, _decomp_mask; - byte _transparentColor; uint32 _vertStripNextInc; bool _zbufferDisabled; @@ -270,11 +269,8 @@ protected: void decompressMaskImg(byte *dst, const byte *src, int height) const; /* Misc */ - void ditherCGA(byte *dst, int dstPitch, int x, int y, int width, int height) const; - void ditherHerc(byte *src, byte *hercbuf, int srcPitch, int *x, int *y, int *width, int *height) const; + void decodeC64Gfx(const byte *src, byte *dst, int size) const; - byte *getMaskBuffer(int x, int y, int z); - int getZPlanes(const byte *smap_ptr, const byte *zplane_list[9], bool bmapImage) const; StripTable *generateStripTable(const byte *src, int width, int height, StripTable *table) const; @@ -288,7 +284,6 @@ public: void drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int width, const int height, int stripnr, int numstrip, byte flag); - void decodeC64Gfx(const byte *src, byte *dst, int size) const; void decodeNESGfx(const byte *room); void decodeNESObject(const byte *ptr, int xpos, int ypos, int width, int height); @@ -297,14 +292,16 @@ public: void copyVirtScreenBuffers(Common::Rect rect); + byte *getMaskBuffer(int x, int y, int z); void disableZBuffer() { _zbufferDisabled = true; } void enableZBuffer() { _zbufferDisabled = false; } void resetBackground(int top, int bottom, int strip); enum DrawBitmapFlags { - dbAllowMaskOr = 1, - dbDrawMaskOnAll = 2 + dbAllowMaskOr = 1 << 0, + dbDrawMaskOnAll = 1 << 1, + dbObjectMode = 2 << 2 }; }; diff --git a/scumm/object.cpp b/scumm/object.cpp index af145f796c..f406b36158 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -433,7 +433,7 @@ void ScummEngine::drawObject(int obj, int arg) { return; ObjectData &od = _objs[obj]; - int xpos, ypos, height, width; + int height, width; const byte *ptr; int x, a, numstrip; int tmp; @@ -446,8 +446,8 @@ void ScummEngine::drawObject(int obj, int arg) { checkRange(_numGlobalObjects - 1, 0, od.obj_nr, "Object %d out of range in drawObject"); - xpos = od.x_pos / 8; - ypos = od.y_pos; + const int xpos = od.x_pos / 8; + const int ypos = od.y_pos; width = od.width / 8; height = od.height &= 0xFFFFFFF8; // Mask out last 3 bits @@ -483,14 +483,11 @@ void ScummEngine::drawObject(int obj, int arg) { } if (numstrip != 0) { - byte flags = od.flags; + byte flags = od.flags | Gdi::dbObjectMode; - gdi._objectMode = true; if (_version == 1) { if (_features & GF_NES) { gdi.decodeNESObject(ptr, xpos, ypos, width, height); - } else { - gdi.decodeC64Gfx(ptr, gdi._C64.objectMap, width * (height / 8) * 3); } } // Sam & Max needs this to fix object-layering problems with diff --git a/scumm/scumm.h b/scumm/scumm.h index eed39e4b91..fafaa37c33 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -983,6 +983,8 @@ protected: void drawDirtyScreenParts(); void updateDirtyScreen(VirtScreenNumber slot); void drawStripToScreen(VirtScreen *vs, int x, int w, int t, int b); + void ditherCGA(byte *dst, int dstPitch, int x, int y, int width, int height) const; + void ditherHerc(byte *src, byte *hercbuf, int srcPitch, int *x, int *y, int *width, int *height) const; public: VirtScreen *findVirtScreen(int y); diff --git a/scumm/verbs.cpp b/scumm/verbs.cpp index 154e6d9093..80b4517159 100644 --- a/scumm/verbs.cpp +++ b/scumm/verbs.cpp @@ -578,13 +578,9 @@ void ScummEngine::drawVerbBitmap(int verb, int x, int y) { imptr = getObjectImage(obim, 1); } assert(imptr); - if (_version == 1) { - gdi._objectMode = true; - gdi.decodeC64Gfx(imptr, gdi._C64.objectMap, imgw * imgh * 3); - } for (i = 0; i < imgw; i++) { tmp = xstrip + i; - gdi.drawBitmap(imptr, vs, tmp, ydiff, imgw * 8, imgh * 8, i, 1, Gdi::dbAllowMaskOr); + gdi.drawBitmap(imptr, vs, tmp, ydiff, imgw * 8, imgh * 8, i, 1, Gdi::dbAllowMaskOr | Gdi::dbObjectMode); } vst = &_verbs[verb]; |