MADS: Fixed handling of dirty rects to copy areas to the physical screen
This commit is contained in:
parent
84fb90e7a5
commit
3f0cd4771c
18 changed files with 84 additions and 30 deletions
|
@ -23,7 +23,7 @@
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
#include "mads/mads.h"
|
#include "mads/mads.h"
|
||||||
#include "mads/graphics.h"
|
#include "mads/screen.h"
|
||||||
#include "mads/msurface.h"
|
#include "mads/msurface.h"
|
||||||
#include "mads/nebular/dialogs_nebular.h"
|
#include "mads/nebular/dialogs_nebular.h"
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include "mads/game.h"
|
#include "mads/game.h"
|
||||||
#include "mads/game_data.h"
|
#include "mads/game_data.h"
|
||||||
#include "mads/events.h"
|
#include "mads/events.h"
|
||||||
#include "mads/graphics.h"
|
#include "mads/screen.h"
|
||||||
#include "mads/msurface.h"
|
#include "mads/msurface.h"
|
||||||
#include "mads/resources.h"
|
#include "mads/resources.h"
|
||||||
#include "mads/nebular/game_nebular.h"
|
#include "mads/nebular/game_nebular.h"
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "mads/mads.h"
|
#include "mads/mads.h"
|
||||||
#include "mads/game.h"
|
#include "mads/game.h"
|
||||||
#include "mads/nebular/game_nebular.h"
|
#include "mads/nebular/game_nebular.h"
|
||||||
#include "mads/graphics.h"
|
#include "mads/screen.h"
|
||||||
#include "mads/msurface.h"
|
#include "mads/msurface.h"
|
||||||
#include "mads/resources.h"
|
#include "mads/resources.h"
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include "common/events.h"
|
#include "common/events.h"
|
||||||
#include "engines/util.h"
|
#include "engines/util.h"
|
||||||
#include "mads/mads.h"
|
#include "mads/mads.h"
|
||||||
#include "mads/graphics.h"
|
#include "mads/screen.h"
|
||||||
#include "mads/msurface.h"
|
#include "mads/msurface.h"
|
||||||
#include "mads/resources.h"
|
#include "mads/resources.h"
|
||||||
#include "mads/sound.h"
|
#include "mads/sound.h"
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include "mads/events.h"
|
#include "mads/events.h"
|
||||||
#include "mads/font.h"
|
#include "mads/font.h"
|
||||||
#include "mads/game.h"
|
#include "mads/game.h"
|
||||||
#include "mads/graphics.h"
|
#include "mads/screen.h"
|
||||||
#include "mads/msurface.h"
|
#include "mads/msurface.h"
|
||||||
#include "mads/resources.h"
|
#include "mads/resources.h"
|
||||||
#include "mads/sound.h"
|
#include "mads/sound.h"
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
#include "mads/mads.h"
|
#include "mads/mads.h"
|
||||||
#include "mads/font.h"
|
#include "mads/font.h"
|
||||||
#include "mads/graphics.h"
|
#include "mads/screen.h"
|
||||||
#include "mads/messages.h"
|
#include "mads/messages.h"
|
||||||
#include "mads/scene_data.h"
|
#include "mads/scene_data.h"
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ MODULE_OBJS := \
|
||||||
font.o \
|
font.o \
|
||||||
game.o \
|
game.o \
|
||||||
game_data.o \
|
game_data.o \
|
||||||
graphics.o \
|
|
||||||
hotspots.o \
|
hotspots.o \
|
||||||
interface.o \
|
interface.o \
|
||||||
mads.o \
|
mads.o \
|
||||||
|
@ -29,6 +28,7 @@ MODULE_OBJS := \
|
||||||
resources.o \
|
resources.o \
|
||||||
scene.o \
|
scene.o \
|
||||||
scene_data.o \
|
scene_data.o \
|
||||||
|
screen.o \
|
||||||
sequence.o \
|
sequence.o \
|
||||||
sound.o \
|
sound.o \
|
||||||
sprites.o \
|
sprites.o \
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include "engines/util.h"
|
#include "engines/util.h"
|
||||||
#include "mads/compression.h"
|
#include "mads/compression.h"
|
||||||
#include "mads/graphics.h"
|
#include "mads/screen.h"
|
||||||
#include "mads/mads.h"
|
#include "mads/mads.h"
|
||||||
#include "mads/msurface.h"
|
#include "mads/msurface.h"
|
||||||
#include "mads/resources.h"
|
#include "mads/resources.h"
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
#include "mads/mads.h"
|
#include "mads/mads.h"
|
||||||
#include "mads/graphics.h"
|
#include "mads/screen.h"
|
||||||
#include "mads/msurface.h"
|
#include "mads/msurface.h"
|
||||||
#include "mads/nebular/dialogs_nebular.h"
|
#include "mads/nebular/dialogs_nebular.h"
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
#include "mads/mads.h"
|
#include "mads/mads.h"
|
||||||
#include "mads/game.h"
|
#include "mads/game.h"
|
||||||
#include "mads/graphics.h"
|
#include "mads/screen.h"
|
||||||
#include "mads/msurface.h"
|
#include "mads/msurface.h"
|
||||||
#include "mads/nebular/game_nebular.h"
|
#include "mads/nebular/game_nebular.h"
|
||||||
#include "mads/nebular/dialogs_nebular.h"
|
#include "mads/nebular/dialogs_nebular.h"
|
||||||
|
|
|
@ -438,7 +438,7 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
|
||||||
_dirtyAreas.merge(1, DIRTY_AREAS_SIZE);
|
_dirtyAreas.merge(1, DIRTY_AREAS_SIZE);
|
||||||
|
|
||||||
// Copy dirty areas to the main display surface
|
// Copy dirty areas to the main display surface
|
||||||
_dirtyAreas.copy(&_vm->_screen, &_backgroundSurface, _posAdjust);
|
_dirtyAreas.copy(&_backgroundSurface, &_vm->_screen, _posAdjust);
|
||||||
|
|
||||||
// Handle dirty areas for foreground objects
|
// Handle dirty areas for foreground objects
|
||||||
_spriteSlots.setDirtyAreas();
|
_spriteSlots.setDirtyAreas();
|
||||||
|
@ -463,7 +463,7 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
|
||||||
_vm->_sound->startQueuedCommands();
|
_vm->_sound->startQueuedCommands();
|
||||||
} else {
|
} else {
|
||||||
// Copy dirty areas to the screen
|
// Copy dirty areas to the screen
|
||||||
_dirtyAreas.copy(&_vm->_screen, &_backgroundSurface, _vm->_screen._offset);
|
_dirtyAreas.copyToScreen(_vm->_screen._offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
warning("TODO: sub_115A2");
|
warning("TODO: sub_115A2");
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "common/array.h"
|
#include "common/array.h"
|
||||||
#include "common/rect.h"
|
#include "common/rect.h"
|
||||||
#include "mads/assets.h"
|
#include "mads/assets.h"
|
||||||
#include "mads/graphics.h"
|
#include "mads/screen.h"
|
||||||
#include "mads/hotspots.h"
|
#include "mads/hotspots.h"
|
||||||
#include "mads/messages.h"
|
#include "mads/messages.h"
|
||||||
#include "mads/msurface.h"
|
#include "mads/msurface.h"
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "mads/scene_data.h"
|
#include "mads/scene_data.h"
|
||||||
#include "mads/mads.h"
|
#include "mads/mads.h"
|
||||||
#include "mads/compression.h"
|
#include "mads/compression.h"
|
||||||
#include "mads/graphics.h"
|
#include "mads/screen.h"
|
||||||
#include "mads/resources.h"
|
#include "mads/resources.h"
|
||||||
#include "mads/nebular/nebular_scenes.h"
|
#include "mads/nebular/nebular_scenes.h"
|
||||||
|
|
||||||
|
@ -276,7 +276,20 @@ void DirtyAreas::mergeAreas(int idx1, int idx2) {
|
||||||
da1._textActive = true;
|
da1._textActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirtyAreas::copy(MSurface *dest, MSurface *src, const Common::Point &posAdjust) {
|
void DirtyAreas::copy(MSurface *srcSurface, MSurface *destSurface, const Common::Point &posAdjust) {
|
||||||
|
for (uint i = 0; i < size(); ++i) {
|
||||||
|
const Common::Rect &srcBounds = (*this)[i]._bounds;
|
||||||
|
|
||||||
|
Common::Rect bounds(srcBounds.left + posAdjust.x, srcBounds.top + posAdjust.y,
|
||||||
|
srcBounds.right + posAdjust.x, srcBounds.bottom + posAdjust.y);
|
||||||
|
|
||||||
|
if ((*this)[i]._active && bounds.isValidRect()) {
|
||||||
|
srcSurface->copyTo(destSurface, bounds, Common::Point(bounds.left, bounds.top));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DirtyAreas::copyToScreen(const Common::Point &posAdjust) {
|
||||||
for (uint i = 0; i < size(); ++i) {
|
for (uint i = 0; i < size(); ++i) {
|
||||||
const Common::Rect &srcBounds = (*this)[i]._bounds;
|
const Common::Rect &srcBounds = (*this)[i]._bounds;
|
||||||
|
|
||||||
|
@ -284,8 +297,7 @@ void DirtyAreas::copy(MSurface *dest, MSurface *src, const Common::Point &posAdj
|
||||||
srcBounds.right + posAdjust.x, srcBounds.bottom + posAdjust.y);
|
srcBounds.right + posAdjust.x, srcBounds.bottom + posAdjust.y);
|
||||||
|
|
||||||
if ((*this)[i]._active && (*this)[i]._bounds.isValidRect()) {
|
if ((*this)[i]._active && (*this)[i]._bounds.isValidRect()) {
|
||||||
src->copyTo(dest, bounds, Common::Point((*this)[i]._bounds.left,
|
_vm->_screen.copyRectToScreen(bounds);
|
||||||
(*this)[i]._bounds.top));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,21 @@ public:
|
||||||
|
|
||||||
bool intersects(int idx1, int idx2);
|
bool intersects(int idx1, int idx2);
|
||||||
void mergeAreas(int idx1, int idx2);
|
void mergeAreas(int idx1, int idx2);
|
||||||
void copy(MSurface *dest, MSurface *src, const Common::Point &posAdjust);
|
|
||||||
|
/**
|
||||||
|
* Copy the data specified by the dirty rect list between surfaces
|
||||||
|
* @param srcSurface Source surface
|
||||||
|
* @param destSurface Dest surface
|
||||||
|
* @param posAdjust Position adjustment
|
||||||
|
*/
|
||||||
|
void copy(MSurface *srcSurface, MSurface *destSurface, const Common::Point &posAdjust);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use the lsit of dirty areas to copy areas of the screen surface to
|
||||||
|
* the physical screen
|
||||||
|
* @param posAdjust Position adjustment */
|
||||||
|
void copyToScreen(const Common::Point &posAdjust);
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,17 +23,32 @@
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
#include "mads/mads.h"
|
#include "mads/mads.h"
|
||||||
#include "mads/game.h"
|
#include "mads/game.h"
|
||||||
#include "mads/graphics.h"
|
#include "mads/screen.h"
|
||||||
#include "mads/palette.h"
|
#include "mads/palette.h"
|
||||||
|
|
||||||
namespace MADS {
|
namespace MADS {
|
||||||
|
|
||||||
|
ScreenSurface::ScreenSurface() {
|
||||||
|
_dataP = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenSurface::init() {
|
void ScreenSurface::init() {
|
||||||
setSize(g_system->getWidth(), g_system->getHeight());
|
setSize(g_system->getWidth(), g_system->getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenSurface::copyRectToScreen(const Common::Point &destPos,
|
||||||
|
const Common::Rect &bounds) {
|
||||||
|
byte *buf = getBasePtr(destPos.x, destPos.y);
|
||||||
|
g_system->copyRectToScreen(buf, this->pitch, bounds.left, bounds.top,
|
||||||
|
bounds.width(), bounds.height());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSurface::copyRectToScreen(const Common::Rect &bounds) {
|
||||||
|
copyRectToScreen(Common::Point(bounds.left, bounds.top), bounds);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ScreenSurface::updateScreen() {
|
void ScreenSurface::updateScreen() {
|
||||||
g_system->copyRectToScreen((const byte *)pixels, pitch, 0, 0, w, h);
|
|
||||||
g_system->updateScreen();
|
g_system->updateScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,8 +90,7 @@ void ScreenSurface::transition(ScreenTransition transitionType, bool surfaceFlag
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSurface::setPointer(MSurface *s) {
|
void ScreenSurface::setPointer(MSurface *s) {
|
||||||
_pixels = s->getData();
|
_dataP = s->getData();
|
||||||
_pitch = s->w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSurface::fadeOut() {
|
void ScreenSurface::fadeOut() {
|
||||||
|
@ -86,6 +100,7 @@ void ScreenSurface::fadeOut() {
|
||||||
void ScreenSurface::fadeIn() {
|
void ScreenSurface::fadeIn() {
|
||||||
warning("TODO: Proper fade in");
|
warning("TODO: Proper fade in");
|
||||||
_vm->_palette->setFullPalette(_vm->_palette->_mainPalette);
|
_vm->_palette->setFullPalette(_vm->_palette->_mainPalette);
|
||||||
|
_vm->_screen.copyRectToScreen(Common::Rect(0, 0, 320, 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace MADS
|
} // End of namespace MADS
|
|
@ -20,8 +20,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MADS_GRAPHICS_H
|
#ifndef MADS_SCREEN_H
|
||||||
#define MADS_GRAPHICS_H
|
#define MADS_SCREEN_H
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
#include "common/array.h"
|
#include "common/array.h"
|
||||||
|
@ -58,13 +58,12 @@ private:
|
||||||
void fadeIn();
|
void fadeIn();
|
||||||
public:
|
public:
|
||||||
Common::Point _offset;
|
Common::Point _offset;
|
||||||
byte *_pixels;
|
byte *_dataP;
|
||||||
int _pitch;
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
ScreenSurface() {}
|
ScreenSurface();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise the surface
|
* Initialise the surface
|
||||||
|
@ -73,6 +72,20 @@ public:
|
||||||
|
|
||||||
void setPointer(MSurface *s);
|
void setPointer(MSurface *s);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copys an area of the screen surface to a given destination position on
|
||||||
|
* the ScummVM physical screen buffer
|
||||||
|
* @param destPos Destination position
|
||||||
|
* @param bounds Area of screen surface to copy
|
||||||
|
*/
|
||||||
|
void copyRectToScreen(const Common::Point &destPos, const Common::Rect &bounds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copys an area of the screen surface to the ScmmVM physical screen buffer
|
||||||
|
* @param bounds Area of screen surface to copy
|
||||||
|
*/
|
||||||
|
void copyRectToScreen(const Common::Rect &bounds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the screen with the contents of the surface
|
* Updates the screen with the contents of the surface
|
||||||
*/
|
*/
|
||||||
|
@ -83,4 +96,4 @@ public:
|
||||||
|
|
||||||
} // End of namespace MADS
|
} // End of namespace MADS
|
||||||
|
|
||||||
#endif /* MADS_GRAPHICS_H */
|
#endif /* MADS_SCREEN_H */
|
|
@ -24,7 +24,7 @@
|
||||||
#include "engines/util.h"
|
#include "engines/util.h"
|
||||||
#include "graphics/palette.h"
|
#include "graphics/palette.h"
|
||||||
#include "mads/mads.h"
|
#include "mads/mads.h"
|
||||||
#include "mads/graphics.h"
|
#include "mads/screen.h"
|
||||||
#include "mads/msurface.h"
|
#include "mads/msurface.h"
|
||||||
#include "mads/sprites.h"
|
#include "mads/sprites.h"
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
#include "mads/mads.h"
|
#include "mads/mads.h"
|
||||||
#include "mads/graphics.h"
|
#include "mads/screen.h"
|
||||||
#include "mads/user_interface.h"
|
#include "mads/user_interface.h"
|
||||||
#include "mads/msurface.h"
|
#include "mads/msurface.h"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue