aboutsummaryrefslogtreecommitdiff
path: root/queen/cutaway.h
blob: 3739ab4b2351af4b2590f20149b8fac36d6c16d1 (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
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2003-2004 The ScummVM project
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header$
 *
 */

#ifndef QUEENCUTAWAY_H
#define QUEENCUTAWAY_H

#include "common/util.h"
#include "queen/structs.h"

namespace Queen {

class QueenEngine;

class Cutaway {
	public:
		//! Public interface to run a cutaway from a file
		static void run(
				const char *filename,
				char *nextFilename,
				QueenEngine *vm);

	public:
		//! Collection of constants used by QueenCutaway
		enum {
			PREVIOUS_ROOM = 0,
			CURRENT_ROOM = 0,
			OBJECT_ROOMFADE = -1,
			PERSON_JOE = -1,
			OBJECT_JOE = 0,
			MAX_PERSON_COUNT = 6,
			CUTAWAY_BANK = 8,
			MAX_BANK_NAME_COUNT = 5,
			MAX_FILENAME_LENGTH = 12,
			MAX_FILENAME_SIZE = (MAX_FILENAME_LENGTH + 1),
			MAX_PERSON_FACE_COUNT = 12,
			MAX_STRING_LENGTH = 255,
			MAX_STRING_SIZE = (MAX_STRING_LENGTH + 1),
			LEFT = 1,
			RIGHT = 2,
			FRONT = 3,
			BACK = 4
		};

		//! Different kinds of cutaway objects
		enum ObjectType {
			OBJECT_TYPE_ANIMATION               = 0,
			OBJECT_TYPE_PERSON                  = 1,
			OBJECT_TYPE_NO_ANIMATION            = 2,
			OBJECT_TYPE_TEXT_SPEAK              = 3,
			OBJECT_TYPE_TEXT_DISPLAY_AND_SPEAK  = 4,
			OBJECT_TYPE_TEXT_DISPLAY            = 5
		};

	private:
		//! Data for a cutaway object
		struct CutawayObject {
			int16 objectNumber;    // 0 = JOE, -1 = MESSAGE
			int16 moveToX;
			int16 moveToY;
			int16 bank;             // 0 = PBOB, 13 = Joe Bank, else BANK NAMEstr()
			int16 animList;
			int16 execute;          // 1 Yes, 0 No
			int16 limitBobX1;
			int16 limitBobY1;
			int16 limitBobX2;
			int16 limitBobY2;
			int16 specialMove;
			int16 animType;        // 0 - Packet, 1 - Amal, 2 - Unpack
			int16 fromObject;
			int16 bobStartX;
			int16 bobStartY;
			int16 room;
			int16 scale;

			// Variables derived from the variables above
			int song;

			//! People to turn on
			int person[MAX_PERSON_COUNT];

			//! Number of elements used in _person array
			int personCount;
		};

		struct CutawayAnim {
			int16 object;
			int16 unpackFrame;          // Frame to unpack
			int16 speed;
			int16 bank;
			int16 mx;
			int16 my;
			int16 cx;
			int16 cy;
			int16 scale;
			int16 currentFrame;  // Index to Current Frame
			int16 originalFrame;  // Index to Original Object Frame
			int16 song;
			bool flip;		// set this if unpackFrame is negative
		};

		struct ObjectDataBackup {
			int index;
			int16 name;
			int16 image;
		};

		struct PersonFace {
		  int16 index;
		  int16 image;
		};

		QueenEngine *_vm;

		//! Raw .cut file data (without 20 byte header)
		byte *_fileData;

		//! COMPANEL
		int16 _comPanel;

		//! Game state data inside of _fileDat
		byte *_gameStatePtr;

		//! Actual cutaway data inside of _fileData
		byte *_objectData;

		//! Pointer to next sentence string in _fileData
		byte *_nextSentence;

		//! ???
		bool _roomFade;

		//! Number of cutaway objects at _cutawayData
		int16 _cutawayObjectCount;

		//! This cutaway is followed by another
		bool _anotherCutaway;

		//! Room before cutaway
		int _initialRoom; 

		//! Temporary room for cutaway
		int _temporaryRoom; 

		//! Room to stay in 
		int _finalRoom; 

		//! Bank names
		char _bankNames[MAX_BANK_NAME_COUNT][MAX_FILENAME_SIZE];

		//! Filename without ".cut"
		char _basename[MAX_FILENAME_SIZE];

		//! Name of .dog file
		char _talkFile[MAX_FILENAME_SIZE];

		//! Person to talk to
		int16 _talkTo;

		//! Used by changeRooms
		ObjectDataBackup _personData[MAX_PERSON_COUNT];

		//! Number of elements used in _personData array
		int _personDataCount;

		//! Used by handlePersonRecord()
		PersonFace _personFace[MAX_PERSON_FACE_COUNT];

		//! Number of entries in _personFace array
		int _personFaceCount;

		//! Play this song when leaving cutaway
		int16 _lastSong;

		//! Song played before running comic.cut
		int16 _songBeforeComic;

		int16 _currentImage;

		AnimFrame _cutAnim[17][30];

		Cutaway(const char *filename, 
				QueenEngine *vm);
		~Cutaway();

		//! Run this cutaway object 
		void run(char *nextFilename);

		//! Load cutaway data from file 
		void load(const char *filename);

		//! Used by load to read string data
		void loadStrings(byte *ptr);

		//! Get persons
		byte *turnOnPeople(byte *ptr, CutawayObject &object);

		//! Limit the BOB
		void limitBob(CutawayObject &object);

		//! This cutaway object occurs in another room
		void changeRooms(CutawayObject &object);

		//! Get the object type for this CutawayObject
		ObjectType getObjectType(CutawayObject &object);

		//! Perform actions for an animation
		byte *handleAnimation(byte *ptr, CutawayObject &object);

		//! Perform actions for a person record
		void handlePersonRecord(
				int index, 
				CutawayObject &object, 
				const char *sentence);
		
		//! Perform text actions
		void handleText(
				int index, 
				ObjectType type, 
				CutawayObject &object, 
				const char *sentence);

		//! Restore QueenLogic::_objectData from _personData
		void restorePersonData();

		//! Stop the cutaway
		void stop();

		//! Update game state after cutaway
		void updateGameState();

		//! Prepare for talk after cutaway
		void talk(char *nextFilename);

		//! Get CutawayAnim data from ptr and return new ptr
		byte *getCutawayAnim(byte *ptr, int header, CutawayAnim &anim);

		//! Special animation
		int makeComplexAnimation(int16 currentImage, CutawayAnim *objAnim, int frameCount);

		//! Read a CutawayObject from ptr and return new ptr
		static byte *getCutawayObject(byte *ptr, CutawayObject &object);

		//! Dump a CutawayObject with debug()
		void dumpCutawayObject(int index, CutawayObject &object);

		//! Used by handleText()
		int countSpaces(ObjectType type, const char *segment);

		//! Scale Joe
		int scale(CutawayObject &object);

		//! Dump CutawayAnum data with debug()
		static void dumpCutawayAnim(CutawayAnim &anim);

};

} // End of namespace Queen

#endif