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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23  // Disable symbol overrides so that we can use system headers.
24 #define FORBIDDEN_SYMBOL_ALLOW_ALL
25 
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include "common/language.h"
30 #include "common/memstream.h"
31 #include "common/rect.h"
32 #include "zlib.h"
33 #include "winexe_pe.h"
34 #include "file.h"
35 #include "script_preresponses.h"
36 #include "script_quotes.h"
37 #include "script_responses.h"
38 #include "script_ranges.h"
39 #include "script_states.h"
40 #include "tag_maps.h"
41 
42 /**
43  * Format of the access.dat file that will be created:
44  * 4 Bytes - Magic string 'SVTN' to identify valid data file
45  * 2 bytes - Version number
46  *
47  * Following is a series of index entries with the following fields:
48  * 4 bytes - offset in file of entry
49  * 4 bytes - size of entry in the file
50  * ASCIIZ  - name of the resource
51  */
52 
53 #define VERSION_NUMBER 5
54 #define HEADER_SIZE 0x1700
55 
56 Common::File inputFile, outputFile;
57 Common::PEResources resEng, resGer;
58 uint headerOffset = 6;
59 uint dataOffset = HEADER_SIZE;
60 
61 #define ENGLISH_10042C_FILESIZE 4099072
62 #define ENGLISH_10042B_FILESIZE 4095488
63 #define ENGLISH_10042_FILESIZE 4094976
64 #define GERMAN_10042D_FILESIZE 4542464
65 
66 enum {
67 	ENGLISH_10042C_DIFF = 0x401C00,
68 	ENGLISH_10042B_DIFF = 0x401400,
69 	ENGLISH_10042_DIFF = 0x402000,
70 	GERMAN_DIFF = 0x401200
71 };
72 enum Version {
73 	ENGLISH_10042C = 0,
74 	ENGLISH_10042B = 1,
75 	ENGLISH_10042 = 2,
76 	GERMAN = 3
77 };
78 Version _version;
79 
80 const int FILE_DIFF[4] = {
81 	ENGLISH_10042C_DIFF, ENGLISH_10042B_DIFF, ENGLISH_10042_DIFF,
82 	GERMAN_DIFF
83 };
84 
85 static const char *const ITEM_NAMES[46] = {
86 	"LeftArmWith", "LeftArmWithout", "RightArmWith", "RightArmWithout", "BridgeRed",
87 	"BridgeYellow", "BridgeBlue", "BridgeGreen", "Parrot", "CentralCore", "BrainGreen",
88 	"BrainYellow", "BrainRed", "BrainBlue", "ChickenGreasy", "ChickenPlain", "ChickenPurple",
89 	"ChickenRed", "ChickenYellow", "CrushedTV", "Ear", "Ear1", "Eyeball", "Eyeball1",
90 	"Feather", "Lemon", "GlassEmpty", "GlassPurple", "GlassRed", "GlassYellow", "Hammer",
91 	"Hose", "HoseEnd", "LiftHead", "LongStick", "Magazine", "Mouth", "MusicKey", "Napkin",
92 	"Nose", "Perch", "PhonoCylinder", "PhonoCylinder1", "PhonoCylinder2", "PhonoCylinder3",
93 	"Photo"
94 };
95 
96 static const char *const ITEM_DESCRIPTIONS[46] = {
97 	"The Maitre d'Bot's left arm holding a key", "The Maitre d'Bot's left arm",
98 	"The Maitre d'Bot's right arm holding Titania's auditory center",
99 	"The Maitre d'Bot's right arm", "Red Fuse", "Yellow Fuse", "Blue Fuse",
100 	"Green Fuse", "The Parrot", "Titania's central intelligence core",
101 	"Titania's auditory center", "Titania's olfactory center",
102 	"Titania's speech center", "Titania's vision center", "rather greasy chicken",
103 	"very plain chicken", "chicken smeared with starling pur$e",
104 	"chicken covered with tomato sauce", "chicken coated in mustard sauce",
105 	"A crushed television set", "Titania's ear", "Titania's ear", "Titania's eye",
106 	"Titania's eye", "A parrot feather", "A nice fat juicy lemon",
107 	"An empty beer glass", "A beer glass containing pur$ed flock of starlings",
108 	"A beer glass containing tomato sauce", "A beer glass containing mustard sauce",
109 	"A hammer", "A hose", "The other end of a hose", "The LiftBot's head",
110 	"A rather long stick", "A magazine", "Titania's mouth", "A key",
111 	"A super-absorbent napkin", "Titania's nose", "A perch", "A phonograph cylinder",
112 	"A phonograph cylinder", "A phonograph cylinder", "A phonograph cylinder",
113 	"A photograph"
114 };
115 static const char *const ITEM_DESCRIPTIONS_DE[46] = {
116 	"Der linke Arm des OberkellnerBots, im Besitz eines Schl\xFC""ssels ",
117 	"Der linke Arm des OberkellnerBots",
118 	"Der rechte Arm des OberkellnerBots, im Besitz von Titanias Geh\xF6""rmodul",
119 	"Der rechte Arm des OberkellnerBots",
120 	"Rote Sicherung",
121 	"Gelbe Sicherung",
122 	"Blaue Sicherung",
123 	"Gr\xFC""ne Sicherung",
124 	"Der Papagei",
125 	"Titanias Gro\xDF""hirn",
126 	"Titanias Geh\xF6""rmodul",
127 	"Titanias Geruchsmodul",
128 	"Titanias Sprachmodul",
129 	"Titanias Gesichtsmodul",
130 	"ziemlich fettiges H\xFC""hnchen",
131 	"H\xFC""hnchen ohne alles",
132 	"mit Starenp\xFC""ree beschmiertes H\xFC""hnchen",
133 	"mit Tomatensauce garniertes H\xFC""hnchen",
134 	"mit Senfso\xDF""e \xFC""berzogenes H\xFC""hnchen",
135 	"Ein zerschmetterter Fernsehapparat",
136 	"Titanias Ohr",
137 	"Titanias Ohr",
138 	"Titanias Auge",
139 	"Titanias Auge",
140 	"Eine Papageienfeder",
141 	"Eine sch\xF6""ne fette saftige Zitrone",
142 	"Ein leeres Bierglas",
143 	"Ein Starenp\xFC""ree enthaltendes Bierglas",
144 	"Ein Tomatenso\xDF""e enthaltendes Bierglas",
145 	"Ein Senfso\xDF""e enthaltendes Bierglas",
146 	"Ein Hammer",
147 	"Ein Schlauch",
148 	"Das andere Ende eines Schlauchs",
149 	"Der Kopf eines LiftBots",
150 	"Ein ziemlich langer Stab",
151 	"Ein Magazin",
152 	"Titanias Mund",
153 	"Ein Schl\xFC""ssel",
154 	"Eine supersaugf\xE4""hige Serviette",
155 	"Titanias Nase",
156 	"Eine Vogelstange",
157 	"Ein Grammophonzylinder",
158 	"Ein Grammophonzylinder",
159 	"Ein Grammophonzylinder",
160 	"Ein Grammophonzylinder",
161 	"Ein Foto"
162 };
163 
164 static const char *const ITEM_IDS[40] = {
165 	"MaitreD Left Arm", "MaitreD Right Arm", "OlfactoryCentre", "AuditoryCentre",
166 	"SpeechCentre", "VisionCentre", "CentralCore", "Perch", "SeasonBridge",
167 	"FanBridge", "BeamBridge", "ChickenBridge", "CarryParrot", "Chicken",
168 	"CrushedTV", "Feathers", "Lemon", "BeerGlass", "BigHammer", "Ear1", "Ear 2",
169 	"Eye1", "Eye2", "Mouth", "Nose", "NoseSpare", "Hose", "DeadHoseSpare",
170 	"HoseEnd", "DeadHoseEndSpare", "BrokenLiftbotHead", "LongStick", "Magazine",
171 	"Napkin", "Phonograph Cylinder", "Phonograph Cylinder 1", "Phonograph Cylinder 2",
172 	"Phonograph Cylinder 3", "Photograph", "Music System Key"
173 };
174 
175 static const char *const ROOM_NAMES[34] = {
176 	"1stClassLobby", "1stClassRestaurant", "1stClassState",
177 	"2ndClassLobby", "secClassState", "Arboretum", "FrozenArboretum",
178 	"Bar", "BilgeRoom", "BilgeRoomWith", "BottomOfWell", "Bridge",
179 	"CreatorsChamber", "CreatorsChamberOn", "Dome", "Home", "Lift",
180 	"EmbLobby", "MoonEmbLobby", "MusicRoomLobby", "MusicRoom",
181 	"ParrotLobby", "Pellerator", "PromenadeDeck", "SculptureChamber",
182 	"SecClassLittleLift", "ServiceElevator", "SGTLeisure", "SGTLittleLift",
183 	"SgtLobby", "SGTState", "Titania", "TopOfWell", "PlayersRoom"
184 };
185 
186 struct NumberEntry {
187 	const char *_text;
188 	int _value;
189 	uint _flags;
190 };
191 
192 const NumberEntry NUMBERS[76] = {
193 	{ "a", 1, 3 },
194 	{ "and", 0, 1 },
195 	{ "negative", 0, 10 },
196 	{ "minus", 0, 10 },
197 	{ "below zero", 0, 8 },
198 	{ "degrees below zero", 0, 8 },
199 	{ "nil", 0, 2 },
200 	{ "zero", 0, 2 },
201 	{ "one", 1, 0x12 },
202 	{ "two", 2, 0x12 },
203 	{ "three", 3, 0x12 },
204 	{ "four", 4, 0x12 },
205 	{ "five", 5, 0x12 },
206 	{ "six", 6, 0x12 },
207 	{ "seven", 7, 0x12 },
208 	{ "eight", 8, 0x12 },
209 	{ "nine", 9, 0x12 },
210 	{ "0", 0, 2 },
211 	{ "1", 1, 2 },
212 	{ "2", 2, 2 },
213 	{ "3", 3, 2 },
214 	{ "4", 4, 2 },
215 	{ "5", 5, 2 },
216 	{ "6", 6, 2 },
217 	{ "7", 7, 2 },
218 	{ "8", 8, 2 },
219 	{ "9", 9, 2 },
220 	{ "first", 1, 2 },
221 	{ "second", 2, 2 },
222 	{ "third", 3, 2 },
223 	{ "fourth", 4, 2 },
224 	{ "fifth", 5, 2 },
225 	{ "sixth", 6, 2 },
226 	{ "seventh", 7, 2 },
227 	{ "eighth", 8, 2 },
228 	{ "ninth", 9, 2 },
229 	{ "ten", 10, 2 },
230 	{ "eleven", 11, 2 },
231 	{ "twelve", 12, 2 },
232 	{ "thirteen", 13, 2 },
233 	{ "fourteen", 14, 2 },
234 	{ "fifteen", 15, 2 },
235 	{ "sixteen", 16, 2 },
236 	{ "seventeen", 17, 2 },
237 	{ "eighteen", 18, 2 },
238 	{ "nineteen", 19, 2 },
239 	{ "tenth", 10, 2 },
240 	{ "eleventh", 11, 2 },
241 	{ "twelfth", 12, 2 },
242 	{ "thirteenth", 13, 2 },
243 	{ "fourteenth", 14, 2 },
244 	{ "fifteenth", 15, 2 },
245 	{ "sixteenth", 16, 2 },
246 	{ "seventeenth", 17, 2 },
247 	{ "eighteenth", 18, 2 },
248 	{ "nineteenth", 19, 2 },
249 	{ "twenty", 20, 0x12 },
250 	{ "thirty", 30, 0x12 },
251 	{ "forty", 40, 0x12 },
252 	{ "fourty", 40, 0x12 },
253 	{ "fifty", 50, 0x12 },
254 	{ "sixty", 60, 0x12 },
255 	{ "seventy", 70, 0x12 },
256 	{ "eighty", 80, 0x12 },
257 	{ "ninety", 90, 0x12 },
258 	{ "twentieth", 20, 2 },
259 	{ "thirtieth", 30, 2 },
260 	{ "fortieth", 40, 2 },
261 	{ "fiftieth", 50, 2 },
262 	{ "sixtieth", 60, 2 },
263 	{ "seventieth", 70, 2 },
264 	{ "eightieth", 80, 2 },
265 	{ "ninetieth", 90, 2 },
266 	{ "hundred", 100, 4 },
267 	{ "hundredth", 100, 6 }
268 };
269 
270 struct CommonPhrase {
271 	const char *_str;
272 	uint _dialogueId;
273 	uint _roomNum;
274 	uint _val1;
275 };
276 
277 static const CommonPhrase BELLBOT_COMMON_PHRASES_EN[] = {
278 	{ "what is wrong with her", 0x30FF9, 0x7B, 0 },
279 	{ "what is wrong with titania", 0x30FF9, 0x7B, 0 },
280 	{ "something for the weekend", 0x30D8B, 0x00, 0 },
281 	{ "other food", 0x30E1D, 0x00, 3 },
282 	{ "different food", 0x30E1D, 0x00, 3 },
283 	{ "alternative food", 0x30E1D, 0x00, 3 },
284 	{ "decent food", 0x30E1D, 0x00, 3 },
285 	{ "nice food", 0x30E1D, 0x00, 3 },
286 	{ "nicer food", 0x30E1D, 0x00, 3 },
287 	{ "make me happy", 0x31011, 0x00, 0 },
288 	{ "cheer me up", 0x31011, 0x00, 0 },
289 	{ "help me if im unhappy", 0x31011, 0x00, 0 },
290 	{ "i obtain a better room", 0x30E8A, 0x00, 3 },
291 	{ "i obtain a better room", 0x30E8A, 0x00, 2 },
292 	{ "i get a better room", 0x30E8A, 0x00, 3 },
293 	{ "i get a better room", 0x30E8A, 0x00, 2 },
294 	{ "i want a better room", 0x30E8A, 0x00, 3 },
295 	{ "i want a better room", 0x30E8A, 0x00, 2 },
296 	{ "i understood", 0x30D75, 0x6D, 0 },
297 	{ "i knew", 0x30D75, 0x6D, 0 },
298 	{ "i know", 0x30D75, 0x6D, 0 },
299 	{ "not stupid", 0x30D75, 0x6D, 0 },
300 	{ "cheeky", 0x30D75, 0x6D, 0 },
301 	{ "not help", 0x30D6F, 0x6D, 0 },
302 	{ "not helpful", 0x30D6F, 0x6D, 0 },
303 	{ "dont help", 0x30D6F, 0x6D, 0 },
304 	{ "no help", 0x30D6F, 0x6D, 0 },
305 	{ "sorry", 0x30D76, 0x6D, 0 },
306 	{ "not mean that", 0x30D76, 0x6D, 0 },
307 	{ "didnt mean that", 0x30D76, 0x6D, 0 },
308 	{ "apologise", 0x30D76, 0x6D, 0 },
309 	{ "play golf", 0x313B6, 0x00, 0 },
310 	{ "is not the captain meant to go down with the ship", 0x31482, 0x00, 0 },
311 	{ "is not the captain supposed to go down with the ship", 0x31482, 0x00, 0 },
312 	{ "sauce sticks to the chicken", 0x3156B, 0x00, 0 },
313 	{ "sauce gets stuck to the chicken", 0x3156B, 0x00, 0 },
314 	{ nullptr, 0, 0, 0 }
315 };
316 static const CommonPhrase BELLBOT_COMMON_PHRASES_DE[] = {
317 	{ "was ist mit ihr los", 0x30ff9, 0x7b, 0 },
318 	{ "was fehlt ihr", 0x30ff9, 0x7b, 0 },
319 	{ "was hat sie denn", 0x30ff9, 0x7b, 0 },
320 	{ "was ist denn mit ihr", 0x30ff9, 0x7b, 0 },
321 	{ "was stimmt denn nicht mit ihr", 0x30ff9, 0x7b, 0 },
322 	{ "was ist mit titania los", 0x30ff9, 0x7b, 0 },
323 	{ "was fehlt titania", 0x30ff9, 0x7b, 0 },
324 	{ " was ist denn mit titania", 0x30ff9, 0x7b, 0 },
325 	{ "was ist denn mit titania los", 0x30ff9, 0x7b, 0 },
326 	{ "etwas anderes zu essen", 0x30e1d, 0, 3 },
327 	{ "noch zu essen", 0x30e1d, 0, 3 },
328 	{ "noch essen", 0x30e1d, 0, 3 },
329 	{ "anderes essen", 0x30e1d, 0, 3 },
330 	{ "etwas gutes zu essen", 0x30e1d, 0, 3 },
331 	{ "vernuenftiges essen", 0x30e1d, 0, 3 },
332 	{ "leckeres essen", 0x30e1d, 0, 3 },
333 	{ "lecker essen", 0x30e1d, 0, 3 },
334 	{ "besseres essen", 0x30e1d, 0, 3 },
335 	{ "gutes zu essen", 0x30e1d, 0, 3 },
336 	{ "aufheitern", 0x31011, 0, 0 },
337 	{ "heiter mich mal auf", 0x31011, 0, 0 },
338 	{ "kriege ich ein besseres zimmer", 0x30e8a, 0, 3 },
339 	{ "kriege ich ein besseres zimmer", 0x30e8a, 0, 2 },
340 	{ "kriege ich eine bessere kabine", 0x30e8a, 0, 3 },
341 	{ "kriege ich eine bessere kabine", 0x30e8a, 0, 2 },
342 	{ "komme ich an eine schoenere kabine", 0x30e8a, 0, 3 },
343 	{ "komme ich an eine schoenere kabine", 0x30e8a, 0, 2 },
344 	{ "kriege ich eine schoenere kabine", 0x30e8a, 0, 3 },
345 	{ "kriege ich eine schoenere kabine", 0x30e8a, 0, 2 },
346 	{ "bekomme ich eine schoenere kabine", 0x30e8a, 0, 3 },
347 	{ "bekomme ich eine schoenere kabine", 0x30e8a, 0, 2 },
348 	{ "komme ich an eine bessere kabine", 0x30e8a, 0, 3 },
349 	{ "komme ich an eine bessere kabine", 0x30e8a, 0, 2 },
350 	{ "ich verstehe", 0x30d75, 0x6d, 0 },
351 	{ "das wusste ich", 0x30d75, 0x6d, 0 },
352 	{ "wusste ich es doch", 0x30d75, 0x6d, 0 },
353 	{ "ich weiss", 0x30d75, 0x6d, 0 },
354 	{ "ich kenne", 0x30d75, 0x6d, 0 },
355 	{ "hilfst du nicht", 0x30d6f, 0x6d, 0 },
356 	{ "du hilfst nicht", 0x30d6f, 0x6d, 0 },
357 	{ "nicht hilfsbereit", 0x30d6f, 0x6d, 0 },
358 	{ "nicht freundlich", 0x30d6f, 0x6d, 0 },
359 	{ "nicht zuvorkommend", 0x30d6f, 0x6d, 0 },
360 	{ "hilfst nicht", 0x30d6f, 0x6d, 0 },
361 	{ "keine hilfe", 0x30d6f, 0x6d, 0 },
362 	{ "hilfst du mir nicht", 0x30d6f, 0x6d, 0 },
363 	{ "entschuldig", 0x30d76, 0x6d, 0 },
364 	{ "verzeihung", 0x30d76, 0x6d, 0 },
365 	{ "tut mir leid", 0x30d76, 0x6d, 0 },
366 	{ "tut mir aber leid", 0x30d76, 0x6d, 0 },
367 	{ "ich meinte es nicht so", 0x30d76, 0x6d, 0 },
368 	{ "wollte ich nicht sagen", 0x30d76, 0x6d, 0 },
369 	{ "nicht so gemeint", 0x30d76, 0x6d, 0 },
370 	{ "nichts fuer ungut", 0x30d76, 0x6d, 0 },
371 	{ "spielst du golf", 0x313b6, 0, 0 },
372 	{ "golf spielen", 0x313b6, 0, 0 },
373 	{ "spiele golf", 0x313b6, 0, 0 },
374 	{ "sosse klebt am huhn fest", 0x3156b, 0, 0 },
375 	{ "die sosse nicht von dem huehnchen los", 0x3156b, 0, 0 },
376 	{ nullptr, 0, 0, 0 }
377 };
378 
379 struct FrameRange {
380 	int _startFrame;
381 	int _endFrame;
382 };
383 
384 static const FrameRange BARBOT_FRAME_RANGES[60] = {
385 	{ 558, 585 }, { 659, 692 }, { 802, 816 }, { 1941, 1977 }, { 1901, 1941 },
386 	{ 810, 816 }, { 857, 865}, { 842, 857 }, { 821, 842 }, { 682, 692 },
387 	{ 1977, 2018 }, { 2140, 2170 }, { 2101, 2139 }, { 2018, 2099}, { 1902, 2015 },
388 	{ 1811, 1901 }, { 1751, 1810 }, { 1703, 1750 }, { 1681, 1702 }, { 1642, 1702 },
389 	{ 1571, 1641 }, { 1499, 1570 }, { 1403, 1463 }, { 1464, 1499 }, { 1288, 1295 },
390 	{ 1266, 1287 }, { 1245, 1265 }, { 1208, 1244 }, { 1171, 1207 }, { 1120, 1170 },
391 	{ 1092, 1120 }, { 1092, 1092 }, { 1044, 1091 }, { 1011, 1043 }, { 1001, 1010 },
392 	{ 985, 1001 }, { 927, 984 }, { 912, 926 }, { 898, 906 }, { 802, 896 },
393 	{ 865, 896 }, { 842, 865 }, { 816, 842 }, { 802, 842 }, { 740, 801 },
394 	{ 692, 740 }, { 610, 692 }, { 558, 610 }, { 500, 558 }, { 467, 500 },
395 	{ 421, 466 }, { 349, 420 }, { 306, 348 }, { 305, 306 }, { 281, 305 },
396 	{ 202, 281 }, { 182, 202 }, { 165, 182 }, { 96, 165 }, { 0, 95 }
397 };
398 
399 static const char *const MISSIVEOMAT_MESSAGES[3] = {
400 	"Welcome, Leovinus.\n"
401 	"\n"
402 	"This is your Missive-O-Mat.\n"
403 	"\n"
404 	"You have received 1827 Electric Missives.\n"
405 	"\n"
406 	"For your convenience I have deleted:\n"
407 	" 453 things that people you don't know thought it would be "
408 	"terribly witty to forward to you,\n"
409 	" 63 Missives containing double or triple exclamation marks,\n"
410 	" 846 Missives from mailing-lists you once thought might be quite "
411 	"interesting and now can't figure out how to cancel,\n"
412 	" 962 Chain Missives,\n"
413 	" 1034 instructions on how to become a millionaire using butter,\n"
414 	" 3 Yassaccan Death Threats (slightly down on last week which is"
415 	" pleasing news),\n"
416 	" and a Missive from your Mother which I have answered reassuringly.\n"
417 	"\n"
418 	"I have selected the following Missives for your particular attention. "
419 	"You will not need to run Fib-Finder to see why.  Something Is Up and I "
420 	"suspect those two slippery urchins Brobostigon and Scraliontis are behind it.",
421 
422 	"Hello Droot.  I have evaluated your recent missives.\n"
423 	"Contents break down as follows:\n"
424 	"\n"
425 	"Good news 49%\n"
426 	"Bad news 48%\n"
427 	"Indifferent news 4%\n"
428 	"Petty mailings and Family Missives 5%\n"
429 	"Special Offers from the Blerontin Sand Society 1% (note - there's"
430 	" a rather pretty dune for hire on p4)\n"
431 	"\n"
432 	"In general terms you Thrive.  You continue to Prosper.   Your shares are"
433 	" Secure.  Your hair, as always, looks Good.  Carpet 14 needs cleaning.  \n"
434 	"\n"
435 	"I am pleased to report there have been no further comments about "
436 	"foot odor.\n"
437 	"\n"
438 	"Recommend urgently you sell all fish paste shares as Market jittery.\n"
439 	"\n"
440 	"As your Great Scheme nears completion I have taken the liberty of"
441 	" replying to all non-urgent Missives and list below only communic"
442 	"ations with Manager Brobostigon and His Pain in the Ass Loftiness"
443 	" Leovinus.  \n"
444 	"\n"
445 	"Beware - Leovinus grows suspicious.  Don't take your eye off B"
446 	"robostigon.  \n"
447 	"\n"
448 	"Weather for the Launch tomorrow is bright and sunny.  Hazy clouds"
449 	" will be turned on at eleven.  I suggest the red suit with the st"
450 	"reamers.\n"
451 	"\n"
452 	"All money transfers will be completed through alias accounts by m"
453 	"oonsup.\n"
454 	"\n"
455 	"Eat well.  Your fish levels are down and you may suffer indecisio"
456 	"n flutters mid-morning.\n"
457 	"\n"
458 	"Here are your Missives...",
459 
460 	"Hello Antar, this is your Missive-o-Mat.\n"
461 	"Not that you need reminding but today is the Glorious Dawning of "
462 	"a New Age in Luxury Space Travel.\n"
463 	"\n"
464 	"Generally my assessment of your position this morning is that you"
465 	" are well, albeit not as rich as you would like to be.  I hope yo"
466 	"ur interesting collaboration with Mr Scraliontis will soon bear f"
467 	"ruit. \n"
468 	"\n"
469 	"I trust your flatulence has eased during the night.  Such a distr"
470 	"essing condition for a man in your position.\n"
471 	"\n"
472 	"Most of your Missives are routine construction matters which I ha"
473 	"ve dealt with and deleted.  All Missives from Mr Scraliontis and "
474 	"His Loftiness Leovinus are here."
475 };
476 
477 static const char *const MISSIVEOMAT_MESSAGES_DE[3] = {
478 	"Willkommen, Leovinus.\n"
479 	"\n"
480 	"Dies ist Ihr Depesch-O-Mat.\n"
481 	"\n"
482 	"Sie haben 1827 Elektrische Depeschen erhalten.\n"
483 	"\n"
484 	"Aus praktischen Gr\xFC""nden habe ich 453 Nachrichten von Leuten, "
485 	"die Sie nicht kennen und die dachten, es w\xE4""re unheimlich geistreich, "
486 	"sie an Sie weiterzusenden, gel\xF6""scht, darunter 63 Depeschen mit "
487 	"doppelten oder dreifachen Ausrufezeichen,\n"
488 	"846 Depeschen von Mailing-Listen, die Sie einmal f\xFC"
489 	"r sehr interessant hielten, und von denen Sie jetzt keine Ahnung haben, "
490 	"wie man sie l\xF6""schen kann, \n"
491 	"962 Kettendepeschen,\n"
492 	"1034 Anweisungen, wie man durch den Einsatz von Butter zum Million\xE4""r wird,\n"
493 	"3 Yassakkanische Morddrohungen (diese Zahl ist im Vergleich zur Vorwoche leicht "
494 	"gesunken, was durchaus erfreulich ist), \n"
495 	"und eine Depesche von Ihrer Mutter, die ich mit beruhigenden Worten beantwortet habe.\n"
496 	"\n"
497 	"Auf folgende Depeschen m\xF6""chte ich Ihre besondere Aufmerksamkeit lenken. "
498 	"Sie brauchen den Flunker-Finder nicht zu aktivieren um zu sehen, warum. "
499 	"Irgend etwas ist faul, und ich habe den Verdacht, da\xDF"" die beiden schleimigen "
500 	"Quallen Brobostigon und Scraliontis wieder dahinter stecken.",
501 
502 	"Hallo Droot.  Ich habe Ihre letzten Depeschen ausgewertet.\n"
503 	"Der Inhalt gliedert sich wie folgt:\n"
504 	"\n"
505 	"Gute Nachrichten 49%\n"
506 	"Schlechte Nachrichten 48%\n"
507 	"Mittelm\xE4\xDF""ige Nachrichten 4%\n"
508 	"Belanglose Mailings und Familiendepeschen 5%\n"
509 	"Sonderangebote der Blerontinischen Sand Gesellschaft 1% "
510 	"(beachtenswert: die ziemlich h\xFC""bsche Miet-D\xFC""ne auf Seite 4)\n"
511 	"\n"
512 	"Insgesamt gesehen sind Sie \xE4""u\xDF""erst Erfolgreich.  Die Gesch\xE4""fte "
513 	"Florieren weiterhin.  Ihre Aktien sind in Sicherheit. Ihr Haar "
514 	"sieht wie immer Toll aus. Teppich 14 mu\xDF"" gereinigt werden.\n"
515 	"\n"
516 	"Es freut mich, berichten zu d\xFC""rfen, da\xDF"" keine weiteren "
517 	"Kommentare zu Schwei\xDF""f\xFC\xDF""en gemeldet wurden.\n"
518 	"\n"
519 	"Empfehle dringend, alle Fischpaste-Aktien zu verkaufen, da Marktschwankungen.\n"
520 	"\n"
521 	"Da Ihr Gro\xDF""er Plan beinahe vollendet ist, war ich so frei, alle "
522 	"nicht dringenden Depeschen zu beantworten und f\xFC""hre hierauffolgend nur "
523 	"die Korrespondenz mit Manager Brobostigon und Ihrer Durchlauchtigsten Gro\xDF""kotz "
524 	"Nervens\xE4""ge Leovinus auf.\n"
525 	"\n"
526 	"Achtung: Leovinus sch\xF6""pft langsam Verdacht.  Lassen Sie auch Brobostigon "
527 	"nicht aus den Augen.\n"
528 	"\n"
529 	"F\xFC""r den morgigen Stapellauf ist das Wetter heiter und sonnig.  "
530 	"Um elf Uhr wird leichte Bew\xF6""lkung eingeschaltet. Ich schlage "
531 	"den roten Anzug mit der Sch\xE4""rpe vor.\n"
532 	"\n"
533 	"Alle Geld\xFC""berweisungen werden \xFC""ber Decknamenkonten vor Mondaufgang get\xE4""tigt.\n"
534 	"\n"
535 	"Achten Sie auf eine ausgewogene Ern\xE4""hrung.  Ihr Fischstand ist niedrig und Sie k\xF6"
536 	"nnten am sp\xE4""ten Vormittag unter Entscheidungsschwankungen leiden.\n"
537 	"\n"
538 	"Hier sind Ihre Depeschen...",
539 
540 	"Hallo Antar, dies ist Ihr Depesch-O-Mat.\n"
541 	"\n"
542 	"Nicht, da\xDF"" Sie daran noch erinnert werden m\xFC"
543 	"ssen, aber heute ist die Glorreiche D\xE4""mmerung eines Neuen Zeitalters "
544 	"in der Luxusraumfahrt. \n"
545 	"\n"
546 	"Im Allgemeinen zeigt meine Bewertung Ihrer Verfassung an diesem Morgen, "
547 	"da\xDF"" Sie wohlauf sind, wenn auch nicht so reich, wie Sie es gerne w\xE4""ren.  "
548 	"Ich hoffe, die interessante Zusammenarbeit mit Herrn Scraliontis wird bald "
549 	"Fr\xFC""chte tragen. \n"
550 	"\n"
551 	"Ich hoffe, Ihre Bl\xE4""hungen haben in der Nacht etwas nachgelassen.  "
552 	"Was f\xFC""r ein betr\xFC""bliches Leiden f\xFC""r  "
553 	"einen Mann in Ihrer Position.\n"
554 	"\n"
555 	"Bei den meisten eingegangenen Depeschen handelt es sich um routinem\xE4\xDF"
556 	"ige Bauangelegenheiten, die ich bearbeitet und dann gel\xF6""scht "
557 	"habe.  Alle Depeschen von Herrn Scraliontis und Ihrer Durchlauchtigen "
558 	"Aufgeblasenheit Leovinus folgen."
559 };
560 
561 struct BedheadEntry {
562 	const char *_name1;
563 	const char *_name2;
564 	const char *_name3;
565 	const char *_name4;
566 	int _startFrame;
567 	int _endFrame;
568 };
569 
570 static const BedheadEntry ON_CLOSED[4] = {
571 	{ "Closed", "Closed", "Open", "Open", 0, 12 },
572 	{ "Open", "Any", "Any", "RestingUTV", 0, 4 },
573 	{ "Closed", "Open", "Any", "RestingV", 0, 6 },
574 	{ "Closed", "Closed", "Closed", "RestingG", 0, 21 }
575 };
576 static const BedheadEntry ON_RESTING_TV[2] = {
577 	{ "Any", "Closed", "Open", "Open", 6, 12 },
578 	{ "Any", "Closed", "Closed", "RestingG", 6, 21 }
579 };
580 static const BedheadEntry ON_RESTING_UV[2] = {
581 	{ "Any", "Any", "Open", "Open", 8, 12 },
582 	{ "Any", "Any", "Closed", "RestingG", 8, 21 }
583 };
584 static const BedheadEntry ON_CLOSED_WRONG[2] = {
585 	{ "Any", "Any", "Closed", "OpenWrong", 42, 56 },
586 	{ "Any", "Any", "Open", "RestingDWrong", 42, 52 }
587 };
588 
589 static const BedheadEntry OFF_OPEN[3] = {
590 	{ "Closed", "Closed", "Open", "Closed", 27, 41 },
591 	{ "Any", "Open", "Any", "RestingUV", 27, 29 },
592 	{ "Open", "Closed", "Any", "RestingTV", 27, 33 }
593 };
594 static const BedheadEntry OFF_RESTING_UTV[1] = {
595 	{ "Any", "Any", "Any", "Closed", 36, 41 }
596 };
597 static const BedheadEntry OFF_RESTING_V[1] = {
598 	{ "Closed", "Any", "Any", "Closed", 32, 41 }
599 };
600 static const BedheadEntry OFF_RESTING_G[3] = {
601 	{ "Closed", "Closed", "Closed", "Closed", 21, 41 },
602 	{ "Any", "Open", "Closed", "RestingUV", 21, 29 },
603 	{ "Open", "Closed", "Closed", "RestingTV", 21, 33 }
604 };
605 static const BedheadEntry OFF_OPEN_WRONG[1] = {
606 	{ "Any", "Any", "Any", "ClosedWrong", 56, 70 }
607 };
608 static const BedheadEntry OFF_RESTING_D_WRONG[1] = {
609 	{ "Any", "Any", "Any", "ClosedWrong", 59, 70 }
610 };
611 
612 static const char *const STRINGS_EN[156] = {
613 	"",
614 	"You are standing outside the Pellerator.",
615 	"I'm sorry, you cannot enter this pellerator at present as a bot is in the way.",
616 	"I'm sorry, you cannot enter this pellerator at present as it's frozen shut",
617 	"The Succ-U-Bus is in Standby, or \"Off\" mode at present.",
618 	"There is currently nothing to deliver.",
619 	"There is currently nothing in the tray to send.",
620 	"The Succ-U-Bus is a Single Entity Delivery Device.",
621 	"Chickens are allocated on a one-per-customer basis.",
622 	"Only one piece of chicken per passenger. Thank you.",
623 	"You have been upgraded to 1st Class status. Enjoy hugely.",
624 	"You have been upgraded to 2nd Class status. Enjoy.",
625 	"This room is reserved for the exclusive use of first class passengers."
626 	" That does not currently include you",
627 	"No losers.",
628 	"Passengers of your class are not permitted to enter this area.",
629 	"Please exit from the other side.",
630 	"For mysterious and unknowable reasons, this transport is temporarily out of order.",
631 	"Unfortunately this fan controller has blown a fuse.",
632 	"In case of emergency hammer requirement, poke with long stick.",
633 	"This stick is too short to reach the branches.",
634 	"You are standing outside Elevator %d",
635 	"I'm sorry, you cannot enter this elevator at present as a bot is in the way.",
636 	"This elevator is currently in an advanced state of non-functionality.",
637 	"That light appears to be loose.",
638 	"Lumi-Glow(tm) Lights.  They glow in the dark!",
639 	"You already have one.",
640 	"This glass is totally and utterly unbreakable.",
641 	"For emergency long stick, smash glass.",
642 	"This dispenser has suddenly been fitted with unbreakable glass "
643 	"to prevent unseemly hoarding of sticks.",
644 	"The Chicken is already quite clean enough, thank you.",
645 	"Now would be an excellent opportunity to adjust your viewing apparatus.",
646 	"You cannot take this because the cage is locked shut.",
647 	"You are already at your chosen destination.",
648 	"Passengers of your class are not permitted to enter this area.",
649 	"Sorry, you must be at least 3rd class before you can summon for help.",
650 	"You have not assigned a room to go to.",
651 	"Sorry, this elevator does not go below floor 27.",
652 	"You must select a game to load first.",
653 	"You must select a game to save first.",
654 	"Please supply Galactic reference material.",
655 	"This is the restaurant music system.  It appears to be locked.",
656 	"You can't pick this up on account of it being stuck to the branch.",
657 	"You cannot get this, it is frozen to the branch.",
658 	"Please check in at the reception desk.",
659 	"This foodstuff is already sufficiently garnished.",
660 	"Sadly, this dispenser is currently empty.",
661 	"Please place food source beneath dispenser for sauce delivery.",
662 	"The Seasonal Adjustment switch is not operational at the present time.",
663 	"This is your stateroom. It is for sleeping. If you desire "
664 	"entertainment or relaxation, please visit your local leisure lounge.",
665 	"The bed will not currently support your weight."
666 	" We are working on this problem but are unlikely to be able to fix it.",
667 	"This is not your assigned room. Please do not enjoy.",
668 	"Sadly, this is out of your reach.",
669 	"The Succ-U-Bus is a Single Entity Delivery Device.",
670 	"Sadly, the Grand Canal transport system is closed for the winter.",
671 	"This area is off limits to passengers.",
672 	"Go where?",
673 	"It would be nice if you could take that but you can't.",
674 	"A bowl of pistachio nuts.",
675 	"Not a bowl of pistachio nuts.",
676 
677 	"Sadly, it is not possible to summon the DoorBot from this location.",
678 	"Sadly, it is not possible to summon the BellBot from this location.",
679 	"There is no one here to talk to",
680 	"Talking to ",
681 	"the DoorBot",
682 	"the DeskBot",
683 	"a LiftBot",
684 	"the Parrot",
685 	"the BarBot",
686 	"a ChatterBot",
687 	"the BellBot",
688 	"the Maitre d'Bot",
689 	"a Succ-U-Bus",
690 	"Unknown",
691 	"The arm is already holding something.",
692 	"You can't get this.",
693 	"That doesn't seem to do anything.",
694 	"It doesn't seem to want this.",
695 	"This does not reach.",
696 	"The chicken is already clean.",
697 	"Succ-U-Bus auxiliary hose attachment incompatible with sliding glass cover.",
698 	"This item is incorrectly calibrated.",
699 	"Only First Class passengers are allowed to use the Gondoliers.",
700 	"There is currently nothing available for your viewing pleasure on this channel.",
701 	"Television control",
702 	"Operate visual entertainment device",
703 	"Operate the lights",
704 	"Deploy floral enhancement",
705 	"Deploy fully recumbent relaxation device",
706 	"Deploy comfort workstation",
707 	"Deploy minor horizontally mobile storage compartment",
708 	"Deploy major semi-recumbent relaxation device",
709 	"Inflate fully recumbent relaxation device",
710 	"Deploy personal maintenance hub",
711 	"Deploy executive horizontal worksurface",
712 	"Deploy minor semi-recumbent relaxation device",
713 	"Deploy aqueous cleansing receptacle",
714 	"Deploy major horizontally mobile storage compartment",
715 	"Succ-U-Bus delivery system control",
716 	"Navigation controller",
717 	"Let Titania figure out where Earth is (skip puzzle)",
718 	"Summon Elevator",
719 	"Summon Pellerator",
720 	"Go to the Bottom of the Well",
721 	"Go to the Top of the Well",
722 	"Go to your stateroom",
723 	"Go to the Bar",
724 	"Go to the Promenade Deck",
725 	"Go to the Arboretum",
726 	"Go to the Music Room",
727 	"Go to the First Class Restaurant",
728 	"The Parrot Lobby",
729 	"The Creators' Chamber",
730 	"The Bridge",
731 	"The Bilge Room",
732 	"The Sculpture Chamber",
733 	"The Arboretum",
734 	"The Bottom of the Well",
735 	"The Promenade Deck",
736 	"The 1st class restaurant",
737 	"Titania's Room",
738 	"The Bar",
739 	"The Embarkation Lobby",
740 	"The Music Room",
741 	"Unknown Room",
742 	"The Service Elevator",
743 	"The Super Galactic Leisure Lounge",
744 	"The Elevator",
745 	"The Dome",
746 	"The Pellerator",
747 	"The Top of the Well",
748 	"Nowhere you're likely to want to go.",
749 	"1st class",
750 	"2nd class",
751 	"SGT class",
752 	"no class",
753 	"Your assigned room: ",
754 	"A previously assigned room: ",
755 	"Saved Chevron: ",
756 	"Current location: ",
757 	"Elevator %d",
758 	"Floor %d",
759 	"Room %d",
760 	" (shift-click edits)",
761 	"A hot",
762 	"A cold",
763 	"Load the game.",
764 	"Save the game.",
765 	"Empty",
766 	"Quit the game.",
767 	"Are you sure you want to quit?",
768 	"Change the volume settings",
769 	"Master volume",
770 	"Music volume",
771 	"Parrot volume",
772 	"Speech volume"
773 };
774 
775 static const char *const STRINGS_DE[202] = {
776 	"",
777 	"Sie befinden sich vor dem Pellerator.",
778 	"Wir bedauern, da ein Bot den Weg versperrt, ist Ihnen der "
779 		"Zutritt zum Pellerator Ihnen gegenwSrtig verwehrt.",
780 	"Wir bedauern, Zutritt zu diesem Pellerator ist nicht m\xF6"
781 		"glich, da die T\xFC" "r zugefroren ist.",
782 	"Der Sukk-U-Bus befindet sich gegenwSrtig im Standby-oder \"AUS\"-Betrieb.",
783 	"Zur Zeit gibt es nichts zuzustellen.",
784 	"Gegenw\xE4rtig befindet sich nichts im Ablagekorb.",
785 	"Der Sukk-U-Bus ist ein Einzel-St\xFC" "ck-Liefergerst.",
786 	"Nur ein H\xFChnchen pro Passagier. Wir bedanken uns f\xFC"
787 		"r Ihr Verst\xE4ndnis.",
788 	"H\xFChner werden nur in Eine-Einheit-Pro-Person-Rationen zugeteilt.",
789 	"Sie sind in die Erste Klasse h\xF6hergestuft worden. Genie\xDF"
790 		"en Sie es in vollen Z\xFCgen.",
791 	"Sie sind in die Zweite Klasse h\xF6hergestuft worden. Genie\xDF"
792 		"en Sie es.",
793 	"Diese Kabine ist ausschlie\xDFlich f\xFCr Erste-Klasse-Passagiere "
794 		"reserviert worden. Zur Zeit schlie\xDFt das Sie nicht ein.",
795 	"Bitte keine Versager.",
796 	"Passagieren Ihrer Klasse ist der Zugang zu diesem Bereich nicht gestattet.",
797 	"Benutzen Sie bitte den Ausgang auf der anderen Seite.",
798 	"Aus mysteri\xF6sen, v\xF6llig unbekannten Gr\xFCnden ist dieses "
799 		"Transportmittel vor\xFC" "bergehend au\xDF" "er Betrieb.",
800 	"Leider ist diesem Ventilatorschalter eine Sicherung durchgebrannt.",
801 	"Im Falle eines dringenden Hammerbed\xFCrfnisses, bedienen Sie sich eines Stabs.",
802 	"Dieser Stab ist zu kurz um die Aste zu erreichen.",
803 	"Sie befinden sich vor dem Aufzug %d",
804 	"Wir bedauern, da ein Bot den Weg versperrt, ist Ihnen der Zutritt "
805 		"zu diesem Aufzug gegenwSrtig verwehrt.",
806 	"Dieser Aufzug ist gegenwSrtig im fortgeschrittenen Zustand des "
807 		"Nicht-Funktionierens.",
808 	"Die Lampe scheint irgendwie los zu sein.",
809 	"Lumina Leuchten. Sie leuchten im Dunkeln!",
810 	"Sie haben doch schon eins.",
811 	"Dieses Glas ist ganz und gar unzerbrechlich.",
812 	"Im Falle von dringend ben\xF6tigtem Langen Stab, zertr\xFCmmern Sie das Glas.",
813 	"Dieser Automat ist v\xF6llig unerwartet mit unzerbrechlichem Glas "
814 		"ausgestattet worden um ungeb\xFC hrlichem Horten von "
815 		"St\xF6" "cken vorzubeugen.",
816 	"Das H\xFChnchen ist eigentlich schon sauber genug, danke vielmals.",
817 	"Jetzt wSre der ideale Zeitpunkt, Ihre Sehhilfe zur Hand zu nehmen.",
818 	"Dieses Objekt k\xF6nnen Sie nicht mitnehmen, da die T\xFCr fest verschlossen ist.",
819 	"Sie befinden sich bereits an Ihrem gew\xFCnschten Reiseziel.",
820 	"Passagieren Ihrer Klasse ist der Zugang zu diesem Bereich nicht gestattet.",
821 	"Wir bedauern, aber Sie m\xFCssen mindestens Dritte Klasse sein "
822 		"bevor Sie um Hilfe bitten k\xF6nnen.",
823 	"Ihnen wurde keine Kabine zugeteilt.",
824 	"Wir bedauern, aber dieser Aufzug geht nicht tiefer als bis in den 27. Stock.",
825 	"Sie m\xFCssen zuerst das Spiel selektieren, das Sie laden m\xF6" "chten.",
826 	"Sie m\xFCssen zuerst das Spiel selektieren, das Sie speichern m\xF6" "chten.",
827 	"Stellen Sie bitte das Galaktische Referenzmaterial zur Verf\xFCgung.",
828 	"Dies ist das Musiksystem des Restaurants. Scheinbar ist es verschlossen.",
829 	" Aufgrund der Tatsache, da\xDF dieses Objekt an einem Ast festhSngt, "
830 		"k\xF6nnen Sie es nicht entfernen.",
831 	"Sie k\xF6nnen dieses Objekt nicht entfernen, es ist am Ast festgefroren.",
832 	"Melden Sie sich bitte an der Rezeption an.",
833 	"Dieses Nahrungsmittel ist bereits ausreichend garniert.",
834 	"Leider ist dieser Automat gegenwSrtig leer.",
835 	"Bei So\xAF" "enbedarf positionieren Sie bitte die Nahrungsquelle direkt "
836 		"unter den Automaten.",
837 	"Der Jahreszeitenschalter befindet sich zur Zeit au\xDF" "er Betrieb.",
838 	"Dies ist Ihre Kabine. Sie dient zum Schlafen. Wenn Sie Unterhaltung "
839 		"oder Entspannung w\xFCnschen, statten Sie bitte Ihrem "
840 		"nSchstgelegenen Salon einen Besuch ab.",
841 	"Das Bett ist Ihrem Gewicht momentan nicht gewachsen. Wir geben "
842 		"uns gro\xDF" "e M\xFChe, aber es ist unwahrscheinlich, "
843 		"da\xDF wir das Problem beheben k\xF6nnen.",
844 	"Dies ist nicht die Ihnen zugeteilte Kabine. Genie\xDF" "en Sie den "
845 		"Aufenthalt bitte nicht.",
846 	"Leider ist dies f\xFCr Sie au\xDF" "er Reichweite.",
847 	"Der Sukk-U-Bus ist ein Einzel-St\xFC" "ck-Lieferger\xE4t.",
848 	"Leider ist das Gro\xAF" "e-Kanal-Bef\xF6rderungssystem im Winter geschlossen.",
849 	"Passagieren ist der Zutritt zu diesem Bereich nicht gestattet.",
850 	"Wohin m\xF6" "chten Sie gehen?",
851 	"Es wSre zwar ganz nett, wenn Sie das mitnehmen k\xF6nnten, "
852 		"aber das k\xF6nnen Sie eben nicht.",
853 	"Eine Schale Pistazien.",
854 	"Keine Schale Pistazien.",
855 
856 	"Leider ist es nicht m\xF6""glich den T\xFC""r-Bot von diesem Ort aus herbeizurufen.",
857 	"Leider ist es nicht m\xF6""glich den Klingel-Bot von diesem Ort aus herbeizurufen.",
858 	"Es ist niemand hier mit dem du sprechen k\xF6""nntest",
859 	"Im Gespr\xE4""ch mit ",
860 	"der T\xFC""r-Bot",
861 	"der Empfangs-Bot",
862 	"der Aufzugs-Bot",
863 	"der Papagei",
864 	"der Bar-Bot",
865 	"ein Quassel-Bot",
866 	"der Klingel-Bot",
867 	"der Chef-Bot",
868 	"ein Sukk-U-Bus",
869 	"Unbekannt",
870 	"Der Arm h\xE4""lt bereits etwas.",
871 	"Das kannst du nicht bekommen.",
872 	"Das scheint nichts zu tun.",
873 	"Es scheint das nicht zu wollen.",
874 	"Das erreicht es nicht.",
875 	"Das H\xFC""hnchen ist bereits sauber.",
876 	"Sukk-U-Bus Hilfsschlauch-Aufsatz nicht kompatibel mit gl\xE4""serner Schiebeabdeckung.",
877 	"Der Gegenstand ist falsch kalibriert.",
878 	"Nur Passagiere erster Klasse ist es erlaubt den Gondoliere zu benutzen.",
879 	"Zurzeit kommt auf diesem Kanal nichts sehenswertes.",
880 	"Fernbedienung",
881 	"Bediene visuelles Unterhaltungssystem",
882 	"Bediene die Lichter",
883 	"Setze florale Verbesserung ein",
884 	"Stelle vollkommend-liegendes Entspannungsger\xE4""t bereit",
885 	"Stelle Wohlf\xFC""hl-Arbeitsplatz bereit",
886 	"Stelle kleineres horizontal bewegliches Abstellfach bereit",
887 	"Stelle gr\xF6""\xDF""eres halbliegendes Entspannungsger\xE4""t bereit",
888 	"Pumpe vollkommend-liegendes Entspannungsger\xE4""t auf",
889 	"Stelle pers\xF6""nliche Instandsetzungsstation bereit",
890 	"Stelle horizontale F\xFC""hrungskrafts-Arbeitsfl\xE4""che bereit",
891 	"Stelle kleineres halbliegendes Entspannungsger\xE4""t bereit",
892 	"Stelle mit Wasser reinigendes Beh\xE4""ltnis bereit",
893 	"Stelle gr\xF6""\xDF""eres horizontal tragbares Abstellfach bereit",
894 	"Sukk-U-Bus Zustell-Kontrollsystem",
895 	"Navigations-Kontroller",
896 	"Lass Titania herausbekommen wo die Erde ist (\xFC""berspringe Puzzle)",
897 	"Rufe Aufzug",
898 	"Rufe Pellerator",
899 	"Gehe zum Grund des Brunnens",
900 	"Gehe zur Oberfl\xE4""che des Brunnens",
901 	"Gehe zu deiner Kabine",
902 	"Gehe zur Bar",
903 	"Gehe zum Promenadendeck",
904 	"Gehe zum Baumgarten",
905 	"Gehe zum Musikzimmer",
906 	"Gehe zum First-Class-Restaurant",
907 	"Die Papagei-Lobby",
908 	"Das Zimmer des Erschaffers",
909 	"Die Br\xFC""cke",
910 	"Der Kielraum",
911 	"Das Skulpturenzimmer",
912 	"Der Baumgarten",
913 	"Der Grund des Brunnens",
914 	"Das Promenadendeck",
915 	"Das First-Class-Restaurant",
916 	"Titanias Zimmer",
917 	"Die Bar",
918 	"Die Empfangshalle",
919 	"Das Musikzimmer",
920 	"Unbekanntes Zimmer",
921 	"Der G\xFC""teraufzug",
922 	"Die Supergalaktische-Freizeitlounge",
923 	"Der Aufzug",
924 	"Die Kuppel",
925 	"Der Pellerator",
926 	"Die Oberfl\xE4""che des Brunnens",
927 	"Nirgends, wo du hingehen m\xF6""chtest.",
928 	"Erste Klasse",
929 	"Zweite Klasse",
930 	"SGT Klasse",
931 	"keine Klasse",
932 	"Dein zugewiesenes Zimmer: ",
933 	"Dein zuvor zugewiesenes Zimmer: ",
934 	"Gespeichertes Abzeichen: ",
935 	"Derzeitige Position: ",
936 	"Aufzug %d",
937 	"Stock %d",
938 	"Kabine %d",
939 	" (Chevrons ver\xE4" "ndern mit Umschalt-Taste+Klicken)",
940 	"Eine hei\xDF""e",
941 	"Eine kalte",
942 	"Laden Sie das Spiel.",
943 	"Speichern Sie das Spiel.",
944 	"Leer",
945 	"Beenden Sie das Spiel.",
946 	"Sind Sie sicher, da\xDF"" Sie das Spiel verlassen m\xF6""chten?",
947 	"\xC4""ndern der Lautst\xE4""rkeeinstellungen",
948 	"Grundlautst\xE4""rke",
949 	"Musiklautst\xE4""rke",
950 	"Papageienlautst\xE4""rke",
951 	"Sprachlautst\xE4""rke",
952 
953 	"Sommer",
954 	"Herbst",
955 	"Winter",
956 	"Fr\xFC" "nhling",
957 	"Sn'ood",
958 	"J'af'ah",
959 	"Bitta",
960 	"Fr\xAA" "ic",
961 	"Pflanzen bitte nicht ber\xFC" "nhren.",
962 	"!\xBC" "ta'\xAD" "ta! !T\xAA" "z n\xAA" " sappibundli t\xAA"
963 		"cn\xAA" "z!",
964 
965 	"Stop",
966 	"!Hanaz!",
967 	"VorwSrts",
968 	"!Panaz!",
969 	"T\xAA" "z k'b\xAA" "z",
970 	"Ein wenig herumkurven",
971 	"Otundo a\x92" " doom\xAA" "n n\x92" "sanza",
972 	"Sinnlose Drehung des Steuerrads",
973 	"!0xBC" "ta\x92\xAD" "ta!  T\xAA""z vidsta\x92" "jaha i\xAC"
974 		"in\x92" "qu\xAA" " m\xAA" "n\xAA" "z",
975 	"Sternenpanorama des Reiseziels hier einf\xFC" "ngen.",
976 
977 	"V'lo\xAC",
978 	"Geschwindigkeit",
979 	"Pan",
980 	"Ein",
981 	"Han",
982 	"Aus",
983 	"Turgo",
984 	"Langsam",
985 	"Pido",
986 	"Schnell",
987 
988 	"\xBC" "lu\xAD" " q\xB0 scu'b\xAA" "rri",
989 	"H\xFC" "hnchen a la sauce tomate",
990 	"\xBC" "lu\xAD" " q\xB0 scu'jajaja",
991 	"H0xFC" "hnchen a la sauce moutarde",
992 	"\xBC" "lu0xAD q\xB0 scu'\xAD" "lu\xAD",
993 	"H\xFC" "hnchen a la sauce 'Vogel'",
994 	"\xBC" "lu\xAD" " sanza scu, n\xAA n\xAA n\xAA",
995 	"H\xFC" "hnchen bar jeglicher sauce",
996 
997 	"!\xB2" "la! !\xB2" "la!  !!!Sizzlo ab\x92\xAA\xAA" "o s\xAA"
998 		"nza cr\xAA" "dibo!!!  N\xAA" "nto p\xAA" "rificio i\xAC" "ind\xAA",
999 	"Achtung, Lebensgefahr. Unglaublich hohe Voltzahl!!! Innen keine "
1000 		"artungsbed\xFC" "rftigen Teile vorhanden.",
1001 	"!!!Birin\xAC" "i sp\xAA" "culato t\xAA" "z n\xAA n\xAA n\xAA"
1002 		" ouvraditiniz!  J\x92" "in n\xAA n\xAA upraximus stifibilimus"
1003 		" j\x92" "in sigorto funct",
1004 	"Sie hStten die erste Kontrollt\xFC" "r nicht \xF6"
1005 		"ffnen sollen! Dies ist nicht nur ungeheuer gef\xE4"
1006 		"hrlich, Sie verlieren auch jegliche Garantie-Anspr\xFC" "che.",
1007 	"!T\xAA" "z n\xAA bleabaz t\xAA" "z n\xAA j\x92" "abaz!  Coco?",
1008 	"Und sagen Sie hinterher blo\xFC nicht, niemand hStte Sie gewarnt.",
1009 	"Pin\xAA" "z-pin\xAA" "z stot \xAF" "r\xB0 jibbli",
1010 	"Dr\xFC" "cken Sie den Knopf um die Bombe zu entschSrfen."
1011 };
1012 
1013 static const char *const MUSIC_DATA[4] = {
1014 	"64,^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|8,^^^^ 5:A///|64,/|/|/|/|/|/|/"
1015 	"|/|/|/|/|/|/|/|/|/|^|^|^|^|^|^|^|^|^|16, ^B//|64,/|/|/|/|^|16,^C/"
1016 	"/|64,/|/|/|/|",
1017 	"2:8,^^^^B//a|//g//B//|g///B//a|//g//A//|B//^C//b|//a//a//|BCb/b//"
1018 	"a|//g//A//|g/+f/D//c|//b//gA/|g/^^C//C|//C//a//|BCb////a|//g//g//"
1019 	"|g/g//B/a|/g//////|//^^B//a|//g//B//|g///B//a|//g//B//|g//^C//b|/"
1020 	"/a//a//|BCb/b//a|//g//B//|g/+f/D//c|//b//gA/|g/^^C//C|//C//a//|BC"
1021 	"b////a|//g//g//|g/g//B/a|/g//////|3:^^B//a//|g//A//g/|/^B//a//|g/"
1022 	"/A//B/|b^ 3:C//b//|a//g//+f/|+fG/G/GA/|B/a/g///|B///+f//G|G/G/+f/"
1023 	"G/|^^e//d//|c//b//gA|g/B//a//|g//g//g/|g//B/a/g|//////^^|^^Ga///G"
1024 	"|////////|////////|////////|",
1025 	"2:8,^^^^^^D/|/E//E//E|/d//^^d/|/E//E//E|/E//^^G/|/d//d//d|/^^^^^d"
1026 	"/|/E//E//E|/d/^^^E/|/E//d/+F/|bD^^^^G/|/e//e//e|^^^^^^d/|/E//E//E"
1027 	"|//d///d/|//b/////|^^^^^^D/|/E//E//E|/d//^^d/|/E//E//E|/E//^^G/|/"
1028 	"d//d//d|/^^^^^d/|/E//E//E|/d/^^^E/|/E//d/d/|d/^^^^G/|/e//e//e|^^^"
1029 	"^^^d/|/E//E//E|//d///d/|//b/////|3:D///c//b|//b//b//|D///c//b|//b"
1030 	"//g//|E///d//c|//b//a//|aB/B/BC/|D/c/b///|^^^D//DE|/E/E/d/d|//E/g"
1031 	"//g|//g//d//|^^^^g//E|//E//E//|d///d///|b///////|// 3:Db///C|///b"
1032 	"/// 5:A|64,/|/|/|/|/|/|/|/|",
1033 	"2:8,^^G//+f//|e//e//e/|//G//+f//|e//e//+F/|G/a//g//|+f//+f//+f/|/"
1034 	"/G//+F//|e//e//e/|//B//a//|g//e///d|//c//b//|a//a//a/|+f/G// 2:+F"
1035 	"//|e//e//C/|//b/g/+f/|//G/////|^^G//+f//|e//e//e/|//G//+f//|e//e/"
1036 	"/e/|//a//g//|+f//+f//+f/|//G//+F//|e//e//e/|//B//a//|g//e///d|/  "
1037 	"2:dC//b//|a//a//a/|+f/G//+F//|e//e//C/|//b/g/+f/|//G/////|d//d//d"
1038 	"/|/E//E//d|d//d//E/|/+F//G//b|a//a//a/|/D//D// 3:D|//g/g//D|/d/G/"
1039 	"///|^^b//b//|b//ba/B/|c//B//a/|/g//+f//+f|G//+F//e/|/c//C///|b/g/"
1040 	"+f///|G///////|G///////|C///////|////////|////////|"
1041 };
1042 
error(const char * s,...)1043 void NORETURN_PRE error(const char *s, ...) {
1044 	printf("%s\n", s);
1045 	exit(1);
1046 }
1047 
writeEntryHeader(const char * name,uint offset,uint size,uint flags)1048 void writeEntryHeader(const char *name, uint offset, uint size, uint flags) {
1049 	assert(headerOffset < HEADER_SIZE);
1050 	outputFile.seek(headerOffset);
1051 	outputFile.writeLong(offset);
1052 	outputFile.writeLong(size);
1053 	outputFile.writeWord(flags);
1054 	outputFile.writeString(name);
1055 
1056 	headerOffset += 10 + strlen(name) + 1;
1057 }
1058 
writeEntryHeader(const char * name,uint offset,uint size)1059 void writeEntryHeader(const char *name, uint offset, uint size) {
1060 	writeEntryHeader(name, offset, size, 0);
1061 }
1062 
writeEntryHeader(const char * name,uint offset,uint size,bool isCompressed)1063 void writeEntryHeader(const char *name, uint offset, uint size, bool isCompressed) {
1064 	uint flags = isCompressed ? 1 : 0;
1065 	writeEntryHeader(name, offset, size, flags);
1066 }
1067 
writeFinalEntryHeader()1068 void writeFinalEntryHeader() {
1069 	assert(headerOffset <= (HEADER_SIZE - 8));
1070 	outputFile.seek(headerOffset);
1071 	outputFile.writeLong(0);
1072 	outputFile.writeLong(0);
1073 }
1074 
writeCompressedRes(Common::File * src)1075 void writeCompressedRes(Common::File *src) {
1076 
1077 }
1078 
writeStringArray(const char * name,uint offset,int count)1079 void writeStringArray(const char *name, uint offset, int count) {
1080 	outputFile.seek(dataOffset);
1081 
1082 	inputFile.seek(offset - FILE_DIFF[_version]);
1083 	uint *offsets = new uint[count];
1084 	for (int idx = 0; idx < count; ++idx)
1085 		offsets[idx] = inputFile.readLong();
1086 
1087 	// Iterate through reading each string
1088 	for (int idx = 0; idx < count; ++idx) {
1089 		if (offsets[idx]) {
1090 			inputFile.seek(offsets[idx] - FILE_DIFF[_version]);
1091 			outputFile.writeString(inputFile);
1092 		} else {
1093 			outputFile.writeString("");
1094 		}
1095 	}
1096 
1097 	uint size = outputFile.size() - dataOffset;
1098 	writeEntryHeader(name, dataOffset, size);
1099 	dataOffset += size;
1100 
1101 	delete[] offsets;
1102 }
1103 
writeStringArray(const char * name,const char * const * strings,int count)1104 void writeStringArray(const char *name, const char *const *strings, int count) {
1105 	outputFile.seek(dataOffset);
1106 
1107 	// Iterate through writing each string
1108 	for (int idx = 0; idx < count; ++idx) {
1109 		outputFile.writeString(strings[idx]);
1110 	}
1111 
1112 	uint size = outputFile.size() - dataOffset;
1113 	writeEntryHeader(name, dataOffset, size);
1114 	dataOffset += size;
1115 }
1116 
getResId(uint id)1117 Common::WinResourceID getResId(uint id) {
1118 	return Common::WinResourceID(id);
1119 }
1120 
getResId(const char * id)1121 Common::WinResourceID getResId(const char *id) {
1122 	if (!strcmp(id, "Bitmap"))
1123 		return Common::WinResourceID(2);
1124 
1125 	return Common::WinResourceID(id);
1126 }
1127 
writeResource(const char * name,Common::File * file)1128 void writeResource(const char *name, Common::File *file) {
1129 	outputFile.seek(dataOffset);
1130 	outputFile.write(*file, file->size());
1131 
1132 	writeEntryHeader(name, dataOffset, file->size());
1133 	dataOffset += file->size();
1134 	delete file;
1135 }
1136 
writeResource(const char * resName,const char * sectionStr,uint32 resId,bool isEnglish=true)1137 void writeResource(const char *resName, const char *sectionStr, uint32 resId, bool isEnglish = true) {
1138 	Common::PEResources &res = isEnglish ? resEng : resGer;
1139 	Common::File *file = res.getResource(getResId(sectionStr), resId);
1140 	assert(file);
1141 	writeResource(resName, file);
1142 }
1143 
writeResource(const char * sectionStr,uint32 resId,bool isEnglish=true)1144 void writeResource(const char *sectionStr, uint32 resId, bool isEnglish = true) {
1145 	char nameBuffer[256];
1146 	sprintf(nameBuffer, "%s/%u", sectionStr, resId);
1147 	if (!isEnglish)
1148 		strcat(nameBuffer, "/DE");
1149 
1150 	writeResource(nameBuffer, sectionStr, resId, isEnglish);
1151 }
1152 
writeResource(const char * resName,const char * sectionStr,const char * resId,bool isEnglish=true)1153 void writeResource(const char *resName, const char *sectionStr, const char *resId, bool isEnglish = true) {
1154 	Common::PEResources &res = isEnglish ? resEng : resGer;
1155 	Common::File *file = res.getResource(getResId(sectionStr),
1156 		Common::WinResourceID(resId));
1157 	assert(file);
1158 	writeResource(resName, file);
1159 }
1160 
writeResource(const char * sectionStr,const char * resId,bool isEnglish=true)1161 void writeResource(const char *sectionStr, const char *resId, bool isEnglish = true) {
1162 	char nameBuffer[256];
1163 	sprintf(nameBuffer, "%s/%s", sectionStr, resId);
1164 	if (!isEnglish)
1165 		strcat(nameBuffer, "/DE");
1166 
1167 	writeResource(nameBuffer, sectionStr, resId, isEnglish);
1168 }
1169 
writeBitmap(const char * name,Common::File * file)1170 void writeBitmap(const char *name, Common::File *file) {
1171 	outputFile.seek(dataOffset);
1172 
1173 	// Set up a memory stream for the compressed data, and wrap
1174 	// it with a zlib compressor
1175 	Common::MemoryWriteStreamDynamic *compressedData =
1176 		new Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES);
1177 	Common::WriteStream *zlib = Common::wrapCompressedWriteStream(compressedData);
1178 
1179 	// Write out the necessary bitmap header so that the ScummVM
1180 	// BMP decoder can properly handle decoding the bitmaps
1181 	zlib->write("BM", 2);
1182 	zlib->writeUint32LE(file->size() + 14);	// Filesize
1183 	zlib->writeUint32LE(0);					// res1 & res2
1184 	zlib->writeUint32LE(0x436);				// image offset
1185 
1186 	// Transfer the bitmap data
1187 	int srcSize = file->size();
1188 	byte *data = new byte[srcSize];
1189 	file->read(data, srcSize);
1190 	zlib->write(data, srcSize);
1191 
1192 	delete[] data;
1193 	zlib->finalize();
1194 
1195 	// Write out the compressed data
1196 	outputFile.write(compressedData->getData(), compressedData->size());
1197 
1198 	writeEntryHeader(name, dataOffset, compressedData->size() + 14, true);
1199 	dataOffset += compressedData->size() + 14;
1200 
1201 	// Free the zlib write stream
1202 	delete zlib;
1203 }
1204 
writeBitmap(const char * sectionStr,const char * resId,bool isEnglish=true)1205 void writeBitmap(const char *sectionStr, const char *resId, bool isEnglish = true) {
1206 	char nameBuffer[256];
1207 	sprintf(nameBuffer, "%s/%s%s", sectionStr, resId,
1208 		isEnglish ? "" : "/DE");
1209 
1210 	Common::PEResources &res = isEnglish ? resEng : resGer;
1211 	Common::File *file = res.getResource(getResId(sectionStr),
1212 		Common::WinResourceID(resId));
1213 	assert(file);
1214 	writeBitmap(nameBuffer, file);
1215 }
1216 
writeBitmap(const char * sectionStr,uint32 resId,bool isEnglish=true)1217 void writeBitmap(const char *sectionStr, uint32 resId, bool isEnglish = true) {
1218 	char nameBuffer[256];
1219 	sprintf(nameBuffer, "%s/%u%s", sectionStr, resId,
1220 		isEnglish ? "" : "/DE");
1221 
1222 	Common::PEResources &res = isEnglish ? resEng : resGer;
1223 	Common::File *file = res.getResource(getResId(sectionStr),
1224 		Common::WinResourceID(resId));
1225 	assert(file);
1226 	writeBitmap(nameBuffer, file);
1227 }
1228 
writeNumbers()1229 void writeNumbers() {
1230 	outputFile.seek(dataOffset);
1231 
1232 	// Iterate through writing each string
1233 	for (int idx = 0; idx < 76; ++idx) {
1234 		outputFile.writeString(NUMBERS[idx]._text);
1235 		outputFile.writeLong(NUMBERS[idx]._value);
1236 		outputFile.writeLong(NUMBERS[idx]._flags);
1237 	}
1238 
1239 	uint size = outputFile.size() - dataOffset;
1240 	writeEntryHeader("TEXT/NUMBERS", dataOffset, size);
1241 	dataOffset += size;
1242 }
1243 
writeString(uint offset)1244 void writeString(uint offset) {
1245 	if (offset == 0) {
1246 		outputFile.writeByte(0);
1247 	} else {
1248 		inputFile.seek(offset - FILE_DIFF[_version]);
1249 		char c;
1250 		do {
1251 			c = inputFile.readByte();
1252 			outputFile.writeByte(c);
1253 		} while (c);
1254 	}
1255 }
1256 
writeResponseTree()1257 void writeResponseTree() {
1258 	outputFile.seek(dataOffset);
1259 
1260 	const uint OFFSETS[3] = { 0x619520, 0x618340, 0x617380 };
1261 	for (int idx = 0; idx < 1022; ++idx) {
1262 		inputFile.seek(OFFSETS[_version] - FILE_DIFF[_version] + idx * 8);
1263 		uint id = inputFile.readLong();
1264 		uint offset = inputFile.readLong();
1265 
1266 		outputFile.writeLong(id);
1267 		if (!id) {
1268 			// An end of list id
1269 		} else if (offset >= OFFSETS[_version] && offset <= (OFFSETS[_version] + 0x1FF0)) {
1270 			// Offset to another table
1271 			outputFile.writeByte(0);
1272 			outputFile.writeLong((offset - OFFSETS[_version]) / 8);
1273 		} else {
1274 			// Offset to ASCIIZ string
1275 			outputFile.writeByte(1);
1276 			writeString(offset);
1277 		}
1278 	}
1279 
1280 	uint size = outputFile.size() - dataOffset;
1281 	writeEntryHeader("TEXT/TREE", dataOffset, size);
1282 	dataOffset += size;
1283 }
1284 
writeSentenceEntries(const char * name,uint tableOffset)1285 void writeSentenceEntries(const char *name, uint tableOffset) {
1286 	outputFile.seek(dataOffset);
1287 
1288 	uint v1, category, v4, v9, v11, v12, v13;
1289 	uint offset3, offset5, offset6, offset7, offset8, offset10;
1290 
1291 	for (uint idx = 0; ; ++idx) {
1292 		inputFile.seek(tableOffset - FILE_DIFF[_version] + idx * 0x34);
1293 		v1 = inputFile.readLong();
1294 		if (!v1)
1295 			// Reached end of list
1296 			break;
1297 
1298 		// Read data fields
1299 		category = inputFile.readLong();
1300 		offset3 = inputFile.readLong();
1301 		v4 = inputFile.readLong();
1302 		offset5 = inputFile.readLong();
1303 		offset6 = inputFile.readLong();
1304 		offset7 = inputFile.readLong();
1305 		offset8 = inputFile.readLong();
1306 		v9 = inputFile.readLong();
1307 		offset10 = inputFile.readLong();
1308 		v11 = inputFile.readLong();
1309 		v12 = inputFile.readLong();
1310 		v13 = inputFile.readLong();
1311 
1312 		outputFile.writeLong(v1);
1313 		outputFile.writeLong(category);
1314 		writeString(offset3);
1315 		outputFile.writeLong(v4);
1316 		writeString(offset5);
1317 		writeString(offset6);
1318 		writeString(offset7);
1319 		writeString(offset8);
1320 		outputFile.writeLong(v9);
1321 		writeString(offset10);
1322 		outputFile.writeLong(v11);
1323 		outputFile.writeLong(v12);
1324 		outputFile.writeLong(v13);
1325 	}
1326 
1327 	uint size = outputFile.size() - dataOffset;
1328 	writeEntryHeader(name, dataOffset, size);
1329 	dataOffset += size;
1330 }
1331 
writeWords(const char * name,uint tableOffset,int recordCount=2)1332 void writeWords(const char *name, uint tableOffset, int recordCount = 2) {
1333 	outputFile.seek(dataOffset);
1334 	int recordSize = recordCount * 4;
1335 
1336 	uint val, strOffset;
1337 	for (uint idx = 0; ; ++idx) {
1338 		inputFile.seek(tableOffset - FILE_DIFF[_version] + idx * recordSize);
1339 		val = inputFile.readLong();
1340 		strOffset = inputFile.readLong();
1341 
1342 		if (!val) {
1343 			// Reached end of list
1344 			assert(idx >= 128);
1345 			break;
1346 		}
1347 
1348 		outputFile.writeLong(val);
1349 		writeString(strOffset);
1350 	}
1351 
1352 	uint size = outputFile.size() - dataOffset;
1353 	writeEntryHeader(name, dataOffset, size);
1354 	dataOffset += size;
1355 }
1356 
writeSentenceMappings(const char * name,uint offset,int numValues)1357 void writeSentenceMappings(const char *name, uint offset, int numValues) {
1358 	inputFile.seek(offset - FILE_DIFF[_version]);
1359 	outputFile.seek(dataOffset);
1360 
1361 	uint id;
1362 	while ((id = inputFile.readLong()) != 0) {
1363 		outputFile.writeLong(id);
1364 
1365 		for (int ctr = 0; ctr < numValues; ++ctr)
1366 			outputFile.writeLong(inputFile.readLong());
1367 	}
1368 
1369 	uint size = outputFile.size() - dataOffset;
1370 	writeEntryHeader(name, dataOffset, size);
1371 	dataOffset += size;
1372 }
1373 
writeStarfieldPoints()1374 void writeStarfieldPoints() {
1375 	outputFile.seek(dataOffset);
1376 
1377 	const int OFFSETS[3] = { 0x59DE4C, 0x59DBEC, 0x59CC1C };
1378 	inputFile.seek(OFFSETS[_version] - FILE_DIFF[_version]);
1379 	uint size = 876 * 12;
1380 
1381 	outputFile.write(inputFile, size);
1382 	writeEntryHeader("STARFIELD/POINTS", dataOffset, size);
1383 	dataOffset += size;
1384 }
1385 
writeStarfieldPoints2()1386 void writeStarfieldPoints2() {
1387 	outputFile.seek(dataOffset);
1388 
1389 	const int OFFSETS[3] = { 0x5A2F28, 0x5A2CC8, 0x5A1CF8 };
1390 	for (int rootCtr = 0; rootCtr < 80; ++rootCtr) {
1391 		inputFile.seek(OFFSETS[_version] - FILE_DIFF[_version] + rootCtr * 8);
1392 		uint offset = inputFile.readUint32LE();
1393 		uint count = inputFile.readUint32LE();
1394 
1395 		outputFile.writeLong(count);
1396 		inputFile.seek(offset - FILE_DIFF[_version]);
1397 		outputFile.write(inputFile, count * 4 * 4);
1398 	}
1399 
1400 	uint size = outputFile.size() - dataOffset;
1401 	outputFile.write(inputFile, size);
1402 	writeEntryHeader("STARFIELD/POINTS2", dataOffset, size);
1403 	dataOffset += size;
1404 }
1405 
writePhrases(const char * name,const CommonPhrase * phrases)1406 void writePhrases(const char *name, const CommonPhrase *phrases) {
1407 	outputFile.seek(dataOffset);
1408 
1409 	for (uint idx = 0; phrases->_str; ++idx, ++phrases) {
1410 		outputFile.writeString(phrases->_str);
1411 		outputFile.writeLong(phrases->_dialogueId);
1412 		outputFile.writeLong(phrases->_roomNum);
1413 		outputFile.writeLong(phrases->_val1);
1414 	}
1415 
1416 	uint size = outputFile.size() - dataOffset;
1417 	writeEntryHeader("Phrases/Bellbot", dataOffset, size);
1418 	dataOffset += size;
1419 }
1420 
writeBarbotFrameRanges()1421 void writeBarbotFrameRanges() {
1422 	outputFile.seek(dataOffset);
1423 
1424 	for (int idx = 0; idx < 60; ++idx) {
1425 		outputFile.writeLong(BARBOT_FRAME_RANGES[idx]._startFrame);
1426 		outputFile.writeLong(BARBOT_FRAME_RANGES[idx]._endFrame);
1427 	}
1428 
1429 	uint size = outputFile.size() - dataOffset;
1430 	writeEntryHeader("FRAMES/BARBOT", dataOffset, size);
1431 	dataOffset += size;
1432 }
1433 
writeMissiveOMatMessages()1434 void writeMissiveOMatMessages() {
1435 	outputFile.seek(dataOffset);
1436 
1437 	for (int idx = 0; idx < 3; ++idx)
1438 		outputFile.writeString(MISSIVEOMAT_MESSAGES[idx]);
1439 
1440 	uint size = outputFile.size() - dataOffset;
1441 	writeEntryHeader("TEXT/MISSIVEOMAT/WELCOME", dataOffset, size);
1442 	dataOffset += size;
1443 
1444 	static const int MESSAGES[3] = { 0x5A63C0, 0x5A5BA8, 0x5A4A18 };
1445 	writeStringArray("TEXT/MISSIVEOMAT/MESSAGES", MESSAGES[_version], 58);
1446 	static const int FROM[3] = { 0x5A61F0, 0x5A59D8, 0x5A4BE8 };
1447 	writeStringArray("TEXT/MISSIVEOMAT/FROM", FROM[_version], 58);
1448 	static const int TO[3] = { 0x5A62D8, 0x5A5AC0, 0x5A4B00 };
1449 	writeStringArray("TEXT/MISSIVEOMAT/TO", TO[_version], 58);
1450 }
1451 
writeMissiveOMatMessagesDE()1452 void writeMissiveOMatMessagesDE() {
1453 	outputFile.seek(dataOffset);
1454 
1455 	for (int idx = 0; idx < 3; ++idx)
1456 		outputFile.writeString(MISSIVEOMAT_MESSAGES_DE[idx]);
1457 
1458 	uint size = outputFile.size() - dataOffset;
1459 	writeEntryHeader("TEXT/MISSIVEOMAT/WELCOME/DE", dataOffset, size);
1460 	dataOffset += size;
1461 
1462 	writeStringArray("TEXT/MISSIVEOMAT/MESSAGES/DE", 0x5A9988, 58);
1463 	writeStringArray("TEXT/MISSIVEOMAT/FROM/DE", 0x5A97B8, 58);
1464 	writeStringArray("TEXT/MISSIVEOMAT/TO/DE", 0x5A98A0, 58);
1465 }
1466 
writeBedheadGroup(const BedheadEntry * data,int count)1467 void writeBedheadGroup(const BedheadEntry *data, int count) {
1468 	for (int idx = 0; idx < count; ++idx, ++data) {
1469 		outputFile.writeString(data->_name1);
1470 		outputFile.writeString(data->_name2);
1471 		outputFile.writeString(data->_name3);
1472 		outputFile.writeString(data->_name4);
1473 		outputFile.writeLong(data->_startFrame);
1474 		outputFile.writeLong(data->_endFrame);
1475 	}
1476 }
1477 
writeBedheadData()1478 void writeBedheadData() {
1479 	outputFile.seek(dataOffset);
1480 
1481 	writeBedheadGroup(ON_CLOSED, 4);
1482 	writeBedheadGroup(ON_RESTING_TV, 2);
1483 	writeBedheadGroup(ON_RESTING_UV, 2);
1484 	writeBedheadGroup(ON_CLOSED_WRONG, 2);
1485 	writeBedheadGroup(OFF_OPEN, 3);
1486 	writeBedheadGroup(OFF_RESTING_UTV, 1);
1487 	writeBedheadGroup(OFF_RESTING_V, 1);
1488 	writeBedheadGroup(OFF_RESTING_G, 3);
1489 	writeBedheadGroup(OFF_OPEN_WRONG, 1);
1490 	writeBedheadGroup(OFF_RESTING_D_WRONG, 1);
1491 
1492 	uint size = outputFile.size() - dataOffset;
1493 	writeEntryHeader("DATA/BEDHEAD", dataOffset, size);
1494 	dataOffset += size;
1495 }
1496 
writeParrotLobbyLinkUpdaterEntries()1497 void writeParrotLobbyLinkUpdaterEntries() {
1498 	static const int OFFSETS[3] = { 0x5A5B38, 0x5A5320, 0x5A4360 };
1499 	static const int COUNTS[5] = { 7, 5, 6, 9, 1 };
1500 	static const int SKIP[5] = { 36, 36, 40, 36, 0 };
1501 	uint recordOffset = OFFSETS[_version], linkOffset;
1502 	byte vals[8];
1503 
1504 	outputFile.seek(dataOffset);
1505 
1506 	for (int groupNum = 0; groupNum < 4; ++groupNum) {
1507 		for (int entryNum = 0; entryNum < COUNTS[groupNum];
1508 				++entryNum, recordOffset += 36) {
1509 			inputFile.seek(recordOffset - FILE_DIFF[_version]);
1510 			linkOffset = inputFile.readUint32LE();
1511 			for (int idx = 0; idx < 8; ++idx)
1512 				vals[idx] = inputFile.readUint32LE();
1513 
1514 			// Write out the entry
1515 			inputFile.seek(linkOffset - FILE_DIFF[_version]);
1516 			outputFile.writeString(inputFile);
1517 			outputFile.write(vals, 8);
1518 		}
1519 
1520 		// Skip space between groups
1521 		recordOffset += SKIP[groupNum];
1522 	}
1523 
1524 	uint size = outputFile.size() - dataOffset;
1525 	writeEntryHeader("DATA/PARROT_LOBBY_LINK_UPDATOR", dataOffset, size);
1526 	dataOffset += size;
1527 }
1528 
writeHeader()1529 void writeHeader() {
1530 	// Write out magic string
1531 	const char *MAGIC_STR = "SVTN";
1532 	outputFile.write(MAGIC_STR, 4);
1533 
1534 	// Write out version number
1535 	outputFile.writeWord(VERSION_NUMBER);
1536 }
1537 
writeData()1538 void writeData() {
1539 	for (int idx = 0; idx < (resGer.empty() ? 1 : 2); ++idx) {
1540 		bool isEnglish = idx == 0;
1541 
1542 		writeBitmap("Bitmap", "BACKDROP", isEnglish);
1543 		writeBitmap("Bitmap", "EVILTWIN", isEnglish);
1544 		writeBitmap("Bitmap", "RESTORED", isEnglish);
1545 		writeBitmap("Bitmap", "RESTOREF", isEnglish);
1546 		writeBitmap("Bitmap", "RESTOREU", isEnglish);
1547 		writeBitmap("Bitmap", "STARTD", isEnglish);
1548 		writeBitmap("Bitmap", "STARTF", isEnglish);
1549 		writeBitmap("Bitmap", "STARTU", isEnglish);
1550 		writeBitmap("Bitmap", "TITANIC", isEnglish);
1551 		writeBitmap("Bitmap", 133, isEnglish);
1552 		writeBitmap("Bitmap", 164, isEnglish);
1553 		writeBitmap("Bitmap", 165, isEnglish);
1554 	}
1555 
1556 	writeResource("STFONT", 149);
1557 	writeResource("STFONT", 151);
1558 	writeResource("STFONT", 152);
1559 	writeResource("STFONT", 153);
1560 
1561 	writeResource("TEXT/STVOCAB", "TEXT", "STVOCAB.TXT");
1562 	writeResource("TEXT/JRQUOTES", "TEXT", "JRQUOTES.TXT");
1563 	writeResource("TEXT", 155);
1564 
1565 	writeResource("STARFIELD", 132);
1566 	writeStarfieldPoints();
1567 	writeStarfieldPoints2();
1568 
1569 	writeStringArray("TEXT/ITEM_DESCRIPTIONS", ITEM_DESCRIPTIONS, 46);
1570 	writeStringArray("TEXT/ITEM_DESCRIPTIONS/DE", ITEM_DESCRIPTIONS_DE, 46);
1571 	writeStringArray("TEXT/ITEM_NAMES", ITEM_NAMES, 46);
1572 	writeStringArray("TEXT/ITEM_IDS", ITEM_IDS, 40);
1573 	writeStringArray("TEXT/ROOM_NAMES", ROOM_NAMES, 34);
1574 	writeStringArray("TEXT/STRINGS", STRINGS_EN, 156);
1575 	writeStringArray("TEXT/STRINGS/DE", STRINGS_DE, 202);
1576 	const int TEXT_PHRASES[3] = { 0x61D3C8, 0x618340, 0x61B1E0 };
1577 	const int TEXT_REPLACEMENTS1[3] = { 0x61D9B0, 0x61C788, 0x61B7C8 };
1578 	const int TEXT_REPLACEMENTS2[3] = { 0x61DD20, 0x61CAF8, 0x61BB38 };
1579 	const int TEXT_REPLACEMENTS3[3] = { 0x61F5C8, 0x61E3A0, 0x61D3E0 };
1580 	const int TEXT_PRONOUNS[3] = { 0x631318, 0x6300F8, 0x62F138 };
1581 	writeStringArray("TEXT/PHRASES", TEXT_PHRASES[_version], 376);
1582 	writeStringArray("TEXT/REPLACEMENTS1", TEXT_REPLACEMENTS1[_version], 218);
1583 	writeStringArray("TEXT/REPLACEMENTS2", TEXT_REPLACEMENTS2[_version], 1576);
1584 	writeStringArray("TEXT/REPLACEMENTS3", TEXT_REPLACEMENTS3[_version], 82);
1585 	writeStringArray("TEXT/PRONOUNS", TEXT_PRONOUNS[_version], 15);
1586 	writeStringArray("MUSIC/PARSER", MUSIC_DATA, 4);
1587 
1588 	const int SENTENCES_DEFAULT[3] = { 0x5C0130, 0x5BEFC8, 0x5BE008 };
1589 	const int SENTENCES_BARBOT[2][3] = {
1590 		{ 0x5ABE60, 0x5AACF8, 0x5A9D38 }, { 0x5BD4E8, 0x5BC380, 0x5BB3C0 }
1591 	};
1592 	const int SENTENCES_BELLBOT[20][3] = {
1593 		{ 0x5C2230, 0x5C10C8, 0X5C0108 }, { 0x5D1670, 0x5D0508, 0x5CF548 },
1594 		{ 0x5D1A80, 0x5D0918, 0x5CF958 }, { 0x5D1AE8, 0x5D0980, 0x5CF9C0 },
1595 		{ 0x5D1B88, 0x5D0A20, 0x5CFA60 }, { 0x5D2A60, 0x5D18F8, 0x5D0938 },
1596 		{ 0x5D2CD0, 0x5D1B68, 0x5D0BA8 }, { 0x5D3488, 0x5D2320, 0x5D1360 },
1597 		{ 0x5D3900, 0x5D2798, 0x5D17D8 }, { 0x5D3968, 0x5D2800, 0x5D1840 },
1598 		{ 0x5D4668, 0x5D3500, 0x5D2540 }, { 0x5D47A0, 0x5D3638, 0x5D2678 },
1599 		{ 0x5D4EC0, 0x5D3D58, 0x5D2D98 }, { 0x5D5100, 0x5D3F98, 0x5D2FD8 },
1600 		{ 0x5D5370, 0x5D4208, 0x5D3248 }, { 0x5D5548, 0x5D43E0, 0x5D3420 },
1601 		{ 0x5D56B8, 0x5D4550, 0x5D3590 }, { 0x5D57C0, 0x5D4658, 0x5D3698 },
1602 		{ 0x5D5B38, 0x5D49D0, 0x5D3A10 }, { 0x5D61B8, 0x5D5050, 0x5D4090 }
1603 	};
1604 	writeSentenceEntries("Sentences/Default", SENTENCES_DEFAULT[_version]);
1605 	writeSentenceEntries("Sentences/Barbot", SENTENCES_BARBOT[0][_version]);
1606 	writeSentenceEntries("Sentences/Barbot2", SENTENCES_BARBOT[1][_version]);
1607 	writeSentenceEntries("Sentences/Bellbot", SENTENCES_BELLBOT[0][_version]);
1608 	writeSentenceEntries("Sentences/Bellbot/1", SENTENCES_BELLBOT[1][_version]);
1609 	writeSentenceEntries("Sentences/Bellbot/2", SENTENCES_BELLBOT[2][_version]);
1610 	writeSentenceEntries("Sentences/Bellbot/3", SENTENCES_BELLBOT[3][_version]);
1611 	writeSentenceEntries("Sentences/Bellbot/4", SENTENCES_BELLBOT[4][_version]);
1612 	writeSentenceEntries("Sentences/Bellbot/5", SENTENCES_BELLBOT[5][_version]);
1613 	writeSentenceEntries("Sentences/Bellbot/6", SENTENCES_BELLBOT[6][_version]);
1614 	writeSentenceEntries("Sentences/Bellbot/7", SENTENCES_BELLBOT[7][_version]);
1615 	writeSentenceEntries("Sentences/Bellbot/8", SENTENCES_BELLBOT[8][_version]);
1616 	writeSentenceEntries("Sentences/Bellbot/9", SENTENCES_BELLBOT[9][_version]);
1617 	writeSentenceEntries("Sentences/Bellbot/10", SENTENCES_BELLBOT[10][_version]);
1618 	writeSentenceEntries("Sentences/Bellbot/11", SENTENCES_BELLBOT[11][_version]);
1619 	writeSentenceEntries("Sentences/Bellbot/12", SENTENCES_BELLBOT[12][_version]);
1620 	writeSentenceEntries("Sentences/Bellbot/13", SENTENCES_BELLBOT[13][_version]);
1621 	writeSentenceEntries("Sentences/Bellbot/14", SENTENCES_BELLBOT[14][_version]);
1622 	writeSentenceEntries("Sentences/Bellbot/15", SENTENCES_BELLBOT[15][_version]);
1623 	writeSentenceEntries("Sentences/Bellbot/16", SENTENCES_BELLBOT[16][_version]);
1624 	writeSentenceEntries("Sentences/Bellbot/17", SENTENCES_BELLBOT[17][_version]);
1625 	writeSentenceEntries("Sentences/Bellbot/18", SENTENCES_BELLBOT[18][_version]);
1626 	writeSentenceEntries("Sentences/Bellbot/19", SENTENCES_BELLBOT[19][_version]);
1627 
1628 	const int SENTENCES_DESKBOT[3][3] = {
1629 		{ 0x5DCD10, 0x5DBBA8, 0x5DABE8 }, { 0x5E8E18, 0x5E7CB0, 0x5E6CF0 },
1630 		{ 0x5E8BA8, 0x5E7A40, 0x5E6A80 }
1631 	};
1632 	writeSentenceEntries("Sentences/Deskbot", SENTENCES_DESKBOT[0][_version]);
1633 	writeSentenceEntries("Sentences/Deskbot/2", SENTENCES_DESKBOT[1][_version]);
1634 	writeSentenceEntries("Sentences/Deskbot/3", SENTENCES_DESKBOT[2][_version]);
1635 
1636 	const int SENTENCES_DOORBOT[12][3] = {
1637 		{ 0x5EC110, 0x5EAFA8, 0x5E9FE8 }, { 0x5FD930, 0x5FC7C8, 0x5FB808 },
1638 		{ 0x5FDD0C, 0x5FCBA4, 0x5FBBE4 }, { 0x5FE668, 0x5FD500, 0x5FC540 },
1639 		{ 0x5FDD40, 0x5FCBD8, 0X5FBC18 }, { 0x5FFF08, 0x5FEDA0, 0x5FDDE0 },
1640 		{ 0x5FE3C0, 0x5FD258, 0x5FC298 }, { 0x5FF0C8, 0x5FDF60, 0x5FCFA0 },
1641 		{ 0x5FF780, 0x5FE618, 0x5FD658 }, { 0x5FFAC0, 0x5FE958, 0x5FD998 },
1642 		{ 0x5FFC30, 0x5FEAC8, 0x5FDB08 }, { 0x6000E0, 0x5FEF78, 0x5FDFB8 }
1643 	};
1644 	writeSentenceEntries("Sentences/Doorbot", SENTENCES_DOORBOT[0][_version]);
1645 	writeSentenceEntries("Sentences/Doorbot/2", SENTENCES_DOORBOT[1][_version]);
1646 	writeSentenceEntries("Sentences/Doorbot/100", SENTENCES_DOORBOT[2][_version]);
1647 	writeSentenceEntries("Sentences/Doorbot/101", SENTENCES_DOORBOT[3][_version]);
1648 	writeSentenceEntries("Sentences/Doorbot/102", SENTENCES_DOORBOT[4][_version]);
1649 	writeSentenceEntries("Sentences/Doorbot/107", SENTENCES_DOORBOT[5][_version]);
1650 	writeSentenceEntries("Sentences/Doorbot/110", SENTENCES_DOORBOT[6][_version]);
1651 	writeSentenceEntries("Sentences/Doorbot/111", SENTENCES_DOORBOT[7][_version]);
1652 	writeSentenceEntries("Sentences/Doorbot/124", SENTENCES_DOORBOT[8][_version]);
1653 	writeSentenceEntries("Sentences/Doorbot/129", SENTENCES_DOORBOT[9][_version]);
1654 	writeSentenceEntries("Sentences/Doorbot/131", SENTENCES_DOORBOT[10][_version]);
1655 	writeSentenceEntries("Sentences/Doorbot/132", SENTENCES_DOORBOT[11][_version]);
1656 
1657 	const int SENTENCES_LIFTBOT[3] = { 0x6026B0, 0x601548, 0x600588 };
1658 	const int SENTENCES_MAITRED[2][3] = {
1659 		{ 0x60CFD8, 0x60BE70, 0x60AEB0 }, { 0x614288, 0x613120, 0x612160 }
1660 	};
1661 	const int SENTENCES_PARROT[3] = { 0x615858, 0x6146F0, 0x613730 };
1662 	const int SENTENCES_SUCCUBUS[3] = { 0x616698, 0x615530, 0x614570 };
1663 	const int MAPPINGS_BARBOT[3] = { 0x5B28A0, 0x5B173E, 0x5B0778 };
1664 	const int MAPPINGS_BELLBOT[3] = { 0x5CD830, 0x5CC6C8, 0x5CB708 };
1665 	const int MAPPINGS_DESKBOT[3] = { 0x5E2BB8, 0x5E1A50, 0x5E0A90 };
1666 	const int MAPPINGS_DOORBOT[3] = { 0x5F7950, 0x5F67E8, 0x5F5828 };
1667 	const int MAPPINGS_LIFTBOT[3] = { 0x608660, 0x6074F8, 0x606538 };
1668 	const int MAPPINGS_MAITRED[3] = { 0x6125C8, 0x611460, 0x6104A0 };
1669 	const int MAPPINGS_PARROT[3] = { 0x615B68, 0x614A00, 0x613A40 };
1670 	const int MAPPINGS_SUCCUBUS[3] = { 0x6189F0, 0x617888, 0x6168C8 };
1671 	const int WORDS_BARBOT[3] = { 0x5BE2E0, 0x5BD178, 0x5BC1B8 };
1672 	const int WORDS_BELLBOT[3] = { 0x5D8230, 0x5D70C8, 0x5D6108 };
1673 	const int WORDS_DESKBOT[3] = { 0x5EAAA8, 0x5E9940, 0x5E8980 };
1674 	const int WORDS_DOORBOT[3] = { 0x601098, 0x5FFF30, 0x5FEF70 };
1675 	const int WORDS_LIFTBOT[3] = { 0x60C788, 0x60B620, 0x60A660 };
1676 	writeSentenceEntries("Sentences/Liftbot", SENTENCES_LIFTBOT[_version]);
1677 	writeSentenceEntries("Sentences/MaitreD", SENTENCES_MAITRED[0][_version]);
1678 	writeSentenceEntries("Sentences/MaitreD/1", SENTENCES_MAITRED[1][_version]);
1679 	writeSentenceEntries("Sentences/Parrot", SENTENCES_PARROT[_version]);
1680 	writeSentenceEntries("Sentences/SuccUBus", SENTENCES_SUCCUBUS[_version]);
1681 	writeSentenceMappings("Mappings/Barbot", MAPPINGS_BARBOT[_version], 8);
1682 	writeSentenceMappings("Mappings/Bellbot", MAPPINGS_BELLBOT[_version], 1);
1683 	writeSentenceMappings("Mappings/Deskbot", MAPPINGS_DESKBOT[_version], 4);
1684 	writeSentenceMappings("Mappings/Doorbot", MAPPINGS_DOORBOT[_version], 4);
1685 	writeSentenceMappings("Mappings/Liftbot", MAPPINGS_LIFTBOT[_version], 4);
1686 	writeSentenceMappings("Mappings/MaitreD", MAPPINGS_MAITRED[_version], 1);
1687 	writeSentenceMappings("Mappings/Parrot", MAPPINGS_PARROT[_version], 1);
1688 	writeSentenceMappings("Mappings/SuccUBus", MAPPINGS_SUCCUBUS[_version], 1);
1689 	writeWords("Words/Barbot", WORDS_BARBOT[_version]);
1690 	writeWords("Words/Bellbot", WORDS_BELLBOT[_version], 3);
1691 	writeWords("Words/Deskbot", WORDS_DESKBOT[_version], 3);
1692 	writeWords("Words/Doorbot", WORDS_DOORBOT[_version], 3);
1693 	writeWords("Words/Liftbot", WORDS_LIFTBOT[_version]);
1694 	writePhrases("Phrases/Bellbot", BELLBOT_COMMON_PHRASES_EN);
1695 
1696 	writeResponseTree();
1697 	writeNumbers();
1698 	writeAllScriptQuotes();
1699 	writeAllScriptResponses();
1700 	writeAllScriptRanges();
1701 
1702 	writeAllTagMappings();
1703 	writeAllUpdateStates();
1704 	writeAllScriptPreResponses();
1705 	writeBarbotFrameRanges();
1706 	writeMissiveOMatMessages();
1707 	writeBedheadData();
1708 	writeParrotLobbyLinkUpdaterEntries();
1709 }
1710 
writeGermanData()1711 void writeGermanData() {
1712 	writeResource("TEXT/STVOCAB/DE", "TEXT", "STVOCABDE.TXT", false);
1713 	writeResource("TEXT/JRQUOTES/DE", "TEXT", "JRQUOTESDE.TXT", false);
1714 	writeResource("TEXT/155/DE", "TEXT", 155, false);
1715 
1716 	writeStringArray("TEXT/PHRASES/DE", 0x23EEC8 + GERMAN_DIFF, 178);
1717 	writeStringArray("TEXT/REPLACEMENTS1/DE", 0x23F198 + GERMAN_DIFF, 1362);
1718 	writeStringArray("TEXT/REPLACEMENTS2/DE", 0x2406E8 + GERMAN_DIFF, 816);
1719 	writeStringArray("TEXT/REPLACEMENTS3/DE", 0x2413B0 + GERMAN_DIFF, 608);
1720 	writeStringArray("TEXT/REPLACEMENTS4/DE", 0x241D38 + GERMAN_DIFF, 195);
1721 	writeStringArray("TEXT/PRONOUNS/DE", 0x248610 + GERMAN_DIFF, 15);
1722 
1723 	writeSentenceMappings("Mappings/Barbot/DE", 0x1BA388 + GERMAN_DIFF, 8);
1724 	writeSentenceMappings("Mappings/Bellbot/DE", 0x1E1D20 + GERMAN_DIFF, 1);
1725 	writeSentenceMappings("Mappings/Deskbot/DE", 0x1F5A18 + GERMAN_DIFF, 4);
1726 	writeSentenceMappings("Mappings/Doorbot/DE", 0x214E00 + GERMAN_DIFF, 4);
1727 	writeSentenceMappings("Mappings/Liftbot/DE", 0x224AE0 + GERMAN_DIFF, 4);
1728 	writeSentenceMappings("Mappings/MaitreD/DE", 0x232E30 + GERMAN_DIFF, 1);
1729 	writeSentenceMappings("Mappings/Parrot/DE", 0x235FA8 + GERMAN_DIFF, 1);
1730 	writeSentenceMappings("Mappings/SuccUBus/DE", 0x2399C8 + GERMAN_DIFF, 1);
1731 	writeWords("Words/Barbot/DE", 0x5C68B8);
1732 	writeWords("Words/Bellbot/DE", 0x5E8378, 3);
1733 	writeWords("Words/Deskbot/DE", 0x5FE8D8, 3);
1734 	writeWords("Words/Doorbot/DE", 0x61B398, 3);
1735 	writeWords("Words/Liftbot/DE", 0x629618);
1736 	writePhrases("Phrases/Bellbot/DE", BELLBOT_COMMON_PHRASES_DE);
1737 
1738 	const int SENTENCES_BARBOT[2] = { 0x5B00C0, 0x5C5AC8 };
1739 	const int SENTENCES_BELLBOT[20] = { 0x5CACF8, 0x5D1670 };
1740 	const int SENTENCES_DESKBOT[3] = { 0x5ED428, 0x5FCEA0, 0x5FCC30 };
1741 	const int SENTENCES_DOORBOT[4] = { 0x5FFFC8, 0x61A690, 0x61AA38 };
1742 
1743 	writeSentenceEntries("Sentences/Default/DE", 0x5C8C70);
1744 	writeSentenceEntries("Sentences/Barbot/DE", SENTENCES_BARBOT[0]);
1745 	writeSentenceEntries("Sentences/Barbot2/DE", SENTENCES_BARBOT[1]);
1746 	writeSentenceEntries("Sentences/Bellbot/DE", SENTENCES_BELLBOT[0]);
1747 	writeSentenceEntries("Sentences/Bellbot/1/DE", SENTENCES_BELLBOT[1]);
1748 	writeSentenceEntries("Sentences/Deskbot/DE", SENTENCES_DESKBOT[0]);
1749 	writeSentenceEntries("Sentences/Deskbot/2/DE", SENTENCES_DESKBOT[1]);
1750 	writeSentenceEntries("Sentences/Deskbot/3/DE", SENTENCES_DESKBOT[2]);
1751 	writeSentenceEntries("Sentences/Doorbot/DE", SENTENCES_DOORBOT[0]);
1752 	writeSentenceEntries("Sentences/Doorbot/1/DE", SENTENCES_DOORBOT[1]);
1753 	writeSentenceEntries("Sentences/Doorbot/2/DE", SENTENCES_DOORBOT[2]);
1754 	writeSentenceEntries("Sentences/Liftbot/DE", 0x61CAD0);
1755 	writeSentenceEntries("Sentences/MaitreD/DE", 0x629EE8);
1756 	writeSentenceEntries("Sentences/Parrot/DE", 0x633FFC);
1757 	writeSentenceEntries("Sentences/SuccUBus/DE", 0x637CD8);
1758 
1759 	writeMissiveOMatMessagesDE();
1760 
1761 	writeResource("STFONT", 149, false);
1762 	writeResource("STFONT", 151, false);
1763 	writeResource("STFONT", 152, false);
1764 	writeResource("STFONT", 153, false);
1765 }
1766 
createScriptMap()1767 void createScriptMap() {
1768 	Common::File inFile;
1769 	char line[80];
1770 	char c[2];
1771 	c[0] = c[1] = '\0';
1772 	int counter = 0;
1773 
1774 	inFile.open("d:\\temp\\map.txt");
1775 	printf("static const TagMapping xxxx_ID_MAP[] = {\n");
1776 
1777 	do {
1778 		strcpy(line, "");
1779 
1780 		while (!inFile.eof()) {
1781 			c[0] = inFile.readByte();
1782 			if (c[0] == '\n')
1783 				c[0] = ' ';
1784 			else if (c[0] == '\r')
1785 				continue;
1786 			strcat(line, c);
1787 			if (inFile.eof() || strlen(line) == (2 * 9))
1788 				break;
1789 		}
1790 
1791 		uint v1, v2;
1792 		sscanf(line, "%x %x", &v1, &v2);
1793 
1794 		if (counter != 0 && (counter % 3) == 0)
1795 			printf("\r\n");
1796 		if ((counter % 3) == 0)
1797 			printf("\t");
1798 
1799 		printf("{ 0x%.5x, 0x%.5x }, ", v1, v2);
1800 		++counter;
1801 	} while (!inFile.eof());
1802 
1803 	printf("};\r\n");
1804 	inFile.close();
1805 }
1806 
main(int argc,char * argv[])1807 int main(int argc, char *argv[]) {
1808 	if (argc < 2) {
1809 		printf("Format: %s ST.exe [ST_german.exe] [titanic.dat]\n", argv[0]);
1810 		exit(0);
1811 	}
1812 
1813 	if (!inputFile.open(argv[1])) {
1814 		error("Could not open input file");
1815 	}
1816 	resEng.loadFromEXE(argv[1]);
1817 
1818 	if (argc == 4) {
1819 		resGer.loadFromEXE(argv[2]);
1820 	}
1821 
1822 	if (inputFile.size() == ENGLISH_10042C_FILESIZE)
1823 		_version = ENGLISH_10042C;
1824 	else if (inputFile.size() == ENGLISH_10042B_FILESIZE)
1825 		_version = ENGLISH_10042B;
1826 	else if (inputFile.size() == ENGLISH_10042_FILESIZE)
1827 		_version = ENGLISH_10042;
1828 	else if (inputFile.size() == GERMAN_10042D_FILESIZE) {
1829 		printf("German version detected. You must use an English versoin "
1830 			"for the primary input file\n");
1831 		exit(0);
1832 	} else {
1833 		printf("Unknown version of ST.exe specified\n");
1834 		exit(0);
1835 	}
1836 
1837 	if (!outputFile.open(argc == 4 ? argv[3] : "titanic.dat", Common::kFileWriteMode)) {
1838 		printf("Could not open output file\n");
1839 		exit(0);
1840 	}
1841 
1842 	writeHeader();
1843 	writeData();
1844 
1845 	if (argc == 4) {
1846 		inputFile.open(argv[2]);
1847 		_version = GERMAN;
1848 		writeGermanData();
1849 	}
1850 	writeFinalEntryHeader();
1851 	inputFile.close();
1852 	outputFile.close();
1853 	return 0;
1854 }
1855