diff options
author | Max Horn | 2004-01-08 21:21:40 +0000 |
---|---|---|
committer | Max Horn | 2004-01-08 21:21:40 +0000 |
commit | 04b002bbaaef75f45c2fb962dbbce23db53116e7 (patch) | |
tree | d21d5b51f4e0bebb87f62e6e5599b5321e47cfad | |
parent | ebecf1dbaa0284f22a053e5b2e9510d6e6db4fdf (diff) | |
download | scummvm-rg350-04b002bbaaef75f45c2fb962dbbce23db53116e7.tar.gz scummvm-rg350-04b002bbaaef75f45c2fb962dbbce23db53116e7.tar.bz2 scummvm-rg350-04b002bbaaef75f45c2fb962dbbce23db53116e7.zip |
move the charset mask to the charset renderer class; some other related changes
svn-id: r12263
-rw-r--r-- | scumm/actor.cpp | 2 | ||||
-rw-r--r-- | scumm/camera.cpp | 10 | ||||
-rw-r--r-- | scumm/charset.h | 11 | ||||
-rw-r--r-- | scumm/gfx.cpp | 50 | ||||
-rw-r--r-- | scumm/gfx.h | 2 | ||||
-rw-r--r-- | scumm/saveload.cpp | 4 | ||||
-rw-r--r-- | scumm/script_v6.cpp | 2 | ||||
-rw-r--r-- | scumm/scumm.h | 24 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 8 | ||||
-rw-r--r-- | scumm/string.cpp | 18 |
10 files changed, 78 insertions, 53 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp index 7eb0f80bef..1f827bf960 100644 --- a/scumm/actor.cpp +++ b/scumm/actor.cpp @@ -1190,7 +1190,7 @@ void ScummEngine::stopTalk() { VAR(VAR_TALK_ACTOR) = 0xFF; } _keepText = false; - restoreCharsetBg(); + _charset->restoreCharsetBg(); } void ScummEngine::clearMsgQueue() { diff --git a/scumm/camera.cpp b/scumm/camera.cpp index bf2f23ab46..d6e0b17b65 100644 --- a/scumm/camera.cpp +++ b/scumm/camera.cpp @@ -347,12 +347,12 @@ void ScummEngine::cameraMoved() { // When talking to Rusty for first time // When sleeping in straw at Blacksmith's Guild. if ((_gameId == GID_LOOM256 || _gameId == GID_PASS) && dx) - gdi._mask.left -= 8; + _charset->_mask.left -= 8; else if (dx || dy) { - gdi._mask.left -= dx; - gdi._mask.right -= dx; - gdi._mask.top -= dy; - gdi._mask.bottom -= dy; + _charset->_mask.left -= dx; + _charset->_mask.right -= dx; + _charset->_mask.top -= dy; + _charset->_mask.bottom -= dy; } } } diff --git a/scumm/charset.h b/scumm/charset.h index 056fd967ef..4a7e1009d9 100644 --- a/scumm/charset.h +++ b/scumm/charset.h @@ -32,6 +32,13 @@ struct VirtScreen; class CharsetRenderer { public: + + /** + * Charset mask - rectangle covering the parts of the screen which are + * currently (partially) masked. + */ + Common::Rect _mask; + Common::Rect _str; int _nextLeft, _nextTop; @@ -62,6 +69,10 @@ public: CharsetRenderer(ScummEngine *vm); virtual ~CharsetRenderer() {} + void restoreCharsetBg(); + void clearCharsetMask(); + bool hasCharsetMask(int left, int top, int right, int bottom); + virtual void printChar(int chr) = 0; int getStringWidth(int a, const byte *str); diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index 5044ad9f0e..adbbc8a3ec 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -542,20 +542,6 @@ void ScummEngine::redrawBGStrip(int start, int num) { &virtscr[0], s, 0, _roomWidth, virtscr[0].height, s, num, 0, _roomStrips); } -void ScummEngine::restoreCharsetBg() { - if (_charset->_hasMask) { - restoreBG(gdi._mask); - _charset->_hasMask = false; - gdi._mask.top = gdi._mask.left = 32767; - gdi._mask.right = gdi._mask.bottom = 0; - _charset->_str.left = -1; - _charset->_left = -1; - } - - _charset->_nextLeft = _string[0].xpos; - _charset->_nextTop = _string[0].ypos; -} - void ScummEngine::restoreBG(Common::Rect rect, byte backColor) { VirtScreen *vs; int topline, height, width; @@ -589,7 +575,7 @@ void ScummEngine::restoreBG(Common::Rect rect, byte backColor) { width = rect.width(); // Check whether lights are turned on or not - lightsOn = (_features & GF_NEW_OPCODES) || (vs->number != kMainVirtScreen) || (VAR(VAR_CURRENT_LIGHTS) & LIGHTMODE_screen); + lightsOn = isLightOn(); if (vs->hasTwoBuffers && _currentRoom != 0 && lightsOn ) { blit(backbuff, vs->backBuf + offset, width, height); @@ -621,16 +607,30 @@ void ScummEngine::restoreBG(Common::Rect rect, byte backColor) { } } -void Gdi::clearCharsetMask() { - memset(_vm->getResourceAddress(rtBuffer, 9), 0, _imgBufOffs[1]); +void CharsetRenderer::restoreCharsetBg() { + if (_hasMask) { + _vm->restoreBG(_mask); + _hasMask = false; + _mask.top = _mask.left = 32767; + _mask.right = _mask.bottom = 0; + _str.left = -1; + _left = -1; + } + + _nextLeft = _vm->_string[0].xpos; + _nextTop = _vm->_string[0].ypos; +} + +void CharsetRenderer::clearCharsetMask() { + memset(_vm->getResourceAddress(rtBuffer, 9), 0, _vm->gdi._imgBufOffs[1]); _mask.top = _mask.left = 32767; _mask.right = _mask.bottom = 0; } -bool ScummEngine::hasCharsetMask(int left, int top, int right, int bottom) { +bool CharsetRenderer::hasCharsetMask(int left, int top, int right, int bottom) { Common::Rect rect(left, top, right, bottom); - return _charset->_hasMask && rect.intersects(gdi._mask); + return _hasMask && rect.intersects(_mask); } byte *ScummEngine::getMaskBuffer(int x, int y, int z) { @@ -814,6 +814,10 @@ void ScummEngine::drawFlashlight() { _flashlight.isDrawn = true; } +bool ScummEngine::isLightOn() const { + return (VAR_CURRENT_LIGHTS == 0xFF) || (VAR(VAR_CURRENT_LIGHTS) & LIGHTMODE_screen); +} + #pragma mark - #pragma mark --- Image drawing --- #pragma mark - @@ -841,7 +845,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int wi bool useOrDecompress = false; // Check whether lights are turned on or not - lightsOn = (_vm->_features & GF_NEW_OPCODES) || (vs->number != kMainVirtScreen) || (_vm->VAR(_vm->VAR_CURRENT_LIGHTS) & LIGHTMODE_screen); + lightsOn = _vm->isLightOn(); CHECK_HEAP; if (_vm->_features & GF_SMALL_HEADER) @@ -1077,7 +1081,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int wi CHECK_HEAP; if (vs->hasTwoBuffers) { - if (_vm->hasCharsetMask(sx * 8, y, (sx + 1) * 8, bottom)) { + if (_vm->_charset->hasCharsetMask(sx * 8, y, (sx + 1) * 8, bottom)) { if (flag & dbClear || !lightsOn) clear8ColWithMasking(backbuff_ptr, height, mask_ptr); else @@ -1213,8 +1217,8 @@ void Gdi::resetBackground(int top, int bottom, int strip) { numLinesToProcess = bottom - top; if (numLinesToProcess) { - if ((_vm->_features & GF_NEW_OPCODES) || (_vm->VAR(_vm->VAR_CURRENT_LIGHTS) & LIGHTMODE_screen)) { - if (_vm->hasCharsetMask(strip * 8, top, (strip + 1) * 8, bottom)) + if (_vm->isLightOn()) { + if (_vm->_charset->hasCharsetMask(strip * 8, top, (strip + 1) * 8, bottom)) draw8ColWithMasking(backbuff_ptr, bgbak_ptr, numLinesToProcess, mask_ptr); else draw8Col(backbuff_ptr, bgbak_ptr, numLinesToProcess); diff --git a/scumm/gfx.h b/scumm/gfx.h index 9c0019187a..04d7c80591 100644 --- a/scumm/gfx.h +++ b/scumm/gfx.h @@ -213,7 +213,6 @@ public: int _numZBuffer; int _imgBufOffs[8]; int32 _numStrips; - Common::Rect _mask; byte _C64Colors[4]; Gdi(ScummEngine *vm); @@ -266,7 +265,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, StripTable *table = 0); StripTable *generateStripTable(const byte *src, int width, int height, StripTable *table); - void clearCharsetMask(); void disableZBuffer() { _zbufferDisabled = true; } void enableZBuffer() { _zbufferDisabled = false; } diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index c7467a5be5..2972644c97 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -216,8 +216,8 @@ bool ScummEngine::loadState(int slot, bool compat, SaveFileManager *mgr) { _completeScreenRedraw = true; // Reset charset mask - gdi._mask.top = gdi._mask.left = 32767; - gdi._mask.right = gdi._mask.bottom = 0; + _charset->_mask.top = _charset->_mask.left = 32767; + _charset->_mask.right = _charset->_mask.bottom = 0; _charset->_hasMask = false; // With version 22, we replaced the scale items with scale slots. So when diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index da9f32f7ff..53af8c0553 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -2619,7 +2619,7 @@ void ScummEngine_v6::o6_kernelSetFunctions() { createSpecialPalette(args[1], args[2], args[3], args[4], args[5], 0, 256); break; case 110: - gdi.clearCharsetMask(); + _charset->clearCharsetMask(); break; case 111: a = derefActor(args[1], "o6_kernelSetFunctions: 111"); diff --git a/scumm/scumm.h b/scumm/scumm.h index 29072a4bef..145e268506 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -246,6 +246,8 @@ class ScummEngine : public Engine { friend class ScummDebugger; friend class SmushPlayer; friend class Insane; + friend class CharsetRenderer; + void errorString(const char *buf_input, char *buf_output); public: /* Put often used variables at the top. @@ -371,6 +373,13 @@ public: } return _scummVars[var]; } + int32 scummVar(byte var, const char *varName, const char *file, int line) const + { + if (var == 0xFF) { + warning("Illegal access to variable %s in file %s, line %d", varName, file, line); + } + return _scummVars[var]; + } protected: int16 _varwatch; @@ -765,6 +774,8 @@ protected: uint32 _CLUT_offs; uint32 _IM00_offs, _PALS_offs; + StripTable *_roomStrips; + //ender: fullscreen bool _fullRedraw, _BgNeedsRedraw, _verbRedraw; bool _screenEffectFlag, _completeScreenRedraw; @@ -787,8 +798,10 @@ protected: bool isDrawn; } _flashlight; - StripTable *_roomStrips; - +public: + bool isLightOn() const; + +protected: void initScreens(int b, int h); void initVirtScreen(VirtScreenNumber slot, int number, int top, int width, int height, bool twobufs, bool scrollable); void initBGBuffers(int height); @@ -1005,7 +1018,9 @@ protected: bool areBoxesNeighbours(int i, int j); /* String class */ +public: CharsetRenderer *_charset; +protected: byte _charsetColor; public: byte _charsetColorMap[16]; @@ -1018,10 +1033,7 @@ protected: protected: void initCharset(int charset); - void restoreCharsetBg(); -public: - bool hasCharsetMask(int left, int top, int right, int bottom); -protected: + void CHARSET_1(); void drawString(int a); const byte *addMessageToStack(const byte *msg); diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index f55d05eb30..a1274a6d61 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -1086,7 +1086,7 @@ void ScummEngine::scummInit() { virtscr[0].xstart = 0; - if (!(_features & GF_NEW_OPCODES)) { + if (VAR_CURRENT_LIGHTS != 0xFF) { // Setup light _flashlight.xStrips = 7; _flashlight.yStrips = 7; @@ -1222,7 +1222,7 @@ void ScummEngine::initScummVars() { VAR(39) = 320; } - if (!(_features & GF_NEW_OPCODES)) { + if (VAR_CURRENT_LIGHTS != 0xFF) { // Setup light VAR(VAR_CURRENT_LIGHTS) = LIGHTMODE_actor_base | LIGHTMODE_actor_color | LIGHTMODE_screen; } @@ -1426,7 +1426,7 @@ load_game: if (_completeScreenRedraw) { _completeScreenRedraw = false; - gdi.clearCharsetMask(); + _charset->clearCharsetMask(); _charset->_hasMask = false; // HACK as in game save stuff isn't supported currently @@ -1499,7 +1499,7 @@ load_game: setActorRedrawFlags(); resetActorBgs(); - if (!(_features & GF_NEW_OPCODES) && + if (VAR_CURRENT_LIGHTS != 0xFF && !(VAR(VAR_CURRENT_LIGHTS) & LIGHTMODE_screen) && VAR(VAR_CURRENT_LIGHTS) & LIGHTMODE_flashlight) { drawFlashlight(); diff --git a/scumm/string.cpp b/scumm/string.cpp index 5757e95fde..de5bd9fb72 100644 --- a/scumm/string.cpp +++ b/scumm/string.cpp @@ -160,7 +160,7 @@ void ScummEngine::CHARSET_1() { _charsetColorMap[i] = _charsetData[_charset->getCurID()][i]; if (_keepText) { - _charset->_str = gdi._mask; + _charset->_str = _charset->_mask; } if (_talkDelay) @@ -198,14 +198,14 @@ void ScummEngine::CHARSET_1() { if (!_keepText) { if (_version <= 3 && _gameId != GID_LOOM) { _charset->_hasMask = true; - gdi._mask.left = _string[0].xpos; - gdi._mask.top = _string[0].ypos; - gdi._mask.bottom = _string[0].ypos + 8; - gdi._mask.right = _screenWidth; + _charset->_mask.left = _string[0].xpos; + _charset->_mask.top = _string[0].ypos; + _charset->_mask.bottom = _string[0].ypos + 8; + _charset->_mask.right = _screenWidth; if (_string[0].ypos <= 16) // If we are cleaning the text line, clean 2 lines. - gdi._mask.bottom = 16; + _charset->_mask.bottom = 16; } - restoreCharsetBg(); + _charset->restoreCharsetBg(); } t = _charset->_right - _string[0].xpos - 1; @@ -353,7 +353,7 @@ void ScummEngine::CHARSET_1() { _charsetBufPos = buffer - _charsetBuffer; _charset->_hasMask = (_charset->_str.left != -1); - gdi._mask = _charset->_str; + _charset->_mask = _charset->_str; } void ScummEngine::drawString(int a) { @@ -483,7 +483,7 @@ warning("Would have set _charset->_blitAlso = true (wanted to print '%c' = %d\n" if (_version >= 7) { _charset->_hasMask = true; - gdi._mask.extend(_charset->_str); + _charset->_mask.extend(_charset->_str); } } |