1 /* ResidualVM - A 3D game interpreter
2  *
3  * ResidualVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the AUTHORS
5  * file distributed with this source distribution.
6  *
7  * Additional copyright for this file:
8  * Copyright (C) 1999-2000 Revolution Software Ltd.
9  * This code is based on source code created by Revolution Software,
10  * used with permission.
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25  *
26  */
27 
28 #ifndef ICB_MISSION
29 #define ICB_MISSION
30 
31 #include "engines/icb/common/px_common.h"
32 #include "engines/icb/session.h"
33 #include "engines/icb/string_vest.h"
34 
35 namespace ICB {
36 
37 #define SR_VERSION 17
38 
39 // save_game_max is :
40 // 8192 (1 memory card block) - 256 (PSX system data) - 8 (PSX engine data)
41 #define SAVE_GAME_MAX_SIZE (8192 - 256 - 8)
42 
43 // total number of sessions allowed per mission
44 #define MAX_sessions 5
45 #define MAX_fvars (MAX_voxel_list * 4)
46 #define MAX_lvars 30
47 
48 class _micro_object {
49 public:
50 	int32 lvar_value[MAX_lvars];
51 	uint32 total_lvars; // worth doing to reduce save game size
52 
53 	_object_status status_flag;
54 };
55 
56 class _micro_session {
57 public:
58 	char session__name[ENGINE_STRING_LEN]; // eg land_train
59 
60 	uint32 number_of_micro_objects;
61 	_micro_object micro_objects[MAX_session_objects];
62 
63 	int32 fvars[MAX_fvars];
64 };
65 
66 enum __load_result { __NO_SUCH_FILE, __WRONG_VERSION, __GLOBAL_MISMATCH, __LOAD_OK };
67 
68 class _mission {
69 
70 public:
71 	_mission();
72 	~_mission();
73 
74 	void ___init_mission(const char *mission, const char *session);
75 	void ___delete_mission();
76 
77 	void End_mission();
78 
79 	inline const char *Fetch_mission_name();
80 	inline const char *Fetch_h_mission_name();
81 	inline const char *Fetch_tiny_mission_name();
82 	inline const char *Fetch_tiny_session_name();
83 	uint32 Game_cycle();
84 	void Create_display();
85 	void Set_new_session_name(const char *ascii);
86 	void Set_init_nico_name(const char *ascii);
87 	bool8 Is_there_init_nico();
88 	const char *Return_init_nico_name();
89 	void Reset_init_nico();
90 	void Save_micro_session();
91 	void Restore_micro_session_coords(bool8 from_disk);
92 	void Restore_micro_session_vars();
93 	void Save_game_position(const char *filename, const char *slot_label, uint32 timeplayed);
94 	void Restore_micro_session_from_save_game(Common::SeekableReadStream *stream);
95 	void SavePlatformSpecific(Common::WriteStream *stream);
96 	void LoadPlatformSpecific(Common::SeekableReadStream *stream);
97 
98 	_game_session *session; // pointer to current game session object
99 
100 	// camera stuff
101 	uint32 camera_follow_id_overide; // id of a character to watch - if 0 defaults to player
102 	// here because we want it to hold across session boundaries
103 	// This flag keeps track of whether or not the Remora was active when an fn_set_watch()
104 	// was issued, so it can be put back how it was.
105 	int32 remora_save_mode;
106 
107 	uint32 ad_time;           // actor draw timer flags used for debugging
108 	uint32 lt_time;           // actor draw timer flags used for debugging
109 	uint32 set_time;          // setdraw timer flags used for debugging
110 	uint32 flip_time;         // back buffer blit timer used for debugging
111 	uint32 cycle_time;        // The length of time the last cycle took
112 	uint32 logic_time;        // Time spent in logic
113 	uint32 resman_logic_time; // Time spent in logic
114 	uint32 los_time;
115 	uint32 event_time;
116 	uint32 sound_time;
117 	uint32 xtra_mega_time;
118 	uint32 nActorsDrawn;
119 	uint32 nActorsConsidered;
120 
121 	// points to the name of a new session
122 	char new_session_name[TINY_NAME_LEN];
123 	char init_nico_name[TINY_NAME_LEN];
124 	int32 old_hits_value; // we carry across the lvars from the previous session - this is getting tweeky
125 
126 	bool8 chi_following; // is a chi object following the player? Used for session changes
127 
128 	// player requires these to cross sessions
129 	uint32 num_bullets;
130 	uint32 num_clips;
131 	uint32 num_medi;
132 
133 	bool8 inited_globals; // yes or no - used to init the globals
134 
135 private:
136 	char mission_name[ENGINE_STRING_LEN];  // full path
137 	char tiny_mission_name[TINY_NAME_LEN]; // eg land_train
138 	char tiny_session_name[TINY_NAME_LEN]; // eg car_5
139 
140 	uint32 mission_terminate; //! 0 means the mission will end
141 	char h_mission_name[8];   // filename of the hash'ed version of mission_name
142 
143 	uint32 mission_status; // 0 ok
144 	// 1 terminate the mission - mission has finished
145 
146 	uint32 number_sessions_saved;
147 	_micro_session micro_sessions[MAX_sessions];
148 
149 	bool8 new_session; // yes new session
150 	bool8 init_nico;   // yes new session nico
151 };
152 
153 bool8 Setup_new_mission(const char *mission_name, const char *session_name);
154 bool8 Setup_camtest_mission();
155 __load_result Load_game(const char *filename);
156 
Fetch_mission_name()157 inline const char *_mission::Fetch_mission_name() { return (mission_name); }
158 
Fetch_tiny_mission_name()159 inline const char *_mission::Fetch_tiny_mission_name() { return (tiny_mission_name); }
160 
Fetch_tiny_session_name()161 inline const char *_mission::Fetch_tiny_session_name() { return (tiny_session_name); }
162 
Fetch_h_mission_name()163 inline const char *_mission::Fetch_h_mission_name() { return (h_mission_name); }
164 
165 } // End of namespace ICB
166 
167 #endif
168