aboutsummaryrefslogtreecommitdiff
path: root/engines/made/scriptfuncs.h
blob: 5fdfb77f45c5f715e63992b2ff77537931e55ada (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/* 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.
 *
 * $URL$
 * $Id$
 *
 */

#ifndef MADE_SCRIPTFUNCS_H
#define MADE_SCRIPTFUNCS_H

#include "common/util.h"
#include "common/file.h"
#include "common/func.h"
#include "common/stream.h"

#include "made/resource.h"

namespace Made {

class MadeEngine;

typedef Common::Functor2<int16, int16*, int16> ExternalFunc;

class ScriptFunctions {
public:
	ScriptFunctions(MadeEngine *vm) : _vm(vm), _soundStarted(false) {}
	virtual ~ScriptFunctions() {
		for (uint i = 0; i < _externalFuncs.size(); ++i)
			delete _externalFuncs[i];
	}
	int16 callFunction(uint16 index, int16 argc, int16 *argv)  {
		if (index >= _externalFuncs.size())
			error("ScriptFunctions::callFunction() Invalid function index %d", index);
		debug(4, "%s", _externalFuncNames[index]);
		return (*_externalFuncs[index])(argc, argv);
	}
	void setupExternalsTable();
	const char* getFuncName(int index) { return _externalFuncNames[index]; }
	int getCount() const { return _externalFuncs.size(); }
	void stopSound();

protected:
	MadeEngine *_vm;
	Audio::SoundHandle _audioStreamHandle;
	Audio::SoundHandle _voiceStreamHandle;
	SoundResource* _soundResource;
	bool _soundStarted;

	Common::Array<const ExternalFunc*> _externalFuncs;
	Common::Array<const char *> _externalFuncNames;
	GenericResource *_musicRes;

	int16 sfSystemCall(int16 argc, int16 *argv);
	int16 sfInitGraf(int16 argc, int16 *argv);
	int16 sfRestoreGraf(int16 argc, int16 *argv);
	int16 sfDrawPicture(int16 argc, int16 *argv);
	int16 sfClearScreen(int16 argc, int16 *argv);
	int16 sfShowPage(int16 argc, int16 *argv);
	int16 sfPollEvent(int16 argc, int16 *argv);
	int16 sfGetMouseX(int16 argc, int16 *argv);
	int16 sfGetMouseY(int16 argc, int16 *argv);
	int16 sfGetKey(int16 argc, int16 *argv);
	int16 sfSetVisualEffect(int16 argc, int16 *argv);
	int16 sfPlaySound(int16 argc, int16 *argv);
	int16 sfPlayMusic(int16 argc, int16 *argv);
	int16 sfStopMusic(int16 argc, int16 *argv);
	int16 sfIsMusicPlaying(int16 argc, int16 *argv);
	int16 sfSetTextPos(int16 argc, int16 *argv);
	int16 sfFlashScreen(int16 argc, int16 *argv);
	int16 sfPlayNote(int16 argc, int16 *argv);
	int16 sfStopNote(int16 argc, int16 *argv);
	int16 sfPlayTele(int16 argc, int16 *argv);
	int16 sfStopTele(int16 argc, int16 *argv);
	int16 sfHideMouseCursor(int16 argc, int16 *argv);
	int16 sfShowMouseCursor(int16 argc, int16 *argv);
	int16 sfGetMusicBeat(int16 argc, int16 *argv);
	int16 sfSetScreenLock(int16 argc, int16 *argv);
	int16 sfAddSprite(int16 argc, int16 *argv);
	int16 sfFreeAnim(int16 argc, int16 *argv);
	int16 sfDrawSprite(int16 argc, int16 *argv);
	int16 sfEraseSprites(int16 argc, int16 *argv);
	int16 sfUpdateSprites(int16 argc, int16 *argv);
	int16 sfGetTimer(int16 argc, int16 *argv);
	int16 sfSetTimer(int16 argc, int16 *argv);
	int16 sfResetTimer(int16 argc, int16 *argv);
	int16 sfAllocTimer(int16 argc, int16 *argv);
	int16 sfFreeTimer(int16 argc, int16 *argv);
	int16 sfSetPaletteLock(int16 argc, int16 *argv);
	int16 sfSetFont(int16 argc, int16 *argv);
	int16 sfDrawText(int16 argc, int16 *argv);
	int16 sfHomeText(int16 argc, int16 *argv);
	int16 sfSetTextRect(int16 argc, int16 *argv);
	int16 sfSetTextXY(int16 argc, int16 *argv);
	int16 sfSetFontDropShadow(int16 argc, int16 *argv);
	int16 sfSetFontColor(int16 argc, int16 *argv);
	int16 sfSetFontOutline(int16 argc, int16 *argv);
	int16 sfLoadMouseCursor(int16 argc, int16 *argv);
	int16 sfSetSpriteGround(int16 argc, int16 *argv);
	int16 sfLoadResText(int16 argc, int16 *argv);
	int16 sfSetClipArea(int16 argc, int16 *argv);
	int16 sfSetSpriteClip(int16 argc, int16 *argv);
	int16 sfAddScreenMask(int16 argc, int16 *argv);
	int16 sfSetSpriteMask(int16 argc, int16 *argv);
	int16 sfSoundPlaying(int16 argc, int16 *argv);
	int16 sfStopSound(int16 argc, int16 *argv);
	int16 sfPlayVoice(int16 argc, int16 *argv);
	int16 sfPlayCd(int16 argc, int16 *argv);
	int16 sfStopCd(int16 argc, int16 *argv);
	int16 sfGetCdStatus(int16 argc, int16 *argv);
	int16 sfGetCdTime(int16 argc, int16 *argv);
	int16 sfPlayCdSegment(int16 argc, int16 *argv);
	int16 sfPrintf(int16 argc, int16 *argv);
	int16 sfClearMono(int16 argc, int16 *argv);
	int16 sfGetSoundEnergy(int16 argc, int16 *argv);
	int16 sfClearText(int16 argc, int16 *argv);
	int16 sfAnimText(int16 argc, int16 *argv);
	int16 sfGetTextWidth(int16 argc, int16 *argv);
	int16 sfPlayMovie(int16 argc, int16 *argv);
	int16 sfLoadSound(int16 argc, int16 *argv);
	int16 sfLoadMusic(int16 argc, int16 *argv);
	int16 sfLoadPicture(int16 argc, int16 *argv);
	int16 sfSetMusicVolume(int16 argc, int16 *argv);
	int16 sfRestartEvents(int16 argc, int16 *argv);
	int16 sfPlaceSprite(int16 argc, int16 *argv);
	int16 sfPlaceText(int16 argc, int16 *argv);
	int16 sfDeleteChannel(int16 argc, int16 *argv);
	int16 sfGetChannelType(int16 argc, int16 *argv);
	int16 sfSetChannelState(int16 argc, int16 *argv);
	int16 sfSetChannelLocation(int16 argc, int16 *argv);
	int16 sfSetChannelContent(int16 argc, int16 *argv);
	int16 sfSetExcludeArea(int16 argc, int16 *argv);
	int16 sfSetSpriteExclude(int16 argc, int16 *argv);
	int16 sfGetChannelState(int16 argc, int16 *argv);
	int16 sfPlaceAnim(int16 argc, int16 *argv);
	int16 sfSetAnimFrame(int16 argc, int16 *argv);
	int16 sfGetAnimFrame(int16 argc, int16 *argv);
	int16 sfGetAnimFrameCount(int16 argc, int16 *argv);
	int16 sfGetPictureWidth(int16 argc, int16 *argv);
	int16 sfGetPictureHeight(int16 argc, int16 *argv);
	int16 sfSetSoundRate(int16 argc, int16 *argv);
	int16 sfDrawAnimPic(int16 argc, int16 *argv);
	int16 sfLoadAnim(int16 argc, int16 *argv);
	int16 sfReadText(int16 argc, int16 *argv);
	int16 sfReadMenu(int16 argc, int16 *argv);
	int16 sfDrawMenu(int16 argc, int16 *argv);
	int16 sfGetMenuCount(int16 argc, int16 *argv);
	int16 sfSaveGame(int16 argc, int16 *argv);
	int16 sfLoadGame(int16 argc, int16 *argv);
	int16 sfGetGameDescription(int16 argc, int16 *argv);
	int16 sfShakeScreen(int16 argc, int16 *argv);
	int16 sfPlaceMenu(int16 argc, int16 *argv);
	int16 sfSetSoundVolume(int16 argc, int16 *argv);
	int16 sfGetSynthType(int16 argc, int16 *argv);
	int16 sfIsSlowSystem(int16 argc, int16 *argv);

};

} // End of namespace Made

#endif /* MADE_H */