[Scummvm-git-logs] scummvm master -> dffa2633cb9366a5a44122ce890c045d1e72d61b

dreammaster dreammaster at scummvm.org
Sun Jul 11 21:09:24 UTC 2021


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

Summary:
ee75794504 AGS: Cleanup of usage of ScummVM Graphics::Screen
b4056b39b0 AGS: Skeleton AGSWave plugin
dffa2633cb AGS: Workaround for missing frames in the speech view loops


Commit: ee7579450467c2534760646d2db2ecba001600e6
    https://github.com/scummvm/scummvm/commit/ee7579450467c2534760646d2db2ecba001600e6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-07-11T14:06:26-07:00

Commit Message:
AGS: Cleanup of usage of ScummVM Graphics::Screen

Changed paths:
    engines/ags/ags.cpp
    engines/ags/ags.h
    engines/ags/engine/gfx/ali_3d_scummvm.cpp
    engines/ags/engine/gfx/ali_3d_scummvm.h
    engines/ags/engine/media/video/video.cpp


diff --git a/engines/ags/ags.cpp b/engines/ags/ags.cpp
index 90c81fa95f..396a850afa 100644
--- a/engines/ags/ags.cpp
+++ b/engines/ags/ags.cpp
@@ -71,8 +71,7 @@ AGSEngine *g_vm;
 
 AGSEngine::AGSEngine(OSystem *syst, const AGSGameDescription *gameDesc) : Engine(syst),
 	_gameDescription(gameDesc), _randomSource("AGS"), _events(nullptr), _music(nullptr),
-	_rawScreen(nullptr), _screen(nullptr), _gfxDriver(nullptr),
-	_globals(nullptr), _forceTextAA(false) {
+	_gfxDriver(nullptr), _globals(nullptr), _forceTextAA(false) {
 	g_vm = this;
 
 	_events = new EventsManager();
@@ -93,8 +92,6 @@ AGSEngine::~AGSEngine() {
 		                           _G(our_eip), _G(EngineVersion).LongString.GetCStr());
 	}
 
-	delete _screen;
-	delete _rawScreen;
 	delete _events;
 	delete _music;
 	delete _globals;
@@ -223,9 +220,6 @@ void AGSEngine::setGraphicsMode(size_t w, size_t h, int colorDepth) {
 	//Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
 
 	initGraphics(w, h, &format);
-
-	_rawScreen = new Graphics::Screen();
-	_screen = new ::AGS3::BITMAP(_rawScreen);
 }
 
 bool AGSEngine::isUnsupportedPre25() const {
diff --git a/engines/ags/ags.h b/engines/ags/ags.h
index 7cfd80ecf5..0b03279613 100644
--- a/engines/ags/ags.h
+++ b/engines/ags/ags.h
@@ -67,8 +67,6 @@ private:
 public:
 	EventsManager *_events;
 	Music *_music;
-	Graphics::Screen *_rawScreen;
-	::AGS3::BITMAP *_screen;
 	::AGS3::GFX_DRIVER *_gfxDriver;
 	::AGS3::AGS::Engine::Mutex _sMutex;
 	::AGS3::AGS::Engine::Mutex _soundCacheMutex;
@@ -165,7 +163,6 @@ public:
 };
 
 extern AGSEngine *g_vm;
-#define screen ::AGS::g_vm->_screen
 #define gfx_driver ::AGS::g_vm->_gfxDriver
 #define SHOULD_QUIT ::AGS::g_vm->shouldQuit()
 
diff --git a/engines/ags/engine/gfx/ali_3d_scummvm.cpp b/engines/ags/engine/gfx/ali_3d_scummvm.cpp
index b7dc3ee8ce..951347aae4 100644
--- a/engines/ags/engine/gfx/ali_3d_scummvm.cpp
+++ b/engines/ags/engine/gfx/ali_3d_scummvm.cpp
@@ -57,6 +57,11 @@ ScummVMRendererGraphicsDriver::ScummVMRendererGraphicsDriver() {
 	ScummVMRendererGraphicsDriver::InitSpriteBatch(0, _spriteBatchDesc[0]);
 }
 
+ScummVMRendererGraphicsDriver::~ScummVMRendererGraphicsDriver() {
+	delete _screen;
+	ScummVMRendererGraphicsDriver::UnInit();
+}
+
 bool ScummVMRendererGraphicsDriver::IsModeSupported(const DisplayMode &mode) {
 	if (mode.Width <= 0 || mode.Height <= 0 || mode.ColorDepth <= 0) {
 		warning("Invalid resolution parameters: %d x %d x %d",
@@ -135,30 +140,7 @@ void ScummVMRendererGraphicsDriver::CreateVirtualScreen() {
 	virtualScreen = _origVirtualScreen.get();
 	_stageVirtualScreen = virtualScreen;
 
-#ifdef TODO
-	_screenTex = SDL_CreateTexture(_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, vscreen_w, vscreen_h);
-
-	// Fake bitmap that will wrap over texture pixels for simplier conversion
-	_fakeTexBitmap = reinterpret_cast<BITMAP *>(new char[sizeof(BITMAP) + (sizeof(char *) * vscreen_h)]);
-	_fakeTexBitmap->w = vscreen_w;
-	_fakeTexBitmap->cr = vscreen_w;
-	_fakeTexBitmap->h = vscreen_h;
-	_fakeTexBitmap->cb = vscreen_h;
-	_fakeTexBitmap->clip = true;
-	_fakeTexBitmap->cl = 0;
-	_fakeTexBitmap->ct = 0;
-	_fakeTexBitmap->id = 0;
-	_fakeTexBitmap->extra = nullptr;
-	_fakeTexBitmap->x_ofs = 0;
-	_fakeTexBitmap->y_ofs = 0;
-	_fakeTexBitmap->dat = nullptr;
-
-	auto tmpbitmap = create_bitmap_ex(32, 1, 1);
-	_fakeTexBitmap->vtable = tmpbitmap->vtable;
-	_fakeTexBitmap->write_bank = tmpbitmap->write_bank;
-	_fakeTexBitmap->read_bank = tmpbitmap->read_bank;
-	destroy_bitmap(tmpbitmap);
-#endif
+
 	_lastTexPixels = nullptr;
 	_lastTexPitch = -1;
 }
@@ -166,13 +148,7 @@ void ScummVMRendererGraphicsDriver::CreateVirtualScreen() {
 void ScummVMRendererGraphicsDriver::DestroyVirtualScreen() {
 	delete[] _fakeTexBitmap; // don't use destroy_bitmap(), because it's a fake structure
 	_fakeTexBitmap = nullptr;
-#ifdef TODO
-	if (_screenTex != nullptr) {
-		SDL_DestroyTexture(_screenTex);
-	}
 
-	_screenTex = nullptr;
-#endif
 	_origVirtualScreen.reset();
 	virtualScreen = nullptr;
 	_stageVirtualScreen = nullptr;
@@ -199,20 +175,10 @@ void ScummVMRendererGraphicsDriver::ClearRectangle(int x1, int y1, int x2, int y
 	// See SDL_RenderDrawRect
 }
 
-ScummVMRendererGraphicsDriver::~ScummVMRendererGraphicsDriver() {
-	ScummVMRendererGraphicsDriver::UnInit();
-}
-
 void ScummVMRendererGraphicsDriver::UnInit() {
 	OnUnInit();
 	ReleaseDisplayMode();
 	DestroyVirtualScreen();
-#ifdef TODO
-	if (_renderer) {
-		SDL_DestroyRenderer(_renderer);
-		_renderer = nullptr;
-	}
-#endif
 
 	sys_window_destroy();
 }
@@ -405,36 +371,33 @@ void ScummVMRendererGraphicsDriver::RenderSpriteBatch(const ALSpriteBatch &batch
 	}
 }
 
-void ScummVMRendererGraphicsDriver::BlitToTexture() {
+void ScummVMRendererGraphicsDriver::BlitToScreen() {
 	const Graphics::Surface &src =
 		virtualScreen->GetAllegroBitmap()->getSurface();
 
-	// Blit the entire surface to the screen, ignoring the alphas
-	Graphics::Surface srcCopy = src;
-	srcCopy.format.aLoss = 8;
-
-	::AGS::g_vm->_screen->getSurface().blitFrom(srcCopy);
-}
-
-void ScummVMRendererGraphicsDriver::Present() {
-	BlitToTexture();
+	if (!_screen && !_useVirtScreenDirectly) {
+		// Check whether whether the AGS surface format matches the screen
+		_useVirtScreenDirectly = src.format == g_system->getScreenFormat();
 
-	::AGS::g_vm->_rawScreen->update();
+		if (!_useVirtScreenDirectly)
+			_screen = new Graphics::Screen();
+	}
 
-#if DEPRECATED
-	SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_NONE);
-	SDL_SetRenderDrawColor(_renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
-	SDL_RenderFillRect(_renderer, nullptr);
+	if (_screen) {
+		// Blit the surface to the temporary screen, ignoring the alphas.
+		// This takes care of converting to the screen format
+		Graphics::Surface srcCopy = src;
+		srcCopy.format.aLoss = 8;
 
-	SDL_Rect dst;
-	dst.x = _dstRect.Left;
-	dst.y = _dstRect.Top;
-	dst.w = _dstRect.GetWidth();
-	dst.h = _dstRect.GetHeight();
-	SDL_RenderCopyEx(_renderer, _screenTex, nullptr, &dst, 0.0, nullptr, _renderFlip);
+		_screen->blitFrom(srcCopy);
+		_screen->update();
 
-	SDL_RenderPresent(_renderer);
-#endif
+	} else {
+		// Blit the virtual surface directly to the screen
+		g_system->copyRectToScreen(src.getPixels(), src.pitch,
+			0, 0, src.w, src.h);
+		g_system->updateScreen();
+	}
 }
 
 void ScummVMRendererGraphicsDriver::Render(int /*xoff*/, int /*yoff*/, GlobalFlipType flip) {
diff --git a/engines/ags/engine/gfx/ali_3d_scummvm.h b/engines/ags/engine/gfx/ali_3d_scummvm.h
index 5ee3a2ea3d..fb215522da 100644
--- a/engines/ags/engine/gfx/ali_3d_scummvm.h
+++ b/engines/ags/engine/gfx/ali_3d_scummvm.h
@@ -167,6 +167,7 @@ typedef std::vector<ALSpriteBatch> ALSpriteBatches;
 class ScummVMRendererGraphicsDriver : public GraphicsDriverBase {
 public:
 	ScummVMRendererGraphicsDriver();
+	~ScummVMRendererGraphicsDriver() override;
 
 	const char *GetDriverName() override {
 		return "SDL 2D Software renderer";
@@ -226,13 +227,14 @@ public:
 	bool GetStageMatrixes(RenderMatrixes &rm) override {
 		return false; /* not supported */
 	}
-	~ScummVMRendererGraphicsDriver() override;
 
 	typedef std::shared_ptr<ScummVMRendererGfxFilter> PSDLRenderFilter;
 
 	void SetGraphicsFilter(PSDLRenderFilter filter);
 
 private:
+	Graphics::Screen *_screen = nullptr;
+	bool _useVirtScreenDirectly = false;
 	PSDLRenderFilter _filter;
 
 	bool _hasGamma = false;
@@ -277,10 +279,10 @@ private:
 	void highcolor_fade_out(Bitmap *vs, void(*draw_callback)(), int offx, int offy, int speed, int targetColourRed, int targetColourGreen, int targetColourBlue);
 	void __fade_from_range(PALETTE source, PALETTE dest, int speed, int from, int to);
 	void __fade_out_range(int speed, int from, int to, int targetColourRed, int targetColourGreen, int targetColourBlue);
-	// Copy raw screen bitmap pixels to the SDL texture
-	void BlitToTexture();
-	// Render SDL texture on screen
-	void Present();
+	// Copy raw screen bitmap pixels to the screen
+	void BlitToScreen();
+	// Render bitmap on screen
+	void Present() { BlitToScreen(); }
 };
 
 
diff --git a/engines/ags/engine/media/video/video.cpp b/engines/ags/engine/media/video/video.cpp
index bdf4096d9b..bef24afb84 100644
--- a/engines/ags/engine/media/video/video.cpp
+++ b/engines/ags/engine/media/video/video.cpp
@@ -72,7 +72,7 @@ static bool play_video(Video::VideoDecoder *decoder, const char *name, int skip,
 
 	update_polled_stuff_if_runtime();
 
-	Graphics::Screen &scr = *::AGS::g_vm->_rawScreen;
+	Graphics::Screen scr;
 	bool stretchVideo = (flags % 10) != 0;
 	int canAbort = skip;
 	bool ignoreAudio = (flags >= 10);


Commit: b4056b39b02838fad1bacf04e0ec0683f8e8989b
    https://github.com/scummvm/scummvm/commit/b4056b39b02838fad1bacf04e0ec0683f8e8989b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-07-11T14:06:26-07:00

Commit Message:
AGS: Skeleton AGSWave plugin

Changed paths:
  A engines/ags/plugins/ags_waves/ags_waves.cpp
  A engines/ags/plugins/ags_waves/ags_waves.h
    engines/ags/module.mk
    engines/ags/plugins/plugin_base.cpp


diff --git a/engines/ags/module.mk b/engines/ags/module.mk
index 190cc3afec..3fd90119bc 100644
--- a/engines/ags/module.mk
+++ b/engines/ags/module.mk
@@ -318,7 +318,8 @@ MODULE_OBJS = \
 	plugins/ags_sprite_font/variable_width_sprite_font_clifftop.o \
 	plugins/ags_shell/ags_shell.o \
 	plugins/ags_tcp_ip/ags_tcp_ip.o \
-	plugins/ags_wadjet_util/ags_wadjet_util.o
+	plugins/ags_wadjet_util/ags_wadjet_util.o \
+	plugins/ags_waves/ags_waves.o
 
 ifdef ENABLE_AGS_TESTS
 MODULE_OBJS += \
diff --git a/engines/ags/plugins/ags_waves/ags_waves.cpp b/engines/ags/plugins/ags_waves/ags_waves.cpp
new file mode 100644
index 0000000000..84837d36ac
--- /dev/null
+++ b/engines/ags/plugins/ags_waves/ags_waves.cpp
@@ -0,0 +1,301 @@
+/* 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.
+ *
+ */
+
+#include "ags/plugins/ags_waves/ags_waves.h"
+
+namespace AGS3 {
+namespace Plugins {
+namespace AGSWaves {
+
+IAGSEngine *AGSWaves::_engine;
+
+AGSWaves::AGSWaves() : PluginBase() {
+	_engine = nullptr;
+
+	DLL_METHOD(AGS_GetPluginName);
+	DLL_METHOD(AGS_EngineStartup);
+}
+
+const char *AGSWaves::AGS_GetPluginName() {
+	return "AGS Waves";
+}
+
+void AGSWaves::AGS_EngineStartup(IAGSEngine *engine) {
+	_engine = engine;
+
+	SCRIPT_METHOD(DrawScreenEffect);
+	SCRIPT_METHOD(SFX_Play);
+	SCRIPT_METHOD(SFX_SetVolume); 
+	SCRIPT_METHOD(SFX_GetVolume);
+	SCRIPT_METHOD(Music_Play);
+	SCRIPT_METHOD(Music_GetVolume);
+	SCRIPT_METHOD(Music_SetVolume);
+	SCRIPT_METHOD(SFX_Stop);
+	SCRIPT_METHOD(SFX_SetPosition);
+	SCRIPT_METHOD(SFX_SetGlobalVolume);
+	SCRIPT_METHOD(Load_SFX);
+	SCRIPT_METHOD(Audio_Apply_Filter);
+	SCRIPT_METHOD(Audio_Remove_Filter);
+	SCRIPT_METHOD(SFX_AllowOverlap);
+	SCRIPT_METHOD(SFX_Filter);
+	SCRIPT_METHOD(DrawBlur); 
+	SCRIPT_METHOD(DrawTunnel);
+	SCRIPT_METHOD(DrawCylinder);
+	SCRIPT_METHOD(DrawForceField);
+	SCRIPT_METHOD(Grayscale);
+	SCRIPT_METHOD(ReadWalkBehindIntoSprite);
+	SCRIPT_METHOD(AdjustSpriteFont);
+	SCRIPT_METHOD(SpriteGradient);
+	SCRIPT_METHOD(Outline);
+	SCRIPT_METHOD(OutlineOnly);
+	SCRIPT_METHOD(SaveVariable);
+	SCRIPT_METHOD(ReadVariable);
+	SCRIPT_METHOD(GameDoOnceOnly);
+	SCRIPT_METHOD(SetGDState);
+	SCRIPT_METHOD(GetGDState);
+	SCRIPT_METHOD(ResetAllGD);
+	SCRIPT_METHOD(SpriteSkew);
+	SCRIPT_METHOD(FireUpdate);
+	SCRIPT_METHOD(WindUpdate);
+	SCRIPT_METHOD(SetWindValues);
+	SCRIPT_METHOD(ReturnWidth);
+	SCRIPT_METHOD(ReturnHeight);
+	SCRIPT_METHOD(ReturnNewHeight);
+	SCRIPT_METHOD(ReturnNewWidth);
+	SCRIPT_METHOD(Warper);
+	SCRIPT_METHOD(SetWarper);
+	SCRIPT_METHOD(RainUpdate);
+	SCRIPT_METHOD(BlendTwoSprites);
+	SCRIPT_METHOD(Blend);
+	SCRIPT_METHOD(Dissolve);
+	SCRIPT_METHOD(ReverseTransparency);
+	SCRIPT_METHOD(NoiseCreator);
+	SCRIPT_METHOD(TintProper);
+	SCRIPT_METHOD(GetWalkbehindBaserine);
+	SCRIPT_METHOD(SetWalkbehindBaserine);
+}
+
+void AGSWaves::DrawScreenEffect(ScriptMethodParams &params) {
+	//PARAMS4(int, sprite, int, sprite_prev, int, ide, int, n);
+}
+
+void AGSWaves::SFX_Play(ScriptMethodParams &params) {
+	//PARAMS2(int, SFX, int, repeat);
+}
+
+void AGSWaves::SFX_SetVolume(ScriptMethodParams &params) {
+	//PARAMS2(int, SFX, int, volume);
+}
+
+void AGSWaves::SFX_GetVolume(ScriptMethodParams &params) {
+	//PARAMS1(int, SFX);
+	params._result = 0;
+}
+
+void AGSWaves::Music_Play(ScriptMethodParams &params) {
+	//PARAMS6(int, MFX, int, repeat, int, fadeinMS, int, fadeoutMS, int, Position, bool, fixclick);
+}
+
+void AGSWaves::Music_SetVolume(ScriptMethodParams &params) {
+	//PARAMS1(int, volume);
+}
+
+void AGSWaves::Music_GetVolume(ScriptMethodParams &params) {
+	params._result = 0;
+}
+
+void AGSWaves::SFX_Stop(ScriptMethodParams &params) {
+	//PARAMS2(int, SFX, int, fademsOUT);
+}
+
+void AGSWaves::SFX_SetPosition(ScriptMethodParams &params) {
+	//PARAMS4(int, SFX, int, x, int, y, int, intensity);
+}
+
+void AGSWaves::SFX_SetGlobalVolume(ScriptMethodParams &params) {
+	//PARAMS1(int, volume);
+}
+
+void AGSWaves::Load_SFX(ScriptMethodParams &params) {
+	//PARAMS1(int, SFX);
+}
+
+void AGSWaves::Audio_Apply_Filter(ScriptMethodParams &params) {
+	//PARAMS1(int, Frequency);
+}
+
+void AGSWaves::Audio_Remove_Filter(ScriptMethodParams &params) {
+}
+
+void AGSWaves::SFX_AllowOverlap(ScriptMethodParams &params) {
+	//PARAMS2(int, SFX, int, allow);
+}
+
+void AGSWaves::SFX_Filter(ScriptMethodParams &params) {
+	//PARAMS2(int, SFX, int, enable);
+}
+
+void AGSWaves::DrawBlur(ScriptMethodParams &params) {
+	//PARAMS2(int, spriteD, int, radius);
+}
+
+void AGSWaves::DrawTunnel(ScriptMethodParams &params) {
+	//PARAMS3(int, spriteD, float, scale, float, speed);
+}
+
+void AGSWaves::DrawCylinder(ScriptMethodParams &params) {
+	//PARAMS2(int, spriteD, int, ogsprite);
+}
+
+void AGSWaves::DrawForceField(ScriptMethodParams &params) {
+	//PARAMS4(int, spriteD, int, scale, float, speed, int, id);
+}
+
+void AGSWaves::Grayscale(ScriptMethodParams &params) {
+	//PARAMS1(int, sprite);
+}
+
+void AGSWaves::ReadWalkBehindIntoSprite(ScriptMethodParams &params) {
+	//PARAMS3(int, sprite, int, bgsprite, int, walkbehindBaseline);
+}
+
+void AGSWaves::AdjustSpriteFont(ScriptMethodParams &params) {
+	//PARAMS5(int, sprite, int, rate, int, outlineRed, int, outlineGreen, int, outlineBlue);
+}
+
+void AGSWaves::SpriteGradient(ScriptMethodParams &params) {
+	//PARAMS3(int, sprite, int, rate, int, toy);
+}
+
+void AGSWaves::Outline(ScriptMethodParams &params) {
+	//PARAMS5(int, sprite, int, red, int, ged, int, bed, int, aed);
+}
+
+void AGSWaves::OutlineOnly(ScriptMethodParams &params) {
+	//PARAMS7(int, sprite, int, refsprite, int, red, int, ged, int, bed, int, aed, int, trans);
+}
+
+void AGSWaves::SaveVariable(ScriptMethodParams &params) {
+	//PARAMS2(const char *, value, int, id);
+}
+
+void AGSWaves::ReadVariable(ScriptMethodParams &params) {
+	//PARAMS1(int, id);
+	params._result = (const char *)nullptr;
+}
+
+void AGSWaves::GameDoOnceOnly(ScriptMethodParams &params) {
+	//PARAMS1(const char *, value);
+}
+
+void AGSWaves::SetGDState(ScriptMethodParams &params) {
+	//PARAMS2(const char *, value, bool, setvalue);
+}
+
+void AGSWaves::GetGDState(ScriptMethodParams &params) {
+	//PARAMS1(const char *, value);
+	params._result = false;
+}
+
+void AGSWaves::ResetAllGD(ScriptMethodParams &params) {
+}
+
+void AGSWaves::SpriteSkew(ScriptMethodParams &params) {
+	//PARAMS5(int, sprite, float, xskewmin, float, yskewmin, float, xskewmax, float, yskewmax);
+}
+
+void AGSWaves::FireUpdate(ScriptMethodParams &params) {
+	//PARAMS2(int, getDynamicSprite, bool, Fire2Visible));
+}
+
+void AGSWaves::WindUpdate(ScriptMethodParams &params) {
+	//PARAMS4(int, ForceX, int, ForceY, int, Transparency, int, sprite);
+}
+
+void AGSWaves::SetWindValues(ScriptMethodParams &params) {
+	//PARAMS4(int, w, int, h, int, pr, int, prev);
+}
+
+void AGSWaves::ReturnWidth(ScriptMethodParams &params) {
+	//PARAMS8(int, x1, int, y1, int, x2, int, y2, int, x3, int, y3, int, x4, int, y4);
+	params._result = 0;
+}
+
+void AGSWaves::ReturnHeight(ScriptMethodParams &params) {
+	//PARAMS8(int, x1, int, y1, int, x2, int, y2, int, x3, int, y3, int, x4, int, y4);
+	params._result = 0;
+}
+
+void AGSWaves::ReturnNewHeight(ScriptMethodParams &params) {
+}
+
+void AGSWaves::ReturnNewWidth(ScriptMethodParams &params) {
+}
+
+void AGSWaves::Warper(ScriptMethodParams &params) {
+	//PARAMS5(int, swarp, int, sadjust, int, x1, int, y1, int, x2);
+}
+
+void AGSWaves::SetWarper(ScriptMethodParams &params) {
+	//PARAMS5(int, y2x, int, x3x, int, y3x, int, x4x, int, y4x);
+}
+
+void AGSWaves::RainUpdate(ScriptMethodParams &params) {
+	//PARAMS7(int, rdensity, int, FX, int, FY, int, RW, int, RH, int, graphic, float, perc);
+}
+
+void AGSWaves::BlendTwoSprites(ScriptMethodParams &params) {
+	//PARAMS2(int, graphic, int, refgraphic);
+}
+
+void AGSWaves::Blend(ScriptMethodParams &params) {
+	//PARAMS4(int, graphic, int, refgraphic, bool, screen, int, perc);
+}
+
+void AGSWaves::Dissolve(ScriptMethodParams &params) {
+	//PARAMS3(int, graphic, int, noisegraphic, int, disvalue);
+}
+
+void AGSWaves::ReverseTransparency(ScriptMethodParams &params) {
+	//PARAMS1(int, graphic);
+}
+
+void AGSWaves::NoiseCreator(ScriptMethodParams &params) {
+	//PARAMS2(int, graphic, int, setA);
+}
+
+void AGSWaves::TintProper(ScriptMethodParams &params) {
+	//PARAMS7(int, sprite, int, lightx, int, lighty, int, radi, int, rex, int, grx, int, blx);
+}
+
+void AGSWaves::GetWalkbehindBaserine(ScriptMethodParams &params) {
+	//PARAMS1(int, id);
+	params._result = 0;
+}
+
+void AGSWaves::SetWalkbehindBaserine(ScriptMethodParams &params) {
+	//PARAMS2(int, id, int, base);
+}
+
+} // namespace AGSWaves
+} // namespace Plugins
+} // namespace AGS3
diff --git a/engines/ags/plugins/ags_waves/ags_waves.h b/engines/ags/plugins/ags_waves/ags_waves.h
new file mode 100644
index 0000000000..934e81e951
--- /dev/null
+++ b/engines/ags/plugins/ags_waves/ags_waves.h
@@ -0,0 +1,97 @@
+/* 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 AGS_PLUGINS_AGS_WAVES_AGS_WAVES_H
+#define AGS_PLUGINS_AGS_WAVES_AGS_WAVES_H
+
+#include "ags/plugins/plugin_base.h"
+
+namespace AGS3 {
+namespace Plugins {
+namespace AGSWaves {
+
+class AGSWaves : public PluginBase {
+private:
+	static IAGSEngine *_engine;
+	static const char *AGS_GetPluginName();
+	static void AGS_EngineStartup(IAGSEngine *engine);
+
+private:
+	static void DrawScreenEffect(ScriptMethodParams &params);
+	static void SFX_Play(ScriptMethodParams &params);
+	static void SFX_SetVolume(ScriptMethodParams &params);
+	static void SFX_GetVolume(ScriptMethodParams &params);
+	static void Music_Play(ScriptMethodParams &params);
+	static void Music_GetVolume(ScriptMethodParams &params);
+	static void Music_SetVolume(ScriptMethodParams &params);
+	static void SFX_Stop(ScriptMethodParams &params);
+	static void SFX_SetPosition(ScriptMethodParams &params);
+	static void SFX_SetGlobalVolume(ScriptMethodParams &params);
+	static void Load_SFX(ScriptMethodParams &params);
+	static void Audio_Apply_Filter(ScriptMethodParams &params);
+	static void Audio_Remove_Filter(ScriptMethodParams &params);
+	static void SFX_AllowOverlap(ScriptMethodParams &params);
+	static void SFX_Filter(ScriptMethodParams &params);
+	static void DrawBlur(ScriptMethodParams &params);
+	static void DrawTunnel(ScriptMethodParams &params);
+	static void DrawCylinder(ScriptMethodParams &params);
+	static void DrawForceField(ScriptMethodParams &params);
+	static void Grayscale(ScriptMethodParams &params);
+	static void ReadWalkBehindIntoSprite(ScriptMethodParams &params);
+	static void AdjustSpriteFont(ScriptMethodParams &params);
+	static void SpriteGradient(ScriptMethodParams &params);
+	static void Outline(ScriptMethodParams &params);
+	static void OutlineOnly(ScriptMethodParams &params);
+	static void SaveVariable(ScriptMethodParams &params);
+	static void ReadVariable(ScriptMethodParams &params);
+	static void GameDoOnceOnly(ScriptMethodParams &params);
+	static void SetGDState(ScriptMethodParams &params);
+	static void GetGDState(ScriptMethodParams &params);
+	static void ResetAllGD(ScriptMethodParams &params);
+	static void SpriteSkew(ScriptMethodParams &params);
+	static void FireUpdate(ScriptMethodParams &params);
+	static void WindUpdate(ScriptMethodParams &params);
+	static void SetWindValues(ScriptMethodParams &params);
+	static void ReturnWidth(ScriptMethodParams &params);
+	static void ReturnHeight(ScriptMethodParams &params);
+	static void ReturnNewHeight(ScriptMethodParams &params);
+	static void ReturnNewWidth(ScriptMethodParams &params);
+	static void Warper(ScriptMethodParams &params);
+	static void SetWarper(ScriptMethodParams &params);
+	static void RainUpdate(ScriptMethodParams &params);
+	static void BlendTwoSprites(ScriptMethodParams &params);
+	static void Blend(ScriptMethodParams &params);
+	static void Dissolve(ScriptMethodParams &params);
+	static void ReverseTransparency(ScriptMethodParams &params);
+	static void NoiseCreator(ScriptMethodParams &params);
+	static void TintProper(ScriptMethodParams &params);
+	static void GetWalkbehindBaserine(ScriptMethodParams &params);
+	static void SetWalkbehindBaserine(ScriptMethodParams &params);
+public:
+	AGSWaves();
+};
+
+} // namespace AGSWaves
+} // namespace Plugins
+} // namespace AGS3
+
+#endif
diff --git a/engines/ags/plugins/plugin_base.cpp b/engines/ags/plugins/plugin_base.cpp
index 868a61d79f..febf293a97 100644
--- a/engines/ags/plugins/plugin_base.cpp
+++ b/engines/ags/plugins/plugin_base.cpp
@@ -42,6 +42,7 @@
 #include "ags/plugins/ags_sprite_font/ags_sprite_font_clifftop.h"
 #include "ags/plugins/ags_tcp_ip/ags_tcp_ip.h"
 #include "ags/plugins/ags_wadjet_util/ags_wadjet_util.h"
+#include "ags/plugins/ags_waves/ags_waves.h"
 #include "ags/ags.h"
 #include "ags/detection.h"
 #include "common/str.h"
@@ -127,6 +128,9 @@ void *pluginOpen(const char *filename) {
 	if (fname.equalsIgnoreCase("AGSWadjetUtil"))
 		return new AGSWadjetUtil::AGSWadjetUtil();
 
+	if (fname.equalsIgnoreCase("agswaves"))
+		return new AGSWaves::AGSWaves();
+
 	debug("Plugin '%s' is not yet supported", fname.c_str());
 	return nullptr;
 }


Commit: dffa2633cb9366a5a44122ce890c045d1e72d61b
    https://github.com/scummvm/scummvm/commit/dffa2633cb9366a5a44122ce890c045d1e72d61b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-07-11T14:06:26-07:00

Commit Message:
AGS: Workaround for missing frames in the speech view loops

>From upstream 08aef03ac693c28cc632f566d0a3a17dba48e157

This is a better fix for the crash in the Fatman intro, so
my original workaround has been removed

Changed paths:
    engines/ags/engine/ac/character.cpp


diff --git a/engines/ags/engine/ac/character.cpp b/engines/ags/engine/ac/character.cpp
index d8b48dbf85..a0df9a72dd 100644
--- a/engines/ags/engine/ac/character.cpp
+++ b/engines/ags/engine/ac/character.cpp
@@ -2378,19 +2378,16 @@ void _displayspeech(const char *texx, int aschar, int xx, int yy, int widd, int
 		if (viewWasLocked)
 			charFrameWas = speakingChar->frame;
 
-		// if the current loop doesn't exist in talking view, use loop 0
-		if (speakingChar->loop >= _G(views)[speakingChar->view].numLoops)
+		// If speech view is missing a loop or the loop does not have frames - use loop 0
+		if (speakingChar->loop >= _G(views)[speakingChar->view].numLoops ||
+				_G(views)[speakingChar->view].loops[speakingChar->loop].numFrames < 1) {
+			String err = String::FromFormat("Character %s speech view %d does not have necessary loop %d or it has no frames",
+				speakingChar->scrname, speakingChar->view + 1, speakingChar->loop);
+			// is there even a fallback loop?
+			if (_G(views)[speakingChar->view].numLoops == 0 || _G(views)[speakingChar->view].loops[0].numFrames == 0)
+				quitprintf("!%s; and there's no valid loop to fall back.", err.GetCStr());
+			debug_script_warn("WARNING: %s; switching to loop 0.", err.GetCStr());
 			speakingChar->loop = 0;
-
-		if ((speakingChar->view < 0) ||
-		        (speakingChar->loop >= _G(views)[speakingChar->view].numLoops) ||
-		        (_G(views)[speakingChar->view].loops[speakingChar->loop].numFrames < 1)) {
-#if AGS_PLATFORM_SCUMMVM
-			// WORKAROUND: Fix crash in Fatman intro by ignoring invalid speeches
-			return;
-#else
-			quitprintf("Unable to display speech because the character %s has an invalid view frame (View %d, loop %d, frame %d)", speakingChar->scrname, speakingChar->view + 1, speakingChar->loop, speakingChar->frame);
-#endif
 		}
 
 		_G(our_eip) = 1504;
@@ -2621,24 +2618,20 @@ void _displayspeech(const char *texx, int aschar, int xx, int yy, int widd, int
 			speakingChar->frame = 0;
 			speakingChar->flags |= CHF_FIXVIEW;
 
-			if (speakingChar->loop >= _G(views)[speakingChar->view].numLoops) {
-				// current character loop is outside the normal talking directions
+			// If speech view is missing a loop or the loop does not have frames - use loop 0
+			if (speakingChar->loop >= _G(views)[speakingChar->view].numLoops ||
+				_G(views)[speakingChar->view].loops[speakingChar->loop].numFrames < 1) {
+				String err = String::FromFormat("Character %s speech view %d does not have necessary loop %d or it has no frames",
+					speakingChar->scrname, speakingChar->view + 1, speakingChar->loop);
+				// is there even a fallback loop?
+				if (_G(views)[speakingChar->view].numLoops == 0 || _G(views)[speakingChar->view].loops[0].numFrames == 0)
+					quitprintf("!%s; and there's no valid loop to fall back.", err.GetCStr());
+				debug_script_warn("WARNING: %s; switching to loop 0.", err.GetCStr());
 				speakingChar->loop = 0;
 			}
 
 			_G(facetalkBlinkLoop) = speakingChar->loop;
 
-			if (speakingChar->on && // don't bother checking if character is not visible (also fixes 'Trilby's Notes' legacy game)
-			        ((speakingChar->loop >= _G(views)[speakingChar->view].numLoops) ||
-			         (_G(views)[speakingChar->view].loops[speakingChar->loop].numFrames < 1))) {
-#if AGS_PLATFORM_SCUMMVM
-				// WORKAROUND: Fix crash in Fatman intro by ignoring invalid speeches
-				return;
-#else
-				quitprintf("!Unable to display speech because the character %s has an invalid speech view (View %d, loop %d, frame %d)", speakingChar->scrname, speakingChar->view + 1, speakingChar->loop, speakingChar->frame);
-#endif
-			}
-
 			// set up the speed of the first frame
 			speakingChar->wait = GetCharacterSpeechAnimationDelay(speakingChar) +
 			                     _G(views)[speakingChar->view].loops[speakingChar->loop].frames[0].speed;




More information about the Scummvm-git-logs mailing list