[Scummvm-cvs-logs] scummvm master -> 463aa52ac6bad2f5d15c1daed613396e5c0e149b

lordhoto lordhoto at gmail.com
Mon Dec 26 19:34:53 CET 2011


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
487e73bd21 KYRA: Merge Screen_Rpg with Screen (for now).
463aa52ac6 KYRA: Cleanup va_arg use in drawShape.


Commit: 487e73bd218775dec22818477ad75dd230d97052
    https://github.com/scummvm/scummvm/commit/487e73bd218775dec22818477ad75dd230d97052
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-12-26T10:32:05-08:00

Commit Message:
KYRA: Merge Screen_Rpg with Screen (for now).

This should(!) fix ARM compilation issues due to virtual inheritance.

Changed paths:
  R engines/kyra/screen_rpg.cpp
  R engines/kyra/screen_rpg.h
    engines/kyra/eobcommon.h
    engines/kyra/kyra_rpg.h
    engines/kyra/lol.cpp
    engines/kyra/lol.h
    engines/kyra/module.mk
    engines/kyra/scene_rpg.cpp
    engines/kyra/screen.cpp
    engines/kyra/screen.h
    engines/kyra/screen_eob.cpp
    engines/kyra/screen_eob.h
    engines/kyra/screen_hof.cpp
    engines/kyra/screen_hof.h
    engines/kyra/screen_lok.cpp
    engines/kyra/screen_lok.h
    engines/kyra/screen_lol.cpp
    engines/kyra/screen_lol.h
    engines/kyra/screen_mr.cpp
    engines/kyra/screen_mr.h
    engines/kyra/screen_v2.cpp
    engines/kyra/screen_v2.h
    engines/kyra/text_lol.cpp
    engines/kyra/text_lol.h
    engines/kyra/text_rpg.cpp
    engines/kyra/text_rpg.h



diff --git a/engines/kyra/eobcommon.h b/engines/kyra/eobcommon.h
index dfc99ea..fa65c93 100644
--- a/engines/kyra/eobcommon.h
+++ b/engines/kyra/eobcommon.h
@@ -251,7 +251,6 @@ public:
 	virtual ~EoBCoreEngine();
 
 	Screen *screen() { return _screen; }
-	Screen_Rpg *screen_rpg() { return _screen; }
 	GUI *gui() const { return _gui; }
 
 protected:
diff --git a/engines/kyra/kyra_rpg.h b/engines/kyra/kyra_rpg.h
index 13a67c6..1a5acb8 100644
--- a/engines/kyra/kyra_rpg.h
+++ b/engines/kyra/kyra_rpg.h
@@ -87,7 +87,6 @@ public:
 	virtual ~KyraRpgEngine();
 
 	virtual Screen *screen() = 0;
-	virtual Screen_Rpg *screen_rpg() = 0;
 	virtual GUI *gui() const = 0;
 
 protected:
diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp
index d90b5c9..01b1bdf 100644
--- a/engines/kyra/lol.cpp
+++ b/engines/kyra/lol.cpp
@@ -361,10 +361,6 @@ Screen *LoLEngine::screen() {
 	return _screen;
 }
 
-Screen_Rpg *LoLEngine::screen_rpg() {
-	return _screen;
-}
-
 GUI *LoLEngine::gui() const {
 	return _gui;
 }
diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h
index 3a6486b..eeaa1b5 100644
--- a/engines/kyra/lol.h
+++ b/engines/kyra/lol.h
@@ -279,7 +279,6 @@ public:
 	virtual void initKeymap();
 
 	Screen *screen();
-	Screen_Rpg *screen_rpg();
 	GUI *gui() const;
 
 private:
diff --git a/engines/kyra/module.mk b/engines/kyra/module.mk
index edadcdb..21e3ba3 100644
--- a/engines/kyra/module.mk
+++ b/engines/kyra/module.mk
@@ -78,7 +78,6 @@ KYRARPG_COMMON_OBJ = \
 	kyra_rpg.o \
 	saveload_rpg.o \
 	scene_rpg.o \
-	screen_rpg.o \
 	sprites_rpg.o \
 	staticres_rpg.o \
 	text_rpg.o \
diff --git a/engines/kyra/scene_rpg.cpp b/engines/kyra/scene_rpg.cpp
index 88e992f..07a7a87 100644
--- a/engines/kyra/scene_rpg.cpp
+++ b/engines/kyra/scene_rpg.cpp
@@ -23,7 +23,6 @@
 #if defined(ENABLE_EOB) || defined(ENABLE_LOL)
 
 #include "kyra/kyra_rpg.h"
-#include "kyra/screen_rpg.h"
 #include "kyra/resource.h"
 #include "kyra/timer.h"
 #include "kyra/sound.h"
@@ -118,11 +117,11 @@ void KyraRpgEngine::scaleLevelShapesDim(int index, int16 &y1, int16 &y2, int dim
 
 	const ScreenDim *cDim = screen()->getScreenDim(dim);
 
-	screen_rpg()->modifyScreenDim(dim, cDim->sx, y1, cDim->w, y2 - y1);
+	screen()->modifyScreenDim(dim, cDim->sx, y1, cDim->w, y2 - y1);
 }
 
 void KyraRpgEngine::drawLevelModifyScreenDim(int dim, int16 x1, int16 y1, int16 x2, int16 y2) {
-	screen_rpg()->modifyScreenDim(dim, x1, y1 << 3, x2 - x1, (y2 - y1) << 3);
+	screen()->modifyScreenDim(dim, x1, y1 << 3, x2 - x1, (y2 - y1) << 3);
 }
 
 void KyraRpgEngine::generateBlockDrawingBuffer() {
diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index 3d94189..fa1daa2 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -36,8 +36,8 @@
 
 namespace Kyra {
 
-Screen::Screen(KyraEngine_v1 *vm, OSystem *system)
-	: _system(system), _vm(vm), _sjisInvisibleColor(0),
+Screen::Screen(KyraEngine_v1 *vm, OSystem *system, const ScreenDim *dimTable, const int dimTableSize)
+	: _system(system), _vm(vm), _sjisInvisibleColor(0), _dimTable(dimTable), _dimTableCount(dimTableSize),
 	_cursorColorKey((vm->game() == GI_KYRA1) ? 0xFF : 0x00) {
 	_debugEnabled = false;
 	_maskMinY = _maskMaxY = -1;
@@ -70,6 +70,10 @@ Screen::~Screen() {
 
 	for (uint i = 0; i < _palettes.size(); ++i)
 		delete _palettes[i];
+
+	for (int i = 0; i < _dimTableCount; ++i)
+		delete _customDimTable[i];
+	delete[] _customDimTable;
 }
 
 bool Screen::init() {
@@ -146,6 +150,10 @@ bool Screen::init() {
 		_system->getPaletteManager()->setPalette(palette, 16, 8);
 	}
 
+	_customDimTable = new ScreenDim *[_dimTableCount];
+	memset(_customDimTable, 0, sizeof(ScreenDim *) * _dimTableCount);
+
+	_curDimIndex = -1;
 	_curDim = 0;
 	_charWidth = 0;
 	_charOffset = 0;
@@ -375,6 +383,29 @@ void Screen::mergeOverlay(int x, int y, int w, int h) {
 	}
 }
 
+const ScreenDim *Screen::getScreenDim(int dim) const {
+	assert(dim < _dimTableCount);
+	return _customDimTable[dim] ? _customDimTable[dim] : &_dimTable[dim];
+}
+
+void Screen::modifyScreenDim(int dim, int x, int y, int w, int h) {
+	if (!_customDimTable[dim])
+		_customDimTable[dim] = new ScreenDim;
+
+	memcpy(_customDimTable[dim], &_dimTable[dim], sizeof(ScreenDim));
+	_customDimTable[dim]->sx = x;
+	_customDimTable[dim]->sy = y;
+	_customDimTable[dim]->w = w;
+	_customDimTable[dim]->h = h;
+	if (dim == _curDimIndex || _vm->game() == GI_LOL)
+		setScreenDim(dim);
+}
+
+void Screen::setScreenDim(int dim) {
+	_curDim = getScreenDim(dim);
+	_curDimIndex = dim;
+}
+
 uint8 *Screen::getPagePtr(int pageNum) {
 	assert(pageNum < SCREEN_PAGE_NUM);
 	return _pagePtrs[pageNum];
@@ -3170,6 +3201,61 @@ void Screen::copyOverlayRegion(int x, int y, int x2, int y2, int w, int h, int s
 	}
 }
 
+void Screen::crossFadeRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPage, int dstPage) {
+	if (srcPage > 13 || dstPage > 13)
+		error("Screen::crossFadeRegion(): attempting to use temp page as source or dest page.");
+
+	hideMouse();
+
+	uint16 *wB = (uint16*)_pagePtrs[14];
+	uint8 *hB = _pagePtrs[14] + 640;
+
+	for (int i = 0; i < w; i++)
+		wB[i] = i;
+
+	for (int i = 0; i < h; i++)
+		hB[i] = i;
+
+	for (int i = 0; i < w; i++)
+		SWAP(wB[_vm->_rnd.getRandomNumberRng(0, w - 1)], wB[i]);
+
+	for (int i = 0; i < h; i++)
+		SWAP(hB[_vm->_rnd.getRandomNumberRng(0, h - 1)], hB[i]);
+
+	uint8 *s = _pagePtrs[srcPage];
+	uint8 *d = _pagePtrs[dstPage];
+
+	for (int i = 0; i < h; i++) {
+		int iH = i;
+		uint32 end = _system->getMillis() + 3;
+		for (int ii = 0; ii < w; ii++) {
+			int sX = x1 + wB[ii];
+			int sY = y1 + hB[iH];
+			int dX = x2 + wB[ii];
+			int dY = y2 + hB[iH];
+
+			if (++iH >= h)
+				iH = 0;
+
+			d[dY * 320 + dX] = s[sY * 320 + sX];
+			addDirtyRect(dX, dY, 1, 1);
+		}
+
+		// This tries to speed things up, to get similiar speeds as in DOSBox etc.
+		// We can't write single pixels directly into the video memory like the original did.
+		// We also (unlike the original) want to aim at similiar speeds for all platforms.
+		if (!(i % 10))
+			updateScreen();
+
+		uint32 cur = _system->getMillis();
+		if (end > cur)
+			_system->delayMillis(end - cur);
+	}
+
+	updateScreen();
+	showMouse();
+}
+
 #pragma mark -
 
 DOSFont::DOSFont() {
diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h
index 1118c97..dd74692 100644
--- a/engines/kyra/screen.h
+++ b/engines/kyra/screen.h
@@ -366,7 +366,7 @@ public:
 		FID_NUM
 	};
 
-	Screen(KyraEngine_v1 *vm, OSystem *system);
+	Screen(KyraEngine_v1 *vm, OSystem *system, const ScreenDim *dimTable, const int dimTableSize);
 	virtual ~Screen();
 
 	// init
@@ -449,9 +449,12 @@ public:
 	virtual void setTextColorMap(const uint8 *cmap) = 0;
 	void setTextColor(const uint8 *cmap, int a, int b);
 
-	virtual void setScreenDim(int dim) = 0;
-	virtual const ScreenDim *getScreenDim(int dim) = 0;
-	virtual int screenDimTableCount() const = 0;
+	const ScreenDim *getScreenDim(int dim) const;
+	void modifyScreenDim(int dim, int x, int y, int w, int h);
+	int screenDimTableCount() const { return _dimTableCount; }
+
+	void setScreenDim(int dim);
+	int curDimIndex() const { return _curDimIndex; }
 
 	const ScreenDim *_curDim;
 
@@ -513,6 +516,9 @@ public:
 	static void convertAmigaGfx(uint8 *data, int w, int h, int depth = 5, bool wsa = false, int bytesPerPlane = -1);
 	static void convertAmigaMsc(uint8 *data);
 
+	// RPG specific, this does not belong here
+	void crossFadeRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPage, int dstPage);
+
 protected:
 	uint8 *getPagePtr(int pageNum);
 	void updateDirtyRects();
@@ -560,6 +566,12 @@ protected:
 	uint8 *_animBlockPtr;
 	int _animBlockSize;
 
+	// dimension handling
+	const ScreenDim * const _dimTable;
+	ScreenDim **_customDimTable;
+	const int _dimTableCount;
+	int _curDimIndex;
+
 	// mouse handling
 	int _mouseLockCount;
 	const uint8 _cursorColorKey;
diff --git a/engines/kyra/screen_eob.cpp b/engines/kyra/screen_eob.cpp
index 62d8bca..7061ada 100644
--- a/engines/kyra/screen_eob.cpp
+++ b/engines/kyra/screen_eob.cpp
@@ -36,7 +36,7 @@
 
 namespace Kyra {
 
-Screen_EoB::Screen_EoB(EoBCoreEngine *vm, OSystem *system) : Screen(vm, system), Screen_Rpg(vm, system, _screenDimTable, _screenDimTableCount) {
+Screen_EoB::Screen_EoB(EoBCoreEngine *vm, OSystem *system) : Screen(vm, system, _screenDimTable, _screenDimTableCount) {
 	_shapeFadeMode[0] = _shapeFadeMode[1] = 0;
 	_shapeFadeInternal = 0;
 	_fadeData = 0;
diff --git a/engines/kyra/screen_eob.h b/engines/kyra/screen_eob.h
index 2efed83..7040177 100644
--- a/engines/kyra/screen_eob.h
+++ b/engines/kyra/screen_eob.h
@@ -25,20 +25,18 @@
 
 #ifdef ENABLE_EOB
 
-#include "kyra/screen_rpg.h"
+#include "kyra/screen.h"
 
 namespace Kyra {
 
 class EoBCoreEngine;
-class Screen_EoB : public Screen_Rpg{
+class Screen_EoB : public Screen {
 public:
 	Screen_EoB(EoBCoreEngine *vm, OSystem *system);
 	virtual ~Screen_EoB();
 
 	bool init();
 
-	int screenDimTableCount() const { return _screenDimTableCount; }
-
 	void setClearScreenDim(int dim);
 	void clearCurDim();
 
diff --git a/engines/kyra/screen_hof.cpp b/engines/kyra/screen_hof.cpp
index 7d4d074..ac6ee5e 100644
--- a/engines/kyra/screen_hof.cpp
+++ b/engines/kyra/screen_hof.cpp
@@ -26,17 +26,7 @@
 namespace Kyra {
 
 Screen_HoF::Screen_HoF(KyraEngine_HoF *vm, OSystem *system)
-	: Screen(vm, system), Screen_v2(vm, system), _vm(vm) {
-}
-
-void Screen_HoF::setScreenDim(int dim) {
-	assert(dim < _screenDimTableCount);
-	_curDim = &_screenDimTable[dim];
-}
-
-const ScreenDim *Screen_HoF::getScreenDim(int dim) {
-	assert(dim < _screenDimTableCount);
-	return &_screenDimTable[dim];
+	: Screen_v2(vm, system, _screenDimTable, _screenDimTableCount), _vm(vm) {
 }
 
 void Screen_HoF::generateGrayOverlay(const Palette &srcPal, uint8 *grayOverlay, int factor, int addR, int addG, int addB, int lastColor, bool flag) {
diff --git a/engines/kyra/screen_hof.h b/engines/kyra/screen_hof.h
index edcb339..51c6a00 100644
--- a/engines/kyra/screen_hof.h
+++ b/engines/kyra/screen_hof.h
@@ -34,10 +34,6 @@ friend class Debugger_v2;
 public:
 	Screen_HoF(KyraEngine_HoF *vm, OSystem *system);
 
-	void setScreenDim(int dim);
-	const ScreenDim *getScreenDim(int dim);
-	int screenDimTableCount() const { return _screenDimTableCount; }
-
 	// sequence player
 	void generateGrayOverlay(const Palette &pal, uint8 *grayOverlay, int factor, int addR, int addG, int addB, int lastColor, bool flag);
 	void cmpFadeFrameStep(int srcPage, int srcW, int srcH, int srcX, int srcY, int dstPage,	int dstW, int dstH, int dstX, int dstY, int cmpW, int cmpH, int cmpPage);
diff --git a/engines/kyra/screen_lok.cpp b/engines/kyra/screen_lok.cpp
index 106ef5d..447e142 100644
--- a/engines/kyra/screen_lok.cpp
+++ b/engines/kyra/screen_lok.cpp
@@ -30,7 +30,7 @@
 namespace Kyra {
 
 Screen_LoK::Screen_LoK(KyraEngine_LoK *vm, OSystem *system)
-	: Screen(vm, system) {
+	: Screen(vm, system, _screenDimTable, _screenDimTableCount) {
 	_vm = vm;
 	_unkPtr1 = _unkPtr2 = 0;
 	_bitBlitNum = 0;
@@ -70,16 +70,6 @@ bool Screen_LoK::init() {
 	return true;
 }
 
-void Screen_LoK::setScreenDim(int dim) {
-	assert(dim < _screenDimTableCount);
-	_curDim = &_screenDimTable[dim];
-}
-
-const ScreenDim *Screen_LoK::getScreenDim(int dim) {
-	assert(dim < _screenDimTableCount);
-	return &_screenDimTable[dim];
-}
-
 void Screen_LoK::fadeSpecialPalette(int palIndex, int startIndex, int size, int fadeTime) {
 	if (_vm->gameFlags().platform == Common::kPlatformAmiga)
 		return;
diff --git a/engines/kyra/screen_lok.h b/engines/kyra/screen_lok.h
index 3b74912..3cb9254 100644
--- a/engines/kyra/screen_lok.h
+++ b/engines/kyra/screen_lok.h
@@ -38,10 +38,6 @@ public:
 
 	int getRectSize(int w, int h);
 
-	void setScreenDim(int dim);
-	const ScreenDim *getScreenDim(int dim);
-	int screenDimTableCount() const { return _screenDimTableCount; }
-
 	void setTextColorMap(const uint8 *cmap);
 
 	void fadeSpecialPalette(int palIndex, int startIndex, int size, int fadeTime);
diff --git a/engines/kyra/screen_lol.cpp b/engines/kyra/screen_lol.cpp
index bef83f4..4b8b443 100644
--- a/engines/kyra/screen_lol.cpp
+++ b/engines/kyra/screen_lol.cpp
@@ -31,7 +31,7 @@
 
 namespace Kyra {
 
-Screen_LoL::Screen_LoL(LoLEngine *vm, OSystem *system) : Screen(vm, system), Screen_v2(vm, system), Screen_Rpg(vm, system, _screenDimTable = vm->gameFlags().use16ColorMode ? _screenDimTable16C : _screenDimTable256C, _screenDimTableCount), _vm(vm) {
+Screen_LoL::Screen_LoL(LoLEngine *vm, OSystem *system) : Screen_v2(vm, system,  vm->gameFlags().use16ColorMode ? _screenDimTable16C : _screenDimTable256C, _screenDimTableCount), _vm(vm) {
 	_paletteOverlay1 = new uint8[0x100];
 	_paletteOverlay2 = new uint8[0x100];
 	_grayOverlay = new uint8[0x100];
@@ -42,7 +42,6 @@ Screen_LoL::Screen_LoL(LoLEngine *vm, OSystem *system) : Screen(vm, system), Scr
 	for (int i = 0; i < 8; i++)
 		_levelOverlays[i] = new uint8[256];
 
-	_screenDimTable = 0;
 	_fadeFlag = 2;
 }
 
diff --git a/engines/kyra/screen_lol.h b/engines/kyra/screen_lol.h
index eb025fb..3bba9f8 100644
--- a/engines/kyra/screen_lol.h
+++ b/engines/kyra/screen_lol.h
@@ -26,19 +26,16 @@
 #define KYRA_SCREEN_LOL_H
 
 #include "kyra/screen_v2.h"
-#include "kyra/screen_rpg.h"
 
 namespace Kyra {
 
 class LoLEngine;
 
-class Screen_LoL : public Screen_v2, public Screen_Rpg {
+class Screen_LoL : public Screen_v2 {
 public:
 	Screen_LoL(LoLEngine *vm, OSystem *system);
 	~Screen_LoL();
 
-	int screenDimTableCount() const { return _screenDimTableCount; }
-
 	void fprintString(const char *format, int x, int y, uint8 col1, uint8 col2, uint16 flags, ...) GCC_PRINTF(2, 8);
 	void fprintStringIntro(const char *format, int x, int y, uint8 c1, uint8 c2, uint8 c3, uint16 flags, ...) GCC_PRINTF(2, 9);
 
@@ -94,11 +91,9 @@ public:
 private:
 	LoLEngine *_vm;
 
-	const ScreenDim *_screenDimTable;
-	static const int _screenDimTableCount;
-
 	static const ScreenDim _screenDimTable256C[];
 	static const ScreenDim _screenDimTable16C[];
+	static const int _screenDimTableCount;
 
 	uint8 *_levelOverlays[8];
 
diff --git a/engines/kyra/screen_mr.cpp b/engines/kyra/screen_mr.cpp
index d4446c6..337860d 100644
--- a/engines/kyra/screen_mr.cpp
+++ b/engines/kyra/screen_mr.cpp
@@ -25,22 +25,13 @@
 
 namespace Kyra {
 
-Screen_MR::Screen_MR(KyraEngine_MR *vm, OSystem *system) : Screen(vm, system), Screen_v2(vm, system) {
+Screen_MR::Screen_MR(KyraEngine_MR *vm, OSystem *system)
+    : Screen_v2(vm, system, _screenDimTable, _screenDimTableCount) {
 }
 
 Screen_MR::~Screen_MR() {
 }
 
-void Screen_MR::setScreenDim(int dim) {
-	assert(dim < _screenDimTableCount);
-	_curDim = &_screenDimTable[dim];
-}
-
-const ScreenDim *Screen_MR::getScreenDim(int dim) {
-	assert(dim < _screenDimTableCount);
-	return &_screenDimTable[dim];
-}
-
 int Screen_MR::getLayer(int x, int y) {
 	if (x < 0)
 		x = 0;
diff --git a/engines/kyra/screen_mr.h b/engines/kyra/screen_mr.h
index 0cb3240..e10afcc 100644
--- a/engines/kyra/screen_mr.h
+++ b/engines/kyra/screen_mr.h
@@ -34,10 +34,6 @@ public:
 	Screen_MR(KyraEngine_MR *vm, OSystem *system);
 	~Screen_MR();
 
-	void setScreenDim(int dim);
-	const ScreenDim *getScreenDim(int dim);
-	int screenDimTableCount() const { return _screenDimTableCount; }
-
 	int getLayer(int x, int y);
 
 	byte getShapeFlag1(int x, int y);
diff --git a/engines/kyra/screen_rpg.cpp b/engines/kyra/screen_rpg.cpp
deleted file mode 100644
index 3b29f0a..0000000
--- a/engines/kyra/screen_rpg.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/* ScummVM - Graphic Adventure Engine

- *

- * ScummVM is the legal property of its developers, whose names

- * are too numerous to list here. Please refer to the COPYRIGHT

- * file distributed with this source distribution.

- *

- * This program is free software; you can redistribute it and/or

- * modify it under the terms of the GNU General Public License

- * as published by the Free Software Foundation; either version 2

- * of the License, or (at your option) any later version.

-

- * This program is distributed in the hope that it will be useful,

- * but WITHOUT ANY WARRANTY; without even the implied warranty of

- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

- * GNU General Public License for more details.

-

- * You should have received a copy of the GNU General Public License

- * along with this program; if not, write to the Free Software

- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

- *

- */

-

-

-#if defined(ENABLE_EOB) || defined(ENABLE_LOL)

-

-#include "kyra/screen_rpg.h"

-#include "kyra/kyra_v1.h"

-

-#include "common/endian.h"

-

-namespace Kyra {

-

-Screen_Rpg::Screen_Rpg(KyraEngine_v1 *vm, OSystem *system, const ScreenDim *dimTable, int dimTableSize) : Screen(vm, system), _screenDimTable(dimTable), _screenDimTableCount(dimTableSize) {

-	_customDimTable = new ScreenDim*[_screenDimTableCount];

-	memset(_customDimTable, 0, sizeof(ScreenDim *)* _screenDimTableCount);

-	_curDimIndex = 0;

-}

-

-Screen_Rpg::~Screen_Rpg() {

-	for (int i = 0; i < _screenDimTableCount; i++)

-		delete _customDimTable[i];

-	delete[] _customDimTable;

-}

-

-void Screen_Rpg::setScreenDim(int dim) {

-	assert(dim < _screenDimTableCount);

-	_curDim = _customDimTable[dim] ? (const ScreenDim *)_customDimTable[dim] : &_screenDimTable[dim];

-	_curDimIndex = dim;

-}

-

-const ScreenDim *Screen_Rpg::getScreenDim(int dim) {

-	assert(dim < _screenDimTableCount);

-	return _customDimTable[dim] ? (const ScreenDim *)_customDimTable[dim] : &_screenDimTable[dim];

-}

-

-void Screen_Rpg::modifyScreenDim(int dim, int x, int y, int w, int h) {

-	if (!_customDimTable[dim])

-		_customDimTable[dim] = new ScreenDim;

-

-	memcpy(_customDimTable[dim], &_screenDimTable[dim], sizeof(ScreenDim));

-	_customDimTable[dim]->sx = x;

-	_customDimTable[dim]->sy = y;

-	_customDimTable[dim]->w = w;

-	_customDimTable[dim]->h = h;

-	if (dim == _curDimIndex || _vm->game() == GI_LOL)

-		setScreenDim(dim);

-}

-

-void Screen_Rpg::crossFadeRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPage, int dstPage) {

-	if (srcPage > 13 || dstPage > 13)

-		error("Screen_Rpg::crossFadeRegion(): attempting to use temp page as source or dest page.");

-

-	hideMouse();

-

-	uint16 *wB = (uint16*)_pagePtrs[14];

-	uint8 *hB = _pagePtrs[14] + 640;

-

-	for (int i = 0; i < w; i++)

-		wB[i] = i;

-

-	for (int i = 0; i < h; i++)

-		hB[i] = i;

-

-	for (int i = 0; i < w; i++)

-		SWAP(wB[_vm->_rnd.getRandomNumberRng(0, w - 1)], wB[i]);

-

-	for (int i = 0; i < h; i++)

-		SWAP(hB[_vm->_rnd.getRandomNumberRng(0, h - 1)], hB[i]);

-

-	uint8 *s = _pagePtrs[srcPage];

-	uint8 *d = _pagePtrs[dstPage];

-

-	for (int i = 0; i < h; i++) {

-		int iH = i;

-		uint32 end = _system->getMillis() + 3;

-		for (int ii = 0; ii < w; ii++) {

-			int sX = x1 + wB[ii];

-			int sY = y1 + hB[iH];

-			int dX = x2 + wB[ii];

-			int dY = y2 + hB[iH];

-

-			if (++iH >= h)

-				iH = 0;

-

-			d[dY * 320 + dX] = s[sY * 320 + sX];

-			addDirtyRect(dX, dY, 1, 1);

-		}

-

-		// This tries to speed things up, to get similiar speeds as in DOSBox etc.

-		// We can't write single pixels directly into the video memory like the original did.

-		// We also (unlike the original) want to aim at similiar speeds for all platforms.

-		if (!(i % 10))

-			updateScreen();

-

-		uint32 cur = _system->getMillis();

-		if (end > cur)

-			_system->delayMillis(end - cur);

-	}

-

-	updateScreen();

-	showMouse();

-}

-

-}	// End of namespace Kyra

-

-#endif // ENABLE_EOB || ENABLE_LOL

diff --git a/engines/kyra/screen_rpg.h b/engines/kyra/screen_rpg.h
deleted file mode 100644
index e9b15c2..0000000
--- a/engines/kyra/screen_rpg.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ScummVM - Graphic Adventure Engine

- *

- * ScummVM is the legal property of its developers, whose names

- * are too numerous to list here. Please refer to the COPYRIGHT

- * file distributed with this source distribution.

- *

- * This program is free software; you can redistribute it and/or

- * modify it under the terms of the GNU General Public License

- * as published by the Free Software Foundation; either version 2

- * of the License, or (at your option) any later version.

-

- * This program is distributed in the hope that it will be useful,

- * but WITHOUT ANY WARRANTY; without even the implied warranty of

- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

- * GNU General Public License for more details.

-

- * You should have received a copy of the GNU General Public License

- * along with this program; if not, write to the Free Software

- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

- *

- */

-

-#ifndef KYRA_SCREEN_RPG_H

-#define KYRA_SCREEN_RPG_H

-

-#if defined(ENABLE_EOB) || defined(ENABLE_LOL)

-

-#include "kyra/screen.h"

-#include "common/system.h"

-

-namespace Kyra {

-

-class Screen;

-class KyraEngine_v1;

-

-class Screen_Rpg : virtual public Screen {

-public:

-	Screen_Rpg(KyraEngine_v1 *vm, OSystem *system, const ScreenDim *dimTable, int dimTableSize);

-	virtual ~Screen_Rpg();

-

-	virtual void setScreenDim(int dim);

-	virtual const ScreenDim *getScreenDim(int dim);

-	virtual int screenDimTableCount() const = 0;

-

-	void modifyScreenDim(int dim, int x, int y, int w, int h);

-	int curDimIndex() const { return _curDimIndex; }

-

-	void crossFadeRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPage, int dstPage);

-

-private:

-	int _curDimIndex;

-	int _screenDimTableCount;

-	ScreenDim **_customDimTable;

-	const ScreenDim *_screenDimTable;

-};

-

-}	// End of namespace Kyra

-

-#endif // ENABLE_EOB || ENABLE_LOL

-

-#endif

diff --git a/engines/kyra/screen_v2.cpp b/engines/kyra/screen_v2.cpp
index 57581fa..c608c6e 100644
--- a/engines/kyra/screen_v2.cpp
+++ b/engines/kyra/screen_v2.cpp
@@ -26,7 +26,8 @@
 
 namespace Kyra {
 
-Screen_v2::Screen_v2(KyraEngine_v1 *vm, OSystem *system) : Screen(vm, system), _wsaFrameAnimBuffer(0) {
+Screen_v2::Screen_v2(KyraEngine_v1 *vm, OSystem *system, const ScreenDim *dimTable, const int dimTableSize)
+    : Screen(vm, system, dimTable, dimTableSize), _wsaFrameAnimBuffer(0) {
 	_wsaFrameAnimBuffer = new uint8[1024];
 	assert(_wsaFrameAnimBuffer);
 }
diff --git a/engines/kyra/screen_v2.h b/engines/kyra/screen_v2.h
index f50c81e..f84c923 100644
--- a/engines/kyra/screen_v2.h
+++ b/engines/kyra/screen_v2.h
@@ -28,9 +28,9 @@
 
 namespace Kyra {
 
-class Screen_v2 : virtual public Screen {
+class Screen_v2 : public Screen {
 public:
-	Screen_v2(KyraEngine_v1 *vm, OSystem *system);
+	Screen_v2(KyraEngine_v1 *vm, OSystem *system, const ScreenDim *dimTable, const int dimTableSize);
 	~Screen_v2();
 
 	// screen page handling
diff --git a/engines/kyra/text_lol.cpp b/engines/kyra/text_lol.cpp
index 8535516..ee42d6d 100644
--- a/engines/kyra/text_lol.cpp
+++ b/engines/kyra/text_lol.cpp
@@ -32,7 +32,7 @@
 
 namespace Kyra {
 
-TextDisplayer_LoL::TextDisplayer_LoL(LoLEngine *engine, Screen_LoL *screenLoL) : TextDisplayer_rpg(engine, engine->screen_rpg()),
+TextDisplayer_LoL::TextDisplayer_LoL(LoLEngine *engine, Screen_LoL *screenLoL) : TextDisplayer_rpg(engine, screenLoL),
 	_vm(engine), _screen(screenLoL), _scriptTextParameter(0) {
 
 	memset(_stringParameters, 0, 15 * sizeof(char *));
@@ -337,7 +337,7 @@ KyraRpgEngine *TextDisplayer_LoL::vm() {
 	return _vm;
 }
 
-Screen_Rpg *TextDisplayer_LoL::screen() {
+Screen *TextDisplayer_LoL::screen() {
 	return _screen;
 }
 
diff --git a/engines/kyra/text_lol.h b/engines/kyra/text_lol.h
index a5eebd6..e2b10e8 100644
--- a/engines/kyra/text_lol.h
+++ b/engines/kyra/text_lol.h
@@ -50,8 +50,8 @@ public:
 	int16 _scriptTextParameter;
 
 private:
-	KyraRpgEngine *vm();
-	Screen_Rpg *screen();
+	virtual KyraRpgEngine *vm();
+	virtual Screen *screen();
 
 	void preprocessString(char *str, EMCState *script, const uint16 *paramList, int16 paramIndex);
 	void textPageBreak();
diff --git a/engines/kyra/text_rpg.cpp b/engines/kyra/text_rpg.cpp
index ca1fd04..78206d3 100644
--- a/engines/kyra/text_rpg.cpp
+++ b/engines/kyra/text_rpg.cpp
@@ -24,7 +24,6 @@
 #if defined(ENABLE_EOB) || defined(ENABLE_LOL)
 
 #include "kyra/kyra_rpg.h"
-#include "kyra/screen_rpg.h"
 #include "kyra/timer.h"
 
 #include "common/system.h"
@@ -35,7 +34,7 @@ enum {
 	kEoBTextBufferSize = 2048
 };
 
-TextDisplayer_rpg::TextDisplayer_rpg(KyraRpgEngine *engine, Screen_Rpg *scr) : _vm(engine), _screen(scr),
+TextDisplayer_rpg::TextDisplayer_rpg(KyraRpgEngine *engine, Screen *scr) : _vm(engine), _screen(scr),
 	_lineCount(0), _printFlag(false), _lineWidth(0), _numCharsTotal(0), _allowPageBreak(true),
 	_numCharsLeft(0), _numCharsPrinted(0), _sjisLineBreakFlag(false), _waitButtonMode(1) {
 
diff --git a/engines/kyra/text_rpg.h b/engines/kyra/text_rpg.h
index ff3473d..8ef8fdd 100644
--- a/engines/kyra/text_rpg.h
+++ b/engines/kyra/text_rpg.h
@@ -29,12 +29,12 @@
 
 namespace Kyra {
 
-class Screen_Rpg;
+class Screen;
 class KyraRpgEngine;
 
 class TextDisplayer_rpg {
 public:
-	TextDisplayer_rpg(KyraRpgEngine *engine, Screen_Rpg *scr);
+	TextDisplayer_rpg(KyraRpgEngine *engine, Screen *scr);
 	virtual ~TextDisplayer_rpg();
 
 	virtual void setupField(int dim, bool mode);
@@ -57,7 +57,7 @@ public:
 
 protected:
 	virtual KyraRpgEngine *vm() { return _vm; }
-	virtual Screen_Rpg *screen() { return _screen; }
+	virtual Screen *screen() { return _screen; }
 
 	void displayText(char *str, ...);
 	char parseCommand();
@@ -102,7 +102,7 @@ protected:
 
 private:
 	KyraRpgEngine *_vm;
-	Screen_Rpg *_screen;
+	Screen *_screen;
 
 	char *_table1;
 	char *_table2;


Commit: 463aa52ac6bad2f5d15c1daed613396e5c0e149b
    https://github.com/scummvm/scummvm/commit/463aa52ac6bad2f5d15c1daed613396e5c0e149b
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-12-26T10:32:05-08:00

Commit Message:
KYRA: Cleanup va_arg use in drawShape.

Thanks to wjp for noticing this.

Changed paths:
    engines/kyra/screen.cpp



diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index fa1daa2..b6383c8 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -1335,6 +1335,8 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int
 	if ((flags & 0x2000) && _vm->game() != GI_KYRA1)
 		_dsTable5 = va_arg(args, uint8 *);
 
+	va_end(args);
+
 	static const DsMarginSkipFunc dsMarginFunc[] = {
 		&Screen::drawShapeMarginNoScaleUpwind,
 		&Screen::drawShapeMarginNoScaleDownwind,
@@ -1420,7 +1422,6 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int
 			warning("Missing drawShape plotting method type %d", ppc);
 		if (dsPlot3 != dsPlot2 && !dsPlot3)
 			warning("Missing drawShape plotting method type %d", (((flags >> 8) & 0xF7) & 0x3F));
-		va_end(args);
 		return;
 	}
 
@@ -1453,10 +1454,8 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int
 		shapeHeight = (shapeHeight * _dsScaleH) >> 8;
 		shpWidthScaled1 = shpWidthScaled2 = (shapeWidth * _dsScaleW) >> 8;
 
-		if (!shapeHeight || !shpWidthScaled1) {
-			va_end(args);
+		if (!shapeHeight || !shpWidthScaled1)
 			return;
-		}
 	}
 
 	if (flags & DSF_CENTER) {
@@ -1486,7 +1485,6 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int
 	if (t < 0) {
 		shapeHeight += t;
 		if (shapeHeight <= 0) {
-			va_end(args);
 			return;
 		}
 
@@ -1520,10 +1518,8 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int
 	}
 
 	t = (flags & 2) ? y + shapeHeight - y1 : y2 - y;
-	if (t <= 0) {
-		va_end(args);
+	if (t <= 0)
 		return;
-	}
 
 	if (t < shapeHeight) {
 		shapeHeight = t;
@@ -1535,20 +1531,16 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int
 	if (x < 0) {
 		shpWidthScaled1 += x;
 		_dsOffscreenLeft = -x;
-		if (_dsOffscreenLeft >= shpWidthScaled2) {
-			va_end(args);
+		if (_dsOffscreenLeft >= shpWidthScaled2)
 			return;
-		}
 		x = 0;
 	}
 
 	_dsOffscreenRight = 0;
 	t = x2 - x;
 
-	if (t <= 0) {
-		va_end(args);
+	if (t <= 0)
 		return;
-	}
 
 	if (t < shpWidthScaled1) {
 		shpWidthScaled1 = t;
@@ -1628,8 +1620,6 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int
 			scaleCounterV -= 0x100;
 		} while (scaleCounterV & 0xFF00);
 	}
-
-	va_end(args);
 }
 
 int Screen::drawShapeMarginNoScaleUpwind(uint8 *&dst, const uint8 *&src, int &cnt) {






More information about the Scummvm-git-logs mailing list