Debian Codegraph @

src/config.c

raw symbols SCIP
1 /*
2 * OpenTyrian: A modern cross-platform port of Tyrian
3 * Copyright (C) 2007-2009 The OpenTyrian Development Team
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19 #include "config.h"cxx . . $ `<file>/src/config.h`/
20
21 #include "episodes.h"cxx . . $ `<file>/src/episodes.h`/
22 #include "file.h"cxx . . $ `<file>/src/file.h`/
23 #include "joystick.h"cxx . . $ `<file>/src/joystick.h`/
24 #include "loudness.h"cxx . . $ `<file>/src/loudness.h`/
25 #include "mtrand.h"cxx . . $ `<file>/src/mtrand.h`/
26 #include "nortsong.h"cxx . . $ `<file>/src/nortsong.h`/
27 #include "opentyr.h"cxx . . $ `<file>/src/opentyr.h`/
28 #include "player.h"cxx . . $ `<file>/src/player.h`/
29 #include "varz.h"cxx . . $ `<file>/src/varz.h`/
30 #include "vga256d.h"cxx . . $ `<file>/src/vga256d.h`/
31 #include "video.h"cxx . . $ `<file>/src/video.h`/
32 #include "video_scale.h"cxx . . $ `<file>/src/video_scale.h`/
33
34 #include <stdio.h>
35 #include <sys/stat.h>
36
37 #ifdef _MSC_VER
38 #include <direct.h>
39 #define mkdir _mkdir
40 #else
41 #include <unistd.h>
42 #endif
43
44 /* Configuration Load/Save handler */
45
46 const JE_bytecxx . . $ JE_byte# cryptKeycxx . . $ cryptKey.[10] = /* [1..10] */
47 {
48 15, 50, 89, 240, 147, 34, 86, 9, 32, 208
49 };
50
51 const DosKeySettingscxx . . $ DosKeySettings# defaultDosKeySettingscxx . . $ defaultDosKeySettings. =
52 {
53 72, 80, 75, 77, 57, 28, 29, 56
54 };
55
56 const KeySettingscxx . . $ KeySettings# defaultKeySettingscxx . . $ defaultKeySettings. =
57 {
58 SDL_SCANCODE_UPcxx . . $ SDL_SCANCODE_UP.,
59 SDL_SCANCODE_DOWNcxx . . $ SDL_SCANCODE_DOWN.,
60 SDL_SCANCODE_LEFTcxx . . $ SDL_SCANCODE_LEFT.,
61 SDL_SCANCODE_RIGHTcxx . . $ SDL_SCANCODE_RIGHT.,
62 SDL_SCANCODE_SPACEcxx . . $ SDL_SCANCODE_SPACE.,
63 SDL_SCANCODE_RETURNcxx . . $ SDL_SCANCODE_RETURN.,
64 SDL_SCANCODE_LCTRLcxx . . $ SDL_SCANCODE_LCTRL.,
65 SDL_SCANCODE_LALTcxx . . $ SDL_SCANCODE_LALT.,
66 };
67
68 static const char *const keySettingNamescxx . . $ keySettingNames.[] =
69 {
70 "up",
71 "down",
72 "left",
73 "right",
74 "fire",
75 "change fire",
76 "left sidekick",
77 "right sidekick",
78 };
79
80 const char defaultHighScoreNamescxx . . $ defaultHighScoreNames.[34][23] = /* [1..34] of string [22] */
81 {/*1P*/
82 /*TYR*/ "The Prime Chair", /*13*/
83 "Transon Lohk",
84 "Javi Onukala",
85 "Mantori",
86 "Nortaneous",
87 "Dougan",
88 "Reid",
89 "General Zinglon",
90 "Late Gyges Phildren",
91 "Vykromod",
92 "Beppo",
93 "Borogar",
94 "ShipMaster Carlos",
95
96 /*OTHER*/ "Jill", /*5*/
97 "Darcy",
98 "Jake Stone",
99 "Malvineous Havershim",
100 "Marta Louise Velasquez",
101
102 /*JAZZ*/ "Jazz Jackrabbit", /*3*/
103 "Eva Earlong",
104 "Devan Shell",
105
106 /*OMF*/ "Crystal Devroe", /*11*/
107 "Steffan Tommas",
108 "Milano Angston",
109 "Christian",
110 "Shirro",
111 "Jean-Paul",
112 "Ibrahim Hothe",
113 "Angel",
114 "Cossette Akira",
115 "Raven",
116 "Hans Kreissack",
117
118 /*DARE*/ "Tyler", /*2*/
119 "Rennis the Rat Guard"
120 };
121
122 const char defaultTeamNamescxx . . $ defaultTeamNames.[22][25] = /* [1..22] of string [24] */
123 {
124 "Jackrabbits",
125 "Team Tyrian",
126 "The Elam Brothers",
127 "Dare to Dream Team",
128 "Pinball Freaks",
129 "Extreme Pinball Freaks",
130 "Team Vykromod",
131 "Epic All-Stars",
132 "Hans Keissack's WARriors",
133 "Team Overkill",
134 "Pied Pipers",
135 "Gencore Growlers",
136 "Microsol Masters",
137 "Beta Warriors",
138 "Team Loco",
139 "The Shellians",
140 "Jungle Jills",
141 "Murderous Malvineous",
142 "The Traffic Department",
143 "Clan Mikal",
144 "Clan Patrok",
145 "Carlos' Crawlers"
146 };
147
148 const JE_EditorItemAvailTypecxx . . $ JE_EditorItemAvailType# initialItemAvailcxx . . $ initialItemAvail. =
149 {
150 1,1,1,0,0,1,1,0,1,1,1,1,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0, /* Front/Rear Weapons 1-38 */
151 0,0,0,0,0,0,0,0,0,0,1, /* Fill */
152 1,0,0,0,0,1,0,0,0,1,1,0,1,0,0,0,0,0, /* Sidekicks 51-68 */
153 0,0,0,0,0,0,0,0,0,0,0, /* Fill */
154 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* Special Weapons 81-93 */
155 0,0,0,0,0 /* Fill */
156 };
157
158 /* Last 2 bytes = Word
159 *
160 * Max Value = 1680
161 * X div 60 = Armor (1-28)
162 * X div 168 = Shield (1-12)
163 * X div 280 = Engine (1-06)
164 */
165
166 JE_booleancxx . . $ JE_boolean# smoothiescxx . . $ smoothies.[9] = /* [1..9] */
167 { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
168
169 JE_bytecxx . . $ JE_byte# starShowVGASpecialCodecxx . . $ starShowVGASpecialCode.;
170
171 /* CubeData */
172 JE_wordcxx . . $ JE_word# lastCubeMaxcxx . . $ lastCubeMax., cubeMaxcxx . . $ cubeMax.;
173 JE_wordcxx . . $ JE_word# cubeListcxx . . $ cubeList.[4]; /* [1..4] */
174
175 /* High-Score Stuff */
176 JE_booleancxx . . $ JE_boolean# gameHasRepeatedcxx . . $ gameHasRepeated.; // can only get highscore on first play-through
177
178 /* Difficulty */
179 JE_shortintcxx . . $ JE_shortint# difficultyLevelcxx . . $ difficultyLevel., oldDifficultyLevelcxx . . $ oldDifficultyLevel.,
180 initialDifficultycxx . . $ initialDifficulty.; // can only get highscore on initial episode
181
182 /* Player Stuff */
183 uintcxx . . $ uint# powercxx . . $ power., lastPowercxx . . $ lastPower., powerAddcxx . . $ powerAdd.;
184 JE_bytecxx . . $ JE_byte# shieldWaitcxx . . $ shieldWait., shieldTcxx . . $ shieldT.;
185
186 JE_bytecxx . . $ JE_byte# shotRepeatcxx . . $ shotRepeat.[11], shotMultiPoscxx . . $ shotMultiPos.[11];
187 JE_booleancxx . . $ JE_boolean# portConfigChangecxx . . $ portConfigChange., portConfigDonecxx . . $ portConfigDone.;
188
189 /* Level Data */
190 char lastLevelNamecxx . . $ lastLevelName.[11], levelNamecxx . . $ levelName.[11]; /* string [10] */
191 JE_bytecxx . . $ JE_byte# mainLevelcxx . . $ mainLevel., nextLevelcxx . . $ nextLevel., saveLevelcxx . . $ saveLevel.; /*Current Level #*/
192
193 /* Keyboard Junk */
194 DosKeySettingscxx . . $ DosKeySettings# dosKeySettingscxx . . $ dosKeySettings.;
195 KeySettingscxx . . $ KeySettings# keySettingscxx . . $ keySettings.;
196
197 /* Configuration */
198 JE_shortintcxx . . $ JE_shortint# levelFiltercxx . . $ levelFilter., levelFilterNewcxx . . $ levelFilterNew., levelBrightnesscxx . . $ levelBrightness., levelBrightnessChgcxx . . $ levelBrightnessChg.;
199 JE_booleancxx . . $ JE_boolean# filtrationAvailcxx . . $ filtrationAvail., filterActivecxx . . $ filterActive., filterFadecxx . . $ filterFade., filterFadeStartcxx . . $ filterFadeStart.;
200
201 JE_booleancxx . . $ JE_boolean# gameJustLoadedcxx . . $ gameJustLoaded.;
202
203 JE_booleancxx . . $ JE_boolean# galagaModecxx . . $ galagaMode.;
204
205 JE_booleancxx . . $ JE_boolean# extraGamecxx . . $ extraGame.;
206
207 JE_booleancxx . . $ JE_boolean# twoPlayerModecxx . . $ twoPlayerMode., twoPlayerLinkedcxx . . $ twoPlayerLinked., onePlayerActioncxx . . $ onePlayerAction., superTyriancxx . . $ superTyrian.;
208 JE_booleancxx . . $ JE_boolean# trentWincxx . . $ trentWin. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
209 JE_bytecxx . . $ JE_byte# superArcadeModecxx . . $ superArcadeMode.;
210
211 JE_bytecxx . . $ JE_byte# superArcadePowerUpcxx . . $ superArcadePowerUp.;
212
213 JE_realcxx . . $ JE_real# linkGunDireccxx . . $ linkGunDirec.;
214 JE_bytecxx . . $ JE_byte# inputDevicecxx . . $ inputDevice.[2] = { 1, 2 }; // 0:any 1:keyboard 2:mouse 3+:joystick
215
216 JE_bytecxx . . $ JE_byte# secretHintcxx . . $ secretHint.;
217 JE_bytecxx . . $ JE_byte# background3overcxx . . $ background3over.;
218 JE_bytecxx . . $ JE_byte# background2overcxx . . $ background2over.;
219 JE_bytecxx . . $ JE_byte# gammaCorrectioncxx . . $ gammaCorrection.;
220 JE_booleancxx . . $ JE_boolean# superPausecxx . . $ superPause. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
221 JE_booleancxx . . $ JE_boolean# explosionTransparentcxx . . $ explosionTransparent.,
222 youAreCheatingcxx . . $ youAreCheating.,
223 displayScorecxx . . $ displayScore.,
224 background2cxx . . $ background2., smoothScrollcxx . . $ smoothScroll., wildcxx . . $ wild., superWildcxx . . $ superWild., starActivecxx . . $ starActive.,
225 topEnemyOvercxx . . $ topEnemyOver.,
226 skyEnemyOverAllcxx . . $ skyEnemyOverAll.,
227 background2notTransparentcxx . . $ background2notTransparent.;
228
229 JE_bytecxx . . $ JE_byte# soundEffectscxx . . $ soundEffects.; // dummy value for config
230 JE_bytecxx . . $ JE_byte# versionNumcxx . . $ versionNum.; /* SW 1.0 and SW/Reg 1.1 = 0 or 1
231 * EA 1.2 = 2 */
232
233 JE_bytecxx . . $ JE_byte# fastPlaycxx . . $ fastPlay.;
234 JE_booleancxx . . $ JE_boolean# pentiumModecxx . . $ pentiumMode.;
235
236 /* Savegame files */
237 JE_bytecxx . . $ JE_byte# gameSpeedcxx . . $ gameSpeed.;
238 JE_bytecxx . . $ JE_byte# processorTypecxx . . $ processorType.; /* 1=386 2=486 3=Pentium Hyper */
239
240 JE_SaveFilesTypecxx . . $ JE_SaveFilesType# saveFilescxx . . $ saveFiles.; /*array[1..saveLevelnum] of savefiletype;*/
241 JE_SaveGameTempcxx . . $ JE_SaveGameTemp# saveTempcxx . . $ saveTemp.;
242
243 JE_wordcxx . . $ JE_word# editorLevelcxx . . $ editorLevel.; /*Initial value 800*/
244
245 Configcxx . . $ Config# opentyrian_configcxx . . $ opentyrian_config.; // implicitly initialized
246
247 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! load_opentyrian_configcxx . . $ load_opentyrian_config(c9857a73d68e59ba).(void)
248 {
249 // defaults
250 fullscreen_displaycxx . . $ fullscreen_display. = -1;
251 set_scaler_by_namecxx . . $ set_scaler_by_name(85c52e162fed56f9).("Scale2x");
252 memcpycxx . . $ memcpy(cc817cb175f282d).(keySettingscxx . . $ keySettings., defaultKeySettingscxx . . $ defaultKeySettings., sizeof(keySettingscxx . . $ keySettings.));
253
254 Configcxx . . $ Config# *config = &opentyrian_configcxx . . $ opentyrian_config.;
255
256 FILEcxx . . $ FILE# *file = dir_fopen_warncxx . . $ dir_fopen_warn(2493aa730c89ee72).(get_user_directorycxx . . $ get_user_directory(33a1f659e94feb42).(), "opentyrian.cfg", "r");
257 if (file == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
258 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
259
260 if (!config_parsecxx . . $ config_parse(7d28d4b21896e09c).(config, file))
261 {
262 fclosecxx . . $ fclose(89bc1efcdac0ca22).(file);
263
264 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
265 }
266
267 ConfigSectioncxx . . $ ConfigSection# *section;
268
269 section = config_find_sectioncxx . . $ config_find_section(9d60c5d7489db765).(config, "video", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
270 if (section != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
271 {
272 config_get_int_optioncxx . . $ config_get_int_option(e9b2851f0de0b00d).(section, "fullscreen", &fullscreen_displaycxx . . $ fullscreen_display.);
273
274 const char *scaler;
275 if (config_get_string_optioncxx . . $ config_get_string_option(667c6ff1f014f85c).(section, "scaler", &scaler))
276 set_scaler_by_namecxx . . $ set_scaler_by_name(85c52e162fed56f9).(scaler);
277
278 const char *scaling_mode;
279 if (config_get_string_optioncxx . . $ config_get_string_option(667c6ff1f014f85c).(section, "scaling_mode", &scaling_mode))
280 set_scaling_mode_by_namecxx . . $ set_scaling_mode_by_name(c5f7da30cbc0f4e9).(scaling_mode);
281 }
282
283 section = config_find_sectioncxx . . $ config_find_section(9d60c5d7489db765).(config, "keyboard", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
284 if (section != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
285 {
286 for (size_t i = 0; i < COUNTOFcxx . . $ `src/opentyr.h:27:9`!(keySettings); ++i)
287 {
288 const char *keyName;
289 if (config_get_string_optioncxx . . $ config_get_string_option(667c6ff1f014f85c).(section, keySettingNamescxx . . $ keySettingNames.[i], &keyName))
290 {
291 SDL_Scancodecxx . . $ SDL_Scancode# scancode = SDL_GetScancodeFromNamecxx . . $ SDL_GetScancodeFromName(fb4900f4c3435660).(keyName);
292 if (scancode != SDL_SCANCODE_UNKNOWNcxx . . $ SDL_SCANCODE_UNKNOWN.)
293 keySettingscxx . . $ keySettings.[i] = scancode;
294 }
295 }
296 }
297
298 fclosecxx . . $ fclose(89bc1efcdac0ca22).(file);
299
300 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
301 }
302
303 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! save_opentyrian_configcxx . . $ save_opentyrian_config(c9857a73d68e59ba).(void)
304 {
305 Configcxx . . $ Config# *config = &opentyrian_configcxx . . $ opentyrian_config.;
306
307 ConfigSectioncxx . . $ ConfigSection# *section;
308
309 section = config_find_or_add_sectioncxx . . $ config_find_or_add_section(9d60c5d7489db765).(config, "video", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
310 if (section == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
311 exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!); // out of memory
312
313 config_set_int_optioncxx . . $ config_set_int_option(3efcdbae08d7b398).(section, "fullscreen", fullscreen_displaycxx . . $ fullscreen_display.);
314
315 config_set_string_optioncxx . . $ config_set_string_option(b1b38906554e988).(section, "scaler", scalerscxx . . $ scalers.[scalercxx . . $ scaler.].namecxx . . $ Scalers#name.);
316
317 config_set_string_optioncxx . . $ config_set_string_option(b1b38906554e988).(section, "scaling_mode", scaling_mode_namescxx . . $ scaling_mode_names.[scaling_modecxx . . $ scaling_mode.]);
318
319 section = config_find_or_add_sectioncxx . . $ config_find_or_add_section(9d60c5d7489db765).(config, "keyboard", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
320 if (section == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
321 exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!); // out of memory
322
323 for (size_t i = 0; i < COUNTOFcxx . . $ `src/opentyr.h:27:9`!(keySettings); ++i)
324 {
325 const char *keyName = SDL_GetScancodeNamecxx . . $ SDL_GetScancodeName(784ff5cdfe45052d).(keySettingscxx . . $ keySettings.[i]);
326 if (keyName[0] == '\0')
327 keyName = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
328 config_set_string_optioncxx . . $ config_set_string_option(b1b38906554e988).(section, keySettingNamescxx . . $ keySettingNames.[i], keyName);
329 }
330
331 #ifndef TARGET_WIN32
332 mkdircxx . . $ mkdir(1df18506ef0a631b).(get_user_directorycxx . . $ get_user_directory(33a1f659e94feb42).(), 0700);
333 #else
334 mkdir(get_user_directory());
335 #endif
336
337 FILEcxx . . $ FILE# *file = dir_fopencxx . . $ dir_fopen(2493aa730c89ee72).(get_user_directorycxx . . $ get_user_directory(33a1f659e94feb42).(), "opentyrian.cfg", "w");
338 if (file == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
339 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
340
341 config_writecxx . . $ config_write(743dd42310ca6b83).(config, file);
342
343 #if _POSIX_C_SOURCEcxx . . $ `<external>/18206667465210621810/features.h:313:10`! >= 1 || _XOPEN_SOURCEcxx . . $ `<external>/18206667465210621810/features.h:228:10`! || _POSIX_SOURCEcxx . . $ `<external>/18206667465210621810/features.h:311:10`!
344 fsynccxx . . $ fsync(7864480464b09eea).(filenocxx . . $ fileno(89bc1efcdac0ca22).(file));
345 #endif
346 fclosecxx . . $ fclose(89bc1efcdac0ca22).(file);
347
348 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
349 }
350
351 static void playeritems_to_pitemscxx . . $ playeritems_to_pitems(1aa91e4120bdac6).(JE_PItemsTypecxx . . $ JE_PItemsType# pItems, PlayerItemscxx . . $ PlayerItems# *items, JE_bytecxx . . $ JE_byte# initial_episode_num)
352 {
353 pItems[0] = items->weaponcxx . . $ $anonymous_type_55bed0e189d5bed_2#weapon.[FRONT_WEAPONcxx . . $ FRONT_WEAPON.].idcxx . . $ $anonymous_type_55bed0e189d5bed_2#$anonymous_type_3#id.;
354 pItems[1] = items->weaponcxx . . $ $anonymous_type_55bed0e189d5bed_2#weapon.[REAR_WEAPONcxx . . $ REAR_WEAPON.].idcxx . . $ $anonymous_type_55bed0e189d5bed_2#$anonymous_type_3#id.;
355 pItems[2] = items->super_arcade_modecxx . . $ $anonymous_type_55bed0e189d5bed_2#super_arcade_mode.;
356 pItems[3] = items->sidekickcxx . . $ $anonymous_type_55bed0e189d5bed_2#sidekick.[LEFT_SIDEKICKcxx . . $ LEFT_SIDEKICK.];
357 pItems[4] = items->sidekickcxx . . $ $anonymous_type_55bed0e189d5bed_2#sidekick.[RIGHT_SIDEKICKcxx . . $ RIGHT_SIDEKICK.];
358 pItems[5] = items->generatorcxx . . $ $anonymous_type_55bed0e189d5bed_2#generator.;
359 pItems[6] = items->sidekick_levelcxx . . $ $anonymous_type_55bed0e189d5bed_2#sidekick_level.;
360 pItems[7] = items->sidekick_seriescxx . . $ $anonymous_type_55bed0e189d5bed_2#sidekick_series.;
361 pItems[8] = initial_episode_num;
362 pItems[9] = items->shieldcxx . . $ $anonymous_type_55bed0e189d5bed_2#shield.;
363 pItems[10] = items->specialcxx . . $ $anonymous_type_55bed0e189d5bed_2#special.;
364 pItems[11] = items->shipcxx . . $ $anonymous_type_55bed0e189d5bed_2#ship.;
365 }
366
367 static void pitems_to_playeritemscxx . . $ pitems_to_playeritems(d13ed797afe13992).(PlayerItemscxx . . $ PlayerItems# *items, JE_PItemsTypecxx . . $ JE_PItemsType# pItems, JE_bytecxx . . $ JE_byte# *initial_episode_num)
368 {
369 items->weaponcxx . . $ $anonymous_type_55bed0e189d5bed_2#weapon.[FRONT_WEAPONcxx . . $ FRONT_WEAPON.].idcxx . . $ $anonymous_type_55bed0e189d5bed_2#$anonymous_type_3#id. = pItems[0];
370 items->weaponcxx . . $ $anonymous_type_55bed0e189d5bed_2#weapon.[REAR_WEAPONcxx . . $ REAR_WEAPON.].idcxx . . $ $anonymous_type_55bed0e189d5bed_2#$anonymous_type_3#id. = pItems[1];
371 items->super_arcade_modecxx . . $ $anonymous_type_55bed0e189d5bed_2#super_arcade_mode. = pItems[2];
372 items->sidekickcxx . . $ $anonymous_type_55bed0e189d5bed_2#sidekick.[LEFT_SIDEKICKcxx . . $ LEFT_SIDEKICK.] = pItems[3];
373 items->sidekickcxx . . $ $anonymous_type_55bed0e189d5bed_2#sidekick.[RIGHT_SIDEKICKcxx . . $ RIGHT_SIDEKICK.] = pItems[4];
374 items->generatorcxx . . $ $anonymous_type_55bed0e189d5bed_2#generator. = pItems[5];
375 items->sidekick_levelcxx . . $ $anonymous_type_55bed0e189d5bed_2#sidekick_level. = pItems[6];
376 items->sidekick_seriescxx . . $ $anonymous_type_55bed0e189d5bed_2#sidekick_series. = pItems[7];
377 if (initial_episode_num != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
378 *initial_episode_num = pItems[8];
379 items->shieldcxx . . $ $anonymous_type_55bed0e189d5bed_2#shield. = pItems[9];
380 items->specialcxx . . $ $anonymous_type_55bed0e189d5bed_2#special. = pItems[10];
381 items->shipcxx . . $ $anonymous_type_55bed0e189d5bed_2#ship. = pItems[11];
382 }
383
384 void JE_saveGamecxx . . $ JE_saveGame(9d0d6db36a0a8a6f).(JE_bytecxx . . $ JE_byte# slot, const char *name)
385 {
386 saveFilescxx . . $ saveFiles.[slot-1].initialDifficultycxx . . $ $anonymous_type_5227559294d527ce_2#initialDifficulty. = initialDifficultycxx . . $ initialDifficulty.;
387 saveFilescxx . . $ saveFiles.[slot-1].gameHasRepeatedcxx . . $ $anonymous_type_5227559294d527ce_2#gameHasRepeated. = gameHasRepeatedcxx . . $ gameHasRepeated.;
388 saveFilescxx . . $ saveFiles.[slot-1].levelcxx . . $ $anonymous_type_5227559294d527ce_2#level. = saveLevelcxx . . $ saveLevel.;
389
390 if (superTyriancxx . . $ superTyrian.)
391 playercxx . . $ player.[0].itemscxx . . $ $anonymous_type_55bed0e189d5bed_4#items..super_arcade_modecxx . . $ $anonymous_type_55bed0e189d5bed_2#super_arcade_mode. = SA_SUPERTYRIANcxx . . $ SA_SUPERTYRIAN.;
392 else if (superArcadeModecxx . . $ superArcadeMode. == SA_NONEcxx . . $ SA_NONE. && onePlayerActioncxx . . $ onePlayerAction.)
393 playercxx . . $ player.[0].itemscxx . . $ $anonymous_type_55bed0e189d5bed_4#items..super_arcade_modecxx . . $ $anonymous_type_55bed0e189d5bed_2#super_arcade_mode. = SA_ARCADEcxx . . $ SA_ARCADE.;
394 else
395 playercxx . . $ player.[0].itemscxx . . $ $anonymous_type_55bed0e189d5bed_4#items..super_arcade_modecxx . . $ $anonymous_type_55bed0e189d5bed_2#super_arcade_mode. = superArcadeModecxx . . $ superArcadeMode.;
396
397 playeritems_to_pitemscxx . . $ playeritems_to_pitems(1aa91e4120bdac6).(saveFilescxx . . $ saveFiles.[slot-1].itemscxx . . $ $anonymous_type_5227559294d527ce_2#items., &playercxx . . $ player.[0].itemscxx . . $ $anonymous_type_55bed0e189d5bed_4#items., initial_episode_numcxx . . $ initial_episode_num.);
398
399 if (twoPlayerModecxx . . $ twoPlayerMode.)
400 playeritems_to_pitemscxx . . $ playeritems_to_pitems(1aa91e4120bdac6).(saveFilescxx . . $ saveFiles.[slot-1].lastItemscxx . . $ $anonymous_type_5227559294d527ce_2#lastItems., &playercxx . . $ player.[1].itemscxx . . $ $anonymous_type_55bed0e189d5bed_4#items., 0);
401 else
402 playeritems_to_pitemscxx . . $ playeritems_to_pitems(1aa91e4120bdac6).(saveFilescxx . . $ saveFiles.[slot-1].lastItemscxx . . $ $anonymous_type_5227559294d527ce_2#lastItems., &playercxx . . $ player.[0].last_itemscxx . . $ $anonymous_type_55bed0e189d5bed_4#last_items., 0);
403
404 saveFilescxx . . $ saveFiles.[slot-1].scorecxx . . $ $anonymous_type_5227559294d527ce_2#score. = playercxx . . $ player.[0].cashcxx . . $ $anonymous_type_55bed0e189d5bed_4#cash.;
405 saveFilescxx . . $ saveFiles.[slot-1].score2cxx . . $ $anonymous_type_5227559294d527ce_2#score2. = playercxx . . $ player.[1].cashcxx . . $ $anonymous_type_55bed0e189d5bed_4#cash.;
406
407 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[slot-1].levelNamecxx . . $ $anonymous_type_5227559294d527ce_2#levelName., &lastLevelNamecxx . . $ lastLevelName., sizeof(lastLevelNamecxx . . $ lastLevelName.));
408 saveFilescxx . . $ saveFiles.[slot-1].cubescxx . . $ $anonymous_type_5227559294d527ce_2#cubes. = lastCubeMaxcxx . . $ lastCubeMax.;
409
410 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(lastLevelNamecxx . . $ lastLevelName., "Completed") == 0)
411 {
412 tempcxx . . $ temp. = episodeNumcxx . . $ episodeNum. - 1;
413 if (tempcxx . . $ temp. < 1)
414 {
415 tempcxx . . $ temp. = EPISODE_AVAILABLEcxx . . $ `src/episodes.h:30:9`!; /* JE: {Episodemax is 4 for completion purposes} */
416 }
417 saveFilescxx . . $ saveFiles.[slot-1].episodecxx . . $ $anonymous_type_5227559294d527ce_2#episode. = tempcxx . . $ temp.;
418 }
419 else
420 {
421 saveFilescxx . . $ saveFiles.[slot-1].episodecxx . . $ $anonymous_type_5227559294d527ce_2#episode. = episodeNumcxx . . $ episodeNum.;
422 }
423
424 saveFilescxx . . $ saveFiles.[slot-1].difficultycxx . . $ $anonymous_type_5227559294d527ce_2#difficulty. = difficultyLevelcxx . . $ difficultyLevel.;
425 saveFilescxx . . $ saveFiles.[slot-1].secretHintcxx . . $ $anonymous_type_5227559294d527ce_2#secretHint. = secretHintcxx . . $ secretHint.;
426 saveFilescxx . . $ saveFiles.[slot-1].input1cxx . . $ $anonymous_type_5227559294d527ce_2#input1. = inputDevicecxx . . $ inputDevice.[0];
427 saveFilescxx . . $ saveFiles.[slot-1].input2cxx . . $ $anonymous_type_5227559294d527ce_2#input2. = inputDevicecxx . . $ inputDevice.[1];
428
429 strcpycxx . . $ strcpy(b7b3a83273496486).(saveFilescxx . . $ saveFiles.[slot-1].namecxx . . $ $anonymous_type_5227559294d527ce_2#name., name);
430
431 for (uintcxx . . $ uint# port = 0; port < 2; ++port)
432 {
433 // if two-player, use first player's front and second player's rear weapon
434 saveFilescxx . . $ saveFiles.[slot-1].powercxx . . $ $anonymous_type_5227559294d527ce_2#power.[port] = playercxx . . $ player.[twoPlayerModecxx . . $ twoPlayerMode. ? port : 0].itemscxx . . $ $anonymous_type_55bed0e189d5bed_4#items..weaponcxx . . $ $anonymous_type_55bed0e189d5bed_2#weapon.[port].powercxx . . $ $anonymous_type_55bed0e189d5bed_2#$anonymous_type_3#power.;
435 }
436
437 JE_saveConfigurationcxx . . $ JE_saveConfiguration(49f6e7a06ebc5aa8).();
438 }
439
440 void JE_loadGamecxx . . $ JE_loadGame(ac50b47256ae7414).(JE_bytecxx . . $ JE_byte# slot)
441 {
442 superTyriancxx . . $ superTyrian. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
443 onePlayerActioncxx . . $ onePlayerAction. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
444 twoPlayerModecxx . . $ twoPlayerMode. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
445 extraGamecxx . . $ extraGame. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
446 galagaModecxx . . $ galagaMode. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
447
448 initialDifficultycxx . . $ initialDifficulty. = saveFilescxx . . $ saveFiles.[slot-1].initialDifficultycxx . . $ $anonymous_type_5227559294d527ce_2#initialDifficulty.;
449 gameHasRepeatedcxx . . $ gameHasRepeated. = saveFilescxx . . $ saveFiles.[slot-1].gameHasRepeatedcxx . . $ $anonymous_type_5227559294d527ce_2#gameHasRepeated.;
450 twoPlayerModecxx . . $ twoPlayerMode. = (slot-1) > 10;
451 difficultyLevelcxx . . $ difficultyLevel. = saveFilescxx . . $ saveFiles.[slot-1].difficultycxx . . $ $anonymous_type_5227559294d527ce_2#difficulty.;
452
453 pitems_to_playeritemscxx . . $ pitems_to_playeritems(d13ed797afe13992).(&playercxx . . $ player.[0].itemscxx . . $ $anonymous_type_55bed0e189d5bed_4#items., saveFilescxx . . $ saveFiles.[slot-1].itemscxx . . $ $anonymous_type_5227559294d527ce_2#items., &initial_episode_numcxx . . $ initial_episode_num.);
454
455 superArcadeModecxx . . $ superArcadeMode. = playercxx . . $ player.[0].itemscxx . . $ $anonymous_type_55bed0e189d5bed_4#items..super_arcade_modecxx . . $ $anonymous_type_55bed0e189d5bed_2#super_arcade_mode.;
456
457 if (superArcadeModecxx . . $ superArcadeMode. == SA_SUPERTYRIANcxx . . $ SA_SUPERTYRIAN.)
458 superTyriancxx . . $ superTyrian. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
459 if (superArcadeModecxx . . $ superArcadeMode. != SA_NONEcxx . . $ SA_NONE.)
460 onePlayerActioncxx . . $ onePlayerAction. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
461 if (superArcadeModecxx . . $ superArcadeMode. > SA_NORTSHIPZcxx . . $ SA_NORTSHIPZ.)
462 superArcadeModecxx . . $ superArcadeMode. = SA_NONEcxx . . $ SA_NONE.;
463
464 if (twoPlayerModecxx . . $ twoPlayerMode.)
465 {
466 onePlayerActioncxx . . $ onePlayerAction. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
467
468 pitems_to_playeritemscxx . . $ pitems_to_playeritems(d13ed797afe13992).(&playercxx . . $ player.[1].itemscxx . . $ $anonymous_type_55bed0e189d5bed_4#items., saveFilescxx . . $ saveFiles.[slot-1].lastItemscxx . . $ $anonymous_type_5227559294d527ce_2#lastItems., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
469 }
470 else
471 {
472 pitems_to_playeritemscxx . . $ pitems_to_playeritems(d13ed797afe13992).(&playercxx . . $ player.[0].last_itemscxx . . $ $anonymous_type_55bed0e189d5bed_4#last_items., saveFilescxx . . $ saveFiles.[slot-1].lastItemscxx . . $ $anonymous_type_5227559294d527ce_2#lastItems., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
473 }
474
475 /* Compatibility with old version */
476 if (playercxx . . $ player.[1].itemscxx . . $ $anonymous_type_55bed0e189d5bed_4#items..sidekick_levelcxx . . $ $anonymous_type_55bed0e189d5bed_2#sidekick_level. < 101)
477 {
478 playercxx . . $ player.[1].itemscxx . . $ $anonymous_type_55bed0e189d5bed_4#items..sidekick_levelcxx . . $ $anonymous_type_55bed0e189d5bed_2#sidekick_level. = 101;
479 playercxx . . $ player.[1].itemscxx . . $ $anonymous_type_55bed0e189d5bed_4#items..sidekick_seriescxx . . $ $anonymous_type_55bed0e189d5bed_2#sidekick_series. = playercxx . . $ player.[1].itemscxx . . $ $anonymous_type_55bed0e189d5bed_4#items..sidekickcxx . . $ $anonymous_type_55bed0e189d5bed_2#sidekick.[LEFT_SIDEKICKcxx . . $ LEFT_SIDEKICK.];
480 }
481
482 playercxx . . $ player.[0].cashcxx . . $ $anonymous_type_55bed0e189d5bed_4#cash. = saveFilescxx . . $ saveFiles.[slot-1].scorecxx . . $ $anonymous_type_5227559294d527ce_2#score.;
483 playercxx . . $ player.[1].cashcxx . . $ $anonymous_type_55bed0e189d5bed_4#cash. = saveFilescxx . . $ saveFiles.[slot-1].score2cxx . . $ $anonymous_type_5227559294d527ce_2#score2.;
484
485 mainLevelcxx . . $ mainLevel. = saveFilescxx . . $ saveFiles.[slot-1].levelcxx . . $ $anonymous_type_5227559294d527ce_2#level.;
486 cubeMaxcxx . . $ cubeMax. = saveFilescxx . . $ saveFiles.[slot-1].cubescxx . . $ $anonymous_type_5227559294d527ce_2#cubes.;
487 lastCubeMaxcxx . . $ lastCubeMax. = cubeMaxcxx . . $ cubeMax.;
488
489 secretHintcxx . . $ secretHint. = saveFilescxx . . $ saveFiles.[slot-1].secretHintcxx . . $ $anonymous_type_5227559294d527ce_2#secretHint.;
490 inputDevicecxx . . $ inputDevice.[0] = saveFilescxx . . $ saveFiles.[slot-1].input1cxx . . $ $anonymous_type_5227559294d527ce_2#input1.;
491 inputDevicecxx . . $ inputDevice.[1] = saveFilescxx . . $ saveFiles.[slot-1].input2cxx . . $ $anonymous_type_5227559294d527ce_2#input2.;
492
493 for (uintcxx . . $ uint# port = 0; port < 2; ++port)
494 {
495 // if two-player, use first player's front and second player's rear weapon
496 playercxx . . $ player.[twoPlayerModecxx . . $ twoPlayerMode. ? port : 0].itemscxx . . $ $anonymous_type_55bed0e189d5bed_4#items..weaponcxx . . $ $anonymous_type_55bed0e189d5bed_2#weapon.[port].powercxx . . $ $anonymous_type_55bed0e189d5bed_2#$anonymous_type_3#power. = saveFilescxx . . $ saveFiles.[slot-1].powercxx . . $ $anonymous_type_5227559294d527ce_2#power.[port];
497 }
498
499 int episode = saveFilescxx . . $ saveFiles.[slot-1].episodecxx . . $ $anonymous_type_5227559294d527ce_2#episode.;
500
501 memcpycxx . . $ memcpy(cc817cb175f282d).(&levelNamecxx . . $ levelName., &saveFilescxx . . $ saveFiles.[slot-1].levelNamecxx . . $ $anonymous_type_5227559294d527ce_2#levelName., sizeof(levelNamecxx . . $ levelName.));
502
503 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(levelNamecxx . . $ levelName., "Completed") == 0)
504 {
505 if (episode == EPISODE_AVAILABLEcxx . . $ `src/episodes.h:30:9`!)
506 episode = 1;
507 else if (episode < EPISODE_AVAILABLEcxx . . $ `src/episodes.h:30:9`!)
508 episode++;
509 /* Increment episode. Episode EPISODE_AVAILABLE goes to 1. */
510 }
511
512 JE_initEpisodecxx . . $ JE_initEpisode(ac50b47256ae7414).(episode);
513 saveLevelcxx . . $ saveLevel. = mainLevelcxx . . $ mainLevel.;
514 memcpycxx . . $ memcpy(cc817cb175f282d).(&lastLevelNamecxx . . $ lastLevelName., &levelNamecxx . . $ levelName., sizeof(levelNamecxx . . $ levelName.));
515 }
516
517 void JE_initProcessorTypecxx . . $ JE_initProcessorType(49f6e7a06ebc5aa8).(void)
518 {
519 /* SYN: Originally this proc looked at your hardware specs and chose appropriate options. We don't care, so I'll just set
520 decent defaults here. */
521
522 wildcxx . . $ wild. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
523 superWildcxx . . $ superWild. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
524 smoothScrollcxx . . $ smoothScroll. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
525 explosionTransparentcxx . . $ explosionTransparent. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
526 filtrationAvailcxx . . $ filtrationAvail. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
527 background2cxx . . $ background2. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
528 displayScorecxx . . $ displayScore. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
529
530 switch (processorTypecxx . . $ processorType.)
531 {
532 case 1: /* 386 */
533 background2cxx . . $ background2. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
534 displayScorecxx . . $ displayScore. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
535 explosionTransparentcxx . . $ explosionTransparent. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
536 break;
537 case 2: /* 486 - Default */
538 break;
539 case 3: /* High Detail */
540 smoothScrollcxx . . $ smoothScroll. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
541 break;
542 case 4: /* Pentium */
543 wildcxx . . $ wild. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
544 filtrationAvailcxx . . $ filtrationAvail. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
545 break;
546 case 5: /* Nonstandard VGA */
547 smoothScrollcxx . . $ smoothScroll. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
548 break;
549 case 6: /* SuperWild */
550 wildcxx . . $ wild. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
551 superWildcxx . . $ superWild. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
552 filtrationAvailcxx . . $ filtrationAvail. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
553 break;
554 }
555
556 switch (gameSpeedcxx . . $ gameSpeed.)
557 {
558 case 1: /* Slug Mode */
559 fastPlaycxx . . $ fastPlay. = 3;
560 break;
561 case 2: /* Slower */
562 fastPlaycxx . . $ fastPlay. = 4;
563 break;
564 case 3: /* Slow */
565 fastPlaycxx . . $ fastPlay. = 5;
566 break;
567 case 4: /* Normal */
568 fastPlaycxx . . $ fastPlay. = 0;
569 break;
570 case 5: /* Pentium Hyper */
571 fastPlaycxx . . $ fastPlay. = 1;
572 break;
573 }
574
575 }
576
577 void JE_setNewGameSpeedcxx . . $ JE_setNewGameSpeed(49f6e7a06ebc5aa8).(void)
578 {
579 pentiumModecxx . . $ pentiumMode. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
580
581 Uint16cxx . . $ Uint16# speed;
582 switch (fastPlaycxx . . $ fastPlay.)
583 {
584 default:
585 assertcxx . . $ `/usr/include/assert.h:50:10`!(false);
586 // fall through
587 case 0: // Normal
588 speed = 0x4300;
589 smoothScrollcxx . . $ smoothScroll. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
590 frameCountMaxcxx . . $ frameCountMax. = 2;
591 break;
592 case 1: // Pentium Hyper
593 speed = 0x3000;
594 smoothScrollcxx . . $ smoothScroll. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
595 frameCountMaxcxx . . $ frameCountMax. = 2;
596 break;
597 case 2:
598 speed = 0x2000;
599 smoothScrollcxx . . $ smoothScroll. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
600 frameCountMaxcxx . . $ frameCountMax. = 2;
601 break;
602 case 3: // Slug mode
603 speed = 0x5300;
604 smoothScrollcxx . . $ smoothScroll. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
605 frameCountMaxcxx . . $ frameCountMax. = 4;
606 break;
607 case 4: // Slower
608 speed = 0x4300;
609 smoothScrollcxx . . $ smoothScroll. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
610 frameCountMaxcxx . . $ frameCountMax. = 3;
611 break;
612 case 5: // Slow
613 speed = 0x4300;
614 smoothScrollcxx . . $ smoothScroll. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
615 frameCountMaxcxx . . $ frameCountMax. = 2;
616 pentiumModecxx . . $ pentiumMode. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
617 break;
618 }
619
620 setDelaySpeedcxx . . $ setDelaySpeed(ed53e3bbd3fa2f69).(speed);
621 setDelaycxx . . $ setDelay(d4f767463ce0a6b3).(frameCountMaxcxx . . $ frameCountMax.);
622 }
623
624 void JE_encryptSaveTempcxx . . $ JE_encryptSaveTemp(49f6e7a06ebc5aa8).(void)
625 {
626 JE_SaveGameTempcxx . . $ JE_SaveGameTemp# s3;
627 JE_wordcxx . . $ JE_word# x;
628 JE_bytecxx . . $ JE_byte# y;
629
630 memcpycxx . . $ memcpy(cc817cb175f282d).(&s3, &saveTempcxx . . $ saveTemp., sizeof(s3));
631
632 y = 0;
633 for (x = 0; x < SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!; x++)
634 {
635 y += s3[x];
636 }
637 saveTempcxx . . $ saveTemp.[SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!] = y;
638
639 y = 0;
640 for (x = 0; x < SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!; x++)
641 {
642 y -= s3[x];
643 }
644 saveTempcxx . . $ saveTemp.[SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!+1] = y;
645
646 y = 1;
647 for (x = 0; x < SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!; x++)
648 {
649 y = (y * s3[x]) + 1;
650 }
651 saveTempcxx . . $ saveTemp.[SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!+2] = y;
652
653 y = 0;
654 for (x = 0; x < SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!; x++)
655 {
656 y = y ^ s3[x];
657 }
658 saveTempcxx . . $ saveTemp.[SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!+3] = y;
659
660 for (x = 0; x < SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!; x++)
661 {
662 saveTempcxx . . $ saveTemp.[x] = saveTempcxx . . $ saveTemp.[x] ^ cryptKeycxx . . $ cryptKey.[(x+1) % 10];
663 if (x > 0)
664 {
665 saveTempcxx . . $ saveTemp.[x] = saveTempcxx . . $ saveTemp.[x] ^ saveTempcxx . . $ saveTemp.[x - 1];
666 }
667 }
668 }
669
670 void JE_decryptSaveTempcxx . . $ JE_decryptSaveTemp(49f6e7a06ebc5aa8).(void)
671 {
672 JE_booleancxx . . $ JE_boolean# correct = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
673 JE_SaveGameTempcxx . . $ JE_SaveGameTemp# s2;
674 int x;
675 JE_bytecxx . . $ JE_byte# y;
676
677 /* Decrypt save game file */
678 for (x = (SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`! - 1); x >= 0; x--)
679 {
680 s2[x] = (JE_bytecxx . . $ JE_byte#)saveTempcxx . . $ saveTemp.[x] ^ (JE_bytecxx . . $ JE_byte#)(cryptKeycxx . . $ cryptKey.[(x+1) % 10]);
681 if (x > 0)
682 {
683 s2[x] ^= (JE_bytecxx . . $ JE_byte#)saveTempcxx . . $ saveTemp.[x - 1];
684 }
685
686 }
687
688 /* for (x = 0; x < SAVE_FILE_SIZE; x++) printf("%c", s2[x]); */
689
690 /* Check save file for correctitude */
691 y = 0;
692 for (x = 0; x < SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!; x++)
693 {
694 y += s2[x];
695 }
696 if (saveTempcxx . . $ saveTemp.[SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!] != y)
697 {
698 correct = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
699 printfcxx . . $ printf(581fddd72a8db8fc).("Failed additive checksum: %d vs %d\n", saveTempcxx . . $ saveTemp.[SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!], y);
700 }
701
702 y = 0;
703 for (x = 0; x < SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!; x++)
704 {
705 y -= s2[x];
706 }
707 if (saveTempcxx . . $ saveTemp.[SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!+1] != y)
708 {
709 correct = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
710 printfcxx . . $ printf(581fddd72a8db8fc).("Failed subtractive checksum: %d vs %d\n", saveTempcxx . . $ saveTemp.[SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!+1], y);
711 }
712
713 y = 1;
714 for (x = 0; x < SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!; x++)
715 {
716 y = (y * s2[x]) + 1;
717 }
718 if (saveTempcxx . . $ saveTemp.[SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!+2] != y)
719 {
720 correct = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
721 printfcxx . . $ printf(581fddd72a8db8fc).("Failed multiplicative checksum: %d vs %d\n", saveTempcxx . . $ saveTemp.[SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!+2], y);
722 }
723
724 y = 0;
725 for (x = 0; x < SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!; x++)
726 {
727 y = y ^ s2[x];
728 }
729 if (saveTempcxx . . $ saveTemp.[SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!+3] != y)
730 {
731 correct = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
732 printfcxx . . $ printf(581fddd72a8db8fc).("Failed XOR'd checksum: %d vs %d\n", saveTempcxx . . $ saveTemp.[SAVE_FILE_SIZEcxx . . $ `src/config.h:35:9`!+3], y);
733 }
734
735 /* Barf and die if save file doesn't validate */
736 if (!correct)
737 {
738 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Error reading save file!\n");
739 exitcxx . . $ exit(3ca292c338df9bb3).(255);
740 }
741
742 /* Keep decrypted version plz */
743 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveTempcxx . . $ saveTemp., &s2, sizeof(s2));
744 }
745
746 const char *get_user_directorycxx . . $ get_user_directory(33a1f659e94feb42).(void)
747 {
748 static char user_dir[500] = "";
749
750 if (strlencxx . . $ strlen(751346f8406fd082).(user_dir) == 0)
751 {
752 #ifndef TARGET_WIN32
753 char *xdg_config_home = getenvcxx . . $ getenv(a8b8e32347182212).("XDG_CONFIG_HOME");
754 if (xdg_config_home != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
755 {
756 snprintfcxx . . $ snprintf(ea502d73e74c754c).(user_dir, sizeof(user_dir), "%s/opentyrian", xdg_config_home);
757 }
758 else
759 {
760 char *home = getenvcxx . . $ getenv(a8b8e32347182212).("HOME");
761 if (home != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
762 {
763 snprintfcxx . . $ snprintf(ea502d73e74c754c).(user_dir, sizeof(user_dir), "%s/.config/opentyrian", home);
764 }
765 else
766 {
767 strcpycxx . . $ strcpy(b7b3a83273496486).(user_dir, ".");
768 }
769 }
770 #else
771 strcpy(user_dir, ".");
772 #endif
773 }
774
775 return user_dir;
776 }
777
778 // for compatibility
779 Uint8cxx . . $ Uint8# joyButtonAssigncxx . . $ joyButtonAssign.[4] = {1, 4, 5, 5};
780 Uint8cxx . . $ Uint8# inputDevice_cxx . . $ inputDevice_. = 0, jConfigurecxx . . $ jConfigure. = 0, midiPortcxx . . $ midiPort. = 1;
781
782 void JE_loadConfigurationcxx . . $ JE_loadConfiguration(49f6e7a06ebc5aa8).(void)
783 {
784 FILEcxx . . $ FILE# *fi;
785 int z;
786 JE_bytecxx . . $ JE_byte# *p;
787 int y;
788
789 fi = dir_fopen_warncxx . . $ dir_fopen_warn(2493aa730c89ee72).(get_user_directorycxx . . $ get_user_directory(33a1f659e94feb42).(), "tyrian.cfg", "rb");
790 if (fi && ftell_eofcxx . . $ ftell_eof(1dcafcd8ef4c6e6c).(fi) == 28)
791 {
792 background2cxx . . $ background2. = 0;
793 fread_bool_diecxx . . $ fread_bool_die(907b9e3ee78d059).(&background2cxx . . $ background2., fi);
794 fread_u8_diecxx . . $ fread_u8_die(77ebc59a7bf9f340).(&gameSpeedcxx . . $ gameSpeed., 1, fi);
795
796 fread_u8_diecxx . . $ fread_u8_die(77ebc59a7bf9f340).(&inputDevice_cxx . . $ inputDevice_., 1, fi);
797 fread_u8_diecxx . . $ fread_u8_die(77ebc59a7bf9f340).(&jConfigurecxx . . $ jConfigure., 1, fi);
798
799 fread_u8_diecxx . . $ fread_u8_die(77ebc59a7bf9f340).(&versionNumcxx . . $ versionNum., 1, fi);
800
801 fread_u8_diecxx . . $ fread_u8_die(77ebc59a7bf9f340).(&processorTypecxx . . $ processorType., 1, fi);
802 fread_u8_diecxx . . $ fread_u8_die(77ebc59a7bf9f340).(&midiPortcxx . . $ midiPort., 1, fi);
803 fread_u8_diecxx . . $ fread_u8_die(77ebc59a7bf9f340).(&soundEffectscxx . . $ soundEffects., 1, fi);
804 fread_u8_diecxx . . $ fread_u8_die(77ebc59a7bf9f340).(&gammaCorrectioncxx . . $ gammaCorrection., 1, fi);
805 fread_s8_diecxx . . $ fread_s8_die(dc08b0f48459588a).(&difficultyLevelcxx . . $ difficultyLevel., 1, fi);
806
807 fread_u8_diecxx . . $ fread_u8_die(77ebc59a7bf9f340).(joyButtonAssigncxx . . $ joyButtonAssign., 4, fi);
808
809 fread_u16_diecxx . . $ fread_u16_die(c6228d4965a46ad0).(&tyrMusicVolumecxx . . $ tyrMusicVolume., 1, fi);
810 fread_u16_diecxx . . $ fread_u16_die(c6228d4965a46ad0).(&fxVolumecxx . . $ fxVolume., 1, fi);
811
812 fread_u8_diecxx . . $ fread_u8_die(77ebc59a7bf9f340).(inputDevicecxx . . $ inputDevice., 2, fi);
813
814 fread_u8_diecxx . . $ fread_u8_die(77ebc59a7bf9f340).(dosKeySettingscxx . . $ dosKeySettings., 8, fi);
815
816 fclosecxx . . $ fclose(89bc1efcdac0ca22).(fi);
817 }
818 else
819 {
820 printfcxx . . $ printf(581fddd72a8db8fc).("\nInvalid or missing TYRIAN.CFG! Continuing using defaults.\n\n");
821
822 soundEffectscxx . . $ soundEffects. = 1;
823 memcpycxx . . $ memcpy(cc817cb175f282d).(&dosKeySettingscxx . . $ dosKeySettings., &defaultDosKeySettingscxx . . $ defaultDosKeySettings., sizeof(dosKeySettingscxx . . $ dosKeySettings.));
824 background2cxx . . $ background2. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
825 tyrMusicVolumecxx . . $ tyrMusicVolume. = 191;
826 fxVolumecxx . . $ fxVolume. = 191;
827 gammaCorrectioncxx . . $ gammaCorrection. = 0;
828 processorTypecxx . . $ processorType. = 3;
829 gameSpeedcxx . . $ gameSpeed. = 4;
830 }
831
832 load_opentyrian_configcxx . . $ load_opentyrian_config(c9857a73d68e59ba).();
833
834 if (tyrMusicVolumecxx . . $ tyrMusicVolume. > 255)
835 tyrMusicVolumecxx . . $ tyrMusicVolume. = 255;
836 if (fxVolumecxx . . $ fxVolume. > 255)
837 fxVolumecxx . . $ fxVolume. = 255;
838
839 set_volumecxx . . $ set_volume(8fbe6856f5410d23).(tyrMusicVolumecxx . . $ tyrMusicVolume., fxVolumecxx . . $ fxVolume.);
840
841 fi = dir_fopen_warncxx . . $ dir_fopen_warn(2493aa730c89ee72).(get_user_directorycxx . . $ get_user_directory(33a1f659e94feb42).(), "tyrian.sav", "rb");
842 if (fi)
843 {
844
845 fseekcxx . . $ fseek(543fae30d249f6b1).(fi, 0, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:110:9`!);
846 fread_diecxx . . $ fread_die(82d71c9ec5b61e0f).(saveTempcxx . . $ saveTemp., 1, sizeof(saveTempcxx . . $ saveTemp.), fi);
847 JE_decryptSaveTempcxx . . $ JE_decryptSaveTemp(49f6e7a06ebc5aa8).();
848
849 /* SYN: The original mostly blasted the save file into raw memory. However, our lives are not so
850 easy, because the C struct is necessarily a different size. So instead we have to loop
851 through each record and load fields manually. *emo tear* :'( */
852
853 p = saveTempcxx . . $ saveTemp.;
854 for (z = 0; z < SAVE_FILES_NUMcxx . . $ `src/config.h:29:9`!; z++)
855 {
856 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].encodecxx . . $ $anonymous_type_5227559294d527ce_2#encode., p, sizeof(JE_wordcxx . . $ JE_word#)); p += 2;
857 saveFilescxx . . $ saveFiles.[z].encodecxx . . $ $anonymous_type_5227559294d527ce_2#encode. = SDL_SwapLE16cxx . . $ `<external>/7875807700584907893/SDL_endian.h:368:9`!(saveFiles[z].encode);
858
859 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].levelcxx . . $ $anonymous_type_5227559294d527ce_2#level., p, sizeof(JE_wordcxx . . $ JE_word#)); p += 2;
860 saveFilescxx . . $ saveFiles.[z].levelcxx . . $ $anonymous_type_5227559294d527ce_2#level. = SDL_SwapLE16cxx . . $ `<external>/7875807700584907893/SDL_endian.h:368:9`!(saveFiles[z].level);
861
862 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].itemscxx . . $ $anonymous_type_5227559294d527ce_2#items., p, sizeof(JE_PItemsTypecxx . . $ JE_PItemsType#)); p += sizeof(JE_PItemsTypecxx . . $ JE_PItemsType#);
863
864 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].scorecxx . . $ $anonymous_type_5227559294d527ce_2#score., p, sizeof(JE_longintcxx . . $ JE_longint#)); p += 4;
865 saveFilescxx . . $ saveFiles.[z].scorecxx . . $ $anonymous_type_5227559294d527ce_2#score. = SDL_SwapLE32cxx . . $ `<external>/7875807700584907893/SDL_endian.h:369:9`!(saveFiles[z].score);
866
867 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].score2cxx . . $ $anonymous_type_5227559294d527ce_2#score2., p, sizeof(JE_longintcxx . . $ JE_longint#)); p += 4;
868 saveFilescxx . . $ saveFiles.[z].score2cxx . . $ $anonymous_type_5227559294d527ce_2#score2. = SDL_SwapLE32cxx . . $ `<external>/7875807700584907893/SDL_endian.h:369:9`!(saveFiles[z].score2);
869
870 /* SYN: Pascal strings are prefixed by a byte holding the length! */
871 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&saveFilescxx . . $ saveFiles.[z].levelNamecxx . . $ $anonymous_type_5227559294d527ce_2#levelName., 0, sizeof(saveFilescxx . . $ saveFiles.[z].levelNamecxx . . $ $anonymous_type_5227559294d527ce_2#levelName.));
872 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].levelNamecxx . . $ $anonymous_type_5227559294d527ce_2#levelName., &p[1], *p);
873 p += 10;
874
875 /* This was a BYTE array, not a STRING, in the original. Go fig. */
876 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].namecxx . . $ $anonymous_type_5227559294d527ce_2#name., p, 14);
877 p += 14;
878
879 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].cubescxx . . $ $anonymous_type_5227559294d527ce_2#cubes., p, sizeof(JE_bytecxx . . $ JE_byte#)); p++;
880 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].powercxx . . $ $anonymous_type_5227559294d527ce_2#power., p, sizeof(JE_bytecxx . . $ JE_byte#) * 2); p += 2;
881 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].episodecxx . . $ $anonymous_type_5227559294d527ce_2#episode., p, sizeof(JE_bytecxx . . $ JE_byte#)); p++;
882 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].lastItemscxx . . $ $anonymous_type_5227559294d527ce_2#lastItems., p, sizeof(JE_PItemsTypecxx . . $ JE_PItemsType#)); p += sizeof(JE_PItemsTypecxx . . $ JE_PItemsType#);
883 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].difficultycxx . . $ $anonymous_type_5227559294d527ce_2#difficulty., p, sizeof(JE_bytecxx . . $ JE_byte#)); p++;
884 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].secretHintcxx . . $ $anonymous_type_5227559294d527ce_2#secretHint., p, sizeof(JE_bytecxx . . $ JE_byte#)); p++;
885 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].input1cxx . . $ $anonymous_type_5227559294d527ce_2#input1., p, sizeof(JE_bytecxx . . $ JE_byte#)); p++;
886 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].input2cxx . . $ $anonymous_type_5227559294d527ce_2#input2., p, sizeof(JE_bytecxx . . $ JE_byte#)); p++;
887
888 /* booleans were 1 byte in pascal -- working around it */
889 Uint8cxx . . $ Uint8# temp;
890 memcpycxx . . $ memcpy(cc817cb175f282d).(&temp, p, 1); p++;
891 saveFilescxx . . $ saveFiles.[z].gameHasRepeatedcxx . . $ $anonymous_type_5227559294d527ce_2#gameHasRepeated. = temp != 0;
892
893 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].initialDifficultycxx . . $ $anonymous_type_5227559294d527ce_2#initialDifficulty., p, sizeof(JE_bytecxx . . $ JE_byte#)); p++;
894
895 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].highScore1cxx . . $ $anonymous_type_5227559294d527ce_2#highScore1., p, sizeof(JE_longintcxx . . $ JE_longint#)); p += 4;
896 saveFilescxx . . $ saveFiles.[z].highScore1cxx . . $ $anonymous_type_5227559294d527ce_2#highScore1. = SDL_SwapLE32cxx . . $ `<external>/7875807700584907893/SDL_endian.h:369:9`!(saveFiles[z].highScore1);
897
898 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].highScore2cxx . . $ $anonymous_type_5227559294d527ce_2#highScore2., p, sizeof(JE_longintcxx . . $ JE_longint#)); p += 4;
899 saveFilescxx . . $ saveFiles.[z].highScore2cxx . . $ $anonymous_type_5227559294d527ce_2#highScore2. = SDL_SwapLE32cxx . . $ `<external>/7875807700584907893/SDL_endian.h:369:9`!(saveFiles[z].highScore2);
900
901 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&saveFilescxx . . $ saveFiles.[z].highScoreNamecxx . . $ $anonymous_type_5227559294d527ce_2#highScoreName., 0, sizeof(saveFilescxx . . $ saveFiles.[z].highScoreNamecxx . . $ $anonymous_type_5227559294d527ce_2#highScoreName.));
902 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].highScoreNamecxx . . $ $anonymous_type_5227559294d527ce_2#highScoreName., &p[1], *p);
903 p += 30;
904
905 memcpycxx . . $ memcpy(cc817cb175f282d).(&saveFilescxx . . $ saveFiles.[z].highScoreDiffcxx . . $ $anonymous_type_5227559294d527ce_2#highScoreDiff., p, sizeof(JE_bytecxx . . $ JE_byte#)); p++;
906 }
907
908 /* SYN: This is truncating to bytes. I have no idea what this is doing or why. */
909 /* TODO: Figure out what this is about and make sure it isn't broken. */
910 editorLevelcxx . . $ editorLevel. = (saveTempcxx . . $ saveTemp.[SIZEOF_SAVEGAMETEMPcxx . . $ `src/config.h:34:9`! - 5] << 8) | saveTempcxx . . $ saveTemp.[SIZEOF_SAVEGAMETEMPcxx . . $ `src/config.h:34:9`! - 6];
911
912 fclosecxx . . $ fclose(89bc1efcdac0ca22).(fi);
913 }
914 else
915 {
916 /* We didn't have a save file! Let's make up random stuff! */
917 editorLevelcxx . . $ editorLevel. = 800;
918
919 for (z = 0; z < 100; z++)
920 {
921 saveTempcxx . . $ saveTemp.[SAVE_FILES_SIZEcxx . . $ `src/config.h:33:9`! + z] = initialItemAvailcxx . . $ initialItemAvail.[z];
922 }
923
924 for (z = 0; z < SAVE_FILES_NUMcxx . . $ `src/config.h:29:9`!; z++)
925 {
926 saveFilescxx . . $ saveFiles.[z].levelcxx . . $ $anonymous_type_5227559294d527ce_2#level. = 0;
927
928 for (y = 0; y < 14; y++)
929 {
930 saveFilescxx . . $ saveFiles.[z].namecxx . . $ $anonymous_type_5227559294d527ce_2#name.[y] = ' ';
931 }
932 saveFilescxx . . $ saveFiles.[z].namecxx . . $ $anonymous_type_5227559294d527ce_2#name.[14] = 0;
933
934 saveFilescxx . . $ saveFiles.[z].highScore1cxx . . $ $anonymous_type_5227559294d527ce_2#highScore1. = ((mt_randcxx . . $ mt_rand(f708dce9a8856c70).() % 20) + 1) * 1000;
935
936 if (z % 6 > 2)
937 {
938 saveFilescxx . . $ saveFiles.[z].highScore2cxx . . $ $anonymous_type_5227559294d527ce_2#highScore2. = ((mt_randcxx . . $ mt_rand(f708dce9a8856c70).() % 20) + 1) * 1000;
939 strcpycxx . . $ strcpy(b7b3a83273496486).(saveFilescxx . . $ saveFiles.[z].highScoreNamecxx . . $ $anonymous_type_5227559294d527ce_2#highScoreName., defaultTeamNamescxx . . $ defaultTeamNames.[mt_randcxx . . $ mt_rand(f708dce9a8856c70).() % 22]);
940 }
941 else
942 {
943 strcpycxx . . $ strcpy(b7b3a83273496486).(saveFilescxx . . $ saveFiles.[z].highScoreNamecxx . . $ $anonymous_type_5227559294d527ce_2#highScoreName., defaultHighScoreNamescxx . . $ defaultHighScoreNames.[mt_randcxx . . $ mt_rand(f708dce9a8856c70).() % 34]);
944 }
945 }
946 }
947
948 JE_initProcessorTypecxx . . $ JE_initProcessorType(49f6e7a06ebc5aa8).();
949 }
950
951 void JE_saveConfigurationcxx . . $ JE_saveConfiguration(49f6e7a06ebc5aa8).(void)
952 {
953 FILEcxx . . $ FILE# *f;
954 JE_bytecxx . . $ JE_byte# *p;
955 int z;
956
957 p = saveTempcxx . . $ saveTemp.;
958 for (z = 0; z < SAVE_FILES_NUMcxx . . $ `src/config.h:29:9`!; z++)
959 {
960 JE_SaveFileTypecxx . . $ JE_SaveFileType# tempSaveFile;
961 memcpycxx . . $ memcpy(cc817cb175f282d).(&tempSaveFile, &saveFilescxx . . $ saveFiles.[z], sizeof(tempSaveFile));
962
963 tempSaveFile.encodecxx . . $ $anonymous_type_5227559294d527ce_2#encode. = SDL_SwapLE16cxx . . $ `<external>/7875807700584907893/SDL_endian.h:368:9`!(tempSaveFile.encode);
964 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.encodecxx . . $ $anonymous_type_5227559294d527ce_2#encode., sizeof(JE_wordcxx . . $ JE_word#)); p += 2;
965
966 tempSaveFile.levelcxx . . $ $anonymous_type_5227559294d527ce_2#level. = SDL_SwapLE16cxx . . $ `<external>/7875807700584907893/SDL_endian.h:368:9`!(tempSaveFile.level);
967 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.levelcxx . . $ $anonymous_type_5227559294d527ce_2#level., sizeof(JE_wordcxx . . $ JE_word#)); p += 2;
968
969 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.itemscxx . . $ $anonymous_type_5227559294d527ce_2#items., sizeof(JE_PItemsTypecxx . . $ JE_PItemsType#)); p += sizeof(JE_PItemsTypecxx . . $ JE_PItemsType#);
970
971 tempSaveFile.scorecxx . . $ $anonymous_type_5227559294d527ce_2#score. = SDL_SwapLE32cxx . . $ `<external>/7875807700584907893/SDL_endian.h:369:9`!(tempSaveFile.score);
972 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.scorecxx . . $ $anonymous_type_5227559294d527ce_2#score., sizeof(JE_longintcxx . . $ JE_longint#)); p += 4;
973
974 tempSaveFile.score2cxx . . $ $anonymous_type_5227559294d527ce_2#score2. = SDL_SwapLE32cxx . . $ `<external>/7875807700584907893/SDL_endian.h:369:9`!(tempSaveFile.score2);
975 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.score2cxx . . $ $anonymous_type_5227559294d527ce_2#score2., sizeof(JE_longintcxx . . $ JE_longint#)); p += 4;
976
977 /* SYN: Pascal strings are prefixed by a byte holding the length! */
978 memsetcxx . . $ memset(d1de1e4fb215f1c6).(p, 0, sizeof(tempSaveFile.levelNamecxx . . $ $anonymous_type_5227559294d527ce_2#levelName.));
979 *p = strlencxx . . $ strlen(751346f8406fd082).(tempSaveFile.levelNamecxx . . $ $anonymous_type_5227559294d527ce_2#levelName.);
980 memcpycxx . . $ memcpy(cc817cb175f282d).(&p[1], &tempSaveFile.levelNamecxx . . $ $anonymous_type_5227559294d527ce_2#levelName., *p);
981 p += 10;
982
983 /* This was a BYTE array, not a STRING, in the original. Go fig. */
984 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.namecxx . . $ $anonymous_type_5227559294d527ce_2#name., 14);
985 p += 14;
986
987 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.cubescxx . . $ $anonymous_type_5227559294d527ce_2#cubes., sizeof(JE_bytecxx . . $ JE_byte#)); p++;
988 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.powercxx . . $ $anonymous_type_5227559294d527ce_2#power., sizeof(JE_bytecxx . . $ JE_byte#) * 2); p += 2;
989 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.episodecxx . . $ $anonymous_type_5227559294d527ce_2#episode., sizeof(JE_bytecxx . . $ JE_byte#)); p++;
990 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.lastItemscxx . . $ $anonymous_type_5227559294d527ce_2#lastItems., sizeof(JE_PItemsTypecxx . . $ JE_PItemsType#)); p += sizeof(JE_PItemsTypecxx . . $ JE_PItemsType#);
991 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.difficultycxx . . $ $anonymous_type_5227559294d527ce_2#difficulty., sizeof(JE_bytecxx . . $ JE_byte#)); p++;
992 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.secretHintcxx . . $ $anonymous_type_5227559294d527ce_2#secretHint., sizeof(JE_bytecxx . . $ JE_byte#)); p++;
993 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.input1cxx . . $ $anonymous_type_5227559294d527ce_2#input1., sizeof(JE_bytecxx . . $ JE_byte#)); p++;
994 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.input2cxx . . $ $anonymous_type_5227559294d527ce_2#input2., sizeof(JE_bytecxx . . $ JE_byte#)); p++;
995
996 /* booleans were 1 byte in pascal -- working around it */
997 Uint8cxx . . $ Uint8# temp = tempSaveFile.gameHasRepeatedcxx . . $ $anonymous_type_5227559294d527ce_2#gameHasRepeated. != falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
998 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &temp, 1); p++;
999
1000 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.initialDifficultycxx . . $ $anonymous_type_5227559294d527ce_2#initialDifficulty., sizeof(JE_bytecxx . . $ JE_byte#)); p++;
1001
1002 tempSaveFile.highScore1cxx . . $ $anonymous_type_5227559294d527ce_2#highScore1. = SDL_SwapLE32cxx . . $ `<external>/7875807700584907893/SDL_endian.h:369:9`!(tempSaveFile.highScore1);
1003 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.highScore1cxx . . $ $anonymous_type_5227559294d527ce_2#highScore1., sizeof(JE_longintcxx . . $ JE_longint#)); p += 4;
1004
1005 tempSaveFile.highScore2cxx . . $ $anonymous_type_5227559294d527ce_2#highScore2. = SDL_SwapLE32cxx . . $ `<external>/7875807700584907893/SDL_endian.h:369:9`!(tempSaveFile.highScore2);
1006 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.highScore2cxx . . $ $anonymous_type_5227559294d527ce_2#highScore2., sizeof(JE_longintcxx . . $ JE_longint#)); p += 4;
1007
1008 memsetcxx . . $ memset(d1de1e4fb215f1c6).(p, 0, sizeof(tempSaveFile.highScoreNamecxx . . $ $anonymous_type_5227559294d527ce_2#highScoreName.));
1009 *p = strlencxx . . $ strlen(751346f8406fd082).(tempSaveFile.highScoreNamecxx . . $ $anonymous_type_5227559294d527ce_2#highScoreName.);
1010 memcpycxx . . $ memcpy(cc817cb175f282d).(&p[1], &tempSaveFile.highScoreNamecxx . . $ $anonymous_type_5227559294d527ce_2#highScoreName., *p);
1011 p += 30;
1012
1013 memcpycxx . . $ memcpy(cc817cb175f282d).(p, &tempSaveFile.highScoreDiffcxx . . $ $anonymous_type_5227559294d527ce_2#highScoreDiff., sizeof(JE_bytecxx . . $ JE_byte#)); p++;
1014 }
1015
1016 saveTempcxx . . $ saveTemp.[SIZEOF_SAVEGAMETEMPcxx . . $ `src/config.h:34:9`! - 6] = editorLevelcxx . . $ editorLevel. >> 8;
1017 saveTempcxx . . $ saveTemp.[SIZEOF_SAVEGAMETEMPcxx . . $ `src/config.h:34:9`! - 5] = editorLevelcxx . . $ editorLevel.;
1018
1019 JE_encryptSaveTempcxx . . $ JE_encryptSaveTemp(49f6e7a06ebc5aa8).();
1020
1021 #ifndef TARGET_WIN32
1022 mkdircxx . . $ mkdir(1df18506ef0a631b).(get_user_directorycxx . . $ get_user_directory(33a1f659e94feb42).(), 0700);
1023 #else
1024 mkdir(get_user_directory());
1025 #endif
1026
1027 f = dir_fopen_warncxx . . $ dir_fopen_warn(2493aa730c89ee72).(get_user_directorycxx . . $ get_user_directory(33a1f659e94feb42).(), "tyrian.sav", "wb");
1028 if (f != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
1029 {
1030 fwrite_diecxx . . $ fwrite_die(8541cce38b5beb5e).(saveTempcxx . . $ saveTemp., 1, sizeof(saveTempcxx . . $ saveTemp.), f);
1031
1032 #if _POSIX_C_SOURCEcxx . . $ `<external>/18206667465210621810/features.h:313:10`! >= 1 || _XOPEN_SOURCEcxx . . $ `<external>/18206667465210621810/features.h:228:10`! || _POSIX_SOURCEcxx . . $ `<external>/18206667465210621810/features.h:311:10`!
1033 fsynccxx . . $ fsync(7864480464b09eea).(filenocxx . . $ fileno(89bc1efcdac0ca22).(f));
1034 #endif
1035 fclosecxx . . $ fclose(89bc1efcdac0ca22).(f);
1036 }
1037
1038 JE_decryptSaveTempcxx . . $ JE_decryptSaveTemp(49f6e7a06ebc5aa8).();
1039
1040 f = dir_fopen_warncxx . . $ dir_fopen_warn(2493aa730c89ee72).(get_user_directorycxx . . $ get_user_directory(33a1f659e94feb42).(), "tyrian.cfg", "wb");
1041 if (f != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
1042 {
1043 fwrite_bool_diecxx . . $ fwrite_bool_die(d02cc9ace855460f).(&background2cxx . . $ background2., f);
1044 fwrite_u8_diecxx . . $ fwrite_u8_die(a9c0feb52dde6622).(&gameSpeedcxx . . $ gameSpeed., 1, f);
1045
1046 fwrite_u8_diecxx . . $ fwrite_u8_die(a9c0feb52dde6622).(&inputDevice_cxx . . $ inputDevice_., 1, f);
1047 fwrite_u8_diecxx . . $ fwrite_u8_die(a9c0feb52dde6622).(&jConfigurecxx . . $ jConfigure., 1, f);
1048
1049 fwrite_u8_diecxx . . $ fwrite_u8_die(a9c0feb52dde6622).(&versionNumcxx . . $ versionNum., 1, f);
1050 fwrite_u8_diecxx . . $ fwrite_u8_die(a9c0feb52dde6622).(&processorTypecxx . . $ processorType., 1, f);
1051 fwrite_u8_diecxx . . $ fwrite_u8_die(a9c0feb52dde6622).(&midiPortcxx . . $ midiPort., 1, f);
1052 fwrite_u8_diecxx . . $ fwrite_u8_die(a9c0feb52dde6622).(&soundEffectscxx . . $ soundEffects., 1, f);
1053 fwrite_u8_diecxx . . $ fwrite_u8_die(a9c0feb52dde6622).(&gammaCorrectioncxx . . $ gammaCorrection., 1, f);
1054 fwrite_s8_diecxx . . $ fwrite_s8_die(c6d81d9f7f466d04).(&difficultyLevelcxx . . $ difficultyLevel., 1, f);
1055 fwrite_u8_diecxx . . $ fwrite_u8_die(a9c0feb52dde6622).(joyButtonAssigncxx . . $ joyButtonAssign., 4, f);
1056
1057 fwrite_u16_diecxx . . $ fwrite_u16_die(79016506b65b1ae8).(&tyrMusicVolumecxx . . $ tyrMusicVolume., f);
1058 fwrite_u16_diecxx . . $ fwrite_u16_die(79016506b65b1ae8).(&fxVolumecxx . . $ fxVolume., f);
1059
1060 fwrite_u8_diecxx . . $ fwrite_u8_die(a9c0feb52dde6622).(inputDevicecxx . . $ inputDevice., 2, f);
1061
1062 fwrite_u8_diecxx . . $ fwrite_u8_die(a9c0feb52dde6622).(dosKeySettingscxx . . $ dosKeySettings., 8, f);
1063
1064 #if _POSIX_C_SOURCEcxx . . $ `<external>/18206667465210621810/features.h:313:10`! >= 1 || _XOPEN_SOURCEcxx . . $ `<external>/18206667465210621810/features.h:228:10`! || _POSIX_SOURCEcxx . . $ `<external>/18206667465210621810/features.h:311:10`!
1065 fsynccxx . . $ fsync(7864480464b09eea).(filenocxx . . $ fileno(89bc1efcdac0ca22).(f));
1066 #endif
1067 fclosecxx . . $ fclose(89bc1efcdac0ca22).(f);
1068 }
1069
1070 save_opentyrian_configcxx . . $ save_opentyrian_config(c9857a73d68e59ba).();
1071 }