ScummVM API documentation
scriptfuncs.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  * (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 MADE_SCRIPTFUNCS_H
23 #define MADE_SCRIPTFUNCS_H
24 
25 #include "made/resource.h"
26 
27 #include "audio/mixer.h"
28 
29 #include "common/debug.h"
30 #include "common/system.h"
31 
32 namespace Audio {
33 class PCSpeaker;
34 }
35 
36 namespace Made {
37 
38 class MadeEngine;
39 
40 typedef Common::Functor2<int16, int16*, int16> ExternalFunc;
41 
43 public:
45  virtual ~ScriptFunctions();
46 
47  int16 callFunction(uint16 index, int16 argc, int16 *argv) {
48  if (index >= _externalFuncs.size())
49  error("ScriptFunctions::callFunction() Invalid function index %d", index);
50  debug(4, "%s", _externalFuncNames[index]);
51  return (*_externalFuncs[index])(argc, argv);
52  }
53 
54  void setupExternalsTable();
55  const char* getFuncName(int index) { return _externalFuncNames[index]; }
56  int getCount() const { return _externalFuncs.size(); }
57  void stopSound();
58 
59 protected:
60  MadeEngine *_vm;
61  Audio::SoundHandle _audioStreamHandle;
62  Audio::SoundHandle _voiceStreamHandle;
63  SoundResource* _soundResource;
64  bool _soundStarted;
65  // The sound length in milliseconds for purpose of checking if the sound is
66  // still playing.
67  int _soundCheckLength;
68  // The audio volume set by the game scripts.
69  uint8 _gameAudioVolume;
70 
71  // PlayNote/StopNote and PlayTele/StopTele wave generators
72  Audio::SoundHandle _pcSpeakerHandle1, _pcSpeakerHandle2;
73  Audio::PCSpeaker *_pcSpeaker1, *_pcSpeaker2;
74 
76  Common::Array<const char *> _externalFuncNames;
77  GenericResource *_musicRes;
78 
79  int16 sfSystemCall(int16 argc, int16 *argv);
80  int16 sfInitGraf(int16 argc, int16 *argv);
81  int16 sfRestoreGraf(int16 argc, int16 *argv);
82  int16 sfDrawPicture(int16 argc, int16 *argv);
83  int16 sfClearScreen(int16 argc, int16 *argv);
84  int16 sfShowPage(int16 argc, int16 *argv);
85  int16 sfPollEvent(int16 argc, int16 *argv);
86  int16 sfGetMouseX(int16 argc, int16 *argv);
87  int16 sfGetMouseY(int16 argc, int16 *argv);
88  int16 sfGetKey(int16 argc, int16 *argv);
89  int16 sfSetVisualEffect(int16 argc, int16 *argv);
90  int16 sfPlaySound(int16 argc, int16 *argv);
91  int16 sfPlayMusic(int16 argc, int16 *argv);
92  int16 sfStopMusic(int16 argc, int16 *argv);
93  int16 sfIsMusicPlaying(int16 argc, int16 *argv);
94  int16 sfSetTextPos(int16 argc, int16 *argv);
95  int16 sfFlashScreen(int16 argc, int16 *argv);
96  int16 sfPlayNote(int16 argc, int16 *argv);
97  int16 sfStopNote(int16 argc, int16 *argv);
98  int16 sfPlayTele(int16 argc, int16 *argv);
99  int16 sfStopTele(int16 argc, int16 *argv);
100  int16 sfHideMouseCursor(int16 argc, int16 *argv);
101  int16 sfShowMouseCursor(int16 argc, int16 *argv);
102  int16 sfGetMusicBeat(int16 argc, int16 *argv);
103  int16 sfSetScreenLock(int16 argc, int16 *argv);
104  int16 sfAddSprite(int16 argc, int16 *argv);
105  int16 sfFreeAnim(int16 argc, int16 *argv);
106  int16 sfDrawSprite(int16 argc, int16 *argv);
107  int16 sfEraseSprites(int16 argc, int16 *argv);
108  int16 sfUpdateSprites(int16 argc, int16 *argv);
109  int16 sfGetTimer(int16 argc, int16 *argv);
110  int16 sfSetTimer(int16 argc, int16 *argv);
111  int16 sfResetTimer(int16 argc, int16 *argv);
112  int16 sfAllocTimer(int16 argc, int16 *argv);
113  int16 sfFreeTimer(int16 argc, int16 *argv);
114  int16 sfSetPaletteLock(int16 argc, int16 *argv);
115  int16 sfSetFont(int16 argc, int16 *argv);
116  int16 sfDrawText(int16 argc, int16 *argv);
117  int16 sfHomeText(int16 argc, int16 *argv);
118  int16 sfSetTextRect(int16 argc, int16 *argv);
119  int16 sfSetTextXY(int16 argc, int16 *argv);
120  int16 sfSetFontDropShadow(int16 argc, int16 *argv);
121  int16 sfSetFontColor(int16 argc, int16 *argv);
122  int16 sfSetFontOutline(int16 argc, int16 *argv);
123  int16 sfLoadMouseCursor(int16 argc, int16 *argv);
124  int16 sfSetSpriteGround(int16 argc, int16 *argv);
125  int16 sfLoadResText(int16 argc, int16 *argv);
126  int16 sfSetClipArea(int16 argc, int16 *argv);
127  int16 sfSetSpriteClip(int16 argc, int16 *argv);
128  int16 sfAddScreenMask(int16 argc, int16 *argv);
129  int16 sfSetSpriteMask(int16 argc, int16 *argv);
130  int16 sfSoundPlaying(int16 argc, int16 *argv);
131  int16 sfStopSound(int16 argc, int16 *argv);
132  int16 sfPlayVoice(int16 argc, int16 *argv);
133  int16 sfPlayCd(int16 argc, int16 *argv);
134  int16 sfStopCd(int16 argc, int16 *argv);
135  int16 sfGetCdStatus(int16 argc, int16 *argv);
136  int16 sfGetCdTime(int16 argc, int16 *argv);
137  int16 sfPlayCdSegment(int16 argc, int16 *argv);
138  int16 sfPrintf(int16 argc, int16 *argv);
139  int16 sfClearMono(int16 argc, int16 *argv);
140  int16 sfGetSoundEnergy(int16 argc, int16 *argv);
141  int16 sfClearText(int16 argc, int16 *argv);
142  int16 sfAnimText(int16 argc, int16 *argv);
143  int16 sfGetTextWidth(int16 argc, int16 *argv);
144  int16 sfPlayMovie(int16 argc, int16 *argv);
145  int16 sfLoadSound(int16 argc, int16 *argv);
146  int16 sfLoadMusic(int16 argc, int16 *argv);
147  int16 sfLoadPicture(int16 argc, int16 *argv);
148  int16 sfSetMusicVolume(int16 argc, int16 *argv);
149  int16 sfRestartEvents(int16 argc, int16 *argv);
150  int16 sfPlaceSprite(int16 argc, int16 *argv);
151  int16 sfPlaceText(int16 argc, int16 *argv);
152  int16 sfDeleteChannel(int16 argc, int16 *argv);
153  int16 sfGetChannelType(int16 argc, int16 *argv);
154  int16 sfSetChannelState(int16 argc, int16 *argv);
155  int16 sfSetChannelLocation(int16 argc, int16 *argv);
156  int16 sfSetChannelContent(int16 argc, int16 *argv);
157  int16 sfSetExcludeArea(int16 argc, int16 *argv);
158  int16 sfSetSpriteExclude(int16 argc, int16 *argv);
159  int16 sfGetChannelState(int16 argc, int16 *argv);
160  int16 sfPlaceAnim(int16 argc, int16 *argv);
161  int16 sfSetAnimFrame(int16 argc, int16 *argv);
162  int16 sfGetAnimFrame(int16 argc, int16 *argv);
163  int16 sfGetAnimFrameCount(int16 argc, int16 *argv);
164  int16 sfGetPictureWidth(int16 argc, int16 *argv);
165  int16 sfGetPictureHeight(int16 argc, int16 *argv);
166  int16 sfSetSoundRate(int16 argc, int16 *argv);
167  int16 sfDrawAnimPic(int16 argc, int16 *argv);
168  int16 sfLoadAnim(int16 argc, int16 *argv);
169  int16 sfReadText(int16 argc, int16 *argv);
170  int16 sfReadMenu(int16 argc, int16 *argv);
171  int16 sfDrawMenu(int16 argc, int16 *argv);
172  int16 sfGetMenuCount(int16 argc, int16 *argv);
173  int16 sfSaveGame(int16 argc, int16 *argv);
174  int16 sfLoadGame(int16 argc, int16 *argv);
175  int16 sfGetGameDescription(int16 argc, int16 *argv);
176  int16 sfShakeScreen(int16 argc, int16 *argv);
177  int16 sfPlaceMenu(int16 argc, int16 *argv);
178  int16 sfSetSoundVolume(int16 argc, int16 *argv);
179  int16 sfGetSynthType(int16 argc, int16 *argv);
180  int16 sfIsSlowSystem(int16 argc, int16 *argv);
181 
182 };
183 
184 } // End of namespace Made
185 
186 #endif /* MADE_H */
Definition: resource.h:165
Definition: array.h:52
Definition: made.h:68
Definition: mixer.h:49
void debug(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: resource.h:118
Definition: console.h:27
Definition: scriptfuncs.h:42
Definition: func.h:473
Definition: pcspk.h:31
Definition: system.h:38