[Scummvm-cvs-logs] SF.net SVN: scummvm: [32066] scummvm/trunk/engines/made

john_doe at users.sourceforge.net john_doe at users.sourceforge.net
Mon May 12 19:43:33 CEST 2008


Revision: 32066
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32066&view=rev
Author:   john_doe
Date:     2008-05-12 10:43:33 -0700 (Mon, 12 May 2008)

Log Message:
-----------
Implemented o1_ADDMASK and o1_SETMASK for LGOP2

Modified Paths:
--------------
    scummvm/trunk/engines/made/screen.cpp
    scummvm/trunk/engines/made/screen.h
    scummvm/trunk/engines/made/scriptfuncs_lgop2.cpp

Modified: scummvm/trunk/engines/made/screen.cpp
===================================================================
--- scummvm/trunk/engines/made/screen.cpp	2008-05-12 17:23:28 UTC (rev 32065)
+++ scummvm/trunk/engines/made/screen.cpp	2008-05-12 17:43:33 UTC (rev 32066)
@@ -34,6 +34,7 @@
 
 	_screen1 = new Graphics::Surface();
 	_screen1->create(320, 200, 1);
+
 	_screen2 = new Graphics::Surface();
 	_screen2->create(320, 200, 1);
 
@@ -45,7 +46,16 @@
 	_clipInfo1.destSurface = _screen1;
 	_clipInfo2.destSurface = _screen2;
 	_clipArea.destSurface = _screen2;
-	
+
+	// FIXME: Screen mask is only needed in v2 games
+	_screenMask = new Graphics::Surface();
+	_screenMask->create(320, 200, 1);
+	_maskDrawCtx.x = 0;
+	_maskDrawCtx.y = 0;
+	_maskDrawCtx.w = 320;
+	_maskDrawCtx.h = 200;
+	_maskDrawCtx.destSurface = _screenMask;
+
 	for (int i = 0; i <= 3; i++)
 		_excludeClipAreaEnabled[i] = false;
 
@@ -62,6 +72,7 @@
 	_ground = 1;
 	_clip = 0;
 	_exclude = 0;
+	_mask = 0;
 	
 	_visualEffectNum = 0;
 	
@@ -86,17 +97,20 @@
 Screen::~Screen() {
 	delete _screen1;
 	delete _screen2;
+	delete _screenMask;
 }
 
 void Screen::clearScreen() {
 	_screen1->fillRect(Common::Rect(0, 0, 320, 200), 0);
 	_screen2->fillRect(Common::Rect(0, 0, 320, 200), 0);
+	_screenMask->fillRect(Common::Rect(0, 0, 320, 200), 0);
+	_mask = 0;
 	_needPalette = true;
 }
 
-void Screen::drawSurface(Graphics::Surface *sourceSurface, int x, int y, int16 flipX, int16 flipY, const ClipInfo &clipInfo) {
+void Screen::drawSurface(Graphics::Surface *sourceSurface, int x, int y, int16 flipX, int16 flipY, int16 mask, const ClipInfo &clipInfo) {
 
-	byte *source, *dest;
+	byte *source, *dest, *maskp;
 	int startX = 0;
 	int startY = 0;
 	int clipWidth = sourceSurface->w;
@@ -124,6 +138,7 @@
 
 	source = (byte*)sourceSurface->getBasePtr(startX, startY);
 	dest = (byte*)clipInfo.destSurface->getBasePtr(x, y);
+	maskp = (byte*)_maskDrawCtx.destSurface->getBasePtr(x, y);
 
 	int32 sourcePitch, linePtrAdd;
 	byte *linePtr;
@@ -148,12 +163,15 @@
 			linePtr = source;
 		}
 		for (int16 xc = 0; xc < clipWidth; xc++) {
-			if (*linePtr)
-				dest[xc] = *linePtr;
+			if (*linePtr && (mask == 0 || maskp[xc] == 0)) {
+				if (*linePtr)
+					dest[xc] = *linePtr;
+			}
 			linePtr += linePtrAdd;
 		}
 		source += sourcePitch;
 		dest += clipInfo.destSurface->pitch;
+		maskp += _maskDrawCtx.destSurface->pitch;
 	}
 
 }
@@ -218,6 +236,12 @@
 	return updateChannel(channelIndex - 1) + 1;
 }
 
+void Screen::setChannelUseMask(uint16 channelIndex) {
+	if (channelIndex < 1 || channelIndex >= 100)
+		return;
+	_channels[channelIndex - 1].mask = _mask;
+}
+
 void Screen::drawSpriteChannels(const ClipInfo &clipInfo, int16 includeStateMask, int16 excludeStateMask) {
 
 	for (int i = 0; i <= 3; i++)
@@ -239,15 +263,15 @@
 
 			case 1: // drawFlex
 				if (_channels[i].state & 4) {
-					drawFlex(_channels[i].index, _channels[i].x, _channels[i].y, flipX, flipY, _clipArea);
+					drawFlex(_channels[i].index, _channels[i].x, _channels[i].y, flipX, flipY, _channels[i].mask, _clipArea);
 				} else if (_channels[i].state & 8) {
 					for (int excludeIndex = 0; excludeIndex < 4; excludeIndex++) {
 						if (_excludeClipAreaEnabled[excludeIndex]) {
-							drawFlex(_channels[i].index, _channels[i].x, _channels[i].y, flipX, flipY, _excludeClipArea[excludeIndex]);
+							drawFlex(_channels[i].index, _channels[i].x, _channels[i].y, flipX, flipY, _channels[i].mask, _excludeClipArea[excludeIndex]);
 						}
 					}
 				} else {
-					drawFlex(_channels[i].index, _channels[i].x, _channels[i].y, flipX, flipY, clipInfo);
+					drawFlex(_channels[i].index, _channels[i].x, _channels[i].y, flipX, flipY, _channels[i].mask, clipInfo);
 				}
 				break;
 
@@ -300,11 +324,12 @@
 	for (uint16 i = 0; i < ARRAYSIZE(_channels); i++) {
 		_channels[i].type = 0;
 		_channels[i].index = 0;
+		_channels[i].mask = 0;
 	}
 	_channelsUsedCount = 0;
 }
 
-uint16 Screen::drawFlex(uint16 flexIndex, int16 x, int16 y, int16 flipX, int16 flipY, const ClipInfo &clipInfo) {
+uint16 Screen::drawFlex(uint16 flexIndex, int16 x, int16 y, int16 flipX, int16 flipY, int16 mask, const ClipInfo &clipInfo) {
 
 	if (flexIndex == 0)
 		return 0;
@@ -312,7 +337,7 @@
 	PictureResource *flex = _vm->_res->getPicture(flexIndex);
 	Graphics::Surface *sourceSurface = flex->getPicture();
 
-	drawSurface(sourceSurface, x, y, flipX, flipY, clipInfo);
+	drawSurface(sourceSurface, x, y, flipX, flipY, mask, clipInfo);
 
 	// Palette is set in showPage
 	if (flex->hasPalette() && !_paletteLock && _needPalette) {
@@ -337,16 +362,21 @@
 	AnimationResource *anim = _vm->_res->getAnimation(animIndex);
 	Graphics::Surface *sourceSurface = anim->getFrame(frameNum);
 
-	drawSurface(sourceSurface, x, y, flipX, flipY, clipInfo);
+	drawSurface(sourceSurface, x, y, flipX, flipY, 0, clipInfo);
 
 	_vm->_res->freeResource(anim);
 }
 
 uint16 Screen::drawPic(uint16 index, int16 x, int16 y, int16 flipX, int16 flipY) {
-	drawFlex(index, x, y, flipX, flipY, _clipInfo1);
+	drawFlex(index, x, y, flipX, flipY, 0, _clipInfo1);
 	return 0;
 }
 
+uint16 Screen::drawMask(uint16 index, int16 x, int16 y) {
+	drawFlex(index, x, y, 0, 0, 0, _maskDrawCtx);
+	return 0;
+}
+
 uint16 Screen::drawAnimPic(uint16 animIndex, int16 x, int16 y, int16 frameNum, int16 flipX, int16 flipY) {
 	drawAnimFrame(animIndex, x, y, frameNum, flipX, flipY, _clipInfo1);
 	return 0;
@@ -354,7 +384,7 @@
 
 void Screen::addSprite(uint16 spriteIndex) {
 	bool oldScreenLock = _screenLock;
-	drawFlex(spriteIndex, 0, 0, 0, 0, _clipInfo1);
+	drawFlex(spriteIndex, 0, 0, 0, 0, 0, _clipInfo1);
 	_screenLock = oldScreenLock;
 }
 
@@ -566,11 +596,20 @@
 	memcpy(_screen2->pixels, _screen1->pixels, 64000);
 	drawSpriteChannels(_clipInfo2, 1, 2);
 
+	if (_visualEffectNum != 0) {
+		warning("Unimplemented visual fx %d", _visualEffectNum);
+	}
+
 	// TODO: Implement visual effects (palette fading etc.)
+	
 	if (!_paletteLock)
 		setRGBPalette(_palette, 0, _paletteColorCount);
 	_vm->_system->copyRectToScreen((const byte*)_screen2->pixels, _screen2->pitch, 0, 0, _screen2->w, _screen2->h);
+	
+	
 	_vm->_system->updateScreen();
+	
+	_visualEffectNum = 0;
 
 	if (!_paletteInitialized) {
 		memcpy(_newPalette, _palette, _paletteColorCount * 3);
@@ -589,10 +628,10 @@
 	while (flashCount--) {
 		setRGBPalette(_fxPalette, 0, _paletteColorCount);
 		_vm->_system->updateScreen();
-		_vm->_system->delayMillis(30);
+		_vm->_system->delayMillis(20);
 		setRGBPalette(_palette, 0, _paletteColorCount);
 		_vm->_system->updateScreen();
-		_vm->_system->delayMillis(30);
+		_vm->_system->delayMillis(20);
 	}
 }
 

Modified: scummvm/trunk/engines/made/screen.h
===================================================================
--- scummvm/trunk/engines/made/screen.h	2008-05-12 17:23:28 UTC (rev 32065)
+++ scummvm/trunk/engines/made/screen.h	2008-05-12 17:43:33 UTC (rev 32066)
@@ -46,6 +46,7 @@
 	uint16 fontNum;
 	int16 textColor, outlineColor;
 	int16 frameNum;
+	int16 mask;
 };
 
 struct ClipInfo {
@@ -62,14 +63,14 @@
 
 	void clearScreen();
 	
-	void drawSurface(Graphics::Surface *sourceSurface, int x, int y, int16 flipX, int16 flipY, const ClipInfo &clipInfo);
+	void drawSurface(Graphics::Surface *sourceSurface, int x, int y, int16 flipX, int16 flipY, int16 mask, const ClipInfo &clipInfo);
+	
 	void loadRGBPalette(byte *palRGB, int count = 256);
 	void setRGBPalette(byte *palRGB, int start = 0, int count = 256);
 	bool isPaletteLocked() { return _paletteLock; }
 	void setScreenLock(bool lock) { _screenLock = lock; }
 	void setPaletteLock(bool lock) { _paletteLock = lock; }
 	void setVisualEffectNum(int visualEffectNum) { _visualEffectNum = visualEffectNum; }
-	void setClip(uint16 clip) { _clip = clip; }
 
 	void setClipArea(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { 
 		_clipArea.x = x1;
@@ -78,8 +79,11 @@
 		_clipArea.h = ABS(y2 - y1);
 	}
 
-	void setExclude(uint16 exclude) { _exclude = exclude; }
-	void setGround(uint16 ground) { _ground = ground; }
+	void setClip(int16 clip) { _clip = clip; }
+	void setExclude(int16 exclude) { _exclude = exclude; }
+	void setGround(int16 ground) { _ground = ground; }
+	void setMask(int16 mask) { _mask = mask; }
+
 	void setTextColor(int16 color) { _textColor = color; }
 
 	void setTextRect(const Common::Rect &textRect) {
@@ -114,14 +118,17 @@
 	void setChannelState(uint16 channelIndex, int16 state);
 	uint16 setChannelLocation(uint16 channelIndex, int16 x, int16 y);
 	uint16 setChannelContent(uint16 channelIndex, uint16 index);
+	void setChannelUseMask(uint16 channelIndex);
 	void drawSpriteChannels(const ClipInfo &clipInfo, int16 includeStateMask, int16 excludeStateMask);
 	void updateSprites();
 	void clearChannels();
 	
-	uint16 drawFlex(uint16 flexIndex, int16 x, int16 y, int16 flipX, int16 flipY, const ClipInfo &clipInfo);
+	uint16 drawFlex(uint16 flexIndex, int16 x, int16 y, int16 flipX, int16 flipY, int16 mask, const ClipInfo &clipInfo);
 	void drawAnimFrame(uint16 animIndex, int16 x, int16 y, int16 frameNum, int16 flipX, int16 flipY, const ClipInfo &clipInfo);
 
 	uint16 drawPic(uint16 index, int16 x, int16 y, int16 flipX, int16 flipY);
+	uint16 drawMask(uint16 index, int16 x, int16 y);
+	
 	uint16 drawAnimPic(uint16 animIndex, int16 x, int16 y, int16 frameNum, int16 flipX, int16 flipY);
 	
 	void addSprite(uint16 spriteIndex);
@@ -147,7 +154,6 @@
 	void printObjectText(int16 objectIndex, int16 x, int16 y, int16 fontNum, int16 textColor, int16 outlineColor, const ClipInfo &clipInfo);
 	int16 getTextWidth(int16 fontNum, const char *text);
 
-
 protected:
 	MadeEngine *_vm;
 	
@@ -168,11 +174,11 @@
 	FontResource *_font;
 	ClipInfo _fontDrawCtx;
 
-	uint16 _clip, _exclude, _ground;
+	int16 _clip, _exclude, _ground, _mask;
 	int _visualEffectNum;
 	
-	Graphics::Surface *_screen1, *_screen2;
-	ClipInfo _clipArea, _clipInfo1, _clipInfo2;
+	Graphics::Surface *_screen1, *_screen2, *_screenMask;
+	ClipInfo _clipArea, _clipInfo1, _clipInfo2, _maskDrawCtx;
 	
 	ClipInfo _excludeClipArea[4];
 	bool _excludeClipAreaEnabled[4];

Modified: scummvm/trunk/engines/made/scriptfuncs_lgop2.cpp
===================================================================
--- scummvm/trunk/engines/made/scriptfuncs_lgop2.cpp	2008-05-12 17:23:28 UTC (rev 32065)
+++ scummvm/trunk/engines/made/scriptfuncs_lgop2.cpp	2008-05-12 17:43:33 UTC (rev 32066)
@@ -312,8 +312,6 @@
 }
 
 int16 ScriptFunctionsLgop2::o1_ADDSPRITE(int16 argc, int16 *argv) {
-	warning("Unimplemented opcode: o1_ADDSPRITE");
-	//_vm->_screen->drawSprite(argv[2], argv[1], argv[0]);
 	return argv[2];
 }
 
@@ -323,7 +321,8 @@
 }
 
 int16 ScriptFunctionsLgop2::o1_DRAWSPRITE(int16 argc, int16 *argv) {
-	_vm->_screen->drawSprite(argv[2], argv[1], argv[0]);
+	int16 channel = _vm->_screen->drawSprite(argv[2], argv[1], argv[0]);
+	_vm->_screen->setChannelUseMask(channel);
 	return 0;
 }
 
@@ -439,14 +438,12 @@
 }
 
 int16 ScriptFunctionsLgop2::o1_ADDMASK(int16 argc, int16 *argv) {
-	warning("Unimplemented opcode: o1_ADDMASK");
-	//PictureResource *flex = _vm->_res->getPicture(flexIndex);
-	//Graphics::Surface *sourceSurface = flex->getPicture();
+	_vm->_screen->drawMask(argv[2], argv[1], argv[0]);
 	return 0;
 }
 
 int16 ScriptFunctionsLgop2::o1_SETMASK(int16 argc, int16 *argv) {
-	warning("Unimplemented opcode: o1_SETMASK");
+	_vm->_screen->setMask(argv[0]);
 	return 0;
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list