ScummVM API documentation
script.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 AWE_SCRIPT_H
23 #define AWE_SCRIPT_H
24 
25 #include "audio/mixer.h"
26 #include "awe/intern.h"
27 
28 namespace Awe {
29 
30 class Sound;
31 struct Resource;
32 struct SfxPlayer;
33 struct SystemStub;
34 struct Video;
35 
36 enum Difficulty {
37  DIFFICULTY_EASY = 0,
38  DIFFICULTY_NORMAL = 1,
39  DIFFICULTY_HARD = 2
40 };
41 
42 struct Script {
43  typedef void (Script:: *OpcodeStub)();
44 
45  enum ScriptVars {
46  VAR_RANDOM_SEED = 0x3C,
47 
48  VAR_SCREEN_NUM = 0x67,
49 
50  VAR_LAST_KEYCHAR = 0xDA,
51 
52  VAR_HERO_POS_UP_DOWN = 0xE5,
53 
54  VAR_MUSIC_SYNC = 0xF4,
55 
56  VAR_SCROLL_Y = 0xF9,
57  VAR_HERO_ACTION = 0xFA,
58  VAR_HERO_POS_JUMP_DOWN = 0xFB,
59  VAR_HERO_POS_LEFT_RIGHT = 0xFC,
60  VAR_HERO_POS_MASK = 0xFD,
61  VAR_HERO_ACTION_POS_MASK = 0xFE,
62  VAR_PAUSE_SLICES = 0xFF
63  };
64 
65  static const OpcodeStub OPCODE_TABLE[];
66  static const uint16 PERIOD_TABLE[];
67  static Difficulty _difficulty;
68  static bool _useRemasteredAudio;
69 
70  Sound *_sound;
71  Resource *_res;
72  SfxPlayer *_ply;
73  Video *_vid;
74  SystemStub *_stub = nullptr;
75 
76  int16 _scriptVars[256] = { 0 };
77  uint16 _scriptStackCalls[64] = { 0 };
78  uint16 _scriptTasks[2][64] = { { 0 } };
79  uint8 _scriptStates[2][64] = { { 0 } };
80  Ptr _scriptPtr;
81  uint8 _stackPtr = 0;
82  bool _scriptPaused = false;
83  bool _fastMode = false;
84  int _screenNum = 0;
85  bool _is3DO = false;
86  uint32 _startTime = 0, _timeStamp = 0;
87 
88  Script(Sound *snd, Resource *res, SfxPlayer *ply, Video *vid);
89  void init();
90 
91  void op_movConst();
92  void op_mov();
93  void op_add();
94  void op_addConst();
95  void op_call();
96  void op_ret();
97  void op_yieldTask();
98  void op_jmp();
99  void op_installTask();
100  void op_jmpIfVar();
101  void op_condJmp();
102  void op_setPalette();
103  void op_changeTasksState();
104  void op_selectPage();
105  void op_fillPage();
106  void op_copyPage();
107  void op_updateDisplay();
108  void op_removeTask();
109  void op_drawString();
110  void op_sub();
111  void op_and();
112  void op_or();
113  void op_shl();
114  void op_shr();
115  void op_playSound();
116  void op_updateResources();
117  void op_playMusic();
118 
119  void restartAt(int part, int pos = -1);
120  void setupPart(int num);
121  void setupTasks();
122  void runTasks();
123  void executeTask();
124 
125  void updateInput();
126  void inp_handleSpecialKeys();
127 
128  void snd_playSound(uint16 resNum, uint8 freq, uint8 vol, uint8 channel);
129  void snd_playMusic(uint16 resNum, uint16 delay, uint8 pos);
130  void snd_preloadSound(uint16 resNum, const uint8 *data);
131 
132  void fixUpPalette_changeScreen(int part, int screen);
133 };
134 
135 } // namespace Awe
136 
137 #endif
Definition: script.h:42
Definition: sound.h:57
Definition: resource.h:89
Definition: aifc_player.h:29
Definition: avi_frames.h:36
Definition: system_stub.h:58
Definition: intern.h:50
Definition: sfx_player.h:70