ScummVM API documentation
fta.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  * Based on the original sources
22  * Faery Tale II -- The Halls of the Dead
23  * (c) 1993-1996 The Wyrmkeep Entertainment Co.
24  */
25 
26 #ifndef SAGA2_FTA_H
27 #define SAGA2_FTA_H
28 
29 #include "saga2/gpointer.h"
30 
31 namespace Saga2 {
32 
33 class hResContext;
34 class hResource;
35 
36 /* ===================================================================== *
37  Constants
38  * ===================================================================== */
39 
40 // For GameMode Stack
41 const int kMax_Modes = 8, //Max Game Mode Objects
42  kEnd_List = 0; //Variable To Indicate End Of Arg List
43 
44 // Width and height of full screen
45 const int kScreenWidth = 640,
46  kScreenHeight = 480;
47 
48 // Number of ticks per second
49 const int kTicksPerSecond = 72; // 72 ticks per second
50 
51 // Desired frame rate of game (fps)
52 const int kFrameRate = 10,
53  kFramePeriod = kTicksPerSecond / kFrameRate;
54 
55 /* ====================================================================== *
56  Overall game modes
57  * ====================================================================== */
58 
59 /* There are basically 5 different 'modes' in the game. Three of those modes
60  are exclusive, while the other two "nest" on top of the others.
61 
62  The exclusive modes are:
63  1. Intro The animated slideshow of the introduction.
64  2. Finale The animated slideshow of the finale.
65  3. Main Play The scrolling tilemap view.
66 
67  The modes which can nest on top of the others are:
68  4. Modal Dialog A popup window that blocks all other input.
69  5. Cut Scene A non-interactive animated interlude.
70 
71  The GameMode class represents these modes as an explicit object.
72 */
73 
74 struct gMouseState;
75 
76 class GameMode {
77 public:
78  GameMode *_prev; // previous nested mode
79  int16 _nestable; // true if mode nests
80 
81  static GameMode *_modeStackPtr[kMax_Modes]; // Array Of Current Mode Stack Pointers to Game Objects
82  static int _modeStackCtr; // Counter For Array Of Mode Stack Pointers to Game Objects
83  static GameMode *_newmodeStackPtr[kMax_Modes]; // Array Of New Mode Stack Pointers to Game Objects
84  static int _newmodeStackCtr; // Counter For Array Of Mode Stack Pointers to Game Objects
85  static int _newmodeFlag; // Flag Telling EventLoop Theres A New Mode So Update
86  static GameMode *_currentMode, // pointer to current mode.
87  *_newMode; // next mode to run
88 
89  void (*_setup)(); // initialize this mode
90  void (*_cleanup)(); // deallocate mode resources
91  void (*_handleTask)(); // "application task" for mode
92  void (*_handleKey)(int16 key, int16 qual); // handle keystroke from window
93  void (*_draw)(); // handle draw functions for window
94 
95  static void modeUnStack();
96  static void modeUnStack(int StopHere);
97  static int getStack(GameMode **saveStackPtr);
98  static void SetStack(GameMode *modeFirst, ...);
99  static void SetStack(GameMode **newStack, int newStackSize);
100  static bool update();
101  static void modeStack(GameMode *AddThisMode);
102  void begin(); // launch this mode
103  void end(); // quit this mode
104  static void modeSwitch(); // quit this mode
105 };
106 
107 extern GameMode IntroMode,
108  FinaleMode,
109  PlayMode,
110  TileMode,
111  StageMode,
112  ModalDialogMode,
113  CutSceneMode,
114  VideoMode; //stageprob
115 
116 /* ====================================================================== *
117  Game Clock routines
118  * ====================================================================== */
119 
120 // Initialize the timer
121 void initTimer();
122 
123 void saveTimer(Common::OutSaveFile *out);
124 void loadTimer(Common::InSaveFile *in);
125 
126 void pauseTimer(); // pause game clock
127 void resumeTimer(); // resume game clock
128 
129 // Alarm is a useful class for specifying time delays. It will
130 // work correctly even if the game counter wraps around.
131 
132 class Alarm {
133 public:
134  uint32 _basetime; // timer alarm was set
135  uint32 _duration; // duration of alarm
136 
137  void set(uint32 duration);
138  bool check();
139  uint32 elapsed(); // time elapsed since alarm set
140 
141  void write(Common::MemoryWriteStreamDynamic *out);
142  void read(Common::InSaveFile *in);
143 };
144 
145 /* ===================================================================== *
146  Misc Prototypes
147  * ===================================================================== */
148 
149 // Debugging status
150 
151 void WriteStatusF(int16 lin, const char *msg, ...);
152 
153 // File loading
154 
155 void *LoadFile(char *filename); // load file into buffer
156 
157 // Resource loading
158 
159 void *LoadResource(hResContext *con, uint32 id, const char desc[]);
160 void dumpResource(hResContext *con, uint32 id);
161 Common::SeekableReadStream *loadResourceToStream(hResContext *con, uint32 id, const char desc[]);
162 
163 // Directory control
164 
165 void restoreProgramDir(); // chdir() to program directory
166 
167 // Returns Random Number
168 
169 int16 GetRandomBetween(int start, int end);
170 
171 // Distance calculation
172 
173 int16 quickDistance(const Point16 &p);
174 int32 quickDistance(const Point32 &p);
175 
176 void initPathFinder();
177 void cleanupPathFinder();
178 
179 /* ===================================================================== *
180  Miscellaneous globals management functions
181  * ===================================================================== */
182 
183 void initGlobals();
184 void saveGlobals(Common::OutSaveFile *outS);
185 void loadGlobals(Common::InSaveFile *in);
186 inline void cleanupGlobals() {} // do nothing
187 
188 /* ===================================================================== *
189  Script-related
190  * ===================================================================== */
191 
192 typedef int16 ThreadID;
193 const ThreadID NoThread = -1;
194 
195 // Wake up a thread unconditionally
196 void wakeUpThread(ThreadID thread);
197 
198 // Wake up a thread and set return value from SAGA function
199 void wakeUpThread(ThreadID thread, int16 returnVal);
200 
201 // Script system initialization and cleanup
202 void initScripts();
203 void cleanupScripts();
204 void dispatchScripts();
205 
206 // An extended script is running -- suspend all background processing.
207 extern int16 extendedThreadLevel;
208 
209 /* ===================================================================== *
210  Misc Globals
211  * ===================================================================== */
212 
213 extern volatile int32 gameTime; // current timer
214 
215 // Resource files
216 
217 extern hResource *resFile, // our main resource file
218  *objResFile,
219  *auxResFile;
220 
221 } // end of namespace Saga2
222 
223 #endif
Definition: rect.h:184
Definition: savefile.h:54
Definition: actor.h:32
Definition: memstream.h:194
Definition: stream.h:745
Definition: hresmgr.h:98
Definition: hresmgr.h:152
Definition: rect.h:42
Definition: fta.h:76
Definition: fta.h:132