aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/base-backend.cpp4
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp40
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp29
-rw-r--r--backends/platform/android/gfx.cpp4
-rw-r--r--backends/platform/android/texture.cpp10
-rw-r--r--backends/platform/dc/display.cpp6
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.cpp23
-rw-r--r--backends/platform/iphone/iphone_video.mm6
-rw-r--r--backends/platform/iphone/osys_main.cpp4
-rw-r--r--backends/platform/iphone/osys_video.mm22
-rw-r--r--backends/platform/n64/osys_n64_base.cpp6
-rw-r--r--backends/platform/ps2/Gs2dScreen.cpp8
-rw-r--r--backends/platform/psp/default_display_client.cpp7
-rw-r--r--backends/platform/wii/osystem_gfx.cpp11
-rw-r--r--backends/vkeybd/virtual-keyboard-gui.cpp12
-rw-r--r--common/config-manager.h1
-rw-r--r--common/ini-file.cpp (renamed from common/config-file.cpp)60
-rw-r--r--common/ini-file.h (renamed from common/config-file.h)29
-rw-r--r--common/module.mk2
-rw-r--r--engines/agos/animation.cpp8
-rw-r--r--engines/agos/charset-fontdata.cpp8
-rw-r--r--engines/agos/charset.cpp2
-rw-r--r--engines/agos/draw.cpp30
-rw-r--r--engines/agos/event.cpp2
-rw-r--r--engines/agos/gfx.cpp64
-rw-r--r--engines/agos/icons.cpp16
-rw-r--r--engines/agos/menus.cpp4
-rw-r--r--engines/agos/verb.cpp2
-rw-r--r--engines/agos/vga.cpp11
-rw-r--r--engines/agos/vga_e2.cpp10
-rw-r--r--engines/agos/vga_pn.cpp4
-rw-r--r--engines/agos/vga_s2.cpp5
-rw-r--r--engines/agos/vga_ww.cpp2
-rw-r--r--engines/agos/window.cpp4
-rw-r--r--engines/cge/cge_main.cpp2
-rw-r--r--engines/cge/vga13h.cpp6
-rw-r--r--engines/composer/composer.h4
-rw-r--r--engines/composer/graphics.cpp10
-rw-r--r--engines/draci/screen.cpp4
-rw-r--r--engines/draci/surface.cpp2
-rw-r--r--engines/drascula/graphics.cpp8
-rw-r--r--engines/gob/iniconfig.cpp4
-rw-r--r--engines/gob/iniconfig.h4
-rw-r--r--engines/gob/surface.cpp2
-rw-r--r--engines/gob/videoplayer.cpp6
-rw-r--r--engines/groovie/graphics.cpp6
-rw-r--r--engines/groovie/roq.cpp14
-rw-r--r--engines/groovie/script.cpp4
-rw-r--r--engines/groovie/vdx.cpp14
-rw-r--r--engines/hopkins/dialogs.cpp2
-rw-r--r--engines/hopkins/graphics.cpp6
-rw-r--r--engines/hopkins/saveload.cpp10
-rw-r--r--engines/hugo/dialogs.cpp4
-rw-r--r--engines/hugo/intro.cpp18
-rw-r--r--engines/kyra/gui_mr.cpp2
-rw-r--r--engines/lastexpress/data/animation.cpp2
-rw-r--r--engines/lastexpress/data/sequence.cpp12
-rw-r--r--engines/lastexpress/graphics.cpp12
-rw-r--r--engines/lure/hotspots.cpp197
-rw-r--r--engines/made/graphics.cpp4
-rw-r--r--engines/made/pmvplayer.cpp2
-rw-r--r--engines/made/screen.cpp8
-rw-r--r--engines/made/screenfx.cpp4
-rw-r--r--engines/made/scriptfuncs.cpp2
-rw-r--r--engines/mohawk/bitmap.cpp10
-rw-r--r--engines/mohawk/cursors.cpp4
-rw-r--r--engines/mohawk/livingbooks.cpp4
-rw-r--r--engines/mohawk/livingbooks.h4
-rw-r--r--engines/mohawk/livingbooks_lbx.cpp10
-rw-r--r--engines/mohawk/riven_graphics.cpp8
-rw-r--r--engines/mohawk/video.cpp2
-rw-r--r--engines/mortevielle/graphics.cpp9
-rw-r--r--engines/mortevielle/menu.cpp2
-rw-r--r--engines/mortevielle/saveload.cpp2
-rw-r--r--engines/neverhood/mouse.cpp2
-rw-r--r--engines/neverhood/resource.cpp6
-rw-r--r--engines/neverhood/screen.cpp6
-rw-r--r--engines/parallaction/disk_br.cpp8
-rw-r--r--engines/parallaction/disk_ns.cpp6
-rw-r--r--engines/parallaction/exec_ns.cpp4
-rw-r--r--engines/parallaction/graphics.cpp22
-rw-r--r--engines/parallaction/input.cpp2
-rw-r--r--engines/parallaction/inventory.h2
-rw-r--r--engines/pegasus/cursor.cpp6
-rw-r--r--engines/pegasus/graphics.cpp2
-rw-r--r--engines/pegasus/neighborhood/caldoria/caldoria.cpp4
-rw-r--r--engines/pegasus/pegasus.cpp10
-rw-r--r--engines/pegasus/transition.cpp2
-rw-r--r--engines/saga/animation.cpp2
-rw-r--r--engines/saga/gfx.h2
-rw-r--r--engines/saga/introproc_ihnm.cpp8
-rw-r--r--engines/saga/introproc_saga2.cpp2
-rw-r--r--engines/saga/scene.cpp6
-rw-r--r--engines/sci/detection_tables.h17
-rw-r--r--engines/sci/engine/kvideo.cpp4
-rw-r--r--engines/sci/graphics/frameout.cpp2
-rw-r--r--engines/sci/graphics/maciconbar.cpp6
-rw-r--r--engines/sci/graphics/screen.cpp4
-rw-r--r--engines/sci/video/robot_decoder.cpp2
-rw-r--r--engines/sci/video/seq_decoder.cpp4
-rw-r--r--engines/scumm/akos.cpp6
-rw-r--r--engines/scumm/base-costume.cpp8
-rw-r--r--engines/scumm/bomp.cpp5
-rw-r--r--engines/scumm/charset.cpp10
-rw-r--r--engines/scumm/costume.cpp6
-rw-r--r--engines/scumm/cursor.cpp10
-rw-r--r--engines/scumm/debugger.cpp2
-rw-r--r--engines/scumm/gfx.cpp16
-rw-r--r--engines/scumm/gfx_towns.cpp2
-rw-r--r--engines/scumm/he/animation_he.cpp4
-rw-r--r--engines/scumm/he/script_v80he.cpp6
-rw-r--r--engines/scumm/nut_renderer.cpp10
-rw-r--r--engines/scumm/object.cpp2
-rw-r--r--engines/sword1/animation.cpp6
-rw-r--r--engines/sword2/animation.cpp4
-rw-r--r--engines/sword25/fmv/movieplayer.cpp4
-rw-r--r--engines/sword25/gfx/image/imgloader.cpp2
-rw-r--r--engines/sword25/gfx/image/renderedimage.cpp12
-rw-r--r--engines/sword25/gfx/screenshot.cpp4
-rw-r--r--engines/teenagent/font.cpp2
-rw-r--r--engines/teenagent/resources.cpp2
-rw-r--r--engines/teenagent/scene.cpp12
-rw-r--r--engines/teenagent/teenagent.cpp2
-rw-r--r--engines/testbed/config.cpp8
-rw-r--r--engines/testbed/config.h4
-rw-r--r--engines/tinsel/bmv.cpp2
-rw-r--r--engines/tinsel/graphics.cpp2
-rw-r--r--engines/toltecs/menu.cpp4
-rw-r--r--engines/toltecs/screen.cpp2
-rw-r--r--engines/toltecs/segmap.cpp2
-rw-r--r--engines/tony/detection.cpp4
-rw-r--r--engines/toon/anim.cpp6
-rw-r--r--engines/toon/movie.cpp2
-rw-r--r--engines/toon/picture.cpp6
-rw-r--r--engines/toon/toon.cpp12
-rw-r--r--engines/tsage/events.cpp8
-rw-r--r--engines/tsage/graphics.cpp23
-rw-r--r--engines/tsage/ringworld2/ringworld2_logic.cpp2
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes0.cpp4
-rw-r--r--engines/tsage/saveload.cpp2
-rw-r--r--engines/tucker/sequences.cpp4
-rw-r--r--engines/wintermute/base/gfx/osystem/base_render_osystem.cpp6
-rw-r--r--engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp2
-rw-r--r--engines/wintermute/graphics/transparent_surface.cpp15
-rw-r--r--engines/wintermute/video/video_theora_player.cpp4
-rw-r--r--graphics/VectorRenderer.h2
-rw-r--r--graphics/VectorRendererSpec.cpp8
-rw-r--r--graphics/decoders/bmp.cpp6
-rw-r--r--graphics/decoders/iff.cpp4
-rw-r--r--graphics/decoders/jpeg.cpp2
-rw-r--r--graphics/decoders/pcx.cpp6
-rw-r--r--graphics/decoders/pict.cpp2
-rw-r--r--graphics/decoders/png.cpp2
-rw-r--r--graphics/decoders/tga.cpp4
-rw-r--r--graphics/fonts/ttf.cpp4
-rw-r--r--graphics/scaler/thumbnail_intern.cpp21
-rw-r--r--graphics/surface.cpp8
-rw-r--r--graphics/surface.h43
-rw-r--r--graphics/yuv_to_rgb.cpp18
-rw-r--r--gui/EventRecorder.cpp2
-rw-r--r--gui/ThemeEngine.cpp10
-rw-r--r--gui/widget.cpp8
-rw-r--r--test/audio/raw.h1
-rw-r--r--video/avi_decoder.cpp153
-rw-r--r--video/avi_decoder.h30
-rw-r--r--video/codecs/cdtoons.cpp2
-rw-r--r--video/codecs/cinepak.cpp6
-rw-r--r--video/codecs/msrle.cpp2
-rw-r--r--video/codecs/msvideo1.cpp2
-rw-r--r--video/codecs/qtrle.cpp12
-rw-r--r--video/codecs/rpza.cpp2
-rw-r--r--video/codecs/smc.cpp2
-rw-r--r--video/coktel_decoder.cpp51
-rw-r--r--video/dxa_decoder.cpp6
-rw-r--r--video/flic_decoder.cpp14
-rw-r--r--video/smk_decoder.cpp6
-rw-r--r--video/theora_decoder.cpp9
-rw-r--r--video/video_decoder.cpp14
-rw-r--r--video/video_decoder.h18
179 files changed, 935 insertions, 833 deletions
diff --git a/backends/base-backend.cpp b/backends/base-backend.cpp
index 3e0005dedd..3e95c3e26a 100644
--- a/backends/base-backend.cpp
+++ b/backends/base-backend.cpp
@@ -57,7 +57,7 @@ void BaseBackend::initBackend() {
void BaseBackend::fillScreen(uint32 col) {
Graphics::Surface *screen = lockScreen();
- if (screen && screen->pixels)
- memset(screen->pixels, col, screen->h * screen->pitch);
+ if (screen && screen->getPixels())
+ memset(screen->getPixels(), col, screen->h * screen->pitch);
unlockScreen();
}
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 48e2663d44..84be83d524 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -357,7 +357,7 @@ void OpenGLGraphicsManager::copyRectToScreen(const void *buf, int pitch, int x,
// Copy buffer data to game screen internal buffer
const byte *src = (const byte *)buf;
- byte *dst = (byte *)_screenData.pixels + y * _screenData.pitch + x * _screenData.format.bytesPerPixel;
+ byte *dst = (byte *)_screenData.getBasePtr(x, y);
for (int i = 0; i < h; i++) {
memcpy(dst, src, w * _screenData.format.bytesPerPixel);
src += pitch;
@@ -385,15 +385,15 @@ void OpenGLGraphicsManager::fillScreen(uint32 col) {
#ifdef USE_RGB_COLOR
if (_screenFormat.bytesPerPixel == 1) {
- memset(_screenData.pixels, col, _screenData.h * _screenData.pitch);
+ memset(_screenData.getPixels(), col, _screenData.h * _screenData.pitch);
} else if (_screenFormat.bytesPerPixel == 2) {
- uint16 *pixels = (uint16 *)_screenData.pixels;
+ uint16 *pixels = (uint16 *)_screenData.getPixels();
uint16 col16 = (uint16)col;
for (int i = 0; i < _screenData.w * _screenData.h; i++) {
pixels[i] = col16;
}
} else if (_screenFormat.bytesPerPixel == 3) {
- uint8 *pixels = (uint8 *)_screenData.pixels;
+ uint8 *pixels = (uint8 *)_screenData.getPixels();
byte r = (col >> 16) & 0xFF;
byte g = (col >> 8) & 0xFF;
byte b = col & 0xFF;
@@ -404,13 +404,13 @@ void OpenGLGraphicsManager::fillScreen(uint32 col) {
pixels += 3;
}
} else if (_screenFormat.bytesPerPixel == 4) {
- uint32 *pixels = (uint32 *)_screenData.pixels;
+ uint32 *pixels = (uint32 *)_screenData.getPixels();
for (int i = 0; i < _screenData.w * _screenData.h; i++) {
pixels[i] = col;
}
}
#else
- memset(_screenData.pixels, col, _screenData.h * _screenData.pitch);
+ memset(_screenData.getPixels(), col, _screenData.h * _screenData.pitch);
#endif
_screenNeedsRedraw = true;
}
@@ -463,12 +463,12 @@ Graphics::PixelFormat OpenGLGraphicsManager::getOverlayFormat() const {
void OpenGLGraphicsManager::clearOverlay() {
// Set all pixels to 0
- memset(_overlayData.pixels, 0, _overlayData.h * _overlayData.pitch);
+ memset(_overlayData.getPixels(), 0, _overlayData.h * _overlayData.pitch);
_overlayNeedsRedraw = true;
}
void OpenGLGraphicsManager::grabOverlay(void *buf, int pitch) {
- const byte *src = (byte *)_overlayData.pixels;
+ const byte *src = (byte *)_overlayData.getPixels();
byte *dst = (byte *)buf;
for (int i = 0; i < _overlayData.h; i++) {
// Copy overlay data to buffer
@@ -509,7 +509,7 @@ void OpenGLGraphicsManager::copyRectToOverlay(const void *buf, int pitch, int x,
return;
// Copy buffer data to internal overlay surface
- byte *dst = (byte *)_overlayData.pixels + y * _overlayData.pitch;
+ byte *dst = (byte *)_overlayData.getBasePtr(0, y);
for (int i = 0; i < h; i++) {
memcpy(dst + x * _overlayData.format.bytesPerPixel, src, w * _overlayData.format.bytesPerPixel);
src += pitch;
@@ -609,7 +609,7 @@ void OpenGLGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, int
_cursorData.create(w, h, _cursorFormat);
// Save cursor data
- memcpy(_cursorData.pixels, buf, h * _cursorData.pitch);
+ memcpy(_cursorData.getPixels(), buf, h * _cursorData.pitch);
// Set cursor info
_cursorState.w = w;
@@ -688,7 +688,7 @@ void OpenGLGraphicsManager::refreshGameScreen() {
byte *surface = new byte[w * h * 3];
// Convert the paletted buffer to RGB888
- const byte *src = (byte *)_screenData.pixels + y * _screenData.pitch;
+ const byte *src = (byte *)_screenData.getBasePtr(0, y);
src += x * _screenData.format.bytesPerPixel;
byte *dst = surface;
for (int i = 0; i < h; i++) {
@@ -708,8 +708,7 @@ void OpenGLGraphicsManager::refreshGameScreen() {
delete[] surface;
} else {
// Update the texture
- _gameTexture->updateBuffer((byte *)_screenData.pixels + y * _screenData.pitch +
- x * _screenData.format.bytesPerPixel, _screenData.pitch, x, y, w, h);
+ _gameTexture->updateBuffer((byte *)_screenData.getBasePtr(x, y), _screenData.pitch, x, y, w, h);
}
_screenNeedsRedraw = false;
@@ -730,7 +729,7 @@ void OpenGLGraphicsManager::refreshOverlay() {
byte *surface = new byte[w * h * 3];
// Convert the paletted buffer to RGB888
- const byte *src = (byte *)_overlayData.pixels + y * _overlayData.pitch;
+ const byte *src = (byte *)_overlayData.getBasePtr(0, y);
src += x * _overlayData.format.bytesPerPixel;
byte *dst = surface;
for (int i = 0; i < h; i++) {
@@ -750,8 +749,7 @@ void OpenGLGraphicsManager::refreshOverlay() {
delete[] surface;
} else {
// Update the texture
- _overlayTexture->updateBuffer((byte *)_overlayData.pixels + y * _overlayData.pitch +
- x * _overlayData.format.bytesPerPixel, _overlayData.pitch, x, y, w, h);
+ _overlayTexture->updateBuffer((byte *)_overlayData.getBasePtr(x, y), _overlayData.pitch, x, y, w, h);
}
_overlayNeedsRedraw = false;
@@ -780,7 +778,7 @@ void OpenGLGraphicsManager::refreshCursor() {
palette = _cursorPalette;
// Convert the paletted cursor to RGBA8888
- const byte *src = (byte *)_cursorData.pixels;
+ const byte *src = (byte *)_cursorData.getPixels();
for (int i = 0; i < _cursorState.w * _cursorState.h; i++) {
// Check for keycolor
if (src[i] != _cursorKeyColor) {
@@ -796,7 +794,7 @@ void OpenGLGraphicsManager::refreshCursor() {
// Convert the RGB cursor to RGBA8888
if (_cursorFormat.bytesPerPixel == 2) {
- const uint16 *src = (uint16 *)_cursorData.pixels;
+ const uint16 *src = (uint16 *)_cursorData.getPixels();
for (int i = 0; i < _cursorState.w * _cursorState.h; i++) {
// Check for keycolor
if (src[i] != _cursorKeyColor) {
@@ -808,7 +806,7 @@ void OpenGLGraphicsManager::refreshCursor() {
dst += 4;
}
} else if (_cursorFormat.bytesPerPixel == 4) {
- const uint32 *src = (uint32 *)_cursorData.pixels;
+ const uint32 *src = (uint32 *)_cursorData.getPixels();
for (int i = 0; i < _cursorState.w * _cursorState.h; i++) {
// Check for keycolor
if (src[i] != _cursorKeyColor) {
@@ -1356,7 +1354,7 @@ void OpenGLGraphicsManager::updateOSD() {
_osdSurface.create(_osdTexture->getWidth(), _osdTexture->getHeight(), _overlayFormat);
else
// Clear everything
- memset(_osdSurface.pixels, 0, _osdSurface.h * _osdSurface.pitch);
+ memset(_osdSurface.getPixels(), 0, _osdSurface.h * _osdSurface.pitch);
// Determine a rect which would contain the message string (clipped to the
// screen dimensions).
@@ -1390,7 +1388,7 @@ void OpenGLGraphicsManager::updateOSD() {
}
// Update the texture
- _osdTexture->updateBuffer(_osdSurface.pixels, _osdSurface.pitch, 0, 0,
+ _osdTexture->updateBuffer(_osdSurface.getPixels(), _osdSurface.pitch, 0, 0,
_osdSurface.w, _osdSurface.h);
}
#endif
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index a2e1981e79..871c6c49b2 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -1308,15 +1308,13 @@ Graphics::Surface *SurfaceSdlGraphicsManager::lockScreen() {
if (SDL_LockSurface(_screen) == -1)
error("SDL_LockSurface failed: %s", SDL_GetError());
- _framebuffer.pixels = _screen->pixels;
- _framebuffer.w = _screen->w;
- _framebuffer.h = _screen->h;
- _framebuffer.pitch = _screen->pitch;
+ _framebuffer.init(_screen->w, _screen->h, _screen->pitch, _screen->pixels,
#ifdef USE_RGB_COLOR
- _framebuffer.format = _screenFormat;
+ _screenFormat
#else
- _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8();
+ Graphics::PixelFormat::createFormatCLUT8()
#endif
+ );
return &_framebuffer;
}
@@ -1340,8 +1338,8 @@ void SurfaceSdlGraphicsManager::unlockScreen() {
void SurfaceSdlGraphicsManager::fillScreen(uint32 col) {
Graphics::Surface *screen = lockScreen();
- if (screen && screen->pixels)
- memset(screen->pixels, col, screen->h * screen->pitch);
+ if (screen && screen->getPixels())
+ memset(screen->getPixels(), col, screen->h * screen->pitch);
unlockScreen();
}
@@ -2062,15 +2060,12 @@ void SurfaceSdlGraphicsManager::displayMessageOnOSD(const char *msg) {
error("displayMessageOnOSD: SDL_LockSurface failed: %s", SDL_GetError());
Graphics::Surface dst;
- dst.pixels = _osdSurface->pixels;
- dst.w = _osdSurface->w;
- dst.h = _osdSurface->h;
- dst.pitch = _osdSurface->pitch;
- dst.format = Graphics::PixelFormat(_osdSurface->format->BytesPerPixel,
- 8 - _osdSurface->format->Rloss, 8 - _osdSurface->format->Gloss,
- 8 - _osdSurface->format->Bloss, 8 - _osdSurface->format->Aloss,
- _osdSurface->format->Rshift, _osdSurface->format->Gshift,
- _osdSurface->format->Bshift, _osdSurface->format->Ashift);
+ dst.init(_osdSurface->w, _osdSurface->h, _osdSurface->pitch, _osdSurface->pixels,
+ Graphics::PixelFormat(_osdSurface->format->BytesPerPixel,
+ 8 - _osdSurface->format->Rloss, 8 - _osdSurface->format->Gloss,
+ 8 - _osdSurface->format->Bloss, 8 - _osdSurface->format->Aloss,
+ _osdSurface->format->Rshift, _osdSurface->format->Gshift,
+ _osdSurface->format->Bshift, _osdSurface->format->Ashift));
// The font we are going to use:
const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kLocalizedFont);
diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp
index cd0fd88484..882dcff9a4 100644
--- a/backends/platform/android/gfx.cpp
+++ b/backends/platform/android/gfx.cpp
@@ -552,7 +552,7 @@ Graphics::Surface *OSystem_Android::lockScreen() {
GLTHREADCHECK;
Graphics::Surface *surface = _game_texture->surface();
- assert(surface->pixels);
+ assert(surface->getPixels());
return surface;
}
@@ -645,7 +645,7 @@ void OSystem_Android::grabOverlay(void *buf, int pitch) {
assert(surface->format.bytesPerPixel == sizeof(uint16));
byte *dst = (byte *)buf;
- const byte *src = (const byte *)surface->pixels;
+ const byte *src = (const byte *)surface->getPixels();
uint h = surface->h;
do {
diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp
index b174e93191..cc41c0d8a6 100644
--- a/backends/platform/android/texture.cpp
+++ b/backends/platform/android/texture.cpp
@@ -233,7 +233,7 @@ void GLESTexture::allocBuffer(GLuint w, GLuint h) {
_pixels = new byte[w * h * _surface.format.bytesPerPixel];
assert(_pixels);
- _surface.pixels = _pixels;
+ _surface.setPixels(_pixels);
fillBuffer(0);
@@ -256,7 +256,7 @@ void GLESTexture::updateBuffer(GLuint x, GLuint y, GLuint w, GLuint h,
}
void GLESTexture::fillBuffer(uint32 color) {
- assert(_surface.pixels);
+ assert(_surface.getPixels());
if (_pixelFormat.bytesPerPixel == 1 ||
((color & 0xff) == ((color >> 8) & 0xff)))
@@ -377,7 +377,7 @@ void GLESFakePaletteTexture::allocBuffer(GLuint w, GLuint h) {
assert(_pixels);
// fixup surface, for the outside this is a CLUT8 surface
- _surface.pixels = _pixels;
+ _surface.setPixels(_pixels);
fillBuffer(0);
@@ -386,8 +386,8 @@ void GLESFakePaletteTexture::allocBuffer(GLuint w, GLuint h) {
}
void GLESFakePaletteTexture::fillBuffer(uint32 color) {
- assert(_surface.pixels);
- memset(_surface.pixels, color & 0xff, _surface.pitch * _surface.h);
+ assert(_surface.getPixels());
+ memset(_surface.getPixels(), color & 0xff, _surface.pitch * _surface.h);
setDirty();
}
diff --git a/backends/platform/dc/display.cpp b/backends/platform/dc/display.cpp
index cc5798fc10..54ee6000ed 100644
--- a/backends/platform/dc/display.cpp
+++ b/backends/platform/dc/display.cpp
@@ -711,11 +711,7 @@ Graphics::Surface *OSystem_Dreamcast::lockScreen()
if (!screen)
return 0;
- _framebuffer.pixels = screen;
- _framebuffer.w = _screen_w;
- _framebuffer.h = _screen_h;
- _framebuffer.pitch = SCREEN_W*2;
- _framebuffer.format = screenFormats[_screenFormat];
+ _framebuffer.init(_screen_w, _screen_h, SCREEN_W*2, screen, screenFormats[_screenFormat]);
return &_framebuffer;
}
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp
index 2f6358d8ee..f109983fbc 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.cpp
+++ b/backends/platform/ds/arm9/source/osystem_ds.cpp
@@ -296,7 +296,7 @@ void OSystem_DS::copyRectToScreen(const void *buf, int pitch, int x, int y, int
// to save a few pennies/euro cents on the hardware.
if (_frameBufferExists) {
- bg = (u16 *)_framebuffer.pixels;
+ bg = (u16 *)_framebuffer.getPixels();
stride = _framebuffer.pitch;
} else {
bg = (u16 *)DS::get8BitBackBuffer();
@@ -455,7 +455,7 @@ void OSystem_DS::copyRectToScreen(const void *buf, int pitch, int x, int y, int
dmaCopyHalfWords(3, src, dest1, w);
- if ((!_frameBufferExists) || (buf == _framebuffer.pixels)) {
+ if ((!_frameBufferExists) || (buf == _framebuffer.getPixels())) {
dmaCopyHalfWords(2, src, dest2, w);
}
@@ -476,7 +476,7 @@ void OSystem_DS::updateScreen() {
_frameBufferExists = false;
// Copy temp framebuffer back to screen
- copyRectToScreen((byte *)_framebuffer.pixels, _framebuffer.pitch, 0, 0, _framebuffer.w, _framebuffer.h);
+ copyRectToScreen((byte *)_framebuffer.getPixels(), _framebuffer.pitch, 0, 0, _framebuffer.w, _framebuffer.h);
}
DS::displayMode16BitFlipBuffer();
@@ -755,11 +755,8 @@ Graphics::Surface *OSystem_DS::createTempFrameBuffer() {
if (DS::isCpuScalerEnabled()) {
- _framebuffer.pixels = DS::getScalerBuffer();
- _framebuffer.w = DS::getGameWidth();
- _framebuffer.h = DS::getGameHeight();
- _framebuffer.pitch = DS::getGameWidth();
- _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8();
+ _framebuffer.init(DS::getGameWidth(), DS::getGameHeight(), DS::getGameWidth(),
+ DS::getScalerBuffer(), Graphics::PixelFormat::createFormatCLUT8());
} else {
@@ -780,11 +777,7 @@ Graphics::Surface *OSystem_DS::createTempFrameBuffer() {
dmaCopyHalfWords(3, srcLine, destLine, width);
}
- _framebuffer.pixels = dest;
- _framebuffer.w = width;
- _framebuffer.h = height;
- _framebuffer.pitch = width;
- _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8();
+ _framebuffer.init(width, height, width, dest, Graphics::PixelFormat::createFormatCLUT8());
}
@@ -798,8 +791,8 @@ Graphics::Surface *OSystem_DS::createTempFrameBuffer() {
for (int y = 0; y < DS::getGameHeight(); y++) {
DC_FlushRange(image + (y * imageStrideInWords), DS::getGameWidth());
for (int x = 0; x < DS::getGameWidth() >> 1; x++) {
- *(((u16 *) (_framebuffer.pixels)) + y * (DS::getGameWidth() >> 1) + x) = image[(y * imageStrideInWords) + x];
-// *(((u16 *) (surf->pixels)) + y * (DS::getGameWidth() >> 1) + x) = image[y * imageStrideInWords + x];
+ *(((u16 *) (_framebuffer.getPixels())) + y * (DS::getGameWidth() >> 1) + x) = image[(y * imageStrideInWords) + x];
+// *(((u16 *) (surf->getPixels())) + y * (DS::getGameWidth() >> 1) + x) = image[y * imageStrideInWords + x];
}
}*/
diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm
index 0bfae30fc7..f2c1527658 100644
--- a/backends/platform/iphone/iphone_video.mm
+++ b/backends/platform/iphone/iphone_video.mm
@@ -365,7 +365,7 @@ const char *iPhone_getDocumentsDir() {
_mouseTexCoords[5] = _mouseTexCoords[7] = _videoContext.mouseHeight / (GLfloat)_videoContext.mouseTexture.h;
glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError();
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.mouseTexture.w, _videoContext.mouseTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.mouseTexture.pixels); printOpenGLError();
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.mouseTexture.w, _videoContext.mouseTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.mouseTexture.getPixels()); printOpenGLError();
}
- (void)updateMainSurface {
@@ -377,7 +377,7 @@ const char *iPhone_getDocumentsDir() {
// Unfortunately we have to update the whole texture every frame, since glTexSubImage2D is actually slower in all cases
// due to the iPhone internals having to convert the whole texture back from its internal format when used.
// In the future we could use several tiled textures instead.
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _videoContext.screenTexture.w, _videoContext.screenTexture.h, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _videoContext.screenTexture.pixels); printOpenGLError();
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _videoContext.screenTexture.w, _videoContext.screenTexture.h, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _videoContext.screenTexture.getPixels()); printOpenGLError();
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError();
}
@@ -386,7 +386,7 @@ const char *iPhone_getDocumentsDir() {
glTexCoordPointer(2, GL_FLOAT, 0, _overlayTexCoords); printOpenGLError();
glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError();
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.overlayTexture.w, _videoContext.overlayTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.overlayTexture.pixels); printOpenGLError();
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.overlayTexture.w, _videoContext.overlayTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.overlayTexture.getPixels()); printOpenGLError();
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError();
}
diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp
index 460d3fd2ac..a814495b80 100644
--- a/backends/platform/iphone/osys_main.cpp
+++ b/backends/platform/iphone/osys_main.cpp
@@ -77,8 +77,8 @@ OSystem_IPHONE::~OSystem_IPHONE() {
delete _mixer;
// Prevent accidental freeing of the screen texture here. This needs to be
// checked since we might use the screen texture as framebuffer in the case
- // of hi-color games for example.
- if (_framebuffer.pixels == _videoContext->screenTexture.pixels)
+ // of hi-color games for example. Otherwise this can lead to a double free.
+ if (_framebuffer.getPixels() != _videoContext->screenTexture.getPixels())
_framebuffer.free();
_mouseBuffer.free();
}
diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm
index a11bf32c54..ce7f94f5bd 100644
--- a/backends/platform/iphone/osys_video.mm
+++ b/backends/platform/iphone/osys_video.mm
@@ -76,8 +76,8 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm
// In case we use the screen texture as frame buffer we reset the pixels
// pointer here to avoid freeing the screen texture.
- if (_framebuffer.pixels == _videoContext->screenTexture.pixels)
- _framebuffer.pixels = 0;
+ if (_framebuffer.getPixels() == _videoContext->screenTexture.getPixels())
+ _framebuffer.setPixels(0);
// Create the screen texture right here. We need to do this here, since
// when a game requests hi-color mode, we actually set the framebuffer
@@ -310,7 +310,7 @@ void OSystem_IPHONE::hideOverlay() {
void OSystem_IPHONE::clearOverlay() {
//printf("clearOverlay()\n");
- bzero(_videoContext->overlayTexture.getBasePtr(0, 0), _videoContext->overlayTexture.h * _videoContext->overlayTexture.pitch);
+ bzero(_videoContext->overlayTexture.getPixels(), _videoContext->overlayTexture.h * _videoContext->overlayTexture.pitch);
dirtyFullOverlayScreen();
}
@@ -319,7 +319,7 @@ void OSystem_IPHONE::grabOverlay(void *buf, int pitch) {
int h = _videoContext->overlayHeight;
byte *dst = (byte *)buf;
- const byte *src = (const byte *)_videoContext->overlayTexture.getBasePtr(0, 0);
+ const byte *src = (const byte *)_videoContext->overlayTexture.getPixels();
do {
memcpy(dst, src, _videoContext->overlayWidth * sizeof(uint16));
src += _videoContext->overlayTexture.pitch;
@@ -417,7 +417,7 @@ void OSystem_IPHONE::setMouseCursor(const void *buf, uint w, uint h, int hotspot
#endif
assert(pixelFormat.bytesPerPixel == 1 || pixelFormat.bytesPerPixel == 2);
- if (_mouseBuffer.w != w || _mouseBuffer.h != h || _mouseBuffer.format != pixelFormat || !_mouseBuffer.pixels)
+ if (_mouseBuffer.w != w || _mouseBuffer.h != h || _mouseBuffer.format != pixelFormat || !_mouseBuffer.getPixels())
_mouseBuffer.create(w, h, pixelFormat);
_videoContext->mouseWidth = w;
@@ -428,7 +428,7 @@ void OSystem_IPHONE::setMouseCursor(const void *buf, uint w, uint h, int hotspot
_mouseKeyColor = keycolor;
- memcpy(_mouseBuffer.getBasePtr(0, 0), buf, h * _mouseBuffer.pitch);
+ memcpy(_mouseBuffer.getPixels(), buf, h * _mouseBuffer.pitch);
_mouseDirty = true;
_mouseNeedTextureUpdate = true;
@@ -464,7 +464,7 @@ void OSystem_IPHONE::updateMouseTexture() {
else
palette = _gamePaletteRGBA5551;
- uint16 *mouseBuf = (uint16 *)mouseTexture.getBasePtr(0, 0);
+ uint16 *mouseBuf = (uint16 *)mouseTexture.getPixels();
for (uint x = 0; x < _videoContext->mouseWidth; ++x) {
for (uint y = 0; y < _videoContext->mouseHeight; ++y) {
const byte color = *(const byte *)_mouseBuffer.getBasePtr(x, y);
@@ -475,12 +475,12 @@ void OSystem_IPHONE::updateMouseTexture() {
}
}
} else {
- if (crossBlit((byte *)mouseTexture.getBasePtr(0, 0), (const byte *)_mouseBuffer.getBasePtr(0, 0), mouseTexture.pitch,
+ if (crossBlit((byte *)mouseTexture.getPixels(), (const byte *)_mouseBuffer.getPixels(), mouseTexture.pitch,
_mouseBuffer.pitch, _mouseBuffer.w, _mouseBuffer.h, mouseTexture.format, _mouseBuffer.format)) {
if (!_mouseBuffer.format.aBits()) {
// Apply color keying since the original cursor had no alpha channel.
- const uint16 *src = (const uint16 *)_mouseBuffer.getBasePtr(0, 0);
- uint8 *dstRaw = (uint8 *)mouseTexture.getBasePtr(0, 0);
+ const uint16 *src = (const uint16 *)_mouseBuffer.getPixels();
+ uint8 *dstRaw = (uint8 *)mouseTexture.getPixels();
for (uint y = 0; y < _mouseBuffer.h; ++y, dstRaw += mouseTexture.pitch) {
uint16 *dst = (uint16 *)dstRaw;
@@ -495,7 +495,7 @@ void OSystem_IPHONE::updateMouseTexture() {
} else {
// TODO: Log this!
// Make the cursor all transparent... we really need a better fallback ;-).
- memset(mouseTexture.getBasePtr(0, 0), 0, mouseTexture.h * mouseTexture.pitch);
+ memset(mouseTexture.getPixels(), 0, mouseTexture.h * mouseTexture.pitch);
}
}
diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp
index afd93f5e09..36e5085764 100644
--- a/backends/platform/n64/osys_n64_base.cpp
+++ b/backends/platform/n64/osys_n64_base.cpp
@@ -605,11 +605,7 @@ void OSystem_N64::updateScreen() {
}
Graphics::Surface *OSystem_N64::lockScreen() {
- _framebuffer.pixels = _offscreen_pal;
- _framebuffer.w = _gameWidth;
- _framebuffer.h = _gameHeight;
- _framebuffer.pitch = _screenWidth;
- _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8();
+ _framebuffer.init(_gameWidth, _gameHeight, _screenWidth, _offscreen_pal, Graphics::PixelFormat::createFormatCLUT8());
return &_framebuffer;
}
diff --git a/backends/platform/ps2/Gs2dScreen.cpp b/backends/platform/ps2/Gs2dScreen.cpp
index e818305c29..58667c0230 100644
--- a/backends/platform/ps2/Gs2dScreen.cpp
+++ b/backends/platform/ps2/Gs2dScreen.cpp
@@ -392,12 +392,8 @@ void Gs2dScreen::copyScreenRect(const uint8 *buf, int pitch, int x, int y, int w
Graphics::Surface *Gs2dScreen::lockScreen() {
WaitSema(g_DmacSema);
- _framebuffer.pixels = _screenBuf;
- _framebuffer.w = _width;
- _framebuffer.h = _height;
- _framebuffer.pitch = _width; // -not- _pitch; ! It's EE mem, not Tex
- _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8();
-
+ // -not- _pitch; ! It's EE mem, not Tex
+ _framebuffer.init(_width, _height, _width, _screenBuf, Graphics::PixelFormat::createFormatCLUT8());
return &_framebuffer;
}
diff --git a/backends/platform/psp/default_display_client.cpp b/backends/platform/psp/default_display_client.cpp
index bc252144fa..6d6eb641f7 100644
--- a/backends/platform/psp/default_display_client.cpp
+++ b/backends/platform/psp/default_display_client.cpp
@@ -192,11 +192,8 @@ void Screen::setScummvmPixelFormat(const Graphics::PixelFormat *format) {
Graphics::Surface *Screen::lockAndGetForEditing() {
DEBUG_ENTER_FUNC();
- _frameBuffer.pixels = _buffer.getPixels();
- _frameBuffer.w = _buffer.getSourceWidth();
- _frameBuffer.h = _buffer.getSourceHeight();
- _frameBuffer.pitch = _buffer.getBytesPerPixel() * _buffer.getWidth();
- _frameBuffer.format = _pixelFormat;
+ _frameBuffer.init(_buffer.getSourceWidth(), _buffer.getSourceHeight(), _buffer.getBytesPerPixel() * _buffer.getWidth(),
+ _buffer.getPixels(), _pixelFormat);
// We'll set to dirty once we unlock the screen
return &_frameBuffer;
diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp
index a9bcdbb8d1..92c890b0a9 100644
--- a/backends/platform/wii/osystem_gfx.cpp
+++ b/backends/platform/wii/osystem_gfx.cpp
@@ -528,16 +528,13 @@ void OSystem_Wii::updateScreen() {
}
Graphics::Surface *OSystem_Wii::lockScreen() {
- _surface.pixels = _gamePixels;
- _surface.w = _gameWidth;
- _surface.h = _gameHeight;
+ _surface.init(_gameWidth, _gameHeight,
#ifdef USE_RGB_COLOR
- _surface.pitch = _gameWidth * _pfGame.bytesPerPixel;
- _surface.format = _pfGame;
+ _gameWidth * _pfGame.bytesPerPixel, _gamePixels, _pfGame
#else
- _surface.pitch = _gameWidth;
- _surface.format = Graphics::PixelFormat::createFormatCLUT8();
+ _gameWidth, _gamePixels, Graphics::PixelFormat::createFormatCLUT8()
#endif
+ );
return &_surface;
}
diff --git a/backends/vkeybd/virtual-keyboard-gui.cpp b/backends/vkeybd/virtual-keyboard-gui.cpp
index 75de86472f..8bf9a54251 100644
--- a/backends/vkeybd/virtual-keyboard-gui.cpp
+++ b/backends/vkeybd/virtual-keyboard-gui.cpp
@@ -36,7 +36,7 @@ static void blit(Graphics::Surface *surf_dst, Graphics::Surface *surf_src, int16
if (surf_dst->format.bytesPerPixel != sizeof(OverlayColor) || surf_src->format.bytesPerPixel != sizeof(OverlayColor))
return;
- const OverlayColor *src = (const OverlayColor *)surf_src->pixels;
+ const OverlayColor *src = (const OverlayColor *)surf_src->getPixels();
int blitW = surf_src->w;
int blitH = surf_src->h;
@@ -161,7 +161,7 @@ void VirtualKeyboardGUI::run() {
_system->clearOverlay();
}
_overlayBackup.create(_screenW, _screenH, _system->getOverlayFormat());
- _system->grabOverlay(_overlayBackup.pixels, _overlayBackup.pitch);
+ _system->grabOverlay(_overlayBackup.getPixels(), _overlayBackup.pitch);
setupCursor();
@@ -171,7 +171,7 @@ void VirtualKeyboardGUI::run() {
removeCursor();
- _system->copyRectToOverlay(_overlayBackup.pixels, _overlayBackup.pitch, 0, 0, _overlayBackup.w, _overlayBackup.h);
+ _system->copyRectToOverlay(_overlayBackup.getPixels(), _overlayBackup.pitch, 0, 0, _overlayBackup.w, _overlayBackup.h);
if (!g_gui.isActive()) _system->hideOverlay();
_overlayBackup.free();
@@ -262,7 +262,7 @@ void VirtualKeyboardGUI::screenChanged() {
_screenH = newScreenH;
_overlayBackup.create(_screenW, _screenH, _system->getOverlayFormat());
- _system->grabOverlay(_overlayBackup.pixels, _overlayBackup.pitch);
+ _system->grabOverlay(_overlayBackup.getPixels(), _overlayBackup.pitch);
if (!_kbd->checkModeResolutions()) {
_displaying = false;
@@ -356,7 +356,7 @@ void VirtualKeyboardGUI::redraw() {
Graphics::Surface surf;
surf.create(w, h, _system->getOverlayFormat());
- OverlayColor *dst = (OverlayColor *)surf.pixels;
+ OverlayColor *dst = (OverlayColor *)surf.getPixels();
const OverlayColor *src = (OverlayColor *) _overlayBackup.getBasePtr(_dirtyRect.left, _dirtyRect.top);
while (h--) {
@@ -371,7 +371,7 @@ void VirtualKeyboardGUI::redraw() {
blit(&surf, &_dispSurface, _dispX - _dirtyRect.left,
_dispY - _dirtyRect.top, _dispBackColor);
}
- _system->copyRectToOverlay(surf.pixels, surf.pitch,
+ _system->copyRectToOverlay(surf.getPixels(), surf.pitch,
_dirtyRect.left, _dirtyRect.top, surf.w, surf.h);
surf.free();
diff --git a/common/config-manager.h b/common/config-manager.h
index d43a7bec51..6295a93ba5 100644
--- a/common/config-manager.h
+++ b/common/config-manager.h
@@ -24,7 +24,6 @@
#define COMMON_CONFIG_MANAGER_H
#include "common/array.h"
-//#include "common/config-file.h"
#include "common/hashmap.h"
#include "common/singleton.h"
#include "common/str.h"
diff --git a/common/config-file.cpp b/common/ini-file.cpp
index 0ce6dcf0c8..be5247dcfb 100644
--- a/common/config-file.cpp
+++ b/common/ini-file.cpp
@@ -20,7 +20,7 @@
*
*/
-#include "common/config-file.h"
+#include "common/ini-file.h"
#include "common/file.h"
#include "common/savefile.h"
#include "common/system.h"
@@ -28,24 +28,24 @@
namespace Common {
-bool ConfigFile::isValidName(const String &name) {
+bool INIFile::isValidName(const String &name) {
const char *p = name.c_str();
while (*p && (isAlnum(*p) || *p == '-' || *p == '_' || *p == '.'))
p++;
return *p == 0;
}
-ConfigFile::ConfigFile() {
+INIFile::INIFile() {
}
-ConfigFile::~ConfigFile() {
+INIFile::~INIFile() {
}
-void ConfigFile::clear() {
+void INIFile::clear() {
_sections.clear();
}
-bool ConfigFile::loadFromFile(const String &filename) {
+bool INIFile::loadFromFile(const String &filename) {
File file;
if (file.open(filename))
return loadFromStream(file);
@@ -53,7 +53,7 @@ bool ConfigFile::loadFromFile(const String &filename) {
return false;
}
-bool ConfigFile::loadFromSaveFile(const char *filename) {
+bool INIFile::loadFromSaveFile(const char *filename) {
assert(g_system);
SaveFileManager *saveFileMan = g_system->getSavefileManager();
SeekableReadStream *loadFile;
@@ -67,7 +67,7 @@ bool ConfigFile::loadFromSaveFile(const char *filename) {
return status;
}
-bool ConfigFile::loadFromStream(SeekableReadStream &stream) {
+bool INIFile::loadFromStream(SeekableReadStream &stream) {
Section section;
KeyValue kv;
String comment;
@@ -112,9 +112,9 @@ bool ConfigFile::loadFromStream(SeekableReadStream &stream) {
p++;
if (*p == '\0')
- error("ConfigFile::loadFromStream: missing ] in line %d", lineno);
+ error("INIFile::loadFromStream: missing ] in line %d", lineno);
else if (*p != ']')
- error("ConfigFile::loadFromStream: Invalid character '%c' occurred in section name in line %d", *p, lineno);
+ error("INIFile::loadFromStream: Invalid character '%c' occurred in section name in line %d", *p, lineno);
// Previous section is finished now, store it.
if (!section.name.empty())
@@ -140,7 +140,7 @@ bool ConfigFile::loadFromStream(SeekableReadStream &stream) {
// If no section has been set, this config file is invalid!
if (section.name.empty()) {
- error("ConfigFile::loadFromStream: Key/value pair found outside a section in line %d", lineno);
+ error("INIFile::loadFromStream: Key/value pair found outside a section in line %d", lineno);
}
// Split string at '=' into 'key' and 'value'. First, find the "=" delimeter.
@@ -173,7 +173,7 @@ bool ConfigFile::loadFromStream(SeekableReadStream &stream) {
return (!stream.err() || stream.eos());
}
-bool ConfigFile::saveToFile(const String &filename) {
+bool INIFile::saveToFile(const String &filename) {
DumpFile file;
if (file.open(filename))
return saveToStream(file);
@@ -181,7 +181,7 @@ bool ConfigFile::saveToFile(const String &filename) {
return false;
}
-bool ConfigFile::saveToSaveFile(const char *filename) {
+bool INIFile::saveToSaveFile(const char *filename) {
assert(g_system);
SaveFileManager *saveFileMan = g_system->getSavefileManager();
WriteStream *saveFile;
@@ -195,7 +195,7 @@ bool ConfigFile::saveToSaveFile(const char *filename) {
return status;
}
-bool ConfigFile::saveToStream(WriteStream &stream) {
+bool INIFile::saveToStream(WriteStream &stream) {
for (List<Section>::iterator i = _sections.begin(); i != _sections.end(); ++i) {
// Write out the section comment, if any
if (! i->comment.empty()) {
@@ -226,7 +226,7 @@ bool ConfigFile::saveToStream(WriteStream &stream) {
return !stream.err();
}
-void ConfigFile::addSection(const String &section) {
+void INIFile::addSection(const String &section) {
Section *s = getSection(section);
if (s)
return;
@@ -236,7 +236,7 @@ void ConfigFile::addSection(const String &section) {
_sections.push_back(newSection);
}
-void ConfigFile::removeSection(const String &section) {
+void INIFile::removeSection(const String &section) {
assert(isValidName(section));
for (List<Section>::iterator i = _sections.begin(); i != _sections.end(); ++i) {
if (section.equalsIgnoreCase(i->name)) {
@@ -246,13 +246,13 @@ void ConfigFile::removeSection(const String &section) {
}
}
-bool ConfigFile::hasSection(const String &section) const {
+bool INIFile::hasSection(const String &section) const {
assert(isValidName(section));
const Section *s = getSection(section);
return s != 0;
}
-void ConfigFile::renameSection(const String &oldName, const String &newName) {
+void INIFile::renameSection(const String &oldName, const String &newName) {
assert(isValidName(oldName));
assert(isValidName(newName));
@@ -262,7 +262,7 @@ void ConfigFile::renameSection(const String &oldName, const String &newName) {
// HACK: For now we just print a warning, for more info see the TODO
// below.
if (ns)
- warning("ConfigFile::renameSection: Section name \"%s\" already used", newName.c_str());
+ warning("INIFile::renameSection: Section name \"%s\" already used", newName.c_str());
else
os->name = newName;
}
@@ -274,7 +274,7 @@ void ConfigFile::renameSection(const String &oldName, const String &newName) {
}
-bool ConfigFile::hasKey(const String &key, const String &section) const {
+bool INIFile::hasKey(const String &key, const String &section) const {
assert(isValidName(key));
assert(isValidName(section));
@@ -284,7 +284,7 @@ bool ConfigFile::hasKey(const String &key, const String &section) const {
return s->hasKey(key);
}
-void ConfigFile::removeKey(const String &key, const String &section) {
+void INIFile::removeKey(const String &key, const String &section) {
assert(isValidName(key));
assert(isValidName(section));
@@ -293,7 +293,7 @@ void ConfigFile::removeKey(const String &key, const String &section) {
s->removeKey(key);
}
-bool ConfigFile::getKey(const String &key, const String &section, String &value) const {
+bool INIFile::getKey(const String &key, const String &section, String &value) const {
assert(isValidName(key));
assert(isValidName(section));
@@ -307,7 +307,7 @@ bool ConfigFile::getKey(const String &key, const String &section, String &value)
return true;
}
-void ConfigFile::setKey(const String &key, const String &section, const String &value) {
+void INIFile::setKey(const String &key, const String &section, const String &value) {
assert(isValidName(key));
assert(isValidName(section));
// TODO: Verify that value is valid, too. In particular, it shouldn't
@@ -329,13 +329,13 @@ void ConfigFile::setKey(const String &key, const String &section, const String &
}
}
-const ConfigFile::SectionKeyList ConfigFile::getKeys(const String &section) const {
+const INIFile::SectionKeyList INIFile::getKeys(const String &section) const {
const Section *s = getSection(section);
return s->getKeys();
}
-ConfigFile::Section *ConfigFile::getSection(const String &section) {
+INIFile::Section *INIFile::getSection(const String &section) {
for (List<Section>::iterator i = _sections.begin(); i != _sections.end(); ++i) {
if (section.equalsIgnoreCase(i->name)) {
return &(*i);
@@ -344,7 +344,7 @@ ConfigFile::Section *ConfigFile::getSection(const String &section) {
return 0;
}
-const ConfigFile::Section *ConfigFile::getSection(const String &section) const {
+const INIFile::Section *INIFile::getSection(const String &section) const {
for (List<Section>::const_iterator i = _sections.begin(); i != _sections.end(); ++i) {
if (section.equalsIgnoreCase(i->name)) {
return &(*i);
@@ -353,11 +353,11 @@ const ConfigFile::Section *ConfigFile::getSection(const String &section) const {
return 0;
}
-bool ConfigFile::Section::hasKey(const String &key) const {
+bool INIFile::Section::hasKey(const String &key) const {
return getKey(key) != 0;
}
-const ConfigFile::KeyValue* ConfigFile::Section::getKey(const String &key) const {
+const INIFile::KeyValue* INIFile::Section::getKey(const String &key) const {
for (List<KeyValue>::const_iterator i = keys.begin(); i != keys.end(); ++i) {
if (key.equalsIgnoreCase(i->key)) {
return &(*i);
@@ -366,7 +366,7 @@ const ConfigFile::KeyValue* ConfigFile::Section::getKey(const String &key) const
return 0;
}
-void ConfigFile::Section::setKey(const String &key, const String &value) {
+void INIFile::Section::setKey(const String &key, const String &value) {
for (List<KeyValue>::iterator i = keys.begin(); i != keys.end(); ++i) {
if (key.equalsIgnoreCase(i->key)) {
i->value = value;
@@ -380,7 +380,7 @@ void ConfigFile::Section::setKey(const String &key, const String &value) {
keys.push_back(newKV);
}
-void ConfigFile::Section::removeKey(const String &key) {
+void INIFile::Section::removeKey(const String &key) {
for (List<KeyValue>::iterator i = keys.begin(); i != keys.end(); ++i) {
if (key.equalsIgnoreCase(i->key)) {
keys.erase(i);
diff --git a/common/config-file.h b/common/ini-file.h
index 8bba851110..1d94ce7bdc 100644
--- a/common/config-file.h
+++ b/common/ini-file.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef COMMON_CONFIG_FILE_H
-#define COMMON_CONFIG_FILE_H
+#ifndef COMMON_INI_FILE_H
+#define COMMON_INI_FILE_H
#include "common/hash-str.h"
#include "common/list.h"
@@ -34,9 +34,6 @@ class WriteStream;
/**
* This class allows reading/writing INI style config files.
- * It is used by the ConfigManager for storage, but can also
- * be used by other code if it needs to read/write custom INI
- * files.
*
* Lines starting with a '#' are ignored (i.e. treated as comments).
* Some effort is made to preserve comments, though.
@@ -47,10 +44,8 @@ class WriteStream;
* from/to files, but of course is not appropriate for fast access.
* The main reason is that this class is indeed geared toward doing precisely
* that!
- * If you need fast access to the game config, use higher level APIs, like the
- * one provided by ConfigManager.
*/
-class ConfigFile {
+class INIFile {
public:
struct KeyValue {
String key;
@@ -60,12 +55,12 @@ public:
typedef List<KeyValue> SectionKeyList;
- /** A section in a config file. I.e. corresponds to something like this:
+ /** A section in a ini file. I.e. corresponds to something like this:
* [mySection]
* key=value
*
* Comments are also stored, to keep users happy who like editing their
- * config files manually.
+ * ini files manually.
*/
struct Section {
String name;
@@ -82,8 +77,8 @@ public:
typedef List<Section> SectionList;
public:
- ConfigFile();
- ~ConfigFile();
+ INIFile();
+ ~INIFile();
// TODO: Maybe add a copy constructor etc.?
@@ -95,7 +90,7 @@ public:
*/
static bool isValidName(const String &name);
- /** Reset everything stored in this config file. */
+ /** Reset everything stored in this ini file. */
void clear();
bool loadFromFile(const String &filename);
@@ -127,14 +122,6 @@ private:
const Section *getSection(const String &section) const;
};
-/*
-- ConfigMan owns a config file
-- allow direct access to that config file (for the launcher)
-- simplify and unify the regular ConfigMan API in exchange
-
-
-*/
-
} // End of namespace Common
#endif
diff --git a/common/module.mk b/common/module.mk
index 9f9126c8ef..1b34d151d0 100644
--- a/common/module.mk
+++ b/common/module.mk
@@ -2,7 +2,6 @@ MODULE := common
MODULE_OBJS := \
archive.o \
- config-file.o \
config-manager.o \
coroutines.o \
dcl.o \
@@ -15,6 +14,7 @@ MODULE_OBJS := \
gui_options.o \
hashmap.o \
iff_container.o \
+ ini-file.o \
installshield_cab.o \
language.o \
localization.o \
diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp
index 9176412e0e..40c9d1d049 100644
--- a/engines/agos/animation.cpp
+++ b/engines/agos/animation.cpp
@@ -272,7 +272,7 @@ void MoviePlayerDXA::copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch) {
if (!surface)
return;
- byte *src = (byte *)surface->pixels;
+ const byte *src = (const byte *)surface->getPixels();
dst += y * pitch + x;
do {
@@ -344,7 +344,7 @@ void MoviePlayerDXA::handleNextFrame() {
bool MoviePlayerDXA::processFrame() {
Graphics::Surface *screen = _vm->_system->lockScreen();
- copyFrameToBuffer((byte *)screen->pixels, (_vm->_screenWidth - getWidth()) / 2, (_vm->_screenHeight - getHeight()) / 2, screen->pitch);
+ copyFrameToBuffer((byte *)screen->getPixels(), (_vm->_screenWidth - getWidth()) / 2, (_vm->_screenHeight - getHeight()) / 2, screen->pitch);
_vm->_system->unlockScreen();
uint32 soundTime = _mixer->getSoundElapsedTime(_bgSound);
@@ -443,7 +443,7 @@ void MoviePlayerSMK::copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch) {
if (!surface)
return;
- byte *src = (byte *)surface->pixels;
+ const byte *src = (const byte *)surface->getPixels();
dst += y * pitch + x;
do {
@@ -495,7 +495,7 @@ void MoviePlayerSMK::nextFrame() {
bool MoviePlayerSMK::processFrame() {
Graphics::Surface *screen = _vm->_system->lockScreen();
- copyFrameToBuffer((byte *)screen->pixels, (_vm->_screenWidth - getWidth()) / 2, (_vm->_screenHeight - getHeight()) / 2, screen->pitch);
+ copyFrameToBuffer((byte *)screen->getPixels(), (_vm->_screenWidth - getWidth()) / 2, (_vm->_screenHeight - getHeight()) / 2, screen->pitch);
_vm->_system->unlockScreen();
uint32 waitTime = getTimeToNextFrame();
diff --git a/engines/agos/charset-fontdata.cpp b/engines/agos/charset-fontdata.cpp
index 262ae44f01..b6b90eefcc 100644
--- a/engines/agos/charset-fontdata.cpp
+++ b/engines/agos/charset-fontdata.cpp
@@ -2924,7 +2924,7 @@ void AGOSEngine::windowDrawChar(WindowBlock *window, uint x, uint y, byte chr) {
Graphics::Surface *screen = _system->lockScreen();
if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) {
- dst = (byte *)screen->pixels;
+ dst = (byte *)screen->getPixels();
dstPitch = screen->pitch;
h = 8;
w = 6;
@@ -2961,7 +2961,7 @@ void AGOSEngine::windowDrawChar(WindowBlock *window, uint x, uint y, byte chr) {
error("windowDrawChar: Unknown language %d", _language);
}
} else if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) {
- dst = (byte *)screen->pixels;
+ dst = (byte *)screen->getPixels();
dstPitch = screen->pitch;
h = 8;
w = 6;
@@ -2986,14 +2986,14 @@ void AGOSEngine::windowDrawChar(WindowBlock *window, uint x, uint y, byte chr) {
error("windowDrawChar: Unknown language %d", _language);
}
} else if (getGameType() == GType_ELVIRA1) {
- dst = (byte *)screen->pixels;
+ dst = (byte *)screen->getPixels();
dstPitch = screen->pitch;
h = 8;
w = 6;
src = english_elvira1Font + (chr - 32) * 8;
} else {
- dst = (byte *)screen->pixels;
+ dst = (byte *)screen->getPixels();
dstPitch = screen->pitch;
h = 8;
w = 8;
diff --git a/engines/agos/charset.cpp b/engines/agos/charset.cpp
index f58f4397b5..eca9728643 100644
--- a/engines/agos/charset.cpp
+++ b/engines/agos/charset.cpp
@@ -362,7 +362,7 @@ void AGOSEngine::windowScroll(WindowBlock *window) {
w = window->width * 8;
h = (window->height -1) * 8;
- dst = (byte *)screen->pixels + window->y * screen->pitch + window->x * 8;
+ dst = (byte *)screen->getBasePtr(window->x * 8, window->y);
src = dst + 8 * screen->pitch;
do {
diff --git a/engines/agos/draw.cpp b/engines/agos/draw.cpp
index cf3a12ceb8..d27aed29db 100644
--- a/engines/agos/draw.cpp
+++ b/engines/agos/draw.cpp
@@ -32,15 +32,15 @@
namespace AGOS {
byte *AGOSEngine::getBackBuf() {
- return (byte *)_backBuf->pixels;
+ return (byte *)_backBuf->getPixels();
}
byte *AGOSEngine::getBackGround() {
- return (byte *)_backGroundBuf->pixels;
+ return (byte *)_backGroundBuf->getPixels();
}
byte *AGOSEngine::getScaleBuf() {
- return (byte *)_scaleBuf->pixels;
+ return (byte *)_scaleBuf->getPixels();
}
#ifdef ENABLE_AGOS2
@@ -226,7 +226,7 @@ void AGOSEngine::animateSprites() {
debug(0, "Using special wall");
uint8 color, h, len;
- byte *dst = (byte *)_window4BackScn->pixels;
+ byte *dst = (byte *)_window4BackScn->getPixels();
color = (_variableArray[293] & 1) ? 13 : 15;
_wallOn = 2;
@@ -256,7 +256,7 @@ void AGOSEngine::animateSprites() {
} else if (getGameType() == GType_ELVIRA2 && _variableArray[71] & 2) {
// Used by the Unholy Barrier spell
uint8 color, h, len;
- byte *dst = (byte *)_window4BackScn->pixels;
+ byte *dst = (byte *)_window4BackScn->getPixels();
color = 1;
_wallOn = 2;
@@ -491,7 +491,7 @@ void AGOSEngine::saveBackGround(VgaSprite *vsp) {
int16 y = vsp->y - _scrollY;
if (_window3Flag == 1) {
- animTable->srcPtr = (const byte *)_window4BackScn->pixels;
+ animTable->srcPtr = (const byte *)_window4BackScn->getPixels();
} else {
int xoffs = (_videoWindows[vsp->windowNum * 4 + 0] * 2 + x) * 8;
int yoffs = (_videoWindows[vsp->windowNum * 4 + 1] + y);
@@ -565,7 +565,7 @@ void AGOSEngine::displayBoxStars() {
if (x_ >= 311)
continue;
- dst = (byte *)screen->pixels;
+ dst = (byte *)screen->getPixels();
dst += (((screen->pitch / 4) * y_) * 4) + x_;
@@ -673,7 +673,7 @@ void AGOSEngine::scrollScreen() {
if (getGameType() == GType_SIMON2) {
src = getBackGround();
- dst = (byte *)_window4BackScn->pixels;
+ dst = (byte *)_window4BackScn->getPixels();
for (int i = 0; i < _scrollHeight; i++) {
memcpy(dst, src, _screenWidth);
src += _backGroundBuf->pitch;
@@ -725,7 +725,7 @@ void AGOSEngine::fillBackFromBackGround(uint16 height, uint16 width) {
void AGOSEngine::fillBackFromFront() {
Graphics::Surface *screen = _system->lockScreen();
- byte *src = (byte *)screen->pixels;
+ byte *src = (byte *)screen->getPixels();
byte *dst = getBackBuf();
for (int i = 0; i < _screenHeight; i++) {
@@ -748,7 +748,7 @@ void AGOSEngine::fillBackGroundFromBack() {
void AGOSEngine::fillBackGroundFromFront() {
Graphics::Surface *screen = _system->lockScreen();
- byte *src = (byte *)screen->pixels;
+ byte *src = (byte *)screen->getPixels();
byte *dst = getBackGround();
for (int i = 0; i < _screenHeight; i++) {
@@ -785,7 +785,7 @@ void AGOSEngine::displayScreen() {
Graphics::Surface *screen = _system->lockScreen();
if (getGameType() == GType_PP || getGameType() == GType_FF) {
byte *src = getBackBuf();
- byte *dst = (byte *)screen->pixels;
+ byte *dst = (byte *)screen->getPixels();
for (int i = 0; i < _screenHeight; i++) {
memcpy(dst, src, _screenWidth);
src += _backBuf->pitch;
@@ -798,9 +798,9 @@ void AGOSEngine::displayScreen() {
_window4Flag = 0;
uint16 srcWidth, width, height;
- byte *dst = (byte *)screen->pixels;
+ byte *dst = (byte *)screen->getPixels();
- const byte *src = (const byte *)_window4BackScn->pixels;
+ const byte *src = (const byte *)_window4BackScn->getPixels();
if (_window3Flag == 1) {
src = getBackGround();
}
@@ -831,8 +831,8 @@ void AGOSEngine::displayScreen() {
if (_window6Flag == 2) {
_window6Flag = 0;
- byte *src = (byte *)_window6BackScn->pixels;
- byte *dst = (byte *)screen->pixels + 51 * screen->pitch;
+ byte *src = (byte *)_window6BackScn->getPixels();
+ byte *dst = (byte *)screen->getBasePtr(0, 51);
for (int i = 0; i < 80; i++) {
memcpy(dst, src, _window6BackScn->w);
dst += screen->pitch;
diff --git a/engines/agos/event.cpp b/engines/agos/event.cpp
index cc1c40c207..65c7f7fd77 100644
--- a/engines/agos/event.cpp
+++ b/engines/agos/event.cpp
@@ -365,7 +365,7 @@ void AGOSEngine::drawStuff(const byte *src, uint xoffs) {
const uint8 y = (getPlatform() == Common::kPlatformAtariST) ? 132 : 135;
Graphics::Surface *screen = _system->lockScreen();
- byte *dst = (byte *)screen->pixels + y * screen->pitch + xoffs;
+ byte *dst = (byte *)screen->getBasePtr(xoffs, y);
for (uint h = 0; h < 6; h++) {
memcpy(dst, src, 4);
diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp
index db0817250b..266fcc9796 100644
--- a/engines/agos/gfx.cpp
+++ b/engines/agos/gfx.cpp
@@ -649,7 +649,7 @@ void AGOSEngine_Simon1::drawImage(VC10_state *state) {
state->surf2_addr = getBackGround();
state->surf2_pitch = _backGroundBuf->pitch;
- state->surf_addr = (byte *)_window4BackScn->pixels;
+ state->surf_addr = (byte *)_window4BackScn->getPixels();
state->surf_pitch = _window4BackScn->pitch;
xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
@@ -666,7 +666,7 @@ void AGOSEngine_Simon1::drawImage(VC10_state *state) {
state->surf2_addr = getBackGround();
state->surf2_pitch = _backGroundBuf->pitch;
- state->surf_addr = (byte *)_window4BackScn->pixels;
+ state->surf_addr = (byte *)_window4BackScn->getPixels();
state->surf_pitch = _videoWindows[18] * 16;
xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
@@ -678,7 +678,7 @@ void AGOSEngine_Simon1::drawImage(VC10_state *state) {
_window4Flag = 1;
} else {
- state->surf_addr = (byte *)screen->pixels;
+ state->surf_addr = (byte *)screen->getPixels();
state->surf_pitch = screen->pitch;
xoffs = (vlut[0] * 2 + state->x) * 8;
@@ -696,7 +696,7 @@ void AGOSEngine_Simon1::drawImage(VC10_state *state) {
state->surf2_addr = getBackGround();
state->surf2_pitch = _backGroundBuf->pitch;
- state->surf_addr = (byte *)_window4BackScn->pixels;
+ state->surf_addr = (byte *)_window4BackScn->getPixels();
state->surf_pitch = _window4BackScn->pitch;
}
@@ -712,7 +712,7 @@ void AGOSEngine_Simon1::drawImage(VC10_state *state) {
state->surf2_addr = getBackGround();
state->surf2_pitch = _backGroundBuf->pitch;
- state->surf_addr = (byte *)screen->pixels;
+ state->surf_addr = (byte *)screen->getPixels();
state->surf_pitch = screen->pitch;
xoffs = (vlut[0] * 2 + state->x) * 8;
@@ -861,7 +861,7 @@ void AGOSEngine::drawImage(VC10_state *state) {
uint16 xoffs = 0, yoffs = 0;
if (getGameType() == GType_WW) {
if (_windowNum == 4 || (_windowNum >= 10 && _windowNum <= 27)) {
- state->surf_addr = (byte *)_window4BackScn->pixels;
+ state->surf_addr = (byte *)_window4BackScn->getPixels();
state->surf_pitch = _videoWindows[18] * 16;
xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
@@ -873,7 +873,7 @@ void AGOSEngine::drawImage(VC10_state *state) {
_window4Flag = 1;
} else {
- state->surf_addr = (byte *)screen->pixels;
+ state->surf_addr = (byte *)screen->getPixels();
state->surf_pitch = screen->pitch;
xoffs = (vlut[0] * 2 + state->x) * 8;
@@ -881,7 +881,7 @@ void AGOSEngine::drawImage(VC10_state *state) {
}
} else if (getGameType() == GType_ELVIRA2) {
if (_windowNum == 4 || _windowNum >= 10) {
- state->surf_addr = (byte *)_window4BackScn->pixels;
+ state->surf_addr = (byte *)_window4BackScn->getPixels();
state->surf_pitch = _videoWindows[18] * 16;
xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
@@ -893,7 +893,7 @@ void AGOSEngine::drawImage(VC10_state *state) {
_window4Flag = 1;
} else {
- state->surf_addr = (byte *)screen->pixels;
+ state->surf_addr = (byte *)screen->getPixels();
state->surf_pitch = screen->pitch;
xoffs = (vlut[0] * 2 + state->x) * 8;
@@ -901,19 +901,19 @@ void AGOSEngine::drawImage(VC10_state *state) {
}
} else if (getGameType() == GType_ELVIRA1) {
if (_windowNum == 6) {
- state->surf_addr = (byte *)_window6BackScn->pixels;
+ state->surf_addr = (byte *)_window6BackScn->getPixels();
state->surf_pitch = _window6BackScn->pitch;
xoffs = state->x * 8;
yoffs = state->y;
} else if (_windowNum == 2 || _windowNum == 3) {
- state->surf_addr = (byte *)screen->pixels;
+ state->surf_addr = (byte *)screen->getPixels();
state->surf_pitch = screen->pitch;
xoffs = (vlut[0] * 2 + state->x) * 8;
yoffs = vlut[1] + state->y;
} else {
- state->surf_addr = (byte *)_window4BackScn->pixels;
+ state->surf_addr = (byte *)_window4BackScn->getPixels();
state->surf_pitch = _videoWindows[18] * 16;
xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
@@ -926,7 +926,7 @@ void AGOSEngine::drawImage(VC10_state *state) {
_window4Flag = 1;
}
} else {
- state->surf_addr = (byte *)screen->pixels;
+ state->surf_addr = (byte *)screen->getPixels();
state->surf_pitch = screen->pitch;
xoffs = (vlut[0] * 2 + state->x) * 8;
@@ -973,7 +973,7 @@ void AGOSEngine::horizontalScroll(VC10_state *state) {
vcWriteVar(251, _scrollX);
if (getGameType() == GType_SIMON2) {
- dst = (byte *)_window4BackScn->pixels;
+ dst = (byte *)_window4BackScn->getPixels();
dstPitch = _window4BackScn->pitch;
} else {
dst = getBackBuf();
@@ -1375,10 +1375,10 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vgaSpriteId, bool specialCas
} else if (getGameType() == GType_SIMON1 && (getFeatures() & GF_DEMO)) {
// The DOS Floppy demo was based off Waxworks engine
if (updateWindow == 4 || updateWindow >= 10) {
- src = (byte *)_window4BackScn->pixels;
+ src = (byte *)_window4BackScn->getPixels();
srcWidth = _videoWindows[18] * 16;
} else if (updateWindow == 3 || updateWindow == 9) {
- src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+ src = (byte *)screen->getBasePtr(xoffs, yoffs);
srcWidth = screen->pitch;
} else {
_system->unlockScreen();
@@ -1387,13 +1387,13 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vgaSpriteId, bool specialCas
}
} else if (getGameType() == GType_SIMON1) {
if (updateWindow == 4) {
- src = (byte *)_window4BackScn->pixels;
+ src = (byte *)_window4BackScn->getPixels();
srcWidth = _videoWindows[18] * 16;
} else if (updateWindow >= 10) {
- src = (byte *)_window4BackScn->pixels + xoffs + yoffs * 320;
+ src = (byte *)_window4BackScn->getBasePtr(xoffs, yoffs);
srcWidth = _videoWindows[18] * 16;
} else if (updateWindow == 0) {
- src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+ src = (byte *)screen->getBasePtr(xoffs, yoffs);
srcWidth = screen->pitch;
} else {
_system->unlockScreen();
@@ -1402,10 +1402,10 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vgaSpriteId, bool specialCas
}
} else if (getGameType() == GType_WW) {
if (updateWindow == 4 || updateWindow >= 10) {
- src = (byte *)_window4BackScn->pixels;
+ src = (byte *)_window4BackScn->getPixels();
srcWidth = _videoWindows[18] * 16;
} else if (updateWindow == 3 || updateWindow == 9) {
- src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+ src = (byte *)screen->getBasePtr(xoffs, yoffs);
srcWidth = screen->pitch;
} else {
_system->unlockScreen();
@@ -1414,10 +1414,10 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vgaSpriteId, bool specialCas
}
} else if (getGameType() == GType_ELVIRA2) {
if (updateWindow == 4 || updateWindow >= 10) {
- src = (byte *)_window4BackScn->pixels;
+ src = (byte *)_window4BackScn->getPixels();
srcWidth = _videoWindows[18] * 16;
} else if (updateWindow == 3) {
- src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+ src = (byte *)screen->getBasePtr(xoffs, yoffs);
srcWidth = screen->pitch;
} else {
_system->unlockScreen();
@@ -1427,17 +1427,17 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vgaSpriteId, bool specialCas
} else if (getGameType() == GType_ELVIRA1) {
if (updateWindow == 6) {
_window6Flag = 1;
- src = (byte *)_window6BackScn->pixels;
+ src = (byte *)_window6BackScn->getPixels();
srcWidth = 48;
} else if (updateWindow == 2 || updateWindow == 3) {
- src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+ src = (byte *)screen->getBasePtr(xoffs, yoffs);
srcWidth = screen->pitch;
} else {
- src = (byte *)_window4BackScn->pixels;
+ src = (byte *)_window4BackScn->getPixels();
srcWidth = _videoWindows[18] * 16;
}
} else {
- src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+ src = (byte *)screen->getBasePtr(xoffs, yoffs);
srcWidth = screen->pitch;
}
@@ -1451,13 +1451,13 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vgaSpriteId, bool specialCas
if (getGameType() == GType_PN && !_wiped && !specialCase) {
uint8 color = (getPlatform() == Common::kPlatformDOS) ? 7 : 15;
- dst = (byte *)screen->pixels + 48;
+ dst = (byte *)screen->getBasePtr(48, 0);
memset(dst, color, 224);
- dst = (byte *)screen->pixels + 132 * screen->pitch + 48;
+ dst = (byte *)screen->getBasePtr(48, 132);
memset(dst, color, 224);
} else if (getGameType() == GType_ELVIRA1 && updateWindow == 3 && _bottomPalette) {
- dst = (byte *)screen->pixels + 133 * screen->pitch;
+ dst = (byte *)screen->getBasePtr(0, 133);
for (int h = 0; h < 67; h++) {
for (int w = 0; w < _screenWidth; w++)
@@ -1479,7 +1479,7 @@ void AGOSEngine::drawEdging() {
Graphics::Surface *screen = _system->lockScreen();
- dst = (byte *)screen->pixels + 136 * screen->pitch;
+ dst = (byte *)screen->getBasePtr(0, 136);
uint8 len = 52;
while (len--) {
@@ -1488,7 +1488,7 @@ void AGOSEngine::drawEdging() {
dst += screen->pitch;
}
- dst = (byte *)screen->pixels + 187 * screen->pitch;
+ dst = (byte *)screen->getBasePtr(0, 187);
memset(dst, color, _screenWidth);
_system->unlockScreen();
diff --git a/engines/agos/icons.cpp b/engines/agos/icons.cpp
index 0ee1d62fde..6d4192da2a 100644
--- a/engines/agos/icons.cpp
+++ b/engines/agos/icons.cpp
@@ -202,7 +202,7 @@ void AGOSEngine_Simon2::drawIcon(WindowBlock *window, uint icon, uint x, uint y)
_videoLockOut |= 0x8000;
Graphics::Surface *screen = _system->lockScreen();
- dst = (byte *)screen->pixels;
+ dst = (byte *)screen->getPixels();
dst += 110;
dst += x;
@@ -228,7 +228,7 @@ void AGOSEngine_Simon1::drawIcon(WindowBlock *window, uint icon, uint x, uint y)
_videoLockOut |= 0x8000;
Graphics::Surface *screen = _system->lockScreen();
- dst = (byte *)screen->pixels;
+ dst = (byte *)screen->getPixels();
dst += (x + window->x) * 8;
dst += (y * 25 + window->y) * screen->pitch;
@@ -256,7 +256,7 @@ void AGOSEngine_Waxworks::drawIcon(WindowBlock *window, uint icon, uint x, uint
_videoLockOut |= 0x8000;
Graphics::Surface *screen = _system->lockScreen();
- dst = (byte *)screen->pixels;
+ dst = (byte *)screen->getPixels();
dst += (x + window->x) * 8;
dst += (y * 20 + window->y) * screen->pitch;
@@ -284,7 +284,7 @@ void AGOSEngine_Elvira2::drawIcon(WindowBlock *window, uint icon, uint x, uint y
_videoLockOut |= 0x8000;
Graphics::Surface *screen = _system->lockScreen();
- dst = (byte *)screen->pixels;
+ dst = (byte *)screen->getPixels();
dst += (x + window->x) * 8;
dst += (y * 8 + window->y) * screen->pitch;
@@ -312,7 +312,7 @@ void AGOSEngine_Elvira1::drawIcon(WindowBlock *window, uint icon, uint x, uint y
_videoLockOut |= 0x8000;
Graphics::Surface *screen = _system->lockScreen();
- dst = (byte *)screen->pixels;
+ dst = (byte *)screen->getPixels();
dst += (x + window->x) * 8;
dst += (y * 8 + window->y) * screen->pitch;
@@ -339,7 +339,7 @@ void AGOSEngine::drawIcon(WindowBlock *window, uint icon, uint x, uint y) {
_videoLockOut |= 0x8000;
Graphics::Surface *screen = _system->lockScreen();
- dst = (byte *)screen->pixels + y * screen->pitch + x * 8;
+ dst = (byte *)screen->getBasePtr(x * 8, y);
src = _iconFilePtr + icon * 146;
if (icon == 0xFF) {
@@ -951,7 +951,7 @@ void AGOSEngine::drawArrow(uint16 x, uint16 y, int8 dir) {
}
Graphics::Surface *screen = _system->lockScreen();
- byte *dst = (byte *)screen->pixels + y * screen->pitch + x * 8;
+ byte *dst = (byte *)screen->getBasePtr(x * 8, y);
for (h = 0; h < 19; h++) {
for (w = 0; w < 16; w++) {
@@ -1042,7 +1042,7 @@ static const byte hitBarData[12 * 7] = {
// Personal Nightmare specific
void AGOSEngine_PN::drawIconHitBar() {
Graphics::Surface *screen = _system->lockScreen();
- byte *dst = (byte *)screen->pixels + 3 * screen->pitch + 6 * 8;
+ byte *dst = (byte *)screen->getBasePtr(6 * 8, 3);
const byte *src = hitBarData;
uint8 color = (getPlatform() == Common::kPlatformDOS) ? 7 : 15;
diff --git a/engines/agos/menus.cpp b/engines/agos/menus.cpp
index a0d2bdcaa0..85c50e421b 100644
--- a/engines/agos/menus.cpp
+++ b/engines/agos/menus.cpp
@@ -164,7 +164,7 @@ void AGOSEngine::unlightMenuStrip() {
mouseOff();
Graphics::Surface *screen = _system->lockScreen();
- src = (byte *)screen->pixels + 8 * screen->pitch + 272;
+ src = (byte *)screen->getBasePtr(272, 8);
w = 48;
h = 82;
@@ -192,7 +192,7 @@ void AGOSEngine::lightMenuBox(uint hitarea) {
mouseOff();
Graphics::Surface *screen = _system->lockScreen();
- src = (byte *)screen->pixels + ha->y * screen->pitch + ha->x;
+ src = (byte *)screen->getBasePtr(ha->x, ha->y);
w = ha->width;
h = ha->height;
diff --git a/engines/agos/verb.cpp b/engines/agos/verb.cpp
index 93077ed83e..f5b57a01c8 100644
--- a/engines/agos/verb.cpp
+++ b/engines/agos/verb.cpp
@@ -973,7 +973,7 @@ void AGOSEngine::invertBox(HitArea *ha, byte a, byte b, byte c, byte d) {
_videoLockOut |= 0x8000;
Graphics::Surface *screen = _system->lockScreen();
- src = (byte *)screen->pixels + ha->y * screen->pitch + ha->x;
+ src = (byte *)screen->getBasePtr(ha->x, ha->y);
// WORKAROUND: Hitareas for saved game names aren't adjusted for scrolling locations
if (getGameType() == GType_SIMON2 && ha->id >= 208 && ha->id <= 213) {
diff --git a/engines/agos/vga.cpp b/engines/agos/vga.cpp
index 8541f579d6..cc5ede5f2c 100644
--- a/engines/agos/vga.cpp
+++ b/engines/agos/vga.cpp
@@ -1179,7 +1179,7 @@ void AGOSEngine::vc32_saveScreen() {
if (getGameType() == GType_PN) {
Graphics::Surface *screen = _system->lockScreen();
byte *dst = getBackGround();
- byte *src = (byte *)screen->pixels;
+ byte *src = (byte *)screen->getPixels();
for (int i = 0; i < _screenHeight; i++) {
memcpy(dst, src, _screenWidth);
dst += _backGroundBuf->pitch;
@@ -1193,7 +1193,7 @@ void AGOSEngine::vc32_saveScreen() {
uint16 height = _videoWindows[4 * 4 + 3];
byte *dst = (byte *)_backGroundBuf->getBasePtr(xoffs, yoffs);
- byte *src = (byte *)_window4BackScn->pixels;
+ byte *src = (byte *)_window4BackScn->getPixels();
uint16 srcWidth = _videoWindows[4 * 4 + 2] * 16;
for (; height > 0; height--) {
memcpy(dst, src, width);
@@ -1247,7 +1247,7 @@ void AGOSEngine::clearVideoWindow(uint16 num, uint16 color) {
if (getGameType() == GType_ELVIRA1 && num == 3) {
Graphics::Surface *screen = _system->lockScreen();
- byte *dst = (byte *)screen->pixels;
+ byte *dst = (byte *)screen->getPixels();
for (int i = 0; i < _screenHeight; i++) {
memset(dst, color, _screenWidth);
dst += screen->pitch;
@@ -1258,7 +1258,10 @@ void AGOSEngine::clearVideoWindow(uint16 num, uint16 color) {
uint16 xoffs = (vlut[0] - _videoWindows[16]) * 16;
uint16 yoffs = (vlut[1] - _videoWindows[17]);
uint16 dstWidth = _videoWindows[18] * 16;
- byte *dst = (byte *)_window4BackScn->pixels + xoffs + yoffs * dstWidth;
+ // TODO: Is there any known connection between dstWidth and the pitch
+ // of the _window4BackScn Surface? If so, we might be able to pass
+ // yoffs as proper y parameter to getBasePtr.
+ byte *dst = (byte *)_window4BackScn->getBasePtr(xoffs, 0) + yoffs * dstWidth;
setMoveRect(0, 0, vlut[2] * 16, vlut[3]);
diff --git a/engines/agos/vga_e2.cpp b/engines/agos/vga_e2.cpp
index d4aafd3d7b..4eb337c687 100644
--- a/engines/agos/vga_e2.cpp
+++ b/engines/agos/vga_e2.cpp
@@ -76,7 +76,7 @@ void AGOSEngine::vc45_setWindowPalette() {
uint8 height = vlut[3];
if (num == 4) {
- byte *dst = (byte *)_window4BackScn->pixels;
+ byte *dst = (byte *)_window4BackScn->getPixels();
for (uint8 h = 0; h < height; h++) {
for (uint8 w = 0; w < width; w++) {
@@ -223,11 +223,11 @@ void AGOSEngine::vc53_dissolveIn() {
uint16 count = dissolveCheck * 2;
while (count--) {
Graphics::Surface *screen = _system->lockScreen();
- byte *dstPtr = (byte *)screen->pixels + x + y * screen->pitch;
+ byte *dstPtr = (byte *)screen->getBasePtr(x, y);
yoffs = _rnd.getRandomNumber(dissolveY);
dst = dstPtr + yoffs * screen->pitch;
- src = (byte *)_window4BackScn->pixels + yoffs * _window4BackScn->pitch;
+ src = (byte *)_window4BackScn->getBasePtr(0, yoffs);
xoffs = _rnd.getRandomNumber(dissolveX);
dst += xoffs;
@@ -296,7 +296,7 @@ void AGOSEngine::vc54_dissolveOut() {
uint16 count = dissolveCheck * 2;
while (count--) {
Graphics::Surface *screen = _system->lockScreen();
- byte *dstPtr = (byte *)screen->pixels + x + y * screen->pitch;
+ byte *dstPtr = (byte *)screen->getBasePtr(x, y);
color |= dstPtr[0] & 0xF0;
yoffs = _rnd.getRandomNumber(dissolveY);
@@ -378,7 +378,7 @@ void AGOSEngine::fullFade() {
void AGOSEngine::vc56_fullScreen() {
Graphics::Surface *screen = _system->lockScreen();
- byte *dst = (byte *)screen->pixels;
+ byte *dst = (byte *)screen->getPixels();
byte *src = _curVgaFile2 + 800;
for (int i = 0; i < _screenHeight; i++) {
diff --git a/engines/agos/vga_pn.cpp b/engines/agos/vga_pn.cpp
index 1e7b2ba060..b7f80ebf91 100644
--- a/engines/agos/vga_pn.cpp
+++ b/engines/agos/vga_pn.cpp
@@ -155,7 +155,7 @@ void AGOSEngine::vc48_specialEffect() {
if (getPlatform() == Common::kPlatformDOS) {
if (num == 1) {
Graphics::Surface *screen = _system->lockScreen();
- byte *dst = (byte *)screen->pixels;
+ byte *dst = (byte *)screen->getPixels();
for (uint h = 0; h < _screenHeight; h++) {
for (uint w = 0; w < _screenWidth; w++) {
@@ -205,7 +205,7 @@ void AGOSEngine_PN::clearVideoWindow(uint16 num, uint16 color) {
uint16 yoffs = vlut[1];
Graphics::Surface *screen = _system->lockScreen();
- byte *dst = (byte *)screen->pixels + xoffs + yoffs * screen->pitch;
+ byte *dst = (byte *)screen->getBasePtr(xoffs, yoffs);
for (uint h = 0; h < vlut[3]; h++) {
memset(dst, color, vlut[2] * 16);
dst += screen->pitch;
diff --git a/engines/agos/vga_s2.cpp b/engines/agos/vga_s2.cpp
index 9b9ed4e297..e0780b491a 100644
--- a/engines/agos/vga_s2.cpp
+++ b/engines/agos/vga_s2.cpp
@@ -213,7 +213,10 @@ void AGOSEngine_Simon2::clearVideoWindow(uint16 num, uint16 color) {
uint16 xoffs = vlut[0] * 16;
uint16 yoffs = vlut[1];
uint16 dstWidth = _videoWindows[18] * 16;
- byte *dst = (byte *)_window4BackScn->pixels + xoffs + yoffs * dstWidth;
+ // TODO: Is there any known connection between dstWidth and the pitch
+ // of the _window4BackScn Surface? If so, we might be able to pass
+ // yoffs as proper y parameter to getBasePtr.
+ byte *dst = (byte *)_window4BackScn->getBasePtr(xoffs, 0) + yoffs * dstWidth;
setMoveRect(0, 0, vlut[2] * 16, vlut[3]);
diff --git a/engines/agos/vga_ww.cpp b/engines/agos/vga_ww.cpp
index c74f0cf52b..ca93fa9fec 100644
--- a/engines/agos/vga_ww.cpp
+++ b/engines/agos/vga_ww.cpp
@@ -143,7 +143,7 @@ void AGOSEngine::vc61() {
uint h, tmp;
Graphics::Surface *screen = _system->lockScreen();
- dstPtr = (byte *)screen->pixels;
+ dstPtr = (byte *)screen->getPixels();
if (a == 6) {
src = _curVgaFile2 + 800;
diff --git a/engines/agos/window.cpp b/engines/agos/window.cpp
index 0365c736d8..892df92554 100644
--- a/engines/agos/window.cpp
+++ b/engines/agos/window.cpp
@@ -170,7 +170,7 @@ void AGOSEngine::colorBlock(WindowBlock *window, uint16 x, uint16 y, uint16 w, u
_videoLockOut |= 0x8000;
Graphics::Surface *screen = _system->lockScreen();
- byte *dst = (byte *)screen->pixels + y * screen->pitch + x;
+ byte *dst = (byte *)screen->getBasePtr(x, y);
uint8 color = window->fillColor;
if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW)
@@ -232,7 +232,7 @@ void AGOSEngine::restoreBlock(uint16 x, uint16 y, uint16 w, uint16 h) {
uint i;
Graphics::Surface *screen = _system->lockScreen();
- dst = (byte *)screen->pixels;
+ dst = (byte *)screen->getPixels();
src = getBackGround();
dst += y * screen->pitch;
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index f4f1cd3e0b..ae4dee6090 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -358,7 +358,7 @@ void CGEEngine::writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &he
// Create a thumbnail and save it
Graphics::Surface *thumb = new Graphics::Surface();
Graphics::Surface *s = _vga->_page[0];
- ::createThumbnail(thumb, (const byte *)s->pixels, kScrWidth, kScrHeight, thumbPalette);
+ ::createThumbnail(thumb, (const byte *)s->getPixels(), kScrWidth, kScrHeight, thumbPalette);
Graphics::saveThumbnail(*out, *thumb);
thumb->free();
delete thumb;
diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp
index 56a0754527..c0407cab42 100644
--- a/engines/cge/vga13h.cpp
+++ b/engines/cge/vga13h.cpp
@@ -826,7 +826,7 @@ void Vga::update() {
}
}
- g_system->copyRectToScreen(Vga::_page[0]->getBasePtr(0, 0), kScrWidth, 0, 0, kScrWidth, kScrHeight);
+ g_system->copyRectToScreen(Vga::_page[0]->getPixels(), kScrWidth, 0, 0, kScrWidth, kScrHeight);
g_system->updateScreen();
}
@@ -845,7 +845,7 @@ void Bitmap::xShow(int16 x, int16 y) {
debugC(4, kCGEDebugBitmap, "Bitmap::xShow(%d, %d)", x, y);
const byte *srcP = (const byte *)_v;
- byte *destEndP = (byte *)_vm->_vga->_page[1]->pixels + (kScrWidth * kScrHeight);
+ byte *destEndP = (byte *)_vm->_vga->_page[1]->getBasePtr(0, kScrHeight);
byte *lookupTable = _m;
// Loop through processing data for each plane. The game originally ran in plane mapped mode, where a
@@ -898,7 +898,7 @@ void Bitmap::show(int16 x, int16 y) {
debugC(5, kCGEDebugBitmap, "Bitmap::show(%d, %d)", x, y);
const byte *srcP = (const byte *)_v;
- byte *destEndP = (byte *)_vm->_vga->_page[1]->pixels + (kScrWidth * kScrHeight);
+ byte *destEndP = (byte *)_vm->_vga->_page[1]->getBasePtr(0, kScrHeight);
// Loop through processing data for each plane. The game originally ran in plane mapped mode, where a
// given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data
diff --git a/engines/composer/composer.h b/engines/composer/composer.h
index 33a5356b3a..7d8022455a 100644
--- a/engines/composer/composer.h
+++ b/engines/composer/composer.h
@@ -23,7 +23,7 @@
#ifndef COMPOSER_H
#define COMPOSER_H
-#include "common/config-file.h"
+#include "common/ini-file.h"
#include "common/random.h"
#include "common/system.h"
#include "common/debug.h"
@@ -174,7 +174,7 @@ private:
Common::List<Sprite> _sprites;
uint _directoriesToStrip;
- Common::ConfigFile _bookIni;
+ Common::INIFile _bookIni;
Common::String _bookGroup;
Common::List<Library> _libraries;
Common::Array<PendingPageChange> _pendingPageChanges;
diff --git a/engines/composer/graphics.cpp b/engines/composer/graphics.cpp
index 2b68fac233..caf3ba3a40 100644
--- a/engines/composer/graphics.cpp
+++ b/engines/composer/graphics.cpp
@@ -39,7 +39,7 @@ bool Sprite::contains(const Common::Point &pos) const {
return false;
if (adjustedPos.y < 0 || adjustedPos.y >= _surface.h)
return false;
- byte *pixels = (byte *)_surface.pixels;
+ const byte *pixels = (const byte *)_surface.getPixels();
return (pixels[(_surface.h - adjustedPos.y - 1) * _surface.w + adjustedPos.x] != 0);
}
@@ -541,7 +541,7 @@ void ComposerEngine::redraw() {
for (uint i = 0; i < _dirtyRects.size(); i++) {
const Common::Rect &rect = _dirtyRects[i];
- byte *pixels = (byte *)_screen.pixels + (rect.top * _screen.pitch) + rect.left;
+ byte *pixels = (byte *)_screen.getBasePtr(rect.left, rect.top);
_system->copyRectToScreen(pixels, _screen.pitch, rect.left, rect.top, rect.width(), rect.height());
}
_system->updateScreen();
@@ -794,7 +794,7 @@ bool ComposerEngine::initSprite(Sprite &sprite) {
if (width > 0 && height > 0) {
sprite._surface.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
- decompressBitmap(type, stream, (byte *)sprite._surface.pixels, size, width, height);
+ decompressBitmap(type, stream, (byte *)sprite._surface.getPixels(), size, width, height);
} else {
// there are some sprites (e.g. a -998x-998 one in Gregory's title screen)
// which have an invalid size, but the original engine doesn't notice for
@@ -814,13 +814,13 @@ void ComposerEngine::drawSprite(const Sprite &sprite) {
int y = sprite._pos.y;
// incoming data is BMP-style (bottom-up), so flip it
- byte *pixels = (byte *)_screen.pixels;
+ byte *pixels = (byte *)_screen.getPixels();
for (int j = 0; j < sprite._surface.h; j++) {
if (j + y < 0)
continue;
if (j + y >= _screen.h)
break;
- byte *in = (byte *)sprite._surface.pixels + (sprite._surface.h - j - 1) * sprite._surface.w;
+ const byte *in = (const byte *)sprite._surface.getBasePtr(0, sprite._surface.h - j - 1);
byte *out = pixels + ((j + y) * _screen.w) + x;
for (int i = 0; i < sprite._surface.w; i++)
if ((x + i >= 0) && (x + i < _screen.w) && in[i])
diff --git a/engines/draci/screen.cpp b/engines/draci/screen.cpp
index 8c1a0c40f7..e43e367300 100644
--- a/engines/draci/screen.cpp
+++ b/engines/draci/screen.cpp
@@ -110,7 +110,7 @@ void Screen::copyToScreen() {
// If a full update is needed, update the whole screen
if (_surface->needsFullUpdate()) {
- byte *ptr = (byte *)_surface->getBasePtr(0, 0);
+ byte *ptr = (byte *)_surface->getPixels();
_vm->_system->copyRectToScreen(ptr, kScreenWidth,
0, 0, kScreenWidth, kScreenHeight);
@@ -138,7 +138,7 @@ void Screen::copyToScreen() {
* Clears the screen and marks the whole screen dirty.
*/
void Screen::clearScreen() {
- byte *ptr = (byte *)_surface->getBasePtr(0, 0);
+ byte *ptr = (byte *)_surface->getPixels();
_surface->markDirty();
diff --git a/engines/draci/surface.cpp b/engines/draci/surface.cpp
index 8380f8777b..3676c6edac 100644
--- a/engines/draci/surface.cpp
+++ b/engines/draci/surface.cpp
@@ -80,7 +80,7 @@ void Surface::markClean() {
* @brief Fills the surface with the specified color
*/
void Surface::fill(uint color) {
- byte *ptr = (byte *)getBasePtr(0, 0);
+ byte *ptr = (byte *)getPixels();
memset(ptr, color, w * h);
}
diff --git a/engines/drascula/graphics.cpp b/engines/drascula/graphics.cpp
index 3bdf724670..31d03a94a7 100644
--- a/engines/drascula/graphics.cpp
+++ b/engines/drascula/graphics.cpp
@@ -132,7 +132,7 @@ void DrasculaEngine::showFrame(Common::SeekableReadStream *stream, bool firstFra
byte *prevFrame = (byte *)malloc(64000);
Graphics::Surface *screenSurf = _system->lockScreen();
- byte *screenBuffer = (byte *)screenSurf->pixels;
+ byte *screenBuffer = (byte *)screenSurf->getPixels();
uint16 screenPitch = screenSurf->pitch;
for (int y = 0; y < 200; y++) {
memcpy(prevFrame+y*320, screenBuffer+y*screenPitch, 320);
@@ -449,7 +449,7 @@ void DrasculaEngine::screenSaver() {
int x1_, y1_, off1, off2;
Graphics::Surface *screenSurf = _system->lockScreen();
- byte *screenBuffer = (byte *)screenSurf->pixels;
+ byte *screenBuffer = (byte *)screenSurf->getPixels();
uint16 screenPitch = screenSurf->pitch;
for (int i = 0; i < 200; i++) {
for (int j = 0; j < 320; j++) {
@@ -538,7 +538,7 @@ int DrasculaEngine::playFrameSSN(Common::SeekableReadStream *stream) {
waitFrameSSN();
Graphics::Surface *screenSurf = _system->lockScreen();
- byte *screenBuffer = (byte *)screenSurf->pixels;
+ byte *screenBuffer = (byte *)screenSurf->getPixels();
uint16 screenPitch = screenSurf->pitch;
if (FrameSSN)
mixVideo(screenBuffer, screenSurface, screenPitch);
@@ -557,7 +557,7 @@ int DrasculaEngine::playFrameSSN(Common::SeekableReadStream *stream) {
free(BufferSSN);
waitFrameSSN();
Graphics::Surface *screenSurf = _system->lockScreen();
- byte *screenBuffer = (byte *)screenSurf->pixels;
+ byte *screenBuffer = (byte *)screenSurf->getPixels();
uint16 screenPitch = screenSurf->pitch;
if (FrameSSN)
mixVideo(screenBuffer, screenSurface, screenPitch);
diff --git a/engines/gob/iniconfig.cpp b/engines/gob/iniconfig.cpp
index bba531723c..032231bd4d 100644
--- a/engines/gob/iniconfig.cpp
+++ b/engines/gob/iniconfig.cpp
@@ -73,7 +73,7 @@ bool INIConfig::getConfig(const Common::String &file, Config &config) {
}
bool INIConfig::openConfig(const Common::String &file, Config &config) {
- config.config = new Common::ConfigFile();
+ config.config = new Common::INIFile();
config.created = false;
if (!config.config->loadFromFile(file)) {
@@ -89,7 +89,7 @@ bool INIConfig::openConfig(const Common::String &file, Config &config) {
}
bool INIConfig::createConfig(const Common::String &file, Config &config) {
- config.config = new Common::ConfigFile();
+ config.config = new Common::INIFile();
config.created = true;
_configs.setVal(file, config);
diff --git a/engines/gob/iniconfig.h b/engines/gob/iniconfig.h
index bf60f2d125..c1890170dc 100644
--- a/engines/gob/iniconfig.h
+++ b/engines/gob/iniconfig.h
@@ -24,7 +24,7 @@
#define GOB_INICONFIG_H
#include "common/str.h"
-#include "common/config-file.h"
+#include "common/ini-file.h"
#include "common/hashmap.h"
namespace Gob {
@@ -43,7 +43,7 @@ public:
private:
struct Config {
- Common::ConfigFile *config;
+ Common::INIFile *config;
bool created;
};
diff --git a/engines/gob/surface.cpp b/engines/gob/surface.cpp
index 839378a412..870b0f15b3 100644
--- a/engines/gob/surface.cpp
+++ b/engines/gob/surface.cpp
@@ -821,7 +821,7 @@ bool Surface::loadIFF(Common::SeekableReadStream &stream) {
return false;
resize(decoder.getSurface()->w, decoder.getSurface()->h);
- memcpy(_vidMem, decoder.getSurface()->pixels, decoder.getSurface()->w * decoder.getSurface()->h);
+ memcpy(_vidMem, decoder.getSurface()->getPixels(), decoder.getSurface()->w * decoder.getSurface()->h);
return true;
}
diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp
index a478492ccc..155989ccee 100644
--- a/engines/gob/videoplayer.cpp
+++ b/engines/gob/videoplayer.cpp
@@ -734,7 +734,11 @@ bool VideoPlayer::copyFrame(int slot, Surface &dest,
if (!surface)
return false;
- Surface src(surface->w, surface->h, surface->format.bytesPerPixel, (byte *)surface->pixels);
+ // FIXME? This currently casts away const from the pixel data. However, it
+ // is only used read-only in this case (as far as I can tell). Not casting
+ // the const qualifier away will lead to an additional allocation and copy
+ // of the frame data which is undesirable.
+ Surface src(surface->w, surface->h, surface->format.bytesPerPixel, (byte *)const_cast<void *>(surface->getPixels()));
dest.blit(src, left, top, left + width - 1, top + height - 1, x, y, transp);
return true;
diff --git a/engines/groovie/graphics.cpp b/engines/groovie/graphics.cpp
index 73eb574dec..a4d8a4330c 100644
--- a/engines/groovie/graphics.cpp
+++ b/engines/groovie/graphics.cpp
@@ -82,8 +82,8 @@ void GraphicsMan::mergeFgAndBg() {
uint32 i;
byte *countf, *countb;
- countf = (byte *)_foreground.getBasePtr(0, 0);
- countb = (byte *)_background.getBasePtr(0, 0);
+ countf = (byte *)_foreground.getPixels();
+ countb = (byte *)_background.getPixels();
for (i = 640 * 320; i; i--) {
if (255 == *(countf)) {
*(countf) = *(countb);
@@ -94,7 +94,7 @@ void GraphicsMan::mergeFgAndBg() {
}
void GraphicsMan::updateScreen(Graphics::Surface *source) {
- _vm->_system->copyRectToScreen(source->getBasePtr(0, 0), 640, 0, 80, 640, 320);
+ _vm->_system->copyRectToScreen(source->getPixels(), 640, 0, 80, 640, 320);
change();
}
diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp
index 72a61fefb2..f9a938bfd4 100644
--- a/engines/groovie/roq.cpp
+++ b/engines/groovie/roq.cpp
@@ -160,7 +160,7 @@ bool ROQPlayer::playFrameInternal() {
if (_dirty) {
// Update the screen
- _syst->copyRectToScreen(_bg->getBasePtr(0, 0), _bg->pitch, 0, (_syst->getHeight() - _bg->h) / 2, _bg->w, _bg->h);
+ _syst->copyRectToScreen(_bg->getPixels(), _bg->pitch, 0, (_syst->getHeight() - _bg->h) / 2, _bg->w, _bg->h);
_syst->updateScreen();
// Clear the dirty flag
@@ -291,8 +291,8 @@ bool ROQPlayer::processBlockInfo(ROQBlockHeader &blockHeader) {
}
// Clear the buffers with black YUV values
- byte *ptr1 = (byte *)_currBuf->getBasePtr(0, 0);
- byte *ptr2 = (byte *)_prevBuf->getBasePtr(0, 0);
+ byte *ptr1 = (byte *)_currBuf->getPixels();
+ byte *ptr2 = (byte *)_prevBuf->getPixels();
for (int i = 0; i < width * height; i++) {
*ptr1++ = 0;
*ptr1++ = 128;
@@ -436,11 +436,11 @@ bool ROQPlayer::processBlockStill(ROQBlockHeader &blockHeader) {
Graphics::JPEGDecoder *jpg = new Graphics::JPEGDecoder();
jpg->loadStream(*_file);
- const byte *y = (const byte *)jpg->getComponent(1)->getBasePtr(0, 0);
- const byte *u = (const byte *)jpg->getComponent(2)->getBasePtr(0, 0);
- const byte *v = (const byte *)jpg->getComponent(3)->getBasePtr(0, 0);
+ const byte *y = (const byte *)jpg->getComponent(1)->getPixels();
+ const byte *u = (const byte *)jpg->getComponent(2)->getPixels();
+ const byte *v = (const byte *)jpg->getComponent(3)->getPixels();
- byte *ptr = (byte *)_currBuf->getBasePtr(0, 0);
+ byte *ptr = (byte *)_currBuf->getPixels();
for (int i = 0; i < _currBuf->w * _currBuf->h; i++) {
*ptr++ = *y++;
*ptr++ = *u++;
diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp
index cbbdecc3e7..8e3bef9945 100644
--- a/engines/groovie/script.cpp
+++ b/engines/groovie/script.cpp
@@ -373,7 +373,7 @@ bool Script::hotspot(Common::Rect rect, uint16 address, uint8 cursor) {
DebugMan.isDebugChannelEnabled(kGroovieDebugAll)) {
rect.translate(0, -80);
_vm->_graphicsMan->_foreground.frameRect(rect, 250);
- _vm->_system->copyRectToScreen(_vm->_graphicsMan->_foreground.getBasePtr(0, 0), _vm->_graphicsMan->_foreground.pitch, 0, 80, 640, 320);
+ _vm->_system->copyRectToScreen(_vm->_graphicsMan->_foreground.getPixels(), _vm->_graphicsMan->_foreground.pitch, 0, 80, 640, 320);
_vm->_system->updateScreen();
}
@@ -983,7 +983,7 @@ void Script::o_strcmpnejmp_var() { // 0x21
void Script::o_copybgtofg() { // 0x22
debugScript(1, true, "COPY_BG_TO_FG");
- memcpy(_vm->_graphicsMan->_foreground.getBasePtr(0, 0), _vm->_graphicsMan->_background.getBasePtr(0, 0), 640 * 320);
+ memcpy(_vm->_graphicsMan->_foreground.getPixels(), _vm->_graphicsMan->_background.getPixels(), 640 * 320);
}
void Script::o_strcmpeqjmp() { // 0x23
diff --git a/engines/groovie/vdx.cpp b/engines/groovie/vdx.cpp
index 8786e75488..59d966a22f 100644
--- a/engines/groovie/vdx.cpp
+++ b/engines/groovie/vdx.cpp
@@ -358,7 +358,7 @@ void VDXPlayer::getStill(Common::ReadStream *in) {
byte *buf;
if (_flagOne) {
// Paint to the foreground
- buf = (byte *)_fg->getBasePtr(0, 0);
+ buf = (byte *)_fg->getPixels();
if (_flag2Byte) {
mask = 0xff;
} else {
@@ -370,7 +370,7 @@ void VDXPlayer::getStill(Common::ReadStream *in) {
_flagFirstFrame = true;
} else {
// Paint to the background
- buf = (byte *)_bg->getBasePtr(0, 0);
+ buf = (byte *)_bg->getPixels();
}
// Read the palette
@@ -486,9 +486,9 @@ void VDXPlayer::decodeBlockDelta(uint32 offset, byte *colors, uint16 imageWidth)
// TODO: Verify just the else block is required
//if (_flagOne) {
// Paint to the foreground
- //dest = (byte *)_fg->getBasePtr(0, 0) + offset;
+ //dest = (byte *)_fg->getPixels() + offset;
//} else {
- dest = (byte *)_bg->getBasePtr(0, 0) + offset;
+ dest = (byte *)_bg->getPixels() + offset;
//}
// Move the pointers to the beginning of the current block
@@ -496,8 +496,8 @@ void VDXPlayer::decodeBlockDelta(uint32 offset, byte *colors, uint16 imageWidth)
dest += blockOff;
byte *fgBuf = 0;
if (_flagSeven) {
- fgBuf = (byte *)_fg->getBasePtr(0, 0) + offset + blockOff;
- //byte *bgBuf = (byte *)_bg->getBasePtr(0, 0) + offset + blockOff;
+ fgBuf = (byte *)_fg->getPixels() + offset + blockOff;
+ //byte *bgBuf = (byte *)_bg->getPixels() + offset + blockOff;
}
for (int y = TILE_SIZE; y; y--) {
@@ -550,7 +550,7 @@ void VDXPlayer::fadeIn(uint8 *targetpal) {
// TODO: Is it required? If so, move to an appropiate place
// Copy the foreground to the background
- memcpy((byte *)_vm->_graphicsMan->_foreground.getBasePtr(0, 0), (byte *)_vm->_graphicsMan->_background.getBasePtr(0, 0), 640 * 320);
+ memcpy((byte *)_vm->_graphicsMan->_foreground.getPixels(), (byte *)_vm->_graphicsMan->_background.getPixels(), 640 * 320);
// Start a fadein
_vm->_graphicsMan->fadeIn(targetpal);
diff --git a/engines/hopkins/dialogs.cpp b/engines/hopkins/dialogs.cpp
index ab672d4c48..3b8fedf0ee 100644
--- a/engines/hopkins/dialogs.cpp
+++ b/engines/hopkins/dialogs.cpp
@@ -691,7 +691,7 @@ void DialogsManager::showSaveLoad(SaveLoadMode mode) {
Graphics::Surface thumb8;
_vm->_saveLoad->convertThumb16To8(header._thumbnail, &thumb8);
- byte *thumb = (byte *)thumb8.pixels;
+ byte *thumb = (byte *)thumb8.getPixels();
int16 startPosX_ = _vm->_events->_startPos.x;
switch (slotNumber) {
diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp
index b83371d65f..de9f043763 100644
--- a/engines/hopkins/graphics.cpp
+++ b/engines/hopkins/graphics.cpp
@@ -325,7 +325,7 @@ void GraphicsManager::loadPCX640(byte *surface, const Common::String &file, byte
// Copy out the dimensions and pixels of the decoded surface
_largeScreenFl = s->w > SCREEN_WIDTH;
- Common::copy((byte *)s->pixels, (byte *)s->pixels + (s->pitch * s->h), surface);
+ Common::copy((const byte *)s->getPixels(), (const byte *)s->getBasePtr(0, s->h), surface);
// Copy out the palette
const byte *palSrc = pcxDecoder.getPalette();
@@ -1202,15 +1202,13 @@ void GraphicsManager::displayZones() {
void GraphicsManager::displayLines() {
Graphics::Surface *screenSurface = g_system->lockScreen();
- uint16* pixels = (uint16*)screenSurface->pixels;
-
for (int lineIndex = 0; lineIndex < _vm->_linesMan->_linesNumb; lineIndex++) {
int i = 0;
do {
int x = _vm->_linesMan->_lineItem[lineIndex]._lineData[i] - _scrollPosX;
int y = _vm->_linesMan->_lineItem[lineIndex]._lineData[i+1];
if (x >= 0 && x < SCREEN_WIDTH && y >= 0 && y < SCREEN_HEIGHT) {
- pixels[ y * screenSurface->w + x ] = 0xffff;
+ WRITE_UINT16(screenSurface->getBasePtr(x, y), 0xffff);
}
i += 2;
}
diff --git a/engines/hopkins/saveload.cpp b/engines/hopkins/saveload.cpp
index c514df6943..b0dea7e6d1 100644
--- a/engines/hopkins/saveload.cpp
+++ b/engines/hopkins/saveload.cpp
@@ -233,14 +233,14 @@ void SaveLoadManager::createThumbnail(Graphics::Surface *s) {
Graphics::Surface thumb8;
thumb8.create(w, h, Graphics::PixelFormat::createFormatCLUT8());
- _vm->_graphicsMan->reduceScreenPart(_vm->_graphicsMan->_frontBuffer, (byte *)thumb8.pixels,
+ _vm->_graphicsMan->reduceScreenPart(_vm->_graphicsMan->_frontBuffer, (byte *)thumb8.getPixels(),
_vm->_events->_startPos.x, 20, SCREEN_WIDTH, SCREEN_HEIGHT - 40, 80);
// Convert the 8-bit pixel to 16 bit surface
s->create(w, h, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
- const byte *srcP = (const byte *)thumb8.pixels;
- uint16 *destP = (uint16 *)s->pixels;
+ const byte *srcP = (const byte *)thumb8.getPixels();
+ uint16 *destP = (uint16 *)s->getPixels();
for (int yp = 0; yp < h; ++yp) {
// Copy over the line, using the source pixels as lookups into the pixels palette
@@ -299,8 +299,8 @@ void SaveLoadManager::convertThumb16To8(Graphics::Surface *thumb16, Graphics::Su
pixelFormat16.colorToRGB(p, paletteR[palIndex], paletteG[palIndex], paletteB[palIndex]);
}
- const uint16 *srcP = (const uint16 *)thumb16->pixels;
- byte *destP = (byte *)thumb8->pixels;
+ const uint16 *srcP = (const uint16 *)thumb16->getPixels();
+ byte *destP = (byte *)thumb8->getPixels();
for (int yp = 0; yp < thumb16->h; ++yp) {
const uint16 *lineSrcP = srcP;
diff --git a/engines/hugo/dialogs.cpp b/engines/hugo/dialogs.cpp
index 0f07d52aee..5dcee3ae94 100644
--- a/engines/hugo/dialogs.cpp
+++ b/engines/hugo/dialogs.cpp
@@ -140,8 +140,8 @@ void TopMenu::loadBmpArr(Common::SeekableReadStream &in) {
_arrayBmp[i * 2] = bitmapSrc->convertTo(g_system->getOverlayFormat());
_arrayBmp[i * 2 + 1] = new Graphics::Surface();
_arrayBmp[i * 2 + 1]->create(_arrayBmp[i * 2]->w * 2, _arrayBmp[i * 2]->h * 2, g_system->getOverlayFormat());
- byte *src = (byte *)_arrayBmp[i * 2]->pixels;
- byte *dst = (byte *)_arrayBmp[i * 2 + 1]->pixels;
+ byte *src = (byte *)_arrayBmp[i * 2]->getPixels();
+ byte *dst = (byte *)_arrayBmp[i * 2 + 1]->getPixels();
for (int j = 0; j < _arrayBmp[i * 2]->h; j++) {
src = (byte *)_arrayBmp[i * 2]->getBasePtr(0, j);
diff --git a/engines/hugo/intro.cpp b/engines/hugo/intro.cpp
index 505e356049..6f314c8774 100644
--- a/engines/hugo/intro.cpp
+++ b/engines/hugo/intro.cpp
@@ -89,11 +89,7 @@ void intro_v1d::preNewGame() {
void intro_v1d::introInit() {
_introState = 0;
_introTicks = 0;
- _surf.w = 320;
- _surf.h = 200;
- _surf.pixels = _vm->_screen->getFrontBuffer();
- _surf.pitch = 320;
- _surf.format = Graphics::PixelFormat::createFormatCLUT8();
+ _surf.init(320, 200, 320, _vm->_screen->getFrontBuffer(), Graphics::PixelFormat::createFormatCLUT8());
_vm->_screen->displayList(kDisplayInit);
}
@@ -243,11 +239,7 @@ void intro_v2d::preNewGame() {
void intro_v2d::introInit() {
_vm->_screen->displayList(kDisplayInit);
_vm->_file->readBackground(_vm->_numScreens - 1); // display splash screen
- _surf.w = 320;
- _surf.h = 200;
- _surf.pixels = _vm->_screen->getFrontBuffer();
- _surf.pitch = 320;
- _surf.format = Graphics::PixelFormat::createFormatCLUT8();
+ _surf.init(320, 200, 320, _vm->_screen->getFrontBuffer(), Graphics::PixelFormat::createFormatCLUT8());
char buffer[128];
@@ -289,11 +281,7 @@ void intro_v3d::preNewGame() {
void intro_v3d::introInit() {
_vm->_screen->displayList(kDisplayInit);
_vm->_file->readBackground(_vm->_numScreens - 1); // display splash screen
- _surf.w = 320;
- _surf.h = 200;
- _surf.pixels = _vm->_screen->getFrontBuffer();
- _surf.pitch = 320;
- _surf.format = Graphics::PixelFormat::createFormatCLUT8();
+ _surf.init(320, 200, 320, _vm->_screen->getFrontBuffer(), Graphics::PixelFormat::createFormatCLUT8());
char buffer[128];
if (_vm->_boot._registered)
diff --git a/engines/kyra/gui_mr.cpp b/engines/kyra/gui_mr.cpp
index bcbfe27b69..ee0303c8c3 100644
--- a/engines/kyra/gui_mr.cpp
+++ b/engines/kyra/gui_mr.cpp
@@ -737,7 +737,7 @@ void KyraEngine_MR::loadAlbumPageWSA() {
if (_album.curPage != 14) {
filename = Common::String::format("PAGE%x.WSA", _album.curPage+1);
_album.rightPage.wsa->open(filename.c_str(), 1, 0);
- _album.rightPage.maxFrame = _album.leftPage.wsa->frames()-1;
+ _album.rightPage.maxFrame = _album.rightPage.wsa->frames()-1;
}
}
diff --git a/engines/lastexpress/data/animation.cpp b/engines/lastexpress/data/animation.cpp
index 7618259e69..832bcc2e26 100644
--- a/engines/lastexpress/data/animation.cpp
+++ b/engines/lastexpress/data/animation.cpp
@@ -270,7 +270,7 @@ void Animation::play() {
draw(s);
// XXX: Update the screen
- g_system->copyRectToScreen(s->pixels, s->pitch, 0, 0, s->w, s->h);
+ g_system->copyRectToScreen(s->getPixels(), s->pitch, 0, 0, s->w, s->h);
// Free the temporary surface
s->free();
diff --git a/engines/lastexpress/data/sequence.cpp b/engines/lastexpress/data/sequence.cpp
index a5bcba84cd..c7073b560c 100644
--- a/engines/lastexpress/data/sequence.cpp
+++ b/engines/lastexpress/data/sequence.cpp
@@ -128,8 +128,8 @@ AnimFrame::~AnimFrame() {
}
Common::Rect AnimFrame::draw(Graphics::Surface *s) {
- byte *inp = (byte *)_image.pixels;
- uint16 *outp = (uint16 *)s->pixels;
+ byte *inp = (byte *)_image.getPixels();
+ uint16 *outp = (uint16 *)s->getPixels();
for (int i = 0; i < 640 * 480; i++, inp++, outp++) {
if (*inp)
*outp = _palette[*inp];
@@ -155,7 +155,7 @@ void AnimFrame::decomp4(Common::SeekableReadStream *in, const FrameInfo &f) {
}
void AnimFrame::decomp34(Common::SeekableReadStream *in, const FrameInfo &f, byte mask, byte shift) {
- byte *p = (byte *)_image.getBasePtr(0, 0);
+ byte *p = (byte *)_image.getPixels();
uint32 skip = f.initialSkip / 2;
uint32 size = f.decompressedEndOffset / 2;
@@ -200,7 +200,7 @@ void AnimFrame::decomp34(Common::SeekableReadStream *in, const FrameInfo &f, byt
}
void AnimFrame::decomp5(Common::SeekableReadStream *in, const FrameInfo &f) {
- byte *p = (byte *)_image.getBasePtr(0, 0);
+ byte *p = (byte *)_image.getPixels();
uint32 skip = f.initialSkip / 2;
uint32 size = f.decompressedEndOffset / 2;
@@ -235,7 +235,7 @@ void AnimFrame::decomp5(Common::SeekableReadStream *in, const FrameInfo &f) {
}
void AnimFrame::decomp7(Common::SeekableReadStream *in, const FrameInfo &f) {
- byte *p = (byte *)_image.getBasePtr(0, 0);
+ byte *p = (byte *)_image.getPixels();
uint32 skip = f.initialSkip / 2;
uint32 size = f.decompressedEndOffset / 2;
@@ -288,7 +288,7 @@ void AnimFrame::decomp7(Common::SeekableReadStream *in, const FrameInfo &f) {
}
void AnimFrame::decompFF(Common::SeekableReadStream *in, const FrameInfo &f) {
- byte *p = (byte *)_image.getBasePtr(0, 0);
+ byte *p = (byte *)_image.getPixels();
uint32 skip = f.initialSkip / 2;
uint32 size = f.decompressedEndOffset / 2;
diff --git a/engines/lastexpress/graphics.cpp b/engines/lastexpress/graphics.cpp
index 753c3a39e4..9ced38a2e1 100644
--- a/engines/lastexpress/graphics.cpp
+++ b/engines/lastexpress/graphics.cpp
@@ -131,11 +131,11 @@ void GraphicsManager::mergePlanes() {
// Clear screen surface
_screen.fillRect(Common::Rect(640, 480), 0);
- uint16 *screen = (uint16 *)_screen.pixels;
- uint16 *inventory = (uint16 *)_inventory.pixels;
- uint16 *overlay = (uint16 *)_overlay.pixels;
- uint16 *backgroundC = (uint16 *)_backgroundC.pixels;
- uint16 *backgroundA = (uint16 *)_backgroundA.pixels;
+ uint16 *screen = (uint16 *)_screen.getPixels();
+ uint16 *inventory = (uint16 *)_inventory.getPixels();
+ uint16 *overlay = (uint16 *)_overlay.getPixels();
+ uint16 *backgroundC = (uint16 *)_backgroundC.getPixels();
+ uint16 *backgroundA = (uint16 *)_backgroundA.getPixels();
for (int i = 0; i < 640 * 480; i++) {
@@ -160,7 +160,7 @@ void GraphicsManager::mergePlanes() {
void GraphicsManager::updateScreen() {
g_system->fillScreen(0);
- g_system->copyRectToScreen(_screen.getBasePtr(0, 0), 640 * 2, 0, 0, 640, 480);
+ g_system->copyRectToScreen(_screen.getPixels(), 640 * 2, 0, 0, 640, 480);
}
} // End of namespace LastExpress
diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp
index efd4051eba..d0b439677d 100644
--- a/engines/lure/hotspots.cpp
+++ b/engines/lure/hotspots.cpp
@@ -260,8 +260,10 @@ void Hotspot::setAnimation(HotspotAnimData *newRecord) {
_anim = NULL;
_numFrames = 0;
_frameNumber = 0;
- if (!newRecord) return;
- if (!disk.exists(newRecord->animId)) return;
+ if (!newRecord)
+ return;
+ if (!disk.exists(newRecord->animId))
+ return;
// Scan for any size overrides - some animations get their size set after decoding, but
// we want it in advance so we can decode the animation straight to a graphic surface
@@ -516,7 +518,8 @@ void Hotspot::endAction() {
}
void Hotspot::setDirection(Direction dir) {
- if ((_numFrames == 0) || (_direction == dir)) return;
+ if ((_numFrames == 0) || (_direction == dir))
+ return;
uint8 newFrameNumber = 0;
switch (dir) {
@@ -634,7 +637,8 @@ void Hotspot::setOccupied(bool occupiedFlag) {
if (xp < 0) {
xp = -xp;
widthVal -= xp;
- if (widthVal <= 0) return;
+ if (widthVal <= 0)
+ return;
xp = 0;
}
@@ -642,7 +646,8 @@ void Hotspot::setOccupied(bool occupiedFlag) {
int x2 = xp + widthVal - ROOM_PATHS_WIDTH - 1;
if (x2 >= 0) {
widthVal -= (x2 + 1);
- if (widthVal <= 0) return;
+ if (widthVal <= 0)
+ return;
}
RoomPathsData &paths = Resources::getReference().getRoom(_roomNumber)->paths;
@@ -656,14 +661,16 @@ void Hotspot::setOccupied(bool occupiedFlag) {
// walks the character a single step in a sequence defined by the walking list
bool Hotspot::walkingStep() {
- if (_pathFinder.isEmpty()) return true;
+ if (_pathFinder.isEmpty())
+ return true;
// Check to see if the end of the next straight walking slice
if (_pathFinder.stepCtr() >= _pathFinder.top().numSteps()) {
// Move to next slice in walking sequence
_pathFinder.stepCtr() = 0;
_pathFinder.pop();
- if (_pathFinder.isEmpty()) return true;
+ if (_pathFinder.isEmpty())
+ return true;
}
if (_pathFinder.stepCtr() == 0)
@@ -782,13 +789,15 @@ void Hotspot::showMessage(uint16 messageId, uint16 destCharacterId) {
uint16 *v = (uint16 *) (msgData + READ_LE_UINT16(msgData + idx + sizeof(uint16)));
while ((idVal = READ_LE_UINT16(v)) != 0xffff) {
++v;
- if (READ_LE_UINT16(v) == messageId) break;
+ if (READ_LE_UINT16(v) == messageId)
+ break;
++v;
}
// default response if a specific response not found
- if (idVal == 0xffff) idVal = 0x8c4;
+ if (idVal == 0xffff)
+ idVal = 0x8c4;
debugC(ERROR_DETAILED, kLureDebugStrings, "Hotspot::showMessage idVal=%xh", idVal);
if (idVal == 0x76) {
@@ -826,7 +835,8 @@ void Hotspot::handleTalkDialog() {
Room &room = Room::getReference();
// Return if no talk dialog is necessary
- if (_data->talkCountdown == 0) return;
+ if (_data->talkCountdown == 0)
+ return;
debugC(ERROR_DETAILED, kLureDebugAnimations, "Talk countdown = %d", _data->talkCountdown);
if (_data->talkCountdown == CONVERSE_COUNTDOWN_SIZE) {
@@ -933,7 +943,8 @@ static const uint16 validRoomExitHotspots[] = {0x2711, 0x2712, 0x2714, 0x2715, 0
bool Hotspot::isRoomExit(uint16 id) {
for (const uint16 *p = &validRoomExitHotspots[0]; *p != 0; ++p)
- if (*p == id) return true;
+ if (*p == id)
+ return true;
return false;
}
@@ -1043,7 +1054,7 @@ BarPlaceResult Hotspot::getBarPlace() {
index = -1;
while (++index < NUM_SERVE_CUSTOMERS) {
if (barEntry.customers[index].hotspotId == 0)
- break;
+ break;
}
if (index == NUM_SERVE_CUSTOMERS)
@@ -1391,7 +1402,8 @@ void Hotspot::doGet(HotspotData *hotspot) {
Resources &res = Resources::getReference();
HotspotPrecheckResult result = actionPrecheck(hotspot);
- if (result == PC_WAIT) return;
+ if (result == PC_WAIT)
+ return;
else if (result != PC_EXECUTE) {
endAction();
return;
@@ -1409,7 +1421,8 @@ void Hotspot::doGet(HotspotData *hotspot) {
if (sequenceOffset != 0) {
uint16 execResult = Script::execute(sequenceOffset);
- if (execResult == 1) return;
+ if (execResult == 1)
+ return;
else if (execResult != 0) {
showMessage(execResult);
return;
@@ -1432,7 +1445,8 @@ void Hotspot::doOperate(HotspotData *hotspot) {
Action action = currentActions().top().supportData().action();
HotspotPrecheckResult result = actionPrecheck(hotspot);
- if (result == PC_WAIT) return;
+ if (result == PC_WAIT)
+ return;
else if (result != PC_EXECUTE) {
endAction();
return;
@@ -1467,7 +1481,8 @@ void Hotspot::doOpen(HotspotData *hotspot) {
}
HotspotPrecheckResult result = actionPrecheck(hotspot);
- if (result == PC_WAIT) return;
+ if (result == PC_WAIT)
+ return;
else if (result != PC_EXECUTE) {
endAction();
return;
@@ -1487,7 +1502,8 @@ void Hotspot::doOpen(HotspotData *hotspot) {
if (sequenceOffset != 0) {
sequenceOffset = Script::execute(sequenceOffset);
- if (sequenceOffset == 1) return;
+ if (sequenceOffset == 1)
+ return;
if (sequenceOffset != 0) {
if (_exitCtr != 0)
_exitCtr = 4;
@@ -1522,7 +1538,8 @@ void Hotspot::doClose(HotspotData *hotspot) {
}
HotspotPrecheckResult result = actionPrecheck(hotspot);
- if (result == PC_WAIT) return;
+ if (result == PC_WAIT)
+ return;
else if (result != PC_EXECUTE) {
endAction();
return;
@@ -1575,7 +1592,8 @@ void Hotspot::doUse(HotspotData *hotspot) {
}
HotspotPrecheckResult result = actionPrecheck(hotspot);
- if (result == PC_WAIT) return;
+ if (result == PC_WAIT)
+ return;
else if (result != PC_EXECUTE) {
endAction();
return;
@@ -1616,7 +1634,8 @@ void Hotspot::doGive(HotspotData *hotspot) {
}
HotspotPrecheckResult result = actionPrecheck(hotspot);
- if (result == PC_WAIT) return;
+ if (result == PC_WAIT)
+ return;
else if (result != PC_EXECUTE) {
endAction();
return;
@@ -1662,7 +1681,8 @@ void Hotspot::doTalkTo(HotspotData *hotspot) {
(hotspot->hotspotId != BLACKSMITH_ID))) {
HotspotPrecheckResult result = actionPrecheck(hotspot);
- if (result == PC_WAIT) return;
+ if (result == PC_WAIT)
+ return;
else if (result != PC_EXECUTE) {
endAction();
return;
@@ -1706,7 +1726,8 @@ void Hotspot::doTell(HotspotData *hotspot) {
assert(character);
HotspotPrecheckResult hsResult = actionPrecheck(hotspot);
- if (hsResult == PC_WAIT) return;
+ if (hsResult == PC_WAIT)
+ return;
else if (hsResult != PC_EXECUTE) {
endAction();
return;
@@ -1800,7 +1821,8 @@ void Hotspot::doAsk(HotspotData *hotspot) {
_data->useHotspotId = usedId;
HotspotPrecheckResult result = actionPrecheck(hotspot);
- if (result == PC_WAIT) return;
+ if (result == PC_WAIT)
+ return;
else if (result != PC_EXECUTE) {
endAction();
return;
@@ -1886,14 +1908,17 @@ void Hotspot::doStatus(HotspotData *hotspot) {
HotspotData const &rec = **i;
if (rec.roomNumber == PLAYER_ID) {
- if (numItems++ == 0) strcat(buffer, ": ");
- else strcat(buffer, ", ");
+ if (numItems++ == 0)
+ strcat(buffer, ": ");
+ else
+ strcat(buffer, ", ");
strings.getString(rec.nameId, buffer + strlen(buffer));
}
}
// If there were no items, add in the word 'nothing'
- if (numItems == 0) strcat(buffer, stringList.getString(S_INV_NOTHING));
+ if (numItems == 0)
+ strcat(buffer, stringList.getString(S_INV_NOTHING));
// If the player has money, add it in
uint16 numGroats = res.fieldList().numGroats();
@@ -1943,7 +1968,8 @@ void Hotspot::doBribe(HotspotData *hotspot) {
fields.setField(USE_HOTSPOT_ID, hotspot->hotspotId);
HotspotPrecheckResult result = actionPrecheck(hotspot);
- if (result == PC_WAIT) return;
+ if (result == PC_WAIT)
+ return;
else if (result != PC_EXECUTE) {
endAction();
return;
@@ -1968,7 +1994,8 @@ void Hotspot::doBribe(HotspotData *hotspot) {
sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, BRIBE);
if (sequenceOffset != 0) {
sequenceOffset = Script::execute(sequenceOffset);
- if (sequenceOffset != 0) return;
+ if (sequenceOffset != 0)
+ return;
}
uint16 talkIndex = res.fieldList().getField(TALK_INDEX);
@@ -2004,7 +2031,8 @@ void Hotspot::doLockUnlock(HotspotData *hotspot) {
fields.setField(USE_HOTSPOT_ID, hotspot->hotspotId);
HotspotPrecheckResult result = actionPrecheck(hotspot);
- if (result == PC_WAIT) return;
+ if (result == PC_WAIT)
+ return;
else if (result != PC_EXECUTE) {
endAction();
return;
@@ -2156,7 +2184,8 @@ void Hotspot::npcTalkNpcToNpc(HotspotData *hotspot) {
fields.setField(USE_HOTSPOT_ID, hotspot->hotspotId);
HotspotPrecheckResult result = actionPrecheck(hotspot);
- if (result == PC_WAIT) return;
+ if (result == PC_WAIT)
+ return;
else if (result != PC_EXECUTE) {
endAction();
return;
@@ -2594,7 +2623,8 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) {
if (h.characterMode() == CHARMODE_PLAYER_WAIT) {
h.updateMovement();
- if (bumpedPlayer) return;
+ if (bumpedPlayer)
+ return;
} else {
// All other character modes
if (h.delayCtr() > 0) {
@@ -2691,7 +2721,8 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) {
res.pausedList().scan(h);
pfResult = pathFinder.process();
- if (pfResult == PF_UNFINISHED) break;
+ if (pfResult == PF_UNFINISHED)
+ break;
debugC(ERROR_DETAILED, kLureDebugAnimations,
"pathFinder done: result = %d", pfResult);
@@ -2863,7 +2894,8 @@ void HotspotTickHandlers::roomExitAnimHandler(Hotspot &h) {
Room &room = Room::getReference();
RoomExitJoinData *rec = res.getExitJoin(h.hotspotId());
- if (!rec) return;
+ if (!rec)
+ return;
RoomExitJoinStruct &rs = (rec->hotspots[0].hotspotId == h.hotspotId()) ?
rec->hotspots[0] : rec->hotspots[1];
@@ -3036,7 +3068,8 @@ void HotspotTickHandlers::playerAnimHandler(Hotspot &h) {
res.pausedList().scan(h);
pfResult = pathFinder.process();
- if (pfResult == PF_UNFINISHED) break;
+ if (pfResult == PF_UNFINISHED)
+ break;
// Pathfinding is now complete
buffer = pathFinder.getDebugInfo();
@@ -3474,7 +3507,8 @@ void HotspotTickHandlers::talkAnimHandler(Hotspot &h) {
showSelections |= (entry->descId & 0x3fff) != TALK_MAGIC_ID;
}
- if ((entry->preSequenceId & 0x8000) != 0) break;
+ if ((entry->preSequenceId & 0x8000) != 0)
+ break;
}
if (showSelections && (numLines > 1)) {
@@ -3584,7 +3618,8 @@ void HotspotTickHandlers::talkAnimHandler(Hotspot &h) {
debugC(ERROR_DETAILED, kLureDebugAnimations, "Character response pre id = %xh",
_talkResponse->preSequenceId);
- if (!_talkResponse->preSequenceId) break;
+ if (!_talkResponse->preSequenceId)
+ break;
responseNumber = Script::execute(_talkResponse->preSequenceId);
debugC(ERROR_DETAILED, kLureDebugAnimations, "Character response new response = %d",
responseNumber);
@@ -3680,9 +3715,12 @@ void HotspotTickHandlers::grubAnimHandler(Hotspot &h) {
character = ratpouch;
}
- if (character->x() < 72) frameNumber = 0;
- else if (character->x() < 172) frameNumber = 1;
- else frameNumber = 2;
+ if (character->x() < 72)
+ frameNumber = 0;
+ else if (character->x() < 172)
+ frameNumber = 1;
+ else
+ frameNumber = 2;
h.setActionCtr(frameNumber);
h.setFrameNumber(frameNumber);
@@ -3782,7 +3820,8 @@ void HotspotTickHandlers::barmanAnimHandler(Hotspot &h) {
// Moving right
h.setPosition(h.x() + 2, h.y());
h.setActionCtr(h.actionCtr() + 1);
- if (h.actionCtr() >= 6) h.setActionCtr(0);
+ if (h.actionCtr() >= 6)
+ h.setActionCtr(0);
}
} else {
// Stop the barman moving
@@ -4231,7 +4270,8 @@ PathFinderResult PathFinder::process() {
while (1) {
// Loop through to process cells in the given area
- if (!returnFlag) _yCtr = 0;
+ if (!returnFlag)
+ _yCtr = 0;
while (returnFlag || (_yCtr < ROOM_PATHS_HEIGHT)) {
if (!returnFlag) _xCtr = 0;
@@ -4239,7 +4279,8 @@ PathFinderResult PathFinder::process() {
if (!returnFlag) {
processCell(&_layer[(_yChangeStart + _yCtr * _yChangeInc) * DECODED_PATHS_WIDTH +
(_xChangeStart + _xCtr * _xChangeInc)]);
- if (breakFlag && (_countdownCtr <= 0)) return PF_UNFINISHED;
+ if (breakFlag && (_countdownCtr <= 0))
+ return PF_UNFINISHED;
} else {
returnFlag = false;
}
@@ -4249,7 +4290,8 @@ PathFinderResult PathFinder::process() {
}
// If the destination cell has been filled in, then break out of loop
- if (*_pDest != 0) break;
+ if (*_pDest != 0)
+ break;
if (_cellPopulated) {
// At least one cell populated, so go repeat loop
@@ -4307,27 +4349,37 @@ PathFinderResult PathFinder::process() {
currDirection = NO_DIRECTION;
while (1) {
v = *pCurrent - 1;
- if (v == 0) break;
+ if (v == 0)
+ break;
newDirection = NO_DIRECTION;
if (!altFlag && (currDirection != LEFT) && (currDirection != RIGHT)) {
// Standard order direction checking
- if (*(pCurrent - DECODED_PATHS_WIDTH) == v) newDirection = DOWN;
- else if (*(pCurrent + DECODED_PATHS_WIDTH) == v) newDirection = UP;
- else if (*(pCurrent + 1) == v) newDirection = LEFT;
- else if (*(pCurrent - 1) == v) newDirection = RIGHT;
+ if (*(pCurrent - DECODED_PATHS_WIDTH) == v)
+ newDirection = DOWN;
+ else if (*(pCurrent + DECODED_PATHS_WIDTH) == v)
+ newDirection = UP;
+ else if (*(pCurrent + 1) == v)
+ newDirection = LEFT;
+ else if (*(pCurrent - 1) == v)
+ newDirection = RIGHT;
} else {
// Alternate order direction checking
- if (*(pCurrent + 1) == v) newDirection = LEFT;
- else if (*(pCurrent - 1) == v) newDirection = RIGHT;
- else if (*(pCurrent - DECODED_PATHS_WIDTH) == v) newDirection = DOWN;
- else if (*(pCurrent + DECODED_PATHS_WIDTH) == v) newDirection = UP;
+ if (*(pCurrent + 1) == v)
+ newDirection = LEFT;
+ else if (*(pCurrent - 1) == v)
+ newDirection = RIGHT;
+ else if (*(pCurrent - DECODED_PATHS_WIDTH) == v)
+ newDirection = DOWN;
+ else if (*(pCurrent + DECODED_PATHS_WIDTH) == v)
+ newDirection = UP;
}
if (newDirection == NO_DIRECTION)
error("Path finding process failed");
// Process for the specified direction
- if (newDirection != currDirection) add(newDirection, 0);
+ if (newDirection != currDirection)
+ add(newDirection, 0);
switch (newDirection) {
case UP:
@@ -4374,8 +4426,10 @@ PathFinderResult PathFinder::process() {
}
// Final Step
- if (_xPos < 0) add(RIGHT, -_xPos);
- else if (_xPos > 0) add(LEFT, _xPos);
+ if (_xPos < 0)
+ add(RIGHT, -_xPos);
+ else if (_xPos > 0)
+ add(LEFT, _xPos);
return result;
}
@@ -4402,16 +4456,20 @@ void PathFinder::processCell(uint16 *p) {
// Check the surrounding cells (up,down,left,right) for values
// Up
vTemp = *(p - DECODED_PATHS_WIDTH);
- if ((vTemp != 0) && (vTemp < vMax)) vMax = vTemp;
+ if ((vTemp != 0) && (vTemp < vMax))
+ vMax = vTemp;
// Down
vTemp = *(p + DECODED_PATHS_WIDTH);
- if ((vTemp != 0) && (vTemp < vMax)) vMax = vTemp;
+ if ((vTemp != 0) && (vTemp < vMax))
+ vMax = vTemp;
// Left
vTemp = *(p - 1);
- if ((vTemp != 0) && (vTemp < vMax)) vMax = vTemp;
+ if ((vTemp != 0) && (vTemp < vMax))
+ vMax = vTemp;
// Right
vTemp = *(p + 1);
- if ((vTemp != 0) && (vTemp < vMax)) vMax = vTemp;
+ if ((vTemp != 0) && (vTemp < vMax))
+ vMax = vTemp;
if (vMax != 0xffff) {
// A surrounding cell with a value was found
@@ -4433,7 +4491,8 @@ void PathFinder::scanLine(int numScans, int changeAmount, uint16 *&pEnd, int &v)
for (int ctr = 1; ctr <= numScans; ++ctr) {
pTemp += changeAmount;
if ((*pTemp != 0) && (*pTemp != 0xffff)) {
- if ((v < ctr) || ((v == ctr) && (*pTemp >= *pEnd))) return;
+ if ((v < ctr) || ((v == ctr) && (*pTemp >= *pEnd)))
+ return;
pEnd = pTemp;
v = ctr;
break;
@@ -4448,11 +4507,15 @@ void PathFinder::initVars() {
_destX = _hotspot->destX();
_destY = _hotspot->destY();
- if (_destX < 10) _destX -= 50;
- if (_destX >= FULL_SCREEN_WIDTH-10) _destX += 50;
+ if (_destX < 10)
+ _destX -= 50;
+ if (_destX >= FULL_SCREEN_WIDTH-10)
+ _destX += 50;
- _xPos = 0; _yPos = 0;
- _xDestPos = 0; _yDestPos = 0;
+ _xPos = 0;
+ _yPos = 0;
+ _xDestPos = 0;
+ _yDestPos = 0;
_xCurrent = _hotspot->x();
if (_xCurrent < 0) {
@@ -4622,7 +4685,8 @@ void Support::characterChangeRoom(Hotspot &h, uint16 roomNumber,
if (h.hotspotId() == PLAYER_ID) {
// Room change code for the player
- if (room.cursorState() != CS_NONE) return;
+ if (room.cursorState() != CS_NONE)
+ return;
PlayerNewPosition &p = fields.playerNewPos();
if (checkForIntersectingCharacter(h, newX, newY - 48, roomNumber)) {
@@ -4679,7 +4743,8 @@ bool Support::charactersIntersecting(HotspotData *hotspot1, HotspotData *hotspot
bool Support::isCharacterInList(uint16 *lst, int numEntries, uint16 charId) {
while (numEntries-- > 0)
- if (*lst++ == charId) return true;
+ if (*lst++ == charId)
+ return true;
return false;
}
diff --git a/engines/made/graphics.cpp b/engines/made/graphics.cpp
index 4d3fc7116a..a8e33774f6 100644
--- a/engines/made/graphics.cpp
+++ b/engines/made/graphics.cpp
@@ -83,7 +83,7 @@ void decompressImage(byte *source, Graphics::Surface &surface, uint16 cmdOffs, u
if ((maskFlags != 0) && (maskFlags != 2) && (pixelFlags != 0) && (pixelFlags != 2) && (cmdFlags != 0))
error("decompressImage() Unsupported flags: cmdFlags = %02X; maskFlags = %02X, pixelFlags = %02X", cmdFlags, maskFlags, pixelFlags);
- byte *destPtr = (byte *)surface.getBasePtr(0, 0);
+ byte *destPtr = (byte *)surface.getPixels();
byte lineBuf[640 * 4];
byte bitBuf[40];
@@ -196,7 +196,7 @@ void decompressMovieImage(byte *source, Graphics::Surface &surface, uint16 cmdOf
byte *maskBuffer = source + maskOffs;
byte *pixelBuffer = source + pixelOffs;
- byte *destPtr = (byte *)surface.getBasePtr(0, 0);
+ byte *destPtr = (byte *)surface.getPixels();
byte bitBuf[40];
diff --git a/engines/made/pmvplayer.cpp b/engines/made/pmvplayer.cpp
index cf450f7e25..573ff7faf1 100644
--- a/engines/made/pmvplayer.cpp
+++ b/engines/made/pmvplayer.cpp
@@ -248,7 +248,7 @@ void PmvPlayer::handleEvents() {
}
void PmvPlayer::updateScreen() {
- _vm->_system->copyRectToScreen(_surface->pixels, _surface->pitch,
+ _vm->_system->copyRectToScreen(_surface->getPixels(), _surface->pitch,
(320 - _surface->w) / 2, (200 - _surface->h) / 2, _surface->w, _surface->h);
_vm->_system->updateScreen();
}
diff --git a/engines/made/screen.cpp b/engines/made/screen.cpp
index ea7d57f82d..30848e8ec1 100644
--- a/engines/made/screen.cpp
+++ b/engines/made/screen.cpp
@@ -344,12 +344,12 @@ void Screen::drawSpriteChannels(const ClipInfo &clipInfo, int16 includeStateMask
void Screen::updateSprites() {
// TODO: This needs some more work, dirty rectangles are currently not used
- memcpy(_workScreen->pixels, _backgroundScreen->pixels, 64000);
+ memcpy(_workScreen->getPixels(), _backgroundScreen->getPixels(), 64000);
drawSpriteChannels(_backgroundScreenDrawCtx, 3, 0);
drawSpriteChannels(_workScreenDrawCtx, 1, 2);
- _vm->_system->copyRectToScreen(_workScreen->pixels, _workScreen->pitch, 0, 0, _workScreen->w, _workScreen->h);
+ _vm->_system->copyRectToScreen(_workScreen->getPixels(), _workScreen->pitch, 0, 0, _workScreen->w, _workScreen->h);
_vm->_screen->updateScreenAndWait(10);
}
@@ -593,7 +593,7 @@ void Screen::show() {
return;
drawSpriteChannels(_backgroundScreenDrawCtx, 3, 0);
- memcpy(_workScreen->pixels, _backgroundScreen->pixels, 64000);
+ memcpy(_workScreen->getPixels(), _backgroundScreen->getPixels(), 64000);
drawSpriteChannels(_workScreenDrawCtx, 1, 2);
_fx->run(_visualEffectNum, _workScreen, _palette, _newPalette, _paletteColorCount);
@@ -775,7 +775,7 @@ void Screen::unlockScreen() {
}
void Screen::showWorkScreen() {
- _vm->_system->copyRectToScreen(_workScreen->pixels, _workScreen->pitch, 0, 0, _workScreen->w, _workScreen->h);
+ _vm->_system->copyRectToScreen(_workScreen->getPixels(), _workScreen->pitch, 0, 0, _workScreen->w, _workScreen->h);
}
void Screen::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) {
diff --git a/engines/made/screenfx.cpp b/engines/made/screenfx.cpp
index ad71f1fb49..d069308a4b 100644
--- a/engines/made/screenfx.cpp
+++ b/engines/made/screenfx.cpp
@@ -368,7 +368,7 @@ void ScreenEffects::vfx07(Graphics::Surface *surface, byte *palette, byte *newPa
// "Screen slide in" right to left
void ScreenEffects::vfx08(Graphics::Surface *surface, byte *palette, byte *newPalette, int colorCount) {
for (int x = 8; x <= 320; x += 8) {
- _screen->copyRectToScreen(surface->getBasePtr(0, 0), surface->pitch, 320 - x, 0, x, 200);
+ _screen->copyRectToScreen(surface->getPixels(), surface->pitch, 320 - x, 0, x, 200);
_screen->updateScreenAndWait(25);
}
setPalette(palette);
@@ -529,7 +529,7 @@ void ScreenEffects::vfx19(Graphics::Surface *surface, byte *palette, byte *newPa
// "Screen slide in" bottom to top
void ScreenEffects::vfx20(Graphics::Surface *surface, byte *palette, byte *newPalette, int colorCount) {
for (int y = 4; y <= 200; y += 4) {
- _screen->copyRectToScreen(surface->getBasePtr(0, 0), surface->pitch, 0, 200 - y, 320, y);
+ _screen->copyRectToScreen(surface->getPixels(), surface->pitch, 0, 200 - y, 320, y);
_screen->updateScreenAndWait(25);
}
diff --git a/engines/made/scriptfuncs.cpp b/engines/made/scriptfuncs.cpp
index c57778fb71..0e3b50aa98 100644
--- a/engines/made/scriptfuncs.cpp
+++ b/engines/made/scriptfuncs.cpp
@@ -574,7 +574,7 @@ int16 ScriptFunctions::sfLoadMouseCursor(int16 argc, int16 *argv) {
PictureResource *flex = _vm->_res->getPicture(argv[2]);
if (flex) {
Graphics::Surface *surf = flex->getPicture();
- CursorMan.replaceCursor(surf->pixels, surf->w, surf->h, argv[1], argv[0], 0);
+ CursorMan.replaceCursor(surf->getPixels(), surf->w, surf->h, argv[1], argv[0], 0);
_vm->_res->freeResource(flex);
}
return 0;
diff --git a/engines/mohawk/bitmap.cpp b/engines/mohawk/bitmap.cpp
index bc19fe2d3e..b321e043d9 100644
--- a/engines/mohawk/bitmap.cpp
+++ b/engines/mohawk/bitmap.cpp
@@ -580,7 +580,7 @@ void MohawkBitmap::drawRaw(Graphics::Surface *surface) {
_data->skip(_header.bytesPerRow - _header.width * 3);
} else {
- _data->read((byte *)surface->pixels + y * _header.width, _header.width);
+ _data->read((byte *)surface->getBasePtr(0, y), _header.width);
_data->skip(_header.bytesPerRow - _header.width);
}
}
@@ -599,7 +599,7 @@ void MohawkBitmap::drawRLE8(Graphics::Surface *surface, bool isLE) {
for (uint16 i = 0; i < _header.height; i++) {
uint16 rowByteCount = isLE ? _data->readUint16LE() : _data->readUint16BE();
int32 startPos = _data->pos();
- byte *dst = (byte *)surface->pixels + i * _header.width;
+ byte *dst = (byte *)surface->getBasePtr(0, i);
int16 remaining = _header.width;
while (remaining > 0) {
@@ -779,7 +779,7 @@ MohawkSurface *DOSBitmap::decodeImage(Common::SeekableReadStream *stream) {
}
Graphics::Surface *surface = createSurface(_header.width, _header.height);
- memset(surface->pixels, 0, _header.width * _header.height);
+ memset(surface->getPixels(), 0, _header.width * _header.height);
// Expand the <8bpp data to one byte per pixel
switch (getBitsPerPixel()) {
@@ -801,7 +801,7 @@ MohawkSurface *DOSBitmap::decodeImage(Common::SeekableReadStream *stream) {
void DOSBitmap::expandMonochromePlane(Graphics::Surface *surface, Common::SeekableReadStream *rawStream) {
assert(surface->format.bytesPerPixel == 1);
- byte *dst = (byte *)surface->pixels;
+ byte *dst = (byte *)surface->getPixels();
// Expand the 8 pixels in a byte into a full byte per pixel
@@ -830,7 +830,7 @@ void DOSBitmap::expandEGAPlanes(Graphics::Surface *surface, Common::SeekableRead
// Note that the image is in EGA planar form and not just standard 4bpp
// This seems to contradict the PoP specs which seem to do something else
- byte *dst = (byte *)surface->pixels;
+ byte *dst = (byte *)surface->getPixels();
for (uint32 i = 0; i < surface->h; i++) {
uint x = 0;
diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp
index c7bd03678f..f70efde5fb 100644
--- a/engines/mohawk/cursors.cpp
+++ b/engines/mohawk/cursors.cpp
@@ -121,11 +121,11 @@ void MystCursorManager::setCursor(uint16 id) {
// Myst ME stores some cursors as 24bpp images instead of 8bpp
if (surface->format.bytesPerPixel == 1) {
- CursorMan.replaceCursor(surface->pixels, surface->w, surface->h, hotspotX, hotspotY, 0);
+ CursorMan.replaceCursor(surface->getPixels(), surface->w, surface->h, hotspotX, hotspotY, 0);
CursorMan.replaceCursorPalette(mhkSurface->getPalette(), 0, 256);
} else {
Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
- CursorMan.replaceCursor(surface->pixels, surface->w, surface->h, hotspotX, hotspotY, pixelFormat.RGBToColor(255, 255, 255), false, &pixelFormat);
+ CursorMan.replaceCursor(surface->getPixels(), surface->w, surface->h, hotspotX, hotspotY, pixelFormat.RGBToColor(255, 255, 255), false, &pixelFormat);
}
_vm->_needsUpdate = true;
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index efa0dd3fd3..634ff441b6 100644
--- a/engines/mohawk/livingbooks.cpp
+++ b/engines/mohawk/livingbooks.cpp
@@ -311,8 +311,8 @@ void MohawkEngine_LivingBooks::loadBookInfo(const Common::String &filename) {
// - fDebugWindow (always 0?)
if (_bookInfoFile.hasSection("Globals")) {
- const Common::ConfigFile::SectionKeyList globals = _bookInfoFile.getKeys("Globals");
- for (Common::ConfigFile::SectionKeyList::const_iterator i = globals.begin(); i != globals.end(); i++) {
+ const Common::INIFile::SectionKeyList globals = _bookInfoFile.getKeys("Globals");
+ for (Common::INIFile::SectionKeyList::const_iterator i = globals.begin(); i != globals.end(); i++) {
Common::String command = Common::String::format("%s = %s", i->key.c_str(), i->value.c_str());
LBCode tempCode(this, 0);
uint offset = tempCode.parseCode(command);
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index 76da7d8219..615fcd0e16 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -28,7 +28,7 @@
#include "mohawk/livingbooks_graphics.h"
#include "mohawk/sound.h"
-#include "common/config-file.h"
+#include "common/ini-file.h"
#include "common/rect.h"
#include "common/queue.h"
#include "common/random.h"
@@ -759,7 +759,7 @@ public:
private:
LivingBooksConsole *_console;
- Common::ConfigFile _bookInfoFile;
+ Common::INIFile _bookInfoFile;
Common::String getBookInfoFileName() const;
void loadBookInfo(const Common::String &filename);
diff --git a/engines/mohawk/livingbooks_lbx.cpp b/engines/mohawk/livingbooks_lbx.cpp
index 2b8b22ec81..dcf8caa4a5 100644
--- a/engines/mohawk/livingbooks_lbx.cpp
+++ b/engines/mohawk/livingbooks_lbx.cpp
@@ -33,7 +33,7 @@ public:
bool call(uint callId, const Common::Array<LBValue> &params, LBValue &result);
protected:
- Common::ConfigFile _dataFile;
+ Common::INIFile _dataFile;
Common::String _curSection;
void open(const Common::String &filename);
@@ -77,8 +77,8 @@ bool LBXDataFile::call(uint callId, const Common::Array<LBValue> &params, LBValu
case kLBXDataFileGetSectionList:
{
Common::SharedPtr<LBList> list = Common::SharedPtr<LBList>(new LBList);
- Common::ConfigFile::SectionList sections = _dataFile.getSections();
- for (Common::List<Common::ConfigFile::Section>::const_iterator i = sections.begin(); i != sections.end(); ++i)
+ Common::INIFile::SectionList sections = _dataFile.getSections();
+ for (Common::List<Common::INIFile::Section>::const_iterator i = sections.begin(); i != sections.end(); ++i)
list->array.push_back(LBValue(i->name));
result = LBValue(list);
}
@@ -103,8 +103,8 @@ bool LBXDataFile::call(uint callId, const Common::Array<LBValue> &params, LBValu
error("incorrect number of parameters (%d) to LBXDataFile::loadCurSectionVars", params.size());
{
- const Common::ConfigFile::SectionKeyList globals = _dataFile.getKeys(_curSection);
- for (Common::ConfigFile::SectionKeyList::const_iterator i = globals.begin(); i != globals.end(); i++) {
+ const Common::INIFile::SectionKeyList globals = _dataFile.getKeys(_curSection);
+ for (Common::INIFile::SectionKeyList::const_iterator i = globals.begin(); i != globals.end(); i++) {
Common::String command = Common::String::format("%s = %s", i->key.c_str(), i->value.c_str());
LBCode tempCode(_vm, 0);
uint offset = tempCode.parseCode(command);
diff --git a/engines/mohawk/riven_graphics.cpp b/engines/mohawk/riven_graphics.cpp
index 05e66a3924..cd15960b85 100644
--- a/engines/mohawk/riven_graphics.cpp
+++ b/engines/mohawk/riven_graphics.cpp
@@ -255,7 +255,7 @@ void RivenGraphics::runScheduledTransition() {
}
// For now, just copy the image to screen without doing any transition.
- _vm->_system->copyRectToScreen(_mainScreen->pixels, _mainScreen->pitch, 0, 0, _mainScreen->w, _mainScreen->h);
+ _vm->_system->copyRectToScreen(_mainScreen->getPixels(), _mainScreen->pitch, 0, 0, _mainScreen->w, _mainScreen->h);
_vm->_system->updateScreen();
_scheduledTransition = -1; // Clear scheduled transition
@@ -345,7 +345,7 @@ void RivenGraphics::drawInventoryImage(uint16 id, const Common::Rect *rect) {
mhkSurface->convertToTrueColor();
Graphics::Surface *surface = mhkSurface->getSurface();
- _vm->_system->copyRectToScreen(surface->pixels, surface->pitch, rect->left, rect->top, surface->w, surface->h);
+ _vm->_system->copyRectToScreen(surface->getPixels(), surface->pitch, rect->left, rect->top, surface->w, surface->h);
delete mhkSurface;
}
@@ -420,7 +420,7 @@ void RivenGraphics::updateCredits() {
} else {
// Otheriwse, we're scrolling
// Move the screen up one row
- memmove(_mainScreen->pixels, _mainScreen->getBasePtr(0, 1), _mainScreen->pitch * (_mainScreen->h - 1));
+ memmove(_mainScreen->getPixels(), _mainScreen->getBasePtr(0, 1), _mainScreen->pitch * (_mainScreen->h - 1));
// Only update as long as we're not before the last frame
// Otherwise, we're just moving up a row (which we already did)
@@ -437,7 +437,7 @@ void RivenGraphics::updateCredits() {
}
// Now flush the new screen
- _vm->_system->copyRectToScreen(_mainScreen->pixels, _mainScreen->pitch, 0, 0, _mainScreen->w, _mainScreen->h);
+ _vm->_system->copyRectToScreen(_mainScreen->getPixels(), _mainScreen->pitch, 0, 0, _mainScreen->w, _mainScreen->h);
_vm->_system->updateScreen();
}
}
diff --git a/engines/mohawk/video.cpp b/engines/mohawk/video.cpp
index 8b0130d711..b7e06a2b9f 100644
--- a/engines/mohawk/video.cpp
+++ b/engines/mohawk/video.cpp
@@ -245,7 +245,7 @@ bool VideoManager::updateMovies() {
// Clip the width/height to make sure we stay on the screen (Myst does this a few times)
uint16 width = MIN<int32>(_videoStreams[i]->getWidth(), _vm->_system->getWidth() - _videoStreams[i].x);
uint16 height = MIN<int32>(_videoStreams[i]->getHeight(), _vm->_system->getHeight() - _videoStreams[i].y);
- _vm->_system->copyRectToScreen(frame->pixels, frame->pitch, _videoStreams[i].x, _videoStreams[i].y, width, height);
+ _vm->_system->copyRectToScreen(frame->getPixels(), frame->pitch, _videoStreams[i].x, _videoStreams[i].y, width, height);
// We've drawn something to the screen, make sure we update it
updateScreen = true;
diff --git a/engines/mortevielle/graphics.cpp b/engines/mortevielle/graphics.cpp
index c066114e8d..059f5a9be8 100644
--- a/engines/mortevielle/graphics.cpp
+++ b/engines/mortevielle/graphics.cpp
@@ -897,12 +897,7 @@ Graphics::Surface ScreenSurface::lockArea(const Common::Rect &bounds) {
_dirtyRects.push_back(bounds);
Graphics::Surface s;
- s.format = format;
- s.pixels = getBasePtr(bounds.left, bounds.top);
- s.pitch = pitch;
- s.w = bounds.width();
- s.h = bounds.height();
-
+ s.init(bounds.width(), bounds.height(), pitch, getBasePtr(bounds.left, bounds.top), format);
return s;
}
@@ -1067,7 +1062,7 @@ void ScreenSurface::setPixel(const Common::Point &pt, int palIndex) {
assert((pt.x >= 0) && (pt.y >= 0) && (pt.x <= SCREEN_WIDTH) && (pt.y <= SCREEN_ORIG_HEIGHT));
Graphics::Surface destSurface = lockArea(Common::Rect(pt.x, pt.y * 2, pt.x + 1, (pt.y + 1) * 2));
- byte *destP = (byte *)destSurface.pixels;
+ byte *destP = (byte *)destSurface.getPixels();
*destP = palIndex;
*(destP + SCREEN_WIDTH) = palIndex;
}
diff --git a/engines/mortevielle/menu.cpp b/engines/mortevielle/menu.cpp
index aa8d67e98a..f32c551ddb 100644
--- a/engines/mortevielle/menu.cpp
+++ b/engines/mortevielle/menu.cpp
@@ -393,7 +393,7 @@ void Menu::menuUp(int msgId) {
// Get a pointer to the source and destination of the area to restore
const byte *pSrc = (const byte *)_vm->_backgroundSurface.getBasePtr(0, 10);
Graphics::Surface destArea = _vm->_screenSurface.lockArea(Common::Rect(0, 10, SCREEN_WIDTH, SCREEN_HEIGHT));
- byte *pDest = (byte *)destArea.getBasePtr(0, 0);
+ byte *pDest = (byte *)destArea.getPixels();
// Copy the data
Common::copy(pSrc, pSrc + (400 - 10) * SCREEN_WIDTH, pDest);
diff --git a/engines/mortevielle/saveload.cpp b/engines/mortevielle/saveload.cpp
index 77c242c9e7..651ed07b65 100644
--- a/engines/mortevielle/saveload.cpp
+++ b/engines/mortevielle/saveload.cpp
@@ -189,7 +189,7 @@ void SavegameManager::writeSavegameHeader(Common::OutSaveFile *out, const Common
Graphics::Surface *thumb = new Graphics::Surface();
Graphics::Surface s = g_vm->_screenSurface.lockArea(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT));
- ::createThumbnail(thumb, (const byte *)s.pixels, SCREEN_WIDTH, SCREEN_HEIGHT, thumbPalette);
+ ::createThumbnail(thumb, (const byte *)s.getPixels(), SCREEN_WIDTH, SCREEN_HEIGHT, thumbPalette);
Graphics::saveThumbnail(*out, *thumb);
thumb->free();
delete thumb;
diff --git a/engines/neverhood/mouse.cpp b/engines/neverhood/mouse.cpp
index 13fba41e92..f11a3f99ea 100644
--- a/engines/neverhood/mouse.cpp
+++ b/engines/neverhood/mouse.cpp
@@ -183,7 +183,7 @@ void Mouse::updateCursor() {
_drawOffset = _mouseCursorResource.getRect();
_surface->drawMouseCursorResource(_mouseCursorResource, _frameNum / 2);
Graphics::Surface *cursorSurface = _surface->getSurface();
- CursorMan.replaceCursor((const byte*)cursorSurface->pixels,
+ CursorMan.replaceCursor((const byte*)cursorSurface->getPixels(),
cursorSurface->w, cursorSurface->h, -_drawOffset.x, -_drawOffset.y, 0);
}
diff --git a/engines/neverhood/resource.cpp b/engines/neverhood/resource.cpp
index 5f7aea86f4..a1a517f251 100644
--- a/engines/neverhood/resource.cpp
+++ b/engines/neverhood/resource.cpp
@@ -39,7 +39,7 @@ SpriteResource::~SpriteResource() {
void SpriteResource::draw(Graphics::Surface *destSurface, bool flipX, bool flipY) {
if (_pixels) {
- byte *dest = (byte*)destSurface->pixels;
+ byte *dest = (byte*)destSurface->getPixels();
const int destPitch = destSurface->pitch;
if (_rle)
unpackSpriteRle(_pixels, _dimensions.width, _dimensions.height, dest, destPitch, flipX, flipY);
@@ -116,7 +116,7 @@ AnimResource::~AnimResource() {
void AnimResource::draw(uint frameIndex, Graphics::Surface *destSurface, bool flipX, bool flipY) {
const AnimFrameInfo frameInfo = _frames[frameIndex];
- byte *dest = (byte*)destSurface->pixels;
+ byte *dest = (byte*)destSurface->getPixels();
const int destPitch = destSurface->pitch;
_currSpriteData = _spriteData + frameInfo.spriteDataOffs;
_width = frameInfo.drawOffset.width;
@@ -298,7 +298,7 @@ void MouseCursorResource::draw(int frameNum, Graphics::Surface *destSurface) {
const int sourcePitch = (_cursorSprite.getDimensions().width + 3) & 0xFFFC; // 4 byte alignment
const int destPitch = destSurface->pitch;
const byte *source = _cursorSprite.getPixels() + _cursorNum * (sourcePitch * 32) + frameNum * 32;
- byte *dest = (byte*)destSurface->pixels;
+ byte *dest = (byte*)destSurface->getPixels();
for (int16 yc = 0; yc < 32; yc++) {
memcpy(dest, source, 32);
source += sourcePitch;
diff --git a/engines/neverhood/screen.cpp b/engines/neverhood/screen.cpp
index 4a5bfb92ce..4c8dd9add0 100644
--- a/engines/neverhood/screen.cpp
+++ b/engines/neverhood/screen.cpp
@@ -54,7 +54,7 @@ void Screen::update() {
if (_fullRefresh) {
// NOTE When playing a fullscreen/doubled Smacker video usually a full screen refresh is needed
- _vm->_system->copyRectToScreen((const byte*)_backScreen->pixels, _backScreen->pitch, 0, 0, 640, 480);
+ _vm->_system->copyRectToScreen((const byte*)_backScreen->getPixels(), _backScreen->pitch, 0, 0, 640, 480);
_fullRefresh = false;
return;
}
@@ -174,7 +174,7 @@ void Screen::updatePalette() {
}
void Screen::clear() {
- memset(_backScreen->pixels, 0, _backScreen->pitch * _backScreen->h);
+ memset(_backScreen->getPixels(), 0, _backScreen->pitch * _backScreen->h);
_fullRefresh = true;
clearRenderQueue();
}
@@ -257,7 +257,7 @@ void Screen::drawSurface3(const Graphics::Surface *surface, int16 x, int16 y, ND
void Screen::drawDoubleSurface2(const Graphics::Surface *surface, NDrawRect &drawRect) {
- const byte *source = (const byte*)surface->getBasePtr(0, 0);
+ const byte *source = (const byte*)surface->getPixels();
byte *dest = (byte*)_backScreen->getBasePtr(drawRect.x, drawRect.y);
for (int16 yc = 0; yc < surface->h; yc++) {
diff --git a/engines/parallaction/disk_br.cpp b/engines/parallaction/disk_br.cpp
index 3135c3e8c5..f648f4b9a1 100644
--- a/engines/parallaction/disk_br.cpp
+++ b/engines/parallaction/disk_br.cpp
@@ -225,7 +225,7 @@ void DosDisk_br::loadBitmap(Common::SeekableReadStream &stream, Graphics::Surfac
}
surf.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
- stream.read(surf.pixels, width * height);
+ stream.read(surf.getPixels(), width * height);
}
Frames* DosDisk_br::loadPointer(const char *name) {
@@ -449,7 +449,7 @@ void AmigaDisk_br::init() {
void AmigaDisk_br::adjustForPalette(Graphics::Surface &surf, int transparentColor) {
uint size = surf.w * surf.h;
- byte *data = (byte *)surf.pixels;
+ byte *data = (byte *)surf.getPixels();
for (uint i = 0; i < size; i++, data++) {
if (transparentColor == -1 || transparentColor != *data)
*data += 16;
@@ -552,7 +552,7 @@ MaskBuffer *AmigaDisk_br::loadMask(const char *name, uint32 w, uint32 h) {
MaskBuffer *buffer = new MaskBuffer;
// surface width was shrunk to 1/4th of the bitmap width due to the pixel packing
buffer->create(decoder.getSurface()->w * 4, decoder.getSurface()->h);
- memcpy(buffer->data, decoder.getSurface()->pixels, buffer->size);
+ memcpy(buffer->data, decoder.getSurface()->getPixels(), buffer->size);
buffer->bigEndian = true;
finalpass(buffer->data, buffer->size);
return buffer;
@@ -612,7 +612,7 @@ GfxObj* AmigaDisk_br::loadStatic(const char* name) {
stream->read(shadow, shadowSize);
for (int32 i = 0; i < surf->h; ++i) {
byte *src = shadow + shadowWidth * i;
- byte *dst = (byte *)surf->pixels + surf->pitch * i;
+ byte *dst = (byte *)surf->getPixels() + surf->pitch * i;
for (int32 j = 0; j < surf->w; ++j, ++dst) {
byte bit = src[j/8] & (1 << (7 - (j & 7)));
diff --git a/engines/parallaction/disk_ns.cpp b/engines/parallaction/disk_ns.cpp
index 4c4893ec61..ae28e864a9 100644
--- a/engines/parallaction/disk_ns.cpp
+++ b/engines/parallaction/disk_ns.cpp
@@ -482,7 +482,7 @@ void DosDisk_ns::loadBackground(BackgroundInfo& info, const char *filename) {
// read bitmap, mask and path data and extract them into the 3 buffers
info.bg.create(info.width, info.height, Graphics::PixelFormat::createFormatCLUT8());
createMaskAndPathBuffers(info);
- unpackBackground(stream, (byte *)info.bg.pixels, info._mask->data, info._path->data);
+ unpackBackground(stream, (byte *)info.bg.getPixels(), info._mask->data, info._path->data);
delete stream;
}
@@ -976,7 +976,7 @@ void AmigaDisk_ns::loadMask_internal(BackgroundInfo& info, const char *name) {
info._mask = new MaskBuffer;
// surface width was shrunk to 1/4th of the bitmap width due to the pixel packing
info._mask->create(decoder.getSurface()->w * 4, decoder.getSurface()->h);
- memcpy(info._mask->data, decoder.getSurface()->pixels, info._mask->size);
+ memcpy(info._mask->data, decoder.getSurface()->getPixels(), info._mask->size);
info._mask->bigEndian = true;
}
@@ -998,7 +998,7 @@ void AmigaDisk_ns::loadPath_internal(BackgroundInfo& info, const char *name) {
info._path = new PathBuffer;
// surface width was shrunk to 1/8th of the bitmap width due to the pixel packing
info._path->create(decoder.getSurface()->w * 8, decoder.getSurface()->h);
- memcpy(info._path->data, decoder.getSurface()->pixels, info._path->size);
+ memcpy(info._path->data, decoder.getSurface()->getPixels(), info._path->size);
info._path->bigEndian = true;
}
diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp
index 3ea4332e50..816f220b1f 100644
--- a/engines/parallaction/exec_ns.cpp
+++ b/engines/parallaction/exec_ns.cpp
@@ -126,9 +126,7 @@ DECLARE_INSTRUCTION_OPCODE(put) {
inst->_a->getFrameRect(r);
Graphics::Surface v18;
- v18.w = r.width();
- v18.h = r.height();
- v18.pixels = inst->_a->getFrameData();
+ v18.init(r.width(), r.height(), r.width(), inst->_a->getFrameData(), Graphics::PixelFormat::createFormatCLUT8());
int16 x = inst->_opA.getValue();
int16 y = inst->_opB.getValue();
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index b8a8ceb61f..3f36d56420 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -332,7 +332,7 @@ void Gfx::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int
void Gfx::clearScreen() {
if (_doubleBuffering) {
- if (_backBuffer.pixels) {
+ if (_backBuffer.getPixels()) {
Common::Rect r(_backBuffer.w, _backBuffer.h);
_backBuffer.fillRect(r, 0);
}
@@ -419,13 +419,13 @@ void Gfx::updateScreen() {
// is needed
_overlayMode = false;
- bool skipBackground = (_backgroundInfo->bg.pixels == 0); // don't render frame if background is missing
+ bool skipBackground = (_backgroundInfo->bg.getPixels() == 0); // don't render frame if background is missing
if (!skipBackground) {
// background may not cover the whole screen, so adjust bulk update size
uint w = _backgroundInfo->width;
uint h = _backgroundInfo->height;
- byte *backgroundData = (byte *)_backgroundInfo->bg.getBasePtr(0, 0);
+ byte *backgroundData = (byte *)_backgroundInfo->bg.getPixels();
uint16 backgroundPitch = _backgroundInfo->bg.pitch;
copyRectToScreen(backgroundData, backgroundPitch, _backgroundInfo->_x, _backgroundInfo->_y, w, h);
}
@@ -450,7 +450,7 @@ void Gfx::applyHalfbriteEffect_NS(Graphics::Surface &surf) {
return;
}
- byte *buf = (byte *)surf.pixels;
+ byte *buf = (byte *)surf.getPixels();
for (int i = 0; i < surf.w*surf.h; i++) {
*buf++ |= 0x20;
}
@@ -493,7 +493,7 @@ void Gfx::patchBackground(Graphics::Surface &surf, int16 x, int16 y, bool mask)
r.moveTo(x, y);
uint16 z = (mask) ? _backgroundInfo->getMaskLayer(y) : LAYER_FOREGROUND;
- blt(r, (byte *)surf.pixels, &_backgroundInfo->bg, z, 100, 0);
+ blt(r, (byte *)surf.getPixels(), &_backgroundInfo->bg, z, 100, 0);
}
void Gfx::fillBackground(const Common::Rect& r, byte color) {
@@ -536,12 +536,12 @@ GfxObj *Gfx::renderFloatingLabel(Font *font, char *text) {
setupLabelSurface(*cnv, w, h);
font->setColor((_gameType == GType_BRA) ? 0 : 7);
- font->drawString((byte *)cnv->pixels + 1, cnv->w, text);
- font->drawString((byte *)cnv->pixels + 1 + cnv->w * 2, cnv->w, text);
- font->drawString((byte *)cnv->pixels + cnv->w, cnv->w, text);
- font->drawString((byte *)cnv->pixels + 2 + cnv->w, cnv->w, text);
+ font->drawString((byte *)cnv->getBasePtr(1, 0), cnv->w, text);
+ font->drawString((byte *)cnv->getBasePtr(1, 2), cnv->w, text);
+ font->drawString((byte *)cnv->getBasePtr(0, 1), cnv->w, text);
+ font->drawString((byte *)cnv->getBasePtr(2, 1), cnv->w, text);
font->setColor((_gameType == GType_BRA) ? 11 : 1);
- font->drawString((byte *)cnv->pixels + 1 + cnv->w, cnv->w, text);
+ font->drawString((byte *)cnv->getBasePtr(1, 1), cnv->w, text);
} else {
w = font->getStringWidth(text);
h = font->height();
@@ -704,7 +704,7 @@ void Gfx::unregisterLabel(GfxObj *label) {
void Gfx::copyRect(const Common::Rect &r, Graphics::Surface &src, Graphics::Surface &dst) {
byte *s = (byte *)src.getBasePtr(r.left, r.top);
- byte *d = (byte *)dst.getBasePtr(0, 0);
+ byte *d = (byte *)dst.getPixels();
for (uint16 i = 0; i < r.height(); i++) {
memcpy(d, s, r.width());
diff --git a/engines/parallaction/input.cpp b/engines/parallaction/input.cpp
index bf7cdc439d..a445ce0138 100644
--- a/engines/parallaction/input.cpp
+++ b/engines/parallaction/input.cpp
@@ -499,7 +499,7 @@ void Input::initCursors() {
// TODO: scale mouse cursor (see staticres.cpp)
Graphics::Surface *surf2 = new Graphics::Surface;
surf2->create(32, 16, Graphics::PixelFormat::createFormatCLUT8());
- memcpy(surf2->pixels, _resMouseArrow_BR_Amiga, 32*16);
+ memcpy(surf2->getPixels(), _resMouseArrow_BR_Amiga, 32*16);
_mouseArrow = new SurfaceToFrames(surf2);
}
break;
diff --git a/engines/parallaction/inventory.h b/engines/parallaction/inventory.h
index a3b7bf953f..d5cf8badf0 100644
--- a/engines/parallaction/inventory.h
+++ b/engines/parallaction/inventory.h
@@ -108,7 +108,7 @@ public:
void highlightItem(ItemPosition pos, byte color);
void drawItem(ItemName name, byte *buffer, uint pitch);
- byte* getData() const { return (byte *)_surf.pixels; }
+ byte *getData() { return (byte *)_surf.getPixels(); }
void getRect(Common::Rect &r) const;
int16 getNumLines() const;
diff --git a/engines/pegasus/cursor.cpp b/engines/pegasus/cursor.cpp
index 897d31d7bd..ad0d2c2d7d 100644
--- a/engines/pegasus/cursor.cpp
+++ b/engines/pegasus/cursor.cpp
@@ -85,9 +85,9 @@ void Cursor::setCurrentFrameIndex(int32 index) {
if (_info[index].surface->format.bytesPerPixel == 1) {
CursorMan.replaceCursorPalette(_info[index].palette, 0, _info[index].colorCount);
- CursorMan.replaceCursor(_info[index].surface->pixels, _info[index].surface->w, _info[index].surface->h, _info[index].hotspot.x, _info[index].hotspot.y, 0);
+ CursorMan.replaceCursor(_info[index].surface->getPixels(), _info[index].surface->w, _info[index].surface->h, _info[index].hotspot.x, _info[index].hotspot.y, 0);
} else {
- CursorMan.replaceCursor(_info[index].surface->pixels, _info[index].surface->w, _info[index].surface->h, _info[index].hotspot.x, _info[index].hotspot.y, _info[index].surface->format.RGBToColor(0xFF, 0xFF, 0xFF), false, &_info[index].surface->format);
+ CursorMan.replaceCursor(_info[index].surface->getPixels(), _info[index].surface->w, _info[index].surface->h, _info[index].hotspot.x, _info[index].hotspot.y, _info[index].surface->format.RGBToColor(0xFF, 0xFF, 0xFF), false, &_info[index].surface->format);
}
((PegasusEngine *)g_engine)->_gfx->markCursorAsDirty();
@@ -203,7 +203,7 @@ void Cursor::loadCursorImage(CursorInfo &cursorInfo) {
// PixMap data
if (pixMap.pixelSize == 8) {
cursorInfo.surface->create(pixMap.rowBytes, pixMap.bounds.height(), Graphics::PixelFormat::createFormatCLUT8());
- cicnStream->read(cursorInfo.surface->pixels, pixMap.rowBytes * pixMap.bounds.height());
+ cicnStream->read(cursorInfo.surface->getPixels(), pixMap.rowBytes * pixMap.bounds.height());
// While this looks sensible, it actually doesn't work for some cursors
// (ie. the 'can grab' hand)
diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index 8dbd678809..5475108abd 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -318,7 +318,7 @@ void GraphicsManager::shakeTheWorld(TimeValue duration, TimeScale scale) {
}
if (lastOffset.x != 0 || lastOffset.y != 0) {
- g_system->copyRectToScreen((byte *)oldScreen.pixels, oldScreen.pitch, 0, 0, 640, 480);
+ g_system->copyRectToScreen((byte *)oldScreen.getPixels(), oldScreen.pitch, 0, 0, 640, 480);
g_system->updateScreen();
}
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index 9a378a6728..0b3e1ee040 100644
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -200,7 +200,7 @@ void Caldoria::start() {
const Graphics::Surface *frame = pullbackMovie->decodeNextFrame();
assert(frame);
assert(frame->format == g_system->getScreenFormat());
- g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, 64, 112, frame->w, frame->h);
+ g_system->copyRectToScreen((const byte *)frame->getPixels(), frame->pitch, 64, 112, frame->w, frame->h);
_vm->_gfx->doFadeInSync(kTwoSeconds * kFifteenTicksPerSecond, kFifteenTicksPerSecond);
bool saveAllowed = _vm->swapSaveAllowed(false);
@@ -216,7 +216,7 @@ void Caldoria::start() {
frame = pullbackMovie->decodeNextFrame();
if (frame) {
- g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, 64, 112, frame->w, frame->h);
+ g_system->copyRectToScreen((const byte *)frame->getPixels(), frame->pitch, 64, 112, frame->w, frame->h);
g_system->updateScreen();
}
}
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 463e81e52e..3bd29ce8dd 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -313,7 +313,7 @@ void PegasusEngine::runIntro() {
const Graphics::Surface *frame = video->decodeNextFrame();
if (frame) {
- _system->copyRectToScreen((byte *)frame->pixels, frame->pitch, 0, 0, frame->w, frame->h);
+ _system->copyRectToScreen((const byte *)frame->getPixels(), frame->pitch, 0, 0, frame->w, frame->h);
_system->updateScreen();
}
}
@@ -1367,7 +1367,7 @@ bool PegasusEngine::playMovieScaled(Video::VideoDecoder *video, uint16 x, uint16
if (frame->w <= 320 && frame->h <= 240) {
drawScaledFrame(frame, x, y);
} else {
- _system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);
+ _system->copyRectToScreen((const byte *)frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
_system->updateScreen();
}
}
@@ -2270,11 +2270,11 @@ void PegasusEngine::drawScaledFrame(const Graphics::Surface *frame, uint16 x, ui
scaledFrame.create(frame->w * 2, frame->h * 2, frame->format);
if (frame->format.bytesPerPixel == 2)
- scaleFrame<uint16>((uint16 *)frame->pixels, (uint16 *)scaledFrame.pixels, frame->w, frame->h, frame->pitch);
+ scaleFrame<uint16>((const uint16 *)frame->getPixels(), (uint16 *)scaledFrame.getPixels(), frame->w, frame->h, frame->pitch);
else
- scaleFrame<uint32>((uint32 *)frame->pixels, (uint32 *)scaledFrame.pixels, frame->w, frame->h, frame->pitch);
+ scaleFrame<uint32>((const uint32 *)frame->getPixels(), (uint32 *)scaledFrame.getPixels(), frame->w, frame->h, frame->pitch);
- _system->copyRectToScreen((byte *)scaledFrame.pixels, scaledFrame.pitch, x, y, scaledFrame.w, scaledFrame.h);
+ _system->copyRectToScreen((byte *)scaledFrame.getPixels(), scaledFrame.pitch, x, y, scaledFrame.w, scaledFrame.h);
_system->updateScreen();
scaledFrame.free();
}
diff --git a/engines/pegasus/transition.cpp b/engines/pegasus/transition.cpp
index 1ae212df85..b736b115ee 100644
--- a/engines/pegasus/transition.cpp
+++ b/engines/pegasus/transition.cpp
@@ -70,7 +70,7 @@ void ScreenFader::setFaderValue(const int32 value) {
if (value != getFaderValue()) {
Fader::setFaderValue(value);
- if (_screen->pixels) {
+ if (_screen->getPixels()) {
// The original game does a gamma fade here using the Mac API. In order to do
// that, it would require an immense amount of CPU processing. This does a
// linear fade instead, which looks fairly well, IMO.
diff --git a/engines/saga/animation.cpp b/engines/saga/animation.cpp
index a99bd66e5e..df8283b4c2 100644
--- a/engines/saga/animation.cpp
+++ b/engines/saga/animation.cpp
@@ -501,7 +501,7 @@ void Anim::play(uint16 animId, int vectorTime, bool playing) {
}
anim = getAnimation(animId);
- displayBuffer = (byte *)_vm->_render->getBackGroundSurface()->pixels;
+ displayBuffer = (byte *)_vm->_render->getBackGroundSurface()->getPixels();
if (playing) {
anim->state = ANIM_PLAYING;
diff --git a/engines/saga/gfx.h b/engines/saga/gfx.h
index c677b76324..c68160e907 100644
--- a/engines/saga/gfx.h
+++ b/engines/saga/gfx.h
@@ -201,7 +201,7 @@ public:
// Whenever it gets called, the corresponding caller must take care
// to add the corresponding dirty rectangle itself
byte *getBackBufferPixels() {
- return (byte *)_backBuffer.pixels;
+ return (byte *)_backBuffer.getPixels();
}
uint16 getBackBufferWidth() {
diff --git a/engines/saga/introproc_ihnm.cpp b/engines/saga/introproc_ihnm.cpp
index 6015e6757a..7922d56425 100644
--- a/engines/saga/introproc_ihnm.cpp
+++ b/engines/saga/introproc_ihnm.cpp
@@ -212,7 +212,7 @@ bool Scene::playTitle(int title, int time, int mode) {
break;
case 2: // display background
- _vm->_system->copyRectToScreen(backBufferSurface->pixels, backBufferSurface->w, 0, 0,
+ _vm->_system->copyRectToScreen(backBufferSurface->getPixels(), backBufferSurface->w, 0, 0,
backBufferSurface->w, backBufferSurface->h);
phase++;
startTime = curTime;
@@ -247,7 +247,7 @@ bool Scene::playTitle(int title, int time, int mode) {
frameTime = curTime;
- _vm->_system->copyRectToScreen(backBufferSurface->pixels, backBufferSurface->w, 0, 0,
+ _vm->_system->copyRectToScreen(backBufferSurface->getPixels(), backBufferSurface->w, 0, 0,
backBufferSurface->w, backBufferSurface->h);
}
@@ -273,8 +273,8 @@ bool Scene::playTitle(int title, int time, int mode) {
_vm->_anim->endVideo();
- memset((byte *)backBufferSurface->pixels, 0, backBufferSurface->w * backBufferSurface->h);
- _vm->_system->copyRectToScreen(backBufferSurface->pixels, backBufferSurface->w, 0, 0,
+ memset((byte *)backBufferSurface->getPixels(), 0, backBufferSurface->w * backBufferSurface->h);
+ _vm->_system->copyRectToScreen(backBufferSurface->getPixels(), backBufferSurface->w, 0, 0,
backBufferSurface->w, backBufferSurface->h);
return interrupted;
diff --git a/engines/saga/introproc_saga2.cpp b/engines/saga/introproc_saga2.cpp
index 260eca98e6..e61dfbf161 100644
--- a/engines/saga/introproc_saga2.cpp
+++ b/engines/saga/introproc_saga2.cpp
@@ -108,7 +108,7 @@ void Scene::playMovie(const char *filename) {
if (smkDecoder->needsUpdate()) {
const Graphics::Surface *frame = smkDecoder->decodeNextFrame();
if (frame) {
- _vm->_system->copyRectToScreen(frame->pixels, frame->pitch, x, y, frame->w, frame->h);
+ _vm->_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
if (smkDecoder->hasDirtyPalette())
_vm->_system->getPaletteManager()->setPalette(smkDecoder->getPalette(), 0, 256);
diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp
index 75876b1c90..eff31cf98b 100644
--- a/engines/saga/scene.cpp
+++ b/engines/saga/scene.cpp
@@ -468,7 +468,7 @@ void Scene::changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionTy
pal = decoder.getPalette();
rect.setWidth(decoder.getSurface()->w);
rect.setHeight(decoder.getSurface()->h);
- _vm->_gfx->drawRegion(rect, (const byte *)decoder.getSurface()->pixels);
+ _vm->_gfx->drawRegion(rect, (const byte *)decoder.getSurface()->getPixels());
for (int j = 0; j < PAL_ENTRIES; j++) {
cPal[j].red = *pal++;
cPal[j].green = *pal++;
@@ -1120,9 +1120,9 @@ void Scene::draw() {
_vm->_render->getBackGroundSurface()->getRect(rect);
rect.bottom = (_sceneClip.bottom < rect.bottom) ? getHeight() : rect.bottom;
if (_vm->_render->isFullRefresh())
- _vm->_gfx->drawRegion(rect, (const byte *)_vm->_render->getBackGroundSurface()->pixels);
+ _vm->_gfx->drawRegion(rect, (const byte *)_vm->_render->getBackGroundSurface()->getPixels());
else
- _vm->_gfx->drawBgRegion(rect, (const byte *)_vm->_render->getBackGroundSurface()->pixels);
+ _vm->_gfx->drawBgRegion(rect, (const byte *)_vm->_render->getBackGroundSurface()->getPixels());
}
}
diff --git a/engines/sci/detection_tables.h b/engines/sci/detection_tables.h
index 66164a1937..7c4638a992 100644
--- a/engines/sci/detection_tables.h
+++ b/engines/sci/detection_tables.h
@@ -1054,6 +1054,23 @@ static const struct ADGameDescription SciGameDescriptions[] = {
AD_LISTEND},
Common::EN_ANY, Common::kPlatformWindows, ADGF_CD, GUIO4(GUIO_MIDIGM, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_FB01_MIDI, GAMEOPTION_JONES_CDAUDIO) },
+ // Jones in the Fast Lane - English DOS US CD (alternate version)
+ // Supplied by collector9 in bug #3614668
+ {"jones", "CD", {
+ {"resource.map", 0, "4344ff3f796707843b992adec2c87663", 4878},
+ {"resource.001", 0, "3876da2ce16fb7dea2f5d943d946fa84", 1652062},
+ AD_LISTEND},
+ Common::EN_ANY, Common::kPlatformDOS, ADGF_CD, GUIO1(GAMEOPTION_JONES_CDAUDIO) },
+
+ // Jones in the Fast Lane - English DOS US CD (alternate version)
+ // Same entry as the DOS version above. This one is used for the alternate
+ // General MIDI music tracks in the Windows version
+ {"jones", "CD", {
+ {"resource.map", 0, "4344ff3f796707843b992adec2c87663", 4878},
+ {"resource.001", 0, "3876da2ce16fb7dea2f5d943d946fa84", 1652062},
+ AD_LISTEND},
+ Common::EN_ANY, Common::kPlatformWindows, ADGF_CD, GUIO4(GUIO_MIDIGM, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_FB01_MIDI, GAMEOPTION_JONES_CDAUDIO) },
+
// King's Quest 1 SCI Remake - English Amiga (from www.back2roots.org)
// Executable scanning reports "1.003.007"
// SCI interpreter version 0.001.010
diff --git a/engines/sci/engine/kvideo.cpp b/engines/sci/engine/kvideo.cpp
index 9b0cb38f51..3964ccc1f8 100644
--- a/engines/sci/engine/kvideo.cpp
+++ b/engines/sci/engine/kvideo.cpp
@@ -103,10 +103,10 @@ void playVideo(Video::VideoDecoder *videoDecoder, VideoState videoState) {
if (frame) {
if (scaleBuffer) {
// TODO: Probably should do aspect ratio correction in e.g. GK1 Windows
- g_sci->_gfxScreen->scale2x((byte *)frame->pixels, scaleBuffer, videoDecoder->getWidth(), videoDecoder->getHeight(), bytesPerPixel);
+ g_sci->_gfxScreen->scale2x((const byte *)frame->getPixels(), scaleBuffer, videoDecoder->getWidth(), videoDecoder->getHeight(), bytesPerPixel);
g_system->copyRectToScreen(scaleBuffer, pitch, x, y, width, height);
} else {
- g_system->copyRectToScreen(frame->pixels, frame->pitch, x, y, width, height);
+ g_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, width, height);
}
if (videoDecoder->hasDirtyPalette()) {
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index ca1ef357ae..76510fa53b 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -532,7 +532,7 @@ void GfxFrameout::showVideo() {
if (videoDecoder->needsUpdate()) {
const Graphics::Surface *frame = videoDecoder->decodeNextFrame();
if (frame) {
- g_system->copyRectToScreen(frame->pixels, frame->pitch, x, y, frame->w, frame->h);
+ g_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
if (videoDecoder->hasDirtyPalette())
g_system->getPaletteManager()->setPalette(videoDecoder->getPalette(), 0, 256);
diff --git a/engines/sci/graphics/maciconbar.cpp b/engines/sci/graphics/maciconbar.cpp
index dfb50b0edb..4df80b289f 100644
--- a/engines/sci/graphics/maciconbar.cpp
+++ b/engines/sci/graphics/maciconbar.cpp
@@ -129,7 +129,7 @@ void GfxMacIconBar::drawIcon(uint16 iconIndex, bool selected) {
void GfxMacIconBar::drawEnabledImage(Graphics::Surface *surface, const Common::Rect &rect) {
if (surface)
- g_system->copyRectToScreen(surface->pixels, surface->pitch, rect.left, rect.top, rect.width(), rect.height());
+ g_system->copyRectToScreen(surface->getPixels(), surface->pitch, rect.left, rect.top, rect.width(), rect.height());
}
void GfxMacIconBar::drawDisabledImage(Graphics::Surface *surface, const Common::Rect &rect) {
@@ -153,7 +153,7 @@ void GfxMacIconBar::drawDisabledImage(Graphics::Surface *surface, const Common::
*((byte *)newSurf.getBasePtr(j, i)) = 0;
}
- g_system->copyRectToScreen(newSurf.pixels, newSurf.pitch, rect.left, rect.top, rect.width(), rect.height());
+ g_system->copyRectToScreen(newSurf.getPixels(), newSurf.pitch, rect.left, rect.top, rect.width(), rect.height());
newSurf.free();
}
@@ -224,7 +224,7 @@ Graphics::Surface *GfxMacIconBar::createImage(uint32 iconIndex, bool isSelected)
}
void GfxMacIconBar::remapColors(Graphics::Surface *surf, const byte *palette) {
- byte *pixels = (byte *)surf->pixels;
+ byte *pixels = (byte *)surf->getPixels();
// Remap to the screen palette
for (uint16 i = 0; i < surf->w * surf->h; i++) {
diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp
index 74503c0c77..7b92bc89eb 100644
--- a/engines/sci/graphics/screen.cpp
+++ b/engines/sci/graphics/screen.cpp
@@ -170,14 +170,14 @@ void GfxScreen::copyToScreen() {
void GfxScreen::copyFromScreen(byte *buffer) {
// TODO this ignores the pitch
Graphics::Surface *screen = g_system->lockScreen();
- memcpy(buffer, screen->pixels, _displayPixels);
+ memcpy(buffer, screen->getPixels(), _displayPixels);
g_system->unlockScreen();
}
void GfxScreen::kernelSyncWithFramebuffer() {
// TODO this ignores the pitch
Graphics::Surface *screen = g_system->lockScreen();
- memcpy(_displayScreen, screen->pixels, _displayPixels);
+ memcpy(_displayScreen, screen->getPixels(), _displayPixels);
g_system->unlockScreen();
}
diff --git a/engines/sci/video/robot_decoder.cpp b/engines/sci/video/robot_decoder.cpp
index 0337a8d306..a567ece2ea 100644
--- a/engines/sci/video/robot_decoder.cpp
+++ b/engines/sci/video/robot_decoder.cpp
@@ -210,7 +210,7 @@ void RobotDecoder::readNextPacket() {
// Copy over the decompressed frame
byte *inFrame = decompressedFrame;
- byte *outFrame = (byte *)surface->pixels;
+ byte *outFrame = (byte *)surface->getPixels();
// Black out the surface
memset(outFrame, 0, surface->w * surface->h);
diff --git a/engines/sci/video/seq_decoder.cpp b/engines/sci/video/seq_decoder.cpp
index a7b6346eca..54603ec1f1 100644
--- a/engines/sci/video/seq_decoder.cpp
+++ b/engines/sci/video/seq_decoder.cpp
@@ -119,7 +119,7 @@ const Graphics::Surface *SEQDecoder::SEQVideoTrack::decodeNextFrame() {
_fileStream->seek(offset);
if (frameType == kSeqFrameFull) {
- byte *dst = (byte *)_surface->pixels + frameTop * SEQ_SCREEN_WIDTH + frameLeft;
+ byte *dst = (byte *)_surface->getBasePtr(frameLeft, frameTop);
byte *linebuf = new byte[frameWidth];
@@ -133,7 +133,7 @@ const Graphics::Surface *SEQDecoder::SEQVideoTrack::decodeNextFrame() {
} else {
byte *buf = new byte[frameSize];
_fileStream->read(buf, frameSize);
- decodeFrame(buf, rleSize, buf + rleSize, frameSize - rleSize, (byte *)_surface->pixels + SEQ_SCREEN_WIDTH * frameTop, frameLeft, frameWidth, frameHeight, colorKey);
+ decodeFrame(buf, rleSize, buf + rleSize, frameSize - rleSize, (byte *)_surface->getBasePtr(0, frameTop), frameLeft, frameWidth, frameHeight, colorKey);
delete[] buf;
}
diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp
index b6acf01050..481c4af432 100644
--- a/engines/scumm/akos.cpp
+++ b/engines/scumm/akos.cpp
@@ -994,7 +994,7 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) {
if (_draw_bottom < rect.bottom)
_draw_bottom = rect.bottom;
- v1.destptr = (byte *)_out.pixels + v1.y * _out.pitch + v1.x * _vm->_bytesPerPixel;
+ v1.destptr = (byte *)_out.getBasePtr(v1.x, v1.y);
codec1_genericDecode(v1);
@@ -1288,7 +1288,7 @@ byte AkosRenderer::codec16(int xmoveCur, int ymoveCur) {
int32 numskip_before = skip_x + (skip_y * _width);
int32 numskip_after = _width - cur_x;
- byte *dst = (byte *)_out.pixels + height_unk * _out.pitch + width_unk * _vm->_bytesPerPixel;
+ byte *dst = (byte *)_out.getBasePtr(width_unk, height_unk);
akos16Decompress(dst, _out.pitch, _srcptr, cur_x, out_height, dir, numskip_before, numskip_after, transparency, clip.left, clip.top, _zbuf);
return 0;
@@ -1358,7 +1358,7 @@ byte AkosRenderer::codec32(int xmoveCur, int ymoveCur) {
palPtr = _vm->_hePalettes + _vm->_hePaletteSlot + 768;
}
- byte *dstPtr = (byte *)_out.pixels + dst.top * _out.pitch + dst.left * _vm->_bytesPerPixel;
+ byte *dstPtr = (byte *)_out.getBasePtr(dst.left, dst.top);
if (_shadow_mode == 3) {
Wiz::decompressWizImage<kWizXMap>(dstPtr, _out.pitch, kDstScreen, _srcptr, src, 0, palPtr, xmap, _vm->_bytesPerPixel);
} else {
diff --git a/engines/scumm/base-costume.cpp b/engines/scumm/base-costume.cpp
index 46c68c81b0..e1a8688bb9 100644
--- a/engines/scumm/base-costume.cpp
+++ b/engines/scumm/base-costume.cpp
@@ -32,13 +32,15 @@ byte BaseCostumeRenderer::drawCostume(const VirtScreen &vs, int numStrips, const
_out = vs;
if (drawToBackBuf)
- _out.pixels = vs.getBackPixels(0, 0);
+ _out.setPixels(vs.getBackPixels(0, 0));
else
- _out.pixels = vs.getPixels(0, 0);
+ _out.setPixels(vs.getPixels(0, 0));
_actorX += _vm->_virtscr[kMainVirtScreen].xstart & 7;
_out.w = _out.pitch / _vm->_bytesPerPixel;
- _out.pixels = (byte *)_out.pixels - (_vm->_virtscr[kMainVirtScreen].xstart & 7);
+ // We do not use getBasePtr here because the offset to pixels never used
+ // _vm->_bytesPerPixel, but it seems unclear why.
+ _out.setPixels((byte *)_out.getPixels() - (_vm->_virtscr[kMainVirtScreen].xstart & 7));
_numStrips = numStrips;
diff --git a/engines/scumm/bomp.cpp b/engines/scumm/bomp.cpp
index 845cf70722..5b87f3042c 100644
--- a/engines/scumm/bomp.cpp
+++ b/engines/scumm/bomp.cpp
@@ -231,7 +231,10 @@ void drawBomp(const BompDrawData &bd) {
}
src = bd.src;
- dst = (byte *)bd.dst.pixels + bd.y * bd.dst.pitch + (bd.x + clip.left);
+ // FIXME: This gets passed a const destination Surface. Intuitively this
+ // should never get written to. But sadly it does... For now we simply
+ // cast the const qualifier away.
+ dst = (byte *)const_cast<void *>(bd.dst.getBasePtr((bd.x + clip.left), bd.y));
const byte maskbit = revBitMask((bd.x + clip.left) & 7);
diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp
index 9ae75b6683..dd79aff2da 100644
--- a/engines/scumm/charset.cpp
+++ b/engines/scumm/charset.cpp
@@ -799,7 +799,7 @@ void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr,
if (ignoreCharsetMask || !vs->hasTwoBuffers) {
dstPtr = vs->getPixels(0, 0);
} else {
- dstPtr = (byte *)_vm->_textSurface.pixels;
+ dstPtr = (byte *)_vm->_textSurface.getPixels();
}
if (_blitAlso && vs->hasTwoBuffers) {
@@ -829,7 +829,7 @@ void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr,
dstPtr = vs->getPixels(_left, drawTop);
} else {
dstSurface = _vm->_textSurface;
- dstPtr = (byte *)_vm->_textSurface.pixels + (_top - _vm->_screenTop) * _vm->_textSurface.pitch * _vm->_textSurfaceMultiplier + _left * _vm->_textSurfaceMultiplier;
+ dstPtr = (byte *)_vm->_textSurface.getBasePtr(_left * _vm->_textSurfaceMultiplier, (_top - _vm->_screenTop) * _vm->_textSurfaceMultiplier);
}
if (_blitAlso && vs->hasTwoBuffers) {
@@ -907,7 +907,7 @@ bool CharsetRendererClassic::prepareDraw(uint16 chr) {
void CharsetRendererClassic::drawChar(int chr, Graphics::Surface &s, int x, int y) {
if (!prepareDraw(chr))
return;
- byte *dst = (byte *)s.pixels + y * s.pitch + x;
+ byte *dst = (byte *)s.getBasePtr(x, y);
drawBitsN(s, dst, _charPtr, *_fontPtr, y, _width, _height);
}
@@ -1242,7 +1242,7 @@ void CharsetRendererNut::printChar(int chr, bool ignoreCharsetMask) {
if (ignoreCharsetMask) {
VirtScreen *vs = &_vm->_virtscr[kMainVirtScreen];
s = *vs;
- s.pixels = vs->getPixels(0, 0);
+ s.setPixels(vs->getPixels(0, 0));
} else {
s = _vm->_textSurface;
drawTop -= _vm->_screenTop;
@@ -1401,7 +1401,7 @@ void CharsetRendererTownsClassic::drawBitsN(const Graphics::Surface&, byte *dst,
}
bool scale2x = (_vm->_textSurfaceMultiplier == 2);
- dst = (byte *)_vm->_textSurface.pixels + (_top - _vm->_screenTop) * _vm->_textSurface.pitch * _vm->_textSurfaceMultiplier + _left * _vm->_textSurfaceMultiplier;
+ dst = (byte *)_vm->_textSurface.getBasePtr(_left * _vm->_textSurfaceMultiplier, (_top - _vm->_screenTop) * _vm->_textSurfaceMultiplier);
int y, x;
int color;
diff --git a/engines/scumm/costume.cpp b/engines/scumm/costume.cpp
index 4ebdd00fdc..85c60f9a40 100644
--- a/engines/scumm/costume.cpp
+++ b/engines/scumm/costume.cpp
@@ -293,7 +293,7 @@ byte ClassicCostumeRenderer::mainRoutine(int xmoveCur, int ymoveCur) {
return 2;
}
- v1.destptr = (byte *)_out.pixels + v1.y * _out.pitch + v1.x * _vm->_bytesPerPixel;
+ v1.destptr = (byte *)_out.getBasePtr(v1.x, v1.y);
v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, _zbuf);
@@ -826,7 +826,7 @@ byte NESCostumeRenderer::drawLimb(const Actor *a, int limb) {
int my = _actorY + y + ty;
int mx = _actorX + x + tx;
if (!(_zbuf && (maskBuf[my * _numStrips + mx / 8] & revBitMask(mx & 7))))
- *((byte *)_out.pixels + my * _out.pitch + mx) = palette[c];
+ *((byte *)_out.getBasePtr(mx, my)) = palette[c];
}
}
}
@@ -1238,7 +1238,7 @@ byte V0CostumeRenderer::drawLimb(const Actor *a, int limb) {
int destY = ypos + y;
if (destY >= 0 && destY < _out.h && destX >= 0 && destX < _out.w) {
- byte *dst = (byte *)_out.pixels + destY * _out.pitch + destX;
+ byte *dst = (byte *)_out.getBasePtr(destX, destY);
byte *mask = _vm->getMaskBuffer(0, destY, _zbuf);
if (a0->_limb_flipped[limb]) {
LINE(0, 0); LINE(2, 2); LINE(4, 4); LINE(6, 6);
diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp
index 269ae9e10a..721644b554 100644
--- a/engines/scumm/cursor.cpp
+++ b/engines/scumm/cursor.cpp
@@ -139,7 +139,7 @@ void ScummEngine_v6::grabCursor(int x, int y, int w, int h) {
return;
}
- setCursorFromBuffer((byte *)vs->pixels + (y - vs->topline) * vs->pitch + x, w, h, vs->pitch);
+ setCursorFromBuffer((byte *)vs->getBasePtr(x, y - vs->topline), w, h, vs->pitch);
}
void ScummEngine_v6::setDefaultCursor() {
@@ -417,13 +417,11 @@ void ScummEngine_v5::redefineBuiltinCursorFromChar(int index, int chr) {
Graphics::Surface s;
byte buf[16*17];
memset(buf, 123, 16*17);
- s.pixels = buf;
- s.w = _charset->getCharWidth(chr);
- s.h = _charset->getFontHeight();
- s.pitch = s.w;
+ s.init(_charset->getCharWidth(chr), _charset->getFontHeight(),
+ _charset->getCharWidth(chr), buf,
+ Graphics::PixelFormat::createFormatCLUT8());
// s.h = 17 for FM-TOWNS Loom Japanese. Fixes bug #1166917
assert(s.w <= 16 && s.h <= 17);
- s.format = Graphics::PixelFormat::createFormatCLUT8();
_charset->drawChar(chr, s, 0, 0);
diff --git a/engines/scumm/debugger.cpp b/engines/scumm/debugger.cpp
index 9b6dd1e687..872293f821 100644
--- a/engines/scumm/debugger.cpp
+++ b/engines/scumm/debugger.cpp
@@ -641,7 +641,7 @@ static void hlineColor(ScummEngine *scumm, int x1, int x2, int y, byte color) {
x2 = right - 1;
- ptr = (byte *)vs->pixels + x1 + y * vs->pitch;
+ ptr = (byte *)vs->getBasePtr(x1, y);
while (x1++ <= x2) {
*ptr++ = color;
diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp
index 50ff0b3988..4c1fdaf673 100644
--- a/engines/scumm/gfx.cpp
+++ b/engines/scumm/gfx.cpp
@@ -421,8 +421,8 @@ void ScummEngine::initVirtScreen(VirtScreenNumber slot, int top, int width, int
}
_res->createResource(rtBuffer, slot + 1, size);
- vs->pixels = getResourceAddress(rtBuffer, slot + 1);
- memset(vs->pixels, 0, size); // reset background
+ vs->setPixels(getResourceAddress(rtBuffer, slot + 1));
+ memset(vs->getBasePtr(0, 0), 0, size); // reset background
if (twobufs) {
vs->backBuf = _res->createResource(rtBuffer, slot + 5, size);
@@ -612,7 +612,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i
// Some paranoia checks
assert(top >= 0 && bottom <= vs->h);
assert(x >= 0 && width <= vs->pitch);
- assert(_textSurface.pixels);
+ assert(_textSurface.getPixels());
// Perform some clipping
if (width > vs->w - x)
@@ -1135,7 +1135,7 @@ void ScummEngine::clearTextSurface() {
_townsScreen->fillLayerRect(1, 0, 0, _textSurface.w, _textSurface.h, 0);
#endif
- fill((byte *)_textSurface.pixels, _textSurface.pitch,
+ fill((byte *)_textSurface.getPixels(), _textSurface.pitch,
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
_game.platform == Common::kPlatformFMTowns ? 0 :
#endif
@@ -1590,7 +1590,7 @@ void GdiV2::prepareDrawBitmap(const byte *ptr, VirtScreen *vs,
if (vs->hasTwoBuffers)
dst = vs->backBuf + y * vs->pitch + x * 8;
else
- dst = (byte *)vs->pixels + y * vs->pitch + x * 8;
+ dst = (byte *)vs->getBasePtr(x * 8, y);
mask_ptr = getMaskBuffer(x, y, 1);
@@ -1827,7 +1827,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const
if (vs->hasTwoBuffers)
dstPtr = vs->backBuf + y * vs->pitch + (x * 8 * vs->format.bytesPerPixel);
else
- dstPtr = (byte *)vs->pixels + y * vs->pitch + (x * 8 * vs->format.bytesPerPixel);
+ dstPtr = (byte *)vs->getBasePtr(x * 8, y);
transpStrip = drawStrip(dstPtr, vs, x, y, width, height, stripnr, smap_ptr);
@@ -1836,7 +1836,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const
transpStrip = true;
if (vs->hasTwoBuffers) {
- byte *frontBuf = (byte *)vs->pixels + y * vs->pitch + (x * 8 * vs->format.bytesPerPixel);
+ byte *frontBuf = (byte *)vs->getBasePtr(x * 8, y);
if (lightsOn)
copy8Col(frontBuf, vs->pitch, dstPtr, height, vs->format.bytesPerPixel);
else
@@ -2262,7 +2262,7 @@ void Gdi::resetBackground(int top, int bottom, int strip) {
vs->bdirty[strip] = bottom;
bgbak_ptr = (byte *)vs->backBuf + top * vs->pitch + (strip + vs->xstart/8) * 8 * vs->format.bytesPerPixel;
- backbuff_ptr = (byte *)vs->pixels + top * vs->pitch + (strip + vs->xstart/8) * 8 * vs->format.bytesPerPixel;
+ backbuff_ptr = (byte *)vs->getBasePtr((strip + vs->xstart/8) * 8, top);
numLinesToProcess = bottom - top;
if (numLinesToProcess) {
diff --git a/engines/scumm/gfx_towns.cpp b/engines/scumm/gfx_towns.cpp
index f86a4e56d5..0aed181afd 100644
--- a/engines/scumm/gfx_towns.cpp
+++ b/engines/scumm/gfx_towns.cpp
@@ -34,7 +34,7 @@ void ScummEngine::towns_drawStripToScreen(VirtScreen *vs, int dstX, int dstY, in
if (width <= 0 || height <= 0)
return;
- assert(_textSurface.pixels);
+ assert(_textSurface.getPixels());
int m = _textSurfaceMultiplier;
diff --git a/engines/scumm/he/animation_he.cpp b/engines/scumm/he/animation_he.cpp
index be17a3b305..d01b456c8b 100644
--- a/engines/scumm/he/animation_he.cpp
+++ b/engines/scumm/he/animation_he.cpp
@@ -90,7 +90,7 @@ void MoviePlayer::copyFrameToBuffer(byte *dst, int dstType, uint x, uint y, uint
if (!surface)
return;
- byte *src = (byte *)surface->pixels;
+ const byte *src = (const byte *)surface->getPixels();
if (_video->hasDirtyPalette())
_vm->setPaletteFromPtr(_video->getPalette(), 256);
@@ -119,7 +119,7 @@ void MoviePlayer::copyFrameToBuffer(byte *dst, int dstType, uint x, uint y, uint
dst += y * pitch + x * 2;
do {
for (uint i = 0; i < w; i++) {
- uint16 color = *((uint16 *)src + i);
+ uint16 color = *((const uint16 *)src + i);
switch (dstType) {
case kDstScreen:
WRITE_UINT16(dst + i * 2, color);
diff --git a/engines/scumm/he/script_v80he.cpp b/engines/scumm/he/script_v80he.cpp
index eb62b650a4..ae43d714ad 100644
--- a/engines/scumm/he/script_v80he.cpp
+++ b/engines/scumm/he/script_v80he.cpp
@@ -23,7 +23,7 @@
#ifdef ENABLE_HE
#include "common/archive.h"
-#include "common/config-file.h"
+#include "common/ini-file.h"
#include "common/config-manager.h"
#include "common/macresman.h"
#include "common/savefile.h"
@@ -180,7 +180,7 @@ void ScummEngine_v80he::o80_readConfigFile() {
}
} else {
// Normal Windows INI files
- Common::ConfigFile confFile;
+ Common::INIFile confFile;
if (!strcmp((char *)filename + r, "map.ini"))
confFile.loadFromFile((const char *)filename + r);
else
@@ -250,7 +250,7 @@ void ScummEngine_v80he::o80_writeConfigFile() {
memcpy(section, "BluesTreasureHunt-Disc2\0", 24);
}
- Common::ConfigFile ConfFile;
+ Common::INIFile ConfFile;
ConfFile.loadFromSaveFile((const char *)filename + r);
ConfFile.setKey((char *)option, (char *)section, (char *)string);
ConfFile.saveToSaveFile((const char *)filename + r);
diff --git a/engines/scumm/nut_renderer.cpp b/engines/scumm/nut_renderer.cpp
index 048b29d68b..d9f0b412e1 100644
--- a/engines/scumm/nut_renderer.cpp
+++ b/engines/scumm/nut_renderer.cpp
@@ -357,7 +357,10 @@ void NutRenderer::drawFrame(byte *dst, int c, int x, int y) {
}
void NutRenderer::drawChar(const Graphics::Surface &s, byte c, int x, int y, byte color) {
- byte *dst = (byte *)s.pixels + y * s.pitch + x;
+ // FIXME: This gets passed a const destination Surface. Intuitively this
+ // should never get written to. But sadly it does... For now we simply
+ // cast the const qualifier away.
+ byte *dst = (byte *)const_cast<void *>(s.getBasePtr(x, y));
const int width = MIN((int)_chars[c].width, s.w - x);
const int height = MIN((int)_chars[c].height, s.h - y);
const byte *src = unpackChar(c);
@@ -391,7 +394,10 @@ void NutRenderer::drawChar(const Graphics::Surface &s, byte c, int x, int y, byt
}
void NutRenderer::draw2byte(const Graphics::Surface &s, int c, int x, int y, byte color) {
- byte *dst = (byte *)s.pixels + y * s.pitch + x;
+ // FIXME: This gets passed a const destination Surface. Intuitively this
+ // should never get written to. But sadly it does... For now we simply
+ // cast the const qualifier away.
+ byte *dst = (byte *)const_cast<void *>(s.getBasePtr(x, y));
const int width = _vm->_2byteWidth;
const int height = MIN(_vm->_2byteHeight, s.h - y);
const byte *src = _vm->get2byteCharPtr(c);
diff --git a/engines/scumm/object.cpp b/engines/scumm/object.cpp
index ed77a863cd..d266183f85 100644
--- a/engines/scumm/object.cpp
+++ b/engines/scumm/object.cpp
@@ -1715,7 +1715,7 @@ void ScummEngine_v6::drawBlastObject(BlastObject *eo) {
error("object %d is not a blast object", eo->number);
bdd.dst = *vs;
- bdd.dst.pixels = vs->getPixels(0, 0);
+ bdd.dst.setPixels(vs->getPixels(0, 0));
bdd.x = eo->rect.left;
bdd.y = eo->rect.top;
diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp
index 79ec060bc1..742aac1a53 100644
--- a/engines/sword1/animation.cpp
+++ b/engines/sword1/animation.cpp
@@ -314,7 +314,7 @@ bool MoviePlayer::playVideo() {
if (_decoderType == kVideoDecoderPSX)
drawFramePSX(frame);
else
- _vm->_system->copyRectToScreen(frame->pixels, frame->pitch, x, y, frame->w, frame->h);
+ _vm->_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
}
if (_decoder->hasDirtyPalette()) {
@@ -407,7 +407,7 @@ bool MoviePlayer::playVideo() {
}
Graphics::Surface *screen = _vm->_system->lockScreen();
- performPostProcessing((byte *)screen->pixels);
+ performPostProcessing((byte *)screen->getPixels());
_vm->_system->unlockScreen();
_vm->_system->updateScreen();
}
@@ -498,7 +498,7 @@ void MoviePlayer::drawFramePSX(const Graphics::Surface *frame) {
uint16 x = (g_system->getWidth() - scaledFrame.w) / 2;
uint16 y = (g_system->getHeight() - scaledFrame.h) / 2;
- _vm->_system->copyRectToScreen(scaledFrame.pixels, scaledFrame.pitch, x, y, scaledFrame.w, scaledFrame.h);
+ _vm->_system->copyRectToScreen(scaledFrame.getPixels(), scaledFrame.pitch, x, y, scaledFrame.w, scaledFrame.h);
scaledFrame.free();
}
diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp
index 713120ad43..92fa9d0e44 100644
--- a/engines/sword2/animation.cpp
+++ b/engines/sword2/animation.cpp
@@ -334,7 +334,7 @@ bool MoviePlayer::playVideo() {
if (_decoderType == kVideoDecoderPSX)
drawFramePSX(frame);
else
- _vm->_system->copyRectToScreen(frame->pixels, frame->pitch, x, y, frame->w, frame->h);
+ _vm->_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
}
if (_decoder->hasDirtyPalette()) {
@@ -403,7 +403,7 @@ void MoviePlayer::drawFramePSX(const Graphics::Surface *frame) {
uint16 x = (g_system->getWidth() - scaledFrame.w) / 2;
uint16 y = (g_system->getHeight() - scaledFrame.h) / 2;
- _vm->_system->copyRectToScreen(scaledFrame.pixels, scaledFrame.pitch, x, y, scaledFrame.w, scaledFrame.h);
+ _vm->_system->copyRectToScreen(scaledFrame.getPixels(), scaledFrame.pitch, x, y, scaledFrame.w, scaledFrame.h);
scaledFrame.free();
}
diff --git a/engines/sword25/fmv/movieplayer.cpp b/engines/sword25/fmv/movieplayer.cpp
index a95532ec65..3cdce1b493 100644
--- a/engines/sword25/fmv/movieplayer.cpp
+++ b/engines/sword25/fmv/movieplayer.cpp
@@ -130,10 +130,10 @@ void MoviePlayer::update() {
assert(s->format.bytesPerPixel == 4);
#ifdef THEORA_INDIRECT_RENDERING
- const byte *frameData = (const byte *)s->getBasePtr(0, 0);
+ const byte *frameData = (const byte *)s->getPixels();
_outputBitmap->setContent(frameData, s->pitch * s->h, 0, s->pitch);
#else
- g_system->copyRectToScreen(s->getBasePtr(0, 0), s->pitch, _outX, _outY, MIN(s->w, _backSurface->w), MIN(s->h, _backSurface->h));
+ g_system->copyRectToScreen(s->getPixels(), s->pitch, _outX, _outY, MIN(s->w, _backSurface->w), MIN(s->h, _backSurface->h));
g_system->updateScreen();
#endif
}
diff --git a/engines/sword25/gfx/image/imgloader.cpp b/engines/sword25/gfx/image/imgloader.cpp
index e103626416..9006a596b4 100644
--- a/engines/sword25/gfx/image/imgloader.cpp
+++ b/engines/sword25/gfx/image/imgloader.cpp
@@ -50,7 +50,7 @@ bool ImgLoader::decodePNGImage(const byte *fileDataPtr, uint fileSize, byte *&un
width = pngSurface->w;
height = pngSurface->h;
uncompressedDataPtr = new byte[pngSurface->pitch * pngSurface->h];
- memcpy(uncompressedDataPtr, (byte *)pngSurface->pixels, pngSurface->pitch * pngSurface->h);
+ memcpy(uncompressedDataPtr, (byte *)pngSurface->getPixels(), pngSurface->pitch * pngSurface->h);
pngSurface->free();
delete pngSurface;
diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp
index 9b8cf2266d..346b46f3b4 100644
--- a/engines/sword25/gfx/image/renderedimage.cpp
+++ b/engines/sword25/gfx/image/renderedimage.cpp
@@ -251,14 +251,10 @@ bool RenderedImage::blit(int posX, int posY, int flipping, Common::Rect *pPartRe
// Create an encapsulating surface for the data
Graphics::Surface srcImage;
// TODO: Is the data really in the screen format?
- srcImage.format = g_system->getScreenFormat();
- srcImage.pitch = _width * 4;
- srcImage.w = _width;
- srcImage.h = _height;
- srcImage.pixels = _data;
+ srcImage.init(_width, _height, _width * 4, _data, g_system->getScreenFormat());
if (pPartRect) {
- srcImage.pixels = &_data[pPartRect->top * srcImage.pitch + pPartRect->left * 4];
+ srcImage.setPixels(&_data[pPartRect->top * srcImage.pitch + pPartRect->left * 4]);
srcImage.w = pPartRect->right - pPartRect->left;
srcImage.h = pPartRect->bottom - pPartRect->top;
@@ -287,7 +283,7 @@ bool RenderedImage::blit(int posX, int posY, int flipping, Common::Rect *pPartRe
if ((width != srcImage.w) || (height != srcImage.h)) {
// Scale the image
img = imgScaled = scale(srcImage, width, height);
- savedPixels = (byte *)img->pixels;
+ savedPixels = (byte *)img->getPixels();
} else {
img = &srcImage;
}
@@ -464,7 +460,7 @@ bool RenderedImage::blit(int posX, int posY, int flipping, Common::Rect *pPartRe
}
if (imgScaled) {
- imgScaled->pixels = savedPixels;
+ imgScaled->setPixels(savedPixels);
imgScaled->free();
delete imgScaled;
}
diff --git a/engines/sword25/gfx/screenshot.cpp b/engines/sword25/gfx/screenshot.cpp
index 0ea4bff906..7b56a6e9f3 100644
--- a/engines/sword25/gfx/screenshot.cpp
+++ b/engines/sword25/gfx/screenshot.cpp
@@ -40,7 +40,7 @@ namespace Sword25 {
bool Screenshot::saveToFile(Graphics::Surface *data, Common::WriteStream *stream) {
// Convert the RGBA data to RGB
- const byte *pSrc = (const byte *)data->getBasePtr(0, 0);
+ const byte *pSrc = (const byte *)data->getPixels();
// Write our own custom header
stream->writeUint32BE(MKTAG('S','C','R','N')); // SCRN, short for "Screenshot"
@@ -85,7 +85,7 @@ Common::SeekableReadStream *Screenshot::createThumbnail(Graphics::Surface *data)
uint x, y;
x = y = 0;
- for (byte *pDest = (byte *)thumbnail.pixels; pDest < ((byte *)thumbnail.pixels + thumbnail.pitch * thumbnail.h); ) {
+ for (byte *pDest = (byte *)thumbnail.getPixels(); pDest < ((byte *)thumbnail.getBasePtr(0, thumbnail.h)); ) {
// Get an average over a 4x4 pixel block in the source image
int alpha, red, green, blue;
alpha = red = green = blue = 0;
diff --git a/engines/teenagent/font.cpp b/engines/teenagent/font.cpp
index 47f52ff90f..9d85328f20 100644
--- a/engines/teenagent/font.cpp
+++ b/engines/teenagent/font.cpp
@@ -65,7 +65,7 @@ uint Font::render(Graphics::Surface *surface, int x, int y, char c, byte color)
byte *glyph = _data + READ_LE_UINT16(_data + idx * 2);
int h = glyph[0], w = glyph[1];
- if (surface == NULL || surface->pixels == NULL || y + h <= 0 || y >= kScreenHeight || x + w <= 0 || x >= kScreenWidth)
+ if (surface == NULL || surface->getPixels() == NULL || y + h <= 0 || y >= kScreenHeight || x + w <= 0 || x >= kScreenWidth)
return w - _widthPack;
int i0 = 0, j0 = 0;
diff --git a/engines/teenagent/resources.cpp b/engines/teenagent/resources.cpp
index 399baf469f..cdbdcf9655 100644
--- a/engines/teenagent/resources.cpp
+++ b/engines/teenagent/resources.cpp
@@ -160,7 +160,7 @@ void Resources::loadOff(Graphics::Surface &surface, byte *palette, int id) {
off.read(id, buf, bufferSize);
byte *src = buf;
- byte *dst = (byte *)surface.pixels;
+ byte *dst = (byte *)surface.getPixels();
memcpy(dst, src, 64000);
memcpy(palette, buf + 64000, 768);
diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp
index bdeb11a841..f36a60932c 100644
--- a/engines/teenagent/scene.cpp
+++ b/engines/teenagent/scene.cpp
@@ -48,7 +48,6 @@ Scene::Scene(TeenAgentEngine *vm) : _vm(vm), intro(false), _id(0), ons(0),
onEnabled = true;
memset(palette, 0, sizeof(palette));
- background.pixels = 0;
FilePack varia;
varia.open("varia.res");
@@ -74,8 +73,7 @@ Scene::Scene(TeenAgentEngine *vm) : _vm(vm), intro(false), _id(0), ons(0),
}
Scene::~Scene() {
- if (background.pixels)
- background.free();
+ background.free();
delete[] ons;
ons = 0;
@@ -372,7 +370,7 @@ void Scene::init(int id, const Common::Point &pos) {
for (byte i = 0; i < 4; ++i)
customAnimation[i].free();
- if (background.pixels == NULL)
+ if (background.getPixels() == NULL)
background.create(kScreenWidth, kScreenHeight, Graphics::PixelFormat::createFormatCLUT8());
warp(pos);
@@ -416,7 +414,7 @@ void Scene::init(int id, const Common::Point &pos) {
if (nowPlaying != _vm->res->dseg.get_byte(dsAddr_currentMusic))
_vm->music->load(_vm->res->dseg.get_byte(dsAddr_currentMusic));
- _vm->_system->copyRectToScreen(background.pixels, background.pitch, 0, 0, background.w, background.h);
+ _vm->_system->copyRectToScreen(background.getPixels(), background.pitch, 0, 0, background.w, background.h);
setPalette(0);
}
@@ -642,8 +640,8 @@ bool Scene::render(bool tickGame, bool tickMark, uint32 messageDelta) {
return true;
}
- if (background.pixels && debugFeatures.feature[DebugFeatures::kShowBack]) {
- _vm->_system->copyRectToScreen(background.pixels, background.pitch, 0, 0, background.w, background.h);
+ if (background.getPixels() && debugFeatures.feature[DebugFeatures::kShowBack]) {
+ _vm->_system->copyRectToScreen(background.getPixels(), background.pitch, 0, 0, background.w, background.h);
} else
_vm->_system->fillScreen(0);
diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp
index 0b48a18b26..e73f1100d6 100644
--- a/engines/teenagent/teenagent.cpp
+++ b/engines/teenagent/teenagent.cpp
@@ -399,7 +399,7 @@ bool TeenAgentEngine::showLogo() {
return true;
}
- _system->copyRectToScreen(s.pixels, s.w, s.x, s.y, s.w, s.h);
+ _system->copyRectToScreen(s.getPixels(), s.w, s.x, s.y, s.w, s.h);
_system->updateScreen();
_system->delayMillis(100);
diff --git a/engines/testbed/config.cpp b/engines/testbed/config.cpp
index 6b56616c9b..a40d239ebf 100644
--- a/engines/testbed/config.cpp
+++ b/engines/testbed/config.cpp
@@ -213,22 +213,22 @@ void TestbedConfigManager::parseConfigFile() {
return;
}
_configFileInterface.loadFromStream(*rs);
- Common::ConfigFile::SectionList sections = _configFileInterface.getSections();
+ Common::INIFile::SectionList sections = _configFileInterface.getSections();
Testsuite *currTS = 0;
- for (Common::ConfigFile::SectionList::const_iterator i = sections.begin(); i != sections.end(); i++) {
+ for (Common::INIFile::SectionList::const_iterator i = sections.begin(); i != sections.end(); i++) {
if (i->name.equalsIgnoreCase("Global")) {
// Global params may be directly queried, ignore them
} else {
// A testsuite, process it.
currTS = getTestsuiteByName(i->name);
- Common::ConfigFile::SectionKeyList kList = i->getKeys();
+ Common::INIFile::SectionKeyList kList = i->getKeys();
if (!currTS) {
Testsuite::logPrintf("Warning! Error in config: Testsuite %s not found\n", i->name.c_str());
continue;
}
- for (Common::ConfigFile::SectionKeyList::const_iterator j = kList.begin(); j != kList.end(); j++) {
+ for (Common::INIFile::SectionKeyList::const_iterator j = kList.begin(); j != kList.end(); j++) {
if (j->key.equalsIgnoreCase("this")) {
currTS->enable(stringToBool(j->value));
} else {
diff --git a/engines/testbed/config.h b/engines/testbed/config.h
index fd5588aa31..d611ae4ec3 100644
--- a/engines/testbed/config.h
+++ b/engines/testbed/config.h
@@ -24,7 +24,7 @@
#include "common/array.h"
-#include "common/config-file.h"
+#include "common/ini-file.h"
#include "common/str-array.h"
#include "common/tokenizer.h"
@@ -62,7 +62,7 @@ public:
private:
Common::Array<Testsuite *> &_testsuiteList;
Common::String _configFileName;
- Common::ConfigFile _configFileInterface;
+ Common::INIFile _configFileInterface;
void parseConfigFile();
};
diff --git a/engines/tinsel/bmv.cpp b/engines/tinsel/bmv.cpp
index 106e1542d5..fa66b7ad8e 100644
--- a/engines/tinsel/bmv.cpp
+++ b/engines/tinsel/bmv.cpp
@@ -1031,7 +1031,7 @@ void BMVPlayer::CopyMovieToScreen() {
// The movie surface is slightly less high than the output screen (429 rows versus 432).
// Because of this, there's some extra line clearing above and below the displayed area
int yStart = (SCREEN_HEIGHT - SCREEN_HIGH) / 2;
- memset(_vm->screen().getBasePtr(0, 0), 0, yStart * SCREEN_WIDTH);
+ memset(_vm->screen().getPixels(), 0, yStart * SCREEN_WIDTH);
memcpy(_vm->screen().getBasePtr(0, yStart), ScreenBeg, SCREEN_WIDTH * SCREEN_HIGH);
memset(_vm->screen().getBasePtr(0, yStart + SCREEN_HIGH), 0,
(SCREEN_HEIGHT - SCREEN_HIGH - yStart) * SCREEN_WIDTH);
diff --git a/engines/tinsel/graphics.cpp b/engines/tinsel/graphics.cpp
index 5dae984def..c4f341f6fe 100644
--- a/engines/tinsel/graphics.cpp
+++ b/engines/tinsel/graphics.cpp
@@ -798,7 +798,7 @@ static void PackedWrtNonZero(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP,
*/
void ClearScreen() {
byte blackColorIndex = (!TinselV1Mac) ? 0 : 255;
- void *pDest = _vm->screen().getBasePtr(0, 0);
+ void *pDest = _vm->screen().getPixels();
memset(pDest, blackColorIndex, SCREEN_WIDTH * SCREEN_HEIGHT);
g_system->fillScreen(blackColorIndex);
g_system->updateScreen();
diff --git a/engines/toltecs/menu.cpp b/engines/toltecs/menu.cpp
index b52d7dad82..0850630c43 100644
--- a/engines/toltecs/menu.cpp
+++ b/engines/toltecs/menu.cpp
@@ -69,7 +69,7 @@ int MenuSystem::run(MenuID menuId) {
_vm->_screen->blastSprite(0x140 + _vm->_cameraX, 0x175 + _vm->_cameraY, 0, 1, 0x4000);
shadeRect(60, 39, 520, 247, 225, 229);
- memcpy(_background->pixels, _vm->_screen->_frontScreen, 640 * 400);
+ memcpy(_background->getPixels(), _vm->_screen->_frontScreen, 640 * 400);
while (_running) {
update();
@@ -229,7 +229,7 @@ void MenuSystem::initMenu(MenuID menuID) {
_items.clear();
- memcpy(_vm->_screen->_frontScreen, _background->pixels, 640 * 400);
+ memcpy(_vm->_screen->_frontScreen, _background->getPixels(), 640 * 400);
switch (menuID) {
case kMenuIdMain:
diff --git a/engines/toltecs/screen.cpp b/engines/toltecs/screen.cpp
index 5e12773e1b..1eb2f41fd2 100644
--- a/engines/toltecs/screen.cpp
+++ b/engines/toltecs/screen.cpp
@@ -651,7 +651,7 @@ void Screen::drawSurface(int16 x, int16 y, Graphics::Surface *surface) {
int16 skipX = 0;
int16 width = surface->w;
int16 height = surface->h;
- byte *surfacePixels = (byte *)surface->getBasePtr(0, 0);
+ byte *surfacePixels = (byte *)surface->getPixels();
byte *frontScreen;
// Not on screen, skip
diff --git a/engines/toltecs/segmap.cpp b/engines/toltecs/segmap.cpp
index b06c0af675..fea40f3277 100644
--- a/engines/toltecs/segmap.cpp
+++ b/engines/toltecs/segmap.cpp
@@ -373,7 +373,7 @@ void SegmentMap::loadSegmapMaskRectSurface(byte *maskData, SegmapMaskRect &maskR
maskRect.surface->create(maskRect.width, maskRect.height, Graphics::PixelFormat::createFormatCLUT8());
byte *backScreen = _vm->_screen->_backScreen + maskRect.x + (maskRect.y * _vm->_sceneWidth);
- byte *dest = (byte *)maskRect.surface->getBasePtr(0, 0);
+ byte *dest = (byte *)maskRect.surface->getPixels();
for (int16 h = 0; h < maskRect.height; h++) {
int16 w = maskRect.width;
diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp
index 2a443c4097..d355450153 100644
--- a/engines/tony/detection.cpp
+++ b/engines/tony/detection.cpp
@@ -158,9 +158,9 @@ SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int s
Graphics::Surface *to = new Graphics::Surface();
to->create(160, 120, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0));
- if (Tony::RMOptionScreen::loadThumbnailFromSaveState(slot, (byte *)to->pixels, saveName, difficulty)) {
+ if (Tony::RMOptionScreen::loadThumbnailFromSaveState(slot, (byte *)to->getPixels(), saveName, difficulty)) {
#ifdef SCUMM_BIG_ENDIAN
- uint16 *pixels = (uint16 *)to->pixels;
+ uint16 *pixels = (uint16 *)to->getPixels();
for (int i = 0; i < to->w * to->h; ++i)
pixels[i] = READ_LE_UINT16(pixels + i);
#endif
diff --git a/engines/toon/anim.cpp b/engines/toon/anim.cpp
index a6744568f7..78d3954325 100644
--- a/engines/toon/anim.cpp
+++ b/engines/toon/anim.cpp
@@ -190,7 +190,7 @@ void Animation::drawFrame(Graphics::Surface &surface, int32 frame, int16 xx, int
int32 destPitch = surface.pitch;
uint8 *srcRow = _frames[frame]._data + offsX + (_frames[frame]._x2 - _frames[frame]._x1) * offsY;
- uint8 *curRow = (uint8 *)surface.pixels + (yy + _frames[frame]._y1 + _y1 + offsY) * destPitch + (xx + _x1 + _frames[frame]._x1 + offsX);
+ uint8 *curRow = (uint8 *)surface.getBasePtr(xx + _x1 + _frames[frame]._x1 + offsX, yy + _frames[frame]._y1 + _y1 + offsY);
for (int16 y = 0; y < rectY; y++) {
uint8 *cur = curRow;
uint8 *c = srcRow + y * (_frames[frame]._x2 - _frames[frame]._x1);
@@ -231,7 +231,7 @@ void Animation::drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 fram
int32 destPitch = surface.pitch;
int32 destPitchMask = mask->getWidth();
uint8 *c = _frames[frame]._data;
- uint8 *curRow = (uint8 *)surface.pixels;
+ uint8 *curRow = (uint8 *)surface.getPixels();
uint8 *curRowMask = mask->getDataPtr();
bool shadowFlag = false;
@@ -341,7 +341,7 @@ void Animation::drawFontFrame(Graphics::Surface &surface, int32 frame, int16 xx,
int32 destPitch = surface.pitch;
uint8 *c = _frames[frame]._data;
- uint8 *curRow = (uint8 *)surface.pixels + (yy + _frames[frame]._y1 + _y1) * destPitch + (xx + _x1 + _frames[frame]._x1);
+ uint8 *curRow = (uint8 *)surface.getBasePtr(xx + _x1 + _frames[frame]._x1, yy + _frames[frame]._y1 + _y1);
for (int16 y = 0; y < rectY; y++) {
unsigned char *cur = curRow;
for (int16 x = 0; x < rectX; x++) {
diff --git a/engines/toon/movie.cpp b/engines/toon/movie.cpp
index 8c85e20f7c..f0463a52e1 100644
--- a/engines/toon/movie.cpp
+++ b/engines/toon/movie.cpp
@@ -112,7 +112,7 @@ bool Movie::playVideo(bool isFirstIntroVideo) {
}
_vm->_system->unlockScreen();
} else {
- _vm->_system->copyRectToScreen(frame->pixels, frame->pitch, 0, 0, frame->w, frame->h);
+ _vm->_system->copyRectToScreen(frame->getPixels(), frame->pitch, 0, 0, frame->w, frame->h);
// WORKAROUND: There is an encoding glitch in the first intro video. This hides this using the adjacent pixels.
if (isFirstIntroVideo) {
diff --git a/engines/toon/picture.cpp b/engines/toon/picture.cpp
index f59cdca064..65cc3a70e1 100644
--- a/engines/toon/picture.cpp
+++ b/engines/toon/picture.cpp
@@ -170,7 +170,7 @@ void Picture::drawMask(Graphics::Surface &surface, int16 x, int16 y, int16 dx, i
int32 destPitch = surface.pitch;
int32 srcPitch = _width;
uint8 *c = _data + _width * dy + dx;
- uint8 *curRow = (uint8 *)surface.pixels + y * destPitch + x;
+ uint8 *curRow = (uint8 *)surface.getBasePtr(x, y);
for (int16 yy = 0; yy < ry; yy++) {
uint8 *curSrc = c;
@@ -205,7 +205,7 @@ void Picture::drawWithRectList(Graphics::Surface& surface, int16 x, int16 y, int
int16 fillRy = MIN<int32>(ry, rect.bottom - rect.top);
uint8 *c = _data + _width * (dy + rect.top) + (dx + rect.left);
- uint8 *curRow = (uint8 *)surface.pixels + (y + rect.top) * destPitch + (x + rect.left);
+ uint8 *curRow = (uint8 *)surface.getBasePtr(x + rect.left, y + rect.top);
for (int16 yy = 0; yy < fillRy; yy++) {
uint8 *curSrc = c;
@@ -233,7 +233,7 @@ void Picture::draw(Graphics::Surface &surface, int16 x, int16 y, int16 dx, int16
int32 destPitch = surface.pitch;
int32 srcPitch = _width;
uint8 *c = _data + _width * dy + dx;
- uint8 *curRow = (uint8 *)surface.pixels + y * destPitch + x;
+ uint8 *curRow = (uint8 *)surface.getBasePtr(x, y);
for (int16 yy = 0; yy < ry; yy++) {
uint8 *curSrc = c;
diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp
index 7ad29ab8d8..286bcf1941 100644
--- a/engines/toon/toon.cpp
+++ b/engines/toon/toon.cpp
@@ -466,8 +466,7 @@ void ToonEngine::doMagnifierEffect() {
int32 cy = CLIP<int32>(posY + y, 0, TOON_BACKBUFFER_HEIGHT-1);
for (int32 x = -12; x <= 12; x++) {
int32 cx = CLIP<int32>(posX + x, 0, TOON_BACKBUFFER_WIDTH-1);
- int32 destPitch = surface.pitch;
- uint8 *curRow = (uint8 *)surface.pixels + cy * destPitch + cx;
+ uint8 *curRow = (uint8 *)surface.getBasePtr(cx, cy);
tempBuffer[(y + 12) * 25 + x + 12] = *curRow;
}
}
@@ -479,8 +478,7 @@ void ToonEngine::doMagnifierEffect() {
if (dist > 144)
continue;
int32 cx = CLIP<int32>(posX + x, 0, TOON_BACKBUFFER_WIDTH-1);
- int32 destPitch = surface.pitch;
- uint8 *curRow = (uint8 *)surface.pixels + cy * destPitch + cx;
+ uint8 *curRow = (uint8 *)surface.getBasePtr(cx, cy);
int32 lerp = (512 + intSqrt[dist] * 256 / 12);
*curRow = tempBuffer[(y * lerp / 1024 + 12) * 25 + x * lerp / 1024 + 12];
}
@@ -501,7 +499,7 @@ void ToonEngine::copyToVirtualScreen(bool updateScreen) {
if (_dirtyAll || _gameState->_currentScrollValue != lastScroll) {
// we have to refresh everything in case of scrolling.
- _system->copyRectToScreen((byte *)_mainSurface->pixels + state()->_currentScrollValue, TOON_BACKBUFFER_WIDTH, 0, 0, TOON_SCREEN_WIDTH, TOON_SCREEN_HEIGHT);
+ _system->copyRectToScreen((byte *)_mainSurface->getPixels() + state()->_currentScrollValue, TOON_BACKBUFFER_WIDTH, 0, 0, TOON_SCREEN_WIDTH, TOON_SCREEN_HEIGHT);
} else {
int32 offX = 0;
@@ -517,7 +515,7 @@ void ToonEngine::copyToVirtualScreen(bool updateScreen) {
}
rect.clip(TOON_SCREEN_WIDTH, TOON_SCREEN_HEIGHT);
if (rect.left >= 0 && rect.top >= 0 && rect.right - rect.left > 0 && rect.bottom - rect.top > 0) {
- _system->copyRectToScreen((byte *)_mainSurface->pixels + _oldDirtyRects[i].left + offX + _oldDirtyRects[i].top * TOON_BACKBUFFER_WIDTH, TOON_BACKBUFFER_WIDTH, rect.left , rect.top, rect.right - rect.left, rect.bottom - rect.top);
+ _system->copyRectToScreen((byte *)_mainSurface->getBasePtr(_oldDirtyRects[i].left + offX, _oldDirtyRects[i].top), TOON_BACKBUFFER_WIDTH, rect.left , rect.top, rect.right - rect.left, rect.bottom - rect.top);
}
}
@@ -533,7 +531,7 @@ void ToonEngine::copyToVirtualScreen(bool updateScreen) {
}
rect.clip(TOON_SCREEN_WIDTH, TOON_SCREEN_HEIGHT);
if (rect.left >= 0 && rect.top >= 0 && rect.right - rect.left > 0 && rect.bottom - rect.top > 0) {
- _system->copyRectToScreen((byte *)_mainSurface->pixels + _dirtyRects[i].left + offX + _dirtyRects[i].top * TOON_BACKBUFFER_WIDTH, TOON_BACKBUFFER_WIDTH, rect.left , rect.top, rect.right - rect.left, rect.bottom - rect.top);
+ _system->copyRectToScreen((byte *)_mainSurface->getBasePtr(_dirtyRects[i].left + offX, _dirtyRects[i].top), TOON_BACKBUFFER_WIDTH, rect.left , rect.top, rect.right - rect.left, rect.bottom - rect.top);
}
}
}
diff --git a/engines/tsage/events.cpp b/engines/tsage/events.cpp
index 8f07a8243b..5ca531fdb9 100644
--- a/engines/tsage/events.cpp
+++ b/engines/tsage/events.cpp
@@ -277,7 +277,7 @@ void EventsClass::setCursor(CursorType cursorType) {
GfxSurface s = surfaceFromRes(cursor);
Graphics::Surface surface = s.lockSurface();
- const byte *cursorData = (const byte *)surface.getBasePtr(0, 0);
+ const byte *cursorData = (const byte *)surface.getPixels();
CursorMan.replaceCursor(cursorData, surface.w, surface.h, s._centroid.x, s._centroid.y, s._transColor);
s.unlockSurface();
@@ -333,7 +333,7 @@ void EventsClass::pushCursor(CursorType cursorType) {
GfxSurface s = surfaceFromRes(cursor);
Graphics::Surface surface = s.lockSurface();
- const byte *cursorData = (const byte *)surface.getBasePtr(0, 0);
+ const byte *cursorData = (const byte *)surface.getPixels();
CursorMan.pushCursor(cursorData, surface.w, surface.h, s._centroid.x, s._centroid.y, s._transColor);
s.unlockSurface();
@@ -346,7 +346,7 @@ void EventsClass::popCursor() {
}
void EventsClass::setCursor(Graphics::Surface &cursor, int transColor, const Common::Point &hotspot, CursorType cursorId) {
- const byte *cursorData = (const byte *)cursor.getBasePtr(0, 0);
+ const byte *cursorData = (const byte *)cursor.getPixels();
CursorMan.replaceCursor(cursorData, cursor.w, cursor.h, hotspot.x, hotspot.y, transColor);
_currentCursor = cursorId;
@@ -355,7 +355,7 @@ void EventsClass::setCursor(Graphics::Surface &cursor, int transColor, const Com
void EventsClass::setCursor(GfxSurface &cursor) {
Graphics::Surface s = cursor.lockSurface();
- const byte *cursorData = (const byte *)s.getBasePtr(0, 0);
+ const byte *cursorData = (const byte *)s.getPixels();
CursorMan.replaceCursor(cursorData, cursor.getBounds().width(), cursor.getBounds().height(),
cursor._centroid.x, cursor._centroid.y, cursor._transColor);
diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp
index ce19502524..1815c3d751 100644
--- a/engines/tsage/graphics.cpp
+++ b/engines/tsage/graphics.cpp
@@ -47,7 +47,7 @@ GfxSurface *surfaceGetArea(GfxSurface &src, const Rect &bounds) {
Graphics::Surface destSurface = dest->lockSurface();
byte *srcP = (byte *)srcSurface.getBasePtr(bounds.left, bounds.top);
- byte *destP = (byte *)destSurface.getBasePtr(0, 0);
+ byte *destP = (byte *)destSurface.getPixels();
for (int y = bounds.top; y < bounds.bottom; ++y, srcP += srcSurface.pitch, destP += destSurface.pitch)
Common::copy(srcP, srcP + destSurface.pitch, destP);
@@ -76,7 +76,7 @@ GfxSurface surfaceFromRes(const byte *imgData) {
const byte *srcP = imgData + 10;
Graphics::Surface destSurface = s.lockSurface();
- byte *destP = (byte *)destSurface.getBasePtr(0, 0);
+ byte *destP = (byte *)destSurface.getPixels();
if (!rleEncoded) {
Common::copy(srcP, srcP + (r.width() * r.height()), destP);
@@ -316,7 +316,7 @@ void GfxSurface::create(int width, int height) {
}
_customSurface = new Graphics::Surface();
_customSurface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
- Common::fill((byte *)_customSurface->pixels, (byte *)_customSurface->pixels + (width * height), 0);
+ Common::fill((byte *)_customSurface->getPixels(), (byte *)_customSurface->getBasePtr(0, height), 0);
_bounds = Rect(0, 0, width, height);
}
@@ -332,12 +332,7 @@ Graphics::Surface GfxSurface::lockSurface() {
// Setup the returned surface either as one pointing to the same pixels as the source, or
// as a subset of the source one based on the currently set bounds
Graphics::Surface result;
- result.w = _bounds.width();
- result.h = _bounds.height();
- result.pitch = src->pitch;
- result.format = src->format;
- result.pixels = src->getBasePtr(_bounds.left, _bounds.top);
-
+ result.init(_bounds.width(), _bounds.height(), src->pitch, src->getBasePtr(_bounds.left, _bounds.top), src->format);
return result;
}
@@ -363,7 +358,7 @@ void GfxSurface::synchronize(Serializer &s) {
if (_customSurface) {
s.syncAsSint16LE(_customSurface->w);
s.syncAsSint16LE(_customSurface->h);
- s.syncBytes((byte *)_customSurface->pixels, _customSurface->w * _customSurface->h);
+ s.syncBytes((byte *)_customSurface->getPixels(), _customSurface->w * _customSurface->h);
} else {
int zero = 0;
s.syncAsSint16LE(zero);
@@ -380,7 +375,7 @@ void GfxSurface::synchronize(Serializer &s) {
_customSurface = NULL;
} else {
create(w, h);
- s.syncBytes((byte *)_customSurface->pixels, w * h);
+ s.syncBytes((byte *)_customSurface->getPixels(), w * h);
}
}
}
@@ -417,8 +412,8 @@ GfxSurface &GfxSurface::operator=(const GfxSurface &s) {
// Surface owns the internal data, so replicate it so new surface owns it's own
_customSurface = new Graphics::Surface();
_customSurface->create(s._customSurface->w, s._customSurface->h, Graphics::PixelFormat::createFormatCLUT8());
- const byte *srcP = (const byte *)s._customSurface->getBasePtr(0, 0);
- byte *destP = (byte *)_customSurface->getBasePtr(0, 0);
+ const byte *srcP = (const byte *)s._customSurface->getPixels();
+ byte *destP = (byte *)_customSurface->getPixels();
Common::copy(srcP, srcP + (_bounds.width() * _bounds.height()), destP);
}
@@ -581,7 +576,7 @@ void GfxSurface::copyFrom(GfxSurface &src, Rect srcBounds, Rect destBounds, Regi
Graphics::Surface destSurface = srcImage.lockSurface();
const byte *srcP = (const byte *)srcSurface.getBasePtr(srcBounds.left, srcBounds.top);
- byte *destP = (byte *)destSurface.pixels;
+ byte *destP = (byte *)destSurface.getPixels();
for (int yp = srcBounds.top; yp < srcBounds.bottom; ++yp, srcP += srcSurface.pitch, destP += destSurface.pitch) {
Common::copy(srcP, srcP + srcBounds.width(), destP);
}
diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp
index 0495834307..cb28d6d60b 100644
--- a/engines/tsage/ringworld2/ringworld2_logic.cpp
+++ b/engines/tsage/ringworld2/ringworld2_logic.cpp
@@ -522,7 +522,7 @@ void SceneExt::refreshBackground(int xAmount, int yAmount) {
assert(screenSize == (s.w * s.h));
// Copy the data
- byte *destP = (byte *)s.getBasePtr(0, 0);
+ byte *destP = (byte *)s.getPixels();
Common::copy(dataP, dataP + (s.w * s.h), destP);
_backSurface.unlockSurface();
diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.cpp b/engines/tsage/ringworld2/ringworld2_scenes0.cpp
index e37d5bfff3..ead4f5c770 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes0.cpp
+++ b/engines/tsage/ringworld2/ringworld2_scenes0.cpp
@@ -5399,9 +5399,9 @@ GfxSurface Scene600::Actor4::getFrame() {
// Translate the frame using the scene's pixel map
byte *pixelMap = static_cast<Scene600 *>(R2_GLOBALS._sceneManager._scene)->_pixelMap;
Graphics::Surface surface = frame.lockSurface();
- byte *srcP = (byte *)surface.pixels;
+ byte *srcP = (byte *)surface.getPixels();
- while (srcP < ((byte *)surface.pixels + (surface.w * surface.h))) {
+ while (srcP < ((byte *)surface.getBasePtr(0, surface.h))) {
*srcP = pixelMap[*srcP];
srcP++;
}
diff --git a/engines/tsage/saveload.cpp b/engines/tsage/saveload.cpp
index af2f3566ad..7143305586 100644
--- a/engines/tsage/saveload.cpp
+++ b/engines/tsage/saveload.cpp
@@ -289,7 +289,7 @@ void Saver::writeSavegameHeader(Common::OutSaveFile *out, tSageSavegameHeader &h
// Create a thumbnail and save it
Graphics::Surface *thumb = new Graphics::Surface();
Graphics::Surface s = g_globals->_screenSurface.lockSurface();
- ::createThumbnail(thumb, (const byte *)s.pixels, SCREEN_WIDTH, SCREEN_HEIGHT, thumbPalette);
+ ::createThumbnail(thumb, (const byte *)s.getPixels(), SCREEN_WIDTH, SCREEN_HEIGHT, thumbPalette);
Graphics::saveThumbnail(*out, *thumb);
g_globals->_screenSurface.unlockSurface();
thumb->free();
diff --git a/engines/tucker/sequences.cpp b/engines/tucker/sequences.cpp
index 16c4f4f6f0..bd03eed00b 100644
--- a/engines/tucker/sequences.cpp
+++ b/engines/tucker/sequences.cpp
@@ -763,7 +763,7 @@ bool AnimationSequencePlayer::decodeNextAnimationFrame(int index, bool copyDirty
if (!copyDirtyRects) {
for (uint16 y = 0; (y < surface->h) && (y < kScreenHeight); y++)
- memcpy(_offscreenBuffer + y * kScreenWidth, (byte *)surface->pixels + y * surface->pitch, surface->w);
+ memcpy(_offscreenBuffer + y * kScreenWidth, (const byte *)surface->getBasePtr(0, y), surface->w);
} else {
_flicPlayer[index].copyDirtyRectsToBuffer(_offscreenBuffer, kScreenWidth);
}
@@ -811,7 +811,7 @@ void AnimationSequencePlayer::playIntroSeq19_20() {
if (surface)
for (int i = 0; i < kScreenWidth * kScreenHeight; ++i)
if (_offscreenBuffer[i] == 0)
- _offscreenBuffer[i] = *((byte *)surface->pixels + i);
+ _offscreenBuffer[i] = *((const byte *)surface->getPixels() + i);
if (!framesLeft)
_changeToNextSequence = true;
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
index 964762f077..b16cf60752 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
@@ -187,9 +187,9 @@ bool BaseRenderOSystem::flip() {
}
if (_needsFlip || _disableDirtyRects || _tempDisableDirtyRects) {
if (_disableDirtyRects || _tempDisableDirtyRects) {
- g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h);
+ g_system->copyRectToScreen((byte *)_renderSurface->getPixels(), _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h);
}
- // g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height());
+ // g_system->copyRectToScreen((byte *)_renderSurface->getPixels(), _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height());
delete _dirtyRect;
_dirtyRect = nullptr;
g_system->updateScreen();
@@ -682,7 +682,7 @@ void BaseRenderOSystem::endSaveLoad() {
_drawNum = 1;
_renderSurface->fillRect(Common::Rect(0, 0, _renderSurface->h, _renderSurface->w), _renderSurface->format.ARGBToColor(255, 0, 0, 0));
- g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h);
+ g_system->copyRectToScreen((byte *)_renderSurface->getPixels(), _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h);
g_system->updateScreen();
}
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index eeb0a8097b..d4c5905c4b 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -234,7 +234,7 @@ uint32 BaseSurfaceOSystem::getPixelAt(Graphics::Surface *surface, int x, int y)
warning("BaseSurfaceOSystem::GetPixel - Not ported yet");
int bpp = surface->format.bytesPerPixel;
/* Here p is the address to the pixel we want to retrieve */
- uint8 *p = (uint8 *)surface->pixels + y * surface->pitch + x * bpp;
+ uint8 *p = (uint8 *)surface->getBasePtr(x, y);
switch (bpp) {
case 1:
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index 663c0ed01a..df6286e37a 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -157,7 +157,10 @@ TransparentSurface::TransparentSurface(const Surface &surf, bool copyData) : Sur
h = surf.h;
pitch = surf.pitch;
format = surf.format;
- pixels = surf.pixels;
+ // We need to cast the const qualifier away here because 'pixels'
+ // always needs to be writable. 'surf' however is a constant Surface,
+ // thus getPixels will always return const pixel data.
+ pixels = const_cast<void *>(surf.getPixels());
}
}
@@ -306,7 +309,7 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
}
if (pPartRect) {
- srcImage.pixels = &((char *)pixels)[pPartRect->top * srcImage.pitch + pPartRect->left * 4];
+ srcImage.pixels = getBasePtr(pPartRect->left, pPartRect->top);
srcImage.w = pPartRect->width();
srcImage.h = pPartRect->height();
@@ -335,7 +338,7 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
if ((width != srcImage.w) || (height != srcImage.h)) {
// Scale the image
img = imgScaled = srcImage.scale(width, height);
- savedPixels = (byte *)img->pixels;
+ savedPixels = (byte *)img->getPixels();
} else {
img = &srcImage;
}
@@ -343,13 +346,13 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
// Handle off-screen clipping
if (posY < 0) {
img->h = MAX(0, (int)img->h - -posY);
- img->pixels = (byte *)img->pixels + img->pitch * -posY;
+ img->setPixels((byte *)img->getBasePtr(0, -posY));
posY = 0;
}
if (posX < 0) {
img->w = MAX(0, (int)img->w - -posX);
- img->pixels = (byte *)img->pixels + (-posX * 4);
+ img->setPixels((byte *)img->getBasePtr(-posX, 0));
posX = 0;
}
@@ -486,7 +489,7 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
retSize.setHeight(img->h);
if (imgScaled) {
- imgScaled->pixels = savedPixels;
+ imgScaled->setPixels(savedPixels);
imgScaled->free();
delete imgScaled;
}
diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp
index b33001c6b7..12884a76c3 100644
--- a/engines/wintermute/video/video_theora_player.cpp
+++ b/engines/wintermute/video/video_theora_player.cpp
@@ -369,14 +369,14 @@ void VideoTheoraPlayer::writeAlpha() {
if (_alphaImage && _surface.w == _alphaImage->getSurface()->w && _surface.h == _alphaImage->getSurface()->h) {
assert(_alphaImage->getSurface()->format.bytesPerPixel == 4);
assert(_surface.format.bytesPerPixel == 4);
- const byte *alphaData = (const byte *)_alphaImage->getSurface()->getBasePtr(0, 0);
+ const byte *alphaData = (const byte *)_alphaImage->getSurface()->getPixels();
#ifdef SCUMM_LITTLE_ENDIAN
int alphaPlace = (_alphaImage->getSurface()->format.aShift / 8);
#else
int alphaPlace = 3 - (_alphaImage->getSurface()->format.aShift / 8);
#endif
alphaData += alphaPlace;
- byte *imgData = (byte *)_surface.getBasePtr(0, 0);
+ byte *imgData = (byte *)_surface.getPixels();
#ifdef SCUMM_LITTLE_ENDIAN
imgData += (_surface.format.aShift / 8);
#else
diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h
index 0467cac946..5d6369c08f 100644
--- a/graphics/VectorRenderer.h
+++ b/graphics/VectorRenderer.h
@@ -278,7 +278,7 @@ public:
* Clears the active surface.
*/
virtual void clearSurface() {
- byte *src = (byte *)_activeSurface->pixels;
+ byte *src = (byte *)_activeSurface->getPixels();
memset(src, 0, _activeSurface->pitch * _activeSurface->h);
}
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index 6a3ee306a5..4c5dd33cb5 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -397,7 +397,7 @@ gradientFill(PixelType *ptr, int width, int x, int y) {
template<typename PixelType>
void VectorRendererSpec<PixelType>::
fillSurface() {
- byte *ptr = (byte *)_activeSurface->getBasePtr(0, 0);
+ byte *ptr = (byte *)_activeSurface->getPixels();
int h = _activeSurface->h;
int pitch = _activeSurface->pitch;
@@ -453,7 +453,7 @@ template<typename PixelType>
void VectorRendererSpec<PixelType>::
blitSubSurface(const Graphics::Surface *source, const Common::Rect &r) {
byte *dst_ptr = (byte *)_activeSurface->getBasePtr(r.left, r.top);
- const byte *src_ptr = (const byte *)source->getBasePtr(0, 0);
+ const byte *src_ptr = (const byte *)source->getPixels();
const int dst_pitch = _activeSurface->pitch;
const int src_pitch = source->pitch;
@@ -481,7 +481,7 @@ blitAlphaBitmap(const Graphics::Surface *source, const Common::Rect &r) {
y = y + (r.height() >> 1) - (source->h >> 1);
PixelType *dst_ptr = (PixelType *)_activeSurface->getBasePtr(x, y);
- const PixelType *src_ptr = (const PixelType *)source->getBasePtr(0, 0);
+ const PixelType *src_ptr = (const PixelType *)source->getPixels();
int dst_pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int src_pitch = source->pitch / source->format.bytesPerPixel;
@@ -508,7 +508,7 @@ template<typename PixelType>
void VectorRendererSpec<PixelType>::
applyScreenShading(GUI::ThemeEngine::ShadingStyle shadingStyle) {
int pixels = _activeSurface->w * _activeSurface->h;
- PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(0, 0);
+ PixelType *ptr = (PixelType *)_activeSurface->getPixels();
uint8 r, g, b;
uint lum;
diff --git a/graphics/decoders/bmp.cpp b/graphics/decoders/bmp.cpp
index bcfd0abbda..2eabbb7631 100644
--- a/graphics/decoders/bmp.cpp
+++ b/graphics/decoders/bmp.cpp
@@ -130,14 +130,14 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0;
if (bitsPerPixel == 8) {
- byte *dst = (byte *)_surface->pixels;
+ byte *dst = (byte *)_surface->getPixels();
for (int32 i = 0; i < height; i++) {
stream.read(dst + (height - i - 1) * width, width);
stream.skip(extraDataLength);
}
} else if (bitsPerPixel == 24) {
- byte *dst = (byte *)_surface->pixels + (height - 1) * _surface->pitch;
+ byte *dst = (byte *)_surface->getBasePtr(0, height - 1);
for (int32 i = 0; i < height; i++) {
for (uint32 j = 0; j < width; j++) {
@@ -154,7 +154,7 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
dst -= _surface->pitch * 2;
}
} else { // 32 bpp
- byte *dst = (byte *)_surface->pixels + (height - 1) * _surface->pitch;
+ byte *dst = (byte *)_surface->getBasePtr(0, height - 1);
for (int32 i = 0; i < height; i++) {
for (uint32 j = 0; j < width; j++) {
diff --git a/graphics/decoders/iff.cpp b/graphics/decoders/iff.cpp
index 50c7b4f7de..7b37969fc1 100644
--- a/graphics/decoders/iff.cpp
+++ b/graphics/decoders/iff.cpp
@@ -170,7 +170,7 @@ void IFFDecoder::loadBitmap(Common::SeekableReadStream &stream) {
if (_type == TYPE_ILBM) {
uint32 scanlinePitch = ((_header.width + 15) >> 4) << 1;
byte *scanlines = new byte[scanlinePitch * _header.numPlanes];
- byte *data = (byte *)_surface->pixels;
+ byte *data = (byte *)_surface->getPixels();
for (uint16 i = 0; i < _header.height; ++i) {
byte *scanline = scanlines;
@@ -194,7 +194,7 @@ void IFFDecoder::loadBitmap(Common::SeekableReadStream &stream) {
delete[] scanlines;
} else if (_type == TYPE_PBM) {
- byte *data = (byte *)_surface->pixels;
+ byte *data = (byte *)_surface->getPixels();
uint32 outSize = _header.width * _header.height;
if (_header.compression) {
diff --git a/graphics/decoders/jpeg.cpp b/graphics/decoders/jpeg.cpp
index 75fdcd6e5a..ff018c799a 100644
--- a/graphics/decoders/jpeg.cpp
+++ b/graphics/decoders/jpeg.cpp
@@ -81,7 +81,7 @@ const Surface *JPEGDecoder::getSurface() const {
const Graphics::Surface *uComponent = getComponent(2);
const Graphics::Surface *vComponent = getComponent(3);
- YUVToRGBMan.convert444(_rgbSurface, Graphics::YUVToRGBManager::kScaleFull, (byte *)yComponent->pixels, (byte *)uComponent->pixels, (byte *)vComponent->pixels, yComponent->w, yComponent->h, yComponent->pitch, uComponent->pitch);
+ YUVToRGBMan.convert444(_rgbSurface, Graphics::YUVToRGBManager::kScaleFull, (const byte *)yComponent->getPixels(), (const byte *)uComponent->getPixels(), (const byte *)vComponent->getPixels(), yComponent->w, yComponent->h, yComponent->pitch, uComponent->pitch);
return _rgbSurface;
}
diff --git a/graphics/decoders/pcx.cpp b/graphics/decoders/pcx.cpp
index 1250398c73..eb9b4c997d 100644
--- a/graphics/decoders/pcx.cpp
+++ b/graphics/decoders/pcx.cpp
@@ -117,7 +117,7 @@ bool PCXDecoder::loadStream(Common::SeekableReadStream &stream) {
if (nPlanes == 3 && bitsPerPixel == 8) { // 24bpp
Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
_surface->create(width, height, format);
- dst = (byte *)_surface->pixels;
+ dst = (byte *)_surface->getPixels();
_paletteColorCount = 0;
for (y = 0; y < height; y++) {
@@ -135,7 +135,7 @@ bool PCXDecoder::loadStream(Common::SeekableReadStream &stream) {
}
} else if (nPlanes == 1 && bitsPerPixel == 8) { // 8bpp indexed
_surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
- dst = (byte *)_surface->pixels;
+ dst = (byte *)_surface->getPixels();
_paletteColorCount = 16;
for (y = 0; y < height; y++, dst += _surface->pitch) {
@@ -163,7 +163,7 @@ bool PCXDecoder::loadStream(Common::SeekableReadStream &stream) {
}
} else if ((nPlanes == 2 || nPlanes == 3 || nPlanes == 4) && bitsPerPixel == 1) { // planar, 4, 8 or 16 colors
_surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
- dst = (byte *)_surface->pixels;
+ dst = (byte *)_surface->getPixels();
_paletteColorCount = 16;
for (y = 0; y < height; y++, dst += _surface->pitch) {
diff --git a/graphics/decoders/pict.cpp b/graphics/decoders/pict.cpp
index b1d408ebc3..f3e17b33e2 100644
--- a/graphics/decoders/pict.cpp
+++ b/graphics/decoders/pict.cpp
@@ -364,7 +364,7 @@ void PICTDecoder::unpackBitsRect(Common::SeekableReadStream &stream, bool withPa
case 1:
// Just copy to the image
_outputSurface->create(width, height, PixelFormat::createFormatCLUT8());
- memcpy(_outputSurface->pixels, buffer, _outputSurface->w * _outputSurface->h);
+ memcpy(_outputSurface->getPixels(), buffer, _outputSurface->w * _outputSurface->h);
break;
case 2:
// We have a 16-bit surface
diff --git a/graphics/decoders/png.cpp b/graphics/decoders/png.cpp
index 11e26162eb..505475213f 100644
--- a/graphics/decoders/png.cpp
+++ b/graphics/decoders/png.cpp
@@ -164,7 +164,7 @@ bool PNGDecoder::loadStream(Common::SeekableReadStream &stream) {
png_set_packing(pngPtr);
} else {
_outputSurface->create(width, height, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
- if (!_outputSurface->pixels) {
+ if (!_outputSurface->getPixels()) {
error("Could not allocate memory for output image.");
}
if (bitDepth == 16)
diff --git a/graphics/decoders/tga.cpp b/graphics/decoders/tga.cpp
index c3b9d84055..a9f136d238 100644
--- a/graphics/decoders/tga.cpp
+++ b/graphics/decoders/tga.cpp
@@ -272,7 +272,7 @@ bool TGADecoder::readData(Common::SeekableReadStream &tga, byte imageType, byte
} else if (imageType == TYPE_BW) {
_surface.create(_surface.w, _surface.h, _format);
- byte *data = (byte *)_surface.pixels;
+ byte *data = (byte *)_surface.getPixels();
uint32 count = _surface.w * _surface.h;
while (count-- > 0) {
@@ -318,7 +318,7 @@ bool TGADecoder::readDataRLE(Common::SeekableReadStream &tga, byte imageType, by
if (imageType == TYPE_RLE_TRUECOLOR || imageType == TYPE_RLE_BW || imageType == TYPE_RLE_CMAP) {
_surface.create(_surface.w, _surface.h, _format);
uint32 count = _surface.w * _surface.h;
- byte *data = (byte *)_surface.pixels;
+ byte *data = (byte *)_surface.getPixels();
while (count > 0) {
uint32 header = tga.readByte();
diff --git a/graphics/fonts/ttf.cpp b/graphics/fonts/ttf.cpp
index 2b1dca1eae..b9e9610d77 100644
--- a/graphics/fonts/ttf.cpp
+++ b/graphics/fonts/ttf.cpp
@@ -322,7 +322,7 @@ void TTFFont::drawChar(Surface *dst, byte chr, int x, int y, uint32 color) const
int w = glyph.image.w;
int h = glyph.image.h;
- const uint8 *srcPos = (const uint8 *)glyph.image.getBasePtr(0, 0);
+ const uint8 *srcPos = (const uint8 *)glyph.image.getPixels();
// Make sure we are not drawing outside the screen bounds
if (x < 0) {
@@ -422,7 +422,7 @@ bool TTFFont::cacheGlyph(Glyph &glyph, FT_UInt &slot, uint chr) {
srcPitch = -srcPitch;
}
- uint8 *dst = (uint8 *)glyph.image.getBasePtr(0, 0);
+ uint8 *dst = (uint8 *)glyph.image.getPixels();
memset(dst, 0, glyph.image.h * glyph.image.pitch);
switch (bitmap.pixel_mode) {
diff --git a/graphics/scaler/thumbnail_intern.cpp b/graphics/scaler/thumbnail_intern.cpp
index 347a25ec37..c30fc3b6fd 100644
--- a/graphics/scaler/thumbnail_intern.cpp
+++ b/graphics/scaler/thumbnail_intern.cpp
@@ -77,13 +77,13 @@ void createThumbnail_4(const uint8 *src, uint32 srcPitch, uint8 *dstPtr, uint32
static void scaleThumbnail(Graphics::Surface &in, Graphics::Surface &out) {
while (in.w / out.w >= 4 || in.h / out.h >= 4) {
- createThumbnail_4<565>((const uint8 *)in.pixels, in.pitch, (uint8 *)in.pixels, in.pitch, in.w, in.h);
+ createThumbnail_4<565>((const uint8 *)in.getPixels(), in.pitch, (uint8 *)in.getPixels(), in.pitch, in.w, in.h);
in.w /= 4;
in.h /= 4;
}
while (in.w / out.w >= 2 || in.h / out.h >= 2) {
- createThumbnail_2<565>((const uint8 *)in.pixels, in.pitch, (uint8 *)in.pixels, in.pitch, in.w, in.h);
+ createThumbnail_2<565>((const uint8 *)in.getPixels(), in.pitch, (uint8 *)in.getPixels(), in.pitch, in.w, in.h);
in.w /= 2;
in.h /= 2;
}
@@ -91,7 +91,7 @@ static void scaleThumbnail(Graphics::Surface &in, Graphics::Surface &out) {
if ((in.w == out.w && in.h < out.h) || (in.w < out.w && in.h == out.h)) {
// In this case we simply center the input surface in the output
uint8 *dst = (uint8 *)out.getBasePtr((out.w - in.w) / 2, (out.h - in.h) / 2);
- const uint8 *src = (const uint8 *)in.getBasePtr(0, 0);
+ const uint8 *src = (const uint8 *)in.getPixels();
for (int y = 0; y < in.h; ++y) {
memcpy(dst, src, in.w * in.format.bytesPerPixel);
@@ -172,7 +172,7 @@ static bool grabScreen565(Graphics::Surface *surf) {
return false;
assert(screen->format.bytesPerPixel == 1 || screen->format.bytesPerPixel == 2);
- assert(screen->pixels != 0);
+ assert(screen->getPixels() != 0);
Graphics::PixelFormat screenFormat = g_system->getScreenFormat();
@@ -190,15 +190,16 @@ static bool grabScreen565(Graphics::Surface *surf) {
byte r = 0, g = 0, b = 0;
if (screenFormat.bytesPerPixel == 1) {
- r = palette[((uint8 *)screen->pixels)[y * screen->pitch + x] * 3];
- g = palette[((uint8 *)screen->pixels)[y * screen->pitch + x] * 3 + 1];
- b = palette[((uint8 *)screen->pixels)[y * screen->pitch + x] * 3 + 2];
+ uint8 pixel = *(uint8 *)screen->getBasePtr(x, y);
+ r = palette[pixel * 3 + 0];
+ g = palette[pixel * 3 + 1];
+ b = palette[pixel * 3 + 2];
} else if (screenFormat.bytesPerPixel == 2) {
uint16 col = READ_UINT16(screen->getBasePtr(x, y));
screenFormat.colorToRGB(col, r, g, b);
}
- ((uint16 *)surf->pixels)[y * surf->w + x] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(r, g, b);
+ *((uint16 *)surf->getBasePtr(x, y)) = Graphics::RGBToColor<Graphics::ColorMasks<565> >(r, g, b);
}
}
@@ -246,7 +247,7 @@ bool createThumbnail(Graphics::Surface *surf, const uint8 *pixels, int w, int h,
g = palette[pixels[y * w + x] * 3 + 1];
b = palette[pixels[y * w + x] * 3 + 2];
- ((uint16 *)screen.pixels)[y * screen.w + x] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(r, g, b);
+ *((uint16 *)screen.getBasePtr(x, y)) = Graphics::RGBToColor<Graphics::ColorMasks<565> >(r, g, b);
}
}
@@ -272,7 +273,7 @@ bool createScreenShot(Graphics::Surface &surf) {
byte r = 0, g = 0, b = 0, a = 0;
uint32 col = READ_UINT32(screen->getBasePtr(x, y));
screenFormat.colorToARGB(col, a, r, g, b);
- ((uint32 *)surf.pixels)[y * surf.w + x] = Graphics::ARGBToColor<Graphics::ColorMasks<8888> >(a, r, g, b);
+ *((uint32 *)surf.getBasePtr(x, y)) = Graphics::ARGBToColor<Graphics::ColorMasks<8888> >(a, r, g, b);
}
}
g_system->unlockScreen();
diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index b90ddd23e8..929157203e 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -82,6 +82,14 @@ void Surface::free() {
format = PixelFormat();
}
+void Surface::init(uint16 width, uint16 height, uint16 newPitch, void *newPixels, const PixelFormat &f) {
+ w = width;
+ h = height;
+ pitch = newPitch;
+ pixels = newPixels;
+ format = f;
+}
+
void Surface::copyFrom(const Surface &surf) {
create(surf.w, surf.h, surf.format);
if (surf.pitch == pitch) {
diff --git a/graphics/surface.h b/graphics/surface.h
index 21b491e043..b08d4a5cb7 100644
--- a/graphics/surface.h
+++ b/graphics/surface.h
@@ -61,11 +61,13 @@ struct Surface {
*/
uint16 pitch;
+protected:
/**
* The surface's pixel data.
*/
void *pixels;
+public:
/**
* The pixel format of the surface.
*/
@@ -78,6 +80,33 @@ struct Surface {
}
/**
+ * Return a pointer to the pixel data.
+ *
+ * @return Pointer to the pixel data.
+ */
+ inline const void *getPixels() const {
+ return pixels;
+ }
+
+ /**
+ * Return a pointer to the pixel data.
+ *
+ * @return Pointer to the pixel data.
+ */
+ inline void *getPixels() {
+ return pixels;
+ }
+
+ /**
+ * Sets the pixel data.
+ *
+ * Note that this is a simply a setter. Be careful what you are doing!
+ *
+ * @param newPixels The new pixel data.
+ */
+ void setPixels(void *newPixels) { pixels = newPixels; }
+
+ /**
* Return a pointer to the pixel at the specified point.
*
* @param x The x coordinate of the pixel.
@@ -122,6 +151,20 @@ struct Surface {
void free();
/**
+ * Set up the Surface with user specified data.
+ *
+ * Note that this simply sets the 'internal' attributes of the Surface. It
+ * will not take care of freeing old data via free or similar!
+ *
+ * @param width Width of the pixel data.
+ * @param height Height of the pixel data.
+ * @param pitch The pitch of the pixel data.
+ * @param pixels The pixel data itself.
+ * @param format The pixel format of the pixel data.
+ */
+ void init(uint16 width, uint16 height, uint16 pitch, void *pixels, const PixelFormat &format);
+
+ /**
* Copy the data from another Surface.
*
* Note that this calls free on the current surface, to assure it being
diff --git a/graphics/yuv_to_rgb.cpp b/graphics/yuv_to_rgb.cpp
index 6043315a13..2a485fa664 100644
--- a/graphics/yuv_to_rgb.cpp
+++ b/graphics/yuv_to_rgb.cpp
@@ -229,7 +229,7 @@ void convertYUV444ToRGB(byte *dstPtr, int dstPitch, const YUVToRGBLookup *lookup
void YUVToRGBManager::convert444(Graphics::Surface *dst, YUVToRGBManager::LuminanceScale scale, const byte *ySrc, const byte *uSrc, const byte *vSrc, int yWidth, int yHeight, int yPitch, int uvPitch) {
// Sanity checks
- assert(dst && dst->pixels);
+ assert(dst && dst->getPixels());
assert(dst->format.bytesPerPixel == 2 || dst->format.bytesPerPixel == 4);
assert(ySrc && uSrc && vSrc);
@@ -237,9 +237,9 @@ void YUVToRGBManager::convert444(Graphics::Surface *dst, YUVToRGBManager::Lumina
// Use a templated function to avoid an if check on every pixel
if (dst->format.bytesPerPixel == 2)
- convertYUV444ToRGB<uint16>((byte *)dst->pixels, dst->pitch, lookup, _colorTab, ySrc, uSrc, vSrc, yWidth, yHeight, yPitch, uvPitch);
+ convertYUV444ToRGB<uint16>((byte *)dst->getPixels(), dst->pitch, lookup, _colorTab, ySrc, uSrc, vSrc, yWidth, yHeight, yPitch, uvPitch);
else
- convertYUV444ToRGB<uint32>((byte *)dst->pixels, dst->pitch, lookup, _colorTab, ySrc, uSrc, vSrc, yWidth, yHeight, yPitch, uvPitch);
+ convertYUV444ToRGB<uint32>((byte *)dst->getPixels(), dst->pitch, lookup, _colorTab, ySrc, uSrc, vSrc, yWidth, yHeight, yPitch, uvPitch);
}
template<typename PixelInt>
@@ -283,7 +283,7 @@ void convertYUV420ToRGB(byte *dstPtr, int dstPitch, const YUVToRGBLookup *lookup
void YUVToRGBManager::convert420(Graphics::Surface *dst, YUVToRGBManager::LuminanceScale scale, const byte *ySrc, const byte *uSrc, const byte *vSrc, int yWidth, int yHeight, int yPitch, int uvPitch) {
// Sanity checks
- assert(dst && dst->pixels);
+ assert(dst && dst->getPixels());
assert(dst->format.bytesPerPixel == 2 || dst->format.bytesPerPixel == 4);
assert(ySrc && uSrc && vSrc);
assert((yWidth & 1) == 0);
@@ -293,9 +293,9 @@ void YUVToRGBManager::convert420(Graphics::Surface *dst, YUVToRGBManager::Lumina
// Use a templated function to avoid an if check on every pixel
if (dst->format.bytesPerPixel == 2)
- convertYUV420ToRGB<uint16>((byte *)dst->pixels, dst->pitch, lookup, _colorTab, ySrc, uSrc, vSrc, yWidth, yHeight, yPitch, uvPitch);
+ convertYUV420ToRGB<uint16>((byte *)dst->getPixels(), dst->pitch, lookup, _colorTab, ySrc, uSrc, vSrc, yWidth, yHeight, yPitch, uvPitch);
else
- convertYUV420ToRGB<uint32>((byte *)dst->pixels, dst->pitch, lookup, _colorTab, ySrc, uSrc, vSrc, yWidth, yHeight, yPitch, uvPitch);
+ convertYUV420ToRGB<uint32>((byte *)dst->getPixels(), dst->pitch, lookup, _colorTab, ySrc, uSrc, vSrc, yWidth, yHeight, yPitch, uvPitch);
}
#define READ_QUAD(ptr, prefix) \
@@ -368,7 +368,7 @@ void convertYUV410ToRGB(byte *dstPtr, int dstPitch, const YUVToRGBLookup *lookup
void YUVToRGBManager::convert410(Graphics::Surface *dst, YUVToRGBManager::LuminanceScale scale, const byte *ySrc, const byte *uSrc, const byte *vSrc, int yWidth, int yHeight, int yPitch, int uvPitch) {
// Sanity checks
- assert(dst && dst->pixels);
+ assert(dst && dst->getPixels());
assert(dst->format.bytesPerPixel == 2 || dst->format.bytesPerPixel == 4);
assert(ySrc && uSrc && vSrc);
assert((yWidth & 3) == 0);
@@ -378,9 +378,9 @@ void YUVToRGBManager::convert410(Graphics::Surface *dst, YUVToRGBManager::Lumina
// Use a templated function to avoid an if check on every pixel
if (dst->format.bytesPerPixel == 2)
- convertYUV410ToRGB<uint16>((byte *)dst->pixels, dst->pitch, lookup, _colorTab, ySrc, uSrc, vSrc, yWidth, yHeight, yPitch, uvPitch);
+ convertYUV410ToRGB<uint16>((byte *)dst->getPixels(), dst->pitch, lookup, _colorTab, ySrc, uSrc, vSrc, yWidth, yHeight, yPitch, uvPitch);
else
- convertYUV410ToRGB<uint32>((byte *)dst->pixels, dst->pitch, lookup, _colorTab, ySrc, uSrc, vSrc, yWidth, yHeight, yPitch, uvPitch);
+ convertYUV410ToRGB<uint32>((byte *)dst->getPixels(), dst->pitch, lookup, _colorTab, ySrc, uSrc, vSrc, yWidth, yHeight, yPitch, uvPitch);
}
} // End of namespace Graphics
diff --git a/gui/EventRecorder.cpp b/gui/EventRecorder.cpp
index fd0093d266..4bf5832864 100644
--- a/gui/EventRecorder.cpp
+++ b/gui/EventRecorder.cpp
@@ -522,7 +522,7 @@ bool EventRecorder::grabScreenAndComputeMD5(Graphics::Surface &screen, uint8 md5
warning("Can't save screenshot");
return false;
}
- Common::MemoryReadStream bitmapStream((const byte*)screen.pixels, screen.w * screen.h * screen.format.bytesPerPixel);
+ Common::MemoryReadStream bitmapStream((const byte*)screen.getPixels(), screen.w * screen.h * screen.format.bytesPerPixel);
computeStreamMD5(bitmapStream, md5);
return true;
}
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 3ce043cb39..0f8b449b58 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -389,7 +389,7 @@ bool ThemeEngine::init() {
_overlayFormat = _system->getOverlayFormat();
setGraphicsMode(_graphicsMode);
- if (_screen.pixels && _backBuffer.pixels) {
+ if (_screen.getPixels() && _backBuffer.getPixels()) {
_initOk = true;
}
@@ -439,7 +439,7 @@ bool ThemeEngine::init() {
void ThemeEngine::clearAll() {
if (_initOk) {
_system->clearOverlay();
- _system->grabOverlay(_screen.pixels, _screen.pitch);
+ _system->grabOverlay(_screen.getPixels(), _screen.pitch);
}
}
@@ -1219,7 +1219,7 @@ void ThemeEngine::updateScreen(bool render) {
}
_vectorRenderer->setSurface(&_screen);
- memcpy(_screen.getBasePtr(0, 0), _backBuffer.getBasePtr(0, 0), _screen.pitch * _screen.h);
+ memcpy(_screen.getPixels(), _backBuffer.getPixels(), _screen.pitch * _screen.h);
_bufferQueue.clear();
}
@@ -1287,7 +1287,7 @@ void ThemeEngine::openDialog(bool doBuffer, ShadingStyle style) {
addDirtyRect(Common::Rect(0, 0, _screen.w, _screen.h));
}
- memcpy(_backBuffer.getBasePtr(0, 0), _screen.getBasePtr(0, 0), _screen.pitch * _screen.h);
+ memcpy(_backBuffer.getPixels(), _screen.getPixels(), _screen.pitch * _screen.h);
_vectorRenderer->setSurface(&_screen);
}
@@ -1326,7 +1326,7 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int
// to 8 bit mode, and have to create a suitable palette on the fly.
uint colorsFound = 0;
Common::HashMap<int, int> colorToIndex;
- const OverlayColor *src = (const OverlayColor *)cursor->pixels;
+ const OverlayColor *src = (const OverlayColor *)cursor->getPixels();
for (uint y = 0; y < _cursorHeight; ++y) {
for (uint x = 0; x < _cursorWidth; ++x) {
byte r, g, b;
diff --git a/gui/widget.cpp b/gui/widget.cpp
index c3f10a861f..d97c46a5cc 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -396,7 +396,7 @@ PicButtonWidget::~PicButtonWidget() {
void PicButtonWidget::setGfx(const Graphics::Surface *gfx) {
_gfx.free();
- if (!gfx || !gfx->pixels)
+ if (!gfx || !gfx->getPixels())
return;
if (gfx->format.bytesPerPixel == 1) {
@@ -429,7 +429,7 @@ void PicButtonWidget::setGfx(int w, int h, int r, int g, int b) {
void PicButtonWidget::drawWidget() {
g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), "", _state, getFlags());
- if (_gfx.pixels) {
+ if (_gfx.getPixels()) {
// Check whether the set up surface needs to be converted to the GUI
// color format.
const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat();
@@ -646,7 +646,7 @@ GraphicsWidget::~GraphicsWidget() {
void GraphicsWidget::setGfx(const Graphics::Surface *gfx) {
_gfx.free();
- if (!gfx || !gfx->pixels)
+ if (!gfx || !gfx->getPixels())
return;
if (gfx->format.bytesPerPixel == 1) {
@@ -676,7 +676,7 @@ void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) {
}
void GraphicsWidget::drawWidget() {
- if (_gfx.pixels) {
+ if (_gfx.getPixels()) {
// Check whether the set up surface needs to be converted to the GUI
// color format.
const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat();
diff --git a/test/audio/raw.h b/test/audio/raw.h
index e7cb42ac44..3792f82674 100644
--- a/test/audio/raw.h
+++ b/test/audio/raw.h
@@ -1,6 +1,7 @@
#include <cxxtest/TestSuite.h>
#include "audio/decoders/raw.h"
+#include "audio/audiostream.h"
#include "helper.h"
diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp
index ff728a8437..92a60fcccf 100644
--- a/video/avi_decoder.cpp
+++ b/video/avi_decoder.cpp
@@ -67,6 +67,7 @@ namespace Video {
#define ID_STRD MKTAG('s','t','r','d')
//#define ID_INFO MKTAG('I','N','F','O')
#define ID_ISFT MKTAG('I','S','F','T')
+#define ID_DISP MKTAG('D','I','S','P')
// Codec tags
#define ID_RLE MKTAG('R','L','E',' ')
@@ -78,18 +79,6 @@ namespace Video {
#define ID_DUCK MKTAG('D','U','C','K')
#define ID_MPG2 MKTAG('m','p','g','2')
-static byte char2num(char c) {
- c = tolower((byte)c);
- return (c >= 'a' && c <= 'f') ? c - 'a' + 10 : c - '0';
-}
-
-static byte getStreamIndex(uint32 tag) {
- return char2num((tag >> 24) & 0xFF) << 4 | char2num((tag >> 16) & 0xFF);
-}
-
-static uint16 getStreamType(uint32 tag) {
- return tag & 0xffff;
-}
AVIDecoder::AVIDecoder(Audio::Mixer::SoundType soundType) : _frameRateOverride(0), _soundType(soundType) {
initCommon();
@@ -107,29 +96,26 @@ AVIDecoder::~AVIDecoder() {
void AVIDecoder::initCommon() {
_decodedHeader = false;
_foundMovieList = false;
+ _movieListStart = 0;
_fileStream = 0;
- memset(&_ixInfo, 0, sizeof(_ixInfo));
memset(&_header, 0, sizeof(_header));
}
-void AVIDecoder::runHandle(uint32 tag) {
- assert(_fileStream);
+bool AVIDecoder::parseNextChunk() {
+ uint32 tag = _fileStream->readUint32BE();
+ uint32 size = _fileStream->readUint32LE();
+
if (_fileStream->eos())
- return;
+ return false;
debug(3, "Decoding tag %s", tag2str(tag));
switch (tag) {
- case ID_RIFF:
- /*_filesize = */_fileStream->readUint32LE();
- if (_fileStream->readUint32BE() != ID_AVI)
- error("RIFF file is not an AVI video");
- break;
case ID_LIST:
- handleList();
+ handleList(size);
break;
case ID_AVIH:
- _header.size = _fileStream->readUint32LE();
+ _header.size = size;
_header.microSecondsPerFrame = _fileStream->readUint32LE();
_header.maxBytesPerSecond = _fileStream->readUint32LE();
_header.padding = _fileStream->readUint32LE();
@@ -144,58 +130,64 @@ void AVIDecoder::runHandle(uint32 tag) {
_fileStream->skip(16);
break;
case ID_STRH:
- handleStreamHeader();
+ handleStreamHeader(size);
break;
case ID_STRD: // Extra stream info, safe to ignore
case ID_VEDT: // Unknown, safe to ignore
case ID_JUNK: // Alignment bytes, should be ignored
case ID_ISFT: // Metadata, safe to ignore
- {
- uint32 junkSize = _fileStream->readUint32LE();
- _fileStream->skip(junkSize + (junkSize & 1)); // Alignment
- } break;
+ case ID_DISP: // Metadata, should be safe to ignore
+ skipChunk(size);
+ break;
case ID_IDX1:
- _ixInfo.size = _fileStream->readUint32LE();
- _ixInfo.indices = new OldIndex::Index[_ixInfo.size / 16];
- debug(0, "%d Indices", (_ixInfo.size / 16));
- for (uint32 i = 0; i < (_ixInfo.size / 16); i++) {
- _ixInfo.indices[i].id = _fileStream->readUint32BE();
- _ixInfo.indices[i].flags = _fileStream->readUint32LE();
- _ixInfo.indices[i].offset = _fileStream->readUint32LE();
- _ixInfo.indices[i].size = _fileStream->readUint32LE();
- debug(0, "Index %d == Tag \'%s\', Offset = %d, Size = %d", i, tag2str(_ixInfo.indices[i].id), _ixInfo.indices[i].offset, _ixInfo.indices[i].size);
+ debug(0, "%d Indices", size / 16);
+ for (uint32 i = 0; i < size / 16; i++) {
+ OldIndex indexEntry;
+ indexEntry.id = _fileStream->readUint32BE();
+ indexEntry.flags = _fileStream->readUint32LE();
+ indexEntry.offset = _fileStream->readUint32LE();
+ indexEntry.size = _fileStream->readUint32LE();
+ _indexEntries.push_back(indexEntry);
+ debug(0, "Index %d == Tag \'%s\', Offset = %d, Size = %d", i, tag2str(indexEntry.id), indexEntry.offset, indexEntry.size);
}
break;
default:
error("Unknown tag \'%s\' found", tag2str(tag));
}
+
+ return true;
}
-void AVIDecoder::handleList() {
- uint32 listSize = _fileStream->readUint32LE() - 4; // Subtract away listType's 4 bytes
+void AVIDecoder::skipChunk(uint32 size) {
+ // Make sure we're aligned on a word boundary
+ _fileStream->skip(size + (size & 1));
+}
+
+void AVIDecoder::handleList(uint32 listSize) {
uint32 listType = _fileStream->readUint32BE();
+ listSize -= 4; // Subtract away listType's 4 bytes
uint32 curPos = _fileStream->pos();
debug(0, "Found LIST of type %s", tag2str(listType));
if (listType == ID_MOVI) {
- // Found the 'movi' list
- // We're done parsing everything
+ // If we found the movie block
_foundMovieList = true;
+ _movieListStart = curPos;
+ _fileStream->skip(listSize);
return;
+ } else if (listType == ID_HDRL) {
+ // Mark the header as decoded
+ _decodedHeader = true;
}
while ((_fileStream->pos() - curPos) < listSize)
- runHandle(_fileStream->readUint32BE());
-
- // We now have all the header data
- if (listType == ID_HDRL)
- _decodedHeader = true;
+ parseNextChunk();
}
-void AVIDecoder::handleStreamHeader() {
+void AVIDecoder::handleStreamHeader(uint32 size) {
AVIStreamHeader sHeader;
- sHeader.size = _fileStream->readUint32LE();
+ sHeader.size = size;
sHeader.streamType = _fileStream->readUint32BE();
if (sHeader.streamType == ID_MIDS || sHeader.streamType == ID_TXTS)
@@ -286,28 +278,41 @@ void AVIDecoder::handleStreamHeader() {
bool AVIDecoder::loadStream(Common::SeekableReadStream *stream) {
close();
- _fileStream = stream;
- _decodedHeader = false;
- _foundMovieList = false;
+ uint32 riffTag = stream->readUint32BE();
+ if (riffTag != ID_RIFF) {
+ warning("Failed to find RIFF header");
+ return false;
+ }
- // Read chunks until we have decoded the header
- while (!_decodedHeader && _fileStream->pos() < _fileStream->size())
- runHandle(_fileStream->readUint32BE());
+ /* uint32 fileSize = */ stream->readUint32LE();
+ uint32 riffType = stream->readUint32BE();
- if (_fileStream->pos() >= _fileStream->size()) {
- warning("Failed to find AVI header");
+ if (riffType != ID_AVI) {
+ warning("RIFF not an AVI file");
return false;
}
- // Then read until we find the movie list
- while (!_foundMovieList && _fileStream->pos() < _fileStream->size())
- runHandle(_fileStream->readUint32BE());
+ _fileStream = stream;
+
+ // Go through all chunks in the file
+ while (parseNextChunk())
+ ;
- if (_fileStream->pos() >= _fileStream->size()) {
- warning("Failed to find AVI 'movi' LIST");
+ if (!_decodedHeader) {
+ warning("Failed to parse AVI header");
+ close();
return false;
}
+ if (!_foundMovieList) {
+ warning("Failed to find 'MOVI' list");
+ close();
+ return false;
+ }
+
+ // Seek back to the start of the MOVI list
+ _fileStream->seek(_movieListStart);
+
return true;
}
@@ -318,33 +323,35 @@ void AVIDecoder::close() {
_fileStream = 0;
_decodedHeader = false;
_foundMovieList = false;
+ _movieListStart = 0;
- delete[] _ixInfo.indices;
- memset(&_ixInfo, 0, sizeof(_ixInfo));
+ _indexEntries.clear();
memset(&_header, 0, sizeof(_header));
}
void AVIDecoder::readNextPacket() {
uint32 nextTag = _fileStream->readUint32BE();
+ uint32 size = _fileStream->readUint32LE();
if (_fileStream->eos())
return;
if (nextTag == ID_LIST) {
// A list of audio/video chunks
- uint32 listSize = _fileStream->readUint32LE() - 4;
int32 startPos = _fileStream->pos();
if (_fileStream->readUint32BE() != ID_REC)
error("Expected 'rec ' LIST");
+ size -= 4; // subtract list type
+
// Decode chunks in the list
- while (_fileStream->pos() < startPos + (int32)listSize)
+ while (_fileStream->pos() < startPos + (int32)size)
readNextPacket();
return;
} else if (nextTag == ID_JUNK || nextTag == ID_IDX1) {
- runHandle(nextTag);
+ skipChunk(size);
return;
}
@@ -353,12 +360,11 @@ void AVIDecoder::readNextPacket() {
if (!track)
error("Cannot get track from tag '%s'", tag2str(nextTag));
- uint32 chunkSize = _fileStream->readUint32LE();
Common::SeekableReadStream *chunk = 0;
- if (chunkSize != 0) {
- chunk = _fileStream->readStream(chunkSize);
- _fileStream->skip(chunkSize & 1);
+ if (size != 0) {
+ chunk = _fileStream->readStream(size);
+ _fileStream->skip(size & 1);
}
if (track->getTrackType() == Track::kTrackTypeAudio) {
@@ -403,6 +409,13 @@ void AVIDecoder::readNextPacket() {
}
}
+byte AVIDecoder::getStreamIndex(uint32 tag) const {
+ char string[3];
+ WRITE_BE_UINT16(string, tag >> 16);
+ string[2] = 0;
+ return strtol(string, 0, 16);
+}
+
AVIDecoder::AVIVideoTrack::AVIVideoTrack(int frameCount, const AVIStreamHeader &streamHeader, const BitmapInfoHeader &bitmapInfoHeader)
: _frameCount(frameCount), _vidsHeader(streamHeader), _bmInfo(bitmapInfoHeader) {
memset(_palette, 0, sizeof(_palette));
diff --git a/video/avi_decoder.h b/video/avi_decoder.h
index 6082232464..5d52c7c797 100644
--- a/video/avi_decoder.h
+++ b/video/avi_decoder.h
@@ -20,10 +20,10 @@
*
*/
-#ifndef VIDEO_AVI_PLAYER_H
-#define VIDEO_AVI_PLAYER_H
+#ifndef VIDEO_AVI_DECODER_H
+#define VIDEO_AVI_DECODER_H
-#include "common/endian.h"
+#include "common/array.h"
#include "common/rational.h"
#include "common/rect.h"
#include "common/str.h"
@@ -102,13 +102,10 @@ private:
};
struct OldIndex {
+ uint32 id;
+ uint32 flags;
+ uint32 offset;
uint32 size;
- struct Index {
- uint32 id;
- uint32 flags;
- uint32 offset;
- uint32 size;
- } *indices;
};
// Index Flags
@@ -218,19 +215,24 @@ private:
Audio::QueuingAudioStream *createAudioStream();
};
- OldIndex _ixInfo;
+ Common::Array<OldIndex> _indexEntries;
AVIHeader _header;
Common::SeekableReadStream *_fileStream;
- bool _decodedHeader, _foundMovieList;
+ bool _decodedHeader;
+ bool _foundMovieList;
+ uint32 _movieListStart;
Audio::Mixer::SoundType _soundType;
Common::Rational _frameRateOverride;
void initCommon();
- void runHandle(uint32 tag);
- void handleList();
- void handleStreamHeader();
+ bool parseNextChunk();
+ void skipChunk(uint32 size);
+ void handleList(uint32 listSize);
+ void handleStreamHeader(uint32 size);
+ uint16 getStreamType(uint32 tag) const { return tag & 0xFFFF; }
+ byte getStreamIndex(uint32 tag) const;
};
} // End of namespace Video
diff --git a/video/codecs/cdtoons.cpp b/video/codecs/cdtoons.cpp
index 528cee8094..68925ed0db 100644
--- a/video/codecs/cdtoons.cpp
+++ b/video/codecs/cdtoons.cpp
@@ -298,7 +298,7 @@ Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *strea
for (uint i = 0; i < actions.size(); i++) {
CDToonsAction &action = actions[i];
if (i == 0 && action.blockId == 0)
- memset(_surface->pixels, backgroundColor, _surface->w * _surface->h);
+ memset(_surface->getPixels(), backgroundColor, _surface->w * _surface->h);
if (!_blocks.contains(action.blockId))
continue;
if (!action.rect.right)
diff --git a/video/codecs/cinepak.cpp b/video/codecs/cinepak.cpp
index bcf0cf1180..a7782f4192 100644
--- a/video/codecs/cinepak.cpp
+++ b/video/codecs/cinepak.cpp
@@ -41,11 +41,11 @@ namespace Video {
byte b = _clipTable[lum + (u << 1)]; \
\
if (_pixelFormat.bytesPerPixel == 2) \
- *((uint16 *)_curFrame.surface->pixels + offset) = _pixelFormat.RGBToColor(r, g, b); \
+ *((uint16 *)_curFrame.surface->getPixels() + offset) = _pixelFormat.RGBToColor(r, g, b); \
else \
- *((uint32 *)_curFrame.surface->pixels + offset) = _pixelFormat.RGBToColor(r, g, b); \
+ *((uint32 *)_curFrame.surface->getPixels() + offset) = _pixelFormat.RGBToColor(r, g, b); \
} else \
- *((byte *)_curFrame.surface->pixels + offset) = lum
+ *((byte *)_curFrame.surface->getPixels() + offset) = lum
CinepakDecoder::CinepakDecoder(int bitsPerPixel) : Codec() {
_curFrame.surface = NULL;
diff --git a/video/codecs/msrle.cpp b/video/codecs/msrle.cpp
index fa03a59efd..2f2ac0334f 100644
--- a/video/codecs/msrle.cpp
+++ b/video/codecs/msrle.cpp
@@ -53,7 +53,7 @@ void MSRLEDecoder::decode8(Common::SeekableReadStream *stream) {
int x = 0;
int y = _surface->h - 1;
- byte *data = (byte *) _surface->pixels;
+ byte *data = (byte *) _surface->getPixels();
uint16 width = _surface->w;
uint16 height = _surface->h;
diff --git a/video/codecs/msvideo1.cpp b/video/codecs/msvideo1.cpp
index 06e4640025..409d588ddf 100644
--- a/video/codecs/msvideo1.cpp
+++ b/video/codecs/msvideo1.cpp
@@ -48,7 +48,7 @@ MSVideo1Decoder::~MSVideo1Decoder() {
void MSVideo1Decoder::decode8(Common::SeekableReadStream *stream) {
byte colors[8];
- byte *pixels = (byte *)_surface->pixels;
+ byte *pixels = (byte *)_surface->getPixels();
uint16 stride = _surface->w;
int skipBlocks = 0;
diff --git a/video/codecs/qtrle.cpp b/video/codecs/qtrle.cpp
index d2cdea27de..1f1fee7997 100644
--- a/video/codecs/qtrle.cpp
+++ b/video/codecs/qtrle.cpp
@@ -61,7 +61,7 @@ QTRLEDecoder::QTRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel) : Cod
void QTRLEDecoder::decode1(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
uint32 pixelPtr = 0;
- byte *rgb = (byte *)_surface->pixels;
+ byte *rgb = (byte *)_surface->getPixels();
while (linesToChange) {
CHECK_STREAM_PTR(2);
@@ -105,7 +105,7 @@ void QTRLEDecoder::decode1(Common::SeekableReadStream *stream, uint32 rowPtr, ui
void QTRLEDecoder::decode2_4(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange, byte bpp) {
uint32 pixelPtr = 0;
- byte *rgb = (byte *)_surface->pixels;
+ byte *rgb = (byte *)_surface->getPixels();
byte numPixels = (bpp == 4) ? 8 : 16;
while (linesToChange--) {
@@ -165,7 +165,7 @@ void QTRLEDecoder::decode2_4(Common::SeekableReadStream *stream, uint32 rowPtr,
void QTRLEDecoder::decode8(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
uint32 pixelPtr = 0;
- byte *rgb = (byte *)_surface->pixels;
+ byte *rgb = (byte *)_surface->getPixels();
while (linesToChange--) {
CHECK_STREAM_PTR(2);
@@ -210,7 +210,7 @@ void QTRLEDecoder::decode8(Common::SeekableReadStream *stream, uint32 rowPtr, ui
void QTRLEDecoder::decode16(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
uint32 pixelPtr = 0;
- uint16 *rgb = (uint16 *)_surface->pixels;
+ uint16 *rgb = (uint16 *)_surface->getPixels();
while (linesToChange--) {
CHECK_STREAM_PTR(2);
@@ -248,7 +248,7 @@ void QTRLEDecoder::decode16(Common::SeekableReadStream *stream, uint32 rowPtr, u
void QTRLEDecoder::decode24(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
uint32 pixelPtr = 0;
- uint32 *rgb = (uint32 *)_surface->pixels;
+ uint32 *rgb = (uint32 *)_surface->getPixels();
while (linesToChange--) {
CHECK_STREAM_PTR(2);
@@ -294,7 +294,7 @@ void QTRLEDecoder::decode24(Common::SeekableReadStream *stream, uint32 rowPtr, u
void QTRLEDecoder::decode32(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
uint32 pixelPtr = 0;
- uint32 *rgb = (uint32 *)_surface->pixels;
+ uint32 *rgb = (uint32 *)_surface->getPixels();
while (linesToChange--) {
CHECK_STREAM_PTR(2);
diff --git a/video/codecs/rpza.cpp b/video/codecs/rpza.cpp
index 0a9f87747e..17a2c53d9b 100644
--- a/video/codecs/rpza.cpp
+++ b/video/codecs/rpza.cpp
@@ -58,7 +58,7 @@ RPZADecoder::~RPZADecoder() {
#define PUT_PIXEL(color) \
if ((int32)blockPtr < _surface->w * _surface->h) \
- WRITE_UINT16((uint16 *)_surface->pixels + blockPtr, color); \
+ WRITE_UINT16((uint16 *)_surface->getPixels() + blockPtr, color); \
blockPtr++
const Graphics::Surface *RPZADecoder::decodeImage(Common::SeekableReadStream *stream) {
diff --git a/video/codecs/smc.cpp b/video/codecs/smc.cpp
index 2eedb62a0f..c0f8152547 100644
--- a/video/codecs/smc.cpp
+++ b/video/codecs/smc.cpp
@@ -56,7 +56,7 @@ SMCDecoder::~SMCDecoder() {
}
const Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *stream) {
- byte *pixels = (byte *)_surface->pixels;
+ byte *pixels = (byte *)_surface->getPixels();
uint32 numBlocks = 0;
uint32 colorFlags = 0;
diff --git a/video/coktel_decoder.cpp b/video/coktel_decoder.cpp
index 4c3b6f8414..024e479bf7 100644
--- a/video/coktel_decoder.cpp
+++ b/video/coktel_decoder.cpp
@@ -97,12 +97,8 @@ void CoktelDecoder::setSurfaceMemory(void *mem, uint16 width, uint16 height, uin
assert(bpp == getPixelFormat().bytesPerPixel);
// Create a surface over this memory
- _surface.w = width;
- _surface.h = height;
- _surface.pitch = width * bpp;
- _surface.pixels = mem;
// TODO: Check whether it is fine to assume we want the setup PixelFormat.
- _surface.format = getPixelFormat();
+ _surface.init(width, height, width * bpp, mem, getPixelFormat());
_ownSurface = false;
}
@@ -122,7 +118,7 @@ const Graphics::Surface *CoktelDecoder::getSurface() const {
}
bool CoktelDecoder::hasSurface() {
- return _surface.pixels != 0;
+ return _surface.getPixels();
}
void CoktelDecoder::createSurface() {
@@ -143,7 +139,7 @@ void CoktelDecoder::freeSurface() {
_surface.w = 0;
_surface.h = 0;
_surface.pitch = 0;
- _surface.pixels = 0;
+ _surface.setPixels(0);
_surface.format = Graphics::PixelFormat();
} else
_surface.free();
@@ -473,7 +469,7 @@ void CoktelDecoder::renderBlockWhole(Graphics::Surface &dstSurf, const byte *src
rect.clip(dstSurf.w, dstSurf.h);
- byte *dst = (byte *)dstSurf.pixels + (rect.top * dstSurf.pitch) + rect.left * dstSurf.format.bytesPerPixel;
+ byte *dst = (byte *)dstSurf.getBasePtr(rect.left, rect.top);
for (int i = 0; i < rect.height(); i++) {
memcpy(dst, src, rect.width() * dstSurf.format.bytesPerPixel);
@@ -488,7 +484,7 @@ void CoktelDecoder::renderBlockWhole4X(Graphics::Surface &dstSurf, const byte *s
rect.clip(dstSurf.w, dstSurf.h);
- byte *dst = (byte *)dstSurf.pixels + (rect.top * dstSurf.pitch) + rect.left;
+ byte *dst = (byte *)dstSurf.getBasePtr(rect.left, rect.top);
for (int i = 0; i < rect.height(); i++) {
byte *dstRow = dst;
const byte *srcRow = src;
@@ -515,7 +511,7 @@ void CoktelDecoder::renderBlockWhole2Y(Graphics::Surface &dstSurf, const byte *s
int16 height = rect.height();
- byte *dst = (byte *)dstSurf.pixels + (rect.top * dstSurf.pitch) + rect.left;
+ byte *dst = (byte *)dstSurf.getBasePtr(rect.left, rect.top);
while (height > 1) {
memcpy(dst , src, rect.width());
memcpy(dst + dstSurf.pitch, src, rect.width());
@@ -535,7 +531,7 @@ void CoktelDecoder::renderBlockSparse(Graphics::Surface &dstSurf, const byte *sr
rect.clip(dstSurf.w, dstSurf.h);
- byte *dst = (byte *)dstSurf.pixels + (rect.top * dstSurf.pitch) + rect.left;
+ byte *dst = (byte *)dstSurf.getBasePtr(rect.left, rect.top);
for (int i = 0; i < rect.height(); i++) {
byte *dstRow = dst;
int16 pixWritten = 0;
@@ -572,7 +568,7 @@ void CoktelDecoder::renderBlockSparse2Y(Graphics::Surface &dstSurf, const byte *
rect.clip(dstSurf.w, dstSurf.h);
- byte *dst = (byte *)dstSurf.pixels + (rect.top * dstSurf.pitch) + rect.left;
+ byte *dst = (byte *)dstSurf.getBasePtr(rect.left, rect.top);
for (int i = 0; i < rect.height(); i += 2) {
byte *dstRow = dst;
int16 pixWritten = 0;
@@ -604,7 +600,7 @@ void CoktelDecoder::renderBlockRLE(Graphics::Surface &dstSurf, const byte *src,
rect.clip(dstSurf.w, dstSurf.h);
- byte *dst = (byte *)dstSurf.pixels + (rect.top * dstSurf.pitch) + rect.left;
+ byte *dst = (byte *)dstSurf.getBasePtr(rect.left, rect.top);
for (int i = 0; i < rect.height(); i++) {
byte *dstRow = dst;
int16 pixWritten = 0;
@@ -865,7 +861,7 @@ void PreIMDDecoder::renderFrame() {
uint16 h = CLIP<int32>(_surface.h - _y, 0, _height);
const byte *src = _videoBuffer;
- byte *dst = (byte *)_surface.pixels + (_y * _surface.pitch) + _x;
+ byte *dst = (byte *)_surface.getBasePtr(_x, _y);
uint32 frameDataSize = _videoBufferSize;
@@ -1458,7 +1454,7 @@ bool IMDDecoder::renderFrame(Common::Rect &rect) {
const int offsetY = (_y + rect.top) * _surface.pitch;
const int offset = offsetX + offsetY;
- if (deLZ77((byte *)_surface.pixels + offset, dataPtr, dataSize,
+ if (deLZ77((byte *)_surface.getPixels() + offset, dataPtr, dataSize,
_surface.w * _surface.h * _surface.format.bytesPerPixel - offset))
return true;
}
@@ -1879,11 +1875,8 @@ bool VMDDecoder::assessVideoProperties() {
_videoBuffer[i] = new byte[_videoBufferSize];
memset(_videoBuffer[i], 0, _videoBufferSize);
- _8bppSurface[i].w = _width * _bytesPerPixel;
- _8bppSurface[i].h = _height;
- _8bppSurface[i].pitch = _width * _bytesPerPixel;
- _8bppSurface[i].pixels = _videoBuffer[i];
- _8bppSurface[i].format = Graphics::PixelFormat::createFormatCLUT8();
+ _8bppSurface[i].init(_width * _bytesPerPixel, _height, _width * _bytesPerPixel,
+ _videoBuffer[i], Graphics::PixelFormat::createFormatCLUT8());
}
}
@@ -2277,7 +2270,7 @@ bool VMDDecoder::renderFrame(Common::Rect &rect) {
rect = Common::Rect(_x, _y, _x + codecSurf->w, _y + codecSurf->h);
rect.clip(Common::Rect(_x, _y, _x + _width, _y + _height));
- renderBlockWhole(_surface, (const byte *) codecSurf->pixels, rect);
+ renderBlockWhole(_surface, (const byte *)codecSurf->getPixels(), rect);
return true;
}
@@ -2298,7 +2291,7 @@ bool VMDDecoder::renderFrame(Common::Rect &rect) {
const int offsetY = (_y + rect.top) * _surface.pitch;
const int offset = offsetX + offsetY;
- if (deLZ77((byte *)_surface.pixels + offset, dataPtr, dataSize,
+ if (deLZ77((byte *)_surface.getPixels() + offset, dataPtr, dataSize,
_surface.w * _surface.h * _surface.format.bytesPerPixel - offset))
return true;
}
@@ -2406,10 +2399,11 @@ void VMDDecoder::blit16(const Graphics::Surface &srcSurf, Common::Rect &rect) {
Graphics::PixelFormat pixelFormat = getPixelFormat();
- const byte *src = (byte *)srcSurf.pixels +
+ // We cannot use getBasePtr here because srcSurf.format.bytesPerPixel is
+ // different from _bytesPerPixel.
+ const byte *src = (const byte *)srcSurf.getPixels() +
(srcRect.top * srcSurf.pitch) + srcRect.left * _bytesPerPixel;
- byte *dst = (byte *)_surface.pixels +
- ((_y + rect.top) * _surface.pitch) + (_x + rect.left) * _surface.format.bytesPerPixel;
+ byte *dst = (byte *)_surface.getBasePtr(_x + rect.left, _y + rect.top);
for (int i = 0; i < rect.height(); i++) {
const byte *srcRow = src;
@@ -2446,10 +2440,11 @@ void VMDDecoder::blit24(const Graphics::Surface &srcSurf, Common::Rect &rect) {
Graphics::PixelFormat pixelFormat = getPixelFormat();
- const byte *src = (byte *)srcSurf.pixels +
+ // We cannot use getBasePtr here because srcSurf.format.bytesPerPixel is
+ // different from _bytesPerPixel.
+ const byte *src = (const byte *)srcSurf.getPixels() +
(srcRect.top * srcSurf.pitch) + srcRect.left * _bytesPerPixel;
- byte *dst = (byte *)_surface.pixels +
- ((_y + rect.top) * _surface.pitch) + (_x + rect.left) * _surface.format.bytesPerPixel;
+ byte *dst = (byte *)_surface.getBasePtr(_x + rect.left, _y + rect.top);
for (int i = 0; i < rect.height(); i++) {
const byte *srcRow = src;
diff --git a/video/dxa_decoder.cpp b/video/dxa_decoder.cpp
index 5ac9bd2088..27b1664b07 100644
--- a/video/dxa_decoder.cpp
+++ b/video/dxa_decoder.cpp
@@ -521,17 +521,17 @@ const Graphics::Surface *DXADecoder::DXAVideoTrack::decodeNextFrame() {
memcpy(&_scaledBuffer[2 * cy * _width], &_frameBuffer1[cy * _width], _width);
memset(&_scaledBuffer[((2 * cy) + 1) * _width], 0, _width);
}
- _surface->pixels = _scaledBuffer;
+ _surface->setPixels(_scaledBuffer);
break;
case S_DOUBLE:
for (int cy = 0; cy < _curHeight; cy++) {
memcpy(&_scaledBuffer[2 * cy * _width], &_frameBuffer1[cy * _width], _width);
memcpy(&_scaledBuffer[((2 * cy) + 1) * _width], &_frameBuffer1[cy * _width], _width);
}
- _surface->pixels = _scaledBuffer;
+ _surface->setPixels(_scaledBuffer);
break;
case S_NONE:
- _surface->pixels = _frameBuffer1;
+ _surface->setPixels(_frameBuffer1);
break;
}
diff --git a/video/flic_decoder.cpp b/video/flic_decoder.cpp
index de545366b1..317dc14691 100644
--- a/video/flic_decoder.cpp
+++ b/video/flic_decoder.cpp
@@ -244,7 +244,7 @@ void FlicDecoder::FlicVideoTrack::copyDirtyRectsToBuffer(uint8 *dst, uint pitch)
for (Common::List<Common::Rect>::const_iterator it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
for (int y = (*it).top; y < (*it).bottom; ++y) {
const int x = (*it).left;
- memcpy(dst + y * pitch + x, (byte *)_surface->pixels + y * getWidth() + x, (*it).right - x);
+ memcpy(dst + y * pitch + x, (byte *)_surface->getBasePtr(x, y), (*it).right - x);
}
}
@@ -252,7 +252,7 @@ void FlicDecoder::FlicVideoTrack::copyDirtyRectsToBuffer(uint8 *dst, uint pitch)
}
void FlicDecoder::FlicVideoTrack::copyFrame(uint8 *data) {
- memcpy((byte *)_surface->pixels, data, getWidth() * getHeight());
+ memcpy((byte *)_surface->getPixels(), data, getWidth() * getHeight());
// Redraw
_dirtyRects.clear();
@@ -260,8 +260,8 @@ void FlicDecoder::FlicVideoTrack::copyFrame(uint8 *data) {
}
void FlicDecoder::FlicVideoTrack::decodeByteRun(uint8 *data) {
- byte *ptr = (byte *)_surface->pixels;
- while ((int32)(ptr - (byte *)_surface->pixels) < (getWidth() * getHeight())) {
+ byte *ptr = (byte *)_surface->getPixels();
+ while ((int32)(ptr - (byte *)_surface->getPixels()) < (getWidth() * getHeight())) {
int chunks = *data++;
while (chunks--) {
int count = (int8)*data++;
@@ -305,7 +305,7 @@ void FlicDecoder::FlicVideoTrack::decodeDeltaFLC(uint8 *data) {
case OP_UNDEFINED:
break;
case OP_LASTPIXEL:
- *((byte *)_surface->pixels + currentLine * getWidth() + getWidth() - 1) = (opcode & 0xFF);
+ *((byte *)_surface->getBasePtr(getWidth() - 1, currentLine)) = (opcode & 0xFF);
_dirtyRects.push_back(Common::Rect(getWidth() - 1, currentLine, getWidth(), currentLine + 1));
break;
case OP_LINESKIPCOUNT:
@@ -321,14 +321,14 @@ void FlicDecoder::FlicVideoTrack::decodeDeltaFLC(uint8 *data) {
column += *data++;
int rleCount = (int8)*data++;
if (rleCount > 0) {
- memcpy((byte *)_surface->pixels + (currentLine * getWidth()) + column, data, rleCount * 2);
+ memcpy((byte *)_surface->getBasePtr(column, currentLine), data, rleCount * 2);
data += rleCount * 2;
_dirtyRects.push_back(Common::Rect(column, currentLine, column + rleCount * 2, currentLine + 1));
} else if (rleCount < 0) {
rleCount = -rleCount;
uint16 dataWord = READ_UINT16(data); data += 2;
for (int i = 0; i < rleCount; ++i) {
- WRITE_UINT16((byte *)_surface->pixels + currentLine * getWidth() + column + i * 2, dataWord);
+ WRITE_UINT16((byte *)_surface->getBasePtr(column + i * 2, currentLine), dataWord);
}
_dirtyRects.push_back(Common::Rect(column, currentLine, column + rleCount * 2, currentLine + 1));
} else { // End of cutscene ?
diff --git a/video/smk_decoder.cpp b/video/smk_decoder.cpp
index b622a0ab61..3dbcebcde4 100644
--- a/video/smk_decoder.cpp
+++ b/video/smk_decoder.cpp
@@ -580,7 +580,7 @@ void SmackerDecoder::SmackerVideoTrack::decodeFrame(Common::BitStream &bs) {
while (run-- && block < blocks) {
clr = _MClrTree->getCode(bs);
map = _MMapTree->getCode(bs);
- out = (byte *)_surface->pixels + (block / bw) * (stride * 4 * doubleY) + (block % bw) * 4;
+ out = (byte *)_surface->getPixels() + (block / bw) * (stride * 4 * doubleY) + (block % bw) * 4;
hi = clr >> 8;
lo = clr & 0xff;
for (i = 0; i < 4; i++) {
@@ -613,7 +613,7 @@ void SmackerDecoder::SmackerVideoTrack::decodeFrame(Common::BitStream &bs) {
}
while (run-- && block < blocks) {
- out = (byte *)_surface->pixels + (block / bw) * (stride * 4 * doubleY) + (block % bw) * 4;
+ out = (byte *)_surface->getPixels() + (block / bw) * (stride * 4 * doubleY) + (block % bw) * 4;
switch (mode) {
case 0:
for (i = 0; i < 4; ++i) {
@@ -679,7 +679,7 @@ void SmackerDecoder::SmackerVideoTrack::decodeFrame(Common::BitStream &bs) {
uint32 col;
mode = type >> 8;
while (run-- && block < blocks) {
- out = (byte *)_surface->pixels + (block / bw) * (stride * 4 * doubleY) + (block % bw) * 4;
+ out = (byte *)_surface->getPixels() + (block / bw) * (stride * 4 * doubleY) + (block % bw) * 4;
col = mode * 0x01010101;
for (i = 0; i < 4 * doubleY; ++i) {
out[0] = out[1] = out[2] = out[3] = col;
diff --git a/video/theora_decoder.cpp b/video/theora_decoder.cpp
index 63aa93e2f5..53e528faf2 100644
--- a/video/theora_decoder.cpp
+++ b/video/theora_decoder.cpp
@@ -262,11 +262,8 @@ TheoraDecoder::TheoraVideoTrack::TheoraVideoTrack(const Graphics::PixelFormat &f
_surface.create(theoraInfo.frame_width, theoraInfo.frame_height, format);
// Set up a display surface
- _displaySurface.pixels = _surface.getBasePtr(theoraInfo.pic_x, theoraInfo.pic_y);
- _displaySurface.w = theoraInfo.pic_width;
- _displaySurface.h = theoraInfo.pic_height;
- _displaySurface.format = format;
- _displaySurface.pitch = _surface.pitch;
+ _displaySurface.init(theoraInfo.pic_width, theoraInfo.pic_height, _surface.pitch,
+ _surface.getBasePtr(theoraInfo.pic_x, theoraInfo.pic_y), format);
// Set the frame rate
_frameRate = Common::Rational(theoraInfo.fps_numerator, theoraInfo.fps_denominator);
@@ -280,7 +277,7 @@ TheoraDecoder::TheoraVideoTrack::~TheoraVideoTrack() {
th_decode_free(_theoraDecode);
_surface.free();
- _displaySurface.pixels = 0;
+ _displaySurface.setPixels(0);
}
bool TheoraDecoder::TheoraVideoTrack::decodePacket(ogg_packet &oggPacket) {
diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp
index 5df811008c..a512a49fac 100644
--- a/video/video_decoder.cpp
+++ b/video/video_decoder.cpp
@@ -336,9 +336,9 @@ bool VideoDecoder::seek(const Audio::Timestamp &time) {
if (isPlaying())
stopAudio();
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if (!(*it)->seek(time))
- return false;
+ // Do the actual seeking
+ if (!seekIntern(time))
+ return false;
_lastTimeChange = time;
@@ -471,6 +471,14 @@ Audio::Timestamp VideoDecoder::getDuration() const {
return maxDuration;
}
+bool VideoDecoder::seekIntern(const Audio::Timestamp &time) {
+ for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
+ if (!(*it)->seek(time))
+ return false;
+
+ return true;
+}
+
VideoDecoder::Track::Track() {
_paused = false;
}
diff --git a/video/video_decoder.h b/video/video_decoder.h
index d0a6e08005..7811734dd5 100644
--- a/video/video_decoder.h
+++ b/video/video_decoder.h
@@ -168,14 +168,15 @@ public:
/**
* Seek to a given time in the video.
*
- * If the video is playing, it will continue to play. The default
- * implementation will seek each track and must still be called
- * from any other implementation.
+ * If the video is playing, it will continue to play. This calls
+ * seekIntern(), which can be overriden. By default, seekIntern()
+ * will call Track::seek() on all tracks with the time passed to
+ * this function.
*
* @param time The time to seek to
* @return true on success, false otherwise
*/
- virtual bool seek(const Audio::Timestamp &time);
+ bool seek(const Audio::Timestamp &time);
/**
* Seek to a given frame.
@@ -820,6 +821,15 @@ protected:
*/
TrackListIterator getTrackListEnd() { return _tracks.end(); }
+ /**
+ * The internal seek function that does the actual seeking.
+ *
+ * @see seek()
+ *
+ * @return true on success, false otherwise
+ */
+ virtual bool seekIntern(const Audio::Timestamp &time);
+
private:
// Tracks owned by this VideoDecoder
TrackList _tracks;