aboutsummaryrefslogtreecommitdiff
path: root/engines/agos
diff options
context:
space:
mode:
authorNorbert Lange2009-07-17 21:23:54 +0000
committerNorbert Lange2009-07-17 21:23:54 +0000
commitbb64bf008d03e01760a468d0df8cacb164725d41 (patch)
treed73710df5b07f3fa1ca30e719c1c1f58ebe0b107 /engines/agos
parent81ac29ebca30c352646a5b21de512087cb96a672 (diff)
parent53756ef1d022a959b24c041e18f55eef34e60dd3 (diff)
downloadscummvm-rg350-bb64bf008d03e01760a468d0df8cacb164725d41.tar.gz
scummvm-rg350-bb64bf008d03e01760a468d0df8cacb164725d41.tar.bz2
scummvm-rg350-bb64bf008d03e01760a468d0df8cacb164725d41.zip
merge with trunk
svn-id: r42574
Diffstat (limited to 'engines/agos')
-rw-r--r--engines/agos/agos.cpp34
-rw-r--r--engines/agos/agos.h49
-rw-r--r--engines/agos/charset-fontdata.cpp20
-rw-r--r--engines/agos/charset.cpp8
-rw-r--r--engines/agos/draw.cpp112
-rw-r--r--engines/agos/event.cpp6
-rw-r--r--engines/agos/feeble.cpp39
-rw-r--r--engines/agos/gfx.cpp146
-rw-r--r--engines/agos/icons.cpp44
-rw-r--r--engines/agos/items.cpp2
-rw-r--r--engines/agos/menus.cpp8
-rw-r--r--engines/agos/oracle.cpp40
-rw-r--r--engines/agos/pn.cpp10
-rw-r--r--engines/agos/res_snd.cpp19
-rw-r--r--engines/agos/script_e1.cpp2
-rw-r--r--engines/agos/script_pn.cpp248
-rw-r--r--engines/agos/string.cpp14
-rw-r--r--engines/agos/subroutine.cpp2
-rw-r--r--engines/agos/verb.cpp4
-rw-r--r--engines/agos/vga.cpp26
-rw-r--r--engines/agos/vga_e2.cpp52
-rw-r--r--engines/agos/vga_ff.cpp2
-rw-r--r--engines/agos/vga_pn.cpp3
-rw-r--r--engines/agos/vga_s2.cpp4
-rw-r--r--engines/agos/vga_ww.cpp21
-rw-r--r--engines/agos/window.cpp16
26 files changed, 515 insertions, 416 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp
index cdbeeecd8e..9903952577 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,12 @@ AGOSEngine::AGOSEngine(OSystem *syst)
_backGroundBuf = 0;
_backBuf = 0;
_scaleBuf = 0;
+ _window4BackScn = 0;
+ _window6BackScn = 0;
_window3Flag = 0;
_window4Flag = 0;
_window6Flag = 0;
- _window4BackScn = 0;
- _window6BackScn = 0;
_moveXMin = 0;
_moveYMin = 0;
@@ -580,26 +580,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 405ee3622c..263811b78a 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;
@@ -615,8 +613,8 @@ protected:
void paletteFadeOut(byte *palPtr, uint num, uint size);
- byte *allocateItem(uint size);
- byte *allocateTable(uint size);
+ void *allocateItem(uint size);
+ void *allocateTable(uint size);
void alignTableMem();
Child *findChildOfType(Item *i, uint child);
@@ -673,7 +671,7 @@ protected:
void uncompressText(byte *ptr);
byte *uncompressToken(byte a, byte *ptr);
- void showMessageFormat(const char *s, ...);
+ void showMessageFormat(const char *s, ...) GCC_PRINTF(2, 3);
const byte *getStringPtrByID(uint16 stringId, bool upperCase = false);
const byte *getLocalStringByID(uint16 stringId);
uint getNextStringID();
@@ -1267,8 +1265,8 @@ protected:
#ifdef ENABLE_PN
class AGOSEngine_PN : public AGOSEngine {
- struct stackframe {
- struct stackframe *nextframe;
+ struct StackFrame {
+ StackFrame *nextframe;
int16 flag[6];
int16 param[8];
int16 classnum;
@@ -1278,7 +1276,7 @@ class AGOSEngine_PN : public AGOSEngine {
int16 linenum;
int16 process;
jmp_buf *savearea;
- stackframe() { memset(this, 0, sizeof(*this)); }
+ StackFrame() { memset(this, 0, sizeof(*this)); }
};
@@ -1286,6 +1284,7 @@ class AGOSEngine_PN : public AGOSEngine {
void demoSeq();
void introSeq();
void setupBoxes();
+ int readfromline();
public:
AGOSEngine_PN(OSystem *system);
~AGOSEngine_PN();
@@ -1299,10 +1298,10 @@ public:
int actCallD(int n);
void opn_opcode00();
- void opn_opcode01();
- void opn_opcode02();
- void opn_opcode03();
- void opn_opcode04();
+ void opn_add();
+ void opn_sub();
+ void opn_mul();
+ void opn_div();
void opn_opcode05();
void opn_opcode06();
void opn_opcode07();
@@ -1315,10 +1314,10 @@ public:
void opn_opcode14();
void opn_opcode15();
void opn_opcode16();
- void opn_opcode17();
- void opn_opcode18();
- void opn_opcode19();
- void opn_opcode20();
+ void opn_lt();
+ void opn_gt();
+ void opn_eq();
+ void opn_neq();
void opn_opcode21();
void opn_opcode22();
void opn_opcode23();
@@ -1359,14 +1358,14 @@ public:
void opn_opcode62();
void opn_opcode63();
- stackframe *_stackbase;
+ StackFrame *_stackbase;
byte *_dataBase, *_textBase;
uint32 _dataBaseSize, _textBaseSize;
HitArea _invHitAreas[45];
- char _buffer[80];
+ char _buffer[80];
char _inputline[61];
char _saveFile[20];
char _sb[80];
@@ -1392,7 +1391,7 @@ public:
uint16 _objects;
int16 _objectCountS;
- int16 _bp;
+ int16 _bp;
int16 _xofs;
int16 _havinit;
uint16 _seed;
@@ -1977,7 +1976,7 @@ protected:
virtual void printScreenText(uint vgaSpriteId, uint color, const char *stringPtr, int16 x, int16 y, int16 width);
void printInteractText(uint16 num, const char *string);
- void sendInteractText(uint16 num, const char *fmt, ...);
+ void sendInteractText(uint16 num, const char *fmt, ...) GCC_PRINTF(3, 4);
void checkLinkBox();
void hyperLinkOn(uint16 x);
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..45443aa335 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,18 +492,18 @@ 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;
animTable->y = y;
animTable->width = READ_BE_UINT16(ptr + 6) / 16;
- if (vsp->flags & 40) {
+ if (vsp->flags & 0x40) {
animTable->width++;
}
@@ -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..cbb09e1ec7 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();
@@ -484,7 +484,7 @@ void AGOSEngine::delay(uint amount) {
_fastMode ^= 1;
} else if (event.kbd.keycode == Common::KEYCODE_d) {
_debugger->attach();
- } else if (event.kbd.keycode == Common::KEYCODE_u) {
+ } else if (event.kbd.keycode == Common::KEYCODE_s) {
dumpAllSubroutines();
} else if (event.kbd.keycode == Common::KEYCODE_i) {
dumpAllVgaImageFiles();
diff --git a/engines/agos/feeble.cpp b/engines/agos/feeble.cpp
index 492d855614..89b6f6da27 100644
--- a/engines/agos/feeble.cpp
+++ b/engines/agos/feeble.cpp
@@ -161,21 +161,16 @@ void AGOSEngine_FeebleDemo::exitMenu() {
playVideo("fbye1.smk", true);
HitArea *ha;
- while (!shouldQuit()) {
+ do {
_lastHitArea = NULL;
_lastHitArea3 = NULL;
- while (!shouldQuit()) {
- if (_lastHitArea3 != 0)
- break;
+ while (!shouldQuit() && _lastHitArea3 == 0) {
delay(1);
}
ha = _lastHitArea;
-
- if (ha != NULL && ha->id == 21)
- break;
- }
+ } while (!shouldQuit() && !(ha != NULL && ha->id == 21));
playVideo("fbye2.smk");
quitGame();
@@ -202,9 +197,7 @@ void AGOSEngine_FeebleDemo::filmMenu() {
_lastHitArea = NULL;
_lastHitArea3 = NULL;
- while (!shouldQuit()) {
- if (_lastHitArea3 != 0)
- break;
+ while (!shouldQuit() && _lastHitArea3 == 0) {
handleWobble();
delay(1);
}
@@ -287,25 +280,23 @@ void AGOSEngine_FeebleDemo::mainMenu() {
startInteractiveVideo("mainmenu.smk");
- HitArea *ha;
- while (!shouldQuit()) {
+ HitArea *ha = 0;
+ do {
_lastHitArea = NULL;
_lastHitArea3 = NULL;
- while (!shouldQuit()) {
- if (_lastHitArea3 != 0)
- break;
+ while (_lastHitArea3 == 0) {
+ if (shouldQuit())
+ return;
handleText();
delay(1);
}
ha = _lastHitArea;
+ } while (ha == NULL || !(ha->id >= 1 && ha->id <= 6));
- if (ha == NULL) {
- } else if (ha->id >= 1 && ha->id <= 6) {
- break;
- }
- }
+ if (shouldQuit())
+ return;
stopInteractiveVideo();
@@ -384,11 +375,9 @@ void AGOSEngine_FeebleDemo::waitForSpace() {
windowPutChar(_textWindow, *message);
mouseOff();
- while (!shouldQuit()) {
+ do {
delay(1);
- if (_keyPressed.keycode == Common::KEYCODE_SPACE)
- break;
- }
+ } while (!shouldQuit() && (_keyPressed.keycode != Common::KEYCODE_SPACE));
_keyPressed.reset();
mouseOn();
}
diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp
index 4b2d2b3321..1b5a820260 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->pixels;
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/items.cpp b/engines/agos/items.cpp
index c439be3555..49792b99c5 100644
--- a/engines/agos/items.cpp
+++ b/engines/agos/items.cpp
@@ -41,7 +41,7 @@ Child *AGOSEngine::allocateChildBlock(Item *i, uint type, uint size) {
return child;
}
-byte *AGOSEngine::allocateItem(uint size) {
+void *AGOSEngine::allocateItem(uint size) {
byte *item = new byte[size];
memset(item, 0, size);
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/pn.cpp b/engines/agos/pn.cpp
index fd88d63ec3..d92efa9077 100644
--- a/engines/agos/pn.cpp
+++ b/engines/agos/pn.cpp
@@ -269,16 +269,16 @@ void AGOSEngine_PN::processor() {
_variableArray[16] = _quickshort[6];
_variableArray[17] = _quickshort[7];
_variableArray[19] = getptr(55L);
+
+ // q indicates the process to run and is 0 the first time,
+ // but 1 later on (i.e., when we are "called" from badload()).
setposition(q, 0);
doline(0);
}
void AGOSEngine_PN::setqptrs() {
- int a = 0;
-
- while (a < 11) {
- _quickptr[a] = getlong(3L * a);
- a++;
+ for (int i = 0; i < 11; ++i) {
+ _quickptr[i] = getlong(3 * i);
}
_quickptr[11] = getlong(58L);
_quickptr[12] = getlong(61L);
diff --git a/engines/agos/res_snd.cpp b/engines/agos/res_snd.cpp
index 60c79b2324..e85440d8e1 100644
--- a/engines/agos/res_snd.cpp
+++ b/engines/agos/res_snd.cpp
@@ -332,7 +332,7 @@ void AGOSEngine::playSting(uint16 soundId) {
mus_file.seek(soundId * 2, SEEK_SET);
mus_offset = mus_file.readUint16LE();
- if (mus_file.ioFailed())
+ if (mus_file.err())
error("playSting: Can't read sting %d offset", soundId);
mus_file.seek(mus_offset, SEEK_SET);
@@ -527,6 +527,7 @@ void AGOSEngine::loadSound(uint16 sound, int16 pan, int16 vol, uint16 type) {
void AGOSEngine::loadSound(uint16 sound, uint16 freq, uint16 flags) {
byte *dst;
uint32 offs, size = 0;
+ uint32 rate = 8000;
if (_curSfxFile == NULL)
return;
@@ -570,13 +571,23 @@ void AGOSEngine::loadSound(uint16 sound, uint16 freq, uint16 flags) {
offs = READ_BE_UINT32(dst + 8);
}
- // TODO: Handle other sound flags and frequency
+ if (getGameType() == GType_PN) {
+ if (freq == 0) {
+ rate = 4600;
+ } else if (freq == 1) {
+ rate = 7400;
+ } else {
+ rate = 9400;
+ }
+ }
+
+ // TODO: Handle other sound flags in Amiga/AtariST versions
if (flags == 2 && _sound->isSfxActive()) {
- _sound->queueSound(dst + offs, sound, size, 8000);
+ _sound->queueSound(dst + offs, sound, size, rate);
} else {
if (flags == 0)
_sound->stopSfx();
- _sound->playRawData(dst + offs, sound, size, 8000);
+ _sound->playRawData(dst + offs, sound, size, rate);
}
}
diff --git a/engines/agos/script_e1.cpp b/engines/agos/script_e1.cpp
index 0080748699..df37a38a7c 100644
--- a/engines/agos/script_e1.cpp
+++ b/engines/agos/script_e1.cpp
@@ -532,7 +532,7 @@ void AGOSEngine_Elvira1::oe1_moveDirn() {
void AGOSEngine_Elvira1::oe1_score() {
// 90: score
SubPlayer *p = (SubPlayer *)findChildOfType(me(), kPlayerType);
- showMessageFormat("Your score is %ld.\n", p->score);
+ showMessageFormat("Your score is %d.\n", p->score);
}
void AGOSEngine_Elvira1::oe1_look() {
diff --git a/engines/agos/script_pn.cpp b/engines/agos/script_pn.cpp
index 62ca94e387..4f9aab2965 100644
--- a/engines/agos/script_pn.cpp
+++ b/engines/agos/script_pn.cpp
@@ -30,17 +30,21 @@
namespace AGOS {
+enum {
+ kJmpClassNum = -1
+};
+
#define OPCODE(x) _OPCODE(AGOSEngine_PN, x)
void AGOSEngine_PN::setupOpcodes() {
static const OpcodeEntryPN opcodes[] = {
/* 00 */
OPCODE(opn_opcode00),
- OPCODE(opn_opcode01),
- OPCODE(opn_opcode02),
- OPCODE(opn_opcode03),
+ OPCODE(opn_add),
+ OPCODE(opn_sub),
+ OPCODE(opn_mul),
/* 04 */
- OPCODE(opn_opcode04),
+ OPCODE(opn_div),
OPCODE(opn_opcode05),
OPCODE(opn_opcode06),
OPCODE(opn_opcode07),
@@ -56,11 +60,11 @@ void AGOSEngine_PN::setupOpcodes() {
OPCODE(opn_opcode15),
/* 16 */
OPCODE(opn_opcode16),
- OPCODE(opn_opcode17),
- OPCODE(opn_opcode18),
- OPCODE(opn_opcode19),
+ OPCODE(opn_lt),
+ OPCODE(opn_gt),
+ OPCODE(opn_eq),
/* 20 */
- OPCODE(opn_opcode20),
+ OPCODE(opn_neq),
OPCODE(opn_opcode21),
OPCODE(opn_opcode22),
OPCODE(opn_opcode23),
@@ -122,13 +126,14 @@ void AGOSEngine_PN::setupOpcodes() {
void AGOSEngine_PN::executeOpcode(int opcode) {
OpcodeProcPN op = _opcodesPN[opcode].proc;
- (this->*op) ();
+ (this->*op)();
}
-#define readfromline() (_linct-- ? (int)*_workptr++ : readoverr())
-
-int readoverr() {
- error("readfromline: Internal Error - Line Over-run");
+int AGOSEngine_PN::readfromline() {
+ if (!_linct)
+ error("readfromline: Internal Error - Line Over-run");
+ _linct--;
+ return *_workptr++;
}
// -----------------------------------------------------------------------
@@ -142,30 +147,30 @@ void AGOSEngine_PN::opn_opcode00() {
setScriptReturn(true);
}
-void AGOSEngine_PN::opn_opcode01() {
+void AGOSEngine_PN::opn_add() {
uint8 *str = _workptr;
int32 sp = varval() + varval();
_variableArray[12] = sp % 65536;
_variableArray[13] = sp / 65536;
if (sp > 65535)
- sp=65535;
+ sp = 65535;
writeval(str, (int)sp);
setScriptReturn(true);
}
-void AGOSEngine_PN::opn_opcode02() {
+void AGOSEngine_PN::opn_sub() {
uint8 *str = _workptr;
int32 sp = varval();
sp -= varval();
_variableArray[12] = sp % 65536;
_variableArray[13] = sp / 65536;
- if(sp < 0)
+ if (sp < 0)
sp = 0;
writeval(str, (int)sp);
setScriptReturn(true);
}
-void AGOSEngine_PN::opn_opcode03() {
+void AGOSEngine_PN::opn_mul() {
uint8 *str = _workptr;
int32 sp = varval() * varval();
_variableArray[12] = sp % 65536;
@@ -176,12 +181,12 @@ void AGOSEngine_PN::opn_opcode03() {
setScriptReturn(true);
}
-void AGOSEngine_PN::opn_opcode04() {
+void AGOSEngine_PN::opn_div() {
uint8 *str = _workptr;
int32 sp = varval();
int32 sp2 = varval();
if (sp2 == 0)
- error("Division by 0");
+ error("opn_div: Division by 0");
sp = sp / sp2;
_variableArray[12] = sp % 65536;
_variableArray[13] = sp / 65536;
@@ -234,7 +239,7 @@ void AGOSEngine_PN::opn_opcode12() {
char bf[8];
int a = 0;
sprintf(bf,"%d", varval());
- while(bf[a])
+ while (bf[a])
pcf(bf[a++]);
setScriptReturn(true);
}
@@ -243,7 +248,7 @@ void AGOSEngine_PN::opn_opcode13() {
char bf[8];
int a = 0;
sprintf(bf,"%d", varval());
- while(bf[a])
+ while (bf[a])
pcf(bf[a++]);
pcf((uint8)'\n');
setScriptReturn(true);
@@ -271,25 +276,25 @@ void AGOSEngine_PN::opn_opcode16() {
setScriptReturn((sp >= 0 && sp <= 4));
}
-void AGOSEngine_PN::opn_opcode17() {
+void AGOSEngine_PN::opn_lt() {
int16 v1 = varval();
int16 v2 = varval();
setScriptReturn(v1 < v2);
}
-void AGOSEngine_PN::opn_opcode18() {
+void AGOSEngine_PN::opn_gt() {
int16 v1 = varval();
int16 v2 = varval();
setScriptReturn(v1 > v2);
}
-void AGOSEngine_PN::opn_opcode19() {
+void AGOSEngine_PN::opn_eq() {
int16 v1 = varval();
int16 v2 = varval();
setScriptReturn(v1 == v2);
}
-void AGOSEngine_PN::opn_opcode20() {
+void AGOSEngine_PN::opn_neq() {
int16 v1 = varval();
int16 v2 = varval();
setScriptReturn(v1 != v2);
@@ -302,11 +307,10 @@ void AGOSEngine_PN::opn_opcode21() {
void AGOSEngine_PN::opn_opcode22() {
int pf[8];
- int a;
- a = varval();
- funcentry(pf, a);
+ int n = varval();
+ funcentry(pf, n);
funccpy(pf);
- setposition(a, 0);
+ setposition(n, 0);
setScriptReturn(true);
}
@@ -315,19 +319,27 @@ void AGOSEngine_PN::opn_opcode23() {
}
void AGOSEngine_PN::opn_opcode24() {
- popstack(-1);
+ popstack(kJmpClassNum);
+ // Jump back to the last doline, which will return 2-1=1.
+ // That value then is returned to actCallD, which once again
+ // returns it. In the end, this amounts to a setScriptReturn(true)
+ // (but possibly in a different level than the current one).
longjmp(*(_stackbase->savearea), 2);
setScriptReturn(false);
}
void AGOSEngine_PN::opn_opcode25() {
- popstack(-1);
+ popstack(kJmpClassNum);
+ // Jump back to the last doline, which will return 1-1=0.
+ // That value then is returned to actCallD, which once again
+ // returns it. In the end, this amounts to a setScriptReturn(false)
+ // (but possibly in a different level than the current one).
longjmp(*(_stackbase->savearea), 1);
setScriptReturn(false);
}
void AGOSEngine_PN::opn_opcode26() {
- while ((_stackbase->classnum != -1) && (_stackbase != NULL))
+ while ((_stackbase != NULL) && (_stackbase->classnum != kJmpClassNum))
junkstack();
dumpstack();
setScriptReturn(true);
@@ -347,6 +359,8 @@ void AGOSEngine_PN::opn_opcode28() {
void AGOSEngine_PN::opn_opcode29() {
popstack(varval());
+ // Jump back to the last doline indicated by the top stackfram.
+ // The -1 tells it to simply go on with its business.
longjmp(*(_stackbase->savearea), -1);
setScriptReturn(false);
}
@@ -395,7 +409,8 @@ void AGOSEngine_PN::opn_opcode32() {
char bf[60];
int a, slot;
- if ((a = varval()) > 2) {
+ a = varval();
+ if (a > 2) {
setScriptReturn(true);
return;
}
@@ -451,10 +466,8 @@ void AGOSEngine_PN::opn_opcode35() {
}
void AGOSEngine_PN::opn_opcode36() {
- int ct = 0;
- while (ct < _dataBase[57] + 1)
- _wordcp[ct++] = 0;
- ct = 1;
+ for (int i = 0; i < _dataBase[57] + 1; ++i)
+ _wordcp[i] = 0;
if (isspace(*_inpp))
while ((*_inpp) && (isspace(*_inpp)))
_inpp++;
@@ -468,6 +481,8 @@ void AGOSEngine_PN::opn_opcode36() {
setScriptReturn(true);
return;
}
+
+ int ct = 1;
while ((*_inpp != '.') && (*_inpp != ',') && (!isspace(*_inpp)) && (*_inpp != '\0') &&
(*_inpp!='"')) {
if (ct < _dataBase[57])
@@ -734,37 +749,38 @@ int AGOSEngine_PN::varval() {
int a;
int b;
- if ((a = readfromline()) < 247) {
+ a = readfromline();
+ if (a < 247) {
return a;
}
switch (a) {
case 249:
b = readfromline();
- return((int)(b + 256 * readfromline()));
+ return (int)(b + 256 * readfromline());
break;
case 250:
- return(readfromline());
+ return readfromline();
case 251:
- return((int)_variableArray[varval()]);
+ return (int)_variableArray[varval()];
case 252:
b = varval();
- return((int)_dataBase[_quickptr[0] + b * _quickshort[0] + varval()]);
+ return (int)_dataBase[_quickptr[0] + b * _quickshort[0] + varval()];
case 254:
b = varval();
- return((int)_dataBase[_quickptr[3] + b * _quickshort[2] + varval()]);
+ return (int)_dataBase[_quickptr[3] + b * _quickshort[2] + varval()];
case 247:
b = varval();
- return((int)getptr(_quickptr[11] + (b * _quickshort[4]) + (2 * varval())));
+ return (int)getptr(_quickptr[11] + (b * _quickshort[4]) + (2 * varval()));
case 248:
b = varval();
- return((int)getptr(_quickptr[12] + (b * _quickshort[5]) + (2 * varval())));
+ return (int)getptr(_quickptr[12] + (b * _quickshort[5]) + (2 * varval()));
case 253:
b = varval();
- return(bitextract((int32)_quickptr[1] + b * _quickshort[1], varval()));
+ return bitextract((int32)_quickptr[1] + b * _quickshort[1], varval());
case 255:
b = varval();
- return(bitextract((int32)_quickptr[4] + b * _quickshort[3], varval()));
+ return bitextract((int32)_quickptr[4] + b * _quickshort[3], varval());
default:
error("VARVAL : Illegal code %d encountered", a);
}
@@ -834,10 +850,10 @@ void AGOSEngine_PN::setbitf(uint32 ptr, int offs, int val) {
int AGOSEngine_PN::actCallD(int n) {
int pf[8];
funcentry(pf, n);
- addstack(-1);
+ addstack(kJmpClassNum);
funccpy(pf);
setposition(n, 0);
- return(doline(1));
+ return doline(1);
}
int AGOSEngine_PN::doaction() {
@@ -859,47 +875,59 @@ int AGOSEngine_PN::doaction() {
int AGOSEngine_PN::doline(int needsave) {
int x;
- jmp_buf *ljmpbuff = NULL;
+ jmp_buf *old_jmpbuf = NULL;
jmp_buf *mybuf;
mybuf = (jmp_buf *)malloc(sizeof(jmp_buf));
if (mybuf == NULL)
error("doline: Out of memory - stack overflow");
- if ((x = setjmp(*mybuf)) > 0) {
+ x = setjmp(*mybuf);
+ // Looking at the longjmp calls below, x can be -1, 1 or 2
+ // (and of course 0 when it returns directly, as always).
+ if (x > 0) {
dumpstack();
- _cjmpbuff = ljmpbuff;
+ // Restore the active jmpbuf to its previous value,
+ // then return the longjmp value (will be 2-1=1 or 1-1=0).
+ _cjmpbuff = old_jmpbuf;
free((char *)mybuf);
return (x - 1);
}
if (x == -1) {
+ // Make this doline instance the active one (again).
+ // This is used to "return" over possibly multiple
+ // layers of nested script invocations.
+ // Kind of like throwing an exception.
_cjmpbuff = mybuf;
goto carryon;
}
- ljmpbuff = _cjmpbuff;
+
+ // Remember the previous active jmpbuf (gets restored
+ // above when a longjmp with a positive param occurs).
+ old_jmpbuf = _cjmpbuff;
_cjmpbuff = mybuf;
if (needsave)
_stackbase->savearea = mybuf;
-nln: _linct = ((*_linebase) & 127) - 1;
- _workptr = _linebase + 1;
- if (*_linebase > 127) {
- x = varval();
- if (x != (int)_variableArray[1])
- goto skipln;
- }
-
-carryon:
do {
- x = doaction();
- } while (x && !shouldQuit());
+ _linct = ((*_linebase) & 127) - 1;
+ _workptr = _linebase + 1;
+ if (*_linebase > 127) {
+ x = varval();
+ if (x != (int)_variableArray[1])
+ goto skipln;
+ }
-skipln: _linebase += 127 & *_linebase;
- _linembr++;
+carryon:
+ do {
+ x = doaction();
+ } while (x && !shouldQuit());
- if (!shouldQuit())
- goto nln;
+skipln:
+ _linebase += 127 & *_linebase;
+ _linembr++;
+ } while (!shouldQuit());
return 0;
}
@@ -951,23 +979,15 @@ int AGOSEngine_PN::findset() {
}
void AGOSEngine_PN::funccpy(int *store) {
- int a = 0;
- int b = 24;
-
- while (a < 8) {
- _variableArray[b++] = *store++;
- a++;
+ for (int i = 24; i < 32; ++i) {
+ _variableArray[i] = *store++;
}
}
void AGOSEngine_PN::funcentry(int *store, int procn) {
- int ct = 0;
- int nprm;
-
- nprm = _dataBase[getlong(_quickptr[6] + 3L * procn)];
- while (ct < nprm) {
+ int numParams = _dataBase[getlong(_quickptr[6] + 3 * procn)];
+ for (int i = 0; i < numParams; ++i) {
*store++ = varval();
- ct++;
}
}
@@ -990,23 +1010,28 @@ int AGOSEngine_PN::gvwrd(uint8 *wptr, int mask) {
int AGOSEngine_PN::setposition(int process, int line) {
uint8 *ourptr;
int np;
- int ct = 0;
- ourptr = _dataBase + getlong(_quickptr[6] + 3L * process);
+ int ct;
+
+ ourptr = _dataBase + getlong(_quickptr[6] + 3 * process);
np = *ourptr++;
- while (ct < line) {
+ for (ct = 0; ct < line; ++ct) {
ourptr += (127 & *ourptr);
- ct++;
}
-x1: _linebase = ourptr;
- _linct = (127 & (*ourptr)) - 1;
- if (*ourptr++ > 127) {
+
+ while (true) {
+ _linebase = ourptr;
+ _linct = (127 & *ourptr) - 1;
+ if (*ourptr++ <= 127)
+ break;
+
ct = varval();
- if (ct != (int)_variableArray[1]) {
- ourptr += _linct - 1;
- line++;
- goto x1;
- }
+ if (ct == (int)_variableArray[1])
+ break;
+
+ ourptr += _linct - 1;
+ line++;
}
+
_linembr = line;
_procnum = process;
_variableArray[0] = process;
@@ -1035,22 +1060,20 @@ int AGOSEngine_PN::wrdmatch(uint8 *word1, int mask1, uint8 *word2, int mask2) {
// -----------------------------------------------------------------------
void AGOSEngine_PN::addstack(int type) {
- struct stackframe *a;
- int pt, ct = 0;
+ StackFrame *a;
+ int i;
- a = (struct stackframe *)malloc(sizeof(struct stackframe));
+ a = (StackFrame *)malloc(sizeof(StackFrame));
if (a == NULL)
error("addstack: Out of memory - stack overflow");
a->nextframe = _stackbase;
_stackbase = a;
- pt = 0;
- while (ct < 6)
- a->flag[ct++] = _variableArray[pt++];
- ct = 0;
- pt = 24;
- while (ct < 8)
- a->param[ct++] = _variableArray[pt++];
+
+ for (i = 0; i < 6; ++i)
+ a->flag[i] = _variableArray[i];
+ for (i = 0; i < 8; ++i)
+ a->param[i] = _variableArray[24 + i];
a->classnum = type;
a->ll = _linct;
a->linenum = _linembr;
@@ -1060,7 +1083,7 @@ void AGOSEngine_PN::addstack(int type) {
}
void AGOSEngine_PN::dumpstack() {
- struct stackframe *a;
+ StackFrame *a;
if (_stackbase == NULL)
error("dumpstack: Stack underflow or unknown longjmp");
@@ -1071,20 +1094,20 @@ void AGOSEngine_PN::dumpstack() {
}
void AGOSEngine_PN::junkstack() {
- struct stackframe *a;
+ StackFrame *a;
if (_stackbase == NULL)
error("junkstack: Stack underflow or unknown longjmp");
a = _stackbase->nextframe;
- if (_stackbase->classnum == -1)
+ if (_stackbase->classnum == kJmpClassNum)
free((char *)_stackbase->savearea);
free((char *)_stackbase);
_stackbase = a;
}
void AGOSEngine_PN::popstack(int type) {
- int a = 0, b;
+ int i;
while ((_stackbase != NULL) && (_stackbase->classnum != type))
junkstack();
@@ -1097,13 +1120,10 @@ void AGOSEngine_PN::popstack(int type) {
_workptr = _stackbase->linpos;
_procnum = _stackbase->process;
_linembr = _stackbase->linenum;
- b = 0;
- while (a < 6)
- _variableArray[b++] = _stackbase->flag[a++];
- b = 24;
- a = 0;
- while (a < 8)
- _variableArray[b++] = _stackbase->param[a++];
+ for (i = 0; i < 6; ++i)
+ _variableArray[i] = _stackbase->flag[i];
+ for (i = 0; i < 8; ++i)
+ _variableArray[24 + i] = _stackbase->param[i];
}
} // End of namespace AGOS
diff --git a/engines/agos/string.cpp b/engines/agos/string.cpp
index a466be796f..3773b1fa10 100644
--- a/engines/agos/string.cpp
+++ b/engines/agos/string.cpp
@@ -136,6 +136,20 @@ const byte *AGOSEngine::getStringPtrByID(uint16 stringId, bool upperCase) {
strcpy((char *)dst, (const char *)stringPtr);
}
+ // WORKAROUND bug #1538873: The French version of Simon 1 and the
+ // Polish version of Simon 2 used excess spaces, at the end of many
+ // messages, so we strip off those excess spaces.
+ if ((getGameType() == GType_SIMON1 && _language == Common::FR_FRA) ||
+ (getGameType() == GType_SIMON2 && _language == Common::PL_POL)) {
+ uint16 len = strlen((const char *)dst) - 1;
+
+ while (len && dst[len] == 32) {
+ dst[len] = 0;
+ len--;
+ }
+
+ }
+
if (upperCase && *dst) {
if (islower(*dst))
*dst = toupper(*dst);
diff --git a/engines/agos/subroutine.cpp b/engines/agos/subroutine.cpp
index 742ac48ac8..70ad3404f5 100644
--- a/engines/agos/subroutine.cpp
+++ b/engines/agos/subroutine.cpp
@@ -226,7 +226,7 @@ void AGOSEngine::alignTableMem() {
}
}
-byte *AGOSEngine::allocateTable(uint size) {
+void *AGOSEngine::allocateTable(uint size) {
byte *org = _tablesHeapPtr;
size = (size + 1) & ~1;
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..d37681508e 100644
--- a/engines/agos/vga.cpp
+++ b/engines/agos/vga.cpp
@@ -1182,11 +1182,13 @@ 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 += _backGroundBuf->pitch;
+ src += screen->pitch;
+ }
_system->unlockScreen();
} else {
uint16 xoffs = _videoWindows[4 * 4 + 0] * 16;
@@ -1194,12 +1196,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 +1230,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 +1252,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..f6e6630d43 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();
@@ -207,6 +207,7 @@ void AGOSEngine::vc53_dissolveIn() {
uint16 speed = vcReadNextWord() + 1;
byte *src, *dst, *srcOffs, *srcOffs2, *dstOffs, *dstOffs2;
+ int16 xoffs, yoffs;
uint8 color = 0;
// Only uses Video Window 4
@@ -218,18 +219,17 @@ void AGOSEngine::vc53_dissolveIn() {
uint16 dissolveDelay = dissolveCheck * 2 / speed;
uint16 dissolveCount = dissolveCheck * 2 / speed;
- int16 xoffs = _videoWindows[num * 4 + 0] * 16;
- int16 yoffs = _videoWindows[num * 4 + 1];
- int16 offs = xoffs + yoffs * _screenWidth;
+ int16 x = _videoWindows[num * 4 + 0] * 16;
+ int16 y = _videoWindows[num * 4 + 1];
uint16 count = dissolveCheck * 2;
while (count--) {
Graphics::Surface *screen = _system->lockScreen();
- byte *dstPtr = (byte *)screen->pixels + offs;
+ byte *dstPtr = (byte *)screen->pixels + x + y * screen->pitch;
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 +252,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;
@@ -284,6 +284,7 @@ void AGOSEngine::vc54_dissolveOut() {
uint16 speed = vcReadNextWord() + 1;
byte *dst, *dstOffs;
+ int16 xoffs, yoffs;
uint16 dissolveX = _videoWindows[num * 4 + 2] * 8;
uint16 dissolveY = (_videoWindows[num * 4 + 3] + 1) / 2;
@@ -291,19 +292,18 @@ void AGOSEngine::vc54_dissolveOut() {
uint16 dissolveDelay = dissolveCheck * 2 / speed;
uint16 dissolveCount = dissolveCheck * 2 / speed;
- int16 xoffs = _videoWindows[num * 4 + 0] * 16;
- int16 yoffs = _videoWindows[num * 4 + 1];
- int16 offs = xoffs + yoffs * _screenWidth;
+ int16 x = _videoWindows[num * 4 + 0] * 16;
+ int16 y = _videoWindows[num * 4 + 1];
uint16 count = dissolveCheck * 2;
while (count--) {
Graphics::Surface *screen = _system->lockScreen();
- byte *dstPtr = (byte *)screen->pixels + offs;
+ byte *dstPtr = (byte *)screen->pixels + x + y * screen->pitch;
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 +313,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 +354,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_ff.cpp b/engines/agos/vga_ff.cpp
index 58eb2f4cc0..14451a3dbe 100644
--- a/engines/agos/vga_ff.cpp
+++ b/engines/agos/vga_ff.cpp
@@ -70,7 +70,7 @@ int AGOSEngine::getScale(int16 y, int16 x) {
void AGOSEngine::vc75_setScale() {
_baseY = vcReadNextWord();
- _scale = (float)vcReadNextWord() / 1000000.;
+ _scale = vcReadNextWord() / 1000000.0f;
}
void AGOSEngine::vc76_setScaleXOffs() {
diff --git a/engines/agos/vga_pn.cpp b/engines/agos/vga_pn.cpp
index e84248bb4d..12846b08f1 100644
--- a/engines/agos/vga_pn.cpp
+++ b/engines/agos/vga_pn.cpp
@@ -129,7 +129,6 @@ void AGOSEngine::vc36_pause() {
_keyPressed.reset();
windowPutChar(_windowArray[2], 13);
- windowPutChar(_windowArray[2], 128);
_wiped = oldWiped;
_videoLockOut &= ~8;
@@ -168,7 +167,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..e7f2ad7807 100644
--- a/engines/agos/vga_ww.cpp
+++ b/engines/agos/vga_ww.cpp
@@ -145,14 +145,20 @@ 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);
+ dst = dstPtr;
+
+ 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 +166,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 +184,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();