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