ScummVM API documentation
ags_waves.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * of the License, or(at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef AGS_PLUGINS_AGS_WAVES_AGS_WAVES_H
23#define AGS_PLUGINS_AGS_WAVES_AGS_WAVES_H
24
25#include "audio/mixer.h"
26#include "common/fs.h"
27#include "ags/plugins/ags_plugin.h"
28#include "ags/plugins/ags_waves/vars.h"
29
30namespace AGS3 {
31namespace Plugins {
32namespace AGSWaves {
33
34class AGSWaves : public PluginBase, public Vars {
35 SCRIPT_HASH(AGSWaves)
36private:
37 Audio::Mixer *_mixer;
38private:
39 void DrawScreenEffect(ScriptMethodParams &params);
40 void SFX_Play(ScriptMethodParams &params);
41 void SFX_SetVolume(ScriptMethodParams &params);
42 void SFX_GetVolume(ScriptMethodParams &params);
43 void Music_Play(ScriptMethodParams &params);
44 void Music_GetVolume(ScriptMethodParams &params);
45 void Music_SetVolume(ScriptMethodParams &params);
46 void SFX_Stop(ScriptMethodParams &params);
47 void SFX_SetPosition(ScriptMethodParams &params);
48 void SFX_SetGlobalVolume(ScriptMethodParams &params);
49 void Load_SFX(ScriptMethodParams &params);
50 void Audio_Apply_Filter(ScriptMethodParams &params);
51 void Audio_Remove_Filter(ScriptMethodParams &params);
52 void SFX_AllowOverlap(ScriptMethodParams &params);
53 void SFX_Filter(ScriptMethodParams &params);
54 void DrawBlur(ScriptMethodParams &params);
55 void DrawTunnel(ScriptMethodParams &params);
56 void DrawCylinder(ScriptMethodParams &params);
57 void DrawForceField(ScriptMethodParams &params);
58 void Grayscale(ScriptMethodParams &params);
59 void ReadWalkBehindIntoSprite(ScriptMethodParams &params);
60 void AdjustSpriteFont(ScriptMethodParams &params);
61 void SpriteGradient(ScriptMethodParams &params);
62 void Outline(ScriptMethodParams &params);
63 void OutlineOnly(ScriptMethodParams &params);
64 void SaveVariable(ScriptMethodParams &params);
65 void ReadVariable(ScriptMethodParams &params);
66 void GameDoOnceOnly(ScriptMethodParams &params);
67 void SetGDState(ScriptMethodParams &params);
68 void GetGDState(ScriptMethodParams &params);
69 void ResetAllGD(ScriptMethodParams &params);
70 void SpriteSkew(ScriptMethodParams &params);
71 void FireUpdate(ScriptMethodParams &params);
72 void WindUpdate(ScriptMethodParams &params);
73 void SetWindValues(ScriptMethodParams &params);
74 void ReturnWidth(ScriptMethodParams &params);
75 void ReturnHeight(ScriptMethodParams &params);
76 void ReturnNewHeight(ScriptMethodParams &params);
77 void ReturnNewWidth(ScriptMethodParams &params);
78 void Warper(ScriptMethodParams &params);
79 void SetWarper(ScriptMethodParams &params);
80 void RainUpdate(ScriptMethodParams &params);
81 void BlendTwoSprites(ScriptMethodParams &params);
82 void Blend(ScriptMethodParams &params);
83 void Dissolve(ScriptMethodParams &params);
84 void ReverseTransparency(ScriptMethodParams &params);
85 void NoiseCreator(ScriptMethodParams &params);
86 void TintProper(ScriptMethodParams &params);
87 void GetWalkbehindBaserine(ScriptMethodParams &params);
88 void SetWalkbehindBaserine(ScriptMethodParams &params);
89
90private:
91 void StartingValues();
92 void Update();
93
94 void CastWave(int delayMax, int PixelsWide, int n);
95 void DrawEffect(int sprite_a, int sprite_b, int id, int n);
96 int Random(int threshold);
97
98 inline static int getRcolor(int color) {
99 return ((color >> 16) & 0xFF);
100 }
101 inline static int getGcolor(int color) {
102 return ((color >> 8) & 0xFF);
103 }
104 inline static int getBcolor(int color) {
105 return ((color >> 0) & 0xFF);
106 }
107 inline static int getAcolor(int color) {
108 return ((color >> 24) & 0xFF);
109 }
110 static int BlendColor(int Ln, int Bn, int perc) {
111 return ((Ln < 128) ? (2 * Bn * Ln / perc) : (perc - 2 * (perc - Bn) * (perc - Ln) / perc));
112 }
113 static int BlendColorScreen(int Ln, int Bn, int perc) {
114 return (Bn == perc) ? Bn :
115 MIN(perc, (Ln * Ln / (perc - Bn)));
116 }
117 static int SetColorRGBA(int r, int g, int b, int a);
118 static int ConvertColorToGrayScale(int color);
119 static bool IsPixelTransparent(int color);
120 float noiseField(float tx, float ty, float tz);
121
122 int IntersectLines(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
123
124 static inline float fracts(float value) {
125 return value - floor(value);
126 }
127 static inline float lerp(float x, float y, float fn) {
128 return x * (1.0 - fn) + y * fn;
129 }
130 static inline float hasher(float n) {
131 return fracts(sin(n) * 153.5453123);
132 }
133 static float min4(float m1, float m2, float m3, float m4) {
134 return MIN(MIN(m1, m2), MIN(m3, m4));
135 }
136 static float max4(float m1, float m2, float m3, float m4) {
137 return MAX(MAX(m1, m2), MAX(m3, m4));
138 }
139
140 // Weather
141 void DrawLineCustom(int x1, int y1, int x2, int y2, int graphic, int setR, int setG, int setB, int setA, int TranDif);
142 void CreateParticle(int xx, int yy, int ForceX, int ForceY);
143 void CreateParticle2(int xx, int yy, int ForceX, int ForceY);
144 void CreateParticleF(int xx, int yy, int ForceX, int ForceY);
145 void CreateDustParticle(int xx, int yy);
146 void CreateRainParticleMid(int x, int y, int fx, int fy, int maxpart);
147 void CreateRainParticleFore(int x, int y, int fx, int fy, int maxpart);
148 void CreateRainParticleBack(int x, int y, int fx, int fy, int maxpart);
149
150 // Sound
156 void PlaySFX(int SoundToPlay, int repeat);
157
161 void StopSFX(int sfxNum);
162
166 Audio::AudioStream *loadOGG(const Common::ArchiveMemberPtr &member);
167
168 void playStream(Audio::Mixer::SoundType type, Audio::SoundHandle *handle, Audio::AudioStream *stream, int repeat);
169
170 void stopAllSounds();
171 void GlitchFix();
172 void ApplyFilter(int SetFrequency);
173 void SetFilterFrequency(int setFrequency);
174 void MusicPlay(int MusicToPlay, int repeat, int fadeinMS, int fadeoutMS, int pos, bool forceplay, bool fixclick);
175
176public:
177 AGSWaves();
178 virtual ~AGSWaves();
179
180 const char *AGS_GetPluginName() override;
181 void AGS_EngineStartup(IAGSEngine *engine) override;
182 int64 AGS_EngineOnEvent(int event, NumberPtr data) override;
183};
184
185} // namespace AGSWaves
186} // namespace Plugins
187} // namespace AGS3
188
189#endif
Definition: ags_plugin.h:296
Definition: types.h:112
Definition: ags_waves.h:34
Definition: plugin_base.h:171
Definition: plugin_base.h:131
Definition: audiostream.h:50
Definition: mixer.h:70
SoundType
Definition: mixer.h:73
Definition: mixer.h:49
T MIN(T a, T b)
Definition: util.h:63
T MAX(T a, T b)
Definition: util.h:66
Definition: vars.h:140
Definition: color.h:49