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