Unified
Split
Showing
with
82 additions
and 106 deletions.
- +13 −5 engines/zvision/core/events.cpp
- +21 −77 engines/zvision/graphics/render_manager.cpp
- +5 −12 engines/zvision/graphics/render_manager.h
- +12 −0 engines/zvision/scripting/actions.cpp
- +2 −8 engines/zvision/scripting/sidefx/animation_node.cpp
- +4 −3 engines/zvision/text/text.cpp
- +18 −1 engines/zvision/zvision.cpp
- +7 −0 engines/zvision/zvision.h
| @@ -158,15 +158,18 @@ void ZVision::cheatCodes(uint8 key) { | ||
| } | ||
| } | ||
|
|
||
| if (checkCode("FRAME")) | ||
| _renderManager->showDebugMsg(Common::String::format("FPS: ???, not implemented")); | ||
| if (checkCode("FRAME")) { | ||
| Common::String fpsStr = Common::String::format("FPS: %d", getFPS()); | ||
| _renderManager->showDebugMsg(fpsStr); | ||
| } | ||
|
|
||
| if (checkCode("COMPUTERARCH")) | ||
| _renderManager->showDebugMsg("COMPUTERARCH: var-viewer not implemented"); | ||
|
|
||
| // This cheat essentially toggles the GOxxxx cheat below | ||
| if (checkCode("XYZZY")) | ||
| _scriptManager->setStateValue(StateKey_DebugCheats, 1 - _scriptManager->getStateValue(StateKey_DebugCheats)); | ||
|
|
||
| if (checkCode("COMPUTERARCH")) | ||
| _renderManager->showDebugMsg(Common::String::format("COMPUTERARCH: var-viewer not implemented")); | ||
|
|
||
| if (_scriptManager->getStateValue(StateKey_DebugCheats) == 1) | ||
| if (checkCode("GO????")) | ||
| _scriptManager->changeLocation(getBufferedKey(3), | ||
| @@ -240,6 +243,11 @@ void ZVision::processEvents() { | ||
| _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; | ||
| break; | ||
|
|
||
| case Common::KEYCODE_F10: { | ||
| Common::String fpsStr = Common::String::format("FPS: %d", getFPS()); | ||
| _renderManager->showDebugMsg(fpsStr); | ||
| } | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| @@ -104,7 +104,8 @@ void RenderManager::renderSceneToScreen() { | ||
| post = (*it)->draw(_currentBackgroundImage.getSubArea(rect)); | ||
| else | ||
| post = (*it)->draw(_effectSurface.getSubArea(rect)); | ||
| blitSurfaceToSurface(*post, _effectSurface, screenSpaceLocation.left, screenSpaceLocation.top); | ||
| Common::Rect empty; | ||
| blitSurfaceToSurface(*post, empty, _effectSurface, screenSpaceLocation.left, screenSpaceLocation.top); | ||
| screenSpaceLocation.clip(windowRect); | ||
| if (_backgroundSurfaceDirtyRect .isEmpty()) { | ||
| _backgroundSurfaceDirtyRect = screenSpaceLocation; | ||
| @@ -511,30 +512,12 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com | ||
| delete srcAdapted; | ||
| } | ||
|
|
||
| void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y) { | ||
| void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, int32 colorkey) { | ||
| Common::Rect empt; | ||
| blitSurfaceToSurface(src, empt, dst, x, y); | ||
| } | ||
|
|
||
| void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey) { | ||
| Common::Rect empt; | ||
| blitSurfaceToSurface(src, empt, dst, x, y, colorkey); | ||
| } | ||
|
|
||
| void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y) { | ||
| Common::Rect empt; | ||
| blitSurfaceToSurface(src, empt, _currentBackgroundImage, x, y); | ||
| Common::Rect dirty(src.w, src.h); | ||
| dirty.translate(x, y); | ||
| if (_backgroundDirtyRect.isEmpty()) | ||
| _backgroundDirtyRect = dirty; | ||
| if (colorkey >= 0) | ||
| blitSurfaceToSurface(src, empt, _currentBackgroundImage, x, y, colorkey); | ||
| else | ||
| _backgroundDirtyRect.extend(dirty); | ||
| } | ||
|
|
||
| void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, uint32 colorkey) { | ||
| Common::Rect empt; | ||
| blitSurfaceToSurface(src, empt, _currentBackgroundImage, x, y, colorkey); | ||
| blitSurfaceToSurface(src, empt, _currentBackgroundImage, x, y); | ||
| Common::Rect dirty(src.w, src.h); | ||
| dirty.translate(x, y); | ||
| if (_backgroundDirtyRect.isEmpty()) | ||
| @@ -543,23 +526,10 @@ void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, | ||
| _backgroundDirtyRect.extend(dirty); | ||
| } | ||
|
|
||
| void RenderManager::blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect) { | ||
| if (src.w == _dstRect.width() && src.h == _dstRect.height()) | ||
| blitSurfaceToBkg(src, _dstRect.left, _dstRect.top); | ||
| else { | ||
| Graphics::Surface *tmp = new Graphics::Surface; | ||
| tmp->create(_dstRect.width(), _dstRect.height(), src.format); | ||
| scaleBuffer(src.getPixels(), tmp->getPixels(), src.w, src.h, src.format.bytesPerPixel, _dstRect.width(), _dstRect.height()); | ||
| blitSurfaceToBkg(*tmp, _dstRect.left, _dstRect.top); | ||
| tmp->free(); | ||
| delete tmp; | ||
| } | ||
| } | ||
|
|
||
| void RenderManager::blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect, uint32 colorkey) { | ||
| if (src.w == _dstRect.width() && src.h == _dstRect.height()) | ||
| void RenderManager::blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect, int32 colorkey) { | ||
| if (src.w == _dstRect.width() && src.h == _dstRect.height()) { | ||
| blitSurfaceToBkg(src, _dstRect.left, _dstRect.top, colorkey); | ||
| else { | ||
| } else { | ||
| Graphics::Surface *tmp = new Graphics::Surface; | ||
| tmp->create(_dstRect.width(), _dstRect.height(), src.format); | ||
| scaleBuffer(src.getPixels(), tmp->getPixels(), src.w, src.h, src.format.bytesPerPixel, _dstRect.width(), _dstRect.height()); | ||
| @@ -569,20 +539,12 @@ void RenderManager::blitSurfaceToBkgScaled(const Graphics::Surface &src, const C | ||
| } | ||
| } | ||
|
|
||
| void RenderManager::blitSurfaceToMenu(const Graphics::Surface &src, int x, int y) { | ||
| void RenderManager::blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, int32 colorkey) { | ||
| Common::Rect empt; | ||
| blitSurfaceToSurface(src, empt, _menuSurface, x, y); | ||
| Common::Rect dirty(src.w, src.h); | ||
| dirty.translate(x, y); | ||
| if (_menuSurfaceDirtyRect.isEmpty()) | ||
| _menuSurfaceDirtyRect = dirty; | ||
| if (colorkey >= 0) | ||
| blitSurfaceToSurface(src, empt, _menuSurface, x, y, colorkey); | ||
| else | ||
| _menuSurfaceDirtyRect.extend(dirty); | ||
| } | ||
|
|
||
| void RenderManager::blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey) { | ||
| Common::Rect empt; | ||
| blitSurfaceToSurface(src, empt, _menuSurface, x, y, colorkey); | ||
| blitSurfaceToSurface(src, empt, _menuSurface, x, y); | ||
| Common::Rect dirty(src.w, src.h); | ||
| dirty.translate(x, y); | ||
| if (_menuSurfaceDirtyRect.isEmpty()) | ||
| @@ -606,28 +568,18 @@ Graphics::Surface *RenderManager::getBkgRect(Common::Rect &rect) { | ||
| return srf; | ||
| } | ||
|
|
||
| Graphics::Surface *RenderManager::loadImage(Common::String &file) { | ||
| Graphics::Surface *RenderManager::loadImage(Common::String file) { | ||
| Graphics::Surface *tmp = new Graphics::Surface; | ||
| readImageToSurface(file, *tmp); | ||
| return tmp; | ||
| } | ||
|
|
||
| Graphics::Surface *RenderManager::loadImage(const char *file) { | ||
| Common::String str = Common::String(file); | ||
| return loadImage(str); | ||
| } | ||
|
|
||
| Graphics::Surface *RenderManager::loadImage(Common::String &file, bool transposed) { | ||
| Graphics::Surface *RenderManager::loadImage(Common::String file, bool transposed) { | ||
| Graphics::Surface *tmp = new Graphics::Surface; | ||
| readImageToSurface(file, *tmp, transposed); | ||
| return tmp; | ||
| } | ||
|
|
||
| Graphics::Surface *RenderManager::loadImage(const char *file, bool transposed) { | ||
| Common::String str = Common::String(file); | ||
| return loadImage(str, transposed); | ||
| } | ||
|
|
||
| void RenderManager::prepareBackground() { | ||
| _backgroundDirtyRect.clip(_backgroundWidth, _backgroundHeight); | ||
| RenderTable::RenderState state = _renderTable.getRenderState(); | ||
| @@ -746,18 +698,9 @@ uint16 RenderManager::createSubArea(const Common::Rect &area) { | ||
| } | ||
|
|
||
| uint16 RenderManager::createSubArea() { | ||
| _subid++; | ||
|
|
||
| OneSubtitle sub; | ||
| sub.redraw = false; | ||
| sub.timer = -1; | ||
| sub.todelete = false; | ||
| sub.r = Common::Rect(_subtitleArea.left, _subtitleArea.top, _subtitleArea.right, _subtitleArea.bottom); | ||
| sub.r.translate(-_workingWindow.left, -_workingWindow.top); | ||
|
|
||
| _subsList[_subid] = sub; | ||
|
|
||
| return _subid; | ||
| Common::Rect r(_subtitleArea.left, _subtitleArea.top, _subtitleArea.right, _subtitleArea.bottom); | ||
| r.translate(-_workingWindow.left, -_workingWindow.top); | ||
| return createSubArea(r); | ||
| } | ||
|
|
||
| void RenderManager::deleteSubArea(uint16 id) { | ||
| @@ -794,7 +737,7 @@ void RenderManager::processSubs(uint16 deltatime) { | ||
| } | ||
| } | ||
|
|
||
| if (redraw) { | ||
| if (redraw && _engine->getScriptManager()->getStateValue(StateKey_Subtitles) == 1) { | ||
| _subtitleSurface.fillRect(Common::Rect(_subtitleSurface.w, _subtitleSurface.h), 0); | ||
|
|
||
| for (SubtitleMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) { | ||
| @@ -803,7 +746,8 @@ void RenderManager::processSubs(uint16 deltatime) { | ||
| Graphics::Surface *rndr = new Graphics::Surface(); | ||
| rndr->create(sub->r.width(), sub->r.height(), _engine->_resourcePixelFormat); | ||
| _engine->getTextRenderer()->drawTxtInOneLine(sub->txt, *rndr); | ||
| blitSurfaceToSurface(*rndr, _subtitleSurface, sub->r.left - _subtitleArea.left + _workingWindow.left, sub->r.top - _subtitleArea.top + _workingWindow.top); | ||
| Common::Rect empty; | ||
| blitSurfaceToSurface(*rndr, empty, _subtitleSurface, sub->r.left - _subtitleArea.left + _workingWindow.left, sub->r.top - _subtitleArea.top + _workingWindow.top); | ||
| rndr->free(); | ||
| delete rndr; | ||
| } | ||
| @@ -230,20 +230,15 @@ class RenderManager { | ||
| // Blitting surface-to-surface methods | ||
| void blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int x, int y); | ||
| void blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y, uint32 colorkey); | ||
| void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y); | ||
| void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey); | ||
|
|
||
| // Blitting surface-to-background methods | ||
| void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y); | ||
| void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, uint32 colorkey); | ||
| void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, int32 colorkey = -1); | ||
|
|
||
| // Blitting surface-to-background methods with scale | ||
| void blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect); | ||
| void blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect, uint32 colorkey); | ||
| void blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect, int32 colorkey = -1); | ||
|
|
||
| // Blitting surface-to-menu methods | ||
| void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y); | ||
| void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey); | ||
| void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, int32 colorkey = -1); | ||
|
|
||
| // Subtitles methods | ||
|
|
||
| @@ -268,10 +263,8 @@ class RenderManager { | ||
| Graphics::Surface *getBkgRect(Common::Rect &rect); | ||
|
|
||
| // Load image into new surface | ||
| Graphics::Surface *loadImage(const char *file); | ||
| Graphics::Surface *loadImage(Common::String &file); | ||
| Graphics::Surface *loadImage(const char *file, bool transposed); | ||
| Graphics::Surface *loadImage(Common::String &file, bool transposed); | ||
| Graphics::Surface *loadImage(Common::String file); | ||
| Graphics::Surface *loadImage(Common::String file, bool transposed); | ||
|
|
||
| // Clear whole/area of menu surface | ||
| void clearMenuSurface(); | ||
| @@ -566,6 +566,12 @@ ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, int32 slotkey, c | ||
| // The two %*u are usually 0 and dont seem to have a use | ||
| sscanf(line.c_str(), "%24s %*u %*u %d %d", fileName, &_mask, &_framerate); | ||
|
|
||
| // Mask 0 means "no transparency" in this case. Since we use a common blitting | ||
| // code for images and animations, we set it to -1 to avoid confusion with | ||
| // color 0, which is used as a mask in some images | ||
| if (_mask == 0) | ||
| _mask = -1; | ||
|
|
||
| _fileName = Common::String(fileName); | ||
| } | ||
|
|
||
| @@ -628,6 +634,12 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, int32 slotkey, const C | ||
| "%24s %u %u %u %u %u %u %d %*u %*u %d %d", | ||
| fileName, &_x, &_y, &_x2, &_y2, &_start, &_end, &_loopCount, &_mask, &_framerate); | ||
|
|
||
| // Mask 0 means "no transparency" in this case. Since we use a common blitting | ||
| // code for images and animations, we set it to -1 to avoid confusion with | ||
| // color 0, which is used as a mask in some images | ||
| if (_mask == 0) | ||
| _mask = -1; | ||
|
|
||
| _fileName = Common::String(fileName); | ||
| } | ||
|
|
||
| @@ -154,17 +154,11 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { | ||
|
|
||
| if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) { | ||
| Graphics::Surface *transposed = RenderManager::tranposeSurface(frame); | ||
| if (_mask > 0) | ||
| _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask); | ||
| else | ||
| _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top); | ||
| _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask); | ||
| transposed->free(); | ||
| delete transposed; | ||
| } else { | ||
| if (_mask > 0) | ||
| _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask); | ||
| else | ||
| _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top); | ||
| _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask); | ||
| } | ||
| } | ||
| } | ||
| @@ -462,15 +462,16 @@ void TextRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac | ||
| j++; | ||
| } | ||
| dx = 0; | ||
| Common::Rect empty; | ||
| for (int32 jj = 0; jj < j; jj++) { | ||
| if (TxtJustify[i] == TXT_JUSTIFY_LEFT) | ||
| _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); | ||
| _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], empty, dst, dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); | ||
|
|
||
| else if (TxtJustify[i] == TXT_JUSTIFY_CENTER) | ||
| _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, ((dst.w - width) / 2) + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); | ||
| _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], empty, dst, ((dst.w - width) / 2) + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); | ||
|
|
||
| else if (TxtJustify[i] == TXT_JUSTIFY_RIGHT) | ||
| _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dst.w - width + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); | ||
| _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], empty, dst, dst.w - width + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); | ||
|
|
||
| dx += TxtSurfaces[i][jj]->w; | ||
| } | ||
| @@ -101,7 +101,9 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) | ||
| _frameRenderDelay(2), | ||
| _keyboardVelocity(0), | ||
| _mouseVelocity(0), | ||
| _videoIsPlaying(false) { | ||
| _videoIsPlaying(false), | ||
| _renderedFrameCount(0), | ||
| _fps(0) { | ||
|
|
||
| debug(1, "ZVision::ZVision"); | ||
|
|
||
| @@ -130,6 +132,8 @@ ZVision::~ZVision() { | ||
| delete _rnd; | ||
| delete _midiManager; | ||
|
|
||
| getTimerManager()->removeTimerProc(&fpsTimerCallback); | ||
|
|
||
| // Remove all of our debug levels | ||
| DebugMan.clearAllDebugChannels(); | ||
| } | ||
| @@ -214,6 +218,9 @@ void ZVision::initialize() { | ||
| // Create debugger console. It requires GFX to be initialized | ||
| _console = new Console(this); | ||
| _doubleFPS = ConfMan.getBool("doublefps"); | ||
|
|
||
| // Initialize FPS timer callback | ||
| getTimerManager()->installTimerProc(&fpsTimerCallback, 1000000, this, "zvisionFPS"); | ||
| } | ||
|
|
||
| Common::Error ZVision::run() { | ||
| @@ -246,6 +253,7 @@ Common::Error ZVision::run() { | ||
| // Update the screen | ||
| if (canRender()) { | ||
| _system->updateScreen(); | ||
| _renderedFrameCount++; | ||
| } else { | ||
| _frameRenderDelay--; | ||
| } | ||
| @@ -291,4 +299,13 @@ bool ZVision::canRender() { | ||
| return _frameRenderDelay <= 0; | ||
| } | ||
|
|
||
| void ZVision::fpsTimerCallback(void *refCon) { | ||
| ((ZVision *)refCon)->fpsTimer(); | ||
| } | ||
|
|
||
| void ZVision::fpsTimer() { | ||
| _fps = _renderedFrameCount; | ||
| _renderedFrameCount = 0; | ||
| } | ||
|
|
||
| } // End of namespace ZVision | ||
| @@ -119,6 +119,8 @@ class ZVision : public Engine { | ||
| Common::Event _event; | ||
|
|
||
| int _frameRenderDelay; | ||
| int _renderedFrameCount; | ||
| int _fps; | ||
| int16 _mouseVelocity; | ||
| int16 _keyboardVelocity; | ||
| bool _doubleFPS; | ||
| @@ -197,6 +199,11 @@ class ZVision : public Engine { | ||
|
|
||
| void setRenderDelay(uint); | ||
| bool canRender(); | ||
| static void fpsTimerCallback(void *refCon); | ||
| void fpsTimer(); | ||
| int getFPS() const { | ||
| return _fps; | ||
| } | ||
|
|
||
| void loadSettings(); | ||
| void saveSettings(); | ||
Showing you all comments on commits in this comparison.
This comment has been minimized.
This comment has been minimized.
|
This will silence all system messages, not only subtitles. I think is better to add this check into: and simple don't load subs |
This comment has been minimized.
This comment has been minimized.
|
Thanks! Fixed |