aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorTravis Howell2009-07-06 06:21:59 +0000
committerTravis Howell2009-07-06 06:21:59 +0000
commitdc0f6dce7698ce383ad7ca82f8ae1dcba984a044 (patch)
tree91bd92cb5835a456efa42361d5b9fd5a8bf619db /engines
parent08df8dc2721808c7019f49d9051e2eebfe8dad9c (diff)
downloadscummvm-rg350-dc0f6dce7698ce383ad7ca82f8ae1dcba984a044.tar.gz
scummvm-rg350-dc0f6dce7698ce383ad7ca82f8ae1dcba984a044.tar.bz2
scummvm-rg350-dc0f6dce7698ce383ad7ca82f8ae1dcba984a044.zip
Use graphics surfaces for screen buffers, and always use correct pitch when writing to the frameBuffer.
svn-id: r42163
Diffstat (limited to 'engines')
-rw-r--r--engines/agos/agos.cpp35
-rw-r--r--engines/agos/agos.h12
-rw-r--r--engines/agos/charset-fontdata.cpp20
-rw-r--r--engines/agos/charset.cpp8
-rw-r--r--engines/agos/draw.cpp110
-rw-r--r--engines/agos/event.cpp4
-rw-r--r--engines/agos/gfx.cpp146
-rw-r--r--engines/agos/icons.cpp44
-rw-r--r--engines/agos/menus.cpp8
-rw-r--r--engines/agos/oracle.cpp40
-rw-r--r--engines/agos/verb.cpp4
-rw-r--r--engines/agos/vga.cpp25
-rw-r--r--engines/agos/vga_e2.cpp46
-rw-r--r--engines/agos/vga_pn.cpp2
-rw-r--r--engines/agos/vga_s2.cpp4
-rw-r--r--engines/agos/vga_ww.cpp20
-rw-r--r--engines/agos/window.cpp16
17 files changed, 305 insertions, 239 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp
index cdbeeecd8e..4a8170b2a4 100644
--- a/engines/agos/agos.cpp
+++ b/engines/agos/agos.cpp
@@ -33,6 +33,8 @@
#include "agos/agos.h"
#include "agos/vga.h"
+#include "graphics/surface.h"
+
#include "sound/mididrv.h"
#include "sound/mods/protracker.h"
#include "sound/audiocd.h"
@@ -182,8 +184,6 @@ AGOSEngine::AGOSEngine(OSystem *syst)
_subroutineList = 0;
- _dxSurfacePitch = 0;
-
_recursionDepth = 0;
_lastVgaTick = 0;
@@ -490,12 +490,13 @@ AGOSEngine::AGOSEngine(OSystem *syst)
_backGroundBuf = 0;
_backBuf = 0;
_scaleBuf = 0;
+ _window4BackScn = 0;
+ _window6BackScn = 0;
+ printf("Cleared all\n");
_window3Flag = 0;
_window4Flag = 0;
_window6Flag = 0;
- _window4BackScn = 0;
- _window6BackScn = 0;
_moveXMin = 0;
_moveYMin = 0;
@@ -580,26 +581,34 @@ Common::Error AGOSEngine::init() {
syncSoundSettings();
// allocate buffers
- _backGroundBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
+ _backGroundBuf = new Graphics::Surface();
+ _backGroundBuf->create(_screenWidth, _screenHeight, 1);
if (getGameType() == GType_FF || getGameType() == GType_PP) {
- _backBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
- _scaleBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
+ _backBuf = new Graphics::Surface();
+ _backBuf->create(_screenWidth, _screenHeight, 1);
+ _scaleBuf = new Graphics::Surface();
+ _scaleBuf->create(_screenWidth, _screenHeight, 1);
}
if (getGameType() == GType_SIMON2) {
- _window4BackScn = (byte *)calloc(_screenWidth * _screenHeight, 1);
+ _window4BackScn = new Graphics::Surface();
+ _window4BackScn->create(_screenWidth, _screenHeight, 1);
} else if (getGameType() == GType_SIMON1) {
- _window4BackScn = (byte *)calloc(_screenWidth * 134, 1);
+ _window4BackScn = new Graphics::Surface();
+ _window4BackScn->create(_screenWidth, 134, 1);
} else if (getGameType() == GType_WW || getGameType() == GType_ELVIRA2) {
- _window4BackScn = (byte *)calloc(224 * 127, 1);
+ _window4BackScn = new Graphics::Surface();
+ _window4BackScn->create(224, 127, 1);
} else if (getGameType() == GType_ELVIRA1) {
+ _window4BackScn = new Graphics::Surface();
if (getPlatform() == Common::kPlatformAmiga && (getFeatures() & GF_DEMO)) {
- _window4BackScn = (byte *)calloc(224 * 196, 1);
+ _window4BackScn->create(224, 196, 1);
} else {
- _window4BackScn = (byte *)calloc(224 * 144, 1);
+ _window4BackScn->create(224, 144, 1);
}
- _window6BackScn = (byte *)calloc(48 * 80, 1);
+ _window6BackScn = new Graphics::Surface();
+ _window6BackScn->create(48, 80, 1);
}
setupGame();
diff --git a/engines/agos/agos.h b/engines/agos/agos.h
index f6a85d498d..093f7bb039 100644
--- a/engines/agos/agos.h
+++ b/engines/agos/agos.h
@@ -276,8 +276,6 @@ protected:
Subroutine *_subroutineList;
- uint16 _dxSurfacePitch;
-
uint8 _recursionDepth;
uint32 _lastVgaTick;
@@ -527,8 +525,6 @@ protected:
uint8 _window3Flag;
uint8 _window4Flag;
uint8 _window6Flag;
- byte *_window4BackScn;
- byte *_window6BackScn;
uint16 _moveXMin, _moveYMin;
uint16 _moveXMax, _moveYMax;
@@ -566,9 +562,11 @@ protected:
byte _saveLoadType, _saveLoadSlot;
char _saveLoadName[108];
- byte *_backGroundBuf;
- byte *_backBuf;
- byte *_scaleBuf;
+ Graphics::Surface *_backGroundBuf;
+ Graphics::Surface *_backBuf;
+ Graphics::Surface *_scaleBuf;
+ Graphics::Surface *_window4BackScn;
+ Graphics::Surface *_window6BackScn;
Common::RandomSource _rnd;
diff --git a/engines/agos/charset-fontdata.cpp b/engines/agos/charset-fontdata.cpp
index d23e772306..1cbc4f95dc 100644
--- a/engines/agos/charset-fontdata.cpp
+++ b/engines/agos/charset-fontdata.cpp
@@ -2090,7 +2090,7 @@ static const byte english_pnFont[] = {
void AGOSEngine::windowDrawChar(WindowBlock *window, uint x, uint y, byte chr) {
const byte *src;
byte color, *dst;
- uint h, w, i;
+ uint dstPitch, h, w, i;
if (_noOracleScroll)
return;
@@ -2100,7 +2100,8 @@ void AGOSEngine::windowDrawChar(WindowBlock *window, uint x, uint y, byte chr) {
Graphics::Surface *screen = _system->lockScreen();
if (getGameType() == GType_FF || getGameType() == GType_PP) {
- dst = getBackGround() + y * _dxSurfacePitch + x + window->textColumnOffset;
+ dst = getBackGround();
+ dstPitch = _backGroundBuf->pitch;
h = 13;
w = getFeebleFontSize(chr);
@@ -2109,7 +2110,8 @@ void AGOSEngine::windowDrawChar(WindowBlock *window, uint x, uint y, byte chr) {
else
src = feeble_windowFont + (chr - 32) * 13;
} else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) {
- dst = (byte *)screen->pixels + y * _dxSurfacePitch + x + window->textColumnOffset;
+ dst = (byte *)screen->pixels;
+ dstPitch = screen->pitch;
h = 8;
w = 6;
@@ -2145,7 +2147,8 @@ 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 + y * _dxSurfacePitch + x + window->textColumnOffset;
+ dst = (byte *)screen->pixels;
+ dstPitch = screen->pitch;
h = 8;
w = 6;
@@ -2169,18 +2172,21 @@ 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 + y * _dxSurfacePitch + x + window->textColumnOffset;
+ dst = (byte *)screen->pixels;
+ dstPitch = screen->pitch;
h = 8;
w = 6;
src = english_elvira1Font + (chr - 32) * 8;
} else {
- dst = (byte *)screen->pixels + y * _dxSurfacePitch + x + window->textColumnOffset;
+ dst = (byte *)screen->pixels;
+ dstPitch = screen->pitch;
h = 8;
w = 8;
src = english_pnFont + (chr - 32) * 8;
}
+ dst += y * dstPitch + x + window->textColumnOffset;
color = window->textColor;
if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW)
@@ -2201,7 +2207,7 @@ void AGOSEngine::windowDrawChar(WindowBlock *window, uint x, uint y, byte chr) {
b <<= 1;
} while (++i != w);
- dst += _dxSurfacePitch;
+ dst += dstPitch;
} while (--h);
_system->unlockScreen();
diff --git a/engines/agos/charset.cpp b/engines/agos/charset.cpp
index c60640d761..5b0a694312 100644
--- a/engines/agos/charset.cpp
+++ b/engines/agos/charset.cpp
@@ -639,13 +639,13 @@ void AGOSEngine::windowScroll(WindowBlock *window) {
w = window->width * 8;
h = (window->height -1) * 8;
- dst = (byte *)screen->pixels + window->y * _screenWidth + window->x * 8;
- src = dst + 8 * _screenWidth;
+ dst = (byte *)screen->pixels + window->y * screen->pitch + window->x * 8;
+ src = dst + 8 * screen->pitch;
do {
memcpy(dst, src, w);
- src += _screenWidth;
- dst += _screenWidth;
+ src += screen->pitch;
+ dst += screen->pitch;
} while (--h);
_system->unlockScreen();
diff --git a/engines/agos/draw.cpp b/engines/agos/draw.cpp
index 19520e66e9..d09f02c76d 100644
--- a/engines/agos/draw.cpp
+++ b/engines/agos/draw.cpp
@@ -35,18 +35,15 @@
namespace AGOS {
byte *AGOSEngine::getBackBuf() {
- _dxSurfacePitch = _screenWidth;
- return _backBuf;
+ return (byte *)_backBuf->pixels;
}
byte *AGOSEngine::getBackGround() {
- _dxSurfacePitch = _screenWidth;
- return _backGroundBuf;
+ return (byte *)_backGroundBuf->pixels;
}
byte *AGOSEngine::getScaleBuf() {
- _dxSurfacePitch = _screenWidth;
- return _scaleBuf;
+ return (byte *)_scaleBuf->pixels;
}
void AGOSEngine_Feeble::animateSpritesByY() {
@@ -166,7 +163,7 @@ void AGOSEngine::animateSprites() {
_wallOn--;
VC10_state state;
- state.srcPtr = getBackGround() + 3 * _screenWidth + 3 * 16;
+ state.srcPtr = getBackGround() + 3 * _backGroundBuf->pitch + 3 * 16;
state.height = state.draw_height = 127;
state.width = state.draw_width = 14;
state.y = 0;
@@ -230,7 +227,7 @@ void AGOSEngine::animateSprites() {
debug(0, "Using special wall");
uint8 color, h, len;
- byte *dst = _window4BackScn;
+ byte *dst = (byte *)_window4BackScn->pixels;
color = (_variableArray[293] & 1) ? 13 : 15;
_wallOn = 2;
@@ -260,7 +257,7 @@ void AGOSEngine::animateSprites() {
} else if (getGameType() == GType_ELVIRA2 && _variableArray[71] & 2) {
// Used by the Unholy Barrier spell
uint8 color, h, len;
- byte *dst = _window4BackScn;
+ byte *dst = (byte *)_window4BackScn->pixels;
color = 1;
_wallOn = 2;
@@ -495,11 +492,11 @@ void AGOSEngine::saveBackGround(VgaSprite *vsp) {
int16 y = vsp->y - _scrollY;
if (_window3Flag == 1) {
- animTable->srcPtr = (const byte *)_window4BackScn;
+ animTable->srcPtr = (const byte *)_window4BackScn->pixels;
} else {
int xoffs = (_videoWindows[vsp->windowNum * 4 + 0] * 2 + x) * 8;
int yoffs = (_videoWindows[vsp->windowNum * 4 + 1] + y);
- animTable->srcPtr = getBackGround() + xoffs + yoffs * _screenWidth;
+ animTable->srcPtr = getBackGround() + yoffs * _backGroundBuf->pitch + xoffs;
}
animTable->x = x;
@@ -571,39 +568,39 @@ void AGOSEngine::displayBoxStars() {
dst = (byte *)screen->pixels;
- dst += (((_dxSurfacePitch / 4) * y_) * 4) + x_;
+ dst += (((screen->pitch / 4) * y_) * 4) + x_;
- b = _dxSurfacePitch;
+ b = screen->pitch;
dst[4] = color;
dst[b+1] = color;
dst[b+4] = color;
dst[b+7] = color;
- b += _dxSurfacePitch;
+ b += screen->pitch;
dst[b+2] = color;
dst[b+4] = color;
dst[b+6] = color;
- b += _dxSurfacePitch;
+ b += screen->pitch;
dst[b+3] = color;
dst[b+5] = color;
- b += _dxSurfacePitch;
+ b += screen->pitch;
dst[b] = color;
dst[b+1] = color;
dst[b+2] = color;
dst[b+6] = color;
dst[b+7] = color;
dst[b+8] = color;
- b += _dxSurfacePitch;
+ b += screen->pitch;
dst[b+3] = color;
dst[b+5] = color;
- b += _dxSurfacePitch;
+ b += screen->pitch;
dst[b+2] = color;
dst[b+4] = color;
dst[b+6] = color;
- b += _dxSurfacePitch;
+ b += screen->pitch;
dst[b+1] = color;
dst[b+4] = color;
dst[b+7] = color;
- b += _dxSurfacePitch;
+ b += screen->pitch;
dst[b+4] = color;
}
} while (ha++, --count);
@@ -645,7 +642,7 @@ void AGOSEngine::scrollScreen() {
}
src = _scrollImage + y / 2;
- decodeRow(dst, src + readUint32Wrapper(src), _scrollWidth, _dxSurfacePitch);
+ decodeRow(dst, src + readUint32Wrapper(src), _scrollWidth, _backGroundBuf->pitch);
_scrollY += _scrollFlag;
vcWriteVar(250, _scrollY);
@@ -670,13 +667,19 @@ void AGOSEngine::scrollScreen() {
src = _scrollImage + x / 2;
else
src = _scrollImage + x * 4;
- decodeColumn(dst, src + readUint32Wrapper(src), _scrollHeight, _dxSurfacePitch);
+ decodeColumn(dst, src + readUint32Wrapper(src), _scrollHeight, _backGroundBuf->pitch);
_scrollX += _scrollFlag;
vcWriteVar(251, _scrollX);
if (getGameType() == GType_SIMON2) {
- memcpy(_window4BackScn, _backGroundBuf, _scrollHeight * _screenWidth);
+ src = getBackGround();
+ dst = (byte *)_window4BackScn->pixels;
+ for (int i = 0; i < _scrollHeight; i++) {
+ memcpy(dst, src, _screenWidth);
+ src += _backGroundBuf->pitch;
+ dst += _window4BackScn->pitch;
+ }
} else {
fillBackFromBackGround(_scrollHeight, _screenWidth);
}
@@ -707,27 +710,53 @@ void AGOSEngine::clearSurfaces() {
_system->fillScreen(0);
if (_backBuf) {
- memset(_backBuf, 0, _screenHeight * _screenWidth);
+ memset(getBackBuf(), 0, _backBuf->h * _backBuf->pitch);
}
}
void AGOSEngine::fillBackFromBackGround(uint16 height, uint16 width) {
- memcpy(_backBuf, _backGroundBuf, height * width);
+ byte *src = getBackGround();
+ byte *dst = getBackBuf();
+ for (int i = 0; i < height; i++) {
+ memcpy(dst, src, width);
+ src += _backGroundBuf->pitch;
+ dst += _backBuf->pitch;
+ }
}
void AGOSEngine::fillBackFromFront() {
Graphics::Surface *screen = _system->lockScreen();
- memcpy(_backBuf, (byte *)screen->pixels, _screenHeight * _screenWidth);
+ byte *src = (byte *)screen->pixels;
+ byte *dst = getBackBuf();
+
+ for (int i = 0; i < _screenHeight; i++) {
+ memcpy(dst, src, _screenWidth);
+ src += screen->pitch;
+ dst += _backBuf->pitch;
+ }
_system->unlockScreen();
}
void AGOSEngine::fillBackGroundFromBack() {
- memcpy(_backGroundBuf, _backBuf, _screenHeight * _screenWidth);
+ byte *src = getBackBuf();
+ byte *dst = getBackGround();
+ for (int i = 0; i < _screenHeight; i++) {
+ memcpy(dst, src, _screenWidth);
+ src += _backBuf->pitch;
+ dst += _backGroundBuf->pitch;
+ }
}
void AGOSEngine::fillBackGroundFromFront() {
Graphics::Surface *screen = _system->lockScreen();
- memcpy(_backGroundBuf, (byte *)screen->pixels, _screenHeight * _screenWidth);
+ byte *src = (byte *)screen->pixels;
+ byte *dst = getBackGround();
+
+ for (int i = 0; i < _screenHeight; i++) {
+ memcpy(dst, src, _screenWidth);
+ src += screen->pitch;
+ dst += _backGroundBuf->pitch;
+ }
_system->unlockScreen();
}
@@ -756,8 +785,13 @@ void AGOSEngine::displayScreen() {
Graphics::Surface *screen = _system->lockScreen();
if (getGameType() == GType_PP || getGameType() == GType_FF) {
- memcpy((byte *)screen->pixels, getBackBuf(), _screenWidth * _screenHeight);
-
+ byte *src = getBackBuf();
+ byte *dst = (byte *)screen->pixels;
+ for (int i = 0; i < _screenHeight; i++) {
+ memcpy(dst, src, _screenWidth);
+ src += _backBuf->pitch;
+ dst += screen->pitch;
+ }
if (getGameId() != GID_DIMP)
fillBackFromBackGround(_screenHeight, _screenWidth);
} else {
@@ -767,12 +801,12 @@ void AGOSEngine::displayScreen() {
uint16 srcWidth, width, height;
byte *dst = (byte *)screen->pixels;
- const byte *src = _window4BackScn;
+ const byte *src = (const byte *)_window4BackScn->pixels;
if (_window3Flag == 1) {
src = getBackGround();
}
- dst += (_moveYMin + _videoWindows[17]) * _screenWidth;
+ dst += (_moveYMin + _videoWindows[17]) * screen->pitch;
dst += (_videoWindows[16] * 16) + _moveXMin;
src += (_videoWindows[18] * 16 * _moveYMin);
@@ -785,7 +819,7 @@ void AGOSEngine::displayScreen() {
for (; height > 0; height--) {
memcpy(dst, src, width);
- dst += _screenWidth;
+ dst += screen->pitch;
src += srcWidth;
}
@@ -798,12 +832,12 @@ void AGOSEngine::displayScreen() {
if (_window6Flag == 2) {
_window6Flag = 0;
- byte *src = _window6BackScn;
- byte *dst = (byte *)screen->pixels + 16320;
+ byte *src = (byte *)_window6BackScn->pixels;
+ byte *dst = (byte *)screen->pixels + 51 * screen->pitch;
for (int i = 0; i < 80; i++) {
- memcpy(dst, src, 48);
- dst += _screenWidth;
- src += 48;
+ memcpy(dst, src, _window6BackScn->w);
+ dst += screen->pitch;
+ src += _window6BackScn->pitch;
}
}
}
diff --git a/engines/agos/event.cpp b/engines/agos/event.cpp
index ad7b079d53..b9c16d3d86 100644
--- a/engines/agos/event.cpp
+++ b/engines/agos/event.cpp
@@ -367,12 +367,12 @@ 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 * _screenWidth + xoffs;
+ byte *dst = (byte *)screen->pixels + y * screen->pitch + xoffs;
for (uint h = 0; h < 6; h++) {
memcpy(dst, src, 4);
src += 4;
- dst += _screenWidth;
+ dst += screen->pitch;
}
_system->unlockScreen();
diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp
index 4b2d2b3321..1755391ac3 100644
--- a/engines/agos/gfx.cpp
+++ b/engines/agos/gfx.cpp
@@ -272,13 +272,13 @@ void AGOSEngine_Feeble::scaleClip(int16 h, int16 w, int16 y, int16 x, int16 scro
byte *src = getScaleBuf();
byte *dst = getBackBuf();
- dst += _dxSurfacePitch * dstRect.top + dstRect.left;
+ dst += dstRect.top * _backBuf->pitch + dstRect.left;
for (int dstY = 0; dstY < scaledH; dstY++) {
if (dstRect.top + dstY >= 0 && dstRect.top + dstY < _screenHeight) {
int srcY = (dstY * h) / scaledH;
- byte *srcPtr = src + _dxSurfacePitch * srcY;
- byte *dstPtr = dst + _dxSurfacePitch * dstY;
+ byte *srcPtr = src + _scaleBuf->pitch * srcY;
+ byte *dstPtr = dst + _backBuf->pitch * dstY;
for (int dstX = 0; dstX < scaledW; dstX++) {
if (dstRect.left + dstX >= 0 && dstRect.left + dstX < _screenWidth) {
int srcX = (dstX * w) / scaledW;
@@ -292,12 +292,12 @@ void AGOSEngine_Feeble::scaleClip(int16 h, int16 w, int16 y, int16 x, int16 scro
void AGOSEngine_Feeble::drawImage(VC10_state *state) {
state->surf_addr = getBackBuf();
- state->surf_pitch = _dxSurfacePitch;
+ state->surf_pitch = _backBuf->pitch;
if (state->flags & kDFCompressed) {
if (state->flags & kDFScaled) {
state->surf_addr = getScaleBuf();
- state->surf_pitch = _dxSurfacePitch;
+ state->surf_pitch = _scaleBuf->pitch;
uint w, h;
byte *src, *dst, *dstPtr;
@@ -314,7 +314,7 @@ void AGOSEngine_Feeble::drawImage(VC10_state *state) {
h = 0;
do {
*dst = *src;
- dst += _screenWidth;
+ dst += state->surf_pitch;
src++;
} while (++h != state->draw_height);
dstPtr++;
@@ -330,7 +330,7 @@ void AGOSEngine_Feeble::drawImage(VC10_state *state) {
}
} else if (state->flags & kDFOverlayed) {
state->surf_addr = getScaleBuf();
- state->surf_pitch = _dxSurfacePitch;
+ state->surf_pitch = _scaleBuf->pitch;
state->surf_addr += (state->x + _scrollX) + (state->y + _scrollY) * state->surf_pitch;
uint w, h;
@@ -352,7 +352,7 @@ void AGOSEngine_Feeble::drawImage(VC10_state *state) {
color = *src;
if (color != 0)
*dst = color;
- dst += _screenWidth;
+ dst += state->surf_pitch;
src++;
} while (++h != state->draw_height);
dstPtr++;
@@ -406,7 +406,7 @@ void AGOSEngine_Feeble::drawImage(VC10_state *state) {
color = *src;
if (color)
*dst = color;
- dst += _screenWidth;
+ dst += state->surf_pitch;
src++;
} while (++h != state->draw_height);
dstPtr++;
@@ -425,7 +425,7 @@ void AGOSEngine_Feeble::drawImage(VC10_state *state) {
color = *src;
if ((state->flags & kDFNonTrans) || color != 0)
*dst = color;
- dst += _screenWidth;
+ dst += state->surf_pitch;
src++;
} while (++h != state->draw_height);
dstPtr++;
@@ -456,7 +456,7 @@ void AGOSEngine_Feeble::drawImage(VC10_state *state) {
dst[count] = color;
}
}
- dst += _screenWidth;
+ dst += state->surf_pitch;
src += state->width;
} while (--state->draw_height);
}
@@ -557,8 +557,8 @@ void AGOSEngine_Simon1::drawMaskedImage(VC10_state *state) {
dst[count * 2 + 1] = src[count * 2 + 1];
}
}
- src += _screenWidth;
- dst += _screenWidth;
+ src += state->surf2_pitch;
+ dst += state->surf_pitch;
mask += state->width * 8;
} while (--state->draw_height);
}
@@ -615,7 +615,7 @@ void AGOSEngine_Simon1::draw32ColorImage(VC10_state *state) {
dst += 8;
src += 5;
} while (--count);
- dstPtr += _screenWidth;
+ dstPtr += state->surf_pitch;
} while (--state->draw_height);
} else {
src = state->srcPtr + (state->width * state->y_skip * 16) + (state->x_skip * 8);
@@ -628,7 +628,7 @@ void AGOSEngine_Simon1::draw32ColorImage(VC10_state *state) {
for (i = 0; i != state->draw_width; i++)
if ((state->flags & kDFNonTrans) || src[i])
dst[i] = src[i] + state->paletteMod;
- dst += _screenWidth;
+ dst += state->surf_pitch;
src += state->width * 16;
} while (--h);
}
@@ -648,10 +648,10 @@ void AGOSEngine_Simon1::drawImage(VC10_state *state) {
uint16 xoffs, yoffs;
if (getGameType() == GType_SIMON2) {
state->surf2_addr = getBackGround();
- state->surf2_pitch = _screenWidth;
+ state->surf2_pitch = _backGroundBuf->pitch;
- state->surf_addr = _window4BackScn;
- state->surf_pitch = _screenWidth;
+ state->surf_addr = (byte *)_window4BackScn->pixels;
+ state->surf_pitch = _window4BackScn->pitch;
xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
yoffs = (vlut[1] - _videoWindows[17] + state->y);
@@ -665,9 +665,9 @@ void AGOSEngine_Simon1::drawImage(VC10_state *state) {
// The DOS Floppy demo was based off Waxworks engine
if (_windowNum == 4 || (_windowNum >= 10 && _windowNum <= 27)) {
state->surf2_addr = getBackGround();
- state->surf2_pitch = _screenWidth;
+ state->surf2_pitch = _backGroundBuf->pitch;
- state->surf_addr = _window4BackScn;
+ state->surf_addr = (byte *)_window4BackScn;
state->surf_pitch = _videoWindows[18] * 16;
xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
@@ -680,7 +680,7 @@ void AGOSEngine_Simon1::drawImage(VC10_state *state) {
_window4Flag = 1;
} else {
state->surf_addr = (byte *)screen->pixels;
- state->surf_pitch = _screenWidth;
+ state->surf_pitch = screen->pitch;
xoffs = (vlut[0] * 2 + state->x) * 8;
yoffs = vlut[1] + state->y;
@@ -689,16 +689,16 @@ void AGOSEngine_Simon1::drawImage(VC10_state *state) {
if (_windowNum == 3 || _windowNum == 4 || _windowNum >= 10) {
if (_window3Flag == 1) {
state->surf2_addr = getBackGround();
- state->surf2_pitch = _screenWidth;
+ state->surf2_pitch = _backGroundBuf->pitch;
state->surf_addr = getBackGround();
- state->surf_pitch = _screenWidth;
+ state->surf_pitch = _backGroundBuf->pitch;
} else {
state->surf2_addr = getBackGround();
- state->surf2_pitch = _screenWidth;
+ state->surf2_pitch = _backGroundBuf->pitch;
- state->surf_addr = _window4BackScn;
- state->surf_pitch = _screenWidth;
+ state->surf_addr = (byte *)_window4BackScn->pixels;
+ state->surf_pitch = _window4BackScn->pitch;
}
xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
@@ -711,10 +711,10 @@ void AGOSEngine_Simon1::drawImage(VC10_state *state) {
_window4Flag = 1;
} else {
state->surf2_addr = getBackGround();
- state->surf2_pitch = _screenWidth;
+ state->surf2_pitch = _backGroundBuf->pitch;
state->surf_addr = (byte *)screen->pixels;
- state->surf_pitch = _screenWidth;
+ state->surf_pitch = screen->pitch;
xoffs = (vlut[0] * 2 + state->x) * 8;
yoffs = vlut[1] + state->y;
@@ -862,7 +862,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 = _window4BackScn;
+ state->surf_addr = (byte *)_window4BackScn->pixels;
state->surf_pitch = _videoWindows[18] * 16;
xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
@@ -875,14 +875,14 @@ void AGOSEngine::drawImage(VC10_state *state) {
_window4Flag = 1;
} else {
state->surf_addr = (byte *)screen->pixels;
- state->surf_pitch = _screenWidth;
+ state->surf_pitch = screen->pitch;
xoffs = (vlut[0] * 2 + state->x) * 8;
yoffs = vlut[1] + state->y;
}
} else if (getGameType() == GType_ELVIRA2) {
if (_windowNum == 4 || _windowNum >= 10) {
- state->surf_addr = _window4BackScn;
+ state->surf_addr = (byte *)_window4BackScn->pixels;
state->surf_pitch = _videoWindows[18] * 16;
xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
@@ -895,26 +895,26 @@ void AGOSEngine::drawImage(VC10_state *state) {
_window4Flag = 1;
} else {
state->surf_addr = (byte *)screen->pixels;
- state->surf_pitch = _screenWidth;
+ state->surf_pitch = screen->pitch;
xoffs = (vlut[0] * 2 + state->x) * 8;
yoffs = vlut[1] + state->y;
}
} else if (getGameType() == GType_ELVIRA1) {
if (_windowNum == 6) {
- state->surf_addr = _window6BackScn;
- state->surf_pitch = 48;
+ state->surf_addr = (byte *)_window6BackScn->pixels;
+ 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_pitch = _screenWidth;
+ state->surf_pitch = screen->pitch;
xoffs = (vlut[0] * 2 + state->x) * 8;
yoffs = vlut[1] + state->y;
} else {
- state->surf_addr = _window4BackScn;
+ state->surf_addr = (byte *)_window4BackScn->pixels;
state->surf_pitch = _videoWindows[18] * 16;
xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
@@ -928,7 +928,7 @@ void AGOSEngine::drawImage(VC10_state *state) {
}
} else {
state->surf_addr = (byte *)screen->pixels;
- state->surf_pitch = _screenWidth;
+ state->surf_pitch = screen->pitch;
xoffs = (vlut[0] * 2 + state->x) * 8;
yoffs = vlut[1] + state->y;
@@ -957,7 +957,7 @@ void AGOSEngine::drawImage(VC10_state *state) {
void AGOSEngine::horizontalScroll(VC10_state *state) {
const byte *src;
byte *dst;
- int w;
+ int dstPitch, w;
if (getGameType() == GType_FF)
_scrollXMax = state->width - 640;
@@ -974,9 +974,11 @@ void AGOSEngine::horizontalScroll(VC10_state *state) {
vcWriteVar(251, _scrollX);
if (getGameType() == GType_SIMON2) {
- dst = _window4BackScn;
+ dst = (byte *)_window4BackScn->pixels;
+ dstPitch = _window4BackScn->pitch;
} else {
dst = getBackBuf();
+ dstPitch = _backBuf->pitch;
}
if (getGameType() == GType_FF)
@@ -985,7 +987,7 @@ void AGOSEngine::horizontalScroll(VC10_state *state) {
src = state->srcPtr + _scrollX * 4;
for (w = 0; w < _screenWidth; w += 8) {
- decodeColumn(dst, src + readUint32Wrapper(src), state->height, _dxSurfacePitch);
+ decodeColumn(dst, src + readUint32Wrapper(src), state->height, dstPitch);
dst += 8;
src += 4;
}
@@ -1015,7 +1017,7 @@ void AGOSEngine::verticalScroll(VC10_state *state) {
src = state->srcPtr + _scrollY / 2;
for (h = 0; h < _screenHeight; h += 8) {
- decodeRow(dst, src + READ_LE_UINT32(src), state->width, _dxSurfacePitch);
+ decodeRow(dst, src + READ_LE_UINT32(src), state->width, _backBuf->pitch);
dst += 8 * state->width;
src += 4;
}
@@ -1366,21 +1368,21 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vgaSpriteId, bool specialCas
uint height = _videoWindows[updateWindow * 4 + 3];
Graphics::Surface *screen = _system->lockScreen();
- byte *dst = getBackGround() + xoffs + yoffs * _screenWidth;
+ byte *dst = (byte *)_backGroundBuf->getBasePtr(xoffs, yoffs);
byte *src = 0;
uint srcWidth = 0;
if (getGameType() == GType_SIMON2) {
- src = _window4BackScn + xoffs + yoffs * 320;
+ src = (byte *)_window4BackScn->getBasePtr(xoffs, yoffs);
srcWidth = 320;
} else if (getGameType() == GType_SIMON1 && (getFeatures() & GF_DEMO)) {
// The DOS Floppy demo was based off Waxworks engine
if (updateWindow == 4 || updateWindow >= 10) {
- src = _window4BackScn;
+ src = (byte *)_window4BackScn->pixels;
srcWidth = _videoWindows[18] * 16;
} else if (updateWindow == 3 || updateWindow == 9) {
- src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
- srcWidth = _screenWidth;
+ src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+ srcWidth = screen->pitch;
} else {
_system->unlockScreen();
_videoLockOut &= ~0x20;
@@ -1388,14 +1390,14 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vgaSpriteId, bool specialCas
}
} else if (getGameType() == GType_SIMON1) {
if (updateWindow == 4) {
- src = _window4BackScn;
+ src = (byte *)_window4BackScn->pixels;
srcWidth = _videoWindows[18] * 16;
} else if (updateWindow >= 10) {
- src = _window4BackScn + xoffs + yoffs * 320;
+ src = (byte *)_window4BackScn->pixels + xoffs + yoffs * 320;
srcWidth = _videoWindows[18] * 16;
} else if (updateWindow == 0) {
- src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
- srcWidth = _screenWidth;
+ src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+ srcWidth = screen->pitch;
} else {
_system->unlockScreen();
_videoLockOut &= ~0x20;
@@ -1403,11 +1405,11 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vgaSpriteId, bool specialCas
}
} else if (getGameType() == GType_WW) {
if (updateWindow == 4 || updateWindow >= 10) {
- src = _window4BackScn;
+ src = (byte *)_window4BackScn->pixels;
srcWidth = _videoWindows[18] * 16;
} else if (updateWindow == 3 || updateWindow == 9) {
- src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
- srcWidth = _screenWidth;
+ src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+ srcWidth = screen->pitch;
} else {
_system->unlockScreen();
_videoLockOut &= ~0x20;
@@ -1415,11 +1417,11 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vgaSpriteId, bool specialCas
}
} else if (getGameType() == GType_ELVIRA2) {
if (updateWindow == 4 || updateWindow >= 10) {
- src = _window4BackScn;
+ src = (byte *)_window4BackScn->pixels;
srcWidth = _videoWindows[18] * 16;
} else if (updateWindow == 3) {
- src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
- srcWidth = _screenWidth;
+ src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+ srcWidth = screen->pitch;
} else {
_system->unlockScreen();
_videoLockOut &= ~0x20;
@@ -1428,25 +1430,25 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vgaSpriteId, bool specialCas
} else if (getGameType() == GType_ELVIRA1) {
if (updateWindow == 6) {
_window6Flag = 1;
- src = _window6BackScn;
+ src = (byte *)_window6BackScn->pixels;
srcWidth = 48;
} else if (updateWindow == 2 || updateWindow == 3) {
- src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
- srcWidth = _screenWidth;
+ src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+ srcWidth = screen->pitch;
} else {
- src = _window4BackScn;
+ src = (byte *)_window4BackScn->pixels;
srcWidth = _videoWindows[18] * 16;
}
} else {
- src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
- srcWidth = _screenWidth;
+ src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+ srcWidth = screen->pitch;
}
_boxStarHeight = height;
for (; height > 0; height--) {
memcpy(dst, src, width);
- dst += _screenWidth;
+ dst += _backGroundBuf->pitch;
src += srcWidth;
}
@@ -1455,15 +1457,15 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vgaSpriteId, bool specialCas
dst = (byte *)screen->pixels + 48;
memset(dst, color, 224);
- dst = (byte *)screen->pixels + 132 * _screenWidth + 48;
+ dst = (byte *)screen->pixels + 132 * screen->pitch + 48;
memset(dst, color, 224);
} else if (getGameType() == GType_ELVIRA1 && updateWindow == 3 && _bottomPalette) {
- dst = (byte *)screen->pixels + 133 * _screenWidth;
- int size = 67 * _screenWidth;
+ dst = (byte *)screen->pixels + 133 * screen->pitch;
- while (size--) {
- *dst += 0x10;
- dst++;
+ for (int h = 0; h < 67; h++) {
+ for (int w = 0; w < _screenWidth; w++)
+ dst[w] += 0x10;
+ dst += screen->pitch;
}
}
@@ -1480,16 +1482,16 @@ void AGOSEngine::drawEdging() {
Graphics::Surface *screen = _system->lockScreen();
- dst = (byte *)screen->pixels + 136 * _screenWidth;
+ dst = (byte *)screen->pixels + 136 * screen->pitch;
uint8 len = 52;
while (len--) {
dst[0] = color;
dst[319] = color;
- dst += _screenWidth;
+ dst += screen->pitch;
}
- dst = (byte *)screen->pixels + 187 * _screenWidth;
+ dst = (byte *)screen->pixels + 187 * screen->pitch;
memset(dst, color, _screenWidth);
_system->unlockScreen();
diff --git a/engines/agos/icons.cpp b/engines/agos/icons.cpp
index 0472b1192b..2fd93e64f2 100644
--- a/engines/agos/icons.cpp
+++ b/engines/agos/icons.cpp
@@ -211,15 +211,15 @@ void AGOSEngine_Simon2::drawIcon(WindowBlock *window, uint icon, uint x, uint y)
dst += 110;
dst += x;
- dst += (y + window->y) * _dxSurfacePitch;
+ dst += (y + window->y) * screen->pitch;
src = _iconFilePtr;
src += READ_LE_UINT16(src + icon * 4 + 0);
- decompressIcon(dst, src, 20, 10, 224, _dxSurfacePitch);
+ decompressIcon(dst, src, 20, 10, 224, screen->pitch);
src = _iconFilePtr;
src += READ_LE_UINT16(src + icon * 4 + 2);
- decompressIcon(dst, src, 20, 10, 208, _dxSurfacePitch);
+ decompressIcon(dst, src, 20, 10, 208, screen->pitch);
_system->unlockScreen();
@@ -236,17 +236,17 @@ void AGOSEngine_Simon1::drawIcon(WindowBlock *window, uint icon, uint x, uint y)
dst = (byte *)screen->pixels;
dst += (x + window->x) * 8;
- dst += (y * 25 + window->y) * _dxSurfacePitch;
+ dst += (y * 25 + window->y) * screen->pitch;
if (getPlatform() == Common::kPlatformAmiga) {
src = _iconFilePtr;
src += READ_BE_UINT32(src + icon * 4);
uint8 color = (getFeatures() & GF_32COLOR) ? 224 : 240;
- decompressIconPlanar(dst, src, 24, 12, color, _dxSurfacePitch);
+ decompressIconPlanar(dst, src, 24, 12, color, screen->pitch);
} else {
src = _iconFilePtr;
src += READ_LE_UINT16(src + icon * 2);
- decompressIcon(dst, src, 24, 12, 224, _dxSurfacePitch);
+ decompressIcon(dst, src, 24, 12, 224, screen->pitch);
}
_system->unlockScreen();
@@ -264,17 +264,17 @@ void AGOSEngine_Waxworks::drawIcon(WindowBlock *window, uint icon, uint x, uint
dst = (byte *)screen->pixels;
dst += (x + window->x) * 8;
- dst += (y * 20 + window->y) * _dxSurfacePitch;
+ dst += (y * 20 + window->y) * screen->pitch;
uint8 color = dst[0] & 0xF0;
if (getPlatform() == Common::kPlatformAmiga) {
src = _iconFilePtr;
src += READ_BE_UINT32(src + icon * 4);
- decompressIconPlanar(dst, src, 24, 10, color, _dxSurfacePitch);
+ decompressIconPlanar(dst, src, 24, 10, color, screen->pitch);
} else {
src = _iconFilePtr;
src += READ_LE_UINT16(src + icon * 2);
- decompressIcon(dst, src, 24, 10, color, _dxSurfacePitch);
+ decompressIcon(dst, src, 24, 10, color, screen->pitch);
}
_system->unlockScreen();
@@ -292,17 +292,17 @@ void AGOSEngine_Elvira2::drawIcon(WindowBlock *window, uint icon, uint x, uint y
dst = (byte *)screen->pixels;
dst += (x + window->x) * 8;
- dst += (y * 8 + window->y) * _dxSurfacePitch;
+ dst += (y * 8 + window->y) * screen->pitch;
uint color = dst[0] & 0xF0;
if (getFeatures() & GF_PLANAR) {
src = _iconFilePtr;
src += READ_BE_UINT32(src + icon * 4);
- decompressIconPlanar(dst, src, 24, 12, color, _dxSurfacePitch);
+ decompressIconPlanar(dst, src, 24, 12, color, screen->pitch);
} else {
src = _iconFilePtr;
src += READ_LE_UINT16(src + icon * 2);
- decompressIcon(dst, src, 24, 12, color, _dxSurfacePitch);
+ decompressIcon(dst, src, 24, 12, color, screen->pitch);
}
_system->unlockScreen();
@@ -320,16 +320,16 @@ void AGOSEngine_Elvira1::drawIcon(WindowBlock *window, uint icon, uint x, uint y
dst = (byte *)screen->pixels;
dst += (x + window->x) * 8;
- dst += (y * 8 + window->y) * _dxSurfacePitch;
+ dst += (y * 8 + window->y) * screen->pitch;
if (getFeatures() & GF_PLANAR) {
src = _iconFilePtr;
src += READ_BE_UINT16(src + icon * 2);
- decompressIconPlanar(dst, src, 24, 12, 16, _dxSurfacePitch);
+ decompressIconPlanar(dst, src, 24, 12, 16, screen->pitch);
} else {
src = _iconFilePtr;
src += icon * 288;
- decompressIconPlanar(dst, src, 24, 12, 16, _dxSurfacePitch, false);
+ decompressIconPlanar(dst, src, 24, 12, 16, screen->pitch, false);
}
_system->unlockScreen();
@@ -344,14 +344,14 @@ void AGOSEngine::drawIcon(WindowBlock *window, uint icon, uint x, uint y) {
_videoLockOut |= 0x8000;
Graphics::Surface *screen = _system->lockScreen();
- dst = (byte *)screen->pixels + y * _dxSurfacePitch + x * 8;
+ dst = (byte *)screen->pixels + y * screen->pitch + x * 8;
src = _iconFilePtr + icon * 146;
if (icon == 0xFF) {
// Draw Blank Icon
for (int yp = 0; yp < 24; yp++) {
memset(dst, 0, 24);
- dst += _dxSurfacePitch;
+ dst += screen->pitch;
}
} else {
uint8 palette[4];
@@ -364,7 +364,7 @@ void AGOSEngine::drawIcon(WindowBlock *window, uint icon, uint x, uint y) {
uint32 v1 = (READ_BE_UINT16(src) << 8) | *(src + 4);
uint32 v2 = (READ_BE_UINT16(src + 2) << 8) | *(src + 5);
for (int xp = 0; xp < 24; ++xp, v1 >>= 1, v2 >>= 1) {
- dst[yp * _screenWidth + (23 - xp)] = palette[((v1 & 1) << 1) | (v2 & 1)];
+ dst[yp * screen->pitch + (23 - xp)] = palette[((v1 & 1) << 1) | (v2 & 1)];
}
}
}
@@ -952,7 +952,7 @@ void AGOSEngine::drawArrow(uint16 x, uint16 y, int8 dir) {
}
Graphics::Surface *screen = _system->lockScreen();
- byte *dst = (byte *)screen->pixels + y * _screenWidth + x * 8;
+ byte *dst = (byte *)screen->pixels + y * screen->pitch + x * 8;
for (h = 0; h < 19; h++) {
for (w = 0; w < 16; w++) {
@@ -960,7 +960,7 @@ void AGOSEngine::drawArrow(uint16 x, uint16 y, int8 dir) {
}
src += dir;
- dst+= _screenWidth;
+ dst+= screen->pitch;
}
_system->unlockScreen();
@@ -1043,7 +1043,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 * _dxSurfacePitch + 6 * 8;
+ byte *dst = (byte *)screen->pixels + 3 * screen->pitch + 6 * 8;
const byte *src = hitBarData;
uint8 color = (getPlatform() == Common::kPlatformPC) ? 7 : 15;
@@ -1058,7 +1058,7 @@ void AGOSEngine_PN::drawIconHitBar() {
b <<= 1;
}
}
- dst += _dxSurfacePitch;
+ dst += screen->pitch;
}
_system->unlockScreen();
diff --git a/engines/agos/menus.cpp b/engines/agos/menus.cpp
index 9e71849c6e..df837a5e16 100644
--- a/engines/agos/menus.cpp
+++ b/engines/agos/menus.cpp
@@ -170,7 +170,7 @@ void AGOSEngine::unlightMenuStrip() {
mouseOff();
Graphics::Surface *screen = _system->lockScreen();
- src = (byte *)screen->pixels + 2832;
+ src = (byte *)screen->pixels + 8 * screen->pitch + 272;
w = 48;
h = 82;
@@ -179,7 +179,7 @@ void AGOSEngine::unlightMenuStrip() {
if (src[i] != 0)
src[i] = 14;
}
- src += _dxSurfacePitch;
+ src += screen->pitch;
} while (--h);
for (i = 120; i != 130; i++)
@@ -198,7 +198,7 @@ void AGOSEngine::lightMenuBox(uint hitarea) {
mouseOff();
Graphics::Surface *screen = _system->lockScreen();
- src = (byte *)screen->pixels + ha->y * _dxSurfacePitch + ha->x;
+ src = (byte *)screen->pixels + ha->y * screen->pitch + ha->x;
w = ha->width;
h = ha->height;
@@ -207,7 +207,7 @@ void AGOSEngine::lightMenuBox(uint hitarea) {
if (src[i] == 14)
src[i] = 15;
}
- src += _dxSurfacePitch;
+ src += screen->pitch;
} while (--h);
_system->unlockScreen();
diff --git a/engines/agos/oracle.cpp b/engines/agos/oracle.cpp
index 88346fa9f8..e7192ea2ec 100644
--- a/engines/agos/oracle.cpp
+++ b/engines/agos/oracle.cpp
@@ -246,28 +246,28 @@ void AGOSEngine_Feeble::scrollOracleUp() {
byte *src, *dst;
uint16 w, h;
- dst = getBackGround() + 103 * _screenWidth + 136;
- src = getBackGround() + 106 * _screenWidth + 136;
+ dst = getBackGround() + 103 * _backGroundBuf->pitch + 136;
+ src = getBackGround() + 106 * _backGroundBuf->pitch + 136;
for (h = 0; h < 21; h++) {
for (w = 0; w < 360; w++) {
if (dst[w] == 0 || dst[w] == 113 || dst[w] == 116 || dst[w] == 252)
dst[w] = src[w];
}
- dst += _screenWidth;
- src += _screenWidth;
+ dst += _backGroundBuf->pitch;
+ src += _backGroundBuf->pitch;
}
for (h = 0; h < 80; h++) {
memcpy(dst, src, 360);
- dst += _screenWidth;
- src += _screenWidth;
+ dst += _backGroundBuf->pitch;
+ src += _backGroundBuf->pitch;
}
for (h = 0; h < 3; h++) {
memset(dst, 0, 360);
- dst += _screenWidth;
- src += _screenWidth;
+ dst += _backGroundBuf->pitch;
+ src += _backGroundBuf->pitch;
}
}
@@ -275,13 +275,13 @@ void AGOSEngine_Feeble::scrollOracleDown() {
byte *src, *dst;
uint16 w, h;
- src = getBackGround() + 203 * _screenWidth + 136;
- dst = getBackGround() + 206 * _screenWidth + 136;
+ src = getBackGround() + 203 * _backGroundBuf->pitch + 136;
+ dst = getBackGround() + 206 * _backGroundBuf->pitch + 136;
for (h = 0; h < 77; h++) {
memcpy(dst, src, 360);
- dst -= _screenWidth;
- src -= _screenWidth;
+ dst -= _backGroundBuf->pitch;
+ src -= _backGroundBuf->pitch;
}
for (h = 0; h < 24; h++) {
@@ -294,8 +294,8 @@ void AGOSEngine_Feeble::scrollOracleDown() {
src[w] = 0;
}
}
- dst -= _screenWidth;
- src -= _screenWidth;
+ dst -= _backGroundBuf->pitch;
+ src -= _backGroundBuf->pitch;
}
}
@@ -315,7 +315,7 @@ void AGOSEngine_Feeble::oracleLogo() {
srcRect.bottom = 43;
src = _iconFilePtr;
- dst = getBackBuf() + _screenWidth * dstRect.top + dstRect.left;
+ dst = getBackBuf() + _backBuf->pitch * dstRect.top + dstRect.left;
for (h = 0; h < dstRect.height(); h++) {
for (w = 0; w < dstRect.width(); w++) {
@@ -323,7 +323,7 @@ void AGOSEngine_Feeble::oracleLogo() {
dst[w] = src[w];
}
src += 336;
- dst += _screenWidth;
+ dst += _backBuf->pitch;
}
}
@@ -355,7 +355,7 @@ void AGOSEngine_Feeble::swapCharacterLogo() {
srcRect.right = srcRect.left + 42;
src = _iconFilePtr + srcRect.top * 336 + srcRect.left;
- dst = getBackBuf() + _screenWidth * dstRect.top + dstRect.left;
+ dst = getBackBuf() + _backBuf->pitch * dstRect.top + dstRect.left;
for (h = 0; h < dstRect.height(); h++) {
for (w = 0; w < dstRect.width(); w++) {
@@ -363,7 +363,7 @@ void AGOSEngine_Feeble::swapCharacterLogo() {
dst[w] = src[w];
}
src += 336;
- dst += _screenWidth;
+ dst += _backBuf->pitch;
}
}
@@ -506,14 +506,14 @@ void AGOSEngine_Feeble::windowBackSpace(WindowBlock *window) {
x = window->x + window->textColumn;
y = window->y + window->textRow;
- dst = getBackGround() + _dxSurfacePitch * y + x;
+ dst = getBackGround() + _backGroundBuf->pitch * y + x;
for (h = 0; h < 13; h++) {
for (w = 0; w < 8; w++) {
if (dst[w] == 113 || dst[w] == 116 || dst[w] == 252)
dst[w] = 0;
}
- dst += _screenWidth;
+ dst += _backGroundBuf->pitch;
}
_videoLockOut &= ~0x8000;
diff --git a/engines/agos/verb.cpp b/engines/agos/verb.cpp
index 2486f09626..8376ebb28e 100644
--- a/engines/agos/verb.cpp
+++ b/engines/agos/verb.cpp
@@ -967,7 +967,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 * _dxSurfacePitch + ha->x;
+ src = (byte *)screen->pixels + ha->y * screen->pitch + ha->x;
// WORKAROUND: Hitareas for saved game names aren't adjusted for scrolling locations
if (getGameType() == GType_SIMON2 && ha->id >= 208 && ha->id <= 213) {
@@ -1019,7 +1019,7 @@ void AGOSEngine::invertBox(HitArea *ha, byte a, byte b, byte c, byte d) {
}
}
}
- src += _dxSurfacePitch;
+ src += screen->pitch;
} while (--h);
_system->unlockScreen();
diff --git a/engines/agos/vga.cpp b/engines/agos/vga.cpp
index eea53b9864..d2e620d86e 100644
--- a/engines/agos/vga.cpp
+++ b/engines/agos/vga.cpp
@@ -1182,11 +1182,12 @@ void AGOSEngine::vc31_setWindow() {
void AGOSEngine::vc32_saveScreen() {
if (getGameType() == GType_PN) {
Graphics::Surface *screen = _system->lockScreen();
-
byte *dst = getBackGround();
byte *src = (byte *)screen->pixels;
- memcpy(dst, src, 64000);
-
+ for (int i = 0; i < _screenHeight; i++) {
+ memcpy(dst, src, _screenWidth);
+ dst += screen->pitch;
+ }
_system->unlockScreen();
} else {
uint16 xoffs = _videoWindows[4 * 4 + 0] * 16;
@@ -1194,12 +1195,12 @@ void AGOSEngine::vc32_saveScreen() {
uint16 width = _videoWindows[4 * 4 + 2] * 16;
uint16 height = _videoWindows[4 * 4 + 3];
- byte *dst = getBackGround() + xoffs + yoffs * _screenWidth;
- byte *src = _window4BackScn;
+ byte *dst = (byte *)_backGroundBuf->getBasePtr(xoffs, yoffs);
+ byte *src = (byte *)_window4BackScn->pixels;;
uint16 srcWidth = _videoWindows[4 * 4 + 2] * 16;
for (; height > 0; height--) {
memcpy(dst, src, width);
- dst += _screenWidth;
+ dst += _backGroundBuf->pitch;
src += srcWidth;
}
}
@@ -1228,11 +1229,11 @@ void AGOSEngine::vc34_setMouseOff() {
void AGOSEngine::clearVideoBackGround(uint16 num, uint16 color) {
const uint16 *vlut = &_videoWindows[num * 4];
- byte *dst = getBackGround() + vlut[0] * 16 + vlut[1] * _dxSurfacePitch;
+ byte *dst = (byte *)_backGroundBuf->getBasePtr(vlut[0] * 16, vlut[1]);
for (uint h = 0; h < vlut[3]; h++) {
memset(dst, color, vlut[2] * 16);
- dst += _screenWidth;
+ dst += _backGroundBuf->pitch;
}
}
@@ -1250,14 +1251,18 @@ void AGOSEngine::clearVideoWindow(uint16 num, uint16 color) {
if (getGameType() == GType_ELVIRA1 && num == 3) {
Graphics::Surface *screen = _system->lockScreen();
- memset((byte *)screen->pixels, color, _screenWidth * _screenHeight);
+ byte *dst = (byte *)screen->pixels;
+ for (int i = 0; i < _screenHeight; i++) {
+ memset(dst, color, _screenWidth);
+ dst += screen->pitch;
+ }
_system->unlockScreen();
} else if (num == 4) {
const uint16 *vlut = &_videoWindows[num * 4];
uint16 xoffs = (vlut[0] - _videoWindows[16]) * 16;
uint16 yoffs = (vlut[1] - _videoWindows[17]);
uint16 dstWidth = _videoWindows[18] * 16;
- byte *dst = _window4BackScn + xoffs + yoffs * dstWidth;
+ byte *dst = (byte *)_window4BackScn->pixels + xoffs + 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 58d3329296..7f02398e13 100644
--- a/engines/agos/vga_e2.cpp
+++ b/engines/agos/vga_e2.cpp
@@ -77,7 +77,7 @@ void AGOSEngine::vc45_setWindowPalette() {
uint8 height = vlut[3];
if (num == 4) {
- byte *dst = _window4BackScn;
+ byte *dst = (byte *)_window4BackScn->pixels;
for (uint8 h = 0; h < height; h++) {
for (uint8 w = 0; w < width; w++) {
@@ -90,7 +90,7 @@ void AGOSEngine::vc45_setWindowPalette() {
}
} else {
Graphics::Surface *screen = _system->lockScreen();
- byte *dst = (byte *)screen->pixels + vlut[0] * 16 + vlut[1] * _dxSurfacePitch;
+ byte *dst = (byte *)screen->getBasePtr(vlut[0] * 16, vlut[1]);
if (getGameType() == GType_ELVIRA2 && num == 7) {
dst -= 8;
@@ -104,7 +104,7 @@ void AGOSEngine::vc45_setWindowPalette() {
val |= color * 16;
WRITE_LE_UINT16(dst + w * 2, val);
}
- dst += _dxSurfacePitch;
+ dst += screen->pitch;
}
_system->unlockScreen();
@@ -218,18 +218,19 @@ void AGOSEngine::vc53_dissolveIn() {
uint16 dissolveDelay = dissolveCheck * 2 / speed;
uint16 dissolveCount = dissolveCheck * 2 / speed;
+ Graphics::Surface *screen = _system->lockScreen();
+
int16 xoffs = _videoWindows[num * 4 + 0] * 16;
int16 yoffs = _videoWindows[num * 4 + 1];
- int16 offs = xoffs + yoffs * _screenWidth;
+ int16 offs = xoffs + yoffs * screen->pitch;
uint16 count = dissolveCheck * 2;
while (count--) {
- Graphics::Surface *screen = _system->lockScreen();
byte *dstPtr = (byte *)screen->pixels + offs;
yoffs = _rnd.getRandomNumber(dissolveY);
- dst = dstPtr + yoffs * _screenWidth;
- src = _window4BackScn + yoffs * 224;
+ dst = dstPtr + yoffs * screen->pitch;
+ src = (byte *)_window4BackScn->pixels + yoffs * _window4BackScn->pitch;
xoffs = _rnd.getRandomNumber(dissolveX);
dst += xoffs;
@@ -252,15 +253,15 @@ void AGOSEngine::vc53_dissolveIn() {
dstOffs2 = dst;
yoffs = (dissolveY - 1) * 2 - (yoffs * 2);
- src = srcOffs + yoffs * 224;
- dst = dstOffs + yoffs * _screenWidth;
+ src = srcOffs + yoffs * _window4BackScn->pitch;
+ dst = dstOffs + yoffs * screen->pitch;
color = 0xF0;
*dst &= color;
*dst |= *src & 0xF;
- dst = dstOffs2 + yoffs * _screenWidth;
- src = srcOffs2 + yoffs * 224;
+ dst = dstOffs2 + yoffs * screen->pitch;
+ src = srcOffs2 + yoffs * _window4BackScn->pitch;
*dst &= color;
*dst |= *src & 0xF;
@@ -291,19 +292,20 @@ void AGOSEngine::vc54_dissolveOut() {
uint16 dissolveDelay = dissolveCheck * 2 / speed;
uint16 dissolveCount = dissolveCheck * 2 / speed;
+ Graphics::Surface *screen = _system->lockScreen();
+
int16 xoffs = _videoWindows[num * 4 + 0] * 16;
int16 yoffs = _videoWindows[num * 4 + 1];
- int16 offs = xoffs + yoffs * _screenWidth;
+ int16 offs = xoffs + yoffs * screen->pitch;
uint16 count = dissolveCheck * 2;
while (count--) {
- Graphics::Surface *screen = _system->lockScreen();
byte *dstPtr = (byte *)screen->pixels + offs;
color |= dstPtr[0] & 0xF0;
yoffs = _rnd.getRandomNumber(dissolveY);
xoffs = _rnd.getRandomNumber(dissolveX);
- dst = dstPtr + xoffs + yoffs * _screenWidth;
+ dst = dstPtr + xoffs + yoffs * screen->pitch;
*dst = color;
dstOffs = dst;
@@ -313,7 +315,7 @@ void AGOSEngine::vc54_dissolveOut() {
*dst = color;
yoffs = (dissolveY - 1) * 2 - (yoffs * 2);
- dst = dstOffs + yoffs * _screenWidth;
+ dst = dstOffs + yoffs * screen->pitch;
*dst = color;
dst += xoffs;
@@ -354,18 +356,22 @@ void AGOSEngine::vc55_moveBox() {
}
void AGOSEngine::vc56_fullScreen() {
- Graphics::Surface *screen = _system->lockScreen();
+ uint8 palette[1024];
+ Graphics::Surface *screen = _system->lockScreen();
byte *dst = (byte *)screen->pixels;
- byte *src = _curVgaFile2 + 32;
-
- memcpy(dst, src + 768, _screenHeight * _screenWidth);
+ byte *src = _curVgaFile2 + 800;
+ for (int i = 0; i < _screenHeight; i++) {
+ memcpy(dst, src, _screenWidth);
+ src += 320;
+ dst += screen->pitch;
+ }
_system->unlockScreen();
//fullFade();
- uint8 palette[1024];
+ src = _curVgaFile2 + 32;
for (int i = 0; i < 256; i++) {
palette[i * 4 + 0] = *src++ * 4;
palette[i * 4 + 1] = *src++ * 4;
diff --git a/engines/agos/vga_pn.cpp b/engines/agos/vga_pn.cpp
index e84248bb4d..32c6e15f00 100644
--- a/engines/agos/vga_pn.cpp
+++ b/engines/agos/vga_pn.cpp
@@ -168,7 +168,7 @@ void AGOSEngine::vc48_specialEffect() {
if (dst[w] == 15)
dst[w] = 4;
}
- dst += _screenWidth;
+ dst += screen->pitch;
}
_system->unlockScreen();
} else if (num == 2) {
diff --git a/engines/agos/vga_s2.cpp b/engines/agos/vga_s2.cpp
index 28a383547f..e133427d76 100644
--- a/engines/agos/vga_s2.cpp
+++ b/engines/agos/vga_s2.cpp
@@ -28,6 +28,8 @@
#include "agos/agos.h"
#include "agos/intern.h"
+#include "graphics/surface.h"
+
namespace AGOS {
void AGOSEngine_Simon2::setupVideoOpcodes(VgaOpcodeProc *op) {
@@ -215,7 +217,7 @@ void AGOSEngine_Simon2::clearVideoWindow(uint16 num, uint16 color) {
uint16 xoffs = vlut[0] * 16;
uint16 yoffs = vlut[1];
uint16 dstWidth = _videoWindows[18] * 16;
- byte *dst = _window4BackScn + xoffs + yoffs * dstWidth;
+ byte *dst = (byte *)_window4BackScn->pixels + xoffs + 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 4f6d510fbf..97c31b299c 100644
--- a/engines/agos/vga_ww.cpp
+++ b/engines/agos/vga_ww.cpp
@@ -145,14 +145,19 @@ void AGOSEngine::vc61() {
uint h, tmp;
Graphics::Surface *screen = _system->lockScreen();
+ dstPtr = (byte *)screen->pixels;
if (a == 6) {
src = _curVgaFile2 + 800;
- dstPtr = (byte *)screen->pixels;
- memcpy(dstPtr, src, 64000);
+
+ for (int i = 0; i < _screenHeight; i++) {
+ memcpy(dst, src, _screenWidth);
+ src += 320;
+ dst += screen->pitch;
+ }
+
tmp = 4 - 1;
} else {
- dstPtr = (byte *)screen->pixels;
tmp = a - 1;
}
@@ -160,15 +165,14 @@ void AGOSEngine::vc61() {
while (tmp--)
src += 1536 * 16 + 1712;
-
src += 800;
if (a != 5) {
- dst = dstPtr + 7448;
+ dst = dstPtr + 23 * screen->pitch + 88;
for (h = 0; h < 177; h++) {
memcpy(dst, src, 144);
src += 144;
- dst += _screenWidth;
+ dst += screen->pitch;
}
if (a != 6) {
@@ -179,11 +183,11 @@ void AGOSEngine::vc61() {
src = _curVgaFile2 + 9984 * 16 + 15344;
}
- dst = dstPtr + 50296;
+ dst = dstPtr + 157 * screen->pitch + 56;
for (h = 0; h < 17; h++) {
memcpy(dst, src, 208);
src += 208;
- dst += _screenWidth;
+ dst += screen->pitch;
}
_system->unlockScreen();
diff --git a/engines/agos/window.cpp b/engines/agos/window.cpp
index 8737498e79..a578568a03 100644
--- a/engines/agos/window.cpp
+++ b/engines/agos/window.cpp
@@ -128,14 +128,14 @@ void AGOSEngine_Feeble::colorWindow(WindowBlock *window) {
_videoLockOut |= 0x8000;
- dst = getBackGround() + _dxSurfacePitch * window->y + window->x;
+ dst = getBackGround() + _backGroundBuf->pitch * window->y + window->x;
for (h = 0; h < window->height; h++) {
for (w = 0; w < window->width; w++) {
if (dst[w] == 113 || dst[w] == 116 || dst[w] == 252)
dst[w] = window->fillColor;
}
- dst += _screenWidth;
+ dst += _backGroundBuf->pitch;
}
_videoLockOut &= ~0x8000;
@@ -171,7 +171,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 * _screenWidth + x;
+ byte *dst = (byte *)screen->pixels + y * screen->pitch + x;
uint8 color = window->fillColor;
if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW)
@@ -179,7 +179,7 @@ void AGOSEngine::colorBlock(WindowBlock *window, uint16 x, uint16 y, uint16 w, u
do {
memset(dst, color, w);
- dst += _screenWidth;
+ dst += screen->pitch;
} while (--h);
_system->unlockScreen();
@@ -236,8 +236,8 @@ void AGOSEngine::restoreBlock(uint16 x, uint16 y, uint16 w, uint16 h) {
dst = (byte *)screen->pixels;
src = getBackGround();
- dst += y * _dxSurfacePitch;
- src += y * _dxSurfacePitch;
+ dst += y * screen->pitch;
+ src += y * _backGroundBuf->pitch;
uint8 paletteMod = 0;
if (getGameType() == GType_ELVIRA1 && !(getFeatures() & GF_DEMO) && y >= 133)
@@ -247,8 +247,8 @@ void AGOSEngine::restoreBlock(uint16 x, uint16 y, uint16 w, uint16 h) {
for (i = x; i < w; i++)
dst[i] = src[i] + paletteMod;
y++;
- dst += _dxSurfacePitch;
- src += _dxSurfacePitch;
+ dst += screen->pitch;
+ src += _backGroundBuf->pitch;
}
_system->unlockScreen();