aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Howell2007-06-21 03:14:20 +0000
committerTravis Howell2007-06-21 03:14:20 +0000
commit89b2cf75e22fd76b48e9e27d70ba617d5b2468b6 (patch)
tree2acc580f2cac44a4524003665387a9f0b5484185
parent3f5eb0f976e3e6cf0d8e4306ffd3767759eb707f (diff)
downloadscummvm-rg350-89b2cf75e22fd76b48e9e27d70ba617d5b2468b6.tar.gz
scummvm-rg350-89b2cf75e22fd76b48e9e27d70ba617d5b2468b6.tar.bz2
scummvm-rg350-89b2cf75e22fd76b48e9e27d70ba617d5b2468b6.zip
Use frameBuffer directly, in order to drop extra buffer (frontBuffer) and cleanup code.
svn-id: r27577
-rw-r--r--engines/agos/agos.cpp5
-rw-r--r--engines/agos/agos.h5
-rw-r--r--engines/agos/animation.cpp12
-rw-r--r--engines/agos/charset.cpp17
-rw-r--r--engines/agos/draw.cpp82
-rw-r--r--engines/agos/event.cpp20
-rw-r--r--engines/agos/gfx.cpp65
-rw-r--r--engines/agos/icons.cpp39
-rw-r--r--engines/agos/menus.cpp13
-rw-r--r--engines/agos/oracle.cpp13
-rw-r--r--engines/agos/verb.cpp10
-rw-r--r--engines/agos/vga.cpp14
-rw-r--r--engines/agos/vga_e2.cpp39
-rw-r--r--engines/agos/vga_ww.cpp18
-rw-r--r--engines/agos/window.cpp16
15 files changed, 219 insertions, 149 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp
index 1d44fc45b7..d44176bea5 100644
--- a/engines/agos/agos.cpp
+++ b/engines/agos/agos.cpp
@@ -208,7 +208,6 @@ AGOSEngine::AGOSEngine(OSystem *syst)
_cepeFlag = 0;
_copyPartialMode = 0;
_fastMode = 0;
- _useBackGround = 0;
_backFlag = 0;
@@ -502,7 +501,6 @@ AGOSEngine::AGOSEngine(OSystem *syst)
_noOracleScroll = 0;
_backGroundBuf = 0;
- _frontBuf = 0;
_backBuf = 0;
_scaleBuf = 0;
@@ -602,7 +600,6 @@ int AGOSEngine::init() {
// allocate buffers
_backGroundBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
- _frontBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
if (getGameType() == GType_FF || getGameType() == GType_PP) {
_backBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
@@ -935,7 +932,6 @@ AGOSEngine::~AGOSEngine() {
free(_textMem);
free(_backGroundBuf);
- free(_frontBuf);
free(_backBuf);
free(_scaleBuf);
@@ -1068,7 +1064,6 @@ void AGOSEngine::shutdown() {
free(_textMem);
free(_backGroundBuf);
- free(_frontBuf);
free(_backBuf);
free(_scaleBuf);
diff --git a/engines/agos/agos.h b/engines/agos/agos.h
index 20453b1277..7858cf99dd 100644
--- a/engines/agos/agos.h
+++ b/engines/agos/agos.h
@@ -550,7 +550,6 @@ protected:
bool _oopsValid;
byte *_backGroundBuf;
- byte *_frontBuf;
byte *_backBuf;
byte *_scaleBuf;
@@ -1130,7 +1129,6 @@ protected:
void restoreWindow(WindowBlock *window);
void restoreBlock(uint h, uint w, uint y, uint x);
- byte *getFrontBuf();
byte *getBackBuf();
byte *getBackGround();
byte *getScaleBuf();
@@ -1171,10 +1169,7 @@ protected:
void dumpSingleBitmap(int file, int image, const byte *offs, int w, int h, byte base);
void dumpBitmap(const char *filename, const byte *offs, int w, int h, int flags, const byte *palette, byte base);
- void clearBackFromTop(uint lines);
- void fillFrontFromBack(uint x, uint y, uint w, uint h);
void fillBackGroundFromBack(uint lines);
- void fillBackFromFront(uint x, uint y, uint w, uint h);
virtual void doOutput(const byte *src, uint len);
void clsCheck(WindowBlock *window);
diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp
index 1cbf74549d..c36af7aa9c 100644
--- a/engines/agos/animation.cpp
+++ b/engines/agos/animation.cpp
@@ -30,6 +30,7 @@
#include "common/system.h"
#include "graphics/cursorman.h"
+#include "graphics/surface.h"
#include "agos/animation.h"
#include "agos/intern.h"
@@ -140,7 +141,7 @@ void MoviePlayer::play() {
// Resolution is smaller in Amiga verison so always clear screen
if (_width == 384 && _height == 280) {
- memset(_vm->_frontBuf, 0, _vm->_screenHeight * _vm->_screenWidth);
+ _vm->_system->clearScreen();
}
_ticks = _vm->_system->getMillis();
@@ -155,7 +156,9 @@ void MoviePlayer::play() {
_vm->o_killAnimate();
if (_vm->getBitFlag(41)) {
- memcpy(_vm->_backBuf, _vm->_frontBuf, _frameSize);
+ Graphics::Surface *screen = _vm->_system->lockScreen();
+ memcpy(_vm->_backBuf, (byte *)screen->pixels, _frameSize);
+ _vm->_system->unlockScreen();
} else {
uint8 palette[1024];
memset(palette, 0, sizeof(palette));
@@ -303,8 +306,9 @@ void MoviePlayer::setPalette(byte *pal) {
}
bool MoviePlayer::processFrame() {
- copyFrameToBuffer(_vm->getFrontBuf(), (_vm->_screenWidth - _width) / 2, (_vm->_screenHeight - _height) / 2, _vm->_screenWidth);
- _vm->_system->copyRectToScreen(_vm->getFrontBuf(), _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight);
+ Graphics::Surface *screen = _vm->_system->lockScreen();
+ copyFrameToBuffer((byte *)screen->pixels, (_vm->_screenWidth - _width) / 2, (_vm->_screenHeight - _height) / 2, _vm->_screenWidth);
+ _vm->_system->unlockScreen();
if ((_bgSoundStream == NULL) || ((int)(_mixer->getSoundElapsedTime(_bgSound) * _framesPerSec) / 1000 < _frameNum + 1) ||
_frameSkipped > _framesPerSec) {
diff --git a/engines/agos/charset.cpp b/engines/agos/charset.cpp
index 298805ba2d..5b5e85f002 100644
--- a/engines/agos/charset.cpp
+++ b/engines/agos/charset.cpp
@@ -25,9 +25,13 @@
#include "common/stdafx.h"
+#include "common/system.h"
+
#include "agos/agos.h"
#include "agos/intern.h"
+#include "graphics/surface.h"
+
namespace AGOS {
void AGOSEngine_Feeble::doOutput(const byte *src, uint len) {
@@ -712,13 +716,15 @@ void AGOSEngine::windowScroll(WindowBlock *window) {
_lockWord |= 0x8000;
if (window->height != 1) {
+ Graphics::Surface *screen = _system->lockScreen();
+
byte *src, *dst;
uint16 w, h;
w = window->width * 8;
h = (window->height -1) * 8;
- dst = getFrontBuf() + window->y * _screenWidth + window->x * 8;
+ dst = (byte *)screen->pixels + window->y * _screenWidth + window->x * 8;
src = dst + 8 * _screenWidth;
do {
@@ -726,6 +732,8 @@ void AGOSEngine::windowScroll(WindowBlock *window) {
src += _screenWidth;
dst += _screenWidth;
} while (--h);
+
+ _system->unlockScreen();
}
colorBlock(window, window->x * 8, (window->height - 1) * 8 + window->y, window->width * 8, 8);
@@ -2169,14 +2177,16 @@ void AGOSEngine::windowDrawChar(WindowBlock *window, uint x, uint y, byte chr) {
_lockWord |= 0x8000;
- dst = getFrontBuf() + y * _dxSurfacePitch + x + window->textColumnOffset;
+ Graphics::Surface *screen = _system->lockScreen();
if (getGameType() == GType_FF || getGameType() == GType_PP) {
+ dst = getBackGround() + y * _dxSurfacePitch + x + window->textColumnOffset;
h = 13;
w = feebleFontSize[chr - 0x20];
src = feeble_windowFont + (chr - 0x20) * 13;
} else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) {
+ dst = (byte *)screen->pixels + y * _dxSurfacePitch + x + window->textColumnOffset;
h = 8;
w = 6;
@@ -2212,6 +2222,7 @@ void AGOSEngine::windowDrawChar(WindowBlock *window, uint x, uint y, byte chr) {
error("windowDrawChar: Unknown language %d\n", _language);
}
} else {
+ dst = (byte *)screen->pixels + y * _dxSurfacePitch + x + window->textColumnOffset;
h = 8;
w = 6;
@@ -2259,6 +2270,8 @@ void AGOSEngine::windowDrawChar(WindowBlock *window, uint x, uint y, byte chr) {
dst += _dxSurfacePitch;
} while (--h);
+ _system->unlockScreen();
+
_lockWord &= ~0x8000;
}
diff --git a/engines/agos/draw.cpp b/engines/agos/draw.cpp
index 876f523121..af6597ca69 100644
--- a/engines/agos/draw.cpp
+++ b/engines/agos/draw.cpp
@@ -27,19 +27,13 @@
#include "common/system.h"
+#include "graphics/surface.h"
+
#include "agos/agos.h"
#include "agos/intern.h"
namespace AGOS {
-byte *AGOSEngine::getFrontBuf() {
- if (getGameType() != GType_PP && getGameType() != GType_FF)
- _updateScreen = true;
-
- _dxSurfacePitch = _screenWidth;
- return _frontBuf;
-}
-
byte *AGOSEngine::getBackBuf() {
_dxSurfacePitch = _screenWidth;
return _useBackGround ? _backGroundBuf : _backBuf;
@@ -547,10 +541,13 @@ void AGOSEngine::displayBoxStars() {
uint curHeight = (getGameType() == GType_SIMON2) ? _boxStarHeight : 134;
+
for (int i = 0; i < 5; i++) {
ha = _hitAreas;
count = ARRAYSIZE(_hitAreas);
+ Graphics::Surface *screen = _system->lockScreen();
+
do {
if (ha->id != 0 && ha->flags & kBFBoxInUse && !(ha->flags & kBFBoxDead)) {
@@ -578,7 +575,7 @@ void AGOSEngine::displayBoxStars() {
if (x_ >= 311)
continue;
- dst = getFrontBuf();
+ dst = (byte *)screen->pixels;
dst += (((_dxSurfacePitch / 4) * y_) * 4) + x_;
@@ -617,6 +614,8 @@ void AGOSEngine::displayBoxStars() {
}
} while (ha++, --count);
+ _system->unlockScreen();
+
delay(100);
setMoveRect(0, 0, 320, curHeight);
@@ -634,11 +633,7 @@ void AGOSEngine::scrollScreen() {
const byte *src;
uint x, y;
- if (getGameType() == GType_SIMON2) {
- dst = getBackGround();
- } else {
- dst = getFrontBuf();
- }
+ dst = getBackGround();
if (_scrollXMax == 0) {
uint screenSize = 8 * _screenWidth;
@@ -661,8 +656,7 @@ void AGOSEngine::scrollScreen() {
_scrollY += _scrollFlag;
vcWriteVar(250, _scrollY);
- memcpy(_backBuf, _frontBuf, _screenWidth * _screenHeight);
- memcpy(_backGroundBuf, _backBuf, _screenHeight * _scrollWidth);
+ memcpy(_backBuf, _backGroundBuf, _screenHeight * _scrollWidth);
} else {
if (_scrollFlag < 0) {
memmove(dst + 8, dst, _screenWidth * _scrollHeight - 8);
@@ -690,8 +684,7 @@ void AGOSEngine::scrollScreen() {
if (getGameType() == GType_SIMON2) {
memcpy(_window4BackScn, _backGroundBuf, _scrollHeight * _screenWidth);
} else {
- memcpy(_backBuf, _frontBuf, _screenWidth * _screenHeight);
- memcpy(_backGroundBuf, _backBuf, _scrollHeight * _screenWidth);
+ memcpy(_backBuf, _backGroundBuf, _scrollHeight * _screenWidth);
}
setMoveRect(0, 0, 320, _scrollHeight);
@@ -716,43 +709,13 @@ void AGOSEngine::scrollScreen() {
}
}
-void AGOSEngine::clearBackFromTop(uint lines) {
- memset(_backBuf, 0, lines * _screenWidth);
-}
-
void AGOSEngine::clearSurfaces(uint num_lines) {
- memset(_backBuf, 0, num_lines * _screenWidth);
-
- _system->copyRectToScreen(_backBuf, _screenWidth, 0, 0, _screenWidth, num_lines);
-
- if (_useBackGround) {
- memset(_frontBuf, 0, num_lines * _screenWidth);
- memset(_backGroundBuf, 0, num_lines * _screenWidth);
- }
-}
+ Graphics::Surface *screen = _system->lockScreen();
-void AGOSEngine::fillFrontFromBack(uint x, uint y, uint w, uint h) {
- uint offs = x + y * _screenWidth;
- byte *s = _backBuf + offs;
- byte *d = _frontBuf + offs;
-
- do {
- memcpy(d, s, w);
- d += _screenWidth;
- s += _screenWidth;
- } while (--h);
-}
-
-void AGOSEngine::fillBackFromFront(uint x, uint y, uint w, uint h) {
- uint offs = x + y * _screenWidth;
- byte *s = _frontBuf + offs;
- byte *d = _backBuf + offs;
+ memset((byte *)screen->pixels, 0, num_lines * _screenWidth);
+ memset(_backBuf, 0, num_lines * _screenWidth);
- do {
- memcpy(d, s, w);
- d += _screenWidth;
- s += _screenWidth;
- } while (--h);
+ _system->unlockScreen();
}
void AGOSEngine::fillBackGroundFromBack(uint lines) {
@@ -782,18 +745,18 @@ void AGOSEngine::displayScreen() {
}
}
+ Graphics::Surface *screen = _system->lockScreen();
if (getGameType() == GType_PP || getGameType() == GType_FF) {
- _system->copyRectToScreen(getBackBuf(), _screenWidth, 0, 0, _screenWidth, _screenHeight);
- _system->updateScreen();
+ memcpy((byte *)screen->pixels, getBackBuf(), _screenWidth * _screenHeight);
if (getGameId() != GID_DIMP)
- memcpy(getBackBuf(), getFrontBuf(), _screenWidth * _screenHeight);
+ memcpy(getBackBuf(), getBackGround(), _screenWidth * _screenHeight);
} else {
if (_window4Flag == 2) {
_window4Flag = 0;
uint16 srcWidth, width, height;
- byte *dst = getFrontBuf();
+ byte *dst = (byte *)screen->pixels;
const byte *src = _window4BackScn;
if (_window3Flag == 1) {
@@ -827,18 +790,17 @@ void AGOSEngine::displayScreen() {
_window6Flag = 0;
byte *src = _window6BackScn;
- byte *dst = getFrontBuf() + 16320;
+ byte *dst = (byte *)screen->pixels + 16320;
for (int i = 0; i < 80; i++) {
memcpy(dst, src, 48);
dst += _screenWidth;
src += 48;
}
}
-
- _system->copyRectToScreen(getFrontBuf(), _screenWidth, 0, 0, _screenWidth, _screenHeight);
- _system->updateScreen();
}
+ _system->unlockScreen();
+
if (getGameType() == GType_FF && _scrollFlag) {
scrollScreen();
}
diff --git a/engines/agos/event.cpp b/engines/agos/event.cpp
index 13de82fcbd..4c0f2c1eb6 100644
--- a/engines/agos/event.cpp
+++ b/engines/agos/event.cpp
@@ -34,6 +34,8 @@
#include "gui/about.h"
+#include "graphics/surface.h"
+
#include "sound/audiocd.h"
namespace AGOS {
@@ -366,13 +368,17 @@ static const byte _image4[32] = {
void AGOSEngine::drawStuff(const byte *src, uint xoffs) {
const uint8 y = (getPlatform() == Common::kPlatformAtariST) ? 132 : 135;
- byte *dst = getFrontBuf() + y * _screenWidth + xoffs;
+
+ Graphics::Surface *screen = _system->lockScreen();
+ byte *dst = (byte *)screen->pixels + y * _screenWidth + xoffs;
for (uint h = 0; h < 6; h++) {
memcpy(dst, src, 4);
src += 4;
dst += _screenWidth;
}
+
+ _system->unlockScreen();
}
void AGOSEngine::imageEvent2(VgaTimerEntry * vte, uint dx) {
@@ -587,11 +593,6 @@ void AGOSEngine_Feeble::timer_proc1() {
animateSprites();
}
- if (_copyPartialMode == 2) {
- fillFrontFromBack(0, 0, _screenWidth, _screenHeight);
- _copyPartialMode = 0;
- }
-
if (_displayScreen) {
if (getGameType() == GType_FF) {
if (!getBitFlag(78)) {
@@ -627,13 +628,6 @@ void AGOSEngine::timer_proc1() {
processVgaEvents();
}
- if (_updateScreen) {
- _system->copyRectToScreen(getFrontBuf(), _screenWidth, 0, 0, _screenWidth, _screenHeight);
- _system->updateScreen();
-
- _updateScreen = false;
- }
-
if (_displayScreen) {
displayScreen();
_displayScreen = false;
diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp
index 2ce6b03b03..28c10c0f1e 100644
--- a/engines/agos/gfx.cpp
+++ b/engines/agos/gfx.cpp
@@ -25,6 +25,10 @@
#include "common/stdafx.h"
+#include "common/system.h"
+
+#include "graphics/surface.h"
+
#include "agos/agos.h"
#include "agos/intern.h"
#include "agos/vga.h"
@@ -289,6 +293,9 @@ 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;
+
if (state->flags & kDFCompressed) {
if (state->flags & kDFScaled) {
state->surf_addr = getScaleBuf();
@@ -357,8 +364,9 @@ void AGOSEngine_Feeble::drawImage(VC10_state *state) {
scaleClip(_scaleHeight, _scaleWidth, _scaleY, _scaleX, _scaleY + _scrollY);
}
} else {
- if (!drawImage_clip(state))
+ if (!drawImage_clip(state)) {
return;
+ }
state->surf_addr += state->x + state->y * state->surf_pitch;
@@ -373,14 +381,18 @@ void AGOSEngine_Feeble::drawImage(VC10_state *state) {
if (state->flags & kDFMasked) {
if (getGameType() == GType_FF && !getBitFlag(81)) {
- if (state->x > _feebleRect.right)
+ if (state->x > _feebleRect.right) {
return;
- if (state->y > _feebleRect.bottom)
+ }
+ if (state->y > _feebleRect.bottom) {
return;
- if (state->x + state->width < _feebleRect.left)
+ }
+ if (state->x + state->width < _feebleRect.left) {
return;
- if (state->y + state->height < _feebleRect.top)
+ }
+ if (state->y + state->height < _feebleRect.top) {
return;
+ }
}
dstPtr = state->surf_addr;
@@ -423,8 +435,9 @@ void AGOSEngine_Feeble::drawImage(VC10_state *state) {
}
}
} else {
- if (!drawImage_clip(state))
+ if (!drawImage_clip(state)) {
return;
+ }
state->surf_addr += state->x + state->y * state->surf_pitch;
@@ -448,7 +461,7 @@ void AGOSEngine_Feeble::drawImage(VC10_state *state) {
dst += _screenWidth;
src += state->width;
} while (--state->draw_height);
- }
+ }
}
void AGOSEngine_Simon1::drawMaskedImage(VC10_state *state) {
@@ -629,6 +642,8 @@ void AGOSEngine_Simon1::drawImage(VC10_state *state) {
if (!drawImage_clip(state))
return;
+ Graphics::Surface *screen = _system->lockScreen();
+
if (getFeatures() & GF_32COLOR)
state->palette = 0xC0;
@@ -663,7 +678,7 @@ void AGOSEngine_Simon1::drawImage(VC10_state *state) {
_window4Flag = 1;
} else {
- state->surf_addr = getFrontBuf();
+ state->surf_addr = (byte *)screen->pixels;
state->surf_pitch = _screenWidth;
xoffs = (vlut[0] * 2 + state->x) * 8;
@@ -697,7 +712,7 @@ void AGOSEngine_Simon1::drawImage(VC10_state *state) {
state->surf2_addr = getBackGround();
state->surf2_pitch = _screenWidth;
- state->surf_addr = getFrontBuf();
+ state->surf_addr = (byte *)screen->pixels;
state->surf_pitch = _screenWidth;
xoffs = (vlut[0] * 2 + state->x) * 8;
@@ -717,6 +732,8 @@ void AGOSEngine_Simon1::drawImage(VC10_state *state) {
} else {
drawVertImage(state);
}
+
+ _system->unlockScreen();
}
void AGOSEngine::drawBackGroundImage(VC10_state *state) {
@@ -812,6 +829,8 @@ void AGOSEngine::drawImage(VC10_state *state) {
if (!drawImage_clip(state))
return;
+ Graphics::Surface *screen = _system->lockScreen();
+
uint16 xoffs, yoffs;
if (getGameType() == GType_WW) {
if (_windowNum == 4 || (_windowNum >= 10 && _windowNum <= 27)) {
@@ -827,7 +846,7 @@ void AGOSEngine::drawImage(VC10_state *state) {
_window4Flag = 1;
} else {
- state->surf_addr = getFrontBuf();
+ state->surf_addr = (byte *)screen->pixels;
state->surf_pitch = _screenWidth;
xoffs = (vlut[0] * 2 + state->x) * 8;
@@ -847,7 +866,7 @@ void AGOSEngine::drawImage(VC10_state *state) {
_window4Flag = 1;
} else {
- state->surf_addr = getFrontBuf();
+ state->surf_addr = (byte *)screen->pixels;
state->surf_pitch = _screenWidth;
xoffs = (vlut[0] * 2 + state->x) * 8;
@@ -861,7 +880,7 @@ void AGOSEngine::drawImage(VC10_state *state) {
xoffs = state->x * 8;
yoffs = state->y;
} else if (_windowNum == 2 || _windowNum == 3) {
- state->surf_addr = getFrontBuf();
+ state->surf_addr = (byte *)screen->pixels;
state->surf_pitch = _screenWidth;
xoffs = (vlut[0] * 2 + state->x) * 8;
@@ -894,6 +913,8 @@ void AGOSEngine::drawImage(VC10_state *state) {
} else {
drawVertImage(state);
}
+
+ _system->unlockScreen();
}
void AGOSEngine::horizontalScroll(VC10_state *state) {
@@ -1280,7 +1301,6 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vga_res_id) {
setImage(vga_res_id);
if (getGameType() == GType_FF || getGameType() == GType_PP) {
- fillFrontFromBack(0, 0, _screenWidth, _screenHeight);
fillBackGroundFromBack(_screenHeight);
_syncFlag2 = 1;
} else {
@@ -1298,6 +1318,7 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vga_res_id) {
uint width = _videoWindows[updateWindow * 4 + 2] * 16;
uint height = _videoWindows[updateWindow * 4 + 3];
+ Graphics::Surface *screen = _system->lockScreen();
byte *dst = getBackGround() + xoffs + yoffs * _screenWidth;
byte *src;
uint srcWidth;
@@ -1311,9 +1332,10 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vga_res_id) {
src = _window4BackScn;
srcWidth = _videoWindows[18] * 16;
} else if (updateWindow == 3 || updateWindow == 9) {
- src = getFrontBuf() + xoffs + yoffs * _screenWidth;
+ src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
srcWidth = _screenWidth;
} else {
+ _system->unlockScreen();
_lockWord &= ~0x20;
return;
}
@@ -1325,9 +1347,10 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vga_res_id) {
src = _window4BackScn + xoffs + yoffs * 320;
srcWidth = _videoWindows[18] * 16;
} else if (updateWindow == 0) {
- src = getFrontBuf() + xoffs + yoffs * _screenWidth;
+ src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
srcWidth = _screenWidth;
} else {
+ _system->unlockScreen();
_lockWord &= ~0x20;
return;
}
@@ -1336,9 +1359,10 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vga_res_id) {
src = _window4BackScn;
srcWidth = _videoWindows[18] * 16;
} else if (updateWindow == 3 || updateWindow == 9) {
- src = getFrontBuf() + xoffs + yoffs * _screenWidth;
+ src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
srcWidth = _screenWidth;
} else {
+ _system->unlockScreen();
_lockWord &= ~0x20;
return;
}
@@ -1347,9 +1371,10 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vga_res_id) {
src = _window4BackScn;
srcWidth = _videoWindows[18] * 16;
} else if (updateWindow == 3) {
- src = getFrontBuf() + xoffs + yoffs * _screenWidth;
+ src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
srcWidth = _screenWidth;
} else {
+ _system->unlockScreen();
_lockWord &= ~0x20;
return;
}
@@ -1359,7 +1384,7 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vga_res_id) {
src = _window6BackScn;
srcWidth = 48;
} else if (updateWindow == 2 || updateWindow == 3) {
- src = getFrontBuf() + xoffs + yoffs * _screenWidth;
+ src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
srcWidth = _screenWidth;
} else {
src = _window4BackScn;
@@ -1376,7 +1401,7 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vga_res_id) {
}
if (getGameType() == GType_ELVIRA1 && updateWindow == 3 && _bottomPalette) {
- dst = getFrontBuf() + 133 * _screenWidth;
+ dst = (byte *)screen->pixels + 133 * _screenWidth;
int size = 67 * _screenWidth;
while (size--) {
@@ -1384,6 +1409,8 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vga_res_id) {
dst++;
}
}
+
+ _system->unlockScreen();
}
_lockWord &= ~0x20;
diff --git a/engines/agos/icons.cpp b/engines/agos/icons.cpp
index 64703c29a1..d1c58b68fb 100644
--- a/engines/agos/icons.cpp
+++ b/engines/agos/icons.cpp
@@ -25,8 +25,12 @@
#include "common/stdafx.h"
+#include "common/system.h"
+
#include "common/file.h"
+#include "graphics/surface.h"
+
#include "agos/agos.h"
namespace AGOS {
@@ -193,7 +197,9 @@ void AGOSEngine_Simon2::drawIcon(WindowBlock *window, uint icon, uint x, uint y)
byte *src;
_lockWord |= 0x8000;
- dst = getFrontBuf();
+
+ Graphics::Surface *screen = _system->lockScreen();
+ dst = (byte *)screen->pixels;
dst += 110;
dst += x;
@@ -207,6 +213,8 @@ void AGOSEngine_Simon2::drawIcon(WindowBlock *window, uint icon, uint x, uint y)
src += READ_LE_UINT16(&((uint16 *)src)[icon * 2 + 1]);
decompressIcon(dst, src, 20, 10, 208, _dxSurfacePitch);
+ _system->unlockScreen();
+
_lockWord &= ~0x8000;
}
@@ -215,7 +223,9 @@ void AGOSEngine_Simon1::drawIcon(WindowBlock *window, uint icon, uint x, uint y)
byte *src;
_lockWord |= 0x8000;
- dst = getFrontBuf();
+
+ Graphics::Surface *screen = _system->lockScreen();
+ dst = (byte *)screen->pixels;
dst += (x + window->x) * 8;
dst += (y * 25 + window->y) * _dxSurfacePitch;
@@ -231,6 +241,8 @@ void AGOSEngine_Simon1::drawIcon(WindowBlock *window, uint icon, uint x, uint y)
decompressIcon(dst, src, 24, 12, 224, _dxSurfacePitch);
}
+ _system->unlockScreen();
+
_lockWord &= ~0x8000;
}
@@ -239,7 +251,9 @@ void AGOSEngine_Waxworks::drawIcon(WindowBlock *window, uint icon, uint x, uint
byte *src;
_lockWord |= 0x8000;
- dst = getFrontBuf();
+
+ Graphics::Surface *screen = _system->lockScreen();
+ dst = (byte *)screen->pixels;
dst += (x + window->x) * 8;
dst += (y * 20 + window->y) * _dxSurfacePitch;
@@ -255,6 +269,8 @@ void AGOSEngine_Waxworks::drawIcon(WindowBlock *window, uint icon, uint x, uint
decompressIcon(dst, src, 24, 10, color, _dxSurfacePitch);
}
+ _system->unlockScreen();
+
_lockWord &= ~0x8000;
}
@@ -263,7 +279,9 @@ void AGOSEngine_Elvira2::drawIcon(WindowBlock *window, uint icon, uint x, uint y
byte *src;
_lockWord |= 0x8000;
- dst = getFrontBuf();
+
+ Graphics::Surface *screen = _system->lockScreen();
+ dst = (byte *)screen->pixels;
dst += (x + window->x) * 8;
dst += (y * 8 + window->y) * _dxSurfacePitch;
@@ -279,6 +297,8 @@ void AGOSEngine_Elvira2::drawIcon(WindowBlock *window, uint icon, uint x, uint y
decompressIcon(dst, src, 24, 12, color, _dxSurfacePitch);
}
+ _system->unlockScreen();
+
_lockWord &= ~0x8000;
}
@@ -287,7 +307,9 @@ void AGOSEngine::drawIcon(WindowBlock *window, uint icon, uint x, uint y) {
byte *src;
_lockWord |= 0x8000;
- dst = getFrontBuf();
+
+ Graphics::Surface *screen = _system->lockScreen();
+ dst = (byte *)screen->pixels;
dst += (x + window->x) * 8;
dst += (y * 8 + window->y) * _dxSurfacePitch;
@@ -302,6 +324,8 @@ void AGOSEngine::drawIcon(WindowBlock *window, uint icon, uint x, uint y) {
decompressIconPlanar(dst, src, 24, 12, 16, _dxSurfacePitch, false);
}
+ _system->unlockScreen();
+
_lockWord &= ~0x8000;
}
@@ -882,7 +906,8 @@ void AGOSEngine::drawArrow(uint16 x, uint16 y, int8 dir) {
src = _arrowImage;
}
- byte *dst = getFrontBuf() + y * _screenWidth + x * 8;
+ Graphics::Surface *screen = _system->lockScreen();
+ byte *dst = (byte *)screen->pixels + y * _screenWidth + x * 8;
for (h = 0; h < 19; h++) {
for (w = 0; w < 16; w++) {
@@ -892,6 +917,8 @@ void AGOSEngine::drawArrow(uint16 x, uint16 y, int8 dir) {
src += dir;
dst+= _screenWidth;
}
+
+ _system->unlockScreen();
}
void AGOSEngine::removeArrows(WindowBlock *window, uint num) {
diff --git a/engines/agos/menus.cpp b/engines/agos/menus.cpp
index 802752fad9..6dd1a356d8 100644
--- a/engines/agos/menus.cpp
+++ b/engines/agos/menus.cpp
@@ -26,6 +26,9 @@
#include "common/stdafx.h"
#include "common/file.h"
+#include "common/system.h"
+
+#include "graphics/surface.h"
#include "agos/agos.h"
#include "agos/intern.h"
@@ -145,7 +148,8 @@ void AGOSEngine::unlightMenuStrip() {
mouseOff();
- src = getFrontBuf() + 2832;
+ Graphics::Surface *screen = _system->lockScreen();
+ src = (byte *)screen->pixels + 2832;
w = 48;
h = 82;
@@ -160,6 +164,8 @@ void AGOSEngine::unlightMenuStrip() {
for (i = 120; i != 130; i++)
disableBox(i);
+ _system->unlockScreen();
+
mouseOn();
}
@@ -170,7 +176,8 @@ void AGOSEngine::lightMenuBox(uint hitarea) {
mouseOff();
- src = getFrontBuf() + ha->y * _dxSurfacePitch + ha->x;
+ Graphics::Surface *screen = _system->lockScreen();
+ src = (byte *)screen->pixels + ha->y * _dxSurfacePitch + ha->x;
w = ha->width;
h = ha->height;
@@ -182,6 +189,8 @@ void AGOSEngine::lightMenuBox(uint hitarea) {
src += _dxSurfacePitch;
} while (--h);
+ _system->unlockScreen();
+
mouseOn();
}
diff --git a/engines/agos/oracle.cpp b/engines/agos/oracle.cpp
index c38ee8fa6d..787596a966 100644
--- a/engines/agos/oracle.cpp
+++ b/engines/agos/oracle.cpp
@@ -26,6 +26,9 @@
#include "common/stdafx.h"
#include "common/savefile.h"
+#include "common/system.h"
+
+#include "graphics/surface.h"
#include "agos/agos.h"
#include "agos/intern.h"
@@ -247,8 +250,8 @@ void AGOSEngine_Feeble::scrollOracleUp() {
byte *src, *dst;
uint16 w, h;
- dst = getFrontBuf() + 103 * _screenWidth + 136;
- src = getFrontBuf() + 106 * _screenWidth + 136;
+ dst = getBackGround() + 103 * _screenWidth + 136;
+ src = getBackGround() + 106 * _screenWidth + 136;
for (h = 0; h < 21; h++) {
for (w = 0; w < 360; w++) {
@@ -276,8 +279,8 @@ void AGOSEngine_Feeble::scrollOracleDown() {
byte *src, *dst;
uint16 w, h;
- src = getFrontBuf() + 203 * _screenWidth + 136;
- dst = getFrontBuf() + 206 * _screenWidth + 136;
+ src = getBackGround() + 203 * _screenWidth + 136;
+ dst = getBackGround() + 206 * _screenWidth + 136;
for (h = 0; h < 77; h++) {
memcpy(dst, src, 360);
@@ -507,7 +510,7 @@ void AGOSEngine_Feeble::windowBackSpace(WindowBlock *window) {
x = window->x + window->textColumn;
y = window->y + window->textRow;
- dst = getFrontBuf() + _dxSurfacePitch * y + x;
+ dst = getBackGround() + _dxSurfacePitch * y + x;
for (h = 0; h < 13; h++) {
for (w = 0; w < 8; w++) {
diff --git a/engines/agos/verb.cpp b/engines/agos/verb.cpp
index 8c898cfaeb..f99d6db591 100644
--- a/engines/agos/verb.cpp
+++ b/engines/agos/verb.cpp
@@ -26,6 +26,10 @@
// Verb and hitarea handling
#include "common/stdafx.h"
+#include "common/system.h"
+
+#include "graphics/surface.h"
+
#include "agos/agos.h"
#include "agos/intern.h"
@@ -832,7 +836,9 @@ void AGOSEngine::invertBox(HitArea * ha, byte a, byte b, byte c, byte d) {
int w, h, i;
_lockWord |= 0x8000;
- src = getFrontBuf() + ha->y * _dxSurfacePitch + ha->x;
+
+ Graphics::Surface *screen = _system->lockScreen();
+ src = (byte *)screen->pixels + ha->y * _dxSurfacePitch + ha->x;
// WORKAROUND: Hitareas for saved game names aren't adjusted for scrolling locations
if (getGameType() == GType_SIMON2 && ha->id >= 208 && ha->id <= 213) {
@@ -875,6 +881,8 @@ void AGOSEngine::invertBox(HitArea * ha, byte a, byte b, byte c, byte d) {
src += _dxSurfacePitch;
} while (--h);
+ _system->unlockScreen();
+
_lockWord &= ~0x8000;
}
diff --git a/engines/agos/vga.cpp b/engines/agos/vga.cpp
index 9e1f913410..4f400fa1fb 100644
--- a/engines/agos/vga.cpp
+++ b/engines/agos/vga.cpp
@@ -32,6 +32,8 @@
#include "common/system.h"
+#include "graphics/surface.h"
+
namespace AGOS {
// Opcode tables
@@ -698,12 +700,6 @@ void AGOSEngine::drawImage_init(int16 image, uint16 palette, int16 x, int16 y, u
}
}
- state.surf2_addr = getFrontBuf();
- state.surf2_pitch = _dxSurfacePitch;
-
- state.surf_addr = getBackBuf();
- state.surf_pitch = _dxSurfacePitch;
-
drawImage(&state);
}
@@ -1170,7 +1166,9 @@ void AGOSEngine::clearVideoWindow(uint num, uint color) {
_window4Flag = 1;
} else {
if (getGameType() == GType_ELVIRA1 && num == 3) {
- memset(getFrontBuf(), color, _screenWidth * _screenHeight);
+ Graphics::Surface *screen = _system->lockScreen();
+ memset((byte *)screen->pixels, color, _screenWidth * _screenHeight);
+ _system->unlockScreen();
} else if (num == 4) {
const uint16 *vlut = &_videoWindows[num * 4];
uint xoffs = (vlut[0] - _videoWindows[16]) * 16;
@@ -1219,7 +1217,7 @@ void AGOSEngine::vc36_setWindowImage() {
uint16 windowNum = vcReadNextWord();
if (getGameType() == GType_FF || getGameType() == GType_PP) {
- _copyPartialMode = 2;
+ memcpy(_backGroundBuf, _backBuf, _screenHeight * _screenWidth);
} else {
setWindowImage(windowNum, vga_res);
}
diff --git a/engines/agos/vga_e2.cpp b/engines/agos/vga_e2.cpp
index ca1a3a4469..a3f335c4b9 100644
--- a/engines/agos/vga_e2.cpp
+++ b/engines/agos/vga_e2.cpp
@@ -31,6 +31,8 @@
#include "common/system.h"
+#include "graphics/surface.h"
+
namespace AGOS {
void AGOSEngine_Elvira2::setupVideoOpcodes(VgaOpcodeProc *op) {
@@ -85,7 +87,10 @@ void AGOSEngine::vc45_setWindowPalette() {
}
} else {
const uint16 *vlut = &_videoWindows[num * 4];
- uint16 *dst = (uint16 *)getFrontBuf() + vlut[0] * 8 + vlut[1] * _dxSurfacePitch / 2;
+
+ Graphics::Surface *screen = _system->lockScreen();
+ uint16 *dst = (uint16 *)screen->pixels + vlut[0] * 8 + vlut[1] * _dxSurfacePitch / 2;
+
uint width = vlut[2] * 16 / 2;
uint height = vlut[3];
@@ -101,6 +106,8 @@ void AGOSEngine::vc45_setWindowPalette() {
}
dst += _dxSurfacePitch / 2;
}
+
+ _system->unlockScreen();
}
}
@@ -211,10 +218,13 @@ void AGOSEngine::vc53_dissolveIn() {
int16 xoffs = _videoWindows[num * 4 + 0] * 16;
int16 yoffs = _videoWindows[num * 4 + 1];
- byte *dstPtr = getFrontBuf() + xoffs + yoffs * _screenWidth;
+ int16 offs = xoffs + yoffs * _screenWidth;
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;
@@ -253,15 +263,15 @@ void AGOSEngine::vc53_dissolveIn() {
*dst &= color;
*dst |= *src & 0xF;
+ _system->unlockScreen();
+
dissolveCount--;
if (!dissolveCount) {
if (count >= dissolveCheck)
dissolveDelay++;
dissolveCount = dissolveDelay;
- _system->copyRectToScreen(getFrontBuf(), _screenWidth, 0, 0, _screenWidth, _screenHeight);
- _system->updateScreen();
- delay(0);
+ delay(1);
}
}
}
@@ -281,11 +291,14 @@ void AGOSEngine::vc54_dissolveOut() {
int16 xoffs = _videoWindows[num * 4 + 0] * 16;
int16 yoffs = _videoWindows[num * 4 + 1];
- byte *dstPtr = getFrontBuf() + xoffs + yoffs * _screenWidth;
- color |= dstPtr[0] & 0xF0;
+ int16 offs = xoffs + yoffs * _screenWidth;
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;
@@ -304,15 +317,15 @@ void AGOSEngine::vc54_dissolveOut() {
dst += xoffs;
*dst = color;
+ _system->unlockScreen();
+
dissolveCount--;
if (!dissolveCount) {
if (count >= dissolveCheck)
dissolveDelay++;
dissolveCount = dissolveDelay;
- _system->copyRectToScreen(getFrontBuf(), _screenWidth, 0, 0, _screenWidth, _screenHeight);
- _system->updateScreen();
- delay(0);
+ delay(1);
}
}
}
@@ -339,11 +352,15 @@ void AGOSEngine::vc55_moveBox() {
}
void AGOSEngine::vc56_fullScreen() {
+ Graphics::Surface *screen = _system->lockScreen();
+
+ byte *dst = (byte *)screen->pixels;
byte *src = _curVgaFile2 + 32;
- byte *dst = getFrontBuf();
memcpy(dst, src + 768, _screenHeight * _screenWidth);
+ _system->unlockScreen();
+
//fullFade();
uint8 palette[1024];
diff --git a/engines/agos/vga_ww.cpp b/engines/agos/vga_ww.cpp
index 09b51ecfe1..a14129cc72 100644
--- a/engines/agos/vga_ww.cpp
+++ b/engines/agos/vga_ww.cpp
@@ -31,6 +31,8 @@
#include "common/system.h"
+#include "graphics/surface.h"
+
namespace AGOS {
void AGOSEngine_Waxworks::setupVideoOpcodes(VgaOpcodeProc *op) {
@@ -139,13 +141,15 @@ void AGOSEngine::vc61() {
byte *src, *dst, *dstPtr;
uint h, tmp;
+ Graphics::Surface *screen = _system->lockScreen();
+
if (a == 6) {
src = _curVgaFile2 + 800;
- dstPtr = getFrontBuf();
+ dstPtr = (byte *)screen->pixels;
memcpy(dstPtr, src, 64000);
tmp = 4 - 1;
} else {
- dstPtr = getFrontBuf();
+ dstPtr = (byte *)screen->pixels;
tmp = a - 1;
}
@@ -164,8 +168,10 @@ void AGOSEngine::vc61() {
dst += _screenWidth;
}
- if (a != 6)
+ if (a != 6) {
+ _system->unlockScreen();
return;
+ }
src = _curVgaFile2 + 9984 * 16 + 15344;
}
@@ -177,6 +183,8 @@ void AGOSEngine::vc61() {
dst += _screenWidth;
}
+ _system->unlockScreen();
+
if (a == 6) {
//fullFade();
src = _curVgaFile2 + 32;
@@ -229,10 +237,10 @@ void AGOSEngine::vc62_fastFadeOut() {
if (getGameType() == GType_FF || getGameType() == GType_PP) {
clearSurfaces(_screenHeight);
} else if (getGameType() == GType_WW) {
- memset(getFrontBuf(), 0, _screenWidth * _screenHeight);
+ _system->clearScreen();
} else {
if (_windowNum != 4) {
- memset(getFrontBuf(), 0, _screenWidth * _screenHeight);
+ _system->clearScreen();
}
}
}
diff --git a/engines/agos/window.cpp b/engines/agos/window.cpp
index c02a733972..9aaa6a6896 100644
--- a/engines/agos/window.cpp
+++ b/engines/agos/window.cpp
@@ -25,6 +25,10 @@
#include "common/stdafx.h"
+#include "common/system.h"
+
+#include "graphics/surface.h"
+
#include "agos/agos.h"
#include "agos/intern.h"
@@ -119,7 +123,7 @@ void AGOSEngine_Feeble::colorWindow(WindowBlock *window) {
_lockWord |= 0x8000;
- dst = getFrontBuf() + _dxSurfacePitch * window->y + window->x;
+ dst = getBackGround() + _dxSurfacePitch * window->y + window->x;
for (h = 0; h < window->height; h++) {
for (w = 0; w < window->width; w++) {
@@ -161,7 +165,8 @@ void AGOSEngine::colorWindow(WindowBlock *window) {
void AGOSEngine::colorBlock(WindowBlock *window, uint16 x, uint16 y, uint16 w, uint16 h) {
_lockWord |= 0x8000;
- byte *dst = getFrontBuf() + y * _screenWidth + x;
+ Graphics::Surface *screen = _system->lockScreen();
+ byte *dst = (byte *)screen->pixels + y * _screenWidth + x;
uint8 color = window->fill_color;
if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW)
@@ -172,6 +177,8 @@ void AGOSEngine::colorBlock(WindowBlock *window, uint16 x, uint16 y, uint16 w, u
dst += _screenWidth;
} while (--h);
+ _system->unlockScreen();
+
_lockWord &= ~0x8000;
}
@@ -220,7 +227,8 @@ void AGOSEngine::restoreBlock(uint h, uint w, uint y, uint x) {
byte *dst, *src;
uint i;
- dst = getFrontBuf();
+ Graphics::Surface *screen = _system->lockScreen();
+ dst = (byte *)screen->pixels;
src = getBackGround();
dst += y * _dxSurfacePitch;
@@ -237,6 +245,8 @@ void AGOSEngine::restoreBlock(uint h, uint w, uint y, uint x) {
dst += _dxSurfacePitch;
src += _dxSurfacePitch;
}
+
+ _system->unlockScreen();
}
void AGOSEngine::setTextColor(uint color) {