File: fta.h

package info (click to toggle)
scummvm 2.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 450,580 kB
  • sloc: cpp: 4,299,825; asm: 28,322; python: 12,901; sh: 11,302; java: 9,289; xml: 7,895; perl: 2,639; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (223 lines) | stat: -rw-r--r-- 7,661 bytes parent folder | download | duplicates (3)
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/* 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 3 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, see <http://www.gnu.org/licenses/>.
 *
 *
 * Based on the original sources
 *   Faery Tale II -- The Halls of the Dead
 *   (c) 1993-1996 The Wyrmkeep Entertainment Co.
 */

#ifndef SAGA2_FTA_H
#define SAGA2_FTA_H

#include "saga2/gpointer.h"

namespace Saga2 {

class hResContext;
class hResource;

/* ===================================================================== *
   Constants
 * ===================================================================== */

//  For GameMode Stack
const int           kMax_Modes   =   8,  //Max Game Mode Objects
                    kEnd_List    =   0;  //Variable To Indicate End Of Arg List

//  Width and height of full screen
const int           kScreenWidth = 640,
                    kScreenHeight = 480;

//  Number of ticks per second
const int           kTicksPerSecond = 72;    // 72 ticks per second

//  Desired frame rate of game (fps)
const int           kFrameRate = 10,
                    kFramePeriod = kTicksPerSecond / kFrameRate;

/* ====================================================================== *
   Overall game modes
 * ====================================================================== */

/*  There are basically 5 different 'modes' in the game. Three of those modes
    are exclusive, while the other two "nest" on top of the others.

    The exclusive modes are:
        1.  Intro           The animated slideshow of the introduction.
        2.  Finale          The animated slideshow of the finale.
        3.  Main Play       The scrolling tilemap view.

    The modes which can nest on top of the others are:
        4.  Modal Dialog    A popup window that blocks all other input.
        5.  Cut Scene       A non-interactive animated interlude.

    The GameMode class represents these modes as an explicit object.
*/

struct gMouseState;

class GameMode {
public:
	GameMode        *_prev;                  // previous nested mode
	int16           _nestable;               // true if mode nests

	static  GameMode    *_modeStackPtr[kMax_Modes]; // Array Of Current Mode Stack Pointers to Game Objects
	static  int         _modeStackCtr;       // Counter For Array Of Mode Stack Pointers to Game Objects
	static  GameMode    *_newmodeStackPtr[kMax_Modes]; // Array Of New Mode Stack Pointers to Game Objects
	static  int         _newmodeStackCtr;        // Counter For Array Of Mode Stack Pointers to Game Objects
	static  int         _newmodeFlag;        // Flag Telling EventLoop Theres A New Mode So Update
	static GameMode *_currentMode,           // pointer to current mode.
	       *_newMode;               // next mode to run

	void (*_setup)();                     // initialize this mode
	void (*_cleanup)();               // deallocate mode resources
	void (*_handleTask)();                // "application task" for mode
	void (*_handleKey)(int16 key, int16 qual);  // handle keystroke from window
	void (*_draw)();                          // handle draw functions for window

	static  void modeUnStack();
	static  void modeUnStack(int StopHere);
	static  int getStack(GameMode **saveStackPtr);
	static  void SetStack(GameMode *modeFirst, ...);
	static  void SetStack(GameMode **newStack, int newStackSize);
	static  bool update();
	static  void modeStack(GameMode *AddThisMode);
	void begin();                        // launch this mode
	void end();                          // quit this mode
	static void modeSwitch();            // quit this mode
};

extern GameMode     IntroMode,
       FinaleMode,
       PlayMode,
       TileMode,
       StageMode,
       ModalDialogMode,
       CutSceneMode,
       VideoMode; //stageprob

/* ====================================================================== *
   Game Clock routines
 * ====================================================================== */

//  Initialize the timer
void initTimer();

void saveTimer(Common::OutSaveFile *out);
void loadTimer(Common::InSaveFile *in);

void pauseTimer();               // pause game clock
void resumeTimer();                  // resume game clock

//  Alarm is a useful class for specifying time delays. It will
//  work correctly even if the game counter wraps around.

class Alarm {
public:
	uint32 _basetime;                            // timer alarm was set
	uint32 _duration;                            // duration of alarm

	void set(uint32 duration);
	bool check();
	uint32 elapsed();                    // time elapsed since alarm set

	void write(Common::MemoryWriteStreamDynamic *out);
	void read(Common::InSaveFile *in);
};

/* ===================================================================== *
   Misc Prototypes
 * ===================================================================== */

//  Debugging status

void WriteStatusF(int16 lin, const char *msg, ...);

//  File loading

void  *LoadFile(char *filename);             // load file into buffer

//  Resource loading

void *LoadResource(hResContext *con, uint32 id, const char desc[]);
void dumpResource(hResContext *con, uint32 id);
Common::SeekableReadStream *loadResourceToStream(hResContext *con, uint32 id, const char desc[]);

//  Directory control

void restoreProgramDir();                // chdir() to program directory

// Returns Random Number

int16 GetRandomBetween(int start, int end);

//  Distance calculation

int16 quickDistance(const Point16 &p);
int32 quickDistance(const Point32 &p);

void initPathFinder();
void cleanupPathFinder();

/* ===================================================================== *
   Miscellaneous globals management functions
 * ===================================================================== */

void initGlobals();
void saveGlobals(Common::OutSaveFile *outS);
void loadGlobals(Common::InSaveFile *in);
inline void cleanupGlobals() {}      // do nothing

/* ===================================================================== *
   Script-related
 * ===================================================================== */

typedef int16 ThreadID;
const ThreadID  NoThread = -1;

//  Wake up a thread unconditionally
void wakeUpThread(ThreadID thread);

//  Wake up a thread and set return value from SAGA function
void wakeUpThread(ThreadID thread, int16 returnVal);

//  Script system initialization and cleanup
void initScripts();
void cleanupScripts();
void dispatchScripts();

//  An extended script is running -- suspend all background processing.
extern int16            extendedThreadLevel;

/* ===================================================================== *
   Misc Globals
 * ===================================================================== */

extern volatile int32 gameTime;             // current timer

//  Resource files

extern hResource    *resFile,               // our main resource file
       *objResFile,
       *auxResFile;

} // end of namespace Saga2

#endif